@qntx/wallet-engine 0.8.1 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,8 +1,9 @@
1
- import { $ as sparkStore, A as RiskFinding, B as ParseOptions, C as SparkDepositInput, Ct as Controller, D as BrowserOrigin, E as SignLogOutcome, F as PreparedZap, G as PreparedSparkAction, H as PaymentParse, I as ZapRecipient, J as SparkAccountState, K as SparkDisplay, L as prepareZap, M as SignatureResult, N as PrepareZapContext, O as RequestMethod, P as PrepareZapParams, Q as SparkControllerState, R as PayParams, S as RequestStage, St as createEventBus, T as SignLogEntry, U as PaymentRequest, V as PaymentOption, W as parsePayment, X as SparkController, Y as SparkClientFactory, Z as SparkControllerOptions, _ as PendingRequest, _t as PendingConnection, at as AddressBookEntry, b as RequestControllerState, bt as EngineLogger, ct as NetworkController, dt as ConnectionController, et as PaymentNote, f as Eip1193Event, ft as ConnectionOrigin, g as PayInput, h as EvmSignInput, ht as ConnectionState, it as AddressBookState, j as TransactionController, k as RequestOrigin, l as SolanaWalletHandler, lt as Esplora, m as Eip1193Request, mt as ConnectionSession, n as WeblnHandler, nt as RequestCheckCode, ot as AddressBookRecord, p as Eip1193Handler, pt as ConnectionScope, q as SparkResult, rt as AddressBookController, st as AddressFamily, t as ProviderError, tt as SparkActivity, u as Nip07Handler, ut as AccountGroup$1, v as REQUEST_TTL_MS, vt as EngineCollection, w as SparkExitInput, wt as ControllerOptions, x as RequestInput, xt as EventBus, y as RequestController, yt as EngineStore, z as WithdrawLnurlParams } from "./errors-CW_XXGL9.mjs";
1
+ import { $ as PrepareZapContext, A as PayInput, At as EngineCollection, B as SignLogEntry, C as ConnectionOrigin, Ct as NetworkController, Dt as AddressBookEntry, E as ConnectionState, Et as AddressBookState, F as RequestControllerState, Ft as createEventBus, G as RiskFinding, H as BrowserOrigin, I as RequestInput, It as Controller, J as PHISHING_REFRESH_MS, K as TransactionController, L as RequestStage, Lt as ControllerOptions, M as REQUEST_TTL_MS, Mt as PublicStore, N as RESIMULATE_AFTER_MS, Nt as EngineLogger, O as PendingConnection, Ot as AddressBookRecord, P as RequestController, Pt as EventBus, Q as PhishingStatus, R as SparkDepositInput, S as ConnectionController, St as RequestCheckCode, T as ConnectionSession, Tt as AddressBookController, U as RequestMethod, V as SignLogOutcome, W as RequestOrigin, X as PhishingControllerOptions, Y as PhishingController, Z as PhishingState, _t as SparkControllerOptions, at as WithdrawLnurlParams, b as BitcoinWalletHandler, bt as PaymentNote, ct as PaymentParse, dt as PreparedSparkAction, et as PrepareZapParams, f as Eip1193Event, ft as SparkDisplay, gt as SparkController, ht as SparkClientFactory, it as PayParams, j as PendingRequest, jt as EngineStore, k as EvmSignInput, kt as AddressFamily, l as SolanaWalletHandler, lt as PaymentRequest, m as Eip1193Request, mt as SparkAccountState, n as WeblnHandler, nt as ZapRecipient, ot as ParseOptions, p as Eip1193Handler, pt as SparkResult, q as SignatureResult, rt as prepareZap, st as PaymentOption, t as ProviderError, tt as PreparedZap, u as Nip07Handler, ut as parsePayment, vt as SparkControllerState, w as ConnectionScope, wt as Esplora, x as AccountGroup$1, xt as SparkActivity, yt as sparkStore, z as SparkExitInput } from "./errors-Bglz0VYn.mjs";
2
2
  import { BackupHeader, BackupInfo, InitialFactor, UnlockFactor, Wallet, WalletInfo } from "@qntx/wallet";
3
3
  import { LightningInvoice, SparkExitChain, SparkNetwork } from "@qntx/spark";
4
4
  import { Event, Filter } from "@qntx/nostr";
5
5
  import { WalletSyncSigner } from "@qntx/wallet/nostr";
