@onekeyfe/hwk-keystone-adapter 1.2.5-alpha.3 → 1.2.6-alpha.0
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 +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +10 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +15 -12
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import bs58check from "bs58check";
|
|
|
5
5
|
import * as bitcoin from "bitcoinjs-lib";
|
|
6
6
|
import HDKey from "hdkey";
|
|
7
7
|
import { parse as uuidParse, stringify as uuidStringify } from "uuid";
|
|
8
|
-
import {
|
|
8
|
+
import { parseWalletMasterFingerprint } from "@onekeyfe/hwk-adapter-core";
|
|
9
9
|
|
|
10
10
|
// src/urEngine/TronSignRequest.ts
|
|
11
11
|
import {
|
|
@@ -155,10 +155,9 @@ function requireSignatureBytes(hex, expectedBytes, chain) {
|
|
|
155
155
|
}
|
|
156
156
|
return hex;
|
|
157
157
|
}
|
|
158
|
-
var MISSING_MASTER_FINGERPRINT = "00000000";
|
|
159
158
|
function requireBip32MasterFingerprint(value) {
|
|
160
|
-
const fingerprint =
|
|
161
|
-
if (!fingerprint
|
|
159
|
+
const fingerprint = parseWalletMasterFingerprint(value);
|
|
160
|
+
if (!fingerprint) {
|
|
162
161
|
throw new Error("Keystone master fingerprint must be exactly 4 bytes (8 hex characters)");
|
|
163
162
|
}
|
|
164
163
|
return fingerprint;
|
|
@@ -402,6 +401,7 @@ import {
|
|
|
402
401
|
DEVICE,
|
|
403
402
|
DeviceJobQueue,
|
|
404
403
|
HardwareErrorCode,
|
|
404
|
+
MISSING_BIP32_MASTER_FINGERPRINT,
|
|
405
405
|
OperationRegistry,
|
|
406
406
|
SDK,
|
|
407
407
|
TypedEventEmitter,
|
|
@@ -424,7 +424,8 @@ import {
|
|
|
424
424
|
isHwkRecoveryHint,
|
|
425
425
|
isUserRefusal,
|
|
426
426
|
operationMayHaveCompletedParams,
|
|
427
|
-
parseBip32MasterFingerprint
|
|
427
|
+
parseBip32MasterFingerprint,
|
|
428
|
+
parseWalletMasterFingerprint as parseWalletMasterFingerprint3,
|
|
428
429
|
rehydrateConnectorError,
|
|
429
430
|
resolveHardwareOperationTarget as resolveGenericHardwareOperationTarget,
|
|
430
431
|
runAllNetworkGetAddress,
|
|
@@ -525,14 +526,14 @@ function placeholderDeviceInfo() {
|
|
|
525
526
|
}
|
|
526
527
|
|
|
527
528
|
// src/utils/queueKey.ts
|
|
528
|
-
import { isHardwareOperationId,
|
|
529
|
+
import { isHardwareOperationId, parseWalletMasterFingerprint as parseWalletMasterFingerprint2 } from "@onekeyfe/hwk-adapter-core";
|
|
529
530
|
var KEYSTONE_COLD_START_JOB_LABEL = "keystone-cold-start";
|
|
530
531
|
function keystoneQueueKey(connectId, deviceId) {
|
|
531
532
|
return isHardwareOperationId(connectId) ? connectId : deviceId || connectId || KEYSTONE_COLD_START_JOB_LABEL;
|
|
532
533
|
}
|
|
533
534
|
function keystoneMfpFromIdentifier(identifier) {
|
|
534
535
|
const value = identifier.startsWith(KEYSTONE_WALLET_CONNECT_ID_PREFIX) ? identifier.slice(KEYSTONE_WALLET_CONNECT_ID_PREFIX.length) : identifier;
|
|
535
|
-
return
|
|
536
|
+
return parseWalletMasterFingerprint2(value);
|
|
536
537
|
}
|
|
537
538
|
function keystoneCancelQueueKeys(identifiers) {
|
|
538
539
|
const keys = /* @__PURE__ */ new Set();
|
|
@@ -1837,11 +1838,12 @@ var KeystoneAdapter = class _KeystoneAdapter {
|
|
|
1837
1838
|
sessionId = session.sessionId;
|
|
1838
1839
|
_KeystoneAdapter._throwIfAborted(signal);
|
|
1839
1840
|
const raw = session.deviceInfo.raw;
|
|
1840
|
-
const mfpValue =
|
|
1841
|
+
const mfpValue = parseWalletMasterFingerprint3(raw?.masterFingerprint);
|
|
1841
1842
|
if (!mfpValue) {
|
|
1843
|
+
const empty = parseBip32MasterFingerprint(raw?.masterFingerprint) === MISSING_BIP32_MASTER_FINGERPRINT;
|
|
1842
1844
|
throw createHwkError({
|
|
1843
|
-
code: HardwareErrorCode.DeviceMismatch,
|
|
1844
|
-
message: "Keystone USB did not report a master fingerprint"
|
|
1845
|
+
code: empty ? HardwareErrorCode.DeviceNotInitialized : HardwareErrorCode.DeviceMismatch,
|
|
1846
|
+
message: empty ? "Keystone has no wallet yet; it reported an empty master fingerprint" : "Keystone USB did not report a master fingerprint"
|
|
1845
1847
|
});
|
|
1846
1848
|
}
|
|
1847
1849
|
const masterFingerprint = mfpValue.toLowerCase();
|
|
@@ -2308,11 +2310,12 @@ var KeystoneAdapter = class _KeystoneAdapter {
|
|
|
2308
2310
|
throw signal.reason instanceof Error ? signal.reason : new Error("Operation aborted");
|
|
2309
2311
|
}
|
|
2310
2312
|
}
|
|
2313
|
+
/** A response without the request's id is as unrelated as one with another id. */
|
|
2311
2314
|
static _assertRequestIdMatches(expected, actual) {
|
|
2312
|
-
if (actual
|
|
2315
|
+
if (!actual || actual.toLowerCase() !== expected.toLowerCase()) {
|
|
2313
2316
|
throw createHwkError({
|
|
2314
2317
|
code: HardwareErrorCode.DeviceMismatch,
|
|
2315
|
-
message: "Keystone response requestId does not match the pending request \u2014 discarding a stale or unrelated scan"
|
|
2318
|
+
message: actual ? "Keystone response requestId does not match the pending request \u2014 discarding a stale or unrelated scan" : "Keystone response carries no requestId \u2014 discarding a stale or unrelated scan"
|
|
2316
2319
|
});
|
|
2317
2320
|
}
|
|
2318
2321
|
}
|