@onekeyfe/hwk-ledger-adapter 1.1.26 → 1.1.27-alpha.100
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 +95 -65
- package/dist/index.d.ts +95 -65
- package/dist/index.js +606 -97
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +606 -97
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -6,26 +6,101 @@ import { SignerBtc as SignerBtc$1 } from '@ledgerhq/device-signer-kit-bitcoin';
|
|
|
6
6
|
import { SignerSolana } from '@ledgerhq/device-signer-kit-solana';
|
|
7
7
|
import Transport from '@ledgerhq/hw-transport';
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Re-export DMK types under local aliases for backward compatibility.
|
|
11
|
+
* These replace the previous duck-typed interfaces with the real SDK types.
|
|
12
|
+
*/
|
|
13
|
+
type DmkDiscoveredDevice = DiscoveredDevice;
|
|
14
|
+
/**
|
|
15
|
+
* DMK DeviceAction — the Observable-based return type of all DMK signer methods.
|
|
16
|
+
*
|
|
17
|
+
* This is a permissive alias for `ExecuteDeviceActionReturnType` that accepts
|
|
18
|
+
* any Error and IntermediateValue generics. Signer wrapper code only cares about
|
|
19
|
+
* the Output type and the observable/cancel shape.
|
|
20
|
+
*/
|
|
21
|
+
type DeviceAction<T> = ExecuteDeviceActionReturnType<T, any, any>;
|
|
22
|
+
/**
|
|
23
|
+
* DMK DeviceActionState — re-exported with permissive Error/IntermediateValue.
|
|
24
|
+
* The real type is a discriminated union on `status`.
|
|
25
|
+
*/
|
|
26
|
+
type DeviceActionState<T> = DeviceActionState$1<T, any, any>;
|
|
27
|
+
/** ETH address result — re-exported from DMK for backward compatibility. */
|
|
28
|
+
type SignerEvmAddress = Address;
|
|
29
|
+
/** ETH signature result — re-exported from DMK for backward compatibility. */
|
|
30
|
+
type SignerEvmSignature = Signature;
|
|
31
|
+
/** BTC address result (WalletAddress not exported from DMK top-level). */
|
|
32
|
+
interface SignerBtcAddress {
|
|
33
|
+
address: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Optional context attached to the rejection when a canceller fires. */
|
|
37
|
+
interface CancelReason {
|
|
38
|
+
code?: number;
|
|
39
|
+
tag?: string;
|
|
40
|
+
message?: string;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Convert a DMK DeviceAction (Observable-based) into a Promise.
|
|
44
|
+
* Handles pending -> completed/error state transitions and interaction callbacks.
|
|
45
|
+
*
|
|
46
|
+
* Tracks the last DMK step observed (e.g. `signer.eth.steps.blindSignTransactionFallback`)
|
|
47
|
+
* and attaches it to the rejected error as a non-enumerable `_lastStep` property,
|
|
48
|
+
* so upstream error classifiers can distinguish failure contexts (e.g. Blind signing
|
|
49
|
+
* disabled vs. generic Invalid data).
|
|
50
|
+
*
|
|
51
|
+
* @param timeoutMs Idle watchdog ms. Re-armed on each emission, paused
|
|
52
|
+
* during interactive pending. 0 disables. Default 65s
|
|
53
|
+
* (covers DMK's 60s + margin; we're a backstop only).
|
|
54
|
+
* @param onRegisterCanceller Optional callback that receives a function which, when
|
|
55
|
+
* called, unsubscribes and cancels the underlying DeviceAction
|
|
56
|
+
* (releases DMK's IntentQueue slot). Caller is responsible
|
|
57
|
+
* for invoking the canceller on timeout/abort scenarios.
|
|
58
|
+
*/
|
|
59
|
+
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>;
|
|
60
|
+
|
|
61
|
+
interface AppMetadata {
|
|
62
|
+
versionName: string;
|
|
63
|
+
versionId: number;
|
|
64
|
+
version: string;
|
|
65
|
+
versionDisplayName: string | null;
|
|
66
|
+
description: string | null;
|
|
67
|
+
icon: string | null;
|
|
68
|
+
bytes: number | null;
|
|
69
|
+
currencyId: string | null;
|
|
70
|
+
isDevTools: boolean;
|
|
71
|
+
}
|
|
72
|
+
interface FirmwareVersion {
|
|
73
|
+
/** BOLOS version on the secure element — the user-facing firmware version. */
|
|
74
|
+
seVersion: string;
|
|
75
|
+
/** MCU SEPH (SE–MCU link protocol) version. */
|
|
76
|
+
mcuSephVersion: string;
|
|
77
|
+
/** MCU bootloader version. */
|
|
78
|
+
mcuBootloaderVersion: string;
|
|
79
|
+
/** Hardware revision (e.g. "00" / "01" on Nano X). */
|
|
80
|
+
hwVersion: string;
|
|
16
81
|
}
|
|
82
|
+
/** Full GetOsVersionResponse projected to a plain serializable shape. */
|
|
83
|
+
interface LedgerDeviceInfo extends FirmwareVersion {
|
|
84
|
+
isBootloader: boolean;
|
|
85
|
+
isOsu: boolean;
|
|
86
|
+
targetId: number;
|
|
87
|
+
seTargetId?: number;
|
|
88
|
+
mcuTargetId?: number;
|
|
89
|
+
/** Secure element flags as hex string (raw bytes turned readable). */
|
|
90
|
+
seFlagsHex: string;
|
|
91
|
+
}
|
|
92
|
+
|
|
17
93
|
declare class LedgerAdapter implements IHardwareWallet {
|
|
18
94
|
readonly vendor: "ledger";
|
|
19
95
|
private readonly connector;
|
|
20
96
|
private readonly emitter;
|
|
21
|
-
private readonly _handleSelectDevice;
|
|
22
97
|
private _discoveredDevices;
|
|
23
98
|
private _sessions;
|
|
24
99
|
private readonly _uiRegistry;
|
|
25
100
|
private _btcHighIndexConfirmedThisSession;
|
|
26
101
|
private readonly _jobQueue;
|
|
27
102
|
private _doConnectAbortController;
|
|
28
|
-
constructor(connector: IConnector
|
|
103
|
+
constructor(connector: IConnector);
|
|
29
104
|
get activeTransport(): TransportType | null;
|
|
30
105
|
getAvailableTransports(): TransportType[];
|
|
31
106
|
switchTransport(_type: TransportType): Promise<void>;
|
|
@@ -39,6 +114,7 @@ declare class LedgerAdapter implements IHardwareWallet {
|
|
|
39
114
|
dispose(): Promise<void>;
|
|
40
115
|
uiResponse(response: UiResponseEvent): void;
|
|
41
116
|
searchDevices(options?: SearchDevicesOptions): Promise<DeviceInfo[]>;
|
|
117
|
+
private _evictAllSessions;
|
|
42
118
|
private static readonly MAX_BUSINESS_RETRY_BUDGET;
|
|
43
119
|
private static readonly STUCK_APP_RETRY_DELAY_MS;
|
|
44
120
|
private static readonly MAX_DOCONNECT_CONFIRMS;
|
|
@@ -67,6 +143,11 @@ declare class LedgerAdapter implements IHardwareWallet {
|
|
|
67
143
|
tronGetAddress(connectId: string, deviceId: string, params: TronGetAddressParams): Promise<Response<TronAddress>>;
|
|
68
144
|
tronSignTransaction(connectId: string, deviceId: string, params: TronSignTxParams): Promise<Response<TronSignedTx>>;
|
|
69
145
|
tronSignMessage(connectId: string, deviceId: string, params: TronSignMsgParams): Promise<Response<TronSignature>>;
|
|
146
|
+
installApp(connectId: string, appName: string): Promise<Response<void>>;
|
|
147
|
+
listInstalledApps(connectId: string): Promise<Response<AppMetadata[]>>;
|
|
148
|
+
listAvailableApps(connectId: string): Promise<Response<AppMetadata[]>>;
|
|
149
|
+
getLedgerFirmwareVersion(connectId: string): Promise<Response<FirmwareVersion>>;
|
|
150
|
+
getLedgerDeviceInfo(connectId: string): Promise<Response<LedgerDeviceInfo>>;
|
|
70
151
|
on<K extends keyof HardwareEventMap>(event: K, listener: (event: HardwareEventMap[K]) => void): void;
|
|
71
152
|
on(event: string, listener: DeviceEventListener): void;
|
|
72
153
|
off<K extends keyof HardwareEventMap>(event: K, listener: (event: HardwareEventMap[K]) => void): void;
|
|
@@ -98,7 +179,7 @@ declare class LedgerAdapter implements IHardwareWallet {
|
|
|
98
179
|
*
|
|
99
180
|
* - If a session already exists for the given connectId, reuse it.
|
|
100
181
|
* - If ANY session exists (Ledger IDs are ephemeral), reuse it.
|
|
101
|
-
* - Otherwise: search → 1 device
|
|
182
|
+
* - Otherwise: search → exactly 1 USB device auto-connects; multiple or none throws.
|
|
102
183
|
*/
|
|
103
184
|
private _connectingPromise;
|
|
104
185
|
private _waitForDeviceConnect;
|
|
@@ -115,7 +196,6 @@ declare class LedgerAdapter implements IHardwareWallet {
|
|
|
115
196
|
private _doConnect;
|
|
116
197
|
private _connectFirstOrSelect;
|
|
117
198
|
private _connectDeviceOrThrow;
|
|
118
|
-
private _chooseDeviceFromList;
|
|
119
199
|
/**
|
|
120
200
|
* Call the connector with automatic session resolution and disconnect retry.
|
|
121
201
|
*
|
|
@@ -173,38 +253,12 @@ declare class LedgerAdapter implements IHardwareWallet {
|
|
|
173
253
|
private deviceConnectHandler;
|
|
174
254
|
private deviceDisconnectHandler;
|
|
175
255
|
private uiEventForwarder;
|
|
256
|
+
private appInstallProgressForwarder;
|
|
176
257
|
private registerEventListeners;
|
|
177
258
|
private unregisterEventListeners;
|
|
178
259
|
private connectorDeviceToDeviceInfo;
|
|
179
260
|
}
|
|
180
261
|
|
|
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
262
|
/**
|
|
209
263
|
* Manages device discovery, connection, and session tracking.
|
|
210
264
|
* Wraps DMK's Observable APIs into simpler imperative calls.
|
|
@@ -320,6 +374,7 @@ interface LedgerConnectorBaseOptions {
|
|
|
320
374
|
declare class LedgerConnectorBase implements IConnector {
|
|
321
375
|
private _deviceManager;
|
|
322
376
|
private _signerManager;
|
|
377
|
+
private _deviceAppsManager;
|
|
323
378
|
private _dmk;
|
|
324
379
|
private readonly _eventHandlers;
|
|
325
380
|
private readonly _providedDmk;
|
|
@@ -373,8 +428,7 @@ declare class LedgerConnectorBase implements IConnector {
|
|
|
373
428
|
* `LedgerAdapter._sessions` map would hold a dead session entry until
|
|
374
429
|
* the next call hit `DeviceSessionNotFound`.
|
|
375
430
|
*
|
|
376
|
-
*
|
|
377
|
-
* doesn't break the connect path.
|
|
431
|
+
* Subscribe failure is fatal — see the inline note at the subscribe call.
|
|
378
432
|
*/
|
|
379
433
|
private _watchSessionState;
|
|
380
434
|
private _unwatchSessionState;
|
|
@@ -395,6 +449,7 @@ declare class LedgerConnectorBase implements IConnector {
|
|
|
395
449
|
private _initManagers;
|
|
396
450
|
private _getDeviceManager;
|
|
397
451
|
private _getSignerManager;
|
|
452
|
+
private _getDeviceAppsManager;
|
|
398
453
|
private _invalidateSession;
|
|
399
454
|
/**
|
|
400
455
|
* Replace an old session with a new one after app switch.
|
|
@@ -421,31 +476,6 @@ declare class LedgerConnectorBase implements IConnector {
|
|
|
421
476
|
private _wrapError;
|
|
422
477
|
}
|
|
423
478
|
|
|
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
479
|
/**
|
|
450
480
|
* Wraps Ledger's SDK signer (Observable-based DeviceActions) into
|
|
451
481
|
* a simple async interface returning plain serializable data.
|
package/dist/index.d.ts
CHANGED
|
@@ -6,26 +6,101 @@ import { SignerBtc as SignerBtc$1 } from '@ledgerhq/device-signer-kit-bitcoin';
|
|
|
6
6
|
import { SignerSolana } from '@ledgerhq/device-signer-kit-solana';
|
|
7
7
|
import Transport from '@ledgerhq/hw-transport';
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Re-export DMK types under local aliases for backward compatibility.
|
|
11
|
+
* These replace the previous duck-typed interfaces with the real SDK types.
|
|
12
|
+
*/
|
|
13
|
+
type DmkDiscoveredDevice = DiscoveredDevice;
|
|
14
|
+
/**
|
|
15
|
+
* DMK DeviceAction — the Observable-based return type of all DMK signer methods.
|
|
16
|
+
*
|
|
17
|
+
* This is a permissive alias for `ExecuteDeviceActionReturnType` that accepts
|
|
18
|
+
* any Error and IntermediateValue generics. Signer wrapper code only cares about
|
|
19
|
+
* the Output type and the observable/cancel shape.
|
|
20
|
+
*/
|
|
21
|
+
type DeviceAction<T> = ExecuteDeviceActionReturnType<T, any, any>;
|
|
22
|
+
/**
|
|
23
|
+
* DMK DeviceActionState — re-exported with permissive Error/IntermediateValue.
|
|
24
|
+
* The real type is a discriminated union on `status`.
|
|
25
|
+
*/
|
|
26
|
+
type DeviceActionState<T> = DeviceActionState$1<T, any, any>;
|
|
27
|
+
/** ETH address result — re-exported from DMK for backward compatibility. */
|
|
28
|
+
type SignerEvmAddress = Address;
|
|
29
|
+
/** ETH signature result — re-exported from DMK for backward compatibility. */
|
|
30
|
+
type SignerEvmSignature = Signature;
|
|
31
|
+
/** BTC address result (WalletAddress not exported from DMK top-level). */
|
|
32
|
+
interface SignerBtcAddress {
|
|
33
|
+
address: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Optional context attached to the rejection when a canceller fires. */
|
|
37
|
+
interface CancelReason {
|
|
38
|
+
code?: number;
|
|
39
|
+
tag?: string;
|
|
40
|
+
message?: string;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Convert a DMK DeviceAction (Observable-based) into a Promise.
|
|
44
|
+
* Handles pending -> completed/error state transitions and interaction callbacks.
|
|
45
|
+
*
|
|
46
|
+
* Tracks the last DMK step observed (e.g. `signer.eth.steps.blindSignTransactionFallback`)
|
|
47
|
+
* and attaches it to the rejected error as a non-enumerable `_lastStep` property,
|
|
48
|
+
* so upstream error classifiers can distinguish failure contexts (e.g. Blind signing
|
|
49
|
+
* disabled vs. generic Invalid data).
|
|
50
|
+
*
|
|
51
|
+
* @param timeoutMs Idle watchdog ms. Re-armed on each emission, paused
|
|
52
|
+
* during interactive pending. 0 disables. Default 65s
|
|
53
|
+
* (covers DMK's 60s + margin; we're a backstop only).
|
|
54
|
+
* @param onRegisterCanceller Optional callback that receives a function which, when
|
|
55
|
+
* called, unsubscribes and cancels the underlying DeviceAction
|
|
56
|
+
* (releases DMK's IntentQueue slot). Caller is responsible
|
|
57
|
+
* for invoking the canceller on timeout/abort scenarios.
|
|
58
|
+
*/
|
|
59
|
+
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>;
|
|
60
|
+
|
|
61
|
+
interface AppMetadata {
|
|
62
|
+
versionName: string;
|
|
63
|
+
versionId: number;
|
|
64
|
+
version: string;
|
|
65
|
+
versionDisplayName: string | null;
|
|
66
|
+
description: string | null;
|
|
67
|
+
icon: string | null;
|
|
68
|
+
bytes: number | null;
|
|
69
|
+
currencyId: string | null;
|
|
70
|
+
isDevTools: boolean;
|
|
71
|
+
}
|
|
72
|
+
interface FirmwareVersion {
|
|
73
|
+
/** BOLOS version on the secure element — the user-facing firmware version. */
|
|
74
|
+
seVersion: string;
|
|
75
|
+
/** MCU SEPH (SE–MCU link protocol) version. */
|
|
76
|
+
mcuSephVersion: string;
|
|
77
|
+
/** MCU bootloader version. */
|
|
78
|
+
mcuBootloaderVersion: string;
|
|
79
|
+
/** Hardware revision (e.g. "00" / "01" on Nano X). */
|
|
80
|
+
hwVersion: string;
|
|
16
81
|
}
|
|
82
|
+
/** Full GetOsVersionResponse projected to a plain serializable shape. */
|
|
83
|
+
interface LedgerDeviceInfo extends FirmwareVersion {
|
|
84
|
+
isBootloader: boolean;
|
|
85
|
+
isOsu: boolean;
|
|
86
|
+
targetId: number;
|
|
87
|
+
seTargetId?: number;
|
|
88
|
+
mcuTargetId?: number;
|
|
89
|
+
/** Secure element flags as hex string (raw bytes turned readable). */
|
|
90
|
+
seFlagsHex: string;
|
|
91
|
+
}
|
|
92
|
+
|
|
17
93
|
declare class LedgerAdapter implements IHardwareWallet {
|
|
18
94
|
readonly vendor: "ledger";
|
|
19
95
|
private readonly connector;
|
|
20
96
|
private readonly emitter;
|
|
21
|
-
private readonly _handleSelectDevice;
|
|
22
97
|
private _discoveredDevices;
|
|
23
98
|
private _sessions;
|
|
24
99
|
private readonly _uiRegistry;
|
|
25
100
|
private _btcHighIndexConfirmedThisSession;
|
|
26
101
|
private readonly _jobQueue;
|
|
27
102
|
private _doConnectAbortController;
|
|
28
|
-
constructor(connector: IConnector
|
|
103
|
+
constructor(connector: IConnector);
|
|
29
104
|
get activeTransport(): TransportType | null;
|
|
30
105
|
getAvailableTransports(): TransportType[];
|
|
31
106
|
switchTransport(_type: TransportType): Promise<void>;
|
|
@@ -39,6 +114,7 @@ declare class LedgerAdapter implements IHardwareWallet {
|
|
|
39
114
|
dispose(): Promise<void>;
|
|
40
115
|
uiResponse(response: UiResponseEvent): void;
|
|
41
116
|
searchDevices(options?: SearchDevicesOptions): Promise<DeviceInfo[]>;
|
|
117
|
+
private _evictAllSessions;
|
|
42
118
|
private static readonly MAX_BUSINESS_RETRY_BUDGET;
|
|
43
119
|
private static readonly STUCK_APP_RETRY_DELAY_MS;
|
|
44
120
|
private static readonly MAX_DOCONNECT_CONFIRMS;
|
|
@@ -67,6 +143,11 @@ declare class LedgerAdapter implements IHardwareWallet {
|
|
|
67
143
|
tronGetAddress(connectId: string, deviceId: string, params: TronGetAddressParams): Promise<Response<TronAddress>>;
|
|
68
144
|
tronSignTransaction(connectId: string, deviceId: string, params: TronSignTxParams): Promise<Response<TronSignedTx>>;
|
|
69
145
|
tronSignMessage(connectId: string, deviceId: string, params: TronSignMsgParams): Promise<Response<TronSignature>>;
|
|
146
|
+
installApp(connectId: string, appName: string): Promise<Response<void>>;
|
|
147
|
+
listInstalledApps(connectId: string): Promise<Response<AppMetadata[]>>;
|
|
148
|
+
listAvailableApps(connectId: string): Promise<Response<AppMetadata[]>>;
|
|
149
|
+
getLedgerFirmwareVersion(connectId: string): Promise<Response<FirmwareVersion>>;
|
|
150
|
+
getLedgerDeviceInfo(connectId: string): Promise<Response<LedgerDeviceInfo>>;
|
|
70
151
|
on<K extends keyof HardwareEventMap>(event: K, listener: (event: HardwareEventMap[K]) => void): void;
|
|
71
152
|
on(event: string, listener: DeviceEventListener): void;
|
|
72
153
|
off<K extends keyof HardwareEventMap>(event: K, listener: (event: HardwareEventMap[K]) => void): void;
|
|
@@ -98,7 +179,7 @@ declare class LedgerAdapter implements IHardwareWallet {
|
|
|
98
179
|
*
|
|
99
180
|
* - If a session already exists for the given connectId, reuse it.
|
|
100
181
|
* - If ANY session exists (Ledger IDs are ephemeral), reuse it.
|
|
101
|
-
* - Otherwise: search → 1 device
|
|
182
|
+
* - Otherwise: search → exactly 1 USB device auto-connects; multiple or none throws.
|
|
102
183
|
*/
|
|
103
184
|
private _connectingPromise;
|
|
104
185
|
private _waitForDeviceConnect;
|
|
@@ -115,7 +196,6 @@ declare class LedgerAdapter implements IHardwareWallet {
|
|
|
115
196
|
private _doConnect;
|
|
116
197
|
private _connectFirstOrSelect;
|
|
117
198
|
private _connectDeviceOrThrow;
|
|
118
|
-
private _chooseDeviceFromList;
|
|
119
199
|
/**
|
|
120
200
|
* Call the connector with automatic session resolution and disconnect retry.
|
|
121
201
|
*
|
|
@@ -173,38 +253,12 @@ declare class LedgerAdapter implements IHardwareWallet {
|
|
|
173
253
|
private deviceConnectHandler;
|
|
174
254
|
private deviceDisconnectHandler;
|
|
175
255
|
private uiEventForwarder;
|
|
256
|
+
private appInstallProgressForwarder;
|
|
176
257
|
private registerEventListeners;
|
|
177
258
|
private unregisterEventListeners;
|
|
178
259
|
private connectorDeviceToDeviceInfo;
|
|
179
260
|
}
|
|
180
261
|
|
|
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
262
|
/**
|
|
209
263
|
* Manages device discovery, connection, and session tracking.
|
|
210
264
|
* Wraps DMK's Observable APIs into simpler imperative calls.
|
|
@@ -320,6 +374,7 @@ interface LedgerConnectorBaseOptions {
|
|
|
320
374
|
declare class LedgerConnectorBase implements IConnector {
|
|
321
375
|
private _deviceManager;
|
|
322
376
|
private _signerManager;
|
|
377
|
+
private _deviceAppsManager;
|
|
323
378
|
private _dmk;
|
|
324
379
|
private readonly _eventHandlers;
|
|
325
380
|
private readonly _providedDmk;
|
|
@@ -373,8 +428,7 @@ declare class LedgerConnectorBase implements IConnector {
|
|
|
373
428
|
* `LedgerAdapter._sessions` map would hold a dead session entry until
|
|
374
429
|
* the next call hit `DeviceSessionNotFound`.
|
|
375
430
|
*
|
|
376
|
-
*
|
|
377
|
-
* doesn't break the connect path.
|
|
431
|
+
* Subscribe failure is fatal — see the inline note at the subscribe call.
|
|
378
432
|
*/
|
|
379
433
|
private _watchSessionState;
|
|
380
434
|
private _unwatchSessionState;
|
|
@@ -395,6 +449,7 @@ declare class LedgerConnectorBase implements IConnector {
|
|
|
395
449
|
private _initManagers;
|
|
396
450
|
private _getDeviceManager;
|
|
397
451
|
private _getSignerManager;
|
|
452
|
+
private _getDeviceAppsManager;
|
|
398
453
|
private _invalidateSession;
|
|
399
454
|
/**
|
|
400
455
|
* Replace an old session with a new one after app switch.
|
|
@@ -421,31 +476,6 @@ declare class LedgerConnectorBase implements IConnector {
|
|
|
421
476
|
private _wrapError;
|
|
422
477
|
}
|
|
423
478
|
|
|
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
479
|
/**
|
|
450
480
|
* Wraps Ledger's SDK signer (Observable-based DeviceActions) into
|
|
451
481
|
* a simple async interface returning plain serializable data.
|