@onekeyfe/hd-core 1.2.0-alpha.15 → 1.2.0-alpha.17
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__/DeviceCommands.test.ts +77 -0
- package/__tests__/DeviceEventRegistration.test.ts +8 -3
- package/__tests__/deviceFeaturesUtils.test.ts +27 -0
- package/__tests__/evmLedgerLegacySafety.test.ts +3 -0
- package/__tests__/homescreen.test.ts +24 -0
- package/__tests__/protocol-v2.test.ts +1006 -204
- package/__tests__/protocolV2FileWrite.test.ts +28 -3
- package/__tests__/protocolV2UiInteraction.test.ts +266 -0
- package/dist/api/BaseMethod.d.ts +4 -0
- package/dist/api/BaseMethod.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV4.d.ts +3 -3
- package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
- package/dist/api/GetDeviceInfo.d.ts.map +1 -1
- package/dist/api/GetPassphraseState.d.ts.map +1 -1
- package/dist/api/UploadPortfolio.d.ts.map +1 -1
- package/dist/api/allnetwork/AllNetworkGetAddressBase.d.ts.map +1 -1
- package/dist/api/device/DeviceCancel.d.ts.map +1 -1
- package/dist/api/device/DeviceChangePin.d.ts.map +1 -1
- package/dist/api/device/DeviceLock.d.ts.map +1 -1
- package/dist/api/device/DeviceUnlock.d.ts.map +1 -1
- package/dist/api/device/DeviceWipe.d.ts.map +1 -1
- package/dist/api/helpers/protocolV2FileWrite.d.ts +1 -0
- package/dist/api/helpers/protocolV2FileWrite.d.ts.map +1 -1
- package/dist/api/index.d.ts +1 -1
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceInfoGet.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceSessionOpen.d.ts +28 -0
- package/dist/api/protocol-v2/DeviceSessionOpen.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceSettingsPageShow.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceSettingsSet.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceStatusGet.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceUploadWallpaper.d.ts.map +1 -1
- package/dist/core/deviceEventRegistration.d.ts +2 -2
- package/dist/core/deviceEventRegistration.d.ts.map +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/device/Device.d.ts +3 -3
- package/dist/device/Device.d.ts.map +1 -1
- package/dist/device/DeviceCommands.d.ts +3 -1
- package/dist/device/DeviceCommands.d.ts.map +1 -1
- package/dist/device/DevicePool.d.ts +2 -2
- package/dist/device/DevicePool.d.ts.map +1 -1
- package/dist/deviceProfile/buildDeviceFeatures.d.ts +6 -2
- package/dist/deviceProfile/buildDeviceFeatures.d.ts.map +1 -1
- package/dist/deviceProfile/buildDeviceProfile.d.ts +3 -2
- package/dist/deviceProfile/buildDeviceProfile.d.ts.map +1 -1
- package/dist/events/device.d.ts +4 -0
- package/dist/events/device.d.ts.map +1 -1
- package/dist/events/ui-request.d.ts +18 -2
- package/dist/events/ui-request.d.ts.map +1 -1
- package/dist/index.d.ts +56 -11
- package/dist/index.js +1014 -559
- package/dist/protocols/protocol-v2/features.d.ts +6 -18
- package/dist/protocols/protocol-v2/features.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/index.d.ts +1 -1
- package/dist/protocols/protocol-v2/index.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/uiInteraction.d.ts +39 -0
- package/dist/protocols/protocol-v2/uiInteraction.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/unlockRetry.d.ts +5 -3
- package/dist/protocols/protocol-v2/unlockRetry.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/walletSession.d.ts +2 -1
- package/dist/protocols/protocol-v2/walletSession.d.ts.map +1 -1
- package/dist/types/api/getDeviceInfo.d.ts +2 -1
- package/dist/types/api/getDeviceInfo.d.ts.map +1 -1
- package/dist/types/api/index.d.ts +2 -2
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/types/api/protocolV2.d.ts +4 -2
- package/dist/types/api/protocolV2.d.ts.map +1 -1
- package/dist/types/device.d.ts +2 -1
- package/dist/types/device.d.ts.map +1 -1
- package/dist/utils/deviceFeaturesUtils.d.ts.map +1 -1
- package/dist/utils/homescreen.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/BaseMethod.ts +10 -2
- package/src/api/FirmwareUpdateV4.ts +27 -73
- package/src/api/GetDeviceInfo.ts +9 -2
- package/src/api/GetPassphraseState.ts +5 -2
- package/src/api/UploadPortfolio.ts +2 -0
- package/src/api/allnetwork/AllNetworkGetAddressBase.ts +8 -13
- package/src/api/device/DeviceCancel.ts +1 -0
- package/src/api/device/DeviceChangePin.ts +23 -0
- package/src/api/device/DeviceLock.ts +1 -0
- package/src/api/device/DeviceUnlock.ts +9 -0
- package/src/api/device/DeviceWipe.ts +18 -0
- package/src/api/helpers/protocolV2FileWrite.ts +35 -11
- package/src/api/index.ts +1 -1
- package/src/api/protocol-v2/DeviceInfoGet.ts +0 -1
- package/src/api/protocol-v2/DeviceSessionOpen.ts +100 -0
- package/src/api/protocol-v2/DeviceSettingsPageShow.ts +9 -1
- package/src/api/protocol-v2/DeviceSettingsSet.ts +11 -1
- package/src/api/protocol-v2/DeviceStatusGet.ts +1 -0
- package/src/api/protocol-v2/DeviceUploadWallpaper.ts +2 -1
- package/src/core/deviceEventRegistration.ts +3 -8
- package/src/core/index.ts +36 -3
- package/src/data/messages/messages-protocol-v2.json +122 -23
- package/src/device/Device.ts +33 -41
- package/src/device/DeviceCommands.ts +22 -4
- package/src/device/DevicePool.ts +14 -6
- package/src/deviceProfile/buildDeviceFeatures.ts +21 -9
- package/src/deviceProfile/buildDeviceProfile.ts +27 -11
- package/src/events/device.ts +4 -0
- package/src/events/ui-request.ts +24 -2
- package/src/inject.ts +2 -2
- package/src/protocols/protocol-v2/features.ts +27 -20
- package/src/protocols/protocol-v2/index.ts +0 -1
- package/src/protocols/protocol-v2/uiInteraction.ts +209 -0
- package/src/protocols/protocol-v2/unlockRetry.ts +43 -3
- package/src/protocols/protocol-v2/walletSession.ts +122 -31
- package/src/types/api/getDeviceInfo.ts +6 -1
- package/src/types/api/index.ts +2 -2
- package/src/types/api/protocolV2.ts +5 -3
- package/src/types/device.ts +6 -1
- package/src/utils/deviceFeaturesUtils.ts +13 -0
- package/src/utils/homescreen.ts +10 -0
- package/dist/api/protocol-v2/DeviceSessionGet.d.ts +0 -6
- package/dist/api/protocol-v2/DeviceSessionGet.d.ts.map +0 -1
- package/src/api/protocol-v2/DeviceSessionGet.ts +0 -15
package/src/types/device.ts
CHANGED
|
@@ -2,7 +2,11 @@ import { EDeviceType, type EFirmwareType } from '@onekeyfe/hd-shared';
|
|
|
2
2
|
|
|
3
3
|
import type { IVersionArray } from './settings';
|
|
4
4
|
import type { PROTO } from '../constants';
|
|
5
|
-
import type {
|
|
5
|
+
import type {
|
|
6
|
+
DeviceStatus as ProtocolV2DeviceStatus,
|
|
7
|
+
OneKeyDeviceCommType,
|
|
8
|
+
ProtocolV2DeviceInfo,
|
|
9
|
+
} from '@onekeyfe/hd-transport';
|
|
6
10
|
|
|
7
11
|
export type DeviceStatus = 'available' | 'occupied' | 'used';
|
|
8
12
|
|
|
@@ -127,6 +131,7 @@ export type DeviceFeaturesRaw = {
|
|
|
127
131
|
protocolV1Features?: PROTO.Features;
|
|
128
132
|
protocolV1OneKeyFeatures?: OnekeyFeatures;
|
|
129
133
|
protocolV2DeviceInfo?: ProtocolV2DeviceInfo;
|
|
134
|
+
protocolV2DeviceStatus?: ProtocolV2DeviceStatus;
|
|
130
135
|
};
|
|
131
136
|
|
|
132
137
|
export type NormalizedFeatures = {
|
|
@@ -30,6 +30,17 @@ export const getSupportProtocolV1MessageSchema = (
|
|
|
30
30
|
const currentDeviceVersion = getDeviceFirmwareVersion(features).join('.');
|
|
31
31
|
const deviceType = getDeviceType(features);
|
|
32
32
|
|
|
33
|
+
if (
|
|
34
|
+
features.bootloaderMode === true &&
|
|
35
|
+
features.firmwarePresent === false &&
|
|
36
|
+
DeviceModelToTypes.model_mini.includes(deviceType)
|
|
37
|
+
) {
|
|
38
|
+
return {
|
|
39
|
+
messages: DataManager.messages.v1CurrentSchema,
|
|
40
|
+
protocolV1MessageSchema: 'v1CurrentSchema',
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
33
44
|
const deviceVersionConfigs =
|
|
34
45
|
PROTOBUF_MESSAGE_CONFIG[deviceType] ||
|
|
35
46
|
(DeviceTypeToModels[deviceType] &&
|
|
@@ -104,6 +115,7 @@ export const getPassphraseStateWithRefreshDeviceInfo = async (
|
|
|
104
115
|
return getProtocolV2WalletSession(device, {
|
|
105
116
|
initSession: options?.initSession,
|
|
106
117
|
expectedPassphraseState: options?.expectPassphraseState,
|
|
118
|
+
onlyMainPin: options?.onlyMainPin,
|
|
107
119
|
});
|
|
108
120
|
}
|
|
109
121
|
|
|
@@ -183,6 +195,7 @@ export const getPassphraseState = async (
|
|
|
183
195
|
return getProtocolV2WalletSession(device, {
|
|
184
196
|
initSession: options?.initSession,
|
|
185
197
|
expectedPassphraseState: options?.expectPassphraseState,
|
|
198
|
+
onlyMainPin: options?.onlyMainPin,
|
|
186
199
|
});
|
|
187
200
|
}
|
|
188
201
|
|
package/src/utils/homescreen.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { EDeviceType } from '@onekeyfe/hd-shared';
|
|
|
3
3
|
|
|
4
4
|
import { getDeviceType } from './deviceInfoUtils';
|
|
5
5
|
import { getDeviceFirmwareVersion } from './deviceVersionUtils';
|
|
6
|
+
import { PRO2_WALLPAPER_HEIGHT, PRO2_WALLPAPER_WIDTH } from './pro2Wallpaper';
|
|
6
7
|
|
|
7
8
|
import type { Features, IDeviceType } from '../types';
|
|
8
9
|
|
|
@@ -310,6 +311,15 @@ export const getHomeScreenSize = ({
|
|
|
310
311
|
homeScreenType: 'WallPaper' | 'Nft';
|
|
311
312
|
thumbnail?: boolean;
|
|
312
313
|
}) => {
|
|
314
|
+
if (deviceType === EDeviceType.Pro2) {
|
|
315
|
+
return thumbnail
|
|
316
|
+
? undefined
|
|
317
|
+
: {
|
|
318
|
+
width: PRO2_WALLPAPER_WIDTH,
|
|
319
|
+
height: PRO2_WALLPAPER_HEIGHT,
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
|
|
313
323
|
const sizes: Partial<
|
|
314
324
|
Record<
|
|
315
325
|
IDeviceType,
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DeviceSessionGet.d.ts","sourceRoot":"","sources":["../../../src/api/protocol-v2/DeviceSessionGet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,UAAU;IACtD,IAAI;IAOE,GAAG;CAIV"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { BaseMethod } from '../BaseMethod';
|
|
2
|
-
|
|
3
|
-
export default class DeviceSessionGet extends BaseMethod {
|
|
4
|
-
init() {
|
|
5
|
-
this.requireProtocolV2 = true;
|
|
6
|
-
this.useDevicePassphraseState = false;
|
|
7
|
-
this.skipForceUpdateCheck = true;
|
|
8
|
-
this.params = undefined;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
async run() {
|
|
12
|
-
const { message } = await this.device.commands.typedCall('DeviceSessionGet', 'DeviceSession', {});
|
|
13
|
-
return message;
|
|
14
|
-
}
|
|
15
|
-
}
|