-
Notifications
You must be signed in to change notification settings - Fork 5.5k
[FLASK] Implement offscreen execution service for running Snaps in MV3 #17008
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Currently pending a merge and release of MetaMask/snaps#1082. |
b42fcc5 to
ff1b0bc
Compare
package.json
Outdated
| "lockfile-lint-api@^5.4.6": "patch:lockfile-lint-api@npm%3A5.4.6#./.yarn/patches/lockfile-lint-api-npm-5.4.6-dc86b73900.patch", | ||
| "symbol-observable": "^2.0.3" | ||
| "symbol-observable": "^2.0.3", | ||
| "@metamask/post-message-stream": "^6.1.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be removed once MetaMask/snaps#1082 is merged and released.
72be8f3 to
40af0a7
Compare
|
@Mrtenz MetaMask/snaps#1082 has been merged. What is the remaining action on this? |
|
@Mrtenz hey there. I'm closing drafts that haven't received commits within the last 90 days. If this can be updated to be reconsidered please do that and reopen the PR! |
bbc8766 to
a2760bb
Compare
|
@metamaskbot update-policies |
|
Policy update failed. You can review the logs or retry the policy update here |
|
@metamaskbot update-policies |
|
Policies updated |
f8672df to
bdeb9bc
Compare
|
@metamaskbot update-policies |
|
Policies updated |
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## develop #17008 +/- ##
===========================================
- Coverage 68.83% 68.58% -0.25%
===========================================
Files 1035 1030 -5
Lines 41194 41042 -152
Branches 10991 10964 -27
===========================================
- Hits 28353 28147 -206
- Misses 12841 12895 +54
☔ View full report in Codecov by Sentry. |
Builds ready [7d0e814]
Page Load Metrics (1444 ± 414 ms)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
|
@Mrtenz I think i've got this working for the normal build types, but not sure if the MV3 route with snaps gets tested. Should we add that to this PR to ensure the offscreen communication is working for snaps? |
7d0e814 to
5bfd552
Compare
|
New dependencies detected. Learn more about Socket for GitHub ↗︎
|
|
🚨 Potential security issues detected. Learn more about Socket for GitHub ↗︎ To accept the risk, merge this PR and you will not be notified again.
Next stepsWhat is network access?This module accesses the network. Packages should remove all network access that is functionally unnecessary. Consumers should audit network access to ensure legitimate use. Take a deeper look at the dependencyTake a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support [AT] socket [DOT] dev. Remove the packageIf you happen to install a dependency that Socket reports as Known Malware you should immediately remove it and select a different dependency. For other alert types, you may may wish to investigate alternative packages or consider if there are other ways to mitigate the specific risk posed by the dependency. Mark a package as acceptable riskTo ignore an alert, reply with a comment starting with
|
## **Description** For MV3 snaps and Hardware wallet functionality we need to run some sets of code in an offscreen document that can communicate with the extension. The purpose of this Pull request is to start the conversation about how to build this. This PR should be a stepping stone for the fundamentals of #17687 and #17008 to incrementally be adopted. The idea here is that we create a new "entry point" into the application in the way of this offscreen.html file. There is a offscreen.ts file that can be used to initialize a PostMessageStream for the iframe itself, which is done in #17008. Essentially the snaps-execution-environment offscreen document sets up lockdown and then initializes the OffscreenSnapExecutor with its PostMessageStream. These pieces can be added in a future PR, although I might need some guidance on the proper way to setup lockdown. In terms of Hardware wallet support, the iframes in #17687 and the supporting typescript files can be included in layers ontop of this folder structure, eventually getting to full hardware wallet support but we should tackle these one at a time. There are a couple PRs opened by @mikesposito to upgrade trezor and ledger keyrings that are also piecing out elements from #17687 that are prereqs for continuing HW support in MV3. This uses post-message-stream which will later be used as well for snaps execution in the offscreen document. ## **Related issues** Partially progresses #21622 ## **Manual testing steps** 1. run `yarn start:mv3` 2. Go to extensions in chrome. 3. You should see both a service-worker and offscreen.html file loaded and be able to inspect both. 4. Open both windows. From the service-worker console, run `chrome.runtime.sendMessage({target: 'child', data: 'test'})` 5. See that the offscreen.html console logs the message. 6. From the offscreen console, run `chrome.runtime.sendMessage({target: 'parent', data: 'test'})` 7. See that the service worker console logs the message. ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** - [x] I’ve followed [MetaMask Coding Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md). - [x] I've clearly explained what problem this PR is solving and how it is solved. - [x] I've linked related issues - [x] I've included manual testing steps - [x] I've included screenshots/recordings if applicable - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. - [x] I’ve properly set the pull request status: - [ ] In case it's not yet "ready for review", I've set it to "draft". - [x] In case it's "ready for review", I've changed it from "draft" to "non-draft". ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.
|
This PR has been automatically marked as stale because it has not had recent activity in the last 60 days. It will be closed in 14 days. Thank you for your contributions. |
|
New implementation in #22732 borrowing heavily from this PR and with collaboration with snaps team |
Explanation
This implements the offscreen execution service in order to run Snaps in MV3. It uses the offscreen document API to create a new window, where the snaps are run.
Manual Testing Steps
yarn start:mv3 --build-type=flask.Pre-merge author checklist
Pre-merge reviewer checklist