@onekeyfe/hwk-ledger-adapter 1.2.8-alpha.127 → 1.2.8-alpha.129
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.js +23 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +23 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -916,6 +916,12 @@ function isLostConnectionError(err) {
|
|
|
916
916
|
return isDeviceDisconnectedError(err) || isDeviceNotAdvertisingError(err) || isTimeoutError(err) || isConnectionLevelError(err);
|
|
917
917
|
}
|
|
918
918
|
var BTC_HIGH_INDEX_THRESHOLD = 100;
|
|
919
|
+
var APP_MANAGEMENT_METHODS = /* @__PURE__ */ new Set([
|
|
920
|
+
"installApp",
|
|
921
|
+
"listInstalledApps",
|
|
922
|
+
"listInstalledNames",
|
|
923
|
+
"listAvailableApps"
|
|
924
|
+
]);
|
|
919
925
|
function btcAccountIndexFromPath(path) {
|
|
920
926
|
const segments = path.replace(/^m\//, "").split("/");
|
|
921
927
|
if (segments.length < 3) return null;
|
|
@@ -2424,7 +2430,7 @@ var _LedgerAdapter = class _LedgerAdapter {
|
|
|
2424
2430
|
(connection) => connection.transport === "usb"
|
|
2425
2431
|
);
|
|
2426
2432
|
const usbTarget = knownUsb?.transport === "usb" ? knownUsb.connectId : usbDevices.find((device) => device.connectId === targetConnectId)?.connectId;
|
|
2427
|
-
if (usbDevices.length > 0 && (usbTarget || !targetConnectId || allowUsbEphemeralFallback)) {
|
|
2433
|
+
if (usbDevices.length > 0 && (usbTarget || !targetConnectId || allowUsbEphemeralFallback || context?.takesPluggedUsb)) {
|
|
2428
2434
|
return this._connectFirstOrSelect(
|
|
2429
2435
|
usbDevices,
|
|
2430
2436
|
usbTarget,
|
|
@@ -2889,7 +2895,8 @@ var _LedgerAdapter = class _LedgerAdapter {
|
|
|
2889
2895
|
/** Actual work done under the job queue — connection, fingerprint, call, and recovery. */
|
|
2890
2896
|
async _runConnectorCall(connectId, method, params, signal, fingerprint, permissionDeviceId, commonParams, installContext, operationId, lockedRetryBudget = _LedgerAdapter.MAX_BUSINESS_RETRY_BUDGET) {
|
|
2891
2897
|
_LedgerAdapter._throwIfAborted(signal);
|
|
2892
|
-
|
|
2898
|
+
const resolvesAppManagementTransport = APP_MANAGEMENT_METHODS.has(method) && this.connector.availableTransports?.includes("usb") && this.connector.availableTransports.includes("ble");
|
|
2899
|
+
if (!operationId && !resolvesAppManagementTransport) {
|
|
2893
2900
|
await this._ensureDevicePermission(
|
|
2894
2901
|
connectId,
|
|
2895
2902
|
permissionDeviceId ?? fingerprint?.deviceId,
|
|
@@ -2922,7 +2929,8 @@ var _LedgerAdapter = class _LedgerAdapter {
|
|
|
2922
2929
|
);
|
|
2923
2930
|
const connectionAttempt = {
|
|
2924
2931
|
...commonParams,
|
|
2925
|
-
deferBindingSave: checksWallet
|
|
2932
|
+
deferBindingSave: checksWallet,
|
|
2933
|
+
...APP_MANAGEMENT_METHODS.has(method) ? { takesPluggedUsb: true } : {}
|
|
2926
2934
|
};
|
|
2927
2935
|
const bundleConnection = installContext?.connection;
|
|
2928
2936
|
if (bundleConnection && this._sessions.get(bundleConnection.connectId) !== bundleConnection.sessionId) {
|
|
@@ -2962,6 +2970,16 @@ var _LedgerAdapter = class _LedgerAdapter {
|
|
|
2962
2970
|
_tag: ERROR_TAG.DeviceSessionNotFound
|
|
2963
2971
|
});
|
|
2964
2972
|
}
|
|
2973
|
+
if (!operationId && resolvesAppManagementTransport) {
|
|
2974
|
+
const transport = this._sessionTransports.get(sessionId);
|
|
2975
|
+
await this._ensureDevicePermission(
|
|
2976
|
+
resolvedConnectId,
|
|
2977
|
+
permissionDeviceId ?? fingerprint?.deviceId,
|
|
2978
|
+
signal,
|
|
2979
|
+
transport && (isLedgerBleConnectionType(transport) ? "ble" : "hid")
|
|
2980
|
+
);
|
|
2981
|
+
_LedgerAdapter._throwIfAborted(signal);
|
|
2982
|
+
}
|
|
2965
2983
|
try {
|
|
2966
2984
|
const isBleSession = this._sessionTransports.get(sessionId) === "ble";
|
|
2967
2985
|
if (!operationId && connectionAttempt.pendingBinding) {
|
|
@@ -3194,11 +3212,11 @@ var _LedgerAdapter = class _LedgerAdapter {
|
|
|
3194
3212
|
* Ensure OS-level Bluetooth/USB permission; times out after 60s if the host never
|
|
3195
3213
|
* replies. Without connectId the request is environment-level, else device-level.
|
|
3196
3214
|
*/
|
|
3197
|
-
async _ensureDevicePermission(connectId, deviceId, signal) {
|
|
3215
|
+
async _ensureDevicePermission(connectId, deviceId, signal, transportOverride) {
|
|
3198
3216
|
if (signal?.aborted) {
|
|
3199
3217
|
_LedgerAdapter._throwIfAborted(signal);
|
|
3200
3218
|
}
|
|
3201
|
-
const transportType = this.activeTransport ?? "hid";
|
|
3219
|
+
const transportType = transportOverride ?? this.activeTransport ?? "hid";
|
|
3202
3220
|
const operationId = this._activeOperationId();
|
|
3203
3221
|
const waitPromise = this._uiRegistry.wait(
|
|
3204
3222
|
UI_REQUEST.REQUEST_DEVICE_PERMISSION,
|