@onekeyfe/hwk-ledger-adapter 1.2.2-alpha.8 → 1.2.3-alpha.1
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 +62 -28
- package/dist/index.d.ts +62 -28
- package/dist/index.js +1113 -465
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1112 -446
- package/dist/index.mjs.map +1 -1
- package/package.json +12 -9
package/dist/index.d.mts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import * as _onekeyfe_hwk_adapter_core from '@onekeyfe/hwk-adapter-core';
|
|
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';
|
|
2
|
+
import { IHardwareWallet, IConnector, TransportType, UiResponseEvent, SearchDevicesOptions, DeviceInfo, DeviceSearchTarget, ConnectionTarget, Response, IHardwareConnectionContext, 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, ZcashGetFullViewingKeyParams, ZcashFullViewingKey, ZcashGetShieldedAddressParams, ZcashShieldedAddress, DeviceAuthenticityParams, DeviceAuthenticityResult, HardwareEventMap, DeviceEventListener, ChainForFingerprint, DeviceDescriptor, DeviceChangeEvent, ConnectionType, ConnectorDevice, ConnectorSession, ConnectorCallResult, ConnectorEventType, ConnectorEventMap, ConnectorConfig, Failure, HardwareErrorCode, HwkErrorOrigin, HwkRecoveryHint } 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';
|
|
8
9
|
import Transport from '@ledgerhq/hw-transport';
|
|
9
10
|
|
|
10
11
|
/**
|
|
@@ -97,14 +98,27 @@ declare class LedgerAdapter implements IHardwareWallet {
|
|
|
97
98
|
readonly vendor: "ledger";
|
|
98
99
|
private readonly connector;
|
|
99
100
|
private readonly emitter;
|
|
101
|
+
private readonly _interactions;
|
|
100
102
|
private _discoveredDevices;
|
|
101
103
|
private _sessions;
|
|
104
|
+
private readonly _pendingInteractionBindings;
|
|
105
|
+
private readonly _verifiedBleReconnectTargets;
|
|
102
106
|
private readonly _uiRegistry;
|
|
103
107
|
private _btcHighIndexConfirmedThisSession;
|
|
104
108
|
private readonly _jobQueue;
|
|
105
109
|
private _deviceAuthenticityQueueTail;
|
|
106
110
|
private _doConnectAbortController;
|
|
107
111
|
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;
|
|
108
122
|
constructor(connector: IConnector, options?: {
|
|
109
123
|
autoInstallApp?: boolean;
|
|
110
124
|
});
|
|
@@ -118,21 +132,32 @@ declare class LedgerAdapter implements IHardwareWallet {
|
|
|
118
132
|
* The next operation will re-discover and re-connect automatically.
|
|
119
133
|
*/
|
|
120
134
|
resetState(): void;
|
|
135
|
+
private _resetStateAndDisconnectSessions;
|
|
121
136
|
dispose(): Promise<void>;
|
|
122
137
|
uiResponse(response: UiResponseEvent): void;
|
|
123
138
|
searchDevices(options?: SearchDevicesOptions): Promise<DeviceInfo[]>;
|
|
139
|
+
private _searchDevices;
|
|
140
|
+
searchDeviceTargets(options?: SearchDevicesOptions): Promise<DeviceSearchTarget[]>;
|
|
141
|
+
listConnectionTargets(options?: SearchDevicesOptions): Promise<ConnectionTarget[]>;
|
|
124
142
|
private _evictAllSessions;
|
|
125
143
|
private static readonly MAX_BUSINESS_RETRY_BUDGET;
|
|
126
144
|
private static readonly STUCK_APP_RETRY_DELAY_MS;
|
|
127
145
|
private static readonly MAX_DOCONNECT_CONFIRMS;
|
|
128
146
|
private _lastCancelReason;
|
|
147
|
+
private readonly _activeInteractionJobs;
|
|
148
|
+
private readonly _pendingInteractionDisconnects;
|
|
129
149
|
private static readonly APP_INSTALL_PROGRESS_MIN_DELTA;
|
|
130
150
|
private _installProgressLastEmittedValue;
|
|
131
151
|
private _installProgressLastKey;
|
|
132
152
|
private static _createDeviceBusyError;
|
|
133
|
-
connectDevice(
|
|
134
|
-
|
|
135
|
-
|
|
153
|
+
connectDevice(searchTargetId: string): Promise<Response<string>>;
|
|
154
|
+
acquireInteraction(connectId: string, context: IHardwareConnectionContext): Promise<Response<string>>;
|
|
155
|
+
private _createInteraction;
|
|
156
|
+
private _connectTarget;
|
|
157
|
+
releaseInteraction(interactionId: string): Promise<void>;
|
|
158
|
+
private _releaseInteractionConnection;
|
|
159
|
+
private _releaseLostInteractionConnection;
|
|
160
|
+
getDeviceInfo(connectIdOrInteractionId: string, deviceId: string): Promise<Response<DeviceInfo>>;
|
|
136
161
|
getSupportedChains(): ChainCapability[];
|
|
137
162
|
allNetworkGetAddress: (connectId: string, _deviceId: string, params: _onekeyfe_hwk_adapter_core.AllNetworkGetAddressParams) => Promise<Response<_onekeyfe_hwk_adapter_core.AllNetworkAddressResponse[]>>;
|
|
138
163
|
private callChain;
|
|
@@ -157,6 +182,8 @@ declare class LedgerAdapter implements IHardwareWallet {
|
|
|
157
182
|
tronGetAddress(connectId?: string | null, deviceId?: string | null, params?: LedgerCallParams<TronGetAddressParams>): Promise<Response<TronAddress>>;
|
|
158
183
|
tronSignTransaction(connectId?: string | null, deviceId?: string | null, params?: LedgerCallParams<TronSignTxParams>): Promise<Response<TronSignedTx>>;
|
|
159
184
|
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>>;
|
|
160
187
|
installApp(connectId: string, appName: string): Promise<Response<void>>;
|
|
161
188
|
listInstalledApps(connectId: string): Promise<Response<AppMetadata[]>>;
|
|
162
189
|
listInstalledNames(connectId: string): Promise<Response<string[]>>;
|
|
@@ -181,11 +208,11 @@ declare class LedgerAdapter implements IHardwareWallet {
|
|
|
181
208
|
off<K extends keyof HardwareEventMap>(event: K, listener: (event: HardwareEventMap[K]) => void): void;
|
|
182
209
|
off(event: string, listener: DeviceEventListener): void;
|
|
183
210
|
cancel(connectId?: string): void;
|
|
211
|
+
/** A non-empty deviceId is an expected chain fingerprint, not a transport identifier. */
|
|
184
212
|
getChainFingerprint(connectId: string, deviceId: string, chain: ChainForFingerprint): Promise<Response<string>>;
|
|
185
|
-
/**
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
*/
|
|
213
|
+
/** Discovery may select a BLE target before a later call verifies its wallet. */
|
|
214
|
+
private _publishVerifiedBleBinding;
|
|
215
|
+
/** Verify on the acquired session without re-entering the job queue. */
|
|
189
216
|
private _verifyDeviceFingerprintWithSession;
|
|
190
217
|
/**
|
|
191
218
|
* Compute the chain fingerprint via a caller-supplied call strategy.
|
|
@@ -207,7 +234,7 @@ declare class LedgerAdapter implements IHardwareWallet {
|
|
|
207
234
|
*
|
|
208
235
|
* - If a session already exists for the given connectId, reuse it.
|
|
209
236
|
* - If ANY session exists (Ledger IDs are ephemeral), reuse it.
|
|
210
|
-
* - Otherwise: search →
|
|
237
|
+
* - Otherwise: search → one USB device auto-connects; multiple asks the host to choose.
|
|
211
238
|
*/
|
|
212
239
|
private _connectingPromise;
|
|
213
240
|
private _waitForDeviceConnect;
|
|
@@ -250,6 +277,10 @@ declare class LedgerAdapter implements IHardwareWallet {
|
|
|
250
277
|
* lives in one place.
|
|
251
278
|
*/
|
|
252
279
|
private _callConnector;
|
|
280
|
+
private _assertConnectorReady;
|
|
281
|
+
private _runConnectorTeardown;
|
|
282
|
+
private _waitForConnectorOperationsToDrain;
|
|
283
|
+
private _retainConnectorOperation;
|
|
253
284
|
private connectorCall;
|
|
254
285
|
/**
|
|
255
286
|
* Race a promise against an abort signal. On abort, rejects with
|
|
@@ -260,24 +291,7 @@ declare class LedgerAdapter implements IHardwareWallet {
|
|
|
260
291
|
private static _throwIfAborted;
|
|
261
292
|
/** Actual work done under the job queue — connection, fingerprint, call, and recovery. */
|
|
262
293
|
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;
|
|
272
294
|
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;
|
|
281
295
|
/**
|
|
282
296
|
* Ensure OS-level device permission (Bluetooth / USB) before proceeding.
|
|
283
297
|
*
|
|
@@ -654,6 +668,25 @@ declare class SignerSol {
|
|
|
654
668
|
}>;
|
|
655
669
|
}
|
|
656
670
|
|
|
671
|
+
/**
|
|
672
|
+
* Wraps Ledger's Zcash SDK signer (Observable-based DeviceActions) into a
|
|
673
|
+
* simple async interface. Only the viewing-key and shielded-address reads are
|
|
674
|
+
* exposed; PCZT signing goes through a different host-side pipeline.
|
|
675
|
+
*/
|
|
676
|
+
declare class SignerZcash {
|
|
677
|
+
private readonly _sdk;
|
|
678
|
+
onInteraction?: (interaction: string) => void;
|
|
679
|
+
onRegisterCanceller?: (cancel: (reason?: CancelReason) => void) => void;
|
|
680
|
+
constructor(_sdk: SignerZcash$1);
|
|
681
|
+
/** GET_VK: UFVK string (default) or raw 96-byte Orchard FVK. */
|
|
682
|
+
getFullViewingKey(derivationPath: string, options?: FullViewingKeyOptions): Promise<GetFullViewingKeyDAOutput>;
|
|
683
|
+
/** GET_SHIELDED_ADDRESS: single-Orchard-receiver UA for a 5-level transparent path. */
|
|
684
|
+
getShieldedAddress(derivationPath: string, options?: {
|
|
685
|
+
checkOnDevice?: boolean;
|
|
686
|
+
skipOpenApp?: boolean;
|
|
687
|
+
}): Promise<GetShieldedAddressDAOutput>;
|
|
688
|
+
}
|
|
689
|
+
|
|
657
690
|
/**
|
|
658
691
|
* Transport adapter that bridges Ledger's legacy hw-app-* SDKs to DMK's sendApdu.
|
|
659
692
|
*
|
|
@@ -737,7 +770,7 @@ interface WrapErrorOptions {
|
|
|
737
770
|
/** Fallback when err has no `appName` (DMK signer errors don't carry it). */
|
|
738
771
|
defaultAppName?: string;
|
|
739
772
|
}
|
|
740
|
-
declare function ledgerFailure(code: HardwareErrorCode, error: string, appName?: string, tag?: string, params?: Record<string, unknown
|
|
773
|
+
declare function ledgerFailure(code: HardwareErrorCode, error: string, appName?: string, tag?: string, params?: Record<string, unknown>, origin?: HwkErrorOrigin, recovery?: HwkRecoveryHint): LedgerFailure;
|
|
741
774
|
declare function isDeviceLockedError(err: unknown): boolean;
|
|
742
775
|
/**
|
|
743
776
|
* Map a Ledger DMK error to a HardwareErrorCode and human-readable message.
|
|
@@ -747,6 +780,7 @@ declare function isDeviceLockedError(err: unknown): boolean;
|
|
|
747
780
|
declare function mapLedgerError(err: unknown, opts?: WrapErrorOptions): {
|
|
748
781
|
code: HardwareErrorCode;
|
|
749
782
|
message: string;
|
|
783
|
+
origin?: HwkErrorOrigin;
|
|
750
784
|
appName?: string;
|
|
751
785
|
};
|
|
752
786
|
|
|
@@ -782,4 +816,4 @@ declare function isLedgerDmkBleTransport(transport?: string): boolean;
|
|
|
782
816
|
declare function isLedgerBleConnectionType(connectionType?: ConnectionType): boolean;
|
|
783
817
|
declare function isLedgerBleDescriptor(connectionType: ConnectionType, descriptor: DeviceDescriptor): boolean;
|
|
784
818
|
|
|
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 };
|
|
819
|
+
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, SignerZcash, type TransportFactory, debugLog, deviceActionToPromise, isDeviceLockedError, isLedgerBleConnectionType, isLedgerBleDescriptor, isLedgerDmkBleTransport, ledgerFailure, mapLedgerError, offSdkEvent, onSdkEvent };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import * as _onekeyfe_hwk_adapter_core from '@onekeyfe/hwk-adapter-core';
|
|
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';
|
|
2
|
+
import { IHardwareWallet, IConnector, TransportType, UiResponseEvent, SearchDevicesOptions, DeviceInfo, DeviceSearchTarget, ConnectionTarget, Response, IHardwareConnectionContext, 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, ZcashGetFullViewingKeyParams, ZcashFullViewingKey, ZcashGetShieldedAddressParams, ZcashShieldedAddress, DeviceAuthenticityParams, DeviceAuthenticityResult, HardwareEventMap, DeviceEventListener, ChainForFingerprint, DeviceDescriptor, DeviceChangeEvent, ConnectionType, ConnectorDevice, ConnectorSession, ConnectorCallResult, ConnectorEventType, ConnectorEventMap, ConnectorConfig, Failure, HardwareErrorCode, HwkErrorOrigin, HwkRecoveryHint } 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';
|
|
8
9
|
import Transport from '@ledgerhq/hw-transport';
|
|
9
10
|
|
|
10
11
|
/**
|
|
@@ -97,14 +98,27 @@ declare class LedgerAdapter implements IHardwareWallet {
|
|
|
97
98
|
readonly vendor: "ledger";
|
|
98
99
|
private readonly connector;
|
|
99
100
|
private readonly emitter;
|
|
101
|
+
private readonly _interactions;
|
|
100
102
|
private _discoveredDevices;
|
|
101
103
|
private _sessions;
|
|
104
|
+
private readonly _pendingInteractionBindings;
|
|
105
|
+
private readonly _verifiedBleReconnectTargets;
|
|
102
106
|
private readonly _uiRegistry;
|
|
103
107
|
private _btcHighIndexConfirmedThisSession;
|
|
104
108
|
private readonly _jobQueue;
|
|
105
109
|
private _deviceAuthenticityQueueTail;
|
|
106
110
|
private _doConnectAbortController;
|
|
107
111
|
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;
|
|
108
122
|
constructor(connector: IConnector, options?: {
|
|
109
123
|
autoInstallApp?: boolean;
|
|
110
124
|
});
|
|
@@ -118,21 +132,32 @@ declare class LedgerAdapter implements IHardwareWallet {
|
|
|
118
132
|
* The next operation will re-discover and re-connect automatically.
|
|
119
133
|
*/
|
|
120
134
|
resetState(): void;
|
|
135
|
+
private _resetStateAndDisconnectSessions;
|
|
121
136
|
dispose(): Promise<void>;
|
|
122
137
|
uiResponse(response: UiResponseEvent): void;
|
|
123
138
|
searchDevices(options?: SearchDevicesOptions): Promise<DeviceInfo[]>;
|
|
139
|
+
private _searchDevices;
|
|
140
|
+
searchDeviceTargets(options?: SearchDevicesOptions): Promise<DeviceSearchTarget[]>;
|
|
141
|
+
listConnectionTargets(options?: SearchDevicesOptions): Promise<ConnectionTarget[]>;
|
|
124
142
|
private _evictAllSessions;
|
|
125
143
|
private static readonly MAX_BUSINESS_RETRY_BUDGET;
|
|
126
144
|
private static readonly STUCK_APP_RETRY_DELAY_MS;
|
|
127
145
|
private static readonly MAX_DOCONNECT_CONFIRMS;
|
|
128
146
|
private _lastCancelReason;
|
|
147
|
+
private readonly _activeInteractionJobs;
|
|
148
|
+
private readonly _pendingInteractionDisconnects;
|
|
129
149
|
private static readonly APP_INSTALL_PROGRESS_MIN_DELTA;
|
|
130
150
|
private _installProgressLastEmittedValue;
|
|
131
151
|
private _installProgressLastKey;
|
|
132
152
|
private static _createDeviceBusyError;
|
|
133
|
-
connectDevice(
|
|
134
|
-
|
|
135
|
-
|
|
153
|
+
connectDevice(searchTargetId: string): Promise<Response<string>>;
|
|
154
|
+
acquireInteraction(connectId: string, context: IHardwareConnectionContext): Promise<Response<string>>;
|
|
155
|
+
private _createInteraction;
|
|
156
|
+
private _connectTarget;
|
|
157
|
+
releaseInteraction(interactionId: string): Promise<void>;
|
|
158
|
+
private _releaseInteractionConnection;
|
|
159
|
+
private _releaseLostInteractionConnection;
|
|
160
|
+
getDeviceInfo(connectIdOrInteractionId: string, deviceId: string): Promise<Response<DeviceInfo>>;
|
|
136
161
|
getSupportedChains(): ChainCapability[];
|
|
137
162
|
allNetworkGetAddress: (connectId: string, _deviceId: string, params: _onekeyfe_hwk_adapter_core.AllNetworkGetAddressParams) => Promise<Response<_onekeyfe_hwk_adapter_core.AllNetworkAddressResponse[]>>;
|
|
138
163
|
private callChain;
|
|
@@ -157,6 +182,8 @@ declare class LedgerAdapter implements IHardwareWallet {
|
|
|
157
182
|
tronGetAddress(connectId?: string | null, deviceId?: string | null, params?: LedgerCallParams<TronGetAddressParams>): Promise<Response<TronAddress>>;
|
|
158
183
|
tronSignTransaction(connectId?: string | null, deviceId?: string | null, params?: LedgerCallParams<TronSignTxParams>): Promise<Response<TronSignedTx>>;
|
|
159
184
|
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>>;
|
|
160
187
|
installApp(connectId: string, appName: string): Promise<Response<void>>;
|
|
161
188
|
listInstalledApps(connectId: string): Promise<Response<AppMetadata[]>>;
|
|
162
189
|
listInstalledNames(connectId: string): Promise<Response<string[]>>;
|
|
@@ -181,11 +208,11 @@ declare class LedgerAdapter implements IHardwareWallet {
|
|
|
181
208
|
off<K extends keyof HardwareEventMap>(event: K, listener: (event: HardwareEventMap[K]) => void): void;
|
|
182
209
|
off(event: string, listener: DeviceEventListener): void;
|
|
183
210
|
cancel(connectId?: string): void;
|
|
211
|
+
/** A non-empty deviceId is an expected chain fingerprint, not a transport identifier. */
|
|
184
212
|
getChainFingerprint(connectId: string, deviceId: string, chain: ChainForFingerprint): Promise<Response<string>>;
|
|
185
|
-
/**
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
*/
|
|
213
|
+
/** Discovery may select a BLE target before a later call verifies its wallet. */
|
|
214
|
+
private _publishVerifiedBleBinding;
|
|
215
|
+
/** Verify on the acquired session without re-entering the job queue. */
|
|
189
216
|
private _verifyDeviceFingerprintWithSession;
|
|
190
217
|
/**
|
|
191
218
|
* Compute the chain fingerprint via a caller-supplied call strategy.
|
|
@@ -207,7 +234,7 @@ declare class LedgerAdapter implements IHardwareWallet {
|
|
|
207
234
|
*
|
|
208
235
|
* - If a session already exists for the given connectId, reuse it.
|
|
209
236
|
* - If ANY session exists (Ledger IDs are ephemeral), reuse it.
|
|
210
|
-
* - Otherwise: search →
|
|
237
|
+
* - Otherwise: search → one USB device auto-connects; multiple asks the host to choose.
|
|
211
238
|
*/
|
|
212
239
|
private _connectingPromise;
|
|
213
240
|
private _waitForDeviceConnect;
|
|
@@ -250,6 +277,10 @@ declare class LedgerAdapter implements IHardwareWallet {
|
|
|
250
277
|
* lives in one place.
|
|
251
278
|
*/
|
|
252
279
|
private _callConnector;
|
|
280
|
+
private _assertConnectorReady;
|
|
281
|
+
private _runConnectorTeardown;
|
|
282
|
+
private _waitForConnectorOperationsToDrain;
|
|
283
|
+
private _retainConnectorOperation;
|
|
253
284
|
private connectorCall;
|
|
254
285
|
/**
|
|
255
286
|
* Race a promise against an abort signal. On abort, rejects with
|
|
@@ -260,24 +291,7 @@ declare class LedgerAdapter implements IHardwareWallet {
|
|
|
260
291
|
private static _throwIfAborted;
|
|
261
292
|
/** Actual work done under the job queue — connection, fingerprint, call, and recovery. */
|
|
262
293
|
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;
|
|
272
294
|
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;
|
|
281
295
|
/**
|
|
282
296
|
* Ensure OS-level device permission (Bluetooth / USB) before proceeding.
|
|
283
297
|
*
|
|
@@ -654,6 +668,25 @@ declare class SignerSol {
|
|
|
654
668
|
}>;
|
|
655
669
|
}
|
|
656
670
|
|
|
671
|
+
/**
|
|
672
|
+
* Wraps Ledger's Zcash SDK signer (Observable-based DeviceActions) into a
|
|
673
|
+
* simple async interface. Only the viewing-key and shielded-address reads are
|
|
674
|
+
* exposed; PCZT signing goes through a different host-side pipeline.
|
|
675
|
+
*/
|
|
676
|
+
declare class SignerZcash {
|
|
677
|
+
private readonly _sdk;
|
|
678
|
+
onInteraction?: (interaction: string) => void;
|
|
679
|
+
onRegisterCanceller?: (cancel: (reason?: CancelReason) => void) => void;
|
|
680
|
+
constructor(_sdk: SignerZcash$1);
|
|
681
|
+
/** GET_VK: UFVK string (default) or raw 96-byte Orchard FVK. */
|
|
682
|
+
getFullViewingKey(derivationPath: string, options?: FullViewingKeyOptions): Promise<GetFullViewingKeyDAOutput>;
|
|
683
|
+
/** GET_SHIELDED_ADDRESS: single-Orchard-receiver UA for a 5-level transparent path. */
|
|
684
|
+
getShieldedAddress(derivationPath: string, options?: {
|
|
685
|
+
checkOnDevice?: boolean;
|
|
686
|
+
skipOpenApp?: boolean;
|
|
687
|
+
}): Promise<GetShieldedAddressDAOutput>;
|
|
688
|
+
}
|
|
689
|
+
|
|
657
690
|
/**
|
|
658
691
|
* Transport adapter that bridges Ledger's legacy hw-app-* SDKs to DMK's sendApdu.
|
|
659
692
|
*
|
|
@@ -737,7 +770,7 @@ interface WrapErrorOptions {
|
|
|
737
770
|
/** Fallback when err has no `appName` (DMK signer errors don't carry it). */
|
|
738
771
|
defaultAppName?: string;
|
|
739
772
|
}
|
|
740
|
-
declare function ledgerFailure(code: HardwareErrorCode, error: string, appName?: string, tag?: string, params?: Record<string, unknown
|
|
773
|
+
declare function ledgerFailure(code: HardwareErrorCode, error: string, appName?: string, tag?: string, params?: Record<string, unknown>, origin?: HwkErrorOrigin, recovery?: HwkRecoveryHint): LedgerFailure;
|
|
741
774
|
declare function isDeviceLockedError(err: unknown): boolean;
|
|
742
775
|
/**
|
|
743
776
|
* Map a Ledger DMK error to a HardwareErrorCode and human-readable message.
|
|
@@ -747,6 +780,7 @@ declare function isDeviceLockedError(err: unknown): boolean;
|
|
|
747
780
|
declare function mapLedgerError(err: unknown, opts?: WrapErrorOptions): {
|
|
748
781
|
code: HardwareErrorCode;
|
|
749
782
|
message: string;
|
|
783
|
+
origin?: HwkErrorOrigin;
|
|
750
784
|
appName?: string;
|
|
751
785
|
};
|
|
752
786
|
|
|
@@ -782,4 +816,4 @@ declare function isLedgerDmkBleTransport(transport?: string): boolean;
|
|
|
782
816
|
declare function isLedgerBleConnectionType(connectionType?: ConnectionType): boolean;
|
|
783
817
|
declare function isLedgerBleDescriptor(connectionType: ConnectionType, descriptor: DeviceDescriptor): boolean;
|
|
784
818
|
|
|
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 };
|
|
819
|
+
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, SignerZcash, type TransportFactory, debugLog, deviceActionToPromise, isDeviceLockedError, isLedgerBleConnectionType, isLedgerBleDescriptor, isLedgerDmkBleTransport, ledgerFailure, mapLedgerError, offSdkEvent, onSdkEvent };
|