@onekeyfe/hd-core 1.2.0-alpha.132 → 1.2.0-alpha.133-ok59992
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 +0 -7
- package/__tests__/device-lifecycle-events.test.ts +2 -91
- package/__tests__/device-settings.test.ts +8 -105
- package/__tests__/protocol-v2.test.ts +1 -4
- package/dist/api/device/DeviceSettings.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceUploadWallpaper.d.ts.map +1 -1
- package/dist/core/index.d.ts +1 -3
- package/dist/core/index.d.ts.map +1 -1
- package/dist/device/Device.d.ts +0 -2
- package/dist/device/Device.d.ts.map +1 -1
- package/dist/device/DeviceCommands.d.ts.map +1 -1
- package/dist/index.d.ts +1 -4
- package/dist/index.js +51 -112
- package/package.json +4 -4
- package/src/api/device/DeviceSettings.ts +16 -2
- package/src/api/protocol-v2/DeviceUploadWallpaper.ts +0 -1
- package/src/core/index.ts +25 -67
- package/src/device/Device.ts +2 -30
- package/src/device/DeviceCommands.ts +1 -14
|
@@ -800,13 +800,7 @@ describe('DeviceCommands cancellation', () => {
|
|
|
800
800
|
try {
|
|
801
801
|
const commands = createCommands();
|
|
802
802
|
commands.disposed = false;
|
|
803
|
-
commands.mainId = 'main-id';
|
|
804
803
|
commands.callPromise = new Promise(() => {});
|
|
805
|
-
const disconnect = jest.fn().mockResolvedValue(undefined);
|
|
806
|
-
commands.transport = {
|
|
807
|
-
name: 'ReactNativeBleTransport',
|
|
808
|
-
disconnect,
|
|
809
|
-
} as any;
|
|
810
804
|
const dispose = jest.fn().mockResolvedValue(undefined);
|
|
811
805
|
commands.dispose = dispose;
|
|
812
806
|
|
|
@@ -816,7 +810,6 @@ describe('DeviceCommands cancellation', () => {
|
|
|
816
810
|
|
|
817
811
|
await expect(cancellation).resolves.toBeUndefined();
|
|
818
812
|
expect(dispose).toHaveBeenCalledWith(true);
|
|
819
|
-
expect(disconnect).toHaveBeenCalledWith('main-id');
|
|
820
813
|
expect(commands.callPromise).toBeUndefined();
|
|
821
814
|
} finally {
|
|
822
815
|
jest.useRealTimers();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { EDeviceType,
|
|
1
|
+
import { EDeviceType, HardwareErrorCode } from '@onekeyfe/hd-shared';
|
|
2
2
|
import { DeviceType, TRANSPORT_EVENT } from '@onekeyfe/hd-transport';
|
|
3
3
|
|
|
4
|
-
import { initConnector, initCore
|
|
4
|
+
import { initConnector, initCore } from '../src/core';
|
|
5
5
|
import { DataManager } from '../src/data-manager';
|
|
6
6
|
import TransportManager from '../src/data-manager/TransportManager';
|
|
7
7
|
import { Device } from '../src/device/Device';
|
|
@@ -82,23 +82,6 @@ describe('public device lifecycle events', () => {
|
|
|
82
82
|
expect(DevicePool.emitter.listenerCount(DEVICE.DISCONNECT)).toBe(1);
|
|
83
83
|
});
|
|
84
84
|
|
|
85
|
-
test('isolates pending cancellation cleanup by connect id', () => {
|
|
86
|
-
core = initCore();
|
|
87
|
-
const context = (core as any).getCoreContext();
|
|
88
|
-
const firstCleanup = createDeferred<void>();
|
|
89
|
-
const replacementCleanup = createDeferred<void>();
|
|
90
|
-
|
|
91
|
-
context.setPrePendingCallPromise('device-a', firstCleanup.promise);
|
|
92
|
-
|
|
93
|
-
expect(context.getPrePendingCallPromise('device-a')).toBe(firstCleanup.promise);
|
|
94
|
-
expect(context.getPrePendingCallPromise('device-b')).toBeUndefined();
|
|
95
|
-
|
|
96
|
-
context.setPrePendingCallPromise('device-a', replacementCleanup.promise);
|
|
97
|
-
context.removePrePendingCallPromise('device-a', firstCleanup.promise);
|
|
98
|
-
|
|
99
|
-
expect(context.getPrePendingCallPromise('device-a')).toBe(replacementCleanup.promise);
|
|
100
|
-
});
|
|
101
|
-
|
|
102
85
|
test('keeps shared device lifecycle listeners across a device cache reset', () => {
|
|
103
86
|
jest.spyOn(DataManager, 'getSettings').mockReturnValue('react-native' as never);
|
|
104
87
|
core = initCore();
|
|
@@ -251,22 +234,6 @@ describe('public device lifecycle events', () => {
|
|
|
251
234
|
expect(device.getProtocol()).toBe('V2');
|
|
252
235
|
});
|
|
253
236
|
|
|
254
|
-
test.each([
|
|
255
|
-
['V2', true],
|
|
256
|
-
['V1', false],
|
|
257
|
-
] as const)(
|
|
258
|
-
'retries a missing detected protocol only for an explicit Protocol %s connection',
|
|
259
|
-
(connectProtocol, expected) => {
|
|
260
|
-
const method = { payload: { connectProtocol } } as never;
|
|
261
|
-
const error = {
|
|
262
|
-
errorCode: HardwareErrorCode.RuntimeError,
|
|
263
|
-
message: 'Device protocol has not been detected for ble-id',
|
|
264
|
-
};
|
|
265
|
-
|
|
266
|
-
expect(isMissingDetectedProtocolV2Error(method, error)).toBe(expected);
|
|
267
|
-
}
|
|
268
|
-
);
|
|
269
|
-
|
|
270
237
|
test('converts an internal transport disconnect into a public KnownDevice snapshot', () => {
|
|
271
238
|
jest.spyOn(DataManager, 'getSettings').mockReturnValue('react-native' as never);
|
|
272
239
|
core = initCore();
|
|
@@ -343,62 +310,6 @@ describe('public device lifecycle events', () => {
|
|
|
343
310
|
}
|
|
344
311
|
);
|
|
345
312
|
|
|
346
|
-
test('sends a fallback Cancel for an acquired Protocol V2 BLE call without a prompt callback', async () => {
|
|
347
|
-
jest.spyOn(DataManager, 'getSettings').mockReturnValue('react-native' as never);
|
|
348
|
-
const device = createInitializedDevice('V2');
|
|
349
|
-
const post = jest.fn().mockResolvedValue(undefined);
|
|
350
|
-
const cancelDevice = jest.fn(() => cancelDeviceInPrompt(device, false));
|
|
351
|
-
const cancel = jest.fn().mockResolvedValue(undefined);
|
|
352
|
-
(device as unknown as { deviceAcquired: boolean }).deviceAcquired = true;
|
|
353
|
-
device.commands = {
|
|
354
|
-
transport: { post },
|
|
355
|
-
cancelDevice,
|
|
356
|
-
cancel,
|
|
357
|
-
} as never;
|
|
358
|
-
|
|
359
|
-
await device.interruptionFromUser();
|
|
360
|
-
|
|
361
|
-
expect(cancelDevice).toHaveBeenCalledTimes(1);
|
|
362
|
-
expect(post).toHaveBeenCalledWith(device.mainId, 'Cancel', {});
|
|
363
|
-
expect(cancel).toHaveBeenCalledTimes(1);
|
|
364
|
-
});
|
|
365
|
-
|
|
366
|
-
test('waits for the canceled run to finish releasing before cancellation completes', async () => {
|
|
367
|
-
jest.spyOn(DataManager, 'getSettings').mockReturnValue('react-native' as never);
|
|
368
|
-
const device = createInitializedDevice('V2');
|
|
369
|
-
const operation = createDeferred<void>();
|
|
370
|
-
const releaseGate = createDeferred<void>();
|
|
371
|
-
const cancelError = ERRORS.TypedError(HardwareErrorCode.DeviceInterruptedFromUser);
|
|
372
|
-
const release = jest.spyOn(device, 'release').mockImplementation(() => releaseGate.promise);
|
|
373
|
-
device.commands = {
|
|
374
|
-
disposed: false,
|
|
375
|
-
cancel: jest.fn(() => {
|
|
376
|
-
operation.reject(cancelError);
|
|
377
|
-
return Promise.resolve();
|
|
378
|
-
}),
|
|
379
|
-
} as never;
|
|
380
|
-
(device as unknown as { deviceAcquired: boolean }).deviceAcquired = true;
|
|
381
|
-
|
|
382
|
-
const runResult = device.run(() => operation.promise).catch(error => error);
|
|
383
|
-
const cancellation = device.interruptionFromUser();
|
|
384
|
-
let cancellationCompleted = false;
|
|
385
|
-
cancellation.then(() => {
|
|
386
|
-
cancellationCompleted = true;
|
|
387
|
-
});
|
|
388
|
-
|
|
389
|
-
await new Promise(resolve => {
|
|
390
|
-
setImmediate(resolve);
|
|
391
|
-
});
|
|
392
|
-
expect(release).toHaveBeenCalledTimes(1);
|
|
393
|
-
expect(cancellationCompleted).toBe(false);
|
|
394
|
-
|
|
395
|
-
releaseGate.resolve();
|
|
396
|
-
await cancellation;
|
|
397
|
-
await expect(runResult).resolves.toMatchObject({
|
|
398
|
-
errorCode: HardwareErrorCode.DeviceInterruptedFromUser,
|
|
399
|
-
});
|
|
400
|
-
});
|
|
401
|
-
|
|
402
313
|
test.each([
|
|
403
314
|
[EDeviceType.Pro2, 'webusb', false, DeviceType.PRO2],
|
|
404
315
|
[EDeviceType.Neo, 'webusb', false, DeviceType.NEO],
|
|
@@ -2,9 +2,6 @@ import { EDeviceType, HardwareErrorCode } from '@onekeyfe/hd-shared';
|
|
|
2
2
|
import { DeviceSettingsPage } from '@onekeyfe/hd-transport';
|
|
3
3
|
|
|
4
4
|
import DeviceSettings from '../src/api/device/DeviceSettings';
|
|
5
|
-
import { Device } from '../src/device/Device';
|
|
6
|
-
import { DEVICE } from '../src/events';
|
|
7
|
-
import { PROTOCOL_V2_DEVICE_STATUS_GET_MESSAGE_TYPE } from '../src/protocols/protocol-v2';
|
|
8
5
|
import { DEVICE_SETTINGS_NEVER_TIMEOUT_MS } from '../src/utils/deviceSettings';
|
|
9
6
|
|
|
10
7
|
import type { Features } from '../src/types';
|
|
@@ -24,9 +21,6 @@ function createDevice({ protocol }: { protocol: 'V1' | 'V2' }) {
|
|
|
24
21
|
const typedCall = jest.fn().mockResolvedValue({ message: { message: 'Success' } });
|
|
25
22
|
const updateState = jest.fn();
|
|
26
23
|
const getDeviceState = jest.fn();
|
|
27
|
-
const refreshProtocolV2SettingsAfterMutation = jest.fn(() =>
|
|
28
|
-
getDeviceState({ refreshSections: ['status', 'settings'] })
|
|
29
|
-
);
|
|
30
24
|
return {
|
|
31
25
|
device: {
|
|
32
26
|
features,
|
|
@@ -35,7 +29,6 @@ function createDevice({ protocol }: { protocol: 'V1' | 'V2' }) {
|
|
|
35
29
|
commands: { typedCall },
|
|
36
30
|
updateState,
|
|
37
31
|
getDeviceState,
|
|
38
|
-
refreshProtocolV2SettingsAfterMutation,
|
|
39
32
|
},
|
|
40
33
|
typedCall,
|
|
41
34
|
updateState,
|
|
@@ -188,97 +181,6 @@ describe('DeviceSettings protocol routing', () => {
|
|
|
188
181
|
expect(updateState).not.toHaveBeenCalled();
|
|
189
182
|
});
|
|
190
183
|
|
|
191
|
-
it('reconciles stale passphrase and label after an unrelated Protocol V2 setting change', async () => {
|
|
192
|
-
const typedCall = jest.fn().mockImplementation((requestType: string) => {
|
|
193
|
-
if (requestType === 'DeviceSettingsSet') {
|
|
194
|
-
return { message: { message: 'Success' } };
|
|
195
|
-
}
|
|
196
|
-
if (requestType === 'DeviceStatusGet') {
|
|
197
|
-
return {
|
|
198
|
-
message: {
|
|
199
|
-
init_states: true,
|
|
200
|
-
unlocked: false,
|
|
201
|
-
passphrase_enabled: false,
|
|
202
|
-
},
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
if (requestType === 'DeviceSettingsGet') {
|
|
206
|
-
return {
|
|
207
|
-
message: {
|
|
208
|
-
label: 'Current Label',
|
|
209
|
-
brightness: 80,
|
|
210
|
-
passphrase_enable: false,
|
|
211
|
-
},
|
|
212
|
-
};
|
|
213
|
-
}
|
|
214
|
-
throw new Error(`Unexpected request: ${requestType}`);
|
|
215
|
-
});
|
|
216
|
-
const device = Device.fromDescriptor({
|
|
217
|
-
id: 'pro2',
|
|
218
|
-
path: 'pro2',
|
|
219
|
-
protocolType: 'V2',
|
|
220
|
-
} as never);
|
|
221
|
-
(device as any).commands = { typedCall };
|
|
222
|
-
device.updateState(
|
|
223
|
-
{
|
|
224
|
-
protocol: 'V2',
|
|
225
|
-
identity: {
|
|
226
|
-
deviceType: EDeviceType.Pro2,
|
|
227
|
-
label: 'Stale Label',
|
|
228
|
-
},
|
|
229
|
-
status: {
|
|
230
|
-
mode: 'normal',
|
|
231
|
-
unlocked: false,
|
|
232
|
-
passphraseProtection: true,
|
|
233
|
-
},
|
|
234
|
-
settings: { brightness: 20 },
|
|
235
|
-
raw: {
|
|
236
|
-
protocolV2ProtocolInfo: {
|
|
237
|
-
version: 1,
|
|
238
|
-
build_fingerprint: 'application__5.0.0__abcdef0__PROD__RELEASE',
|
|
239
|
-
supported_messages: [PROTOCOL_V2_DEVICE_STATUS_GET_MESSAGE_TYPE],
|
|
240
|
-
},
|
|
241
|
-
},
|
|
242
|
-
},
|
|
243
|
-
'initialize'
|
|
244
|
-
);
|
|
245
|
-
const onState = jest.fn();
|
|
246
|
-
device.on(DEVICE.STATE, onState);
|
|
247
|
-
const method = new DeviceSettings({
|
|
248
|
-
id: 3,
|
|
249
|
-
payload: {
|
|
250
|
-
method: 'deviceSettings',
|
|
251
|
-
brightness: 80,
|
|
252
|
-
},
|
|
253
|
-
});
|
|
254
|
-
method.init();
|
|
255
|
-
(method as any).device = device;
|
|
256
|
-
|
|
257
|
-
await expect(method.run()).resolves.toEqual({ message: 'Success' });
|
|
258
|
-
|
|
259
|
-
expect(typedCall.mock.calls.map(call => call[0])).toEqual([
|
|
260
|
-
'DeviceSettingsSet',
|
|
261
|
-
'DeviceStatusGet',
|
|
262
|
-
'DeviceSettingsGet',
|
|
263
|
-
]);
|
|
264
|
-
expect(device.state).toMatchObject({
|
|
265
|
-
identity: { label: 'Current Label' },
|
|
266
|
-
status: { passphraseProtection: false },
|
|
267
|
-
settings: { brightness: 80 },
|
|
268
|
-
});
|
|
269
|
-
expect(onState).toHaveBeenLastCalledWith(
|
|
270
|
-
device,
|
|
271
|
-
expect.objectContaining({
|
|
272
|
-
source: 'settings-read',
|
|
273
|
-
state: expect.objectContaining({
|
|
274
|
-
identity: expect.objectContaining({ label: 'Current Label' }),
|
|
275
|
-
status: expect.objectContaining({ passphraseProtection: false }),
|
|
276
|
-
settings: expect.objectContaining({ brightness: 80 }),
|
|
277
|
-
}),
|
|
278
|
-
})
|
|
279
|
-
);
|
|
280
|
-
});
|
|
281
|
-
|
|
282
184
|
it('uses the Pro2 passphrase page as a device-side toggle and verifies the target state', async () => {
|
|
283
185
|
const { device, typedCall, getDeviceState } = createDevice({ protocol: 'V2' });
|
|
284
186
|
getDeviceState
|
|
@@ -361,8 +263,8 @@ describe('DeviceSettings protocol routing', () => {
|
|
|
361
263
|
expect(getDeviceState).toHaveBeenCalledWith({ refreshSections: ['settings'] });
|
|
362
264
|
});
|
|
363
265
|
|
|
364
|
-
it('
|
|
365
|
-
const { device, getDeviceState
|
|
266
|
+
it('rejects a successful Pro2 page response when the hardware did not reach the target', async () => {
|
|
267
|
+
const { device, getDeviceState } = createDevice({ protocol: 'V2' });
|
|
366
268
|
getDeviceState.mockResolvedValue({
|
|
367
269
|
status: { passphraseProtection: false },
|
|
368
270
|
});
|
|
@@ -376,12 +278,14 @@ describe('DeviceSettings protocol routing', () => {
|
|
|
376
278
|
method.init();
|
|
377
279
|
(method as any).device = device;
|
|
378
280
|
|
|
379
|
-
await expect(method.run()).
|
|
380
|
-
|
|
281
|
+
await expect(method.run()).rejects.toMatchObject({
|
|
282
|
+
errorCode: HardwareErrorCode.RuntimeError,
|
|
283
|
+
message: 'Protocol V2 passphrase setting did not reach the requested value.',
|
|
284
|
+
});
|
|
381
285
|
});
|
|
382
286
|
|
|
383
|
-
it('
|
|
384
|
-
const { device, getDeviceState
|
|
287
|
+
it('accepts a locked Pro2 as confirmation after disabling passphrase', async () => {
|
|
288
|
+
const { device, getDeviceState } = createDevice({ protocol: 'V2' });
|
|
385
289
|
getDeviceState
|
|
386
290
|
.mockResolvedValueOnce({
|
|
387
291
|
status: { unlocked: true, passphraseProtection: true },
|
|
@@ -400,7 +304,6 @@ describe('DeviceSettings protocol routing', () => {
|
|
|
400
304
|
(method as any).device = device;
|
|
401
305
|
|
|
402
306
|
await expect(method.run()).resolves.toEqual({ message: 'Success' });
|
|
403
|
-
expect(updateState).not.toHaveBeenCalled();
|
|
404
307
|
});
|
|
405
308
|
|
|
406
309
|
it('keeps Protocol V1 passphrase settings on ApplySettings', async () => {
|
|
@@ -183,7 +183,6 @@ describe('DeviceUploadWallpaper', () => {
|
|
|
183
183
|
stubDevice({
|
|
184
184
|
...device,
|
|
185
185
|
ensureProtocolV2RuntimeContext: jest.fn().mockResolvedValue(wallpaperProtocolInfo),
|
|
186
|
-
refreshProtocolV2SettingsAfterMutation: jest.fn().mockResolvedValue({}),
|
|
187
186
|
});
|
|
188
187
|
|
|
189
188
|
test('encodes, uploads and applies a Pro2 wallpaper', async () => {
|
|
@@ -205,8 +204,7 @@ describe('DeviceUploadWallpaper', () => {
|
|
|
205
204
|
jpegBase64: createJpegBase64(604, 1024),
|
|
206
205
|
},
|
|
207
206
|
});
|
|
208
|
-
|
|
209
|
-
(method as any).device = device;
|
|
207
|
+
(method as any).device = stubWallpaperDevice({ commands: { typedCall } });
|
|
210
208
|
method.postMessage = jest.fn();
|
|
211
209
|
|
|
212
210
|
method.init();
|
|
@@ -226,7 +224,6 @@ describe('DeviceUploadWallpaper', () => {
|
|
|
226
224
|
expect(typedCall).toHaveBeenLastCalledWith('DeviceSettingsSet', 'Success', {
|
|
227
225
|
settings: { wallpaper_path: result.path },
|
|
228
226
|
});
|
|
229
|
-
expect(device.refreshProtocolV2SettingsAfterMutation).toHaveBeenCalledTimes(1);
|
|
230
227
|
expect(typedCall.mock.calls.some(call => call[0] === 'SetWallpaper')).toBe(false);
|
|
231
228
|
expect(result).toMatchObject({ colorFormat: 'RGB565', message: 'wallpaper applied' });
|
|
232
229
|
const fileWriteCallCount = typedCall.mock.calls.filter(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeviceSettings.d.ts","sourceRoot":"","sources":["../../../src/api/device/DeviceSettings.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAgB3C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AA0D5D,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,UAAU,CAAC,aAAa,CAAC;IACnE,qBAAqB;IAIrB,IAAI;IA0EJ,eAAe;;;;;;;IAWT,GAAG;
|
|
1
|
+
{"version":3,"file":"DeviceSettings.d.ts","sourceRoot":"","sources":["../../../src/api/device/DeviceSettings.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAgB3C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AA0D5D,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,UAAU,CAAC,aAAa,CAAC;IACnE,qBAAqB;IAIrB,IAAI;IA0EJ,eAAe;;;;;;;IAWT,GAAG;CAyIV"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeviceUploadWallpaper.d.ts","sourceRoot":"","sources":["../../../src/api/protocol-v2/DeviceUploadWallpaper.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAM3C,OAAO,EAGL,KAAK,wBAAwB,EAE9B,MAAM,2BAA2B,CAAC;AAEnC,MAAM,MAAM,2BAA2B,GAAG;IACxC,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,6BAA6B,GAAG;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,wBAAwB,CAAC;IACtC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAkBF,MAAM,CAAC,OAAO,OAAO,qBAAsB,SAAQ,UAAU,CAAC,2BAA2B,CAAC;IACxF,qBAAqB;IAIrB,OAAO,CAAC,OAAO,CAAC,CAA8D;IAE9E,OAAO,CAAC,cAAc,CAAS;IAE/B,OAAO,CAAC,QAAQ,CAAS;IAEzB,OAAO,CAAC,IAAI,CAAM;IAElB,IAAI;YAwBU,kBAAkB;YAgBlB,eAAe;YAaf,MAAM;IAwBd,GAAG,IAAI,OAAO,CAAC,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"DeviceUploadWallpaper.d.ts","sourceRoot":"","sources":["../../../src/api/protocol-v2/DeviceUploadWallpaper.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAM3C,OAAO,EAGL,KAAK,wBAAwB,EAE9B,MAAM,2BAA2B,CAAC;AAEnC,MAAM,MAAM,2BAA2B,GAAG;IACxC,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,6BAA6B,GAAG;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,wBAAwB,CAAC;IACtC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAkBF,MAAM,CAAC,OAAO,OAAO,qBAAsB,SAAQ,UAAU,CAAC,2BAA2B,CAAC;IACxF,qBAAqB;IAIrB,OAAO,CAAC,OAAO,CAAC,CAA8D;IAE9E,OAAO,CAAC,cAAc,CAAS;IAE/B,OAAO,CAAC,QAAQ,CAAS;IAEzB,OAAO,CAAC,IAAI,CAAM;IAElB,IAAI;YAwBU,kBAAkB;YAgBlB,eAAe;YAaf,MAAM;IAwBd,GAAG,IAAI,OAAO,CAAC,6BAA6B,CAAC;CAgBpD"}
|
package/dist/core/index.d.ts
CHANGED
|
@@ -5,10 +5,8 @@ import DeviceConnector from '../device/DeviceConnector';
|
|
|
5
5
|
import type { ConnectSettings } from '../types';
|
|
6
6
|
import type { CoreMessage } from '../events';
|
|
7
7
|
import type { LowlevelTransportSharedPlugin } from '@onekeyfe/hd-transport';
|
|
8
|
-
import type { BaseMethod } from '../api/BaseMethod';
|
|
9
8
|
export type CoreContext = ReturnType<Core['getCoreContext']>;
|
|
10
9
|
export declare const callAPI: (context: CoreContext, message: CoreMessage) => Promise<any>;
|
|
11
|
-
export declare function isMissingDetectedProtocolV2Error(method: BaseMethod, error: unknown): boolean;
|
|
12
10
|
export declare const cancel: (context: CoreContext, connectId?: string) => void;
|
|
13
11
|
export declare const onDeviceButtonHandler: (__0_0: Device, __0_1: import("../events").DeviceButtonRequestPayload) => void;
|
|
14
12
|
export default class Core extends EventEmitter {
|
|
@@ -16,7 +14,7 @@ export default class Core extends EventEmitter {
|
|
|
16
14
|
readonly sdkInstanceId: string;
|
|
17
15
|
private requestQueue;
|
|
18
16
|
private disposePromise?;
|
|
19
|
-
private
|
|
17
|
+
private prePendingCallPromise;
|
|
20
18
|
private methodSynchronize;
|
|
21
19
|
constructor();
|
|
22
20
|
private getCoreContext;
|
package/dist/core/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":";AACA,OAAO,YAAY,MAAM,QAAQ,CAAC;AAoClC,OAAO,EAAE,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,EACV,6BAA6B,EAG9B,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":";AACA,OAAO,YAAY,MAAM,QAAQ,CAAC;AAoClC,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,EACV,6BAA6B,EAG9B,MAAM,wBAAwB,CAAC;AAWhC,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC;AAmE7D,eAAO,MAAM,OAAO,YAAmB,WAAW,WAAW,WAAW,iBAoFvE,CAAC;AA44BF,eAAO,MAAM,MAAM,YAAa,WAAW,cAAc,MAAM,SAkF9D,CAAC;AAmGF,eAAO,MAAM,qBAAqB,gFAejC,CAAC;AAiLF,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,YAAY;IAC5C,OAAO,CAAC,cAAc,CAAoB;IAE1C,SAAgB,aAAa,EAAE,MAAM,CAAC;IAEtC,OAAO,CAAC,YAAY,CAAsB;IAE1C,OAAO,CAAC,cAAc,CAAC,CAAgB;IAGvC,OAAO,CAAC,qBAAqB,CAA4B;IAEzD,OAAO,CAAC,iBAAiB,CAAoB;;IAS7C,OAAO,CAAC,cAAc;IAoBhB,aAAa,CAAC,OAAO,EAAE,WAAW;IAuExC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;YAOV,gBAAgB;CAiC/B;AAED,eAAO,MAAM,QAAQ,YAIpB,CAAC;AAEF,eAAO,MAAM,aAAa,uBAYzB,CAAC;AAMF,eAAO,MAAM,IAAI,aACL,eAAe,aACd,GAAG,WACL,6BAA6B,8BAiBvC,CAAC;AAEF,eAAO,MAAM,eAAe;SAKrB,eAAe,CAAC,KAAK,CAAC;eAChB,GAAG;;UASf,CAAC"}
|
package/dist/device/Device.d.ts
CHANGED
|
@@ -80,7 +80,6 @@ export declare class Device extends EventEmitter {
|
|
|
80
80
|
get features(): Features | undefined;
|
|
81
81
|
set features(features: Features | undefined);
|
|
82
82
|
runPromise?: Deferred<void> | null;
|
|
83
|
-
private runCleanupPromise?;
|
|
84
83
|
externalState: string[];
|
|
85
84
|
unavailableCapabilities: UnavailableCapabilities;
|
|
86
85
|
instance: number;
|
|
@@ -149,7 +148,6 @@ export declare class Device extends EventEmitter {
|
|
|
149
148
|
private _initializeProtocolV2;
|
|
150
149
|
getFeatures(): Promise<Features | undefined>;
|
|
151
150
|
getDeviceState(params?: DeviceStateReadOptions): Promise<import("../types").DeviceState>;
|
|
152
|
-
refreshProtocolV2SettingsAfterMutation(): Promise<import("../types").DeviceState>;
|
|
153
151
|
_updateFeatures(protoFeatures: PROTO.Features | Features, initSession?: boolean): void;
|
|
154
152
|
updateState(patch: DeviceStatePatch, source: DeviceStateUpdateSource): import("../types").DeviceState & {
|
|
155
153
|
raw?: import("../types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CAAC,EACpB,OAAO,CAAC,EAAE,oBAAoB,GAC7B,OAAO,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC;IA4D7B,WAAW,CACf,IAAI,EAAE,UAAU,EAChB,GAAG,CAAC,EAAE,sBAAsB,CAAC,SAAS,CAAC,EACvC,OAAO,CAAC,EAAE,oBAAoB;IAMhC,kBAAkB,CAChB,GAAG,EAAE,sBAAsB,EAC3B,QAAQ,EAAE,UAAU,EACpB,OAAO,CAAC,EAAE,oBAAoB,GAC7B,OAAO,CAAC,sBAAsB,CAAC;IA8QlC,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
|
@@ -833,8 +833,6 @@ declare class Device extends EventEmitter {
|
|
|
833
833
|
get features(): Features | undefined;
|
|
834
834
|
set features(features: Features | undefined);
|
|
835
835
|
runPromise?: Deferred<void> | null;
|
|
836
|
-
/** Resolves only after the active run has completed its release path. */
|
|
837
|
-
private runCleanupPromise?;
|
|
838
836
|
externalState: string[];
|
|
839
837
|
unavailableCapabilities: UnavailableCapabilities;
|
|
840
838
|
instance: number;
|
|
@@ -929,7 +927,6 @@ declare class Device extends EventEmitter {
|
|
|
929
927
|
private _initializeProtocolV2;
|
|
930
928
|
getFeatures(): Promise<Features | undefined>;
|
|
931
929
|
getDeviceState(params?: DeviceStateReadOptions): Promise<DeviceState>;
|
|
932
|
-
refreshProtocolV2SettingsAfterMutation(): Promise<DeviceState>;
|
|
933
930
|
_updateFeatures(protoFeatures: Messages.Features | Features, initSession?: boolean): void;
|
|
934
931
|
updateState(patch: DeviceStatePatch, source: DeviceStateUpdateSource): DeviceState & {
|
|
935
932
|
raw?: DeviceFeaturesRaw | undefined;
|
|
@@ -1093,7 +1090,7 @@ declare class Core extends EventEmitter {
|
|
|
1093
1090
|
readonly sdkInstanceId: string;
|
|
1094
1091
|
private requestQueue;
|
|
1095
1092
|
private disposePromise?;
|
|
1096
|
-
private
|
|
1093
|
+
private prePendingCallPromise;
|
|
1097
1094
|
private methodSynchronize;
|
|
1098
1095
|
constructor();
|
|
1099
1096
|
private getCoreContext;
|
package/dist/index.js
CHANGED
|
@@ -43679,7 +43679,6 @@ class DeviceCommands {
|
|
|
43679
43679
|
}
|
|
43680
43680
|
const activeCall = this.callPromise;
|
|
43681
43681
|
let timer;
|
|
43682
|
-
let timedOut = false;
|
|
43683
43682
|
const cancellation = (() => __awaiter(this, void 0, void 0, function* () {
|
|
43684
43683
|
yield this.dispose(true);
|
|
43685
43684
|
yield (activeCall === null || activeCall === void 0 ? void 0 : activeCall.catch(() => undefined));
|
|
@@ -43688,23 +43687,13 @@ class DeviceCommands {
|
|
|
43688
43687
|
yield Promise.race([
|
|
43689
43688
|
cancellation,
|
|
43690
43689
|
new Promise(resolve => {
|
|
43691
|
-
timer = setTimeout(
|
|
43692
|
-
timedOut = true;
|
|
43693
|
-
resolve();
|
|
43694
|
-
}, 10 * 1000);
|
|
43690
|
+
timer = setTimeout(resolve, 10 * 1000);
|
|
43695
43691
|
}),
|
|
43696
43692
|
]);
|
|
43697
43693
|
}
|
|
43698
43694
|
finally {
|
|
43699
43695
|
if (timer)
|
|
43700
43696
|
clearTimeout(timer);
|
|
43701
|
-
if (timedOut &&
|
|
43702
|
-
this.transport.name === 'ReactNativeBleTransport' &&
|
|
43703
|
-
this.transport.disconnect) {
|
|
43704
|
-
yield this.transport.disconnect(this.mainId).catch(error => {
|
|
43705
|
-
Log$h.debug('BLE cancellation timeout disconnect error (ignored)', error);
|
|
43706
|
-
});
|
|
43707
|
-
}
|
|
43708
43697
|
if (this.callPromise === activeCall) {
|
|
43709
43698
|
this.callPromise = undefined;
|
|
43710
43699
|
}
|
|
@@ -45743,11 +45732,6 @@ class Device extends events.exports {
|
|
|
45743
45732
|
return params.includeRaw ? cloneDeviceState(this.state) : createPublicDeviceState(this.state);
|
|
45744
45733
|
});
|
|
45745
45734
|
}
|
|
45746
|
-
refreshProtocolV2SettingsAfterMutation() {
|
|
45747
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
45748
|
-
return this.getDeviceState({ refreshSections: ['status', 'settings'] });
|
|
45749
|
-
});
|
|
45750
|
-
}
|
|
45751
45735
|
_updateFeatures(protoFeatures, initSession) {
|
|
45752
45736
|
var _a;
|
|
45753
45737
|
const previousDeviceId = this.getCurrentDeviceId();
|
|
@@ -46003,20 +45987,12 @@ class Device extends events.exports {
|
|
|
46003
45987
|
options = parseRunOptions(options);
|
|
46004
45988
|
const runPromise = hdShared.createDeferred();
|
|
46005
45989
|
this.runPromise = runPromise;
|
|
46006
|
-
|
|
45990
|
+
this._runInner(fn, options, runPromise).catch(error => {
|
|
46007
45991
|
if (this.runPromise === runPromise) {
|
|
46008
45992
|
this.runPromise = null;
|
|
46009
45993
|
}
|
|
46010
45994
|
runPromise.reject(error);
|
|
46011
45995
|
});
|
|
46012
|
-
this.runCleanupPromise = cleanupPromise;
|
|
46013
|
-
cleanupPromise
|
|
46014
|
-
.finally(() => {
|
|
46015
|
-
if (this.runCleanupPromise === cleanupPromise) {
|
|
46016
|
-
this.runCleanupPromise = undefined;
|
|
46017
|
-
}
|
|
46018
|
-
})
|
|
46019
|
-
.catch(() => undefined);
|
|
46020
45996
|
return runPromise.promise;
|
|
46021
45997
|
});
|
|
46022
45998
|
}
|
|
@@ -46110,27 +46086,15 @@ class Device extends events.exports {
|
|
|
46110
46086
|
});
|
|
46111
46087
|
}
|
|
46112
46088
|
interruptionFromUser() {
|
|
46113
|
-
var _a, _b
|
|
46089
|
+
var _a, _b;
|
|
46114
46090
|
return __awaiter(this, void 0, void 0, function* () {
|
|
46115
46091
|
const error = hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceInterruptedFromUser);
|
|
46116
|
-
|
|
46117
|
-
|
|
46118
|
-
if (cancelableAction) {
|
|
46119
|
-
yield cancelableAction(error);
|
|
46120
|
-
}
|
|
46121
|
-
else if (this.isProtocolV2() &&
|
|
46122
|
-
DataManager.isBleConnect(DataManager.getSettings('env')) &&
|
|
46123
|
-
this.hasDeviceAcquire()) {
|
|
46124
|
-
yield ((_b = (_a = this.commands) === null || _a === void 0 ? void 0 : _a.cancelDevice) === null || _b === void 0 ? void 0 : _b.call(_a).catch(cancelError => {
|
|
46125
|
-
Log$g.debug('Protocol V2 BLE fallback cancel error', cancelError);
|
|
46126
|
-
}));
|
|
46127
|
-
}
|
|
46128
|
-
yield ((_c = this.commands) === null || _c === void 0 ? void 0 : _c.cancel());
|
|
46092
|
+
yield ((_a = this.cancelableAction) === null || _a === void 0 ? void 0 : _a.call(this, error));
|
|
46093
|
+
yield ((_b = this.commands) === null || _b === void 0 ? void 0 : _b.cancel());
|
|
46129
46094
|
if (this.runPromise) {
|
|
46130
46095
|
this.runPromise.reject(error);
|
|
46131
46096
|
this.runPromise = null;
|
|
46132
46097
|
}
|
|
46133
|
-
yield (cleanupPromise === null || cleanupPromise === void 0 ? void 0 : cleanupPromise.catch(() => undefined));
|
|
46134
46098
|
});
|
|
46135
46099
|
}
|
|
46136
46100
|
setCancelableAction(callback) {
|
|
@@ -48503,7 +48467,7 @@ class DeviceSettings extends BaseMethod {
|
|
|
48503
48467
|
return __awaiter(this, void 0, void 0, function* () {
|
|
48504
48468
|
try {
|
|
48505
48469
|
if (this.device.isProtocolV2()) {
|
|
48506
|
-
const refreshStatusAndSettings = () => this.device.
|
|
48470
|
+
const refreshStatusAndSettings = () => this.device.getDeviceState({ refreshSections: ['status', 'settings'] });
|
|
48507
48471
|
assertSettingsSupported(this.payload, DEVICE_SETTINGS_V1_ONLY_FIELDS, 'Protocol V2');
|
|
48508
48472
|
const capabilities = getDeviceSettingsCapabilities(this.device.getCurrentDeviceType(), 'V2');
|
|
48509
48473
|
assertProtocolV2SettingValues(this.payload, capabilities);
|
|
@@ -48526,7 +48490,14 @@ class DeviceSettings extends BaseMethod {
|
|
|
48526
48490
|
const res = yield this.device.commands.typedCall('DeviceSettingsPageShow', 'Success', {
|
|
48527
48491
|
page: hdTransport.DeviceSettingsPage.DevicePassphrase,
|
|
48528
48492
|
});
|
|
48529
|
-
yield refreshStatusAndSettings();
|
|
48493
|
+
const updated = yield refreshStatusAndSettings();
|
|
48494
|
+
const lockedAfterDisabling = requestedPassphrase === false &&
|
|
48495
|
+
current.status.unlocked === true &&
|
|
48496
|
+
updated.status.unlocked === false;
|
|
48497
|
+
if (updated.status.passphraseProtection !== requestedPassphrase &&
|
|
48498
|
+
!lockedAfterDisabling) {
|
|
48499
|
+
throw hdShared.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'Protocol V2 passphrase setting did not reach the requested value.');
|
|
48500
|
+
}
|
|
48530
48501
|
return res.message;
|
|
48531
48502
|
}
|
|
48532
48503
|
if (requestedAirgap !== undefined) {
|
|
@@ -54496,7 +54467,6 @@ class DeviceUploadWallpaper extends BaseMethod {
|
|
|
54496
54467
|
const response = yield this.device.commands.typedCall('DeviceSettingsSet', 'Success', {
|
|
54497
54468
|
settings: { wallpaper_path: this.path },
|
|
54498
54469
|
});
|
|
54499
|
-
yield this.device.refreshProtocolV2SettingsAfterMutation();
|
|
54500
54470
|
return {
|
|
54501
54471
|
path: this.path,
|
|
54502
54472
|
size: encoded.data.byteLength,
|
|
@@ -65018,7 +64988,6 @@ const createUiProgressMessageFilter = (intervalMs = DEFAULT_UI_PROGRESS_INTERVAL
|
|
|
65018
64988
|
|
|
65019
64989
|
const Log = getLogger(exports.LoggerNames.Core);
|
|
65020
64990
|
const PRE_INITIALIZE_TTL_MS = 60 * 1000;
|
|
65021
|
-
const PRE_PENDING_CALL_TIMEOUT_MS = 15 * 1000;
|
|
65022
64991
|
const preWarmInflight = new Map();
|
|
65023
64992
|
const preWarmDoneAt = new Map();
|
|
65024
64993
|
function hasDeriveCardano(method) {
|
|
@@ -65174,40 +65143,29 @@ const handlePreWarmSignal = (context, message, method) => __awaiter(void 0, void
|
|
|
65174
65143
|
}
|
|
65175
65144
|
}
|
|
65176
65145
|
});
|
|
65177
|
-
const
|
|
65178
|
-
const
|
|
65146
|
+
const waitWithTimeout = (promise, timeout) => __awaiter(void 0, void 0, void 0, function* () {
|
|
65147
|
+
const timeoutPromise = new Promise((_, reject) => {
|
|
65148
|
+
setTimeout(() => reject(new Error('Request timeout')), timeout);
|
|
65149
|
+
});
|
|
65150
|
+
return Promise.race([promise, timeoutPromise]);
|
|
65151
|
+
});
|
|
65152
|
+
const waitForPendingPromise = (getPrePendingCallPromise, removePrePendingCallPromise) => __awaiter(void 0, void 0, void 0, function* () {
|
|
65153
|
+
const pendingPromise = getPrePendingCallPromise();
|
|
65179
65154
|
if (pendingPromise) {
|
|
65180
65155
|
Log.debug('pre pending call promise before call method, wait for it');
|
|
65181
|
-
let timer;
|
|
65182
|
-
let timedOut = false;
|
|
65183
65156
|
try {
|
|
65184
|
-
yield
|
|
65185
|
-
pendingPromise,
|
|
65186
|
-
new Promise(resolve => {
|
|
65187
|
-
timer = setTimeout(() => {
|
|
65188
|
-
timedOut = true;
|
|
65189
|
-
resolve();
|
|
65190
|
-
}, PRE_PENDING_CALL_TIMEOUT_MS);
|
|
65191
|
-
}),
|
|
65192
|
-
]);
|
|
65157
|
+
yield waitWithTimeout(pendingPromise, 5 * 1000);
|
|
65193
65158
|
}
|
|
65194
65159
|
catch (error) {
|
|
65195
65160
|
}
|
|
65196
|
-
|
|
65197
|
-
if (timer)
|
|
65198
|
-
clearTimeout(timer);
|
|
65199
|
-
removePrePendingCallPromise === null || removePrePendingCallPromise === void 0 ? void 0 : removePrePendingCallPromise(connectId, pendingPromise);
|
|
65200
|
-
}
|
|
65201
|
-
if (timedOut) {
|
|
65202
|
-
Log.warn('pre pending call promise timed out before call method', { connectId });
|
|
65203
|
-
}
|
|
65161
|
+
removePrePendingCallPromise === null || removePrePendingCallPromise === void 0 ? void 0 : removePrePendingCallPromise(pendingPromise);
|
|
65204
65162
|
Log.debug('pre pending call promise before call method done');
|
|
65205
65163
|
}
|
|
65206
65164
|
});
|
|
65207
65165
|
const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, void 0, function* () {
|
|
65208
|
-
var _d, _e, _f, _g, _h
|
|
65166
|
+
var _d, _e, _f, _g, _h;
|
|
65209
65167
|
let messageResponse;
|
|
65210
|
-
const { requestQueue, getPrePendingCallPromise,
|
|
65168
|
+
const { requestQueue, getPrePendingCallPromise, setPrePendingCallPromise } = context;
|
|
65211
65169
|
updateMethodRequestContext(method, { status: 'running' });
|
|
65212
65170
|
const normalizePassphraseState = (s) => s || '';
|
|
65213
65171
|
const connectStateChange = normalizePassphraseState(preConnectCache.passphraseState) !==
|
|
@@ -65222,7 +65180,7 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
65222
65180
|
if (method.connectId) {
|
|
65223
65181
|
yield context.waitForCallbackTasks(method.connectId);
|
|
65224
65182
|
}
|
|
65225
|
-
yield waitForPendingPromise(
|
|
65183
|
+
yield waitForPendingPromise(getPrePendingCallPromise, setPrePendingCallPromise);
|
|
65226
65184
|
const task = requestQueue.createTask(method);
|
|
65227
65185
|
let preWarmCallbackTask;
|
|
65228
65186
|
if (method.isPreWarmSignal && method.connectId) {
|
|
@@ -65231,9 +65189,9 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
65231
65189
|
}
|
|
65232
65190
|
let device;
|
|
65233
65191
|
try {
|
|
65234
|
-
const connectId = (
|
|
65192
|
+
const connectId = (_d = method.connectId) !== null && _d !== void 0 ? _d : '';
|
|
65235
65193
|
const pollingId = pollingManager.start(connectId);
|
|
65236
|
-
device = yield ensureConnected(context, method, connectId, pollingId, (
|
|
65194
|
+
device = yield ensureConnected(context, method, connectId, pollingId, (_e = task.abortController) === null || _e === void 0 ? void 0 : _e.signal);
|
|
65237
65195
|
}
|
|
65238
65196
|
catch (e) {
|
|
65239
65197
|
preWarmCallbackTask === null || preWarmCallbackTask === void 0 ? void 0 : preWarmCallbackTask.resolve();
|
|
@@ -65248,17 +65206,17 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
65248
65206
|
requestQueue.releaseTask(method.responseID);
|
|
65249
65207
|
return createResponseMessage(method.responseID, false, { error: e });
|
|
65250
65208
|
}
|
|
65251
|
-
if ((
|
|
65209
|
+
if ((_f = method.payload) === null || _f === void 0 ? void 0 : _f.onlyConnectBleDevice) {
|
|
65252
65210
|
preWarmCallbackTask === null || preWarmCallbackTask === void 0 ? void 0 : preWarmCallbackTask.resolve();
|
|
65253
65211
|
Log.debug('Call API - only connect ble device: ', device === null || device === void 0 ? void 0 : device.mainId);
|
|
65254
65212
|
return createResponseMessage(method.responseID, true, null);
|
|
65255
65213
|
}
|
|
65256
65214
|
Log.debug('Call API - setDevice: ', device.mainId);
|
|
65257
|
-
(
|
|
65215
|
+
(_g = method.setDevice) === null || _g === void 0 ? void 0 : _g.call(method, device);
|
|
65258
65216
|
method.context = context;
|
|
65259
65217
|
updateMethodRequestContext(method, {
|
|
65260
65218
|
deviceInstanceId: device.instanceId,
|
|
65261
|
-
commandsInstanceId: (
|
|
65219
|
+
commandsInstanceId: (_h = device.commands) === null || _h === void 0 ? void 0 : _h.instanceId,
|
|
65262
65220
|
});
|
|
65263
65221
|
const activeRequests = getActiveRequestsByDeviceInstance(device.instanceId);
|
|
65264
65222
|
if (activeRequests.length > 0) {
|
|
@@ -65287,14 +65245,14 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
65287
65245
|
if (method.connectId) {
|
|
65288
65246
|
yield context.waitForCallbackTasks(method.connectId, preWarmCallbackTask);
|
|
65289
65247
|
}
|
|
65290
|
-
yield waitForPendingPromise(
|
|
65248
|
+
yield waitForPendingPromise(getPrePendingCallPromise, setPrePendingCallPromise);
|
|
65291
65249
|
const inner = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
65292
|
-
var
|
|
65250
|
+
var _j, _k;
|
|
65293
65251
|
method.assertProtocolSupported(device.getProtocol(), device.getCurrentFirmwareType());
|
|
65294
65252
|
protocolV2Operation = device.isProtocolV2();
|
|
65295
65253
|
const versionRange = device.getCurrentMethodVersionRange(type => method.getVersionRange()[type]);
|
|
65296
|
-
const currentFirmwareVersion = (
|
|
65297
|
-
const currentBleVersion = (
|
|
65254
|
+
const currentFirmwareVersion = (_j = device.getCurrentFirmwareVersionString()) !== null && _j !== void 0 ? _j : '0.0.0';
|
|
65255
|
+
const currentBleVersion = (_k = device.getCurrentBLEFirmwareVersionString()) !== null && _k !== void 0 ? _k : '0.0.0';
|
|
65298
65256
|
const deviceFirmwareType = device.getCurrentFirmwareType();
|
|
65299
65257
|
let newVersionStatus;
|
|
65300
65258
|
if (device.features && !device.isProtocolV2()) {
|
|
@@ -65372,7 +65330,7 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
65372
65330
|
}
|
|
65373
65331
|
},
|
|
65374
65332
|
prepare: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
65375
|
-
var
|
|
65333
|
+
var _l, _m, _o, _p, _q;
|
|
65376
65334
|
if (method.deviceId && method.checkDeviceId && !deviceIdCheckedDuringUnlockPreflight) {
|
|
65377
65335
|
const isSameDeviceID = yield checkLiveDeviceId(device, method.deviceId);
|
|
65378
65336
|
if (!isSameDeviceID) {
|
|
@@ -65392,7 +65350,7 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
65392
65350
|
require: support.require,
|
|
65393
65351
|
});
|
|
65394
65352
|
}
|
|
65395
|
-
const passphraseStateSafety = yield device.checkPassphraseStateSafety((
|
|
65353
|
+
const passphraseStateSafety = yield device.checkPassphraseStateSafety((_l = method.payload) === null || _l === void 0 ? void 0 : _l.passphraseState, (_m = method.payload) === null || _m === void 0 ? void 0 : _m.useEmptyPassphrase, (_o = method.payload) === null || _o === void 0 ? void 0 : _o.skipPassphraseCheck, hasDeriveCardano(method));
|
|
65396
65354
|
checkPassphraseEnableState(method, device.features);
|
|
65397
65355
|
if (!passphraseStateSafety) {
|
|
65398
65356
|
DevicePool.clearDeviceCache(method.payload.connectId);
|
|
@@ -65410,7 +65368,7 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
|
|
|
65410
65368
|
? e
|
|
65411
65369
|
: hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'open safety check failed.');
|
|
65412
65370
|
}
|
|
65413
|
-
(
|
|
65371
|
+
(_q = (_p = method.device) === null || _p === void 0 ? void 0 : _p.commands) === null || _q === void 0 ? void 0 : _q.checkDisposed();
|
|
65414
65372
|
}),
|
|
65415
65373
|
});
|
|
65416
65374
|
messageResponse = createResponseMessage(method.responseID, true, response);
|
|
@@ -65606,13 +65564,6 @@ function isRetryableBleProtocolV2ProbeError(method, error) {
|
|
|
65606
65564
|
message.includes('expected V2') &&
|
|
65607
65565
|
message.includes('did not respond to expected protocol'));
|
|
65608
65566
|
}
|
|
65609
|
-
function isMissingDetectedProtocolV2Error(method, error) {
|
|
65610
|
-
const typedError = error;
|
|
65611
|
-
return (method.payload.connectProtocol === 'V2' &&
|
|
65612
|
-
(typedError === null || typedError === void 0 ? void 0 : typedError.errorCode) === hdShared.HardwareErrorCode.RuntimeError &&
|
|
65613
|
-
typeof typedError.message === 'string' &&
|
|
65614
|
-
typedError.message.includes('Device protocol has not been detected'));
|
|
65615
|
-
}
|
|
65616
65567
|
function connectDeviceForBle(method, device, retryCount = 0) {
|
|
65617
65568
|
var _a;
|
|
65618
65569
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -65647,8 +65598,7 @@ function connectDeviceForBle(method, device, retryCount = 0) {
|
|
|
65647
65598
|
}
|
|
65648
65599
|
}
|
|
65649
65600
|
catch (err) {
|
|
65650
|
-
|
|
65651
|
-
if ((hdShared.ERROR_CODES_REQUIRE_DISCONNECT.includes(err.errorCode) || requiresColdReconnect) &&
|
|
65601
|
+
if (hdShared.ERROR_CODES_REQUIRE_DISCONNECT.includes(err.errorCode) &&
|
|
65652
65602
|
device.mainId &&
|
|
65653
65603
|
device.deviceConnector) {
|
|
65654
65604
|
yield device.deviceConnector.disconnect(device.mainId).catch(() => undefined);
|
|
@@ -65656,11 +65606,10 @@ function connectDeviceForBle(method, device, retryCount = 0) {
|
|
|
65656
65606
|
}
|
|
65657
65607
|
if ((err.errorCode === hdShared.HardwareErrorCode.BleTimeoutError ||
|
|
65658
65608
|
err.errorCode === hdShared.HardwareErrorCode.BleConnectedError ||
|
|
65659
|
-
isRetryableBleProtocolV2ProbeError(method, err)
|
|
65660
|
-
requiresColdReconnect) &&
|
|
65609
|
+
isRetryableBleProtocolV2ProbeError(method, err)) &&
|
|
65661
65610
|
retryCount < 6) {
|
|
65662
65611
|
const nextRetry = retryCount + 1;
|
|
65663
|
-
Log.debug(`Bluetooth
|
|
65612
|
+
Log.debug(`Bluetooth connect timeout and will retry, retry count: ${nextRetry}`);
|
|
65664
65613
|
yield wait(3000);
|
|
65665
65614
|
yield connectDeviceForBle(method, device, nextRetry);
|
|
65666
65615
|
}
|
|
@@ -65679,7 +65628,7 @@ const ensureConnected = (_context, method, connectId, pollingId, abortSignal) =>
|
|
|
65679
65628
|
Log.debug(`EnsureConnected function start, MAX_RETRY_COUNT=${MAX_RETRY_COUNT}, POLL_INTERVAL_TIME=${POLL_INTERVAL_TIME} `);
|
|
65680
65629
|
const poll = (time = POLL_INTERVAL_TIME) => __awaiter(void 0, void 0, void 0, function* () {
|
|
65681
65630
|
return new Promise((resolve, reject) => __awaiter(void 0, void 0, void 0, function* () {
|
|
65682
|
-
var
|
|
65631
|
+
var _r;
|
|
65683
65632
|
const abort = () => {
|
|
65684
65633
|
if (abortSignal && abortSignal.aborted) {
|
|
65685
65634
|
if (timer) {
|
|
@@ -65794,7 +65743,7 @@ const ensureConnected = (_context, method, connectId, pollingId, abortSignal) =>
|
|
|
65794
65743
|
clearTimeout(timer);
|
|
65795
65744
|
}
|
|
65796
65745
|
Log.debug('EnsureConnected get to max try count, will return: ', tryCount);
|
|
65797
|
-
if (DataManager.isBrowserWebUsb(env) && !((
|
|
65746
|
+
if (DataManager.isBrowserWebUsb(env) && !((_r = method.payload) === null || _r === void 0 ? void 0 : _r.skipWebDevicePrompt)) {
|
|
65798
65747
|
postMessage(createUiMessage(UI_REQUEST.WEB_DEVICE_PROMPT_ACCESS_PERMISSION));
|
|
65799
65748
|
reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.WebDeviceNotFoundOrNeedsPermission));
|
|
65800
65749
|
}
|
|
@@ -65812,7 +65761,7 @@ const ensureConnected = (_context, method, connectId, pollingId, abortSignal) =>
|
|
|
65812
65761
|
return poll();
|
|
65813
65762
|
});
|
|
65814
65763
|
const cancel = (context, connectId) => {
|
|
65815
|
-
var _a, _b
|
|
65764
|
+
var _a, _b;
|
|
65816
65765
|
const { requestQueue, setPrePendingCallPromise } = context;
|
|
65817
65766
|
if (connectId) {
|
|
65818
65767
|
try {
|
|
@@ -65826,7 +65775,7 @@ const cancel = (context, connectId) => {
|
|
|
65826
65775
|
if (task && ((_a = task.method) === null || _a === void 0 ? void 0 : _a.device)) {
|
|
65827
65776
|
if (!canceledDevices.includes(task.method.device)) {
|
|
65828
65777
|
const { device } = task.method;
|
|
65829
|
-
setPrePendingCallPromise(
|
|
65778
|
+
setPrePendingCallPromise(device === null || device === void 0 ? void 0 : device.interruptionFromUser());
|
|
65830
65779
|
canceledDevices.push(device);
|
|
65831
65780
|
}
|
|
65832
65781
|
requestQueue.rejectRequest(requestId, hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.CallQueueActionCancelled));
|
|
@@ -65846,7 +65795,7 @@ const cancel = (context, connectId) => {
|
|
|
65846
65795
|
for (const requestId of requestQueue.getRequestTasksId()) {
|
|
65847
65796
|
const task = requestQueue.getTask(requestId);
|
|
65848
65797
|
Log.debug('Cancel Api connect task: ', task);
|
|
65849
|
-
if (task && ((
|
|
65798
|
+
if (task && ((_b = task.method) === null || _b === void 0 ? void 0 : _b.device)) {
|
|
65850
65799
|
if (!canceledDevices.includes(task.method.device)) {
|
|
65851
65800
|
const { device } = task.method;
|
|
65852
65801
|
device === null || device === void 0 ? void 0 : device.interruptionFromUser();
|
|
@@ -66035,7 +65984,6 @@ class Core extends events.exports {
|
|
|
66035
65984
|
constructor() {
|
|
66036
65985
|
super();
|
|
66037
65986
|
this.requestQueue = new RequestQueue();
|
|
66038
|
-
this.prePendingCallPromises = new Map();
|
|
66039
65987
|
this.methodSynchronize = getSynchronize();
|
|
66040
65988
|
this.tracingContext = createSdkTracingContext();
|
|
66041
65989
|
this.sdkInstanceId = this.tracingContext.sdkInstanceId;
|
|
@@ -66047,18 +65995,9 @@ class Core extends events.exports {
|
|
|
66047
65995
|
tracingContext: this.tracingContext,
|
|
66048
65996
|
requestQueue: this.requestQueue,
|
|
66049
65997
|
methodSynchronize: this.methodSynchronize,
|
|
66050
|
-
getPrePendingCallPromise: (
|
|
66051
|
-
setPrePendingCallPromise: (
|
|
66052
|
-
|
|
66053
|
-
this.prePendingCallPromises.delete(connectId);
|
|
66054
|
-
return;
|
|
66055
|
-
}
|
|
66056
|
-
this.prePendingCallPromises.set(connectId, promise);
|
|
66057
|
-
},
|
|
66058
|
-
removePrePendingCallPromise: (connectId, promise) => {
|
|
66059
|
-
if (this.prePendingCallPromises.get(connectId) === promise) {
|
|
66060
|
-
this.prePendingCallPromises.delete(connectId);
|
|
66061
|
-
}
|
|
65998
|
+
getPrePendingCallPromise: () => this.prePendingCallPromise,
|
|
65999
|
+
setPrePendingCallPromise: (promise) => {
|
|
66000
|
+
this.prePendingCallPromise = promise;
|
|
66062
66001
|
},
|
|
66063
66002
|
registerCallbackTask: (connectId, callbackPromise) => {
|
|
66064
66003
|
this.requestQueue.registerPendingCallbackTask(connectId, callbackPromise);
|
|
@@ -66152,7 +66091,7 @@ class Core extends events.exports {
|
|
|
66152
66091
|
preWarmInflight.clear();
|
|
66153
66092
|
preWarmDoneAt.clear();
|
|
66154
66093
|
preConnectCache = { passphraseState: undefined };
|
|
66155
|
-
this.
|
|
66094
|
+
this.prePendingCallPromise = undefined;
|
|
66156
66095
|
this.removeAllListeners();
|
|
66157
66096
|
cleanupSdkInstance(this.sdkInstanceId);
|
|
66158
66097
|
if (_core === this)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/hd-core",
|
|
3
|
-
"version": "1.2.0-alpha.
|
|
3
|
+
"version": "1.2.0-alpha.133-ok59992",
|
|
4
4
|
"description": "Core processes and APIs for communicating with OneKey hardware devices.",
|
|
5
5
|
"author": "OneKey",
|
|
6
6
|
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"url": "https://github.com/OneKeyHQ/hardware-js-sdk/issues"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@onekeyfe/hd-shared": "1.2.0-alpha.
|
|
29
|
-
"@onekeyfe/hd-transport": "1.2.0-alpha.
|
|
28
|
+
"@onekeyfe/hd-shared": "1.2.0-alpha.133-ok59992",
|
|
29
|
+
"@onekeyfe/hd-transport": "1.2.0-alpha.133-ok59992",
|
|
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": "521eb4523f54abc5ceca28a48b7120158fea1ac0"
|
|
50
50
|
}
|
|
@@ -168,7 +168,8 @@ export default class DeviceSettings extends BaseMethod<ApplySettings> {
|
|
|
168
168
|
async run() {
|
|
169
169
|
try {
|
|
170
170
|
if (this.device.isProtocolV2()) {
|
|
171
|
-
const refreshStatusAndSettings = () =>
|
|
171
|
+
const refreshStatusAndSettings = () =>
|
|
172
|
+
this.device.getDeviceState({ refreshSections: ['status', 'settings'] });
|
|
172
173
|
assertSettingsSupported(this.payload, DEVICE_SETTINGS_V1_ONLY_FIELDS, 'Protocol V2');
|
|
173
174
|
const capabilities = getDeviceSettingsCapabilities(
|
|
174
175
|
this.device.getCurrentDeviceType(),
|
|
@@ -200,7 +201,20 @@ export default class DeviceSettings extends BaseMethod<ApplySettings> {
|
|
|
200
201
|
const res = await this.device.commands.typedCall('DeviceSettingsPageShow', 'Success', {
|
|
201
202
|
page: DeviceSettingsPage.DevicePassphrase,
|
|
202
203
|
});
|
|
203
|
-
await refreshStatusAndSettings();
|
|
204
|
+
const updated = await refreshStatusAndSettings();
|
|
205
|
+
const lockedAfterDisabling =
|
|
206
|
+
requestedPassphrase === false &&
|
|
207
|
+
current.status.unlocked === true &&
|
|
208
|
+
updated.status.unlocked === false;
|
|
209
|
+
if (
|
|
210
|
+
updated.status.passphraseProtection !== requestedPassphrase &&
|
|
211
|
+
!lockedAfterDisabling
|
|
212
|
+
) {
|
|
213
|
+
throw TypedError(
|
|
214
|
+
HardwareErrorCode.RuntimeError,
|
|
215
|
+
'Protocol V2 passphrase setting did not reach the requested value.'
|
|
216
|
+
);
|
|
217
|
+
}
|
|
204
218
|
return res.message;
|
|
205
219
|
}
|
|
206
220
|
if (requestedAirgap !== undefined) {
|
|
@@ -143,7 +143,6 @@ export default class DeviceUploadWallpaper extends BaseMethod<DeviceUploadWallpa
|
|
|
143
143
|
const response = await this.device.commands.typedCall('DeviceSettingsSet', 'Success', {
|
|
144
144
|
settings: { wallpaper_path: this.path },
|
|
145
145
|
});
|
|
146
|
-
await this.device.refreshProtocolV2SettingsAfterMutation();
|
|
147
146
|
return {
|
|
148
147
|
path: this.path,
|
|
149
148
|
size: encoded.data.byteLength,
|
package/src/core/index.ts
CHANGED
|
@@ -83,7 +83,6 @@ import type { BaseMethod } from '../api/BaseMethod';
|
|
|
83
83
|
|
|
84
84
|
const Log = getLogger(LoggerNames.Core);
|
|
85
85
|
const PRE_INITIALIZE_TTL_MS = 60 * 1000;
|
|
86
|
-
const PRE_PENDING_CALL_TIMEOUT_MS = 15 * 1000;
|
|
87
86
|
|
|
88
87
|
// Dedup/coalesce state for "pre-warm signal" methods (isPreWarmSignal),
|
|
89
88
|
// keyed by getPreWarmKey(): coalesce in-flight, skip if warmed within TTL.
|
|
@@ -297,35 +296,26 @@ const handlePreWarmSignal = async (
|
|
|
297
296
|
}
|
|
298
297
|
};
|
|
299
298
|
|
|
299
|
+
const waitWithTimeout = async (promise: Promise<any>, timeout: number) => {
|
|
300
|
+
const timeoutPromise = new Promise((_, reject) => {
|
|
301
|
+
setTimeout(() => reject(new Error('Request timeout')), timeout);
|
|
302
|
+
});
|
|
303
|
+
return Promise.race([promise, timeoutPromise]);
|
|
304
|
+
};
|
|
305
|
+
|
|
300
306
|
const waitForPendingPromise = async (
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
removePrePendingCallPromise?: (connectId: string, promise: Promise<void>) => void
|
|
307
|
+
getPrePendingCallPromise: () => Promise<void> | undefined,
|
|
308
|
+
removePrePendingCallPromise?: (promise: Promise<void> | undefined) => void
|
|
304
309
|
) => {
|
|
305
|
-
const pendingPromise = getPrePendingCallPromise(
|
|
310
|
+
const pendingPromise = getPrePendingCallPromise();
|
|
306
311
|
if (pendingPromise) {
|
|
307
312
|
Log.debug('pre pending call promise before call method, wait for it');
|
|
308
|
-
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
309
|
-
let timedOut = false;
|
|
310
313
|
try {
|
|
311
|
-
await
|
|
312
|
-
pendingPromise,
|
|
313
|
-
new Promise<void>(resolve => {
|
|
314
|
-
timer = setTimeout(() => {
|
|
315
|
-
timedOut = true;
|
|
316
|
-
resolve();
|
|
317
|
-
}, PRE_PENDING_CALL_TIMEOUT_MS);
|
|
318
|
-
}),
|
|
319
|
-
]);
|
|
314
|
+
await waitWithTimeout(pendingPromise, 5 * 1000);
|
|
320
315
|
} catch (error) {
|
|
321
|
-
//
|
|
322
|
-
} finally {
|
|
323
|
-
if (timer) clearTimeout(timer);
|
|
324
|
-
removePrePendingCallPromise?.(connectId, pendingPromise);
|
|
325
|
-
}
|
|
326
|
-
if (timedOut) {
|
|
327
|
-
Log.warn('pre pending call promise timed out before call method', { connectId });
|
|
316
|
+
// ignore timeout error
|
|
328
317
|
}
|
|
318
|
+
removePrePendingCallPromise?.(pendingPromise);
|
|
329
319
|
Log.debug('pre pending call promise before call method done');
|
|
330
320
|
}
|
|
331
321
|
};
|
|
@@ -337,7 +327,7 @@ const onCallDevice = async (
|
|
|
337
327
|
): Promise<any> => {
|
|
338
328
|
let messageResponse: any;
|
|
339
329
|
|
|
340
|
-
const { requestQueue, getPrePendingCallPromise,
|
|
330
|
+
const { requestQueue, getPrePendingCallPromise, setPrePendingCallPromise } = context;
|
|
341
331
|
|
|
342
332
|
updateMethodRequestContext(method, { status: 'running' });
|
|
343
333
|
|
|
@@ -365,11 +355,7 @@ const onCallDevice = async (
|
|
|
365
355
|
await context.waitForCallbackTasks(method.connectId);
|
|
366
356
|
}
|
|
367
357
|
|
|
368
|
-
await waitForPendingPromise(
|
|
369
|
-
method.connectId ?? '',
|
|
370
|
-
getPrePendingCallPromise,
|
|
371
|
-
removePrePendingCallPromise
|
|
372
|
-
);
|
|
358
|
+
await waitForPendingPromise(getPrePendingCallPromise, setPrePendingCallPromise);
|
|
373
359
|
|
|
374
360
|
const task = requestQueue.createTask(method);
|
|
375
361
|
|
|
@@ -468,11 +454,7 @@ const onCallDevice = async (
|
|
|
468
454
|
await context.waitForCallbackTasks(method.connectId, preWarmCallbackTask);
|
|
469
455
|
}
|
|
470
456
|
|
|
471
|
-
await waitForPendingPromise(
|
|
472
|
-
method.connectId ?? '',
|
|
473
|
-
getPrePendingCallPromise,
|
|
474
|
-
removePrePendingCallPromise
|
|
475
|
-
);
|
|
457
|
+
await waitForPendingPromise(getPrePendingCallPromise, setPrePendingCallPromise);
|
|
476
458
|
|
|
477
459
|
const inner = async (): Promise<void> => {
|
|
478
460
|
// Protocol is established from an active device response during acquire/initialize.
|
|
@@ -924,16 +906,6 @@ function isRetryableBleProtocolV2ProbeError(method: BaseMethod, error: unknown)
|
|
|
924
906
|
);
|
|
925
907
|
}
|
|
926
908
|
|
|
927
|
-
export function isMissingDetectedProtocolV2Error(method: BaseMethod, error: unknown) {
|
|
928
|
-
const typedError = error as { errorCode?: unknown; message?: unknown };
|
|
929
|
-
return (
|
|
930
|
-
method.payload.connectProtocol === 'V2' &&
|
|
931
|
-
typedError?.errorCode === HardwareErrorCode.RuntimeError &&
|
|
932
|
-
typeof typedError.message === 'string' &&
|
|
933
|
-
typedError.message.includes('Device protocol has not been detected')
|
|
934
|
-
);
|
|
935
|
-
}
|
|
936
|
-
|
|
937
909
|
/**
|
|
938
910
|
* If the Bluetooth connection times out, retry up to 6 times
|
|
939
911
|
* @param retryCount - Current retry count (default 0)
|
|
@@ -971,13 +943,12 @@ async function connectDeviceForBle(method: BaseMethod, device: Device, retryCoun
|
|
|
971
943
|
DevicePool.emitter.emit(DEVICE.CONNECT, device);
|
|
972
944
|
}
|
|
973
945
|
} catch (err) {
|
|
974
|
-
const requiresColdReconnect = isMissingDetectedProtocolV2Error(method, err);
|
|
975
946
|
// Device.run()'s REQUIRE_DISCONNECT handling never sees acquire/initialize
|
|
976
947
|
// failures, so with keep-alive a wedged link would be reused by every retry
|
|
977
948
|
// (field case: Initialize timing out at 25s per attempt, forever). Drop it
|
|
978
949
|
// here so the next retry cold-connects.
|
|
979
950
|
if (
|
|
980
|
-
|
|
951
|
+
ERROR_CODES_REQUIRE_DISCONNECT.includes(err.errorCode) &&
|
|
981
952
|
device.mainId &&
|
|
982
953
|
device.deviceConnector
|
|
983
954
|
) {
|
|
@@ -990,12 +961,11 @@ async function connectDeviceForBle(method: BaseMethod, device: Device, retryCoun
|
|
|
990
961
|
if (
|
|
991
962
|
(err.errorCode === HardwareErrorCode.BleTimeoutError ||
|
|
992
963
|
err.errorCode === HardwareErrorCode.BleConnectedError ||
|
|
993
|
-
isRetryableBleProtocolV2ProbeError(method, err)
|
|
994
|
-
requiresColdReconnect) &&
|
|
964
|
+
isRetryableBleProtocolV2ProbeError(method, err)) &&
|
|
995
965
|
retryCount < 6
|
|
996
966
|
) {
|
|
997
967
|
const nextRetry = retryCount + 1;
|
|
998
|
-
Log.debug(`Bluetooth
|
|
968
|
+
Log.debug(`Bluetooth connect timeout and will retry, retry count: ${nextRetry}`);
|
|
999
969
|
await wait(3000);
|
|
1000
970
|
await connectDeviceForBle(method, device, nextRetry);
|
|
1001
971
|
} else {
|
|
@@ -1207,10 +1177,7 @@ export const cancel = (context: CoreContext, connectId?: string) => {
|
|
|
1207
1177
|
if (task && task.method?.device) {
|
|
1208
1178
|
if (!canceledDevices.includes(task.method.device)) {
|
|
1209
1179
|
const { device } = task.method;
|
|
1210
|
-
setPrePendingCallPromise(
|
|
1211
|
-
task.method.connectId ?? connectId,
|
|
1212
|
-
device.interruptionFromUser()
|
|
1213
|
-
);
|
|
1180
|
+
setPrePendingCallPromise(device?.interruptionFromUser());
|
|
1214
1181
|
canceledDevices.push(device);
|
|
1215
1182
|
}
|
|
1216
1183
|
requestQueue.rejectRequest(
|
|
@@ -1564,7 +1531,7 @@ export default class Core extends EventEmitter {
|
|
|
1564
1531
|
private disposePromise?: Promise<void>;
|
|
1565
1532
|
|
|
1566
1533
|
// background task
|
|
1567
|
-
private
|
|
1534
|
+
private prePendingCallPromise: Promise<void> | undefined;
|
|
1568
1535
|
|
|
1569
1536
|
private methodSynchronize = getSynchronize();
|
|
1570
1537
|
|
|
@@ -1581,18 +1548,9 @@ export default class Core extends EventEmitter {
|
|
|
1581
1548
|
tracingContext: this.tracingContext,
|
|
1582
1549
|
requestQueue: this.requestQueue,
|
|
1583
1550
|
methodSynchronize: this.methodSynchronize,
|
|
1584
|
-
getPrePendingCallPromise: (
|
|
1585
|
-
setPrePendingCallPromise: (
|
|
1586
|
-
|
|
1587
|
-
this.prePendingCallPromises.delete(connectId);
|
|
1588
|
-
return;
|
|
1589
|
-
}
|
|
1590
|
-
this.prePendingCallPromises.set(connectId, promise);
|
|
1591
|
-
},
|
|
1592
|
-
removePrePendingCallPromise: (connectId: string, promise: Promise<void>) => {
|
|
1593
|
-
if (this.prePendingCallPromises.get(connectId) === promise) {
|
|
1594
|
-
this.prePendingCallPromises.delete(connectId);
|
|
1595
|
-
}
|
|
1551
|
+
getPrePendingCallPromise: () => this.prePendingCallPromise,
|
|
1552
|
+
setPrePendingCallPromise: (promise: Promise<void> | undefined) => {
|
|
1553
|
+
this.prePendingCallPromise = promise;
|
|
1596
1554
|
},
|
|
1597
1555
|
// callback 任务管理
|
|
1598
1556
|
registerCallbackTask: (connectId: string, callbackPromise: Deferred<any>) => {
|
|
@@ -1707,7 +1665,7 @@ export default class Core extends EventEmitter {
|
|
|
1707
1665
|
preWarmInflight.clear();
|
|
1708
1666
|
preWarmDoneAt.clear();
|
|
1709
1667
|
preConnectCache = { passphraseState: undefined };
|
|
1710
|
-
this.
|
|
1668
|
+
this.prePendingCallPromise = undefined;
|
|
1711
1669
|
this.removeAllListeners();
|
|
1712
1670
|
cleanupSdkInstance(this.sdkInstanceId);
|
|
1713
1671
|
if (_core === this) _core = undefined;
|
package/src/device/Device.ts
CHANGED
|
@@ -284,9 +284,6 @@ export class Device extends EventEmitter {
|
|
|
284
284
|
|
|
285
285
|
runPromise?: Deferred<void> | null;
|
|
286
286
|
|
|
287
|
-
/** Resolves only after the active run has completed its release path. */
|
|
288
|
-
private runCleanupPromise?: Promise<void>;
|
|
289
|
-
|
|
290
287
|
externalState: string[] = [];
|
|
291
288
|
|
|
292
289
|
unavailableCapabilities: UnavailableCapabilities = {};
|
|
@@ -1082,10 +1079,6 @@ export class Device extends EventEmitter {
|
|
|
1082
1079
|
return params.includeRaw ? cloneDeviceState(this.state) : createPublicDeviceState(this.state);
|
|
1083
1080
|
}
|
|
1084
1081
|
|
|
1085
|
-
async refreshProtocolV2SettingsAfterMutation() {
|
|
1086
|
-
return this.getDeviceState({ refreshSections: ['status', 'settings'] });
|
|
1087
|
-
}
|
|
1088
|
-
|
|
1089
1082
|
_updateFeatures(protoFeatures: PROTO.Features | Features, initSession?: boolean) {
|
|
1090
1083
|
const previousDeviceId = this.getCurrentDeviceId();
|
|
1091
1084
|
let feat =
|
|
@@ -1403,20 +1396,12 @@ export class Device extends EventEmitter {
|
|
|
1403
1396
|
|
|
1404
1397
|
const runPromise = createDeferred<void>();
|
|
1405
1398
|
this.runPromise = runPromise;
|
|
1406
|
-
|
|
1399
|
+
this._runInner(fn, options, runPromise).catch(error => {
|
|
1407
1400
|
if (this.runPromise === runPromise) {
|
|
1408
1401
|
this.runPromise = null;
|
|
1409
1402
|
}
|
|
1410
1403
|
runPromise.reject(error);
|
|
1411
1404
|
});
|
|
1412
|
-
this.runCleanupPromise = cleanupPromise;
|
|
1413
|
-
cleanupPromise
|
|
1414
|
-
.finally(() => {
|
|
1415
|
-
if (this.runCleanupPromise === cleanupPromise) {
|
|
1416
|
-
this.runCleanupPromise = undefined;
|
|
1417
|
-
}
|
|
1418
|
-
})
|
|
1419
|
-
.catch(() => undefined);
|
|
1420
1405
|
return runPromise.promise;
|
|
1421
1406
|
}
|
|
1422
1407
|
|
|
@@ -1528,26 +1513,13 @@ export class Device extends EventEmitter {
|
|
|
1528
1513
|
|
|
1529
1514
|
async interruptionFromUser() {
|
|
1530
1515
|
const error = ERRORS.TypedError(HardwareErrorCode.DeviceInterruptedFromUser);
|
|
1531
|
-
|
|
1532
|
-
const { cancelableAction } = this;
|
|
1533
|
-
if (cancelableAction) {
|
|
1534
|
-
await cancelableAction(error);
|
|
1535
|
-
} else if (
|
|
1536
|
-
this.isProtocolV2() &&
|
|
1537
|
-
DataManager.isBleConnect(DataManager.getSettings('env')) &&
|
|
1538
|
-
this.hasDeviceAcquire()
|
|
1539
|
-
) {
|
|
1540
|
-
await this.commands?.cancelDevice?.().catch(cancelError => {
|
|
1541
|
-
Log.debug('Protocol V2 BLE fallback cancel error', cancelError);
|
|
1542
|
-
});
|
|
1543
|
-
}
|
|
1516
|
+
await this.cancelableAction?.(error);
|
|
1544
1517
|
await this.commands?.cancel();
|
|
1545
1518
|
|
|
1546
1519
|
if (this.runPromise) {
|
|
1547
1520
|
this.runPromise.reject(error);
|
|
1548
1521
|
this.runPromise = null;
|
|
1549
1522
|
}
|
|
1550
|
-
await cleanupPromise?.catch(() => undefined);
|
|
1551
1523
|
}
|
|
1552
1524
|
|
|
1553
1525
|
setCancelableAction(callback: (err?: Error) => Promise<unknown>) {
|
|
@@ -264,7 +264,6 @@ export class DeviceCommands {
|
|
|
264
264
|
}
|
|
265
265
|
const activeCall = this.callPromise;
|
|
266
266
|
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
267
|
-
let timedOut = false;
|
|
268
267
|
const cancellation = (async () => {
|
|
269
268
|
await this.dispose(true);
|
|
270
269
|
await activeCall?.catch(() => undefined);
|
|
@@ -274,23 +273,11 @@ export class DeviceCommands {
|
|
|
274
273
|
await Promise.race([
|
|
275
274
|
cancellation,
|
|
276
275
|
new Promise<void>(resolve => {
|
|
277
|
-
timer = setTimeout(
|
|
278
|
-
timedOut = true;
|
|
279
|
-
resolve();
|
|
280
|
-
}, 10 * 1000);
|
|
276
|
+
timer = setTimeout(resolve, 10 * 1000);
|
|
281
277
|
}),
|
|
282
278
|
]);
|
|
283
279
|
} finally {
|
|
284
280
|
if (timer) clearTimeout(timer);
|
|
285
|
-
if (
|
|
286
|
-
timedOut &&
|
|
287
|
-
this.transport.name === 'ReactNativeBleTransport' &&
|
|
288
|
-
this.transport.disconnect
|
|
289
|
-
) {
|
|
290
|
-
await this.transport.disconnect(this.mainId).catch(error => {
|
|
291
|
-
Log.debug('BLE cancellation timeout disconnect error (ignored)', error);
|
|
292
|
-
});
|
|
293
|
-
}
|
|
294
281
|
if (this.callPromise === activeCall) {
|
|
295
282
|
this.callPromise = undefined;
|
|
296
283
|
}
|