@qntx/wallet 0.12.0 → 0.13.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/{chains-BSP0x9RI.d.mts → chains-B-FmFmuV.d.mts} +34 -2
- package/dist/chains.d.mts +2 -2
- package/dist/chains.mjs +6 -1
- package/dist/chains.mjs.map +1 -1
- package/dist/{channel-BQg--l_3.mjs → channel-BLwce5hh.mjs} +3 -3
- package/dist/{channel-BQg--l_3.mjs.map → channel-BLwce5hh.mjs.map} +1 -1
- package/dist/{core-DDfzuSIa.mjs → core-DaRwkTaV.mjs} +43 -2
- package/dist/core-DaRwkTaV.mjs.map +1 -0
- package/dist/host.d.mts +2 -2
- package/dist/host.mjs +53 -2
- package/dist/host.mjs.map +1 -1
- package/dist/{index-DDyJ9KqA.d.mts → index-CEhrd0Pl.d.mts} +9 -3
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +2 -2
- package/dist/nostr.d.mts +1 -1
- package/dist/nostr.mjs +1 -1
- package/dist/{protocol-C8x0H3Rr.mjs → protocol-fXHXJguP.mjs} +23 -8
- package/dist/protocol-fXHXJguP.mjs.map +1 -0
- package/dist/protocol.d.mts +3 -3
- package/dist/protocol.mjs +2 -2
- package/dist/spark.d.mts +2 -2
- package/dist/{types-Dub5eUl3.d.mts → types-cAQAJBLi.d.mts} +23 -2
- package/dist/types.d.mts +2 -2
- package/dist/types.mjs.map +1 -1
- package/package.json +3 -3
- package/dist/core-DDfzuSIa.mjs.map +0 -1
- package/dist/protocol-C8x0H3Rr.mjs.map +0 -1
package/dist/host.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host.mjs","names":[],"sources":["../src/wallet.ts"],"sourcesContent":["/**\n * The host-facing `Wallet` (design/entry.mdx \"API\"): snapshot state, the core API groups, and the\n * glue between the kernel `Channel` and factor resolution. `connectKernel` is exported under the\n * `./host` subpath — reserved for host packages; applications must not use it. Protocol modules\n * (@qntx/wallet/nostr and future siblings) reach this wallet's channel through the registered\n * internals in internal.ts — never through the public type.\n */\n\nimport { Channel } from \"./channel.ts\";\nimport type { MainPort, SetTimer } from \"./channel.ts\";\nimport {\n PASSKEY_PURPOSE_WALLET,\n passkeyName,\n requireCeremony,\n resolveFactor,\n resolveInitialFactor,\n vaultSaltBytes,\n walletSaltBytes,\n wireBytes,\n wirePassphrase,\n wireSecretText,\n resolveBackupFactor,\n resolveBackupUnlockFactor,\n defaultUnlockFactor,\n} from \"./factors.ts\";\nimport type { FactorMode, FactorSource, PasskeyCeremony, PrfResult } from \"./factors.ts\";\nimport { registerInternals } from \"./internal.ts\";\nimport type { Factor, SignedEvent } from \"./protocol/index.ts\";\nimport { SingleUseSecret } from \"./secret.ts\";\nimport { WalletError } from \"./types.ts\";\nimport type {\n BackupApi,\n DataKeyApi,\n ExportedMnemonic,\n FactorInfo,\n InitialFactor,\n LockReason,\n MnemonicDraft,\n PasskeyConfig,\n StatusPayload,\n UnlockFactor,\n VaultApi,\n Wallet,\n WalletInfo,\n WalletSnapshot,\n WalletsApi,\n} from \"./types.ts\";\n\nexport type ConnectOptions = {\n readonly spawn: () => MainPort;\n /** Fixed by the host entry: `hardware` on React Native, `software` on web and node. */\n readonly factors: FactorMode;\n readonly passkey: PasskeyConfig;\n readonly verifyEvent: (event: SignedEvent) => boolean;\n readonly ceremony: PasskeyCeremony | undefined;\n /** Timer source injected by the host package (globalThis timers on web/node). */\n readonly setTimer: SetTimer;\n /**\n * User-presence source: subscribes to activity signals and returns an unsubscribe the wallet\n * owns. Absent means the host has no presence signals (the kernel policy decides what counts).\n */\n readonly presence?: (onActivity: () => void) => () => void;\n /** Runs once inside `destroy()` — host-side cleanup (page listeners, timers). */\n readonly onDestroy?: () => void;\n};\n\n/** One `session.touch` at most per interval — the idle deadline slips at most this much early. */\nexport const PRESENCE_TOUCH_INTERVAL_MS = 30_000;\n\n/** Structural equality over plain snapshot data (validated protocol payloads only). */\nfunction deepEqual(a: unknown, b: unknown): boolean {\n if (a === b) {\n return true;\n }\n if (typeof a !== \"object\" || a === null || typeof b !== \"object\" || b === null) {\n return false;\n }\n if (Array.isArray(a) || Array.isArray(b)) {\n return (\n Array.isArray(a) &&\n Array.isArray(b) &&\n a.length === b.length &&\n a.every((item, index) => deepEqual(item, b[index]))\n );\n }\n const aKeys = Object.keys(a);\n const bKeys = Object.keys(b);\n return (\n aKeys.length === bKeys.length &&\n aKeys.every(\n (key) =>\n key in b &&\n deepEqual(\n (a as Record<string, unknown>)[key], // oxlint-disable-line typescript/no-unsafe-type-assertion -- plain-object records\n (b as Record<string, unknown>)[key], // oxlint-disable-line typescript/no-unsafe-type-assertion -- plain-object records\n ),\n )\n );\n}\n\nexport class KernelWallet implements Wallet {\n private readonly channel: Channel;\n private readonly factorMode: FactorMode;\n private readonly passkeyCfg: PasskeyConfig;\n private readonly ceremony: PasskeyCeremony | undefined;\n private readonly setTimer: SetTimer;\n private readonly onDestroy: (() => void) | undefined;\n private readonly unsubscribePresence: (() => void) | undefined;\n private presenceCooling = false;\n private cancelCooldown: (() => void) | undefined;\n private destroyed = false;\n\n private status: StatusPayload | undefined;\n private lockReason: LockReason | undefined;\n private verifying = 0;\n private snapshotValue: WalletSnapshot;\n private readonly listeners = new Set<() => void>();\n\n private constructor(options: ConnectOptions) {\n this.factorMode = options.factors;\n this.passkeyCfg = options.passkey;\n this.ceremony = options.ceremony;\n this.setTimer = options.setTimer;\n this.onDestroy = options.onDestroy;\n this.snapshotValue = {\n vault: \"uninitialized\",\n lockReason: undefined,\n verifying: false,\n factors: [],\n wallets: [],\n nostr: { keys: [] },\n backup: null,\n };\n this.channel = new Channel(\n options.spawn,\n {\n onStatus: (status) => {\n this.onStatus(status);\n },\n onLocked: (reason) => {\n this.lockReason = reason;\n this.markLocked();\n },\n onCrashed: () => {\n this.lockReason = \"crashed\";\n this.markLocked();\n },\n },\n options.setTimer,\n );\n // The wallet owns the subscription it creates: destroy() unsubscribes — no second owner.\n this.unsubscribePresence = options.presence?.(() => {\n this.onPresence();\n });\n registerInternals(this, {\n call: async (method, params, transfer) => this.channel.call(method, params, transfer),\n ready: async () => this.channel.ready,\n snapshot: () => this.snapshotValue,\n verifyEvent: options.verifyEvent,\n withVerifying: async (fn) => this.withVerifying(fn),\n resolveFactor: async (factor, transfer) => resolveFactor(this.factorSource, factor, transfer),\n createFactorParam: async (factor, transfer) => this.createFactorParam(factor, transfer),\n sessionOf: (result) => {\n this.sessionOf(result);\n },\n });\n }\n\n static async connect(options: ConnectOptions): Promise<KernelWallet> {\n const wallet = new KernelWallet(options);\n await wallet.channel.start();\n return wallet;\n }\n\n /** Runs a host-ceremony passkey call and adopts the returned session and wallet info. */\n private async hostPasskeyWallet(\n method: \"wallet.createWithPasskey\" | \"wallet.restoreWithPasskey\",\n result: PrfResult,\n factor: Factor | undefined,\n transfer: ArrayBuffer[],\n ): Promise<WalletInfo> {\n const created = await this.channel.call(\n method,\n {\n ceremony: \"host\",\n credentialId: wireBytes(result.credentialId, transfer),\n prfWallet: wireBytes(result.first, transfer, true),\n synced: result.synced,\n ...(factor === undefined ? {} : { factor }),\n },\n transfer,\n );\n this.sessionOf(created);\n return created.wallet;\n }\n\n /**\n * Presence refresh, throttled to one touch per interval: once a touch fires, signals are ignored\n * until the cooldown elapses — no clock reads, just the injected timer. Touches only go out while\n * a session is held; failures are silent (a lock or respawn needs no handling).\n */\n private onPresence(): void {\n if (this.presenceCooling || this.destroyed || this.channel.session === undefined) {\n return;\n }\n this.presenceCooling = true;\n this.cancelCooldown = this.setTimer(PRESENCE_TOUCH_INTERVAL_MS, () => {\n this.presenceCooling = false;\n this.cancelCooldown = undefined;\n });\n void this.touchSession();\n }\n\n private async touchSession(): Promise<void> {\n try {\n await this.channel.call(\"session.touch\", null);\n } catch {\n // A racing lock or respawn needs no handling.\n }\n }\n\n /**\n * The worker is dead or replaced — no status will arrive from it, yet an unlocked vault is locked\n * now. Reflect that in the snapshot without waiting for the respawned kernel; other states\n * (uninitialized, corrupted, …) are the kernel's truth and stay untouched.\n */\n private markLocked(): void {\n if (this.status !== undefined && this.status.vault === \"unlocked\") {\n this.status = { ...this.status, vault: \"locked\" };\n }\n this.emit();\n }\n\n private onStatus(status: StatusPayload): void {\n if (this.lockReason === undefined && status.vault === \"locked\") {\n this.lockReason = \"cold-start\"; // locked at first sight, not by an action of ours\n }\n this.status = status;\n this.emit();\n }\n\n /**\n * Rebuilds the immutable snapshot and notifies subscribers — only when the content actually\n * changed (identical status events produce no new reference and no notification).\n */\n private emit(): void {\n const { status } = this;\n const next: WalletSnapshot = {\n vault: status === undefined ? \"uninitialized\" : status.vault,\n lockReason: this.lockReason,\n verifying: this.verifying > 0,\n factors: status === undefined ? [] : status.factors,\n wallets: status === undefined ? [] : status.wallets,\n nostr: { keys: status === undefined ? [] : status.nostr.keys },\n backup: status === undefined ? null : status.backup,\n };\n const current = this.snapshotValue;\n if (\n current.vault === next.vault &&\n current.lockReason === next.lockReason &&\n current.verifying === next.verifying &&\n deepEqual(current.factors, next.factors) &&\n deepEqual(current.wallets, next.wallets) &&\n deepEqual(current.nostr, next.nostr) &&\n deepEqual(current.backup, next.backup)\n ) {\n return;\n }\n this.snapshotValue = next;\n for (const listener of this.listeners) {\n listener();\n }\n }\n\n // Arrow properties: safe unbound, e.g. useSyncExternalStore(wallet.subscribe, wallet.getSnapshot).\n readonly getSnapshot = (): WalletSnapshot => this.snapshotValue;\n\n readonly subscribe = (listener: () => void): (() => void) => {\n this.listeners.add(listener);\n return () => {\n this.listeners.delete(listener);\n };\n };\n\n private get factorSource(): FactorSource {\n return {\n mode: this.factorMode,\n passkey: this.passkeyCfg,\n ceremony: this.ceremony,\n factors: () => this.snapshotValue.factors,\n };\n }\n\n /** True while a ceremony or a factor-bearing request is in flight; drives `verifying`. */\n private async withVerifying<T>(fn: () => Promise<T>): Promise<T> {\n this.verifying++;\n this.emit();\n try {\n return await fn();\n } finally {\n this.verifying--;\n this.emit();\n }\n }\n\n private initialized(): boolean {\n return this.snapshotValue.vault !== \"uninitialized\";\n }\n\n /** The factor gate on create/import commands; keeps useless ceremonies from firing. */\n private async createFactorParam(\n factor: InitialFactor | undefined,\n transfer: ArrayBuffer[],\n ): Promise<Factor | undefined> {\n if (this.initialized()) {\n if (factor !== undefined) {\n throw new WalletError(\"invalid-input\", \"the vault is already initialized\");\n }\n return undefined;\n }\n if (factor === undefined && this.factorMode === \"software\") {\n throw new WalletError(\"invalid-input\", \"an initial factor is required\");\n }\n return resolveInitialFactor(this.factorSource, factor, transfer);\n }\n\n private sessionOf(result: { readonly session: string }): void {\n this.channel.session = result.session;\n this.channel.flushStatus();\n }\n\n readonly vault: VaultApi = {\n unlock: async (factor?: UnlockFactor): Promise<void> =>\n this.withVerifying(async () => {\n const transfer: ArrayBuffer[] = [];\n const wire = await resolveFactor(\n this.factorSource,\n factor ?? defaultUnlockFactor(this.factorSource),\n transfer,\n );\n const result = await this.channel.call(\"vault.unlock\", { factor: wire }, transfer);\n this.sessionOf(result);\n }),\n // Host-side lock: immediate, no kernel round trip — fails pending calls, clears the session\n // and respawns the port. Idempotent: re-locking is a no-op.\n // oxlint-disable-next-line typescript/require-await -- the interface's Promise is resolved synchronously\n lock: async (): Promise<void> => {\n this.channel.lockNow();\n this.markLocked();\n },\n addFactor: async (factor: InitialFactor, verify: UnlockFactor): Promise<FactorInfo> =>\n this.withVerifying(async () => {\n const transfer: ArrayBuffer[] = [];\n const wireVerify = await resolveFactor(this.factorSource, verify, transfer);\n const wireFactor = await resolveInitialFactor(this.factorSource, factor, transfer);\n return this.channel.call(\n \"vault.addFactor\",\n { verify: wireVerify, factor: wireFactor },\n transfer,\n );\n }),\n removeFactor: async (id: string, verify: UnlockFactor): Promise<void> =>\n this.withVerifying(async () => {\n const transfer: ArrayBuffer[] = [];\n const wireVerify = await resolveFactor(this.factorSource, verify, transfer);\n await this.channel.call(\"vault.removeFactor\", { verify: wireVerify, id }, transfer);\n }),\n reset: async (): Promise<void> => {\n await this.channel.call(\"vault.reset\", null);\n },\n };\n\n readonly wallets: WalletsApi = {\n createWithPasskey: async (options: {\n readonly name: string;\n readonly factor?: InitialFactor;\n }): Promise<WalletInfo> =>\n this.withVerifying(async () => {\n const name = passkeyName(options.name);\n const transfer: ArrayBuffer[] = [];\n if (this.factorMode === \"hardware\") {\n // The kernel runs the platform ceremony: nothing secret crosses the channel.\n const factor = await this.createFactorParam(options.factor, transfer);\n const created = await this.channel.call(\n \"wallet.createWithPasskey\",\n {\n ceremony: \"kernel\",\n rpId: this.passkeyCfg.rpId,\n rpName: this.passkeyCfg.rpName,\n name,\n walletSalt: this.passkeyCfg.walletSalt,\n ...(factor === undefined ? {} : { factor }),\n },\n transfer,\n );\n this.sessionOf(created);\n return created.wallet;\n }\n const ceremony = requireCeremony(this.factorSource);\n const result = await ceremony.create({\n purpose: \"wallet\",\n name,\n salts: {\n first: walletSaltBytes(this.factorSource),\n second: vaultSaltBytes(this.factorSource),\n },\n });\n let factor: Factor | undefined;\n if (this.initialized()) {\n if (options.factor !== undefined) {\n throw new WalletError(\"invalid-input\", \"the vault is already initialized\");\n }\n result.second?.fill(0); // the vault factor slot is not needed\n } else {\n factor = await resolveInitialFactor(this.factorSource, options.factor, transfer, result);\n }\n return this.hostPasskeyWallet(\"wallet.createWithPasskey\", result, factor, transfer);\n }),\n restoreWithPasskey: async (options?: {\n readonly factor?: InitialFactor;\n }): Promise<WalletInfo> =>\n this.withVerifying(async () => {\n const transfer: ArrayBuffer[] = [];\n if (this.factorMode === \"hardware\") {\n const factor = await this.createFactorParam(options?.factor, transfer);\n const created = await this.channel.call(\n \"wallet.restoreWithPasskey\",\n {\n ceremony: \"kernel\",\n rpId: this.passkeyCfg.rpId,\n walletSalt: this.passkeyCfg.walletSalt,\n ...(factor === undefined ? {} : { factor }),\n },\n transfer,\n );\n this.sessionOf(created);\n return created.wallet;\n }\n const ceremony = requireCeremony(this.factorSource);\n const result = await ceremony.assert({\n salts: {\n first: walletSaltBytes(this.factorSource),\n second: vaultSaltBytes(this.factorSource),\n },\n });\n // The asserted credential must be a wallet-purpose passkey: a vault-purpose credential\n // would silently derive a different wallet. Rejected assertions never reach the kernel.\n if (result.userHandle?.[0] !== PASSKEY_PURPOSE_WALLET) {\n result.first.fill(0);\n result.second?.fill(0);\n throw new WalletError(\"wrong-passkey\", \"the passkey is not a wallet credential\");\n }\n let factor: Factor | undefined;\n if (this.initialized()) {\n if (options?.factor !== undefined) {\n throw new WalletError(\"invalid-input\", \"the vault is already initialized\");\n }\n result.second?.fill(0);\n } else {\n factor = await resolveInitialFactor(this.factorSource, options?.factor, transfer, result);\n }\n return this.hostPasskeyWallet(\"wallet.restoreWithPasskey\", result, factor, transfer);\n }),\n createMnemonic: async (options: {\n readonly words: 12 | 24;\n readonly factor?: InitialFactor;\n }): Promise<MnemonicDraft> => {\n const transfer: ArrayBuffer[] = [];\n const factor = await this.createFactorParam(options.factor, transfer);\n const created = await this.channel.call(\n \"wallet.createMnemonic\",\n { words: options.words, ...(factor === undefined ? {} : { factor }) },\n transfer,\n );\n const draftId = created.draft;\n return {\n words: new SingleUseSecret(created.words),\n quiz: created.quiz,\n confirm: async (\n answers: ReadonlyArray<string>,\n confirmOptions?: { readonly passphrase?: string },\n ): Promise<WalletInfo> => {\n const answerTransfer: ArrayBuffer[] = [];\n const encoded = answers.map((word) => wireSecretText(word, answerTransfer));\n const passphrase = wirePassphrase(confirmOptions?.passphrase, answerTransfer);\n const confirmed = await this.channel.call(\n \"wallet.confirmMnemonic\",\n { draft: draftId, answers: encoded, ...passphrase },\n answerTransfer,\n );\n this.sessionOf(confirmed);\n return confirmed.wallet;\n },\n discard: async (): Promise<void> => {\n await this.channel.call(\"wallet.discardMnemonic\", { draft: draftId });\n },\n };\n },\n importMnemonic: async (options: {\n readonly mnemonic: string;\n readonly passphrase?: string;\n readonly factor?: InitialFactor;\n }): Promise<WalletInfo> => {\n const transfer: ArrayBuffer[] = [];\n const factor = await this.createFactorParam(options.factor, transfer);\n const mnemonic = wireSecretText(options.mnemonic, transfer);\n const passphrase = wirePassphrase(options.passphrase, transfer);\n const created = await this.channel.call(\n \"wallet.importMnemonic\",\n { mnemonic, ...passphrase, ...(factor === undefined ? {} : { factor }) },\n transfer,\n );\n this.sessionOf(created);\n return created.wallet;\n },\n exportMnemonic: async (walletId: string, verify: UnlockFactor): Promise<ExportedMnemonic> =>\n this.withVerifying(async () => {\n const transfer: ArrayBuffer[] = [];\n const wireVerify = await resolveFactor(this.factorSource, verify, transfer);\n const exported = await this.channel.call(\n \"wallet.exportMnemonic\",\n { verify: wireVerify, walletId },\n transfer,\n );\n return {\n mnemonic: new SingleUseSecret(exported.mnemonic),\n ...(exported.passphrase === undefined\n ? {}\n : { passphrase: new SingleUseSecret(exported.passphrase) }),\n };\n }),\n delete: async (walletId: string, verify: UnlockFactor): Promise<void> =>\n this.withVerifying(async () => {\n const transfer: ArrayBuffer[] = [];\n const wireVerify = await resolveFactor(this.factorSource, verify, transfer);\n await this.channel.call(\"wallet.delete\", { verify: wireVerify, walletId }, transfer);\n }),\n };\n\n readonly dataKeys: DataKeyApi = {\n get: async (purpose: string): Promise<Uint8Array> =>\n this.channel.call(\"dataKeys.get\", { purpose }),\n };\n\n readonly backup: BackupApi = {\n enable: async (options: {\n readonly verify: UnlockFactor;\n readonly factors: ReadonlyArray<UnlockFactor>;\n }): Promise<void> =>\n this.withVerifying(async () => {\n const transfer: ArrayBuffer[] = [];\n const wireVerify = await resolveFactor(this.factorSource, options.verify, transfer);\n const wireFactors = await Promise.all(\n options.factors.map(async (factor) =>\n resolveBackupFactor(this.factorSource, factor, transfer),\n ),\n );\n await this.channel.call(\n \"backup.enable\",\n { verify: wireVerify, factors: wireFactors },\n transfer,\n );\n }),\n update: async (): Promise<string> => {\n const result = await this.channel.call(\"backup.update\", null);\n return result.envelope;\n },\n disable: async (): Promise<void> => {\n await this.channel.call(\"backup.disable\", null);\n },\n restore: async (options: {\n readonly envelope: string;\n readonly backupFactor: UnlockFactor;\n readonly passphrases?: ReadonlyArray<{\n readonly walletId: string;\n readonly passphrase: string;\n }>;\n readonly factor?: InitialFactor;\n }): Promise<{\n readonly wallets: ReadonlyArray<WalletInfo>;\n readonly passphraseRequired: ReadonlyArray<string>;\n }> =>\n this.withVerifying(async () => {\n const transfer: ArrayBuffer[] = [];\n const backupFactor = await resolveBackupUnlockFactor(\n this.factorSource,\n options.backupFactor,\n transfer,\n );\n const factor = await this.createFactorParam(options.factor, transfer);\n const passphrases = options.passphrases?.map(({ walletId, passphrase }) => ({\n walletId,\n passphrase: wireSecretText(passphrase, transfer),\n }));\n const result = await this.channel.call(\n \"backup.restore\",\n {\n envelope: options.envelope,\n backupFactor,\n ...(passphrases === undefined ? {} : { passphrases }),\n ...(factor === undefined ? {} : { factor }),\n },\n transfer,\n );\n this.sessionOf(result);\n return { wallets: result.wallets, passphraseRequired: result.passphraseRequired };\n }),\n };\n\n // oxlint-disable-next-line typescript/require-await -- the interface's Promise is resolved synchronously\n async destroy(): Promise<void> {\n if (this.destroyed) {\n return;\n }\n this.destroyed = true;\n this.unsubscribePresence?.();\n this.cancelCooldown?.();\n this.onDestroy?.();\n this.channel.destroy();\n }\n}\n\n/**\n * Validates the passkey configuration: the RP identity and both PRF salts are permanent\n * identifiers, so an empty or colliding value is rejected here rather than producing unrecoverable\n * credentials later.\n */\nfunction checkPasskeyConfig(passkey: PasskeyConfig): void {\n const { rpId, rpName, walletSalt, vaultSalt, backupSalt } = passkey;\n if (\n rpId.length === 0 ||\n rpName.length === 0 ||\n walletSalt.length === 0 ||\n vaultSalt.length === 0 ||\n backupSalt.length === 0 ||\n walletSalt === vaultSalt ||\n backupSalt === vaultSalt ||\n backupSalt === walletSalt\n ) {\n throw new WalletError(\n \"invalid-input\",\n \"passkey config requires a non-empty rpId, rpName and two different salts\",\n );\n }\n}\n\n/**\n * Connects a kernel spawned by the host package and returns the host-facing `Wallet`. The first\n * spawn must deliver a status event before this resolves.\n */\nexport async function connectKernel(options: ConnectOptions): Promise<Wallet> {\n checkPasskeyConfig(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AA,IAAY,CAAC,IAAI,EAAE,YAAY;IACnD,GAAI,WAAW,KAAA,IAAY,CAAC,IAAI,EAAE,OAAO;GAC3C,GACA,QACF;GACA,KAAK,UAAU,MAAM;GACrB,OAAO;IAAE,SAAS,OAAO;IAAS,oBAAoB,OAAO;GAAmB;EAClF,CAAC;CACL;CAGA,MAAM,UAAyB;EAC7B,IAAI,KAAK,WACP;EAEF,KAAK,YAAY;EACjB,KAAK,sBAAsB;EAC3B,KAAK,iBAAiB;EACtB,KAAK,YAAY;EACjB,KAAK,QAAQ,QAAQ;CACvB;AACF;;;;;;AAOA,SAAS,mBAAmB,SAA8B;CACxD,MAAM,EAAE,MAAM,QAAQ,YAAY,WAAW,eAAe;CAC5D,IACE,KAAK,WAAW,KAChB,OAAO,WAAW,KAClB,WAAW,WAAW,KACtB,UAAU,WAAW,KACrB,WAAW,WAAW,KACtB,eAAe,aACf,eAAe,aACf,eAAe,YAEf,MAAM,IAAI,YACR,iBACA,0EACF;AAEJ;;;;;AAMA,eAAsB,cAAc,SAA0C;CAC5E,mBAAmB,QAAQ,OAAO;CAClC,OAAO,aAAa,QAAQ,OAAO;AACrC"}
|
|
1
|
+
{"version":3,"file":"host.mjs","names":[],"sources":["../src/wallet.ts"],"sourcesContent":["/**\n * The host-facing `Wallet` (design/entry.mdx \"API\"): snapshot state, the core API groups, and the\n * glue between the kernel `Channel` and factor resolution. `connectKernel` is exported under the\n * `./host` subpath — reserved for host packages; applications must not use it. Protocol modules\n * (@qntx/wallet/nostr and future siblings) reach this wallet's channel through the registered\n * internals in internal.ts — never through the public type.\n */\n\nimport { base58, hex } from \"@scure/base\";\n\nimport { Channel } from \"./channel.ts\";\nimport type { MainPort, SetTimer } from \"./channel.ts\";\nimport {\n PASSKEY_PURPOSE_WALLET,\n passkeyName,\n requireCeremony,\n resolveFactor,\n resolveInitialFactor,\n vaultSaltBytes,\n walletSaltBytes,\n wireBytes,\n wirePassphrase,\n wireSecretText,\n resolveBackupFactor,\n resolveBackupUnlockFactor,\n defaultUnlockFactor,\n} from \"./factors.ts\";\nimport type { FactorMode, FactorSource, PasskeyCeremony, PrfResult } from \"./factors.ts\";\nimport { registerInternals } from \"./internal.ts\";\nimport type { Factor, SignedEvent } from \"./protocol/index.ts\";\nimport { SingleUseSecret } from \"./secret.ts\";\nimport { WalletError } from \"./types.ts\";\nimport type {\n BackupApi,\n DataKeyApi,\n ExportedMnemonic,\n FactorInfo,\n InitialFactor,\n KeyInfo,\n KeysApi,\n LockReason,\n MnemonicDraft,\n PasskeyConfig,\n StatusPayload,\n UnlockFactor,\n VaultApi,\n Wallet,\n WalletInfo,\n WalletSnapshot,\n WalletsApi,\n} from \"./types.ts\";\n\nexport type ConnectOptions = {\n readonly spawn: () => MainPort;\n /** Fixed by the host entry: `hardware` on React Native, `software` on web and node. */\n readonly factors: FactorMode;\n readonly passkey: PasskeyConfig;\n readonly verifyEvent: (event: SignedEvent) => boolean;\n readonly ceremony: PasskeyCeremony | undefined;\n /** Timer source injected by the host package (globalThis timers on web/node). */\n readonly setTimer: SetTimer;\n /**\n * User-presence source: subscribes to activity signals and returns an unsubscribe the wallet\n * owns. Absent means the host has no presence signals (the kernel policy decides what counts).\n */\n readonly presence?: (onActivity: () => void) => () => void;\n /** Runs once inside `destroy()` — host-side cleanup (page listeners, timers). */\n readonly onDestroy?: () => void;\n};\n\n/** One `session.touch` at most per interval — the idle deadline slips at most this much early. */\nexport const PRESENCE_TOUCH_INTERVAL_MS = 30_000;\n\n/** Structural equality over plain snapshot data (validated protocol payloads only). */\nfunction deepEqual(a: unknown, b: unknown): boolean {\n if (a === b) {\n return true;\n }\n if (typeof a !== \"object\" || a === null || typeof b !== \"object\" || b === null) {\n return false;\n }\n if (Array.isArray(a) || Array.isArray(b)) {\n return (\n Array.isArray(a) &&\n Array.isArray(b) &&\n a.length === b.length &&\n a.every((item, index) => deepEqual(item, b[index]))\n );\n }\n const aKeys = Object.keys(a);\n const bKeys = Object.keys(b);\n return (\n aKeys.length === bKeys.length &&\n aKeys.every(\n (key) =>\n key in b &&\n deepEqual(\n (a as Record<string, unknown>)[key], // oxlint-disable-line typescript/no-unsafe-type-assertion -- plain-object records\n (b as Record<string, unknown>)[key], // oxlint-disable-line typescript/no-unsafe-type-assertion -- plain-object records\n ),\n )\n );\n}\n\nexport class KernelWallet implements Wallet {\n private readonly channel: Channel;\n private readonly factorMode: FactorMode;\n private readonly passkeyCfg: PasskeyConfig;\n private readonly ceremony: PasskeyCeremony | undefined;\n private readonly setTimer: SetTimer;\n private readonly onDestroy: (() => void) | undefined;\n private readonly unsubscribePresence: (() => void) | undefined;\n private presenceCooling = false;\n private cancelCooldown: (() => void) | undefined;\n private destroyed = false;\n\n private status: StatusPayload | undefined;\n private lockReason: LockReason | undefined;\n private verifying = 0;\n private snapshotValue: WalletSnapshot;\n private readonly listeners = new Set<() => void>();\n\n private constructor(options: ConnectOptions) {\n this.factorMode = options.factors;\n this.passkeyCfg = options.passkey;\n this.ceremony = options.ceremony;\n this.setTimer = options.setTimer;\n this.onDestroy = options.onDestroy;\n this.snapshotValue = {\n vault: \"uninitialized\",\n lockReason: undefined,\n verifying: false,\n factors: [],\n wallets: [],\n nostr: { keys: [] },\n importedKeys: [],\n backup: null,\n };\n this.channel = new Channel(\n options.spawn,\n {\n onStatus: (status) => {\n this.onStatus(status);\n },\n onLocked: (reason) => {\n this.lockReason = reason;\n this.markLocked();\n },\n onCrashed: () => {\n this.lockReason = \"crashed\";\n this.markLocked();\n },\n },\n options.setTimer,\n );\n // The wallet owns the subscription it creates: destroy() unsubscribes — no second owner.\n this.unsubscribePresence = options.presence?.(() => {\n this.onPresence();\n });\n registerInternals(this, {\n call: async (method, params, transfer) => this.channel.call(method, params, transfer),\n ready: async () => this.channel.ready,\n snapshot: () => this.snapshotValue,\n verifyEvent: options.verifyEvent,\n withVerifying: async (fn) => this.withVerifying(fn),\n resolveFactor: async (factor, transfer) => resolveFactor(this.factorSource, factor, transfer),\n createFactorParam: async (factor, transfer) => this.createFactorParam(factor, transfer),\n sessionOf: (result) => {\n this.sessionOf(result);\n },\n });\n }\n\n static async connect(options: ConnectOptions): Promise<KernelWallet> {\n const wallet = new KernelWallet(options);\n await wallet.channel.start();\n return wallet;\n }\n\n /** Runs a host-ceremony passkey call and adopts the returned session and wallet info. */\n private async hostPasskeyWallet(\n method: \"wallet.createWithPasskey\" | \"wallet.restoreWithPasskey\",\n result: PrfResult,\n factor: Factor | undefined,\n transfer: ArrayBuffer[],\n ): Promise<WalletInfo> {\n const created = await this.channel.call(\n method,\n {\n ceremony: \"host\",\n credentialId: wireBytes(result.credentialId, transfer),\n prfWallet: wireBytes(result.first, transfer, true),\n synced: result.synced,\n ...(factor === undefined ? {} : { factor }),\n },\n transfer,\n );\n this.sessionOf(created);\n return created.wallet;\n }\n\n /**\n * Presence refresh, throttled to one touch per interval: once a touch fires, signals are ignored\n * until the cooldown elapses — no clock reads, just the injected timer. Touches only go out while\n * a session is held; failures are silent (a lock or respawn needs no handling).\n */\n private onPresence(): void {\n if (this.presenceCooling || this.destroyed || this.channel.session === undefined) {\n return;\n }\n this.presenceCooling = true;\n this.cancelCooldown = this.setTimer(PRESENCE_TOUCH_INTERVAL_MS, () => {\n this.presenceCooling = false;\n this.cancelCooldown = undefined;\n });\n void this.touchSession();\n }\n\n private async touchSession(): Promise<void> {\n try {\n await this.channel.call(\"session.touch\", null);\n } catch {\n // A racing lock or respawn needs no handling.\n }\n }\n\n /**\n * The worker is dead or replaced — no status will arrive from it, yet an unlocked vault is locked\n * now. Reflect that in the snapshot without waiting for the respawned kernel; other states\n * (uninitialized, corrupted, …) are the kernel's truth and stay untouched.\n */\n private markLocked(): void {\n if (this.status !== undefined && this.status.vault === \"unlocked\") {\n this.status = { ...this.status, vault: \"locked\" };\n }\n this.emit();\n }\n\n private onStatus(status: StatusPayload): void {\n if (this.lockReason === undefined && status.vault === \"locked\") {\n this.lockReason = \"cold-start\"; // locked at first sight, not by an action of ours\n }\n this.status = status;\n this.emit();\n }\n\n /**\n * Rebuilds the immutable snapshot and notifies subscribers — only when the content actually\n * changed (identical status events produce no new reference and no notification).\n */\n private emit(): void {\n const { status } = this;\n const next: WalletSnapshot = {\n vault: status === undefined ? \"uninitialized\" : status.vault,\n lockReason: this.lockReason,\n verifying: this.verifying > 0,\n factors: status === undefined ? [] : status.factors,\n wallets: status === undefined ? [] : status.wallets,\n nostr: { keys: status === undefined ? [] : status.nostr.keys },\n importedKeys: status === undefined ? [] : status.importedKeys,\n backup: status === undefined ? null : status.backup,\n };\n const current = this.snapshotValue;\n if (\n current.vault === next.vault &&\n current.lockReason === next.lockReason &&\n current.verifying === next.verifying &&\n deepEqual(current.factors, next.factors) &&\n deepEqual(current.wallets, next.wallets) &&\n deepEqual(current.nostr, next.nostr) &&\n deepEqual(current.importedKeys, next.importedKeys) &&\n deepEqual(current.backup, next.backup)\n ) {\n return;\n }\n this.snapshotValue = next;\n for (const listener of this.listeners) {\n listener();\n }\n }\n\n // Arrow properties: safe unbound, e.g. useSyncExternalStore(wallet.subscribe, wallet.getSnapshot).\n readonly getSnapshot = (): WalletSnapshot => this.snapshotValue;\n\n readonly subscribe = (listener: () => void): (() => void) => {\n this.listeners.add(listener);\n return () => {\n this.listeners.delete(listener);\n };\n };\n\n private get factorSource(): FactorSource {\n return {\n mode: this.factorMode,\n passkey: this.passkeyCfg,\n ceremony: this.ceremony,\n factors: () => this.snapshotValue.factors,\n };\n }\n\n /** True while a ceremony or a factor-bearing request is in flight; drives `verifying`. */\n private async withVerifying<T>(fn: () => Promise<T>): Promise<T> {\n this.verifying++;\n this.emit();\n try {\n return await fn();\n } finally {\n this.verifying--;\n this.emit();\n }\n }\n\n private initialized(): boolean {\n return this.snapshotValue.vault !== \"uninitialized\";\n }\n\n /** The factor gate on create/import commands; keeps useless ceremonies from firing. */\n private async createFactorParam(\n factor: InitialFactor | undefined,\n transfer: ArrayBuffer[],\n ): Promise<Factor | undefined> {\n if (this.initialized()) {\n if (factor !== undefined) {\n throw new WalletError(\"invalid-input\", \"the vault is already initialized\");\n }\n return undefined;\n }\n if (factor === undefined && this.factorMode === \"software\") {\n throw new WalletError(\"invalid-input\", \"an initial factor is required\");\n }\n return resolveInitialFactor(this.factorSource, factor, transfer);\n }\n\n private sessionOf(result: { readonly session: string }): void {\n this.channel.session = result.session;\n this.channel.flushStatus();\n }\n\n readonly vault: VaultApi = {\n unlock: async (factor?: UnlockFactor): Promise<void> =>\n this.withVerifying(async () => {\n const transfer: ArrayBuffer[] = [];\n const wire = await resolveFactor(\n this.factorSource,\n factor ?? defaultUnlockFactor(this.factorSource),\n transfer,\n );\n const result = await this.channel.call(\"vault.unlock\", { factor: wire }, transfer);\n this.sessionOf(result);\n }),\n // Host-side lock: immediate, no kernel round trip — fails pending calls, clears the session\n // and respawns the port. Idempotent: re-locking is a no-op.\n // oxlint-disable-next-line typescript/require-await -- the interface's Promise is resolved synchronously\n lock: async (): Promise<void> => {\n this.channel.lockNow();\n this.markLocked();\n },\n addFactor: async (factor: InitialFactor, verify: UnlockFactor): Promise<FactorInfo> =>\n this.withVerifying(async () => {\n const transfer: ArrayBuffer[] = [];\n const wireVerify = await resolveFactor(this.factorSource, verify, transfer);\n const wireFactor = await resolveInitialFactor(this.factorSource, factor, transfer);\n return this.channel.call(\n \"vault.addFactor\",\n { verify: wireVerify, factor: wireFactor },\n transfer,\n );\n }),\n removeFactor: async (id: string, verify: UnlockFactor): Promise<void> =>\n this.withVerifying(async () => {\n const transfer: ArrayBuffer[] = [];\n const wireVerify = await resolveFactor(this.factorSource, verify, transfer);\n await this.channel.call(\"vault.removeFactor\", { verify: wireVerify, id }, transfer);\n }),\n reset: async (): Promise<void> => {\n await this.channel.call(\"vault.reset\", null);\n },\n };\n\n readonly keys: KeysApi = {\n import: async (\n family: \"evm\" | \"solana\" | \"bitcoin\",\n secret: string | Uint8Array,\n ): Promise<KeyInfo> =>\n this.withVerifying(async () => {\n const transfer: ArrayBuffer[] = [];\n const decoded = decodeKeySecret(family, secret);\n try {\n return await this.channel.call(\n \"keys.import\",\n { family, secret: wireBytes(decoded, transfer) },\n transfer,\n );\n } finally {\n if (decoded !== secret) {\n decoded.fill(0);\n }\n }\n }),\n list: async (): Promise<ReadonlyArray<KeyInfo>> => this.channel.call(\"keys.list\", null, []),\n remove: async (keyId: string, verify: UnlockFactor): Promise<void> =>\n this.withVerifying(async () => {\n const transfer: ArrayBuffer[] = [];\n const wireVerify = await resolveFactor(this.factorSource, verify, transfer);\n await this.channel.call(\"keys.remove\", { verify: wireVerify, keyId }, transfer);\n }),\n export: async (keyId: string, verify: UnlockFactor): Promise<Uint8Array> =>\n this.withVerifying(async () => {\n const transfer: ArrayBuffer[] = [];\n const wireVerify = await resolveFactor(this.factorSource, verify, transfer);\n return this.channel.call(\"keys.export\", { verify: wireVerify, keyId }, transfer);\n }),\n };\n\n readonly wallets: WalletsApi = {\n createWithPasskey: async (options: {\n readonly name: string;\n readonly factor?: InitialFactor;\n }): Promise<WalletInfo> =>\n this.withVerifying(async () => {\n const name = passkeyName(options.name);\n const transfer: ArrayBuffer[] = [];\n if (this.factorMode === \"hardware\") {\n // The kernel runs the platform ceremony: nothing secret crosses the channel.\n const factor = await this.createFactorParam(options.factor, transfer);\n const created = await this.channel.call(\n \"wallet.createWithPasskey\",\n {\n ceremony: \"kernel\",\n rpId: this.passkeyCfg.rpId,\n rpName: this.passkeyCfg.rpName,\n name,\n walletSalt: this.passkeyCfg.walletSalt,\n ...(factor === undefined ? {} : { factor }),\n },\n transfer,\n );\n this.sessionOf(created);\n return created.wallet;\n }\n const ceremony = requireCeremony(this.factorSource);\n const result = await ceremony.create({\n purpose: \"wallet\",\n name,\n salts: {\n first: walletSaltBytes(this.factorSource),\n second: vaultSaltBytes(this.factorSource),\n },\n });\n let factor: Factor | undefined;\n if (this.initialized()) {\n if (options.factor !== undefined) {\n throw new WalletError(\"invalid-input\", \"the vault is already initialized\");\n }\n result.second?.fill(0); // the vault factor slot is not needed\n } else {\n factor = await resolveInitialFactor(this.factorSource, options.factor, transfer, result);\n }\n return this.hostPasskeyWallet(\"wallet.createWithPasskey\", result, factor, transfer);\n }),\n restoreWithPasskey: async (options?: {\n readonly factor?: InitialFactor;\n }): Promise<WalletInfo> =>\n this.withVerifying(async () => {\n const transfer: ArrayBuffer[] = [];\n if (this.factorMode === \"hardware\") {\n const factor = await this.createFactorParam(options?.factor, transfer);\n const created = await this.channel.call(\n \"wallet.restoreWithPasskey\",\n {\n ceremony: \"kernel\",\n rpId: this.passkeyCfg.rpId,\n walletSalt: this.passkeyCfg.walletSalt,\n ...(factor === undefined ? {} : { factor }),\n },\n transfer,\n );\n this.sessionOf(created);\n return created.wallet;\n }\n const ceremony = requireCeremony(this.factorSource);\n const result = await ceremony.assert({\n salts: {\n first: walletSaltBytes(this.factorSource),\n second: vaultSaltBytes(this.factorSource),\n },\n });\n // The asserted credential must be a wallet-purpose passkey: a vault-purpose credential\n // would silently derive a different wallet. Rejected assertions never reach the kernel.\n if (result.userHandle?.[0] !== PASSKEY_PURPOSE_WALLET) {\n result.first.fill(0);\n result.second?.fill(0);\n throw new WalletError(\"wrong-passkey\", \"the passkey is not a wallet credential\");\n }\n let factor: Factor | undefined;\n if (this.initialized()) {\n if (options?.factor !== undefined) {\n throw new WalletError(\"invalid-input\", \"the vault is already initialized\");\n }\n result.second?.fill(0);\n } else {\n factor = await resolveInitialFactor(this.factorSource, options?.factor, transfer, result);\n }\n return this.hostPasskeyWallet(\"wallet.restoreWithPasskey\", result, factor, transfer);\n }),\n createMnemonic: async (options: {\n readonly words: 12 | 24;\n readonly factor?: InitialFactor;\n }): Promise<MnemonicDraft> => {\n const transfer: ArrayBuffer[] = [];\n const factor = await this.createFactorParam(options.factor, transfer);\n const created = await this.channel.call(\n \"wallet.createMnemonic\",\n { words: options.words, ...(factor === undefined ? {} : { factor }) },\n transfer,\n );\n const draftId = created.draft;\n return {\n words: new SingleUseSecret(created.words),\n quiz: created.quiz,\n confirm: async (\n answers: ReadonlyArray<string>,\n confirmOptions?: { readonly passphrase?: string },\n ): Promise<WalletInfo> => {\n const answerTransfer: ArrayBuffer[] = [];\n const encoded = answers.map((word) => wireSecretText(word, answerTransfer));\n const passphrase = wirePassphrase(confirmOptions?.passphrase, answerTransfer);\n const confirmed = await this.channel.call(\n \"wallet.confirmMnemonic\",\n { draft: draftId, answers: encoded, ...passphrase },\n answerTransfer,\n );\n this.sessionOf(confirmed);\n return confirmed.wallet;\n },\n discard: async (): Promise<void> => {\n await this.channel.call(\"wallet.discardMnemonic\", { draft: draftId });\n },\n };\n },\n importMnemonic: async (options: {\n readonly mnemonic: string;\n readonly passphrase?: string;\n readonly factor?: InitialFactor;\n }): Promise<WalletInfo> => {\n const transfer: ArrayBuffer[] = [];\n const factor = await this.createFactorParam(options.factor, transfer);\n const mnemonic = wireSecretText(options.mnemonic, transfer);\n const passphrase = wirePassphrase(options.passphrase, transfer);\n const created = await this.channel.call(\n \"wallet.importMnemonic\",\n { mnemonic, ...passphrase, ...(factor === undefined ? {} : { factor }) },\n transfer,\n );\n this.sessionOf(created);\n return created.wallet;\n },\n exportMnemonic: async (walletId: string, verify: UnlockFactor): Promise<ExportedMnemonic> =>\n this.withVerifying(async () => {\n const transfer: ArrayBuffer[] = [];\n const wireVerify = await resolveFactor(this.factorSource, verify, transfer);\n const exported = await this.channel.call(\n \"wallet.exportMnemonic\",\n { verify: wireVerify, walletId },\n transfer,\n );\n return {\n mnemonic: new SingleUseSecret(exported.mnemonic),\n ...(exported.passphrase === undefined\n ? {}\n : { passphrase: new SingleUseSecret(exported.passphrase) }),\n };\n }),\n delete: async (walletId: string, verify: UnlockFactor): Promise<void> =>\n this.withVerifying(async () => {\n const transfer: ArrayBuffer[] = [];\n const wireVerify = await resolveFactor(this.factorSource, verify, transfer);\n await this.channel.call(\"wallet.delete\", { verify: wireVerify, walletId }, transfer);\n }),\n };\n\n readonly dataKeys: DataKeyApi = {\n get: async (purpose: string): Promise<Uint8Array> =>\n this.channel.call(\"dataKeys.get\", { purpose }),\n };\n\n readonly backup: BackupApi = {\n enable: async (options: {\n readonly verify: UnlockFactor;\n readonly factors: ReadonlyArray<UnlockFactor>;\n }): Promise<void> =>\n this.withVerifying(async () => {\n const transfer: ArrayBuffer[] = [];\n const wireVerify = await resolveFactor(this.factorSource, options.verify, transfer);\n const wireFactors = await Promise.all(\n options.factors.map(async (factor) =>\n resolveBackupFactor(this.factorSource, factor, transfer),\n ),\n );\n await this.channel.call(\n \"backup.enable\",\n { verify: wireVerify, factors: wireFactors },\n transfer,\n );\n }),\n update: async (): Promise<string> => {\n const result = await this.channel.call(\"backup.update\", null);\n return result.envelope;\n },\n disable: async (): Promise<void> => {\n await this.channel.call(\"backup.disable\", null);\n },\n restore: async (options: {\n readonly envelope: string;\n readonly backupFactor: UnlockFactor;\n readonly passphrases?: ReadonlyArray<{\n readonly walletId: string;\n readonly passphrase: string;\n }>;\n readonly factor?: InitialFactor;\n }): Promise<{\n readonly wallets: ReadonlyArray<WalletInfo>;\n readonly passphraseRequired: ReadonlyArray<string>;\n }> =>\n this.withVerifying(async () => {\n const transfer: ArrayBuffer[] = [];\n const backupFactor = await resolveBackupUnlockFactor(\n this.factorSource,\n options.backupFactor,\n transfer,\n );\n const factor = await this.createFactorParam(options.factor, transfer);\n const passphrases = options.passphrases?.map(({ walletId, passphrase }) => ({\n walletId,\n passphrase: wireSecretText(passphrase, transfer),\n }));\n const result = await this.channel.call(\n \"backup.restore\",\n {\n envelope: options.envelope,\n backupFactor,\n ...(passphrases === undefined ? {} : { passphrases }),\n ...(factor === undefined ? {} : { factor }),\n },\n transfer,\n );\n this.sessionOf(result);\n return { wallets: result.wallets, passphraseRequired: result.passphraseRequired };\n }),\n };\n\n // oxlint-disable-next-line typescript/require-await -- the interface's Promise is resolved synchronously\n async destroy(): Promise<void> {\n if (this.destroyed) {\n return;\n }\n this.destroyed = true;\n this.unsubscribePresence?.();\n this.cancelCooldown?.();\n this.onDestroy?.();\n this.channel.destroy();\n }\n}\n\n/**\n * `keys.import`'s `secret` in bytes: a string is the family's canonical text encoding — `0x` hex\n * for EVM, base58 for Solana — while a Uint8Array passes straight through to the kernel's checks.\n */\nfunction decodeKeySecret(\n family: \"evm\" | \"solana\" | \"bitcoin\",\n secret: string | Uint8Array,\n): Uint8Array {\n if (secret instanceof Uint8Array) {\n return secret;\n }\n if (family === \"evm\") {\n if (!/^0x[0-9a-fA-F]{64}$/.test(secret)) {\n throw new WalletError(\"invalid-input\", \"an EVM private key is 0x-prefixed 64-hex\");\n }\n return hex.decode(secret.slice(2));\n }\n if (family === \"solana\") {\n try {\n return base58.decode(secret);\n } catch {\n throw new WalletError(\"invalid-input\", \"a Solana private key is base58\");\n }\n }\n throw new WalletError(\"invalid-input\", `keys are not supported on ${family}`);\n}\n\n/**\n * Validates the passkey configuration: the RP identity and both PRF salts are permanent\n * identifiers, so an empty or colliding value is rejected here rather than producing unrecoverable\n * credentials later.\n */\nfunction checkPasskeyConfig(passkey: PasskeyConfig): void {\n const { rpId, rpName, walletSalt, vaultSalt, backupSalt } = passkey;\n if (\n rpId.length === 0 ||\n rpName.length === 0 ||\n walletSalt.length === 0 ||\n vaultSalt.length === 0 ||\n backupSalt.length === 0 ||\n walletSalt === vaultSalt ||\n backupSalt === vaultSalt ||\n backupSalt === walletSalt\n ) {\n throw new WalletError(\n \"invalid-input\",\n \"passkey config requires a non-empty rpId, rpName and two different salts\",\n );\n }\n}\n\n/**\n * Connects a kernel spawned by the host package and returns the host-facing `Wallet`. The first\n * spawn must deliver a status event before this resolves.\n */\nexport async function connectKernel(options: ConnectOptions): Promise<Wallet> {\n checkPasskeyConfig(options.passkey);\n return KernelWallet.connect(options);\n}\n"],"mappings":";;;;;;;;;;;;;;AAuEA,MAAa,6BAA6B;;AAG1C,SAAS,UAAU,GAAY,GAAqB;CAClD,IAAI,MAAM,GACR,OAAO;CAET,IAAI,OAAO,MAAM,YAAY,MAAM,QAAQ,OAAO,MAAM,YAAY,MAAM,MACxE,OAAO;CAET,IAAI,MAAM,QAAQ,CAAC,KAAK,MAAM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,CAAC;CACnC;CACA,IAAI,WAAW,UACb,IAAI;EACF,OAAO,OAAO,OAAO,MAAM;CAC7B,QAAQ;EACN,MAAM,IAAI,YAAY,iBAAiB,gCAAgC;CACzE;CAEF,MAAM,IAAI,YAAY,iBAAiB,6BAA6B,QAAQ;AAC9E;;;;;;AAOA,SAAS,mBAAmB,SAA8B;CACxD,MAAM,EAAE,MAAM,QAAQ,YAAY,WAAW,eAAe;CAC5D,IACE,KAAK,WAAW,KAChB,OAAO,WAAW,KAClB,WAAW,WAAW,KACtB,UAAU,WAAW,KACrB,WAAW,WAAW,KACtB,eAAe,aACf,eAAe,aACf,eAAe,YAEf,MAAM,IAAI,YACR,iBACA,0EACF;AAEJ;;;;;AAMA,eAAsB,cAAc,SAA0C;CAC5E,mBAAmB,QAAQ,OAAO;CAClC,OAAO,aAAa,QAAQ,OAAO;AACrC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { f as Factor, g as NullValue, l as CORE_METHODS, p as MethodSpec, t as CHAINS_METHODS, v as Validator } from "./chains-
|
|
1
|
+
import { C as WalletErrorCode, _ as StatusPayload, a as DerivedNostrKey, f as LockReason, m as NostrKeyInfo } from "./types-cAQAJBLi.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-B-FmFmuV.mjs";
|
|
3
3
|
/**
|
|
4
4
|
* The unsigned event input the kernel signs. `pubkey` is optional: callers may omit it and the
|
|
5
5
|
* kernel fills the signing key's own. Structurally compatible with @qntx/nostr's UnsignedEvent.
|
|
@@ -407,8 +407,14 @@ type BackupHeaderWallet = {
|
|
|
407
407
|
/** The wallet has a BIP-39 passphrase; it is never part of the payload. */
|
|
408
408
|
readonly passphrase?: true;
|
|
409
409
|
};
|
|
410
|
+
type BackupHeaderKey = {
|
|
411
|
+
readonly keyId: string;
|
|
412
|
+
readonly family: "evm" | "solana" | "bitcoin";
|
|
413
|
+
};
|
|
410
414
|
type BackupHeaderWire = {
|
|
411
415
|
readonly wallets: ReadonlyArray<BackupHeaderWallet>;
|
|
416
|
+
/** Imported keys carried by the payload; absent when there are none. */
|
|
417
|
+
readonly keys?: ReadonlyArray<BackupHeaderKey>;
|
|
412
418
|
};
|
|
413
419
|
declare const backupHeader: Validator<BackupHeaderWire>;
|
|
414
420
|
/** The whole-envelope text bound — `backup.update` results and `backup.restore` params use it. */
|
|
@@ -492,4 +498,4 @@ declare const responseError: Validator<{
|
|
|
492
498
|
detail?: string | undefined;
|
|
493
499
|
}>;
|
|
494
500
|
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 };
|
|
495
|
-
//# sourceMappingURL=index-
|
|
501
|
+
//# sourceMappingURL=index-CEhrd0Pl.d.mts.map
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as
|
|
2
|
-
import { et as SignedEvent, x as BackupHeaderWire } from "./index-
|
|
1
|
+
import { C as WalletErrorCode, E as WalletsApi, S as WalletError, T as WalletSnapshot, _ as StatusPayload, a as DerivedNostrKey, b as VaultState, c as FactorInfo, d as KeysApi, f as LockReason, g as PasskeyConfig, h as NostrKeyRef, i as DataKeyApi, l as InitialFactor, m as NostrKeyInfo, n as BackupApi, o as ExportedMnemonic, p as MnemonicDraft, r as BackupInfo, s as ExportedSecret, t as AutoLockPolicy, u as KeyInfo, v as UnlockFactor, w as WalletInfo, x as Wallet, y as VaultApi } from "./types-cAQAJBLi.mjs";
|
|
2
|
+
import { et as SignedEvent, x as BackupHeaderWire } from "./index-CEhrd0Pl.mjs";
|
|
3
3
|
type BackupHeaderWallet = BackupHeaderWire["wallets"][number];
|
|
4
4
|
type BackupHeader = {
|
|
5
5
|
readonly version: 1;
|
|
@@ -22,5 +22,5 @@ type WalletOptions = {
|
|
|
22
22
|
*/
|
|
23
23
|
readonly verifyEvent: (event: SignedEvent) => boolean;
|
|
24
24
|
};
|
|
25
|
-
export { type AutoLockPolicy, type BackupApi, type BackupHeader, type BackupHeaderWallet, type BackupInfo, type DataKeyApi, type DerivedNostrKey, type ExportedMnemonic, 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 };
|
|
25
|
+
export { type AutoLockPolicy, type BackupApi, type BackupHeader, type BackupHeaderWallet, type BackupInfo, type DataKeyApi, type DerivedNostrKey, type ExportedMnemonic, type ExportedSecret, type FactorInfo, type InitialFactor, type KeyInfo, type KeysApi, 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 };
|
|
26
26
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { f as backupEnvelope, h as backupHeader } from "./protocol-
|
|
1
|
+
import { O as validate } from "./core-DaRwkTaV.mjs";
|
|
2
|
+
import { f as backupEnvelope, h as backupHeader } from "./protocol-fXHXJguP.mjs";
|
|
3
3
|
import { WalletError } from "./types.mjs";
|
|
4
4
|
// src/backup.ts
|
|
5
5
|
function integrity(msg) {
|
package/dist/nostr.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { C as WalletErrorCode, a as DerivedNostrKey, h as NostrKeyRef, m as NostrKeyInfo, s as ExportedSecret, v as UnlockFactor, x as Wallet } from "./types-cAQAJBLi.mjs";
|
|
2
2
|
import { Event, NostrSigner, UnsignedEvent } from "@qntx/nostr";
|
|
3
3
|
import { Rumor } from "@qntx/nostr/nips/nip59";
|
|
4
4
|
type NostrUnwrapResult = {
|
package/dist/nostr.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { WalletError } from "./types.mjs";
|
|
2
|
-
import { n as integrity } from "./channel-
|
|
2
|
+
import { n as integrity } from "./channel-BLwce5hh.mjs";
|
|
3
3
|
import { t as internalsOf } from "./internal-CAKfHjIg.mjs";
|
|
4
4
|
import { h as wireSecretText, t as SingleUseSecret } from "./secret-CcjyF8D3.mjs";
|
|
5
5
|
import { signedMatchesUnsigned } from "@qntx/nostr";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as
|
|
1
|
+
import { C as obj, D as union, E as str, S as nullValue, T as record, _ as arr, a as MAX_TEXT, b as int, c as groupIndex, d as publicKey, f as safeTime, g as ValidationError, h as walletInfo, i as MAX_TAG_ITEM, l as identityIndex, m as walletId, n as MAX_SNAPSHOT_ITEMS, o as factor, p as walletErrorCode, r as MAX_TAGS, s as factorInfo, t as CORE_METHODS, u as keyInfo, w as opt, x as literal, y as bytes } from "./core-DaRwkTaV.mjs";
|
|
2
2
|
// src/protocol/backup.ts
|
|
3
3
|
/**
|
|
4
4
|
* Backup-envelope wire validators (design/backup.mdx): the strict structural shape the kernel and
|
|
@@ -28,12 +28,18 @@ const backupEnvelope = obj({
|
|
|
28
28
|
factors: arr(backupEnvelopeFactor, 5, 1),
|
|
29
29
|
payload: str(MAX_PAYLOAD_CHARS)
|
|
30
30
|
});
|
|
31
|
-
const backupHeader = obj({
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
31
|
+
const backupHeader = obj({
|
|
32
|
+
wallets: arr(obj({
|
|
33
|
+
walletId: str(128),
|
|
34
|
+
origin: union(literal("mnemonic"), literal("passkey")),
|
|
35
|
+
words: union(literal(12), literal(15), literal(18), literal(21), literal(24)),
|
|
36
|
+
passphrase: opt(literal(true))
|
|
37
|
+
}), 1e3),
|
|
38
|
+
keys: opt(arr(obj({
|
|
39
|
+
keyId: str(16, /^[0-9a-f]{16}$/),
|
|
40
|
+
family: union(literal("evm"), literal("solana"), literal("bitcoin"))
|
|
41
|
+
}), 256))
|
|
42
|
+
});
|
|
37
43
|
/** The whole-envelope text bound — `backup.update` results and `backup.restore` params use it. */
|
|
38
44
|
const backupEnvelopeText = str(MAX_ENVELOPE_CHARS);
|
|
39
45
|
const backupInfo = obj({
|
|
@@ -93,6 +99,14 @@ const evmTx = union(obj({
|
|
|
93
99
|
maxFeePerGas: hexQuantity,
|
|
94
100
|
maxPriorityFeePerGas: hexQuantity,
|
|
95
101
|
accessList
|
|
102
|
+
}), obj({
|
|
103
|
+
...txBase,
|
|
104
|
+
type: literal("eip7702"),
|
|
105
|
+
to: evmAddress,
|
|
106
|
+
maxFeePerGas: hexQuantity,
|
|
107
|
+
maxPriorityFeePerGas: hexQuantity,
|
|
108
|
+
accessList,
|
|
109
|
+
authorization: obj({ address: evmAddress })
|
|
96
110
|
}));
|
|
97
111
|
const signRequest = union(obj({
|
|
98
112
|
kind: literal("evm.transaction"),
|
|
@@ -778,6 +792,7 @@ const statusPayload = obj({
|
|
|
778
792
|
factors: arr(factorInfo, MAX_SNAPSHOT_ITEMS),
|
|
779
793
|
wallets: arr(walletInfo, MAX_SNAPSHOT_ITEMS),
|
|
780
794
|
nostr: nostrStatus,
|
|
795
|
+
importedKeys: arr(keyInfo, MAX_SNAPSHOT_ITEMS),
|
|
781
796
|
backup: union(backupInfo, nullValue)
|
|
782
797
|
});
|
|
783
798
|
const METHODS = {
|
|
@@ -812,4 +827,4 @@ const kernelEvent = union(obj({
|
|
|
812
827
|
const responseError = errorPayload;
|
|
813
828
|
export { isProtocolValue as a, responseError as c, CHAINS_METHODS as d, backupEnvelope as f, backupInfo as g, backupHeader as h, UNATTRIBUTED_ID as i, SPARK_METHODS as l, backupEnvelopeText as m, METHODS as n, kernelEvent as o, backupEnvelopeFactor as p, PROTOCOL_VERSION as r, requestBytes as s, MAX_REQUEST_BYTES as t, NOSTR_METHODS as u };
|
|
814
829
|
|
|
815
|
-
//# sourceMappingURL=protocol-
|
|
830
|
+
//# sourceMappingURL=protocol-fXHXJguP.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol-fXHXJguP.mjs","names":[],"sources":["../src/protocol/backup.ts","../src/protocol/chains.ts","../src/protocol/nostr.ts","../src/protocol/spark.ts","../src/protocol/index.ts"],"sourcesContent":["/**\n * Backup-envelope wire validators (design/backup.mdx): the strict structural shape the kernel and\n * the host-side `parseBackupHeader` share — version 1, bounded fields, `obj` rejects unknown keys.\n * Cryptographic checks (the payload tag, factor unwrap) stay in the kernel; these rules only shape\n * the JSON.\n */\nimport { safeTime } from \"./core.ts\";\nimport type { Validator } from \"./validate.ts\";\nimport { arr, int, literal, obj, opt, str, union } from \"./validate.ts\";\n\nconst MAX_FACTOR_CHARS = 512;\nconst MAX_STRING_BYTES = 64_000;\nconst MAX_PAYLOAD_CHARS = 1_400_000; // ~1 MiB of sealed bytes in base64url\nconst MAX_ENVELOPE_CHARS = 4_000_000;\n\nexport type BackupEnvelopeFactor =\n | { readonly kind: \"passkey\"; readonly credentialId: string; readonly sealedBek: string }\n | {\n readonly kind: \"password\";\n readonly iterations: 600_000;\n readonly salt: string;\n readonly sealedBek: string;\n };\n\nexport type BackupEnvelopeWire = {\n readonly version: 1;\n readonly createdAt: number;\n /** Raw JSON text — authenticated by the payload tag before it is parsed. */\n readonly header: string;\n readonly factors: ReadonlyArray<BackupEnvelopeFactor>;\n readonly payload: string;\n};\n\n/** One public factor entry — shared by the envelope and the retained `backup-key` header. */\nexport const backupEnvelopeFactor: Validator<BackupEnvelopeFactor> = union(\n obj({\n kind: literal(\"passkey\"),\n credentialId: str(MAX_FACTOR_CHARS),\n sealedBek: str(MAX_FACTOR_CHARS),\n }),\n obj({\n kind: literal(\"password\"),\n iterations: literal(600_000),\n salt: str(128),\n sealedBek: str(MAX_FACTOR_CHARS),\n }),\n);\n\nexport const backupEnvelope: Validator<BackupEnvelopeWire> = obj({\n version: literal(1),\n createdAt: int(0, Number.MAX_SAFE_INTEGER),\n header: str(MAX_STRING_BYTES),\n factors: arr(backupEnvelopeFactor, 5, 1),\n payload: str(MAX_PAYLOAD_CHARS),\n});\n\nexport type BackupHeaderWallet = {\n readonly walletId: string;\n readonly origin: \"mnemonic\" | \"passkey\";\n readonly words: 12 | 15 | 18 | 21 | 24;\n /** The wallet has a BIP-39 passphrase; it is never part of the payload. */\n readonly passphrase?: true;\n};\n\nexport type BackupHeaderKey = {\n readonly keyId: string;\n readonly family: \"evm\" | \"solana\" | \"bitcoin\";\n};\n\nexport type BackupHeaderWire = {\n readonly wallets: ReadonlyArray<BackupHeaderWallet>;\n /** Imported keys carried by the payload; absent when there are none. */\n readonly keys?: ReadonlyArray<BackupHeaderKey>;\n};\n\nexport const backupHeader: Validator<BackupHeaderWire> = obj({\n wallets: arr(\n obj({\n walletId: str(128),\n origin: union(literal(\"mnemonic\"), literal(\"passkey\")),\n words: union(literal(12), literal(15), literal(18), literal(21), literal(24)),\n passphrase: opt(literal(true)),\n }),\n 1000,\n ),\n keys: opt(\n arr(\n obj({\n keyId: str(16, /^[0-9a-f]{16}$/),\n family: union(literal(\"evm\"), literal(\"solana\"), literal(\"bitcoin\")),\n }),\n 256,\n ),\n ),\n});\n\n/** The whole-envelope text bound — `backup.update` results and `backup.restore` params use it. */\nexport const backupEnvelopeText: Validator<string> = str(MAX_ENVELOPE_CHARS);\n\n/** The status/snapshot summary of a retained backup key — public data only. */\nexport type BackupInfo = {\n readonly id: string; // 32 lowercase hex, HKDF over the BEK\n readonly factors: ReadonlyArray<\"passkey\" | \"password\">;\n readonly createdAt: number;\n};\n\nexport const backupInfo: Validator<BackupInfo> = obj({\n id: str(32, /^[0-9a-f]{32}$/),\n factors: arr(union(literal(\"passkey\"), literal(\"password\")), 5, 1),\n createdAt: safeTime,\n});\n","/**\n * The chains module's method table and wire validators. `wallet.accounts` derives the public\n * account for a template at the wallet's group index — the EVM/Solana arm returns the address; the\n * Bitcoin arm returns the account-level extended public key plus the master fingerprint and account\n * path (both needed to build the PSBT `bip32Derivation` entries later). The protocol is free of\n *\n * @qntx/wallet-chains imports; template names and path shapes are declared here.\n */\nimport type { Factor, MethodSpec } from \"./core.ts\";\nimport { factor, groupIndex, walletId } from \"./core.ts\";\nimport type { Validator } from \"./validate.ts\";\nimport { arr, bytes, int, literal, obj, opt, str, union } from \"./validate.ts\";\n\nexport type ChainTemplate =\n | \"evm.bip44\"\n | \"solana.bip44-change\"\n | \"btc.bip44\"\n | \"btc.bip49\"\n | \"btc.bip84\"\n | \"btc.bip86\";\n\nexport type ChainAccountsParams = {\n readonly walletId: string;\n readonly groupIndex: number;\n readonly template: ChainTemplate;\n readonly network: string;\n};\n\nexport type ChainAccount =\n | {\n readonly template: \"evm.bip44\";\n readonly network: string;\n readonly address: string;\n }\n | {\n readonly template: \"solana.bip44-change\";\n readonly network: string;\n readonly address: string;\n }\n | {\n readonly template: \"btc.bip44\" | \"btc.bip49\" | \"btc.bip84\" | \"btc.bip86\";\n readonly network: string;\n readonly xpub: string;\n /** Master-key fingerprint as 8 lowercase hex chars (PSBT bip32Derivation). */\n readonly fingerprint: string;\n /** Account derivation path, e.g. \"m/84'/0'/0'\". */\n readonly path: string;\n };\n\nconst template: Validator<ChainTemplate> = union(\n literal(\"evm.bip44\"),\n literal(\"solana.bip44-change\"),\n union(literal(\"btc.bip44\"), literal(\"btc.bip49\"), literal(\"btc.bip84\")),\n literal(\"btc.bip86\"),\n);\n\nconst btcTemplate = union(\n literal(\"btc.bip44\"),\n literal(\"btc.bip49\"),\n literal(\"btc.bip84\"),\n literal(\"btc.bip86\"),\n);\n\nconst caip2: Validator<string> = str(200, /^[a-z0-9-]{3,64}:[0-9a-zA-Z-]{1,128}$/);\nconst addressResult = (t: \"evm.bip44\" | \"solana.bip44-change\"): Validator<ChainAccount> =>\n obj({\n template: literal(t),\n network: caip2,\n address: str(128, /^[0-9a-zA-Z-]{20,128}$/),\n });\n\nexport type AccountRef =\n | {\n readonly kind: \"hd\";\n readonly walletId: string;\n readonly groupIndex: number;\n readonly template: ChainTemplate;\n }\n | {\n readonly kind: \"imported\";\n readonly keyId: string;\n readonly family: \"evm\" | \"solana\" | \"bitcoin\";\n };\n\nexport type EvmAccessListEntryWire = {\n readonly address: string;\n readonly storageKeys: ReadonlyArray<string>;\n};\n\ntype EvmTransactionBase = {\n readonly chainId: number;\n readonly nonce: number;\n readonly gas: string;\n readonly value: string;\n readonly data: string;\n readonly to?: string;\n};\n\nexport type EvmTransactionWire =\n | (EvmTransactionBase & { readonly type: \"legacy\"; readonly gasPrice: string })\n | (EvmTransactionBase & {\n readonly type: \"eip2930\";\n readonly gasPrice: string;\n readonly accessList: ReadonlyArray<EvmAccessListEntryWire>;\n })\n | (EvmTransactionBase & {\n readonly type: \"eip1559\";\n readonly maxFeePerGas: string;\n readonly maxPriorityFeePerGas: string;\n readonly accessList: ReadonlyArray<EvmAccessListEntryWire>;\n })\n | (EvmTransactionBase & {\n readonly type: \"eip7702\";\n readonly to: string;\n readonly maxFeePerGas: string;\n readonly maxPriorityFeePerGas: string;\n readonly accessList: ReadonlyArray<EvmAccessListEntryWire>;\n readonly authorization: { readonly address: string };\n });\n\n/** `chain.sign`'s request — the wire mirror of @qntx/wallet-chains `SignRequest`. */\nexport type ChainSignRequest =\n | {\n readonly kind: \"evm.transaction\";\n readonly network: string;\n readonly account: AccountRef;\n readonly tx: EvmTransactionWire;\n }\n | {\n readonly kind: \"evm.personal-message\";\n readonly network: string;\n readonly account: AccountRef;\n readonly message: Uint8Array;\n }\n | {\n readonly kind: \"evm.typed-data\";\n readonly network: string;\n readonly account: AccountRef;\n readonly typedData: string;\n }\n | {\n readonly kind: \"solana.transaction\";\n readonly network: string;\n readonly account: AccountRef;\n readonly message: Uint8Array;\n readonly lookupTables?: ReadonlyArray<{\n readonly address: string;\n readonly addresses: ReadonlyArray<string>;\n }>;\n }\n | {\n readonly kind: \"solana.message\";\n readonly network: string;\n readonly account: AccountRef;\n readonly message: Uint8Array;\n readonly format: \"raw\";\n }\n | {\n readonly kind: \"bitcoin.psbt\";\n readonly network: string;\n /** The wallet group whose keys sign; each signed input names its template. */\n readonly account: {\n readonly kind: \"hd\";\n readonly walletId: string;\n readonly groupIndex: number;\n };\n readonly psbt: Uint8Array;\n readonly sign: ReadonlyArray<{\n readonly index: number;\n readonly template: \"btc.bip44\" | \"btc.bip49\" | \"btc.bip84\" | \"btc.bip86\";\n }>;\n }\n | {\n readonly kind: \"bitcoin.message\";\n readonly network: string;\n readonly account: AccountRef;\n readonly address: string;\n readonly message: string;\n readonly format: \"bip322-simple\" | \"legacy\";\n readonly change: 0 | 1;\n readonly index: number;\n };\n\nexport type ChainSignResult =\n | { readonly kind: \"evm.transaction\"; readonly signedTransaction: Uint8Array }\n | { readonly kind: \"evm.personal-message\" | \"evm.typed-data\"; readonly signature: Uint8Array }\n | { readonly kind: \"solana.transaction\" | \"solana.message\"; readonly signature: Uint8Array }\n | { readonly kind: \"bitcoin.psbt\"; readonly signedPsbt: Uint8Array }\n | { readonly kind: \"bitcoin.message\"; readonly signature: string };\n\nexport type ChainSignParams = { readonly request: ChainSignRequest; readonly verify: Factor };\n\nconst accountRef: Validator<AccountRef> = union(\n obj({ kind: literal(\"hd\"), walletId, groupIndex, template }),\n obj({\n kind: literal(\"imported\"),\n keyId: str(64, /^[0-9a-f]{8,64}$/),\n family: union(literal(\"evm\"), literal(\"solana\"), literal(\"bitcoin\")),\n }),\n);\n\nconst hexQuantity = str(66, /^0x[0-9a-fA-F]+$/);\nconst hexData = str(40000, /^0x[0-9a-fA-F]*$/);\nconst evmAddress = str(42, /^0x[0-9a-fA-F]{40}$/);\nconst solanaAddress = str(44, /^[1-9A-HJ-NP-Za-km-z]{32,44}$/);\nconst bitcoinAddress = str(90, /^(bc1|tb1|bcrt1|[13mn2])[a-zA-Z0-9]{4,87}$/);\nconst safeInt = int(0, 9007199254740991);\nconst accessList = arr(\n obj({ address: evmAddress, storageKeys: arr(str(66, /^0x[0-9a-fA-F]{64}$/), 256) }),\n 256,\n);\nconst txBase = {\n chainId: safeInt,\n nonce: safeInt,\n gas: hexQuantity,\n value: hexQuantity,\n data: hexData,\n to: opt(evmAddress),\n};\nconst evmTx: Validator<EvmTransactionWire> = union(\n obj({ ...txBase, type: literal(\"legacy\"), gasPrice: hexQuantity }),\n obj({ ...txBase, type: literal(\"eip2930\"), gasPrice: hexQuantity, accessList }),\n obj({\n ...txBase,\n type: literal(\"eip1559\"),\n maxFeePerGas: hexQuantity,\n maxPriorityFeePerGas: hexQuantity,\n accessList,\n }),\n obj({\n ...txBase,\n type: literal(\"eip7702\"),\n to: evmAddress,\n maxFeePerGas: hexQuantity,\n maxPriorityFeePerGas: hexQuantity,\n accessList,\n authorization: obj({ address: evmAddress }),\n }),\n);\n\nconst signRequest: Validator<ChainSignRequest> = union(\n obj({ kind: literal(\"evm.transaction\"), network: caip2, account: accountRef, tx: evmTx }),\n obj({\n kind: literal(\"evm.personal-message\"),\n network: caip2,\n account: accountRef,\n message: bytes(0, 65536),\n }),\n obj({\n kind: literal(\"evm.typed-data\"),\n network: caip2,\n account: accountRef,\n typedData: str(1048576),\n }),\n obj({\n kind: literal(\"solana.transaction\"),\n network: caip2,\n account: accountRef,\n message: bytes(1, 1232),\n lookupTables: opt(arr(obj({ address: solanaAddress, addresses: arr(solanaAddress, 256) }), 64)),\n }),\n obj({\n kind: literal(\"solana.message\"),\n network: caip2,\n account: accountRef,\n message: bytes(1, 65536),\n format: literal(\"raw\"),\n }),\n obj({\n kind: literal(\"bitcoin.psbt\"),\n network: caip2,\n account: obj({ kind: literal(\"hd\"), walletId, groupIndex }),\n psbt: bytes(1, 131072),\n sign: arr(obj({ index: int(0, 1024), template: btcTemplate }), 1024),\n }),\n obj({\n kind: literal(\"bitcoin.message\"),\n network: caip2,\n account: accountRef,\n address: bitcoinAddress,\n message: str(1048576),\n format: union(literal(\"bip322-simple\"), literal(\"legacy\")),\n change: union(literal(0), literal(1)),\n index: int(0, 2147483647),\n }),\n);\n\nconst signResult: Validator<ChainSignResult> = union(\n obj({ kind: literal(\"evm.transaction\"), signedTransaction: bytes(1, 65536) }),\n obj({\n kind: union(literal(\"evm.personal-message\"), literal(\"evm.typed-data\")),\n signature: bytes(65, 65),\n }),\n obj({\n kind: union(literal(\"solana.transaction\"), literal(\"solana.message\")),\n signature: bytes(64, 64),\n }),\n obj({ kind: literal(\"bitcoin.psbt\"), signedPsbt: bytes(1, 131072) }),\n obj({ kind: literal(\"bitcoin.message\"), signature: str(512) }),\n);\n\nexport const CHAINS_METHODS: {\n readonly \"wallet.accounts\": MethodSpec<ChainAccountsParams, ChainAccount>;\n readonly \"chain.sign\": MethodSpec<ChainSignParams, ChainSignResult>;\n} = {\n \"wallet.accounts\": {\n session: true,\n presence: false,\n params: obj({ walletId, groupIndex, template, network: caip2 }),\n result: union(\n addressResult(\"evm.bip44\"),\n addressResult(\"solana.bip44-change\"),\n obj({\n template: union(\n literal(\"btc.bip44\"),\n literal(\"btc.bip49\"),\n literal(\"btc.bip84\"),\n literal(\"btc.bip86\"),\n ),\n network: caip2,\n xpub: str(111, /^[a-zA-Z0-9]{111}$/),\n fingerprint: str(8, /^[0-9a-f]{8}$/),\n path: str(11, /^m\\/[0-9'/]+$/),\n }),\n ),\n },\n \"chain.sign\": {\n session: true,\n presence: true,\n params: obj({ request: signRequest, verify: factor }),\n result: signResult,\n },\n};\n","/**\n * The nostr module's method table and wire validators. The protocol stays free of @qntx/nostr\n * imports — even types — so the event shapes it validates are declared here structurally; a\n * type-level test in packages/wallet/tests pins them assignable to and from @qntx/nostr's\n * Event/UnsignedEvent/Rumor.\n */\nimport type { DerivedNostrKey, NostrKeyInfo, WalletErrorCode } from \"../types.ts\";\nimport {\n factor,\n identityIndex,\n MAX_BATCH,\n MAX_SNAPSHOT_ITEMS,\n MAX_TAG_ITEM,\n MAX_TAG_ITEMS,\n MAX_TAGS,\n MAX_TEXT,\n publicKey,\n safeTime,\n walletErrorCode,\n walletId,\n} from \"./core.ts\";\nimport type { Factor, MethodSpec } from \"./core.ts\";\nimport type { NullValue, Validator } from \"./validate.ts\";\nimport { arr, bytes, int, literal, nullValue, obj, opt, str, union } from \"./validate.ts\";\n\n/**\n * The unsigned event input the kernel signs. `pubkey` is optional: callers may omit it and the\n * kernel fills the signing key's own. Structurally compatible with @qntx/nostr's UnsignedEvent.\n */\nexport type UnsignedEventInput = {\n readonly kind: number;\n readonly created_at: number;\n readonly tags: ReadonlyArray<ReadonlyArray<string>>;\n readonly content: string;\n readonly pubkey?: string;\n};\n\n/** The signed event the kernel returns — the Nostr event minus `id`-less forms. */\nexport type SignedEvent = {\n readonly id: string;\n readonly pubkey: string;\n readonly sig: string;\n readonly kind: number;\n readonly created_at: number;\n readonly tags: ReadonlyArray<ReadonlyArray<string>>;\n readonly content: string;\n};\n\n/** A NIP-59 rumor: an unsigned event carrying a computed `id` but no `sig`. */\nexport type Rumor = {\n readonly id: string;\n readonly pubkey: string;\n readonly kind: number;\n readonly created_at: number;\n readonly tags: ReadonlyArray<ReadonlyArray<string>>;\n readonly content: string;\n};\n\nexport type NostrExportFormat =\n | { readonly kind: \"nsec\" }\n | { readonly kind: \"ncryptsec\"; readonly password: Uint8Array };\n\nexport type UnwrapResult = { readonly ok: Rumor } | { readonly err: WalletErrorCode };\n\nconst hex128: Validator<string> = str(128, /^[0-9a-f]{128}$/);\n\nconst nostrKeyRef = obj({ kind: literal(\"derived\"), walletId, index: identityIndex });\n\nexport const nostrKeyInfo: Validator<NostrKeyInfo> = obj({\n ref: nostrKeyRef,\n publicKey,\n createdAt: safeTime,\n});\n\n/** The nostr section of the status payload, composed by protocol/index.ts. */\nexport const nostrStatus: Validator<{ readonly keys: ReadonlyArray<NostrKeyInfo> }> = obj({\n keys: arr(nostrKeyInfo, MAX_SNAPSHOT_ITEMS),\n});\n\nconst derivedNostrKey: Validator<DerivedNostrKey> = obj({ index: identityIndex, publicKey });\n\nconst tags: Validator<ReadonlyArray<ReadonlyArray<string>>> = arr(\n arr(str(MAX_TAG_ITEM), MAX_TAG_ITEMS),\n MAX_TAGS,\n);\n\nconst signEventInput: Validator<UnsignedEventInput> = obj({\n kind: int(0, 65535),\n created_at: safeTime,\n tags,\n content: str(MAX_TEXT),\n pubkey: opt(publicKey),\n});\n\nconst signedEvent: Validator<SignedEvent> = obj({\n id: publicKey,\n pubkey: publicKey,\n sig: hex128,\n kind: int(0, 65535),\n created_at: safeTime,\n tags,\n content: str(MAX_TEXT),\n});\n\nconst rumor: Validator<Rumor> = obj({\n id: publicKey,\n pubkey: publicKey,\n kind: int(0, 65535),\n created_at: safeTime,\n tags,\n content: str(MAX_TEXT),\n});\n\nconst nostrExportFormat: Validator<NostrExportFormat> = union(\n obj({ kind: literal(\"nsec\") }),\n obj({ kind: literal(\"ncryptsec\"), password: bytes(1, 1024) }),\n);\n\nconst textParams = obj({ publicKey, peer: publicKey, text: str(MAX_TEXT) });\nconst textResult = str(MAX_TEXT * 4);\n\nexport const NOSTR_METHODS: {\n readonly \"nostr.discover\": MethodSpec<\n { readonly walletId: string; readonly from: number; readonly count: number },\n { readonly keys: ReadonlyArray<DerivedNostrKey> }\n >;\n readonly \"nostr.deriveKey\": MethodSpec<\n { readonly walletId: string; readonly index: number },\n NostrKeyInfo\n >;\n readonly \"nostr.removeKey\": MethodSpec<{ readonly publicKey: string }, NullValue>;\n readonly \"nostr.exportKey\": MethodSpec<\n { readonly verify: Factor; readonly publicKey: string; readonly format: NostrExportFormat },\n Uint8Array\n >;\n readonly \"nostr.signEvent\": MethodSpec<\n { readonly publicKey: string; readonly event: UnsignedEventInput },\n SignedEvent\n >;\n readonly \"nostr.nip04Encrypt\": MethodSpec<\n { readonly publicKey: string; readonly peer: string; readonly text: string },\n string\n >;\n readonly \"nostr.nip04Decrypt\": MethodSpec<\n { readonly publicKey: string; readonly peer: string; readonly text: string },\n string\n >;\n readonly \"nostr.nip44Encrypt\": MethodSpec<\n { readonly publicKey: string; readonly peer: string; readonly text: string },\n string\n >;\n readonly \"nostr.nip44Decrypt\": MethodSpec<\n { readonly publicKey: string; readonly peer: string; readonly text: string },\n string\n >;\n readonly \"nostr.syncKey\": MethodSpec<\n { readonly walletId: string },\n { readonly publicKey: string }\n >;\n readonly \"nostr.syncSign\": MethodSpec<\n { readonly walletId: string; readonly event: UnsignedEventInput },\n SignedEvent\n >;\n readonly \"nostr.syncEncrypt\": MethodSpec<\n { readonly walletId: string; readonly text: string },\n string\n >;\n readonly \"nostr.syncDecrypt\": MethodSpec<\n { readonly walletId: string; readonly text: string },\n string\n >;\n readonly \"nostr.unwrapGiftWraps\": MethodSpec<\n { readonly publicKey: string; readonly events: ReadonlyArray<SignedEvent> },\n { readonly results: ReadonlyArray<UnwrapResult> }\n >;\n} = {\n \"nostr.discover\": {\n session: true,\n presence: false,\n params: obj({ walletId, from: identityIndex, count: int(1, 20) }),\n result: obj({ keys: arr(derivedNostrKey, 20) }),\n },\n \"nostr.deriveKey\": {\n session: true,\n presence: false,\n params: obj({ walletId, index: identityIndex }),\n result: nostrKeyInfo,\n },\n \"nostr.removeKey\": {\n session: true,\n presence: true,\n params: obj({ publicKey }),\n result: nullValue,\n },\n \"nostr.exportKey\": {\n session: true,\n presence: true,\n params: obj({ verify: factor, publicKey, format: nostrExportFormat }),\n result: bytes(16, 4096),\n },\n \"nostr.signEvent\": {\n session: true,\n presence: false,\n params: obj({ publicKey, event: signEventInput }),\n result: signedEvent,\n },\n \"nostr.nip04Encrypt\": { session: true, presence: false, params: textParams, result: textResult },\n \"nostr.nip04Decrypt\": { session: true, presence: false, params: textParams, result: textResult },\n \"nostr.nip44Encrypt\": { session: true, presence: false, params: textParams, result: textResult },\n \"nostr.nip44Decrypt\": { session: true, presence: false, params: textParams, result: textResult },\n \"nostr.unwrapGiftWraps\": {\n session: true,\n presence: false,\n params: obj({ publicKey, events: arr(signedEvent, MAX_BATCH) }),\n result: obj({\n results: arr(union(obj({ ok: rumor }), obj({ err: walletErrorCode })), MAX_BATCH),\n }),\n },\n \"nostr.syncKey\": {\n session: true,\n presence: false,\n params: obj({ walletId }),\n result: obj({ publicKey }),\n },\n \"nostr.syncSign\": {\n session: true,\n presence: false,\n params: obj({ walletId, event: signEventInput }),\n result: signedEvent,\n },\n \"nostr.syncEncrypt\": {\n session: true,\n presence: false,\n params: obj({ walletId, text: str(MAX_TEXT) }),\n result: textResult,\n },\n \"nostr.syncDecrypt\": {\n session: true,\n presence: false,\n params: obj({ walletId, text: str(MAX_TEXT * 4) }),\n result: textResult,\n },\n};\n","/**\n * The spark module's method table and wire validators. The protocol stays free of @qntx/spark\n * imports — even types — so the signer shapes it validates are declared here structurally; a\n * type-level test in packages/wallet/tests pins them assignable to and from @qntx/spark/signer's\n * types.\n *\n * Every method carries `account` — walletId/groupIndex/network — and is session-gated but not\n * presence-bearing (signer work must not hold a session open). List params are capped at MAX_BATCH;\n * the leaf lists of prepareTransfer/prepareClaim are capped at the signer's own 256.\n */\nimport { factor, groupIndex, MAX_BATCH, safeTime, walletId } from \"./core.ts\";\nimport type { Factor, MethodSpec } from \"./core.ts\";\nimport type { Validator } from \"./validate.ts\";\nimport {\n arr,\n bytes,\n int,\n literal,\n obj,\n opt,\n record,\n str,\n union,\n ValidationError,\n} from \"./validate.ts\";\n\n/** The Spark network the account's signer runs on — identical to @qntx/spark's SparkNetwork. */\nexport type SparkNetwork = \"mainnet\" | \"regtest\";\n\n/** The wallet+group+network triple every spark.* request addresses a pooled signer by. */\nexport type SparkAccountRef = {\n readonly walletId: string;\n readonly groupIndex: number;\n readonly network: SparkNetwork;\n};\n\nexport type SparkLeafKey =\n | { readonly type: \"leaf\"; readonly leafId: string }\n | { readonly type: \"static-deposit\"; readonly index: number };\n\nexport type SparkKey =\n | SparkLeafKey\n | { readonly type: \"received\"; readonly ciphertext: Uint8Array };\n\nexport type SigningCommitment = {\n readonly hiding: Uint8Array;\n readonly binding: Uint8Array;\n};\n\nexport type OperatorCommitment = {\n readonly identifier: string;\n readonly commitment: SigningCommitment;\n};\n\nexport type SigningTarget = {\n readonly transaction: Uint8Array;\n readonly inputIndex: number;\n readonly prevouts: ReadonlyArray<{\n script: Uint8Array;\n amount: number;\n }>;\n};\n\nexport type FrostSignJob = {\n readonly key: SparkKey;\n readonly target: SigningTarget;\n readonly verifyingKey: Uint8Array;\n readonly commitment: SigningCommitment;\n readonly operatorCommitments: ReadonlyArray<OperatorCommitment>;\n readonly adaptorPublicKey?: Uint8Array;\n /** Connector-refund proof pair — see `FrostSignJob.exit` in @qntx/spark/signer. */\n readonly exit?: {\n readonly connectorTx: Uint8Array;\n readonly exitTx: Uint8Array;\n };\n};\n\nexport type FrostAggregateJob = {\n readonly key: SparkKey;\n readonly target: SigningTarget;\n readonly verifyingKey: Uint8Array;\n readonly commitment: SigningCommitment;\n readonly signatureShare: Uint8Array;\n readonly operators: ReadonlyArray<{\n readonly identifier: string;\n readonly commitment: SigningCommitment;\n readonly signatureShare: Uint8Array;\n readonly publicKey: Uint8Array;\n }>;\n readonly adaptorPublicKey?: Uint8Array;\n};\n\nexport type StaticDepositClaimStatement = {\n readonly kind: \"static-deposit-claim\";\n readonly network: SparkNetwork;\n readonly txid: Uint8Array;\n readonly vout: number;\n readonly creditAmountSats: number;\n readonly sspSignature: Uint8Array;\n};\n\nexport type IdentityStatement =\n | { readonly kind: \"so-challenge\"; readonly challenge: Uint8Array }\n | { readonly kind: \"ssp-challenge\"; readonly protectedChallenge: string }\n | { readonly kind: \"transfer-package\"; readonly transferId: string; readonly package: Uint8Array }\n | { readonly kind: \"claim-package\"; readonly transferId: string; readonly package: Uint8Array }\n | StaticDepositClaimStatement\n | {\n readonly kind: \"static-deposit-refund\";\n readonly network: SparkNetwork;\n readonly txid: Uint8Array;\n readonly vout: number;\n readonly amount: number;\n readonly target: SigningTarget;\n }\n | {\n readonly kind: \"watchtower-recovery\";\n readonly network: SparkNetwork;\n readonly leafId: string;\n readonly target: SigningTarget;\n }\n | { readonly kind: \"spark-invoice\"; readonly invoice: Uint8Array }\n | { readonly kind: \"token-transaction\"; readonly partialTransaction: Uint8Array }\n | {\n readonly kind: \"lightning-address\";\n readonly action: \"register\";\n readonly domain: string;\n readonly username: string;\n readonly description: string;\n readonly timestamp: number;\n }\n | {\n readonly kind: \"lightning-address\";\n readonly action: \"unregister\";\n readonly domain: string;\n readonly username: string;\n readonly timestamp: number;\n };\n\nexport type PrepareTransferRequest = {\n readonly transferId: string;\n readonly leaves: ReadonlyArray<{\n readonly leafId: string;\n readonly key: SparkLeafKey;\n readonly receiverIdentityPublicKey: Uint8Array;\n }>;\n};\n\nexport type PreparedTransferLeaf = {\n readonly leafId: string;\n readonly newPublicKey: Uint8Array;\n readonly secretCipher: Uint8Array;\n readonly signature: Uint8Array;\n};\n\nexport type PreparedTransfer = {\n readonly operatorPackages: Record<string, Uint8Array>;\n readonly leaves: ReadonlyArray<PreparedTransferLeaf>;\n};\n\nexport type PrepareClaimRequest = {\n readonly transferId: string;\n readonly leaves: ReadonlyArray<{\n readonly leafId: string;\n readonly secretCipher: Uint8Array;\n }>;\n};\n\nexport type PreparedClaim = {\n readonly operatorPackages: Record<string, Uint8Array>;\n};\n\nexport type PreparedLightningReceive = {\n readonly paymentHash: Uint8Array;\n readonly operatorPackages: Record<string, Uint8Array>;\n};\n\nexport type HtlcTimeoutSignRequest = {\n readonly transaction: Uint8Array;\n readonly inputIndex: number;\n readonly prevoutAmountSats: number;\n readonly paymentHash: Uint8Array;\n readonly hashLockPublicKey: Uint8Array;\n};\n\nexport type StaticDepositClaimRequest = {\n readonly index: number;\n readonly statement: StaticDepositClaimStatement;\n};\n\nexport type StaticDepositClaimResult = {\n readonly encryptedSecretKey: Uint8Array;\n readonly signature: Uint8Array;\n};\n\n// Field bounds. Where @qntx/spark/signer constrains a value the same rule is mirrored (64-hex\n// identifiers, 32/33/64-byte keys and signatures, 1..MAX_BATCH counts); where it leaves a value\n// unbounded (leafId/transferId are hashed as UTF-8, ciphertexts and protobuf blobs are bytes) the\n// protocol still needs a size — the MAX_REQUEST_BYTES envelope cap makes these generous bounds\n// sufficient rather than security-critical.\nconst MAX_LEAVES = 256;\nconst MAX_OPERATORS = 16;\nconst MAX_PACKAGE_BYTES = 1_048_576;\nconst MAX_TX_BYTES = 1_048_576;\nconst MAX_PREVOUTS = 1024;\nconst MAX_SCRIPT_BYTES = 16_384;\nconst MAX_CIPHERTEXT_BYTES = 4096;\nconst MAX_SATS = 2_100_000_000_000_000; // 21M BTC in sats\n\nconst network: Validator<SparkNetwork> = union(literal(\"mainnet\"), literal(\"regtest\"));\nconst account: Validator<SparkAccountRef> = obj({ walletId, groupIndex, network });\n\nconst identifier: Validator<string> = str(64, /^[0-9a-f]{64}$/);\nconst leafId: Validator<string> = str(64);\nconst transferId: Validator<string> = str(64);\nconst bytes32: Validator<Uint8Array> = bytes(32);\nconst bytes33: Validator<Uint8Array> = bytes(33);\nconst bytes64: Validator<Uint8Array> = bytes(64);\nconst ciphertext: Validator<Uint8Array> = bytes(1, MAX_CIPHERTEXT_BYTES);\nconst sats: Validator<number> = int(0, MAX_SATS);\n\nconst sparkLeafKey: Validator<SparkLeafKey> = union(\n obj({ type: literal(\"leaf\"), leafId }),\n obj({ type: literal(\"static-deposit\"), index: int(0, 0x7fffffff) }),\n);\n\nconst sparkKey: Validator<SparkKey> = union(\n obj({ type: literal(\"leaf\"), leafId }),\n obj({ type: literal(\"static-deposit\"), index: int(0, 0x7fffffff) }),\n obj({ type: literal(\"received\"), ciphertext }),\n);\n\nconst signingCommitment: Validator<SigningCommitment> = obj({\n hiding: bytes33,\n binding: bytes33,\n});\n\nconst operatorCommitment: Validator<OperatorCommitment> = obj({\n identifier,\n commitment: signingCommitment,\n});\n\nconst signingTarget: Validator<SigningTarget> = obj({\n transaction: bytes(1, MAX_TX_BYTES),\n inputIndex: int(0, 0x7fffffff),\n prevouts: arr(obj({ script: bytes(0, MAX_SCRIPT_BYTES), amount: sats }), MAX_PREVOUTS),\n});\n\nconst adaptorPublicKey = opt(union(bytes(0), bytes(33)));\n\nconst frostSignJob: Validator<FrostSignJob> = obj({\n key: sparkKey,\n target: signingTarget,\n verifyingKey: bytes33,\n commitment: signingCommitment,\n operatorCommitments: arr(operatorCommitment, MAX_OPERATORS),\n adaptorPublicKey,\n});\n\nconst frostAggregateJob: Validator<FrostAggregateJob> = obj({\n key: sparkKey,\n target: signingTarget,\n verifyingKey: bytes33,\n commitment: signingCommitment,\n signatureShare: bytes32,\n operators: arr(\n obj({\n identifier,\n commitment: signingCommitment,\n signatureShare: bytes32,\n publicKey: bytes33,\n }),\n MAX_OPERATORS,\n ),\n adaptorPublicKey,\n});\n\nconst staticDepositClaimStatement: Validator<StaticDepositClaimStatement> = obj({\n kind: literal(\"static-deposit-claim\"),\n network,\n txid: bytes32,\n vout: int(0, 0x7fffffff),\n creditAmountSats: sats,\n sspSignature: bytes(1, 1024),\n});\n\nconst identityStatement: Validator<IdentityStatement> = union(\n obj({ kind: literal(\"so-challenge\"), challenge: bytes(1, 4096) }),\n obj({ kind: literal(\"ssp-challenge\"), protectedChallenge: str(8192) }),\n obj({\n kind: literal(\"transfer-package\"),\n transferId,\n package: bytes(1, MAX_PACKAGE_BYTES),\n }),\n obj({\n kind: literal(\"claim-package\"),\n transferId,\n package: bytes(1, MAX_PACKAGE_BYTES),\n }),\n staticDepositClaimStatement,\n obj({\n kind: literal(\"static-deposit-refund\"),\n network,\n txid: bytes32,\n vout: int(0, 0x7fffffff),\n amount: sats,\n target: signingTarget,\n }),\n obj({\n kind: literal(\"watchtower-recovery\"),\n network,\n leafId,\n target: signingTarget,\n }),\n obj({ kind: literal(\"spark-invoice\"), invoice: bytes(1, 65_536) }),\n obj({ kind: literal(\"token-transaction\"), partialTransaction: bytes(1, MAX_PACKAGE_BYTES) }),\n obj({\n kind: literal(\"lightning-address\"),\n action: literal(\"register\"),\n domain: str(253),\n username: str(64, /^[a-z0-9\\-_.+]{1,64}$/u),\n description: str(512),\n timestamp: safeTime,\n }),\n obj({\n kind: literal(\"lightning-address\"),\n action: literal(\"unregister\"),\n domain: str(253),\n username: str(64, /^[a-z0-9\\-_.+]{1,64}$/u),\n timestamp: safeTime,\n }),\n);\n\nconst htlcTimeoutRequest: Validator<HtlcTimeoutSignRequest> = obj({\n transaction: bytes(1, MAX_TX_BYTES),\n inputIndex: int(0, 0x7fffffff),\n prevoutAmountSats: sats,\n paymentHash: bytes32,\n hashLockPublicKey: bytes33,\n});\n\nconst prepareTransferRequest: Validator<PrepareTransferRequest> = obj({\n transferId,\n leaves: arr(\n obj({ leafId, key: sparkLeafKey, receiverIdentityPublicKey: bytes33 }),\n MAX_LEAVES,\n 1,\n ),\n});\n\nconst preparedTransfer: Validator<PreparedTransfer> = obj({\n operatorPackages: record(identifier, bytes(1, MAX_PACKAGE_BYTES), MAX_OPERATORS),\n leaves: arr(\n obj({\n leafId,\n newPublicKey: bytes33,\n secretCipher: ciphertext,\n signature: bytes64,\n }),\n MAX_LEAVES,\n ),\n});\n\nconst prepareClaimRequest: Validator<PrepareClaimRequest> = obj({\n transferId,\n leaves: arr(obj({ leafId, secretCipher: ciphertext }), MAX_LEAVES, 1),\n});\n\nconst preparedClaim: Validator<PreparedClaim> = obj({\n operatorPackages: record(identifier, bytes(1, MAX_PACKAGE_BYTES), MAX_OPERATORS),\n});\n\nconst preparedLightningReceive: Validator<PreparedLightningReceive> = obj({\n paymentHash: bytes32,\n operatorPackages: record(identifier, bytes(1, MAX_PACKAGE_BYTES), MAX_OPERATORS),\n});\n\nconst staticDepositClaimRequest: Validator<StaticDepositClaimRequest> = obj({\n index: int(0, 0x7fffffff),\n statement: staticDepositClaimStatement,\n});\n\nconst staticDepositClaimResult: Validator<StaticDepositClaimResult> = obj({\n encryptedSecretKey: bytes(1, MAX_CIPHERTEXT_BYTES),\n signature: bytes(64, 128),\n});\n\n/**\n * The intent a `spark.approve` registers — kernel-decoded before the host ever displays it. `token`\n * receivers' amounts are canonical decimal strings in the u128 range.\n */\ntype SparkOutflowIntent =\n | {\n readonly kind: \"exit\";\n readonly address: string;\n readonly amountSats: number;\n readonly maxFeeSats: number;\n }\n | {\n readonly kind: \"onchain\";\n readonly address: string;\n readonly maxFeeSats: number;\n }\n | {\n readonly kind: \"token\";\n readonly tokenIdentifier: Uint8Array;\n readonly receivers: ReadonlyArray<{\n readonly ownerPublicKey: Uint8Array;\n readonly amount: string;\n }>;\n };\n\nexport type SparkApproveIntent =\n | {\n readonly kind: \"transfer\";\n readonly receivers: ReadonlyArray<{\n readonly identityPublicKey: Uint8Array;\n readonly amountSats: number;\n }>;\n }\n | {\n readonly kind: \"lightning\";\n readonly invoice: string;\n readonly amountSats?: number;\n readonly maxFeeSats: number;\n }\n | SparkOutflowIntent;\n\n/**\n * What `spark.approve` returns: the kernel's own decode of the intent — receivers and amounts, the\n * invoice's payment hash and amount, or the exit/onchain destination — never host-provided text.\n */\nexport type SparkApprovalSummary =\n | {\n readonly kind: \"transfer\";\n readonly receivers: ReadonlyArray<{\n readonly identityPublicKey: Uint8Array;\n readonly amountSats: number;\n }>;\n }\n | {\n readonly kind: \"lightning\";\n readonly paymentHash: Uint8Array;\n readonly invoiceAmountSats?: number;\n readonly maxFeeSats: number;\n }\n | SparkOutflowIntent;\n\n// sats amounts are bounded by the protocol's safe-integer contract; u128 token amounts\n// travel as canonical decimal strings.\nconst satsAmount = (): Validator<number> => int(0, Number.MAX_SAFE_INTEGER);\nconst U128_MAX = 340282366920938463463374607431768211455n;\n// Canonical decimal u128: \"0\" or no leading zeros, at most 2^128 − 1.\nconst decimalU128: Validator<string> = (value) => {\n if (\n typeof value !== \"string\" ||\n value.length > 39 ||\n !/^(?:0|[1-9][0-9]*)$/.test(value) ||\n BigInt(value) > U128_MAX\n ) {\n throw new ValidationError();\n }\n return value;\n};\nconst outflowIntents = [\n obj({\n kind: literal(\"exit\"),\n address: str(128),\n amountSats: satsAmount(),\n maxFeeSats: satsAmount(),\n }),\n obj({\n kind: literal(\"onchain\"),\n address: str(128),\n maxFeeSats: satsAmount(),\n }),\n obj({\n kind: literal(\"token\"),\n tokenIdentifier: bytes(32),\n receivers: arr(obj({ ownerPublicKey: bytes(33), amount: decimalU128 }), 256, 1),\n }),\n] as const;\n\nconst approveIntent: Validator<SparkApproveIntent> = union(\n obj({\n kind: literal(\"transfer\"),\n receivers: arr(obj({ identityPublicKey: bytes(33), amountSats: satsAmount() }), 256, 1),\n }),\n obj({\n kind: literal(\"lightning\"),\n invoice: str(4096),\n amountSats: opt(satsAmount()),\n maxFeeSats: satsAmount(),\n }),\n ...outflowIntents,\n);\n\nconst approvalSummary: Validator<SparkApprovalSummary> = union(\n obj({\n kind: literal(\"transfer\"),\n receivers: arr(obj({ identityPublicKey: bytes(33), amountSats: satsAmount() }), 256, 1),\n }),\n obj({\n kind: literal(\"lightning\"),\n paymentHash: bytes(32),\n invoiceAmountSats: opt(satsAmount()),\n maxFeeSats: satsAmount(),\n }),\n ...outflowIntents,\n);\n\nexport const SPARK_METHODS: {\n readonly \"spark.identityPublicKey\": MethodSpec<{ readonly account: SparkAccountRef }, Uint8Array>;\n readonly \"spark.publicKeys\": MethodSpec<\n { readonly account: SparkAccountRef; readonly keys: ReadonlyArray<SparkLeafKey> },\n ReadonlyArray<Uint8Array>\n >;\n readonly \"spark.receivedPublicKeys\": MethodSpec<\n { readonly account: SparkAccountRef; readonly ciphertexts: ReadonlyArray<Uint8Array> },\n ReadonlyArray<Uint8Array>\n >;\n readonly \"spark.newCommitments\": MethodSpec<\n { readonly account: SparkAccountRef; readonly count: number },\n ReadonlyArray<SigningCommitment>\n >;\n readonly \"spark.signFrost\": MethodSpec<\n { readonly account: SparkAccountRef; readonly jobs: ReadonlyArray<FrostSignJob> },\n ReadonlyArray<Uint8Array>\n >;\n readonly \"spark.aggregateFrost\": MethodSpec<\n { readonly account: SparkAccountRef; readonly jobs: ReadonlyArray<FrostAggregateJob> },\n ReadonlyArray<Uint8Array>\n >;\n readonly \"spark.signIdentity\": MethodSpec<\n { readonly account: SparkAccountRef; readonly statement: IdentityStatement },\n Uint8Array\n >;\n readonly \"spark.signKeySpend\": MethodSpec<\n {\n readonly account: SparkAccountRef;\n readonly key: SparkKey;\n readonly target: SigningTarget;\n },\n Uint8Array\n >;\n readonly \"spark.signHtlcTimeout\": MethodSpec<\n { readonly account: SparkAccountRef; readonly request: HtlcTimeoutSignRequest },\n Uint8Array\n >;\n readonly \"spark.prepareTransfer\": MethodSpec<\n { readonly account: SparkAccountRef; readonly request: PrepareTransferRequest },\n PreparedTransfer\n >;\n readonly \"spark.prepareClaim\": MethodSpec<\n { readonly account: SparkAccountRef; readonly request: PrepareClaimRequest },\n PreparedClaim\n >;\n readonly \"spark.prepareLightningReceive\": MethodSpec<\n { readonly account: SparkAccountRef },\n PreparedLightningReceive\n >;\n readonly \"spark.claimStaticDeposit\": MethodSpec<\n { readonly account: SparkAccountRef; readonly request: StaticDepositClaimRequest },\n StaticDepositClaimResult\n >;\n readonly \"spark.approve\": MethodSpec<\n {\n readonly account: SparkAccountRef;\n readonly intent: SparkApproveIntent;\n readonly verify: Factor;\n },\n SparkApprovalSummary\n >;\n} = {\n \"spark.identityPublicKey\": {\n session: true,\n presence: false,\n params: obj({ account }),\n result: bytes33,\n },\n \"spark.publicKeys\": {\n session: true,\n presence: false,\n params: obj({ account, keys: arr(sparkLeafKey, MAX_BATCH) }),\n result: arr(bytes33, MAX_BATCH),\n },\n \"spark.receivedPublicKeys\": {\n session: true,\n presence: false,\n params: obj({ account, ciphertexts: arr(ciphertext, MAX_BATCH) }),\n result: arr(bytes33, MAX_BATCH),\n },\n \"spark.newCommitments\": {\n session: true,\n presence: false,\n params: obj({ account, count: int(1, MAX_BATCH) }),\n result: arr(signingCommitment, MAX_BATCH),\n },\n \"spark.signFrost\": {\n session: true,\n presence: false,\n params: obj({ account, jobs: arr(frostSignJob, MAX_BATCH) }),\n result: arr(bytes32, MAX_BATCH),\n },\n \"spark.aggregateFrost\": {\n session: true,\n presence: false,\n params: obj({ account, jobs: arr(frostAggregateJob, MAX_BATCH) }),\n result: arr(bytes64, MAX_BATCH),\n },\n \"spark.signIdentity\": {\n session: true,\n presence: false,\n params: obj({ account, statement: identityStatement }),\n result: bytes(64, 128),\n },\n \"spark.signKeySpend\": {\n session: true,\n presence: false,\n params: obj({ account, key: sparkKey, target: signingTarget }),\n result: bytes64,\n },\n \"spark.signHtlcTimeout\": {\n session: true,\n presence: false,\n params: obj({ account, request: htlcTimeoutRequest }),\n result: bytes64,\n },\n \"spark.prepareTransfer\": {\n session: true,\n presence: false,\n params: obj({ account, request: prepareTransferRequest }),\n result: preparedTransfer,\n },\n \"spark.prepareClaim\": {\n session: true,\n presence: false,\n params: obj({ account, request: prepareClaimRequest }),\n result: preparedClaim,\n },\n \"spark.prepareLightningReceive\": {\n session: true,\n presence: false,\n params: obj({ account }),\n result: preparedLightningReceive,\n },\n \"spark.claimStaticDeposit\": {\n session: true,\n presence: false,\n params: obj({ account, request: staticDepositClaimRequest }),\n result: staticDepositClaimResult,\n },\n \"spark.approve\": {\n session: true,\n presence: true,\n params: obj({ account, intent: approveIntent, verify: factor }),\n result: approvalSummary,\n },\n};\n","/**\n * Secret-area wire protocol (design/impl/wallet-e0.mdx \"协议与传输\"). Shared by the kernel and the main\n * runtime: the kernel validates every request, the host validates every response. Web/Node carry\n * ProtocolValue via structured clone; the RN host encodes the same values as CBOR.\n *\n * This file is the method-table composition point: `METHODS` spreads the core table\n * (protocol/core.ts) and the nostr module's table (protocol/nostr.ts), and the status result\n * validator composes the core sections with each module's status section.\n */\nimport type { LockReason, StatusPayload, WalletErrorCode } from \"../types.ts\";\nimport { backupInfo } from \"./backup.ts\";\nimport { CHAINS_METHODS } from \"./chains.ts\";\nimport {\n CORE_METHODS,\n factorInfo,\n keyInfo,\n MAX_SNAPSHOT_ITEMS,\n safeTime,\n walletErrorCode,\n walletInfo,\n} from \"./core.ts\";\nimport type { MethodSpec } from \"./core.ts\";\n// oxlint-disable-next-line unicorn/prefer-export-from -- the table is composed locally AND re-exported\nimport { NOSTR_METHODS, nostrStatus } from \"./nostr.ts\";\n// oxlint-disable-next-line unicorn/prefer-export-from -- the table is composed locally AND re-exported\nimport { SPARK_METHODS } from \"./spark.ts\";\nimport { arr, literal, nullValue, obj, opt, str, union } from \"./validate.ts\";\nimport type { NullValue, Validator } from \"./validate.ts\";\n\nexport type { WalletErrorCode } from \"../types.ts\";\n\nexport const PROTOCOL_VERSION = 2;\n\n/**\n * Responses to requests whose `id` cannot be parsed (malformed envelope) carry id 0. Main-side\n * request ids start at 1, so a `0` is never a real pending request.\n */\nexport const UNATTRIBUTED_ID = 0;\n\nexport type { NullValue } from \"./validate.ts\";\n\nexport type ProtocolValue =\n | NullValue\n | boolean\n | number // safe integer\n | string\n | Uint8Array\n | ReadonlyArray<ProtocolValue>\n | { readonly [key: string]: ProtocolValue };\n\nexport type Request = {\n readonly v: typeof PROTOCOL_VERSION;\n readonly id: number;\n readonly method: string;\n readonly session?: string;\n readonly params: ProtocolValue;\n};\n\nexport type ErrorPayload = {\n readonly code: WalletErrorCode;\n readonly retryAt?: number; // only for \"rate-limited\"\n /** Platform diagnostic `\"<domain>:<code>\"` — sanitized at the producer, never free text. */\n readonly detail?: string;\n};\n\nexport type Response =\n | { readonly v: typeof PROTOCOL_VERSION; readonly id: number; readonly ok: ProtocolValue }\n | { readonly v: typeof PROTOCOL_VERSION; readonly id: number; readonly err: ErrorPayload };\n\nexport type KernelEvent =\n | {\n readonly v: typeof PROTOCOL_VERSION;\n readonly event: \"status\";\n readonly status: StatusPayload;\n }\n | { readonly v: typeof PROTOCOL_VERSION; readonly event: \"locked\"; readonly reason: LockReason };\n\n/**\n * The worst-case encoded size of one request, enforced by both sides: the host refuses to post a\n * request over the cap and the kernel answers an oversized raw request with `invalid-input`.\n * Responses are not capped.\n */\nexport const MAX_REQUEST_BYTES = 1_048_576;\n\n/**\n * Upper-bound byte weight of a protocol value: a string costs `length * 3` (worst-case UTF-8), a\n * Uint8Array its `byteLength`, every scalar and every array element 8, and every object key\n * `key.length * 3 + 8` plus its value. Iterative — a deeply nested value cannot overflow the\n * stack.\n */\nexport function requestBytes(value: ProtocolValue): number {\n let total = 0;\n const stack: ProtocolValue[] = [value];\n while (stack.length > 0) {\n const item = stack.pop();\n if (item === undefined) {\n continue;\n }\n if (typeof item === \"string\") {\n total += item.length * 3;\n } else if (item instanceof Uint8Array) {\n total += item.byteLength;\n } else if (item === null || typeof item === \"boolean\" || typeof item === \"number\") {\n total += 8;\n } else if (Array.isArray(item)) {\n // Array.isArray widens the readonly member to any[] — re-annotate the element domain.\n const elements: ReadonlyArray<ProtocolValue> = item;\n total += elements.length * 8;\n for (const element of elements) {\n stack.push(element);\n }\n } else {\n for (const [key, child] of Object.entries(item)) {\n total += key.length * 3 + 8;\n stack.push(child);\n }\n }\n }\n return total;\n}\n\n/** Deep check that a structured-cloned value is a strict ProtocolValue (no cycles detected). */\nexport function isProtocolValue(value: unknown): value is ProtocolValue {\n switch (typeof value) {\n case \"boolean\":\n case \"string\":\n return true;\n case \"number\":\n return Number.isSafeInteger(value);\n case \"object\":\n break;\n default:\n return false;\n }\n if (value === null || value instanceof Uint8Array) {\n return true;\n }\n if (Array.isArray(value)) {\n return value.every(isProtocolValue);\n }\n if (Object.getPrototypeOf(value) !== Object.prototype) {\n return false;\n }\n return Object.values(value).every(isProtocolValue);\n}\n\n/** The status payload: core sections plus one object section per protocol module. */\nconst statusPayload: Validator<StatusPayload> = obj({\n protocol: literal(PROTOCOL_VERSION),\n vault: union(\n literal(\"uninitialized\"),\n literal(\"locked\"),\n literal(\"unlocked\"),\n literal(\"corrupted\"),\n literal(\"unsupported\"),\n literal(\"unavailable\"),\n ),\n factors: arr(factorInfo, MAX_SNAPSHOT_ITEMS),\n wallets: arr(walletInfo, MAX_SNAPSHOT_ITEMS),\n nostr: nostrStatus,\n importedKeys: arr(keyInfo, MAX_SNAPSHOT_ITEMS),\n backup: union(backupInfo, nullValue),\n});\n\n// The explicit annotation is the composition contract: a key missing from either table fails\n// declaration emit, and a duplicated key fails assignability (the spread's type for that key\n// cannot satisfy the intersection).\nexport const METHODS: {\n readonly status: MethodSpec<NullValue, StatusPayload>;\n} & typeof CORE_METHODS &\n typeof NOSTR_METHODS &\n typeof CHAINS_METHODS &\n typeof SPARK_METHODS = {\n status: {\n session: false,\n presence: false,\n params: nullValue,\n result: statusPayload,\n },\n ...CORE_METHODS,\n ...CHAINS_METHODS,\n ...NOSTR_METHODS,\n ...SPARK_METHODS,\n};\n\n// A method name must live in exactly one table: an overlap violates the never constraint.\ntype AssertNever<T extends never> = T;\nexport type MethodTablesDisjoint = [\n AssertNever<keyof typeof CORE_METHODS & keyof typeof NOSTR_METHODS>,\n AssertNever<keyof typeof CORE_METHODS & keyof typeof SPARK_METHODS>,\n AssertNever<keyof typeof NOSTR_METHODS & keyof typeof SPARK_METHODS>,\n];\n\nexport type MethodName = keyof typeof METHODS;\nexport type ParamsOf<M extends MethodName> = ReturnType<(typeof METHODS)[M][\"params\"]>;\nexport type ResultOf<M extends MethodName> = ReturnType<(typeof METHODS)[M][\"result\"]>;\n\nconst lockReason: Validator<LockReason> = union(\n literal(\"cold-start\"),\n literal(\"user\"),\n literal(\"idle\"),\n literal(\"background\"),\n literal(\"expired\"),\n literal(\"crashed\"),\n literal(\"invalidated\"),\n);\n\nconst errorPayload = obj({\n code: walletErrorCode,\n retryAt: opt(safeTime),\n detail: opt(str(80, /^[A-Za-z0-9_.:-]+$/)),\n});\n\n/** Host-side validators: `kernelEvent` covers the two push messages. */\nexport const kernelEvent: Validator<KernelEvent> = union(\n obj({ v: literal(PROTOCOL_VERSION), event: literal(\"status\"), status: statusPayload }),\n obj({ v: literal(PROTOCOL_VERSION), event: literal(\"locked\"), reason: lockReason }),\n);\n\n/** Validates the `err` payload of a response; `ok` is checked against `METHODS[m].result`. */\nexport const responseError: Validator<{\n code: WalletErrorCode;\n retryAt?: number | undefined;\n detail?: string | undefined;\n}> = errorPayload;\n\nexport { NOSTR_METHODS, SPARK_METHODS };\nexport { CHAINS_METHODS } from \"./chains.ts\";\nexport type {\n ChainAccount,\n ChainAccountsParams,\n ChainSignResult,\n ChainTemplate,\n} from \"./chains.ts\";\nexport { CORE_METHODS, walletErrorCode } from \"./core.ts\";\nexport type { MethodSpec } from \"./core.ts\";\nexport {\n backupEnvelope,\n backupEnvelopeFactor,\n backupEnvelopeText,\n backupHeader,\n backupInfo,\n} from \"./backup.ts\";\nexport type {\n BackupFactor,\n BackupUnlockFactor,\n CreatedResult,\n CreateWithPasskeyParams,\n Factor,\n RestoreWithPasskeyParams,\n} from \"./core.ts\";\nexport type {\n BackupEnvelopeFactor,\n BackupEnvelopeWire,\n BackupHeaderWallet,\n BackupHeaderWire,\n BackupInfo,\n} from \"./backup.ts\";\nexport type {\n NostrExportFormat,\n Rumor,\n SignedEvent,\n UnsignedEventInput,\n UnwrapResult,\n} from \"./nostr.ts\";\nexport type {\n FrostAggregateJob,\n SparkApprovalSummary,\n SparkApproveIntent,\n FrostSignJob,\n HtlcTimeoutSignRequest,\n IdentityStatement,\n OperatorCommitment,\n PrepareClaimRequest,\n PreparedClaim,\n PreparedLightningReceive,\n PreparedTransfer,\n PreparedTransferLeaf,\n PrepareTransferRequest,\n SigningCommitment,\n SigningTarget,\n SparkAccountRef,\n SparkKey,\n SparkLeafKey,\n SparkNetwork,\n StaticDepositClaimRequest,\n StaticDepositClaimResult,\n StaticDepositClaimStatement,\n} from \"./spark.ts\";\nexport {\n ValidationError,\n arr,\n bool,\n bytes,\n int,\n literal,\n nullValue,\n obj,\n opt,\n record,\n str,\n union,\n validate,\n type Validator,\n} from \"./validate.ts\";\n"],"mappings":";;;;;;;;AAUA,MAAM,mBAAmB;AACzB,MAAM,mBAAmB;AACzB,MAAM,oBAAoB;AAC1B,MAAM,qBAAqB;;AAqB3B,MAAa,uBAAwD,MACnE,IAAI;CACF,MAAM,QAAQ,SAAS;CACvB,cAAc,IAAI,gBAAgB;CAClC,WAAW,IAAI,gBAAgB;AACjC,CAAC,GACD,IAAI;CACF,MAAM,QAAQ,UAAU;CACxB,YAAY,QAAQ,GAAO;CAC3B,MAAM,IAAI,GAAG;CACb,WAAW,IAAI,gBAAgB;AACjC,CAAC,CACH;AAEA,MAAa,iBAAgD,IAAI;CAC/D,SAAS,QAAQ,CAAC;CAClB,WAAW,IAAI,GAAG,OAAO,gBAAgB;CACzC,QAAQ,IAAI,gBAAgB;CAC5B,SAAS,IAAI,sBAAsB,GAAG,CAAC;CACvC,SAAS,IAAI,iBAAiB;AAChC,CAAC;AAqBD,MAAa,eAA4C,IAAI;CAC3D,SAAS,IACP,IAAI;EACF,UAAU,IAAI,GAAG;EACjB,QAAQ,MAAM,QAAQ,UAAU,GAAG,QAAQ,SAAS,CAAC;EACrD,OAAO,MAAM,QAAQ,EAAE,GAAG,QAAQ,EAAE,GAAG,QAAQ,EAAE,GAAG,QAAQ,EAAE,GAAG,QAAQ,EAAE,CAAC;EAC5E,YAAY,IAAI,QAAQ,IAAI,C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CACA,SAAS,IAAI,YAAY,kBAAkB;CAC3C,SAAS,IAAI,YAAY,kBAAkB;CAC3C,OAAO;CACP,cAAc,IAAI,SAAS,kBAAkB;CAC7C,QAAQ,MAAM,YAAY,SAAS;AACrC,CAAC;AAKD,MAAa,UAKY;CACvB,QAAQ;EACN,SAAS;EACT,UAAU;EACV,QAAQ;EACR,QAAQ;CACV;CACA,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;AACL;AAcA,MAAM,aAAoC,MACxC,QAAQ,YAAY,GACpB,QAAQ,MAAM,GACd,QAAQ,MAAM,GACd,QAAQ,YAAY,GACpB,QAAQ,SAAS,GACjB,QAAQ,SAAS,GACjB,QAAQ,aAAa,CACvB;AAEA,MAAM,eAAe,IAAI;CACvB,MAAM;CACN,SAAS,IAAI,QAAQ;CACrB,QAAQ,IAAI,IAAI,IAAI,oBAAoB,CAAC;AAC3C,CAAC;;AAGD,MAAa,cAAsC,MACjD,IAAI;CAAE,GAAG,QAAA,CAAwB;CAAG,OAAO,QAAQ,QAAQ;CAAG,QAAQ;AAAc,CAAC,GACrF,IAAI;CAAE,GAAG,QAAA,CAAwB;CAAG,OAAO,QAAQ,QAAQ;CAAG,QAAQ;AAAW,CAAC,CACpF;;AAGA,MAAa,gBAIR"}
|
package/dist/protocol.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { A as validate, C as literal, D as record, E as opt, O as str, S as int, T as obj, _ as ValidationError, a as ChainSignResult, b as bool, c as BackupUnlockFactor, d as CreatedResult, f as Factor, g as NullValue, h as walletErrorCode, k as union, l as CORE_METHODS, m as RestoreWithPasskeyParams, n as ChainAccount, o as ChainTemplate, p as MethodSpec, r as ChainAccountsParams, s as BackupFactor, t as CHAINS_METHODS, u as CreateWithPasskeyParams, v as Validator, w as nullValue, x as bytes, y as arr } from "./chains-
|
|
3
|
-
import { $ as Rumor, A as HtlcTimeoutSignRequest, B as SigningCommitment, C as backupEnvelope, D as backupInfo, E as backupHeader, F as PreparedClaim, G as SparkKey, H as SparkAccountRef, I as PreparedLightningReceive, J as StaticDepositClaimRequest, K as SparkLeafKey, L as PreparedTransfer, M as OperatorCommitment, N as PrepareClaimRequest, O as FrostAggregateJob, P as PrepareTransferRequest, Q as NostrExportFormat, R as PreparedTransferLeaf, S as BackupInfo, T as backupEnvelopeText, U as SparkApprovalSummary, V as SigningTarget, W as SparkApproveIntent, X as StaticDepositClaimStatement, Y as StaticDepositClaimResult, Z as NOSTR_METHODS, _ as responseError, a as MethodName, b as BackupHeaderWallet, c as ParamsOf, d as Response, et as SignedEvent, f as ResultOf, g as requestBytes, h as kernelEvent, i as METHODS, j as IdentityStatement, k as FrostSignJob, l as ProtocolValue, m as isProtocolValue, n as KernelEvent, nt as UnwrapResult, o as MethodTablesDisjoint, p as UNATTRIBUTED_ID, q as SparkNetwork, r as MAX_REQUEST_BYTES, s as PROTOCOL_VERSION, t as ErrorPayload, tt as UnsignedEventInput, u as Request, v as BackupEnvelopeFactor, w as backupEnvelopeFactor, x as BackupHeaderWire, y as BackupEnvelopeWire, z as SPARK_METHODS } from "./index-
|
|
1
|
+
import { C as WalletErrorCode } from "./types-cAQAJBLi.mjs";
|
|
2
|
+
import { A as validate, C as literal, D as record, E as opt, O as str, S as int, T as obj, _ as ValidationError, a as ChainSignResult, b as bool, c as BackupUnlockFactor, d as CreatedResult, f as Factor, g as NullValue, h as walletErrorCode, k as union, l as CORE_METHODS, m as RestoreWithPasskeyParams, n as ChainAccount, o as ChainTemplate, p as MethodSpec, r as ChainAccountsParams, s as BackupFactor, t as CHAINS_METHODS, u as CreateWithPasskeyParams, v as Validator, w as nullValue, x as bytes, y as arr } from "./chains-B-FmFmuV.mjs";
|
|
3
|
+
import { $ as Rumor, A as HtlcTimeoutSignRequest, B as SigningCommitment, C as backupEnvelope, D as backupInfo, E as backupHeader, F as PreparedClaim, G as SparkKey, H as SparkAccountRef, I as PreparedLightningReceive, J as StaticDepositClaimRequest, K as SparkLeafKey, L as PreparedTransfer, M as OperatorCommitment, N as PrepareClaimRequest, O as FrostAggregateJob, P as PrepareTransferRequest, Q as NostrExportFormat, R as PreparedTransferLeaf, S as BackupInfo, T as backupEnvelopeText, U as SparkApprovalSummary, V as SigningTarget, W as SparkApproveIntent, X as StaticDepositClaimStatement, Y as StaticDepositClaimResult, Z as NOSTR_METHODS, _ as responseError, a as MethodName, b as BackupHeaderWallet, c as ParamsOf, d as Response, et as SignedEvent, f as ResultOf, g as requestBytes, h as kernelEvent, i as METHODS, j as IdentityStatement, k as FrostSignJob, l as ProtocolValue, m as isProtocolValue, n as KernelEvent, nt as UnwrapResult, o as MethodTablesDisjoint, p as UNATTRIBUTED_ID, q as SparkNetwork, r as MAX_REQUEST_BYTES, s as PROTOCOL_VERSION, t as ErrorPayload, tt as UnsignedEventInput, u as Request, v as BackupEnvelopeFactor, w as backupEnvelopeFactor, x as BackupHeaderWire, y as BackupEnvelopeWire, z as SPARK_METHODS } from "./index-CEhrd0Pl.mjs";
|
|
4
4
|
export { type BackupEnvelopeFactor, type BackupEnvelopeWire, type BackupFactor, type BackupHeaderWallet, type BackupHeaderWire, type BackupInfo, type BackupUnlockFactor, CHAINS_METHODS, CORE_METHODS, type ChainAccount, type ChainAccountsParams, type ChainSignResult, type ChainTemplate, type CreateWithPasskeyParams, type CreatedResult, ErrorPayload, type Factor, type FrostAggregateJob, type FrostSignJob, type HtlcTimeoutSignRequest, type IdentityStatement, KernelEvent, MAX_REQUEST_BYTES, METHODS, MethodName, type MethodSpec, MethodTablesDisjoint, NOSTR_METHODS, type NostrExportFormat, type NullValue, type OperatorCommitment, PROTOCOL_VERSION, ParamsOf, type PrepareClaimRequest, type PrepareTransferRequest, type PreparedClaim, type PreparedLightningReceive, type PreparedTransfer, type PreparedTransferLeaf, ProtocolValue, Request, Response, type RestoreWithPasskeyParams, ResultOf, type Rumor, SPARK_METHODS, type SignedEvent, type SigningCommitment, type SigningTarget, type SparkAccountRef, type SparkApprovalSummary, type SparkApproveIntent, type SparkKey, type SparkLeafKey, type SparkNetwork, type StaticDepositClaimRequest, type StaticDepositClaimResult, type StaticDepositClaimStatement, UNATTRIBUTED_ID, type UnsignedEventInput, type UnwrapResult, ValidationError, type Validator, type WalletErrorCode, arr, backupEnvelope, backupEnvelopeFactor, backupEnvelopeText, backupHeader, backupInfo, bool, bytes, int, isProtocolValue, kernelEvent, literal, nullValue, obj, opt, record, requestBytes, responseError, str, union, validate, walletErrorCode };
|
package/dist/protocol.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { C as
|
|
2
|
-
import { a as isProtocolValue, c as responseError, d as CHAINS_METHODS, f as backupEnvelope, g as backupInfo, h as backupHeader, i as UNATTRIBUTED_ID, l as SPARK_METHODS, m as backupEnvelopeText, n as METHODS, o as kernelEvent, p as backupEnvelopeFactor, r as PROTOCOL_VERSION, s as requestBytes, t as MAX_REQUEST_BYTES, u as NOSTR_METHODS } from "./protocol-
|
|
1
|
+
import { C as obj, D as union, E as str, O as validate, S as nullValue, T as record, _ as arr, b as int, g as ValidationError, p as walletErrorCode, t as CORE_METHODS, v as bool, w as opt, x as literal, y as bytes } from "./core-DaRwkTaV.mjs";
|
|
2
|
+
import { a as isProtocolValue, c as responseError, d as CHAINS_METHODS, f as backupEnvelope, g as backupInfo, h as backupHeader, i as UNATTRIBUTED_ID, l as SPARK_METHODS, m as backupEnvelopeText, n as METHODS, o as kernelEvent, p as backupEnvelopeFactor, r as PROTOCOL_VERSION, s as requestBytes, t as MAX_REQUEST_BYTES, u as NOSTR_METHODS } from "./protocol-fXHXJguP.mjs";
|
|
3
3
|
export { CHAINS_METHODS, CORE_METHODS, MAX_REQUEST_BYTES, METHODS, NOSTR_METHODS, PROTOCOL_VERSION, SPARK_METHODS, UNATTRIBUTED_ID, ValidationError, arr, backupEnvelope, backupEnvelopeFactor, backupEnvelopeText, backupHeader, backupInfo, bool, bytes, int, isProtocolValue, kernelEvent, literal, nullValue, obj, opt, record, requestBytes, responseError, str, union, validate, walletErrorCode };
|
package/dist/spark.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { H as SparkAccountRef, U as SparkApprovalSummary, W as SparkApproveIntent } from "./index-
|
|
1
|
+
import { v as UnlockFactor, x as Wallet } from "./types-cAQAJBLi.mjs";
|
|
2
|
+
import { H as SparkAccountRef, U as SparkApprovalSummary, W as SparkApproveIntent } from "./index-CEhrd0Pl.mjs";
|
|
3
3
|
import { SparkSigner, SparkSigner as SparkSigner$1 } from "@qntx/spark/signer";
|
|
4
4
|
type SparkApi = {
|
|
5
5
|
/**
|
|
@@ -65,6 +65,7 @@ type StatusPayload = {
|
|
|
65
65
|
readonly nostr: {
|
|
66
66
|
readonly keys: ReadonlyArray<NostrKeyInfo>;
|
|
67
67
|
};
|
|
68
|
+
readonly importedKeys: ReadonlyArray<KeyInfo>;
|
|
68
69
|
readonly backup: BackupInfo | null;
|
|
69
70
|
};
|
|
70
71
|
/** Public summary of a retained backup key — factors are the unwrap paths, never secrets. */
|
|
@@ -132,6 +133,24 @@ type AutoLockPolicy = {
|
|
|
132
133
|
readonly platform: "web";
|
|
133
134
|
readonly idleMinutes: 5 | 15 | 60;
|
|
134
135
|
};
|
|
136
|
+
/** Public info for an imported private key — the record id, family and address. */
|
|
137
|
+
type KeyInfo = {
|
|
138
|
+
readonly keyId: string;
|
|
139
|
+
readonly family: "evm" | "solana" | "bitcoin";
|
|
140
|
+
readonly address: string;
|
|
141
|
+
readonly createdAt: number;
|
|
142
|
+
};
|
|
143
|
+
/** The `wallet.keys` facade — import/list/remove/export for single private keys. */
|
|
144
|
+
type KeysApi = {
|
|
145
|
+
/**
|
|
146
|
+
* `secret` is the family's canonical encoding: `0x`-prefixed 64-hex or 32 bytes for EVM; base58
|
|
147
|
+
* or raw bytes for a Solana 32-byte seed or 64-byte keypair.
|
|
148
|
+
*/
|
|
149
|
+
readonly import: (family: "evm" | "solana" | "bitcoin", secret: string | Uint8Array) => Promise<KeyInfo>;
|
|
150
|
+
readonly list: () => Promise<ReadonlyArray<KeyInfo>>;
|
|
151
|
+
readonly remove: (keyId: string, verify: UnlockFactor) => Promise<void>;
|
|
152
|
+
readonly export: (keyId: string, verify: UnlockFactor) => Promise<Uint8Array>;
|
|
153
|
+
};
|
|
135
154
|
type WalletSnapshot = {
|
|
136
155
|
readonly vault: VaultState;
|
|
137
156
|
readonly lockReason: LockReason | undefined;
|
|
@@ -141,6 +160,7 @@ type WalletSnapshot = {
|
|
|
141
160
|
readonly nostr: {
|
|
142
161
|
readonly keys: ReadonlyArray<NostrKeyInfo>;
|
|
143
162
|
};
|
|
163
|
+
readonly importedKeys: ReadonlyArray<KeyInfo>;
|
|
144
164
|
/** The retained backup key's public id, or null when cloud backup is off. */
|
|
145
165
|
readonly backup: BackupInfo | null;
|
|
146
166
|
};
|
|
@@ -231,9 +251,10 @@ type Wallet = {
|
|
|
231
251
|
readonly subscribe: (listener: () => void) => () => void;
|
|
232
252
|
readonly vault: VaultApi;
|
|
233
253
|
readonly wallets: WalletsApi;
|
|
254
|
+
readonly keys: KeysApi;
|
|
234
255
|
readonly dataKeys: DataKeyApi;
|
|
235
256
|
readonly backup: BackupApi;
|
|
236
257
|
readonly destroy: () => Promise<void>;
|
|
237
258
|
};
|
|
238
|
-
export {
|
|
239
|
-
//# sourceMappingURL=types-
|
|
259
|
+
export { WalletErrorCode as C, WalletsApi as E, WalletError as S, WalletSnapshot as T, StatusPayload as _, DerivedNostrKey as a, VaultState as b, FactorInfo as c, KeysApi as d, LockReason as f, PasskeyConfig as g, NostrKeyRef as h, DataKeyApi as i, InitialFactor as l, NostrKeyInfo as m, BackupApi as n, ExportedMnemonic as o, MnemonicDraft as p, BackupInfo as r, ExportedSecret as s, AutoLockPolicy as t, KeyInfo as u, UnlockFactor as v, WalletInfo as w, Wallet as x, VaultApi as y };
|
|
260
|
+
//# sourceMappingURL=types-cAQAJBLi.d.mts.map
|
package/dist/types.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { C as
|
|
2
|
-
export { AutoLockPolicy, BackupApi, BackupInfo, DataKeyApi, DerivedNostrKey, ExportedMnemonic, ExportedSecret, FactorInfo, InitialFactor, LockReason, MnemonicDraft, NostrKeyInfo, NostrKeyRef, PasskeyConfig, StatusPayload, UnlockFactor, VaultApi, VaultState, Wallet, WalletError, WalletErrorCode, WalletInfo, WalletSnapshot, WalletsApi };
|
|
1
|
+
import { C as WalletErrorCode, E as WalletsApi, S as WalletError, T as WalletSnapshot, _ as StatusPayload, a as DerivedNostrKey, b as VaultState, c as FactorInfo, d as KeysApi, f as LockReason, g as PasskeyConfig, h as NostrKeyRef, i as DataKeyApi, l as InitialFactor, m as NostrKeyInfo, n as BackupApi, o as ExportedMnemonic, p as MnemonicDraft, r as BackupInfo, s as ExportedSecret, t as AutoLockPolicy, u as KeyInfo, v as UnlockFactor, w as WalletInfo, x as Wallet, y as VaultApi } from "./types-cAQAJBLi.mjs";
|
|
2
|
+
export { AutoLockPolicy, BackupApi, BackupInfo, DataKeyApi, DerivedNostrKey, ExportedMnemonic, ExportedSecret, FactorInfo, InitialFactor, KeyInfo, KeysApi, LockReason, MnemonicDraft, NostrKeyInfo, NostrKeyRef, PasskeyConfig, StatusPayload, UnlockFactor, VaultApi, VaultState, Wallet, WalletError, WalletErrorCode, WalletInfo, WalletSnapshot, WalletsApi };
|