@onekeyfe/hd-shared 1.2.2-alpha.10 → 1.2.2-alpha.11
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/dist/HardwareError.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/package.json +2 -2
- package/src/HardwareError.test.ts +19 -0
- package/src/HardwareError.ts +5 -3
|
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAybpB,CAAC;AAEX,eAAO,MAAM,wBAAwB,EAAE,+
|
|
1
|
+
{"version":3,"file":"HardwareError.d.ts","sourceRoot":"","sources":["../src/HardwareError.ts"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AM,uCAAuC;oBAM3B,MAAM;oBACN,MAAM;;;mBAcvB,CAAC;AAEF,QAAA,MAAM,sCAAsC;oBAM1B,MAAM;oBACN,MAAM;;;mBAcvB,CAAC;AAEF,QAAA,MAAM,yCAAyC,cAClC,MAAM,GAAG,SAAS,YACnB,MAAM,GAAG,SAAS,iBACb,CAAC,UAAU,GAAG,KAAK,CAAC,EAAE,oBACnB;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"}
|
package/dist/index.js
CHANGED
|
@@ -183,7 +183,7 @@ const HardwareErrorCodeMessage = {
|
|
|
183
183
|
[HardwareErrorCode.DeviceInterruptedFromOutside]: 'Device interrupted',
|
|
184
184
|
[HardwareErrorCode.DeviceInterruptedFromUser]: 'Device interrupted',
|
|
185
185
|
[HardwareErrorCode.RequiredButInBootloaderMode]: 'Device should be in bootloader mode',
|
|
186
|
-
[HardwareErrorCode.DeviceCheckDeviceIdError]: '
|
|
186
|
+
[HardwareErrorCode.DeviceCheckDeviceIdError]: 'The connected device does not match this wallet. Reconnect the correct device, or add it again after a reset or recovery.',
|
|
187
187
|
[HardwareErrorCode.DeviceNotSupportPassphrase]: 'Device not support passphrase',
|
|
188
188
|
[HardwareErrorCode.DeviceCheckPassphraseStateError]: 'Device passphrase state error',
|
|
189
189
|
[HardwareErrorCode.DeviceNotOpenedPassphrase]: 'Device not opened passphrase',
|
|
@@ -191,7 +191,7 @@ const HardwareErrorCodeMessage = {
|
|
|
191
191
|
[HardwareErrorCode.DeviceDetectInBootloaderMode]: 'Device in bootloader mode',
|
|
192
192
|
[HardwareErrorCode.NotAllowInBootloaderMode]: 'Device not allow in bootloader mode',
|
|
193
193
|
[HardwareErrorCode.DeviceBusy]: 'Device is busy',
|
|
194
|
-
[HardwareErrorCode.DeviceCheckUnlockTypeError]: '
|
|
194
|
+
[HardwareErrorCode.DeviceCheckUnlockTypeError]: 'The unlocked wallet does not match the selected wallet. Use the corresponding PIN or passphrase and try again.',
|
|
195
195
|
[HardwareErrorCode.NotInitialized]: 'Not initialized',
|
|
196
196
|
[HardwareErrorCode.IFrameNotInitialized]: 'IFrame not initialized',
|
|
197
197
|
[HardwareErrorCode.IFrameAleradyInitialized]: 'IFrame alerady initialized',
|
|
@@ -296,6 +296,7 @@ const isBleStaleBondErrorText = (text) => {
|
|
|
296
296
|
return (value.includes('encryption is insufficient') ||
|
|
297
297
|
value.includes('insufficient encryption') ||
|
|
298
298
|
value.includes('peer removed pairing information') ||
|
|
299
|
+
value.includes('cberrordomain:14') ||
|
|
299
300
|
value.includes('gatt_insuf_authentication'));
|
|
300
301
|
};
|
|
301
302
|
const serializeError = (payload) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/hd-shared",
|
|
3
|
-
"version": "1.2.2-alpha.
|
|
3
|
+
"version": "1.2.2-alpha.11",
|
|
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": "
|
|
29
|
+
"gitHead": "8928100acb893d72361eb74422d5e2a0f7af77d8"
|
|
30
30
|
}
|
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
HardwareErrorCode,
|
|
3
3
|
HardwareErrorCodeMessage,
|
|
4
4
|
TypedError,
|
|
5
|
+
isBleStaleBondErrorText,
|
|
5
6
|
serializeError,
|
|
6
7
|
} from './HardwareError';
|
|
7
8
|
|
|
@@ -12,6 +13,15 @@ describe('HardwareErrorCode compatibility', () => {
|
|
|
12
13
|
expect(HardwareErrorCode.WalletSessionInvalid).toBe(831);
|
|
13
14
|
});
|
|
14
15
|
|
|
16
|
+
test('uses actionable wallet-context messages', () => {
|
|
17
|
+
expect(HardwareErrorCodeMessage[HardwareErrorCode.DeviceCheckDeviceIdError]).toContain(
|
|
18
|
+
'does not match this wallet'
|
|
19
|
+
);
|
|
20
|
+
expect(HardwareErrorCodeMessage[HardwareErrorCode.DeviceCheckUnlockTypeError]).toContain(
|
|
21
|
+
'corresponding PIN or passphrase'
|
|
22
|
+
);
|
|
23
|
+
});
|
|
24
|
+
|
|
15
25
|
test('reserves the BLE and USB conflict code for app error mapping', () => {
|
|
16
26
|
expect(HardwareErrorCode.BleUnavailableWhileUsbConnected).toBe(723);
|
|
17
27
|
expect(HardwareErrorCodeMessage[HardwareErrorCode.BleUnavailableWhileUsbConnected]).toBe(
|
|
@@ -33,4 +43,13 @@ describe('HardwareErrorCode compatibility', () => {
|
|
|
33
43
|
},
|
|
34
44
|
});
|
|
35
45
|
});
|
|
46
|
+
|
|
47
|
+
test('recognizes the macOS CoreBluetooth stale-pairing error without matching generic failures', () => {
|
|
48
|
+
expect(
|
|
49
|
+
isBleStaleBondErrorText(
|
|
50
|
+
'CBErrorDomain:14 Peer removed pairing information on the device side'
|
|
51
|
+
)
|
|
52
|
+
).toBe(true);
|
|
53
|
+
expect(isBleStaleBondErrorText('connection failed')).toBe(false);
|
|
54
|
+
});
|
|
36
55
|
});
|
package/src/HardwareError.ts
CHANGED
|
@@ -534,7 +534,8 @@ export const HardwareErrorCodeMessage: HardwareErrorCodeMessageMapping = {
|
|
|
534
534
|
[HardwareErrorCode.DeviceInterruptedFromOutside]: 'Device interrupted',
|
|
535
535
|
[HardwareErrorCode.DeviceInterruptedFromUser]: 'Device interrupted',
|
|
536
536
|
[HardwareErrorCode.RequiredButInBootloaderMode]: 'Device should be in bootloader mode',
|
|
537
|
-
[HardwareErrorCode.DeviceCheckDeviceIdError]:
|
|
537
|
+
[HardwareErrorCode.DeviceCheckDeviceIdError]:
|
|
538
|
+
'The connected device does not match this wallet. Reconnect the correct device, or add it again after a reset or recovery.',
|
|
538
539
|
[HardwareErrorCode.DeviceNotSupportPassphrase]: 'Device not support passphrase',
|
|
539
540
|
[HardwareErrorCode.DeviceCheckPassphraseStateError]: 'Device passphrase state error',
|
|
540
541
|
[HardwareErrorCode.DeviceNotOpenedPassphrase]: 'Device not opened passphrase',
|
|
@@ -542,7 +543,8 @@ export const HardwareErrorCodeMessage: HardwareErrorCodeMessageMapping = {
|
|
|
542
543
|
[HardwareErrorCode.DeviceDetectInBootloaderMode]: 'Device in bootloader mode',
|
|
543
544
|
[HardwareErrorCode.NotAllowInBootloaderMode]: 'Device not allow in bootloader mode',
|
|
544
545
|
[HardwareErrorCode.DeviceBusy]: 'Device is busy',
|
|
545
|
-
[HardwareErrorCode.DeviceCheckUnlockTypeError]:
|
|
546
|
+
[HardwareErrorCode.DeviceCheckUnlockTypeError]:
|
|
547
|
+
'The unlocked wallet does not match the selected wallet. Use the corresponding PIN or passphrase and try again.',
|
|
546
548
|
/**
|
|
547
549
|
* Node Errors
|
|
548
550
|
*/
|
|
@@ -660,7 +662,6 @@ export const HardwareErrorCodeMessage: HardwareErrorCodeMessageMapping = {
|
|
|
660
662
|
[HardwareErrorCode.WalletSessionInvalid]: 'Wallet session is invalid or expired',
|
|
661
663
|
[HardwareErrorCode.NftStorageLimitReached]:
|
|
662
664
|
'NFT storage limit reached. Remove an NFT from the device and try again.',
|
|
663
|
-
|
|
664
665
|
/**
|
|
665
666
|
* Lowlevel transport
|
|
666
667
|
*/
|
|
@@ -696,6 +697,7 @@ export const isBleStaleBondErrorText = (text: string): boolean => {
|
|
|
696
697
|
value.includes('encryption is insufficient') ||
|
|
697
698
|
value.includes('insufficient encryption') ||
|
|
698
699
|
value.includes('peer removed pairing information') ||
|
|
700
|
+
value.includes('cberrordomain:14') ||
|
|
699
701
|
value.includes('gatt_insuf_authentication')
|
|
700
702
|
);
|
|
701
703
|
};
|