@onekeyfe/hwk-ledger-adapter 1.2.3-alpha.4 → 1.2.3-alpha.5
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 +29 -65
- package/dist/index.d.ts +29 -65
- package/dist/index.js +781 -1591
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +778 -1606
- package/dist/index.mjs.map +1 -1
- package/package.json +11 -14
package/dist/index.d.mts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import * as _onekeyfe_hwk_adapter_core from '@onekeyfe/hwk-adapter-core';
|
|
2
|
-
import { IHardwareWallet, IConnector, TransportType, UiResponseEvent, SearchDevicesOptions, DeviceInfo,
|
|
2
|
+
import { IHardwareWallet, IConnector, TransportType, UiResponseEvent, SearchDevicesOptions, DeviceInfo, Response, ChainCapability, NullableCallArg, IHardwareCallParams, EvmGetAddressParams, EvmAddress, EvmSignTxLedgerParams, EvmSignedTx, EvmSignMsgParams, EvmSignature, EvmSignTypedDataParams, BtcGetAddressParams, BtcAddress, BtcGetPublicKeyParams, BtcPublicKey, BtcSignTxParams, BtcSignedTx, BtcSignPsbtParams, BtcSignedPsbt, BtcSignMsgParams, BtcSignature, IHardwareCommonCallParams, SolGetAddressParams, SolAddress, SolSignTxParams, SolSignedTx, SolSignMsgParams, SolSignature, TronGetAddressParams, TronAddress, TronSignTxParams, TronSignedTx, TronSignMsgParams, TronSignature, DeviceAuthenticityParams, DeviceAuthenticityResult, HardwareEventMap, DeviceEventListener, ChainForFingerprint, DeviceDescriptor, DeviceChangeEvent, ConnectionType, ConnectorDevice, ConnectorSession, ConnectorCallResult, ConnectorEventType, ConnectorEventMap, ConnectorConfig, Failure, HardwareErrorCode } from '@onekeyfe/hwk-adapter-core';
|
|
3
3
|
import { DeviceActionState as DeviceActionState$1, DiscoveredDevice, ExecuteDeviceActionReturnType, DeviceManagementKit } from '@ledgerhq/device-management-kit';
|
|
4
4
|
import { Address, Signature, SignerEth as SignerEth$1, TypedData } from '@ledgerhq/device-signer-kit-ethereum';
|
|
5
5
|
import { ContextModule } from '@ledgerhq/context-module';
|
|
6
6
|
import { SignerBtc as SignerBtc$1 } from '@ledgerhq/device-signer-kit-bitcoin';
|
|
7
7
|
import { SignerSolana } from '@ledgerhq/device-signer-kit-solana';
|
|
8
|
-
import { SignerZcash as SignerZcash$1, FullViewingKeyOptions, GetFullViewingKeyDAOutput, GetShieldedAddressDAOutput } from '@ledgerhq/device-signer-kit-zcash';
|
|
9
8
|
import Transport from '@ledgerhq/hw-transport';
|
|
10
9
|
|
|
11
10
|
/**
|
|
@@ -98,27 +97,14 @@ declare class LedgerAdapter implements IHardwareWallet {
|
|
|
98
97
|
readonly vendor: "ledger";
|
|
99
98
|
private readonly connector;
|
|
100
99
|
private readonly emitter;
|
|
101
|
-
private readonly _operations;
|
|
102
100
|
private _discoveredDevices;
|
|
103
101
|
private _sessions;
|
|
104
|
-
private readonly _pendingOperationBindings;
|
|
105
|
-
private readonly _verifiedBleReconnectTargets;
|
|
106
102
|
private readonly _uiRegistry;
|
|
107
103
|
private _btcHighIndexConfirmedThisSession;
|
|
108
104
|
private readonly _jobQueue;
|
|
109
105
|
private _deviceAuthenticityQueueTail;
|
|
110
106
|
private _doConnectAbortController;
|
|
111
107
|
private readonly _defaultAutoInstallApp;
|
|
112
|
-
private readonly _unsettledConnectorOperations;
|
|
113
|
-
private readonly _connectorIdleWaiters;
|
|
114
|
-
private _resetPromise;
|
|
115
|
-
private _stateGeneration;
|
|
116
|
-
private _connectorTeardownTail;
|
|
117
|
-
private _pendingConnectorTeardowns;
|
|
118
|
-
private _activeConnectionType;
|
|
119
|
-
private _bindingSelectionRequestId;
|
|
120
|
-
private _finishBleBinding;
|
|
121
|
-
private _isBleConnection;
|
|
122
108
|
constructor(connector: IConnector, options?: {
|
|
123
109
|
autoInstallApp?: boolean;
|
|
124
110
|
});
|
|
@@ -132,33 +118,22 @@ declare class LedgerAdapter implements IHardwareWallet {
|
|
|
132
118
|
* The next operation will re-discover and re-connect automatically.
|
|
133
119
|
*/
|
|
134
120
|
resetState(): void;
|
|
135
|
-
private _resetStateAndDisconnectSessions;
|
|
136
121
|
dispose(): Promise<void>;
|
|
137
122
|
uiResponse(response: UiResponseEvent): void;
|
|
138
123
|
searchDevices(options?: SearchDevicesOptions): Promise<DeviceInfo[]>;
|
|
139
|
-
private _searchDevices;
|
|
140
|
-
searchDeviceTargets(options?: SearchDevicesOptions): Promise<DeviceSearchTarget[]>;
|
|
141
|
-
listConnectionTargets(options?: SearchDevicesOptions): Promise<ConnectionTarget[]>;
|
|
142
124
|
private _evictAllSessions;
|
|
143
125
|
private static readonly MAX_BUSINESS_RETRY_BUDGET;
|
|
144
126
|
private static readonly STUCK_APP_RETRY_DELAY_MS;
|
|
145
127
|
private static readonly MAX_DOCONNECT_CONFIRMS;
|
|
146
128
|
private _lastCancelReason;
|
|
147
|
-
private readonly _activeOperationJobs;
|
|
148
|
-
private readonly _pendingOperationDisconnects;
|
|
149
129
|
private static readonly APP_INSTALL_PROGRESS_MIN_DELTA;
|
|
150
130
|
private _installProgressLastEmittedValue;
|
|
151
131
|
private _installProgressLastKey;
|
|
152
132
|
private static _createDeviceBusyError;
|
|
153
|
-
connectDevice(
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
private _connectTarget;
|
|
158
|
-
releaseOperation(operationId: string): Promise<void>;
|
|
159
|
-
private _releaseOperationConnection;
|
|
160
|
-
private _releaseLostOperationConnection;
|
|
161
|
-
getDeviceInfo(connectIdOrOperationId: string, deviceId: string): Promise<Response<DeviceInfo>>;
|
|
133
|
+
connectDevice(connectId: string): Promise<Response<string>>;
|
|
134
|
+
disconnectDevice(connectId: string): Promise<void>;
|
|
135
|
+
getDeviceInfo(connectId: string, deviceId: string): Promise<Response<DeviceInfo>>;
|
|
136
|
+
getSupportedChains(): ChainCapability[];
|
|
162
137
|
allNetworkGetAddress: (connectId: string, _deviceId: string, params: _onekeyfe_hwk_adapter_core.AllNetworkGetAddressParams) => Promise<Response<_onekeyfe_hwk_adapter_core.AllNetworkAddressResponse[]>>;
|
|
163
138
|
private callChain;
|
|
164
139
|
private static normalizeCallArgs;
|
|
@@ -182,8 +157,6 @@ declare class LedgerAdapter implements IHardwareWallet {
|
|
|
182
157
|
tronGetAddress(connectId?: string | null, deviceId?: string | null, params?: LedgerCallParams<TronGetAddressParams>): Promise<Response<TronAddress>>;
|
|
183
158
|
tronSignTransaction(connectId?: string | null, deviceId?: string | null, params?: LedgerCallParams<TronSignTxParams>): Promise<Response<TronSignedTx>>;
|
|
184
159
|
tronSignMessage(connectId?: string | null, deviceId?: string | null, params?: LedgerCallParams<TronSignMsgParams>): Promise<Response<TronSignature>>;
|
|
185
|
-
zcashGetFullViewingKey(connectId?: string | null, deviceId?: string | null, params?: LedgerCallParams<ZcashGetFullViewingKeyParams>): Promise<Response<ZcashFullViewingKey>>;
|
|
186
|
-
zcashGetShieldedAddress(connectId?: string | null, deviceId?: string | null, params?: LedgerCallParams<ZcashGetShieldedAddressParams>): Promise<Response<ZcashShieldedAddress>>;
|
|
187
160
|
installApp(connectId: string, appName: string): Promise<Response<void>>;
|
|
188
161
|
listInstalledApps(connectId: string): Promise<Response<AppMetadata[]>>;
|
|
189
162
|
listInstalledNames(connectId: string): Promise<Response<string[]>>;
|
|
@@ -208,11 +181,11 @@ declare class LedgerAdapter implements IHardwareWallet {
|
|
|
208
181
|
off<K extends keyof HardwareEventMap>(event: K, listener: (event: HardwareEventMap[K]) => void): void;
|
|
209
182
|
off(event: string, listener: DeviceEventListener): void;
|
|
210
183
|
cancel(connectId?: string): void;
|
|
211
|
-
/** A non-empty deviceId is an expected chain fingerprint, not a transport identifier. */
|
|
212
184
|
getChainFingerprint(connectId: string, deviceId: string, chain: ChainForFingerprint): Promise<Response<string>>;
|
|
213
|
-
/**
|
|
214
|
-
|
|
215
|
-
|
|
185
|
+
/**
|
|
186
|
+
* Verify fingerprint using an existing sessionId directly.
|
|
187
|
+
* Safe to call inside connectorCall without causing queue deadlock.
|
|
188
|
+
*/
|
|
216
189
|
private _verifyDeviceFingerprintWithSession;
|
|
217
190
|
/**
|
|
218
191
|
* Compute the chain fingerprint via a caller-supplied call strategy.
|
|
@@ -234,7 +207,7 @@ declare class LedgerAdapter implements IHardwareWallet {
|
|
|
234
207
|
*
|
|
235
208
|
* - If a session already exists for the given connectId, reuse it.
|
|
236
209
|
* - If ANY session exists (Ledger IDs are ephemeral), reuse it.
|
|
237
|
-
* - Otherwise: search →
|
|
210
|
+
* - Otherwise: search → exactly 1 USB device auto-connects; multiple or none throws.
|
|
238
211
|
*/
|
|
239
212
|
private _connectingPromise;
|
|
240
213
|
private _waitForDeviceConnect;
|
|
@@ -277,23 +250,34 @@ declare class LedgerAdapter implements IHardwareWallet {
|
|
|
277
250
|
* lives in one place.
|
|
278
251
|
*/
|
|
279
252
|
private _callConnector;
|
|
280
|
-
private _assertConnectorReady;
|
|
281
|
-
private _runConnectorTeardown;
|
|
282
|
-
private _waitForConnectorOperationsToDrain;
|
|
283
|
-
private _retainConnectorOperation;
|
|
284
253
|
private connectorCall;
|
|
285
254
|
/**
|
|
286
255
|
* Race a promise against an abort signal. On abort, rejects with
|
|
287
256
|
* signal.reason → instance _lastCancelReason → generic Error('Aborted').
|
|
288
257
|
*/
|
|
289
|
-
/** Hermes/RN polyfills don't always populate signal.reason; fall back. */
|
|
290
|
-
private _abortReason;
|
|
291
258
|
private _abortable;
|
|
292
259
|
/** Throw an AbortError if signal is already aborted. */
|
|
293
260
|
private static _throwIfAborted;
|
|
294
261
|
/** Actual work done under the job queue — connection, fingerprint, call, and recovery. */
|
|
295
262
|
private _runConnectorCall;
|
|
263
|
+
/**
|
|
264
|
+
* Stuck-app recovery: pause for the device's UI transition, then retry once.
|
|
265
|
+
*
|
|
266
|
+
* Caller has already cleared the session + reset connector. We wait so Stax
|
|
267
|
+
* finishes its post-CloseApp animation, then go through ensureConnected +
|
|
268
|
+
* fingerprint check + call exactly once. Caller decides what to do on a
|
|
269
|
+
* second stuck-app hit.
|
|
270
|
+
*/
|
|
271
|
+
private _retryAfterStuckApp;
|
|
296
272
|
private _sleepAbortable;
|
|
273
|
+
/**
|
|
274
|
+
* Clear stale session, reconnect, and retry the call.
|
|
275
|
+
*
|
|
276
|
+
* Timeout recovery starts with a full connector reset. After an APDU
|
|
277
|
+
* timeout, DMK/transport state may still emit malformed responses; retrying
|
|
278
|
+
* on the same DMK can poison the next chain switch.
|
|
279
|
+
*/
|
|
280
|
+
private _retryWithFreshConnection;
|
|
297
281
|
/**
|
|
298
282
|
* Ensure OS-level device permission (Bluetooth / USB) before proceeding.
|
|
299
283
|
*
|
|
@@ -670,25 +654,6 @@ declare class SignerSol {
|
|
|
670
654
|
}>;
|
|
671
655
|
}
|
|
672
656
|
|
|
673
|
-
/**
|
|
674
|
-
* Wraps Ledger's Zcash SDK signer (Observable-based DeviceActions) into a
|
|
675
|
-
* simple async interface. Only the viewing-key and shielded-address reads are
|
|
676
|
-
* exposed; PCZT signing goes through a different host-side pipeline.
|
|
677
|
-
*/
|
|
678
|
-
declare class SignerZcash {
|
|
679
|
-
private readonly _sdk;
|
|
680
|
-
onInteraction?: (interaction: string) => void;
|
|
681
|
-
onRegisterCanceller?: (cancel: (reason?: CancelReason) => void) => void;
|
|
682
|
-
constructor(_sdk: SignerZcash$1);
|
|
683
|
-
/** GET_VK: UFVK string (default) or raw 96-byte Orchard FVK. */
|
|
684
|
-
getFullViewingKey(derivationPath: string, options?: FullViewingKeyOptions): Promise<GetFullViewingKeyDAOutput>;
|
|
685
|
-
/** GET_SHIELDED_ADDRESS: single-Orchard-receiver UA for a 5-level transparent path. */
|
|
686
|
-
getShieldedAddress(derivationPath: string, options?: {
|
|
687
|
-
checkOnDevice?: boolean;
|
|
688
|
-
skipOpenApp?: boolean;
|
|
689
|
-
}): Promise<GetShieldedAddressDAOutput>;
|
|
690
|
-
}
|
|
691
|
-
|
|
692
657
|
/**
|
|
693
658
|
* Transport adapter that bridges Ledger's legacy hw-app-* SDKs to DMK's sendApdu.
|
|
694
659
|
*
|
|
@@ -772,7 +737,7 @@ interface WrapErrorOptions {
|
|
|
772
737
|
/** Fallback when err has no `appName` (DMK signer errors don't carry it). */
|
|
773
738
|
defaultAppName?: string;
|
|
774
739
|
}
|
|
775
|
-
declare function ledgerFailure(code: HardwareErrorCode, error: string, appName?: string, tag?: string, params?: Record<string, unknown
|
|
740
|
+
declare function ledgerFailure(code: HardwareErrorCode, error: string, appName?: string, tag?: string, params?: Record<string, unknown>): LedgerFailure;
|
|
776
741
|
declare function isDeviceLockedError(err: unknown): boolean;
|
|
777
742
|
/**
|
|
778
743
|
* Map a Ledger DMK error to a HardwareErrorCode and human-readable message.
|
|
@@ -782,7 +747,6 @@ declare function isDeviceLockedError(err: unknown): boolean;
|
|
|
782
747
|
declare function mapLedgerError(err: unknown, opts?: WrapErrorOptions): {
|
|
783
748
|
code: HardwareErrorCode;
|
|
784
749
|
message: string;
|
|
785
|
-
origin?: HwkErrorOrigin;
|
|
786
750
|
appName?: string;
|
|
787
751
|
};
|
|
788
752
|
|
|
@@ -818,4 +782,4 @@ declare function isLedgerDmkBleTransport(transport?: string): boolean;
|
|
|
818
782
|
declare function isLedgerBleConnectionType(connectionType?: ConnectionType): boolean;
|
|
819
783
|
declare function isLedgerBleDescriptor(connectionType: ConnectionType, descriptor: DeviceDescriptor): boolean;
|
|
820
784
|
|
|
821
|
-
export { AppManager, type DeviceActionState, type DmkDiscoveredDevice, DmkTransport, LedgerAdapter, LedgerConnectorBase, type LedgerConnectorBaseOptions, LedgerDeviceManager, type LedgerFailure, type SdkEvent, type SdkEventListener, type SdkLogEvent, SignerBtc, type SignerBtcAddress, SignerEth, type SignerEvmAddress, type SignerEvmSignature, SignerManager, SignerSol,
|
|
785
|
+
export { AppManager, type DeviceActionState, type DmkDiscoveredDevice, DmkTransport, LedgerAdapter, LedgerConnectorBase, type LedgerConnectorBaseOptions, LedgerDeviceManager, type LedgerFailure, type SdkEvent, type SdkEventListener, type SdkLogEvent, SignerBtc, type SignerBtcAddress, SignerEth, type SignerEvmAddress, type SignerEvmSignature, SignerManager, SignerSol, type TransportFactory, debugLog, deviceActionToPromise, isDeviceLockedError, isLedgerBleConnectionType, isLedgerBleDescriptor, isLedgerDmkBleTransport, ledgerFailure, mapLedgerError, offSdkEvent, onSdkEvent };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import * as _onekeyfe_hwk_adapter_core from '@onekeyfe/hwk-adapter-core';
|
|
2
|
-
import { IHardwareWallet, IConnector, TransportType, UiResponseEvent, SearchDevicesOptions, DeviceInfo,
|
|
2
|
+
import { IHardwareWallet, IConnector, TransportType, UiResponseEvent, SearchDevicesOptions, DeviceInfo, Response, ChainCapability, NullableCallArg, IHardwareCallParams, EvmGetAddressParams, EvmAddress, EvmSignTxLedgerParams, EvmSignedTx, EvmSignMsgParams, EvmSignature, EvmSignTypedDataParams, BtcGetAddressParams, BtcAddress, BtcGetPublicKeyParams, BtcPublicKey, BtcSignTxParams, BtcSignedTx, BtcSignPsbtParams, BtcSignedPsbt, BtcSignMsgParams, BtcSignature, IHardwareCommonCallParams, SolGetAddressParams, SolAddress, SolSignTxParams, SolSignedTx, SolSignMsgParams, SolSignature, TronGetAddressParams, TronAddress, TronSignTxParams, TronSignedTx, TronSignMsgParams, TronSignature, DeviceAuthenticityParams, DeviceAuthenticityResult, HardwareEventMap, DeviceEventListener, ChainForFingerprint, DeviceDescriptor, DeviceChangeEvent, ConnectionType, ConnectorDevice, ConnectorSession, ConnectorCallResult, ConnectorEventType, ConnectorEventMap, ConnectorConfig, Failure, HardwareErrorCode } from '@onekeyfe/hwk-adapter-core';
|
|
3
3
|
import { DeviceActionState as DeviceActionState$1, DiscoveredDevice, ExecuteDeviceActionReturnType, DeviceManagementKit } from '@ledgerhq/device-management-kit';
|
|
4
4
|
import { Address, Signature, SignerEth as SignerEth$1, TypedData } from '@ledgerhq/device-signer-kit-ethereum';
|
|
5
5
|
import { ContextModule } from '@ledgerhq/context-module';
|
|
6
6
|
import { SignerBtc as SignerBtc$1 } from '@ledgerhq/device-signer-kit-bitcoin';
|
|
7
7
|
import { SignerSolana } from '@ledgerhq/device-signer-kit-solana';
|
|
8
|
-
import { SignerZcash as SignerZcash$1, FullViewingKeyOptions, GetFullViewingKeyDAOutput, GetShieldedAddressDAOutput } from '@ledgerhq/device-signer-kit-zcash';
|
|
9
8
|
import Transport from '@ledgerhq/hw-transport';
|
|
10
9
|
|
|
11
10
|
/**
|
|
@@ -98,27 +97,14 @@ declare class LedgerAdapter implements IHardwareWallet {
|
|
|
98
97
|
readonly vendor: "ledger";
|
|
99
98
|
private readonly connector;
|
|
100
99
|
private readonly emitter;
|
|
101
|
-
private readonly _operations;
|
|
102
100
|
private _discoveredDevices;
|
|
103
101
|
private _sessions;
|
|
104
|
-
private readonly _pendingOperationBindings;
|
|
105
|
-
private readonly _verifiedBleReconnectTargets;
|
|
106
102
|
private readonly _uiRegistry;
|
|
107
103
|
private _btcHighIndexConfirmedThisSession;
|
|
108
104
|
private readonly _jobQueue;
|
|
109
105
|
private _deviceAuthenticityQueueTail;
|
|
110
106
|
private _doConnectAbortController;
|
|
111
107
|
private readonly _defaultAutoInstallApp;
|
|
112
|
-
private readonly _unsettledConnectorOperations;
|
|
113
|
-
private readonly _connectorIdleWaiters;
|
|
114
|
-
private _resetPromise;
|
|
115
|
-
private _stateGeneration;
|
|
116
|
-
private _connectorTeardownTail;
|
|
117
|
-
private _pendingConnectorTeardowns;
|
|
118
|
-
private _activeConnectionType;
|
|
119
|
-
private _bindingSelectionRequestId;
|
|
120
|
-
private _finishBleBinding;
|
|
121
|
-
private _isBleConnection;
|
|
122
108
|
constructor(connector: IConnector, options?: {
|
|
123
109
|
autoInstallApp?: boolean;
|
|
124
110
|
});
|
|
@@ -132,33 +118,22 @@ declare class LedgerAdapter implements IHardwareWallet {
|
|
|
132
118
|
* The next operation will re-discover and re-connect automatically.
|
|
133
119
|
*/
|
|
134
120
|
resetState(): void;
|
|
135
|
-
private _resetStateAndDisconnectSessions;
|
|
136
121
|
dispose(): Promise<void>;
|
|
137
122
|
uiResponse(response: UiResponseEvent): void;
|
|
138
123
|
searchDevices(options?: SearchDevicesOptions): Promise<DeviceInfo[]>;
|
|
139
|
-
private _searchDevices;
|
|
140
|
-
searchDeviceTargets(options?: SearchDevicesOptions): Promise<DeviceSearchTarget[]>;
|
|
141
|
-
listConnectionTargets(options?: SearchDevicesOptions): Promise<ConnectionTarget[]>;
|
|
142
124
|
private _evictAllSessions;
|
|
143
125
|
private static readonly MAX_BUSINESS_RETRY_BUDGET;
|
|
144
126
|
private static readonly STUCK_APP_RETRY_DELAY_MS;
|
|
145
127
|
private static readonly MAX_DOCONNECT_CONFIRMS;
|
|
146
128
|
private _lastCancelReason;
|
|
147
|
-
private readonly _activeOperationJobs;
|
|
148
|
-
private readonly _pendingOperationDisconnects;
|
|
149
129
|
private static readonly APP_INSTALL_PROGRESS_MIN_DELTA;
|
|
150
130
|
private _installProgressLastEmittedValue;
|
|
151
131
|
private _installProgressLastKey;
|
|
152
132
|
private static _createDeviceBusyError;
|
|
153
|
-
connectDevice(
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
private _connectTarget;
|
|
158
|
-
releaseOperation(operationId: string): Promise<void>;
|
|
159
|
-
private _releaseOperationConnection;
|
|
160
|
-
private _releaseLostOperationConnection;
|
|
161
|
-
getDeviceInfo(connectIdOrOperationId: string, deviceId: string): Promise<Response<DeviceInfo>>;
|
|
133
|
+
connectDevice(connectId: string): Promise<Response<string>>;
|
|
134
|
+
disconnectDevice(connectId: string): Promise<void>;
|
|
135
|
+
getDeviceInfo(connectId: string, deviceId: string): Promise<Response<DeviceInfo>>;
|
|
136
|
+
getSupportedChains(): ChainCapability[];
|
|
162
137
|
allNetworkGetAddress: (connectId: string, _deviceId: string, params: _onekeyfe_hwk_adapter_core.AllNetworkGetAddressParams) => Promise<Response<_onekeyfe_hwk_adapter_core.AllNetworkAddressResponse[]>>;
|
|
163
138
|
private callChain;
|
|
164
139
|
private static normalizeCallArgs;
|
|
@@ -182,8 +157,6 @@ declare class LedgerAdapter implements IHardwareWallet {
|
|
|
182
157
|
tronGetAddress(connectId?: string | null, deviceId?: string | null, params?: LedgerCallParams<TronGetAddressParams>): Promise<Response<TronAddress>>;
|
|
183
158
|
tronSignTransaction(connectId?: string | null, deviceId?: string | null, params?: LedgerCallParams<TronSignTxParams>): Promise<Response<TronSignedTx>>;
|
|
184
159
|
tronSignMessage(connectId?: string | null, deviceId?: string | null, params?: LedgerCallParams<TronSignMsgParams>): Promise<Response<TronSignature>>;
|
|
185
|
-
zcashGetFullViewingKey(connectId?: string | null, deviceId?: string | null, params?: LedgerCallParams<ZcashGetFullViewingKeyParams>): Promise<Response<ZcashFullViewingKey>>;
|
|
186
|
-
zcashGetShieldedAddress(connectId?: string | null, deviceId?: string | null, params?: LedgerCallParams<ZcashGetShieldedAddressParams>): Promise<Response<ZcashShieldedAddress>>;
|
|
187
160
|
installApp(connectId: string, appName: string): Promise<Response<void>>;
|
|
188
161
|
listInstalledApps(connectId: string): Promise<Response<AppMetadata[]>>;
|
|
189
162
|
listInstalledNames(connectId: string): Promise<Response<string[]>>;
|
|
@@ -208,11 +181,11 @@ declare class LedgerAdapter implements IHardwareWallet {
|
|
|
208
181
|
off<K extends keyof HardwareEventMap>(event: K, listener: (event: HardwareEventMap[K]) => void): void;
|
|
209
182
|
off(event: string, listener: DeviceEventListener): void;
|
|
210
183
|
cancel(connectId?: string): void;
|
|
211
|
-
/** A non-empty deviceId is an expected chain fingerprint, not a transport identifier. */
|
|
212
184
|
getChainFingerprint(connectId: string, deviceId: string, chain: ChainForFingerprint): Promise<Response<string>>;
|
|
213
|
-
/**
|
|
214
|
-
|
|
215
|
-
|
|
185
|
+
/**
|
|
186
|
+
* Verify fingerprint using an existing sessionId directly.
|
|
187
|
+
* Safe to call inside connectorCall without causing queue deadlock.
|
|
188
|
+
*/
|
|
216
189
|
private _verifyDeviceFingerprintWithSession;
|
|
217
190
|
/**
|
|
218
191
|
* Compute the chain fingerprint via a caller-supplied call strategy.
|
|
@@ -234,7 +207,7 @@ declare class LedgerAdapter implements IHardwareWallet {
|
|
|
234
207
|
*
|
|
235
208
|
* - If a session already exists for the given connectId, reuse it.
|
|
236
209
|
* - If ANY session exists (Ledger IDs are ephemeral), reuse it.
|
|
237
|
-
* - Otherwise: search →
|
|
210
|
+
* - Otherwise: search → exactly 1 USB device auto-connects; multiple or none throws.
|
|
238
211
|
*/
|
|
239
212
|
private _connectingPromise;
|
|
240
213
|
private _waitForDeviceConnect;
|
|
@@ -277,23 +250,34 @@ declare class LedgerAdapter implements IHardwareWallet {
|
|
|
277
250
|
* lives in one place.
|
|
278
251
|
*/
|
|
279
252
|
private _callConnector;
|
|
280
|
-
private _assertConnectorReady;
|
|
281
|
-
private _runConnectorTeardown;
|
|
282
|
-
private _waitForConnectorOperationsToDrain;
|
|
283
|
-
private _retainConnectorOperation;
|
|
284
253
|
private connectorCall;
|
|
285
254
|
/**
|
|
286
255
|
* Race a promise against an abort signal. On abort, rejects with
|
|
287
256
|
* signal.reason → instance _lastCancelReason → generic Error('Aborted').
|
|
288
257
|
*/
|
|
289
|
-
/** Hermes/RN polyfills don't always populate signal.reason; fall back. */
|
|
290
|
-
private _abortReason;
|
|
291
258
|
private _abortable;
|
|
292
259
|
/** Throw an AbortError if signal is already aborted. */
|
|
293
260
|
private static _throwIfAborted;
|
|
294
261
|
/** Actual work done under the job queue — connection, fingerprint, call, and recovery. */
|
|
295
262
|
private _runConnectorCall;
|
|
263
|
+
/**
|
|
264
|
+
* Stuck-app recovery: pause for the device's UI transition, then retry once.
|
|
265
|
+
*
|
|
266
|
+
* Caller has already cleared the session + reset connector. We wait so Stax
|
|
267
|
+
* finishes its post-CloseApp animation, then go through ensureConnected +
|
|
268
|
+
* fingerprint check + call exactly once. Caller decides what to do on a
|
|
269
|
+
* second stuck-app hit.
|
|
270
|
+
*/
|
|
271
|
+
private _retryAfterStuckApp;
|
|
296
272
|
private _sleepAbortable;
|
|
273
|
+
/**
|
|
274
|
+
* Clear stale session, reconnect, and retry the call.
|
|
275
|
+
*
|
|
276
|
+
* Timeout recovery starts with a full connector reset. After an APDU
|
|
277
|
+
* timeout, DMK/transport state may still emit malformed responses; retrying
|
|
278
|
+
* on the same DMK can poison the next chain switch.
|
|
279
|
+
*/
|
|
280
|
+
private _retryWithFreshConnection;
|
|
297
281
|
/**
|
|
298
282
|
* Ensure OS-level device permission (Bluetooth / USB) before proceeding.
|
|
299
283
|
*
|
|
@@ -670,25 +654,6 @@ declare class SignerSol {
|
|
|
670
654
|
}>;
|
|
671
655
|
}
|
|
672
656
|
|
|
673
|
-
/**
|
|
674
|
-
* Wraps Ledger's Zcash SDK signer (Observable-based DeviceActions) into a
|
|
675
|
-
* simple async interface. Only the viewing-key and shielded-address reads are
|
|
676
|
-
* exposed; PCZT signing goes through a different host-side pipeline.
|
|
677
|
-
*/
|
|
678
|
-
declare class SignerZcash {
|
|
679
|
-
private readonly _sdk;
|
|
680
|
-
onInteraction?: (interaction: string) => void;
|
|
681
|
-
onRegisterCanceller?: (cancel: (reason?: CancelReason) => void) => void;
|
|
682
|
-
constructor(_sdk: SignerZcash$1);
|
|
683
|
-
/** GET_VK: UFVK string (default) or raw 96-byte Orchard FVK. */
|
|
684
|
-
getFullViewingKey(derivationPath: string, options?: FullViewingKeyOptions): Promise<GetFullViewingKeyDAOutput>;
|
|
685
|
-
/** GET_SHIELDED_ADDRESS: single-Orchard-receiver UA for a 5-level transparent path. */
|
|
686
|
-
getShieldedAddress(derivationPath: string, options?: {
|
|
687
|
-
checkOnDevice?: boolean;
|
|
688
|
-
skipOpenApp?: boolean;
|
|
689
|
-
}): Promise<GetShieldedAddressDAOutput>;
|
|
690
|
-
}
|
|
691
|
-
|
|
692
657
|
/**
|
|
693
658
|
* Transport adapter that bridges Ledger's legacy hw-app-* SDKs to DMK's sendApdu.
|
|
694
659
|
*
|
|
@@ -772,7 +737,7 @@ interface WrapErrorOptions {
|
|
|
772
737
|
/** Fallback when err has no `appName` (DMK signer errors don't carry it). */
|
|
773
738
|
defaultAppName?: string;
|
|
774
739
|
}
|
|
775
|
-
declare function ledgerFailure(code: HardwareErrorCode, error: string, appName?: string, tag?: string, params?: Record<string, unknown
|
|
740
|
+
declare function ledgerFailure(code: HardwareErrorCode, error: string, appName?: string, tag?: string, params?: Record<string, unknown>): LedgerFailure;
|
|
776
741
|
declare function isDeviceLockedError(err: unknown): boolean;
|
|
777
742
|
/**
|
|
778
743
|
* Map a Ledger DMK error to a HardwareErrorCode and human-readable message.
|
|
@@ -782,7 +747,6 @@ declare function isDeviceLockedError(err: unknown): boolean;
|
|
|
782
747
|
declare function mapLedgerError(err: unknown, opts?: WrapErrorOptions): {
|
|
783
748
|
code: HardwareErrorCode;
|
|
784
749
|
message: string;
|
|
785
|
-
origin?: HwkErrorOrigin;
|
|
786
750
|
appName?: string;
|
|
787
751
|
};
|
|
788
752
|
|
|
@@ -818,4 +782,4 @@ declare function isLedgerDmkBleTransport(transport?: string): boolean;
|
|
|
818
782
|
declare function isLedgerBleConnectionType(connectionType?: ConnectionType): boolean;
|
|
819
783
|
declare function isLedgerBleDescriptor(connectionType: ConnectionType, descriptor: DeviceDescriptor): boolean;
|
|
820
784
|
|
|
821
|
-
export { AppManager, type DeviceActionState, type DmkDiscoveredDevice, DmkTransport, LedgerAdapter, LedgerConnectorBase, type LedgerConnectorBaseOptions, LedgerDeviceManager, type LedgerFailure, type SdkEvent, type SdkEventListener, type SdkLogEvent, SignerBtc, type SignerBtcAddress, SignerEth, type SignerEvmAddress, type SignerEvmSignature, SignerManager, SignerSol,
|
|
785
|
+
export { AppManager, type DeviceActionState, type DmkDiscoveredDevice, DmkTransport, LedgerAdapter, LedgerConnectorBase, type LedgerConnectorBaseOptions, LedgerDeviceManager, type LedgerFailure, type SdkEvent, type SdkEventListener, type SdkLogEvent, SignerBtc, type SignerBtcAddress, SignerEth, type SignerEvmAddress, type SignerEvmSignature, SignerManager, SignerSol, type TransportFactory, debugLog, deviceActionToPromise, isDeviceLockedError, isLedgerBleConnectionType, isLedgerBleDescriptor, isLedgerDmkBleTransport, ledgerFailure, mapLedgerError, offSdkEvent, onSdkEvent };
|