@onekeyfe/hd-core 1.2.0-alpha.20 → 1.2.0-alpha.21
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__/device-lifecycle-events.test.ts +1 -1
- package/__tests__/device-settings.test.ts +110 -5
- package/__tests__/device-state-events.test.ts +3 -3
- package/__tests__/device-state-mapper.test.ts +15 -3
- package/__tests__/device-state-store.test.ts +1 -1
- package/__tests__/deviceSettings.test.ts +55 -15
- package/__tests__/evmLedgerLegacySafety.test.ts +6 -5
- package/__tests__/get-device-state.test.ts +7 -0
- package/__tests__/protocol-v2.test.ts +40 -153
- package/__tests__/public-device-state-api.test.ts +19 -15
- package/__tests__/public-pro2-api-boundary.test.ts +20 -1
- package/dist/api/BaseMethod.d.ts +0 -3
- package/dist/api/BaseMethod.d.ts.map +1 -1
- package/dist/api/UploadPortfolio.d.ts +0 -1
- package/dist/api/UploadPortfolio.d.ts.map +1 -1
- package/dist/api/device/DeviceSettings.d.ts.map +1 -1
- package/dist/api/device/DeviceUnlock.d.ts +1 -1
- package/dist/api/device/DeviceUnlock.d.ts.map +1 -1
- package/dist/api/index.d.ts +0 -3
- package/dist/api/index.d.ts.map +1 -1
- package/dist/core/RequestQueue.d.ts +1 -19
- package/dist/core/RequestQueue.d.ts.map +1 -1
- package/dist/core/index.d.ts +0 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/device/Device.d.ts +1 -1
- package/dist/device/DeviceFeaturesState.d.ts +0 -1
- package/dist/device/DeviceFeaturesState.d.ts.map +1 -1
- package/dist/device/DeviceStateMapper.d.ts.map +1 -1
- package/dist/deviceProfile/buildDeviceFeatures.d.ts.map +1 -1
- package/dist/events/call.d.ts +0 -7
- package/dist/events/call.d.ts.map +1 -1
- package/dist/events/core.d.ts +2 -2
- package/dist/events/core.d.ts.map +1 -1
- package/dist/events/iframe.d.ts +0 -1
- package/dist/events/iframe.d.ts.map +1 -1
- package/dist/index.d.ts +59 -55
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +169 -310
- package/dist/inject.d.ts +2 -3
- package/dist/inject.d.ts.map +1 -1
- package/dist/lowLevelInject.d.ts +1 -2
- package/dist/lowLevelInject.d.ts.map +1 -1
- package/dist/topLevelInject.d.ts.map +1 -1
- package/dist/types/api/deviceSettings.d.ts +2 -2
- package/dist/types/api/deviceSettings.d.ts.map +1 -1
- package/dist/types/api/deviceUnlock.d.ts +2 -2
- package/dist/types/api/deviceUnlock.d.ts.map +1 -1
- package/dist/types/api/index.d.ts +1 -5
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/types/api/protocolV2.d.ts +1 -9
- package/dist/types/api/protocolV2.d.ts.map +1 -1
- package/dist/types/device.d.ts +4 -4
- package/dist/types/device.d.ts.map +1 -1
- package/dist/utils/deviceSettings.d.ts +36 -7
- package/dist/utils/deviceSettings.d.ts.map +1 -1
- package/dist/utils/index.d.ts +2 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/api/BaseMethod.ts +3 -9
- package/src/api/UploadPortfolio.ts +2 -12
- package/src/api/device/DeviceSettings.ts +66 -5
- package/src/api/device/DeviceUnlock.ts +2 -1
- package/src/api/index.ts +0 -3
- package/src/core/RequestQueue.ts +4 -123
- package/src/core/index.ts +25 -31
- package/src/device/Device.ts +1 -1
- package/src/device/DeviceFeaturesState.ts +0 -9
- package/src/device/DeviceStateMapper.ts +8 -7
- package/src/deviceProfile/buildDeviceFeatures.ts +2 -1
- package/src/events/call.ts +0 -6
- package/src/events/core.ts +0 -2
- package/src/events/iframe.ts +0 -1
- package/src/index.ts +0 -4
- package/src/inject.ts +0 -10
- package/src/lowLevelInject.ts +0 -3
- package/src/topLevelInject.ts +0 -2
- package/src/types/api/deviceSettings.ts +17 -2
- package/src/types/api/deviceUnlock.ts +5 -2
- package/src/types/api/index.ts +0 -7
- package/src/types/api/protocolV2.ts +0 -31
- package/src/types/device.ts +5 -3
- package/src/utils/deviceSettings.ts +130 -56
- package/src/utils/index.ts +18 -1
- package/__tests__/RequestQueue.test.ts +0 -140
- package/__tests__/UploadPortfolio.test.ts +0 -46
- package/dist/api/protocol-v2/DeviceSettingsGet.d.ts +0 -6
- package/dist/api/protocol-v2/DeviceSettingsGet.d.ts.map +0 -1
- package/dist/api/protocol-v2/DeviceSettingsPageShow.d.ts +0 -16
- package/dist/api/protocol-v2/DeviceSettingsPageShow.d.ts.map +0 -1
- package/dist/api/protocol-v2/DeviceSettingsSet.d.ts +0 -12
- package/dist/api/protocol-v2/DeviceSettingsSet.d.ts.map +0 -1
- package/src/api/protocol-v2/DeviceSettingsGet.ts +0 -18
- package/src/api/protocol-v2/DeviceSettingsPageShow.ts +0 -70
- package/src/api/protocol-v2/DeviceSettingsSet.ts +0 -44
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { BaseMethod } from '../BaseMethod';
|
|
2
|
-
import type { DeviceSettings } from '@onekeyfe/hd-transport';
|
|
3
|
-
export type DeviceSettingsSetParams = {
|
|
4
|
-
settings?: Omit<DeviceSettings, 'passphrase_enable' | 'airgap_mode'>;
|
|
5
|
-
};
|
|
6
|
-
export default class DeviceSettingsSet extends BaseMethod<{
|
|
7
|
-
settings: Omit<DeviceSettings, 'passphrase_enable' | 'airgap_mode'>;
|
|
8
|
-
}> {
|
|
9
|
-
init(): void;
|
|
10
|
-
run(): Promise<import("@onekeyfe/hd-transport").Success>;
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=DeviceSettingsSet.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DeviceSettingsSet.d.ts","sourceRoot":"","sources":["../../../src/api/protocol-v2/DeviceSettingsSet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAK3C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAE7D,MAAM,MAAM,uBAAuB,GAAG;IACpC,QAAQ,CAAC,EAAE,IAAI,CAAC,cAAc,EAAE,mBAAmB,GAAG,aAAa,CAAC,CAAC;CACtE,CAAC;AAEF,MAAM,CAAC,OAAO,OAAO,iBAAkB,SAAQ,UAAU,CAAC;IACxD,QAAQ,EAAE,IAAI,CAAC,cAAc,EAAE,mBAAmB,GAAG,aAAa,CAAC,CAAC;CACrE,CAAC;IACA,IAAI;IAwBE,GAAG;CAKV"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { BaseMethod } from '../BaseMethod';
|
|
2
|
-
import { mapDeviceSettingsToState } from '../../device/DeviceStateMapper';
|
|
3
|
-
|
|
4
|
-
export default class DeviceSettingsGet extends BaseMethod {
|
|
5
|
-
init() {
|
|
6
|
-
this.requireProtocolV2 = true;
|
|
7
|
-
this.unlockPolicy = 'none';
|
|
8
|
-
this.skipForceUpdateCheck = true;
|
|
9
|
-
this.useDevicePassphraseState = false;
|
|
10
|
-
this.params = undefined;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
async run() {
|
|
14
|
-
const res = await this.device.commands.typedCall('DeviceSettingsGet', 'DeviceSettings', {});
|
|
15
|
-
this.device.updateState(mapDeviceSettingsToState(res.message), 'apply-settings');
|
|
16
|
-
return Promise.resolve(res.message);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { DeviceSettingsPage } from '@onekeyfe/hd-transport';
|
|
2
|
-
|
|
3
|
-
import { BaseMethod } from '../BaseMethod';
|
|
4
|
-
import { invalidParameter } from '../helpers/filesystemValidation';
|
|
5
|
-
import { getProtocolV2SettingsBehavior } from '../../protocols/protocol-v2/settingsUnlockPolicy';
|
|
6
|
-
|
|
7
|
-
export type SupportedDeviceSettingsPage = DeviceSettingsPage;
|
|
8
|
-
|
|
9
|
-
export type DeviceSettingsPageShowParams = {
|
|
10
|
-
page?:
|
|
11
|
-
| SupportedDeviceSettingsPage
|
|
12
|
-
| 'DeviceReset'
|
|
13
|
-
| 'DevicePinChange'
|
|
14
|
-
| 'DevicePassphrase'
|
|
15
|
-
| 'DeviceAirgap';
|
|
16
|
-
fieldName?: string;
|
|
17
|
-
field_name?: string;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const SUPPORTED_PAGES = new Set<number>([
|
|
21
|
-
DeviceSettingsPage.DeviceReset,
|
|
22
|
-
DeviceSettingsPage.DevicePinChange,
|
|
23
|
-
DeviceSettingsPage.DevicePassphrase,
|
|
24
|
-
DeviceSettingsPage.DeviceAirgap,
|
|
25
|
-
]);
|
|
26
|
-
|
|
27
|
-
function normalizePage(value: DeviceSettingsPageShowParams['page']): SupportedDeviceSettingsPage {
|
|
28
|
-
const page = typeof value === 'string' ? DeviceSettingsPage[value] : value;
|
|
29
|
-
if (page !== undefined && SUPPORTED_PAGES.has(page)) {
|
|
30
|
-
return page;
|
|
31
|
-
}
|
|
32
|
-
throw invalidParameter(
|
|
33
|
-
'Parameter [page] must be DeviceReset, DevicePinChange, DevicePassphrase, or DeviceAirgap.'
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export default class DeviceSettingsPageShow extends BaseMethod<{
|
|
38
|
-
page: SupportedDeviceSettingsPage;
|
|
39
|
-
field_name?: string;
|
|
40
|
-
}> {
|
|
41
|
-
init() {
|
|
42
|
-
this.requireProtocolV2 = true;
|
|
43
|
-
this.skipForceUpdateCheck = true;
|
|
44
|
-
this.useDevicePassphraseState = false;
|
|
45
|
-
this.params = {
|
|
46
|
-
page: normalizePage(this.payload.page),
|
|
47
|
-
field_name: this.payload.field_name ?? this.payload.fieldName,
|
|
48
|
-
};
|
|
49
|
-
const behavior = getProtocolV2SettingsBehavior({
|
|
50
|
-
kind: 'page',
|
|
51
|
-
page: this.params.page,
|
|
52
|
-
});
|
|
53
|
-
this.unlockPolicy = behavior.unlockPolicy;
|
|
54
|
-
this.protocolV2UiInteraction = behavior.uiInteraction;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
async run() {
|
|
58
|
-
const res = await this.device.commands.typedCall(
|
|
59
|
-
'DeviceSettingsPageShow',
|
|
60
|
-
'Success',
|
|
61
|
-
this.params
|
|
62
|
-
);
|
|
63
|
-
if (this.params.page === DeviceSettingsPage.DevicePassphrase) {
|
|
64
|
-
await this.device.getDeviceState({ refreshSections: ['status'] });
|
|
65
|
-
} else if (this.params.page === DeviceSettingsPage.DeviceAirgap) {
|
|
66
|
-
await this.device.getDeviceState({ refreshSections: ['settings'] });
|
|
67
|
-
}
|
|
68
|
-
return Promise.resolve(res.message);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { BaseMethod } from '../BaseMethod';
|
|
2
|
-
import { mapDeviceSettingsToState } from '../../device/DeviceStateMapper';
|
|
3
|
-
import { getProtocolV2SettingsBehavior } from '../../protocols/protocol-v2/settingsUnlockPolicy';
|
|
4
|
-
import { invalidParameter } from '../helpers/filesystemValidation';
|
|
5
|
-
|
|
6
|
-
import type { DeviceSettings } from '@onekeyfe/hd-transport';
|
|
7
|
-
|
|
8
|
-
export type DeviceSettingsSetParams = {
|
|
9
|
-
settings?: Omit<DeviceSettings, 'passphrase_enable' | 'airgap_mode'>;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export default class DeviceSettingsSet extends BaseMethod<{
|
|
13
|
-
settings: Omit<DeviceSettings, 'passphrase_enable' | 'airgap_mode'>;
|
|
14
|
-
}> {
|
|
15
|
-
init() {
|
|
16
|
-
const { settings } = this.payload;
|
|
17
|
-
if (!settings || typeof settings !== 'object' || Array.isArray(settings)) {
|
|
18
|
-
throw invalidParameter('Parameter [settings] must be an object.');
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const {
|
|
22
|
-
passphrase_enable: _passphraseEnable,
|
|
23
|
-
airgap_mode: _airgapMode,
|
|
24
|
-
...supported
|
|
25
|
-
} = settings as DeviceSettings;
|
|
26
|
-
if (Object.keys(supported).length === 0) {
|
|
27
|
-
throw invalidParameter('Parameter [settings] must contain at least one supported setting.');
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
this.requireProtocolV2 = true;
|
|
31
|
-
const behavior = getProtocolV2SettingsBehavior({ kind: 'direct', settings: supported });
|
|
32
|
-
this.unlockPolicy = behavior.unlockPolicy;
|
|
33
|
-
this.skipForceUpdateCheck = true;
|
|
34
|
-
this.useDevicePassphraseState = false;
|
|
35
|
-
this.params = { settings: supported };
|
|
36
|
-
this.protocolV2UiInteraction = behavior.uiInteraction;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
async run() {
|
|
40
|
-
const res = await this.device.commands.typedCall('DeviceSettingsSet', 'Success', this.params);
|
|
41
|
-
this.device.updateState(mapDeviceSettingsToState(this.params.settings), 'apply-settings');
|
|
42
|
-
return Promise.resolve(res.message);
|
|
43
|
-
}
|
|
44
|
-
}
|