@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.d.mts CHANGED
@@ -220,11 +220,6 @@ type BundleAccess = {
220
220
  } | {
221
221
  channel: 'usb';
222
222
  usbSessionId: string;
223
- qrFallback: QrFallbackChoice;
224
- };
225
- /** The answer to "show it as a QR?" for a request USB cannot carry; a bundle asks only once. */
226
- type QrFallbackChoice = {
227
- confirmed?: boolean;
228
223
  };
229
224
  interface ImportFromQrOptions {
230
225
  /**
@@ -411,11 +406,6 @@ declare class KeystoneAdapter implements IHardwareWallet {
411
406
  * a cancel reach the wait before the QR timeout.
412
407
  */
413
408
  private _awaitQrResponse;
414
- /**
415
- * Asks whether a request too large for USB may be shown as a QR. A timeout or an unanswered
416
- * prompt reads as no; a cancelled call keeps its own error.
417
- */
418
- private _confirmQrFallback;
419
409
  /** Shows `data` for the device to scan, or with no `data` asks the host to scan the device. */
420
410
  private _requestQrAndAwaitResponse;
421
411
  private _callUsbResolveUr;
package/dist/index.d.ts CHANGED
@@ -220,11 +220,6 @@ type BundleAccess = {
220
220
  } | {
221
221
  channel: 'usb';
222
222
  usbSessionId: string;
223
- qrFallback: QrFallbackChoice;
224
- };
225
- /** The answer to "show it as a QR?" for a request USB cannot carry; a bundle asks only once. */
226
- type QrFallbackChoice = {
227
- confirmed?: boolean;
228
223
  };
229
224
  interface ImportFromQrOptions {
230
225
  /**
@@ -411,11 +406,6 @@ declare class KeystoneAdapter implements IHardwareWallet {
411
406
  * a cancel reach the wait before the QR timeout.
412
407
  */
413
408
  private _awaitQrResponse;
414
- /**
415
- * Asks whether a request too large for USB may be shown as a QR. A timeout or an unanswered
416
- * prompt reads as no; a cancelled call keeps its own error.
417
- */
418
- private _confirmQrFallback;
419
409
  /** Shows `data` for the device to scan, or with no `data` asks the host to scan the device. */
420
410
  private _requestQrAndAwaitResponse;
421
411
  private _callUsbResolveUr;
package/dist/index.js CHANGED
@@ -607,7 +607,6 @@ function keystoneBtcParamsFailure(params) {
607
607
  }
608
608
  return void 0;
609
609
  }
610
- var KEYSTONE_MAX_KEY_DERIVATION_SCHEMAS = 24;
611
610
  var KEYSTONE_USB_REATTACH_PROBE_ATTEMPTS = 4;
612
611
  var KEYSTONE_USB_REATTACH_PROBE_INTERVAL_MS = 500;
613
612
  var CHAIN_TYPE_BY_CHAIN = {
@@ -1767,7 +1766,7 @@ var KeystoneAdapter = class _KeystoneAdapter {
1767
1766
  }
1768
1767
  if (this._forcedTransport !== "qr" && !routedToQr && record?.usbSessionId) {
1769
1768
  return {
1770
- access: { channel: "usb", usbSessionId: record.usbSessionId, qrFallback: {} },
1769
+ access: { channel: "usb", usbSessionId: record.usbSessionId },
1771
1770
  masterFingerprint: record.masterFingerprint
1772
1771
  };
1773
1772
  }
@@ -1778,13 +1777,6 @@ var KeystoneAdapter = class _KeystoneAdapter {
1778
1777
  });
1779
1778
  }
1780
1779
  const schemas = Array.from(requestedByKey.values());
