From 9648f7af4b8eb1d1e52b7d8db1282344df25df30 Mon Sep 17 00:00:00 2001 From: satyam70288 Date: Wed, 18 Sep 2024 12:12:18 +0000 Subject: [PATCH] [update] - on server push --- package.json | 3 +- src/api/icici.api.js | 18 +++++++++- src/config/config.js | 6 ++-- .../bankDetails/bankDetails.controller.js | 33 +++++++++++++++++-- src/routes/icici/user.routes.js | 1 + 5 files changed, 53 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 6a428bb..a362281 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,8 @@ "version": "1.0.0", "main": "index.js", "scripts": { - "start": "nodemon src/index", + "start": "node src/index", + "dev": "nodemon src/index", "test": "echo \"Error: no test specified\" && exit 1" }, "keywords": [], diff --git a/src/api/icici.api.js b/src/api/icici.api.js index 7e44e58..122b2c0 100644 --- a/src/api/icici.api.js +++ b/src/api/icici.api.js @@ -11,7 +11,23 @@ module.exports = { 'Content-Type': 'text/plain', 'apikey': 'COIbAAYzt0SMosd3fFexJlk42uqnPvvu', 'x-forwarded-for': '77.68.102.23', - 'Content-Length': Buffer.byteLength(encryptedData).toString() + 'Content-Length': 684 + } + } + ) + return data + }, + RegistrationStatus: async (encryptedData) => { + const { data } = await axios.post( + 'https://apibankingonesandbox.icicibank.com/api/Corporate/CIB_SV/v1/RegistrationStatus', + encryptedData, + { + headers: { + 'accept': "*", + 'Content-Type': 'text/plain', + 'apikey': 'COIbAAYzt0SMosd3fFexJlk42uqnPvvu', + 'x-forwarded-for': '77.68.102.23', + 'Content-Length': 684 } } ) diff --git a/src/config/config.js b/src/config/config.js index 2fb747e..c46c739 100644 --- a/src/config/config.js +++ b/src/config/config.js @@ -44,9 +44,9 @@ try { // byPassOTP: envVars?.BY_PASS_OTP, mysql: { development: { - username: "root", - password: "root", - database: "optifii", + username: "mymotukuser", + password: "password_Carrot11", + database: "optifii_sprint", host: "127.0.0.1", port: 3306, dialect: "mysql", diff --git a/src/controllers/bankDetails/bankDetails.controller.js b/src/controllers/bankDetails/bankDetails.controller.js index 5016b14..ae9b999 100644 --- a/src/controllers/bankDetails/bankDetails.controller.js +++ b/src/controllers/bankDetails/bankDetails.controller.js @@ -17,16 +17,14 @@ module.exports = { "URN": "TESTING123", "ALIASID": "" }; - const jsonString = JSON.stringify(jsonData); // Encrypt JSON data with the public key - const buffer = Buffer.from(jsonString, 'utf-8'); const encrypted = crypto.publicEncrypt( { key: publicKeyPem, padding: crypto.constants.RSA_PKCS1_PADDING }, - buffer + Buffer.from(JSON.stringify(jsonData)) ); // Encode encrypted bytes to Base64 @@ -36,4 +34,33 @@ module.exports = { res.status(200).json(data); }), + + RegistrationStatus: AsyncHandler(async (req, res) => { + const publicKeyPath = path.join(__dirname, 'public_key.pem'); + const publicKeyPem = fs.readFileSync(publicKeyPath, 'utf8'); + + const jsonData = { + "AGGRNAME": "CIBTESTING", + "AGGRID": "TXBCIBTEST001", + "CORPID": "TXBCORP1", + "USERID": "USER1", + "URN": "TESTING123", + }; + + // Encrypt JSON data with the public key + const encrypted = crypto.publicEncrypt( + { + key: publicKeyPem, + padding: crypto.constants.RSA_PKCS1_PADDING + }, + Buffer.from(JSON.stringify(jsonData)) + ); + + // Encode encrypted bytes to Base64 + const base64Encrypted = encrypted.toString('base64'); + + const data = await iciciApi.RegistrationStatus(base64Encrypted) + res.status(200).json(data); + + }), } diff --git a/src/routes/icici/user.routes.js b/src/routes/icici/user.routes.js index 3bc3ab4..81fc3d9 100644 --- a/src/routes/icici/user.routes.js +++ b/src/routes/icici/user.routes.js @@ -3,5 +3,6 @@ const { bankDetailsController } = require('../../controllers') const userRoutes = require('express').Router() userRoutes.post('/registration', bankDetailsController.Registration) +userRoutes.post('/registration-status', bankDetailsController.Registration) module.exports = userRoutes \ No newline at end of file