@seams/voiceid 0.27.0 → 0.29.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.
Files changed (36) hide show
  1. package/README.md +23 -3
  2. package/dist/esm/descriptor.js +5 -2
  3. package/dist/public/sdk/voiceid/CITRINET_LICENSE.txt +395 -0
  4. package/dist/public/sdk/voiceid/NOTICE.txt +19 -2
  5. package/dist/public/sdk/voiceid/addVoiceId-Dbd-PwWG.js +1 -0
  6. package/dist/public/sdk/voiceid/approval-C4KlEQYu.js +1 -0
  7. package/dist/public/sdk/voiceid/citrinet-int8.onnx +0 -0
  8. package/dist/public/sdk/voiceid/{deviceBridge-L6ZKqifG.js → deviceBridge-DQLPNdC8.js} +1 -1
  9. package/dist/public/sdk/voiceid/enrollment-DPOYb36Z.js +1 -0
  10. package/dist/public/sdk/voiceid/host.js +2 -2
  11. package/dist/public/sdk/voiceid/prompt-vztg41jG.js +614 -0
  12. package/dist/public/sdk/voiceid/unlock-Da49yYxd.js +1 -0
  13. package/dist/types/activation/addVoiceId.d.ts +2 -1
  14. package/dist/types/activation/manageEnrollment.d.ts +2 -1
  15. package/dist/types/browser/enrollment.d.ts +3 -2
  16. package/dist/types/browser/model.d.ts +1 -1
  17. package/dist/types/browser/phrase.d.ts +5 -2
  18. package/dist/types/browser/phraseTokens.d.ts +2 -0
  19. package/dist/types/browser/phraseVocabulary.d.ts +3 -3
  20. package/dist/types/browser/progress.d.ts +2 -1
  21. package/dist/types/capture/approval.d.ts +4 -2
  22. package/dist/types/capture/bridge.d.ts +2 -1
  23. package/dist/types/capture/deviceBridge.d.ts +7 -4
  24. package/dist/types/descriptor.d.ts +5 -2
  25. package/dist/types/host.d.ts +3 -2
  26. package/dist/types/index.d.ts +1 -1
  27. package/dist/types/session/activation.d.ts +2 -2
  28. package/dist/types/session/unlock.d.ts +2 -1
  29. package/dist/types/session/unlockFromDevice.d.ts +2 -2
  30. package/package.json +2 -2
  31. package/src/README.md +26 -16
  32. package/dist/public/sdk/voiceid/addVoiceId-DOpYRrar.js +0 -1
  33. package/dist/public/sdk/voiceid/approval-DNlI4I0d.js +0 -1
  34. package/dist/public/sdk/voiceid/enrollment-Cs7Tzcho.js +0 -1
  35. package/dist/public/sdk/voiceid/prompt-g_wE9gYv.js +0 -614
  36. package/dist/public/sdk/voiceid/unlock-B9WYZcqy.js +0 -1
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @seams/voiceid
2
2
 
3
- Optional browser VoiceID authentication for `@seams/wallet` 0.27.0.
3
+ Optional browser VoiceID authentication for `@seams/wallet` 0.29.0.
4
4
  This package owns microphone capture, enrollment, local inference, voice UI,
5
5
  and the model/runtime assets. The Wallet SDK owns custody, sessions, signing,
6
6
  and the trusted host API. Existing voice enrollments keep their storage identity.
@@ -9,6 +9,10 @@ and the trusted host API. Existing voice enrollments keep their storage identity
9
9
 
10
10
  Install matching Wallet and VoiceID versions, then import the descriptor:
11
11
 
12
+ ```sh
13
+ pnpm add @seams/wallet@0.29.0 @seams/voiceid@0.29.0
14
+ ```
15
+
12
16
  ```ts
13
17
  import { defineSeamsConfig } from '@seams/wallet';
14
18
  import { voiceIdAuthMethod } from '@seams/voiceid';
@@ -17,10 +21,25 @@ const config = defineSeamsConfig({
17
21
  walletOrigin,
18
22
  relayerUrl,
19
23
  publishableKey,
20
- authMethods: [voiceIdAuthMethod()],
24
+ authMethods: [voiceIdAuthMethod({ transcriptionModel: 'citrinet' })],
21
25
  });
22
26
  ```
23
27
 
28
+ Choose `transcriptionModel: 'aurora'` for the smaller speech model. Citrinet is
29
+ the default when this option is omitted. The choice applies to enrollment,
30
+ unlock, and transaction approval. Each action keeps its chosen model throughout
31
+ preparation and recording.
32
+
33
+ | Speech model | Uncompressed | Gzip |
34
+ | --- | ---: | ---: |
35
+ | Citrinet INT8 | 10.48 MB | 8.84 MB |
36
+ | Aurora INT8 | 1.34 MB | 1.02 MB |
37
+
38
+ Both models ship with this package. The browser downloads only the selected
39
+ speech model, plus the shared speaker model, speech detector, and inference
40
+ engine. Each model has its own integrity-checked cache. Changing the speech
41
+ model preserves saved speaker samples and verification thresholds.
42
+
24
43
  The root entry contains only the descriptor. Importing it or enabling it does not
25
44
  load capture code, ONNX Runtime, or models. The selected VoiceID action starts
26
45
  loading in the trusted Wallet iframe. Passkey and Email OTP flows remain independent.
@@ -115,7 +134,8 @@ enrollment and verification thresholds stay unchanged.
115
134
  Choose **Use system microphone** on the retry prompt to switch inputs. The next
116
135
  Record click uses the system default and remembers it after usable audio.
117
136
 
118
- The package remains a roughly 27 MB cold payload before transfer compression.
137
+ The cold payload before transfer compression is roughly 27 MB with Aurora or
138
+ 36 MB with Citrinet.
119
139
  Splitting it removes that payload from Wallet-only installations. It does not
120
140
  reduce the bytes needed for the first VoiceID operation.
121
141
 
@@ -1,7 +1,10 @@
1
1
  //#region src/descriptor.ts
2
2
  /** A small opt-in descriptor with no capture, model, or host implementation. */
