@onekeyfe/hd-core 1.2.8-alpha.10 → 1.2.8-alpha.11
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__/DeviceCommands.test.ts +66 -13
- package/__tests__/core-error-output.test.ts +34 -3
- package/__tests__/device-lifecycle-events.test.ts +22 -17
- package/__tests__/protocol-v2-bootloader-mode.test.ts +43 -2
- package/__tests__/protocol-v2.test.ts +0 -47
- package/__tests__/refresh-device-state.test.ts +19 -17
- package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
- package/dist/api/GetDeviceState.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceReboot.d.ts.map +1 -1
- package/dist/core/index.d.ts +0 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/device/DeviceCommands.d.ts +4 -4
- package/dist/device/DeviceCommands.d.ts.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +22 -25
- package/dist/types/params.d.ts +1 -0
- package/dist/types/params.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/api/FirmwareUpdateV4.ts +8 -25
- package/src/api/GetDeviceState.ts +2 -5
- package/src/api/protocol-v2/DeviceReboot.ts +2 -0
- package/src/core/index.ts +2 -6
- package/src/device/Device.ts +1 -1
- package/src/device/DeviceCommands.ts +15 -1
- package/src/events/core.ts +2 -2
- package/src/types/params.ts +1 -1
|
@@ -130,19 +130,6 @@ describe('DeviceCommands failure mapping', () => {
|
|
|
130
130
|
);
|
|
131
131
|
});
|
|
132
132
|
|
|
133
|
-
it('preserves the Protocol V2 peer-removed pairing error code', async () => {
|
|
134
|
-
const commands = createCommands();
|
|
135
|
-
const transportError = Object.assign(new Error('Peer removed pairing information'), {
|
|
136
|
-
errorCode: HardwareErrorCode.BlePeerRemovedPairingInformation,
|
|
137
|
-
});
|
|
138
|
-
commands.mainId = 'main-id';
|
|
139
|
-
commands.transport = {
|
|
140
|
-
call: jest.fn().mockRejectedValue(transportError),
|
|
141
|
-
} as any;
|
|
142
|
-
|
|
143
|
-
await expect(commands._commonCall('DeviceInfoGet', {})).rejects.toBe(transportError);
|
|
144
|
-
});
|
|
145
|
-
|
|
146
133
|
it('logs canonical DeviceStatus response fields without exposing the device ID', async () => {
|
|
147
134
|
const commands = createCommands();
|
|
148
135
|
const log = getLogger(LoggerNames.DeviceCommands);
|
|
@@ -414,6 +401,27 @@ describe('DeviceCommands failure mapping', () => {
|
|
|
414
401
|
).rejects.toMatchObject({ errorCode: HardwareErrorCode.DeviceBusy });
|
|
415
402
|
});
|
|
416
403
|
|
|
404
|
+
it('maps commands rejected during a Protocol V2 firmware update to DeviceBusy', async () => {
|
|
405
|
+
const commands = createCommands();
|
|
406
|
+
const message = 'Requested command not allowed while a firmware update is in progress';
|
|
407
|
+
|
|
408
|
+
await expect(
|
|
409
|
+
commands._filterCommonTypes(
|
|
410
|
+
{
|
|
411
|
+
type: 'Failure',
|
|
412
|
+
message: { code: 'Failure_ProcessError', message },
|
|
413
|
+
} as any,
|
|
414
|
+
'ProtocolInfoRequest'
|
|
415
|
+
)
|
|
416
|
+
).rejects.toMatchObject({
|
|
417
|
+
errorCode: HardwareErrorCode.DeviceBusy,
|
|
418
|
+
params: {
|
|
419
|
+
failureCode: 'Failure_ProcessError',
|
|
420
|
+
firmwareMessage: message,
|
|
421
|
+
},
|
|
422
|
+
});
|
|
423
|
+
});
|
|
424
|
+
|
|
417
425
|
it('maps the current AskPin passphrase-disabled response without relying on a subcode', async () => {
|
|
418
426
|
const commands = createCommands();
|
|
419
427
|
|
|
@@ -551,6 +559,51 @@ describe('DeviceCommands failure mapping', () => {
|
|
|
551
559
|
}
|
|
552
560
|
);
|
|
553
561
|
|
|
562
|
+
it('maps the Protocol V2 seed-session busy response to DeviceBusy', async () => {
|
|
563
|
+
const commands = createCommands();
|
|
564
|
+
|
|
565
|
+
await expect(
|
|
566
|
+
commands._filterCommonTypes(
|
|
567
|
+
{
|
|
568
|
+
type: 'Failure',
|
|
569
|
+
message: {
|
|
570
|
+
code: 'Failure_ProcessError',
|
|
571
|
+
subcode: DeviceSessionErrorCode.DeviceSessionError_UserCancelled,
|
|
572
|
+
message: 'PIN cancelled',
|
|
573
|
+
},
|
|
574
|
+
} as any,
|
|
575
|
+
'SignTx'
|
|
576
|
+
)
|
|
577
|
+
).rejects.toMatchObject({
|
|
578
|
+
errorCode: HardwareErrorCode.DeviceBusy,
|
|
579
|
+
params: {
|
|
580
|
+
failureCode: 'Failure_ProcessError',
|
|
581
|
+
subcode: DeviceSessionErrorCode.DeviceSessionError_UserCancelled,
|
|
582
|
+
firmwareMessage: 'PIN cancelled',
|
|
583
|
+
},
|
|
584
|
+
});
|
|
585
|
+
});
|
|
586
|
+
|
|
587
|
+
it('keeps the same Protocol V2 response as ActionCancelled for DeviceSession calls', async () => {
|
|
588
|
+
const commands = createCommands();
|
|
589
|
+
|
|
590
|
+
await expect(
|
|
591
|
+
commands._filterCommonTypes(
|
|
592
|
+
{
|
|
593
|
+
type: 'Failure',
|
|
594
|
+
message: {
|
|
595
|
+
code: 'Failure_ProcessError',
|
|
596
|
+
subcode: DeviceSessionErrorCode.DeviceSessionError_UserCancelled,
|
|
597
|
+
message: 'PIN cancelled',
|
|
598
|
+
},
|
|
599
|
+
} as any,
|
|
600
|
+
'DeviceSessionAskPin'
|
|
601
|
+
)
|
|
602
|
+
).rejects.toMatchObject({
|
|
603
|
+
errorCode: HardwareErrorCode.ActionCancelled,
|
|
604
|
+
});
|
|
605
|
+
});
|
|
606
|
+
|
|
554
607
|
it('does not use the legacy cancellation-message fallback for Protocol V1', async () => {
|
|
555
608
|
const commands = createCommands();
|
|
556
609
|
(commands.device.isProtocolV2 as jest.Mock).mockReturnValue(false);
|
|
@@ -3,7 +3,7 @@ import { ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
|
|
|
3
3
|
import { initConnector, initCore } from '../src/core';
|
|
4
4
|
import { DataManager } from '../src/data-manager';
|
|
5
5
|
import TransportManager from '../src/data-manager/TransportManager';
|
|
6
|
-
import { IFRAME } from '../src/events';
|
|
6
|
+
import { IFRAME, createErrorMessage } from '../src/events';
|
|
7
7
|
import SearchDevices from '../src/api/SearchDevices';
|
|
8
8
|
import { DeviceList } from '../src/device/DeviceList';
|
|
9
9
|
import { Device } from '../src/device/Device';
|
|
@@ -28,6 +28,23 @@ describe('Core 错误输出边界', () => {
|
|
|
28
28
|
jest.restoreAllMocks();
|
|
29
29
|
});
|
|
30
30
|
|
|
31
|
+
test('entry-point errors preserve USB recovery context across JSON serialization', () => {
|
|
32
|
+
const params = {
|
|
33
|
+
operation: 'open',
|
|
34
|
+
nativeErrorName: 'SecurityError',
|
|
35
|
+
nativeErrorMessage: 'Access denied',
|
|
36
|
+
};
|
|
37
|
+
const error = ERRORS.TypedError(
|
|
38
|
+
HardwareErrorCode.BridgeNeedsPermission,
|
|
39
|
+
'Access denied',
|
|
40
|
+
params
|
|
41
|
+
);
|
|
42
|
+
expect(JSON.parse(JSON.stringify(createErrorMessage(error)))).toEqual({
|
|
43
|
+
success: false,
|
|
44
|
+
payload: { code: HardwareErrorCode.BridgeNeedsPermission, error: 'Access denied', params },
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
|
|
31
48
|
test.each([
|
|
32
49
|
['webusb', false],
|
|
33
50
|
['desktop-webusb', false],
|
|
@@ -108,14 +125,28 @@ describe('Core 错误输出边界', () => {
|
|
|
108
125
|
HardwareErrorCode.BleDeviceBondedCanceled,
|
|
109
126
|
HardwareErrorCode.BleDeviceDisconnected,
|
|
110
127
|
HardwareErrorCode.PollingTimeout,
|
|
128
|
+
HardwareErrorCode.BlePoweredOff,
|
|
129
|
+
HardwareErrorCode.BleUnsupported,
|
|
130
|
+
HardwareErrorCode.BridgeNeedsPermission,
|
|
131
|
+
HardwareErrorCode.WebUsbDeviceAccessError,
|
|
111
132
|
])(
|
|
112
|
-
'preserves terminal
|
|
133
|
+
'preserves terminal transport error %s in the public response without polling again',
|
|
113
134
|
async errorCode => {
|
|
114
|
-
jest
|
|
135
|
+
jest
|
|
136
|
+
.spyOn(DataManager, 'getSettings')
|
|
137
|
+
.mockReturnValue(
|
|
138
|
+
[
|
|
139
|
+
HardwareErrorCode.BridgeNeedsPermission,
|
|
140
|
+
HardwareErrorCode.WebUsbDeviceAccessError,
|
|
141
|
+
].includes(errorCode)
|
|
142
|
+
? ('desktop-webusb' as never)
|
|
143
|
+
: ('react-native' as never)
|
|
144
|
+
);
|
|
115
145
|
const error = ERRORS.TypedError(errorCode);
|
|
116
146
|
const acquire = jest.fn().mockRejectedValue(error);
|
|
117
147
|
jest.spyOn(TransportManager, 'getTransport').mockReturnValue({
|
|
118
148
|
acquire,
|
|
149
|
+
enumerate: jest.fn().mockResolvedValue([{ path: 'ble-pairing-test' }]),
|
|
119
150
|
release: jest.fn().mockResolvedValue(true),
|
|
120
151
|
stop: jest.fn().mockResolvedValue(undefined),
|
|
121
152
|
} as never);
|
|
@@ -10,7 +10,6 @@ import {
|
|
|
10
10
|
isMissingDetectedProtocolV2Error,
|
|
11
11
|
isRetryableBleConnectionError,
|
|
12
12
|
isRetryableBleProtocolV2ProbeError,
|
|
13
|
-
isTerminalBleStaleBondError,
|
|
14
13
|
resolveBleConnectProtocol,
|
|
15
14
|
} from '../src/core';
|
|
16
15
|
import { DataManager } from '../src/data-manager';
|
|
@@ -613,7 +612,6 @@ describe('public device lifecycle events', () => {
|
|
|
613
612
|
test.each([
|
|
614
613
|
[HardwareErrorCode.RuntimeError, true],
|
|
615
614
|
[HardwareErrorCode.BleDeviceBondError, false],
|
|
616
|
-
[HardwareErrorCode.BlePeerRemovedPairingInformation, false],
|
|
617
615
|
] as const)(
|
|
618
616
|
'retries a Protocol V2 probe mismatch with error code %s: %s',
|
|
619
617
|
(errorCode, expected) => {
|
|
@@ -633,8 +631,6 @@ describe('public device lifecycle events', () => {
|
|
|
633
631
|
[HardwareErrorCode.BleTimeoutError, true],
|
|
634
632
|
[HardwareErrorCode.PollingTimeout, false],
|
|
635
633
|
[HardwareErrorCode.BleDeviceBondError, false],
|
|
636
|
-
[HardwareErrorCode.BlePeerRemovedPairingInformation, false],
|
|
637
|
-
[HardwareErrorCode.BleBondInvalid, false],
|
|
638
634
|
] as const)('retries a BLE connection error with error code %s: %s', (errorCode, expected) => {
|
|
639
635
|
const method = { payload: { connectProtocol: 'V2' } } as never;
|
|
640
636
|
const error = {
|
|
@@ -687,19 +683,6 @@ describe('public device lifecycle events', () => {
|
|
|
687
683
|
}
|
|
688
684
|
);
|
|
689
685
|
|
|
690
|
-
test.each([
|
|
691
|
-
[HardwareErrorCode.BleDeviceBondError, true],
|
|
692
|
-
[HardwareErrorCode.BlePeerRemovedPairingInformation, true],
|
|
693
|
-
[HardwareErrorCode.BleBondInvalid, true],
|
|
694
|
-
[HardwareErrorCode.DeviceNotFound, false],
|
|
695
|
-
] as const)('treats BLE stale-bond error code %s as terminal: %s', (errorCode, expected) => {
|
|
696
|
-
const error = {
|
|
697
|
-
errorCode,
|
|
698
|
-
};
|
|
699
|
-
|
|
700
|
-
expect(isTerminalBleStaleBondError(error)).toBe(expected);
|
|
701
|
-
});
|
|
702
|
-
|
|
703
686
|
test.each([
|
|
704
687
|
[HardwareErrorCode.DeviceCheckDeviceIdError, true],
|
|
705
688
|
[HardwareErrorCode.DeviceNotFound, false],
|
|
@@ -1058,6 +1041,28 @@ describe('public device lifecycle events', () => {
|
|
|
1058
1041
|
expect(device.wasInterruptedByUser()).toBe(false);
|
|
1059
1042
|
});
|
|
1060
1043
|
|
|
1044
|
+
test.each(['V1', 'V2'] as const)(
|
|
1045
|
+
'retires a failed USB %s session before the next user attempt',
|
|
1046
|
+
async protocol => {
|
|
1047
|
+
jest.spyOn(DataManager, 'getSettings').mockReturnValue('desktop-webusb' as never);
|
|
1048
|
+
const device = createInitializedDevice(protocol);
|
|
1049
|
+
device.originalDescriptor = { ...device.originalDescriptor, session: device.mainId };
|
|
1050
|
+
const disconnect = jest.fn().mockResolvedValue(undefined);
|
|
1051
|
+
const release = jest.fn().mockResolvedValue(undefined);
|
|
1052
|
+
device.deviceConnector = { disconnect, release } as never;
|
|
1053
|
+
device.commands = { disposed: false, dispose: jest.fn() } as never;
|
|
1054
|
+
(device as unknown as { deviceAcquired: boolean }).deviceAcquired = true;
|
|
1055
|
+
const error = ERRORS.TypedError(HardwareErrorCode.WebUsbDeviceAccessError);
|
|
1056
|
+
await expect(device.run(() => Promise.reject(error))).rejects.toBe(error);
|
|
1057
|
+
await new Promise(resolve => {
|
|
1058
|
+
setImmediate(resolve);
|
|
1059
|
+
});
|
|
1060
|
+
expect(disconnect).toHaveBeenCalledWith(device.mainId);
|
|
1061
|
+
expect(release).toHaveBeenCalledTimes(1);
|
|
1062
|
+
expect(device.hasDeviceAcquire()).toBe(false);
|
|
1063
|
+
}
|
|
1064
|
+
);
|
|
1065
|
+
|
|
1061
1066
|
test('waits for the canceled run to finish releasing before cancellation completes', async () => {
|
|
1062
1067
|
jest.spyOn(DataManager, 'getSettings').mockReturnValue('react-native' as never);
|
|
1063
1068
|
const device = createInitializedDevice('V2');
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { EDeviceType } from '@onekeyfe/hd-shared';
|
|
2
|
+
|
|
3
|
+
import DeviceReboot from '../src/api/protocol-v2/DeviceReboot';
|
|
1
4
|
import { Device } from '../src/device/Device';
|
|
2
5
|
import { UI_REQUEST } from '../src/events/ui-request';
|
|
3
6
|
|
|
@@ -23,12 +26,50 @@ const createBootloaderDevice = (protocolType: 'V1' | 'V2') => {
|
|
|
23
26
|
};
|
|
24
27
|
|
|
25
28
|
describe('Pro2 bootloader mode', () => {
|
|
26
|
-
test('
|
|
29
|
+
test('allows deviceReboot to return a Protocol V2 bootloader to normal mode', () => {
|
|
30
|
+
const device = createBootloaderDevice('V2');
|
|
31
|
+
const method = new DeviceReboot({
|
|
32
|
+
id: 1,
|
|
33
|
+
payload: { method: 'deviceReboot', rebootType: 'normal' },
|
|
34
|
+
});
|
|
35
|
+
method.init();
|
|
36
|
+
|
|
37
|
+
expect(device.hasUnexpectedMode(method.allowDeviceMode, method.requireDeviceMode)).toBeNull();
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
test('blocks Protocol V2 methods that are not allowed in bootloader mode', () => {
|
|
41
|
+
const device = createBootloaderDevice('V2');
|
|
42
|
+
|
|
43
|
+
expect(device.hasUnexpectedMode([], [])).toBe(UI_REQUEST.BOOTLOADER);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
test('allows Protocol V2 methods that explicitly support bootloader mode', () => {
|
|
27
47
|
const device = createBootloaderDevice('V2');
|
|
28
48
|
|
|
29
|
-
expect(device.hasUnexpectedMode([], [])).toBeNull();
|
|
49
|
+
expect(device.hasUnexpectedMode([UI_REQUEST.BOOTLOADER], [])).toBeNull();
|
|
30
50
|
});
|
|
31
51
|
|
|
52
|
+
test.each([EDeviceType.Pro2, EDeviceType.Neo])(
|
|
53
|
+
'blocks unsupported Protocol V2 methods in %s romloader mode',
|
|
54
|
+
deviceType => {
|
|
55
|
+
const device = createBootloaderDevice('V2');
|
|
56
|
+
device.updateState(
|
|
57
|
+
{
|
|
58
|
+
protocol: 'V2',
|
|
59
|
+
identity: { deviceType },
|
|
60
|
+
status: { mode: 'romloader', initialized: null },
|
|
61
|
+
},
|
|
62
|
+
'initialize'
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
expect(device.hasUnexpectedMode([], [])).toBe(UI_REQUEST.BOOTLOADER);
|
|
66
|
+
expect(device.hasUnexpectedMode([UI_REQUEST.NOT_INITIALIZE], [])).toBe(UI_REQUEST.BOOTLOADER);
|
|
67
|
+
expect(
|
|
68
|
+
device.hasUnexpectedMode([UI_REQUEST.BOOTLOADER, UI_REQUEST.NOT_INITIALIZE], [])
|
|
69
|
+
).toBeNull();
|
|
70
|
+
}
|
|
71
|
+
);
|
|
72
|
+
|
|
32
73
|
test('keeps the Protocol V1 bootloader restriction', () => {
|
|
33
74
|
const device = createBootloaderDevice('V1');
|
|
34
75
|
|
|
@@ -4991,23 +4991,6 @@ describe('Protocol V2 firmware update targets', () => {
|
|
|
4991
4991
|
expect(typedCall.mock.calls.map(call => call[0])).toEqual(['DeviceInfoGet']);
|
|
4992
4992
|
});
|
|
4993
4993
|
|
|
4994
|
-
test('stops V4 bootloader reconnect polling on a stale BLE bond', async () => {
|
|
4995
|
-
const method = new FirmwareUpdateV4({
|
|
4996
|
-
id: 1,
|
|
4997
|
-
payload: {
|
|
4998
|
-
method: 'firmwareUpdateV4',
|
|
4999
|
-
},
|
|
5000
|
-
});
|
|
5001
|
-
const staleBondError = ERRORS.TypedError(HardwareErrorCode.BlePeerRemovedPairingInformation);
|
|
5002
|
-
const reconnectProtocolV2Device = jest.fn().mockRejectedValue(staleBondError);
|
|
5003
|
-
(method as any).reconnectProtocolV2Device = reconnectProtocolV2Device;
|
|
5004
|
-
|
|
5005
|
-
await expect((method as any).waitForProtocolV2BootloaderMode(60_000, 0)).rejects.toBe(
|
|
5006
|
-
staleBondError
|
|
5007
|
-
);
|
|
5008
|
-
expect(reconnectProtocolV2Device).toHaveBeenCalledTimes(1);
|
|
5009
|
-
});
|
|
5010
|
-
|
|
5011
4994
|
test('polls again when Protocol V2 bootloader serial is temporarily unavailable', async () => {
|
|
5012
4995
|
const method = new FirmwareUpdateV4({
|
|
5013
4996
|
id: 1,
|
|
@@ -9009,36 +8992,6 @@ describe('Protocol V2 firmware update targets', () => {
|
|
|
9009
8992
|
);
|
|
9010
8993
|
});
|
|
9011
8994
|
|
|
9012
|
-
test('does not retry or wrap a stale BLE bond during a V4 file transfer', async () => {
|
|
9013
|
-
const method = new FirmwareUpdateV4({
|
|
9014
|
-
id: 1,
|
|
9015
|
-
payload: {
|
|
9016
|
-
method: 'firmwareUpdateV4',
|
|
9017
|
-
},
|
|
9018
|
-
});
|
|
9019
|
-
const staleBondError = ERRORS.TypedError(HardwareErrorCode.BlePeerRemovedPairingInformation);
|
|
9020
|
-
(method as any).fileWriteChunk = jest.fn().mockRejectedValue(staleBondError);
|
|
9021
|
-
const recoverProtocolV2FileTransfer = jest.fn();
|
|
9022
|
-
(method as any).recoverProtocolV2FileTransfer = recoverProtocolV2FileTransfer;
|
|
9023
|
-
const source = await openFirmwareByteSource({
|
|
9024
|
-
binary: new Uint8Array([1]).buffer,
|
|
9025
|
-
});
|
|
9026
|
-
|
|
9027
|
-
try {
|
|
9028
|
-
await expect(
|
|
9029
|
-
(method as any).protocolV2SourceUpdateProcess({
|
|
9030
|
-
source,
|
|
9031
|
-
filePath: 'vol1:firmware.bin',
|
|
9032
|
-
processedSize: 0,
|
|
9033
|
-
totalSize: 1,
|
|
9034
|
-
})
|
|
9035
|
-
).rejects.toBe(staleBondError);
|
|
9036
|
-
} finally {
|
|
9037
|
-
await source?.close();
|
|
9038
|
-
}
|
|
9039
|
-
expect(recoverProtocolV2FileTransfer).not.toHaveBeenCalled();
|
|
9040
|
-
});
|
|
9041
|
-
|
|
9042
8995
|
test('does not recover or wrap a cancelled V4 file transfer', async () => {
|
|
9043
8996
|
const method = new FirmwareUpdateV4({
|
|
9044
8997
|
id: 1,
|
|
@@ -73,24 +73,26 @@ describe('live device state reads', () => {
|
|
|
73
73
|
}
|
|
74
74
|
);
|
|
75
75
|
|
|
76
|
-
test('
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
76
|
+
test.each(['bootloader', 'romloader'] as const)(
|
|
77
|
+
'reports %s mode for settings scope after minimal mode detection',
|
|
78
|
+
async mode => {
|
|
79
|
+
const getDeviceState = jest.fn().mockResolvedValue({ status: { mode } });
|
|
80
|
+
const method = new GetDeviceState({
|
|
81
|
+
id: 1,
|
|
82
|
+
payload: { method: 'getDeviceState', scope: 'settings' },
|
|
83
|
+
});
|
|
84
|
+
method.init();
|
|
85
|
+
(method as any).device = {
|
|
86
|
+
isProtocolV2: () => true,
|
|
87
|
+
getDeviceState,
|
|
88
|
+
};
|
|
88
89
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
90
|
+
await expect(method.run()).rejects.toMatchObject({
|
|
91
|
+
errorCode: HardwareErrorCode.NotAllowInBootloaderMode,
|
|
92
|
+
});
|
|
93
|
+
expect(getDeviceState).toHaveBeenCalledWith({ refreshSections: ['status', 'settings'] });
|
|
94
|
+
}
|
|
95
|
+
);
|
|
94
96
|
|
|
95
97
|
test('rejects an unknown scope', () => {
|
|
96
98
|
const method = new GetDeviceState({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FirmwareUpdateV4.d.ts","sourceRoot":"","sources":["../../src/api/FirmwareUpdateV4.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"FirmwareUpdateV4.d.ts","sourceRoot":"","sources":["../../src/api/FirmwareUpdateV4.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkD,MAAM,qBAAqB,CAAC;AA0BlG,OAAO,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;AAiC/E,OAAO,KAAK,EAEV,sBAAsB,EAEvB,MAAM,6BAA6B,CAAC;AAuErC,wBAAgB,wCAAwC,CACtD,UAAU,EAAE,WAAW,GAAG,MAAM,GAAG,SAAS,EAC5C,MAAM,EAAE,sBAAsB,EAC9B,0BAA0B,UAAQ,QAiCnC;AA6UD,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,C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cAAe,SAAQ,UAAU,CACpD,QAAQ,CAAC,IAAI,CAAC,oBAAoB,EAAE,OAAO,CAAC,CAAC,CAC9C;IACC,qBAAqB;IAIrB,IAAI;IAmBE,GAAG;
|
|
1
|
+
{"version":3,"file":"GetDeviceState.d.ts","sourceRoot":"","sources":["../../src/api/GetDeviceState.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1C,OAAO,KAAK,EAAoB,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAU1F,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,UAAU,CACpD,QAAQ,CAAC,IAAI,CAAC,oBAAoB,EAAE,OAAO,CAAC,CAAC,CAC9C;IACC,qBAAqB;IAIrB,IAAI;IAmBE,GAAG;CAaV"}
|
|
@@ -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":"AAGA,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;IAaE,GAAG;CAQV"}
|
package/dist/core/index.d.ts
CHANGED
|
@@ -12,7 +12,6 @@ export declare function getPostCallPendingPromise(method: BaseMethod, device: De
|
|
|
12
12
|
export declare function isRetryableBleProtocolV2ProbeError(method: BaseMethod, error: unknown): boolean;
|
|
13
13
|
export declare function isRetryableBleConnectionError(method: BaseMethod, error: unknown): boolean;
|
|
14
14
|
export declare function isMissingDetectedProtocolV2Error(method: BaseMethod, error: unknown): boolean;
|
|
15
|
-
export declare function isTerminalBleStaleBondError(error: unknown): boolean;
|
|
16
15
|
export declare function isDeviceIdentityMismatchError(error: unknown): boolean;
|
|
17
16
|
export declare function resolveBleConnectProtocol(method: BaseMethod): ProtocolType | undefined;
|
|
18
17
|
export declare const cancel: (context: CoreContext, connectId?: string) => 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;AAClC,OAAO,EAEL,KAAK,6BAA6B,EAElC,KAAK,YAAY,EAIlB,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":";AACA,OAAO,YAAY,MAAM,QAAQ,CAAC;AAClC,OAAO,EAEL,KAAK,6BAA6B,EAElC,KAAK,YAAY,EAIlB,MAAM,wBAAwB,CAAC;AAgChC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAsB1C,OAAO,eAAe,MAAM,2BAA2B,CAAC;AAYxD,OAAO,KAAK,EAAE,eAAe,EAAyB,MAAM,UAAU,CAAC;AACvE,OAAO,KAAK,EAAE,WAAW,EAAmD,MAAM,WAAW,CAAC;AAI9F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAYpD,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC;AA0E7D,eAAO,MAAM,OAAO,YAAmB,WAAW,WAAW,WAAW,iBA0FvE,CAAC;AA2FF,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAY3F;AAunBD,wBAAgB,kCAAkC,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,WAWpF;AAED,wBAAgB,6BAA6B,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,WAoB/E;AAED,wBAAgB,gCAAgC,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,WAQlF;AAED,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,OAAO,WAI3D;AAiKD,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,UAAU,GAAG,YAAY,GAAG,SAAS,CAMtF;AA4MD,eAAO,MAAM,MAAM,YAAa,WAAW,cAAc,MAAM,SA4G9D,CAAC;AA8GF,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;IAuChB,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"}
|
|
@@ -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 | 723 | 724 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 823 | 824 | 825 | 826 | 827 | 828 | 830 | 831 | 832 | 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 | 723 | 724 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 823 | 824 | 825 | 826 | 827 | 828 | 830 | 831 | 832 | 900 | 901 | 902 | 903;
|
|
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 | 723 | 724 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 823 | 824 | 825 | 826 | 827 | 828 | 830 | 831 | 832 | 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 | 723 | 724 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 823 | 824 | 825 | 826 | 827 | 828 | 830 | 831 | 832 | 900 | 901 | 902 | 903;
|
|
54
54
|
payload: {
|
|
55
55
|
message: string;
|
|
56
56
|
};
|
|
@@ -81,7 +81,7 @@ export declare class DeviceCommands {
|
|
|
81
81
|
};
|
|
82
82
|
} | {
|
|
83
83
|
success: boolean;
|
|
84
|
-
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 | 723 | 724 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 823 | 824 | 825 | 826 | 827 | 828 | 830 | 831 | 832 | 900 | 901 | 902;
|
|
84
|
+
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 | 723 | 724 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 823 | 824 | 825 | 826 | 827 | 828 | 830 | 831 | 832 | 900 | 901 | 902 | 903;
|
|
85
85
|
payload: {
|
|
86
86
|
message: string;
|
|
87
87
|
};
|
|
@@ -100,7 +100,7 @@ export declare class DeviceCommands {
|
|
|
100
100
|
};
|
|
101
101
|
} | {
|
|
102
102
|
success: boolean;
|
|
103
|
-
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 | 723 | 724 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 823 | 824 | 825 | 826 | 827 | 828 | 830 | 831 | 832 | 900 | 901 | 902;
|
|
103
|
+
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 | 723 | 724 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 823 | 824 | 825 | 826 | 827 | 828 | 830 | 831 | 832 | 900 | 901 | 902 | 903;
|
|
104
104
|
payload: {
|
|
105
105
|
message: string;
|
|
106
106
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeviceCommands.d.ts","sourceRoot":"","sources":["../../src/device/DeviceCommands.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,KAAK,QAAQ,EACb,KAAK,SAAS,EACd,KAAK,oBAAoB,EAG1B,MAAM,wBAAwB,CAAC;AAIhC,OAAO,EAAU,KAAK,wBAAwB,EAAE,MAAM,WAAW,CAAC;AAQlE,OAAO,KAAK,EAAE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d.ts
CHANGED
|
@@ -82,6 +82,7 @@ interface Unsuccessful {
|
|
|
82
82
|
payload: {
|
|
83
83
|
error: string;
|
|
84
84
|
code?: string | number;
|
|
85
|
+
params?: Record<string, unknown>;
|
|
85
86
|
};
|
|
86
87
|
}
|
|
87
88
|
interface Success<T> {
|
|
@@ -144,7 +145,7 @@ declare class DeviceCommands {
|
|
|
144
145
|
};
|
|
145
146
|
} | {
|
|
146
147
|
success: boolean;
|
|
147
|
-
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 | 723 | 724 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 823 | 824 | 825 | 826 | 827 | 828 | 830 | 831 | 832 | 900 | 901 | 902;
|
|
148
|
+
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 | 723 | 724 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 823 | 824 | 825 | 826 | 827 | 828 | 830 | 831 | 832 | 900 | 901 | 902 | 903;
|
|
148
149
|
payload: {
|
|
149
150
|
message: string;
|
|
150
151
|
};
|
|
@@ -163,7 +164,7 @@ declare class DeviceCommands {
|
|
|
163
164
|
};
|
|
164
165
|
} | {
|
|
165
166
|
success: boolean;
|
|
166
|
-
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 | 723 | 724 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 823 | 824 | 825 | 826 | 827 | 828 | 830 | 831 | 832 | 900 | 901 | 902;
|
|
167
|
+
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 | 723 | 724 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 823 | 824 | 825 | 826 | 827 | 828 | 830 | 831 | 832 | 900 | 901 | 902 | 903;
|
|
167
168
|
payload: {
|
|
168
169
|
message: string;
|
|
169
170
|
};
|
package/dist/index.js
CHANGED
|
@@ -41586,7 +41586,7 @@ const parseMessage = (messageData) => {
|
|
|
41586
41586
|
const createErrorMessage = (error) => {
|
|
41587
41587
|
let payload = { error: error.message, code: error.code };
|
|
41588
41588
|
if (error instanceof hdShared.HardwareError) {
|
|
41589
|
-
payload = { error: error.message, code: error.errorCode };
|
|
41589
|
+
payload = { error: error.message, code: error.errorCode, params: error.params };
|
|
41590
41590
|
}
|
|
41591
41591
|
return {
|
|
41592
41592
|
success: false,
|
|
@@ -44268,6 +44268,12 @@ class DeviceCommands {
|
|
|
44268
44268
|
const isProtocolV2DeviceBusyFailure = this.device.isProtocolV2() &&
|
|
44269
44269
|
DEVICE_CONTROL_CALLS.has(callType) &&
|
|
44270
44270
|
subcode === hdTransport.DeviceErrorCode.DeviceError_Busy;
|
|
44271
|
+
const isProtocolV2PinCancelledBusyFailure = this.device.isProtocolV2() &&
|
|
44272
|
+
!DEVICE_SESSION_CALLS.has(callType) &&
|
|
44273
|
+
subcode === hdTransport.DeviceSessionErrorCode.DeviceSessionError_UserCancelled &&
|
|
44274
|
+
/^pin cancelled$/i.test(normalizedMessage);
|
|
44275
|
+
const isProtocolV2FirmwareUpdateBusyFailure = this.device.isProtocolV2() &&
|
|
44276
|
+
/^requested command not allowed while a firmware update is in progress$/i.test(normalizedMessage);
|
|
44271
44277
|
const isLegacyProtocolV2LockedFailure = this.device.isProtocolV2() && /^device (?:is )?locked$/i.test(normalizedMessage);
|
|
44272
44278
|
if (DEVICE_SESSION_CALLS.has(callType) &&
|
|
44273
44279
|
subcode === hdTransport.DeviceSessionErrorCode.DeviceSessionError_InvalidSession) {
|
|
@@ -44318,7 +44324,9 @@ class DeviceCommands {
|
|
|
44318
44324
|
firmwareMessage: message,
|
|
44319
44325
|
});
|
|
44320
44326
|
}
|
|
44321
|
-
else if (isProtocolV2DeviceBusyFailure
|
|
44327
|
+
else if (isProtocolV2DeviceBusyFailure ||
|
|
44328
|
+
isProtocolV2PinCancelledBusyFailure ||
|
|
44329
|
+
isProtocolV2FirmwareUpdateBusyFailure) {
|
|
44322
44330
|
error = hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceBusy, message, {
|
|
44323
44331
|
failureCode: code,
|
|
44324
44332
|
subcode,
|
|
@@ -46728,7 +46736,7 @@ class Device extends events.exports {
|
|
|
46728
46736
|
}
|
|
46729
46737
|
hasUnexpectedMode(allow, require) {
|
|
46730
46738
|
if (!this.isUnacquired()) {
|
|
46731
|
-
if (this.isBootloader()
|
|
46739
|
+
if ((this.isBootloader() || this.isRomloader()) && !allow.includes(UI_REQUEST.BOOTLOADER)) {
|
|
46732
46740
|
return UI_REQUEST.BOOTLOADER;
|
|
46733
46741
|
}
|
|
46734
46742
|
if (!this.isInitialized() && !allow.includes(UI_REQUEST.NOT_INITIALIZE)) {
|
|
@@ -47539,7 +47547,7 @@ class GetDeviceState extends BaseMethod {
|
|
|
47539
47547
|
if (this.params.scope === 'settings' &&
|
|
47540
47548
|
this.device.isProtocolV2() &&
|
|
47541
47549
|
isLoaderMode(state.status.mode)) {
|
|
47542
|
-
throw hdShared.
|
|
47550
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.NotAllowInBootloaderMode);
|
|
47543
47551
|
}
|
|
47544
47552
|
return state;
|
|
47545
47553
|
});
|
|
@@ -52658,12 +52666,11 @@ const getProtocolV2ErrorCode = (error) => {
|
|
|
52658
52666
|
};
|
|
52659
52667
|
const isProtocolV2TerminalInstallStatusError = (error) => {
|
|
52660
52668
|
var _a;
|
|
52661
|
-
return hdShared.
|
|
52662
|
-
(error
|
|
52663
|
-
|
|
52664
|
-
|
|
52665
|
-
|
|
52666
|
-
((_a = error.params) === null || _a === void 0 ? void 0 : _a.firmwareUpdateCode) === PROTOCOL_V2_INSTALL_STATUS_CONFLICT_CODE));
|
|
52669
|
+
return error instanceof hdShared.HardwareError &&
|
|
52670
|
+
(error.errorCode === hdShared.HardwareErrorCode.ActionCancelled ||
|
|
52671
|
+
error.errorCode === hdShared.HardwareErrorCode.FirmwareError ||
|
|
52672
|
+
error.errorCode === hdShared.HardwareErrorCode.FirmwareVerificationFailed ||
|
|
52673
|
+
((_a = error.params) === null || _a === void 0 ? void 0 : _a.firmwareUpdateCode) === PROTOCOL_V2_INSTALL_STATUS_CONFLICT_CODE);
|
|
52667
52674
|
};
|
|
52668
52675
|
const isProtocolV2TargetStatusFinished = (status) => normalizeProtocolV2TargetStatus(status) === PROTOCOL_V2_TARGET_STATUS_FINISHED;
|
|
52669
52676
|
const isProtocolV2TargetStatusInProgress = (status) => normalizeProtocolV2TargetStatus(status) === PROTOCOL_V2_TARGET_STATUS_PENDING ||
|
|
@@ -53757,9 +53764,6 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53757
53764
|
return true;
|
|
53758
53765
|
}
|
|
53759
53766
|
catch (error) {
|
|
53760
|
-
if (hdShared.isBleStaleBondHardwareError(error)) {
|
|
53761
|
-
throw error;
|
|
53762
|
-
}
|
|
53763
53767
|
Log$6.log(`[FirmwareUpdateV4] RESC bundle ${bundle.name} header check failed: `, error);
|
|
53764
53768
|
return false;
|
|
53765
53769
|
}
|
|
@@ -53844,7 +53848,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53844
53848
|
lastError = new Error('Protocol V2 device is reachable but is not in bootloader mode');
|
|
53845
53849
|
}
|
|
53846
53850
|
catch (error) {
|
|
53847
|
-
if (
|
|
53851
|
+
if (this.isProtocolV2ReconnectIdentityError(error)) {
|
|
53848
53852
|
throw error;
|
|
53849
53853
|
}
|
|
53850
53854
|
shouldReconnect = true;
|
|
@@ -54061,9 +54065,6 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
54061
54065
|
}
|
|
54062
54066
|
catch (error) {
|
|
54063
54067
|
this.throwIfAborted();
|
|
54064
|
-
if (hdShared.isBleStaleBondHardwareError(error)) {
|
|
54065
|
-
throw error;
|
|
54066
|
-
}
|
|
54067
54068
|
lastError = error;
|
|
54068
54069
|
if (attempt < PROTOCOL_V2_FILE_TRANSFER_RETRY_COUNT) {
|
|
54069
54070
|
yield this.recoverProtocolV2FileTransfer();
|
|
@@ -54552,9 +54553,6 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
54552
54553
|
}
|
|
54553
54554
|
}
|
|
54554
54555
|
catch (error) {
|
|
54555
|
-
if (hdShared.isBleStaleBondHardwareError(error)) {
|
|
54556
|
-
throw error;
|
|
54557
|
-
}
|
|
54558
54556
|
Log$6.log('[FirmwareUpdateV4] unable to confirm App mode before Normal reboot: ', error);
|
|
54559
54557
|
}
|
|
54560
54558
|
yield this.protocolV2Reboot(hdTransport.DeviceRebootType.Normal);
|
|
@@ -54629,7 +54627,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
54629
54627
|
lastError = hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceNotFound, 'Protocol V2 device is still in bootloader mode');
|
|
54630
54628
|
}
|
|
54631
54629
|
catch (error) {
|
|
54632
|
-
if (
|
|
54630
|
+
if (this.isProtocolV2ReconnectIdentityError(error)) {
|
|
54633
54631
|
throw error;
|
|
54634
54632
|
}
|
|
54635
54633
|
shouldReconnect = true;
|
|
@@ -54907,6 +54905,7 @@ class DeviceReboot extends BaseMethod {
|
|
|
54907
54905
|
return ['V2'];
|
|
54908
54906
|
}
|
|
54909
54907
|
init() {
|
|
54908
|
+
this.allowDeviceMode.push(UI_REQUEST.BOOTLOADER);
|
|
54910
54909
|
this.skipForceUpdateCheck = true;
|
|
54911
54910
|
this.useDevicePassphraseState = false;
|
|
54912
54911
|
this.unlockPolicy = 'unlock-before-run';
|
|
@@ -66817,9 +66816,6 @@ function isMissingDetectedProtocolV2Error(method, error) {
|
|
|
66817
66816
|
typeof typedError.message === 'string' &&
|
|
66818
66817
|
typedError.message.includes('Device protocol has not been detected'));
|
|
66819
66818
|
}
|
|
66820
|
-
function isTerminalBleStaleBondError(error) {
|
|
66821
|
-
return hdShared.isBleStaleBondHardwareError(error);
|
|
66822
|
-
}
|
|
66823
66819
|
function isDeviceIdentityMismatchError(error) {
|
|
66824
66820
|
return ((error === null || error === void 0 ? void 0 : error.errorCode) === hdShared.HardwareErrorCode.DeviceCheckDeviceIdError);
|
|
66825
66821
|
}
|
|
@@ -66984,6 +66980,7 @@ const ensureConnected = (_context, method, connectId, pollingId, abortSignal) =>
|
|
|
66984
66980
|
hdShared.HardwareErrorCode.BridgeNotInstalled,
|
|
66985
66981
|
hdShared.HardwareErrorCode.BridgeTimeoutError,
|
|
66986
66982
|
hdShared.HardwareErrorCode.BridgeNeedsPermission,
|
|
66983
|
+
hdShared.HardwareErrorCode.WebUsbDeviceAccessError,
|
|
66987
66984
|
].includes(error.errorCode)) {
|
|
66988
66985
|
_deviceList = undefined;
|
|
66989
66986
|
reject(error);
|
|
@@ -67058,12 +67055,12 @@ const ensureConnected = (_context, method, connectId, pollingId, abortSignal) =>
|
|
|
67058
67055
|
hdShared.HardwareErrorCode.DeviceDetectInBootloaderMode,
|
|
67059
67056
|
hdShared.HardwareErrorCode.BleCharacteristicNotifyChangeFailure,
|
|
67060
67057
|
hdShared.HardwareErrorCode.BridgeNeedsPermission,
|
|
67058
|
+
hdShared.HardwareErrorCode.WebUsbDeviceAccessError,
|
|
67061
67059
|
hdShared.HardwareErrorCode.DeviceInterruptedFromUser,
|
|
67062
67060
|
hdShared.HardwareErrorCode.CallQueueActionCancelled,
|
|
67063
67061
|
].includes(error.errorCode) ||
|
|
67064
67062
|
(env === 'react-native' &&
|
|
67065
67063
|
[hdShared.HardwareErrorCode.BleDeviceDisconnected, hdShared.HardwareErrorCode.PollingTimeout].includes(error.errorCode)) ||
|
|
67066
|
-
isTerminalBleStaleBondError(error) ||
|
|
67067
67064
|
isDeviceIdentityMismatchError(error)) {
|
|
67068
67065
|
reject(error);
|
|
67069
67066
|
return;
|
package/dist/types/params.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"params.d.ts","sourceRoot":"","sources":["../../src/types/params.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAEnE,MAAM,WAAW,YAAY;IAQ3B,WAAW,CAAC,EAAE,OAAO,CAAC;IAItB,UAAU,CAAC,EAAE,MAAM,CAAC;IAIpB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAI1B,OAAO,CAAC,EAAE,MAAM,CAAC;IAIjB,6BAA6B,CAAC,EAAE,MAAM,CAAC;IAIvC,eAAe,CAAC,EAAE,MAAM,CAAC;IAIzB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAI7B,WAAW,CAAC,EAAE,OAAO,CAAC;IAKtB,aAAa,CAAC,EAAE,OAAO,CAAC;IAGxB,sBAAsB,CAAC,EAAE,OAAO,CAAC;IAKjC,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAK9B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAK9B,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAK/B,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAM3B,eAAe,CAAC,EAAE,uBAAuB,CAAC;IAM1C,sBAAsB,CAAC,EAAE,OAAO,CAAC;CAClC;AAED,MAAM,MAAM,MAAM,CAAC,CAAC,IAAI,YAAY,GAAG,CAAC,GAAG;IAAE,MAAM,CAAC,EAAE,SAAS,CAAA;CAAE,CAAC;AAElE,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,KAAK,CAAC;IACf,OAAO,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"params.d.ts","s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AAC,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/hd-core",
|
|
3
|
-
"version": "1.2.8-alpha.
|
|
3
|
+
"version": "1.2.8-alpha.11",
|
|
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.8-alpha.
|
|
29
|
-
"@onekeyfe/hd-transport": "1.2.8-alpha.
|
|
28
|
+
"@onekeyfe/hd-shared": "1.2.8-alpha.11",
|
|
29
|
+
"@onekeyfe/hd-transport": "1.2.8-alpha.11",
|
|
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": "b605c09bab7bf26b969c73820a73b5cf257ce1dc"
|
|
50
50
|
}
|
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
EDeviceType,
|
|
3
|
-
ERRORS,
|
|
4
|
-
HardwareError,
|
|
5
|
-
HardwareErrorCode,
|
|
6
|
-
isBleStaleBondHardwareError,
|
|
7
|
-
wait,
|
|
8
|
-
} from '@onekeyfe/hd-shared';
|
|
1
|
+
import { EDeviceType, ERRORS, HardwareError, HardwareErrorCode, wait } from '@onekeyfe/hd-shared';
|
|
9
2
|
import JSZip from 'jszip';
|
|
10
3
|
import {
|
|
11
4
|
DeviceRebootType,
|
|
@@ -393,12 +386,11 @@ const getProtocolV2ErrorCode = (error: unknown): number | string | undefined =>
|
|
|
393
386
|
};
|
|
394
387
|
|
|
395
388
|
const isProtocolV2TerminalInstallStatusError = (error: unknown) =>
|
|
396
|
-
|
|
397
|
-
(error
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
error.params?.firmwareUpdateCode === PROTOCOL_V2_INSTALL_STATUS_CONFLICT_CODE));
|
|
389
|
+
error instanceof HardwareError &&
|
|
390
|
+
(error.errorCode === HardwareErrorCode.ActionCancelled ||
|
|
391
|
+
error.errorCode === HardwareErrorCode.FirmwareError ||
|
|
392
|
+
error.errorCode === HardwareErrorCode.FirmwareVerificationFailed ||
|
|
393
|
+
error.params?.firmwareUpdateCode === PROTOCOL_V2_INSTALL_STATUS_CONFLICT_CODE);
|
|
402
394
|
|
|
403
395
|
const isProtocolV2TargetStatusFinished = (status: ProtocolV2FirmwareUpdateStatusTarget['status']) =>
|
|
404
396
|
normalizeProtocolV2TargetStatus(status) === PROTOCOL_V2_TARGET_STATUS_FINISHED;
|
|
@@ -1880,9 +1872,6 @@ export default class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
1880
1872
|
if (!expectedHeaderHash || header.headerHash !== expectedHeaderHash) return false;
|
|
1881
1873
|
return true;
|
|
1882
1874
|
} catch (error) {
|
|
1883
|
-
if (isBleStaleBondHardwareError(error)) {
|
|
1884
|
-
throw error;
|
|
1885
|
-
}
|
|
1886
1875
|
Log.log(`[FirmwareUpdateV4] RESC bundle ${bundle.name} header check failed: `, error);
|
|
1887
1876
|
return false;
|
|
1888
1877
|
}
|
|
@@ -1976,7 +1965,7 @@ export default class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
1976
1965
|
}
|
|
1977
1966
|
lastError = new Error('Protocol V2 device is reachable but is not in bootloader mode');
|
|
1978
1967
|
} catch (error) {
|
|
1979
|
-
if (
|
|
1968
|
+
if (this.isProtocolV2ReconnectIdentityError(error)) {
|
|
1980
1969
|
throw error;
|
|
1981
1970
|
}
|
|
1982
1971
|
shouldReconnect = true;
|
|
@@ -2274,9 +2263,6 @@ export default class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
2274
2263
|
return processedSize + source.size;
|
|
2275
2264
|
} catch (error) {
|
|
2276
2265
|
this.throwIfAborted();
|
|
2277
|
-
if (isBleStaleBondHardwareError(error)) {
|
|
2278
|
-
throw error;
|
|
2279
|
-
}
|
|
2280
2266
|
lastError = error;
|
|
2281
2267
|
if (attempt < PROTOCOL_V2_FILE_TRANSFER_RETRY_COUNT) {
|
|
2282
2268
|
await this.recoverProtocolV2FileTransfer();
|
|
@@ -2944,9 +2930,6 @@ export default class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
2944
2930
|
return;
|
|
2945
2931
|
}
|
|
2946
2932
|
} catch (error) {
|
|
2947
|
-
if (isBleStaleBondHardwareError(error)) {
|
|
2948
|
-
throw error;
|
|
2949
|
-
}
|
|
2950
2933
|
Log.log('[FirmwareUpdateV4] unable to confirm App mode before Normal reboot: ', error);
|
|
2951
2934
|
}
|
|
2952
2935
|
await this.protocolV2Reboot(DeviceRebootType.Normal);
|
|
@@ -3039,7 +3022,7 @@ export default class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
3039
3022
|
'Protocol V2 device is still in bootloader mode'
|
|
3040
3023
|
);
|
|
3041
3024
|
} catch (error) {
|
|
3042
|
-
if (
|
|
3025
|
+
if (this.isProtocolV2ReconnectIdentityError(error)) {
|
|
3043
3026
|
throw error;
|
|
3044
3027
|
}
|
|
3045
3028
|
shouldReconnect = true;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ERRORS, HardwareErrorCode
|
|
1
|
+
import { ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
|
|
2
2
|
|
|
3
3
|
import { UI_REQUEST } from '../constants/ui-request';
|
|
4
4
|
import { BaseMethod } from './BaseMethod';
|
|
@@ -49,10 +49,7 @@ export default class GetDeviceState extends BaseMethod<
|
|
|
49
49
|
this.device.isProtocolV2() &&
|
|
50
50
|
isLoaderMode(state.status.mode)
|
|
51
51
|
) {
|
|
52
|
-
throw
|
|
53
|
-
`${this.name}:${this.params.scope}`,
|
|
54
|
-
this.device.getCurrentFirmwareType()
|
|
55
|
-
);
|
|
52
|
+
throw ERRORS.TypedError(HardwareErrorCode.NotAllowInBootloaderMode);
|
|
56
53
|
}
|
|
57
54
|
return state;
|
|
58
55
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DeviceSessionPinType } from '@onekeyfe/hd-transport';
|
|
2
2
|
|
|
3
|
+
import { UI_REQUEST } from '../../constants/ui-request';
|
|
3
4
|
import { BaseMethod } from '../BaseMethod';
|
|
4
5
|
import { normalizeRebootType } from './helpers';
|
|
5
6
|
|
|
@@ -11,6 +12,7 @@ export default class DeviceReboot extends BaseMethod<DeviceRebootParams> {
|
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
init() {
|
|
15
|
+
this.allowDeviceMode.push(UI_REQUEST.BOOTLOADER);
|
|
14
16
|
this.skipForceUpdateCheck = true;
|
|
15
17
|
this.useDevicePassphraseState = false;
|
|
16
18
|
this.unlockPolicy = 'unlock-before-run';
|
package/src/core/index.ts
CHANGED
|
@@ -23,7 +23,6 @@ import {
|
|
|
23
23
|
createNeedUpgradeFirmwareHardwareError,
|
|
24
24
|
createNewFirmwareForceUpdateHardwareError,
|
|
25
25
|
createNewFirmwareUnReleaseHardwareError,
|
|
26
|
-
isBleStaleBondHardwareError,
|
|
27
26
|
} from '@onekeyfe/hd-shared';
|
|
28
27
|
|
|
29
28
|
import { LoggerNames, enableLog, getLogger, setLoggerPostMessage, wait } from '../utils';
|
|
@@ -1035,10 +1034,6 @@ export function isMissingDetectedProtocolV2Error(method: BaseMethod, error: unkn
|
|
|
1035
1034
|
);
|
|
1036
1035
|
}
|
|
1037
1036
|
|
|
1038
|
-
export function isTerminalBleStaleBondError(error: unknown) {
|
|
1039
|
-
return isBleStaleBondHardwareError(error);
|
|
1040
|
-
}
|
|
1041
|
-
|
|
1042
1037
|
export function isDeviceIdentityMismatchError(error: unknown) {
|
|
1043
1038
|
return (
|
|
1044
1039
|
(error as { errorCode?: unknown })?.errorCode === HardwareErrorCode.DeviceCheckDeviceIdError
|
|
@@ -1277,6 +1272,7 @@ const ensureConnected = async (
|
|
|
1277
1272
|
HardwareErrorCode.BridgeNotInstalled,
|
|
1278
1273
|
HardwareErrorCode.BridgeTimeoutError,
|
|
1279
1274
|
HardwareErrorCode.BridgeNeedsPermission,
|
|
1275
|
+
HardwareErrorCode.WebUsbDeviceAccessError,
|
|
1280
1276
|
].includes(error.errorCode)
|
|
1281
1277
|
) {
|
|
1282
1278
|
_deviceList = undefined;
|
|
@@ -1363,6 +1359,7 @@ const ensureConnected = async (
|
|
|
1363
1359
|
HardwareErrorCode.DeviceDetectInBootloaderMode,
|
|
1364
1360
|
HardwareErrorCode.BleCharacteristicNotifyChangeFailure,
|
|
1365
1361
|
HardwareErrorCode.BridgeNeedsPermission,
|
|
1362
|
+
HardwareErrorCode.WebUsbDeviceAccessError,
|
|
1366
1363
|
HardwareErrorCode.DeviceInterruptedFromUser,
|
|
1367
1364
|
HardwareErrorCode.CallQueueActionCancelled,
|
|
1368
1365
|
].includes(error.errorCode) ||
|
|
@@ -1370,7 +1367,6 @@ const ensureConnected = async (
|
|
|
1370
1367
|
[HardwareErrorCode.BleDeviceDisconnected, HardwareErrorCode.PollingTimeout].includes(
|
|
1371
1368
|
error.errorCode
|
|
1372
1369
|
)) ||
|
|
1373
|
-
isTerminalBleStaleBondError(error) ||
|
|
1374
1370
|
isDeviceIdentityMismatchError(error)
|
|
1375
1371
|
) {
|
|
1376
1372
|
reject(error);
|
package/src/device/Device.ts
CHANGED
|
@@ -1811,7 +1811,7 @@ export class Device extends EventEmitter {
|
|
|
1811
1811
|
// both allow and require cases might generate single unexpected mode
|
|
1812
1812
|
if (!this.isUnacquired()) {
|
|
1813
1813
|
// allow cases
|
|
1814
|
-
if (this.isBootloader()
|
|
1814
|
+
if ((this.isBootloader() || this.isRomloader()) && !allow.includes(UI_REQUEST.BOOTLOADER)) {
|
|
1815
1815
|
return UI_REQUEST.BOOTLOADER;
|
|
1816
1816
|
}
|
|
1817
1817
|
if (!this.isInitialized() && !allow.includes(UI_REQUEST.NOT_INITIALIZE)) {
|
|
@@ -549,6 +549,16 @@ export class DeviceCommands {
|
|
|
549
549
|
this.device.isProtocolV2() &&
|
|
550
550
|
DEVICE_CONTROL_CALLS.has(callType) &&
|
|
551
551
|
subcode === DeviceErrorCode.DeviceError_Busy;
|
|
552
|
+
const isProtocolV2PinCancelledBusyFailure =
|
|
553
|
+
this.device.isProtocolV2() &&
|
|
554
|
+
!DEVICE_SESSION_CALLS.has(callType) &&
|
|
555
|
+
subcode === DeviceSessionErrorCode.DeviceSessionError_UserCancelled &&
|
|
556
|
+
/^pin cancelled$/i.test(normalizedMessage);
|
|
557
|
+
const isProtocolV2FirmwareUpdateBusyFailure =
|
|
558
|
+
this.device.isProtocolV2() &&
|
|
559
|
+
/^requested command not allowed while a firmware update is in progress$/i.test(
|
|
560
|
+
normalizedMessage
|
|
561
|
+
);
|
|
552
562
|
const isLegacyProtocolV2LockedFailure =
|
|
553
563
|
this.device.isProtocolV2() && /^device (?:is )?locked$/i.test(normalizedMessage);
|
|
554
564
|
if (
|
|
@@ -606,7 +616,11 @@ export class DeviceCommands {
|
|
|
606
616
|
subcode,
|
|
607
617
|
firmwareMessage: message,
|
|
608
618
|
});
|
|
609
|
-
} else if (
|
|
619
|
+
} else if (
|
|
620
|
+
isProtocolV2DeviceBusyFailure ||
|
|
621
|
+
isProtocolV2PinCancelledBusyFailure ||
|
|
622
|
+
isProtocolV2FirmwareUpdateBusyFailure
|
|
623
|
+
) {
|
|
610
624
|
error = ERRORS.TypedError(HardwareErrorCode.DeviceBusy, message, {
|
|
611
625
|
failureCode: code,
|
|
612
626
|
subcode,
|
package/src/events/core.ts
CHANGED
|
@@ -54,9 +54,9 @@ export const parseMessage = (messageData: any): CoreMessage => {
|
|
|
54
54
|
};
|
|
55
55
|
|
|
56
56
|
export const createErrorMessage = (error: Error & { code?: string | number }): Unsuccessful => {
|
|
57
|
-
let payload = { error: error.message, code: error.code };
|
|
57
|
+
let payload: Unsuccessful['payload'] = { error: error.message, code: error.code };
|
|
58
58
|
if (error instanceof HardwareError) {
|
|
59
|
-
payload = { error: error.message, code: error.errorCode };
|
|
59
|
+
payload = { error: error.message, code: error.errorCode, params: error.params };
|
|
60
60
|
}
|
|
61
61
|
return {
|
|
62
62
|
success: false,
|
package/src/types/params.ts
CHANGED
|
@@ -83,7 +83,7 @@ export type Params<T> = CommonParams & T & { bundle?: undefined };
|
|
|
83
83
|
|
|
84
84
|
export interface Unsuccessful {
|
|
85
85
|
success: false;
|
|
86
|
-
payload: { error: string; code?: string | number };
|
|
86
|
+
payload: { error: string; code?: string | number; params?: Record<string, unknown> };
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
export interface Success<T> {
|