@onekeyfe/hd-core 1.2.0-alpha.50 → 1.2.0-alpha.52
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__/check-all-firmware-release-protocol-v2.test.ts +3 -111
- package/__tests__/connectSettings.test.ts +47 -5
- package/__tests__/device-initialize-timeout.test.ts +56 -0
- package/__tests__/device-lifecycle-events.test.ts +3 -105
- 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-bootloader-poll.test.ts +200 -0
- package/__tests__/firmware-update/firmware-update-capabilities.test.ts +13 -0
- package/__tests__/firmware-update/firmware-update-plan-bootloader-identity.test.ts +294 -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__/method-protocol-support.test.ts +0 -19
- package/__tests__/open-wallet-session.test.ts +33 -446
- package/__tests__/protocol-v2-unlock-policy.test.ts +35 -196
- package/__tests__/protocol-v2.test.ts +1032 -1056
- package/__tests__/protocolV2UiInteraction.test.ts +0 -63
- package/__tests__/public-pro2-api-boundary.test.ts +0 -1
- package/__tests__/search-devices.test.ts +3 -12
- 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/FirmwareUpdate.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 +25 -9
- 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/SearchDevices.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 +9 -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 +32 -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 -2
- 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 +2 -4
- 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 +6 -29
- package/dist/device/Device.d.ts.map +1 -1
- package/dist/device/DeviceCommands.d.ts +4 -4
- package/dist/device/DevicePool.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-promise.d.ts +2 -4
- package/dist/events/ui-promise.d.ts.map +1 -1
- package/dist/events/ui-request.d.ts +2 -31
- package/dist/events/ui-request.d.ts.map +1 -1
- package/dist/events/ui-response.d.ts +2 -10
- package/dist/events/ui-response.d.ts.map +1 -1
- package/dist/index.d.ts +230 -203
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3469 -2419
- package/dist/inject.d.ts +1 -6
- 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 +4 -7
- 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 -1
- 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 +70 -2
- 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 -7
- 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/params.d.ts +0 -1
- package/dist/types/params.d.ts.map +1 -1
- package/dist/types/settings.d.ts +13 -22
- package/dist/types/settings.d.ts.map +1 -1
- package/dist/utils/deviceFeaturesCompat.d.ts +1 -0
- package/dist/utils/deviceFeaturesCompat.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 +53 -41
- package/src/api/FirmwareUpdate.ts +15 -7
- package/src/api/FirmwareUpdateV2.ts +316 -126
- package/src/api/FirmwareUpdateV3.ts +265 -63
- package/src/api/FirmwareUpdateV4.ts +937 -430
- package/src/api/GetPassphraseState.ts +1 -7
- package/src/api/OpenWalletSession.ts +17 -54
- package/src/api/SearchDevices.ts +1 -3
- 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 +83 -16
- package/src/api/firmware/FirmwareUpdateCapabilities.ts +9 -0
- package/src/api/firmware/FirmwareUpdatePlan.ts +772 -0
- package/src/api/firmware/FirmwareUpdatePreparedPlan.ts +415 -0
- package/src/api/firmware/progressThrottle.ts +44 -0
- package/src/api/firmware/updateBootloader.ts +19 -4
- package/src/api/firmware/uploadFirmware.ts +144 -39
- package/src/api/helpers/protocolV2FileWrite.ts +4 -11
- package/src/api/index.ts +0 -2
- package/src/api/protocol-v2/ProtocolInfoRequest.ts +1 -3
- package/src/core/deviceEventRegistration.ts +0 -4
- package/src/core/index.ts +83 -167
- package/src/data/messages/messages-protocol-v2.json +0 -25
- package/src/data-manager/DataManager.ts +38 -67
- package/src/data-manager/connectSettings.ts +11 -0
- package/src/device/Device.ts +42 -257
- package/src/device/DevicePool.ts +2 -7
- package/src/events/device.ts +0 -4
- package/src/events/logBlockEvent.ts +0 -1
- package/src/events/ui-promise.ts +2 -4
- package/src/events/ui-request.ts +2 -36
- package/src/events/ui-response.ts +2 -12
- package/src/index.ts +5 -0
- package/src/inject.ts +24 -60
- package/src/lowLevelInject.ts +8 -7
- 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 +6 -46
- 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 +30 -169
- package/src/topLevelInject.ts +8 -7
- package/src/types/api/checkAllFirmwareRelease.ts +4 -1
- package/src/types/api/deviceUpdateBootloader.ts +6 -0
- package/src/types/api/export.ts +18 -0
- package/src/types/api/firmwareUpdate.ts +76 -3
- 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 -13
- package/src/types/api/protocolV2.ts +0 -13
- package/src/types/params.ts +1 -7
- package/src/types/settings.ts +13 -42
- package/src/utils/deviceFeaturesCompat.ts +6 -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 -293
- package/__tests__/pro2Nft.test.ts +0 -108
- package/__tests__/protocol-binding.test.ts +0 -89
- package/__tests__/protocol-v2-resources.test.ts +0 -284
- package/__tests__/protocol-v2-ui-lifecycle.test.ts +0 -91
- package/__tests__/uiProgressThrottle.test.ts +0 -74
- package/__tests__/uiPromiseRegistry.test.ts +0 -86
- package/dist/api/DetectDeviceConnectProtocol.d.ts +0 -7
- package/dist/api/DetectDeviceConnectProtocol.d.ts.map +0 -1
- package/dist/api/protocol-v2/DeviceUploadNft.d.ts +0 -31
- package/dist/api/protocol-v2/DeviceUploadNft.d.ts.map +0 -1
- package/dist/core/uiPromiseRegistry.d.ts +0 -4
- package/dist/core/uiPromiseRegistry.d.ts.map +0 -1
- package/dist/protocols/protocol-v2/resources.d.ts +0 -30
- package/dist/protocols/protocol-v2/resources.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/types/api/detectDeviceConnectProtocol.d.ts +0 -4
- package/dist/types/api/detectDeviceConnectProtocol.d.ts.map +0 -1
- package/dist/utils/pro2Nft.d.ts +0 -31
- 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/DetectDeviceConnectProtocol.ts +0 -18
- package/src/api/protocol-v2/DeviceUploadNft.ts +0 -189
- package/src/core/uiPromiseRegistry.ts +0 -41
- package/src/protocols/protocol-v2/resources.ts +0 -359
- package/src/protocols/protocol-v2/unlockPolicyRunner.ts +0 -124
- package/src/types/api/detectDeviceConnectProtocol.ts +0 -7
- package/src/utils/pro2Nft.ts +0 -142
- package/src/utils/uiProgressThrottle.ts +0 -63
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
|
|
2
|
-
import { DeviceSessionPinType
|
|
2
|
+
import { DeviceSessionPinType } from '@onekeyfe/hd-transport';
|
|
3
3
|
|
|
4
4
|
import { DEVICE } from '../../events';
|
|
5
5
|
import { assertCompleteDeviceSession } from './deviceSession';
|
|
@@ -38,74 +38,32 @@ export async function refreshProtocolV2DeviceStatus(device: Device) {
|
|
|
38
38
|
return device.updateProtocolV2Status(status);
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
export async function ensureProtocolV2WalletSessionUnlocked(device: Device) {
|
|
42
|
-
if (!device.isProtocolV2() || device.isBootloader?.() || device.isRomloader?.()) {
|
|
43
|
-
return false;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
await refreshProtocolV2DeviceStatus(device);
|
|
47
|
-
if (device.state?.status.unlocked !== false) {
|
|
48
|
-
return false;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
await device.unlockDevice(DeviceSessionPinType.Main, {
|
|
52
|
-
source: 'unlock-coordinator',
|
|
53
|
-
reason: 'device-locked',
|
|
54
|
-
deviceOnly: true,
|
|
55
|
-
});
|
|
56
|
-
return true;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
41
|
const negotiateEventlessWalletSession = async (device: Device) => {
|
|
60
|
-
await device.
|
|
42
|
+
await device.commands.typedCall('ProtocolInfoRequest', 'ProtocolInfo', {
|
|
43
|
+
eventless_wallet_session: true,
|
|
44
|
+
});
|
|
61
45
|
};
|
|
62
46
|
|
|
63
47
|
const getDeviceSession = async (device: Device, request: DeviceSessionGet) =>
|
|
64
48
|
device.commands.typedCall('DeviceSessionGet', 'DeviceSession', request);
|
|
65
49
|
|
|
66
|
-
const buildDeviceSessionGetRequest = ({
|
|
67
|
-
sessionId,
|
|
68
|
-
expectedPassphraseState,
|
|
69
|
-
deriveCardano,
|
|
70
|
-
}: {
|
|
71
|
-
sessionId?: string;
|
|
72
|
-
expectedPassphraseState?: string;
|
|
73
|
-
deriveCardano?: boolean;
|
|
74
|
-
} = {}): DeviceSessionGet => ({
|
|
75
|
-
...(sessionId ? { session_id: sessionId } : {}),
|
|
76
|
-
...(expectedPassphraseState ? { btc_test_address: expectedPassphraseState } : {}),
|
|
77
|
-
seed_domains:
|
|
78
|
-
deriveCardano === undefined
|
|
79
|
-
? []
|
|
80
|
-
: [
|
|
81
|
-
DeviceSessionSeedDomain.SeedDomain_Standard,
|
|
82
|
-
...(deriveCardano ? [DeviceSessionSeedDomain.SeedDomain_Cardano] : []),
|
|
83
|
-
],
|
|
84
|
-
});
|
|
85
|
-
|
|
86
50
|
const askDevicePassphrase = async (device: Device, requestPayload: DeviceSessionAskPassphrase) => {
|
|
87
51
|
await device.commands.typedCall('DeviceSessionAskPassphrase', 'Success', requestPayload);
|
|
88
52
|
await refreshProtocolV2DeviceStatus(device);
|
|
89
53
|
};
|
|
90
54
|
|
|
91
|
-
const selectDeviceSession = async (
|
|
92
|
-
device: Device,
|
|
93
|
-
expectedPassphraseState?: string,
|
|
94
|
-
deriveCardano?: boolean
|
|
95
|
-
) => {
|
|
55
|
+
const selectDeviceSession = async (device: Device, expectedPassphraseState?: string) => {
|
|
96
56
|
const existsAttachPinUser = device.features?.attachToPinEnabled === true;
|
|
97
57
|
const metadata = {
|
|
98
58
|
source: 'wallet-session-coordinator' as const,
|
|
99
59
|
reason: expectedPassphraseState ? ('session-recovery' as const) : ('open-wallet' as const),
|
|
100
60
|
...(expectedPassphraseState ? { expectedPassphraseState } : {}),
|
|
101
61
|
};
|
|
102
|
-
const passphraseInteraction = device.createProtocolV2UiPhaseMetadata?.('passphrase', 'start');
|
|
103
62
|
const response = await device.commands.promptPassphrase(
|
|
104
63
|
{
|
|
105
64
|
existsAttachPinUser,
|
|
106
65
|
deviceOnly: false,
|
|
107
66
|
...metadata,
|
|
108
|
-
...(passphraseInteraction ? { interaction: passphraseInteraction } : {}),
|
|
109
67
|
},
|
|
110
68
|
{ cancelDeviceOnReject: false }
|
|
111
69
|
);
|
|
@@ -144,16 +102,9 @@ const selectDeviceSession = async (
|
|
|
144
102
|
'Attach PIN wallet selection is unavailable on this device.'
|
|
145
103
|
);
|
|
146
104
|
}
|
|
147
|
-
|
|
148
|
-
device.
|
|
149
|
-
|
|
150
|
-
...(attachPinInteraction ? { interaction: attachPinInteraction } : {}),
|
|
151
|
-
});
|
|
152
|
-
await device.unlockDevice(DeviceSessionPinType.AttachToPin, {
|
|
153
|
-
emitUiEvent: false,
|
|
154
|
-
interaction: attachPinInteraction,
|
|
155
|
-
});
|
|
156
|
-
return getDeviceSession(device, buildDeviceSessionGetRequest({ deriveCardano }));
|
|
105
|
+
device.emit(DEVICE.ATTACH_PIN_ON_DEVICE, device, metadata);
|
|
106
|
+
await device.unlockDevice(DeviceSessionPinType.AttachToPin);
|
|
107
|
+
return getDeviceSession(device, {});
|
|
157
108
|
}
|
|
158
109
|
|
|
159
110
|
if (hasHostPassphrase) {
|
|
@@ -161,19 +112,12 @@ const selectDeviceSession = async (
|
|
|
161
112
|
passphrase: hostPassphrase,
|
|
162
113
|
on_device: false,
|
|
163
114
|
});
|
|
164
|
-
return getDeviceSession(device,
|
|
115
|
+
return getDeviceSession(device, {});
|
|
165
116
|
}
|
|
166
117
|
|
|
167
|
-
|
|
168
|
-
'passphrase-on-device',
|
|
169
|
-
'start'
|
|
170
|
-
);
|
|
171
|
-
device.emit(DEVICE.PASSPHRASE_ON_DEVICE, device, {
|
|
172
|
-
...metadata,
|
|
173
|
-
...(passphraseOnDeviceInteraction ? { interaction: passphraseOnDeviceInteraction } : {}),
|
|
174
|
-
});
|
|
118
|
+
device.emit(DEVICE.PASSPHRASE_ON_DEVICE, device, metadata);
|
|
175
119
|
await askDevicePassphrase(device, { on_device: true });
|
|
176
|
-
return getDeviceSession(device,
|
|
120
|
+
return getDeviceSession(device, {});
|
|
177
121
|
};
|
|
178
122
|
|
|
179
123
|
export async function getProtocolV2WalletSession(
|
|
@@ -184,9 +128,7 @@ export async function getProtocolV2WalletSession(
|
|
|
184
128
|
initSession?: boolean;
|
|
185
129
|
expectedPassphraseState?: string;
|
|
186
130
|
onlyMainPin?: boolean;
|
|
187
|
-
selectMainWalletBeforeRestore?: boolean;
|
|
188
131
|
resumeOnly?: boolean;
|
|
189
|
-
deriveCardano?: boolean;
|
|
190
132
|
}
|
|
191
133
|
) {
|
|
192
134
|
const forceWalletSelection =
|
|
@@ -219,71 +161,17 @@ export async function getProtocolV2WalletSession(
|
|
|
219
161
|
: undefined;
|
|
220
162
|
let response;
|
|
221
163
|
let resumed = false;
|
|
222
|
-
let mainPinSelected =
|
|
223
|
-
options?.onlyMainPin === true &&
|
|
224
|
-
device.features?.unlocked === true &&
|
|
225
|
-
device.features?.unlockedAttachPin === false;
|
|
226
|
-
|
|
227
|
-
const clearCurrentWalletSession = () => {
|
|
228
|
-
if (options?.onlyMainPin) {
|
|
229
|
-
device.clearStandardInternalState?.();
|
|
230
|
-
} else {
|
|
231
|
-
device.clearInternalState();
|
|
232
|
-
}
|
|
233
|
-
};
|
|
234
|
-
|
|
235
|
-
const rejectMismatchedAttachPinWallet = async () => {
|
|
236
|
-
const features = await refreshProtocolV2DeviceStatus(device);
|
|
237
|
-
if (features.unlockedAttachPin !== true) {
|
|
238
|
-
return;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
try {
|
|
242
|
-
await device.lockDevice();
|
|
243
|
-
} catch {
|
|
244
|
-
// Reject the mismatched Attach PIN wallet even when older firmware cannot lock.
|
|
245
|
-
}
|
|
246
|
-
clearCurrentWalletSession();
|
|
247
|
-
throw ERRORS.TypedError(HardwareErrorCode.DeviceCheckUnlockTypeError);
|
|
248
|
-
};
|
|
249
|
-
|
|
250
|
-
const selectMainPin = async (force = false) => {
|
|
251
|
-
if (force || !mainPinSelected) {
|
|
252
|
-
await device.unlockDevice(DeviceSessionPinType.Main, {
|
|
253
|
-
source: 'wallet-session-coordinator',
|
|
254
|
-
reason: expectedPassphraseState ? 'session-recovery' : 'open-wallet',
|
|
255
|
-
deviceOnly: true,
|
|
256
|
-
});
|
|
257
|
-
mainPinSelected = true;
|
|
258
|
-
}
|
|
259
|
-
};
|
|
260
|
-
|
|
261
|
-
const selectStandardWallet = async () => {
|
|
262
|
-
// Main PIN authenticates the device; an empty host passphrase selects the standard derivation.
|
|
263
|
-
await selectMainPin();
|
|
264
|
-
if (device.features?.passphraseProtection === true) {
|
|
265
|
-
await askDevicePassphrase(device, {
|
|
266
|
-
passphrase: '',
|
|
267
|
-
on_device: false,
|
|
268
|
-
});
|
|
269
|
-
}
|
|
270
|
-
};
|
|
271
164
|
|
|
272
165
|
if (options?.onlyMainPin) {
|
|
273
166
|
expectedPassphraseState = cachedStandardSession?.passphraseState;
|
|
274
167
|
if (cachedStandardSession) {
|
|
275
168
|
try {
|
|
276
|
-
if (
|
|
277
|
-
await
|
|
169
|
+
if (device.features?.unlockedAttachPin === true) {
|
|
170
|
+
await device.unlockDevice(DeviceSessionPinType.Main);
|
|
278
171
|
}
|
|
279
|
-
response = await getDeviceSession(
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
sessionId: cachedStandardSession.sessionId,
|
|
283
|
-
expectedPassphraseState,
|
|
284
|
-
deriveCardano: options?.deriveCardano,
|
|
285
|
-
})
|
|
286
|
-
);
|
|
172
|
+
response = await getDeviceSession(device, {
|
|
173
|
+
session_id: cachedStandardSession.sessionId,
|
|
174
|
+
});
|
|
287
175
|
resumed = true;
|
|
288
176
|
} catch (error) {
|
|
289
177
|
device.clearStandardInternalState?.();
|
|
@@ -295,22 +183,12 @@ export async function getProtocolV2WalletSession(
|
|
|
295
183
|
}
|
|
296
184
|
|
|
297
185
|
if (!response) {
|
|
298
|
-
await
|
|
299
|
-
response = await getDeviceSession(
|
|
300
|
-
device,
|
|
301
|
-
buildDeviceSessionGetRequest({ deriveCardano: options?.deriveCardano })
|
|
302
|
-
);
|
|
186
|
+
await device.unlockDevice(DeviceSessionPinType.Main);
|
|
187
|
+
response = await getDeviceSession(device, {});
|
|
303
188
|
}
|
|
304
189
|
} else if (cachedSessionId && expectedPassphraseState) {
|
|
305
190
|
try {
|
|
306
|
-
response = await getDeviceSession(
|
|
307
|
-
device,
|
|
308
|
-
buildDeviceSessionGetRequest({
|
|
309
|
-
sessionId: cachedSessionId,
|
|
310
|
-
expectedPassphraseState,
|
|
311
|
-
deriveCardano: options?.deriveCardano,
|
|
312
|
-
})
|
|
313
|
-
);
|
|
191
|
+
response = await getDeviceSession(device, { session_id: cachedSessionId });
|
|
314
192
|
resumed = true;
|
|
315
193
|
} catch (error) {
|
|
316
194
|
device.clearInternalState();
|
|
@@ -319,20 +197,6 @@ export async function getProtocolV2WalletSession(
|
|
|
319
197
|
}
|
|
320
198
|
resumed = false;
|
|
321
199
|
}
|
|
322
|
-
} else if (expectedPassphraseState) {
|
|
323
|
-
try {
|
|
324
|
-
response = await getDeviceSession(
|
|
325
|
-
device,
|
|
326
|
-
buildDeviceSessionGetRequest({
|
|
327
|
-
expectedPassphraseState,
|
|
328
|
-
deriveCardano: options?.deriveCardano,
|
|
329
|
-
})
|
|
330
|
-
);
|
|
331
|
-
} catch (error) {
|
|
332
|
-
if (options?.resumeOnly || !isWalletSessionInvalidError(error)) {
|
|
333
|
-
throw error;
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
200
|
}
|
|
337
201
|
|
|
338
202
|
if (!response) {
|
|
@@ -340,7 +204,7 @@ export async function getProtocolV2WalletSession(
|
|
|
340
204
|
device.clearInternalState();
|
|
341
205
|
throw ERRORS.TypedError(HardwareErrorCode.WalletSessionInvalid);
|
|
342
206
|
}
|
|
343
|
-
response = await selectDeviceSession(device, expectedPassphraseState
|
|
207
|
+
response = await selectDeviceSession(device, expectedPassphraseState);
|
|
344
208
|
}
|
|
345
209
|
|
|
346
210
|
let { message } = response;
|
|
@@ -356,21 +220,17 @@ export async function getProtocolV2WalletSession(
|
|
|
356
220
|
}
|
|
357
221
|
if (expectedPassphraseState && expectedPassphraseState !== message.btc_test_address) {
|
|
358
222
|
resumed = false;
|
|
359
|
-
await rejectMismatchedAttachPinWallet();
|
|
360
223
|
if (options?.resumeOnly) {
|
|
361
224
|
device.clearInternalState();
|
|
362
225
|
throw ERRORS.TypedError(HardwareErrorCode.WalletSessionInvalid);
|
|
363
226
|
}
|
|
364
227
|
if (options?.onlyMainPin) {
|
|
365
228
|
device.clearStandardInternalState?.();
|
|
366
|
-
await
|
|
367
|
-
response = await getDeviceSession(
|
|
368
|
-
device,
|
|
369
|
-
buildDeviceSessionGetRequest({ deriveCardano: options?.deriveCardano })
|
|
370
|
-
);
|
|
229
|
+
await device.unlockDevice(DeviceSessionPinType.Main);
|
|
230
|
+
response = await getDeviceSession(device, {});
|
|
371
231
|
} else {
|
|
372
232
|
device.clearInternalState();
|
|
373
|
-
response = await selectDeviceSession(device, expectedPassphraseState
|
|
233
|
+
response = await selectDeviceSession(device, expectedPassphraseState);
|
|
374
234
|
}
|
|
375
235
|
message = response.message;
|
|
376
236
|
try {
|
|
@@ -384,8 +244,11 @@ export async function getProtocolV2WalletSession(
|
|
|
384
244
|
throw error;
|
|
385
245
|
}
|
|
386
246
|
if (expectedPassphraseState !== message.btc_test_address) {
|
|
387
|
-
|
|
388
|
-
|
|
247
|
+
if (options?.onlyMainPin) {
|
|
248
|
+
device.clearStandardInternalState?.();
|
|
249
|
+
} else {
|
|
250
|
+
device.clearInternalState();
|
|
251
|
+
}
|
|
389
252
|
throw ERRORS.TypedError(HardwareErrorCode.DeviceCheckPassphraseStateError);
|
|
390
253
|
}
|
|
391
254
|
}
|
|
@@ -406,19 +269,17 @@ export async function getProtocolV2WalletSession(
|
|
|
406
269
|
return {
|
|
407
270
|
passphraseState: message.btc_test_address,
|
|
408
271
|
newSession: message.session_id,
|
|
409
|
-
unlockedAttachPin:
|
|
272
|
+
unlockedAttachPin: device.features?.unlockedAttachPin ?? undefined,
|
|
410
273
|
resumed,
|
|
411
274
|
};
|
|
412
275
|
}
|
|
413
276
|
|
|
414
277
|
export async function restoreProtocolV2WalletSession(
|
|
415
278
|
device: Device,
|
|
416
|
-
expectedPassphraseState: string
|
|
417
|
-
deriveCardano?: boolean
|
|
279
|
+
expectedPassphraseState: string
|
|
418
280
|
) {
|
|
419
281
|
return getProtocolV2WalletSession(device, {
|
|
420
282
|
expectedPassphraseState,
|
|
421
283
|
resumeOnly: true,
|
|
422
|
-
deriveCardano,
|
|
423
284
|
});
|
|
424
285
|
}
|
package/src/topLevelInject.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import EventEmitter from 'events';
|
|
2
2
|
|
|
3
|
-
import { createCoreApi
|
|
3
|
+
import { createCoreApi } from './inject';
|
|
4
|
+
import { unregisterFirmwareUpdateHostBinding } from './api/firmware/FirmwareHostBinding';
|
|
4
5
|
|
|
5
6
|
import type { ConnectSettings } from './types/settings';
|
|
6
7
|
import type { CoreApi } from './types/api';
|
|
@@ -19,7 +20,6 @@ export const topLevelInject = () => {
|
|
|
19
20
|
if (!lowLevelApi) return Promise.resolve(undefined);
|
|
20
21
|
return lowLevelApi.call(params);
|
|
21
22
|
};
|
|
22
|
-
const protocolAwareCall = createProtocolAwareCall(call);
|
|
23
23
|
const api: CoreApi = {
|
|
24
24
|
on: <T extends string, P extends (...args: any[]) => any>(type: T, fn: P) => {
|
|
25
25
|
eventEmitter.on(type, fn);
|
|
@@ -38,18 +38,19 @@ export const topLevelInject = () => {
|
|
|
38
38
|
return lowLevelApi?.init(settings) ?? Promise.resolve(false);
|
|
39
39
|
},
|
|
40
40
|
|
|
41
|
-
call
|
|
41
|
+
call,
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
...createCoreApi(protocolAwareCall.call),
|
|
43
|
+
...createCoreApi(call),
|
|
46
44
|
|
|
47
45
|
removeAllListeners: type => {
|
|
48
46
|
eventEmitter.removeAllListeners(type);
|
|
49
47
|
lowLevelApi?.removeAllListeners(type);
|
|
50
48
|
},
|
|
51
49
|
|
|
52
|
-
dispose: () =>
|
|
50
|
+
dispose: async () => {
|
|
51
|
+
unregisterFirmwareUpdateHostBinding();
|
|
52
|
+
await lowLevelApi?.dispose();
|
|
53
|
+
},
|
|
53
54
|
|
|
54
55
|
uiResponse: response => lowLevelApi?.uiResponse(response),
|
|
55
56
|
|
|
@@ -12,6 +12,7 @@ import type {
|
|
|
12
12
|
IProtocolV2FirmwareComponentTarget,
|
|
13
13
|
} from '../settings';
|
|
14
14
|
import type { FirmwareUpdateV4Target } from './firmwareUpdate';
|
|
15
|
+
import type { FirmwareUpdatePlan, FirmwareUpdatePlanForceTarget } from './firmwareUpdatePlan';
|
|
15
16
|
|
|
16
17
|
export type FirmwareRelease = {
|
|
17
18
|
shouldUpdate?: boolean;
|
|
@@ -59,16 +60,18 @@ export type AllFirmwareRelease = {
|
|
|
59
60
|
status?: ProtocolV2FirmwareReleaseStatus;
|
|
60
61
|
hasUpgrade?: boolean;
|
|
61
62
|
required?: boolean;
|
|
62
|
-
resourceStatus?: 'valid' | 'outdated' | 'unknown';
|
|
63
63
|
currentVersions?: DeviceStateVersions;
|
|
64
64
|
components?: ProtocolV2FirmwareComponentRelease[];
|
|
65
65
|
targetsToUpdate?: FirmwareUpdateV4Target[];
|
|
66
66
|
release?: IFirmwareReleaseInfo;
|
|
67
|
+
firmwareUpdatePlan?: FirmwareUpdatePlan;
|
|
67
68
|
};
|
|
68
69
|
|
|
69
70
|
export type CheckAllFirmwareReleaseParams = {
|
|
70
71
|
checkBridgeRelease?: boolean;
|
|
71
72
|
firmwareType?: EFirmwareType;
|
|
73
|
+
platform?: 'native' | 'desktop' | 'ext' | 'web' | 'web-embed';
|
|
74
|
+
forceUpdateTargets?: FirmwareUpdatePlanForceTarget[];
|
|
72
75
|
};
|
|
73
76
|
|
|
74
77
|
export declare function checkAllFirmwareRelease(
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import type { Success } from '@onekeyfe/hd-transport';
|
|
2
2
|
import type { EFirmwareType } from '@onekeyfe/hd-shared';
|
|
3
|
+
import type { FirmwareArtifactReader, FirmwareArtifactReference } from './firmwareUpdate';
|
|
4
|
+
import type { FirmwareUpdatePreparedPlan } from './firmwareUpdatePreparedPlan';
|
|
3
5
|
import type { Response } from '../params';
|
|
4
6
|
|
|
5
7
|
export type DeviceUpdateBootloaderParams = {
|
|
8
|
+
preparedPlan?: FirmwareUpdatePreparedPlan;
|
|
9
|
+
hostBindingGeneration?: number;
|
|
6
10
|
binary?: ArrayBuffer;
|
|
11
|
+
artifact?: FirmwareArtifactReference;
|
|
12
|
+
artifactReader?: FirmwareArtifactReader;
|
|
7
13
|
firmwareType?: EFirmwareType;
|
|
8
14
|
};
|
|
9
15
|
|
package/src/types/api/export.ts
CHANGED
|
@@ -25,12 +25,30 @@ export type {
|
|
|
25
25
|
DeviceUploadResourceResponse,
|
|
26
26
|
} from './deviceUploadResource';
|
|
27
27
|
export type {
|
|
28
|
+
FirmwareArtifactReader,
|
|
29
|
+
FirmwareArtifactReference,
|
|
30
|
+
FirmwareUpdateHostBinding,
|
|
31
|
+
FirmwareUpdateArtifactParams,
|
|
28
32
|
FirmwareUpdateParams,
|
|
29
33
|
FirmwareUpdateBinaryParams,
|
|
30
34
|
FirmwareUpdateV3Params,
|
|
31
35
|
FirmwareUpdateV4Params,
|
|
32
36
|
FirmwareUpdateV4Target,
|
|
33
37
|
} from './firmwareUpdate';
|
|
38
|
+
export type {
|
|
39
|
+
FirmwareUpdatePlan,
|
|
40
|
+
FirmwareUpdatePlanArtifact,
|
|
41
|
+
FirmwareUpdatePlanArtifactRole,
|
|
42
|
+
FirmwareUpdatePlanForceTarget,
|
|
43
|
+
FirmwareUpdatePlanTarget,
|
|
44
|
+
} from './firmwareUpdatePlan';
|
|
45
|
+
export type {
|
|
46
|
+
FirmwareUpdatePreparedArtifact,
|
|
47
|
+
FirmwareUpdatePreparedArtifactInput,
|
|
48
|
+
FirmwareUpdatePreparedEntry,
|
|
49
|
+
FirmwareUpdatePreparedPlan,
|
|
50
|
+
} from './firmwareUpdatePreparedPlan';
|
|
51
|
+
export type { FirmwareUpdateCapabilities } from './firmwareUpdateCapabilities';
|
|
34
52
|
export type { AllFirmwareRelease } from './checkAllFirmwareRelease';
|
|
35
53
|
export type {
|
|
36
54
|
ProtocolV2FirmwareComponentRelease,
|
|
@@ -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
|
/**
|
|
@@ -63,7 +119,6 @@ export interface FirmwareUpdateV3Params {
|
|
|
63
119
|
*/
|
|
64
120
|
export type FirmwareUpdateV4Target =
|
|
65
121
|
| 'boot'
|
|
66
|
-
| 'boot_resources'
|
|
67
122
|
| 'app_v1'
|
|
68
123
|
| 'app_v2'
|
|
69
124
|
| 'coprocessor'
|
|
@@ -74,17 +129,19 @@ export type FirmwareUpdateV4Target =
|
|
|
74
129
|
| 'se04';
|
|
75
130
|
|
|
76
131
|
export interface FirmwareUpdateV4Params {
|
|
132
|
+
preparedPlan?: FirmwareUpdatePreparedPlan;
|
|
133
|
+
hostBindingGeneration?: number;
|
|
77
134
|
platform: IPlatform;
|
|
135
|
+
expectedDeviceId?: string;
|
|
78
136
|
chunkSize?: number;
|
|
79
137
|
firmwareType?: EFirmwareType;
|
|
80
138
|
targetsToUpdate?: FirmwareUpdateV4Target[];
|
|
139
|
+
expectedTargetVersions?: Partial<Record<FirmwareUpdateV4Target, string>>;
|
|
81
140
|
|
|
82
141
|
/** FW_MGMT_TARGET_ROMLOADER = 2; Pro2 cannot install it through firmwareUpdateV4. */
|
|
83
142
|
romloaderBinary?: ArrayBuffer;
|
|
84
143
|
/** FW_MGMT_TARGET_BOOTLOADER = 3 */
|
|
85
144
|
bootloaderBinary?: ArrayBuffer;
|
|
86
|
-
/** FW_MGMT_TARGET_CRATE = 1; optional Pro2 startup resources. */
|
|
87
|
-
bootResourcesBinary?: ArrayBuffer;
|
|
88
145
|
/** FW_MGMT_TARGET_APPLICATION_P1 = 4 */
|
|
89
146
|
applicationP1Binary?: ArrayBuffer;
|
|
90
147
|
/** FW_MGMT_TARGET_APPLICATION_P2 = 5 */
|
|
@@ -105,8 +162,24 @@ export interface FirmwareUpdateV4Params {
|
|
|
105
162
|
binary: ArrayBuffer;
|
|
106
163
|
devicePath: string;
|
|
107
164
|
}>;
|
|
165
|
+
artifactReader?: FirmwareArtifactReader;
|
|
166
|
+
componentArtifacts?: Partial<
|
|
167
|
+
Record<Exclude<FirmwareUpdateV4Target, 'resource'>, FirmwareArtifactReference>
|
|
168
|
+
>;
|
|
169
|
+
resourceBundleArtifacts?: Array<{
|
|
170
|
+
name: string;
|
|
171
|
+
artifact: FirmwareArtifactReference;
|
|
172
|
+
}>;
|
|
108
173
|
}
|
|
109
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
|
+
|
|
110
183
|
export declare function firmwareUpdateV3(
|
|
111
184
|
connectId: string | undefined,
|
|
112
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;
|