@onekeyfe/hwk-keystone-adapter 1.2.8-alpha.54 → 1.2.10-alpha.2
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 +47 -9
- package/dist/index.d.ts +47 -9
- package/dist/index.js +453 -96
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +459 -96
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -35,6 +35,15 @@ interface KeystoneParsedMultiAccounts {
|
|
|
35
35
|
deviceId?: string;
|
|
36
36
|
deviceVersion?: string;
|
|
37
37
|
accounts: KeystoneParsedAccount[];
|
|
38
|
+
/**
|
|
39
|
+
* Export only: paths the export carried but could not vouch for. They are left out of `accounts`
|
|
40
|
+
* and only fail a caller that asks for one of them.
|
|
41
|
+
*/
|
|
42
|
+
rejectedPaths?: KeystoneRejectedExportPath[];
|
|
43
|
+
}
|
|
44
|
+
interface KeystoneRejectedExportPath {
|
|
45
|
+
path: string;
|
|
46
|
+
reason: 'different-wallet' | 'conflicting-keys' | 'unusable-key';
|
|
38
47
|
}
|
|
39
48
|
interface KeystoneEthSignRequestInput {
|
|
40
49
|
requestId: string;
|
|
@@ -84,9 +93,12 @@ interface KeystoneBtcSignatureResult {
|
|
|
84
93
|
}
|
|
85
94
|
/** SLIP-10 secp256k1 (EVM/BTC) and ed25519 (SOL); Cardano BIP32-Ed25519 is out of scope. */
|
|
86
95
|
type KeystoneDerivationCurve = 'secp256k1' | 'ed25519';
|
|
96
|
+
/** Chain types firmware before 3.0.4 checks each requested path against. */
|
|
97
|
+
type KeystoneHardwareCallChainType = 'ETH' | 'SOL' | 'TRX' | 'BTC_LEGACY' | 'BTC' | 'BTC_NATIVE_SEGWIT' | 'BTC_TAPROOT';
|
|
87
98
|
interface KeystoneKeySchema {
|
|
88
99
|
path: string;
|
|
89
100
|
curve?: KeystoneDerivationCurve;
|
|
101
|
+
chainType?: KeystoneHardwareCallChainType;
|
|
90
102
|
}
|
|
91
103
|
interface KeystoneKeyDerivationRequestInput {
|
|
92
104
|
schemas: KeystoneKeySchema[];
|
|
@@ -130,6 +142,12 @@ declare class KeystoneUrEngine {
|
|
|
130
142
|
* hdkey source fingerprint is the mfp only because every request here derives from the seed.
|
|
131
143
|
*/
|
|
132
144
|
parseAccountResponse(ur: KeystoneUr): KeystoneParsedMultiAccounts;
|
|
145
|
+
/**
|
|
146
|
+
* Device exports are opt-in: request responses retain their existing format/path checks. An
|
|
147
|
+
* export carries whatever the device syncs to other wallets, so each key is checked on its own: a
|
|
148
|
+
* key that fails lands in `rejectedPaths` instead of discarding the whole export.
|
|
149
|
+
*/
|
|
150
|
+
parseAccountExport(ur: KeystoneUr): KeystoneParsedMultiAccounts;
|
|
133
151
|
buildEthSignRequest(input: KeystoneEthSignRequestInput): KeystoneUr;
|
|
134
152
|
parseEthSignature(ur: KeystoneUr): KeystoneEthSignatureResult;
|
|
135
153
|
/** Derives an EVM address offline; `relativeDerivePath` is relative to the xpub, e.g. `'0/0'`. */
|
|
@@ -190,8 +208,9 @@ interface KeystoneDeviceRecord {
|
|
|
190
208
|
hardwareDeviceId?: string;
|
|
191
209
|
/** Model string from the device (e.g. "Keystone 3 Pro"); not unique per unit. */
|
|
192
210
|
model?: string;
|
|
211
|
+
/** Last QR response's display metadata, not a capability check for the next QR request. */
|
|
193
212
|
deviceVersion?: string;
|
|
194
|
-
|
|
213
|
+
usbFirmwareVersion?: string;
|
|
195
214
|
/** Connector session id while a live USB session exists; its presence routes calls over USB. */
|
|
196
215
|
usbSessionId?: string;
|
|
197
216
|
/**
|
|
@@ -214,9 +233,16 @@ declare function placeholderDeviceInfo(): DeviceInfo;
|
|
|
214
233
|
type BundleAccess = {
|
|
215
234
|
channel: 'qr';
|
|
216
235
|
scanned: ReadonlyMap<string, KeystoneAccountEntry>;
|
|
236
|
+
firmwareVersion?: string;
|
|
237
|
+
accountExport?: boolean;
|
|
217
238
|
} | {
|
|
218
239
|
channel: 'usb';
|
|
219
240
|
usbSessionId: string;
|
|
241
|
+
qrFallback: QrFallbackChoice;
|
|
242
|
+
};
|
|
243
|
+
/** The answer to "show it as a QR?" for a request USB cannot carry; a bundle asks only once. */
|
|
244
|
+
type QrFallbackChoice = {
|
|
245
|
+
confirmed?: boolean;
|
|
220
246
|
};
|
|
221
247
|
interface ImportFromQrOptions {
|
|
222
248
|
/**
|
|
@@ -244,6 +270,8 @@ declare class KeystoneAdapter implements IHardwareWallet {
|
|
|
244
270
|
private readonly _origin;
|
|
245
271
|
/** Host answer timeout for QR display/scan requests; undefined uses the registry default. */
|
|
246
272
|
private readonly _qrTimeoutMs;
|
|
273
|
+
/** At most this many account paths per QR key request; see the constructor option. */
|
|
274
|
+
private readonly _qrKeyRequestLimit;
|
|
247
275
|
/** Host-supplied USB connector; undefined means QR-only. */
|
|
248
276
|
private readonly _usbConnector;
|
|
249
277
|
/** Serializes USB open/identity handshakes that run outside the job queue. */
|
|
@@ -257,10 +285,15 @@ declare class KeystoneAdapter implements IHardwareWallet {
|
|
|
257
285
|
private _forcedTransport;
|
|
258
286
|
private readonly _handleUsbDisconnect;
|
|
259
287
|
private readonly _handleUsbUiEvent;
|
|
288
|
+
/**
|
|
289
|
+
* `qrKeyRequestLimit` caps the account paths one QR key request may ask for, below the firmware's
|
|
290
|
+
* own limit: a host with no USB to fall back on can refuse a large request before the device does.
|
|
291
|
+
*/
|
|
260
292
|
constructor(options?: {
|
|
261
293
|
origin?: string;
|
|
262
294
|
qrTimeoutMs?: number;
|
|
263
295
|
usbConnector?: IConnector;
|
|
296
|
+
qrKeyRequestLimit?: number;
|
|
264
297
|
});
|
|
265
298
|
get activeTransport(): TransportType | null;
|
|
266
299
|
getAvailableTransports(): TransportType[];
|
|
@@ -369,7 +402,7 @@ declare class KeystoneAdapter implements IHardwareWallet {
|
|
|
369
402
|
private _connectUsbExclusive;
|
|
370
403
|
/**
|
|
371
404
|
* Probes already-authorized USB devices without a permission picker, then attaches and verifies
|
|
372
|
-
* the requested wallet if present.
|
|
405
|
+
* the requested wallet if present. Undefined means use QR: no device, or the user chose QR.
|
|
373
406
|
*/
|
|
374
407
|
private _tryUsbAttach;
|
|
375
408
|
/**
|
|
@@ -387,14 +420,12 @@ declare class KeystoneAdapter implements IHardwareWallet {
|
|
|
387
420
|
*/
|
|
388
421
|
private _fetchAccount;
|
|
389
422
|
/**
|
|
390
|
-
* Resolves
|
|
391
|
-
*
|
|
423
|
+
* Resolves wallet identity without a per-path account. A caller-supplied fingerprint needs no
|
|
424
|
+
* device round trip; otherwise request the account path from the device.
|
|
392
425
|
*/
|
|
393
426
|
private _ensureWalletKnown;
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
* through the operation route; a cold start returns undefined.
|
|
397
|
-
*/
|
|
427
|
+
private _assertQrChainSupported;
|
|
428
|
+
/** Only an operation id supplied to the running call owns its UI prompts. */
|
|
398
429
|
private _activeOperationId;
|
|
399
430
|
/** Routes are keyed by connectId; a job key may be the bare master fingerprint. */
|
|
400
431
|
private _operationRouteForIdentifier;
|
|
@@ -403,6 +434,13 @@ declare class KeystoneAdapter implements IHardwareWallet {
|
|
|
403
434
|
* a cancel reach the wait before the QR timeout.
|
|
404
435
|
*/
|
|
405
436
|
private _awaitQrResponse;
|
|
437
|
+
/**
|
|
438
|
+
* Asks whether a request too large for USB may be shown as a QR. A timeout or an unanswered
|
|
439
|
+
* prompt reads as no; a cancelled call keeps its own error.
|
|
440
|
+
*/
|
|
441
|
+
private _confirmQrFallback;
|
|
442
|
+
/** A timeout or an unanswered prompt reads as cancel; a cancelled call keeps its own error. */
|
|
443
|
+
private _askQrFallback;
|
|
406
444
|
/** Shows `data` for the device to scan, or with no `data` asks the host to scan the device. */
|
|
407
445
|
private _requestQrAndAwaitResponse;
|
|
408
446
|
private _callUsbResolveUr;
|
|
@@ -433,4 +471,4 @@ declare function splitAccountPath(path: string): {
|
|
|
433
471
|
/** BIP-44/49/84/86 purpose to script type; undefined for any other purpose. */
|
|
434
472
|
declare function btcScriptTypeFromPath(path: string): BtcScriptType | undefined;
|
|
435
473
|
|
|
436
|
-
export { type BtcScriptType, type ImportFromQrOptions, KEYSTONE_COLD_START_PATH, KEYSTONE_WALLET_CONNECT_ID_PREFIX, type KeystoneAccountEntry, KeystoneAdapter, type KeystoneBtcSignRequestAccount, type KeystoneBtcSignatureResult, type KeystoneDerivationCurve, type KeystoneDeviceRecord, type KeystoneEthSignRequestInput, type KeystoneEthSignatureResult, type KeystoneKeyDerivationRequestInput, type KeystoneKeySchema, type KeystoneParsedAccount, type KeystoneParsedMultiAccounts, type KeystoneSolSignRequestInput, type KeystoneSolSignatureResult, type KeystoneTronSignRequestInput, type KeystoneTronSignatureResult, type KeystoneUr, KeystoneUrEngine, accountKey, btcScriptTypeFromPath, createDeviceRecord, normalizePath, placeholderDeviceInfo, splitAccountPath, toDeviceInfo, walletConnectId };
|
|
474
|
+
export { type BtcScriptType, type ImportFromQrOptions, KEYSTONE_COLD_START_PATH, KEYSTONE_WALLET_CONNECT_ID_PREFIX, type KeystoneAccountEntry, KeystoneAdapter, type KeystoneBtcSignRequestAccount, type KeystoneBtcSignatureResult, type KeystoneDerivationCurve, type KeystoneDeviceRecord, type KeystoneEthSignRequestInput, type KeystoneEthSignatureResult, type KeystoneHardwareCallChainType, type KeystoneKeyDerivationRequestInput, type KeystoneKeySchema, type KeystoneParsedAccount, type KeystoneParsedMultiAccounts, type KeystoneSolSignRequestInput, type KeystoneSolSignatureResult, type KeystoneTronSignRequestInput, type KeystoneTronSignatureResult, type KeystoneUr, KeystoneUrEngine, accountKey, btcScriptTypeFromPath, createDeviceRecord, normalizePath, placeholderDeviceInfo, splitAccountPath, toDeviceInfo, walletConnectId };
|
package/dist/index.d.ts
CHANGED
|
@@ -35,6 +35,15 @@ interface KeystoneParsedMultiAccounts {
|
|
|
35
35
|
deviceId?: string;
|
|
36
36
|
deviceVersion?: string;
|
|
37
37
|
accounts: KeystoneParsedAccount[];
|
|
38
|
+
/**
|
|
39
|
+
* Export only: paths the export carried but could not vouch for. They are left out of `accounts`
|
|
40
|
+
* and only fail a caller that asks for one of them.
|
|
41
|
+
*/
|
|
42
|
+
rejectedPaths?: KeystoneRejectedExportPath[];
|
|
43
|
+
}
|
|
44
|
+
interface KeystoneRejectedExportPath {
|
|
45
|
+
path: string;
|
|
46
|
+
reason: 'different-wallet' | 'conflicting-keys' | 'unusable-key';
|
|
38
47
|
}
|
|
39
48
|
interface KeystoneEthSignRequestInput {
|
|
40
49
|
requestId: string;
|
|
@@ -84,9 +93,12 @@ interface KeystoneBtcSignatureResult {
|
|
|
84
93
|
}
|
|
85
94
|
/** SLIP-10 secp256k1 (EVM/BTC) and ed25519 (SOL); Cardano BIP32-Ed25519 is out of scope. */
|
|
86
95
|
type KeystoneDerivationCurve = 'secp256k1' | 'ed25519';
|
|
96
|
+
/** Chain types firmware before 3.0.4 checks each requested path against. */
|
|
97
|
+
type KeystoneHardwareCallChainType = 'ETH' | 'SOL' | 'TRX' | 'BTC_LEGACY' | 'BTC' | 'BTC_NATIVE_SEGWIT' | 'BTC_TAPROOT';
|
|
87
98
|
interface KeystoneKeySchema {
|
|
88
99
|
path: string;
|
|
89
100
|
curve?: KeystoneDerivationCurve;
|
|
101
|
+
chainType?: KeystoneHardwareCallChainType;
|
|
90
102
|
}
|
|
91
103
|
interface KeystoneKeyDerivationRequestInput {
|
|
92
104
|
schemas: KeystoneKeySchema[];
|
|
@@ -130,6 +142,12 @@ declare class KeystoneUrEngine {
|
|
|
130
142
|
* hdkey source fingerprint is the mfp only because every request here derives from the seed.
|
|
131
143
|
*/
|
|
132
144
|
parseAccountResponse(ur: KeystoneUr): KeystoneParsedMultiAccounts;
|
|
145
|
+
/**
|
|
146
|
+
* Device exports are opt-in: request responses retain their existing format/path checks. An
|
|
147
|
+
* export carries whatever the device syncs to other wallets, so each key is checked on its own: a
|
|
148
|
+
* key that fails lands in `rejectedPaths` instead of discarding the whole export.
|
|
149
|
+
*/
|
|
150
|
+
parseAccountExport(ur: KeystoneUr): KeystoneParsedMultiAccounts;
|
|
133
151
|
buildEthSignRequest(input: KeystoneEthSignRequestInput): KeystoneUr;
|
|
134
152
|
parseEthSignature(ur: KeystoneUr): KeystoneEthSignatureResult;
|
|
135
153
|
/** Derives an EVM address offline; `relativeDerivePath` is relative to the xpub, e.g. `'0/0'`. */
|
|
@@ -190,8 +208,9 @@ interface KeystoneDeviceRecord {
|
|
|
190
208
|
hardwareDeviceId?: string;
|
|
191
209
|
/** Model string from the device (e.g. "Keystone 3 Pro"); not unique per unit. */
|
|
192
210
|
model?: string;
|
|
211
|
+
/** Last QR response's display metadata, not a capability check for the next QR request. */
|
|
193
212
|
deviceVersion?: string;
|
|
194
|
-
|
|
213
|
+
usbFirmwareVersion?: string;
|
|
195
214
|
/** Connector session id while a live USB session exists; its presence routes calls over USB. */
|
|
196
215
|
usbSessionId?: string;
|
|
197
216
|
/**
|
|
@@ -214,9 +233,16 @@ declare function placeholderDeviceInfo(): DeviceInfo;
|
|
|
214
233
|
type BundleAccess = {
|
|
215
234
|
channel: 'qr';
|
|
216
235
|
scanned: ReadonlyMap<string, KeystoneAccountEntry>;
|
|
236
|
+
firmwareVersion?: string;
|
|
237
|
+
accountExport?: boolean;
|
|
217
238
|
} | {
|
|
218
239
|
channel: 'usb';
|
|
219
240
|
usbSessionId: string;
|
|
241
|
+
qrFallback: QrFallbackChoice;
|
|
242
|
+
};
|
|
243
|
+
/** The answer to "show it as a QR?" for a request USB cannot carry; a bundle asks only once. */
|
|
244
|
+
type QrFallbackChoice = {
|
|
245
|
+
confirmed?: boolean;
|
|
220
246
|
};
|
|
221
247
|
interface ImportFromQrOptions {
|
|
222
248
|
/**
|
|
@@ -244,6 +270,8 @@ declare class KeystoneAdapter implements IHardwareWallet {
|
|
|
244
270
|
private readonly _origin;
|
|
245
271
|
/** Host answer timeout for QR display/scan requests; undefined uses the registry default. */
|
|
246
272
|
private readonly _qrTimeoutMs;
|
|
273
|
+
/** At most this many account paths per QR key request; see the constructor option. */
|
|
274
|
+
private readonly _qrKeyRequestLimit;
|
|
247
275
|
/** Host-supplied USB connector; undefined means QR-only. */
|
|
248
276
|
private readonly _usbConnector;
|
|
249
277
|
/** Serializes USB open/identity handshakes that run outside the job queue. */
|
|
@@ -257,10 +285,15 @@ declare class KeystoneAdapter implements IHardwareWallet {
|
|
|
257
285
|
private _forcedTransport;
|
|
258
286
|
private readonly _handleUsbDisconnect;
|
|
259
287
|
private readonly _handleUsbUiEvent;
|
|
288
|
+
/**
|
|
289
|
+
* `qrKeyRequestLimit` caps the account paths one QR key request may ask for, below the firmware's
|
|
290
|
+
* own limit: a host with no USB to fall back on can refuse a large request before the device does.
|
|
291
|
+
*/
|
|
260
292
|
constructor(options?: {
|
|
261
293
|
origin?: string;
|
|
262
294
|
qrTimeoutMs?: number;
|
|
263
295
|
usbConnector?: IConnector;
|
|
296
|
+
qrKeyRequestLimit?: number;
|
|
264
297
|
});
|
|
265
298
|
get activeTransport(): TransportType | null;
|
|
266
299
|
getAvailableTransports(): TransportType[];
|
|
@@ -369,7 +402,7 @@ declare class KeystoneAdapter implements IHardwareWallet {
|
|
|
369
402
|
private _connectUsbExclusive;
|
|
370
403
|
/**
|
|
371
404
|
* Probes already-authorized USB devices without a permission picker, then attaches and verifies
|
|
372
|
-
* the requested wallet if present.
|
|
405
|
+
* the requested wallet if present. Undefined means use QR: no device, or the user chose QR.
|
|
373
406
|
*/
|
|
374
407
|
private _tryUsbAttach;
|
|
375
408
|
/**
|
|
@@ -387,14 +420,12 @@ declare class KeystoneAdapter implements IHardwareWallet {
|
|
|
387
420
|
*/
|
|
388
421
|
private _fetchAccount;
|
|
389
422
|
/**
|
|
390
|
-
* Resolves
|
|
391
|
-
*
|
|
423
|
+
* Resolves wallet identity without a per-path account. A caller-supplied fingerprint needs no
|
|
424
|
+
* device round trip; otherwise request the account path from the device.
|
|
392
425
|
*/
|
|
393
426
|
private _ensureWalletKnown;
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
* through the operation route; a cold start returns undefined.
|
|
397
|
-
*/
|
|
427
|
+
private _assertQrChainSupported;
|
|
428
|
+
/** Only an operation id supplied to the running call owns its UI prompts. */
|
|
398
429
|
private _activeOperationId;
|
|
399
430
|
/** Routes are keyed by connectId; a job key may be the bare master fingerprint. */
|
|
400
431
|
private _operationRouteForIdentifier;
|
|
@@ -403,6 +434,13 @@ declare class KeystoneAdapter implements IHardwareWallet {
|
|
|
403
434
|
* a cancel reach the wait before the QR timeout.
|
|
404
435
|
*/
|
|
405
436
|
private _awaitQrResponse;
|
|
437
|
+
/**
|
|
438
|
+
* Asks whether a request too large for USB may be shown as a QR. A timeout or an unanswered
|
|
439
|
+
* prompt reads as no; a cancelled call keeps its own error.
|
|
440
|
+
*/
|
|
441
|
+
private _confirmQrFallback;
|
|
442
|
+
/** A timeout or an unanswered prompt reads as cancel; a cancelled call keeps its own error. */
|
|
443
|
+
private _askQrFallback;
|
|
406
444
|
/** Shows `data` for the device to scan, or with no `data` asks the host to scan the device. */
|
|
407
445
|
private _requestQrAndAwaitResponse;
|
|
408
446
|
private _callUsbResolveUr;
|
|
@@ -433,4 +471,4 @@ declare function splitAccountPath(path: string): {
|
|
|
433
471
|
/** BIP-44/49/84/86 purpose to script type; undefined for any other purpose. */
|
|
434
472
|
declare function btcScriptTypeFromPath(path: string): BtcScriptType | undefined;
|
|
435
473
|
|
|
436
|
-
export { type BtcScriptType, type ImportFromQrOptions, KEYSTONE_COLD_START_PATH, KEYSTONE_WALLET_CONNECT_ID_PREFIX, type KeystoneAccountEntry, KeystoneAdapter, type KeystoneBtcSignRequestAccount, type KeystoneBtcSignatureResult, type KeystoneDerivationCurve, type KeystoneDeviceRecord, type KeystoneEthSignRequestInput, type KeystoneEthSignatureResult, type KeystoneKeyDerivationRequestInput, type KeystoneKeySchema, type KeystoneParsedAccount, type KeystoneParsedMultiAccounts, type KeystoneSolSignRequestInput, type KeystoneSolSignatureResult, type KeystoneTronSignRequestInput, type KeystoneTronSignatureResult, type KeystoneUr, KeystoneUrEngine, accountKey, btcScriptTypeFromPath, createDeviceRecord, normalizePath, placeholderDeviceInfo, splitAccountPath, toDeviceInfo, walletConnectId };
|
|
474
|
+
export { type BtcScriptType, type ImportFromQrOptions, KEYSTONE_COLD_START_PATH, KEYSTONE_WALLET_CONNECT_ID_PREFIX, type KeystoneAccountEntry, KeystoneAdapter, type KeystoneBtcSignRequestAccount, type KeystoneBtcSignatureResult, type KeystoneDerivationCurve, type KeystoneDeviceRecord, type KeystoneEthSignRequestInput, type KeystoneEthSignatureResult, type KeystoneHardwareCallChainType, type KeystoneKeyDerivationRequestInput, type KeystoneKeySchema, type KeystoneParsedAccount, type KeystoneParsedMultiAccounts, type KeystoneSolSignRequestInput, type KeystoneSolSignatureResult, type KeystoneTronSignRequestInput, type KeystoneTronSignatureResult, type KeystoneUr, KeystoneUrEngine, accountKey, btcScriptTypeFromPath, createDeviceRecord, normalizePath, placeholderDeviceInfo, splitAccountPath, toDeviceInfo, walletConnectId };
|