secure-flow
Advanced tools
Comparing version 1.0.0 to 1.0.1
{ | ||
"name": "secure-flow", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Secure Flow is a lightweight TypeScript utility package for encryption and decryption using the AES-256-CBC algorithm. This package simplifies the process of securely encrypting and decrypting text, making it easy to integrate strong encryption into your Node.js applications.", | ||
"main": "server.js", | ||
"type": "module", | ||
"main": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"build": "tsc", | ||
"create-config": "ts-node src/cli.ts", | ||
"dev": "npm run build && nodemon --inspect ./dist/server.js", | ||
"start": "npm run build && node ./dist/server.js" | ||
}, | ||
"bin": { | ||
"create-secureflow-config": "./bin/create-secureflow-config.js" | ||
}, | ||
"keywords": [ | ||
@@ -14,0 +18,0 @@ "encrypt", |
@@ -1,3 +0,2 @@ | ||
// config.js | ||
export const config = { | ||
export const defaultConfig = { | ||
encryptionAlgorithm: "aes-256-cbc", | ||
@@ -7,1 +6,3 @@ encryptionKey: "12345678901234567890123456789012", // Must be 32 characters | ||
}; | ||
export type Config = typeof defaultConfig; |
import crypto from "crypto"; | ||
import { config } from "./config.js"; | ||
import { loadConfig } from './loadConfig.js'; | ||
import { Config } from './config.js'; | ||
const { encryptionAlgorithm, encryptionKey, iv } = config; | ||
const config: Config = loadConfig(); | ||
@@ -10,5 +11,5 @@ // Define return types and parameter types for the functions | ||
const cipher = crypto.createCipheriv( | ||
encryptionAlgorithm, | ||
Buffer.from(encryptionKey), | ||
iv | ||
config.encryptionAlgorithm, | ||
Buffer.from(config.encryptionKey), | ||
config.iv | ||
); | ||
@@ -27,5 +28,5 @@ let encrypted = cipher.update(text, "utf8", "hex"); | ||
const decipher = crypto.createDecipheriv( | ||
encryptionAlgorithm, | ||
Buffer.from(encryptionKey), | ||
iv | ||
config.encryptionAlgorithm, | ||
Buffer.from(config.encryptionKey), | ||
config.iv | ||
); | ||
@@ -32,0 +33,0 @@ |
@@ -6,4 +6,7 @@ import express, { Request, Response, NextFunction } from "express"; | ||
app.use(express.json()); | ||
app.use(express.urlencoded({ extended: true })); | ||
// Middleware to encrypt response | ||
app.use((req: Request, res: Response, next: NextFunction) => { | ||
app.use('/encrypt', (req: Request, res: Response, next: NextFunction) => { | ||
const originalSend = res.send; | ||
@@ -20,4 +23,4 @@ res.send = function (body: any) { | ||
// Sample route | ||
app.get("/", (req: Request, res: Response) => { | ||
res.send("Hello, world!"); | ||
app.get("/encrypt", (req: Request, res: Response) => { | ||
res.send(req.body); | ||
}); | ||
@@ -27,8 +30,9 @@ | ||
app.get("/decrypt", (req: Request, res: Response) => { | ||
const encryptedMessage = encrypt("Hello, World!"); | ||
const encryptedMessage = req.body.data; | ||
if (encryptedMessage) { | ||
const decryptedMessage = decrypt(encryptedMessage); | ||
console.log(encryptedMessage); | ||
console.log(decryptedMessage); | ||
res.send(`Decrypted message: ${decryptedMessage}`); | ||
console.log(JSON.parse(decryptedMessage)); | ||
res.status(200).json(decryptedMessage); | ||
} else { | ||
@@ -35,0 +39,0 @@ res.status(400).send("No message provided"); |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
11485
16
256
3
1
No