This commit is contained in:
Tben 2023-08-13 12:06:14 +01:00
parent 4264704ce8
commit bf45ea89ba
3 changed files with 16 additions and 6 deletions

View File

@ -1,21 +1,31 @@
// @ts-check
const { scryptSync, createDecipheriv } = require("crypto"); const { scryptSync, createDecipheriv } = require("crypto");
const { Buffer } = require("buffer"); const { Buffer } = require("buffer");
/**
*
* @param {object} param0
* @param {string} param0.encryptedString
* @param {string} param0.encryptionKey
* @param {string} param0.encryptionSalt
* @returns
*/
const decrypt = ({ encryptedString, encryptionKey, encryptionSalt }) => { const decrypt = ({ encryptedString, encryptionKey, encryptionSalt }) => {
if (!encryptedString?.match(/.}/)) { if (!encryptedString?.match(/.}/)) {
console.log("Encrypted string is invalid"); console.log("Encrypted string is invalid");
console.log("Encrypted string =>", encryptedString); console.log("Encrypted string =>", encryptedString);
return data; return encryptedString;
} }
if (!encryptionKey?.match(/.{8,}/)) { if (!encryptionKey?.match(/.{8,}/)) {
console.log("Decrption key is invalid"); console.log("Decrption key is invalid");
return data; return encryptedString;
} }
if (!encryptionSalt?.match(/.{8,}/)) { if (!encryptionSalt?.match(/.{8,}/)) {
console.log("Decrption salt is invalid"); console.log("Decrption salt is invalid");
return data; return encryptedString;
} }
const algorithm = "aes-192-cbc"; const algorithm = "aes-192-cbc";
@ -33,7 +43,7 @@ const decrypt = ({ encryptedString, encryptionKey, encryptionSalt }) => {
console.log("encryptedString =>", encryptedString); console.log("encryptedString =>", encryptedString);
console.log("encryptionKey =>", encryptionKey); console.log("encryptionKey =>", encryptionKey);
console.log("encryptionSalt =>", encryptionSalt); console.log("encryptionSalt =>", encryptionSalt);
return data; return encryptedString;
} }
}; };

View File

@ -1,6 +1,6 @@
{ {
"name": "datasquirel", "name": "datasquirel",
"version": "1.6.6", "version": "1.6.7",
"description": "Cloud-based SQL data management tool", "description": "Cloud-based SQL data management tool",
"main": "index.js", "main": "index.js",
"bin": { "bin": {

View File

@ -21,7 +21,7 @@ const decrypt = require("../functions/decrypt");
* @description This Function takes in a encrypted token and returns a user object * @description This Function takes in a encrypted token and returns a user object
* *
* @param {Object} params - Arg * @param {Object} params - Arg
* @param {http.IncomingMessage} params.token - Http request object * @param {string} params.token - Encrypted Token
* @param {string} params.encryptionKey - Encryption Key * @param {string} params.encryptionKey - Encryption Key
* @param {string} params.encryptionSalt - Encryption Salt * @param {string} params.encryptionSalt - Encryption Salt
* @param {("deep" | "normal")?} [params.level] - Optional. "Deep" value indicates an extra layer of security * @param {("deep" | "normal")?} [params.level] - Optional. "Deep" value indicates an extra layer of security