@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,162 @@
1
+ import { n as EvmDataType } from "./evm-DJxGGAbD.cjs";
2
+ import { n as TronLatestBlock, t as SignedTronTx } from "./messages-DsPvW8Oi.cjs";
3
+ //#region src/verify/result.d.ts
4
+ /** Outcome of a verification helper. Helpers return, never throw, on mismatches. */
5
+ type VerifyResult =
6
+ /** Verified cryptographically / byte-for-byte. */
7
+ {
8
+ readonly ok: true;
9
+ readonly checked: true;
10
+ } |
11
+ /**
12
+ * Nothing client-side is verifiable for this input (EIP-712 typed data:
13
+ * the digest is the hash of the structure, which only the device computes).
14
+ * The UR-type pin and the request-id echo are the whole binding.
15
+ */
16
+ {
17
+ readonly ok: true;
18
+ readonly checked: false;
19
+ readonly reason: string;
20
+ } | {
21
+ readonly ok: false;
22
+ readonly reason: string;
23
+ };
24
+ //#endregion
25
+ //#region src/verify/btc.d.ts
26
+ interface VerifySignedPsbtArgs {
27
+ /** The PSBT you sent to the device. */
28
+ readonly sentPsbt: Uint8Array;
29
+ /** The PSBT the device returned. */
30
+ readonly signedPsbt: Uint8Array;
31
+ /**
32
+ * true (default) on flows where every input is yours (a plain send): a
33
+ * reply that signed only part of the transaction is refused here with a
34
+ * reason instead of failing later inside a finalizer. Set false for dApp
35
+ * `signPsbt` hand-backs, where a PSBT legitimately carries inputs you
36
+ * cannot sign.
37
+ */
38
+ readonly requireEveryInputSigned?: boolean;
39
+ }
40
+ /**
41
+ * The `crypto-psbt` reply carries NO request id — this comparison IS the
42
+ * anti-replay binding for Bitcoin. It is not optional.
43
+ *
44
+ * The unsigned transaction is compared byte for byte, which pins the input
45
+ * set and order, the outputs, their amounts, the version and the locktime in
46
+ * one shot — and therefore the txid. The device only ADDS per-input
47
+ * signature fields, so a legitimate reply always matches.
48
+ */
49
+ declare function verifySignedPsbt(args: VerifySignedPsbtArgs): VerifyResult;
50
+ interface VerifyBtcMessageHeaderArgs {
51
+ /** The address the request asked the device to sign with. */
52
+ readonly address: string;
53
+ /** The raw 65-byte BIP-137 signature. */
54
+ readonly signature: Uint8Array;
55
+ }
56
+ /**
57
+ * BIP-137: the recovery header names the address type a verifier derives
58
+ * before comparing. A header of the wrong range produces a signature that
59
+ * LOOKS fine (65 bytes, valid base64) but fails every verifier downstream —
60
+ * this check is the only place that difference is visible.
61
+ */
62
+ declare function verifyBtcMessageHeader(args: VerifyBtcMessageHeaderArgs): VerifyResult;
63
+ //#endregion
64
+ //#region src/verify/evm.d.ts
65
+ interface VerifyEvmSignatureArgs {
66
+ /** The exact bytes the request carried in `signData`. */
67
+ readonly signData: Uint8Array;
68
+ readonly dataType: EvmDataType;
69
+ /** Raw `r || s || v` from the reply (65+ bytes; multi-byte legacy `v` handled). */
70
+ readonly signature: Uint8Array;
71
+ /** The signer address the request was built for. */
72
+ readonly address: Uint8Array | `0x${string}`;
73
+ /**
74
+ * Optional: the signing payload re-derived from the transaction you are
75
+ * ABOUT TO BROADCAST. Recovering against `signData` alone proves the device
76
+ * signed something you asked for — this closes the second half: that it is
77
+ * the transaction still in your hands (payloads can legitimately change
78
+ * between build and send, e.g. a blockhash refresh in your own state).
79
+ */
80
+ readonly reEncodedSignData?: Uint8Array;
81
+ }
82
+ /**
83
+ * "Did the device sign exactly what I sent, with the key I expected?"
84
+ * keccak digest + public-key recovery; the recovered address must equal the
85
+ * request's. Run it before broadcasting.
86
+ */
87
+ declare function verifyEvmSignature(args: VerifyEvmSignatureArgs): VerifyResult;
88
+ //#endregion
89
+ //#region src/verify/psbt-reader.d.ts
90
+ /**
91
+ * Minimal PSBT v0 (BIP-174) reader — just enough structure for the
92
+ * verification guard: the global unsigned transaction (verbatim slice, never
93
+ * re-serialized), the PSBT version, and per-input key/value maps.
94
+ *
95
+ * Hardened: compact-size lengths bounds-checked before slicing, duplicate
96
+ * keys within one map refused (a hostile PSBT carrying two final scriptSigs
97
+ * for one input must not survive parsing).
98
+ */
99
+ interface PsbtKeyValue {
100
+ readonly keyType: number;
101
+ readonly keyData: Uint8Array;
102
+ readonly value: Uint8Array;
103
+ }
104
+ interface ParsedPsbt {
105
+ /** The global UNSIGNED_TX value, verbatim. */
106
+ readonly unsignedTx: Uint8Array;
107
+ /** Global PSBT_GLOBAL_VERSION (0xFB) if present; v0 files normally omit it. */
108
+ readonly version: number;
109
+ readonly inputs: readonly (readonly PsbtKeyValue[])[];
110
+ readonly outputs: readonly (readonly PsbtKeyValue[])[];
111
+ }
112
+ declare const PsbtInputType: {
113
+ readonly partialSig: 2;
114
+ readonly finalScriptSig: 7;
115
+ readonly finalScriptWitness: 8;
116
+ readonly taprootKeySpendSignature: 19;
117
+ readonly taprootScriptSpendSignature: 20;
118
+ };
119
+ declare function parsePsbt(bytes: Uint8Array): ParsedPsbt;
120
+ //#endregion
121
+ //#region src/verify/solana.d.ts
122
+ interface VerifySolanaSignatureArgs {
123
+ /** The exact bytes the request carried in `signData` (the compiled message). */
124
+ readonly signData: Uint8Array;
125
+ /** 64-byte Ed25519 signature from the reply. */
126
+ readonly signature: Uint8Array;
127
+ /** The 32-byte signer public key the request was built for. */
128
+ readonly publicKey: Uint8Array;
129
+ /**
130
+ * Optional: the message bytes you are ABOUT TO BROADCAST. Matters most on
131
+ * Solana — a blockhash refresh between build and send makes "what was
132
+ * signed" and "what will be sent" two different objects that must agree.
133
+ */
134
+ readonly broadcastMessageBytes?: Uint8Array;
135
+ }
136
+ declare function verifySolanaSignature(args: VerifySolanaSignatureArgs): VerifyResult;
137
+ //#endregion
138
+ //#region src/verify/tron.d.ts
139
+ interface VerifyTronSignatureArgs {
140
+ /** The `raw_data` bytes the request carried. */
141
+ readonly rawData: Uint8Array;
142
+ /** The base58 owner address the transaction spends from. */
143
+ readonly from: string;
144
+ /** The reference block the request carried (enables the rebuild-path window check). */
145
+ readonly latestBlock?: TronLatestBlock;
146
+ /** The reply: either the split frame from `TronSignatureResult.signedTx`, or the raw hex. */
147
+ readonly signedTx: SignedTronTx | string;
148
+ }
149
+ /**
150
+ * The Tron reply is a fully signed transaction broadcast VERBATIM, so it is
151
+ * checked on both counts: every signature must recover to the owner address,
152
+ * and the transaction must move what the user approved.
153
+ *
154
+ * Byte equality with the request's `rawData` is the strong form. When the
155
+ * bytes differ (a firmware that rebuilds `raw_data` from the semantic
156
+ * fields), the fallback compares the fields that decide where the money goes,
157
+ * plus the validity window against the reference block.
158
+ */
159
+ declare function verifyTronSignature(args: VerifyTronSignatureArgs): VerifyResult;
160
+ //#endregion
161
+ export { type ParsedPsbt, PsbtInputType, type PsbtKeyValue, type VerifyBtcMessageHeaderArgs, type VerifyEvmSignatureArgs, type VerifyResult, type VerifySignedPsbtArgs, type VerifySolanaSignatureArgs, type VerifyTronSignatureArgs, parsePsbt, verifyBtcMessageHeader, verifyEvmSignature, verifySignedPsbt, verifySolanaSignature, verifyTronSignature };
162
+ //# sourceMappingURL=verify.d.cts.map
@@ -0,0 +1,162 @@
1
+ import { n as EvmDataType } from "./evm-KrV5wK08.js";
2
+ import { n as TronLatestBlock, t as SignedTronTx } from "./messages-DsPvW8Oi.js";
3
+ //#region src/verify/result.d.ts
4
+ /** Outcome of a verification helper. Helpers return, never throw, on mismatches. */
5
+ type VerifyResult =
6
+ /** Verified cryptographically / byte-for-byte. */
7
+ {
8
+ readonly ok: true;
9
+ readonly checked: true;
10
+ } |
11
+ /**
12
+ * Nothing client-side is verifiable for this input (EIP-712 typed data:
13
+ * the digest is the hash of the structure, which only the device computes).
14
+ * The UR-type pin and the request-id echo are the whole binding.
15
+ */
16
+ {
17
+ readonly ok: true;
18
+ readonly checked: false;
19
+ readonly reason: string;
20
+ } | {
21
+ readonly ok: false;
22
+ readonly reason: string;
23
+ };
24
+ //#endregion
25
+ //#region src/verify/btc.d.ts
26
+ interface VerifySignedPsbtArgs {
27
+ /** The PSBT you sent to the device. */
28
+ readonly sentPsbt: Uint8Array;
29
+ /** The PSBT the device returned. */
30
+ readonly signedPsbt: Uint8Array;
31
+ /**
32
+ * true (default) on flows where every input is yours (a plain send): a
33
+ * reply that signed only part of the transaction is refused here with a
34
+ * reason instead of failing later inside a finalizer. Set false for dApp
35
+ * `signPsbt` hand-backs, where a PSBT legitimately carries inputs you
36
+ * cannot sign.
37
+ */
38
+ readonly requireEveryInputSigned?: boolean;
39
+ }
40
+ /**
41
+ * The `crypto-psbt` reply carries NO request id — this comparison IS the
42
+ * anti-replay binding for Bitcoin. It is not optional.
43
+ *
44
+ * The unsigned transaction is compared byte for byte, which pins the input
45
+ * set and order, the outputs, their amounts, the version and the locktime in
46
+ * one shot — and therefore the txid. The device only ADDS per-input
47
+ * signature fields, so a legitimate reply always matches.
48
+ */
49
+ declare function verifySignedPsbt(args: VerifySignedPsbtArgs): VerifyResult;
50
+ interface VerifyBtcMessageHeaderArgs {
51
+ /** The address the request asked the device to sign with. */
52
+ readonly address: string;
53
+ /** The raw 65-byte BIP-137 signature. */
54
+ readonly signature: Uint8Array;
55
+ }
56
+ /**
57
+ * BIP-137: the recovery header names the address type a verifier derives
58
+ * before comparing. A header of the wrong range produces a signature that
59
+ * LOOKS fine (65 bytes, valid base64) but fails every verifier downstream —
60
+ * this check is the only place that difference is visible.
61
+ */
62
+ declare function verifyBtcMessageHeader(args: VerifyBtcMessageHeaderArgs): VerifyResult;
63
+ //#endregion
64
+ //#region src/verify/evm.d.ts
65
+ interface VerifyEvmSignatureArgs {
66
+ /** The exact bytes the request carried in `signData`. */
67
+ readonly signData: Uint8Array;
68
+ readonly dataType: EvmDataType;
69
+ /** Raw `r || s || v` from the reply (65+ bytes; multi-byte legacy `v` handled). */
70
+ readonly signature: Uint8Array;
71
+ /** The signer address the request was built for. */
72
+ readonly address: Uint8Array | `0x${string}`;
73
+ /**
74
+ * Optional: the signing payload re-derived from the transaction you are
75
+ * ABOUT TO BROADCAST. Recovering against `signData` alone proves the device
76
+ * signed something you asked for — this closes the second half: that it is
77
+ * the transaction still in your hands (payloads can legitimately change
78
+ * between build and send, e.g. a blockhash refresh in your own state).
79
+ */
80
+ readonly reEncodedSignData?: Uint8Array;
81
+ }
82
+ /**
83
+ * "Did the device sign exactly what I sent, with the key I expected?"
84
+ * keccak digest + public-key recovery; the recovered address must equal the
85
+ * request's. Run it before broadcasting.
86
+ */
87
+ declare function verifyEvmSignature(args: VerifyEvmSignatureArgs): VerifyResult;
88
+ //#endregion
89
+ //#region src/verify/psbt-reader.d.ts
90
+ /**
91
+ * Minimal PSBT v0 (BIP-174) reader — just enough structure for the
92
+ * verification guard: the global unsigned transaction (verbatim slice, never
93
+ * re-serialized), the PSBT version, and per-input key/value maps.
94
+ *
95
+ * Hardened: compact-size lengths bounds-checked before slicing, duplicate
96
+ * keys within one map refused (a hostile PSBT carrying two final scriptSigs
97
+ * for one input must not survive parsing).
98
+ */
99
+ interface PsbtKeyValue {
100
+ readonly keyType: number;
101
+ readonly keyData: Uint8Array;
102
+ readonly value: Uint8Array;
103
+ }
104
+ interface ParsedPsbt {
105
+ /** The global UNSIGNED_TX value, verbatim. */
106
+ readonly unsignedTx: Uint8Array;
107
+ /** Global PSBT_GLOBAL_VERSION (0xFB) if present; v0 files normally omit it. */
108
+ readonly version: number;
109
+ readonly inputs: readonly (readonly PsbtKeyValue[])[];
110
+ readonly outputs: readonly (readonly PsbtKeyValue[])[];
111
+ }
112
+ declare const PsbtInputType: {
113
+ readonly partialSig: 2;
114
+ readonly finalScriptSig: 7;
115
+ readonly finalScriptWitness: 8;
116
+ readonly taprootKeySpendSignature: 19;
117
+ readonly taprootScriptSpendSignature: 20;
118
+ };
119
+ declare function parsePsbt(bytes: Uint8Array): ParsedPsbt;
120
+ //#endregion
121
+ //#region src/verify/solana.d.ts
122
+ interface VerifySolanaSignatureArgs {
123
+ /** The exact bytes the request carried in `signData` (the compiled message). */
124
+ readonly signData: Uint8Array;
125
+ /** 64-byte Ed25519 signature from the reply. */
126
+ readonly signature: Uint8Array;
127
+ /** The 32-byte signer public key the request was built for. */
128
+ readonly publicKey: Uint8Array;
129
+ /**
130
+ * Optional: the message bytes you are ABOUT TO BROADCAST. Matters most on
131
+ * Solana — a blockhash refresh between build and send makes "what was
132
+ * signed" and "what will be sent" two different objects that must agree.
133
+ */
134
+ readonly broadcastMessageBytes?: Uint8Array;
135
+ }
136
+ declare function verifySolanaSignature(args: VerifySolanaSignatureArgs): VerifyResult;
137
+ //#endregion
138
+ //#region src/verify/tron.d.ts
139
+ interface VerifyTronSignatureArgs {
140
+ /** The `raw_data` bytes the request carried. */
141
+ readonly rawData: Uint8Array;
142
+ /** The base58 owner address the transaction spends from. */
143
+ readonly from: string;
144
+ /** The reference block the request carried (enables the rebuild-path window check). */
145
+ readonly latestBlock?: TronLatestBlock;
146
+ /** The reply: either the split frame from `TronSignatureResult.signedTx`, or the raw hex. */
147
+ readonly signedTx: SignedTronTx | string;
148
+ }
149
+ /**
150
+ * The Tron reply is a fully signed transaction broadcast VERBATIM, so it is
151
+ * checked on both counts: every signature must recover to the owner address,
152
+ * and the transaction must move what the user approved.
153
+ *
154
+ * Byte equality with the request's `rawData` is the strong form. When the
155
+ * bytes differ (a firmware that rebuilds `raw_data` from the semantic
156
+ * fields), the fallback compares the fields that decide where the money goes,
157
+ * plus the validity window against the reference block.
158
+ */
159
+ declare function verifyTronSignature(args: VerifyTronSignatureArgs): VerifyResult;
160
+ //#endregion
161
+ export { type ParsedPsbt, PsbtInputType, type PsbtKeyValue, type VerifyBtcMessageHeaderArgs, type VerifyEvmSignatureArgs, type VerifyResult, type VerifySignedPsbtArgs, type VerifySolanaSignatureArgs, type VerifyTronSignatureArgs, parsePsbt, verifyBtcMessageHeader, verifyEvmSignature, verifySignedPsbt, verifySolanaSignature, verifyTronSignature };
162
+ //# sourceMappingURL=verify.d.ts.map