@qntx/wallet-worker 0.13.0 → 0.14.1
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 +38 -3
- package/dist/kernel.manifest.json +30 -20
- package/dist/kernel.node.js +35206 -6807
- package/dist/kernel.worker.js +37113 -8695
- package/dist/{node-k5etevb7.js → node-2mp4qyt2.js} +72 -63
- package/dist/node.mjs +46 -22
- package/dist/node.mjs.map +1 -1
- package/dist/{signer-h69ffzx5.js → signer-pydq66hv.js} +1 -1
- package/dist/{worker-k5etevb7.js → worker-2mp4qyt2.js} +72 -63
- package/package.json +13 -17
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: "
|
|
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: {
|
|
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
|
-
- `
|
|
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":
|
|
3
|
-
"vaultFormat":
|
|
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.
|
|
29
|
-
"integrity": "sha512-
|
|
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": "
|
|
75
|
-
"sha256": "
|
|
84
|
+
"file": "kernel.node.js",
|
|
85
|
+
"sha256": "d4abb042733edc06d997006a0ab97747245ca7c36692c8aebc811baa35421ee7"
|
|
76
86
|
},
|
|
77
87
|
{
|
|
78
|
-
"file": "
|
|
79
|
-
"sha256": "
|
|
88
|
+
"file": "worker-gsare3mw.js",
|
|
89
|
+
"sha256": "163a8aeb01c8d699a7567eecb90c6d5c859151d1e7322c3be0487eb13940b9c7"
|
|
80
90
|
},
|
|
81
91
|
{
|
|
82
|
-
"file": "
|
|
83
|
-
"sha256": "
|
|
92
|
+
"file": "node-gsare3mw.js",
|
|
93
|
+
"sha256": "163a8aeb01c8d699a7567eecb90c6d5c859151d1e7322c3be0487eb13940b9c7"
|
|
84
94
|
},
|
|
85
95
|
{
|
|
86
|
-
"file": "
|
|
87
|
-
"sha256": "
|
|
96
|
+
"file": "node-2mp4qyt2.js",
|
|
97
|
+
"sha256": "9debec9e42923b1a3fd7efdbfc349628dc88b108d40305b1e0f852955a308faf"
|
|
88
98
|
},
|
|
89
99
|
{
|
|
90
|
-
"file": "
|
|
91
|
-
"sha256": "
|
|
100
|
+
"file": "browser-1vpxmqwn.js",
|
|
101
|
+
"sha256": "e5afdeec6f071a87cb6a1040ddeb1b9995d53ed2cea239f8f9424dc1d3df601b"
|
|
92
102
|
},
|
|
93
103
|
{
|
|
94
|
-
"file": "
|
|
95
|
-
"sha256": "
|
|
104
|
+
"file": "kernel.worker.js",
|
|
105
|
+
"sha256": "1a7d3a5f7e49a0c20b46b8c0fb0a7858bebe33222b34a3557372bccf0ad21633"
|
|
96
106
|
},
|
|
97
107
|
{
|
|
98
|
-
"file": "
|
|
99
|
-
"sha256": "
|
|
108
|
+
"file": "signer-pydq66hv.js",
|
|
109
|
+
"sha256": "d6d27146fad018c6ac87744b1b4046765ba4890e2292e79c23c542660f55a168"
|
|
100
110
|
},
|
|
101
111
|
{
|
|
102
|
-
"file": "worker-
|
|
103
|
-
"sha256": "
|
|
112
|
+
"file": "worker-2mp4qyt2.js",
|
|
113
|
+
"sha256": "9debec9e42923b1a3fd7efdbfc349628dc88b108d40305b1e0f852955a308faf"
|
|
104
114
|
}
|
|
105
115
|
]
|
|
106
116
|
}
|