@hwlt/era-connect 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +9 -0
  3. package/README.md +101 -0
  4. package/btc/package.json +6 -0
  5. package/dist/btc-DfQ0q79G.d.ts +58 -0
  6. package/dist/btc-Dn6_Y12c.d.cts +58 -0
  7. package/dist/btc-Fr6Jz4Fi.cjs +104 -0
  8. package/dist/btc-Fr6Jz4Fi.cjs.map +1 -0
  9. package/dist/btc-VyJKXq7d.js +99 -0
  10. package/dist/btc-VyJKXq7d.js.map +1 -0
  11. package/dist/btc.cjs +9 -0
  12. package/dist/btc.d.cts +3 -0
  13. package/dist/btc.d.ts +3 -0
  14. package/dist/btc.js +3 -0
  15. package/dist/evm-BHj_2OTG.cjs +134 -0
  16. package/dist/evm-BHj_2OTG.cjs.map +1 -0
  17. package/dist/evm-DJxGGAbD.d.cts +76 -0
  18. package/dist/evm-KrV5wK08.d.ts +76 -0
  19. package/dist/evm-kJb3-oiR.js +117 -0
  20. package/dist/evm-kJb3-oiR.js.map +1 -0
  21. package/dist/evm.cjs +11 -0
  22. package/dist/evm.d.cts +3 -0
  23. package/dist/evm.d.ts +3 -0
  24. package/dist/evm.js +3 -0
  25. package/dist/index.cjs +530 -0
  26. package/dist/index.cjs.map +1 -0
  27. package/dist/index.d.cts +285 -0
  28. package/dist/index.d.ts +285 -0
  29. package/dist/index.js +506 -0
  30. package/dist/index.js.map +1 -0
  31. package/dist/messages-17Oup0-Z.js +208 -0
  32. package/dist/messages-17Oup0-Z.js.map +1 -0
  33. package/dist/messages-BzcdWlg1.cjs +243 -0
  34. package/dist/messages-BzcdWlg1.cjs.map +1 -0
  35. package/dist/messages-DsPvW8Oi.d.cts +29 -0
  36. package/dist/messages-DsPvW8Oi.d.ts +29 -0
  37. package/dist/shared-B8Wc7ViU.js +1472 -0
  38. package/dist/shared-B8Wc7ViU.js.map +1 -0
  39. package/dist/shared-CI8zhQiE.d.cts +218 -0
  40. package/dist/shared-CI8zhQiE.d.ts +218 -0
  41. package/dist/shared-nISrEktU.cjs +1777 -0
  42. package/dist/shared-nISrEktU.cjs.map +1 -0
  43. package/dist/solana-8eOwz0gM.d.cts +49 -0
  44. package/dist/solana-C2Xm7w8a.d.ts +49 -0
  45. package/dist/solana-C7JQEAec.js +87 -0
  46. package/dist/solana-C7JQEAec.js.map +1 -0
  47. package/dist/solana-DdEn24X4.cjs +98 -0
  48. package/dist/solana-DdEn24X4.cjs.map +1 -0
  49. package/dist/solana.cjs +10 -0
  50. package/dist/solana.d.cts +3 -0
  51. package/dist/solana.d.ts +3 -0
  52. package/dist/solana.js +3 -0
  53. package/dist/tron-Bo9HnvVE.js +158 -0
  54. package/dist/tron-Bo9HnvVE.js.map +1 -0
  55. package/dist/tron-CQIEqjCA.cjs +163 -0
  56. package/dist/tron-CQIEqjCA.cjs.map +1 -0
  57. package/dist/tron-YllfTmx6.d.ts +63 -0
  58. package/dist/tron-gG51KMnX.d.cts +63 -0
  59. package/dist/tron.cjs +11 -0
  60. package/dist/tron.d.cts +4 -0
  61. package/dist/tron.d.ts +4 -0
  62. package/dist/tron.js +4 -0
  63. package/dist/verify.cjs +445 -0
  64. package/dist/verify.cjs.map +1 -0
  65. package/dist/verify.d.cts +162 -0
  66. package/dist/verify.d.ts +162 -0
  67. package/dist/verify.js +438 -0
  68. package/dist/verify.js.map +1 -0
  69. package/evm/package.json +6 -0
  70. package/package.json +140 -0
  71. package/proto/tron/base.proto +16 -0
  72. package/proto/tron/message.proto +12 -0
  73. package/proto/tron/payload.proto +35 -0
  74. package/proto/tron/sign_transaction_result.proto +10 -0
  75. package/proto/tron/sync.proto +21 -0
  76. package/proto/tron/transaction.proto +17 -0
  77. package/proto/tron/tron_transaction.proto +31 -0
  78. package/proto/tron/verify_address.proto +10 -0
  79. package/solana/package.json +6 -0
  80. package/tron/package.json +6 -0
  81. package/verify/package.json +6 -0
