@onekeyfe/hd-core 1.2.0-alpha.119 → 1.2.0-alpha.120

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.
@@ -77,7 +77,7 @@ describe('DeviceSettings protocol routing', () => {
77
77
  expect(method.unlockPolicy).toBe('unlock-before-run');
78
78
  });
79
79
 
80
- it('uses ApplySettings and commits the confirmed patch for Protocol V1', async () => {
80
+ it('uses ApplySettings and refreshes Protocol V1 settings from the device', async () => {
81
81
  const { device, typedCall, updateState } = createDevice({ protocol: 'V1' });
82
82
  const method = new DeviceSettings({
83
83
  id: 1,
@@ -107,13 +107,8 @@ describe('DeviceSettings protocol routing', () => {
107
107
  use_ble: true,
108
108
  haptic_feedback: undefined,
109
109
  });
110
- expect(updateState).toHaveBeenCalledWith(
111
- {
112
- identity: { label: 'Shared Label' },
113
- settings: { language: 'ja', bleEnabled: true },
114
- },
115
- 'settings-write'
116
- );
110
+ expect(device.getDeviceState).toHaveBeenCalledWith({ refreshSections: ['settings'] });
111
+ expect(updateState).not.toHaveBeenCalled();
117
112
  });
118
113
 
119
114
  it('normalizes legacy Protocol V1 never values before ApplySettings', async () => {
@@ -138,15 +133,33 @@ describe('DeviceSettings protocol routing', () => {
138
133
  auto_shutdown_delay_ms: DEVICE_SETTINGS_NEVER_TIMEOUT_MS,
139
134
  })
140
135
  );
141
- expect(updateState).toHaveBeenCalledWith(
142
- {
143
- settings: {
144
- autoLockDelayMs: DEVICE_SETTINGS_NEVER_TIMEOUT_MS,
145
- autoShutdownDelayMs: DEVICE_SETTINGS_NEVER_TIMEOUT_MS,
146
- },
136
+ expect(device.getDeviceState).toHaveBeenCalledWith({ refreshSections: ['settings'] });
137
+ expect(updateState).not.toHaveBeenCalled();
138
+ });
139
+
140
+ it('refreshes Protocol V1 settings after the on-device brightness update completes', async () => {
141
+ const { device, typedCall, updateState, getDeviceState } = createDevice({ protocol: 'V1' });
142
+ const method = new DeviceSettings({
143
+ id: 3,
144
+ payload: {
145
+ method: 'deviceSettings',
146
+ changeBrightness: true,
147
147
  },
148
- 'settings-write'
148
+ });
149
+ method.init();
150
+ (method as any).device = device;
151
+
152
+ await expect(method.run()).resolves.toEqual({ message: 'Success' });
153
+ expect(typedCall).toHaveBeenCalledWith(
154
+ 'ApplySettings',
155
+ 'Success',
156
+ expect.objectContaining({ change_brightness: true })
157
+ );
158
+ expect(getDeviceState).toHaveBeenCalledWith({ refreshSections: ['settings'] });
159
+ expect(typedCall.mock.invocationCallOrder[0]).toBeLessThan(
160
+ getDeviceState.mock.invocationCallOrder[0]
149
161
  );
162
+ expect(updateState).not.toHaveBeenCalled();
150
163
  });
151
164
 
152
165
  it('uses DeviceSettingsSet and reloads Protocol V2 status and settings from the device', async () => {
@@ -325,7 +338,7 @@ describe('DeviceSettings protocol routing', () => {
325
338
  'Success',
326
339
  expect.objectContaining({ use_passphrase: true })
327
340
  );
328
- expect(getDeviceState).not.toHaveBeenCalled();
341
+ expect(getDeviceState).toHaveBeenCalledWith({ refreshSections: ['settings'] });
329
342
  });
330
343
 
331
344
  it('rejects combining a Pro2 device-side toggle with direct settings', async () => {
@@ -0,0 +1,53 @@
1
+ import { EDeviceType } from '@onekeyfe/hd-shared';
2
+ import { ResourceType } from '@onekeyfe/hd-transport';
3
+
4
+ import DeviceUploadResource from '../src/api/device/DeviceUploadResource';
5
+
6
+ jest.mock('../src/data/config', () => ({
7
+ DEFAULT_DOMAIN: 'https://example.com/',
8
+ getSDKVersion: () => '0.0.0-test',
9
+ }));
10
+
11
+ describe('DeviceUploadResource state refresh', () => {
12
+ it('refreshes Protocol V1 settings inside a wallpaper update', async () => {
13
+ const typedCall = jest.fn().mockResolvedValue({
14
+ type: 'Success',
15
+ message: { message: 'Success' },
16
+ });
17
+ const getDeviceState = jest.fn().mockResolvedValue({
18
+ settings: { language: 'en-US' },
19
+ });
20
+ const method = new DeviceUploadResource({
21
+ id: 1,
22
+ payload: {
23
+ method: 'deviceUploadResource',
24
+ suffix: 'jpg',
25
+ dataHex: '00',
26
+ thumbnailDataHex: '00',
27
+ blurDataHex: '00',
28
+ resType: ResourceType.WallPaper,
29
+ },
30
+ });
31
+ method.init();
32
+ (method as any).device = {
33
+ commands: { typedCall },
34
+ getCurrentDeviceType: () => EDeviceType.Pro,
35
+ getCurrentFirmwareVersionString: () => '4.21.0',
36
+ getDeviceState,
37
+ };
38
+
39
+ await expect(method.run()).resolves.toEqual({
40
+ message: 'Success',
41
+ applyScreen: false,
42
+ });
43
+ expect(typedCall).toHaveBeenCalledWith(
44
+ 'ResourceUpload',
45
+ ['ResourceRequest', 'ZoomRequest', 'BlurRequest', 'Success'],
46
+ expect.objectContaining({ res_type: ResourceType.WallPaper })
47
+ );
48
+ expect(getDeviceState).toHaveBeenCalledWith({ refreshSections: ['settings'] });
49
+ expect(typedCall.mock.invocationCallOrder[0]).toBeLessThan(
50
+ getDeviceState.mock.invocationCallOrder[0]
51
+ );
52
+ });
53
+ });
@@ -2,6 +2,7 @@ import { DeviceSessionPinType } from '@onekeyfe/hd-transport';
2
2
 
3
3
  import ConfluxSignMessageCIP23 from '../src/api/conflux/ConfluxSignMessageCIP23';
4
4
  import DeviceLock from '../src/api/device/DeviceLock';
5
+ import DeviceSettings from '../src/api/device/DeviceSettings';
5
6
  import OpenWalletSession from '../src/api/OpenWalletSession';
6
7
  import { runMethodWithUnlockPolicy } from '../src/protocols/protocol-v2/unlockPolicyRunner';
7
8
 
@@ -160,6 +161,36 @@ describe('Protocol V2 unlock semantics', () => {
160
161
  expect(device.unlockDevice).toHaveBeenCalledWith(DeviceSessionPinType.Main, expect.any(Object));
161
162
  });
162
163
 
164
+ test('allows either PIN type when pre-unlocking device settings', async () => {
165
+ const method = new DeviceSettings({
166
+ id: 1,
167
+ payload: { method: 'deviceSettings', autoLockDelayMs: 60_000 },
168
+ });
169
+ method.init();
170
+ const features = { unlocked: false };
171
+ const device = {
172
+ features,
173
+ commands: {
174
+ typedCall: jest.fn().mockResolvedValue({ message: { unlocked: false } }),
175
+ },
176
+ isProtocolV2: () => true,
177
+ isBootloader: () => false,
178
+ isRomloader: () => false,
179
+ updateProtocolV2Status: jest.fn(() => features),
180
+ unlockDevice: jest.fn().mockImplementation(() => {
181
+ features.unlocked = true;
182
+ return Promise.resolve(features);
183
+ }),
184
+ };
185
+ method.run = jest.fn().mockResolvedValue({ message: 'ok' });
186
+
187
+ await expect(runMethodWithUnlockPolicy(method, device as any)).resolves.toEqual({
188
+ message: 'ok',
189
+ });
190
+
191
+ expect(device.unlockDevice).toHaveBeenCalledWith(DeviceSessionPinType.Any, expect.any(Object));
192
+ });
193
+
163
194
  test('pre-unlocks a locked standard wallet before wallet-session preparation', async () => {
164
195
  const calls: string[] = [];
165
196
  const features = {
@@ -4145,7 +4145,7 @@ describe('Protocol V2 firmware update targets', () => {
4145
4145
  );
4146
4146
  });
4147
4147
 
4148
- test('uses Protocol V2 features after BLE final reconnect without V1 Initialize', async () => {
4148
+ test('accepts uninitialized Protocol V2 features after BLE final reconnect', async () => {
4149
4149
  const method = new FirmwareUpdateV4({
4150
4150
  id: 1,
4151
4151
  payload: {
@@ -4173,7 +4173,7 @@ describe('Protocol V2 firmware update targets', () => {
4173
4173
  if (name === 'DeviceStatusGet') {
4174
4174
  return Promise.resolve({
4175
4175
  type: 'DeviceStatus',
4176
- message: { init_states: true, unlocked: true },
4176
+ message: { init_states: false, unlocked: false },
4177
4177
  });
4178
4178
  }
4179
4179
  if (name === 'ProtocolInfoRequest') {
@@ -4194,7 +4194,7 @@ describe('Protocol V2 firmware update targets', () => {
4194
4194
  getCommands: () => commands,
4195
4195
  updateProtocolV2Features: jest.fn(() => ({
4196
4196
  bootloaderMode: false,
4197
- mode: 'normal',
4197
+ mode: 'notInitialized',
4198
4198
  firmwareVersion: '0.0.0',
4199
4199
  bootloaderVersion: '0.0.0',
4200
4200
  bleVersion: '0.0.0',
@@ -5609,6 +5609,7 @@ describe('Protocol V2 firmware update targets', () => {
5609
5609
 
5610
5610
  test.each([
5611
5611
  [{ mode: 'normal', bootloaderMode: false }, true],
5612
+ [{ mode: 'notInitialized', bootloaderMode: false }, true],
5612
5613
  [{ mode: 'bootloader', bootloaderMode: true }, false],
5613
5614
  ])('derives firmware completion from the runtime-state probe: %o', async (features, expected) => {
5614
5615
  const method = new FirmwareUpdateV4({
@@ -1,5 +1,5 @@
1
1
  import { type EFirmwareType } from '@onekeyfe/hd-shared';
2
- import { type ProtocolType } from '@onekeyfe/hd-transport';
2
+ import { type DeviceSessionPinType, type ProtocolType } from '@onekeyfe/hd-transport';
3
3
  import type { Device } from '../device/Device';
4
4
  import type DeviceConnector from '../device/DeviceConnector';
5
5
  import type { DeviceFirmwareRange } from '../types';
@@ -38,6 +38,7 @@ export declare abstract class BaseMethod<Params = undefined> {
38
38
  getPreWarmKey(): string;
39
39
  strictCheckDeviceSupport: boolean;
40
40
  unlockPolicy: UnlockPolicy;
41
+ protocolV2PreUnlockPinType?: DeviceSessionPinType;
41
42
  protocolV2UnlockContext?: ProtocolV2UnlockContext;
42
43
  getSupportedProtocols(): readonly ProtocolType[];
43
44
  supportsProtocol(protocol: ProtocolType): boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"BaseMethod.d.ts","sourceRoot":"","sources":["../../src/api/BaseMethod.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,aAAa,EAKnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAyB,KAAK,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAWlF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,KAAK,eAAe,MAAM,2BAA2B,CAAC;AAC7D,OAAO,KAAK,EAAE,mBAAmB,EAAe,MAAM,UAAU,CAAC;AACjE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AAC1E,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,wCA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B,OAAO;IAGP,0BAA0B,SAAU;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,UAOrE;CACH"}
@@ -79,6 +79,7 @@ export default class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod<FirmwareU
79
79
  private waitForProtocolV2FirmwareUpdateComplete;
80
80
  private exitProtocolV2BootloaderToNormal;
81
81
  private probeProtocolV2NormalMode;
82
+ private isProtocolV2ApplicationMode;
82
83
  private waitForProtocolV2FinalFeatures;
83
84
  private getProtocolV2VersionResult;
84
85
  private completeProtocolV2FinalVerification;
@@ -1 +1 @@
1
- {"version":3,"file":"FirmwareUpdateV4.d.ts","sourceRoot":"","sources":["../../src/api/FirmwareUpdateV4.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkD,MAAM,qBAAqB,CAAC;AAyBlG,OAAO,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;AAkC/E,OAAO,KAAK,EAEV,sBAAsB,EAEvB,MAAM,6BAA6B,CAAC;AAmFrC,wBAAgB,wCAAwC,CACtD,UAAU,EAAE,WAAW,GAAG,MAAM,GAAG,SAAS,EAC5C,MAAM,EAAE,sBAAsB,EAC9B,0BAA0B,UAAQ,QAiCnC;AAsVD,eAAO,MAAM,oCAAoC,WACvC,WAAW,GAAG,UAAU,eACnB,MAAM,GAAG,SAAS,YAKhC,CAAC;AAEF,eAAO,MAAM,iCAAiC,0BACrB,MAAM,uBACR,MAAM,iBACZ,MAAM,eACR,MAAM,SAsBpB,CAAC;AAUF,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,wBAAwB,CAAC,sBAAsB,CAAC;IAC5F,OAAO,CAAC,8BAA8B,CAAC,CAAS;IAEhD,OAAO,CAAC,sBAAsB,CAAC,CAAS;IAExC,OAAO,CAAC,oCAAoC,CAAS;IAErD,qBAAqB;IAIrB,OAAO,CAAC,yBAAyB,CAA4B;IAE7D,OAAO,CAAC,2BAA2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+BAA+B;IAkD7C,OAAO,CAAC,6BAA6B;YAkCvB,6BAA6B;YA0B7B,0CAA0C;YA6B1C,uBAAuB;YAiCvB,8BAA8B;YAsE9B,6BAA6B;IAuE3C,OAAO,CAAC,mCAAmC;YAI7B,0BAA0B;IAaxC,OAAO,CAAC,4BAA4B;IAyGpC,OAAO,CAAC,6BAA6B;IAcrC,OAAO,CAAC,qCAAqC;IAyB7C,OAAO,CAAC,kCAAkC;YAgB5B,uCAAuC;YAuPvC,gCAAgC;YAehC,yBAAyB;IASvC,OAAO,CAAC,2BAA2B;YAMrB,8BAA8B;IAQ5C,OAAO,CAAC,0BAA0B;YAkBpB,mCAAmC;YAWnC,qCAAqC;YAgDrC,yBAAyB;YA8DzB,8BAA8B;IAU5C,OAAO,CAAC,kCAAkC;YAQ5B,cAAc;YAuCd,6BAA6B;YAW7B,0BAA0B;YAS1B,6BAA6B;YAa7B,gBAAgB;IAiB9B,OAAO,CAAC,qBAAqB;CAM9B"}
@@ -1 +1 @@
1
- {"version":3,"file":"DeviceSettings.d.ts","sourceRoot":"","sources":["../../../src/api/device/DeviceSettings.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAgB3C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AA0D5D,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,UAAU,CAAC,aAAa,CAAC;IACnE,qBAAqB;IAIrB,IAAI;IAwEJ,eAAe;;;;;;;IAWT,GAAG;CAyIV"}
1
+ {"version":3,"file":"DeviceSettings.d.ts","sourceRoot":"","sources":["../../../src/api/device/DeviceSettings.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAa3C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AA0D5D,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,UAAU,CAAC,aAAa,CAAC;IACnE,qBAAqB;IAIrB,IAAI;IA0EJ,eAAe;;;;;;;IAWT,GAAG;CAyIV"}
@@ -1 +1 @@
1
- {"version":3,"file":"DeviceUploadResource.d.ts","sourceRoot":"","sources":["../../../src/api/device/DeviceUploadResource.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAK3C,OAAO,KAAK,EAA8B,4BAA4B,EAAE,MAAM,aAAa,CAAC;AAC5F,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAE7D,MAAM,CAAC,OAAO,OAAO,oBAAqB,SAAQ,UAAU,CAAC,cAAc,CAAC;IAC1E,UAAU;;;;MAIR;IAEF,OAAO,CAAC,cAAc,CAIpB;IAEF,eAAe;;;;;IAQf,qBAAqB;IAgBrB,IAAI;IA+CJ,OAAO,CAAC,YAAY;IAMpB,OAAO,CAAC,cAAc;IAoBtB,sBAAsB,QAEhB,qBAAqB,iBAAiB,CAAC,GACvC,qBAAqB,aAAa,CAAC,GACnC,qBAAqB,aAAa,CAAC,GACnC,qBAAqB,SAAS,CAAC,KAClC,QAAQ,4BAA4B,CAAC,CAuDtC;IAEI,GAAG;CAaV"}
1
+ {"version":3,"file":"DeviceUploadResource.d.ts","sourceRoot":"","sources":["../../../src/api/device/DeviceUploadResource.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAK3C,OAAO,KAAK,EAA8B,4BAA4B,EAAE,MAAM,aAAa,CAAC;AAC5F,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAE7D,MAAM,CAAC,OAAO,OAAO,oBAAqB,SAAQ,UAAU,CAAC,cAAc,CAAC;IAC1E,UAAU;;;;MAIR;IAEF,OAAO,CAAC,cAAc,CAIpB;IAEF,eAAe;;;;;IAQf,qBAAqB;IAgBrB,IAAI;IA+CJ,OAAO,CAAC,YAAY;IAMpB,OAAO,CAAC,cAAc;IAoBtB,sBAAsB,QAEhB,qBAAqB,iBAAiB,CAAC,GACvC,qBAAqB,aAAa,CAAC,GACnC,qBAAqB,aAAa,CAAC,GACnC,qBAAqB,SAAS,CAAC,KAClC,QAAQ,4BAA4B,CAAC,CAuDtC;IAEI,GAAG;CAiBV"}
package/dist/index.js CHANGED
@@ -44617,22 +44617,6 @@ const mapProtocolV2DeviceStatusToState = (status) => {
44617
44617
  raw: { protocolV2DeviceStatus: status },
44618
44618
  });
44619
44619
  };
44620
- const mapApplySettingsToState = (settings) => {
44621
- const identity = definedEntries({ label: settings.label });
44622
- const status = definedEntries({ passphraseProtection: settings.use_passphrase });
44623
- const stateSettings = definedEntries({
44624
- language: settings.language,
44625
- autoLockDelayMs: settings.auto_lock_delay_ms,
44626
- autoShutdownDelayMs: settings.auto_shutdown_delay_ms,
44627
- displayRotation: settings.display_rotation,
44628
- passphraseAlwaysOnDevice: settings.passphrase_always_on_device,
44629
- safetyChecks: normalizeSafetyCheckLevel(settings.safety_checks),
44630
- experimentalFeatures: settings.experimental_features,
44631
- hapticFeedback: settings.haptic_feedback,
44632
- bleEnabled: settings.use_ble,
44633
- });
44634
- return Object.assign(Object.assign(Object.assign({}, (Object.keys(identity).length ? { identity } : {})), (Object.keys(status).length ? { status } : {})), (Object.keys(stateSettings).length ? { settings: stateSettings } : {}));
44635
- };
44636
44620
  const mapDeviceSettingsToState = (settings) => {
44637
44621
  const identity = definedEntries({ label: settings.label });
44638
44622
  const status = definedEntries({ passphraseProtection: settings.passphrase_enable });
@@ -48434,6 +48418,8 @@ class DeviceSettings extends BaseMethod {
48434
48418
  })
48435
48419
  : getProtocolV2SettingsBehavior({ kind: 'page', page });
48436
48420
  this.unlockPolicy = behavior.unlockPolicy;
48421
+ this.protocolV2PreUnlockPinType =
48422
+ behavior.unlockPolicy === 'unlock-before-run' ? hdTransport.DeviceSessionPinType.Any : undefined;
48437
48423
  this.protocolV2UiInteraction = behavior.uiInteraction;
48438
48424
  }
48439
48425
  getVersionRange() {
@@ -48517,7 +48503,7 @@ class DeviceSettings extends BaseMethod {
48517
48503
  }
48518
48504
  const protocolV1Params = Object.assign(Object.assign({}, this.params), { auto_lock_delay_ms: normalizeProtocolV1DelayMs(this.params.auto_lock_delay_ms), auto_shutdown_delay_ms: normalizeProtocolV1DelayMs(this.params.auto_shutdown_delay_ms) });
48519
48505
  const res = yield this.device.commands.typedCall('ApplySettings', 'Success', protocolV1Params);
48520
- this.device.updateState(mapApplySettingsToState(protocolV1Params), 'settings-write');
48506
+ yield this.device.getDeviceState({ refreshSections: ['settings'] });
48521
48507
  return res.message;
48522
48508
  }
48523
48509
  catch (error) {
@@ -48716,7 +48702,11 @@ class DeviceUploadResource extends BaseMethod {
48716
48702
  this.checkUploadNFTSupport();
48717
48703
  }
48718
48704
  const res = yield this.device.commands.typedCall('ResourceUpload', ['ResourceRequest', 'ZoomRequest', 'BlurRequest', 'Success'], this.params);
48719
- return this.processResourceRequest(res);
48705
+ const result = yield this.processResourceRequest(res);
48706
+ if (this.payload.resType === hdTransport.Messages.ResourceType.WallPaper) {
48707
+ yield this.device.getDeviceState({ refreshSections: ['settings'] });
48708
+ }
48709
+ return result;
48720
48710
  });
48721
48711
  }
48722
48712
  }
@@ -53675,9 +53665,12 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
53675
53665
  return __awaiter(this, void 0, void 0, function* () {
53676
53666
  const features = yield this.device.probeProtocolV2RuntimeState(deviceInfo, PROTOCOL_V2_SHORT_RESPONSE_TIMEOUT);
53677
53667
  this.protocolV2LastRuntimeProbeFeatures = features;
53678
- return features.mode === 'normal' && !features.bootloaderMode;
53668
+ return this.isProtocolV2ApplicationMode(features);
53679
53669
  });
53680
53670
  }
53671
+ isProtocolV2ApplicationMode(features) {
53672
+ return ((features.mode === 'normal' || features.mode === 'notInitialized') && !features.bootloaderMode);
53673
+ }
53681
53674
  waitForProtocolV2FinalFeatures() {
53682
53675
  return __awaiter(this, void 0, void 0, function* () {
53683
53676
  const features = yield this.waitForProtocolV2ReconnectAndFeatures(PROTOCOL_V2_FINAL_RECONNECT_TIMEOUT);
@@ -53728,7 +53721,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
53728
53721
  });
53729
53722
  this.assertProtocolV2DeviceInfoIdentity(deviceInfo);
53730
53723
  const features = yield this.device.probeProtocolV2RuntimeState(deviceInfo, PROTOCOL_V2_SHORT_RESPONSE_TIMEOUT);
53731
- if (features.mode === 'normal' && !features.bootloaderMode) {
53724
+ if (this.isProtocolV2ApplicationMode(features)) {
53732
53725
  return features;
53733
53726
  }
53734
53727
  lastError = hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceNotFound, 'Protocol V2 device is still in bootloader mode');
@@ -54871,6 +54864,9 @@ const createProtocolV2UnlockContext = () => ({
54871
54864
  });
54872
54865
  const resolvePreUnlockPinType = (method) => {
54873
54866
  var _a, _b;
54867
+ if (method.protocolV2PreUnlockPinType !== undefined) {
54868
+ return method.protocolV2PreUnlockPinType;
54869
+ }
54874
54870
  const targetsKnownHiddenWallet = method.useDevicePassphraseState &&
54875
54871
  ((_a = method.payload) === null || _a === void 0 ? void 0 : _a.useEmptyPassphrase) !== true &&
54876
54872
  typeof ((_b = method.payload) === null || _b === void 0 ? void 0 : _b.passphraseState) === 'string' &&
@@ -5,7 +5,7 @@ export type ProtocolV2UnlockContext = {
5
5
  preflightCompleted: boolean;
6
6
  };
7
7
  export declare const createProtocolV2UnlockContext: () => ProtocolV2UnlockContext;
8
- type RunnableMethod = Pick<BaseMethod, 'run' | 'unlockPolicy' | 'useDevicePassphraseState' | 'protocolV2UiInteraction' | 'protocolV2UiMode' | 'params' | 'payload'> & {
8
+ type RunnableMethod = Pick<BaseMethod, 'run' | 'unlockPolicy' | 'useDevicePassphraseState' | 'protocolV2UiInteraction' | 'protocolV2UiMode' | 'protocolV2PreUnlockPinType' | 'params' | 'payload'> & {
9
9
  name?: string;
10
10
  protocolV2UnlockContext?: ProtocolV2UnlockContext;
11
11
  };
@@ -1 +1 @@
1
- {"version":3,"file":"unlockPolicyRunner.d.ts","sourceRoot":"","sources":["../../../src/protocols/protocol-v2/unlockPolicyRunner.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAElD,OAAO,KAAK,EAAE,kCAAkC,EAAE,MAAM,iBAAiB,CAAC;AAI1E,MAAM,MAAM,uBAAuB,GAAG;IACpC,kBAAkB,EAAE,OAAO,CAAC;CAC7B,CAAC;AAEF,eAAO,MAAM,6BAA6B,QAAO,uBAE/C,CAAC;AAEH,KAAK,cAAc,GAAG,IAAI,CACxB,UAAU,EACR,KAAK,GACL,cAAc,GACd,0BAA0B,GAC1B,yBAAyB,GACzB,kBAAkB,GAClB,QAAQ,GACR,SAAS,CACZ,GAAG;IACF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,uBAAuB,CAAC,EAAE,uBAAuB,CAAC;CACnD,CAAC;AAEF,KAAK,wBAAwB,GAAG,IAAI,CAClC,kCAAkC,EAClC,wBAAwB,GAAG,wBAAwB,CACpD,CAAC;AAEF,KAAK,gCAAgC,CAAC,CAAC,IAAI;IACzC,OAAO,CAAC,EAAE,uBAAuB,CAAC;IAClC,aAAa,CAAC,EAAE,wBAAwB,CAAC;IACzC,uBAAuB,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACrD,OAAO,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9B,GAAG,CAAC,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,CAAC;CACxB,CAAC;AAeF,wBAAsB,yBAAyB,CAAC,CAAC,GAAG,OAAO,EACzD,MAAM,EAAE,cAAc,EACtB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,EACtB,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,gCAAgC,CAAC,CAAC,CAAM,GAChD,OAAO,CAAC,CAAC,CAAC,CAiEZ"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/hd-core",
3
- "version": "1.2.0-alpha.119",
3
+ "version": "1.2.0-alpha.120",
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.119",
29
- "@onekeyfe/hd-transport": "1.2.0-alpha.119",
28
+ "@onekeyfe/hd-shared": "1.2.0-alpha.120",
29
+ "@onekeyfe/hd-transport": "1.2.0-alpha.120",
30
30
  "axios": "1.15.2",
31
31
  "bignumber.js": "^9.0.2",
32
32
  "buffer": "^6.0.3",
@@ -46,5 +46,5 @@
46
46
  "@types/w3c-web-usb": "^1.0.10",
47
47
  "@types/web-bluetooth": "^0.0.21"
48
48
  },
49
- "gitHead": "63d9140aec732cf5c3d74bec8d62e6344e14eb10"
49
+ "gitHead": "8aaff2584cedc5fcb5dc68e0ca19588e9965bb8a"
50
50
  }
@@ -6,7 +6,11 @@ import {
6
6
  createDeviceNotSupportMethodError,
7
7
  createNeedUpgradeFirmwareHardwareError,
8
8
  } from '@onekeyfe/hd-shared';
9
- import { Enum_SafetyCheckLevel, type ProtocolType } from '@onekeyfe/hd-transport';
9
+ import {
10
+ type DeviceSessionPinType,
11
+ Enum_SafetyCheckLevel,
12
+ type ProtocolType,
13
+ } from '@onekeyfe/hd-transport';
10
14
 
11
15
  import { createDeviceMessage } from '../events/device';
12
16
  import { UI_REQUEST } from '../constants/ui-request';
@@ -167,6 +171,9 @@ export abstract class BaseMethod<Params = undefined> {
167
171
  /** Non-wallet methods may explicitly require Protocol V2 pre-unlock. */
168
172
  unlockPolicy: UnlockPolicy = 'none';
169
173
 
174
+ /** PIN type accepted by an explicit Protocol V2 pre-unlock. */
175
+ protocolV2PreUnlockPinType?: DeviceSessionPinType;
176
+
170
177
  /** Shared by composite methods so nested calls do not repeat the root preflight. */
171
178
  protocolV2UnlockContext?: ProtocolV2UnlockContext;
172
179
 
@@ -2896,7 +2896,13 @@ export default class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod<FirmwareU
2896
2896
  PROTOCOL_V2_SHORT_RESPONSE_TIMEOUT
2897
2897
  );
2898
2898
  this.protocolV2LastRuntimeProbeFeatures = features;
2899
- return features.mode === 'normal' && !features.bootloaderMode;
2899
+ return this.isProtocolV2ApplicationMode(features);
2900
+ }
2901
+
2902
+ private isProtocolV2ApplicationMode(features: Features) {
2903
+ return (
2904
+ (features.mode === 'normal' || features.mode === 'notInitialized') && !features.bootloaderMode
2905
+ );
2900
2906
  }
2901
2907
 
2902
2908
  private async waitForProtocolV2FinalFeatures() {
@@ -2958,7 +2964,7 @@ export default class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod<FirmwareU
2958
2964
  deviceInfo,
2959
2965
  PROTOCOL_V2_SHORT_RESPONSE_TIMEOUT
2960
2966
  );
2961
- if (features.mode === 'normal' && !features.bootloaderMode) {
2967
+ if (this.isProtocolV2ApplicationMode(features)) {
2962
2968
  return features;
2963
2969
  }
2964
2970
  lastError = ERRORS.TypedError(
@@ -1,13 +1,10 @@
1
1
  import { HardwareErrorCode, TypedError } from '@onekeyfe/hd-shared';
2
- import { DeviceSettingsPage } from '@onekeyfe/hd-transport';
2
+ import { DeviceSessionPinType, DeviceSettingsPage } from '@onekeyfe/hd-transport';
3
3
 
4
4
  import { BaseMethod } from '../BaseMethod';
5
5
  import { invalidParameter } from '../helpers/filesystemValidation';
6
6
  import { validateParams } from '../helpers/paramsValidator';
7
- import {
8
- mapApplySettingsToState,
9
- mapCommonSettingsToProtocolV2,
10
- } from '../../device/DeviceStateMapper';
7
+ import { mapCommonSettingsToProtocolV2 } from '../../device/DeviceStateMapper';
11
8
  import { getProtocolV2SettingsBehavior } from '../../protocols/protocol-v2/settingsUnlockPolicy';
12
9
  import {
13
10
  DEVICE_SETTINGS_NEVER_TIMEOUT_MS,
@@ -149,6 +146,8 @@ export default class DeviceSettings extends BaseMethod<ApplySettings> {
149
146
  })
150
147
  : getProtocolV2SettingsBehavior({ kind: 'page', page });
151
148
  this.unlockPolicy = behavior.unlockPolicy;
149
+ this.protocolV2PreUnlockPinType =
150
+ behavior.unlockPolicy === 'unlock-before-run' ? DeviceSessionPinType.Any : undefined;
152
151
  this.protocolV2UiInteraction = behavior.uiInteraction;
153
152
  }
154
153
 
@@ -269,7 +268,7 @@ export default class DeviceSettings extends BaseMethod<ApplySettings> {
269
268
  'Success',
270
269
  protocolV1Params
271
270
  );
272
- this.device.updateState(mapApplySettingsToState(protocolV1Params), 'settings-write');
271
+ await this.device.getDeviceState({ refreshSections: ['settings'] });
273
272
  return res.message;
274
273
  } catch (error) {
275
274
  if (error.message?.toLowerCase().includes('no setting provided')) {
@@ -198,6 +198,10 @@ export default class DeviceUploadResource extends BaseMethod<ResourceUpload> {
198
198
  this.params
199
199
  );
200
200
 
201
- return this.processResourceRequest(res);
201
+ const result = await this.processResourceRequest(res);
202
+ if (this.payload.resType === PROTO.ResourceType.WallPaper) {
203
+ await this.device.getDeviceState({ refreshSections: ['settings'] });
204
+ }
205
+ return result;
202
206
  }
203
207
  }
@@ -27,6 +27,7 @@ type RunnableMethod = Pick<
27
27
  | 'useDevicePassphraseState'
28
28
  | 'protocolV2UiInteraction'
29
29
  | 'protocolV2UiMode'
30
+ | 'protocolV2PreUnlockPinType'
30
31
  | 'params'
31
32
  | 'payload'
32
33
  > & {
@@ -48,6 +49,9 @@ type RunMethodWithUnlockPolicyOptions<T> = {
48
49
  };
49
50
 
50
51
  const resolvePreUnlockPinType = (method: RunnableMethod) => {
52
+ if (method.protocolV2PreUnlockPinType !== undefined) {
53
+ return method.protocolV2PreUnlockPinType;
54
+ }
51
55
  const targetsKnownHiddenWallet =
52
56
  method.useDevicePassphraseState &&
53
57
  method.payload?.useEmptyPassphrase !== true &&