@onekeyfe/hd-shared 1.2.0-alpha.41 → 1.2.0-alpha.43
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 -0
- package/dist/HardwareError.d.ts.map +1 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.js +2 -4
- package/package.json +2 -2
- package/src/HardwareError.ts +8 -0
- package/src/constants.test.ts +5 -5
- package/src/constants.ts +0 -7
package/dist/HardwareError.d.ts
CHANGED
|
@@ -118,6 +118,7 @@ export declare const HardwareErrorCode: {
|
|
|
118
118
|
readonly KaspaPrevTxIdMismatch: 829;
|
|
119
119
|
readonly DeviceLocked: 830;
|
|
120
120
|
readonly WalletSessionInvalid: 831;
|
|
121
|
+
readonly NftStorageLimitReached: 832;
|
|
121
122
|
readonly LowlevelTrasnportConnectError: 900;
|
|
122
123
|
readonly WebDeviceNotFoundOrNeedsPermission: 901;
|
|
123
124
|
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,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,qB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,oBAAoB,iCAAiC;IACrD,eAAe,4BAA4B;IAC3C,mBAAmB,gCAAgC;IACnD,qBAAqB,kCAAkC;IACvD,sBAAsB,mCAAmC;IACzD,wBAAwB,qCAAqC;CAC9D;AAED,eAAO,MAAM,mBAAmB,yCAAyC,CAAC;AAC1E,eAAO,MAAM,gCAAgC,yCAAyC,CAAC;AACvF,eAAO,MAAM,iCAAiC,yCAAyC,CAAC;AAIxF,eAAO,MAAM,aAAa,UAAW,MAAM,GAAG,UAAU,KAAG,OAa1D,CAAC;AAkBF,eAAO,MAAM,cAAc,SAAU,MAAM,GAAG,IAAI,OAAO,MAAM,KAAG,OAsBjE,CAAC;AAEF,KAAK,uBAAuB,GAAG;IAC7B,EAAE,CAAC,EAAE,MAAM,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,iBAC1B,MAAM,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,GAAG,IAAI,GAAG,SAAS,YAIhE,CAAC;AAEJ,eAAO,MAAM,uBAAuB,2CAKjC,uBAAuB,KAAG,OAW5B,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -439,6 +439,11 @@ declare const HardwareErrorCode: {
|
|
|
439
439
|
* @params: { failureCode?: string; subcode?: number; firmwareMessage?: string }
|
|
440
440
|
*/
|
|
441
441
|
readonly WalletSessionInvalid: 831;
|
|
442
|
+
/**
|
|
443
|
+
* Pro2 NFT storage has reached its item limit.
|
|
444
|
+
* @params: { count: number; limit: number }
|
|
445
|
+
*/
|
|
446
|
+
readonly NftStorageLimitReached: 832;
|
|
442
447
|
/**
|
|
443
448
|
* Lowlevel transport connect error
|
|
444
449
|
*/
|
package/dist/index.js
CHANGED
|
@@ -167,6 +167,7 @@ const HardwareErrorCode = {
|
|
|
167
167
|
KaspaPrevTxIdMismatch: 829,
|
|
168
168
|
DeviceLocked: 830,
|
|
169
169
|
WalletSessionInvalid: 831,
|
|
170
|
+
NftStorageLimitReached: 832,
|
|
170
171
|
LowlevelTrasnportConnectError: 900,
|
|
171
172
|
WebDeviceNotFoundOrNeedsPermission: 901,
|
|
172
173
|
WebDevicePromptAccessError: 902,
|
|
@@ -274,6 +275,7 @@ const HardwareErrorCodeMessage = {
|
|
|
274
275
|
[HardwareErrorCode.DeviceLocked]: 'Device locked',
|
|
275
276
|
[HardwareErrorCode.KaspaPrevTxIdMismatch]: 'Kaspa previous transaction id mismatch',
|
|
276
277
|
[HardwareErrorCode.WalletSessionInvalid]: 'Wallet session is invalid or expired',
|
|
278
|
+
[HardwareErrorCode.NftStorageLimitReached]: 'NFT storage limit reached. Remove an NFT from the device and try again.',
|
|
277
279
|
[HardwareErrorCode.LowlevelTrasnportConnectError]: 'Lowlevel transport connect error',
|
|
278
280
|
[HardwareErrorCode.WebDeviceNotFoundOrNeedsPermission]: 'Web-USB or Web-Bluetooth device not found or needs permission',
|
|
279
281
|
[HardwareErrorCode.WebDevicePromptAccessError]: 'Web-USB or Web-Bluetooth device prompt access error',
|
|
@@ -514,13 +516,9 @@ 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 isFindMyAdvertisementName = (value) => { var _a; return /\bfinde?\s+my\b/.test((_a = value === null || value === void 0 ? void 0 : value.trim().toLowerCase()) !== null && _a !== void 0 ? _a : ''); };
|
|
518
519
|
const hasOnekeyCommunicationService = (serviceUuids) => (serviceUuids !== null && serviceUuids !== void 0 ? serviceUuids : []).some(uuid => matchesKnownBleUuid(uuid, ONEKEY_COMMUNICATION_SERVICE_ALIASES));
|
|
519
520
|
const isOnekeyBluetoothDevice = ({ id, name, localName, serviceUuids, }) => {
|
|
520
521
|
const advertisedServiceUuids = serviceUuids !== null && serviceUuids !== void 0 ? serviceUuids : [];
|
|
521
|
-
if (isFindMyAdvertisementName(name) || isFindMyAdvertisementName(localName)) {
|
|
522
|
-
return false;
|
|
523
|
-
}
|
|
524
522
|
if (hasOnekeyCommunicationService(advertisedServiceUuids)) {
|
|
525
523
|
return true;
|
|
526
524
|
}
|
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.43",
|
|
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": "2ea7c9d60472502a272a57f808aed3773ccd84c4"
|
|
30
30
|
}
|
package/src/HardwareError.ts
CHANGED
|
@@ -501,6 +501,12 @@ export const HardwareErrorCode = {
|
|
|
501
501
|
*/
|
|
502
502
|
WalletSessionInvalid: 831,
|
|
503
503
|
|
|
504
|
+
/**
|
|
505
|
+
* Pro2 NFT storage has reached its item limit.
|
|
506
|
+
* @params: { count: number; limit: number }
|
|
507
|
+
*/
|
|
508
|
+
NftStorageLimitReached: 832,
|
|
509
|
+
|
|
504
510
|
/**
|
|
505
511
|
* Lowlevel transport connect error
|
|
506
512
|
*/
|
|
@@ -655,6 +661,8 @@ export const HardwareErrorCodeMessage: HardwareErrorCodeMessageMapping = {
|
|
|
655
661
|
[HardwareErrorCode.DeviceLocked]: 'Device locked',
|
|
656
662
|
[HardwareErrorCode.KaspaPrevTxIdMismatch]: 'Kaspa previous transaction id mismatch',
|
|
657
663
|
[HardwareErrorCode.WalletSessionInvalid]: 'Wallet session is invalid or expired',
|
|
664
|
+
[HardwareErrorCode.NftStorageLimitReached]:
|
|
665
|
+
'NFT storage limit reached. Remove an NFT from the device and try again.',
|
|
658
666
|
|
|
659
667
|
/**
|
|
660
668
|
* Lowlevel transport
|
package/src/constants.test.ts
CHANGED
|
@@ -20,14 +20,14 @@ describe('hardware device identity filters', () => {
|
|
|
20
20
|
expect(isOnekeyDevice('Ledger Nano X')).toBe(false);
|
|
21
21
|
});
|
|
22
22
|
|
|
23
|
-
it('does not identify an
|
|
23
|
+
it('does not identify an FFFD-only advertisement as OneKey', () => {
|
|
24
24
|
expect(isOnekeyBluetoothDevice({ name: 'Find My', serviceUuids: ['fffd'] })).toBe(false);
|
|
25
25
|
expect(
|
|
26
26
|
isOnekeyBluetoothDevice({ serviceUuids: ['0000fffd-0000-1000-8000-00805f9b34fb'] })
|
|
27
27
|
).toBe(false);
|
|
28
28
|
});
|
|
29
29
|
|
|
30
|
-
it('
|
|
30
|
+
it('identifies Pro2 communication advertisements independently of their display name', () => {
|
|
31
31
|
expect(
|
|
32
32
|
isOnekeyBluetoothDevice({
|
|
33
33
|
name: 'Pro2 A1B2',
|
|
@@ -37,15 +37,15 @@ describe('hardware device identity filters', () => {
|
|
|
37
37
|
expect(
|
|
38
38
|
isOnekeyBluetoothDevice({
|
|
39
39
|
localName: 'Pro2 A1B2 - Find My',
|
|
40
|
-
serviceUuids: ['fffd'],
|
|
40
|
+
serviceUuids: ['0001', 'fffd'],
|
|
41
41
|
})
|
|
42
|
-
).toBe(
|
|
42
|
+
).toBe(true);
|
|
43
43
|
expect(
|
|
44
44
|
isOnekeyBluetoothDevice({
|
|
45
45
|
name: 'Pro2 5E9D - Finde My',
|
|
46
46
|
serviceUuids: ['0001', 'fffd'],
|
|
47
47
|
})
|
|
48
|
-
).toBe(
|
|
48
|
+
).toBe(true);
|
|
49
49
|
});
|
|
50
50
|
|
|
51
51
|
it('keeps OneKey discovery on the communication service', () => {
|
package/src/constants.ts
CHANGED
|
@@ -191,9 +191,6 @@ export const matchesKnownBleUuid = (
|
|
|
191
191
|
const ONEKEY_COMMUNICATION_SERVICE_ALIASES = createKnownBleUuidAliases(ONEKEY_SERVICE_UUID);
|
|
192
192
|
const FIDO_SERVICE_ALIASES = createKnownBleUuidAliases('0000fffd-0000-1000-8000-00805f9b34fb');
|
|
193
193
|
|
|
194
|
-
const isFindMyAdvertisementName = (value?: string | null) =>
|
|
195
|
-
/\bfinde?\s+my\b/.test(value?.trim().toLowerCase() ?? '');
|
|
196
|
-
|
|
197
194
|
export const hasOnekeyCommunicationService = (
|
|
198
195
|
serviceUuids: Array<string | null | undefined> | null | undefined
|
|
199
196
|
) =>
|
|
@@ -208,10 +205,6 @@ export const isOnekeyBluetoothDevice = ({
|
|
|
208
205
|
serviceUuids,
|
|
209
206
|
}: BluetoothDeviceIdentity): boolean => {
|
|
210
207
|
const advertisedServiceUuids = serviceUuids ?? [];
|
|
211
|
-
if (isFindMyAdvertisementName(name) || isFindMyAdvertisementName(localName)) {
|
|
212
|
-
return false;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
208
|
if (hasOnekeyCommunicationService(advertisedServiceUuids)) {
|
|
216
209
|
return true;
|
|
217
210
|
}
|