@qntx/wallet-worker 0.13.0 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -17,14 +17,16 @@ npm install @qntx/wallet-worker @qntx/wallet
17
17
  `@qntx/wallet-worker/browser`:
18
18
 
19
19
  ```ts
20
+ import { verifyEvent } from "@qntx/nostr";
20
21
  import { createWebWallet } from "@qntx/wallet-worker/browser";
21
22
 
22
23
  const wallet = await createWebWallet({
23
24
  passkey: {
24
- rpId: "app.example.com", // permanent — see Security notes
25
+ rpId: "wallet.example.com", // permanent, wallet-only — see Security notes
25
26
  rpName: "Example",
26
27
  walletSalt: "example/wallet",
27
28
  vaultSalt: "example/vault",
29
+ backupSalt: "example/backup",
28
30
  },
29
31
  autoLock: { platform: "web", idleMinutes: 15 }, // 5 | 15 | 60; max session 12 h
30
32
  verifyEvent, // verifies every event the kernel signs; pass your app's verifier
@@ -46,10 +48,20 @@ in-memory vault store. `createSoftwarePasskey(seed)` is a **test-only** WebAuthn
46
48
  deterministic, no authenticator, anyone holding the seed owns the wallet:
47
49
 
48
50
  ```ts
51
+ import { verifyEvent } from "@qntx/nostr";
49
52
  import { createNodeWallet, createSoftwarePasskey } from "@qntx/wallet-worker/node";
50
53
 
