fix(pow): support strict CSP without unsafe-eval - #32
Conversation
|
@edgepillar Nice fix for the core problem — replacing the embind Two things I'd want addressed before merge:
Minor nits, not blocking:
Once the CSP docs and the test file are tightened up this looks good to me. |
|
Thanks for the detailed review and for independently reproducing the generated artifacts. I addressed the two requested changes in
I also updated the PR description with the complete CSP example and documented the intentional removal of the previous SDK-managed 10-second polling timeout. The fresh Node 20, Node 22, and coverage checks are green. For the remaining non-blocking notes, I left the unused |
Summary
new Function(...import...)shim and browser inline module script with native dynamic importsScope
This is limited to the existing PoW loader, generated JS/WASM assets, build script, tests, and documentation. It does not change the PoW algorithm, wire format, or public transaction API.
The resulting browser policy for the built-in worker, when
pow.jsandpow.wasmare served from the same origin, can use:The generated PoW loader no longer requires
'unsafe-eval'. The narrower'wasm-unsafe-eval'permission is still required for WebAssembly compilationin Chromium.
The native browser
import()path intentionally removes the previousSDK-managed 10-second polling timeout; loading now follows the platform's
module and fetch promise behavior.
Reproducibility
zenon-network/znn-pow-links-cpp@9c63abdcd4e6bd642a81476cbff2f5190efabe956.0.8DYNAMIC_EXECUTION=0,EMBIND_AOT=1pow.jscontainseval()ornew Function()Validation
npm run build:wasmnpm test— 649 passing locally; GitHub Actions passed on Node20and22npm run lint— 0 errorsnpm run cover— passed in GitHub Actions on Node20npm run buildnpm pack --dry-run --ignore-scripts'wasm-unsafe-eval', which failed only at WebAssembly compilation as expected