fix(ext): generate_device_keypair returns object not JSON string
The wasm-bindgen binding for generate_device_keypair uses
serde-wasm-bindgen and returns a plain JsValue (object), not a JSON
string. Two consumers were calling JSON.parse on it, causing the
runtime error 'SyntaxError: "[object Object]" is not valid JSON' which
broke device registration end-to-end.
Fixes:
- wasm.d.ts: return type now { public_key_hex; private_key_base64 }
matching the rate_passphrase pattern (also a JsValue-returning
binding).
- popup-only.ts (register_this_device handler) and setup.ts (initial
device wire-up): drop JSON.parse, use the object directly.
- router.test.ts: pin the contract — mock generate_device_keypair as a
function returning an object (matching real binding behavior) and
assert register_this_device returns ok and forwards the public key.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -1049,9 +1049,7 @@ function attachStep5(): void {
|
||||
|
||||
try {
|
||||
const w = await loadWasm();
|
||||
const keypair = JSON.parse(w.generate_device_keypair()) as {
|
||||
public_key_hex: string; private_key_base64: string;
|
||||
};
|
||||
const keypair = w.generate_device_keypair();
|
||||
|
||||
// 1) Save private key + name locally.
|
||||
await chrome.storage.local.set({
|
||||
|
||||
Reference in New Issue
Block a user