@onekeyfe/hd-core 1.2.0-alpha.57 → 1.2.0-alpha.58
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 +84 -2
- package/__tests__/DeviceCommands.test.ts +17 -6
- package/__tests__/core-initialization.test.ts +23 -0
- package/__tests__/device-connector-protocol.test.ts +81 -0
- package/__tests__/device-settings.test.ts +39 -18
- package/__tests__/protocol-v2-resources.test.ts +24 -0
- package/__tests__/protocol-v2.test.ts +49 -126
- package/__tests__/protocolV2FileWrite.test.ts +113 -0
- package/__tests__/public-pro2-api-boundary.test.ts +2 -98
- package/dist/api/FirmwareUpdateV4.d.ts +0 -1
- package/dist/api/FirmwareUpdateV4.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/DeviceVerify.d.ts.map +1 -1
- package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts +4 -2
- package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts.map +1 -1
- package/dist/api/helpers/protocolV2FileWrite.d.ts +7 -0
- package/dist/api/helpers/protocolV2FileWrite.d.ts.map +1 -1
- package/dist/api/index.d.ts +0 -3
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceFactoryInfoGet.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceFactoryInfoSet.d.ts.map +1 -1
- package/dist/api/protocol-v2/helpers.d.ts +5 -15
- package/dist/api/protocol-v2/helpers.d.ts.map +1 -1
- package/dist/api/stellar/StellarSignTransaction.d.ts +1 -1
- package/dist/api/utils.d.ts +1 -6
- package/dist/api/utils.d.ts.map +1 -1
- package/dist/core/index.d.ts +4 -10
- package/dist/core/index.d.ts.map +1 -1
- package/dist/data-manager/DataManager.d.ts +1 -0
- package/dist/data-manager/DataManager.d.ts.map +1 -1
- package/dist/data-manager/TransportManager.d.ts.map +1 -1
- package/dist/device/DeviceCommands.d.ts.map +1 -1
- package/dist/device/DeviceConnector.d.ts +2 -1
- package/dist/device/DeviceConnector.d.ts.map +1 -1
- package/dist/index.d.ts +44 -723
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +499 -2953
- package/dist/inject.d.ts +2 -6
- package/dist/inject.d.ts.map +1 -1
- package/dist/types/api/index.d.ts +3 -176
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/types/api/protocolV2.d.ts +2 -8
- package/dist/types/api/protocolV2.d.ts.map +1 -1
- package/dist/utils/patch.d.ts +1 -1
- package/dist/utils/patch.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/api/FirmwareUpdateV4.ts +39 -69
- package/src/api/allnetwork/AllNetworkGetAddressBase.ts +3 -1
- package/src/api/device/DeviceSettings.ts +5 -4
- package/src/api/device/DeviceVerify.ts +0 -2
- package/src/api/firmware/FirmwareUpdateBaseMethod.ts +12 -1
- package/src/api/helpers/protocolV2FileWrite.ts +192 -73
- package/src/api/index.ts +0 -3
- package/src/api/protocol-v2/DeviceFactoryInfoGet.ts +0 -3
- package/src/api/protocol-v2/DeviceFactoryInfoSet.ts +7 -6
- package/src/api/protocol-v2/helpers.ts +5 -152
- package/src/api/utils.ts +1 -46
- package/src/core/index.ts +16 -28
- package/src/data-manager/DataManager.ts +25 -4
- package/src/data-manager/TransportManager.ts +6 -0
- package/src/device/DeviceCommands.ts +20 -2
- package/src/device/DeviceConnector.ts +33 -13
- package/src/index.ts +0 -5
- package/src/inject.ts +7 -209
- package/src/types/api/index.ts +2 -288
- package/src/types/api/protocolV2.ts +2 -43
- package/__tests__/public-test-api-boundary.test.ts +0 -167
- package/dist/api/BixinBackupDevice.d.ts +0 -7
- package/dist/api/BixinBackupDevice.d.ts.map +0 -1
- package/dist/api/BixinLoadDevice.d.ts +0 -7
- package/dist/api/BixinLoadDevice.d.ts.map +0 -1
- package/dist/api/BixinMessageSE.d.ts +0 -8
- package/dist/api/BixinMessageSE.d.ts.map +0 -1
- package/dist/api/BixinVerifyDeviceRequest.d.ts +0 -8
- package/dist/api/BixinVerifyDeviceRequest.d.ts.map +0 -1
- package/dist/api/WebAuthnAddResidentCredential.d.ts +0 -8
- package/dist/api/WebAuthnAddResidentCredential.d.ts.map +0 -1
- package/dist/api/WebAuthnListResidentCredentials.d.ts +0 -8
- package/dist/api/WebAuthnListResidentCredentials.d.ts.map +0 -1
- package/dist/api/WebAuthnRemoveResidentCredential.d.ts +0 -8
- package/dist/api/WebAuthnRemoveResidentCredential.d.ts.map +0 -1
- package/dist/api/binance/BinanceGetAddress.d.ts +0 -8
- package/dist/api/binance/BinanceGetAddress.d.ts.map +0 -1
- package/dist/api/binance/BinanceGetPublicKey.d.ts +0 -8
- package/dist/api/binance/BinanceGetPublicKey.d.ts.map +0 -1
- package/dist/api/binance/BinanceSignTx.d.ts +0 -7
- package/dist/api/binance/BinanceSignTx.d.ts.map +0 -1
- package/dist/api/btc/BTCAuthorizeCoinJoin.d.ts +0 -7
- package/dist/api/btc/BTCAuthorizeCoinJoin.d.ts.map +0 -1
- package/dist/api/btc/BTCGetOwnershipId.d.ts +0 -7
- package/dist/api/btc/BTCGetOwnershipId.d.ts.map +0 -1
- package/dist/api/btc/BTCGetOwnershipProof.d.ts +0 -7
- package/dist/api/btc/BTCGetOwnershipProof.d.ts.map +0 -1
- package/dist/api/crypto/CryptoBatchGetPublickeys.d.ts +0 -8
- package/dist/api/crypto/CryptoBatchGetPublickeys.d.ts.map +0 -1
- package/dist/api/crypto/CryptoCipherKeyValue.d.ts +0 -8
- package/dist/api/crypto/CryptoCipherKeyValue.d.ts.map +0 -1
- package/dist/api/crypto/CryptoCosiCommit.d.ts +0 -8
- package/dist/api/crypto/CryptoCosiCommit.d.ts.map +0 -1
- package/dist/api/crypto/CryptoCosiSign.d.ts +0 -8
- package/dist/api/crypto/CryptoCosiSign.d.ts.map +0 -1
- package/dist/api/crypto/CryptoGetECDHSessionKey.d.ts +0 -8
- package/dist/api/crypto/CryptoGetECDHSessionKey.d.ts.map +0 -1
- package/dist/api/crypto/CryptoSignIdentity.d.ts +0 -8
- package/dist/api/crypto/CryptoSignIdentity.d.ts.map +0 -1
- package/dist/api/debug/DebugLinkDecision.d.ts +0 -7
- package/dist/api/debug/DebugLinkDecision.d.ts.map +0 -1
- package/dist/api/debug/DebugLinkEraseSdCard.d.ts +0 -7
- package/dist/api/debug/DebugLinkEraseSdCard.d.ts.map +0 -1
- package/dist/api/debug/DebugLinkFlashErase.d.ts +0 -7
- package/dist/api/debug/DebugLinkFlashErase.d.ts.map +0 -1
- package/dist/api/debug/DebugLinkGetState.d.ts +0 -7
- package/dist/api/debug/DebugLinkGetState.d.ts.map +0 -1
- package/dist/api/debug/DebugLinkMemoryRead.d.ts +0 -7
- package/dist/api/debug/DebugLinkMemoryRead.d.ts.map +0 -1
- package/dist/api/debug/DebugLinkMemoryWrite.d.ts +0 -7
- package/dist/api/debug/DebugLinkMemoryWrite.d.ts.map +0 -1
- package/dist/api/debug/DebugLinkRecordScreen.d.ts +0 -7
- package/dist/api/debug/DebugLinkRecordScreen.d.ts.map +0 -1
- package/dist/api/debug/DebugLinkReseedRandom.d.ts +0 -7
- package/dist/api/debug/DebugLinkReseedRandom.d.ts.map +0 -1
- package/dist/api/debug/DebugLinkStop.d.ts +0 -7
- package/dist/api/debug/DebugLinkStop.d.ts.map +0 -1
- package/dist/api/debug/DebugLinkWatchLayout.d.ts +0 -7
- package/dist/api/debug/DebugLinkWatchLayout.d.ts.map +0 -1
- package/dist/api/emmc/EmmcDirList.d.ts +0 -7
- package/dist/api/emmc/EmmcDirList.d.ts.map +0 -1
- package/dist/api/emmc/EmmcDirMake.d.ts +0 -7
- package/dist/api/emmc/EmmcDirMake.d.ts.map +0 -1
- package/dist/api/emmc/EmmcDirRemove.d.ts +0 -7
- package/dist/api/emmc/EmmcDirRemove.d.ts.map +0 -1
- package/dist/api/emmc/EmmcFileDelete.d.ts +0 -7
- package/dist/api/emmc/EmmcFileDelete.d.ts.map +0 -1
- package/dist/api/emmc/EmmcFileRead.d.ts +0 -7
- package/dist/api/emmc/EmmcFileRead.d.ts.map +0 -1
- package/dist/api/emmc/EmmcFileWrite.d.ts +0 -7
- package/dist/api/emmc/EmmcFileWrite.d.ts.map +0 -1
- package/dist/api/emmc/EmmcFixPermission.d.ts +0 -7
- package/dist/api/emmc/EmmcFixPermission.d.ts.map +0 -1
- package/dist/api/emmc/EmmcPathInfo.d.ts +0 -7
- package/dist/api/emmc/EmmcPathInfo.d.ts.map +0 -1
- package/dist/api/eos/EosGetPublicKey.d.ts +0 -8
- package/dist/api/eos/EosGetPublicKey.d.ts.map +0 -1
- package/dist/api/eos/EosSignTx.d.ts +0 -12
- package/dist/api/eos/EosSignTx.d.ts.map +0 -1
- package/dist/api/evmTrezor/EVMGetAddress.d.ts +0 -10
- package/dist/api/evmTrezor/EVMGetAddress.d.ts.map +0 -1
- package/dist/api/evmTrezor/EVMGetPublicKey.d.ts +0 -16
- package/dist/api/evmTrezor/EVMGetPublicKey.d.ts.map +0 -1
- package/dist/api/evmTrezor/EVMSignMessage.d.ts +0 -7
- package/dist/api/evmTrezor/EVMSignMessage.d.ts.map +0 -1
- package/dist/api/evmTrezor/EVMSignTransaction.d.ts +0 -15
- package/dist/api/evmTrezor/EVMSignTransaction.d.ts.map +0 -1
- package/dist/api/evmTrezor/EVMSignTypedData.d.ts +0 -43
- package/dist/api/evmTrezor/EVMSignTypedData.d.ts.map +0 -1
- package/dist/api/evmTrezor/EVMVerifyMessage.d.ts +0 -7
- package/dist/api/evmTrezor/EVMVerifyMessage.d.ts.map +0 -1
- package/dist/api/evmTrezor/legacyV1/getAddress.d.ts +0 -6
- package/dist/api/evmTrezor/legacyV1/getAddress.d.ts.map +0 -1
- package/dist/api/evmTrezor/legacyV1/getPublicKey.d.ts +0 -6
- package/dist/api/evmTrezor/legacyV1/getPublicKey.d.ts.map +0 -1
- package/dist/api/evmTrezor/legacyV1/signMessage.d.ts +0 -6
- package/dist/api/evmTrezor/legacyV1/signMessage.d.ts.map +0 -1
- package/dist/api/evmTrezor/legacyV1/signTransaction.d.ts +0 -9
- package/dist/api/evmTrezor/legacyV1/signTransaction.d.ts.map +0 -1
- package/dist/api/evmTrezor/legacyV1/signTypedData.d.ts +0 -10
- package/dist/api/evmTrezor/legacyV1/signTypedData.d.ts.map +0 -1
- package/dist/api/evmTrezor/legacyV1/signTypedHash.d.ts +0 -11
- package/dist/api/evmTrezor/legacyV1/signTypedHash.d.ts.map +0 -1
- package/dist/api/evmTrezor/legacyV1/verifyMessage.d.ts +0 -6
- package/dist/api/evmTrezor/legacyV1/verifyMessage.d.ts.map +0 -1
- package/dist/api/extensionMethodNames.d.ts +0 -3
- package/dist/api/extensionMethodNames.d.ts.map +0 -1
- package/dist/api/factoryMethods.d.ts +0 -3
- package/dist/api/factoryMethods.d.ts.map +0 -1
- package/dist/api/firmware/FirmwareErase.d.ts +0 -12
- package/dist/api/firmware/FirmwareErase.d.ts.map +0 -1
- package/dist/api/firmware/FirmwareEraseEx.d.ts +0 -12
- package/dist/api/firmware/FirmwareEraseEx.d.ts.map +0 -1
- package/dist/api/firmware/FirmwareUpdateEmmcTest.d.ts +0 -7
- package/dist/api/firmware/FirmwareUpdateEmmcTest.d.ts.map +0 -1
- package/dist/api/firmware/FirmwareUploadTest.d.ts +0 -7
- package/dist/api/firmware/FirmwareUploadTest.d.ts.map +0 -1
- package/dist/api/firmware/Reboot.d.ts +0 -7
- package/dist/api/firmware/Reboot.d.ts.map +0 -1
- package/dist/api/firmware/SelfTest.d.ts +0 -7
- package/dist/api/firmware/SelfTest.d.ts.map +0 -1
- package/dist/api/manager/DeviceCancelAuthorization.d.ts +0 -7
- package/dist/api/manager/DeviceCancelAuthorization.d.ts.map +0 -1
- package/dist/api/manager/DeviceChangeWipeCode.d.ts +0 -7
- package/dist/api/manager/DeviceChangeWipeCode.d.ts.map +0 -1
- package/dist/api/manager/DeviceDoPreauthorized.d.ts +0 -7
- package/dist/api/manager/DeviceDoPreauthorized.d.ts.map +0 -1
- package/dist/api/manager/DeviceEndSession.d.ts +0 -7
- package/dist/api/manager/DeviceEndSession.d.ts.map +0 -1
- package/dist/api/manager/DeviceGetEntropy.d.ts +0 -7
- package/dist/api/manager/DeviceGetEntropy.d.ts.map +0 -1
- package/dist/api/manager/DeviceGetFirmwareHash.d.ts +0 -7
- package/dist/api/manager/DeviceGetFirmwareHash.d.ts.map +0 -1
- package/dist/api/manager/DeviceInfoSettings.d.ts +0 -7
- package/dist/api/manager/DeviceInfoSettings.d.ts.map +0 -1
- package/dist/api/manager/DeviceLoad.d.ts +0 -7
- package/dist/api/manager/DeviceLoad.d.ts.map +0 -1
- package/dist/api/manager/DevicePing.d.ts +0 -7
- package/dist/api/manager/DevicePing.d.ts.map +0 -1
- package/dist/api/manager/DeviceReadSEPublicCert.d.ts +0 -7
- package/dist/api/manager/DeviceReadSEPublicCert.d.ts.map +0 -1
- package/dist/api/manager/DeviceSESignMessage.d.ts +0 -7
- package/dist/api/manager/DeviceSESignMessage.d.ts.map +0 -1
- package/dist/api/manager/DeviceSdProtect.d.ts +0 -7
- package/dist/api/manager/DeviceSdProtect.d.ts.map +0 -1
- package/dist/api/manager/DeviceSpiFlashRead.d.ts +0 -7
- package/dist/api/manager/DeviceSpiFlashRead.d.ts.map +0 -1
- package/dist/api/manager/DeviceSpiFlashWrite.d.ts +0 -7
- package/dist/api/manager/DeviceSpiFlashWrite.d.ts.map +0 -1
- package/dist/api/manager/DeviceUnlockPath.d.ts +0 -7
- package/dist/api/manager/DeviceUnlockPath.d.ts.map +0 -1
- package/dist/api/manager/DeviceWriteSEPrivateKey.d.ts +0 -7
- package/dist/api/manager/DeviceWriteSEPrivateKey.d.ts.map +0 -1
- package/dist/api/manager/DeviceWriteSEPublicCert.d.ts +0 -7
- package/dist/api/manager/DeviceWriteSEPublicCert.d.ts.map +0 -1
- package/dist/api/manager/GetDeviceInfoSettings.d.ts +0 -7
- package/dist/api/manager/GetDeviceInfoSettings.d.ts.map +0 -1
- package/dist/api/manager/GetPublicKeyMultiple.d.ts +0 -7
- package/dist/api/manager/GetPublicKeyMultiple.d.ts.map +0 -1
- package/dist/api/manager/ListResDir.d.ts +0 -7
- package/dist/api/manager/ListResDir.d.ts.map +0 -1
- package/dist/api/manager/NFTWriteData.d.ts +0 -7
- package/dist/api/manager/NFTWriteData.d.ts.map +0 -1
- package/dist/api/manager/NFTWriteInfo.d.ts +0 -7
- package/dist/api/manager/NFTWriteInfo.d.ts.map +0 -1
- package/dist/api/manager/ReadSEPublicKey.d.ts +0 -7
- package/dist/api/manager/ReadSEPublicKey.d.ts.map +0 -1
- package/dist/api/manager/ResourceUpdate.d.ts +0 -6
- package/dist/api/manager/ResourceUpdate.d.ts.map +0 -1
- package/dist/api/methodExtension.d.ts +0 -13
- package/dist/api/methodExtension.d.ts.map +0 -1
- package/dist/api/monero/MoneroGetAddress.d.ts +0 -9
- package/dist/api/monero/MoneroGetAddress.d.ts.map +0 -1
- package/dist/api/monero/MoneroGetWatchKey.d.ts +0 -8
- package/dist/api/monero/MoneroGetWatchKey.d.ts.map +0 -1
- package/dist/api/nem/NEMDecryptMessage.d.ts +0 -8
- package/dist/api/nem/NEMDecryptMessage.d.ts.map +0 -1
- package/dist/api/protocol-v2/DeviceFactoryCertificateRead.d.ts +0 -7
- package/dist/api/protocol-v2/DeviceFactoryCertificateRead.d.ts.map +0 -1
- package/dist/api/protocol-v2/DeviceFactoryCertificateWrite.d.ts +0 -8
- package/dist/api/protocol-v2/DeviceFactoryCertificateWrite.d.ts.map +0 -1
- package/dist/api/protocol-v2/DeviceFactoryChallengeSign.d.ts +0 -8
- package/dist/api/protocol-v2/DeviceFactoryChallengeSign.d.ts.map +0 -1
- package/dist/api/testMethods.d.ts +0 -82
- package/dist/api/testMethods.d.ts.map +0 -1
- package/dist/api/tezos/TezosGetAddress.d.ts +0 -9
- package/dist/api/tezos/TezosGetAddress.d.ts.map +0 -1
- package/dist/api/tezos/TezosGetPublicKey.d.ts +0 -8
- package/dist/api/tezos/TezosGetPublicKey.d.ts.map +0 -1
- package/dist/api/tezos/TezosSignTx.d.ts +0 -12
- package/dist/api/tezos/TezosSignTx.d.ts.map +0 -1
- package/dist/types/api/binanceGetAddress.d.ts +0 -11
- package/dist/types/api/binanceGetAddress.d.ts.map +0 -1
- package/dist/types/api/binanceGetPublicKey.d.ts +0 -11
- package/dist/types/api/binanceGetPublicKey.d.ts.map +0 -1
- package/dist/types/api/binanceSignTx.d.ts +0 -7
- package/dist/types/api/binanceSignTx.d.ts.map +0 -1
- package/dist/types/api/bixinBackupDevice.d.ts +0 -4
- package/dist/types/api/bixinBackupDevice.d.ts.map +0 -1
- package/dist/types/api/bixinLoadDevice.d.ts +0 -4
- package/dist/types/api/bixinLoadDevice.d.ts.map +0 -1
- package/dist/types/api/bixinMessageSE.d.ts +0 -4
- package/dist/types/api/bixinMessageSE.d.ts.map +0 -1
- package/dist/types/api/bixinVerifyDeviceRequest.d.ts +0 -4
- package/dist/types/api/bixinVerifyDeviceRequest.d.ts.map +0 -1
- package/dist/types/api/btcAuthorizeCoinJoin.d.ts +0 -13
- package/dist/types/api/btcAuthorizeCoinJoin.d.ts.map +0 -1
- package/dist/types/api/btcGetOwnershipId.d.ts +0 -10
- package/dist/types/api/btcGetOwnershipId.d.ts.map +0 -1
- package/dist/types/api/btcGetOwnershipProof.d.ts +0 -13
- package/dist/types/api/btcGetOwnershipProof.d.ts.map +0 -1
- package/dist/types/api/cryptoBatchGetPublickeys.d.ts +0 -12
- package/dist/types/api/cryptoBatchGetPublickeys.d.ts.map +0 -1
- package/dist/types/api/cryptoCipherKeyValue.d.ts +0 -13
- package/dist/types/api/cryptoCipherKeyValue.d.ts.map +0 -1
- package/dist/types/api/cryptoCosiCommit.d.ts +0 -8
- package/dist/types/api/cryptoCosiCommit.d.ts.map +0 -1
- package/dist/types/api/cryptoCosiSign.d.ts +0 -10
- package/dist/types/api/cryptoCosiSign.d.ts.map +0 -1
- package/dist/types/api/cryptoGetECDHSessionKey.d.ts +0 -4
- package/dist/types/api/cryptoGetECDHSessionKey.d.ts.map +0 -1
- package/dist/types/api/cryptoSignIdentity.d.ts +0 -4
- package/dist/types/api/cryptoSignIdentity.d.ts.map +0 -1
- package/dist/types/api/debugLinkDecision.d.ts +0 -4
- package/dist/types/api/debugLinkDecision.d.ts.map +0 -1
- package/dist/types/api/debugLinkEraseSdCard.d.ts +0 -4
- package/dist/types/api/debugLinkEraseSdCard.d.ts.map +0 -1
- package/dist/types/api/debugLinkFlashErase.d.ts +0 -4
- package/dist/types/api/debugLinkFlashErase.d.ts.map +0 -1
- package/dist/types/api/debugLinkGetState.d.ts +0 -4
- package/dist/types/api/debugLinkGetState.d.ts.map +0 -1
- package/dist/types/api/debugLinkMemoryRead.d.ts +0 -4
- package/dist/types/api/debugLinkMemoryRead.d.ts.map +0 -1
- package/dist/types/api/debugLinkMemoryWrite.d.ts +0 -4
- package/dist/types/api/debugLinkMemoryWrite.d.ts.map +0 -1
- package/dist/types/api/debugLinkRecordScreen.d.ts +0 -4
- package/dist/types/api/debugLinkRecordScreen.d.ts.map +0 -1
- package/dist/types/api/debugLinkReseedRandom.d.ts +0 -4
- package/dist/types/api/debugLinkReseedRandom.d.ts.map +0 -1
- package/dist/types/api/debugLinkStop.d.ts +0 -4
- package/dist/types/api/debugLinkStop.d.ts.map +0 -1
- package/dist/types/api/debugLinkWatchLayout.d.ts +0 -4
- package/dist/types/api/debugLinkWatchLayout.d.ts.map +0 -1
- package/dist/types/api/deviceCancelAuthorization.d.ts +0 -4
- package/dist/types/api/deviceCancelAuthorization.d.ts.map +0 -1
- package/dist/types/api/deviceChangeWipeCode.d.ts +0 -4
- package/dist/types/api/deviceChangeWipeCode.d.ts.map +0 -1
- package/dist/types/api/deviceDoPreauthorized.d.ts +0 -4
- package/dist/types/api/deviceDoPreauthorized.d.ts.map +0 -1
- package/dist/types/api/deviceEndSession.d.ts +0 -4
- package/dist/types/api/deviceEndSession.d.ts.map +0 -1
- package/dist/types/api/deviceGetEntropy.d.ts +0 -4
- package/dist/types/api/deviceGetEntropy.d.ts.map +0 -1
- package/dist/types/api/deviceGetFirmwareHash.d.ts +0 -4
- package/dist/types/api/deviceGetFirmwareHash.d.ts.map +0 -1
- package/dist/types/api/deviceGetInfo.d.ts +0 -4
- package/dist/types/api/deviceGetInfo.d.ts.map +0 -1
- package/dist/types/api/deviceInfoSettings.d.ts +0 -4
- package/dist/types/api/deviceInfoSettings.d.ts.map +0 -1
- package/dist/types/api/deviceLoad.d.ts +0 -16
- package/dist/types/api/deviceLoad.d.ts.map +0 -1
- package/dist/types/api/devicePing.d.ts +0 -4
- package/dist/types/api/devicePing.d.ts.map +0 -1
- package/dist/types/api/deviceReadSEPublicCert.d.ts +0 -4
- package/dist/types/api/deviceReadSEPublicCert.d.ts.map +0 -1
- package/dist/types/api/deviceSESignMessage.d.ts +0 -4
- package/dist/types/api/deviceSESignMessage.d.ts.map +0 -1
- package/dist/types/api/deviceSdProtect.d.ts +0 -4
- package/dist/types/api/deviceSdProtect.d.ts.map +0 -1
- package/dist/types/api/deviceSpiFlashRead.d.ts +0 -4
- package/dist/types/api/deviceSpiFlashRead.d.ts.map +0 -1
- package/dist/types/api/deviceSpiFlashWrite.d.ts +0 -4
- package/dist/types/api/deviceSpiFlashWrite.d.ts.map +0 -1
- package/dist/types/api/deviceUnlockPath.d.ts +0 -11
- package/dist/types/api/deviceUnlockPath.d.ts.map +0 -1
- package/dist/types/api/deviceWriteSEPrivateKey.d.ts +0 -4
- package/dist/types/api/deviceWriteSEPrivateKey.d.ts.map +0 -1
- package/dist/types/api/deviceWriteSEPublicCert.d.ts +0 -4
- package/dist/types/api/deviceWriteSEPublicCert.d.ts.map +0 -1
- package/dist/types/api/emmcDirList.d.ts +0 -4
- package/dist/types/api/emmcDirList.d.ts.map +0 -1
- package/dist/types/api/emmcDirMake.d.ts +0 -4
- package/dist/types/api/emmcDirMake.d.ts.map +0 -1
- package/dist/types/api/emmcDirRemove.d.ts +0 -4
- package/dist/types/api/emmcDirRemove.d.ts.map +0 -1
- package/dist/types/api/emmcFileDelete.d.ts +0 -4
- package/dist/types/api/emmcFileDelete.d.ts.map +0 -1
- package/dist/types/api/emmcFileRead.d.ts +0 -4
- package/dist/types/api/emmcFileRead.d.ts.map +0 -1
- package/dist/types/api/emmcFileWrite.d.ts +0 -4
- package/dist/types/api/emmcFileWrite.d.ts.map +0 -1
- package/dist/types/api/emmcFixPermission.d.ts +0 -4
- package/dist/types/api/emmcFixPermission.d.ts.map +0 -1
- package/dist/types/api/emmcPathInfo.d.ts +0 -4
- package/dist/types/api/emmcPathInfo.d.ts.map +0 -1
- package/dist/types/api/eosGetPublicKey.d.ts +0 -8
- package/dist/types/api/eosGetPublicKey.d.ts.map +0 -1
- package/dist/types/api/eosSignTx.d.ts +0 -7
- package/dist/types/api/eosSignTx.d.ts.map +0 -1
- package/dist/types/api/evmGetAddressTrezor.d.ts +0 -15
- package/dist/types/api/evmGetAddressTrezor.d.ts.map +0 -1
- package/dist/types/api/evmGetPublicKeyTrezor.d.ts +0 -20
- package/dist/types/api/evmGetPublicKeyTrezor.d.ts.map +0 -1
- package/dist/types/api/evmSignMessageTrezor.d.ts +0 -9
- package/dist/types/api/evmSignMessageTrezor.d.ts.map +0 -1
- package/dist/types/api/evmSignTransactionTrezor.d.ts +0 -40
- package/dist/types/api/evmSignTransactionTrezor.d.ts.map +0 -1
- package/dist/types/api/evmSignTypedDataTrezor.d.ts +0 -34
- package/dist/types/api/evmSignTypedDataTrezor.d.ts.map +0 -1
- package/dist/types/api/evmVerifyMessageTrezor.d.ts +0 -10
- package/dist/types/api/evmVerifyMessageTrezor.d.ts.map +0 -1
- package/dist/types/api/firmwareErase.d.ts +0 -4
- package/dist/types/api/firmwareErase.d.ts.map +0 -1
- package/dist/types/api/firmwareEraseEx.d.ts +0 -4
- package/dist/types/api/firmwareEraseEx.d.ts.map +0 -1
- package/dist/types/api/firmwareUpdateEmmcTest.d.ts +0 -4
- package/dist/types/api/firmwareUpdateEmmcTest.d.ts.map +0 -1
- package/dist/types/api/firmwareUploadTest.d.ts +0 -4
- package/dist/types/api/firmwareUploadTest.d.ts.map +0 -1
- package/dist/types/api/getPublicKeyMultiple.d.ts +0 -4
- package/dist/types/api/getPublicKeyMultiple.d.ts.map +0 -1
- package/dist/types/api/listResDir.d.ts +0 -4
- package/dist/types/api/listResDir.d.ts.map +0 -1
- package/dist/types/api/moneroGetAddress.d.ts +0 -14
- package/dist/types/api/moneroGetAddress.d.ts.map +0 -1
- package/dist/types/api/moneroGetWatchKey.d.ts +0 -14
- package/dist/types/api/moneroGetWatchKey.d.ts.map +0 -1
- package/dist/types/api/nemDecryptMessage.d.ts +0 -10
- package/dist/types/api/nemDecryptMessage.d.ts.map +0 -1
- package/dist/types/api/nftWriteData.d.ts +0 -4
- package/dist/types/api/nftWriteData.d.ts.map +0 -1
- package/dist/types/api/nftWriteInfo.d.ts +0 -4
- package/dist/types/api/nftWriteInfo.d.ts.map +0 -1
- package/dist/types/api/readSEPublicKey.d.ts +0 -4
- package/dist/types/api/readSEPublicKey.d.ts.map +0 -1
- package/dist/types/api/reboot.d.ts +0 -4
- package/dist/types/api/reboot.d.ts.map +0 -1
- package/dist/types/api/resourceUpdate.d.ts +0 -7
- package/dist/types/api/resourceUpdate.d.ts.map +0 -1
- package/dist/types/api/selfTest.d.ts +0 -4
- package/dist/types/api/selfTest.d.ts.map +0 -1
- package/dist/types/api/tezosGetAddress.d.ts +0 -14
- package/dist/types/api/tezosGetAddress.d.ts.map +0 -1
- package/dist/types/api/tezosGetPublicKey.d.ts +0 -14
- package/dist/types/api/tezosGetPublicKey.d.ts.map +0 -1
- package/dist/types/api/tezosSignTx.d.ts +0 -7
- package/dist/types/api/tezosSignTx.d.ts.map +0 -1
- package/dist/types/api/webAuthnAddResidentCredential.d.ts +0 -4
- package/dist/types/api/webAuthnAddResidentCredential.d.ts.map +0 -1
- package/dist/types/api/webAuthnListResidentCredentials.d.ts +0 -4
- package/dist/types/api/webAuthnListResidentCredentials.d.ts.map +0 -1
- package/dist/types/api/webAuthnRemoveResidentCredential.d.ts +0 -4
- package/dist/types/api/webAuthnRemoveResidentCredential.d.ts.map +0 -1
- package/src/api/BixinBackupDevice.ts +0 -15
- package/src/api/BixinLoadDevice.ts +0 -22
- package/src/api/BixinMessageSE.ts +0 -22
- package/src/api/BixinVerifyDeviceRequest.ts +0 -22
- package/src/api/WebAuthnAddResidentCredential.ts +0 -22
- package/src/api/WebAuthnListResidentCredentials.ts +0 -24
- package/src/api/WebAuthnRemoveResidentCredential.ts +0 -22
- package/src/api/binance/BinanceGetAddress.ts +0 -26
- package/src/api/binance/BinanceGetPublicKey.ts +0 -26
- package/src/api/binance/BinanceSignTx.ts +0 -35
- package/src/api/btc/BTCAuthorizeCoinJoin.ts +0 -37
- package/src/api/btc/BTCGetOwnershipId.ts +0 -34
- package/src/api/btc/BTCGetOwnershipProof.ts +0 -37
- package/src/api/crypto/CryptoBatchGetPublickeys.ts +0 -30
- package/src/api/crypto/CryptoCipherKeyValue.ts +0 -29
- package/src/api/crypto/CryptoCosiCommit.ts +0 -24
- package/src/api/crypto/CryptoCosiSign.ts +0 -26
- package/src/api/crypto/CryptoGetECDHSessionKey.ts +0 -24
- package/src/api/crypto/CryptoSignIdentity.ts +0 -25
- package/src/api/debug/DebugLinkDecision.ts +0 -25
- package/src/api/debug/DebugLinkEraseSdCard.ts +0 -23
- package/src/api/debug/DebugLinkFlashErase.ts +0 -23
- package/src/api/debug/DebugLinkGetState.ts +0 -21
- package/src/api/debug/DebugLinkMemoryRead.ts +0 -24
- package/src/api/debug/DebugLinkMemoryWrite.ts +0 -25
- package/src/api/debug/DebugLinkRecordScreen.ts +0 -23
- package/src/api/debug/DebugLinkReseedRandom.ts +0 -23
- package/src/api/debug/DebugLinkStop.ts +0 -25
- package/src/api/debug/DebugLinkWatchLayout.ts +0 -23
- package/src/api/emmc/EmmcDirList.ts +0 -20
- package/src/api/emmc/EmmcDirMake.ts +0 -20
- package/src/api/emmc/EmmcDirRemove.ts +0 -20
- package/src/api/emmc/EmmcFileDelete.ts +0 -20
- package/src/api/emmc/EmmcFileRead.ts +0 -21
- package/src/api/emmc/EmmcFileWrite.ts +0 -23
- package/src/api/emmc/EmmcFixPermission.ts +0 -17
- package/src/api/emmc/EmmcPathInfo.ts +0 -20
- package/src/api/eos/EosGetPublicKey.ts +0 -26
- package/src/api/eos/EosSignTx.ts +0 -40
- package/src/api/evmTrezor/EVMGetAddress.ts +0 -75
- package/src/api/evmTrezor/EVMGetPublicKey.ts +0 -106
- package/src/api/evmTrezor/EVMSignMessage.ts +0 -40
- package/src/api/evmTrezor/EVMSignTransaction.ts +0 -83
- package/src/api/evmTrezor/EVMSignTypedData.ts +0 -366
- package/src/api/evmTrezor/EVMVerifyMessage.ts +0 -37
- package/src/api/evmTrezor/legacyV1/getAddress.ts +0 -16
- package/src/api/evmTrezor/legacyV1/getPublicKey.ts +0 -20
- package/src/api/evmTrezor/legacyV1/signMessage.ts +0 -22
- package/src/api/evmTrezor/legacyV1/signTransaction.ts +0 -24
- package/src/api/evmTrezor/legacyV1/signTypedData.ts +0 -36
- package/src/api/evmTrezor/legacyV1/signTypedHash.ts +0 -48
- package/src/api/evmTrezor/legacyV1/verifyMessage.ts +0 -19
- package/src/api/extensionMethodNames.ts +0 -88
- package/src/api/factoryMethods.ts +0 -2
- package/src/api/firmware/FirmwareErase.ts +0 -18
- package/src/api/firmware/FirmwareEraseEx.ts +0 -18
- package/src/api/firmware/FirmwareUpdateEmmcTest.ts +0 -18
- package/src/api/firmware/FirmwareUploadTest.ts +0 -17
- package/src/api/firmware/Reboot.ts +0 -17
- package/src/api/firmware/SelfTest.ts +0 -17
- package/src/api/manager/DeviceCancelAuthorization.ts +0 -15
- package/src/api/manager/DeviceChangeWipeCode.ts +0 -19
- package/src/api/manager/DeviceDoPreauthorized.ts +0 -15
- package/src/api/manager/DeviceEndSession.ts +0 -19
- package/src/api/manager/DeviceGetEntropy.ts +0 -19
- package/src/api/manager/DeviceGetFirmwareHash.ts +0 -23
- package/src/api/manager/DeviceInfoSettings.ts +0 -23
- package/src/api/manager/DeviceLoad.ts +0 -27
- package/src/api/manager/DevicePing.ts +0 -19
- package/src/api/manager/DeviceReadSEPublicCert.ts +0 -18
- package/src/api/manager/DeviceSESignMessage.ts +0 -23
- package/src/api/manager/DeviceSdProtect.ts +0 -18
- package/src/api/manager/DeviceSpiFlashRead.ts +0 -22
- package/src/api/manager/DeviceSpiFlashWrite.ts +0 -22
- package/src/api/manager/DeviceUnlockPath.ts +0 -26
- package/src/api/manager/DeviceWriteSEPrivateKey.ts +0 -23
- package/src/api/manager/DeviceWriteSEPublicCert.ts +0 -23
- package/src/api/manager/GetDeviceInfoSettings.ts +0 -20
- package/src/api/manager/GetPublicKeyMultiple.ts +0 -24
- package/src/api/manager/ListResDir.ts +0 -19
- package/src/api/manager/NFTWriteData.ts +0 -21
- package/src/api/manager/NFTWriteInfo.ts +0 -23
- package/src/api/manager/ReadSEPublicKey.ts +0 -20
- package/src/api/manager/ResourceUpdate.ts +0 -22
- package/src/api/methodExtension.ts +0 -27
- package/src/api/monero/MoneroGetAddress.ts +0 -64
- package/src/api/monero/MoneroGetWatchKey.ts +0 -59
- package/src/api/nem/NEMDecryptMessage.ts +0 -29
- package/src/api/protocol-v2/DeviceFactoryCertificateRead.ts +0 -25
- package/src/api/protocol-v2/DeviceFactoryCertificateWrite.ts +0 -30
- package/src/api/protocol-v2/DeviceFactoryChallengeSign.ts +0 -28
- package/src/api/testMethods.ts +0 -95
- package/src/api/tezos/TezosGetAddress.ts +0 -64
- package/src/api/tezos/TezosGetPublicKey.ts +0 -63
- package/src/api/tezos/TezosSignTx.ts +0 -44
- package/src/types/api/binanceGetAddress.ts +0 -17
- package/src/types/api/binanceGetPublicKey.ts +0 -17
- package/src/types/api/binanceSignTx.ts +0 -15
- package/src/types/api/bixinBackupDevice.ts +0 -8
- package/src/types/api/bixinLoadDevice.ts +0 -8
- package/src/types/api/bixinMessageSE.ts +0 -8
- package/src/types/api/bixinVerifyDeviceRequest.ts +0 -8
- package/src/types/api/btcAuthorizeCoinJoin.ts +0 -18
- package/src/types/api/btcGetOwnershipId.ts +0 -19
- package/src/types/api/btcGetOwnershipProof.ts +0 -22
- package/src/types/api/cryptoBatchGetPublickeys.ts +0 -18
- package/src/types/api/cryptoCipherKeyValue.ts +0 -18
- package/src/types/api/cryptoCosiCommit.ts +0 -13
- package/src/types/api/cryptoCosiSign.ts +0 -15
- package/src/types/api/cryptoGetECDHSessionKey.ts +0 -8
- package/src/types/api/cryptoSignIdentity.ts +0 -8
- package/src/types/api/debugLinkDecision.ts +0 -7
- package/src/types/api/debugLinkEraseSdCard.ts +0 -7
- package/src/types/api/debugLinkFlashErase.ts +0 -7
- package/src/types/api/debugLinkGetState.ts +0 -7
- package/src/types/api/debugLinkMemoryRead.ts +0 -7
- package/src/types/api/debugLinkMemoryWrite.ts +0 -7
- package/src/types/api/debugLinkRecordScreen.ts +0 -7
- package/src/types/api/debugLinkReseedRandom.ts +0 -7
- package/src/types/api/debugLinkStop.ts +0 -7
- package/src/types/api/debugLinkWatchLayout.ts +0 -7
- package/src/types/api/deviceCancelAuthorization.ts +0 -7
- package/src/types/api/deviceChangeWipeCode.ts +0 -7
- package/src/types/api/deviceDoPreauthorized.ts +0 -7
- package/src/types/api/deviceEndSession.ts +0 -7
- package/src/types/api/deviceGetEntropy.ts +0 -7
- package/src/types/api/deviceGetFirmwareHash.ts +0 -7
- package/src/types/api/deviceGetInfo.ts +0 -7
- package/src/types/api/deviceInfoSettings.ts +0 -7
- package/src/types/api/deviceLoad.ts +0 -19
- package/src/types/api/devicePing.ts +0 -7
- package/src/types/api/deviceReadSEPublicCert.ts +0 -7
- package/src/types/api/deviceSESignMessage.ts +0 -7
- package/src/types/api/deviceSdProtect.ts +0 -7
- package/src/types/api/deviceSpiFlashRead.ts +0 -7
- package/src/types/api/deviceSpiFlashWrite.ts +0 -7
- package/src/types/api/deviceUnlockPath.ts +0 -16
- package/src/types/api/deviceWriteSEPrivateKey.ts +0 -7
- package/src/types/api/deviceWriteSEPublicCert.ts +0 -7
- package/src/types/api/emmcDirList.ts +0 -7
- package/src/types/api/emmcDirMake.ts +0 -7
- package/src/types/api/emmcDirRemove.ts +0 -7
- package/src/types/api/emmcFileDelete.ts +0 -7
- package/src/types/api/emmcFileRead.ts +0 -7
- package/src/types/api/emmcFileWrite.ts +0 -7
- package/src/types/api/emmcFixPermission.ts +0 -7
- package/src/types/api/emmcPathInfo.ts +0 -7
- package/src/types/api/eosGetPublicKey.ts +0 -13
- package/src/types/api/eosSignTx.ts +0 -12
- package/src/types/api/evmGetAddressTrezor.ts +0 -24
- package/src/types/api/evmGetPublicKeyTrezor.ts +0 -31
- package/src/types/api/evmSignMessageTrezor.ts +0 -14
- package/src/types/api/evmSignTransactionTrezor.ts +0 -49
- package/src/types/api/evmSignTypedDataTrezor.ts +0 -42
- package/src/types/api/evmVerifyMessageTrezor.ts +0 -15
- package/src/types/api/firmwareErase.ts +0 -4
- package/src/types/api/firmwareEraseEx.ts +0 -7
- package/src/types/api/firmwareUpdateEmmcTest.ts +0 -7
- package/src/types/api/firmwareUploadTest.ts +0 -7
- package/src/types/api/getPublicKeyMultiple.ts +0 -11
- package/src/types/api/listResDir.ts +0 -8
- package/src/types/api/moneroGetAddress.ts +0 -23
- package/src/types/api/moneroGetWatchKey.ts +0 -26
- package/src/types/api/nemDecryptMessage.ts +0 -15
- package/src/types/api/nftWriteData.ts +0 -8
- package/src/types/api/nftWriteInfo.ts +0 -8
- package/src/types/api/readSEPublicKey.ts +0 -8
- package/src/types/api/reboot.ts +0 -4
- package/src/types/api/resourceUpdate.ts +0 -11
- package/src/types/api/selfTest.ts +0 -7
- package/src/types/api/tezosGetAddress.ts +0 -23
- package/src/types/api/tezosGetPublicKey.ts +0 -23
- package/src/types/api/tezosSignTx.ts +0 -12
- package/src/types/api/webAuthnAddResidentCredential.ts +0 -8
- package/src/types/api/webAuthnListResidentCredentials.ts +0 -8
- package/src/types/api/webAuthnRemoveResidentCredential.ts +0 -8
package/src/core/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import semver from 'semver';
|
|
2
|
-
import
|
|
2
|
+
import EventEmitter from 'events';
|
|
3
3
|
import { DeviceSessionPinType, TRANSPORT_EVENT } from '@onekeyfe/hd-transport';
|
|
4
4
|
import {
|
|
5
5
|
ERRORS,
|
|
@@ -75,7 +75,6 @@ import type {
|
|
|
75
75
|
TransportDeviceDisconnectEvent,
|
|
76
76
|
} from '@onekeyfe/hd-transport';
|
|
77
77
|
import type { BaseMethod } from '../api/BaseMethod';
|
|
78
|
-
import type { CoreMethodExtension } from '../api/methodExtension';
|
|
79
78
|
|
|
80
79
|
const Log = getLogger(LoggerNames.Core);
|
|
81
80
|
const PRE_INITIALIZE_TTL_MS = 60 * 1000;
|
|
@@ -87,11 +86,6 @@ const preWarmDoneAt = new Map<string, number>();
|
|
|
87
86
|
|
|
88
87
|
export type CoreContext = ReturnType<Core['getCoreContext']>;
|
|
89
88
|
|
|
90
|
-
export type CoreOptions = {
|
|
91
|
-
methodExtensions?: readonly CoreMethodExtension[];
|
|
92
|
-
allowDestructiveOperations?: boolean;
|
|
93
|
-
};
|
|
94
|
-
|
|
95
89
|
function hasDeriveCardano(method: BaseMethod): boolean {
|
|
96
90
|
if (
|
|
97
91
|
method.name.startsWith('allNetworkGetAddress') &&
|
|
@@ -162,10 +156,7 @@ export const callAPI = async (context: CoreContext, message: CoreMessage) => {
|
|
|
162
156
|
// find api method
|
|
163
157
|
let method!: BaseMethod;
|
|
164
158
|
try {
|
|
165
|
-
method = findMethod(message as IFrameCallMessage
|
|
166
|
-
extensions: context.methodExtensions,
|
|
167
|
-
allowDestructiveOperations: context.allowDestructiveOperations,
|
|
168
|
-
});
|
|
159
|
+
method = findMethod(message as IFrameCallMessage);
|
|
169
160
|
method.connector = _connector;
|
|
170
161
|
const shouldPostMessage = createUiProgressMessageFilter();
|
|
171
162
|
method.postMessage = event => {
|
|
@@ -661,6 +652,12 @@ const onCallDevice = async (
|
|
|
661
652
|
requestQueue.resolveRequest(method.responseID, messageResponse);
|
|
662
653
|
completeMethodRequestContext(method);
|
|
663
654
|
} catch (error) {
|
|
655
|
+
// Device.run may release the request before transport callbacks finish after a timeout.
|
|
656
|
+
// Ignore the stale callback because the caller already received the connection error.
|
|
657
|
+
if (!requestQueue.getTask(method.responseID)) {
|
|
658
|
+
Log.debug(`Call API - Ignore late inner method result`, error);
|
|
659
|
+
return;
|
|
660
|
+
}
|
|
664
661
|
Log.debug(`Call API - Inner Method Run Error`, error);
|
|
665
662
|
messageResponse = createResponseMessage(method.responseID, false, { error });
|
|
666
663
|
requestQueue.resolveRequest(method.responseID, messageResponse);
|
|
@@ -1486,11 +1483,8 @@ export default class Core extends EventEmitter {
|
|
|
1486
1483
|
|
|
1487
1484
|
private methodSynchronize = getSynchronize();
|
|
1488
1485
|
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
constructor(options: CoreOptions = {}) {
|
|
1486
|
+
constructor() {
|
|
1492
1487
|
super();
|
|
1493
|
-
this.options = options;
|
|
1494
1488
|
this.tracingContext = createSdkTracingContext();
|
|
1495
1489
|
this.sdkInstanceId = this.tracingContext.sdkInstanceId;
|
|
1496
1490
|
Log.debug(`[Core] Created SDK instance: ${this.sdkInstanceId}`);
|
|
@@ -1499,8 +1493,6 @@ export default class Core extends EventEmitter {
|
|
|
1499
1493
|
private getCoreContext() {
|
|
1500
1494
|
return {
|
|
1501
1495
|
sdkInstanceId: this.sdkInstanceId,
|
|
1502
|
-
methodExtensions: this.options.methodExtensions ?? [],
|
|
1503
|
-
allowDestructiveOperations: this.options.allowDestructiveOperations === true,
|
|
1504
1496
|
tracingContext: this.tracingContext,
|
|
1505
1497
|
requestQueue: this.requestQueue,
|
|
1506
1498
|
methodSynchronize: this.methodSynchronize,
|
|
@@ -1631,8 +1623,8 @@ export default class Core extends EventEmitter {
|
|
|
1631
1623
|
}
|
|
1632
1624
|
}
|
|
1633
1625
|
|
|
1634
|
-
export const initCore = (
|
|
1635
|
-
const core = new Core(
|
|
1626
|
+
export const initCore = () => {
|
|
1627
|
+
const core = new Core();
|
|
1636
1628
|
_core = core;
|
|
1637
1629
|
return core;
|
|
1638
1630
|
};
|
|
@@ -1658,26 +1650,22 @@ const initTransport = (Transport: any, plugin?: LowlevelTransportSharedPlugin) =
|
|
|
1658
1650
|
export const init = async (
|
|
1659
1651
|
settings: ConnectSettings,
|
|
1660
1652
|
Transport: any,
|
|
1661
|
-
plugin?: LowlevelTransportSharedPlugin
|
|
1662
|
-
options?: CoreOptions
|
|
1653
|
+
plugin?: LowlevelTransportSharedPlugin
|
|
1663
1654
|
) => {
|
|
1664
1655
|
try {
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
initTransport(Transport, plugin);
|
|
1668
|
-
} catch {
|
|
1669
|
-
Log.error('DataManager.load error');
|
|
1670
|
-
}
|
|
1656
|
+
await DataManager.load(settings);
|
|
1657
|
+
initTransport(Transport, plugin);
|
|
1671
1658
|
enableLog(DataManager.getSettings('debug'));
|
|
1672
1659
|
if (DataManager.getSettings('env') !== 'react-native') {
|
|
1673
1660
|
setLoggerPostMessage(postMessage);
|
|
1674
1661
|
}
|
|
1675
|
-
initCore(
|
|
1662
|
+
initCore();
|
|
1676
1663
|
initConnector();
|
|
1677
1664
|
|
|
1678
1665
|
return _core;
|
|
1679
1666
|
} catch (error) {
|
|
1680
1667
|
Log.error('core init', error);
|
|
1668
|
+
throw error;
|
|
1681
1669
|
}
|
|
1682
1670
|
};
|
|
1683
1671
|
|
|
@@ -26,6 +26,7 @@ import type {
|
|
|
26
26
|
Features,
|
|
27
27
|
IDeviceBLEFirmwareStatus,
|
|
28
28
|
IDeviceFirmwareStatus,
|
|
29
|
+
IProtocolV2Resources,
|
|
29
30
|
ITransportStatus,
|
|
30
31
|
IVersionArray,
|
|
31
32
|
RemoteConfigResponse,
|
|
@@ -112,6 +113,8 @@ export default class DataManager {
|
|
|
112
113
|
|
|
113
114
|
static lastCheckTimestamp = 0;
|
|
114
115
|
|
|
116
|
+
static protocolV2ResourcesConfigError: Error | undefined;
|
|
117
|
+
|
|
115
118
|
static getFirmwareStatus = (
|
|
116
119
|
features: Features,
|
|
117
120
|
firmwareType: EFirmwareType
|
|
@@ -400,6 +403,7 @@ export default class DataManager {
|
|
|
400
403
|
|
|
401
404
|
static async load(settings: ConnectSettings): Promise<boolean> {
|
|
402
405
|
this.settings = settings;
|
|
406
|
+
this.protocolV2ResourcesConfigError = undefined;
|
|
403
407
|
if (!settings.fetchConfig) {
|
|
404
408
|
return false;
|
|
405
409
|
}
|
|
@@ -446,9 +450,20 @@ export default class DataManager {
|
|
|
446
450
|
|
|
447
451
|
// 3. Apply config if available
|
|
448
452
|
if (data) {
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
453
|
+
let pro2Resources: IProtocolV2Resources | undefined;
|
|
454
|
+
try {
|
|
455
|
+
pro2Resources = parseProtocolV2Resources(
|
|
456
|
+
(data.pro2 as { resources?: unknown } | undefined)?.resources
|
|
457
|
+
);
|
|
458
|
+
} catch (error) {
|
|
459
|
+
// Firmware resource metadata is not required for base communication. If the
|
|
460
|
+
// remote config is temporarily incomplete, disable this resource update only.
|
|
461
|
+
this.protocolV2ResourcesConfigError =
|
|
462
|
+
error instanceof Error ? error : new Error(String(error));
|
|
463
|
+
Log.warn('[DataConfig] Ignoring invalid Pro2 resources config:', error);
|
|
464
|
+
}
|
|
465
|
+
const enrichedPro2Config = this.enrichFirmwareReleaseInfo(data.pro2);
|
|
466
|
+
const { resources: _unvalidatedResources, ...pro2Config } = enrichedPro2Config;
|
|
452
467
|
Log.log(`[DataConfig] Config loaded successfully via [${fetchMethod}]`);
|
|
453
468
|
this.deviceMap = {
|
|
454
469
|
[EDeviceType.Classic]: this.enrichFirmwareReleaseInfo(data.classic),
|
|
@@ -458,7 +473,7 @@ export default class DataManager {
|
|
|
458
473
|
[EDeviceType.Touch]: this.enrichFirmwareReleaseInfo(data.touch),
|
|
459
474
|
[EDeviceType.Pro]: this.enrichFirmwareReleaseInfo(data.pro),
|
|
460
475
|
[EDeviceType.Pro2]: {
|
|
461
|
-
...
|
|
476
|
+
...pro2Config,
|
|
462
477
|
...(pro2Resources ? { resources: pro2Resources } : undefined),
|
|
463
478
|
},
|
|
464
479
|
};
|
|
@@ -505,6 +520,12 @@ export default class DataManager {
|
|
|
505
520
|
'Unable to refresh the latest remote config'
|
|
506
521
|
);
|
|
507
522
|
}
|
|
523
|
+
if (this.protocolV2ResourcesConfigError) {
|
|
524
|
+
throw ERRORS.TypedError(
|
|
525
|
+
HardwareErrorCode.NetworkError,
|
|
526
|
+
`Invalid Pro2 resources config: ${this.protocolV2ResourcesConfigError.message}`
|
|
527
|
+
);
|
|
528
|
+
}
|
|
508
529
|
this.lastCheckTimestamp = getTimeStamp();
|
|
509
530
|
}
|
|
510
531
|
|
|
@@ -121,6 +121,12 @@ export default class TransportManager {
|
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
static setTransport(TransportConstructor: any, plugin?: LowlevelTransportSharedPlugin) {
|
|
124
|
+
if (typeof TransportConstructor !== 'function') {
|
|
125
|
+
throw ERRORS.TypedError(
|
|
126
|
+
HardwareErrorCode.TransportNotConfigured,
|
|
127
|
+
'Transport constructor is not available'
|
|
128
|
+
);
|
|
129
|
+
}
|
|
124
130
|
const env = DataManager.getSettings('env');
|
|
125
131
|
if (env === 'react-native') {
|
|
126
132
|
/** Actually initializes the ReactNativeTransport */
|
|
@@ -55,8 +55,10 @@ const DEVICE_SESSION_CALLS = new Set([
|
|
|
55
55
|
'DeviceSessionAskPassphrase',
|
|
56
56
|
]);
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
const PROTOCOL_V2_ACTION_CANCELLED_SUBCODE = 1;
|
|
59
|
+
|
|
60
|
+
// Older Protocol V2 firmware may omit the cancellation subcode, so retain a
|
|
61
|
+
// narrow message fallback for compatibility.
|
|
60
62
|
const isProtocolV2ActionCancelledMessage = (message: string) =>
|
|
61
63
|
/^(?:cancel(?:led|ed)(?: on device)?|confirm dismissed|user cancel(?:led|ed)(?:\s+.*)?)$/i.test(
|
|
62
64
|
message
|
|
@@ -499,6 +501,15 @@ export class DeviceCommands {
|
|
|
499
501
|
const normalizedMessage = message?.trim() ?? '';
|
|
500
502
|
const isProtocolV2ActionCancelledFailure =
|
|
501
503
|
this.device.isProtocolV2() && isProtocolV2ActionCancelledMessage(normalizedMessage);
|
|
504
|
+
const isProtocolV2ActionCancelledSubcode =
|
|
505
|
+
this.device.isProtocolV2() && subcode === PROTOCOL_V2_ACTION_CANCELLED_SUBCODE;
|
|
506
|
+
// DeviceErrorCode currently reuses subcode 1 for Busy. Resolve that
|
|
507
|
+
// domain-specific exception before applying the common cancellation map.
|
|
508
|
+
const isProtocolV2DeviceBusyFailure =
|
|
509
|
+
this.device.isProtocolV2() &&
|
|
510
|
+
callType.startsWith('Device') &&
|
|
511
|
+
!DEVICE_SESSION_CALLS.has(callType) &&
|
|
512
|
+
subcode === DeviceErrorCode.DeviceError_Busy;
|
|
502
513
|
const isLegacyProtocolV2LockedFailure =
|
|
503
514
|
this.device.isProtocolV2() && /^device (?:is )?locked$/i.test(normalizedMessage);
|
|
504
515
|
if (
|
|
@@ -556,8 +567,15 @@ export class DeviceCommands {
|
|
|
556
567
|
subcode,
|
|
557
568
|
firmwareMessage: message,
|
|
558
569
|
});
|
|
570
|
+
} else if (isProtocolV2DeviceBusyFailure) {
|
|
571
|
+
error = ERRORS.TypedError(HardwareErrorCode.DeviceBusy, message, {
|
|
572
|
+
failureCode: code,
|
|
573
|
+
subcode,
|
|
574
|
+
firmwareMessage: message,
|
|
575
|
+
});
|
|
559
576
|
} else if (
|
|
560
577
|
subcode === DeviceErrorCode.DeviceError_ActionCancelled ||
|
|
578
|
+
isProtocolV2ActionCancelledSubcode ||
|
|
561
579
|
isProtocolV2ActionCancelledFailure
|
|
562
580
|
) {
|
|
563
581
|
error = ERRORS.TypedError(HardwareErrorCode.ActionCancelled, message, {
|
|
@@ -14,7 +14,7 @@ import type { OneKeyDeviceInfo as DeviceDescriptor, Transport } from '@onekeyfe/
|
|
|
14
14
|
const Log = getLogger(LoggerNames.DeviceConnector);
|
|
15
15
|
|
|
16
16
|
export default class DeviceConnector {
|
|
17
|
-
transport
|
|
17
|
+
transport?: Transport;
|
|
18
18
|
|
|
19
19
|
listenTimestamp = 0;
|
|
20
20
|
|
|
@@ -30,9 +30,21 @@ export default class DeviceConnector {
|
|
|
30
30
|
DevicePool.setConnector(this);
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
private getActiveTransport(): Transport {
|
|
34
|
+
const transport = this.transport ?? TransportManager.getTransport();
|
|
35
|
+
if (!transport) {
|
|
36
|
+
throw ERRORS.TypedError(
|
|
37
|
+
HardwareErrorCode.TransportNotConfigured,
|
|
38
|
+
'Device connector was created before transport initialization'
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
this.transport = transport;
|
|
42
|
+
return transport;
|
|
43
|
+
}
|
|
44
|
+
|
|
33
45
|
async enumerate() {
|
|
34
46
|
try {
|
|
35
|
-
const descriptors = await this.
|
|
47
|
+
const descriptors = await this.getActiveTransport().enumerate();
|
|
36
48
|
this.upcoming = descriptors;
|
|
37
49
|
this._reportDevicesChange();
|
|
38
50
|
return { descriptors } as DeviceDescriptorDiff;
|
|
@@ -50,11 +62,10 @@ export default class DeviceConnector {
|
|
|
50
62
|
let descriptors: DeviceDescriptor[];
|
|
51
63
|
|
|
52
64
|
try {
|
|
65
|
+
const transport = this.getActiveTransport();
|
|
53
66
|
Log.debug('Start listening', current);
|
|
54
67
|
this.listenTimestamp = new Date().getTime();
|
|
55
|
-
descriptors = waitForEvent
|
|
56
|
-
? await this.transport.listen(current)
|
|
57
|
-
: await this.transport.enumerate();
|
|
68
|
+
descriptors = waitForEvent ? await transport.listen(current) : await transport.enumerate();
|
|
58
69
|
if (!this.listening) return; // do not continue if stop() was called
|
|
59
70
|
|
|
60
71
|
this.upcoming = descriptors;
|
|
@@ -88,16 +99,17 @@ export default class DeviceConnector {
|
|
|
88
99
|
Log.debug('acquire', path, session, expectedProtocol, protocolHint);
|
|
89
100
|
const env = DataManager.getSettings('env');
|
|
90
101
|
try {
|
|
102
|
+
const transport = this.getActiveTransport();
|
|
91
103
|
let res;
|
|
92
104
|
if (DataManager.isBleConnect(env)) {
|
|
93
|
-
res = await
|
|
105
|
+
res = await transport.acquire({
|
|
94
106
|
uuid: path,
|
|
95
107
|
forceCleanRunPromise,
|
|
96
108
|
expectedProtocol,
|
|
97
109
|
protocolHint,
|
|
98
110
|
});
|
|
99
111
|
} else {
|
|
100
|
-
res = await
|
|
112
|
+
res = await transport.acquire({
|
|
101
113
|
path,
|
|
102
114
|
previous: session ?? null,
|
|
103
115
|
expectedProtocol,
|
|
@@ -105,7 +117,13 @@ export default class DeviceConnector {
|
|
|
105
117
|
});
|
|
106
118
|
}
|
|
107
119
|
if (expectedProtocol) {
|
|
108
|
-
|
|
120
|
+
// The acquire response is the stable snapshot from this active probe. A delayed
|
|
121
|
+
// disconnect from an older generation may clear caches, so do not rely on cache alone.
|
|
122
|
+
const acquiredProtocol =
|
|
123
|
+
typeof res === 'object' && res !== null
|
|
124
|
+
? (res as DeviceDescriptor).protocolType
|
|
125
|
+
: undefined;
|
|
126
|
+
const detectedProtocol = acquiredProtocol ?? transport.getProtocolType(path);
|
|
109
127
|
if (detectedProtocol !== expectedProtocol) {
|
|
110
128
|
throw ERRORS.TypedError(
|
|
111
129
|
HardwareErrorCode.RuntimeError,
|
|
@@ -122,7 +140,7 @@ export default class DeviceConnector {
|
|
|
122
140
|
|
|
123
141
|
async release(session: string, onclose: boolean) {
|
|
124
142
|
try {
|
|
125
|
-
const res = await this.
|
|
143
|
+
const res = await this.getActiveTransport().release(session, onclose);
|
|
126
144
|
return res;
|
|
127
145
|
} catch (error) {
|
|
128
146
|
safeThrowError(error);
|
|
@@ -131,8 +149,9 @@ export default class DeviceConnector {
|
|
|
131
149
|
|
|
132
150
|
async disconnect(session: string | undefined | null) {
|
|
133
151
|
try {
|
|
134
|
-
|
|
135
|
-
|
|
152
|
+
const transport = this.getActiveTransport();
|
|
153
|
+
if (transport.disconnect && !!session) {
|
|
154
|
+
await transport.disconnect(session);
|
|
136
155
|
}
|
|
137
156
|
} catch (error) {
|
|
138
157
|
safeThrowError(error);
|
|
@@ -140,10 +159,11 @@ export default class DeviceConnector {
|
|
|
140
159
|
}
|
|
141
160
|
|
|
142
161
|
promptDeviceAccess(): Promise<USBDevice | BluetoothDevice | null> {
|
|
143
|
-
|
|
162
|
+
const transport = this.getActiveTransport();
|
|
163
|
+
if (!transport.promptDeviceAccess) {
|
|
144
164
|
return Promise.resolve(null);
|
|
145
165
|
}
|
|
146
|
-
return
|
|
166
|
+
return transport.promptDeviceAccess();
|
|
147
167
|
}
|
|
148
168
|
|
|
149
169
|
_reportDevicesChange() {
|
package/src/index.ts
CHANGED
|
@@ -10,11 +10,6 @@ export type { LowLevelCoreApi, LowLevelInjectApi } from './lowLevelInject';
|
|
|
10
10
|
export type { TopLevelInjectApi } from './topLevelInject';
|
|
11
11
|
|
|
12
12
|
export { default as Core, init as initCore, switchTransport } from './core';
|
|
13
|
-
export type { CoreOptions } from './core';
|
|
14
|
-
export { factoryApiMethodExtension, testApiMethodExtension } from './api/methodExtension';
|
|
15
|
-
export type { CoreMethodConstructor, CoreMethodExtension } from './api/methodExtension';
|
|
16
|
-
export { FACTORY_API_METHOD_NAMES, TEST_API_METHOD_NAMES } from './api/extensionMethodNames';
|
|
17
|
-
export { createFactoryApi, createTestApi } from './inject';
|
|
18
13
|
|
|
19
14
|
export * from './constants';
|
|
20
15
|
export * from './utils';
|
package/src/inject.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { FACTORY_API_METHOD_NAMES, TEST_API_METHOD_NAMES } from './api/extensionMethodNames';
|
|
2
|
-
|
|
3
1
|
import type { HardwareConnectProtocol } from '@onekeyfe/hd-shared';
|
|
4
2
|
import type { Unsuccessful } from './types';
|
|
5
3
|
import type { EventEmitter } from 'events';
|
|
6
4
|
import type { CallMethod } from './events';
|
|
7
|
-
import type { CoreApi
|
|
5
|
+
import type { CoreApi } from './types/api';
|
|
8
6
|
import type { AllNetworkAddress } from './types/api/allNetworkGetAddress';
|
|
9
7
|
|
|
10
8
|
type CallbackFunction = (data?: any, error?: Unsuccessful) => void;
|
|
@@ -133,7 +131,10 @@ export const inject = ({
|
|
|
133
131
|
return api;
|
|
134
132
|
};
|
|
135
133
|
|
|
136
|
-
|
|
134
|
+
export const createCoreApi = (
|
|
135
|
+
call: CoreApi['call']
|
|
136
|
+
): Omit<
|
|
137
|
+
CoreApi,
|
|
137
138
|
| 'on'
|
|
138
139
|
| 'off'
|
|
139
140
|
| 'emit'
|
|
@@ -145,11 +146,8 @@ type ApiControlMethodName =
|
|
|
145
146
|
| 'uiResponse'
|
|
146
147
|
| 'cancel'
|
|
147
148
|
| 'updateSettings'
|
|
148
|
-
| 'switchTransport'
|
|
149
|
-
|
|
150
|
-
type InjectedApi<TApi> = Omit<TApi, ApiControlMethodName>;
|
|
151
|
-
|
|
152
|
-
const createAllCoreApi = (call: CoreApi['call']): InjectedApi<TestApi> => ({
|
|
149
|
+
| 'switchTransport'
|
|
150
|
+
> => ({
|
|
153
151
|
getLogs: () => call({ method: 'getLogs' }),
|
|
154
152
|
clearSessionCache: params => call({ ...params, method: 'clearSessionCache' }),
|
|
155
153
|
/**
|
|
@@ -217,16 +215,6 @@ const createAllCoreApi = (call: CoreApi['call']): InjectedApi<TestApi> => ({
|
|
|
217
215
|
deviceReboot: (connectId, params) => call({ ...params, connectId, method: 'deviceReboot' }),
|
|
218
216
|
deviceGetOnboardingStatus: (connectId, params) =>
|
|
219
217
|
call({ ...params, connectId, method: 'deviceGetOnboardingStatus' }),
|
|
220
|
-
deviceProvisionFactoryInfo: (connectId, params) =>
|
|
221
|
-
call({ ...params, connectId, method: 'deviceProvisionFactoryInfo' }),
|
|
222
|
-
deviceReadFactoryInfo: (connectId, params) =>
|
|
223
|
-
call({ ...params, connectId, method: 'deviceReadFactoryInfo' }),
|
|
224
|
-
deviceWriteFactoryCertificate: (connectId, params) =>
|
|
225
|
-
call({ ...params, connectId, method: 'deviceWriteFactoryCertificate' }),
|
|
226
|
-
deviceReadFactoryCertificate: (connectId, params) =>
|
|
227
|
-
call({ ...params, connectId, method: 'deviceReadFactoryCertificate' }),
|
|
228
|
-
deviceSignFactoryChallenge: (connectId, params) =>
|
|
229
|
-
call({ ...params, connectId, method: 'deviceSignFactoryChallenge' }),
|
|
230
218
|
deviceUploadWallpaper: (connectId, params) =>
|
|
231
219
|
call({ ...params, connectId, method: 'deviceUploadWallpaper' }),
|
|
232
220
|
deviceUploadNft: (connectId, params) => call({ ...params, connectId, method: 'deviceUploadNft' }),
|
|
@@ -297,19 +285,6 @@ const createAllCoreApi = (call: CoreApi['call']): InjectedApi<TestApi> => ({
|
|
|
297
285
|
evmVerifyMessage: (connectId, deviceId, params) =>
|
|
298
286
|
call({ ...params, connectId, deviceId, method: 'evmVerifyMessage' }),
|
|
299
287
|
|
|
300
|
-
evmGetAddressTrezor: (connectId, deviceId, params) =>
|
|
301
|
-
call({ ...params, connectId, deviceId, method: 'evmGetAddressTrezor' }),
|
|
302
|
-
evmGetPublicKeyTrezor: (connectId, deviceId, params) =>
|
|
303
|
-
call({ ...params, connectId, deviceId, method: 'evmGetPublicKeyTrezor' }),
|
|
304
|
-
evmSignMessageTrezor: (connectId, deviceId, params) =>
|
|
305
|
-
call({ ...params, connectId, deviceId, method: 'evmSignMessageTrezor' }),
|
|
306
|
-
evmSignTransactionTrezor: (connectId, deviceId, params) =>
|
|
307
|
-
call({ ...params, connectId, deviceId, method: 'evmSignTransactionTrezor' }),
|
|
308
|
-
evmSignTypedDataTrezor: (connectId, deviceId, params) =>
|
|
309
|
-
call({ ...params, connectId, deviceId, method: 'evmSignTypedDataTrezor' }),
|
|
310
|
-
evmVerifyMessageTrezor: (connectId, deviceId, params) =>
|
|
311
|
-
call({ ...params, connectId, deviceId, method: 'evmVerifyMessageTrezor' }),
|
|
312
|
-
|
|
313
288
|
btcGetAddress: (connectId, deviceId, params) =>
|
|
314
289
|
call({ ...params, connectId, deviceId, method: 'btcGetAddress' }),
|
|
315
290
|
btcGetPublicKey: (connectId, deviceId, params) =>
|
|
@@ -322,25 +297,6 @@ const createAllCoreApi = (call: CoreApi['call']): InjectedApi<TestApi> => ({
|
|
|
322
297
|
call({ ...params, connectId, deviceId, method: 'btcSignTransaction' }),
|
|
323
298
|
btcVerifyMessage: (connectId, deviceId, params) =>
|
|
324
299
|
call({ ...params, connectId, deviceId, method: 'btcVerifyMessage' }),
|
|
325
|
-
btcGetOwnershipId: (connectId, deviceId, params) =>
|
|
326
|
-
call({ ...params, connectId, deviceId, method: 'btcGetOwnershipId' }),
|
|
327
|
-
btcGetOwnershipProof: (connectId, deviceId, params) =>
|
|
328
|
-
call({ ...params, connectId, deviceId, method: 'btcGetOwnershipProof' }),
|
|
329
|
-
btcAuthorizeCoinJoin: (connectId, deviceId, params) =>
|
|
330
|
-
call({ ...params, connectId, deviceId, method: 'btcAuthorizeCoinJoin' }),
|
|
331
|
-
|
|
332
|
-
cryptoBatchGetPublickeys: (connectId, deviceId, params) =>
|
|
333
|
-
call({ ...params, connectId, deviceId, method: 'cryptoBatchGetPublickeys' }),
|
|
334
|
-
cryptoCipherKeyValue: (connectId, deviceId, params) =>
|
|
335
|
-
call({ ...params, connectId, deviceId, method: 'cryptoCipherKeyValue' }),
|
|
336
|
-
cryptoCosiCommit: (connectId, deviceId, params) =>
|
|
337
|
-
call({ ...params, connectId, deviceId, method: 'cryptoCosiCommit' }),
|
|
338
|
-
cryptoCosiSign: (connectId, deviceId, params) =>
|
|
339
|
-
call({ ...params, connectId, deviceId, method: 'cryptoCosiSign' }),
|
|
340
|
-
cryptoGetECDHSessionKey: (connectId, deviceId, params) =>
|
|
341
|
-
call({ ...params, connectId, deviceId, method: 'cryptoGetECDHSessionKey' }),
|
|
342
|
-
cryptoSignIdentity: (connectId, deviceId, params) =>
|
|
343
|
-
call({ ...params, connectId, deviceId, method: 'cryptoSignIdentity' }),
|
|
344
300
|
|
|
345
301
|
starcoinGetAddress: (connectId, deviceId, params) =>
|
|
346
302
|
call({ ...params, connectId, deviceId, method: 'starcoinGetAddress' }),
|
|
@@ -357,8 +313,6 @@ const createAllCoreApi = (call: CoreApi['call']): InjectedApi<TestApi> => ({
|
|
|
357
313
|
call({ ...params, connectId, deviceId, method: 'nemGetAddress' }),
|
|
358
314
|
nemSignTransaction: (connectId, deviceId, params) =>
|
|
359
315
|
call({ ...params, connectId, deviceId, method: 'nemSignTransaction' }),
|
|
360
|
-
nemDecryptMessage: (connectId, deviceId, params) =>
|
|
361
|
-
call({ ...params, connectId, deviceId, method: 'nemDecryptMessage' }),
|
|
362
316
|
|
|
363
317
|
solGetAddress: (connectId, deviceId, params) =>
|
|
364
318
|
call({ ...params, connectId, deviceId, method: 'solGetAddress' }),
|
|
@@ -524,164 +478,8 @@ const createAllCoreApi = (call: CoreApi['call']): InjectedApi<TestApi> => ({
|
|
|
524
478
|
benfenSignMessage: (connectId, deviceId, params) =>
|
|
525
479
|
call({ ...params, connectId, deviceId, method: 'benfenSignMessage' }),
|
|
526
480
|
|
|
527
|
-
/**
|
|
528
|
-
* Test-only APIs.
|
|
529
|
-
*/
|
|
530
|
-
tezosGetAddress: (connectId, deviceId, params) =>
|
|
531
|
-
call({ ...params, connectId, deviceId, method: 'tezosGetAddress' }),
|
|
532
|
-
tezosGetPublicKey: (connectId, deviceId, params) =>
|
|
533
|
-
call({ ...params, connectId, deviceId, method: 'tezosGetPublicKey' }),
|
|
534
|
-
tezosSignTx: (connectId, deviceId, params) =>
|
|
535
|
-
call({ ...params, connectId, deviceId, method: 'tezosSignTx' }),
|
|
536
|
-
|
|
537
|
-
binanceGetAddress: (connectId, deviceId, params) =>
|
|
538
|
-
call({ ...params, connectId, deviceId, method: 'binanceGetAddress' }),
|
|
539
|
-
binanceGetPublicKey: (connectId, deviceId, params) =>
|
|
540
|
-
call({ ...params, connectId, deviceId, method: 'binanceGetPublicKey' }),
|
|
541
|
-
binanceSignTx: (connectId, deviceId, params) =>
|
|
542
|
-
call({ ...params, connectId, deviceId, method: 'binanceSignTx' }),
|
|
543
|
-
|
|
544
|
-
moneroGetWatchKey: (connectId, deviceId, params) =>
|
|
545
|
-
call({ ...params, connectId, deviceId, method: 'moneroGetWatchKey' }),
|
|
546
|
-
moneroGetAddress: (connectId, deviceId, params) =>
|
|
547
|
-
call({ ...params, connectId, deviceId, method: 'moneroGetAddress' }),
|
|
548
|
-
|
|
549
|
-
eosGetPublicKey: (connectId, deviceId, params) =>
|
|
550
|
-
call({ ...params, connectId, deviceId, method: 'eosGetPublicKey' }),
|
|
551
|
-
eosSignTx: (connectId, deviceId, params) =>
|
|
552
|
-
call({ ...params, connectId, deviceId, method: 'eosSignTx' }),
|
|
553
|
-
|
|
554
|
-
webAuthnAddResidentCredential: (connectId, deviceId, params) =>
|
|
555
|
-
call({ ...params, connectId, deviceId, method: 'webAuthnAddResidentCredential' }),
|
|
556
|
-
webAuthnListResidentCredentials: (connectId, deviceId, params) =>
|
|
557
|
-
call({ ...params, connectId, deviceId, method: 'webAuthnListResidentCredentials' }),
|
|
558
|
-
webAuthnRemoveResidentCredential: (connectId, deviceId, params) =>
|
|
559
|
-
call({ ...params, connectId, deviceId, method: 'webAuthnRemoveResidentCredential' }),
|
|
560
|
-
|
|
561
|
-
getPublicKeyMultiple: (connectId, deviceId, params) =>
|
|
562
|
-
call({ ...params, connectId, deviceId, method: 'getPublicKeyMultiple' }),
|
|
563
|
-
listResDir: (connectId, deviceId, params) =>
|
|
564
|
-
call({ ...params, connectId, deviceId, method: 'listResDir' }),
|
|
565
|
-
nftWriteData: (connectId, deviceId, params) =>
|
|
566
|
-
call({ ...params, connectId, deviceId, method: 'nftWriteData' }),
|
|
567
|
-
nftWriteInfo: (connectId, deviceId, params) =>
|
|
568
|
-
call({ ...params, connectId, deviceId, method: 'nftWriteInfo' }),
|
|
569
|
-
readSEPublicKey: (connectId, deviceId, params) =>
|
|
570
|
-
call({ ...params, connectId, deviceId, method: 'readSEPublicKey' }),
|
|
571
|
-
resourceUpdate: (connectId, deviceId, params) =>
|
|
572
|
-
call({ ...params, connectId, deviceId, method: 'resourceUpdate' }),
|
|
573
|
-
|
|
574
|
-
bixinBackupDevice: (connectId, deviceId, params) =>
|
|
575
|
-
call({ ...params, connectId, deviceId, method: 'bixinBackupDevice' }),
|
|
576
|
-
bixinLoadDevice: (connectId, deviceId, params) =>
|
|
577
|
-
call({ ...params, connectId, deviceId, method: 'bixinLoadDevice' }),
|
|
578
|
-
bixinMessageSE: (connectId, deviceId, params) =>
|
|
579
|
-
call({ ...params, connectId, deviceId, method: 'bixinMessageSE' }),
|
|
580
|
-
bixinVerifyDeviceRequest: (connectId, deviceId, params) =>
|
|
581
|
-
call({ ...params, connectId, deviceId, method: 'bixinVerifyDeviceRequest' }),
|
|
582
|
-
|
|
583
|
-
deviceSpiFlashWrite: (connectId, params) =>
|
|
584
|
-
call({ ...params, connectId, method: 'deviceSpiFlashWrite' }),
|
|
585
|
-
deviceSpiFlashRead: (connectId, params) =>
|
|
586
|
-
call({ ...params, connectId, method: 'deviceSpiFlashRead' }),
|
|
587
|
-
deviceInfoSettings: (connectId, params) =>
|
|
588
|
-
call({ ...params, connectId, method: 'deviceInfoSettings' }),
|
|
589
|
-
deviceGetInfo: (connectId, params) => call({ ...params, connectId, method: 'deviceGetInfo' }),
|
|
590
|
-
deviceReadSEPublicCert: (connectId, params) =>
|
|
591
|
-
call({ ...params, connectId, method: 'deviceReadSEPublicCert' }),
|
|
592
|
-
deviceWriteSEPrivateKey: (connectId, params) =>
|
|
593
|
-
call({ ...params, connectId, method: 'deviceWriteSEPrivateKey' }),
|
|
594
|
-
deviceWriteSEPublicCert: (connectId, params) =>
|
|
595
|
-
call({ ...params, connectId, method: 'deviceWriteSEPublicCert' }),
|
|
596
|
-
deviceSESignMessage: (connectId, params) =>
|
|
597
|
-
call({ ...params, connectId, method: 'deviceSESignMessage' }),
|
|
598
|
-
deviceGetFirmwareHash: (connectId, params) =>
|
|
599
|
-
call({ ...params, connectId, method: 'deviceGetFirmwareHash' }),
|
|
600
|
-
deviceUnlockPath: (connectId, params) =>
|
|
601
|
-
call({ ...params, connectId, method: 'deviceUnlockPath' }),
|
|
602
|
-
devicePing: (connectId, params) => call({ ...params, connectId, method: 'devicePing' }),
|
|
603
|
-
deviceGetEntropy: (connectId, params) =>
|
|
604
|
-
call({ ...params, connectId, method: 'deviceGetEntropy' }),
|
|
605
|
-
deviceSdProtect: (connectId, params) => call({ ...params, connectId, method: 'deviceSdProtect' }),
|
|
606
|
-
deviceChangeWipeCode: (connectId, params) =>
|
|
607
|
-
call({ ...params, connectId, method: 'deviceChangeWipeCode' }),
|
|
608
|
-
deviceEndSession: (connectId, params) =>
|
|
609
|
-
call({ ...params, connectId, method: 'deviceEndSession' }),
|
|
610
|
-
deviceLoad: (connectId, params) => call({ ...params, connectId, method: 'deviceLoad' }),
|
|
611
|
-
deviceDoPreauthorized: (connectId, params) =>
|
|
612
|
-
call({ ...params, connectId, method: 'deviceDoPreauthorized' }),
|
|
613
|
-
deviceCancelAuthorization: (connectId, params) =>
|
|
614
|
-
call({ ...params, connectId, method: 'deviceCancelAuthorization' }),
|
|
615
|
-
|
|
616
|
-
emmcDirList: (connectId, params) => call({ ...params, connectId, method: 'emmcDirList' }),
|
|
617
|
-
emmcDirMake: (connectId, params) => call({ ...params, connectId, method: 'emmcDirMake' }),
|
|
618
|
-
emmcDirRemove: (connectId, params) => call({ ...params, connectId, method: 'emmcDirRemove' }),
|
|
619
|
-
emmcFileDelete: (connectId, params) => call({ ...params, connectId, method: 'emmcFileDelete' }),
|
|
620
|
-
emmcFileRead: (connectId, params) => call({ ...params, connectId, method: 'emmcFileRead' }),
|
|
621
|
-
emmcFileWrite: (connectId, params) => call({ ...params, connectId, method: 'emmcFileWrite' }),
|
|
622
|
-
emmcFixPermission: (connectId, params) =>
|
|
623
|
-
call({ ...params, connectId, method: 'emmcFixPermission' }),
|
|
624
|
-
emmcPathInfo: (connectId, params) => call({ ...params, connectId, method: 'emmcPathInfo' }),
|
|
625
|
-
|
|
626
|
-
debugLinkDecision: (connectId, params) =>
|
|
627
|
-
call({ ...params, connectId, method: 'debugLinkDecision' }),
|
|
628
|
-
debugLinkEraseSdCard: (connectId, params) =>
|
|
629
|
-
call({ ...params, connectId, method: 'debugLinkEraseSdCard' }),
|
|
630
|
-
debugLinkFlashErase: (connectId, params) =>
|
|
631
|
-
call({ ...params, connectId, method: 'debugLinkFlashErase' }),
|
|
632
|
-
debugLinkGetState: (connectId, params) =>
|
|
633
|
-
call({ ...params, connectId, method: 'debugLinkGetState' }),
|
|
634
|
-
debugLinkMemoryRead: (connectId, params) =>
|
|
635
|
-
call({ ...params, connectId, method: 'debugLinkMemoryRead' }),
|
|
636
|
-
debugLinkMemoryWrite: (connectId, params) =>
|
|
637
|
-
call({ ...params, connectId, method: 'debugLinkMemoryWrite' }),
|
|
638
|
-
debugLinkRecordScreen: (connectId, params) =>
|
|
639
|
-
call({ ...params, connectId, method: 'debugLinkRecordScreen' }),
|
|
640
|
-
debugLinkReseedRandom: (connectId, params) =>
|
|
641
|
-
call({ ...params, connectId, method: 'debugLinkReseedRandom' }),
|
|
642
|
-
debugLinkStop: (connectId, params) => call({ ...params, connectId, method: 'debugLinkStop' }),
|
|
643
|
-
debugLinkWatchLayout: (connectId, params) =>
|
|
644
|
-
call({ ...params, connectId, method: 'debugLinkWatchLayout' }),
|
|
645
|
-
|
|
646
|
-
firmwareEraseEx: (connectId, params) => call({ ...params, connectId, method: 'firmwareEraseEx' }),
|
|
647
|
-
firmwareErase: (connectId, params) => call({ ...params, connectId, method: 'firmwareErase' }),
|
|
648
|
-
firmwareUpdateEmmcTest: (connectId, params) =>
|
|
649
|
-
call({ ...params, connectId, method: 'firmwareUpdateEmmcTest' }),
|
|
650
|
-
firmwareUploadTest: (connectId, params) =>
|
|
651
|
-
call({ ...params, connectId, method: 'firmwareUploadTest' }),
|
|
652
|
-
reboot: (connectId, params) => call({ ...params, connectId, method: 'reboot' }),
|
|
653
|
-
selfTest: (connectId, params) => call({ ...params, connectId, method: 'selfTest' }),
|
|
654
|
-
|
|
655
481
|
neoGetAddress: (connectId, deviceId, params) =>
|
|
656
482
|
call({ ...params, connectId, deviceId, method: 'neoGetAddress' }),
|
|
657
483
|
neoSignTransaction: (connectId, deviceId, params) =>
|
|
658
484
|
call({ ...params, connectId, deviceId, method: 'neoSignTransaction' }),
|
|
659
485
|
});
|
|
660
|
-
|
|
661
|
-
const pickApiMethods = <TApi extends object>(
|
|
662
|
-
api: InjectedApi<TestApi>,
|
|
663
|
-
methodNames: readonly string[]
|
|
664
|
-
): TApi => {
|
|
665
|
-
const selected: Record<string, unknown> = {};
|
|
666
|
-
methodNames.forEach(methodName => {
|
|
667
|
-
selected[methodName] = api[methodName as keyof typeof api];
|
|
668
|
-
});
|
|
669
|
-
return selected as TApi;
|
|
670
|
-
};
|
|
671
|
-
|
|
672
|
-
export const createCoreApi = (call: CoreApi['call']): InjectedApi<CoreApi> => {
|
|
673
|
-
const api = createAllCoreApi(call);
|
|
674
|
-
const extensionMethodNames = new Set<string>([
|
|
675
|
-
...TEST_API_METHOD_NAMES,
|
|
676
|
-
...FACTORY_API_METHOD_NAMES,
|
|
677
|
-
]);
|
|
678
|
-
return Object.fromEntries(
|
|
679
|
-
Object.entries(api).filter(([methodName]) => !extensionMethodNames.has(methodName))
|
|
680
|
-
) as InjectedApi<CoreApi>;
|
|
681
|
-
};
|
|
682
|
-
|
|
683
|
-
export const createTestApi = (call: CoreApi['call']): TestApiMethods =>
|
|
684
|
-
pickApiMethods<TestApiMethods>(createAllCoreApi(call), TEST_API_METHOD_NAMES);
|
|
685
|
-
|
|
686
|
-
export const createFactoryApi = (call: CoreApi['call']): FactoryApi =>
|
|
687
|
-
pickApiMethods<FactoryApi>(createAllCoreApi(call), FACTORY_API_METHOD_NAMES);
|