@onekeyfe/hwk-keystone-adapter 1.2.8-alpha.50 → 1.2.8-alpha.53

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
@@ -422,8 +422,9 @@ declare class KeystoneAdapter implements IHardwareWallet {
422
422
  /** Always returns an `m/`-prefixed path, regardless of the input's casing/prefix. */
423
423
  declare function normalizePath(path: string): string;
424
424
  /**
425
- * Splits a 5-segment BIP-44 leaf path into the 3-segment account path and the relative
426
- * `change/index`; a path of 3 or fewer segments is already an account path.
425
+ * Splits a leaf path after its last hardened segment: the account path is what Keystone exports,
426
+ * the unhardened rest is derived from it offline (`change/index`, or a bare `index` for Ledger
427
+ * Legacy `m/44'/60'/0'/<index>`). A path of 3 or fewer segments is already an account path.
427
428
  */
428
429
  declare function splitAccountPath(path: string): {
429
430
  accountPath: string;
package/dist/index.d.ts CHANGED
@@ -422,8 +422,9 @@ declare class KeystoneAdapter implements IHardwareWallet {
422
422
  /** Always returns an `m/`-prefixed path, regardless of the input's casing/prefix. */
423
423
  declare function normalizePath(path: string): string;
424
424
  /**
425
- * Splits a 5-segment BIP-44 leaf path into the 3-segment account path and the relative
426
- * `change/index`; a path of 3 or fewer segments is already an account path.
425
+ * Splits a leaf path after its last hardened segment: the account path is what Keystone exports,
426
+ * the unhardened rest is derived from it offline (`change/index`, or a bare `index` for Ledger
427
+ * Legacy `m/44'/60'/0'/<index>`). A path of 3 or fewer segments is already an account path.
427
428
  */
428
429
  declare function splitAccountPath(path: string): {
429
430
  accountPath: string;
package/dist/index.js CHANGED
@@ -479,11 +479,15 @@ function isBip32Path(path) {
479
479
  function splitAccountPath(path) {
480
480
  const normalized = normalizePath(path);
481
481
  const segments = normalized.slice(2).split("/");
482
- if (segments.length <= 3) {
482
+ let accountLength = 0;
483
+ segments.forEach((segment, index) => {
484
+ if (segment.endsWith("'")) accountLength = index + 1;
485
+ });
486
+ if (segments.length <= 3 || accountLength === 0 || accountLength === segments.length) {
483
487
  return { accountPath: normalized, relativeDerivePath: "" };
484
488
  }
485
- const accountSegments = segments.slice(0, segments.length - 2);
486
- const relativeSegments = segments.slice(segments.length - 2);
489
+ const accountSegments = segments.slice(0, accountLength);
490
+ const relativeSegments = segments.slice(accountLength);
487
491
  return {
488
492
  accountPath: `m/${accountSegments.join("/")}`,
489
493
  relativeDerivePath: relativeSegments.join("/")
@@ -1875,7 +1879,18 @@ var KeystoneAdapter = class _KeystoneAdapter {
1875
1879
  signal.addEventListener("abort", onAbort, { once: true });
1876
1880
  const pending = this._usbConnectTail.then(async () => {
1877
1881
  _KeystoneAdapter._throwIfAborted(signal);
1878
- return this._connectUsbExclusive(connector, expected, searchTargetId, signal);
1882
+ if (this._unsettledUsbOperations.size > 0) {
1883
+ return (0, import_hwk_adapter_core3.failure)(
1884
+ import_hwk_adapter_core3.HardwareErrorCode.DeviceBusyInternal,
1885
+ "Keystone USB is still finishing an earlier request"
1886
+ );
1887
+ }
1888
+ const releaseConnect = this._retainUsbOperation("connect");
1889
+ try {
1890
+ return await this._connectUsbExclusive(connector, expected, searchTargetId, signal);
1891
+ } finally {
1892
+ releaseConnect();
1893
+ }
1879
1894
  });
1880
1895
  const settled = pending.finally(() => {
1881
1896
  signal.removeEventListener("abort", onAbort);