feat: setup S2S integration, tailwind fixes, admin routing, nginx fallback

This commit is contained in:
2026-09-22 16:40:42 +05:30
parent 45d13fa7be
commit 05358be6c1
17 changed files with 522 additions and 149 deletions
+34
View File
@@ -0,0 +1,34 @@
const crypto = require('crypto');
// The encryption key must be exactly 32 bytes for AES-256
const getEncryptionKey = () => {
const key = process.env.ENCRYPTION_KEY || 'default_secret_key_needs_32_bytes!';
// Ensure it's 32 bytes by hashing it if it's not exactly 32 bytes
if (key.length !== 32) {
return crypto.createHash('sha256').update(key).digest();
}
return Buffer.from(key);
};
const algorithm = 'aes-256-cbc';
function encrypt(text) {
const iv = crypto.randomBytes(16);
const cipher = crypto.createCipheriv(algorithm, getEncryptionKey(), iv);
let encrypted = cipher.update(text, 'utf8', 'hex');
encrypted += cipher.final('hex');
return {
iv: iv.toString('hex'),
encryptedData: encrypted
};
}
function decrypt(encryptedData, ivHex) {
const iv = Buffer.from(ivHex, 'hex');
const decipher = crypto.createDecipheriv(algorithm, getEncryptionKey(), iv);
let decrypted = decipher.update(encryptedData, 'hex', 'utf8');
decrypted += decipher.final('utf8');
return decrypted;
}
module.exports = { encrypt, decrypt };