@onekeyfe/hd-core 1.1.16-alpha.7 → 1.1.16
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/firmware/FirmwareUpdateBaseMethod.d.ts +2 -1
- package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts.map +1 -1
- package/dist/api/firmware/uploadFirmware.d.ts.map +1 -1
- package/dist/index.js +53 -10
- package/package.json +4 -4
- package/src/api/firmware/FirmwareUpdateBaseMethod.ts +28 -4
- package/src/api/firmware/uploadFirmware.ts +26 -4
|
@@ -4,6 +4,7 @@ import { RebootType } from '@onekeyfe/hd-transport';
|
|
|
4
4
|
import { IFirmwareUpdateTipMessage, IFirmwareUpdateProgressType } from '../../events/ui-request';
|
|
5
5
|
import { BaseMethod } from '../BaseMethod';
|
|
6
6
|
import { PROTO } from '../../constants';
|
|
7
|
+
import type { TypedResponseMessage } from '../../device/DeviceCommands';
|
|
7
8
|
export declare class FirmwareUpdateBaseMethod<Params> extends BaseMethod<Params> {
|
|
8
9
|
checkPromise: Deferred<any> | null;
|
|
9
10
|
init(): void;
|
|
@@ -25,7 +26,7 @@ export declare class FirmwareUpdateBaseMethod<Params> extends BaseMethod<Params>
|
|
|
25
26
|
processedSize?: number;
|
|
26
27
|
totalSize?: number;
|
|
27
28
|
}): Promise<number>;
|
|
28
|
-
emmcFileWriteWithRetry(filePath: string, chunkLength: number, offset: number, chunk: ArrayBuffer | Buffer, overwrite: boolean, progress: number | null): Promise<
|
|
29
|
+
emmcFileWriteWithRetry(filePath: string, chunkLength: number, offset: number, chunk: ArrayBuffer | Buffer, overwrite: boolean, progress: number | null): Promise<TypedResponseMessage<"EmmcFile"> | undefined>;
|
|
29
30
|
reboot(rebootType: RebootType): Promise<import("@onekeyfe/hd-transport").Success>;
|
|
30
31
|
}
|
|
31
32
|
//# sourceMappingURL=FirmwareUpdateBaseMethod.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FirmwareUpdateBaseMethod.d.ts","sourceRoot":"","sources":["../../../src/api/firmware/FirmwareUpdateBaseMethod.ts"],"names":[],"mappings":";AAAA,OAAO,EAEL,QAAQ,EAKT,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAGpD,OAAO,EAIL,yBAAyB,EACzB,2BAA2B,EAC5B,MAAM,yBAAyB,CAAC;AAMjC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"FirmwareUpdateBaseMethod.d.ts","sourceRoot":"","sources":["../../../src/api/firmware/FirmwareUpdateBaseMethod.ts"],"names":[],"mappings":";AAAA,OAAO,EAEL,QAAQ,EAKT,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAGpD,OAAO,EAIL,yBAAyB,EACzB,2BAA2B,EAC5B,MAAM,yBAAyB,CAAC;AAMjC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAexE,qBAAa,wBAAwB,CAAC,MAAM,CAAE,SAAQ,UAAU,CAAC,MAAM,CAAC;IACtE,YAAY,EAAE,QAAQ,CAAC,GAAG,CAAC,GAAG,IAAI,CAAQ;IAE1C,IAAI,IAAI,IAAI;IAEZ,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC;IAInB,cAAc,IAAI,OAAO;IASzB,cAAc,YAAa,yBAAyB,UASlD;IAMF,qBAAqB,SAAU,UAAU,GAAG,KAAK,GAAG,YAAY,GAAG,UAAU,UAM3E;IAMF,mBAAmB,aAAc,MAAM,gBAAgB,2BAA2B,UAQhF;YAEY,qCAAqC;IAkBnD,uBAAuB,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS;YAmFvC,4BAA4B;IAuBpC,mBAAmB;IA8CnB,uBAAuB,CAAC,EAAE,IAAI,EAAE,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE;IA6BlD,8BAA8B,CAAC,IAAI,EAAE,MAAM;IAW3C,uBAAuB,CAAC,EAC5B,OAAO,EACP,QAAQ,EACR,aAAa,EACb,SAAS,GACV,EAAE,KAAK,CAAC,cAAc,GAAG;QACxB,QAAQ,EAAE,MAAM,CAAC;QACjB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB;IA4CK,sBAAsB,CAC1B,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,WAAW,GAAG,MAAM,EAC3B,SAAS,EAAE,OAAO,EAClB,QAAQ,EAAE,MAAM,GAAG,IAAI;IAwEnB,MAAM,CAAC,UAAU,EAAE,UAAU;CAsBpC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uploadFirmware.d.ts","sourceRoot":"","sources":["../../../src/api/firmware/uploadFirmware.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAQjD,OAAO,EAEL,WAAW,EAIZ,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,SAAS,EAAwB,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"uploadFirmware.d.ts","sourceRoot":"","sources":["../../../src/api/firmware/uploadFirmware.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAQjD,OAAO,EAEL,WAAW,EAIZ,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,SAAS,EAAwB,MAAM,6BAA6B,CAAC;AAqEnF,eAAO,MAAM,cAAc,eAAsB,MAAM,kBAKtD,CAAC;AAEF,eAAO,MAAM,cAAc,eACb,UAAU,GAAG,KAAK,aACnB,SAAS,yBACG,WAAW,KAAK,IAAI,UACnC,MAAM;;sBAsFf,CAAC;AA+NF,eAAO,MAAM,cAAc,cACd,SAAS,YACV,MAAM,QACV,WAAW,mBACA,MAAM,IAAI,qBAc5B,CAAC;AAEF,eAAO,MAAM,eAAe,cACf,SAAS,yBACG,WAAW,KAAK,IAAI,UACnC,MAAM,UACN,WAAW,qBAwBpB,CAAC;AAEF,eAAO,MAAM,gBAAgB,cAChB,SAAS,yBACG,WAAW,KAAK,IAAI,UACnC,MAAM,UACN,WAAW,qBAUpB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -28608,8 +28608,14 @@ const getInfo = ({ features, updateType, targetVersion }) => {
|
|
|
28608
28608
|
|
|
28609
28609
|
const NEW_BOOT_UPRATE_FIRMWARE_VERSION = '2.4.5';
|
|
28610
28610
|
const SESSION_ERROR$1 = 'session not found';
|
|
28611
|
-
const FIRMWARE_UPDATE_CONFIRM = 'Firmware install confirmed';
|
|
28611
|
+
const FIRMWARE_UPDATE_CONFIRM$1 = 'Firmware install confirmed';
|
|
28612
28612
|
const Log$8 = getLogger(exports.LoggerNames.Method);
|
|
28613
|
+
const isDeviceDisconnectedError$1 = (error) => {
|
|
28614
|
+
const message = error instanceof Error ? error.message : String(error !== null && error !== void 0 ? error : '');
|
|
28615
|
+
return (message.includes('device was disconnected') ||
|
|
28616
|
+
message.includes('transferIn') ||
|
|
28617
|
+
message.includes('USBDevice'));
|
|
28618
|
+
};
|
|
28613
28619
|
const postConfirmationMessage = (device) => {
|
|
28614
28620
|
var _a;
|
|
28615
28621
|
if ((_a = device.features) === null || _a === void 0 ? void 0 : _a.firmware_present) {
|
|
@@ -28723,12 +28729,27 @@ const newTouchUpdateProcess = (updateType, postMessage, device, { payload }, reb
|
|
|
28723
28729
|
postProgressTip(device, 'ConfirmOnDevice', postMessage);
|
|
28724
28730
|
postProgressTip(device, 'InstallingFirmware', postMessage);
|
|
28725
28731
|
typedCall = device.getCommands().typedCall.bind(device.getCommands());
|
|
28726
|
-
|
|
28727
|
-
|
|
28728
|
-
|
|
28729
|
-
|
|
28732
|
+
let response;
|
|
28733
|
+
try {
|
|
28734
|
+
response = yield typedCall('FirmwareUpdateEmmc', 'Success', {
|
|
28735
|
+
path: filePath,
|
|
28736
|
+
reboot_on_success: rebootOnSuccess,
|
|
28737
|
+
});
|
|
28738
|
+
}
|
|
28739
|
+
catch (error) {
|
|
28740
|
+
if (isDeviceDisconnectedError$1(error)) {
|
|
28741
|
+
Log$8.log('Rebooting device');
|
|
28742
|
+
response = {
|
|
28743
|
+
type: 'Success',
|
|
28744
|
+
message: { message: FIRMWARE_UPDATE_CONFIRM$1 },
|
|
28745
|
+
};
|
|
28746
|
+
}
|
|
28747
|
+
else {
|
|
28748
|
+
throw error;
|
|
28749
|
+
}
|
|
28750
|
+
}
|
|
28730
28751
|
if (response.type === 'Success' &&
|
|
28731
|
-
((_a = response === null || response === void 0 ? void 0 : response.message) === null || _a === void 0 ? void 0 : _a.message) === FIRMWARE_UPDATE_CONFIRM) {
|
|
28752
|
+
((_a = response === null || response === void 0 ? void 0 : response.message) === null || _a === void 0 ? void 0 : _a.message) === FIRMWARE_UPDATE_CONFIRM$1) {
|
|
28732
28753
|
const timeout = 2 * 60 * 1000;
|
|
28733
28754
|
const startTime = Date.now();
|
|
28734
28755
|
const isBleReconnect = DataManager.isBleConnect(env);
|
|
@@ -28949,6 +28970,13 @@ class DeviceFullyUploadResource extends BaseMethod {
|
|
|
28949
28970
|
|
|
28950
28971
|
const Log$7 = getLogger(exports.LoggerNames.Method);
|
|
28951
28972
|
const SESSION_ERROR = 'session not found';
|
|
28973
|
+
const FIRMWARE_UPDATE_CONFIRM = 'Firmware install confirmed';
|
|
28974
|
+
const isDeviceDisconnectedError = (error) => {
|
|
28975
|
+
const message = error instanceof Error ? error.message : String(error !== null && error !== void 0 ? error : '');
|
|
28976
|
+
return (message.includes('device was disconnected') ||
|
|
28977
|
+
message.includes('transferIn') ||
|
|
28978
|
+
message.includes('USBDevice'));
|
|
28979
|
+
};
|
|
28952
28980
|
class FirmwareUpdateBaseMethod extends BaseMethod {
|
|
28953
28981
|
constructor() {
|
|
28954
28982
|
super(...arguments);
|
|
@@ -29118,10 +29146,25 @@ class FirmwareUpdateBaseMethod extends BaseMethod {
|
|
|
29118
29146
|
startEmmcFirmwareUpdate({ path }) {
|
|
29119
29147
|
return __awaiter(this, void 0, void 0, function* () {
|
|
29120
29148
|
const typedCall = this.device.getCommands().typedCall.bind(this.device.getCommands());
|
|
29121
|
-
|
|
29122
|
-
|
|
29123
|
-
|
|
29124
|
-
|
|
29149
|
+
let updaeteResponse;
|
|
29150
|
+
try {
|
|
29151
|
+
updaeteResponse = yield typedCall('FirmwareUpdateEmmc', 'Success', {
|
|
29152
|
+
path,
|
|
29153
|
+
reboot_on_success: true,
|
|
29154
|
+
});
|
|
29155
|
+
}
|
|
29156
|
+
catch (error) {
|
|
29157
|
+
if (isDeviceDisconnectedError(error)) {
|
|
29158
|
+
Log$7.log('Rebooting device');
|
|
29159
|
+
updaeteResponse = {
|
|
29160
|
+
type: 'Success',
|
|
29161
|
+
message: { message: FIRMWARE_UPDATE_CONFIRM },
|
|
29162
|
+
};
|
|
29163
|
+
}
|
|
29164
|
+
else {
|
|
29165
|
+
throw error;
|
|
29166
|
+
}
|
|
29167
|
+
}
|
|
29125
29168
|
if (updaeteResponse.type !== 'Success') {
|
|
29126
29169
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.FirmwareError, 'firmware update error');
|
|
29127
29170
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/hd-core",
|
|
3
|
-
"version": "1.1.16
|
|
3
|
+
"version": "1.1.16",
|
|
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.16
|
|
29
|
-
"@onekeyfe/hd-transport": "1.1.16
|
|
28
|
+
"@onekeyfe/hd-shared": "1.1.16",
|
|
29
|
+
"@onekeyfe/hd-transport": "1.1.16",
|
|
30
30
|
"axios": "1.12.2",
|
|
31
31
|
"bignumber.js": "^9.0.2",
|
|
32
32
|
"bytebuffer": "^5.0.1",
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"@types/web-bluetooth": "^0.0.21",
|
|
47
47
|
"ripple-keypairs": "^1.3.1"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "9c63b9bac888ffc9f14a05c6431a072bd65e41d2"
|
|
50
50
|
}
|
|
@@ -24,9 +24,20 @@ import { DataManager } from '../../data-manager';
|
|
|
24
24
|
import { BaseMethod } from '../BaseMethod';
|
|
25
25
|
import { DEVICE } from '../../events';
|
|
26
26
|
import { PROTO } from '../../constants';
|
|
27
|
+
import type { TypedResponseMessage } from '../../device/DeviceCommands';
|
|
27
28
|
|
|
28
29
|
const Log = getLogger(LoggerNames.Method);
|
|
29
30
|
const SESSION_ERROR = 'session not found';
|
|
31
|
+
const FIRMWARE_UPDATE_CONFIRM = 'Firmware install confirmed';
|
|
32
|
+
|
|
33
|
+
const isDeviceDisconnectedError = (error: unknown) => {
|
|
34
|
+
const message = error instanceof Error ? error.message : String(error ?? '');
|
|
35
|
+
return (
|
|
36
|
+
message.includes('device was disconnected') ||
|
|
37
|
+
message.includes('transferIn') ||
|
|
38
|
+
message.includes('USBDevice')
|
|
39
|
+
);
|
|
40
|
+
};
|
|
30
41
|
|
|
31
42
|
export class FirmwareUpdateBaseMethod<Params> extends BaseMethod<Params> {
|
|
32
43
|
checkPromise: Deferred<any> | null = null;
|
|
@@ -255,10 +266,23 @@ export class FirmwareUpdateBaseMethod<Params> extends BaseMethod<Params> {
|
|
|
255
266
|
*/
|
|
256
267
|
async startEmmcFirmwareUpdate({ path }: { path: string }) {
|
|
257
268
|
const typedCall = this.device.getCommands().typedCall.bind(this.device.getCommands());
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
269
|
+
let updaeteResponse: TypedResponseMessage<'Success'>;
|
|
270
|
+
try {
|
|
271
|
+
updaeteResponse = await typedCall('FirmwareUpdateEmmc', 'Success', {
|
|
272
|
+
path,
|
|
273
|
+
reboot_on_success: true,
|
|
274
|
+
});
|
|
275
|
+
} catch (error) {
|
|
276
|
+
if (isDeviceDisconnectedError(error)) {
|
|
277
|
+
Log.log('Rebooting device');
|
|
278
|
+
updaeteResponse = {
|
|
279
|
+
type: 'Success',
|
|
280
|
+
message: { message: FIRMWARE_UPDATE_CONFIRM },
|
|
281
|
+
};
|
|
282
|
+
} else {
|
|
283
|
+
throw error;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
262
286
|
if (updaeteResponse.type !== 'Success') {
|
|
263
287
|
throw ERRORS.TypedError(HardwareErrorCode.FirmwareError, 'firmware update error');
|
|
264
288
|
}
|
|
@@ -31,6 +31,15 @@ const FIRMWARE_UPDATE_CONFIRM = 'Firmware install confirmed';
|
|
|
31
31
|
|
|
32
32
|
const Log = getLogger(LoggerNames.Method);
|
|
33
33
|
|
|
34
|
+
const isDeviceDisconnectedError = (error: unknown) => {
|
|
35
|
+
const message = error instanceof Error ? error.message : String(error ?? '');
|
|
36
|
+
return (
|
|
37
|
+
message.includes('device was disconnected') ||
|
|
38
|
+
message.includes('transferIn') ||
|
|
39
|
+
message.includes('USBDevice')
|
|
40
|
+
);
|
|
41
|
+
};
|
|
42
|
+
|
|
34
43
|
const postConfirmationMessage = (device: Device) => {
|
|
35
44
|
// only if firmware is already installed. fresh device does not require button confirmation
|
|
36
45
|
if (device.features?.firmware_present) {
|
|
@@ -220,10 +229,23 @@ const newTouchUpdateProcess = async (
|
|
|
220
229
|
postProgressTip(device, 'InstallingFirmware', postMessage);
|
|
221
230
|
typedCall = device.getCommands().typedCall.bind(device.getCommands());
|
|
222
231
|
// Firmware Update
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
232
|
+
let response: TypedResponseMessage<'Success'>;
|
|
233
|
+
try {
|
|
234
|
+
response = await typedCall('FirmwareUpdateEmmc', 'Success', {
|
|
235
|
+
path: filePath,
|
|
236
|
+
reboot_on_success: rebootOnSuccess,
|
|
237
|
+
});
|
|
238
|
+
} catch (error) {
|
|
239
|
+
if (isDeviceDisconnectedError(error)) {
|
|
240
|
+
Log.log('Rebooting device');
|
|
241
|
+
response = {
|
|
242
|
+
type: 'Success',
|
|
243
|
+
message: { message: FIRMWARE_UPDATE_CONFIRM },
|
|
244
|
+
} as TypedResponseMessage<'Success'>;
|
|
245
|
+
} else {
|
|
246
|
+
throw error;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
227
249
|
|
|
228
250
|
if (
|
|
229
251
|
response.type === 'Success' &&
|