54
+ // The deterministic seed behind the software passkey — test/dev hosts only.
55
+ declare const seed: Uint8Array;
56
+
51
57
  const wallet = await createNodeWallet({
52
- passkey: { rpId: "qntx.test", rpName: "test", walletSalt: "t/wallet", vaultSalt: "t/vault" },
58
+ passkey: {
59
+ rpId: "qntx.test",
60
+ rpName: "test",
61
+ walletSalt: "t/wallet",
62
+ vaultSalt: "t/vault",
63
+ backupSalt: "t/backup",
64
+ },
53
65
  autoLock: { platform: "web", idleMinutes: 15 },
54
66
  verifyEvent,
55
67
  authenticator: createSoftwarePasskey(seed),
@@ -69,7 +81,10 @@ const wallet = await createNodeWallet({
69
81
  the record to `"mnemonic"`.
70
82
  - `createSoftwarePasskey(seed, { synced })` — `synced` defaults to `true` and lands in every
71
83
  `PrfResult`; pass `{ synced: false }` to exercise the device-bound path.
72
- - `passkey.rpId` and the two salts are permanent identifiers: changing them makes existing
84
+ - The `rpId` scope is the wallet's trust boundary: any origin that may claim the RP id (its
85
+ subdomains, its related origins) can derive a passkey wallet's seed with one passkey prompt.
86
+ Serve the wallet from a domain of its own and use that domain as the `rpId`.
87
+ - `passkey.rpId` and the three salts are permanent identifiers: changing them makes existing
73
88
  passkey factors and passkey-derived wallets unrecoverable. Moving domains needs WebAuthn
74
89
  related origins (`/.well-known/webauthn`); offer `exportMnemonic` for passkey-derived wallets.
75
90
  - IndexedDB upgrades are never `blocked`: the worker closes its connection on `versionchange`,
@@ -83,6 +98,26 @@ const wallet = await createNodeWallet({
83
98
  `worker: { format: "es" }` (required to keep the Spark backend lazy; the default `"iife"`
84
99
  still runs but ships Spark inside the initial worker) and dev-server
85
100
  `optimizeDeps.exclude: ["@qntx/wallet-worker"]`; webpack 5 — nothing.
101
+ - Trusted Types (`require-trusted-types-for 'script'`) works with a `default` policy that admits
102
+ the bundled kernel worker. Bundlers recognise the worker only in the literal
103
+ `new Worker(new URL(…))` form, so the library cannot pass a named policy's `TrustedScriptURL`
104
+ itself. Add `trusted-types default` to the CSP and install the policy before
105
+ `createWebWallet`:
106
+
107
+ ```ts
108
+ trustedTypes?.createPolicy("default", {
109
+ createScriptURL: (input) => {
110
+ const url = new URL(input, location.href);
111
+ if (url.origin !== location.origin || !/\/kernel\.worker[^/]*\.js$/.test(url.pathname)) {
112
+ throw new TypeError(`script URL not allowed: ${input}`);
113
+ }
114
+ return url.href;
115
+ },
116
+ });
117
+ ```
118
+
119
+ The Playwright suite runs the whole Web host under exactly this CSP and policy.
120
+
86
121
  - `dist/kernel.manifest.json` pins the artifacts the package was built from. Consumer bundlers
87
122
  re-bundle the worker, so the shipped bytes differ from the manifest's; `spark.wasm` is still
88
123
  verified by its integrity constant when the kernel loads it.
@@ -1,6 +1,6 @@
1
1
  {
2
- "protocol": 2,
3
- "vaultFormat": 3,
2
+ "protocol": 3,
3
+ "vaultFormat": 6,
4
4
  "backends": {
5
5
  "spark": {
6
6
  "abiVersion": 1,
@@ -8,6 +8,11 @@
8
8
  }
9
9
  },
10
10
  "libraries": [
11
+ {
12
+ "name": "@blockchaincommons/dcbor",
13
+ "version": "1.0.0-beta.5",
14
+ "integrity": "sha512-dmuEkmfcJk6g/+m73F9Rosxb+sHb790fiNfOdE6CI/TFLZCnXCRr3+K1QR4Se+vtBllEBgv85s28zaC1Jnegkw=="
15
+ },
11
16
  {
12
17
  "name": "@noble/ciphers",
13
18
  "version": "2.4.0",
@@ -25,8 +30,8 @@
25
30
  },
26
31
  {
27
32
  "name": "@qntx/nostr",
28
- "version": "0.15.4",
29
- "integrity": "sha512-kxWfN3HxKm7bTDn7Mzd+X80J74fbzNwUHOx8in5qMcb89/FgytR0jXllnF6eqGyO7VYG3pKSj94JnhgbkV73BQ=="
33
+ "version": "0.16.0",
34
+ "integrity": "sha512-52tWXXYutmDisBRVJ2+b5mgIHlKufXzV4zBQ1LlKKPmUsHeSVr214R25GKh9QF2bNfOnkik10j3SZjEZ8O2ytA=="
30
35
  },
31
36
  {
32
37
  "name": "@qntx/siwx",
@@ -43,6 +48,11 @@
43
48
  "version": "0.5.2",
44
49
  "integrity": "sha512-0ZgjgOeIAMvWNmFq/StiG6ymQKvFRJkTBTjkfda04ooeBv5/32p+u39CFeN1G0hxnCBiDYe5FOAkrrGXVZ5VxQ=="
45
50
  },
51
+ {
52
+ "name": "@qntx/ur",
53
+ "version": "4.1.0",
54
+ "integrity": "sha512-eOJJLek5tKn3Ts/8wo3yt6/VVwhAKjv7l5l8k7SGLSXLxz2OggXzm7RUURIlpSgyBbGAAQqf5ecCGt81iZGoGw=="
55
+ },
46
56
  {
47
57
  "name": "@scure/base",
48
58
  "version": "2.4.0",
@@ -71,36 +81,36 @@
71
81
  ],
72
82
  "bundles": [
73
83
  {
74
- "file": "browser-1vpxmqwn.js",
75
- "sha256": "e5afdeec6f071a87cb6a1040ddeb1b9995d53ed2cea239f8f9424dc1d3df601b"
84
+ "file": "kernel.node.js",
85
+ "sha256": "db014f9052b60a17b54ce3707e93c8bb0b8a2628b9c7138a7aa5ca94e9f3f300"
76
86
  },
77
87
  {
78
- "file": "kernel.node.js",
79
- "sha256": "2f019838e3e54f22c6966ff94fc4ce72a6d94fb3e85dca2e19b9a5831f7bc241"
88
+ "file": "worker-gsare3mw.js",
89
+ "sha256": "163a8aeb01c8d699a7567eecb90c6d5c859151d1e7322c3be0487eb13940b9c7"
80
90
  },
81
91
  {
82
- "file": "signer-h69ffzx5.js",
83
- "sha256": "706a31a8c4c2110f571aa26ce4203c1e66484b9a3073d94afb4abe892a868654"
92
+ "file": "node-gsare3mw.js",
93
+ "sha256": "163a8aeb01c8d699a7567eecb90c6d5c859151d1e7322c3be0487eb13940b9c7"
84
94
  },
85
95
  {
86
- "file": "kernel.worker.js",
87
- "sha256": "8afc03f3bff5a620b9bd048abec6e85a5c92d343d9bea12bedcd44b4ad6ea9d3"
96
+ "file": "node-2mp4qyt2.js",
97
+ "sha256": "9debec9e42923b1a3fd7efdbfc349628dc88b108d40305b1e0f852955a308faf"
88
98
  },
89
99
  {
90
- "file": "worker-gsare3mw.js",
91
- "sha256": "163a8aeb01c8d699a7567eecb90c6d5c859151d1e7322c3be0487eb13940b9c7"
100
+ "file": "browser-1vpxmqwn.js",
101
+ "sha256": "e5afdeec6f071a87cb6a1040ddeb1b9995d53ed2cea239f8f9424dc1d3df601b"
92
102
  },
93
103
  {
94
- "file": "node-k5etevb7.js",
95
- "sha256": "18e36552147e8187df5a0154d39101bb417ba070424e1f068c5e8582d34afd3b"
104
+ "file": "kernel.worker.js",
105
+ "sha256": "962066695360f0dd27a9c239c733c8a9e00ca929d8ba14a8c29f04caed351084"
96
106
  },
97
107
  {
98
- "file": "node-gsare3mw.js",
99
- "sha256": "163a8aeb01c8d699a7567eecb90c6d5c859151d1e7322c3be0487eb13940b9c7"
108
+ "file": "signer-pydq66hv.js",
109
+ "sha256": "d6d27146fad018c6ac87744b1b4046765ba4890e2292e79c23c542660f55a168"
100
110
  },
101
111
  {
102
- "file": "worker-k5etevb7.js",
103
- "sha256": "18e36552147e8187df5a0154d39101bb417ba070424e1f068c5e8582d34afd3b"
112
+ "file": "worker-2mp4qyt2.js",
113
+ "sha256": "9debec9e42923b1a3fd7efdbfc349628dc88b108d40305b1e0f852955a308faf"
104
114
  }
105
115
  ]
106
116
  }