@onekeyfe/hwk-keystone-adapter 1.2.5-alpha.4 → 1.2.6-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -377,6 +377,7 @@ declare class KeystoneAdapter implements IHardwareWallet {
377
377
  private _retainUsbOperation;
378
378
  private static _abortable;
379
379
  private static _throwIfAborted;
380
+ /** A response without the request's id is as unrelated as one with another id. */
380
381
  private static _assertRequestIdMatches;
381
382
  private _unsupported;
382
383
  private _errorToFailure;
package/dist/index.d.ts CHANGED
@@ -377,6 +377,7 @@ declare class KeystoneAdapter implements IHardwareWallet {
377
377
  private _retainUsbOperation;
378
378
  private static _abortable;
379
379
  private static _throwIfAborted;
380
+ /** A response without the request's id is as unrelated as one with another id. */
380
381
  private static _assertRequestIdMatches;
381
382
  private _unsupported;
382
383
  private _errorToFailure;
package/dist/index.js CHANGED
@@ -188,10 +188,9 @@ function requireSignatureBytes(hex, expectedBytes, chain) {
188
188
  }
189
189
  return hex;
190
190
  }
191
- var MISSING_MASTER_FINGERPRINT = "00000000";
192
191
  function requireBip32MasterFingerprint(value) {
193
- const fingerprint = (0, import_hwk_adapter_core.parseBip32MasterFingerprint)(value);
194
- if (!fingerprint || fingerprint === MISSING_MASTER_FINGERPRINT) {
192
+ const fingerprint = (0, import_hwk_adapter_core.parseWalletMasterFingerprint)(value);
193
+ if (!fingerprint) {
195
194
  throw new Error("Keystone master fingerprint must be exactly 4 bytes (8 hex characters)");
196
195
  }
197
196
  return fingerprint;
@@ -532,7 +531,7 @@ function keystoneQueueKey(connectId, deviceId) {
532
531
  }
533
532
  function keystoneMfpFromIdentifier(identifier) {
534
533
  const value = identifier.startsWith(KEYSTONE_WALLET_CONNECT_ID_PREFIX) ? identifier.slice(KEYSTONE_WALLET_CONNECT_ID_PREFIX.length) : identifier;
535
- return (0, import_hwk_adapter_core2.parseBip32MasterFingerprint)(value);
534
+ return (0, import_hwk_adapter_core2.parseWalletMasterFingerprint)(value);
536
535
  }
537
536
  function keystoneCancelQueueKeys(identifiers) {
538
537
  const keys = /* @__PURE__ */ new Set();
@@ -1837,11 +1836,12 @@ var KeystoneAdapter = class _KeystoneAdapter {
1837
1836
  sessionId = session.sessionId;
1838
1837
  _KeystoneAdapter._throwIfAborted(signal);
1839
1838
  const raw = session.deviceInfo.raw;
1840
- const mfpValue = (0, import_hwk_adapter_core3.parseBip32MasterFingerprint)(raw?.masterFingerprint);
1839
+ const mfpValue = (0, import_hwk_adapter_core3.parseWalletMasterFingerprint)(raw?.masterFingerprint);
1841
1840
  if (!mfpValue) {
1841
+ const empty = (0, import_hwk_adapter_core3.parseBip32MasterFingerprint)(raw?.masterFingerprint) === import_hwk_adapter_core3.MISSING_BIP32_MASTER_FINGERPRINT;
1842
1842
  throw (0, import_hwk_adapter_core3.createHwkError)({
1843
- code: import_hwk_adapter_core3.HardwareErrorCode.DeviceMismatch,
1844
- message: "Keystone USB did not report a master fingerprint"
1843
+ code: empty ? import_hwk_adapter_core3.HardwareErrorCode.DeviceNotInitialized : import_hwk_adapter_core3.HardwareErrorCode.DeviceMismatch,
1844
+ message: empty ? "Keystone has no wallet yet; it reported an empty master fingerprint" : "Keystone USB did not report a master fingerprint"
1845
1845
  });
1846
1846
  }
1847
1847
  const masterFingerprint = mfpValue.toLowerCase();
@@ -2308,11 +2308,12 @@ var KeystoneAdapter = class _KeystoneAdapter {
2308
2308
  throw signal.reason instanceof Error ? signal.reason : new Error("Operation aborted");
2309
2309
  }
2310
2310
  }
2311
+ /** A response without the request's id is as unrelated as one with another id. */
2311
2312
  static _assertRequestIdMatches(expected, actual) {
2312
- if (actual && actual.toLowerCase() !== expected.toLowerCase()) {
2313
+ if (!actual || actual.toLowerCase() !== expected.toLowerCase()) {
2313
2314
  throw (0, import_hwk_adapter_core3.createHwkError)({
2314
2315
  code: import_hwk_adapter_core3.HardwareErrorCode.DeviceMismatch,
2315
- message: "Keystone response requestId does not match the pending request \u2014 discarding a stale or unrelated scan"
2316
+ message: actual ? "Keystone response requestId does not match the pending request \u2014 discarding a stale or unrelated scan" : "Keystone response carries no requestId \u2014 discarding a stale or unrelated scan"
2316
2317
  });
2317
2318
  }
2318
2319
  }