@onekeyfe/hd-core 1.1.19-alpha.1 → 1.1.19-alpha.2

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.
@@ -1 +1 @@
1
- {"version":3,"file":"FirmwareUpdate.d.ts","sourceRoot":"","sources":["../../src/api/FirmwareUpdate.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAW1C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAEpD,KAAK,MAAM,GAAG;IACZ,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,UAAU,EAAE,UAAU,GAAG,KAAK,CAAC;CAChC,CAAC;AAIF,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,UAAU,CAAC,MAAM,CAAC;IAC5D,YAAY,EAAE,QAAQ,CAAC,GAAG,CAAC,GAAG,IAAI,CAAQ;IAE1C,IAAI;IAgCJ,cAAc,YAAa,MAAM,UAS/B;IAEF,uBAAuB,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS;IAsD/C,GAAG;CAuFV"}
1
+ {"version":3,"file":"FirmwareUpdate.d.ts","sourceRoot":"","sources":["../../src/api/FirmwareUpdate.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAW1C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAEpD,KAAK,MAAM,GAAG;IACZ,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,UAAU,EAAE,UAAU,GAAG,KAAK,CAAC;CAChC,CAAC;AAIF,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,UAAU,CAAC,MAAM,CAAC;IAC5D,YAAY,EAAE,QAAQ,CAAC,GAAG,CAAC,GAAG,IAAI,CAAQ;IA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ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,QAAQ,EAEb,KAAK,aAAa,EAKnB,MAAM,qBAAqB,CAAC;AAI7B,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAmB1C,OAAO,KAAK,EAAE,QAAQ,EAAe,MAAM,UAAU,CAAC;AAGtD,KAAK,MAAM,GAAG;IACZ,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,UAAU,EAAE,UAAU,GAAG,KAAK,CAAC;IAC/B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,YAAY,CAAC,EAAE,aAAa,CAAC;CAC9B,CAAC;AAIF,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,UAAU,CAAC,MAAM,CAAC;IAC9D,YAAY,EAAE,QAAQ,CAAC,GAAG,CAAC,GAAG,IAAI,CAAQ;IAE1C,IAAI;IA6CJ,cAAc,YAAa,MAAM,UAS/B;YAEY,qCAAqC;IAkBnD,uBAAuB,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS;YAqFvC,4BAA4B;IAuB1C,qBAAqB,CAAC,QAAQ,EAAE,QAAQ;IAUxC,uBAAuB,CAAC,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM;IAc9D,gCAAgC,CAAC,QAAQ,EAAE,QAAQ,GAAG,SAAS,EAAE,YAAY,EAAE,aAAa;IAwBtF,GAAG;CAiIV"}
@@ -1,9 +1,9 @@
1
1
  /// <reference types="node" />
2
- import { Deferred } from '@onekeyfe/hd-shared';
3
- import { RebootType } from '@onekeyfe/hd-transport';
4
- import { IFirmwareUpdateTipMessage, IFirmwareUpdateProgressType } from '../../events/ui-request';
5
2
  import { BaseMethod } from '../BaseMethod';
6
- import { PROTO } from '../../constants';
3
+ import type { IFirmwareUpdateProgressType, IFirmwareUpdateTipMessage } from '../../events/ui-request';
4
+ import type { PROTO } from '../../constants';
5
+ import type { RebootType } from '@onekeyfe/hd-transport';
6
+ import type { Deferred } from '@onekeyfe/hd-shared';
7
7
  import type { TypedResponseMessage } from '../../device/DeviceCommands';
8
8
  export declare class FirmwareUpdateBaseMethod<Params> extends BaseMethod<Params> {
9
9
  checkPromise: Deferred<any> | null;
@@ -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;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,8BA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G,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,4 +1,4 @@
1
- import { Features, IVersionArray } from '../../types';
1
+ import type { Features, IVersionArray } from '../../types';
2
2
  export declare function shouldUpdateBootloaderForClassicAndMini({ currentVersion, bootloaderVersion, willUpdateFirmware, targetBootloaderVersion, bootloaderRelatedFirmwareVersion, }: {
3
3
  currentVersion: string;
4
4
  bootloaderVersion: string;
@@ -1 +1 @@
1
- {"version":3,"file":"bootloaderHelper.d.ts","sourceRoot":"","sources":["../../../src/api/firmware/bootloaderHelper.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAGtD,wBAAgB,uCAAuC,CAAC,EACtD,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAClB,uBAAuB,EACvB,gCAAgC,GACjC,EAAE;IACD,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,uBAAuB,CAAC,EAAE,aAAa,CAAC;IACxC,gCAAgC,EAAE,aAAa,CAAC;CACjD,WAgBA;AAED,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,WAQ3E"}
1
+ {"version":3,"file":"bootloaderHelper.d.ts","sourceRoot":"","sources":["../../../src/api/firmware/bootloaderHelper.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE3D,wBAAgB,uCAAuC,CAAC,EACtD,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAClB,uBAAuB,EACvB,gCAAgC,GACjC,EAAE;IACD,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,uBAAuB,CAAC,EAAE,aAAa,CAAC;IACxC,gCAAgC,EAAE,aAAa,CAAC;CACjD,WAgBA;AAED,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,WAQ3E"}
@@ -1,5 +1,5 @@
1
+ import type { Features } from '../../types';
1
2
  import type { EFirmwareType } from '@onekeyfe/hd-shared';
2
- import { Features } from '../../types';
3
3
  export declare function checkNeedUpdateBootForTouch(features: Features, firmwareType: EFirmwareType): boolean;
4
4
  export declare function checkNeedUpdateBootForClassicAndMini({ features, willUpdateFirmware, firmwareType, }: {
5
5
  features: Features;
@@ -1 +1 @@
1
- {"version":3,"file":"updateBootloader.d.ts","sourceRoot":"","sources":["../../../src/api/firmware/updateBootloader.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAsB,QAAQ,EAAE,MAAM,aAAa,CAAC;AAK3D,wBAAgB,2BAA2B,CAAC,QAAQ,EAAE,QAAQ,EAAE,YAAY,EAAE,aAAa,WAgB1F;AAED,wBAAgB,oCAAoC,CAAC,EACnD,QAAQ,EACR,kBAAkB,EAClB,YAAY,GACb,EAAE;IACD,QAAQ,EAAE,QAAQ,CAAC;IACnB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,YAAY,EAAE,aAAa,CAAC;CAC7B,WAwBA;AAGD,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,WAAW,WAiBtD"}
1
+ {"version":3,"file":"updateBootloader.d.ts","sourceRoot":"","sources":["../../../src/api/firmware/updateBootloader.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,wBAAgB,2BAA2B,CAAC,QAAQ,EAAE,QAAQ,EAAE,YAAY,EAAE,aAAa,WAgB1F;AAED,wBAAgB,oCAAoC,CAAC,EACnD,QAAQ,EACR,kBAAkB,EAClB,YAAY,GACb,EAAE;IACD,QAAQ,EAAE,QAAQ,CAAC;IACnB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,YAAY,EAAE,aAAa,CAAC;CAC7B,WAwBA;AAGD,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,WAAW,WAiBtD"}
@@ -6,7 +6,7 @@ import type { Device } from '../../device/Device';
6
6
  export declare const waitBleInstall: (updateType: string) => Promise<void>;
7
7
  export declare const uploadFirmware: (updateType: 'firmware' | 'ble', typedCall: TypedCall, postMessage: (message: CoreMessage) => void, device: Device, { payload, rebootOnSuccess, }: import("@onekeyfe/hd-transport").FirmwareUpload & {
8
8
  rebootOnSuccess?: boolean | undefined;
9
- }) => Promise<Success>;
9
+ }, isUpdateBootloader?: boolean) => Promise<Success>;
10
10
  export declare const updateResource: (typedCall: TypedCall, fileName: string, data: ArrayBuffer, onConfirmAfter?: () => void) => Promise<Success>;
11
11
  export declare const updateResources: (typedCall: TypedCall, postMessage: (message: CoreMessage) => void, device: Device, source: ArrayBuffer) => Promise<boolean>;
12
12
  export declare const updateBootloader: (typedCall: TypedCall, postMessage: (message: CoreMessage) => void, device: Device, source: ArrayBuffer) => Promise<boolean>;
@@ -1 +1 @@
1
- {"version":3,"file":"uploadFirmware.d.ts","sourceRoot":"","sources":["../../../src/api/firmware/uploadFirmware.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,SAAS,EAAwB,MAAM,6BAA6B,CAAC;AACnF,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,KAAK,EAAE,WAAW,EAA+B,MAAM,cAAc,CAAC;AAC7E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAiElD,eAAO,MAAM,cAAc,eAAsB,MAAM,kBAKtD,CAAC;AAEF,eAAO,MAAM,cAAc,eACb,UAAU,GAAG,KAAK,aACnB,SAAS,yBACG,WAAW,KAAK,IAAI,UACnC,MAAM;;sBA4Hf,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"}
1
+ {"version":3,"file":"uploadFirmware.d.ts","sourceRoot":"","sources":["../../../src/api/firmware/uploadFirmware.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,SAAS,EAAwB,MAAM,6BAA6B,CAAC;AACnF,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,KAAK,EAAE,WAAW,EAA+B,MAAM,cAAc,CAAC;AAC7E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAiElD,eAAO,MAAM,cAAc,eAAsB,MAAM,kBAKtD,CAAC;AAEF,eAAO,MAAM,cAAc,eACb,UAAU,GAAG,KAAK,aACnB,SAAS,yBACG,WAAW,KAAK,IAAI,UACnC,MAAM;;wBAOO,OAAO,qBAkJ7B,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"}
@@ -1,10 +1,10 @@
1
1
  /// <reference types="node" />
2
2
  import EventEmitter from 'events';
3
- import { LowlevelTransportSharedPlugin } from '@onekeyfe/hd-transport';
4
3
  import { Device } from '../device/Device';
5
- import { CoreMessage } from '../events';
6
- import type { ConnectSettings } from '../types';
7
4
  import DeviceConnector from '../device/DeviceConnector';
5
+ import type { ConnectSettings } from '../types';
6
+ import type { CoreMessage } from '../events';
7
+ import type { LowlevelTransportSharedPlugin } from '@onekeyfe/hd-transport';
8
8
  export type CoreContext = ReturnType<Core['getCoreContext']>;
9
9
  export declare const callAPI: (context: CoreContext, message: CoreMessage) => Promise<any>;
10
10
  export declare const cancel: (context: CoreContext, connectId?: string) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":";AACA,OAAO,YAAY,MAAM,QAAQ,CAAC;AAClC,OA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,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;AAKhC,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC;AA8D7D,eAAO,MAAM,OAAO,YAAmB,WAAW,WAAW,WAAW,iBAuEvE,CAAC;AA8oBF,eAAO,MAAM,MAAM,YAAa,WAAW,cAAc,MAAM,SAkF9D,CAAC;AAsEF,eAAO,MAAM,qBAAqB,gFAejC,CAAC;AAyFF,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;IA0DxC,OAAO;CAMR;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"}
@@ -1,6 +1,6 @@
1
- import type { Transport, Messages } from '@onekeyfe/hd-transport';
2
- import type { Device } from './Device';
3
1
  import { type PassphraseRequestPayload } from '../events';
2
+ import type { Device } from './Device';
3
+ import type { Messages, Transport } from '@onekeyfe/hd-transport';
4
4
  export type PassphrasePromptResponse = {
5
5
  passphrase?: string;
6
6
  passphraseOnDevice?: boolean;
@@ -31,7 +31,7 @@ export declare const cancelDeviceInPrompt: (device: Device, expectResponse?: boo
31
31
  };
32
32
  } | {
33
33
  success: boolean;
34
- error: 0 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 200 | 300 | 301 | 302 | 303 | 304 | 305 | 400 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 500 | 600 | 601 | 602 | 603 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 900 | 901 | 902;
34
+ error: 0 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 200 | 300 | 301 | 302 | 303 | 304 | 305 | 400 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 500 | 600 | 601 | 602 | 603 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 823 | 900 | 901 | 902;
35
35
  payload: {
36
36
  message: string;
37
37
  };
@@ -50,7 +50,7 @@ export declare const cancelDeviceWithInitialize: (device: Device) => Promise<{
50
50
  };
51
51
  } | {
52
52
  success: boolean;
53
- error: 0 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 200 | 300 | 301 | 302 | 303 | 304 | 305 | 400 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 500 | 600 | 601 | 602 | 603 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 900 | 901 | 902;
53
+ error: 0 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 200 | 300 | 301 | 302 | 303 | 304 | 305 | 400 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 500 | 600 | 601 | 602 | 603 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 823 | 900 | 901 | 902;
54
54
  payload: {
55
55
  message: string;
56
56
  };
@@ -80,7 +80,7 @@ export declare class DeviceCommands {
80
80
  };
81
81
  } | {
82
82
  success: boolean;
83
- error: 0 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 200 | 300 | 301 | 302 | 303 | 304 | 305 | 400 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 500 | 600 | 601 | 602 | 603 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 900 | 901 | 902;
83
+ error: 0 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 200 | 300 | 301 | 302 | 303 | 304 | 305 | 400 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 500 | 600 | 601 | 602 | 603 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 823 | 900 | 901 | 902;
84
84
  payload: {
85
85
  message: string;
86
86
  };
@@ -99,7 +99,7 @@ export declare class DeviceCommands {
99
99
  };
100
100
  } | {
101
101
  success: boolean;
102
- error: 0 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 200 | 300 | 301 | 302 | 303 | 304 | 305 | 400 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 500 | 600 | 601 | 602 | 603 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 900 | 901 | 902;
102
+ error: 0 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 200 | 300 | 301 | 302 | 303 | 304 | 305 | 400 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 500 | 600 | 601 | 602 | 603 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 823 | 900 | 901 | 902;
103
103
  payload: {
104
104
  message: string;
105
105
  };
@@ -1 +1 @@
1
- {"version":3,"file":"DeviceCommands.d.ts","sourceRoot":"","sources":["../../src/device/DeviceCommands.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAe,MAAM,wBAAwB,CAAC;AAK/E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAU,KAAK,wBAAwB,EAAE,MAAM,WAAW,CAAC;AAQlE,MAAM,MAAM,wBAAwB,GAAG;IACrC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,KAAK,WAAW,GAAG,QAAQ,CAAC,WAAW,CAAC;AACxC,KAAK,UAAU,GAAG,MAAM,WAAW,CAAC;AACpC,MAAM,MAAM,oBAAoB,CAAC,CAAC,SAAS,UAAU,IAAI;IACvD,IAAI,EAAE,CAAC,CAAC;IACR,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;CACzB,CAAC;AACF,KAAK,oBAAoB,GA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AW,CAAC,IAAI,EAAE,UAAU,EAAE,GAAG,CAAC,EAAE,sBAAsB,CAAC,SAAS,CAAC;IAK3E,kBAAkB,CAChB,GAAG,EAAE,sBAAsB,EAC3B,QAAQ,EAAE,UAAU,GACnB,OAAO,CAAC,sBAAsB,CAAC;IAsJlC,UAAU,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,oBAAoB;IA8D/C,iBAAiB,CAAC,OAAO,EAAE,wBAAwB;CAiDpD;AAED,MAAM,MAAM,SAAS,GAAG,cAAc,CAAC,WAAW,CAAC,CAAC"}
package/dist/index.d.ts CHANGED
@@ -2955,7 +2955,7 @@ declare class DeviceCommands {
2955
2955
  };
2956
2956
  } | {
2957
2957
  success: boolean;
2958
- error: 0 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 200 | 300 | 301 | 302 | 303 | 304 | 305 | 400 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 500 | 600 | 601 | 602 | 603 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 900 | 901 | 902;
2958
+ error: 0 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 200 | 300 | 301 | 302 | 303 | 304 | 305 | 400 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 500 | 600 | 601 | 602 | 603 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 823 | 900 | 901 | 902;
2959
2959
  payload: {
2960
2960
  message: string;
2961
2961
  };
@@ -2974,7 +2974,7 @@ declare class DeviceCommands {
2974
2974
  };
2975
2975
  } | {
2976
2976
  success: boolean;
2977
- error: 0 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 200 | 300 | 301 | 302 | 303 | 304 | 305 | 400 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 500 | 600 | 601 | 602 | 603 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 900 | 901 | 902;
2977
+ error: 0 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 200 | 300 | 301 | 302 | 303 | 304 | 305 | 400 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 500 | 600 | 601 | 602 | 603 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 823 | 900 | 901 | 902;
2978
2978
  payload: {
2979
2979
  message: string;
2980
2980
  };
package/dist/index.js CHANGED
@@ -26749,7 +26749,12 @@ class DeviceCommands {
26749
26749
  const promise = this.transport.call(this.mainId, type, msg);
26750
26750
  this.callPromise = promise;
26751
26751
  const res = yield promise;
26752
- LogCore.debug('[DeviceCommands] [call] Received', res.type);
26752
+ if (res.type === 'Failure') {
26753
+ LogCore.debug('[DeviceCommands] [call] Received', res.type, res.message);
26754
+ }
26755
+ else {
26756
+ LogCore.debug('[DeviceCommands] [call] Received', res.type);
26757
+ }
26753
26758
  return res;
26754
26759
  }
26755
26760
  catch (error) {
@@ -26885,12 +26890,15 @@ class DeviceCommands {
26885
26890
  (message === null || message === void 0 ? void 0 : message.includes('verify failed'))) {
26886
26891
  error = hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.FirmwareVerificationFailed, message);
26887
26892
  }
26893
+ else if (message === null || message === void 0 ? void 0 : message.includes('Firmware downgrade not allowed')) {
26894
+ error = hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.FirmwareDowngradeNotAllowed, message);
26895
+ }
26888
26896
  }
26889
26897
  if (code === 'Failure_UnexpectedMessage') {
26890
26898
  if (callType === 'PassphraseAck') {
26891
26899
  error = hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.UnexpectPassphrase);
26892
26900
  }
26893
- if (message === 'Not in Signing mode') {
26901
+ else if (message === 'Not in Signing mode') {
26894
26902
  error = hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.NotInSigningMode);
26895
26903
  }
26896
26904
  }
@@ -28905,33 +28913,48 @@ const waitBleInstall = (updateType) => __awaiter(void 0, void 0, void 0, functio
28905
28913
  yield wait(10 * 1000);
28906
28914
  }
28907
28915
  });
28908
- const uploadFirmware = (updateType, typedCall, postMessage, device, { payload, rebootOnSuccess, }) => __awaiter(void 0, void 0, void 0, function* () {
28916
+ const uploadFirmware = (updateType, typedCall, postMessage, device, { payload, rebootOnSuccess, }, isUpdateBootloader) => __awaiter(void 0, void 0, void 0, function* () {
28909
28917
  var _a, _b;
28910
28918
  const deviceType = getDeviceType(device.features);
28911
28919
  if (DeviceModelToTypes.model_mini.includes(deviceType)) {
28912
28920
  postConfirmationMessage(device);
28913
28921
  postProgressTip(device, 'ConfirmOnDevice', postMessage);
28914
28922
  const isFirmware = updateType === 'firmware';
28915
- const deviceBootloaderVersion = getDeviceBootloaderVersion(device.features).join('.');
28916
- const supportUpgradeFileHeader = semver__default["default"].gt(deviceBootloaderVersion, '2.1.0');
28917
- Log$8.debug('supportUpgradeFileHeader:', supportUpgradeFileHeader, 'deviceBootloaderVersion:', deviceBootloaderVersion);
28918
- if (isFirmware && supportUpgradeFileHeader) {
28919
- const HEADER_SIZE = 1024;
28920
- if (payload.byteLength < HEADER_SIZE) {
28921
- throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, `firmware payload too small: ${payload.byteLength} bytes, expected at least ${HEADER_SIZE} bytes`);
28922
- }
28923
- Log$8.debug('Uploading firmware header:', { size: HEADER_SIZE, totalSize: payload.byteLength });
28924
- postProgressTip(device, 'UploadingFirmwareHeader', postMessage);
28925
- const header = new Uint8Array(payload.slice(0, HEADER_SIZE));
28926
- const headerRes = (yield typedCall('UpgradeFileHeader', 'Success', {
28927
- data: bytesToHex(header),
28928
- }));
28929
- const isUnexpectedMessage = (_b = (_a = headerRes.message) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.includes('Failure_UnexpectedMessage');
28930
- if (headerRes.type !== 'Success' && !isUnexpectedMessage) {
28931
- Log$8.error('Firmware header upload failed:', headerRes);
28932
- throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'failed to upload firmware header');
28923
+ if (isFirmware && !isUpdateBootloader) {
28924
+ const newFeatures = yield typedCall('GetFeatures', 'Features', {});
28925
+ const deviceBootloaderVersion = getDeviceBootloaderVersion(newFeatures.message).join('.');
28926
+ const supportUpgradeFileHeader = semver__default["default"].gte(deviceBootloaderVersion, '2.1.0');
28927
+ Log$8.debug('supportUpgradeFileHeader:', supportUpgradeFileHeader);
28928
+ if (supportUpgradeFileHeader) {
28929
+ const HEADER_SIZE = 1024;
28930
+ if (payload.byteLength < HEADER_SIZE) {
28931
+ throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, `firmware payload too small: ${payload.byteLength} bytes, expected at least ${HEADER_SIZE} bytes`);
28932
+ }
28933
+ Log$8.debug('Uploading firmware header:', {
28934
+ size: HEADER_SIZE,
28935
+ totalSize: payload.byteLength,
28936
+ });
28937
+ postProgressTip(device, 'UploadingFirmwareHeader', postMessage);
28938
+ const header = new Uint8Array(payload.slice(0, HEADER_SIZE));
28939
+ try {
28940
+ const headerRes = yield typedCall('UpgradeFileHeader', 'Success', {
28941
+ data: bytesToHex(header),
28942
+ });
28943
+ const isUnknownMessage = (_b = (_a = headerRes.message) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.includes('Failure_UnknownMessage');
28944
+ if (headerRes.type !== 'Success' && !isUnknownMessage) {
28945
+ Log$8.error('Firmware header upload failed:', headerRes);
28946
+ throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'failed to upload firmware header');
28947
+ }
28948
+ }
28949
+ catch (error) {
28950
+ Log$8.error('Firmware header upload failed:', error);
28951
+ const message = error instanceof Error ? error.message : String(error !== null && error !== void 0 ? error : '');
28952
+ if (!message.includes('Failure_UnknownMessage')) {
28953
+ throw error;
28954
+ }
28955
+ }
28956
+ Log$8.debug('Firmware header uploaded successfully');
28933
28957
  }
28934
- Log$8.debug('Firmware header uploaded successfully, isUnexpectedMessage:', isUnexpectedMessage);
28935
28958
  }
28936
28959
  const eraseCommand = isFirmware ? 'FirmwareErase' : 'FirmwareErase_ex';
28937
28960
  const eraseRes = yield typedCall(eraseCommand, 'Success', {});
@@ -28940,15 +28963,30 @@ const uploadFirmware = (updateType, typedCall, postMessage, device, { payload, r
28940
28963
  }
28941
28964
  postProgressTip(device, 'FirmwareEraseSuccess', postMessage);
28942
28965
  postProgressMessage(device, 0, 'installingFirmware', postMessage);
28943
- const { message, type } = yield typedCall('FirmwareUpload', 'Success', {
28944
- payload,
28945
- });
28966
+ let updateResponse;
28967
+ try {
28968
+ updateResponse = yield typedCall('FirmwareUpload', 'Success', {
28969
+ payload,
28970
+ });
28971
+ }
28972
+ catch (error) {
28973
+ if (isDeviceDisconnectedError$1(error)) {
28974
+ Log$8.log('Rebooting device');
28975
+ updateResponse = {
28976
+ type: 'Success',
28977
+ message: { message: FIRMWARE_UPDATE_CONFIRM$1 },
28978
+ };
28979
+ }
28980
+ else {
28981
+ throw error;
28982
+ }
28983
+ }
28946
28984
  postProgressMessage(device, 100, 'installingFirmware', postMessage);
28947
28985
  yield waitBleInstall(updateType);
28948
- if (type !== 'Success') {
28986
+ if (updateResponse.type !== 'Success') {
28949
28987
  throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'install firmware error');
28950
28988
  }
28951
- return message;
28989
+ return updateResponse.message;
28952
28990
  }
28953
28991
  if (DeviceModelToTypes.model_touch.includes(deviceType)) {
28954
28992
  if (device.features) {
@@ -29431,9 +29469,9 @@ class FirmwareUpdateBaseMethod extends BaseMethod {
29431
29469
  startEmmcFirmwareUpdate({ path }) {
29432
29470
  return __awaiter(this, void 0, void 0, function* () {
29433
29471
  const typedCall = this.device.getCommands().typedCall.bind(this.device.getCommands());
29434
- let updaeteResponse;
29472
+ let updateResponse;
29435
29473
  try {
29436
- updaeteResponse = yield typedCall('FirmwareUpdateEmmc', 'Success', {
29474
+ updateResponse = yield typedCall('FirmwareUpdateEmmc', 'Success', {
29437
29475
  path,
29438
29476
  reboot_on_success: true,
29439
29477
  });
@@ -29441,7 +29479,7 @@ class FirmwareUpdateBaseMethod extends BaseMethod {
29441
29479
  catch (error) {
29442
29480
  if (isDeviceDisconnectedError(error)) {
29443
29481
  Log$7.log('Rebooting device');
29444
- updaeteResponse = {
29482
+ updateResponse = {
29445
29483
  type: 'Success',
29446
29484
  message: { message: FIRMWARE_UPDATE_CONFIRM },
29447
29485
  };
@@ -29450,7 +29488,7 @@ class FirmwareUpdateBaseMethod extends BaseMethod {
29450
29488
  throw error;
29451
29489
  }
29452
29490
  }
29453
- if (updaeteResponse.type !== 'Success') {
29491
+ if (updateResponse.type !== 'Success') {
29454
29492
  throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.FirmwareError, 'firmware update error');
29455
29493
  }
29456
29494
  this.postTipMessage(exports.FirmwareUpdateTipMessage.FirmwareUpdating);
@@ -29842,7 +29880,7 @@ class FirmwareUpdate extends BaseMethod {
29842
29880
  throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.FirmwareUpdateDownloadFailed, (_b = err.message) !== null && _b !== void 0 ? _b : err);
29843
29881
  }
29844
29882
  yield this.device.acquire();
29845
- const response = yield uploadFirmware(params.updateType, this.device.getCommands().typedCall.bind(this.device.getCommands()), this.postMessage, device, { payload: binary, rebootOnSuccess: this.payload.rebootOnSuccess });
29883
+ const response = yield uploadFirmware(params.updateType, this.device.getCommands().typedCall.bind(this.device.getCommands()), this.postMessage, device, { payload: binary, rebootOnSuccess: this.payload.rebootOnSuccess }, false);
29846
29884
  if (this.connectId) {
29847
29885
  DevicePool.clearDeviceCache(this.connectId);
29848
29886
  }
@@ -30114,7 +30152,7 @@ class FirmwareUpdateV2 extends BaseMethod {
30114
30152
  }
30115
30153
  (_j = (_h = this.device) === null || _h === void 0 ? void 0 : _h.commands) === null || _j === void 0 ? void 0 : _j.checkDisposed();
30116
30154
  yield this.device.acquire();
30117
- const response = yield uploadFirmware(params.updateType, this.device.getCommands().typedCall.bind(this.device.getCommands()), this.postMessage, device, { payload: binary, rebootOnSuccess: true });
30155
+ const response = yield uploadFirmware(params.updateType, this.device.getCommands().typedCall.bind(this.device.getCommands()), this.postMessage, device, { payload: binary, rebootOnSuccess: true }, params.isUpdateBootloader);
30118
30156
  if (this.connectId) {
30119
30157
  DevicePool.clearDeviceCache(this.connectId);
30120
30158
  }
@@ -39854,7 +39892,9 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
39854
39892
  pinListeners: device.listenerCount(DEVICE.PIN),
39855
39893
  });
39856
39894
  }
39857
- removeDeviceListener(device);
39895
+ else {
39896
+ removeDeviceListener(device);
39897
+ }
39858
39898
  }
39859
39899
  }
39860
39900
  });
@@ -40238,6 +40278,9 @@ const onSelectDeviceInBootloaderForWebDeviceHandler = (...[device, callback]) =>
40238
40278
  callback(null, uiResp.payload.deviceId);
40239
40279
  });
40240
40280
  const postMessage = (message) => {
40281
+ if (!_core) {
40282
+ return;
40283
+ }
40241
40284
  _core.emit(CORE_EVENT, message);
40242
40285
  };
40243
40286
  const createUiPromise = (promiseEvent, device) => {
@@ -1,4 +1,4 @@
1
- import { CoreMessage } from '../events';
1
+ import type { CoreMessage } from '../events';
2
2
  type LogMessage = {
3
3
  level: string;
4
4
  prefix: string;
@@ -1 +1 @@
1
- {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAGxC,KAAK,UAAU,GAAG;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,GAAG,EAAE,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAMF,cAAM,GAAG;IACP,MAAM,EAAE,MAAM,CAAC;IAEf,OAAO,EAAE,OAAO,CAAC;IAEjB,QAAQ,EAAE,UAAU,EAAE,CAAC;gBAEX,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO;IAM5C,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE;IAYxD,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE;IASlB,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG,E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,iBAAiB,CAW3D;AAQD,wBAAgB,oBAAoB,CAClC,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE;IACR,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B,GACA,cAAc,CAyBhB;AAKD,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,IAAI,CAK/F;AAKD,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI,CAuB9E;AAOD,wBAAgB,iCAAiC,CAAC,gBAAgB,EAAE,MAAM,GAAG,cAAc,EAAE,CAI5F;AAOD,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,cAAc,GAAG,MAAM,CAmBpE;AAOD,wBAAgB,kBAAkB,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,CAW9D"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/hd-core",
3
- "version": "1.1.19-alpha.1",
3
+ "version": "1.1.19-alpha.2",
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.19-alpha.1",
29
- "@onekeyfe/hd-transport": "1.1.19-alpha.1",
28
+ "@onekeyfe/hd-shared": "1.1.19-alpha.2",
29
+ "@onekeyfe/hd-transport": "1.1.19-alpha.2",
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": "cc93ea24ebfc9b4c3c0d71fd53bcfa3c2c304153"
49
+ "gitHead": "fb0244c624d5546c09262f366ef090f5fa906d03"
50
50
  }
@@ -206,7 +206,8 @@ export default class FirmwareUpdate extends BaseMethod<Params> {
206
206
  this.device.getCommands().typedCall.bind(this.device.getCommands()),
207
207
  this.postMessage,
208
208
  device,
209
- { payload: binary, rebootOnSuccess: this.payload.rebootOnSuccess }
209
+ { payload: binary, rebootOnSuccess: this.payload.rebootOnSuccess },
210
+ false
210
211
  );
211
212
 
212
213
  if (this.connectId) {
@@ -395,7 +395,8 @@ export default class FirmwareUpdateV2 extends BaseMethod<Params> {
395
395
  this.device.getCommands().typedCall.bind(this.device.getCommands()),
396
396
  this.postMessage,
397
397
  device,
398
- { payload: binary, rebootOnSuccess: true }
398
+ { payload: binary, rebootOnSuccess: true },
399
+ params.isUpdateBootloader
399
400
  );
400
401
 
401
402
  if (this.connectId) {
@@ -1,29 +1,27 @@
1
1
  import {
2
- createDeferred,
3
- Deferred,
4
2
  EDeviceType,
5
3
  ERRORS,
6
4
  HardwareError,
7
5
  HardwareErrorCode,
6
+ createDeferred,
8
7
  } from '@onekeyfe/hd-shared';
9
- import { RebootType } from '@onekeyfe/hd-transport';
10
- import type { KnownDevice } from '../../types';
11
8
 
12
- import {
13
- UI_REQUEST,
14
- createUiMessage,
15
- FirmwareUpdateTipMessage,
16
- IFirmwareUpdateTipMessage,
17
- IFirmwareUpdateProgressType,
18
- } from '../../events/ui-request';
9
+ import { FirmwareUpdateTipMessage, UI_REQUEST, createUiMessage } from '../../events/ui-request';
19
10
  import { DevicePool } from '../../device/DevicePool';
20
- import { getDeviceType, wait, getLogger, LoggerNames, getDeviceUUID } from '../../utils';
11
+ import { LoggerNames, getDeviceType, getDeviceUUID, getLogger, wait } from '../../utils';
21
12
  import { DeviceModelToTypes } from '../../types';
22
13
  import { DataManager } from '../../data-manager';
23
-
24
14
  import { BaseMethod } from '../BaseMethod';
25
15
  import { DEVICE } from '../../events';
26
- import { PROTO } from '../../constants';
16
+
17
+ import type {
18
+ IFirmwareUpdateProgressType,
19
+ IFirmwareUpdateTipMessage,
20
+ } from '../../events/ui-request';
21
+ import type { PROTO } from '../../constants';
22
+ import type { RebootType } from '@onekeyfe/hd-transport';
23
+ import type { Deferred } from '@onekeyfe/hd-shared';
24
+ import type { KnownDevice } from '../../types';
27
25
  import type { TypedResponseMessage } from '../../device/DeviceCommands';
28
26
 
29
27
  const Log = getLogger(LoggerNames.Method);
@@ -266,16 +264,16 @@ export class FirmwareUpdateBaseMethod<Params> extends BaseMethod<Params> {
266
264
  */
267
265
  async startEmmcFirmwareUpdate({ path }: { path: string }) {
268
266
  const typedCall = this.device.getCommands().typedCall.bind(this.device.getCommands());
269
- let updaeteResponse: TypedResponseMessage<'Success'>;
267
+ let updateResponse: TypedResponseMessage<'Success'>;
270
268
  try {
271
- updaeteResponse = await typedCall('FirmwareUpdateEmmc', 'Success', {
269
+ updateResponse = await typedCall('FirmwareUpdateEmmc', 'Success', {
272
270
  path,
273
271
  reboot_on_success: true,
274
272
  });
275
273
  } catch (error) {
276
274
  if (isDeviceDisconnectedError(error)) {
277
275
  Log.log('Rebooting device');
278
- updaeteResponse = {
276
+ updateResponse = {
279
277
  type: 'Success',
280
278
  message: { message: FIRMWARE_UPDATE_CONFIRM },
281
279
  };
@@ -283,7 +281,7 @@ export class FirmwareUpdateBaseMethod<Params> extends BaseMethod<Params> {
283
281
  throw error;
284
282
  }
285
283
  }
286
- if (updaeteResponse.type !== 'Success') {
284
+ if (updateResponse.type !== 'Success') {
287
285
  throw ERRORS.TypedError(HardwareErrorCode.FirmwareError, 'firmware update error');
288
286
  }
289
287
  this.postTipMessage(FirmwareUpdateTipMessage.FirmwareUpdating);
@@ -1,8 +1,10 @@
1
1
  import semver from 'semver';
2
2
  import { EDeviceType } from '@onekeyfe/hd-shared';
3
- import { Features, IVersionArray } from '../../types';
3
+
4
4
  import { getDeviceType } from '../../utils';
5
5
 
6
+ import type { Features, IVersionArray } from '../../types';
7
+
6
8
  export function shouldUpdateBootloaderForClassicAndMini({
7
9
  currentVersion,
8
10
  bootloaderVersion,
@@ -1,11 +1,14 @@
1
1
  import ByteBuffer from 'bytebuffer';
2
2
  import semver from 'semver';
3
- import type { EFirmwareType } from '@onekeyfe/hd-shared';
4
- import { DeviceModelToTypes, Features } from '../../types';
5
- import { getDeviceType, getDeviceBootloaderVersion, getDeviceFirmwareVersion } from '../../utils';
3
+
4
+ import { DeviceModelToTypes } from '../../types';
5
+ import { getDeviceBootloaderVersion, getDeviceFirmwareVersion, getDeviceType } from '../../utils';
6
6
  import { DataManager } from '../../data-manager';
7
7
  import { shouldUpdateBootloaderForClassicAndMini } from './bootloaderHelper';
8
8
 
9
+ import type { Features } from '../../types';
10
+ import type { EFirmwareType } from '@onekeyfe/hd-shared';
11
+
9
12
  export function checkNeedUpdateBootForTouch(features: Features, firmwareType: EFirmwareType) {
10
13
  const deviceType = getDeviceType(features);
11
14
  if (!DeviceModelToTypes.model_touch.includes(deviceType)) return false;
@@ -3,6 +3,7 @@ import { blake2s } from '@noble/hashes/blake2s';
3
3
  import JSZip from 'jszip';
4
4
  import { ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
5
5
 
6
+ import { getDeviceFirmwareVersion } from '../../utils/deviceVersionUtils';
6
7
  import {
7
8
  LoggerNames,
8
9
  getDeviceBootloaderVersion,
@@ -103,48 +104,63 @@ export const uploadFirmware = async (
103
104
  rebootOnSuccess,
104
105
  }: PROTO.FirmwareUpload & {
105
106
  rebootOnSuccess?: boolean;
106
- }
107
+ },
108
+ isUpdateBootloader?: boolean
107
109
  ) => {
108
110
  const deviceType = getDeviceType(device.features);
109
111
  if (DeviceModelToTypes.model_mini.includes(deviceType)) {
110
112
  postConfirmationMessage(device);
111
113
  postProgressTip(device, 'ConfirmOnDevice', postMessage);
114
+
112
115
  const isFirmware = updateType === 'firmware';
113
116
 
114
- const deviceBootloaderVersion = getDeviceBootloaderVersion(device.features).join('.');
115
- const supportUpgradeFileHeader = semver.gt(deviceBootloaderVersion, '2.1.0');
117
+ if (isFirmware && !isUpdateBootloader) {
118
+ const newFeatures = await typedCall('GetFeatures', 'Features', {});
119
+ const deviceBootloaderVersion = getDeviceBootloaderVersion(newFeatures.message).join('.');
120
+ const supportUpgradeFileHeader = semver.gte(deviceBootloaderVersion, '2.1.0');
121
+ Log.debug('supportUpgradeFileHeader:', supportUpgradeFileHeader);
122
+
123
+ if (supportUpgradeFileHeader) {
124
+ // Extract and validate firmware header (first 1KB)
125
+ const HEADER_SIZE = 1024;
126
+ if (payload.byteLength < HEADER_SIZE) {
127
+ throw ERRORS.TypedError(
128
+ HardwareErrorCode.RuntimeError,
129
+ `firmware payload too small: ${payload.byteLength} bytes, expected at least ${HEADER_SIZE} bytes`
130
+ );
131
+ }
116
132
 
117
- Log.debug(
118
- 'supportUpgradeFileHeader:',
119
- supportUpgradeFileHeader,
120
- 'deviceBootloaderVersion:',
121
- deviceBootloaderVersion
122
- );
123
- if (isFirmware && supportUpgradeFileHeader) {
124
- // Extract and validate firmware header (first 1KB)
125
- const HEADER_SIZE = 1024;
126
- if (payload.byteLength < HEADER_SIZE) {
127
- throw ERRORS.TypedError(
128
- HardwareErrorCode.RuntimeError,
129
- `firmware payload too small: ${payload.byteLength} bytes, expected at least ${HEADER_SIZE} bytes`
130
- );
131
- }
133
+ Log.debug('Uploading firmware header:', {
134
+ size: HEADER_SIZE,
135
+ totalSize: payload.byteLength,
136
+ });
137
+ postProgressTip(device, 'UploadingFirmwareHeader', postMessage);
132
138
 
133
- Log.debug('Uploading firmware header:', { size: HEADER_SIZE, totalSize: payload.byteLength });
134
- postProgressTip(device, 'UploadingFirmwareHeader', postMessage);
139
+ const header = new Uint8Array(payload.slice(0, HEADER_SIZE));
135
140
 
136
- const header = new Uint8Array(payload.slice(0, HEADER_SIZE));
137
- const headerRes = (await typedCall('UpgradeFileHeader', 'Success', {
138
- data: bytesToHex(header),
139
- })) as TypedResponseMessage<'Success'>;
141
+ try {
142
+ const headerRes = await typedCall('UpgradeFileHeader', 'Success', {
143
+ data: bytesToHex(header),
144
+ });
140
145
 
141
- const isUnexpectedMessage = headerRes.message?.message?.includes('Failure_UnexpectedMessage');
142
- if (headerRes.type !== 'Success' && !isUnexpectedMessage) {
143
- Log.error('Firmware header upload failed:', headerRes);
144
- throw ERRORS.TypedError(HardwareErrorCode.RuntimeError, 'failed to upload firmware header');
145
- }
146
+ const isUnknownMessage = headerRes.message?.message?.includes('Failure_UnknownMessage');
146
147
 
147
- Log.debug('Firmware header uploaded successfully, isUnexpectedMessage:', isUnexpectedMessage);
148
+ if (headerRes.type !== 'Success' && !isUnknownMessage) {
149
+ Log.error('Firmware header upload failed:', headerRes);
150
+ throw ERRORS.TypedError(
151
+ HardwareErrorCode.RuntimeError,
152
+ 'failed to upload firmware header'
153
+ );
154
+ }
155
+ } catch (error) {
156
+ Log.error('Firmware header upload failed:', error);
157
+ const message = error instanceof Error ? error.message : String(error ?? '');
158
+ if (!message.includes('Failure_UnknownMessage')) {
159
+ throw error;
160
+ }
161
+ }
162
+ Log.debug('Firmware header uploaded successfully');
163
+ }
148
164
  }
149
165
 
150
166
  const eraseCommand = isFirmware ? 'FirmwareErase' : 'FirmwareErase_ex';
@@ -153,17 +169,31 @@ export const uploadFirmware = async (
153
169
  throw ERRORS.TypedError(HardwareErrorCode.RuntimeError, 'erase firmware error');
154
170
  }
155
171
  postProgressTip(device, 'FirmwareEraseSuccess', postMessage);
172
+
156
173
  postProgressMessage(device, 0, 'installingFirmware', postMessage);
157
- const { message, type } = await typedCall('FirmwareUpload', 'Success', {
158
- payload,
159
- });
174
+ let updateResponse: TypedResponseMessage<'Success'>;
175
+ try {
176
+ updateResponse = await typedCall('FirmwareUpload', 'Success', {
177
+ payload,
178
+ });
179
+ } catch (error) {
180
+ if (isDeviceDisconnectedError(error)) {
181
+ Log.log('Rebooting device');
182
+ updateResponse = {
183
+ type: 'Success',
184
+ message: { message: FIRMWARE_UPDATE_CONFIRM },
185
+ };
186
+ } else {
187
+ throw error;
188
+ }
189
+ }
160
190
  postProgressMessage(device, 100, 'installingFirmware', postMessage);
161
191
 
162
192
  await waitBleInstall(updateType);
163
- if (type !== 'Success') {
193
+ if (updateResponse.type !== 'Success') {
164
194
  throw ERRORS.TypedError(HardwareErrorCode.RuntimeError, 'install firmware error');
165
195
  }
166
- return message;
196
+ return updateResponse.message;
167
197
  }
168
198
 
169
199
  if (DeviceModelToTypes.model_touch.includes(deviceType)) {
package/src/core/index.ts CHANGED
@@ -1,28 +1,27 @@
1
1
  import semver from 'semver';
2
2
  import EventEmitter from 'events';
3
- import { Features, LowlevelTransportSharedPlugin, OneKeyDeviceInfo } from '@onekeyfe/hd-transport';
4
3
  import {
5
- createDeferred,
6
- Deferred,
7
4
  ERRORS,
8
5
  HardwareError,
9
6
  HardwareErrorCode,
7
+ createDefectiveFirmwareError,
8
+ createDeferred,
10
9
  createDeprecatedHardwareError,
11
10
  createNeedUpgradeFirmwareHardwareError,
12
11
  createNewFirmwareForceUpdateHardwareError,
13
12
  createNewFirmwareUnReleaseHardwareError,
14
- createDefectiveFirmwareError,
15
13
  } from '@onekeyfe/hd-shared';
14
+
16
15
  import {
17
- getDeviceFirmwareVersion,
18
- getDeviceBLEFirmwareVersion,
16
+ LoggerNames,
19
17
  enableLog,
18
+ getDeviceBLEFirmwareVersion,
19
+ getDeviceFirmwareVersion,
20
+ getFirmwareType,
20
21
  getLogger,
21
- LoggerNames,
22
+ getMethodVersionRange,
22
23
  setLoggerPostMessage,
23
24
  wait,
24
- getMethodVersionRange,
25
- getFirmwareType,
26
25
  } from '../utils';
27
26
  import {
28
27
  findDefectiveBatchDevice,
@@ -30,43 +29,47 @@ import {
30
29
  } from '../utils/findDefectiveBatchDevice';
31
30
  import { supportNewPassphrase } from '../utils/deviceFeaturesUtils';
32
31
  import {
32
+ cleanupSdkInstance,
33
33
  completeRequestContext,
34
34
  createRequestContext,
35
35
  createSdkTracingContext,
36
36
  formatRequestContext,
37
37
  getActiveRequestsByDeviceInstance,
38
- SdkTracingContext,
39
38
  updateRequestContext,
40
- cleanupSdkInstance,
41
39
  } from '../utils/tracing';
42
- import { Device, DeviceEvents, InitOptions, RunOptions } from '../device/Device';
40
+ import { Device } from '../device/Device';
43
41
  import { DeviceList } from '../device/DeviceList';
44
42
  import { DevicePool } from '../device/DevicePool';
45
43
  import { findMethod } from '../api/utils';
46
44
  import { DataManager } from '../data-manager';
47
-
48
45
  import { UI_REQUEST as UI_REQUEST_CONST } from '../constants/ui-request';
49
46
  import {
50
47
  CORE_EVENT,
51
- CoreMessage,
52
- createDeviceMessage,
53
- createResponseMessage,
54
- createUiMessage,
55
48
  DEVICE,
56
49
  IFRAME,
57
- IFrameCallMessage,
58
50
  UI_REQUEST,
59
51
  UI_RESPONSE,
60
- UiPromise,
61
- UiPromiseResponse,
52
+ createDeviceMessage,
53
+ createResponseMessage,
54
+ createUiMessage,
62
55
  } from '../events';
63
- import type { BaseMethod } from '../api/BaseMethod';
64
- import type { ConnectSettings, KnownDevice } from '../types';
65
56
  import TransportManager from '../data-manager/TransportManager';
66
57
  import DeviceConnector from '../device/DeviceConnector';
67
58
  import RequestQueue from './RequestQueue';
68
59
  import { getSynchronize } from '../utils/getSynchronize';
69
60
 
61
+ import type { ConnectSettings, KnownDevice } from '../types';
62
+ import type { CoreMessage, IFrameCallMessage, UiPromise, UiPromiseResponse } from '../events';
63
+ import type { DeviceEvents, InitOptions, RunOptions } from '../device/Device';
64
+ import type { SdkTracingContext } from '../utils/tracing';
65
+ import type { Deferred } from '@onekeyfe/hd-shared';
66
+ import type {
67
+ Features,
68
+ LowlevelTransportSharedPlugin,
69
+ OneKeyDeviceInfo,
70
+ } from '@onekeyfe/hd-transport';
71
+ import type { BaseMethod } from '../api/BaseMethod';
72
+
70
73
  const Log = getLogger(LoggerNames.Core);
71
74
 
72
75
  export type CoreContext = ReturnType<Core['getCoreContext']>;
@@ -585,8 +588,9 @@ const onCallDevice = async (
585
588
  pinListeners: device.listenerCount(DEVICE.PIN),
586
589
  }
587
590
  );
591
+ } else {
592
+ removeDeviceListener(device);
588
593
  }
589
- removeDeviceListener(device);
590
594
  }
591
595
  }
592
596
  };
@@ -1091,6 +1095,9 @@ const onSelectDeviceInBootloaderForWebDeviceHandler = async (
1091
1095
  * @memberof Core
1092
1096
  */
1093
1097
  const postMessage = (message: CoreMessage) => {
1098
+ if (!_core) {
1099
+ return;
1100
+ }
1094
1101
  _core.emit(CORE_EVENT, message);
1095
1102
  };
1096
1103
 
@@ -1,9 +1,8 @@
1
- import type { Transport, Messages, FailureType } from '@onekeyfe/hd-transport';
2
1
  import { ERRORS, HardwareError, HardwareErrorCode } from '@onekeyfe/hd-shared';
2
+
3
3
  import TransportManager from '../data-manager/TransportManager';
4
4
  import DataManager from '../data-manager/DataManager';
5
- import { patchFeatures, getLogger, LoggerNames, getDeviceType } from '../utils';
6
- import type { Device } from './Device';
5
+ import { LoggerNames, getDeviceType, getLogger, patchFeatures } from '../utils';
7
6
  import { DEVICE, type PassphraseRequestPayload } from '../events';
8
7
  import { DeviceModelToTypes } from '../types';
9
8
  import {
@@ -12,6 +11,9 @@ import {
12
11
  getActiveRequestsByDeviceInstance,
13
12
  } from '../utils/tracing';
14
13
 
14
+ import type { Device } from './Device';
15
+ import type { FailureType, Messages, Transport } from '@onekeyfe/hd-transport';
16
+
15
17
  export type PassphrasePromptResponse = {
16
18
  passphrase?: string;
17
19
  passphraseOnDevice?: boolean;
@@ -230,7 +232,11 @@ export class DeviceCommands {
230
232
  const promise = this.transport.call(this.mainId, type, msg) as any;
231
233
  this.callPromise = promise;
232
234
  const res = await promise;
233
- LogCore.debug('[DeviceCommands] [call] Received', res.type);
235
+ if (res.type === 'Failure') {
236
+ LogCore.debug('[DeviceCommands] [call] Received', res.type, res.message);
237
+ } else {
238
+ LogCore.debug('[DeviceCommands] [call] Received', res.type);
239
+ }
234
240
  return res;
235
241
  } catch (error) {
236
242
  LogCore.debug('[DeviceCommands] [call] Received error', error);
@@ -413,14 +419,16 @@ export class DeviceCommands {
413
419
  message?.includes('verify failed')
414
420
  ) {
415
421
  error = ERRORS.TypedError(HardwareErrorCode.FirmwareVerificationFailed, message);
422
+ } else if (message?.includes('Firmware downgrade not allowed')) {
423
+ // Check firmware check failed
424
+ error = ERRORS.TypedError(HardwareErrorCode.FirmwareDowngradeNotAllowed, message);
416
425
  }
417
426
  }
418
427
 
419
428
  if (code === 'Failure_UnexpectedMessage') {
420
429
  if (callType === 'PassphraseAck') {
421
430
  error = ERRORS.TypedError(HardwareErrorCode.UnexpectPassphrase);
422
- }
423
- if (message === 'Not in Signing mode') {
431
+ } else if (message === 'Not in Signing mode') {
424
432
  error = ERRORS.TypedError(HardwareErrorCode.NotInSigningMode);
425
433
  }
426
434
  }
@@ -1,5 +1,6 @@
1
- import { CoreMessage } from '../events';
2
- import { createLogMessage, LOG } from '../events/log';
1
+ import { LOG, createLogMessage } from '../events/log';
2
+
3
+ import type { CoreMessage } from '../events';
3
4
 
4
5
  type LogMessage = {
5
6
  level: string;
@@ -1,15 +1,11 @@
1
1
  /**
2
2
  * SDK Tracing Utilities
3
- * 用于追踪对象实例和请求调用链路
4
- *
5
- * 支持多个 SDK 实例,每个实例有独立的追踪上下文
3
+ * Tracks object instances and request call chains across multiple SDK instances
6
4
  */
7
5
 
8
6
  import { getLogger, LoggerNames } from './logger';
9
7
 
10
- // ============================================================
11
- // 全局计数器(跨 SDK 实例)
12
- // ============================================================
8
+ // Global counters (cross-SDK instances)
13
9
 
14
10
  const Log = getLogger(LoggerNames.Core);
15
11
 
@@ -17,8 +13,8 @@ let globalInstanceCounter = 0;
17
13
  let sdkInstanceCounter = 0;
18
14
 
19
15
  /**
20
- * 生成 SDK 实例 ID
21
- * @returns 格式: "SDK-<序号>-<时间戳>"
16
+ * Generate SDK instance ID
17
+ * @returns Format: "SDK-<number>-<timestamp>"
22
18
  * @example "SDK-1-123456"
23
19
  */
24
20
  export function generateSdkInstanceId(): string {
@@ -28,11 +24,11 @@ export function generateSdkInstanceId(): string {
28
24
  }
29
25
 
30
26
  /**
31
- * 生成全局唯一的实例 ID
32
- * @param type 实例类型 (Device, DeviceCommands, BaseMethod, etc.)
33
- * @param sdkInstanceId SDK 实例 ID(可选,用于前缀)
34
- * @returns 格式: <SDK实例>.<类型>-<序号>-<时间戳>
35
- * @example "SDK-1.Device-1-123456" "Device-1-123456"(无 SDK 实例)
27
+ * Generate globally unique instance ID
28
+ * @param type Instance type (Device, DeviceCommands, BaseMethod, etc.)
29
+ * @param sdkInstanceId SDK instance ID (optional)
30
+ * @returns Format: <SDK>.<type>-<number>-<timestamp>
31
+ * @example "SDK-1.Device-1-123456" or "Device-1-123456"
36
32
  */
37
33
  export function generateInstanceId(type: string, sdkInstanceId?: string): string {
38
34
  globalInstanceCounter++;
@@ -41,58 +37,56 @@ export function generateInstanceId(type: string, sdkInstanceId?: string): string
41
37
  return sdkInstanceId ? `${sdkInstanceId}.${baseId}` : baseId;
42
38
  }
43
39
 
44
- // ============================================================
45
- // 请求上下文管理
46
- // ============================================================
40
+ // Request context management
47
41
 
48
42
  /**
49
- * 请求上下文信息
43
+ * Request context information
50
44
  */
51
45
  export interface RequestContext {
52
- /** 请求唯一 ID (复用 BaseMethod.responseID) */
46
+ /** Request unique ID (reuses BaseMethod.responseID) */
53
47
  responseID: number;
54
- /** SDK 实例 ID */
48
+ /** SDK instance ID */
55
49
  sdkInstanceId?: string;
56
- /** API 方法名 */
50
+ /** API method name */
57
51
  methodName: string;
58
- /** 设备连接 ID */
52
+ /** Device connection ID */
59
53
  connectId?: string;
60
- /** Device 实例 ID */
54
+ /** Device instance ID */
61
55
  deviceInstanceId?: string;
62
- /** DeviceCommands 实例 ID */
56
+ /** DeviceCommands instance ID */
63
57
  commandsInstanceId?: string;
64
- /** 父请求 ID (用于嵌套调用如 allNetworkGetAddress) */
58
+ /** Parent request ID (for nested calls like allNetworkGetAddress) */
65
59
  parentResponseID?: number;
66
- /** 请求开始时间 */
60
+ /** Request start time */
67
61
  startTime: number;
68
- /** 请求结束时间 */
62
+ /** Request end time */
69
63
  endTime?: number;
70
- /** 请求状态 */
64
+ /** Request status */
71
65
  status?: 'pending' | 'running' | 'success' | 'error' | 'cancelled';
72
- /** 错误信息 */
66
+ /** Error message */
73
67
  error?: string;
74
68
  }
75
69
 
76
70
  /**
77
- * SDK 实例追踪上下文
71
+ * SDK instance tracing context
78
72
  */
79
73
  export interface SdkTracingContext {
80
- /** SDK 实例 ID */
74
+ /** SDK instance ID */
81
75
  sdkInstanceId: string;
82
- /** 创建时间 */
76
+ /** Creation timestamp */
83
77
  createdAt: number;
84
- /** 活跃请求 */
78
+ /** Active requests */
85
79
  activeRequests: Map<number, RequestContext>;
86
80
  }
87
81
 
88
- // 全局 SDK 实例追踪 Map
82
+ // Global SDK instance tracking map
89
83
  const sdkInstances = new Map<string, SdkTracingContext>();
90
84
 
91
- // 全局请求 Map(跨 SDK 实例,用于快速查找)
85
+ // Global request map (cross-SDK instances for quick lookup)
92
86
  const globalActiveRequests = new Map<number, RequestContext>();
93
87
 
94
88
  /**
95
- * 创建 SDK 实例追踪上下文
89
+ * Create SDK instance tracing context
96
90
  */
97
91
  export function createSdkTracingContext(): SdkTracingContext {
98
92
  const sdkInstanceId = generateSdkInstanceId();
@@ -108,10 +102,10 @@ export function createSdkTracingContext(): SdkTracingContext {
108
102
  }
109
103
 
110
104
  /**
111
- * 创建并注册请求上下文
112
- * @param responseID 请求 ID (复用 BaseMethod.responseID)
113
- * @param methodName API 方法名
114
- * @param options 额外选项
105
+ * Create and register request context
106
+ * @param responseID Request ID (reuses BaseMethod.responseID)
107
+ * @param methodName API method name
108
+ * @param options Additional options
115
109
  */
116
110
  export function createRequestContext(
117
111
  responseID: number,
@@ -136,10 +130,10 @@ export function createRequestContext(
136
130
  status: 'pending',
137
131
  };
138
132
 
139
- // 注册到全局 Map
133
+ // Register to global map
140
134
  globalActiveRequests.set(context.responseID, context);
141
135
 
142
- // 注册到 SDK 实例 Map
136
+ // Register to SDK instance map
143
137
  if (options?.sdkInstanceId) {
144
138
  const sdkContext = sdkInstances.get(options.sdkInstanceId);
145
139
  if (sdkContext) {
@@ -151,7 +145,7 @@ export function createRequestContext(
151
145
  }
152
146
 
153
147
  /**
154
- * 更新请求状态
148
+ * Update request context
155
149
  */
156
150
  export function updateRequestContext(responseID: number, updates: Partial<RequestContext>): void {
157
151
  const context = globalActiveRequests.get(responseID);
@@ -161,7 +155,7 @@ export function updateRequestContext(responseID: number, updates: Partial<Reques
161
155
  }
162
156
 
163
157
  /**
164
- * 完成请求
158
+ * Complete request context
165
159
  */
166
160
  export function completeRequestContext(responseID: number, error?: Error): void {
167
161
  const context = globalActiveRequests.get(responseID);
@@ -170,16 +164,15 @@ export function completeRequestContext(responseID: number, error?: Error): void
170
164
  context.status = error ? 'error' : 'success';
171
165
  if (error) {
172
166
  context.error = error.message;
173
- // print core log
174
167
  Log.error(
175
168
  `[RequestContext] [completeRequestContext] Error: ${formatRequestContext(context)}`
176
169
  );
177
170
  }
178
171
 
179
- // 从活跃列表移除
172
+ // Remove from active list
180
173
  globalActiveRequests.delete(responseID);
181
174
 
182
- // SDK 实例移除
175
+ // Remove from SDK instance
183
176
  if (context.sdkInstanceId) {
184
177
  const sdkContext = sdkInstances.get(context.sdkInstanceId);
185
178
  if (sdkContext) {
@@ -189,12 +182,10 @@ export function completeRequestContext(responseID: number, error?: Error): void
189
182
  }
190
183
  }
191
184
 
192
- // ============================================================
193
- // 查询 API
194
- // ============================================================
185
+ // Query API
195
186
 
196
187
  /**
197
- * 获取特定 Device 实例的活跃请求
188
+ * Get active requests for specific Device instance
198
189
  */
199
190
  export function getActiveRequestsByDeviceInstance(deviceInstanceId: string): RequestContext[] {
200
191
  return Array.from(globalActiveRequests.values()).filter(
@@ -202,12 +193,10 @@ export function getActiveRequestsByDeviceInstance(deviceInstanceId: string): Req
202
193
  );
203
194
  }
204
195
 
205
- // ============================================================
206
- // 格式化输出
207
- // ============================================================
196
+ // Format output
208
197
 
209
198
  /**
210
- * 格式化请求上下文用于日志输出
199
+ * Format request context for logging
211
200
  */
212
201
  export function formatRequestContext(context: RequestContext): string {
213
202
  const duration = context.endTime
@@ -230,22 +219,20 @@ export function formatRequestContext(context: RequestContext): string {
230
219
  return parts.join(' ');
231
220
  }
232
221
 
233
- // ============================================================
234
- // 清理和重置
235
- // ============================================================
222
+ // Cleanup and reset
236
223
 
237
224
  /**
238
- * 清理特定 SDK 实例
225
+ * Cleanup specific SDK instance
239
226
  */
240
227
  export function cleanupSdkInstance(sdkInstanceId: string): void {
241
228
  const sdkContext = sdkInstances.get(sdkInstanceId);
242
229
  if (sdkContext) {
243
- // 从全局活跃请求中移除该 SDK 的请求
230
+ // Remove SDK requests from global active requests
244
231
  for (const responseID of sdkContext.activeRequests.keys()) {
245
232
  globalActiveRequests.delete(responseID);
246
233
  }
247
234
 
248
- // 移除 SDK 实例
235
+ // Remove SDK instance
249
236
  sdkInstances.delete(sdkInstanceId);
250
237
  }
251
238
  }