6
+ import { getEnsAddress } from "viem/ens";
6
7
  type EngineErrorCode = "closed" | "integrity" | "invalid-input";
7
8
  /** Typed engine errors: store codes are `closed` and `integrity` (decrypt or bind failure). */
8
9
  export declare class EngineStoreError extends Error {
@@ -13,6 +14,10 @@ export declare class EngineStoreError extends Error {
13
14
  export declare function createMemoryEngineStore(backing?: {
14
15
  readonly collections?: Map<string, Map<string, Uint8Array>>;
15
16
  }): EngineStore;
17
+ /** In-memory PublicStore: the Node/test implementation — same contract, no durability. */
18
+ export declare function createMemoryPublicStore(backing?: {
19
+ readonly values?: Map<string, Uint8Array>;
20
+ }): PublicStore;
16
21
  type AddressBookErrorCategory = "invalid-input" | "duplicate" | "not-found" | "locked" | "limit";
17
22
  export declare class AddressBookError extends Error {
18
23
  readonly category: AddressBookErrorCategory;
@@ -53,6 +58,8 @@ type AccountGroup = {
53
58
  readonly hidden: boolean;
54
59
  /** A social identity (64 lowercase hex) bound to this group; one identity binds one group. */
55
60
  readonly boundPubkey?: string;
61
+ /** Device-local opt-in to signing messages that cannot be shown as text; absent means off. */
62
+ readonly blindSigning?: true;
56
63
  /** Last local modification time (ms); reconcile-created entries start at 0. */
57
64
  readonly updatedAt: number;
58
65
  };
@@ -88,6 +95,7 @@ type DiscoveryNetworks = {
88
95
  };
89
96
  type AccountTreeControllerOptions = {
90
97
  readonly wallet: Wallet;
98
+ readonly setTimer: (ms: number, fn: () => void) => () => void;
91
99
  readonly spark: SparkController;
92
100
  readonly sparkNetwork: SparkNetwork;
93
101
  readonly networks?: DiscoveryNetworks;
@@ -109,7 +117,7 @@ export declare class AccountTreeController extends Controller<AccountTreeState>
109
117
  private readonly options;
110
118
  private col;
111
119
  private sparkUnsubscribe;
112
- private totalsTimer;
120
+ private cancelTotals;
113
121
  private persistChain;
114
122
  constructor(options: AccountTreeControllerOptions);
115
123
  setStore(store: EngineStore | undefined): void;
@@ -125,6 +133,13 @@ export declare class AccountTreeController extends Controller<AccountTreeState>
125
133
  renameWallet(walletId: string, name: string): void;
126
134
  renameGroup(walletId: string, index: number, name: string): void;
127
135
  setHidden(walletId: string, index: number, hidden: boolean): void;
136
+ /**
137
+ * Device-local opt-in to blind signing: no factor, the setting lives in the main runtime —
138
+ * per-request verification and the kernel's blind prompt are the real protection.
139
+ */
140
+ setBlindSigning(walletId: string, index: number, enabled: boolean): void;
141
+ /** Whether the group opted in to signing messages that cannot be shown as text. */
142
+ blindSigning(walletId: string, index: number): boolean;
128
143
  select(walletId: string, index: number): void;
129
144
  /**
130
145
  * Binds a social identity to one group. The identity is unique across the whole tree — every
@@ -223,6 +238,13 @@ declare class AssetsController extends Controller<AssetsControllerState> {
223
238
  private balanceOfBatch;
224
239
  private balanceOf;
225
240
  private callToken;
241
+ /** Whether `address` is in the built-in token table of `network` or among the custom tokens. */
242
+ isTracked(network: string, address: string): boolean;
243
+ /** The token's own `symbol` and `decimals` (EVM only); throws when either read fails. */
244
+ tokenMetadata(network: string, address: string): Promise<{
245
+ readonly symbol: string;
246
+ readonly decimals: number;
247
+ }>;
226
248
  /** Reads symbol/decimals on-chain, marks unverified, persists; throws when the calls fail. */
227
249
  addToken(network: string, address: string): Promise<void>;
228
250
  private persistToken;
@@ -300,11 +322,22 @@ export declare class BackupController extends Controller<BackupControllerState>
300
322
  readonly name: string;
301
323
  readonly header: BackupHeader;
302
324
  }>>;
325
+ /**
326
+ * Merges a cloud backup into the vault. Wallets with a BIP-39 passphrase restore only when
327
+ * `passphrases` carries theirs; the rest come back in `passphraseRequired`.
328
+ */
303
329
  restore(options: {
304
330
  readonly name: string;
305
331
  readonly backupFactor: UnlockFactor;
332
+ readonly passphrases?: ReadonlyArray<{
333
+ readonly walletId: string;
334
+ readonly passphrase: string;
335
+ }>;
306
336
  readonly factor?: InitialFactor;
307
- }): Promise<ReadonlyArray<WalletInfo>>;
337
+ }): Promise<{
338
+ readonly wallets: ReadonlyArray<WalletInfo>;
339
+ readonly passphraseRequired: ReadonlyArray<string>;
340
+ }>;
308
341
  private reconcileOrThrow;
309
342
  private readRecord;
310
343
  private writeRecord;
@@ -364,6 +397,7 @@ type MetaSyncControllerOptions = {
364
397
  readonly metaSync: MetaSyncConfig | undefined;
365
398
  readonly logger: EngineLogger;
366
399
  readonly now: () => number;
400
+ readonly setTimer: (ms: number, fn: () => void) => () => void;
367
401
  readonly verifyEvent: (event: Event) => boolean;
368
402
  };
369
403
  /**
@@ -405,6 +439,11 @@ export declare class MetaSyncController extends Controller<MetaSyncState> {
405
439
  private onTreeChange;
406
440
  private publishNow;
407
441
  }
442
+ type EnsResolution = {
443
+ readonly name: string;
444
+ readonly address: string;
445
+ readonly checks: ReadonlyArray<RequestCheckCode>;
446
+ };
408
447
  type EngineOptions = {
409
448
  readonly wallet: Wallet;
410
449
  /**
@@ -424,6 +463,11 @@ type EngineOptions = {
424
463
  readonly lightningMaxFee: (amountSats: number) => number;
425
464
  readonly logger: EngineLogger;
426
465
  readonly openStore: () => Promise<EngineStore>;
466
+ /**
467
+ * Non-secret device data (the phishing list, the origins the user trusts), available while the
468
+ * wallet is locked: a page can be opened before the first unlock.
469
+ */
470
+ readonly publicStore: PublicStore;
427
471
  /** Cloud file transport for the backup controller; absent → `unavailable`. */
428
472
  readonly cloud?: CloudStore;
429
473
  /**
@@ -439,9 +483,9 @@ type EngineOptions = {
439
483
  readonly url: string;
440
484
  readonly installId: string;
441
485
  };
442
- /** Injected timer for transaction polling; defaults to setTimeout. */
443
486
  /** Development builds: also accept `http://localhost` as a dApp origin. */
444
487
  readonly allowLocalhostOrigins?: boolean;
488
+ /** Injected timer for polling and refresh loops; defaults to setTimeout. */
445
489
  readonly setTimer?: (ms: number, fn: () => void) => () => void;
446
490
  /** Kind-30078 wallet-metadata sync; absent → no wallet metadata is synced. */
447
491
  readonly metaSync?: MetaSyncConfig;
@@ -459,6 +503,9 @@ type WalletEngine = {
459
503
  readonly nip07: Nip07Handler;
460
504
  readonly webln: WeblnHandler;
461
505
  readonly solanaWallet: SolanaWalletHandler;
506
+ readonly bitcoinWallet: BitcoinWalletHandler;
507
+ /** The phishing list: lifecycle is independent of the lock state. */
508
+ readonly phishing: PhishingController;
462
509
  /** Read and receive surface; every payment goes through `requests`. */
463
510
  readonly spark: Omit<SparkController, "send" | "payInvoice" | "paySparkInvoice" | "withdraw">;
464
511
  readonly accounts: AccountTreeController;
@@ -467,6 +514,10 @@ type WalletEngine = {
467
514
  readonly zaps: {
468
515
  readonly prepare: (params: PrepareZapParams) => Promise<PreparedZap>;
469
516
  };
517
+ readonly names: {
518
+ /** Forward-resolves an ENS name for a send on `network`; throws when it cannot resolve. */
519
+ readonly resolve: (name: string, network: string) => Promise<EnsResolution>;
520
+ };
470
521
  readonly payments: {
471
522
  readonly parse: (input: string, network: SparkNetwork) => PaymentParse;
472
523
  readonly resolve: (input: string, network: SparkNetwork) => Promise<PaymentParse>;
@@ -476,6 +527,7 @@ type WalletEngine = {
476
527
  readonly invoice: LightningInvoice;
477
528
  }>;
478
529
  };
530
+ /** Stops listening to the wallet and stops the phishing list refresh. */
479
531
  readonly unsubscribe: () => void;
480
532
  };
481
533
  export declare function createWalletEngine(options: EngineOptions): WalletEngine;
@@ -510,5 +562,5 @@ type ResolveOptions = ParseOptions & {
510
562
  export declare function resolvePayment(input: string, options: ResolveOptions): Promise<PaymentParse>;
511
563
  export declare function encodeExitChain(chain: SparkExitChain): Uint8Array;
512
564
  export declare function decodeExitChain(bytes: Uint8Array): SparkExitChain;
513
- export { type AccountGroup, type AccountTreeState, AddressBookController, type AddressBookEntry, type AddressBookErrorCategory, type AddressBookState, type AddressFamily, type BackupControllerState, type BackupErrorCategory, type BrowserOrigin, type CloudStore, type AccountGroup$1 as ConnectionAccountGroup, ConnectionController, type ConnectionOrigin, type ConnectionScope, type ConnectionSession, type ConnectionState, Controller, type ControllerOptions, type Eip1193Event, Eip1193Handler, type Eip1193Request, type EngineCollection, type EngineErrorCode, type EngineLogger, type EngineOptions, type EngineStore, type EventBus, type EvmSignInput, type MetaDoc, type MetaDocGroup, type MetaDocTree, type MetaDocWallet, type MetaSyncConfig, type MetaSyncRelayPort, type MetaSyncState, type MetaSyncWalletStatus, type PayInput, type PayParams, type PaymentNote, type PaymentOption, type PaymentParse, type PaymentRequest, type PendingConnection, type PendingRequest, type PrepareZapContext, type PrepareZapParams, type PreparedSparkAction, type PreparedZap, ProviderError, REQUEST_TTL_MS, type RequestCheckCode, RequestController, type RequestControllerState, type RequestInput, type RequestMethod, type RequestOrigin, type RequestStage, type RiskFinding, type SignLogEntry, type SignLogOutcome, type SignatureResult, type SparkAccountState, type SparkActivity, type SparkClientFactory, SparkController, type SparkControllerOptions, type SparkControllerState, type SparkDepositInput, type SparkDisplay, type SparkErrorCategory, type SparkExitInput, type SparkResult, type WalletEngine, type WithdrawLnurlParams, type ZapRecipient, createEventBus, parsePayment, prepareZap, sparkStore };
565
+ export { type AccountGroup, type AccountTreeState, AddressBookController, type AddressBookEntry, type AddressBookErrorCategory, type AddressBookState, type AddressFamily, type BackupControllerState, type BackupErrorCategory, type BrowserOrigin, type CloudStore, type AccountGroup$1 as ConnectionAccountGroup, ConnectionController, type ConnectionOrigin, type ConnectionScope, type ConnectionSession, type ConnectionState, Controller, type ControllerOptions, type Eip1193Event, Eip1193Handler, type Eip1193Request, type EngineCollection, type EngineErrorCode, type EngineLogger, type EngineOptions, type EngineStore, type EventBus, type EvmSignInput, type MetaDoc, type MetaDocGroup, type MetaDocTree, type MetaDocWallet, type MetaSyncConfig, type MetaSyncRelayPort, type MetaSyncState, type MetaSyncWalletStatus, PHISHING_REFRESH_MS, type PayInput, type PayParams, type PaymentNote, type PaymentOption, type PaymentParse, type PaymentRequest, type PendingConnection, type PendingRequest, PhishingController, type PhishingControllerOptions, type PhishingState, type PhishingStatus, type PrepareZapContext, type PrepareZapParams, type PreparedSparkAction, type PreparedZap, ProviderError, type PublicStore, REQUEST_TTL_MS, RESIMULATE_AFTER_MS, type RequestCheckCode, RequestController, type RequestControllerState, type RequestInput, type RequestMethod, type RequestOrigin, type RequestStage, type RiskFinding, type SignLogEntry, type SignLogOutcome, type SignatureResult, type SparkAccountState, type SparkActivity, type SparkClientFactory, SparkController, type SparkControllerOptions, type SparkControllerState, type SparkDepositInput, type SparkDisplay, type SparkErrorCategory, type SparkExitInput, type SparkResult, type WalletEngine, type WithdrawLnurlParams, type ZapRecipient, createEventBus, parsePayment, prepareZap, sparkStore };
514
566
  //# sourceMappingURL=index.d.mts.map