1781
- if (schemas.length > KEYSTONE_MAX_KEY_DERIVATION_SCHEMAS) {
1782
- throw (0, import_hwk_adapter_core3.createHwkError)({
1783
- code: import_hwk_adapter_core3.HardwareErrorCode.QrRequestTooLarge,
1784
- message: `Keystone accepts at most ${KEYSTONE_MAX_KEY_DERIVATION_SCHEMAS} account paths per QR request; this one needs ${schemas.length}`,
1785
- params: { limit: KEYSTONE_MAX_KEY_DERIVATION_SCHEMAS, requested: schemas.length }
1786
- });
1787
- }
1788
1780
  const requestUr = this.urEngine.buildKeyDerivationRequest({
1789
1781
  schemas: schemas.map((schema) => keySchema(schema.hwkChain, schema.path)),
1790
1782
  origin: this._origin
@@ -2045,7 +2037,7 @@ var KeystoneAdapter = class _KeystoneAdapter {
2045
2037
  * Decides QR vs USB for one UR round trip. A pinned 'usb' with no live session reattaches once
2046
2038
  * and fails closed if that fails; otherwise a failed USB reattach leaves the call on QR.
2047
2039
  */
2048
- async _resolveUr(record, requestUr, animated, operationId, signal, operationName, qrFallback) {
2040
+ async _resolveUr(record, requestUr, animated, operationId, signal, operationName) {
2049
2041
  const releaseOperationRetention = (0, import_hwk_adapter_core3.isHardwareOperationId)(operationId) ? this._operations.retain(operationId) : void 0;
2050
2042
  try {
2051
2043
  return await this._resolveUrWithRoute(
@@ -2054,14 +2046,13 @@ var KeystoneAdapter = class _KeystoneAdapter {
2054
2046
  animated,
2055
2047
  operationId,
2056
2048
  signal,
2057
- operationName,
2058
- qrFallback
2049
+ operationName
2059
2050
  );
2060
2051
  } finally {
2061
2052
  releaseOperationRetention?.();
2062
2053
  }
2063
2054
  }
2064
- async _resolveUrWithRoute(callerRecord, requestUr, animated, operationId, signal, operationName, qrFallback) {
2055
+ async _resolveUrWithRoute(callerRecord, requestUr, animated, operationId, signal, operationName) {
2065
2056
  let record = callerRecord;
2066
2057
  let interactionRoute;
2067
2058
  if ((0, import_hwk_adapter_core3.isHardwareOperationId)(operationId)) {
@@ -2105,12 +2096,6 @@ var KeystoneAdapter = class _KeystoneAdapter {
2105
2096
  const { origin: usbErrorOrigin, code: usbErrorCode } = usbError;
2106
2097
  if (usbErrorCode === import_hwk_adapter_core3.HardwareErrorCode.PayloadTooLarge && usbErrorOrigin !== "device") {
2107
2098
  if (!interactionRoute && !this._forcedTransport) {
2108
- if (!await this._confirmQrFallback(signal, qrFallback)) {
2109
- throw (0, import_hwk_adapter_core3.createHwkError)({
2110
- code: import_hwk_adapter_core3.HardwareErrorCode.UserAborted,
2111
- message: "User declined to show the request too large for USB as a QR code"
2112
- });
2113
- }
2114
2099
  const displayDevice2 = toDeviceInfo(record);
2115
2100
  return this._requestQrAndAwaitResponse(displayDevice2, { ...requestUr, animated }, signal);
2116
2101
  }
@@ -2215,15 +2200,7 @@ var KeystoneAdapter = class _KeystoneAdapter {
2215
2200
  const useSinglePathUsbExport = operationConnectionType ? operationConnectionType === "usb" : this._forcedTransport === "usb" || this._forcedTransport !== "qr" && Boolean(existingRecord?.usbSessionId);
2216
2201
  const schemas = [keySchema(hwkChain, syncPath)];
2217
2202
  const requestUr = this.urEngine.buildKeyDerivationRequest({ schemas, origin: this._origin });
2218
- const responseUr = await this._resolveUr(
2219
- existingRecord,
2220
- requestUr,
2221
- false,
2222
- connectId,
2223
- signal,
2224
- void 0,
2225
- bundle?.channel === "usb" ? bundle.qrFallback : void 0
2226
- );
2203
+ const responseUr = await this._resolveUr(existingRecord, requestUr, false, connectId, signal);
2227
2204
  _KeystoneAdapter._throwIfAborted(signal);
2228
2205
  const parsed = this.urEngine.parseAccountResponse(responseUr);
2229
2206
  const account = requireExportedPath(parsed, syncPath);
@@ -2309,37 +2286,6 @@ var KeystoneAdapter = class _KeystoneAdapter {
2309
2286
  signal.removeEventListener("abort", onAbort);
2310
2287
  }
2311
2288
  }
2312
- /**
2313
- * Asks whether a request too large for USB may be shown as a QR. A timeout or an unanswered
2314
- * prompt reads as no; a cancelled call keeps its own error.
2315
- */
2316
- async _confirmQrFallback(signal, choice) {
2317
- if (choice?.confirmed !== void 0) return choice.confirmed;
2318
- const requestType = import_hwk_adapter_core3.UI_REQUEST.REQUEST_QR_FALLBACK_CONFIRM;
2319
- const operationId = this._activeOperationId();
2320
- const release = operationId ? this._operations.retain(operationId) : void 0;
2321
- try {
2322
- const waitPromise = this._uiRegistry.wait(requestType, {
2323
- operationId
2324
- });
2325
- this.emitter.emit(requestType, {
2326
- type: requestType,
2327
- payload: { vendor: "keystone", operationId }
2328
- });
2329
- let confirmed = false;
2330
- try {
2331
- confirmed = Boolean(
2332
- (await this._awaitQrResponse(requestType, waitPromise, signal))?.confirmed
2333
- );
2334
- } catch (error) {
2335
- if (signal.aborted) throw error;
2336
- }
2337
- if (choice) choice.confirmed = confirmed;
2338
- return confirmed;
2339
- } finally {
2340
- release?.();
2341
- }
2342
- }
2343
2289
  /** Shows `data` for the device to scan, or with no `data` asks the host to scan the device. */
2344
2290
  async _requestQrAndAwaitResponse(device, data, signal) {
2345
2291
  const requestType = data ? import_hwk_adapter_core3.UI_REQUEST.REQUEST_QR_DISPLAY : import_hwk_adapter_core3.UI_REQUEST.REQUEST_QR_SCAN;