@onekeyfe/hwk-ledger-adapter 1.1.27-alpha.1 → 1.1.27-alpha.101
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 +139 -83
- package/dist/index.d.ts +139 -83
- package/dist/index.js +1410 -283
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1361 -227
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as _onekeyfe_hwk_adapter_core from '@onekeyfe/hwk-adapter-core';
|
|
2
|
+
import { IHardwareWallet, IConnector, TransportType, UiResponseEvent, SearchDevicesOptions, DeviceInfo, Response, ChainCapability, EvmGetAddressParams, ICommonCallParams, EvmAddress, EvmSignTxParams, EvmSignedTx, EvmSignMsgParams, EvmSignature, EvmSignTypedDataParams, BtcGetAddressParams, BtcAddress, BtcGetPublicKeyParams, BtcPublicKey, BtcSignTxParams, BtcSignedTx, BtcSignPsbtParams, BtcSignedPsbt, BtcSignMsgParams, BtcSignature, SolGetAddressParams, SolAddress, SolSignTxParams, SolSignedTx, SolSignMsgParams, SolSignature, TronGetAddressParams, TronAddress, TronSignTxParams, TronSignedTx, TronSignMsgParams, TronSignature, HardwareEventMap, DeviceEventListener, ChainForFingerprint, DeviceDescriptor, DeviceChangeEvent, ConnectionType, ConnectorDevice, ConnectorSession, ConnectorCallResult, ConnectorEventType, ConnectorEventMap, Failure, HardwareErrorCode } from '@onekeyfe/hwk-adapter-core';
|
|
2
3
|
import { DeviceActionState as DeviceActionState$1, DiscoveredDevice, ExecuteDeviceActionReturnType, DeviceManagementKit } from '@ledgerhq/device-management-kit';
|
|
3
4
|
import { Address, Signature, SignerEth as SignerEth$1, TypedData } from '@ledgerhq/device-signer-kit-ethereum';
|
|
4
5
|
import { ContextModule } from '@ledgerhq/context-module';
|
|
@@ -6,26 +7,104 @@ import { SignerBtc as SignerBtc$1 } from '@ledgerhq/device-signer-kit-bitcoin';
|
|
|
6
7
|
import { SignerSolana } from '@ledgerhq/device-signer-kit-solana';
|
|
7
8
|
import Transport from '@ledgerhq/hw-transport';
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Re-export DMK types under local aliases for backward compatibility.
|
|
12
|
+
* These replace the previous duck-typed interfaces with the real SDK types.
|
|
13
|
+
*/
|
|
14
|
+
type DmkDiscoveredDevice = DiscoveredDevice;
|
|
15
|
+
/**
|
|
16
|
+
* DMK DeviceAction — the Observable-based return type of all DMK signer methods.
|
|
17
|
+
*
|
|
18
|
+
* This is a permissive alias for `ExecuteDeviceActionReturnType` that accepts
|
|
19
|
+
* any Error and IntermediateValue generics. Signer wrapper code only cares about
|
|
20
|
+
* the Output type and the observable/cancel shape.
|
|
21
|
+
*/
|
|
22
|
+
type DeviceAction<T> = ExecuteDeviceActionReturnType<T, any, any>;
|
|
23
|
+
/**
|
|
24
|
+
* DMK DeviceActionState — re-exported with permissive Error/IntermediateValue.
|
|
25
|
+
* The real type is a discriminated union on `status`.
|
|
26
|
+
*/
|
|
27
|
+
type DeviceActionState<T> = DeviceActionState$1<T, any, any>;
|
|
28
|
+
/** ETH address result — re-exported from DMK for backward compatibility. */
|
|
29
|
+
type SignerEvmAddress = Address;
|
|
30
|
+
/** ETH signature result — re-exported from DMK for backward compatibility. */
|
|
31
|
+
type SignerEvmSignature = Signature;
|
|
32
|
+
/** BTC address result (WalletAddress not exported from DMK top-level). */
|
|
33
|
+
interface SignerBtcAddress {
|
|
34
|
+
address: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Optional context attached to the rejection when a canceller fires. */
|
|
38
|
+
interface CancelReason {
|
|
39
|
+
code?: number;
|
|
40
|
+
tag?: string;
|
|
41
|
+
message?: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Convert a DMK DeviceAction (Observable-based) into a Promise.
|
|
45
|
+
* Handles pending -> completed/error state transitions and interaction callbacks.
|
|
46
|
+
*
|
|
47
|
+
* Tracks the last DMK step observed (e.g. `signer.eth.steps.blindSignTransactionFallback`)
|
|
48
|
+
* and attaches it to the rejected error as a non-enumerable `_lastStep` property,
|
|
49
|
+
* so upstream error classifiers can distinguish failure contexts (e.g. Blind signing
|
|
50
|
+
* disabled vs. generic Invalid data).
|
|
51
|
+
*
|
|
52
|
+
* @param timeoutMs Idle watchdog ms. Re-armed on each emission, paused
|
|
53
|
+
* during interactive pending. 0 disables. Default 65s
|
|
54
|
+
* (covers DMK's 60s + margin; we're a backstop only).
|
|
55
|
+
* @param onRegisterCanceller Optional callback that receives a function which, when
|
|
56
|
+
* called, unsubscribes and cancels the underlying DeviceAction
|
|
57
|
+
* (releases DMK's IntentQueue slot). Caller is responsible
|
|
58
|
+
* for invoking the canceller on timeout/abort scenarios.
|
|
59
|
+
*/
|
|
60
|
+
declare function deviceActionToPromise<T>(action: DeviceAction<T>, onInteraction?: (interaction: string) => void, timeoutMs?: number, onRegisterCanceller?: (cancel: (reason?: CancelReason) => void) => void, onIntermediate?: (intermediateValue: unknown) => void): Promise<T>;
|
|
61
|
+
|
|
62
|
+
interface AppMetadata {
|
|
63
|
+
versionName: string;
|
|
64
|
+
versionId: number;
|
|
65
|
+
version: string;
|
|
66
|
+
versionDisplayName: string | null;
|
|
67
|
+
description: string | null;
|
|
68
|
+
icon: string | null;
|
|
69
|
+
bytes: number | null;
|
|
70
|
+
currencyId: string | null;
|
|
71
|
+
isDevTools: boolean;
|
|
16
72
|
}
|
|
73
|
+
interface FirmwareVersion {
|
|
74
|
+
/** BOLOS version on the secure element — the user-facing firmware version. */
|
|
75
|
+
seVersion: string;
|
|
76
|
+
/** MCU SEPH (SE–MCU link protocol) version. */
|
|
77
|
+
mcuSephVersion: string;
|
|
78
|
+
/** MCU bootloader version. */
|
|
79
|
+
mcuBootloaderVersion: string;
|
|
80
|
+
/** Hardware revision (e.g. "00" / "01" on Nano X). */
|
|
81
|
+
hwVersion: string;
|
|
82
|
+
}
|
|
83
|
+
/** Full GetOsVersionResponse projected to a plain serializable shape. */
|
|
84
|
+
interface LedgerDeviceInfo extends FirmwareVersion {
|
|
85
|
+
isBootloader: boolean;
|
|
86
|
+
isOsu: boolean;
|
|
87
|
+
targetId: number;
|
|
88
|
+
seTargetId?: number;
|
|
89
|
+
mcuTargetId?: number;
|
|
90
|
+
/** Secure element flags as hex string (raw bytes turned readable). */
|
|
91
|
+
seFlagsHex: string;
|
|
92
|
+
}
|
|
93
|
+
|
|
17
94
|
declare class LedgerAdapter implements IHardwareWallet {
|
|
18
95
|
readonly vendor: "ledger";
|
|
19
96
|
private readonly connector;
|
|
20
97
|
private readonly emitter;
|
|
21
|
-
private readonly _handleSelectDevice;
|
|
22
98
|
private _discoveredDevices;
|
|
23
99
|
private _sessions;
|
|
24
100
|
private readonly _uiRegistry;
|
|
25
101
|
private _btcHighIndexConfirmedThisSession;
|
|
26
102
|
private readonly _jobQueue;
|
|
27
103
|
private _doConnectAbortController;
|
|
28
|
-
|
|
104
|
+
private readonly _defaultAutoInstallApp;
|
|
105
|
+
constructor(connector: IConnector, options?: {
|
|
106
|
+
autoInstallApp?: boolean;
|
|
107
|
+
});
|
|
29
108
|
get activeTransport(): TransportType | null;
|
|
30
109
|
getAvailableTransports(): TransportType[];
|
|
31
110
|
switchTransport(_type: TransportType): Promise<void>;
|
|
@@ -39,34 +118,45 @@ declare class LedgerAdapter implements IHardwareWallet {
|
|
|
39
118
|
dispose(): Promise<void>;
|
|
40
119
|
uiResponse(response: UiResponseEvent): void;
|
|
41
120
|
searchDevices(options?: SearchDevicesOptions): Promise<DeviceInfo[]>;
|
|
121
|
+
private _evictAllSessions;
|
|
42
122
|
private static readonly MAX_BUSINESS_RETRY_BUDGET;
|
|
43
123
|
private static readonly STUCK_APP_RETRY_DELAY_MS;
|
|
44
124
|
private static readonly MAX_DOCONNECT_CONFIRMS;
|
|
45
125
|
private _lastCancelReason;
|
|
126
|
+
private static readonly APP_INSTALL_PROGRESS_MIN_DELTA;
|
|
127
|
+
private _installProgressLastEmittedValue;
|
|
128
|
+
private _installProgressLastKey;
|
|
46
129
|
private static _createDeviceBusyError;
|
|
47
130
|
connectDevice(connectId: string): Promise<Response<string>>;
|
|
48
131
|
disconnectDevice(connectId: string): Promise<void>;
|
|
49
132
|
getDeviceInfo(connectId: string, deviceId: string): Promise<Response<DeviceInfo>>;
|
|
50
133
|
getSupportedChains(): ChainCapability[];
|
|
134
|
+
allNetworkGetAddress: (connectId: string, _deviceId: string, params: _onekeyfe_hwk_adapter_core.AllNetworkGetAddressParams) => Promise<Response<_onekeyfe_hwk_adapter_core.AllNetworkAddressResponse[]>>;
|
|
51
135
|
private callChain;
|
|
52
|
-
evmGetAddress(connectId: string, deviceId: string, params: EvmGetAddressParams): Promise<Response<EvmAddress>>;
|
|
53
|
-
evmSignTransaction(connectId: string, deviceId: string, params: EvmSignTxParams): Promise<Response<EvmSignedTx>>;
|
|
54
|
-
evmSignMessage(connectId: string, deviceId: string, params: EvmSignMsgParams): Promise<Response<EvmSignature>>;
|
|
55
|
-
evmSignTypedData(connectId: string, deviceId: string, params: EvmSignTypedDataParams): Promise<Response<EvmSignature>>;
|
|
56
|
-
btcGetAddress(connectId: string, deviceId: string, params: BtcGetAddressParams): Promise<Response<BtcAddress>>;
|
|
57
|
-
btcGetPublicKey(connectId: string, deviceId: string, params: BtcGetPublicKeyParams): Promise<Response<BtcPublicKey>>;
|
|
58
|
-
btcSignTransaction(connectId: string, deviceId: string, params: BtcSignTxParams): Promise<Response<BtcSignedTx>>;
|
|
59
|
-
btcSignPsbt(connectId: string, deviceId: string, params: BtcSignPsbtParams): Promise<Response<BtcSignedPsbt>>;
|
|
60
|
-
btcSignMessage(connectId: string, deviceId: string, params: BtcSignMsgParams): Promise<Response<BtcSignature>>;
|
|
61
|
-
btcGetMasterFingerprint(connectId: string, deviceId: string): Promise<Response<{
|
|
136
|
+
evmGetAddress(connectId: string, deviceId: string, params: EvmGetAddressParams, commonParams?: ICommonCallParams): Promise<Response<EvmAddress>>;
|
|
137
|
+
evmSignTransaction(connectId: string, deviceId: string, params: EvmSignTxParams, commonParams?: ICommonCallParams): Promise<Response<EvmSignedTx>>;
|
|
138
|
+
evmSignMessage(connectId: string, deviceId: string, params: EvmSignMsgParams, commonParams?: ICommonCallParams): Promise<Response<EvmSignature>>;
|
|
139
|
+
evmSignTypedData(connectId: string, deviceId: string, params: EvmSignTypedDataParams, commonParams?: ICommonCallParams): Promise<Response<EvmSignature>>;
|
|
140
|
+
btcGetAddress(connectId: string, deviceId: string, params: BtcGetAddressParams, commonParams?: ICommonCallParams): Promise<Response<BtcAddress>>;
|
|
141
|
+
btcGetPublicKey(connectId: string, deviceId: string, params: BtcGetPublicKeyParams, commonParams?: ICommonCallParams): Promise<Response<BtcPublicKey>>;
|
|
142
|
+
btcSignTransaction(connectId: string, deviceId: string, params: BtcSignTxParams, commonParams?: ICommonCallParams): Promise<Response<BtcSignedTx>>;
|
|
143
|
+
btcSignPsbt(connectId: string, deviceId: string, params: BtcSignPsbtParams, commonParams?: ICommonCallParams): Promise<Response<BtcSignedPsbt>>;
|
|
144
|
+
btcSignMessage(connectId: string, deviceId: string, params: BtcSignMsgParams, commonParams?: ICommonCallParams): Promise<Response<BtcSignature>>;
|
|
145
|
+
btcGetMasterFingerprint(connectId: string, deviceId: string, commonParams?: ICommonCallParams): Promise<Response<{
|
|
62
146
|
masterFingerprint: string;
|
|
63
147
|
}>>;
|
|
64
|
-
solGetAddress(connectId: string, deviceId: string, params: SolGetAddressParams): Promise<Response<SolAddress>>;
|
|
65
|
-
solSignTransaction(connectId: string, deviceId: string, params: SolSignTxParams): Promise<Response<SolSignedTx>>;
|
|
66
|
-
solSignMessage(connectId: string, deviceId: string, params: SolSignMsgParams): Promise<Response<SolSignature>>;
|
|
67
|
-
tronGetAddress(connectId: string, deviceId: string, params: TronGetAddressParams): Promise<Response<TronAddress>>;
|
|
68
|
-
tronSignTransaction(connectId: string, deviceId: string, params: TronSignTxParams): Promise<Response<TronSignedTx>>;
|
|
69
|
-
tronSignMessage(connectId: string, deviceId: string, params: TronSignMsgParams): Promise<Response<TronSignature>>;
|
|
148
|
+
solGetAddress(connectId: string, deviceId: string, params: SolGetAddressParams, commonParams?: ICommonCallParams): Promise<Response<SolAddress>>;
|
|
149
|
+
solSignTransaction(connectId: string, deviceId: string, params: SolSignTxParams, commonParams?: ICommonCallParams): Promise<Response<SolSignedTx>>;
|
|
150
|
+
solSignMessage(connectId: string, deviceId: string, params: SolSignMsgParams, commonParams?: ICommonCallParams): Promise<Response<SolSignature>>;
|
|
151
|
+
tronGetAddress(connectId: string, deviceId: string, params: TronGetAddressParams, commonParams?: ICommonCallParams): Promise<Response<TronAddress>>;
|
|
152
|
+
tronSignTransaction(connectId: string, deviceId: string, params: TronSignTxParams, commonParams?: ICommonCallParams): Promise<Response<TronSignedTx>>;
|
|
153
|
+
tronSignMessage(connectId: string, deviceId: string, params: TronSignMsgParams, commonParams?: ICommonCallParams): Promise<Response<TronSignature>>;
|
|
154
|
+
installApp(connectId: string, appName: string): Promise<Response<void>>;
|
|
155
|
+
listInstalledApps(connectId: string): Promise<Response<AppMetadata[]>>;
|
|
156
|
+
listInstalledNames(connectId: string): Promise<Response<string[]>>;
|
|
157
|
+
listAvailableApps(connectId: string): Promise<Response<AppMetadata[]>>;
|
|
158
|
+
getLedgerFirmwareVersion(connectId: string): Promise<Response<FirmwareVersion>>;
|
|
159
|
+
getLedgerDeviceInfo(connectId: string): Promise<Response<LedgerDeviceInfo>>;
|
|
70
160
|
on<K extends keyof HardwareEventMap>(event: K, listener: (event: HardwareEventMap[K]) => void): void;
|
|
71
161
|
on(event: string, listener: DeviceEventListener): void;
|
|
72
162
|
off<K extends keyof HardwareEventMap>(event: K, listener: (event: HardwareEventMap[K]) => void): void;
|
|
@@ -98,7 +188,7 @@ declare class LedgerAdapter implements IHardwareWallet {
|
|
|
98
188
|
*
|
|
99
189
|
* - If a session already exists for the given connectId, reuse it.
|
|
100
190
|
* - If ANY session exists (Ledger IDs are ephemeral), reuse it.
|
|
101
|
-
* - Otherwise: search → 1 device
|
|
191
|
+
* - Otherwise: search → exactly 1 USB device auto-connects; multiple or none throws.
|
|
102
192
|
*/
|
|
103
193
|
private _connectingPromise;
|
|
104
194
|
private _waitForDeviceConnect;
|
|
@@ -111,11 +201,11 @@ declare class LedgerAdapter implements IHardwareWallet {
|
|
|
111
201
|
*/
|
|
112
202
|
private _gateBtcHighIndex;
|
|
113
203
|
private _waitForBtcHighIndexConfirm;
|
|
204
|
+
private _waitForInstallAppConfirm;
|
|
114
205
|
private ensureConnected;
|
|
115
206
|
private _doConnect;
|
|
116
207
|
private _connectFirstOrSelect;
|
|
117
208
|
private _connectDeviceOrThrow;
|
|
118
|
-
private _chooseDeviceFromList;
|
|
119
209
|
/**
|
|
120
210
|
* Call the connector with automatic session resolution and disconnect retry.
|
|
121
211
|
*
|
|
@@ -124,6 +214,23 @@ declare class LedgerAdapter implements IHardwareWallet {
|
|
|
124
214
|
* 3. Calls connector.call()
|
|
125
215
|
* 4. On disconnect error: clears stale session, re-connects, retries once
|
|
126
216
|
*/
|
|
217
|
+
/**
|
|
218
|
+
* Unwrap a `ConnectorCallResult` back into the throw-based control flow this
|
|
219
|
+
* class relies on. On failure, rehydrate a FLAT Error (lifting `params.*`
|
|
220
|
+
* back to own-properties) so the downstream recovery predicates
|
|
221
|
+
* (`isStuckAppStateError`, `isDeviceLockedError`, …) and `mapLedgerError`
|
|
222
|
+
* (which read `err._tag` / `err.code` / `err.appName` / `err.originalError`)
|
|
223
|
+
* keep working exactly as before — the Result shape is confined to the
|
|
224
|
+
* connector boundary.
|
|
225
|
+
*/
|
|
226
|
+
private _unwrapConnectorResult;
|
|
227
|
+
/**
|
|
228
|
+
* `connector.call` + result unwrap, optionally raced against an abort
|
|
229
|
+
* signal. Returns the call payload or throws the rehydrated error. All
|
|
230
|
+
* `this.connector.call` usage goes through here so the Result→throw seam
|
|
231
|
+
* lives in one place.
|
|
232
|
+
*/
|
|
233
|
+
private _callConnector;
|
|
127
234
|
private connectorCall;
|
|
128
235
|
/**
|
|
129
236
|
* Race a promise against an abort signal. On abort, rejects with
|
|
@@ -178,33 +285,6 @@ declare class LedgerAdapter implements IHardwareWallet {
|
|
|
178
285
|
private connectorDeviceToDeviceInfo;
|
|
179
286
|
}
|
|
180
287
|
|
|
181
|
-
/**
|
|
182
|
-
* Re-export DMK types under local aliases for backward compatibility.
|
|
183
|
-
* These replace the previous duck-typed interfaces with the real SDK types.
|
|
184
|
-
*/
|
|
185
|
-
type DmkDiscoveredDevice = DiscoveredDevice;
|
|
186
|
-
/**
|
|
187
|
-
* DMK DeviceAction — the Observable-based return type of all DMK signer methods.
|
|
188
|
-
*
|
|
189
|
-
* This is a permissive alias for `ExecuteDeviceActionReturnType` that accepts
|
|
190
|
-
* any Error and IntermediateValue generics. Signer wrapper code only cares about
|
|
191
|
-
* the Output type and the observable/cancel shape.
|
|
192
|
-
*/
|
|
193
|
-
type DeviceAction<T> = ExecuteDeviceActionReturnType<T, any, any>;
|
|
194
|
-
/**
|
|
195
|
-
* DMK DeviceActionState — re-exported with permissive Error/IntermediateValue.
|
|
196
|
-
* The real type is a discriminated union on `status`.
|
|
197
|
-
*/
|
|
198
|
-
type DeviceActionState<T> = DeviceActionState$1<T, any, any>;
|
|
199
|
-
/** ETH address result — re-exported from DMK for backward compatibility. */
|
|
200
|
-
type SignerEvmAddress = Address;
|
|
201
|
-
/** ETH signature result — re-exported from DMK for backward compatibility. */
|
|
202
|
-
type SignerEvmSignature = Signature;
|
|
203
|
-
/** BTC address result (WalletAddress not exported from DMK top-level). */
|
|
204
|
-
interface SignerBtcAddress {
|
|
205
|
-
address: string;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
288
|
/**
|
|
209
289
|
* Manages device discovery, connection, and session tracking.
|
|
210
290
|
* Wraps DMK's Observable APIs into simpler imperative calls.
|
|
@@ -320,6 +400,7 @@ interface LedgerConnectorBaseOptions {
|
|
|
320
400
|
declare class LedgerConnectorBase implements IConnector {
|
|
321
401
|
private _deviceManager;
|
|
322
402
|
private _signerManager;
|
|
403
|
+
private _deviceAppsManager;
|
|
323
404
|
private _dmk;
|
|
324
405
|
private readonly _eventHandlers;
|
|
325
406
|
private readonly _providedDmk;
|
|
@@ -373,13 +454,12 @@ declare class LedgerConnectorBase implements IConnector {
|
|
|
373
454
|
* `LedgerAdapter._sessions` map would hold a dead session entry until
|
|
374
455
|
* the next call hit `DeviceSessionNotFound`.
|
|
375
456
|
*
|
|
376
|
-
*
|
|
377
|
-
* doesn't break the connect path.
|
|
457
|
+
* Subscribe failure is fatal — see the inline note at the subscribe call.
|
|
378
458
|
*/
|
|
379
459
|
private _watchSessionState;
|
|
380
460
|
private _unwatchSessionState;
|
|
381
461
|
private _handleAutonomousDisconnect;
|
|
382
|
-
call(sessionId: string, method: string, params: unknown): Promise<
|
|
462
|
+
call(sessionId: string, method: string, params: unknown): Promise<ConnectorCallResult>;
|
|
383
463
|
private _dispatch;
|
|
384
464
|
cancel(sessionId: string): Promise<void>;
|
|
385
465
|
uiResponse(_response: UiResponseEvent): void;
|
|
@@ -395,6 +475,7 @@ declare class LedgerConnectorBase implements IConnector {
|
|
|
395
475
|
private _initManagers;
|
|
396
476
|
private _getDeviceManager;
|
|
397
477
|
private _getSignerManager;
|
|
478
|
+
private _getDeviceAppsManager;
|
|
398
479
|
private _invalidateSession;
|
|
399
480
|
/**
|
|
400
481
|
* Replace an old session with a new one after app switch.
|
|
@@ -421,31 +502,6 @@ declare class LedgerConnectorBase implements IConnector {
|
|
|
421
502
|
private _wrapError;
|
|
422
503
|
}
|
|
423
504
|
|
|
424
|
-
/** Optional context attached to the rejection when a canceller fires. */
|
|
425
|
-
interface CancelReason {
|
|
426
|
-
code?: number;
|
|
427
|
-
tag?: string;
|
|
428
|
-
message?: string;
|
|
429
|
-
}
|
|
430
|
-
/**
|
|
431
|
-
* Convert a DMK DeviceAction (Observable-based) into a Promise.
|
|
432
|
-
* Handles pending -> completed/error state transitions and interaction callbacks.
|
|
433
|
-
*
|
|
434
|
-
* Tracks the last DMK step observed (e.g. `signer.eth.steps.blindSignTransactionFallback`)
|
|
435
|
-
* and attaches it to the rejected error as a non-enumerable `_lastStep` property,
|
|
436
|
-
* so upstream error classifiers can distinguish failure contexts (e.g. Blind signing
|
|
437
|
-
* disabled vs. generic Invalid data).
|
|
438
|
-
*
|
|
439
|
-
* @param timeoutMs Idle watchdog ms. Re-armed on each emission, paused
|
|
440
|
-
* during interactive pending. 0 disables. Default 65s
|
|
441
|
-
* (covers DMK's 60s + margin; we're a backstop only).
|
|
442
|
-
* @param onRegisterCanceller Optional callback that receives a function which, when
|
|
443
|
-
* called, unsubscribes and cancels the underlying DeviceAction
|
|
444
|
-
* (releases DMK's IntentQueue slot). Caller is responsible
|
|
445
|
-
* for invoking the canceller on timeout/abort scenarios.
|
|
446
|
-
*/
|
|
447
|
-
declare function deviceActionToPromise<T>(action: DeviceAction<T>, onInteraction?: (interaction: string) => void, timeoutMs?: number, onRegisterCanceller?: (cancel: (reason?: CancelReason) => void) => void): Promise<T>;
|
|
448
|
-
|
|
449
505
|
/**
|
|
450
506
|
* Wraps Ledger's SDK signer (Observable-based DeviceActions) into
|
|
451
507
|
* a simple async interface returning plain serializable data.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as _onekeyfe_hwk_adapter_core from '@onekeyfe/hwk-adapter-core';
|
|
2
|
+
import { IHardwareWallet, IConnector, TransportType, UiResponseEvent, SearchDevicesOptions, DeviceInfo, Response, ChainCapability, EvmGetAddressParams, ICommonCallParams, EvmAddress, EvmSignTxParams, EvmSignedTx, EvmSignMsgParams, EvmSignature, EvmSignTypedDataParams, BtcGetAddressParams, BtcAddress, BtcGetPublicKeyParams, BtcPublicKey, BtcSignTxParams, BtcSignedTx, BtcSignPsbtParams, BtcSignedPsbt, BtcSignMsgParams, BtcSignature, SolGetAddressParams, SolAddress, SolSignTxParams, SolSignedTx, SolSignMsgParams, SolSignature, TronGetAddressParams, TronAddress, TronSignTxParams, TronSignedTx, TronSignMsgParams, TronSignature, HardwareEventMap, DeviceEventListener, ChainForFingerprint, DeviceDescriptor, DeviceChangeEvent, ConnectionType, ConnectorDevice, ConnectorSession, ConnectorCallResult, ConnectorEventType, ConnectorEventMap, Failure, HardwareErrorCode } from '@onekeyfe/hwk-adapter-core';
|
|
2
3
|
import { DeviceActionState as DeviceActionState$1, DiscoveredDevice, ExecuteDeviceActionReturnType, DeviceManagementKit } from '@ledgerhq/device-management-kit';
|
|
3
4
|
import { Address, Signature, SignerEth as SignerEth$1, TypedData } from '@ledgerhq/device-signer-kit-ethereum';
|
|
4
5
|
import { ContextModule } from '@ledgerhq/context-module';
|
|
@@ -6,26 +7,104 @@ import { SignerBtc as SignerBtc$1 } from '@ledgerhq/device-signer-kit-bitcoin';
|
|
|
6
7
|
import { SignerSolana } from '@ledgerhq/device-signer-kit-solana';
|
|
7
8
|
import Transport from '@ledgerhq/hw-transport';
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Re-export DMK types under local aliases for backward compatibility.
|
|
12
|
+
* These replace the previous duck-typed interfaces with the real SDK types.
|
|
13
|
+
*/
|
|
14
|
+
type DmkDiscoveredDevice = DiscoveredDevice;
|
|
15
|
+
/**
|
|
16
|
+
* DMK DeviceAction — the Observable-based return type of all DMK signer methods.
|
|
17
|
+
*
|
|
18
|
+
* This is a permissive alias for `ExecuteDeviceActionReturnType` that accepts
|
|
19
|
+
* any Error and IntermediateValue generics. Signer wrapper code only cares about
|
|
20
|
+
* the Output type and the observable/cancel shape.
|
|
21
|
+
*/
|
|
22
|
+
type DeviceAction<T> = ExecuteDeviceActionReturnType<T, any, any>;
|
|
23
|
+
/**
|
|
24
|
+
* DMK DeviceActionState — re-exported with permissive Error/IntermediateValue.
|
|
25
|
+
* The real type is a discriminated union on `status`.
|
|
26
|
+
*/
|
|
27
|
+
type DeviceActionState<T> = DeviceActionState$1<T, any, any>;
|
|
28
|
+
/** ETH address result — re-exported from DMK for backward compatibility. */
|
|
29
|
+
type SignerEvmAddress = Address;
|
|
30
|
+
/** ETH signature result — re-exported from DMK for backward compatibility. */
|
|
31
|
+
type SignerEvmSignature = Signature;
|
|
32
|
+
/** BTC address result (WalletAddress not exported from DMK top-level). */
|
|
33
|
+
interface SignerBtcAddress {
|
|
34
|
+
address: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Optional context attached to the rejection when a canceller fires. */
|
|
38
|
+
interface CancelReason {
|
|
39
|
+
code?: number;
|
|
40
|
+
tag?: string;
|
|
41
|
+
message?: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Convert a DMK DeviceAction (Observable-based) into a Promise.
|
|
45
|
+
* Handles pending -> completed/error state transitions and interaction callbacks.
|
|
46
|
+
*
|
|
47
|
+
* Tracks the last DMK step observed (e.g. `signer.eth.steps.blindSignTransactionFallback`)
|
|
48
|
+
* and attaches it to the rejected error as a non-enumerable `_lastStep` property,
|
|
49
|
+
* so upstream error classifiers can distinguish failure contexts (e.g. Blind signing
|
|
50
|
+
* disabled vs. generic Invalid data).
|
|
51
|
+
*
|
|
52
|
+
* @param timeoutMs Idle watchdog ms. Re-armed on each emission, paused
|
|
53
|
+
* during interactive pending. 0 disables. Default 65s
|
|
54
|
+
* (covers DMK's 60s + margin; we're a backstop only).
|
|
55
|
+
* @param onRegisterCanceller Optional callback that receives a function which, when
|
|
56
|
+
* called, unsubscribes and cancels the underlying DeviceAction
|
|
57
|
+
* (releases DMK's IntentQueue slot). Caller is responsible
|
|
58
|
+
* for invoking the canceller on timeout/abort scenarios.
|
|
59
|
+
*/
|
|
60
|
+
declare function deviceActionToPromise<T>(action: DeviceAction<T>, onInteraction?: (interaction: string) => void, timeoutMs?: number, onRegisterCanceller?: (cancel: (reason?: CancelReason) => void) => void, onIntermediate?: (intermediateValue: unknown) => void): Promise<T>;
|
|
61
|
+
|
|
62
|
+
interface AppMetadata {
|
|
63
|
+
versionName: string;
|
|
64
|
+
versionId: number;
|
|
65
|
+
version: string;
|
|
66
|
+
versionDisplayName: string | null;
|
|
67
|
+
description: string | null;
|
|
68
|
+
icon: string | null;
|
|
69
|
+
bytes: number | null;
|
|
70
|
+
currencyId: string | null;
|
|
71
|
+
isDevTools: boolean;
|
|
16
72
|
}
|
|
73
|
+
interface FirmwareVersion {
|
|
74
|
+
/** BOLOS version on the secure element — the user-facing firmware version. */
|
|
75
|
+
seVersion: string;
|
|
76
|
+
/** MCU SEPH (SE–MCU link protocol) version. */
|
|
77
|
+
mcuSephVersion: string;
|
|
78
|
+
/** MCU bootloader version. */
|
|
79
|
+
mcuBootloaderVersion: string;
|
|
80
|
+
/** Hardware revision (e.g. "00" / "01" on Nano X). */
|
|
81
|
+
hwVersion: string;
|
|
82
|
+
}
|
|
83
|
+
/** Full GetOsVersionResponse projected to a plain serializable shape. */
|
|
84
|
+
interface LedgerDeviceInfo extends FirmwareVersion {
|
|
85
|
+
isBootloader: boolean;
|
|
86
|
+
isOsu: boolean;
|
|
87
|
+
targetId: number;
|
|
88
|
+
seTargetId?: number;
|
|
89
|
+
mcuTargetId?: number;
|
|
90
|
+
/** Secure element flags as hex string (raw bytes turned readable). */
|
|
91
|
+
seFlagsHex: string;
|
|
92
|
+
}
|
|
93
|
+
|
|
17
94
|
declare class LedgerAdapter implements IHardwareWallet {
|
|
18
95
|
readonly vendor: "ledger";
|
|
19
96
|
private readonly connector;
|
|
20
97
|
private readonly emitter;
|
|
21
|
-
private readonly _handleSelectDevice;
|
|
22
98
|
private _discoveredDevices;
|
|
23
99
|
private _sessions;
|
|
24
100
|
private readonly _uiRegistry;
|
|
25
101
|
private _btcHighIndexConfirmedThisSession;
|
|
26
102
|
private readonly _jobQueue;
|
|
27
103
|
private _doConnectAbortController;
|
|
28
|
-
|
|
104
|
+
private readonly _defaultAutoInstallApp;
|
|
105
|
+
constructor(connector: IConnector, options?: {
|
|
106
|
+
autoInstallApp?: boolean;
|
|
107
|
+
});
|
|
29
108
|
get activeTransport(): TransportType | null;
|
|
30
109
|
getAvailableTransports(): TransportType[];
|
|
31
110
|
switchTransport(_type: TransportType): Promise<void>;
|
|
@@ -39,34 +118,45 @@ declare class LedgerAdapter implements IHardwareWallet {
|
|
|
39
118
|
dispose(): Promise<void>;
|
|
40
119
|
uiResponse(response: UiResponseEvent): void;
|
|
41
120
|
searchDevices(options?: SearchDevicesOptions): Promise<DeviceInfo[]>;
|
|
121
|
+
private _evictAllSessions;
|
|
42
122
|
private static readonly MAX_BUSINESS_RETRY_BUDGET;
|
|
43
123
|
private static readonly STUCK_APP_RETRY_DELAY_MS;
|
|
44
124
|
private static readonly MAX_DOCONNECT_CONFIRMS;
|
|
45
125
|
private _lastCancelReason;
|
|
126
|
+
private static readonly APP_INSTALL_PROGRESS_MIN_DELTA;
|
|
127
|
+
private _installProgressLastEmittedValue;
|
|
128
|
+
private _installProgressLastKey;
|
|
46
129
|
private static _createDeviceBusyError;
|
|
47
130
|
connectDevice(connectId: string): Promise<Response<string>>;
|
|
48
131
|
disconnectDevice(connectId: string): Promise<void>;
|
|
49
132
|
getDeviceInfo(connectId: string, deviceId: string): Promise<Response<DeviceInfo>>;
|
|
50
133
|
getSupportedChains(): ChainCapability[];
|
|
134
|
+
allNetworkGetAddress: (connectId: string, _deviceId: string, params: _onekeyfe_hwk_adapter_core.AllNetworkGetAddressParams) => Promise<Response<_onekeyfe_hwk_adapter_core.AllNetworkAddressResponse[]>>;
|
|
51
135
|
private callChain;
|
|
52
|
-
evmGetAddress(connectId: string, deviceId: string, params: EvmGetAddressParams): Promise<Response<EvmAddress>>;
|
|
53
|
-
evmSignTransaction(connectId: string, deviceId: string, params: EvmSignTxParams): Promise<Response<EvmSignedTx>>;
|
|
54
|
-
evmSignMessage(connectId: string, deviceId: string, params: EvmSignMsgParams): Promise<Response<EvmSignature>>;
|
|
55
|
-
evmSignTypedData(connectId: string, deviceId: string, params: EvmSignTypedDataParams): Promise<Response<EvmSignature>>;
|
|
56
|
-
btcGetAddress(connectId: string, deviceId: string, params: BtcGetAddressParams): Promise<Response<BtcAddress>>;
|
|
57
|
-
btcGetPublicKey(connectId: string, deviceId: string, params: BtcGetPublicKeyParams): Promise<Response<BtcPublicKey>>;
|
|
58
|
-
btcSignTransaction(connectId: string, deviceId: string, params: BtcSignTxParams): Promise<Response<BtcSignedTx>>;
|
|
59
|
-
btcSignPsbt(connectId: string, deviceId: string, params: BtcSignPsbtParams): Promise<Response<BtcSignedPsbt>>;
|
|
60
|
-
btcSignMessage(connectId: string, deviceId: string, params: BtcSignMsgParams): Promise<Response<BtcSignature>>;
|
|
61
|
-
btcGetMasterFingerprint(connectId: string, deviceId: string): Promise<Response<{
|
|
136
|
+
evmGetAddress(connectId: string, deviceId: string, params: EvmGetAddressParams, commonParams?: ICommonCallParams): Promise<Response<EvmAddress>>;
|
|
137
|
+
evmSignTransaction(connectId: string, deviceId: string, params: EvmSignTxParams, commonParams?: ICommonCallParams): Promise<Response<EvmSignedTx>>;
|
|
138
|
+
evmSignMessage(connectId: string, deviceId: string, params: EvmSignMsgParams, commonParams?: ICommonCallParams): Promise<Response<EvmSignature>>;
|
|
139
|
+
evmSignTypedData(connectId: string, deviceId: string, params: EvmSignTypedDataParams, commonParams?: ICommonCallParams): Promise<Response<EvmSignature>>;
|
|
140
|
+
btcGetAddress(connectId: string, deviceId: string, params: BtcGetAddressParams, commonParams?: ICommonCallParams): Promise<Response<BtcAddress>>;
|
|
141
|
+
btcGetPublicKey(connectId: string, deviceId: string, params: BtcGetPublicKeyParams, commonParams?: ICommonCallParams): Promise<Response<BtcPublicKey>>;
|
|
142
|
+
btcSignTransaction(connectId: string, deviceId: string, params: BtcSignTxParams, commonParams?: ICommonCallParams): Promise<Response<BtcSignedTx>>;
|
|
143
|
+
btcSignPsbt(connectId: string, deviceId: string, params: BtcSignPsbtParams, commonParams?: ICommonCallParams): Promise<Response<BtcSignedPsbt>>;
|
|
144
|
+
btcSignMessage(connectId: string, deviceId: string, params: BtcSignMsgParams, commonParams?: ICommonCallParams): Promise<Response<BtcSignature>>;
|
|
145
|
+
btcGetMasterFingerprint(connectId: string, deviceId: string, commonParams?: ICommonCallParams): Promise<Response<{
|
|
62
146
|
masterFingerprint: string;
|
|
63
147
|
}>>;
|
|
64
|
-
solGetAddress(connectId: string, deviceId: string, params: SolGetAddressParams): Promise<Response<SolAddress>>;
|
|
65
|
-
solSignTransaction(connectId: string, deviceId: string, params: SolSignTxParams): Promise<Response<SolSignedTx>>;
|
|
66
|
-
solSignMessage(connectId: string, deviceId: string, params: SolSignMsgParams): Promise<Response<SolSignature>>;
|
|
67
|
-
tronGetAddress(connectId: string, deviceId: string, params: TronGetAddressParams): Promise<Response<TronAddress>>;
|
|
68
|
-
tronSignTransaction(connectId: string, deviceId: string, params: TronSignTxParams): Promise<Response<TronSignedTx>>;
|
|
69
|
-
tronSignMessage(connectId: string, deviceId: string, params: TronSignMsgParams): Promise<Response<TronSignature>>;
|
|
148
|
+
solGetAddress(connectId: string, deviceId: string, params: SolGetAddressParams, commonParams?: ICommonCallParams): Promise<Response<SolAddress>>;
|
|
149
|
+
solSignTransaction(connectId: string, deviceId: string, params: SolSignTxParams, commonParams?: ICommonCallParams): Promise<Response<SolSignedTx>>;
|
|
150
|
+
solSignMessage(connectId: string, deviceId: string, params: SolSignMsgParams, commonParams?: ICommonCallParams): Promise<Response<SolSignature>>;
|
|
151
|
+
tronGetAddress(connectId: string, deviceId: string, params: TronGetAddressParams, commonParams?: ICommonCallParams): Promise<Response<TronAddress>>;
|
|
152
|
+
tronSignTransaction(connectId: string, deviceId: string, params: TronSignTxParams, commonParams?: ICommonCallParams): Promise<Response<TronSignedTx>>;
|
|
153
|
+
tronSignMessage(connectId: string, deviceId: string, params: TronSignMsgParams, commonParams?: ICommonCallParams): Promise<Response<TronSignature>>;
|
|
154
|
+
installApp(connectId: string, appName: string): Promise<Response<void>>;
|
|
155
|
+
listInstalledApps(connectId: string): Promise<Response<AppMetadata[]>>;
|
|
156
|
+
listInstalledNames(connectId: string): Promise<Response<string[]>>;
|
|
157
|
+
listAvailableApps(connectId: string): Promise<Response<AppMetadata[]>>;
|
|
158
|
+
getLedgerFirmwareVersion(connectId: string): Promise<Response<FirmwareVersion>>;
|
|
159
|
+
getLedgerDeviceInfo(connectId: string): Promise<Response<LedgerDeviceInfo>>;
|
|
70
160
|
on<K extends keyof HardwareEventMap>(event: K, listener: (event: HardwareEventMap[K]) => void): void;
|
|
71
161
|
on(event: string, listener: DeviceEventListener): void;
|
|
72
162
|
off<K extends keyof HardwareEventMap>(event: K, listener: (event: HardwareEventMap[K]) => void): void;
|
|
@@ -98,7 +188,7 @@ declare class LedgerAdapter implements IHardwareWallet {
|
|
|
98
188
|
*
|
|
99
189
|
* - If a session already exists for the given connectId, reuse it.
|
|
100
190
|
* - If ANY session exists (Ledger IDs are ephemeral), reuse it.
|
|
101
|
-
* - Otherwise: search → 1 device
|
|
191
|
+
* - Otherwise: search → exactly 1 USB device auto-connects; multiple or none throws.
|
|
102
192
|
*/
|
|
103
193
|
private _connectingPromise;
|
|
104
194
|
private _waitForDeviceConnect;
|
|
@@ -111,11 +201,11 @@ declare class LedgerAdapter implements IHardwareWallet {
|
|
|
111
201
|
*/
|
|
112
202
|
private _gateBtcHighIndex;
|
|
113
203
|
private _waitForBtcHighIndexConfirm;
|
|
204
|
+
private _waitForInstallAppConfirm;
|
|
114
205
|
private ensureConnected;
|
|
115
206
|
private _doConnect;
|
|
116
207
|
private _connectFirstOrSelect;
|
|
117
208
|
private _connectDeviceOrThrow;
|
|
118
|
-
private _chooseDeviceFromList;
|
|
119
209
|
/**
|
|
120
210
|
* Call the connector with automatic session resolution and disconnect retry.
|
|
121
211
|
*
|
|
@@ -124,6 +214,23 @@ declare class LedgerAdapter implements IHardwareWallet {
|
|
|
124
214
|
* 3. Calls connector.call()
|
|
125
215
|
* 4. On disconnect error: clears stale session, re-connects, retries once
|
|
126
216
|
*/
|
|
217
|
+
/**
|
|
218
|
+
* Unwrap a `ConnectorCallResult` back into the throw-based control flow this
|
|
219
|
+
* class relies on. On failure, rehydrate a FLAT Error (lifting `params.*`
|
|
220
|
+
* back to own-properties) so the downstream recovery predicates
|
|
221
|
+
* (`isStuckAppStateError`, `isDeviceLockedError`, …) and `mapLedgerError`
|
|
222
|
+
* (which read `err._tag` / `err.code` / `err.appName` / `err.originalError`)
|
|
223
|
+
* keep working exactly as before — the Result shape is confined to the
|
|
224
|
+
* connector boundary.
|
|
225
|
+
*/
|
|
226
|
+
private _unwrapConnectorResult;
|
|
227
|
+
/**
|
|
228
|
+
* `connector.call` + result unwrap, optionally raced against an abort
|
|
229
|
+
* signal. Returns the call payload or throws the rehydrated error. All
|
|
230
|
+
* `this.connector.call` usage goes through here so the Result→throw seam
|
|
231
|
+
* lives in one place.
|
|
232
|
+
*/
|
|
233
|
+
private _callConnector;
|
|
127
234
|
private connectorCall;
|
|
128
235
|
/**
|
|
129
236
|
* Race a promise against an abort signal. On abort, rejects with
|
|
@@ -178,33 +285,6 @@ declare class LedgerAdapter implements IHardwareWallet {
|
|
|
178
285
|
private connectorDeviceToDeviceInfo;
|
|
179
286
|
}
|
|
180
287
|
|
|
181
|
-
/**
|
|
182
|
-
* Re-export DMK types under local aliases for backward compatibility.
|
|
183
|
-
* These replace the previous duck-typed interfaces with the real SDK types.
|
|
184
|
-
*/
|
|
185
|
-
type DmkDiscoveredDevice = DiscoveredDevice;
|
|
186
|
-
/**
|
|
187
|
-
* DMK DeviceAction — the Observable-based return type of all DMK signer methods.
|
|
188
|
-
*
|
|
189
|
-
* This is a permissive alias for `ExecuteDeviceActionReturnType` that accepts
|
|
190
|
-
* any Error and IntermediateValue generics. Signer wrapper code only cares about
|
|
191
|
-
* the Output type and the observable/cancel shape.
|
|
192
|
-
*/
|
|
193
|
-
type DeviceAction<T> = ExecuteDeviceActionReturnType<T, any, any>;
|
|
194
|
-
/**
|
|
195
|
-
* DMK DeviceActionState — re-exported with permissive Error/IntermediateValue.
|
|
196
|
-
* The real type is a discriminated union on `status`.
|
|
197
|
-
*/
|
|
198
|
-
type DeviceActionState<T> = DeviceActionState$1<T, any, any>;
|
|
199
|
-
/** ETH address result — re-exported from DMK for backward compatibility. */
|
|
200
|
-
type SignerEvmAddress = Address;
|
|
201
|
-
/** ETH signature result — re-exported from DMK for backward compatibility. */
|
|
202
|
-
type SignerEvmSignature = Signature;
|
|
203
|
-
/** BTC address result (WalletAddress not exported from DMK top-level). */
|
|
204
|
-
interface SignerBtcAddress {
|
|
205
|
-
address: string;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
288
|
/**
|
|
209
289
|
* Manages device discovery, connection, and session tracking.
|
|
210
290
|
* Wraps DMK's Observable APIs into simpler imperative calls.
|
|
@@ -320,6 +400,7 @@ interface LedgerConnectorBaseOptions {
|
|
|
320
400
|
declare class LedgerConnectorBase implements IConnector {
|
|
321
401
|
private _deviceManager;
|
|
322
402
|
private _signerManager;
|
|
403
|
+
private _deviceAppsManager;
|
|
323
404
|
private _dmk;
|
|
324
405
|
private readonly _eventHandlers;
|
|
325
406
|
private readonly _providedDmk;
|
|
@@ -373,13 +454,12 @@ declare class LedgerConnectorBase implements IConnector {
|
|
|
373
454
|
* `LedgerAdapter._sessions` map would hold a dead session entry until
|
|
374
455
|
* the next call hit `DeviceSessionNotFound`.
|
|
375
456
|
*
|
|
376
|
-
*
|
|
377
|
-
* doesn't break the connect path.
|
|
457
|
+
* Subscribe failure is fatal — see the inline note at the subscribe call.
|
|
378
458
|
*/
|
|
379
459
|
private _watchSessionState;
|
|
380
460
|
private _unwatchSessionState;
|
|
381
461
|
private _handleAutonomousDisconnect;
|
|
382
|
-
call(sessionId: string, method: string, params: unknown): Promise<
|
|
462
|
+
call(sessionId: string, method: string, params: unknown): Promise<ConnectorCallResult>;
|
|
383
463
|
private _dispatch;
|
|
384
464
|
cancel(sessionId: string): Promise<void>;
|
|
385
465
|
uiResponse(_response: UiResponseEvent): void;
|
|
@@ -395,6 +475,7 @@ declare class LedgerConnectorBase implements IConnector {
|
|
|
395
475
|
private _initManagers;
|
|
396
476
|
private _getDeviceManager;
|
|
397
477
|
private _getSignerManager;
|
|
478
|
+
private _getDeviceAppsManager;
|
|
398
479
|
private _invalidateSession;
|
|
399
480
|
/**
|
|
400
481
|
* Replace an old session with a new one after app switch.
|
|
@@ -421,31 +502,6 @@ declare class LedgerConnectorBase implements IConnector {
|
|
|
421
502
|
private _wrapError;
|
|
422
503
|
}
|
|
423
504
|
|
|
424
|
-
/** Optional context attached to the rejection when a canceller fires. */
|
|
425
|
-
interface CancelReason {
|
|
426
|
-
code?: number;
|
|
427
|
-
tag?: string;
|
|
428
|
-
message?: string;
|
|
429
|
-
}
|
|
430
|
-
/**
|
|
431
|
-
* Convert a DMK DeviceAction (Observable-based) into a Promise.
|
|
432
|
-
* Handles pending -> completed/error state transitions and interaction callbacks.
|
|
433
|
-
*
|
|
434
|
-
* Tracks the last DMK step observed (e.g. `signer.eth.steps.blindSignTransactionFallback`)
|
|
435
|
-
* and attaches it to the rejected error as a non-enumerable `_lastStep` property,
|
|
436
|
-
* so upstream error classifiers can distinguish failure contexts (e.g. Blind signing
|
|
437
|
-
* disabled vs. generic Invalid data).
|
|
438
|
-
*
|
|
439
|
-
* @param timeoutMs Idle watchdog ms. Re-armed on each emission, paused
|
|
440
|
-
* during interactive pending. 0 disables. Default 65s
|
|
441
|
-
* (covers DMK's 60s + margin; we're a backstop only).
|
|
442
|
-
* @param onRegisterCanceller Optional callback that receives a function which, when
|
|
443
|
-
* called, unsubscribes and cancels the underlying DeviceAction
|
|
444
|
-
* (releases DMK's IntentQueue slot). Caller is responsible
|
|
445
|
-
* for invoking the canceller on timeout/abort scenarios.
|
|
446
|
-
*/
|
|
447
|
-
declare function deviceActionToPromise<T>(action: DeviceAction<T>, onInteraction?: (interaction: string) => void, timeoutMs?: number, onRegisterCanceller?: (cancel: (reason?: CancelReason) => void) => void): Promise<T>;
|
|
448
|
-
|
|
449
505
|
/**
|
|
450
506
|
* Wraps Ledger's SDK signer (Observable-based DeviceActions) into
|
|
451
507
|
* a simple async interface returning plain serializable data.
|