@onekeyfe/hwk-adapter-core 1.2.6-alpha.0 → 1.2.6-alpha.1

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 (37) hide show
  1. package/dist/{chunk-H7BZ2C6J.js → chunk-BAGEFFFY.js} +13 -45
  2. package/dist/chunk-BAGEFFFY.js.map +1 -0
  3. package/dist/{chunk-T5HIQPNG.js → chunk-SZZF623R.js} +55 -155
  4. package/dist/chunk-SZZF623R.js.map +1 -0
  5. package/dist/{chunk-AYA6FQES.mjs → chunk-U63HTLGJ.mjs} +12 -44
  6. package/dist/chunk-U63HTLGJ.mjs.map +1 -0
  7. package/dist/{chunk-KTRQZ5AJ.mjs → chunk-YA4BWFTZ.mjs} +55 -155
  8. package/dist/chunk-YA4BWFTZ.mjs.map +1 -0
  9. package/dist/errors.d.mts +207 -1
  10. package/dist/errors.d.ts +207 -1
  11. package/dist/errors.js +2 -8
  12. package/dist/errors.js.map +1 -1
  13. package/dist/errors.mjs +3 -9
  14. package/dist/index.d.mts +104 -583
  15. package/dist/index.d.ts +104 -583
  16. package/dist/index.js +85 -642
  17. package/dist/index.js.map +1 -1
  18. package/dist/index.mjs +76 -633
  19. package/dist/index.mjs.map +1 -1
  20. package/dist/{ui-events-DdttFKj9.d.ts → ui-events-Cb7haAeE.d.mts} +3 -37
  21. package/dist/{ui-events-DdttFKj9.d.mts → ui-events-Cb7haAeE.d.ts} +3 -37
  22. package/dist/ui-events.d.mts +1 -1
  23. package/dist/ui-events.d.ts +1 -1
  24. package/dist/ui-events.js +2 -3
  25. package/dist/ui-events.js.map +1 -1
  26. package/dist/ui-events.mjs +1 -2
  27. package/package.json +2 -2
  28. package/dist/chunk-AYA6FQES.mjs.map +0 -1
  29. package/dist/chunk-DB4JOPZO.mjs +0 -74
  30. package/dist/chunk-DB4JOPZO.mjs.map +0 -1
  31. package/dist/chunk-H7BZ2C6J.js.map +0 -1
  32. package/dist/chunk-KTRQZ5AJ.mjs.map +0 -1
  33. package/dist/chunk-T5HIQPNG.js.map +0 -1
  34. package/dist/chunk-YLCHSNXO.js +0 -74
  35. package/dist/chunk-YLCHSNXO.js.map +0 -1
  36. package/dist/errors-BgJ4kzRx.d.mts +0 -276
  37. package/dist/errors-BgJ4kzRx.d.ts +0 -276
package/dist/index.js CHANGED
@@ -1,48 +1,31 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
- var _chunkYLCHSNXOjs = require('./chunk-YLCHSNXO.js');
4
3
 
5
4
 
6
5
 
6
+ var _chunkSZZF623Rjs = require('./chunk-SZZF623R.js');
7
7
 
8
8
 
9
9
 
10
10
 
11
11
 
12
12
 
13
- var _chunkH7BZ2C6Jjs = require('./chunk-H7BZ2C6J.js');
14
13
 
15
14
 
16
15
 
17
-
18
-
19
-
20
-
21
-
22
- var _chunkT5HIQPNGjs = require('./chunk-T5HIQPNG.js');
16
+ var _chunkBAGEFFFYjs = require('./chunk-BAGEFFFY.js');
23
17
 
24
18
  // src/types/response.ts
25
19
  function success(payload) {
26
20
  return { success: true, payload };
27
21
  }
