@onekeyfe/hd-core 1.1.27-alpha.2 → 1.1.27-alpha.3
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/core/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/package.json +4 -4
- package/src/core/index.ts +14 -6
package/dist/core/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":";AACA,OAAO,YAAY,MAAM,QAAQ,CAAC;AAwClC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAkB1C,OAAO,eAAe,MAAM,2BAA2B,CAAC;AAIxD,OAAO,KAAK,EAAE,eAAe,EAAe,MAAM,UAAU,CAAC;AAC7D,OAAO,KAAK,EAAE,WAAW,EAAmD,MAAM,WAAW,CAAC;AAI9F,OAAO,KAAK,EAEV,6BAA6B,EAE9B,MAAM,wBAAwB,CAAC;AAWhC,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC;AA6D7D,eAAO,MAAM,OAAO,YAAmB,WAAW,WAAW,WAAW,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":";AACA,OAAO,YAAY,MAAM,QAAQ,CAAC;AAwClC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAkB1C,OAAO,eAAe,MAAM,2BAA2B,CAAC;AAIxD,OAAO,KAAK,EAAE,eAAe,EAAe,MAAM,UAAU,CAAC;AAC7D,OAAO,KAAK,EAAE,WAAW,EAAmD,MAAM,WAAW,CAAC;AAI9F,OAAO,KAAK,EAEV,6BAA6B,EAE9B,MAAM,wBAAwB,CAAC;AAWhC,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC;AA6D7D,eAAO,MAAM,OAAO,YAAmB,WAAW,WAAW,WAAW,iBA6EvE,CAAC;AAixBF,eAAO,MAAM,MAAM,YAAa,WAAW,cAAc,MAAM,SAkF9D,CAAC;AAuEF,eAAO,MAAM,qBAAqB,gFAejC,CAAC;AA0GF,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,YAAY;IAC5C,OAAO,CAAC,cAAc,CAAoB;IAE1C,SAAgB,aAAa,EAAE,MAAM,CAAC;IAEtC,OAAO,CAAC,YAAY,CAAsB;IAG1C,OAAO,CAAC,qBAAqB,CAA4B;IAEzD,OAAO,CAAC,iBAAiB,CAAoB;;IAS7C,OAAO,CAAC,cAAc;IAoBhB,aAAa,CAAC,OAAO,EAAE,WAAW;IA2DxC,OAAO;CASR;AAED,eAAO,MAAM,QAAQ,YAGpB,CAAC;AAEF,eAAO,MAAM,aAAa,uBAIzB,CAAC;AAMF,eAAO,MAAM,IAAI,aACL,eAAe,aACd,GAAG,WACL,6BAA6B,8BAoBvC,CAAC;AAEF,eAAO,MAAM,eAAe;SAKrB,eAAe,CAAC,KAAK,CAAC;eAChB,GAAG;;UASf,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -40731,6 +40731,9 @@ const callAPI = (context, message) => __awaiter(void 0, void 0, void 0, function
|
|
|
40731
40731
|
return onCallDevice(context, message, method);
|
|
40732
40732
|
});
|
|
40733
40733
|
const handlePreWarmSignal = (context, message, method) => __awaiter(void 0, void 0, void 0, function* () {
|
|
40734
|
+
if (!method.connectId) {
|
|
40735
|
+
return createResponseMessage(method.responseID, true, true);
|
|
40736
|
+
}
|
|
40734
40737
|
const key = method.getPreWarmKey();
|
|
40735
40738
|
const inflight = preWarmInflight.get(key);
|
|
40736
40739
|
if (inflight) {
|
|
@@ -41096,6 +41099,8 @@ function canSkipInitialize(method, device) {
|
|
|
41096
41099
|
reasons.push('method.disallow');
|
|
41097
41100
|
if (!((_a = method.payload) === null || _a === void 0 ? void 0 : _a.usePreInitialize))
|
|
41098
41101
|
reasons.push('payload.usePreInitialize=false');
|
|
41102
|
+
if (!method.connectId)
|
|
41103
|
+
reasons.push('connectId.missing');
|
|
41099
41104
|
if (!device.isPreInitializeMetaMatch(method.payload))
|
|
41100
41105
|
reasons.push('meta.mismatch');
|
|
41101
41106
|
if (!device.features)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/hd-core",
|
|
3
|
-
"version": "1.1.27-alpha.
|
|
3
|
+
"version": "1.1.27-alpha.3",
|
|
4
4
|
"description": "Core processes and APIs for communicating with OneKey hardware devices.",
|
|
5
5
|
"author": "OneKey",
|
|
6
6
|
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"url": "https://github.com/OneKeyHQ/hardware-js-sdk/issues"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@onekeyfe/hd-shared": "1.1.27-alpha.
|
|
29
|
-
"@onekeyfe/hd-transport": "1.1.27-alpha.
|
|
28
|
+
"@onekeyfe/hd-shared": "1.1.27-alpha.3",
|
|
29
|
+
"@onekeyfe/hd-transport": "1.1.27-alpha.3",
|
|
30
30
|
"axios": "1.15.2",
|
|
31
31
|
"bignumber.js": "^9.0.2",
|
|
32
32
|
"bytebuffer": "^5.0.1",
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"@types/w3c-web-usb": "^1.0.10",
|
|
45
45
|
"@types/web-bluetooth": "^0.0.21"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "10fc2dc0e9a181c9fde6e299e27d1a3a4f91f626"
|
|
48
48
|
}
|
package/src/core/index.ts
CHANGED
|
@@ -212,6 +212,8 @@ export const callAPI = async (context: CoreContext, message: CoreMessage) => {
|
|
|
212
212
|
return createResponseMessage(method.responseID, false, { error });
|
|
213
213
|
}
|
|
214
214
|
|
|
215
|
+
// only the pre-warm signal (PreInitialize) forks here; normal methods fall
|
|
216
|
+
// through to onCallDevice below, so the pre-warm dedup/guards never touch them
|
|
215
217
|
if (method.isPreWarmSignal) {
|
|
216
218
|
return handlePreWarmSignal(context, message, method);
|
|
217
219
|
}
|
|
@@ -227,6 +229,11 @@ const handlePreWarmSignal = async (
|
|
|
227
229
|
message: CoreMessage,
|
|
228
230
|
method: BaseMethod
|
|
229
231
|
): Promise<any> => {
|
|
232
|
+
// no connectId: can't target a device safely, skip pre-warm (ack only)
|
|
233
|
+
if (!method.connectId) {
|
|
234
|
+
return createResponseMessage(method.responseID, true, true);
|
|
235
|
+
}
|
|
236
|
+
|
|
230
237
|
const key = method.getPreWarmKey();
|
|
231
238
|
|
|
232
239
|
const inflight = preWarmInflight.get(key);
|
|
@@ -781,16 +788,17 @@ function initDeviceForBle(method: BaseMethod) {
|
|
|
781
788
|
*/
|
|
782
789
|
function canSkipInitialize(method: BaseMethod, device: Device): boolean {
|
|
783
790
|
const reasons: string[] = [];
|
|
784
|
-
//
|
|
785
|
-
// only sign-style methods opt in; getAddress/getPublicKey never do).
|
|
791
|
+
// only sign-style methods opt in; getAddress/getPublicKey never do
|
|
786
792
|
if (!method.allowUsePreInitialize) reasons.push('method.disallow');
|
|
787
|
-
//
|
|
793
|
+
// caller must opt in per call
|
|
788
794
|
if (!method.payload?.usePreInitialize) reasons.push('payload.usePreInitialize=false');
|
|
789
|
-
//
|
|
795
|
+
// no connectId: can't pin the target device, never skip
|
|
796
|
+
if (!method.connectId) reasons.push('connectId.missing');
|
|
797
|
+
// passphrase state must match the pre-initialize
|
|
790
798
|
if (!device.isPreInitializeMetaMatch(method.payload)) reasons.push('meta.mismatch');
|
|
791
|
-
//
|
|
799
|
+
// device must have been initialized before (has features)
|
|
792
800
|
if (!device.features) reasons.push('features.missing');
|
|
793
|
-
//
|
|
801
|
+
// within pre-initialize TTL
|
|
794
802
|
if (!device.isPreInitializedValid(PRE_INITIALIZE_TTL_MS)) reasons.push('ttl.expired');
|
|
795
803
|
|
|
796
804
|
if (reasons.length) {
|