@onekeyfe/hd-shared 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.
@@ -63,6 +63,8 @@ export declare const HardwareErrorCode: {
63
63
  readonly TransportCallInProgress: 601;
64
64
  readonly TransportNotFound: 602;
65
65
  readonly TransportInvalidProtobuf: 603;
66
+ readonly TransportProtocolProbeFailed: 604;
67
+ readonly TransportProtocolMismatch: 605;
66
68
  readonly BleScanError: 700;
67
69
  readonly BlePermissionError: 701;
68
70
  readonly BleLocationError: 702;
@@ -1 +1 @@
1
- {"version":3,"file":"HardwareError.d.ts","sourceRoot":"","sources":["../src/HardwareError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,OAAO,CAAC,OAAO,iBAAiB,CAAC,CAAC;IAC7C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,GAAG,CAAC;CACd;AAED,KAAK,OAAO,CAAC,CAAC,SAAS,MAAM,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAE5C,KAAK,+BAA+B,GAAG;KAAG,CAAC,IAAI,OAAO,CAAC,OAAO,iBAAiB,CAAC,GAAG,MAAM;CAAE,CAAC;AAE5F,KAAK,cAAc,GAAG,OAAO,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAsCxD,qBAAa,aAAc,SAAQ,KAAK;IACtC,SAAS,EAAE,cAAc,CAAkC;IAE3D,OAAO,SAAM;IAEb,MAAM,EAAE,GAAG,CAAM;gBAEL,aAAa,EAAE,cAAc,GAAG,MAAM;CAmBnD;AAED,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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B;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,kBAsBF,CAAC;AAEF,QAAA,MAAM,6BAA6B,mBACjB,MAAM,qBACH,MAAM,eACZ,MAAM,kBAQpB,CAAC;AAEF,QAAA,MAAM,4BAA4B,aACtB,MAAM,aACL,MAAM,cACL,MAAM,cACN,MAAM,aACP,MAAM,kBAWlB,CAAC;AAEF,QAAA,MAAM,iCAAiC,eAAgB,MAAM,gBAAgB,aAAa,kBAItF,CAAC;AAEL,OAAO,EACL,uCAAuC,EACvC,sCAAsC,EACtC,yCAAyC,EACzC,6BAA6B,EAC7B,4BAA4B,EAC5B,iCAAiC,GAClC,CAAC"}
@@ -18,8 +18,8 @@ type WebUsbIdentityDescriptor = {
18
18
  manufacturerName?: string | null;
19
19
  };
20
20
  export declare const isKnownTrezorWebUsbDevice: (descriptor: WebUsbIdentityDescriptor) => boolean;
21
- export declare const ERROR_CODES_REQUIRE_RELEASE: readonly [903, 106, 107, 109, 112, 805, 801, 802, 812];
22
- export declare const ERROR_CODES_REQUIRE_DISCONNECT: readonly [903, 106, 805];
21
+ export declare const ERROR_CODES_REQUIRE_RELEASE: readonly [903, 604, 605, 106, 107, 109, 112, 805, 801, 802, 812];
22
+ export declare const ERROR_CODES_REQUIRE_DISCONNECT: readonly [903, 604, 605, 106, 805];
23
23
  export declare enum EOneKeyBleMessageKeys {
24
24
  BLE_SELECT = "$onekey-ble-select",
25
25
  BLE_SELECT_RESULT = "$onekey-ble-select-result",
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";AAEA,eAAO,MAAM,yBAAyB;;;CAG5B,CAAC;AAEX,MAAM,MAAM,uBAAuB,GACjC,CAAC,OAAO,yBAAyB,CAAC,CAAC,MAAM,OAAO,yBAAyB,CAAC,CAAC;AAE7E,eAAO,MAAM,oBAAoB;;;GAOhC,CAAC;AAGF,eAAO,M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;AAEF,eAAO,MAAM,mBAAmB,eAClB,MAAM,GAAG,IAAI,GAAG,SAAS,WAC5B,YAAY,MAAM,CAAC,YACgB,CAAC;AAmC/C,eAAO,MAAM,6BAA6B,WAAY,MAAM,GAAG,IAAI,YAWlE,CAAC;AAEF,eAAO,MAAM,oCAAoC,UAAW,MAAM,WAejE,CAAC;AAUF,eAAO,MAAM,oCAAoC,UAAW,MAAM,WAWjE,CAAC;AAEF,eAAO,MAAM,mBAAmB,UAAW,MAAM,GAAG,IAAI,UAAU,MAAM,GAAG,IAAI,YAO9E,CAAC;AAEF,eAAO,MAAM,6BAA6B,iBAC1B,MAAM,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,GAAG,IAAI,GAAG,SAAS,YAIhE,CAAC;AAOJ,eAAO,MAAM,mBAAmB,WAAY,MAAM,GAAG,IAAI,KAAG,OAiB3D,CAAC;AAEF,eAAO,MAAM,uBAAuB,2CAKjC,uBAAuB,KAAG,OAiB5B,CAAC"}
package/dist/index.d.ts CHANGED
@@ -22,12 +22,12 @@ declare const isKnownTrezorWebUsbDevice: (descriptor: WebUsbIdentityDescriptor)
22
22
  * Error codes that require device release after occurrence
23
23
  * These errors indicate the device is in an invalid state and needs to be released
24
24
  */
25
- declare const ERROR_CODES_REQUIRE_RELEASE: readonly [903, 106, 107, 109, 112, 805, 801, 802, 812];
25
+ declare const ERROR_CODES_REQUIRE_RELEASE: readonly [903, 604, 605, 106, 107, 109, 112, 805, 801, 802, 812];
26
26
  /**
27
27
  * Error codes that require device disconnect before release
28
28
  * These errors indicate a communication failure that requires full reconnection
29
29
  */
30
- declare const ERROR_CODES_REQUIRE_DISCONNECT: readonly [903, 106, 805];
30
+ declare const ERROR_CODES_REQUIRE_DISCONNECT: readonly [903, 604, 605, 106, 805];
31
31
  declare enum EOneKeyBleMessageKeys {
32
32
  BLE_SELECT = "$onekey-ble-select",
33
33
  BLE_SELECT_RESULT = "$onekey-ble-select-result",
@@ -334,6 +334,16 @@ declare const HardwareErrorCode: {
334
334
  * Transport invalid protobuf
335
335
  */
336
336
  readonly TransportInvalidProtobuf: 603;
337
+ /**
338
+ * No supported device protocol answered the active probe.
339
+ * @params: { expectedProtocol?: 'V1' | 'V2'; attempts?: number }
340
+ */
341
+ readonly TransportProtocolProbeFailed: 604;
342
+ /**
343
+ * The actively detected device protocol differs from the required protocol.
344
+ * @params: { expectedProtocol: 'V1' | 'V2'; detectedProtocol?: 'V1' | 'V2' }
345
+ */
346
+ readonly TransportProtocolMismatch: 605;
337
347
  /**
338
348
  * Bluetooth error code
339
349
  */
package/dist/index.js CHANGED
@@ -112,6 +112,8 @@ const HardwareErrorCode = {
112
112
  TransportCallInProgress: 601,
113
113
  TransportNotFound: 602,
114
114
  TransportInvalidProtobuf: 603,
115
+ TransportProtocolProbeFailed: 604,
116
+ TransportProtocolMismatch: 605,
115
117
  BleScanError: 700,
116
118
  BlePermissionError: 701,
117
119
  BleLocationError: 702,
@@ -222,6 +224,8 @@ const HardwareErrorCodeMessage = {
222
224
  [HardwareErrorCode.TransportCallInProgress]: 'Transport call in progress',
223
225
  [HardwareErrorCode.TransportNotFound]: 'Transport not found',
224
226
  [HardwareErrorCode.TransportInvalidProtobuf]: 'Transport invalid protobuf',
227
+ [HardwareErrorCode.TransportProtocolProbeFailed]: 'Failed to detect the device communication protocol. Reconnect the device and try again.',
228
+ [HardwareErrorCode.TransportProtocolMismatch]: 'The device communication protocol does not match the expected protocol.',
225
229
  [HardwareErrorCode.BleScanError]: 'BLE scan error',
226
230
  [HardwareErrorCode.BlePermissionError]: 'Bluetooth required to be turned on',
227
231
  [HardwareErrorCode.BleLocationError]: 'Bluetooth or location permissions for the application are not available',
@@ -415,6 +419,8 @@ const isKnownTrezorWebUsbDevice = (descriptor) => {
415
419
  };
416
420
  const ERROR_CODES_REQUIRE_RELEASE = [
417
421
  HardwareErrorCode.WebUsbDeviceAccessError,
422
+ HardwareErrorCode.TransportProtocolProbeFailed,
423
+ HardwareErrorCode.TransportProtocolMismatch,
418
424
  HardwareErrorCode.DeviceInitializeFailed,
419
425
  HardwareErrorCode.DeviceInterruptedFromOutside,
420
426
  HardwareErrorCode.DeviceInterruptedFromUser,
@@ -426,6 +432,8 @@ const ERROR_CODES_REQUIRE_RELEASE = [
426
432
  ];
427
433
  const ERROR_CODES_REQUIRE_DISCONNECT = [
428
434
  HardwareErrorCode.WebUsbDeviceAccessError,
435
+ HardwareErrorCode.TransportProtocolProbeFailed,
436
+ HardwareErrorCode.TransportProtocolMismatch,
429
437
  HardwareErrorCode.DeviceInitializeFailed,
430
438
  HardwareErrorCode.ResponseUnexpectTypeError,
431
439
  ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/hd-shared",
3
- "version": "1.2.8-alpha.52",
3
+ "version": "1.2.8-alpha.53",
4
4
  "description": "Hardware SDK's shared tool library",
5
5
  "keywords": [
6
6
  "Hardware-SDK",
@@ -26,5 +26,5 @@
26
26
  "lint": "eslint .",
27
27
  "lint:fix": "eslint . --fix"
28
28
  },
29
- "gitHead": "389c588beb19de26451c729bb09bc8e7ce6b0717"
29
+ "gitHead": "8b628967c6057e743ffe0d5fa8a8d2120e64c5e3"
30
30
  }
@@ -4,8 +4,23 @@ import {
4
4
  TypedError,
5
5
  serializeError,
6
6
  } from './HardwareError';
7
+ import { ERROR_CODES_REQUIRE_DISCONNECT, ERROR_CODES_REQUIRE_RELEASE } from './constants';
7
8
 
8
9
  describe('HardwareErrorCode compatibility', () => {
10
+ test.each([
11
+ ['TransportProtocolProbeFailed', 604, { expectedProtocol: 'V1' }],
12
+ ['TransportProtocolMismatch', 605, { expectedProtocol: 'V2', detectedProtocol: 'V1' }],
13
+ ] as const)('serializes the dedicated %s transport error', (name, code, params) => {
14
+ expect(HardwareErrorCode[name]).toBe(code);
15
+ const message = HardwareErrorCodeMessage[HardwareErrorCode[name]];
16
+ expect(message).toBeTruthy();
17
+ expect(ERROR_CODES_REQUIRE_RELEASE).toContain(code);
18
+ expect(ERROR_CODES_REQUIRE_DISCONNECT).toContain(code);
19
+ expect(
20
+ JSON.parse(JSON.stringify(serializeError({ error: TypedError(code, undefined, params) })))
21
+ ).toEqual({ code, error: message, params });
22
+ });
23
+
9
24
  test('preserves published Protocol V2 values while leaving code 829 unused', () => {
10
25
  expect(HardwareErrorCode).not.toHaveProperty('KaspaPrevTxIdMismatch');
11
26
  expect(HardwareErrorCode.DeviceLocked).toBe(830);
@@ -319,6 +319,18 @@ export const HardwareErrorCode = {
319
319
  */
320
320
  TransportInvalidProtobuf: 603,
321
321
 
322
+ /**
323
+ * No supported device protocol answered the active probe.
324
+ * @params: { expectedProtocol?: 'V1' | 'V2'; attempts?: number }
325
+ */
326
+ TransportProtocolProbeFailed: 604,
327
+
328
+ /**
329
+ * The actively detected device protocol differs from the required protocol.
330
+ * @params: { expectedProtocol: 'V1' | 'V2'; detectedProtocol?: 'V1' | 'V2' }
331
+ */
332
+ TransportProtocolMismatch: 605,
333
+
322
334
  /**
323
335
  * Bluetooth error code
324
336
  */
@@ -605,6 +617,10 @@ export const HardwareErrorCodeMessage: HardwareErrorCodeMessageMapping = {
605
617
  [HardwareErrorCode.TransportCallInProgress]: 'Transport call in progress',
606
618
  [HardwareErrorCode.TransportNotFound]: 'Transport not found',
607
619
  [HardwareErrorCode.TransportInvalidProtobuf]: 'Transport invalid protobuf',
620
+ [HardwareErrorCode.TransportProtocolProbeFailed]:
621
+ 'Failed to detect the device communication protocol. Reconnect the device and try again.',
622
+ [HardwareErrorCode.TransportProtocolMismatch]:
623
+ 'The device communication protocol does not match the expected protocol.',
608
624
 
609
625
  /**
610
626
  * Bluetooth Error
package/src/constants.ts CHANGED
@@ -44,6 +44,8 @@ export const isKnownTrezorWebUsbDevice = (descriptor: WebUsbIdentityDescriptor):
44
44
  */
45
45
  export const ERROR_CODES_REQUIRE_RELEASE = [
46
46
  HardwareErrorCode.WebUsbDeviceAccessError,
47
+ HardwareErrorCode.TransportProtocolProbeFailed,
48
+ HardwareErrorCode.TransportProtocolMismatch,
47
49
  HardwareErrorCode.DeviceInitializeFailed,
48
50
  HardwareErrorCode.DeviceInterruptedFromOutside,
49
51
  HardwareErrorCode.DeviceInterruptedFromUser,
@@ -60,6 +62,8 @@ export const ERROR_CODES_REQUIRE_RELEASE = [
60
62
  */
61
63
  export const ERROR_CODES_REQUIRE_DISCONNECT = [
62
64
  HardwareErrorCode.WebUsbDeviceAccessError,
65
+ HardwareErrorCode.TransportProtocolProbeFailed,
66
+ HardwareErrorCode.TransportProtocolMismatch,
63
67
  HardwareErrorCode.DeviceInitializeFailed,
64
68
  HardwareErrorCode.ResponseUnexpectTypeError,
65
69
  ] as const;