@hwlt/era-connect 0.3.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/README.md +8 -14
  2. package/bch/package.json +6 -0
  3. package/cosmos/package.json +6 -0
  4. package/dist/bch-CK6dKGQA.d.ts +74 -0
  5. package/dist/bch-CpLACx0j.cjs +139 -0
  6. package/dist/bch-CpLACx0j.cjs.map +1 -0
  7. package/dist/bch-DHsIVJqK.d.cts +74 -0
  8. package/dist/bch-dMESlQfv.js +134 -0
  9. package/dist/bch-dMESlQfv.js.map +1 -0
  10. package/dist/bch.cjs +13 -0
  11. package/dist/bch.d.cts +26 -0
  12. package/dist/bch.d.ts +26 -0
  13. package/dist/bch.js +4 -0
  14. package/dist/{btc-VyJKXq7d.js → btc-BmVgvvBd.js} +17 -8
  15. package/dist/btc-BmVgvvBd.js.map +1 -0
  16. package/dist/{btc-Fr6Jz4Fi.cjs → btc-BxNww6kW.cjs} +20 -11
  17. package/dist/btc-BxNww6kW.cjs.map +1 -0
  18. package/dist/{btc-DfQ0q79G.d.ts → btc-uzt0uC-Q.d.ts} +15 -4
  19. package/dist/{btc-Dn6_Y12c.d.cts → btc-wogJ4INA.d.cts} +15 -4
  20. package/dist/btc.cjs +2 -2
  21. package/dist/btc.d.cts +1 -1
  22. package/dist/btc.d.ts +1 -1
  23. package/dist/btc.js +2 -2
  24. package/dist/{cardano-yuOygqwp.js → cardano-BCT55gwf.js} +3 -2
  25. package/dist/{cardano-yuOygqwp.js.map → cardano-BCT55gwf.js.map} +1 -1
  26. package/dist/{cardano-DP6U_K1J.cjs → cardano-CzYswGzK.cjs} +5 -4
  27. package/dist/{cardano-DP6U_K1J.cjs.map → cardano-CzYswGzK.cjs.map} +1 -1
  28. package/dist/cardano.cjs +2 -2
  29. package/dist/cardano.js +2 -2
  30. package/dist/cashaddr-BIzawizX.js +134 -0
  31. package/dist/cashaddr-BIzawizX.js.map +1 -0
  32. package/dist/cashaddr-Ci0_8ITN.cjs +151 -0
  33. package/dist/cashaddr-Ci0_8ITN.cjs.map +1 -0
  34. package/dist/cosmos-BYrhIqRk.d.cts +77 -0
  35. package/dist/cosmos-DDsgtUki.cjs +113 -0
  36. package/dist/cosmos-DDsgtUki.cjs.map +1 -0
  37. package/dist/cosmos-DqyjA6lg.d.ts +77 -0
  38. package/dist/cosmos-jUHNxgWC.js +102 -0
  39. package/dist/cosmos-jUHNxgWC.js.map +1 -0
  40. package/dist/cosmos.cjs +10 -0
  41. package/dist/cosmos.d.cts +3 -0
  42. package/dist/cosmos.d.ts +3 -0
  43. package/dist/cosmos.js +3 -0
  44. package/dist/{derive-C4JdycUh.js → derive-00JUOkmn.js} +14 -3
  45. package/dist/derive-00JUOkmn.js.map +1 -0
  46. package/dist/{derive-CuILJRPT.cjs → derive-BuNsfWlg.cjs} +25 -2
  47. package/dist/derive-BuNsfWlg.cjs.map +1 -0
  48. package/dist/{evm-kJb3-oiR.js → evm-CI1cuZsp.js} +3 -2
  49. package/dist/{evm-kJb3-oiR.js.map → evm-CI1cuZsp.js.map} +1 -1
  50. package/dist/{evm-BHj_2OTG.cjs → evm-yfKOc2dy.cjs} +6 -5
  51. package/dist/{evm-BHj_2OTG.cjs.map → evm-yfKOc2dy.cjs.map} +1 -1
  52. package/dist/evm.cjs +2 -2
  53. package/dist/evm.js +2 -2
  54. package/dist/gzip-CLzDX7AZ.cjs +79 -0
  55. package/dist/gzip-CLzDX7AZ.cjs.map +1 -0
  56. package/dist/gzip-DyZLtgJJ.js +68 -0
  57. package/dist/gzip-DyZLtgJJ.js.map +1 -0
  58. package/dist/index.cjs +120 -31
  59. package/dist/index.cjs.map +1 -1
  60. package/dist/index.d.cts +50 -3
  61. package/dist/index.d.ts +50 -3
  62. package/dist/index.js +90 -9
  63. package/dist/index.js.map +1 -1
  64. package/dist/keypath-Bvv_cfHt.js +75 -0
  65. package/dist/keypath-Bvv_cfHt.js.map +1 -0
  66. package/dist/keypath-pzm_YIfN.cjs +116 -0
  67. package/dist/keypath-pzm_YIfN.cjs.map +1 -0
  68. package/dist/{messages-17Oup0-Z.js → messages--XbVef_k.js} +39 -3
  69. package/dist/messages--XbVef_k.js.map +1 -0
  70. package/dist/{messages-BzcdWlg1.cjs → messages-orAQ52CI.cjs} +44 -2
  71. package/dist/messages-orAQ52CI.cjs.map +1 -0
  72. package/dist/{shared-B8Wc7ViU.js → shared-Bbgejrus.js} +2 -73
  73. package/dist/shared-Bbgejrus.js.map +1 -0
  74. package/dist/{shared-nISrEktU.cjs → shared-Cu2yynP9.cjs} +13 -114
  75. package/dist/shared-Cu2yynP9.cjs.map +1 -0
  76. package/dist/{solana-DdEn24X4.cjs → solana-BoQBy0hu.cjs} +6 -5
  77. package/dist/{solana-DdEn24X4.cjs.map → solana-BoQBy0hu.cjs.map} +1 -1
  78. package/dist/{solana-C7JQEAec.js → solana-BukH3AI3.js} +3 -2
  79. package/dist/{solana-C7JQEAec.js.map → solana-BukH3AI3.js.map} +1 -1
  80. package/dist/solana.cjs +2 -2
  81. package/dist/solana.js +2 -2
  82. package/dist/sui-6WX6VPlW.d.cts +49 -0
  83. package/dist/sui-BtbPG6Xt.js +71 -0
  84. package/dist/sui-BtbPG6Xt.js.map +1 -0
  85. package/dist/sui-CYRn331O.cjs +82 -0
  86. package/dist/sui-CYRn331O.cjs.map +1 -0
  87. package/dist/sui-DI0ruW7E.d.ts +49 -0
  88. package/dist/sui.cjs +10 -0
  89. package/dist/sui.d.cts +3 -0
  90. package/dist/sui.d.ts +3 -0
  91. package/dist/sui.js +3 -0
  92. package/dist/{ton-5Uvi5ifg.js → ton-BSPKU5B9.js} +3 -2
  93. package/dist/{ton-5Uvi5ifg.js.map → ton-BSPKU5B9.js.map} +1 -1
  94. package/dist/{ton-DUJGXdGa.cjs → ton-CI2s9puH.cjs} +6 -5
  95. package/dist/{ton-DUJGXdGa.cjs.map → ton-CI2s9puH.cjs.map} +1 -1
  96. package/dist/ton.cjs +2 -2
  97. package/dist/ton.js +2 -2
  98. package/dist/{tron-Bo9HnvVE.js → tron-BpUEYTPT.js} +5 -67
  99. package/dist/tron-BpUEYTPT.js.map +1 -0
  100. package/dist/{tron-CQIEqjCA.cjs → tron-DYPOg5cm.cjs} +10 -72
  101. package/dist/{tron-Bo9HnvVE.js.map → tron-DYPOg5cm.cjs.map} +1 -1
  102. package/dist/tron.cjs +3 -3
  103. package/dist/tron.js +3 -3
  104. package/dist/verify.cjs +414 -24
  105. package/dist/verify.cjs.map +1 -1
  106. package/dist/verify.d.cts +120 -1
  107. package/dist/verify.d.ts +120 -1
  108. package/dist/verify.js +408 -24
  109. package/dist/verify.js.map +1 -1
  110. package/dist/xrp-BXAeK4iH.d.cts +32 -0
  111. package/dist/xrp-BrHXUnX5.cjs +52 -0
  112. package/dist/xrp-BrHXUnX5.cjs.map +1 -0
  113. package/dist/xrp-C8LJO5b-.js +47 -0
  114. package/dist/xrp-C8LJO5b-.js.map +1 -0
  115. package/dist/xrp-DqCXGYEk.d.ts +32 -0
  116. package/dist/xrp.cjs +9 -0
  117. package/dist/xrp.d.cts +3 -0
  118. package/dist/xrp.d.ts +3 -0
  119. package/dist/xrp.js +3 -0
  120. package/package.json +49 -1
  121. package/sui/package.json +6 -0
  122. package/xrp/package.json +6 -0
  123. package/dist/btc-Fr6Jz4Fi.cjs.map +0 -1
  124. package/dist/btc-VyJKXq7d.js.map +0 -1
  125. package/dist/derive-C4JdycUh.js.map +0 -1
  126. package/dist/derive-CuILJRPT.cjs.map +0 -1
  127. package/dist/messages-17Oup0-Z.js.map +0 -1
  128. package/dist/messages-BzcdWlg1.cjs.map +0 -1
  129. package/dist/shared-B8Wc7ViU.js.map +0 -1
  130. package/dist/shared-nISrEktU.cjs.map +0 -1
  131. package/dist/tron-CQIEqjCA.cjs.map +0 -1
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["UrValue","EraAccountsClass","UrValue"],"sources":["../src/registry/multi-accounts.ts","../src/accounts/accounts.ts","../src/hardware-call/key-derivation.ts","../src/raw.ts","../src/index.ts"],"sourcesContent":["import { cborDecode } from '../cbor/decode';\nimport type { CborValue } from '../cbor/model';\nimport { asArray, asBytes, asMap, asText, asUint, mapGet } from '../cbor/model';\nimport { EraSdkError } from '../core/errors';\nimport { parseUrString, type Ur } from '../ur/ur';\nimport type { PathLevel } from './keypath';\nimport { parsePathComponents } from './keypath';\n\n/**\n * Raw account entry parsed from a `crypto-multi-accounts` (1103) export.\n *\n * `xfp` is the entry's ORIGIN source fingerprint (`crypto-keypath` key 2) —\n * the value a `*-sign-request` keypath must carry. It is NOT the top-level\n * master fingerprint, although the two often coincide.\n */\nexport interface RawAccountEntry {\n readonly path: readonly PathLevel[];\n /**\n * The origin's source fingerprint, when the export carries one. Cardano\n * entries deliberately ship a path-only origin — resolve against the\n * wrapper's master fingerprint in that case.\n */\n readonly xfp: number | null;\n /**\n * Nullable and length-unconstrained, as in the reference implementation: an\n * entry without a usable key still resolves its xfp for signing — only the\n * address-derivation views require the 33/32-byte forms.\n */\n readonly publicKey: Uint8Array | null;\n readonly chainCode: Uint8Array | null;\n readonly parentFingerprint: number | null;\n readonly name: string | null;\n /** A label string (`account.standard`, ...) — NEVER chain metadata. */\n readonly note: string | null;\n}\n\nexport interface RawMultiAccounts {\n readonly masterFingerprint: number;\n readonly deviceName: string | null;\n readonly deviceId: string | null;\n readonly deviceVersion: string | null;\n readonly entries: readonly RawAccountEntry[];\n}\n\n/** UR types a device links a watch-only wallet with. */\nexport const WALLET_UR_TYPES: ReadonlySet<string> = new Set([\n 'crypto-multi-accounts',\n 'crypto-account',\n 'crypto-hdkey',\n]);\n\n/**\n * Parse a wallet-export UR.\n *\n * Of the three admitted link types only the `crypto-multi-accounts` shape\n * yields derivable accounts; an export that yields none is refused rather\n * than stored as an unusable wallet. Malformed entries are skipped\n * individually so one foreign item does not abort the rest.\n */\nexport function parseMultiAccountsUr(input: Ur | string): RawMultiAccounts {\n let type: string;\n let cbor: Uint8Array;\n if (typeof input === 'string') {\n const parsed = parseUrString(input);\n if (parsed.seq !== null) {\n throw new EraSdkError(\n 'invalid-props',\n 'multi-part UR string: assemble it with a UrScanner first',\n );\n }\n type = parsed.type;\n cbor = parsed.payload;\n } else {\n type = input.type;\n cbor = input.cbor;\n }\n\n if (!WALLET_UR_TYPES.has(type)) {\n // The type is attacker-sized (the UR grammar allows an unbounded letter\n // run) — truncate before it reaches a message or error data.\n const shown = type.length > 32 ? `${type.slice(0, 32)}…` : type;\n throw new EraSdkError(\n 'wrong-ur-type',\n `\"${shown}\" is not a wallet export; expected one of ${[...WALLET_UR_TYPES].join(', ')}`,\n { received: shown },\n );\n }\n\n let decoded: CborValue;\n try {\n decoded = cborDecode(cbor);\n } catch (e) {\n throw new EraSdkError('malformed-cbor', `cannot decode wallet UR: ${(e as Error).message}`);\n }\n const root = asMap(decoded);\n if (!root) {\n throw new EraSdkError('malformed-cbor', 'wallet UR is not a CBOR map');\n }\n\n // A standalone `crypto-hdkey` export (the single-account link some wallet\n // profiles use — e.g. the TON one: `{3: key, 6: keypath, 10: name}`) IS the\n // entry map itself: no master-fingerprint/list wrapper. The entry's origin\n // fingerprint doubles as the master fingerprint.\n if (type === 'crypto-hdkey') {\n const entry = tryParseEntry(decoded);\n if (!entry) {\n throw new EraSdkError(\n 'malformed-reply',\n 'crypto-hdkey export carries no derivable account (missing origin keypath)',\n );\n }\n return {\n masterFingerprint: entry.xfp ?? 0,\n deviceName: null,\n deviceId: null,\n deviceVersion: null,\n entries: [entry],\n };\n }\n\n const master = asUint(mapGet(root, 1));\n const list = asArray(mapGet(root, 2));\n if (master === undefined || !list) {\n throw new EraSdkError(\n 'malformed-reply',\n 'wallet UR missing master fingerprint (key 1) or accounts (key 2)',\n );\n }\n\n const entries: RawAccountEntry[] = [];\n for (const item of list) {\n const entry = tryParseEntry(item);\n if (entry) entries.push(entry);\n }\n if (entries.length === 0) {\n throw new EraSdkError(\n 'malformed-reply',\n 'wallet UR carries no account this SDK can derive an address from',\n );\n }\n\n return {\n masterFingerprint: Number(master & 0xffffffffn),\n deviceName: asText(mapGet(root, 3)) ?? null,\n deviceId: asText(mapGet(root, 4)) ?? null,\n deviceVersion: asText(mapGet(root, 5)) ?? null,\n entries,\n };\n}\n\nfunction tryParseEntry(item: CborValue): RawAccountEntry | null {\n const map = asMap(item);\n if (!map) return null;\n const origin = asMap(mapGet(map, 6));\n if (!origin) return null;\n\n const path = parsePathComponents(mapGet(origin, 1));\n if (!path || path.length === 0) return null;\n const xfpValue = asUint(mapGet(origin, 2));\n const xfp = xfpValue !== undefined && xfpValue <= 0xffffffffn ? Number(xfpValue) : null;\n\n const parentFp = asUint(mapGet(map, 8));\n return {\n path,\n xfp,\n publicKey: asBytes(mapGet(map, 3)) ?? null,\n chainCode: asBytes(mapGet(map, 4)) ?? null,\n parentFingerprint: parentFp !== undefined && parentFp <= 0xffffffffn ? Number(parentFp) : null,\n name: asText(mapGet(map, 9)) ?? null,\n note: asText(mapGet(map, 10)) ?? null,\n };\n}\n","import { EraSdkError } from '../core/errors';\nimport type { PathLevel } from '../registry/keypath';\nimport { formatPath, parsePath, pathEquals, xfpToHex } from '../registry/keypath';\nimport type { RawAccountEntry, RawMultiAccounts } from '../registry/multi-accounts';\nimport { parseMultiAccountsUr } from '../registry/multi-accounts';\nimport type { Ur } from '../ur/ur';\nimport {\n btcNestedSegwitAddressFromPublicKey,\n btcP2pkhAddressFromPublicKey,\n btcP2wpkhAddressFromPublicKey,\n cardanoSoftDerivePath,\n derivePublicKey,\n evmAddressFromPublicKey,\n serializeExtendedPublicKey,\n solanaAddressFromPublicKey,\n tronAddressFromPublicKey,\n ZPUB_VERSION,\n} from './derive';\n\n/** Chain family of an exported account, matched by its derivation path — never by the note label. */\nexport type AccountChain = 'evm' | 'btc' | 'solana' | 'tron' | 'ton' | 'cardano' | 'unknown';\n\nexport interface AccountKey {\n readonly chain: AccountChain;\n /** Account-level derivation path, e.g. `m/44'/60'/0'`. */\n readonly path: string;\n /**\n * The source fingerprint a `*-sign-request` keypath must carry for this\n * account (lowercase 8-hex). NOT necessarily the master fingerprint.\n */\n readonly xfp: string;\n /** 33-byte compressed secp256k1, or 32-byte Ed25519 (Solana); absent when the export omitted it. */\n readonly publicKey: Uint8Array | undefined;\n readonly chainCode: Uint8Array | undefined;\n readonly name: string | undefined;\n /** Derivation-scheme label (`account.standard`, ...) — display only. */\n readonly note: string | undefined;\n}\n\nexport interface DeviceInfo {\n readonly name: string | undefined;\n readonly id: string | undefined;\n readonly firmwareVersion: string | undefined;\n}\n\nfunction classify(path: readonly PathLevel[]): AccountChain {\n const p0 = path[0];\n const p1 = path[1];\n if (!p0 || !p1 || !p0.hardened || !p1.hardened) return 'unknown';\n if (p0.index === 44 && p1.index === 60) return 'evm';\n if (\n p1.index === 0 &&\n (p0.index === 84 || p0.index === 49 || p0.index === 44 || p0.index === 86)\n ) {\n return 'btc';\n }\n if (p0.index === 44 && p1.index === 501) return 'solana';\n if (p0.index === 44 && p1.index === 195) return 'tron';\n if (p0.index === 44 && p1.index === 607) return 'ton';\n if (p0.index === 1852 && p1.index === 1815) return 'cardano';\n return 'unknown';\n}\n\nfunction withChainCode(entry: RawAccountEntry): Uint8Array {\n if (!entry.chainCode) {\n throw new EraSdkError(\n 'account-not-found',\n `account ${formatPath([...entry.path])} carries no chain code; cannot derive children`,\n );\n }\n return entry.chainCode;\n}\n\n/** The entry's key at the required length, or a typed refusal (derivation only). */\nfunction requireKey(entry: RawAccountEntry, length: number): Uint8Array {\n if (!entry.publicKey || entry.publicKey.length !== length) {\n throw new EraSdkError(\n 'invalid-props',\n `account ${formatPath([...entry.path])} carries no ${length}-byte public key; ` +\n 'xfp lookup still works, address derivation does not',\n );\n }\n return entry.publicKey;\n}\n\n/** EVM view over the linked wallet: one account xpub, addresses derived at `0/index`. */\nexport class EvmAccountView {\n constructor(\n private readonly entry: RawAccountEntry,\n private readonly resolvedXfp: number,\n ) {}\n\n get xfp(): string {\n return xfpToHex(this.resolvedXfp);\n }\n\n get accountPath(): string {\n return formatPath([...this.entry.path]);\n }\n\n /** Signing path for address `index`: `<account>/0/<index>`. */\n pathFor(index: number): string {\n return `${this.accountPath}/0/${index}`;\n }\n\n deriveAddress(index: number): `0x${string}` {\n return evmAddressFromPublicKey(\n derivePublicKey(requireKey(this.entry, 33), withChainCode(this.entry), 0, index),\n );\n }\n\n xpub(): string {\n return extendedKeyOf(this.entry);\n }\n}\n\nexport type BtcPurpose = 44 | 49 | 84 | 86;\n\n/**\n * Bitcoin view over one exported account. The default is the BIP-84\n * native-segwit account; pass `purpose` to reach the other script types the\n * device exports (44 = legacy P2PKH — the kind the device signs MESSAGES for,\n * 49 = nested segwit, 86 = taproot).\n */\nexport class BtcAccountView {\n constructor(\n private readonly entry: RawAccountEntry,\n private readonly testnet: boolean,\n readonly purpose: BtcPurpose,\n private readonly resolvedXfp: number,\n ) {}\n\n get xfp(): string {\n return xfpToHex(this.resolvedXfp);\n }\n\n get accountPath(): string {\n return formatPath([...this.entry.path]);\n }\n\n receivePath(index: number): string {\n return `${this.accountPath}/0/${index}`;\n }\n\n changePath(index: number): string {\n return `${this.accountPath}/1/${index}`;\n }\n\n deriveAddress(index: number, options?: { change?: boolean }): string {\n const change = options?.change ? 1 : 0;\n const child = derivePublicKey(\n requireKey(this.entry, 33),\n withChainCode(this.entry),\n change,\n index,\n );\n switch (this.purpose) {\n case 84:\n return btcP2wpkhAddressFromPublicKey(child, this.testnet ? 'tb' : 'bc');\n case 44:\n return btcP2pkhAddressFromPublicKey(child, this.testnet);\n case 49:\n return btcNestedSegwitAddressFromPublicKey(child, this.testnet);\n case 86:\n throw new EraSdkError(\n 'invalid-props',\n 'taproot addresses need the BIP-341 output-key tweak; derive them from xpub() with your Bitcoin library',\n );\n }\n }\n\n xpub(): string {\n return extendedKeyOf(this.entry);\n }\n\n /** SLIP-132 zpub form of the BIP-84 key, for tools that require it. */\n zpub(): string {\n if (this.purpose !== 84) {\n throw new EraSdkError(\n 'invalid-props',\n 'zpub is the SLIP-132 form of the BIP-84 account only',\n );\n }\n return extendedKeyOf(this.entry, ZPUB_VERSION);\n }\n}\n\n/** Tron view: addresses derived at `0/index`. */\nexport class TronAccountView {\n constructor(\n private readonly entry: RawAccountEntry,\n private readonly resolvedXfp: number,\n ) {}\n\n get xfp(): string {\n return xfpToHex(this.resolvedXfp);\n }\n\n get accountPath(): string {\n return formatPath([...this.entry.path]);\n }\n\n pathFor(index: number): string {\n return `${this.accountPath}/0/${index}`;\n }\n\n deriveAddress(index: number): string {\n return tronAddressFromPublicKey(\n derivePublicKey(requireKey(this.entry, 33), withChainCode(this.entry), 0, index),\n );\n }\n}\n\n/**\n * TON view: one Ed25519 key per account (`m/44'/607'/0'`), shared by the\n * V4R2 and V5R1 wallet contracts — the contract version affects only the\n * ADDRESS, which this SDK leaves to TON tooling (derive it from `publicKey`\n * with @ton/core or equivalent).\n */\nexport class TonAccountView {\n constructor(\n private readonly entry: RawAccountEntry,\n private readonly resolvedXfp: number,\n ) {}\n\n get xfp(): string {\n return xfpToHex(this.resolvedXfp);\n }\n\n get accountPath(): string {\n return formatPath([...this.entry.path]);\n }\n\n /** 32-byte Ed25519 public key — the signer for both wallet-contract versions. */\n get publicKey(): Uint8Array {\n return requireKey(this.entry, 32);\n }\n\n get name(): string | undefined {\n return this.entry.name ?? this.entry.note ?? undefined;\n }\n}\n\n/**\n * Cardano view (CIP-1852): the exported account key supports SOFT public\n * derivation (BIP32-Ed25519), so payment (`0/i`), change (`1/i`) and stake\n * (`2/0`) verification keys derive locally. Bech32 ADDRESS assembly is left\n * to Cardano tooling — `deriveKey` hands you the raw vkeys it needs.\n */\nexport class CardanoAccountView {\n constructor(\n private readonly entry: RawAccountEntry,\n private readonly resolvedXfp: number,\n ) {}\n\n get xfp(): string {\n return xfpToHex(this.resolvedXfp);\n }\n\n get accountPath(): string {\n return formatPath([...this.entry.path]);\n }\n\n /** The account-level extended public key material. */\n get publicKey(): Uint8Array {\n return requireKey(this.entry, 32);\n }\n\n get chainCode(): Uint8Array {\n return withChainCode(this.entry);\n }\n\n /** Signing path for `role/index`, e.g. `pathFor(0, 0)` → `.../0/0`. */\n pathFor(role: number, index: number): string {\n return `${this.accountPath}/${role}/${index}`;\n }\n\n /** Soft-derived 32-byte verification key at `role/index` (0 payment, 1 change, 2 stake). */\n deriveKey(role: number, index: number): Uint8Array {\n return cardanoSoftDerivePath(requireKey(this.entry, 32), withChainCode(this.entry), [\n role,\n index,\n ]);\n }\n}\n\n/**\n * Solana view: Ed25519 has no public child derivation, so the device\n * pre-derives hardened accounts (`m/44'/501'/idx'`) and each entry IS a\n * signer. The public key, base58, IS the address.\n */\nexport class SolanaAccountView {\n constructor(\n private readonly entry: RawAccountEntry,\n private readonly resolvedXfp: number,\n ) {}\n\n get xfp(): string {\n return xfpToHex(this.resolvedXfp);\n }\n\n get path(): string {\n return formatPath([...this.entry.path]);\n }\n\n /** The hardened account index (third path level). */\n get index(): number {\n return this.entry.path[2]?.index ?? 0;\n }\n\n get publicKey(): Uint8Array {\n return requireKey(this.entry, 32);\n }\n\n get address(): string {\n return solanaAddressFromPublicKey(requireKey(this.entry, 32));\n }\n}\n\nfunction extendedKeyOf(entry: RawAccountEntry, version?: number): string {\n const chainCode = withChainCode(entry);\n const publicKey = requireKey(entry, 33);\n const last = entry.path[entry.path.length - 1]!;\n const args = {\n depth: entry.path.length,\n parentFingerprint: entry.parentFingerprint ?? 0,\n childNumber: last.hardened ? last.index + 0x80000000 : last.index,\n chainCode,\n publicKey,\n };\n return version === undefined\n ? serializeExtendedPublicKey(args)\n : serializeExtendedPublicKey({ ...args, version });\n}\n\n/**\n * The linked wallet: everything a software wallet extracts from the device's\n * `crypto-multi-accounts` QR. Parse once, store the source UR string, derive\n * addresses locally — the device is not needed again until signing.\n */\nexport class EraAccounts {\n private constructor(\n private readonly raw: RawMultiAccounts,\n readonly sourceUr: string | undefined,\n ) {}\n\n static fromUr(input: Ur | string): EraAccounts {\n const raw = parseMultiAccountsUr(input);\n return new EraAccounts(raw, typeof input === 'string' ? input : input.toString());\n }\n\n /** Master fingerprint, lowercase 8-hex. */\n get masterFingerprint(): string {\n return xfpToHex(this.raw.masterFingerprint);\n }\n\n get device(): DeviceInfo {\n return {\n name: this.raw.deviceName ?? undefined,\n id: this.raw.deviceId ?? undefined,\n firmwareVersion: this.raw.deviceVersion ?? undefined,\n };\n }\n\n get keys(): AccountKey[] {\n return this.raw.entries.map((entry) => ({\n chain: classify(entry.path),\n path: formatPath([...entry.path]),\n xfp: xfpToHex(entry.xfp ?? this.raw.masterFingerprint),\n publicKey: entry.publicKey ?? undefined,\n chainCode: entry.chainCode ?? undefined,\n name: entry.name ?? undefined,\n note: entry.note ?? undefined,\n }));\n }\n\n /**\n * The xfp a sign request must carry for the account whose path exactly\n * equals `accountPath`. Throws `account-not-found` — never a silent zero.\n */\n xfpFor(accountPath: string): string {\n return xfpToHex(this.resolveXfp(this.entryFor(accountPath)));\n }\n\n /** Entry xfp, falling back to the wrapper's master fingerprint (Cardano-style path-only origins). */\n private resolveXfp(entry: RawAccountEntry): number {\n return entry.xfp ?? this.raw.masterFingerprint;\n }\n\n /** The EVM account (standard `m/44'/60'/...` scheme), if the export carries one. */\n evm(): EvmAccountView | undefined {\n const entry =\n this.raw.entries.find(\n (e) => classify(e.path) === 'evm' && (e.note === null || e.note === 'account.standard'),\n ) ?? this.raw.entries.find((e) => classify(e.path) === 'evm');\n return entry ? new EvmAccountView(entry, this.resolveXfp(entry)) : undefined;\n }\n\n /**\n * A Bitcoin account view. Defaults to the BIP-84 native-segwit account;\n * pass `purpose: 44` for the legacy P2PKH account (message signing), 49 for\n * nested segwit, 86 for taproot — if the export carries them.\n */\n btc(options?: { testnet?: boolean; purpose?: BtcPurpose }): BtcAccountView | undefined {\n const purpose = options?.purpose ?? 84;\n const entry = this.raw.entries.find(\n (e) => classify(e.path) === 'btc' && e.path[0]?.index === purpose,\n );\n return entry\n ? new BtcAccountView(entry, options?.testnet ?? false, purpose, this.resolveXfp(entry))\n : undefined;\n }\n\n tron(): TronAccountView | undefined {\n const entry = this.raw.entries.find((e) => classify(e.path) === 'tron');\n return entry ? new TronAccountView(entry, this.resolveXfp(entry)) : undefined;\n }\n\n /** The TON account (linked via the Tonkeeper-style `crypto-hdkey` export). */\n ton(): TonAccountView | undefined {\n const entry = this.raw.entries.find(\n (e) => classify(e.path) === 'ton' && e.publicKey?.length === 32,\n );\n return entry ? new TonAccountView(entry, this.resolveXfp(entry)) : undefined;\n }\n\n /** The Cardano account (CIP-1852 Icarus export), if the export carries one. */\n cardano(): CardanoAccountView | undefined {\n const entry = this.raw.entries.find(\n (e) => classify(e.path) === 'cardano' && e.publicKey?.length === 32,\n );\n return entry ? new CardanoAccountView(entry, this.resolveXfp(entry)) : undefined;\n }\n\n /** All pre-derived Solana signers (usually `m/44'/501'/0'..9'`). */\n solana(): SolanaAccountView[] {\n return this.raw.entries\n .filter((e) => classify(e.path) === 'solana' && e.publicKey?.length === 32)\n .map((e) => new SolanaAccountView(e, this.resolveXfp(e)));\n }\n\n private entryFor(accountPath: string): RawAccountEntry {\n const levels = parsePath(accountPath);\n const entry = this.raw.entries.find((e) => pathEquals(e.path, levels));\n if (!entry) {\n throw new EraSdkError(\n 'account-not-found',\n `the linked wallet carries no account at ${accountPath}`,\n { path: accountPath },\n );\n }\n return entry;\n }\n}\n","import type { EraAccounts } from '../accounts/accounts';\nimport { EraAccounts as EraAccountsClass } from '../accounts/accounts';\nimport { cborEncode } from '../cbor/encode';\nimport type { CborValue } from '../cbor/model';\nimport { cbArray, cbMap, cbTag, cbText, cbUint } from '../cbor/model';\nimport type { ChainContext } from '../chains/shared';\nimport { EraSdkError } from '../core/errors';\nimport type { AnimatedUrOptions } from '../qr/animated-ur';\nimport { AnimatedUr } from '../qr/animated-ur';\nimport { keypath304, parsePath } from '../registry/keypath';\nimport { WALLET_UR_TYPES } from '../registry/multi-accounts';\nimport { TypedUrScanner } from '../scan/ur-scanner';\nimport type { Ur } from '../ur/ur';\nimport { Ur as UrValue } from '../ur/ur';\n\nexport type DerivationCurve = 'secp256k1' | 'ed25519';\nexport type DerivationAlgorithm = 'slip10' | 'bip32ed25519';\n\nexport interface KeyDerivationSchema {\n /** The derivation path to request, e.g. `m/44'/60'/0'`. */\n readonly path: string;\n /** Defaults to `secp256k1`. */\n readonly curve?: DerivationCurve;\n /** Defaults to `slip10`. */\n readonly algo?: DerivationAlgorithm;\n /** Optional chain hint shown by the device. */\n readonly chainType?: string;\n}\n\nexport interface KeyDerivationCallProps {\n readonly schemas: readonly KeyDerivationSchema[];\n readonly origin?: string;\n}\n\n/** The pull-model linking request: display it, then scan the device's account export back. */\nexport interface HardwareCallRequest {\n readonly ur: Ur;\n readonly replyTypes: readonly string[];\n toAnimated(options?: AnimatedUrOptions): AnimatedUr;\n scanner(): TypedUrScanner<EraAccounts>;\n}\n\nconst CURVES: Record<DerivationCurve, number> = { secp256k1: 0, ed25519: 1 };\nconst ALGOS: Record<DerivationAlgorithm, number> = { slip10: 0, bip32ed25519: 1 };\n\n/**\n * Build a `qr-hardware-call` (1201) wrapping a `key-derivation-call` (1301):\n * the WALLET asks the device for specific derivation paths, curves and\n * algorithms instead of accepting whatever the device's sync screen\n * volunteers. The device answers with a `crypto-multi-accounts` export, which\n * closes the loop through `parseAccounts`.\n *\n * Registry shape (Keystone-standard):\n * `1201({1: type=0, 2: 1301({1: [1302({1: 304(keypath), 2: curve, 3: algo, 4?: chainType})...]}), 3?: origin})`.\n */\nexport function generateKeyDerivationCall(\n context: ChainContext,\n props: KeyDerivationCallProps,\n): HardwareCallRequest {\n if (props.schemas.length === 0) {\n throw new EraSdkError('invalid-props', 'at least one derivation schema is required');\n }\n const schemas: CborValue[] = props.schemas.map((schema) => {\n const levels = parsePath(schema.path);\n const entries: [number, CborValue][] = [\n [1, keypath304(levels)],\n [2, cbUint(CURVES[schema.curve ?? 'secp256k1'])],\n [3, cbUint(ALGOS[schema.algo ?? 'slip10'])],\n ];\n if (schema.chainType !== undefined) entries.push([4, cbText(schema.chainType)]);\n return cbTag(1302, cbMap(entries));\n });\n\n const call = cbTag(1301, cbMap([[1, cbArray(schemas)]]));\n const root = cbMap([\n [1, cbUint(0)], // type: KeyDerivation\n [2, call],\n [3, cbText(props.origin ?? context.origin)],\n ]);\n\n const ur = new UrValue('qr-hardware-call', cborEncode(root));\n const replyTypes = [...WALLET_UR_TYPES];\n return {\n ur,\n replyTypes,\n toAnimated: (options?: AnimatedUrOptions) =>\n new AnimatedUr(ur, {\n maxFragmentLength: options?.maxFragmentLength ?? context.maxFragmentLength,\n }),\n scanner: () =>\n new TypedUrScanner<EraAccounts>({ expectedTypes: replyTypes }, (reply) =>\n EraAccountsClass.fromUr(reply),\n ),\n };\n}\n","import type { ChainContext } from './chains/shared';\nimport { toUr } from './chains/shared';\nimport type { AnimatedUrOptions } from './qr/animated-ur';\nimport { AnimatedUr } from './qr/animated-ur';\nimport type { Ur } from './ur/ur';\nimport { Ur as UrValue } from './ur/ur';\n\n/**\n * Escape hatch for UR types this SDK has no dedicated module for (future\n * chains, custom registry items). You bring the CBOR; the SDK brings the UR\n * plumbing, fountain frames and the hardened scanner\n * (`EraConnect.scanner({expectedTypes})`).\n */\nexport class RawModule {\n constructor(private readonly context: ChainContext) {}\n\n /** Wrap raw CBOR bytes in a UR of the given registry type. */\n ur(type: string, cbor: Uint8Array): Ur {\n return new UrValue(type, cbor);\n }\n\n /** Parse a single-part `ur:` string into a Ur. */\n parse(text: string): Ur {\n return toUr(text);\n }\n\n /** Fragment + animate any UR. */\n animate(ur: Ur, options?: AnimatedUrOptions): AnimatedUr {\n return new AnimatedUr(ur, {\n maxFragmentLength: options?.maxFragmentLength ?? this.context.maxFragmentLength,\n });\n }\n}\n","/**\n * ERA Connect SDK — air-gapped UR/QR linking and signing for the ERA\n * hardware wallet.\n *\n * Headless by design: you render the QR codes and own the camera; the SDK\n * owns every byte of the protocol. No network I/O, no Node built-ins,\n * `Uint8Array` end-to-end.\n */\n\nimport type { EraAccounts as EraAccountsType } from './accounts/accounts';\nimport { EraAccounts } from './accounts/accounts';\nimport { BtcChain } from './chains/btc';\nimport { CardanoChain } from './chains/cardano';\nimport { EvmChain } from './chains/evm';\nimport type { ChainContext, EraConnectConfig } from './chains/shared';\nimport { resolveContext } from './chains/shared';\nimport { SolanaChain } from './chains/solana';\nimport { TonChain } from './chains/ton';\nimport { TronChain } from './chains/tron';\nimport type { HardwareCallRequest, KeyDerivationCallProps } from './hardware-call/key-derivation';\nimport { generateKeyDerivationCall } from './hardware-call/key-derivation';\nimport { RawModule } from './raw';\nimport type { UrScannerOptions } from './scan/ur-scanner';\nimport { UrScanner } from './scan/ur-scanner';\nimport type { Ur } from './ur/ur';\n\n/** Timing/size constants of the device's own QR pipeline, for progress UI and timeouts. */\nexport const DeviceProfile = {\n /** What the phone displays to the device: ~200 wire bytes per frame at 8 fps. */\n phoneToDevice: { fragmentBytesOnWire: 200, payloadBytes: 180, frameIntervalMs: 125 },\n /**\n * What the device displays back: 150-byte fragments at 2.5 fps. Receiving\n * is SLOWER than sending — budget scan timeouts accordingly.\n */\n deviceToPhone: { fragmentBytesOnWire: 150, frameIntervalMs: 400 },\n} as const;\n\n/** The SDK facade. Cheap to construct; chain modules are created lazily. */\nexport class EraConnect {\n private readonly context: ChainContext;\n private _evm: EvmChain | undefined;\n private _btc: BtcChain | undefined;\n private _solana: SolanaChain | undefined;\n private _tron: TronChain | undefined;\n private _ton: TonChain | undefined;\n private _cardano: CardanoChain | undefined;\n private _raw: RawModule | undefined;\n\n constructor(config?: EraConnectConfig) {\n this.context = resolveContext(config);\n }\n\n get evm(): EvmChain {\n this._evm ??= new EvmChain(this.context);\n return this._evm;\n }\n\n get btc(): BtcChain {\n this._btc ??= new BtcChain(this.context);\n return this._btc;\n }\n\n get solana(): SolanaChain {\n this._solana ??= new SolanaChain(this.context);\n return this._solana;\n }\n\n get tron(): TronChain {\n this._tron ??= new TronChain(this.context);\n return this._tron;\n }\n\n get ton(): TonChain {\n this._ton ??= new TonChain(this.context);\n return this._ton;\n }\n\n get cardano(): CardanoChain {\n this._cardano ??= new CardanoChain(this.context);\n return this._cardano;\n }\n\n /** Escape hatch for UR types without a dedicated module. */\n get raw(): RawModule {\n this._raw ??= new RawModule(this.context);\n return this._raw;\n }\n\n /**\n * Linking: parse the device's `crypto-multi-accounts` export (a `Ur` from a\n * scanner, or a single-part `ur:` string).\n */\n parseAccounts(input: Ur | string): EraAccountsType {\n return EraAccounts.fromUr(input);\n }\n\n /**\n * Pull-model linking: ask the device for SPECIFIC derivations\n * (`qr-hardware-call` 1201). The device answers with a\n * `crypto-multi-accounts` export.\n */\n generateKeyDerivationCall(props: KeyDerivationCallProps): HardwareCallRequest {\n return generateKeyDerivationCall(this.context, props);\n }\n\n /** A type-agnostic hardened scanner (linking flows, raw flows). */\n scanner(options?: UrScannerOptions): UrScanner {\n return new UrScanner(options);\n }\n}\n\n// ---------------------------------------------------------------------------\n// Public types & modules\n// ---------------------------------------------------------------------------\n\nexport type { AccountChain, AccountKey, BtcPurpose, DeviceInfo } from './accounts/accounts';\nexport {\n BtcAccountView,\n CardanoAccountView,\n EraAccounts,\n EvmAccountView,\n SolanaAccountView,\n TonAccountView,\n TronAccountView,\n} from './accounts/accounts';\nexport type {\n BtcMessageSignatureResult,\n BtcMessageSignRequestProps,\n BtcPsbtResult,\n BtcPsbtSignRequestProps,\n} from './chains/btc';\nexport { BtcChain } from './chains/btc';\nexport type {\n CardanoCertKeyRef,\n CardanoSignatureResult,\n CardanoSignRequestProps,\n CardanoUtxoRef,\n CardanoWitness,\n} from './chains/cardano';\nexport { CardanoChain, parseWitnessSet } from './chains/cardano';\nexport type { EvmSignatureResult, EvmSignRequestProps } from './chains/evm';\nexport { EvmChain, EvmDataType } from './chains/evm';\nexport type {\n ChainContext,\n EraConnectConfig,\n ExpectedReply,\n SignRequest,\n} from './chains/shared';\nexport { DEFAULT_ORIGIN } from './chains/shared';\nexport type { SolSignatureResult, SolSignRequestProps } from './chains/solana';\nexport { SolanaChain, SolSignType } from './chains/solana';\nexport type { TonSignatureResult, TonSignRequestProps } from './chains/ton';\nexport { TonChain, TonDataType } from './chains/ton';\nexport type { TronLatestBlock, TronSignatureResult, TronSignRequestProps } from './chains/tron';\nexport { TronChain } from './chains/tron';\n// UTF-8 helpers that work on every Hermes version (TextEncoder does not):\nexport { utf8Decode, utf8Encode } from './core/bytes';\nexport type { EraErrorCode } from './core/errors';\nexport { EraSdkError } from './core/errors';\nexport type { RandomBytesFn } from './core/rand';\nexport type {\n DerivationAlgorithm,\n DerivationCurve,\n HardwareCallRequest,\n KeyDerivationCallProps,\n KeyDerivationSchema,\n} from './hardware-call/key-derivation';\nexport type { AnimatedUrOptions } from './qr/animated-ur';\nexport { AnimatedUr, DEFAULT_FRAGMENT_LENGTH } from './qr/animated-ur';\nexport { RawModule } from './raw';\nexport type { ScanFeedResult, ScanRejection, UrScannerOptions } from './scan/ur-scanner';\nexport { TypedUrScanner, UrScanner } from './scan/ur-scanner';\nexport { UrLimits } from './ur/limits';\nexport { Ur } from './ur/ur';\n"],"mappings":";;;;;;;;;;AA6CA,MAAa,kCAAuC,IAAI,IAAI;CAC1D;CACA;CACA;AACF,CAAC;;;;;;;;;AAUD,SAAgB,qBAAqB,OAAsC;CACzE,IAAI;CACJ,IAAI;CACJ,IAAI,OAAO,UAAU,UAAU;EAC7B,MAAM,SAAS,cAAc,KAAK;EAClC,IAAI,OAAO,QAAQ,MACjB,MAAM,IAAI,YACR,iBACA,0DACF;EAEF,OAAO,OAAO;EACd,OAAO,OAAO;CAChB,OAAO;EACL,OAAO,MAAM;EACb,OAAO,MAAM;CACf;CAEA,IAAI,CAAC,gBAAgB,IAAI,IAAI,GAAG;EAG9B,MAAM,QAAQ,KAAK,SAAS,KAAK,GAAG,KAAK,MAAM,GAAG,EAAE,EAAE,KAAK;EAC3D,MAAM,IAAI,YACR,iBACA,IAAI,MAAM,4CAA4C,CAAC,GAAG,eAAe,CAAC,CAAC,KAAK,IAAI,KACpF,EAAE,UAA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I,MAAiB;EACnB,KAAK,SAAL,KAAK,OAAS,IAAI,UAAU,KAAK,OAAO;EACxC,OAAO,KAAK;CACd;;;;;CAMA,cAAc,OAAqC;EACjD,OAAO,YAAY,OAAO,KAAK;CACjC;;;;;;CAOA,0BAA0B,OAAoD;EAC5E,OAAO,0BAA0B,KAAK,SAAS,KAAK;CACtD;;CAGA,QAAQ,SAAuC;EAC7C,OAAO,IAAI,UAAU,OAAO;CAC9B;AACF"}
1
+ {"version":3,"file":"index.js","names":["UrValue","EraAccountsClass","UrValue"],"sources":["../src/registry/multi-accounts.ts","../src/accounts/accounts.ts","../src/hardware-call/key-derivation.ts","../src/raw.ts","../src/index.ts"],"sourcesContent":["import { cborDecode } from '../cbor/decode';\nimport type { CborValue } from '../cbor/model';\nimport { asArray, asBytes, asMap, asText, asUint, mapGet } from '../cbor/model';\nimport { EraSdkError } from '../core/errors';\nimport { parseUrString, type Ur } from '../ur/ur';\nimport type { PathLevel } from './keypath';\nimport { parsePathComponents } from './keypath';\n\n/**\n * Raw account entry parsed from a `crypto-multi-accounts` (1103) export.\n *\n * `xfp` is the entry's ORIGIN source fingerprint (`crypto-keypath` key 2) —\n * the value a `*-sign-request` keypath must carry. It is NOT the top-level\n * master fingerprint, although the two often coincide.\n */\nexport interface RawAccountEntry {\n readonly path: readonly PathLevel[];\n /**\n * The origin's source fingerprint, when the export carries one. Cardano\n * entries deliberately ship a path-only origin — resolve against the\n * wrapper's master fingerprint in that case.\n */\n readonly xfp: number | null;\n /**\n * Nullable and length-unconstrained, as in the reference implementation: an\n * entry without a usable key still resolves its xfp for signing — only the\n * address-derivation views require the 33/32-byte forms.\n */\n readonly publicKey: Uint8Array | null;\n readonly chainCode: Uint8Array | null;\n readonly parentFingerprint: number | null;\n readonly name: string | null;\n /** A label string (`account.standard`, ...) — NEVER chain metadata. */\n readonly note: string | null;\n}\n\nexport interface RawMultiAccounts {\n readonly masterFingerprint: number;\n readonly deviceName: string | null;\n readonly deviceId: string | null;\n readonly deviceVersion: string | null;\n readonly entries: readonly RawAccountEntry[];\n}\n\n/** UR types a device links a watch-only wallet with. */\nexport const WALLET_UR_TYPES: ReadonlySet<string> = new Set([\n 'crypto-multi-accounts',\n 'crypto-account',\n 'crypto-hdkey',\n]);\n\n/**\n * Parse a wallet-export UR.\n *\n * Of the three admitted link types only the `crypto-multi-accounts` shape\n * yields derivable accounts; an export that yields none is refused rather\n * than stored as an unusable wallet. Malformed entries are skipped\n * individually so one foreign item does not abort the rest.\n */\nexport function parseMultiAccountsUr(input: Ur | string): RawMultiAccounts {\n let type: string;\n let cbor: Uint8Array;\n if (typeof input === 'string') {\n const parsed = parseUrString(input);\n if (parsed.seq !== null) {\n throw new EraSdkError(\n 'invalid-props',\n 'multi-part UR string: assemble it with a UrScanner first',\n );\n }\n type = parsed.type;\n cbor = parsed.payload;\n } else {\n type = input.type;\n cbor = input.cbor;\n }\n\n if (!WALLET_UR_TYPES.has(type)) {\n // The type is attacker-sized (the UR grammar allows an unbounded letter\n // run) — truncate before it reaches a message or error data.\n const shown = type.length > 32 ? `${type.slice(0, 32)}…` : type;\n throw new EraSdkError(\n 'wrong-ur-type',\n `\"${shown}\" is not a wallet export; expected one of ${[...WALLET_UR_TYPES].join(', ')}`,\n { received: shown },\n );\n }\n\n let decoded: CborValue;\n try {\n decoded = cborDecode(cbor);\n } catch (e) {\n throw new EraSdkError('malformed-cbor', `cannot decode wallet UR: ${(e as Error).message}`);\n }\n const root = asMap(decoded);\n if (!root) {\n throw new EraSdkError('malformed-cbor', 'wallet UR is not a CBOR map');\n }\n\n // A standalone `crypto-hdkey` export (the single-account link some wallet\n // profiles use — e.g. the TON one: `{3: key, 6: keypath, 10: name}`) IS the\n // entry map itself: no master-fingerprint/list wrapper. The entry's origin\n // fingerprint doubles as the master fingerprint.\n if (type === 'crypto-hdkey') {\n const entry = tryParseEntry(decoded);\n if (!entry) {\n throw new EraSdkError(\n 'malformed-reply',\n 'crypto-hdkey export carries no derivable account (missing origin keypath)',\n );\n }\n return {\n masterFingerprint: entry.xfp ?? 0,\n deviceName: null,\n deviceId: null,\n deviceVersion: null,\n entries: [entry],\n };\n }\n\n const master = asUint(mapGet(root, 1));\n const list = asArray(mapGet(root, 2));\n if (master === undefined || !list) {\n throw new EraSdkError(\n 'malformed-reply',\n 'wallet UR missing master fingerprint (key 1) or accounts (key 2)',\n );\n }\n\n const entries: RawAccountEntry[] = [];\n for (const item of list) {\n const entry = tryParseEntry(item);\n if (entry) entries.push(entry);\n }\n if (entries.length === 0) {\n throw new EraSdkError(\n 'malformed-reply',\n 'wallet UR carries no account this SDK can derive an address from',\n );\n }\n\n return {\n masterFingerprint: Number(master & 0xffffffffn),\n deviceName: asText(mapGet(root, 3)) ?? null,\n deviceId: asText(mapGet(root, 4)) ?? null,\n deviceVersion: asText(mapGet(root, 5)) ?? null,\n entries,\n };\n}\n\nfunction tryParseEntry(item: CborValue): RawAccountEntry | null {\n const map = asMap(item);\n if (!map) return null;\n const origin = asMap(mapGet(map, 6));\n if (!origin) return null;\n\n const path = parsePathComponents(mapGet(origin, 1));\n if (!path || path.length === 0) return null;\n const xfpValue = asUint(mapGet(origin, 2));\n const xfp = xfpValue !== undefined && xfpValue <= 0xffffffffn ? Number(xfpValue) : null;\n\n const parentFp = asUint(mapGet(map, 8));\n return {\n path,\n xfp,\n publicKey: asBytes(mapGet(map, 3)) ?? null,\n chainCode: asBytes(mapGet(map, 4)) ?? null,\n parentFingerprint: parentFp !== undefined && parentFp <= 0xffffffffn ? Number(parentFp) : null,\n name: asText(mapGet(map, 9)) ?? null,\n note: asText(mapGet(map, 10)) ?? null,\n };\n}\n","import { EraSdkError } from '../core/errors';\nimport type { PathLevel } from '../registry/keypath';\nimport { formatPath, parsePath, pathEquals, xfpToHex } from '../registry/keypath';\nimport type { RawAccountEntry, RawMultiAccounts } from '../registry/multi-accounts';\nimport { parseMultiAccountsUr } from '../registry/multi-accounts';\nimport type { Ur } from '../ur/ur';\nimport {\n bchAddressFromPublicKey,\n btcNestedSegwitAddressFromPublicKey,\n btcP2pkhAddressFromPublicKey,\n btcP2wpkhAddressFromPublicKey,\n cardanoSoftDerivePath,\n derivePublicKey,\n evmAddressFromPublicKey,\n serializeExtendedPublicKey,\n solanaAddressFromPublicKey,\n suiAddressFromPublicKey,\n tronAddressFromPublicKey,\n ZPUB_VERSION,\n} from './derive';\n\n/** Chain family of an exported account, matched by its derivation path — never by the note label. */\nexport type AccountChain =\n | 'evm'\n | 'btc'\n | 'bch'\n | 'solana'\n | 'tron'\n | 'ton'\n | 'cardano'\n | 'sui'\n | 'cosmos'\n | 'unknown';\n\nexport interface AccountKey {\n readonly chain: AccountChain;\n /** Account-level derivation path, e.g. `m/44'/60'/0'`. */\n readonly path: string;\n /**\n * The source fingerprint a `*-sign-request` keypath must carry for this\n * account (lowercase 8-hex). NOT necessarily the master fingerprint.\n */\n readonly xfp: string;\n /** 33-byte compressed secp256k1, or 32-byte Ed25519 (Solana); absent when the export omitted it. */\n readonly publicKey: Uint8Array | undefined;\n readonly chainCode: Uint8Array | undefined;\n readonly name: string | undefined;\n /** Derivation-scheme label (`account.standard`, ...) — display only. */\n readonly note: string | undefined;\n}\n\nexport interface DeviceInfo {\n readonly name: string | undefined;\n readonly id: string | undefined;\n readonly firmwareVersion: string | undefined;\n}\n\nfunction classify(path: readonly PathLevel[]): AccountChain {\n const p0 = path[0];\n const p1 = path[1];\n if (!p0 || !p1 || !p0.hardened || !p1.hardened) return 'unknown';\n if (p0.index === 44 && p1.index === 60) return 'evm';\n if (\n p1.index === 0 &&\n (p0.index === 84 || p0.index === 49 || p0.index === 44 || p0.index === 86)\n ) {\n return 'btc';\n }\n if (p0.index === 44 && p1.index === 145) return 'bch';\n if (p0.index === 44 && p1.index === 501) return 'solana';\n if (p0.index === 44 && p1.index === 195) return 'tron';\n if (p0.index === 44 && p1.index === 607) return 'ton';\n if (p0.index === 1852 && p1.index === 1815) return 'cardano';\n if (p0.index === 44 && p1.index === 784) return 'sui';\n if (p0.index === 44 && p1.index === 118) return 'cosmos';\n return 'unknown';\n}\n\nfunction withChainCode(entry: RawAccountEntry): Uint8Array {\n if (!entry.chainCode) {\n throw new EraSdkError(\n 'account-not-found',\n `account ${formatPath([...entry.path])} carries no chain code; cannot derive children`,\n );\n }\n return entry.chainCode;\n}\n\n/** The entry's key at the required length, or a typed refusal (derivation only). */\nfunction requireKey(entry: RawAccountEntry, length: number): Uint8Array {\n if (!entry.publicKey || entry.publicKey.length !== length) {\n throw new EraSdkError(\n 'invalid-props',\n `account ${formatPath([...entry.path])} carries no ${length}-byte public key; ` +\n 'xfp lookup still works, address derivation does not',\n );\n }\n return entry.publicKey;\n}\n\n/** EVM view over the linked wallet: one account xpub, addresses derived at `0/index`. */\nexport class EvmAccountView {\n constructor(\n private readonly entry: RawAccountEntry,\n private readonly resolvedXfp: number,\n ) {}\n\n get xfp(): string {\n return xfpToHex(this.resolvedXfp);\n }\n\n get accountPath(): string {\n return formatPath([...this.entry.path]);\n }\n\n /** Signing path for address `index`: `<account>/0/<index>`. */\n pathFor(index: number): string {\n return `${this.accountPath}/0/${index}`;\n }\n\n deriveAddress(index: number): `0x${string}` {\n return evmAddressFromPublicKey(\n derivePublicKey(requireKey(this.entry, 33), withChainCode(this.entry), 0, index),\n );\n }\n\n xpub(): string {\n return extendedKeyOf(this.entry);\n }\n}\n\nexport type BtcPurpose = 44 | 49 | 84 | 86;\n\n/**\n * Bitcoin view over one exported account. The default is the BIP-84\n * native-segwit account; pass `purpose` to reach the other script types the\n * device exports (44 = legacy P2PKH — the kind the device signs MESSAGES for,\n * 49 = nested segwit, 86 = taproot).\n */\nexport class BtcAccountView {\n constructor(\n private readonly entry: RawAccountEntry,\n private readonly testnet: boolean,\n readonly purpose: BtcPurpose,\n private readonly resolvedXfp: number,\n ) {}\n\n get xfp(): string {\n return xfpToHex(this.resolvedXfp);\n }\n\n get accountPath(): string {\n return formatPath([...this.entry.path]);\n }\n\n receivePath(index: number): string {\n return `${this.accountPath}/0/${index}`;\n }\n\n changePath(index: number): string {\n return `${this.accountPath}/1/${index}`;\n }\n\n deriveAddress(index: number, options?: { change?: boolean }): string {\n const change = options?.change ? 1 : 0;\n const child = derivePublicKey(\n requireKey(this.entry, 33),\n withChainCode(this.entry),\n change,\n index,\n );\n switch (this.purpose) {\n case 84:\n return btcP2wpkhAddressFromPublicKey(child, this.testnet ? 'tb' : 'bc');\n case 44:\n return btcP2pkhAddressFromPublicKey(child, this.testnet);\n case 49:\n return btcNestedSegwitAddressFromPublicKey(child, this.testnet);\n case 86:\n throw new EraSdkError(\n 'invalid-props',\n 'taproot addresses need the BIP-341 output-key tweak; derive them from xpub() with your Bitcoin library',\n );\n }\n }\n\n xpub(): string {\n return extendedKeyOf(this.entry);\n }\n\n /** SLIP-132 zpub form of the BIP-84 key, for tools that require it. */\n zpub(): string {\n if (this.purpose !== 84) {\n throw new EraSdkError(\n 'invalid-props',\n 'zpub is the SLIP-132 form of the BIP-84 account only',\n );\n }\n return extendedKeyOf(this.entry, ZPUB_VERSION);\n }\n}\n\n/** Tron view: addresses derived at `0/index`. */\nexport class TronAccountView {\n constructor(\n private readonly entry: RawAccountEntry,\n private readonly resolvedXfp: number,\n ) {}\n\n get xfp(): string {\n return xfpToHex(this.resolvedXfp);\n }\n\n get accountPath(): string {\n return formatPath([...this.entry.path]);\n }\n\n pathFor(index: number): string {\n return `${this.accountPath}/0/${index}`;\n }\n\n deriveAddress(index: number): string {\n return tronAddressFromPublicKey(\n derivePublicKey(requireKey(this.entry, 33), withChainCode(this.entry), 0, index),\n );\n }\n}\n\n/** Bitcoin Cash view: `m/44'/145'/0'`, CashAddr P2PKH addresses. */\nexport class BchAccountView {\n constructor(\n private readonly entry: RawAccountEntry,\n private readonly resolvedXfp: number,\n ) {}\n\n get xfp(): string {\n return xfpToHex(this.resolvedXfp);\n }\n\n get accountPath(): string {\n return formatPath([...this.entry.path]);\n }\n\n receivePath(index: number): string {\n return `${this.accountPath}/0/${index}`;\n }\n\n changePath(index: number): string {\n return `${this.accountPath}/1/${index}`;\n }\n\n /** The compressed public key at receive/change `index` — what a sign request's input names. */\n derivePublicKey(index: number, options?: { change?: boolean }): Uint8Array {\n return derivePublicKey(\n requireKey(this.entry, 33),\n withChainCode(this.entry),\n options?.change ? 1 : 0,\n index,\n );\n }\n\n /** Bare CashAddr by default; `{ withPrefix: true }` for `bitcoincash:...`. */\n deriveAddress(index: number, options?: { change?: boolean; withPrefix?: boolean }): string {\n return bchAddressFromPublicKey(this.derivePublicKey(index, options), {\n withPrefix: options?.withPrefix ?? false,\n });\n }\n}\n\n/**\n * TON view: one Ed25519 key per account (`m/44'/607'/0'`), shared by the\n * V4R2 and V5R1 wallet contracts — the contract version affects only the\n * ADDRESS, which this SDK leaves to TON tooling (derive it from `publicKey`\n * with @ton/core or equivalent).\n */\nexport class TonAccountView {\n constructor(\n private readonly entry: RawAccountEntry,\n private readonly resolvedXfp: number,\n ) {}\n\n get xfp(): string {\n return xfpToHex(this.resolvedXfp);\n }\n\n get accountPath(): string {\n return formatPath([...this.entry.path]);\n }\n\n /** 32-byte Ed25519 public key — the signer for both wallet-contract versions. */\n get publicKey(): Uint8Array {\n return requireKey(this.entry, 32);\n }\n\n get name(): string | undefined {\n return this.entry.name ?? this.entry.note ?? undefined;\n }\n}\n\n/**\n * Cardano view (CIP-1852): the exported account key supports SOFT public\n * derivation (BIP32-Ed25519), so payment (`0/i`), change (`1/i`) and stake\n * (`2/0`) verification keys derive locally. Bech32 ADDRESS assembly is left\n * to Cardano tooling — `deriveKey` hands you the raw vkeys it needs.\n */\nexport class CardanoAccountView {\n constructor(\n private readonly entry: RawAccountEntry,\n private readonly resolvedXfp: number,\n ) {}\n\n get xfp(): string {\n return xfpToHex(this.resolvedXfp);\n }\n\n get accountPath(): string {\n return formatPath([...this.entry.path]);\n }\n\n /** The account-level extended public key material. */\n get publicKey(): Uint8Array {\n return requireKey(this.entry, 32);\n }\n\n get chainCode(): Uint8Array {\n return withChainCode(this.entry);\n }\n\n /** Signing path for `role/index`, e.g. `pathFor(0, 0)` → `.../0/0`. */\n pathFor(role: number, index: number): string {\n return `${this.accountPath}/${role}/${index}`;\n }\n\n /** Soft-derived 32-byte verification key at `role/index` (0 payment, 1 change, 2 stake). */\n deriveKey(role: number, index: number): Uint8Array {\n return cardanoSoftDerivePath(requireKey(this.entry, 32), withChainCode(this.entry), [\n role,\n index,\n ]);\n }\n}\n\n/** Sui view: like Solana, each fully-hardened exported entry IS a signer. */\nexport class SuiAccountView {\n constructor(\n private readonly entry: RawAccountEntry,\n private readonly resolvedXfp: number,\n ) {}\n\n get xfp(): string {\n return xfpToHex(this.resolvedXfp);\n }\n\n get path(): string {\n return formatPath([...this.entry.path]);\n }\n\n get publicKey(): Uint8Array {\n return requireKey(this.entry, 32);\n }\n\n /** `0x` Sui address: BLAKE2b-256 of `0x00 || publicKey`. */\n get address(): string {\n return suiAddressFromPublicKey(requireKey(this.entry, 32));\n }\n}\n\n/**\n * Solana view: Ed25519 has no public child derivation, so the device\n * pre-derives hardened accounts (`m/44'/501'/idx'`) and each entry IS a\n * signer. The public key, base58, IS the address.\n */\nexport class SolanaAccountView {\n constructor(\n private readonly entry: RawAccountEntry,\n private readonly resolvedXfp: number,\n ) {}\n\n get xfp(): string {\n return xfpToHex(this.resolvedXfp);\n }\n\n get path(): string {\n return formatPath([...this.entry.path]);\n }\n\n /** The hardened account index (third path level). */\n get index(): number {\n return this.entry.path[2]?.index ?? 0;\n }\n\n get publicKey(): Uint8Array {\n return requireKey(this.entry, 32);\n }\n\n get address(): string {\n return solanaAddressFromPublicKey(requireKey(this.entry, 32));\n }\n}\n\nfunction extendedKeyOf(entry: RawAccountEntry, version?: number): string {\n const chainCode = withChainCode(entry);\n const publicKey = requireKey(entry, 33);\n const last = entry.path[entry.path.length - 1]!;\n const args = {\n depth: entry.path.length,\n parentFingerprint: entry.parentFingerprint ?? 0,\n childNumber: last.hardened ? last.index + 0x80000000 : last.index,\n chainCode,\n publicKey,\n };\n return version === undefined\n ? serializeExtendedPublicKey(args)\n : serializeExtendedPublicKey({ ...args, version });\n}\n\n/**\n * The linked wallet: everything a software wallet extracts from the device's\n * `crypto-multi-accounts` QR. Parse once, store the source UR string, derive\n * addresses locally — the device is not needed again until signing.\n */\nexport class EraAccounts {\n private constructor(\n private readonly raw: RawMultiAccounts,\n readonly sourceUr: string | undefined,\n ) {}\n\n static fromUr(input: Ur | string): EraAccounts {\n const raw = parseMultiAccountsUr(input);\n return new EraAccounts(raw, typeof input === 'string' ? input : input.toString());\n }\n\n /** Master fingerprint, lowercase 8-hex. */\n get masterFingerprint(): string {\n return xfpToHex(this.raw.masterFingerprint);\n }\n\n get device(): DeviceInfo {\n return {\n name: this.raw.deviceName ?? undefined,\n id: this.raw.deviceId ?? undefined,\n firmwareVersion: this.raw.deviceVersion ?? undefined,\n };\n }\n\n get keys(): AccountKey[] {\n return this.raw.entries.map((entry) => ({\n chain: classify(entry.path),\n path: formatPath([...entry.path]),\n xfp: xfpToHex(entry.xfp ?? this.raw.masterFingerprint),\n publicKey: entry.publicKey ?? undefined,\n chainCode: entry.chainCode ?? undefined,\n name: entry.name ?? undefined,\n note: entry.note ?? undefined,\n }));\n }\n\n /**\n * The xfp a sign request must carry for the account whose path exactly\n * equals `accountPath`. Throws `account-not-found` — never a silent zero.\n */\n xfpFor(accountPath: string): string {\n return xfpToHex(this.resolveXfp(this.entryFor(accountPath)));\n }\n\n /** Entry xfp, falling back to the wrapper's master fingerprint (Cardano-style path-only origins). */\n private resolveXfp(entry: RawAccountEntry): number {\n return entry.xfp ?? this.raw.masterFingerprint;\n }\n\n /** The EVM account (standard `m/44'/60'/...` scheme), if the export carries one. */\n evm(): EvmAccountView | undefined {\n const entry =\n this.raw.entries.find(\n (e) => classify(e.path) === 'evm' && (e.note === null || e.note === 'account.standard'),\n ) ?? this.raw.entries.find((e) => classify(e.path) === 'evm');\n return entry ? new EvmAccountView(entry, this.resolveXfp(entry)) : undefined;\n }\n\n /**\n * A Bitcoin account view. Defaults to the BIP-84 native-segwit account;\n * pass `purpose: 44` for the legacy P2PKH account (message signing), 49 for\n * nested segwit, 86 for taproot — if the export carries them.\n */\n btc(options?: { testnet?: boolean; purpose?: BtcPurpose }): BtcAccountView | undefined {\n const purpose = options?.purpose ?? 84;\n const entry = this.raw.entries.find(\n (e) => classify(e.path) === 'btc' && e.path[0]?.index === purpose,\n );\n return entry\n ? new BtcAccountView(entry, options?.testnet ?? false, purpose, this.resolveXfp(entry))\n : undefined;\n }\n\n tron(): TronAccountView | undefined {\n const entry = this.raw.entries.find((e) => classify(e.path) === 'tron');\n return entry ? new TronAccountView(entry, this.resolveXfp(entry)) : undefined;\n }\n\n /** The Bitcoin Cash account (`m/44'/145'/0'`), if the export carries one. */\n bch(): BchAccountView | undefined {\n const entry = this.raw.entries.find((e) => classify(e.path) === 'bch');\n return entry ? new BchAccountView(entry, this.resolveXfp(entry)) : undefined;\n }\n\n /** The TON account (linked via the Tonkeeper-style `crypto-hdkey` export). */\n ton(): TonAccountView | undefined {\n const entry = this.raw.entries.find(\n (e) => classify(e.path) === 'ton' && e.publicKey?.length === 32,\n );\n return entry ? new TonAccountView(entry, this.resolveXfp(entry)) : undefined;\n }\n\n /** All exported Sui signers (fully hardened SLIP-10 entries). */\n sui(): SuiAccountView[] {\n return this.raw.entries\n .filter((e) => classify(e.path) === 'sui' && e.publicKey?.length === 32)\n .map((e) => new SuiAccountView(e, this.resolveXfp(e)));\n }\n\n /** The Cardano account (CIP-1852 Icarus export), if the export carries one. */\n cardano(): CardanoAccountView | undefined {\n const entry = this.raw.entries.find(\n (e) => classify(e.path) === 'cardano' && e.publicKey?.length === 32,\n );\n return entry ? new CardanoAccountView(entry, this.resolveXfp(entry)) : undefined;\n }\n\n /** All pre-derived Solana signers (usually `m/44'/501'/0'..9'`). */\n solana(): SolanaAccountView[] {\n return this.raw.entries\n .filter((e) => classify(e.path) === 'solana' && e.publicKey?.length === 32)\n .map((e) => new SolanaAccountView(e, this.resolveXfp(e)));\n }\n\n private entryFor(accountPath: string): RawAccountEntry {\n const levels = parsePath(accountPath);\n const entry = this.raw.entries.find((e) => pathEquals(e.path, levels));\n if (!entry) {\n throw new EraSdkError(\n 'account-not-found',\n `the linked wallet carries no account at ${accountPath}`,\n { path: accountPath },\n );\n }\n return entry;\n }\n}\n","import type { EraAccounts } from '../accounts/accounts';\nimport { EraAccounts as EraAccountsClass } from '../accounts/accounts';\nimport { cborEncode } from '../cbor/encode';\nimport type { CborValue } from '../cbor/model';\nimport { cbArray, cbMap, cbTag, cbText, cbUint } from '../cbor/model';\nimport type { ChainContext } from '../chains/shared';\nimport { EraSdkError } from '../core/errors';\nimport type { AnimatedUrOptions } from '../qr/animated-ur';\nimport { AnimatedUr } from '../qr/animated-ur';\nimport { keypath304, parsePath } from '../registry/keypath';\nimport { WALLET_UR_TYPES } from '../registry/multi-accounts';\nimport { TypedUrScanner } from '../scan/ur-scanner';\nimport type { Ur } from '../ur/ur';\nimport { Ur as UrValue } from '../ur/ur';\n\nexport type DerivationCurve = 'secp256k1' | 'ed25519';\nexport type DerivationAlgorithm = 'slip10' | 'bip32ed25519';\n\nexport interface KeyDerivationSchema {\n /** The derivation path to request, e.g. `m/44'/60'/0'`. */\n readonly path: string;\n /** Defaults to `secp256k1`. */\n readonly curve?: DerivationCurve;\n /** Defaults to `slip10`. */\n readonly algo?: DerivationAlgorithm;\n /** Optional chain hint shown by the device. */\n readonly chainType?: string;\n}\n\nexport interface KeyDerivationCallProps {\n readonly schemas: readonly KeyDerivationSchema[];\n readonly origin?: string;\n}\n\n/** The pull-model linking request: display it, then scan the device's account export back. */\nexport interface HardwareCallRequest {\n readonly ur: Ur;\n readonly replyTypes: readonly string[];\n toAnimated(options?: AnimatedUrOptions): AnimatedUr;\n scanner(): TypedUrScanner<EraAccounts>;\n}\n\nconst CURVES: Record<DerivationCurve, number> = { secp256k1: 0, ed25519: 1 };\nconst ALGOS: Record<DerivationAlgorithm, number> = { slip10: 0, bip32ed25519: 1 };\n\n/**\n * Build a `qr-hardware-call` (1201) wrapping a `key-derivation-call` (1301):\n * the WALLET asks the device for specific derivation paths, curves and\n * algorithms instead of accepting whatever the device's sync screen\n * volunteers. The device answers with a `crypto-multi-accounts` export, which\n * closes the loop through `parseAccounts`.\n *\n * Registry shape (Keystone-standard):\n * `1201({1: type=0, 2: 1301({1: [1302({1: 304(keypath), 2: curve, 3: algo, 4?: chainType})...]}), 3?: origin})`.\n */\nexport function generateKeyDerivationCall(\n context: ChainContext,\n props: KeyDerivationCallProps,\n): HardwareCallRequest {\n if (props.schemas.length === 0) {\n throw new EraSdkError('invalid-props', 'at least one derivation schema is required');\n }\n const schemas: CborValue[] = props.schemas.map((schema) => {\n const levels = parsePath(schema.path);\n const entries: [number, CborValue][] = [\n [1, keypath304(levels)],\n [2, cbUint(CURVES[schema.curve ?? 'secp256k1'])],\n [3, cbUint(ALGOS[schema.algo ?? 'slip10'])],\n ];\n if (schema.chainType !== undefined) entries.push([4, cbText(schema.chainType)]);\n return cbTag(1302, cbMap(entries));\n });\n\n const call = cbTag(1301, cbMap([[1, cbArray(schemas)]]));\n const root = cbMap([\n [1, cbUint(0)], // type: KeyDerivation\n [2, call],\n [3, cbText(props.origin ?? context.origin)],\n ]);\n\n const ur = new UrValue('qr-hardware-call', cborEncode(root));\n const replyTypes = [...WALLET_UR_TYPES];\n return {\n ur,\n replyTypes,\n toAnimated: (options?: AnimatedUrOptions) =>\n new AnimatedUr(ur, {\n maxFragmentLength: options?.maxFragmentLength ?? context.maxFragmentLength,\n }),\n scanner: () =>\n new TypedUrScanner<EraAccounts>({ expectedTypes: replyTypes }, (reply) =>\n EraAccountsClass.fromUr(reply),\n ),\n };\n}\n","import type { ChainContext } from './chains/shared';\nimport { toUr } from './chains/shared';\nimport type { AnimatedUrOptions } from './qr/animated-ur';\nimport { AnimatedUr } from './qr/animated-ur';\nimport type { Ur } from './ur/ur';\nimport { Ur as UrValue } from './ur/ur';\n\n/**\n * Escape hatch for UR types this SDK has no dedicated module for (future\n * chains, custom registry items). You bring the CBOR; the SDK brings the UR\n * plumbing, fountain frames and the hardened scanner\n * (`EraConnect.scanner({expectedTypes})`).\n */\nexport class RawModule {\n constructor(private readonly context: ChainContext) {}\n\n /** Wrap raw CBOR bytes in a UR of the given registry type. */\n ur(type: string, cbor: Uint8Array): Ur {\n return new UrValue(type, cbor);\n }\n\n /** Parse a single-part `ur:` string into a Ur. */\n parse(text: string): Ur {\n return toUr(text);\n }\n\n /** Fragment + animate any UR. */\n animate(ur: Ur, options?: AnimatedUrOptions): AnimatedUr {\n return new AnimatedUr(ur, {\n maxFragmentLength: options?.maxFragmentLength ?? this.context.maxFragmentLength,\n });\n }\n}\n","/**\n * ERA Connect SDK — air-gapped UR/QR linking and signing for the ERA\n * hardware wallet.\n *\n * Headless by design: you render the QR codes and own the camera; the SDK\n * owns every byte of the protocol. No network I/O, no Node built-ins,\n * `Uint8Array` end-to-end.\n */\n\nimport type { EraAccounts as EraAccountsType } from './accounts/accounts';\nimport { EraAccounts } from './accounts/accounts';\nimport { BtcChain } from './chains/btc';\nimport { CardanoChain } from './chains/cardano';\n\nexport type {\n CosmosSignatureResult,\n CosmosSignRequestProps,\n EthermintSignRequestProps,\n} from './chains/cosmos';\nexport type {\n SuiSignatureResult,\n SuiSignHashRequestProps,\n SuiSignRequestProps,\n} from './chains/sui';\nexport type { XrpSignatureResult, XrpSignRequestProps } from './chains/xrp';\n\nimport { BchChain } from './chains/bch';\nimport { CosmosChain } from './chains/cosmos';\nimport { EvmChain } from './chains/evm';\nimport type { ChainContext, EraConnectConfig } from './chains/shared';\nimport { resolveContext } from './chains/shared';\nimport { SolanaChain } from './chains/solana';\nimport { SuiChain } from './chains/sui';\nimport { TonChain } from './chains/ton';\nimport { TronChain } from './chains/tron';\nimport { XrpChain } from './chains/xrp';\nimport type { HardwareCallRequest, KeyDerivationCallProps } from './hardware-call/key-derivation';\nimport { generateKeyDerivationCall } from './hardware-call/key-derivation';\nimport { RawModule } from './raw';\nimport type { UrScannerOptions } from './scan/ur-scanner';\nimport { UrScanner } from './scan/ur-scanner';\nimport type { Ur } from './ur/ur';\n\n/** Timing/size constants of the device's own QR pipeline, for progress UI and timeouts. */\nexport const DeviceProfile = {\n /** What the phone displays to the device: ~200 wire bytes per frame at 8 fps. */\n phoneToDevice: { fragmentBytesOnWire: 200, payloadBytes: 180, frameIntervalMs: 125 },\n /**\n * What the device displays back: 150-byte fragments at 2.5 fps. Receiving\n * is SLOWER than sending — budget scan timeouts accordingly.\n */\n deviceToPhone: { fragmentBytesOnWire: 150, frameIntervalMs: 400 },\n} as const;\n\n/** The SDK facade. Cheap to construct; chain modules are created lazily. */\nexport class EraConnect {\n private readonly context: ChainContext;\n private _evm: EvmChain | undefined;\n private _btc: BtcChain | undefined;\n private _solana: SolanaChain | undefined;\n private _tron: TronChain | undefined;\n private _bch: BchChain | undefined;\n private _ton: TonChain | undefined;\n private _cardano: CardanoChain | undefined;\n private _sui: SuiChain | undefined;\n private _cosmos: CosmosChain | undefined;\n private _xrp: XrpChain | undefined;\n private _raw: RawModule | undefined;\n\n constructor(config?: EraConnectConfig) {\n this.context = resolveContext(config);\n }\n\n get evm(): EvmChain {\n this._evm ??= new EvmChain(this.context);\n return this._evm;\n }\n\n get btc(): BtcChain {\n this._btc ??= new BtcChain(this.context);\n return this._btc;\n }\n\n get solana(): SolanaChain {\n this._solana ??= new SolanaChain(this.context);\n return this._solana;\n }\n\n get tron(): TronChain {\n this._tron ??= new TronChain(this.context);\n return this._tron;\n }\n\n /** Bitcoin Cash — the structured keystone envelope (see `@hwlt/era-connect/bch`). */\n get bch(): BchChain {\n this._bch ??= new BchChain(this.context);\n return this._bch;\n }\n\n get ton(): TonChain {\n this._ton ??= new TonChain(this.context);\n return this._ton;\n }\n\n get cardano(): CardanoChain {\n this._cardano ??= new CardanoChain(this.context);\n return this._cardano;\n }\n\n get sui(): SuiChain {\n this._sui ??= new SuiChain(this.context);\n return this._sui;\n }\n\n get cosmos(): CosmosChain {\n this._cosmos ??= new CosmosChain(this.context);\n return this._cosmos;\n }\n\n get xrp(): XrpChain {\n this._xrp ??= new XrpChain(this.context);\n return this._xrp;\n }\n\n /** Escape hatch for UR types without a dedicated module. */\n get raw(): RawModule {\n this._raw ??= new RawModule(this.context);\n return this._raw;\n }\n\n /**\n * Linking: parse the device's `crypto-multi-accounts` export (a `Ur` from a\n * scanner, or a single-part `ur:` string).\n */\n parseAccounts(input: Ur | string): EraAccountsType {\n return EraAccounts.fromUr(input);\n }\n\n /**\n * Pull-model linking: ask the device for SPECIFIC derivations\n * (`qr-hardware-call` 1201). The device answers with a\n * `crypto-multi-accounts` export.\n */\n generateKeyDerivationCall(props: KeyDerivationCallProps): HardwareCallRequest {\n return generateKeyDerivationCall(this.context, props);\n }\n\n /** A type-agnostic hardened scanner (linking flows, raw flows). */\n scanner(options?: UrScannerOptions): UrScanner {\n return new UrScanner(options);\n }\n}\n\n// ---------------------------------------------------------------------------\n// Public types & modules\n// ---------------------------------------------------------------------------\n\nexport type { AccountChain, AccountKey, BtcPurpose, DeviceInfo } from './accounts/accounts';\nexport {\n BchAccountView,\n BtcAccountView,\n CardanoAccountView,\n EraAccounts,\n EvmAccountView,\n SolanaAccountView,\n SuiAccountView,\n TonAccountView,\n TronAccountView,\n} from './accounts/accounts';\nexport type {\n BchSignatureResult,\n BchSignRequestProps,\n BchTxInput,\n BchTxOutput,\n} from './chains/bch';\nexport { BchChain } from './chains/bch';\nexport type {\n BtcMessageSignatureResult,\n BtcMessageSignRequestProps,\n BtcPsbtResult,\n BtcPsbtSignRequestProps,\n} from './chains/btc';\nexport { BtcChain } from './chains/btc';\nexport type {\n CardanoCertKeyRef,\n CardanoSignatureResult,\n CardanoSignRequestProps,\n CardanoUtxoRef,\n CardanoWitness,\n} from './chains/cardano';\nexport { CardanoChain, parseWitnessSet } from './chains/cardano';\nexport { CosmosChain, CosmosDataType } from './chains/cosmos';\nexport type { EvmSignatureResult, EvmSignRequestProps } from './chains/evm';\nexport { EvmChain, EvmDataType } from './chains/evm';\nexport type {\n ChainContext,\n EraConnectConfig,\n ExpectedReply,\n SignRequest,\n} from './chains/shared';\nexport { DEFAULT_ORIGIN } from './chains/shared';\nexport type { SolSignatureResult, SolSignRequestProps } from './chains/solana';\nexport { SolanaChain, SolSignType } from './chains/solana';\nexport { SuiChain, suiIntentDigest } from './chains/sui';\nexport type { TonSignatureResult, TonSignRequestProps } from './chains/ton';\nexport { TonChain, TonDataType } from './chains/ton';\nexport type { TronLatestBlock, TronSignatureResult, TronSignRequestProps } from './chains/tron';\nexport { TronChain } from './chains/tron';\nexport { XrpChain } from './chains/xrp';\n// UTF-8 helpers that work on every Hermes version (TextEncoder does not):\nexport { utf8Decode, utf8Encode } from './core/bytes';\nexport type { EraErrorCode } from './core/errors';\nexport { EraSdkError } from './core/errors';\nexport type { RandomBytesFn } from './core/rand';\nexport type {\n DerivationAlgorithm,\n DerivationCurve,\n HardwareCallRequest,\n KeyDerivationCallProps,\n KeyDerivationSchema,\n} from './hardware-call/key-derivation';\nexport type { AnimatedUrOptions } from './qr/animated-ur';\nexport { AnimatedUr, DEFAULT_FRAGMENT_LENGTH } from './qr/animated-ur';\nexport { RawModule } from './raw';\nexport type { ScanFeedResult, ScanRejection, UrScannerOptions } from './scan/ur-scanner';\nexport { TypedUrScanner, UrScanner } from './scan/ur-scanner';\nexport { UrLimits } from './ur/limits';\nexport { Ur } from './ur/ur';\n"],"mappings":";;;;;;;;;;;;;;;AA6CA,MAAa,kCAAuC,IAAI,IAAI;CAC1D;CACA;CACA;AACF,CAAC;;;;;;;;;AAUD,SAAgB,qBAAqB,OAAsC;CACzE,IAAI;CACJ,IAAI;CACJ,IAAI,OAAO,UAAU,UAAU;EAC7B,MAAM,SAAS,cAAc,KAAK;EAClC,IAAI,OAAO,QAAQ,MACjB,MAAM,IAAI,YACR,iBACA,0DACF;EAEF,OAAO,OAAO;EACd,OAAO,OAAO;CAChB,OAAO;EACL,OAAO,MAAM;EACb,OAAO,MAAM;CACf;CAEA,IAAI,CAAC,gBAAgB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int, V as cbTag, j as asArray } from "./shared-Bbgejrus.js";
2
+ //#region src/registry/keypath.ts
3
+ const PATH_LEVEL = /^(\d+)('?)$/;
4
+ const HARDENED_OFFSET = 2147483648;
5
+ /** Parse `m/44'/60'/0'/0/5` into levels. Throws `invalid-props` on anything else. */
6
+ function parsePath(path) {
7
+ if (!path.startsWith("m/")) throw new EraSdkError("invalid-props", `derivation path must start with "m/": ${path}`);
8
+ const segments = path.slice(2).split("/");
9
+ const levels = [];
10
+ for (const segment of segments) {
11
+ const match = PATH_LEVEL.exec(segment);
12
+ if (!match) throw new EraSdkError("invalid-props", `bad derivation path segment "${segment}"`);
13
+ const index = Number(match[1]);
14
+ if (!Number.isSafeInteger(index) || index >= HARDENED_OFFSET) throw new EraSdkError("invalid-props", `derivation index out of range in "${segment}"`);
15
+ levels.push({
16
+ index,
17
+ hardened: match[2] === "'"
18
+ });
19
+ }
20
+ if (levels.length === 0) throw new EraSdkError("invalid-props", "derivation path has no levels");
21
+ return levels;
22
+ }
23
+ function formatPath(levels) {
24
+ return `m/${levels.map((l) => `${l.index}${l.hardened ? "'" : ""}`).join("/")}`;
25
+ }
26
+ function pathEquals(a, b) {
27
+ if (a.length !== b.length) return false;
28
+ return a.every((l, i) => l.index === b[i].index && l.hardened === b[i].hardened);
29
+ }
30
+ /** Flat `[index, hardened, index, hardened, ...]` component list. */
31
+ function pathComponentsCbor(levels) {
32
+ const items = [];
33
+ for (const level of levels) items.push(cbUint(level.index), cbBool(level.hardened));
34
+ return cbArray(items);
35
+ }
36
+ /** A `crypto-keypath` (tag 304): `{1: components, 2: xfp}` (key 2 omitted when no xfp). */
37
+ function keypath304(levels, xfp) {
38
+ const entries = [[1, pathComponentsCbor(levels)]];
39
+ if (xfp !== void 0) entries.push([2, cbUint(xfp)]);
40
+ return cbTag(304, cbMap(entries));
41
+ }
42
+ /** Parse the flat component list of a `crypto-keypath` back into levels (null on malformed). */
43
+ function parsePathComponents(value) {
44
+ const items = asArray(value);
45
+ if (!items || items.length % 2 !== 0) return null;
46
+ const levels = [];
47
+ for (let i = 0; i < items.length; i += 2) {
48
+ const index = asUint(items[i]);
49
+ const hardened = asBool(items[i + 1]);
50
+ if (index === void 0 || hardened === void 0 || index >= BigInt(HARDENED_OFFSET)) return null;
51
+ levels.push({
52
+ index: Number(index),
53
+ hardened
54
+ });
55
+ }
56
+ return levels;
57
+ }
58
+ /** Normalize an xfp given as a u32 int or an 8-hex string into a u32 number. */
59
+ function normalizeXfp(xfp) {
60
+ if (typeof xfp === "number") {
61
+ if (!Number.isSafeInteger(xfp) || xfp < 0 || xfp > 4294967295) throw new EraSdkError("invalid-props", "xfp must be an unsigned 32-bit integer");
62
+ return xfp;
63
+ }
64
+ const hex = xfp.startsWith("0x") ? xfp.slice(2) : xfp;
65
+ if (!/^[0-9a-fA-F]{1,8}$/.test(hex)) throw new EraSdkError("invalid-props", "xfp string must be up to 8 hex characters");
66
+ return Number.parseInt(hex, 16);
67
+ }
68
+ /** Lowercase 8-hex form of an xfp (the display / Tron wire form). */
69
+ function xfpToHex(xfp) {
70
+ return xfp.toString(16).padStart(8, "0");
71
+ }
72
+ //#endregion
73
+ export { parsePathComponents as a, parsePath as i, keypath304 as n, pathEquals as o, normalizeXfp as r, xfpToHex as s, formatPath as t };
74
+
75
+ //# sourceMappingURL=keypath-Bvv_cfHt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keypath-Bvv_cfHt.js","names":[],"sources":["../src/registry/keypath.ts"],"sourcesContent":["import type { CborValue } from '../cbor/model';\nimport { asArray, asBool, asUint, cbArray, cbBool, cbMap, cbTag, cbUint } from '../cbor/model';\nimport { EraSdkError } from '../core/errors';\n\n/** One BIP-32 derivation level: child index plus the hardened flag (`'`). */\nexport interface PathLevel {\n readonly index: number;\n readonly hardened: boolean;\n}\n\nconst PATH_LEVEL = /^(\\d+)('?)$/;\nconst HARDENED_OFFSET = 0x80000000;\n\n/** Parse `m/44'/60'/0'/0/5` into levels. Throws `invalid-props` on anything else. */\nexport function parsePath(path: string): PathLevel[] {\n if (!path.startsWith('m/')) {\n throw new EraSdkError('invalid-props', `derivation path must start with \"m/\": ${path}`);\n }\n const segments = path.slice(2).split('/');\n const levels: PathLevel[] = [];\n for (const segment of segments) {\n const match = PATH_LEVEL.exec(segment);\n if (!match) {\n throw new EraSdkError('invalid-props', `bad derivation path segment \"${segment}\"`);\n }\n const index = Number(match[1]);\n if (!Number.isSafeInteger(index) || index >= HARDENED_OFFSET) {\n throw new EraSdkError('invalid-props', `derivation index out of range in \"${segment}\"`);\n }\n levels.push({ index, hardened: match[2] === \"'\" });\n }\n if (levels.length === 0) {\n throw new EraSdkError('invalid-props', 'derivation path has no levels');\n }\n return levels;\n}\n\nexport function formatPath(levels: readonly PathLevel[]): string {\n return `m/${levels.map((l) => `${l.index}${l.hardened ? \"'\" : ''}`).join('/')}`;\n}\n\nexport function pathEquals(a: readonly PathLevel[], b: readonly PathLevel[]): boolean {\n if (a.length !== b.length) return false;\n return a.every((l, i) => l.index === b[i]!.index && l.hardened === b[i]!.hardened);\n}\n\n/** Flat `[index, hardened, index, hardened, ...]` component list. */\nexport function pathComponentsCbor(levels: readonly PathLevel[]): CborValue {\n const items: CborValue[] = [];\n for (const level of levels) {\n items.push(cbUint(level.index), cbBool(level.hardened));\n }\n return cbArray(items);\n}\n\n/** A `crypto-keypath` (tag 304): `{1: components, 2: xfp}` (key 2 omitted when no xfp). */\nexport function keypath304(levels: readonly PathLevel[], xfp?: number): CborValue {\n const entries: [number, CborValue][] = [[1, pathComponentsCbor(levels)]];\n if (xfp !== undefined) entries.push([2, cbUint(xfp)]);\n return cbTag(304, cbMap(entries));\n}\n\n/** Parse the flat component list of a `crypto-keypath` back into levels (null on malformed). */\nexport function parsePathComponents(value: CborValue | undefined): PathLevel[] | null {\n const items = asArray(value);\n if (!items || items.length % 2 !== 0) return null;\n const levels: PathLevel[] = [];\n for (let i = 0; i < items.length; i += 2) {\n const index = asUint(items[i]);\n const hardened = asBool(items[i + 1]);\n if (index === undefined || hardened === undefined || index >= BigInt(HARDENED_OFFSET)) {\n return null;\n }\n levels.push({ index: Number(index), hardened });\n }\n return levels;\n}\n\n/** Normalize an xfp given as a u32 int or an 8-hex string into a u32 number. */\nexport function normalizeXfp(xfp: number | string): number {\n if (typeof xfp === 'number') {\n if (!Number.isSafeInteger(xfp) || xfp < 0 || xfp > 0xffffffff) {\n throw new EraSdkError('invalid-props', 'xfp must be an unsigned 32-bit integer');\n }\n return xfp;\n }\n const hex = xfp.startsWith('0x') ? xfp.slice(2) : xfp;\n if (!/^[0-9a-fA-F]{1,8}$/.test(hex)) {\n throw new EraSdkError('invalid-props', 'xfp string must be up to 8 hex characters');\n }\n return Number.parseInt(hex, 16);\n}\n\n/** Lowercase 8-hex form of an xfp (the display / Tron wire form). */\nexport function xfpToHex(xfp: number): string {\n return xfp.toString(16).padStart(8, '0');\n}\n"],"mappings":";;AAUA,MAAM,aAAa;AACnB,MAAM,kBAAkB;;AAGxB,SAAgB,UAAU,MAA2B;CACnD,IAAI,CAAC,KAAK,WAAW,IAAI,GACvB,MAAM,IAAI,YAAY,iBAAiB,yCAAyC,MAAM;CAExF,MAAM,WAAW,KAAK,MAAM,CAAC,CAAC,CAAC,MAAM,GAAG;CACxC,MAAM,SAAsB,CAAC;CAC7B,KAAK,MAAM,WAAW,UAAU;EAC9B,MAAM,QAAQ,WAAW,KAAK,OAAO;EACrC,IAAI,CAAC,OACH,MAAM,IAAI,YAAY,iBAAiB,gCAAgC,QAAQ,EAAE;EAEnF,MAAM,QAAQ,OAAO,MAAM,EAAE;EAC7B,IAAI,CAAC,OAAO,cAAc,KAAK,KAAK,SAAS,iBAC3C,MAAM,IAAI,YAAY,iBAAiB,qCAAqC,QAAQ,EAAE;EAExF,OAAO,KAAK;GAAE;GAAO,UAAU,MAAM,OAAO;EAAI,CAAC;CACnD;CACA,IAAI,OAAO,WAAW,GACpB,MAAM,IAAI,YAAY,iBAAiB,+BAA+B;CAExE,OAAO;AACT;AAEA,SAA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U;EAC3B,IAAI,CAAC,OAAO,cAAc,GAAG,KAAK,MAAM,KAAK,MAAM,YACjD,MAAM,IAAI,YAAY,iBAAiB,wCAAwC;EAEjF,OAAO;CACT;CACA,MAAM,MAAM,IAAI,WAAW,IAAI,IAAI,IAAI,MAAM,CAAC,IAAI;CAClD,IAAI,CAAC,qBAAqB,KAAK,GAAG,GAChC,MAAM,IAAI,YAAY,iBAAiB,2CAA2C;CAEpF,OAAO,OAAO,SAAS,KAAK,EAAE;AAChC;;AAGA,SAAgB,SAAS,KAAqB;CAC5C,OAAO,IAAI,SAAS,EAAE,CAAC,CAAC,SAAS,GAAG,GAAG;AACzC"}
@@ -0,0 +1,116 @@
1
+ const require_shared = require("./shared-Cu2yynP9.cjs");
2
+ //#region src/registry/keypath.ts
3
+ const PATH_LEVEL = /^(\d+)('?)$/;
4
+ const HARDENED_OFFSET = 2147483648;
5
+ /** Parse `m/44'/60'/0'/0/5` into levels. Throws `invalid-props` on anything else. */
6
+ function parsePath(path) {
7
+ if (!path.startsWith("m/")) throw new require_shared.EraSdkError("invalid-props", `derivation path must start with "m/": ${path}`);
8
+ const segments = path.slice(2).split("/");
9
+ const levels = [];
10
+ for (const segment of segments) {
11
+ const match = PATH_LEVEL.exec(segment);
12
+ if (!match) throw new require_shared.EraSdkError("invalid-props", `bad derivation path segment "${segment}"`);
13
+ const index = Number(match[1]);
14
+ if (!Number.isSafeInteger(index) || index >= HARDENED_OFFSET) throw new require_shared.EraSdkError("invalid-props", `derivation index out of range in "${segment}"`);
15
+ levels.push({
16
+ index,
17
+ hardened: match[2] === "'"
18
+ });
19
+ }
20
+ if (levels.length === 0) throw new require_shared.EraSdkError("invalid-props", "derivation path has no levels");
21
+ return levels;
22
+ }
23
+ function formatPath(levels) {
24
+ return `m/${levels.map((l) => `${l.index}${l.hardened ? "'" : ""}`).join("/")}`;
25
+ }
26
+ function pathEquals(a, b) {
27
+ if (a.length !== b.length) return false;
28
+ return a.every((l, i) => l.index === b[i].index && l.hardened === b[i].hardened);
29
+ }
30
+ /** Flat `[index, hardened, index, hardened, ...]` component list. */
31
+ function pathComponentsCbor(levels) {
32
+ const items = [];
33
+ for (const level of levels) items.push(require_shared.cbUint(level.index), require_shared.cbBool(level.hardened));
34
+ return require_shared.cbArray(items);
35
+ }
36
+ /** A `crypto-keypath` (tag 304): `{1: components, 2: xfp}` (key 2 omitted when no xfp). */
37
+ function keypath304(levels, xfp) {
38
+ const entries = [[1, pathComponentsCbor(levels)]];
39
+ if (xfp !== void 0) entries.push([2, require_shared.cbUint(xfp)]);
40
+ return require_shared.cbTag(304, require_shared.cbMap(entries));
41
+ }
42
+ /** Parse the flat component list of a `crypto-keypath` back into levels (null on malformed). */
43
+ function parsePathComponents(value) {
44
+ const items = require_shared.asArray(value);
45
+ if (!items || items.length % 2 !== 0) return null;
46
+ const levels = [];
47
+ for (let i = 0; i < items.length; i += 2) {
48
+ const index = require_shared.asUint(items[i]);
49
+ const hardened = require_shared.asBool(items[i + 1]);
50
+ if (index === void 0 || hardened === void 0 || index >= BigInt(HARDENED_OFFSET)) return null;
51
+ levels.push({
52
+ index: Number(index),
53
+ hardened
54
+ });
55
+ }
56
+ return levels;
57
+ }
58
+ /** Normalize an xfp given as a u32 int or an 8-hex string into a u32 number. */
59
+ function normalizeXfp(xfp) {
60
+ if (typeof xfp === "number") {
61
+ if (!Number.isSafeInteger(xfp) || xfp < 0 || xfp > 4294967295) throw new require_shared.EraSdkError("invalid-props", "xfp must be an unsigned 32-bit integer");
62
+ return xfp;
63
+ }
64
+ const hex = xfp.startsWith("0x") ? xfp.slice(2) : xfp;
65
+ if (!/^[0-9a-fA-F]{1,8}$/.test(hex)) throw new require_shared.EraSdkError("invalid-props", "xfp string must be up to 8 hex characters");
66
+ return Number.parseInt(hex, 16);
67
+ }
68
+ /** Lowercase 8-hex form of an xfp (the display / Tron wire form). */
69
+ function xfpToHex(xfp) {
70
+ return xfp.toString(16).padStart(8, "0");
71
+ }
72
+ //#endregion
73
+ Object.defineProperty(exports, "formatPath", {
74
+ enumerable: true,
75
+ get: function() {
76
+ return formatPath;
77
+ }
78
+ });
79
+ Object.defineProperty(exports, "keypath304", {
80
+ enumerable: true,
81
+ get: function() {
82
+ return keypath304;
83
+ }
84
+ });
85
+ Object.defineProperty(exports, "normalizeXfp", {
86
+ enumerable: true,
87
+ get: function() {
88
+ return normalizeXfp;
89
+ }
90
+ });
91
+ Object.defineProperty(exports, "parsePath", {
92
+ enumerable: true,
93
+ get: function() {
94
+ return parsePath;
95
+ }
96
+ });
97
+ Object.defineProperty(exports, "parsePathComponents", {
98
+ enumerable: true,
99
+ get: function() {
100
+ return parsePathComponents;
101
+ }
102
+ });
103
+ Object.defineProperty(exports, "pathEquals", {
104
+ enumerable: true,
105
+ get: function() {
106
+ return pathEquals;
107
+ }
108
+ });
109
+ Object.defineProperty(exports, "xfpToHex", {
110
+ enumerable: true,
111
+ get: function() {
112
+ return xfpToHex;
113
+ }
114
+ });
115
+
116
+ //# sourceMappingURL=keypath-pzm_YIfN.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keypath-pzm_YIfN.cjs","names":["EraSdkError","cbUint","cbBool","cbArray","cbTag","cbMap","asArray","asUint","asBool"],"sources":["../src/registry/keypath.ts"],"sourcesContent":["import type { CborValue } from '../cbor/model';\nimport { asArray, asBool, asUint, cbArray, cbBool, cbMap, cbTag, cbUint } from '../cbor/model';\nimport { EraSdkError } from '../core/errors';\n\n/** One BIP-32 derivation level: child index plus the hardened flag (`'`). */\nexport interface PathLevel {\n readonly index: number;\n readonly hardened: boolean;\n}\n\nconst PATH_LEVEL = /^(\\d+)('?)$/;\nconst HARDENED_OFFSET = 0x80000000;\n\n/** Parse `m/44'/60'/0'/0/5` into levels. Throws `invalid-props` on anything else. */\nexport function parsePath(path: string): PathLevel[] {\n if (!path.startsWith('m/')) {\n throw new EraSdkError('invalid-props', `derivation path must start with \"m/\": ${path}`);\n }\n const segments = path.slice(2).split('/');\n const levels: PathLevel[] = [];\n for (const segment of segments) {\n const match = PATH_LEVEL.exec(segment);\n if (!match) {\n throw new EraSdkError('invalid-props', `bad derivation path segment \"${segment}\"`);\n }\n const index = Number(match[1]);\n if (!Number.isSafeInteger(index) || index >= HARDENED_OFFSET) {\n throw new EraSdkError('invalid-props', `derivation index out of range in \"${segment}\"`);\n }\n levels.push({ index, hardened: match[2] === \"'\" });\n }\n if (levels.length === 0) {\n throw new EraSdkError('invalid-props', 'derivation path has no levels');\n }\n return levels;\n}\n\nexport function formatPath(levels: readonly PathLevel[]): string {\n return `m/${levels.map((l) => `${l.index}${l.hardened ? \"'\" : ''}`).join('/')}`;\n}\n\nexport function pathEquals(a: readonly PathLevel[], b: readonly PathLevel[]): boolean {\n if (a.length !== b.length) return false;\n return a.every((l, i) => l.index === b[i]!.index && l.hardened === b[i]!.hardened);\n}\n\n/** Flat `[index, hardened, index, hardened, ...]` component list. */\nexport function pathComponentsCbor(levels: readonly PathLevel[]): CborValue {\n const items: CborValue[] = [];\n for (const level of levels) {\n items.push(cbUint(level.index), cbBool(level.hardened));\n }\n return cbArray(items);\n}\n\n/** A `crypto-keypath` (tag 304): `{1: components, 2: xfp}` (key 2 omitted when no xfp). */\nexport function keypath304(levels: readonly PathLevel[], xfp?: number): CborValue {\n const entries: [number, CborValue][] = [[1, pathComponentsCbor(levels)]];\n if (xfp !== undefined) entries.push([2, cbUint(xfp)]);\n return cbTag(304, cbMap(entries));\n}\n\n/** Parse the flat component list of a `crypto-keypath` back into levels (null on malformed). */\nexport function parsePathComponents(value: CborValue | undefined): PathLevel[] | null {\n const items = asArray(value);\n if (!items || items.length % 2 !== 0) return null;\n const levels: PathLevel[] = [];\n for (let i = 0; i < items.length; i += 2) {\n const index = asUint(items[i]);\n const hardened = asBool(items[i + 1]);\n if (index === undefined || hardened === undefined || index >= BigInt(HARDENED_OFFSET)) {\n return null;\n }\n levels.push({ index: Number(index), hardened });\n }\n return levels;\n}\n\n/** Normalize an xfp given as a u32 int or an 8-hex string into a u32 number. */\nexport function normalizeXfp(xfp: number | string): number {\n if (typeof xfp === 'number') {\n if (!Number.isSafeInteger(xfp) || xfp < 0 || xfp > 0xffffffff) {\n throw new EraSdkError('invalid-props', 'xfp must be an unsigned 32-bit integer');\n }\n return xfp;\n }\n const hex = xfp.startsWith('0x') ? xfp.slice(2) : xfp;\n if (!/^[0-9a-fA-F]{1,8}$/.test(hex)) {\n throw new EraSdkError('invalid-props', 'xfp string must be up to 8 hex characters');\n }\n return Number.parseInt(hex, 16);\n}\n\n/** Lowercase 8-hex form of an xfp (the display / Tron wire form). */\nexport function xfpToHex(xfp: number): string {\n return xfp.toString(16).padStart(8, '0');\n}\n"],"mappings":";;AAUA,MAAM,aAAa;AACnB,MAAM,kBAAkB;;AAGxB,SAAgB,UAAU,MAA2B;CACnD,IAAI,CAAC,KAAK,WAAW,IAAI,GACvB,MAAM,IAAIA,eAAAA,YAAY,iBAAiB,yCAAyC,MAAM;CAExF,MAAM,WAAW,KAAK,MAAM,CAAC,CAAC,CAAC,MAAM,GAAG;CACxC,MAAM,SAAsB,CAAC;CAC7B,KAAK,MAAM,WAAW,UAAU;EAC9B,MAAM,QAAQ,WAAW,KAAK,OAAO;EACrC,IAAI,CAAC,OACH,MAAM,IAAIA,eAAAA,YAAY,iBAAiB,gCAAgC,QAAQ,EAAE;EAEnF,MAAM,QAAQ,OAAO,MAAM,EAAE;EAC7B,IAAI,CAAC,OAAO,cAAc,KAAK,KAAK,SAAS,iBAC3C,MAAM,IAAIA,eAAAA,YAAY,iBAAiB,qCAAqC,QAAQ,EAAE;EAExF,OAAO,KAAK;GAAE;GAAO,UAAU,MAAM,OAAO;EAAI,CAAC;CACnD;CACA,IAAI,OAAO,WAAW,GACpB,MAAM,IAAIA,eAAAA,YAAY,iBAAiB,+BAA+B;CAExE,OAAO;AACT;AAEA,SAAgB,WAAW,QAAsC;CAC/D,OAAO,KAAK,OAAO,KAAK,MAAM,GAAG,EAAE,QAAQ,EAAE,WAAW,MAAM,IAAI,CAAC,C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c,GAAG,KAAK,MAAM,KAAK,MAAM,YACjD,MAAM,IAAIR,eAAAA,YAAY,iBAAiB,wCAAwC;EAEjF,OAAO;CACT;CACA,MAAM,MAAM,IAAI,WAAW,IAAI,IAAI,IAAI,MAAM,CAAC,IAAI;CAClD,IAAI,CAAC,qBAAqB,KAAK,GAAG,GAChC,MAAM,IAAIA,eAAAA,YAAY,iBAAiB,2CAA2C;CAEpF,OAAO,OAAO,SAAS,KAAK,EAAE;AAChC;;AAGA,SAAgB,SAAS,KAAqB;CAC5C,OAAO,IAAI,SAAS,EAAE,CAAC,CAAC,SAAS,GAAG,GAAG;AACzC"}
@@ -1,4 +1,4 @@
1
- import { A as utf8Encode, D as hexToBytes, T as concatBytes, Z as EraSdkError, k as utf8Decode } from "./shared-B8Wc7ViU.js";
1
+ import { A as utf8Encode, D as hexToBytes, K as EraSdkError, T as concatBytes, k as utf8Decode } from "./shared-Bbgejrus.js";
2
2
  //#region src/tron-proto/wire.ts
3
3
  /**
4
4
  * Minimal protobuf wire codec for the Tron signing envelope. Varint and
@@ -151,6 +151,42 @@ function encodeSignRequestProto(req) {
151
151
  const payload = new ProtoWriter().varintField(1, PAYLOAD_TYPE_SIGN_TX).stringField(2, req.xfpHex).messageField(4, signTx).finish();
152
152
  return new ProtoWriter().varintField(1, 2).stringField(2, "QrCode Protocol").messageField(3, payload).finish();
153
153
  }
154
+ /**
155
+ * The BCH leg of the same envelope: `Base -> Payload -> SignTransaction ->
156
+ * BchTx` at oneof tag 10, with FLAT inputs (value/publicKey are direct
157
+ * fields, no nested Utxo sub-message). Unlike the Tron writer, default
158
+ * values are OMITTED here — proto3 emission, which is what the reference
159
+ * wallet capture the firmware fixture pins does. `hdPath` (SignTransaction
160
+ * field 3) is deliberately absent: the reference never sends it and the
161
+ * device reads the per-input `ownerKeyPath` instead.
162
+ */
163
+ function encodeBchSignRequestProto(req) {
164
+ const bchTx = new ProtoWriter();
165
+ if (req.fee !== 0n) bchTx.varintField(1, req.fee);
166
+ if (req.dustThreshold !== 0) bchTx.varintField(2, req.dustThreshold);
167
+ if (req.memo !== void 0 && req.memo !== "") bchTx.stringField(3, req.memo);
168
+ for (const input of req.inputs) {
169
+ const w = new ProtoWriter().stringField(1, input.txidHex);
170
+ if (input.index !== 0) w.varintField(2, input.index);
171
+ if (input.value !== 0n) w.varintField(3, input.value);
172
+ w.stringField(4, input.publicKeyHex);
173
+ w.stringField(5, input.ownerKeyPath);
174
+ bchTx.messageField(4, w.finish());
175
+ }
176
+ for (const output of req.outputs) {
177
+ const w = new ProtoWriter().stringField(1, output.address);
178
+ if (output.value !== 0n) w.varintField(2, output.value);
179
+ if (output.isChange) w.varintField(3, 1);
180
+ if (output.changeAddressPath !== void 0 && output.changeAddressPath !== "") w.stringField(4, output.changeAddressPath);
181
+ bchTx.messageField(5, w.finish());
182
+ }
183
+ const signTx = new ProtoWriter().stringField(1, "BCH").stringField(2, req.signId);
184
+ if (req.timestamp !== 0) signTx.varintField(4, req.timestamp);
185
+ signTx.varintField(5, 8);
186
+ signTx.messageField(10, bchTx.finish());
187
+ const payload = new ProtoWriter().varintField(1, PAYLOAD_TYPE_SIGN_TX).stringField(2, req.xfpHex).messageField(4, signTx.finish()).finish();
188
+ return new ProtoWriter().varintField(1, 2).stringField(2, "QrCode Protocol").messageField(3, payload).finish();
189
+ }
154
190
  /** Parse a `keystone-sign-result` Base protobuf. Unknown fields are skipped. */
155
191
  function decodeSignResultProto(bytes) {
156
192
  const payloadBytes = firstBytes(readFields(bytes), 3);
@@ -203,6 +239,6 @@ function splitSignedTronTx(rawTxHex) {
203
239
  };
204
240
  }
205
241
  //#endregion
206
- export { firstVarint as a, firstBytes as i, encodeSignRequestProto as n, readFields as o, splitSignedTronTx as r, decodeSignResultProto as t };
242
+ export { firstBytes as a, splitSignedTronTx as i, encodeBchSignRequestProto as n, firstVarint as o, encodeSignRequestProto as r, readFields as s, decodeSignResultProto as t };
207
243
 
208
- //# sourceMappingURL=messages-17Oup0-Z.js.map
244
+ //# sourceMappingURL=messages--XbVef_k.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messages--XbVef_k.js","names":[],"sources":["../src/tron-proto/wire.ts","../src/tron-proto/messages.ts"],"sourcesContent":["import { concatBytes, utf8Encode } from '../core/bytes';\nimport { EraSdkError } from '../core/errors';\n\n/**\n * Minimal protobuf wire codec for the Tron signing envelope. Varint and\n * length-delimited wire types only — the schema uses nothing else.\n *\n * Writer semantics mirror the reference implementation: EXPLICITLY SET fields\n * are written even when they hold default values (a `timestamp` of 0 is\n * `tag, 0x00` on the wire), and fields are emitted in ascending field-number\n * order. Byte-exactness against the golden fixtures depends on both.\n */\n\nexport class ProtoWriter {\n private readonly parts: Uint8Array[] = [];\n\n varintField(field: number, value: number | bigint): this {\n this.parts.push(tag(field, 0), varint(value));\n return this;\n }\n\n stringField(field: number, value: string): this {\n const bytes = utf8Encode(value);\n this.parts.push(tag(field, 2), varint(bytes.length), bytes);\n return this;\n }\n\n bytesField(field: number, value: Uint8Array): this {\n this.parts.push(tag(field, 2), varint(value.length), value);\n return this;\n }\n\n messageField(field: number, encoded: Uint8Array): this {\n this.parts.push(tag(field, 2), varint(encoded.length), encoded);\n return this;\n }\n\n finish(): Uint8Array {\n return concatBytes(...this.parts);\n }\n}\n\nfunction tag(field: number, wireType: number): Uint8Array {\n return varint((field << 3) | wireType);\n}\n\nexport function varint(value: number | bigint): Uint8Array {\n let v = typeof value === 'number' ? BigInt(value) : value;\n if (v < 0n) throw new EraSdkError('protobuf-error', 'negative varint');\n const out: number[] = [];\n do {\n let byte = Number(v & 0x7fn);\n v >>= 7n;\n if (v > 0n) byte |= 0x80;\n out.push(byte);\n } while (v > 0n);\n return new Uint8Array(out);\n}\n\nexport interface ProtoField {\n readonly field: number;\n readonly wireType: number;\n /** Set for wire type 0. */\n readonly value: bigint;\n /** Set for wire type 2 (verbatim slice of the input). */\n readonly bytes: Uint8Array;\n}\n\n/**\n * Hardened field reader: varint shift capped, lengths bounds-checked before\n * slicing, unknown fields skippable by wire type, group wire types refused.\n */\nexport function readFields(bytes: Uint8Array): ProtoField[] {\n const fields: ProtoField[] = [];\n let offset = 0;\n\n const readVarint = (): bigint => {\n let result = 0n;\n let shift = 0n;\n for (;;) {\n const byte = bytes[offset];\n if (byte === undefined) throw new EraSdkError('protobuf-error', 'truncated varint');\n offset += 1;\n result |= BigInt(byte & 0x7f) << shift;\n if ((byte & 0x80) === 0) return result;\n shift += 7n;\n if (shift > 63n) throw new EraSdkError('protobuf-error', 'varint exceeds 64 bits');\n }\n };\n\n while (offset < bytes.length) {\n const key = readVarint();\n const field = Number(key >> 3n);\n const wireType = Number(key & 7n);\n if (field === 0) throw new EraSdkError('protobuf-error', 'field number 0');\n switch (wireType) {\n case 0: {\n fields.push({ field, wireType, value: readVarint(), bytes: EMPTY });\n break;\n }\n case 1: {\n if (offset + 8 > bytes.length) throw new EraSdkError('protobuf-error', 'truncated fixed64');\n fields.push({ field, wireType, value: 0n, bytes: bytes.slice(offset, offset + 8) });\n offset += 8;\n break;\n }\n case 2: {\n const length = readVarint();\n if (length > BigInt(bytes.length - offset)) {\n throw new EraSdkError('protobuf-error', 'length-delimited field exceeds input');\n }\n const len = Number(length);\n fields.push({ field, wireType, value: 0n, bytes: bytes.slice(offset, offset + len) });\n offset += len;\n break;\n }\n case 5: {\n if (offset + 4 > bytes.length) throw new EraSdkError('protobuf-error', 'truncated fixed32');\n fields.push({ field, wireType, value: 0n, bytes: bytes.slice(offset, offset + 4) });\n offset += 4;\n break;\n }\n default:\n throw new EraSdkError('protobuf-error', `unsupported wire type ${wireType}`);\n }\n }\n return fields;\n}\n\nconst EMPTY = new Uint8Array(0);\n\n/** First occurrence of a length-delimited field, or null. */\nexport function firstBytes(fields: ProtoField[], field: number): Uint8Array | null {\n for (const f of fields) {\n if (f.field === field && f.wireType === 2) return f.bytes;\n }\n return null;\n}\n\n/** First occurrence of a varint field, or null. */\nexport function firstVarint(fields: ProtoField[], field: number): bigint | null {\n for (const f of fields) {\n if (f.field === field && f.wireType === 0) return f.value;\n }\n return null;\n}\n","import { hexToBytes, utf8Decode } from '../core/bytes';\nimport { EraSdkError } from '../core/errors';\nimport { firstBytes, ProtoWriter, readFields } from './wire';\n\n/**\n * The Tron signing envelope (\"QrCode Protocol\"):\n * `Base -> Payload -> SignTransaction -> TronTx`, gzip-compressed and wrapped\n * in a `keystone-sign-request` (6101) CBOR map. Schemas are vendored under\n * `proto/tron/`; this codec hand-writes the five messages the wallet side\n * speaks, with reference-exact field emission (explicitly-set defaults ARE\n * written; ascending field order).\n */\n\nexport interface TronLatestBlock {\n /** FULL 64-hex block id of a live now-block (the device slices ref_block_hash from it). */\n readonly hash: string;\n readonly number: number;\n readonly timestamp: number;\n}\n\nexport interface TronSignRequestProto {\n /** Lowercase, ZERO-PADDED 8-hex source fingerprint (the wire demands the string form). */\n readonly xfpHex: string;\n /** Hyphenated UUID string; echoed by the device as the only reply binding. */\n readonly signId: string;\n readonly hdPath: string;\n readonly timestamp: number;\n readonly decimals: number;\n readonly token: string;\n readonly contractAddress?: string | undefined;\n readonly from?: string | undefined;\n readonly to?: string | undefined;\n readonly memo?: string | undefined;\n readonly value?: string | undefined;\n readonly fee?: number | undefined;\n readonly latestBlock: TronLatestBlock;\n /** Serialized `Transaction.raw_data` — the signing source of truth. */\n readonly rawData: Uint8Array;\n}\n\nconst PAYLOAD_TYPE_SIGN_TX = 2;\n\nexport function encodeSignRequestProto(req: TronSignRequestProto): Uint8Array {\n if (req.fee !== undefined && (req.fee < 0 || req.fee > 0x7fffffff)) {\n throw new EraSdkError('invalid-props', 'tron fee must fit a positive int32');\n }\n const latestBlock = new ProtoWriter()\n .stringField(1, req.latestBlock.hash)\n .varintField(2, req.latestBlock.number)\n .varintField(3, req.latestBlock.timestamp)\n .finish();\n\n const tronTx = new ProtoWriter().stringField(1, req.token);\n if (req.contractAddress !== undefined) tronTx.stringField(2, req.contractAddress);\n if (req.from !== undefined) tronTx.stringField(3, req.from);\n if (req.to !== undefined) tronTx.stringField(4, req.to);\n if (req.memo !== undefined) tronTx.stringField(5, req.memo);\n if (req.value !== undefined) tronTx.stringField(6, req.value);\n tronTx.messageField(7, latestBlock);\n if (req.fee !== undefined) tronTx.varintField(9, req.fee);\n tronTx.bytesField(10, req.rawData);\n\n const signTx = new ProtoWriter()\n .stringField(1, 'TRON')\n .stringField(2, req.signId)\n .stringField(3, req.hdPath)\n .varintField(4, req.timestamp)\n .varintField(5, req.decimals)\n .messageField(8, tronTx.finish())\n .finish();\n\n const payload = new ProtoWriter()\n .varintField(1, PAYLOAD_TYPE_SIGN_TX)\n .stringField(2, req.xfpHex)\n .messageField(4, signTx)\n .finish();\n\n return new ProtoWriter()\n .varintField(1, 2) // Base.version\n .stringField(2, 'QrCode Protocol')\n .messageField(3, payload)\n .finish();\n}\n\nexport interface BchProtoInput {\n /** Display-order (big-endian) txid, 64 hex chars — a STRING on the wire. */\n readonly txidHex: string;\n readonly index: number;\n /** UTXO value in satoshis. */\n readonly value: bigint;\n /** Compressed public key, 66 hex chars — a STRING on the wire. */\n readonly publicKeyHex: string;\n /** Full derivation path of the key that owns the UTXO. */\n readonly ownerKeyPath: string;\n}\n\nexport interface BchProtoOutput {\n /** CashAddr (verbatim; the device accepts both prefixed and bare form). */\n readonly address: string;\n readonly value: bigint;\n readonly isChange: boolean;\n readonly changeAddressPath?: string | undefined;\n}\n\nexport interface BchSignRequestProto {\n /** Lowercase, ZERO-PADDED 8-hex source fingerprint (the wire demands the string form). */\n readonly xfpHex: string;\n /** Hyphenated UUID string; echoed by the device as the only reply binding. */\n readonly signId: string;\n readonly timestamp: number;\n /** Fee in satoshis — shown on the device; MUST equal inputs minus outputs. */\n readonly fee: bigint;\n readonly dustThreshold: number;\n readonly memo?: string | undefined;\n readonly inputs: readonly BchProtoInput[];\n readonly outputs: readonly BchProtoOutput[];\n}\n\n/**\n * The BCH leg of the same envelope: `Base -> Payload -> SignTransaction ->\n * BchTx` at oneof tag 10, with FLAT inputs (value/publicKey are direct\n * fields, no nested Utxo sub-message). Unlike the Tron writer, default\n * values are OMITTED here — proto3 emission, which is what the reference\n * wallet capture the firmware fixture pins does. `hdPath` (SignTransaction\n * field 3) is deliberately absent: the reference never sends it and the\n * device reads the per-input `ownerKeyPath` instead.\n */\nexport function encodeBchSignRequestProto(req: BchSignRequestProto): Uint8Array {\n const bchTx = new ProtoWriter();\n if (req.fee !== 0n) bchTx.varintField(1, req.fee);\n if (req.dustThreshold !== 0) bchTx.varintField(2, req.dustThreshold);\n if (req.memo !== undefined && req.memo !== '') bchTx.stringField(3, req.memo);\n for (const input of req.inputs) {\n const w = new ProtoWriter().stringField(1, input.txidHex);\n if (input.index !== 0) w.varintField(2, input.index);\n if (input.value !== 0n) w.varintField(3, input.value);\n w.stringField(4, input.publicKeyHex);\n w.stringField(5, input.ownerKeyPath);\n bchTx.messageField(4, w.finish());\n }\n for (const output of req.outputs) {\n const w = new ProtoWriter().stringField(1, output.address);\n if (output.value !== 0n) w.varintField(2, output.value);\n if (output.isChange) w.varintField(3, 1);\n if (output.changeAddressPath !== undefined && output.changeAddressPath !== '') {\n w.stringField(4, output.changeAddressPath);\n }\n bchTx.messageField(5, w.finish());\n }\n\n const signTx = new ProtoWriter().stringField(1, 'BCH').stringField(2, req.signId);\n if (req.timestamp !== 0) signTx.varintField(4, req.timestamp);\n signTx.varintField(5, 8); // decimal: BCH is always 8\n signTx.messageField(10, bchTx.finish());\n\n const payload = new ProtoWriter()\n .varintField(1, PAYLOAD_TYPE_SIGN_TX)\n .stringField(2, req.xfpHex)\n .messageField(4, signTx.finish())\n .finish();\n\n return new ProtoWriter()\n .varintField(1, 2) // Base.version\n .stringField(2, 'QrCode Protocol')\n .messageField(3, payload)\n .finish();\n}\n\nexport interface TronSignResultProto {\n readonly signId: string;\n readonly txId: string;\n readonly rawTx: string;\n}\n\n/** Parse a `keystone-sign-result` Base protobuf. Unknown fields are skipped. */\nexport function decodeSignResultProto(bytes: Uint8Array): TronSignResultProto {\n const base = readFields(bytes);\n const payloadBytes = firstBytes(base, 3);\n if (!payloadBytes) {\n throw new EraSdkError('malformed-reply', 'keystone-sign-result carries no payload');\n }\n const payload = readFields(payloadBytes);\n const resultBytes = firstBytes(payload, 7); // Payload.signTxResult\n if (!resultBytes) {\n return { signId: '', txId: '', rawTx: '' };\n }\n const result = readFields(resultBytes);\n return {\n signId: text(firstBytes(result, 1)),\n txId: text(firstBytes(result, 2)),\n rawTx: text(firstBytes(result, 3)),\n };\n}\n\nfunction text(bytes: Uint8Array | null): string {\n if (!bytes) return '';\n try {\n return utf8Decode(bytes);\n } catch {\n throw new EraSdkError('malformed-reply', 'protobuf string field is not valid UTF-8');\n }\n}\n\nexport interface SignedTronTx {\n /** Verbatim `raw_data` slice — the digest is sha256 over the device's own serialization. */\n readonly rawData: Uint8Array;\n readonly signatures: readonly Uint8Array[];\n}\n\n/**\n * Split a signed Tron network `Transaction` frame (`{1: raw_data, 2: signature*}`)\n * from the reply's `rawTx` hex. Top-level fields must be length-delimited —\n * anything else is not a transaction frame.\n */\nexport function splitSignedTronTx(rawTxHex: string): SignedTronTx {\n let frame: Uint8Array;\n try {\n frame = hexToBytes(rawTxHex);\n } catch {\n throw new EraSdkError('malformed-reply', 'signed Tron transaction is not hex');\n }\n const fields = readFields(frame);\n let rawData: Uint8Array | null = null;\n const signatures: Uint8Array[] = [];\n for (const f of fields) {\n if (f.wireType !== 2) {\n throw new EraSdkError('malformed-reply', 'unexpected wire type in signed Tron transaction');\n }\n if (f.field === 1 && rawData === null) rawData = f.bytes;\n if (f.field === 2) signatures.push(f.bytes);\n }\n if (rawData === null) {\n throw new EraSdkError('malformed-reply', 'signed Tron transaction carries no raw_data');\n }\n return { rawData, signatures };\n}\n"],"mappings":";;;;;;;;;;;AAaA,IAAa,cAAb,MAAyB;;EACvB,KAAiB,QAAsB,CAAC;;CAExC,YAAY,OAAe,OAA8B;EACvD,KAAK,MAAM,KAAK,IAAI,OAAO,CAAC,GAAG,OAAO,KAAK,CAAC;EAC5C,OAAO;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CAA0C;CACrF;AACF;;;;;;AAaA,SAAgB,kBAAkB,UAAgC;CAChE,IAAI;CACJ,IAAI;EACF,QAAQ,WAAW,QAAQ;CAC7B,QAAQ;EACN,MAAM,IAAI,YAAY,mBAAmB,oCAAoC;CAC/E;CACA,MAAM,SAAS,WAAW,KAAK;CAC/B,IAAI,UAA6B;CACjC,MAAM,aAA2B,CAAC;CAClC,KAAK,MAAM,KAAK,QAAQ;EACtB,IAAI,EAAE,aAAa,GACjB,MAAM,IAAI,YAAY,mBAAmB,iDAAiD;EAE5F,IAAI,EAAE,UAAU,KAAK,YAAY,MAAM,UAAU,EAAE;EACnD,IAAI,EAAE,UAAU,GAAG,WAAW,KAAK,EAAE,KAAK;CAC5C;CACA,IAAI,YAAY,MACd,MAAM,IAAI,YAAY,mBAAmB,6CAA6C;CAExF,OAAO;EAAE;EAAS;CAAW;AAC/B"}
@@ -1,4 +1,4 @@
1
- const require_shared = require("./shared-nISrEktU.cjs");
1
+ const require_shared = require("./shared-Cu2yynP9.cjs");
2
2
  //#region src/tron-proto/wire.ts
3
3
  /**
4
4
  * Minimal protobuf wire codec for the Tron signing envelope. Varint and
@@ -151,6 +151,42 @@ function encodeSignRequestProto(req) {
151
151
  const payload = new ProtoWriter().varintField(1, PAYLOAD_TYPE_SIGN_TX).stringField(2, req.xfpHex).messageField(4, signTx).finish();
152
152
  return new ProtoWriter().varintField(1, 2).stringField(2, "QrCode Protocol").messageField(3, payload).finish();
153
153
  }
154
+ /**
155
+ * The BCH leg of the same envelope: `Base -> Payload -> SignTransaction ->
156
+ * BchTx` at oneof tag 10, with FLAT inputs (value/publicKey are direct
157
+ * fields, no nested Utxo sub-message). Unlike the Tron writer, default
158
+ * values are OMITTED here — proto3 emission, which is what the reference
159
+ * wallet capture the firmware fixture pins does. `hdPath` (SignTransaction
160
+ * field 3) is deliberately absent: the reference never sends it and the
161
+ * device reads the per-input `ownerKeyPath` instead.
162
+ */
163
+ function encodeBchSignRequestProto(req) {
164
+ const bchTx = new ProtoWriter();
165
+ if (req.fee !== 0n) bchTx.varintField(1, req.fee);
166
+ if (req.dustThreshold !== 0) bchTx.varintField(2, req.dustThreshold);
167
+ if (req.memo !== void 0 && req.memo !== "") bchTx.stringField(3, req.memo);
168
+ for (const input of req.inputs) {
169
+ const w = new ProtoWriter().stringField(1, input.txidHex);
170
+ if (input.index !== 0) w.varintField(2, input.index);
171
+ if (input.value !== 0n) w.varintField(3, input.value);
172
+ w.stringField(4, input.publicKeyHex);
173
+ w.stringField(5, input.ownerKeyPath);
174
+ bchTx.messageField(4, w.finish());
175
+ }
176
+ for (const output of req.outputs) {
177
+ const w = new ProtoWriter().stringField(1, output.address);
178
+ if (output.value !== 0n) w.varintField(2, output.value);
179
+ if (output.isChange) w.varintField(3, 1);
180
+ if (output.changeAddressPath !== void 0 && output.changeAddressPath !== "") w.stringField(4, output.changeAddressPath);
181
+ bchTx.messageField(5, w.finish());
182
+ }
183
+ const signTx = new ProtoWriter().stringField(1, "BCH").stringField(2, req.signId);
184
+ if (req.timestamp !== 0) signTx.varintField(4, req.timestamp);
185
+ signTx.varintField(5, 8);
186
+ signTx.messageField(10, bchTx.finish());
187
+ const payload = new ProtoWriter().varintField(1, PAYLOAD_TYPE_SIGN_TX).stringField(2, req.xfpHex).messageField(4, signTx.finish()).finish();
188
+ return new ProtoWriter().varintField(1, 2).stringField(2, "QrCode Protocol").messageField(3, payload).finish();
189
+ }
154
190
  /** Parse a `keystone-sign-result` Base protobuf. Unknown fields are skipped. */
155
191
  function decodeSignResultProto(bytes) {
156
192
  const payloadBytes = firstBytes(readFields(bytes), 3);
@@ -209,6 +245,12 @@ Object.defineProperty(exports, "decodeSignResultProto", {
209
245
  return decodeSignResultProto;
210
246
  }
211
247
  });
248
+ Object.defineProperty(exports, "encodeBchSignRequestProto", {
249
+ enumerable: true,
250
+ get: function() {
251
+ return encodeBchSignRequestProto;
252
+ }
253
+ });
212
254
  Object.defineProperty(exports, "encodeSignRequestProto", {
213
255
  enumerable: true,
214
256
  get: function() {
@@ -240,4 +282,4 @@ Object.defineProperty(exports, "splitSignedTronTx", {
240
282
  }
241
283
  });
242
284
 
243
- //# sourceMappingURL=messages-BzcdWlg1.cjs.map
285
+ //# sourceMappingURL=messages-orAQ52CI.cjs.map