From bf45ea89bad9b5f75388b32f1bd61cfc6a04a6f1 Mon Sep 17 00:00:00 2001 From: Tben Date: Sun, 13 Aug 2023 12:06:14 +0100 Subject: [PATCH] Upgrades --- functions/decrypt.js | 18 ++++++++++++++---- package.json | 2 +- users/validate-token.js | 2 +- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/functions/decrypt.js b/functions/decrypt.js index 7627cef..59e0182 100644 --- a/functions/decrypt.js +++ b/functions/decrypt.js @@ -1,21 +1,31 @@ +// @ts-check + const { scryptSync, createDecipheriv } = require("crypto"); 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 }) => { if (!encryptedString?.match(/.}/)) { console.log("Encrypted string is invalid"); console.log("Encrypted string =>", encryptedString); - return data; + return encryptedString; } if (!encryptionKey?.match(/.{8,}/)) { console.log("Decrption key is invalid"); - return data; + return encryptedString; } if (!encryptionSalt?.match(/.{8,}/)) { console.log("Decrption salt is invalid"); - return data; + return encryptedString; } const algorithm = "aes-192-cbc"; @@ -33,7 +43,7 @@ const decrypt = ({ encryptedString, encryptionKey, encryptionSalt }) => { console.log("encryptedString =>", encryptedString); console.log("encryptionKey =>", encryptionKey); console.log("encryptionSalt =>", encryptionSalt); - return data; + return encryptedString; } }; diff --git a/package.json b/package.json index 54edb6f..adc00e6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "datasquirel", - "version": "1.6.6", + "version": "1.6.7", "description": "Cloud-based SQL data management tool", "main": "index.js", "bin": { diff --git a/users/validate-token.js b/users/validate-token.js index b16381a..e920592 100644 --- a/users/validate-token.js +++ b/users/validate-token.js @@ -21,7 +21,7 @@ const decrypt = require("../functions/decrypt"); * @description This Function takes in a encrypted token and returns a user object * * @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.encryptionSalt - Encryption Salt * @param {("deep" | "normal")?} [params.level] - Optional. "Deep" value indicates an extra layer of security