@onekeyfe/hd-shared 1.1.29-alpha.1 → 1.1.29-alpha.10

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.
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";AAEA,eAAO,MAAM,oBAAoB;;;GAOhC,CAAC;AAEF,KAAK,wBAAwB,GAAG;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAClC,CAAC;AAIF,eAAO,MAAM,yBAAyB,eAAgB,wBAAwB,KAAG,OAQhF,CAAC;AAMF,eAAO,MAAM,2BAA2B,mDAS9B,CAAC;AAMX,eAAO,MAAM,8BAA8B,qBAGjC,CAAC;AAGX,oBAAY,qBAAqB;IAE/B,UAAU,uBAAuB;IACjC,iBAAiB,8BAA8B;IAC/C,aAAa,0BAA0B;IACvC,kBAAkB,+BAA+B;IACjD,cAAc,2BAA2B;IACzC,oBAAoB,iCAAiC;IAGrD,mBAAmB,gCAAgC;IACnD,oBAAoB,iCAAiC;IAGrD,aAAa,0BAA0B;IACvC,oBAAoB,iCAAiC;IAGrD,uBAAuB,oCAAoC;IAC3D,sBAAsB,mCAAmC;IAGzD,mBAAmB,gCAAgC;IACnD,mBAAmB,gCAAgC;IACnD,oBAAoB,iCAAiC;IACrD,iBAAiB,8BAA8B;IAC/C,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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AW,MAAM,GAAG,UAAU,KAAG,OAa1D,CAAC;AAkBF,eAAO,MAAM,cAAc,SAAU,MAAM,GAAG,IAAI,OAAO,MAAM,KAAG,OAgBjE,CAAC"}
package/dist/index.js CHANGED
@@ -386,7 +386,7 @@ const ONEKEY_WEBUSB_FILTER = [
386
386
  { vendorId: 0x1209, productId: 0x4f4a },
387
387
  { vendorId: 0x1209, productId: 0x4f4b },
388
388
  ];
389
- const TREZOR_WEBUSB_MANUFACTURER_NAMES = new Set(['trezor', 'trezor company']);
389
+ const TREZOR_WEBUSB_MANUFACTURER_NAMES = new Set(['trezor', 'trezor company', 'satoshilabs']);
390
390
  const isKnownTrezorWebUsbDevice = (descriptor) => {
391
391
  var _a;
392
392
  const isSharedWebUsbId = ONEKEY_WEBUSB_FILTER.some(filter => descriptor.vendorId === filter.vendorId && descriptor.productId === filter.productId);
@@ -450,27 +450,20 @@ const isHeaderChunk = (chunk) => {
450
450
  }
451
451
  return false;
452
452
  };
453
- const isAllDigits = (value) => {
454
- if (!value)
455
- return false;
456
- for (const char of value) {
457
- if (char < '0' || char > '9')
458
- return false;
459
- }
460
- return true;
461
- };
462
- const isOneKeyShortName = (name) => {
463
- const upperName = name.toUpperCase();
464
- if (upperName.length === 5 && (upperName[0] === 'K' || upperName[0] === 'T')) {
465
- return isAllDigits(upperName.slice(1));
466
- }
467
- return false;
468
- };
469
453
  const isKnownNonOneKeyDeviceName = (normalizedName) => normalizedName.startsWith('trezor') ||
470
454
  normalizedName.startsWith('ledger') ||
471
455
  normalizedName.startsWith('nano ') ||
472
456
  normalizedName.startsWith('stax') ||
473
457
  normalizedName.startsWith('flex');