@@ -0,0 +1,99 @@
1
+ import { G as cbMap, J as cbUint, K as cbTag, M as keypath304, N as normalizeXfp, P as parsePath, S as asciiDecode, U as cbArray, W as cbBytes, Y as mapGet, Z as EraSdkError, _ as Ur, b as cborDecode, c as resolveRequestId, h as normalizeRequestId, i as requireRequestIdEcho, l as toUr, n as makeSignRequest, o as requireUrType, q as cbText, r as requireReplyMap, s as resolveContext, x as cborEncode, z as asBytes } from "./shared-B8Wc7ViU.js";
2
+ import { base64 } from "@scure/base";
3
+ //#region src/chains/btc.ts
4
+ const PSBT_REPLY_TYPES = ["crypto-psbt"];
5
+ const MESSAGE_REPLY_TYPES = ["btc-signature"];
6
+ var BtcChain = class BtcChain {
7
+ constructor(config) {
8
+ this.context = resolveContext(config);
9
+ }
10
+ /**
11
+ * Build a `crypto-psbt` (310) request: the UR payload is a bare CBOR byte
12
+ * string of the raw PSBT — no map, no request id, no origin.
13
+ *
14
+ * BECAUSE the protocol carries no request id on this path, the reply is
15
+ * bound to the request only by its content: after parsing, compare the
16
+ * returned PSBT's unsigned transaction against the one you sent
17
+ * (`verifySignedPsbt` from `@hwlt/era-connect/verify`). Skipping that
18
+ * check re-opens replay of a stale signed PSBT.
19
+ */
20
+ generatePsbtSignRequest(props) {
21
+ if (props.psbt.length === 0) throw new EraSdkError("invalid-props", "psbt must not be empty");
22
+ const ur = new Ur("crypto-psbt", cborEncode(cbBytes(props.psbt)));
23
+ return makeSignRequest({
24
+ ur,
25
+ replyTypes: PSBT_REPLY_TYPES,
26
+ context: this.context,
27
+ parse: (reply) => this.parsePsbt(reply)
28
+ });
29
+ }
30
+ /** Parse a `crypto-psbt` reply: the signed (not finalized) PSBT bytes. */
31
+ parsePsbt(input) {
32
+ const ur = toUr(input);
33
+ requireUrType(ur, [...PSBT_REPLY_TYPES], "crypto-psbt");
34
+ let decoded;
35
+ try {
36
+ decoded = cborDecode(ur.cbor);
37
+ } catch (e) {
38
+ throw new EraSdkError("malformed-cbor", `crypto-psbt reply: ${e.message}`);
39
+ }
40
+ const bytes = asBytes(decoded);
41
+ if (!bytes) throw new EraSdkError("malformed-reply", "crypto-psbt reply is not a byte string");
42
+ if (bytes.length === 0) throw new EraSdkError("malformed-reply", "crypto-psbt reply is empty");
43
+ return { psbt: bytes };
44
+ }
45
+ /** Build a `btc-sign-request` (8101) for message signing. Reply: `btc-signature` (8102). */
46
+ generateMessageSignRequest(props) {
47
+ const requestId = resolveRequestId(this.context, props.requestId);
48
+ const path = parsePath(props.path);
49
+ const xfp = normalizeXfp(props.xfp);
50
+ const ur = new Ur("btc-sign-request", cborEncode(cbMap([
51
+ [1, cbTag(37, cbBytes(requestId))],
52
+ [2, cbBytes(props.message)],
53
+ [3, cbUint(BtcChain.DataType.message)],
54
+ [4, cbArray([keypath304(path, xfp)])],
55
+ [5, cbArray([cbText(props.address)])],
56
+ [6, cbText(props.origin ?? this.context.origin)]
57
+ ])));
58
+ return makeSignRequest({
59
+ ur,
60
+ requestId,
61
+ replyTypes: MESSAGE_REPLY_TYPES,
62
+ context: this.context,
63
+ parse: (reply) => parseMessageSignature(reply, requestId)
64
+ });
65
+ }
66
+ /** Parse a `btc-signature` standalone. Prefer `SignRequest.scanner().parse()`. */
67
+ parseMessageSignature(input, expect) {
68
+ return parseMessageSignature(toUr(input), expect?.requestId === void 0 ? void 0 : normalizeRequestId(expect.requestId));
69
+ }
70
+ };
71
+ BtcChain.DataType = { message: 1 };
72
+ function parseMessageSignature(ur, expectedRequestId) {
73
+ requireUrType(ur, [...MESSAGE_REPLY_TYPES], "btc-signature");
74
+ const map = requireReplyMap(ur, "btc-signature");
75
+ const requestId = requireRequestIdEcho(map, 1, expectedRequestId, "btc-signature");
76
+ const sigValue = asBytes(mapGet(map, 2));
77
+ if (sigValue === void 0) throw new EraSdkError("malformed-reply", "btc-signature is missing the signature (key 2)");
78
+ if (sigValue.length === 0) throw new EraSdkError("empty-signature", "the device returned an empty signature — Bitcoin message signing supports legacy P2PKH (1...) addresses only");
79
+ let signature;
80
+ try {
81
+ signature = base64.decode(asciiDecode(sigValue));
82
+ } catch {
83
+ signature = sigValue;
84
+ }
85
+ if (signature.length !== 65) {
86
+ if (sigValue.length === 65) signature = sigValue;
87
+ else throw new EraSdkError("malformed-reply", `btc-signature payload does not decode to a 65-byte BIP-137 signature (${sigValue.length} bytes on the wire)`);
88
+ }
89
+ return {
90
+ requestId,
91
+ signature,
92
+ signatureBase64: base64.encode(signature),
93
+ publicKey: asBytes(mapGet(map, 3))
94
+ };
95
+ }
96
+ //#endregion
97
+ export { BtcChain as t };
98
+
99
+ //# sourceMappingURL=btc-VyJKXq7d.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"btc-VyJKXq7d.js","names":["UrValue"],"sources":["../src/chains/btc.ts"],"sourcesContent":["import { base64 } from '@scure/base';\nimport { cborDecode } from '../cbor/decode';\nimport { cborEncode } from '../cbor/encode';\nimport type { CborValue } from '../cbor/model';\nimport { asBytes, cbArray, cbBytes, cbMap, cbTag, cbText, cbUint, mapGet } from '../cbor/model';\nimport { asciiDecode } 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 requireUrType,\n resolveContext,\n resolveRequestId,\n toUr,\n} from './shared';\n\nexport interface BtcPsbtSignRequestProps {\n /** Raw PSBT v0 bytes (BIP-174). The device's signer relies on the global UNSIGNED_TX. */\n readonly psbt: Uint8Array;\n}\n\nexport interface BtcPsbtResult {\n /** The signed, NOT finalized PSBT. Finalize + broadcast with your own stack. */\n readonly psbt: Uint8Array;\n}\n\nexport interface BtcMessageSignRequestProps {\n readonly requestId?: Uint8Array | string;\n readonly message: Uint8Array;\n /** Full signing path, e.g. `m/84'/0'/0'/0/0`. */\n readonly path: string;\n readonly xfp: string | number;\n /**\n * The signing address. The device's message signer supports LEGACY P2PKH\n * (`1...`) addresses only; a segwit address yields `empty-signature`.\n */\n readonly address: string;\n readonly origin?: string;\n}\n\nexport interface BtcMessageSignatureResult {\n readonly requestId: Uint8Array;\n /** Raw 65-byte BIP-137 signature (header + r + s). */\n readonly signature: Uint8Array;\n /** The base64 form dApps and verifiers expect. */\n readonly signatureBase64: string;\n readonly publicKey: Uint8Array | undefined;\n}\n\nconst PSBT_REPLY_TYPES = ['crypto-psbt'] as const;\nconst MESSAGE_REPLY_TYPES = ['btc-signature'] as const;\n\nexport class BtcChain {\n static readonly DataType = { message: 1 } as const;\n\n private readonly context: ChainContext;\n\n constructor(config?: EraConnectConfig) {\n this.context = resolveContext(config);\n }\n\n /**\n * Build a `crypto-psbt` (310) request: the UR payload is a bare CBOR byte\n * string of the raw PSBT — no map, no request id, no origin.\n *\n * BECAUSE the protocol carries no request id on this path, the reply is\n * bound to the request only by its content: after parsing, compare the\n * returned PSBT's unsigned transaction against the one you sent\n * (`verifySignedPsbt` from `@hwlt/era-connect/verify`). Skipping that\n * check re-opens replay of a stale signed PSBT.\n */\n generatePsbtSignRequest(props: BtcPsbtSignRequestProps): SignRequest<BtcPsbtResult> {\n if (props.psbt.length === 0) {\n throw new EraSdkError('invalid-props', 'psbt must not be empty');\n }\n const ur = new UrValue('crypto-psbt', cborEncode(cbBytes(props.psbt)));\n return makeSignRequest({\n ur,\n replyTypes: PSBT_REPLY_TYPES,\n context: this.context,\n parse: (reply) => this.parsePsbt(reply),\n });\n }\n\n /** Parse a `crypto-psbt` reply: the signed (not finalized) PSBT bytes. */\n parsePsbt(input: Ur | string): BtcPsbtResult {\n const ur = toUr(input);\n requireUrType(ur, [...PSBT_REPLY_TYPES], 'crypto-psbt');\n let decoded: CborValue;\n try {\n decoded = cborDecode(ur.cbor);\n } catch (e) {\n throw new EraSdkError('malformed-cbor', `crypto-psbt reply: ${(e as Error).message}`);\n }\n const bytes = asBytes(decoded);\n if (!bytes) {\n throw new EraSdkError('malformed-reply', 'crypto-psbt reply is not a byte string');\n }\n if (bytes.length === 0) {\n throw new EraSdkError('malformed-reply', 'crypto-psbt reply is empty');\n }\n return { psbt: bytes };\n }\n\n /** Build a `btc-sign-request` (8101) for message signing. Reply: `btc-signature` (8102). */\n generateMessageSignRequest(\n props: BtcMessageSignRequestProps,\n ): SignRequest<BtcMessageSignatureResult> {\n const requestId = resolveRequestId(this.context, props.requestId);\n const path = parsePath(props.path);\n const xfp = normalizeXfp(props.xfp);\n\n const ur = new UrValue(\n 'btc-sign-request',\n cborEncode(\n cbMap([\n // Tag-37-wrapped on this chain (per-chain firmware policy).\n [1, cbTag(37, cbBytes(requestId))],\n [2, cbBytes(props.message)],\n [3, cbUint(BtcChain.DataType.message)],\n [4, cbArray([keypath304(path, xfp)])],\n [5, cbArray([cbText(props.address)])],\n [6, cbText(props.origin ?? this.context.origin)],\n ]),\n ),\n );\n return makeSignRequest({\n ur,\n requestId,\n replyTypes: MESSAGE_REPLY_TYPES,\n context: this.context,\n parse: (reply) => parseMessageSignature(reply, requestId),\n });\n }\n\n /** Parse a `btc-signature` standalone. Prefer `SignRequest.scanner().parse()`. */\n parseMessageSignature(input: Ur | string, expect?: ExpectedReply): BtcMessageSignatureResult {\n return parseMessageSignature(\n toUr(input),\n expect?.requestId === undefined ? undefined : normalizeRequestId(expect.requestId),\n );\n }\n}\n\nfunction parseMessageSignature(\n ur: Ur,\n expectedRequestId: Uint8Array | undefined,\n): BtcMessageSignatureResult {\n requireUrType(ur, [...MESSAGE_REPLY_TYPES], 'btc-signature');\n const map = requireReplyMap(ur, 'btc-signature');\n const requestId = requireRequestIdEcho(map, 1, expectedRequestId, 'btc-signature');\n\n const sigValue = asBytes(mapGet(map, 2));\n if (sigValue === undefined) {\n throw new EraSdkError('malformed-reply', 'btc-signature is missing the signature (key 2)');\n }\n // The device answers a message request for an address its signer cannot\n // handle (any non-legacy script type) with an EMPTY signature.\n if (sigValue.length === 0) {\n throw new EraSdkError(\n 'empty-signature',\n 'the device returned an empty signature — Bitcoin message signing supports legacy P2PKH (1...) addresses only',\n );\n }\n\n // Device quirk: the reply bytes are the ASCII of a base64 string, not raw\n // signature bytes. Decode twice; tolerate a firmware that starts sending\n // raw 65-byte signatures directly.\n let signature: Uint8Array;\n try {\n signature = base64.decode(asciiDecode(sigValue));\n } catch {\n signature = sigValue;\n }\n if (signature.length !== 65) {\n if (sigValue.length === 65) {\n signature = sigValue;\n } else {\n throw new EraSdkError(\n 'malformed-reply',\n `btc-signature payload does not decode to a 65-byte BIP-137 signature (${sigValue.length} bytes on the wire)`,\n );\n }\n }\n return {\n requestId,\n signature,\n signatureBase64: base64.encode(signature),\n publicKey: asBytes(mapGet(map, 3)),\n };\n}\n"],"mappings":";;;AAuDA,MAAM,mBAAmB,CAAC,aAAa;AACvC,MAAM,sBAAsB,CAAC,eAAe;AAE5C,IAAa,WAAb,MAAa,SAAS;CAKpB,YAAY,QAA2B;EACrC,KAAK,UAAU,eAAe,MAAM;CACtC;;;;;;;;;;;CAYA,wBAAwB,OAA4D;EAClF,IAAI,MAAM,KAAK,WAAW,GACxB,MAAM,IAAI,YAAY,iBAAiB,wBAAwB;EAEjE,MAAM,KAAK,IAAIA,GAAQ,eAAe,WAAW,QAAQ,MAAM,IAAI,CAAC,CAAC;EACrE,OAAO,gBAAgB;GACrB;GACA,YAAY;GACZ,SAAS,KAAK;GACd,QAAQ,UAAU,KAAK,UAAU,KAAK;EACxC,CAAC;CACH;;CAGA,UAAU,OAAmC;EAC3C,MAAM,KAAK,KAAK,KAAK;EACrB,cAAc,IAAI,CAAC,GAAG,gBAAgB,GAAG,aAAa;EACtD,IAAI;EACJ,IAAI;GACF,UAAU,WAAW,GAAG,IAAI;EAC9B,SAAS,GAAG;GACV,MAAM,IAAI,YAAY,kBAAkB,sBAAuB,EAAY,SAAS;EACtF;EACA,MAAM,QAAQ,QAAQ,OAAO;EAC7B,IAAI,CAAC,OACH,MAA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KAAA,GACf,MAAM,IAAI,YAAY,mBAAmB,gDAAgD;CAI3F,IAAI,SAAS,WAAW,GACtB,MAAM,IAAI,YACR,mBACA,8GACF;CAMF,IAAI;CACJ,IAAI;EACF,YAAY,OAAO,OAAO,YAAY,QAAQ,CAAC;CACjD,QAAQ;EACN,YAAY;CACd;CACA,IAAI,UAAU,WAAW,IAAI;EAC3B,IAAI,SAAS,WAAW,IACtB,YAAY;OAEZ,MAAM,IAAI,YACR,mBACA,yEAAyE,SAAS,OAAO,oBAC3F;CAEJ;CACA,OAAO;EACL;EACA;EACA,iBAAiB,OAAO,OAAO,SAAS;EACxC,WAAW,QAAQ,OAAO,KAAK,CAAC,CAAC;CACnC;AACF"}
package/dist/btc.cjs ADDED
@@ -0,0 +1,9 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_shared = require("./shared-nISrEktU.cjs");
3
+ const require_btc = require("./btc-Fr6Jz4Fi.cjs");
4
+ exports.AnimatedUr = require_shared.AnimatedUr;
5
+ exports.BtcChain = require_btc.BtcChain;
6
+ exports.EraSdkError = require_shared.EraSdkError;
7
+ exports.TypedUrScanner = require_shared.TypedUrScanner;
8
+ exports.Ur = require_shared.Ur;
9
+ exports.UrScanner = require_shared.UrScanner;
package/dist/btc.d.cts ADDED
@@ -0,0 +1,3 @@
1
+ import { _ as Ur, a as SignRequest, c as TypedUrScanner, d as EraErrorCode, f as EraSdkError, i as ExpectedReply, l as UrScanner, p as AnimatedUr, r as EraConnectConfig } from "./shared-CI8zhQiE.cjs";
2
+ import { a as BtcPsbtSignRequestProps, i as BtcPsbtResult, n as BtcMessageSignRequestProps, r as BtcMessageSignatureResult, t as BtcChain } from "./btc-Dn6_Y12c.cjs";
3
+ export { AnimatedUr, BtcChain, type BtcMessageSignRequestProps, type BtcMessageSignatureResult, type BtcPsbtResult, type BtcPsbtSignRequestProps, type EraConnectConfig, type EraErrorCode, EraSdkError, type ExpectedReply, type SignRequest, TypedUrScanner, Ur, UrScanner };
package/dist/btc.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import { _ as Ur, a as SignRequest, c as TypedUrScanner, d as EraErrorCode, f as EraSdkError, i as ExpectedReply, l as UrScanner, p as AnimatedUr, r as EraConnectConfig } from "./shared-CI8zhQiE.js";
2
+ import { a as BtcPsbtSignRequestProps, i as BtcPsbtResult, n as BtcMessageSignRequestProps, r as BtcMessageSignatureResult, t as BtcChain } from "./btc-DfQ0q79G.js";
3
+ export { AnimatedUr, BtcChain, type BtcMessageSignRequestProps, type BtcMessageSignatureResult, type BtcPsbtResult, type BtcPsbtSignRequestProps, type EraConnectConfig, type EraErrorCode, EraSdkError, type ExpectedReply, type SignRequest, TypedUrScanner, Ur, UrScanner };
package/dist/btc.js ADDED
@@ -0,0 +1,3 @@
1
+ import { Z as EraSdkError, _ as Ur, d as UrScanner, f as AnimatedUr, u as TypedUrScanner } from "./shared-B8Wc7ViU.js";
2
+ import { t as BtcChain } from "./btc-VyJKXq7d.js";
3
+ export { AnimatedUr, BtcChain, EraSdkError, TypedUrScanner, Ur, UrScanner };
@@ -0,0 +1,134 @@
1
+ const require_shared = require("./shared-nISrEktU.cjs");
2
+ //#region src/chains/evm.ts
3
+ /** `eth-sign-request` dataType (CBOR key 3). */
4
+ const EvmDataType = {
5
+ /** RLP-encoded transaction (the device sniffs EIP-1559/2930/legacy from the leading byte). */
6
+ transaction: 1,
7
+ /** EIP-712 typed data JSON (UTF-8 bytes). */
8
+ typedData: 2,
9
+ /** personal_sign / raw message bytes (EIP-191 prefix applied by the device). */
10
+ personalMessage: 3,
11
+ /** Typed (EIP-2718) transaction bytes — treated identically to `transaction`. */
12
+ typedTransaction: 4
13
+ };
14
+ /** Over this size the device skips transaction decoding and falls back to blind signing. */
15
+ const BLIND_SIGN_THRESHOLD = 32768;
16
+ const REPLY_TYPES = ["eth-signature", "evm-signature"];
17
+ var EvmChain = class {
18
+ constructor(config) {
19
+ this.context = require_shared.resolveContext(config);
20
+ }
21
+ /** Build an `eth-sign-request` (401). Reply: `eth-signature` (402). */
22
+ generateSignRequest(props) {
23
+ const requestId = require_shared.resolveRequestId(this.context, props.requestId);
24
+ const path = require_shared.parsePath(props.path);
25
+ const xfp = require_shared.normalizeXfp(props.xfp);
26
+ if ((props.dataType === EvmDataType.transaction || props.dataType === EvmDataType.typedTransaction) && props.chainId === void 0) throw new require_shared.EraSdkError("invalid-props", "chainId is required for transaction sign requests");
27
+ if (props.chainId !== void 0) {
28
+ if (!Number.isSafeInteger(props.chainId) || props.chainId < 0) throw new require_shared.EraSdkError("invalid-props", "chainId must be a non-negative integer");
29
+ if (props.chainId > 4294967295) throw new require_shared.EraSdkError("invalid-props", `chainId ${props.chainId} exceeds the device's unsigned 32-bit range; a truncated id would produce a signature for a different chain`, { chainId: props.chainId });
30
+ }
31
+ const entries = [
32
+ [1, require_shared.cbBytes(requestId)],
33
+ [2, require_shared.cbBytes(props.signData)],
34
+ [3, require_shared.cbUint(props.dataType)]
35
+ ];
36
+ if (props.chainId !== void 0) entries.push([4, require_shared.cbUint(props.chainId)]);
37
+ entries.push([5, require_shared.keypath304(path, xfp)]);
38
+ if (props.address !== void 0) entries.push([6, require_shared.cbBytes(normalizeAddress(props.address))]);
39
+ entries.push([7, require_shared.cbText(props.origin ?? this.context.origin)]);
40
+ const ur = new require_shared.Ur("eth-sign-request", require_shared.cborEncode(require_shared.cbMap(entries)));
41
+ const warnings = [];
42
+ if (props.signData.length > BLIND_SIGN_THRESHOLD) warnings.push("blind-sign-threshold");
43
+ const maxSigLength = 64 + maxVBytes(props.dataType, props.chainId);
44
+ return require_shared.makeSignRequest({
45
+ ur,
46
+ requestId,
47
+ replyTypes: REPLY_TYPES,
48
+ warnings,
49
+ context: this.context,
50
+ parse: (reply) => parseEvmSignature(reply, { requestId }, maxSigLength)
51
+ });
52
+ }
53
+ /**
54
+ * Parse an `eth-signature` standalone. Without `expect.requestId` the echo
55
+ * is returned but not validated — prefer `SignRequest.scanner().parse()`.
56
+ */
57
+ parseSignature(input, expect) {
58
+ const expected = expect?.requestId === void 0 ? void 0 : { requestId: require_shared.normalizeRequestId(expect.requestId) };
59
+ return parseEvmSignature(require_shared.toUr(input), expected, 72);
60
+ }
61
+ };
62
+ EvmChain.DataType = EvmDataType;
63
+ function normalizeAddress(address) {
64
+ const bytes = address instanceof Uint8Array ? address : require_shared.hexToBytes(address);
65
+ if (bytes.length !== 20) throw new require_shared.EraSdkError("invalid-props", "EVM address must be 20 bytes");
66
+ return bytes;
67
+ }
68
+ /**
69
+ * Width of the widest `v` the device can legitimately return.
70
+ *
71
+ * For a legacy EIP-155 transaction `v = parity + chainId*2 + 35` — 2 bytes
72
+ * past chain id 110, 4 bytes for Aurora. Messages and typed data always
73
+ * answer with one byte (27/28). A flat ceiling either refuses genuine replies
74
+ * on large-id chains or accepts implausibly wide values; the exact bound
75
+ * comes from the request.
76
+ */
77
+ function maxVBytes(dataType, chainId) {
78
+ if (dataType !== EvmDataType.transaction && dataType !== EvmDataType.typedTransaction) return 1;
79
+ if (chainId === void 0) return 8;
80
+ let widest = BigInt(chainId) * 2n + 36n;
81
+ if (widest < 28n) widest = 28n;
82
+ let bytes = 0;
83
+ while (widest > 0n) {
84
+ bytes += 1;
85
+ widest >>= 8n;
86
+ }
87
+ return bytes;
88
+ }
89
+ function parseEvmSignature(ur, expect, maxSigLength) {
90
+ require_shared.requireUrType(ur, [...REPLY_TYPES], "eth-signature");
91
+ const map = require_shared.requireReplyMap(ur, "eth-signature");
92
+ const requestId = require_shared.requireRequestIdEcho(map, 1, expect?.requestId, "eth-signature");
93
+ const signature = require_shared.requireSignatureBytes(require_shared.mapGet(map, 2), "eth-signature", 65, maxSigLength);
94
+ const r = signature.slice(0, 32);
95
+ const s = signature.slice(32, 64);
96
+ const v = require_shared.bytesToBigint(signature.slice(64));
97
+ const recoveryId = foldRecoveryId(v);
98
+ if (recoveryId !== 0 && recoveryId !== 1) throw new require_shared.EraSdkError("malformed-reply", `eth-signature carries an implausible recovery value ${v}`);
99
+ return {
100
+ requestId,
101
+ signature,
102
+ r,
103
+ s,
104
+ v,
105
+ recoveryId
106
+ };
107
+ }
108
+ /** Fold parity / 27-28 / EIP-155 forms of `v` to a 0/1 recovery id. */
109
+ function foldRecoveryId(v) {
110
+ if (v >= 35n) return Number(v - 35n & 1n);
111
+ if (v >= 27n) return Number(v - 27n);
112
+ return Number(v);
113
+ }
114
+ //#endregion
115
+ Object.defineProperty(exports, "EvmChain", {
116
+ enumerable: true,
117
+ get: function() {
118
+ return EvmChain;
119
+ }
120
+ });
121
+ Object.defineProperty(exports, "EvmDataType", {
122
+ enumerable: true,
123
+ get: function() {
124
+ return EvmDataType;
125
+ }
126
+ });
127
+ Object.defineProperty(exports, "foldRecoveryId", {
128
+ enumerable: true,
129
+ get: function() {
130
+ return foldRecoveryId;
131
+ }
132
+ });
133
+
134
+ //# sourceMappingURL=evm-BHj_2OTG.cjs.map
@@ -0,0 +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,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,eAAAA,UAAU,MAAM,IAAI;EACjC,MAAM,MAAMC,eAAAA,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,MAAM,YAAY,KAAA,GAAW,QAAQ,KAAK,CA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,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"}
@@ -0,0 +1,76 @@
1
+ import { _ as Ur, a as SignRequest, i as ExpectedReply, r as EraConnectConfig } from "./shared-CI8zhQiE.cjs";
2
+ //#region src/chains/evm.d.ts
3
+ /** `eth-sign-request` dataType (CBOR key 3). */
4
+ declare const EvmDataType: {
5
+ /** RLP-encoded transaction (the device sniffs EIP-1559/2930/legacy from the leading byte). */
6
+ readonly transaction: 1;
7
+ /** EIP-712 typed data JSON (UTF-8 bytes). */
8
+ readonly typedData: 2;
9
+ /** personal_sign / raw message bytes (EIP-191 prefix applied by the device). */
10
+ readonly personalMessage: 3;
11
+ /** Typed (EIP-2718) transaction bytes — treated identically to `transaction`. */
12
+ readonly typedTransaction: 4;
13
+ };
14
+ type EvmDataType = (typeof EvmDataType)[keyof typeof EvmDataType];
15
+ interface EvmSignRequestProps {
16
+ /** 16 bytes or a UUID string; minted if omitted. */
17
+ readonly requestId?: Uint8Array | string;
18
+ /** RLP tx bytes, typed-data JSON UTF-8, or raw message bytes. */
19
+ readonly signData: Uint8Array;
20
+ readonly dataType: EvmDataType;
21
+ /** Full signing path, e.g. `m/44'/60'/0'/0/0`. */
22
+ readonly path: string;
23
+ /** The account's source fingerprint from the linked wallet (`EraAccounts.xfpFor(...)`). */
24
+ readonly xfp: string | number;
25
+ /**
26
+ * Required for transactions (it derives the legal reply width). The device
27
+ * reads it as an unsigned 32-bit value — larger chain ids are refused here,
28
+ * because a silently truncated id would sign for a different chain.
29
+ */
30
+ readonly chainId?: number;
31
+ /** 20-byte signer address; recommended (enables verification helpers). */
32
+ readonly address?: Uint8Array | `0x${string}`;
33
+ /** Overrides the SDK-level origin label for this request. */
34
+ readonly origin?: string;
35
+ }
36
+ interface EvmSignatureResult {
37
+ readonly requestId: Uint8Array;
38
+ /** Raw `r || s || v` exactly as the device sent it (may exceed 65 bytes for legacy EIP-155). */
39
+ readonly signature: Uint8Array;
40
+ readonly r: Uint8Array;
41
+ readonly s: Uint8Array;
42
+ /**
43
+ * The recovery value AS SENT: parity (0/1) for typed transactions, 27/28
44
+ * for messages, already-EIP-155-encoded (`parity + chainId*2 + 35`) for
45
+ * legacy transactions. Do NOT re-apply the EIP-155 formula.
46
+ */
47
+ readonly v: bigint;
48
+ /** `v` folded to a plain 0/1 recovery id, whichever of the three forms it arrived in. */
49
+ readonly recoveryId: 0 | 1;
50
+ }
51
+ declare class EvmChain {
52
+ static readonly DataType: {
53
+ /** RLP-encoded transaction (the device sniffs EIP-1559/2930/legacy from the leading byte). */
54
+ readonly transaction: 1;
55
+ /** EIP-712 typed data JSON (UTF-8 bytes). */
56
+ readonly typedData: 2;
57
+ /** personal_sign / raw message bytes (EIP-191 prefix applied by the device). */
58
+ readonly personalMessage: 3;
59
+ /** Typed (EIP-2718) transaction bytes — treated identically to `transaction`. */
60
+ readonly typedTransaction: 4;
61
+ };
62
+ private readonly context;
63
+ constructor(config?: EraConnectConfig);
64
+ /** Build an `eth-sign-request` (401). Reply: `eth-signature` (402). */
65
+ generateSignRequest(props: EvmSignRequestProps): SignRequest<EvmSignatureResult>;
66
+ /**
67
+ * Parse an `eth-signature` standalone. Without `expect.requestId` the echo
68
+ * is returned but not validated — prefer `SignRequest.scanner().parse()`.
69
+ */
70
+ parseSignature(input: Ur | string, expect?: ExpectedReply): EvmSignatureResult;
71
+ }
72
+ /** Fold parity / 27-28 / EIP-155 forms of `v` to a 0/1 recovery id. */
73
+ declare function foldRecoveryId(v: bigint): number;
74
+ //#endregion
75
+ export { foldRecoveryId as a, EvmSignatureResult as i, EvmDataType as n, EvmSignRequestProps as r, EvmChain as t };
76
+ //# sourceMappingURL=evm-DJxGGAbD.d.cts.map
@@ -0,0 +1,76 @@
1
+ import { _ as Ur, a as SignRequest, i as ExpectedReply, r as EraConnectConfig } from "./shared-CI8zhQiE.js";
2
+ //#region src/chains/evm.d.ts
3
+ /** `eth-sign-request` dataType (CBOR key 3). */
4
+ declare const EvmDataType: {
5
+ /** RLP-encoded transaction (the device sniffs EIP-1559/2930/legacy from the leading byte). */
6
+ readonly transaction: 1;
7
+ /** EIP-712 typed data JSON (UTF-8 bytes). */
8
+ readonly typedData: 2;
9
+ /** personal_sign / raw message bytes (EIP-191 prefix applied by the device). */
10
+ readonly personalMessage: 3;
11
+ /** Typed (EIP-2718) transaction bytes — treated identically to `transaction`. */
12
+ readonly typedTransaction: 4;
13
+ };
14
+ type EvmDataType = (typeof EvmDataType)[keyof typeof EvmDataType];
15
+ interface EvmSignRequestProps {
16
+ /** 16 bytes or a UUID string; minted if omitted. */
17
+ readonly requestId?: Uint8Array | string;
18
+ /** RLP tx bytes, typed-data JSON UTF-8, or raw message bytes. */
19
+ readonly signData: Uint8Array;
20
+ readonly dataType: EvmDataType;
21
+ /** Full signing path, e.g. `m/44'/60'/0'/0/0`. */
22
+ readonly path: string;
23
+ /** The account's source fingerprint from the linked wallet (`EraAccounts.xfpFor(...)`). */
24
+ readonly xfp: string | number;
25
+ /**
26
+ * Required for transactions (it derives the legal reply width). The device
27
+ * reads it as an unsigned 32-bit value — larger chain ids are refused here,
28
+ * because a silently truncated id would sign for a different chain.
29
+ */
30
+ readonly chainId?: number;
31
+ /** 20-byte signer address; recommended (enables verification helpers). */
32
+ readonly address?: Uint8Array | `0x${string}`;
33
+ /** Overrides the SDK-level origin label for this request. */
34
+ readonly origin?: string;
35
+ }
36
+ interface EvmSignatureResult {
37
+ readonly requestId: Uint8Array;
38
+ /** Raw `r || s || v` exactly as the device sent it (may exceed 65 bytes for legacy EIP-155). */
39
+ readonly signature: Uint8Array;
40
+ readonly r: Uint8Array;
41
+ readonly s: Uint8Array;
42
+ /**
43
+ * The recovery value AS SENT: parity (0/1) for typed transactions, 27/28
44
+ * for messages, already-EIP-155-encoded (`parity + chainId*2 + 35`) for
45
+ * legacy transactions. Do NOT re-apply the EIP-155 formula.
46
+ */
47
+ readonly v: bigint;
48
+ /** `v` folded to a plain 0/1 recovery id, whichever of the three forms it arrived in. */
49
+ readonly recoveryId: 0 | 1;
50
+ }
51
+ declare class EvmChain {
52
+ static readonly DataType: {
53
+ /** RLP-encoded transaction (the device sniffs EIP-1559/2930/legacy from the leading byte). */
54
+ readonly transaction: 1;
55
+ /** EIP-712 typed data JSON (UTF-8 bytes). */
56
+ readonly typedData: 2;
57
+ /** personal_sign / raw message bytes (EIP-191 prefix applied by the device). */
58
+ readonly personalMessage: 3;
59
+ /** Typed (EIP-2718) transaction bytes — treated identically to `transaction`. */
60
+ readonly typedTransaction: 4;
61
+ };
62
+ private readonly context;
63
+ constructor(config?: EraConnectConfig);
64
+ /** Build an `eth-sign-request` (401). Reply: `eth-signature` (402). */
65
+ generateSignRequest(props: EvmSignRequestProps): SignRequest<EvmSignatureResult>;
66
+ /**
67
+ * Parse an `eth-signature` standalone. Without `expect.requestId` the echo
68
+ * is returned but not validated — prefer `SignRequest.scanner().parse()`.
69
+ */
70
+ parseSignature(input: Ur | string, expect?: ExpectedReply): EvmSignatureResult;
71
+ }
72
+ /** Fold parity / 27-28 / EIP-155 forms of `v` to a 0/1 recovery id. */
73
+ declare function foldRecoveryId(v: bigint): number;
74
+ //#endregion
75
+ export { foldRecoveryId as a, EvmSignatureResult as i, EvmDataType as n, EvmSignRequestProps as r, EvmChain as t };
76
+ //# sourceMappingURL=evm-KrV5wK08.d.ts.map
@@ -0,0 +1,117 @@
1
+ import { C as bytesToBigint, D as hexToBytes, G as cbMap, J as cbUint, M as keypath304, N as normalizeXfp, P as parsePath, W as cbBytes, Y as mapGet, Z as EraSdkError, _ as Ur, a as requireSignatureBytes, c as resolveRequestId, h as normalizeRequestId, i as requireRequestIdEcho, l as toUr, n as makeSignRequest, o as requireUrType, q as cbText, r as requireReplyMap, s as resolveContext, x as cborEncode } from "./shared-B8Wc7ViU.js";
2
+ //#region src/chains/evm.ts
3
+ /** `eth-sign-request` dataType (CBOR key 3). */
4
+ const EvmDataType = {
5
+ /** RLP-encoded transaction (the device sniffs EIP-1559/2930/legacy from the leading byte). */
6
+ transaction: 1,
7
+ /** EIP-712 typed data JSON (UTF-8 bytes). */
8
+ typedData: 2,
9
+ /** personal_sign / raw message bytes (EIP-191 prefix applied by the device). */
10
+ personalMessage: 3,
11
+ /** Typed (EIP-2718) transaction bytes — treated identically to `transaction`. */
12
+ typedTransaction: 4
13
+ };
14
+ /** Over this size the device skips transaction decoding and falls back to blind signing. */
15
+ const BLIND_SIGN_THRESHOLD = 32768;
16
+ const REPLY_TYPES = ["eth-signature", "evm-signature"];
17
+ var EvmChain = class {
18
+ constructor(config) {
19
+ this.context = resolveContext(config);
20
+ }
21
+ /** Build an `eth-sign-request` (401). Reply: `eth-signature` (402). */
22
+ generateSignRequest(props) {
23
+ const requestId = resolveRequestId(this.context, props.requestId);
24
+ const path = parsePath(props.path);
25
+ const xfp = normalizeXfp(props.xfp);
26
+ if ((props.dataType === EvmDataType.transaction || props.dataType === EvmDataType.typedTransaction) && props.chainId === void 0) throw new EraSdkError("invalid-props", "chainId is required for transaction sign requests");
27
+ if (props.chainId !== void 0) {
28
+ if (!Number.isSafeInteger(props.chainId) || props.chainId < 0) throw new EraSdkError("invalid-props", "chainId must be a non-negative integer");
29
+ if (props.chainId > 4294967295) throw new EraSdkError("invalid-props", `chainId ${props.chainId} exceeds the device's unsigned 32-bit range; a truncated id would produce a signature for a different chain`, { chainId: props.chainId });
30
+ }
31
+ const entries = [
32
+ [1, cbBytes(requestId)],
33
+ [2, cbBytes(props.signData)],
34
+ [3, cbUint(props.dataType)]
35
+ ];
36
+ if (props.chainId !== void 0) entries.push([4, cbUint(props.chainId)]);
37
+ entries.push([5, keypath304(path, xfp)]);
38
+ if (props.address !== void 0) entries.push([6, cbBytes(normalizeAddress(props.address))]);
39
+ entries.push([7, cbText(props.origin ?? this.context.origin)]);
40
+ const ur = new Ur("eth-sign-request", cborEncode(cbMap(entries)));
41
+ const warnings = [];
42
+ if (props.signData.length > BLIND_SIGN_THRESHOLD) warnings.push("blind-sign-threshold");
43
+ const maxSigLength = 64 + maxVBytes(props.dataType, props.chainId);
44
+ return makeSignRequest({
45
+ ur,
46
+ requestId,
47
+ replyTypes: REPLY_TYPES,
48
+ warnings,
49
+ context: this.context,
50
+ parse: (reply) => parseEvmSignature(reply, { requestId }, maxSigLength)
51
+ });
52
+ }
53
+ /**
54
+ * Parse an `eth-signature` standalone. Without `expect.requestId` the echo
55
+ * is returned but not validated — prefer `SignRequest.scanner().parse()`.
56
+ */
57
+ parseSignature(input, expect) {
58
+ const expected = expect?.requestId === void 0 ? void 0 : { requestId: normalizeRequestId(expect.requestId) };
59
+ return parseEvmSignature(toUr(input), expected, 72);
60
+ }
61
+ };
62
+ EvmChain.DataType = EvmDataType;
63
+ function normalizeAddress(address) {
64
+ const bytes = address instanceof Uint8Array ? address : hexToBytes(address);
65
+ if (bytes.length !== 20) throw new EraSdkError("invalid-props", "EVM address must be 20 bytes");
66
+ return bytes;
67
+ }
68
+ /**
69
+ * Width of the widest `v` the device can legitimately return.
70
+ *
71
+ * For a legacy EIP-155 transaction `v = parity + chainId*2 + 35` — 2 bytes
72
+ * past chain id 110, 4 bytes for Aurora. Messages and typed data always
73
+ * answer with one byte (27/28). A flat ceiling either refuses genuine replies
74
+ * on large-id chains or accepts implausibly wide values; the exact bound
75
+ * comes from the request.
76
+ */
77
+ function maxVBytes(dataType, chainId) {
78
+ if (dataType !== EvmDataType.transaction && dataType !== EvmDataType.typedTransaction) return 1;
79
+ if (chainId === void 0) return 8;
80
+ let widest = BigInt(chainId) * 2n + 36n;
81
+ if (widest < 28n) widest = 28n;
82
+ let bytes = 0;
83
+ while (widest > 0n) {
84
+ bytes += 1;
85
+ widest >>= 8n;
86
+ }
87
+ return bytes;
88
+ }
89
+ function parseEvmSignature(ur, expect, maxSigLength) {
90
+ requireUrType(ur, [...REPLY_TYPES], "eth-signature");
91
+ const map = requireReplyMap(ur, "eth-signature");
92
+ const requestId = requireRequestIdEcho(map, 1, expect?.requestId, "eth-signature");
93
+ const signature = requireSignatureBytes(mapGet(map, 2), "eth-signature", 65, maxSigLength);
94
+ const r = signature.slice(0, 32);
95
+ const s = signature.slice(32, 64);
96
+ const v = bytesToBigint(signature.slice(64));
97
+ const recoveryId = foldRecoveryId(v);
98
+ if (recoveryId !== 0 && recoveryId !== 1) throw new EraSdkError("malformed-reply", `eth-signature carries an implausible recovery value ${v}`);
99
+ return {
100
+ requestId,
101
+ signature,
102
+ r,
103
+ s,
104
+ v,
105
+ recoveryId
106
+ };
107
+ }
108
+ /** Fold parity / 27-28 / EIP-155 forms of `v` to a 0/1 recovery id. */
109
+ function foldRecoveryId(v) {
110
+ if (v >= 35n) return Number(v - 35n & 1n);
111
+ if (v >= 27n) return Number(v - 27n);
112
+ return Number(v);
113
+ }
114
+ //#endregion
115
+ export { EvmDataType as n, foldRecoveryId as r, EvmChain as t };
116
+
117
+ //# sourceMappingURL=evm-kJb3-oiR.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evm-kJb3-oiR.js","names":["UrValue"],"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,UAAU,eAAe,MAAM;CACtC;;CAGA,oBAAoB,OAA6D;EAC/E,MAAM,YAAY,iBAAiB,KAAK,SAAS,MAAM,SAAS;EAChE,MAAM,OAAO,UAAU,MAAM,IAAI;E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G;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 ADDED
@@ -0,0 +1,11 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_shared = require("./shared-nISrEktU.cjs");
3
+ const require_evm = require("./evm-BHj_2OTG.cjs");
4
+ exports.AnimatedUr = require_shared.AnimatedUr;
5
+ exports.EraSdkError = require_shared.EraSdkError;
6
+ exports.EvmChain = require_evm.EvmChain;
7
+ exports.EvmDataType = require_evm.EvmDataType;
8
+ exports.TypedUrScanner = require_shared.TypedUrScanner;
9
+ exports.Ur = require_shared.Ur;
10
+ exports.UrScanner = require_shared.UrScanner;
11
+ exports.foldRecoveryId = require_evm.foldRecoveryId;
package/dist/evm.d.cts ADDED
@@ -0,0 +1,3 @@
1
+ import { _ as Ur, a as SignRequest, c as TypedUrScanner, d as EraErrorCode, f as EraSdkError, i as ExpectedReply, l as UrScanner, p as AnimatedUr, r as EraConnectConfig } from "./shared-CI8zhQiE.cjs";
2
+ import { a as foldRecoveryId, i as EvmSignatureResult, n as EvmDataType, r as EvmSignRequestProps, t as EvmChain } from "./evm-DJxGGAbD.cjs";
3
+ export { AnimatedUr, type EraConnectConfig, type EraErrorCode, EraSdkError, EvmChain, EvmDataType, type EvmSignRequestProps, type EvmSignatureResult, type ExpectedReply, type SignRequest, TypedUrScanner, Ur, UrScanner, foldRecoveryId };
package/dist/evm.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import { _ as Ur, a as SignRequest, c as TypedUrScanner, d as EraErrorCode, f as EraSdkError, i as ExpectedReply, l as UrScanner, p as AnimatedUr, r as EraConnectConfig } from "./shared-CI8zhQiE.js";
2
+ import { a as foldRecoveryId, i as EvmSignatureResult, n as EvmDataType, r as EvmSignRequestProps, t as EvmChain } from "./evm-KrV5wK08.js";
3
+ export { AnimatedUr, type EraConnectConfig, type EraErrorCode, EraSdkError, EvmChain, EvmDataType, type EvmSignRequestProps, type EvmSignatureResult, type ExpectedReply, type SignRequest, TypedUrScanner, Ur, UrScanner, foldRecoveryId };
package/dist/evm.js ADDED
@@ -0,0 +1,3 @@
1
+ import { Z as EraSdkError, _ as Ur, d as UrScanner, f as AnimatedUr, u as TypedUrScanner } from "./shared-B8Wc7ViU.js";
2
+ import { n as EvmDataType, r as foldRecoveryId, t as EvmChain } from "./evm-kJb3-oiR.js";
3
+ export { AnimatedUr, EraSdkError, EvmChain, EvmDataType, TypedUrScanner, Ur, UrScanner, foldRecoveryId };