@onekeyfe/hd-core 1.2.0-alpha.125 → 1.2.0-alpha.127
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 +42 -0
- package/__tests__/device-connector-protocol.test.ts +21 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/device/DeviceCommands.d.ts.map +1 -1
- package/dist/device/DeviceConnector.d.ts.map +1 -1
- package/dist/index.js +18 -2
- package/package.json +4 -4
- package/src/core/index.ts +4 -0
- package/src/device/DeviceCommands.ts +8 -2
- package/src/device/DeviceConnector.ts +7 -0
|
@@ -19,6 +19,22 @@ const createCommands = () => {
|
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
describe('DeviceCommands failure mapping', () => {
|
|
22
|
+
it.each(['File already exists', 'NFT already exists'])(
|
|
23
|
+
'maps duplicate file response "%s" to FileAlreadyExists',
|
|
24
|
+
async message => {
|
|
25
|
+
const commands = createCommands();
|
|
26
|
+
await expect(
|
|
27
|
+
commands._filterCommonTypes(
|
|
28
|
+
{
|
|
29
|
+
type: 'Failure',
|
|
30
|
+
message: { code: 'Failure_DataError', message },
|
|
31
|
+
} as any,
|
|
32
|
+
'NFTUpdate'
|
|
33
|
+
)
|
|
34
|
+
).rejects.toMatchObject({ errorCode: HardwareErrorCode.FileAlreadyExists });
|
|
35
|
+
}
|
|
36
|
+
);
|
|
37
|
+
|
|
22
38
|
it('logs passphrase request and canonical response without exposing the passphrase', async () => {
|
|
23
39
|
const commands = createCommands();
|
|
24
40
|
const log = getLogger(LoggerNames.DeviceCommands);
|
|
@@ -276,6 +292,32 @@ describe('DeviceCommands failure mapping', () => {
|
|
|
276
292
|
]);
|
|
277
293
|
});
|
|
278
294
|
|
|
295
|
+
it.each(['Failure_ProcessError', 5])(
|
|
296
|
+
'maps USB-priority link disabled to public BLE error 723 for code %s',
|
|
297
|
+
async code => {
|
|
298
|
+
const commands = createCommands();
|
|
299
|
+
|
|
300
|
+
await expect(
|
|
301
|
+
commands._filterCommonTypes(
|
|
302
|
+
{
|
|
303
|
+
type: 'Failure',
|
|
304
|
+
message: {
|
|
305
|
+
code,
|
|
306
|
+
message: ' link disabled ',
|
|
307
|
+
},
|
|
308
|
+
} as any,
|
|
309
|
+
'DeviceInfo'
|
|
310
|
+
)
|
|
311
|
+
).rejects.toMatchObject({
|
|
312
|
+
errorCode: HardwareErrorCode.BleUnavailableWhileUsbConnected,
|
|
313
|
+
params: {
|
|
314
|
+
failureCode: code,
|
|
315
|
+
firmwareMessage: ' link disabled ',
|
|
316
|
+
},
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
);
|
|
320
|
+
|
|
279
321
|
it('maps an invalid DeviceSessionGet resume to WalletSessionInvalid', async () => {
|
|
280
322
|
const commands = createCommands();
|
|
281
323
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { HardwareErrorCode } from '@onekeyfe/hd-shared';
|
|
2
|
+
import { createProtocolV2LinkDisabledError } from '@onekeyfe/hd-transport';
|
|
2
3
|
|
|
3
4
|
import DeviceConnector from '../src/device/DeviceConnector';
|
|
4
5
|
|
|
@@ -78,4 +79,24 @@ describe('DeviceConnector protocol validation', () => {
|
|
|
78
79
|
'Device protocol mismatch: expected V2, detected V1'
|
|
79
80
|
);
|
|
80
81
|
});
|
|
82
|
+
|
|
83
|
+
it('preserves the Protocol V2 USB-priority failure as public BLE error 723', async () => {
|
|
84
|
+
transportManagerMock.default.getTransport.mockReturnValue({
|
|
85
|
+
acquire: jest
|
|
86
|
+
.fn()
|
|
87
|
+
.mockRejectedValue(
|
|
88
|
+
createProtocolV2LinkDisabledError('Failure_ProcessError', 'link disabled')
|
|
89
|
+
),
|
|
90
|
+
getProtocolType: jest.fn(() => undefined),
|
|
91
|
+
});
|
|
92
|
+
const connector = new DeviceConnector();
|
|
93
|
+
|
|
94
|
+
await expect(connector.acquire('pro2-id', undefined, undefined, 'V2')).rejects.toMatchObject({
|
|
95
|
+
errorCode: HardwareErrorCode.BleUnavailableWhileUsbConnected,
|
|
96
|
+
params: {
|
|
97
|
+
failureCode: 'Failure_ProcessError',
|
|
98
|
+
firmwareMessage: 'link disabled',
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
});
|
|
81
102
|
});
|
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;AAWhC,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC;AAmE7D,eAAO,MAAM,OAAO,YAAmB,WAAW,WAAW,WAAW,iBAoFvE,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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeviceCommands.d.ts","sourceRoot":"","sources":["../../src/device/DeviceCommands.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,KAAK,QAAQ,EACb,KAAK,SAAS,EACd,KAAK,oBAAoB,
|
|
1
|
+
{"version":3,"file":"DeviceCommands.d.ts","sourceRoot":"","sources":["../../src/device/DeviceCommands.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,KAAK,QAAQ,EACb,KAAK,SAAS,EACd,KAAK,oBAAoB,EAG1B,MAAM,wBAAwB,CAAC;AAIhC,OAAO,EAAU,KAAK,wBAAwB,EAAE,MAAM,WAAW,CAAC;AAQlE,OAAO,KAAK,EAAE,MAA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Root":"","sources":["../../src/device/DeviceConnector.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"DeviceConnector.d.ts","sourceRoot":"","sources":["../../src/device/DeviceConnector.ts"],"names":[],"mappings":";;AAUA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,KAAK,EAAE,gBAAgB,IAAI,gBAAgB,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAI9F,MAAM,CAAC,OAAO,OAAO,eAAe;IAClC,SAAS,CAAC,EAAE,SAAS,CAAC;IAEtB,eAAe,SAAK;IAEpB,OAAO,EAAE,gBAAgB,EAAE,GAAG,IAAI,CAAQ;IAE1C,QAAQ,EAAE,gBAAgB,EAAE,CAAM;IAElC,SAAS,UAAS;;IAQlB,OAAO,CAAC,kBAAkB;IAYpB,SAAS;IAWT,MAAM;IAgCZ,IAAI;IAIE,OAAO,CACX,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,EACvB,oBAAoB,CAAC,EAAE,OAAO,EAC9B,gBAAgB,CAAC,EAAE,uBAAuB,EAC1C,YAAY,CAAC,EAAE,uBAAuB;IAkDlC,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,CAAC,EAAE,OAAO;IAShE,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI;IAWnD,kBAAkB,IAAI,OAAO,CAAC,SAAS,GAAG,eAAe,GAAG,IAAI,CAAC;IAQjE,oBAAoB;CAGrB"}
|
package/dist/index.js
CHANGED
|
@@ -43830,7 +43830,7 @@ class DeviceCommands {
|
|
|
43830
43830
|
if (message === 'Please confirm the BlindSign enabled') {
|
|
43831
43831
|
error = hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.BlindSignDisabled);
|
|
43832
43832
|
}
|
|
43833
|
-
if (message === 'File already exists') {
|
|
43833
|
+
if (message === 'File already exists' || message === 'NFT already exists') {
|
|
43834
43834
|
error = hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.FileAlreadyExists);
|
|
43835
43835
|
}
|
|
43836
43836
|
if (message === null || message === void 0 ? void 0 : message.includes('bytes overflow')) {
|
|
@@ -43843,7 +43843,13 @@ class DeviceCommands {
|
|
|
43843
43843
|
});
|
|
43844
43844
|
}
|
|
43845
43845
|
}
|
|
43846
|
-
if (code
|
|
43846
|
+
if (hdTransport.isProtocolV2LinkDisabledFailure(code, message)) {
|
|
43847
|
+
error = hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.BleUnavailableWhileUsbConnected, undefined, {
|
|
43848
|
+
failureCode: code,
|
|
43849
|
+
firmwareMessage: message,
|
|
43850
|
+
});
|
|
43851
|
+
}
|
|
43852
|
+
else if (code === 'Failure_ProcessError') {
|
|
43847
43853
|
const normalizedMessage = (_a = message === null || message === void 0 ? void 0 : message.trim()) !== null && _a !== void 0 ? _a : '';
|
|
43848
43854
|
const isProtocolV2ActionCancelledFailure = this.device.isProtocolV2() && isProtocolV2ActionCancelledMessage(normalizedMessage);
|
|
43849
43855
|
const isProtocolV2DeviceBusyFailure = this.device.isProtocolV2() &&
|
|
@@ -64706,6 +64712,12 @@ class DeviceConnector {
|
|
|
64706
64712
|
}
|
|
64707
64713
|
catch (error) {
|
|
64708
64714
|
Log$2.error('acquire error: ', error.message);
|
|
64715
|
+
if (hdTransport.isProtocolV2LinkDisabledError(error)) {
|
|
64716
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.BleUnavailableWhileUsbConnected, undefined, {
|
|
64717
|
+
failureCode: error.failureCode,
|
|
64718
|
+
firmwareMessage: error.firmwareMessage,
|
|
64719
|
+
});
|
|
64720
|
+
}
|
|
64709
64721
|
safeThrowError(error);
|
|
64710
64722
|
}
|
|
64711
64723
|
});
|
|
@@ -65672,6 +65684,10 @@ const ensureConnected = (_context, method, connectId, pollingId, abortSignal) =>
|
|
|
65672
65684
|
}
|
|
65673
65685
|
catch (error) {
|
|
65674
65686
|
Log.debug('device error: ', error);
|
|
65687
|
+
if (error.errorCode === hdShared.HardwareErrorCode.BleUnavailableWhileUsbConnected) {
|
|
65688
|
+
reject(error);
|
|
65689
|
+
return;
|
|
65690
|
+
}
|
|
65675
65691
|
if (hdTransport.isProtocolV2LinkDisabledError(error)) {
|
|
65676
65692
|
reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.BleUnavailableWhileUsbConnected, undefined, {
|
|
65677
65693
|
failureCode: error.failureCode,
|
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.127",
|
|
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.127",
|
|
29
|
+
"@onekeyfe/hd-transport": "1.2.0-alpha.127",
|
|
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": "55a124eb1fb7bcdfa7890fa19947f2330d687d14"
|
|
50
50
|
}
|
package/src/core/index.ts
CHANGED
|
@@ -1079,6 +1079,10 @@ const ensureConnected = async (
|
|
|
1079
1079
|
}
|
|
1080
1080
|
} catch (error) {
|
|
1081
1081
|
Log.debug('device error: ', error);
|
|
1082
|
+
if (error.errorCode === HardwareErrorCode.BleUnavailableWhileUsbConnected) {
|
|
1083
|
+
reject(error);
|
|
1084
|
+
return;
|
|
1085
|
+
}
|
|
1082
1086
|
if (isProtocolV2LinkDisabledError(error)) {
|
|
1083
1087
|
reject(
|
|
1084
1088
|
ERRORS.TypedError(HardwareErrorCode.BleUnavailableWhileUsbConnected, undefined, {
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
type Transport,
|
|
8
8
|
type TransportCallOptions,
|
|
9
9
|
getSafeTransportLogPayload,
|
|
10
|
+
isProtocolV2LinkDisabledFailure,
|
|
10
11
|
} from '@onekeyfe/hd-transport';
|
|
11
12
|
|
|
12
13
|
import TransportManager from '../data-manager/TransportManager';
|
|
@@ -481,7 +482,7 @@ export class DeviceCommands {
|
|
|
481
482
|
if (message === 'Please confirm the BlindSign enabled') {
|
|
482
483
|
error = ERRORS.TypedError(HardwareErrorCode.BlindSignDisabled);
|
|
483
484
|
}
|
|
484
|
-
if (message === 'File already exists') {
|
|
485
|
+
if (message === 'File already exists' || message === 'NFT already exists') {
|
|
485
486
|
error = ERRORS.TypedError(HardwareErrorCode.FileAlreadyExists);
|
|
486
487
|
}
|
|
487
488
|
if (message?.includes('bytes overflow')) {
|
|
@@ -495,7 +496,12 @@ export class DeviceCommands {
|
|
|
495
496
|
}
|
|
496
497
|
}
|
|
497
498
|
|
|
498
|
-
if (code
|
|
499
|
+
if (isProtocolV2LinkDisabledFailure(code, message)) {
|
|
500
|
+
error = ERRORS.TypedError(HardwareErrorCode.BleUnavailableWhileUsbConnected, undefined, {
|
|
501
|
+
failureCode: code,
|
|
502
|
+
firmwareMessage: message,
|
|
503
|
+
});
|
|
504
|
+
} else if (code === 'Failure_ProcessError') {
|
|
499
505
|
const normalizedMessage = message?.trim() ?? '';
|
|
500
506
|
const isProtocolV2ActionCancelledFailure =
|
|
501
507
|
this.device.isProtocolV2() && isProtocolV2ActionCancelledMessage(normalizedMessage);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isProtocolV2LinkDisabledError } from '@onekeyfe/hd-transport';
|
|
1
2
|
import { ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
|
|
2
3
|
|
|
3
4
|
import { safeThrowError } from '../constants';
|
|
@@ -134,6 +135,12 @@ export default class DeviceConnector {
|
|
|
134
135
|
return res;
|
|
135
136
|
} catch (error) {
|
|
136
137
|
Log.error('acquire error: ', error.message);
|
|
138
|
+
if (isProtocolV2LinkDisabledError(error)) {
|
|
139
|
+
throw ERRORS.TypedError(HardwareErrorCode.BleUnavailableWhileUsbConnected, undefined, {
|
|
140
|
+
failureCode: error.failureCode,
|
|
141
|
+
firmwareMessage: error.firmwareMessage,
|
|
142
|
+
});
|
|
143
|
+
}
|
|
137
144
|
safeThrowError(error);
|
|
138
145
|
}
|
|
139
146
|
}
|