@initia/initia.js 0.2.31 → 1.0.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.
@@ -1,456 +0,0 @@
1
- import T from "semver";
2
- const U = {}, C = {}, x = (t, r) => {
3
- C[t] = r;
4
- }, e = (t) => {
5
- class r extends Error {
6
- constructor(n, o, s) {
7
- if (super(n || t, s), Object.setPrototypeOf(this, r.prototype), this.name = t, o)
8
- for (const i in o)
9
- this[i] = o[i];
10
- if (s && f(s) && "cause" in s && !("cause" in this)) {
11
- const i = s.cause;
12
- this.cause = i, "stack" in i && (this.stack = this.stack + `
13
- CAUSE: ` + i.stack);
14
- }
15
- }
16
- }
17
- return U[t] = r, r;
18
- };
19
- function f(t) {
20
- return typeof t == "object";
21
- }
22
- e("AccountNameRequired");
23
- e("AccountNotSupported");
24
- e("AccountAwaitingSendPendingOperations");
25
- e("AmountRequired");
26
- e("BluetoothRequired");
27
- e("BtcUnmatchedApp");
28
- e("CantOpenDevice");
29
- e("CashAddrNotSupported");
30
- e("ClaimRewardsFeesWarning");
31
- e("CurrencyNotSupported");
32
- e("DeviceAppVerifyNotSupported");
33
- e("DeviceGenuineSocketEarlyClose");
34
- e("DeviceNotGenuine");
35
- e("DeviceOnDashboardExpected");
36
- e("DeviceOnDashboardUnexpected");
37
- e("DeviceInOSUExpected");
38
- e("DeviceHalted");
39
- e("DeviceNameInvalid");
40
- e("DeviceSocketFail");
41
- e("DeviceSocketNoBulkStatus");
42
- e("DeviceSocketNoBulkStatus");
43
- e("UnresponsiveDeviceError");
44
- const M = e("DisconnectedDevice"), F = e("DisconnectedDeviceDuringOperation");
45
- e("DeviceExtractOnboardingStateError");
46
- e("DeviceOnboardingStatePollingError");
47
- e("EnpointConfig");
48
- e("EthAppPleaseEnableContractData");
49
- e("FeeEstimationFailed");
50
- e("FirmwareNotRecognized");
51
- e("HardResetFail");
52
- e("InvalidXRPTag");
53
- e("InvalidAddress");
54
- e("InvalidNonce");
55
- e("InvalidAddressBecauseDestinationIsAlsoSource");
56
- e("LatestMCUInstalledError");
57
- e("UnknownMCU");
58
- e("LedgerAPIError");
59
- e("LedgerAPIErrorWithMessage");
60
- e("LedgerAPINotAvailable");
61
- e("ManagerAppAlreadyInstalled");
62
- e("ManagerAppRelyOnBTC");
63
- e("ManagerAppDepInstallRequired");
64
- e("ManagerAppDepUninstallRequired");
65
- e("ManagerDeviceLocked");
66
- e("ManagerFirmwareNotEnoughSpace");
67
- e("ManagerNotEnoughSpace");
68
- e("ManagerUninstallBTCDep");
69
- e("NetworkDown");
70
- e("NetworkError");
71
- e("NoAddressesFound");
72
- e("NotEnoughBalance");
73
- e("NotEnoughBalanceSwap");
74
- e("NotEnoughBalanceToDelegate");
75
- e("NotEnoughBalanceInParentAccount");
76
- e("NotEnoughSpendableBalance");
77
- e("NotEnoughBalanceBecauseDestinationNotCreated");
78
- e("NoAccessToCamera");
79
- e("NotEnoughGas");
80
- e("NotEnoughGasSwap");
81
- e("TronEmptyAccount");
82
- e("MaybeKeepTronAccountAlive");
83
- e("NotSupportedLegacyAddress");
84
- e("GasLessThanEstimate");
85
- e("PriorityFeeTooLow");
86
- e("PriorityFeeTooHigh");
87
- e("PriorityFeeHigherThanMaxFee");
88
- e("MaxFeeTooLow");
89
- e("PasswordsDontMatch");
90
- e("PasswordIncorrect");
91
- e("RecommendSubAccountsToEmpty");
92
- e("RecommendUndelegation");
93
- e("TimeoutTagged");
94
- e("UnexpectedBootloader");
95
- e("MCUNotGenuineToDashboard");
96
- e("RecipientRequired");
97
- e("UnavailableTezosOriginatedAccountReceive");
98
- e("UnavailableTezosOriginatedAccountSend");
99
- e("UpdateFetchFileFail");
100
- e("UpdateIncorrectHash");
101
- e("UpdateIncorrectSig");
102
- e("UpdateYourApp");
103
- e("UserRefusedDeviceNameChange");
104
- e("UserRefusedAddress");
105
- e("UserRefusedFirmwareUpdate");
106
- e("UserRefusedAllowManager");
107
- e("UserRefusedOnDevice");
108
- e("PinNotSet");
109
- e("ExpertModeRequired");
110
- const w = e("TransportOpenUserCancelled"), y = e("TransportInterfaceNotAvailable");
111
- e("TransportRaceCondition");
112
- const k = e("TransportWebUSBGestureRequired");
113
- e("TransactionHasBeenValidatedError");
114
- e("TransportExchangeTimeoutError");
115
- e("DeviceShouldStayInApp");
116
- e("WebsocketConnectionError");
117
- e("WebsocketConnectionFailed");
118
- e("WrongDeviceForAccount");
119
- e("WrongDeviceForAccountPayout");
120
- e("WrongDeviceForAccountRefund");
121
- e("WrongAppForCurrency");
122
- e("ETHAddressNonEIP");
123
- e("CantScanQRCode");
124
- e("FeeNotLoaded");
125
- e("FeeNotLoadedSwap");
126
- e("FeeRequired");
127
- e("FeeTooHigh");
128
- e("PendingOperation");
129
- e("SyncError");
130
- e("PairingFailed");
131
- e("PeerRemovedPairing");
132
- e("GenuineCheckFailed");
133
- e("LedgerAPI4xx");
134
- e("LedgerAPI5xx");
135
- e("FirmwareOrAppUpdateRequired");
136
- e("ReplacementTransactionUnderpriced");
137
- e("OpReturnSizeLimit");
138
- e("DustLimit");
139
- e("LanguageNotFound");
140
- e("NoDBPathGiven");
141
- e("DBWrongPassword");
142
- e("DBNotReset");
143
- e("SequenceNumberError");
144
- e("DisabledTransactionBroadcastError");
145
- var A;
146
- (function(t) {
147
- t.Unknown = "Unknown", t.LocationServicesDisabled = "LocationServicesDisabled", t.LocationServicesUnauthorized = "LocationServicesUnauthorized", t.BluetoothScanStartFailed = "BluetoothScanStartFailed";
148
- })(A || (A = {}));
149
- class E extends Error {
150
- constructor(r, a) {
151
- const n = "TransportError";
152
- super(r || n), this.name = n, this.message = r, this.stack = new Error(r).stack, this.id = a;
153
- }
154
- }
155
- x("TransportError", (t) => new E(t.message, t.id));
156
- const I = {
157
- ACCESS_CONDITION_NOT_FULFILLED: 38916,
158
- ALGORITHM_NOT_SUPPORTED: 38020,
159
- CLA_NOT_SUPPORTED: 28160,
160
- CODE_BLOCKED: 38976,
161
- CODE_NOT_INITIALIZED: 38914,
162
- COMMAND_INCOMPATIBLE_FILE_STRUCTURE: 27009,
163
- CONDITIONS_OF_USE_NOT_SATISFIED: 27013,
164
- CONTRADICTION_INVALIDATION: 38928,
165
- CONTRADICTION_SECRET_CODE_STATUS: 38920,
166
- DEVICE_IN_RECOVERY_MODE: 26159,
167
- CUSTOM_IMAGE_EMPTY: 26158,
168
- FILE_ALREADY_EXISTS: 27273,
169
- FILE_NOT_FOUND: 37892,
170
- GP_AUTH_FAILED: 25344,
171
- HALTED: 28586,
172
- INCONSISTENT_FILE: 37896,
173
- INCORRECT_DATA: 27264,
174
- INCORRECT_LENGTH: 26368,
175
- INCORRECT_P1_P2: 27392,
176
- INS_NOT_SUPPORTED: 27904,
177
- DEVICE_NOT_ONBOARDED: 27911,
178
- DEVICE_NOT_ONBOARDED_2: 26129,
179
- INVALID_KCV: 38021,
180
- INVALID_OFFSET: 37890,
181
- LICENSING: 28482,
182
- LOCKED_DEVICE: 21781,
183
- MAX_VALUE_REACHED: 38992,
184
- MEMORY_PROBLEM: 37440,
185
- MISSING_CRITICAL_PARAMETER: 26624,
186
- NO_EF_SELECTED: 37888,
187
- NOT_ENOUGH_MEMORY_SPACE: 27268,
188
- OK: 36864,
189
- PIN_REMAINING_ATTEMPTS: 25536,
190
- REFERENCED_DATA_NOT_FOUND: 27272,
191
- SECURITY_STATUS_NOT_SATISFIED: 27010,
192
- TECHNICAL_PROBLEM: 28416,
193
- UNKNOWN_APDU: 27906,
194
- USER_REFUSED_ON_DEVICE: 21761,
195
- NOT_ENOUGH_SPACE: 20738,
196
- APP_NOT_FOUND_OR_INVALID_CONTEXT: 20771,
197
- INVALID_APP_NAME_LENGTH: 26378,
198
- GEN_AES_KEY_FAILED: 21529,
199
- INTERNAL_CRYPTO_OPERATION_FAILED: 21530,
200
- INTERNAL_COMPUTE_AES_CMAC_FAILED: 21531,
201
- ENCRYPT_APP_STORAGE_FAILED: 21532,
202
- INVALID_BACKUP_STATE: 26178,
203
- PIN_NOT_SET: 21762,
204
- INVALID_BACKUP_LENGTH: 26419,
205
- INVALID_RESTORE_STATE: 26179,
206
- INVALID_CHUNK_LENGTH: 26420,
207
- INVALID_BACKUP_HEADER: 26698,
208
- // Not documented:
209
- TRUSTCHAIN_WRONG_SEED: 45063
210
- };
211
- function h(t) {
212
- switch (t) {
213
- case 26368:
214
- return "Incorrect length";
215
- case 26624:
216
- return "Missing critical parameter";
217
- case 27010:
218
- return "Security not satisfied (dongle locked or have invalid access rights)";
219
- case 27013:
220
- return "Condition of use not satisfied (denied by the user?)";
221
- case 27264:
222
- return "Invalid data received";
223
- case 27392:
224
- return "Invalid parameter received";
225
- case 21781:
226
- return "Locked device";
227
- }
228
- if (28416 <= t && t <= 28671)
229
- return "Internal error, please report";
230
- }
231
- class N extends Error {
232
- /**
233
- * @param statusCode The error status code coming from a Transport implementation
234
- * @param options containing:
235
- * - canBeMappedToChildError: enable the mapping of TransportStatusError to an error extending/inheriting from it
236
- * . Ex: LockedDeviceError. Default to true.
237
- */
238
- constructor(r, { canBeMappedToChildError: a = !0 } = {}) {
239
- const n = Object.keys(I).find((d) => I[d] === r) || "UNKNOWN_ERROR", o = h(r) || n, s = r.toString(16), i = `Ledger device: ${o} (0x${s})`;
240
- if (super(i), this.name = "TransportStatusError", this.statusCode = r, this.statusText = n, Object.setPrototypeOf(this, N.prototype), a && r === I.LOCKED_DEVICE)
241
- return new p(i);
242
- }
243
- }
244
- class p extends N {
245
- constructor(r) {
246
- super(I.LOCKED_DEVICE, { canBeMappedToChildError: !1 }), r && (this.message = r), this.name = "LockedDeviceError", Object.setPrototypeOf(this, p.prototype);
247
- }
248
- }
249
- x("TransportStatusError", (t) => new N(t.statusCode));
250
- const _ = 5;
251
- function R(t) {
252
- const r = Buffer.alloc(2);
253
- return r.writeUInt16BE(t, 0), r;
254
- }
255
- const L = {
256
- data: Buffer.alloc(0),
257
- dataLength: 0,
258
- sequence: 0
259
- }, V = (t, r) => ({
260
- /**
261
- * Frames/encodes an APDU message into HID USB packets/frames
262
- *
263
- * @param apdu The APDU message to send, in a Buffer containing [cla, ins, p1, p2, data length, data(if not empty)]
264
- * @returns an array of HID USB frames ready to be sent
265
- */
266
- makeBlocks(a) {
267
- let n = Buffer.concat([R(a.length), a]);
268
- const o = r - 5, s = Math.ceil(n.length / o);
269
- n = Buffer.concat([n, Buffer.alloc(s * o - n.length + 1).fill(0)]);
270
- const i = [];
271
- for (let d = 0; d < s; d++) {
272
- const l = Buffer.alloc(5);
273
- l.writeUInt16BE(t, 0), l.writeUInt8(_, 2), l.writeUInt16BE(d, 3);
274
- const O = n.slice(d * o, (d + 1) * o);
275
- i.push(Buffer.concat([l, O]));
276
- }
277
- return i;
278
- },
279
- /**
280
- * Reduces HID USB packets/frames to one response.
281
- *
282
- * @param acc The value resulting from (accumulating) the previous call of reduceResponse.
283
- * On first call initialized to `initialAcc`. The accumulator enables handling multi-frames messages.
284
- * @param chunk Current chunk to reduce into accumulator
285
- * @returns An accumulator value updated with the current chunk
286
- */
287
- reduceResponse(a, n) {
288
- let { data: o, dataLength: s, sequence: i } = a || L;
289
- if (n.readUInt16BE(0) !== t)
290
- throw new E("Invalid channel", "InvalidChannel");
291
- if (n.readUInt8(2) !== _)
292
- throw new E("Invalid tag", "InvalidTag");
293
- if (n.readUInt16BE(3) !== i)
294
- throw new E("Invalid sequence", "InvalidSequence");
295
- a || (s = n.readUInt16BE(5)), i++;
296
- const d = n.slice(a ? 5 : 7);
297
- return o = Buffer.concat([o, d]), o.length > s && (o = o.slice(0, s)), {
298
- data: o,
299
- dataLength: s,
300
- sequence: i
301
- };
302
- },
303
- /**
304
- * Returns the response message that has been reduced from the HID USB frames
305
- *
306
- * @param acc The accumulator
307
- * @returns A Buffer containing the cleaned response message, or null if no response message, or undefined if the
308
- * accumulator is incorrect (message length is not valid)
309
- */
310
- getReducedResult(a) {
311
- if (a && a.dataLength === a.data.length)
312
- return a.data;
313
- }
314
- });
315
- var c;
316
- (function(t) {
317
- t.blue = "blue", t.nanoS = "nanoS", t.nanoSP = "nanoSP", t.nanoX = "nanoX", t.stax = "stax", t.europa = "europa";
318
- })(c || (c = {}));
319
- const S = {
320
- [c.blue]: {
321
- id: c.blue,
322
- productName: "Ledger Blue",
323
- productIdMM: 0,
324
- legacyUsbProductId: 0,
325
- usbOnly: !0,
326
- memorySize: 480 * 1024,
327
- masks: [822083584, 822149120],
328
- getBlockSize: (t) => 4 * 1024
329
- },
330
- [c.nanoS]: {
331
- id: c.nanoS,
332
- productName: "Ledger Nano S",
333
- productIdMM: 16,
334
- legacyUsbProductId: 1,
335
- usbOnly: !0,
336
- memorySize: 320 * 1024,
337
- masks: [823132160],
338
- getBlockSize: (t) => {
339
- var r;
340
- return T.lt((r = T.coerce(t)) !== null && r !== void 0 ? r : "", "2.0.0") ? 4 * 1024 : 2 * 1024;
341
- }
342
- },
343
- [c.nanoX]: {
344
- id: c.nanoX,
345
- productName: "Ledger Nano X",
346
- productIdMM: 64,
347
- legacyUsbProductId: 4,
348
- usbOnly: !1,
349
- memorySize: 2 * 1024 * 1024,
350
- masks: [855638016],
351
- getBlockSize: (t) => 4 * 1024,
352
- bluetoothSpec: [
353
- {
354
- serviceUuid: "13d63400-2c97-0004-0000-4c6564676572",
355
- notifyUuid: "13d63400-2c97-0004-0001-4c6564676572",
356
- writeUuid: "13d63400-2c97-0004-0002-4c6564676572",
357
- writeCmdUuid: "13d63400-2c97-0004-0003-4c6564676572"
358
- }
359
- ]
360
- },
361
- [c.nanoSP]: {
362
- id: c.nanoSP,
363
- productName: "Ledger Nano S Plus",
364
- productIdMM: 80,
365
- legacyUsbProductId: 5,
366
- usbOnly: !0,
367
- memorySize: 1533 * 1024,
368
- masks: [856686592],
369
- getBlockSize: (t) => 32
370
- },
371
- [c.stax]: {
372
- id: c.stax,
373
- productName: "Ledger Stax",
374
- productIdMM: 96,
375
- legacyUsbProductId: 6,
376
- usbOnly: !1,
377
- memorySize: 1533 * 1024,
378
- masks: [857735168],
379
- getBlockSize: (t) => 32,
380
- bluetoothSpec: [
381
- {
382
- serviceUuid: "13d63400-2c97-6004-0000-4c6564676572",
383
- notifyUuid: "13d63400-2c97-6004-0001-4c6564676572",
384
- writeUuid: "13d63400-2c97-6004-0002-4c6564676572",
385
- writeCmdUuid: "13d63400-2c97-6004-0003-4c6564676572"
386
- }
387
- ]
388
- },
389
- [c.europa]: {
390
- id: c.europa,
391
- productName: "Ledger Flex",
392
- productIdMM: 112,
393
- legacyUsbProductId: 7,
394
- usbOnly: !1,
395
- memorySize: 1533 * 1024,
396
- masks: [858783744],
397
- getBlockSize: (t) => 32,
398
- bluetoothSpec: [
399
- {
400
- serviceUuid: "13d63400-2c97-3004-0000-4c6564676572",
401
- notifyUuid: "13d63400-2c97-3004-0001-4c6564676572",
402
- writeUuid: "13d63400-2c97-3004-0002-4c6564676572",
403
- writeCmdUuid: "13d63400-2c97-3004-0003-4c6564676572"
404
- }
405
- ]
406
- }
407
- };
408
- c.blue, c.nanoS, c.nanoSP, c.nanoX, c.stax, c.europa;
409
- const D = Object.values(S), G = 11415, z = (t) => {
410
- const r = D.find((o) => o.legacyUsbProductId === t);
411
- if (r)
412
- return r;
413
- const a = t >> 8;
414
- return D.find((o) => o.productIdMM === a);
415
- }, v = [], g = {};
416
- for (const t in S) {
417
- const r = S[t], { bluetoothSpec: a } = r;
418
- if (a)
419
- for (let n = 0; n < a.length; n++) {
420
- const o = a[n];
421
- v.push(o.serviceUuid), g[o.serviceUuid] = g[o.serviceUuid.replace(/-/g, "")] = Object.assign({ deviceModel: r }, o);
422
- }
423
- }
424
- let P = 0;
425
- const u = [], H = (t, r, a) => {
426
- const n = {
427
- type: t,
428
- id: String(++P),
429
- date: /* @__PURE__ */ new Date()
430
- };
431
- r && (n.message = r), b(n);
432
- }, m = (t) => (u.push(t), () => {
433
- const r = u.indexOf(t);
434
- r !== -1 && (u[r] = u[u.length - 1], u.pop());
435
- });
436
- function b(t) {
437
- for (let r = 0; r < u.length; r++)
438
- try {
439
- u[r](t);
440
- } catch (a) {
441
- console.error(a);
442
- }
443
- }
444
- typeof window < "u" && (window.__ledgerLogsListen = m);
445
- export {
446
- F as D,
447
- w as T,
448
- E as a,
449
- G as b,
450
- V as c,
451
- M as d,
452
- y as e,
453
- k as f,
454
- z as i,
455
- H as l
456
- };
@@ -1,2 +0,0 @@
1
- "use strict";const T=require("semver"),U={},C={},x=(t,r)=>{C[t]=r},e=t=>{class r extends Error{constructor(n,o,s){if(super(n||t,s),Object.setPrototypeOf(this,r.prototype),this.name=t,o)for(const i in o)this[i]=o[i];if(s&&f(s)&&"cause"in s&&!("cause"in this)){const i=s.cause;this.cause=i,"stack"in i&&(this.stack=this.stack+`
2
- CAUSE: `+i.stack)}}}return U[t]=r,r};function f(t){return typeof t=="object"}e("AccountNameRequired");e("AccountNotSupported");e("AccountAwaitingSendPendingOperations");e("AmountRequired");e("BluetoothRequired");e("BtcUnmatchedApp");e("CantOpenDevice");e("CashAddrNotSupported");e("ClaimRewardsFeesWarning");e("CurrencyNotSupported");e("DeviceAppVerifyNotSupported");e("DeviceGenuineSocketEarlyClose");e("DeviceNotGenuine");e("DeviceOnDashboardExpected");e("DeviceOnDashboardUnexpected");e("DeviceInOSUExpected");e("DeviceHalted");e("DeviceNameInvalid");e("DeviceSocketFail");e("DeviceSocketNoBulkStatus");e("DeviceSocketNoBulkStatus");e("UnresponsiveDeviceError");const R=e("DisconnectedDevice"),h=e("DisconnectedDeviceDuringOperation");e("DeviceExtractOnboardingStateError");e("DeviceOnboardingStatePollingError");e("EnpointConfig");e("EthAppPleaseEnableContractData");e("FeeEstimationFailed");e("FirmwareNotRecognized");e("HardResetFail");e("InvalidXRPTag");e("InvalidAddress");e("InvalidNonce");e("InvalidAddressBecauseDestinationIsAlsoSource");e("LatestMCUInstalledError");e("UnknownMCU");e("LedgerAPIError");e("LedgerAPIErrorWithMessage");e("LedgerAPINotAvailable");e("ManagerAppAlreadyInstalled");e("ManagerAppRelyOnBTC");e("ManagerAppDepInstallRequired");e("ManagerAppDepUninstallRequired");e("ManagerDeviceLocked");e("ManagerFirmwareNotEnoughSpace");e("ManagerNotEnoughSpace");e("ManagerUninstallBTCDep");e("NetworkDown");e("NetworkError");e("NoAddressesFound");e("NotEnoughBalance");e("NotEnoughBalanceSwap");e("NotEnoughBalanceToDelegate");e("NotEnoughBalanceInParentAccount");e("NotEnoughSpendableBalance");e("NotEnoughBalanceBecauseDestinationNotCreated");e("NoAccessToCamera");e("NotEnoughGas");e("NotEnoughGasSwap");e("TronEmptyAccount");e("MaybeKeepTronAccountAlive");e("NotSupportedLegacyAddress");e("GasLessThanEstimate");e("PriorityFeeTooLow");e("PriorityFeeTooHigh");e("PriorityFeeHigherThanMaxFee");e("MaxFeeTooLow");e("PasswordsDontMatch");e("PasswordIncorrect");e("RecommendSubAccountsToEmpty");e("RecommendUndelegation");e("TimeoutTagged");e("UnexpectedBootloader");e("MCUNotGenuineToDashboard");e("RecipientRequired");e("UnavailableTezosOriginatedAccountReceive");e("UnavailableTezosOriginatedAccountSend");e("UpdateFetchFileFail");e("UpdateIncorrectHash");e("UpdateIncorrectSig");e("UpdateYourApp");e("UserRefusedDeviceNameChange");e("UserRefusedAddress");e("UserRefusedFirmwareUpdate");e("UserRefusedAllowManager");e("UserRefusedOnDevice");e("PinNotSet");e("ExpertModeRequired");const L=e("TransportOpenUserCancelled"),v=e("TransportInterfaceNotAvailable");e("TransportRaceCondition");const P=e("TransportWebUSBGestureRequired");e("TransactionHasBeenValidatedError");e("TransportExchangeTimeoutError");e("DeviceShouldStayInApp");e("WebsocketConnectionError");e("WebsocketConnectionFailed");e("WrongDeviceForAccount");e("WrongDeviceForAccountPayout");e("WrongDeviceForAccountRefund");e("WrongAppForCurrency");e("ETHAddressNonEIP");e("CantScanQRCode");e("FeeNotLoaded");e("FeeNotLoadedSwap");e("FeeRequired");e("FeeTooHigh");e("PendingOperation");e("SyncError");e("PairingFailed");e("PeerRemovedPairing");e("GenuineCheckFailed");e("LedgerAPI4xx");e("LedgerAPI5xx");e("FirmwareOrAppUpdateRequired");e("ReplacementTransactionUnderpriced");e("OpReturnSizeLimit");e("DustLimit");e("LanguageNotFound");e("NoDBPathGiven");e("DBWrongPassword");e("DBNotReset");e("SequenceNumberError");e("DisabledTransactionBroadcastError");var A;(function(t){t.Unknown="Unknown",t.LocationServicesDisabled="LocationServicesDisabled",t.LocationServicesUnauthorized="LocationServicesUnauthorized",t.BluetoothScanStartFailed="BluetoothScanStartFailed"})(A||(A={}));class l extends Error{constructor(r,a){const n="TransportError";super(r||n),this.name=n,this.message=r,this.stack=new Error(r).stack,this.id=a}}x("TransportError",t=>new l(t.message,t.id));const I={ACCESS_CONDITION_NOT_FULFILLED:38916,ALGORITHM_NOT_SUPPORTED:38020,CLA_NOT_SUPPORTED:28160,CODE_BLOCKED:38976,CODE_NOT_INITIALIZED:38914,COMMAND_INCOMPATIBLE_FILE_STRUCTURE:27009,CONDITIONS_OF_USE_NOT_SATISFIED:27013,CONTRADICTION_INVALIDATION:38928,CONTRADICTION_SECRET_CODE_STATUS:38920,DEVICE_IN_RECOVERY_MODE:26159,CUSTOM_IMAGE_EMPTY:26158,FILE_ALREADY_EXISTS:27273,FILE_NOT_FOUND:37892,GP_AUTH_FAILED:25344,HALTED:28586,INCONSISTENT_FILE:37896,INCORRECT_DATA:27264,INCORRECT_LENGTH:26368,INCORRECT_P1_P2:27392,INS_NOT_SUPPORTED:27904,DEVICE_NOT_ONBOARDED:27911,DEVICE_NOT_ONBOARDED_2:26129,INVALID_KCV:38021,INVALID_OFFSET:37890,LICENSING:28482,LOCKED_DEVICE:21781,MAX_VALUE_REACHED:38992,MEMORY_PROBLEM:37440,MISSING_CRITICAL_PARAMETER:26624,NO_EF_SELECTED:37888,NOT_ENOUGH_MEMORY_SPACE:27268,OK:36864,PIN_REMAINING_ATTEMPTS:25536,REFERENCED_DATA_NOT_FOUND:27272,SECURITY_STATUS_NOT_SATISFIED:27010,TECHNICAL_PROBLEM:28416,UNKNOWN_APDU:27906,USER_REFUSED_ON_DEVICE:21761,NOT_ENOUGH_SPACE:20738,APP_NOT_FOUND_OR_INVALID_CONTEXT:20771,INVALID_APP_NAME_LENGTH:26378,GEN_AES_KEY_FAILED:21529,INTERNAL_CRYPTO_OPERATION_FAILED:21530,INTERNAL_COMPUTE_AES_CMAC_FAILED:21531,ENCRYPT_APP_STORAGE_FAILED:21532,INVALID_BACKUP_STATE:26178,PIN_NOT_SET:21762,INVALID_BACKUP_LENGTH:26419,INVALID_RESTORE_STATE:26179,INVALID_CHUNK_LENGTH:26420,INVALID_BACKUP_HEADER:26698,TRUSTCHAIN_WRONG_SEED:45063};function m(t){switch(t){case 26368:return"Incorrect length";case 26624:return"Missing critical parameter";case 27010:return"Security not satisfied (dongle locked or have invalid access rights)";case 27013:return"Condition of use not satisfied (denied by the user?)";case 27264:return"Invalid data received";case 27392:return"Invalid parameter received";case 21781:return"Locked device"}if(28416<=t&&t<=28671)return"Internal error, please report"}class N extends Error{constructor(r,{canBeMappedToChildError:a=!0}={}){const n=Object.keys(I).find(d=>I[d]===r)||"UNKNOWN_ERROR",o=m(r)||n,s=r.toString(16),i=`Ledger device: ${o} (0x${s})`;if(super(i),this.name="TransportStatusError",this.statusCode=r,this.statusText=n,Object.setPrototypeOf(this,N.prototype),a&&r===I.LOCKED_DEVICE)return new p(i)}}class p extends N{constructor(r){super(I.LOCKED_DEVICE,{canBeMappedToChildError:!1}),r&&(this.message=r),this.name="LockedDeviceError",Object.setPrototypeOf(this,p.prototype)}}x("TransportStatusError",t=>new N(t.statusCode));const D=5;function b(t){const r=Buffer.alloc(2);return r.writeUInt16BE(t,0),r}const B={data:Buffer.alloc(0),dataLength:0,sequence:0},M=(t,r)=>({makeBlocks(a){let n=Buffer.concat([b(a.length),a]);const o=r-5,s=Math.ceil(n.length/o);n=Buffer.concat([n,Buffer.alloc(s*o-n.length+1).fill(0)]);const i=[];for(let d=0;d<s;d++){const E=Buffer.alloc(5);E.writeUInt16BE(t,0),E.writeUInt8(D,2),E.writeUInt16BE(d,3);const O=n.slice(d*o,(d+1)*o);i.push(Buffer.concat([E,O]))}return i},reduceResponse(a,n){let{data:o,dataLength:s,sequence:i}=a||B;if(n.readUInt16BE(0)!==t)throw new l("Invalid channel","InvalidChannel");if(n.readUInt8(2)!==D)throw new l("Invalid tag","InvalidTag");if(n.readUInt16BE(3)!==i)throw new l("Invalid sequence","InvalidSequence");a||(s=n.readUInt16BE(5)),i++;const d=n.slice(a?5:7);return o=Buffer.concat([o,d]),o.length>s&&(o=o.slice(0,s)),{data:o,dataLength:s,sequence:i}},getReducedResult(a){if(a&&a.dataLength===a.data.length)return a.data}});var c;(function(t){t.blue="blue",t.nanoS="nanoS",t.nanoSP="nanoSP",t.nanoX="nanoX",t.stax="stax",t.europa="europa"})(c||(c={}));const S={[c.blue]:{id:c.blue,productName:"Ledger Blue",productIdMM:0,legacyUsbProductId:0,usbOnly:!0,memorySize:480*1024,masks:[822083584,822149120],getBlockSize:t=>4*1024},[c.nanoS]:{id:c.nanoS,productName:"Ledger Nano S",productIdMM:16,legacyUsbProductId:1,usbOnly:!0,memorySize:320*1024,masks:[823132160],getBlockSize:t=>{var r;return T.lt((r=T.coerce(t))!==null&&r!==void 0?r:"","2.0.0")?4*1024:2*1024}},[c.nanoX]:{id:c.nanoX,productName:"Ledger Nano X",productIdMM:64,legacyUsbProductId:4,usbOnly:!1,memorySize:2*1024*1024,masks:[855638016],getBlockSize:t=>4*1024,bluetoothSpec:[{serviceUuid:"13d63400-2c97-0004-0000-4c6564676572",notifyUuid:"13d63400-2c97-0004-0001-4c6564676572",writeUuid:"13d63400-2c97-0004-0002-4c6564676572",writeCmdUuid:"13d63400-2c97-0004-0003-4c6564676572"}]},[c.nanoSP]:{id:c.nanoSP,productName:"Ledger Nano S Plus",productIdMM:80,legacyUsbProductId:5,usbOnly:!0,memorySize:1533*1024,masks:[856686592],getBlockSize:t=>32},[c.stax]:{id:c.stax,productName:"Ledger Stax",productIdMM:96,legacyUsbProductId:6,usbOnly:!1,memorySize:1533*1024,masks:[857735168],getBlockSize:t=>32,bluetoothSpec:[{serviceUuid:"13d63400-2c97-6004-0000-4c6564676572",notifyUuid:"13d63400-2c97-6004-0001-4c6564676572",writeUuid:"13d63400-2c97-6004-0002-4c6564676572",writeCmdUuid:"13d63400-2c97-6004-0003-4c6564676572"}]},[c.europa]:{id:c.europa,productName:"Ledger Flex",productIdMM:112,legacyUsbProductId:7,usbOnly:!1,memorySize:1533*1024,masks:[858783744],getBlockSize:t=>32,bluetoothSpec:[{serviceUuid:"13d63400-2c97-3004-0000-4c6564676572",notifyUuid:"13d63400-2c97-3004-0001-4c6564676572",writeUuid:"13d63400-2c97-3004-0002-4c6564676572",writeCmdUuid:"13d63400-2c97-3004-0003-4c6564676572"}]}};c.blue,c.nanoS,c.nanoSP,c.nanoX,c.stax,c.europa;const g=Object.values(S),F=11415,y=t=>{const r=g.find(o=>o.legacyUsbProductId===t);if(r)return r;const a=t>>8;return g.find(o=>o.productIdMM===a)},w=[],_={};for(const t in S){const r=S[t],{bluetoothSpec:a}=r;if(a)for(let n=0;n<a.length;n++){const o=a[n];w.push(o.serviceUuid),_[o.serviceUuid]=_[o.serviceUuid.replace(/-/g,"")]=Object.assign({deviceModel:r},o)}}let k=0;const u=[],V=(t,r,a)=>{const n={type:t,id:String(++k),date:new Date};r&&(n.message=r),H(n)},G=t=>(u.push(t),()=>{const r=u.indexOf(t);r!==-1&&(u[r]=u[u.length-1],u.pop())});function H(t){for(let r=0;r<u.length;r++)try{u[r](t)}catch(a){console.error(a)}}typeof window<"u"&&(window.__ledgerLogsListen=G);exports.DisconnectedDevice=R;exports.DisconnectedDeviceDuringOperation=h;exports.TransportError=l;exports.TransportInterfaceNotAvailable=v;exports.TransportOpenUserCancelled=L;exports.TransportWebUSBGestureRequired=P;exports.createHIDframing=M;exports.identifyUSBProductId=y;exports.ledgerUSBVendorId=F;exports.log=V;