@onekeyfe/hd-shared 1.2.0-alpha.67 → 1.2.0-alpha.69
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 +1 -1
- package/dist/HardwareError.d.ts.map +1 -1
- package/dist/constants.d.ts +2 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/deviceType.d.ts +2 -1
- package/dist/deviceType.d.ts.map +1 -1
- package/dist/index.d.ts +10 -6
- package/dist/index.js +15 -7
- package/package.json +2 -2
- package/src/HardwareError.test.ts +2 -2
- package/src/HardwareError.ts +8 -6
- package/src/constants.test.ts +25 -4
- package/src/constants.ts +13 -7
- package/src/deviceType.ts +1 -0
package/dist/HardwareError.d.ts
CHANGED
|
@@ -115,9 +115,9 @@ export declare const HardwareErrorCode: {
|
|
|
115
115
|
readonly DeviceSettingsLanguageNotSupport: 826;
|
|
116
116
|
readonly TooManyInputs: 827;
|
|
117
117
|
readonly PinMismatch: 828;
|
|
118
|
-
readonly KaspaPrevTxIdMismatch: 829;
|
|
119
118
|
readonly DeviceLocked: 830;
|
|
120
119
|
readonly WalletSessionInvalid: 831;
|
|
120
|
+
readonly NftStorageLimitReached: 832;
|
|
121
121
|
readonly LowlevelTrasnportConnectError: 900;
|
|
122
122
|
readonly WebDeviceNotFoundOrNeedsPermission: 901;
|
|
123
123
|
readonly WebDevicePromptAccessError: 902;
|
|
@@ -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,M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OneKeyBleMessageKeys {
|
|
|
38
38
|
NOBLE_BLE_SUBSCRIBE = "$onekey-noble-ble-subscribe",
|
|
39
39
|
NOBLE_BLE_UNSUBSCRIBE = "$onekey-noble-ble-unsubscribe",
|
|
40
40
|
NOBLE_BLE_NOTIFICATION = "$onekey-noble-ble-notification",
|
|
41
|
+
NOBLE_BLE_MTU_CHANGED = "$onekey-noble-ble-mtu-changed",
|
|
41
42
|
NOBLE_BLE_CANCEL_PAIRING = "$onekey-noble-ble-cancel-pairing"
|
|
42
43
|
}
|
|
43
44
|
export declare const ONEKEY_SERVICE_UUID = "00000001-0000-1000-8000-00805f9b34fb";
|
|
@@ -54,6 +55,7 @@ type BluetoothDeviceIdentity = {
|
|
|
54
55
|
export declare const normalizeBleUuid: (uuid?: string | null) => string;
|
|
55
56
|
export declare const createKnownBleUuidAliases: (uuid: string) => ReadonlySet<string>;
|
|
56
57
|
export declare const matchesKnownBleUuid: (actualUuid: string | null | undefined, aliases: ReadonlySet<string>) => boolean;
|
|
58
|
+
export declare const isPro2FindMyAdvertisementName: (value?: string | null) => boolean;
|
|
57
59
|
export declare const hasOnekeyCommunicationService: (serviceUuids: Array<string | null | undefined> | null | undefined) => boolean;
|
|
58
60
|
export declare const isOnekeyBluetoothDevice: ({ id, name, localName, serviceUuids, }: BluetoothDeviceIdentity) => boolean;
|
|
59
61
|
export {};
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -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;AAEF,KAAK,wBAAwB,GAAG;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAA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,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,YAAY,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,GAAG,IAAI,CAAC;CACxD,CAAC;AAIF,eAAO,MAAM,gBAAgB,UAAW,MAAM,GAAG,IAAI,WACP,CAAC;AAE/C,eAAO,MAAM,yBAAyB,SAAU,MAAM,KAAG,YAAY,MAAM,CAc1E,CAAC;AAEF,eAAO,MAAM,mBAAmB,eAClB,MAAM,GAAG,IAAI,GAAG,SAAS,WAC5B,YAAY,MAAM,CAAC,YACgB,CAAC;AAK/C,eAAO,MAAM,6BAA6B,WAAY,MAAM,GAAG,IAAI,YAGlE,CAAC;AAEF,eAAO,MAAM,6BAA6B,iBAC1B,MAAM,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,GAAG,IAAI,GAAG,SAAS,YAIhE,CAAC;AAEJ,eAAO,MAAM,uBAAuB,2CAKjC,uBAAuB,KAAG,OAiB5B,CAAC"}
|
package/dist/deviceType.d.ts
CHANGED
package/dist/deviceType.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deviceType.d.ts","sourceRoot":"","sources":["../src/deviceType.ts"],"names":[],"mappings":"AAAA,oBAAY,WAAW;IACrB,OAAO,YAAY;IACnB,OAAO,YAAY;IACnB,SAAS,cAAc;IACvB,WAAW,gBAAgB;IAC3B,IAAI,SAAS;IACb,KAAK,UAAU;IACf,GAAG,QAAQ;IACX,IAAI,SAAS;
|
|
1
|
+
{"version":3,"file":"deviceType.d.ts","sourceRoot":"","sources":["../src/deviceType.ts"],"names":[],"mappings":"AAAA,oBAAY,WAAW;IACrB,OAAO,YAAY;IACnB,OAAO,YAAY;IACnB,SAAS,cAAc;IACvB,WAAW,gBAAgB;IAC3B,IAAI,SAAS;IACb,KAAK,UAAU;IACf,GAAG,QAAQ;IACX,IAAI,SAAS;IACb,GAAG,QAAQ;CACZ"}
|
package/dist/index.d.ts
CHANGED
|
@@ -45,6 +45,7 @@ declare enum EOneKeyBleMessageKeys {
|
|
|
45
45
|
NOBLE_BLE_SUBSCRIBE = "$onekey-noble-ble-subscribe",
|
|
46
46
|
NOBLE_BLE_UNSUBSCRIBE = "$onekey-noble-ble-unsubscribe",
|
|
47
47
|
NOBLE_BLE_NOTIFICATION = "$onekey-noble-ble-notification",
|
|
48
|
+
NOBLE_BLE_MTU_CHANGED = "$onekey-noble-ble-mtu-changed",
|
|
48
49
|
NOBLE_BLE_CANCEL_PAIRING = "$onekey-noble-ble-cancel-pairing"
|
|
49
50
|
}
|
|
50
51
|
declare const ONEKEY_SERVICE_UUID = "00000001-0000-1000-8000-00805f9b34fb";
|
|
@@ -61,6 +62,7 @@ type BluetoothDeviceIdentity = {
|
|
|
61
62
|
declare const normalizeBleUuid: (uuid?: string | null) => string;
|
|
62
63
|
declare const createKnownBleUuidAliases: (uuid: string) => ReadonlySet<string>;
|
|
63
64
|
declare const matchesKnownBleUuid: (actualUuid: string | null | undefined, aliases: ReadonlySet<string>) => boolean;
|
|
65
|
+
declare const isPro2FindMyAdvertisementName: (value?: string | null) => boolean;
|
|
64
66
|
declare const hasOnekeyCommunicationService: (serviceUuids: Array<string | null | undefined> | null | undefined) => boolean;
|
|
65
67
|
declare const isOnekeyBluetoothDevice: ({ id, name, localName, serviceUuids, }: BluetoothDeviceIdentity) => boolean;
|
|
66
68
|
|
|
@@ -425,10 +427,6 @@ declare const HardwareErrorCode: {
|
|
|
425
427
|
* The two PIN entries did not match while setting/changing PIN on device
|
|
426
428
|
*/
|
|
427
429
|
readonly PinMismatch: 828;
|
|
428
|
-
/**
|
|
429
|
-
* Device refused to sign: refTxs don't match the spent input's outpoint
|
|
430
|
-
*/
|
|
431
|
-
readonly KaspaPrevTxIdMismatch: 829;
|
|
432
430
|
/**
|
|
433
431
|
* Protocol V2 device must be unlocked before the requested operation.
|
|
434
432
|
* @params: { failureCode?: string; subcode?: number; firmwareMessage?: string }
|
|
@@ -439,6 +437,11 @@ declare const HardwareErrorCode: {
|
|
|
439
437
|
* @params: { failureCode?: string; subcode?: number; firmwareMessage?: string }
|
|
440
438
|
*/
|
|
441
439
|
readonly WalletSessionInvalid: 831;
|
|
440
|
+
/**
|
|
441
|
+
* Pro2 NFT storage has reached its item limit.
|
|
442
|
+
* @params: { count: number; limit: number }
|
|
443
|
+
*/
|
|
444
|
+
readonly NftStorageLimitReached: 832;
|
|
442
445
|
/**
|
|
443
446
|
* Lowlevel transport connect error
|
|
444
447
|
*/
|
|
@@ -521,7 +524,8 @@ declare enum EDeviceType {
|
|
|
521
524
|
Mini = "mini",
|
|
522
525
|
Touch = "touch",
|
|
523
526
|
Pro = "pro",
|
|
524
|
-
Pro2 = "pro2"
|
|
527
|
+
Pro2 = "pro2",
|
|
528
|
+
Neo = "neo"
|
|
525
529
|
}
|
|
526
530
|
|
|
527
|
-
export { CreateErrorByMessage, CreateHardwareErrorByBridgeError, Deferred, EDeviceType, EFirmwareType, EOneKeyBleMessageKeys, HardwareError$1 as ERRORS, ERROR_CODES_REQUIRE_DISCONNECT, ERROR_CODES_REQUIRE_RELEASE, HARDWARE_CONNECT_PROTOCOL, HardwareConnectProtocol, HardwareError, HardwareErrorCode, HardwareErrorCodeMessage, IHardwareError, ONEKEY_NOTIFY_CHARACTERISTIC_UUID, ONEKEY_SERVICE_UUID, ONEKEY_WEBUSB_FILTER, ONEKEY_WRITE_CHARACTERISTIC_UUID, TypedError, createDefectiveFirmwareError, createDeferred, createDeprecatedHardwareError, createDeviceNotSupportMethodError, createKnownBleUuidAliases, createNeedUpgradeFirmwareHardwareError, createNewFirmwareForceUpdateHardwareError, createNewFirmwareUnReleaseHardwareError, hasOnekeyCommunicationService, isHeaderChunk, isKnownTrezorWebUsbDevice, isOnekeyBluetoothDevice, isOnekeyDevice, matchesKnownBleUuid, normalizeBleUuid, serializeError, wait };
|
|
531
|
+
export { CreateErrorByMessage, CreateHardwareErrorByBridgeError, Deferred, EDeviceType, EFirmwareType, EOneKeyBleMessageKeys, HardwareError$1 as ERRORS, ERROR_CODES_REQUIRE_DISCONNECT, ERROR_CODES_REQUIRE_RELEASE, HARDWARE_CONNECT_PROTOCOL, HardwareConnectProtocol, HardwareError, HardwareErrorCode, HardwareErrorCodeMessage, IHardwareError, ONEKEY_NOTIFY_CHARACTERISTIC_UUID, ONEKEY_SERVICE_UUID, ONEKEY_WEBUSB_FILTER, ONEKEY_WRITE_CHARACTERISTIC_UUID, TypedError, createDefectiveFirmwareError, createDeferred, createDeprecatedHardwareError, createDeviceNotSupportMethodError, createKnownBleUuidAliases, createNeedUpgradeFirmwareHardwareError, createNewFirmwareForceUpdateHardwareError, createNewFirmwareUnReleaseHardwareError, hasOnekeyCommunicationService, isHeaderChunk, isKnownTrezorWebUsbDevice, isOnekeyBluetoothDevice, isOnekeyDevice, isPro2FindMyAdvertisementName, matchesKnownBleUuid, normalizeBleUuid, serializeError, wait };
|
package/dist/index.js
CHANGED
|
@@ -164,9 +164,9 @@ const HardwareErrorCode = {
|
|
|
164
164
|
DeviceSettingsLanguageNotSupport: 826,
|
|
165
165
|
TooManyInputs: 827,
|
|
166
166
|
PinMismatch: 828,
|
|
167
|
-
KaspaPrevTxIdMismatch: 829,
|
|
168
167
|
DeviceLocked: 830,
|
|
169
168
|
WalletSessionInvalid: 831,
|
|
169
|
+
NftStorageLimitReached: 832,
|
|
170
170
|
LowlevelTrasnportConnectError: 900,
|
|
171
171
|
WebDeviceNotFoundOrNeedsPermission: 901,
|
|
172
172
|
WebDevicePromptAccessError: 902,
|
|
@@ -272,8 +272,8 @@ const HardwareErrorCodeMessage = {
|
|
|
272
272
|
[HardwareErrorCode.TooManyInputs]: 'Too many inputs',
|
|
273
273
|
[HardwareErrorCode.PinMismatch]: 'PIN mismatch',
|
|
274
274
|
[HardwareErrorCode.DeviceLocked]: 'Device locked',
|
|
275
|
-
[HardwareErrorCode.KaspaPrevTxIdMismatch]: 'Kaspa previous transaction id mismatch',
|
|
276
275
|
[HardwareErrorCode.WalletSessionInvalid]: 'Wallet session is invalid or expired',
|
|
276
|
+
[HardwareErrorCode.NftStorageLimitReached]: 'NFT storage limit reached. Remove an NFT from the device and try again.',
|
|
277
277
|
[HardwareErrorCode.LowlevelTrasnportConnectError]: 'Lowlevel transport connect error',
|
|
278
278
|
[HardwareErrorCode.WebDeviceNotFoundOrNeedsPermission]: 'Web-USB or Web-Bluetooth device not found or needs permission',
|
|
279
279
|
[HardwareErrorCode.WebDevicePromptAccessError]: 'Web-USB or Web-Bluetooth device prompt access error',
|
|
@@ -443,6 +443,7 @@ exports.EOneKeyBleMessageKeys = void 0;
|
|
|
443
443
|
EOneKeyBleMessageKeys["NOBLE_BLE_SUBSCRIBE"] = "$onekey-noble-ble-subscribe";
|
|
444
444
|
EOneKeyBleMessageKeys["NOBLE_BLE_UNSUBSCRIBE"] = "$onekey-noble-ble-unsubscribe";
|
|
445
445
|
EOneKeyBleMessageKeys["NOBLE_BLE_NOTIFICATION"] = "$onekey-noble-ble-notification";
|
|
446
|
+
EOneKeyBleMessageKeys["NOBLE_BLE_MTU_CHANGED"] = "$onekey-noble-ble-mtu-changed";
|
|
446
447
|
EOneKeyBleMessageKeys["NOBLE_BLE_CANCEL_PAIRING"] = "$onekey-noble-ble-cancel-pairing";
|
|
447
448
|
})(exports.EOneKeyBleMessageKeys || (exports.EOneKeyBleMessageKeys = {}));
|
|
448
449
|
const ONEKEY_SERVICE_UUID = '00000001-0000-1000-8000-00805f9b34fb';
|
|
@@ -491,7 +492,8 @@ const isOnekeyDevice = (name, id) => {
|
|
|
491
492
|
return true;
|
|
492
493
|
if (normalizedName.startsWith('touch ') ||
|
|
493
494
|
normalizedName.startsWith('pro ') ||
|
|
494
|
-
normalizedName.startsWith('pro2 ')
|
|
495
|
+
normalizedName.startsWith('pro2 ') ||
|
|
496
|
+
normalizedName.startsWith('neo ')) {
|
|
495
497
|
return true;
|
|
496
498
|
}
|
|
497
499
|
return isOneKeyShortName(normalizedName);
|
|
@@ -514,16 +516,20 @@ const createKnownBleUuidAliases = (uuid) => {
|
|
|
514
516
|
const matchesKnownBleUuid = (actualUuid, aliases) => aliases.has(normalizeBleUuid(actualUuid));
|
|
515
517
|
const ONEKEY_COMMUNICATION_SERVICE_ALIASES = createKnownBleUuidAliases(ONEKEY_SERVICE_UUID);
|
|
516
518
|
const FIDO_SERVICE_ALIASES = createKnownBleUuidAliases('0000fffd-0000-1000-8000-00805f9b34fb');
|
|
517
|
-
const
|
|
519
|
+
const isPro2FindMyAdvertisementName = (value) => {
|
|
520
|
+
var _a;
|
|
521
|
+
const normalizedName = (_a = value === null || value === void 0 ? void 0 : value.trim().toLowerCase()) !== null && _a !== void 0 ? _a : '';
|
|
522
|
+
return /\bpro\s*2\b/.test(normalizedName) && /\bfinde?\s+my\b/.test(normalizedName);
|
|
523
|
+
};
|
|
518
524
|
const hasOnekeyCommunicationService = (serviceUuids) => (serviceUuids !== null && serviceUuids !== void 0 ? serviceUuids : []).some(uuid => matchesKnownBleUuid(uuid, ONEKEY_COMMUNICATION_SERVICE_ALIASES));
|
|
519
525
|
const isOnekeyBluetoothDevice = ({ id, name, localName, serviceUuids, }) => {
|
|
520
526
|
const advertisedServiceUuids = serviceUuids !== null && serviceUuids !== void 0 ? serviceUuids : [];
|
|
521
|
-
if (isFindMyAdvertisementName(name) || isFindMyAdvertisementName(localName)) {
|
|
522
|
-
return false;
|
|
523
|
-
}
|
|
524
527
|
if (hasOnekeyCommunicationService(advertisedServiceUuids)) {
|
|
525
528
|
return true;
|
|
526
529
|
}
|
|
530
|
+
if (isPro2FindMyAdvertisementName(name) || isPro2FindMyAdvertisementName(localName)) {
|
|
531
|
+
return false;
|
|
532
|
+
}
|
|
527
533
|
if (advertisedServiceUuids.some(uuid => matchesKnownBleUuid(uuid, FIDO_SERVICE_ALIASES))) {
|
|
528
534
|
return false;
|
|
529
535
|
}
|
|
@@ -601,6 +607,7 @@ exports.EDeviceType = void 0;
|
|
|
601
607
|
EDeviceType["Touch"] = "touch";
|
|
602
608
|
EDeviceType["Pro"] = "pro";
|
|
603
609
|
EDeviceType["Pro2"] = "pro2";
|
|
610
|
+
EDeviceType["Neo"] = "neo";
|
|
604
611
|
})(exports.EDeviceType || (exports.EDeviceType = {}));
|
|
605
612
|
|
|
606
613
|
exports.CreateErrorByMessage = CreateErrorByMessage;
|
|
@@ -630,6 +637,7 @@ exports.isHeaderChunk = isHeaderChunk;
|
|
|
630
637
|
exports.isKnownTrezorWebUsbDevice = isKnownTrezorWebUsbDevice;
|
|
631
638
|
exports.isOnekeyBluetoothDevice = isOnekeyBluetoothDevice;
|
|
632
639
|
exports.isOnekeyDevice = isOnekeyDevice;
|
|
640
|
+
exports.isPro2FindMyAdvertisementName = isPro2FindMyAdvertisementName;
|
|
633
641
|
exports.matchesKnownBleUuid = matchesKnownBleUuid;
|
|
634
642
|
exports.normalizeBleUuid = normalizeBleUuid;
|
|
635
643
|
exports.serializeError = serializeError;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/hd-shared",
|
|
3
|
-
"version": "1.2.0-alpha.
|
|
3
|
+
"version": "1.2.0-alpha.69",
|
|
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": "c6baed25917e3c3f027f83dfc23cde85400de558"
|
|
30
30
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { HardwareErrorCode } from './HardwareError';
|
|
2
2
|
|
|
3
3
|
describe('HardwareErrorCode compatibility', () => {
|
|
4
|
-
test('preserves published values
|
|
5
|
-
expect(HardwareErrorCode
|
|
4
|
+
test('preserves published Protocol V2 values while leaving code 829 unused', () => {
|
|
5
|
+
expect(HardwareErrorCode).not.toHaveProperty('KaspaPrevTxIdMismatch');
|
|
6
6
|
expect(HardwareErrorCode.DeviceLocked).toBe(830);
|
|
7
7
|
expect(HardwareErrorCode.WalletSessionInvalid).toBe(831);
|
|
8
8
|
});
|
package/src/HardwareError.ts
CHANGED
|
@@ -484,11 +484,6 @@ export const HardwareErrorCode = {
|
|
|
484
484
|
*/
|
|
485
485
|
PinMismatch: 828,
|
|
486
486
|
|
|
487
|
-
/**
|
|
488
|
-
* Device refused to sign: refTxs don't match the spent input's outpoint
|
|
489
|
-
*/
|
|
490
|
-
KaspaPrevTxIdMismatch: 829,
|
|
491
|
-
|
|
492
487
|
/**
|
|
493
488
|
* Protocol V2 device must be unlocked before the requested operation.
|
|
494
489
|
* @params: { failureCode?: string; subcode?: number; firmwareMessage?: string }
|
|
@@ -501,6 +496,12 @@ export const HardwareErrorCode = {
|
|
|
501
496
|
*/
|
|
502
497
|
WalletSessionInvalid: 831,
|
|
503
498
|
|
|
499
|
+
/**
|
|
500
|
+
* Pro2 NFT storage has reached its item limit.
|
|
501
|
+
* @params: { count: number; limit: number }
|
|
502
|
+
*/
|
|
503
|
+
NftStorageLimitReached: 832,
|
|
504
|
+
|
|
504
505
|
/**
|
|
505
506
|
* Lowlevel transport connect error
|
|
506
507
|
*/
|
|
@@ -653,8 +654,9 @@ export const HardwareErrorCodeMessage: HardwareErrorCodeMessageMapping = {
|
|
|
653
654
|
[HardwareErrorCode.TooManyInputs]: 'Too many inputs',
|
|
654
655
|
[HardwareErrorCode.PinMismatch]: 'PIN mismatch',
|
|
655
656
|
[HardwareErrorCode.DeviceLocked]: 'Device locked',
|
|
656
|
-
[HardwareErrorCode.KaspaPrevTxIdMismatch]: 'Kaspa previous transaction id mismatch',
|
|
657
657
|
[HardwareErrorCode.WalletSessionInvalid]: 'Wallet session is invalid or expired',
|
|
658
|
+
[HardwareErrorCode.NftStorageLimitReached]:
|
|
659
|
+
'NFT storage limit reached. Remove an NFT from the device and try again.',
|
|
658
660
|
|
|
659
661
|
/**
|
|
660
662
|
* Lowlevel transport
|
package/src/constants.test.ts
CHANGED
|
@@ -11,6 +11,7 @@ describe('hardware device identity filters', () => {
|
|
|
11
11
|
it('accepts known OneKey BLE names', () => {
|
|
12
12
|
expect(isOnekeyDevice('Touch A1B2')).toBe(true);
|
|
13
13
|
expect(isOnekeyDevice('Pro A1B2')).toBe(true);
|
|
14
|
+
expect(isOnekeyDevice('Neo A1B2')).toBe(true);
|
|
14
15
|
expect(isOnekeyDevice('K1234')).toBe(true);
|
|
15
16
|
expect(isOnekeyDevice('S8')).toBe(true);
|
|
16
17
|
});
|
|
@@ -20,14 +21,14 @@ describe('hardware device identity filters', () => {
|
|
|
20
21
|
expect(isOnekeyDevice('Ledger Nano X')).toBe(false);
|
|
21
22
|
});
|
|
22
23
|
|
|
23
|
-
it('does not identify an
|
|
24
|
+
it('does not identify an FFFD-only advertisement as OneKey', () => {
|
|
24
25
|
expect(isOnekeyBluetoothDevice({ name: 'Find My', serviceUuids: ['fffd'] })).toBe(false);
|
|
25
26
|
expect(
|
|
26
27
|
isOnekeyBluetoothDevice({ serviceUuids: ['0000fffd-0000-1000-8000-00805f9b34fb'] })
|
|
27
28
|
).toBe(false);
|
|
28
29
|
});
|
|
29
30
|
|
|
30
|
-
it('
|
|
31
|
+
it('identifies Pro2 communication advertisements independently of their display name', () => {
|
|
31
32
|
expect(
|
|
32
33
|
isOnekeyBluetoothDevice({
|
|
33
34
|
name: 'Pro2 A1B2',
|
|
@@ -37,14 +38,34 @@ describe('hardware device identity filters', () => {
|
|
|
37
38
|
expect(
|
|
38
39
|
isOnekeyBluetoothDevice({
|
|
39
40
|
localName: 'Pro2 A1B2 - Find My',
|
|
40
|
-
serviceUuids: ['fffd'],
|
|
41
|
+
serviceUuids: ['0001', 'fffd'],
|
|
41
42
|
})
|
|
42
|
-
).toBe(
|
|
43
|
+
).toBe(true);
|
|
43
44
|
expect(
|
|
44
45
|
isOnekeyBluetoothDevice({
|
|
45
46
|
name: 'Pro2 5E9D - Finde My',
|
|
46
47
|
serviceUuids: ['0001', 'fffd'],
|
|
47
48
|
})
|
|
49
|
+
).toBe(true);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('rejects Pro2 Find My entries when the communication service is absent', () => {
|
|
53
|
+
expect(
|
|
54
|
+
isOnekeyBluetoothDevice({
|
|
55
|
+
name: 'Pro2 A1B2 - Find My',
|
|
56
|
+
})
|
|
57
|
+
).toBe(false);
|
|
58
|
+
expect(
|
|
59
|
+
isOnekeyBluetoothDevice({
|
|
60
|
+
localName: 'OneKey Pro 2 A1B2 - Find My',
|
|
61
|
+
serviceUuids: [],
|
|
62
|
+
})
|
|
63
|
+
).toBe(false);
|
|
64
|
+
expect(
|
|
65
|
+
isOnekeyBluetoothDevice({
|
|
66
|
+
name: 'Pro2 5E9D - Finde My',
|
|
67
|
+
serviceUuids: ['fffd'],
|
|
68
|
+
})
|
|
48
69
|
).toBe(false);
|
|
49
70
|
});
|
|
50
71
|
|
package/src/constants.ts
CHANGED
|
@@ -91,6 +91,7 @@ export enum EOneKeyBleMessageKeys {
|
|
|
91
91
|
NOBLE_BLE_SUBSCRIBE = '$onekey-noble-ble-subscribe',
|
|
92
92
|
NOBLE_BLE_UNSUBSCRIBE = '$onekey-noble-ble-unsubscribe',
|
|
93
93
|
NOBLE_BLE_NOTIFICATION = '$onekey-noble-ble-notification',
|
|
94
|
+
NOBLE_BLE_MTU_CHANGED = '$onekey-noble-ble-mtu-changed',
|
|
94
95
|
NOBLE_BLE_CANCEL_PAIRING = '$onekey-noble-ble-cancel-pairing',
|
|
95
96
|
}
|
|
96
97
|
|
|
@@ -148,7 +149,8 @@ export const isOnekeyDevice = (name: string | null, id?: string): boolean => {
|
|
|
148
149
|
if (
|
|
149
150
|
normalizedName.startsWith('touch ') ||
|
|
150
151
|
normalizedName.startsWith('pro ') ||
|
|
151
|
-
normalizedName.startsWith('pro2 ')
|
|
152
|
+
normalizedName.startsWith('pro2 ') ||
|
|
153
|
+
normalizedName.startsWith('neo ')
|
|
152
154
|
) {
|
|
153
155
|
return true;
|
|
154
156
|
}
|
|
@@ -191,8 +193,10 @@ export const matchesKnownBleUuid = (
|
|
|
191
193
|
const ONEKEY_COMMUNICATION_SERVICE_ALIASES = createKnownBleUuidAliases(ONEKEY_SERVICE_UUID);
|
|
192
194
|
const FIDO_SERVICE_ALIASES = createKnownBleUuidAliases('0000fffd-0000-1000-8000-00805f9b34fb');
|
|
193
195
|
|
|
194
|
-
const
|
|
195
|
-
|
|
196
|
+
export const isPro2FindMyAdvertisementName = (value?: string | null) => {
|
|
197
|
+
const normalizedName = value?.trim().toLowerCase() ?? '';
|
|
198
|
+
return /\bpro\s*2\b/.test(normalizedName) && /\bfinde?\s+my\b/.test(normalizedName);
|
|
199
|
+
};
|
|
196
200
|
|
|
197
201
|
export const hasOnekeyCommunicationService = (
|
|
198
202
|
serviceUuids: Array<string | null | undefined> | null | undefined
|
|
@@ -208,14 +212,16 @@ export const isOnekeyBluetoothDevice = ({
|
|
|
208
212
|
serviceUuids,
|
|
209
213
|
}: BluetoothDeviceIdentity): boolean => {
|
|
210
214
|
const advertisedServiceUuids = serviceUuids ?? [];
|
|
211
|
-
if (isFindMyAdvertisementName(name) || isFindMyAdvertisementName(localName)) {
|
|
212
|
-
return false;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
215
|
if (hasOnekeyCommunicationService(advertisedServiceUuids)) {
|
|
216
216
|
return true;
|
|
217
217
|
}
|
|
218
218
|
|
|
219
|
+
// Android can return a connected Find My peripheral without its advertised
|
|
220
|
+
// services. Do not let the Pro2-looking name fall through to name discovery.
|
|
221
|
+
if (isPro2FindMyAdvertisementName(name) || isPro2FindMyAdvertisementName(localName)) {
|
|
222
|
+
return false;
|
|
223
|
+
}
|
|
224
|
+
|
|
219
225
|
if (advertisedServiceUuids.some(uuid => matchesKnownBleUuid(uuid, FIDO_SERVICE_ALIASES))) {
|
|
220
226
|
return false;
|
|
221
227
|
}
|