@onekeyfe/hd-core 1.2.0-alpha.40 → 1.2.0-alpha.41
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__/AllNetworkGetAddressBase.tracing.test.ts +0 -78
- package/__tests__/DeviceEventRegistration.test.ts +0 -6
- package/__tests__/connectSettings.test.ts +47 -5
- package/__tests__/firmware-update/check-all-firmware-release.test.ts +175 -0
- package/__tests__/firmware-update/firmware-artifact-source.test.ts +119 -0
- package/__tests__/firmware-update/firmware-host-binding.test.ts +70 -0
- package/__tests__/firmware-update/firmware-preparation-error.test.ts +27 -0
- package/__tests__/firmware-update/firmware-update-capabilities.test.ts +13 -0
- package/__tests__/firmware-update/firmware-update-plan.test.ts +593 -0
- package/__tests__/firmware-update/firmware-update-prepared-plan.test.ts +213 -0
- package/__tests__/firmware-update/firmware-update-v2-download-before-boot.test.ts +59 -31
- package/__tests__/firmware-update/firmware-update-v3-reconnect.test.ts +58 -0
- package/__tests__/firmware-update/firmware-upload-source.test.ts +70 -0
- package/__tests__/get-device-state.test.ts +12 -132
- package/__tests__/homescreen.test.ts +1 -41
- package/__tests__/logBlockEvent.test.ts +1 -1
- package/__tests__/open-wallet-session.test.ts +18 -259
- package/__tests__/protocol-v2-unlock-policy.test.ts +35 -86
- package/__tests__/protocol-v2.test.ts +632 -333
- package/__tests__/public-pro2-api-boundary.test.ts +0 -1
- package/dist/api/BaseMethod.d.ts +1 -3
- package/dist/api/BaseMethod.d.ts.map +1 -1
- package/dist/api/CheckAllFirmwareRelease.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV2.d.ts +11 -0
- package/dist/api/FirmwareUpdateV2.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV3.d.ts +7 -3
- package/dist/api/FirmwareUpdateV3.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV4.d.ts +22 -5
- package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
- package/dist/api/GetPassphraseState.d.ts.map +1 -1
- package/dist/api/OpenWalletSession.d.ts.map +1 -1
- package/dist/api/allnetwork/AllNetworkGetAddressBase.d.ts.map +1 -1
- package/dist/api/device/DeviceUpdateBootloader.d.ts +5 -1
- package/dist/api/device/DeviceUpdateBootloader.d.ts.map +1 -1
- package/dist/api/firmware/FirmwareArtifactSource.d.ts +25 -0
- package/dist/api/firmware/FirmwareArtifactSource.d.ts.map +1 -0
- package/dist/api/firmware/FirmwareHostBinding.d.ts +6 -0
- package/dist/api/firmware/FirmwareHostBinding.d.ts.map +1 -0
- package/dist/api/firmware/FirmwarePreparationError.d.ts +3 -0
- package/dist/api/firmware/FirmwarePreparationError.d.ts.map +1 -0
- package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts +8 -0
- package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts.map +1 -1
- package/dist/api/firmware/FirmwareUpdateCapabilities.d.ts +3 -0
- package/dist/api/firmware/FirmwareUpdateCapabilities.d.ts.map +1 -0
- package/dist/api/firmware/FirmwareUpdatePlan.d.ts +25 -0
- package/dist/api/firmware/FirmwareUpdatePlan.d.ts.map +1 -0
- package/dist/api/firmware/FirmwareUpdatePreparedPlan.d.ts +30 -0
- package/dist/api/firmware/FirmwareUpdatePreparedPlan.d.ts.map +1 -0
- package/dist/api/firmware/getBinary.d.ts +7 -0
- package/dist/api/firmware/getBinary.d.ts.map +1 -1
- package/dist/api/firmware/progressThrottle.d.ts +3 -0
- package/dist/api/firmware/progressThrottle.d.ts.map +1 -0
- package/dist/api/firmware/updateBootloader.d.ts +2 -0
- package/dist/api/firmware/updateBootloader.d.ts.map +1 -1
- package/dist/api/firmware/uploadFirmware.d.ts +9 -1
- package/dist/api/firmware/uploadFirmware.d.ts.map +1 -1
- package/dist/api/helpers/protocolV2FileWrite.d.ts +0 -2
- package/dist/api/helpers/protocolV2FileWrite.d.ts.map +1 -1
- package/dist/api/index.d.ts +0 -1
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/protocol-v2/ProtocolInfoRequest.d.ts.map +1 -1
- package/dist/api/stellar/StellarSignTransaction.d.ts +1 -1
- package/dist/core/deviceEventRegistration.d.ts +0 -2
- package/dist/core/deviceEventRegistration.d.ts.map +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/data-manager/DataManager.d.ts +1 -0
- package/dist/data-manager/DataManager.d.ts.map +1 -1
- package/dist/data-manager/connectSettings.d.ts.map +1 -1
- package/dist/device/Device.d.ts +4 -22
- package/dist/device/Device.d.ts.map +1 -1
- package/dist/events/device.d.ts +0 -4
- package/dist/events/device.d.ts.map +1 -1
- package/dist/events/logBlockEvent.d.ts.map +1 -1
- package/dist/events/ui-request.d.ts +2 -27
- package/dist/events/ui-request.d.ts.map +1 -1
- package/dist/index.d.ts +181 -88
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3162 -1614
- package/dist/inject.d.ts.map +1 -1
- package/dist/lowLevelInject.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/features.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/lockedError.d.ts +2 -0
- package/dist/protocols/protocol-v2/lockedError.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/uiInteraction.d.ts +3 -3
- package/dist/protocols/protocol-v2/uiInteraction.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/unlockPolicy.d.ts +3 -1
- package/dist/protocols/protocol-v2/unlockPolicy.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/unlockRetry.d.ts +10 -0
- package/dist/protocols/protocol-v2/unlockRetry.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/walletSession.d.ts +1 -4
- package/dist/protocols/protocol-v2/walletSession.d.ts.map +1 -1
- package/dist/topLevelInject.d.ts.map +1 -1
- package/dist/types/api/checkAllFirmwareRelease.d.ts +4 -0
- package/dist/types/api/checkAllFirmwareRelease.d.ts.map +1 -1
- package/dist/types/api/deviceUpdateBootloader.d.ts +6 -0
- package/dist/types/api/deviceUpdateBootloader.d.ts.map +1 -1
- package/dist/types/api/export.d.ts +4 -1
- package/dist/types/api/export.d.ts.map +1 -1
- package/dist/types/api/firmwareUpdate.d.ts +69 -0
- package/dist/types/api/firmwareUpdate.d.ts.map +1 -1
- package/dist/types/api/firmwareUpdateCapabilities.d.ts +9 -0
- package/dist/types/api/firmwareUpdateCapabilities.d.ts.map +1 -0
- package/dist/types/api/firmwareUpdatePlan.d.ts +28 -0
- package/dist/types/api/firmwareUpdatePlan.d.ts.map +1 -0
- package/dist/types/api/firmwareUpdatePreparedPlan.d.ts +42 -0
- package/dist/types/api/firmwareUpdatePreparedPlan.d.ts.map +1 -0
- package/dist/types/api/index.d.ts +10 -3
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/types/api/protocolV2.d.ts +0 -3
- package/dist/types/api/protocolV2.d.ts.map +1 -1
- package/dist/types/settings.d.ts +13 -0
- package/dist/types/settings.d.ts.map +1 -1
- package/dist/utils/deviceFeaturesUtils.d.ts +0 -2
- package/dist/utils/deviceFeaturesUtils.d.ts.map +1 -1
- package/dist/utils/homescreen.d.ts +0 -4
- package/dist/utils/homescreen.d.ts.map +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/patch.d.ts +1 -1
- package/dist/utils/patch.d.ts.map +1 -1
- package/dist/utils/pro2Wallpaper.d.ts +0 -10
- package/dist/utils/pro2Wallpaper.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/api/BaseMethod.ts +10 -8
- package/src/api/CheckAllFirmwareRelease.ts +51 -6
- package/src/api/FirmwareUpdateV2.ts +298 -120
- package/src/api/FirmwareUpdateV3.ts +263 -57
- package/src/api/FirmwareUpdateV4.ts +748 -281
- package/src/api/GetPassphraseState.ts +1 -7
- package/src/api/OpenWalletSession.ts +17 -54
- package/src/api/allnetwork/AllNetworkGetAddressBase.ts +11 -32
- package/src/api/device/DeviceUnlock.ts +1 -1
- package/src/api/device/DeviceUpdateBootloader.ts +122 -6
- package/src/api/firmware/FirmwareArtifactSource.ts +278 -0
- package/src/api/firmware/FirmwareHostBinding.ts +100 -0
- package/src/api/firmware/FirmwarePreparationError.ts +12 -0
- package/src/api/firmware/FirmwareUpdateBaseMethod.ts +57 -0
- package/src/api/firmware/FirmwareUpdateCapabilities.ts +9 -0
- package/src/api/firmware/FirmwareUpdatePlan.ts +745 -0
- package/src/api/firmware/FirmwareUpdatePreparedPlan.ts +392 -0
- package/src/api/firmware/progressThrottle.ts +44 -0
- package/src/api/firmware/updateBootloader.ts +19 -4
- package/src/api/firmware/uploadFirmware.ts +140 -22
- package/src/api/helpers/protocolV2FileWrite.ts +4 -11
- package/src/api/index.ts +0 -1
- package/src/api/protocol-v2/ProtocolInfoRequest.ts +1 -3
- package/src/core/deviceEventRegistration.ts +0 -4
- package/src/core/index.ts +75 -118
- package/src/data/messages/messages-protocol-v2.json +0 -10
- package/src/data-manager/DataManager.ts +33 -33
- package/src/data-manager/connectSettings.ts +11 -0
- package/src/device/Device.ts +21 -193
- package/src/events/device.ts +0 -4
- package/src/events/logBlockEvent.ts +0 -1
- package/src/events/ui-request.ts +2 -32
- package/src/index.ts +5 -0
- package/src/inject.ts +22 -3
- package/src/lowLevelInject.ts +5 -1
- package/src/protocols/protocol-v2/features.ts +2 -9
- package/src/protocols/protocol-v2/lockedError.ts +10 -0
- package/src/protocols/protocol-v2/uiInteraction.ts +5 -31
- package/src/protocols/protocol-v2/unlockPolicy.ts +105 -1
- package/src/protocols/protocol-v2/unlockRetry.ts +109 -0
- package/src/protocols/protocol-v2/walletSession.ts +18 -93
- package/src/topLevelInject.ts +5 -1
- package/src/types/api/checkAllFirmwareRelease.ts +4 -0
- package/src/types/api/deviceUpdateBootloader.ts +6 -0
- package/src/types/api/export.ts +18 -0
- package/src/types/api/firmwareUpdate.ts +76 -0
- package/src/types/api/firmwareUpdateCapabilities.ts +9 -0
- package/src/types/api/firmwareUpdatePlan.ts +38 -0
- package/src/types/api/firmwareUpdatePreparedPlan.ts +53 -0
- package/src/types/api/index.ts +14 -2
- package/src/types/api/protocolV2.ts +0 -13
- package/src/types/settings.ts +13 -0
- package/src/utils/deviceFeaturesUtils.ts +0 -4
- package/src/utils/homescreen.ts +6 -32
- package/src/utils/index.ts +1 -6
- package/src/utils/pro2Wallpaper.ts +8 -35
- package/__tests__/deviceUploadNft.test.ts +0 -187
- package/__tests__/pro2Nft.test.ts +0 -108
- package/__tests__/protocol-v2-ui-lifecycle.test.ts +0 -56
- package/__tests__/uiProgressThrottle.test.ts +0 -74
- package/dist/api/protocol-v2/DeviceUploadNft.d.ts +0 -30
- package/dist/api/protocol-v2/DeviceUploadNft.d.ts.map +0 -1
- package/dist/protocols/protocol-v2/unlockPolicyRunner.d.ts +0 -22
- package/dist/protocols/protocol-v2/unlockPolicyRunner.d.ts.map +0 -1
- package/dist/utils/pro2Nft.d.ts +0 -29
- package/dist/utils/pro2Nft.d.ts.map +0 -1
- package/dist/utils/uiProgressThrottle.d.ts +0 -3
- package/dist/utils/uiProgressThrottle.d.ts.map +0 -1
- package/src/api/protocol-v2/DeviceUploadNft.ts +0 -166
- package/src/protocols/protocol-v2/unlockPolicyRunner.ts +0 -117
- package/src/utils/pro2Nft.ts +0 -91
- package/src/utils/uiProgressThrottle.ts +0 -63
|
@@ -1,14 +1,53 @@
|
|
|
1
1
|
import type { EFirmwareType } from '@onekeyfe/hd-shared';
|
|
2
2
|
import type { PROTO } from '../../constants';
|
|
3
3
|
import type { Params, Response } from '../params';
|
|
4
|
+
import type { FirmwareUpdatePreparedPlan } from './firmwareUpdatePreparedPlan';
|
|
4
5
|
|
|
5
6
|
type IUpdateType = 'firmware' | 'ble';
|
|
6
7
|
|
|
8
|
+
export interface FirmwareArtifactReference {
|
|
9
|
+
artifactRef: string;
|
|
10
|
+
size: number;
|
|
11
|
+
sha256: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface FirmwareArtifactReader {
|
|
15
|
+
open(input: { artifactRef: string }): Promise<{
|
|
16
|
+
readerId: string;
|
|
17
|
+
size: number;
|
|
18
|
+
}>;
|
|
19
|
+
read(input: { readerId: string; offset: number; length: number }): Promise<{
|
|
20
|
+
data: ArrayBuffer;
|
|
21
|
+
bytesRead: number;
|
|
22
|
+
eof: boolean;
|
|
23
|
+
}>;
|
|
24
|
+
close(input: { readerId: string }): Promise<void>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface FirmwareUpdateHostBinding {
|
|
28
|
+
artifactReader: FirmwareArtifactReader;
|
|
29
|
+
}
|
|
30
|
+
|
|
7
31
|
export interface FirmwareUpdateBinaryParams {
|
|
8
32
|
binary: ArrayBuffer;
|
|
9
33
|
updateType: IUpdateType;
|
|
10
34
|
}
|
|
11
35
|
|
|
36
|
+
export interface FirmwareUpdateArtifactParams {
|
|
37
|
+
preparedPlan: FirmwareUpdatePreparedPlan;
|
|
38
|
+
hostBindingGeneration: number;
|
|
39
|
+
artifact: FirmwareArtifactReference;
|
|
40
|
+
resourceArtifact?: FirmwareArtifactReference;
|
|
41
|
+
resourceEntries?: Array<{
|
|
42
|
+
entryName: string;
|
|
43
|
+
artifact: FirmwareArtifactReference;
|
|
44
|
+
}>;
|
|
45
|
+
updateType: IUpdateType;
|
|
46
|
+
forcedUpdateRes?: boolean;
|
|
47
|
+
isUpdateBootloader?: boolean;
|
|
48
|
+
firmwareType?: EFirmwareType;
|
|
49
|
+
}
|
|
50
|
+
|
|
12
51
|
export interface FirmwareUpdateParams {
|
|
13
52
|
version?: number[];
|
|
14
53
|
updateType: IUpdateType;
|
|
@@ -37,8 +76,14 @@ export declare function firmwareUpdateV2(
|
|
|
37
76
|
connectId: string | undefined,
|
|
38
77
|
params: Params<FirmwareUpdateBinaryParams & Platform>
|
|
39
78
|
): Response<PROTO.Success>;
|
|
79
|
+
export declare function firmwareUpdateV2(
|
|
80
|
+
connectId: string | undefined,
|
|
81
|
+
params: Params<FirmwareUpdateArtifactParams & Platform>
|
|
82
|
+
): Response<PROTO.Success>;
|
|
40
83
|
|
|
41
84
|
export interface FirmwareUpdateV3Params {
|
|
85
|
+
preparedPlan?: FirmwareUpdatePreparedPlan;
|
|
86
|
+
hostBindingGeneration?: number;
|
|
42
87
|
bleVersion?: number[];
|
|
43
88
|
bleBinary?: ArrayBuffer;
|
|
44
89
|
chunkSize?: number;
|
|
@@ -55,6 +100,17 @@ export interface FirmwareUpdateV3Params {
|
|
|
55
100
|
firmwareType?: EFirmwareType;
|
|
56
101
|
|
|
57
102
|
platform: IPlatform;
|
|
103
|
+
|
|
104
|
+
artifactReader?: FirmwareArtifactReader;
|
|
105
|
+
artifacts?: {
|
|
106
|
+
ble?: FirmwareArtifactReference;
|
|
107
|
+
firmware?: FirmwareArtifactReference;
|
|
108
|
+
bootloader?: FirmwareArtifactReference;
|
|
109
|
+
resourceEntries?: Array<{
|
|
110
|
+
entryName: string;
|
|
111
|
+
artifact: FirmwareArtifactReference;
|
|
112
|
+
}>;
|
|
113
|
+
};
|
|
58
114
|
}
|
|
59
115
|
|
|
60
116
|
/**
|
|
@@ -73,10 +129,14 @@ export type FirmwareUpdateV4Target =
|
|
|
73
129
|
| 'se04';
|
|
74
130
|
|
|
75
131
|
export interface FirmwareUpdateV4Params {
|
|
132
|
+
preparedPlan?: FirmwareUpdatePreparedPlan;
|
|
133
|
+
hostBindingGeneration?: number;
|
|
76
134
|
platform: IPlatform;
|
|
135
|
+
expectedDeviceId?: string;
|
|
77
136
|
chunkSize?: number;
|
|
78
137
|
firmwareType?: EFirmwareType;
|
|
79
138
|
targetsToUpdate?: FirmwareUpdateV4Target[];
|
|
139
|
+
expectedTargetVersions?: Partial<Record<FirmwareUpdateV4Target, string>>;
|
|
80
140
|
|
|
81
141
|
/** FW_MGMT_TARGET_ROMLOADER = 2; Pro2 cannot install it through firmwareUpdateV4. */
|
|
82
142
|
romloaderBinary?: ArrayBuffer;
|
|
@@ -102,8 +162,24 @@ export interface FirmwareUpdateV4Params {
|
|
|
102
162
|
binary: ArrayBuffer;
|
|
103
163
|
devicePath: string;
|
|
104
164
|
}>;
|
|
165
|
+
artifactReader?: FirmwareArtifactReader;
|
|
166
|
+
componentArtifacts?: Partial<
|
|
167
|
+
Record<Exclude<FirmwareUpdateV4Target, 'resource'>, FirmwareArtifactReference>
|
|
168
|
+
>;
|
|
169
|
+
resourceBundleArtifacts?: Array<{
|
|
170
|
+
name: string;
|
|
171
|
+
artifact: FirmwareArtifactReference;
|
|
172
|
+
}>;
|
|
105
173
|
}
|
|
106
174
|
|
|
175
|
+
export declare function registerFirmwareUpdateHostBinding(
|
|
176
|
+
binding: FirmwareUpdateHostBinding
|
|
177
|
+
): number;
|
|
178
|
+
|
|
179
|
+
export declare function unregisterFirmwareUpdateHostBinding(generation?: number): boolean;
|
|
180
|
+
|
|
181
|
+
export declare function getFirmwareUpdateHostBindingGeneration(): number;
|
|
182
|
+
|
|
107
183
|
export declare function firmwareUpdateV3(
|
|
108
184
|
connectId: string | undefined,
|
|
109
185
|
params: Params<FirmwareUpdateV3Params>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface FirmwareUpdateCapabilities {
|
|
2
|
+
planSchemaVersion: 2;
|
|
3
|
+
preparedPlanSchemaVersion: 2;
|
|
4
|
+
hostBindingProtocolVersion: 2;
|
|
5
|
+
manifestModes: Array<'external-only' | 'sdk-managed'>;
|
|
6
|
+
supportsArtifactReader: true;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export declare function getFirmwareUpdateCapabilities(): FirmwareUpdateCapabilities;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { FirmwareUpdateV4Target } from './firmwareUpdate';
|
|
2
|
+
import type { EFirmwareType } from '@onekeyfe/hd-shared';
|
|
3
|
+
|
|
4
|
+
export type FirmwareUpdatePlanArtifactRole =
|
|
5
|
+
| 'firmware'
|
|
6
|
+
| 'ble'
|
|
7
|
+
| 'bootloader'
|
|
8
|
+
| 'resource'
|
|
9
|
+
| 'component'
|
|
10
|
+
| 'resourceBundle';
|
|
11
|
+
|
|
12
|
+
export type FirmwareUpdatePlanTarget = 'firmware' | 'ble' | 'bootloader' | FirmwareUpdateV4Target;
|
|
13
|
+
|
|
14
|
+
export type FirmwareUpdatePlanForceTarget = 'firmware' | 'ble' | 'bootloader' | 'resource';
|
|
15
|
+
|
|
16
|
+
export interface FirmwareUpdatePlanArtifact {
|
|
17
|
+
artifactId: string;
|
|
18
|
+
role: FirmwareUpdatePlanArtifactRole;
|
|
19
|
+
target: FirmwareUpdatePlanTarget;
|
|
20
|
+
url: string;
|
|
21
|
+
container: 'raw' | 'zip';
|
|
22
|
+
logicalName?: string;
|
|
23
|
+
expectedSize?: number;
|
|
24
|
+
expectedSha256?: string;
|
|
25
|
+
targetVersion?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface FirmwareUpdatePlan {
|
|
29
|
+
schemaVersion: 2;
|
|
30
|
+
planDigest: string;
|
|
31
|
+
executor: 'v2' | 'v3' | 'v4';
|
|
32
|
+
deviceIdentity: string;
|
|
33
|
+
deviceModel: string;
|
|
34
|
+
firmwareType: EFirmwareType;
|
|
35
|
+
platform: 'native' | 'desktop' | 'ext' | 'web' | 'web-embed';
|
|
36
|
+
artifacts: FirmwareUpdatePlanArtifact[];
|
|
37
|
+
targetsToUpdate: FirmwareUpdatePlanTarget[];
|
|
38
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { FirmwareArtifactReference } from './firmwareUpdate';
|
|
2
|
+
import type {
|
|
3
|
+
FirmwareUpdatePlan,
|
|
4
|
+
FirmwareUpdatePlanArtifactRole,
|
|
5
|
+
FirmwareUpdatePlanTarget,
|
|
6
|
+
} from './firmwareUpdatePlan';
|
|
7
|
+
|
|
8
|
+
export interface FirmwareUpdatePreparedEntry {
|
|
9
|
+
entryName: string;
|
|
10
|
+
artifact: FirmwareArtifactReference;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface FirmwareUpdatePreparedArtifactInput {
|
|
14
|
+
artifactId: string;
|
|
15
|
+
artifact: FirmwareArtifactReference;
|
|
16
|
+
materializedEntries?: FirmwareUpdatePreparedEntry[];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface FirmwareUpdatePreparedArtifact {
|
|
20
|
+
artifactId: string;
|
|
21
|
+
role: FirmwareUpdatePlanArtifactRole;
|
|
22
|
+
target: FirmwareUpdatePlanTarget;
|
|
23
|
+
container: 'raw' | 'zip';
|
|
24
|
+
logicalName?: string;
|
|
25
|
+
targetVersion?: string;
|
|
26
|
+
artifact: FirmwareArtifactReference;
|
|
27
|
+
materializedEntries?: FirmwareUpdatePreparedEntry[];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface FirmwareUpdatePreparedPlan {
|
|
31
|
+
schemaVersion: 2;
|
|
32
|
+
preparedPlanDigest: string;
|
|
33
|
+
planDigest: string;
|
|
34
|
+
networkPolicy: 'forbid';
|
|
35
|
+
executor: FirmwareUpdatePlan['executor'];
|
|
36
|
+
deviceIdentity: string;
|
|
37
|
+
deviceModel: string;
|
|
38
|
+
firmwareType: FirmwareUpdatePlan['firmwareType'];
|
|
39
|
+
platform: FirmwareUpdatePlan['platform'];
|
|
40
|
+
leaseRef: string;
|
|
41
|
+
artifacts: FirmwareUpdatePreparedArtifact[];
|
|
42
|
+
targetsToUpdate: FirmwareUpdatePlanTarget[];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export declare function prepareFirmwareUpdatePlan(input: {
|
|
46
|
+
plan: FirmwareUpdatePlan;
|
|
47
|
+
leaseRef: string;
|
|
48
|
+
artifacts: FirmwareUpdatePreparedArtifactInput[];
|
|
49
|
+
}): FirmwareUpdatePreparedPlan;
|
|
50
|
+
|
|
51
|
+
export declare function validateFirmwareUpdatePreparedPlan(
|
|
52
|
+
value: unknown
|
|
53
|
+
): FirmwareUpdatePreparedPlan;
|
package/src/types/api/index.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
deviceGetOnboardingStatus,
|
|
3
3
|
deviceReboot,
|
|
4
|
-
deviceUploadNft,
|
|
5
4
|
deviceUploadWallpaper,
|
|
6
5
|
testProtocolV2Ping,
|
|
7
6
|
uploadPortfolio,
|
|
@@ -31,7 +30,15 @@ import type {
|
|
|
31
30
|
firmwareUpdateV2,
|
|
32
31
|
firmwareUpdateV3,
|
|
33
32
|
firmwareUpdateV4,
|
|
33
|
+
getFirmwareUpdateHostBindingGeneration,
|
|
34
|
+
registerFirmwareUpdateHostBinding,
|
|
35
|
+
unregisterFirmwareUpdateHostBinding,
|
|
34
36
|
} from './firmwareUpdate';
|
|
37
|
+
import type { getFirmwareUpdateCapabilities } from './firmwareUpdateCapabilities';
|
|
38
|
+
import type {
|
|
39
|
+
prepareFirmwareUpdatePlan,
|
|
40
|
+
validateFirmwareUpdatePreparedPlan,
|
|
41
|
+
} from './firmwareUpdatePreparedPlan';
|
|
35
42
|
import type { promptWebDeviceAccess } from './promptWebDeviceAccess';
|
|
36
43
|
import type { deviceReset } from './deviceReset';
|
|
37
44
|
import type { deviceRecovery } from './deviceRecovery';
|
|
@@ -228,6 +235,12 @@ export type CoreApi = {
|
|
|
228
235
|
firmwareUpdateV2: typeof firmwareUpdateV2;
|
|
229
236
|
firmwareUpdateV3: typeof firmwareUpdateV3;
|
|
230
237
|
firmwareUpdateV4: typeof firmwareUpdateV4;
|
|
238
|
+
registerFirmwareUpdateHostBinding: typeof registerFirmwareUpdateHostBinding;
|
|
239
|
+
unregisterFirmwareUpdateHostBinding: typeof unregisterFirmwareUpdateHostBinding;
|
|
240
|
+
getFirmwareUpdateHostBindingGeneration: typeof getFirmwareUpdateHostBindingGeneration;
|
|
241
|
+
getFirmwareUpdateCapabilities: typeof getFirmwareUpdateCapabilities;
|
|
242
|
+
prepareFirmwareUpdatePlan: typeof prepareFirmwareUpdatePlan;
|
|
243
|
+
validateFirmwareUpdatePreparedPlan: typeof validateFirmwareUpdatePreparedPlan;
|
|
231
244
|
cipherKeyValue: typeof cipherKeyValue;
|
|
232
245
|
|
|
233
246
|
/**
|
|
@@ -235,7 +248,6 @@ export type CoreApi = {
|
|
|
235
248
|
*/
|
|
236
249
|
deviceReboot: typeof deviceReboot;
|
|
237
250
|
deviceGetOnboardingStatus: typeof deviceGetOnboardingStatus;
|
|
238
|
-
deviceUploadNft: typeof deviceUploadNft;
|
|
239
251
|
deviceUploadWallpaper: typeof deviceUploadWallpaper;
|
|
240
252
|
uploadPortfolio: typeof uploadPortfolio;
|
|
241
253
|
|
|
@@ -5,10 +5,6 @@ import type {
|
|
|
5
5
|
DeviceUploadWallpaperParams,
|
|
6
6
|
DeviceUploadWallpaperResponse,
|
|
7
7
|
} from '../../api/protocol-v2/DeviceUploadWallpaper';
|
|
8
|
-
import type {
|
|
9
|
-
DeviceUploadNftParams,
|
|
10
|
-
DeviceUploadNftResponse,
|
|
11
|
-
} from '../../api/protocol-v2/DeviceUploadNft';
|
|
12
8
|
|
|
13
9
|
// Re-export implementation parameter types as the single source of truth.
|
|
14
10
|
export type { DeviceRebootParams, RebootTypeInput } from '../../api/protocol-v2/helpers';
|
|
@@ -16,10 +12,6 @@ export type {
|
|
|
16
12
|
DeviceUploadWallpaperParams,
|
|
17
13
|
DeviceUploadWallpaperResponse,
|
|
18
14
|
} from '../../api/protocol-v2/DeviceUploadWallpaper';
|
|
19
|
-
export type {
|
|
20
|
-
DeviceUploadNftParams,
|
|
21
|
-
DeviceUploadNftResponse,
|
|
22
|
-
} from '../../api/protocol-v2/DeviceUploadNft';
|
|
23
15
|
|
|
24
16
|
// ── Shared response shapes (Protocol V2 file system) ────────────────────
|
|
25
17
|
|
|
@@ -60,11 +52,6 @@ export declare function deviceUploadWallpaper(
|
|
|
60
52
|
params: CommonParams & DeviceUploadWallpaperParams
|
|
61
53
|
): Response<DeviceUploadWallpaperResponse>;
|
|
62
54
|
|
|
63
|
-
export declare function deviceUploadNft(
|
|
64
|
-
connectId: string,
|
|
65
|
-
params: CommonParams & DeviceUploadNftParams
|
|
66
|
-
): Response<DeviceUploadNftResponse>;
|
|
67
|
-
|
|
68
55
|
export declare function uploadPortfolio(
|
|
69
56
|
connectId: string,
|
|
70
57
|
params: {
|
package/src/types/settings.ts
CHANGED
|
@@ -31,6 +31,8 @@ export type ConnectSettings = {
|
|
|
31
31
|
timestamp: number;
|
|
32
32
|
isFrame?: boolean;
|
|
33
33
|
preRelease?: boolean;
|
|
34
|
+
firmwareManifestMode?: 'sdk-managed' | 'external-only';
|
|
35
|
+
preloadedConfig?: RemoteConfigResponse;
|
|
34
36
|
fetchConfig?: boolean;
|
|
35
37
|
extension?: string;
|
|
36
38
|
configFetcher?: (url: string) => Promise<RemoteConfigResponse | null>;
|
|
@@ -58,6 +60,7 @@ export type IProtocolV2FirmwareComponent = {
|
|
|
58
60
|
fingerprint?: string;
|
|
59
61
|
/** OKPP payload hash, used to detect same-version package changes. */
|
|
60
62
|
payloadHash?: string;
|
|
63
|
+
expectedSize?: number;
|
|
61
64
|
version?: IVersionArray;
|
|
62
65
|
};
|
|
63
66
|
|
|
@@ -67,6 +70,8 @@ export type IProtocolV2ResourceBundle = {
|
|
|
67
70
|
name: string;
|
|
68
71
|
/** Download URL. */
|
|
69
72
|
url: string;
|
|
73
|
+
fingerprint?: string;
|
|
74
|
+
expectedSize?: number;
|
|
70
75
|
/** Device target path, such as vol0:/bundles/images/images.okpkg. */
|
|
71
76
|
devicePath: string;
|
|
72
77
|
/** okpkg payload_version used to skip matching content after FileRead. */
|
|
@@ -88,10 +93,16 @@ export type IFirmwareReleaseInfo = {
|
|
|
88
93
|
firmwareType?: EFirmwareType;
|
|
89
94
|
/** Firmware UI resource */
|
|
90
95
|
resource?: string;
|
|
96
|
+
resourceFingerprint?: string;
|
|
97
|
+
resourceExpectedSize?: number;
|
|
91
98
|
/** Firmware full UI resource */
|
|
92
99
|
fullResource?: string;
|
|
100
|
+
fullResourceFingerprint?: string;
|
|
101
|
+
fullResourceExpectedSize?: number;
|
|
93
102
|
fullResourceRange?: string[];
|
|
94
103
|
bootloaderResource?: string;
|
|
104
|
+
bootloaderFingerprint?: string;
|
|
105
|
+
bootloaderExpectedSize?: number;
|
|
95
106
|
bootloaderVersion?: IVersionArray;
|
|
96
107
|
displayBootloaderVersion?: IVersionArray;
|
|
97
108
|
bootloaderRelatedFirmwareVersion?: IVersionArray;
|
|
@@ -104,6 +115,7 @@ export type IFirmwareReleaseInfo = {
|
|
|
104
115
|
[k in ILocale]: string;
|
|
105
116
|
};
|
|
106
117
|
fingerprint: string;
|
|
118
|
+
expectedSize?: number;
|
|
107
119
|
version: IVersionArray;
|
|
108
120
|
changelog: {
|
|
109
121
|
[k in ILocale]: string;
|
|
@@ -119,6 +131,7 @@ export type IBLEFirmwareReleaseInfo = {
|
|
|
119
131
|
webUpdate: string;
|
|
120
132
|
fingerprint: string;
|
|
121
133
|
fingerprintWeb: string;
|
|
134
|
+
expectedSize?: number;
|
|
122
135
|
version: IVersionArray;
|
|
123
136
|
changelog: {
|
|
124
137
|
[k in ILocale]: string;
|
|
@@ -106,7 +106,6 @@ export const getPassphraseStateWithRefreshDeviceInfo = async (
|
|
|
106
106
|
expectPassphraseState?: string;
|
|
107
107
|
onlyMainPin?: boolean;
|
|
108
108
|
initSession?: boolean;
|
|
109
|
-
deriveCardano?: boolean;
|
|
110
109
|
}
|
|
111
110
|
) => {
|
|
112
111
|
if (device.isProtocolV2()) {
|
|
@@ -122,7 +121,6 @@ export const getPassphraseStateWithRefreshDeviceInfo = async (
|
|
|
122
121
|
initSession: options?.initSession,
|
|
123
122
|
expectedPassphraseState: options?.expectPassphraseState,
|
|
124
123
|
onlyMainPin: options?.onlyMainPin,
|
|
125
|
-
deriveCardano: options?.deriveCardano,
|
|
126
124
|
});
|
|
127
125
|
}
|
|
128
126
|
|
|
@@ -187,7 +185,6 @@ export const getPassphraseState = async (
|
|
|
187
185
|
expectPassphraseState?: string;
|
|
188
186
|
onlyMainPin?: boolean;
|
|
189
187
|
initSession?: boolean;
|
|
190
|
-
deriveCardano?: boolean;
|
|
191
188
|
}
|
|
192
189
|
): Promise<{
|
|
193
190
|
passphraseState: string | undefined;
|
|
@@ -208,7 +205,6 @@ export const getPassphraseState = async (
|
|
|
208
205
|
initSession: options?.initSession,
|
|
209
206
|
expectedPassphraseState: options?.expectPassphraseState,
|
|
210
207
|
onlyMainPin: options?.onlyMainPin,
|
|
211
|
-
deriveCardano: options?.deriveCardano,
|
|
212
208
|
});
|
|
213
209
|
}
|
|
214
210
|
|
package/src/utils/homescreen.ts
CHANGED
|
@@ -4,12 +4,6 @@ import { EDeviceType } from '@onekeyfe/hd-shared';
|
|
|
4
4
|
import { getDeviceType } from './deviceInfoUtils';
|
|
5
5
|
import { getDeviceFirmwareVersion } from './deviceVersionUtils';
|
|
6
6
|
import { PRO2_WALLPAPER_HEIGHT, PRO2_WALLPAPER_WIDTH } from './pro2Wallpaper';
|
|
7
|
-
import {
|
|
8
|
-
PRO2_NFT_IMAGE_HEIGHT,
|
|
9
|
-
PRO2_NFT_IMAGE_WIDTH,
|
|
10
|
-
PRO2_NFT_THUMBNAIL_HEIGHT,
|
|
11
|
-
PRO2_NFT_THUMBNAIL_WIDTH,
|
|
12
|
-
} from './pro2Nft';
|
|
13
7
|
|
|
14
8
|
import type { Features, IDeviceType } from '../types';
|
|
15
9
|
|
|
@@ -308,31 +302,6 @@ type SizeConfig = {
|
|
|
308
302
|
radius?: number;
|
|
309
303
|
};
|
|
310
304
|
|
|
311
|
-
export const getNftSize = ({
|
|
312
|
-
deviceType,
|
|
313
|
-
thumbnail,
|
|
314
|
-
}: {
|
|
315
|
-
deviceType: IDeviceType;
|
|
316
|
-
thumbnail?: boolean;
|
|
317
|
-
}): SizeConfig | undefined => {
|
|
318
|
-
const sizes: Partial<Record<IDeviceType, { full: SizeConfig; thumbnail: SizeConfig }>> = {
|
|
319
|
-
touch: {
|
|
320
|
-
full: { width: 480, height: 800 },
|
|
321
|
-
thumbnail: { width: 238, height: 238 },
|
|
322
|
-
},
|
|
323
|
-
pro: {
|
|
324
|
-
full: { width: 480, height: 800 },
|
|
325
|
-
thumbnail: { width: 226, height: 226, radius: 40 },
|
|
326
|
-
},
|
|
327
|
-
pro2: {
|
|
328
|
-
full: { width: PRO2_NFT_IMAGE_WIDTH, height: PRO2_NFT_IMAGE_HEIGHT },
|
|
329
|
-
thumbnail: { width: PRO2_NFT_THUMBNAIL_WIDTH, height: PRO2_NFT_THUMBNAIL_HEIGHT },
|
|
330
|
-
},
|
|
331
|
-
};
|
|
332
|
-
|
|
333
|
-
return sizes[deviceType]?.[thumbnail ? 'thumbnail' : 'full'];
|
|
334
|
-
};
|
|
335
|
-
|
|
336
305
|
export const getHomeScreenSize = ({
|
|
337
306
|
deviceType,
|
|
338
307
|
homeScreenType,
|
|
@@ -343,7 +312,12 @@ export const getHomeScreenSize = ({
|
|
|
343
312
|
thumbnail?: boolean;
|
|
344
313
|
}) => {
|
|
345
314
|
if (deviceType === EDeviceType.Pro2) {
|
|
346
|
-
return thumbnail
|
|
315
|
+
return thumbnail
|
|
316
|
+
? undefined
|
|
317
|
+
: {
|
|
318
|
+
width: PRO2_WALLPAPER_WIDTH,
|
|
319
|
+
height: PRO2_WALLPAPER_HEIGHT,
|
|
320
|
+
};
|
|
347
321
|
}
|
|
348
322
|
|
|
349
323
|
const sizes: Partial<
|
package/src/utils/index.ts
CHANGED
|
@@ -54,12 +54,7 @@ export { getHDPath, getScriptType, getOutputScriptType } from '../api/helpers/pa
|
|
|
54
54
|
|
|
55
55
|
export const isBleConnect = (env: string) => env === 'react-native' || env === 'lowlevel';
|
|
56
56
|
|
|
57
|
-
export {
|
|
58
|
-
getHomeScreenHex,
|
|
59
|
-
getHomeScreenDefaultList,
|
|
60
|
-
getHomeScreenSize,
|
|
61
|
-
getNftSize,
|
|
62
|
-
} from './homescreen';
|
|
57
|
+
export { getHomeScreenHex, getHomeScreenDefaultList, getHomeScreenSize } from './homescreen';
|
|
63
58
|
export { encodePro2Wallpaper, PRO2_WALLPAPER_HEIGHT, PRO2_WALLPAPER_WIDTH } from './pro2Wallpaper';
|
|
64
59
|
export type { Pro2WallpaperColorFormat } from './pro2Wallpaper';
|
|
65
60
|
|
|
@@ -8,8 +8,6 @@ export const PRO2_WALLPAPER_HEIGHT = 1024;
|
|
|
8
8
|
|
|
9
9
|
export type Pro2WallpaperColorFormat = 'RGB565' | 'RGB565A8';
|
|
10
10
|
|
|
11
|
-
export type Pro2ImageAlphaMode = 'preserve' | 'black-background';
|
|
12
|
-
|
|
13
11
|
const COLOR_FORMAT_RGB565 = 0x12;
|
|
14
12
|
const COLOR_FORMAT_RGB565A8 = 0x14;
|
|
15
13
|
|
|
@@ -38,11 +36,10 @@ function align(value: number, boundary: number): number {
|
|
|
38
36
|
return Math.ceil(value / boundary) * boundary;
|
|
39
37
|
}
|
|
40
38
|
|
|
41
|
-
export function
|
|
39
|
+
export function encodePro2Wallpaper(options: {
|
|
42
40
|
width: number;
|
|
43
41
|
height: number;
|
|
44
42
|
rgba: Uint8Array | ArrayBuffer;
|
|
45
|
-
alphaMode?: Pro2ImageAlphaMode;
|
|
46
43
|
}): { data: Uint8Array; colorFormat: Pro2WallpaperColorFormat } {
|
|
47
44
|
const { width, height } = options;
|
|
48
45
|
if (!Number.isInteger(width) || width <= 0 || width > 0xffff) {
|
|
@@ -60,14 +57,11 @@ export function encodePro2Image(options: {
|
|
|
60
57
|
);
|
|
61
58
|
}
|
|
62
59
|
|
|
63
|
-
const alphaMode = options.alphaMode ?? 'preserve';
|
|
64
60
|
let hasTransparency = false;
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
break;
|
|
70
|
-
}
|
|
61
|
+
for (let index = 3; index < rgba.length; index += 4) {
|
|
62
|
+
if (rgba[index] !== 0xff) {
|
|
63
|
+
hasTransparency = true;
|
|
64
|
+
break;
|
|
71
65
|
}
|
|
72
66
|
}
|
|
73
67
|
|
|
@@ -91,22 +85,9 @@ export function encodePro2Image(options: {
|
|
|
91
85
|
for (let x = 0; x < width; x += 1) {
|
|
92
86
|
const sourceOffset = (y * width + x) * 4;
|
|
93
87
|
const thresholdIndex = ((y & 7) << 3) + (x & 7);
|
|
94
|
-
const
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
? Math.round((rgba[sourceOffset] * alpha) / 0xff)
|
|
98
|
-
: rgba[sourceOffset];
|
|
99
|
-
const greenChannel =
|
|
100
|
-
alphaMode === 'black-background'
|
|
101
|
-
? Math.round((rgba[sourceOffset + 1] * alpha) / 0xff)
|
|
102
|
-
: rgba[sourceOffset + 1];
|
|
103
|
-
const blueChannel =
|
|
104
|
-
alphaMode === 'black-background'
|
|
105
|
-
? Math.round((rgba[sourceOffset + 2] * alpha) / 0xff)
|
|
106
|
-
: rgba[sourceOffset + 2];
|
|
107
|
-
const red = Math.min(redChannel + RED_THRESHOLD[thresholdIndex], 0xff) & 0xf8;
|
|
108
|
-
const green = Math.min(greenChannel + GREEN_THRESHOLD[thresholdIndex], 0xff) & 0xfc;
|
|
109
|
-
const blue = Math.min(blueChannel + BLUE_THRESHOLD[thresholdIndex], 0xff) & 0xf8;
|
|
88
|
+
const red = Math.min(rgba[sourceOffset] + RED_THRESHOLD[thresholdIndex], 0xff) & 0xf8;
|
|
89
|
+
const green = Math.min(rgba[sourceOffset + 1] + GREEN_THRESHOLD[thresholdIndex], 0xff) & 0xfc;
|
|
90
|
+
const blue = Math.min(rgba[sourceOffset + 2] + BLUE_THRESHOLD[thresholdIndex], 0xff) & 0xf8;
|
|
110
91
|
const rgb565 = ((red >> 3) << 11) | ((green >> 2) << 5) | (blue >> 3);
|
|
111
92
|
const rgbOffset = 12 + y * stride + x * 2;
|
|
112
93
|
data[rgbOffset] = rgb565 & 0xff;
|
|
@@ -120,11 +101,3 @@ export function encodePro2Image(options: {
|
|
|
120
101
|
|
|
121
102
|
return { data, colorFormat };
|
|
122
103
|
}
|
|
123
|
-
|
|
124
|
-
export function encodePro2Wallpaper(options: {
|
|
125
|
-
width: number;
|
|
126
|
-
height: number;
|
|
127
|
-
rgba: Uint8Array | ArrayBuffer;
|
|
128
|
-
}): { data: Uint8Array; colorFormat: Pro2WallpaperColorFormat } {
|
|
129
|
-
return encodePro2Image(options);
|
|
130
|
-
}
|