@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,218 @@
1
+ //#region src/ur/ur.d.ts
2
+ /** An immutable Uniform Resource: a registry type string plus its CBOR payload. */
3
+ declare class Ur {
4
+ readonly type: string;
5
+ readonly cbor: Uint8Array;
6
+ constructor(type: string, cbor: Uint8Array);
7
+ /** The whole UR as one single-part `ur:` string, lowercase (the loggable form). */
8
+ toString(): string;
9
+ /** The single-part wire form, uppercase (QR alphanumeric mode). */
10
+ toWireString(): string;
11
+ }
12
+ //#endregion
13
+ //#region src/core/rand.d.ts
14
+ type RandomBytesFn = (length: number) => Uint8Array;
15
+ //#endregion
16
+ //#region src/qr/animated-ur.d.ts
17
+ interface AnimatedUrOptions {
18
+ /**
19
+ * Payload bytes per fountain fragment. The on-wire frame adds a ~16-byte
20
+ * CBOR header, so the default 180 keeps frames within the ~200-byte
21
+ * per-fragment ceiling hardware-wallet cameras scan reliably. Larger
22
+ * fragments mean fewer frames but denser QR codes.
23
+ */
24
+ readonly maxFragmentLength?: number;
25
+ }
26
+ declare const DEFAULT_FRAGMENT_LENGTH = 180;
27
+ /**
28
+ * Frame source for rendering a UR as an animated QR.
29
+ *
30
+ * Drive `nextFrame()` from your own ticker (~8 fps is the battle-tested
31
+ * default) and hand each string to your QR component. Frames are UPPERCASE so
32
+ * the QR encoder can use alphanumeric mode (~45% denser than byte mode).
33
+ */
34
+ declare class AnimatedUr {
35
+ private readonly encoder;
36
+ constructor(ur: Ur, options?: AnimatedUrOptions);
37
+ /** Whether the payload fits one QR (no animation needed). */
38
+ get isSingleFrame(): boolean;
39
+ /** The UR registry type being sent, e.g. `eth-sign-request`. */
40
+ get urType(): string;
41
+ /** How many source fragments the payload was split into. */
42
+ get fragmentCount(): number;
43
+ /** Next wire frame (uppercase). Single-frame payloads return the same string every call. */
44
+ nextFrame(): string;
45
+ /** The whole request as ONE lowercase `ur:` string — the loggable form, not what is on screen. */
46
+ toString(): string;
47
+ }
48
+ //#endregion
49
+ //#region src/core/errors.d.ts
50
+ /**
51
+ * Closed set of error codes the SDK can produce. Integrators branch on
52
+ * `code`, never on message text — messages are for humans and may change.
53
+ */
54
+ type EraErrorCode =
55
+ /** No CSPRNG available: neither `globalThis.crypto.getRandomValues` nor an injected `randomBytes`. */
56
+ 'no-secure-random' |
57
+ /** The scanned text is not a `ur:` string at all. */
58
+ 'not-a-ur' |
59
+ /** A UR of a type this operation does not accept. */
60
+ 'wrong-ur-type' |
61
+ /** Bytewords body malformed (unknown letter pair, too short). */
62
+ 'malformed-bytewords' |
63
+ /** Bytewords or reassembly CRC32 does not match. */
64
+ 'checksum-mismatch' |
65
+ /** CBOR payload malformed or outside the hardened decoder's policy. */
66
+ 'malformed-cbor' |
67
+ /** The `<seq>` path segment of a multi-part UR is unreadable. */
68
+ 'malformed-sequence' |
69
+ /** A fragment that does not belong to the stream being assembled. */
70
+ 'fragment-mismatch' |
71
+ /** A size/count cap was exceeded (fragment count, message size, inflate ceiling). */
72
+ 'limit-exceeded' |
73
+ /** `result()`/`parse()` called before the scan completed. */
74
+ 'incomplete-scan' |
75
+ /** The reply echoes a different request id — it answers another sign request. */
76
+ 'request-id-mismatch' |
77
+ /** The linked wallet carries no account for the requested path. */
78
+ 'account-not-found' |
79
+ /** Invalid request properties (bad path string, chainId over the device's 32-bit ceiling, ...). */
80
+ 'invalid-props' |
81
+ /** The device refused to sign (e.g. a Bitcoin message for a non-legacy address). */
82
+ 'empty-signature' |
83
+ /** Reply CBOR/protobuf decoded but its shape is not the expected reply. */
84
+ 'malformed-reply' |
85
+ /** gzip payload malformed, truncated, or a decompression bomb. */
86
+ 'gzip-error' |
87
+ /** Protobuf payload malformed. */
88
+ 'protobuf-error' |
89
+ /** A verification helper found a mismatch between request and reply. */
90
+ 'verification-failed';
91
+ /** Every error thrown by this SDK. `code` is stable API; `message` is not. */
92
+ declare class EraSdkError extends Error {
93
+ readonly code: EraErrorCode;
94
+ readonly details?: Record<string, unknown>;
95
+ constructor(code: EraErrorCode, message: string, details?: Record<string, unknown>);
96
+ }
97
+ //#endregion
98
+ //#region src/scan/ur-scanner.d.ts
99
+ interface UrScannerOptions {
100
+ /**
101
+ * Pin: frames of any other UR type are rejected BEFORE the fountain decoder
102
+ * sees them. The decoder commits to a stream once one binds, so a frame that
103
+ * gets that far has a say in what the rest of the session may look like —
104
+ * pinning is the cheap half of the hostile-QR cure (the decoder's
105
+ * two-fragment binding rule is the other half).
106
+ */
107
+ readonly expectedTypes?: readonly string[];
108
+ }
109
+ interface ScanRejection {
110
+ readonly code: EraErrorCode;
111
+ readonly message: string;
112
+ /**
113
+ * Consecutive occurrences of this same rejection. A static hostile or
114
+ * malformed QR produces the identical rejection at camera framerate; this
115
+ * counter lets a UI or a log show it once instead of ~10 times per second.
116
+ */
117
+ readonly repeated: number;
118
+ }
119
+ type ScanFeedResult = {
120
+ readonly kind: 'progress';
121
+ readonly progress: number;
122
+ readonly framesReceived: number;
123
+ readonly framesExpected: number;
124
+ } | {
125
+ readonly kind: 'duplicate';
126
+ } | {
127
+ readonly kind: 'rejected';
128
+ readonly rejection: ScanRejection;
129
+ } | {
130
+ readonly kind: 'complete';
131
+ readonly ur: Ur;
132
+ };
133
+ /**
134
+ * Accumulates camera frames into a UR. Synchronous and non-throwing on the
135
+ * feed path (safe to call from camera callbacks); malformed frames come back
136
+ * as typed rejections, never exceptions.
137
+ */
138
+ declare class UrScanner {
139
+ private readonly decoder;
140
+ private readonly expectedTypes;
141
+ private readonly seen;
142
+ private rejection;
143
+ /** Distinct frames remembered for dedup. Attacker-suppliable strings, so capped. */
144
+ private static readonly maxRememberedFrames;
145
+ constructor(options?: UrScannerOptions);
146
+ get isComplete(): boolean;
147
+ get progress(): number;
148
+ /** The UR type of the bound stream, or null until one binds. */
149
+ get urType(): string | null;
150
+ get framesReceived(): number;
151
+ get framesExpected(): number;
152
+ get lastRejection(): ScanRejection | null;
153
+ /** Feed one scanned frame. */
154
+ receivePart(frame: string): ScanFeedResult;
155
+ /** The assembled UR. Throws `incomplete-scan` until done. */
156
+ result(): Ur;
157
+ private reject;
158
+ }
159
+ /** A scanner whose completed UR parses into a typed result (a chain signature). */
160
+ declare class TypedUrScanner<TResult> extends UrScanner {
161
+ private readonly parseResult;
162
+ constructor(options: UrScannerOptions, parseResult: (ur: Ur) => TResult);
163
+ /** Assemble + parse + validate (UR type, request-id echo) in one call. */
164
+ parse(): TResult;
165
+ }
166
+ //#endregion
167
+ //#region src/chains/shared.d.ts
168
+ /** Resolved SDK configuration handed to every chain module. */
169
+ interface ChainContext {
170
+ readonly origin: string;
171
+ readonly randomBytes: RandomBytesFn | undefined;
172
+ readonly maxFragmentLength: number;
173
+ }
174
+ /** SDK configuration. Everything is optional; the SDK performs NO network I/O ever. */
175
+ interface EraConnectConfig {
176
+ /**
177
+ * Wallet name the device shows the user on every request ("Sign for
178
+ * <origin>?"). Set it once here; individual requests can override.
179
+ */
180
+ readonly origin?: string | undefined;
181
+ /**
182
+ * CSPRNG override. By default `globalThis.crypto.getRandomValues` is used;
183
+ * on React Native install `react-native-get-random-values`, or inject a
184
+ * secure source here. Request-id minting throws `no-secure-random` when
185
+ * neither is available.
186
+ */
187
+ readonly randomBytes?: RandomBytesFn | undefined;
188
+ /** Default payload bytes per animated-QR fragment (180 unless overridden). */
189
+ readonly maxFragmentLength?: number | undefined;
190
+ }
191
+ declare const DEFAULT_ORIGIN = "ERA Connect";
192
+ /** Optional expectations when parsing a reply standalone (outside `SignRequest.scanner()`). */
193
+ interface ExpectedReply {
194
+ readonly requestId?: Uint8Array | string;
195
+ }
196
+ /**
197
+ * A built sign request: the UR to display plus everything needed to consume
198
+ * the reply. The request id is minted at CONSTRUCTION so the same object that
199
+ * renders the QR also validates the echo — a reply carrying a different id
200
+ * (from an earlier, cancelled flow re-presented to the camera) is refused
201
+ * instead of accepted.
202
+ */
203
+ interface SignRequest<TResult> {
204
+ readonly ur: Ur;
205
+ /** Absent only where the protocol has no request id (Bitcoin PSBT). */
206
+ readonly requestId: Uint8Array | undefined;
207
+ /** UR types that can answer THIS request. */
208
+ readonly replyTypes: readonly string[];
209
+ /** Non-fatal advisories (e.g. `blind-sign-threshold`). */
210
+ readonly warnings: readonly string[];
211
+ /** Fragment + animate for display. */
212
+ toAnimated(options?: AnimatedUrOptions): AnimatedUr;
213
+ /** A scanner pre-pinned to `replyTypes`; its `parse()` validates the request-id echo. */
214
+ scanner(): TypedUrScanner<TResult>;
215
+ }
216
+ //#endregion
217
+ export { Ur as _, SignRequest as a, TypedUrScanner as c, EraErrorCode as d, EraSdkError as f, RandomBytesFn as g, DEFAULT_FRAGMENT_LENGTH as h, ExpectedReply as i, UrScanner as l, AnimatedUrOptions as m, DEFAULT_ORIGIN as n, ScanFeedResult as o, AnimatedUr as p, EraConnectConfig as r, ScanRejection as s, ChainContext as t, UrScannerOptions as u };
218
+ //# sourceMappingURL=shared-CI8zhQiE.d.ts.map