@onekeyfe/hd-core 1.2.0-alpha.66 → 1.2.0-alpha.67
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 -313
- package/__tests__/DeviceCommands.test.ts +13 -59
- package/__tests__/DeviceEventRegistration.test.ts +0 -6
- package/__tests__/check-all-firmware-release-protocol-v2.test.ts +3 -198
- 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__/device-pool-state.test.ts +0 -22
- package/__tests__/device-settings.test.ts +18 -39
- package/__tests__/device-state-contract.test.ts +0 -1
- package/__tests__/device-state-mapper.test.ts +1 -13
- package/__tests__/device-utils.test.ts +1 -48
- package/__tests__/deviceSettings.test.ts +1 -11
- package/__tests__/firmware-update/check-all-firmware-release.test.ts +175 -0
- package/__tests__/firmware-update/device-update-bootloader.test.ts +87 -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 +394 -0
- package/__tests__/firmware-update/firmware-update-plan.test.ts +593 -0
- package/__tests__/firmware-update/firmware-update-prepared-plan.test.ts +231 -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__/kaspa-use-tweak-pro2.test.ts +2 -2
- package/__tests__/kaspaSignTransaction.test.ts +26 -3
- package/__tests__/logBlockEvent.test.ts +1 -1
- package/__tests__/method-protocol-support.test.ts +0 -19
- package/__tests__/open-wallet-session.test.ts +37 -568
- package/__tests__/protocol-v2-unlock-policy.test.ts +37 -300
- package/__tests__/protocol-v2.test.ts +1153 -1458
- package/__tests__/protocolV2FileWrite.test.ts +0 -152
- 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/__tests__/tron-sign-message-init.test.ts +2 -2
- package/dist/api/BaseMethod.d.ts +1 -3
- package/dist/api/BaseMethod.d.ts.map +1 -1
- package/dist/api/CheckAllFirmwareRelease.d.ts +1 -2
- package/dist/api/CheckAllFirmwareRelease.d.ts.map +1 -1
- package/dist/api/FirmwareUpdate.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV2.d.ts +10 -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 +27 -13
- 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/DeviceSettings.d.ts.map +1 -1
- package/dist/api/device/DeviceUnlock.d.ts +2 -2
- package/dist/api/device/DeviceUnlock.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 +11 -4
- 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 -9
- 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/kaspa/KaspaGetAddress.d.ts +1 -1
- package/dist/api/kaspa/KaspaSignTransaction.d.ts +1 -1
- package/dist/api/kaspa/KaspaSignTransaction.d.ts.map +1 -1
- package/dist/api/polkadot/PolkadotGetAddress.d.ts +1 -1
- package/dist/api/polkadot/networks.d.ts +1 -1
- package/dist/api/protocol-v2/ProtocolInfoRequest.d.ts.map +1 -1
- package/dist/api/protocol-v2/helpers.d.ts.map +1 -1
- package/dist/api/solana/SolSignMessage.d.ts +1 -1
- package/dist/api/solana/SolSignOffchainMessage.d.ts +1 -1
- package/dist/api/solana/SolSignTransaction.d.ts +2 -2
- package/dist/api/stellar/StellarSignTransaction.d.ts +1 -1
- package/dist/api/sui/SuiGetAddress.d.ts +1 -1
- package/dist/api/sui/SuiGetPublicKey.d.ts +1 -1
- package/dist/api/sui/SuiSignMessage.d.ts +1 -1
- package/dist/api/sui/SuiSignTransaction.d.ts +1 -1
- package/dist/api/ton/TonGetAddress.d.ts +1 -1
- package/dist/api/ton/TonSignMessage.d.ts +1 -1
- package/dist/api/ton/TonSignProof.d.ts +1 -1
- package/dist/api/tron/TronSignMessage.d.ts +2 -2
- package/dist/api/tron/TronSignTransaction.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 +4 -9
- package/dist/data-manager/DataManager.d.ts.map +1 -1
- package/dist/data-manager/TransportManager.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/DeviceCommands.d.ts.map +1 -1
- package/dist/device/DeviceConnector.d.ts +1 -2
- package/dist/device/DeviceConnector.d.ts.map +1 -1
- package/dist/device/DevicePool.d.ts.map +1 -1
- package/dist/deviceProfile/protocolV2DeviceIdentity.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 +247 -243
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3773 -3054
- 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 +4 -0
- package/dist/protocols/protocol-v2/features.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/firmware.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 -6
- 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 +5 -3
- package/dist/types/api/checkAllFirmwareRelease.d.ts.map +1 -1
- package/dist/types/api/deviceUnlock.d.ts +1 -5
- package/dist/types/api/deviceUnlock.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 -2
- package/dist/types/api/export.d.ts.map +1 -1
- package/dist/types/api/firmwareUpdate.d.ts +70 -4
- 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/device.d.ts +2 -2
- package/dist/types/device.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 +21 -38
- 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 -4
- package/dist/utils/deviceFeaturesUtils.d.ts.map +1 -1
- package/dist/utils/deviceInfoUtils.d.ts.map +1 -1
- package/dist/utils/deviceSettings.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 +60 -59
- package/src/api/FirmwareUpdate.ts +15 -7
- package/src/api/FirmwareUpdateV2.ts +298 -126
- package/src/api/FirmwareUpdateV3.ts +265 -63
- package/src/api/FirmwareUpdateV4.ts +1017 -602
- package/src/api/GetPassphraseState.ts +1 -7
- package/src/api/OpenWalletSession.ts +17 -71
- package/src/api/SearchDevices.ts +1 -3
- package/src/api/allnetwork/AllNetworkGetAddress.ts +21 -21
- package/src/api/allnetwork/AllNetworkGetAddressBase.ts +11 -36
- package/src/api/device/DeviceSettings.ts +4 -5
- package/src/api/device/DeviceUnlock.ts +3 -8
- package/src/api/device/DeviceUpdateBootloader.ts +125 -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 -27
- package/src/api/firmware/FirmwareUpdateCapabilities.ts +9 -0
- package/src/api/firmware/FirmwareUpdatePlan.ts +772 -0
- package/src/api/firmware/FirmwareUpdatePreparedPlan.ts +449 -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 +63 -202
- package/src/api/index.ts +0 -2
- package/src/api/kaspa/KaspaGetAddress.ts +1 -1
- package/src/api/kaspa/KaspaSignTransaction.ts +13 -2
- package/src/api/polkadot/networks.ts +3 -3
- package/src/api/protocol-v2/ProtocolInfoRequest.ts +1 -3
- package/src/api/protocol-v2/helpers.ts +1 -1
- package/src/api/solana/SolSignMessage.ts +1 -1
- package/src/api/solana/SolSignOffchainMessage.ts +1 -1
- package/src/api/solana/SolSignTransaction.ts +2 -2
- package/src/api/sui/SuiGetAddress.ts +1 -1
- package/src/api/sui/SuiGetPublicKey.ts +1 -1
- package/src/api/sui/SuiSignMessage.ts +1 -1
- package/src/api/sui/SuiSignTransaction.ts +1 -1
- package/src/api/ton/TonGetAddress.ts +1 -1
- package/src/api/ton/TonSignMessage.ts +1 -1
- package/src/api/ton/TonSignProof.ts +1 -1
- package/src/api/tron/TronSignMessage.ts +2 -2
- package/src/api/tron/TronSignTransaction.ts +1 -1
- package/src/core/deviceEventRegistration.ts +0 -4
- package/src/core/index.ts +111 -213
- package/src/data/messages/messages-protocol-v2.json +0 -25
- package/src/data-manager/DataManager.ts +41 -113
- package/src/data-manager/TransportManager.ts +0 -6
- package/src/data-manager/connectSettings.ts +11 -0
- package/src/device/Device.ts +49 -274
- package/src/device/DeviceCommands.ts +4 -31
- package/src/device/DeviceConnector.ts +13 -33
- package/src/device/DevicePool.ts +7 -21
- package/src/deviceProfile/buildDeviceFeatures.ts +2 -2
- package/src/deviceProfile/protocolV2DeviceIdentity.ts +0 -3
- 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 +7 -10
- package/src/protocols/protocol-v2/firmware.ts +0 -2
- 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 +36 -214
- package/src/topLevelInject.ts +8 -7
- package/src/types/api/checkAllFirmwareRelease.ts +5 -3
- package/src/types/api/deviceUnlock.ts +1 -12
- package/src/types/api/deviceUpdateBootloader.ts +6 -0
- package/src/types/api/export.ts +18 -1
- package/src/types/api/firmwareUpdate.ts +78 -6
- 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/device.ts +3 -15
- package/src/types/params.ts +1 -7
- package/src/types/settings.ts +22 -60
- package/src/utils/deviceFeaturesCompat.ts +6 -5
- package/src/utils/deviceFeaturesUtils.ts +3 -14
- package/src/utils/deviceInfoUtils.ts +0 -2
- package/src/utils/deviceSettings.ts +0 -3
- package/src/utils/homescreen.ts +6 -32
- package/src/utils/index.ts +1 -6
- package/src/utils/pro2Wallpaper.ts +8 -35
- package/__tests__/core-initialization.test.ts +0 -23
- package/__tests__/device-connector-protocol.test.ts +0 -81
- package/__tests__/deviceUploadNft.test.ts +0 -316
- package/__tests__/pro2Nft.test.ts +0 -108
- package/__tests__/protocol-binding.test.ts +0 -89
- package/__tests__/protocol-v2-resources.test.ts +0 -340
- package/__tests__/protocol-v2-ui-lifecycle.test.ts +0 -91
- package/__tests__/uiProgressThrottle.test.ts +0 -74
- package/__tests__/uiPromiseRegistry.test.ts +0 -115
- 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 -6
- 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 -197
- package/src/core/uiPromiseRegistry.ts +0 -63
- package/src/protocols/protocol-v2/resources.ts +0 -390
- package/src/protocols/protocol-v2/unlockPolicyRunner.ts +0 -131
- package/src/types/api/detectDeviceConnectProtocol.ts +0 -6
- 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,18 +128,11 @@ export async function getProtocolV2WalletSession(
|
|
|
184
128
|
initSession?: boolean;
|
|
185
129
|
expectedPassphraseState?: string;
|
|
186
130
|
onlyMainPin?: boolean;
|
|
187
|
-
/** 业务安全校验遇到 Attach PIN 上下文时直接拒绝,不主动切换钱包。 */
|
|
188
|
-
rejectAttachPinForMainWallet?: boolean;
|
|
189
|
-
selectMainWalletBeforeRestore?: boolean;
|
|
190
131
|
resumeOnly?: boolean;
|
|
191
|
-
deriveCardano?: boolean;
|
|
192
|
-
/** Read the wallet already selected by Attach PIN without reopening wallet selection. */
|
|
193
|
-
readCurrentAttachPinSession?: boolean;
|
|
194
132
|
}
|
|
195
133
|
) {
|
|
196
134
|
const forceWalletSelection =
|
|
197
135
|
options?.forceWalletSelection === true || options?.initSession === true;
|
|
198
|
-
const readCurrentAttachPinSession = options?.readCurrentAttachPinSession === true;
|
|
199
136
|
|
|
200
137
|
if (forceWalletSelection) {
|
|
201
138
|
if (options.onlyMainPin) {
|
|
@@ -208,114 +145,33 @@ export async function getProtocolV2WalletSession(
|
|
|
208
145
|
|
|
209
146
|
await negotiateEventlessWalletSession(device);
|
|
210
147
|
|
|
211
|
-
if (options?.onlyMainPin
|
|
148
|
+
if (options?.onlyMainPin) {
|
|
212
149
|
device.passphraseState = undefined;
|
|
213
150
|
}
|
|
214
|
-
let expectedPassphraseState =
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
: options?.expectedPassphraseState ?? device.passphraseState;
|
|
151
|
+
let expectedPassphraseState = options?.onlyMainPin
|
|
152
|
+
? undefined
|
|
153
|
+
: options?.expectedPassphraseState ?? device.passphraseState;
|
|
218
154
|
|
|
219
155
|
const cachedStandardSession = options?.onlyMainPin
|
|
220
156
|
? device.getStandardInternalState?.()
|
|
221
157
|
: undefined;
|
|
222
158
|
const cachedSessionId =
|
|
223
|
-
!options?.onlyMainPin &&
|
|
224
|
-
!readCurrentAttachPinSession &&
|
|
225
|
-
typeof device.getInternalState === 'function'
|
|
159
|
+
!options?.onlyMainPin && typeof device.getInternalState === 'function'
|
|
226
160
|
? device.getInternalState()
|
|
227
161
|
: undefined;
|
|
228
162
|
let response;
|
|
229
163
|
let resumed = false;
|
|
230
|
-
let mainPinSelected =
|
|
231
|
-
options?.onlyMainPin === true &&
|
|
232
|
-
device.features?.unlocked === true &&
|
|
233
|
-
device.features?.unlockedAttachPin === false;
|
|
234
|
-
|
|
235
|
-
const clearCurrentWalletSession = () => {
|
|
236
|
-
if (options?.onlyMainPin) {
|
|
237
|
-
device.clearStandardInternalState?.();
|
|
238
|
-
} else {
|
|
239
|
-
device.clearInternalState();
|
|
240
|
-
}
|
|
241
|
-
};
|
|
242
164
|
|
|
243
|
-
|
|
244
|
-
const features = await refreshProtocolV2DeviceStatus(device);
|
|
245
|
-
if (features.unlockedAttachPin !== true) {
|
|
246
|
-
return;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
try {
|
|
250
|
-
await device.lockDevice();
|
|
251
|
-
} catch {
|
|
252
|
-
// Reject the mismatched Attach PIN wallet even when older firmware cannot lock.
|
|
253
|
-
}
|
|
254
|
-
if (options?.rejectAttachPinForMainWallet) {
|
|
255
|
-
device.clearStandardInternalState?.();
|
|
256
|
-
device.clearInternalState();
|
|
257
|
-
} else {
|
|
258
|
-
clearCurrentWalletSession();
|
|
259
|
-
}
|
|
260
|
-
throw ERRORS.TypedError(HardwareErrorCode.DeviceCheckUnlockTypeError);
|
|
261
|
-
};
|
|
262
|
-
|
|
263
|
-
if (options?.onlyMainPin && options.rejectAttachPinForMainWallet) {
|
|
264
|
-
await rejectMismatchedAttachPinWallet();
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
const selectMainPin = async (force = false) => {
|
|
268
|
-
if (force || !mainPinSelected) {
|
|
269
|
-
await device.unlockDevice(DeviceSessionPinType.Main, {
|
|
270
|
-
source: 'wallet-session-coordinator',
|
|
271
|
-
reason: expectedPassphraseState ? 'session-recovery' : 'open-wallet',
|
|
272
|
-
deviceOnly: true,
|
|
273
|
-
});
|
|
274
|
-
mainPinSelected = true;
|
|
275
|
-
}
|
|
276
|
-
};
|
|
277
|
-
|
|
278
|
-
const selectStandardWallet = async () => {
|
|
279
|
-
// Main PIN authenticates the device; an empty host passphrase selects the standard derivation.
|
|
280
|
-
await selectMainPin();
|
|
281
|
-
if (device.features?.passphraseProtection === true) {
|
|
282
|
-
await askDevicePassphrase(device, {
|
|
283
|
-
passphrase: '',
|
|
284
|
-
on_device: false,
|
|
285
|
-
});
|
|
286
|
-
}
|
|
287
|
-
};
|
|
288
|
-
|
|
289
|
-
if (readCurrentAttachPinSession) {
|
|
290
|
-
const status = await requestProtocolV2DeviceStatus(device);
|
|
291
|
-
device.updateProtocolV2Status(status);
|
|
292
|
-
if (
|
|
293
|
-
status.unlocked !== true ||
|
|
294
|
-
status.passphrase_enabled !== true ||
|
|
295
|
-
status.unlocked_by_attach_to_pin !== true
|
|
296
|
-
) {
|
|
297
|
-
device.clearInternalState();
|
|
298
|
-
throw ERRORS.TypedError(HardwareErrorCode.DeviceCheckUnlockTypeError);
|
|
299
|
-
}
|
|
300
|
-
response = await getDeviceSession(
|
|
301
|
-
device,
|
|
302
|
-
buildDeviceSessionGetRequest({ deriveCardano: options?.deriveCardano })
|
|
303
|
-
);
|
|
304
|
-
} else if (options?.onlyMainPin) {
|
|
165
|
+
if (options?.onlyMainPin) {
|
|
305
166
|
expectedPassphraseState = cachedStandardSession?.passphraseState;
|
|
306
167
|
if (cachedStandardSession) {
|
|
307
168
|
try {
|
|
308
|
-
if (
|
|
309
|
-
await
|
|
169
|
+
if (device.features?.unlockedAttachPin === true) {
|
|
170
|
+
await device.unlockDevice(DeviceSessionPinType.Main);
|
|
310
171
|
}
|
|
311
|
-
response = await getDeviceSession(
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
sessionId: cachedStandardSession.sessionId,
|
|
315
|
-
expectedPassphraseState,
|
|
316
|
-
deriveCardano: options?.deriveCardano,
|
|
317
|
-
})
|
|
318
|
-
);
|
|
172
|
+
response = await getDeviceSession(device, {
|
|
173
|
+
session_id: cachedStandardSession.sessionId,
|
|
174
|
+
});
|
|
319
175
|
resumed = true;
|
|
320
176
|
} catch (error) {
|
|
321
177
|
device.clearStandardInternalState?.();
|
|
@@ -327,22 +183,12 @@ export async function getProtocolV2WalletSession(
|
|
|
327
183
|
}
|
|
328
184
|
|
|
329
185
|
if (!response) {
|
|
330
|
-
await
|
|
331
|
-
response = await getDeviceSession(
|
|
332
|
-
device,
|
|
333
|
-
buildDeviceSessionGetRequest({ deriveCardano: options?.deriveCardano })
|
|
334
|
-
);
|
|
186
|
+
await device.unlockDevice(DeviceSessionPinType.Main);
|
|
187
|
+
response = await getDeviceSession(device, {});
|
|
335
188
|
}
|
|
336
189
|
} else if (cachedSessionId && expectedPassphraseState) {
|
|
337
190
|
try {
|
|
338
|
-
response = await getDeviceSession(
|
|
339
|
-
device,
|
|
340
|
-
buildDeviceSessionGetRequest({
|
|
341
|
-
sessionId: cachedSessionId,
|
|
342
|
-
expectedPassphraseState,
|
|
343
|
-
deriveCardano: options?.deriveCardano,
|
|
344
|
-
})
|
|
345
|
-
);
|
|
191
|
+
response = await getDeviceSession(device, { session_id: cachedSessionId });
|
|
346
192
|
resumed = true;
|
|
347
193
|
} catch (error) {
|
|
348
194
|
device.clearInternalState();
|
|
@@ -351,20 +197,6 @@ export async function getProtocolV2WalletSession(
|
|
|
351
197
|
}
|
|
352
198
|
resumed = false;
|
|
353
199
|
}
|
|
354
|
-
} else if (expectedPassphraseState) {
|
|
355
|
-
try {
|
|
356
|
-
response = await getDeviceSession(
|
|
357
|
-
device,
|
|
358
|
-
buildDeviceSessionGetRequest({
|
|
359
|
-
expectedPassphraseState,
|
|
360
|
-
deriveCardano: options?.deriveCardano,
|
|
361
|
-
})
|
|
362
|
-
);
|
|
363
|
-
} catch (error) {
|
|
364
|
-
if (options?.resumeOnly || !isWalletSessionInvalidError(error)) {
|
|
365
|
-
throw error;
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
200
|
}
|
|
369
201
|
|
|
370
202
|
if (!response) {
|
|
@@ -372,7 +204,7 @@ export async function getProtocolV2WalletSession(
|
|
|
372
204
|
device.clearInternalState();
|
|
373
205
|
throw ERRORS.TypedError(HardwareErrorCode.WalletSessionInvalid);
|
|
374
206
|
}
|
|
375
|
-
response = await selectDeviceSession(device, expectedPassphraseState
|
|
207
|
+
response = await selectDeviceSession(device, expectedPassphraseState);
|
|
376
208
|
}
|
|
377
209
|
|
|
378
210
|
let { message } = response;
|
|
@@ -388,21 +220,17 @@ export async function getProtocolV2WalletSession(
|
|
|
388
220
|
}
|
|
389
221
|
if (expectedPassphraseState && expectedPassphraseState !== message.btc_test_address) {
|
|
390
222
|
resumed = false;
|
|
391
|
-
await rejectMismatchedAttachPinWallet();
|
|
392
223
|
if (options?.resumeOnly) {
|
|
393
224
|
device.clearInternalState();
|
|
394
225
|
throw ERRORS.TypedError(HardwareErrorCode.WalletSessionInvalid);
|
|
395
226
|
}
|
|
396
227
|
if (options?.onlyMainPin) {
|
|
397
228
|
device.clearStandardInternalState?.();
|
|
398
|
-
await
|
|
399
|
-
response = await getDeviceSession(
|
|
400
|
-
device,
|
|
401
|
-
buildDeviceSessionGetRequest({ deriveCardano: options?.deriveCardano })
|
|
402
|
-
);
|
|
229
|
+
await device.unlockDevice(DeviceSessionPinType.Main);
|
|
230
|
+
response = await getDeviceSession(device, {});
|
|
403
231
|
} else {
|
|
404
232
|
device.clearInternalState();
|
|
405
|
-
response = await selectDeviceSession(device, expectedPassphraseState
|
|
233
|
+
response = await selectDeviceSession(device, expectedPassphraseState);
|
|
406
234
|
}
|
|
407
235
|
message = response.message;
|
|
408
236
|
try {
|
|
@@ -416,8 +244,11 @@ export async function getProtocolV2WalletSession(
|
|
|
416
244
|
throw error;
|
|
417
245
|
}
|
|
418
246
|
if (expectedPassphraseState !== message.btc_test_address) {
|
|
419
|
-
|
|
420
|
-
|
|
247
|
+
if (options?.onlyMainPin) {
|
|
248
|
+
device.clearStandardInternalState?.();
|
|
249
|
+
} else {
|
|
250
|
+
device.clearInternalState();
|
|
251
|
+
}
|
|
421
252
|
throw ERRORS.TypedError(HardwareErrorCode.DeviceCheckPassphraseStateError);
|
|
422
253
|
}
|
|
423
254
|
}
|
|
@@ -435,29 +266,20 @@ export async function getProtocolV2WalletSession(
|
|
|
435
266
|
device.updateInternalState(...internalStateArgs);
|
|
436
267
|
}
|
|
437
268
|
|
|
438
|
-
let unlockedAttachPin: boolean | undefined;
|
|
439
|
-
if (readCurrentAttachPinSession) {
|
|
440
|
-
unlockedAttachPin = true;
|
|
441
|
-
} else if (mainPinSelected) {
|
|
442
|
-
unlockedAttachPin = false;
|
|
443
|
-
}
|
|
444
|
-
|
|
445
269
|
return {
|
|
446
270
|
passphraseState: message.btc_test_address,
|
|
447
271
|
newSession: message.session_id,
|
|
448
|
-
unlockedAttachPin,
|
|
272
|
+
unlockedAttachPin: device.features?.unlockedAttachPin ?? undefined,
|
|
449
273
|
resumed,
|
|
450
274
|
};
|
|
451
275
|
}
|
|
452
276
|
|
|
453
277
|
export async function restoreProtocolV2WalletSession(
|
|
454
278
|
device: Device,
|
|
455
|
-
expectedPassphraseState: string
|
|
456
|
-
deriveCardano?: boolean
|
|
279
|
+
expectedPassphraseState: string
|
|
457
280
|
) {
|
|
458
281
|
return getProtocolV2WalletSession(device, {
|
|
459
282
|
expectedPassphraseState,
|
|
460
283
|
resumeOnly: true,
|
|
461
|
-
deriveCardano,
|
|
462
284
|
});
|
|
463
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;
|
|
@@ -54,22 +55,23 @@ export type AllFirmwareRelease = {
|
|
|
54
55
|
bridge?: FirmwareRelease;
|
|
55
56
|
features?: Features;
|
|
56
57
|
protocol?: 'V1' | 'V2';
|
|
57
|
-
deviceType?: 'pro2'
|
|
58
|
+
deviceType?: 'pro2';
|
|
58
59
|
firmwareType?: EFirmwareType;
|
|
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
|
-
checkFirmwareHash?: boolean;
|
|
72
72
|
firmwareType?: EFirmwareType;
|
|
73
|
+
platform?: 'native' | 'desktop' | 'ext' | 'web' | 'web-embed';
|
|
74
|
+
forceUpdateTargets?: FirmwareUpdatePlanForceTarget[];
|
|
73
75
|
};
|
|
74
76
|
|
|
75
77
|
export declare function checkAllFirmwareRelease(
|
|
@@ -1,15 +1,4 @@
|
|
|
1
|
-
import type { DeviceSessionPinType } from '@onekeyfe/hd-transport';
|
|
2
1
|
import type { Features } from '../device';
|
|
3
2
|
import type { CommonParams, Response } from '../params';
|
|
4
3
|
|
|
5
|
-
export
|
|
6
|
-
/**
|
|
7
|
-
* 限定本次解锁允许使用的 PIN 类型。省略时保持兼容行为,仅允许主 PIN。
|
|
8
|
-
*/
|
|
9
|
-
pinType?: DeviceSessionPinType;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export declare function deviceUnlock(
|
|
13
|
-
connectId: string,
|
|
14
|
-
params?: CommonParams & DeviceUnlockParams
|
|
15
|
-
): Response<Features>;
|
|
4
|
+
export declare function deviceUnlock(connectId: string, params?: CommonParams): Response<Features>;
|
|
@@ -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
|
@@ -14,7 +14,6 @@ export type {
|
|
|
14
14
|
export type { CipheredKeyValue, CipheredKeyValueParams } from './cipherKeyValue';
|
|
15
15
|
|
|
16
16
|
export type { DeviceChangePinParams } from './deviceChangePin';
|
|
17
|
-
export type { DeviceUnlockParams } from './deviceUnlock';
|
|
18
17
|
export type { DeviceFlagsParams } from './deviceFlags';
|
|
19
18
|
export type { DeviceRecoveryParams } from './deviceRecovery';
|
|
20
19
|
export type { DeviceResetParams } from './deviceReset';
|
|
@@ -26,12 +25,30 @@ export type {
|
|
|
26
25
|
DeviceUploadResourceResponse,
|
|
27
26
|
} from './deviceUploadResource';
|
|
28
27
|
export type {
|
|
28
|
+
FirmwareArtifactReader,
|
|
29
|
+
FirmwareArtifactReference,
|
|
30
|
+
FirmwareUpdateHostBinding,
|
|
31
|
+
FirmwareUpdateArtifactParams,
|
|
29
32
|
FirmwareUpdateParams,
|
|
30
33
|
FirmwareUpdateBinaryParams,
|
|
31
34
|
FirmwareUpdateV3Params,
|
|
32
35
|
FirmwareUpdateV4Params,
|
|
33
36
|
FirmwareUpdateV4Target,
|
|
34
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';
|
|
35
52
|
export type { AllFirmwareRelease } from './checkAllFirmwareRelease';
|
|
36
53
|
export type {
|
|
37
54
|
ProtocolV2FirmwareComponentRelease,
|
|
@@ -1,14 +1,52 @@
|
|
|
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
|
+
resourceEntries?: Array<{
|
|
41
|
+
entryName: string;
|
|
42
|
+
artifact: FirmwareArtifactReference;
|
|
43
|
+
}>;
|
|
44
|
+
updateType: IUpdateType;
|
|
45
|
+
forcedUpdateRes?: boolean;
|
|
46
|
+
isUpdateBootloader?: boolean;
|
|
47
|
+
firmwareType?: EFirmwareType;
|
|
48
|
+
}
|
|
49
|
+
|
|
12
50
|
export interface FirmwareUpdateParams {
|
|
13
51
|
version?: number[];
|
|
14
52
|
updateType: IUpdateType;
|
|
@@ -37,8 +75,14 @@ export declare function firmwareUpdateV2(
|
|
|
37
75
|
connectId: string | undefined,
|
|
38
76
|
params: Params<FirmwareUpdateBinaryParams & Platform>
|
|
39
77
|
): Response<PROTO.Success>;
|
|
78
|
+
export declare function firmwareUpdateV2(
|
|
79
|
+
connectId: string | undefined,
|
|
80
|
+
params: Params<FirmwareUpdateArtifactParams & Platform>
|
|
81
|
+
): Response<PROTO.Success>;
|
|
40
82
|
|
|
41
83
|
export interface FirmwareUpdateV3Params {
|
|
84
|
+
preparedPlan?: FirmwareUpdatePreparedPlan;
|
|
85
|
+
hostBindingGeneration?: number;
|
|
42
86
|
bleVersion?: number[];
|
|
43
87
|
bleBinary?: ArrayBuffer;
|
|
44
88
|
chunkSize?: number;
|
|
@@ -55,6 +99,17 @@ export interface FirmwareUpdateV3Params {
|
|
|
55
99
|
firmwareType?: EFirmwareType;
|
|
56
100
|
|
|
57
101
|
platform: IPlatform;
|
|
102
|
+
|
|
103
|
+
artifactReader?: FirmwareArtifactReader;
|
|
104
|
+
artifacts?: {
|
|
105
|
+
ble?: FirmwareArtifactReference;
|
|
106
|
+
firmware?: FirmwareArtifactReference;
|
|
107
|
+
bootloader?: FirmwareArtifactReference;
|
|
108
|
+
resourceEntries?: Array<{
|
|
109
|
+
entryName: string;
|
|
110
|
+
artifact: FirmwareArtifactReference;
|
|
111
|
+
}>;
|
|
112
|
+
};
|
|
58
113
|
}
|
|
59
114
|
|
|
60
115
|
/**
|
|
@@ -63,7 +118,6 @@ export interface FirmwareUpdateV3Params {
|
|
|
63
118
|
*/
|
|
64
119
|
export type FirmwareUpdateV4Target =
|
|
65
120
|
| 'boot'
|
|
66
|
-
| 'boot_resources'
|
|
67
121
|
| 'app_v1'
|
|
68
122
|
| 'app_v2'
|
|
69
123
|
| 'coprocessor'
|
|
@@ -74,10 +128,14 @@ export type FirmwareUpdateV4Target =
|
|
|
74
128
|
| 'se04';
|
|
75
129
|
|
|
76
130
|
export interface FirmwareUpdateV4Params {
|
|
131
|
+
preparedPlan?: FirmwareUpdatePreparedPlan;
|
|
132
|
+
hostBindingGeneration?: number;
|
|
77
133
|
platform: IPlatform;
|
|
134
|
+
expectedDeviceId?: string;
|
|
78
135
|
chunkSize?: number;
|
|
79
136
|
firmwareType?: EFirmwareType;
|
|
80
137
|
targetsToUpdate?: FirmwareUpdateV4Target[];
|
|
138
|
+
expectedTargetVersions?: Partial<Record<FirmwareUpdateV4Target, string>>;
|
|
81
139
|
|
|
82
140
|
/** FW_MGMT_TARGET_ROMLOADER = 2; Pro2 cannot install it through firmwareUpdateV4. */
|
|
83
141
|
romloaderBinary?: ArrayBuffer;
|
|
@@ -96,17 +154,31 @@ export interface FirmwareUpdateV4Params {
|
|
|
96
154
|
se04Binary?: ArrayBuffer;
|
|
97
155
|
forcedUpdateRes?: boolean;
|
|
98
156
|
/**
|
|
99
|
-
*
|
|
100
|
-
*
|
|
157
|
+
* RESC bundle okpkg files written directly to devicePath through FilesystemFileWrite.
|
|
158
|
+
* Manual mode installs them without version comparison.
|
|
101
159
|
*/
|
|
102
|
-
|
|
160
|
+
resourceBundleFiles?: Array<{
|
|
103
161
|
binary: ArrayBuffer;
|
|
104
162
|
devicePath: string;
|
|
105
|
-
|
|
106
|
-
|
|
163
|
+
}>;
|
|
164
|
+
artifactReader?: FirmwareArtifactReader;
|
|
165
|
+
componentArtifacts?: Partial<
|
|
166
|
+
Record<Exclude<FirmwareUpdateV4Target, 'resource'>, FirmwareArtifactReference>
|
|
167
|
+
>;
|
|
168
|
+
resourceBundleArtifacts?: Array<{
|
|
169
|
+
name: string;
|
|
170
|
+
artifact: FirmwareArtifactReference;
|
|
107
171
|
}>;
|
|
108
172
|
}
|
|
109
173
|
|
|
174
|
+
export declare function registerFirmwareUpdateHostBinding(
|
|
175
|
+
binding: FirmwareUpdateHostBinding
|
|
176
|
+
): number;
|
|
177
|
+
|
|
178
|
+
export declare function unregisterFirmwareUpdateHostBinding(generation?: number): boolean;
|
|
179
|
+
|
|
180
|
+
export declare function getFirmwareUpdateHostBindingGeneration(): number;
|
|
181
|
+
|
|
110
182
|
export declare function firmwareUpdateV3(
|
|
111
183
|
connectId: string | undefined,
|
|
112
184
|
params: Params<FirmwareUpdateV3Params>
|