@onekeyfe/hwk-keystone-adapter 1.2.8-alpha.124 → 1.2.8-alpha.125

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
@@ -1946,9 +1946,20 @@ var KeystoneAdapter = class _KeystoneAdapter {
1946
1946
  message: "Account export contains an invalid derivation path"
1947
1947
  });
1948
1948
  }
1949
- for (const schema of schemas) {
1949
+ const usableSchemas = schemas.filter(
1950
+ (schema) => !firmware || firmware.supportedChains.includes(schema.hwkChain)
1951
+ );
1952
+ const isColdStart = !target.expectedMasterFingerprint;
1953
+ if (firmware && isColdStart && !responseUr.accountExport && !usableSchemas.length) {
1954
+ throw createHwkError2({
1955
+ code: HardwareErrorCode2.ChainNotSupported,
1956
+ message: `Keystone ${firmware.variant} firmware cannot use any requested chain`,
1957
+ params: { firmwareVariant: firmware.variant }
1958
+ });
1959
+ }
1960
+ for (const schema of usableSchemas) {
1950
1961
  const exported = responseUr.accountExport ? parsed.accounts.find((account) => normalizePath(account.path) === schema.path) : requireExportedPath(parsed, schema.path);
1951
- if (exported && (!responseUr.accountExport || !firmware || firmware.supportedChains.includes(schema.hwkChain))) {
1962
+ if (exported) {
1952
1963
  scanned.set(accountKey(schema.hwkChain, schema.path), {
1953
1964
  ...exported,
1954
1965
  hwkChain: schema.hwkChain
@@ -2388,13 +2399,13 @@ var KeystoneAdapter = class _KeystoneAdapter {
2388
2399
  params: { reason: "account-not-exported" }
2389
2400
  });
2390
2401
  }
2402
+ this._assertQrChainSupported(bundle.firmwareVersion, hwkChain);
2391
2403
  if (!target.record || !scanned) {
2392
2404
  throw createHwkError2({
2393
2405
  code: HardwareErrorCode2.DeviceMismatch,
2394
2406
  message: `Keystone did not return the requested derivation path (${syncPath})`
2395
2407
  });
2396
2408
  }
2397
- this._assertQrChainSupported(bundle.firmwareVersion, hwkChain);
2398
2409
  return { record: target.record, account: scanned };
2399
2410
  }
2400
2411
  if (bundle?.channel === "usb" && target.record?.usbSessionId !== bundle.usbSessionId) {
@@ -2457,7 +2468,7 @@ var KeystoneAdapter = class _KeystoneAdapter {
2457
2468
  const responseUr = await this._resolveUr(void 0, requestUr, false, connectId, signal);
2458
2469
  _KeystoneAdapter._throwIfAborted(signal);
2459
2470
  const parsed = responseUr.accountExport ? this.urEngine.parseAccountExport(responseUr) : this.urEngine.parseAccountResponse(responseUr);
2460
- requireExportedPath(parsed, normalizePath(accountPath), responseUr.accountExport);
2471
+ if (!responseUr.accountExport) requireExportedPath(parsed, normalizePath(accountPath));
2461
2472
  this._assertQrChainSupported(parsed.deviceVersion, chain);
2462
2473
  const record = this._upsertDeviceRecord(parsed);
2463
2474
  return { record };