28
- function failure(code, error, params, origin, recovery) {
22
+ function failure(code, error, params) {
29
23
  return {
30
24
  success: false,
31
- payload: {
32
- error,
33
- code,
34
- ...origin !== void 0 ? { origin } : {},
35
- recovery: _nullishCoalesce(recovery, () => ( _chunkT5HIQPNGjs.defaultRecoveryForCode.call(void 0, code))),
36
- ...params ? { params } : {}
37
- }
25
+ payload: { error, code, ...params ? { params } : {} }
38
26
  };
39
27
  }
40
28
 
41
- // src/types/device.ts
42
- function resolveSearchTargetReusePolicy(device) {
43
- return _optionalChain([device, 'access', _ => _.capabilities, 'optionalAccess', _2 => _2.persistentDeviceIdentity]) ? "reconnectable" : "current-discovery";
44
- }
45
-
46
29
  // src/types/fingerprint.ts
47
30
  var _sha256 = require('@noble/hashes/sha256');
48
31
  var _utils = require('@noble/hashes/utils');
@@ -52,26 +35,11 @@ var CHAIN_FINGERPRINT_PATHS = {
52
35
  // Cointype 1 (testnet) is rejected by some Ledger BTC App configurations.
53
36
  btc: "m/44'/0'/0'",
54
37
  sol: "m/44'/501'/0'",
55
- tron: "m/44'/195'/0'/0/0",
56
- // Shielded UA (single Orchard receiver) derived from the transparent path.
57
- zcash: "m/44'/133'/0'/0/0"
38
+ tron: "m/44'/195'/0'/0/0"
58
39
  };
59
- function parseBip32MasterFingerprint(value) {
60
- if (typeof value !== "string") return void 0;
61
- const normalized = value.trim().toLowerCase();
62
- return /^[0-9a-f]{8}$/.test(normalized) ? normalized : void 0;
63
- }
64
- var MISSING_BIP32_MASTER_FINGERPRINT = "00000000";
65
- function parseWalletMasterFingerprint(value) {
66
- const fingerprint = parseBip32MasterFingerprint(value);
67
- return fingerprint === MISSING_BIP32_MASTER_FINGERPRINT ? void 0 : fingerprint;
68
- }
69
40
  function deriveDeviceFingerprint(value) {
70
41
  return _utils.bytesToHex.call(void 0, _sha256.sha256.call(void 0, _utils.utf8ToBytes.call(void 0, value))).slice(0, 16);
71
42
  }
72
- function deriveWalletId(canonicalPublicMaterial) {
73
- return _utils.bytesToHex.call(void 0, _sha256.sha256.call(void 0, _utils.utf8ToBytes.call(void 0, `onekey-hwk-wallet-id:v1:${canonicalPublicMaterial}`)));
74
- }
75
43
 
76
44
  // src/events/device.ts
77
45
  var DEVICE_EVENT = "DEVICE_EVENT";
@@ -98,8 +66,7 @@ var SDK = {
98
66
  DEVICE_STUCK: "device-stuck",
99
67
  DEVICE_UNRESPONSIVE: "device-unresponsive",
100
68
  DEVICE_RECOVERED: "device-recovered",
101
- DEVICE_INTERACTION: "device-interaction",
102
- OPERATION_ENDED: "operation-ended"
69
+ DEVICE_INTERACTION: "device-interaction"
103
70
  };
104
71
 
105
72
  // src/utils/DeviceJobQueue.ts
@@ -108,7 +75,6 @@ var DeviceJobQueue = class {
108
75
  this._tail = Promise.resolve();
109
76
  this._active = null;
110
77
  this._jobs = /* @__PURE__ */ new Map();
111
- this._cancelScopes = /* @__PURE__ */ new Map();
112
78
  /** Incremented on clear() so queued-but-not-yet-running jobs detect invalidation. */
113
79
  this._generation = 0;
114
80
  this._generationCancelReasons = /* @__PURE__ */ new Map();
@@ -131,13 +97,12 @@ var DeviceJobQueue = class {
131
97
  abortController: ac,
132
98
  startedAt: Date.now()
133
99
  };
134
- this._jobs.set(jobToken, activeJob);
100
+ this._jobs.set(jobToken, { deviceId });
135
101
  const next = prev.catch(() => {
136
102
  }).then(async () => {
137
103
  if (this._generation !== gen) {
138
104
  throw _nullishCoalesce(this._generationCancelReasons.get(gen), () => ( new Error("Job cancelled: queue was cleared")));
139
105
  }
140
- if (ac.signal.aborted) throw ac.signal.reason;
141
106
  this._active = activeJob;
142
107
  try {
143
108
  return await job(ac.signal);
@@ -153,52 +118,32 @@ var DeviceJobQueue = class {
153
118
  });
154
119
  return next;
155
120
  }
156
- /**
157
- * Holds a cancel across the gaps between a bundle's per-item jobs, when the queue is empty.
158
- * Callers must `release()` when the bundle ends.
159
- */
160
- createCancelScope(deviceId) {
161
- const scopeToken = {};
162
- const abortController = new AbortController();
163
- this._cancelScopes.set(scopeToken, { deviceId, abortController });
164
- return {
165
- signal: abortController.signal,
166
- release: () => {
167
- this._cancelScopes.delete(scopeToken);
168
- }
169
- };
121
+ /** Cancel the active job. If `deviceId` is given, only cancels when it matches. */
122
+ cancelActive(deviceId) {
123
+ if (!this._active) return false;
124
+ if (deviceId && this._active.deviceId !== deviceId) return false;
125
+ this._active.abortController.abort(new Error("Manually cancelled"));
126
+ return true;
170
127
  }
171
- /**
172
- * Cancels the running job only; `reason` becomes signal.reason. Adapters use
173
- * `cancelActiveAndPending`; this stays for a connector layer that stops only what is on the wire.
174
- */
175
- cancelActive(deviceId, reason) {
128
+ /** Force cancel the active job. `reason` becomes signal.reason. */
129
+ forceCancelActive(deviceId, reason) {
176
130
  if (!this._active) return false;
177
131
  if (deviceId && this._active.deviceId !== deviceId) return false;
178
- this._active.abortController.abort(_nullishCoalesce(reason, () => ( new Error("Cancelled"))));
132
+ this._active.abortController.abort(_nullishCoalesce(reason, () => ( new Error("Force cancelled for recovery"))));
179
133
  return true;
180
134
  }
181
- /**
182
- * Cancels the active job and unstarted queued jobs; returns whether anything was reached. Only
183
- * `undefined` means everything: an empty key matches nothing instead of tearing the queue down.
184
- */
135
+ /** Cancel the active job (alias for callers that previously needed multi-device cancel). */
136
+ cancelAllActive(reason) {
137
+ if (!this._active) return;
138
+ this._active.abortController.abort(_nullishCoalesce(reason, () => ( new Error("Cancelled by cancelAllActive"))));
139
+ }
140
+ /** Cancel the active job and invalidate queued jobs that have not started. */
185
141
  cancelActiveAndPending(deviceId, reason) {
186
- const cancelReason = _nullishCoalesce(reason, () => ( new Error("Cancelled by cancelActiveAndPending")));
187
- if (deviceId !== void 0) {
188
- let cancelled = false;
189
- const targets = [this._jobs, this._cancelScopes];
190
- for (const map of targets) {
191
- for (const target of map.values()) {
192
- if (target.deviceId !== deviceId) continue;
193
- target.abortController.abort(cancelReason);
194
- cancelled = true;
195
- }
196
- }
197
- return cancelled;
142
+ if (deviceId && this._active && this._active.deviceId !== deviceId) {
143
+ return false;
198
144
  }
199
- const reached = this._active !== null || this._jobs.size > 0 || this._cancelScopes.size > 0;
200
- this.clear(cancelReason);
201
- return reached;
145
+ this.clear(_nullishCoalesce(reason, () => ( new Error("Cancelled by cancelActiveAndPending"))));
146
+ return true;
202
147
  }
203
148
  /** Get info about the currently active job, or null if idle. */
204
149
  getActiveJob(deviceId) {
@@ -210,6 +155,10 @@ var DeviceJobQueue = class {
210
155
  startedAt: this._active.startedAt
211
156
  };
212
157
  }
158
+ /** True if any job is currently running. */
159
+ isBusy() {
160
+ return this._jobs.size > 0;
161
+ }
213
162
  clear(reason) {
214
163
  const cancelledGeneration = this._generation;
215
164
  this._generation++;
@@ -223,219 +172,9 @@ var DeviceJobQueue = class {
223
172
  if (this._active) {
224
173
  this._active.abortController.abort(cancelReason);
225
174
  }
226
- for (const scope of this._cancelScopes.values()) {
227
- scope.abortController.abort(cancelReason);
228
- }
229
175
  }
230
176
  };
231
177
 
232
- // src/utils/hardwareRuntimeId.ts
233
-
234
- var HARDWARE_RUNTIME_ID_PREFIX = "hwk:runtime";
235
- var RANDOM_ID_BYTES = 16;
236
- var RANDOM_ID_PATTERN = /^[0-9a-f]{32}$/;
237
- var KINDS = /* @__PURE__ */ new Set([
238
- "operation",
239
- "search-target",
240
- "link"
241
- ]);
242
- var VENDORS = /* @__PURE__ */ new Set(["trezor", "ledger", "keystone"]);
243
- function create(kind, vendor) {
244
- return `${HARDWARE_RUNTIME_ID_PREFIX}:${kind}:${vendor}:${_utils.bytesToHex.call(void 0,
245
- _utils.randomBytes.call(void 0, RANDOM_ID_BYTES)
246
- )}`;
247
- }
248
- function createHardwareOperationId(vendor) {
249
- return create("operation", vendor);
250
- }
251
- function createHardwareSearchTargetId(vendor) {
252
- return create("search-target", vendor);
253
- }
254
- function createHardwareLinkId(vendor) {
255
- return create("link", vendor);
256
- }
257
- function hasHardwareRuntimeIdPrefix(value) {
258
- return typeof value === "string" && value.startsWith(`${HARDWARE_RUNTIME_ID_PREFIX}:`);
259
- }
260
- function parseHardwareRuntimeId(value) {
261
- if (!hasHardwareRuntimeIdPrefix(value)) return void 0;
262
- const parts = value.split(":");
263
- if (parts.length !== 5) return void 0;
264
- const [, , kind, vendor, nonce] = parts;
265
- if (!KINDS.has(kind) || !VENDORS.has(vendor) || !RANDOM_ID_PATTERN.test(nonce)) {
266
- return void 0;
267
- }
268
- return { kind, vendor };
269
- }
270
- function isHardwareOperationId(value) {
271
- return _optionalChain([parseHardwareRuntimeId, 'call', _3 => _3(value), 'optionalAccess', _4 => _4.kind]) === "operation";
272
- }
273
-
274
- // src/utils/OperationRegistry.ts
275
- var OPERATION_DEFAULT_TTL_MS = 6e5;
276
- var uniqueKeys = (keys) => Array.from(new Set(keys.filter(Boolean)));
277
- var OperationRegistry = class {
278
- constructor(options) {
279
- this._active = /* @__PURE__ */ new Map();
280
- this._ended = /* @__PURE__ */ new Map();
281
- this._vendor = options.vendor;
282
- this._ttlMs = _nullishCoalesce(options.ttlMs, () => ( OPERATION_DEFAULT_TTL_MS));
283
- this._onEnded = options.onEnded;
284
- }
285
- create(params) {
286
- const now = Date.now();
287
- const operationId = createHardwareOperationId(this._vendor);
288
- const operation = {
289
- operationId,
290
- connectId: params.connectId,
291
- device: params.device,
292
- connectionType: params.connectionType,
293
- connectionKeys: uniqueKeys([
294
- params.searchTargetId,
295
- params.connectId,
296
- ..._nullishCoalesce(params.connectionKeys, () => ( []))
297
- ]),
298
- createdAt: now,
299
- lastActiveAt: now
300
- };
301
- const timer = this._createTimer(operationId);
302
- this._active.set(operationId, { ...operation, timer, retainCount: 0 });
303
- return operation;
304
- }
305
- resolve(operationId) {
306
- const active = this._active.get(operationId);
307
- if (!active) {
308
- const ended = this._ended.get(operationId);
309
- if (ended) {
310
- throw _chunkT5HIQPNGjs.createHwkError.call(void 0, {
311
- code: 10113 /* OperationEnded */,
312
- message: `Hardware operation has ended (${ended.reason})`,
313
- params: { operationId, reason: ended.reason }
314
- });
315
- }
316
- throw _chunkT5HIQPNGjs.createHwkError.call(void 0, {
317
- code: 10112 /* OperationNotFound */,
318
- message: "Hardware operation was not found",
319
- params: { operationId }
320
- });
321
- }
322
- this._touch(active);
323
- return active;
324
- }
325
- /** Keep an operation alive while one device job is actively using it. */
326
- retain(operationId) {
327
- const active = this.resolve(operationId);
328
- active.retainCount += 1;
329
- this._touch(active);
330
- let released = false;
331
- return () => {
332
- if (released) return;
333
- released = true;
334
- const current = this._active.get(operationId);
335
- if (!current) return;
336
- current.retainCount = Math.max(0, current.retainCount - 1);
337
- this._touch(current);
338
- };
339
- }
340
- /** Return active or tombstoned binding data without refreshing its TTL. */
341
- find(operationId) {
342
- return _nullishCoalesce(this._active.get(operationId), () => ( _optionalChain([this, 'access', _5 => _5._ended, 'access', _6 => _6.get, 'call', _7 => _7(operationId), 'optionalAccess', _8 => _8.operation])));
343
- }
344
- findActiveByConnectionKey(connectionKey) {
345
- if (!connectionKey) return void 0;
346
- return [...this._active.values()].find(
347
- (operation) => operation.connectionKeys.includes(connectionKey)
348
- );
349
- }
350
- /** Replace the live transport binding after the same target was reconnected. */
351
- rebind(operationId, params) {
352
- const active = this.resolve(operationId);
353
- active.connectId = params.connectId;
354
- active.device = params.device;
355
- active.connectionType = params.connectionType;
356
- active.connectionKeys = uniqueKeys([params.connectId, ..._nullishCoalesce(params.connectionKeys, () => ( []))]);
357
- this._touch(active);
358
- return active;
359
- }
360
- end(operationId, reason) {
361
- const active = this._active.get(operationId);
362
- if (!active) return void 0;
363
- if (active.timer) clearTimeout(active.timer);
364
- this._active.delete(operationId);
365
- this._rememberEnded(active, reason);
366
- _optionalChain([this, 'access', _9 => _9._onEnded, 'optionalCall', _10 => _10(active, reason)]);
367
- return active;
368
- }
369
- endByConnectionKey(connectionKey, reason, exceptOperationId) {
370
- if (!connectionKey) return;
371
- for (const operation of [...this._active.values()]) {
372
- if (operation.operationId === exceptOperationId) continue;
373
- if (operation.connectionKeys.includes(connectionKey)) {
374
- this.end(operation.operationId, reason);
375
- }
376
- }
377
- }
378
- endAll(reason, exceptOperationId) {
379
- for (const operationId of [...this._active.keys()]) {
380
- if (operationId === exceptOperationId) continue;
381
- this.end(operationId, reason);
382
- }
383
- }
384
- _touch(active) {
385
- if (active.timer) clearTimeout(active.timer);
386
- active.lastActiveAt = Date.now();
387
- active.timer = active.retainCount === 0 ? this._createTimer(active.operationId) : void 0;
388
- }
389
- _createTimer(operationId) {
390
- const timer = setTimeout(() => {
391
- this.end(operationId, "timeout");
392
- }, this._ttlMs);
393
- _optionalChain([timer, 'access', _11 => _11.unref, 'optionalCall', _12 => _12()]);
394
- return timer;
395
- }
396
- _rememberEnded(operation, reason) {
397
- this._ended.set(operation.operationId, { reason, operation });
398
- if (this._ended.size <= 100) return;
399
- const oldest = this._ended.keys().next().value;
400
- if (oldest) this._ended.delete(oldest);
401
- }
402
- };
403
-
404
- // src/utils/hardwareOperationTarget.ts
405
- function resolveHardwareOperationTarget(positionalTargetId, commonOperationId, expectedVendor) {
406
- const targetId = _nullishCoalesce(positionalTargetId, () => ( void 0));
407
- const commonId = commonOperationId || void 0;
408
- const parsedTarget = parseHardwareRuntimeId(targetId);
409
- const parsedCommon = parseHardwareRuntimeId(commonId);
410
- const positionalOperationId = _optionalChain([parsedTarget, 'optionalAccess', _13 => _13.kind]) === "operation" ? targetId : void 0;
411
- if (hasHardwareRuntimeIdPrefix(targetId) && !parsedTarget) {
412
- return failure(10002 /* InvalidParams */, "Invalid hardware operation target id");
413
- }
414
- if (_optionalChain([parsedTarget, 'optionalAccess', _14 => _14.kind]) === "link") {
415
- return failure(
416
- 10002 /* InvalidParams */,
417
- "Hardware transport link id cannot be used as an operation target"
418
- );
419
- }
420
- if (commonId && _optionalChain([parsedCommon, 'optionalAccess', _15 => _15.kind]) !== "operation") {
421
- return failure(10002 /* InvalidParams */, "Invalid hardware operation id");
422
- }
423
- if (expectedVendor && [parsedTarget, parsedCommon].some((parsed) => parsed && parsed.vendor !== expectedVendor)) {
424
- return failure(
425
- 10002 /* InvalidParams */,
426
- `Hardware operation does not belong to ${expectedVendor}`
427
- );
428
- }
429
- if (positionalOperationId && commonId && positionalOperationId !== commonId) {
430
- return failure(10002 /* InvalidParams */, "Conflicting hardware operation ids", {
431
- positionalOperationId,
432
- commonOperationId: commonId
433
- });
434
- }
435
- const operationId = _nullishCoalesce(commonId, () => ( positionalOperationId));
436
- return success({ operationId, targetId: _nullishCoalesce(operationId, () => ( targetId)) });
437
- }
438
-
439
178
  // src/types/connector.ts
440
179
  var EConnectorInteraction = /* @__PURE__ */ ((EConnectorInteraction2) => {
441
180
  EConnectorInteraction2["Searching"] = "searching";
@@ -451,7 +190,7 @@ function createBridgedConnector(vendor, connectionType, bridge) {
451
190
  return {
452
191
  connectionType,
453
192
  searchDevices: (options) => bridge.searchDevices({ vendor, options }),
454
- connect: (deviceId, options) => bridge.connect({ vendor, deviceId, ...options ? { options } : {} }),
193
+ connect: (deviceId) => bridge.connect({ vendor, deviceId }),
455
194
  disconnect: (sessionId) => bridge.disconnect({ vendor, sessionId }),
456
195
  call: (sessionId, method, callParams) => bridge.call({ vendor, sessionId, method, callParams }),
457
196
  cancel: (sessionId) => bridge.cancel({ vendor, sessionId }),
@@ -472,14 +211,14 @@ function createBridgedConnector(vendor, connectionType, bridge) {
472
211
  },
473
212
  off: (event, handler) => {
474
213
  const inner = handlerMap.get(event);
475
- const bridgeHandler = _optionalChain([inner, 'optionalAccess', _16 => _16.get, 'call', _17 => _17(handler)]);
214
+ const bridgeHandler = _optionalChain([inner, 'optionalAccess', _ => _.get, 'call', _2 => _2(handler)]);
476
215
  if (!bridgeHandler || !inner) return;
477
216
  bridge.offEvent({ vendor }, bridgeHandler);
478
217
  inner.delete(handler);
479
218
  if (inner.size === 0) handlerMap.delete(event);
480
219
  },
481
220
  reset: () => bridge.reset({ vendor }),
482
- configure: bridge.configure ? (config) => _optionalChain([bridge, 'access', _18 => _18.configure, 'optionalCall', _19 => _19({ vendor, config })]) : void 0,
221
+ configure: bridge.configure ? (config) => _optionalChain([bridge, 'access', _3 => _3.configure, 'optionalCall', _4 => _4({ vendor, config })]) : void 0,
483
222
  setKnownCredentials: bridge.setKnownCredentials ? (credentials) => bridge.setKnownCredentials({ vendor, credentials }) : void 0
484
223
  };
485
224
  }
@@ -548,13 +287,13 @@ function isDeviceUnavailableError(error) {
548
287
  return false;
549
288
  }
550
289
  function combinedDeviceNotFoundError(message) {
551
- return _chunkT5HIQPNGjs.createHwkError.call(void 0, {
290
+ return _chunkSZZF623Rjs.createHwkError.call(void 0, {
552
291
  code: 10100 /* DeviceNotFound */,
553
292
  message
554
293
  });
555
294
  }
556
295
  function combinedSessionNotFoundError(message) {
557
- return _chunkT5HIQPNGjs.createHwkError.call(void 0, {
296
+ return _chunkSZZF623Rjs.createHwkError.call(void 0, {
558
297
  code: 10101 /* DeviceDisconnected */,
559
298
  message
560
299
  });
@@ -583,7 +322,7 @@ function createCombinedConnector(connectors) {
583
322
  };
584
323
  const broadcastCredentials = async () => {
585
324
  await Promise.all(
586
- connectors.map((child) => Promise.resolve(_optionalChain([child, 'access', _20 => _20.setKnownCredentials, 'optionalCall', _21 => _21(sharedCredentials)])))
325
+ connectors.map((child) => Promise.resolve(_optionalChain([child, 'access', _5 => _5.setKnownCredentials, 'optionalCall', _6 => _6(sharedCredentials)])))
587
326
  );
588
327
  };
589
328
  for (const child of connectors) {
@@ -591,14 +330,11 @@ function createCombinedConnector(connectors) {
591
330
  if (mergeShared(data.credentials)) void broadcastCredentials();
592
331
  });
593
332
  }
594
- const onTransport = (child, transportType) => !transportType || child.connectionType === transportType;
595
333
  const searchDevices = async (options = {}) => {
596
- const selectedConnectors = connectors.map((child, index) => ({ child, index })).filter(({ child }) => onTransport(child, options.transportType));
597
- if (!selectedConnectors.length) return [];
598
334
  const perConnector = [];
599
- await new Promise((resolve, reject) => {
335
+ await new Promise((resolve) => {
600
336
  let finished = false;
601
- let remaining = selectedConnectors.length;
337
+ let remaining = connectors.length;
602
338
  let settleTimer;
603
339
  const finish = () => {
604
340
  if (finished) return;
@@ -606,20 +342,19 @@ function createCombinedConnector(connectors) {
606
342
  if (settleTimer) clearTimeout(settleTimer);
607
343
  resolve();
608
344
  };
609
- selectedConnectors.forEach(({ child, index }) => {
610
- void child.searchDevices(options.purpose ? { purpose: options.purpose } : void 0).then(
345
+ connectors.forEach((child, index) => {
346
+ void child.searchDevices().then(
611
347
  (devices) => devices.map((device) => ({
612
348
  ...device,
613
349
  connectionType: _nullishCoalesce(device.connectionType, () => ( child.connectionType))
614
350
  }))
615
- ).catch((error) => {
616
- if (options.transportType) {
617
- finished = true;
618
- if (settleTimer) clearTimeout(settleTimer);
619
- reject(error);
620
- }
621
- return [];
622
- }).then((devices) => {
351
+ ).catch(
352
+ () => (
353
+ // A transport that can't scan (powered off, unauthorized, absent)
354
+ // must not fail the whole fused search.
355
+ []
356
+ )
357
+ ).then((devices) => {
623
358
  remaining -= 1;
624
359
  if (!finished) {
625
360
  perConnector.push({ index, devices });
@@ -636,9 +371,7 @@ function createCombinedConnector(connectors) {
636
371
  });
637
372
  });
638
373
  perConnector.sort((a, b) => a.index - b.index);
639
- for (const [id, owner] of deviceOwner) {
640
- if (onTransport(owner, options.transportType)) deviceOwner.delete(id);
641
- }
374
+ deviceOwner.clear();
642
375
  const merged = [];
643
376
  perConnector.forEach(({ index, devices }) => {
644
377
  for (const device of devices) {
@@ -648,12 +381,11 @@ function createCombinedConnector(connectors) {
648
381
  });
649
382
  return merged.sort((a, b) => rank(a) - rank(b));
650
383
  };
651
- const resolveOwner = async (deviceId, transportType) => {
652
- const cachedOwner = deviceId ? deviceOwner.get(deviceId) : void 0;
653
- if (cachedOwner && onTransport(cachedOwner, transportType)) {
654
- return { owner: cachedOwner, deviceId };
384
+ const resolveOwner = async (deviceId) => {
385
+ if (deviceId && deviceOwner.has(deviceId)) {
386
+ return { owner: deviceOwner.get(deviceId), deviceId };
655
387
  }
656
- const devices = await searchDevices({ waitForAll: Boolean(deviceId), transportType });
388
+ const devices = await searchDevices({ waitForAll: Boolean(deviceId) });
657
389
  if (deviceId) {
658
390
  const owner = deviceOwner.get(deviceId);
659
391
  if (!owner)
@@ -664,14 +396,13 @@ function createCombinedConnector(connectors) {
664
396
  if (!first) throw combinedDeviceNotFoundError("Combined connector: no devices found");
665
397
  return { owner: deviceOwner.get(first.connectId), deviceId: first.connectId };
666
398
  };
667
- const connectByExplicitId = async (deviceId, transportType) => {
399
+ const connectByExplicitId = async (deviceId) => {
668
400
  const cachedOwner = deviceOwner.get(deviceId);
669
- if (cachedOwner && onTransport(cachedOwner, transportType)) {
401
+ if (cachedOwner) {
670
402
  return { session: await cachedOwner.connect(deviceId), owner: cachedOwner };
671
403
  }
672
404
  let lastError;
673
405
  for (const child of connectors) {
674
- if (!onTransport(child, transportType)) continue;
675
406
  try {
676
407
  const session = await child.connect(deviceId);
677
408
  deviceOwner.set(deviceId, child);
@@ -684,7 +415,7 @@ function createCombinedConnector(connectors) {
684
415
  }
685
416
  }
686
417
  const message = lastError instanceof Error ? lastError.message : `Combined connector: device not found: ${deviceId}`;
687
- throw _chunkT5HIQPNGjs.createHwkError.call(void 0, {
418
+ throw _chunkSZZF623Rjs.createHwkError.call(void 0, {
688
419
  code: 10100 /* DeviceNotFound */,
689
420
  message
690
421
  });
@@ -693,15 +424,14 @@ function createCombinedConnector(connectors) {
693
424
  // Nominal value only — the per-device `connectionType` is authoritative
694
425
  // for a fused connector.
695
426
  connectionType: connectors[0].connectionType,
696
- availableTransports: [...new Set(connectors.map((child) => child.connectionType))],
697
- searchDevices: (options) => searchDevices(options),
698
- connect: async (deviceId, options) => {
427
+ searchDevices: (options) => searchDevices({ waitForAll: _optionalChain([options, 'optionalAccess', _7 => _7.waitForAll]) }),
428
+ connect: async (deviceId) => {
699
429
  let owner;
700
430
  let session;
701
431
  if (deviceId) {
702
- ({ session, owner } = await connectByExplicitId(deviceId, _optionalChain([options, 'optionalAccess', _22 => _22.transportType])));
432
+ ({ session, owner } = await connectByExplicitId(deviceId));
703
433
  } else {
704
- const resolved = await resolveOwner(void 0, _optionalChain([options, 'optionalAccess', _23 => _23.transportType]));
434
+ const resolved = await resolveOwner();
705
435
  owner = resolved.owner;
706
436
  session = await owner.connect(resolved.deviceId);
707
437
  }
@@ -723,11 +453,8 @@ function createCombinedConnector(connectors) {
723
453
  },
724
454
  cancel: async (sessionId) => {
725
455
  const owner = sessionOwner.get(sessionId);
726
- if (owner) {
727
- await owner.cancel(sessionId);
728
- return;
729
- }
730
- await Promise.all(connectors.map((child) => child.cancel(sessionId)));
456
+ if (!owner) return;
457
+ await owner.cancel(sessionId);
731
458
  },
732
459
  uiResponse: (response) => {
733
460
  for (const child of connectors) child.uiResponse(response);
@@ -747,7 +474,7 @@ function createCombinedConnector(connectors) {
747
474
  },
748
475
  off: (event, handler) => {
749
476
  const inner = forwarders.get(event);
750
- const attached = _optionalChain([inner, 'optionalAccess', _24 => _24.get, 'call', _25 => _25(handler)]);
477
+ const attached = _optionalChain([inner, 'optionalAccess', _8 => _8.get, 'call', _9 => _9(handler)]);
751
478
  if (!attached || !inner) return;
752
479
  for (const { child, handler: forward } of attached) {
753
480
  child.off(event, forward);
@@ -762,7 +489,7 @@ function createCombinedConnector(connectors) {
762
489
  forwarders.clear();
763
490
  },
764
491
  configure: connectors.some((c) => c.configure) ? async (config) => {
765
- await Promise.all(connectors.map((child) => Promise.resolve(_optionalChain([child, 'access', _26 => _26.configure, 'optionalCall', _27 => _27(config)]))));
492
+ await Promise.all(connectors.map((child) => Promise.resolve(_optionalChain([child, 'access', _10 => _10.configure, 'optionalCall', _11 => _11(config)]))));
766
493
  deviceOwner.clear();
767
494
  sessionOwner.clear();
768
495
  } : void 0,
@@ -806,145 +533,10 @@ var TypedEventEmitter = class {
806
533
  }
807
534
  /** Number of listeners registered for `event`. 0 if none. */
808
535
  listenerCount(event) {
809
- return _nullishCoalesce(_optionalChain([this, 'access', _28 => _28._listeners, 'access', _29 => _29.get, 'call', _30 => _30(event), 'optionalAccess', _31 => _31.size]), () => ( 0));
536
+ return _nullishCoalesce(_optionalChain([this, 'access', _12 => _12._listeners, 'access', _13 => _13.get, 'call', _14 => _14(event), 'optionalAccess', _15 => _15.size]), () => ( 0));
810
537
  }
811
538
  };
812
539
 
813
- // src/utils/requestSaveDeviceBinding.ts
814
- async function requestSaveDeviceBinding(emitter, registry, binding, signal) {
815
- const type = _chunkH7BZ2C6Jjs.UI_REQUEST.REQUEST_SAVE_DEVICE_BINDING;
816
- const emitStatus = (status) => emitter.emit(_chunkH7BZ2C6Jjs.UI_REQUEST.DEVICE_BINDING_STATUS, {
817
- type: _chunkH7BZ2C6Jjs.UI_REQUEST.DEVICE_BINDING_STATUS,
818
- payload: { selectionRequestId: binding.selectionRequestId, status }
819
- });
820
- const declined = (reason) => {
821
- emitStatus("failed");
822
- return { saved: false, reason };
823
- };
824
- if (!emitter.listenerCount(type)) {
825
- return declined("skipped");
826
- }
827
- if (_optionalChain([signal, 'optionalAccess', _32 => _32.aborted])) throw signal.reason;
828
- const requestId = registry.createRequestId();
829
- const pending = registry.wait(type, { requestId, operationId: binding.operationId });
830
- void pending.catch(() => void 0);
831
- const cancel = () => registry.cancel(type, requestId);
832
- _optionalChain([signal, 'optionalAccess', _33 => _33.addEventListener, 'call', _34 => _34("abort", cancel, { once: true })]);
833
- try {
834
- emitter.emit(type, { type, payload: { ...binding, requestId } });
835
- const response = await pending;
836
- if (_optionalChain([signal, 'optionalAccess', _35 => _35.aborted])) throw signal.reason;
837
- if (_optionalChain([response, 'optionalAccess', _36 => _36.saved]) !== true) {
838
- return declined(_nullishCoalesce(_optionalChain([response, 'optionalAccess', _37 => _37.reason]), () => ( "skipped")));
839
- }
840
- emitStatus("saved");
841
- return { saved: true };
842
- } catch (error) {
843
- if (_optionalChain([signal, 'optionalAccess', _38 => _38.aborted])) {
844
- emitStatus("cancelled");
845
- throw error;
846
- }
847
- return declined("skipped");
848
- } finally {
849
- _optionalChain([signal, 'optionalAccess', _39 => _39.removeEventListener, 'call', _40 => _40("abort", cancel)]);
850
- registry.cancel(type, requestId);
851
- }
852
- }
853
-
854
- // src/utils/requestBleDeviceSelection.ts
855
- async function requestBleDeviceSelection({
856
- emitter,
857
- registry,
858
- request,
859
- scan,
860
- signal,
861
- allowUsbFallback = false,
862
- pollIntervalMs = 1500
863
- }) {
864
- const type = _chunkH7BZ2C6Jjs.UI_REQUEST.REQUEST_SELECT_DEVICE;
865
- if (signal.aborted) throw signal.reason;
866
- if (!emitter.listenerCount(type)) {
867
- throw _chunkT5HIQPNGjs.createHwkError.call(void 0, {
868
- code: 10100 /* DeviceNotFound */,
869
- message: "Select a Bluetooth device before continuing"
870
- });
871
- }
872
- const requestId = registry.createRequestId();
873
- const { operationId } = request;
874
- let devices = allowUsbFallback ? request.devices.filter((device) => device.connectionType === "ble") : request.devices;
875
- const publishedDevices = /* @__PURE__ */ new Map();
876
- let stopped = false;
877
- let timer;
878
- let wake;
879
- const stop = () => {
880
- stopped = true;
881
- if (timer !== void 0) clearTimeout(timer);
882
- _optionalChain([wake, 'optionalCall', _41 => _41()]);
883
- };
884
- const waitForNextScan = () => new Promise((resolve) => {
885
- wake = resolve;
886
- timer = setTimeout(resolve, pollIntervalMs);
887
- if (stopped) resolve();
888
- });
889
- const cancel = () => registry.cancel(type, requestId);
890
- const reply = registry.wait(type, { requestId, operationId }).finally(stop);
891
- void reply.catch(() => void 0);
892
- const publish = () => {
893
- for (const device of devices) publishedDevices.set(device.connectId, device);
894
- emitter.emit(type, {
895
- type,
896
- payload: { ...request, devices, requestId, scanning: true }
897
- });
898
- };
899
- signal.addEventListener("abort", cancel, { once: true });
900
- let polling;
901
- try {
902
- publish();
903
- polling = (async () => {
904
- await Promise.resolve();
905
- while (!stopped) {
906
- const snapshot = await scan();
907
- if (stopped || signal.aborted) return;
908
- const usbFallback = allowUsbFallback ? snapshot.find((device2) => device2.connectionType === "usb") : void 0;
909
- if (usbFallback) return usbFallback;
910
- devices = snapshot;
911
- publish();
912
- await waitForNextScan();
913
- }
914
- })();
915
- const userSelection = reply.then((selected) => publishedDevices.get(selected.sdkConnectId));
916
- const device = await Promise.race([
917
- userSelection,
918
- polling.then((usbFallback) => _nullishCoalesce(usbFallback, () => ( userSelection)))
919
- ]);
920
- stop();
921
- await polling;
922
- if (signal.aborted) throw signal.reason;
923
- if (!device) {
924
- throw _chunkT5HIQPNGjs.createHwkError.call(void 0, {
925
- code: 10100 /* DeviceNotFound */,
926
- message: "Selected Bluetooth device is no longer available"
927
- });
928
- }
929
- emitter.emit(_chunkH7BZ2C6Jjs.UI_REQUEST.DEVICE_BINDING_STATUS, {
930
- type: _chunkH7BZ2C6Jjs.UI_REQUEST.DEVICE_BINDING_STATUS,
931
- payload: { selectionRequestId: requestId, status: "verifying" }
932
- });
933
- return { device, requestId };
934
- } catch (error) {
935
- emitter.emit(_chunkH7BZ2C6Jjs.UI_REQUEST.DEVICE_BINDING_STATUS, {
936
- type: _chunkH7BZ2C6Jjs.UI_REQUEST.DEVICE_BINDING_STATUS,
937
- payload: { selectionRequestId: requestId, status: signal.aborted ? "cancelled" : "failed" }
938
- });
939
- throw error;
940
- } finally {
941
- stop();
942
- signal.removeEventListener("abort", cancel);
943
- registry.cancel(type, requestId);
944
- await _optionalChain([polling, 'optionalAccess', _42 => _42.catch, 'call', _43 => _43(() => void 0)]);
945
- }
946
- }
947
-
948
540
  // src/utils/semver.ts
949
541
  function compareSemver(a, b) {
950
542
  const pa = a.split(".").map(Number);
@@ -972,87 +564,15 @@ function padHex64(hex) {
972
564
  function hexToBytes(hex) {
973
565
  return _utils.hexToBytes.call(void 0, stripHex(hex));
974
566
  }
975
- function bytesToHex3(bytes) {
567
+ function bytesToHex2(bytes) {
976
568
  return _utils.bytesToHex.call(void 0, bytes);
977
569
  }
978
570
 
979
- // src/utils/solanaOffchainMessage.ts
980
- var SOLANA_OFFCHAIN_SIGNING_DOMAIN = Uint8Array.of(
981
- 255,
982
- ...Array.from("solana offchain", (character) => character.charCodeAt(0))
983
- );
984
- var SOLANA_PUBLIC_KEY_LENGTH = 32;
985
- var MAX_SOLANA_OFFCHAIN_SIGNERS = 255;
986
- function compareBytes(a, b) {
987
- for (let index = 0; index < a.length; index += 1) {
988
- const difference = (_nullishCoalesce(a[index], () => ( 0))) - (_nullishCoalesce(b[index], () => ( 0)));
989
- if (difference !== 0) return difference;
990
- }
991
- return a.length - b.length;
992
- }
993
- function bytesEqual(a, b) {
994
- return a.length === b.length && a.every((value, index) => value === b[index]);
995
- }
996
- function decodeUtf8Strict(bytes) {
997
- return decodeURIComponent(
998
- Array.from(bytes, (value) => `%${value.toString(16).padStart(2, "0")}`).join("")
999
- );
1000
- }
1001
- function prepareSolanaOffchainMessageV1({
1002
- message,
1003
- requiredSigners
1004
- }) {
1005
- if (message.length === 0) {
1006
- throw new Error("Solana off-chain message cannot be empty");
1007
- }
1008
- if (requiredSigners.length === 0 || requiredSigners.length > MAX_SOLANA_OFFCHAIN_SIGNERS) {
1009
- throw new Error("Solana off-chain message requires between 1 and 255 signers");
1010
- }
1011
- let messageText;
1012
- try {
1013
- messageText = decodeUtf8Strict(message);
1014
- } catch (e3) {
1015
- throw new Error("Solana off-chain message must contain valid UTF-8");
1016
- }
1017
- const signerBytes = requiredSigners.map((signer, index) => {
1018
- let bytes;
1019
- try {
1020
- bytes = hexToBytes(signer);
1021
- } catch (e4) {
1022
- throw new Error(`Solana off-chain signer ${index} must be a hex public key`);
1023
- }
1024
- if (bytes.length !== SOLANA_PUBLIC_KEY_LENGTH) {
1025
- throw new Error(`Solana off-chain signer ${index} must be 32 bytes`);
1026
- }
1027
- return bytes;
1028
- });
1029
- signerBytes.sort(compareBytes);
1030
- if (signerBytes.some((bytes, index) => index > 0 && bytesEqual(signerBytes[index - 1], bytes))) {
1031
- throw new Error("Solana off-chain signers must be unique");
1032
- }
1033
- const signersOffset = SOLANA_OFFCHAIN_SIGNING_DOMAIN.length + 2;
1034
- const messageOffset = signersOffset + signerBytes.length * SOLANA_PUBLIC_KEY_LENGTH;
1035
- const serializedMessage = new Uint8Array(messageOffset + message.length);
1036
- serializedMessage.set(SOLANA_OFFCHAIN_SIGNING_DOMAIN);
1037
- serializedMessage.set([1, signerBytes.length], SOLANA_OFFCHAIN_SIGNING_DOMAIN.length);
1038
- signerBytes.forEach(
1039
- (signer, index) => serializedMessage.set(signer, signersOffset + index * SOLANA_PUBLIC_KEY_LENGTH)
1040
- );
1041
- serializedMessage.set(message, messageOffset);
1042
- return {
1043
- messageText,
1044
- requiredSigners: signerBytes.map(bytesToHex3),
1045
- serializedMessage
1046
- };
1047
- }
1048
-
1049
571
  // src/utils/deviceIdentity.ts
1050
572
  var ONEKEY_BLE_SERVICE_UUID = "00000001-0000-1000-8000-00805f9b34fb";
1051
573
  var TREZOR_BLE_SERVICE_UUID = "8c000001-a59b-4d58-a9ad-073df69fa1b1";
1052
574
  var LEDGER_USB_VENDOR_ID = 11415;
1053
- var KEYSTONE_USB_VENDOR_ID = 4617;
1054
- var KEYSTONE_USB_PRODUCT_ID = 12289;
1055
- var lower = (value) => _nullishCoalesce(_optionalChain([value, 'optionalAccess', _44 => _44.trim, 'call', _45 => _45(), 'access', _46 => _46.toLowerCase, 'call', _47 => _47()]), () => ( ""));
575
+ var lower = (value) => _nullishCoalesce(_optionalChain([value, 'optionalAccess', _16 => _16.trim, 'call', _17 => _17(), 'access', _18 => _18.toLowerCase, 'call', _19 => _19()]), () => ( ""));
1056
576
  var hasServiceUuid = (input, uuid) => {
1057
577
  const expected = uuid.toLowerCase();
1058
578
  const values = [
@@ -1074,11 +594,6 @@ function detectHardwareVendorFromDescriptor(input) {
1074
594
  if (typeof input.vendor === "number" && input.vendor === LEDGER_USB_VENDOR_ID || input.vendorId === LEDGER_USB_VENDOR_ID || manufacturerName.includes("ledger")) {
1075
595
  return "ledger";
1076
596
  }
1077
- const usbVendorId = typeof input.vendor === "number" ? input.vendor : input.vendorId;
1078
- const usbProductId = typeof input.product === "number" ? input.product : input.productId;
1079
- if (usbVendorId === KEYSTONE_USB_VENDOR_ID && usbProductId === KEYSTONE_USB_PRODUCT_ID || manufacturerName.includes("keystone")) {
1080
- return "keystone";
1081
- }
1082
597
  return void 0;
1083
598
  }
1084
599
  function isKnownNonTargetHardwareVendor(input, targetVendor) {
@@ -1095,69 +610,35 @@ async function batchCall(params, callFn, onProgress) {
1095
610
  return result;
1096
611
  }
1097
612
  results.push(result.payload);
1098
- _optionalChain([onProgress, 'optionalCall', _48 => _48({ index: i, total: params.length })]);
613
+ _optionalChain([onProgress, 'optionalCall', _20 => _20({ index: i, total: params.length })]);
1099
614
  }
1100
615
  return { success: true, payload: results };
1101
616
  }
1102
617
 
1103
618
  // src/utils/methodCatalog.ts
1104
619
  var HARDWARE_METHOD_CATALOG = {
1105
- evmGetAddress: { chain: "evm", allNetwork: true, replayAfterTransportFailure: "safe" },
1106
- evmSignTransaction: {
1107
- chain: "evm",
1108
- allNetwork: false,
1109
- replayAfterTransportFailure: "unsafe"
1110
- },
1111
- evmSignMessage: { chain: "evm", allNetwork: false, replayAfterTransportFailure: "unsafe" },
1112
- evmSignTypedData: { chain: "evm", allNetwork: false, replayAfterTransportFailure: "unsafe" },
1113
- btcGetAddress: { chain: "btc", allNetwork: true, replayAfterTransportFailure: "safe" },
1114
- btcGetPublicKey: { chain: "btc", allNetwork: true, replayAfterTransportFailure: "safe" },
1115
- btcSignTransaction: {
1116
- chain: "btc",
1117
- allNetwork: false,
1118
- replayAfterTransportFailure: "unsafe"
1119
- },
1120
- btcSignPsbt: { chain: "btc", allNetwork: false, replayAfterTransportFailure: "unsafe" },
1121
- btcSignMessage: { chain: "btc", allNetwork: false, replayAfterTransportFailure: "unsafe" },
1122
- btcGetMasterFingerprint: {
1123
- chain: "btc",
1124
- allNetwork: false,
1125
- replayAfterTransportFailure: "safe"
1126
- },
1127
- solGetAddress: { chain: "sol", allNetwork: true, replayAfterTransportFailure: "safe" },
1128
- solSignTransaction: {
1129
- chain: "sol",
1130
- allNetwork: false,
1131
- replayAfterTransportFailure: "unsafe"
1132
- },
1133
- solSignMessage: { chain: "sol", allNetwork: false, replayAfterTransportFailure: "unsafe" },
1134
- tronGetAddress: { chain: "tron", allNetwork: true, replayAfterTransportFailure: "safe" },
1135
- tronSignTransaction: {
1136
- chain: "tron",
1137
- allNetwork: false,
1138
- replayAfterTransportFailure: "unsafe"
1139
- },
1140
- tronSignMessage: { chain: "tron", allNetwork: false, replayAfterTransportFailure: "unsafe" },
1141
- zcashGetFullViewingKey: {
1142
- chain: "zcash",
1143
- allNetwork: false,
1144
- replayAfterTransportFailure: "safe"
1145
- },
1146
- zcashGetShieldedAddress: {
1147
- chain: "zcash",
1148
- allNetwork: false,
1149
- replayAfterTransportFailure: "safe"
1150
- }
620
+ evmGetAddress: { chain: "evm", allNetwork: true },
621
+ evmSignTransaction: { chain: "evm", allNetwork: false },
622
+ evmSignMessage: { chain: "evm", allNetwork: false },
623
+ evmSignTypedData: { chain: "evm", allNetwork: false },
624
+ btcGetAddress: { chain: "btc", allNetwork: true },
625
+ btcGetPublicKey: { chain: "btc", allNetwork: true },
626
+ btcSignTransaction: { chain: "btc", allNetwork: false },
627
+ btcSignPsbt: { chain: "btc", allNetwork: false },
628
+ btcSignMessage: { chain: "btc", allNetwork: false },
629
+ btcGetMasterFingerprint: { chain: "btc", allNetwork: false },
630
+ solGetAddress: { chain: "sol", allNetwork: true },
631
+ solSignTransaction: { chain: "sol", allNetwork: false },
632
+ solSignMessage: { chain: "sol", allNetwork: false },
633
+ tronGetAddress: { chain: "tron", allNetwork: true },
634
+ tronSignTransaction: { chain: "tron", allNetwork: false },
635
+ tronSignMessage: { chain: "tron", allNetwork: false }
1151
636
  };
1152
637
  var ALL_NETWORK_METHOD_NAMES = Object.entries(HARDWARE_METHOD_CATALOG).filter(([, metadata]) => metadata.allNetwork).map(([method]) => method);
1153
638
  var ALL_NETWORK_METHOD_SET = new Set(ALL_NETWORK_METHOD_NAMES);
1154
639
  function getHardwareMethodMetadata(method) {
1155
640
  return HARDWARE_METHOD_CATALOG[method];
1156
641
  }
1157
- var SAFE_NON_CHAIN_METHODS = /* @__PURE__ */ new Set(["getFeatures", "authenticateDevice"]);
1158
- function canReplayHardwareMethodAfterTransportFailure(method) {
1159
- return _optionalChain([getHardwareMethodMetadata, 'call', _49 => _49(method), 'optionalAccess', _50 => _50.replayAfterTransportFailure]) === "safe" || SAFE_NON_CHAIN_METHODS.has(method);
1160
- }
1161
642
  function isAllNetworkMethodName(method) {
1162
643
  return ALL_NETWORK_METHOD_SET.has(method);
1163
644
  }
@@ -1185,7 +666,7 @@ async function runAllNetworkGetAddress({
1185
666
  continue;
1186
667
  }
1187
668
  const method = item.methodName;
1188
- const unsupportedNetwork = _optionalChain([buildUnsupportedNetworkResponse, 'optionalCall', _51 => _51(item, method)]);
669
+ const unsupportedNetwork = _optionalChain([buildUnsupportedNetworkResponse, 'optionalCall', _21 => _21(item, method)]);
1189
670
  if (unsupportedNetwork) {
1190
671
  responses.push(unsupportedNetwork);
1191
672
  continue;
@@ -1217,19 +698,6 @@ async function runAllNetworkGetAddress({
1217
698
  }
1218
699
  return success(responses);
1219
700
  }
1220
- function isUserRefusal(code) {
1221
- return code === 10005 /* UserAborted */ || code === 10001 /* UserRejected */ || code === 10401 /* PinCancelled */;
1222
- }
1223
- function isConnectionLost(code) {
1224
- const codes = [
1225
- 10101 /* DeviceDisconnected */,
1226
- 10003 /* OperationTimeout */,
1227
- 10300 /* TransportError */,
1228
- 10113 /* OperationEnded */,
1229
- 10112 /* OperationNotFound */
1230
- ];
1231
- return code !== void 0 && codes.includes(code);
1232
- }
1233
701
  function buildUnsupportedMethodResponse(item) {
1234
702
  return {
1235
703
  ...item,
@@ -1298,30 +766,5 @@ var DEVICE_CONNECT_RETRY_DELAY_MS = 1e3;
1298
766
 
1299
767
 
1300
768
 
1301
-
1302
-
1303
-
1304
-
1305
-
1306
-
1307
-
1308
-
1309
-
1310
-
1311
-
1312
-
1313
-
1314
-
1315
-
1316
-
1317
-
1318
-
1319
-
1320
-
1321
-
1322
-
1323
-
1324
-
1325
-
1326
- exports.ALL_NETWORK_METHOD_NAMES = ALL_NETWORK_METHOD_NAMES; exports.CHAIN_FINGERPRINT_PATHS = CHAIN_FINGERPRINT_PATHS; exports.DEVICE = DEVICE; exports.DEVICE_CONNECT_RETRY_DELAY_MS = DEVICE_CONNECT_RETRY_DELAY_MS; exports.DEVICE_EVENT = DEVICE_EVENT; exports.DeviceJobQueue = DeviceJobQueue; exports.EConnectorInteraction = EConnectorInteraction; exports.HARDWARE_METHOD_CATALOG = HARDWARE_METHOD_CATALOG; exports.HARDWARE_RUNTIME_ID_PREFIX = HARDWARE_RUNTIME_ID_PREFIX; exports.HardwareErrorCode = _chunkT5HIQPNGjs.HardwareErrorCode; exports.MISSING_BIP32_MASTER_FINGERPRINT = MISSING_BIP32_MASTER_FINGERPRINT; exports.OPERATION_DEFAULT_TTL_MS = OPERATION_DEFAULT_TTL_MS; exports.ORPHAN_ELIGIBLE_ERROR_CODES = _chunkT5HIQPNGjs.ORPHAN_ELIGIBLE_ERROR_CODES; exports.OperationRegistry = OperationRegistry; exports.SDK = SDK; exports.TypedEventEmitter = TypedEventEmitter; exports.UI_EVENT = _chunkH7BZ2C6Jjs.UI_EVENT; exports.UI_REQUEST = _chunkH7BZ2C6Jjs.UI_REQUEST; exports.UI_REQUEST_CANCELLED_TAG = _chunkH7BZ2C6Jjs.UI_REQUEST_CANCELLED_TAG; exports.UI_REQUEST_DEFAULT_TIMEOUT_MS = _chunkH7BZ2C6Jjs.UI_REQUEST_DEFAULT_TIMEOUT_MS; exports.UI_REQUEST_PREEMPTED_TAG = _chunkH7BZ2C6Jjs.UI_REQUEST_PREEMPTED_TAG; exports.UI_REQUEST_TIMEOUT_TAG = _chunkH7BZ2C6Jjs.UI_REQUEST_TIMEOUT_TAG; exports.UI_RESPONSE = _chunkH7BZ2C6Jjs.UI_RESPONSE; exports.UiRequestRegistry = _chunkH7BZ2C6Jjs.UiRequestRegistry; exports.batchCall = batchCall; exports.buildUnsupportedMethodResponse = buildUnsupportedMethodResponse; exports.bytesToHex = bytesToHex3; exports.canReplayHardwareMethodAfterTransportFailure = canReplayHardwareMethodAfterTransportFailure; exports.compareSemver = compareSemver; exports.createBridgedConnector = createBridgedConnector; exports.createCombinedConnector = createCombinedConnector; exports.createHardwareLinkId = createHardwareLinkId; exports.createHardwareOperationId = createHardwareOperationId; exports.createHardwareSearchTargetId = createHardwareSearchTargetId; exports.createHwkError = _chunkT5HIQPNGjs.createHwkError; exports.defaultOriginForCode = _chunkT5HIQPNGjs.defaultOriginForCode; exports.defaultRecoveryForCode = _chunkT5HIQPNGjs.defaultRecoveryForCode; exports.deriveDeviceFingerprint = deriveDeviceFingerprint; exports.deriveWalletId = deriveWalletId; exports.detectHardwareVendorFromDescriptor = detectHardwareVendorFromDescriptor; exports.enrichErrorMessage = _chunkYLCHSNXOjs.enrichErrorMessage; exports.ensure0x = ensure0x; exports.failure = failure; exports.getAllNetworkMethodChain = getAllNetworkMethodChain; exports.getHardwareMethodMetadata = getHardwareMethodMetadata; exports.hasHardwareRuntimeIdPrefix = hasHardwareRuntimeIdPrefix; exports.hexToBytes = hexToBytes; exports.isAllNetworkMethodName = isAllNetworkMethodName; exports.isConnectionLost = isConnectionLost; exports.isHardwareOperationId = isHardwareOperationId; exports.isHwkRecoveryHint = _chunkT5HIQPNGjs.isHwkRecoveryHint; exports.isKnownNonTargetHardwareVendor = isKnownNonTargetHardwareVendor; exports.isUserRefusal = isUserRefusal; exports.operationMayHaveCompletedParams = _chunkT5HIQPNGjs.operationMayHaveCompletedParams; exports.padHex64 = padHex64; exports.parseBip32MasterFingerprint = parseBip32MasterFingerprint; exports.parseHardwareRuntimeId = parseHardwareRuntimeId; exports.parseWalletMasterFingerprint = parseWalletMasterFingerprint; exports.prepareSolanaOffchainMessageV1 = prepareSolanaOffchainMessageV1; exports.rehydrateConnectorError = rehydrateConnectorError; exports.requestBleDeviceSelection = requestBleDeviceSelection; exports.requestSaveDeviceBinding = requestSaveDeviceBinding; exports.resolveHardwareOperationTarget = resolveHardwareOperationTarget; exports.resolveSearchTargetReusePolicy = resolveSearchTargetReusePolicy; exports.runAllNetworkGetAddress = runAllNetworkGetAddress; exports.serializeConnectorError = serializeConnectorError; exports.stripHex = stripHex; exports.success = success;
769
+ exports.ALL_NETWORK_METHOD_NAMES = ALL_NETWORK_METHOD_NAMES; exports.CHAIN_FINGERPRINT_PATHS = CHAIN_FINGERPRINT_PATHS; exports.DEVICE = DEVICE; exports.DEVICE_CONNECT_RETRY_DELAY_MS = DEVICE_CONNECT_RETRY_DELAY_MS; exports.DEVICE_EVENT = DEVICE_EVENT; exports.DeviceJobQueue = DeviceJobQueue; exports.EConnectorInteraction = EConnectorInteraction; exports.HARDWARE_METHOD_CATALOG = HARDWARE_METHOD_CATALOG; exports.HardwareErrorCode = _chunkSZZF623Rjs.HardwareErrorCode; exports.ORPHAN_ELIGIBLE_ERROR_CODES = _chunkSZZF623Rjs.ORPHAN_ELIGIBLE_ERROR_CODES; exports.SDK = SDK; exports.TypedEventEmitter = TypedEventEmitter; exports.UI_EVENT = _chunkBAGEFFFYjs.UI_EVENT; exports.UI_REQUEST = _chunkBAGEFFFYjs.UI_REQUEST; exports.UI_REQUEST_CANCELLED_TAG = _chunkBAGEFFFYjs.UI_REQUEST_CANCELLED_TAG; exports.UI_REQUEST_DEFAULT_TIMEOUT_MS = _chunkBAGEFFFYjs.UI_REQUEST_DEFAULT_TIMEOUT_MS; exports.UI_REQUEST_PREEMPTED_TAG = _chunkBAGEFFFYjs.UI_REQUEST_PREEMPTED_TAG; exports.UI_REQUEST_TIMEOUT_TAG = _chunkBAGEFFFYjs.UI_REQUEST_TIMEOUT_TAG; exports.UI_RESPONSE = _chunkBAGEFFFYjs.UI_RESPONSE; exports.UiRequestRegistry = _chunkBAGEFFFYjs.UiRequestRegistry; exports.batchCall = batchCall; exports.buildUnsupportedMethodResponse = buildUnsupportedMethodResponse; exports.bytesToHex = bytesToHex2; exports.compareSemver = compareSemver; exports.createBridgedConnector = createBridgedConnector; exports.createCombinedConnector = createCombinedConnector; exports.createHwkError = _chunkSZZF623Rjs.createHwkError; exports.deriveDeviceFingerprint = deriveDeviceFingerprint; exports.detectHardwareVendorFromDescriptor = detectHardwareVendorFromDescriptor; exports.enrichErrorMessage = _chunkSZZF623Rjs.enrichErrorMessage; exports.ensure0x = ensure0x; exports.failure = failure; exports.getAllNetworkMethodChain = getAllNetworkMethodChain; exports.getHardwareMethodMetadata = getHardwareMethodMetadata; exports.hexToBytes = hexToBytes; exports.isAllNetworkMethodName = isAllNetworkMethodName; exports.isKnownNonTargetHardwareVendor = isKnownNonTargetHardwareVendor; exports.padHex64 = padHex64; exports.rehydrateConnectorError = rehydrateConnectorError; exports.runAllNetworkGetAddress = runAllNetworkGetAddress; exports.serializeConnectorError = serializeConnectorError; exports.stripHex = stripHex; exports.success = success;
1327
770
  //# sourceMappingURL=index.js.map