@hwlt/era-connect 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/cosmos/package.json +6 -0
- package/dist/{btc-DfQ0q79G.d.ts → btc-B8LfSEkv.d.ts} +11 -2
- package/dist/{btc-VyJKXq7d.js → btc-B_Nq2H4T.js} +16 -7
- package/dist/btc-B_Nq2H4T.js.map +1 -0
- package/dist/{btc-Fr6Jz4Fi.cjs → btc-ByzjzUKs.cjs} +19 -10
- package/dist/btc-ByzjzUKs.cjs.map +1 -0
- package/dist/{btc-Dn6_Y12c.d.cts → btc-C4dVkxHb.d.cts} +11 -2
- package/dist/btc.cjs +2 -2
- package/dist/btc.d.cts +1 -1
- package/dist/btc.d.ts +1 -1
- package/dist/btc.js +2 -2
- package/dist/{cardano-yuOygqwp.js → cardano-BCT55gwf.js} +3 -2
- package/dist/{cardano-yuOygqwp.js.map → cardano-BCT55gwf.js.map} +1 -1
- package/dist/{cardano-DP6U_K1J.cjs → cardano-CzYswGzK.cjs} +5 -4
- package/dist/{cardano-DP6U_K1J.cjs.map → cardano-CzYswGzK.cjs.map} +1 -1
- package/dist/cardano.cjs +2 -2
- package/dist/cardano.js +2 -2
- package/dist/cosmos-BYrhIqRk.d.cts +77 -0
- package/dist/cosmos-DDsgtUki.cjs +113 -0
- package/dist/cosmos-DDsgtUki.cjs.map +1 -0
- package/dist/cosmos-DqyjA6lg.d.ts +77 -0
- package/dist/cosmos-jUHNxgWC.js +102 -0
- package/dist/cosmos-jUHNxgWC.js.map +1 -0
- package/dist/cosmos.cjs +10 -0
- package/dist/cosmos.d.cts +3 -0
- package/dist/cosmos.d.ts +3 -0
- package/dist/cosmos.js +3 -0
- package/dist/{derive-CuILJRPT.cjs → derive-BayrpfJk.cjs} +14 -2
- package/dist/derive-BayrpfJk.cjs.map +1 -0
- package/dist/{derive-C4JdycUh.js → derive-CK9Nc9Jc.js} +9 -3
- package/dist/derive-CK9Nc9Jc.js.map +1 -0
- package/dist/{evm-kJb3-oiR.js → evm-CI1cuZsp.js} +3 -2
- package/dist/{evm-kJb3-oiR.js.map → evm-CI1cuZsp.js.map} +1 -1
- package/dist/{evm-BHj_2OTG.cjs → evm-yfKOc2dy.cjs} +6 -5
- package/dist/{evm-BHj_2OTG.cjs.map → evm-yfKOc2dy.cjs.map} +1 -1
- package/dist/evm.cjs +2 -2
- package/dist/evm.js +2 -2
- package/dist/index.cjs +79 -31
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +25 -3
- package/dist/index.d.ts +25 -3
- package/dist/index.js +51 -9
- package/dist/index.js.map +1 -1
- package/dist/keypath-Bvv_cfHt.js +75 -0
- package/dist/keypath-Bvv_cfHt.js.map +1 -0
- package/dist/keypath-pzm_YIfN.cjs +116 -0
- package/dist/keypath-pzm_YIfN.cjs.map +1 -0
- package/dist/{messages-BzcdWlg1.cjs → messages-BZXDY29v.cjs} +2 -2
- package/dist/{messages-BzcdWlg1.cjs.map → messages-BZXDY29v.cjs.map} +1 -1
- package/dist/{messages-17Oup0-Z.js → messages-DbnXy3dC.js} +2 -2
- package/dist/{messages-17Oup0-Z.js.map → messages-DbnXy3dC.js.map} +1 -1
- package/dist/{shared-B8Wc7ViU.js → shared-Bbgejrus.js} +2 -73
- package/dist/shared-Bbgejrus.js.map +1 -0
- package/dist/{shared-nISrEktU.cjs → shared-Cu2yynP9.cjs} +13 -114
- package/dist/shared-Cu2yynP9.cjs.map +1 -0
- package/dist/{solana-DdEn24X4.cjs → solana-BoQBy0hu.cjs} +6 -5
- package/dist/{solana-DdEn24X4.cjs.map → solana-BoQBy0hu.cjs.map} +1 -1
- package/dist/{solana-C7JQEAec.js → solana-BukH3AI3.js} +3 -2
- package/dist/{solana-C7JQEAec.js.map → solana-BukH3AI3.js.map} +1 -1
- package/dist/solana.cjs +2 -2
- package/dist/solana.js +2 -2
- package/dist/sui-6WX6VPlW.d.cts +49 -0
- package/dist/sui-BtbPG6Xt.js +71 -0
- package/dist/sui-BtbPG6Xt.js.map +1 -0
- package/dist/sui-CYRn331O.cjs +82 -0
- package/dist/sui-CYRn331O.cjs.map +1 -0
- package/dist/sui-DI0ruW7E.d.ts +49 -0
- package/dist/sui.cjs +10 -0
- package/dist/sui.d.cts +3 -0
- package/dist/sui.d.ts +3 -0
- package/dist/sui.js +3 -0
- package/dist/{ton-5Uvi5ifg.js → ton-BSPKU5B9.js} +3 -2
- package/dist/{ton-5Uvi5ifg.js.map → ton-BSPKU5B9.js.map} +1 -1
- package/dist/{ton-DUJGXdGa.cjs → ton-CI2s9puH.cjs} +6 -5
- package/dist/{ton-DUJGXdGa.cjs.map → ton-CI2s9puH.cjs.map} +1 -1
- package/dist/ton.cjs +2 -2
- package/dist/ton.js +2 -2
- package/dist/{tron-CQIEqjCA.cjs → tron-B9wXdzlA.cjs} +7 -6
- package/dist/{tron-CQIEqjCA.cjs.map → tron-B9wXdzlA.cjs.map} +1 -1
- package/dist/{tron-Bo9HnvVE.js → tron-fufBDNuQ.js} +4 -3
- package/dist/{tron-Bo9HnvVE.js.map → tron-fufBDNuQ.js.map} +1 -1
- package/dist/tron.cjs +3 -3
- package/dist/tron.js +3 -3
- package/dist/verify.cjs +192 -9
- package/dist/verify.cjs.map +1 -1
- package/dist/verify.d.cts +54 -1
- package/dist/verify.d.ts +54 -1
- package/dist/verify.js +189 -9
- package/dist/verify.js.map +1 -1
- package/dist/xrp-BXAeK4iH.d.cts +32 -0
- package/dist/xrp-BrHXUnX5.cjs +52 -0
- package/dist/xrp-BrHXUnX5.cjs.map +1 -0
- package/dist/xrp-C8LJO5b-.js +47 -0
- package/dist/xrp-C8LJO5b-.js.map +1 -0
- package/dist/xrp-DqCXGYEk.d.ts +32 -0
- package/dist/xrp.cjs +9 -0
- package/dist/xrp.d.cts +3 -0
- package/dist/xrp.d.ts +3 -0
- package/dist/xrp.js +3 -0
- package/package.json +37 -1
- package/sui/package.json +6 -0
- package/xrp/package.json +6 -0
- package/dist/btc-Fr6Jz4Fi.cjs.map +0 -1
- package/dist/btc-VyJKXq7d.js.map +0 -1
- package/dist/derive-C4JdycUh.js.map +0 -1
- package/dist/derive-CuILJRPT.cjs.map +0 -1
- package/dist/shared-B8Wc7ViU.js.map +0 -1
- package/dist/shared-nISrEktU.cjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evm-BHj_2OTG.cjs","names":["resolveContext","resolveRequestId","parsePath","normalizeXfp","EraSdkError","cbBytes","cbUint","keypath304","cbText","UrValue","cborEncode","cbMap","makeSignRequest","normalizeRequestId","toUr","hexToBytes","requireReplyMap","requireRequestIdEcho","requireSignatureBytes","mapGet","bytesToBigint"],"sources":["../src/chains/evm.ts"],"sourcesContent":["import { cborEncode } from '../cbor/encode';\nimport type { CborValue } from '../cbor/model';\nimport { cbBytes, cbMap, cbText, cbUint, mapGet } from '../cbor/model';\nimport { bytesToBigint, hexToBytes } from '../core/bytes';\nimport { EraSdkError } from '../core/errors';\nimport { normalizeRequestId } from '../core/rand';\nimport { keypath304, normalizeXfp, parsePath } from '../registry/keypath';\nimport type { Ur } from '../ur/ur';\nimport { Ur as UrValue } from '../ur/ur';\nimport type { ChainContext, EraConnectConfig, ExpectedReply, SignRequest } from './shared';\nimport {\n makeSignRequest,\n requireReplyMap,\n requireRequestIdEcho,\n requireSignatureBytes,\n requireUrType,\n resolveContext,\n resolveRequestId,\n toUr,\n} from './shared';\n\n/** `eth-sign-request` dataType (CBOR key 3). */\nexport const EvmDataType = {\n /** RLP-encoded transaction (the device sniffs EIP-1559/2930/legacy from the leading byte). */\n transaction: 1,\n /** EIP-712 typed data JSON (UTF-8 bytes). */\n typedData: 2,\n /** personal_sign / raw message bytes (EIP-191 prefix applied by the device). */\n personalMessage: 3,\n /** Typed (EIP-2718) transaction bytes — treated identically to `transaction`. */\n typedTransaction: 4,\n} as const;\nexport type EvmDataType = (typeof EvmDataType)[keyof typeof EvmDataType];\n\nexport interface EvmSignRequestProps {\n /** 16 bytes or a UUID string; minted if omitted. */\n readonly requestId?: Uint8Array | string;\n /** RLP tx bytes, typed-data JSON UTF-8, or raw message bytes. */\n readonly signData: Uint8Array;\n readonly dataType: EvmDataType;\n /** Full signing path, e.g. `m/44'/60'/0'/0/0`. */\n readonly path: string;\n /** The account's source fingerprint from the linked wallet (`EraAccounts.xfpFor(...)`). */\n readonly xfp: string | number;\n /**\n * Required for transactions (it derives the legal reply width). The device\n * reads it as an unsigned 32-bit value — larger chain ids are refused here,\n * because a silently truncated id would sign for a different chain.\n */\n readonly chainId?: number;\n /** 20-byte signer address; recommended (enables verification helpers). */\n readonly address?: Uint8Array | `0x${string}`;\n /** Overrides the SDK-level origin label for this request. */\n readonly origin?: string;\n}\n\nexport interface EvmSignatureResult {\n readonly requestId: Uint8Array;\n /** Raw `r || s || v` exactly as the device sent it (may exceed 65 bytes for legacy EIP-155). */\n readonly signature: Uint8Array;\n readonly r: Uint8Array;\n readonly s: Uint8Array;\n /**\n * The recovery value AS SENT: parity (0/1) for typed transactions, 27/28\n * for messages, already-EIP-155-encoded (`parity + chainId*2 + 35`) for\n * legacy transactions. Do NOT re-apply the EIP-155 formula.\n */\n readonly v: bigint;\n /** `v` folded to a plain 0/1 recovery id, whichever of the three forms it arrived in. */\n readonly recoveryId: 0 | 1;\n}\n\n/** Over this size the device skips transaction decoding and falls back to blind signing. */\nconst BLIND_SIGN_THRESHOLD = 32 * 1024;\n\nconst REPLY_TYPES = ['eth-signature', 'evm-signature'] as const;\n\nexport class EvmChain {\n static readonly DataType = EvmDataType;\n\n private readonly context: ChainContext;\n\n constructor(config?: EraConnectConfig) {\n this.context = resolveContext(config);\n }\n\n /** Build an `eth-sign-request` (401). Reply: `eth-signature` (402). */\n generateSignRequest(props: EvmSignRequestProps): SignRequest<EvmSignatureResult> {\n const requestId = resolveRequestId(this.context, props.requestId);\n const path = parsePath(props.path);\n const xfp = normalizeXfp(props.xfp);\n const isTransaction =\n props.dataType === EvmDataType.transaction || props.dataType === EvmDataType.typedTransaction;\n\n if (isTransaction && props.chainId === undefined) {\n throw new EraSdkError('invalid-props', 'chainId is required for transaction sign requests');\n }\n if (props.chainId !== undefined) {\n if (!Number.isSafeInteger(props.chainId) || props.chainId < 0) {\n throw new EraSdkError('invalid-props', 'chainId must be a non-negative integer');\n }\n if (props.chainId > 0xffffffff) {\n throw new EraSdkError(\n 'invalid-props',\n `chainId ${props.chainId} exceeds the device's unsigned 32-bit range; ` +\n 'a truncated id would produce a signature for a different chain',\n { chainId: props.chainId },\n );\n }\n }\n\n const entries: [number, CborValue][] = [\n [1, cbBytes(requestId)],\n [2, cbBytes(props.signData)],\n [3, cbUint(props.dataType)],\n ];\n if (props.chainId !== undefined) entries.push([4, cbUint(props.chainId)]);\n entries.push([5, keypath304(path, xfp)]);\n if (props.address !== undefined) entries.push([6, cbBytes(normalizeAddress(props.address))]);\n entries.push([7, cbText(props.origin ?? this.context.origin)]);\n\n const ur = new UrValue('eth-sign-request', cborEncode(cbMap(entries)));\n const warnings: string[] = [];\n if (props.signData.length > BLIND_SIGN_THRESHOLD) warnings.push('blind-sign-threshold');\n\n const maxSigLength = 64 + maxVBytes(props.dataType, props.chainId);\n return makeSignRequest({\n ur,\n requestId,\n replyTypes: REPLY_TYPES,\n warnings,\n context: this.context,\n parse: (reply) => parseEvmSignature(reply, { requestId }, maxSigLength),\n });\n }\n\n /**\n * Parse an `eth-signature` standalone. Without `expect.requestId` the echo\n * is returned but not validated — prefer `SignRequest.scanner().parse()`.\n */\n parseSignature(input: Ur | string, expect?: ExpectedReply): EvmSignatureResult {\n const expected =\n expect?.requestId === undefined\n ? undefined\n : { requestId: normalizeRequestId(expect.requestId) };\n return parseEvmSignature(toUr(input), expected, 64 + 8);\n }\n}\n\nfunction normalizeAddress(address: Uint8Array | `0x${string}`): Uint8Array {\n const bytes = address instanceof Uint8Array ? address : hexToBytes(address);\n if (bytes.length !== 20) {\n throw new EraSdkError('invalid-props', 'EVM address must be 20 bytes');\n }\n return bytes;\n}\n\n/**\n * Width of the widest `v` the device can legitimately return.\n *\n * For a legacy EIP-155 transaction `v = parity + chainId*2 + 35` — 2 bytes\n * past chain id 110, 4 bytes for Aurora. Messages and typed data always\n * answer with one byte (27/28). A flat ceiling either refuses genuine replies\n * on large-id chains or accepts implausibly wide values; the exact bound\n * comes from the request.\n */\nfunction maxVBytes(dataType: EvmDataType, chainId: number | undefined): number {\n if (dataType !== EvmDataType.transaction && dataType !== EvmDataType.typedTransaction) return 1;\n if (chainId === undefined) return 8;\n let widest = BigInt(chainId) * 2n + 36n;\n if (widest < 28n) widest = 28n;\n let bytes = 0;\n while (widest > 0n) {\n bytes += 1;\n widest >>= 8n;\n }\n return bytes;\n}\n\nfunction parseEvmSignature(\n ur: Ur,\n expect: { requestId: Uint8Array } | undefined,\n maxSigLength: number,\n): EvmSignatureResult {\n requireUrType(ur, [...REPLY_TYPES], 'eth-signature');\n const map = requireReplyMap(ur, 'eth-signature');\n const requestId = requireRequestIdEcho(map, 1, expect?.requestId, 'eth-signature');\n const signature = requireSignatureBytes(mapGet(map, 2), 'eth-signature', 65, maxSigLength);\n\n const r = signature.slice(0, 32);\n const s = signature.slice(32, 64);\n const v = bytesToBigint(signature.slice(64));\n const recoveryId = foldRecoveryId(v);\n if (recoveryId !== 0 && recoveryId !== 1) {\n throw new EraSdkError(\n 'malformed-reply',\n `eth-signature carries an implausible recovery value ${v}`,\n );\n }\n return { requestId, signature, r, s, v, recoveryId };\n}\n\n/** Fold parity / 27-28 / EIP-155 forms of `v` to a 0/1 recovery id. */\nexport function foldRecoveryId(v: bigint): number {\n if (v >= 35n) return Number((v - 35n) & 1n);\n if (v >= 27n) return Number(v - 27n);\n return Number(v);\n}\n"],"mappings":";;;AAsBA,MAAa,cAAc;;CAEzB,aAAa;;CAEb,WAAW;;CAEX,iBAAiB;;CAEjB,kBAAkB;AACpB;;AA0CA,MAAM,uBAAuB;AAE7B,MAAM,cAAc,CAAC,iBAAiB,eAAe;AAErD,IAAa,WAAb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B,KAAK,GAAG,QAAQ,WAAW,eAAe;CACjF,MAAM,YAAYC,eAAAA,sBAAsBC,eAAAA,OAAO,KAAK,CAAC,GAAG,iBAAiB,IAAI,YAAY;CAEzF,MAAM,IAAI,UAAU,MAAM,GAAG,EAAE;CAC/B,MAAM,IAAI,UAAU,MAAM,IAAI,EAAE;CAChC,MAAM,IAAIC,eAAAA,cAAc,UAAU,MAAM,EAAE,CAAC;CAC3C,MAAM,aAAa,eAAe,CAAC;CACnC,IAAI,eAAe,KAAK,eAAe,GACrC,MAAM,IAAIhB,eAAAA,YACR,mBACA,uDAAuD,GACzD;CAEF,OAAO;EAAE;EAAW;EAAW;EAAG;EAAG;EAAG;CAAW;AACrD;;AAGA,SAAgB,eAAe,GAAmB;CAChD,IAAI,KAAK,KAAK,OAAO,OAAQ,IAAI,MAAO,EAAE;CAC1C,IAAI,KAAK,KAAK,OAAO,OAAO,IAAI,GAAG;CACnC,OAAO,OAAO,CAAC;AACjB"}
|
|
1
|
+
{"version":3,"file":"evm-yfKOc2dy.cjs","names":["resolveContext","resolveRequestId","parsePath","normalizeXfp","EraSdkError","cbBytes","cbUint","keypath304","cbText","UrValue","cborEncode","cbMap","makeSignRequest","normalizeRequestId","toUr","hexToBytes","requireReplyMap","requireRequestIdEcho","requireSignatureBytes","mapGet","bytesToBigint"],"sources":["../src/chains/evm.ts"],"sourcesContent":["import { cborEncode } from '../cbor/encode';\nimport type { CborValue } from '../cbor/model';\nimport { cbBytes, cbMap, cbText, cbUint, mapGet } from '../cbor/model';\nimport { bytesToBigint, hexToBytes } from '../core/bytes';\nimport { EraSdkError } from '../core/errors';\nimport { normalizeRequestId } from '../core/rand';\nimport { keypath304, normalizeXfp, parsePath } from '../registry/keypath';\nimport type { Ur } from '../ur/ur';\nimport { Ur as UrValue } from '../ur/ur';\nimport type { ChainContext, EraConnectConfig, ExpectedReply, SignRequest } from './shared';\nimport {\n makeSignRequest,\n requireReplyMap,\n requireRequestIdEcho,\n requireSignatureBytes,\n requireUrType,\n resolveContext,\n resolveRequestId,\n toUr,\n} from './shared';\n\n/** `eth-sign-request` dataType (CBOR key 3). */\nexport const EvmDataType = {\n /** RLP-encoded transaction (the device sniffs EIP-1559/2930/legacy from the leading byte). */\n transaction: 1,\n /** EIP-712 typed data JSON (UTF-8 bytes). */\n typedData: 2,\n /** personal_sign / raw message bytes (EIP-191 prefix applied by the device). */\n personalMessage: 3,\n /** Typed (EIP-2718) transaction bytes — treated identically to `transaction`. */\n typedTransaction: 4,\n} as const;\nexport type EvmDataType = (typeof EvmDataType)[keyof typeof EvmDataType];\n\nexport interface EvmSignRequestProps {\n /** 16 bytes or a UUID string; minted if omitted. */\n readonly requestId?: Uint8Array | string;\n /** RLP tx bytes, typed-data JSON UTF-8, or raw message bytes. */\n readonly signData: Uint8Array;\n readonly dataType: EvmDataType;\n /** Full signing path, e.g. `m/44'/60'/0'/0/0`. */\n readonly path: string;\n /** The account's source fingerprint from the linked wallet (`EraAccounts.xfpFor(...)`). */\n readonly xfp: string | number;\n /**\n * Required for transactions (it derives the legal reply width). The device\n * reads it as an unsigned 32-bit value — larger chain ids are refused here,\n * because a silently truncated id would sign for a different chain.\n */\n readonly chainId?: number;\n /** 20-byte signer address; recommended (enables verification helpers). */\n readonly address?: Uint8Array | `0x${string}`;\n /** Overrides the SDK-level origin label for this request. */\n readonly origin?: string;\n}\n\nexport interface EvmSignatureResult {\n readonly requestId: Uint8Array;\n /** Raw `r || s || v` exactly as the device sent it (may exceed 65 bytes for legacy EIP-155). */\n readonly signature: Uint8Array;\n readonly r: Uint8Array;\n readonly s: Uint8Array;\n /**\n * The recovery value AS SENT: parity (0/1) for typed transactions, 27/28\n * for messages, already-EIP-155-encoded (`parity + chainId*2 + 35`) for\n * legacy transactions. Do NOT re-apply the EIP-155 formula.\n */\n readonly v: bigint;\n /** `v` folded to a plain 0/1 recovery id, whichever of the three forms it arrived in. */\n readonly recoveryId: 0 | 1;\n}\n\n/** Over this size the device skips transaction decoding and falls back to blind signing. */\nconst BLIND_SIGN_THRESHOLD = 32 * 1024;\n\nconst REPLY_TYPES = ['eth-signature', 'evm-signature'] as const;\n\nexport class EvmChain {\n static readonly DataType = EvmDataType;\n\n private readonly context: ChainContext;\n\n constructor(config?: EraConnectConfig) {\n this.context = resolveContext(config);\n }\n\n /** Build an `eth-sign-request` (401). Reply: `eth-signature` (402). */\n generateSignRequest(props: EvmSignRequestProps): SignRequest<EvmSignatureResult> {\n const requestId = resolveRequestId(this.context, props.requestId);\n const path = parsePath(props.path);\n const xfp = normalizeXfp(props.xfp);\n const isTransaction =\n props.dataType === EvmDataType.transaction || props.dataType === EvmDataType.typedTransaction;\n\n if (isTransaction && props.chainId === undefined) {\n throw new EraSdkError('invalid-props', 'chainId is required for transaction sign requests');\n }\n if (props.chainId !== undefined) {\n if (!Number.isSafeInteger(props.chainId) || props.chainId < 0) {\n throw new EraSdkError('invalid-props', 'chainId must be a non-negative integer');\n }\n if (props.chainId > 0xffffffff) {\n throw new EraSdkError(\n 'invalid-props',\n `chainId ${props.chainId} exceeds the device's unsigned 32-bit range; ` +\n 'a truncated id would produce a signature for a different chain',\n { chainId: props.chainId },\n );\n }\n }\n\n const entries: [number, CborValue][] = [\n [1, cbBytes(requestId)],\n [2, cbBytes(props.signData)],\n [3, cbUint(props.dataType)],\n ];\n if (props.chainId !== undefined) entries.push([4, cbUint(props.chainId)]);\n entries.push([5, keypath304(path, xfp)]);\n if (props.address !== undefined) entries.push([6, cbBytes(normalizeAddress(props.address))]);\n entries.push([7, cbText(props.origin ?? this.context.origin)]);\n\n const ur = new UrValue('eth-sign-request', cborEncode(cbMap(entries)));\n const warnings: string[] = [];\n if (props.signData.length > BLIND_SIGN_THRESHOLD) warnings.push('blind-sign-threshold');\n\n const maxSigLength = 64 + maxVBytes(props.dataType, props.chainId);\n return makeSignRequest({\n ur,\n requestId,\n replyTypes: REPLY_TYPES,\n warnings,\n context: this.context,\n parse: (reply) => parseEvmSignature(reply, { requestId }, maxSigLength),\n });\n }\n\n /**\n * Parse an `eth-signature` standalone. Without `expect.requestId` the echo\n * is returned but not validated — prefer `SignRequest.scanner().parse()`.\n */\n parseSignature(input: Ur | string, expect?: ExpectedReply): EvmSignatureResult {\n const expected =\n expect?.requestId === undefined\n ? undefined\n : { requestId: normalizeRequestId(expect.requestId) };\n return parseEvmSignature(toUr(input), expected, 64 + 8);\n }\n}\n\nfunction normalizeAddress(address: Uint8Array | `0x${string}`): Uint8Array {\n const bytes = address instanceof Uint8Array ? address : hexToBytes(address);\n if (bytes.length !== 20) {\n throw new EraSdkError('invalid-props', 'EVM address must be 20 bytes');\n }\n return bytes;\n}\n\n/**\n * Width of the widest `v` the device can legitimately return.\n *\n * For a legacy EIP-155 transaction `v = parity + chainId*2 + 35` — 2 bytes\n * past chain id 110, 4 bytes for Aurora. Messages and typed data always\n * answer with one byte (27/28). A flat ceiling either refuses genuine replies\n * on large-id chains or accepts implausibly wide values; the exact bound\n * comes from the request.\n */\nfunction maxVBytes(dataType: EvmDataType, chainId: number | undefined): number {\n if (dataType !== EvmDataType.transaction && dataType !== EvmDataType.typedTransaction) return 1;\n if (chainId === undefined) return 8;\n let widest = BigInt(chainId) * 2n + 36n;\n if (widest < 28n) widest = 28n;\n let bytes = 0;\n while (widest > 0n) {\n bytes += 1;\n widest >>= 8n;\n }\n return bytes;\n}\n\nfunction parseEvmSignature(\n ur: Ur,\n expect: { requestId: Uint8Array } | undefined,\n maxSigLength: number,\n): EvmSignatureResult {\n requireUrType(ur, [...REPLY_TYPES], 'eth-signature');\n const map = requireReplyMap(ur, 'eth-signature');\n const requestId = requireRequestIdEcho(map, 1, expect?.requestId, 'eth-signature');\n const signature = requireSignatureBytes(mapGet(map, 2), 'eth-signature', 65, maxSigLength);\n\n const r = signature.slice(0, 32);\n const s = signature.slice(32, 64);\n const v = bytesToBigint(signature.slice(64));\n const recoveryId = foldRecoveryId(v);\n if (recoveryId !== 0 && recoveryId !== 1) {\n throw new EraSdkError(\n 'malformed-reply',\n `eth-signature carries an implausible recovery value ${v}`,\n );\n }\n return { requestId, signature, r, s, v, recoveryId };\n}\n\n/** Fold parity / 27-28 / EIP-155 forms of `v` to a 0/1 recovery id. */\nexport function foldRecoveryId(v: bigint): number {\n if (v >= 35n) return Number((v - 35n) & 1n);\n if (v >= 27n) return Number(v - 27n);\n return Number(v);\n}\n"],"mappings":";;;;AAsBA,MAAa,cAAc;;CAEzB,aAAa;;CAEb,WAAW;;CAEX,iBAAiB;;CAEjB,kBAAkB;AACpB;;AA0CA,MAAM,uBAAuB;AAE7B,MAAM,cAAc,CAAC,iBAAiB,eAAe;AAErD,IAAa,WAAb,MAAsB;CAKpB,YAAY,QAA2B;EACrC,KAAK,UAAUA,eAAAA,eAAe,MAAM;CACtC;;CAGA,oBAAoB,OAA6D;EAC/E,MAAM,YAAYC,eAAAA,iBAAiB,KAAK,SAAS,MAAM,SAAS;EAChE,MAAM,OAAOC,gBAAAA,UAAU,MAAM,IAAI;EACjC,MAAM,MAAMC,gBAAAA,aAAa,MAAM,GAAG;EAIlC,KAFE,MAAM,aAAa,YAAY,eAAe,MAAM,aAAa,YAAY,qBAE1D,MAAM,YAAY,KAAA,GACrC,MAAM,IAAIC,eAAAA,YAAY,iBAAiB,mDAAmD;EAE5F,IAAI,MAAM,YAAY,KAAA,GAAW;GAC/B,IAAI,CAAC,OAAO,cAAc,MAAM,OAAO,KAAK,MAAM,UAAU,GAC1D,MAAM,IAAIA,eAAAA,YAAY,iBAAiB,wCAAwC;GAEjF,IAAI,MAAM,UAAU,YAClB,MAAM,IAAIA,eAAAA,YACR,iBACA,WAAW,MAAM,QAAQ,8GAEzB,EAAE,SAAS,MAAM,QAAQ,CAC3B;EAEJ;EAEA,MAAM,UAAiC;GACrC,CAAC,GAAGC,eAAAA,QAAQ,SAAS,CAAC;GACtB,CAAC,GAAGA,eAAAA,QAAQ,MAAM,QAAQ,CAAC;GAC3B,CAAC,GAAGC,eAAAA,OAAO,MAAM,QAAQ,CAAC;EAC5B;EACA,IAAI,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a,YAAY,kBAAkB,OAAO;CAC9F,IAAI,YAAY,KAAA,GAAW,OAAO;CAClC,IAAI,SAAS,OAAO,OAAO,IAAI,KAAK;CACpC,IAAI,SAAS,KAAK,SAAS;CAC3B,IAAI,QAAQ;CACZ,OAAO,SAAS,IAAI;EAClB,SAAS;EACT,WAAW;CACb;CACA,OAAO;AACT;AAEA,SAAS,kBACP,IACA,QACA,cACoB;CACpB,eAAA,cAAc,IAAI,CAAC,GAAG,WAAW,GAAG,eAAe;CACnD,MAAM,MAAMY,eAAAA,gBAAgB,IAAI,eAAe;CAC/C,MAAM,YAAYC,eAAAA,qBAAqB,KAAK,GAAG,QAAQ,WAAW,eAAe;CACjF,MAAM,YAAYC,eAAAA,sBAAsBC,eAAAA,OAAO,KAAK,CAAC,GAAG,iBAAiB,IAAI,YAAY;CAEzF,MAAM,IAAI,UAAU,MAAM,GAAG,EAAE;CAC/B,MAAM,IAAI,UAAU,MAAM,IAAI,EAAE;CAChC,MAAM,IAAIC,eAAAA,cAAc,UAAU,MAAM,EAAE,CAAC;CAC3C,MAAM,aAAa,eAAe,CAAC;CACnC,IAAI,eAAe,KAAK,eAAe,GACrC,MAAM,IAAIhB,eAAAA,YACR,mBACA,uDAAuD,GACzD;CAEF,OAAO;EAAE;EAAW;EAAW;EAAG;EAAG;EAAG;CAAW;AACrD;;AAGA,SAAgB,eAAe,GAAmB;CAChD,IAAI,KAAK,KAAK,OAAO,OAAQ,IAAI,MAAO,EAAE;CAC1C,IAAI,KAAK,KAAK,OAAO,OAAO,IAAI,GAAG;CACnC,OAAO,OAAO,CAAC;AACjB"}
|
package/dist/evm.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_shared = require("./shared-
|
|
3
|
-
const require_evm = require("./evm-
|
|
2
|
+
const require_shared = require("./shared-Cu2yynP9.cjs");
|
|
3
|
+
const require_evm = require("./evm-yfKOc2dy.cjs");
|
|
4
4
|
exports.AnimatedUr = require_shared.AnimatedUr;
|
|
5
5
|
exports.EraSdkError = require_shared.EraSdkError;
|
|
6
6
|
exports.EvmChain = require_evm.EvmChain;
|
package/dist/evm.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as EvmDataType, r as foldRecoveryId, t as EvmChain } from "./evm-
|
|
1
|
+
import { K as EraSdkError, _ as Ur, d as UrScanner, f as AnimatedUr, u as TypedUrScanner } from "./shared-Bbgejrus.js";
|
|
2
|
+
import { n as EvmDataType, r as foldRecoveryId, t as EvmChain } from "./evm-CI1cuZsp.js";
|
|
3
3
|
export { AnimatedUr, EraSdkError, EvmChain, EvmDataType, TypedUrScanner, Ur, UrScanner, foldRecoveryId };
|
package/dist/index.cjs
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_shared = require("./shared-
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
2
|
+
const require_shared = require("./shared-Cu2yynP9.cjs");
|
|
3
|
+
const require_keypath = require("./keypath-pzm_YIfN.cjs");
|
|
4
|
+
const require_derive = require("./derive-BayrpfJk.cjs");
|
|
5
|
+
const require_btc = require("./btc-ByzjzUKs.cjs");
|
|
6
|
+
const require_cardano = require("./cardano-CzYswGzK.cjs");
|
|
7
|
+
const require_cosmos = require("./cosmos-DDsgtUki.cjs");
|
|
8
|
+
const require_evm = require("./evm-yfKOc2dy.cjs");
|
|
9
|
+
const require_solana = require("./solana-BoQBy0hu.cjs");
|
|
10
|
+
const require_sui = require("./sui-CYRn331O.cjs");
|
|
11
|
+
const require_ton = require("./ton-CI2s9puH.cjs");
|
|
12
|
+
const require_tron = require("./tron-B9wXdzlA.cjs");
|
|
13
|
+
const require_xrp = require("./xrp-BrHXUnX5.cjs");
|
|
10
14
|
//#region src/registry/multi-accounts.ts
|
|
11
15
|
/** UR types a device links a watch-only wallet with. */
|
|
12
16
|
const WALLET_UR_TYPES = /* @__PURE__ */ new Set([
|
|
@@ -79,7 +83,7 @@ function tryParseEntry(item) {
|
|
|
79
83
|
if (!map) return null;
|
|
80
84
|
const origin = require_shared.asMap(require_shared.mapGet(map, 6));
|
|
81
85
|
if (!origin) return null;
|
|
82
|
-
const path =
|
|
86
|
+
const path = require_keypath.parsePathComponents(require_shared.mapGet(origin, 1));
|
|
83
87
|
if (!path || path.length === 0) return null;
|
|
84
88
|
const xfpValue = require_shared.asUint(require_shared.mapGet(origin, 2));
|
|
85
89
|
const xfp = xfpValue !== void 0 && xfpValue <= 4294967295n ? Number(xfpValue) : null;
|
|
@@ -106,15 +110,17 @@ function classify(path) {
|
|
|
106
110
|
if (p0.index === 44 && p1.index === 195) return "tron";
|
|
107
111
|
if (p0.index === 44 && p1.index === 607) return "ton";
|
|
108
112
|
if (p0.index === 1852 && p1.index === 1815) return "cardano";
|
|
113
|
+
if (p0.index === 44 && p1.index === 784) return "sui";
|
|
114
|
+
if (p0.index === 44 && p1.index === 118) return "cosmos";
|
|
109
115
|
return "unknown";
|
|
110
116
|
}
|
|
111
117
|
function withChainCode(entry) {
|
|
112
|
-
if (!entry.chainCode) throw new require_shared.EraSdkError("account-not-found", `account ${
|
|
118
|
+
if (!entry.chainCode) throw new require_shared.EraSdkError("account-not-found", `account ${require_keypath.formatPath([...entry.path])} carries no chain code; cannot derive children`);
|
|
113
119
|
return entry.chainCode;
|
|
114
120
|
}
|
|
115
121
|
/** The entry's key at the required length, or a typed refusal (derivation only). */
|
|
116
122
|
function requireKey(entry, length) {
|
|
117
|
-
if (!entry.publicKey || entry.publicKey.length !== length) throw new require_shared.EraSdkError("invalid-props", `account ${
|
|
123
|
+
if (!entry.publicKey || entry.publicKey.length !== length) throw new require_shared.EraSdkError("invalid-props", `account ${require_keypath.formatPath([...entry.path])} carries no ${length}-byte public key; xfp lookup still works, address derivation does not`);
|
|
118
124
|
return entry.publicKey;
|
|
119
125
|
}
|
|
120
126
|
/** EVM view over the linked wallet: one account xpub, addresses derived at `0/index`. */
|
|
@@ -124,10 +130,10 @@ var EvmAccountView = class {
|
|
|
124
130
|
this.resolvedXfp = resolvedXfp;
|
|
125
131
|
}
|
|
126
132
|
get xfp() {
|
|
127
|
-
return
|
|
133
|
+
return require_keypath.xfpToHex(this.resolvedXfp);
|
|
128
134
|
}
|
|
129
135
|
get accountPath() {
|
|
130
|
-
return
|
|
136
|
+
return require_keypath.formatPath([...this.entry.path]);
|
|
131
137
|
}
|
|
132
138
|
/** Signing path for address `index`: `<account>/0/<index>`. */
|
|
133
139
|
pathFor(index) {
|
|
@@ -154,10 +160,10 @@ var BtcAccountView = class {
|
|
|
154
160
|
this.resolvedXfp = resolvedXfp;
|
|
155
161
|
}
|
|
156
162
|
get xfp() {
|
|
157
|
-
return
|
|
163
|
+
return require_keypath.xfpToHex(this.resolvedXfp);
|
|
158
164
|
}
|
|
159
165
|
get accountPath() {
|
|
160
|
-
return
|
|
166
|
+
return require_keypath.formatPath([...this.entry.path]);
|
|
161
167
|
}
|
|
162
168
|
receivePath(index) {
|
|
163
169
|
return `${this.accountPath}/0/${index}`;
|
|
@@ -191,10 +197,10 @@ var TronAccountView = class {
|
|
|
191
197
|
this.resolvedXfp = resolvedXfp;
|
|
192
198
|
}
|
|
193
199
|
get xfp() {
|
|
194
|
-
return
|
|
200
|
+
return require_keypath.xfpToHex(this.resolvedXfp);
|
|
195
201
|
}
|
|
196
202
|
get accountPath() {
|
|
197
|
-
return
|
|
203
|
+
return require_keypath.formatPath([...this.entry.path]);
|
|
198
204
|
}
|
|
199
205
|
pathFor(index) {
|
|
200
206
|
return `${this.accountPath}/0/${index}`;
|
|
@@ -215,10 +221,10 @@ var TonAccountView = class {
|
|
|
215
221
|
this.resolvedXfp = resolvedXfp;
|
|
216
222
|
}
|
|
217
223
|
get xfp() {
|
|
218
|
-
return
|
|
224
|
+
return require_keypath.xfpToHex(this.resolvedXfp);
|
|
219
225
|
}
|
|
220
226
|
get accountPath() {
|
|
221
|
-
return
|
|
227
|
+
return require_keypath.formatPath([...this.entry.path]);
|
|
222
228
|
}
|
|
223
229
|
/** 32-byte Ed25519 public key — the signer for both wallet-contract versions. */
|
|
224
230
|
get publicKey() {
|
|
@@ -240,10 +246,10 @@ var CardanoAccountView = class {
|
|
|
240
246
|
this.resolvedXfp = resolvedXfp;
|
|
241
247
|
}
|
|
242
248
|
get xfp() {
|
|
243
|
-
return
|
|
249
|
+
return require_keypath.xfpToHex(this.resolvedXfp);
|
|
244
250
|
}
|
|
245
251
|
get accountPath() {
|
|
246
|
-
return
|
|
252
|
+
return require_keypath.formatPath([...this.entry.path]);
|
|
247
253
|
}
|
|
248
254
|
/** The account-level extended public key material. */
|
|
249
255
|
get publicKey() {
|
|
@@ -261,6 +267,26 @@ var CardanoAccountView = class {
|
|
|
261
267
|
return require_derive.cardanoSoftDerivePath(requireKey(this.entry, 32), withChainCode(this.entry), [role, index]);
|
|
262
268
|
}
|
|
263
269
|
};
|
|
270
|
+
/** Sui view: like Solana, each fully-hardened exported entry IS a signer. */
|
|
271
|
+
var SuiAccountView = class {
|
|
272
|
+
constructor(entry, resolvedXfp) {
|
|
273
|
+
this.entry = entry;
|
|
274
|
+
this.resolvedXfp = resolvedXfp;
|
|
275
|
+
}
|
|
276
|
+
get xfp() {
|
|
277
|
+
return require_keypath.xfpToHex(this.resolvedXfp);
|
|
278
|
+
}
|
|
279
|
+
get path() {
|
|
280
|
+
return require_keypath.formatPath([...this.entry.path]);
|
|
281
|
+
}
|
|
282
|
+
get publicKey() {
|
|
283
|
+
return requireKey(this.entry, 32);
|
|
284
|
+
}
|
|
285
|
+
/** `0x` Sui address: BLAKE2b-256 of `0x00 || publicKey`. */
|
|
286
|
+
get address() {
|
|
287
|
+
return require_derive.suiAddressFromPublicKey(requireKey(this.entry, 32));
|
|
288
|
+
}
|
|
289
|
+
};
|
|
264
290
|
/**
|
|
265
291
|
* Solana view: Ed25519 has no public child derivation, so the device
|
|
266
292
|
* pre-derives hardened accounts (`m/44'/501'/idx'`) and each entry IS a
|
|
@@ -272,10 +298,10 @@ var SolanaAccountView = class {
|
|
|
272
298
|
this.resolvedXfp = resolvedXfp;
|
|
273
299
|
}
|
|
274
300
|
get xfp() {
|
|
275
|
-
return
|
|
301
|
+
return require_keypath.xfpToHex(this.resolvedXfp);
|
|
276
302
|
}
|
|
277
303
|
get path() {
|
|
278
|
-
return
|
|
304
|
+
return require_keypath.formatPath([...this.entry.path]);
|
|
279
305
|
}
|
|
280
306
|
/** The hardened account index (third path level). */
|
|
281
307
|
get index() {
|
|
@@ -320,7 +346,7 @@ var EraAccounts = class EraAccounts {
|
|
|
320
346
|
}
|
|
321
347
|
/** Master fingerprint, lowercase 8-hex. */
|
|
322
348
|
get masterFingerprint() {
|
|
323
|
-
return
|
|
349
|
+
return require_keypath.xfpToHex(this.raw.masterFingerprint);
|
|
324
350
|
}
|
|
325
351
|
get device() {
|
|
326
352
|
return {
|
|
@@ -332,8 +358,8 @@ var EraAccounts = class EraAccounts {
|
|
|
332
358
|
get keys() {
|
|
333
359
|
return this.raw.entries.map((entry) => ({
|
|
334
360
|
chain: classify(entry.path),
|
|
335
|
-
path:
|
|
336
|
-
xfp:
|
|
361
|
+
path: require_keypath.formatPath([...entry.path]),
|
|
362
|
+
xfp: require_keypath.xfpToHex(entry.xfp ?? this.raw.masterFingerprint),
|
|
337
363
|
publicKey: entry.publicKey ?? void 0,
|
|
338
364
|
chainCode: entry.chainCode ?? void 0,
|
|
339
365
|
name: entry.name ?? void 0,
|
|
@@ -345,7 +371,7 @@ var EraAccounts = class EraAccounts {
|
|
|
345
371
|
* equals `accountPath`. Throws `account-not-found` — never a silent zero.
|
|
346
372
|
*/
|
|
347
373
|
xfpFor(accountPath) {
|
|
348
|
-
return
|
|
374
|
+
return require_keypath.xfpToHex(this.resolveXfp(this.entryFor(accountPath)));
|
|
349
375
|
}
|
|
350
376
|
/** Entry xfp, falling back to the wrapper's master fingerprint (Cardano-style path-only origins). */
|
|
351
377
|
resolveXfp(entry) {
|
|
@@ -375,6 +401,10 @@ var EraAccounts = class EraAccounts {
|
|
|
375
401
|
const entry = this.raw.entries.find((e) => classify(e.path) === "ton" && e.publicKey?.length === 32);
|
|
376
402
|
return entry ? new TonAccountView(entry, this.resolveXfp(entry)) : void 0;
|
|
377
403
|
}
|
|
404
|
+
/** All exported Sui signers (fully hardened SLIP-10 entries). */
|
|
405
|
+
sui() {
|
|
406
|
+
return this.raw.entries.filter((e) => classify(e.path) === "sui" && e.publicKey?.length === 32).map((e) => new SuiAccountView(e, this.resolveXfp(e)));
|
|
407
|
+
}
|
|
378
408
|
/** The Cardano account (CIP-1852 Icarus export), if the export carries one. */
|
|
379
409
|
cardano() {
|
|
380
410
|
const entry = this.raw.entries.find((e) => classify(e.path) === "cardano" && e.publicKey?.length === 32);
|
|
@@ -385,8 +415,8 @@ var EraAccounts = class EraAccounts {
|
|
|
385
415
|
return this.raw.entries.filter((e) => classify(e.path) === "solana" && e.publicKey?.length === 32).map((e) => new SolanaAccountView(e, this.resolveXfp(e)));
|
|
386
416
|
}
|
|
387
417
|
entryFor(accountPath) {
|
|
388
|
-
const levels =
|
|
389
|
-
const entry = this.raw.entries.find((e) =>
|
|
418
|
+
const levels = require_keypath.parsePath(accountPath);
|
|
419
|
+
const entry = this.raw.entries.find((e) => require_keypath.pathEquals(e.path, levels));
|
|
390
420
|
if (!entry) throw new require_shared.EraSdkError("account-not-found", `the linked wallet carries no account at ${accountPath}`, { path: accountPath });
|
|
391
421
|
return entry;
|
|
392
422
|
}
|
|
@@ -414,9 +444,9 @@ const ALGOS = {
|
|
|
414
444
|
function generateKeyDerivationCall(context, props) {
|
|
415
445
|
if (props.schemas.length === 0) throw new require_shared.EraSdkError("invalid-props", "at least one derivation schema is required");
|
|
416
446
|
const schemas = props.schemas.map((schema) => {
|
|
417
|
-
const levels =
|
|
447
|
+
const levels = require_keypath.parsePath(schema.path);
|
|
418
448
|
const entries = [
|
|
419
|
-
[1,
|
|
449
|
+
[1, require_keypath.keypath304(levels)],
|
|
420
450
|
[2, require_shared.cbUint(CURVES[schema.curve ?? "secp256k1"])],
|
|
421
451
|
[3, require_shared.cbUint(ALGOS[schema.algo ?? "slip10"])]
|
|
422
452
|
];
|
|
@@ -511,6 +541,18 @@ var EraConnect = class {
|
|
|
511
541
|
this._cardano ?? (this._cardano = new require_cardano.CardanoChain(this.context));
|
|
512
542
|
return this._cardano;
|
|
513
543
|
}
|
|
544
|
+
get sui() {
|
|
545
|
+
this._sui ?? (this._sui = new require_sui.SuiChain(this.context));
|
|
546
|
+
return this._sui;
|
|
547
|
+
}
|
|
548
|
+
get cosmos() {
|
|
549
|
+
this._cosmos ?? (this._cosmos = new require_cosmos.CosmosChain(this.context));
|
|
550
|
+
return this._cosmos;
|
|
551
|
+
}
|
|
552
|
+
get xrp() {
|
|
553
|
+
this._xrp ?? (this._xrp = new require_xrp.XrpChain(this.context));
|
|
554
|
+
return this._xrp;
|
|
555
|
+
}
|
|
514
556
|
/** Escape hatch for UR types without a dedicated module. */
|
|
515
557
|
get raw() {
|
|
516
558
|
this._raw ?? (this._raw = new RawModule(this.context));
|
|
@@ -542,6 +584,8 @@ exports.BtcAccountView = BtcAccountView;
|
|
|
542
584
|
exports.BtcChain = require_btc.BtcChain;
|
|
543
585
|
exports.CardanoAccountView = CardanoAccountView;
|
|
544
586
|
exports.CardanoChain = require_cardano.CardanoChain;
|
|
587
|
+
exports.CosmosChain = require_cosmos.CosmosChain;
|
|
588
|
+
exports.CosmosDataType = require_cosmos.CosmosDataType;
|
|
545
589
|
exports.DEFAULT_FRAGMENT_LENGTH = require_shared.DEFAULT_FRAGMENT_LENGTH;
|
|
546
590
|
exports.DEFAULT_ORIGIN = require_shared.DEFAULT_ORIGIN;
|
|
547
591
|
exports.DeviceProfile = DeviceProfile;
|
|
@@ -555,6 +599,8 @@ exports.RawModule = RawModule;
|
|
|
555
599
|
exports.SolSignType = require_solana.SolSignType;
|
|
556
600
|
exports.SolanaAccountView = SolanaAccountView;
|
|
557
601
|
exports.SolanaChain = require_solana.SolanaChain;
|
|
602
|
+
exports.SuiAccountView = SuiAccountView;
|
|
603
|
+
exports.SuiChain = require_sui.SuiChain;
|
|
558
604
|
exports.TonAccountView = TonAccountView;
|
|
559
605
|
exports.TonChain = require_ton.TonChain;
|
|
560
606
|
exports.TonDataType = require_ton.TonDataType;
|
|
@@ -564,7 +610,9 @@ exports.TypedUrScanner = require_shared.TypedUrScanner;
|
|
|
564
610
|
exports.Ur = require_shared.Ur;
|
|
565
611
|
exports.UrLimits = require_shared.UrLimits;
|
|
566
612
|
exports.UrScanner = require_shared.UrScanner;
|
|
613
|
+
exports.XrpChain = require_xrp.XrpChain;
|
|
567
614
|
exports.parseWitnessSet = require_cardano.parseWitnessSet;
|
|
615
|
+
exports.suiIntentDigest = require_sui.suiIntentDigest;
|
|
568
616
|
exports.utf8Decode = require_shared.utf8Decode;
|
|
569
617
|
exports.utf8Encode = require_shared.utf8Encode;
|
|
570
618
|
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["parseUrString","EraSdkError","cborDecode","asMap","asUint","mapGet","asArray","asText","parsePathComponents","asBytes","EraSdkError","formatPath","xfpToHex","evmAddressFromPublicKey","derivePublicKey","btcP2wpkhAddressFromPublicKey","btcP2pkhAddressFromPublicKey","btcNestedSegwitAddressFromPublicKey","ZPUB_VERSION","tronAddressFromPublicKey","cardanoSoftDerivePath","solanaAddressFromPublicKey","serializeExtendedPublicKey","parsePath","pathEquals","EraSdkError","parsePath","keypath304","cbUint","cbText","cbTag","cbMap","cbArray","UrValue","cborEncode","AnimatedUr","TypedUrScanner","EraAccountsClass","UrValue","toUr","AnimatedUr","resolveContext","EvmChain","BtcChain","SolanaChain","TronChain","TonChain","CardanoChain","UrScanner"],"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,SAASA,eAAAA,cAAc,KAAK;EAClC,IAAI,OAAO,QAAQ,MACjB,MAAM,IAAIC,eAAAA,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,IAAIA,eAAAA,YACR,iBACA,IAAI,MAAM,4CAA4C,CAAC,GAAG,eAAe,CAAC,CAAC,KAA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ePathComponents","asBytes","EraSdkError","formatPath","xfpToHex","evmAddressFromPublicKey","derivePublicKey","btcP2wpkhAddressFromPublicKey","btcP2pkhAddressFromPublicKey","btcNestedSegwitAddressFromPublicKey","ZPUB_VERSION","tronAddressFromPublicKey","cardanoSoftDerivePath","suiAddressFromPublicKey","solanaAddressFromPublicKey","serializeExtendedPublicKey","parsePath","pathEquals","EraSdkError","parsePath","keypath304","cbUint","cbText","cbTag","cbMap","cbArray","UrValue","cborEncode","AnimatedUr","TypedUrScanner","EraAccountsClass","UrValue","toUr","AnimatedUr","resolveContext","EvmChain","BtcChain","SolanaChain","TronChain","TonChain","CardanoChain","SuiChain","CosmosChain","XrpChain","UrScanner"],"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 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 | '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 === 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/**\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 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 { 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 _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 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 BtcAccountView,\n CardanoAccountView,\n EraAccounts,\n EvmAccountView,\n SolanaAccountView,\n SuiAccountView,\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 { 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,IAA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