@onekeyfe/hd-core 1.2.7 → 1.2.8-alpha.2
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 +31 -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/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 +21 -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/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';
|
|
@@ -611,7 +610,6 @@ describe('public device lifecycle events', () => {
|
|
|
611
610
|
test.each([
|
|
612
611
|
[HardwareErrorCode.RuntimeError, true],
|
|
613
612
|
[HardwareErrorCode.BleDeviceBondError, false],
|
|
614
|
-
[HardwareErrorCode.BlePeerRemovedPairingInformation, false],
|
|
615
613
|
] as const)(
|
|
616
614
|
'retries a Protocol V2 probe mismatch with error code %s: %s',
|
|
617
615
|
(errorCode, expected) => {
|
|
@@ -631,8 +629,6 @@ describe('public device lifecycle events', () => {
|
|
|
631
629
|
[HardwareErrorCode.BleTimeoutError, true],
|
|
632
630
|
[HardwareErrorCode.PollingTimeout, false],
|
|
633
631
|
[HardwareErrorCode.BleDeviceBondError, false],
|
|
634
|
-
[HardwareErrorCode.BlePeerRemovedPairingInformation, false],
|
|
635
|
-
[HardwareErrorCode.BleBondInvalid, false],
|
|
636
632
|
] as const)('retries a BLE connection error with error code %s: %s', (errorCode, expected) => {
|
|
637
633
|
const method = { payload: { connectProtocol: 'V2' } } as never;
|
|
638
634
|
const error = {
|
|
@@ -685,19 +681,6 @@ describe('public device lifecycle events', () => {
|
|
|
685
681
|
}
|
|
686
682
|
);
|
|
687
683
|
|
|
688
|
-
test.each([
|
|
689
|
-
[HardwareErrorCode.BleDeviceBondError, true],
|
|
690
|
-
[HardwareErrorCode.BlePeerRemovedPairingInformation, true],
|
|
691
|
-
[HardwareErrorCode.BleBondInvalid, true],
|
|
692
|
-
[HardwareErrorCode.DeviceNotFound, false],
|
|
693
|
-
] as const)('treats BLE stale-bond error code %s as terminal: %s', (errorCode, expected) => {
|
|
694
|
-
const error = {
|
|
695
|
-
errorCode,
|
|
696
|
-
};
|
|
697
|
-
|
|
698
|
-
expect(isTerminalBleStaleBondError(error)).toBe(expected);
|
|
699
|
-
});
|
|
700
|
-
|
|
701
684
|
test.each([
|
|
702
685
|
[HardwareErrorCode.DeviceCheckDeviceIdError, true],
|
|
703
686
|
[HardwareErrorCode.DeviceNotFound, false],
|
|
@@ -1014,6 +997,28 @@ describe('public device lifecycle events', () => {
|
|
|
1014
997
|
expect(device.wasInterruptedByUser()).toBe(false);
|
|
1015
998
|
});
|
|
1016
999
|
|
|
1000
|
+
test.each(['V1', 'V2'] as const)(
|
|
1001
|
+
'retires a failed USB %s session before the next user attempt',
|
|
1002
|
+
async protocol => {
|
|
1003
|
+
jest.spyOn(DataManager, 'getSettings').mockReturnValue('desktop-webusb' as never);
|
|
1004
|
+
const device = createInitializedDevice(protocol);
|
|
1005
|
+
device.originalDescriptor = { ...device.originalDescriptor, session: device.mainId };
|
|
1006
|
+
const disconnect = jest.fn().mockResolvedValue(undefined);
|
|
1007
|
+
const release = jest.fn().mockResolvedValue(undefined);
|
|
1008
|
+
device.deviceConnector = { disconnect, release } as never;
|
|
1009
|
+
device.commands = { disposed: false, dispose: jest.fn() } as never;
|
|
1010
|
+
(device as unknown as { deviceAcquired: boolean }).deviceAcquired = true;
|
|
1011
|
+
const error = ERRORS.TypedError(HardwareErrorCode.WebUsbDeviceAccessError);
|
|
1012
|
+
await expect(device.run(() => Promise.reject(error))).rejects.toBe(error);
|
|
1013
|
+
await new Promise(resolve => {
|
|
1014
|
+
setImmediate(resolve);
|
|
1015
|
+
});
|
|
1016
|
+
expect(disconnect).toHaveBeenCalledWith(device.mainId);
|
|
1017
|
+
expect(release).toHaveBeenCalledTimes(1);
|
|
1018
|
+
expect(device.hasDeviceAcquire()).toBe(false);
|
|
1019
|
+
}
|
|
1020
|
+
);
|
|
1021
|
+
|
|
1017
1022
|
test('waits for the canceled run to finish releasing before cancellation completes', async () => {
|
|
1018
1023
|
jest.spyOn(DataManager, 'getSettings').mockReturnValue('react-native' as never);
|
|
1019
1024
|
const device = createInitializedDevice('V2');
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { EDeviceType } from '@onekeyfe/hd-shared';
|
|
2
|
+
|
|
1
3
|
import { Device } from '../src/device/Device';
|
|
2
4
|
import { UI_REQUEST } from '../src/events/ui-request';
|
|
3
5
|
|
|
@@ -23,12 +25,39 @@ const createBootloaderDevice = (protocolType: 'V1' | 'V2') => {
|
|
|
23
25
|
};
|
|
24
26
|
|
|
25
27
|
describe('Pro2 bootloader mode', () => {
|
|
26
|
-
test('
|
|
28
|
+
test('blocks Protocol V2 methods that are not allowed in bootloader mode', () => {
|
|
29
|
+
const device = createBootloaderDevice('V2');
|
|
30
|
+
|
|
31
|
+
expect(device.hasUnexpectedMode([], [])).toBe(UI_REQUEST.BOOTLOADER);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
test('allows Protocol V2 methods that explicitly support bootloader mode', () => {
|
|
27
35
|
const device = createBootloaderDevice('V2');
|
|
28
36
|
|
|
29
|
-
expect(device.hasUnexpectedMode([], [])).toBeNull();
|
|
37
|
+
expect(device.hasUnexpectedMode([UI_REQUEST.BOOTLOADER], [])).toBeNull();
|
|
30
38
|
});
|
|
31
39
|
|
|
40
|
+
test.each([EDeviceType.Pro2, EDeviceType.Neo])(
|
|
41
|
+
'blocks unsupported Protocol V2 methods in %s romloader mode',
|
|
42
|
+
deviceType => {
|
|
43
|
+
const device = createBootloaderDevice('V2');
|
|
44
|
+
device.updateState(
|
|
45
|
+
{
|
|
46
|
+
protocol: 'V2',
|
|
47
|
+
identity: { deviceType },
|
|
48
|
+
status: { mode: 'romloader', initialized: null },
|
|
49
|
+
},
|
|
50
|
+
'initialize'
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
expect(device.hasUnexpectedMode([], [])).toBe(UI_REQUEST.BOOTLOADER);
|
|
54
|
+
expect(device.hasUnexpectedMode([UI_REQUEST.NOT_INITIALIZE], [])).toBe(UI_REQUEST.BOOTLOADER);
|
|
55
|
+
expect(
|
|
56
|
+
device.hasUnexpectedMode([UI_REQUEST.BOOTLOADER, UI_REQUEST.NOT_INITIALIZE], [])
|
|
57
|
+
).toBeNull();
|
|
58
|
+
}
|
|
59
|
+
);
|
|
60
|
+
|
|
32
61
|
test('keeps the Protocol V1 bootloader restriction', () => {
|
|
33
62
|
const device = createBootloaderDevice('V1');
|
|
34
63
|
|
|
@@ -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.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CAAmC;YAI7B,0BAA0B;IAaxC,OAAO,CAAC,8BAA8B;IAiBtC,OAAO,CAAC,4BAA4B;IAoLpC,OAAO,CAAC,6BAA6B;IAcrC,OAAO,CAAC,qCAAqC;IAoC7C,OAAO,CAAC,kCAAkC;IAyC1C,OAAO,CAAC,8CAA8C;YAIxC,uCAAuC;YA8UvC,gCAAgC;YAehC,yBAAyB;IAUvC,OAAO,CAAC,2BAA2B;YAMrB,8BAA8B;IAQ5C,OAAO,CAAC,0BAA0B;YAkBpB,mCAAmC;YAWnC,qCAAqC;YAmDrC,yBAAyB;YAgGzB,8BAA8B;IAU5C,OAAO,CAAC,kCAAkC;YAQ5B,cAAc;YAyCd,6BAA6B;YAW7B,0BAA0B;YAoB1B,6BAA6B;YAwD7B,gBAAgB;IA0B9B,OAAO,CAAC,qBAAqB;CAM9B"}
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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"}
|
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,GAA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BvC,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,MAAM,EAAE,MAAM,UAAU,CAAC;AAEvC,MAAM,MAAM,wBAAwB,GAAG;IACrC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,KAAK,WAAW,GAAG,QAAQ,CAAC,WAAW,CAAC;AACxC,KAAK,UAAU,GAAG,OAAO,CAAC,MAAM,WAAW,EAAE,MAAM,CAAC,CAAC;AACrD,MAAM,MAAM,oBAAoB,CAAC,CAAC,SAAS,UAAU,IAAI;IACvD,IAAI,EAAE,CAAC,CAAC;IACR,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;CACzB,CAAC;AACF,KAAK,oBAAoB,GAAG;KACzB,CAAC,IAAI,UAAU,GAAG,oBAAoB,CAAC,CAAC,CAAC;CAC3C,CAAC;AACF,MAAM,MAAM,sBAAsB,GAAG,oBAAoB,CAAC,UAAU,CAAC,CAAC;AA8DtE,eAAO,MAAM,oBAAoB,WAAY,MAAM;;;;;;;;;;;;;;;;;;EA0ClD,CAAC;AAEF,eAAO,MAAM,0BAA0B,WAAY,MAAM;;;;;;;;;;;;;;;;;;EAgCxD,CAAC;AASF,qBAAa,cAAc;IACzB,UAAU,EAAE,MAAM,CAAC;IAEnB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B,MAA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AAQ,EAAE,UAAU,EACpB,OAAO,CAAC,EAAE,oBAAoB,GAC7B,OAAO,CAAC,sBAAsB,CAAC;IA4RlC,UAAU,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,oBAAoB;IA8D/C,gBAAgB,CACd,OAAO,EAAE,wBAAwB,EACjC,aAAa,GAAE;QAAE,oBAAoB,CAAC,EAAE,OAAO,CAAA;KAAO;CAiEzD;AAED,MAAM,MAAM,SAAS,GAAG,cAAc,CAAC,WAAW,CAAC,CAAC"}
|
package/dist/index.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
|
@@ -41534,7 +41534,7 @@ const parseMessage = (messageData) => {
|
|
|
41534
41534
|
const createErrorMessage = (error) => {
|
|
41535
41535
|
let payload = { error: error.message, code: error.code };
|
|
41536
41536
|
if (error instanceof hdShared.HardwareError) {
|
|
41537
|
-
payload = { error: error.message, code: error.errorCode };
|
|
41537
|
+
payload = { error: error.message, code: error.errorCode, params: error.params };
|
|
41538
41538
|
}
|
|
41539
41539
|
return {
|
|
41540
41540
|
success: false,
|
|
@@ -44209,6 +44209,12 @@ class DeviceCommands {
|
|
|
44209
44209
|
const isProtocolV2DeviceBusyFailure = this.device.isProtocolV2() &&
|
|
44210
44210
|
DEVICE_CONTROL_CALLS.has(callType) &&
|
|
44211
44211
|
subcode === hdTransport.DeviceErrorCode.DeviceError_Busy;
|
|
44212
|
+
const isProtocolV2PinCancelledBusyFailure = this.device.isProtocolV2() &&
|
|
44213
|
+
!DEVICE_SESSION_CALLS.has(callType) &&
|
|
44214
|
+
subcode === hdTransport.DeviceSessionErrorCode.DeviceSessionError_UserCancelled &&
|
|
44215
|
+
/^pin cancelled$/i.test(normalizedMessage);
|
|
44216
|
+
const isProtocolV2FirmwareUpdateBusyFailure = this.device.isProtocolV2() &&
|
|
44217
|
+
/^requested command not allowed while a firmware update is in progress$/i.test(normalizedMessage);
|
|
44212
44218
|
const isLegacyProtocolV2LockedFailure = this.device.isProtocolV2() && /^device (?:is )?locked$/i.test(normalizedMessage);
|
|
44213
44219
|
if (DEVICE_SESSION_CALLS.has(callType) &&
|
|
44214
44220
|
subcode === hdTransport.DeviceSessionErrorCode.DeviceSessionError_InvalidSession) {
|
|
@@ -44259,7 +44265,9 @@ class DeviceCommands {
|
|
|
44259
44265
|
firmwareMessage: message,
|
|
44260
44266
|
});
|
|
44261
44267
|
}
|
|
44262
|
-
else if (isProtocolV2DeviceBusyFailure
|
|
44268
|
+
else if (isProtocolV2DeviceBusyFailure ||
|
|
44269
|
+
isProtocolV2PinCancelledBusyFailure ||
|
|
44270
|
+
isProtocolV2FirmwareUpdateBusyFailure) {
|
|
44263
44271
|
error = hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceBusy, message, {
|
|
44264
44272
|
failureCode: code,
|
|
44265
44273
|
subcode,
|
|
@@ -46661,7 +46669,7 @@ class Device extends events.exports {
|
|
|
46661
46669
|
}
|
|
46662
46670
|
hasUnexpectedMode(allow, require) {
|
|
46663
46671
|
if (!this.isUnacquired()) {
|
|
46664
|
-
if (this.isBootloader()
|
|
46672
|
+
if ((this.isBootloader() || this.isRomloader()) && !allow.includes(UI_REQUEST.BOOTLOADER)) {
|
|
46665
46673
|
return UI_REQUEST.BOOTLOADER;
|
|
46666
46674
|
}
|
|
46667
46675
|
if (!this.isInitialized() && !allow.includes(UI_REQUEST.NOT_INITIALIZE)) {
|
|
@@ -47472,7 +47480,7 @@ class GetDeviceState extends BaseMethod {
|
|
|
47472
47480
|
if (this.params.scope === 'settings' &&
|
|
47473
47481
|
this.device.isProtocolV2() &&
|
|
47474
47482
|
isLoaderMode(state.status.mode)) {
|
|
47475
|
-
throw hdShared.
|
|
47483
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.NotAllowInBootloaderMode);
|
|
47476
47484
|
}
|
|
47477
47485
|
return state;
|
|
47478
47486
|
});
|
|
@@ -52591,12 +52599,11 @@ const getProtocolV2ErrorCode = (error) => {
|
|
|
52591
52599
|
};
|
|
52592
52600
|
const isProtocolV2TerminalInstallStatusError = (error) => {
|
|
52593
52601
|
var _a;
|
|
52594
|
-
return hdShared.
|
|
52595
|
-
(error
|
|
52596
|
-
|
|
52597
|
-
|
|
52598
|
-
|
|
52599
|
-
((_a = error.params) === null || _a === void 0 ? void 0 : _a.firmwareUpdateCode) === PROTOCOL_V2_INSTALL_STATUS_CONFLICT_CODE));
|
|
52602
|
+
return error instanceof hdShared.HardwareError &&
|
|
52603
|
+
(error.errorCode === hdShared.HardwareErrorCode.ActionCancelled ||
|
|
52604
|
+
error.errorCode === hdShared.HardwareErrorCode.FirmwareError ||
|
|
52605
|
+
error.errorCode === hdShared.HardwareErrorCode.FirmwareVerificationFailed ||
|
|
52606
|
+
((_a = error.params) === null || _a === void 0 ? void 0 : _a.firmwareUpdateCode) === PROTOCOL_V2_INSTALL_STATUS_CONFLICT_CODE);
|
|
52600
52607
|
};
|
|
52601
52608
|
const isProtocolV2TargetStatusFinished = (status) => normalizeProtocolV2TargetStatus(status) === PROTOCOL_V2_TARGET_STATUS_FINISHED;
|
|
52602
52609
|
const isProtocolV2TargetStatusInProgress = (status) => normalizeProtocolV2TargetStatus(status) === PROTOCOL_V2_TARGET_STATUS_PENDING ||
|
|
@@ -53690,9 +53697,6 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53690
53697
|
return true;
|
|
53691
53698
|
}
|
|
53692
53699
|
catch (error) {
|
|
53693
|
-
if (hdShared.isBleStaleBondHardwareError(error)) {
|
|
53694
|
-
throw error;
|
|
53695
|
-
}
|
|
53696
53700
|
Log$6.log(`[FirmwareUpdateV4] RESC bundle ${bundle.name} header check failed: `, error);
|
|
53697
53701
|
return false;
|
|
53698
53702
|
}
|
|
@@ -53777,7 +53781,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53777
53781
|
lastError = new Error('Protocol V2 device is reachable but is not in bootloader mode');
|
|
53778
53782
|
}
|
|
53779
53783
|
catch (error) {
|
|
53780
|
-
if (
|
|
53784
|
+
if (this.isProtocolV2ReconnectIdentityError(error)) {
|
|
53781
53785
|
throw error;
|
|
53782
53786
|
}
|
|
53783
53787
|
shouldReconnect = true;
|
|
@@ -53994,9 +53998,6 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53994
53998
|
}
|
|
53995
53999
|
catch (error) {
|
|
53996
54000
|
this.throwIfAborted();
|
|
53997
|
-
if (hdShared.isBleStaleBondHardwareError(error)) {
|
|
53998
|
-
throw error;
|
|
53999
|
-
}
|
|
54000
54001
|
lastError = error;
|
|
54001
54002
|
if (attempt < PROTOCOL_V2_FILE_TRANSFER_RETRY_COUNT) {
|
|
54002
54003
|
yield this.recoverProtocolV2FileTransfer();
|
|
@@ -54485,9 +54486,6 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
54485
54486
|
}
|
|
54486
54487
|
}
|
|
54487
54488
|
catch (error) {
|
|
54488
|
-
if (hdShared.isBleStaleBondHardwareError(error)) {
|
|
54489
|
-
throw error;
|
|
54490
|
-
}
|
|
54491
54489
|
Log$6.log('[FirmwareUpdateV4] unable to confirm App mode before Normal reboot: ', error);
|
|
54492
54490
|
}
|
|
54493
54491
|
yield this.protocolV2Reboot(hdTransport.DeviceRebootType.Normal);
|
|
@@ -54562,7 +54560,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
54562
54560
|
lastError = hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceNotFound, 'Protocol V2 device is still in bootloader mode');
|
|
54563
54561
|
}
|
|
54564
54562
|
catch (error) {
|
|
54565
|
-
if (
|
|
54563
|
+
if (this.isProtocolV2ReconnectIdentityError(error)) {
|
|
54566
54564
|
throw error;
|
|
54567
54565
|
}
|
|
54568
54566
|
shouldReconnect = true;
|
|
@@ -66683,9 +66681,6 @@ function isMissingDetectedProtocolV2Error(method, error) {
|
|
|
66683
66681
|
typeof typedError.message === 'string' &&
|
|
66684
66682
|
typedError.message.includes('Device protocol has not been detected'));
|
|
66685
66683
|
}
|
|
66686
|
-
function isTerminalBleStaleBondError(error) {
|
|
66687
|
-
return hdShared.isBleStaleBondHardwareError(error);
|
|
66688
|
-
}
|
|
66689
66684
|
function isDeviceIdentityMismatchError(error) {
|
|
66690
66685
|
return ((error === null || error === void 0 ? void 0 : error.errorCode) === hdShared.HardwareErrorCode.DeviceCheckDeviceIdError);
|
|
66691
66686
|
}
|
|
@@ -66850,6 +66845,7 @@ const ensureConnected = (_context, method, connectId, pollingId, abortSignal) =>
|
|
|
66850
66845
|
hdShared.HardwareErrorCode.BridgeNotInstalled,
|
|
66851
66846
|
hdShared.HardwareErrorCode.BridgeTimeoutError,
|
|
66852
66847
|
hdShared.HardwareErrorCode.BridgeNeedsPermission,
|
|
66848
|
+
hdShared.HardwareErrorCode.WebUsbDeviceAccessError,
|
|
66853
66849
|
].includes(error.errorCode)) {
|
|
66854
66850
|
_deviceList = undefined;
|
|
66855
66851
|
reject(error);
|
|
@@ -66924,12 +66920,12 @@ const ensureConnected = (_context, method, connectId, pollingId, abortSignal) =>
|
|
|
66924
66920
|
hdShared.HardwareErrorCode.DeviceDetectInBootloaderMode,
|
|
66925
66921
|
hdShared.HardwareErrorCode.BleCharacteristicNotifyChangeFailure,
|
|
66926
66922
|
hdShared.HardwareErrorCode.BridgeNeedsPermission,
|
|
66923
|
+
hdShared.HardwareErrorCode.WebUsbDeviceAccessError,
|
|
66927
66924
|
hdShared.HardwareErrorCode.DeviceInterruptedFromUser,
|
|
66928
66925
|
hdShared.HardwareErrorCode.CallQueueActionCancelled,
|
|
66929
66926
|
].includes(error.errorCode) ||
|
|
66930
66927
|
(env === 'react-native' &&
|
|
66931
66928
|
[hdShared.HardwareErrorCode.BleDeviceDisconnected, hdShared.HardwareErrorCode.PollingTimeout].includes(error.errorCode)) ||
|
|
66932
|
-
isTerminalBleStaleBondError(error) ||
|
|
66933
66929
|
isDeviceIdentityMismatchError(error)) {
|
|
66934
66930
|
reject(error);
|
|
66935
66931
|
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,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AO,EAAE,CAAC,CAAC;CACZ;AAED,MAAM,MAAM,QAAQ,CAAC,CAAC,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.
|
|
3
|
+
"version": "1.2.8-alpha.2",
|
|
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.
|
|
29
|
-
"@onekeyfe/hd-transport": "1.2.
|
|
28
|
+
"@onekeyfe/hd-shared": "1.2.8-alpha.2",
|
|
29
|
+
"@onekeyfe/hd-transport": "1.2.8-alpha.2",
|
|
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": "74ac64464df3806ef44ad54d313378754c3eaed2"
|
|
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
|
}
|
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
|
@@ -1801,7 +1801,7 @@ export class Device extends EventEmitter {
|
|
|
1801
1801
|
// both allow and require cases might generate single unexpected mode
|
|
1802
1802
|
if (!this.isUnacquired()) {
|
|
1803
1803
|
// allow cases
|
|
1804
|
-
if (this.isBootloader()
|
|
1804
|
+
if ((this.isBootloader() || this.isRomloader()) && !allow.includes(UI_REQUEST.BOOTLOADER)) {
|
|
1805
1805
|
return UI_REQUEST.BOOTLOADER;
|
|
1806
1806
|
}
|
|
1807
1807
|
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> {
|