@qntx/wallet 0.2.0 → 0.4.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.
@@ -0,0 +1,668 @@
1
+ import { a as DerivedNostrKey, b as WalletErrorCode, d as NostrKeyInfo, l as LockReason, m as StatusPayload, s as FactorInfo, x as WalletInfo } from "./types-D4OUjGVS.mjs";
2
+ //#region src/protocol/validate.d.ts
3
+ declare class ValidationError extends Error {
4
+ name: string;
5
+ }
6
+ type Validator<T> = (value: unknown) => T;
7
+ declare function literal<T extends NullValue | boolean | number | string>(expected: T): Validator<T>;
8
+ declare const nullValue: Validator<NullValue>;
9
+ declare const bool: Validator<boolean>;
10
+ declare function int(min: number, max: number): Validator<number>;
11
+ declare function str(max: number, pattern?: RegExp): Validator<string>;
12
+ declare function bytes(min: number, max?: number): Validator<Uint8Array>;
13
+ declare function arr<T>(item: Validator<T>, max: number, min?: number): Validator<ReadonlyArray<T>>;
14
+ declare class Opt<T> {
15
+ readonly validator: Validator<T>;
16
+ constructor(validator: Validator<T>);
17
+ }
18
+ declare function opt<T>(validator: Validator<T>): Opt<T>;
19
+ type Field = Validator<unknown> | Opt<unknown>;
20
+ type Shape = Record<string, Field>;
21
+ type RequiredKeys<S extends Shape> = { readonly [K in keyof S as S[K] extends Opt<unknown> ? never : K]: S[K] extends Validator<infer T> ? T : never; };
22
+ type OptionalKeys<S extends Shape> = { readonly [K in keyof S as S[K] extends Opt<unknown> ? K : never]?: S[K] extends Opt<infer T> ? T : never; };
23
+ type ShapeResult<S extends Shape> = RequiredKeys<S> & OptionalKeys<S>;
24
+ /** Exact key set: required keys present, optional keys allowed, nothing else. */
25
+ declare function obj<S extends Shape>(shape: S): Validator<ShapeResult<S>>;
26
+ /**
27
+ * A `Record<K, V>` wire value: plain objects only, every key checked by `key`, every value by
28
+ * `value`, at most `max` entries. Prototype-polluting keys are rejected outright — a validated
29
+ * record must be safe to copy key-by-key.
30
+ */
31
+ declare function record<K extends string, V>(key: Validator<K>, value: Validator<V>, max: number): Validator<Record<K, V>>;
32
+ /** Tries each branch in order; the first match wins. */
33
+ declare function union<Vs extends ReadonlyArray<Validator<unknown>>>(...branches: Vs): Validator<ReturnType<Vs[number]>>;
34
+ /** Validates a value and returns it, or undefined on a shape mismatch. */
35
+ declare function validate<T>(validator: Validator<T>, value: unknown): T | undefined;
36
+ //#endregion
37
+ //#region src/protocol/core.d.ts
38
+ type MethodSpec<P, R> = {
39
+ readonly session: boolean;
40
+ /** Whether a successful call refreshes the idle timer — presence-bearing methods only. */
41
+ readonly presence: boolean;
42
+ readonly params: Validator<P>;
43
+ readonly result: Validator<R>;
44
+ };
45
+ type Factor = {
46
+ readonly kind: "password";
47
+ readonly password: Uint8Array;
48
+ } | {
49
+ readonly kind: "passkey";
50
+ readonly credentialId: Uint8Array;
51
+ readonly prf: Uint8Array;
52
+ };
53
+ /**
54
+ * A backup-envelope factor: same shapes as `Factor`, except the passkey arm carries `prfBackup` —
55
+ * the PRF evaluated over `backupSalt`, not the vault or wallet salt.
56
+ */
57
+ type BackupFactor = {
58
+ readonly kind: "password";
59
+ readonly password: Uint8Array;
60
+ } | {
61
+ readonly kind: "passkey";
62
+ readonly credentialId: Uint8Array;
63
+ readonly prfBackup: Uint8Array;
64
+ };
65
+ declare const walletErrorCode: Validator<WalletErrorCode>;
66
+ /**
67
+ * The result of every "create or import" wallet command: the new wallet's public info plus the
68
+ * session it opened. Creating a wallet derives no protocol keys — modules add keys separately.
69
+ */
70
+ type CreatedResult = {
71
+ readonly wallet: WalletInfo;
72
+ readonly session: string;
73
+ };
74
+ declare const CORE_METHODS: {
75
+ readonly "vault.unlock": MethodSpec<{
76
+ readonly factor: Factor;
77
+ }, {
78
+ readonly session: string;
79
+ }>;
80
+ readonly "vault.reset": MethodSpec<NullValue, NullValue>;
81
+ readonly "vault.addFactor": MethodSpec<{
82
+ readonly verify: Factor;
83
+ readonly factor: Factor;
84
+ }, FactorInfo>;
85
+ readonly "vault.removeFactor": MethodSpec<{
86
+ readonly verify: Factor;
87
+ readonly id: string;
88
+ }, NullValue>;
89
+ readonly "session.touch": MethodSpec<NullValue, NullValue>;
90
+ readonly "wallet.createWithPasskey": MethodSpec<{
91
+ readonly credentialId: Uint8Array;
92
+ readonly prfWallet: Uint8Array;
93
+ readonly synced: boolean;
94
+ readonly factor?: Factor;
95
+ }, CreatedResult>;
96
+ readonly "wallet.restoreWithPasskey": MethodSpec<{
97
+ readonly credentialId: Uint8Array;
98
+ readonly prfWallet: Uint8Array;
99
+ readonly synced: boolean;
100
+ readonly factor?: Factor;
101
+ }, CreatedResult>;
102
+ readonly "wallet.createMnemonic": MethodSpec<{
103
+ readonly words: 12 | 24;
104
+ readonly factor?: Factor;
105
+ }, {
106
+ readonly draft: string;
107
+ readonly words: Uint8Array;
108
+ readonly quiz: ReadonlyArray<number>;
109
+ }>;
110
+ readonly "wallet.confirmMnemonic": MethodSpec<{
111
+ readonly draft: string;
112
+ readonly answers: ReadonlyArray<Uint8Array>;
113
+ }, CreatedResult>;
114
+ readonly "wallet.discardMnemonic": MethodSpec<{
115
+ readonly draft: string;
116
+ }, NullValue>;
117
+ readonly "backup.enable": MethodSpec<{
118
+ readonly verify: Factor;
119
+ readonly factors: ReadonlyArray<BackupFactor>;
120
+ }, NullValue>;
121
+ readonly "backup.update": MethodSpec<NullValue, {
122
+ readonly envelope: string;
123
+ }>;
124
+ readonly "backup.disable": MethodSpec<NullValue, NullValue>;
125
+ readonly "backup.restore": MethodSpec<{
126
+ readonly envelope: string;
127
+ readonly backupFactor: BackupFactor;
128
+ readonly factor?: Factor;
129
+ }, {
130
+ readonly wallets: ReadonlyArray<WalletInfo>;
131
+ readonly session: string;
132
+ }>;
133
+ readonly "wallet.importMnemonic": MethodSpec<{
134
+ readonly mnemonic: Uint8Array;
135
+ readonly factor?: Factor;
136
+ }, CreatedResult>;
137
+ readonly "wallet.exportMnemonic": MethodSpec<{
138
+ readonly verify: Factor;
139
+ readonly walletId: string;
140
+ }, Uint8Array>;
141
+ readonly "wallet.delete": MethodSpec<{
142
+ readonly verify: Factor;
143
+ readonly walletId: string;
144
+ }, NullValue>;
145
+ readonly "dataKeys.get": MethodSpec<{
146
+ readonly purpose: string;
147
+ }, Uint8Array>;
148
+ };
149
+ //#endregion
150
+ //#region src/protocol/nostr.d.ts
151
+ /**
152
+ * The unsigned event input the kernel signs. `pubkey` is optional: callers may omit it and the
153
+ * kernel fills the signing key's own. Structurally compatible with @qntx/nostr's UnsignedEvent.
154
+ */
155
+ type UnsignedEventInput = {
156
+ readonly kind: number;
157
+ readonly created_at: number;
158
+ readonly tags: ReadonlyArray<ReadonlyArray<string>>;
159
+ readonly content: string;
160
+ readonly pubkey?: string;
161
+ };
162
+ /** The signed event the kernel returns — the Nostr event minus `id`-less forms. */
163
+ type SignedEvent = {
164
+ readonly id: string;
165
+ readonly pubkey: string;
166
+ readonly sig: string;
167
+ readonly kind: number;
168
+ readonly created_at: number;
169
+ readonly tags: ReadonlyArray<ReadonlyArray<string>>;
170
+ readonly content: string;
171
+ };
172
+ /** A NIP-59 rumor: an unsigned event carrying a computed `id` but no `sig`. */
173
+ type Rumor = {
174
+ readonly id: string;
175
+ readonly pubkey: string;
176
+ readonly kind: number;
177
+ readonly created_at: number;
178
+ readonly tags: ReadonlyArray<ReadonlyArray<string>>;
179
+ readonly content: string;
180
+ };
181
+ type NostrImportInput = {
182
+ readonly kind: "nsec";
183
+ readonly nsec: Uint8Array;
184
+ } | {
185
+ readonly kind: "ncryptsec";
186
+ readonly ncryptsec: string;
187
+ readonly password: Uint8Array;
188
+ };
189
+ type NostrExportFormat = {
190
+ readonly kind: "nsec";
191
+ } | {
192
+ readonly kind: "ncryptsec";
193
+ readonly password: Uint8Array;
194
+ };
195
+ /** One "import/generate a key" result: the key's public info plus the session it may have opened. */
196
+ type KeyResult = {
197
+ readonly key: NostrKeyInfo;
198
+ readonly session: string;
199
+ };
200
+ type UnwrapResult = {
201
+ readonly ok: Rumor;
202
+ } | {
203
+ readonly err: WalletErrorCode;
204
+ };
205
+ declare const NOSTR_METHODS: {
206
+ readonly "nostr.discover": MethodSpec<{
207
+ readonly walletId: string;
208
+ readonly from: number;
209
+ readonly count: number;
210
+ }, {
211
+ readonly keys: ReadonlyArray<DerivedNostrKey>;
212
+ }>;
213
+ readonly "nostr.deriveKey": MethodSpec<{
214
+ readonly walletId: string;
215
+ readonly groupIndex: number;
216
+ }, NostrKeyInfo>;
217
+ readonly "nostr.importKey": MethodSpec<{
218
+ readonly input: NostrImportInput;
219
+ readonly factor?: Factor;
220
+ }, KeyResult>;
221
+ readonly "nostr.generateKey": MethodSpec<{
222
+ readonly factor?: Factor;
223
+ }, KeyResult>;
224
+ readonly "nostr.createNip46ClientKey": MethodSpec<NullValue, NostrKeyInfo>;
225
+ readonly "nostr.removeKey": MethodSpec<{
226
+ readonly publicKey: string;
227
+ readonly verify?: Factor;
228
+ }, NullValue>;
229
+ readonly "nostr.exportKey": MethodSpec<{
230
+ readonly verify: Factor;
231
+ readonly publicKey: string;
232
+ readonly format: NostrExportFormat;
233
+ }, Uint8Array>;
234
+ readonly "nostr.signEvent": MethodSpec<{
235
+ readonly publicKey: string;
236
+ readonly event: UnsignedEventInput;
237
+ }, SignedEvent>;
238
+ readonly "nostr.nip04Encrypt": MethodSpec<{
239
+ readonly publicKey: string;
240
+ readonly peer: string;
241
+ readonly text: string;
242
+ }, string>;
243
+ readonly "nostr.nip04Decrypt": MethodSpec<{
244
+ readonly publicKey: string;
245
+ readonly peer: string;
246
+ readonly text: string;
247
+ }, string>;
248
+ readonly "nostr.nip44Encrypt": MethodSpec<{
249
+ readonly publicKey: string;
250
+ readonly peer: string;
251
+ readonly text: string;
252
+ }, string>;
253
+ readonly "nostr.nip44Decrypt": MethodSpec<{
254
+ readonly publicKey: string;
255
+ readonly peer: string;
256
+ readonly text: string;
257
+ }, string>;
258
+ readonly "nostr.unwrapGiftWraps": MethodSpec<{
259
+ readonly publicKey: string;
260
+ readonly events: ReadonlyArray<SignedEvent>;
261
+ }, {
262
+ readonly results: ReadonlyArray<UnwrapResult>;
263
+ }>;
264
+ };
265
+ //#endregion
266
+ //#region src/protocol/spark.d.ts
267
+ /** The Spark network the account's signer runs on — identical to @qntx/spark's SparkNetwork. */
268
+ type SparkNetwork = "mainnet" | "regtest";
269
+ /** The wallet+group+network triple every spark.* request addresses a pooled signer by. */
270
+ type SparkAccountRef = {
271
+ readonly walletId: string;
272
+ readonly groupIndex: number;
273
+ readonly network: SparkNetwork;
274
+ };
275
+ type SparkLeafKey = {
276
+ readonly type: "leaf";
277
+ readonly leafId: string;
278
+ } | {
279
+ readonly type: "static-deposit";
280
+ readonly index: number;
281
+ };
282
+ type SparkKey = SparkLeafKey | {
283
+ readonly type: "received";
284
+ readonly ciphertext: Uint8Array;
285
+ };
286
+ type SigningCommitment = {
287
+ readonly hiding: Uint8Array;
288
+ readonly binding: Uint8Array;
289
+ };
290
+ type OperatorCommitment = {
291
+ readonly identifier: string;
292
+ readonly commitment: SigningCommitment;
293
+ };
294
+ type SigningTarget = {
295
+ readonly transaction: Uint8Array;
296
+ readonly inputIndex: number;
297
+ readonly prevouts: ReadonlyArray<{
298
+ script: Uint8Array;
299
+ amount: number;
300
+ }>;
301
+ };
302
+ type FrostSignJob = {
303
+ readonly key: SparkKey;
304
+ readonly target: SigningTarget;
305
+ readonly verifyingKey: Uint8Array;
306
+ readonly commitment: SigningCommitment;
307
+ readonly operatorCommitments: ReadonlyArray<OperatorCommitment>;
308
+ readonly adaptorPublicKey?: Uint8Array;
309
+ /** Connector-refund proof pair — see `FrostSignJob.exit` in @qntx/spark/signer. */
310
+ readonly exit?: {
311
+ readonly connectorTx: Uint8Array;
312
+ readonly exitTx: Uint8Array;
313
+ };
314
+ };
315
+ type FrostAggregateJob = {
316
+ readonly key: SparkKey;
317
+ readonly target: SigningTarget;
318
+ readonly verifyingKey: Uint8Array;
319
+ readonly commitment: SigningCommitment;
320
+ readonly signatureShare: Uint8Array;
321
+ readonly operators: ReadonlyArray<{
322
+ readonly identifier: string;
323
+ readonly commitment: SigningCommitment;
324
+ readonly signatureShare: Uint8Array;
325
+ readonly publicKey: Uint8Array;
326
+ }>;
327
+ readonly adaptorPublicKey?: Uint8Array;
328
+ };
329
+ type StaticDepositClaimStatement = {
330
+ readonly kind: "static-deposit-claim";
331
+ readonly network: SparkNetwork;
332
+ readonly txid: Uint8Array;
333
+ readonly vout: number;
334
+ readonly creditAmountSats: number;
335
+ readonly sspSignature: Uint8Array;
336
+ };
337
+ type IdentityStatement = {
338
+ readonly kind: "so-challenge";
339
+ readonly challenge: Uint8Array;
340
+ } | {
341
+ readonly kind: "ssp-challenge";
342
+ readonly protectedChallenge: string;
343
+ } | {
344
+ readonly kind: "transfer-package";
345
+ readonly transferId: string;
346
+ readonly package: Uint8Array;
347
+ } | {
348
+ readonly kind: "claim-package";
349
+ readonly transferId: string;
350
+ readonly package: Uint8Array;
351
+ } | StaticDepositClaimStatement | {
352
+ readonly kind: "static-deposit-refund";
353
+ readonly network: SparkNetwork;
354
+ readonly txid: Uint8Array;
355
+ readonly vout: number;
356
+ readonly amount: number;
357
+ readonly target: SigningTarget;
358
+ } | {
359
+ readonly kind: "watchtower-recovery";
360
+ readonly network: SparkNetwork;
361
+ readonly leafId: string;
362
+ readonly target: SigningTarget;
363
+ } | {
364
+ readonly kind: "spark-invoice";
365
+ readonly invoice: Uint8Array;
366
+ } | {
367
+ readonly kind: "token-transaction";
368
+ readonly partialTransaction: Uint8Array;
369
+ } | {
370
+ readonly kind: "lightning-address";
371
+ readonly action: "register";
372
+ readonly domain: string;
373
+ readonly username: string;
374
+ readonly description: string;
375
+ readonly timestamp: number;
376
+ } | {
377
+ readonly kind: "lightning-address";
378
+ readonly action: "unregister";
379
+ readonly domain: string;
380
+ readonly username: string;
381
+ readonly timestamp: number;
382
+ };
383
+ type PrepareTransferRequest = {
384
+ readonly transferId: string;
385
+ readonly leaves: ReadonlyArray<{
386
+ readonly leafId: string;
387
+ readonly key: SparkLeafKey;
388
+ readonly receiverIdentityPublicKey: Uint8Array;
389
+ }>;
390
+ };
391
+ type PreparedTransferLeaf = {
392
+ readonly leafId: string;
393
+ readonly newPublicKey: Uint8Array;
394
+ readonly secretCipher: Uint8Array;
395
+ readonly signature: Uint8Array;
396
+ };
397
+ type PreparedTransfer = {
398
+ readonly operatorPackages: Record<string, Uint8Array>;
399
+ readonly leaves: ReadonlyArray<PreparedTransferLeaf>;
400
+ };
401
+ type PrepareClaimRequest = {
402
+ readonly transferId: string;
403
+ readonly leaves: ReadonlyArray<{
404
+ readonly leafId: string;
405
+ readonly secretCipher: Uint8Array;
406
+ }>;
407
+ };
408
+ type PreparedClaim = {
409
+ readonly operatorPackages: Record<string, Uint8Array>;
410
+ };
411
+ type PreparedLightningReceive = {
412
+ readonly paymentHash: Uint8Array;
413
+ readonly operatorPackages: Record<string, Uint8Array>;
414
+ };
415
+ type HtlcTimeoutSignRequest = {
416
+ readonly transaction: Uint8Array;
417
+ readonly inputIndex: number;
418
+ readonly prevoutAmountSats: number;
419
+ readonly paymentHash: Uint8Array;
420
+ readonly hashLockPublicKey: Uint8Array;
421
+ };
422
+ type StaticDepositClaimRequest = {
423
+ readonly index: number;
424
+ readonly statement: StaticDepositClaimStatement;
425
+ };
426
+ type StaticDepositClaimResult = {
427
+ readonly encryptedSecretKey: Uint8Array;
428
+ readonly signature: Uint8Array;
429
+ };
430
+ /**
431
+ * The intent a `spark.approve` registers — kernel-decoded before the host ever displays it. `token`
432
+ * receivers' amounts are canonical decimal strings in the u128 range.
433
+ */
434
+ type SparkApproveIntent = {
435
+ readonly kind: "transfer";
436
+ readonly receivers: ReadonlyArray<{
437
+ readonly identityPublicKey: Uint8Array;
438
+ readonly amountSats: number;
439
+ }>;
440
+ } | {
441
+ readonly kind: "lightning";
442
+ readonly invoice: string;
443
+ readonly amountSats?: number;
444
+ readonly maxFeeSats: number;
445
+ } | {
446
+ readonly kind: "exit";
447
+ readonly address: string;
448
+ readonly amountSats: number;
449
+ readonly maxFeeSats: number;
450
+ } | {
451
+ readonly kind: "onchain";
452
+ readonly address: string;
453
+ readonly maxFeeSats: number;
454
+ } | {
455
+ readonly kind: "token";
456
+ readonly tokenIdentifier: Uint8Array;
457
+ readonly receivers: ReadonlyArray<{
458
+ readonly ownerPublicKey: Uint8Array;
459
+ readonly amount: string;
460
+ }>;
461
+ };
462
+ /**
463
+ * What `spark.approve` returns: the kernel's own decode of the intent — receivers and amounts, the
464
+ * invoice's payment hash and amount, or the exit/onchain destination — never host-provided text.
465
+ */
466
+ type SparkApprovalSummary = {
467
+ readonly kind: "transfer";
468
+ readonly receivers: ReadonlyArray<{
469
+ readonly identityPublicKey: Uint8Array;
470
+ readonly amountSats: number;
471
+ }>;
472
+ } | {
473
+ readonly kind: "lightning";
474
+ readonly paymentHash: Uint8Array;
475
+ readonly invoiceAmountSats?: number;
476
+ readonly maxFeeSats: number;
477
+ } | {
478
+ readonly kind: "exit";
479
+ readonly address: string;
480
+ readonly amountSats: number;
481
+ readonly maxFeeSats: number;
482
+ } | {
483
+ readonly kind: "onchain";
484
+ readonly address: string;
485
+ readonly maxFeeSats: number;
486
+ } | {
487
+ readonly kind: "token";
488
+ readonly tokenIdentifier: Uint8Array;
489
+ readonly receivers: ReadonlyArray<{
490
+ readonly ownerPublicKey: Uint8Array;
491
+ readonly amount: string;
492
+ }>;
493
+ };
494
+ declare const SPARK_METHODS: {
495
+ readonly "spark.identityPublicKey": MethodSpec<{
496
+ readonly account: SparkAccountRef;
497
+ }, Uint8Array>;
498
+ readonly "spark.publicKeys": MethodSpec<{
499
+ readonly account: SparkAccountRef;
500
+ readonly keys: ReadonlyArray<SparkLeafKey>;
501
+ }, ReadonlyArray<Uint8Array>>;
502
+ readonly "spark.receivedPublicKeys": MethodSpec<{
503
+ readonly account: SparkAccountRef;
504
+ readonly ciphertexts: ReadonlyArray<Uint8Array>;
505
+ }, ReadonlyArray<Uint8Array>>;
506
+ readonly "spark.newCommitments": MethodSpec<{
507
+ readonly account: SparkAccountRef;
508
+ readonly count: number;
509
+ }, ReadonlyArray<SigningCommitment>>;
510
+ readonly "spark.signFrost": MethodSpec<{
511
+ readonly account: SparkAccountRef;
512
+ readonly jobs: ReadonlyArray<FrostSignJob>;
513
+ }, ReadonlyArray<Uint8Array>>;
514
+ readonly "spark.aggregateFrost": MethodSpec<{
515
+ readonly account: SparkAccountRef;
516
+ readonly jobs: ReadonlyArray<FrostAggregateJob>;
517
+ }, ReadonlyArray<Uint8Array>>;
518
+ readonly "spark.signIdentity": MethodSpec<{
519
+ readonly account: SparkAccountRef;
520
+ readonly statement: IdentityStatement;
521
+ }, Uint8Array>;
522
+ readonly "spark.signKeySpend": MethodSpec<{
523
+ readonly account: SparkAccountRef;
524
+ readonly key: SparkKey;
525
+ readonly target: SigningTarget;
526
+ }, Uint8Array>;
527
+ readonly "spark.signHtlcTimeout": MethodSpec<{
528
+ readonly account: SparkAccountRef;
529
+ readonly request: HtlcTimeoutSignRequest;
530
+ }, Uint8Array>;
531
+ readonly "spark.prepareTransfer": MethodSpec<{
532
+ readonly account: SparkAccountRef;
533
+ readonly request: PrepareTransferRequest;
534
+ }, PreparedTransfer>;
535
+ readonly "spark.prepareClaim": MethodSpec<{
536
+ readonly account: SparkAccountRef;
537
+ readonly request: PrepareClaimRequest;
538
+ }, PreparedClaim>;
539
+ readonly "spark.prepareLightningReceive": MethodSpec<{
540
+ readonly account: SparkAccountRef;
541
+ }, PreparedLightningReceive>;
542
+ readonly "spark.claimStaticDeposit": MethodSpec<{
543
+ readonly account: SparkAccountRef;
544
+ readonly request: StaticDepositClaimRequest;
545
+ }, StaticDepositClaimResult>;
546
+ readonly "spark.approve": MethodSpec<{
547
+ readonly account: SparkAccountRef;
548
+ readonly intent: SparkApproveIntent;
549
+ readonly verify: Factor;
550
+ }, SparkApprovalSummary>;
551
+ };
552
+ //#endregion
553
+ //#region src/protocol/backup.d.ts
554
+ type BackupEnvelopeFactor = {
555
+ readonly kind: "passkey";
556
+ readonly credentialId: string;
557
+ readonly sealedBek: string;
558
+ } | {
559
+ readonly kind: "password";
560
+ readonly iterations: 600_000;
561
+ readonly salt: string;
562
+ readonly sealedBek: string;
563
+ };
564
+ type BackupEnvelopeWire = {
565
+ readonly version: 1;
566
+ readonly createdAt: number;
567
+ /** Raw JSON text — authenticated by the payload tag before it is parsed. */
568
+ readonly header: string;
569
+ readonly factors: ReadonlyArray<BackupEnvelopeFactor>;
570
+ readonly payload: string;
571
+ };
572
+ /** One public factor entry — shared by the envelope and the retained `backup-key` header. */
573
+ declare const backupEnvelopeFactor: Validator<BackupEnvelopeFactor>;
574
+ declare const backupEnvelope: Validator<BackupEnvelopeWire>;
575
+ type BackupHeaderWallet = {
576
+ readonly walletId: string;
577
+ readonly origin: "mnemonic" | "passkey";
578
+ readonly words: 12 | 15 | 18 | 21 | 24;
579
+ };
580
+ type BackupHeaderWire = {
581
+ readonly wallets: ReadonlyArray<BackupHeaderWallet>;
582
+ readonly importedNostrKeyCount: number;
583
+ readonly importedChainKeyCount: number;
584
+ };
585
+ declare const backupHeader: Validator<BackupHeaderWire>;
586
+ /** The whole-envelope text bound — `backup.update` results and `backup.restore` params use it. */
587
+ declare const backupEnvelopeText: Validator<string>;
588
+ /** The status/snapshot summary of a retained backup key — public data only. */
589
+ type BackupInfo = {
590
+ readonly id: string;
591
+ readonly factors: ReadonlyArray<"passkey" | "password">;
592
+ readonly createdAt: number;
593
+ };
594
+ declare const backupInfo: Validator<BackupInfo>;
595
+ //#endregion
596
+ //#region src/protocol/index.d.ts
597
+ declare const PROTOCOL_VERSION = 1;
598
+ /**
599
+ * Responses to requests whose `id` cannot be parsed (malformed envelope) carry id 0. Main-side
600
+ * request ids start at 1, so a `0` is never a real pending request.
601
+ */
602
+ declare const UNATTRIBUTED_ID = 0;
603
+ type NullValue = null;
604
+ type ProtocolValue = NullValue | boolean | number | string | Uint8Array | ReadonlyArray<ProtocolValue> | {
605
+ readonly [key: string]: ProtocolValue;
606
+ };
607
+ type Request = {
608
+ readonly v: 1;
609
+ readonly id: number;
610
+ readonly method: string;
611
+ readonly session?: string;
612
+ readonly params: ProtocolValue;
613
+ };
614
+ type ErrorPayload = {
615
+ readonly code: WalletErrorCode;
616
+ readonly retryAt?: number;
617
+ };
618
+ type Response = {
619
+ readonly v: 1;
620
+ readonly id: number;
621
+ readonly ok: ProtocolValue;
622
+ } | {
623
+ readonly v: 1;
624
+ readonly id: number;
625
+ readonly err: ErrorPayload;
626
+ };
627
+ type KernelEvent = {
628
+ readonly v: 1;
629
+ readonly event: "status";
630
+ readonly status: StatusPayload;
631
+ } | {
632
+ readonly v: 1;
633
+ readonly event: "locked";
634
+ readonly reason: LockReason;
635
+ };
636
+ /**
637
+ * The worst-case encoded size of one request, enforced by both sides: the host refuses to post a
638
+ * request over the cap and the kernel answers an oversized raw request with `invalid-input`.
639
+ * Responses are not capped.
640
+ */
641
+ declare const MAX_REQUEST_BYTES = 1048576;
642
+ /**
643
+ * Upper-bound byte weight of a protocol value: a string costs `length * 3` (worst-case UTF-8), a
644
+ * Uint8Array its `byteLength`, every scalar and every array element 8, and every object key
645
+ * `key.length * 3 + 8` plus its value. Iterative — a deeply nested value cannot overflow the
646
+ * stack.
647
+ */
648
+ declare function requestBytes(value: ProtocolValue): number;
649
+ /** Deep check that a structured-cloned value is a strict ProtocolValue (no cycles detected). */
650
+ declare function isProtocolValue(value: unknown): value is ProtocolValue;
651
+ declare const METHODS: {
652
+ readonly status: MethodSpec<NullValue, StatusPayload>;
653
+ } & typeof CORE_METHODS & typeof NOSTR_METHODS & typeof SPARK_METHODS;
654
+ type AssertNever<T extends never> = T;
655
+ type MethodTablesDisjoint = [AssertNever<keyof typeof CORE_METHODS & keyof typeof NOSTR_METHODS>, AssertNever<keyof typeof CORE_METHODS & keyof typeof SPARK_METHODS>, AssertNever<keyof typeof NOSTR_METHODS & keyof typeof SPARK_METHODS>];
656
+ type MethodName = keyof typeof METHODS;
657
+ type ParamsOf<M extends MethodName> = ReturnType<(typeof METHODS)[M]["params"]>;
658
+ type ResultOf<M extends MethodName> = ReturnType<(typeof METHODS)[M]["result"]>;
659
+ /** Host-side validators: `kernelEvent` covers the two push messages. */
660
+ declare const kernelEvent: Validator<KernelEvent>;
661
+ /** Validates the `err` payload of a response; `ok` is checked against `METHODS[m].result`. */
662
+ declare const responseError: Validator<{
663
+ code: WalletErrorCode;
664
+ retryAt?: number | undefined;
665
+ }>;
666
+ //#endregion
667
+ export { NOSTR_METHODS as $, FrostSignJob as A, SPARK_METHODS as B, BackupInfo as C, str as Ct, backupHeader as D, backupEnvelopeText as E, PrepareTransferRequest as F, SparkApproveIntent as G, SigningTarget as H, PreparedClaim as I, SparkNetwork as J, SparkKey as K, PreparedLightningReceive as L, IdentityStatement as M, OperatorCommitment as N, backupInfo as O, PrepareClaimRequest as P, KeyResult as Q, PreparedTransfer as R, BackupHeaderWire as S, record as St, backupEnvelopeFactor as T, validate as Tt, SparkAccountRef as U, SigningCommitment as V, SparkApprovalSummary as W, StaticDepositClaimResult as X, StaticDepositClaimRequest as Y, StaticDepositClaimStatement as Z, requestBytes as _, int as _t, MethodName as a, UnwrapResult as at, BackupEnvelopeWire as b, obj as bt, PROTOCOL_VERSION as c, CreatedResult as ct, Request as d, walletErrorCode as dt, NostrExportFormat as et, Response as f, ValidationError as ft, kernelEvent as g, bytes as gt, isProtocolValue as h, bool as ht, METHODS as i, UnsignedEventInput as it, HtlcTimeoutSignRequest as j, FrostAggregateJob as k, ParamsOf as l, Factor as lt, UNATTRIBUTED_ID as m, arr as mt, KernelEvent as n, Rumor as nt, MethodTablesDisjoint as o, BackupFactor as ot, ResultOf as p, Validator as pt, SparkLeafKey as q, MAX_REQUEST_BYTES as r, SignedEvent as rt, NullValue as s, CORE_METHODS as st, ErrorPayload as t, NostrImportInput as tt, ProtocolValue as u, MethodSpec as ut, responseError as v, literal as vt, backupEnvelope as w, union as wt, BackupHeaderWallet as x, opt as xt, BackupEnvelopeFactor as y, nullValue as yt, PreparedTransferLeaf as z };
668
+ //# sourceMappingURL=index-Dhf6wGjQ.d.mts.map
package/dist/index.d.mts CHANGED
@@ -1,2 +1,18 @@
1
- import { _ as WalletErrorCode, a as FactorInfo, b as WalletSnapshot, c as MnemonicDraft, d as PasskeyConfig, f as StatusPayload, g as WalletError, h as Wallet, i as ExportedSecret, l as NostrKeyInfo, m as VaultApi, n as DataKeyApi, o as InitialFactor, p as UnlockFactor, r as DerivedNostrKey, s as LockReason, t as AutoLockPolicy, u as NostrKeyRef, v as WalletInfo, x as WalletsApi, y as WalletOptions } from "./types-CEy7At1l.mjs";
2
- export { type AutoLockPolicy, type DataKeyApi, type DerivedNostrKey, type ExportedSecret, type FactorInfo, type InitialFactor, type LockReason, type MnemonicDraft, type NostrKeyInfo, type NostrKeyRef, type PasskeyConfig, type StatusPayload, type UnlockFactor, type VaultApi, type Wallet, WalletError, type WalletErrorCode, type WalletInfo, type WalletOptions, type WalletSnapshot, type WalletsApi };
1
+ import { C as WalletSnapshot, S as WalletOptions, _ as VaultState, a as DerivedNostrKey, b as WalletErrorCode, c as InitialFactor, d as NostrKeyInfo, f as NostrKeyRef, g as VaultApi, h as UnlockFactor, i as DataKeyApi, l as LockReason, m as StatusPayload, n as BackupApi, o as ExportedSecret, p as PasskeyConfig, r as BackupInfo, s as FactorInfo, t as AutoLockPolicy, u as MnemonicDraft, v as Wallet, w as WalletsApi, x as WalletInfo, y as WalletError } from "./types-D4OUjGVS.mjs";
2
+ import { S as BackupHeaderWire } from "./index-Dhf6wGjQ.mjs";
3
+ //#region src/backup.d.ts
4
+ type BackupHeaderWallet = BackupHeaderWire["wallets"][number];
5
+ type BackupHeader = {
6
+ readonly version: 1;
7
+ readonly createdAt: number;
8
+ readonly wallets: ReadonlyArray<BackupHeaderWallet>;
9
+ readonly importedNostrKeyCount: number;
10
+ readonly importedChainKeyCount: number;
11
+ /** The factor kinds the envelope can be unwrapped with. */
12
+ readonly factorKinds: ReadonlyArray<"passkey" | "password">;
13
+ };
14
+ /** Strictly validates the envelope and returns the header fields — no secrets, no writes. */
15
+ export declare function parseBackupHeader(envelope: string): BackupHeader;
16
+ //#endregion
17
+ export { type AutoLockPolicy, type BackupApi, type BackupHeader, type BackupHeaderWallet, type BackupInfo, type DataKeyApi, type DerivedNostrKey, type ExportedSecret, type FactorInfo, type InitialFactor, type LockReason, type MnemonicDraft, type NostrKeyInfo, type NostrKeyRef, type PasskeyConfig, type StatusPayload, type UnlockFactor, type VaultApi, type VaultState, type Wallet, WalletError, type WalletErrorCode, type WalletInfo, type WalletOptions, type WalletSnapshot, type WalletsApi };
18
+ //# sourceMappingURL=index.d.mts.map