@onekeyfe/hwk-ledger-adapter 1.1.26-patch.1 → 1.1.26-patch.2
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 +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +9 -20
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +9 -20
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -1025,12 +1025,6 @@ var _LedgerAdapter = class _LedgerAdapter {
|
|
|
1025
1025
|
throw new Error("_doConnect aborted");
|
|
1026
1026
|
}
|
|
1027
1027
|
async _connectFirstOrSelect(devices, targetConnectId) {
|
|
1028
|
-
if (!isLedgerBleConnectionType(this.connector.connectionType) && devices.length > 1) {
|
|
1029
|
-
debugLog(
|
|
1030
|
-
`[DMK] Multiple Ledger USB devices found (${devices.length}); refusing to auto-select by ephemeral connectId.`
|
|
1031
|
-
);
|
|
1032
|
-
throw createMultipleUsbLedgerDevicesError();
|
|
1033
|
-
}
|
|
1034
1028
|
if (targetConnectId) {
|
|
1035
1029
|
const target = devices.find(
|
|
1036
1030
|
(d) => d.connectId === targetConnectId || d.deviceId === targetConnectId
|
|
@@ -1057,6 +1051,9 @@ var _LedgerAdapter = class _LedgerAdapter {
|
|
|
1057
1051
|
code: HardwareErrorCode2.DeviceNotFound
|
|
1058
1052
|
});
|
|
1059
1053
|
}
|
|
1054
|
+
if (devices.length > 1) {
|
|
1055
|
+
throw createMultipleUsbLedgerDevicesError();
|
|
1056
|
+
}
|
|
1060
1057
|
if (devices.length !== 1) {
|
|
1061
1058
|
throw Object.assign(new Error("Ledger device not found."), {
|
|
1062
1059
|
code: HardwareErrorCode2.DeviceNotFound
|
|
@@ -3052,22 +3049,18 @@ var LedgerConnectorBase = class {
|
|
|
3052
3049
|
}
|
|
3053
3050
|
return descriptors;
|
|
3054
3051
|
}
|
|
3055
|
-
_assertSingleUsbDescriptor(descriptors) {
|
|
3056
|
-
if (isLedgerBleConnectionType(this.connectionType) || descriptors.length <= 1) {
|
|
3057
|
-
return;
|
|
3058
|
-
}
|
|
3059
|
-
debugLog(
|
|
3060
|
-
`[DMK] Multiple Ledger USB devices found (${descriptors.length}); refusing to choose by ephemeral path. paths=[${descriptors.map((d) => d.path).join(",")}]`
|
|
3061
|
-
);
|
|
3062
|
-
throw createMultipleUsbLedgerDevicesError();
|
|
3063
|
-
}
|
|
3064
3052
|
// ---------------------------------------------------------------------------
|
|
3065
3053
|
// IConnector -- Device discovery
|
|
3054
|
+
//
|
|
3055
|
+
// Discovery never throws on multiple USB devices — it returns the full list.
|
|
3056
|
+
// The "connect exactly one device" rule is enforced upstream: an explicit
|
|
3057
|
+
// connectId connects that device (or fails as not-found), and only the
|
|
3058
|
+
// no-connectId USB path rejects when more than one device is present
|
|
3059
|
+
// (see LedgerAdapter._connectFirstOrSelect).
|
|
3066
3060
|
// ---------------------------------------------------------------------------
|
|
3067
3061
|
async searchDevices() {
|
|
3068
3062
|
const dm = await this._getDeviceManager();
|
|
3069
3063
|
const descriptors = await this._discoverDescriptors(dm);
|
|
3070
|
-
this._assertSingleUsbDescriptor(descriptors);
|
|
3071
3064
|
const resolvedDescriptors = descriptors.map((d) => ({
|
|
3072
3065
|
descriptor: d,
|
|
3073
3066
|
connectId: this._resolveConnectId(d)
|
|
@@ -3093,10 +3086,6 @@ var LedgerConnectorBase = class {
|
|
|
3093
3086
|
async connect(deviceId) {
|
|
3094
3087
|
const callerSuppliedConnectId = Boolean(deviceId);
|
|
3095
3088
|
let targetPath = deviceId;
|
|
3096
|
-
if (callerSuppliedConnectId && !isLedgerBleConnectionType(this.connectionType)) {
|
|
3097
|
-
const dm = await this._getDeviceManager();
|
|
3098
|
-
this._assertSingleUsbDescriptor(await this._discoverDescriptors(dm));
|
|
3099
|
-
}
|
|
3100
3089
|
if (!targetPath) {
|
|
3101
3090
|
const discovered = await this.searchDevices();
|
|
3102
3091
|
if (discovered.length === 0) {
|