minor revision

This commit is contained in:
Tben 2023-07-24 22:34:01 +01:00
parent ab6a09558c
commit ca8a0b0867
4 changed files with 21 additions and 19 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "datasquirel", "name": "datasquirel",
"version": "1.1.83", "version": "1.1.84",
"description": "Cloud-based SQL data management tool", "description": "Cloud-based SQL data management tool",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {

View File

@ -19,22 +19,23 @@ const https = require("https");
*/ */
/** /**
* ============================================================================== * @typedef {object} UserDataPayload
* Main Function * @property {!string} first_name - First Name *Required
* @property {!string} last_name - Last Name *Required
* @property {!string} email - Email *Required
* @property {!string} password - Password *Required
* @property {string?} username - Username (Optional)
*/
/**
* Add User to Database
* ============================================================================== * ==============================================================================
* @async * @async
* *
* @param {{ * @param {object} props - Single object passed
* key: string, * @param {string} props.key - FULL ACCESS API Key
* database: string * @param {string} props.database - Database Name
* payload: { * @param {UserDataPayload} props.payload - User Data Payload
* first_name: string,
* last_name: string,
* username: string,
* email: string,
* password: string,
* },
* }}
* *
* @returns { Promise<FunctionReturn> } * @returns { Promise<FunctionReturn> }
*/ */

View File

@ -14,7 +14,7 @@ const encrypt = require("../functions/encrypt");
/** ****************************************************************************** */ /** ****************************************************************************** */
/** /**
* @typedef {object} FunctionReturn * @typedef {object} AuthenticatedUser
* @property {boolean} success - Did the function run successfully? * @property {boolean} success - Did the function run successfully?
* @property {{ * @property {{
* id: number, * id: number,
@ -37,13 +37,12 @@ const encrypt = require("../functions/encrypt");
*/ */
/** /**
* ============================================================================== * Login A user
* Main Function
* ============================================================================== * ==============================================================================
* @async * @async
* *
* @param {object} params - Single Param object containing params * @param {object} params - Single Param object containing params
* @param {String} params.key - API Key * @param {String} params.key - FULL ACCESS API Key
* @param {String} params.database - Target Database * @param {String} params.database - Target Database
* @param {{ * @param {{
* email: string, * email: string,
@ -53,7 +52,7 @@ const encrypt = require("../functions/encrypt");
* @param {String} params.encryptionKey - Encryption Key * @param {String} params.encryptionKey - Encryption Key
* @param {String} params.encryptionSalt - Encryption Salt * @param {String} params.encryptionSalt - Encryption Salt
* *
* @returns { Promise<FunctionReturn>} * @returns { Promise<AuthenticatedUser>}
*/ */
async function loginUser({ key, payload, database, response, encryptionKey, encryptionSalt }) { async function loginUser({ key, payload, database, response, encryptionKey, encryptionSalt }) {
/** /**

View File

@ -29,6 +29,8 @@ function logoutUser({ request, response, database }) {
const authKeyName = cookiesKeys.filter((cookieKey) => cookieKey.match(keyRegexp))[0]; const authKeyName = cookiesKeys.filter((cookieKey) => cookieKey.match(keyRegexp))[0];
const csrfName = cookiesKeys.filter((cookieKey) => cookieKey.match(csrfRegexp))[0]; const csrfName = cookiesKeys.filter((cookieKey) => cookieKey.match(csrfRegexp))[0];
console.log(authKeyName, csrfName);
if (authKeyName && csrfName) { if (authKeyName && csrfName) {
response.setHeader("Set-Cookie", [`${authKeyName}=null;samesite=strict;path=/;HttpOnly=true;Secure=true`, `${csrfName}=null;samesite=strict;path=/;HttpOnly=true`, `dsqluid=null;samesite=strict;path=/;HttpOnly=true`]); response.setHeader("Set-Cookie", [`${authKeyName}=null;samesite=strict;path=/;HttpOnly=true;Secure=true`, `${csrfName}=null;samesite=strict;path=/;HttpOnly=true`, `dsqluid=null;samesite=strict;path=/;HttpOnly=true`]);
} else { } else {