`feat: updated config files, database connection, and rtgs service to support uat environment and encryption/decryption`
parent
8fcc5c21b5
commit
d268570e1e
@ -1,8 +1,8 @@
|
|||||||
db:
|
db:
|
||||||
host: '161.97.157.52'
|
host: ''
|
||||||
username: 'postgres'
|
username: ''
|
||||||
password: 'inv123'
|
password: ''
|
||||||
sid: 'appliq-dummy'
|
sid: ''
|
||||||
synchronize: false
|
synchronize: false
|
||||||
|
|
||||||
jwt:
|
jwt:
|
||||||
|
|||||||
@ -1,12 +1,21 @@
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
"VAN": "KGZASCB",
|
"VAN": "KGZASCB",
|
||||||
"tag": "scb-dev",
|
"tag": "uat",
|
||||||
"host": "111.92.84.50",
|
"host": "111.92.84.50",
|
||||||
"username": "corepacs",
|
"username": "corepacs",
|
||||||
"password": "corepacs",
|
"password": "corepacs",
|
||||||
"sid": "pacs",
|
"sid": "pacs",
|
||||||
"port":1521,
|
"port":1521,
|
||||||
|
"bankName":"KANGAZHA_SCB_UAT"
|
||||||
|
}, {
|
||||||
|
"VAN": "KGZASCB",
|
||||||
|
"tag": "live",
|
||||||
|
"host": "103.160.232.13",
|
||||||
|
"username": "corepacs",
|
||||||
|
"password": "corepacs",
|
||||||
|
"sid": "pacs",
|
||||||
|
"port":1521,
|
||||||
"bankName":"KANGAZHA_SCB"
|
"bankName":"KANGAZHA_SCB"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,48 @@
|
|||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
const crypto = require('crypto');
|
||||||
|
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class CryptoService {
|
||||||
|
constructor() { }
|
||||||
|
|
||||||
|
encrypt(plainText, secretKey, iv) {
|
||||||
|
try {
|
||||||
|
if (typeof plainText !== 'string') {
|
||||||
|
plainText = JSON.stringify(plainText);
|
||||||
|
}
|
||||||
|
const cipher = crypto.createCipheriv('aes-256-cbc', Buffer.from(secretKey.substring(0, 32), 'utf8'), Buffer.from(iv.substring(0, 16), 'utf8'));
|
||||||
|
let encrypted = cipher.update(plainText, 'utf8', 'hex');
|
||||||
|
encrypted += cipher.final('hex');
|
||||||
|
return encrypted;
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Encryption failed:', error.message); // Log any error during encryption
|
||||||
|
throw new Error('Encryption failed');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
decrypt(encryptedValue, secretKey, iv) {
|
||||||
|
try {
|
||||||
|
// console.log("encryptedValue--",encryptedValue);
|
||||||
|
// console.log("secretKey--",secretKey);
|
||||||
|
// console.log("iv--",iv);
|
||||||
|
|
||||||
|
const key = Buffer.from(secretKey.substring(0, 32), 'utf-8'); // AES-256 key size
|
||||||
|
const ivBuffer = Buffer.from(iv.substring(0, 16), 'utf-8'); // AES-CBC IV size
|
||||||
|
|
||||||
|
const encryptedBuffer = Buffer.from(encryptedValue, 'hex');
|
||||||
|
|
||||||
|
const decipher = crypto.createDecipheriv('aes-256-cbc', key, ivBuffer);
|
||||||
|
let decrypted = decipher.update(encryptedBuffer);
|
||||||
|
decrypted = Buffer.concat([decrypted, decipher.final()]);
|
||||||
|
|
||||||
|
return decrypted.toString('utf-8');
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Decryption failed:', error.message);
|
||||||
|
throw new Error('Decryption failed');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,18 +1,43 @@
|
|||||||
import { Body, Controller, Post } from '@nestjs/common';
|
import { Body, Controller, Post } from '@nestjs/common';
|
||||||
import { RtgsService } from './rtgs.service';
|
import { RtgsService } from './rtgs.service';
|
||||||
import { rtgsDto } from 'src/dto/rtgs.dto';
|
import { rtgsDto } from 'src/dto/rtgs.dto';
|
||||||
|
import { CryptoService } from 'src/auth/crypto.service';
|
||||||
|
import * as config from 'config';
|
||||||
|
|
||||||
@Controller('rtgs')
|
@Controller('rtgs')
|
||||||
export class RtgsController {
|
export class RtgsController {
|
||||||
constructor(private readonly rtgsService: RtgsService) {}
|
constructor(
|
||||||
|
private readonly rtgsService: RtgsService,
|
||||||
|
private cryptoService : CryptoService
|
||||||
|
) {}
|
||||||
|
|
||||||
@Post()
|
@Post()
|
||||||
async createRtgs(@Body() rtgsDto: rtgsDto): Promise<any>{
|
async createRtgs(@Body() rtgsDto: rtgsDto): Promise<any>{
|
||||||
return await this.rtgsService.rtgsEntryPosting(rtgsDto)
|
return await this.rtgsService.rtgsEntryPosting(rtgsDto,"live")
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post('validation')
|
@Post('validation')
|
||||||
async validatingRtgs(@Body() rtgsDto: rtgsDto): Promise<any>{
|
async validatingRtgs(@Body() rtgsDto: rtgsDto): Promise<any>{
|
||||||
return await this.rtgsService.validatingRtgs(rtgsDto)
|
return await this.rtgsService.validatingRtgs(rtgsDto,"live")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post('uat')
|
||||||
|
async createRtgsUat(@Body() rtgsDto: rtgsDto): Promise<any>{
|
||||||
|
return await this.rtgsService.rtgsEntryPosting(rtgsDto,"uat")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post('validation/uat')
|
||||||
|
async validatingRtgsUat(@Body() rtgsDto: rtgsDto): Promise<any>{
|
||||||
|
return await this.rtgsService.validatingRtgs(rtgsDto,"uat")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post('encrypt')
|
||||||
|
async encryptRtgs(@Body() body: any): Promise<any>{
|
||||||
|
return await this.cryptoService.encrypt(body,config.get('crypto').sibKey,config.get('crypto').sibIv)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post('decrypt')
|
||||||
|
async decryptRtgs(@Body() body: any): Promise<any>{
|
||||||
|
return await this.cryptoService.decrypt(body.data,config.get('crypto').sibKey,config.get('crypto').sibIv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,10 @@
|
|||||||
import { Module } from '@nestjs/common';
|
import { Module } from '@nestjs/common';
|
||||||
import { RtgsController } from './rtgs.controller';
|
import { RtgsController } from './rtgs.controller';
|
||||||
import { RtgsService } from './rtgs.service';
|
import { RtgsService } from './rtgs.service';
|
||||||
|
import { CryptoService } from 'src/auth/crypto.service';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
controllers: [RtgsController],
|
controllers: [RtgsController],
|
||||||
providers: [RtgsService]
|
providers: [RtgsService,CryptoService]
|
||||||
})
|
})
|
||||||
export class RtgsModule {}
|
export class RtgsModule {}
|
||||||
|
|||||||
Loading…
Reference in New Issue