@onekeyfe/hwk-adapter-core 1.2.2-alpha.9 → 1.2.3-alpha.2

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-3M3GMF64.mjs +68 -0
  2. package/dist/chunk-3M3GMF64.mjs.map +1 -0
  3. package/dist/chunk-7SFFS2NL.js +68 -0
  4. package/dist/chunk-7SFFS2NL.js.map +1 -0
  5. package/dist/{chunk-67BP77GT.mjs → chunk-E3UPXUN5.mjs} +149 -56
  6. package/dist/chunk-E3UPXUN5.mjs.map +1 -0
  7. package/dist/{chunk-U63HTLGJ.mjs → chunk-ELC6PLKH.mjs} +31 -2
  8. package/dist/chunk-ELC6PLKH.mjs.map +1 -0
  9. package/dist/{chunk-BAGEFFFY.js → chunk-S7X2HM7P.js} +32 -3
  10. package/dist/chunk-S7X2HM7P.js.map +1 -0
  11. package/dist/{chunk-SK7ZF33J.js → chunk-Z3IH25KV.js} +149 -56
  12. package/dist/chunk-Z3IH25KV.js.map +1 -0
  13. package/dist/errors-C5GWtyVN.d.mts +304 -0
  14. package/dist/errors-C5GWtyVN.d.ts +304 -0
  15. package/dist/errors.d.mts +1 -205
  16. package/dist/errors.d.ts +1 -205
  17. package/dist/errors.js +8 -2
  18. package/dist/errors.js.map +1 -1
  19. package/dist/errors.mjs +9 -3
  20. package/dist/index.d.mts +546 -74
  21. package/dist/index.d.ts +546 -74
  22. package/dist/index.js +616 -81
  23. package/dist/index.js.map +1 -1
  24. package/dist/index.mjs +607 -72
  25. package/dist/index.mjs.map +1 -1
  26. package/dist/{ui-events-Cb7haAeE.d.mts → ui-events-CbZdnS8a.d.mts} +28 -3
  27. package/dist/{ui-events-Cb7haAeE.d.ts → ui-events-CbZdnS8a.d.ts} +28 -3
  28. package/dist/ui-events.d.mts +1 -1
  29. package/dist/ui-events.d.ts +1 -1
  30. package/dist/ui-events.js +3 -2
  31. package/dist/ui-events.js.map +1 -1
  32. package/dist/ui-events.mjs +2 -1
  33. package/package.json +2 -2
  34. package/dist/chunk-67BP77GT.mjs.map +0 -1
  35. package/dist/chunk-BAGEFFFY.js.map +0 -1
  36. package/dist/chunk-SK7ZF33J.js.map +0 -1
  37. package/dist/chunk-U63HTLGJ.mjs.map +0 -1
package/dist/index.js CHANGED
@@ -1,31 +1,49 @@
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 _chunk7SFFS2NLjs = require('./chunk-7SFFS2NL.js');
3
4
 
4
5
 
5
6
 
6
- var _chunkSK7ZF33Jjs = require('./chunk-SK7ZF33J.js');
7
7
 
8
8
 
9
9
 
10
10
 
11
11
 
12
12
 
13
+ var _chunkS7X2HM7Pjs = require('./chunk-S7X2HM7P.js');
13
14
 
14
15
 
15
16
 
16
- var _chunkBAGEFFFYjs = require('./chunk-BAGEFFFY.js');
17
+
18
+
19
+
20
+
21
+
22
+ var _chunkZ3IH25KVjs = require('./chunk-Z3IH25KV.js');
17
23
 
18
24
  // src/types/response.ts
19
25
  function success(payload) {
20
26
  return { success: true, payload };
21
27
  }
