Page MenuHomePhabricator

[Cashtab] Modify extension manifest to support wasm
ClosedPublic

Authored by bytesofman on May 31 2024, 22:35.

Details

Reviewers
emack
Group Reviewers
Restricted Project
Commits
rABC76f4e678863e: [Cashtab] Modify extension manifest to support wasm
Summary

Chrome extensions do not automatically allow wasm execution. This must be specified in a CSP directive in the manifest.

Ref https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy

The wasm-unsafe-eval directive, while scary looking, "Allows the loading and execution of WebAssembly modules without the need to also allow unsafe JavaScript execution"

The web assembly is a bit of a black box -- however we are building it from a trusted source.

Test Plan

npm run extension, load manually, it works

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

bytesofman added inline comments.
cashtab/extension/public/manifest.json
29 ↗(On Diff #48067)

note that the policy I have added here was the default policy of chrome extensions until Chrome 103

https://developer.chrome.com/docs/extensions/reference/manifest/content-security-policy

https://developer.chrome.com/docs/extensions/whats-new#m103-wasm-csp

Essentially we are declaring in the manifest that this extension uses web assembly.

emack requested changes to this revision.Jun 1 2024, 02:13
emack added a subscriber: emack.

The local extension build fails as it can't find ecash-lib, even after I've npm ci'ed already. I assume this is likely to be a relative path issue?

image.png (599×854 px, 83 KB)

This revision now requires changes to proceed.Jun 1 2024, 02:13

The local extension build fails as it can't find ecash-lib, even after I've npm ci'ed already. I assume this is likely to be a relative path issue?

image.png (599×854 px, 83 KB)

most likely ecash-lib is not built locally. I don't have the same issue, and Cashtab builds ok in the docker container now.

cd modules/ecash-lib-wasm
./dockerbuild.sh
cd ../ecash-lib
npm run build
cd ../../cashtab
npm run extension

does npm run build work in Cashtab but npm run extension fails?

cd modules/ecash-lib-wasm
./dockerbuild.sh
cd ../ecash-lib
npm run build
cd ../../cashtab
npm run extension

Yup it was this order of build that fixed the issue. Loaded extension manually and works fine.

This revision is now accepted and ready to land.Tue, Jun 4, 07:23

The above build order should probably be in one of the 3 module's README, given how the dependencies are relative now.