@qntx/wallet 0.5.2 → 0.7.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 (35) hide show
  1. package/dist/chains-CuKVAJMN.d.mts +333 -0
  2. package/dist/chains.d.mts +2 -4
  3. package/dist/chains.mjs +3 -4
  4. package/dist/{channel-ChYtMklb.mjs → channel-Iiz28m-e.mjs} +6 -7
  5. package/dist/{channel-ChYtMklb.mjs.map → channel-Iiz28m-e.mjs.map} +1 -1
  6. package/dist/{core-Dmz5SbyJ.mjs → core-Cq5h9X0X.mjs} +11 -6
  7. package/dist/core-Cq5h9X0X.mjs.map +1 -0
  8. package/dist/host.d.mts +2 -8
  9. package/dist/host.mjs +18 -23
  10. package/dist/host.mjs.map +1 -1
  11. package/dist/{chains-D_jfwTPT.d.mts → index-CIZzbqqv.d.mts} +42 -402
  12. package/dist/index.d.mts +2 -6
  13. package/dist/index.mjs +3 -6
  14. package/dist/index.mjs.map +1 -1
  15. package/dist/{internal-LBHal13j.mjs → internal-CAKfHjIg.mjs} +2 -3
  16. package/dist/{internal-LBHal13j.mjs.map → internal-CAKfHjIg.mjs.map} +1 -1
  17. package/dist/nostr.d.mts +19 -22
  18. package/dist/nostr.mjs +59 -51
  19. package/dist/nostr.mjs.map +1 -1
  20. package/dist/{protocol-DvzlUKB8.mjs → protocol-DbpLncEB.mjs} +81 -117
  21. package/dist/protocol-DbpLncEB.mjs.map +1 -0
  22. package/dist/protocol.d.mts +4 -3
  23. package/dist/protocol.mjs +2 -2
  24. package/dist/{secret-BiyX0Hus.mjs → secret-Dz_ItVt6.mjs} +3 -5
  25. package/dist/{secret-BiyX0Hus.mjs.map → secret-Dz_ItVt6.mjs.map} +1 -1
  26. package/dist/spark.d.mts +2 -6
  27. package/dist/spark.mjs +4 -7
  28. package/dist/spark.mjs.map +1 -1
  29. package/dist/{types-BD9fuAUj.d.mts → types-BgFsXgyI.d.mts} +5 -19
  30. package/dist/types.d.mts +1 -1
  31. package/dist/types.mjs +1 -2
  32. package/dist/types.mjs.map +1 -1
  33. package/package.json +4 -4
  34. package/dist/core-Dmz5SbyJ.mjs.map +0 -1
  35. package/dist/protocol-DvzlUKB8.mjs.map +0 -1
