@onekeyfe/hd-core 1.1.27-alpha.34 → 1.1.27-alpha.35

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.
@@ -13,6 +13,7 @@ import DeviceGetOnboardingStatus from '../src/api/protocol-v2/DeviceGetOnboardin
13
13
  import EVMSignMessageEIP712 from '../src/api/evm/EVMSignMessageEIP712';
14
14
  import FirmwareUpdateV3 from '../src/api/FirmwareUpdateV3';
15
15
  import FirmwareUpdateV4 from '../src/api/FirmwareUpdateV4';
16
+ import GetPassphraseState from '../src/api/GetPassphraseState';
16
17
  import GetOnekeyFeatures from '../src/api/GetOnekeyFeatures';
17
18
  import { batchGetPublickeys } from '../src/api/helpers/batchGetPublickeys';
18
19
  import SuiSignTransaction from '../src/api/sui/SuiSignTransaction';
@@ -164,6 +165,51 @@ describe('Protocol V2 feature adapter', () => {
164
165
  });
165
166
  });
166
167
 
168
+ test('returns unified GetPassphraseState object payload for existing Pro devices', async () => {
169
+ const features = {
170
+ device_id: 'pro-device-id',
171
+ onekey_device_type: 'PRO',
172
+ onekey_firmware_version: '4.15.0',
173
+ passphrase_protection: true,
174
+ session_id: 'feature-session',
175
+ unlocked_attach_pin: true,
176
+ };
177
+ const typedCall = jest.fn().mockResolvedValue({
178
+ type: 'PassphraseState',
179
+ message: {
180
+ passphrase_state: 'state-pro',
181
+ session_id: 'session-pro',
182
+ unlocked_attach_pin: false,
183
+ },
184
+ });
185
+ const updateInternalState = jest.fn();
186
+ const method = new GetPassphraseState({
187
+ payload: {
188
+ method: 'getPassphraseState',
189
+ connectId: 'connect-id',
190
+ },
191
+ });
192
+ method.device = {
193
+ features,
194
+ commands: { typedCall },
195
+ updateInternalState,
196
+ } as any;
197
+
198
+ await expect(method.run()).resolves.toEqual({
199
+ passphrase_state: 'state-pro',
200
+ session_id: 'session-pro',
201
+ unlocked_attach_pin: false,
202
+ passphrase_protection: true,
203
+ });
204
+ expect(updateInternalState).toHaveBeenCalledWith(
205
+ true,
206
+ 'state-pro',
207
+ 'pro-device-id',
208
+ 'session-pro',
209
+ 'feature-session'
210
+ );
211
+ });
212
+
167
213
  test('stores Pro2 passphrase sessions without selecting them implicitly', async () => {
168
214
  const device = Device.fromDescriptor({ ...descriptor, protocolType: 'V2' } as any);
169
215
  const typedCall = jest.fn().mockResolvedValue({
@@ -337,10 +383,7 @@ describe('Protocol V2 feature adapter', () => {
337
383
  stellar.init();
338
384
  benfen.init();
339
385
 
340
- const stellarRange = getMethodVersionRange(
341
- features,
342
- type => stellar.getVersionRange()[type]
343
- );
386
+ const stellarRange = getMethodVersionRange(features, type => stellar.getVersionRange()[type]);
344
387
  const benfenRange = getMethodVersionRange(features, type => benfen.getVersionRange()[type]);
345
388
  const neuraiRange = getMethodVersionRange(
346
389
  features,
@@ -521,7 +564,7 @@ describe('API compatibility handling', () => {
521
564
 
522
565
  test('uses chunk transfer for large Sui transactions on Protocol V2', async () => {
523
566
  const rawTx = '0x'.concat('ab'.repeat(5000));
524
- const typedCall = jest.fn(async () => ({
567
+ const typedCall = jest.fn(() => ({
525
568
  type: 'SuiSignedTx',
526
569
  message: {
527
570
  public_key: '',
@@ -1,11 +1,11 @@
1
1
  import { BaseMethod } from './BaseMethod';
2
2
  export default class GetPassphraseState extends BaseMethod {
3
3
  init(): void;
4
- run(): Promise<string | {
4
+ run(): Promise<{
5
5
  passphrase_state: string | undefined;
6
6
  session_id: string | undefined;
7
7
  unlocked_attach_pin: boolean | undefined;
8
8
  passphrase_protection: boolean | null;
9
- } | undefined>;
9
+ }>;
10
10
  }
11
11
  //# sourceMappingURL=GetPassphraseState.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"GetPassphraseState.d.ts","sourceRoot":"","sources":["../../src/api/GetPassphraseState.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,MAAM,CAAC,OAAO,OAAO,kBAAmB,SAAQ,UAAU;IACxD,IAAI;IAKE,GAAG;;;;;;CA8BV"}
1
+ {"version":3,"file":"GetPassphraseState.d.ts","sourceRoot":"","sources":["../../src/api/GetPassphraseState.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,MAAM,CAAC,OAAO,OAAO,kBAAmB,SAAQ,UAAU;IACxD,IAAI;IAKE,GAAG;;;;;;CAuBV"}
package/dist/index.d.ts CHANGED
@@ -523,7 +523,7 @@ declare function getDeviceInfo(connectId?: string, params?: CommonParams & GetDe
523
523
 
524
524
  declare function getOnekeyFeatures(connectId?: string, params?: CommonParams): Response<OnekeyFeatures>;
525
525
 
526
- type GetPassphraseStatePayload = string | {
526
+ type GetPassphraseStatePayload = {
527
527
  passphrase_state?: string;
528
528
  session_id?: string;
529
529
  unlocked_attach_pin?: boolean;
package/dist/index.js CHANGED
@@ -42217,18 +42217,13 @@ class GetPassphraseState extends BaseMethod {
42217
42217
  });
42218
42218
  const { features } = this.device;
42219
42219
  const isPro2 = getDeviceType(features) === hdShared.EDeviceType.Pro2;
42220
- if (isPro2) {
42221
- return Promise.resolve({
42222
- passphrase_state: passphraseState,
42223
- session_id: (_a = newSession !== null && newSession !== void 0 ? newSession : features === null || features === void 0 ? void 0 : features.session_id) !== null && _a !== void 0 ? _a : undefined,
42224
- unlocked_attach_pin: unlockedAttachPin,
42225
- passphrase_protection: (_b = features === null || features === void 0 ? void 0 : features.passphrase_protection) !== null && _b !== void 0 ? _b : null,
42226
- });
42227
- }
42228
- if (features && features.passphrase_protection === true) {
42229
- return Promise.resolve(passphraseState);
42230
- }
42231
- return Promise.resolve(undefined);
42220
+ const passphraseProtection = (_a = features === null || features === void 0 ? void 0 : features.passphrase_protection) !== null && _a !== void 0 ? _a : null;
42221
+ return Promise.resolve({
42222
+ passphrase_state: isPro2 || passphraseProtection === true ? passphraseState : undefined,
42223
+ session_id: (_b = newSession !== null && newSession !== void 0 ? newSession : features === null || features === void 0 ? void 0 : features.session_id) !== null && _b !== void 0 ? _b : undefined,
42224
+ unlocked_attach_pin: unlockedAttachPin !== null && unlockedAttachPin !== void 0 ? unlockedAttachPin : features === null || features === void 0 ? void 0 : features.unlocked_attach_pin,
42225
+ passphrase_protection: passphraseProtection,
42226
+ });
42232
42227
  });
42233
42228
  }
42234
42229
  }
@@ -1,5 +1,5 @@
1
1
  import type { CommonParams, Response } from '../params';
2
- export type GetPassphraseStatePayload = string | {
2
+ export type GetPassphraseStatePayload = {
3
3
  passphrase_state?: string;
4
4
  session_id?: string;
5
5
  unlocked_attach_pin?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"getPassphraseState.d.ts","sourceRoot":"","sources":["../../../src/types/api/getPassphraseState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAExD,MAAM,MAAM,yBAAyB,GACjC,MAAM,GACN;IACE,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,qBAAqB,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;CACxC,CAAC;AAEN,MAAM,MAAM,wBAAwB,GAAG,YAAY,GAAG;IACpD,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,kBAAkB,CACxC,SAAS,CAAC,EAAE,MAAM,EAClB,MAAM,CAAC,EAAE,wBAAwB,GAChC,QAAQ,CAAC,yBAAyB,CAAC,CAAC"}
1
+ {"version":3,"file":"getPassphraseState.d.ts","sourceRoot":"","sources":["../../../src/types/api/getPassphraseState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAExD,MAAM,MAAM,yBAAyB,GAAG;IACtC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,qBAAqB,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;CACxC,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG,YAAY,GAAG;IACpD,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,kBAAkB,CACxC,SAAS,CAAC,EAAE,MAAM,EAClB,MAAM,CAAC,EAAE,wBAAwB,GAChC,QAAQ,CAAC,yBAAyB,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/hd-core",
3
- "version": "1.1.27-alpha.34",
3
+ "version": "1.1.27-alpha.35",
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.1.27-alpha.34",
29
- "@onekeyfe/hd-transport": "1.1.27-alpha.34",
28
+ "@onekeyfe/hd-shared": "1.1.27-alpha.35",
29
+ "@onekeyfe/hd-transport": "1.1.27-alpha.35",
30
30
  "axios": "1.15.2",
31
31
  "bignumber.js": "^9.0.2",
32
32
  "bytebuffer": "^5.0.1",
@@ -44,5 +44,5 @@
44
44
  "@types/w3c-web-usb": "^1.0.10",
45
45
  "@types/web-bluetooth": "^0.0.21"
46
46
  },
47
- "gitHead": "ff1863a1ff300ada1314b7315e5ab827663d9f4c"
47
+ "gitHead": "3a5eb264b57a6cc2338d1f9534be0ba265c2db35"
48
48
  }
@@ -24,21 +24,14 @@ export default class GetPassphraseState extends BaseMethod {
24
24
 
25
25
  const { features } = this.device;
26
26
  const isPro2 = getDeviceType(features) === EDeviceType.Pro2;
27
-
28
- if (isPro2) {
29
- return Promise.resolve({
30
- passphrase_state: passphraseState,
31
- session_id: newSession ?? features?.session_id ?? undefined,
32
- unlocked_attach_pin: unlockedAttachPin,
33
- passphrase_protection: features?.passphrase_protection ?? null,
34
- });
35
- }
27
+ const passphraseProtection = features?.passphrase_protection ?? null;
36
28
 
37
29
  // refresh device info
38
- if (features && features.passphrase_protection === true) {
39
- return Promise.resolve(passphraseState);
40
- }
41
-
42
- return Promise.resolve(undefined);
30
+ return Promise.resolve({
31
+ passphrase_state: isPro2 || passphraseProtection === true ? passphraseState : undefined,
32
+ session_id: newSession ?? features?.session_id ?? undefined,
33
+ unlocked_attach_pin: unlockedAttachPin ?? features?.unlocked_attach_pin,
34
+ passphrase_protection: passphraseProtection,
35
+ });
43
36
  }
44
37
  }
@@ -1,13 +1,11 @@
1
1
  import type { CommonParams, Response } from '../params';
2
2
 
3
- export type GetPassphraseStatePayload =
4
- | string
5
- | {
6
- passphrase_state?: string;
7
- session_id?: string;
8
- unlocked_attach_pin?: boolean;
9
- passphrase_protection?: boolean | null;
10
- };
3
+ export type GetPassphraseStatePayload = {
4
+ passphrase_state?: string;
5
+ session_id?: string;
6
+ unlocked_attach_pin?: boolean;
7
+ passphrase_protection?: boolean | null;
8
+ };
11
9
 
12
10
  export type GetPassphraseStateParams = CommonParams & {
13
11
  allowCreateAttachPin?: boolean;