@qntx/wallet-worker 0.0.0-stage → 0.2.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/LICENSE-APACHE +201 -0
- package/LICENSE-MIT +21 -0
- package/README.md +64 -2
- package/dist/browser.d.mts +20 -0
- package/dist/browser.mjs +227 -0
- package/dist/browser.mjs.map +1 -0
- package/dist/kernel.node.js +10618 -0
- package/dist/kernel.worker.js +10681 -0
- package/dist/node.d.mts +21 -0
- package/dist/node.mjs +1044 -0
- package/dist/node.mjs.map +1 -0
- package/package.json +80 -4
package/LICENSE-APACHE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/LICENSE-MIT
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 QuantX
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,65 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @qntx/wallet-worker
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Web and Node host for [`@qntx/wallet`](https://www.npmjs.com/package/@qntx/wallet): spawns the
|
|
4
|
+
wallet kernel in a Worker (`dist/kernel.worker.js` / `dist/kernel.node.js`, bundled), keeps the
|
|
5
|
+
encrypted vault in IndexedDB (Web) or a main-thread memory store (Node), and runs the WebAuthn
|
|
6
|
+
PRF passkey ceremony on the main thread. Peer dependency: the exact `@qntx/wallet` release this
|
|
7
|
+
kernel was built against — the host/kernel protocol requires it.
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @qntx/wallet-worker @qntx/wallet
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Web
|
|
14
|
+
|
|
15
|
+
`@qntx/wallet-worker/browser`:
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { createWebWallet } from "@qntx/wallet-worker/browser";
|
|
19
|
+
|
|
20
|
+
const wallet = await createWebWallet({
|
|
21
|
+
passkey: {
|
|
22
|
+
rpId: "app.example.com",
|
|
23
|
+
rpName: "Example",
|
|
24
|
+
walletSalt: "example/wallet",
|
|
25
|
+
vaultSalt: "example/vault",
|
|
26
|
+
},
|
|
27
|
+
autoLock: { platform: "web", idleMinutes: 15 },
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const created = await wallet.wallets.createWithPasskey({ name: "Example Wallet" });
|
|
31
|
+
await wallet.vault.unlock({ kind: "passkey" });
|
|
32
|
+
|
|
33
|
+
import { nostr } from "@qntx/wallet/nostr";
|
|
34
|
+
|
|
35
|
+
const key = await nostr(wallet).deriveKey(created.walletId, 0);
|
|
36
|
+
const signer = nostr(wallet).signer(key.ref);
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Node (tests and demos)
|
|
40
|
+
|
|
41
|
+
`@qntx/wallet-worker/node` runs the same kernel in a `node:worker_threads` Worker with an
|
|
42
|
+
in-memory vault store. `createSoftwarePasskey(seed)` is a **test-only** WebAuthn stand-in —
|
|
43
|
+
deterministic, no authenticator, anyone holding the seed owns the wallet:
|
|
44
|
+
|
|
45
|
+
```ts
|
|
46
|
+
import { createNodeWallet, createSoftwarePasskey } from "@qntx/wallet-worker/node";
|
|
47
|
+
|
|
48
|
+
const wallet = await createNodeWallet({
|
|
49
|
+
passkey: { rpId: "qntx.test", rpName: "test", walletSalt: "t/wallet", vaultSalt: "t/vault" },
|
|
50
|
+
autoLock: { platform: "web", idleMinutes: 15 },
|
|
51
|
+
authenticator: createSoftwarePasskey(seed),
|
|
52
|
+
});
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Security notes
|
|
56
|
+
|
|
57
|
+
- Secrets exist only inside the kernel Worker; lock destroys the worker, the vault image
|
|
58
|
+
(ciphertext + public headers) persists in the store.
|
|
59
|
+
- The Web host is a **hot wallet**. CSP needs `worker-src 'self'`; Vite needs
|
|
60
|
+
`optimizeDeps.exclude: ["@qntx/wallet-worker"]`.
|
|
61
|
+
- `@qntx/wallet/host` is for host packages only — not application API.
|
|
62
|
+
|
|
63
|
+
## License
|
|
64
|
+
|
|
65
|
+
MIT OR Apache-2.0
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Wallet, WalletOptions } from "@qntx/wallet";
|
|
2
|
+
import { PasskeyCeremony } from "@qntx/wallet/host";
|
|
3
|
+
//#region src/browser/passkey.d.ts
|
|
4
|
+
type WebAuthnRp = {
|
|
5
|
+
/** RP id — the origin's effective domain, e.g. `location.hostname`. */
|
|
6
|
+
readonly id: string;
|
|
7
|
+
readonly name: string;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* The WebAuthn ceremony. `create` registers a resident credential with `prf.eval` over the salts;
|
|
11
|
+
* when the extension returns no results a single assertion over the new credential produces them.
|
|
12
|
+
* `assert` runs a discoverable (or allowCredentials-scoped) get with the same eval shape.
|
|
13
|
+
*/
|
|
14
|
+
export declare function createWebAuthnPasskey(rp: WebAuthnRp): PasskeyCeremony;
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/browser/index.d.ts
|
|
17
|
+
export declare function createWebWallet(options: WalletOptions): Promise<Wallet>;
|
|
18
|
+
//#endregion
|
|
19
|
+
export type { WebAuthnRp };
|
|
20
|
+
//# sourceMappingURL=browser.d.mts.map
|
package/dist/browser.mjs
ADDED
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import { WalletError } from "@qntx/wallet";
|
|
2
|
+
import { connectKernel } from "@qntx/wallet/host";
|
|
3
|
+
//#region src/browser/passkey.ts
|
|
4
|
+
/**
|
|
5
|
+
* The WebAuthn passkey ceremony (main thread only): `navigator.credentials` with the PRF extension.
|
|
6
|
+
* A wallet passkey derives the wallet seed from `PRF(walletSalt)`; the vault factor derives the
|
|
7
|
+
* vault KEK from `PRF(vaultSalt)` on the same credential. Every ceremony output is checked for
|
|
8
|
+
* `prf.enabled`, PRF results and the user-verification flag — a credential that cannot prove UV
|
|
9
|
+
* never reaches the kernel.
|
|
10
|
+
*/
|
|
11
|
+
const PURPOSE_WALLET = 1;
|
|
12
|
+
const PURPOSE_VAULT = 2;
|
|
13
|
+
const UV_FLAG = 4;
|
|
14
|
+
function factorUnavailable(message) {
|
|
15
|
+
return new WalletError("factor-unavailable", message);
|
|
16
|
+
}
|
|
17
|
+
function cancelled(message) {
|
|
18
|
+
return new WalletError("cancelled", message);
|
|
19
|
+
}
|
|
20
|
+
function mapCeremonyError(error) {
|
|
21
|
+
if (error instanceof DOMException && (error.name === "NotAllowedError" || error.name === "AbortError")) throw cancelled("the passkey ceremony was cancelled");
|
|
22
|
+
if (error instanceof WalletError) throw error;
|
|
23
|
+
throw factorUnavailable("the passkey ceremony failed");
|
|
24
|
+
}
|
|
25
|
+
/** The UV bit of an authenticator-data blob (flags byte at offset 32, bit 0x04). */
|
|
26
|
+
function userVerified(authenticatorData) {
|
|
27
|
+
return authenticatorData.byteLength > 32 && (new DataView(authenticatorData).getUint8(32) & UV_FLAG) !== 0;
|
|
28
|
+
}
|
|
29
|
+
function prfEval(salts) {
|
|
30
|
+
return salts.second === void 0 ? { first: new Uint8Array(salts.first) } : {
|
|
31
|
+
first: new Uint8Array(salts.first),
|
|
32
|
+
second: new Uint8Array(salts.second)
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/** A detached copy of a BufferSource — the returned Uint8Array owns its own fresh buffer. */
|
|
36
|
+
function copyBufferSource(source) {
|
|
37
|
+
const view = source instanceof ArrayBuffer ? new Uint8Array(source) : new Uint8Array(source.buffer, source.byteOffset, source.byteLength);
|
|
38
|
+
return new Uint8Array(view);
|
|
39
|
+
}
|
|
40
|
+
function readPrfResult(credential, results, wantSecond) {
|
|
41
|
+
const first = results?.first;
|
|
42
|
+
const second = results?.second;
|
|
43
|
+
if (first === void 0 || wantSecond && second === void 0) throw factorUnavailable("the passkey produced no PRF output");
|
|
44
|
+
return {
|
|
45
|
+
credentialId: copyBufferSource(credential.rawId),
|
|
46
|
+
first: copyBufferSource(first),
|
|
47
|
+
...second === void 0 ? {} : { second: copyBufferSource(second) }
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function checkCredential(credential) {
|
|
51
|
+
if (!(credential instanceof PublicKeyCredential)) throw factorUnavailable("the authenticator returned no public-key credential");
|
|
52
|
+
return credential;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* The WebAuthn ceremony. `create` registers a resident credential with `prf.eval` over the salts;
|
|
56
|
+
* when the extension returns no results a single assertion over the new credential produces them.
|
|
57
|
+
* `assert` runs a discoverable (or allowCredentials-scoped) get with the same eval shape.
|
|
58
|
+
*/
|
|
59
|
+
function createWebAuthnPasskey(rp) {
|
|
60
|
+
async function assert(input) {
|
|
61
|
+
let credential;
|
|
62
|
+
try {
|
|
63
|
+
credential = checkCredential(await navigator.credentials.get({ publicKey: {
|
|
64
|
+
rpId: rp.id,
|
|
65
|
+
challenge: crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(32)),
|
|
66
|
+
userVerification: "required",
|
|
67
|
+
...input.credentialIds === void 0 ? {} : { allowCredentials: input.credentialIds.map((id) => ({
|
|
68
|
+
type: "public-key",
|
|
69
|
+
id: new Uint8Array(id)
|
|
70
|
+
})) },
|
|
71
|
+
extensions: { prf: { eval: prfEval(input.salts) } }
|
|
72
|
+
} }));
|
|
73
|
+
} catch (error) {
|
|
74
|
+
mapCeremonyError(error);
|
|
75
|
+
}
|
|
76
|
+
const { response } = credential;
|
|
77
|
+
if (!(response instanceof AuthenticatorAssertionResponse)) throw factorUnavailable("the authenticator returned no assertion response");
|
|
78
|
+
if (!userVerified(response.authenticatorData)) throw factorUnavailable("the passkey assertion was not user-verified");
|
|
79
|
+
return readPrfResult(credential, credential.getClientExtensionResults().prf?.results, input.salts.second !== void 0);
|
|
80
|
+
}
|
|
81
|
+
return {
|
|
82
|
+
create: async (input) => {
|
|
83
|
+
const userId = /* @__PURE__ */ new Uint8Array(16);
|
|
84
|
+
userId[0] = input.purpose === "wallet" ? PURPOSE_WALLET : PURPOSE_VAULT;
|
|
85
|
+
crypto.getRandomValues(userId.subarray(1));
|
|
86
|
+
let credential;
|
|
87
|
+
try {
|
|
88
|
+
credential = checkCredential(await navigator.credentials.create({ publicKey: {
|
|
89
|
+
rp: {
|
|
90
|
+
id: rp.id,
|
|
91
|
+
name: rp.name
|
|
92
|
+
},
|
|
93
|
+
user: {
|
|
94
|
+
id: userId,
|
|
95
|
+
name: input.name,
|
|
96
|
+
displayName: input.name
|
|
97
|
+
},
|
|
98
|
+
challenge: crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(32)),
|
|
99
|
+
pubKeyCredParams: [{
|
|
100
|
+
type: "public-key",
|
|
101
|
+
alg: -7
|
|
102
|
+
}, {
|
|
103
|
+
type: "public-key",
|
|
104
|
+
alg: -257
|
|
105
|
+
}],
|
|
106
|
+
authenticatorSelection: {
|
|
107
|
+
residentKey: "required",
|
|
108
|
+
userVerification: "required"
|
|
109
|
+
},
|
|
110
|
+
extensions: { prf: { eval: prfEval(input.salts) } }
|
|
111
|
+
} }));
|
|
112
|
+
} catch (error) {
|
|
113
|
+
mapCeremonyError(error);
|
|
114
|
+
}
|
|
115
|
+
const { response } = credential;
|
|
116
|
+
if (!(response instanceof AuthenticatorAttestationResponse)) throw factorUnavailable("the authenticator returned no attestation response");
|
|
117
|
+
const extensions = credential.getClientExtensionResults();
|
|
118
|
+
if (extensions.prf?.enabled !== true) throw factorUnavailable("the authenticator does not support the PRF extension");
|
|
119
|
+
if (extensions.prf.results === void 0) return assert({
|
|
120
|
+
credentialIds: [copyBufferSource(credential.rawId)],
|
|
121
|
+
salts: input.salts
|
|
122
|
+
});
|
|
123
|
+
if (!userVerified(response.getAuthenticatorData())) throw factorUnavailable("the passkey creation was not user-verified");
|
|
124
|
+
return readPrfResult(credential, extensions.prf.results, input.salts.second !== void 0);
|
|
125
|
+
},
|
|
126
|
+
assert
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
//#endregion
|
|
130
|
+
//#region src/browser/index.ts
|
|
131
|
+
/**
|
|
132
|
+
* The Web host: `createWebWallet` spawns the bundled kernel worker (dist/kernel.worker.js) whose
|
|
133
|
+
* vault lives in the worker's own IndexedDB. Lock destroys the worker; the vault survives in
|
|
134
|
+
* IndexedDB, so the respawned worker reloads it. Page lifecycle locks: 5 minutes hidden or
|
|
135
|
+
* `pagehide`. The WebAuthn ceremony runs on the main thread.
|
|
136
|
+
*/
|
|
137
|
+
const MAX_SESSION_MS = 432e5;
|
|
138
|
+
const HIDDEN_LOCK_MS = 3e5;
|
|
139
|
+
async function bestEffort(task) {
|
|
140
|
+
try {
|
|
141
|
+
await task();
|
|
142
|
+
} catch {}
|
|
143
|
+
}
|
|
144
|
+
async function createWebWallet(options) {
|
|
145
|
+
const { autoLock } = options;
|
|
146
|
+
if (autoLock.platform !== "web") throw new WalletError("invalid-input", "createWebWallet accepts only the web autoLock policy");
|
|
147
|
+
const init = {
|
|
148
|
+
t: "init",
|
|
149
|
+
idleMs: autoLock.idleMinutes * 6e4,
|
|
150
|
+
maxSessionMs: MAX_SESSION_MS
|
|
151
|
+
};
|
|
152
|
+
const kernelUrl = new URL("kernel.worker.js", import.meta.url);
|
|
153
|
+
const ceremony = createWebAuthnPasskey({
|
|
154
|
+
id: options.passkey.rpId,
|
|
155
|
+
name: options.passkey.rpName
|
|
156
|
+
});
|
|
157
|
+
const spawn = () => {
|
|
158
|
+
const worker = new Worker(kernelUrl, {
|
|
159
|
+
type: "module",
|
|
160
|
+
name: "qntx-wallet"
|
|
161
|
+
});
|
|
162
|
+
worker.postMessage(init);
|
|
163
|
+
return {
|
|
164
|
+
post: (message, transfer) => {
|
|
165
|
+
worker.postMessage(message, transfer);
|
|
166
|
+
},
|
|
167
|
+
listen: (handler) => {
|
|
168
|
+
const listener = (event) => {
|
|
169
|
+
handler(event.data);
|
|
170
|
+
};
|
|
171
|
+
worker.addEventListener("message", listener);
|
|
172
|
+
return () => {
|
|
173
|
+
worker.removeEventListener("message", listener);
|
|
174
|
+
};
|
|
175
|
+
},
|
|
176
|
+
onExit: (handler) => {
|
|
177
|
+
const listener = () => {
|
|
178
|
+
handler();
|
|
179
|
+
};
|
|
180
|
+
worker.addEventListener("error", listener);
|
|
181
|
+
worker.addEventListener("messageerror", listener);
|
|
182
|
+
return () => {
|
|
183
|
+
worker.removeEventListener("error", listener);
|
|
184
|
+
worker.removeEventListener("messageerror", listener);
|
|
185
|
+
};
|
|
186
|
+
},
|
|
187
|
+
terminate: () => {
|
|
188
|
+
worker.terminate();
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
};
|
|
192
|
+
const wallet = await connectKernel({
|
|
193
|
+
spawn,
|
|
194
|
+
passkey: options.passkey,
|
|
195
|
+
ceremony,
|
|
196
|
+
onDestroy: () => {
|
|
197
|
+
document.removeEventListener("visibilitychange", onVisibility);
|
|
198
|
+
globalThis.removeEventListener("pagehide", onPageHide);
|
|
199
|
+
globalThis.clearTimeout(hiddenTimer);
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
let hiddenTimer = 0;
|
|
203
|
+
const onVisibility = () => {
|
|
204
|
+
if (document.visibilityState === "hidden") hiddenTimer = globalThis.setTimeout(() => {
|
|
205
|
+
bestEffort(async () => wallet.vault.lock());
|
|
206
|
+
}, HIDDEN_LOCK_MS);
|
|
207
|
+
else globalThis.clearTimeout(hiddenTimer);
|
|
208
|
+
};
|
|
209
|
+
const onPageHide = () => {
|
|
210
|
+
bestEffort(async () => wallet.vault.lock());
|
|
211
|
+
};
|
|
212
|
+
document.addEventListener("visibilitychange", onVisibility);
|
|
213
|
+
globalThis.addEventListener("pagehide", onPageHide);
|
|
214
|
+
let persisted = false;
|
|
215
|
+
const unsubscribe = wallet.subscribe(() => {
|
|
216
|
+
if (!persisted && wallet.getSnapshot().vault !== "uninitialized") {
|
|
217
|
+
persisted = true;
|
|
218
|
+
unsubscribe();
|
|
219
|
+
bestEffort(async () => navigator.storage.persist());
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
return wallet;
|
|
223
|
+
}
|
|
224
|
+
//#endregion
|
|
225
|
+
export { createWebAuthnPasskey, createWebWallet };
|
|
226
|
+
|
|
227
|
+
//# sourceMappingURL=browser.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser.mjs","names":[],"sources":["../src/browser/passkey.ts","../src/browser/index.ts"],"sourcesContent":["/**\n * The WebAuthn passkey ceremony (main thread only): `navigator.credentials` with the PRF extension.\n * A wallet passkey derives the wallet seed from `PRF(walletSalt)`; the vault factor derives the\n * vault KEK from `PRF(vaultSalt)` on the same credential. Every ceremony output is checked for\n * `prf.enabled`, PRF results and the user-verification flag — a credential that cannot prove UV\n * never reaches the kernel.\n */\nimport { WalletError } from \"@qntx/wallet\";\nimport type { PasskeyCeremony, PrfResult, PrfSalts } from \"@qntx/wallet/host\";\n\nexport type WebAuthnRp = {\n /** RP id — the origin's effective domain, e.g. `location.hostname`. */\n readonly id: string;\n readonly name: string;\n};\n\nconst PURPOSE_WALLET = 0x01;\nconst PURPOSE_VAULT = 0x02;\nconst UV_FLAG = 0x04; // authenticator-data flags byte (offset 32), bit 2 = user verified\n\nfunction factorUnavailable(message: string): WalletError {\n return new WalletError(\"factor-unavailable\", message);\n}\n\nfunction cancelled(message: string): WalletError {\n return new WalletError(\"cancelled\", message);\n}\n\nfunction mapCeremonyError(error: unknown): never {\n if (\n error instanceof DOMException &&\n (error.name === \"NotAllowedError\" || error.name === \"AbortError\")\n ) {\n throw cancelled(\"the passkey ceremony was cancelled\");\n }\n if (error instanceof WalletError) {\n throw error;\n }\n throw factorUnavailable(\"the passkey ceremony failed\");\n}\n\n/** The UV bit of an authenticator-data blob (flags byte at offset 32, bit 0x04). */\nfunction userVerified(authenticatorData: ArrayBuffer): boolean {\n return (\n authenticatorData.byteLength > 32 &&\n // oxlint-disable-next-line eslint/no-bitwise -- flags bit test\n (new DataView(authenticatorData).getUint8(32) & UV_FLAG) !== 0\n );\n}\n\nfunction prfEval(salts: PrfSalts): AuthenticationExtensionsPRFValues {\n // The constructor copy narrows Uint8Array<ArrayBufferLike> to Uint8Array<ArrayBuffer> —\n // the DOM BufferSource does not admit shared-array-buffer views.\n return salts.second === undefined\n ? { first: new Uint8Array(salts.first) }\n : { first: new Uint8Array(salts.first), second: new Uint8Array(salts.second) };\n}\n\n/** A detached copy of a BufferSource — the returned Uint8Array owns its own fresh buffer. */\nfunction copyBufferSource(source: BufferSource): Uint8Array {\n const view =\n source instanceof ArrayBuffer\n ? new Uint8Array(source)\n : new Uint8Array(source.buffer, source.byteOffset, source.byteLength);\n return new Uint8Array(view);\n}\n\nfunction readPrfResult(\n credential: PublicKeyCredential,\n results: AuthenticationExtensionsPRFValues | undefined,\n wantSecond: boolean,\n): PrfResult {\n const first = results?.first;\n const second = results?.second;\n if (first === undefined || (wantSecond && second === undefined)) {\n throw factorUnavailable(\"the passkey produced no PRF output\");\n }\n // Copy into fresh Uint8Arrays and drop every reference to the extension's ArrayBuffers.\n return {\n credentialId: copyBufferSource(credential.rawId),\n first: copyBufferSource(first),\n ...(second === undefined ? {} : { second: copyBufferSource(second) }),\n };\n}\n\nfunction checkCredential(credential: unknown): PublicKeyCredential {\n if (!(credential instanceof PublicKeyCredential)) {\n throw factorUnavailable(\"the authenticator returned no public-key credential\");\n }\n return credential;\n}\n\n/**\n * The WebAuthn ceremony. `create` registers a resident credential with `prf.eval` over the salts;\n * when the extension returns no results a single assertion over the new credential produces them.\n * `assert` runs a discoverable (or allowCredentials-scoped) get with the same eval shape.\n */\nexport function createWebAuthnPasskey(rp: WebAuthnRp): PasskeyCeremony {\n async function assert(input: {\n readonly credentialIds?: ReadonlyArray<Uint8Array>;\n readonly salts: PrfSalts;\n }): Promise<PrfResult> {\n let credential: PublicKeyCredential;\n try {\n credential = checkCredential(\n await navigator.credentials.get({\n publicKey: {\n rpId: rp.id,\n challenge: crypto.getRandomValues(new Uint8Array(32)),\n userVerification: \"required\",\n ...(input.credentialIds === undefined\n ? {}\n : {\n allowCredentials: input.credentialIds.map((id) => ({\n type: \"public-key\" as const,\n id: new Uint8Array(id),\n })),\n }),\n extensions: { prf: { eval: prfEval(input.salts) } },\n },\n }),\n );\n } catch (error) {\n mapCeremonyError(error);\n }\n const { response } = credential;\n if (!(response instanceof AuthenticatorAssertionResponse)) {\n throw factorUnavailable(\"the authenticator returned no assertion response\");\n }\n if (!userVerified(response.authenticatorData)) {\n throw factorUnavailable(\"the passkey assertion was not user-verified\");\n }\n return readPrfResult(\n credential,\n credential.getClientExtensionResults().prf?.results,\n input.salts.second !== undefined,\n );\n }\n\n return {\n create: async (input) => {\n const userId = new Uint8Array(16);\n userId[0] = input.purpose === \"wallet\" ? PURPOSE_WALLET : PURPOSE_VAULT;\n crypto.getRandomValues(userId.subarray(1));\n let credential: PublicKeyCredential;\n try {\n credential = checkCredential(\n await navigator.credentials.create({\n publicKey: {\n rp: { id: rp.id, name: rp.name },\n user: {\n id: userId,\n name: input.name,\n displayName: input.name,\n },\n challenge: crypto.getRandomValues(new Uint8Array(32)),\n pubKeyCredParams: [\n { type: \"public-key\", alg: -7 },\n { type: \"public-key\", alg: -257 },\n ],\n authenticatorSelection: {\n residentKey: \"required\",\n userVerification: \"required\",\n },\n extensions: { prf: { eval: prfEval(input.salts) } },\n },\n }),\n );\n } catch (error) {\n mapCeremonyError(error);\n }\n const { response } = credential;\n if (!(response instanceof AuthenticatorAttestationResponse)) {\n throw factorUnavailable(\"the authenticator returned no attestation response\");\n }\n const extensions = credential.getClientExtensionResults();\n if (extensions.prf?.enabled !== true) {\n throw factorUnavailable(\"the authenticator does not support the PRF extension\");\n }\n if (extensions.prf.results === undefined) {\n // Some authenticators omit creation-time PRF outputs: one assertion over the new\n // credential produces them (and it is that response whose UV flag must be checked).\n return assert({\n credentialIds: [copyBufferSource(credential.rawId)],\n salts: input.salts,\n });\n }\n if (!userVerified(response.getAuthenticatorData())) {\n throw factorUnavailable(\"the passkey creation was not user-verified\");\n }\n return readPrfResult(credential, extensions.prf.results, input.salts.second !== undefined);\n },\n assert,\n };\n}\n","/**\n * The Web host: `createWebWallet` spawns the bundled kernel worker (dist/kernel.worker.js) whose\n * vault lives in the worker's own IndexedDB. Lock destroys the worker; the vault survives in\n * IndexedDB, so the respawned worker reloads it. Page lifecycle locks: 5 minutes hidden or\n * `pagehide`. The WebAuthn ceremony runs on the main thread.\n */\nimport { WalletError } from \"@qntx/wallet\";\nimport type { Wallet, WalletOptions } from \"@qntx/wallet\";\nimport { connectKernel } from \"@qntx/wallet/host\";\nimport type { MainPort } from \"@qntx/wallet/host\";\nimport type { ProtocolValue } from \"@qntx/wallet/protocol\";\n\nimport type { BrowserWorkerInit } from \"../shared.ts\";\nimport { createWebAuthnPasskey } from \"./passkey.ts\";\n\nconst MAX_SESSION_MS = 12 * 3_600_000; // fixed: 12 h\nconst HIDDEN_LOCK_MS = 5 * 60_000; // lock after the page has been hidden for 5 minutes\n\nasync function bestEffort(task: () => Promise<unknown>): Promise<void> {\n try {\n await task();\n } catch {\n // Lifecycle hooks and persistence hints must never surface failures.\n }\n}\n\nexport async function createWebWallet(options: WalletOptions): Promise<Wallet> {\n const { autoLock } = options;\n if (autoLock.platform !== \"web\") {\n throw new WalletError(\"invalid-input\", \"createWebWallet accepts only the web autoLock policy\");\n }\n const init: BrowserWorkerInit = {\n t: \"init\",\n idleMs: autoLock.idleMinutes * 60_000,\n maxSessionMs: MAX_SESSION_MS,\n };\n const kernelUrl = new URL(\"kernel.worker.js\", import.meta.url);\n const ceremony = createWebAuthnPasskey({\n id: options.passkey.rpId,\n name: options.passkey.rpName,\n });\n\n const spawn = (): MainPort => {\n const worker = new Worker(kernelUrl, { type: \"module\", name: \"qntx-wallet\" });\n // oxlint-disable-next-line unicorn/require-post-message-target-origin -- Worker.postMessage takes a transfer list, not an origin\n worker.postMessage(init); // the kernel validates it strictly before startKernel\n return {\n post: (message: ProtocolValue, transfer: ArrayBuffer[]) => {\n worker.postMessage(message, transfer);\n },\n listen: (handler) => {\n const listener = (event: MessageEvent): void => {\n handler(event.data);\n };\n worker.addEventListener(\"message\", listener);\n return () => {\n worker.removeEventListener(\"message\", listener);\n };\n },\n onExit: (handler) => {\n // Web Workers have no exit event; error/messageerror are the only death signals.\n const listener = (): void => {\n handler();\n };\n worker.addEventListener(\"error\", listener);\n worker.addEventListener(\"messageerror\", listener);\n return () => {\n worker.removeEventListener(\"error\", listener);\n worker.removeEventListener(\"messageerror\", listener);\n };\n },\n terminate: () => {\n worker.terminate();\n },\n };\n };\n\n const wallet = await connectKernel({\n spawn,\n passkey: options.passkey,\n ceremony,\n onDestroy: () => {\n document.removeEventListener(\"visibilitychange\", onVisibility);\n globalThis.removeEventListener(\"pagehide\", onPageHide);\n globalThis.clearTimeout(hiddenTimer);\n },\n });\n\n // Page lifecycle: lock when the page has been hidden for 5 minutes, and on pagehide. A\n // BFCache-frozen page still runs the queued locked-event handler on restore, so the wallet\n // respawns then — terminating the worker directly would leave the wallet pointing at a dead\n // port.\n let hiddenTimer = 0;\n const onVisibility = (): void => {\n if (document.visibilityState === \"hidden\") {\n hiddenTimer = globalThis.setTimeout(() => {\n void bestEffort(async () => wallet.vault.lock());\n }, HIDDEN_LOCK_MS);\n } else {\n globalThis.clearTimeout(hiddenTimer);\n }\n };\n const onPageHide = (): void => {\n void bestEffort(async () => wallet.vault.lock());\n };\n document.addEventListener(\"visibilitychange\", onVisibility);\n globalThis.addEventListener(\"pagehide\", onPageHide);\n\n // Ask the browser to persist the vault once it exists — a denied request is fine.\n let persisted = false;\n const unsubscribe = wallet.subscribe(() => {\n if (!persisted && wallet.getSnapshot().vault !== \"uninitialized\") {\n persisted = true;\n unsubscribe();\n void bestEffort(async () => navigator.storage.persist());\n }\n });\n\n return wallet;\n}\n\nexport { createWebAuthnPasskey } from \"./passkey.ts\";\nexport type { WebAuthnRp } from \"./passkey.ts\";\n"],"mappings":";;;;;;;;;;AAgBA,MAAM,iBAAiB;AACvB,MAAM,gBAAgB;AACtB,MAAM,UAAU;AAEhB,SAAS,kBAAkB,SAA8B;CACvD,OAAO,IAAI,YAAY,sBAAsB,OAAO;AACtD;AAEA,SAAS,UAAU,SAA8B;CAC/C,OAAO,IAAI,YAAY,aAAa,OAAO;AAC7C;AAEA,SAAS,iBAAiB,OAAuB;CAC/C,IACE,iBAAiB,iBAChB,MAAM,SAAS,qBAAqB,M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