@onekeyfe/hd-core 0.1.59 → 0.2.1
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/api/device/DeviceSupportFeatures.d.ts +1 -0
- package/dist/api/device/DeviceSupportFeatures.d.ts.map +1 -1
- package/dist/api/device/DeviceUploadResource.d.ts.map +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +36 -2
- package/dist/types/device.d.ts +1 -0
- package/dist/types/device.d.ts.map +1 -1
- package/dist/utils/deviceFeaturesUtils.d.ts +1 -0
- package/dist/utils/deviceFeaturesUtils.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/api/device/DeviceSupportFeatures.ts +6 -1
- package/src/api/device/DeviceUploadResource.ts +3 -0
- package/src/core/index.ts +24 -3
- package/src/types/device.ts +1 -0
- package/src/utils/deviceFeaturesUtils.ts +12 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeviceSupportFeatures.d.ts","sourceRoot":"","sources":["../../../src/api/device/DeviceSupportFeatures.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DeviceSupportFeatures.d.ts","sourceRoot":"","sources":["../../../src/api/device/DeviceSupportFeatures.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,MAAM,CAAC,OAAO,OAAO,qBAAsB,SAAQ,UAAU;IAC3D,IAAI;IAIJ,GAAG;;;;;CAcJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeviceUploadResource.d.ts","sourceRoot":"","sources":["../../../src/api/device/DeviceUploadResource.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAEnE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"DeviceUploadResource.d.ts","sourceRoot":"","sources":["../../../src/api/device/DeviceUploadResource.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAEnE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAK3C,MAAM,CAAC,OAAO,OAAO,oBAAqB,SAAQ,UAAU,CAAC,cAAc,CAAC;IAC1E,UAAU;;;MAGR;IAEF,eAAe;;;;;IAQf,IAAI;IA8BJ,sBAAsB,QAEhB,qBAAqB,iBAAiB,CAAC,GACvC,qBAAqB,aAAa,CAAC,GACnC,qBAAqB,SAAS,CAAC,KAClC,QAAQ,OAAO,CAAC,CAkCjB;IAEI,GAAG;CAWV"}
|
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;AA2BxD,eAAO,MAAM,OAAO,YAAmB,WAAW,iBA+PjD,CAAC;
|
|
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;AA2BxD,eAAO,MAAM,OAAO,YAAmB,WAAW,iBA+PjD,CAAC;AAqMF,eAAO,MAAM,MAAM,0CAkBlB,CAAC;AA8IF,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
|
@@ -853,6 +853,16 @@ const supportBatchPublicKey = (features) => {
|
|
|
853
853
|
}
|
|
854
854
|
return semver__default["default"].gte(currentVersion, '2.6.0');
|
|
855
855
|
};
|
|
856
|
+
const supportModifyHomescreen = (features) => {
|
|
857
|
+
if (!features)
|
|
858
|
+
return { support: false };
|
|
859
|
+
const currentVersion = getDeviceFirmwareVersion(features).join('.');
|
|
860
|
+
const deviceType = getDeviceType(features);
|
|
861
|
+
if (deviceType === 'classic' || deviceType === 'mini') {
|
|
862
|
+
return { support: true };
|
|
863
|
+
}
|
|
864
|
+
return { support: semver__default["default"].gte(currentVersion, '3.4.0') };
|
|
865
|
+
};
|
|
856
866
|
|
|
857
867
|
var nested = {
|
|
858
868
|
AlgorandGetAddress: {
|
|
@@ -12548,6 +12558,7 @@ class DeviceUploadResource extends BaseMethod {
|
|
|
12548
12558
|
run() {
|
|
12549
12559
|
return __awaiter(this, void 0, void 0, function* () {
|
|
12550
12560
|
const res = yield this.device.commands.typedCall('ResourceUpload', ['ResourceRequest', 'ZoomRequest', 'Success'], this.params);
|
|
12561
|
+
this.postMessage(createUiMessage(UI_REQUEST$1.CLOSE_UI_WINDOW));
|
|
12551
12562
|
return this.processResourceRequest(res);
|
|
12552
12563
|
});
|
|
12553
12564
|
}
|
|
@@ -12561,8 +12572,10 @@ class DeviceSupportFeatures extends BaseMethod {
|
|
|
12561
12572
|
if (!this.device.features)
|
|
12562
12573
|
return Promise.reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'Device not initialized'));
|
|
12563
12574
|
const inputPinOnSoftware = supportInputPinOnSoftware(this.device.features);
|
|
12575
|
+
const modifyHomescreen = supportModifyHomescreen(this.device.features);
|
|
12564
12576
|
return Promise.resolve({
|
|
12565
12577
|
inputPinOnSoftware,
|
|
12578
|
+
modifyHomescreen,
|
|
12566
12579
|
device: this.device.toMessageObject(),
|
|
12567
12580
|
});
|
|
12568
12581
|
}
|
|
@@ -16347,6 +16360,26 @@ function initDeviceForBle(method) {
|
|
|
16347
16360
|
device.deviceConnector = _connector;
|
|
16348
16361
|
return device;
|
|
16349
16362
|
}
|
|
16363
|
+
let bleTimeoutRetry = 0;
|
|
16364
|
+
function connectDeviceForBle(method, device) {
|
|
16365
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
16366
|
+
try {
|
|
16367
|
+
yield device.acquire();
|
|
16368
|
+
yield device.initialize(parseInitOptions(method));
|
|
16369
|
+
}
|
|
16370
|
+
catch (err) {
|
|
16371
|
+
if (err.errorCode === hdShared.HardwareErrorCode.BleTimeoutError && bleTimeoutRetry <= 5) {
|
|
16372
|
+
bleTimeoutRetry += 1;
|
|
16373
|
+
Log.debug(`Bletooth connect timeout and will retry, retry count: ${bleTimeoutRetry}`);
|
|
16374
|
+
yield wait(3000);
|
|
16375
|
+
yield connectDeviceForBle(method, device);
|
|
16376
|
+
}
|
|
16377
|
+
else {
|
|
16378
|
+
throw err;
|
|
16379
|
+
}
|
|
16380
|
+
}
|
|
16381
|
+
});
|
|
16382
|
+
}
|
|
16350
16383
|
const ensureConnected = (method, pollingId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16351
16384
|
let tryCount = 0;
|
|
16352
16385
|
const MAX_RETRY_COUNT = (method.payload && method.payload.retryCount) || 5;
|
|
@@ -16397,8 +16430,8 @@ const ensureConnected = (method, pollingId) => __awaiter(void 0, void 0, void 0,
|
|
|
16397
16430
|
clearTimeout(timer);
|
|
16398
16431
|
}
|
|
16399
16432
|
if (env === 'react-native') {
|
|
16400
|
-
|
|
16401
|
-
yield
|
|
16433
|
+
bleTimeoutRetry = 0;
|
|
16434
|
+
yield connectDeviceForBle(method, device);
|
|
16402
16435
|
}
|
|
16403
16436
|
resolve(device);
|
|
16404
16437
|
return;
|
|
@@ -16412,6 +16445,7 @@ const ensureConnected = (method, pollingId) => __awaiter(void 0, void 0, void 0,
|
|
|
16412
16445
|
hdShared.HardwareErrorCode.BleLocationServicesDisabled,
|
|
16413
16446
|
hdShared.HardwareErrorCode.BleDeviceNotBonded,
|
|
16414
16447
|
hdShared.HardwareErrorCode.BleCharacteristicNotifyError,
|
|
16448
|
+
hdShared.HardwareErrorCode.BleTimeoutError,
|
|
16415
16449
|
hdShared.HardwareErrorCode.BleWriteCharacteristicError,
|
|
16416
16450
|
hdShared.HardwareErrorCode.BleAlreadyConnected,
|
|
16417
16451
|
hdShared.HardwareErrorCode.FirmwareUpdateLimitOneDevice,
|
package/dist/types/device.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"device.d.ts","sourceRoot":"","sources":["../../src/types/device.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C,oBAAY,YAAY,GAAG,WAAW,GAAG,UAAU,GAAG,MAAM,CAAC;AAE7D,oBAAY,UAAU,GAAG,QAAQ,GAAG,YAAY,GAAG,YAAY,GAAG,UAAU,CAAC;AAE7E,oBAAY,qBAAqB,GAC7B,eAAe,GACf,YAAY,GACZ,iBAAiB,GACjB,yBAAyB,CAAC;AAE9B,oBAAY,uBAAuB,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,qBAAqB,CAAA;CAAE,CAAC;AAE/E,oBAAY,WAAW,GAAG;IACxB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,IAAI,EAAE,MAAM,CAAC;IACb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,IAAI,CAAC;IACf,QAAQ,EAAE,IAAI,CAAC;IACf,QAAQ,EAAE,IAAI,CAAC;IACf,eAAe,EAAE,IAAI,CAAC;IACtB,gBAAgB,EAAE,KAAK,CAAC;CACzB,GACD;IACE,aAAa,EAAE,CAAC,CAAC;IACjB,QAAQ,EAAE,IAAI,CAAC;IACf,QAAQ,EAAE,IAAI,CAAC;IACf,QAAQ,EAAE,IAAI,CAAC;IACf,eAAe,EAAE,IAAI,CAAC;IACtB,gBAAgB,EAAE,IAAI,CAAC;CACxB,CAAC;AAEN,oBAAY,cAAc,GAAG,QAAQ,GAAG,iBAAiB,CAAC;AAE1D,oBAAY,kBAAkB,GAAG;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAExE,oBAAY,eAAe,GAAG;IAC5B,kBAAkB,EAAE,kBAAkB,CAAC;IACvC,gBAAgB,EAAE,kBAAkB,CAAC;CACtC,CAAC"}
|
|
@@ -13,4 +13,5 @@ export declare const supportInputPinOnSoftware: (features: Features) => SupportF
|
|
|
13
13
|
export declare const supportNewPassphrase: (features?: import("packages/hd-transport/dist").Features | undefined) => SupportFeatureType;
|
|
14
14
|
export declare const getPassphraseState: (features: Features, commands: DeviceCommands) => Promise<string | false>;
|
|
15
15
|
export declare const supportBatchPublicKey: (features?: import("packages/hd-transport/dist").Features | undefined) => boolean;
|
|
16
|
+
export declare const supportModifyHomescreen: (features?: import("packages/hd-transport/dist").Features | undefined) => SupportFeatureType;
|
|
16
17
|
//# sourceMappingURL=deviceFeaturesUtils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deviceFeaturesUtils.d.ts","sourceRoot":"","sources":["../../src/utils/deviceFeaturesUtils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,EACV,QAAQ,EACR,aAAa,EACb,WAAW,EACX,YAAY,EAC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CAAwB,WAQ3D,CAAC;AAEF,eAAO,MAAM,aAAa,aAAc,QAAQ,WAM/C,CAAC;AAEF,eAAO,MAAM,cAAc,aAAc,QAAQ,WAOhD,CAAC;AAKF,eAAO,MAAM,wBAAwB,aAAc,QAAQ,GAAG,SAAS,kBAOtE,CAAC;AAKF,eAAO,MAAM,2BAA2B,aAAc,QAAQ,KAAG,aAAa,GAAG,IAQhF,CAAC;AAEF,eAAO,MAAM,yBAAyB,aAAc,QAAQ,KAAG,kBAU9D,CAAC;AAEF,eAAO,MAAM,oBAAoB,4EAA0B,kBAW1D,CAAC;AAEF,eAAO,MAAM,kBAAkB,aAAoB,QAAQ,YAAY,cAAc,4BAUpF,CAAC;AAEF,eAAO,MAAM,qBAAqB,4EAA0B,OAU3D,CAAC;AAEF,eAAO,MAAM,uBAAuB,4EAA0B,kBAU7D,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/hd-core",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
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.1
|
|
28
|
-
"@onekeyfe/hd-transport": "^0.1
|
|
27
|
+
"@onekeyfe/hd-shared": "^0.2.1",
|
|
28
|
+
"@onekeyfe/hd-transport": "^0.2.1",
|
|
29
29
|
"axios": "^0.27.2",
|
|
30
30
|
"bignumber.js": "^9.0.2",
|
|
31
31
|
"jszip": "^3.10.1",
|
|
@@ -40,5 +40,5 @@
|
|
|
40
40
|
"@types/parse-uri": "^1.0.0",
|
|
41
41
|
"@types/semver": "^7.3.9"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "2ed876d7027dd9c59a5d742648c2355cc595fd2f"
|
|
44
44
|
}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
supportInputPinOnSoftware,
|
|
4
|
+
supportModifyHomescreen,
|
|
5
|
+
} from '../../utils/deviceFeaturesUtils';
|
|
3
6
|
import { BaseMethod } from '../BaseMethod';
|
|
4
7
|
|
|
5
8
|
export default class DeviceSupportFeatures extends BaseMethod {
|
|
@@ -14,8 +17,10 @@ export default class DeviceSupportFeatures extends BaseMethod {
|
|
|
14
17
|
);
|
|
15
18
|
|
|
16
19
|
const inputPinOnSoftware = supportInputPinOnSoftware(this.device.features);
|
|
20
|
+
const modifyHomescreen = supportModifyHomescreen(this.device.features);
|
|
17
21
|
return Promise.resolve({
|
|
18
22
|
inputPinOnSoftware,
|
|
23
|
+
modifyHomescreen,
|
|
19
24
|
device: this.device.toMessageObject(),
|
|
20
25
|
});
|
|
21
26
|
}
|
|
@@ -6,6 +6,7 @@ import { DeviceUploadResourceParams } from '../../types';
|
|
|
6
6
|
import { BaseMethod } from '../BaseMethod';
|
|
7
7
|
import { validateParams } from '../helpers/paramsValidator';
|
|
8
8
|
import { hexToBytes } from '../helpers/hexUtils';
|
|
9
|
+
import { createUiMessage, UI_REQUEST } from '../../events';
|
|
9
10
|
|
|
10
11
|
export default class DeviceUploadResource extends BaseMethod<ResourceUpload> {
|
|
11
12
|
paramsData = {
|
|
@@ -99,6 +100,8 @@ export default class DeviceUploadResource extends BaseMethod<ResourceUpload> {
|
|
|
99
100
|
this.params
|
|
100
101
|
);
|
|
101
102
|
|
|
103
|
+
this.postMessage(createUiMessage(UI_REQUEST.CLOSE_UI_WINDOW));
|
|
104
|
+
|
|
102
105
|
return this.processResourceRequest(res);
|
|
103
106
|
}
|
|
104
107
|
}
|
package/src/core/index.ts
CHANGED
|
@@ -19,7 +19,7 @@ import { DeviceList } from '../device/DeviceList';
|
|
|
19
19
|
import { DevicePool } from '../device/DevicePool';
|
|
20
20
|
import { findMethod } from '../api/utils';
|
|
21
21
|
import { DataManager } from '../data-manager';
|
|
22
|
-
import { enableLog, getLogger, LoggerNames, setLoggerPostMessage } from '../utils';
|
|
22
|
+
import { enableLog, getLogger, LoggerNames, setLoggerPostMessage, wait } from '../utils';
|
|
23
23
|
import {
|
|
24
24
|
CoreMessage,
|
|
25
25
|
createResponseMessage,
|
|
@@ -387,6 +387,26 @@ function initDeviceForBle(method: BaseMethod) {
|
|
|
387
387
|
return device;
|
|
388
388
|
}
|
|
389
389
|
|
|
390
|
+
/**
|
|
391
|
+
* If the Bluetooth connection times out, retry 6 times
|
|
392
|
+
*/
|
|
393
|
+
let bleTimeoutRetry = 0;
|
|
394
|
+
async function connectDeviceForBle(method: BaseMethod, device: Device) {
|
|
395
|
+
try {
|
|
396
|
+
await device.acquire();
|
|
397
|
+
await device.initialize(parseInitOptions(method));
|
|
398
|
+
} catch (err) {
|
|
399
|
+
if (err.errorCode === HardwareErrorCode.BleTimeoutError && bleTimeoutRetry <= 5) {
|
|
400
|
+
bleTimeoutRetry += 1;
|
|
401
|
+
Log.debug(`Bletooth connect timeout and will retry, retry count: ${bleTimeoutRetry}`);
|
|
402
|
+
await wait(3000);
|
|
403
|
+
await connectDeviceForBle(method, device);
|
|
404
|
+
} else {
|
|
405
|
+
throw err;
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
|
|
390
410
|
type IPollFn<T> = (time?: number) => T;
|
|
391
411
|
// eslint-disable-next-line @typescript-eslint/require-await
|
|
392
412
|
const ensureConnected = async (method: BaseMethod, pollingId: number) => {
|
|
@@ -455,8 +475,8 @@ const ensureConnected = async (method: BaseMethod, pollingId: number) => {
|
|
|
455
475
|
* Bluetooth should call initialize here
|
|
456
476
|
*/
|
|
457
477
|
if (env === 'react-native') {
|
|
458
|
-
|
|
459
|
-
await
|
|
478
|
+
bleTimeoutRetry = 0;
|
|
479
|
+
await connectDeviceForBle(method, device);
|
|
460
480
|
}
|
|
461
481
|
resolve(device);
|
|
462
482
|
return;
|
|
@@ -470,6 +490,7 @@ const ensureConnected = async (method: BaseMethod, pollingId: number) => {
|
|
|
470
490
|
HardwareErrorCode.BleLocationServicesDisabled,
|
|
471
491
|
HardwareErrorCode.BleDeviceNotBonded,
|
|
472
492
|
HardwareErrorCode.BleCharacteristicNotifyError,
|
|
493
|
+
HardwareErrorCode.BleTimeoutError,
|
|
473
494
|
HardwareErrorCode.BleWriteCharacteristicError,
|
|
474
495
|
HardwareErrorCode.BleAlreadyConnected,
|
|
475
496
|
HardwareErrorCode.FirmwareUpdateLimitOneDevice,
|
package/src/types/device.ts
CHANGED
|
@@ -143,3 +143,15 @@ export const supportBatchPublicKey = (features?: Features): boolean => {
|
|
|
143
143
|
|
|
144
144
|
return semver.gte(currentVersion, '2.6.0');
|
|
145
145
|
};
|
|
146
|
+
|
|
147
|
+
export const supportModifyHomescreen = (features?: Features): SupportFeatureType => {
|
|
148
|
+
if (!features) return { support: false };
|
|
149
|
+
const currentVersion = getDeviceFirmwareVersion(features).join('.');
|
|
150
|
+
|
|
151
|
+
const deviceType = getDeviceType(features);
|
|
152
|
+
if (deviceType === 'classic' || deviceType === 'mini') {
|
|
153
|
+
return { support: true };
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
return { support: semver.gte(currentVersion, '3.4.0') };
|
|
157
|
+
};
|