web-monetization-projects
web-monetization-projects copied to clipboard
ilp-plugin-btp/ilp-protocol-stream require window object in MV3
An object of class IlpPluginBtp from package ilp-plugin-btp cannot be initialized in the service worker of a mv3 chrome extension.
Reason: Uncaught ReferenceError: window is not defined
It requires a window object which is not present in the service worker.
Temporary resolutions
unplug these packages ilp-plugin-btp and ilp-protocol-stream with yarn unplug <package_name>
in ilp-plugin-btp: replace const {crypto} = window
with const{crypto} = self
in file crypto.js
in ilp-protocol-stream: replace const {crypto} = window
with const{crypto} = self
in file crypto-browser.js
TODO
We will need to patch the ILP libs upstream to officially support Service Workers
Look into exports
field of package.json and see if it supports a worker "condition" export and see if can make PRs to respective repositories:
- [ ] ilp-plugin-btp
- [ ] ilp-protocol-stream