@onekeyfe/hd-core 1.2.0-alpha.5 → 1.2.0-alpha.7

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.
@@ -0,0 +1,19 @@
1
+ import { parseConnectSettings } from '../src/data-manager/connectSettings';
2
+
3
+ jest.mock('../src/data/config', () => ({
4
+ getSDKVersion: jest.fn(() => '1.0.0'),
5
+ DEFAULT_DOMAIN: 'https://jssdk.onekey.so/1.0.0/',
6
+ }));
7
+
8
+ describe('parseConnectSettings', () => {
9
+ it('keeps custom configFetcher in parsed settings', () => {
10
+ const configFetcher = jest.fn();
11
+
12
+ const settings = parseConnectSettings({
13
+ fetchConfig: true,
14
+ configFetcher,
15
+ });
16
+
17
+ expect(settings.configFetcher).toBe(configFetcher);
18
+ });
19
+ });
@@ -2917,6 +2917,67 @@ describe('Protocol V2 firmware update targets', () => {
2917
2917
  ]);
2918
2918
  });
2919
2919
 
2920
+ test('installs merged Pro2 resource crate as one CRATE request before firmware targets', async () => {
2921
+ const method = new FirmwareUpdateV4({
2922
+ id: 1,
2923
+ payload: {
2924
+ method: 'firmwareUpdateV4',
2925
+ },
2926
+ });
2927
+
2928
+ const operations: string[] = [];
2929
+ method.postTipMessage = jest.fn();
2930
+ method.postProgressMessage = jest.fn();
2931
+ (method as any).protocolV2CommonUpdateProcess = jest
2932
+ .fn()
2933
+ .mockImplementation(params => {
2934
+ operations.push(`write:${params.filePath}`);
2935
+ return Promise.resolve(
2936
+ Number(params.processedSize ?? 0) + Number(params.payload.byteLength)
2937
+ );
2938
+ });
2939
+ (method as any).protocolV2StartFirmwareUpdate = jest.fn().mockImplementation(({ targets }) => {
2940
+ operations.push(
2941
+ `install:${targets.map((target: { path: string }) => target.path).join(',')}`
2942
+ );
2943
+ return Promise.resolve(undefined);
2944
+ });
2945
+ (method as any).waitForProtocolV2FirmwareUpdateComplete = jest
2946
+ .fn()
2947
+ .mockResolvedValue(undefined);
2948
+
2949
+ await (method as any).executeProtocolV2Update({
2950
+ resourceBinaryMap: [
2951
+ {
2952
+ fileName: 'resource-resource.bin',
2953
+ binary: new Uint8Array([1, 2]).buffer,
2954
+ targetId: 1,
2955
+ },
2956
+ ],
2957
+ bootloaderBinary: null,
2958
+ fwBinaryMap: [
2959
+ {
2960
+ fileName: 'application_p1.bin',
2961
+ binary: new Uint8Array([3]).buffer,
2962
+ targetId: 4,
2963
+ },
2964
+ ],
2965
+ });
2966
+
2967
+ expect((method as any).protocolV2StartFirmwareUpdate).toHaveBeenNthCalledWith(1, {
2968
+ targets: [{ target_id: 1, path: 'vol1:resource-resource.bin' }],
2969
+ });
2970
+ expect((method as any).protocolV2StartFirmwareUpdate).toHaveBeenNthCalledWith(2, {
2971
+ targets: [{ target_id: 4, path: 'vol1:application_p1.bin' }],
2972
+ });
2973
+ expect(operations).toEqual([
2974
+ 'write:vol1:resource-resource.bin',
2975
+ 'write:vol1:application_p1.bin',
2976
+ 'install:vol1:resource-resource.bin',
2977
+ 'install:vol1:application_p1.bin',
2978
+ ]);
2979
+ });
2980
+
2920
2981
  test('skips Pro2 firmware components when configured versions are already installed', async () => {
2921
2982
  const method = new FirmwareUpdateV4({
2922
2983
  id: 1,
@@ -1 +1 @@
1
- {"version":3,"file":"connectSettings.d.ts","sourceRoot":"","sources":["../../src/data-manager/connectSettings.ts"],"names":[],"mappings":"AAEA,OAAO,EAAkB,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAEhD,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAGlC,OAAO,CAAC,MAAM,CAAC;IAEb,IAAI,kBAAkB,EAAE,MAAM,CAAC;CAChC;AAmBD,eAAO,MAAM,MAAM,4DAqBlB,CAAC;AAEF,eAAO,MAAM,aAAa,SAAU,MAAM,uBAKzC,CAAC;AAEF,eAAO,MAAM,oBAAoB,WAAW,QAAQ,eAAe,CAAC,oBAyDnE,CAAC;AAEF,OAAO,EAAE,aAAa,EAAE,CAAC"}
1
+ {"version":3,"file":"connectSettings.d.ts","sourceRoot":"","sources":["../../src/data-manager/connectSettings.ts"],"names":[],"mappings":"AAEA,OAAO,EAAkB,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAEhD,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAGlC,OAAO,CAAC,MAAM,CAAC;IAEb,IAAI,kBAAkB,EAAE,MAAM,CAAC;CAChC;AAmBD,eAAO,MAAM,MAAM,4DAqBlB,CAAC;AAEF,eAAO,MAAM,aAAa,SAAU,MAAM,uBAKzC,CAAC;AAEF,eAAO,MAAM,oBAAoB,WAAW,QAAQ,eAAe,CAAC,oBA6DnE,CAAC;AAEF,OAAO,EAAE,aAAa,EAAE,CAAC"}
package/dist/index.js CHANGED
@@ -38916,6 +38916,9 @@ const parseConnectSettings = (input = {}) => {
38916
38916
  if (input.fetchConfig) {
38917
38917
  settings.fetchConfig = input.fetchConfig;
38918
38918
  }
38919
+ if (input.configFetcher) {
38920
+ settings.configFetcher = input.configFetcher;
38921
+ }
38919
38922
  return settings;
38920
38923
  };
38921
38924
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/hd-core",
3
- "version": "1.2.0-alpha.5",
3
+ "version": "1.2.0-alpha.7",
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.2.0-alpha.5",
29
- "@onekeyfe/hd-transport": "1.2.0-alpha.5",
28
+ "@onekeyfe/hd-shared": "1.2.0-alpha.7",
29
+ "@onekeyfe/hd-transport": "1.2.0-alpha.7",
30
30
  "axios": "1.15.2",
31
31
  "bignumber.js": "^9.0.2",
32
32
  "bytebuffer": "^5.0.1",
@@ -44,5 +44,5 @@
44
44
  "@types/w3c-web-usb": "^1.0.10",
45
45
  "@types/web-bluetooth": "^0.0.21"
46
46
  },
47
- "gitHead": "703cfb4e17c6f9315afcb0522ee23ea016ede659"
47
+ "gitHead": "001372047f518aaeed5fcbe87b990b8b619a9a65"
48
48
  }
@@ -115,6 +115,10 @@ export const parseConnectSettings = (input: Partial<ConnectSettings> = {}) => {
115
115
  settings.fetchConfig = input.fetchConfig;
116
116
  }
117
117
 
118
+ if (input.configFetcher) {
119
+ settings.configFetcher = input.configFetcher;
120
+ }
121
+
118
122
  return settings;
119
123
  };
120
124
 
@@ -81,7 +81,7 @@ export interface FirmwareUpdateV4Params {
81
81
  se02Binary?: ArrayBuffer;
82
82
  se03Binary?: ArrayBuffer;
83
83
  se04Binary?: ArrayBuffer;
84
- /** 资源包通过 FW_MGMT_TARGET_CRATE = 1 安装;每个元素是一个独立资源包 */
84
+ /** 资源包通过 FW_MGMT_TARGET_CRATE = 1 安装;Pro2 正常升级推荐传入单个合并 CRATE,多个元素仅用于调试/兼容 */
85
85
  resourceBinaries?: ArrayBuffer[];
86
86
  forcedUpdateRes?: boolean;
87
87
  }