3
- function voiceIdAuthMethod() {
4
- return { kind: "voiceid" };
3
+ function voiceIdAuthMethod(options = {}) {
4
+ return {
5
+ kind: "voiceid",
6
+ transcriptionModel: options.transcriptionModel ?? "citrinet"
7
+ };
5
8
  }
6
9
  //#endregion
7
10
  export { voiceIdAuthMethod };
@@ -0,0 +1,395 @@
1
+ Attribution 4.0 International
2
+
3
+ =======================================================================
4
+
5
+ Creative Commons Corporation ("Creative Commons") is not a law firm and
6
+ does not provide legal services or legal advice. Distribution of
7
+ Creative Commons public licenses does not create a lawyer-client or
8
+ other relationship. Creative Commons makes its licenses and related
9
+ information available on an "as-is" basis. Creative Commons gives no
10
+ warranties regarding its licenses, any material licensed under their
11
+ terms and conditions, or any related information. Creative Commons
12
+ disclaims all liability for damages resulting from their use to the
13
+ fullest extent possible.
14
+
15
+ Using Creative Commons Public Licenses
16
+
17
+ Creative Commons public licenses provide a standard set of terms and
18
+ conditions that creators and other rights holders may use to share
19
+ original works of authorship and other material subject to copyright
20
+ and certain other rights specified in the public license below. The
21
+ following considerations are for informational purposes only, are not
22
+ exhaustive, and do not form part of our licenses.
23
+
24
+ Considerations for licensors: Our public licenses are
25
+ intended for use by those authorized to give the public
26
+ permission to use material in ways otherwise restricted by
27
+ copyright and certain other rights. Our licenses are
28
+ irrevocable. Licensors should read and understand the terms
29
+ and conditions of the license they choose before applying it.
30
+ Licensors should also secure all rights necessary before
31
+ applying our licenses so that the public can reuse the
32
+ material as expected. Licensors should clearly mark any
33
+ material not subject to the license. This includes other CC-
34
+ licensed material, or material used under an exception or
35
+ limitation to copyright. More considerations for licensors:
36
+ wiki.creativecommons.org/Considerations_for_licensors
37
+
38
+ Considerations for the public: By using one of our public
39
+ licenses, a licensor grants the public permission to use the
40
+ licensed material under specified terms and conditions. If
41
+ the licensor's permission is not necessary for any reason--for
42
+ example, because of any applicable exception or limitation to
43
+ copyright--then that use is not regulated by the license. Our
44
+ licenses grant only permissions under copyright and certain
45
+ other rights that a licensor has authority to grant. Use of
46
+ the licensed material may still be restricted for other
47
+ reasons, including because others have copyright or other
48
+ rights in the material. A licensor may make special requests,
49
+ such as asking that all changes be marked or described.
50
+ Although not required by our licenses, you are encouraged to
51
+ respect those requests where reasonable. More considerations
52
+ for the public:
53
+ wiki.creativecommons.org/Considerations_for_licensees
54
+
55
+ =======================================================================
56
+
57
+ Creative Commons Attribution 4.0 International Public License
58
+
59
+ By exercising the Licensed Rights (defined below), You accept and agree
60
+ to be bound by the terms and conditions of this Creative Commons
61
+ Attribution 4.0 International Public License ("Public License"). To the
62
+ extent this Public License may be interpreted as a contract, You are
63
+ granted the Licensed Rights in consideration of Your acceptance of
64
+ these terms and conditions, and the Licensor grants You such rights in
65
+ consideration of benefits the Licensor receives from making the
66
+ Licensed Material available under these terms and conditions.
67
+
68
+
69
+ Section 1 -- Definitions.
70
+
71
+ a. Adapted Material means material subject to Copyright and Similar
72
+ Rights that is derived from or based upon the Licensed Material
73
+ and in which the Licensed Material is translated, altered,
74
+ arranged, transformed, or otherwise modified in a manner requiring
75
+ permission under the Copyright and Similar Rights held by the
76
+ Licensor. For purposes of this Public License, where the Licensed
77
+ Material is a musical work, performance, or sound recording,
78
+ Adapted Material is always produced where the Licensed Material is
79
+ synched in timed relation with a moving image.
80
+
81
+ b. Adapter's License means the license You apply to Your Copyright
82
+ and Similar Rights in Your contributions to Adapted Material in
83
+ accordance with the terms and conditions of this Public License.
84
+
85
+ c. Copyright and Similar Rights means copyright and/or similar rights
86
+ closely related to copyright including, without limitation,
87
+ performance, broadcast, sound recording, and Sui Generis Database
88
+ Rights, without regard to how the rights are labeled or
89
+ categorized. For purposes of this Public License, the rights
90
+ specified in Section 2(b)(1)-(2) are not Copyright and Similar
91
+ Rights.
92
+
93
+ d. Effective Technological Measures means those measures that, in the
94
+ absence of proper authority, may not be circumvented under laws
95
+ fulfilling obligations under Article 11 of the WIPO Copyright
96
+ Treaty adopted on December 20, 1996, and/or similar international
97
+ agreements.
98
+
99
+ e. Exceptions and Limitations means fair use, fair dealing, and/or
100
+ any other exception or limitation to Copyright and Similar Rights
101
+ that applies to Your use of the Licensed Material.
102
+
103
+ f. Licensed Material means the artistic or literary work, database,
104
+ or other material to which the Licensor applied this Public
105
+ License.
106
+
107
+ g. Licensed Rights means the rights granted to You subject to the
108
+ terms and conditions of this Public License, which are limited to
109
+ all Copyright and Similar Rights that apply to Your use of the
110
+ Licensed Material and that the Licensor has authority to license.
111
+
112
+ h. Licensor means the individual(s) or entity(ies) granting rights
113
+ under this Public License.
114
+
115
+ i. Share means to provide material to the public by any means or
116
+ process that requires permission under the Licensed Rights, such
117
+ as reproduction, public display, public performance, distribution,
118
+ dissemination, communication, or importation, and to make material
119
+ available to the public including in ways that members of the
120
+ public may access the material from a place and at a time
121
+ individually chosen by them.
122
+
123
+ j. Sui Generis Database Rights means rights other than copyright
124
+ resulting from Directive 96/9/EC of the European Parliament and of
125
+ the Council of 11 March 1996 on the legal protection of databases,
126
+ as amended and/or succeeded, as well as other essentially
127
+ equivalent rights anywhere in the world.
128
+
129
+ k. You means the individual or entity exercising the Licensed Rights
130
+ under this Public License. Your has a corresponding meaning.
131
+
132
+
133
+ Section 2 -- Scope.
134
+
135
+ a. License grant.
136
+
137
+ 1. Subject to the terms and conditions of this Public License,
138
+ the Licensor hereby grants You a worldwide, royalty-free,
139
+ non-sublicensable, non-exclusive, irrevocable license to
140
+ exercise the Licensed Rights in the Licensed Material to:
141
+
142
+ a. reproduce and Share the Licensed Material, in whole or
143
+ in part; and
144
+
145
+ b. produce, reproduce, and Share Adapted Material.
146
+
147
+ 2. Exceptions and Limitations. For the avoidance of doubt, where
148
+ Exceptions and Limitations apply to Your use, this Public
149
+ License does not apply, and You do not need to comply with
150
+ its terms and conditions.
151
+
152
+ 3. Term. The term of this Public License is specified in Section
153
+ 6(a).
154
+
155
+ 4. Media and formats; technical modifications allowed. The
156
+ Licensor authorizes You to exercise the Licensed Rights in
157
+ all media and formats whether now known or hereafter created,
158
+ and to make technical modifications necessary to do so. The
159
+ Licensor waives and/or agrees not to assert any right or
160
+ authority to forbid You from making technical modifications
161
+ necessary to exercise the Licensed Rights, including
162
+ technical modifications necessary to circumvent Effective
163
+ Technological Measures. For purposes of this Public License,
164
+ simply making modifications authorized by this Section 2(a)
165
+ (4) never produces Adapted Material.
166
+
167
+ 5. Downstream recipients.
168
+
169
+ a. Offer from the Licensor -- Licensed Material. Every
170
+ recipient of the Licensed Material automatically
171
+ receives an offer from the Licensor to exercise the
172
+ Licensed Rights under the terms and conditions of this
173
+ Public License.
174
+
175
+ b. No downstream restrictions. You may not offer or impose
176
+ any additional or different terms or conditions on, or
177
+ apply any Effective Technological Measures to, the
178
+ Licensed Material if doing so restricts exercise of the
179
+ Licensed Rights by any recipient of the Licensed
180
+ Material.
181
+
182
+ 6. No endorsement. Nothing in this Public License constitutes or
183
+ may be construed as permission to assert or imply that You
184
+ are, or that Your use of the Licensed Material is, connected
185
+ with, or sponsored, endorsed, or granted official status by,
186
+ the Licensor or others designated to receive attribution as
187
+ provided in Section 3(a)(1)(A)(i).
188
+
189
+ b. Other rights.
190
+
191
+ 1. Moral rights, such as the right of integrity, are not
192
+ licensed under this Public License, nor are publicity,
193
+ privacy, and/or other similar personality rights; however, to
194
+ the extent possible, the Licensor waives and/or agrees not to
195
+ assert any such rights held by the Licensor to the limited
196
+ extent necessary to allow You to exercise the Licensed
197
+ Rights, but not otherwise.
198
+
199
+ 2. Patent and trademark rights are not licensed under this
200
+ Public License.
201
+
202
+ 3. To the extent possible, the Licensor waives any right to
203
+ collect royalties from You for the exercise of the Licensed
204
+ Rights, whether directly or through a collecting society
205
+ under any voluntary or waivable statutory or compulsory
206
+ licensing scheme. In all other cases the Licensor expressly
207
+ reserves any right to collect such royalties.
208
+
209
+
210
+ Section 3 -- License Conditions.
211
+
212
+ Your exercise of the Licensed Rights is expressly made subject to the
213
+ following conditions.
214
+
215
+ a. Attribution.
216
+
217
+ 1. If You Share the Licensed Material (including in modified
218
+ form), You must:
219
+
220
+ a. retain the following if it is supplied by the Licensor
221
+ with the Licensed Material:
222
+
223
+ i. identification of the creator(s) of the Licensed
224
+ Material and any others designated to receive
225
+ attribution, in any reasonable manner requested by
226
+ the Licensor (including by pseudonym if
227
+ designated);
228
+
229
+ ii. a copyright notice;
230
+
231
+ iii. a notice that refers to this Public License;
232
+
233
+ iv. a notice that refers to the disclaimer of
234
+ warranties;
235
+
236
+ v. a URI or hyperlink to the Licensed Material to the
237
+ extent reasonably practicable;
238
+
239
+ b. indicate if You modified the Licensed Material and
240
+ retain an indication of any previous modifications; and
241
+
242
+ c. indicate the Licensed Material is licensed under this
243
+ Public License, and include the text of, or the URI or
244
+ hyperlink to, this Public License.
245
+
246
+ 2. You may satisfy the conditions in Section 3(a)(1) in any
247
+ reasonable manner based on the medium, means, and context in
248
+ which You Share the Licensed Material. For example, it may be
249
+ reasonable to satisfy the conditions by providing a URI or
250
+ hyperlink to a resource that includes the required
251
+ information.
252
+
253
+ 3. If requested by the Licensor, You must remove any of the
254
+ information required by Section 3(a)(1)(A) to the extent
255
+ reasonably practicable.
256
+
257
+ 4. If You Share Adapted Material You produce, the Adapter's
258
+ License You apply must not prevent recipients of the Adapted
259
+ Material from complying with this Public License.
260
+
261
+
262
+ Section 4 -- Sui Generis Database Rights.
263
+
264
+ Where the Licensed Rights include Sui Generis Database Rights that
265
+ apply to Your use of the Licensed Material:
266
+
267
+ a. for the avoidance of doubt, Section 2(a)(1) grants You the right
268
+ to extract, reuse, reproduce, and Share all or a substantial
269
+ portion of the contents of the database;
270
+
271
+ b. if You include all or a substantial portion of the database
272
+ contents in a database in which You have Sui Generis Database
273
+ Rights, then the database in which You have Sui Generis Database
274
+ Rights (but not its individual contents) is Adapted Material; and
275
+
276
+ c. You must comply with the conditions in Section 3(a) if You Share
277
+ all or a substantial portion of the contents of the database.
278
+
279
+ For the avoidance of doubt, this Section 4 supplements and does not
280
+ replace Your obligations under this Public License where the Licensed
281
+ Rights include other Copyright and Similar Rights.
282
+
283
+
284
+ Section 5 -- Disclaimer of Warranties and Limitation of Liability.
285
+
286
+ a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE
287
+ EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS
288
+ AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF
289
+ ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,
290
+ IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,
291
+ WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
292
+ PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,
293
+ ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT
294
+ KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT
295
+ ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
296
+
297
+ b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE
298
+ TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,
299
+ NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,
300
+ INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,
301
+ COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR
302
+ USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN
303
+ ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR
304
+ DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR
305
+ IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
306
+
307
+ c. The disclaimer of warranties and limitation of liability provided
308
+ above shall be interpreted in a manner that, to the extent
309
+ possible, most closely approximates an absolute disclaimer and
310
+ waiver of all liability.
311
+
312
+
313
+ Section 6 -- Term and Termination.
314
+
315
+ a. This Public License applies for the term of the Copyright and
316
+ Similar Rights licensed here. However, if You fail to comply with
317
+ this Public License, then Your rights under this Public License
318
+ terminate automatically.
319
+
320
+ b. Where Your right to use the Licensed Material has terminated under
321
+ Section 6(a), it reinstates:
322
+
323
+ 1. automatically as of the date the violation is cured, provided
324
+ it is cured within 30 days of Your discovery of the
325
+ violation; or
326
+
327
+ 2. upon express reinstatement by the Licensor.
328
+
329
+ For the avoidance of doubt, this Section 6(b) does not affect any
330
+ right the Licensor may have to seek remedies for Your violations
331
+ of this Public License.
332
+
333
+ c. For the avoidance of doubt, the Licensor may also offer the
334
+ Licensed Material under separate terms or conditions or stop
335
+ distributing the Licensed Material at any time; however, doing so
336
+ will not terminate this Public License.
337
+
338
+ d. Sections 1, 5, 6, 7, and 8 survive termination of this Public
339
+ License.
340
+
341
+
342
+ Section 7 -- Other Terms and Conditions.
343
+
344
+ a. The Licensor shall not be bound by any additional or different
345
+ terms or conditions communicated by You unless expressly agreed.
346
+
347
+ b. Any arrangements, understandings, or agreements regarding the
348
+ Licensed Material not stated herein are separate from and
349
+ independent of the terms and conditions of this Public License.
350
+
351
+
352
+ Section 8 -- Interpretation.
353
+
354
+ a. For the avoidance of doubt, this Public License does not, and
355
+ shall not be interpreted to, reduce, limit, restrict, or impose
356
+ conditions on any use of the Licensed Material that could lawfully
357
+ be made without permission under this Public License.
358
+
359
+ b. To the extent possible, if any provision of this Public License is
360
+ deemed unenforceable, it shall be automatically reformed to the
361
+ minimum extent necessary to make it enforceable. If the provision
362
+ cannot be reformed, it shall be severed from this Public License
363
+ without affecting the enforceability of the remaining terms and
364
+ conditions.
365
+
366
+ c. No term or condition of this Public License will be waived and no
367
+ failure to comply consented to unless expressly agreed to by the
368
+ Licensor.
369
+
370
+ d. Nothing in this Public License constitutes or may be interpreted
371
+ as a limitation upon, or waiver of, any privileges and immunities
372
+ that apply to the Licensor or You, including from the legal
373
+ processes of any jurisdiction or authority.
374
+
375
+
376
+ =======================================================================
377
+
378
+ Creative Commons is not a party to its public
379
+ licenses. Notwithstanding, Creative Commons may elect to apply one of
380
+ its public licenses to material it publishes and in those instances
381
+ will be considered the “Licensor.” The text of the Creative Commons
382
+ public licenses is dedicated to the public domain under the CC0 Public
383
+ Domain Dedication. Except for the limited purpose of indicating that
384
+ material is shared under a Creative Commons public license or as
385
+ otherwise permitted by the Creative Commons policies published at
386
+ creativecommons.org/policies, Creative Commons does not authorize the
387
+ use of the trademark "Creative Commons" or any other trademark or logo
388
+ of Creative Commons without its prior written consent including,
389
+ without limitation, in connection with any unauthorized modifications
390
+ to any of its public licenses or any other arrangements,
391
+ understandings, or agreements concerning use of licensed material. For
392
+ the avoidance of doubt, this paragraph does not form part of the
393
+ public licenses.
394
+
395
+ Creative Commons may be contacted at creativecommons.org.
@@ -46,8 +46,25 @@ Changes: exported the publisher's INT8-weight checkpoint to ONNX, with
46
46
  full-waveform log-mel preprocessing. The complex STFT is represented by ONNX
47
47
  STFT and power reduction. Constant folding is disabled to retain INT8 weights
48
48
  in the downloaded file. Execution dequantizes weights to floating point.
49
- A 16-phrase token vocabulary is generated from the publisher's SentencePiece
50
- tokenizer. No retraining or user recordings are included.
49
+ Decoder pieces come from the publisher's SentencePiece tokenizer.
50
+ No retraining or user recordings are included.
51
+
52
+ NVIDIA Citrinet-256 LS spoken phrase model
53
+
54
+ Source: https://huggingface.co/nvidia/stt_en_citrinet_256_ls
55
+ Revision: c7cdacff0262bbb2a17771d20ec9f9f3b5cff6ed
56
+ Publisher: NVIDIA
57
+ License: Creative Commons Attribution 4.0 International; see CITRINET_LICENSE.txt.
58
+ License URL: https://creativecommons.org/licenses/by/4.0/
59
+ Checkpoint SHA-256: a00c8fb75a2bcc37271275293bce950863e4e069d43f6cf193d42fcf605aa21c
60
+ ONNX SHA-256: 875f58df0e2a593017ac9550c8fab68c4343cd1fbb2a042290450aa125441ed5
61
+
62
+ Changes: exported to ONNX with full 16 kHz mono waveform preprocessing,
63
+ folded batch normalization, and per-channel INT8 weight storage.
64
+ Execution dequantizes weights to FP32. The publisher's WordPiece decoder
65
+ vocabulary is embedded in code. No retraining or user recordings are included.
66
+ The exporter adapts Thomas Lackner's MIT-licensed BabyTalk architecture.
67
+ See tests/scripts/voiceid-citrinet/NOTICE.md in the source repository.
51
68
 
52
69
  Silero VAD v5.1.2 (MIT), snakers4/silero-vad, revision 6478567951ae5c9979ad7b234185b5515f4be7a1.
53
70
  Model SHA-256: 2623a2953f6ff3d2c1e61740c6cdb7168133479b267dfef114a4a3cc5bdd788f
@@ -0,0 +1 @@
1
+ import"./prompt-vztg41jG.js";import{a as e,i as t,r as n,t as r}from"./deviceBridge-DQLPNdC8.js";import{a as i,d as a,i as o,o as s,s as c,t as l}from"./enrollment-DPOYb36Z.js";import{IndexedDBManager as u,WorkerDeferred as d,allocateWalletAuthMethodId as f,alphabetizeStringify as p,base64UrlDecode as m,buildMethodBoundEnvelopeOwnership as h,buildPasskeyCustodyEnvelopeRecord as g,buildVoiceIdEnvelopeFactor as _,buildWalletCustodySeedBinding as v,custodyEnvelopeBindingJsonV1 as y,fetchWithWalletHomeDiscovery as b,isVoiceIdSeedEnvelope as x,parseDigestB64u as S,parseEnvelopeRevision as C,parsePasskeyCustodyEnvelopeRecord as w,parsePasskeyEnvelopeId as T,parseResealedEnvelopeResult as E,parseVoiceIdDevicePublicKeyB64u as D,parseWalletAuthMethodId as O,parseWalletAuthMethodRecordV2 as k,parseWalletId as A,readUnlockedWalletEd25519ExportRootCapabilityV1 as j,rejectUnknownFields as M,requireRecord as N,secureRandomId as P,sha256DigestB64u as F,toError as I,walletCustodyCeremonyTransportFromWorkerContextV1 as L,walletSessionAuthorizations as R}from"../voiceid-host.js";async function z(e){let t=N(e,`pending VoiceID activation`);if(M(t,[`kind`,`walletId`,`walletAuthMethodId`,`devicePublicKeyB64u`,`deviceKeyId`,`custodyEnvelope`],`pending VoiceID activation`),t.kind!==`pending_voiceid_activation_v1`)throw Error(`Pending VoiceID activation kind is invalid.`);let n=A(t.walletId),r=O(t.walletAuthMethodId);if(!n.ok||!r.ok)throw Error(`Pending VoiceID activation identity is invalid.`);let i=D(t.devicePublicKeyB64u),a=S(t.deviceKeyId),o=w(t.custodyEnvelope);if(!x(o)||o.walletId!==n.value||o.ownership.walletAuthMethodId!==r.value||o.factor.deviceKeyId!==a||Number(o.envelopeRevision)!==1||await F(m(i))!==a)throw Error(`Pending VoiceID activation binding is invalid.`);return{kind:`pending_voiceid_activation_v1`,walletId:n.value,walletAuthMethodId:r.value,devicePublicKeyB64u:i,deviceKeyId:a,custodyEnvelope:o}}function B(e){throw Error(`Unhandled VoiceID activation plan: ${String(e)}`)}function V(e,t){let{capability:n}=e;if(n.walletId!==e.walletId||n.walletSessionId!==t.walletSessionId||n.expiresAtMs<=Date.now())throw Error(`VoiceID activation requires the unlocked owner seed and Wallet Session.`)}async function H(e,t){let n=_({deviceKeyId:t.deviceKeyId}),r=v(),i=h(e.walletAuthMethodId),a=C(1),o=y({walletId:e.walletId,envelopeId:e.envelopeId,factor:n,envelopeRevision:a,binding:r,ownership:i}),s=t.factorSecret32.slice(),c;try{c=E(await e.reseal({capability:e.capability,bindingJson:o,factorSecret:s.buffer}))}finally{s.byteLength>0&&s.fill(0)}if(await F(m(c.sealedCustodySecretB64u))!==c.ciphertextDigestB64u)throw Error(`VoiceID worker returned a mismatched ciphertext digest.`);let l=Date.now(),u=w(g({envelopeId:e.envelopeId,walletId:e.walletId,ownership:i,binding:r,factor:n,envelopeRevision:a,nonceB64u:c.nonceB64u,sealedCustodySecretB64u:c.sealedCustodySecretB64u,ciphertextDigestB64u:c.ciphertextDigestB64u,aadHashB64u:c.aadHashB64u,lifecycle:{state:`active`,activatedAtMs:l},createdAtMs:l,updatedAtMs:l}));if(!x(u))throw Error(`VoiceID worker produced an invalid seed envelope.`);return{kind:`pending_voiceid_activation_v1`,walletId:e.walletId,walletAuthMethodId:e.walletAuthMethodId,devicePublicKeyB64u:t.publicKeyB64u,deviceKeyId:t.deviceKeyId,custodyEnvelope:u}}async function U(e){let t=e.plan;switch(t.kind){case`new`:V(t,e.ownerCredential);break;case`resume`:break;default:return B(t)}let n=t.kind===`new`?t.walletId:t.pending.walletId,r=t.kind===`new`?t.walletAuthMethodId:t.pending.walletAuthMethodId,i=await e.capture({walletId:n,walletAuthMethodId:r,signal:e.signal,onCapture:e.onCapture,phrase:e.phrase}),a;try{switch(t.kind){case`new`:a=await H(t,i),await e.persistPending(a);break;case`resume`:if(t.pending.devicePublicKeyB64u!==i.publicKeyB64u||t.pending.deviceKeyId!==i.deviceKeyId)throw Error(`VoiceID activation retry found a different device key.`);a=t.pending;break;default:return B(t)}}finally{i.factorSecret32.fill(0)}if(e.signal.aborted)throw Error(`VoiceID activation was cancelled.`);let o=await e.http.activate({ownerCredential:e.ownerCredential,walletId:a.walletId,walletAuthMethodId:a.walletAuthMethodId,devicePublicKeyB64u:a.devicePublicKeyB64u,deviceKeyId:a.deviceKeyId,custodyEnvelope:a.custodyEnvelope,signal:e.signal});return await e.persistActive(o,a),{authMethod:o,pending:a}}const W=`voiceid-activation-v1:`;function G(e,t){return`${W}${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function K(e){return`${W}${encodeURIComponent(e)}:`}function q(e,t){return p(e)===p(t)}async function J(e){if(e==null)return null;let t=N(e,`stored VoiceID activation`);switch(t.kind){case`pending`:return M(t,[`kind`,`pending`],`stored VoiceID activation`),{kind:`pending`,pending:await z(t.pending)};case`active`:{M(t,[`kind`,`pending`,`authMethod`],`stored VoiceID activation`);let e=await z(t.pending),n=k(t.authMethod);if(!n||n.kind!==`voiceid`||n.status!==`active`||n.walletId!==e.walletId||n.walletAuthMethodId!==e.walletAuthMethodId||n.deviceKeyId!==e.deviceKeyId||n.devicePublicKeyB64u!==e.devicePublicKeyB64u)throw Error(`Stored VoiceID activation method is invalid.`);return{kind:`active`,pending:e,authMethod:n}}default:throw Error(`Stored VoiceID activation lifecycle is invalid.`)}}var Y=class{constructor(e){this.storage=e}async persistPending(e){let t=G(e.walletId,e.walletAuthMethodId),n=await J(await this.storage.getAppState(t));if(n){if(n.kind===`pending`&&q(n.pending,e))return;throw Error(`A different VoiceID activation already owns this method ID.`)}await this.storage.setAppState(t,{kind:`pending`,pending:e})}async persistActive(e,t){let n=G(t.walletId,t.walletAuthMethodId),r=await J(await this.storage.getAppState(n));if(!r||!q(r.pending,t))throw Error(`VoiceID activation has no matching pending record.`);if(e.walletId!==t.walletId||e.walletAuthMethodId!==t.walletAuthMethodId||e.deviceKeyId!==t.deviceKeyId||e.devicePublicKeyB64u!==t.devicePublicKeyB64u)throw Error(`VoiceID server method does not match pending activation.`);await this.storage.upsertWalletAuthMethodV2(e),await this.storage.setAppState(n,{kind:`active`,pending:t,authMethod:e})}async readPending(e,t){let n=await J(await this.storage.getAppState(G(e,t)));if(!n||n.kind===`active`)return null;if(n.pending.walletId!==e||n.pending.walletAuthMethodId!==t)throw Error(`Stored VoiceID activation key does not match its record.`);return n.pending}async listPending(e){let t=await this.storage.listAppStateEntriesByPrefix(K(e)),n=[];for(let r of t){let t=await J(r.value);if(t){if(t.pending.walletId!==e||G(e,t.pending.walletAuthMethodId)!==r.key)throw Error(`Stored VoiceID activation key does not match its record.`);t.kind===`pending`&&n.push(t.pending)}}return n}};const X=`http://www.w3.org/2000/svg`;async function Z(e,t,n,r){let i=document.querySelector(`.seams-voiceid-activation-surface`);if(!(i instanceof HTMLElement))throw Error(`Open VoiceID management in the Wallet.`);let a=new Q(i,e,t,n,r);try{await a.result}finally{a.dispose()}}var Q=class{completion=new d;result=this.completion.promise;element=document.createElement(`div`);enrollment=document.createElement(`div`);enrollmentValue=document.createElement(`span`);startOver=document.createElement(`p`);status=document.createElement(`p`);actions;busy=!1;closed=!1;constructor(e,t,n,r,i){this.parent=e,this.context=t,this.scope=n,this.signal=r,this.model=i,this.element.className=`seams-voiceid-prompt seams-voiceid-management`;let a=document.createElement(`div`);a.className=`seams-voiceid-management-header`;let o=document.createElement(`button`);o.type=`button`,o.className=`seams-voiceid-management-back`,o.setAttribute(`aria-label`,`Back`),o.append($(`M15 6l-6 6 6 6`,20)),o.addEventListener(`click`,this.cancel);let s=document.createElement(`h2`);s.textContent=`Manage voice`,a.append(o,s);let c=document.createElement(`p`);c.className=`seams-voiceid-management-intro`,c.textContent=`Voice unlock on this device. Each change asks for your passkey.`,this.element.append(a,c,this.enrollmentRow()),this.actions={reset:this.resetAction(),improve:this.action(`improve`,`Improve recognition`,!0),import:this.action(`import`,`Use saved enrollment`,!1),replace:this.startOverAction()},this.status.setAttribute(`role`,`status`),this.element.append(this.status),this.enrollmentValue.textContent=`Checking…`,this.actions.import.button.hidden=!0,this.render(null,!1,!1),this.parent.replaceChildren(this.element),this.signal.addEventListener(`abort`,this.cancel,{once:!0}),this.refresh(),o.focus()}enrollmentRow(){this.enrollment.className=`seams-voiceid-management-enrollment`;let e=document.createElement(`span`);e.textContent=`Enrollment`,this.enrollmentValue.className=`seams-voiceid-management-value`;let t=document.createElement(`span`);return t.className=`seams-voiceid-management-summary`,t.append(this.enrollmentValue),this.enrollment.append(e,t),this.enrollment}resetAction(){let e=document.createElement(`button`);e.type=`button`,e.className=`seams-voiceid-management-reset`,e.textContent=`Reset`,e.setAttribute(`aria-label`,`Reset improvements`),e.addEventListener(`click`,this.begin.bind(this,`reset`));let t=document.createElement(`span`);return t.className=`seams-voiceid-management-enrollment-detail`,this.enrollment.querySelector(`.seams-voiceid-management-summary`)?.append(t),this.enrollment.append(e),{button:e,title:e,detail:t,frame:this.enrollment}}startOverAction(){return this.startOver.className=`seams-voiceid-management-section`,this.startOver.textContent=`Start over`,this.element.append(this.startOver),this.action(`replace`,`Record voice again`,!1)}action(e,t,n){let r=document.createElement(`button`);r.type=`button`,r.className=`seams-voiceid-management-action`;let i=document.createElement(`span`),a=document.createElement(`span`);a.className=`seams-voiceid-management-action-heading`;let o=document.createElement(`span`);o.id=`seams-voiceid-management-${e}-title`,o.textContent=t,a.append(o);let s=[];if(n){let t=document.createElement(`span`);t.id=`seams-voiceid-management-${e}-chip`,t.className=`seams-voiceid-management-chip`,t.textContent=`Experimental`,a.append(t),s.push(t.id)}let c=document.createElement(`span`);return c.id=`seams-voiceid-management-${e}-detail`,c.className=`seams-voiceid-management-action-detail`,s.push(c.id),i.append(a,c),r.append(i,$(`M9 6l6 6-6 6`,16)),r.setAttribute(`aria-labelledby`,o.id),r.setAttribute(`aria-describedby`,s.join(` `)),r.disabled=!0,r.addEventListener(`click`,this.begin.bind(this,e)),this.element.append(r),{button:r,title:o,detail:c,frame:r}}async refresh(){try{let e=await s(this.scope),t=e?null:await i();if(this.closed)return;this.render(e,t!==null,!0)}catch(e){this.completion.reject(I(e))}}render(e,t,n){let r=e?.adaptation??null,{improve:i,reset:a,import:o,replace:s}=this.actions;n&&(this.enrollment.dataset.enrollment=r?.kind??`missing`,this.enrollmentValue.textContent=r===null?`Not on this device`:r.kind===`adapted`?`Improved`:`Original`,i.button.hidden=e===null,o.button.hidden=!t),a.button.hidden=r?.kind!==`adapted`,a.detail.textContent=r?.kind===`adapted`?`Saved on this device`:``,i.title.textContent=r?.kind===`adapted`?`Improve again`:`Improve recognition`,i.detail.textContent=r?.kind===`adapted`?`Replace the added samples. Your original enrollment stays.`:`Add three samples. They stay until you replace or reset them.`,o.detail.textContent=`Import the voice enrollment saved in this browser.`,s.detail.textContent=r?.kind===`adapted`?`Replace your enrollment and remove improvements.`:`Replace your enrollment with three new samples.`,this.startOver.hidden=i.button.hidden&&o.button.hidden;for(let e of Object.values(this.actions))delete e.frame.dataset.state,e.button.disabled=!n;this.status.textContent=``,delete this.status.dataset.placement}show(e,t,n){let r=this.actions[e];if(this.status.textContent=n,r.button.hidden){this.status.dataset.placement=`dialog`;return}r.frame.dataset.state=t,r.detail.textContent=n}begin(e){if(!(this.busy||this.closed)){this.busy=!0;for(let e of Object.values(this.actions))e.button.disabled=!0;this.show(e,`pending`,`Confirm with your passkey to continue.`),this.perform(e)}}async perform(e){try{let r=await t(this.scope,`enrolled`),a=await s(this.scope),c=a?{kind:`present`,enrollment:a}:{kind:`missing`};if(e===`improve`&&c.kind===`missing`)throw Error(`Record or import your original voice first.`);let u=e===`import`?await i():null;if(e===`import`&&(!u||c.kind!==`missing`))throw Error(`The previous enrollment is unavailable.`);let d=await n.request(this.context,this.scope,r,c,e,this.signal);switch(this.signal.throwIfAborted(),e){case`improve`:if(c.kind!==`present`)throw Error(`Original voice enrollment is unavailable.`);await l({kind:`improve`,scope:this.scope,guard:r,snapshot:c,confirmation:d},this.signal,this.model);break;case`replace`:await l({kind:`replace`,scope:this.scope,guard:r,snapshot:c,confirmation:d},this.signal,this.model);break;case`reset`:await o(this.scope,r,c,{kind:`reset`,confirmation:d},this.signal);break;case`import`:if(!u)throw Error(`Previous voice enrollment is unavailable.`);await o(this.scope,r,c,{kind:`import`,baseline:u,confirmation:d},this.signal);break}this.closed||this.completion.resolve()}catch(t){if(this.closed)return;this.parent.replaceChildren(this.element),await this.refresh(),this.closed||this.show(e,`error`,t instanceof Error?t.message:`VoiceID could not be updated.`)}finally{this.busy=!1}}cancel=()=>{this.closed||(this.closed=!0,this.parent.dispatchEvent(new Event(`cancel`,{bubbles:!0})),this.completion.reject(Error(`VoiceID management was cancelled.`)))};dispose(){this.closed=!0,this.signal.removeEventListener(`abort`,this.cancel),this.element.remove()}};function $(e,t){let n=document.createElementNS(X,`svg`);n.setAttribute(`viewBox`,`0 0 24 24`),n.setAttribute(`width`,String(t)),n.setAttribute(`height`,String(t)),n.setAttribute(`aria-hidden`,`true`);let r=document.createElementNS(X,`path`);return r.setAttribute(`d`,e),r.setAttribute(`fill`,`none`),r.setAttribute(`stroke`,`currentColor`),r.setAttribute(`stroke-width`,`1.75`),r.setAttribute(`stroke-linecap`,`round`),r.setAttribute(`stroke-linejoin`,`round`),n.append(r),n}async function ee(e,t){return await e.requestOperation({kind:`walletCustodyCeremony`,request:{type:`resealWalletCustodyFromUnlockedCapability`,payload:{capability:t.capability,replacementEnvelopeBindingJson:t.bindingJson,replacementFactorSecret:t.factorSecret},transfer:[t.factorSecret]}})}async function te(t,n){let r=await u.resolveSelectedWalletAuthority(n);if(r.kind!==`resolved`||r.selection.lockState!==`unlocked`||r.selection.walletId!==n||r.authMethod.status!==`active`||r.authMethod.walletId!==n||r.authMethod.walletAuthorityId!==r.authority.authorityId||r.authority.state!==`active`||r.authority.walletId!==n)throw Error(`Unlock this wallet with a passkey or Email OTP before activating VoiceID.`);let i=await R.readExactWithOperationCredential({walletId:n,authorityId:r.authority.authorityId,authMethodId:r.authMethod.walletAuthMethodId});if(i.kind!==`found`||i.record.walletId!==n||i.record.authMethodId!==r.authMethod.walletAuthMethodId||i.record.authorityId!==r.authority.authorityId||i.record.expiresAtMs<=Date.now())throw Error(`VoiceID activation requires an active owner Wallet Session.`);let o=await u.listWalletAuthMethodsV2ForWallet(n);for(let e of o){if(e.kind!==`voiceid`||e.status!==`active`||e.walletAuthorityId!==r.authority.authorityId)continue;let i=await a(n,e.walletAuthMethodId);if(i&&i.deviceKeyId===e.deviceKeyId)return{kind:`enroll_existing`,walletId:n,walletAuthMethodId:e.walletAuthMethodId,context:t}}if(r.authMethod.kind===`voiceid`)throw Error(`An existing local VoiceID enrollment is required for management.`);let s=new Y(u),c=await s.listPending(n);if(c.length>1)throw Error(`More than one VoiceID activation is pending for this wallet.`);let l;if(c.length===1)l={kind:`resume`,pending:c[0]};else{let e=j(n);if(!e||e.walletSessionId!==i.operationCredential.walletSessionId)throw Error(`Unlock the wallet again to make its custody seed available for VoiceID.`);let r=T(P(`wallet-custody-envelope`,24));if(!r.ok)throw Error(`VoiceID envelope ID generation failed.`);let a=L(t.signingEngine.getSignerWorkerContext());l={kind:`new`,walletId:n,walletAuthMethodId:f(crypto.randomUUID()),envelopeId:r.value,capability:e,reseal:ee.bind(null,a)}}return{kind:`activate`,ownerCredential:i.operationCredential,plan:l,http:new e(t.configs.network.relayer.url,location.origin,b),store:s}}async function ne(e,t,n){t.throwIfAborted();let{context:r,walletId:i}=e,a=await te(r,i);return t.throwIfAborted(),a.kind===`enroll_existing`?{kind:`management`,action:re.bind(null,n,a)}:{kind:`recording`,action:ie.bind(null,n,a),expiresAtMs:null}}async function re(e,t,n){let r=await c(t.walletId,t.walletAuthMethodId);return await Z(t.context,r,n,e),n.throwIfAborted(),{kind:`activated`,walletId:t.walletId,walletAuthMethodId:t.walletAuthMethodId}}async function ie(e,t,n,i,a){let o=await U({plan:t.plan,ownerCredential:t.ownerCredential,http:t.http,signal:n,onCapture:i,phrase:a,capture:r.bind(null,e),persistPending:t.store.persistPending.bind(t.store),persistActive:t.store.persistActive.bind(t.store)});return{kind:`activated`,walletId:o.authMethod.walletId,walletAuthMethodId:o.authMethod.walletAuthMethodId}}export{ne as prepareActivationSurface};
@@ -0,0 +1 @@
1
+ import{c as e,d as t,l as n,m as r,t as i,y as a}from"./prompt-vztg41jG.js";import{f as o,n as s,s as c}from"./enrollment-DPOYb36Z.js";import{ActionType as l,IndexedDBManager as u,TransactionReviewError as d,isPlainObject as f,parseTransactionReviewWire as p,resolveNearNetwork as m,walletForHostRequest as h,walletHostExecutionFingerprint as g}from"../voiceid-host.js";function _(e){if(e===void 0)return{kind:`random`};if(!f(e)||Object.keys(e).length!==1||typeof e.confirmationCommand!=`string`||e.confirmationCommand.length>256)throw v();let t=e.confirmationCommand.normalize(`NFC`).trim();if(!t||/[\u0000-\u001f\u007f]/.test(t))throw v();switch(/^[a-z]+\b/i.exec(t)?.[0].toLowerCase()){case`sell`:return{kind:`action`,action:`sale`};case`buy`:return{kind:`action`,action:`purchase`};case`swap`:return{kind:`action`,action:`swap`};case`send`:case`transfer`:return{kind:`action`,action:`transfer`};default:return{kind:`random`}}}function v(){return new d(`review_invalid_input`,`voiceId requires only a nonempty confirmationCommand of at most 256 characters without control characters.`)}function y(e,t){return e.attemptId===t.attemptId&&e.operationHash===t.operationHash&&e.expiresAtMs===t.expiresAtMs}async function b(r,i,o,c,l,u,d){let f=Math.min(i.expiresAtMs,Date.now()+o);if(c.aborted||f<=Date.now())throw Error(`VoiceID review expired or was cancelled.`);let p;try{p=await s({kind:`active`,scope:r},c,l,u,d)}catch(e){if(!(e instanceof n))throw e;if(c.aborted||f<=Date.now())throw Error(`VoiceID review expired or was cancelled.`);return{kind:`retry`,message:e.message}}if(c.aborted||f<=Date.now())throw Error(`VoiceID review expired or was cancelled.`);switch(p.kind){case`matched`:return{kind:`approved`};case`insufficient_audio`:return{kind:`retry`,message:e(p.quality)};case`mismatch`:return{kind:`retry`,message:new a(p.quality).message};case`phrase_mismatch`:return{kind:`retry`,message:new t().message};default:return x(p)}}function x(e){throw Error(`Unexpected voice result: ${String(e)}`)}function S(e){throw Error(`Unexpected voice outcome: ${String(e)}`)}function C(e){if(!(!f(e)&&!Array.isArray(e))){for(let t of Object.values(e))C(t);Object.freeze(e)}}async function w(e,t,n){switch(e.type){case`PM_SIGN_TX_WITH_ACTIONS`:case`PM_SIGN_DELEGATE_ACTION`:case`PM_SIGN_NEP413`:throw O();case`PM_SIGN_TEMPO`:{let r=e.payload;if(!r||r.operationKind!==`evm_transaction`)throw O();let{tx:i}=r.request,a=r.chainTarget;if(!t.config.network.chains.some(T)||a.kind!==`evm`||a.namespace!==`eip155`||a.networkSlug!==`arc-testnet`||a.chainId!==5042002||r.request.chain!==`evm`||r.request.kind!==`eip1559`||r.request.senderSignatureAlgorithm!==`secp256k1`||i.chainId!==a.chainId||typeof i.to!=`string`||!/^0x[0-9a-fA-F]{40}$/.test(i.to)||i.data!==void 0&&i.data!==`0x`||i.accessList!==void 0&&i.accessList.length!==0||i.abi!==void 0)throw O();return await D(e,t,_(r.options?.voiceId),n)}case`PM_SIGN_AND_SEND_TX`:{if(m(t.config.network.chains)!==`testnet`)throw new d(`review_unsupported_mode`,`This VoiceID prototype requires NEAR testnet.`);let r=e.payload;if(!r||r.transaction.actions.length!==1||r.transaction.actions[0].type!==l.Transfer||!(`transactionReview`in e))throw O();return await D(e,t,_(r.options.voiceId),n)}default:return{kind:`disabled`}}}function T(e){return e.network===`arc-testnet`&&e.chainId===5042002}function E(e,t){return typeof t==`bigint`?{bigint:t.toString()}:t}async function D(e,t,n,r){let i=p(e.transactionReview);if(i.validity.kind!==`expires_at`)throw new d(`review_invalid_input`,`VoiceID requires a review deadline.`);C(e);let a=new TextEncoder().encode(JSON.stringify({domain:`seams-voiceid-operation-v1`,origin:location.origin,executionFingerprint:g(t.config),request:e},E)),o=await crypto.subtle.digest(`SHA-256`,a),s=``;for(let e of new Uint8Array(o))s+=e.toString(16).padStart(2,`0`);let c=h(e,null);if(!c)throw Error(`VoiceID review requires a wallet identity.`);return{kind:`required`,approval:k.forReview(i,s,c,n,r)}}function O(){return new d(`review_unsupported_mode`,`VoiceID requires a reviewed NEAR or Arc testnet transfer.`)}var k=class e{phrase;prompt;surface;get messages(){return{confirm:`Confirm with VoiceID`,approved:`Voice approved this operation.`}}state={kind:`pending`};constructor(e,t,n,a,o){this.reviewExpiresAtMs=e,this.operationHash=t,this.walletId=n,this.confirmation=a,this.model=o,this.phrase=r(a,null),this.prompt=new i(document,`Approve transfer with VoiceID`,this.phrase,`segments`),this.prompt.record.hidden=!0,this.prompt.cancel.hidden=!0,this.surface=this.prompt.element}static forReview(t,n,r,i,a){if(t.validity.kind!==`expires_at`||!/^[0-9a-f]{64}$/.test(n))throw new d(`review_invalid_input`,`VoiceID requires a bounded operation.`);return new e(t.validity.atMs,n,r,i,a)}async prepare(e){if(this.state.kind!==`pending`)throw Error(`VoiceID preparation already started.`);this.state={kind:`preparing`},this.prompt.title.textContent=`VoiceID`,this.prompt.status.textContent=`Loading VoiceID…`;try{if(await o(this.prompt.progress,e,this.model),e.throwIfAborted(),this.state.kind!==`preparing`)throw Error(`VoiceID preparation was interrupted.`);if(Date.now()>=this.reviewExpiresAtMs)throw new d(`review_expired`,`This review has expired.`);this.prompt.progress.replaceChildren(),this.prompt.title.textContent=`Read aloud`,this.state={kind:`prepared`}}catch(e){throw this.state={kind:`closed`},e}}async approve(e){if(this.state.kind===`approved`){if(e.aborted||performance.now()>=this.state.deadline||Date.now()>=this.state.binding.expiresAtMs)throw Error(`Voice approval expired or closed.`);return{kind:`approved`}}if(this.state.kind!==`prepared`)throw Error(`Prepare VoiceID before voice approval.`);if(!navigator.userActivation.isActive||document.visibilityState!==`visible`||!document.hasFocus())throw Error(`Open the Wallet review and select Confirm to start voice capture.`);this.state={kind:`authorizing`};try{let t=await u.resolveSelectedWalletAuthority(this.walletId);if(t.kind!==`resolved`||t.authMethod.kind!==`voiceid`||t.selection.lockState!==`unlocked`)throw Error(`Unlock this wallet with VoiceID before voice approval.`);let n=await c(this.walletId,t.authMethod.walletAuthMethodId),i=this.beginAttempt(e);for(;;){let{binding:t,deadline:a,remaining:o}=i,s=await b(n,t,o,e,this.prompt.capture,this.phrase,this.model);if(this.assertListening(t),e.aborted||performance.now()>=a||Date.now()>=t.expiresAtMs)throw Error(`Voice approval expired or closed.`);switch(s.kind){case`approved`:return this.state={kind:`approved`,binding:t,deadline:a,signal:e},s;case`retry`:this.phrase=r(this.confirmation,this.phrase),this.prompt.setPhrase(this.phrase),this.prompt.record.textContent=`Try again`,this.prompt.ready(s.message),await this.waitForRetry(e),i=this.beginAttempt(e);break;default:return S(s)}}}catch(e){throw this.state={kind:`closed`},e}}beginAttempt(e){let t=Math.min(25e3,this.reviewExpiresAtMs-Date.now());if(t<250||e.aborted)throw Error(`This voice review has expired or closed.`);let n=Object.freeze({attemptId:crypto.randomUUID(),operationHash:this.operationHash,expiresAtMs:Date.now()+t}),r=performance.now()+t;return this.prompt.record.hidden=!0,this.prompt.status.textContent=`Opening microphone…`,this.state={kind:`listening`,binding:n,deadline:r,signal:e},{binding:n,deadline:r,remaining:t}}waitForRetry(e){return new Promise((t,n)=>{let r=this.prompt.record,i=i=>{clearTimeout(s),r.removeEventListener(`click`,a),e.removeEventListener(`abort`,o),i?t():n(Error(`This voice review has expired or closed.`))},a=i.bind(null,!0),o=i.bind(null,!1),s=setTimeout(o,Math.max(0,this.reviewExpiresAtMs-Date.now()));r.addEventListener(`click`,a),e.addEventListener(`abort`,o),e.aborted&&o(),r.focus()})}consume(){let e=this.state;if(this.state={kind:`consumed`},e.kind!==`approved`||e.signal.aborted||performance.now()>=e.deadline||Date.now()>=e.binding.expiresAtMs)throw Error(`A current voice approval is required before signing.`)}assertListening(e){if(this.state.kind!==`listening`||!y(e,this.state.binding))throw Error(`This voice attempt has closed.`)}};export{w as voiceIdPolicyForRequest};
@@ -1 +1 @@
1
- import{d as e,i as t,o as n,s as r,y as i}from"./prompt-g_wE9gYv.js";import{c as a,d as o,l as s,n as c,o as l,r as u,s as d,t as f,u as p}from"./enrollment-Cs7Tzcho.js";import{IndexedDBManager as m,availabilityKey as h,base64UrlDecode as g,base64UrlEncode as _,buildRelayerJsonPostRequestInit as v,buildWalletSessionAuthorizationHeaders as y,buildWebauthnP256SignatureWasm as b,createRelayerExactWalletSessionStatusPort as x,decodeCoseP256PublicKeyWasm as S,fetchWithWalletHomeDiscovery as C,isVoiceIdSeedEnvelope as w,joinNormalizedUrl as T,mpcMaterialActivationRefsEqual as E,normalizeRelayerBaseUrl as D,parseActiveWalletSessionV1 as O,parseEd25519YaoRecoveryCapabilityV1 as k,parseLinkedDeviceListResultV1 as ee,parsePasskeyCustodyEnvelopeRecord as te,parseStoredAuthMethodAvailability as ne,parseVoiceIdDeviceAssertion as re,parseVoiceIdWalletSessionChallenge as ie,parseWalletAuthMethodRecordV2 as ae,parseWalletSessionOperationCredentialV1 as oe,rejectUnknownFields as A,requireRecord as j,sha256DigestB64u as M,voiceIdWalletSessionChallengeBytes as N,walletSessionAuthorizations as P}from"../voiceid-host.js";async function F(e){let t;try{t=await e.json()}catch{throw Error(`VoiceID server returned an invalid response.`)}let n=j(t,`VoiceID server response`);if(!e.ok||n.ok!==!0)throw Error(`VoiceID server request failed (HTTP ${e.status}).`);return n}var I=class{walletOrigin;constructor(e,t,n){this.relayerUrl=e,this.send=n;let r=new URL(t);if(r.origin!==t||r.protocol!==`https:`&&r.protocol!==`http:`)throw Error(`VoiceID Wallet origin is invalid.`);this.walletOrigin=t}async activate(e){if(e.custodyEnvelope.walletId!==e.walletId||e.custodyEnvelope.ownership.walletAuthMethodId!==e.walletAuthMethodId||e.custodyEnvelope.factor.deviceKeyId!==e.deviceKeyId)throw Error(`VoiceID activation envelope does not match the device method.`);let t=new Request(T(this.relayerUrl,`/wallet/voiceid/activate`),{...v({body:{targetWalletAuthMethodId:e.walletAuthMethodId,devicePublicKeyB64u:e.devicePublicKeyB64u,custodyEnvelope:e.custodyEnvelope},headers:y(e.ownerCredential)}),signal:e.signal}),n=await F(await this.send(t));A(n,[`ok`,`authMethod`],`VoiceID activation response`);let r=ae(n.authMethod);if(!r||r.kind!==`voiceid`||r.status!==`active`||r.walletId!==e.walletId||r.walletAuthMethodId!==e.walletAuthMethodId||r.devicePublicKeyB64u!==e.devicePublicKeyB64u||r.deviceKeyId!==e.deviceKeyId)throw Error(`VoiceID server activated a different device method.`);return r}async challenge(e){let t=new Request(T(this.relayerUrl,`/wallet/voiceid/challenge`),{...v({body:{walletId:e.walletId,walletAuthMethodId:e.walletAuthMethodId}}),signal:e.signal}),n=await F(await this.send(t));A(n,[`ok`,`challenge`],`VoiceID challenge response`);let r=ie(n.challenge);if(r.walletId!==e.walletId||r.walletAuthMethodId!==e.walletAuthMethodId||r.requestOrigin!==this.walletOrigin||r.audience!==this.walletOrigin)throw Error(`VoiceID server challenge belongs to a different Wallet method or origin.`);return r}async verify(e){if(e.assertion.challenge.requestOrigin!==this.walletOrigin||e.assertion.challenge.audience!==this.walletOrigin)throw Error(`VoiceID assertion belongs to a different Wallet origin.`);let t=new Request(T(this.relayerUrl,`/wallet/voiceid/verify`),{...v({body:{assertion:e.assertion}}),signal:e.signal}),n=await F(await this.send(t));A(n,[`ok`,`walletSession`,`operationCredential`,`custodyEnvelope`,`near`],`VoiceID verification response`);let r=O(n.walletSession),i=oe(n.operationCredential),a=te(n.custodyEnvelope),o=e.assertion.challenge;if(!w(a)||r.walletId!==o.walletId||r.authMethodId!==o.walletAuthMethodId||r.authorityId!==o.walletAuthorityId||a.walletId!==o.walletId||a.ownership.walletAuthMethodId!==o.walletAuthMethodId||a.factor.deviceKeyId!==o.deviceKeyId)throw Error(`VoiceID server returned a different Wallet Session or custody envelope.`);let s=L(n.near);if(s.kind===`ready`&&(s.capability.applicationBinding.wallet_id!==r.walletId||!r.capabilitySubjects.some(R.bind(null,s.capability.materialActivation))))throw Error(`VoiceID NEAR capability belongs to another Wallet Session.`);return{walletSession:r,operationCredential:i,custodyEnvelope:a,near:s}}};function L(e){let t=j(e,`NEAR installation`);switch(t.kind){case`unavailable`:return A(t,[`kind`],`NEAR installation`),{kind:`unavailable`};case`ready`:if(A(t,[`kind`,`capability`,`remainingUses`],`NEAR installation`),typeof t.remainingUses!=`number`||!Number.isSafeInteger(t.remainingUses)||t.remainingUses<1)throw Error(`NEAR session budget is invalid.`);return{kind:`ready`,capability:k(t.capability),remainingUses:t.remainingUses};default:throw Error(`NEAR installation state is invalid.`)}}function R(e,t){return t.kind===`sign`&&t.keyFamily===`ed25519`&&E(e,t.materialActivation)}function z(e,t,n){if(t<24)return[t,1];let r=e.byteLength-n-1,i=new DataView(e.buffer,n+1),a,o=0;switch(t){case 24:r>0&&(a=i.getUint8(0),o=2);break;case 25:r>1&&(a=i.getUint16(0,!1),o=3);break;case 26:r>3&&(a=i.getUint32(0,!1),o=5);break;case 27:if(r>7){let e=i.getBigUint64(0,!1);if(e>=24n&&e<=2**53-1)return[Number(e),9]}break}if(a&&a>=24)return[a,o];throw Error(`Length not supported or not well formed`)}var B=class{constructor(e,t){Object.defineProperty(this,`tagId`,{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,`tagValue`,{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.tagId=e,this.tagValue=t}get tag(){return this.tagId}get value(){return this.tagValue}};function V(e,t,n){return z(e,t,n)}function H(e,t,n){let[r,i]=V(e,t,n);return[-r-1,i]}function U(e,t,n){let[r,i]=z(e,t,n),a=n+i;return[new Uint8Array(e.buffer.slice(a,a+r)),i+r]}const W=new TextDecoder;function G(e,t,n){let[r,i]=U(e,t,n);return[W.decode(r),i]}function se(e,t,n){if(t===0)return[[],1];let[r,i]=z(e,t,n),a=i,o=[];for(let t=0;t<r;t++){if(e.byteLength-n-a<=0)throw Error(`array is not supported or well formed`);let[t,r]=q(e,n+a);o.push(t),a+=r}return[o,a]}const K=`Map is not supported or well formed`;function ce(e,t,n){if(t===0)return[new Map,1];let[r,i]=z(e,t,n),a=i,o=new Map;for(let t=0;t<r;t++){let t=e.byteLength-n-a;if(t<=0)throw Error(K);let[r,i]=q(e,n+a);if(a+=i,t-=i,t<=0||typeof r!=`string`&&typeof r!=`number`||o.has(r))throw Error(K);let[s,c]=q(e,n+a);a+=c,o.set(r,s)}return[o,a]}function le(e,t){if(t+3>e.byteLength)throw Error(`CBOR stream ended before end of Float 16`);let n=e.getUint16(t+1,!1);if(n==31744)return[1/0,3];if(n==32256)return[NaN,3];if(n==64512)return[-1/0,3];throw Error(`Float16 data is unsupported`)}function ue(e,t){if(t+5>e.byteLength)throw Error(`CBOR stream ended before end of Float 32`);return[e.getFloat32(t+1,!1),5]}function de(e,t){if(t+9>e.byteLength)throw Error(`CBOR stream ended before end of Float 64`);return[e.getFloat64(t+1,!1),9]}function fe(e,t,n){let[r,i]=z(e,t,n),[a,o]=q(e,n+i);return[new B(r,a),i+o]}function q(e,t){if(t>=e.byteLength)throw Error(`CBOR stream ended before tag value`);let n=e.getUint8(t),r=n>>5,i=n&31;switch(r){case 0:return V(e,i,t);case 1:return H(e,i,t);case 2:return U(e,i,t);case 3:return G(e,i,t);case 4:return se(e,i,t);case 5:return ce(e,i,t);case 6:return fe(e,i,t);case 7:switch(i){case 20:return[!1,1];case 21:return[!0,1];case 22:return[null,1];case 23:return[void 0,1];case 25:return le(e,t);case 26:return ue(e,t);case 27:return de(e,t)}}throw Error(`Unsupported or not well formed at ${t}`)}new TextEncoder;function pe(e,t){if(e.byteLength===0||e.byteLength<=t||t<0)throw Error(`No data`);return e instanceof Uint8Array?q(new DataView(e.buffer),t):e instanceof ArrayBuffer?q(new DataView(e),t):q(e,t)}function me(e){let[t,n]=pe(e,0);if(n!==e.byteLength)throw Error(`Data was decoded, but the whole stream was not processed ${n} != ${e.byteLength}`);return t}async function J(e,t){let n=await m.resolveSelectedWalletAuthority(e.walletId);if(n.kind!==`resolved`||n.selection.lockState!==`unlocked`||t===`activating`&&n.authMethod.kind===`voiceid`||n.authMethod.status!==`active`||n.authority.authorityId!==e.authorityId)throw Error(`Unlock this wallet with an owner method before managing VoiceID.`);let r=await P.readExactWithOperationCredential({walletId:e.walletId,authorityId:e.authorityId,authMethodId:n.authMethod.walletAuthMethodId});if(r.kind!==`found`||r.record.expiresAtMs<=Date.now())throw Error(`Unlock this wallet again before managing VoiceID.`);let i=ne(await m.getAppState(h(e.walletId,e.walletAuthMethodId))),a;if(t===`activating`)a={target:t,sessionMethodId:n.authMethod.walletAuthMethodId,walletSessionId:r.operationCredential.walletSessionId,lockGeneration:n.selection.lockGeneration,expiresAtMs:Math.min(r.record.expiresAtMs,Date.now()+5*6e4),availabilityRevision:i.revision};else{let o=(await m.listWalletAuthMethodsV2ForWallet(e.walletId)).find(Y.bind(null,e));if(!o)throw Error(`Add a passkey to this authority before changing your voice enrollment.`);a={target:t,sessionMethodId:n.authMethod.walletAuthMethodId,confirmationMethodId:o.walletAuthMethodId,walletSessionId:r.operationCredential.walletSessionId,lockGeneration:n.selection.lockGeneration,expiresAtMs:Math.min(r.record.expiresAtMs,Date.now()+5*6e4),availabilityRevision:i.revision}}return await u(e,a),a}function Y(e,t){return t.kind===`passkey`&&t.status===`active`&&t.walletId===e.walletId&&t.walletAuthorityId===e.authorityId}function he(e,t,n,r){return r.walletId===e.walletId&&r.walletAuthorityId===e.authorityId&&r.credential.kind===`passkey`&&r.credential.walletAuthMethodId===t.confirmationMethodId&&r.credential.credentialIdB64u===n}function X(e,t,n,r){return JSON.stringify([`seams-voiceid-enrollment-change-v1`,location.origin,e.walletId,e.authorityId,e.walletAuthMethodId,e.deviceKeyId,t.sessionMethodId,t.confirmationMethodId,t.walletSessionId,t.lockGeneration,t.availabilityRevision,t.expiresAtMs,r,n.kind===`present`?n.enrollment.generation:null,n.kind===`present`?n.enrollment.revision:null])}var ge=class e{consumed=!1;constructor(e,t,n){this.binding=e,this.expiresAtMs=t,this.assertCurrentOwner=n}static async request(t,n,r,i,a,o){await u(n,r);let s=_e.bind(null,t.configs.network.relayer.url,n,r);await s(o);let c=await m.getWalletAuthMethodV2(r.confirmationMethodId);if(!c||c.kind!==`passkey`||c.status!==`active`||c.walletId!==n.walletId||c.walletAuthorityId!==n.authorityId||c.rpId!==t.signingEngine.getRpId())throw Error(`The confirming passkey is unavailable for this wallet.`);let l=X(n,r,i,a),d=await M(new TextEncoder().encode(JSON.stringify({binding:l,nonce:crypto.randomUUID(),expiresAtMs:r.expiresAtMs})));o.throwIfAborted();let f=await navigator.credentials.get({publicKey:{challenge:g(d),rpId:c.rpId,allowCredentials:[{type:`public-key`,id:g(c.credentialIdB64u)}],userVerification:`required`,timeout:Math.min(6e4,r.expiresAtMs-Date.now())},signal:o});if(!(f instanceof PublicKeyCredential)||!(f.response instanceof AuthenticatorAssertionResponse)||_(new Uint8Array(f.rawId))!==c.credentialIdB64u)throw Error(`The passkey did not confirm this wallet.`);let p=f.response,h=new Uint8Array(p.clientDataJSON),v=j(JSON.parse(new TextDecoder().decode(h)),`Passkey client data`);if(v.type!==`webauthn.get`||v.challenge!==d||v.origin!==location.origin)throw Error(`The passkey confirmation belongs to another operation.`);let y=new Uint8Array(p.authenticatorData),b=new Uint8Array(await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(c.rpId)));if(y.length<37||(y[32]&5)!=5||_(y.slice(0,32))!==_(b))throw Error(`Passkey user verification is required for this Wallet origin.`);if(!await Q({cosePublicKey:g(c.credentialPublicKeyB64u),challenge:g(d),authenticatorData:y,clientBytes:h,signature:new Uint8Array(p.signature),workerCtx:t.signingEngine.getSignerWorkerContext()}))throw Error(`Passkey confirmation signature is invalid.`);return o.throwIfAborted(),await u(n,r),new e(l,r.expiresAtMs,s)}async consume(e,t,n,r,i){if(this.consumed||this.expiresAtMs<=Date.now()||this.binding!==X(e,t,n,r))throw Error(`Passkey confirmation expired or was already used. Start again.`);if(this.consumed=!0,await this.assertCurrentOwner(i),i.throwIfAborted(),this.expiresAtMs<=Date.now())throw Error(`Passkey confirmation expired. Start again.`)}};async function _e(e,t,n,r){let i=await P.readExactWithOperationCredential({walletId:t.walletId,authorityId:t.authorityId,authMethodId:n.sessionMethodId});if(i.kind!==`found`||i.operationCredential.walletSessionId!==n.walletSessionId)throw Error(`The owner session changed. Unlock this wallet and try again.`);r.throwIfAborted();let a=await x({relayerUrl:e,operationCredential:i.operationCredential,fetchImpl:Z.bind(null,r)}).read({walletSessionId:n.walletSessionId,quotaId:i.record.quotaId});if(a.status!==`active`&&a.status!==`exhausted`||a.authorization.walletId!==t.walletId||a.authorization.authorityId!==t.authorityId||a.authorization.authMethodId!==n.sessionMethodId)throw Error(`The owner session is unavailable. Unlock this wallet and try again.`);let o=await m.getWalletAuthMethodV2(n.confirmationMethodId);if(!o||o.kind!==`passkey`||!Y(t,o))throw Error(`The confirming passkey is unavailable.`);let s=new URLSearchParams({walletId:t.walletId,limit:`50`,cursor:``}),c=await Z(r,`${D(e)}/wallet/device-linking/v1/devices?${s}`,{headers:y(i.operationCredential)});if(!c.ok)throw Error(`Could not verify the confirming passkey with the wallet service.`);let{ok:l,...u}=j(await c.json(),`Wallet method inventory`);if(l!==!0)throw Error(`Could not verify the confirming passkey with the wallet service.`);if(!ee(u).ownerDevices.some(he.bind(null,t,n,o.credentialIdB64u)))throw Error(`The confirming passkey was removed or belongs to another authority.`);r.throwIfAborted()}function Z(e,t,n){return C(new Request(t,{...n,signal:AbortSignal.any([e,AbortSignal.timeout(15e3)])}))}async function Q(e){let t=me(e.cosePublicKey);if(!(t instanceof Map))throw Error(`Passkey public key is invalid.`);let n=new Uint8Array(await crypto.subtle.digest(`SHA-256`,new Uint8Array(e.clientBytes))),r=new Uint8Array(e.authenticatorData.length+n.length);if(r.set(e.authenticatorData),r.set(n,e.authenticatorData.length),t.get(1)===3&&t.get(3)===-257){let n=t.get(-1),i=t.get(-2);if(!(n instanceof Uint8Array)||!(i instanceof Uint8Array))throw Error(`RSA passkey public key is invalid.`);let a=await crypto.subtle.importKey(`jwk`,{kty:`RSA`,n:_(n),e:_(i)},{name:`RSASSA-PKCS1-v1_5`,hash:`SHA-256`},!1,[`verify`]);return crypto.subtle.verify(`RSASSA-PKCS1-v1_5`,a,new Uint8Array(e.signature),r)}if(t.get(1)!==2||t.get(3)!==-7)throw Error(`This passkey type cannot confirm VoiceID changes.`);let i=await S({cosePublicKey:e.cosePublicKey,workerCtx:e.workerCtx}),a=(await b({challenge32:e.challenge,authenticatorData:e.authenticatorData,clientDataJSON:e.clientBytes,signatureDer:e.signature,pubKeyX32:i.pubKeyX32,pubKeyY32:i.pubKeyY32,workerCtx:e.workerCtx})).slice(-128,-64),o=await crypto.subtle.importKey(`jwk`,{kty:`EC`,crv:`P-256`,x:_(i.pubKeyX32),y:_(i.pubKeyY32)},{name:`ECDSA`,namedCurve:`P-256`},!1,[`verify`]);return crypto.subtle.verify({name:`ECDSA`,hash:`SHA-256`},o,a,r)}async function ve(e){r();let t=await s(e.walletId,e.walletAuthMethodId),n=await m.resolveSelectedWalletAuthority(e.walletId);if(n.kind!==`resolved`)throw Error(`Select the owner wallet before enrolling VoiceID.`);let i=a(t,n.authority.authorityId);await l(i)?await $({kind:`activation`,scope:i,owner:await J(i,`activating`)},e.signal,e.onCapture,e.phrase):await f({kind:`activate`,scope:i,guard:await J(i,`activating`),snapshot:{kind:`missing`}},e.signal),e.signal.throwIfAborted();let o=await p(t);if(e.signal.aborted)throw o.fill(0),Error(`VoiceID activation was cancelled.`);return{kind:`activated`,publicKeyB64u:t.publicKeyB64u,deviceKeyId:t.deviceKeyId,factorSecret32:o}}async function ye(e){n();let{challenge:t}=e;if(t.requestOrigin!==location.origin||t.expiresAtMs<=Date.now())throw Error(`VoiceID challenge is expired or belongs to another Wallet origin.`);let r=await o(t.walletId,t.walletAuthMethodId);if(!r||r.deviceKeyId!==t.deviceKeyId)throw Error(`VoiceID device key is unavailable in this browser.`);if(await $({kind:`active`,scope:await d(t.walletId,t.walletAuthMethodId)},e.signal,e.onCapture,e.phrase),e.signal.throwIfAborted(),t.expiresAtMs<=Date.now())throw Error(`VoiceID challenge expired. Start unlock again.`);let i=await crypto.subtle.sign(`Ed25519`,r.privateKey,N(t)),a=await p(r);if(e.signal.aborted||t.expiresAtMs<=Date.now())throw a.fill(0),Error(`VoiceID unlock expired or was cancelled.`);return{kind:`unlocked`,assertion:re({kind:`voiceid_device_assertion_v1`,challenge:t,signatureB64u:_(new Uint8Array(i))}),factorSecret32:a}}async function $(n,r,a,o){let s=await c(n,r,a,o);switch(s.kind){case`matched`:return;case`insufficient_audio`:throw new t(s.quality);case`mismatch`:throw new i(s.quality);case`phrase_mismatch`:throw new e;default:return be(s)}}function be(e){throw Error(`Unexpected voice result: ${String(e)}`)}export{I as a,J as i,ye as n,ge as r,ve as t};
1
+ import{d as e,i as t,o as n,s as r,y as i}from"./prompt-vztg41jG.js";import{c as a,d as o,l as s,n as c,o as l,r as u,s as d,t as f,u as p}from"./enrollment-DPOYb36Z.js";import{IndexedDBManager as m,availabilityKey as h,base64UrlDecode as g,base64UrlEncode as _,buildRelayerJsonPostRequestInit as v,buildWalletSessionAuthorizationHeaders as y,buildWebauthnP256SignatureWasm as b,createRelayerExactWalletSessionStatusPort as x,decodeCoseP256PublicKeyWasm as S,fetchWithWalletHomeDiscovery as C,isVoiceIdSeedEnvelope as w,joinNormalizedUrl as T,mpcMaterialActivationRefsEqual as E,normalizeRelayerBaseUrl as D,parseActiveWalletSessionV1 as O,parseEd25519YaoRecoveryCapabilityV1 as k,parseLinkedDeviceListResultV1 as ee,parsePasskeyCustodyEnvelopeRecord as te,parseStoredAuthMethodAvailability as ne,parseVoiceIdDeviceAssertion as re,parseVoiceIdWalletSessionChallenge as ie,parseWalletAuthMethodRecordV2 as ae,parseWalletSessionOperationCredentialV1 as oe,rejectUnknownFields as A,requireRecord as j,sha256DigestB64u as M,voiceIdWalletSessionChallengeBytes as N,walletSessionAuthorizations as P}from"../voiceid-host.js";async function F(e){let t;try{t=await e.json()}catch{throw Error(`VoiceID server returned an invalid response.`)}let n=j(t,`VoiceID server response`);if(!e.ok||n.ok!==!0)throw Error(`VoiceID server request failed (HTTP ${e.status}).`);return n}var I=class{walletOrigin;constructor(e,t,n){this.relayerUrl=e,this.send=n;let r=new URL(t);if(r.origin!==t||r.protocol!==`https:`&&r.protocol!==`http:`)throw Error(`VoiceID Wallet origin is invalid.`);this.walletOrigin=t}async activate(e){if(e.custodyEnvelope.walletId!==e.walletId||e.custodyEnvelope.ownership.walletAuthMethodId!==e.walletAuthMethodId||e.custodyEnvelope.factor.deviceKeyId!==e.deviceKeyId)throw Error(`VoiceID activation envelope does not match the device method.`);let t=new Request(T(this.relayerUrl,`/wallet/voiceid/activate`),{...v({body:{targetWalletAuthMethodId:e.walletAuthMethodId,devicePublicKeyB64u:e.devicePublicKeyB64u,custodyEnvelope:e.custodyEnvelope},headers:y(e.ownerCredential)}),signal:e.signal}),n=await F(await this.send(t));A(n,[`ok`,`authMethod`],`VoiceID activation response`);let r=ae(n.authMethod);if(!r||r.kind!==`voiceid`||r.status!==`active`||r.walletId!==e.walletId||r.walletAuthMethodId!==e.walletAuthMethodId||r.devicePublicKeyB64u!==e.devicePublicKeyB64u||r.deviceKeyId!==e.deviceKeyId)throw Error(`VoiceID server activated a different device method.`);return r}async challenge(e){let t=new Request(T(this.relayerUrl,`/wallet/voiceid/challenge`),{...v({body:{walletId:e.walletId,walletAuthMethodId:e.walletAuthMethodId}}),signal:e.signal}),n=await F(await this.send(t));A(n,[`ok`,`challenge`],`VoiceID challenge response`);let r=ie(n.challenge);if(r.walletId!==e.walletId||r.walletAuthMethodId!==e.walletAuthMethodId||r.requestOrigin!==this.walletOrigin||r.audience!==this.walletOrigin)throw Error(`VoiceID server challenge belongs to a different Wallet method or origin.`);return r}async verify(e){if(e.assertion.challenge.requestOrigin!==this.walletOrigin||e.assertion.challenge.audience!==this.walletOrigin)throw Error(`VoiceID assertion belongs to a different Wallet origin.`);let t=new Request(T(this.relayerUrl,`/wallet/voiceid/verify`),{...v({body:{assertion:e.assertion}}),signal:e.signal}),n=await F(await this.send(t));A(n,[`ok`,`walletSession`,`operationCredential`,`custodyEnvelope`,`near`],`VoiceID verification response`);let r=O(n.walletSession),i=oe(n.operationCredential),a=te(n.custodyEnvelope),o=e.assertion.challenge;if(!w(a)||r.walletId!==o.walletId||r.authMethodId!==o.walletAuthMethodId||r.authorityId!==o.walletAuthorityId||a.walletId!==o.walletId||a.ownership.walletAuthMethodId!==o.walletAuthMethodId||a.factor.deviceKeyId!==o.deviceKeyId)throw Error(`VoiceID server returned a different Wallet Session or custody envelope.`);let s=L(n.near);if(s.kind===`ready`&&(s.capability.applicationBinding.wallet_id!==r.walletId||!r.capabilitySubjects.some(R.bind(null,s.capability.materialActivation))))throw Error(`VoiceID NEAR capability belongs to another Wallet Session.`);return{walletSession:r,operationCredential:i,custodyEnvelope:a,near:s}}};function L(e){let t=j(e,`NEAR installation`);switch(t.kind){case`unavailable`:return A(t,[`kind`],`NEAR installation`),{kind:`unavailable`};case`ready`:if(A(t,[`kind`,`capability`,`remainingUses`],`NEAR installation`),typeof t.remainingUses!=`number`||!Number.isSafeInteger(t.remainingUses)||t.remainingUses<1)throw Error(`NEAR session budget is invalid.`);return{kind:`ready`,capability:k(t.capability),remainingUses:t.remainingUses};default:throw Error(`NEAR installation state is invalid.`)}}function R(e,t){return t.kind===`sign`&&t.keyFamily===`ed25519`&&E(e,t.materialActivation)}function z(e,t,n){if(t<24)return[t,1];let r=e.byteLength-n-1,i=new DataView(e.buffer,n+1),a,o=0;switch(t){case 24:r>0&&(a=i.getUint8(0),o=2);break;case 25:r>1&&(a=i.getUint16(0,!1),o=3);break;case 26:r>3&&(a=i.getUint32(0,!1),o=5);break;case 27:if(r>7){let e=i.getBigUint64(0,!1);if(e>=24n&&e<=2**53-1)return[Number(e),9]}break}if(a&&a>=24)return[a,o];throw Error(`Length not supported or not well formed`)}var B=class{constructor(e,t){Object.defineProperty(this,`tagId`,{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,`tagValue`,{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.tagId=e,this.tagValue=t}get tag(){return this.tagId}get value(){return this.tagValue}};function V(e,t,n){return z(e,t,n)}function H(e,t,n){let[r,i]=V(e,t,n);return[-r-1,i]}function U(e,t,n){let[r,i]=z(e,t,n),a=n+i;return[new Uint8Array(e.buffer.slice(a,a+r)),i+r]}const W=new TextDecoder;function G(e,t,n){let[r,i]=U(e,t,n);return[W.decode(r),i]}function se(e,t,n){if(t===0)return[[],1];let[r,i]=z(e,t,n),a=i,o=[];for(let t=0;t<r;t++){if(e.byteLength-n-a<=0)throw Error(`array is not supported or well formed`);let[t,r]=q(e,n+a);o.push(t),a+=r}return[o,a]}const K=`Map is not supported or well formed`;function ce(e,t,n){if(t===0)return[new Map,1];let[r,i]=z(e,t,n),a=i,o=new Map;for(let t=0;t<r;t++){let t=e.byteLength-n-a;if(t<=0)throw Error(K);let[r,i]=q(e,n+a);if(a+=i,t-=i,t<=0||typeof r!=`string`&&typeof r!=`number`||o.has(r))throw Error(K);let[s,c]=q(e,n+a);a+=c,o.set(r,s)}return[o,a]}function le(e,t){if(t+3>e.byteLength)throw Error(`CBOR stream ended before end of Float 16`);let n=e.getUint16(t+1,!1);if(n==31744)return[1/0,3];if(n==32256)return[NaN,3];if(n==64512)return[-1/0,3];throw Error(`Float16 data is unsupported`)}function ue(e,t){if(t+5>e.byteLength)throw Error(`CBOR stream ended before end of Float 32`);return[e.getFloat32(t+1,!1),5]}function de(e,t){if(t+9>e.byteLength)throw Error(`CBOR stream ended before end of Float 64`);return[e.getFloat64(t+1,!1),9]}function fe(e,t,n){let[r,i]=z(e,t,n),[a,o]=q(e,n+i);return[new B(r,a),i+o]}function q(e,t){if(t>=e.byteLength)throw Error(`CBOR stream ended before tag value`);let n=e.getUint8(t),r=n>>5,i=n&31;switch(r){case 0:return V(e,i,t);case 1:return H(e,i,t);case 2:return U(e,i,t);case 3:return G(e,i,t);case 4:return se(e,i,t);case 5:return ce(e,i,t);case 6:return fe(e,i,t);case 7:switch(i){case 20:return[!1,1];case 21:return[!0,1];case 22:return[null,1];case 23:return[void 0,1];case 25:return le(e,t);case 26:return ue(e,t);case 27:return de(e,t)}}throw Error(`Unsupported or not well formed at ${t}`)}new TextEncoder;function pe(e,t){if(e.byteLength===0||e.byteLength<=t||t<0)throw Error(`No data`);return e instanceof Uint8Array?q(new DataView(e.buffer),t):e instanceof ArrayBuffer?q(new DataView(e),t):q(e,t)}function me(e){let[t,n]=pe(e,0);if(n!==e.byteLength)throw Error(`Data was decoded, but the whole stream was not processed ${n} != ${e.byteLength}`);return t}async function J(e,t){let n=await m.resolveSelectedWalletAuthority(e.walletId);if(n.kind!==`resolved`||n.selection.lockState!==`unlocked`||t===`activating`&&n.authMethod.kind===`voiceid`||n.authMethod.status!==`active`||n.authority.authorityId!==e.authorityId)throw Error(`Unlock this wallet with an owner method before managing VoiceID.`);let r=await P.readExactWithOperationCredential({walletId:e.walletId,authorityId:e.authorityId,authMethodId:n.authMethod.walletAuthMethodId});if(r.kind!==`found`||r.record.expiresAtMs<=Date.now())throw Error(`Unlock this wallet again before managing VoiceID.`);let i=ne(await m.getAppState(h(e.walletId,e.walletAuthMethodId))),a;if(t===`activating`)a={target:t,sessionMethodId:n.authMethod.walletAuthMethodId,walletSessionId:r.operationCredential.walletSessionId,lockGeneration:n.selection.lockGeneration,expiresAtMs:Math.min(r.record.expiresAtMs,Date.now()+5*6e4),availabilityRevision:i.revision};else{let o=(await m.listWalletAuthMethodsV2ForWallet(e.walletId)).find(Y.bind(null,e));if(!o)throw Error(`Add a passkey to this authority before changing your voice enrollment.`);a={target:t,sessionMethodId:n.authMethod.walletAuthMethodId,confirmationMethodId:o.walletAuthMethodId,walletSessionId:r.operationCredential.walletSessionId,lockGeneration:n.selection.lockGeneration,expiresAtMs:Math.min(r.record.expiresAtMs,Date.now()+5*6e4),availabilityRevision:i.revision}}return await u(e,a),a}function Y(e,t){return t.kind===`passkey`&&t.status===`active`&&t.walletId===e.walletId&&t.walletAuthorityId===e.authorityId}function he(e,t,n,r){return r.walletId===e.walletId&&r.walletAuthorityId===e.authorityId&&r.credential.kind===`passkey`&&r.credential.walletAuthMethodId===t.confirmationMethodId&&r.credential.credentialIdB64u===n}function X(e,t,n,r){return JSON.stringify([`seams-voiceid-enrollment-change-v1`,location.origin,e.walletId,e.authorityId,e.walletAuthMethodId,e.deviceKeyId,t.sessionMethodId,t.confirmationMethodId,t.walletSessionId,t.lockGeneration,t.availabilityRevision,t.expiresAtMs,r,n.kind===`present`?n.enrollment.generation:null,n.kind===`present`?n.enrollment.revision:null])}var ge=class e{consumed=!1;constructor(e,t,n){this.binding=e,this.expiresAtMs=t,this.assertCurrentOwner=n}static async request(t,n,r,i,a,o){await u(n,r);let s=_e.bind(null,t.configs.network.relayer.url,n,r);await s(o);let c=await m.getWalletAuthMethodV2(r.confirmationMethodId);if(!c||c.kind!==`passkey`||c.status!==`active`||c.walletId!==n.walletId||c.walletAuthorityId!==n.authorityId||c.rpId!==t.signingEngine.getRpId())throw Error(`The confirming passkey is unavailable for this wallet.`);let l=X(n,r,i,a),d=await M(new TextEncoder().encode(JSON.stringify({binding:l,nonce:crypto.randomUUID(),expiresAtMs:r.expiresAtMs})));o.throwIfAborted();let f=await navigator.credentials.get({publicKey:{challenge:g(d),rpId:c.rpId,allowCredentials:[{type:`public-key`,id:g(c.credentialIdB64u)}],userVerification:`required`,timeout:Math.min(6e4,r.expiresAtMs-Date.now())},signal:o});if(!(f instanceof PublicKeyCredential)||!(f.response instanceof AuthenticatorAssertionResponse)||_(new Uint8Array(f.rawId))!==c.credentialIdB64u)throw Error(`The passkey did not confirm this wallet.`);let p=f.response,h=new Uint8Array(p.clientDataJSON),v=j(JSON.parse(new TextDecoder().decode(h)),`Passkey client data`);if(v.type!==`webauthn.get`||v.challenge!==d||v.origin!==location.origin)throw Error(`The passkey confirmation belongs to another operation.`);let y=new Uint8Array(p.authenticatorData),b=new Uint8Array(await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(c.rpId)));if(y.length<37||(y[32]&5)!=5||_(y.slice(0,32))!==_(b))throw Error(`Passkey user verification is required for this Wallet origin.`);if(!await Q({cosePublicKey:g(c.credentialPublicKeyB64u),challenge:g(d),authenticatorData:y,clientBytes:h,signature:new Uint8Array(p.signature),workerCtx:t.signingEngine.getSignerWorkerContext()}))throw Error(`Passkey confirmation signature is invalid.`);return o.throwIfAborted(),await u(n,r),new e(l,r.expiresAtMs,s)}async consume(e,t,n,r,i){if(this.consumed||this.expiresAtMs<=Date.now()||this.binding!==X(e,t,n,r))throw Error(`Passkey confirmation expired or was already used. Start again.`);if(this.consumed=!0,await this.assertCurrentOwner(i),i.throwIfAborted(),this.expiresAtMs<=Date.now())throw Error(`Passkey confirmation expired. Start again.`)}};async function _e(e,t,n,r){let i=await P.readExactWithOperationCredential({walletId:t.walletId,authorityId:t.authorityId,authMethodId:n.sessionMethodId});if(i.kind!==`found`||i.operationCredential.walletSessionId!==n.walletSessionId)throw Error(`The owner session changed. Unlock this wallet and try again.`);r.throwIfAborted();let a=await x({relayerUrl:e,operationCredential:i.operationCredential,fetchImpl:Z.bind(null,r)}).read({walletSessionId:n.walletSessionId,quotaId:i.record.quotaId});if(a.status!==`active`&&a.status!==`exhausted`||a.authorization.walletId!==t.walletId||a.authorization.authorityId!==t.authorityId||a.authorization.authMethodId!==n.sessionMethodId)throw Error(`The owner session is unavailable. Unlock this wallet and try again.`);let o=await m.getWalletAuthMethodV2(n.confirmationMethodId);if(!o||o.kind!==`passkey`||!Y(t,o))throw Error(`The confirming passkey is unavailable.`);let s=new URLSearchParams({walletId:t.walletId,limit:`50`,cursor:``}),c=await Z(r,`${D(e)}/wallet/device-linking/v1/devices?${s}`,{headers:y(i.operationCredential)});if(!c.ok)throw Error(`Could not verify the confirming passkey with the wallet service.`);let{ok:l,...u}=j(await c.json(),`Wallet method inventory`);if(l!==!0)throw Error(`Could not verify the confirming passkey with the wallet service.`);if(!ee(u).ownerDevices.some(he.bind(null,t,n,o.credentialIdB64u)))throw Error(`The confirming passkey was removed or belongs to another authority.`);r.throwIfAborted()}function Z(e,t,n){return C(new Request(t,{...n,signal:AbortSignal.any([e,AbortSignal.timeout(15e3)])}))}async function Q(e){let t=me(e.cosePublicKey);if(!(t instanceof Map))throw Error(`Passkey public key is invalid.`);let n=new Uint8Array(await crypto.subtle.digest(`SHA-256`,new Uint8Array(e.clientBytes))),r=new Uint8Array(e.authenticatorData.length+n.length);if(r.set(e.authenticatorData),r.set(n,e.authenticatorData.length),t.get(1)===3&&t.get(3)===-257){let n=t.get(-1),i=t.get(-2);if(!(n instanceof Uint8Array)||!(i instanceof Uint8Array))throw Error(`RSA passkey public key is invalid.`);let a=await crypto.subtle.importKey(`jwk`,{kty:`RSA`,n:_(n),e:_(i)},{name:`RSASSA-PKCS1-v1_5`,hash:`SHA-256`},!1,[`verify`]);return crypto.subtle.verify(`RSASSA-PKCS1-v1_5`,a,new Uint8Array(e.signature),r)}if(t.get(1)!==2||t.get(3)!==-7)throw Error(`This passkey type cannot confirm VoiceID changes.`);let i=await S({cosePublicKey:e.cosePublicKey,workerCtx:e.workerCtx}),a=(await b({challenge32:e.challenge,authenticatorData:e.authenticatorData,clientDataJSON:e.clientBytes,signatureDer:e.signature,pubKeyX32:i.pubKeyX32,pubKeyY32:i.pubKeyY32,workerCtx:e.workerCtx})).slice(-128,-64),o=await crypto.subtle.importKey(`jwk`,{kty:`EC`,crv:`P-256`,x:_(i.pubKeyX32),y:_(i.pubKeyY32)},{name:`ECDSA`,namedCurve:`P-256`},!1,[`verify`]);return crypto.subtle.verify({name:`ECDSA`,hash:`SHA-256`},o,a,r)}async function ve(e,t){r();let n=await s(t.walletId,t.walletAuthMethodId),i=await m.resolveSelectedWalletAuthority(t.walletId);if(i.kind!==`resolved`)throw Error(`Select the owner wallet before enrolling VoiceID.`);let o=a(n,i.authority.authorityId);await l(o)?await $({kind:`activation`,scope:o,owner:await J(o,`activating`)},t.signal,t.onCapture,t.phrase,e):await f({kind:`activate`,scope:o,guard:await J(o,`activating`),snapshot:{kind:`missing`}},t.signal,e),t.signal.throwIfAborted();let c=await p(n);if(t.signal.aborted)throw c.fill(0),Error(`VoiceID activation was cancelled.`);return{kind:`activated`,publicKeyB64u:n.publicKeyB64u,deviceKeyId:n.deviceKeyId,factorSecret32:c}}async function ye(e,t){n();let{challenge:r}=t;if(r.requestOrigin!==location.origin||r.expiresAtMs<=Date.now())throw Error(`VoiceID challenge is expired or belongs to another Wallet origin.`);let i=await o(r.walletId,r.walletAuthMethodId);if(!i||i.deviceKeyId!==r.deviceKeyId)throw Error(`VoiceID device key is unavailable in this browser.`);if(await $({kind:`active`,scope:await d(r.walletId,r.walletAuthMethodId)},t.signal,t.onCapture,t.phrase,e),t.signal.throwIfAborted(),r.expiresAtMs<=Date.now())throw Error(`VoiceID challenge expired. Start unlock again.`);let a=await crypto.subtle.sign(`Ed25519`,i.privateKey,N(r)),s=await p(i);if(t.signal.aborted||r.expiresAtMs<=Date.now())throw s.fill(0),Error(`VoiceID unlock expired or was cancelled.`);return{kind:`unlocked`,assertion:re({kind:`voiceid_device_assertion_v1`,challenge:r,signatureB64u:_(new Uint8Array(a))}),factorSecret32:s}}async function $(n,r,a,o,s){let l=await c(n,r,a,o,s);switch(l.kind){case`matched`:return;case`insufficient_audio`:throw new t(l.quality);case`mismatch`:throw new i(l.quality);case`phrase_mismatch`:throw new e;default:return be(l)}}function be(e){throw Error(`Unexpected voice result: ${String(e)}`)}export{I as a,J as i,ye as n,ge as r,ve as t};