Browser Extension (Chrome MV3) compatibility: wallet.sync() fails due to CSP restrictions
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 25/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Cần làm rõ
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- typescript, wasm
Hướng nghiên cứu
Bắt đầu bằng cách tái hiện lỗi Manifest V3 với WebWallet, wallet.sync() và initThreadPool(8), sau đó theo dõi việc sử dụng worker và eval. So sánh điều này với sync tùy chỉnh của CipherScan và đường dẫn pczt_create để xác định liệu có tồn tại một cách tiếp cận single-threaded hoặc tương thích với cơ sở dữ liệu được hỗ trợ hay không; hoàn tất khi có một luồng giao dịch tương thích với MV3 được ghi lại hoặc hoạt động được.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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!
- Ngôn ngữ chính
- TypeScript
- Star
- 43
- Fork
- 32
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Không có hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của ChainSafe/WebZjs
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 20/100
-
Zcash snap not workingĐang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 42/100
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
-
Snap test supportĐang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
Tất cả issue của ChainSafe/WebZjs
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
high priority
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
CI-CMG/deep-sea-corals-exb#84 · 1 bình luận ·
-
Create/import wallet form shows raw "password must be at least 1 characters" instead of the translated messageCó thể đã có người làm @CapThunder19 đã nhận hôm nay. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
joinmarket-webui/jam#1538 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
t0ggles
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
nolimits4web/swiper#8240 · 1 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày