@onekeyfe/hd-core 1.1.27-alpha.34 → 1.1.27-alpha.36
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/__tests__/protocol-v2.test.ts +52 -11
- package/dist/api/GetPassphraseState.d.ts +2 -2
- package/dist/api/GetPassphraseState.d.ts.map +1 -1
- package/dist/device/Device.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +34 -25
- package/dist/types/api/getPassphraseState.d.ts +1 -1
- package/dist/types/api/getPassphraseState.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/api/GetPassphraseState.ts +7 -14
- package/src/data/messages/messages-protocol-v2.json +19 -7
- package/src/device/Device.ts +10 -6
- package/src/types/api/getPassphraseState.ts +6 -8
|
@@ -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(
|
|
567
|
+
const typedCall = jest.fn(() => ({
|
|
525
568
|
type: 'SuiSignedTx',
|
|
526
569
|
message: {
|
|
527
570
|
public_key: '',
|
|
@@ -1181,9 +1224,8 @@ describe('Protocol V2 onboarding status method', () => {
|
|
|
1181
1224
|
const typedCall = jest.fn().mockResolvedValue({
|
|
1182
1225
|
type: 'DeviceOnboardingStatus',
|
|
1183
1226
|
message: {
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
page_name: 'backup',
|
|
1227
|
+
step: 4,
|
|
1228
|
+
page_name: 'Recovery Phrase',
|
|
1187
1229
|
},
|
|
1188
1230
|
});
|
|
1189
1231
|
|
|
@@ -1192,9 +1234,8 @@ describe('Protocol V2 onboarding status method', () => {
|
|
|
1192
1234
|
};
|
|
1193
1235
|
|
|
1194
1236
|
await expect(method.run()).resolves.toEqual({
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
page_name: 'backup',
|
|
1237
|
+
step: 4,
|
|
1238
|
+
page_name: 'Recovery Phrase',
|
|
1198
1239
|
});
|
|
1199
1240
|
expect(typedCall).toHaveBeenCalledWith(
|
|
1200
1241
|
'DeviceGetOnboardingStatus',
|
|
@@ -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<
|
|
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
|
-
}
|
|
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;;;;;;
|
|
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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Device.d.ts","sourceRoot":"","sources":["../../src/device/Device.ts"],"names":[],"mappings":";AAAA,OAAO,YAAY,MAAM,QAAQ,CAAC;AA8BlC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,MAAM,IAAI,WAAW,EAC1B,iBAAiB,EACjB,KAAK,QAAQ,EACb,KAAK,uBAAuB,EAC7B,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,MAAM,EAAc,MAAM,WAAW,CAAC;AAO/C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,KAAK,EACV,0BAA0B,EAC1B,qBAAqB,EACrB,wBAAwB,EACzB,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO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,CAAC,EAAE,UAAU;IAYlD,SAAS,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,MAAM,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,EAAE,OAAO,EAAE,UAAU;IAgFpE,uBAAuB;IASvB,oBAAoB;IAW1B,mBAAmB,CAAC,QAAQ,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,KAAK,OAAO,CAAC,OAAO,CAAC;IAW/D,qBAAqB;IAIrB,OAAO;IAoBP,kBAAkB;IAKlB,qBAAqB;IAKrB,MAAM;IAIN,gBAAgB;IAQhB,UAAU;IAQV,eAAe,IAAI,OAAO;IAI1B,YAAY;IAIZ,aAAa;IAIb,UAAU;IAIV,YAAY,IAAI,OAAO;IAIvB,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE;IAsBpD,gBAAgB;IAShB,aAAa,CAAC,QAAQ,EAAE,MAAM;IAOxB,UAAU;IAKhB,yBAAyB,IAAI,mBAAmB;IAQ1C,YAAY;IAoDZ,0BAA0B,CAC9B,eAAe,CAAC,EAAE,MAAM,EACxB,kBAAkB,CAAC,EAAE,OAAO,EAC5B,mBAAmB,CAAC,EAAE,OAAO;CA4ChC;AAED,eAAe,MAAM,CAAC"}
|
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 =
|
|
526
|
+
type GetPassphraseStatePayload = {
|
|
527
527
|
passphrase_state?: string;
|
|
528
528
|
session_id?: string;
|
|
529
529
|
unlocked_attach_pin?: boolean;
|
package/dist/index.js
CHANGED
|
@@ -37771,23 +37771,35 @@ var nested = {
|
|
|
37771
37771
|
}
|
|
37772
37772
|
}
|
|
37773
37773
|
},
|
|
37774
|
+
OnboardingStep: {
|
|
37775
|
+
values: {
|
|
37776
|
+
ONBOARDING_STEP_UNKNOWN: 0,
|
|
37777
|
+
ONBOARDING_STEP_SECURITY_CHECK: 1,
|
|
37778
|
+
ONBOARDING_STEP_PIN: 2,
|
|
37779
|
+
ONBOARDING_STEP_SETUP_CHOICE: 3,
|
|
37780
|
+
ONBOARDING_STEP_CREATE_NEW: 4,
|
|
37781
|
+
ONBOARDING_STEP_SEEDCARD_BACKUP: 5,
|
|
37782
|
+
ONBOARDING_STEP_RESTORE_CHOICE: 6,
|
|
37783
|
+
ONBOARDING_STEP_RESTORE_MNEMONIC: 7,
|
|
37784
|
+
ONBOARDING_STEP_RESTORE_MNEMONIC_SEEDCARD_BACKUP: 8,
|
|
37785
|
+
ONBOARDING_STEP_RESTORE_SEEDCARD: 9,
|
|
37786
|
+
ONBOARDING_STEP_DONE: 100
|
|
37787
|
+
}
|
|
37788
|
+
},
|
|
37774
37789
|
DeviceGetOnboardingStatus: {
|
|
37775
37790
|
fields: {
|
|
37776
37791
|
}
|
|
37777
37792
|
},
|
|
37778
37793
|
DeviceOnboardingStatus: {
|
|
37779
37794
|
fields: {
|
|
37780
|
-
|
|
37781
|
-
|
|
37795
|
+
step: {
|
|
37796
|
+
rule: "required",
|
|
37797
|
+
type: "OnboardingStep",
|
|
37782
37798
|
id: 1
|
|
37783
37799
|
},
|
|
37784
|
-
page_count: {
|
|
37785
|
-
type: "uint32",
|
|
37786
|
-
id: 2
|
|
37787
|
-
},
|
|
37788
37800
|
page_name: {
|
|
37789
37801
|
type: "string",
|
|
37790
|
-
id:
|
|
37802
|
+
id: 2
|
|
37791
37803
|
}
|
|
37792
37804
|
}
|
|
37793
37805
|
},
|
|
@@ -41092,31 +41104,33 @@ class Device extends events.exports {
|
|
|
41092
41104
|
}));
|
|
41093
41105
|
}
|
|
41094
41106
|
acquire(connectProtocol) {
|
|
41095
|
-
var _a, _b, _c, _d, _e, _f;
|
|
41107
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
41096
41108
|
return __awaiter(this, void 0, void 0, function* () {
|
|
41097
41109
|
const env = DataManager.getSettings('env');
|
|
41098
41110
|
const mainIdKey = DataManager.isBleConnect(env) ? 'id' : 'session';
|
|
41099
41111
|
const expectedProtocol = connectProtocol !== null && connectProtocol !== void 0 ? connectProtocol : this.originalDescriptor.protocolType;
|
|
41100
41112
|
try {
|
|
41113
|
+
let acquireResult;
|
|
41101
41114
|
if (DataManager.isBleConnect(env)) {
|
|
41102
|
-
|
|
41103
|
-
this.mainId = (_b =
|
|
41115
|
+
acquireResult = yield ((_a = this.deviceConnector) === null || _a === void 0 ? void 0 : _a.acquire(this.originalDescriptor.id, undefined, true, expectedProtocol));
|
|
41116
|
+
this.mainId = (_b = acquireResult === null || acquireResult === void 0 ? void 0 : acquireResult.uuid) !== null && _b !== void 0 ? _b : '';
|
|
41104
41117
|
Log$b.debug('Expected uuid:', this.mainId);
|
|
41105
41118
|
}
|
|
41106
41119
|
else {
|
|
41107
|
-
|
|
41120
|
+
acquireResult = yield ((_c = this.deviceConnector) === null || _c === void 0 ? void 0 : _c.acquire(this.originalDescriptor.path, this.originalDescriptor.session, undefined, expectedProtocol));
|
|
41121
|
+
this.mainId = acquireResult;
|
|
41108
41122
|
Log$b.debug('Expected session id:', this.mainId);
|
|
41109
41123
|
}
|
|
41110
41124
|
this.deviceAcquired = true;
|
|
41111
41125
|
this.updateDescriptor({ [mainIdKey]: this.mainId });
|
|
41112
|
-
const detectedProtocol = (
|
|
41126
|
+
const detectedProtocol = (_d = acquireResult === null || acquireResult === void 0 ? void 0 : acquireResult.protocolType) !== null && _d !== void 0 ? _d : (_f = (_e = TransportManager.transport) === null || _e === void 0 ? void 0 : _e.getProtocolType) === null || _f === void 0 ? void 0 : _f.call(_e, DataManager.isBleConnect(env) ? this.originalDescriptor.id : this.originalDescriptor.path);
|
|
41113
41127
|
if (detectedProtocol) {
|
|
41114
41128
|
this.originalDescriptor.protocolType = detectedProtocol;
|
|
41115
41129
|
}
|
|
41116
41130
|
if (this.commands) {
|
|
41117
41131
|
yield this.commands.dispose(false);
|
|
41118
41132
|
}
|
|
41119
|
-
this.commands = new DeviceCommands(this, (
|
|
41133
|
+
this.commands = new DeviceCommands(this, (_g = this.mainId) !== null && _g !== void 0 ? _g : '');
|
|
41120
41134
|
}
|
|
41121
41135
|
catch (error) {
|
|
41122
41136
|
if (this.runPromise) {
|
|
@@ -42217,18 +42231,13 @@ class GetPassphraseState extends BaseMethod {
|
|
|
42217
42231
|
});
|
|
42218
42232
|
const { features } = this.device;
|
|
42219
42233
|
const isPro2 = getDeviceType(features) === hdShared.EDeviceType.Pro2;
|
|
42220
|
-
|
|
42221
|
-
|
|
42222
|
-
|
|
42223
|
-
|
|
42224
|
-
|
|
42225
|
-
|
|
42226
|
-
|
|
42227
|
-
}
|
|
42228
|
-
if (features && features.passphrase_protection === true) {
|
|
42229
|
-
return Promise.resolve(passphraseState);
|
|
42230
|
-
}
|
|
42231
|
-
return Promise.resolve(undefined);
|
|
42234
|
+
const passphraseProtection = (_a = features === null || features === void 0 ? void 0 : features.passphrase_protection) !== null && _a !== void 0 ? _a : null;
|
|
42235
|
+
return Promise.resolve({
|
|
42236
|
+
passphrase_state: isPro2 || passphraseProtection === true ? passphraseState : undefined,
|
|
42237
|
+
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,
|
|
42238
|
+
unlocked_attach_pin: unlockedAttachPin !== null && unlockedAttachPin !== void 0 ? unlockedAttachPin : features === null || features === void 0 ? void 0 : features.unlocked_attach_pin,
|
|
42239
|
+
passphrase_protection: passphraseProtection,
|
|
42240
|
+
});
|
|
42232
42241
|
});
|
|
42233
42242
|
}
|
|
42234
42243
|
}
|
|
@@ -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,
|
|
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.
|
|
3
|
+
"version": "1.1.27-alpha.36",
|
|
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.
|
|
29
|
-
"@onekeyfe/hd-transport": "1.1.27-alpha.
|
|
28
|
+
"@onekeyfe/hd-shared": "1.1.27-alpha.36",
|
|
29
|
+
"@onekeyfe/hd-transport": "1.1.27-alpha.36",
|
|
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": "
|
|
47
|
+
"gitHead": "1aaff42d7dd10933009ba7e0c0b7324e91d8e993"
|
|
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
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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
|
}
|
|
@@ -12413,22 +12413,34 @@
|
|
|
12413
12413
|
}
|
|
12414
12414
|
}
|
|
12415
12415
|
},
|
|
12416
|
+
"OnboardingStep": {
|
|
12417
|
+
"values": {
|
|
12418
|
+
"ONBOARDING_STEP_UNKNOWN": 0,
|
|
12419
|
+
"ONBOARDING_STEP_SECURITY_CHECK": 1,
|
|
12420
|
+
"ONBOARDING_STEP_PIN": 2,
|
|
12421
|
+
"ONBOARDING_STEP_SETUP_CHOICE": 3,
|
|
12422
|
+
"ONBOARDING_STEP_CREATE_NEW": 4,
|
|
12423
|
+
"ONBOARDING_STEP_SEEDCARD_BACKUP": 5,
|
|
12424
|
+
"ONBOARDING_STEP_RESTORE_CHOICE": 6,
|
|
12425
|
+
"ONBOARDING_STEP_RESTORE_MNEMONIC": 7,
|
|
12426
|
+
"ONBOARDING_STEP_RESTORE_MNEMONIC_SEEDCARD_BACKUP": 8,
|
|
12427
|
+
"ONBOARDING_STEP_RESTORE_SEEDCARD": 9,
|
|
12428
|
+
"ONBOARDING_STEP_DONE": 100
|
|
12429
|
+
}
|
|
12430
|
+
},
|
|
12416
12431
|
"DeviceGetOnboardingStatus": {
|
|
12417
12432
|
"fields": {}
|
|
12418
12433
|
},
|
|
12419
12434
|
"DeviceOnboardingStatus": {
|
|
12420
12435
|
"fields": {
|
|
12421
|
-
"
|
|
12422
|
-
"
|
|
12436
|
+
"step": {
|
|
12437
|
+
"rule": "required",
|
|
12438
|
+
"type": "OnboardingStep",
|
|
12423
12439
|
"id": 1
|
|
12424
12440
|
},
|
|
12425
|
-
"page_count": {
|
|
12426
|
-
"type": "uint32",
|
|
12427
|
-
"id": 2
|
|
12428
|
-
},
|
|
12429
12441
|
"page_name": {
|
|
12430
12442
|
"type": "string",
|
|
12431
|
-
"id":
|
|
12443
|
+
"id": 2
|
|
12432
12444
|
}
|
|
12433
12445
|
}
|
|
12434
12446
|
},
|
package/src/device/Device.ts
CHANGED
|
@@ -290,31 +290,35 @@ export class Device extends EventEmitter {
|
|
|
290
290
|
const mainIdKey = DataManager.isBleConnect(env) ? 'id' : 'session';
|
|
291
291
|
const expectedProtocol = connectProtocol ?? this.originalDescriptor.protocolType;
|
|
292
292
|
try {
|
|
293
|
+
let acquireResult: unknown;
|
|
293
294
|
if (DataManager.isBleConnect(env)) {
|
|
294
|
-
|
|
295
|
+
acquireResult = await this.deviceConnector?.acquire(
|
|
295
296
|
this.originalDescriptor.id,
|
|
296
297
|
undefined,
|
|
297
298
|
true,
|
|
298
299
|
expectedProtocol
|
|
299
300
|
);
|
|
300
|
-
this.mainId = (
|
|
301
|
+
this.mainId = (acquireResult as any)?.uuid ?? '';
|
|
301
302
|
Log.debug('Expected uuid:', this.mainId);
|
|
302
303
|
} else {
|
|
303
|
-
|
|
304
|
+
acquireResult = await this.deviceConnector?.acquire(
|
|
304
305
|
this.originalDescriptor.path,
|
|
305
306
|
this.originalDescriptor.session,
|
|
306
307
|
undefined,
|
|
307
308
|
expectedProtocol
|
|
308
309
|
);
|
|
310
|
+
this.mainId = acquireResult as string | undefined;
|
|
309
311
|
Log.debug('Expected session id:', this.mainId);
|
|
310
312
|
}
|
|
311
313
|
this.deviceAcquired = true;
|
|
312
314
|
this.updateDescriptor({ [mainIdKey]: this.mainId } as unknown as DeviceDescriptor);
|
|
313
315
|
|
|
314
316
|
// Propagate protocol version detected during acquire.
|
|
315
|
-
const detectedProtocol =
|
|
316
|
-
|
|
317
|
-
|
|
317
|
+
const detectedProtocol =
|
|
318
|
+
(acquireResult as { protocolType?: HardwareConnectProtocol } | undefined)?.protocolType ??
|
|
319
|
+
TransportManager.transport?.getProtocolType?.(
|
|
320
|
+
DataManager.isBleConnect(env) ? this.originalDescriptor.id : this.originalDescriptor.path
|
|
321
|
+
);
|
|
318
322
|
if (detectedProtocol) {
|
|
319
323
|
this.originalDescriptor.protocolType = detectedProtocol;
|
|
320
324
|
}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import type { CommonParams, Response } from '../params';
|
|
2
2
|
|
|
3
|
-
export type GetPassphraseStatePayload =
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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;
|