@onekeyfe/hwk-adapter-core 1.1.27-alpha.42 → 1.1.27-alpha.43
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 +502 -342
- package/dist/index.d.ts +502 -342
- package/dist/index.js +75 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +73 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -40,6 +40,8 @@ declare enum HardwareErrorCode {
|
|
|
40
40
|
DeviceAppStuck = 10107,
|
|
41
41
|
/** Vendor (Ledger / Trezor) doesn't support the chain at all. */
|
|
42
42
|
ChainNotSupported = 10108,
|
|
43
|
+
/** Current operation supports only one connected device. */
|
|
44
|
+
DeviceOneDeviceOnly = 10109,
|
|
43
45
|
FirmwareTooOld = 10200,
|
|
44
46
|
FirmwareUpdateRequired = 10201,
|
|
45
47
|
TransportError = 10300,
|
|
@@ -67,6 +69,8 @@ declare enum HardwareErrorCode {
|
|
|
67
69
|
WrongApp = 10501,
|
|
68
70
|
/** 0x911c Command code not supported — app predates current SDK. */
|
|
69
71
|
AppTooOld = 10502,
|
|
72
|
+
/** Not enough free storage for install/update; user must uninstall apps first. */
|
|
73
|
+
DeviceOutOfMemory = 10503,
|
|
70
74
|
/** 0x6a80 Invalid data — observed on blindSignTransactionFallback when the
|
|
71
75
|
* user has not enabled Blind signing on the device. */
|
|
72
76
|
EvmBlindSigningRequired = 11000,
|
|
@@ -141,13 +145,22 @@ interface DeviceCapabilities {
|
|
|
141
145
|
}
|
|
142
146
|
interface DeviceInfo {
|
|
143
147
|
vendor: VendorType;
|
|
148
|
+
/** Machine model id (e.g. "nanoX"). */
|
|
144
149
|
model: string;
|
|
150
|
+
/** Human-readable model name (e.g. "Ledger Nano X"). */
|
|
151
|
+
modelName?: string;
|
|
145
152
|
firmwareVersion: string;
|
|
146
153
|
deviceId: string;
|
|
147
154
|
connectId: string;
|
|
148
155
|
label?: string;
|
|
149
156
|
connectionType: ConnectionType;
|
|
150
157
|
battery?: number;
|
|
158
|
+
/** BLE signal strength (BLE only). */
|
|
159
|
+
rssi?: number | null;
|
|
160
|
+
/** BLE connectable flag (BLE only). */
|
|
161
|
+
isConnectable?: boolean | null;
|
|
162
|
+
/** USB serial number (USB only). */
|
|
163
|
+
serialNumber?: string;
|
|
151
164
|
/** Device capabilities — varies by vendor, model, and connection type */
|
|
152
165
|
capabilities?: DeviceCapabilities;
|
|
153
166
|
}
|
|
@@ -156,95 +169,321 @@ interface DeviceTarget {
|
|
|
156
169
|
deviceId: string;
|
|
157
170
|
}
|
|
158
171
|
|
|
159
|
-
interface
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
172
|
+
interface QrDisplayData {
|
|
173
|
+
urType: string;
|
|
174
|
+
urData: string;
|
|
175
|
+
animated: boolean;
|
|
163
176
|
}
|
|
164
|
-
interface
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
/** Device-reported secp256k1 public key; populated when the transport exposes it. */
|
|
168
|
-
publicKey?: string;
|
|
177
|
+
interface QrResponseData {
|
|
178
|
+
urType: string;
|
|
179
|
+
urData: string;
|
|
169
180
|
}
|
|
170
|
-
|
|
171
|
-
|
|
181
|
+
|
|
182
|
+
declare const UI_EVENT = "UI_EVENT";
|
|
183
|
+
declare const UI_REQUEST: {
|
|
184
|
+
readonly REQUEST_PIN: "ui-request-pin";
|
|
185
|
+
readonly REQUEST_PASSPHRASE: "ui-request-passphrase";
|
|
186
|
+
readonly REQUEST_PASSPHRASE_ON_DEVICE: "ui-request-passphrase-on-device";
|
|
187
|
+
readonly REQUEST_BUTTON: "ui-request-button";
|
|
188
|
+
readonly REQUEST_QR_DISPLAY: "ui-request-qr-display";
|
|
189
|
+
readonly REQUEST_QR_SCAN: "ui-request-qr-scan";
|
|
190
|
+
readonly REQUEST_DEVICE_PERMISSION: "ui-request-device-permission";
|
|
191
|
+
readonly REQUEST_SELECT_DEVICE: "ui-request-select-device";
|
|
192
|
+
readonly REQUEST_DEVICE_CONNECT: "ui-request-device-connect";
|
|
193
|
+
readonly REQUEST_BTC_HIGH_INDEX_CONFIRM: "ui-request-btc-high-index-confirm";
|
|
194
|
+
readonly REQUEST_INSTALL_APP: "ui-request-install-app";
|
|
195
|
+
readonly CLOSE_UI_WINDOW: "ui-close";
|
|
196
|
+
readonly DEVICE_PROGRESS: "ui-device_progress";
|
|
197
|
+
readonly FIRMWARE_PROGRESS: "ui-firmware-progress";
|
|
198
|
+
readonly FIRMWARE_TIP: "ui-firmware-tip";
|
|
199
|
+
};
|
|
200
|
+
declare const UI_RESPONSE: {
|
|
201
|
+
readonly RECEIVE_PIN: "receive-pin";
|
|
202
|
+
readonly RECEIVE_PASSPHRASE: "receive-passphrase";
|
|
203
|
+
readonly RECEIVE_PASSPHRASE_ON_DEVICE: "receive-passphrase-on-device";
|
|
204
|
+
readonly RECEIVE_QR_RESPONSE: "receive-qr-response";
|
|
205
|
+
readonly RECEIVE_SELECT_DEVICE: "receive-select-device";
|
|
206
|
+
readonly RECEIVE_DEVICE_CONNECT: "receive-device-connect";
|
|
207
|
+
readonly RECEIVE_DEVICE_PERMISSION: "receive-device-permission";
|
|
208
|
+
readonly RECEIVE_BTC_HIGH_INDEX_CONFIRM: "receive-btc-high-index-confirm";
|
|
209
|
+
readonly RECEIVE_INSTALL_APP: "receive-install-app";
|
|
210
|
+
readonly CANCEL: "cancel";
|
|
211
|
+
};
|
|
212
|
+
type DevicePermissionDeniedReason = 'bluetoothTurnedOff' | 'permissionDenied' | (string & Record<never, never>);
|
|
213
|
+
type DevicePermissionResponse = {
|
|
214
|
+
granted: boolean;
|
|
215
|
+
reason?: DevicePermissionDeniedReason;
|
|
216
|
+
message?: string;
|
|
217
|
+
};
|
|
218
|
+
type UiResponseEvent = {
|
|
219
|
+
type: typeof UI_RESPONSE.RECEIVE_PIN;
|
|
220
|
+
payload: string;
|
|
221
|
+
} | {
|
|
222
|
+
type: typeof UI_RESPONSE.RECEIVE_PASSPHRASE;
|
|
223
|
+
payload: {
|
|
224
|
+
value: string;
|
|
225
|
+
passphraseOnDevice?: boolean;
|
|
226
|
+
save?: boolean;
|
|
227
|
+
};
|
|
228
|
+
} | {
|
|
229
|
+
type: typeof UI_RESPONSE.RECEIVE_PASSPHRASE_ON_DEVICE;
|
|
230
|
+
payload?: undefined;
|
|
231
|
+
} | {
|
|
232
|
+
type: typeof UI_RESPONSE.RECEIVE_QR_RESPONSE;
|
|
233
|
+
payload: QrResponseData;
|
|
234
|
+
} | {
|
|
235
|
+
type: typeof UI_RESPONSE.RECEIVE_SELECT_DEVICE;
|
|
236
|
+
payload: {
|
|
237
|
+
sdkConnectId: string;
|
|
238
|
+
};
|
|
239
|
+
} | {
|
|
240
|
+
type: typeof UI_RESPONSE.RECEIVE_DEVICE_CONNECT;
|
|
241
|
+
payload: {
|
|
242
|
+
confirmed: boolean;
|
|
243
|
+
};
|
|
244
|
+
} | {
|
|
245
|
+
type: typeof UI_RESPONSE.RECEIVE_DEVICE_PERMISSION;
|
|
246
|
+
payload: DevicePermissionResponse;
|
|
247
|
+
} | {
|
|
248
|
+
type: typeof UI_RESPONSE.RECEIVE_BTC_HIGH_INDEX_CONFIRM;
|
|
249
|
+
payload: {
|
|
250
|
+
confirmed: boolean;
|
|
251
|
+
};
|
|
252
|
+
} | {
|
|
253
|
+
type: typeof UI_RESPONSE.RECEIVE_INSTALL_APP;
|
|
254
|
+
payload: {
|
|
255
|
+
confirmed: boolean;
|
|
256
|
+
};
|
|
257
|
+
} | {
|
|
258
|
+
type: typeof UI_RESPONSE.CANCEL;
|
|
259
|
+
payload?: undefined;
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Minimal device info returned during discovery (searchDevices).
|
|
264
|
+
* At scan time, full DeviceInfo fields like firmwareVersion are not yet available.
|
|
265
|
+
*/
|
|
266
|
+
interface ConnectorDevice {
|
|
267
|
+
connectId: string;
|
|
268
|
+
deviceId: string;
|
|
269
|
+
name: string;
|
|
270
|
+
/** Machine model id (e.g. "nanoX"). */
|
|
271
|
+
model?: string;
|
|
272
|
+
/** Human-readable model name (e.g. "Ledger Nano X"). */
|
|
273
|
+
modelName?: string;
|
|
274
|
+
/** BLE signal strength (BLE only). */
|
|
275
|
+
rssi?: number | null;
|
|
276
|
+
/** BLE connectable flag (BLE only). */
|
|
277
|
+
isConnectable?: boolean | null;
|
|
278
|
+
/** USB serial number (USB only). */
|
|
279
|
+
serialNumber?: string;
|
|
280
|
+
/** Device capabilities — available from scan time */
|
|
281
|
+
capabilities?: DeviceCapabilities;
|
|
282
|
+
}
|
|
283
|
+
interface ConnectorSession {
|
|
284
|
+
sessionId: string;
|
|
285
|
+
deviceInfo: DeviceInfo;
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Vendor-agnostic bag of extra error fields. Known keys are documented for
|
|
289
|
+
* discoverability; the index signature keeps it open so any connector can
|
|
290
|
+
* carry vendor-specific data without losing it across the bridge.
|
|
291
|
+
*/
|
|
292
|
+
interface ConnectorErrorParams {
|
|
293
|
+
/** Vendor SDK error tag (e.g. Ledger DMK `_tag`). */
|
|
294
|
+
_tag?: string;
|
|
295
|
+
/** App involved, e.g. the Ledger app being opened/installed. */
|
|
296
|
+
appName?: string;
|
|
297
|
+
/** Transport / APDU status code (string or number depending on vendor). */
|
|
298
|
+
statusCode?: unknown;
|
|
172
299
|
/**
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
*
|
|
300
|
+
* Shallow snapshot of a nested cause. A raw Error does not survive JSON
|
|
301
|
+
* serialization (its `message`/`stack` are non-enumerable), so recovery
|
|
302
|
+
* predicates that recurse into a cause get this plain-object copy instead.
|
|
176
303
|
*/
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
maxFeePerGas?: string;
|
|
186
|
-
maxPriorityFeePerGas?: string;
|
|
187
|
-
accessList?: Array<{
|
|
188
|
-
address: string;
|
|
189
|
-
storageKeys: string[];
|
|
190
|
-
}>;
|
|
191
|
-
data?: string;
|
|
192
|
-
}
|
|
193
|
-
interface EvmSignedTx {
|
|
194
|
-
/** Recovery id as `0x`-prefixed hex string. */
|
|
195
|
-
v: string;
|
|
196
|
-
/** ECDSA `r` value as `0x`-prefixed, zero-padded 64-char hex string (32 bytes). */
|
|
197
|
-
r: string;
|
|
198
|
-
/** ECDSA `s` value as `0x`-prefixed, zero-padded 64-char hex string (32 bytes). */
|
|
199
|
-
s: string;
|
|
200
|
-
serializedTx?: string;
|
|
304
|
+
originalError?: {
|
|
305
|
+
message?: string;
|
|
306
|
+
code?: number;
|
|
307
|
+
errorCode?: string;
|
|
308
|
+
statusCode?: unknown;
|
|
309
|
+
_tag?: string;
|
|
310
|
+
};
|
|
311
|
+
[key: string]: unknown;
|
|
201
312
|
}
|
|
202
|
-
interface
|
|
203
|
-
path: string;
|
|
313
|
+
interface ConnectorSerializedError {
|
|
204
314
|
message: string;
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
interface EvmSignTypedDataFull {
|
|
209
|
-
path: string;
|
|
210
|
-
/** Defaults to `'full'` when omitted. */
|
|
211
|
-
mode?: 'full';
|
|
212
|
-
data: {
|
|
213
|
-
domain: EIP712Domain;
|
|
214
|
-
types: Record<string, Array<{
|
|
215
|
-
name: string;
|
|
216
|
-
type: string;
|
|
217
|
-
}>>;
|
|
218
|
-
primaryType: string;
|
|
219
|
-
message: Record<string, unknown>;
|
|
220
|
-
};
|
|
221
|
-
metamaskV4Compat?: boolean;
|
|
315
|
+
code?: number;
|
|
316
|
+
errorCode?: string;
|
|
317
|
+
params?: ConnectorErrorParams;
|
|
222
318
|
}
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
319
|
+
type ConnectorCallResult = {
|
|
320
|
+
success: true;
|
|
321
|
+
payload: unknown;
|
|
322
|
+
} | {
|
|
323
|
+
success: false;
|
|
324
|
+
error: ConnectorSerializedError;
|
|
325
|
+
};
|
|
326
|
+
type ConnectorEventType = 'device-connect' | 'device-disconnect' | 'ui-request' | 'ui-event';
|
|
327
|
+
/**
|
|
328
|
+
* Interaction event types emitted via 'ui-event'.
|
|
329
|
+
* These map to user-facing prompts (confirm on device, open app, etc.).
|
|
330
|
+
*/
|
|
331
|
+
declare enum EConnectorInteraction {
|
|
332
|
+
/** Adapter is actively searching for the device (no session yet) */
|
|
333
|
+
Searching = "searching",
|
|
334
|
+
/** Device requires user to open a specific app */
|
|
335
|
+
ConfirmOpenApp = "confirm-open-app",
|
|
336
|
+
/** Device requires user to unlock */
|
|
337
|
+
UnlockDevice = "unlock-device",
|
|
338
|
+
/** Device needs user to confirm on device (sign, verify, etc.) */
|
|
339
|
+
ConfirmOnDevice = "confirm-on-device",
|
|
340
|
+
/** Previous interaction completed — clear UI prompt */
|
|
341
|
+
InteractionComplete = "interaction-complete",
|
|
342
|
+
/**
|
|
343
|
+
* OS-level Ledger app install progress. `progress` is a 0..1 fraction
|
|
344
|
+
* reported by DMK's InstallOrUpdateAppsDeviceAction. Emitted from inside
|
|
345
|
+
* the connector so the progress callback ref never has to cross the
|
|
346
|
+
* IHardwareBridge boundary.
|
|
347
|
+
*/
|
|
348
|
+
AppInstallProgress = "app-install-progress"
|
|
228
349
|
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
350
|
+
type ConnectorUiEvent = {
|
|
351
|
+
type: EConnectorInteraction.Searching;
|
|
352
|
+
payload: {
|
|
353
|
+
sessionId: string;
|
|
354
|
+
};
|
|
355
|
+
} | {
|
|
356
|
+
type: EConnectorInteraction.ConfirmOpenApp;
|
|
357
|
+
payload: {
|
|
358
|
+
sessionId: string;
|
|
359
|
+
};
|
|
360
|
+
} | {
|
|
361
|
+
type: EConnectorInteraction.UnlockDevice;
|
|
362
|
+
payload: {
|
|
363
|
+
sessionId: string;
|
|
364
|
+
};
|
|
365
|
+
} | {
|
|
366
|
+
type: EConnectorInteraction.ConfirmOnDevice;
|
|
367
|
+
payload: {
|
|
368
|
+
sessionId: string;
|
|
369
|
+
};
|
|
370
|
+
} | {
|
|
371
|
+
type: EConnectorInteraction.InteractionComplete;
|
|
372
|
+
payload: {
|
|
373
|
+
sessionId: string;
|
|
374
|
+
};
|
|
375
|
+
} | {
|
|
376
|
+
type: EConnectorInteraction.AppInstallProgress;
|
|
377
|
+
payload: {
|
|
378
|
+
sessionId: string;
|
|
379
|
+
appName: string;
|
|
380
|
+
progress: number;
|
|
381
|
+
};
|
|
382
|
+
};
|
|
383
|
+
interface ConnectorEventMap {
|
|
384
|
+
'device-connect': {
|
|
385
|
+
device: ConnectorDevice;
|
|
386
|
+
};
|
|
387
|
+
'device-disconnect': {
|
|
388
|
+
connectId: string;
|
|
389
|
+
};
|
|
390
|
+
'ui-request': {
|
|
391
|
+
type: string;
|
|
392
|
+
payload?: unknown;
|
|
393
|
+
};
|
|
394
|
+
'ui-event': ConnectorUiEvent;
|
|
236
395
|
}
|
|
237
|
-
interface
|
|
238
|
-
/**
|
|
239
|
-
|
|
240
|
-
|
|
396
|
+
interface IConnector {
|
|
397
|
+
/** Physical connection type this connector uses. Fixed at construction. */
|
|
398
|
+
readonly connectionType: ConnectionType;
|
|
399
|
+
searchDevices(): Promise<ConnectorDevice[]>;
|
|
400
|
+
connect(deviceId?: string): Promise<ConnectorSession>;
|
|
401
|
+
disconnect(sessionId: string): Promise<void>;
|
|
402
|
+
call(sessionId: string, method: string, params: unknown): Promise<ConnectorCallResult>;
|
|
403
|
+
cancel(sessionId: string): Promise<void>;
|
|
404
|
+
/** Send a UI response (e.g. PIN, passphrase) to the device. */
|
|
405
|
+
uiResponse(response: UiResponseEvent): void;
|
|
406
|
+
on<K extends ConnectorEventType>(event: K, handler: (data: ConnectorEventMap[K]) => void): void;
|
|
407
|
+
off<K extends ConnectorEventType>(event: K, handler: (data: ConnectorEventMap[K]) => void): void;
|
|
408
|
+
reset(): void;
|
|
241
409
|
}
|
|
242
|
-
interface
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
410
|
+
interface IHardwareBridge {
|
|
411
|
+
searchDevices(params: {
|
|
412
|
+
vendor: VendorType;
|
|
413
|
+
}): Promise<ConnectorDevice[]>;
|
|
414
|
+
connect(params: {
|
|
415
|
+
vendor: VendorType;
|
|
416
|
+
deviceId?: string;
|
|
417
|
+
}): Promise<ConnectorSession>;
|
|
418
|
+
disconnect(params: {
|
|
419
|
+
vendor: VendorType;
|
|
420
|
+
sessionId: string;
|
|
421
|
+
}): Promise<void>;
|
|
422
|
+
call(params: {
|
|
423
|
+
vendor: VendorType;
|
|
424
|
+
sessionId: string;
|
|
425
|
+
method: string;
|
|
426
|
+
callParams: unknown;
|
|
427
|
+
}): Promise<ConnectorCallResult>;
|
|
428
|
+
cancel(params: {
|
|
429
|
+
vendor: VendorType;
|
|
430
|
+
sessionId: string;
|
|
431
|
+
}): Promise<void>;
|
|
432
|
+
uiResponse(params: {
|
|
433
|
+
vendor: VendorType;
|
|
434
|
+
response: UiResponseEvent;
|
|
435
|
+
}): void;
|
|
436
|
+
reset(params: {
|
|
437
|
+
vendor: VendorType;
|
|
438
|
+
}): void;
|
|
439
|
+
/** Register an event handler for connector events forwarded across the bridge. */
|
|
440
|
+
onEvent(params: {
|
|
441
|
+
vendor: VendorType;
|
|
442
|
+
}, handler: (event: {
|
|
443
|
+
type: ConnectorEventType;
|
|
444
|
+
data: unknown;
|
|
445
|
+
}) => void): void;
|
|
446
|
+
/** Unregister a previously registered event handler. */
|
|
447
|
+
offEvent(params: {
|
|
448
|
+
vendor: VendorType;
|
|
449
|
+
}, handler: (event: {
|
|
450
|
+
type: ConnectorEventType;
|
|
451
|
+
data: unknown;
|
|
452
|
+
}) => void): void;
|
|
247
453
|
}
|
|
454
|
+
/**
|
|
455
|
+
* Adapt an IHardwareBridge (multi-vendor backend) into a single-vendor IConnector.
|
|
456
|
+
* Every IConnector method becomes a transparent forward to bridge.<method>({ vendor, ... }).
|
|
457
|
+
* Events are forwarded via bridge.onEvent / offEvent.
|
|
458
|
+
*
|
|
459
|
+
* Use this anywhere the actual hardware lives behind a process / context boundary
|
|
460
|
+
* (Electron main, extension background, native module, worker, iframe).
|
|
461
|
+
*/
|
|
462
|
+
declare function createBridgedConnector(vendor: VendorType, connectionType: ConnectionType, bridge: IHardwareBridge): IConnector;
|
|
463
|
+
/**
|
|
464
|
+
* Flatten a thrown error into the cross-boundary-safe `ConnectorSerializedError`
|
|
465
|
+
* shape. `message`/`code`/`errorCode` are lifted to the top level; every other
|
|
466
|
+
* own-enumerable field is copied into `params` so NO domain data is lost when
|
|
467
|
+
* the result crosses a host bridge (which may run thrown errors through a
|
|
468
|
+
* field whitelist). A nested `originalError` is shallow-snapshotted because a
|
|
469
|
+
* raw Error does not survive JSON serialization.
|
|
470
|
+
*/
|
|
471
|
+
declare function serializeConnectorError(err: unknown): ConnectorSerializedError;
|
|
472
|
+
/**
|
|
473
|
+
* Inverse of `serializeConnectorError`: rebuild a flat Error instance, lifting
|
|
474
|
+
* `params.*` back to own-properties so existing throw-based classifiers/recovery
|
|
475
|
+
* logic (which read `err._tag` / `err.code` / `err.appName` / …) keep working
|
|
476
|
+
* unchanged. The Result shape stays confined to the connector boundary.
|
|
477
|
+
*/
|
|
478
|
+
declare function rehydrateConnectorError(error: ConnectorSerializedError): Error;
|
|
479
|
+
|
|
480
|
+
declare const DEVICE_EVENT = "DEVICE_EVENT";
|
|
481
|
+
/** Events originating from the hardware device. */
|
|
482
|
+
declare const DEVICE: {
|
|
483
|
+
readonly CONNECT: "device-connect";
|
|
484
|
+
readonly DISCONNECT: "device-disconnect";
|
|
485
|
+
readonly CHANGED: "device-changed";
|
|
486
|
+
};
|
|
248
487
|
|
|
249
488
|
interface BtcGetAddressParams {
|
|
250
489
|
path: string;
|
|
@@ -338,12 +577,12 @@ interface BtcSignature {
|
|
|
338
577
|
address?: string;
|
|
339
578
|
}
|
|
340
579
|
interface IBtcMethods {
|
|
341
|
-
btcGetAddress(connectId: string, deviceId: string, params: BtcGetAddressParams): Promise<Response<BtcAddress>>;
|
|
342
|
-
btcGetPublicKey(connectId: string, deviceId: string, params: BtcGetPublicKeyParams): Promise<Response<BtcPublicKey>>;
|
|
343
|
-
btcSignTransaction(connectId: string, deviceId: string, params: BtcSignTxParams): Promise<Response<BtcSignedTx>>;
|
|
344
|
-
btcSignPsbt(connectId: string, deviceId: string, params: BtcSignPsbtParams): Promise<Response<BtcSignedPsbt>>;
|
|
345
|
-
btcSignMessage(connectId: string, deviceId: string, params: BtcSignMsgParams): Promise<Response<BtcSignature>>;
|
|
346
|
-
btcGetMasterFingerprint(connectId: string, deviceId: string): Promise<Response<{
|
|
580
|
+
btcGetAddress(connectId: string, deviceId: string, params: BtcGetAddressParams, commonParams?: ICommonCallParams): Promise<Response<BtcAddress>>;
|
|
581
|
+
btcGetPublicKey(connectId: string, deviceId: string, params: BtcGetPublicKeyParams, commonParams?: ICommonCallParams): Promise<Response<BtcPublicKey>>;
|
|
582
|
+
btcSignTransaction(connectId: string, deviceId: string, params: BtcSignTxParams, commonParams?: ICommonCallParams): Promise<Response<BtcSignedTx>>;
|
|
583
|
+
btcSignPsbt(connectId: string, deviceId: string, params: BtcSignPsbtParams, commonParams?: ICommonCallParams): Promise<Response<BtcSignedPsbt>>;
|
|
584
|
+
btcSignMessage(connectId: string, deviceId: string, params: BtcSignMsgParams, commonParams?: ICommonCallParams): Promise<Response<BtcSignature>>;
|
|
585
|
+
btcGetMasterFingerprint(connectId: string, deviceId: string, commonParams?: ICommonCallParams): Promise<Response<{
|
|
347
586
|
masterFingerprint: string;
|
|
348
587
|
}>>;
|
|
349
588
|
}
|
|
@@ -384,9 +623,9 @@ interface SolSignature {
|
|
|
384
623
|
signature: string;
|
|
385
624
|
}
|
|
386
625
|
interface ISolMethods {
|
|
387
|
-
solGetAddress(connectId: string, deviceId: string, params: SolGetAddressParams): Promise<Response<SolAddress>>;
|
|
388
|
-
solSignTransaction(connectId: string, deviceId: string, params: SolSignTxParams): Promise<Response<SolSignedTx>>;
|
|
389
|
-
solSignMessage(connectId: string, deviceId: string, params: SolSignMsgParams): Promise<Response<SolSignature>>;
|
|
626
|
+
solGetAddress(connectId: string, deviceId: string, params: SolGetAddressParams, commonParams?: ICommonCallParams): Promise<Response<SolAddress>>;
|
|
627
|
+
solSignTransaction(connectId: string, deviceId: string, params: SolSignTxParams, commonParams?: ICommonCallParams): Promise<Response<SolSignedTx>>;
|
|
628
|
+
solSignMessage(connectId: string, deviceId: string, params: SolSignMsgParams, commonParams?: ICommonCallParams): Promise<Response<SolSignature>>;
|
|
390
629
|
}
|
|
391
630
|
|
|
392
631
|
interface TronGetAddressParams {
|
|
@@ -415,121 +654,30 @@ interface TronSignMsgParams {
|
|
|
415
654
|
interface TronSignature {
|
|
416
655
|
/** 65-byte hex-encoded signature (no 0x prefix) */
|
|
417
656
|
signature: string;
|
|
418
|
-
}
|
|
419
|
-
interface ITronMethods {
|
|
420
|
-
tronGetAddress(connectId: string, deviceId: string, params: TronGetAddressParams): Promise<Response<TronAddress>>;
|
|
421
|
-
tronSignTransaction(connectId: string, deviceId: string, params: TronSignTxParams): Promise<Response<TronSignedTx>>;
|
|
422
|
-
tronSignMessage(connectId: string, deviceId: string, params: TronSignMsgParams): Promise<Response<TronSignature>>;
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
*
|
|
438
|
-
*
|
|
439
|
-
*
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
* - SOL: cointype 501, standard 3-level hardened
|
|
443
|
-
*/
|
|
444
|
-
declare const CHAIN_FINGERPRINT_PATHS: Record<ChainForFingerprint, string>;
|
|
445
|
-
type ChainForFingerprint = 'evm' | 'btc' | 'sol' | 'tron';
|
|
446
|
-
/**
|
|
447
|
-
* 16-char SHA-256 fingerprint for device-identity verification.
|
|
448
|
-
* Callers must canonicalize input (e.g. EVM address → lowercase) —
|
|
449
|
-
* encoding variations otherwise cause false DeviceMismatch.
|
|
450
|
-
*/
|
|
451
|
-
declare function deriveDeviceFingerprint(value: string): string;
|
|
452
|
-
|
|
453
|
-
declare const DEVICE_EVENT = "DEVICE_EVENT";
|
|
454
|
-
/** Events originating from the hardware device. */
|
|
455
|
-
declare const DEVICE: {
|
|
456
|
-
readonly CONNECT: "device-connect";
|
|
457
|
-
readonly DISCONNECT: "device-disconnect";
|
|
458
|
-
readonly CHANGED: "device-changed";
|
|
459
|
-
};
|
|
460
|
-
|
|
461
|
-
declare const UI_EVENT = "UI_EVENT";
|
|
462
|
-
declare const UI_REQUEST: {
|
|
463
|
-
readonly REQUEST_PIN: "ui-request-pin";
|
|
464
|
-
readonly REQUEST_PASSPHRASE: "ui-request-passphrase";
|
|
465
|
-
readonly REQUEST_PASSPHRASE_ON_DEVICE: "ui-request-passphrase-on-device";
|
|
466
|
-
readonly REQUEST_BUTTON: "ui-request-button";
|
|
467
|
-
readonly REQUEST_QR_DISPLAY: "ui-request-qr-display";
|
|
468
|
-
readonly REQUEST_QR_SCAN: "ui-request-qr-scan";
|
|
469
|
-
readonly REQUEST_DEVICE_PERMISSION: "ui-request-device-permission";
|
|
470
|
-
readonly REQUEST_SELECT_DEVICE: "ui-request-select-device";
|
|
471
|
-
readonly REQUEST_DEVICE_CONNECT: "ui-request-device-connect";
|
|
472
|
-
readonly REQUEST_BTC_HIGH_INDEX_CONFIRM: "ui-request-btc-high-index-confirm";
|
|
473
|
-
readonly CLOSE_UI_WINDOW: "ui-close";
|
|
474
|
-
readonly DEVICE_PROGRESS: "ui-device_progress";
|
|
475
|
-
readonly FIRMWARE_PROGRESS: "ui-firmware-progress";
|
|
476
|
-
readonly FIRMWARE_TIP: "ui-firmware-tip";
|
|
477
|
-
};
|
|
478
|
-
declare const UI_RESPONSE: {
|
|
479
|
-
readonly RECEIVE_PIN: "receive-pin";
|
|
480
|
-
readonly RECEIVE_PASSPHRASE: "receive-passphrase";
|
|
481
|
-
readonly RECEIVE_PASSPHRASE_ON_DEVICE: "receive-passphrase-on-device";
|
|
482
|
-
readonly RECEIVE_QR_RESPONSE: "receive-qr-response";
|
|
483
|
-
readonly RECEIVE_SELECT_DEVICE: "receive-select-device";
|
|
484
|
-
readonly RECEIVE_DEVICE_CONNECT: "receive-device-connect";
|
|
485
|
-
readonly RECEIVE_DEVICE_PERMISSION: "receive-device-permission";
|
|
486
|
-
readonly RECEIVE_BTC_HIGH_INDEX_CONFIRM: "receive-btc-high-index-confirm";
|
|
487
|
-
readonly CANCEL: "cancel";
|
|
488
|
-
};
|
|
489
|
-
type DevicePermissionDeniedReason = 'bluetoothTurnedOff' | 'permissionDenied' | (string & Record<never, never>);
|
|
490
|
-
type DevicePermissionResponse = {
|
|
491
|
-
granted: boolean;
|
|
492
|
-
reason?: DevicePermissionDeniedReason;
|
|
493
|
-
message?: string;
|
|
494
|
-
};
|
|
495
|
-
type UiResponseEvent = {
|
|
496
|
-
type: typeof UI_RESPONSE.RECEIVE_PIN;
|
|
497
|
-
payload: string;
|
|
498
|
-
} | {
|
|
499
|
-
type: typeof UI_RESPONSE.RECEIVE_PASSPHRASE;
|
|
500
|
-
payload: {
|
|
501
|
-
value: string;
|
|
502
|
-
passphraseOnDevice?: boolean;
|
|
503
|
-
save?: boolean;
|
|
504
|
-
};
|
|
505
|
-
} | {
|
|
506
|
-
type: typeof UI_RESPONSE.RECEIVE_PASSPHRASE_ON_DEVICE;
|
|
507
|
-
payload?: undefined;
|
|
508
|
-
} | {
|
|
509
|
-
type: typeof UI_RESPONSE.RECEIVE_QR_RESPONSE;
|
|
510
|
-
payload: QrResponseData;
|
|
511
|
-
} | {
|
|
512
|
-
type: typeof UI_RESPONSE.RECEIVE_SELECT_DEVICE;
|
|
513
|
-
payload: {
|
|
514
|
-
sdkConnectId: string;
|
|
515
|
-
};
|
|
516
|
-
} | {
|
|
517
|
-
type: typeof UI_RESPONSE.RECEIVE_DEVICE_CONNECT;
|
|
518
|
-
payload: {
|
|
519
|
-
confirmed: boolean;
|
|
520
|
-
};
|
|
521
|
-
} | {
|
|
522
|
-
type: typeof UI_RESPONSE.RECEIVE_DEVICE_PERMISSION;
|
|
523
|
-
payload: DevicePermissionResponse;
|
|
524
|
-
} | {
|
|
525
|
-
type: typeof UI_RESPONSE.RECEIVE_BTC_HIGH_INDEX_CONFIRM;
|
|
526
|
-
payload: {
|
|
527
|
-
confirmed: boolean;
|
|
528
|
-
};
|
|
529
|
-
} | {
|
|
530
|
-
type: typeof UI_RESPONSE.CANCEL;
|
|
531
|
-
payload?: undefined;
|
|
532
|
-
};
|
|
657
|
+
}
|
|
658
|
+
interface ITronMethods {
|
|
659
|
+
tronGetAddress(connectId: string, deviceId: string, params: TronGetAddressParams, commonParams?: ICommonCallParams): Promise<Response<TronAddress>>;
|
|
660
|
+
tronSignTransaction(connectId: string, deviceId: string, params: TronSignTxParams, commonParams?: ICommonCallParams): Promise<Response<TronSignedTx>>;
|
|
661
|
+
tronSignMessage(connectId: string, deviceId: string, params: TronSignMsgParams, commonParams?: ICommonCallParams): Promise<Response<TronSignature>>;
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
/**
|
|
665
|
+
* Fixed derivation paths used to generate chain fingerprints.
|
|
666
|
+
* Uses standard index 0 — Ledger firmware shows device confirmation for
|
|
667
|
+
* non-standard paths (e.g., index=100), which would interrupt wallet creation.
|
|
668
|
+
* The address is hashed into a 16-char fingerprint, not exposed directly.
|
|
669
|
+
* - EVM: cointype 60 (Ledger ETH App only supports 60)
|
|
670
|
+
* - BTC: cointype 1 (testnet)
|
|
671
|
+
* - SOL: cointype 501, standard 3-level hardened
|
|
672
|
+
*/
|
|
673
|
+
declare const CHAIN_FINGERPRINT_PATHS: Record<ChainForFingerprint, string>;
|
|
674
|
+
type ChainForFingerprint = 'evm' | 'btc' | 'sol' | 'tron';
|
|
675
|
+
/**
|
|
676
|
+
* 16-char SHA-256 fingerprint for device-identity verification.
|
|
677
|
+
* Callers must canonicalize input (e.g. EVM address → lowercase) —
|
|
678
|
+
* encoding variations otherwise cause false DeviceMismatch.
|
|
679
|
+
*/
|
|
680
|
+
declare function deriveDeviceFingerprint(value: string): string;
|
|
533
681
|
|
|
534
682
|
/** Events generated by SDK internal detection (not from hardware directly). */
|
|
535
683
|
declare const SDK: {
|
|
@@ -540,146 +688,35 @@ declare const SDK: {
|
|
|
540
688
|
};
|
|
541
689
|
|
|
542
690
|
/**
|
|
543
|
-
*
|
|
544
|
-
*
|
|
545
|
-
|
|
546
|
-
interface ConnectorDevice {
|
|
547
|
-
connectId: string;
|
|
548
|
-
deviceId: string;
|
|
549
|
-
name: string;
|
|
550
|
-
model?: string;
|
|
551
|
-
/** Device capabilities — available from scan time */
|
|
552
|
-
capabilities?: DeviceCapabilities;
|
|
553
|
-
}
|
|
554
|
-
interface ConnectorSession {
|
|
555
|
-
sessionId: string;
|
|
556
|
-
deviceInfo: DeviceInfo;
|
|
557
|
-
}
|
|
558
|
-
type ConnectorEventType = 'device-connect' | 'device-disconnect' | 'ui-request' | 'ui-event';
|
|
559
|
-
/**
|
|
560
|
-
* Interaction event types emitted via 'ui-event'.
|
|
561
|
-
* These map to user-facing prompts (confirm on device, open app, etc.).
|
|
691
|
+
* Wallet-level `ui-event` variants. Same shape as `ConnectorUiEvent` except
|
|
692
|
+
* the AppInstallProgress variant's payload is re-keyed by the adapter from
|
|
693
|
+
* connector-internal `sessionId` to the public `connectId`.
|
|
562
694
|
*/
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
ConfirmOpenApp = "confirm-open-app",
|
|
568
|
-
/** Device requires user to unlock */
|
|
569
|
-
UnlockDevice = "unlock-device",
|
|
570
|
-
/** Device needs user to confirm on device (sign, verify, etc.) */
|
|
571
|
-
ConfirmOnDevice = "confirm-on-device",
|
|
572
|
-
/** Previous interaction completed — clear UI prompt */
|
|
573
|
-
InteractionComplete = "interaction-complete"
|
|
574
|
-
}
|
|
575
|
-
type ConnectorUiEvent = {
|
|
576
|
-
type: EConnectorInteraction.Searching;
|
|
577
|
-
payload: {
|
|
578
|
-
sessionId: string;
|
|
579
|
-
};
|
|
580
|
-
} | {
|
|
581
|
-
type: EConnectorInteraction.ConfirmOpenApp;
|
|
582
|
-
payload: {
|
|
583
|
-
sessionId: string;
|
|
584
|
-
};
|
|
585
|
-
} | {
|
|
586
|
-
type: EConnectorInteraction.UnlockDevice;
|
|
587
|
-
payload: {
|
|
588
|
-
sessionId: string;
|
|
589
|
-
};
|
|
590
|
-
} | {
|
|
591
|
-
type: EConnectorInteraction.ConfirmOnDevice;
|
|
592
|
-
payload: {
|
|
593
|
-
sessionId: string;
|
|
594
|
-
};
|
|
595
|
-
} | {
|
|
596
|
-
type: EConnectorInteraction.InteractionComplete;
|
|
695
|
+
type HardwareUiEvent = Exclude<ConnectorUiEvent, {
|
|
696
|
+
type: EConnectorInteraction.AppInstallProgress;
|
|
697
|
+
}> | {
|
|
698
|
+
type: EConnectorInteraction.AppInstallProgress;
|
|
597
699
|
payload: {
|
|
598
|
-
sessionId: string;
|
|
599
|
-
};
|
|
600
|
-
};
|
|
601
|
-
interface ConnectorEventMap {
|
|
602
|
-
'device-connect': {
|
|
603
|
-
device: ConnectorDevice;
|
|
604
|
-
};
|
|
605
|
-
'device-disconnect': {
|
|
606
700
|
connectId: string;
|
|
701
|
+
appName: string;
|
|
702
|
+
progress: number;
|
|
607
703
|
};
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
payload?: unknown;
|
|
611
|
-
};
|
|
612
|
-
'ui-event': ConnectorUiEvent;
|
|
613
|
-
}
|
|
614
|
-
interface IConnector {
|
|
615
|
-
/** Physical connection type this connector uses. Fixed at construction. */
|
|
616
|
-
readonly connectionType: ConnectionType;
|
|
617
|
-
searchDevices(): Promise<ConnectorDevice[]>;
|
|
618
|
-
connect(deviceId?: string): Promise<ConnectorSession>;
|
|
619
|
-
disconnect(sessionId: string): Promise<void>;
|
|
620
|
-
call(sessionId: string, method: string, params: unknown): Promise<unknown>;
|
|
621
|
-
cancel(sessionId: string): Promise<void>;
|
|
622
|
-
/** Send a UI response (e.g. PIN, passphrase) to the device. */
|
|
623
|
-
uiResponse(response: UiResponseEvent): void;
|
|
624
|
-
on<K extends ConnectorEventType>(event: K, handler: (data: ConnectorEventMap[K]) => void): void;
|
|
625
|
-
off<K extends ConnectorEventType>(event: K, handler: (data: ConnectorEventMap[K]) => void): void;
|
|
626
|
-
reset(): void;
|
|
627
|
-
}
|
|
628
|
-
interface IHardwareBridge {
|
|
629
|
-
searchDevices(params: {
|
|
630
|
-
vendor: VendorType;
|
|
631
|
-
}): Promise<ConnectorDevice[]>;
|
|
632
|
-
connect(params: {
|
|
633
|
-
vendor: VendorType;
|
|
634
|
-
deviceId?: string;
|
|
635
|
-
}): Promise<ConnectorSession>;
|
|
636
|
-
disconnect(params: {
|
|
637
|
-
vendor: VendorType;
|
|
638
|
-
sessionId: string;
|
|
639
|
-
}): Promise<void>;
|
|
640
|
-
call(params: {
|
|
641
|
-
vendor: VendorType;
|
|
642
|
-
sessionId: string;
|
|
643
|
-
method: string;
|
|
644
|
-
callParams: unknown;
|
|
645
|
-
}): Promise<unknown>;
|
|
646
|
-
cancel(params: {
|
|
647
|
-
vendor: VendorType;
|
|
648
|
-
sessionId: string;
|
|
649
|
-
}): Promise<void>;
|
|
650
|
-
uiResponse(params: {
|
|
651
|
-
vendor: VendorType;
|
|
652
|
-
response: UiResponseEvent;
|
|
653
|
-
}): void;
|
|
654
|
-
reset(params: {
|
|
655
|
-
vendor: VendorType;
|
|
656
|
-
}): void;
|
|
657
|
-
/** Register an event handler for connector events forwarded across the bridge. */
|
|
658
|
-
onEvent(params: {
|
|
659
|
-
vendor: VendorType;
|
|
660
|
-
}, handler: (event: {
|
|
661
|
-
type: ConnectorEventType;
|
|
662
|
-
data: unknown;
|
|
663
|
-
}) => void): void;
|
|
664
|
-
/** Unregister a previously registered event handler. */
|
|
665
|
-
offEvent(params: {
|
|
666
|
-
vendor: VendorType;
|
|
667
|
-
}, handler: (event: {
|
|
668
|
-
type: ConnectorEventType;
|
|
669
|
-
data: unknown;
|
|
670
|
-
}) => void): void;
|
|
671
|
-
}
|
|
704
|
+
};
|
|
705
|
+
type ChainCapability = 'evm' | 'btc' | 'sol' | 'tron';
|
|
672
706
|
/**
|
|
673
|
-
*
|
|
674
|
-
*
|
|
675
|
-
*
|
|
676
|
-
*
|
|
677
|
-
* Use this anywhere the actual hardware lives behind a process / context boundary
|
|
678
|
-
* (Electron main, extension background, native module, worker, iframe).
|
|
707
|
+
* Cross-chain / cross-vendor options passed alongside any chain method's
|
|
708
|
+
* own params (the optional last argument). Holds operation-level switches
|
|
709
|
+
* that aren't specific to one chain. Vendor-specific options can be added
|
|
710
|
+
* as typed sub-fields here when a vendor actually needs them.
|
|
679
711
|
*/
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
712
|
+
interface ICommonCallParams {
|
|
713
|
+
/**
|
|
714
|
+
* When the required device app is missing, prompt the user (UI request)
|
|
715
|
+
* to install it, stream install progress, then retry the operation once.
|
|
716
|
+
* Off by default — preserves the plain "app not installed" failure.
|
|
717
|
+
*/
|
|
718
|
+
autoInstallApp?: boolean;
|
|
719
|
+
}
|
|
683
720
|
interface PassphraseResponse {
|
|
684
721
|
passphrase: string;
|
|
685
722
|
/** If true, passphrase will be entered on the device. `passphrase` field is ignored. */
|
|
@@ -761,6 +798,12 @@ type UiRequestEvent = {
|
|
|
761
798
|
*/
|
|
762
799
|
message: string;
|
|
763
800
|
};
|
|
801
|
+
} | {
|
|
802
|
+
type: typeof UI_REQUEST.REQUEST_INSTALL_APP;
|
|
803
|
+
payload: {
|
|
804
|
+
vendor: string;
|
|
805
|
+
appName: string;
|
|
806
|
+
};
|
|
764
807
|
} | {
|
|
765
808
|
type: typeof UI_REQUEST.CLOSE_UI_WINDOW;
|
|
766
809
|
payload: Record<string, never>;
|
|
@@ -787,7 +830,7 @@ type SdkEvent = {
|
|
|
787
830
|
connectId: string;
|
|
788
831
|
};
|
|
789
832
|
};
|
|
790
|
-
type HardwareEvent = DeviceEvent | UiRequestEvent | SdkEvent |
|
|
833
|
+
type HardwareEvent = DeviceEvent | UiRequestEvent | SdkEvent | HardwareUiEvent;
|
|
791
834
|
type DeviceEventListener = (event: HardwareEvent) => void;
|
|
792
835
|
/**
|
|
793
836
|
* Type-safe event map for IHardwareWallet.on / .off.
|
|
@@ -796,7 +839,7 @@ type DeviceEventListener = (event: HardwareEvent) => void;
|
|
|
796
839
|
* and the value is the narrowed event object the listener will receive.
|
|
797
840
|
*/
|
|
798
841
|
interface HardwareEventMap {
|
|
799
|
-
'ui-event':
|
|
842
|
+
'ui-event': HardwareUiEvent;
|
|
800
843
|
[DEVICE.CONNECT]: {
|
|
801
844
|
type: typeof DEVICE.CONNECT;
|
|
802
845
|
payload: DeviceInfo;
|
|
@@ -879,6 +922,13 @@ interface HardwareEventMap {
|
|
|
879
922
|
accountIndex: number;
|
|
880
923
|
};
|
|
881
924
|
};
|
|
925
|
+
[UI_REQUEST.REQUEST_INSTALL_APP]: {
|
|
926
|
+
type: typeof UI_REQUEST.REQUEST_INSTALL_APP;
|
|
927
|
+
payload: {
|
|
928
|
+
vendor: string;
|
|
929
|
+
appName: string;
|
|
930
|
+
};
|
|
931
|
+
};
|
|
882
932
|
[UI_REQUEST.CLOSE_UI_WINDOW]: {
|
|
883
933
|
type: typeof UI_REQUEST.CLOSE_UI_WINDOW;
|
|
884
934
|
payload: Record<string, never>;
|
|
@@ -916,7 +966,7 @@ interface IHardwareWallet<TConfig = unknown> extends IEvmMethods, IBtcMethods, I
|
|
|
916
966
|
dispose(): Promise<void>;
|
|
917
967
|
getAvailableTransports(): TransportType[];
|
|
918
968
|
switchTransport(type: TransportType): Promise<void>;
|
|
919
|
-
searchDevices(): Promise<DeviceInfo[]>;
|
|
969
|
+
searchDevices(options?: SearchDevicesOptions): Promise<DeviceInfo[]>;
|
|
920
970
|
connectDevice(connectId: string): Promise<Response<string>>;
|
|
921
971
|
disconnectDevice(connectId: string): Promise<void>;
|
|
922
972
|
getDeviceInfo(connectId: string, deviceId: string): Promise<Response<DeviceInfo>>;
|
|
@@ -940,6 +990,106 @@ interface IHardwareWallet<TConfig = unknown> extends IEvmMethods, IBtcMethods, I
|
|
|
940
990
|
off<K extends keyof HardwareEventMap>(event: K, listener: (event: HardwareEventMap[K]) => void): void;
|
|
941
991
|
off(event: string, listener: DeviceEventListener): void;
|
|
942
992
|
}
|
|
993
|
+
interface SearchDevicesOptions {
|
|
994
|
+
/**
|
|
995
|
+
* Clear cached adapter sessions before scanning.
|
|
996
|
+
*
|
|
997
|
+
* Use this for an explicit "search/add another device" flow on transports
|
|
998
|
+
* whose connectId is not stable, such as Ledger WebHID. Normal refresh scans
|
|
999
|
+
* should leave this false so an active session can still be reused.
|
|
1000
|
+
*/
|
|
1001
|
+
resetSession?: boolean;
|
|
1002
|
+
}
|
|
1003
|
+
|
|
1004
|
+
interface EvmGetAddressParams {
|
|
1005
|
+
path: string;
|
|
1006
|
+
showOnDevice?: boolean;
|
|
1007
|
+
chainId?: number;
|
|
1008
|
+
}
|
|
1009
|
+
interface EvmAddress {
|
|
1010
|
+
address: string;
|
|
1011
|
+
path: string;
|
|
1012
|
+
/** Device-reported secp256k1 public key; populated when the transport exposes it. */
|
|
1013
|
+
publicKey?: string;
|
|
1014
|
+
}
|
|
1015
|
+
interface EvmSignTxParams {
|
|
1016
|
+
path: string;
|
|
1017
|
+
/**
|
|
1018
|
+
* RLP-serialized transaction hex (0x-prefixed or plain).
|
|
1019
|
+
* When provided, the connector uses this directly instead of individual fields.
|
|
1020
|
+
* Required for Ledger; Trezor may use individual fields instead.
|
|
1021
|
+
*/
|
|
1022
|
+
serializedTx?: string;
|
|
1023
|
+
/** Contract address or recipient. Optional for contract deployment transactions. */
|
|
1024
|
+
to?: string;
|
|
1025
|
+
value?: string;
|
|
1026
|
+
chainId?: number;
|
|
1027
|
+
nonce?: string;
|
|
1028
|
+
gasLimit?: string;
|
|
1029
|
+
gasPrice?: string;
|
|
1030
|
+
maxFeePerGas?: string;
|
|
1031
|
+
maxPriorityFeePerGas?: string;
|
|
1032
|
+
accessList?: Array<{
|
|
1033
|
+
address: string;
|
|
1034
|
+
storageKeys: string[];
|
|
1035
|
+
}>;
|
|
1036
|
+
data?: string;
|
|
1037
|
+
}
|
|
1038
|
+
interface EvmSignedTx {
|
|
1039
|
+
/** Recovery id as `0x`-prefixed hex string. */
|
|
1040
|
+
v: string;
|
|
1041
|
+
/** ECDSA `r` value as `0x`-prefixed, zero-padded 64-char hex string (32 bytes). */
|
|
1042
|
+
r: string;
|
|
1043
|
+
/** ECDSA `s` value as `0x`-prefixed, zero-padded 64-char hex string (32 bytes). */
|
|
1044
|
+
s: string;
|
|
1045
|
+
serializedTx?: string;
|
|
1046
|
+
}
|
|
1047
|
+
interface EvmSignMsgParams {
|
|
1048
|
+
path: string;
|
|
1049
|
+
message: string;
|
|
1050
|
+
hex?: boolean;
|
|
1051
|
+
}
|
|
1052
|
+
type EvmSignTypedDataParams = EvmSignTypedDataFull | EvmSignTypedDataHash;
|
|
1053
|
+
interface EvmSignTypedDataFull {
|
|
1054
|
+
path: string;
|
|
1055
|
+
/** Defaults to `'full'` when omitted. */
|
|
1056
|
+
mode?: 'full';
|
|
1057
|
+
data: {
|
|
1058
|
+
domain: EIP712Domain;
|
|
1059
|
+
types: Record<string, Array<{
|
|
1060
|
+
name: string;
|
|
1061
|
+
type: string;
|
|
1062
|
+
}>>;
|
|
1063
|
+
primaryType: string;
|
|
1064
|
+
message: Record<string, unknown>;
|
|
1065
|
+
};
|
|
1066
|
+
metamaskV4Compat?: boolean;
|
|
1067
|
+
}
|
|
1068
|
+
interface EvmSignTypedDataHash {
|
|
1069
|
+
path: string;
|
|
1070
|
+
mode: 'hash';
|
|
1071
|
+
domainSeparatorHash: string;
|
|
1072
|
+
messageHash: string;
|
|
1073
|
+
}
|
|
1074
|
+
interface EIP712Domain {
|
|
1075
|
+
name?: string;
|
|
1076
|
+
version?: string;
|
|
1077
|
+
chainId?: number;
|
|
1078
|
+
verifyingContract?: string;
|
|
1079
|
+
salt?: string;
|
|
1080
|
+
[key: string]: unknown;
|
|
1081
|
+
}
|
|
1082
|
+
interface EvmSignature {
|
|
1083
|
+
/** `0x`-prefixed hex string (r + s + v). */
|
|
1084
|
+
signature: string;
|
|
1085
|
+
address?: string;
|
|
1086
|
+
}
|
|
1087
|
+
interface IEvmMethods {
|
|
1088
|
+
evmGetAddress(connectId: string, deviceId: string, params: EvmGetAddressParams, commonParams?: ICommonCallParams): Promise<Response<EvmAddress>>;
|
|
1089
|
+
evmSignTransaction(connectId: string, deviceId: string, params: EvmSignTxParams, commonParams?: ICommonCallParams): Promise<Response<EvmSignedTx>>;
|
|
1090
|
+
evmSignMessage(connectId: string, deviceId: string, params: EvmSignMsgParams, commonParams?: ICommonCallParams): Promise<Response<EvmSignature>>;
|
|
1091
|
+
evmSignTypedData(connectId: string, deviceId: string, params: EvmSignTypedDataParams, commonParams?: ICommonCallParams): Promise<Response<EvmSignature>>;
|
|
1092
|
+
}
|
|
943
1093
|
|
|
944
1094
|
/**
|
|
945
1095
|
* Low-level device descriptor from Transport layer.
|
|
@@ -952,11 +1102,13 @@ interface DeviceDescriptor {
|
|
|
952
1102
|
product?: number;
|
|
953
1103
|
/** USB vendor ID */
|
|
954
1104
|
vendor?: number;
|
|
955
|
-
/** Device type/model identifier */
|
|
1105
|
+
/** Device type/model identifier (e.g. "nanoX"). */
|
|
956
1106
|
type?: string;
|
|
1107
|
+
/** Human-readable model name (e.g. "Ledger Nano X"). */
|
|
1108
|
+
modelName?: string;
|
|
957
1109
|
/** Human-readable display name from the transport layer. */
|
|
958
1110
|
name?: string;
|
|
959
|
-
/**
|
|
1111
|
+
/** Raw Ledger BLE advertisement name from RN BLE `Device.name`, when available. */
|
|
960
1112
|
bleName?: string;
|
|
961
1113
|
/** User-visible Ledger BLE local name from the raw RN BLE `Device.localName` field. */
|
|
962
1114
|
localName?: string;
|
|
@@ -964,6 +1116,14 @@ interface DeviceDescriptor {
|
|
|
964
1116
|
transport?: string;
|
|
965
1117
|
/** BLE RSSI when provided by the transport scanner. */
|
|
966
1118
|
rssi?: number | null;
|
|
1119
|
+
/** BLE advertised service UUIDs, when provided by the scanner. */
|
|
1120
|
+
serviceUUIDs?: string[] | null;
|
|
1121
|
+
/** BLE connectable flag, when provided by the scanner. */
|
|
1122
|
+
isConnectable?: boolean | null;
|
|
1123
|
+
/** USB product name, when provided by the transport. */
|
|
1124
|
+
productName?: string;
|
|
1125
|
+
/** USB serial number, when provided by the transport. */
|
|
1126
|
+
serialNumber?: string;
|
|
967
1127
|
}
|
|
968
1128
|
interface DeviceConnectEvent {
|
|
969
1129
|
type: 'device-connected';
|
|
@@ -1107,4 +1267,4 @@ declare function batchCall<TParam, TResult>(params: TParam[], callFn: (p: TParam
|
|
|
1107
1267
|
total: number;
|
|
1108
1268
|
}) => void): Promise<Response<TResult[]>>;
|
|
1109
1269
|
|
|
1110
|
-
export { type ActiveJobInfo, type BtcAddress, type BtcGetAddressParams, type BtcGetPublicKeyParams, type BtcPublicKey, type BtcRefTransaction, type BtcSignMsgParams, type BtcSignPsbtParams, type BtcSignTxParams, type BtcSignature, type BtcSignedPsbt, type BtcSignedTx, type BtcTxInput, type BtcTxOutput, CHAIN_FINGERPRINT_PATHS, type ChainCapability, type ChainForFingerprint, type ConnectionType, type ConnectorDevice, type ConnectorEventMap, type ConnectorEventType, type ConnectorSession, type ConnectorUiEvent, DEVICE, DEVICE_EVENT, type DeviceCapabilities, type DeviceChangeEvent, type DeviceConnectEvent, type DeviceDescriptor, type DeviceDisconnectEvent, type DeviceEvent, type DeviceEventListener, type DeviceInfo, DeviceJobQueue, type DevicePermissionDeniedReason, type DevicePermissionResponse, type DeviceTarget, EConnectorInteraction, type EIP712Domain, type EvmAddress, type EvmGetAddressParams, type EvmSignMsgParams, type EvmSignTxParams, type EvmSignTypedDataFull, type EvmSignTypedDataHash, type EvmSignTypedDataParams, type EvmSignature, type EvmSignedTx, type Failure, HardwareErrorCode, type HardwareEvent, type HardwareEventMap, type IBtcMethods, type IConnector, type IEvmMethods, type IHardwareBridge, type IHardwareWallet, type ISolMethods, type ITronMethods, type JobOptions, ORPHAN_ELIGIBLE_ERROR_CODES, type PassphraseResponse, type QrDisplayData, type QrResponseData, type Response, SDK, type SdkEvent, type SolAddress, type SolGetAddressParams, type SolSignMsgParams, type SolSignTxParams, type SolSignature, type SolSignedTx, type Success, type TransportType, type TronAddress, type TronGetAddressParams, type TronSignMsgParams, type TronSignTxParams, type TronSignature, type TronSignedTx, TypedEventEmitter, UI_EVENT, UI_REQUEST, UI_REQUEST_CANCELLED_TAG, UI_REQUEST_DEFAULT_TIMEOUT_MS, UI_REQUEST_PREEMPTED_TAG, UI_REQUEST_TIMEOUT_TAG, UI_RESPONSE, type UiRequestEvent, UiRequestRegistry, type UiResponseEvent, type VendorType, batchCall, bytesToHex, compareSemver, createBridgedConnector, deriveDeviceFingerprint, enrichErrorMessage, ensure0x, failure, hexToBytes, padHex64, stripHex, success };
|
|
1270
|
+
export { type ActiveJobInfo, type BtcAddress, type BtcGetAddressParams, type BtcGetPublicKeyParams, type BtcPublicKey, type BtcRefTransaction, type BtcSignMsgParams, type BtcSignPsbtParams, type BtcSignTxParams, type BtcSignature, type BtcSignedPsbt, type BtcSignedTx, type BtcTxInput, type BtcTxOutput, CHAIN_FINGERPRINT_PATHS, type ChainCapability, type ChainForFingerprint, type ConnectionType, type ConnectorCallResult, type ConnectorDevice, type ConnectorErrorParams, type ConnectorEventMap, type ConnectorEventType, type ConnectorSerializedError, type ConnectorSession, type ConnectorUiEvent, DEVICE, DEVICE_EVENT, type DeviceCapabilities, type DeviceChangeEvent, type DeviceConnectEvent, type DeviceDescriptor, type DeviceDisconnectEvent, type DeviceEvent, type DeviceEventListener, type DeviceInfo, DeviceJobQueue, type DevicePermissionDeniedReason, type DevicePermissionResponse, type DeviceTarget, EConnectorInteraction, type EIP712Domain, type EvmAddress, type EvmGetAddressParams, type EvmSignMsgParams, type EvmSignTxParams, type EvmSignTypedDataFull, type EvmSignTypedDataHash, type EvmSignTypedDataParams, type EvmSignature, type EvmSignedTx, type Failure, HardwareErrorCode, type HardwareEvent, type HardwareEventMap, type HardwareUiEvent, type IBtcMethods, type ICommonCallParams, type IConnector, type IEvmMethods, type IHardwareBridge, type IHardwareWallet, type ISolMethods, type ITronMethods, type JobOptions, ORPHAN_ELIGIBLE_ERROR_CODES, type PassphraseResponse, type QrDisplayData, type QrResponseData, type Response, SDK, type SdkEvent, type SearchDevicesOptions, type SolAddress, type SolGetAddressParams, type SolSignMsgParams, type SolSignTxParams, type SolSignature, type SolSignedTx, type Success, type TransportType, type TronAddress, type TronGetAddressParams, type TronSignMsgParams, type TronSignTxParams, type TronSignature, type TronSignedTx, TypedEventEmitter, UI_EVENT, UI_REQUEST, UI_REQUEST_CANCELLED_TAG, UI_REQUEST_DEFAULT_TIMEOUT_MS, UI_REQUEST_PREEMPTED_TAG, UI_REQUEST_TIMEOUT_TAG, UI_RESPONSE, type UiRequestEvent, UiRequestRegistry, type UiResponseEvent, type VendorType, batchCall, bytesToHex, compareSemver, createBridgedConnector, deriveDeviceFingerprint, enrichErrorMessage, ensure0x, failure, hexToBytes, padHex64, rehydrateConnectorError, serializeConnectorError, stripHex, success };
|