@onekeyfe/hd-core 0.1.29 → 0.1.32
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/device/Device.d.ts.map +1 -1
- package/dist/index.js +34 -4
- package/package.json +4 -4
- package/src/device/Device.ts +31 -1
- package/src/device/DeviceCommands.ts +7 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Device.d.ts","sourceRoot":"","sources":["../../src/device/Device.ts"],"names":[],"mappings":";AAAA,OAAO,YAAY,MAAM,QAAQ,CAAC;AAClC,OAAO,EAAE,gBAAgB,IAAI,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC9E,OAAO,EAEL,QAAQ,EAIT,MAAM,qBAAqB,CAAC;AAE7B,OAAO,KAAK,eAAe,MAAM,mBAAmB,CAAC;AAErD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAUlD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,IAAI,WAAW,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AACzF,OAAO,EAAE,MAAM,EAAE,0BAA0B,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAEtF,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAIrC,aAAK,UAAU,GAAG;IAChB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AASF,MAAM,WAAW,YAAY;IAC3B,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC,oBAAoB,GAAG,SAAS,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC,CAAC;IAChG,CAAC,MAAM,CAAC,oBAAoB,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC;IACpE,CAAC,MAAM,CAAC,MAAM,CAAC,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AiB9B,gBAAgB,CAAC,UAAU,EAAE,gBAAgB,EAAE,WAAW,UAAQ;IAiBlE,eAAe,CAAC,MAAM,EAAE,MAAM;IASxB,GAAG,CAAC,EAAE,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,EAAE,UAAU;IAYlD,SAAS,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,MAAM,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,EAAE,OAAO,EAAE,UAAU;IAwEpE,uBAAuB;IASvB,oBAAoB;IAS1B,OAAO;IAOP,kBAAkB;IAKlB,qBAAqB;IAKrB,MAAM;IAIN,UAAU;IAQV,eAAe,IAAI,OAAO;IAI1B,YAAY;IAIZ,aAAa;IAIb,UAAU;IAIV,YAAY,IAAI,OAAO;IAIvB,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE;IAsBpD,aAAa,CAAC,QAAQ,EAAE,MAAM;CAM/B;AAED,eAAe,MAAM,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -10428,9 +10428,6 @@ class DeviceCommands {
|
|
|
10428
10428
|
if (res.type === 'Features') {
|
|
10429
10429
|
return Promise.resolve(patchFeatures(res));
|
|
10430
10430
|
}
|
|
10431
|
-
if ((_a = this.device.features) === null || _a === void 0 ? void 0 : _a.passphrase_protection) {
|
|
10432
|
-
return Promise.reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceNotSupportPassphrase));
|
|
10433
|
-
}
|
|
10434
10431
|
if (res.type === 'ButtonRequest') {
|
|
10435
10432
|
if (res.message.code === 'ButtonRequest_PassphraseEntry') {
|
|
10436
10433
|
this.device.emit(DEVICE.PASSPHRASE_ON_DEVICE, this.device);
|
|
@@ -10453,6 +10450,9 @@ class DeviceCommands {
|
|
|
10453
10450
|
return this._commonCall('PinMatrixAck', { pin });
|
|
10454
10451
|
}, () => this._commonCall('Cancel', {}));
|
|
10455
10452
|
}
|
|
10453
|
+
if ((_a = this.device.features) === null || _a === void 0 ? void 0 : _a.passphrase_protection) {
|
|
10454
|
+
return Promise.reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceNotSupportPassphrase));
|
|
10455
|
+
}
|
|
10456
10456
|
if (res.type === 'PassphraseRequest') {
|
|
10457
10457
|
return Promise.reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceNotSupportPassphrase));
|
|
10458
10458
|
}
|
|
@@ -10738,6 +10738,12 @@ class Device extends events.exports {
|
|
|
10738
10738
|
}
|
|
10739
10739
|
const { message } = yield this.commands.typedCall('Initialize', 'Features', payload);
|
|
10740
10740
|
this._updateFeatures(message);
|
|
10741
|
+
if (message.passphrase_protection) {
|
|
10742
|
+
if (this.listenerCount(DEVICE.PIN) > 0) {
|
|
10743
|
+
Log$3.debug('try to close passpharse');
|
|
10744
|
+
yield this.commands.typedCall('ApplySettings', 'Success', { use_passphrase: false });
|
|
10745
|
+
}
|
|
10746
|
+
}
|
|
10741
10747
|
});
|
|
10742
10748
|
}
|
|
10743
10749
|
getFeatures() {
|
|
@@ -10789,6 +10795,7 @@ class Device extends events.exports {
|
|
|
10789
10795
|
});
|
|
10790
10796
|
}
|
|
10791
10797
|
_runInner(fn, options) {
|
|
10798
|
+
var _a;
|
|
10792
10799
|
return __awaiter(this, void 0, void 0, function* () {
|
|
10793
10800
|
if (!this.isUsedHere() || this.commands.disposed) {
|
|
10794
10801
|
const env = DataManager.getSettings('env');
|
|
@@ -10807,12 +10814,35 @@ class Device extends events.exports {
|
|
|
10807
10814
|
return Promise.reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceInitializeFailed, `Initialize failed: ${error.message}, code: ${error.code}`));
|
|
10808
10815
|
}
|
|
10809
10816
|
}
|
|
10817
|
+
else if (env === 'react-native') {
|
|
10818
|
+
if ((_a = this.features) === null || _a === void 0 ? void 0 : _a.passphrase_protection) {
|
|
10819
|
+
if (this.listenerCount(DEVICE.PIN) > 0) {
|
|
10820
|
+
Log$3.debug('try to close passpharse for mobile');
|
|
10821
|
+
try {
|
|
10822
|
+
yield this.commands.typedCall('ApplySettings', 'Success', { use_passphrase: false });
|
|
10823
|
+
}
|
|
10824
|
+
catch (e) {
|
|
10825
|
+
this.runPromise = null;
|
|
10826
|
+
return Promise.reject(e);
|
|
10827
|
+
}
|
|
10828
|
+
}
|
|
10829
|
+
}
|
|
10830
|
+
}
|
|
10810
10831
|
}
|
|
10811
10832
|
if (options.keepSession) {
|
|
10812
10833
|
this.keepSession = true;
|
|
10813
10834
|
}
|
|
10814
10835
|
if (fn) {
|
|
10815
|
-
|
|
10836
|
+
try {
|
|
10837
|
+
yield fn();
|
|
10838
|
+
}
|
|
10839
|
+
catch (e) {
|
|
10840
|
+
if (this.runPromise) {
|
|
10841
|
+
this.runPromise.reject(e);
|
|
10842
|
+
}
|
|
10843
|
+
this.runPromise = null;
|
|
10844
|
+
return;
|
|
10845
|
+
}
|
|
10816
10846
|
}
|
|
10817
10847
|
if ((!this.keepSession && typeof options.keepSession !== 'boolean') ||
|
|
10818
10848
|
options.keepSession === false) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/hd-core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.32",
|
|
4
4
|
"description": "> TODO: description",
|
|
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": "^0.1.
|
|
29
|
-
"@onekeyfe/hd-transport": "^0.1.
|
|
28
|
+
"@onekeyfe/hd-shared": "^0.1.32",
|
|
29
|
+
"@onekeyfe/hd-transport": "^0.1.32",
|
|
30
30
|
"axios": "^0.27.2",
|
|
31
31
|
"bignumber.js": "^9.0.2",
|
|
32
32
|
"js-sha256": "^0.9.0",
|
|
@@ -37,5 +37,5 @@
|
|
|
37
37
|
"@types/parse-uri": "^1.0.0",
|
|
38
38
|
"@types/semver": "^7.3.9"
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "a9f9851579a20668178fdc06b594deed220cbe43"
|
|
41
41
|
}
|
package/src/device/Device.ts
CHANGED
|
@@ -255,6 +255,12 @@ export class Device extends EventEmitter {
|
|
|
255
255
|
|
|
256
256
|
const { message } = await this.commands.typedCall('Initialize', 'Features', payload);
|
|
257
257
|
this._updateFeatures(message);
|
|
258
|
+
if (message.passphrase_protection) {
|
|
259
|
+
if (this.listenerCount(DEVICE.PIN) > 0) {
|
|
260
|
+
Log.debug('try to close passpharse');
|
|
261
|
+
await this.commands.typedCall('ApplySettings', 'Success', { use_passphrase: false });
|
|
262
|
+
}
|
|
263
|
+
}
|
|
258
264
|
}
|
|
259
265
|
|
|
260
266
|
async getFeatures() {
|
|
@@ -338,6 +344,21 @@ export class Device extends EventEmitter {
|
|
|
338
344
|
)
|
|
339
345
|
);
|
|
340
346
|
}
|
|
347
|
+
} else if (env === 'react-native') {
|
|
348
|
+
/**
|
|
349
|
+
* The timing of the mobile initialization is different, so it needs to be closed here
|
|
350
|
+
*/
|
|
351
|
+
if (this.features?.passphrase_protection) {
|
|
352
|
+
if (this.listenerCount(DEVICE.PIN) > 0) {
|
|
353
|
+
Log.debug('try to close passpharse for mobile');
|
|
354
|
+
try {
|
|
355
|
+
await this.commands.typedCall('ApplySettings', 'Success', { use_passphrase: false });
|
|
356
|
+
} catch (e) {
|
|
357
|
+
this.runPromise = null;
|
|
358
|
+
return Promise.reject(e);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
}
|
|
341
362
|
}
|
|
342
363
|
}
|
|
343
364
|
|
|
@@ -346,7 +367,16 @@ export class Device extends EventEmitter {
|
|
|
346
367
|
}
|
|
347
368
|
|
|
348
369
|
if (fn) {
|
|
349
|
-
|
|
370
|
+
try {
|
|
371
|
+
await fn();
|
|
372
|
+
} catch (e) {
|
|
373
|
+
if (this.runPromise) {
|
|
374
|
+
this.runPromise.reject(e);
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
this.runPromise = null;
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
350
380
|
}
|
|
351
381
|
|
|
352
382
|
if (
|
|
@@ -181,13 +181,6 @@ export class DeviceCommands {
|
|
|
181
181
|
return Promise.resolve(patchFeatures(res));
|
|
182
182
|
}
|
|
183
183
|
|
|
184
|
-
/**
|
|
185
|
-
* Temporary, do not support passphrase
|
|
186
|
-
*/
|
|
187
|
-
if (this.device.features?.passphrase_protection) {
|
|
188
|
-
return Promise.reject(ERRORS.TypedError(HardwareErrorCode.DeviceNotSupportPassphrase));
|
|
189
|
-
}
|
|
190
|
-
|
|
191
184
|
if (res.type === 'ButtonRequest') {
|
|
192
185
|
if (res.message.code === 'ButtonRequest_PassphraseEntry') {
|
|
193
186
|
this.device.emit(DEVICE.PASSPHRASE_ON_DEVICE, this.device);
|
|
@@ -221,6 +214,13 @@ export class DeviceCommands {
|
|
|
221
214
|
);
|
|
222
215
|
}
|
|
223
216
|
|
|
217
|
+
/**
|
|
218
|
+
* Temporary, do not support passphrase
|
|
219
|
+
*/
|
|
220
|
+
if (this.device.features?.passphrase_protection) {
|
|
221
|
+
return Promise.reject(ERRORS.TypedError(HardwareErrorCode.DeviceNotSupportPassphrase));
|
|
222
|
+
}
|
|
223
|
+
|
|
224
224
|
if (res.type === 'PassphraseRequest') {
|
|
225
225
|
/**
|
|
226
226
|
* Temporary, do not support passphrase
|