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",
"version": "1.1.83",
"version": "1.1.84",
"description": "Cloud-based SQL data management tool",
"main": "index.js",
"scripts": {

View File

@ -19,22 +19,23 @@ const https = require("https");
*/
/**
* ==============================================================================
* Main Function
* @typedef {object} UserDataPayload
* @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
*
* @param {{
* key: string,
* database: string
* payload: {
* first_name: string,
* last_name: string,
* username: string,
* email: string,
* password: string,
* },
* }}
* @param {object} props - Single object passed
* @param {string} props.key - FULL ACCESS API Key
* @param {string} props.database - Database Name
* @param {UserDataPayload} props.payload - User Data Payload
*
* @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 {{
* id: number,
@ -37,13 +37,12 @@ const encrypt = require("../functions/encrypt");
*/
/**
* ==============================================================================
* Main Function
* Login A user
* ==============================================================================
* @async
*
* @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 {{
* email: string,
@ -53,7 +52,7 @@ const encrypt = require("../functions/encrypt");
* @param {String} params.encryptionKey - Encryption Key
* @param {String} params.encryptionSalt - Encryption Salt
*
* @returns { Promise<FunctionReturn>}
* @returns { Promise<AuthenticatedUser>}
*/
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 csrfName = cookiesKeys.filter((cookieKey) => cookieKey.match(csrfRegexp))[0];
console.log(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`]);
} else {