lightning-browser-extension
lightning-browser-extension copied to clipboard
refactor!: manifest v3 support #1051
~CURRENT FINDINGS~ ALL GOOD SO FAR
- ~Axios doesn't seem to work in background-scripts, might need to switch (back) to fetch~: https://stackoverflow.com/questions/66305856/typeerror-adapter-is-not-a-function-error-when-using-axios-and-webpack-in-chrom/70206333#70206333
- ~No (extrenal) images~
- ~No external API calls~

- ~Just switching current code to use web workers doesn't work~

Describe the changes you have made in this PR
Trying to prepare the switch to v3
Link this PR to an issue
#1051
Type of change (Remove other not matching type)
refactor: Breaking refactor
How has this been tested?
...not yet
Checklist
- [ ] My code follows the style guidelines of this project and performed a self-review of my own code
- [ ] New and existing tests pass locally with my changes
- [ ] I checked if I need to make corresponding changes to the documentation (and made those changes if needed)
🚀 Thanks for the pull request!
Here are the current build files for testing:
Download and unzip the file for your browser. Refer to the readme for detailed install instructions.
This build is brought to you by: Moritz (who recently dropped 1000 sats):
Merry Christmas to the Alby team
Want to sponsor the next build? send some sats to ⚡️[email protected] (don't forget to provide your name)
Don't forget: keep earning sats!
The message when an incorrect password is entered contains extra information 
that's if you try to signup with a @getalby.com email. which is prevented now.
also ideally check the same on the master branch to see if it is releated to v3
@bumi ok, will do! signup was with a LN address instead of email with a regular email it's ok
there is no sigunp with a lightning address (you can login with a lightning address, but not signup) and there is no user support@
yes, I meant log in, sorry.
Also, the Extension autolocks in a couple of minutes. And when it does (or if I lock it myself) - it gives this when trying to create or login to my Alby account
and these messages about the actions during the lock

that sounds like the background script/worker or such is no longer running. can you always post the logs? https://guides.getalby.com/overall-guide/alby-browser-extension/debugging/alby-on-google-chrome
oh sure
is that ok if I do it like that?

Thanks for testing @AnastasiaVolk !
Apart from the auto-logout, did the basic functionality work as expected?
As bumi said,this might be related to "servceWorkers" are being shut down, which we should be able to avoid as @bumi already pointed out via the metamask code.
I'll focus on that next time I work on this.
- https://developer.chrome.com/docs/extensions/mv3/mv2-sunset/
- https://twitter.com/search?q=manifest%20v3&src=typed_query&f=top
- https://github.com/search?q=%22chrome.storage.session%22&type=Code
- https://github.com/belaviyo/v3tov2
- https://bugs.chromium.org/p/chromium/issues/detail?id=1152255
- https://developer.chrome.com/docs/extensions/reference/storage/#property-session
Steps to reproduce the "receiving end does not exist" error:
- Install extension & password-pin and account
- Do not open any devtools
- Wait ~5 minutes
- Open: chrome://extensions/ and see "service worker (inactive)"
- Click extension icon
- See extension is locked and see error
Force the error:
- Install extension & password-pin and account
- Open: chrome://extensions/ and see "service worker"
- Open: chrome://inspect/#service-workers and see "Service Worker chrome-extension://bbi...mjic/js/background.bundle.js"
- terminate that service worker
- Open: chrome://extensions/ and see "service worker (inactive)"
- Click extension icon
- See extension is locked and see error
chrome.strorage....needs to be replaced by browser
Everything's green but adding commando connector.
Fails with:

Narrowing it down to lnmessage. Could be this:
- https://github.com/aaronbarnardsound/lnmessage/blob/master/src/index.ts#L437
- https://github.com/aaronbarnardsound/lnmessage/blob/master/src/crypto.ts/#L20
- https://github.com/aaronbarnardsound/lnmessage/blob/master/src/crypto.ts/#L103
Using crypto instead of window.crypto solves this issue.
PR here: https://github.com/aaronbarnardsound/lnmessage/pull/12
-> fixed with patch-package for now
Manifest adaption done 😱
This needs testing now.
Testing:
- Works after service-worker is being shut down: https://github.com/getAlby/lightning-browser-extension/pull/1124#issuecomment-1305803446
await webln.enable()- Invoice creation
- Add commando connector
- nostr
I see this error on Chrome:
is three the manifest file not perfectly correct?
I see this error on Chrome
What's the error? Where do you see it? The marked line should be valid mv3.
I assume: it should not be content_security_policy.extension_pages but rather something like:
"content_security_policy": {
"extension_pages": "...",
and google chrome tells this as error. (in the "errors" of the extension.)
Unrecognized manifest key 'content_security_policy.extension_pages'.
and google chrome tells this as error. (in the "errors" of the extension.)
Unrecognized manifest key 'content_security_policy.extension_pages'.
Thanks! Fixed. Didn't know about the "errors" button...
Did we test this with all possible connectors already?
Did we test this with all possible connectors already?
I did not, not sure if @AnastasiaVolk tested with all connectors
OK, likely we then need to test it in:
- [ ] LND
- [ ] CLN/Commando
- [ ] Eclair
- [ ] LNBits
- [ ] BlueWallet
and because this is a big change that also can not be undone I think it would be good if we all check it out and try everything.
Tested with LND (albydev/testnet) and CLN:
- nostr
- send
- invoice creation
CLN throws an error when sending to our ln-address but that's also the case on current master.
Let's do a final round of testing and get this ready for the release. I just prepared a little testing matrix:
| Chrome (Windows) | Chrome (Mac) | Chrome (Linux) | Firefox (Windows) | Firefox (Mac) | Firefox (Linux) | TOR Browser | |
|---|---|---|---|---|---|---|---|
| LND | ✅ | ✅ (missing "TOR Connection" test) | ✅ (missing "TOR Connection" test) | ||||
| LNC | |||||||
| LNDHub | ✅ | ✅ (missing "TOR Connection" test) | ✅ (missing "TOR Connection" test) | ✅ | |||
| Core Lightning | ✅ | ✅ (missing "TOR Connection" test, QR code not working but its a known issue) | ✅ (missing "TOR Connection" test, QR code not working but its a known issue) | ||||
| LNbits | ✅ | ✅ (missing "TOR Connection" test) | ✅ (missing "TOR Connection" test) | ||||
| Kollider | |||||||
| Eclair | |||||||
| Umbrel | ✅ | ✅ | |||||
| BTCPay Server | ✅ | ✅ |
I don't think we have to tick all boxes here, but I'd like to have some overview about what exactly we tested. Please just update this table accordingly ☝️
Things that should be tested:
- Invoice generation
- Sending & receiving payments
- WebLN integration
- Nostr integration
- Permissions
- Extension permissions (scan QR code)
- TOR Connections via Alby Companion
- Batteries (tipping on youtube, etc)
Please also test:
- change password
- lock/unlock