Updates
This commit is contained in:
Vendored
+2
-2
@@ -58,6 +58,7 @@ function post(_a) {
|
||||
* @description make a request to datasquirel.com
|
||||
*/
|
||||
const httpResponse = yield new Promise((resolve, reject) => {
|
||||
var _a;
|
||||
const reqPayloadString = JSON.stringify({
|
||||
query,
|
||||
queryValues,
|
||||
@@ -68,8 +69,7 @@ function post(_a) {
|
||||
JSON.parse(reqPayloadString);
|
||||
}
|
||||
catch (error) {
|
||||
console.log(error);
|
||||
console.log(reqPayloadString);
|
||||
(_a = global.ERROR_CALLBACK) === null || _a === void 0 ? void 0 : _a.call(global, `Error Parsing HTTP response for post action`, error);
|
||||
return {
|
||||
success: false,
|
||||
payload: null,
|
||||
|
||||
+2
@@ -19,6 +19,7 @@ const grab_host_names_1 = __importDefault(require("../utils/grab-host-names"));
|
||||
*/
|
||||
function uploadImage(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ key, payload, user_id, }) {
|
||||
var _b;
|
||||
const grabedHostNames = (0, grab_host_names_1.default)();
|
||||
const { host, port, scheme } = grabedHostNames;
|
||||
try {
|
||||
@@ -66,6 +67,7 @@ function uploadImage(_a) {
|
||||
}
|
||||
catch (error) {
|
||||
console.log("Error in uploading file: ", error.message);
|
||||
(_b = global.ERROR_CALLBACK) === null || _b === void 0 ? void 0 : _b.call(global, `Error Uploading File`, error);
|
||||
return {
|
||||
success: false,
|
||||
payload: null,
|
||||
|
||||
+2
@@ -20,6 +20,7 @@ const grab_host_names_1 = __importDefault(require("../utils/grab-host-names"));
|
||||
*/
|
||||
function uploadImage(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ key, payload, user_id, }) {
|
||||
var _b;
|
||||
const grabedHostNames = (0, grab_host_names_1.default)();
|
||||
const { host, port, scheme } = grabedHostNames;
|
||||
try {
|
||||
@@ -67,6 +68,7 @@ function uploadImage(_a) {
|
||||
}
|
||||
catch (error) {
|
||||
console.log("Error in uploading image: ", error.message);
|
||||
(_b = global.ERROR_CALLBACK) === null || _b === void 0 ? void 0 : _b.call(global, `Error Uploading Image`, error);
|
||||
return {
|
||||
success: false,
|
||||
payload: null,
|
||||
|
||||
@@ -14,6 +14,7 @@ const parseCookies_1 = __importDefault(require("../../utils/backend/parseCookies
|
||||
* string and csrf token string
|
||||
*/
|
||||
function getToken({ request, encryptionKey, encryptionSalt, cookieString, }) {
|
||||
var _a;
|
||||
try {
|
||||
/**
|
||||
* Grab the payload
|
||||
@@ -61,6 +62,7 @@ function getToken({ request, encryptionKey, encryptionSalt, cookieString, }) {
|
||||
return { key, csrf };
|
||||
}
|
||||
catch (error) {
|
||||
(_a = global.ERROR_CALLBACK) === null || _a === void 0 ? void 0 : _a.call(global, `Error Getting Token`, error);
|
||||
/**
|
||||
* Return User Object
|
||||
*
|
||||
|
||||
+5
-3
@@ -26,7 +26,7 @@ const debug_log_1 = __importDefault(require("../../utils/logging/debug-log"));
|
||||
*/
|
||||
function loginUser(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ key, payload, database, additionalFields, response, encryptionKey, encryptionSalt, email_login, email_login_code, temp_code_field, token, user_id, skipPassword, apiUserID, skipWriteAuthFile, dbUserId, debug, }) {
|
||||
var _b;
|
||||
var _b, _c;
|
||||
const grabedHostNames = (0, grab_host_names_1.default)({ userId: user_id || apiUserID });
|
||||
const { host, port, scheme } = grabedHostNames;
|
||||
const defaultTempLoginFieldName = "temp_login_code";
|
||||
@@ -164,7 +164,9 @@ function loginUser(_a) {
|
||||
if (token && encryptedPayload)
|
||||
httpResponse["token"] = encryptedPayload;
|
||||
}
|
||||
catch (error) { }
|
||||
catch (error) {
|
||||
(_b = global.ERROR_CALLBACK) === null || _b === void 0 ? void 0 : _b.call(global, `Login User HTTP Response Error`, error);
|
||||
}
|
||||
const cookieNames = (0, get_auth_cookie_names_1.default)({
|
||||
database,
|
||||
userId: grabedHostNames.user_id,
|
||||
@@ -183,7 +185,7 @@ function loginUser(_a) {
|
||||
}
|
||||
response === null || response === void 0 ? void 0 : response.setHeader("Set-Cookie", [
|
||||
`${authKeyName}=${encryptedPayload};samesite=strict;path=/;HttpOnly=true;Secure=true`,
|
||||
`${csrfName}=${(_b = httpResponse.payload) === null || _b === void 0 ? void 0 : _b.csrf_k};samesite=strict;path=/;HttpOnly=true`,
|
||||
`${csrfName}=${(_c = httpResponse.payload) === null || _c === void 0 ? void 0 : _c.csrf_k};samesite=strict;path=/;HttpOnly=true`,
|
||||
]);
|
||||
if (debug) {
|
||||
debugFn("Response Sent!");
|
||||
|
||||
@@ -15,6 +15,7 @@ const debug_log_1 = __importDefault(require("../../utils/logging/debug-log"));
|
||||
* # Logout user
|
||||
*/
|
||||
function logoutUser({ response, database, dsqlUserId, encryptedUserString, request, cookieString, debug, }) {
|
||||
var _a;
|
||||
/**
|
||||
* Check Encryption Keys
|
||||
*
|
||||
@@ -83,6 +84,7 @@ function logoutUser({ response, database, dsqlUserId, encryptedUserString, reque
|
||||
}
|
||||
catch (error) {
|
||||
console.log("Logout Error:", error.message);
|
||||
(_a = global.ERROR_CALLBACK) === null || _a === void 0 ? void 0 : _a.call(global, `Logout User Error`, error);
|
||||
return {
|
||||
success: false,
|
||||
msg: "Logout Failed",
|
||||
|
||||
+2
-1
@@ -123,11 +123,12 @@ function githubAuth(_a) {
|
||||
str += chunk;
|
||||
});
|
||||
response.on("end", function () {
|
||||
var _a;
|
||||
try {
|
||||
resolve(JSON.parse(str));
|
||||
}
|
||||
catch (error) {
|
||||
console.log(error);
|
||||
(_a = global.ERROR_CALLBACK) === null || _a === void 0 ? void 0 : _a.call(global, `Github Auth Error`, error);
|
||||
resolve({
|
||||
success: false,
|
||||
user: null,
|
||||
|
||||
@@ -23,6 +23,7 @@ const yearInMilliseconds = dayInMilliseconds * 365;
|
||||
* with the user's data
|
||||
*/
|
||||
function userAuth({ request, req, encryptionKey, encryptionSalt, level, database, dsqlUserId, encryptedUserString, expiry = weekInMilliseconds, cookieString, csrfHeaderName, debug, }) {
|
||||
var _a;
|
||||
try {
|
||||
const finalRequest = req || request;
|
||||
const { user_id } = (0, grab_host_names_1.default)({ userId: dsqlUserId });
|
||||
@@ -147,6 +148,7 @@ function userAuth({ request, req, encryptionKey, encryptionSalt, level, database
|
||||
};
|
||||
}
|
||||
catch (error) {
|
||||
(_a = global.ERROR_CALLBACK) === null || _a === void 0 ? void 0 : _a.call(global, `User Auth Error`, error);
|
||||
/**
|
||||
* Return User Object
|
||||
*
|
||||
|
||||
@@ -22,6 +22,7 @@ const ejson_1 = __importDefault(require("../../utils/ejson"));
|
||||
*/
|
||||
function validateTempEmailCode(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ request, email, cookieString, }) {
|
||||
var _b;
|
||||
try {
|
||||
const keyNames = (0, get_auth_cookie_names_1.default)();
|
||||
const oneTimeCodeCookieName = keyNames.oneTimeCodeName;
|
||||
@@ -40,6 +41,7 @@ function validateTempEmailCode(_a) {
|
||||
return null;
|
||||
}
|
||||
catch (error) {
|
||||
(_b = global.ERROR_CALLBACK) === null || _b === void 0 ? void 0 : _b.call(global, `Validate Temp Email Code Error`, error);
|
||||
console.log("validateTempEmailCode error:", error.message);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ const decrypt_1 = __importDefault(require("../../functions/dsql/decrypt"));
|
||||
* @description This Function takes in a encrypted token and returns a user object
|
||||
*/
|
||||
function validateToken({ token, encryptionKey, encryptionSalt, }) {
|
||||
var _a;
|
||||
try {
|
||||
/**
|
||||
* Grab the payload
|
||||
@@ -53,6 +54,7 @@ function validateToken({ token, encryptionKey, encryptionSalt, }) {
|
||||
return userObject;
|
||||
}
|
||||
catch (error) {
|
||||
(_a = global.ERROR_CALLBACK) === null || _a === void 0 ? void 0 : _a.call(global, `Validate Token Error`, error);
|
||||
/**
|
||||
* Return User Object
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user