@ledgerhq/device-signer-kit-ethereum 0.0.0-rn-hid-20250221112139 → 0.0.0-rn-ble-logs-20250416162013
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 +14 -2
- package/lib/cjs/api/app-binder/GetConfigCommandTypes.js +2 -0
- package/lib/cjs/api/app-binder/GetConfigCommandTypes.js.map +7 -0
- package/lib/cjs/api/app-binder/SignTransactionDeviceActionTypes.js +1 -1
- package/lib/cjs/api/app-binder/SignTransactionDeviceActionTypes.js.map +3 -3
- package/lib/cjs/api/app-binder/SignTypedDataDeviceActionTypes.js +1 -1
- package/lib/cjs/api/app-binder/SignTypedDataDeviceActionTypes.js.map +3 -3
- package/lib/cjs/api/index.js +1 -1
- package/lib/cjs/api/index.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/GetAppConfigurationCommand.js +2 -0
- package/lib/cjs/internal/app-binder/command/GetAppConfigurationCommand.js.map +7 -0
- package/lib/cjs/internal/app-binder/command/GetAppConfigurationCommand.test.js +2 -0
- package/lib/cjs/internal/app-binder/command/GetAppConfigurationCommand.test.js.map +7 -0
- package/lib/cjs/internal/app-binder/command/ProvideWeb3CheckCommand.js +2 -0
- package/lib/cjs/internal/app-binder/command/ProvideWeb3CheckCommand.js.map +7 -0
- package/lib/cjs/internal/app-binder/command/ProvideWeb3CheckCommand.test.js +2 -0
- package/lib/cjs/internal/app-binder/command/ProvideWeb3CheckCommand.test.js.map +7 -0
- 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/Web3CheckOptInCommand.js +2 -0
- package/lib/cjs/internal/app-binder/command/Web3CheckOptInCommand.js.map +7 -0
- package/lib/cjs/internal/app-binder/command/Web3CheckOptInCommand.test.js +2 -0
- package/lib/cjs/internal/app-binder/command/Web3CheckOptInCommand.test.js.map +7 -0
- package/lib/cjs/internal/app-binder/constant/plugins.js +1 -1
- package/lib/cjs/internal/app-binder/constant/plugins.js.map +2 -2
- 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/__test-utils__/makeInternalApi.js +1 -1
- package/lib/cjs/internal/app-binder/device-action/__test-utils__/makeInternalApi.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/BuildTransactionContextTask.js +1 -1
- package/lib/cjs/internal/app-binder/task/BuildTransactionContextTask.js.map +3 -3
- package/lib/cjs/internal/app-binder/task/BuildTransactionContextTask.test.js +1 -1
- package/lib/cjs/internal/app-binder/task/BuildTransactionContextTask.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/task/GetWeb3CheckTask.js +2 -0
- package/lib/cjs/internal/app-binder/task/GetWeb3CheckTask.js.map +7 -0
- package/lib/cjs/internal/app-binder/task/GetWeb3CheckTask.test.js +2 -0
- package/lib/cjs/internal/app-binder/task/GetWeb3CheckTask.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/ProvideTransactionContextTask.js +1 -1
- package/lib/cjs/internal/app-binder/task/ProvideTransactionContextTask.js.map +3 -3
- package/lib/cjs/internal/app-binder/task/ProvideTransactionContextTask.test.js +1 -1
- package/lib/cjs/internal/app-binder/task/ProvideTransactionContextTask.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/task/ProvideTransactionFieldDescriptionTask.js +1 -1
- package/lib/cjs/internal/app-binder/task/ProvideTransactionFieldDescriptionTask.js.map +3 -3
- package/lib/cjs/internal/app-binder/task/ProvideTransactionGenericContextTask.js +1 -1
- package/lib/cjs/internal/app-binder/task/ProvideTransactionGenericContextTask.js.map +3 -3
- package/lib/cjs/internal/app-binder/task/ProvideTransactionGenericContextTask.test.js +1 -1
- package/lib/cjs/internal/app-binder/task/ProvideTransactionGenericContextTask.test.js.map +2 -2
- package/lib/cjs/internal/shared/utils/ApplicationChecker.js +2 -0
- package/lib/cjs/internal/shared/utils/ApplicationChecker.js.map +7 -0
- package/lib/cjs/internal/shared/utils/ApplicationChecker.test.js +2 -0
- package/lib/cjs/internal/shared/utils/ApplicationChecker.test.js.map +7 -0
- package/lib/cjs/package.json +2 -2
- package/lib/esm/api/app-binder/GetConfigCommandTypes.js +1 -0
- package/lib/esm/api/app-binder/GetConfigCommandTypes.js.map +7 -0
- package/lib/esm/api/app-binder/SignTransactionDeviceActionTypes.js +1 -0
- package/lib/esm/api/app-binder/SignTransactionDeviceActionTypes.js.map +4 -4
- package/lib/esm/api/app-binder/SignTypedDataDeviceActionTypes.js +1 -0
- package/lib/esm/api/app-binder/SignTypedDataDeviceActionTypes.js.map +4 -4
- package/lib/esm/api/index.js +1 -1
- package/lib/esm/api/index.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/GetAppConfigurationCommand.js +2 -0
- package/lib/esm/internal/app-binder/command/GetAppConfigurationCommand.js.map +7 -0
- package/lib/esm/internal/app-binder/command/GetAppConfigurationCommand.test.js +2 -0
- package/lib/esm/internal/app-binder/command/GetAppConfigurationCommand.test.js.map +7 -0
- package/lib/esm/internal/app-binder/command/ProvideWeb3CheckCommand.js +2 -0
- package/lib/esm/internal/app-binder/command/ProvideWeb3CheckCommand.js.map +7 -0
- package/lib/esm/internal/app-binder/command/ProvideWeb3CheckCommand.test.js +2 -0
- package/lib/esm/internal/app-binder/command/ProvideWeb3CheckCommand.test.js.map +7 -0
- 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/Web3CheckOptInCommand.js +2 -0
- package/lib/esm/internal/app-binder/command/Web3CheckOptInCommand.js.map +7 -0
- package/lib/esm/internal/app-binder/command/Web3CheckOptInCommand.test.js +2 -0
- package/lib/esm/internal/app-binder/command/Web3CheckOptInCommand.test.js.map +7 -0
- package/lib/esm/internal/app-binder/constant/plugins.js +1 -1
- package/lib/esm/internal/app-binder/constant/plugins.js.map +2 -2
- 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/__test-utils__/makeInternalApi.js +1 -1
- package/lib/esm/internal/app-binder/device-action/__test-utils__/makeInternalApi.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/BuildTransactionContextTask.js +1 -1
- package/lib/esm/internal/app-binder/task/BuildTransactionContextTask.js.map +3 -3
- package/lib/esm/internal/app-binder/task/BuildTransactionContextTask.test.js +1 -1
- package/lib/esm/internal/app-binder/task/BuildTransactionContextTask.test.js.map +3 -3
- package/lib/esm/internal/app-binder/task/GetWeb3CheckTask.js +2 -0
- package/lib/esm/internal/app-binder/task/GetWeb3CheckTask.js.map +7 -0
- package/lib/esm/internal/app-binder/task/GetWeb3CheckTask.test.js +2 -0
- package/lib/esm/internal/app-binder/task/GetWeb3CheckTask.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/ProvideTransactionContextTask.js +1 -1
- package/lib/esm/internal/app-binder/task/ProvideTransactionContextTask.js.map +3 -3
- package/lib/esm/internal/app-binder/task/ProvideTransactionContextTask.test.js +1 -1
- package/lib/esm/internal/app-binder/task/ProvideTransactionContextTask.test.js.map +3 -3
- package/lib/esm/internal/app-binder/task/ProvideTransactionFieldDescriptionTask.js +1 -1
- package/lib/esm/internal/app-binder/task/ProvideTransactionFieldDescriptionTask.js.map +3 -3
- package/lib/esm/internal/app-binder/task/ProvideTransactionGenericContextTask.js +1 -1
- package/lib/esm/internal/app-binder/task/ProvideTransactionGenericContextTask.js.map +3 -3
- package/lib/esm/internal/app-binder/task/ProvideTransactionGenericContextTask.test.js +1 -1
- package/lib/esm/internal/app-binder/task/ProvideTransactionGenericContextTask.test.js.map +2 -2
- package/lib/esm/internal/shared/utils/ApplicationChecker.js +2 -0
- package/lib/esm/internal/shared/utils/ApplicationChecker.js.map +7 -0
- package/lib/esm/internal/shared/utils/ApplicationChecker.test.js +2 -0
- package/lib/esm/internal/shared/utils/ApplicationChecker.test.js.map +7 -0
- package/lib/esm/package.json +2 -2
- package/lib/types/api/app-binder/GetConfigCommandTypes.d.ts +7 -0
- package/lib/types/api/app-binder/GetConfigCommandTypes.d.ts.map +1 -0
- package/lib/types/api/app-binder/SignTransactionDeviceActionTypes.d.ts +15 -3
- package/lib/types/api/app-binder/SignTransactionDeviceActionTypes.d.ts.map +1 -1
- package/lib/types/api/app-binder/SignTypedDataDeviceActionTypes.d.ts +14 -1
- package/lib/types/api/app-binder/SignTypedDataDeviceActionTypes.d.ts.map +1 -1
- package/lib/types/api/index.d.ts +2 -2
- package/lib/types/api/index.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/GetAppConfigurationCommand.d.ts +10 -0
- package/lib/types/internal/app-binder/command/GetAppConfigurationCommand.d.ts.map +1 -0
- package/lib/types/internal/app-binder/command/GetAppConfigurationCommand.test.d.ts +2 -0
- package/lib/types/internal/app-binder/command/GetAppConfigurationCommand.test.d.ts.map +1 -0
- package/lib/types/internal/app-binder/command/ProvideWeb3CheckCommand.d.ts +17 -0
- package/lib/types/internal/app-binder/command/ProvideWeb3CheckCommand.d.ts.map +1 -0
- package/lib/types/internal/app-binder/command/ProvideWeb3CheckCommand.test.d.ts +2 -0
- package/lib/types/internal/app-binder/command/ProvideWeb3CheckCommand.test.d.ts.map +1 -0
- package/lib/types/internal/app-binder/command/SendEIP712FilteringCommand.d.ts +8 -1
- package/lib/types/internal/app-binder/command/SendEIP712FilteringCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/Web3CheckOptInCommand.d.ts +15 -0
- package/lib/types/internal/app-binder/command/Web3CheckOptInCommand.d.ts.map +1 -0
- package/lib/types/internal/app-binder/command/Web3CheckOptInCommand.test.d.ts +2 -0
- package/lib/types/internal/app-binder/command/Web3CheckOptInCommand.test.d.ts.map +1 -0
- package/lib/types/internal/app-binder/constant/plugins.d.ts.map +1 -1
- package/lib/types/internal/app-binder/device-action/SignTransaction/SignTransactionDeviceAction.d.ts +9 -4
- 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 +7 -0
- package/lib/types/internal/app-binder/device-action/SignTypedData/SignTypedDataDeviceAction.d.ts.map +1 -1
- package/lib/types/internal/app-binder/device-action/__test-utils__/makeInternalApi.d.ts.map +1 -1
- package/lib/types/internal/app-binder/task/BuildEIP712ContextTask.d.ts +10 -5
- package/lib/types/internal/app-binder/task/BuildEIP712ContextTask.d.ts.map +1 -1
- package/lib/types/internal/app-binder/task/BuildTransactionContextTask.d.ts +8 -3
- package/lib/types/internal/app-binder/task/BuildTransactionContextTask.d.ts.map +1 -1
- package/lib/types/internal/app-binder/task/GetWeb3CheckTask.d.ts +30 -0
- package/lib/types/internal/app-binder/task/GetWeb3CheckTask.d.ts.map +1 -0
- package/lib/types/internal/app-binder/task/GetWeb3CheckTask.test.d.ts +2 -0
- package/lib/types/internal/app-binder/task/GetWeb3CheckTask.test.d.ts.map +1 -0
- package/lib/types/internal/app-binder/task/ProvideEIP712ContextTask.d.ts +7 -2
- package/lib/types/internal/app-binder/task/ProvideEIP712ContextTask.d.ts.map +1 -1
- package/lib/types/internal/app-binder/task/ProvideTransactionContextTask.d.ts +3 -2
- package/lib/types/internal/app-binder/task/ProvideTransactionContextTask.d.ts.map +1 -1
- package/lib/types/internal/app-binder/task/ProvideTransactionFieldDescriptionTask.d.ts.map +1 -1
- package/lib/types/internal/app-binder/task/ProvideTransactionGenericContextTask.d.ts +1 -0
- package/lib/types/internal/app-binder/task/ProvideTransactionGenericContextTask.d.ts.map +1 -1
- package/lib/types/internal/shared/utils/ApplicationChecker.d.ts +13 -0
- package/lib/types/internal/shared/utils/ApplicationChecker.d.ts.map +1 -0
- package/lib/types/internal/shared/utils/ApplicationChecker.test.d.ts +2 -0
- package/lib/types/internal/shared/utils/ApplicationChecker.test.d.ts.map +1 -0
- package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
- package/package.json +8 -8
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/app-binder/task/ProvideTransactionFieldDescriptionTask.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n type ClearSignContextReference,\n type ClearSignContextSuccess,\n type ClearSignContextSuccessType,\n ClearSignContextType,\n type ContextModule,\n type PkiCertificate,\n type TransactionFieldContext,\n} from \"@ledgerhq/context-module\";\nimport {\n bufferToHexaString,\n type CommandErrorResult,\n type CommandResult,\n CommandResultFactory,\n type HexaString,\n type InternalApi,\n InvalidStatusWordError,\n isSuccessCommandResult,\n LoadCertificateCommand,\n} from \"@ledgerhq/device-management-kit\";\nimport { Just, type Maybe, Nothing } from \"purify-ts\";\n\nimport { GetChallengeCommand } from \"@internal/app-binder/command/GetChallengeCommand\";\nimport { ProvideEnumCommand } from \"@internal/app-binder/command/ProvideEnumCommand\";\nimport { ProvideNFTInformationCommand } from \"@internal/app-binder/command/ProvideNFTInformationCommand\";\nimport {\n ProvideTokenInformationCommand,\n type ProvideTokenInformationCommandResponse,\n} from \"@internal/app-binder/command/ProvideTokenInformationCommand\";\nimport { ProvideTransactionFieldDescriptionCommand } from \"@internal/app-binder/command/ProvideTransactionFieldDescriptionCommand\";\nimport { ProvideTrustedNameCommand } from \"@internal/app-binder/command/ProvideTrustedNameCommand\";\nimport { type EthErrorCodes } from \"@internal/app-binder/command/utils/ethAppErrors\";\nimport { type TransactionParserService } from \"@internal/transaction/service/parser/TransactionParserService\";\n\nimport { type ProvideTransactionGenericContextTaskErrorCodes } from \"./ProvideTransactionGenericContextTask\";\nimport { SendPayloadInChunksTask } from \"./SendPayloadInChunksTask\";\n\nexport type ProvideTransactionFieldDescriptionTaskArgs = {\n field: ClearSignContextSuccess<\n Exclude<ClearSignContextSuccessType, ClearSignContextType.ENUM>\n >;\n serializedTransaction: Uint8Array;\n chainId: number;\n transactionParser: TransactionParserService;\n contextModule: ContextModule;\n transactionEnums: ClearSignContextSuccess<ClearSignContextType.ENUM>[];\n};\n\nexport type ProvideTransactionFieldDescriptionTaskErrorCodes =\n void | EthErrorCodes;\n\n/**\n * This task is responsible for providing the transaction context to the device.\n *\n */\nexport class ProvideTransactionFieldDescriptionTask {\n constructor(\n private api: InternalApi,\n private args: ProvideTransactionFieldDescriptionTaskArgs,\n ) {}\n\n async run(): Promise<\n Maybe<\n CommandErrorResult<\n ProvideTransactionFieldDescriptionTaskErrorCodes | EthErrorCodes\n >\n >\n > {\n const { field } = this.args;\n\n // If a certificate is provided, start by loading it to the device\n await this.loadCertificate(field.certificate);\n\n // if the reference is a string, it means it is a direct address\n // and we don't need to extract the value from the transaction\n // as it is already provided in the reference\n if (\n field.reference !== undefined &&\n \"value\" in field.reference &&\n field.reference.value !== undefined\n ) {\n await this.getAndProvideContext({\n type: field.reference.type,\n chainId: this.args.chainId,\n address: field.reference.value,\n });\n }\n\n // if the reference is a path, it means we need to extract the value\n // from the transaction and provide it to the device\n if (\n field.reference !== undefined &&\n field.reference.valuePath !== undefined\n ) {\n // iterate on each reference and provide the context\n const referenceValues = this.args.transactionParser.extractValue(\n this.args.serializedTransaction,\n field.reference.valuePath,\n );\n\n if (referenceValues.isRight()) {\n for (const value of referenceValues.extract()) {\n const provideReferenceResult = await this.provideContextReference(\n field.reference,\n value,\n );\n if (provideReferenceResult.isJust()) {\n return provideReferenceResult;\n }\n }\n }\n }\n\n const transactionFieldResult = await this.provideContext({ ...field });\n if (!isSuccessCommandResult(transactionFieldResult)) {\n return Just(transactionFieldResult);\n }\n\n return Nothing;\n }\n\n /**\n * This method will load the certificate to the device if it is provided.\n *\n * @param {PkiCertificate | undefined} certificate The certificate to load to the device.\n * @returns A promise that resolves when the certificate is loaded.\n */\n private async loadCertificate(\n certificate: PkiCertificate | undefined,\n ): Promise<void> {\n if (!certificate) return;\n\n await this.api.sendCommand(\n new LoadCertificateCommand({\n keyUsage: certificate.keyUsageNumber,\n certificate: certificate.payload,\n }),\n );\n }\n\n /**\n * This method will provide the context reference to the device.\n *\n * @param {ClearSignContextReference} reference The reference to provide.\n * @param {Uint8Array} value The value of the reference.\n * @returns A promise that resolves when the context is provided.\n */\n private async provideContextReference(\n reference: ClearSignContextReference,\n value: Uint8Array,\n ): Promise<\n Maybe<\n CommandErrorResult<\n ProvideTransactionGenericContextTaskErrorCodes | EthErrorCodes\n >\n >\n > {\n if (reference.type === ClearSignContextType.ENUM) {\n return this.provideEnumContextReference(reference, value);\n }\n\n const address = bufferToHexaString(\n value.slice(Math.max(0, value.length - 20)),\n );\n\n if (reference.type === ClearSignContextType.TRUSTED_NAME) {\n return this.provideTustedNameContextReference(reference, address);\n }\n\n return this.getAndProvideContext({\n type: reference.type,\n chainId: this.args.chainId,\n address,\n });\n }\n\n /**\n * This method will provide the enum context reference to the device\n * if the enum value is found in the transaction enums mapping.\n *\n * Note: We do not need to call the context module to get the enum context\n * as it is already provided with transactionEnums mapping.\n *\n * @param {ClearSignContextReference<ClearSignContextType.ENUM>} reference The enum reference to provide.\n * @param {Uint8Array} value The value of the enum.\n * @returns A promise that resolves when the context is provided.\n */\n private async provideEnumContextReference(\n reference: ClearSignContextReference<ClearSignContextType.ENUM>,\n value: Uint8Array,\n ): Promise<\n Maybe<CommandErrorResult<ProvideTransactionGenericContextTaskErrorCodes>>\n > {\n const enumValue = value[value.length - 1];\n if (!enumValue) return Nothing;\n\n const enumDescriptor = this.args.transactionEnums.find(\n (enumContext) =>\n enumContext.value === enumValue && enumContext.id === reference.id,\n );\n if (enumDescriptor) {\n await this.loadCertificate(enumDescriptor.certificate);\n\n const provideEnumResult = await this.provideContext(enumDescriptor);\n if (!isSuccessCommandResult(provideEnumResult)) {\n return Just(provideEnumResult);\n }\n }\n return Nothing;\n }\n\n /**\n * This method will provide the trusted name context reference to the device.\n *\n * Note: We need to call the context module to get the trusted name context\n * with a challenge to ensure the trusted name is valid.\n *\n * @param {ClearSignContextReference<ClearSignContextType.TRUSTED_NAME>} reference The trusted name reference to provide.\n * @param {HexaString} address The address of the trusted name.\n * @returns A promise that resolves when the context is provided.\n */\n private async provideTustedNameContextReference(\n reference: ClearSignContextReference<ClearSignContextType.TRUSTED_NAME>,\n address: HexaString,\n ): Promise<\n Maybe<\n CommandErrorResult<\n ProvideTransactionGenericContextTaskErrorCodes | EthErrorCodes\n >\n >\n > {\n const getChallengeResult = await this.api.sendCommand(\n new GetChallengeCommand(),\n );\n if (!isSuccessCommandResult(getChallengeResult)) {\n return Just(getChallengeResult);\n }\n\n return this.getAndProvideContext({\n type: reference.type,\n chainId: this.args.chainId,\n address,\n challenge: getChallengeResult.data.challenge,\n types: reference.types,\n sources: reference.sources,\n });\n }\n\n /**\n * This method will get the context from the context module\n * and provide it to the device.\n *\n * @param {TransactionFieldContext} field The field to provide.\n * @returns A promise that resolves when the context is provided.\n */\n private async getAndProvideContext(\n field: TransactionFieldContext,\n ): Promise<\n Maybe<CommandErrorResult<ProvideTransactionGenericContextTaskErrorCodes>>\n > {\n const context = await this.args.contextModule.getContext(field);\n if (context.type !== ClearSignContextType.ERROR) {\n const provideReferenceResult = await this.provideContext(context);\n if (!isSuccessCommandResult(provideReferenceResult)) {\n return Just(provideReferenceResult);\n }\n }\n return Nothing;\n }\n\n /**\n * This method will send a command according to the clear sign context type\n * and return the command result if only one command is sent,\n * otherwise it will return the result of the command.\n *\n * @param {ClearSignContextSuccess} context The clear sign context to provide.\n * @returns A promise that resolves when the command return a command response.\n */\n private async provideContext({\n type,\n payload,\n }: ClearSignContextSuccess): Promise<\n CommandResult<\n void | ProvideTokenInformationCommandResponse,\n ProvideTransactionGenericContextTaskErrorCodes\n >\n > {\n switch (type) {\n case ClearSignContextType.NFT:\n return await this.api.sendCommand(\n new ProvideNFTInformationCommand({ payload }),\n );\n case ClearSignContextType.TOKEN:\n return await this.api.sendCommand(\n new ProvideTokenInformationCommand({ payload }),\n );\n case ClearSignContextType.TRUSTED_NAME:\n return new SendPayloadInChunksTask(this.api, {\n payload,\n commandFactory: (args) =>\n new ProvideTrustedNameCommand({\n data: args.chunkedData,\n isFirstChunk: args.isFirstChunk,\n }),\n }).run();\n case ClearSignContextType.ENUM:\n return new SendPayloadInChunksTask(this.api, {\n payload,\n commandFactory: (args) =>\n new ProvideEnumCommand({\n data: args.chunkedData,\n isFirstChunk: args.isFirstChunk,\n }),\n }).run();\n case ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION:\n return new SendPayloadInChunksTask(this.api, {\n payload,\n commandFactory: (args) =>\n new ProvideTransactionFieldDescriptionCommand({\n data: args.chunkedData,\n isFirstChunk: args.isFirstChunk,\n }),\n }).run();\n case ClearSignContextType.TRANSACTION_INFO:\n case ClearSignContextType.PLUGIN:\n case ClearSignContextType.EXTERNAL_PLUGIN:\n return CommandResultFactory({\n error: new InvalidStatusWordError(\n `The context type [${type}] is not valid as a transaction field or metadata`,\n ),\n });\n default: {\n const uncoveredType: never = type;\n return CommandResultFactory({\n error: new InvalidStatusWordError(\n `The context type [${uncoveredType}] is not covered`,\n ),\n });\n }\n }\n }\n}\n"],
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,4CAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAQO,oCACPC,EAUO,2CACPC,EAA0C,qBAE1CC,EAAoC,4DACpCC,EAAmC,2DACnCC,EAA6C,qEAC7CC,EAGO,uEACPC,EAA0D,kFAC1DC,EAA0C,
|
|
6
|
-
"names": ["ProvideTransactionFieldDescriptionTask_exports", "__export", "ProvideTransactionFieldDescriptionTask", "__toCommonJS", "import_context_module", "import_device_management_kit", "import_purify_ts", "import_GetChallengeCommand", "import_ProvideEnumCommand", "import_ProvideNFTInformationCommand", "import_ProvideTokenInformationCommand", "import_ProvideTransactionFieldDescriptionCommand", "import_ProvideTrustedNameCommand", "import_SendPayloadInChunksTask", "api", "args", "field", "referenceValues", "value", "provideReferenceResult", "transactionFieldResult", "certificate", "reference", "address", "enumValue", "enumDescriptor", "enumContext", "provideEnumResult", "getChallengeResult", "context", "type", "payload", "uncoveredType"]
|
|
4
|
+
"sourcesContent": ["import {\n type ClearSignContextReference,\n type ClearSignContextSuccess,\n type ClearSignContextSuccessType,\n ClearSignContextType,\n type ContextModule,\n type PkiCertificate,\n type TransactionFieldContext,\n} from \"@ledgerhq/context-module\";\nimport {\n bufferToHexaString,\n type CommandErrorResult,\n type CommandResult,\n CommandResultFactory,\n type HexaString,\n type InternalApi,\n InvalidStatusWordError,\n isSuccessCommandResult,\n LoadCertificateCommand,\n} from \"@ledgerhq/device-management-kit\";\nimport { Just, type Maybe, Nothing } from \"purify-ts\";\n\nimport { GetChallengeCommand } from \"@internal/app-binder/command/GetChallengeCommand\";\nimport { ProvideEnumCommand } from \"@internal/app-binder/command/ProvideEnumCommand\";\nimport { ProvideNFTInformationCommand } from \"@internal/app-binder/command/ProvideNFTInformationCommand\";\nimport {\n ProvideTokenInformationCommand,\n type ProvideTokenInformationCommandResponse,\n} from \"@internal/app-binder/command/ProvideTokenInformationCommand\";\nimport { ProvideTransactionFieldDescriptionCommand } from \"@internal/app-binder/command/ProvideTransactionFieldDescriptionCommand\";\nimport { ProvideTrustedNameCommand } from \"@internal/app-binder/command/ProvideTrustedNameCommand\";\nimport { ProvideWeb3CheckCommand } from \"@internal/app-binder/command/ProvideWeb3CheckCommand\";\nimport { type EthErrorCodes } from \"@internal/app-binder/command/utils/ethAppErrors\";\nimport { type TransactionParserService } from \"@internal/transaction/service/parser/TransactionParserService\";\n\nimport { type ProvideTransactionGenericContextTaskErrorCodes } from \"./ProvideTransactionGenericContextTask\";\nimport { SendPayloadInChunksTask } from \"./SendPayloadInChunksTask\";\n\nexport type ProvideTransactionFieldDescriptionTaskArgs = {\n field: ClearSignContextSuccess<\n Exclude<ClearSignContextSuccessType, ClearSignContextType.ENUM>\n >;\n serializedTransaction: Uint8Array;\n chainId: number;\n transactionParser: TransactionParserService;\n contextModule: ContextModule;\n transactionEnums: ClearSignContextSuccess<ClearSignContextType.ENUM>[];\n};\n\nexport type ProvideTransactionFieldDescriptionTaskErrorCodes =\n void | EthErrorCodes;\n\n/**\n * This task is responsible for providing the transaction context to the device.\n *\n */\nexport class ProvideTransactionFieldDescriptionTask {\n constructor(\n private api: InternalApi,\n private args: ProvideTransactionFieldDescriptionTaskArgs,\n ) {}\n\n async run(): Promise<\n Maybe<\n CommandErrorResult<\n ProvideTransactionFieldDescriptionTaskErrorCodes | EthErrorCodes\n >\n >\n > {\n const { field } = this.args;\n\n // If a certificate is provided, start by loading it to the device\n await this.loadCertificate(field.certificate);\n\n // if the reference is a string, it means it is a direct address\n // and we don't need to extract the value from the transaction\n // as it is already provided in the reference\n if (\n field.reference !== undefined &&\n \"value\" in field.reference &&\n field.reference.value !== undefined\n ) {\n await this.getAndProvideContext({\n type: field.reference.type,\n chainId: this.args.chainId,\n address: field.reference.value,\n });\n }\n\n // if the reference is a path, it means we need to extract the value\n // from the transaction and provide it to the device\n if (\n field.reference !== undefined &&\n field.reference.valuePath !== undefined\n ) {\n // iterate on each reference and provide the context\n const referenceValues = this.args.transactionParser.extractValue(\n this.args.serializedTransaction,\n field.reference.valuePath,\n );\n\n if (referenceValues.isRight()) {\n for (const value of referenceValues.extract()) {\n const provideReferenceResult = await this.provideContextReference(\n field.reference,\n value,\n );\n if (provideReferenceResult.isJust()) {\n return provideReferenceResult;\n }\n }\n }\n }\n\n const transactionFieldResult = await this.provideContext({ ...field });\n if (!isSuccessCommandResult(transactionFieldResult)) {\n return Just(transactionFieldResult);\n }\n\n return Nothing;\n }\n\n /**\n * This method will load the certificate to the device if it is provided.\n *\n * @param {PkiCertificate | undefined} certificate The certificate to load to the device.\n * @returns A promise that resolves when the certificate is loaded.\n */\n private async loadCertificate(\n certificate: PkiCertificate | undefined,\n ): Promise<void> {\n if (!certificate) return;\n\n await this.api.sendCommand(\n new LoadCertificateCommand({\n keyUsage: certificate.keyUsageNumber,\n certificate: certificate.payload,\n }),\n );\n }\n\n /**\n * This method will provide the context reference to the device.\n *\n * @param {ClearSignContextReference} reference The reference to provide.\n * @param {Uint8Array} value The value of the reference.\n * @returns A promise that resolves when the context is provided.\n */\n private async provideContextReference(\n reference: ClearSignContextReference,\n value: Uint8Array,\n ): Promise<\n Maybe<\n CommandErrorResult<\n ProvideTransactionGenericContextTaskErrorCodes | EthErrorCodes\n >\n >\n > {\n if (reference.type === ClearSignContextType.ENUM) {\n return this.provideEnumContextReference(reference, value);\n }\n\n const address = bufferToHexaString(\n value.slice(Math.max(0, value.length - 20)),\n );\n\n if (reference.type === ClearSignContextType.TRUSTED_NAME) {\n return this.provideTustedNameContextReference(reference, address);\n }\n\n return this.getAndProvideContext({\n type: reference.type,\n chainId: this.args.chainId,\n address,\n });\n }\n\n /**\n * This method will provide the enum context reference to the device\n * if the enum value is found in the transaction enums mapping.\n *\n * Note: We do not need to call the context module to get the enum context\n * as it is already provided with transactionEnums mapping.\n *\n * @param {ClearSignContextReference<ClearSignContextType.ENUM>} reference The enum reference to provide.\n * @param {Uint8Array} value The value of the enum.\n * @returns A promise that resolves when the context is provided.\n */\n private async provideEnumContextReference(\n reference: ClearSignContextReference<ClearSignContextType.ENUM>,\n value: Uint8Array,\n ): Promise<\n Maybe<CommandErrorResult<ProvideTransactionGenericContextTaskErrorCodes>>\n > {\n const enumValue = value[value.length - 1];\n if (!enumValue) return Nothing;\n\n const enumDescriptor = this.args.transactionEnums.find(\n (enumContext) =>\n enumContext.value === enumValue && enumContext.id === reference.id,\n );\n if (enumDescriptor) {\n await this.loadCertificate(enumDescriptor.certificate);\n\n const provideEnumResult = await this.provideContext(enumDescriptor);\n if (!isSuccessCommandResult(provideEnumResult)) {\n return Just(provideEnumResult);\n }\n }\n return Nothing;\n }\n\n /**\n * This method will provide the trusted name context reference to the device.\n *\n * Note: We need to call the context module to get the trusted name context\n * with a challenge to ensure the trusted name is valid.\n *\n * @param {ClearSignContextReference<ClearSignContextType.TRUSTED_NAME>} reference The trusted name reference to provide.\n * @param {HexaString} address The address of the trusted name.\n * @returns A promise that resolves when the context is provided.\n */\n private async provideTustedNameContextReference(\n reference: ClearSignContextReference<ClearSignContextType.TRUSTED_NAME>,\n address: HexaString,\n ): Promise<\n Maybe<\n CommandErrorResult<\n ProvideTransactionGenericContextTaskErrorCodes | EthErrorCodes\n >\n >\n > {\n const getChallengeResult = await this.api.sendCommand(\n new GetChallengeCommand(),\n );\n if (!isSuccessCommandResult(getChallengeResult)) {\n return Just(getChallengeResult);\n }\n\n return this.getAndProvideContext({\n type: reference.type,\n chainId: this.args.chainId,\n address,\n challenge: getChallengeResult.data.challenge,\n types: reference.types,\n sources: reference.sources,\n });\n }\n\n /**\n * This method will get the context from the context module\n * and provide it to the device.\n *\n * @param {TransactionFieldContext} field The field to provide.\n * @returns A promise that resolves when the context is provided.\n */\n private async getAndProvideContext(\n field: TransactionFieldContext,\n ): Promise<\n Maybe<CommandErrorResult<ProvideTransactionGenericContextTaskErrorCodes>>\n > {\n const context = await this.args.contextModule.getContext(field);\n if (context.type !== ClearSignContextType.ERROR) {\n const provideReferenceResult = await this.provideContext(context);\n if (!isSuccessCommandResult(provideReferenceResult)) {\n return Just(provideReferenceResult);\n }\n }\n return Nothing;\n }\n\n /**\n * This method will send a command according to the clear sign context type\n * and return the command result if only one command is sent,\n * otherwise it will return the result of the command.\n *\n * @param {ClearSignContextSuccess} context The clear sign context to provide.\n * @returns A promise that resolves when the command return a command response.\n */\n private async provideContext({\n type,\n payload,\n }: ClearSignContextSuccess): Promise<\n CommandResult<\n void | ProvideTokenInformationCommandResponse,\n ProvideTransactionGenericContextTaskErrorCodes\n >\n > {\n switch (type) {\n case ClearSignContextType.NFT:\n return await this.api.sendCommand(\n new ProvideNFTInformationCommand({ payload }),\n );\n case ClearSignContextType.TOKEN:\n return await this.api.sendCommand(\n new ProvideTokenInformationCommand({ payload }),\n );\n case ClearSignContextType.TRUSTED_NAME:\n return new SendPayloadInChunksTask(this.api, {\n payload,\n commandFactory: (args) =>\n new ProvideTrustedNameCommand({\n data: args.chunkedData,\n isFirstChunk: args.isFirstChunk,\n }),\n }).run();\n case ClearSignContextType.ENUM:\n return new SendPayloadInChunksTask(this.api, {\n payload,\n commandFactory: (args) =>\n new ProvideEnumCommand({\n data: args.chunkedData,\n isFirstChunk: args.isFirstChunk,\n }),\n }).run();\n case ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION:\n return new SendPayloadInChunksTask(this.api, {\n payload,\n commandFactory: (args) =>\n new ProvideTransactionFieldDescriptionCommand({\n data: args.chunkedData,\n isFirstChunk: args.isFirstChunk,\n }),\n }).run();\n case ClearSignContextType.TRANSACTION_INFO:\n case ClearSignContextType.PLUGIN:\n case ClearSignContextType.EXTERNAL_PLUGIN:\n return CommandResultFactory({\n error: new InvalidStatusWordError(\n `The context type [${type}] is not valid as a transaction field or metadata`,\n ),\n });\n case ClearSignContextType.WEB3_CHECK:\n return new SendPayloadInChunksTask(this.api, {\n payload,\n commandFactory: (args) =>\n new ProvideWeb3CheckCommand({\n payload: args.chunkedData,\n isFirstChunk: args.isFirstChunk,\n }),\n }).run();\n default: {\n const uncoveredType: never = type;\n return CommandResultFactory({\n error: new InvalidStatusWordError(\n `The context type [${uncoveredType}] is not covered`,\n ),\n });\n }\n }\n }\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,4CAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAQO,oCACPC,EAUO,2CACPC,EAA0C,qBAE1CC,EAAoC,4DACpCC,EAAmC,2DACnCC,EAA6C,qEAC7CC,EAGO,uEACPC,EAA0D,kFAC1DC,EAA0C,kEAC1CC,EAAwC,gEAKxCC,EAAwC,qCAoBjC,MAAMZ,CAAuC,CAClD,YACUa,EACAC,EACR,CAFQ,SAAAD,EACA,UAAAC,CACP,CAEH,MAAM,KAMJ,CACA,KAAM,CAAE,MAAAC,CAAM,EAAI,KAAK,KAsBvB,GAnBA,MAAM,KAAK,gBAAgBA,EAAM,WAAW,EAM1CA,EAAM,YAAc,QACpB,UAAWA,EAAM,WACjBA,EAAM,UAAU,QAAU,QAE1B,MAAM,KAAK,qBAAqB,CAC9B,KAAMA,EAAM,UAAU,KACtB,QAAS,KAAK,KAAK,QACnB,QAASA,EAAM,UAAU,KAC3B,CAAC,EAMDA,EAAM,YAAc,QACpBA,EAAM,UAAU,YAAc,OAC9B,CAEA,MAAMC,EAAkB,KAAK,KAAK,kBAAkB,aAClD,KAAK,KAAK,sBACVD,EAAM,UAAU,SAClB,EAEA,GAAIC,EAAgB,QAAQ,EAC1B,UAAWC,KAASD,EAAgB,QAAQ,EAAG,CAC7C,MAAME,EAAyB,MAAM,KAAK,wBACxCH,E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AAK,uBAAqB,iBAC1B,KAAK,uBAAqB,OAC1B,KAAK,uBAAqB,gBACxB,SAAO,wBAAqB,CAC1B,MAAO,IAAI,yBACT,qBAAqBe,CAAI,mDAC3B,CACF,CAAC,EACH,KAAK,uBAAqB,WACxB,OAAO,IAAI,0BAAwB,KAAK,IAAK,CAC3C,QAAAC,EACA,eAAiBhB,GACf,IAAI,0BAAwB,CAC1B,QAASA,EAAK,YACd,aAAcA,EAAK,YACrB,CAAC,CACL,CAAC,EAAE,IAAI,EACT,QAAS,CACP,MAAMiB,EAAuBF,EAC7B,SAAO,wBAAqB,CAC1B,MAAO,IAAI,yBACT,qBAAqBE,CAAa,kBACpC,CACF,CAAC,CACH,CACF,CACF,CACF",
|
|
6
|
+
"names": ["ProvideTransactionFieldDescriptionTask_exports", "__export", "ProvideTransactionFieldDescriptionTask", "__toCommonJS", "import_context_module", "import_device_management_kit", "import_purify_ts", "import_GetChallengeCommand", "import_ProvideEnumCommand", "import_ProvideNFTInformationCommand", "import_ProvideTokenInformationCommand", "import_ProvideTransactionFieldDescriptionCommand", "import_ProvideTrustedNameCommand", "import_ProvideWeb3CheckCommand", "import_SendPayloadInChunksTask", "api", "args", "field", "referenceValues", "value", "provideReferenceResult", "transactionFieldResult", "certificate", "reference", "address", "enumValue", "enumDescriptor", "enumContext", "provideEnumResult", "getChallengeResult", "context", "type", "payload", "uncoveredType"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var d=Object.defineProperty;var
|
|
1
|
+
"use strict";var d=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var T=Object.prototype.hasOwnProperty;var g=(a,t)=>{for(var n in t)d(a,n,{get:t[n],enumerable:!0})},k=(a,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of x(t))!T.call(a,r)&&r!==n&&d(a,r,{get:()=>t[r],enumerable:!(o=f(t,r))||o.enumerable});return a};var S=a=>k(d({},"__esModule",{value:!0}),a);var E={};g(E,{ProvideTransactionGenericContextTask:()=>P});module.exports=S(E);var i=require("@ledgerhq/device-management-kit"),l=require("@ledgerhq/signer-utils"),s=require("purify-ts"),C=require("../../app-binder/command/ProvideTransactionInformationCommand"),m=require("../../app-binder/command/StoreTransactionCommand"),p=require("./ProvideTransactionFieldDescriptionTask"),u=require("./SendCommandInChunksTask"),y=require("./SendPayloadInChunksTask");class P{constructor(t,n){this.api=t;this.args=n}async run(){const t=l.DerivationPathUtils.splitPath(this.args.derivationPath),n=new i.ByteArrayBuilder;n.add8BitUIntToData(t.length),t.forEach(e=>{n.add32BitUIntToData(e)}),n.addBufferToData(this.args.serializedTransaction);const o=await new u.SendCommandInChunksTask(this.api,{data:n.build(),commandFactory:e=>new m.StoreTransactionCommand({serializedTransaction:e.chunkedData,isFirstChunk:e.isFirstChunk})}).run();if(!(0,i.isSuccessCommandResult)(o))return(0,s.Just)(o);if(this.args.context.transactionInfoCertificate){const{keyUsageNumber:e,payload:c}=this.args.context.transactionInfoCertificate;await this.api.sendCommand(new i.LoadCertificateCommand({keyUsage:e,certificate:c}))}const r=await new y.SendPayloadInChunksTask(this.api,{payload:this.args.context.transactionInfo,commandFactory:e=>new C.ProvideTransactionInformationCommand({data:e.chunkedData,isFirstChunk:e.isFirstChunk})}).run();if(!(0,i.isSuccessCommandResult)(r))return(0,s.Just)(r);const h=this.args.web3Check?[...this.args.context.transactionFields,this.args.web3Check]:this.args.context.transactionFields;for(const e of h){const c=await new p.ProvideTransactionFieldDescriptionTask(this.api,{field:e,serializedTransaction:this.args.serializedTransaction,chainId:this.args.chainId,transactionParser:this.args.transactionParser,contextModule:this.args.contextModule,transactionEnums:this.args.context.transactionEnums}).run();if(c.isJust())return c}return s.Nothing}}0&&(module.exports={ProvideTransactionGenericContextTask});
|
|
2
2
|
//# sourceMappingURL=ProvideTransactionGenericContextTask.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/app-binder/task/ProvideTransactionGenericContextTask.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n type ClearSignContextSuccess,\n type ClearSignContextSuccessType,\n type ClearSignContextType,\n type ContextModule,\n type PkiCertificate,\n} from \"@ledgerhq/context-module\";\nimport {\n ByteArrayBuilder,\n type CommandErrorResult,\n type InternalApi,\n isSuccessCommandResult,\n LoadCertificateCommand,\n} from \"@ledgerhq/device-management-kit\";\nimport { DerivationPathUtils } from \"@ledgerhq/signer-utils\";\nimport { Just, type Maybe, Nothing } from \"purify-ts\";\n\nimport { ProvideTransactionInformationCommand } from \"@internal/app-binder/command/ProvideTransactionInformationCommand\";\nimport { StoreTransactionCommand } from \"@internal/app-binder/command/StoreTransactionCommand\";\nimport { type EthErrorCodes } from \"@internal/app-binder/command/utils/ethAppErrors\";\nimport { type TransactionParserService } from \"@internal/transaction/service/parser/TransactionParserService\";\n\nimport { ProvideTransactionFieldDescriptionTask } from \"./ProvideTransactionFieldDescriptionTask\";\nimport { SendCommandInChunksTask } from \"./SendCommandInChunksTask\";\nimport { SendPayloadInChunksTask } from \"./SendPayloadInChunksTask\";\n\nexport type GenericContext = {\n readonly transactionInfo: string;\n readonly transactionInfoCertificate: PkiCertificate;\n readonly transactionFields: ClearSignContextSuccess<\n Exclude<ClearSignContextSuccessType, ClearSignContextType.ENUM>\n >[];\n readonly transactionEnums: ClearSignContextSuccess<ClearSignContextType.ENUM>[];\n};\n\nexport type ProvideTransactionGenericContextTaskArgs = {\n readonly contextModule: ContextModule;\n readonly transactionParser: TransactionParserService;\n readonly chainId: number;\n readonly derivationPath: string;\n readonly serializedTransaction: Uint8Array;\n readonly context: GenericContext;\n};\n\nexport type ProvideTransactionGenericContextTaskErrorCodes =\n void | EthErrorCodes;\n\nexport class ProvideTransactionGenericContextTask {\n constructor(\n private api: InternalApi,\n private args: ProvideTransactionGenericContextTaskArgs,\n ) {}\n\n async run(): Promise<\n Maybe<CommandErrorResult<ProvideTransactionGenericContextTaskErrorCodes>>\n > {\n // Store the transaction in the device memory\n const paths = DerivationPathUtils.splitPath(this.args.derivationPath);\n const builder = new ByteArrayBuilder();\n builder.add8BitUIntToData(paths.length);\n paths.forEach((path) => {\n builder.add32BitUIntToData(path);\n });\n builder.addBufferToData(this.args.serializedTransaction);\n const storeTransactionResult = await new SendCommandInChunksTask(this.api, {\n data: builder.build(),\n commandFactory: (args) =>\n new StoreTransactionCommand({\n serializedTransaction: args.chunkedData,\n isFirstChunk: args.isFirstChunk,\n }),\n }).run();\n\n if (!isSuccessCommandResult(storeTransactionResult)) {\n return Just(storeTransactionResult);\n }\n\n if (this.args.context.transactionInfoCertificate) {\n const { keyUsageNumber: keyUsage, payload: certificate } =\n this.args.context.transactionInfoCertificate;\n await this.api.sendCommand(\n new LoadCertificateCommand({\n keyUsage,\n certificate,\n }),\n );\n }\n\n // Provide the transaction information\n const transactionInfoResult = await new SendPayloadInChunksTask(this.api, {\n payload: this.args.context.transactionInfo,\n commandFactory: (args) =>\n new ProvideTransactionInformationCommand({\n data: args.chunkedData,\n isFirstChunk: args.isFirstChunk,\n }),\n }).run();\n\n if (!isSuccessCommandResult(transactionInfoResult)) {\n return Just(transactionInfoResult);\n }\n\n // Provide the transaction field description and according metadata reference\n for (const field of
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,0CAAAE,IAAA,eAAAC,EAAAH,GAOA,IAAAI,EAMO,2CACPC,EAAoC,kCACpCC,EAA0C,qBAE1CC,EAAqD,6EACrDC,EAAwC,gEAIxCC,EAAuD,oDACvDC,EAAwC,qCACxCC,EAAwC,
|
|
6
|
-
"names": ["ProvideTransactionGenericContextTask_exports", "__export", "ProvideTransactionGenericContextTask", "__toCommonJS", "import_device_management_kit", "import_signer_utils", "import_purify_ts", "import_ProvideTransactionInformationCommand", "import_StoreTransactionCommand", "import_ProvideTransactionFieldDescriptionTask", "import_SendCommandInChunksTask", "import_SendPayloadInChunksTask", "api", "args", "paths", "builder", "path", "storeTransactionResult", "keyUsage", "certificate", "transactionInfoResult", "field", "result"]
|
|
4
|
+
"sourcesContent": ["import {\n type ClearSignContextSuccess,\n type ClearSignContextSuccessType,\n type ClearSignContextType,\n type ContextModule,\n type PkiCertificate,\n} from \"@ledgerhq/context-module\";\nimport {\n ByteArrayBuilder,\n type CommandErrorResult,\n type InternalApi,\n isSuccessCommandResult,\n LoadCertificateCommand,\n} from \"@ledgerhq/device-management-kit\";\nimport { DerivationPathUtils } from \"@ledgerhq/signer-utils\";\nimport { Just, type Maybe, Nothing } from \"purify-ts\";\n\nimport { ProvideTransactionInformationCommand } from \"@internal/app-binder/command/ProvideTransactionInformationCommand\";\nimport { StoreTransactionCommand } from \"@internal/app-binder/command/StoreTransactionCommand\";\nimport { type EthErrorCodes } from \"@internal/app-binder/command/utils/ethAppErrors\";\nimport { type TransactionParserService } from \"@internal/transaction/service/parser/TransactionParserService\";\n\nimport { ProvideTransactionFieldDescriptionTask } from \"./ProvideTransactionFieldDescriptionTask\";\nimport { SendCommandInChunksTask } from \"./SendCommandInChunksTask\";\nimport { SendPayloadInChunksTask } from \"./SendPayloadInChunksTask\";\n\nexport type GenericContext = {\n readonly transactionInfo: string;\n readonly transactionInfoCertificate: PkiCertificate;\n readonly transactionFields: ClearSignContextSuccess<\n Exclude<ClearSignContextSuccessType, ClearSignContextType.ENUM>\n >[];\n readonly transactionEnums: ClearSignContextSuccess<ClearSignContextType.ENUM>[];\n};\n\nexport type ProvideTransactionGenericContextTaskArgs = {\n readonly contextModule: ContextModule;\n readonly transactionParser: TransactionParserService;\n readonly chainId: number;\n readonly derivationPath: string;\n readonly serializedTransaction: Uint8Array;\n readonly context: GenericContext;\n readonly web3Check: ClearSignContextSuccess<ClearSignContextType.WEB3_CHECK> | null;\n};\n\nexport type ProvideTransactionGenericContextTaskErrorCodes =\n void | EthErrorCodes;\n\nexport class ProvideTransactionGenericContextTask {\n constructor(\n private api: InternalApi,\n private args: ProvideTransactionGenericContextTaskArgs,\n ) {}\n\n async run(): Promise<\n Maybe<CommandErrorResult<ProvideTransactionGenericContextTaskErrorCodes>>\n > {\n // Store the transaction in the device memory\n const paths = DerivationPathUtils.splitPath(this.args.derivationPath);\n const builder = new ByteArrayBuilder();\n builder.add8BitUIntToData(paths.length);\n paths.forEach((path) => {\n builder.add32BitUIntToData(path);\n });\n builder.addBufferToData(this.args.serializedTransaction);\n const storeTransactionResult = await new SendCommandInChunksTask(this.api, {\n data: builder.build(),\n commandFactory: (args) =>\n new StoreTransactionCommand({\n serializedTransaction: args.chunkedData,\n isFirstChunk: args.isFirstChunk,\n }),\n }).run();\n\n if (!isSuccessCommandResult(storeTransactionResult)) {\n return Just(storeTransactionResult);\n }\n\n if (this.args.context.transactionInfoCertificate) {\n const { keyUsageNumber: keyUsage, payload: certificate } =\n this.args.context.transactionInfoCertificate;\n await this.api.sendCommand(\n new LoadCertificateCommand({\n keyUsage,\n certificate,\n }),\n );\n }\n\n // Provide the transaction information\n const transactionInfoResult = await new SendPayloadInChunksTask(this.api, {\n payload: this.args.context.transactionInfo,\n commandFactory: (args) =>\n new ProvideTransactionInformationCommand({\n data: args.chunkedData,\n isFirstChunk: args.isFirstChunk,\n }),\n }).run();\n\n if (!isSuccessCommandResult(transactionInfoResult)) {\n return Just(transactionInfoResult);\n }\n\n // If there is a web3 check, add it to the transactionField array\n const fields = this.args.web3Check\n ? [...this.args.context.transactionFields, this.args.web3Check]\n : this.args.context.transactionFields;\n\n // Provide the transaction field description and according metadata reference\n for (const field of fields) {\n const result = await new ProvideTransactionFieldDescriptionTask(\n this.api,\n {\n field,\n serializedTransaction: this.args.serializedTransaction,\n chainId: this.args.chainId,\n transactionParser: this.args.transactionParser,\n contextModule: this.args.contextModule,\n transactionEnums: this.args.context.transactionEnums,\n },\n ).run();\n\n if (result.isJust()) {\n return result;\n }\n }\n\n return Nothing;\n }\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,0CA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AK,KAAK,QAAQ,kBAAmB,KAAK,KAAK,SAAS,EAC5D,KAAK,KAAK,QAAQ,kBAGtB,UAAWC,KAASD,EAAQ,CAC1B,MAAME,EAAS,MAAM,IAAI,yCACvB,KAAK,IACL,CACE,MAAAD,EACA,sBAAuB,KAAK,KAAK,sBACjC,QAAS,KAAK,KAAK,QACnB,kBAAmB,KAAK,KAAK,kBAC7B,cAAe,KAAK,KAAK,cACzB,iBAAkB,KAAK,KAAK,QAAQ,gBACtC,CACF,EAAE,IAAI,EAEN,GAAIC,EAAO,OAAO,EAChB,OAAOA,CAEX,CAEA,OAAO,SACT,CACF",
|
|
6
|
+
"names": ["ProvideTransactionGenericContextTask_exports", "__export", "ProvideTransactionGenericContextTask", "__toCommonJS", "import_device_management_kit", "import_signer_utils", "import_purify_ts", "import_ProvideTransactionInformationCommand", "import_StoreTransactionCommand", "import_ProvideTransactionFieldDescriptionTask", "import_SendCommandInChunksTask", "import_SendPayloadInChunksTask", "api", "args", "paths", "builder", "path", "storeTransactionResult", "keyUsage", "certificate", "transactionInfoResult", "fields", "field", "result"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var e=require("@ledgerhq/device-management-kit"),o=require("purify-ts"),m=require("../../app-binder/device-action/__test-utils__/makeInternalApi"),i=require("./ProvideTransactionFieldDescriptionTask"),r=require("./ProvideTransactionGenericContextTask"),a=require("./SendCommandInChunksTask"),c=require("./SendPayloadInChunksTask");describe("ProvideTransactionGenericContextTask",()=>{const
|
|
1
|
+
"use strict";var e=require("@ledgerhq/device-management-kit"),o=require("purify-ts"),m=require("../../app-binder/device-action/__test-utils__/makeInternalApi"),i=require("./ProvideTransactionFieldDescriptionTask"),r=require("./ProvideTransactionGenericContextTask"),a=require("./SendCommandInChunksTask"),c=require("./SendPayloadInChunksTask");describe("ProvideTransactionGenericContextTask",()=>{const C="44/60'/0'/0'/0/0",y=new Uint8Array([18,52]),l="0x5678",u=[],d=[],v=1,x={},T={},p={keyUsageNumber:0,payload:new Uint8Array([18,52])},s={derivationPath:C,serializedTransaction:y,context:{transactionInfo:l,transactionInfoCertificate:p,transactionFields:u,transactionEnums:d},chainId:v,transactionParser:x,contextModule:T,web3Check:null},n=(0,m.makeDeviceActionInternalApiMock)();describe("run",()=>{beforeEach(()=>{vi.resetAllMocks()}),describe("should return an error",()=>{it("when storeTransactionResult fail",async()=>{vi.spyOn(a.SendCommandInChunksTask.prototype,"run").mockResolvedValue((0,e.CommandResultFactory)({error:new e.InvalidStatusWordError("storeTransactionError")})),vi.spyOn(n,"sendCommand").mockResolvedValueOnce((0,e.CommandResultFactory)({data:void 0}));const t=await new r.ProvideTransactionGenericContextTask(n,s).run();expect(t).toEqual((0,o.Just)((0,e.CommandResultFactory)({error:new e.InvalidStatusWordError("storeTransactionError")})))}),it("when provideTransactionInformationResult fail",async()=>{vi.spyOn(a.SendCommandInChunksTask.prototype,"run").mockResolvedValue((0,e.CommandResultFactory)({data:"0x1234"})),vi.spyOn(c.SendPayloadInChunksTask.prototype,"run").mockResolvedValue((0,e.CommandResultFactory)({error:new e.InvalidStatusWordError("provideTransactionInformationError")})),vi.spyOn(n,"sendCommand").mockResolvedValueOnce((0,e.CommandResultFactory)({data:void 0}));const t=await new r.ProvideTransactionGenericContextTask(n,s).run();expect(t).toEqual((0,o.Just)((0,e.CommandResultFactory)({error:new e.InvalidStatusWordError("provideTransactionInformationError")})))}),it("when ProvideTransactionGenericContextTask fail",async()=>{vi.spyOn(a.SendCommandInChunksTask.prototype,"run").mockResolvedValue((0,e.CommandResultFactory)({data:"0x1234"})),vi.spyOn(c.SendPayloadInChunksTask.prototype,"run").mockResolvedValue((0,e.CommandResultFactory)({data:"0x5678"})),vi.spyOn(i.ProvideTransactionFieldDescriptionTask.prototype,"run").mockResolvedValue((0,o.Just)((0,e.CommandResultFactory)({error:new e.InvalidStatusWordError("provideTransactionGenericContextTaskError")}))),vi.spyOn(n,"sendCommand").mockResolvedValueOnce((0,e.CommandResultFactory)({data:void 0}));const t=await new r.ProvideTransactionGenericContextTask(n,{...s,context:{transactionInfo:l,transactionInfoCertificate:p,transactionFields:[{}],transactionEnums:d}}).run();expect(t).toEqual((0,o.Just)((0,e.CommandResultFactory)({error:new e.InvalidStatusWordError("provideTransactionGenericContextTaskError")})))})}),it("should call ProvideTransactionFieldDescriptionTask for each field",async()=>{const t=["field-1","field-2"];vi.spyOn(a.SendCommandInChunksTask.prototype,"run").mockResolvedValue((0,e.CommandResultFactory)({data:"0x1234"})),vi.spyOn(c.SendPayloadInChunksTask.prototype,"run").mockResolvedValue((0,e.CommandResultFactory)({data:"0x5678"})),vi.spyOn(i.ProvideTransactionFieldDescriptionTask.prototype,"run").mockResolvedValue(o.Nothing),vi.spyOn(n,"sendCommand").mockResolvedValueOnce((0,e.CommandResultFactory)({data:void 0})),await new r.ProvideTransactionGenericContextTask(n,{...s,context:{transactionInfo:l,transactionInfoCertificate:p,transactionFields:t,transactionEnums:d}}).run(),expect(i.ProvideTransactionFieldDescriptionTask.prototype.run).toHaveBeenCalledTimes(2)}),it("should return Nothing when all fields are provided",async()=>{vi.spyOn(a.SendCommandInChunksTask.prototype,"run").mockResolvedValue((0,e.CommandResultFactory)({data:"0x1234"})),vi.spyOn(c.SendPayloadInChunksTask.prototype,"run").mockResolvedValue((0,e.CommandResultFactory)({data:"0x5678"})),vi.spyOn(i.ProvideTransactionFieldDescriptionTask.prototype,"run").mockResolvedValue(o.Nothing),vi.spyOn(n,"sendCommand").mockResolvedValueOnce((0,e.CommandResultFactory)({data:void 0}));const t=await new r.ProvideTransactionGenericContextTask(n,s).run();expect(t).toEqual(o.Nothing)}),it("should load the transaction info certificate",async()=>{vi.spyOn(a.SendCommandInChunksTask.prototype,"run").mockResolvedValue((0,e.CommandResultFactory)({data:"0x1234"})),vi.spyOn(c.SendPayloadInChunksTask.prototype,"run").mockResolvedValue((0,e.CommandResultFactory)({data:"0x5678"})),vi.spyOn(i.ProvideTransactionFieldDescriptionTask.prototype,"run").mockResolvedValue(o.Nothing),await new r.ProvideTransactionGenericContextTask(n,{...s,context:{transactionInfo:l,transactionInfoCertificate:p,transactionFields:u,transactionEnums:d}}).run(),expect(n.sendCommand).toHaveBeenCalledTimes(1)})})});
|
|
2
2
|
//# sourceMappingURL=ProvideTransactionGenericContextTask.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/internal/app-binder/task/ProvideTransactionGenericContextTask.test.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n type ClearSignContextSuccess,\n type ClearSignContextSuccessType,\n type ClearSignContextType,\n type ContextModule,\n type PkiCertificate,\n} from \"@ledgerhq/context-module\";\nimport {\n type CommandErrorResult,\n CommandResultFactory,\n InvalidStatusWordError,\n} from \"@ledgerhq/device-management-kit\";\nimport { Just, Nothing } from \"purify-ts\";\n\nimport { makeDeviceActionInternalApiMock } from \"@internal/app-binder/device-action/__test-utils__/makeInternalApi\";\nimport { type TransactionParserService } from \"@internal/transaction/service/parser/TransactionParserService\";\n\nimport { ProvideTransactionFieldDescriptionTask } from \"./ProvideTransactionFieldDescriptionTask\";\nimport {\n ProvideTransactionGenericContextTask,\n type ProvideTransactionGenericContextTaskArgs,\n} from \"./ProvideTransactionGenericContextTask\";\nimport { SendCommandInChunksTask } from \"./SendCommandInChunksTask\";\nimport { SendPayloadInChunksTask } from \"./SendPayloadInChunksTask\";\n\ndescribe(\"ProvideTransactionGenericContextTask\", () => {\n const derivationPath = \"44/60'/0'/0'/0/0\";\n const serializedTransaction = new Uint8Array([0x12, 0x34]);\n const transactionInfo = \"0x5678\";\n const transactionFields: ClearSignContextSuccess<\n Exclude<ClearSignContextSuccessType, ClearSignContextType.ENUM>\n >[] = [];\n const transactionEnums: ClearSignContextSuccess<ClearSignContextType.ENUM>[] =\n [];\n const chainId = 1;\n const transactionParser = {} as TransactionParserService;\n const contextModule = {} as ContextModule;\n const transactionInfoCertificate: PkiCertificate = {\n keyUsageNumber: 0,\n payload: new Uint8Array([0x12, 0x34]),\n };\n\n const defaultArgs: ProvideTransactionGenericContextTaskArgs = {\n derivationPath,\n serializedTransaction,\n context: {\n transactionInfo,\n transactionInfoCertificate,\n transactionFields,\n transactionEnums,\n },\n chainId,\n transactionParser,\n contextModule,\n };\n\n const apiMock = makeDeviceActionInternalApiMock();\n\n describe(\"run\", () => {\n beforeEach(() => {\n vi.resetAllMocks();\n });\n\n describe(\"should return an error\", () => {\n it(\"when storeTransactionResult fail\", async () => {\n // GIVEN\n vi.spyOn(SendCommandInChunksTask.prototype, \"run\").mockResolvedValue(\n CommandResultFactory({\n error: new InvalidStatusWordError(\"storeTransactionError\"),\n }),\n );\n // loadCertificateCommand\n vi.spyOn(apiMock, \"sendCommand\").mockResolvedValueOnce(\n CommandResultFactory({\n data: undefined,\n }),\n );\n\n // WHEN\n const result = await new ProvideTransactionGenericContextTask(\n apiMock,\n defaultArgs,\n ).run();\n\n // THEN\n expect(result).toEqual(\n Just(\n CommandResultFactory({\n error: new InvalidStatusWordError(\"storeTransactionError\"),\n }),\n ),\n );\n });\n\n it(\"when provideTransactionInformationResult fail\", async () => {\n // GIVEN\n vi.spyOn(SendCommandInChunksTask.prototype, \"run\").mockResolvedValue(\n CommandResultFactory({\n data: \"0x1234\",\n }),\n );\n vi.spyOn(SendPayloadInChunksTask.prototype, \"run\").mockResolvedValue(\n CommandResultFactory({\n error: new InvalidStatusWordError(\n \"provideTransactionInformationError\",\n ),\n }),\n );\n // loadCertificateCommand\n vi.spyOn(apiMock, \"sendCommand\").mockResolvedValueOnce(\n CommandResultFactory({\n data: undefined,\n }),\n );\n\n // WHEN\n const result = await new ProvideTransactionGenericContextTask(\n apiMock,\n defaultArgs,\n ).run();\n\n // THEN\n expect(result).toEqual(\n Just(\n CommandResultFactory({\n error: new InvalidStatusWordError(\n \"provideTransactionInformationError\",\n ),\n }),\n ),\n );\n });\n\n it(\"when ProvideTransactionGenericContextTask fail\", async () => {\n // GIVEN\n vi.spyOn(SendCommandInChunksTask.prototype, \"run\").mockResolvedValue(\n CommandResultFactory({\n data: \"0x1234\",\n }),\n );\n vi.spyOn(SendPayloadInChunksTask.prototype, \"run\").mockResolvedValue(\n CommandResultFactory({\n data: \"0x5678\",\n }),\n );\n vi.spyOn(\n ProvideTransactionFieldDescriptionTask.prototype,\n \"run\",\n ).mockResolvedValue(\n Just(\n CommandResultFactory({\n error: new InvalidStatusWordError(\n \"provideTransactionGenericContextTaskError\",\n ),\n }) as CommandErrorResult,\n ),\n );\n // loadCertificateCommand\n vi.spyOn(apiMock, \"sendCommand\").mockResolvedValueOnce(\n CommandResultFactory({\n data: undefined,\n }),\n );\n\n // WHEN\n const result = await new ProvideTransactionGenericContextTask(apiMock, {\n ...defaultArgs,\n context: {\n transactionInfo,\n transactionInfoCertificate,\n transactionFields: [\n {} as ClearSignContextSuccess<ClearSignContextType.TRANSACTION_INFO>,\n ],\n transactionEnums,\n },\n }).run();\n\n // THEN\n expect(result).toEqual(\n Just(\n CommandResultFactory({\n error: new InvalidStatusWordError(\n \"provideTransactionGenericContextTaskError\",\n ),\n }),\n ),\n );\n });\n });\n\n it(\"should call ProvideTransactionFieldDescriptionTask for each field\", async () => {\n // GIVEN\n const fields: ClearSignContextSuccess<ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION>[] =\n [\n \"field-1\" as unknown as ClearSignContextSuccess<ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION>,\n \"field-2\" as unknown as ClearSignContextSuccess<ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION>,\n ];\n vi.spyOn(SendCommandInChunksTask.prototype, \"run\").mockResolvedValue(\n CommandResultFactory({\n data: \"0x1234\",\n }),\n );\n vi.spyOn(SendPayloadInChunksTask.prototype, \"run\").mockResolvedValue(\n CommandResultFactory({\n data: \"0x5678\",\n }),\n );\n vi.spyOn(\n ProvideTransactionFieldDescriptionTask.prototype,\n \"run\",\n ).mockResolvedValue(Nothing);\n // loadCertificateCommand\n vi.spyOn(apiMock, \"sendCommand\").mockResolvedValueOnce(\n CommandResultFactory({\n data: undefined,\n }),\n );\n\n // WHEN\n await new ProvideTransactionGenericContextTask(apiMock, {\n ...defaultArgs,\n context: {\n transactionInfo,\n transactionInfoCertificate,\n transactionFields: fields,\n transactionEnums,\n },\n }).run();\n\n // THEN\n expect(\n ProvideTransactionFieldDescriptionTask.prototype.run,\n ).toHaveBeenCalledTimes(2);\n });\n\n it(\"should return Nothing when all fields are provided\", async () => {\n // GIVEN\n vi.spyOn(SendCommandInChunksTask.prototype, \"run\").mockResolvedValue(\n CommandResultFactory({\n data: \"0x1234\",\n }),\n );\n vi.spyOn(SendPayloadInChunksTask.prototype, \"run\").mockResolvedValue(\n CommandResultFactory({\n data: \"0x5678\",\n }),\n );\n vi.spyOn(\n ProvideTransactionFieldDescriptionTask.prototype,\n \"run\",\n ).mockResolvedValue(Nothing);\n // loadCertificateCommand\n vi.spyOn(apiMock, \"sendCommand\").mockResolvedValueOnce(\n CommandResultFactory({\n data: undefined,\n }),\n );\n\n // WHEN\n const result = await new ProvideTransactionGenericContextTask(\n apiMock,\n defaultArgs,\n ).run();\n\n // THEN\n expect(result).toEqual(Nothing);\n });\n\n it(\"should load the transaction info certificate\", async () => {\n // GIVEN\n vi.spyOn(SendCommandInChunksTask.prototype, \"run\").mockResolvedValue(\n CommandResultFactory({\n data: \"0x1234\",\n }),\n );\n vi.spyOn(SendPayloadInChunksTask.prototype, \"run\").mockResolvedValue(\n CommandResultFactory({\n data: \"0x5678\",\n }),\n );\n vi.spyOn(\n ProvideTransactionFieldDescriptionTask.prototype,\n \"run\",\n ).mockResolvedValue(Nothing);\n\n // WHEN\n await new ProvideTransactionGenericContextTask(apiMock, {\n ...defaultArgs,\n context: {\n transactionInfo,\n transactionInfoCertificate,\n transactionFields,\n transactionEnums,\n },\n }).run();\n\n // THEN\n expect(apiMock.sendCommand).toHaveBeenCalledTimes(1);\n });\n });\n});\n"],
|
|
5
|
-
"mappings": "aAOA,IAAAA,EAIO,2CACPC,EAA8B,qBAE9BC,EAAgD,6EAGhDC,EAAuD,oDACvDC,EAGO,kDACPC,EAAwC,qCACxCC,EAAwC,qCAExC,SAAS,uCAAwC,IAAM,CACrD,MAAMC,EAAiB,mBACjBC,EAAwB,IAAI,WAAW,CAAC,GAAM,EAAI,CAAC,EACnDC,EAAkB,SAClBC,EAEA,CAAC,EACDC,EACJ,CAAC,EACGC,EAAU,EACVC,EAAoB,CAAC,EACrBC,EAAgB,CAAC,EACjBC,EAA6C,CACjD,eAAgB,EAChB,QAAS,IAAI,WAAW,CAAC,GAAM,EAAI,CAAC,CACtC,EAEMC,EAAwD,CAC5D,eAAAT,EACA,sBAAAC,EACA,QAAS,CACP,gBAAAC,EACA,2BAAAM,EACA,kBAAAL,EACA,iBAAAC,CACF,EACA,QAAAC,EACA,kBAAAC,EACA,cAAAC,
|
|
4
|
+
"sourcesContent": ["import {\n type ClearSignContextSuccess,\n type ClearSignContextSuccessType,\n type ClearSignContextType,\n type ContextModule,\n type PkiCertificate,\n} from \"@ledgerhq/context-module\";\nimport {\n type CommandErrorResult,\n CommandResultFactory,\n InvalidStatusWordError,\n} from \"@ledgerhq/device-management-kit\";\nimport { Just, Nothing } from \"purify-ts\";\n\nimport { makeDeviceActionInternalApiMock } from \"@internal/app-binder/device-action/__test-utils__/makeInternalApi\";\nimport { type TransactionParserService } from \"@internal/transaction/service/parser/TransactionParserService\";\n\nimport { ProvideTransactionFieldDescriptionTask } from \"./ProvideTransactionFieldDescriptionTask\";\nimport {\n ProvideTransactionGenericContextTask,\n type ProvideTransactionGenericContextTaskArgs,\n} from \"./ProvideTransactionGenericContextTask\";\nimport { SendCommandInChunksTask } from \"./SendCommandInChunksTask\";\nimport { SendPayloadInChunksTask } from \"./SendPayloadInChunksTask\";\n\ndescribe(\"ProvideTransactionGenericContextTask\", () => {\n const derivationPath = \"44/60'/0'/0'/0/0\";\n const serializedTransaction = new Uint8Array([0x12, 0x34]);\n const transactionInfo = \"0x5678\";\n const transactionFields: ClearSignContextSuccess<\n Exclude<ClearSignContextSuccessType, ClearSignContextType.ENUM>\n >[] = [];\n const transactionEnums: ClearSignContextSuccess<ClearSignContextType.ENUM>[] =\n [];\n const chainId = 1;\n const transactionParser = {} as TransactionParserService;\n const contextModule = {} as ContextModule;\n const transactionInfoCertificate: PkiCertificate = {\n keyUsageNumber: 0,\n payload: new Uint8Array([0x12, 0x34]),\n };\n\n const defaultArgs: ProvideTransactionGenericContextTaskArgs = {\n derivationPath,\n serializedTransaction,\n context: {\n transactionInfo,\n transactionInfoCertificate,\n transactionFields,\n transactionEnums,\n },\n chainId,\n transactionParser,\n contextModule,\n web3Check: null,\n };\n\n const apiMock = makeDeviceActionInternalApiMock();\n\n describe(\"run\", () => {\n beforeEach(() => {\n vi.resetAllMocks();\n });\n\n describe(\"should return an error\", () => {\n it(\"when storeTransactionResult fail\", async () => {\n // GIVEN\n vi.spyOn(SendCommandInChunksTask.prototype, \"run\").mockResolvedValue(\n CommandResultFactory({\n error: new InvalidStatusWordError(\"storeTransactionError\"),\n }),\n );\n // loadCertificateCommand\n vi.spyOn(apiMock, \"sendCommand\").mockResolvedValueOnce(\n CommandResultFactory({\n data: undefined,\n }),\n );\n\n // WHEN\n const result = await new ProvideTransactionGenericContextTask(\n apiMock,\n defaultArgs,\n ).run();\n\n // THEN\n expect(result).toEqual(\n Just(\n CommandResultFactory({\n error: new InvalidStatusWordError(\"storeTransactionError\"),\n }),\n ),\n );\n });\n\n it(\"when provideTransactionInformationResult fail\", async () => {\n // GIVEN\n vi.spyOn(SendCommandInChunksTask.prototype, \"run\").mockResolvedValue(\n CommandResultFactory({\n data: \"0x1234\",\n }),\n );\n vi.spyOn(SendPayloadInChunksTask.prototype, \"run\").mockResolvedValue(\n CommandResultFactory({\n error: new InvalidStatusWordError(\n \"provideTransactionInformationError\",\n ),\n }),\n );\n // loadCertificateCommand\n vi.spyOn(apiMock, \"sendCommand\").mockResolvedValueOnce(\n CommandResultFactory({\n data: undefined,\n }),\n );\n\n // WHEN\n const result = await new ProvideTransactionGenericContextTask(\n apiMock,\n defaultArgs,\n ).run();\n\n // THEN\n expect(result).toEqual(\n Just(\n CommandResultFactory({\n error: new InvalidStatusWordError(\n \"provideTransactionInformationError\",\n ),\n }),\n ),\n );\n });\n\n it(\"when ProvideTransactionGenericContextTask fail\", async () => {\n // GIVEN\n vi.spyOn(SendCommandInChunksTask.prototype, \"run\").mockResolvedValue(\n CommandResultFactory({\n data: \"0x1234\",\n }),\n );\n vi.spyOn(SendPayloadInChunksTask.prototype, \"run\").mockResolvedValue(\n CommandResultFactory({\n data: \"0x5678\",\n }),\n );\n vi.spyOn(\n ProvideTransactionFieldDescriptionTask.prototype,\n \"run\",\n ).mockResolvedValue(\n Just(\n CommandResultFactory({\n error: new InvalidStatusWordError(\n \"provideTransactionGenericContextTaskError\",\n ),\n }) as CommandErrorResult,\n ),\n );\n // loadCertificateCommand\n vi.spyOn(apiMock, \"sendCommand\").mockResolvedValueOnce(\n CommandResultFactory({\n data: undefined,\n }),\n );\n\n // WHEN\n const result = await new ProvideTransactionGenericContextTask(apiMock, {\n ...defaultArgs,\n context: {\n transactionInfo,\n transactionInfoCertificate,\n transactionFields: [\n {} as ClearSignContextSuccess<ClearSignContextType.TRANSACTION_INFO>,\n ],\n transactionEnums,\n },\n }).run();\n\n // THEN\n expect(result).toEqual(\n Just(\n CommandResultFactory({\n error: new InvalidStatusWordError(\n \"provideTransactionGenericContextTaskError\",\n ),\n }),\n ),\n );\n });\n });\n\n it(\"should call ProvideTransactionFieldDescriptionTask for each field\", async () => {\n // GIVEN\n const fields: ClearSignContextSuccess<ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION>[] =\n [\n \"field-1\" as unknown as ClearSignContextSuccess<ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION>,\n \"field-2\" as unknown as ClearSignContextSuccess<ClearSignContextType.TRANSACTION_FIELD_DESCRIPTION>,\n ];\n vi.spyOn(SendCommandInChunksTask.prototype, \"run\").mockResolvedValue(\n CommandResultFactory({\n data: \"0x1234\",\n }),\n );\n vi.spyOn(SendPayloadInChunksTask.prototype, \"run\").mockResolvedValue(\n CommandResultFactory({\n data: \"0x5678\",\n }),\n );\n vi.spyOn(\n ProvideTransactionFieldDescriptionTask.prototype,\n \"run\",\n ).mockResolvedValue(Nothing);\n // loadCertificateCommand\n vi.spyOn(apiMock, \"sendCommand\").mockResolvedValueOnce(\n CommandResultFactory({\n data: undefined,\n }),\n );\n\n // WHEN\n await new ProvideTransactionGenericContextTask(apiMock, {\n ...defaultArgs,\n context: {\n transactionInfo,\n transactionInfoCertificate,\n transactionFields: fields,\n transactionEnums,\n },\n }).run();\n\n // THEN\n expect(\n ProvideTransactionFieldDescriptionTask.prototype.run,\n ).toHaveBeenCalledTimes(2);\n });\n\n it(\"should return Nothing when all fields are provided\", async () => {\n // GIVEN\n vi.spyOn(SendCommandInChunksTask.prototype, \"run\").mockResolvedValue(\n CommandResultFactory({\n data: \"0x1234\",\n }),\n );\n vi.spyOn(SendPayloadInChunksTask.prototype, \"run\").mockResolvedValue(\n CommandResultFactory({\n data: \"0x5678\",\n }),\n );\n vi.spyOn(\n ProvideTransactionFieldDescriptionTask.prototype,\n \"run\",\n ).mockResolvedValue(Nothing);\n // loadCertificateCommand\n vi.spyOn(apiMock, \"sendCommand\").mockResolvedValueOnce(\n CommandResultFactory({\n data: undefined,\n }),\n );\n\n // WHEN\n const result = await new ProvideTransactionGenericContextTask(\n apiMock,\n defaultArgs,\n ).run();\n\n // THEN\n expect(result).toEqual(Nothing);\n });\n\n it(\"should load the transaction info certificate\", async () => {\n // GIVEN\n vi.spyOn(SendCommandInChunksTask.prototype, \"run\").mockResolvedValue(\n CommandResultFactory({\n data: \"0x1234\",\n }),\n );\n vi.spyOn(SendPayloadInChunksTask.prototype, \"run\").mockResolvedValue(\n CommandResultFactory({\n data: \"0x5678\",\n }),\n );\n vi.spyOn(\n ProvideTransactionFieldDescriptionTask.prototype,\n \"run\",\n ).mockResolvedValue(Nothing);\n\n // WHEN\n await new ProvideTransactionGenericContextTask(apiMock, {\n ...defaultArgs,\n context: {\n transactionInfo,\n transactionInfoCertificate,\n transactionFields,\n transactionEnums,\n },\n }).run();\n\n // THEN\n expect(apiMock.sendCommand).toHaveBeenCalledTimes(1);\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "aAOA,IAAAA,EAIO,2CACPC,EAA8B,qBAE9BC,EAAgD,6EAGhDC,EAAuD,oDACvDC,EAGO,kDACPC,EAAwC,qCACxCC,EAAwC,qCAExC,SAAS,uCAAwC,IAAM,CACrD,MAAMC,EAAiB,mBACjBC,EAAwB,IAAI,WAAW,CAAC,GAAM,EAAI,CAAC,EACnDC,EAAkB,SAClBC,EAEA,CAAC,EACDC,EACJ,CAAC,EACGC,EAAU,EACVC,EAAoB,CAAC,EACrBC,EAAgB,CAAC,EACjBC,EAA6C,CACjD,eAAgB,EAChB,QAAS,IAAI,WAAW,CAAC,GAAM,EAAI,CAAC,CACtC,EAEMC,EAAwD,CAC5D,eAAAT,EACA,sBAAAC,EACA,QAAS,CACP,gBAAAC,EACA,2BAAAM,EACA,kBAAAL,EACA,iBAAAC,CACF,EACA,QAAAC,EACA,kBAAAC,EACA,cAAAC,EACA,UAAW,IACb,EAEMG,KAAU,mCAAgC,EAEhD,SAAS,MAAO,IAAM,CACpB,WAAW,IAAM,CACf,GAAG,cAAc,CACnB,CAAC,EAED,SAAS,yBAA0B,IAAM,CACvC,GAAG,mCAAoC,SAAY,CAEjD,GAAG,MAAM,0BAAwB,UAAW,KAAK,EAAE,qBACjD,wBAAqB,CACnB,MAAO,IAAI,yBAAuB,uBAAuB,CAC3D,CAAC,CACH,EAEA,GAAG,MAAMA,EAAS,aAAa,EAAE,yBAC/B,wBAAqB,CACnB,KAAM,MACR,CAAC,CACH,EAGA,MAAMC,EAAS,MAAM,IAAI,uCACvBD,EACAD,CACF,EAAE,IAAI,EAGN,OAAOE,CAAM,EAAE,WACb,WACE,wBAAqB,C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uC,UACvC,KACF,EAAE,kBAAkB,SAAO,EAG3B,MAAM,IAAI,uCAAqCD,EAAS,CACtD,GAAGD,EACH,QAAS,CACP,gBAAAP,EACA,2BAAAM,EACA,kBAAAL,EACA,iBAAAC,CACF,CACF,CAAC,EAAE,IAAI,EAGP,OAAOM,EAAQ,WAAW,EAAE,sBAAsB,CAAC,CACrD,CAAC,CACH,CAAC,CACH,CAAC",
|
|
6
6
|
"names": ["import_device_management_kit", "import_purify_ts", "import_makeInternalApi", "import_ProvideTransactionFieldDescriptionTask", "import_ProvideTransactionGenericContextTask", "import_SendCommandInChunksTask", "import_SendPayloadInChunksTask", "derivationPath", "serializedTransaction", "transactionInfo", "transactionFields", "transactionEnums", "chainId", "transactionParser", "contextModule", "transactionInfoCertificate", "defaultArgs", "apiMock", "result", "fields"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var r=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var h=(i,e)=>{for(var s in e)r(i,s,{get:e[s],enumerable:!0})},f=(i,e,s,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of m(e))!c.call(i,t)&&t!==s&&r(i,t,{get:()=>e[t],enumerable:!(n=a(e,t))||n.enumerable});return i};var u=i=>f(r({},"__esModule",{value:!0}),i);var d={};h(d,{ApplicationChecker:()=>C});module.exports=u(d);var p=require("@ledgerhq/device-management-kit"),o=require("semver"),l=require("../../app-binder/constant/plugins");class C{isCompatible=!0;version="0.0.1";modelId;constructor(e,s){if(this.modelId=e.deviceModelId,e.sessionStateType===p.DeviceSessionStateType.Connected){this.isCompatible=!1;return}if(e.currentApp.name!=="Ethereum"&&!l.ETHEREUM_PLUGINS.includes(e.currentApp.name)){this.isCompatible=!1;return}e.currentApp.name==="Ethereum"?this.version=e.currentApp.version:e.currentApp.name==="Exchange"?this.isCompatible=!1:this.version=s.version}withMinVersionInclusive(e){return(0,o.gte)(this.version,e)||(this.isCompatible=!1),this}withMinVersionExclusive(e){return(0,o.gt)(this.version,e)||(this.isCompatible=!1),this}excludeDeviceModel(e){return this.modelId===e&&(this.isCompatible=!1),this}check(){return this.isCompatible}}0&&(module.exports={ApplicationChecker});
|
|
2
|
+
//# sourceMappingURL=ApplicationChecker.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/internal/shared/utils/ApplicationChecker.ts"],
|
|
4
|
+
"sourcesContent": ["import {\n type DeviceModelId,\n type DeviceSessionState,\n DeviceSessionStateType,\n} from \"@ledgerhq/device-management-kit\";\nimport { gt, gte } from \"semver\";\n\nimport { type GetConfigCommandResponse } from \"@api/app-binder/GetConfigCommandTypes\";\nimport { ETHEREUM_PLUGINS } from \"@internal/app-binder/constant/plugins\";\n\nexport class ApplicationChecker {\n private isCompatible: boolean = true;\n private version: string = \"0.0.1\";\n private modelId: DeviceModelId;\n\n constructor(\n deviceState: DeviceSessionState,\n appConfig: GetConfigCommandResponse,\n ) {\n this.modelId = deviceState.deviceModelId;\n\n // If device is not ready or app is unexpected, checker cannot be successful\n if (deviceState.sessionStateType === DeviceSessionStateType.Connected) {\n this.isCompatible = false;\n return;\n }\n if (\n deviceState.currentApp.name !== \"Ethereum\" &&\n !ETHEREUM_PLUGINS.includes(deviceState.currentApp.name)\n ) {\n this.isCompatible = false;\n return;\n }\n if (deviceState.currentApp.name === \"Ethereum\") {\n this.version = deviceState.currentApp.version;\n } else if (deviceState.currentApp.name === \"Exchange\") {\n // Exchanges flows are not compatibles with ethereum features appart from SignTx\n this.isCompatible = false;\n } else {\n // Fallback on appConfig version if a plugin is running.\n // It won't contain release candidate suffix but it should be enough for that edge case.\n this.version = appConfig.version;\n }\n }\n\n withMinVersionInclusive(version: string): ApplicationChecker {\n if (!gte(this.version, version)) {\n this.isCompatible = false;\n }\n return this;\n }\n\n withMinVersionExclusive(version: string): ApplicationChecker {\n if (!gt(this.version, version)) {\n this.isCompatible = false;\n }\n return this;\n }\n\n excludeDeviceModel(modelId: DeviceModelId): ApplicationChecker {\n if (this.modelId === modelId) {\n this.isCompatible = false;\n }\n return this;\n }\n\n check(): boolean {\n return this.isCompatible;\n }\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,wBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAIO,2CACPC,EAAwB,kBAGxBC,EAAiC,iDAE1B,MAAMJ,CAAmB,CACtB,aAAwB,GACxB,QAAkB,QAClB,QAER,YACEK,EACAC,EACA,CAIA,GAHA,KAAK,QAAUD,EAAY,cAGvBA,EAAY,mBAAqB,yBAAuB,UAAW,CACrE,KAAK,aAAe,GACpB,MACF,CACA,GACEA,EAAY,WAAW,OAAS,YAChC,CAAC,mBAAiB,SAASA,EAAY,WAAW,IAAI,EACtD,CACA,KAAK,aAAe,GACpB,MACF,CACIA,EAAY,WAAW,OAAS,WAClC,KAAK,QAAUA,EAAY,WAAW,QAC7BA,EAAY,WAAW,OAAS,WAEzC,KAAK,aAAe,GAIpB,KAAK,QAAUC,EAAU,OAE7B,CAEA,wBAAwBC,EAAqC,CAC3D,SAAK,OAAI,KAAK,QAASA,CAAO,IAC5B,KAAK,aAAe,IAEf,IACT,CAEA,wBAAwBA,EAAqC,CAC3D,SAAK,MAAG,KAAK,QAASA,CAAO,IAC3B,KAAK,aAAe,IAEf,IACT,CAEA,mBAAmBC,EAA4C,CAC7D,OAAI,KAAK,UAAYA,IACnB,KAAK,aAAe,IAEf,IACT,CAEA,OAAiB,CACf,OAAO,KAAK,YACd,CACF",
|
|
6
|
+
"names": ["ApplicationChecker_exports", "__export", "ApplicationChecker", "__toCommonJS", "import_device_management_kit", "import_semver", "import_plugins", "deviceState", "appConfig", "version", "modelId"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var e=require("@ledgerhq/device-management-kit"),s=require("./ApplicationChecker");describe("ApplicationChecker",()=>{function i(t){return{blindSigningEnabled:!1,web3ChecksEnabled:!1,web3ChecksOptIn:!1,version:t}}it("should pass the check for exclusive version",()=>{const t={sessionStateType:e.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:e.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.13.0-rc"},deviceModelId:e.DeviceModelId.FLEX,isSecureConnectionAllowed:!1},n=i("1.13.0"),c=new s.ApplicationChecker(t,n).withMinVersionExclusive("1.12.0").check();expect(c).toStrictEqual(!0)}),it("should reject the check for exclusive version",()=>{const t={sessionStateType:e.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:e.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:e.DeviceModelId.FLEX,isSecureConnectionAllowed:!1},n=i("1.12.0"),c=new s.ApplicationChecker(t,n).withMinVersionExclusive("1.12.0").check();expect(c).toStrictEqual(!1)}),it("should pass the check for inclusive version",()=>{const t={sessionStateType:e.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:e.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.12.0"},deviceModelId:e.DeviceModelId.FLEX,isSecureConnectionAllowed:!1},n=i("1.10.0"),c=new s.ApplicationChecker(t,n).withMinVersionInclusive("1.12.0").check();expect(c).toStrictEqual(!0)}),it("should reject the check for inclusive version",()=>{const t={sessionStateType:e.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:e.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.11.0"},deviceModelId:e.DeviceModelId.FLEX,isSecureConnectionAllowed:!1},n=i("1.11.0"),c=new s.ApplicationChecker(t,n).withMinVersionInclusive("1.12.0").check();expect(c).toStrictEqual(!1)}),it("should pass the check for excluded device",()=>{const t={sessionStateType:e.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:e.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.11.0"},deviceModelId:e.DeviceModelId.FLEX,isSecureConnectionAllowed:!1},n=i("1.11.0"),c=new s.ApplicationChecker(t,n).excludeDeviceModel(e.DeviceModelId.NANO_S).check();expect(c).toStrictEqual(!0)}),it("should reject the check for excluded device",()=>{const t={sessionStateType:e.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:e.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.11.0"},deviceModelId:e.DeviceModelId.FLEX,isSecureConnectionAllowed:!1},n=i("1.11.0"),c=new s.ApplicationChecker(t,n).excludeDeviceModel(e.DeviceModelId.FLEX).check();expect(c).toStrictEqual(!1)}),it("should pass the check for chained condition",()=>{const t={sessionStateType:e.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:e.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.11.0"},deviceModelId:e.DeviceModelId.FLEX,isSecureConnectionAllowed:!1},n=i("1.11.0"),c=new s.ApplicationChecker(t,n).withMinVersionInclusive("1.11.0").excludeDeviceModel(e.DeviceModelId.NANO_S).check();expect(c).toStrictEqual(!0)}),it("should reject the check for chained condition",()=>{const t={sessionStateType:e.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:e.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Ethereum",version:"1.10.0"},deviceModelId:e.DeviceModelId.FLEX,isSecureConnectionAllowed:!1},n=i("1.10.0"),c=new s.ApplicationChecker(t,n).withMinVersionInclusive("1.11.0").excludeDeviceModel(e.DeviceModelId.NANO_S).check();expect(c).toStrictEqual(!1)}),it("exchange app should not be compatible with eth features",()=>{const t={sessionStateType:e.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:e.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Exchange",version:"1.11.0-rc"},deviceModelId:e.DeviceModelId.FLEX,isSecureConnectionAllowed:!1},n=i("1.13.0"),c=new s.ApplicationChecker(t,n).check();expect(c).toStrictEqual(!1)}),it("should pass the check in plugins",()=>{const t={sessionStateType:e.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:e.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"1inch",version:"1.11.0-rc"},deviceModelId:e.DeviceModelId.FLEX,isSecureConnectionAllowed:!1},n=i("1.13.0"),c=new s.ApplicationChecker(t,n).withMinVersionExclusive("1.12.0").check();expect(c).toStrictEqual(!0)}),it("should reject the check in unknexpected app",()=>{const t={sessionStateType:e.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:e.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Bitcoin",version:"1.13.0-rc"},deviceModelId:e.DeviceModelId.FLEX,isSecureConnectionAllowed:!1},n=i("1.13.0"),c=new s.ApplicationChecker(t,n).withMinVersionExclusive("1.12.0").check();expect(c).toStrictEqual(!1)}),it("should reject the check in unknexpected state",()=>{const t={sessionStateType:e.DeviceSessionStateType.Connected,deviceStatus:e.DeviceStatus.CONNECTED,installedApps:[],currentApp:{name:"Bitcoin",version:"1.13.0-rc"},deviceModelId:e.DeviceModelId.FLEX,isSecureConnectionAllowed:!1},n=i("1.13.0"),c=new s.ApplicationChecker(t,n).withMinVersionExclusive("1.12.0").check();expect(c).toStrictEqual(!1)})});
|
|
2
|
+
//# sourceMappingURL=ApplicationChecker.test.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/internal/shared/utils/ApplicationChecker.test.ts"],
|
|
4
|
+
"sourcesContent": ["import {\n DeviceModelId,\n DeviceSessionStateType,\n DeviceStatus,\n} from \"@ledgerhq/device-management-kit\";\n\nimport type { GetConfigCommandResponse } from \"@api/app-binder/GetConfigCommandTypes\";\n\nimport { ApplicationChecker } from \"./ApplicationChecker\";\n\ndescribe(\"ApplicationChecker\", () => {\n function createAppConfig(version: string): GetConfigCommandResponse {\n return {\n blindSigningEnabled: false,\n web3ChecksEnabled: false,\n web3ChecksOptIn: false,\n version,\n };\n }\n\n it(\"should pass the check for exclusive version\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.13.0-rc\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n const config = createAppConfig(\"1.13.0\");\n // WHEN\n const result = new ApplicationChecker(state, config)\n .withMinVersionExclusive(\"1.12.0\")\n .check();\n // THEN\n expect(result).toStrictEqual(true);\n });\n\n it(\"should reject the check for exclusive version\", () => {\n // GIVEN\n const state = {\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 const config = createAppConfig(\"1.12.0\");\n // WHEN\n const result = new ApplicationChecker(state, config)\n .withMinVersionExclusive(\"1.12.0\")\n .check();\n // THEN\n expect(result).toStrictEqual(false);\n });\n\n it(\"should pass the check for inclusive version\", () => {\n // GIVEN\n const state = {\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 const config = createAppConfig(\"1.10.0\");\n // WHEN\n const result = new ApplicationChecker(state, config)\n .withMinVersionInclusive(\"1.12.0\")\n .check();\n // THEN\n expect(result).toStrictEqual(true);\n });\n\n it(\"should reject the check for inclusive version\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.11.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n const config = createAppConfig(\"1.11.0\");\n // WHEN\n const result = new ApplicationChecker(state, config)\n .withMinVersionInclusive(\"1.12.0\")\n .check();\n // THEN\n expect(result).toStrictEqual(false);\n });\n\n it(\"should pass the check for excluded device\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.11.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n const config = createAppConfig(\"1.11.0\");\n // WHEN\n const result = new ApplicationChecker(state, config)\n .excludeDeviceModel(DeviceModelId.NANO_S)\n .check();\n // THEN\n expect(result).toStrictEqual(true);\n });\n\n it(\"should reject the check for excluded device\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.11.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n const config = createAppConfig(\"1.11.0\");\n // WHEN\n const result = new ApplicationChecker(state, config)\n .excludeDeviceModel(DeviceModelId.FLEX)\n .check();\n // THEN\n expect(result).toStrictEqual(false);\n });\n\n it(\"should pass the check for chained condition\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.11.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n const config = createAppConfig(\"1.11.0\");\n // WHEN\n const result = new ApplicationChecker(state, config)\n .withMinVersionInclusive(\"1.11.0\")\n .excludeDeviceModel(DeviceModelId.NANO_S)\n .check();\n // THEN\n expect(result).toStrictEqual(true);\n });\n\n it(\"should reject the check for chained condition\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Ethereum\", version: \"1.10.0\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n const config = createAppConfig(\"1.10.0\");\n // WHEN\n const result = new ApplicationChecker(state, config)\n .withMinVersionInclusive(\"1.11.0\")\n .excludeDeviceModel(DeviceModelId.NANO_S)\n .check();\n // THEN\n expect(result).toStrictEqual(false);\n });\n\n it(\"exchange app should not be compatible with eth features\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Exchange\", version: \"1.11.0-rc\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n const config = createAppConfig(\"1.13.0\");\n // WHEN\n const result = new ApplicationChecker(state, config).check();\n // THEN\n expect(result).toStrictEqual(false);\n });\n\n it(\"should pass the check in plugins\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"1inch\", version: \"1.11.0-rc\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n const config = createAppConfig(\"1.13.0\");\n // WHEN\n const result = new ApplicationChecker(state, config)\n .withMinVersionExclusive(\"1.12.0\")\n .check();\n // THEN\n expect(result).toStrictEqual(true);\n });\n\n it(\"should reject the check in unknexpected app\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.ReadyWithoutSecureChannel,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Bitcoin\", version: \"1.13.0-rc\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n const config = createAppConfig(\"1.13.0\");\n // WHEN\n const result = new ApplicationChecker(state, config)\n .withMinVersionExclusive(\"1.12.0\")\n .check();\n // THEN\n expect(result).toStrictEqual(false);\n });\n\n it(\"should reject the check in unknexpected state\", () => {\n // GIVEN\n const state = {\n sessionStateType: DeviceSessionStateType.Connected,\n deviceStatus: DeviceStatus.CONNECTED,\n installedApps: [],\n currentApp: { name: \"Bitcoin\", version: \"1.13.0-rc\" },\n deviceModelId: DeviceModelId.FLEX,\n isSecureConnectionAllowed: false,\n };\n const config = createAppConfig(\"1.13.0\");\n // WHEN\n const result = new ApplicationChecker(state, config)\n .withMinVersionExclusive(\"1.12.0\")\n .check();\n // THEN\n expect(result).toStrictEqual(false);\n });\n});\n"],
|
|
5
|
+
"mappings": "aAAA,IAAAA,EAIO,2CAIPC,EAAmC,gCAEnC,SAAS,qBAAsB,IAAM,CACnC,SAASC,EAAgBC,EAA2C,CAClE,MAAO,CACL,oBAAqB,GACrB,kBAAmB,GACnB,gBAAiB,GACjB,QAAAA,CACF,CACF,CAEA,GAAG,8CAA+C,IAAM,CAEtD,MAAMC,EAAQ,CACZ,iBAAkB,yBAAuB,0BACzC,aAAc,eAAa,UAC3B,cAAe,CAAC,EAChB,WAAY,CAAE,KAAM,WAAY,QAAS,WAAY,EACrD,cAAe,gBAAc,KAC7B,0BAA2B,EAC7B,EACMC,EAASH,EAAgB,QAAQ,EAEjCI,EAAS,IAAI,qBAAmBF,EAAOC,CAAM,EAChD,wBAAwB,QAAQ,EAChC,MAAM,EAET,OAAOC,CAAM,EAAE,cAAc,EAAI,CACnC,CAAC,EAED,GAAG,gDAAiD,IAAM,CAExD,MAAMF,EAAQ,CACZ,iBAAkB,yBAAuB,0BACzC,aAAc,eAAa,UAC3B,cAAe,CAAC,EAChB,WAAY,CAAE,KAAM,WAAY,QAAS,QAAS,EAClD,cAAe,gBAAc,KAC7B,0BAA2B,EAC7B,EACMC,EAASH,EAAgB,QAAQ,EAEjCI,EAAS,IAAI,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S,IAAI,qBAAmBF,EAAOC,CAAM,EAAE,MAAM,EAE3D,OAAOC,CAAM,EAAE,cAAc,EAAK,CACpC,CAAC,EAED,GAAG,mCAAoC,IAAM,CAE3C,MAAMF,EAAQ,CACZ,iBAAkB,yBAAuB,0BACzC,aAAc,eAAa,UAC3B,cAAe,CAAC,EAChB,WAAY,CAAE,KAAM,QAAS,QAAS,WAAY,EAClD,cAAe,gBAAc,KAC7B,0BAA2B,EAC7B,EACMC,EAASH,EAAgB,QAAQ,EAEjCI,EAAS,IAAI,qBAAmBF,EAAOC,CAAM,EAChD,wBAAwB,QAAQ,EAChC,MAAM,EAET,OAAOC,CAAM,EAAE,cAAc,EAAI,CACnC,CAAC,EAED,GAAG,8CAA+C,IAAM,CAEtD,MAAMF,EAAQ,CACZ,iBAAkB,yBAAuB,0BACzC,aAAc,eAAa,UAC3B,cAAe,CAAC,EAChB,WAAY,CAAE,KAAM,UAAW,QAAS,WAAY,EACpD,cAAe,gBAAc,KAC7B,0BAA2B,EAC7B,EACMC,EAASH,EAAgB,QAAQ,EAEjCI,EAAS,IAAI,qBAAmBF,EAAOC,CAAM,EAChD,wBAAwB,QAAQ,EAChC,MAAM,EAET,OAAOC,CAAM,EAAE,cAAc,EAAK,CACpC,CAAC,EAED,GAAG,gDAAiD,IAAM,CAExD,MAAMF,EAAQ,CACZ,iBAAkB,yBAAuB,UACzC,aAAc,eAAa,UAC3B,cAAe,CAAC,EAChB,WAAY,CAAE,KAAM,UAAW,QAAS,WAAY,EACpD,cAAe,gBAAc,KAC7B,0BAA2B,EAC7B,EACMC,EAASH,EAAgB,QAAQ,EAEjCI,EAAS,IAAI,qBAAmBF,EAAOC,CAAM,EAChD,wBAAwB,QAAQ,EAChC,MAAM,EAET,OAAOC,CAAM,EAAE,cAAc,EAAK,CACpC,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["import_device_management_kit", "import_ApplicationChecker", "createAppConfig", "version", "state", "config", "result"]
|
|
7
|
+
}
|
package/lib/cjs/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ledgerhq/device-signer-kit-ethereum",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"exports": {
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"@ledgerhq/tsconfig-dsdk": "workspace:*",
|
|
54
54
|
"@ledgerhq/vitest-config-dmk": "workspace:*",
|
|
55
55
|
"@types/semver": "^7.5.8",
|
|
56
|
-
"rxjs": "^7.8.
|
|
56
|
+
"rxjs": "^7.8.2",
|
|
57
57
|
"ts-node": "^10.9.2"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=GetConfigCommandTypes.js.map
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
var r=(e=>(e.OPEN_APP="signer.eth.steps.openApp",e.GET_APP_CONFIG="signer.eth.steps.getAppConfig",e.WEB3_CHECKS_OPT_IN="signer.eth.steps.web3ChecksOptIn",e.BUILD_CONTEXT="signer.eth.steps.buildContext",e.PROVIDE_CONTEXT="signer.eth.steps.provideContext",e.PROVIDE_GENERIC_CONTEXT="signer.eth.steps.provideGenericContext",e.SIGN_TRANSACTION="signer.eth.steps.signTransaction",e))(r||{});export{r as SignTransactionDAStep};
|
|
1
2
|
//# sourceMappingURL=SignTransactionDeviceActionTypes.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": [],
|
|
4
|
-
"sourcesContent": [],
|
|
5
|
-
"mappings": "",
|
|
6
|
-
"names": []
|
|
3
|
+
"sources": ["../../../../src/api/app-binder/SignTransactionDeviceActionTypes.ts"],
|
|
4
|
+
"sourcesContent": ["import {\n type ClearSignContextSuccess,\n type ClearSignContextType,\n type ContextModule,\n} from \"@ledgerhq/context-module\";\nimport {\n type CommandErrorResult,\n type DeviceActionState,\n type ExecuteDeviceActionReturnType,\n type OpenAppDAError,\n type OpenAppDARequiredInteraction,\n type UserInteractionRequired,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { type GetConfigCommandResponse } from \"@api/app-binder/GetConfigCommandTypes\";\nimport { type Signature } from \"@api/model/Signature\";\nimport { type TransactionOptions } from \"@api/model/TransactionOptions\";\nimport { type TransactionType } from \"@api/model/TransactionType\";\nimport { type EthErrorCodes } from \"@internal/app-binder/command/utils/ethAppErrors\";\nimport { type GenericContext } from \"@internal/app-binder/task/ProvideTransactionGenericContextTask\";\nimport { type TransactionMapperService } from \"@internal/transaction/service/mapper/TransactionMapperService\";\nimport { type TransactionParserService } from \"@internal/transaction/service/parser/TransactionParserService\";\n\nexport enum SignTransactionDAStep {\n OPEN_APP = \"signer.eth.steps.openApp\",\n GET_APP_CONFIG = \"signer.eth.steps.getAppConfig\",\n WEB3_CHECKS_OPT_IN = \"signer.eth.steps.web3ChecksOptIn\",\n BUILD_CONTEXT = \"signer.eth.steps.buildContext\",\n PROVIDE_CONTEXT = \"signer.eth.steps.provideContext\",\n PROVIDE_GENERIC_CONTEXT = \"signer.eth.steps.provideGenericContext\",\n SIGN_TRANSACTION = \"signer.eth.steps.signTransaction\",\n}\n\nexport type SignTransactionDAOutput = Signature;\n\nexport type SignTransactionDAInput = {\n readonly derivationPath: string;\n readonly transaction: Uint8Array;\n readonly mapper: TransactionMapperService;\n readonly parser: TransactionParserService;\n readonly contextModule: ContextModule;\n readonly options: TransactionOptions;\n};\n\nexport type SignTransactionDAError =\n | OpenAppDAError\n | CommandErrorResult<EthErrorCodes>[\"error\"];\n\ntype SignTransactionDARequiredInteraction =\n | OpenAppDARequiredInteraction\n | UserInteractionRequired.Web3ChecksOptIn\n | UserInteractionRequired.SignTransaction;\n\nexport type SignTransactionDAIntermediateValue = {\n requiredUserInteraction: SignTransactionDARequiredInteraction;\n step: SignTransactionDAStep;\n};\n\nexport type SignTransactionDAState = DeviceActionState<\n SignTransactionDAOutput,\n SignTransactionDAError,\n SignTransactionDAIntermediateValue\n>;\n\nexport type SignTransactionDAInternalState = {\n readonly error: SignTransactionDAError | null;\n readonly appConfig: GetConfigCommandResponse | null;\n readonly clearSignContexts: ClearSignContextSuccess[] | GenericContext | null;\n readonly web3Check: ClearSignContextSuccess<ClearSignContextType.WEB3_CHECK> | null;\n readonly serializedTransaction: Uint8Array | null;\n readonly chainId: number | null;\n readonly transactionType: TransactionType | null;\n readonly isLegacy: boolean;\n readonly signature: Signature | null;\n};\n\nexport type SignTransactionDAReturnType = ExecuteDeviceActionReturnType<\n SignTransactionDAOutput,\n SignTransactionDAError,\n SignTransactionDAIntermediateValue\n>;\n"],
|
|
5
|
+
"mappings": "AAuBO,IAAKA,OACVA,EAAA,SAAW,2BACXA,EAAA,eAAiB,gCACjBA,EAAA,mBAAqB,mCACrBA,EAAA,cAAgB,gCAChBA,EAAA,gBAAkB,kCAClBA,EAAA,wBAA0B,yCAC1BA,EAAA,iBAAmB,mCAPTA,OAAA",
|
|
6
|
+
"names": ["SignTransactionDAStep"]
|
|
7
7
|
}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
var t=(e=>(e.OPEN_APP="signer.eth.steps.openApp",e.GET_APP_CONFIG="signer.eth.steps.getAppConfig",e.WEB3_CHECKS_OPT_IN="signer.eth.steps.web3ChecksOptIn",e.BUILD_CONTEXT="signer.eth.steps.buildContext",e.PROVIDE_CONTEXT="signer.eth.steps.provideContext",e.PROVIDE_GENERIC_CONTEXT="signer.eth.steps.provideGenericContext",e.SIGN_TYPED_DATA="signer.eth.steps.signTypedData",e.SIGN_TYPED_DATA_LEGACY="signer.eth.steps.signTypedDataLegacy",e))(t||{});export{t as SignTypedDataDAStateStep};
|
|
1
2
|
//# sourceMappingURL=SignTypedDataDeviceActionTypes.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": [],
|
|
4
|
-
"sourcesContent": [],
|
|
5
|
-
"mappings": "",
|
|
6
|
-
"names": []
|
|
3
|
+
"sources": ["../../../../src/api/app-binder/SignTypedDataDeviceActionTypes.ts"],
|
|
4
|
+
"sourcesContent": ["import { type ContextModule } from \"@ledgerhq/context-module\";\nimport {\n type CommandErrorResult,\n type DeviceActionState,\n type ExecuteDeviceActionReturnType,\n type OpenAppDAError,\n type OpenAppDARequiredInteraction,\n type UserInteractionRequired,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { type GetConfigCommandResponse } from \"@api/app-binder/GetConfigCommandTypes\";\nimport { type Signature } from \"@api/model/Signature\";\nimport { type TypedData } from \"@api/model/TypedData\";\nimport { type EthErrorCodes } from \"@internal/app-binder/command/utils/ethAppErrors\";\nimport type { ProvideEIP712ContextTaskArgs } from \"@internal/app-binder/task/ProvideEIP712ContextTask\";\nimport { type TypedDataParserService } from \"@internal/typed-data/service/TypedDataParserService\";\n\nexport enum SignTypedDataDAStateStep {\n OPEN_APP = \"signer.eth.steps.openApp\",\n GET_APP_CONFIG = \"signer.eth.steps.getAppConfig\",\n WEB3_CHECKS_OPT_IN = \"signer.eth.steps.web3ChecksOptIn\",\n BUILD_CONTEXT = \"signer.eth.steps.buildContext\",\n PROVIDE_CONTEXT = \"signer.eth.steps.provideContext\",\n PROVIDE_GENERIC_CONTEXT = \"signer.eth.steps.provideGenericContext\",\n SIGN_TYPED_DATA = \"signer.eth.steps.signTypedData\",\n SIGN_TYPED_DATA_LEGACY = \"signer.eth.steps.signTypedDataLegacy\",\n}\n\nexport type SignTypedDataDAOutput = Signature;\n\nexport type SignTypedDataDAInput = {\n readonly derivationPath: string;\n readonly data: TypedData;\n readonly parser: TypedDataParserService;\n readonly contextModule: ContextModule;\n};\n\nexport type SignTypedDataDAError =\n | OpenAppDAError\n | CommandErrorResult<EthErrorCodes>[\"error\"];\n\ntype SignTypedDataDARequiredInteraction =\n | OpenAppDARequiredInteraction\n | UserInteractionRequired.Web3ChecksOptIn\n | UserInteractionRequired.SignTypedData;\n\nexport type SignTypedDataDAIntermediateValue = {\n requiredUserInteraction: SignTypedDataDARequiredInteraction;\n step: SignTypedDataDAStateStep;\n};\n\nexport type SignTypedDataDAState = DeviceActionState<\n SignTypedDataDAOutput,\n SignTypedDataDAError,\n SignTypedDataDAIntermediateValue\n>;\n\nexport type SignTypedDataDAInternalState = {\n readonly error: SignTypedDataDAError | null;\n readonly appConfig: GetConfigCommandResponse | null;\n readonly typedDataContext: ProvideEIP712ContextTaskArgs | null;\n readonly signature: Signature | null;\n};\n\nexport type SignTypedDataDAReturnType = ExecuteDeviceActionReturnType<\n SignTypedDataDAOutput,\n SignTypedDataDAError,\n SignTypedDataDAIntermediateValue\n>;\n"],
|
|
5
|
+
"mappings": "AAiBO,IAAKA,OACVA,EAAA,SAAW,2BACXA,EAAA,eAAiB,gCACjBA,EAAA,mBAAqB,mCACrBA,EAAA,cAAgB,gCAChBA,EAAA,gBAAkB,kCAClBA,EAAA,wBAA0B,yCAC1BA,EAAA,gBAAkB,iCAClBA,EAAA,uBAAyB,uCARfA,OAAA",
|
|
6
|
+
"names": ["SignTypedDataDAStateStep"]
|
|
7
7
|
}
|
package/lib/esm/api/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export*from"./app-binder/GetAddressDeviceActionTypes";export*from"./model/Address";export*from"./model/AddressOptions";export*from"./model/Signature";export*from"./model/TransactionOptions";export*from"./model/TransactionType";export*from"./model/TypedData";export*from"./SignerEth";export*from"./SignerEthBuilder";
|
|
1
|
+
export*from"./app-binder/GetAddressDeviceActionTypes";import{SignTransactionDAStep as a}from"./app-binder/SignTransactionDeviceActionTypes";import{SignTypedDataDAStateStep as n}from"./app-binder/SignTypedDataDeviceActionTypes";export*from"./model/Address";export*from"./model/AddressOptions";export*from"./model/Signature";export*from"./model/TransactionOptions";export*from"./model/TransactionType";export*from"./model/TypedData";export*from"./SignerEth";export*from"./SignerEthBuilder";export{a as SignTransactionDAStep,n as SignTypedDataDAStateStep};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/lib/esm/api/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/api/index.ts"],
|
|
4
|
-
"sourcesContent": ["export * from \"@api/app-binder/GetAddressDeviceActionTypes\";\nexport type {\n SignPersonalMessageDAError,\n SignPersonalMessageDAIntermediateValue,\n SignPersonalMessageDAOutput,\n} from \"@api/app-binder/SignPersonalMessageDeviceActionTypes\";\nexport
|
|
5
|
-
"mappings": "AAAA,WAAc,
|
|
6
|
-
"names": []
|
|
4
|
+
"sourcesContent": ["export * from \"@api/app-binder/GetAddressDeviceActionTypes\";\nexport type {\n SignPersonalMessageDAError,\n SignPersonalMessageDAIntermediateValue,\n SignPersonalMessageDAOutput,\n} from \"@api/app-binder/SignPersonalMessageDeviceActionTypes\";\nexport {\n type SignTransactionDAError,\n type SignTransactionDAInput,\n type SignTransactionDAIntermediateValue,\n type SignTransactionDAOutput,\n type SignTransactionDAState,\n SignTransactionDAStep,\n} from \"@api/app-binder/SignTransactionDeviceActionTypes\";\nexport {\n type SignTypedDataDAError,\n type SignTypedDataDAInput,\n type SignTypedDataDAIntermediateValue,\n type SignTypedDataDAOutput,\n type SignTypedDataDAState,\n SignTypedDataDAStateStep,\n} from \"@api/app-binder/SignTypedDataDeviceActionTypes\";\nexport * from \"@api/model/Address\";\nexport * from \"@api/model/AddressOptions\";\nexport * from \"@api/model/Signature\";\nexport * from \"@api/model/TransactionOptions\";\nexport * from \"@api/model/TransactionType\";\nexport * from \"@api/model/TypedData\";\nexport * from \"@api/SignerEth\";\nexport * from \"@api/SignerEthBuilder\";\n"],
|
|
5
|
+
"mappings": "AAAA,WAAc,8CAMd,OAME,yBAAAA,MACK,mDACP,OAME,4BAAAC,MACK,iDACP,WAAc,qBACd,WAAc,4BACd,WAAc,uBACd,WAAc,gCACd,WAAc,6BACd,WAAc,uBACd,WAAc,iBACd,WAAc",
|
|
6
|
+
"names": ["SignTransactionDAStep", "SignTypedDataDAStateStep"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{hexaStringToBuffer as v}from"@ledgerhq/device-management-kit";import{DeviceActionStatus as c}from"@ledgerhq/device-management-kit";import{SendCommandInAppDeviceAction as g}from"@ledgerhq/device-management-kit";import{UserInteractionRequired as S}from"@ledgerhq/device-management-kit";import{Transaction as y}from"ethers";import{from as A}from"rxjs";import{GetAddressCommand as h}from"./command/GetAddressCommand";import{ETHEREUM_PLUGINS as f}from"./constant/plugins";import{EthAppBinder as l}from"./EthAppBinder";describe("EthAppBinder",()=>{const a={sendCommand:vi.fn(),executeDeviceAction:vi.fn()},u={getContext:vi.fn(),getContexts:vi.fn(),getTypedDataFilters:vi.fn()},m={mapTransactionToSubset:vi.fn()},D={extractValue:vi.fn()};beforeEach(()=>{vi.clearAllMocks()}),describe("getAddress",()=>{it("should return the address, publicKey, and chainCode",()=>new Promise((s,r)=>{const e="0xF7C69BedB292Dd3fC2cA4103989B5BD705164c43",i="04e3785ca";vi.spyOn(a,"executeDeviceAction").mockReturnValue({observable:A([{status:c.Completed,output:{address:e,publicKey:i,chainCode:void 0}}]),cancel:vi.fn()});const p=new l(a,u,m,D,"sessionId"),{observable:o}=p.getAddress({derivationPath:"44'/60'/3'/2/1"}),t=[];o.subscribe({next:n=>{t.push(n)},error:n=>{r(n)},complete:()=>{try{expect(t).toEqual([{status:c.Completed,output:{address:e,publicKey:i,chainCode:void 0}}]),s()}catch(n){r(n)}}})})),describe("calls of executeDeviceAction with the correct params",()=>{const s={derivationPath:"44'/60'/3'/2/1",returnChainCode:!1};test("when checkOnDevice is true: UserInteractionRequired.VerifyAddress",()=>{const e={...s,checkOnDevice:!0};new l(a,u,m,D,"sessionId").getAddress(e),expect(a.executeDeviceAction).toHaveBeenCalledWith({sessionId:"sessionId",deviceAction:new g({input:{command:new h(e),appName:"Ethereum",requiredUserInteraction:S.VerifyAddress,compatibleAppNames:f}})})}),test("when checkOnDevice is false: UserInteractionRequired.None",()=>{const e={...s,checkOnDevice:!1};new l(a,u,m,D,"sessionId").getAddress(e),expect(a.executeDeviceAction).toHaveBeenCalledWith({sessionId:"sessionId",deviceAction:new g({input:{command:new h(e),appName:"Ethereum",requiredUserInteraction:S.None,compatibleAppNames:f}})})})})}),describe("signTransaction",()=>{it("should return the signature",()=>new Promise((s,r)=>{const e={r:"0xDEAD",s:"0xBEEF",v:0},i=v(y.from({to:"0x1234567890123456789012345678901234567890",value:0n}).unsignedSerialized),d={};vi.spyOn(a,"executeDeviceAction").mockReturnValue({observable:A([{status:c.Completed,output:e}]),cancel:vi.fn()});const p=new l(a,u,m,D,"sessionId"),{observable:o}=p.signTransaction({derivationPath:"44'/60'/3'/2/1",transaction:i,options:d}),t=[];o.subscribe({next:n=>{t.push(n)},error:n=>{r(n)},complete:()=>{try{expect(t).toEqual([{status:c.Completed,output:e}]),s()}catch(n){r(n)}}})})),it("should return the signature without options",()=>new Promise((s,r)=>{const e={r:"0xDEAD",s:"0xBEEF",v:0},i=v(y.from({to:"0x1234567890123456789012345678901234567890",value:0n}).unsignedSerialized);vi.spyOn(a,"executeDeviceAction").mockReturnValue({observable:A([{status:c.Completed,output:e}]),cancel:vi.fn()});const d=new l(a,u,m,D,"sessionId"),{observable:p}=d.signTransaction({derivationPath:"44'/60'/3'/2/1",transaction:i,options:void 0}),o=[];p.subscribe({next:t=>{o.push(t)},error:t=>{r(t)},complete:()=>{try{expect(o).toEqual([{status:c.Completed,output:e}]),s()}catch(t){r(t)}}})}))}),describe("signMessage",()=>{it("should return the signature",()=>new Promise((s,r)=>{const e={r:"0xDEAD",s:"0xBEEF",v:0},i="Hello, World!";vi.spyOn(a,"executeDeviceAction").mockReturnValue({observable:A([{status:c.Completed,output:e}]),cancel:vi.fn()});const d=new l(a,u,m,D,"sessionId"),{observable:p}=d.signPersonalMessage({derivationPath:"44'/60'/3'/2/1",message:i}),o=[];p.subscribe({next:t=>{o.push(t)},error:t=>{r(t)},complete:()=>{try{expect(o).toEqual([{status:c.Completed,output:e}]),s()}catch(t){r(t)}}})}))}),describe("signTypedData",()=>{it("should return the signature",()=>new Promise((s,r)=>{const e={r:"0xDEAD",s:"0xBEEF",v:0},i={domain:{},types:{},primaryType:"test",message:{}},d={parse:vi.fn()};vi.spyOn(a,"executeDeviceAction").mockReturnValue({observable:A([{status:c.Completed,output:e}]),cancel:vi.fn()});const p=new l(a,u,m,D,"sessionId"),{observable:o}=p.signTypedData({derivationPath:"44'/60'/3'/2/1",parser:d,data:i}),t=[];o.subscribe({next:n=>{t.push(n)},error:n=>{r(n)},complete:()=>{try{expect(t).toEqual([{status:c.Completed,output:e}]),s()}catch(n){r(n)}}})}))})});
|
|
1
|
+
import{hexaStringToBuffer as v}from"@ledgerhq/device-management-kit";import{DeviceActionStatus as c}from"@ledgerhq/device-management-kit";import{SendCommandInAppDeviceAction as g}from"@ledgerhq/device-management-kit";import{UserInteractionRequired as S}from"@ledgerhq/device-management-kit";import{Transaction as y}from"ethers";import{from as A}from"rxjs";import{GetAddressCommand as h}from"./command/GetAddressCommand";import{ETHEREUM_PLUGINS as f}from"./constant/plugins";import{EthAppBinder as l}from"./EthAppBinder";describe("EthAppBinder",()=>{const a={sendCommand:vi.fn(),executeDeviceAction:vi.fn()},u={getContext:vi.fn(),getContexts:vi.fn(),getTypedDataFilters:vi.fn(),getWeb3Checks:vi.fn()},m={mapTransactionToSubset:vi.fn()},D={extractValue:vi.fn()};beforeEach(()=>{vi.clearAllMocks()}),describe("getAddress",()=>{it("should return the address, publicKey, and chainCode",()=>new Promise((s,r)=>{const e="0xF7C69BedB292Dd3fC2cA4103989B5BD705164c43",i="04e3785ca";vi.spyOn(a,"executeDeviceAction").mockReturnValue({observable:A([{status:c.Completed,output:{address:e,publicKey:i,chainCode:void 0}}]),cancel:vi.fn()});const p=new l(a,u,m,D,"sessionId"),{observable:o}=p.getAddress({derivationPath:"44'/60'/3'/2/1"}),t=[];o.subscribe({next:n=>{t.push(n)},error:n=>{r(n)},complete:()=>{try{expect(t).toEqual([{status:c.Completed,output:{address:e,publicKey:i,chainCode:void 0}}]),s()}catch(n){r(n)}}})})),describe("calls of executeDeviceAction with the correct params",()=>{const s={derivationPath:"44'/60'/3'/2/1",returnChainCode:!1};test("when checkOnDevice is true: UserInteractionRequired.VerifyAddress",()=>{const e={...s,checkOnDevice:!0};new l(a,u,m,D,"sessionId").getAddress(e),expect(a.executeDeviceAction).toHaveBeenCalledWith({sessionId:"sessionId",deviceAction:new g({input:{command:new h(e),appName:"Ethereum",requiredUserInteraction:S.VerifyAddress,compatibleAppNames:f}})})}),test("when checkOnDevice is false: UserInteractionRequired.None",()=>{const e={...s,checkOnDevice:!1};new l(a,u,m,D,"sessionId").getAddress(e),expect(a.executeDeviceAction).toHaveBeenCalledWith({sessionId:"sessionId",deviceAction:new g({input:{command:new h(e),appName:"Ethereum",requiredUserInteraction:S.None,compatibleAppNames:f}})})})})}),describe("signTransaction",()=>{it("should return the signature",()=>new Promise((s,r)=>{const e={r:"0xDEAD",s:"0xBEEF",v:0},i=v(y.from({to:"0x1234567890123456789012345678901234567890",value:0n}).unsignedSerialized),d={};vi.spyOn(a,"executeDeviceAction").mockReturnValue({observable:A([{status:c.Completed,output:e}]),cancel:vi.fn()});const p=new l(a,u,m,D,"sessionId"),{observable:o}=p.signTransaction({derivationPath:"44'/60'/3'/2/1",transaction:i,options:d}),t=[];o.subscribe({next:n=>{t.push(n)},error:n=>{r(n)},complete:()=>{try{expect(t).toEqual([{status:c.Completed,output:e}]),s()}catch(n){r(n)}}})})),it("should return the signature without options",()=>new Promise((s,r)=>{const e={r:"0xDEAD",s:"0xBEEF",v:0},i=v(y.from({to:"0x1234567890123456789012345678901234567890",value:0n}).unsignedSerialized);vi.spyOn(a,"executeDeviceAction").mockReturnValue({observable:A([{status:c.Completed,output:e}]),cancel:vi.fn()});const d=new l(a,u,m,D,"sessionId"),{observable:p}=d.signTransaction({derivationPath:"44'/60'/3'/2/1",transaction:i,options:void 0}),o=[];p.subscribe({next:t=>{o.push(t)},error:t=>{r(t)},complete:()=>{try{expect(o).toEqual([{status:c.Completed,output:e}]),s()}catch(t){r(t)}}})}))}),describe("signMessage",()=>{it("should return the signature",()=>new Promise((s,r)=>{const e={r:"0xDEAD",s:"0xBEEF",v:0},i="Hello, World!";vi.spyOn(a,"executeDeviceAction").mockReturnValue({observable:A([{status:c.Completed,output:e}]),cancel:vi.fn()});const d=new l(a,u,m,D,"sessionId"),{observable:p}=d.signPersonalMessage({derivationPath:"44'/60'/3'/2/1",message:i}),o=[];p.subscribe({next:t=>{o.push(t)},error:t=>{r(t)},complete:()=>{try{expect(o).toEqual([{status:c.Completed,output:e}]),s()}catch(t){r(t)}}})}))}),describe("signTypedData",()=>{it("should return the signature",()=>new Promise((s,r)=>{const e={r:"0xDEAD",s:"0xBEEF",v:0},i={domain:{},types:{},primaryType:"test",message:{}},d={parse:vi.fn()};vi.spyOn(a,"executeDeviceAction").mockReturnValue({observable:A([{status:c.Completed,output:e}]),cancel:vi.fn()});const p=new l(a,u,m,D,"sessionId"),{observable:o}=p.signTypedData({derivationPath:"44'/60'/3'/2/1",parser:d,data:i}),t=[];o.subscribe({next:n=>{t.push(n)},error:n=>{r(n)},complete:()=>{try{expect(t).toEqual([{status:c.Completed,output:e}]),s()}catch(n){r(n)}}})}))})});
|
|
2
2
|
//# sourceMappingURL=EthAppBinder.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/internal/app-binder/EthAppBinder.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { type ContextModule } from \"@ledgerhq/context-module\";\nimport {\n type DeviceActionState,\n type DeviceManagementKit,\n hexaStringToBuffer,\n} from \"@ledgerhq/device-management-kit\";\nimport { DeviceActionStatus } from \"@ledgerhq/device-management-kit\";\nimport { SendCommandInAppDeviceAction } from \"@ledgerhq/device-management-kit\";\nimport { UserInteractionRequired } from \"@ledgerhq/device-management-kit\";\nimport { Transaction } from \"ethers\";\nimport { from } from \"rxjs\";\n\nimport {\n type GetAddressDAError,\n type GetAddressDAIntermediateValue,\n type GetAddressDAOutput,\n} from \"@api/app-binder/GetAddressDeviceActionTypes\";\nimport {\n type SignPersonalMessageDAError,\n type SignPersonalMessageDAIntermediateValue,\n type SignPersonalMessageDAOutput,\n} from \"@api/app-binder/SignPersonalMessageDeviceActionTypes\";\nimport {\n type SignTransactionDAError,\n type SignTransactionDAIntermediateValue,\n type SignTransactionDAOutput,\n} from \"@api/app-binder/SignTransactionDeviceActionTypes\";\nimport {\n type SignTypedDataDAError,\n type SignTypedDataDAIntermediateValue,\n type SignTypedDataDAOutput,\n} from \"@api/app-binder/SignTypedDataDeviceActionTypes\";\nimport { type Signature } from \"@api/model/Signature\";\nimport { type TypedData } from \"@api/model/TypedData\";\nimport { type TransactionMapperService } from \"@internal/transaction/service/mapper/TransactionMapperService\";\nimport { type TransactionParserService } from \"@internal/transaction/service/parser/TransactionParserService\";\nimport { type TypedDataParserService } from \"@internal/typed-data/service/TypedDataParserService\";\n\nimport { GetAddressCommand } from \"./command/GetAddressCommand\";\nimport { ETHEREUM_PLUGINS } from \"./constant/plugins\";\nimport { EthAppBinder } from \"./EthAppBinder\";\n\ndescribe(\"EthAppBinder\", () => {\n const mockedDmk: DeviceManagementKit = {\n sendCommand: vi.fn(),\n executeDeviceAction: vi.fn(),\n } as unknown as DeviceManagementKit;\n const mockedContextModule: ContextModule = {\n getContext: vi.fn(),\n getContexts: vi.fn(),\n getTypedDataFilters: vi.fn(),\n };\n const mockedMapper: TransactionMapperService = {\n mapTransactionToSubset: vi.fn(),\n } as unknown as TransactionMapperService;\n const mockedParser: TransactionParserService = {\n extractValue: vi.fn(),\n } as unknown as TransactionParserService;\n\n beforeEach(() => {\n vi.clearAllMocks();\n });\n\n describe(\"getAddress\", () => {\n it(\"should return the address, publicKey, and chainCode\", () =>\n new Promise<void>((resolve, reject) => {\n // GIVEN\n const address = \"0xF7C69BedB292Dd3fC2cA4103989B5BD705164c43\";\n const publicKey = \"04e3785ca\";\n const chainCode = undefined;\n\n vi.spyOn(mockedDmk, \"executeDeviceAction\").mockReturnValue({\n observable: from([\n {\n status: DeviceActionStatus.Completed,\n output: { address, publicKey, chainCode },\n } as DeviceActionState<\n GetAddressDAOutput,\n GetAddressDAError,\n GetAddressDAIntermediateValue\n >,\n ]),\n cancel: vi.fn(),\n });\n\n // WHEN\n const appBinder = new EthAppBinder(\n mockedDmk,\n mockedContextModule,\n mockedMapper,\n mockedParser,\n \"sessionId\",\n );\n const { observable } = appBinder.getAddress({\n derivationPath: \"44'/60'/3'/2/1\",\n });\n\n // THEN\n const states: DeviceActionState<\n GetAddressDAOutput,\n GetAddressDAError,\n GetAddressDAIntermediateValue\n >[] = [];\n observable.subscribe({\n next: (state) => {\n states.push(state);\n },\n error: (err) => {\n reject(err);\n },\n complete: () => {\n try {\n expect(states).toEqual([\n {\n status: DeviceActionStatus.Completed,\n output: { address, publicKey, chainCode },\n },\n ]);\n resolve();\n } catch (err) {\n reject(err as Error);\n }\n },\n });\n }));\n\n describe(\"calls of executeDeviceAction with the correct params\", () => {\n const baseParams = {\n derivationPath: \"44'/60'/3'/2/1\",\n returnChainCode: false,\n };\n\n test(\"when checkOnDevice is true: UserInteractionRequired.VerifyAddress\", () => {\n // GIVEN\n const checkOnDevice = true;\n const params = {\n ...baseParams,\n checkOnDevice,\n };\n\n // WHEN\n const appBinder = new EthAppBinder(\n mockedDmk,\n mockedContextModule,\n mockedMapper,\n mockedParser,\n \"sessionId\",\n );\n appBinder.getAddress(params);\n\n // THEN\n expect(mockedDmk.executeDeviceAction).toHaveBeenCalledWith({\n sessionId: \"sessionId\",\n deviceAction: new SendCommandInAppDeviceAction({\n input: {\n command: new GetAddressCommand(params),\n appName: \"Ethereum\",\n requiredUserInteraction: UserInteractionRequired.VerifyAddress,\n compatibleAppNames: ETHEREUM_PLUGINS,\n },\n }),\n });\n });\n\n test(\"when checkOnDevice is false: UserInteractionRequired.None\", () => {\n // GIVEN\n const checkOnDevice = false;\n const params = {\n ...baseParams,\n checkOnDevice,\n };\n\n // WHEN\n const appBinder = new EthAppBinder(\n mockedDmk,\n mockedContextModule,\n mockedMapper,\n mockedParser,\n \"sessionId\",\n );\n appBinder.getAddress(params);\n\n // THEN\n expect(mockedDmk.executeDeviceAction).toHaveBeenCalledWith({\n sessionId: \"sessionId\",\n deviceAction: new SendCommandInAppDeviceAction({\n input: {\n command: new GetAddressCommand(params),\n appName: \"Ethereum\",\n requiredUserInteraction: UserInteractionRequired.None,\n compatibleAppNames: ETHEREUM_PLUGINS,\n },\n }),\n });\n });\n });\n });\n\n describe(\"signTransaction\", () => {\n it(\"should return the signature\", () =>\n new Promise<void>((resolve, reject) => {\n // GIVEN\n const signature: Signature = {\n r: `0xDEAD`,\n s: `0xBEEF`,\n v: 0,\n };\n const transaction: Uint8Array = hexaStringToBuffer(\n Transaction.from({\n to: \"0x1234567890123456789012345678901234567890\",\n value: 0n,\n }).unsignedSerialized,\n )!;\n const options = {};\n\n vi.spyOn(mockedDmk, \"executeDeviceAction\").mockReturnValue({\n observable: from([\n {\n status: DeviceActionStatus.Completed,\n output: signature,\n } as DeviceActionState<\n SignTypedDataDAOutput,\n SignTypedDataDAError,\n SignTypedDataDAIntermediateValue\n >,\n ]),\n cancel: vi.fn(),\n });\n\n // WHEN\n const appBinder = new EthAppBinder(\n mockedDmk,\n mockedContextModule,\n mockedMapper,\n mockedParser,\n \"sessionId\",\n );\n const { observable } = appBinder.signTransaction({\n derivationPath: \"44'/60'/3'/2/1\",\n transaction,\n options,\n });\n\n // THEN\n const states: DeviceActionState<\n SignTransactionDAOutput,\n SignTransactionDAError,\n SignTransactionDAIntermediateValue\n >[] = [];\n observable.subscribe({\n next: (state) => {\n states.push(state);\n },\n error: (err) => {\n reject(err);\n },\n complete: () => {\n try {\n expect(states).toEqual([\n {\n status: DeviceActionStatus.Completed,\n output: signature,\n },\n ]);\n resolve();\n } catch (err) {\n reject(err as Error);\n }\n },\n });\n }));\n\n it(\"should return the signature without options\", () =>\n new Promise<void>((resolve, reject) => {\n // GIVEN\n const signature: Signature = {\n r: `0xDEAD`,\n s: `0xBEEF`,\n v: 0,\n };\n const transaction: Uint8Array = hexaStringToBuffer(\n Transaction.from({\n to: \"0x1234567890123456789012345678901234567890\",\n value: 0n,\n }).unsignedSerialized,\n )!;\n\n vi.spyOn(mockedDmk, \"executeDeviceAction\").mockReturnValue({\n observable: from([\n {\n status: DeviceActionStatus.Completed,\n output: signature,\n } as DeviceActionState<\n SignTypedDataDAOutput,\n SignTypedDataDAError,\n SignTypedDataDAIntermediateValue\n >,\n ]),\n cancel: vi.fn(),\n });\n\n // WHEN\n const appBinder = new EthAppBinder(\n mockedDmk,\n mockedContextModule,\n mockedMapper,\n mockedParser,\n \"sessionId\",\n );\n const { observable } = appBinder.signTransaction({\n derivationPath: \"44'/60'/3'/2/1\",\n transaction,\n options: undefined,\n });\n\n // THEN\n const states: DeviceActionState<\n SignTransactionDAOutput,\n SignTransactionDAError,\n SignTransactionDAIntermediateValue\n >[] = [];\n observable.subscribe({\n next: (state) => {\n states.push(state);\n },\n error: (err) => {\n reject(err);\n },\n complete: () => {\n try {\n expect(states).toEqual([\n {\n status: DeviceActionStatus.Completed,\n output: signature,\n },\n ]);\n resolve();\n } catch (err) {\n reject(err as Error);\n }\n },\n });\n }));\n });\n\n describe(\"signMessage\", () => {\n it(\"should return the signature\", () =>\n new Promise<void>((resolve, reject) => {\n // GIVEN\n const signature: Signature = {\n r: `0xDEAD`,\n s: `0xBEEF`,\n v: 0,\n };\n const message = \"Hello, World!\";\n\n vi.spyOn(mockedDmk, \"executeDeviceAction\").mockReturnValue({\n observable: from([\n {\n status: DeviceActionStatus.Completed,\n output: signature,\n } as DeviceActionState<\n SignPersonalMessageDAOutput,\n SignPersonalMessageDAError,\n SignPersonalMessageDAIntermediateValue\n >,\n ]),\n cancel: vi.fn(),\n });\n\n // WHEN\n const appBinder = new EthAppBinder(\n mockedDmk,\n mockedContextModule,\n mockedMapper,\n mockedParser,\n \"sessionId\",\n );\n const { observable } = appBinder.signPersonalMessage({\n derivationPath: \"44'/60'/3'/2/1\",\n message,\n });\n\n // THEN\n const states: DeviceActionState<\n SignPersonalMessageDAOutput,\n SignPersonalMessageDAError,\n SignPersonalMessageDAIntermediateValue\n >[] = [];\n observable.subscribe({\n next: (state) => {\n states.push(state);\n },\n error: (err) => {\n reject(err);\n },\n complete: () => {\n try {\n expect(states).toEqual([\n {\n status: DeviceActionStatus.Completed,\n output: signature,\n },\n ]);\n resolve();\n } catch (err) {\n reject(err as Error);\n }\n },\n });\n }));\n });\n\n describe(\"signTypedData\", () => {\n it(\"should return the signature\", () =>\n new Promise<void>((resolve, reject) => {\n // GIVEN\n const signature: Signature = {\n r: `0xDEAD`,\n s: `0xBEEF`,\n v: 0,\n };\n const typedData: TypedData = {\n domain: {},\n types: {},\n primaryType: \"test\",\n message: {},\n };\n const parser: TypedDataParserService = {\n parse: vi.fn(),\n };\n\n vi.spyOn(mockedDmk, \"executeDeviceAction\").mockReturnValue({\n observable: from([\n {\n status: DeviceActionStatus.Completed,\n output: signature,\n } as DeviceActionState<\n SignTypedDataDAOutput,\n SignTypedDataDAError,\n SignTypedDataDAIntermediateValue\n >,\n ]),\n cancel: vi.fn(),\n });\n\n // WHEN\n const appBinder = new EthAppBinder(\n mockedDmk,\n mockedContextModule,\n mockedMapper,\n mockedParser,\n \"sessionId\",\n );\n const { observable } = appBinder.signTypedData({\n derivationPath: \"44'/60'/3'/2/1\",\n parser,\n data: typedData,\n });\n\n // THEN\n const states: DeviceActionState<\n SignTypedDataDAOutput,\n SignTypedDataDAError,\n SignTypedDataDAIntermediateValue\n >[] = [];\n observable.subscribe({\n next: (state) => {\n states.push(state);\n },\n error: (err) => {\n reject(err);\n },\n complete: () => {\n try {\n expect(states).toEqual([\n {\n status: DeviceActionStatus.Completed,\n output: signature,\n },\n ]);\n resolve();\n } catch (err) {\n reject(err as Error);\n }\n },\n });\n }));\n });\n});\n"],
|
|
5
|
-
"mappings": "AACA,OAGE,sBAAAA,MACK,kCACP,OAAS,sBAAAC,MAA0B,kCACnC,OAAS,gCAAAC,MAAoC,kCAC7C,OAAS,2BAAAC,MAA+B,kCACxC,OAAS,eAAAC,MAAmB,SAC5B,OAAS,QAAAC,MAAY,OA4BrB,OAAS,qBAAAC,MAAyB,8BAClC,OAAS,oBAAAC,MAAwB,qBACjC,OAAS,gBAAAC,MAAoB,iBAE7B,SAAS,eAAgB,IAAM,CAC7B,MAAMC,EAAiC,CACrC,YAAa,GAAG,GAAG,EACnB,oBAAqB,GAAG,GAAG,CAC7B,EACMC,EAAqC,CACzC,WAAY,GAAG,GAAG,EAClB,YAAa,GAAG,GAAG,EACnB,oBAAqB,GAAG,GAAG,
|
|
4
|
+
"sourcesContent": ["import { type ContextModule } from \"@ledgerhq/context-module\";\nimport {\n type DeviceActionState,\n type DeviceManagementKit,\n hexaStringToBuffer,\n} from \"@ledgerhq/device-management-kit\";\nimport { DeviceActionStatus } from \"@ledgerhq/device-management-kit\";\nimport { SendCommandInAppDeviceAction } from \"@ledgerhq/device-management-kit\";\nimport { UserInteractionRequired } from \"@ledgerhq/device-management-kit\";\nimport { Transaction } from \"ethers\";\nimport { from } from \"rxjs\";\n\nimport {\n type GetAddressDAError,\n type GetAddressDAIntermediateValue,\n type GetAddressDAOutput,\n} from \"@api/app-binder/GetAddressDeviceActionTypes\";\nimport {\n type SignPersonalMessageDAError,\n type SignPersonalMessageDAIntermediateValue,\n type SignPersonalMessageDAOutput,\n} from \"@api/app-binder/SignPersonalMessageDeviceActionTypes\";\nimport {\n type SignTransactionDAError,\n type SignTransactionDAIntermediateValue,\n type SignTransactionDAOutput,\n} from \"@api/app-binder/SignTransactionDeviceActionTypes\";\nimport {\n type SignTypedDataDAError,\n type SignTypedDataDAIntermediateValue,\n type SignTypedDataDAOutput,\n} from \"@api/app-binder/SignTypedDataDeviceActionTypes\";\nimport { type Signature } from \"@api/model/Signature\";\nimport { type TypedData } from \"@api/model/TypedData\";\nimport { type TransactionMapperService } from \"@internal/transaction/service/mapper/TransactionMapperService\";\nimport { type TransactionParserService } from \"@internal/transaction/service/parser/TransactionParserService\";\nimport { type TypedDataParserService } from \"@internal/typed-data/service/TypedDataParserService\";\n\nimport { GetAddressCommand } from \"./command/GetAddressCommand\";\nimport { ETHEREUM_PLUGINS } from \"./constant/plugins\";\nimport { EthAppBinder } from \"./EthAppBinder\";\n\ndescribe(\"EthAppBinder\", () => {\n const mockedDmk: DeviceManagementKit = {\n sendCommand: vi.fn(),\n executeDeviceAction: vi.fn(),\n } as unknown as DeviceManagementKit;\n const mockedContextModule: ContextModule = {\n getContext: vi.fn(),\n getContexts: vi.fn(),\n getTypedDataFilters: vi.fn(),\n getWeb3Checks: vi.fn(),\n };\n const mockedMapper: TransactionMapperService = {\n mapTransactionToSubset: vi.fn(),\n } as unknown as TransactionMapperService;\n const mockedParser: TransactionParserService = {\n extractValue: vi.fn(),\n } as unknown as TransactionParserService;\n\n beforeEach(() => {\n vi.clearAllMocks();\n });\n\n describe(\"getAddress\", () => {\n it(\"should return the address, publicKey, and chainCode\", () =>\n new Promise<void>((resolve, reject) => {\n // GIVEN\n const address = \"0xF7C69BedB292Dd3fC2cA4103989B5BD705164c43\";\n const publicKey = \"04e3785ca\";\n const chainCode = undefined;\n\n vi.spyOn(mockedDmk, \"executeDeviceAction\").mockReturnValue({\n observable: from([\n {\n status: DeviceActionStatus.Completed,\n output: { address, publicKey, chainCode },\n } as DeviceActionState<\n GetAddressDAOutput,\n GetAddressDAError,\n GetAddressDAIntermediateValue\n >,\n ]),\n cancel: vi.fn(),\n });\n\n // WHEN\n const appBinder = new EthAppBinder(\n mockedDmk,\n mockedContextModule,\n mockedMapper,\n mockedParser,\n \"sessionId\",\n );\n const { observable } = appBinder.getAddress({\n derivationPath: \"44'/60'/3'/2/1\",\n });\n\n // THEN\n const states: DeviceActionState<\n GetAddressDAOutput,\n GetAddressDAError,\n GetAddressDAIntermediateValue\n >[] = [];\n observable.subscribe({\n next: (state) => {\n states.push(state);\n },\n error: (err) => {\n reject(err);\n },\n complete: () => {\n try {\n expect(states).toEqual([\n {\n status: DeviceActionStatus.Completed,\n output: { address, publicKey, chainCode },\n },\n ]);\n resolve();\n } catch (err) {\n reject(err as Error);\n }\n },\n });\n }));\n\n describe(\"calls of executeDeviceAction with the correct params\", () => {\n const baseParams = {\n derivationPath: \"44'/60'/3'/2/1\",\n returnChainCode: false,\n };\n\n test(\"when checkOnDevice is true: UserInteractionRequired.VerifyAddress\", () => {\n // GIVEN\n const checkOnDevice = true;\n const params = {\n ...baseParams,\n checkOnDevice,\n };\n\n // WHEN\n const appBinder = new EthAppBinder(\n mockedDmk,\n mockedContextModule,\n mockedMapper,\n mockedParser,\n \"sessionId\",\n );\n appBinder.getAddress(params);\n\n // THEN\n expect(mockedDmk.executeDeviceAction).toHaveBeenCalledWith({\n sessionId: \"sessionId\",\n deviceAction: new SendCommandInAppDeviceAction({\n input: {\n command: new GetAddressCommand(params),\n appName: \"Ethereum\",\n requiredUserInteraction: UserInteractionRequired.VerifyAddress,\n compatibleAppNames: ETHEREUM_PLUGINS,\n },\n }),\n });\n });\n\n test(\"when checkOnDevice is false: UserInteractionRequired.None\", () => {\n // GIVEN\n const checkOnDevice = false;\n const params = {\n ...baseParams,\n checkOnDevice,\n };\n\n // WHEN\n const appBinder = new EthAppBinder(\n mockedDmk,\n mockedContextModule,\n mockedMapper,\n mockedParser,\n \"sessionId\",\n );\n appBinder.getAddress(params);\n\n // THEN\n expect(mockedDmk.executeDeviceAction).toHaveBeenCalledWith({\n sessionId: \"sessionId\",\n deviceAction: new SendCommandInAppDeviceAction({\n input: {\n command: new GetAddressCommand(params),\n appName: \"Ethereum\",\n requiredUserInteraction: UserInteractionRequired.None,\n compatibleAppNames: ETHEREUM_PLUGINS,\n },\n }),\n });\n });\n });\n });\n\n describe(\"signTransaction\", () => {\n it(\"should return the signature\", () =>\n new Promise<void>((resolve, reject) => {\n // GIVEN\n const signature: Signature = {\n r: `0xDEAD`,\n s: `0xBEEF`,\n v: 0,\n };\n const transaction: Uint8Array = hexaStringToBuffer(\n Transaction.from({\n to: \"0x1234567890123456789012345678901234567890\",\n value: 0n,\n }).unsignedSerialized,\n )!;\n const options = {};\n\n vi.spyOn(mockedDmk, \"executeDeviceAction\").mockReturnValue({\n observable: from([\n {\n status: DeviceActionStatus.Completed,\n output: signature,\n } as DeviceActionState<\n SignTypedDataDAOutput,\n SignTypedDataDAError,\n SignTypedDataDAIntermediateValue\n >,\n ]),\n cancel: vi.fn(),\n });\n\n // WHEN\n const appBinder = new EthAppBinder(\n mockedDmk,\n mockedContextModule,\n mockedMapper,\n mockedParser,\n \"sessionId\",\n );\n const { observable } = appBinder.signTransaction({\n derivationPath: \"44'/60'/3'/2/1\",\n transaction,\n options,\n });\n\n // THEN\n const states: DeviceActionState<\n SignTransactionDAOutput,\n SignTransactionDAError,\n SignTransactionDAIntermediateValue\n >[] = [];\n observable.subscribe({\n next: (state) => {\n states.push(state);\n },\n error: (err) => {\n reject(err);\n },\n complete: () => {\n try {\n expect(states).toEqual([\n {\n status: DeviceActionStatus.Completed,\n output: signature,\n },\n ]);\n resolve();\n } catch (err) {\n reject(err as Error);\n }\n },\n });\n }));\n\n it(\"should return the signature without options\", () =>\n new Promise<void>((resolve, reject) => {\n // GIVEN\n const signature: Signature = {\n r: `0xDEAD`,\n s: `0xBEEF`,\n v: 0,\n };\n const transaction: Uint8Array = hexaStringToBuffer(\n Transaction.from({\n to: \"0x1234567890123456789012345678901234567890\",\n value: 0n,\n }).unsignedSerialized,\n )!;\n\n vi.spyOn(mockedDmk, \"executeDeviceAction\").mockReturnValue({\n observable: from([\n {\n status: DeviceActionStatus.Completed,\n output: signature,\n } as DeviceActionState<\n SignTypedDataDAOutput,\n SignTypedDataDAError,\n SignTypedDataDAIntermediateValue\n >,\n ]),\n cancel: vi.fn(),\n });\n\n // WHEN\n const appBinder = new EthAppBinder(\n mockedDmk,\n mockedContextModule,\n mockedMapper,\n mockedParser,\n \"sessionId\",\n );\n const { observable } = appBinder.signTransaction({\n derivationPath: \"44'/60'/3'/2/1\",\n transaction,\n options: undefined,\n });\n\n // THEN\n const states: DeviceActionState<\n SignTransactionDAOutput,\n SignTransactionDAError,\n SignTransactionDAIntermediateValue\n >[] = [];\n observable.subscribe({\n next: (state) => {\n states.push(state);\n },\n error: (err) => {\n reject(err);\n },\n complete: () => {\n try {\n expect(states).toEqual([\n {\n status: DeviceActionStatus.Completed,\n output: signature,\n },\n ]);\n resolve();\n } catch (err) {\n reject(err as Error);\n }\n },\n });\n }));\n });\n\n describe(\"signMessage\", () => {\n it(\"should return the signature\", () =>\n new Promise<void>((resolve, reject) => {\n // GIVEN\n const signature: Signature = {\n r: `0xDEAD`,\n s: `0xBEEF`,\n v: 0,\n };\n const message = \"Hello, World!\";\n\n vi.spyOn(mockedDmk, \"executeDeviceAction\").mockReturnValue({\n observable: from([\n {\n status: DeviceActionStatus.Completed,\n output: signature,\n } as DeviceActionState<\n SignPersonalMessageDAOutput,\n SignPersonalMessageDAError,\n SignPersonalMessageDAIntermediateValue\n >,\n ]),\n cancel: vi.fn(),\n });\n\n // WHEN\n const appBinder = new EthAppBinder(\n mockedDmk,\n mockedContextModule,\n mockedMapper,\n mockedParser,\n \"sessionId\",\n );\n const { observable } = appBinder.signPersonalMessage({\n derivationPath: \"44'/60'/3'/2/1\",\n message,\n });\n\n // THEN\n const states: DeviceActionState<\n SignPersonalMessageDAOutput,\n SignPersonalMessageDAError,\n SignPersonalMessageDAIntermediateValue\n >[] = [];\n observable.subscribe({\n next: (state) => {\n states.push(state);\n },\n error: (err) => {\n reject(err);\n },\n complete: () => {\n try {\n expect(states).toEqual([\n {\n status: DeviceActionStatus.Completed,\n output: signature,\n },\n ]);\n resolve();\n } catch (err) {\n reject(err as Error);\n }\n },\n });\n }));\n });\n\n describe(\"signTypedData\", () => {\n it(\"should return the signature\", () =>\n new Promise<void>((resolve, reject) => {\n // GIVEN\n const signature: Signature = {\n r: `0xDEAD`,\n s: `0xBEEF`,\n v: 0,\n };\n const typedData: TypedData = {\n domain: {},\n types: {},\n primaryType: \"test\",\n message: {},\n };\n const parser: TypedDataParserService = {\n parse: vi.fn(),\n };\n\n vi.spyOn(mockedDmk, \"executeDeviceAction\").mockReturnValue({\n observable: from([\n {\n status: DeviceActionStatus.Completed,\n output: signature,\n } as DeviceActionState<\n SignTypedDataDAOutput,\n SignTypedDataDAError,\n SignTypedDataDAIntermediateValue\n >,\n ]),\n cancel: vi.fn(),\n });\n\n // WHEN\n const appBinder = new EthAppBinder(\n mockedDmk,\n mockedContextModule,\n mockedMapper,\n mockedParser,\n \"sessionId\",\n );\n const { observable } = appBinder.signTypedData({\n derivationPath: \"44'/60'/3'/2/1\",\n parser,\n data: typedData,\n });\n\n // THEN\n const states: DeviceActionState<\n SignTypedDataDAOutput,\n SignTypedDataDAError,\n SignTypedDataDAIntermediateValue\n >[] = [];\n observable.subscribe({\n next: (state) => {\n states.push(state);\n },\n error: (err) => {\n reject(err);\n },\n complete: () => {\n try {\n expect(states).toEqual([\n {\n status: DeviceActionStatus.Completed,\n output: signature,\n },\n ]);\n resolve();\n } catch (err) {\n reject(err as Error);\n }\n },\n });\n }));\n });\n});\n"],
|
|
5
|
+
"mappings": "AACA,OAGE,sBAAAA,MACK,kCACP,OAAS,sBAAAC,MAA0B,kCACnC,OAAS,gCAAAC,MAAoC,kCAC7C,OAAS,2BAAAC,MAA+B,kCACxC,OAAS,eAAAC,MAAmB,SAC5B,OAAS,QAAAC,MAAY,OA4BrB,OAAS,qBAAAC,MAAyB,8BAClC,OAAS,oBAAAC,MAAwB,qBACjC,OAAS,gBAAAC,MAAoB,iBAE7B,SAAS,eAAgB,IAAM,CAC7B,MAAMC,EAAiC,CACrC,YAAa,GAAG,GAAG,EACnB,oBAAqB,GAAG,GAAG,CAC7B,EACMC,EAAqC,CAC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C,EACAC,EACAC,EACAC,EACA,WACF,EACM,CAAE,WAAAM,CAAW,EAAID,EAAU,cAAc,CAC7C,eAAgB,iBAChB,OAAAY,EACA,KAAMD,CACR,CAAC,EAGKT,EAIA,CAAC,EACPD,EAAW,UAAU,CACnB,KAAOE,GAAU,CACfD,EAAO,KAAKC,CAAK,CACnB,EACA,MAAQC,GAAQ,CACdP,EAAOO,CAAG,CACZ,EACA,SAAU,IAAM,CACd,GAAI,CACF,OAAOF,CAAM,EAAE,QAAQ,CACrB,CACE,OAAQlB,EAAmB,UAC3B,OAAQuB,CACV,CACF,CAAC,EACDX,EAAQ,CACV,OAASQ,EAAK,CACZP,EAAOO,CAAY,CACrB,CACF,CACF,CAAC,CACH,CAAC,CAAC,CACN,CAAC,CACH,CAAC",
|
|
6
6
|
"names": ["hexaStringToBuffer", "DeviceActionStatus", "SendCommandInAppDeviceAction", "UserInteractionRequired", "Transaction", "from", "GetAddressCommand", "ETHEREUM_PLUGINS", "EthAppBinder", "mockedDmk", "mockedContextModule", "mockedMapper", "mockedParser", "resolve", "reject", "address", "publicKey", "appBinder", "observable", "states", "state", "err", "baseParams", "params", "signature", "transaction", "options", "message", "typedData", "parser"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{ApduBuilder as C,ApduParser as c,CommandResultFactory as t,InvalidStatusWordError as a}from"@ledgerhq/device-management-kit";import{CommandErrorHelper as l}from"@ledgerhq/signer-utils";import{Maybe as f}from"purify-ts";import{ETH_APP_ERRORS as g,EthAppCommandErrorFactory as A}from"./utils/ethAppErrors";class h{errorHelper=new l(g,A);constructor(){}getApdu(){const r={cla:224,ins:6,p1:0,p2:0};return new C(r).build()}parseResponse(r){return f.fromNullable(this.errorHelper.getError(r)).orDefaultLazy(()=>{const e=new c(r),o=e.extract8BitUInt();if(o===void 0)return t({error:new a("Cannot extract config flags")});const n=e.extract8BitUInt(),p=e.extract8BitUInt(),s=e.extract8BitUInt();if(n===void 0||p===void 0||s===void 0)return t({error:new a("Cannot extract version")});const i=!!(o&1),d=!!(o&16),m=!!(o&32),u={blindSigningEnabled:i,web3ChecksEnabled:d,web3ChecksOptIn:m,version:`${n}.${p}.${s}`};return t({data:u})})}}export{h as GetAppConfiguration};
|
|
2
|
+
//# sourceMappingURL=GetAppConfigurationCommand.js.map
|