lightning-browser-extension icon indicating copy to clipboard operation
lightning-browser-extension copied to clipboard

refactor!: manifest v3 support #1051

Open escapedcat opened this issue 3 years ago • 14 comments

~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~ image
  • ~Just switching current code to use web workers doesn't work~
    image

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)

escapedcat avatar Jul 08 '22 07:07 escapedcat

Build files:

github-actions[bot] avatar Jul 08 '22 07:07 github-actions[bot]

🚀 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!

github-actions[bot] avatar Aug 23 '22 06:08 github-actions[bot]

The message when an incorrect password is entered contains extra information Screenshot 2022-10-11 at 12 59 50

AnastasiaVolk avatar Oct 11 '22 10:10 AnastasiaVolk

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 avatar Oct 11 '22 10:10 bumi

@bumi ok, will do! signup was with a LN address instead of email with a regular email it's ok

AnastasiaVolk avatar Oct 11 '22 10:10 AnastasiaVolk

there is no sigunp with a lightning address (you can login with a lightning address, but not signup) and there is no user support@

bumi avatar Oct 11 '22 10:10 bumi

yes, I meant log in, sorry.

AnastasiaVolk avatar Oct 11 '22 10:10 AnastasiaVolk

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 accountScreenshot 2022-10-11 at 13 36 18

AnastasiaVolk avatar Oct 11 '22 10:10 AnastasiaVolk

and these messages about the actions during the lock Screenshot 2022-10-11 at 13 40 26

AnastasiaVolk avatar Oct 11 '22 10:10 AnastasiaVolk

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

bumi avatar Oct 11 '22 11:10 bumi

oh sure

AnastasiaVolk avatar Oct 11 '22 12:10 AnastasiaVolk

Screenshot 2022-10-11 at 15 42 09 is that ok if I do it like that?

AnastasiaVolk avatar Oct 11 '22 12:10 AnastasiaVolk

Screenshot 2022-10-11 at 15 57 22 Screenshot 2022-10-11 at 15 55 35

AnastasiaVolk avatar Oct 11 '22 12:10 AnastasiaVolk

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.

escapedcat avatar Oct 12 '22 04:10 escapedcat

  • 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

bumi avatar Oct 27 '22 12:10 bumi

  • https://developer.chrome.com/docs/extensions/reference/storage/#property-session

escapedcat avatar Oct 28 '22 12:10 escapedcat

Steps to reproduce the "receiving end does not exist" error:

  1. Install extension & password-pin and account
  2. Do not open any devtools
  3. Wait ~5 minutes
  4. Open: chrome://extensions/ and see "service worker (inactive)"
  5. Click extension icon
  6. See extension is locked and see error

Force the error:

  1. Install extension & password-pin and account
  2. Open: chrome://extensions/ and see "service worker"
  3. Open: chrome://inspect/#service-workers and see "Service Worker chrome-extension://bbi...mjic/js/background.bundle.js"
  4. terminate that service worker
  5. Open: chrome://extensions/ and see "service worker (inactive)"
  6. Click extension icon
  7. See extension is locked and see error

escapedcat avatar Nov 07 '22 15:11 escapedcat

  • chrome.strorage.... needs to be replaced by browser

escapedcat avatar Nov 11 '22 16:11 escapedcat

Everything's green but adding commando connector.
Fails with: image

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

escapedcat avatar Nov 17 '22 10:11 escapedcat

Manifest adaption done 😱
This needs testing now.

escapedcat avatar Nov 17 '22 14:11 escapedcat

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

escapedcat avatar Nov 19 '22 15:11 escapedcat

I see this error on Chrome: image is three the manifest file not perfectly correct?

bumi avatar Nov 20 '22 23:11 bumi

I see this error on Chrome

What's the error? Where do you see it? The marked line should be valid mv3.

escapedcat avatar Nov 21 '22 09:11 escapedcat

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'.

bumi avatar Nov 22 '22 04:11 bumi

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...

escapedcat avatar Nov 22 '22 09:11 escapedcat

Did we test this with all possible connectors already?

bumi avatar Dec 13 '22 09:12 bumi

Did we test this with all possible connectors already?

I did not, not sure if @AnastasiaVolk tested with all connectors

escapedcat avatar Dec 13 '22 09:12 escapedcat

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.

bumi avatar Dec 13 '22 09:12 bumi

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.

escapedcat avatar Dec 13 '22 16:12 escapedcat

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

reneaaron avatar Jan 19 '23 10:01 reneaaron