@ledgerhq/device-signer-kit-ethereum 0.0.0-multisig-20250925175241 → 0.0.0-ng5-ble-ids-20260105102514
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/README.md +59 -1
- package/lib/cjs/api/SignerEth.js +1 -1
- package/lib/cjs/api/SignerEth.js.map +1 -1
- package/lib/cjs/api/SignerEthBuilder.test.js +1 -1
- package/lib/cjs/api/SignerEthBuilder.test.js.map +2 -2
- package/lib/cjs/api/app-binder/SignTransactionDeviceActionTypes.js +1 -1
- package/lib/cjs/api/app-binder/SignTransactionDeviceActionTypes.js.map +2 -2
- package/lib/cjs/api/app-binder/SignTypedDataDeviceActionTypes.js +1 -1
- package/lib/cjs/api/app-binder/SignTypedDataDeviceActionTypes.js.map +2 -2
- package/lib/cjs/api/app-binder/VerifySafeAddressDeviceActionTypes.js +2 -0
- package/lib/cjs/api/app-binder/VerifySafeAddressDeviceActionTypes.js.map +7 -0
- package/lib/cjs/api/model/SafeAddressOptions.js +2 -0
- package/lib/cjs/api/model/SafeAddressOptions.js.map +7 -0
- package/lib/cjs/internal/DefaultSignerEth.js +1 -1
- package/lib/cjs/internal/DefaultSignerEth.js.map +3 -3
- package/lib/cjs/internal/app-binder/EthAppBinder.js +1 -1
- package/lib/cjs/internal/app-binder/EthAppBinder.js.map +3 -3
- package/lib/cjs/internal/app-binder/EthAppBinder.test.js +1 -1
- package/lib/cjs/internal/app-binder/EthAppBinder.test.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/GetAddressCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/GetAddressCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/GetAddressCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/GetAddressCommand.test.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/GetAppConfigurationCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/GetAppConfigurationCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/GetAppConfigurationCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/GetAppConfigurationCommand.test.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/GetChallengeCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/GetChallengeCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/GetChallengeCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/GetChallengeCommand.test.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/ProvideEnumCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/ProvideEnumCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/ProvideEnumCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/ProvideEnumCommand.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/command/ProvideNFTInformationCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/ProvideNFTInformationCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/ProvideNFTInformationCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/ProvideNFTInformationCommand.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/command/ProvideNetworkConfigurationCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/ProvideNetworkConfigurationCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/ProvideNetworkConfigurationCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/ProvideNetworkConfigurationCommand.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/command/ProvideProxyInfoCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/ProvideProxyInfoCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/ProvideProxyInfoCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/ProvideProxyInfoCommand.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/command/ProvideSafeAccountCommand.js +2 -0
- package/lib/cjs/internal/app-binder/command/ProvideSafeAccountCommand.js.map +7 -0
- package/lib/cjs/internal/app-binder/command/ProvideSafeAccountCommand.test.js +2 -0
- package/lib/cjs/internal/app-binder/command/ProvideSafeAccountCommand.test.js.map +7 -0
- package/lib/cjs/internal/app-binder/command/ProvideTokenInformationCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/ProvideTokenInformationCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/ProvideTokenInformationCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/ProvideTokenInformationCommand.test.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/ProvideTransactionFieldDescriptionCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/ProvideTransactionFieldDescriptionCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/ProvideTransactionFieldDescriptionCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/ProvideTransactionFieldDescriptionCommand.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/command/ProvideTransactionInformationCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/ProvideTransactionInformationCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/ProvideTransactionInformationCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/ProvideTransactionInformationCommand.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/command/ProvideTrustedNameCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/ProvideTrustedNameCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/ProvideTrustedNameCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/ProvideTrustedNameCommand.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/command/ProvideWeb3CheckCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/ProvideWeb3CheckCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/ProvideWeb3CheckCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/ProvideWeb3CheckCommand.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/command/SendEIP712FilteringCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/SendEIP712FilteringCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/SendEIP712FilteringCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/SendEIP712FilteringCommand.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/command/SendEIP712StructDefinitionCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/SendEIP712StructDefinitionCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/SendEIP712StructDefinitionCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/SendEIP712StructDefinitionCommand.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/command/SendEIP712StructImplemCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/SendEIP712StructImplemCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/SendEIP712StructImplemCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/SendEIP712StructImplemCommand.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/command/SetExternalPluginCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/SetExternalPluginCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/SetExternalPluginCommand.test.js +2 -2
- package/lib/cjs/internal/app-binder/command/SetExternalPluginCommand.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/command/SetPluginCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/SetPluginCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/SetPluginCommand.test.js +2 -2
- package/lib/cjs/internal/app-binder/command/SetPluginCommand.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/command/SignAuthorizationDelegationCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/SignAuthorizationDelegationCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/SignAuthorizationDelegationCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/SignAuthorizationDelegationCommand.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/command/SignEIP712Command.js +1 -1
- package/lib/cjs/internal/app-binder/command/SignEIP712Command.js.map +3 -3
- package/lib/cjs/internal/app-binder/command/SignEIP712Command.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/SignEIP712Command.test.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/SignPersonalMessageCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/SignPersonalMessageCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/SignPersonalMessageCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/SignPersonalMessageCommand.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/command/SignTransactionCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/SignTransactionCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/SignTransactionCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/SignTransactionCommand.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/command/StartTransactionCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/StartTransactionCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/StartTransactionCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/StartTransactionCommand.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/command/StoreTransactionCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/StoreTransactionCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/StoreTransactionCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/StoreTransactionCommand.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/command/Web3CheckOptInCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/Web3CheckOptInCommand.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/Web3CheckOptInCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/Web3CheckOptInCommand.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.js +1 -1
- package/lib/cjs/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.js.map +3 -3
- package/lib/cjs/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.test.js +1 -1
- package/lib/cjs/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.js +1 -1
- package/lib/cjs/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.js.map +3 -3
- package/lib/cjs/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.test.js +1 -1
- package/lib/cjs/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/device-action/VerifySafeAddress/VerifySafeAddress.js +2 -0
- package/lib/cjs/internal/app-binder/device-action/VerifySafeAddress/VerifySafeAddress.js.map +7 -0
- package/lib/cjs/internal/app-binder/device-action/VerifySafeAddress/VerifySafeAddress.test.js +2 -0
- package/lib/cjs/internal/app-binder/device-action/VerifySafeAddress/VerifySafeAddress.test.js.map +7 -0
- package/lib/cjs/internal/app-binder/task/BuildBaseContexts.js +1 -1
- package/lib/cjs/internal/app-binder/task/BuildBaseContexts.js.map +3 -3
- package/lib/cjs/internal/app-binder/task/BuildBaseContexts.test.js +1 -1
- package/lib/cjs/internal/app-binder/task/BuildBaseContexts.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/task/BuildEIP712ContextTask.js +1 -1
- package/lib/cjs/internal/app-binder/task/BuildEIP712ContextTask.js.map +3 -3
- package/lib/cjs/internal/app-binder/task/BuildEIP712ContextTask.test.js +1 -1
- package/lib/cjs/internal/app-binder/task/BuildEIP712ContextTask.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/task/BuildSafeAddressContextTask.js +2 -0
- package/lib/cjs/internal/app-binder/task/BuildSafeAddressContextTask.js.map +7 -0
- package/lib/cjs/internal/app-binder/task/BuildSafeAddressContextTask.test.js +2 -0
- package/lib/cjs/internal/app-binder/task/BuildSafeAddressContextTask.test.js.map +7 -0
- package/lib/cjs/internal/app-binder/task/BuildSubcontextsTask.js +1 -1
- package/lib/cjs/internal/app-binder/task/BuildSubcontextsTask.js.map +2 -2
- package/lib/cjs/internal/app-binder/task/BuildSubcontextsTask.test.js +1 -1
- package/lib/cjs/internal/app-binder/task/BuildSubcontextsTask.test.js.map +2 -2
- package/lib/cjs/internal/app-binder/task/ProvideContextTask.js +2 -0
- package/lib/cjs/internal/app-binder/task/ProvideContextTask.js.map +7 -0
- package/lib/cjs/internal/app-binder/task/ProvideContextTask.test.js +2 -0
- package/lib/cjs/internal/app-binder/task/ProvideContextTask.test.js.map +7 -0
- package/lib/cjs/internal/app-binder/task/ProvideEIP712ContextTask.js +1 -1
- package/lib/cjs/internal/app-binder/task/ProvideEIP712ContextTask.js.map +3 -3
- package/lib/cjs/internal/app-binder/task/ProvideEIP712ContextTask.test.js +1 -1
- package/lib/cjs/internal/app-binder/task/ProvideEIP712ContextTask.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/task/ProvideTransactionContextsTask.js +2 -0
- package/lib/cjs/internal/app-binder/task/ProvideTransactionContextsTask.js.map +7 -0
- package/lib/cjs/internal/app-binder/task/ProvideTransactionContextsTask.test.js +2 -0
- package/lib/cjs/internal/app-binder/task/ProvideTransactionContextsTask.test.js.map +7 -0
- package/lib/cjs/internal/di.js +1 -1
- package/lib/cjs/internal/di.js.map +3 -3
- package/lib/cjs/internal/safe/di/safeModule.js +2 -0
- package/lib/cjs/internal/safe/di/safeModule.js.map +7 -0
- package/lib/cjs/internal/safe/di/safeModule.test.js +2 -0
- package/lib/cjs/internal/safe/di/safeModule.test.js.map +7 -0
- package/lib/cjs/internal/safe/di/safeTypes.js +2 -0
- package/lib/cjs/internal/safe/di/safeTypes.js.map +7 -0
- package/lib/cjs/internal/safe/use-case/VerifySafeAddressUseCase.js +2 -0
- package/lib/cjs/internal/safe/use-case/VerifySafeAddressUseCase.js.map +7 -0
- package/lib/cjs/internal/safe/use-case/VerifySafeAddressUseCase.test.js +2 -0
- package/lib/cjs/internal/safe/use-case/VerifySafeAddressUseCase.test.js.map +7 -0
- package/lib/cjs/package.json +41 -37
- package/lib/esm/api/SignerEthBuilder.test.js +1 -1
- package/lib/esm/api/SignerEthBuilder.test.js.map +2 -2
- package/lib/esm/api/app-binder/SignTransactionDeviceActionTypes.js +1 -1
- package/lib/esm/api/app-binder/SignTransactionDeviceActionTypes.js.map +2 -2
- package/lib/esm/api/app-binder/SignTypedDataDeviceActionTypes.js +1 -1
- package/lib/esm/api/app-binder/SignTypedDataDeviceActionTypes.js.map +2 -2
- package/lib/esm/api/app-binder/VerifySafeAddressDeviceActionTypes.js +2 -0
- package/lib/esm/api/app-binder/VerifySafeAddressDeviceActionTypes.js.map +7 -0
- package/lib/esm/api/model/SafeAddressOptions.js +1 -0
- package/lib/esm/api/model/SafeAddressOptions.js.map +7 -0
- package/lib/esm/internal/DefaultSignerEth.js +1 -1
- package/lib/esm/internal/DefaultSignerEth.js.map +3 -3
- package/lib/esm/internal/app-binder/EthAppBinder.js +1 -1
- package/lib/esm/internal/app-binder/EthAppBinder.js.map +3 -3
- package/lib/esm/internal/app-binder/EthAppBinder.test.js +1 -1
- package/lib/esm/internal/app-binder/EthAppBinder.test.js.map +2 -2
- package/lib/esm/internal/app-binder/command/GetAddressCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/GetAddressCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/GetAddressCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/GetAddressCommand.test.js.map +2 -2
- package/lib/esm/internal/app-binder/command/GetAppConfigurationCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/GetAppConfigurationCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/GetAppConfigurationCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/GetAppConfigurationCommand.test.js.map +2 -2
- package/lib/esm/internal/app-binder/command/GetChallengeCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/GetChallengeCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/GetChallengeCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/GetChallengeCommand.test.js.map +2 -2
- package/lib/esm/internal/app-binder/command/ProvideEnumCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/ProvideEnumCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/ProvideEnumCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/ProvideEnumCommand.test.js.map +3 -3
- package/lib/esm/internal/app-binder/command/ProvideNFTInformationCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/ProvideNFTInformationCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/ProvideNFTInformationCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/ProvideNFTInformationCommand.test.js.map +3 -3
- package/lib/esm/internal/app-binder/command/ProvideNetworkConfigurationCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/ProvideNetworkConfigurationCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/ProvideNetworkConfigurationCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/ProvideNetworkConfigurationCommand.test.js.map +3 -3
- package/lib/esm/internal/app-binder/command/ProvideProxyInfoCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/ProvideProxyInfoCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/ProvideProxyInfoCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/ProvideProxyInfoCommand.test.js.map +3 -3
- package/lib/esm/internal/app-binder/command/ProvideSafeAccountCommand.js +2 -0
- package/lib/esm/internal/app-binder/command/ProvideSafeAccountCommand.js.map +7 -0
- package/lib/esm/internal/app-binder/command/ProvideSafeAccountCommand.test.js +2 -0
- package/lib/esm/internal/app-binder/command/ProvideSafeAccountCommand.test.js.map +7 -0
- package/lib/esm/internal/app-binder/command/ProvideTokenInformationCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/ProvideTokenInformationCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/ProvideTokenInformationCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/ProvideTokenInformationCommand.test.js.map +2 -2
- package/lib/esm/internal/app-binder/command/ProvideTransactionFieldDescriptionCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/ProvideTransactionFieldDescriptionCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/ProvideTransactionFieldDescriptionCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/ProvideTransactionFieldDescriptionCommand.test.js.map +3 -3
- package/lib/esm/internal/app-binder/command/ProvideTransactionInformationCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/ProvideTransactionInformationCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/ProvideTransactionInformationCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/ProvideTransactionInformationCommand.test.js.map +3 -3
- package/lib/esm/internal/app-binder/command/ProvideTrustedNameCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/ProvideTrustedNameCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/ProvideTrustedNameCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/ProvideTrustedNameCommand.test.js.map +3 -3
- package/lib/esm/internal/app-binder/command/ProvideWeb3CheckCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/ProvideWeb3CheckCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/ProvideWeb3CheckCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/ProvideWeb3CheckCommand.test.js.map +3 -3
- package/lib/esm/internal/app-binder/command/SendEIP712FilteringCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/SendEIP712FilteringCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/SendEIP712FilteringCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/SendEIP712FilteringCommand.test.js.map +3 -3
- package/lib/esm/internal/app-binder/command/SendEIP712StructDefinitionCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/SendEIP712StructDefinitionCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/SendEIP712StructDefinitionCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/SendEIP712StructDefinitionCommand.test.js.map +3 -3
- package/lib/esm/internal/app-binder/command/SendEIP712StructImplemCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/SendEIP712StructImplemCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/SendEIP712StructImplemCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/SendEIP712StructImplemCommand.test.js.map +3 -3
- package/lib/esm/internal/app-binder/command/SetExternalPluginCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/SetExternalPluginCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/SetExternalPluginCommand.test.js +2 -2
- package/lib/esm/internal/app-binder/command/SetExternalPluginCommand.test.js.map +3 -3
- package/lib/esm/internal/app-binder/command/SetPluginCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/SetPluginCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/SetPluginCommand.test.js +2 -2
- package/lib/esm/internal/app-binder/command/SetPluginCommand.test.js.map +3 -3
- package/lib/esm/internal/app-binder/command/SignAuthorizationDelegationCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/SignAuthorizationDelegationCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/SignAuthorizationDelegationCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/SignAuthorizationDelegationCommand.test.js.map +3 -3
- package/lib/esm/internal/app-binder/command/SignEIP712Command.js +1 -1
- package/lib/esm/internal/app-binder/command/SignEIP712Command.js.map +2 -2
- package/lib/esm/internal/app-binder/command/SignEIP712Command.test.js +1 -1
- package/lib/esm/internal/app-binder/command/SignEIP712Command.test.js.map +2 -2
- package/lib/esm/internal/app-binder/command/SignPersonalMessageCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/SignPersonalMessageCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/SignPersonalMessageCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/SignPersonalMessageCommand.test.js.map +3 -3
- package/lib/esm/internal/app-binder/command/SignTransactionCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/SignTransactionCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/SignTransactionCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/SignTransactionCommand.test.js.map +3 -3
- package/lib/esm/internal/app-binder/command/StartTransactionCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/StartTransactionCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/StartTransactionCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/StartTransactionCommand.test.js.map +3 -3
- package/lib/esm/internal/app-binder/command/StoreTransactionCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/StoreTransactionCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/StoreTransactionCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/StoreTransactionCommand.test.js.map +3 -3
- package/lib/esm/internal/app-binder/command/Web3CheckOptInCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/Web3CheckOptInCommand.js.map +2 -2
- package/lib/esm/internal/app-binder/command/Web3CheckOptInCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/Web3CheckOptInCommand.test.js.map +3 -3
- package/lib/esm/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.js +1 -1
- package/lib/esm/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.js.map +3 -3
- package/lib/esm/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.test.js +1 -1
- package/lib/esm/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.test.js.map +3 -3
- package/lib/esm/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.js +1 -1
- package/lib/esm/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.js.map +3 -3
- package/lib/esm/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.test.js +1 -1
- package/lib/esm/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.test.js.map +3 -3
- package/lib/esm/internal/app-binder/device-action/VerifySafeAddress/VerifySafeAddress.js +2 -0
- package/lib/esm/internal/app-binder/device-action/VerifySafeAddress/VerifySafeAddress.js.map +7 -0
- package/lib/esm/internal/app-binder/device-action/VerifySafeAddress/VerifySafeAddress.test.js +2 -0
- package/lib/esm/internal/app-binder/device-action/VerifySafeAddress/VerifySafeAddress.test.js.map +7 -0
- package/lib/esm/internal/app-binder/task/BuildBaseContexts.js +1 -1
- package/lib/esm/internal/app-binder/task/BuildBaseContexts.js.map +3 -3
- package/lib/esm/internal/app-binder/task/BuildBaseContexts.test.js +1 -1
- package/lib/esm/internal/app-binder/task/BuildBaseContexts.test.js.map +3 -3
- package/lib/esm/internal/app-binder/task/BuildEIP712ContextTask.js +1 -1
- package/lib/esm/internal/app-binder/task/BuildEIP712ContextTask.js.map +3 -3
- package/lib/esm/internal/app-binder/task/BuildEIP712ContextTask.test.js +1 -1
- package/lib/esm/internal/app-binder/task/BuildEIP712ContextTask.test.js.map +3 -3
- package/lib/esm/internal/app-binder/task/BuildSafeAddressContextTask.js +2 -0
- package/lib/esm/internal/app-binder/task/BuildSafeAddressContextTask.js.map +7 -0
- package/lib/esm/internal/app-binder/task/BuildSafeAddressContextTask.test.js +2 -0
- package/lib/esm/internal/app-binder/task/BuildSafeAddressContextTask.test.js.map +7 -0
- package/lib/esm/internal/app-binder/task/BuildSubcontextsTask.js +1 -1
- package/lib/esm/internal/app-binder/task/BuildSubcontextsTask.js.map +2 -2
- package/lib/esm/internal/app-binder/task/BuildSubcontextsTask.test.js +1 -1
- package/lib/esm/internal/app-binder/task/BuildSubcontextsTask.test.js.map +2 -2
- package/lib/esm/internal/app-binder/task/ProvideContextTask.js +2 -0
- package/lib/esm/internal/app-binder/task/ProvideContextTask.js.map +7 -0
- package/lib/esm/internal/app-binder/task/ProvideContextTask.test.js +2 -0
- package/lib/esm/internal/app-binder/task/ProvideContextTask.test.js.map +7 -0
- package/lib/esm/internal/app-binder/task/ProvideEIP712ContextTask.js +1 -1
- package/lib/esm/internal/app-binder/task/ProvideEIP712ContextTask.js.map +3 -3
- package/lib/esm/internal/app-binder/task/ProvideEIP712ContextTask.test.js +1 -1
- package/lib/esm/internal/app-binder/task/ProvideEIP712ContextTask.test.js.map +3 -3
- package/lib/esm/internal/app-binder/task/ProvideTransactionContextsTask.js +2 -0
- package/lib/esm/internal/app-binder/task/ProvideTransactionContextsTask.js.map +7 -0
- package/lib/esm/internal/app-binder/task/ProvideTransactionContextsTask.test.js +2 -0
- package/lib/esm/internal/app-binder/task/ProvideTransactionContextsTask.test.js.map +7 -0
- package/lib/esm/internal/di.js +1 -1
- package/lib/esm/internal/di.js.map +3 -3
- package/lib/esm/internal/safe/di/safeModule.js +2 -0
- package/lib/esm/internal/safe/di/safeModule.js.map +7 -0
- package/lib/esm/internal/safe/di/safeModule.test.js +2 -0
- package/lib/esm/internal/safe/di/safeModule.test.js.map +7 -0
- package/lib/esm/internal/safe/di/safeTypes.js +2 -0
- package/lib/esm/internal/safe/di/safeTypes.js.map +7 -0
- package/lib/esm/internal/safe/use-case/VerifySafeAddressUseCase.js +2 -0
- package/lib/esm/internal/safe/use-case/VerifySafeAddressUseCase.js.map +7 -0
- package/lib/esm/internal/safe/use-case/VerifySafeAddressUseCase.test.js +2 -0
- package/lib/esm/internal/safe/use-case/VerifySafeAddressUseCase.test.js.map +7 -0
- package/lib/esm/package.json +41 -37
- package/lib/types/api/SignerEth.d.ts +3 -0
- package/lib/types/api/SignerEth.d.ts.map +1 -1
- package/lib/types/api/app-binder/SignTransactionDeviceActionTypes.d.ts +1 -0
- package/lib/types/api/app-binder/SignTransactionDeviceActionTypes.d.ts.map +1 -1
- package/lib/types/api/app-binder/SignTypedDataDeviceActionTypes.d.ts +2 -0
- package/lib/types/api/app-binder/SignTypedDataDeviceActionTypes.d.ts.map +1 -1
- package/lib/types/api/app-binder/VerifySafeAddressDeviceActionTypes.d.ts +30 -0
- package/lib/types/api/app-binder/VerifySafeAddressDeviceActionTypes.d.ts.map +1 -0
- package/lib/types/api/model/SafeAddressOptions.d.ts +5 -0
- package/lib/types/api/model/SafeAddressOptions.d.ts.map +1 -0
- package/lib/types/internal/DefaultSignerEth.d.ts +3 -0
- package/lib/types/internal/DefaultSignerEth.d.ts.map +1 -1
- package/lib/types/internal/app-binder/EthAppBinder.d.ts +6 -0
- package/lib/types/internal/app-binder/EthAppBinder.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/GetAddressCommand.d.ts +1 -0
- package/lib/types/internal/app-binder/command/GetAddressCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/GetAppConfigurationCommand.d.ts +1 -0
- package/lib/types/internal/app-binder/command/GetAppConfigurationCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/GetChallengeCommand.d.ts +1 -0
- package/lib/types/internal/app-binder/command/GetChallengeCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/ProvideEnumCommand.d.ts +1 -0
- package/lib/types/internal/app-binder/command/ProvideEnumCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/ProvideNFTInformationCommand.d.ts +1 -0
- package/lib/types/internal/app-binder/command/ProvideNFTInformationCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/ProvideNetworkConfigurationCommand.d.ts +1 -0
- package/lib/types/internal/app-binder/command/ProvideNetworkConfigurationCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/ProvideProxyInfoCommand.d.ts +1 -0
- package/lib/types/internal/app-binder/command/ProvideProxyInfoCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/ProvideSafeAccountCommand.d.ts +35 -0
- package/lib/types/internal/app-binder/command/ProvideSafeAccountCommand.d.ts.map +1 -0
- package/lib/types/internal/app-binder/command/ProvideSafeAccountCommand.test.d.ts +2 -0
- package/lib/types/internal/app-binder/command/ProvideSafeAccountCommand.test.d.ts.map +1 -0
- package/lib/types/internal/app-binder/command/ProvideTokenInformationCommand.d.ts +1 -0
- package/lib/types/internal/app-binder/command/ProvideTokenInformationCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/ProvideTransactionFieldDescriptionCommand.d.ts +1 -0
- package/lib/types/internal/app-binder/command/ProvideTransactionFieldDescriptionCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/ProvideTransactionInformationCommand.d.ts +1 -0
- package/lib/types/internal/app-binder/command/ProvideTransactionInformationCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/ProvideTrustedNameCommand.d.ts +1 -0
- package/lib/types/internal/app-binder/command/ProvideTrustedNameCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/ProvideWeb3CheckCommand.d.ts +1 -0
- package/lib/types/internal/app-binder/command/ProvideWeb3CheckCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/SendEIP712FilteringCommand.d.ts +1 -0
- package/lib/types/internal/app-binder/command/SendEIP712FilteringCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/SendEIP712StructDefinitionCommand.d.ts +1 -0
- package/lib/types/internal/app-binder/command/SendEIP712StructDefinitionCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/SendEIP712StructImplemCommand.d.ts +1 -0
- package/lib/types/internal/app-binder/command/SendEIP712StructImplemCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/SetExternalPluginCommand.d.ts +1 -0
- package/lib/types/internal/app-binder/command/SetExternalPluginCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/SetPluginCommand.d.ts +1 -0
- package/lib/types/internal/app-binder/command/SetPluginCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/SignAuthorizationDelegationCommand.d.ts +1 -0
- package/lib/types/internal/app-binder/command/SignAuthorizationDelegationCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/SignEIP712Command.d.ts +1 -0
- package/lib/types/internal/app-binder/command/SignEIP712Command.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/SignPersonalMessageCommand.d.ts +1 -0
- package/lib/types/internal/app-binder/command/SignPersonalMessageCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/SignTransactionCommand.d.ts +1 -0
- package/lib/types/internal/app-binder/command/SignTransactionCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/StartTransactionCommand.d.ts +1 -0
- package/lib/types/internal/app-binder/command/StartTransactionCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/StoreTransactionCommand.d.ts +1 -0
- package/lib/types/internal/app-binder/command/StoreTransactionCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/Web3CheckOptInCommand.d.ts +1 -0
- package/lib/types/internal/app-binder/command/Web3CheckOptInCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.d.ts +7 -3
- package/lib/types/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.d.ts.map +1 -1
- package/lib/types/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.d.ts +5 -0
- package/lib/types/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.d.ts.map +1 -1
- package/lib/types/internal/app-binder/device-action/VerifySafeAddress/VerifySafeAddress.d.ts +20 -0
- package/lib/types/internal/app-binder/device-action/VerifySafeAddress/VerifySafeAddress.d.ts.map +1 -0
- package/lib/types/internal/app-binder/device-action/VerifySafeAddress/VerifySafeAddress.test.d.ts +2 -0
- package/lib/types/internal/app-binder/device-action/VerifySafeAddress/VerifySafeAddress.test.d.ts.map +1 -0
- package/lib/types/internal/app-binder/task/BuildBaseContexts.d.ts +4 -6
- package/lib/types/internal/app-binder/task/BuildBaseContexts.d.ts.map +1 -1
- package/lib/types/internal/app-binder/task/BuildEIP712ContextTask.d.ts +3 -3
- package/lib/types/internal/app-binder/task/BuildEIP712ContextTask.d.ts.map +1 -1
- package/lib/types/internal/app-binder/task/BuildSafeAddressContextTask.d.ts +19 -0
- package/lib/types/internal/app-binder/task/BuildSafeAddressContextTask.d.ts.map +1 -0
- package/lib/types/internal/app-binder/task/BuildSafeAddressContextTask.test.d.ts +2 -0
- package/lib/types/internal/app-binder/task/BuildSafeAddressContextTask.test.d.ts.map +1 -0
- package/lib/types/internal/app-binder/task/BuildSubcontextsTask.d.ts.map +1 -1
- package/lib/types/internal/app-binder/task/ProvideContextTask.d.ts +22 -0
- package/lib/types/internal/app-binder/task/ProvideContextTask.d.ts.map +1 -0
- package/lib/types/internal/app-binder/task/ProvideContextTask.test.d.ts +2 -0
- package/lib/types/internal/app-binder/task/ProvideContextTask.test.d.ts.map +1 -0
- package/lib/types/internal/app-binder/task/ProvideEIP712ContextTask.d.ts +6 -5
- package/lib/types/internal/app-binder/task/ProvideEIP712ContextTask.d.ts.map +1 -1
- package/lib/types/internal/app-binder/task/ProvideTransactionContextsTask.d.ts +36 -0
- package/lib/types/internal/app-binder/task/ProvideTransactionContextsTask.d.ts.map +1 -0
- package/lib/types/internal/app-binder/task/ProvideTransactionContextsTask.test.d.ts +2 -0
- package/lib/types/internal/app-binder/task/ProvideTransactionContextsTask.test.d.ts.map +1 -0
- package/lib/types/internal/di.d.ts.map +1 -1
- package/lib/types/internal/safe/di/safeModule.d.ts +3 -0
- package/lib/types/internal/safe/di/safeModule.d.ts.map +1 -0
- package/lib/types/internal/safe/di/safeModule.test.d.ts +2 -0
- package/lib/types/internal/safe/di/safeModule.test.d.ts.map +1 -0
- package/lib/types/internal/safe/di/safeTypes.d.ts +4 -0
- package/lib/types/internal/safe/di/safeTypes.d.ts.map +1 -0
- package/lib/types/internal/safe/use-case/VerifySafeAddressUseCase.d.ts +9 -0
- package/lib/types/internal/safe/use-case/VerifySafeAddressUseCase.d.ts.map +1 -0
- package/lib/types/internal/safe/use-case/VerifySafeAddressUseCase.test.d.ts +2 -0
- package/lib/types/internal/safe/use-case/VerifySafeAddressUseCase.test.d.ts.map +1 -0
- package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
- package/package.json +33 -29
- package/lib/cjs/internal/app-binder/task/GetWeb3CheckTask.js +0 -2
- package/lib/cjs/internal/app-binder/task/GetWeb3CheckTask.js.map +0 -7
- package/lib/cjs/internal/app-binder/task/GetWeb3CheckTask.test.js +0 -2
- package/lib/cjs/internal/app-binder/task/GetWeb3CheckTask.test.js.map +0 -7
- package/lib/cjs/internal/app-binder/task/ProvideContextsTask.js +0 -2
- package/lib/cjs/internal/app-binder/task/ProvideContextsTask.js.map +0 -7
- package/lib/cjs/internal/app-binder/task/ProvideContextsTask.test.js +0 -2
- package/lib/cjs/internal/app-binder/task/ProvideContextsTask.test.js.map +0 -7
- package/lib/esm/internal/app-binder/task/GetWeb3CheckTask.js +0 -2
- package/lib/esm/internal/app-binder/task/GetWeb3CheckTask.js.map +0 -7
- package/lib/esm/internal/app-binder/task/GetWeb3CheckTask.test.js +0 -2
- package/lib/esm/internal/app-binder/task/GetWeb3CheckTask.test.js.map +0 -7
- package/lib/esm/internal/app-binder/task/ProvideContextsTask.js +0 -2
- package/lib/esm/internal/app-binder/task/ProvideContextsTask.js.map +0 -7
- package/lib/esm/internal/app-binder/task/ProvideContextsTask.test.js +0 -2
- package/lib/esm/internal/app-binder/task/ProvideContextsTask.test.js.map +0 -7
- package/lib/types/internal/app-binder/task/GetWeb3CheckTask.d.ts +0 -29
- package/lib/types/internal/app-binder/task/GetWeb3CheckTask.d.ts.map +0 -1
- package/lib/types/internal/app-binder/task/GetWeb3CheckTask.test.d.ts +0 -2
- package/lib/types/internal/app-binder/task/GetWeb3CheckTask.test.d.ts.map +0 -1
- package/lib/types/internal/app-binder/task/ProvideContextsTask.d.ts +0 -44
- package/lib/types/internal/app-binder/task/ProvideContextsTask.d.ts.map +0 -1
- package/lib/types/internal/app-binder/task/ProvideContextsTask.test.d.ts +0 -2
- package/lib/types/internal/app-binder/task/ProvideContextsTask.test.d.ts.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/app-binder/task/BuildBaseContexts.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n type ClearSignContext,\n type ClearSignContextSuccess,\n ClearSignContextType,\n type ContextModule,\n type TransactionSubset,\n} from \"@ledgerhq/context-module\";\nimport {\n DeviceModelId,\n type DeviceSessionState,\n type InternalApi,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { type GetConfigCommandResponse } from \"@api/app-binder/GetConfigCommandTypes\";\nimport { ClearSigningType } from \"@api/model/ClearSigningType\";\nimport { type TransactionOptions } from \"@api/model/TransactionOptions\";\nimport { GetChallengeCommand } from \"@internal/app-binder/command/GetChallengeCommand\";\nimport {
|
|
5
|
-
"mappings": "AAAA,OAGE,wBAAAA,MAGK,2BACP,OACE,iBAAAC,EAGA,0BAAAC,MACK,kCAGP,OAAS,oBAAAC,MAAwB,8BAEjC,OAAS,uBAAAC,MAA2B,mDACpC,
|
|
6
|
-
"names": ["ClearSignContextType", "DeviceModelId", "isSuccessCommandResult", "ClearSigningType", "GetChallengeCommand", "
|
|
4
|
+
"sourcesContent": ["import {\n type ClearSignContext,\n type ClearSignContextSuccess,\n ClearSignContextType,\n type ContextModule,\n type TransactionSubset,\n} from \"@ledgerhq/context-module\";\nimport {\n DeviceModelId,\n type DeviceSessionState,\n type InternalApi,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { type GetConfigCommandResponse } from \"@api/app-binder/GetConfigCommandTypes\";\nimport { ClearSigningType } from \"@api/model/ClearSigningType\";\nimport { type TransactionOptions } from \"@api/model/TransactionOptions\";\nimport { GetChallengeCommand } from \"@internal/app-binder/command/GetChallengeCommand\";\nimport { ApplicationChecker } from \"@internal/shared/utils/ApplicationChecker\";\n\nexport const NESTED_CALLDATA_CONTEXT_TYPES_FILTER: ClearSignContextType[] = [\n ClearSignContextType.TRANSACTION_INFO,\n ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n ClearSignContextType.ENUM,\n ClearSignContextType.PROXY_INFO,\n];\n\nexport const BASE_CONTEXT_TYPES_FILTER: ClearSignContextType[] = [\n ClearSignContextType.TRANSACTION_INFO,\n ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n ClearSignContextType.PROXY_INFO,\n ClearSignContextType.TRANSACTION_CHECK,\n ClearSignContextType.DYNAMIC_NETWORK,\n ClearSignContextType.DYNAMIC_NETWORK_ICON,\n ClearSignContextType.ENUM,\n ClearSignContextType.TRUSTED_NAME,\n ClearSignContextType.TOKEN,\n ClearSignContextType.NFT,\n ClearSignContextType.PLUGIN,\n ClearSignContextType.EXTERNAL_PLUGIN,\n];\n\nexport type BuildBaseContextsResult = {\n readonly clearSignContexts: ClearSignContextSuccess[];\n readonly clearSignContextsOptional: ClearSignContextSuccess[];\n readonly clearSigningType: ClearSigningType;\n};\n\nexport type BuildBaseContextsArgs = {\n readonly contextModule: ContextModule;\n readonly options: TransactionOptions;\n readonly appConfig: GetConfigCommandResponse;\n readonly subset: TransactionSubset;\n readonly transaction?: Uint8Array;\n};\n\n/**\n * Builds the base contexts for a transaction\n * @param api - The internal API\n * @param args - The arguments for the build\n *\n * returns the base contexts for a transaction, without subcontexts or nested call data contexts\n */\nexport class BuildBaseContexts {\n constructor(\n private readonly _api: InternalApi,\n private readonly _args: BuildBaseContextsArgs,\n ) {}\n\n async run(): Promise<BuildBaseContextsResult> {\n const { contextModule, options, appConfig, transaction, subset } =\n this._args;\n const isNestedCallData = transaction === undefined;\n // As only transaction checks needs the transaction, we don't need to send it if it's not needed\n const needTransaction = !isNestedCallData && appConfig.web3ChecksEnabled;\n\n const deviceState = this._api.getDeviceSessionState();\n\n // Get challenge (not supported on Nano S)\n let challenge: string | undefined = undefined;\n if (deviceState.deviceModelId !== DeviceModelId.NANO_S) {\n const challengeRes = await this._api.sendCommand(\n new GetChallengeCommand(),\n );\n if (isSuccessCommandResult(challengeRes)) {\n challenge = challengeRes.data.challenge;\n }\n }\n\n // Get the clear sign contexts\n const clearSignContexts: ClearSignContext[] =\n await contextModule.getContexts(\n {\n challenge: challenge,\n domain: options.domain,\n deviceModelId: deviceState.deviceModelId,\n transaction: needTransaction ? transaction : undefined,\n ...subset,\n },\n isNestedCallData\n ? NESTED_CALLDATA_CONTEXT_TYPES_FILTER\n : BASE_CONTEXT_TYPES_FILTER,\n );\n\n // filter out the error contexts\n const contextsSuccess: ClearSignContextSuccess[] = clearSignContexts.filter(\n (context) => context.type !== ClearSignContextType.ERROR,\n );\n\n if (\n this._supportsGenericParser(deviceState, appConfig) &&\n this._hasValidTransactionInfo(contextsSuccess)\n ) {\n return this._getERC7730Contexts(contextsSuccess);\n } else {\n return this._getBasicContexts(contextsSuccess);\n }\n }\n\n private _getERC7730Contexts(\n contexts: ClearSignContextSuccess[],\n ): BuildBaseContextsResult {\n const clearSignContexts: ClearSignContextSuccess[] = contexts\n .filter((context) => this._isContextNeededForERC7730ClearSigning(context))\n .sort(\n (a, b) => this._getContextPriority(a) - this._getContextPriority(b),\n );\n\n const clearSignContextsOptional: ClearSignContextSuccess[] =\n contexts.filter((context) => context.type === ClearSignContextType.ENUM);\n\n return {\n clearSignContexts,\n clearSignContextsOptional,\n clearSigningType: ClearSigningType.EIP7730,\n };\n }\n\n private _getBasicContexts(\n contexts: ClearSignContextSuccess[],\n ): BuildBaseContextsResult {\n const clearSignContexts: ClearSignContextSuccess[] = contexts\n .filter((context) => this._isContextNeededForBasicClearSigning(context))\n .sort(\n (a, b) => this._getContextPriority(a) - this._getContextPriority(b),\n );\n\n return {\n clearSignContexts,\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n };\n }\n\n private _isContextNeededForBasicClearSigning({\n type,\n }: ClearSignContextSuccess): boolean {\n switch (type) {\n case ClearSignContextType.TRANSACTION_CHECK:\n case ClearSignContextType.PLUGIN:\n case ClearSignContextType.EXTERNAL_PLUGIN:\n case ClearSignContextType.DYNAMIC_NETWORK:\n case ClearSignContextType.DYNAMIC_NETWORK_ICON:\n case ClearSignContextType.TRUSTED_NAME:\n case ClearSignContextType.TOKEN:\n case ClearSignContextType.NFT:\n return true;\n case ClearSignContextType.TRANSACTION_INFO:\n case ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION:\n case ClearSignContextType.ENUM:\n case ClearSignContextType.PROXY_INFO:\n case ClearSignContextType.SAFE:\n case ClearSignContextType.SIGNER:\n return false;\n default: {\n const uncoveredType: never = type;\n throw new Error(`Unhandled context type ${String(uncoveredType)}`);\n }\n }\n }\n\n private _isContextNeededForERC7730ClearSigning({\n type,\n }: ClearSignContextSuccess): boolean {\n switch (type) {\n case ClearSignContextType.TRANSACTION_INFO:\n case ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION:\n case ClearSignContextType.PROXY_INFO:\n case ClearSignContextType.DYNAMIC_NETWORK:\n case ClearSignContextType.DYNAMIC_NETWORK_ICON:\n case ClearSignContextType.TRANSACTION_CHECK:\n return true;\n case ClearSignContextType.ENUM: // enum is needed but as optional\n case ClearSignContextType.TRUSTED_NAME:\n case ClearSignContextType.TOKEN:\n case ClearSignContextType.NFT:\n case ClearSignContextType.PLUGIN:\n case ClearSignContextType.EXTERNAL_PLUGIN:\n case ClearSignContextType.SAFE:\n case ClearSignContextType.SIGNER:\n return false;\n default: {\n const uncoveredType: never = type;\n throw new Error(`Unhandled context type ${String(uncoveredType)}`);\n }\n }\n }\n\n private _hasValidTransactionInfo(\n contexts: ClearSignContextSuccess[],\n ): boolean {\n return (\n contexts.find(\n (context) => context.type === ClearSignContextType.TRANSACTION_INFO,\n )?.certificate !== undefined\n );\n }\n\n private _supportsGenericParser(\n deviceState: DeviceSessionState,\n appConfig: GetConfigCommandResponse,\n ): boolean {\n return new ApplicationChecker(deviceState, appConfig)\n .withMinVersionExclusive(\"1.14.0\")\n .excludeDeviceModel(DeviceModelId.NANO_S)\n .check();\n }\n\n /**\n * Determines the processing priority of a clear sign context.\n * Lower numbers indicate higher priority (processed first).\n *\n * @param context The clear sign context to get priority for\n * @returns Priority number (lower = higher priority)\n */\n private _getContextPriority({ type }: ClearSignContextSuccess): number {\n switch (type) {\n case ClearSignContextType.TRANSACTION_CHECK:\n return 10;\n case ClearSignContextType.DYNAMIC_NETWORK:\n case ClearSignContextType.DYNAMIC_NETWORK_ICON:\n case ClearSignContextType.PROXY_INFO:\n return 30;\n case ClearSignContextType.TRANSACTION_INFO:\n return 50;\n case ClearSignContextType.PLUGIN:\n case ClearSignContextType.EXTERNAL_PLUGIN:\n case ClearSignContextType.TOKEN:\n case ClearSignContextType.NFT:\n case ClearSignContextType.TRUSTED_NAME:\n case ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION:\n case ClearSignContextType.ENUM:\n return 70;\n\n /* not used here */\n case ClearSignContextType.SAFE:\n case ClearSignContextType.SIGNER:\n return 90;\n\n default: {\n const uncoveredType: never = type;\n throw new Error(\n `Unhandled context type for priority: ${String(uncoveredType)}`,\n );\n }\n }\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAGE,wBAAAA,MAGK,2BACP,OACE,iBAAAC,EAGA,0BAAAC,MACK,kCAGP,OAAS,oBAAAC,MAAwB,8BAEjC,OAAS,uBAAAC,MAA2B,mDACpC,OAAS,sBAAAC,MAA0B,4CAE5B,MAAMC,EAA+D,CAC1EN,EAAqB,iBACrBA,EAAqB,8BACrBA,EAAqB,KACrBA,EAAqB,UACvB,EAEaO,EAAoD,CAC/DP,EAAqB,iBACrBA,EAAqB,8BACrBA,EAAqB,WACrBA,EAAqB,kBACrBA,EAAqB,gBACrBA,EAAqB,qBACrBA,EAAqB,KACrBA,EAAqB,aACrBA,EAAqB,MACrBA,EAAqB,IACrBA,EAAqB,OACrBA,EAAqB,eACvB,EAuBO,MAAMQ,CAAkB,CAC7B,YACmBC,EACAC,EACjB,CAFiB,UAAAD,EACA,WAAAC,CAChB,CAEH,MAAM,KAAwC,CAC5C,KAAM,CAAE,cAAAC,EAAe,QAAAC,EAAS,UAAAC,EAAW,YAAAC,EAAa,OAAAC,CAAO,EAC7D,KAAK,MACDC,EAAmBF,IAAgB,OAEnCG,EAAkB,CAACD,GAAoB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,KAAKA,EAAqB,qBAC1B,KAAKA,EAAqB,WACxB,MAAO,IACT,KAAKA,EAAqB,iBACxB,MAAO,IACT,KAAKA,EAAqB,OAC1B,KAAKA,EAAqB,gBAC1B,KAAKA,EAAqB,MAC1B,KAAKA,EAAqB,IAC1B,KAAKA,EAAqB,aAC1B,KAAKA,EAAqB,8BAC1B,KAAKA,EAAqB,KACxB,MAAO,IAGT,KAAKA,EAAqB,KAC1B,KAAKA,EAAqB,OACxB,MAAO,IAET,QAAS,CACP,MAAM6B,EAAuBD,EAC7B,MAAM,IAAI,MACR,wCAAwC,OAAOC,CAAa,CAAC,EAC/D,CACF,CACF,CACF,CACF",
|
|
6
|
+
"names": ["ClearSignContextType", "DeviceModelId", "isSuccessCommandResult", "ClearSigningType", "GetChallengeCommand", "ApplicationChecker", "NESTED_CALLDATA_CONTEXT_TYPES_FILTER", "BASE_CONTEXT_TYPES_FILTER", "BuildBaseContexts", "_api", "_args", "contextModule", "options", "appConfig", "transaction", "subset", "isNestedCallData", "needTransaction", "deviceState", "challenge", "challengeRes", "contextsSuccess", "context", "contexts", "clearSignContexts", "a", "b", "clearSignContextsOptional", "type", "uncoveredType"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ClearSignContextType as t}from"@ledgerhq/context-module";import{CommandResultFactory as g,DeviceModelId as l,DeviceSessionStateType as r,DeviceStatus as d,hexaStringToBuffer as h,UnknownDeviceExchangeError as m}from"@ledgerhq/device-management-kit";import{Transaction as O}from"ethers";import{ClearSigningType as u}from"../../../api/model/ClearSigningType";import{makeDeviceActionInternalApiMock as v}from"../../app-binder/device-action/__test-utils__/makeInternalApi";import{BuildBaseContexts as s}from"./BuildBaseContexts";import{GetWeb3CheckTask as N}from"./GetWeb3CheckTask";describe("BuildBaseContexts",()=>{const i={getFieldContext:vi.fn(),getContexts:vi.fn(),getTypedDataFilters:vi.fn(),getWeb3Checks:vi.fn(),getSolanaContext:vi.fn()},x={domain:"domain-name.eth"},y=h(O.from({chainId:1n,nonce:0,data:"0x"}).unsignedSerialized),p={keyUsageNumber:1,payload:new Uint8Array([1,2,3])};let o;const n=v(),c=vi.fn();function S(e){return{blindSigningEnabled:!1,web3ChecksEnabled:e,web3ChecksOptIn:!1,version:"1.13.0"}}beforeEach(()=>{vi.resetAllMocks(),n.sendCommand.mockResolvedValue(g({data:{challenge:"challenge"}})),c.mockReturnValue({run:async()=>Promise.resolve({web3Check:null})}),o={contextModule:i,subset:{chainId:1,to:void 0,data:"0x",selector:"0x"},transaction:y,options:x,appConfig:S(!1),derivationPath:"44'/60'/0'/0/0"}}),it("should init with a default GetWeb3CheckTaskFactory",()=>{const e=new s(n,o);expect(e.getWeb3ChecksFactory).toBeDefined(),expect(e.getWeb3ChecksFactory(n,{contextModule:o.contextModule,derivationPath:o.derivationPath,subset:o.subset,transaction:o.transaction})).toBeInstanceOf(N)}),it("should build the transaction context without clear sign contexts",async()=>{const e=[],a=[];i.getContexts.mockResolvedValueOnce(e),n.getDeviceSessionState.mockReturnValueOnce({sessionStateType:r.ReadyWithoutSecureChannel,deviceStatus:d.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:l.FLEX,isSecureConnectionAllowed:!1});const C=await new s(n,{...o,appConfig:S(!0)},c).run();expect(C).toEqual({clearSignContexts:e,clearSignContextsOptional:a,clearSigningType:u.BASIC})}),it("should build the transaction context with web3checks",async()=>{const e=[],a=[],C={type:t.WEB3_CHECK,payload:"web3Check"};c.mockReturnValueOnce({run:async()=>Promise.resolve({web3Check:C})}),i.getContexts.mockResolvedValueOnce([...e]),n.getDeviceSessionState.mockReturnValueOnce({sessionStateType:r.ReadyWithoutSecureChannel,deviceStatus:d.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:l.FLEX,isSecureConnectionAllowed:!1});const E=await new s(n,{...o,appConfig:S(!0)},c).run();expect(E).toEqual({clearSignContexts:[C,...e],clearSignContextsOptional:a,clearSigningType:u.BASIC})}),it("should build the transaction context with web3checks and generic-parser clear sign contexts",async()=>{const e=[{type:t.TRANSACTION_INFO,payload:"payload-1",certificate:p},{type:t.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-2"},{type:t.ENUM,payload:"payload-3",id:1,value:2,certificate:p},{type:t.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-4"}],a={type:t.WEB3_CHECK,payload:"web3Check"};c.mockReturnValueOnce({run:async()=>Promise.resolve({web3Check:a})}),i.getContexts.mockResolvedValueOnce([...e]),n.getDeviceSessionState.mockReturnValueOnce({sessionStateType:r.ReadyWithoutSecureChannel,deviceStatus:d.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.15.0"},deviceModelId:l.FLEX,isSecureConnectionAllowed:!1});const C=await new s(n,{...o,appConfig:S(!0)},c).run();expect(C).toEqual({clearSignContexts:[a,e[0],e[1],e[3]],clearSignContextsOptional:[e[2]],clearSigningType:u.EIP7730})}),it("should build the transaction context with web3checks and generic-parser clear sign contexts in the correct order",async()=>{const e=[{type:t.ENUM,payload:"payload-3",id:1,value:2,certificate:p},{type:t.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-4"},{type:t.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-2"},{type:t.TRANSACTION_INFO,payload:"payload-1",certificate:p}],a={type:t.WEB3_CHECK,payload:"web3Check"};c.mockReturnValueOnce({run:async()=>Promise.resolve({web3Check:a})}),i.getContexts.mockResolvedValueOnce([...e]),n.getDeviceSessionState.mockReturnValueOnce({sessionStateType:r.ReadyWithoutSecureChannel,deviceStatus:d.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.15.0"},deviceModelId:l.FLEX,isSecureConnectionAllowed:!1});const C=await new s(n,{...o,appConfig:S(!0)},c).run();expect(C).toEqual({clearSignContexts:[a,e[3],e[1],e[2]],clearSignContextsOptional:[e[0]],clearSigningType:u.EIP7730})}),it("should build the transaction context with clear sign contexts",async()=>{const e=[{type:t.TOKEN,payload:"payload-1"},{type:t.NFT,payload:"payload-2"}],a={type:t.WEB3_CHECK,payload:"web3Check"};c.mockReturnValueOnce({run:async()=>Promise.resolve({web3Check:a})}),i.getContexts.mockResolvedValueOnce(e),n.getDeviceSessionState.mockReturnValueOnce({sessionStateType:r.ReadyWithoutSecureChannel,deviceStatus:d.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:l.FLEX,isSecureConnectionAllowed:!1});const C=await new s(n,o,c).run();expect(C).toEqual({clearSignContexts:e,clearSignContextsOptional:[],clearSigningType:u.BASIC})}),it("should build the transaction context with generic-parser context",async()=>{const e=[{type:t.TRANSACTION_INFO,payload:"payload-1",certificate:p},{type:t.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-2"},{type:t.ENUM,payload:"payload-3",id:1,value:2,certificate:p},{type:t.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-4"}];i.getContexts.mockResolvedValueOnce(e),n.getDeviceSessionState.mockReturnValueOnce({sessionStateType:r.ReadyWithoutSecureChannel,deviceStatus:d.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.15.0"},deviceModelId:l.FLEX,isSecureConnectionAllowed:!1});const a=await new s(n,o,c).run();expect(a).toEqual({clearSignContexts:[e[0],e[1],e[3]],clearSignContextsOptional:[e[2]],clearSigningType:u.EIP7730})}),it("should build the transaction context with proxy delegate call context",async()=>{const e=[{type:t.TRANSACTION_INFO,payload:"payload-1",certificate:p},{type:t.PROXY_INFO,payload:"payload-2"}],a=[];i.getContexts.mockResolvedValueOnce(e),n.getDeviceSessionState.mockReturnValueOnce({sessionStateType:r.ReadyWithoutSecureChannel,deviceStatus:d.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.15.0"},deviceModelId:l.FLEX,isSecureConnectionAllowed:!1});const C=await new s(n,o,c).run();expect(C).toEqual({clearSignContexts:[e[1],e[0]],clearSignContextsOptional:a,clearSigningType:u.EIP7730})}),it("should call the web3checks factory with correct parameters",async()=>{const e=[];i.getContexts.mockResolvedValueOnce(e),n.getDeviceSessionState.mockReturnValueOnce({sessionStateType:r.ReadyWithoutSecureChannel,deviceStatus:d.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:l.FLEX,isSecureConnectionAllowed:!1}),await new s(n,{...o,appConfig:S(!0)},c).run(),expect(c).toHaveBeenCalledWith(n,{contextModule:i,derivationPath:"44'/60'/0'/0/0",subset:o.subset,transaction:y})}),it("should call the context module with the correct parameters",async()=>{const e=[];i.getContexts.mockResolvedValueOnce(e),n.getDeviceSessionState.mockReturnValueOnce({sessionStateType:r.ReadyWithoutSecureChannel,deviceStatus:d.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:l.FLEX,isSecureConnectionAllowed:!1}),await new s(n,o,c).run(),expect(i.getContexts).toHaveBeenCalledWith({deviceModelId:l.FLEX,challenge:"challenge",domain:"domain-name.eth",...o.subset},void 0)}),it("should call the context module without challenge for Nano S",async()=>{const e=[];i.getContexts.mockResolvedValueOnce(e),n.getDeviceSessionState.mockReturnValueOnce({sessionStateType:r.ReadyWithoutSecureChannel,deviceStatus:d.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:l.NANO_S,isSecureConnectionAllowed:!1}),await new s(n,o,c).run(),expect(i.getContexts).toHaveBeenCalledWith({deviceModelId:l.NANO_S,domain:"domain-name.eth",...o.subset},void 0)}),it("should call the context module without context on error",async()=>{const e=[];i.getContexts.mockResolvedValueOnce(e),n.getDeviceSessionState.mockReturnValueOnce({sessionStateType:r.ReadyWithoutSecureChannel,deviceStatus:d.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:l.FLEX,isSecureConnectionAllowed:!1}),n.sendCommand.mockResolvedValueOnce(g({error:new m})),await new s(n,o,c).run(),expect(i.getContexts).toHaveBeenCalledWith({deviceModelId:l.FLEX,challenge:void 0,domain:"domain-name.eth",...o.subset},void 0)}),it("should exclude error contexts from the result",async()=>{const e=[{type:t.ERROR,error:new Error("error")},{type:t.TOKEN,payload:"payload-1"},{type:t.ERROR,error:new Error("error")},{type:t.NFT,payload:"payload-2"}];i.getContexts.mockResolvedValueOnce(e),n.getDeviceSessionState.mockReturnValueOnce({sessionStateType:r.ReadyWithoutSecureChannel,deviceStatus:d.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:l.FLEX,isSecureConnectionAllowed:!1});const a=await new s(n,o,c).run();expect(a).toEqual({clearSignContexts:[e[1],e[3]],clearSignContextsOptional:[],clearSigningType:u.BASIC})}),it("should exclude generic-parser contexts from the result on old apps",async()=>{const e=[{type:t.TRANSACTION_INFO,payload:"transaction_info",certificate:p},{type:t.TOKEN,payload:"payload-1"},{type:t.TRANSACTION_FIELD_DESCRIPTION,payload:"transaction_field"},{type:t.NFT,payload:"payload-2"},{type:t.ENUM,payload:"enum",id:1,value:2,certificate:p}];i.getContexts.mockResolvedValueOnce(e),n.getDeviceSessionState.mockReturnValueOnce({sessionStateType:r.ReadyWithoutSecureChannel,deviceStatus:d.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:l.FLEX,isSecureConnectionAllowed:!1});const a=await new s(n,o,c).run();expect(a).toEqual({clearSignContexts:[e[1],e[3]],clearSignContextsOptional:[],clearSigningType:u.BASIC})}),it("should exclude generic-parser contexts from the result if no transaction_info was found",async()=>{const e=[{type:t.TRANSACTION_FIELD_DESCRIPTION,payload:"transaction_field"},{type:t.TOKEN,payload:"payload-1"},{type:t.ENUM,payload:"enum",id:1,value:2},{type:t.NFT,payload:"payload-2"}];i.getContexts.mockResolvedValueOnce(e),n.getDeviceSessionState.mockReturnValueOnce({sessionStateType:r.ReadyWithoutSecureChannel,deviceStatus:d.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.14.0"},deviceModelId:l.FLEX,isSecureConnectionAllowed:!1});const a=await new s(n,o,c).run();expect(a).toEqual({clearSignContexts:[e[1],e[3]],clearSignContextsOptional:[],clearSigningType:u.BASIC})}),it("should exclude legacy contexts from the result for generic-parser transactions",async()=>{const e=[{type:t.TOKEN,payload:"payload-1"},{type:t.TRANSACTION_INFO,payload:"payload-2",certificate:p},{type:t.EXTERNAL_PLUGIN,payload:"payload-3"},{type:t.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-4"},{type:t.ENUM,payload:"payload-5",id:1,value:2,certificate:p}];i.getContexts.mockResolvedValueOnce(e),n.getDeviceSessionState.mockReturnValueOnce({sessionStateType:r.ReadyWithoutSecureChannel,deviceStatus:d.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.15.0"},deviceModelId:l.FLEX,isSecureConnectionAllowed:!1});const a=await new s(n,o,c).run();expect(a).toEqual({clearSignContexts:[e[1],e[3]],clearSignContextsOptional:[e[4]],clearSigningType:u.EIP7730})}),it("should exclude generic-parser contexts with a nano s device",async()=>{const e=[{type:t.TOKEN,payload:"payload-1"},{type:t.TRANSACTION_INFO,payload:"payload-2",certificate:p},{type:t.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-3"},{type:t.ENUM,payload:"payload-4",id:1,value:2,certificate:p}];i.getContexts.mockResolvedValueOnce(e),n.getDeviceSessionState.mockReturnValueOnce({sessionStateType:r.ReadyWithoutSecureChannel,deviceStatus:d.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.14.0"},deviceModelId:l.NANO_S,isSecureConnectionAllowed:!1});const a=await new s(n,o,c).run();expect(a).toEqual({clearSignContexts:[e[0]],clearSignContextsOptional:[],clearSigningType:u.BASIC})}),it("should exclude generic-parser contexts with an old app version",async()=>{const e=[{type:t.TOKEN,payload:"payload-1"},{type:t.TRANSACTION_INFO,payload:"payload-2",certificate:p},{type:t.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-3"},{type:t.ENUM,payload:"payload-4",id:1,value:2,certificate:p}];i.getContexts.mockResolvedValueOnce(e),n.getDeviceSessionState.mockReturnValueOnce({sessionStateType:r.ReadyWithoutSecureChannel,deviceStatus:d.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:l.FLEX,isSecureConnectionAllowed:!1});const a=await new s(n,o,c).run();expect(a).toEqual({clearSignContexts:[e[0]],clearSignContextsOptional:[],clearSigningType:u.BASIC})}),it("should exclude generic-parser contexts with a non ready device",async()=>{const e=[{type:t.TOKEN,payload:"payload-1"},{type:t.TRANSACTION_INFO,payload:"payload-2",certificate:p},{type:t.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-3"},{type:t.ENUM,payload:"payload-4",id:1,value:2,certificate:p}];i.getContexts.mockResolvedValueOnce(e),n.getDeviceSessionState.mockReturnValueOnce({sessionStateType:r.Connected,deviceStatus:d.NOT_CONNECTED,deviceModelId:l.FLEX});const a=await new s(n,o,c).run();expect(a).toEqual({clearSignContexts:[e[0]],clearSignContextsOptional:[],clearSigningType:u.BASIC})}),it("should return no clear sign context if the transaction info certificate is missing",async()=>{const e=[{type:t.TRANSACTION_INFO,payload:"payload-1"},{type:t.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-2"},{type:t.ENUM,payload:"payload-3",id:1,value:2}];i.getContexts.mockResolvedValueOnce(e),n.getDeviceSessionState.mockReturnValueOnce({sessionStateType:r.ReadyWithoutSecureChannel,deviceStatus:d.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.17.0"},deviceModelId:l.FLEX,isSecureConnectionAllowed:!1});const a=await new s(n,o,c).run();expect(a).toEqual({clearSignContexts:[],clearSignContextsOptional:[],clearSigningType:u.BASIC})}),it("should not return web3check if the transaction is undefined",async()=>{const e=[];i.getContexts.mockResolvedValueOnce(e),n.getDeviceSessionState.mockReturnValueOnce({sessionStateType:r.ReadyWithoutSecureChannel,deviceStatus:d.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.17.0"},deviceModelId:l.FLEX,isSecureConnectionAllowed:!1}),await new s(n,{...o,transaction:void 0},c).run(),expect(c).not.toHaveBeenCalled()})});
|
|
1
|
+
import{ClearSignContextType as t}from"@ledgerhq/context-module";import{CommandResultFactory as x,DeviceModelId as l,DeviceSessionStateType as s,DeviceStatus as r,hexaStringToBuffer as E}from"@ledgerhq/device-management-kit";import{Transaction as N}from"ethers";import{ClearSigningType as p}from"../../../api/model/ClearSigningType";import{makeDeviceActionInternalApiMock as T}from"../../app-binder/device-action/__test-utils__/makeInternalApi";import{BASE_CONTEXT_TYPES_FILTER as S,BuildBaseContexts as d}from"./BuildBaseContexts";describe("BuildBaseContexts",()=>{const o={getFieldContext:vi.fn(),getContexts:vi.fn(),getTypedDataFilters:vi.fn(),getSolanaContext:vi.fn()},g={domain:"domain-name.eth"},y=E(N.from({chainId:1n,nonce:0,data:"0x"}).unsignedSerialized),c={keyUsageNumber:1,payload:new Uint8Array([1,2,3])};let i;const n=T();function C(e){return{blindSigningEnabled:!1,web3ChecksEnabled:e,web3ChecksOptIn:!1,version:"1.13.0"}}beforeEach(()=>{vi.resetAllMocks(),n.sendCommand.mockResolvedValue(x({data:{challenge:"challenge"}})),i={contextModule:o,subset:{chainId:1,to:void 0,data:"0x",selector:"0x"},transaction:y,options:g,appConfig:C(!1)}}),it("should build the transaction context without clear sign contexts",async()=>{const e=[],a=[];o.getContexts.mockResolvedValueOnce(e),n.getDeviceSessionState.mockReturnValueOnce({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:r.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:l.FLEX,isSecureConnectionAllowed:!1});const u=await new d(n,{...i,appConfig:C(!0)}).run();expect(u).toEqual({clearSignContexts:e,clearSignContextsOptional:a,clearSigningType:p.BASIC})}),it("should build the transaction context with transaction check and generic-parser clear sign contexts",async()=>{const e=[{type:t.TRANSACTION_INFO,payload:"payload-1",certificate:c},{type:t.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-2"},{type:t.ENUM,payload:"payload-3",id:1,value:2,certificate:c},{type:t.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-4"}],a={type:t.TRANSACTION_CHECK,payload:"transactionCheck"};o.getContexts.mockResolvedValueOnce([...e,a]),n.getDeviceSessionState.mockReturnValueOnce({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:r.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.15.0"},deviceModelId:l.FLEX,isSecureConnectionAllowed:!1});const u=await new d(n,{...i,appConfig:C(!0)}).run();expect(u).toEqual({clearSignContexts:[a,e[0],e[1],e[3]],clearSignContextsOptional:[e[2]],clearSigningType:p.EIP7730})}),it("should build the transaction context with transaction check and generic-parser clear sign contexts in the correct order",async()=>{const e=[{type:t.ENUM,payload:"payload-3",id:1,value:2,certificate:c},{type:t.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-4"},{type:t.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-2"},{type:t.TRANSACTION_INFO,payload:"payload-1",certificate:c}],a={type:t.TRANSACTION_CHECK,payload:"transactionCheck"};o.getContexts.mockResolvedValueOnce([...e,a]),n.getDeviceSessionState.mockReturnValueOnce({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:r.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.15.0"},deviceModelId:l.FLEX,isSecureConnectionAllowed:!1});const u=await new d(n,{...i,appConfig:C(!0)}).run();expect(u).toEqual({clearSignContexts:[a,e[3],e[1],e[2]],clearSignContextsOptional:[e[0]],clearSigningType:p.EIP7730})}),it("should build the transaction context with clear sign contexts",async()=>{const e=[{type:t.TRANSACTION_CHECK,payload:"transactionCheck"},{type:t.TOKEN,payload:"payload-1"},{type:t.NFT,payload:"payload-2"}];o.getContexts.mockResolvedValueOnce(e),n.getDeviceSessionState.mockReturnValueOnce({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:r.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:l.FLEX,isSecureConnectionAllowed:!1});const a=await new d(n,i).run();expect(a).toEqual({clearSignContexts:e,clearSignContextsOptional:[],clearSigningType:p.BASIC})}),it("should build the transaction context with generic-parser context",async()=>{const e=[{type:t.TRANSACTION_INFO,payload:"payload-1",certificate:c},{type:t.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-2"},{type:t.ENUM,payload:"payload-3",id:1,value:2,certificate:c},{type:t.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-4"}];o.getContexts.mockResolvedValueOnce(e),n.getDeviceSessionState.mockReturnValueOnce({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:r.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.15.0"},deviceModelId:l.FLEX,isSecureConnectionAllowed:!1});const a=await new d(n,i).run();expect(a).toEqual({clearSignContexts:[e[0],e[1],e[3]],clearSignContextsOptional:[e[2]],clearSigningType:p.EIP7730})}),it("should build the transaction context with proxy delegate call context",async()=>{const e=[{type:t.TRANSACTION_INFO,payload:"payload-1",certificate:c},{type:t.PROXY_INFO,payload:"payload-2"}],a=[];o.getContexts.mockResolvedValueOnce(e),n.getDeviceSessionState.mockReturnValueOnce({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:r.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.15.0"},deviceModelId:l.FLEX,isSecureConnectionAllowed:!1});const u=await new d(n,i).run();expect(u).toEqual({clearSignContexts:[e[1],e[0]],clearSignContextsOptional:a,clearSigningType:p.EIP7730})}),it("should call the context module with the correct parameters if transaction check is enabled",async()=>{const e=[];o.getContexts.mockResolvedValueOnce(e),n.getDeviceSessionState.mockReturnValueOnce({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:r.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:l.FLEX,isSecureConnectionAllowed:!1}),await new d(n,{...i,appConfig:C(!0)}).run(),expect(o.getContexts).toHaveBeenCalledWith({deviceModelId:l.FLEX,challenge:"challenge",domain:"domain-name.eth",transaction:y,...i.subset},S)}),it("should call the context module with the correct parameters if transaction check is disabled",async()=>{const e=[];o.getContexts.mockResolvedValueOnce(e),n.getDeviceSessionState.mockReturnValueOnce({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:r.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:l.FLEX,isSecureConnectionAllowed:!1}),await new d(n,{...i,appConfig:C(!1)}).run(),expect(o.getContexts).toHaveBeenCalledWith({deviceModelId:l.FLEX,challenge:"challenge",domain:"domain-name.eth",...i.subset},S)}),it("should call the context module without challenge for Nano S",async()=>{const e=[];o.getContexts.mockResolvedValueOnce(e),n.getDeviceSessionState.mockReturnValueOnce({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:r.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:l.NANO_S,isSecureConnectionAllowed:!1}),await new d(n,i).run(),expect(o.getContexts).toHaveBeenCalledWith({deviceModelId:l.NANO_S,domain:"domain-name.eth",challenge:void 0,...i.subset},S)}),it("should exclude error contexts from the result",async()=>{const e=[{type:t.ERROR,error:new Error("error")},{type:t.TOKEN,payload:"payload-1"},{type:t.ERROR,error:new Error("error")},{type:t.NFT,payload:"payload-2"}];o.getContexts.mockResolvedValueOnce(e),n.getDeviceSessionState.mockReturnValueOnce({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:r.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:l.FLEX,isSecureConnectionAllowed:!1});const a=await new d(n,i).run();expect(a).toEqual({clearSignContexts:[e[1],e[3]],clearSignContextsOptional:[],clearSigningType:p.BASIC})}),it("should exclude generic-parser contexts from the result on old apps",async()=>{const e=[{type:t.TRANSACTION_INFO,payload:"transaction_info",certificate:c},{type:t.TOKEN,payload:"payload-1"},{type:t.TRANSACTION_FIELD_DESCRIPTION,payload:"transaction_field"},{type:t.NFT,payload:"payload-2"},{type:t.ENUM,payload:"enum",id:1,value:2,certificate:c}];o.getContexts.mockResolvedValueOnce(e),n.getDeviceSessionState.mockReturnValueOnce({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:r.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:l.FLEX,isSecureConnectionAllowed:!1});const a=await new d(n,i).run();expect(a).toEqual({clearSignContexts:[e[1],e[3]],clearSignContextsOptional:[],clearSigningType:p.BASIC})}),it("should exclude generic-parser contexts from the result if no transaction_info was found",async()=>{const e=[{type:t.TRANSACTION_FIELD_DESCRIPTION,payload:"transaction_field"},{type:t.TOKEN,payload:"payload-1"},{type:t.ENUM,payload:"enum",id:1,value:2},{type:t.NFT,payload:"payload-2"}];o.getContexts.mockResolvedValueOnce(e),n.getDeviceSessionState.mockReturnValueOnce({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:r.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.14.0"},deviceModelId:l.FLEX,isSecureConnectionAllowed:!1});const a=await new d(n,i).run();expect(a).toEqual({clearSignContexts:[e[1],e[3]],clearSignContextsOptional:[],clearSigningType:p.BASIC})}),it("should exclude legacy contexts from the result for generic-parser transactions",async()=>{const e=[{type:t.TOKEN,payload:"payload-1"},{type:t.TRANSACTION_INFO,payload:"payload-2",certificate:c},{type:t.EXTERNAL_PLUGIN,payload:"payload-3"},{type:t.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-4"},{type:t.ENUM,payload:"payload-5",id:1,value:2,certificate:c}];o.getContexts.mockResolvedValueOnce(e),n.getDeviceSessionState.mockReturnValueOnce({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:r.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.15.0"},deviceModelId:l.FLEX,isSecureConnectionAllowed:!1});const a=await new d(n,i).run();expect(a).toEqual({clearSignContexts:[e[1],e[3]],clearSignContextsOptional:[e[4]],clearSigningType:p.EIP7730})}),it("should exclude generic-parser contexts with a nano s device",async()=>{const e=[{type:t.TOKEN,payload:"payload-1"},{type:t.TRANSACTION_INFO,payload:"payload-2",certificate:c},{type:t.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-3"},{type:t.ENUM,payload:"payload-4",id:1,value:2,certificate:c}];o.getContexts.mockResolvedValueOnce(e),n.getDeviceSessionState.mockReturnValueOnce({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:r.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.14.0"},deviceModelId:l.NANO_S,isSecureConnectionAllowed:!1});const a=await new d(n,i).run();expect(a).toEqual({clearSignContexts:[e[0]],clearSignContextsOptional:[],clearSigningType:p.BASIC})}),it("should exclude generic-parser contexts with an old app version",async()=>{const e=[{type:t.TOKEN,payload:"payload-1"},{type:t.TRANSACTION_INFO,payload:"payload-2",certificate:c},{type:t.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-3"},{type:t.ENUM,payload:"payload-4",id:1,value:2,certificate:c}];o.getContexts.mockResolvedValueOnce(e),n.getDeviceSessionState.mockReturnValueOnce({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:r.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:l.FLEX,isSecureConnectionAllowed:!1});const a=await new d(n,i).run();expect(a).toEqual({clearSignContexts:[e[0]],clearSignContextsOptional:[],clearSigningType:p.BASIC})}),it("should exclude generic-parser contexts with a non ready device",async()=>{const e=[{type:t.TOKEN,payload:"payload-1"},{type:t.TRANSACTION_INFO,payload:"payload-2",certificate:c},{type:t.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-3"},{type:t.ENUM,payload:"payload-4",id:1,value:2,certificate:c}];o.getContexts.mockResolvedValueOnce(e),n.getDeviceSessionState.mockReturnValueOnce({sessionStateType:s.Connected,deviceStatus:r.NOT_CONNECTED,deviceModelId:l.FLEX});const a=await new d(n,i).run();expect(a).toEqual({clearSignContexts:[e[0]],clearSignContextsOptional:[],clearSigningType:p.BASIC})}),it("should return no clear sign context if the transaction info certificate is missing",async()=>{const e=[{type:t.TRANSACTION_INFO,payload:"payload-1"},{type:t.TRANSACTION_FIELD_DESCRIPTION,payload:"payload-2"},{type:t.ENUM,payload:"payload-3",id:1,value:2}];o.getContexts.mockResolvedValueOnce(e),n.getDeviceSessionState.mockReturnValueOnce({sessionStateType:s.ReadyWithoutSecureChannel,deviceStatus:r.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.17.0"},deviceModelId:l.FLEX,isSecureConnectionAllowed:!1});const a=await new d(n,i).run();expect(a).toEqual({clearSignContexts:[],clearSignContextsOptional:[],clearSigningType:p.BASIC})})});
|
|
2
2
|
//# sourceMappingURL=BuildBaseContexts.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/app-binder/task/BuildBaseContexts.test.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n type ClearSignContext,\n ClearSignContextType,\n type PkiCertificate,\n} from \"@ledgerhq/context-module\";\nimport {\n CommandResultFactory,\n DeviceModelId,\n DeviceSessionStateType,\n DeviceStatus,\n hexaStringToBuffer,\n UnknownDeviceExchangeError,\n} from \"@ledgerhq/device-management-kit\";\nimport { Transaction } from \"ethers\";\n\nimport type { GetConfigCommandResponse } from \"@api/app-binder/GetConfigCommandTypes\";\nimport { ClearSigningType } from \"@api/model/ClearSigningType\";\nimport { makeDeviceActionInternalApiMock } from \"@internal/app-binder/device-action/__test-utils__/makeInternalApi\";\n\nimport {\n BuildBaseContexts,\n type BuildBaseContextsArgs,\n} from \"./BuildBaseContexts\";\nimport { GetWeb3CheckTask } from \"./GetWeb3CheckTask\";\n\ndescribe(\"BuildBaseContexts\", () => {\n const contextModuleMock = {\n getFieldContext: vi.fn(),\n getContexts: vi.fn(),\n getTypedDataFilters: vi.fn(),\n getWeb3Checks: vi.fn(),\n getSolanaContext: vi.fn(),\n };\n const defaultOptions = {\n domain: \"domain-name.eth\",\n };\n const defaultTransaction: Uint8Array = hexaStringToBuffer(\n Transaction.from({\n chainId: 1n,\n nonce: 0,\n data: \"0x\",\n }).unsignedSerialized,\n )!;\n const defaultCertificate: PkiCertificate = {\n keyUsageNumber: 1,\n payload: new Uint8Array([0x01, 0x02, 0x03]),\n };\n\n let defaultArgs: BuildBaseContextsArgs;\n const apiMock = makeDeviceActionInternalApiMock();\n const getWeb3ChecksFactoryMock = vi.fn();\n\n function createAppConfig(\n web3ChecksEnabled: boolean,\n ): GetConfigCommandResponse {\n return {\n blindSigningEnabled: false,\n web3ChecksEnabled,\n web3ChecksOptIn: false,\n version: \"1.13.0\",\n };\n }\n\n beforeEach(() => {\n vi.resetAllMocks();\n apiMock.sendCommand.mockResolvedValue(\n CommandResultFactory({ data: { challenge: \"challenge\" } }),\n );\n getWeb3ChecksFactoryMock.mockReturnValue({\n run: async () => Promise.resolve({ web3Check: null }),\n });\n\n defaultArgs = {\n contextModule: contextModuleMock,\n subset: { chainId: 1, to: undefined, data: \"0x\", selector: \"0x\" },\n transaction: defaultTransaction,\n options: defaultOptions,\n appConfig: createAppConfig(false),\n derivationPath: \"44'/60'/0'/0/0\",\n };\n });\n\n it(\"should init with a default GetWeb3CheckTaskFactory\", () => {\n // GIVEN\n const task = new BuildBaseContexts(apiMock, defaultArgs);\n\n // THEN\n expect(task[\"getWeb3ChecksFactory\"]).toBeDefined();\n expect(\n task[\"getWeb3ChecksFactory\"](apiMock, {\n contextModule: defaultArgs.contextModule,\n derivationPath: defaultArgs.derivationPath,\n subset: defaultArgs.subset,\n transaction: defaultArgs.transaction!,\n }),\n ).toBeInstanceOf(GetWeb3CheckTask);\n });\n\n it(\"should build the transaction context without clear sign contexts\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [];\n const clearSignContextsOptional: ClearSignContext[] = [];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n { ...defaultArgs, appConfig: createAppConfig(true) },\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts,\n clearSignContextsOptional,\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should build the transaction context with web3checks\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [];\n const clearSignContextsOptional: ClearSignContext[] = [];\n const expectedWeb3Check = {\n type: ClearSignContextType.WEB3_CHECK,\n payload: \"web3Check\",\n };\n getWeb3ChecksFactoryMock.mockReturnValueOnce({\n run: async () => Promise.resolve({ web3Check: expectedWeb3Check }),\n });\n contextModuleMock.getContexts.mockResolvedValueOnce([...clearSignContexts]);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n { ...defaultArgs, appConfig: createAppConfig(true) },\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [expectedWeb3Check, ...clearSignContexts],\n clearSignContextsOptional,\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should build the transaction context with web3checks and generic-parser clear sign contexts\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-2\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-3\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-4\",\n },\n ];\n const expectedWeb3Check = {\n type: ClearSignContextType.WEB3_CHECK,\n payload: \"web3Check\",\n };\n getWeb3ChecksFactoryMock.mockReturnValueOnce({\n run: async () => Promise.resolve({ web3Check: expectedWeb3Check }),\n });\n contextModuleMock.getContexts.mockResolvedValueOnce([...clearSignContexts]);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.15.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n { ...defaultArgs, appConfig: createAppConfig(true) },\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [\n expectedWeb3Check,\n clearSignContexts[0],\n clearSignContexts[1],\n clearSignContexts[3],\n ],\n clearSignContextsOptional: [clearSignContexts[2]],\n clearSigningType: ClearSigningType.EIP7730,\n });\n });\n\n it(\"should build the transaction context with web3checks and generic-parser clear sign contexts in the correct order\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-3\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-4\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-2\",\n },\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n certificate: defaultCertificate,\n },\n ];\n const expectedWeb3Check = {\n type: ClearSignContextType.WEB3_CHECK,\n payload: \"web3Check\",\n };\n getWeb3ChecksFactoryMock.mockReturnValueOnce({\n run: async () => Promise.resolve({ web3Check: expectedWeb3Check }),\n });\n contextModuleMock.getContexts.mockResolvedValueOnce([...clearSignContexts]);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.15.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n { ...defaultArgs, appConfig: createAppConfig(true) },\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [\n expectedWeb3Check, // web3 check\n clearSignContexts[3], // transaction info\n clearSignContexts[1], // transaction field description\n clearSignContexts[2], // transaction field description\n ],\n clearSignContextsOptional: [clearSignContexts[0]], // enum\n clearSigningType: ClearSigningType.EIP7730,\n });\n });\n\n it(\"should build the transaction context with clear sign contexts\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.NFT,\n payload: \"payload-2\",\n },\n ];\n const expectedWeb3Check = {\n type: ClearSignContextType.WEB3_CHECK,\n payload: \"web3Check\",\n };\n getWeb3ChecksFactoryMock.mockReturnValueOnce({\n run: async () => Promise.resolve({ web3Check: expectedWeb3Check }),\n });\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts,\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should build the transaction context with generic-parser context\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-2\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-3\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-4\",\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.15.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [\n clearSignContexts[0],\n clearSignContexts[1],\n clearSignContexts[3],\n ],\n clearSignContextsOptional: [clearSignContexts[2]],\n clearSigningType: ClearSigningType.EIP7730,\n });\n });\n\n it(\"should build the transaction context with proxy delegate call context\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.PROXY_INFO,\n payload: \"payload-2\",\n },\n ];\n const clearSignContextsOptional: ClearSignContext[] = [];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.15.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[1], clearSignContexts[0]],\n clearSignContextsOptional,\n clearSigningType: ClearSigningType.EIP7730,\n });\n });\n\n it(\"should call the web3checks factory with correct parameters\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n await new BuildBaseContexts(\n apiMock,\n { ...defaultArgs, appConfig: createAppConfig(true) },\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(getWeb3ChecksFactoryMock).toHaveBeenCalledWith(apiMock, {\n contextModule: contextModuleMock,\n derivationPath: \"44'/60'/0'/0/0\",\n subset: defaultArgs.subset,\n transaction: defaultTransaction,\n });\n });\n\n it(\"should call the context module with the correct parameters\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(contextModuleMock.getContexts).toHaveBeenCalledWith(\n {\n deviceModelId: DeviceModelId.FLEX,\n challenge: \"challenge\",\n domain: \"domain-name.eth\",\n ...defaultArgs.subset,\n },\n undefined,\n );\n });\n\n it(\"should call the context module without challenge for Nano S\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.NANO_S,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(contextModuleMock.getContexts).toHaveBeenCalledWith(\n {\n deviceModelId: DeviceModelId.NANO_S,\n domain: \"domain-name.eth\",\n ...defaultArgs.subset,\n },\n undefined,\n );\n });\n\n it(\"should call the context module without context on error\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n apiMock.sendCommand.mockResolvedValueOnce(\n CommandResultFactory({ error: new UnknownDeviceExchangeError() }),\n );\n\n // WHEN\n await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(contextModuleMock.getContexts).toHaveBeenCalledWith(\n {\n deviceModelId: DeviceModelId.FLEX,\n challenge: undefined,\n domain: \"domain-name.eth\",\n ...defaultArgs.subset,\n },\n undefined,\n );\n });\n\n it(\"should exclude error contexts from the result\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"error\"),\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"error\"),\n },\n {\n type: ClearSignContextType.NFT,\n payload: \"payload-2\",\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[1], clearSignContexts[3]],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should exclude generic-parser contexts from the result on old apps\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"transaction_info\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"transaction_field\",\n },\n {\n type: ClearSignContextType.NFT,\n payload: \"payload-2\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"enum\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[1], clearSignContexts[3]],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should exclude generic-parser contexts from the result if no transaction_info was found\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"transaction_field\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"enum\",\n id: 1,\n value: 2,\n },\n {\n type: ClearSignContextType.NFT,\n payload: \"payload-2\",\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.14.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[1], clearSignContexts[3]],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should exclude legacy contexts from the result for generic-parser transactions\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-2\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"payload-3\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-4\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-5\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.15.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[1], clearSignContexts[3]],\n clearSignContextsOptional: [clearSignContexts[4]],\n clearSigningType: ClearSigningType.EIP7730,\n });\n });\n\n it(\"should exclude generic-parser contexts with a nano s device\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-2\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-3\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-4\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.14.0\" },\n deviceModelId: DeviceModelId.NANO_S,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[0]],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should exclude generic-parser contexts with an old app version\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-2\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-3\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-4\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[0]],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should exclude generic-parser contexts with a non ready device\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-2\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-3\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-4\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.Connected,\n deviceStatus: DeviceStatus.NOT_CONNECTED,\n deviceModelId: DeviceModelId.FLEX,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[0]],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should return no clear sign context if the transaction info certificate is missing\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-2\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-3\",\n id: 1,\n value: 2,\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.17.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(\n apiMock,\n defaultArgs,\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should not return web3check if the transaction is undefined\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.17.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n await new BuildBaseContexts(\n apiMock,\n { ...defaultArgs, transaction: undefined },\n getWeb3ChecksFactoryMock,\n ).run();\n\n // THEN\n expect(getWeb3ChecksFactoryMock).not.toHaveBeenCalled();\n });\n});\n"],
|
|
5
|
-
"mappings": "AAAA,OAEE,wBAAAA,MAEK,2BACP,OACE,wBAAAC,EACA,iBAAAC,EACA,0BAAAC,EACA,gBAAAC,EACA,sBAAAC,EACA,8BAAAC,MACK,kCACP,OAAS,eAAAC,MAAmB,SAG5B,OAAS,oBAAAC,MAAwB,8BACjC,OAAS,mCAAAC,MAAuC,oEAEhD,OACE,qBAAAC,MAEK,sBACP,OAAS,oBAAAC,MAAwB,qBAEjC,SAAS,oBAAqB,IAAM,CAClC,MAAMC,EAAoB,CACxB,gBAAiB,GAAG,GAAG,EACvB,YAAa,GAAG,GAAG,EACnB,oBAAqB,GAAG,GAAG,EAC3B,cAAe,GAAG,GAAG,EACrB,iBAAkB,GAAG,GAAG,CAC1B,EACMC,EAAiB,CACrB,OAAQ,iBACV,EACMC,EAAiCT,EACrCE,EAAY,KAAK,CACf,QAAS,GACT,MAAO,EACP,KAAM,IACR,CAAC,EAAE,kBACL,EACMQ,EAAqC,CACzC,eAAgB,EAChB,QAAS,IAAI,WAAW,CAAC,EAAM,EAAM,CAAI,CAAC,CAC5C,EAEA,IAAIC,EACJ,MAAMC,EAAUR,EAAgC,EAC1CS,EAA2B,GAAG,GAAG,EAEvC,SAASC,EACPC,EAC0B,CAC1B,MAAO,CACL,oBAAqB,GACrB,kBAAAA,EACA,gBAA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BU,CAAiB,EACrEL,EAAQ,sBAAsB,oBAAoB,CAChD,iBAAkBd,EAAuB,0BACzC,aAAcC,EAAa,UAC3B,cAAe,CAAC,EAChB,WAAY,CAAE,KAAM,WAAY,QAAS,QAAS,EAClD,cAAeF,EAAc,KAC7B,0BAA2B,EAC7B,CAAC,EAGD,MAAM,IAAIQ,EACRO,EACA,CAAE,GAAGD,EAAa,YAAa,MAAU,EACzCE,CACF,EAAE,IAAI,EAGN,OAAOA,CAAwB,EAAE,IAAI,iBAAiB,CACxD,CAAC,CACH,CAAC",
|
|
6
|
-
"names": ["ClearSignContextType", "CommandResultFactory", "DeviceModelId", "DeviceSessionStateType", "DeviceStatus", "hexaStringToBuffer", "
|
|
4
|
+
"sourcesContent": ["import {\n type ClearSignContext,\n ClearSignContextType,\n type PkiCertificate,\n} from \"@ledgerhq/context-module\";\nimport {\n CommandResultFactory,\n DeviceModelId,\n DeviceSessionStateType,\n DeviceStatus,\n hexaStringToBuffer,\n} from \"@ledgerhq/device-management-kit\";\nimport { Transaction } from \"ethers\";\n\nimport type { GetConfigCommandResponse } from \"@api/app-binder/GetConfigCommandTypes\";\nimport { ClearSigningType } from \"@api/model/ClearSigningType\";\nimport { makeDeviceActionInternalApiMock } from \"@internal/app-binder/device-action/__test-utils__/makeInternalApi\";\n\nimport {\n BASE_CONTEXT_TYPES_FILTER,\n BuildBaseContexts,\n type BuildBaseContextsArgs,\n} from \"./BuildBaseContexts\";\n\ndescribe(\"BuildBaseContexts\", () => {\n const contextModuleMock = {\n getFieldContext: vi.fn(),\n getContexts: vi.fn(),\n getTypedDataFilters: vi.fn(),\n getSolanaContext: vi.fn(),\n };\n const defaultOptions = {\n domain: \"domain-name.eth\",\n };\n const defaultTransaction: Uint8Array = hexaStringToBuffer(\n Transaction.from({\n chainId: 1n,\n nonce: 0,\n data: \"0x\",\n }).unsignedSerialized,\n )!;\n const defaultCertificate: PkiCertificate = {\n keyUsageNumber: 1,\n payload: new Uint8Array([0x01, 0x02, 0x03]),\n };\n\n let defaultArgs: BuildBaseContextsArgs;\n const apiMock = makeDeviceActionInternalApiMock();\n\n function createAppConfig(\n web3ChecksEnabled: boolean,\n ): GetConfigCommandResponse {\n return {\n blindSigningEnabled: false,\n web3ChecksEnabled,\n web3ChecksOptIn: false,\n version: \"1.13.0\",\n };\n }\n\n beforeEach(() => {\n vi.resetAllMocks();\n apiMock.sendCommand.mockResolvedValue(\n CommandResultFactory({ data: { challenge: \"challenge\" } }),\n );\n\n defaultArgs = {\n contextModule: contextModuleMock,\n subset: { chainId: 1, to: undefined, data: \"0x\", selector: \"0x\" },\n transaction: defaultTransaction,\n options: defaultOptions,\n appConfig: createAppConfig(false),\n };\n });\n\n it(\"should build the transaction context without clear sign contexts\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [];\n const clearSignContextsOptional: ClearSignContext[] = [];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(apiMock, {\n ...defaultArgs,\n appConfig: createAppConfig(true),\n }).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts,\n clearSignContextsOptional,\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should build the transaction context with transaction check and generic-parser clear sign contexts\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-2\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-3\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-4\",\n },\n ];\n const expectedTxCheck = {\n type: ClearSignContextType.TRANSACTION_CHECK,\n payload: \"transactionCheck\",\n };\n contextModuleMock.getContexts.mockResolvedValueOnce([\n ...clearSignContexts,\n expectedTxCheck,\n ]);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.15.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(apiMock, {\n ...defaultArgs,\n appConfig: createAppConfig(true),\n }).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [\n expectedTxCheck,\n clearSignContexts[0],\n clearSignContexts[1],\n clearSignContexts[3],\n ],\n clearSignContextsOptional: [clearSignContexts[2]],\n clearSigningType: ClearSigningType.EIP7730,\n });\n });\n\n it(\"should build the transaction context with transaction check and generic-parser clear sign contexts in the correct order\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-3\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-4\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-2\",\n },\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n certificate: defaultCertificate,\n },\n ];\n const expectedTxCheck = {\n type: ClearSignContextType.TRANSACTION_CHECK,\n payload: \"transactionCheck\",\n };\n contextModuleMock.getContexts.mockResolvedValueOnce([\n ...clearSignContexts,\n expectedTxCheck,\n ]);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.15.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(apiMock, {\n ...defaultArgs,\n appConfig: createAppConfig(true),\n }).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [\n expectedTxCheck, // transaction check\n clearSignContexts[3], // transaction info\n clearSignContexts[1], // transaction field description\n clearSignContexts[2], // transaction field description\n ],\n clearSignContextsOptional: [clearSignContexts[0]], // enum\n clearSigningType: ClearSigningType.EIP7730,\n });\n });\n\n it(\"should build the transaction context with clear sign contexts\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TRANSACTION_CHECK,\n payload: \"transactionCheck\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.NFT,\n payload: \"payload-2\",\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(apiMock, defaultArgs).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts,\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should build the transaction context with generic-parser context\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-2\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-3\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-4\",\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.15.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(apiMock, defaultArgs).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [\n clearSignContexts[0],\n clearSignContexts[1],\n clearSignContexts[3],\n ],\n clearSignContextsOptional: [clearSignContexts[2]],\n clearSigningType: ClearSigningType.EIP7730,\n });\n });\n\n it(\"should build the transaction context with proxy delegate call context\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.PROXY_INFO,\n payload: \"payload-2\",\n },\n ];\n const clearSignContextsOptional: ClearSignContext[] = [];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.15.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(apiMock, defaultArgs).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[1], clearSignContexts[0]],\n clearSignContextsOptional,\n clearSigningType: ClearSigningType.EIP7730,\n });\n });\n\n it(\"should call the context module with the correct parameters if transaction check is enabled\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n await new BuildBaseContexts(apiMock, {\n ...defaultArgs,\n appConfig: createAppConfig(true),\n }).run();\n\n // THEN\n expect(contextModuleMock.getContexts).toHaveBeenCalledWith(\n {\n deviceModelId: DeviceModelId.FLEX,\n challenge: \"challenge\",\n domain: \"domain-name.eth\",\n transaction: defaultTransaction,\n ...defaultArgs.subset,\n },\n BASE_CONTEXT_TYPES_FILTER,\n );\n });\n\n it(\"should call the context module with the correct parameters if transaction check is disabled\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n await new BuildBaseContexts(apiMock, {\n ...defaultArgs,\n appConfig: createAppConfig(false),\n }).run();\n\n // THEN\n expect(contextModuleMock.getContexts).toHaveBeenCalledWith(\n {\n deviceModelId: DeviceModelId.FLEX,\n challenge: \"challenge\",\n domain: \"domain-name.eth\",\n ...defaultArgs.subset,\n },\n BASE_CONTEXT_TYPES_FILTER,\n );\n });\n\n it(\"should call the context module without challenge for Nano S\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.NANO_S,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n await new BuildBaseContexts(apiMock, defaultArgs).run();\n\n // THEN\n expect(contextModuleMock.getContexts).toHaveBeenCalledWith(\n {\n deviceModelId: DeviceModelId.NANO_S,\n domain: \"domain-name.eth\",\n challenge: undefined,\n ...defaultArgs.subset,\n },\n BASE_CONTEXT_TYPES_FILTER,\n );\n });\n\n it(\"should exclude error contexts from the result\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"error\"),\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.ERROR,\n error: new Error(\"error\"),\n },\n {\n type: ClearSignContextType.NFT,\n payload: \"payload-2\",\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(apiMock, defaultArgs).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[1], clearSignContexts[3]],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should exclude generic-parser contexts from the result on old apps\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"transaction_info\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"transaction_field\",\n },\n {\n type: ClearSignContextType.NFT,\n payload: \"payload-2\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"enum\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(apiMock, defaultArgs).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[1], clearSignContexts[3]],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should exclude generic-parser contexts from the result if no transaction_info was found\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"transaction_field\",\n },\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"enum\",\n id: 1,\n value: 2,\n },\n {\n type: ClearSignContextType.NFT,\n payload: \"payload-2\",\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.14.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(apiMock, defaultArgs).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[1], clearSignContexts[3]],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should exclude legacy contexts from the result for generic-parser transactions\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-2\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.EXTERNAL_PLUGIN,\n payload: \"payload-3\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-4\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-5\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.15.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(apiMock, defaultArgs).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[1], clearSignContexts[3]],\n clearSignContextsOptional: [clearSignContexts[4]],\n clearSigningType: ClearSigningType.EIP7730,\n });\n });\n\n it(\"should exclude generic-parser contexts with a nano s device\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-2\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-3\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-4\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.14.0\" },\n deviceModelId: DeviceModelId.NANO_S,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(apiMock, defaultArgs).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[0]],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should exclude generic-parser contexts with an old app version\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-2\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-3\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-4\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.12.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(apiMock, defaultArgs).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[0]],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should exclude generic-parser contexts with a non ready device\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TOKEN,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-2\",\n certificate: defaultCertificate,\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-3\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-4\",\n id: 1,\n value: 2,\n certificate: defaultCertificate,\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.Connected,\n deviceStatus: DeviceStatus.NOT_CONNECTED,\n deviceModelId: DeviceModelId.FLEX,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(apiMock, defaultArgs).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [clearSignContexts[0]],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC,\n });\n });\n\n it(\"should return no clear sign context if the transaction info certificate is missing\", async () => {\n // GIVEN\n const clearSignContexts: ClearSignContext[] = [\n {\n type: ClearSignContextType.TRANSACTION_INFO,\n payload: \"payload-1\",\n },\n {\n type: ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION,\n payload: \"payload-2\",\n },\n {\n type: ClearSignContextType.ENUM,\n payload: \"payload-3\",\n id: 1,\n value: 2,\n },\n ];\n contextModuleMock.getContexts.mockResolvedValueOnce(clearSignContexts);\n apiMock.getDeviceSessionState.mockReturnValueOnce({\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.17.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n });\n\n // WHEN\n const result = await new BuildBaseContexts(apiMock, defaultArgs).run();\n\n // THEN\n expect(result).toEqual({\n clearSignContexts: [],\n clearSignContextsOptional: [],\n clearSigningType: ClearSigningType.BASIC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,EACpB,0BAA2B,CAAC,EAC5B,iBAAkBd,EAAiB,KACrC,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["ClearSignContextType", "CommandResultFactory", "DeviceModelId", "DeviceSessionStateType", "DeviceStatus", "hexaStringToBuffer", "Transaction", "ClearSigningType", "makeDeviceActionInternalApiMock", "BASE_CONTEXT_TYPES_FILTER", "BuildBaseContexts", "contextModuleMock", "defaultOptions", "defaultTransaction", "defaultCertificate", "defaultArgs", "apiMock", "createAppConfig", "web3ChecksEnabled", "clearSignContexts", "clearSignContextsOptional", "result", "expectedTxCheck"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{DeviceModelId as
|
|
1
|
+
import{ClearSignContextType as y}from"@ledgerhq/context-module";import{DeviceModelId as T,isSuccessCommandResult as I}from"@ledgerhq/device-management-kit";import{Just as C,Nothing as g}from"purify-ts";import{ClearSigningType as M}from"../../../api/model/ClearSigningType";import{GetChallengeCommand as D}from"../../app-binder/command/GetChallengeCommand";import{BuildFullContextsTask as P}from"../../app-binder/task/BuildFullContextsTask";import{ApplicationChecker as m}from"../../shared/utils/ApplicationChecker";import{TypedDataValueField as A}from"../../typed-data/model/Types";const k="0x0000000000000000000000000000000000000000";class W{constructor(e,t,n,i,a,o,u,d,c,l=(h,s)=>new P(h,s)){this.api=e;this.contextModule=t;this.parser=n;this.transactionParser=i;this.transactionMapper=a;this.data=o;this.derivationPath=u;this.appConfig=d;this.from=c;this.buildFullContextFactory=l}async run(){const e=this.parser.parse(this.data);if(e.isLeft())throw e.extract();const{types:t,domain:n,message:i}=e.unsafeCoerce(),a=this.api.getDeviceSessionState(),o=a.deviceModelId,u=await this.getTransactionChecks(o);let d=g,c={};const l=this.getClearSignVersion(a);if(l.isJust()){let s;const v=await this.api.sendCommand(new D);I(v)&&(s=v.data.challenge);const x=this.data.domain.verifyingContract?.toLowerCase()||k,f=this.data.domain.chainId||0,S=i.filter(r=>r.value instanceof A).map(r=>({path:r.path,value:r.value.data})),p=await this.contextModule.getTypedDataFilters({verifyingContract:x,chainId:f,version:l.extract(),schema:this.data.types,challenge:s,deviceModelId:a.deviceModelId,fieldsValues:S});p.type==="success"&&(d=C(p),c=await this.getCalldatasContexts(a,p))}return{derivationPath:this.derivationPath,transactionChecks:u,types:t,domain:n,message:i,clearSignContext:d,calldatasContexts:c,deviceModelId:a.deviceModelId}}async getTransactionChecks(e){if(!this.appConfig.web3ChecksEnabled)return;const t=await this.contextModule.getContexts({deviceModelId:e,data:this.data,from:this.from},[y.TRANSACTION_CHECK]);if(t.length>0&&t[0]?.type===y.TRANSACTION_CHECK)return t[0]}getClearSignVersion(e){return new m(e,this.appConfig).withMinVersionInclusive("1.10.0").excludeDeviceModel(T.NANO_S).check()?new m(e,this.appConfig).withMinVersionInclusive("1.12.0").check()?C("v2"):C("v1"):g}async getCalldatasContexts(e,t){const n={};for(const i in t.calldatas){const{subset:a}=t.calldatas[i],o=await this.buildFullContextFactory(this.api,{contextModule:this.contextModule,mapper:this.transactionMapper,parser:this.transactionParser,options:{},appConfig:this.appConfig,derivationPath:this.derivationPath,subset:a,deviceModelId:e.deviceModelId}).run();o.clearSigningType===M.EIP7730&&(n[i]=o.clearSignContexts)}return n}}export{W as BuildEIP712ContextTask,k as ZERO_ADDRESS};
|
|
2
2
|
//# sourceMappingURL=BuildEIP712ContextTask.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/app-binder/task/BuildEIP712ContextTask.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n type ClearSignContextSuccess,\n
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["DeviceModelId", "isSuccessCommandResult", "Just", "Nothing", "ClearSigningType", "GetChallengeCommand", "BuildFullContextsTask", "
|
|
4
|
+
"sourcesContent": ["import {\n type ClearSignContextSuccess,\n ClearSignContextType,\n type ContextModule,\n type TypedDataCalldataIndex,\n type TypedDataClearSignContextSuccess,\n} from \"@ledgerhq/context-module\";\nimport {\n DeviceModelId,\n type DeviceSessionState,\n type InternalApi,\n isSuccessCommandResult,\n} from \"@ledgerhq/device-management-kit\";\nimport { Just, type Maybe, Nothing } from \"purify-ts\";\n\nimport { type GetConfigCommandResponse } from \"@api/app-binder/GetConfigCommandTypes\";\nimport { ClearSigningType } from \"@api/model/ClearSigningType\";\nimport { type TypedData } from \"@api/model/TypedData\";\nimport { GetChallengeCommand } from \"@internal/app-binder/command/GetChallengeCommand\";\nimport {\n BuildFullContextsTask,\n type BuildFullContextsTaskArgs,\n type ContextWithSubContexts,\n} from \"@internal/app-binder/task/BuildFullContextsTask\";\nimport { type ProvideEIP712ContextTaskArgs } from \"@internal/app-binder/task/ProvideEIP712ContextTask\";\nimport { ApplicationChecker } from \"@internal/shared/utils/ApplicationChecker\";\nimport { type TransactionMapperService } from \"@internal/transaction/service/mapper/TransactionMapperService\";\nimport { type TransactionParserService } from \"@internal/transaction/service/parser/TransactionParserService\";\nimport { TypedDataValueField } from \"@internal/typed-data/model/Types\";\nimport { type TypedDataParserService } from \"@internal/typed-data/service/TypedDataParserService\";\n\nexport const ZERO_ADDRESS = \"0x0000000000000000000000000000000000000000\";\n\nexport class BuildEIP712ContextTask {\n constructor(\n private readonly api: InternalApi,\n private readonly contextModule: ContextModule,\n private readonly parser: TypedDataParserService,\n private readonly transactionParser: TransactionParserService,\n private readonly transactionMapper: TransactionMapperService,\n private readonly data: TypedData,\n private readonly derivationPath: string,\n private readonly appConfig: GetConfigCommandResponse,\n private readonly from: string,\n private readonly buildFullContextFactory = (\n api: InternalApi,\n args: BuildFullContextsTaskArgs,\n ) => new BuildFullContextsTask(api, args),\n ) {}\n\n async run(): Promise<ProvideEIP712ContextTaskArgs> {\n // Clear signing context\n // Parse the message types and values\n const parsed = this.parser.parse(this.data);\n if (parsed.isLeft()) {\n throw parsed.extract();\n }\n const { types, domain, message } = parsed.unsafeCoerce();\n\n const deviceState = this.api.getDeviceSessionState();\n const deviceModelId = deviceState.deviceModelId;\n const transactionChecks = await this.getTransactionChecks(deviceModelId);\n\n // Get clear signing context, if any\n let clearSignContext: Maybe<TypedDataClearSignContextSuccess> = Nothing;\n let calldatasContexts: Record<\n TypedDataCalldataIndex,\n ContextWithSubContexts[]\n > = {};\n const version = this.getClearSignVersion(deviceState);\n if (version.isJust()) {\n // Get challenge\n let challenge: string | undefined = undefined;\n const challengeRes = await this.api.sendCommand(\n new GetChallengeCommand(),\n );\n if (isSuccessCommandResult(challengeRes)) {\n challenge = challengeRes.data.challenge;\n }\n\n // Get filters\n const verifyingContract =\n this.data.domain.verifyingContract?.toLowerCase() || ZERO_ADDRESS;\n const chainId = this.data.domain.chainId || 0;\n const fieldsValues = message\n .filter((v) => v.value instanceof TypedDataValueField)\n .map((v) => ({\n path: v.path,\n value: (v.value as TypedDataValueField).data,\n }));\n const filters = await this.contextModule.getTypedDataFilters({\n verifyingContract,\n chainId,\n version: version.extract(),\n schema: this.data.types,\n challenge,\n deviceModelId: deviceState.deviceModelId,\n fieldsValues,\n });\n if (filters.type === \"success\") {\n clearSignContext = Just(filters);\n calldatasContexts = await this.getCalldatasContexts(\n deviceState,\n filters,\n );\n }\n }\n\n // Return the args for provide context task\n const provideTaskArgs: ProvideEIP712ContextTaskArgs = {\n derivationPath: this.derivationPath,\n transactionChecks,\n types,\n domain,\n message,\n clearSignContext,\n calldatasContexts,\n deviceModelId: deviceState.deviceModelId,\n };\n return provideTaskArgs;\n }\n\n private async getTransactionChecks(\n deviceModelId: DeviceModelId,\n ): Promise<ClearSignContextSuccess | undefined> {\n if (!this.appConfig.web3ChecksEnabled) {\n return undefined;\n }\n const contexts = await this.contextModule.getContexts(\n {\n deviceModelId,\n data: this.data,\n from: this.from,\n },\n [ClearSignContextType.TRANSACTION_CHECK],\n );\n if (\n contexts.length > 0 &&\n contexts[0]?.type === ClearSignContextType.TRANSACTION_CHECK\n ) {\n return contexts[0] as ClearSignContextSuccess;\n }\n return undefined;\n }\n\n private getClearSignVersion(\n deviceState: DeviceSessionState,\n ): Maybe<\"v1\" | \"v2\"> {\n if (\n !new ApplicationChecker(deviceState, this.appConfig)\n .withMinVersionInclusive(\"1.10.0\")\n .excludeDeviceModel(DeviceModelId.NANO_S)\n .check()\n ) {\n return Nothing;\n }\n\n // EIP712 v2 (amount & datetime filters) supported since 1.11.0:\n // https://github.com/LedgerHQ/app-ethereum/blob/develop/doc/ethapp.adoc#1110-1\n // But some issues were still present until 1.12.0 among which:\n // * V2 descriptor with missing token not supported by the app\n // * Empty arrays with filters not correctly handled\n // * Trusted name filters not yet released\n // Therefore it's safer and easier to use V1 filters before 1.12.0:\n // https://github.com/LedgerHQ/app-ethereum/blob/develop/doc/ethapp.adoc#1120\n const shouldUseV2Filters = new ApplicationChecker(\n deviceState,\n this.appConfig,\n )\n .withMinVersionInclusive(\"1.12.0\")\n .check();\n return shouldUseV2Filters ? Just(\"v2\") : Just(\"v1\");\n }\n\n private async getCalldatasContexts(\n deviceState: DeviceSessionState,\n filters: TypedDataClearSignContextSuccess,\n ): Promise<Record<TypedDataCalldataIndex, ContextWithSubContexts[]>> {\n const calldatasContexts: Record<\n TypedDataCalldataIndex,\n ContextWithSubContexts[]\n > = {};\n for (const calldataIndex in filters.calldatas) {\n const { subset } = filters.calldatas[calldataIndex]!;\n const calldataContext = await this.buildFullContextFactory(this.api, {\n contextModule: this.contextModule,\n mapper: this.transactionMapper,\n parser: this.transactionParser,\n options: {},\n appConfig: this.appConfig,\n derivationPath: this.derivationPath,\n subset,\n deviceModelId: deviceState.deviceModelId,\n }).run();\n if (calldataContext.clearSigningType === ClearSigningType.EIP7730) {\n calldatasContexts[calldataIndex] = calldataContext.clearSignContexts;\n }\n }\n return calldatasContexts;\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAEE,wBAAAA,MAIK,2BACP,OACE,iBAAAC,EAGA,0BAAAC,MACK,kCACP,OAAS,QAAAC,EAAkB,WAAAC,MAAe,YAG1C,OAAS,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,EACV,UAAW,KAAK,UAChB,eAAgB,KAAK,eACrB,OAAAD,EACA,cAAef,EAAY,aAC7B,CAAC,EAAE,IAAI,EACHgB,EAAgB,mBAAqBtC,EAAiB,UACxD0B,EAAkBU,CAAa,EAAIE,EAAgB,kBAEvD,CACA,OAAOZ,CACT,CACF",
|
|
6
|
+
"names": ["ClearSignContextType", "DeviceModelId", "isSuccessCommandResult", "Just", "Nothing", "ClearSigningType", "GetChallengeCommand", "BuildFullContextsTask", "ApplicationChecker", "TypedDataValueField", "ZERO_ADDRESS", "BuildEIP712ContextTask", "api", "contextModule", "parser", "transactionParser", "transactionMapper", "data", "derivationPath", "appConfig", "from", "buildFullContextFactory", "args", "parsed", "types", "domain", "message", "deviceState", "deviceModelId", "transactionChecks", "clearSignContext", "calldatasContexts", "version", "challenge", "challengeRes", "verifyingContract", "chainId", "fieldsValues", "v", "filters", "contexts", "calldataIndex", "subset", "calldataContext"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{TypedDataCalldataParamPresence as
|
|
1
|
+
import{ClearSignContextType as E}from"@ledgerhq/context-module";import{TypedDataCalldataParamPresence as A}from"@ledgerhq/context-module";import{CommandResultFactory as I,DeviceModelId as s,DeviceSessionStateType as x,DeviceStatus as v}from"@ledgerhq/device-management-kit";import{Just as C,Left as M,Nothing as b,Right as h}from"purify-ts";import{ClearSigningType as R}from"../../../api/model/ClearSigningType";import{makeDeviceActionInternalApiMock as F}from"../../app-binder/device-action/__test-utils__/makeInternalApi";import{PrimitiveType as T,StructType as P,TypedDataValueField as w,TypedDataValueRoot as D}from"../../typed-data/model/Types";import{BuildEIP712ContextTask as y}from"./BuildEIP712ContextTask";describe("BuildEIP712ContextTask",()=>{const n=F(),e={getFieldContext:vi.fn(),getContexts:vi.fn(),getTypedDataFilters:vi.fn()},a={parse:vi.fn()},p={extractValue:vi.fn()},m={mapTransactionToSubset:vi.fn()},l=vi.fn();function f(t){return{blindSigningEnabled:!1,web3ChecksEnabled:t,web3ChecksOptIn:!1,version:"1.13.0"}}const d={domain:{name:"Permit2",chainId:137,verifyingContract:"0x000000000022d473030f116ddee9f6b43ac78ba3"},primaryType:"PermitSingle",message:{details:{token:"0x7ceb23fd6bc0add59e62ac25578270cff1b9f619",amount:"69420000000000000000",expiration:"1718184249",nonce:"0"},spender:"0xec7be89e9d109e7e3fec59c222cf297125fefda2",sigDeadline:"1715594049"},types:{PermitSingle:[{name:"details",type:"PermitDetails"},{name:"spender",type:"address"},{name:"sigDeadline",type:"uint256"}],PermitDetails:[{name:"token",type:"address"},{name:"amount",type:"uint"},{name:"expiration",type:"uint"},{name:"nonce",type:"uint"}]}},o={PermitSingle:{details:new P("PermitDetails"),spender:new T("address","address",b),sigDeadline:new T("uint256","uint",C(32))},PermitDetails:{token:new T("address","address",b),amount:new T("uint160","uint",C(20)),expiration:new T("uint48","uint",C(6)),nonce:new T("uint48","uint",C(6))}},c=[{path:"",type:"",value:new D("EIP712Domain")},{path:"chainId",type:"uint256",value:new w(Uint8Array.from([137]))}],r=[{path:"",type:"",value:new D("PermitSingle")},{path:"details.amount",type:"uint160",value:new w(Uint8Array.from([18]))},{path:"details.expiration",type:"uint48",value:new w(Uint8Array.from([19]))}],g={type:"success",messageInfo:{displayName:"Permit2",filtersCount:1,signature:"3045022100e3c597d13d28a87a88b0239404c668373cf5063362f2a81d09eed4582941dfe802207669aabb504fd5b95b2734057f6b8bbf51f14a69a5f9bdf658a5952cefbf44d3"},trustedNamesAddresses:{},tokens:{},calldatas:{},proxy:void 0,filters:{"details.amount":{displayName:"Amount allowance",path:"details.amount",signature:"304402201a46e6b4ef89eaf9fcf4945d053bfc5616a826400fd758312fbbe976bafc07ec022025a9b408722baf983ee053f90179c75b0c55bb0668f437d55493e36069bbd5a3",tokenIndex:255,type:"amount"}}},k="0x1234",u="0x8ceb23fd6bc0add59e62ac25578270cff1b9f619";beforeEach(()=>{vi.resetAllMocks(),n.sendCommand.mockResolvedValue(I({data:{challenge:k}})),l.mockReturnValue({run:async()=>({clearSignContexts:[],clearSigningType:R.BASIC})})}),it("Build context with clear signing context not supported by the device",async()=>{const t=new y(n,e,a,p,m,d,"44'/60'/0'/0/0",f(!1),u,l);a.parse.mockReturnValueOnce(h({types:o,domain:c,message:r})),n.getDeviceSessionState.mockReturnValueOnce({sessionStateType:x.ReadyWithoutSecureChannel,deviceStatus:v.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.11.0"},deviceModelId:s.NANO_S,isSecureConnectionAllowed:!1});const i=await t.run();expect(i).toStrictEqual({deviceModelId:s.NANO_S,derivationPath:"44'/60'/0'/0/0",transactionChecks:void 0,types:o,domain:c,message:r,clearSignContext:b,calldatasContexts:{}})}),it("Build context with no clear signing context",async()=>{const t=new y(n,e,a,p,m,d,"44'/60'/0'/0/0",f(!1),u,l);a.parse.mockReturnValueOnce(h({types:o,domain:c,message:r})),n.getDeviceSessionState.mockReturnValueOnce({sessionStateType:x.ReadyWithoutSecureChannel,deviceStatus:v.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:s.FLEX,isSecureConnectionAllowed:!1}),e.getTypedDataFilters.mockResolvedValueOnce({type:E.ERROR,error:new Error("no filter")});const i=await t.run();expect(i).toStrictEqual({deviceModelId:s.FLEX,derivationPath:"44'/60'/0'/0/0",transactionChecks:void 0,types:o,domain:c,message:r,clearSignContext:b,calldatasContexts:{}})}),it("Build context with clear signing context",async()=>{const t={type:E.TRANSACTION_CHECK,payload:"web3Check"},i=new y(n,e,a,p,m,d,"44'/60'/0'/0/0",f(!1),u,l);e.getContexts.mockResolvedValueOnce([t]),a.parse.mockReturnValueOnce(h({types:o,domain:c,message:r})),n.getDeviceSessionState.mockReturnValueOnce({sessionStateType:x.ReadyWithoutSecureChannel,deviceStatus:v.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:s.FLEX,isSecureConnectionAllowed:!1}),e.getTypedDataFilters.mockResolvedValueOnce(g);const S=await i.run();expect(S).toStrictEqual({deviceModelId:s.FLEX,derivationPath:"44'/60'/0'/0/0",transactionChecks:void 0,types:o,domain:c,message:r,clearSignContext:C(g),calldatasContexts:{}}),expect(a.parse).toHaveBeenCalledWith(d),expect(e.getTypedDataFilters).toHaveBeenCalledWith({verifyingContract:"0x000000000022d473030f116ddee9f6b43ac78ba3",chainId:137,version:"v2",schema:d.types,challenge:k,deviceModelId:s.FLEX,fieldsValues:[{path:"details.amount",value:Uint8Array.from([18])},{path:"details.expiration",value:Uint8Array.from([19])}]})}),it("Build context with clear signing context and transaction checks",async()=>{const t={type:E.TRANSACTION_CHECK,payload:"transactionCheck"},i=new y(n,e,a,p,m,d,"44'/60'/0'/0/0",f(!0),u,l);e.getContexts.mockResolvedValueOnce([t]),a.parse.mockReturnValueOnce(h({types:o,domain:c,message:r})),n.getDeviceSessionState.mockReturnValueOnce({sessionStateType:x.ReadyWithoutSecureChannel,deviceStatus:v.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:s.FLEX,isSecureConnectionAllowed:!1}),e.getTypedDataFilters.mockResolvedValueOnce(g);const S=await i.run();expect(S).toStrictEqual({deviceModelId:s.FLEX,derivationPath:"44'/60'/0'/0/0",types:o,domain:c,message:r,clearSignContext:C(g),calldatasContexts:{},transactionChecks:t})}),it("Build context with clear signing context V1",async()=>{const t=new y(n,e,a,p,m,d,"44'/60'/0'/0/0",f(!1),u,l);a.parse.mockReturnValueOnce(h({types:o,domain:c,message:r})),n.getDeviceSessionState.mockReturnValueOnce({sessionStateType:x.ReadyWithoutSecureChannel,deviceStatus:v.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.11.0"},deviceModelId:s.FLEX,isSecureConnectionAllowed:!1}),e.getTypedDataFilters.mockResolvedValueOnce(g),await t.run(),expect(e.getTypedDataFilters).toHaveBeenCalledWith({verifyingContract:"0x000000000022d473030f116ddee9f6b43ac78ba3",chainId:137,version:"v1",schema:d.types,challenge:k,deviceModelId:s.FLEX,fieldsValues:[{path:"details.amount",value:Uint8Array.from([18])},{path:"details.expiration",value:Uint8Array.from([19])}]})}),it("Build context with clear signing context and calldatas",async()=>{const t=new y(n,e,a,p,m,d,"44'/60'/0'/0/0",f(!1),u,l),i={chainId:4660,data:"0x6a76120200000000000000000000000023f8abfc2824c397ccb3da89ae772984107ddb99",from:u,selector:"0x778899aa",to:"0x7ceb23fd6bc0add59e62ac25578270cff1b9f619",value:4200000000000000n},S={...g,calldatas:{0:{filter:{calldataIndex:0,displayName:"Transaction",valueFlag:!0,calleeFlag:A.Present,chainIdFlag:!1,selectorFlag:!1,amountFlag:!0,spenderFlag:A.Present,signature:"3045022100d8496ab69152efeef6a923a3ebd225334ad65dcb985814994243be7bc09bf27e02206314835816908dd6d51d3cbb0f9465d91d7ddc9104b34dd6c4247f65c551836e"},subset:i}}};a.parse.mockReturnValueOnce(h({types:o,domain:c,message:r})),n.getDeviceSessionState.mockReturnValueOnce({sessionStateType:x.ReadyWithoutSecureChannel,deviceStatus:v.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:s.FLEX,isSecureConnectionAllowed:!1}),e.getTypedDataFilters.mockResolvedValueOnce(S),l.mockReturnValue({run:async()=>({clearSignContexts:[],clearSigningType:R.EIP7730})});const O=await t.run();expect(O).toStrictEqual({deviceModelId:s.FLEX,derivationPath:"44'/60'/0'/0/0",transactionChecks:void 0,types:o,domain:c,message:r,clearSignContext:C(S),calldatasContexts:{0:[]}})}),it("Should throw an error if parsing fails",async()=>{const t=new y(n,e,a,p,m,d,"44'/60'/0'/0/0",f(!1),u,l);a.parse.mockReturnValueOnce(M(new Error("Parsing error")));try{await t.run()}catch(i){expect(i).toBeInstanceOf(Error),expect(i.message).toBe("Parsing error")}})});
|
|
2
2
|
//# sourceMappingURL=BuildEIP712ContextTask.test.js.map
|