458
+ const ONEKEY_EXACT_SHORT_NAMES = new Set(['s8']);
459
+ const isOneKeyShortName = (normalizedName) => {
460
+ if (ONEKEY_EXACT_SHORT_NAMES.has(normalizedName))
461
+ return true;
462
+ if (normalizedName.length !== 5)
463
+ return false;
464
+ const firstChar = normalizedName[0];
465
+ return (firstChar === 'k' || firstChar === 't') && /^\d{4}$/.test(normalizedName.slice(1));
466
+ };
474
467
  const isOnekeyDevice = (name, id) => {
475
468
  var _a, _b;
476
469
  const normalizedName = (_a = name === null || name === void 0 ? void 0 : name.trim().toLowerCase()) !== null && _a !== void 0 ? _a : '';
@@ -487,7 +480,7 @@ const isOnekeyDevice = (name, id) => {
487
480
  return true;
488
481
  if (normalizedName.startsWith('touch ') || normalizedName.startsWith('pro '))
489
482
  return true;
490
- return isOneKeyShortName(name.trim());
483
+ return isOneKeyShortName(normalizedName);
491
484
  };
492
485
 
493
486
  /******************************************************************************
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/hd-shared",
3
- "version": "1.1.29-alpha.1",
3
+ "version": "1.1.29-alpha.10",
4
4
  "description": "Hardware SDK's shared tool library",
5
5
  "keywords": [
6
6
  "Hardware-SDK",
@@ -25,5 +25,5 @@
25
25
  "lint": "eslint .",
26
26
  "lint:fix": "eslint . --fix"
27
27
  },
28
- "gitHead": "db793e686fecbecbfa72aab8fd35c70159a72e35"
28
+ "gitHead": "77d5627cd6ee50c91af8487c98c7d2fac6d79544"
29
29
  }
@@ -5,6 +5,7 @@ describe('hardware device identity filters', () => {
5
5
  expect(isOnekeyDevice('Touch A1B2')).toBe(true);
6
6
  expect(isOnekeyDevice('Pro A1B2')).toBe(true);
7
7
  expect(isOnekeyDevice('K1234')).toBe(true);
8
+ expect(isOnekeyDevice('S8')).toBe(true);
8
9
  });
9
10
 
10
11
  it('rejects known Trezor and Ledger BLE names from OneKey discovery', () => {
@@ -27,6 +28,13 @@ describe('hardware device identity filters', () => {
27
28
  manufacturerName: 'Trezor',
28
29
  })
29
30
  ).toBe(true);
31
+ expect(
32
+ isKnownTrezorWebUsbDevice({
33
+ vendorId: 0x1209,
34
+ productId: 0x53c1,
35
+ manufacturerName: 'SatoshiLabs',
36
+ })
37
+ ).toBe(true);
30
38
 
31
39
  expect(
32
40
  isKnownTrezorWebUsbDevice({
package/src/constants.ts CHANGED
@@ -15,7 +15,7 @@ type WebUsbIdentityDescriptor = {
15
15
  manufacturerName?: string | null;
16
16
  };
17
17
 
18
- const TREZOR_WEBUSB_MANUFACTURER_NAMES = new Set(['trezor', 'trezor company']);
18
+ const TREZOR_WEBUSB_MANUFACTURER_NAMES = new Set(['trezor', 'trezor company', 'satoshilabs']);
19
19
 
20
20
  export const isKnownTrezorWebUsbDevice = (descriptor: WebUsbIdentityDescriptor): boolean => {
21
21
  const isSharedWebUsbId = ONEKEY_WEBUSB_FILTER.some(
@@ -107,22 +107,6 @@ export const isHeaderChunk = (chunk: Buffer | Uint8Array): boolean => {
107
107
  return false;
108
108
  };
109
109
 
110
- const isAllDigits = (value: string): boolean => {
111
- if (!value) return false;
112
- for (const char of value) {
113
- if (char < '0' || char > '9') return false;
114
- }
115
- return true;
116
- };
117
-
118
- const isOneKeyShortName = (name: string): boolean => {
119
- const upperName = name.toUpperCase();
120
- if (upperName.length === 5 && (upperName[0] === 'K' || upperName[0] === 'T')) {
121
- return isAllDigits(upperName.slice(1));
122
- }
123
- return false;
124
- };
125
-
126
110
  const isKnownNonOneKeyDeviceName = (normalizedName: string): boolean =>
127
111
  normalizedName.startsWith('trezor') ||
128
112
  normalizedName.startsWith('ledger') ||
@@ -130,6 +114,15 @@ const isKnownNonOneKeyDeviceName = (normalizedName: string): boolean =>
130
114
  normalizedName.startsWith('stax') ||
131
115
  normalizedName.startsWith('flex');
132
116
 
117
+ const ONEKEY_EXACT_SHORT_NAMES = new Set(['s8']);
118
+
119
+ const isOneKeyShortName = (normalizedName: string): boolean => {
120
+ if (ONEKEY_EXACT_SHORT_NAMES.has(normalizedName)) return true;
121
+ if (normalizedName.length !== 5) return false;
122
+ const firstChar = normalizedName[0];
123
+ return (firstChar === 'k' || firstChar === 't') && /^\d{4}$/.test(normalizedName.slice(1));
124
+ };
125
+
133
126
  export const isOnekeyDevice = (name: string | null, id?: string): boolean => {
134
127
  const normalizedName = name?.trim().toLowerCase() ?? '';
135
128
  if (isKnownNonOneKeyDeviceName(normalizedName)) {
@@ -145,5 +138,5 @@ export const isOnekeyDevice = (name: string | null, id?: string): boolean => {
145
138
  }
146
139
  if (normalizedName.startsWith('onekey') || normalizedName.startsWith('bixinkey')) return true;
147
140
  if (normalizedName.startsWith('touch ') || normalizedName.startsWith('pro ')) return true;
148
- return isOneKeyShortName(name.trim());
141
+ return isOneKeyShortName(normalizedName);
149
142
  };