@onekeyfe/hd-core 1.2.8-alpha.52 → 1.2.8-alpha.53
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__/core-dispose.test.ts +114 -1
- package/__tests__/core-error-output.test.ts +21 -0
- package/__tests__/device-connector-protocol.test.ts +5 -2
- package/__tests__/device-lifecycle-events.test.ts +22 -3
- package/__tests__/usb-identity-probe.test.ts +358 -0
- package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
- package/dist/api/SearchDevices.d.ts +21 -1
- package/dist/api/SearchDevices.d.ts.map +1 -1
- package/dist/core/index.d.ts +3 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/device/DeviceCommands.d.ts +4 -4
- package/dist/index.d.ts +36 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2692 -2534
- package/dist/types/device.d.ts +9 -0
- package/dist/types/device.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/api/FirmwareUpdateV4.ts +4 -7
- package/src/api/SearchDevices.ts +172 -7
- package/src/core/index.ts +45 -14
- package/src/device/DeviceConnector.ts +4 -4
- package/src/index.ts +1 -0
- package/src/types/device.ts +12 -0
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { HardwareErrorCode, createDeferred } from '@onekeyfe/hd-shared';
|
|
2
|
+
|
|
3
|
+
import Core, { init, initConnector, initCore, switchTransport } from '../src/core';
|
|
4
|
+
import DataManager from '../src/data-manager/DataManager';
|
|
2
5
|
import TransportManager from '../src/data-manager/TransportManager';
|
|
3
6
|
import { DevicePool } from '../src/device/DevicePool';
|
|
4
7
|
|
|
@@ -31,4 +34,114 @@ describe('Core.dispose', () => {
|
|
|
31
34
|
expect(transportStop).toHaveBeenCalledTimes(1);
|
|
32
35
|
expect(disposeDevicePool).toHaveBeenCalledTimes(1);
|
|
33
36
|
});
|
|
37
|
+
|
|
38
|
+
test('disposal rejects a queued switch without recreating a transport or connector', async () => {
|
|
39
|
+
const previous = TransportManager.transport;
|
|
40
|
+
const { settings } = DataManager;
|
|
41
|
+
const active = { stop: jest.fn().mockResolvedValue(undefined) };
|
|
42
|
+
const replacement = jest.fn(() => ({ stop: jest.fn().mockResolvedValue(undefined) }));
|
|
43
|
+
TransportManager.transport = active as never;
|
|
44
|
+
const core = initCore();
|
|
45
|
+
initConnector();
|
|
46
|
+
const switching = switchTransport({ env: 'emulator', Transport: replacement });
|
|
47
|
+
const rejected = expect(switching).rejects.toMatchObject({
|
|
48
|
+
errorCode: HardwareErrorCode.NotInitialized,
|
|
49
|
+
});
|
|
50
|
+
try {
|
|
51
|
+
await core.dispose();
|
|
52
|
+
await rejected;
|
|
53
|
+
expect(replacement).not.toHaveBeenCalled();
|
|
54
|
+
expect(TransportManager.transport).toBe(active);
|
|
55
|
+
expect(DataManager.settings).toBe(settings);
|
|
56
|
+
expect(DevicePool.emitter.eventNames()).toHaveLength(0);
|
|
57
|
+
} finally {
|
|
58
|
+
await Promise.allSettled([switching]);
|
|
59
|
+
await core.dispose();
|
|
60
|
+
TransportManager.transport = previous;
|
|
61
|
+
DataManager.settings = settings;
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
test.each(['dispose/reinit', 'init', 'initCore'] as const)(
|
|
66
|
+
'%s invalidates running and queued switches without blocking a new lifecycle',
|
|
67
|
+
async lifecycle => {
|
|
68
|
+
const previous = TransportManager.transport;
|
|
69
|
+
const { settings } = DataManager;
|
|
70
|
+
const entered = createDeferred<void>();
|
|
71
|
+
const closing = createDeferred<void>();
|
|
72
|
+
const loading = createDeferred<void>();
|
|
73
|
+
const active = {
|
|
74
|
+
stop: jest.fn(() => {
|
|
75
|
+
entered.resolve();
|
|
76
|
+
return closing.promise;
|
|
77
|
+
}),
|
|
78
|
+
};
|
|
79
|
+
const intermediate = jest.fn(() => ({ stop: jest.fn().mockResolvedValue(undefined) }));
|
|
80
|
+
const stale = jest.fn(() => ({ stop: jest.fn().mockResolvedValue(undefined) }));
|
|
81
|
+
const fresh = { stop: jest.fn().mockResolvedValue(undefined) };
|
|
82
|
+
const current = { stop: jest.fn().mockResolvedValue(undefined) };
|
|
83
|
+
const Fresh = jest.fn(() => fresh);
|
|
84
|
+
jest.spyOn(DataManager, 'load').mockImplementation(async next => {
|
|
85
|
+
await loading.promise;
|
|
86
|
+
DataManager.settings = next;
|
|
87
|
+
});
|
|
88
|
+
TransportManager.transport = active as never;
|
|
89
|
+
let core = initCore();
|
|
90
|
+
initConnector();
|
|
91
|
+
const first = switchTransport({ env: 'emulator', Transport: intermediate });
|
|
92
|
+
await entered.promise;
|
|
93
|
+
const second = switchTransport({ env: 'webusb', Transport: stale });
|
|
94
|
+
const rejected = Promise.all([
|
|
95
|
+
expect(first).rejects.toMatchObject({ errorCode: HardwareErrorCode.NotInitialized }),
|
|
96
|
+
expect(second).rejects.toMatchObject({ errorCode: HardwareErrorCode.NotInitialized }),
|
|
97
|
+
]);
|
|
98
|
+
rejected.catch(() => undefined);
|
|
99
|
+
let initializing: ReturnType<typeof init> | undefined;
|
|
100
|
+
try {
|
|
101
|
+
if (lifecycle === 'dispose/reinit') {
|
|
102
|
+
const disposing = core.dispose();
|
|
103
|
+
closing.resolve();
|
|
104
|
+
await disposing;
|
|
105
|
+
}
|
|
106
|
+
if (lifecycle === 'initCore') {
|
|
107
|
+
TransportManager.transport = fresh as never;
|
|
108
|
+
DataManager.settings = { ...settings, env: 'desktop-web-ble' };
|
|
109
|
+
core = initCore();
|
|
110
|
+
initConnector();
|
|
111
|
+
} else {
|
|
112
|
+
initializing = init({ ...settings, env: 'desktop-web-ble' }, Fresh);
|
|
113
|
+
if (lifecycle === 'init') {
|
|
114
|
+
closing.resolve();
|
|
115
|
+
await rejected;
|
|
116
|
+
}
|
|
117
|
+
loading.resolve();
|
|
118
|
+
const initialized = await initializing;
|
|
119
|
+
if (!initialized) throw new Error('Core initialization failed');
|
|
120
|
+
core = initialized;
|
|
121
|
+
}
|
|
122
|
+
await switchTransport({
|
|
123
|
+
env: 'emulator',
|
|
124
|
+
Transport: function Current() {
|
|
125
|
+
return current;
|
|
126
|
+
},
|
|
127
|
+
});
|
|
128
|
+
closing.resolve();
|
|
129
|
+
await rejected;
|
|
130
|
+
expect(intermediate).not.toHaveBeenCalled();
|
|
131
|
+
expect(stale).not.toHaveBeenCalled();
|
|
132
|
+
expect(TransportManager.transport).toBe(current);
|
|
133
|
+
expect(DataManager.getSettings('env')).toBe('emulator');
|
|
134
|
+
expect(fresh.stop).toHaveBeenCalledTimes(1);
|
|
135
|
+
expect(current.stop).not.toHaveBeenCalled();
|
|
136
|
+
} finally {
|
|
137
|
+
closing.resolve();
|
|
138
|
+
loading.resolve();
|
|
139
|
+
await initializing;
|
|
140
|
+
await Promise.allSettled([first, second, rejected]);
|
|
141
|
+
await core.dispose();
|
|
142
|
+
TransportManager.transport = previous;
|
|
143
|
+
DataManager.settings = settings;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
);
|
|
34
147
|
});
|
|
@@ -45,6 +45,23 @@ describe('Core 错误输出边界', () => {
|
|
|
45
45
|
});
|
|
46
46
|
});
|
|
47
47
|
|
|
48
|
+
test.each([
|
|
49
|
+
[HardwareErrorCode.TransportProtocolProbeFailed, { expectedProtocol: 'V1' }],
|
|
50
|
+
[
|
|
51
|
+
HardwareErrorCode.TransportProtocolMismatch,
|
|
52
|
+
{ expectedProtocol: 'V2', detectedProtocol: 'V1' },
|
|
53
|
+
],
|
|
54
|
+
] as const)(
|
|
55
|
+
'preserves protocol error %s and structured context across the public boundary',
|
|
56
|
+
(code, params) => {
|
|
57
|
+
const error = ERRORS.TypedError(code, undefined, params);
|
|
58
|
+
expect(JSON.parse(JSON.stringify(createErrorMessage(error)))).toEqual({
|
|
59
|
+
success: false,
|
|
60
|
+
payload: { code, error: error.message, params },
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
);
|
|
64
|
+
|
|
48
65
|
test.each([
|
|
49
66
|
['webusb', false],
|
|
50
67
|
['desktop-webusb', false],
|
|
@@ -129,6 +146,8 @@ describe('Core 错误输出边界', () => {
|
|
|
129
146
|
HardwareErrorCode.BleUnsupported,
|
|
130
147
|
HardwareErrorCode.BridgeNeedsPermission,
|
|
131
148
|
HardwareErrorCode.WebUsbDeviceAccessError,
|
|
149
|
+
HardwareErrorCode.TransportProtocolProbeFailed,
|
|
150
|
+
HardwareErrorCode.TransportProtocolMismatch,
|
|
132
151
|
])(
|
|
133
152
|
'preserves terminal transport error %s in the public response without polling again',
|
|
134
153
|
async errorCode => {
|
|
@@ -138,6 +157,8 @@ describe('Core 错误输出边界', () => {
|
|
|
138
157
|
[
|
|
139
158
|
HardwareErrorCode.BridgeNeedsPermission,
|
|
140
159
|
HardwareErrorCode.WebUsbDeviceAccessError,
|
|
160
|
+
HardwareErrorCode.TransportProtocolProbeFailed,
|
|
161
|
+
HardwareErrorCode.TransportProtocolMismatch,
|
|
141
162
|
].includes(errorCode)
|
|
142
163
|
? ('desktop-webusb' as never)
|
|
143
164
|
: ('react-native' as never)
|
|
@@ -75,8 +75,11 @@ describe('DeviceConnector protocol validation', () => {
|
|
|
75
75
|
});
|
|
76
76
|
const connector = new DeviceConnector();
|
|
77
77
|
|
|
78
|
-
await expect(connector.acquire('classic-id', undefined, undefined, 'V2')).rejects.
|
|
79
|
-
|
|
78
|
+
await expect(connector.acquire('classic-id', undefined, undefined, 'V2')).rejects.toMatchObject(
|
|
79
|
+
{
|
|
80
|
+
errorCode: HardwareErrorCode.TransportProtocolMismatch,
|
|
81
|
+
params: { expectedProtocol: 'V2', detectedProtocol: 'V1' },
|
|
82
|
+
}
|
|
80
83
|
);
|
|
81
84
|
});
|
|
82
85
|
|
|
@@ -610,7 +610,9 @@ describe('public device lifecycle events', () => {
|
|
|
610
610
|
);
|
|
611
611
|
|
|
612
612
|
test.each([
|
|
613
|
-
[HardwareErrorCode.
|
|
613
|
+
[HardwareErrorCode.TransportProtocolProbeFailed, true],
|
|
614
|
+
[HardwareErrorCode.TransportProtocolMismatch, false],
|
|
615
|
+
[HardwareErrorCode.RuntimeError, false],
|
|
614
616
|
[HardwareErrorCode.BleDeviceBondError, false],
|
|
615
617
|
] as const)(
|
|
616
618
|
'retries a Protocol V2 probe mismatch with error code %s: %s',
|
|
@@ -618,8 +620,8 @@ describe('public device lifecycle events', () => {
|
|
|
618
620
|
const method = { payload: { connectProtocol: 'V2' } } as never;
|
|
619
621
|
const error = {
|
|
620
622
|
errorCode,
|
|
621
|
-
message:
|
|
622
|
-
|
|
623
|
+
message: 'diagnostic wording is not used for classification',
|
|
624
|
+
params: { expectedProtocol: 'V2' },
|
|
623
625
|
};
|
|
624
626
|
|
|
625
627
|
expect(isRetryableBleProtocolV2ProbeError(method, error)).toBe(expected);
|
|
@@ -629,6 +631,8 @@ describe('public device lifecycle events', () => {
|
|
|
629
631
|
test.each([
|
|
630
632
|
[HardwareErrorCode.BleConnectedError, true],
|
|
631
633
|
[HardwareErrorCode.BleTimeoutError, true],
|
|
634
|
+
[HardwareErrorCode.TransportProtocolProbeFailed, true],
|
|
635
|
+
[HardwareErrorCode.TransportProtocolMismatch, false],
|
|
632
636
|
[HardwareErrorCode.PollingTimeout, false],
|
|
633
637
|
[HardwareErrorCode.BleDeviceBondError, false],
|
|
634
638
|
] as const)('retries a BLE connection error with error code %s: %s', (errorCode, expected) => {
|
|
@@ -641,6 +645,21 @@ describe('public device lifecycle events', () => {
|
|
|
641
645
|
expect(isRetryableBleConnectionError(method, error)).toBe(expected);
|
|
642
646
|
});
|
|
643
647
|
|
|
648
|
+
test('does not retry a failed strict V1 probe as a V2 probe or after user cancellation', () => {
|
|
649
|
+
const error = ERRORS.TypedError(HardwareErrorCode.TransportProtocolProbeFailed, undefined, {
|
|
650
|
+
expectedProtocol: 'V1',
|
|
651
|
+
});
|
|
652
|
+
const method = { payload: { connectProtocol: 'V2' } } as never;
|
|
653
|
+
expect(isRetryableBleProtocolV2ProbeError(method, error)).toBe(false);
|
|
654
|
+
expect(isRetryableBleConnectionError(method, error)).toBe(false);
|
|
655
|
+
expect(
|
|
656
|
+
isRetryableBleConnectionError(
|
|
657
|
+
{ payload: {}, device: { wasInterruptedByUser: () => true } } as never,
|
|
658
|
+
ERRORS.TypedError(HardwareErrorCode.TransportProtocolProbeFailed)
|
|
659
|
+
)
|
|
660
|
+
).toBe(false);
|
|
661
|
+
});
|
|
662
|
+
|
|
644
663
|
test('does not retry the desktop acquire deadline fallback', () => {
|
|
645
664
|
const method = { payload: { connectProtocol: 'V2' } } as never;
|
|
646
665
|
const error = {
|
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
import protocolTransport, { DeviceType } from '@onekeyfe/hd-transport';
|
|
2
|
+
import { EDeviceType } from '@onekeyfe/hd-shared';
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
getOwnedUsbDeviceIdentity,
|
|
6
|
+
probeUsbDeviceIdentitiesWithTransport,
|
|
7
|
+
} from '../src/api/SearchDevices';
|
|
8
|
+
import DataManager from '../src/data-manager/DataManager';
|
|
9
|
+
import TransportManager from '../src/data-manager/TransportManager';
|
|
10
|
+
|
|
11
|
+
import type { UsbIdentityProbeTransport } from '../src/api/SearchDevices';
|
|
12
|
+
import type { OneKeyDeviceInfo, Transport } from '@onekeyfe/hd-transport';
|
|
13
|
+
import type { ConnectSettings } from '../src/types';
|
|
14
|
+
import type { Device } from '../src/device/Device';
|
|
15
|
+
|
|
16
|
+
jest.mock('../src/data/config', () => ({
|
|
17
|
+
getSDKVersion: () => '1.2.8-alpha.12',
|
|
18
|
+
DEFAULT_DOMAIN: 'https://jssdk.onekey.so/1.2.8-alpha.12/',
|
|
19
|
+
}));
|
|
20
|
+
|
|
21
|
+
const descriptor = { path: 'USB_DESCRIPTOR_PATH', commType: 'webusb' } as OneKeyDeviceInfo;
|
|
22
|
+
const createTransport = () => ({
|
|
23
|
+
init: jest.fn(),
|
|
24
|
+
configure: jest.fn(),
|
|
25
|
+
configureProtocolV2: jest.fn(),
|
|
26
|
+
enumerate: jest.fn().mockResolvedValue([descriptor]),
|
|
27
|
+
acquire: jest.fn().mockResolvedValue('usb-transport-handle'),
|
|
28
|
+
release: jest.fn().mockResolvedValue(undefined),
|
|
29
|
+
getProtocolType: jest.fn().mockReturnValue('V1'),
|
|
30
|
+
call: jest.fn().mockResolvedValue({
|
|
31
|
+
type: 'Features',
|
|
32
|
+
message: {
|
|
33
|
+
onekey_serial_no: 'PHYSICAL_SERIAL',
|
|
34
|
+
onekey_device_type: 'CLASSIC1S',
|
|
35
|
+
device_id: 'WALLET_ID',
|
|
36
|
+
},
|
|
37
|
+
}),
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
describe('isolated USB identity probe', () => {
|
|
41
|
+
test('identifies V1 by live identity while preserving the active BLE settings and transport', async () => {
|
|
42
|
+
const previousSettings = DataManager.settings;
|
|
43
|
+
const previousTransport = TransportManager.transport;
|
|
44
|
+
const activeBLE = { name: 'active-ble', pendingOperation: true } as unknown as Transport;
|
|
45
|
+
const settings = { env: 'desktop-web-ble' } as ConnectSettings;
|
|
46
|
+
DataManager.settings = settings;
|
|
47
|
+
TransportManager.transport = activeBLE;
|
|
48
|
+
const transport = createTransport();
|
|
49
|
+
try {
|
|
50
|
+
await expect(probeUsbDeviceIdentitiesWithTransport(transport, 'webusb')).resolves.toEqual([
|
|
51
|
+
{
|
|
52
|
+
path: 'USB_DESCRIPTOR_PATH',
|
|
53
|
+
serialNo: 'PHYSICAL_SERIAL',
|
|
54
|
+
deviceId: 'WALLET_ID',
|
|
55
|
+
deviceType: EDeviceType.Classic1s,
|
|
56
|
+
connectProtocol: 'V1',
|
|
57
|
+
commType: 'webusb',
|
|
58
|
+
mode: 'normal',
|
|
59
|
+
},
|
|
60
|
+
]);
|
|
61
|
+
expect(DataManager.settings).toBe(settings);
|
|
62
|
+
expect(TransportManager.transport).toBe(activeBLE);
|
|
63
|
+
expect(transport.call).toHaveBeenCalledWith(
|
|
64
|
+
'usb-transport-handle',
|
|
65
|
+
'GetFeatures',
|
|
66
|
+
{},
|
|
67
|
+
{ timeoutMs: 3000 }
|
|
68
|
+
);
|
|
69
|
+
expect(transport.release).toHaveBeenCalledWith('usb-transport-handle', false);
|
|
70
|
+
} finally {
|
|
71
|
+
DataManager.settings = previousSettings;
|
|
72
|
+
TransportManager.transport = previousTransport;
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
test.each([
|
|
77
|
+
EDeviceType.Classic,
|
|
78
|
+
EDeviceType.Classic1s,
|
|
79
|
+
EDeviceType.ClassicPure,
|
|
80
|
+
EDeviceType.Mini,
|
|
81
|
+
EDeviceType.Touch,
|
|
82
|
+
EDeviceType.Pro,
|
|
83
|
+
])('reads the V1 identity for %s without initializing a wallet', async deviceType => {
|
|
84
|
+
const transport = createTransport();
|
|
85
|
+
transport.call.mockResolvedValue({
|
|
86
|
+
type: 'Features',
|
|
87
|
+
message: {
|
|
88
|
+
onekey_serial_no: 'V1_PHYSICAL_SERIAL',
|
|
89
|
+
onekey_device_type:
|
|
90
|
+
deviceType === EDeviceType.ClassicPure ? 'PURE' : deviceType.toUpperCase(),
|
|
91
|
+
device_id: 'V1_WALLET_ID',
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
const result = await probeUsbDeviceIdentitiesWithTransport(transport, 'webusb');
|
|
95
|
+
expect(result).toMatchObject([
|
|
96
|
+
{
|
|
97
|
+
serialNo: 'V1_PHYSICAL_SERIAL',
|
|
98
|
+
deviceId: 'V1_WALLET_ID',
|
|
99
|
+
deviceType,
|
|
100
|
+
connectProtocol: 'V1',
|
|
101
|
+
},
|
|
102
|
+
]);
|
|
103
|
+
expect(transport.call.mock.calls.map(call => call[1])).toEqual(['GetFeatures']);
|
|
104
|
+
expect(transport.release).toHaveBeenCalledTimes(1);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
test('continues identifying other devices after one device disconnects', async () => {
|
|
108
|
+
const transport = createTransport();
|
|
109
|
+
transport.enumerate.mockResolvedValue([descriptor, { ...descriptor, path: 'SECOND_USB_PATH' }]);
|
|
110
|
+
transport.call.mockRejectedValueOnce(new Error('Disconnected'));
|
|
111
|
+
const result = await probeUsbDeviceIdentitiesWithTransport(transport, 'webusb');
|
|
112
|
+
expect(result).toMatchObject([{ path: 'SECOND_USB_PATH', serialNo: 'PHYSICAL_SERIAL' }]);
|
|
113
|
+
expect(transport.release).toHaveBeenCalledTimes(2);
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
test.each([DeviceType.PRO2, DeviceType.NEO])(
|
|
117
|
+
'reads V2 hardware identity without opening a wallet (%s)',
|
|
118
|
+
async deviceType => {
|
|
119
|
+
const transport = createTransport();
|
|
120
|
+
transport.getProtocolType.mockReturnValue('V2');
|
|
121
|
+
transport.call.mockResolvedValue({
|
|
122
|
+
type: 'DeviceInfo',
|
|
123
|
+
message: { hw: { Device_type: deviceType, serial_no: 'V2_PHYSICAL_SERIAL' } },
|
|
124
|
+
});
|
|
125
|
+
const result = await probeUsbDeviceIdentitiesWithTransport(transport, 'webusb');
|
|
126
|
+
expect(result[0]).toMatchObject({
|
|
127
|
+
serialNo: 'V2_PHYSICAL_SERIAL',
|
|
128
|
+
connectProtocol: 'V2',
|
|
129
|
+
deviceId: null,
|
|
130
|
+
});
|
|
131
|
+
expect(transport.call.mock.calls.map(call => call[1])).toEqual(['DeviceInfoGet']);
|
|
132
|
+
expect(transport.release).toHaveBeenCalledTimes(1);
|
|
133
|
+
}
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
test('reads vendor identity when legacy Features do not report a physical serial', async () => {
|
|
137
|
+
const transport = createTransport();
|
|
138
|
+
transport.call
|
|
139
|
+
.mockResolvedValueOnce({
|
|
140
|
+
type: 'Features',
|
|
141
|
+
message: { device_id: 'WALLET_ID', onekey_device_type: 'CLASSIC1S' },
|
|
142
|
+
})
|
|
143
|
+
.mockResolvedValueOnce({
|
|
144
|
+
type: 'OnekeyFeatures',
|
|
145
|
+
message: { onekey_serial_no: 'VENDOR_SERIAL' },
|
|
146
|
+
});
|
|
147
|
+
await expect(probeUsbDeviceIdentitiesWithTransport(transport, 'webusb')).resolves.toMatchObject(
|
|
148
|
+
[{ serialNo: 'VENDOR_SERIAL', deviceId: 'WALLET_ID' }]
|
|
149
|
+
);
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
test.each([
|
|
153
|
+
{ onekey_device_type: 'CLASSIC', major_version: 2, minor_version: 8, patch_version: 0 },
|
|
154
|
+
{ onekey_device_type: 'TOUCH', major_version: 4, minor_version: 4, patch_version: 0 },
|
|
155
|
+
])(
|
|
156
|
+
'preserves GetFeatures identity when the legacy V1 schema has no vendor query (%s)',
|
|
157
|
+
async firmware => {
|
|
158
|
+
const transport = createTransport();
|
|
159
|
+
let messages = protocolTransport.parseConfigure(
|
|
160
|
+
JSON.stringify(DataManager.getProtobufMessages())
|
|
161
|
+
);
|
|
162
|
+
transport.configure.mockImplementation((schema: string) => {
|
|
163
|
+
messages = protocolTransport.parseConfigure(schema);
|
|
164
|
+
});
|
|
165
|
+
transport.call.mockImplementation((_session, name, data) => {
|
|
166
|
+
protocolTransport.ProtocolV1.encodeMessageChunks(messages, name, data);
|
|
167
|
+
return Promise.resolve({
|
|
168
|
+
type: 'Features',
|
|
169
|
+
message: { ...firmware, device_id: 'LEGACY_WALLET_ID' },
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
await expect(
|
|
173
|
+
probeUsbDeviceIdentitiesWithTransport(transport, 'webusb')
|
|
174
|
+
).resolves.toMatchObject([
|
|
175
|
+
{
|
|
176
|
+
path: descriptor.path,
|
|
177
|
+
serialNo: null,
|
|
178
|
+
deviceId: 'LEGACY_WALLET_ID',
|
|
179
|
+
connectProtocol: 'V1',
|
|
180
|
+
},
|
|
181
|
+
]);
|
|
182
|
+
expect(transport.call.mock.calls.map(call => call[1])).toEqual(['GetFeatures']);
|
|
183
|
+
expect(transport.release).toHaveBeenCalledWith('usb-transport-handle', false);
|
|
184
|
+
}
|
|
185
|
+
);
|
|
186
|
+
|
|
187
|
+
test('does not substitute a USB path for a missing business identity', async () => {
|
|
188
|
+
const transport = createTransport();
|
|
189
|
+
transport.call
|
|
190
|
+
.mockResolvedValueOnce({ type: 'Features', message: { onekey_device_type: 'MINI' } })
|
|
191
|
+
.mockResolvedValueOnce({ type: 'Failure', message: {} });
|
|
192
|
+
await expect(probeUsbDeviceIdentitiesWithTransport(transport, 'webusb')).resolves.toMatchObject(
|
|
193
|
+
[{ path: 'USB_DESCRIPTOR_PATH', serialNo: null, deviceId: null }]
|
|
194
|
+
);
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
test.each([
|
|
198
|
+
['CLASSIC1S', EDeviceType.Classic1s],
|
|
199
|
+
['PURE', EDeviceType.ClassicPure],
|
|
200
|
+
])(
|
|
201
|
+
'retains %s bootloader state without querying unsupported vendor features',
|
|
202
|
+
async (model, deviceType) => {
|
|
203
|
+
const transport = createTransport();
|
|
204
|
+
const path = '000000000000000000000000';
|
|
205
|
+
transport.enumerate.mockResolvedValue([{ ...descriptor, path }]);
|
|
206
|
+
transport.call.mockImplementation((_session, method) => {
|
|
207
|
+
if (method !== 'GetFeatures')
|
|
208
|
+
return Promise.reject(new Error('Unsupported loader query timed out'));
|
|
209
|
+
return Promise.resolve({
|
|
210
|
+
type: 'Features',
|
|
211
|
+
message: {
|
|
212
|
+
onekey_device_type: model,
|
|
213
|
+
model: '1',
|
|
214
|
+
bootloader_mode: true,
|
|
215
|
+
firmware_present: true,
|
|
216
|
+
major_version: 3,
|
|
217
|
+
minor_version: 0,
|
|
218
|
+
patch_version: 0,
|
|
219
|
+
},
|
|
220
|
+
});
|
|
221
|
+
});
|
|
222
|
+
await expect(probeUsbDeviceIdentitiesWithTransport(transport, 'webusb')).resolves.toEqual([
|
|
223
|
+
{
|
|
224
|
+
path,
|
|
225
|
+
serialNo: null,
|
|
226
|
+
deviceId: null,
|
|
227
|
+
deviceType,
|
|
228
|
+
mode: 'bootloader',
|
|
229
|
+
connectProtocol: 'V1',
|
|
230
|
+
commType: 'webusb',
|
|
231
|
+
},
|
|
232
|
+
]);
|
|
233
|
+
expect(transport.call.mock.calls.map(call => call[1])).toEqual(['GetFeatures']);
|
|
234
|
+
expect(transport.release).toHaveBeenCalledWith('usb-transport-handle', false);
|
|
235
|
+
}
|
|
236
|
+
);
|
|
237
|
+
|
|
238
|
+
test.each(['TOUCH', 'PRO'])(
|
|
239
|
+
'preserves the existing %s loader vendor-identity query',
|
|
240
|
+
async model => {
|
|
241
|
+
const transport = createTransport();
|
|
242
|
+
transport.call
|
|
243
|
+
.mockResolvedValueOnce({
|
|
244
|
+
type: 'Features',
|
|
245
|
+
message: { onekey_device_type: model, bootloader_mode: true },
|
|
246
|
+
})
|
|
247
|
+
.mockResolvedValueOnce({
|
|
248
|
+
type: 'OnekeyFeatures',
|
|
249
|
+
message: { onekey_serial_no: 'VENDOR_SERIAL' },
|
|
250
|
+
});
|
|
251
|
+
await expect(
|
|
252
|
+
probeUsbDeviceIdentitiesWithTransport(transport, 'webusb')
|
|
253
|
+
).resolves.toMatchObject([{ serialNo: 'VENDOR_SERIAL', mode: 'bootloader' }]);
|
|
254
|
+
expect(transport.call.mock.calls.map(call => call[1])).toEqual([
|
|
255
|
+
'GetFeatures',
|
|
256
|
+
'OnekeyGetFeatures',
|
|
257
|
+
]);
|
|
258
|
+
}
|
|
259
|
+
);
|
|
260
|
+
|
|
261
|
+
test.each([
|
|
262
|
+
{ ...descriptor, device: { opened: true } },
|
|
263
|
+
{ ...descriptor, commType: 'bridge', session: 'owned-bridge-transport' },
|
|
264
|
+
])('leaves an owned USB connection untouched', async occupied => {
|
|
265
|
+
const transport = createTransport();
|
|
266
|
+
transport.enumerate.mockResolvedValue([occupied]);
|
|
267
|
+
await expect(
|
|
268
|
+
probeUsbDeviceIdentitiesWithTransport(transport, occupied.commType as 'webusb' | 'bridge')
|
|
269
|
+
).resolves.toEqual([]);
|
|
270
|
+
expect(transport.acquire).not.toHaveBeenCalled();
|
|
271
|
+
expect(transport.release).not.toHaveBeenCalled();
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
test.each([undefined, 'occupied-transport-handle'])(
|
|
275
|
+
'does not initialize or acquire a Bridge identity probe (session: %s)',
|
|
276
|
+
async session => {
|
|
277
|
+
const transport = createTransport();
|
|
278
|
+
transport.enumerate.mockResolvedValue([{ ...descriptor, commType: 'bridge', session }]);
|
|
279
|
+
await expect(probeUsbDeviceIdentitiesWithTransport(transport, 'bridge')).resolves.toEqual([]);
|
|
280
|
+
expect(transport.init).not.toHaveBeenCalled();
|
|
281
|
+
expect(transport.enumerate).not.toHaveBeenCalled();
|
|
282
|
+
expect(transport.acquire).not.toHaveBeenCalled();
|
|
283
|
+
expect(transport.release).not.toHaveBeenCalled();
|
|
284
|
+
}
|
|
285
|
+
);
|
|
286
|
+
|
|
287
|
+
test('reuses identity only for the exact active WebUSB handle', () => {
|
|
288
|
+
const handle = {};
|
|
289
|
+
const endpoint = { ...descriptor, device: handle };
|
|
290
|
+
const device = {
|
|
291
|
+
features: {},
|
|
292
|
+
mainId: descriptor.path,
|
|
293
|
+
originalDescriptor: endpoint,
|
|
294
|
+
getCurrentSerialNo: () => 'OWNER_SERIAL',
|
|
295
|
+
getCurrentDeviceId: () => 'OWNER_WALLET',
|
|
296
|
+
getCurrentDeviceType: () => EDeviceType.Pro,
|
|
297
|
+
getProtocol: () => 'V1',
|
|
298
|
+
} as unknown as Device;
|
|
299
|
+
const queue = {
|
|
300
|
+
getRequestTasksIdByConnectId: () => [1],
|
|
301
|
+
getTask: () => ({ method: { device } }),
|
|
302
|
+
};
|
|
303
|
+
expect(getOwnedUsbDeviceIdentity(endpoint, queue)).toMatchObject({ serialNo: 'OWNER_SERIAL' });
|
|
304
|
+
expect(
|
|
305
|
+
getOwnedUsbDeviceIdentity({ ...endpoint, device: {} } as typeof endpoint, queue)
|
|
306
|
+
).toBeUndefined();
|
|
307
|
+
expect(getOwnedUsbDeviceIdentity({ ...endpoint, commType: 'ble' }, queue)).toBeUndefined();
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
test('returns the active request owner identity without acquiring its USB handle', async () => {
|
|
311
|
+
const transport = createTransport();
|
|
312
|
+
transport.enumerate.mockResolvedValue([{ ...descriptor, device: { opened: true } }]);
|
|
313
|
+
const owner = {
|
|
314
|
+
path: descriptor.path,
|
|
315
|
+
serialNo: 'OWNER_SERIAL',
|
|
316
|
+
deviceId: 'OWNER_WALLET',
|
|
317
|
+
deviceType: EDeviceType.Pro,
|
|
318
|
+
connectProtocol: 'V1' as const,
|
|
319
|
+
commType: 'webusb' as const,
|
|
320
|
+
};
|
|
321
|
+
await expect(
|
|
322
|
+
probeUsbDeviceIdentitiesWithTransport(transport, 'webusb', () => owner)
|
|
323
|
+
).resolves.toEqual([owner]);
|
|
324
|
+
expect(transport.acquire).not.toHaveBeenCalled();
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
test('rejects ambiguous paths rather than probing a different USB handle', async () => {
|
|
328
|
+
const transport = createTransport();
|
|
329
|
+
transport.enumerate.mockResolvedValue([descriptor, { ...descriptor }]);
|
|
330
|
+
await expect(probeUsbDeviceIdentitiesWithTransport(transport, 'webusb')).resolves.toEqual([]);
|
|
331
|
+
expect(transport.acquire).not.toHaveBeenCalled();
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
test.each(['read failure', 'unexpected response', 'release failure'] as const)(
|
|
335
|
+
'cleans up without approving the target after %s',
|
|
336
|
+
async failure => {
|
|
337
|
+
const transport = createTransport();
|
|
338
|
+
if (failure === 'read failure')
|
|
339
|
+
transport.call.mockRejectedValue(new Error('USB disconnected'));
|
|
340
|
+
if (failure === 'unexpected response')
|
|
341
|
+
transport.call.mockResolvedValue({ type: 'Failure', message: {} });
|
|
342
|
+
if (failure === 'release failure')
|
|
343
|
+
transport.release.mockRejectedValue(new Error('release failed'));
|
|
344
|
+
await expect(probeUsbDeviceIdentitiesWithTransport(transport, 'webusb')).resolves.toEqual([]);
|
|
345
|
+
expect(transport.release).toHaveBeenCalledTimes(1);
|
|
346
|
+
}
|
|
347
|
+
);
|
|
348
|
+
|
|
349
|
+
test('does not approve an endpoint without a wire-confirmed protocol', async () => {
|
|
350
|
+
const transport = createTransport();
|
|
351
|
+
transport.getProtocolType.mockReturnValue(undefined);
|
|
352
|
+
await expect(
|
|
353
|
+
probeUsbDeviceIdentitiesWithTransport(transport as UsbIdentityProbeTransport, 'webusb')
|
|
354
|
+
).resolves.toEqual([]);
|
|
355
|
+
expect(transport.call).not.toHaveBeenCalled();
|
|
356
|
+
expect(transport.release).toHaveBeenCalledTimes(1);
|
|
357
|
+
});
|
|
358
|
+
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FirmwareUpdateV4.d.ts","sourceRoot":"","sources":["../../src/api/FirmwareUpdateV4.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkD,MAAM,qBAAqB,CAAC;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;
|
|
1
|
+
{"version":3,"file":"FirmwareUpdateV4.d.ts","sourceRoot":"","sources":["../../src/api/FirmwareUpdateV4.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,9 +1,29 @@
|
|
|
1
1
|
import { BaseMethod } from './BaseMethod';
|
|
2
|
-
import type { SearchDevice } from '../types/device';
|
|
2
|
+
import type { SearchDevice, UsbDeviceIdentity } from '../types/device';
|
|
3
3
|
import type DeviceConnector from '../device/DeviceConnector';
|
|
4
|
+
import type { AcquireInput, OneKeyDeviceInfo as DeviceDescriptor, Transport } from '@onekeyfe/hd-transport';
|
|
5
|
+
import type { Device } from '../device/Device';
|
|
6
|
+
type RequestQueueLookup = {
|
|
7
|
+
getRequestTasksIdByConnectId: (connectId: string) => number[];
|
|
8
|
+
getTask: (requestId: number) => {
|
|
9
|
+
method: {
|
|
10
|
+
device?: Device;
|
|
11
|
+
};
|
|
12
|
+
} | undefined;
|
|
13
|
+
};
|
|
14
|
+
export type UsbIdentityProbeDescriptor = Pick<DeviceDescriptor, 'path' | 'commType'> & Partial<Pick<DeviceDescriptor, 'id' | 'session'>>;
|
|
15
|
+
export declare const getOwnedUsbDeviceIdentity: (descriptor: UsbIdentityProbeDescriptor, requestQueue: RequestQueueLookup) => UsbDeviceIdentity | undefined;
|
|
16
|
+
export type UsbIdentityProbeTransport = Pick<Transport, 'release' | 'call' | 'getProtocolType' | 'configureProtocolV2'> & {
|
|
17
|
+
init: (logger: object) => unknown;
|
|
18
|
+
enumerate: () => Promise<UsbIdentityProbeDescriptor[]>;
|
|
19
|
+
acquire: (input: AcquireInput) => Promise<string | undefined>;
|
|
20
|
+
configure: (signedData: string) => void | Promise<void>;
|
|
21
|
+
};
|
|
22
|
+
export declare const probeUsbDeviceIdentitiesWithTransport: (transport: UsbIdentityProbeTransport, commType: UsbDeviceIdentity['commType'], getOwnedIdentity?: ((descriptor: UsbIdentityProbeDescriptor) => UsbDeviceIdentity | undefined) | undefined) => Promise<UsbDeviceIdentity[]>;
|
|
4
23
|
export default class SearchDevices extends BaseMethod {
|
|
5
24
|
connector?: DeviceConnector;
|
|
6
25
|
init(): void;
|
|
7
26
|
run(): Promise<SearchDevice[]>;
|
|
8
27
|
}
|
|
28
|
+
export {};
|
|
9
29
|
//# sourceMappingURL=SearchDevices.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchDevices.d.ts","sourceRoot":"","sources":["../../src/api/SearchDevices.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"SearchDevices.d.ts","sourceRoot":"","sources":["../../src/api/SearchDevices.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAU1C,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEvE,OAAO,KAAK,eAAe,MAAM,2BAA2B,CAAC;AAC7D,OAAO,KAAK,EACV,YAAY,EACZ,gBAAgB,IAAI,gBAAgB,EAEpC,SAAS,EACV,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAI/C,KAAK,kBAAkB,GAAG;IACxB,4BAA4B,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,EAAE,CAAC;IAC9D,OAAO,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK;QAAE,MAAM,EAAE;YAAE,MAAM,CAAC,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,GAAG,SAAS,CAAC;CAC7E,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG,IAAI,CAAC,gBAAgB,EAAE,MAAM,GAAG,UAAU,CAAC,GAClF,OAAO,CAAC,IAAI,CAAC,gBAAgB,EAAE,IAAI,GAAG,SAAS,CAAC,CAAC,CAAC;AA4CpD,eAAO,MAAM,yBAAyB,eACxB,0BAA0B,gBACxB,kBAAkB,KAC/B,iBAAiB,GAAG,SAatB,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG,IAAI,CAC1C,SAAS,EACT,SAAS,GAAG,MAAM,GAAG,iBAAiB,GAAG,qBAAqB,CAC/D,GAAG;IACF,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC;IAClC,SAAS,EAAE,MAAM,OAAO,CAAC,0BAA0B,EAAE,CAAC,CAAC;IACvD,OAAO,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAC9D,SAAS,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACzD,CAAC;AAYF,eAAO,MAAM,qCAAqC,cACrC,yBAAyB,YAC1B,iBAAiB,CAAC,UAAU,CAAC,mCACP,0BAA0B,KAAK,iBAAiB,GAAG,SAAS,kBAC3F,QAAQ,iBAAiB,EAAE,CA4G7B,CAAC;AAsBF,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,UAAU;IACnD,SAAS,CAAC,EAAE,eAAe,CAAa;IAExC,IAAI;IAME,GAAG,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;CAuFrC"}
|
package/dist/core/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
import { getOwnedUsbDeviceIdentity } from '../api/SearchDevices';
|
|
2
3
|
import EventEmitter from 'events';
|
|
3
4
|
import { type LowlevelTransportSharedPlugin, type ProtocolType } from '@onekeyfe/hd-transport';
|
|
4
5
|
import { Device } from '../device/Device';
|
|
@@ -20,6 +21,7 @@ export default class Core extends EventEmitter {
|
|
|
20
21
|
private tracingContext;
|
|
21
22
|
readonly sdkInstanceId: string;
|
|
22
23
|
private requestQueue;
|
|
24
|
+
getOwnedUsbDeviceIdentity(descriptor: Parameters<typeof getOwnedUsbDeviceIdentity>[0]): import("../types").UsbDeviceIdentity | undefined;
|
|
23
25
|
private disposePromise?;
|
|
24
26
|
private prePendingCallPromises;
|
|
25
27
|
private methodSynchronize;
|
|
@@ -36,5 +38,5 @@ export declare const switchTransport: ({ env, Transport, plugin, }: {
|
|
|
36
38
|
env: ConnectSettings['env'];
|
|
37
39
|
Transport: any;
|
|
38
40
|
plugin?: LowlevelTransportSharedPlugin | undefined;
|
|
39
|
-
}) => void
|
|
41
|
+
}) => Promise<void>;
|
|
40
42
|
//# sourceMappingURL=index.d.ts.map
|