@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/types.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.mjs","names":[],"sources":["../src/types.ts"],"sourcesContent":["/** Public types of @qntx/wallet, per design/entry.mdx. Secret data never appears here. */\nexport type LockReason =\n | \"cold-start\"\n | \"user\"\n | \"idle\"\n | \"background\"\n | \"expired\"\n | \"crashed\"\n | \"invalidated\";\n\nexport type FactorInfo =\n | { readonly kind: \"hardware\"; readonly id: string; readonly createdAt: number }\n | {\n readonly kind: \"passkey\";\n readonly id: string;\n /** Base64url, public data — the main side passes it as allowCredentials. */\n readonly credentialId: string;\n readonly createdAt: number;\n }\n | { readonly kind: \"password\"; readonly id: string; readonly createdAt: number };\n\nexport type WalletInfo = {\n readonly walletId: string;\n readonly origin: \"passkey\" | \"mnemonic\";\n readonly words: 12 | 15 | 18 | 21 | 24;\n /**\n * Mnemonic: the user holds the phrase (passed the writing-down quiz, imported it, or exported at\n * least once). passkey: protected only by a synced passkey — still lost when the password manager\n * or account is lost, so the UI should prompt to export. none: exists only on this device (a\n * device-bound passkey).\n */\n readonly backup: \"none\" | \"passkey\" | \"mnemonic\";\n /** The wallet derives from its mnemonic plus a BIP-39 passphrase; only mnemonic wallets can. */\n readonly passphrase: boolean;\n readonly createdAt: number;\n};\n\nexport type NostrKeyRef = {\n readonly kind: \"derived\";\n readonly walletId: string;\n readonly index: number;\n};\n\nexport type NostrKeyInfo = {\n readonly ref: NostrKeyRef;\n readonly publicKey: string; // 64 lowercase hex\n readonly createdAt: number;\n};\n\n/** One entry of a `nostr.discover` result: the public key an identity index produces. */\nexport type DerivedNostrKey = { readonly index: number; readonly publicKey: string };\n\nexport type WalletErrorCode =\n | \"locked\"\n | \"cancelled\"\n | \"factor-invalidated\"\n | \"no-device-credential\"\n | \"passkey-not-configured\"\n | \"passkey-prf-unsupported\"\n | \"wrong-password\"\n | \"wrong-passkey\"\n | \"rate-limited\"\n | \"invalid-input\"\n | \"not-found\"\n | \"already-exists\"\n | \"conflict\"\n | \"unsupported\"\n | \"unavailable\"\n | \"integrity\"\n | \"approval-required\"\n | \"crashed\";\n\n/**\n * The vault half of the status payload: `corrupted` means authentication or structural data failed\n * to verify, `unsupported` means a newer build wrote it (data untouched, update the app),\n * `unavailable` means a transient store I/O failure (retried on the next request or change).\n */\nexport type VaultState =\n | \"uninitialized\"\n | \"locked\"\n | \"unlocked\"\n | \"corrupted\"\n | \"unsupported\"\n | \"unavailable\";\n\n/**\n * `status` result / status event payload. Locked snapshots come from unauthenticated headers;\n * \"corrupted\" means the vault data itself failed to load or verify (reset is the only way out).\n * Each protocol module contributes one section (here: `nostr`).\n */\nexport type StatusPayload = {\n readonly protocol: 2; // PROTOCOL_VERSION — literal to keep types.ts import-free\n readonly vault: VaultState;\n readonly factors: ReadonlyArray<FactorInfo>;\n readonly wallets: ReadonlyArray<WalletInfo>;\n readonly nostr: { readonly keys: ReadonlyArray<NostrKeyInfo> };\n // oxlint-disable-next-line typescript/no-restricted-types -- wire contract: backup is null when off\n readonly backup: BackupInfo | null;\n};\n\n/** Public summary of a retained backup key — factors are the unwrap paths, never secrets. */\nexport type BackupInfo = {\n readonly id: string; // 32 lowercase hex, derived from the BEK\n readonly factors: ReadonlyArray<\"passkey\" | \"password\">;\n readonly createdAt: number;\n};\n\n/** One error class for the whole API; `code` carries the distinction. Messages never echo input. */\nexport class WalletError extends Error {\n readonly code: WalletErrorCode;\n readonly retryAt: number | undefined;\n /**\n * A platform diagnostic as `\"<domain>:<code>\"` (e.g. `\"LAErrorDomain:-5\"`,\n * `\"android:KeyPermanentlyInvalidatedException\"`): never userInfo, localized text or input.\n */\n readonly detail: string | undefined;\n\n constructor(code: WalletErrorCode, message: string, retryAt?: number, detail?: string) {\n super(message);\n this.name = \"WalletError\";\n this.code = code;\n this.retryAt = retryAt;\n this.detail = detail;\n }\n}\n\n/**\n * A factor the user proves again for a guarded operation. `hardware` is the React Native factor:\n * the kernel shows the system verification prompt with text it renders itself.\n */\nexport type UnlockFactor =\n | { readonly kind: \"hardware\" }\n | { readonly kind: \"passkey\" }\n | { readonly kind: \"password\"; readonly password: string };\n\n/**\n * A factor being created; `hardware` exists only on React Native. `name` is the passkey\n * credential's display name — the host validates it before the ceremony (1–64 characters).\n */\nexport type InitialFactor =\n | { readonly kind: \"hardware\" }\n | { readonly kind: \"passkey\"; readonly name: string }\n | { readonly kind: \"password\"; readonly password: string };\n\n/**\n * WebAuthn RP identity + PRF salt labels the host configures once. `rpId`, `walletSalt` and\n * `vaultSalt` are permanent identifiers: changing any of them makes every existing passkey factor\n * and passkey-derived wallet unrecoverable, and the two salts must differ. Moving a wallet to a\n * different domain requires WebAuthn related origins (`/.well-known/webauthn`); hosts should offer\n * `exportMnemonic` for passkey-derived wallets so they survive an RP migration.\n */\nexport type PasskeyConfig = {\n /** RP id — the origin's effective domain or a registrable parent of it (e.g. meowl.social). */\n readonly rpId: string;\n readonly rpName: string;\n readonly walletSalt: string;\n readonly vaultSalt: string;\n /** PRF salt for the cloud-backup factor — a third, distinct permanent label. */\n readonly backupSalt: string;\n};\n\nexport type AutoLockPolicy =\n | { readonly platform: \"native\"; readonly backgroundSeconds: 0 | 60 | 300 | 900 }\n | { readonly platform: \"web\"; readonly idleMinutes: 5 | 15 | 60 };\n\nexport type WalletSnapshot = {\n readonly vault: VaultState;\n readonly lockReason: LockReason | undefined;\n readonly verifying: boolean; // a user verification is in flight\n readonly factors: ReadonlyArray<FactorInfo>;\n readonly wallets: ReadonlyArray<WalletInfo>;\n readonly nostr: { readonly keys: ReadonlyArray<NostrKeyInfo> };\n /** The retained backup key's public id, or null when cloud backup is off. */\n // oxlint-disable-next-line typescript/no-restricted-types -- wire contract: backup is null when off\n readonly backup: BackupInfo | null;\n};\n\n/** A one-shot secret buffer: `read` detaches the bytes to the caller, `wipe` zeroes them. */\nexport type ExportedSecret = {\n readonly read: () => Uint8Array; // UTF-8 text; single use — the second call throws\n readonly wipe: () => void;\n};\n\n/** What `exportMnemonic` returns: the phrase, and the BIP-39 passphrase when the wallet has one. */\nexport type ExportedMnemonic = {\n readonly mnemonic: ExportedSecret;\n readonly passphrase?: ExportedSecret;\n};\n\nexport type MnemonicDraft = {\n readonly words: ExportedSecret; // read once, then the host is responsible for wiping\n readonly quiz: ReadonlyArray<number>; // three positions the enclave picked\n /** `passphrase` becomes the wallet's BIP-39 passphrase; omit or pass \"\" for none. */\n readonly confirm: (\n answers: ReadonlyArray<string>,\n options?: { readonly passphrase?: string },\n ) => Promise<WalletInfo>;\n readonly discard: () => Promise<void>;\n};\n\nexport type VaultApi = {\n readonly unlock: (factor?: UnlockFactor) => Promise<void>;\n readonly lock: () => Promise<void>;\n readonly addFactor: (factor: InitialFactor, verify: UnlockFactor) => Promise<FactorInfo>;\n readonly removeFactor: (id: string, verify: UnlockFactor) => Promise<void>; // ≥1 factor remains\n readonly reset: () => Promise<void>;\n};\n\nexport type WalletsApi = {\n readonly createWithPasskey: (options: {\n /** Display name for the new passkey credential (1–64 characters after trimming). */\n readonly name: string;\n readonly factor?: InitialFactor;\n }) => Promise<WalletInfo>;\n readonly restoreWithPasskey: (options?: {\n readonly factor?: InitialFactor;\n }) => Promise<WalletInfo>;\n readonly createMnemonic: (options: {\n readonly words: 12 | 24;\n readonly factor?: InitialFactor;\n }) => Promise<MnemonicDraft>;\n readonly importMnemonic: (options: {\n readonly mnemonic: string;\n /** BIP-39 passphrase; omit or pass \"\" for none. Spaces are significant. */\n readonly passphrase?: string;\n readonly factor?: InitialFactor;\n }) => Promise<WalletInfo>;\n /** One-shot mnemonic (and passphrase) export; requires re-verification every call. */\n readonly exportMnemonic: (walletId: string, verify: UnlockFactor) => Promise<ExportedMnemonic>;\n readonly delete: (walletId: string, verify: UnlockFactor) => Promise<void>;\n};\n\nexport type DataKeyApi = {\n readonly get: (purpose: string) => Promise<Uint8Array>;\n};\n\n/**\n * Cloud-backup entry points. `enable` re-verifies and retains a fresh BEK in the vault; `update`\n * rewrites the sealed envelope JSON with the retained BEK (no factor ceremony, so an auto-sync can\n * run silently); `restore` merges an envelope into the vault. Factor inputs reuse `UnlockFactor` —\n * passkey assertions evaluate the PRF over `backupSalt`.\n */\nexport type BackupApi = {\n readonly enable: (options: {\n readonly verify: UnlockFactor;\n readonly factors: ReadonlyArray<UnlockFactor>;\n }) => Promise<void>;\n readonly update: () => Promise<string>;\n readonly disable: () => Promise<void>;\n /**\n * Wallets whose header is flagged `passphrase` restore only when `passphrases` carries theirs;\n * the rest are listed in `passphraseRequired` and a later restore can bring them in.\n */\n readonly restore: (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};\n\nexport type Wallet = {\n readonly getSnapshot: () => WalletSnapshot;\n readonly subscribe: (listener: () => void) => () => void;\n readonly vault: VaultApi;\n readonly wallets: WalletsApi;\n readonly dataKeys: DataKeyApi;\n readonly backup: BackupApi;\n readonly destroy: () => Promise<void>;\n};\n"],"mappings":";;AA4GA,IAAa,cAAb,cAAiC,MAAM;CACrC;CACA;;;;;CAKA;CAEA,YAAY,MAAuB,SAAiB,SAAkB,QAAiB;EACrF,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,OAAO;EACZ,KAAK,UAAU;EACf,KAAK,SAAS;CAChB;AACF"}
|
|
1
|
+
{"version":3,"file":"types.mjs","names":[],"sources":["../src/types.ts"],"sourcesContent":["/** Public types of @qntx/wallet, per design/entry.mdx. Secret data never appears here. */\nexport type LockReason =\n | \"cold-start\"\n | \"user\"\n | \"idle\"\n | \"background\"\n | \"expired\"\n | \"crashed\"\n | \"invalidated\";\n\nexport type FactorInfo =\n | { readonly kind: \"hardware\"; readonly id: string; readonly createdAt: number }\n | {\n readonly kind: \"passkey\";\n readonly id: string;\n /** Base64url, public data — the main side passes it as allowCredentials. */\n readonly credentialId: string;\n readonly createdAt: number;\n }\n | { readonly kind: \"password\"; readonly id: string; readonly createdAt: number };\n\nexport type WalletInfo = {\n readonly walletId: string;\n readonly origin: \"passkey\" | \"mnemonic\";\n readonly words: 12 | 15 | 18 | 21 | 24;\n /**\n * Mnemonic: the user holds the phrase (passed the writing-down quiz, imported it, or exported at\n * least once). passkey: protected only by a synced passkey — still lost when the password manager\n * or account is lost, so the UI should prompt to export. none: exists only on this device (a\n * device-bound passkey).\n */\n readonly backup: \"none\" | \"passkey\" | \"mnemonic\";\n /** The wallet derives from its mnemonic plus a BIP-39 passphrase; only mnemonic wallets can. */\n readonly passphrase: boolean;\n readonly createdAt: number;\n};\n\nexport type NostrKeyRef = {\n readonly kind: \"derived\";\n readonly walletId: string;\n readonly index: number;\n};\n\nexport type NostrKeyInfo = {\n readonly ref: NostrKeyRef;\n readonly publicKey: string; // 64 lowercase hex\n readonly createdAt: number;\n};\n\n/** One entry of a `nostr.discover` result: the public key an identity index produces. */\nexport type DerivedNostrKey = { readonly index: number; readonly publicKey: string };\n\nexport type WalletErrorCode =\n | \"locked\"\n | \"cancelled\"\n | \"factor-invalidated\"\n | \"no-device-credential\"\n | \"passkey-not-configured\"\n | \"passkey-prf-unsupported\"\n | \"wrong-password\"\n | \"wrong-passkey\"\n | \"rate-limited\"\n | \"invalid-input\"\n | \"not-found\"\n | \"already-exists\"\n | \"conflict\"\n | \"unsupported\"\n | \"unavailable\"\n | \"integrity\"\n | \"approval-required\"\n | \"crashed\";\n\n/**\n * The vault half of the status payload: `corrupted` means authentication or structural data failed\n * to verify, `unsupported` means a newer build wrote it (data untouched, update the app),\n * `unavailable` means a transient store I/O failure (retried on the next request or change).\n */\nexport type VaultState =\n | \"uninitialized\"\n | \"locked\"\n | \"unlocked\"\n | \"corrupted\"\n | \"unsupported\"\n | \"unavailable\";\n\n/**\n * `status` result / status event payload. Locked snapshots come from unauthenticated headers;\n * \"corrupted\" means the vault data itself failed to load or verify (reset is the only way out).\n * Each protocol module contributes one section (here: `nostr`).\n */\nexport type StatusPayload = {\n readonly protocol: 2; // PROTOCOL_VERSION — literal to keep types.ts import-free\n readonly vault: VaultState;\n readonly factors: ReadonlyArray<FactorInfo>;\n readonly wallets: ReadonlyArray<WalletInfo>;\n readonly nostr: { readonly keys: ReadonlyArray<NostrKeyInfo> };\n readonly importedKeys: ReadonlyArray<KeyInfo>;\n // oxlint-disable-next-line typescript/no-restricted-types -- wire contract: backup is null when off\n readonly backup: BackupInfo | null;\n};\n\n/** Public summary of a retained backup key — factors are the unwrap paths, never secrets. */\nexport type BackupInfo = {\n readonly id: string; // 32 lowercase hex, derived from the BEK\n readonly factors: ReadonlyArray<\"passkey\" | \"password\">;\n readonly createdAt: number;\n};\n\n/** One error class for the whole API; `code` carries the distinction. Messages never echo input. */\nexport class WalletError extends Error {\n readonly code: WalletErrorCode;\n readonly retryAt: number | undefined;\n /**\n * A platform diagnostic as `\"<domain>:<code>\"` (e.g. `\"LAErrorDomain:-5\"`,\n * `\"android:KeyPermanentlyInvalidatedException\"`): never userInfo, localized text or input.\n */\n readonly detail: string | undefined;\n\n constructor(code: WalletErrorCode, message: string, retryAt?: number, detail?: string) {\n super(message);\n this.name = \"WalletError\";\n this.code = code;\n this.retryAt = retryAt;\n this.detail = detail;\n }\n}\n\n/**\n * A factor the user proves again for a guarded operation. `hardware` is the React Native factor:\n * the kernel shows the system verification prompt with text it renders itself.\n */\nexport type UnlockFactor =\n | { readonly kind: \"hardware\" }\n | { readonly kind: \"passkey\" }\n | { readonly kind: \"password\"; readonly password: string };\n\n/**\n * A factor being created; `hardware` exists only on React Native. `name` is the passkey\n * credential's display name — the host validates it before the ceremony (1–64 characters).\n */\nexport type InitialFactor =\n | { readonly kind: \"hardware\" }\n | { readonly kind: \"passkey\"; readonly name: string }\n | { readonly kind: \"password\"; readonly password: string };\n\n/**\n * WebAuthn RP identity + PRF salt labels the host configures once. `rpId`, `walletSalt` and\n * `vaultSalt` are permanent identifiers: changing any of them makes every existing passkey factor\n * and passkey-derived wallet unrecoverable, and the two salts must differ. Moving a wallet to a\n * different domain requires WebAuthn related origins (`/.well-known/webauthn`); hosts should offer\n * `exportMnemonic` for passkey-derived wallets so they survive an RP migration.\n */\nexport type PasskeyConfig = {\n /** RP id — the origin's effective domain or a registrable parent of it (e.g. meowl.social). */\n readonly rpId: string;\n readonly rpName: string;\n readonly walletSalt: string;\n readonly vaultSalt: string;\n /** PRF salt for the cloud-backup factor — a third, distinct permanent label. */\n readonly backupSalt: string;\n};\n\nexport type AutoLockPolicy =\n | { readonly platform: \"native\"; readonly backgroundSeconds: 0 | 60 | 300 | 900 }\n | { readonly platform: \"web\"; readonly idleMinutes: 5 | 15 | 60 };\n\n/** Public info for an imported private key — the record id, family and address. */\nexport type KeyInfo = {\n readonly keyId: string;\n readonly family: \"evm\" | \"solana\" | \"bitcoin\";\n readonly address: string;\n readonly createdAt: number;\n};\n\n/** The `wallet.keys` facade — import/list/remove/export for single private keys. */\nexport type KeysApi = {\n /**\n * `secret` is the family's canonical encoding: `0x`-prefixed 64-hex or 32 bytes for EVM; base58\n * or raw bytes for a Solana 32-byte seed or 64-byte keypair.\n */\n readonly import: (\n family: \"evm\" | \"solana\" | \"bitcoin\",\n secret: string | Uint8Array,\n ) => Promise<KeyInfo>;\n readonly list: () => Promise<ReadonlyArray<KeyInfo>>;\n readonly remove: (keyId: string, verify: UnlockFactor) => Promise<void>;\n readonly export: (keyId: string, verify: UnlockFactor) => Promise<Uint8Array>;\n};\n\nexport type WalletSnapshot = {\n readonly vault: VaultState;\n readonly lockReason: LockReason | undefined;\n readonly verifying: boolean; // a user verification is in flight\n readonly factors: ReadonlyArray<FactorInfo>;\n readonly wallets: ReadonlyArray<WalletInfo>;\n readonly nostr: { readonly keys: ReadonlyArray<NostrKeyInfo> };\n readonly importedKeys: ReadonlyArray<KeyInfo>;\n /** The retained backup key's public id, or null when cloud backup is off. */\n // oxlint-disable-next-line typescript/no-restricted-types -- wire contract: backup is null when off\n readonly backup: BackupInfo | null;\n};\n\n/** A one-shot secret buffer: `read` detaches the bytes to the caller, `wipe` zeroes them. */\nexport type ExportedSecret = {\n readonly read: () => Uint8Array; // UTF-8 text; single use — the second call throws\n readonly wipe: () => void;\n};\n\n/** What `exportMnemonic` returns: the phrase, and the BIP-39 passphrase when the wallet has one. */\nexport type ExportedMnemonic = {\n readonly mnemonic: ExportedSecret;\n readonly passphrase?: ExportedSecret;\n};\n\nexport type MnemonicDraft = {\n readonly words: ExportedSecret; // read once, then the host is responsible for wiping\n readonly quiz: ReadonlyArray<number>; // three positions the enclave picked\n /** `passphrase` becomes the wallet's BIP-39 passphrase; omit or pass \"\" for none. */\n readonly confirm: (\n answers: ReadonlyArray<string>,\n options?: { readonly passphrase?: string },\n ) => Promise<WalletInfo>;\n readonly discard: () => Promise<void>;\n};\n\nexport type VaultApi = {\n readonly unlock: (factor?: UnlockFactor) => Promise<void>;\n readonly lock: () => Promise<void>;\n readonly addFactor: (factor: InitialFactor, verify: UnlockFactor) => Promise<FactorInfo>;\n readonly removeFactor: (id: string, verify: UnlockFactor) => Promise<void>; // ≥1 factor remains\n readonly reset: () => Promise<void>;\n};\n\nexport type WalletsApi = {\n readonly createWithPasskey: (options: {\n /** Display name for the new passkey credential (1–64 characters after trimming). */\n readonly name: string;\n readonly factor?: InitialFactor;\n }) => Promise<WalletInfo>;\n readonly restoreWithPasskey: (options?: {\n readonly factor?: InitialFactor;\n }) => Promise<WalletInfo>;\n readonly createMnemonic: (options: {\n readonly words: 12 | 24;\n readonly factor?: InitialFactor;\n }) => Promise<MnemonicDraft>;\n readonly importMnemonic: (options: {\n readonly mnemonic: string;\n /** BIP-39 passphrase; omit or pass \"\" for none. Spaces are significant. */\n readonly passphrase?: string;\n readonly factor?: InitialFactor;\n }) => Promise<WalletInfo>;\n /** One-shot mnemonic (and passphrase) export; requires re-verification every call. */\n readonly exportMnemonic: (walletId: string, verify: UnlockFactor) => Promise<ExportedMnemonic>;\n readonly delete: (walletId: string, verify: UnlockFactor) => Promise<void>;\n};\n\nexport type DataKeyApi = {\n readonly get: (purpose: string) => Promise<Uint8Array>;\n};\n\n/**\n * Cloud-backup entry points. `enable` re-verifies and retains a fresh BEK in the vault; `update`\n * rewrites the sealed envelope JSON with the retained BEK (no factor ceremony, so an auto-sync can\n * run silently); `restore` merges an envelope into the vault. Factor inputs reuse `UnlockFactor` —\n * passkey assertions evaluate the PRF over `backupSalt`.\n */\nexport type BackupApi = {\n readonly enable: (options: {\n readonly verify: UnlockFactor;\n readonly factors: ReadonlyArray<UnlockFactor>;\n }) => Promise<void>;\n readonly update: () => Promise<string>;\n readonly disable: () => Promise<void>;\n /**\n * Wallets whose header is flagged `passphrase` restore only when `passphrases` carries theirs;\n * the rest are listed in `passphraseRequired` and a later restore can bring them in.\n */\n readonly restore: (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};\n\nexport type Wallet = {\n readonly getSnapshot: () => WalletSnapshot;\n readonly subscribe: (listener: () => void) => () => void;\n readonly vault: VaultApi;\n readonly wallets: WalletsApi;\n readonly keys: KeysApi;\n readonly dataKeys: DataKeyApi;\n readonly backup: BackupApi;\n readonly destroy: () => Promise<void>;\n};\n"],"mappings":";;AA6GA,IAAa,cAAb,cAAiC,MAAM;CACrC;CACA;;;;;CAKA;CAEA,YAAY,MAAuB,SAAiB,SAAkB,QAAiB;EACrF,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,OAAO;EACZ,KAAK,UAAU;EACf,KAAK,SAAS;CAChB;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qntx/wallet",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "Self-custodial wallet SDK: Wallet host entry, protocol and types",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sdk",
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
"@qntx/nostr": "0.15.4",
|
|
85
85
|
"@qntx/spark": "0.5.2",
|
|
86
86
|
"@qntx/tsconfig": "1.0.1",
|
|
87
|
-
"@qntx/wallet-chains": "0.
|
|
87
|
+
"@qntx/wallet-chains": "0.13.0",
|
|
88
88
|
"@scure/bip32": "2.4.0",
|
|
89
89
|
"@scure/bip39": "2.4.0",
|
|
90
90
|
"@scure/btc-signer": "2.4.1",
|
|
@@ -96,7 +96,7 @@
|
|
|
96
96
|
"peerDependencies": {
|
|
97
97
|
"@qntx/nostr": "~0.15.4",
|
|
98
98
|
"@qntx/spark": "~0.5.2",
|
|
99
|
-
"@qntx/wallet-chains": "0.
|
|
99
|
+
"@qntx/wallet-chains": "0.13.0"
|
|
100
100
|
},
|
|
101
101
|
"peerDependenciesMeta": {
|
|
102
102
|
"@qntx/nostr": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"core-DDfzuSIa.mjs","names":[],"sources":["../src/protocol/validate.ts","../src/protocol/core.ts"],"sourcesContent":["/**\n * Strict validator combinators for the secret-area protocol. Both sides share them: the kernel\n * validates every request, the host validates every response. Anything that does not match is a\n * `ValidationError` — never a partially-accepted value.\n */\n\nexport class ValidationError extends Error {\n override name = \"ValidationError\";\n}\n\nexport type Validator<T> = (value: unknown) => T;\n\nfunction fail(): never {\n throw new ValidationError();\n}\n\n// oxlint-disable-next-line typescript/no-restricted-types -- JSON null is a protocol value\nexport type NullValue = null;\n\nexport function literal<T extends NullValue | boolean | number | string>(\n expected: T,\n): Validator<T> {\n return (value) => {\n if (value !== expected) {\n fail();\n }\n return expected;\n };\n}\n\nexport const nullValue: Validator<NullValue> = literal(null);\nexport const bool: Validator<boolean> = (value) => {\n if (typeof value !== \"boolean\") {\n fail();\n }\n return value;\n};\n\nexport function int(min: number, max: number): Validator<number> {\n return (value) => {\n if (typeof value !== \"number\" || !Number.isSafeInteger(value) || value < min || value > max) {\n fail();\n }\n return value;\n };\n}\n\nexport function str(max: number, pattern?: RegExp): Validator<string> {\n return (value) => {\n if (\n typeof value !== \"string\" ||\n value.length > max ||\n (pattern !== undefined && !pattern.test(value))\n ) {\n fail();\n }\n return value;\n };\n}\n\nexport function bytes(min: number, max?: number): Validator<Uint8Array> {\n const high = max ?? min;\n return (value) => {\n if (!(value instanceof Uint8Array) || value.length < min || value.length > high) {\n fail();\n }\n return value;\n };\n}\n\nexport function arr<T>(item: Validator<T>, max: number, min = 0): Validator<ReadonlyArray<T>> {\n return (value) => {\n if (!Array.isArray(value) || value.length < min || value.length > max) {\n fail();\n }\n const out: T[] = [];\n for (const element of value) {\n out.push(item(element));\n }\n return out;\n };\n}\n\nclass Opt<T> {\n readonly validator: Validator<T>;\n\n constructor(validator: Validator<T>) {\n this.validator = validator;\n }\n}\n\nexport function opt<T>(validator: Validator<T>): Opt<T> {\n return new Opt(validator);\n}\n\ntype Field = Validator<unknown> | Opt<unknown>;\ntype Shape = Record<string, Field>;\n\ntype RequiredKeys<S extends Shape> = {\n readonly [K in keyof S as S[K] extends Opt<unknown> ? never : K]: S[K] extends Validator<infer T>\n ? T\n : never;\n};\ntype OptionalKeys<S extends Shape> = {\n readonly [K in keyof S as S[K] extends Opt<unknown> ? K : never]?: S[K] extends Opt<infer T>\n ? T\n : never;\n};\ntype ShapeResult<S extends Shape> = RequiredKeys<S> & OptionalKeys<S>;\n\n/** Exact key set: required keys present, optional keys allowed, nothing else. */\nexport function obj<S extends Shape>(shape: S): Validator<ShapeResult<S>> {\n const keys = Object.keys(shape);\n return (value) => {\n if (\n typeof value !== \"object\" ||\n value === null ||\n Array.isArray(value) ||\n value instanceof Uint8Array\n ) {\n fail();\n }\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion -- narrowed to a plain object above\n const record = value as Record<string, unknown>;\n for (const key of Object.keys(record)) {\n if (!Object.hasOwn(shape, key)) {\n fail();\n }\n }\n const out: Record<string, unknown> = {};\n for (const key of keys) {\n const field = shape[key];\n if (field === undefined) {\n fail();\n }\n const raw = record[key];\n if (field instanceof Opt) {\n if (raw !== undefined) {\n out[key] = field.validator(raw);\n }\n } else {\n if (!Object.hasOwn(record, key)) {\n fail();\n }\n out[key] = field(raw);\n }\n }\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion -- the shape guarantees the keys\n return out as ShapeResult<S>;\n };\n}\n\nconst FORBIDDEN_RECORD_KEYS = new Set([\"__proto__\", \"constructor\", \"prototype\"]);\n\n/**\n * A `Record<K, V>` wire value: plain objects only, every key checked by `key`, every value by\n * `value`, at most `max` entries. Prototype-polluting keys are rejected outright — a validated\n * record must be safe to copy key-by-key.\n */\nexport function record<K extends string, V>(\n key: Validator<K>,\n value: Validator<V>,\n max: number,\n): Validator<Record<K, V>> {\n return (input) => {\n if (\n typeof input !== \"object\" ||\n input === null ||\n Array.isArray(input) ||\n input instanceof Uint8Array ||\n Object.getPrototypeOf(input) !== Object.prototype\n ) {\n fail();\n }\n const out: Record<string, V> = {};\n const entries = Object.entries(input);\n if (entries.length > max) {\n fail();\n }\n for (const [name, item] of entries) {\n if (FORBIDDEN_RECORD_KEYS.has(name)) {\n fail();\n }\n out[key(name)] = value(item);\n }\n return out;\n };\n}\n\n/** Tries each branch in order; the first match wins. */\nexport function union<Vs extends ReadonlyArray<Validator<unknown>>>(\n ...branches: Vs\n): Validator<ReturnType<Vs[number]>> {\n return (value) => {\n for (const branch of branches) {\n try {\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion -- ReturnType of the branch union\n return branch(value) as ReturnType<Vs[number]>;\n } catch (error) {\n if (!(error instanceof ValidationError)) {\n throw error;\n }\n }\n }\n return fail();\n };\n}\n\n/** Validates a value and returns it, or undefined on a shape mismatch. */\nexport function validate<T>(validator: Validator<T>, value: unknown): T | undefined {\n try {\n return validator(value);\n } catch (error) {\n if (error instanceof ValidationError) {\n return undefined;\n }\n throw error;\n }\n}\n","/**\n * The core method table: vault, wallet and data-key commands — nothing protocol-specific. \"Create\n * or import\" commands (createWithPasskey/restoreWithPasskey/createMnemonic/importMnemonic) are\n * `session: false` here because the rule is dynamic: with an uninitialized vault they carry\n * `factor` and establish the vault in one commit; with an established vault `factor` must be absent\n * and a valid session is required.\n *\n * The shared wire validators (factor, wallet info, ids) live here too so the nostr module's table\n * can reuse them — `protocol/nostr.ts` imports only from this file.\n */\nimport type { FactorInfo, WalletErrorCode, WalletInfo } from \"../types.ts\";\nimport type { NullValue, Validator } from \"./validate.ts\";\nimport { arr, bool, bytes, int, literal, nullValue, obj, opt, str, union } from \"./validate.ts\";\n\nexport type MethodSpec<P, R> = {\n readonly session: boolean;\n /** Whether a successful call refreshes the idle timer — presence-bearing methods only. */\n readonly presence: boolean;\n readonly params: Validator<P>;\n readonly result: Validator<R>;\n};\n\n// Size caps (UTF-16 units for strings, bytes for Uint8Array). These bound individual fields; the\n// whole-request cap MAX_REQUEST_BYTES (protocol/index.ts) is enforced by host and kernel.\nexport const MAX_TEXT = 262_144;\nexport const MAX_TAGS = 1024;\nexport const MAX_TAG_ITEMS = 64;\nexport const MAX_TAG_ITEM = 4096;\nexport const MAX_BATCH = 64;\nexport const MAX_SNAPSHOT_ITEMS = 4096;\n\nexport const sessionId: Validator<string> = str(32, /^[0-9a-f]{32}$/);\nexport const draftId: Validator<string> = str(32, /^[0-9a-f]{32}$/);\nexport const walletId: Validator<string> = str(16, /^[0-9a-f]{16}$/);\nexport const publicKey: Validator<string> = str(64, /^[0-9a-f]{64}$/);\nexport const credentialId: Validator<string> = str(1364, /^[A-Za-z0-9_-]+$/);\nexport const safeTime: Validator<number> = int(0, Number.MAX_SAFE_INTEGER);\nexport const groupIndex: Validator<number> = int(0, 0x7fffffff);\n/** Identity indices stop below 2^31 - 1 — the top segment derives the wallet sync key. */\nexport const identityIndex: Validator<number> = int(0, 0x7ffffffe);\n\n/**\n * Vault factor material on the wire. `hardware` carries nothing: the kernel runs the platform\n * keystore ceremony itself, so the main runtime never touches the KEK.\n */\nexport type Factor =\n | { readonly kind: \"hardware\" }\n | { readonly kind: \"password\"; readonly password: Uint8Array }\n | { readonly kind: \"passkey\"; readonly credentialId: Uint8Array; readonly prf: Uint8Array };\n\nexport const factor: Validator<Factor> = union(\n obj({ kind: literal(\"hardware\") }),\n obj({ kind: literal(\"password\"), password: bytes(1, 1024) }),\n obj({ kind: literal(\"passkey\"), credentialId: bytes(1, 1023), prf: bytes(32) }),\n);\n\n/** A host-run backup passkey ceremony's evidence: the PRF over `backupSalt` (web). */\ntype HostBackupPasskey = {\n readonly kind: \"passkey\";\n readonly ceremony: \"host\";\n readonly credentialId: Uint8Array;\n readonly prfBackup: Uint8Array;\n};\n\n/**\n * A factor that seals a new backup key. On React Native the kernel registers a protection\n * credential (`kernel`) itself and names it; on the web the host hands over its ceremony's\n * evidence.\n */\nexport type BackupFactor =\n | { readonly kind: \"password\"; readonly password: Uint8Array }\n | HostBackupPasskey\n | {\n readonly kind: \"passkey\";\n readonly ceremony: \"kernel\";\n readonly rpId: string;\n readonly rpName: string;\n readonly backupSalt: string;\n };\n\n/**\n * A factor that opens a backup envelope. The `kernel` passkey arm asserts one of the envelope's own\n * credentials.\n */\nexport type BackupUnlockFactor =\n | { readonly kind: \"password\"; readonly password: Uint8Array }\n | HostBackupPasskey\n | {\n readonly kind: \"passkey\";\n readonly ceremony: \"kernel\";\n readonly rpId: string;\n readonly backupSalt: string;\n };\n\nexport const factorInfo: Validator<FactorInfo> = union(\n obj({ kind: literal(\"hardware\"), id: sessionId, createdAt: safeTime }),\n obj({\n kind: literal(\"passkey\"),\n id: sessionId,\n credentialId,\n createdAt: safeTime,\n }),\n obj({ kind: literal(\"password\"), id: sessionId, createdAt: safeTime }),\n);\n\n/**\n * Passkey wallet creation. `host`: the host ran the WebAuthn ceremony and hands over the PRF\n * evidence (web). `kernel`: the kernel runs the platform ceremony itself and nothing secret crosses\n * the channel (React Native). The kernel accepts exactly the shape its platform supports.\n */\nexport type CreateWithPasskeyParams =\n | {\n readonly ceremony: \"host\";\n readonly credentialId: Uint8Array;\n readonly prfWallet: Uint8Array;\n readonly synced: boolean;\n readonly factor?: Factor;\n }\n | {\n readonly ceremony: \"kernel\";\n readonly rpId: string;\n readonly rpName: string;\n readonly name: string;\n readonly walletSalt: string;\n readonly factor?: Factor;\n };\n\nexport type RestoreWithPasskeyParams =\n | {\n readonly ceremony: \"host\";\n readonly credentialId: Uint8Array;\n readonly prfWallet: Uint8Array;\n readonly synced: boolean;\n readonly factor?: Factor;\n }\n | {\n readonly ceremony: \"kernel\";\n readonly rpId: string;\n readonly walletSalt: string;\n readonly factor?: Factor;\n };\n\n// An RP id is a lowercase DNS name; the platform rejects anything its associated domains do not\n// list, so this only bounds the shape.\nconst RP_ID =\n /^(?=.{1,253}$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)+$/;\nconst label = (max: number): Validator<string> => str(max, /^\\S(?:.*\\S)?$/su);\n\nconst hostEvidence = {\n ceremony: literal(\"host\"),\n credentialId: bytes(1, 1023),\n prfWallet: bytes(32),\n synced: bool,\n factor: opt(factor),\n};\n\nconst createWithPasskeyParams: Validator<CreateWithPasskeyParams> = union(\n obj(hostEvidence),\n obj({\n ceremony: literal(\"kernel\"),\n rpId: str(253, RP_ID),\n rpName: label(64),\n name: label(64),\n walletSalt: label(64),\n factor: opt(factor),\n }),\n);\n\nconst restoreWithPasskeyParams: Validator<RestoreWithPasskeyParams> = union(\n obj(hostEvidence),\n obj({\n ceremony: literal(\"kernel\"),\n rpId: str(253, RP_ID),\n walletSalt: label(64),\n factor: opt(factor),\n }),\n);\n\nconst hostBackupPasskey = obj({\n kind: literal(\"passkey\"),\n ceremony: literal(\"host\"),\n credentialId: bytes(1, 1023),\n prfBackup: bytes(32),\n});\nconst backupPassword = obj({ kind: literal(\"password\"), password: bytes(1, 1024) });\n\nexport const backupFactor: Validator<BackupFactor> = union(\n backupPassword,\n hostBackupPasskey,\n obj({\n kind: literal(\"passkey\"),\n ceremony: literal(\"kernel\"),\n rpId: str(253, RP_ID),\n rpName: label(64),\n backupSalt: label(64),\n }),\n);\n\nexport const backupUnlockFactor: Validator<BackupUnlockFactor> = union(\n backupPassword,\n hostBackupPasskey,\n obj({\n kind: literal(\"passkey\"),\n ceremony: literal(\"kernel\"),\n rpId: str(253, RP_ID),\n backupSalt: label(64),\n }),\n);\n\nexport const walletInfo: Validator<WalletInfo> = obj({\n walletId,\n origin: union(literal(\"passkey\"), literal(\"mnemonic\")),\n words: union(literal(12), literal(15), literal(18), literal(21), literal(24)),\n backup: union(literal(\"none\"), literal(\"passkey\"), literal(\"mnemonic\")),\n passphrase: bool,\n createdAt: safeTime,\n});\n\n/** A BIP-39 passphrase on the wire: raw UTF-8 bytes, never empty (the host omits \"none\"). */\nconst passphraseBytes: Validator<Uint8Array> = bytes(1, 1024);\n\nexport const walletErrorCode: Validator<WalletErrorCode> = union(\n literal(\"locked\"),\n literal(\"cancelled\"),\n literal(\"factor-invalidated\"),\n literal(\"no-device-credential\"),\n literal(\"passkey-not-configured\"),\n literal(\"passkey-prf-unsupported\"),\n literal(\"wrong-password\"),\n literal(\"wrong-passkey\"),\n literal(\"rate-limited\"),\n literal(\"invalid-input\"),\n literal(\"not-found\"),\n literal(\"already-exists\"),\n literal(\"conflict\"),\n literal(\"unsupported\"),\n literal(\"unavailable\"),\n literal(\"integrity\"),\n literal(\"approval-required\"),\n literal(\"crashed\"),\n);\n\n/**\n * The result of every \"create or import\" wallet command: the new wallet's public info plus the\n * session it opened. Creating a wallet derives no protocol keys — modules add keys separately.\n */\nexport type CreatedResult = {\n readonly wallet: WalletInfo;\n readonly session: string;\n};\n\nconst createdResult: Validator<CreatedResult> = obj({ wallet: walletInfo, session: sessionId });\n\n// `status` itself is a core method, but its result validator composes every module's status\n// section — it is wired in protocol/index.ts, not here.\nexport const CORE_METHODS: {\n readonly \"vault.unlock\": MethodSpec<{ readonly factor: Factor }, { readonly session: string }>;\n readonly \"vault.reset\": MethodSpec<NullValue, NullValue>;\n readonly \"vault.addFactor\": MethodSpec<\n { readonly verify: Factor; readonly factor: Factor },\n FactorInfo\n >;\n readonly \"vault.removeFactor\": MethodSpec<\n { readonly verify: Factor; readonly id: string },\n NullValue\n >;\n readonly \"session.touch\": MethodSpec<NullValue, NullValue>;\n readonly \"wallet.createWithPasskey\": MethodSpec<CreateWithPasskeyParams, CreatedResult>;\n readonly \"wallet.restoreWithPasskey\": MethodSpec<RestoreWithPasskeyParams, CreatedResult>;\n readonly \"wallet.createMnemonic\": MethodSpec<\n { readonly words: 12 | 24; readonly factor?: Factor },\n { readonly draft: string; readonly words: Uint8Array; readonly quiz: ReadonlyArray<number> }\n >;\n readonly \"wallet.confirmMnemonic\": MethodSpec<\n {\n readonly draft: string;\n readonly answers: ReadonlyArray<Uint8Array>;\n readonly passphrase?: Uint8Array;\n },\n CreatedResult\n >;\n readonly \"wallet.discardMnemonic\": MethodSpec<{ readonly draft: string }, NullValue>;\n readonly \"backup.enable\": MethodSpec<\n {\n readonly verify: Factor;\n readonly factors: ReadonlyArray<BackupFactor>;\n },\n NullValue\n >;\n readonly \"backup.update\": MethodSpec<NullValue, { readonly envelope: string }>;\n readonly \"backup.disable\": MethodSpec<NullValue, NullValue>;\n readonly \"backup.restore\": MethodSpec<\n {\n readonly envelope: string;\n readonly backupFactor: BackupUnlockFactor;\n readonly passphrases?: ReadonlyArray<{\n readonly walletId: string;\n readonly passphrase: Uint8Array;\n }>;\n readonly factor?: Factor;\n },\n {\n readonly wallets: ReadonlyArray<WalletInfo>;\n readonly passphraseRequired: ReadonlyArray<string>;\n readonly session: string;\n }\n >;\n readonly \"wallet.importMnemonic\": MethodSpec<\n { readonly mnemonic: Uint8Array; readonly passphrase?: Uint8Array; readonly factor?: Factor },\n CreatedResult\n >;\n readonly \"wallet.exportMnemonic\": MethodSpec<\n { readonly verify: Factor; readonly walletId: string },\n { readonly mnemonic: Uint8Array; readonly passphrase?: Uint8Array }\n >;\n readonly \"wallet.delete\": MethodSpec<\n { readonly verify: Factor; readonly walletId: string },\n NullValue\n >;\n readonly \"dataKeys.get\": MethodSpec<{ readonly purpose: string }, Uint8Array>;\n} = {\n \"session.touch\": {\n session: true,\n presence: true,\n params: nullValue,\n result: nullValue,\n },\n \"vault.unlock\": {\n session: false,\n presence: true,\n params: obj({ factor }),\n result: obj({ session: sessionId }),\n },\n \"vault.reset\": { session: false, presence: false, params: nullValue, result: nullValue },\n \"vault.addFactor\": {\n session: true,\n presence: true,\n params: obj({ verify: factor, factor }),\n result: factorInfo,\n },\n \"vault.removeFactor\": {\n session: true,\n presence: true,\n params: obj({ verify: factor, id: sessionId }),\n result: nullValue,\n },\n \"wallet.createWithPasskey\": {\n session: false,\n presence: true,\n params: createWithPasskeyParams,\n result: createdResult,\n },\n \"wallet.restoreWithPasskey\": {\n session: false,\n presence: true,\n params: restoreWithPasskeyParams,\n result: createdResult,\n },\n \"wallet.createMnemonic\": {\n session: false,\n presence: true,\n params: obj({ words: union(literal(12), literal(24)), factor: opt(factor) }),\n result: obj({\n draft: draftId,\n words: bytes(16, 1024),\n quiz: arr(int(0, 23), 3, 3),\n }),\n },\n \"wallet.confirmMnemonic\": {\n session: false,\n presence: true,\n params: obj({\n draft: draftId,\n answers: arr(bytes(1, 64), 3, 3),\n passphrase: opt(passphraseBytes),\n }),\n result: createdResult,\n },\n \"wallet.discardMnemonic\": {\n session: false,\n presence: false,\n params: obj({ draft: draftId }),\n result: nullValue,\n },\n \"backup.enable\": {\n session: true,\n presence: true,\n params: obj({ verify: factor, factors: arr(backupFactor, 5, 1) }),\n result: nullValue,\n },\n \"backup.update\": {\n session: true,\n presence: false,\n params: nullValue,\n result: obj({ envelope: str(4_000_000) }),\n },\n \"backup.disable\": {\n session: true,\n presence: true,\n params: nullValue,\n result: nullValue,\n },\n \"backup.restore\": {\n session: false,\n presence: true,\n params: obj({\n envelope: str(4_000_000),\n backupFactor: backupUnlockFactor,\n passphrases: opt(arr(obj({ walletId, passphrase: passphraseBytes }), 1000)),\n factor: opt(factor),\n }),\n result: obj({\n wallets: arr(walletInfo, 1000),\n passphraseRequired: arr(str(128), 1000),\n session: sessionId,\n }),\n },\n \"wallet.importMnemonic\": {\n session: false,\n presence: true,\n params: obj({\n mnemonic: bytes(1, 1024),\n passphrase: opt(passphraseBytes),\n factor: opt(factor),\n }),\n result: createdResult,\n },\n \"wallet.exportMnemonic\": {\n session: true,\n presence: true,\n params: obj({ verify: factor, walletId }),\n result: obj({ mnemonic: bytes(16, 1024), passphrase: opt(passphraseBytes) }),\n },\n \"wallet.delete\": {\n session: true,\n presence: true,\n params: obj({ verify: factor, walletId }),\n result: nullValue,\n },\n \"dataKeys.get\": {\n session: true,\n presence: false,\n params: obj({ purpose: str(32, /^[a-z0-9-]{1,32}$/) }),\n result: bytes(32),\n },\n};\n"],"mappings":";;;;;;AAMA,IAAa,kBAAb,cAAqC,MAAM;CACzC,OAAgB;AAClB;AAIA,SAAS,OAAc;CACrB,MAAM,IAAI,gBAAgB;AAC5B;AAKA,SAAgB,QACd,UACc;CACd,QAAQ,UAAU;EAChB,IAAI,UAAU,UACZ,KAAK;EAEP,OAAO;CACT;AACF;AAEA,MAAa,YAAkC,QAAQ,IAAI;AAC3D,MAAa,QAA4B,UAAU;CACjD,IAAI,OAAO,UAAU,WACnB,KAAK;CAEP,OAAO;AACT;AAEA,SAAgB,IAAI,KAAa,KAAgC;CAC/D,QAAQ,UAAU;EAChB,IAAI,OAAO,UAAU,YAAY,CAAC,OAAO,cAAc,KAAK,KAAK,QAAQ,OAAO,QAAQ,KACtF,KAAK;EAEP,OAAO;CACT;AACF;AAEA,SAAgB,IAAI,KAAa,SAAqC;CACpE,QAAQ,UAAU;EAChB,IACE,OAAO,UAAU,YACjB,MAAM,SAAS,OACd,YAAY,KAAA,KAAa,CAAC,QAAQ,KAAK,KAAK,GAE7C,KAAK;EAEP,OAAO;CACT;AACF;AAEA,SAAgB,MAAM,KAAa,KAAqC;CACtE,MAAM,OAAO,OAAO;CACpB,QAAQ,UAAU;EAChB,IAAI,EAAE,iBAAiB,eAAe,MAAM,SAAS,OAAO,MAAM,SAAS,MACzE,KAAK;EAEP,OAAO;CACT;AACF;AAEA,SAAgB,IAAO,MAAoB,KAAa,MAAM,GAAgC;CAC5F,QAAQ,UAAU;EAChB,IA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S;EACT,UAAU;EACV,QAAQ;EACR,QAAQ;CACV;CACA,kBAAkB;EAChB,SAAS;EACT,UAAU;EACV,QAAQ,IAAI;GACV,UAAU,IAAI,GAAS;GACvB,cAAc;GACd,aAAa,IAAI,IAAI,IAAI;IAAE;IAAU,YAAY;GAAgB,CAAC,GAAG,GAAI,CAAC;GAC1E,QAAQ,IAAI,MAAM;EACpB,CAAC;EACD,QAAQ,IAAI;GACV,SAAS,IAAI,YAAY,GAAI;GAC7B,oBAAoB,IAAI,IAAI,GAAG,GAAG,GAAI;GACtC,SAAS;EACX,CAAC;CACH;CACA,yBAAyB;EACvB,SAAS;EACT,UAAU;EACV,QAAQ,IAAI;GACV,UAAU,MAAM,GAAG,IAAI;GACvB,YAAY,IAAI,eAAe;GAC/B,QAAQ,IAAI,MAAM;EACpB,CAAC;EACD,QAAQ;CACV;CACA,yBAAyB;EACvB,SAAS;EACT,UAAU;EACV,QAAQ,IAAI;GAAE,QAAQ;GAAQ;EAAS,CAAC;EACxC,QAAQ,IAAI;GAAE,UAAU,MAAM,IAAI,IAAI;GAAG,YAAY,IAAI,eAAe;EAAE,CAAC;CAC7E;CACA,iBAAiB;EACf,SAAS;EACT,UAAU;EACV,QAAQ,IAAI;GAAE,QAAQ;GAAQ;EAAS,CAAC;EACxC,QAAQ;CACV;CACA,gBAAgB;EACd,SAAS;EACT,UAAU;EACV,QAAQ,IAAI,EAAE,SAAS,IAAI,IAAI,mBAAmB,EAAE,CAAC;EACrD,QAAQ,MAAM,EAAE;CAClB;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"protocol-C8x0H3Rr.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 BackupHeaderWire = {\n readonly wallets: ReadonlyArray<BackupHeaderWallet>;\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});\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\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);\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 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 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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