diff --git a/.gitignore b/.gitignore index 6c643471..e8b1302d 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,5 @@ __pycache__ *.mk util/src/main/resources/version.txt .gitconfig +*/spx/* +spx \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index a22715df..c0ab91a6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,4 +18,4 @@ RUN npm install -g npm@6.9.0 RUN npm install --global yarn@1.22.4 RUN yarn --cwd /app/frontend/ install # RUN yarnpkg --cwd /app/frontend/ build -RUN yarnpkg global add serve \ No newline at end of file +RUN yarnpkg global add serve@13.0.4 \ No newline at end of file diff --git a/frontend/package.json b/frontend/package.json index 1f657b53..4392d1dd 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -3,36 +3,36 @@ "version": "0.1.0", "private": true, "dependencies": { - "@ant-design/icons": "^4.2.1", - "@testing-library/jest-dom": "^4.2.4", - "@testing-library/react": "^9.3.2", - "@testing-library/user-event": "^7.1.2", - "@types/history": "^4.7.6", - "@types/jest": "^24.0.0", - "@types/node": "^12.0.0", - "@types/react": "^16.9.0", - "@types/react-dom": "^16.9.0", - "@types/react-redux": "^7.1.9", - "@types/react-router-dom": "^5.1.5", - "@types/redux": "^3.6.0", - "@types/redux-thunk": "^2.1.0", - "antd": "^4.2.4", - "craco": "^0.0.3", + "@ant-design/icons": "~4.2.1", + "@testing-library/jest-dom": "~4.2.4", + "@testing-library/react": "~9.3.2", + "@testing-library/user-event": "~7.1.2", + "@types/history": "~4.7.6", + "@types/jest": "~24.0.0", + "@types/node": "~12.0.0", + "@types/react": "~16.9.0", + "@types/react-dom": "~16.9.0", + "@types/react-redux": "~7.1.9", + "@types/react-router-dom": "~5.1.5", + "@types/redux": "~3.6.0", + "@types/redux-thunk": "~2.1.0", + "antd": "~4.2.4", + "craco": "~0.0.3", "craco-less": "1.16", - "history": "^4.10.1", - "js-base64": "^2.5.2", - "lodash": "^4.17.19", - "map-keys-deep-lodash": "^1.2.2", - "prettier": "^2.0.5", - "react": "^16.13.1", - "react-dom": "^16.13.1", - "react-json-tree": "^0.11.2", - "react-redux": "^7.2.0", - "react-router-dom": "^5.2.0", + "history": "~4.10.1", + "js-base64": "~2.5.2", + "lodash": "~4.17.19", + "map-keys-deep-lodash": "~1.2.2", + "prettier": "~2.0.5", + "react": "~16.13.1", + "react-dom": "~16.13.1", + "react-json-tree": "~0.11.2", + "react-redux": "~7.2.0", + "react-router-dom": "~5.2.0", "react-scripts": "3.4.1", - "redux": "^4.0.5", - "redux-thunk": "^2.3.0", - "redux-thunk-recursion-detect": "^1.1.4", + "redux": "~4.0.5", + "redux-thunk": "~2.3.0", + "redux-thunk-recursion-detect": "~1.1.4", "typescript": "~3.7.2" }, "scripts": { @@ -60,6 +60,6 @@ ] }, "devDependencies": { - "eslint-config-airbnb-typescript-prettier": "^2.1.1" + "eslint-config-airbnb-typescript-prettier": "~2.1.1" } } diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/ebics/EbicsClient.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/ebics/EbicsClient.kt index 65caf516..bbe01c1d 100644 --- a/nexus/src/main/kotlin/tech/libeufin/nexus/ebics/EbicsClient.kt +++ b/nexus/src/main/kotlin/tech/libeufin/nexus/ebics/EbicsClient.kt @@ -30,6 +30,9 @@ import org.slf4j.LoggerFactory import tech.libeufin.nexus.NexusError import tech.libeufin.util.* import java.util.* +import java.io.File +import java.time.LocalDateTime +import java.time.format.DateTimeFormatter private val logger: Logger = LoggerFactory.getLogger("tech.libeufin.util") @@ -66,6 +69,32 @@ class EbicsDownloadBankErrorResult( val returnCode: EbicsReturnCode ) : EbicsDownloadResult() + +fun writeResponseToFile(initResponseStr: String, transactionId: String) { + // Get base directory from environment variable TRACE_DIR + val baseDirectory = System.getenv("TRACE_DIR") ?: System.getProperty("user.dir") + + // Check if directory "trace" exists, create it if not + val traceDirectory = File("$baseDirectory/trace") + if (!traceDirectory.exists()) { + traceDirectory.mkdirs() + } + + // Get current date and time + val currentDateTime = LocalDateTime.now() + val formatter = DateTimeFormatter.ofPattern("yyyyMMdd_HHmmss") + val formattedDateTime = currentDateTime.format(formatter) + + // Construct file name with transactionId and current date/time + val fileName = "${traceDirectory.absolutePath}/${transactionId}_$formattedDateTime.xml" + + // Write response to file + val file = File(fileName) + file.writeText(initResponseStr) + println("Response written to file: $fileName") +} + + /** * Do an EBICS download transaction. This includes the initialization phase, transaction phase * and receipt phase. @@ -110,6 +139,8 @@ suspend fun doEbicsDownloadTransaction( HttpStatusCode.InternalServerError, "initial response must contain transaction ID" ) + + writeResponseToFile(transactionID,initResponseStr) val encryptionInfo = initResponse.dataEncryptionInfo ?: throw NexusError(HttpStatusCode.InternalServerError, "initial response did not contain encryption info")