Browser Extension (Chrome MV3) compatibility: wallet.sync() fails due to CSP restrictions
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 25/100
- Tipo di issue
- Bug
- Chiarezza
- Da chiarire
- Stato di attività
- Ferma
- Stack tecnologico
- typescript, wasm
Direzione di ricerca
Inizia riproducendo il fallimento di Manifest V3 con WebWallet, wallet.sync() e initThreadPool(8), quindi traccia l’utilizzo di worker ed eval. Confronta questo comportamento con la sincronizzazione personalizzata di CipherScan e il percorso pczt_create per determinare se esiste un percorso supportato single-threaded o compatibile con il database; il lavoro è completato quando esiste un flusso di transazioni documentato o funzionante compatibile con MV3.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Browser Extension (Chrome MV3) Compatibility Issue
🐛 Problem
I'm building a Zcash wallet browser extension using WebZjs, but encountering compatibility issues with Chrome Manifest V3's strict Content Security Policy (CSP).
🔍 Details
Environment:
- Chrome Extension with Manifest V3
@chainsafe/webzjs-wallet(latest version)- Zcash testnet
- CSP:
script-src 'self' 'wasm-unsafe-eval'
Issue:
Chrome MV3 disallows eval() and new Function() for security reasons. This breaks WebZjs's sync mechanism:
// ❌ Fails in Chrome MV3
await wallet.sync();
// Error: eval() is not allowed in Chrome extensions
await initThreadPool(8);
// Error: Web Workers cannot use eval()Root cause:
wallet.sync()spawns Web Workers usingeval()internallyinitThreadPool()also relies oneval()for multi-threading- Chrome MV3 CSP blocks these operations
🔧 Current Workaround
I've implemented a custom sync using CipherScan's WASM for client-side decryption:
// ✅ Works: Custom sync with WASM
const compactBlocks = await fetchCompactBlocks(startHeight, endHeight);
const matches = await batch_filter_compact_outputs(compactBlocks, viewingKey);
const balance = calculateBalance(matches); // 0.02 ZEC ✅However, this creates a critical issue:
// WebZjs's internal database is EMPTY (never synced)
await wallet.propose_transfer(accountId, toAddress, amount);
// ❌ Error: "insufficient balance" (WebZjs DB has no notes!)The problem:
- Custom sync finds funds ✅
- WebZjs DB remains empty ❌
propose_transfer()can't find notes to spend ❌
❓ Questions
Is there a way to:
-
Use WebZjs sync in single-threaded mode (without eval/Web Workers)?
- Does WebZjs have a fallback sync mechanism compatible with MV3?
-
Manually populate WebZjs database with notes from custom sync?
- Can we inject notes/nullifiers into WebZjs's internal DB?
-
Use alternative transaction API (PCZTs?) that doesn't require DB sync?
// Does this work without wallet.sync()?
const pczt = await wallet.pczt_create(accountId, toAddress, value);💡 Why This Matters
Browser extensions are a common use case for crypto wallets (Metamask, Phantom, Rabby, etc.). Chrome MV3 is now mandatory for all new extensions.
Making WebZjs compatible with MV3 would:
- ✅ Enable Zcash browser wallet extensions
- ✅ Improve Zcash ecosystem adoption
- ✅ Align with industry standards (all major wallets support MV3)
📝 Reproduction Steps
- Create Chrome Extension (Manifest V3)
- Add CSP:
"content_security_policy": { "extension_pages": "script-src 'self' 'wasm-unsafe-eval'; object-src 'self'" } - Initialize WebZjs:
const wallet = new WebWallet("test", lightwalletdUrl, 10); - Try to sync:
await wallet.sync();→ Fails with CSP error
🙏 Request
Any guidance on MV3-compatible sync or transaction building would be greatly appreciated!
- Lingua principale
- TypeScript
- Stelle
- 42
- Fork
- 32
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Nessuna guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di ChainSafe/WebZjs
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 20/100
-
Zcash snap not workingAperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 42/100
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
-
Snap test supportAperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 25/100
Tutte le issue di ChainSafe/WebZjs
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
db-ux-design-system/core-web#8461 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Cannot run an integration on windows when power shell is selected as the default profile terminalApertaPriority/Blocker Type/Bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
wso2/product-integrator#2767 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
-
severity:low
Difficoltà 1/5 1-3 ore Idoneità per principianti 84/100
I maintainer di solito rispondono entro 1 giorno