@onekeyfe/hd-core 0.2.34 → 0.2.35
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.d.ts +1 -0
- package/dist/index.js +9 -7
- package/dist/types/params.d.ts +1 -0
- package/dist/types/params.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/core/index.ts +16 -7
- package/src/types/params.ts +4 -0
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;AAqBlC,OAAO,EACL,WAAW,EAYZ,MAAM,WAAW,CAAC;AAEnB,OAAO,KAAK,EAAE,eAAe,EAAe,MAAM,UAAU,CAAC;AAE7D,OAAO,eAAe,MAAM,2BAA2B,CAAC;AA4BxD,eAAO,MAAM,OAAO,YAAmB,WAAW,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":";AACA,OAAO,YAAY,MAAM,QAAQ,CAAC;AAqBlC,OAAO,EACL,WAAW,EAYZ,MAAM,WAAW,CAAC;AAEnB,OAAO,KAAK,EAAE,eAAe,EAAe,MAAM,UAAU,CAAC;AAE7D,OAAO,eAAe,MAAM,2BAA2B,CAAC;AA4BxD,eAAO,MAAM,OAAO,YAAmB,WAAW,iBAkQjD,CAAC;AAqMF,eAAO,MAAM,MAAM,0CAkBlB,CAAC;AAoJF,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,YAAY;IACtC,aAAa,CAAC,OAAO,EAAE,WAAW;IA8CxC,OAAO;CAGR;AAED,eAAO,MAAM,QAAQ,YAGpB,CAAC;AAEF,eAAO,MAAM,aAAa,uBAIzB,CAAC;AAMF,eAAO,MAAM,IAAI,aAAoB,eAAe,aAAa,GAAG,8BAmBnE,CAAC"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -18426,7 +18426,7 @@ const callAPI = (message) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
18426
18426
|
(_a = method.setDevice) === null || _a === void 0 ? void 0 : _a.call(method, device);
|
|
18427
18427
|
device.on(DEVICE.PIN, onDevicePinHandler);
|
|
18428
18428
|
device.on(DEVICE.BUTTON, onDeviceButtonHandler);
|
|
18429
|
-
device.on(DEVICE.PASSPHRASE, onDevicePassphraseHandler);
|
|
18429
|
+
device.on(DEVICE.PASSPHRASE, message.payload.useEmptyPassphrase ? onEmptyPassphraseHandler : onDevicePassphraseHandler);
|
|
18430
18430
|
device.on(DEVICE.PASSPHRASE_ON_DEVICE, onEnterPassphraseOnDeviceHandler);
|
|
18431
18431
|
device.on(DEVICE.FEATURES, onDeviceFeaturesHandler);
|
|
18432
18432
|
try {
|
|
@@ -18730,7 +18730,9 @@ const cancel = (connectId) => {
|
|
|
18730
18730
|
const checkPassphraseSafety = (method, features) => {
|
|
18731
18731
|
if (!method.useDevicePassphraseState)
|
|
18732
18732
|
return;
|
|
18733
|
-
if ((features === null || features === void 0 ? void 0 : features.passphrase_protection) === true &&
|
|
18733
|
+
if ((features === null || features === void 0 ? void 0 : features.passphrase_protection) === true &&
|
|
18734
|
+
(method.payload.passphraseState == null || method.payload.passphraseState === '') &&
|
|
18735
|
+
!method.payload.useEmptyPassphrase) {
|
|
18734
18736
|
DevicePool.clearDeviceCache(method.payload.connectId);
|
|
18735
18737
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceOpenedPassphrase);
|
|
18736
18738
|
}
|
|
@@ -18744,11 +18746,7 @@ const cleanup = () => {
|
|
|
18744
18746
|
Log.debug('Cleanup...');
|
|
18745
18747
|
};
|
|
18746
18748
|
const removeDeviceListener = (device) => {
|
|
18747
|
-
device.
|
|
18748
|
-
device.removeListener(DEVICE.BUTTON, onDeviceButtonHandler);
|
|
18749
|
-
device.removeListener(DEVICE.PASSPHRASE, onDevicePassphraseHandler);
|
|
18750
|
-
device.removeListener(DEVICE.PASSPHRASE_ON_DEVICE, onEnterPassphraseOnDeviceHandler);
|
|
18751
|
-
device.removeListener(DEVICE.FEATURES, onDeviceFeaturesHandler);
|
|
18749
|
+
device.removeAllListeners();
|
|
18752
18750
|
DevicePool.emitter.removeListener(DEVICE.CONNECT, onDeviceConnectHandler);
|
|
18753
18751
|
};
|
|
18754
18752
|
const closePopup = () => {
|
|
@@ -18804,6 +18802,10 @@ const onDevicePassphraseHandler = (...[device, callback]) => __awaiter(void 0, v
|
|
|
18804
18802
|
cache: save,
|
|
18805
18803
|
});
|
|
18806
18804
|
});
|
|
18805
|
+
const onEmptyPassphraseHandler = (...[_, callback]) => {
|
|
18806
|
+
Log.debug('onEmptyPassphraseHandler');
|
|
18807
|
+
callback({ passphrase: '' });
|
|
18808
|
+
};
|
|
18807
18809
|
const onEnterPassphraseOnDeviceHandler = (...[device]) => {
|
|
18808
18810
|
postMessage(createUiMessage(UI_REQUEST$1.REQUEST_PASSPHRASE_ON_DEVICE, {
|
|
18809
18811
|
device: device.toMessageObject(),
|
package/dist/types/params.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"params.d.ts","sourceRoot":"","sources":["../../src/types/params.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC3B,WAAW,CAAC,EAAE,OAAO,CAAC;IAItB,UAAU,CAAC,EAAE,MAAM,CAAC;IAIpB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAI1B,OAAO,CAAC,EAAE,MAAM,CAAC;IAIjB,eAAe,CAAC,EAAE,MAAM,CAAC;IAIzB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,oBAAY,MAAM,CAAC,CAAC,IAAI,YAAY,GAAG,CAAC,GAAG;IAAE,MAAM,CAAC,EAAE,SAAS,CAAA;CAAE,CAAC;AAElE,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,K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
2
|
"name": "@onekeyfe/hd-core",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.35",
|
|
4
4
|
"description": "> TODO: description",
|
|
5
5
|
"author": "OneKey",
|
|
6
6
|
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"url": "https://github.com/OneKeyHQ/hardware-js-sdk/issues"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@onekeyfe/hd-shared": "^0.2.
|
|
28
|
-
"@onekeyfe/hd-transport": "^0.2.
|
|
27
|
+
"@onekeyfe/hd-shared": "^0.2.35",
|
|
28
|
+
"@onekeyfe/hd-transport": "^0.2.35",
|
|
29
29
|
"axios": "^0.27.2",
|
|
30
30
|
"bignumber.js": "^9.0.2",
|
|
31
31
|
"jszip": "^3.10.1",
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"@types/semver": "^7.3.9",
|
|
43
43
|
"ripple-keypairs": "^1.1.4"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "3dc0a64c3a036bf1ffbb1959bfc7957091aab1e6"
|
|
46
46
|
}
|
package/src/core/index.ts
CHANGED
|
@@ -133,7 +133,10 @@ export const callAPI = async (message: CoreMessage) => {
|
|
|
133
133
|
|
|
134
134
|
device.on(DEVICE.PIN, onDevicePinHandler);
|
|
135
135
|
device.on(DEVICE.BUTTON, onDeviceButtonHandler);
|
|
136
|
-
device.on(
|
|
136
|
+
device.on(
|
|
137
|
+
DEVICE.PASSPHRASE,
|
|
138
|
+
message.payload.useEmptyPassphrase ? onEmptyPassphraseHandler : onDevicePassphraseHandler
|
|
139
|
+
);
|
|
137
140
|
device.on(DEVICE.PASSPHRASE_ON_DEVICE, onEnterPassphraseOnDeviceHandler);
|
|
138
141
|
device.on(DEVICE.FEATURES, onDeviceFeaturesHandler);
|
|
139
142
|
|
|
@@ -540,7 +543,11 @@ export const cancel = (connectId?: string) => {
|
|
|
540
543
|
const checkPassphraseSafety = (method: BaseMethod, features?: Features) => {
|
|
541
544
|
if (!method.useDevicePassphraseState) return;
|
|
542
545
|
|
|
543
|
-
if (
|
|
546
|
+
if (
|
|
547
|
+
features?.passphrase_protection === true &&
|
|
548
|
+
(method.payload.passphraseState == null || method.payload.passphraseState === '') &&
|
|
549
|
+
!method.payload.useEmptyPassphrase
|
|
550
|
+
) {
|
|
544
551
|
DevicePool.clearDeviceCache(method.payload.connectId);
|
|
545
552
|
throw ERRORS.TypedError(HardwareErrorCode.DeviceOpenedPassphrase);
|
|
546
553
|
}
|
|
@@ -557,11 +564,7 @@ const cleanup = () => {
|
|
|
557
564
|
};
|
|
558
565
|
|
|
559
566
|
const removeDeviceListener = (device: Device) => {
|
|
560
|
-
device.
|
|
561
|
-
device.removeListener(DEVICE.BUTTON, onDeviceButtonHandler);
|
|
562
|
-
device.removeListener(DEVICE.PASSPHRASE, onDevicePassphraseHandler);
|
|
563
|
-
device.removeListener(DEVICE.PASSPHRASE_ON_DEVICE, onEnterPassphraseOnDeviceHandler);
|
|
564
|
-
device.removeListener(DEVICE.FEATURES, onDeviceFeaturesHandler);
|
|
567
|
+
device.removeAllListeners();
|
|
565
568
|
DevicePool.emitter.removeListener(DEVICE.CONNECT, onDeviceConnectHandler);
|
|
566
569
|
// DevicePool.emitter.removeListener(DEVICE.DISCONNECT, onDeviceDisconnectHandler);
|
|
567
570
|
};
|
|
@@ -641,6 +644,12 @@ const onDevicePassphraseHandler = async (...[device, callback]: DeviceEvents['pa
|
|
|
641
644
|
});
|
|
642
645
|
};
|
|
643
646
|
|
|
647
|
+
const onEmptyPassphraseHandler = (...[_, callback]: DeviceEvents['passphrase']) => {
|
|
648
|
+
Log.debug('onEmptyPassphraseHandler');
|
|
649
|
+
// send as PassphrasePromptResponse
|
|
650
|
+
callback({ passphrase: '' });
|
|
651
|
+
};
|
|
652
|
+
|
|
644
653
|
const onEnterPassphraseOnDeviceHandler = (
|
|
645
654
|
...[device]: [...DeviceEvents['passphrase_on_device']]
|
|
646
655
|
) => {
|