@onekeyfe/hwk-keystone-adapter 1.2.8-alpha.114 → 1.2.8-alpha.115

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.
package/dist/index.mjs CHANGED
@@ -615,7 +615,6 @@ function keystoneBtcParamsFailure(params) {
615
615
  }
616
616
  return void 0;
617
617
  }
618
- var KEYSTONE_MAX_KEY_DERIVATION_SCHEMAS = 24;
619
618
  var KEYSTONE_USB_REATTACH_PROBE_ATTEMPTS = 4;
620
619
  var KEYSTONE_USB_REATTACH_PROBE_INTERVAL_MS = 500;
621
620
  var CHAIN_TYPE_BY_CHAIN = {
@@ -1775,7 +1774,7 @@ var KeystoneAdapter = class _KeystoneAdapter {
1775
1774
  }
1776
1775
  if (this._forcedTransport !== "qr" && !routedToQr && record?.usbSessionId) {
1777
1776
  return {
1778
- access: { channel: "usb", usbSessionId: record.usbSessionId, qrFallback: {} },
1777
+ access: { channel: "usb", usbSessionId: record.usbSessionId },
1779
1778
  masterFingerprint: record.masterFingerprint
1780
1779
  };
1781
1780
  }
@@ -1786,13 +1785,6 @@ var KeystoneAdapter = class _KeystoneAdapter {
1786
1785
  });
1787
1786
  }
1788
1787
  const schemas = Array.from(requestedByKey.values());
1789
- if (schemas.length > KEYSTONE_MAX_KEY_DERIVATION_SCHEMAS) {
1790
- throw createHwkError2({
1791
- code: HardwareErrorCode2.QrRequestTooLarge,
1792
- message: `Keystone accepts at most ${KEYSTONE_MAX_KEY_DERIVATION_SCHEMAS} account paths per QR request; this one needs ${schemas.length}`,
1793
- params: { limit: KEYSTONE_MAX_KEY_DERIVATION_SCHEMAS, requested: schemas.length }
1794
- });
1795
- }
1796
1788
  const requestUr = this.urEngine.buildKeyDerivationRequest({
1797
1789
  schemas: schemas.map((schema) => keySchema(schema.hwkChain, schema.path)),
1798
1790
  origin: this._origin
@@ -2053,7 +2045,7 @@ var KeystoneAdapter = class _KeystoneAdapter {
2053
2045
  * Decides QR vs USB for one UR round trip. A pinned 'usb' with no live session reattaches once
2054
2046
  * and fails closed if that fails; otherwise a failed USB reattach leaves the call on QR.
2055
2047
  */
2056
- async _resolveUr(record, requestUr, animated, operationId, signal, operationName, qrFallback) {
2048
+ async _resolveUr(record, requestUr, animated, operationId, signal, operationName) {
2057
2049
  const releaseOperationRetention = isHardwareOperationId2(operationId) ? this._operations.retain(operationId) : void 0;
2058
2050
  try {
2059
2051
  return await this._resolveUrWithRoute(
@@ -2062,14 +2054,13 @@ var KeystoneAdapter = class _KeystoneAdapter {
2062
2054
  animated,
2063
2055
  operationId,
2064
2056
  signal,
2065
- operationName,
2066
- qrFallback
2057
+ operationName
2067
2058
  );
2068
2059
  } finally {
2069
2060
  releaseOperationRetention?.();
2070
2061
  }
2071
2062
  }
2072
- async _resolveUrWithRoute(callerRecord, requestUr, animated, operationId, signal, operationName, qrFallback) {
2063
+ async _resolveUrWithRoute(callerRecord, requestUr, animated, operationId, signal, operationName) {
2073
2064
  let record = callerRecord;
2074
2065
  let interactionRoute;
2075
2066
  if (isHardwareOperationId2(operationId)) {
@@ -2113,12 +2104,6 @@ var KeystoneAdapter = class _KeystoneAdapter {
2113
2104
  const { origin: usbErrorOrigin, code: usbErrorCode } = usbError;
2114
2105
  if (usbErrorCode === HardwareErrorCode2.PayloadTooLarge && usbErrorOrigin !== "device") {
2115
2106
  if (!interactionRoute && !this._forcedTransport) {
2116
- if (!await this._confirmQrFallback(signal, qrFallback)) {
2117
- throw createHwkError2({
2118
- code: HardwareErrorCode2.UserAborted,
2119
- message: "User declined to show the request too large for USB as a QR code"
2120
- });
2121
- }
2122
2107
  const displayDevice2 = toDeviceInfo(record);
2123
2108
  return this._requestQrAndAwaitResponse(displayDevice2, { ...requestUr, animated }, signal);
2124
2109
  }
@@ -2223,15 +2208,7 @@ var KeystoneAdapter = class _KeystoneAdapter {
2223
2208
  const useSinglePathUsbExport = operationConnectionType ? operationConnectionType === "usb" : this._forcedTransport === "usb" || this._forcedTransport !== "qr" && Boolean(existingRecord?.usbSessionId);
2224
2209
  const schemas = [keySchema(hwkChain, syncPath)];
2225
2210
  const requestUr = this.urEngine.buildKeyDerivationRequest({ schemas, origin: this._origin });
2226
- const responseUr = await this._resolveUr(
2227
- existingRecord,
2228
- requestUr,
2229
- false,
2230
- connectId,
2231
- signal,
2232
- void 0,
2233
- bundle?.channel === "usb" ? bundle.qrFallback : void 0
2234
- );
2211
+ const responseUr = await this._resolveUr(existingRecord, requestUr, false, connectId, signal);
2235
2212
  _KeystoneAdapter._throwIfAborted(signal);
2236
2213
  const parsed = this.urEngine.parseAccountResponse(responseUr);
2237
2214
  const account = requireExportedPath(parsed, syncPath);
@@ -2317,37 +2294,6 @@ var KeystoneAdapter = class _KeystoneAdapter {
2317
2294
  signal.removeEventListener("abort", onAbort);
2318
2295
  }
2319
2296
  }
2320
- /**
2321
- * Asks whether a request too large for USB may be shown as a QR. A timeout or an unanswered
2322
- * prompt reads as no; a cancelled call keeps its own error.
2323
- */
2324
- async _confirmQrFallback(signal, choice) {
2325
- if (choice?.confirmed !== void 0) return choice.confirmed;
2326
- const requestType = UI_REQUEST.REQUEST_QR_FALLBACK_CONFIRM;
2327
- const operationId = this._activeOperationId();
2328
- const release = operationId ? this._operations.retain(operationId) : void 0;
2329
- try {
2330
- const waitPromise = this._uiRegistry.wait(requestType, {
2331
- operationId
2332
- });
2333
- this.emitter.emit(requestType, {
2334
- type: requestType,
2335
- payload: { vendor: "keystone", operationId }
2336
- });
2337
- let confirmed = false;
2338
- try {
2339
- confirmed = Boolean(
2340
- (await this._awaitQrResponse(requestType, waitPromise, signal))?.confirmed
2341
- );
2342
- } catch (error) {
2343
- if (signal.aborted) throw error;
2344
- }
2345
- if (choice) choice.confirmed = confirmed;
2346
- return confirmed;
2347
- } finally {
2348
- release?.();
2349
- }
2350
- }
2351
2297
  /** Shows `data` for the device to scan, or with no `data` asks the host to scan the device. */
2352
2298
  async _requestQrAndAwaitResponse(device, data, signal) {
2353
2299
  const requestType = data ? UI_REQUEST.REQUEST_QR_DISPLAY : UI_REQUEST.REQUEST_QR_SCAN;