@onekeyfe/hd-core 1.2.8-alpha.17 → 1.2.8-alpha.18

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,4 +1,4 @@
1
- import { DeviceType } from '@onekeyfe/hd-transport';
1
+ import protocolTransport, { DeviceType } from '@onekeyfe/hd-transport';
2
2
  import { EDeviceType } from '@onekeyfe/hd-shared';
3
3
 
4
4
  import {
@@ -148,6 +148,41 @@ describe('isolated USB identity probe', () => {
148
148
  );
149
149
  });
150
150
 
151
+ test.each([
152
+ { onekey_device_type: 'CLASSIC', major_version: 2, minor_version: 8, patch_version: 0 },
153
+ { onekey_device_type: 'TOUCH', major_version: 4, minor_version: 4, patch_version: 0 },
154
+ ])(
155
+ 'preserves GetFeatures identity when the legacy V1 schema has no vendor query (%s)',
156
+ async firmware => {
157
+ const transport = createTransport();
158
+ let messages = protocolTransport.parseConfigure(
159
+ JSON.stringify(DataManager.getProtobufMessages())
160
+ );
161
+ transport.configure.mockImplementation((schema: string) => {
162
+ messages = protocolTransport.parseConfigure(schema);
163
+ });
164
+ transport.call.mockImplementation((_session, name, data) => {
165
+ protocolTransport.ProtocolV1.encodeMessageChunks(messages, name, data);
166
+ return Promise.resolve({
167
+ type: 'Features',
168
+ message: { ...firmware, device_id: 'LEGACY_WALLET_ID' },
169
+ });
170
+ });
171
+ await expect(
172
+ probeUsbDeviceIdentitiesWithTransport(transport, 'webusb')
173
+ ).resolves.toMatchObject([
174
+ {
175
+ path: descriptor.path,
176
+ serialNo: null,
177
+ deviceId: 'LEGACY_WALLET_ID',
178
+ connectProtocol: 'V1',
179
+ },
180
+ ]);
181
+ expect(transport.call.mock.calls.map(call => call[1])).toEqual(['GetFeatures']);
182
+ expect(transport.release).toHaveBeenCalledWith('usb-transport-handle', false);
183
+ }
184
+ );
185
+
151
186
  test('does not substitute a USB path for a missing business identity', async () => {
152
187
  const transport = createTransport();
153
188
  transport.call
@@ -1 +1 @@
1
- {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A4CpD,eAAO,MAAM,yBAAyB,eACxB,0BAA0B,gBACxB,kBAAkB,KAC/B,iBAAiB,GAAG,SAYtB,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG,IAAI,CAC1C,SAAS,EACT,SAAS,GAAG,MAAM,GAAG,iBAAiB,GAAG,qBAAqB,CAC/D,GAAG;IACF,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC;IAClC,SAAS,EAAE,MAAM,OAAO,CAAC,0BAA0B,EAAE,CAAC,CAAC;IACvD,OAAO,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAC9D,SAAS,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACzD,CAAC;AAYF,eAAO,MAAM,qCAAqC,cACrC,yBAAyB,YAC1B,iBAAiB,CAAC,UAAU,CAAC,mCACP,0BAA0B,KAAK,iBAAiB,GAAG,SAAS,kBAC3F,QAAQ,iBAAiB,EAAE,CAmG7B,CAAC;AAsBF,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,UAAU;IACnD,SAAS,CAAC,EAAE,eAAe,CAAa;IAExC,IAAI;IAME,GAAG,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;CAuFrC"}
package/dist/index.js CHANGED
@@ -47266,12 +47266,14 @@ const probeUsbDeviceIdentitiesWithTransport = (transport, commType, getOwnedIden
47266
47266
  return undefined;
47267
47267
  let features = buildProtocolV1FeaturesPayload(response.message);
47268
47268
  if (!features.serialNo) {
47269
- const { messages } = getSupportProtocolV1MessageSchema(features);
47270
- if (messages)
47271
- yield transport.configure(JSON.stringify(messages));
47272
- const vendor = yield transport.call(session, 'OnekeyGetFeatures', {}, { timeoutMs: 3000 });
47273
- if (vendor.type === 'OnekeyFeatures') {
47274
- features = buildProtocolV1FeaturesPayload(Object.assign(Object.assign({}, response.message), vendor.message));
47269
+ const { messages, protocolV1MessageSchema } = getSupportProtocolV1MessageSchema(features);
47270
+ if (protocolV1MessageSchema === 'v1CurrentSchema') {
47271
+ if (messages)
47272
+ yield transport.configure(JSON.stringify(messages));
47273
+ const vendor = yield transport.call(session, 'OnekeyGetFeatures', {}, { timeoutMs: 3000 });
47274
+ if (vendor.type === 'OnekeyFeatures') {
47275
+ features = buildProtocolV1FeaturesPayload(Object.assign(Object.assign({}, response.message), vendor.message));
47276
+ }
47275
47277
  }
47276
47278
  }
47277
47279
  identified = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/hd-core",
3
- "version": "1.2.8-alpha.17",
3
+ "version": "1.2.8-alpha.18",
4
4
  "description": "Core processes and APIs for communicating with OneKey hardware devices.",
5
5
  "author": "OneKey",
6
6
  "homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
@@ -25,8 +25,8 @@
25
25
  "url": "https://github.com/OneKeyHQ/hardware-js-sdk/issues"
26
26
  },
27
27
  "dependencies": {
28
- "@onekeyfe/hd-shared": "1.2.8-alpha.17",
29
- "@onekeyfe/hd-transport": "1.2.8-alpha.17",
28
+ "@onekeyfe/hd-shared": "1.2.8-alpha.18",
29
+ "@onekeyfe/hd-transport": "1.2.8-alpha.18",
30
30
  "axios": "1.15.2",
31
31
  "bignumber.js": "^9.0.2",
32
32
  "buffer": "^6.0.3",
@@ -46,5 +46,5 @@
46
46
  "@types/w3c-web-usb": "^1.0.10",
47
47
  "@types/web-bluetooth": "^0.0.21"
48
48
  },
49
- "gitHead": "d7376861ee755a4c65226468a6b67ab2e6e9c55d"
49
+ "gitHead": "1f66fc960c9d775272f989aa673d8efe2174729b"
50
50
  }
@@ -149,19 +149,22 @@ export const probeUsbDeviceIdentitiesWithTransport = async (
149
149
  if (response.type !== 'Features') return undefined;
150
150
  let features = buildProtocolV1FeaturesPayload(response.message as PROTO.Features);
151
151
  if (!features.serialNo) {
152
- const { messages } = getSupportProtocolV1MessageSchema(features);
153
- if (messages) await transport.configure(JSON.stringify(messages));
154
- const vendor = await transport.call(
155
- session,
156
- 'OnekeyGetFeatures',
157
- {},
158
- { timeoutMs: 3000 }
159
- );
160
- if (vendor.type === 'OnekeyFeatures') {
161
- features = buildProtocolV1FeaturesPayload({
162
- ...response.message,
163
- ...vendor.message,
164
- } as PROTO.Features);
152
+ const { messages, protocolV1MessageSchema } = getSupportProtocolV1MessageSchema(features);
153
+ // Legacy V1 has no OnekeyGetFeatures; keep the identity confirmed by GetFeatures.
154
+ if (protocolV1MessageSchema === 'v1CurrentSchema') {
155
+ if (messages) await transport.configure(JSON.stringify(messages));
156
+ const vendor = await transport.call(
157
+ session,
158
+ 'OnekeyGetFeatures',
159
+ {},
160
+ { timeoutMs: 3000 }
161
+ );
162
+ if (vendor.type === 'OnekeyFeatures') {
163
+ features = buildProtocolV1FeaturesPayload({
164
+ ...response.message,
165
+ ...vendor.message,
166
+ } as PROTO.Features);
167
+ }
165
168
  }
166
169
  }
167
170
  identified = {