[update] - fixed api
This commit is contained in:
@@ -4,38 +4,36 @@ const path = require('path');
|
||||
const { iciciApi } = require('../../api');
|
||||
const { AsyncHandler } = require('../../utils/handler/Async.handler');
|
||||
|
||||
const bankApi = 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",
|
||||
"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
|
||||
);
|
||||
|
||||
// Encode encrypted bytes to Base64
|
||||
const base64Encrypted = encrypted.toString('base64');
|
||||
|
||||
const data = await iciciApi.Registration(base64Encrypted)
|
||||
res.status(200).json(data);
|
||||
|
||||
});
|
||||
|
||||
module.exports = {
|
||||
bankApi
|
||||
Registration: 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",
|
||||
"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
|
||||
);
|
||||
|
||||
// Encode encrypted bytes to Base64
|
||||
const base64Encrypted = encrypted.toString('base64');
|
||||
|
||||
const data = await iciciApi.Registration(base64Encrypted)
|
||||
res.status(200).json(data);
|
||||
|
||||
}),
|
||||
}
|
||||
|
||||
@@ -2,6 +2,6 @@ const { bankDetailsController } = require('../../controllers')
|
||||
|
||||
const userRoutes = require('express').Router()
|
||||
|
||||
userRoutes.post('/', bankDetailsController.bankApi)
|
||||
userRoutes.post('/registration', bankDetailsController.Registration)
|
||||
|
||||
module.exports = userRoutes
|
||||
@@ -5,7 +5,7 @@ const router = express.Router();
|
||||
|
||||
const defaultRoutes = [
|
||||
{
|
||||
path: '/bankDetails',
|
||||
path: '/icici',
|
||||
route: require('./icici'),
|
||||
},
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user