@onekeyfe/hd-core 1.2.0-alpha.132 → 1.2.0-alpha.133

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.
@@ -279,7 +279,7 @@ describe('DeviceSettings protocol routing', () => {
279
279
  );
280
280
  });
281
281
 
282
- it('uses the Pro2 passphrase page as a device-side toggle and verifies the target state', async () => {
282
+ it('uses the Pro2 passphrase page and refreshes device state after the toggle', async () => {
283
283
  const { device, typedCall, getDeviceState } = createDevice({ protocol: 'V2' });
284
284
  getDeviceState
285
285
  .mockResolvedValueOnce({
@@ -403,6 +403,67 @@ describe('DeviceSettings protocol routing', () => {
403
403
  expect(updateState).not.toHaveBeenCalled();
404
404
  });
405
405
 
406
+ it('preserves confirmed Pro2 passphrase state when the post-toggle status is locked', async () => {
407
+ let statusReadCount = 0;
408
+ const typedCall = jest.fn().mockImplementation((requestType: string) => {
409
+ if (requestType === 'DeviceStatusGet') {
410
+ statusReadCount += 1;
411
+ return {
412
+ message:
413
+ statusReadCount === 1
414
+ ? { init_states: true, unlocked: true, passphrase_enabled: true }
415
+ : { init_states: true, unlocked: false, passphrase_enabled: false },
416
+ };
417
+ }
418
+ if (requestType === 'DeviceSettingsPageShow') {
419
+ return { message: { message: 'Success' } };
420
+ }
421
+ if (requestType === 'DeviceSettingsGet') {
422
+ return { message: { label: 'Pro 2' } };
423
+ }
424
+ throw new Error(`Unexpected request: ${requestType}`);
425
+ });
426
+ const device = Device.fromDescriptor({
427
+ id: 'pro2-passphrase',
428
+ path: 'pro2-passphrase',
429
+ protocolType: 'V2',
430
+ } as never);
431
+ (device as any).commands = { typedCall };
432
+ device.updateState(
433
+ {
434
+ protocol: 'V2',
435
+ identity: { deviceType: EDeviceType.Pro2 },
436
+ status: {
437
+ mode: 'normal',
438
+ unlocked: true,
439
+ passphraseProtection: true,
440
+ },
441
+ raw: {
442
+ protocolV2ProtocolInfo: {
443
+ version: 1,
444
+ supported_messages: [PROTOCOL_V2_DEVICE_STATUS_GET_MESSAGE_TYPE],
445
+ },
446
+ },
447
+ },
448
+ 'initialize'
449
+ );
450
+ const method = new DeviceSettings({
451
+ id: 6,
452
+ payload: {
453
+ method: 'deviceSettings',
454
+ usePassphrase: false,
455
+ },
456
+ });
457
+ method.init();
458
+ (method as any).device = device;
459
+
460
+ await expect(method.run()).resolves.toEqual({ message: 'Success' });
461
+ expect(device.state?.status).toMatchObject({
462
+ unlocked: false,
463
+ passphraseProtection: true,
464
+ });
465
+ });
466
+
406
467
  it('keeps Protocol V1 passphrase settings on ApplySettings', async () => {
407
468
  const { device, typedCall, getDeviceState } = createDevice({ protocol: 'V1' });
408
469
  const method = new DeviceSettings({
@@ -265,6 +265,36 @@ describe('DeviceUploadWallpaper', () => {
265
265
  expect(typedCall.mock.calls.some(call => call[0] === 'DeviceSettingsSet')).toBe(false);
266
266
  });
267
267
 
268
+ test('returns success when wallpaper read-back fails after apply', async () => {
269
+ const typedCall = jest.fn().mockImplementation((request, _response, params) => {
270
+ if (request === 'FilesystemDirMake') return { message: {} };
271
+ if (request === 'FilesystemFileWrite') {
272
+ const file = params.file as { data: Uint8Array; offset: number };
273
+ return { message: { processed_byte: file.offset + file.data.byteLength } };
274
+ }
275
+ if (request === 'DeviceSettingsSet') {
276
+ return { message: { message: 'wallpaper applied' } };
277
+ }
278
+ throw new Error(`Unexpected request: ${request}`);
279
+ });
280
+ const method = new DeviceUploadWallpaper({
281
+ id: 1,
282
+ payload: {
283
+ method: 'deviceUploadWallpaper',
284
+ jpegBase64: createJpegBase64(604, 1024),
285
+ },
286
+ });
287
+ const device = stubWallpaperDevice({ commands: { typedCall } });
288
+ device.refreshProtocolV2SettingsAfterMutation.mockRejectedValueOnce(
289
+ new Error('settings read-back failed')
290
+ );
291
+ (method as any).device = device;
292
+ method.init();
293
+
294
+ await expect(method.run()).resolves.toMatchObject({ message: 'wallpaper applied' });
295
+ expect(device.refreshProtocolV2SettingsAfterMutation).toHaveBeenCalledTimes(1);
296
+ });
297
+
268
298
  test('rejects unsafe filenames before device communication', () => {
269
299
  const method = new DeviceUploadWallpaper({
270
300
  id: 1,
@@ -1 +1 @@
1
- {"version":3,"file":"DeviceUploadWallpaper.d.ts","sourceRoot":"","sources":["../../../src/api/protocol-v2/DeviceUploadWallpaper.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAM3C,OAAO,EAGL,KAAK,wBAAwB,EAE9B,MAAM,2BAA2B,CAAC;AAEnC,MAAM,MAAM,2BAA2B,GAAG;IACxC,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,6BAA6B,GAAG;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,wBAAwB,CAAC;IACtC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAkBF,MAAM,CAAC,OAAO,OAAO,qBAAsB,SAAQ,UAAU,CAAC,2BAA2B,CAAC;IACxF,qBAAqB;IAIrB,OAAO,CAAC,OAAO,CAAC,CAA8D;IAE9E,OAAO,CAAC,cAAc,CAAS;IAE/B,OAAO,CAAC,QAAQ,CAAS;IAEzB,OAAO,CAAC,IAAI,CAAM;IAElB,IAAI;YAwBU,kBAAkB;YAgBlB,eAAe;YAaf,MAAM;IAwBd,GAAG,IAAI,OAAO,CAAC,6BAA6B,CAAC;CAiBpD"}
1
+ {"version":3,"file":"DeviceUploadWallpaper.d.ts","sourceRoot":"","sources":["../../../src/api/protocol-v2/DeviceUploadWallpaper.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAO3C,OAAO,EAGL,KAAK,wBAAwB,EAE9B,MAAM,2BAA2B,CAAC;AAEnC,MAAM,MAAM,2BAA2B,GAAG;IACxC,UAAU,EAAE,MAAM,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