@onekeyfe/hd-core 1.0.33-alpha.9 → 1.0.33
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/api/GetPassphraseState.d.ts +1 -1
- package/dist/api/GetPassphraseState.d.ts.map +1 -1
- package/dist/api/allnetwork/AllNetworkGetAddress.d.ts +1 -3
- package/dist/api/allnetwork/AllNetworkGetAddress.d.ts.map +1 -1
- package/dist/api/helpers/hexUtils.d.ts +1 -0
- package/dist/api/helpers/hexUtils.d.ts.map +1 -1
- package/dist/api/index.d.ts +0 -1
- package/dist/api/index.d.ts.map +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/device/Device.d.ts +3 -8
- package/dist/device/Device.d.ts.map +1 -1
- package/dist/device/DeviceCommands.d.ts +5 -7
- package/dist/device/DeviceCommands.d.ts.map +1 -1
- package/dist/events/device.d.ts +0 -3
- package/dist/events/device.d.ts.map +1 -1
- package/dist/events/ui-request.d.ts +1 -2
- package/dist/events/ui-request.d.ts.map +1 -1
- package/dist/events/ui-response.d.ts +0 -1
- package/dist/events/ui-response.d.ts.map +1 -1
- package/dist/index.d.ts +9 -23
- package/dist/index.js +69 -188
- package/dist/inject.d.ts.map +1 -1
- package/dist/types/api/index.d.ts +0 -2
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/utils/deviceFeaturesUtils.d.ts +2 -16
- package/dist/utils/deviceFeaturesUtils.d.ts.map +1 -1
- package/dist/utils/patch.d.ts +1 -1
- package/dist/utils/patch.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/api/GetPassphraseState.ts +3 -19
- package/src/api/allnetwork/AllNetworkGetAddress.ts +20 -18
- package/src/api/evm/EVMSignTypedData.ts +2 -2
- package/src/api/helpers/hexUtils.ts +29 -0
- package/src/api/index.ts +0 -1
- package/src/core/index.ts +7 -12
- package/src/data/messages/messages.json +2 -57
- package/src/device/Device.ts +7 -54
- package/src/device/DeviceCommands.ts +4 -15
- package/src/events/device.ts +0 -4
- package/src/events/ui-request.ts +1 -2
- package/src/events/ui-response.ts +0 -1
- package/src/inject.ts +0 -2
- package/src/types/api/index.ts +0 -2
- package/src/utils/deviceFeaturesUtils.ts +7 -71
- package/dist/api/device/DeviceUnlock.d.ts +0 -7
- package/dist/api/device/DeviceUnlock.d.ts.map +0 -1
- package/dist/types/api/deviceUnlock.d.ts +0 -4
- package/dist/types/api/deviceUnlock.d.ts.map +0 -1
- package/src/api/device/DeviceUnlock.ts +0 -26
- package/src/types/api/deviceUnlock.ts +0 -4
|
@@ -3021,8 +3021,7 @@
|
|
|
3021
3021
|
"ButtonRequest_Success": 17,
|
|
3022
3022
|
"ButtonRequest_Warning": 18,
|
|
3023
3023
|
"ButtonRequest_PassphraseEntry": 19,
|
|
3024
|
-
"ButtonRequest_PinEntry": 20
|
|
3025
|
-
"ButtonRequest_AttachPin": 8000
|
|
3024
|
+
"ButtonRequest_PinEntry": 20
|
|
3026
3025
|
}
|
|
3027
3026
|
}
|
|
3028
3027
|
}
|
|
@@ -3072,10 +3071,6 @@
|
|
|
3072
3071
|
"options": {
|
|
3073
3072
|
"deprecated": true
|
|
3074
3073
|
}
|
|
3075
|
-
},
|
|
3076
|
-
"exists_attach_pin_user": {
|
|
3077
|
-
"type": "bool",
|
|
3078
|
-
"id": 8000
|
|
3079
3074
|
}
|
|
3080
3075
|
}
|
|
3081
3076
|
},
|
|
@@ -3095,10 +3090,6 @@
|
|
|
3095
3090
|
"on_device": {
|
|
3096
3091
|
"type": "bool",
|
|
3097
3092
|
"id": 3
|
|
3098
|
-
},
|
|
3099
|
-
"on_device_attach_pin": {
|
|
3100
|
-
"type": "bool",
|
|
3101
|
-
"id": 8000
|
|
3102
3093
|
}
|
|
3103
3094
|
}
|
|
3104
3095
|
},
|
|
@@ -6060,10 +6051,6 @@
|
|
|
6060
6051
|
"derive_cardano": {
|
|
6061
6052
|
"type": "bool",
|
|
6062
6053
|
"id": 3
|
|
6063
|
-
},
|
|
6064
|
-
"passphrase_state": {
|
|
6065
|
-
"type": "string",
|
|
6066
|
-
"id": 8000
|
|
6067
6054
|
}
|
|
6068
6055
|
}
|
|
6069
6056
|
},
|
|
@@ -6442,14 +6429,6 @@
|
|
|
6442
6429
|
"onekey_se04_state": {
|
|
6443
6430
|
"type": "OneKeySEState",
|
|
6444
6431
|
"id": 624
|
|
6445
|
-
},
|
|
6446
|
-
"attach_to_pin_user": {
|
|
6447
|
-
"type": "bool",
|
|
6448
|
-
"id": 625
|
|
6449
|
-
},
|
|
6450
|
-
"unlocked_attach_pin": {
|
|
6451
|
-
"type": "bool",
|
|
6452
|
-
"id": 626
|
|
6453
6432
|
}
|
|
6454
6433
|
},
|
|
6455
6434
|
"nested": {
|
|
@@ -7554,38 +7533,6 @@
|
|
|
7554
7533
|
}
|
|
7555
7534
|
}
|
|
7556
7535
|
},
|
|
7557
|
-
"GetPassphraseState": {
|
|
7558
|
-
"fields": {
|
|
7559
|
-
"passphrase_state": {
|
|
7560
|
-
"type": "string",
|
|
7561
|
-
"id": 1
|
|
7562
|
-
},
|
|
7563
|
-
"_only_main_pin": {
|
|
7564
|
-
"type": "bool",
|
|
7565
|
-
"id": 2
|
|
7566
|
-
},
|
|
7567
|
-
"allow_create_attach_pin": {
|
|
7568
|
-
"type": "bool",
|
|
7569
|
-
"id": 3
|
|
7570
|
-
}
|
|
7571
|
-
}
|
|
7572
|
-
},
|
|
7573
|
-
"PassphraseState": {
|
|
7574
|
-
"fields": {
|
|
7575
|
-
"passphrase_state": {
|
|
7576
|
-
"type": "string",
|
|
7577
|
-
"id": 1
|
|
7578
|
-
},
|
|
7579
|
-
"session_id": {
|
|
7580
|
-
"type": "bytes",
|
|
7581
|
-
"id": 2
|
|
7582
|
-
},
|
|
7583
|
-
"unlocked_attach_pin": {
|
|
7584
|
-
"type": "bool",
|
|
7585
|
-
"id": 3
|
|
7586
|
-
}
|
|
7587
|
-
}
|
|
7588
|
-
},
|
|
7589
7536
|
"MoneroTransactionSourceEntry": {
|
|
7590
7537
|
"fields": {
|
|
7591
7538
|
"outputs": {
|
|
@@ -12197,9 +12144,7 @@
|
|
|
12197
12144
|
"MessageType_ListResDir": 10023,
|
|
12198
12145
|
"MessageType_FileInfoList": 10024,
|
|
12199
12146
|
"MessageType_OnekeyGetFeatures": 10025,
|
|
12200
|
-
"MessageType_OnekeyFeatures": 10026
|
|
12201
|
-
"MessageType_GetPassphraseState": 10028,
|
|
12202
|
-
"MessageType_PassphraseState": 10029
|
|
12147
|
+
"MessageType_OnekeyFeatures": 10026
|
|
12203
12148
|
}
|
|
12204
12149
|
},
|
|
12205
12150
|
"google": {
|
package/src/device/Device.ts
CHANGED
|
@@ -33,13 +33,7 @@ import {
|
|
|
33
33
|
type Features,
|
|
34
34
|
type UnavailableCapabilities,
|
|
35
35
|
} from '../types';
|
|
36
|
-
import {
|
|
37
|
-
DEVICE,
|
|
38
|
-
DeviceButtonRequestPayload,
|
|
39
|
-
DeviceFeaturesPayload,
|
|
40
|
-
PassphraseRequestPayload,
|
|
41
|
-
UI_REQUEST,
|
|
42
|
-
} from '../events';
|
|
36
|
+
import { DEVICE, DeviceButtonRequestPayload, DeviceFeaturesPayload, UI_REQUEST } from '../events';
|
|
43
37
|
import { PROTO } from '../constants';
|
|
44
38
|
import { DataManager } from '../data-manager';
|
|
45
39
|
import TransportManager from '../data-manager/TransportManager';
|
|
@@ -67,11 +61,7 @@ export interface DeviceEvents {
|
|
|
67
61
|
[DEVICE.PASSPHRASE_ON_DEVICE]: [Device, ((response: any) => void)?];
|
|
68
62
|
[DEVICE.BUTTON]: [Device, DeviceButtonRequestPayload];
|
|
69
63
|
[DEVICE.FEATURES]: [Device, DeviceFeaturesPayload];
|
|
70
|
-
[DEVICE.PASSPHRASE]: [
|
|
71
|
-
Device,
|
|
72
|
-
PassphraseRequestPayload,
|
|
73
|
-
(response: PassphrasePromptResponse, error?: Error) => void
|
|
74
|
-
];
|
|
64
|
+
[DEVICE.PASSPHRASE]: [Device, (response: PassphrasePromptResponse, error?: Error) => void];
|
|
75
65
|
[DEVICE.SELECT_DEVICE_IN_BOOTLOADER_FOR_WEB_DEVICE]: [
|
|
76
66
|
Device,
|
|
77
67
|
(err: any, deviceId: string) => void
|
|
@@ -333,26 +323,6 @@ export class Device extends EventEmitter {
|
|
|
333
323
|
Log.debug('tryFixInternalState session cache: ', deviceSessionCache);
|
|
334
324
|
}
|
|
335
325
|
|
|
336
|
-
// attach to pin to fix internal state
|
|
337
|
-
updateInternalState(state: string, deviceId: string, sessionId: string | null = null) {
|
|
338
|
-
Log.debug(
|
|
339
|
-
'updateInternalState session param: ',
|
|
340
|
-
`device_id: ${deviceId}`,
|
|
341
|
-
`passphraseState: ${state}`,
|
|
342
|
-
`sessionId: ${sessionId}`
|
|
343
|
-
);
|
|
344
|
-
|
|
345
|
-
if (sessionId) {
|
|
346
|
-
deviceSessionCache[this.generateStateKey(deviceId, state)] = sessionId;
|
|
347
|
-
// delete the old sessionId
|
|
348
|
-
const oldKey = `${deviceId}`;
|
|
349
|
-
if (deviceSessionCache[oldKey]) {
|
|
350
|
-
delete deviceSessionCache[oldKey];
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
Log.debug('updateInternalState session cache: ', deviceSessionCache);
|
|
354
|
-
}
|
|
355
|
-
|
|
356
326
|
private setInternalState(state: string, initSession?: boolean) {
|
|
357
327
|
Log.debug(
|
|
358
328
|
'setInternalState session param: ',
|
|
@@ -391,7 +361,7 @@ export class Device extends EventEmitter {
|
|
|
391
361
|
}
|
|
392
362
|
|
|
393
363
|
async initialize(options?: InitOptions) {
|
|
394
|
-
|
|
364
|
+
Log.debug('initialize param:', options);
|
|
395
365
|
|
|
396
366
|
this.passphraseState = options?.passphraseState;
|
|
397
367
|
|
|
@@ -408,14 +378,8 @@ export class Device extends EventEmitter {
|
|
|
408
378
|
if (options?.deriveCardano) {
|
|
409
379
|
payload.derive_cardano = true;
|
|
410
380
|
}
|
|
411
|
-
payload.passphrase_state = options?.passphraseState;
|
|
412
381
|
|
|
413
|
-
|
|
414
|
-
console.log('=====>>>>>> initialize device begin: ', payload, {
|
|
415
|
-
deviceId: options?.deviceId,
|
|
416
|
-
passphraseState: options?.passphraseState,
|
|
417
|
-
initSession: options?.initSession,
|
|
418
|
-
});
|
|
382
|
+
Log.debug('initialize payload:', payload);
|
|
419
383
|
|
|
420
384
|
try {
|
|
421
385
|
// @ts-expect-error
|
|
@@ -429,7 +393,6 @@ export class Device extends EventEmitter {
|
|
|
429
393
|
}),
|
|
430
394
|
]);
|
|
431
395
|
|
|
432
|
-
console.log('=====>>>>>> initialize device end: ', message);
|
|
433
396
|
this._updateFeatures(message, options?.initSession);
|
|
434
397
|
await TransportManager.reconfigure(this.features);
|
|
435
398
|
} catch (error) {
|
|
@@ -730,22 +693,12 @@ export class Device extends EventEmitter {
|
|
|
730
693
|
return false;
|
|
731
694
|
}
|
|
732
695
|
|
|
733
|
-
async checkPassphraseStateSafety(passphraseState?: string
|
|
696
|
+
async checkPassphraseStateSafety(passphraseState?: string) {
|
|
734
697
|
if (!this.features) return false;
|
|
735
|
-
const
|
|
736
|
-
await getPassphraseStateWithRefreshDeviceInfo(this, {
|
|
737
|
-
expectPassphraseState: passphraseState,
|
|
738
|
-
onlyMainPin: useEmptyPassphraseState,
|
|
739
|
-
});
|
|
740
|
-
|
|
741
|
-
// Main wallet and unlock Attach Pin, throw safe error
|
|
742
|
-
if (unlockedAttachPin && useEmptyPassphraseState) {
|
|
743
|
-
this.clearInternalState();
|
|
744
|
-
return Promise.reject(ERRORS.TypedError(HardwareErrorCode.DeviceCheckUnlockTypeError));
|
|
745
|
-
}
|
|
698
|
+
const newState = await getPassphraseStateWithRefreshDeviceInfo(this);
|
|
746
699
|
|
|
747
700
|
// When exists passphraseState, check passphraseState
|
|
748
|
-
if (passphraseState && passphraseState !==
|
|
701
|
+
if (passphraseState && passphraseState !== newState) {
|
|
749
702
|
this.clearInternalState();
|
|
750
703
|
return false;
|
|
751
704
|
}
|
|
@@ -4,13 +4,12 @@ import TransportManager from '../data-manager/TransportManager';
|
|
|
4
4
|
import DataManager from '../data-manager/DataManager';
|
|
5
5
|
import { patchFeatures, getLogger, LoggerNames, getDeviceType } from '../utils';
|
|
6
6
|
import type { Device } from './Device';
|
|
7
|
-
import { DEVICE
|
|
7
|
+
import { DEVICE } from '../events';
|
|
8
8
|
import { DeviceModelToTypes } from '../types';
|
|
9
9
|
|
|
10
10
|
export type PassphrasePromptResponse = {
|
|
11
11
|
passphrase?: string;
|
|
12
12
|
passphraseOnDevice?: boolean;
|
|
13
|
-
attachPinOnDevice?: boolean;
|
|
14
13
|
cache?: boolean;
|
|
15
14
|
};
|
|
16
15
|
|
|
@@ -439,17 +438,8 @@ export class DeviceCommands {
|
|
|
439
438
|
}
|
|
440
439
|
|
|
441
440
|
if (res.type === 'PassphraseRequest') {
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
existsAttachPinUser,
|
|
445
|
-
}).then(response => {
|
|
446
|
-
const { passphrase, passphraseOnDevice, attachPinOnDevice } = response;
|
|
447
|
-
|
|
448
|
-
// Attach PIN on device
|
|
449
|
-
if (attachPinOnDevice && existsAttachPinUser) {
|
|
450
|
-
return this._commonCall('PassphraseAck', { on_device_attach_pin: true });
|
|
451
|
-
}
|
|
452
|
-
|
|
441
|
+
return this._promptPassphrase().then(response => {
|
|
442
|
+
const { passphrase, passphraseOnDevice } = response;
|
|
453
443
|
return !passphraseOnDevice
|
|
454
444
|
? this._commonCall('PassphraseAck', { passphrase })
|
|
455
445
|
: this._commonCall('PassphraseAck', { on_device: true });
|
|
@@ -511,7 +501,7 @@ export class DeviceCommands {
|
|
|
511
501
|
});
|
|
512
502
|
}
|
|
513
503
|
|
|
514
|
-
_promptPassphrase(
|
|
504
|
+
_promptPassphrase() {
|
|
515
505
|
return new Promise<PassphrasePromptResponse>((resolve, reject) => {
|
|
516
506
|
const cancelAndReject = (_error?: Error) =>
|
|
517
507
|
cancelDeviceInPrompt(this.device, false)
|
|
@@ -537,7 +527,6 @@ export class DeviceCommands {
|
|
|
537
527
|
this.device.emit(
|
|
538
528
|
DEVICE.PASSPHRASE,
|
|
539
529
|
this.device,
|
|
540
|
-
options,
|
|
541
530
|
(response: PassphrasePromptResponse, error?: Error) => {
|
|
542
531
|
this.device.clearCancelableAction();
|
|
543
532
|
if (error) {
|
package/src/events/device.ts
CHANGED
|
@@ -44,10 +44,6 @@ export interface DeviceButtonRequestPayload extends Omit<PROTO.ButtonRequest, 'c
|
|
|
44
44
|
code?: PROTO.ButtonRequest['code'] | 'ButtonRequest_FirmwareUpdate';
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
export type PassphraseRequestPayload = {
|
|
48
|
-
existsAttachPinUser?: boolean;
|
|
49
|
-
};
|
|
50
|
-
|
|
51
47
|
export interface DeviceButtonRequest {
|
|
52
48
|
type: typeof DEVICE.BUTTON;
|
|
53
49
|
payload: DeviceButtonRequestPayload & { device: Device | null };
|
package/src/events/ui-request.ts
CHANGED
|
@@ -66,7 +66,7 @@ export type UiRequestDeviceAction = {
|
|
|
66
66
|
type: typeof UI_REQUEST.REQUEST_PIN;
|
|
67
67
|
payload: {
|
|
68
68
|
device: Device;
|
|
69
|
-
type?: PROTO.PinMatrixRequestType | 'ButtonRequest_PinEntry'
|
|
69
|
+
type?: PROTO.PinMatrixRequestType | 'ButtonRequest_PinEntry';
|
|
70
70
|
};
|
|
71
71
|
};
|
|
72
72
|
|
|
@@ -80,7 +80,6 @@ export interface UiRequestPassphrase {
|
|
|
80
80
|
payload: {
|
|
81
81
|
device: Device;
|
|
82
82
|
passphraseState?: string;
|
|
83
|
-
existsAttachPinUser?: boolean;
|
|
84
83
|
};
|
|
85
84
|
}
|
|
86
85
|
|
package/src/inject.ts
CHANGED
|
@@ -138,8 +138,6 @@ export const createCoreApi = (
|
|
|
138
138
|
call({ ...params, connectId, method: 'getPassphraseState' }),
|
|
139
139
|
deviceCancel: (connectId, params) => call({ ...params, connectId, method: 'deviceCancel' }),
|
|
140
140
|
deviceLock: (connectId, params) => call({ ...params, connectId, method: 'deviceLock' }),
|
|
141
|
-
deviceUnlock: (connectId, params) =>
|
|
142
|
-
call({ ...params, useEmptyPassphrase: true, connectId, method: 'deviceUnlock' }),
|
|
143
141
|
|
|
144
142
|
getNextU2FCounter: (connectId, params) =>
|
|
145
143
|
call({ ...params, connectId, method: 'getNextU2FCounter' }),
|
package/src/types/api/index.ts
CHANGED
|
@@ -35,7 +35,6 @@ import { deviceSupportFeatures } from './deviceSupportFeatures';
|
|
|
35
35
|
import { deviceFullyUploadResource } from './deviceFullyUploadResource';
|
|
36
36
|
import { deviceUpdateBootloader } from './deviceUpdateBootloader';
|
|
37
37
|
import { deviceLock } from './deviceLock';
|
|
38
|
-
import { deviceUnlock } from './deviceUnlock';
|
|
39
38
|
import { deviceCancel } from './deviceCancel';
|
|
40
39
|
|
|
41
40
|
import { getNextU2FCounter } from './getNextU2FCounter';
|
|
@@ -215,7 +214,6 @@ export type CoreApi = {
|
|
|
215
214
|
deviceFullyUploadResource: typeof deviceFullyUploadResource;
|
|
216
215
|
deviceUpdateBootloader: typeof deviceUpdateBootloader;
|
|
217
216
|
deviceLock: typeof deviceLock;
|
|
218
|
-
deviceUnlock: typeof deviceUnlock;
|
|
219
217
|
deviceCancel: typeof deviceCancel;
|
|
220
218
|
getNextU2FCounter: typeof getNextU2FCounter;
|
|
221
219
|
setU2FCounter: typeof setU2FCounter;
|
|
@@ -73,30 +73,11 @@ export const supportNewPassphrase = (features?: Features): SupportFeatureType =>
|
|
|
73
73
|
return { support: semver.gte(currentVersion, '2.4.0'), require: '2.4.0' };
|
|
74
74
|
};
|
|
75
75
|
|
|
76
|
-
export const getPassphraseStateWithRefreshDeviceInfo = async (
|
|
77
|
-
device: Device,
|
|
78
|
-
options?: {
|
|
79
|
-
expectPassphraseState?: string;
|
|
80
|
-
onlyMainPin?: boolean;
|
|
81
|
-
}
|
|
82
|
-
) => {
|
|
76
|
+
export const getPassphraseStateWithRefreshDeviceInfo = async (device: Device) => {
|
|
83
77
|
const { features, commands } = device;
|
|
84
78
|
const locked = features?.unlocked === false;
|
|
85
79
|
|
|
86
|
-
const
|
|
87
|
-
features,
|
|
88
|
-
commands,
|
|
89
|
-
{
|
|
90
|
-
...options,
|
|
91
|
-
}
|
|
92
|
-
);
|
|
93
|
-
|
|
94
|
-
// Attach to pin try to fix internal state
|
|
95
|
-
if (newSession && passphraseState && features?.device_id) {
|
|
96
|
-
console.log('=====>>>>>> run updateInternalState newSession:', newSession);
|
|
97
|
-
device.updateInternalState(passphraseState, features.device_id, newSession);
|
|
98
|
-
}
|
|
99
|
-
|
|
80
|
+
const passphraseState = await getPassphraseState(features, commands);
|
|
100
81
|
const isModeT =
|
|
101
82
|
getDeviceType(features) === EDeviceType.Touch || getDeviceType(features) === EDeviceType.Pro;
|
|
102
83
|
|
|
@@ -112,55 +93,14 @@ export const getPassphraseStateWithRefreshDeviceInfo = async (
|
|
|
112
93
|
await device.getFeatures();
|
|
113
94
|
}
|
|
114
95
|
|
|
115
|
-
return
|
|
96
|
+
return passphraseState;
|
|
116
97
|
};
|
|
117
98
|
|
|
118
99
|
export const getPassphraseState = async (
|
|
119
100
|
features: Features | undefined,
|
|
120
|
-
commands: DeviceCommands
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
onlyMainPin?: boolean;
|
|
124
|
-
// createAttachPinWallet?: boolean;
|
|
125
|
-
}
|
|
126
|
-
): Promise<{
|
|
127
|
-
passphraseState: string | undefined;
|
|
128
|
-
newSession: string | undefined;
|
|
129
|
-
unlockedAttachPin: boolean | undefined;
|
|
130
|
-
}> => {
|
|
131
|
-
if (!features)
|
|
132
|
-
return { passphraseState: undefined, newSession: undefined, unlockedAttachPin: undefined };
|
|
133
|
-
|
|
134
|
-
const firmwareVersion = getDeviceFirmwareVersion(features);
|
|
135
|
-
const deviceType = getDeviceType(features);
|
|
136
|
-
|
|
137
|
-
if (deviceType === EDeviceType.Pro && semver.gte(firmwareVersion.join('.'), '4.13.2')) {
|
|
138
|
-
console.log(
|
|
139
|
-
'=====>>>>>> getPassphraseState begin: ',
|
|
140
|
-
options?.onlyMainPin,
|
|
141
|
-
options?.expectPassphraseState
|
|
142
|
-
);
|
|
143
|
-
|
|
144
|
-
const { message, type } = await commands.typedCall('GetPassphraseState', 'PassphraseState', {
|
|
145
|
-
passphrase_state: options?.onlyMainPin ? undefined : options?.expectPassphraseState,
|
|
146
|
-
// allow_create_attach_pin: options?.createAttachPinWallet,
|
|
147
|
-
// _only_main_pin: options?.onlyMainPin,
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
console.log('=====>>>>>> getPassphraseState end: result ', message);
|
|
151
|
-
|
|
152
|
-
// @ts-expect-error
|
|
153
|
-
if (type === 'CallMethodError') {
|
|
154
|
-
throw ERRORS.TypedError(HardwareErrorCode.RuntimeError, 'Get the passphrase state error');
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
return {
|
|
158
|
-
passphraseState: message.passphrase_state,
|
|
159
|
-
newSession: message.session_id,
|
|
160
|
-
unlockedAttachPin: message.unlocked_attach_pin,
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
|
|
101
|
+
commands: DeviceCommands
|
|
102
|
+
) => {
|
|
103
|
+
if (!features) return false;
|
|
164
104
|
const { message, type } = await commands.typedCall('GetAddress', 'Address', {
|
|
165
105
|
address_n: [toHardened(44), toHardened(1), toHardened(0), 0, 0],
|
|
166
106
|
coin_name: 'Testnet',
|
|
@@ -173,11 +113,7 @@ export const getPassphraseState = async (
|
|
|
173
113
|
throw ERRORS.TypedError(HardwareErrorCode.RuntimeError, 'Get the passphrase state error');
|
|
174
114
|
}
|
|
175
115
|
|
|
176
|
-
return
|
|
177
|
-
passphraseState: message.address,
|
|
178
|
-
newSession: undefined,
|
|
179
|
-
unlockedAttachPin: undefined,
|
|
180
|
-
};
|
|
116
|
+
return message.address;
|
|
181
117
|
};
|
|
182
118
|
|
|
183
119
|
export const supportBatchPublicKey = (
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { LockDevice } from '@onekeyfe/hd-transport';
|
|
2
|
-
import { BaseMethod } from '../BaseMethod';
|
|
3
|
-
export default class DeviceUnlock extends BaseMethod<LockDevice> {
|
|
4
|
-
init(): void;
|
|
5
|
-
run(): Promise<import("@onekeyfe/hd-transport").Features>;
|
|
6
|
-
}
|
|
7
|
-
//# sourceMappingURL=DeviceUnlock.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DeviceUnlock.d.ts","sourceRoot":"","sources":["../../../src/api/device/DeviceUnlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG3C,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,UAAU,CAAC,UAAU,CAAC;IAC9D,IAAI;IAIE,GAAG;CAeV"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"deviceUnlock.d.ts","sourceRoot":"","sources":["../../../src/types/api/deviceUnlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAExD,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { LockDevice } from '@onekeyfe/hd-transport';
|
|
2
|
-
import { ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
|
|
3
|
-
import { BaseMethod } from '../BaseMethod';
|
|
4
|
-
import { toHardened } from '../helpers/pathUtils';
|
|
5
|
-
|
|
6
|
-
export default class DeviceUnlock extends BaseMethod<LockDevice> {
|
|
7
|
-
init() {
|
|
8
|
-
this.useDevicePassphraseState = false;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
async run() {
|
|
12
|
-
const { type } = await this.device.commands.typedCall('GetAddress', 'Address', {
|
|
13
|
-
address_n: [toHardened(44), toHardened(1), toHardened(0), 0, 0],
|
|
14
|
-
coin_name: 'Testnet',
|
|
15
|
-
script_type: 'SPENDADDRESS',
|
|
16
|
-
show_display: false,
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
// @ts-expect-error
|
|
20
|
-
if (type === 'CallMethodError') {
|
|
21
|
-
throw ERRORS.TypedError(HardwareErrorCode.RuntimeError, 'Get the passphrase state error');
|
|
22
|
-
}
|
|
23
|
-
const res = await this.device.commands.typedCall('GetFeatures', 'Features');
|
|
24
|
-
return Promise.resolve(res.message);
|
|
25
|
-
}
|
|
26
|
-
}
|