@@ -1,40 +1,5 @@
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-BD9fuAUj.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/nostr.d.ts
1
+ import { a as DerivedNostrKey, b as WalletErrorCode, d as NostrKeyInfo, l as LockReason, m as StatusPayload } from "./types-BgFsXgyI.mjs";
2
+ import { f as Factor, g as NullValue, l as CORE_METHODS, p as MethodSpec, t as CHAINS_METHODS, v as Validator } from "./chains-CuKVAJMN.mjs";
38
3
  /**
39
4
  * The unsigned event input the kernel signs. `pubkey` is optional: callers may omit it and the
40
5
  * kernel fills the signing key's own. Structurally compatible with @qntx/nostr's UnsignedEvent.
@@ -65,25 +30,12 @@ type Rumor = {
65
30
  readonly tags: ReadonlyArray<ReadonlyArray<string>>;
66
31
  readonly content: string;
67
32
  };
68
- type NostrImportInput = {
69
- readonly kind: "nsec";
70
- readonly nsec: Uint8Array;
71
- } | {
72
- readonly kind: "ncryptsec";
73
- readonly ncryptsec: string;
74
- readonly password: Uint8Array;
75
- };
76
33
  type NostrExportFormat = {
77
34
  readonly kind: "nsec";
78
35
  } | {
79
36
  readonly kind: "ncryptsec";
80
37
  readonly password: Uint8Array;
81
38
  };
82
- /** One "import/generate a key" result: the key's public info plus the session it may have opened. */
83
- type KeyResult = {
84
- readonly key: NostrKeyInfo;
85
- readonly session: string;
86
- };
87
39
  type UnwrapResult = {
88
40
  readonly ok: Rumor;
89
41
  } | {
@@ -99,19 +51,10 @@ declare const NOSTR_METHODS: {
99
51
  }>;
100
52
  readonly "nostr.deriveKey": MethodSpec<{
101
53
  readonly walletId: string;
102
- readonly groupIndex: number;
54
+ readonly index: number;
103
55
  }, NostrKeyInfo>;
104
- readonly "nostr.importKey": MethodSpec<{
105
- readonly input: NostrImportInput;
106
- readonly factor?: Factor;
107
- }, KeyResult>;
108
- readonly "nostr.generateKey": MethodSpec<{
109
- readonly factor?: Factor;
110
- }, KeyResult>;
111
- readonly "nostr.createNip46ClientKey": MethodSpec<NullValue, NostrKeyInfo>;
112
56
  readonly "nostr.removeKey": MethodSpec<{
113
57
  readonly publicKey: string;
114
- readonly verify?: Factor;
115
58
  }, NullValue>;
116
59
  readonly "nostr.exportKey": MethodSpec<{
117
60
  readonly verify: Factor;
@@ -142,6 +85,23 @@ declare const NOSTR_METHODS: {
142
85
  readonly peer: string;
143
86
  readonly text: string;
144
87
  }, string>;
88
+ readonly "nostr.syncKey": MethodSpec<{
89
+ readonly walletId: string;
90
+ }, {
91
+ readonly publicKey: string;
92
+ }>;
93
+ readonly "nostr.syncSign": MethodSpec<{
94
+ readonly walletId: string;
95
+ readonly event: UnsignedEventInput;
96
+ }, SignedEvent>;
97
+ readonly "nostr.syncEncrypt": MethodSpec<{
98
+ readonly walletId: string;
99
+ readonly text: string;
100
+ }, string>;
101
+ readonly "nostr.syncDecrypt": MethodSpec<{
102
+ readonly walletId: string;
103
+ readonly text: string;
104
+ }, string>;
145
105
  readonly "nostr.unwrapGiftWraps": MethodSpec<{
146
106
  readonly publicKey: string;
147
107
  readonly events: ReadonlyArray<SignedEvent>;
@@ -149,8 +109,6 @@ declare const NOSTR_METHODS: {
149
109
  readonly results: ReadonlyArray<UnwrapResult>;
150
110
  }>;
151
111
  };
152
- //#endregion
153
- //#region src/protocol/spark.d.ts
154
112
  /** The Spark network the account's signer runs on — identical to @qntx/spark's SparkNetwork. */
155
113
  type SparkNetwork = "mainnet" | "regtest";
156
114
  /** The wallet+group+network triple every spark.* request addresses a pooled signer by. */
@@ -318,18 +276,7 @@ type StaticDepositClaimResult = {
318
276
  * The intent a `spark.approve` registers — kernel-decoded before the host ever displays it. `token`
319
277
  * receivers' amounts are canonical decimal strings in the u128 range.
320
278
  */
321
- type SparkApproveIntent = {
322
- readonly kind: "transfer";
323
- readonly receivers: ReadonlyArray<{
324
- readonly identityPublicKey: Uint8Array;
325
- readonly amountSats: number;
326
- }>;
327
- } | {
328
- readonly kind: "lightning";
329
- readonly invoice: string;
330
- readonly amountSats?: number;
331
- readonly maxFeeSats: number;
332
- } | {
279
+ type SparkOutflowIntent = {
333
280
  readonly kind: "exit";
334
281
  readonly address: string;
335
282
  readonly amountSats: number;
@@ -346,6 +293,18 @@ type SparkApproveIntent = {
346
293
  readonly amount: string;
347
294
  }>;
348
295
  };
296
+ type SparkApproveIntent = {
297
+ readonly kind: "transfer";
298
+ readonly receivers: ReadonlyArray<{
299
+ readonly identityPublicKey: Uint8Array;
300
+ readonly amountSats: number;
301
+ }>;
302
+ } | {
303
+ readonly kind: "lightning";
304
+ readonly invoice: string;
305
+ readonly amountSats?: number;
306
+ readonly maxFeeSats: number;
307
+ } | SparkOutflowIntent;
349
308
  /**
350
309
  * What `spark.approve` returns: the kernel's own decode of the intent — receivers and amounts, the
351
310
  * invoice's payment hash and amount, or the exit/onchain destination — never host-provided text.
@@ -361,23 +320,7 @@ type SparkApprovalSummary = {
361
320
  readonly paymentHash: Uint8Array;
362
321
  readonly invoiceAmountSats?: number;
363
322
  readonly maxFeeSats: number;
364
- } | {
365
- readonly kind: "exit";
366
- readonly address: string;
367
- readonly amountSats: number;
368
- readonly maxFeeSats: number;
369
- } | {
370
- readonly kind: "onchain";
371
- readonly address: string;
372
- readonly maxFeeSats: number;
373
- } | {
374
- readonly kind: "token";
375
- readonly tokenIdentifier: Uint8Array;
376
- readonly receivers: ReadonlyArray<{
377
- readonly ownerPublicKey: Uint8Array;
378
- readonly amount: string;
379
- }>;
380
- };
323
+ } | SparkOutflowIntent;
381
324
  declare const SPARK_METHODS: {
382
325
  readonly "spark.identityPublicKey": MethodSpec<{
383
326
  readonly account: SparkAccountRef;
@@ -436,8 +379,6 @@ declare const SPARK_METHODS: {
436
379
  readonly verify: Factor;
437
380
  }, SparkApprovalSummary>;
438
381
  };
439
- //#endregion
440
- //#region src/protocol/backup.d.ts
441
382
  type BackupEnvelopeFactor = {
442
383
  readonly kind: "passkey";
443
384
  readonly credentialId: string;
@@ -466,8 +407,6 @@ type BackupHeaderWallet = {
466
407
  };
467
408
  type BackupHeaderWire = {
468
409
  readonly wallets: ReadonlyArray<BackupHeaderWallet>;
469
- readonly importedNostrKeyCount: number;
470
- readonly importedChainKeyCount: number;
471
410
  };
472
411
  declare const backupHeader: Validator<BackupHeaderWire>;
473
412
  /** The whole-envelope text bound — `backup.update` results and `backup.restore` params use it. */
@@ -479,20 +418,17 @@ type BackupInfo = {
479
418
  readonly createdAt: number;
480
419
  };
481
420
  declare const backupInfo: Validator<BackupInfo>;
482
- //#endregion
483
- //#region src/protocol/index.d.ts
484
- declare const PROTOCOL_VERSION = 1;
421
+ declare const PROTOCOL_VERSION = 2;
485
422
  /**
486
423
  * Responses to requests whose `id` cannot be parsed (malformed envelope) carry id 0. Main-side
487
424
  * request ids start at 1, so a `0` is never a real pending request.
488
425
  */
489
426
  declare const UNATTRIBUTED_ID = 0;
490
- type NullValue = null;
491
427
  type ProtocolValue = NullValue | boolean | number | string | Uint8Array | ReadonlyArray<ProtocolValue> | {
492
428
  readonly [key: string]: ProtocolValue;
493
429
  };
494
430
  type Request = {
495
- readonly v: 1;
431
+ readonly v: typeof PROTOCOL_VERSION;
496
432
  readonly id: number;
497
433
  readonly method: string;
498
434
  readonly session?: string;
@@ -503,20 +439,20 @@ type ErrorPayload = {
503
439
  readonly retryAt?: number;
504
440
  };
505
441
  type Response = {
506
- readonly v: 1;
442
+ readonly v: typeof PROTOCOL_VERSION;
507
443
  readonly id: number;
508
444
  readonly ok: ProtocolValue;
509
445
  } | {
510
- readonly v: 1;
446
+ readonly v: typeof PROTOCOL_VERSION;
511
447
  readonly id: number;
512
448
  readonly err: ErrorPayload;
513
449
  };
514
450
  type KernelEvent = {
515
- readonly v: 1;
451
+ readonly v: typeof PROTOCOL_VERSION;
516
452
  readonly event: "status";
517
453
  readonly status: StatusPayload;
518
454
  } | {
519
- readonly v: 1;
455
+ readonly v: typeof PROTOCOL_VERSION;
520
456
  readonly event: "locked";
521
457
  readonly reason: LockReason;
522
458
  };
@@ -550,301 +486,5 @@ declare const responseError: Validator<{
550
486
  code: WalletErrorCode;
551
487
  retryAt?: number | undefined;
552
488
  }>;
553
- //#endregion
554
- //#region src/protocol/core.d.ts
555
- type MethodSpec<P, R> = {
556
- readonly session: boolean;
557
- /** Whether a successful call refreshes the idle timer — presence-bearing methods only. */
558
- readonly presence: boolean;
559
- readonly params: Validator<P>;
560
- readonly result: Validator<R>;
561
- };
562
- /**
563
- * Vault factor material on the wire. `hardware` carries nothing: the kernel runs the platform
564
- * keystore ceremony itself, so the main runtime never touches the KEK.
565
- */
566
- type Factor = {
567
- readonly kind: "hardware";
568
- } | {
569
- readonly kind: "password";
570
- readonly password: Uint8Array;
571
- } | {
572
- readonly kind: "passkey";
573
- readonly credentialId: Uint8Array;
574
- readonly prf: Uint8Array;
575
- };
576
- /** A host-run backup passkey ceremony's evidence: the PRF over `backupSalt` (web). */
577
- type HostBackupPasskey = {
578
- readonly kind: "passkey";
579
- readonly ceremony: "host";
580
- readonly credentialId: Uint8Array;
581
- readonly prfBackup: Uint8Array;
582
- };
583
- /**
584
- * A factor that seals a new backup key. On React Native the kernel registers a protection
585
- * credential (`kernel`) itself and names it; on the web the host hands over its ceremony's
586
- * evidence.
587
- */
588
- type BackupFactor = {
589
- readonly kind: "password";
590
- readonly password: Uint8Array;
591
- } | HostBackupPasskey | {
592
- readonly kind: "passkey";
593
- readonly ceremony: "kernel";
594
- readonly rpId: string;
595
- readonly rpName: string;
596
- readonly backupSalt: string;
597
- };
598
- /**
599
- * A factor that opens a backup envelope. The `kernel` passkey arm asserts one of the envelope's own
600
- * credentials.
601
- */
602
- type BackupUnlockFactor = {
603
- readonly kind: "password";
604
- readonly password: Uint8Array;
605
- } | HostBackupPasskey | {
606
- readonly kind: "passkey";
607
- readonly ceremony: "kernel";
608
- readonly rpId: string;
609
- readonly backupSalt: string;
610
- };
611
- /**
612
- * Passkey wallet creation. `host`: the host ran the WebAuthn ceremony and hands over the PRF
613
- * evidence (web). `kernel`: the kernel runs the platform ceremony itself and nothing secret crosses
614
- * the channel (React Native). The kernel accepts exactly the shape its platform supports.
615
- */
616
- type CreateWithPasskeyParams = {
617
- readonly ceremony: "host";
618
- readonly credentialId: Uint8Array;
619
- readonly prfWallet: Uint8Array;
620
- readonly synced: boolean;
621
- readonly factor?: Factor;
622
- } | {
623
- readonly ceremony: "kernel";
624
- readonly rpId: string;
625
- readonly rpName: string;
626
- readonly name: string;
627
- readonly walletSalt: string;
628
- readonly factor?: Factor;
629
- };
630
- type RestoreWithPasskeyParams = {
631
- readonly ceremony: "host";
632
- readonly credentialId: Uint8Array;
633
- readonly prfWallet: Uint8Array;
634
- readonly synced: boolean;
635
- readonly factor?: Factor;
636
- } | {
637
- readonly ceremony: "kernel";
638
- readonly rpId: string;
639
- readonly walletSalt: string;
640
- readonly factor?: Factor;
641
- };
642
- declare const walletErrorCode: Validator<WalletErrorCode>;
643
- /**
644
- * The result of every "create or import" wallet command: the new wallet's public info plus the
645
- * session it opened. Creating a wallet derives no protocol keys — modules add keys separately.
646
- */
647
- type CreatedResult = {
648
- readonly wallet: WalletInfo;
649
- readonly session: string;
650
- };
651
- declare const CORE_METHODS: {
652
- readonly "vault.unlock": MethodSpec<{
653
- readonly factor: Factor;
654
- }, {
655
- readonly session: string;
656
- }>;
657
- readonly "vault.reset": MethodSpec<NullValue, NullValue>;
658
- readonly "vault.addFactor": MethodSpec<{
659
- readonly verify: Factor;
660
- readonly factor: Factor;
661
- }, FactorInfo>;
662
- readonly "vault.removeFactor": MethodSpec<{
663
- readonly verify: Factor;
664
- readonly id: string;
665
- }, NullValue>;
666
- readonly "session.touch": MethodSpec<NullValue, NullValue>;
667
- readonly "wallet.createWithPasskey": MethodSpec<CreateWithPasskeyParams, CreatedResult>;
668
- readonly "wallet.restoreWithPasskey": MethodSpec<RestoreWithPasskeyParams, CreatedResult>;
669
- readonly "wallet.createMnemonic": MethodSpec<{
670
- readonly words: 12 | 24;
671
- readonly factor?: Factor;
672
- }, {
673
- readonly draft: string;
674
- readonly words: Uint8Array;
675
- readonly quiz: ReadonlyArray<number>;
676
- }>;
677
- readonly "wallet.confirmMnemonic": MethodSpec<{
678
- readonly draft: string;
679
- readonly answers: ReadonlyArray<Uint8Array>;
680
- }, CreatedResult>;
681
- readonly "wallet.discardMnemonic": MethodSpec<{
682
- readonly draft: string;
683
- }, NullValue>;
684
- readonly "backup.enable": MethodSpec<{
685
- readonly verify: Factor;
686
- readonly factors: ReadonlyArray<BackupFactor>;
687
- }, NullValue>;
688
- readonly "backup.update": MethodSpec<NullValue, {
689
- readonly envelope: string;
690
- }>;
691
- readonly "backup.disable": MethodSpec<NullValue, NullValue>;
692
- readonly "backup.restore": MethodSpec<{
693
- readonly envelope: string;
694
- readonly backupFactor: BackupUnlockFactor;
695
- readonly factor?: Factor;
696
- }, {
697
- readonly wallets: ReadonlyArray<WalletInfo>;
698
- readonly session: string;
699
- }>;
700
- readonly "wallet.importMnemonic": MethodSpec<{
701
- readonly mnemonic: Uint8Array;
702
- readonly factor?: Factor;
703
- }, CreatedResult>;
704
- readonly "wallet.exportMnemonic": MethodSpec<{
705
- readonly verify: Factor;
706
- readonly walletId: string;
707
- }, Uint8Array>;
708
- readonly "wallet.delete": MethodSpec<{
709
- readonly verify: Factor;
710
- readonly walletId: string;
711
- }, NullValue>;
712
- readonly "dataKeys.get": MethodSpec<{
713
- readonly purpose: string;
714
- }, Uint8Array>;
715
- };
716
- //#endregion
717
- //#region src/protocol/chains.d.ts
718
- type ChainTemplate = "evm.bip44" | "solana.bip44-change" | "btc.bip44" | "btc.bip49" | "btc.bip84" | "btc.bip86";
719
- type ChainAccountsParams = {
720
- readonly walletId: string;
721
- readonly groupIndex: number;
722
- readonly template: ChainTemplate;
723
- readonly network: string;
724
- };
725
- type ChainAccount = {
726
- readonly template: "evm.bip44";
727
- readonly network: string;
728
- readonly address: string;
729
- } | {
730
- readonly template: "solana.bip44-change";
731
- readonly network: string;
732
- readonly address: string;
733
- } | {
734
- readonly template: "btc.bip44" | "btc.bip49" | "btc.bip84" | "btc.bip86";
735
- readonly network: string;
736
- readonly xpub: string;
737
- /** Master-key fingerprint as 8 lowercase hex chars (PSBT bip32Derivation). */
738
- readonly fingerprint: string;
739
- /** Account derivation path, e.g. "m/84'/0'/0'". */
740
- readonly path: string;
741
- };
742
- type AccountRef = {
743
- readonly kind: "hd";
744
- readonly walletId: string;
745
- readonly groupIndex: number;
746
- readonly template: ChainTemplate;
747
- } | {
748
- readonly kind: "imported";
749
- readonly keyId: string;
750
- readonly family: "evm" | "solana" | "bitcoin";
751
- };
752
- type EvmAccessListEntryWire = {
753
- readonly address: string;
754
- readonly storageKeys: ReadonlyArray<string>;
755
- };
756
- type EvmTransactionBase = {
757
- readonly chainId: number;
758
- readonly nonce: number;
759
- readonly gas: string;
760
- readonly value: string;
761
- readonly data: string;
762
- readonly to?: string;
763
- };
764
- type EvmTransactionWire = (EvmTransactionBase & {
765
- readonly type: "legacy";
766
- readonly gasPrice: string;
767
- }) | (EvmTransactionBase & {
768
- readonly type: "eip2930";
769
- readonly gasPrice: string;
770
- readonly accessList: ReadonlyArray<EvmAccessListEntryWire>;
771
- }) | (EvmTransactionBase & {
772
- readonly type: "eip1559";
773
- readonly maxFeePerGas: string;
774
- readonly maxPriorityFeePerGas: string;
775
- readonly accessList: ReadonlyArray<EvmAccessListEntryWire>;
776
- });
777
- /** `chain.sign`'s request — the wire mirror of @qntx/wallet-chains `SignRequest`. */
778
- type ChainSignRequest = {
779
- readonly kind: "evm.transaction";
780
- readonly network: string;
781
- readonly account: AccountRef;
782
- readonly tx: EvmTransactionWire;
783
- } | {
784
- readonly kind: "evm.personal-message";
785
- readonly network: string;
786
- readonly account: AccountRef;
787
- readonly message: Uint8Array;
788
- } | {
789
- readonly kind: "evm.typed-data";
790
- readonly network: string;
791
- readonly account: AccountRef;
792
- readonly typedData: string;
793
- } | {
794
- readonly kind: "solana.transaction";
795
- readonly network: string;
796
- readonly account: AccountRef;
797
- readonly message: Uint8Array;
798
- readonly lookupTables?: ReadonlyArray<{
799
- readonly address: string;
800
- readonly addresses: ReadonlyArray<string>;
801
- }>;
802
- } | {
803
- readonly kind: "solana.message";
804
- readonly network: string;
805
- readonly account: AccountRef;
806
- readonly message: Uint8Array;
807
- readonly format: "raw";
808
- } | {
809
- readonly kind: "bitcoin.psbt";
810
- readonly network: string;
811
- readonly account: AccountRef;
812
- readonly psbt: Uint8Array;
813
- readonly sign: ReadonlyArray<number>;
814
- } | {
815
- readonly kind: "bitcoin.message";
816
- readonly network: string;
817
- readonly account: AccountRef;
818
- readonly address: string;
819
- readonly message: string;
820
- readonly format: "bip322-simple" | "legacy";
821
- readonly change: 0 | 1;
822
- readonly index: number;
823
- };
824
- type ChainSignResult = {
825
- readonly kind: "evm.transaction";
826
- readonly signedTransaction: Uint8Array;
827
- } | {
828
- readonly kind: "evm.personal-message" | "evm.typed-data";
829
- readonly signature: Uint8Array;
830
- } | {
831
- readonly kind: "solana.transaction" | "solana.message";
832
- readonly signature: Uint8Array;
833
- } | {
834
- readonly kind: "bitcoin.psbt";
835
- readonly signedPsbt: Uint8Array;
836
- } | {
837
- readonly kind: "bitcoin.message";
838
- readonly signature: string;
839
- };
840
- type ChainSignParams = {
841
- readonly request: ChainSignRequest;
842
- readonly verify: Factor;
843
- };
844
- declare const CHAINS_METHODS: {
845
- readonly "wallet.accounts": MethodSpec<ChainAccountsParams, ChainAccount>;
846
- readonly "chain.sign": MethodSpec<ChainSignParams, ChainSignResult>;
847
- };
848
- //#endregion
849
- export { PreparedTransfer as $, isProtocolValue as A, opt as At, backupEnvelopeFactor as B, PROTOCOL_VERSION as C, arr as Ct, Response as D, literal as Dt, Request as E, int as Et, BackupEnvelopeWire as F, FrostSignJob as G, backupHeader as H, BackupHeaderWallet as I, OperatorCommitment as J, HtlcTimeoutSignRequest as K, BackupHeaderWire as L, requestBytes as M, str as Mt, responseError as N, union as Nt, ResultOf as O, nullValue as Ot, BackupEnvelopeFactor as P, validate as Pt, PreparedLightningReceive as Q, BackupInfo as R, NullValue as S, Validator as St, ProtocolValue as T, bytes as Tt, backupInfo as U, backupEnvelopeText as V, FrostAggregateJob as W, PrepareTransferRequest as X, PrepareClaimRequest as Y, PreparedClaim as Z, KernelEvent as _, Rumor as _t, ChainSignResult as a, SparkApprovalSummary as at, MethodName as b, UnwrapResult as bt, BackupUnlockFactor as c, SparkLeafKey as ct, CreatedResult as d, StaticDepositClaimResult as dt, PreparedTransferLeaf as et, Factor as f, StaticDepositClaimStatement as ft, ErrorPayload as g, NostrImportInput as gt, walletErrorCode as h, NostrExportFormat as ht, ChainSignRequest as i, SparkAccountRef as it, kernelEvent as j, record as jt, UNATTRIBUTED_ID as k, obj as kt, CORE_METHODS as l, SparkNetwork as lt, RestoreWithPasskeyParams as m, NOSTR_METHODS as mt, ChainAccount as n, SigningCommitment as nt, ChainTemplate as o, SparkApproveIntent as ot, MethodSpec as p, KeyResult as pt, IdentityStatement as q, ChainAccountsParams as r, SigningTarget as rt, BackupFactor as s, SparkKey as st, CHAINS_METHODS as t, SPARK_METHODS as tt, CreateWithPasskeyParams as u, StaticDepositClaimRequest as ut, MAX_REQUEST_BYTES as v, SignedEvent as vt, ParamsOf as w, bool as wt, MethodTablesDisjoint as x, ValidationError as xt, METHODS as y, UnsignedEventInput as yt, backupEnvelope as z };
850
- //# sourceMappingURL=chains-D_jfwTPT.d.mts.map
489
+ export { Rumor as $, HtlcTimeoutSignRequest as A, SigningCommitment as B, backupEnvelope as C, backupInfo as D, backupHeader as E, PreparedClaim as F, SparkKey as G, SparkAccountRef as H, PreparedLightningReceive as I, StaticDepositClaimRequest as J, SparkLeafKey as K, PreparedTransfer as L, OperatorCommitment as M, PrepareClaimRequest as N, FrostAggregateJob as O, PrepareTransferRequest as P, NostrExportFormat as Q, PreparedTransferLeaf as R, BackupInfo as S, backupEnvelopeText as T, SparkApprovalSummary as U, SigningTarget as V, SparkApproveIntent as W, StaticDepositClaimStatement as X, StaticDepositClaimResult as Y, NOSTR_METHODS as Z, responseError as _, MethodName as a, BackupHeaderWallet as b, ParamsOf as c, Response as d, SignedEvent as et, ResultOf as f, requestBytes as g, kernelEvent as h, METHODS as i, IdentityStatement as j, FrostSignJob as k, ProtocolValue as l, isProtocolValue as m, KernelEvent as n, UnwrapResult as nt, MethodTablesDisjoint as o, UNATTRIBUTED_ID as p, SparkNetwork as q, MAX_REQUEST_BYTES as r, PROTOCOL_VERSION as s, ErrorPayload as t, UnsignedEventInput as tt, Request as u, BackupEnvelopeFactor as v, backupEnvelopeFactor as w, BackupHeaderWire as x, BackupEnvelopeWire as y, SPARK_METHODS as z };
490
+ //# sourceMappingURL=index-CIZzbqqv.d.mts.map
package/dist/index.d.mts CHANGED
@@ -1,18 +1,14 @@
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-BD9fuAUj.mjs";
2
- import { L as BackupHeaderWire } from "./chains-D_jfwTPT.mjs";
3
- //#region src/backup.d.ts
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-BgFsXgyI.mjs";
2
+ import { x as BackupHeaderWire } from "./index-CIZzbqqv.mjs";
4
3
  type BackupHeaderWallet = BackupHeaderWire["wallets"][number];
5
4
  type BackupHeader = {
6
5
  readonly version: 1;
7
6
  readonly createdAt: number;
8
7
  readonly wallets: ReadonlyArray<BackupHeaderWallet>;
9
- readonly importedNostrKeyCount: number;
10
- readonly importedChainKeyCount: number;
11
8
  /** The factor kinds the envelope can be unwrapped with. */
12
9
  readonly factorKinds: ReadonlyArray<"passkey" | "password">;
13
10
  };
14
11
  /** Strictly validates the envelope and returns the header fields — no secrets, no writes. */
15
12
  export declare function parseBackupHeader(envelope: string): BackupHeader;
16
- //#endregion
17
13
  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
14
  //# sourceMappingURL=index.d.mts.map
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
- import { D as validate } from "./core-Dmz5SbyJ.mjs";
2
- import { f as backupEnvelope, h as backupHeader } from "./protocol-DvzlUKB8.mjs";
1
+ import { D as validate } from "./core-Cq5h9X0X.mjs";
2
+ import { f as backupEnvelope, h as backupHeader } from "./protocol-DbpLncEB.mjs";
3
3
  import { WalletError } from "./types.mjs";
4
- //#region src/backup.ts
4
+ // src/backup.ts
5
5
  function integrity(msg) {
6
6
  throw new WalletError("integrity", `backup: ${msg}`);
7
7
  }
@@ -25,12 +25,9 @@ function parseBackupHeader(envelope) {
25
25
  version: 1,
26
26
  createdAt: parsed.createdAt,
27
27
  wallets: header.wallets,
28
- importedNostrKeyCount: header.importedNostrKeyCount,
29
- importedChainKeyCount: header.importedChainKeyCount,
30
28
  factorKinds
31
29
  };
32
30
  }
33
- //#endregion
34
31
  export { WalletError, parseBackupHeader };
35
32
 
36
33
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../src/backup.ts"],"sourcesContent":["// Read-only envelope inspection for the host: lists what a backup restores before the factor\n// ceremony runs. `header` is authenticated by the payload tag at restore time — this parser only\n// validates structure (bounded lengths, unknown fields rejected via the shared validators), so\n// nothing garbage reaches the kernel.\n\nimport type { BackupHeaderWire } from \"./protocol/index.ts\";\nimport { backupEnvelope, backupHeader, validate } from \"./protocol/index.ts\";\nimport { WalletError } from \"./types.ts\";\n\nexport type BackupHeaderWallet = BackupHeaderWire[\"wallets\"][number];\n\nexport type BackupHeader = {\n readonly version: 1;\n readonly createdAt: number;\n readonly wallets: ReadonlyArray<BackupHeaderWallet>;\n readonly importedNostrKeyCount: number;\n readonly importedChainKeyCount: number;\n /** The factor kinds the envelope can be unwrapped with. */\n readonly factorKinds: ReadonlyArray<\"passkey\" | \"password\">;\n};\n\nfunction integrity(msg: string): never {\n throw new WalletError(\"integrity\", `backup: ${msg}`);\n}\n\nfunction json(text: string, what: string): unknown {\n try {\n return JSON.parse(text);\n } catch {\n return integrity(`${what} is not JSON`);\n }\n}\n\n/** Strictly validates the envelope and returns the header fields — no secrets, no writes. */\nexport function parseBackupHeader(envelope: string): BackupHeader {\n if (envelope.length > 4_000_000) {\n integrity(\"envelope too large\");\n }\n const parsed = validate(backupEnvelope, json(envelope, \"envelope\"));\n if (parsed === undefined) {\n integrity(\"malformed envelope\");\n }\n const header = validate(backupHeader, json(parsed.header, \"header\"));\n if (header === undefined) {\n integrity(\"malformed header\");\n }\n const factorKinds = parsed.factors.map((f) => f.kind);\n if (factorKinds.filter((k) => k === \"password\").length > 1) {\n integrity(\"at most one password factor\");\n }\n return {\n version: 1,\n createdAt: parsed.createdAt,\n wallets: header.wallets,\n importedNostrKeyCount: header.importedNostrKeyCount,\n importedChainKeyCount: header.importedChainKeyCount,\n factorKinds,\n };\n}\n"],"mappings":";;;;AAqBA,SAAS,UAAU,KAAoB;CACrC,MAAM,IAAI,YAAY,aAAa,WAAW,KAAK;AACrD;AAEA,SAAS,KAAK,MAAc,MAAuB;CACjD,IAAI;EACF,OAAO,KAAK,MAAM,IAAI;CACxB,QAAQ;EACN,OAAO,UAAU,GAAG,KAAK,aAAa;CACxC;AACF;;AAGA,SAAgB,kBAAkB,UAAgC;CAChE,IAAI,SAAS,SAAS,KACpB,UAAU,oBAAoB;CAEhC,MAAM,SAAS,SAAS,gBAAgB,KAAK,UAAU,UAAU,CAAC;CAClE,IAAI,WAAW,KAAA,GACb,UAAU,oBAAoB;CAEhC,MAAM,SAAS,SAAS,cAAc,KAAK,OAAO,QAAQ,QAAQ,CAAC;CACnE,IAAI,WAAW,KAAA,GACb,UAAU,kBAAkB;CAE9B,MAAM,cAAc,OAAO,QAAQ,KAAK,MAAM,EAAE,IAAI;CACpD,IAAI,YAAY,QAAQ,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,GACvD,UAAU,6BAA6B;CAEzC,OAAO;EACL,SAAS;EACT,WAAW,OAAO;EAClB,SAAS,OAAO;EAChB,uBAAuB,OAAO;EAC9B,uBAAuB,OAAO;EAC9B;CACF;AACF"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/backup.ts"],"sourcesContent":["// Read-only envelope inspection for the host: lists what a backup restores before the factor\n// ceremony runs. `header` is authenticated by the payload tag at restore time — this parser only\n// validates structure (bounded lengths, unknown fields rejected via the shared validators), so\n// nothing garbage reaches the kernel.\n\nimport type { BackupHeaderWire } from \"./protocol/index.ts\";\nimport { backupEnvelope, backupHeader, validate } from \"./protocol/index.ts\";\nimport { WalletError } from \"./types.ts\";\n\nexport type BackupHeaderWallet = BackupHeaderWire[\"wallets\"][number];\n\nexport type BackupHeader = {\n readonly version: 1;\n readonly createdAt: number;\n readonly wallets: ReadonlyArray<BackupHeaderWallet>;\n /** The factor kinds the envelope can be unwrapped with. */\n readonly factorKinds: ReadonlyArray<\"passkey\" | \"password\">;\n};\n\nfunction integrity(msg: string): never {\n throw new WalletError(\"integrity\", `backup: ${msg}`);\n}\n\nfunction json(text: string, what: string): unknown {\n try {\n return JSON.parse(text);\n } catch {\n return integrity(`${what} is not JSON`);\n }\n}\n\n/** Strictly validates the envelope and returns the header fields — no secrets, no writes. */\nexport function parseBackupHeader(envelope: string): BackupHeader {\n if (envelope.length > 4_000_000) {\n integrity(\"envelope too large\");\n }\n const parsed = validate(backupEnvelope, json(envelope, \"envelope\"));\n if (parsed === undefined) {\n integrity(\"malformed envelope\");\n }\n const header = validate(backupHeader, json(parsed.header, \"header\"));\n if (header === undefined) {\n integrity(\"malformed header\");\n }\n const factorKinds = parsed.factors.map((f) => f.kind);\n if (factorKinds.filter((k) => k === \"password\").length > 1) {\n integrity(\"at most one password factor\");\n }\n return {\n version: 1,\n createdAt: parsed.createdAt,\n wallets: header.wallets,\n factorKinds,\n };\n}\n"],"mappings":";;;;AAmBA,SAAS,UAAU,KAAoB;CACrC,MAAM,IAAI,YAAY,aAAa,WAAW,KAAK;AACrD;AAEA,SAAS,KAAK,MAAc,MAAuB;CACjD,IAAI;EACF,OAAO,KAAK,MAAM,IAAI;CACxB,QAAQ;EACN,OAAO,UAAU,GAAG,KAAK,aAAa;CACxC;AACF;;AAGA,SAAgB,kBAAkB,UAAgC;CAChE,IAAI,SAAS,SAAS,KACpB,UAAU,oBAAoB;CAEhC,MAAM,SAAS,SAAS,gBAAgB,KAAK,UAAU,UAAU,CAAC;CAClE,IAAI,WAAW,KAAA,GACb,UAAU,oBAAoB;CAEhC,MAAM,SAAS,SAAS,cAAc,KAAK,OAAO,QAAQ,QAAQ,CAAC;CACnE,IAAI,WAAW,KAAA,GACb,UAAU,kBAAkB;CAE9B,MAAM,cAAc,OAAO,QAAQ,KAAK,MAAM,EAAE,IAAI;CACpD,IAAI,YAAY,QAAQ,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,GACvD,UAAU,6BAA6B;CAEzC,OAAO;EACL,SAAS;EACT,WAAW,OAAO;EAClB,SAAS,OAAO;EAChB;CACF;AACF"}
@@ -1,5 +1,5 @@
1
1
  import { WalletError } from "./types.mjs";
2
- //#region src/internal.ts
2
+ // src/internal.ts
3
3
  /**
4
4
  * Channel internals shared between the core Wallet and the protocol subpath modules
5
5
  * (@qntx/wallet/nostr, later spark/chains). This file is NOT a package subpath — modules look a
@@ -19,7 +19,6 @@ function internalsOf(wallet) {
19
19
  if (found === void 0) throw new WalletError("invalid-input", "not a Wallet from @qntx/wallet");
20
20
  return found;
21
21
  }
22
- //#endregion
23
22
  export { registerInternals as n, internalsOf as t };
24
23
 
25
- //# sourceMappingURL=internal-LBHal13j.mjs.map
24
+ //# sourceMappingURL=internal-CAKfHjIg.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"internal-LBHal13j.mjs","names":[],"sources":["../src/internal.ts"],"sourcesContent":["import type { Factor, MethodName, ParamsOf, ResultOf } from \"./protocol/index.ts\";\n/**\n * Channel internals shared between the core Wallet and the protocol subpath modules\n * (@qntx/wallet/nostr, later spark/chains). This file is NOT a package subpath — modules look a\n * Wallet up in the WeakMap, so a foreign object has no channel to reach.\n */\nimport { WalletError } from \"./types.ts\";\nimport type { InitialFactor, UnlockFactor, Wallet, WalletSnapshot } from \"./types.ts\";\n\nexport type WalletInternals = {\n /** One validated request on the kernel channel (awaits the live port's first status). */\n readonly call: <M extends MethodName>(\n method: M,\n params: ParamsOf<M>,\n transfer?: ArrayBuffer[],\n ) => Promise<ResultOf<M>>;\n /** The live kernel port's first-status gate — re-read per call (a respawn replaces it). */\n readonly ready: () => Promise<void>;\n readonly snapshot: () => WalletSnapshot;\n /** Marks a user verification in flight on the snapshot (`verifying`). */\n readonly withVerifying: <T>(fn: () => Promise<T>) => Promise<T>;\n /** Public UnlockFactor → wire factor material (the passkey ceremony runs here). */\n readonly resolveFactor: (factor: UnlockFactor, transfer: ArrayBuffer[]) => Promise<Factor>;\n /** The create/import factor gate: required on an uninitialized vault, forbidden after. */\n readonly createFactorParam: (\n factor: InitialFactor | undefined,\n transfer: ArrayBuffer[],\n ) => Promise<Factor | undefined>;\n /** Adopts the session a create/import result opened onto the channel. */\n readonly sessionOf: (result: { readonly session: string }) => void;\n};\n\nconst internals = new WeakMap<Wallet, WalletInternals>();\n\nexport function registerInternals(wallet: Wallet, value: WalletInternals): void {\n internals.set(wallet, value);\n}\n\n/**\n * The internals behind a Wallet from this package — or `invalid-input` for anything else. A foreign\n * object can imitate the Wallet shape but can never hold the channel: modules that look it up here\n * get a closed failure, not a crafted kernel.\n */\nexport function internalsOf(wallet: Wallet): WalletInternals {\n const found = internals.get(wallet);\n if (found === undefined) {\n throw new WalletError(\"invalid-input\", \"not a Wallet from @qntx/wallet\");\n }\n return found;\n}\n"],"mappings":";;;;;;;AAgCA,MAAM,4BAAY,IAAI,QAAiC;AAEvD,SAAgB,kBAAkB,QAAgB,OAA8B;CAC9E,UAAU,IAAI,QAAQ,KAAK;AAC7B;;;;;;AAOA,SAAgB,YAAY,QAAiC;CAC3D,MAAM,QAAQ,UAAU,IAAI,MAAM;CAClC,IAAI,UAAU,KAAA,GACZ,MAAM,IAAI,YAAY,iBAAiB,gCAAgC;CAEzE,OAAO;AACT"}
1
+ {"version":3,"file":"internal-CAKfHjIg.mjs","names":[],"sources":["../src/internal.ts"],"sourcesContent":["import type { Factor, MethodName, ParamsOf, ResultOf } from \"./protocol/index.ts\";\n/**\n * Channel internals shared between the core Wallet and the protocol subpath modules\n * (@qntx/wallet/nostr, later spark/chains). This file is NOT a package subpath — modules look a\n * Wallet up in the WeakMap, so a foreign object has no channel to reach.\n */\nimport { WalletError } from \"./types.ts\";\nimport type { InitialFactor, UnlockFactor, Wallet, WalletSnapshot } from \"./types.ts\";\n\nexport type WalletInternals = {\n /** One validated request on the kernel channel (awaits the live port's first status). */\n readonly call: <M extends MethodName>(\n method: M,\n params: ParamsOf<M>,\n transfer?: ArrayBuffer[],\n ) => Promise<ResultOf<M>>;\n /** The live kernel port's first-status gate — re-read per call (a respawn replaces it). */\n readonly ready: () => Promise<void>;\n readonly snapshot: () => WalletSnapshot;\n /** Marks a user verification in flight on the snapshot (`verifying`). */\n readonly withVerifying: <T>(fn: () => Promise<T>) => Promise<T>;\n /** Public UnlockFactor → wire factor material (the passkey ceremony runs here). */\n readonly resolveFactor: (factor: UnlockFactor, transfer: ArrayBuffer[]) => Promise<Factor>;\n /** The create/import factor gate: required on an uninitialized vault, forbidden after. */\n readonly createFactorParam: (\n factor: InitialFactor | undefined,\n transfer: ArrayBuffer[],\n ) => Promise<Factor | undefined>;\n /** Adopts the session a create/import result opened onto the channel. */\n readonly sessionOf: (result: { readonly session: string }) => void;\n};\n\nconst internals = new WeakMap<Wallet, WalletInternals>();\n\nexport function registerInternals(wallet: Wallet, value: WalletInternals): void {\n internals.set(wallet, value);\n}\n\n/**\n * The internals behind a Wallet from this package — or `invalid-input` for anything else. A foreign\n * object can imitate the Wallet shape but can never hold the channel: modules that look it up here\n * get a closed failure, not a crafted kernel.\n */\nexport function internalsOf(wallet: Wallet): WalletInternals {\n const found = internals.get(wallet);\n if (found === undefined) {\n throw new WalletError(\"invalid-input\", \"not a Wallet from @qntx/wallet\");\n }\n return found;\n}\n"],"mappings":";;;;;;;AAgCA,MAAM,4BAAY,IAAI,QAAiC;AAEvD,SAAgB,kBAAkB,QAAgB,OAA8B;CAC9E,UAAU,IAAI,QAAQ,KAAK;AAC7B;;;;;;AAOA,SAAgB,YAAY,QAAiC;CAC3D,MAAM,QAAQ,UAAU,IAAI,MAAM;CAClC,IAAI,UAAU,KAAA,GACZ,MAAM,IAAI,YAAY,iBAAiB,gCAAgC;CAEzE,OAAO;AACT"}