@onekeyfe/hd-core 1.2.0-alpha.146 → 1.2.0-alpha.148
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__tests__/device-lifecycle-events.test.ts +105 -1
- package/__tests__/protocol-v2-unlock-policy.test.ts +37 -0
- package/__tests__/protocol-v2.test.ts +2 -0
- package/dist/api/device/DeviceRebootToBoardloader.d.ts.map +1 -1
- package/dist/api/device/DeviceRebootToBootloader.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceReboot.d.ts +1 -1
- package/dist/api/protocol-v2/DeviceReboot.d.ts.map +1 -1
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/device/Device.d.ts +4 -0
- package/dist/device/Device.d.ts.map +1 -1
- package/dist/index.d.ts +13 -0
- package/dist/index.js +69 -16
- package/package.json +4 -4
- package/src/api/device/DeviceRebootToBoardloader.ts +3 -1
- package/src/api/device/DeviceRebootToBootloader.ts +3 -1
- package/src/api/protocol-v2/DeviceReboot.ts +5 -0
- package/src/core/index.ts +17 -7
- package/src/device/Device.ts +59 -8
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
initConnector,
|
|
6
6
|
initCore,
|
|
7
7
|
isMissingDetectedProtocolV2Error,
|
|
8
|
+
isRetryableBleConnectionError,
|
|
8
9
|
isRetryableBleProtocolV2ProbeError,
|
|
9
10
|
} from '../src/core';
|
|
10
11
|
import { DataManager } from '../src/data-manager';
|
|
@@ -291,6 +292,21 @@ describe('public device lifecycle events', () => {
|
|
|
291
292
|
}
|
|
292
293
|
);
|
|
293
294
|
|
|
295
|
+
test.each([
|
|
296
|
+
[HardwareErrorCode.BleConnectedError, true],
|
|
297
|
+
[HardwareErrorCode.BleTimeoutError, true],
|
|
298
|
+
[HardwareErrorCode.PollingTimeout, false],
|
|
299
|
+
[HardwareErrorCode.BleDeviceBondError, false],
|
|
300
|
+
] as const)('retries a BLE connection error with error code %s: %s', (errorCode, expected) => {
|
|
301
|
+
const method = { payload: { connectProtocol: 'V2' } } as never;
|
|
302
|
+
const error = {
|
|
303
|
+
errorCode,
|
|
304
|
+
message: 'BLE setup wedged repeatedly',
|
|
305
|
+
};
|
|
306
|
+
|
|
307
|
+
expect(isRetryableBleConnectionError(method, error)).toBe(expected);
|
|
308
|
+
});
|
|
309
|
+
|
|
294
310
|
test('converts an internal transport disconnect into a public KnownDevice snapshot', () => {
|
|
295
311
|
jest.spyOn(DataManager, 'getSettings').mockReturnValue('react-native' as never);
|
|
296
312
|
core = initCore();
|
|
@@ -368,7 +384,7 @@ describe('public device lifecycle events', () => {
|
|
|
368
384
|
);
|
|
369
385
|
|
|
370
386
|
test.each(['react-native', 'webusb', 'desktop-webusb'] as const)(
|
|
371
|
-
'sends a fallback Cancel for an acquired Protocol V2 %s call
|
|
387
|
+
'sends a fallback Cancel for an acquired Protocol V2 %s call with an open UI',
|
|
372
388
|
async env => {
|
|
373
389
|
jest.spyOn(DataManager, 'getSettings').mockReturnValue(env as never);
|
|
374
390
|
const device = createInitializedDevice('V2');
|
|
@@ -382,6 +398,7 @@ describe('public device lifecycle events', () => {
|
|
|
382
398
|
cancelDevice,
|
|
383
399
|
cancel,
|
|
384
400
|
} as never;
|
|
401
|
+
device.createProtocolV2UiPhaseMetadata('button', 'start');
|
|
385
402
|
|
|
386
403
|
await device.interruptionFromUser();
|
|
387
404
|
|
|
@@ -391,6 +408,93 @@ describe('public device lifecycle events', () => {
|
|
|
391
408
|
}
|
|
392
409
|
);
|
|
393
410
|
|
|
411
|
+
test.each(['react-native', 'webusb', 'desktop-webusb'] as const)(
|
|
412
|
+
'does not send Cancel for an acquired Protocol V2 %s connect without an open UI',
|
|
413
|
+
async env => {
|
|
414
|
+
jest.spyOn(DataManager, 'getSettings').mockReturnValue(env as never);
|
|
415
|
+
const device = createInitializedDevice('V2');
|
|
416
|
+
const post = jest.fn().mockResolvedValue(undefined);
|
|
417
|
+
const cancelDevice = jest.fn(() => cancelDeviceInPrompt(device, false));
|
|
418
|
+
const cancel = jest.fn().mockResolvedValue(undefined);
|
|
419
|
+
const disconnect = jest.fn().mockResolvedValue(undefined);
|
|
420
|
+
device.originalDescriptor.session = device.mainId;
|
|
421
|
+
(device as unknown as { deviceAcquired: boolean }).deviceAcquired = true;
|
|
422
|
+
device.deviceConnector = { disconnect } as never;
|
|
423
|
+
device.commands = {
|
|
424
|
+
transport: { post },
|
|
425
|
+
cancelDevice,
|
|
426
|
+
cancel,
|
|
427
|
+
} as never;
|
|
428
|
+
|
|
429
|
+
await device.interruptionFromUser();
|
|
430
|
+
|
|
431
|
+
expect(cancelDevice).not.toHaveBeenCalled();
|
|
432
|
+
expect(post).not.toHaveBeenCalled();
|
|
433
|
+
expect(disconnect).not.toHaveBeenCalled();
|
|
434
|
+
expect(cancel).toHaveBeenCalledTimes(1);
|
|
435
|
+
}
|
|
436
|
+
);
|
|
437
|
+
|
|
438
|
+
test('disconnects a BLE link without sending Cancel when the session is not acquired', async () => {
|
|
439
|
+
jest.spyOn(DataManager, 'getSettings').mockReturnValue('react-native' as never);
|
|
440
|
+
const device = createInitializedDevice('V2');
|
|
441
|
+
const post = jest.fn().mockResolvedValue(undefined);
|
|
442
|
+
const cancelDevice = jest.fn(() => cancelDeviceInPrompt(device, false));
|
|
443
|
+
const cancel = jest.fn().mockResolvedValue(undefined);
|
|
444
|
+
const disconnect = jest.fn().mockResolvedValue(undefined);
|
|
445
|
+
device.deviceConnector = { disconnect } as never;
|
|
446
|
+
device.commands = {
|
|
447
|
+
transport: { post },
|
|
448
|
+
cancelDevice,
|
|
449
|
+
cancel,
|
|
450
|
+
} as never;
|
|
451
|
+
|
|
452
|
+
await device.interruptionFromUser();
|
|
453
|
+
|
|
454
|
+
expect(cancelDevice).not.toHaveBeenCalled();
|
|
455
|
+
expect(post).not.toHaveBeenCalled();
|
|
456
|
+
expect(disconnect).toHaveBeenCalledWith(device.mainId);
|
|
457
|
+
expect(device.hasDeviceAcquire()).toBe(false);
|
|
458
|
+
expect(device.wasInterruptedByUser()).toBe(true);
|
|
459
|
+
expect(cancel).toHaveBeenCalledTimes(1);
|
|
460
|
+
});
|
|
461
|
+
|
|
462
|
+
test('does not finish acquire after the user already cancelled', async () => {
|
|
463
|
+
jest.spyOn(DataManager, 'getSettings').mockReturnValue('react-native' as never);
|
|
464
|
+
const device = createInitializedDevice('V2');
|
|
465
|
+
const disconnect = jest.fn().mockResolvedValue(undefined);
|
|
466
|
+
let resolveAcquire: ((value: { uuid: string; protocolType: 'V2' }) => void) | undefined;
|
|
467
|
+
const acquire = jest.fn(
|
|
468
|
+
() =>
|
|
469
|
+
new Promise<{ uuid: string; protocolType: 'V2' }>(resolve => {
|
|
470
|
+
resolveAcquire = resolve;
|
|
471
|
+
})
|
|
472
|
+
);
|
|
473
|
+
device.deviceConnector = { acquire, disconnect } as never;
|
|
474
|
+
|
|
475
|
+
const acquirePromise = device.acquire('V2');
|
|
476
|
+
await device.interruptionFromUser();
|
|
477
|
+
resolveAcquire?.({ uuid: 'late-session', protocolType: 'V2' });
|
|
478
|
+
|
|
479
|
+
await expect(acquirePromise).rejects.toMatchObject({
|
|
480
|
+
errorCode: HardwareErrorCode.DeviceInterruptedFromUser,
|
|
481
|
+
});
|
|
482
|
+
expect(disconnect).toHaveBeenCalledWith('late-session');
|
|
483
|
+
expect(device.hasDeviceAcquire()).toBe(false);
|
|
484
|
+
});
|
|
485
|
+
|
|
486
|
+
test('does not retry a BLE connection error after the user cancelled', () => {
|
|
487
|
+
const device = createInitializedDevice('V2');
|
|
488
|
+
(device as unknown as { interruptedByUser: boolean }).interruptedByUser = true;
|
|
489
|
+
const method = { payload: { connectProtocol: 'V2' }, device } as never;
|
|
490
|
+
const error = {
|
|
491
|
+
errorCode: HardwareErrorCode.BleConnectedError,
|
|
492
|
+
message: 'BLE setup wedged repeatedly',
|
|
493
|
+
};
|
|
494
|
+
|
|
495
|
+
expect(isRetryableBleConnectionError(method, error)).toBe(false);
|
|
496
|
+
});
|
|
497
|
+
|
|
394
498
|
test('waits for the canceled run to finish releasing before cancellation completes', async () => {
|
|
395
499
|
jest.spyOn(DataManager, 'getSettings').mockReturnValue('react-native' as never);
|
|
396
500
|
const device = createInitializedDevice('V2');
|
|
@@ -4,9 +4,12 @@ import { encode as encodeJpeg } from 'jpeg-js';
|
|
|
4
4
|
import ConfluxSignMessageCIP23 from '../src/api/conflux/ConfluxSignMessageCIP23';
|
|
5
5
|
import DeviceChangePin from '../src/api/device/DeviceChangePin';
|
|
6
6
|
import DeviceLock from '../src/api/device/DeviceLock';
|
|
7
|
+
import DeviceRebootToBoardloader from '../src/api/device/DeviceRebootToBoardloader';
|
|
8
|
+
import DeviceRebootToBootloader from '../src/api/device/DeviceRebootToBootloader';
|
|
7
9
|
import DeviceSettings from '../src/api/device/DeviceSettings';
|
|
8
10
|
import DeviceVerify from '../src/api/device/DeviceVerify';
|
|
9
11
|
import DeviceWipe from '../src/api/device/DeviceWipe';
|
|
12
|
+
import DeviceReboot from '../src/api/protocol-v2/DeviceReboot';
|
|
10
13
|
import DeviceUploadNft from '../src/api/protocol-v2/DeviceUploadNft';
|
|
11
14
|
import DeviceUploadWallpaper from '../src/api/protocol-v2/DeviceUploadWallpaper';
|
|
12
15
|
import FirmwareUpdateV4 from '../src/api/FirmwareUpdateV4';
|
|
@@ -73,6 +76,40 @@ describe('Protocol V2 unlock semantics', () => {
|
|
|
73
76
|
expect(method.getSupportedProtocols()).toContain('V2');
|
|
74
77
|
});
|
|
75
78
|
|
|
79
|
+
test.each([
|
|
80
|
+
[
|
|
81
|
+
'deviceReboot',
|
|
82
|
+
() =>
|
|
83
|
+
new DeviceReboot({
|
|
84
|
+
id: 1,
|
|
85
|
+
payload: { method: 'deviceReboot', rebootType: 2 },
|
|
86
|
+
}),
|
|
87
|
+
],
|
|
88
|
+
[
|
|
89
|
+
'deviceRebootToBootloader',
|
|
90
|
+
() =>
|
|
91
|
+
new DeviceRebootToBootloader({
|
|
92
|
+
id: 1,
|
|
93
|
+
payload: { method: 'deviceRebootToBootloader' },
|
|
94
|
+
}),
|
|
95
|
+
],
|
|
96
|
+
[
|
|
97
|
+
'deviceRebootToBoardloader',
|
|
98
|
+
() =>
|
|
99
|
+
new DeviceRebootToBoardloader({
|
|
100
|
+
id: 1,
|
|
101
|
+
payload: { method: 'deviceRebootToBoardloader' },
|
|
102
|
+
}),
|
|
103
|
+
],
|
|
104
|
+
])('pre-unlocks %s before sending DeviceReboot', (_name, createMethod) => {
|
|
105
|
+
const method = createMethod();
|
|
106
|
+
method.init();
|
|
107
|
+
|
|
108
|
+
expect(method.unlockPolicy).toBe('unlock-before-run');
|
|
109
|
+
expect(method.protocolV2PreUnlockPinType).toBe(DeviceSessionPinType.Any);
|
|
110
|
+
expect(method.useDevicePassphraseState).toBe(false);
|
|
111
|
+
});
|
|
112
|
+
|
|
76
113
|
test('lock-free Protocol V2 controls explicitly opt out of wallet-session handling', () => {
|
|
77
114
|
const method = new DeviceLock({
|
|
78
115
|
id: 1,
|
|
@@ -9295,6 +9295,8 @@ describe('Protocol V2 reboot methods', () => {
|
|
|
9295
9295
|
const device = stubDevice({ commands: { typedCall } });
|
|
9296
9296
|
(method as any).device = device;
|
|
9297
9297
|
|
|
9298
|
+
expect(method.unlockPolicy).toBe('unlock-before-run');
|
|
9299
|
+
|
|
9298
9300
|
await method.run();
|
|
9299
9301
|
|
|
9300
9302
|
expect(typedCall).toHaveBeenCalledWith('DeviceReboot', 'Success', {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeviceRebootToBoardloader.d.ts","sourceRoot":"","sources":["../../../src/api/device/DeviceRebootToBoardloader.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,2CAA2C,CAAC;AAG3F,MAAM,CAAC,OAAO,OAAO,yBAA0B,SAAQ,UAAU,CAAC,yBAAyB,CAAC;IAC1F,qBAAqB;IAIrB,IAAI;
|
|
1
|
+
{"version":3,"file":"DeviceRebootToBoardloader.d.ts","sourceRoot":"","sources":["../../../src/api/device/DeviceRebootToBoardloader.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,2CAA2C,CAAC;AAG3F,MAAM,CAAC,OAAO,OAAO,yBAA0B,SAAQ,UAAU,CAAC,yBAAyB,CAAC;IAC1F,qBAAqB;IAIrB,IAAI;IAOJ,eAAe;;;;;;;;IAWT,GAAG;CAeV"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeviceRebootToBootloader.d.ts","sourceRoot":"","sources":["../../../src/api/device/DeviceRebootToBootloader.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAGjE,MAAM,CAAC,OAAO,OAAO,wBAAyB,SAAQ,UAAU,CAAC,kBAAkB,CAAC;IAClF,qBAAqB;IAIrB,IAAI;
|
|
1
|
+
{"version":3,"file":"DeviceRebootToBootloader.d.ts","sourceRoot":"","sources":["../../../src/api/device/DeviceRebootToBootloader.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAGjE,MAAM,CAAC,OAAO,OAAO,wBAAyB,SAAQ,UAAU,CAAC,kBAAkB,CAAC;IAClF,qBAAqB;IAIrB,IAAI;IAOJ,eAAe;;;;;;;;IAWT,GAAG;CAaV"}
|
|
@@ -3,6 +3,6 @@ import type { DeviceRebootParams } from './helpers';
|
|
|
3
3
|
export default class DeviceReboot extends BaseMethod<DeviceRebootParams> {
|
|
4
4
|
getSupportedProtocols(): readonly ["V2"];
|
|
5
5
|
init(): void;
|
|
6
|
-
run(): Promise<import("
|
|
6
|
+
run(): Promise<import("@onekeyfe/hd-transport").Success>;
|
|
7
7
|
}
|
|
8
8
|
//# sourceMappingURL=DeviceReboot.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeviceReboot.d.ts","sourceRoot":"","sources":["../../../src/api/protocol-v2/DeviceReboot.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DeviceReboot.d.ts","sourceRoot":"","sources":["../../../src/api/protocol-v2/DeviceReboot.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG3C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAEpD,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,UAAU,CAAC,kBAAkB,CAAC;IACtE,qBAAqB;IAIrB,IAAI;IAYE,GAAG;CAQV"}
|
package/dist/core/index.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ import type { BaseMethod } from '../api/BaseMethod';
|
|
|
9
9
|
export type CoreContext = ReturnType<Core['getCoreContext']>;
|
|
10
10
|
export declare const callAPI: (context: CoreContext, message: CoreMessage) => Promise<any>;
|
|
11
11
|
export declare function isRetryableBleProtocolV2ProbeError(method: BaseMethod, error: unknown): boolean;
|
|
12
|
+
export declare function isRetryableBleConnectionError(method: BaseMethod, error: unknown): boolean;
|
|
12
13
|
export declare function isMissingDetectedProtocolV2Error(method: BaseMethod, error: unknown): boolean;
|
|
13
14
|
export declare const cancel: (context: CoreContext, connectId?: string) => void;
|
|
14
15
|
export declare const onDeviceButtonHandler: (__0_0: Device, __0_1: import("../events").DeviceButtonRequestPayload) => void;
|
package/dist/core/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":";AACA,OAAO,YAAY,MAAM,QAAQ,CAAC;AAoClC,OAAO,EAAE,M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E,UAAU,EAAE,KAAK,EAAE,OAAO,WAWpF;AAED,wBAAgB,6BAA6B,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,WAW/E;AAED,wBAAgB,gCAAgC,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,WAQlF;AAmPD,eAAO,MAAM,MAAM,YAAa,WAAW,cAAc,MAAM,SAqF9D,CAAC;AAmGF,eAAO,MAAM,qBAAqB,gFAejC,CAAC;AAiLF,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,YAAY;IAC5C,OAAO,CAAC,cAAc,CAAoB;IAE1C,SAAgB,aAAa,EAAE,MAAM,CAAC;IAEtC,OAAO,CAAC,YAAY,CAAsB;IAE1C,OAAO,CAAC,cAAc,CAAC,CAAgB;IAGvC,OAAO,CAAC,sBAAsB,CAAoC;IAElE,OAAO,CAAC,iBAAiB,CAAoB;;IAS7C,OAAO,CAAC,cAAc;IA6BhB,aAAa,CAAC,OAAO,EAAE,WAAW;IAuExC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;YAOV,gBAAgB;CAiC/B;AAED,eAAO,MAAM,QAAQ,YAIpB,CAAC;AAEF,eAAO,MAAM,aAAa,uBAYzB,CAAC;AAMF,eAAO,MAAM,IAAI,aACL,eAAe,aACd,GAAG,WACL,6BAA6B,8BAiBvC,CAAC;AAEF,eAAO,MAAM,eAAe;SAKrB,eAAe,CAAC,KAAK,CAAC;eAChB,GAAG;;UASf,CAAC"}
|
package/dist/device/Device.d.ts
CHANGED
|
@@ -67,6 +67,7 @@ export declare class Device extends EventEmitter {
|
|
|
67
67
|
commands: DeviceCommands;
|
|
68
68
|
private cancelableAction?;
|
|
69
69
|
private deviceAcquired;
|
|
70
|
+
private interruptedByUser;
|
|
70
71
|
private stateStore;
|
|
71
72
|
private protocolV2StateNeedsReload;
|
|
72
73
|
private protocolV2RuntimeContext?;
|
|
@@ -180,6 +181,9 @@ export declare class Device extends EventEmitter {
|
|
|
180
181
|
getFirmwareVersion(): import("../types").IVersionArray | null;
|
|
181
182
|
getBLEFirmwareVersion(): import("../types").IVersionArray | null;
|
|
182
183
|
isUsed(): boolean;
|
|
184
|
+
wasInterruptedByUser(): boolean;
|
|
185
|
+
private throwIfInterruptedByUser;
|
|
186
|
+
private shouldSendFallbackProtocolCancel;
|
|
183
187
|
hasDeviceAcquire(): boolean;
|
|
184
188
|
isUsedHere(): boolean;
|
|
185
189
|
isUsedElsewhere(): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Device.d.ts","sourceRoot":"","sources":["../../src/device/Device.ts"],"names":[],"mappings":";AAAA,OAAO,YAAY,MAAM,QAAQ,CAAC;AAElC,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAmB,MAAM,wBAAwB,CAAC;AACjG,OAAO,EAEL,aAAa,EAQd,MAAM,qBAAqB,CAAC;AAU7B,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAalD,OAAO,EACL,KAAK,mBAAmB,EAExB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,uBAAuB,EAE5B,KAAK,MAAM,IAAI,WAAW,EAC1B,iBAAiB,EACjB,KAAK,QAAQ,EACb,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,EAC7B,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,MAAM,EAAc,MAAM,WAAW,CAAC;AAI/C,OAAO,EAKL,KAAK,qBAAqB,EAO3B,MAAM,mCAAmC,CAAC;AAI3C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAC1E,OAAO,KAAK,EACV,0BAA0B,EAC1B,qBAAqB,EACrB,yBAAyB,EACzB,wBAAwB,EACxB,yBAAyB,EAC1B,MAAM,WAAW,CAAC;AACnB,OAAO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;AAED,eAAe,MAAM,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -802,6 +802,11 @@ declare class Device extends EventEmitter {
|
|
|
802
802
|
* 设备是否被占用
|
|
803
803
|
*/
|
|
804
804
|
private deviceAcquired;
|
|
805
|
+
/**
|
|
806
|
+
* Set by interruptionFromUser() so an in-flight acquire/initialize cannot
|
|
807
|
+
* finish the link and send Cancel after the caller already aborted.
|
|
808
|
+
*/
|
|
809
|
+
private interruptedByUser;
|
|
805
810
|
/** Canonical device-state cache; legacy Features is a compatibility projection. */
|
|
806
811
|
private stateStore;
|
|
807
812
|
/** Force the next initialization to reload DeviceInfo after reconnect or reboot. */
|
|
@@ -952,6 +957,14 @@ declare class Device extends EventEmitter {
|
|
|
952
957
|
getFirmwareVersion(): IVersionArray | null;
|
|
953
958
|
getBLEFirmwareVersion(): IVersionArray | null;
|
|
954
959
|
isUsed(): boolean;
|
|
960
|
+
wasInterruptedByUser(): boolean;
|
|
961
|
+
private throwIfInterruptedByUser;
|
|
962
|
+
/**
|
|
963
|
+
* Protocol Cancel is only for an acquired session that is already in a
|
|
964
|
+
* user-facing prompt. Connect, probe and initialize must not send Cancel
|
|
965
|
+
* and must not re-acquire just to deliver one.
|
|
966
|
+
*/
|
|
967
|
+
private shouldSendFallbackProtocolCancel;
|
|
955
968
|
hasDeviceAcquire(): boolean;
|
|
956
969
|
isUsedHere(): boolean;
|
|
957
970
|
isUsedElsewhere(): boolean;
|
package/dist/index.js
CHANGED
|
@@ -45130,6 +45130,7 @@ class Device extends events.exports {
|
|
|
45130
45130
|
super();
|
|
45131
45131
|
this.deviceConnector = null;
|
|
45132
45132
|
this.deviceAcquired = false;
|
|
45133
|
+
this.interruptedByUser = false;
|
|
45133
45134
|
this.stateStore = new DeviceStateStore();
|
|
45134
45135
|
this.protocolV2StateNeedsReload = false;
|
|
45135
45136
|
this.protocolV2UiInteractionCounter = 0;
|
|
@@ -45222,8 +45223,9 @@ class Device extends events.exports {
|
|
|
45222
45223
|
}));
|
|
45223
45224
|
}
|
|
45224
45225
|
acquire(expectedProtocol, options) {
|
|
45225
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
45226
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
45226
45227
|
return __awaiter(this, void 0, void 0, function* () {
|
|
45228
|
+
this.throwIfInterruptedByUser();
|
|
45227
45229
|
const env = DataManager.getSettings('env');
|
|
45228
45230
|
const mainIdKey = DataManager.isBleConnect(env) ? 'id' : 'session';
|
|
45229
45231
|
const previousProtocol = this.originalDescriptor.protocolType;
|
|
@@ -45249,12 +45251,21 @@ class Device extends events.exports {
|
|
|
45249
45251
|
if (detectedProtocol) {
|
|
45250
45252
|
this.originalDescriptor.protocolType = detectedProtocol;
|
|
45251
45253
|
}
|
|
45254
|
+
if (this.interruptedByUser) {
|
|
45255
|
+
const session = this.mainId;
|
|
45256
|
+
if (session && ((_g = this.deviceConnector) === null || _g === void 0 ? void 0 : _g.disconnect)) {
|
|
45257
|
+
yield this.deviceConnector.disconnect(session).catch(disconnectError => {
|
|
45258
|
+
Log$h.debug('Ignored disconnect after user cancel during acquire', disconnectError);
|
|
45259
|
+
});
|
|
45260
|
+
}
|
|
45261
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceInterruptedFromUser);
|
|
45262
|
+
}
|
|
45252
45263
|
this.deviceAcquired = true;
|
|
45253
45264
|
this.updateDescriptor({ [mainIdKey]: this.mainId });
|
|
45254
45265
|
if (this.commands) {
|
|
45255
45266
|
yield this.commands.dispose(false);
|
|
45256
45267
|
}
|
|
45257
|
-
this.commands = new DeviceCommands(this, (
|
|
45268
|
+
this.commands = new DeviceCommands(this, (_h = this.mainId) !== null && _h !== void 0 ? _h : '');
|
|
45258
45269
|
this.invalidateProtocolV2RuntimeState();
|
|
45259
45270
|
}
|
|
45260
45271
|
catch (error) {
|
|
@@ -45264,7 +45275,7 @@ class Device extends events.exports {
|
|
|
45264
45275
|
this.deviceAcquired = false;
|
|
45265
45276
|
if (failedSession) {
|
|
45266
45277
|
try {
|
|
45267
|
-
yield ((
|
|
45278
|
+
yield ((_k = (_j = this.deviceConnector) === null || _j === void 0 ? void 0 : _j.release) === null || _k === void 0 ? void 0 : _k.call(_j, failedSession, false));
|
|
45268
45279
|
}
|
|
45269
45280
|
catch (releaseError) {
|
|
45270
45281
|
Log$h.debug('Failed to release an unsuccessful protocol probe', releaseError);
|
|
@@ -45586,6 +45597,7 @@ class Device extends events.exports {
|
|
|
45586
45597
|
}
|
|
45587
45598
|
initialize(options) {
|
|
45588
45599
|
return __awaiter(this, void 0, void 0, function* () {
|
|
45600
|
+
this.throwIfInterruptedByUser();
|
|
45589
45601
|
if (this.isProtocolV2()) {
|
|
45590
45602
|
this.passphraseState = options === null || options === void 0 ? void 0 : options.passphraseState;
|
|
45591
45603
|
if (this.state && !(options === null || options === void 0 ? void 0 : options.initSession) && !this.protocolV2StateNeedsReload) {
|
|
@@ -46007,6 +46019,7 @@ class Device extends events.exports {
|
|
|
46007
46019
|
yield this.interruptionFromOutside();
|
|
46008
46020
|
Log$h.debug('[Device] run error:', 'Device is running, but will cancel previous operate');
|
|
46009
46021
|
}
|
|
46022
|
+
this.interruptedByUser = false;
|
|
46010
46023
|
options = parseRunOptions(options);
|
|
46011
46024
|
const runPromise = hdShared.createDeferred();
|
|
46012
46025
|
this.runPromise = runPromise;
|
|
@@ -46117,25 +46130,29 @@ class Device extends events.exports {
|
|
|
46117
46130
|
});
|
|
46118
46131
|
}
|
|
46119
46132
|
interruptionFromUser() {
|
|
46120
|
-
var _a, _b, _c;
|
|
46133
|
+
var _a, _b, _c, _d;
|
|
46121
46134
|
return __awaiter(this, void 0, void 0, function* () {
|
|
46122
46135
|
const error = hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceInterruptedFromUser);
|
|
46136
|
+
this.interruptedByUser = true;
|
|
46123
46137
|
const cleanupPromise = this.runCleanupPromise;
|
|
46124
46138
|
const { cancelableAction } = this;
|
|
46125
|
-
const env = DataManager.getSettings('env');
|
|
46126
46139
|
if (cancelableAction) {
|
|
46127
46140
|
yield cancelableAction(error);
|
|
46128
46141
|
}
|
|
46129
|
-
else if (this.
|
|
46130
|
-
(DataManager.isBleConnect(env) ||
|
|
46131
|
-
DataManager.isBrowserWebUsb(env) ||
|
|
46132
|
-
DataManager.isDesktopWebUsb(env)) &&
|
|
46133
|
-
this.hasDeviceAcquire()) {
|
|
46142
|
+
else if (this.shouldSendFallbackProtocolCancel()) {
|
|
46134
46143
|
yield ((_b = (_a = this.commands) === null || _a === void 0 ? void 0 : _a.cancelDevice) === null || _b === void 0 ? void 0 : _b.call(_a).catch(cancelError => {
|
|
46135
46144
|
Log$h.debug('Protocol V2 fallback cancel error', cancelError);
|
|
46136
46145
|
}));
|
|
46137
46146
|
}
|
|
46138
|
-
|
|
46147
|
+
else if (!this.hasDeviceAcquire()) {
|
|
46148
|
+
if (this.mainId && ((_c = this.deviceConnector) === null || _c === void 0 ? void 0 : _c.disconnect)) {
|
|
46149
|
+
yield this.deviceConnector.disconnect(this.mainId).catch(disconnectError => {
|
|
46150
|
+
Log$h.debug('Ignored disconnect during user cancel without acquire', disconnectError);
|
|
46151
|
+
});
|
|
46152
|
+
}
|
|
46153
|
+
this.markTransportDisconnected();
|
|
46154
|
+
}
|
|
46155
|
+
yield ((_d = this.commands) === null || _d === void 0 ? void 0 : _d.cancel());
|
|
46139
46156
|
if (this.runPromise) {
|
|
46140
46157
|
this.runPromise.reject(error);
|
|
46141
46158
|
this.runPromise = null;
|
|
@@ -46190,6 +46207,26 @@ class Device extends events.exports {
|
|
|
46190
46207
|
isUsed() {
|
|
46191
46208
|
return typeof this.originalDescriptor.session === 'string';
|
|
46192
46209
|
}
|
|
46210
|
+
wasInterruptedByUser() {
|
|
46211
|
+
return this.interruptedByUser;
|
|
46212
|
+
}
|
|
46213
|
+
throwIfInterruptedByUser() {
|
|
46214
|
+
if (this.interruptedByUser) {
|
|
46215
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceInterruptedFromUser);
|
|
46216
|
+
}
|
|
46217
|
+
}
|
|
46218
|
+
shouldSendFallbackProtocolCancel() {
|
|
46219
|
+
if (!this.hasDeviceAcquire() || !this.isProtocolV2()) {
|
|
46220
|
+
return false;
|
|
46221
|
+
}
|
|
46222
|
+
if (!this.hasOpenProtocolV2UiInteraction()) {
|
|
46223
|
+
return false;
|
|
46224
|
+
}
|
|
46225
|
+
const env = DataManager.getSettings('env');
|
|
46226
|
+
return (DataManager.isBleConnect(env) ||
|
|
46227
|
+
DataManager.isBrowserWebUsb(env) ||
|
|
46228
|
+
DataManager.isDesktopWebUsb(env));
|
|
46229
|
+
}
|
|
46193
46230
|
hasDeviceAcquire() {
|
|
46194
46231
|
const env = DataManager.getSettings('env');
|
|
46195
46232
|
if (DataManager.isBleConnect(env)) {
|
|
@@ -48243,6 +48280,8 @@ class DeviceRebootToBootloader extends BaseMethod {
|
|
|
48243
48280
|
init() {
|
|
48244
48281
|
this.useDevicePassphraseState = false;
|
|
48245
48282
|
this.skipForceUpdateCheck = true;
|
|
48283
|
+
this.unlockPolicy = 'unlock-before-run';
|
|
48284
|
+
this.protocolV2PreUnlockPinType = hdTransport.DeviceSessionPinType.Any;
|
|
48246
48285
|
}
|
|
48247
48286
|
getVersionRange() {
|
|
48248
48287
|
return {
|
|
@@ -48276,6 +48315,8 @@ class DeviceRebootToBoardloader extends BaseMethod {
|
|
|
48276
48315
|
init() {
|
|
48277
48316
|
this.useDevicePassphraseState = false;
|
|
48278
48317
|
this.skipForceUpdateCheck = true;
|
|
48318
|
+
this.unlockPolicy = 'unlock-before-run';
|
|
48319
|
+
this.protocolV2PreUnlockPinType = hdTransport.DeviceSessionPinType.Any;
|
|
48279
48320
|
}
|
|
48280
48321
|
getVersionRange() {
|
|
48281
48322
|
return {
|
|
@@ -53922,6 +53963,8 @@ class DeviceReboot extends BaseMethod {
|
|
|
53922
53963
|
init() {
|
|
53923
53964
|
this.skipForceUpdateCheck = true;
|
|
53924
53965
|
this.useDevicePassphraseState = false;
|
|
53966
|
+
this.unlockPolicy = 'unlock-before-run';
|
|
53967
|
+
this.protocolV2PreUnlockPinType = hdTransport.DeviceSessionPinType.Any;
|
|
53925
53968
|
this.params = {
|
|
53926
53969
|
rebootType: this.payload.rebootType,
|
|
53927
53970
|
reboot_type: this.payload.reboot_type,
|
|
@@ -65521,6 +65564,17 @@ function isRetryableBleProtocolV2ProbeError(method, error) {
|
|
|
65521
65564
|
message.includes('expected V2') &&
|
|
65522
65565
|
message.includes('did not respond to expected protocol'));
|
|
65523
65566
|
}
|
|
65567
|
+
function isRetryableBleConnectionError(method, error) {
|
|
65568
|
+
var _a;
|
|
65569
|
+
if ((_a = method.device) === null || _a === void 0 ? void 0 : _a.wasInterruptedByUser()) {
|
|
65570
|
+
return false;
|
|
65571
|
+
}
|
|
65572
|
+
const typedError = error;
|
|
65573
|
+
return ((typedError === null || typedError === void 0 ? void 0 : typedError.errorCode) === hdShared.HardwareErrorCode.BleTimeoutError ||
|
|
65574
|
+
(typedError === null || typedError === void 0 ? void 0 : typedError.errorCode) === hdShared.HardwareErrorCode.BleConnectedError ||
|
|
65575
|
+
isRetryableBleProtocolV2ProbeError(method, error) ||
|
|
65576
|
+
isMissingDetectedProtocolV2Error(method, error));
|
|
65577
|
+
}
|
|
65524
65578
|
function isMissingDetectedProtocolV2Error(method, error) {
|
|
65525
65579
|
const typedError = error;
|
|
65526
65580
|
return (method.payload.connectProtocol === 'V2' &&
|
|
@@ -65532,6 +65586,9 @@ function connectDeviceForBle(method, device, retryCount = 0) {
|
|
|
65532
65586
|
var _a;
|
|
65533
65587
|
return __awaiter(this, void 0, void 0, function* () {
|
|
65534
65588
|
try {
|
|
65589
|
+
if (device.wasInterruptedByUser()) {
|
|
65590
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceInterruptedFromUser);
|
|
65591
|
+
}
|
|
65535
65592
|
if (method.payload.forceProtocolDetection && device.hasDeviceAcquire()) {
|
|
65536
65593
|
yield device.release();
|
|
65537
65594
|
}
|
|
@@ -65569,11 +65626,7 @@ function connectDeviceForBle(method, device, retryCount = 0) {
|
|
|
65569
65626
|
yield device.deviceConnector.disconnect(device.mainId).catch(() => undefined);
|
|
65570
65627
|
device.markTransportDisconnected();
|
|
65571
65628
|
}
|
|
65572
|
-
if ((err
|
|
65573
|
-
err.errorCode === hdShared.HardwareErrorCode.BleConnectedError ||
|
|
65574
|
-
isRetryableBleProtocolV2ProbeError(method, err) ||
|
|
65575
|
-
requiresColdReconnect) &&
|
|
65576
|
-
retryCount < 6) {
|
|
65629
|
+
if (isRetryableBleConnectionError(method, err) && retryCount < 6) {
|
|
65577
65630
|
const nextRetry = retryCount + 1;
|
|
65578
65631
|
Log.debug(`Bluetooth connection will retry, retry count: ${nextRetry}`);
|
|
65579
65632
|
yield wait(3000);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/hd-core",
|
|
3
|
-
"version": "1.2.0-alpha.
|
|
3
|
+
"version": "1.2.0-alpha.148",
|
|
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.
|
|
29
|
-
"@onekeyfe/hd-transport": "1.2.0-alpha.
|
|
28
|
+
"@onekeyfe/hd-shared": "1.2.0-alpha.148",
|
|
29
|
+
"@onekeyfe/hd-transport": "1.2.0-alpha.148",
|
|
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": "
|
|
49
|
+
"gitHead": "0538b18c48292741d9b7c29a87851227bc3e229b"
|
|
50
50
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DeviceRebootType } from '@onekeyfe/hd-transport';
|
|
1
|
+
import { DeviceRebootType, DeviceSessionPinType } from '@onekeyfe/hd-transport';
|
|
2
2
|
|
|
3
3
|
import { BaseMethod } from '../BaseMethod';
|
|
4
4
|
|
|
@@ -13,6 +13,8 @@ export default class DeviceRebootToBoardloader extends BaseMethod<RebootToBoardl
|
|
|
13
13
|
init() {
|
|
14
14
|
this.useDevicePassphraseState = false;
|
|
15
15
|
this.skipForceUpdateCheck = true;
|
|
16
|
+
this.unlockPolicy = 'unlock-before-run';
|
|
17
|
+
this.protocolV2PreUnlockPinType = DeviceSessionPinType.Any;
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
getVersionRange() {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DeviceRebootType } from '@onekeyfe/hd-transport';
|
|
1
|
+
import { DeviceRebootType, DeviceSessionPinType } from '@onekeyfe/hd-transport';
|
|
2
2
|
|
|
3
3
|
import { BaseMethod } from '../BaseMethod';
|
|
4
4
|
|
|
@@ -13,6 +13,8 @@ export default class DeviceRebootToBootloader extends BaseMethod<RebootToBootloa
|
|
|
13
13
|
init() {
|
|
14
14
|
this.useDevicePassphraseState = false;
|
|
15
15
|
this.skipForceUpdateCheck = true;
|
|
16
|
+
this.unlockPolicy = 'unlock-before-run';
|
|
17
|
+
this.protocolV2PreUnlockPinType = DeviceSessionPinType.Any;
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
getVersionRange() {
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { DeviceSessionPinType } from '@onekeyfe/hd-transport';
|
|
2
|
+
|
|
1
3
|
import { BaseMethod } from '../BaseMethod';
|
|
2
4
|
import { normalizeRebootType } from './helpers';
|
|
3
5
|
|
|
@@ -11,6 +13,9 @@ export default class DeviceReboot extends BaseMethod<DeviceRebootParams> {
|
|
|
11
13
|
init() {
|
|
12
14
|
this.skipForceUpdateCheck = true;
|
|
13
15
|
this.useDevicePassphraseState = false;
|
|
16
|
+
this.unlockPolicy = 'unlock-before-run';
|
|
17
|
+
// Device-management action: main PIN or Attach PIN may authorize reboot.
|
|
18
|
+
this.protocolV2PreUnlockPinType = DeviceSessionPinType.Any;
|
|
14
19
|
this.params = {
|
|
15
20
|
rebootType: this.payload.rebootType,
|
|
16
21
|
reboot_type: this.payload.reboot_type,
|
package/src/core/index.ts
CHANGED
|
@@ -927,6 +927,19 @@ export function isRetryableBleProtocolV2ProbeError(method: BaseMethod, error: un
|
|
|
927
927
|
);
|
|
928
928
|
}
|
|
929
929
|
|
|
930
|
+
export function isRetryableBleConnectionError(method: BaseMethod, error: unknown) {
|
|
931
|
+
if (method.device?.wasInterruptedByUser()) {
|
|
932
|
+
return false;
|
|
933
|
+
}
|
|
934
|
+
const typedError = error as { errorCode?: unknown };
|
|
935
|
+
return (
|
|
936
|
+
typedError?.errorCode === HardwareErrorCode.BleTimeoutError ||
|
|
937
|
+
typedError?.errorCode === HardwareErrorCode.BleConnectedError ||
|
|
938
|
+
isRetryableBleProtocolV2ProbeError(method, error) ||
|
|
939
|
+
isMissingDetectedProtocolV2Error(method, error)
|
|
940
|
+
);
|
|
941
|
+
}
|
|
942
|
+
|
|
930
943
|
export function isMissingDetectedProtocolV2Error(method: BaseMethod, error: unknown) {
|
|
931
944
|
const typedError = error as { errorCode?: unknown; message?: unknown };
|
|
932
945
|
return (
|
|
@@ -943,6 +956,9 @@ export function isMissingDetectedProtocolV2Error(method: BaseMethod, error: unkn
|
|
|
943
956
|
*/
|
|
944
957
|
async function connectDeviceForBle(method: BaseMethod, device: Device, retryCount = 0) {
|
|
945
958
|
try {
|
|
959
|
+
if (device.wasInterruptedByUser()) {
|
|
960
|
+
throw ERRORS.TypedError(HardwareErrorCode.DeviceInterruptedFromUser);
|
|
961
|
+
}
|
|
946
962
|
if (method.payload.forceProtocolDetection && device.hasDeviceAcquire()) {
|
|
947
963
|
await device.release();
|
|
948
964
|
}
|
|
@@ -990,13 +1006,7 @@ async function connectDeviceForBle(method: BaseMethod, device: Device, retryCoun
|
|
|
990
1006
|
// next attempt skip acquire and initialize onto the link we just cut.
|
|
991
1007
|
device.markTransportDisconnected();
|
|
992
1008
|
}
|
|
993
|
-
if (
|
|
994
|
-
(err.errorCode === HardwareErrorCode.BleTimeoutError ||
|
|
995
|
-
err.errorCode === HardwareErrorCode.BleConnectedError ||
|
|
996
|
-
isRetryableBleProtocolV2ProbeError(method, err) ||
|
|
997
|
-
requiresColdReconnect) &&
|
|
998
|
-
retryCount < 6
|
|
999
|
-
) {
|
|
1009
|
+
if (isRetryableBleConnectionError(method, err) && retryCount < 6) {
|
|
1000
1010
|
const nextRetry = retryCount + 1;
|
|
1001
1011
|
Log.debug(`Bluetooth connection will retry, retry count: ${nextRetry}`);
|
|
1002
1012
|
await wait(3000);
|
package/src/device/Device.ts
CHANGED
|
@@ -235,6 +235,12 @@ export class Device extends EventEmitter {
|
|
|
235
235
|
*/
|
|
236
236
|
private deviceAcquired = false;
|
|
237
237
|
|
|
238
|
+
/**
|
|
239
|
+
* Set by interruptionFromUser() so an in-flight acquire/initialize cannot
|
|
240
|
+
* finish the link and send Cancel after the caller already aborted.
|
|
241
|
+
*/
|
|
242
|
+
private interruptedByUser = false;
|
|
243
|
+
|
|
238
244
|
/** Canonical device-state cache; legacy Features is a compatibility projection. */
|
|
239
245
|
private stateStore = new DeviceStateStore();
|
|
240
246
|
|
|
@@ -429,6 +435,7 @@ export class Device extends EventEmitter {
|
|
|
429
435
|
expectedProtocol?: HardwareConnectProtocol,
|
|
430
436
|
options?: { throwOnRunPromiseError?: boolean; forceProtocolDetection?: boolean }
|
|
431
437
|
) {
|
|
438
|
+
this.throwIfInterruptedByUser();
|
|
432
439
|
const env = DataManager.getSettings('env');
|
|
433
440
|
const mainIdKey = DataManager.isBleConnect(env) ? 'id' : 'session';
|
|
434
441
|
const previousProtocol = this.originalDescriptor.protocolType;
|
|
@@ -483,6 +490,15 @@ export class Device extends EventEmitter {
|
|
|
483
490
|
if (detectedProtocol) {
|
|
484
491
|
this.originalDescriptor.protocolType = detectedProtocol;
|
|
485
492
|
}
|
|
493
|
+
if (this.interruptedByUser) {
|
|
494
|
+
const session = this.mainId;
|
|
495
|
+
if (session && this.deviceConnector?.disconnect) {
|
|
496
|
+
await this.deviceConnector.disconnect(session).catch(disconnectError => {
|
|
497
|
+
Log.debug('Ignored disconnect after user cancel during acquire', disconnectError);
|
|
498
|
+
});
|
|
499
|
+
}
|
|
500
|
+
throw ERRORS.TypedError(HardwareErrorCode.DeviceInterruptedFromUser);
|
|
501
|
+
}
|
|
486
502
|
this.deviceAcquired = true;
|
|
487
503
|
this.updateDescriptor({ [mainIdKey]: this.mainId } as unknown as DeviceDescriptor);
|
|
488
504
|
|
|
@@ -903,6 +919,7 @@ export class Device extends EventEmitter {
|
|
|
903
919
|
}
|
|
904
920
|
|
|
905
921
|
async initialize(options?: InitOptions) {
|
|
922
|
+
this.throwIfInterruptedByUser();
|
|
906
923
|
// Protocol V2 does not support legacy Initialize; use its dedicated flow.
|
|
907
924
|
if (this.isProtocolV2()) {
|
|
908
925
|
this.passphraseState = options?.passphraseState;
|
|
@@ -1445,6 +1462,7 @@ export class Device extends EventEmitter {
|
|
|
1445
1462
|
Log.debug('[Device] run error:', 'Device is running, but will cancel previous operate');
|
|
1446
1463
|
}
|
|
1447
1464
|
|
|
1465
|
+
this.interruptedByUser = false;
|
|
1448
1466
|
options = parseRunOptions(options);
|
|
1449
1467
|
|
|
1450
1468
|
const runPromise = createDeferred<void>();
|
|
@@ -1574,21 +1592,24 @@ export class Device extends EventEmitter {
|
|
|
1574
1592
|
|
|
1575
1593
|
async interruptionFromUser() {
|
|
1576
1594
|
const error = ERRORS.TypedError(HardwareErrorCode.DeviceInterruptedFromUser);
|
|
1595
|
+
this.interruptedByUser = true;
|
|
1577
1596
|
const cleanupPromise = this.runCleanupPromise;
|
|
1578
1597
|
const { cancelableAction } = this;
|
|
1579
|
-
const env = DataManager.getSettings('env');
|
|
1580
1598
|
if (cancelableAction) {
|
|
1581
1599
|
await cancelableAction(error);
|
|
1582
|
-
} else if (
|
|
1583
|
-
this.isProtocolV2() &&
|
|
1584
|
-
(DataManager.isBleConnect(env) ||
|
|
1585
|
-
DataManager.isBrowserWebUsb(env) ||
|
|
1586
|
-
DataManager.isDesktopWebUsb(env)) &&
|
|
1587
|
-
this.hasDeviceAcquire()
|
|
1588
|
-
) {
|
|
1600
|
+
} else if (this.shouldSendFallbackProtocolCancel()) {
|
|
1589
1601
|
await this.commands?.cancelDevice?.().catch(cancelError => {
|
|
1590
1602
|
Log.debug('Protocol V2 fallback cancel error', cancelError);
|
|
1591
1603
|
});
|
|
1604
|
+
} else if (!this.hasDeviceAcquire()) {
|
|
1605
|
+
// Pairing / connect-native / probe: drop the physical link only.
|
|
1606
|
+
// Never acquire or send protocol Cancel just to abort setup.
|
|
1607
|
+
if (this.mainId && this.deviceConnector?.disconnect) {
|
|
1608
|
+
await this.deviceConnector.disconnect(this.mainId).catch(disconnectError => {
|
|
1609
|
+
Log.debug('Ignored disconnect during user cancel without acquire', disconnectError);
|
|
1610
|
+
});
|
|
1611
|
+
}
|
|
1612
|
+
this.markTransportDisconnected();
|
|
1592
1613
|
}
|
|
1593
1614
|
await this.commands?.cancel();
|
|
1594
1615
|
|
|
@@ -1652,6 +1673,36 @@ export class Device extends EventEmitter {
|
|
|
1652
1673
|
return typeof this.originalDescriptor.session === 'string';
|
|
1653
1674
|
}
|
|
1654
1675
|
|
|
1676
|
+
wasInterruptedByUser() {
|
|
1677
|
+
return this.interruptedByUser;
|
|
1678
|
+
}
|
|
1679
|
+
|
|
1680
|
+
private throwIfInterruptedByUser() {
|
|
1681
|
+
if (this.interruptedByUser) {
|
|
1682
|
+
throw ERRORS.TypedError(HardwareErrorCode.DeviceInterruptedFromUser);
|
|
1683
|
+
}
|
|
1684
|
+
}
|
|
1685
|
+
|
|
1686
|
+
/**
|
|
1687
|
+
* Protocol Cancel is only for an acquired session that is already in a
|
|
1688
|
+
* user-facing prompt. Connect, probe and initialize must not send Cancel
|
|
1689
|
+
* and must not re-acquire just to deliver one.
|
|
1690
|
+
*/
|
|
1691
|
+
private shouldSendFallbackProtocolCancel() {
|
|
1692
|
+
if (!this.hasDeviceAcquire() || !this.isProtocolV2()) {
|
|
1693
|
+
return false;
|
|
1694
|
+
}
|
|
1695
|
+
if (!this.hasOpenProtocolV2UiInteraction()) {
|
|
1696
|
+
return false;
|
|
1697
|
+
}
|
|
1698
|
+
const env = DataManager.getSettings('env');
|
|
1699
|
+
return (
|
|
1700
|
+
DataManager.isBleConnect(env) ||
|
|
1701
|
+
DataManager.isBrowserWebUsb(env) ||
|
|
1702
|
+
DataManager.isDesktopWebUsb(env)
|
|
1703
|
+
);
|
|
1704
|
+
}
|
|
1705
|
+
|
|
1655
1706
|
hasDeviceAcquire() {
|
|
1656
1707
|
const env = DataManager.getSettings('env');
|
|
1657
1708
|
if (DataManager.isBleConnect(env)) {
|