22
- function failure(code, error, params) {
28
+ function failure(code, error, params, origin, recovery) {
23
29
  return {
24
30
  success: false,
25
- payload: { error, code, ...params ? { params } : {} }
31
+ payload: {
32
+ error,
33
+ code,
34
+ ...origin !== void 0 ? { origin } : {},
35
+ recovery: _nullishCoalesce(recovery, () => ( _chunkZ3IH25KVjs.defaultRecoveryForCode.call(void 0, code))),
36
+ ...params ? { params } : {}
37
+ }
26
38
  };
27
39
  }
28
40
 
41
+ // src/types/device.ts
42
+ function resolveSearchTargetReusePolicy(device) {
43
+ if (_optionalChain([device, 'access', _ => _.capabilities, 'optionalAccess', _2 => _2.persistentDeviceIdentity])) return "reconnectable";
44
+ return "current-discovery";
45
+ }
46
+
29
47
  // src/types/fingerprint.ts
30
48
  var _sha256 = require('@noble/hashes/sha256');
31
49
  var _utils = require('@noble/hashes/utils');
@@ -35,11 +53,21 @@ var CHAIN_FINGERPRINT_PATHS = {
35
53
  // Cointype 1 (testnet) is rejected by some Ledger BTC App configurations.
36
54
  btc: "m/44'/0'/0'",
37
55
  sol: "m/44'/501'/0'",
38
- tron: "m/44'/195'/0'/0/0"
56
+ tron: "m/44'/195'/0'/0/0",
57
+ // Shielded UA (single Orchard receiver) derived from the transparent path.
58
+ zcash: "m/44'/133'/0'/0/0"
39
59
  };
60
+ function parseBip32MasterFingerprint(value) {
61
+ if (typeof value !== "string") return void 0;
62
+ const normalized = value.trim().toLowerCase();
63
+ return /^[0-9a-f]{8}$/.test(normalized) ? normalized : void 0;
64
+ }
40
65
  function deriveDeviceFingerprint(value) {
41
66
  return _utils.bytesToHex.call(void 0, _sha256.sha256.call(void 0, _utils.utf8ToBytes.call(void 0, value))).slice(0, 16);
42
67
  }
68
+ function deriveWalletId(canonicalPublicMaterial) {
69
+ return _utils.bytesToHex.call(void 0, _sha256.sha256.call(void 0, _utils.utf8ToBytes.call(void 0, `onekey-hwk-wallet-id:v1:${canonicalPublicMaterial}`)));
70
+ }
43
71
 
44
72
  // src/events/device.ts
45
73
  var DEVICE_EVENT = "DEVICE_EVENT";
@@ -66,7 +94,8 @@ var SDK = {
66
94
  DEVICE_STUCK: "device-stuck",
67
95
  DEVICE_UNRESPONSIVE: "device-unresponsive",
68
96
  DEVICE_RECOVERED: "device-recovered",
69
- DEVICE_INTERACTION: "device-interaction"
97
+ DEVICE_INTERACTION: "device-interaction",
98
+ OPERATION_ENDED: "operation-ended"
70
99
  };
71
100
 
72
101
  // src/utils/DeviceJobQueue.ts
@@ -97,12 +126,13 @@ var DeviceJobQueue = class {
97
126
  abortController: ac,
98
127
  startedAt: Date.now()
99
128
  };
100
- this._jobs.set(jobToken, { deviceId });
129
+ this._jobs.set(jobToken, activeJob);
101
130
  const next = prev.catch(() => {
102
131
  }).then(async () => {
103
132
  if (this._generation !== gen) {
104
133
  throw _nullishCoalesce(this._generationCancelReasons.get(gen), () => ( new Error("Job cancelled: queue was cleared")));
105
134
  }
135
+ if (ac.signal.aborted) throw ac.signal.reason;
106
136
  this._active = activeJob;
107
137
  try {
108
138
  return await job(ac.signal);
@@ -118,31 +148,27 @@ var DeviceJobQueue = class {
118
148
  });
119
149
  return next;
120
150
  }
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;
127
- }
128
- /** Force cancel the active job. `reason` becomes signal.reason. */
129
- forceCancelActive(deviceId, reason) {
151
+ /** Cancel the running job. `reason` becomes signal.reason. */
152
+ cancelActive(deviceId, reason) {
130
153
  if (!this._active) return false;
131
154
  if (deviceId && this._active.deviceId !== deviceId) return false;
132
- this._active.abortController.abort(_nullishCoalesce(reason, () => ( new Error("Force cancelled for recovery"))));
155
+ this._active.abortController.abort(_nullishCoalesce(reason, () => ( new Error("Cancelled"))));
133
156
  return true;
134
157
  }
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
158
  /** Cancel the active job and invalidate queued jobs that have not started. */
141
159
  cancelActiveAndPending(deviceId, reason) {
142
- if (deviceId && this._active && this._active.deviceId !== deviceId) {
143
- return false;
160
+ const cancelReason = _nullishCoalesce(reason, () => ( new Error("Cancelled by cancelActiveAndPending")));
161
+ if (deviceId) {
162
+ let cancelled = false;
163
+ for (const job of this._jobs.values()) {
164
+ if (job.deviceId === deviceId) {
165
+ job.abortController.abort(cancelReason);
166
+ cancelled = true;
167
+ }
168
+ }
169
+ return cancelled;
144
170
  }
145
- this.clear(_nullishCoalesce(reason, () => ( new Error("Cancelled by cancelActiveAndPending"))));
171
+ this.clear(cancelReason);
146
172
  return true;
147
173
  }
148
174
  /** Get info about the currently active job, or null if idle. */
@@ -155,10 +181,6 @@ var DeviceJobQueue = class {
155
181
  startedAt: this._active.startedAt
156
182
  };
157
183
  }
158
- /** True if any job is currently running. */
159
- isBusy() {
160
- return this._jobs.size > 0;
161
- }
162
184
  clear(reason) {
163
185
  const cancelledGeneration = this._generation;
164
186
  this._generation++;
@@ -175,6 +197,224 @@ var DeviceJobQueue = class {
175
197
  }
176
198
  };
177
199
 
200
+ // src/utils/hardwareRuntimeId.ts
201
+
202
+ var HARDWARE_RUNTIME_ID_PREFIX = "hwk:runtime";
203
+ var RANDOM_ID_BYTES = 16;
204
+ var RANDOM_ID_PATTERN = /^[0-9a-f]{32}$/;
205
+ var KINDS = /* @__PURE__ */ new Set([
206
+ "operation",
207
+ "search-target",
208
+ "link"
209
+ ]);
210
+ var VENDORS = /* @__PURE__ */ new Set(["trezor", "ledger", "keystone"]);
211
+ function create(kind, vendor) {
212
+ return `${HARDWARE_RUNTIME_ID_PREFIX}:${kind}:${vendor}:${_utils.bytesToHex.call(void 0,
213
+ _utils.randomBytes.call(void 0, RANDOM_ID_BYTES)
214
+ )}`;
215
+ }
216
+ function createHardwareOperationId(vendor) {
217
+ return create("operation", vendor);
218
+ }
219
+ function createHardwareSearchTargetId(vendor) {
220
+ return create("search-target", vendor);
221
+ }
222
+ function createHardwareLinkId(vendor) {
223
+ return create("link", vendor);
224
+ }
225
+ function hasHardwareRuntimeIdPrefix(value) {
226
+ return typeof value === "string" && value.startsWith(`${HARDWARE_RUNTIME_ID_PREFIX}:`);
227
+ }
228
+ function parseHardwareRuntimeId(value) {
229
+ if (!hasHardwareRuntimeIdPrefix(value)) return void 0;
230
+ const parts = value.split(":");
231
+ if (parts.length !== 5) return void 0;
232
+ const [, , kind, vendor, nonce] = parts;
233
+ if (!KINDS.has(kind) || !VENDORS.has(vendor) || !RANDOM_ID_PATTERN.test(nonce)) {
234
+ return void 0;
235
+ }
236
+ return { kind, vendor };
237
+ }
238
+ function isHardwareOperationId(value) {
239
+ return _optionalChain([parseHardwareRuntimeId, 'call', _3 => _3(value), 'optionalAccess', _4 => _4.kind]) === "operation";
240
+ }
241
+
242
+ // src/utils/OperationRegistry.ts
243
+ var OPERATION_DEFAULT_TTL_MS = 6e5;
244
+ var OperationRegistry = class {
245
+ constructor(options) {
246
+ this._active = /* @__PURE__ */ new Map();
247
+ this._ended = /* @__PURE__ */ new Map();
248
+ this._vendor = options.vendor;
249
+ this._ttlMs = _nullishCoalesce(options.ttlMs, () => ( OPERATION_DEFAULT_TTL_MS));
250
+ this._onEnded = options.onEnded;
251
+ }
252
+ create(params) {
253
+ const now = Date.now();
254
+ const operationId = createHardwareOperationId(this._vendor);
255
+ const operation = {
256
+ operationId,
257
+ connectId: params.connectId,
258
+ device: params.device,
259
+ connectionKeys: Array.from(
260
+ new Set(
261
+ [params.searchTargetId, params.connectId, ..._nullishCoalesce(params.connectionKeys, () => ( []))].filter(
262
+ Boolean
263
+ )
264
+ )
265
+ ),
266
+ createdAt: now,
267
+ lastActiveAt: now
268
+ };
269
+ const timer = this._createTimer(operationId);
270
+ this._active.set(operationId, { ...operation, timer, retainCount: 0 });
271
+ return operation;
272
+ }
273
+ resolve(operationId) {
274
+ const active = this._active.get(operationId);
275
+ if (!active) {
276
+ const ended = this._ended.get(operationId);
277
+ if (ended) {
278
+ throw _chunkZ3IH25KVjs.createHwkError.call(void 0, {
279
+ code: 10113 /* OperationEnded */,
280
+ message: `Hardware operation has ended (${ended.reason})`,
281
+ params: { operationId, reason: ended.reason }
282
+ });
283
+ }
284
+ throw _chunkZ3IH25KVjs.createHwkError.call(void 0, {
285
+ code: 10112 /* OperationNotFound */,
286
+ message: "Hardware operation was not found",
287
+ params: { operationId }
288
+ });
289
+ }
290
+ if (active.timer) clearTimeout(active.timer);
291
+ active.lastActiveAt = Date.now();
292
+ active.timer = active.retainCount === 0 ? this._createTimer(operationId) : void 0;
293
+ return active;
294
+ }
295
+ /** Keep an operation alive while one device job is actively using it. */
296
+ retain(operationId) {
297
+ const active = this.resolve(operationId);
298
+ if (active.timer) clearTimeout(active.timer);
299
+ active.timer = void 0;
300
+ active.retainCount += 1;
301
+ let released = false;
302
+ return () => {
303
+ if (released) return;
304
+ released = true;
305
+ const current = this._active.get(operationId);
306
+ if (!current) return;
307
+ current.retainCount = Math.max(0, current.retainCount - 1);
308
+ current.lastActiveAt = Date.now();
309
+ if (current.retainCount === 0) {
310
+ current.timer = this._createTimer(operationId);
311
+ }
312
+ };
313
+ }
314
+ /** Return active or tombstoned binding data without refreshing its TTL. */
315
+ find(operationId) {
316
+ return _nullishCoalesce(this._active.get(operationId), () => ( _optionalChain([this, 'access', _5 => _5._ended, 'access', _6 => _6.get, 'call', _7 => _7(operationId), 'optionalAccess', _8 => _8.operation])));
317
+ }
318
+ findActiveByConnectionKey(connectionKey) {
319
+ if (!connectionKey) return void 0;
320
+ return [...this._active.values()].find(
321
+ (operation) => operation.connectionKeys.includes(connectionKey)
322
+ );
323
+ }
324
+ /** Replace the live transport binding after the same target was reconnected. */
325
+ rebind(operationId, params) {
326
+ const active = this._active.get(operationId);
327
+ if (!active) {
328
+ this.resolve(operationId);
329
+ throw new Error("Unreachable operation rebind");
330
+ }
331
+ if (active.timer) clearTimeout(active.timer);
332
+ active.connectId = params.connectId;
333
+ active.device = params.device;
334
+ active.connectionKeys = Array.from(
335
+ new Set([params.connectId, ..._nullishCoalesce(params.connectionKeys, () => ( []))].filter(Boolean))
336
+ );
337
+ active.lastActiveAt = Date.now();
338
+ active.timer = active.retainCount === 0 ? this._createTimer(operationId) : void 0;
339
+ return active;
340
+ }
341
+ end(operationId, reason) {
342
+ const active = this._active.get(operationId);
343
+ if (!active) return void 0;
344
+ if (active.timer) clearTimeout(active.timer);
345
+ this._active.delete(operationId);
346
+ this._rememberEnded(active, reason);
347
+ _optionalChain([this, 'access', _9 => _9._onEnded, 'optionalCall', _10 => _10(active, reason)]);
348
+ return active;
349
+ }
350
+ endByConnectionKey(connectionKey, reason, exceptOperationId) {
351
+ if (!connectionKey) return;
352
+ for (const operation of [...this._active.values()]) {
353
+ if (operation.operationId === exceptOperationId) continue;
354
+ if (operation.connectionKeys.includes(connectionKey)) {
355
+ this.end(operation.operationId, reason);
356
+ }
357
+ }
358
+ }
359
+ endAll(reason, exceptOperationId) {
360
+ for (const operationId of [...this._active.keys()]) {
361
+ if (operationId === exceptOperationId) continue;
362
+ this.end(operationId, reason);
363
+ }
364
+ }
365
+ _createTimer(operationId) {
366
+ const timer = setTimeout(() => {
367
+ this.end(operationId, "timeout");
368
+ }, this._ttlMs);
369
+ _optionalChain([timer, 'access', _11 => _11.unref, 'optionalCall', _12 => _12()]);
370
+ return timer;
371
+ }
372
+ _rememberEnded(operation, reason) {
373
+ this._ended.set(operation.operationId, { reason, operation });
374
+ if (this._ended.size <= 100) return;
375
+ const oldest = this._ended.keys().next().value;
376
+ if (oldest) this._ended.delete(oldest);
377
+ }
378
+ };
379
+
380
+ // src/utils/hardwareOperationTarget.ts
381
+ function resolveHardwareOperationTarget(positionalTargetId, commonOperationId, expectedVendor) {
382
+ const normalizedPositionalTargetId = _nullishCoalesce(positionalTargetId, () => ( void 0));
383
+ const normalizedCommonOperationId = commonOperationId || void 0;
384
+ const positionalOperationId = isHardwareOperationId(normalizedPositionalTargetId) ? normalizedPositionalTargetId : void 0;
385
+ const parsedPositionalTarget = parseHardwareRuntimeId(normalizedPositionalTargetId);
386
+ const parsedCommonOperation = parseHardwareRuntimeId(normalizedCommonOperationId);
387
+ if (normalizedPositionalTargetId && hasHardwareRuntimeIdPrefix(normalizedPositionalTargetId) && !parsedPositionalTarget) {
388
+ return failure(10002 /* InvalidParams */, "Invalid hardware operation target id");
389
+ }
390
+ if (_optionalChain([parsedPositionalTarget, 'optionalAccess', _13 => _13.kind]) === "link") {
391
+ return failure(
392
+ 10002 /* InvalidParams */,
393
+ "Hardware transport link id cannot be used as an operation target"
394
+ );
395
+ }
396
+ if (normalizedCommonOperationId && _optionalChain([parsedCommonOperation, 'optionalAccess', _14 => _14.kind]) !== "operation") {
397
+ return failure(10002 /* InvalidParams */, "Invalid hardware operation id");
398
+ }
399
+ if (expectedVendor && (parsedPositionalTarget && parsedPositionalTarget.vendor !== expectedVendor || parsedCommonOperation && parsedCommonOperation.vendor !== expectedVendor)) {
400
+ return failure(
401
+ 10002 /* InvalidParams */,
402
+ `Hardware operation does not belong to ${expectedVendor}`
403
+ );
404
+ }
405
+ if (positionalOperationId && normalizedCommonOperationId && positionalOperationId !== normalizedCommonOperationId) {
406
+ return failure(10002 /* InvalidParams */, "Conflicting hardware operation ids", {
407
+ positionalOperationId,
408
+ commonOperationId: normalizedCommonOperationId
409
+ });
410
+ }
411
+ const operationId = _nullishCoalesce(normalizedCommonOperationId, () => ( positionalOperationId));
412
+ return success({
413
+ operationId,
414
+ targetId: _nullishCoalesce(operationId, () => ( normalizedPositionalTargetId))
415
+ });
416
+ }
417
+
178
418
  // src/types/connector.ts
179
419
  var EConnectorInteraction = /* @__PURE__ */ ((EConnectorInteraction2) => {
180
420
  EConnectorInteraction2["Searching"] = "searching";
@@ -190,7 +430,7 @@ function createBridgedConnector(vendor, connectionType, bridge) {
190
430
  return {
191
431
  connectionType,
192
432
  searchDevices: (options) => bridge.searchDevices({ vendor, options }),
193
- connect: (deviceId) => bridge.connect({ vendor, deviceId }),
433
+ connect: (deviceId, options) => bridge.connect({ vendor, deviceId, ...options ? { options } : {} }),
194
434
  disconnect: (sessionId) => bridge.disconnect({ vendor, sessionId }),
195
435
  call: (sessionId, method, callParams) => bridge.call({ vendor, sessionId, method, callParams }),
196
436
  cancel: (sessionId) => bridge.cancel({ vendor, sessionId }),
@@ -211,14 +451,14 @@ function createBridgedConnector(vendor, connectionType, bridge) {
211
451
  },
212
452
  off: (event, handler) => {
213
453
  const inner = handlerMap.get(event);
214
- const bridgeHandler = _optionalChain([inner, 'optionalAccess', _ => _.get, 'call', _2 => _2(handler)]);
454
+ const bridgeHandler = _optionalChain([inner, 'optionalAccess', _15 => _15.get, 'call', _16 => _16(handler)]);
215
455
  if (!bridgeHandler || !inner) return;
216
456
  bridge.offEvent({ vendor }, bridgeHandler);
217
457
  inner.delete(handler);
218
458
  if (inner.size === 0) handlerMap.delete(event);
219
459
  },
220
460
  reset: () => bridge.reset({ vendor }),
221
- configure: bridge.configure ? (config) => _optionalChain([bridge, 'access', _3 => _3.configure, 'optionalCall', _4 => _4({ vendor, config })]) : void 0,
461
+ configure: bridge.configure ? (config) => _optionalChain([bridge, 'access', _17 => _17.configure, 'optionalCall', _18 => _18({ vendor, config })]) : void 0,
222
462
  setKnownCredentials: bridge.setKnownCredentials ? (credentials) => bridge.setKnownCredentials({ vendor, credentials }) : void 0
223
463
  };
224
464
  }
@@ -287,13 +527,13 @@ function isDeviceUnavailableError(error) {
287
527
  return false;
288
528
  }
289
529
  function combinedDeviceNotFoundError(message) {
290
- return _chunkSK7ZF33Jjs.createHwkError.call(void 0, {
530
+ return _chunkZ3IH25KVjs.createHwkError.call(void 0, {
291
531
  code: 10100 /* DeviceNotFound */,
292
532
  message
293
533
  });
294
534
  }
295
535
  function combinedSessionNotFoundError(message) {
296
- return _chunkSK7ZF33Jjs.createHwkError.call(void 0, {
536
+ return _chunkZ3IH25KVjs.createHwkError.call(void 0, {
297
537
  code: 10101 /* DeviceDisconnected */,
298
538
  message
299
539
  });
@@ -322,7 +562,7 @@ function createCombinedConnector(connectors) {
322
562
  };
323
563
  const broadcastCredentials = async () => {
324
564
  await Promise.all(
325
- connectors.map((child) => Promise.resolve(_optionalChain([child, 'access', _5 => _5.setKnownCredentials, 'optionalCall', _6 => _6(sharedCredentials)])))
565
+ connectors.map((child) => Promise.resolve(_optionalChain([child, 'access', _19 => _19.setKnownCredentials, 'optionalCall', _20 => _20(sharedCredentials)])))
326
566
  );
327
567
  };
328
568
  for (const child of connectors) {
@@ -331,10 +571,14 @@ function createCombinedConnector(connectors) {
331
571
  });
332
572
  }
333
573
  const searchDevices = async (options = {}) => {
574
+ const selectedConnectors = connectors.map((child, index) => ({ child, index })).filter(
575
+ ({ child }) => !options.transportType || child.connectionType === options.transportType
576
+ );
577
+ if (!selectedConnectors.length) return [];
334
578
  const perConnector = [];
335
- await new Promise((resolve) => {
579
+ await new Promise((resolve, reject) => {
336
580
  let finished = false;
337
- let remaining = connectors.length;
581
+ let remaining = selectedConnectors.length;
338
582
  let settleTimer;
339
583
  const finish = () => {
340
584
  if (finished) return;
@@ -342,19 +586,20 @@ function createCombinedConnector(connectors) {
342
586
  if (settleTimer) clearTimeout(settleTimer);
343
587
  resolve();
344
588
  };
345
- connectors.forEach((child, index) => {
346
- void child.searchDevices().then(
589
+ selectedConnectors.forEach(({ child, index }) => {
590
+ void child.searchDevices(options.purpose ? { purpose: options.purpose } : void 0).then(
347
591
  (devices) => devices.map((device) => ({
348
592
  ...device,
349
593
  connectionType: _nullishCoalesce(device.connectionType, () => ( child.connectionType))
350
594
  }))
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) => {
595
+ ).catch((error) => {
596
+ if (options.transportType) {
597
+ finished = true;
598
+ if (settleTimer) clearTimeout(settleTimer);
599
+ reject(error);
600
+ }
601
+ return [];
602
+ }).then((devices) => {
358
603
  remaining -= 1;
359
604
  if (!finished) {
360
605
  perConnector.push({ index, devices });
@@ -371,7 +616,12 @@ function createCombinedConnector(connectors) {
371
616
  });
372
617
  });
373
618
  perConnector.sort((a, b) => a.index - b.index);
374
- deviceOwner.clear();
619
+ if (!options.transportType) deviceOwner.clear();
620
+ else {
621
+ for (const [id, owner] of deviceOwner) {
622
+ if (owner.connectionType === options.transportType) deviceOwner.delete(id);
623
+ }
624
+ }
375
625
  const merged = [];
376
626
  perConnector.forEach(({ index, devices }) => {
377
627
  for (const device of devices) {
@@ -381,11 +631,11 @@ function createCombinedConnector(connectors) {
381
631
  });
382
632
  return merged.sort((a, b) => rank(a) - rank(b));
383
633
  };
384
- const resolveOwner = async (deviceId) => {
385
- if (deviceId && deviceOwner.has(deviceId)) {
634
+ const resolveOwner = async (deviceId, transportType) => {
635
+ if (deviceId && deviceOwner.has(deviceId) && (!transportType || _optionalChain([deviceOwner, 'access', _21 => _21.get, 'call', _22 => _22(deviceId), 'optionalAccess', _23 => _23.connectionType]) === transportType)) {
386
636
  return { owner: deviceOwner.get(deviceId), deviceId };
387
637
  }
388
- const devices = await searchDevices({ waitForAll: Boolean(deviceId) });
638
+ const devices = await searchDevices({ waitForAll: Boolean(deviceId), transportType });
389
639
  if (deviceId) {
390
640
  const owner = deviceOwner.get(deviceId);
391
641
  if (!owner)
@@ -396,13 +646,14 @@ function createCombinedConnector(connectors) {
396
646
  if (!first) throw combinedDeviceNotFoundError("Combined connector: no devices found");
397
647
  return { owner: deviceOwner.get(first.connectId), deviceId: first.connectId };
398
648
  };
399
- const connectByExplicitId = async (deviceId) => {
649
+ const connectByExplicitId = async (deviceId, transportType) => {
400
650
  const cachedOwner = deviceOwner.get(deviceId);
401
- if (cachedOwner) {
651
+ if (cachedOwner && (!transportType || cachedOwner.connectionType === transportType)) {
402
652
  return { session: await cachedOwner.connect(deviceId), owner: cachedOwner };
403
653
  }
404
654
  let lastError;
405
655
  for (const child of connectors) {
656
+ if (transportType && child.connectionType !== transportType) continue;
406
657
  try {
407
658
  const session = await child.connect(deviceId);
408
659
  deviceOwner.set(deviceId, child);
@@ -415,7 +666,7 @@ function createCombinedConnector(connectors) {
415
666
  }
416
667
  }
417
668
  const message = lastError instanceof Error ? lastError.message : `Combined connector: device not found: ${deviceId}`;
418
- throw _chunkSK7ZF33Jjs.createHwkError.call(void 0, {
669
+ throw _chunkZ3IH25KVjs.createHwkError.call(void 0, {
419
670
  code: 10100 /* DeviceNotFound */,
420
671
  message
421
672
  });
@@ -424,14 +675,15 @@ function createCombinedConnector(connectors) {
424
675
  // Nominal value only — the per-device `connectionType` is authoritative
425
676
  // for a fused connector.
426
677
  connectionType: connectors[0].connectionType,
427
- searchDevices: (options) => searchDevices({ waitForAll: _optionalChain([options, 'optionalAccess', _7 => _7.waitForAll]) }),
428
- connect: async (deviceId) => {
678
+ availableTransports: [...new Set(connectors.map((child) => child.connectionType))],
679
+ searchDevices: (options) => searchDevices(options),
680
+ connect: async (deviceId, options) => {
429
681
  let owner;
430
682
  let session;
431
683
  if (deviceId) {
432
- ({ session, owner } = await connectByExplicitId(deviceId));
684
+ ({ session, owner } = await connectByExplicitId(deviceId, _optionalChain([options, 'optionalAccess', _24 => _24.transportType])));
433
685
  } else {
434
- const resolved = await resolveOwner();
686
+ const resolved = await resolveOwner(void 0, _optionalChain([options, 'optionalAccess', _25 => _25.transportType]));
435
687
  owner = resolved.owner;
436
688
  session = await owner.connect(resolved.deviceId);
437
689
  }
@@ -474,7 +726,7 @@ function createCombinedConnector(connectors) {
474
726
  },
475
727
  off: (event, handler) => {
476
728
  const inner = forwarders.get(event);
477
- const attached = _optionalChain([inner, 'optionalAccess', _8 => _8.get, 'call', _9 => _9(handler)]);
729
+ const attached = _optionalChain([inner, 'optionalAccess', _26 => _26.get, 'call', _27 => _27(handler)]);
478
730
  if (!attached || !inner) return;
479
731
  for (const { child, handler: forward } of attached) {
480
732
  child.off(event, forward);
@@ -489,7 +741,7 @@ function createCombinedConnector(connectors) {
489
741
  forwarders.clear();
490
742
  },
491
743
  configure: connectors.some((c) => c.configure) ? async (config) => {
492
- await Promise.all(connectors.map((child) => Promise.resolve(_optionalChain([child, 'access', _10 => _10.configure, 'optionalCall', _11 => _11(config)]))));
744
+ await Promise.all(connectors.map((child) => Promise.resolve(_optionalChain([child, 'access', _28 => _28.configure, 'optionalCall', _29 => _29(config)]))));
493
745
  deviceOwner.clear();
494
746
  sessionOwner.clear();
495
747
  } : void 0,
@@ -533,10 +785,151 @@ var TypedEventEmitter = class {
533
785
  }
534
786
  /** Number of listeners registered for `event`. 0 if none. */
535
787
  listenerCount(event) {
536
- return _nullishCoalesce(_optionalChain([this, 'access', _12 => _12._listeners, 'access', _13 => _13.get, 'call', _14 => _14(event), 'optionalAccess', _15 => _15.size]), () => ( 0));
788
+ return _nullishCoalesce(_optionalChain([this, 'access', _30 => _30._listeners, 'access', _31 => _31.get, 'call', _32 => _32(event), 'optionalAccess', _33 => _33.size]), () => ( 0));
537
789
  }
538
790
  };
539
791
 
792
+ // src/utils/requestSaveDeviceBinding.ts
793
+ async function requestSaveDeviceBinding(emitter, registry, binding, signal) {
794
+ const type = _chunkS7X2HM7Pjs.UI_REQUEST.REQUEST_SAVE_DEVICE_BINDING;
795
+ const declined = (reason) => {
796
+ emitter.emit(_chunkS7X2HM7Pjs.UI_REQUEST.DEVICE_BINDING_STATUS, {
797
+ type: _chunkS7X2HM7Pjs.UI_REQUEST.DEVICE_BINDING_STATUS,
798
+ payload: { selectionRequestId: binding.selectionRequestId, status: "failed" }
799
+ });
800
+ return { saved: false, reason };
801
+ };
802
+ if (!emitter.listenerCount(type)) {
803
+ return declined("skipped");
804
+ }
805
+ if (_optionalChain([signal, 'optionalAccess', _34 => _34.aborted])) throw signal.reason;
806
+ const requestId = registry.createRequestId();
807
+ const pending = registry.wait(type, { requestId });
808
+ void pending.catch(() => void 0);
809
+ const cancel = () => registry.cancel(type, requestId);
810
+ _optionalChain([signal, 'optionalAccess', _35 => _35.addEventListener, 'call', _36 => _36("abort", cancel, { once: true })]);
811
+ try {
812
+ emitter.emit(type, { type, payload: { ...binding, requestId } });
813
+ const response = await pending;
814
+ if (_optionalChain([signal, 'optionalAccess', _37 => _37.aborted])) throw signal.reason;
815
+ if (_optionalChain([response, 'optionalAccess', _38 => _38.saved]) !== true) {
816
+ return declined(_nullishCoalesce(_optionalChain([response, 'optionalAccess', _39 => _39.reason]), () => ( "skipped")));
817
+ }
818
+ emitter.emit(_chunkS7X2HM7Pjs.UI_REQUEST.DEVICE_BINDING_STATUS, {
819
+ type: _chunkS7X2HM7Pjs.UI_REQUEST.DEVICE_BINDING_STATUS,
820
+ payload: { selectionRequestId: binding.selectionRequestId, status: "saved" }
821
+ });
822
+ return { saved: true };
823
+ } catch (error) {
824
+ emitter.emit(_chunkS7X2HM7Pjs.UI_REQUEST.DEVICE_BINDING_STATUS, {
825
+ type: _chunkS7X2HM7Pjs.UI_REQUEST.DEVICE_BINDING_STATUS,
826
+ payload: {
827
+ selectionRequestId: binding.selectionRequestId,
828
+ status: _optionalChain([signal, 'optionalAccess', _40 => _40.aborted]) ? "cancelled" : "failed"
829
+ }
830
+ });
831
+ if (_optionalChain([signal, 'optionalAccess', _41 => _41.aborted])) throw error;
832
+ return { saved: false, reason: "skipped" };
833
+ } finally {
834
+ _optionalChain([signal, 'optionalAccess', _42 => _42.removeEventListener, 'call', _43 => _43("abort", cancel)]);
835
+ registry.cancel(type, requestId);
836
+ }
837
+ }
838
+
839
+ // src/utils/requestBleDeviceSelection.ts
840
+ async function requestBleDeviceSelection({
841
+ emitter,
842
+ registry,
843
+ request,
844
+ scan,
845
+ signal,
846
+ allowUsbFallback = false,
847
+ pollIntervalMs = 1500
848
+ }) {
849
+ const type = _chunkS7X2HM7Pjs.UI_REQUEST.REQUEST_SELECT_DEVICE;
850
+ if (signal.aborted) throw signal.reason;
851
+ if (!emitter.listenerCount(type)) {
852
+ throw _chunkZ3IH25KVjs.createHwkError.call(void 0, {
853
+ code: 10100 /* DeviceNotFound */,
854
+ message: "Select a Bluetooth device before continuing"
855
+ });
856
+ }
857
+ const requestId = registry.createRequestId();
858
+ let devices = allowUsbFallback ? request.devices.filter((device) => device.connectionType === "ble") : request.devices;
859
+ const publishedDevices = /* @__PURE__ */ new Map();
860
+ let stopped = false;
861
+ let timer;
862
+ let wake;
863
+ const stop = () => {
864
+ stopped = true;
865
+ if (timer !== void 0) clearTimeout(timer);
866
+ _optionalChain([wake, 'optionalCall', _44 => _44()]);
867
+ };
868
+ const waitForNextScan = () => new Promise((resolve) => {
869
+ wake = resolve;
870
+ timer = setTimeout(resolve, pollIntervalMs);
871
+ if (stopped) resolve();
872
+ });
873
+ const cancel = () => registry.cancel(type, requestId);
874
+ const reply = registry.wait(type, { requestId }).finally(stop);
875
+ void reply.catch(() => void 0);
876
+ const publish = () => {
877
+ for (const device of devices) publishedDevices.set(device.connectId, device);
878
+ emitter.emit(type, {
879
+ type,
880
+ payload: { ...request, devices, requestId, scanning: true }
881
+ });
882
+ };
883
+ signal.addEventListener("abort", cancel, { once: true });
884
+ let polling;
885
+ try {
886
+ publish();
887
+ polling = (async () => {
888
+ await Promise.resolve();
889
+ while (!stopped) {
890
+ const snapshot = await scan();
891
+ if (stopped || signal.aborted) return;
892
+ const usbFallback = allowUsbFallback ? snapshot.find((device2) => device2.connectionType === "usb") : void 0;
893
+ if (usbFallback) return usbFallback;
894
+ devices = snapshot;
895
+ publish();
896
+ if (stopped) return;
897
+ await waitForNextScan();
898
+ }
899
+ })();
900
+ const userSelection = reply.then((selected) => publishedDevices.get(selected.sdkConnectId));
901
+ const device = await Promise.race([
902
+ userSelection,
903
+ polling.then((usbFallback) => _nullishCoalesce(usbFallback, () => ( userSelection)))
904
+ ]);
905
+ stop();
906
+ await polling;
907
+ if (signal.aborted) throw signal.reason;
908
+ if (!device) {
909
+ throw _chunkZ3IH25KVjs.createHwkError.call(void 0, {
910
+ code: 10100 /* DeviceNotFound */,
911
+ message: "Selected Bluetooth device is no longer available"
912
+ });
913
+ }
914
+ emitter.emit(_chunkS7X2HM7Pjs.UI_REQUEST.DEVICE_BINDING_STATUS, {
915
+ type: _chunkS7X2HM7Pjs.UI_REQUEST.DEVICE_BINDING_STATUS,
916
+ payload: { selectionRequestId: requestId, status: "verifying" }
917
+ });
918
+ return { device, requestId };
919
+ } catch (error) {
920
+ emitter.emit(_chunkS7X2HM7Pjs.UI_REQUEST.DEVICE_BINDING_STATUS, {
921
+ type: _chunkS7X2HM7Pjs.UI_REQUEST.DEVICE_BINDING_STATUS,
922
+ payload: { selectionRequestId: requestId, status: signal.aborted ? "cancelled" : "failed" }
923
+ });
924
+ throw error;
925
+ } finally {
926
+ stop();
927
+ signal.removeEventListener("abort", cancel);
928
+ registry.cancel(type, requestId);
929
+ await _optionalChain([polling, 'optionalAccess', _45 => _45.catch, 'call', _46 => _46(() => void 0)]);
930
+ }
931
+ }
932
+
540
933
  // src/utils/semver.ts
541
934
  function compareSemver(a, b) {
542
935
  const pa = a.split(".").map(Number);
@@ -564,15 +957,97 @@ function padHex64(hex) {
564
957
  function hexToBytes(hex) {
565
958
  return _utils.hexToBytes.call(void 0, stripHex(hex));
566
959
  }
567
- function bytesToHex2(bytes) {
960
+ function bytesToHex3(bytes) {
568
961
  return _utils.bytesToHex.call(void 0, bytes);
569
962
  }
570
963
 
964
+ // src/utils/solanaOffchainMessage.ts
965
+ var SOLANA_OFFCHAIN_SIGNING_DOMAIN = Uint8Array.of(
966
+ 255,
967
+ ...Array.from("solana offchain", (character) => character.charCodeAt(0))
968
+ );
969
+ var SOLANA_PUBLIC_KEY_LENGTH = 32;
970
+ var MAX_SOLANA_OFFCHAIN_SIGNERS = 255;
971
+ function compareBytes(a, b) {
972
+ for (let index = 0; index < a.length; index += 1) {
973
+ const difference = (_nullishCoalesce(a[index], () => ( 0))) - (_nullishCoalesce(b[index], () => ( 0)));
974
+ if (difference !== 0) return difference;
975
+ }
976
+ return a.length - b.length;
977
+ }
978
+ function bytesEqual(a, b) {
979
+ return a.length === b.length && a.every((value, index) => value === b[index]);
980
+ }
981
+ function decodeUtf8Strict(bytes) {
982
+ let encoded = "";
983
+ for (const value of bytes) {
984
+ encoded += `%${value.toString(16).padStart(2, "0")}`;
985
+ }
986
+ return decodeURIComponent(encoded);
987
+ }
988
+ function prepareSolanaOffchainMessageV1({
989
+ message,
990
+ requiredSigners
991
+ }) {
992
+ if (message.length === 0) {
993
+ throw new Error("Solana off-chain message cannot be empty");
994
+ }
995
+ if (requiredSigners.length === 0 || requiredSigners.length > MAX_SOLANA_OFFCHAIN_SIGNERS) {
996
+ throw new Error("Solana off-chain message requires between 1 and 255 signers");
997
+ }
998
+ let messageText;
999
+ try {
1000
+ messageText = decodeUtf8Strict(message);
1001
+ } catch (e3) {
1002
+ throw new Error("Solana off-chain message must contain valid UTF-8");
1003
+ }
1004
+ const signerBytes = requiredSigners.map((signer, index) => {
1005
+ let bytes;
1006
+ try {
1007
+ bytes = hexToBytes(signer);
1008
+ } catch (e4) {
1009
+ throw new Error(`Solana off-chain signer ${index} must be a hex public key`);
1010
+ }
1011
+ if (bytes.length !== SOLANA_PUBLIC_KEY_LENGTH) {
1012
+ throw new Error(`Solana off-chain signer ${index} must be 32 bytes`);
1013
+ }
1014
+ return bytes;
1015
+ });
1016
+ signerBytes.sort(compareBytes);
1017
+ for (let index = 1; index < signerBytes.length; index += 1) {
1018
+ if (bytesEqual(signerBytes[index - 1], signerBytes[index])) {
1019
+ throw new Error("Solana off-chain signers must be unique");
1020
+ }
1021
+ }
1022
+ const serializedMessage = new Uint8Array(
1023
+ SOLANA_OFFCHAIN_SIGNING_DOMAIN.length + 2 + signerBytes.length * SOLANA_PUBLIC_KEY_LENGTH + message.length
1024
+ );
1025
+ let offset = 0;
1026
+ serializedMessage.set(SOLANA_OFFCHAIN_SIGNING_DOMAIN, offset);
1027
+ offset += SOLANA_OFFCHAIN_SIGNING_DOMAIN.length;
1028
+ serializedMessage[offset] = 1;
1029
+ offset += 1;
1030
+ serializedMessage[offset] = signerBytes.length;
1031
+ offset += 1;
1032
+ for (const signer of signerBytes) {
1033
+ serializedMessage.set(signer, offset);
1034
+ offset += SOLANA_PUBLIC_KEY_LENGTH;
1035
+ }
1036
+ serializedMessage.set(message, offset);
1037
+ return {
1038
+ messageText,
1039
+ requiredSigners: signerBytes.map(bytesToHex3),
1040
+ serializedMessage
1041
+ };
1042
+ }
1043
+
571
1044
  // src/utils/deviceIdentity.ts
572
1045
  var ONEKEY_BLE_SERVICE_UUID = "00000001-0000-1000-8000-00805f9b34fb";
573
1046
  var TREZOR_BLE_SERVICE_UUID = "8c000001-a59b-4d58-a9ad-073df69fa1b1";
574
1047
  var LEDGER_USB_VENDOR_ID = 11415;
575
- var lower = (value) => _nullishCoalesce(_optionalChain([value, 'optionalAccess', _16 => _16.trim, 'call', _17 => _17(), 'access', _18 => _18.toLowerCase, 'call', _19 => _19()]), () => ( ""));
1048
+ var KEYSTONE_USB_VENDOR_ID = 4617;
1049
+ var KEYSTONE_USB_PRODUCT_ID = 12289;
1050
+ var lower = (value) => _nullishCoalesce(_optionalChain([value, 'optionalAccess', _47 => _47.trim, 'call', _48 => _48(), 'access', _49 => _49.toLowerCase, 'call', _50 => _50()]), () => ( ""));
576
1051
  var hasServiceUuid = (input, uuid) => {
577
1052
  const expected = uuid.toLowerCase();
578
1053
  const values = [
@@ -594,6 +1069,11 @@ function detectHardwareVendorFromDescriptor(input) {
594
1069
  if (typeof input.vendor === "number" && input.vendor === LEDGER_USB_VENDOR_ID || input.vendorId === LEDGER_USB_VENDOR_ID || manufacturerName.includes("ledger")) {
595
1070
  return "ledger";
596
1071
  }
1072
+ const usbVendorId = typeof input.vendor === "number" ? input.vendor : input.vendorId;
1073
+ const usbProductId = typeof input.product === "number" ? input.product : input.productId;
1074
+ if (usbVendorId === KEYSTONE_USB_VENDOR_ID && usbProductId === KEYSTONE_USB_PRODUCT_ID || manufacturerName.includes("keystone")) {
1075
+ return "keystone";
1076
+ }
597
1077
  return void 0;
598
1078
  }
599
1079
  function isKnownNonTargetHardwareVendor(input, targetVendor) {
@@ -610,35 +1090,69 @@ async function batchCall(params, callFn, onProgress) {
610
1090
  return result;
611
1091
  }
612
1092
  results.push(result.payload);
613
- _optionalChain([onProgress, 'optionalCall', _20 => _20({ index: i, total: params.length })]);
1093
+ _optionalChain([onProgress, 'optionalCall', _51 => _51({ index: i, total: params.length })]);
614
1094
  }
615
1095
  return { success: true, payload: results };
616
1096
  }
617
1097
 
618
1098
  // src/utils/methodCatalog.ts
619
1099
  var HARDWARE_METHOD_CATALOG = {
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 }
1100
+ evmGetAddress: { chain: "evm", allNetwork: true, replayAfterTransportFailure: "safe" },
1101
+ evmSignTransaction: {
1102
+ chain: "evm",
1103
+ allNetwork: false,
1104
+ replayAfterTransportFailure: "unsafe"
1105
+ },
1106
+ evmSignMessage: { chain: "evm", allNetwork: false, replayAfterTransportFailure: "unsafe" },
1107
+ evmSignTypedData: { chain: "evm", allNetwork: false, replayAfterTransportFailure: "unsafe" },
1108
+ btcGetAddress: { chain: "btc", allNetwork: true, replayAfterTransportFailure: "safe" },
1109
+ btcGetPublicKey: { chain: "btc", allNetwork: true, replayAfterTransportFailure: "safe" },
1110
+ btcSignTransaction: {
1111
+ chain: "btc",
1112
+ allNetwork: false,
1113
+ replayAfterTransportFailure: "unsafe"
1114
+ },
1115
+ btcSignPsbt: { chain: "btc", allNetwork: false, replayAfterTransportFailure: "unsafe" },
1116
+ btcSignMessage: { chain: "btc", allNetwork: false, replayAfterTransportFailure: "unsafe" },
1117
+ btcGetMasterFingerprint: {
1118
+ chain: "btc",
1119
+ allNetwork: false,
1120
+ replayAfterTransportFailure: "safe"
1121
+ },
1122
+ solGetAddress: { chain: "sol", allNetwork: true, replayAfterTransportFailure: "safe" },
1123
+ solSignTransaction: {
1124
+ chain: "sol",
1125
+ allNetwork: false,
1126
+ replayAfterTransportFailure: "unsafe"
1127
+ },
1128
+ solSignMessage: { chain: "sol", allNetwork: false, replayAfterTransportFailure: "unsafe" },
1129
+ tronGetAddress: { chain: "tron", allNetwork: true, replayAfterTransportFailure: "safe" },
1130
+ tronSignTransaction: {
1131
+ chain: "tron",
1132
+ allNetwork: false,
1133
+ replayAfterTransportFailure: "unsafe"
1134
+ },
1135
+ tronSignMessage: { chain: "tron", allNetwork: false, replayAfterTransportFailure: "unsafe" },
1136
+ zcashGetFullViewingKey: {
1137
+ chain: "zcash",
1138
+ allNetwork: false,
1139
+ replayAfterTransportFailure: "safe"
1140
+ },
1141
+ zcashGetShieldedAddress: {
1142
+ chain: "zcash",
1143
+ allNetwork: false,
1144
+ replayAfterTransportFailure: "safe"
1145
+ }
636
1146
  };
637
1147
  var ALL_NETWORK_METHOD_NAMES = Object.entries(HARDWARE_METHOD_CATALOG).filter(([, metadata]) => metadata.allNetwork).map(([method]) => method);
638
1148
  var ALL_NETWORK_METHOD_SET = new Set(ALL_NETWORK_METHOD_NAMES);
639
1149
  function getHardwareMethodMetadata(method) {
640
1150
  return HARDWARE_METHOD_CATALOG[method];
641
1151
  }
1152
+ var SAFE_NON_CHAIN_METHODS = /* @__PURE__ */ new Set(["getFeatures", "authenticateDevice"]);
1153
+ function canReplayHardwareMethodAfterTransportFailure(method) {
1154
+ return _optionalChain([getHardwareMethodMetadata, 'call', _52 => _52(method), 'optionalAccess', _53 => _53.replayAfterTransportFailure]) === "safe" || SAFE_NON_CHAIN_METHODS.has(method);
1155
+ }
642
1156
  function isAllNetworkMethodName(method) {
643
1157
  return ALL_NETWORK_METHOD_SET.has(method);
644
1158
  }
@@ -666,7 +1180,7 @@ async function runAllNetworkGetAddress({
666
1180
  continue;
667
1181
  }
668
1182
  const method = item.methodName;
669
- const unsupportedNetwork = _optionalChain([buildUnsupportedNetworkResponse, 'optionalCall', _21 => _21(item, method)]);
1183
+ const unsupportedNetwork = _optionalChain([buildUnsupportedNetworkResponse, 'optionalCall', _54 => _54(item, method)]);
670
1184
  if (unsupportedNetwork) {
671
1185
  responses.push(unsupportedNetwork);
672
1186
  continue;
@@ -766,5 +1280,26 @@ var DEVICE_CONNECT_RETRY_DELAY_MS = 1e3;
766
1280
 
767
1281
 
768
1282
 
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 = _chunkSK7ZF33Jjs.HardwareErrorCode; exports.ORPHAN_ELIGIBLE_ERROR_CODES = _chunkSK7ZF33Jjs.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 = _chunkSK7ZF33Jjs.createHwkError; exports.deriveDeviceFingerprint = deriveDeviceFingerprint; exports.detectHardwareVendorFromDescriptor = detectHardwareVendorFromDescriptor; exports.enrichErrorMessage = _chunkSK7ZF33Jjs.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;
1283
+
1284
+
1285
+
1286
+
1287
+
1288
+
1289
+
1290
+
1291
+
1292
+
1293
+
1294
+
1295
+
1296
+
1297
+
1298
+
1299
+
1300
+
1301
+
1302
+
1303
+
1304
+ 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 = _chunkZ3IH25KVjs.HardwareErrorCode; exports.OPERATION_DEFAULT_TTL_MS = OPERATION_DEFAULT_TTL_MS; exports.ORPHAN_ELIGIBLE_ERROR_CODES = _chunkZ3IH25KVjs.ORPHAN_ELIGIBLE_ERROR_CODES; exports.OperationRegistry = OperationRegistry; exports.SDK = SDK; exports.TypedEventEmitter = TypedEventEmitter; exports.UI_EVENT = _chunkS7X2HM7Pjs.UI_EVENT; exports.UI_REQUEST = _chunkS7X2HM7Pjs.UI_REQUEST; exports.UI_REQUEST_CANCELLED_TAG = _chunkS7X2HM7Pjs.UI_REQUEST_CANCELLED_TAG; exports.UI_REQUEST_DEFAULT_TIMEOUT_MS = _chunkS7X2HM7Pjs.UI_REQUEST_DEFAULT_TIMEOUT_MS; exports.UI_REQUEST_PREEMPTED_TAG = _chunkS7X2HM7Pjs.UI_REQUEST_PREEMPTED_TAG; exports.UI_REQUEST_TIMEOUT_TAG = _chunkS7X2HM7Pjs.UI_REQUEST_TIMEOUT_TAG; exports.UI_RESPONSE = _chunkS7X2HM7Pjs.UI_RESPONSE; exports.UiRequestRegistry = _chunkS7X2HM7Pjs.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 = _chunkZ3IH25KVjs.createHwkError; exports.defaultOriginForCode = _chunkZ3IH25KVjs.defaultOriginForCode; exports.defaultRecoveryForCode = _chunkZ3IH25KVjs.defaultRecoveryForCode; exports.deriveDeviceFingerprint = deriveDeviceFingerprint; exports.deriveWalletId = deriveWalletId; exports.detectHardwareVendorFromDescriptor = detectHardwareVendorFromDescriptor; exports.enrichErrorMessage = _chunk7SFFS2NLjs.enrichErrorMessage; exports.ensure0x = ensure0x; exports.failure = failure; exports.getAllNetworkMethodChain = getAllNetworkMethodChain; exports.getHardwareMethodMetadata = getHardwareMethodMetadata; exports.hasHardwareRuntimeIdPrefix = hasHardwareRuntimeIdPrefix; exports.hexToBytes = hexToBytes; exports.isAllNetworkMethodName = isAllNetworkMethodName; exports.isHardwareOperationId = isHardwareOperationId; exports.isHwkRecoveryHint = _chunkZ3IH25KVjs.isHwkRecoveryHint; exports.isKnownNonTargetHardwareVendor = isKnownNonTargetHardwareVendor; exports.operationMayHaveCompletedParams = _chunkZ3IH25KVjs.operationMayHaveCompletedParams; exports.padHex64 = padHex64; exports.parseBip32MasterFingerprint = parseBip32MasterFingerprint; exports.parseHardwareRuntimeId = parseHardwareRuntimeId; 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;
770
1305
  //# sourceMappingURL=index.js.map