@onekeyfe/hd-core 1.2.0-alpha.2 → 1.2.0-alpha.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__tests__/AllNetworkGetAddressBase.tracing.test.ts +75 -0
- package/__tests__/DeviceCommands.test.ts +285 -0
- package/__tests__/DeviceEventRegistration.test.ts +43 -0
- package/__tests__/connectSettings.test.ts +19 -0
- package/__tests__/core-dispose.test.ts +34 -0
- package/__tests__/core-error-output.test.ts +39 -0
- package/__tests__/device-features-state.test.ts +78 -0
- package/__tests__/device-identity.test.ts +30 -0
- package/__tests__/device-lifecycle-events.test.ts +117 -0
- package/__tests__/device-pool-state.test.ts +132 -0
- package/__tests__/device-settings.test.ts +391 -0
- package/__tests__/device-state-contract.test.ts +27 -0
- package/__tests__/device-state-events.test.ts +162 -0
- package/__tests__/device-state-mapper.test.ts +241 -0
- package/__tests__/device-state-projector.test.ts +94 -0
- package/__tests__/device-state-store.test.ts +82 -0
- package/__tests__/device-utils.test.ts +106 -0
- package/__tests__/device-wallet-session-store.test.ts +213 -0
- package/__tests__/deviceFeaturesUtils.test.ts +39 -0
- package/__tests__/deviceSettings.test.ts +103 -0
- package/__tests__/evmLedgerLegacySafety.test.ts +10 -6
- package/__tests__/evmSignTypedData.test.ts +80 -0
- package/__tests__/filesystemValidation.test.ts +53 -0
- package/__tests__/firmware-update/firmware-update-v2-download-before-boot.test.ts +402 -0
- package/__tests__/get-device-state.test.ts +410 -0
- package/__tests__/homescreen.test.ts +24 -0
- package/__tests__/kaspaSignTransaction.test.ts +591 -0
- package/__tests__/logBlockEvent.test.ts +26 -0
- package/__tests__/networkUtils.test.ts +386 -0
- package/__tests__/open-wallet-session-error-response.test.ts +43 -0
- package/__tests__/open-wallet-session.test.ts +559 -0
- package/__tests__/preInitialize.test.ts +33 -0
- package/__tests__/pro2Wallpaper.test.ts +50 -0
- package/__tests__/protocol-v2-bootloader-mode.test.ts +37 -0
- package/__tests__/protocol-v2-firmware-targets.test.ts +19 -0
- package/__tests__/protocol-v2.test.ts +3954 -1191
- package/__tests__/protocolV2FileWrite.test.ts +92 -0
- package/__tests__/protocolV2UiInteraction.test.ts +266 -0
- package/__tests__/public-device-state-api.test.ts +257 -0
- package/__tests__/public-pro2-api-boundary.test.ts +110 -0
- package/__tests__/refresh-device-state.test.ts +101 -0
- package/__tests__/request-context-logging.test.ts +16 -0
- package/__tests__/search-devices.test.ts +136 -0
- package/dist/api/BaseMethod.d.ts +8 -0
- package/dist/api/BaseMethod.d.ts.map +1 -1
- package/dist/api/CheckBootloaderRelease.d.ts.map +1 -1
- package/dist/api/CheckFirmwareRelease.d.ts.map +1 -1
- package/dist/api/ClearSessionCache.d.ts +9 -0
- package/dist/api/ClearSessionCache.d.ts.map +1 -0
- package/dist/api/DirList.d.ts.map +1 -1
- package/dist/api/FileRead.d.ts.map +1 -1
- package/dist/api/FileWrite.d.ts +1 -0
- package/dist/api/FileWrite.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV2.d.ts +2 -2
- package/dist/api/FirmwareUpdateV2.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV3.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV4.d.ts +25 -5
- package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
- package/dist/api/GetDeviceState.d.ts +7 -0
- package/dist/api/GetDeviceState.d.ts.map +1 -0
- package/dist/api/GetFeatures.d.ts +1 -1
- package/dist/api/GetFeatures.d.ts.map +1 -1
- package/dist/api/GetOnekeyFeatures.d.ts.map +1 -1
- package/dist/api/GetPassphraseState.d.ts +1 -6
- package/dist/api/GetPassphraseState.d.ts.map +1 -1
- package/dist/api/OpenWalletSession.d.ts +14 -0
- package/dist/api/OpenWalletSession.d.ts.map +1 -0
- package/dist/api/PathInfo.d.ts.map +1 -1
- package/dist/api/PromptWebDeviceAccess.d.ts.map +1 -1
- package/dist/api/SearchDevices.d.ts +3 -0
- package/dist/api/SearchDevices.d.ts.map +1 -1
- package/dist/api/UploadPortfolio.d.ts +17 -0
- package/dist/api/UploadPortfolio.d.ts.map +1 -0
- package/dist/api/allnetwork/AllNetworkGetAddressBase.d.ts.map +1 -1
- package/dist/api/device/DeviceCancel.d.ts.map +1 -1
- package/dist/api/device/DeviceChangePin.d.ts.map +1 -1
- package/dist/api/device/DeviceFullyUploadResource.d.ts +1 -2
- package/dist/api/device/DeviceFullyUploadResource.d.ts.map +1 -1
- package/dist/api/device/DeviceLock.d.ts.map +1 -1
- package/dist/api/device/DeviceRebootToBoardloader.d.ts.map +1 -1
- package/dist/api/device/DeviceRebootToBootloader.d.ts.map +1 -1
- package/dist/api/device/DeviceSettings.d.ts.map +1 -1
- package/dist/api/device/DeviceUnlock.d.ts +1 -1
- package/dist/api/device/DeviceUnlock.d.ts.map +1 -1
- package/dist/api/device/DeviceUpdateBootloader.d.ts.map +1 -1
- package/dist/api/device/DeviceWipe.d.ts.map +1 -1
- package/dist/api/evm/EVMSignTypedData.d.ts.map +1 -1
- package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts +1 -0
- package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts.map +1 -1
- package/dist/api/firmware/getBinary.d.ts +11 -3
- 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/helpers/filesystemValidation.d.ts +3 -0
- package/dist/api/helpers/filesystemValidation.d.ts.map +1 -1
- package/dist/api/helpers/paramsValidator.d.ts +1 -0
- package/dist/api/helpers/paramsValidator.d.ts.map +1 -1
- package/dist/api/helpers/protocolV2FileWrite.d.ts +33 -0
- package/dist/api/helpers/protocolV2FileWrite.d.ts.map +1 -0
- package/dist/api/index.d.ts +12 -19
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/kaspa/KaspaSignTransaction.d.ts +5 -1
- package/dist/api/kaspa/KaspaSignTransaction.d.ts.map +1 -1
- package/dist/api/kaspa/helpers/TransferSerialize.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceFactoryInfoGet.d.ts +6 -0
- package/dist/api/protocol-v2/DeviceFactoryInfoGet.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceFactoryInfoSet.d.ts +7 -0
- package/dist/api/protocol-v2/DeviceFactoryInfoSet.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceFirmwareUpdate.d.ts +1 -1
- package/dist/api/protocol-v2/DeviceFirmwareUpdate.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceGetFirmwareUpdateStatus.d.ts +3 -2
- package/dist/api/protocol-v2/DeviceGetFirmwareUpdateStatus.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts +1 -1
- package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceInfoGet.d.ts +28 -0
- package/dist/api/protocol-v2/DeviceInfoGet.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceReboot.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceStatusGet.d.ts +6 -0
- package/dist/api/protocol-v2/DeviceStatusGet.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceUploadWallpaper.d.ts +26 -0
- package/dist/api/protocol-v2/DeviceUploadWallpaper.d.ts.map +1 -0
- package/dist/api/protocol-v2/FilesystemFormat.d.ts.map +1 -1
- package/dist/api/protocol-v2/{FilesystemFixPermission.d.ts → FilesystemPermissionFix.d.ts} +2 -2
- package/dist/api/protocol-v2/FilesystemPermissionFix.d.ts.map +1 -0
- package/dist/api/protocol-v2/ProtocolInfoRequest.d.ts +6 -0
- package/dist/api/protocol-v2/ProtocolInfoRequest.d.ts.map +1 -0
- package/dist/api/protocol-v2/helpers.d.ts +27 -19
- package/dist/api/protocol-v2/helpers.d.ts.map +1 -1
- package/dist/api/ton/TonSignData.d.ts +1 -5
- package/dist/api/ton/TonSignData.d.ts.map +1 -1
- package/dist/api/utils.d.ts +2 -1
- package/dist/api/utils.d.ts.map +1 -1
- package/dist/constants/index.d.ts +2 -1
- package/dist/constants/index.d.ts.map +1 -1
- package/dist/core/RequestQueue.d.ts.map +1 -1
- package/dist/core/deviceEventRegistration.d.ts +11 -0
- package/dist/core/deviceEventRegistration.d.ts.map +1 -0
- package/dist/core/index.d.ts +3 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/data-manager/DataManager.d.ts +1 -1
- 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 +35 -11
- package/dist/device/Device.d.ts.map +1 -1
- package/dist/device/DeviceCommands.d.ts +8 -6
- package/dist/device/DeviceCommands.d.ts.map +1 -1
- package/dist/device/DeviceFeaturesState.d.ts +3 -0
- package/dist/device/DeviceFeaturesState.d.ts.map +1 -0
- package/dist/device/DevicePool.d.ts +4 -2
- package/dist/device/DevicePool.d.ts.map +1 -1
- package/dist/device/DeviceStateMapper.d.ts +13 -0
- package/dist/device/DeviceStateMapper.d.ts.map +1 -0
- package/dist/device/DeviceStateProjector.d.ts +7 -0
- package/dist/device/DeviceStateProjector.d.ts.map +1 -0
- package/dist/device/DeviceStateStore.d.ts +21 -0
- package/dist/device/DeviceStateStore.d.ts.map +1 -0
- package/dist/device/DeviceWalletSessionStore.d.ts +20 -0
- package/dist/device/DeviceWalletSessionStore.d.ts.map +1 -0
- package/dist/device/cloneDeviceState.d.ts +2 -0
- package/dist/device/cloneDeviceState.d.ts.map +1 -0
- package/dist/device/deviceIdentity.d.ts +5 -0
- package/dist/device/deviceIdentity.d.ts.map +1 -0
- package/dist/deviceProfile/buildDeviceFeatures.d.ts +9 -3
- package/dist/deviceProfile/buildDeviceFeatures.d.ts.map +1 -1
- package/dist/deviceProfile/index.d.ts +0 -1
- package/dist/deviceProfile/index.d.ts.map +1 -1
- package/dist/events/device.d.ts +11 -2
- 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 +18 -2
- package/dist/events/ui-request.d.ts.map +1 -1
- package/dist/index.d.ts +1361 -609
- package/dist/index.js +5898 -2860
- package/dist/inject.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/deviceSession.d.ts +7 -0
- package/dist/protocols/protocol-v2/deviceSession.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/features.d.ts +23 -28
- package/dist/protocols/protocol-v2/features.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/firmware.d.ts +11 -9
- package/dist/protocols/protocol-v2/firmware.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/index.d.ts +3 -2
- package/dist/protocols/protocol-v2/index.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/settingsUnlockPolicy.d.ts +16 -0
- package/dist/protocols/protocol-v2/settingsUnlockPolicy.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/uiInteraction.d.ts +39 -0
- package/dist/protocols/protocol-v2/uiInteraction.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/unlockRetry.d.ts +11 -0
- package/dist/protocols/protocol-v2/unlockRetry.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/walletSession.d.ts +19 -0
- package/dist/protocols/protocol-v2/walletSession.d.ts.map +1 -0
- package/dist/types/api/checkAllFirmwareRelease.d.ts +1 -2
- package/dist/types/api/checkAllFirmwareRelease.d.ts.map +1 -1
- package/dist/types/api/deviceSettings.d.ts +11 -2
- package/dist/types/api/deviceSettings.d.ts.map +1 -1
- package/dist/types/api/deviceUnlock.d.ts +2 -2
- package/dist/types/api/deviceUnlock.d.ts.map +1 -1
- package/dist/types/api/firmwareUpdate.d.ts +6 -6
- package/dist/types/api/firmwareUpdate.d.ts.map +1 -1
- package/dist/types/api/getDeviceState.d.ts +12 -0
- package/dist/types/api/getDeviceState.d.ts.map +1 -0
- package/dist/types/api/getFeatures.d.ts.map +1 -1
- package/dist/types/api/getOnekeyFeatures.d.ts.map +1 -1
- package/dist/types/api/getPassphraseState.d.ts +2 -10
- package/dist/types/api/getPassphraseState.d.ts.map +1 -1
- package/dist/types/api/index.d.ts +22 -25
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/types/api/kaspaSignTransaction.d.ts +27 -2
- package/dist/types/api/kaspaSignTransaction.d.ts.map +1 -1
- package/dist/types/api/openWalletSession.d.ts +41 -0
- package/dist/types/api/openWalletSession.d.ts.map +1 -0
- package/dist/types/api/protocolV2.d.ts +23 -28
- package/dist/types/api/protocolV2.d.ts.map +1 -1
- package/dist/types/api/sessionCache.d.ts +10 -0
- package/dist/types/api/sessionCache.d.ts.map +1 -0
- package/dist/types/device.d.ts +121 -5
- package/dist/types/device.d.ts.map +1 -1
- package/dist/types/params.d.ts +1 -0
- package/dist/types/params.d.ts.map +1 -1
- package/dist/types/settings.d.ts +21 -1
- package/dist/types/settings.d.ts.map +1 -1
- package/dist/utils/assets.d.ts +2 -1
- package/dist/utils/assets.d.ts.map +1 -1
- package/dist/utils/deviceFeaturesCompat.d.ts +13 -0
- package/dist/utils/deviceFeaturesCompat.d.ts.map +1 -0
- package/dist/utils/deviceFeaturesUtils.d.ts +13 -3
- package/dist/utils/deviceFeaturesUtils.d.ts.map +1 -1
- package/dist/utils/deviceInfoUtils.d.ts +9 -8
- package/dist/utils/deviceInfoUtils.d.ts.map +1 -1
- package/dist/utils/deviceSettings.d.ts +38 -7
- package/dist/utils/deviceSettings.d.ts.map +1 -1
- package/dist/utils/deviceVersionUtils.d.ts +6 -5
- package/dist/utils/deviceVersionUtils.d.ts.map +1 -1
- package/dist/utils/homescreen.d.ts.map +1 -1
- package/dist/utils/index.d.ts +5 -2
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/networkUtils.d.ts +9 -1
- package/dist/utils/networkUtils.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 +12 -0
- package/dist/utils/pro2Wallpaper.d.ts.map +1 -0
- package/dist/utils/tracing.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/api/BaseMethod.ts +36 -9
- package/src/api/CheckBootloaderRelease.ts +1 -2
- package/src/api/CheckFirmwareRelease.ts +1 -2
- package/src/api/ClearSessionCache.ts +28 -0
- package/src/api/DirList.ts +5 -3
- package/src/api/DirMake.ts +3 -3
- package/src/api/DirRemove.ts +3 -3
- package/src/api/FileDelete.ts +3 -3
- package/src/api/FileRead.ts +23 -7
- package/src/api/FileWrite.ts +23 -168
- package/src/api/FirmwareUpdate.ts +4 -4
- package/src/api/FirmwareUpdateV2.ts +133 -45
- package/src/api/FirmwareUpdateV3.ts +3 -5
- package/src/api/FirmwareUpdateV4.ts +1138 -357
- package/src/api/GetDeviceState.ts +55 -0
- package/src/api/GetFeatures.ts +8 -3
- package/src/api/GetOnekeyFeatures.ts +3 -72
- package/src/api/GetPassphraseState.ts +11 -18
- package/src/api/OpenWalletSession.ts +221 -0
- package/src/api/PathInfo.ts +5 -3
- package/src/api/PromptWebDeviceAccess.ts +2 -3
- package/src/api/SearchDevices.ts +29 -4
- package/src/api/UploadPortfolio.ts +40 -0
- package/src/api/alephium/AlephiumSignTransaction.ts +2 -2
- package/src/api/allnetwork/AllNetworkGetAddressBase.ts +4 -8
- package/src/api/benfen/BenfenGetAddress.ts +1 -1
- package/src/api/btc/BTCGetPublicKey.ts +1 -1
- package/src/api/cardano/CardanoSignMessage.ts +1 -1
- package/src/api/cardano/CardanoSignTransaction.ts +1 -1
- package/src/api/device/DeviceCancel.ts +1 -0
- package/src/api/device/DeviceChangePin.ts +24 -0
- package/src/api/device/DeviceFullyUploadResource.ts +4 -5
- package/src/api/device/DeviceLock.ts +1 -0
- package/src/api/device/DeviceRebootToBoardloader.ts +5 -4
- package/src/api/device/DeviceRebootToBootloader.ts +5 -4
- package/src/api/device/DeviceSettings.ts +183 -1
- package/src/api/device/DeviceUnlock.ts +11 -1
- package/src/api/device/DeviceUpdateBootloader.ts +1 -2
- package/src/api/device/DeviceWipe.ts +19 -0
- package/src/api/evm/EVMSignTypedData.ts +3 -5
- package/src/api/evm/legacyV1/getAddress.ts +2 -2
- package/src/api/evm/legacyV1/getPublicKey.ts +2 -2
- package/src/api/evm/legacyV1/signMessage.ts +2 -2
- package/src/api/evm/legacyV1/signTypedData.ts +2 -2
- package/src/api/evm/legacyV1/signTypedHash.ts +2 -2
- package/src/api/evm/legacyV1/verifyMessage.ts +2 -2
- package/src/api/firmware/FirmwareUpdateBaseMethod.ts +21 -7
- package/src/api/firmware/getBinary.ts +8 -3
- package/src/api/firmware/progressThrottle.ts +44 -0
- package/src/api/helpers/batchGetPublickeys.ts +2 -2
- package/src/api/helpers/filesystemValidation.ts +61 -0
- package/src/api/helpers/paramsValidator.ts +1 -1
- package/src/api/helpers/protocolV2FileWrite.ts +193 -0
- package/src/api/index.ts +14 -20
- package/src/api/kaspa/KaspaSignTransaction.ts +341 -22
- package/src/api/kaspa/helpers/TransferSerialize.ts +14 -0
- package/src/api/nervos/NervosSignTransaction.ts +2 -2
- package/src/api/nexa/NexaSignTransaction.ts +1 -1
- package/src/api/protocol-v2/{FactoryGetDeviceInfo.ts → DeviceFactoryInfoGet.ts} +4 -4
- package/src/api/protocol-v2/DeviceFactoryInfoSet.ts +32 -0
- package/src/api/protocol-v2/DeviceFirmwareUpdate.ts +7 -9
- package/src/api/protocol-v2/DeviceGetFirmwareUpdateStatus.ts +41 -6
- package/src/api/protocol-v2/DeviceGetOnboardingStatus.ts +6 -4
- package/src/api/protocol-v2/DeviceInfoGet.ts +145 -0
- package/src/api/protocol-v2/DeviceReboot.ts +5 -3
- package/src/api/protocol-v2/DeviceStatusGet.ts +16 -0
- package/src/api/protocol-v2/DeviceUploadWallpaper.ts +131 -0
- package/src/api/protocol-v2/FilesystemFormat.ts +5 -2
- package/src/api/protocol-v2/{FilesystemFixPermission.ts → FilesystemPermissionFix.ts} +3 -3
- package/src/api/protocol-v2/Ping.ts +1 -1
- package/src/api/protocol-v2/{GetProtoVersion.ts → ProtocolInfoRequest.ts} +3 -3
- package/src/api/protocol-v2/helpers.ts +58 -62
- package/src/api/ton/TonSignData.ts +1 -5
- package/src/api/utils.ts +7 -3
- package/src/constants/index.ts +7 -1
- package/src/core/RequestQueue.ts +1 -0
- package/src/core/deviceEventRegistration.ts +23 -0
- package/src/core/index.ts +140 -35
- package/src/data/messages/messages-protocol-v2.json +825 -709
- package/src/data/messages/messages.json +286 -1
- package/src/data-manager/DataManager.ts +13 -6
- package/src/data-manager/connectSettings.ts +4 -0
- package/src/device/Device.ts +480 -192
- package/src/device/DeviceCommands.ts +81 -25
- package/src/device/DeviceFeaturesState.ts +25 -0
- package/src/device/DevicePool.ts +67 -19
- package/src/device/DeviceStateMapper.ts +349 -0
- package/src/device/DeviceStateProjector.ts +95 -0
- package/src/device/DeviceStateStore.ts +201 -0
- package/src/device/DeviceWalletSessionStore.ts +105 -0
- package/src/device/cloneDeviceState.ts +39 -0
- package/src/device/deviceIdentity.ts +18 -0
- package/src/deviceProfile/buildDeviceFeatures.ts +235 -210
- package/src/deviceProfile/index.ts +0 -1
- package/src/events/device.ts +17 -1
- package/src/events/logBlockEvent.ts +8 -1
- package/src/events/ui-request.ts +24 -2
- package/src/inject.ts +23 -34
- package/src/protocols/protocol-v2/deviceSession.ts +24 -0
- package/src/protocols/protocol-v2/features.ts +68 -82
- package/src/protocols/protocol-v2/firmware.ts +12 -36
- package/src/protocols/protocol-v2/index.ts +3 -1
- package/src/protocols/protocol-v2/lockedError.ts +10 -0
- package/src/protocols/protocol-v2/settingsUnlockPolicy.ts +61 -0
- package/src/protocols/protocol-v2/uiInteraction.ts +210 -0
- package/src/protocols/protocol-v2/unlockRetry.ts +76 -0
- package/src/protocols/protocol-v2/walletSession.ts +107 -0
- package/src/types/api/checkAllFirmwareRelease.ts +1 -2
- package/src/types/api/deviceSettings.ts +26 -2
- package/src/types/api/deviceUnlock.ts +5 -2
- package/src/types/api/firmwareUpdate.ts +28 -20
- package/src/types/api/getDeviceState.ts +19 -0
- package/src/types/api/getFeatures.ts +3 -0
- package/src/types/api/getOnekeyFeatures.ts +3 -0
- package/src/types/api/getPassphraseState.ts +8 -11
- package/src/types/api/index.ts +30 -53
- package/src/types/api/kaspaSignTransaction.ts +40 -2
- package/src/types/api/openWalletSession.ts +64 -0
- package/src/types/api/protocolV2.ts +58 -55
- package/src/types/api/sessionCache.ts +14 -0
- package/src/types/device.ts +170 -4
- package/src/types/params.ts +4 -0
- package/src/types/settings.ts +42 -30
- package/src/utils/assets.ts +4 -1
- package/src/utils/deviceFeaturesCompat.ts +173 -0
- package/src/utils/deviceFeaturesUtils.ts +68 -24
- package/src/utils/deviceInfoUtils.ts +26 -64
- package/src/utils/deviceSettings.ts +161 -39
- package/src/utils/deviceVersionUtils.ts +25 -44
- package/src/utils/findDefectiveBatchDevice.ts +3 -3
- package/src/utils/homescreen.ts +10 -0
- package/src/utils/index.ts +21 -1
- package/src/utils/networkUtils.ts +270 -14
- package/src/utils/pro2Wallpaper.ts +109 -0
- package/src/utils/tracing.ts +3 -1
- package/dist/api/GetDeviceInfo.d.ts +0 -9
- package/dist/api/GetDeviceInfo.d.ts.map +0 -1
- package/dist/api/protocol-v2/DevReboot.d.ts +0 -7
- package/dist/api/protocol-v2/DevReboot.d.ts.map +0 -1
- package/dist/api/protocol-v2/DeviceGetDeviceInfo.d.ts +0 -29
- package/dist/api/protocol-v2/DeviceGetDeviceInfo.d.ts.map +0 -1
- package/dist/api/protocol-v2/FactoryDeviceInfoSettings.d.ts +0 -7
- package/dist/api/protocol-v2/FactoryDeviceInfoSettings.d.ts.map +0 -1
- package/dist/api/protocol-v2/FactoryGetDeviceInfo.d.ts +0 -6
- package/dist/api/protocol-v2/FactoryGetDeviceInfo.d.ts.map +0 -1
- package/dist/api/protocol-v2/FilesystemDiskControl.d.ts +0 -13
- package/dist/api/protocol-v2/FilesystemDiskControl.d.ts.map +0 -1
- package/dist/api/protocol-v2/FilesystemFixPermission.d.ts.map +0 -1
- package/dist/api/protocol-v2/GetProtoVersion.d.ts +0 -6
- package/dist/api/protocol-v2/GetProtoVersion.d.ts.map +0 -1
- package/dist/deviceProfile/buildDeviceProfile.d.ts +0 -21
- package/dist/deviceProfile/buildDeviceProfile.d.ts.map +0 -1
- package/dist/types/api/getDeviceInfo.d.ts +0 -85
- package/dist/types/api/getDeviceInfo.d.ts.map +0 -1
- package/src/api/GetDeviceInfo.ts +0 -145
- package/src/api/protocol-v2/DevReboot.ts +0 -24
- package/src/api/protocol-v2/DeviceGetDeviceInfo.ts +0 -118
- package/src/api/protocol-v2/FactoryDeviceInfoSettings.ts +0 -29
- package/src/api/protocol-v2/FilesystemDiskControl.ts +0 -50
- package/src/deviceProfile/buildDeviceProfile.ts +0 -334
- package/src/types/api/getDeviceInfo.ts +0 -99
package/src/utils/homescreen.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { EDeviceType } from '@onekeyfe/hd-shared';
|
|
|
3
3
|
|
|
4
4
|
import { getDeviceType } from './deviceInfoUtils';
|
|
5
5
|
import { getDeviceFirmwareVersion } from './deviceVersionUtils';
|
|
6
|
+
import { PRO2_WALLPAPER_HEIGHT, PRO2_WALLPAPER_WIDTH } from './pro2Wallpaper';
|
|
6
7
|
|
|
7
8
|
import type { Features, IDeviceType } from '../types';
|
|
8
9
|
|
|
@@ -310,6 +311,15 @@ export const getHomeScreenSize = ({
|
|
|
310
311
|
homeScreenType: 'WallPaper' | 'Nft';
|
|
311
312
|
thumbnail?: boolean;
|
|
312
313
|
}) => {
|
|
314
|
+
if (deviceType === EDeviceType.Pro2) {
|
|
315
|
+
return thumbnail
|
|
316
|
+
? undefined
|
|
317
|
+
: {
|
|
318
|
+
width: PRO2_WALLPAPER_WIDTH,
|
|
319
|
+
height: PRO2_WALLPAPER_HEIGHT,
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
|
|
313
323
|
const sizes: Partial<
|
|
314
324
|
Record<
|
|
315
325
|
IDeviceType,
|
package/src/utils/index.ts
CHANGED
|
@@ -8,6 +8,7 @@ export {
|
|
|
8
8
|
getDeviceTypeByBleName,
|
|
9
9
|
getDeviceType,
|
|
10
10
|
getDeviceBleName,
|
|
11
|
+
getDeviceSerialNo,
|
|
11
12
|
getDeviceUUID,
|
|
12
13
|
getDeviceLabel,
|
|
13
14
|
getMethodVersionRange,
|
|
@@ -29,7 +30,24 @@ export {
|
|
|
29
30
|
checkNeedUpdateBootForTouch,
|
|
30
31
|
checkNeedUpdateBootForClassicAndMini,
|
|
31
32
|
} from '../api/firmware/updateBootloader';
|
|
32
|
-
export {
|
|
33
|
+
export {
|
|
34
|
+
DEVICE_SETTINGS_SHARED_FIELDS,
|
|
35
|
+
DEVICE_SETTINGS_V1_ONLY_FIELDS,
|
|
36
|
+
DEVICE_SETTINGS_V2_ONLY_FIELDS,
|
|
37
|
+
PROTOCOL_V2_NEVER_TIMEOUT_MS,
|
|
38
|
+
getAutoLockOptions,
|
|
39
|
+
getAutoShutDownOptions,
|
|
40
|
+
getDeviceSettingsCapabilities,
|
|
41
|
+
getLanguageConfig,
|
|
42
|
+
normalizeSafetyCheckLevel,
|
|
43
|
+
} from './deviceSettings';
|
|
44
|
+
export type {
|
|
45
|
+
DeviceSettingsCapabilities,
|
|
46
|
+
DeviceSettingsDurationOption,
|
|
47
|
+
DeviceSettingsField,
|
|
48
|
+
DeviceSettingsProtocol,
|
|
49
|
+
DeviceSettingsValueOption,
|
|
50
|
+
} from './deviceSettings';
|
|
33
51
|
|
|
34
52
|
// Helpers utils
|
|
35
53
|
|
|
@@ -38,6 +56,8 @@ export { getHDPath, getScriptType, getOutputScriptType } from '../api/helpers/pa
|
|
|
38
56
|
export const isBleConnect = (env: string) => env === 'react-native' || env === 'lowlevel';
|
|
39
57
|
|
|
40
58
|
export { getHomeScreenHex, getHomeScreenDefaultList, getHomeScreenSize } from './homescreen';
|
|
59
|
+
export { encodePro2Wallpaper, PRO2_WALLPAPER_HEIGHT, PRO2_WALLPAPER_WIDTH } from './pro2Wallpaper';
|
|
60
|
+
export type { Pro2WallpaperColorFormat } from './pro2Wallpaper';
|
|
41
61
|
|
|
42
62
|
export const wait = (ms: number) =>
|
|
43
63
|
new Promise(resolve => {
|
|
@@ -1,25 +1,281 @@
|
|
|
1
|
-
import axios from 'axios';
|
|
1
|
+
import axios, { type AxiosResponse } from 'axios';
|
|
2
2
|
|
|
3
|
-
export
|
|
3
|
+
export type HttpRequestOptions = {
|
|
4
|
+
/** Axios adapter-defined request timeout retained for existing opt-in callers. */
|
|
5
|
+
timeoutMs?: number;
|
|
6
|
+
/** Deadline for DNS, connection, TLS, redirects, and the first response-body progress. */
|
|
7
|
+
connectTimeoutMs?: number;
|
|
8
|
+
/** Maximum idle interval between response-body progress events. */
|
|
9
|
+
readTimeoutMs?: number;
|
|
10
|
+
/** Wall-clock deadline across all attempts and retry backoff. */
|
|
11
|
+
overallTimeoutMs?: number;
|
|
12
|
+
maxRetries?: number;
|
|
13
|
+
retryDelayMs?: number;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const MAX_RETRY_COUNT = 3;
|
|
17
|
+
const REQUEST_PHASE_TIMEOUT_CODES = {
|
|
18
|
+
connect: 'ECONNECTTIMEDOUT',
|
|
19
|
+
read: 'EREADTIMEDOUT',
|
|
20
|
+
} as const;
|
|
21
|
+
const RETRYABLE_HTTP_STATUSES = new Set([500, 502, 503, 504]);
|
|
22
|
+
const RETRYABLE_NETWORK_ERROR_CODES = new Set([
|
|
23
|
+
REQUEST_PHASE_TIMEOUT_CODES.connect,
|
|
24
|
+
REQUEST_PHASE_TIMEOUT_CODES.read,
|
|
25
|
+
'ECONNABORTED',
|
|
26
|
+
'ECONNREFUSED',
|
|
27
|
+
'ECONNRESET',
|
|
28
|
+
'EHOSTUNREACH',
|
|
29
|
+
'ENETDOWN',
|
|
30
|
+
'ENETUNREACH',
|
|
31
|
+
'ENOTFOUND',
|
|
32
|
+
'EAI_AGAIN',
|
|
33
|
+
'ERR_NETWORK',
|
|
34
|
+
'ETIMEDOUT',
|
|
35
|
+
]);
|
|
36
|
+
|
|
37
|
+
const createAbortError = () => {
|
|
38
|
+
const error = new Error('httpRequest aborted');
|
|
39
|
+
error.name = 'AbortError';
|
|
40
|
+
return error;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const createOverallTimeoutError = (url: string, timeoutMs: number) => {
|
|
44
|
+
const error = new Error(`httpRequest overall timeout: ${url} ${timeoutMs}ms`);
|
|
45
|
+
error.name = 'HttpRequestOverallTimeoutError';
|
|
46
|
+
return error;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const createRequestPhaseTimeoutError = (
|
|
50
|
+
url: string,
|
|
51
|
+
phase: keyof typeof REQUEST_PHASE_TIMEOUT_CODES,
|
|
52
|
+
timeoutMs: number
|
|
53
|
+
) => {
|
|
54
|
+
const error = new Error(`httpRequest ${phase} timeout: ${url} ${timeoutMs}ms`);
|
|
55
|
+
error.name = 'HttpRequestPhaseTimeoutError';
|
|
56
|
+
return Object.assign(error, {
|
|
57
|
+
code: REQUEST_PHASE_TIMEOUT_CODES[phase],
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const waitForRetry = async (delayMs: number, attempt: number, signal?: AbortSignal) => {
|
|
62
|
+
const backoffMs = delayMs * 2 ** attempt;
|
|
63
|
+
if (backoffMs <= 0) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
await new Promise<void>((resolve, reject) => {
|
|
67
|
+
const timeoutTimer = setTimeout(() => {
|
|
68
|
+
signal?.removeEventListener('abort', handleAbort);
|
|
69
|
+
resolve();
|
|
70
|
+
}, backoffMs);
|
|
71
|
+
const handleAbort = () => {
|
|
72
|
+
clearTimeout(timeoutTimer);
|
|
73
|
+
reject(createAbortError());
|
|
74
|
+
};
|
|
75
|
+
if (signal?.aborted) {
|
|
76
|
+
handleAbort();
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
signal?.addEventListener('abort', handleAbort, { once: true });
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const isRetryableRequestError = (error: unknown) => {
|
|
84
|
+
if (axios.isCancel(error)) {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
if (
|
|
88
|
+
typeof error === 'object' &&
|
|
89
|
+
error !== null &&
|
|
90
|
+
'code' in error &&
|
|
91
|
+
typeof error.code === 'string' &&
|
|
92
|
+
RETRYABLE_NETWORK_ERROR_CODES.has(error.code)
|
|
93
|
+
) {
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
if (!axios.isAxiosError(error)) {
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
const status = error.response?.status;
|
|
100
|
+
if (status !== undefined) {
|
|
101
|
+
return RETRYABLE_HTTP_STATUSES.has(Number(status));
|
|
102
|
+
}
|
|
103
|
+
return false;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export const httpRequest = async <T = unknown>(
|
|
107
|
+
url: string,
|
|
108
|
+
type = 'text',
|
|
109
|
+
options: HttpRequestOptions = {}
|
|
110
|
+
): Promise<T> => {
|
|
4
111
|
const headers: any = {};
|
|
5
112
|
if (url.indexOf('ngrok-free.app') > -1) {
|
|
6
113
|
headers['ngrok-skip-browser-warning'] = true;
|
|
7
114
|
}
|
|
8
|
-
const response = await axios.request({
|
|
9
|
-
url,
|
|
10
|
-
withCredentials: false,
|
|
11
|
-
responseType: type === 'binary' ? 'arraybuffer' : 'json',
|
|
12
|
-
headers,
|
|
13
|
-
});
|
|
14
115
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
116
|
+
const timeoutMs =
|
|
117
|
+
Number.isSafeInteger(options.timeoutMs) && Number(options.timeoutMs) > 0
|
|
118
|
+
? Number(options.timeoutMs)
|
|
119
|
+
: undefined;
|
|
120
|
+
const connectTimeoutMs =
|
|
121
|
+
Number.isSafeInteger(options.connectTimeoutMs) && Number(options.connectTimeoutMs) > 0
|
|
122
|
+
? Number(options.connectTimeoutMs)
|
|
123
|
+
: undefined;
|
|
124
|
+
const readTimeoutMs =
|
|
125
|
+
Number.isSafeInteger(options.readTimeoutMs) && Number(options.readTimeoutMs) > 0
|
|
126
|
+
? Number(options.readTimeoutMs)
|
|
127
|
+
: undefined;
|
|
128
|
+
const overallTimeoutMs =
|
|
129
|
+
Number.isSafeInteger(options.overallTimeoutMs) && Number(options.overallTimeoutMs) > 0
|
|
130
|
+
? Number(options.overallTimeoutMs)
|
|
131
|
+
: undefined;
|
|
132
|
+
const maxRetries =
|
|
133
|
+
Number.isSafeInteger(options.maxRetries) && Number(options.maxRetries) > 0
|
|
134
|
+
? Math.min(Number(options.maxRetries), MAX_RETRY_COUNT)
|
|
135
|
+
: 0;
|
|
136
|
+
const retryDelayMs =
|
|
137
|
+
Number.isSafeInteger(options.retryDelayMs) && Number(options.retryDelayMs) > 0
|
|
138
|
+
? Number(options.retryDelayMs)
|
|
139
|
+
: 0;
|
|
140
|
+
const overallTimeoutError = overallTimeoutMs
|
|
141
|
+
? createOverallTimeoutError(url, overallTimeoutMs)
|
|
142
|
+
: undefined;
|
|
143
|
+
const overallDeadlineAt = overallTimeoutMs ? Date.now() + overallTimeoutMs : undefined;
|
|
144
|
+
const assertWithinOverallDeadline = () => {
|
|
145
|
+
if (overallDeadlineAt !== undefined && overallTimeoutError && Date.now() >= overallDeadlineAt) {
|
|
146
|
+
throw overallTimeoutError;
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
const request = async (attempt: number, signal?: AbortSignal): Promise<T> => {
|
|
151
|
+
assertWithinOverallDeadline();
|
|
152
|
+
if (signal?.aborted) {
|
|
153
|
+
throw createAbortError();
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
let response: AxiosResponse<T> | undefined;
|
|
157
|
+
let requestError: unknown;
|
|
158
|
+
let requestFailed = false;
|
|
159
|
+
let phaseTimeoutError: ReturnType<typeof createRequestPhaseTimeoutError> | undefined;
|
|
160
|
+
let phaseTimeoutTimer: ReturnType<typeof setTimeout> | undefined;
|
|
161
|
+
const hasPhaseDeadline = Boolean(connectTimeoutMs || readTimeoutMs);
|
|
162
|
+
const attemptController = signal || hasPhaseDeadline ? new AbortController() : undefined;
|
|
163
|
+
let attemptSettled = false;
|
|
164
|
+
let lastProgressLoaded = 0;
|
|
165
|
+
const handleParentAbort = () => {
|
|
166
|
+
attemptController?.abort();
|
|
167
|
+
};
|
|
168
|
+
const clearPhaseTimeout = () => {
|
|
169
|
+
if (phaseTimeoutTimer) {
|
|
170
|
+
clearTimeout(phaseTimeoutTimer);
|
|
171
|
+
phaseTimeoutTimer = undefined;
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
const armPhaseTimeout = (
|
|
175
|
+
phase: keyof typeof REQUEST_PHASE_TIMEOUT_CODES,
|
|
176
|
+
phaseTimeoutMs: number | undefined
|
|
177
|
+
) => {
|
|
178
|
+
clearPhaseTimeout();
|
|
179
|
+
if (!phaseTimeoutMs || !attemptController) {
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
phaseTimeoutTimer = setTimeout(() => {
|
|
183
|
+
phaseTimeoutError = createRequestPhaseTimeoutError(url, phase, phaseTimeoutMs);
|
|
184
|
+
attemptController.abort();
|
|
185
|
+
}, phaseTimeoutMs);
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
if (signal) {
|
|
189
|
+
signal.addEventListener('abort', handleParentAbort, { once: true });
|
|
190
|
+
}
|
|
191
|
+
armPhaseTimeout('connect', connectTimeoutMs);
|
|
192
|
+
|
|
193
|
+
try {
|
|
194
|
+
response = await axios.request<T>({
|
|
195
|
+
url,
|
|
196
|
+
withCredentials: false,
|
|
197
|
+
responseType: type === 'binary' ? 'arraybuffer' : 'json',
|
|
198
|
+
headers,
|
|
199
|
+
...(timeoutMs ? { timeout: timeoutMs } : {}),
|
|
200
|
+
...(attemptController ? { signal: attemptController.signal } : {}),
|
|
201
|
+
...(hasPhaseDeadline
|
|
202
|
+
? {
|
|
203
|
+
adapter: ['xhr', 'http'],
|
|
204
|
+
onDownloadProgress: (progressEvent: { loaded: number }) => {
|
|
205
|
+
if (
|
|
206
|
+
attemptSettled ||
|
|
207
|
+
attemptController?.signal.aborted ||
|
|
208
|
+
!Number.isFinite(progressEvent.loaded) ||
|
|
209
|
+
progressEvent.loaded <= lastProgressLoaded
|
|
210
|
+
) {
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
lastProgressLoaded = progressEvent.loaded;
|
|
214
|
+
armPhaseTimeout('read', readTimeoutMs);
|
|
215
|
+
},
|
|
216
|
+
}
|
|
217
|
+
: {}),
|
|
218
|
+
});
|
|
219
|
+
if (phaseTimeoutError) {
|
|
220
|
+
requestFailed = true;
|
|
221
|
+
requestError = phaseTimeoutError;
|
|
222
|
+
response = undefined;
|
|
223
|
+
}
|
|
224
|
+
} catch (error) {
|
|
225
|
+
requestFailed = true;
|
|
226
|
+
requestError = phaseTimeoutError ?? (signal?.aborted ? createAbortError() : error);
|
|
227
|
+
} finally {
|
|
228
|
+
attemptSettled = true;
|
|
229
|
+
clearPhaseTimeout();
|
|
230
|
+
signal?.removeEventListener('abort', handleParentAbort);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
assertWithinOverallDeadline();
|
|
234
|
+
|
|
235
|
+
if (requestFailed) {
|
|
236
|
+
if (attempt >= maxRetries || !isRetryableRequestError(requestError)) {
|
|
237
|
+
throw requestError;
|
|
238
|
+
}
|
|
239
|
+
await waitForRetry(retryDelayMs, attempt, signal);
|
|
240
|
+
assertWithinOverallDeadline();
|
|
241
|
+
return request(attempt + 1, signal);
|
|
18
242
|
}
|
|
19
|
-
|
|
243
|
+
|
|
244
|
+
if (!response) {
|
|
245
|
+
throw new Error(`httpRequest completed without a response: ${url}`);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
if (+response.status === 200) {
|
|
20
249
|
return response.data;
|
|
21
250
|
}
|
|
22
|
-
|
|
251
|
+
|
|
252
|
+
if (RETRYABLE_HTTP_STATUSES.has(Number(response.status)) && attempt < maxRetries) {
|
|
253
|
+
await waitForRetry(retryDelayMs, attempt, signal);
|
|
254
|
+
assertWithinOverallDeadline();
|
|
255
|
+
return request(attempt + 1, signal);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
throw new Error(`httpRequest error: ${url} ${response.statusText}`);
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
if (!overallTimeoutMs) {
|
|
262
|
+
return request(0);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
const controller = new AbortController();
|
|
266
|
+
const requestPromise = request(0, controller.signal);
|
|
267
|
+
let timeoutTimer: ReturnType<typeof setTimeout> | undefined;
|
|
268
|
+
try {
|
|
269
|
+
return await new Promise<T>((resolve, reject) => {
|
|
270
|
+
timeoutTimer = setTimeout(() => {
|
|
271
|
+
reject(overallTimeoutError);
|
|
272
|
+
controller.abort();
|
|
273
|
+
}, overallTimeoutMs);
|
|
274
|
+
requestPromise.then(resolve, reject);
|
|
275
|
+
});
|
|
276
|
+
} finally {
|
|
277
|
+
if (timeoutTimer) {
|
|
278
|
+
clearTimeout(timeoutTimer);
|
|
279
|
+
}
|
|
23
280
|
}
|
|
24
|
-
throw new Error(`httpRequest error: ${url} ${response.statusText}`);
|
|
25
281
|
};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
|
|
2
|
+
|
|
3
|
+
// RGB565 pixel packing and dithering index calculation require bitwise operations.
|
|
4
|
+
/* eslint-disable no-bitwise */
|
|
5
|
+
|
|
6
|
+
export const PRO2_WALLPAPER_WIDTH = 604;
|
|
7
|
+
export const PRO2_WALLPAPER_HEIGHT = 1024;
|
|
8
|
+
|
|
9
|
+
export type Pro2WallpaperColorFormat = 'RGB565' | 'RGB565A8';
|
|
10
|
+
|
|
11
|
+
const COLOR_FORMAT_RGB565 = 0x12;
|
|
12
|
+
const COLOR_FORMAT_RGB565A8 = 0x14;
|
|
13
|
+
|
|
14
|
+
const RED_THRESHOLD = [
|
|
15
|
+
1, 7, 3, 5, 0, 8, 2, 6, 7, 1, 5, 3, 8, 0, 6, 2, 3, 5, 0, 8, 2, 6, 1, 7, 5, 3, 8, 0, 6, 2, 7, 1, 0,
|
|
16
|
+
8, 2, 6, 1, 7, 3, 5, 8, 0, 6, 2, 7, 1, 5, 3, 2, 6, 1, 7, 3, 5, 0, 8, 6, 2, 7, 1, 5, 3, 8, 0,
|
|
17
|
+
];
|
|
18
|
+
const GREEN_THRESHOLD = [
|
|
19
|
+
1, 3, 2, 2, 3, 1, 2, 2, 2, 2, 0, 4, 2, 2, 4, 0, 3, 1, 2, 2, 1, 3, 2, 2, 2, 2, 4, 0, 2, 2, 0, 4, 1,
|
|
20
|
+
3, 2, 2, 3, 1, 2, 2, 2, 2, 0, 4, 2, 2, 4, 0, 3, 1, 2, 2, 1, 3, 2, 2, 2, 2, 4, 0, 2, 2, 0, 4,
|
|
21
|
+
];
|
|
22
|
+
const BLUE_THRESHOLD = [
|
|
23
|
+
5, 3, 8, 0, 6, 2, 7, 1, 3, 5, 0, 8, 2, 6, 1, 7, 8, 0, 6, 2, 7, 1, 5, 3, 0, 8, 2, 6, 1, 7, 3, 5, 6,
|
|
24
|
+
2, 7, 1, 5, 3, 8, 0, 2, 6, 1, 7, 3, 5, 0, 8, 7, 1, 5, 3, 8, 0, 6, 2, 1, 7, 3, 5, 0, 8, 2, 6,
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
function invalidParameter(message: string): Error {
|
|
28
|
+
return ERRORS.TypedError(HardwareErrorCode.CallMethodInvalidParameter, message);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function asBytes(rgba: Uint8Array | ArrayBuffer): Uint8Array {
|
|
32
|
+
return rgba instanceof Uint8Array ? rgba : new Uint8Array(rgba);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function align(value: number, boundary: number): number {
|
|
36
|
+
return Math.ceil(value / boundary) * boundary;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function encodePro2Wallpaper(options: {
|
|
40
|
+
width: number;
|
|
41
|
+
height: number;
|
|
42
|
+
rgba: Uint8Array | ArrayBuffer;
|
|
43
|
+
}): { data: Uint8Array; colorFormat: Pro2WallpaperColorFormat } {
|
|
44
|
+
const { width, height } = options;
|
|
45
|
+
if (!Number.isInteger(width) || width <= 0 || width > 0xffff) {
|
|
46
|
+
throw invalidParameter('Wallpaper width must be an integer between 1 and 65535.');
|
|
47
|
+
}
|
|
48
|
+
if (!Number.isInteger(height) || height <= 0 || height > 0xffff) {
|
|
49
|
+
throw invalidParameter('Wallpaper height must be an integer between 1 and 65535.');
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const rgba = asBytes(options.rgba);
|
|
53
|
+
const expectedLength = width * height * 4;
|
|
54
|
+
if (rgba.byteLength !== expectedLength) {
|
|
55
|
+
throw invalidParameter(
|
|
56
|
+
`Wallpaper RGBA data length must be ${expectedLength} bytes, received ${rgba.byteLength}.`
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
let hasTransparency = false;
|
|
61
|
+
for (let index = 3; index < rgba.length; index += 4) {
|
|
62
|
+
if (rgba[index] !== 0xff) {
|
|
63
|
+
hasTransparency = true;
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const colorFormat: Pro2WallpaperColorFormat = hasTransparency ? 'RGB565A8' : 'RGB565';
|
|
69
|
+
const stride = align(width * 2, 4);
|
|
70
|
+
const alphaStride = stride / 2;
|
|
71
|
+
const rgbSize = stride * height;
|
|
72
|
+
const alphaSize = hasTransparency ? alphaStride * height : 0;
|
|
73
|
+
const data = new Uint8Array(12 + rgbSize + alphaSize);
|
|
74
|
+
const view = new DataView(data.buffer);
|
|
75
|
+
|
|
76
|
+
data[0] = 0x19;
|
|
77
|
+
data[1] = hasTransparency ? COLOR_FORMAT_RGB565A8 : COLOR_FORMAT_RGB565;
|
|
78
|
+
view.setUint16(2, 0, true);
|
|
79
|
+
view.setUint16(4, width, true);
|
|
80
|
+
view.setUint16(6, height, true);
|
|
81
|
+
view.setUint16(8, stride, true);
|
|
82
|
+
view.setUint16(10, 0, true);
|
|
83
|
+
|
|
84
|
+
for (let y = 0; y < height; y += 1) {
|
|
85
|
+
for (let x = 0; x < width; x += 1) {
|
|
86
|
+
const sourceOffset = (y * width + x) * 4;
|
|
87
|
+
const thresholdIndex = ((y & 7) << 3) + (x & 7);
|
|
88
|
+
let red = Math.min(rgba[sourceOffset] + RED_THRESHOLD[thresholdIndex], 0xff) & 0xf8;
|
|
89
|
+
let green = Math.min(rgba[sourceOffset + 1] + GREEN_THRESHOLD[thresholdIndex], 0xff) & 0xfc;
|
|
90
|
+
let blue = Math.min(rgba[sourceOffset + 2] + BLUE_THRESHOLD[thresholdIndex], 0xff) & 0xf8;
|
|
91
|
+
if (!hasTransparency) {
|
|
92
|
+
const alpha = rgba[sourceOffset + 3];
|
|
93
|
+
red = (red * alpha) >> 8;
|
|
94
|
+
green = (green * alpha) >> 8;
|
|
95
|
+
blue = (blue * alpha) >> 8;
|
|
96
|
+
}
|
|
97
|
+
const rgb565 = ((red >> 3) << 11) | ((green >> 2) << 5) | (blue >> 3);
|
|
98
|
+
const rgbOffset = 12 + y * stride + x * 2;
|
|
99
|
+
data[rgbOffset] = rgb565 & 0xff;
|
|
100
|
+
data[rgbOffset + 1] = rgb565 >> 8;
|
|
101
|
+
|
|
102
|
+
if (hasTransparency) {
|
|
103
|
+
data[12 + rgbSize + y * alphaStride + x] = rgba[sourceOffset + 3];
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return { data, colorFormat };
|
|
109
|
+
}
|
package/src/utils/tracing.ts
CHANGED
|
@@ -164,7 +164,9 @@ export function completeRequestContext(responseID: number, error?: Error): void
|
|
|
164
164
|
context.status = error ? 'error' : 'success';
|
|
165
165
|
if (error) {
|
|
166
166
|
context.error = error.message;
|
|
167
|
-
|
|
167
|
+
// Method errors already reach callers through the standard API response.
|
|
168
|
+
// Request tracing is diagnostic and must not emit a second user-facing error.
|
|
169
|
+
Log.debug(
|
|
168
170
|
`[RequestContext] [completeRequestContext] Error: ${formatRequestContext(context)}`
|
|
169
171
|
);
|
|
170
172
|
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { BaseMethod } from './BaseMethod';
|
|
2
|
-
import type { GetDeviceInfoParams } from '../types/api/getDeviceInfo';
|
|
3
|
-
export default class GetDeviceInfo extends BaseMethod<GetDeviceInfoParams> {
|
|
4
|
-
init(): void;
|
|
5
|
-
run(): Promise<import("../types").DeviceProfile>;
|
|
6
|
-
private runProtocolV2;
|
|
7
|
-
private runProtocolV1;
|
|
8
|
-
}
|
|
9
|
-
//# sourceMappingURL=GetDeviceInfo.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GetDeviceInfo.d.ts","sourceRoot":"","sources":["../../src/api/GetDeviceInfo.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,KAAK,EAGV,mBAAmB,EACpB,MAAM,4BAA4B,CAAC;AA0DpC,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,UAAU,CAAC,mBAAmB,CAAC;IACxE,IAAI;IAeE,GAAG;YAOK,aAAa;YAgBb,aAAa;CA4B5B"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { BaseMethod } from '../BaseMethod';
|
|
2
|
-
import type { DeviceRebootParams } from './helpers';
|
|
3
|
-
export default class DevReboot extends BaseMethod<DeviceRebootParams> {
|
|
4
|
-
init(): void;
|
|
5
|
-
run(): Promise<import("packages/hd-transport/dist").Success>;
|
|
6
|
-
}
|
|
7
|
-
//# sourceMappingURL=DevReboot.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DevReboot.d.ts","sourceRoot":"","sources":["../../../src/api/protocol-v2/DevReboot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG3C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAEpD,MAAM,CAAC,OAAO,OAAO,SAAU,SAAQ,UAAU,CAAC,kBAAkB,CAAC;IACnE,IAAI;IAWE,GAAG;CAMV"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { BaseMethod } from '../BaseMethod';
|
|
2
|
-
export type DeviceGetDeviceInfoTargets = {
|
|
3
|
-
hw?: boolean;
|
|
4
|
-
fw?: boolean;
|
|
5
|
-
bt?: boolean;
|
|
6
|
-
se1?: boolean;
|
|
7
|
-
se2?: boolean;
|
|
8
|
-
se3?: boolean;
|
|
9
|
-
se4?: boolean;
|
|
10
|
-
status?: boolean;
|
|
11
|
-
};
|
|
12
|
-
export type DeviceGetDeviceInfoTypes = {
|
|
13
|
-
version?: boolean;
|
|
14
|
-
build_id?: boolean;
|
|
15
|
-
hash?: boolean;
|
|
16
|
-
specific?: boolean;
|
|
17
|
-
};
|
|
18
|
-
export type DeviceGetDeviceInfoParams = {
|
|
19
|
-
targets?: DeviceGetDeviceInfoTargets;
|
|
20
|
-
types?: DeviceGetDeviceInfoTypes;
|
|
21
|
-
};
|
|
22
|
-
export default class DeviceGetDeviceInfo extends BaseMethod<{
|
|
23
|
-
targets: DeviceGetDeviceInfoTargets;
|
|
24
|
-
types: DeviceGetDeviceInfoTypes;
|
|
25
|
-
}> {
|
|
26
|
-
init(): void;
|
|
27
|
-
run(): Promise<import("packages/hd-transport/dist").ProtocolV2DeviceInfo | import("packages/hd-transport/dist").DeviceInfo>;
|
|
28
|
-
}
|
|
29
|
-
//# sourceMappingURL=DeviceGetDeviceInfo.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DeviceGetDeviceInfo.d.ts","sourceRoot":"","sources":["../../../src/api/protocol-v2/DeviceGetDeviceInfo.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,MAAM,MAAM,0BAA0B,GAAG;IACvC,EAAE,CAAC,EAAE,OAAO,CAAC;IACb,EAAE,CAAC,EAAE,OAAO,CAAC;IACb,EAAE,CAAC,EAAE,OAAO,CAAC;IACb,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACrC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACtC,OAAO,CAAC,EAAE,0BAA0B,CAAC;IACrC,KAAK,CAAC,EAAE,wBAAwB,CAAC;CAClC,CAAC;AAmDF,MAAM,CAAC,OAAO,OAAO,mBAAoB,SAAQ,UAAU,CAAC;IAC1D,OAAO,EAAE,0BAA0B,CAAC;IACpC,KAAK,EAAE,wBAAwB,CAAC;CACjC,CAAC;IACA,IAAI;IAmBE,GAAG;CAgBV"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { BaseMethod } from '../BaseMethod';
|
|
2
|
-
import type { FactoryDeviceInfoSettingsParams } from './helpers';
|
|
3
|
-
export default class FactoryDeviceInfoSettings extends BaseMethod<FactoryDeviceInfoSettingsParams> {
|
|
4
|
-
init(): void;
|
|
5
|
-
run(): Promise<import("packages/hd-transport/dist").Success>;
|
|
6
|
-
}
|
|
7
|
-
//# sourceMappingURL=FactoryDeviceInfoSettings.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FactoryDeviceInfoSettings.d.ts","sourceRoot":"","sources":["../../../src/api/protocol-v2/FactoryDeviceInfoSettings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,WAAW,CAAC;AAEjE,MAAM,CAAC,OAAO,OAAO,yBAA0B,SAAQ,UAAU,CAAC,+BAA+B,CAAC;IAChG,IAAI;IAeE,GAAG;CAQV"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FactoryGetDeviceInfo.d.ts","sourceRoot":"","sources":["../../../src/api/protocol-v2/FactoryGetDeviceInfo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,MAAM,CAAC,OAAO,OAAO,oBAAqB,SAAQ,UAAU;IAC1D,IAAI;IAQE,GAAG;CAQV"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { BaseMethod } from '../BaseMethod';
|
|
2
|
-
export type FilesystemDiskControlParams = {
|
|
3
|
-
enable?: boolean | 0 | 1;
|
|
4
|
-
timeoutMs?: number | string;
|
|
5
|
-
};
|
|
6
|
-
export default class FilesystemDiskControl extends BaseMethod<{
|
|
7
|
-
enable: 0 | 1;
|
|
8
|
-
timeoutMs?: number;
|
|
9
|
-
}> {
|
|
10
|
-
init(): void;
|
|
11
|
-
run(): Promise<any>;
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=FilesystemDiskControl.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FilesystemDiskControl.d.ts","sourceRoot":"","sources":["../../../src/api/protocol-v2/FilesystemDiskControl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAM3C,MAAM,MAAM,2BAA2B,GAAG;IAExC,MAAM,CAAC,EAAE,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CAC7B,CAAC;AAUF,MAAM,CAAC,OAAO,OAAO,qBAAsB,SAAQ,UAAU,CAAC;IAC5D,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;IACA,IAAI;IAWE,GAAG;CAcV"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FilesystemFixPermission.d.ts","sourceRoot":"","sources":["../../../src/api/protocol-v2/FilesystemFixPermission.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,MAAM,CAAC,OAAO,OAAO,uBAAwB,SAAQ,UAAU;IAC7D,IAAI;IAQE,GAAG;CAIV"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GetProtoVersion.d.ts","sourceRoot":"","sources":["../../../src/api/protocol-v2/GetProtoVersion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,UAAU;IACrD,IAAI;IAQE,GAAG;CAIV"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { DeviceInfoProtocol, DeviceInfoSource, DeviceProfile, GetDeviceInfoParams } from '../types/api/getDeviceInfo';
|
|
2
|
-
import type { Features, OnekeyFeatures } from '../types';
|
|
3
|
-
import type { ProtocolV2DeviceInfo } from '@onekeyfe/hd-transport';
|
|
4
|
-
type BuildProtocolV1ProfileParams = {
|
|
5
|
-
protocol?: DeviceInfoProtocol;
|
|
6
|
-
features?: Features;
|
|
7
|
-
protocolV1OneKeyFeatures?: OnekeyFeatures;
|
|
8
|
-
sources?: DeviceInfoSource[];
|
|
9
|
-
scope?: GetDeviceInfoParams['scope'];
|
|
10
|
-
includeRaw?: boolean;
|
|
11
|
-
};
|
|
12
|
-
type BuildProtocolV2ProfileParams = {
|
|
13
|
-
deviceInfo?: ProtocolV2DeviceInfo;
|
|
14
|
-
sources?: DeviceInfoSource[];
|
|
15
|
-
scope?: GetDeviceInfoParams['scope'];
|
|
16
|
-
includeRaw?: boolean;
|
|
17
|
-
};
|
|
18
|
-
export declare function buildProfileFromProtocolV1({ protocol, features, protocolV1OneKeyFeatures, sources, scope, includeRaw, }: BuildProtocolV1ProfileParams): DeviceProfile;
|
|
19
|
-
export declare function buildProfileFromProtocolV2({ deviceInfo, sources, scope, includeRaw, }: BuildProtocolV2ProfileParams): DeviceProfile;
|
|
20
|
-
export {};
|
|
21
|
-
//# sourceMappingURL=buildDeviceProfile.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"buildDeviceProfile.d.ts","sourceRoot":"","sources":["../../src/deviceProfile/buildDeviceProfile.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EACV,kBAAkB,EAClB,gBAAgB,EAEhB,aAAa,EAIb,mBAAmB,EACpB,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AACzD,OAAO,KAAK,EAAwB,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAEzF,KAAK,4BAA4B,GAAG;IAClC,QAAQ,CAAC,EAAE,kBAAkB,CAAC;IAC9B,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,wBAAwB,CAAC,EAAE,cAAc,CAAC;IAC1C,OAAO,CAAC,EAAE,gBAAgB,EAAE,CAAC;IAC7B,KAAK,CAAC,EAAE,mBAAmB,CAAC,OAAO,CAAC,CAAC;IACrC,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF,KAAK,4BAA4B,GAAG;IAClC,UAAU,CAAC,EAAE,oBAAoB,CAAC;IAClC,OAAO,CAAC,EAAE,gBAAgB,EAAE,CAAC;IAC7B,KAAK,CAAC,EAAE,mBAAmB,CAAC,OAAO,CAAC,CAAC;IACrC,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AA+NF,wBAAgB,0BAA0B,CAAC,EACzC,QAAe,EACf,QAAQ,EACR,wBAAwB,EACxB,OAAsB,EACtB,KAAe,EACf,UAAkB,GACnB,EAAE,4BAA4B,GAAG,aAAa,CAyB9C;AAED,wBAAgB,0BAA0B,CAAC,EACzC,UAAU,EACV,OAAwB,EACxB,KAAe,EACf,UAAkB,GACnB,EAAE,4BAA4B,GAAG,aAAa,CA4B9C"}
|