diff --git a/client/fetch/index.ts b/client/fetch/index.ts index c48c5ed..dd829a8 100644 --- a/client/fetch/index.ts +++ b/client/fetch/index.ts @@ -40,7 +40,9 @@ export default async function fetchApi( ): Promise { let data; - const csrfValue = localStorage.getItem(localStorageCSRFKey || "csrf"); + const csrfValue = localStorage.getItem( + localStorageCSRFKey || getCsrfHeaderName() + ); let finalHeaders = { "Content-Type": "application/json", diff --git a/dist/client/fetch/index.js b/dist/client/fetch/index.js index c8a02d7..77fff2f 100644 --- a/dist/client/fetch/index.js +++ b/dist/client/fetch/index.js @@ -23,7 +23,7 @@ function fetchApi(url, options, csrf, localStorageCSRFKey) { return __awaiter(this, void 0, void 0, function* () { let data; - const csrfValue = localStorage.getItem(localStorageCSRFKey || "csrf"); + const csrfValue = localStorage.getItem(localStorageCSRFKey || (0, get_csrf_header_name_1.default)()); let finalHeaders = { "Content-Type": "application/json", }; diff --git a/dist/package-shared/actions/users/user-auth.js b/dist/package-shared/actions/users/user-auth.js index 170f768..8dc6085 100644 --- a/dist/package-shared/actions/users/user-auth.js +++ b/dist/package-shared/actions/users/user-auth.js @@ -10,7 +10,7 @@ const write_auth_files_1 = require("../../functions/backend/auth/write-auth-file const parseCookies_1 = __importDefault(require("../../utils/backend/parseCookies")); const get_csrf_header_name_1 = __importDefault(require("../../actions/get-csrf-header-name")); const grab_host_names_1 = __importDefault(require("../../utils/grab-host-names")); -const debug_log_1 = __importDefault(require("@/package-shared/utils/logging/debug-log")); +const debug_log_1 = __importDefault(require("../../utils/logging/debug-log")); const minuteInMilliseconds = 60000; const hourInMilliseconds = minuteInMilliseconds * 60; const dayInMilliseconds = hourInMilliseconds * 24; @@ -122,21 +122,6 @@ function userAuth({ request, req, encryptionKey, encryptionSalt, level, database if ((level === null || level === void 0 ? void 0 : level.match(/deep/i)) && finalRequest) { const finalCsrfHeaderName = csrfHeaderName || (0, get_csrf_header_name_1.default)(); if (finalRequest.headers[finalCsrfHeaderName] !== userObject.csrf_k) { - (0, debug_log_1.default)({ - log: finalCsrfHeaderName, - addTime: true, - label: "userAuth:finalCsrfHeaderName", - }); - (0, debug_log_1.default)({ - log: finalRequest.headers[finalCsrfHeaderName], - addTime: true, - label: "userAuth:finalRequest.headers[finalCsrfHeaderName]", - }); - (0, debug_log_1.default)({ - log: userObject, - addTime: true, - label: "userAuth:userObject", - }); return { success: false, payload: null, diff --git a/dist/package-shared/functions/backend/cookies/get-auth-cookie-names.js b/dist/package-shared/functions/backend/cookies/get-auth-cookie-names.js index cccde6a..7c68391 100644 --- a/dist/package-shared/functions/backend/cookies/get-auth-cookie-names.js +++ b/dist/package-shared/functions/backend/cookies/get-auth-cookie-names.js @@ -1,6 +1,10 @@ "use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = getAuthCookieNames; +const get_csrf_header_name_1 = __importDefault(require("../../../actions/get-csrf-header-name")); /** * # Grab Auth Cookie Names */ @@ -8,7 +12,7 @@ function getAuthCookieNames(params) { var _a, _b; const cookiesPrefix = process.env.DSQL_COOKIES_PREFIX || "dsql_"; const cookiesKeyName = process.env.DSQL_COOKIES_KEY_NAME || "key"; - const cookiesCSRFName = process.env.DSQL_COOKIES_CSRF_NAME || "csrf"; + const cookiesCSRFName = (0, get_csrf_header_name_1.default)(); const cookieOneTimeCodeName = process.env.DSQL_COOKIES_ONE_TIME_CODE_NAME || "one-time-code"; const targetDatabase = ((_a = params === null || params === void 0 ? void 0 : params.database) === null || _a === void 0 ? void 0 : _a.replace(/^datasquirel_user_\d+_/, "")) || ((_b = process.env.DSQL_DB_NAME) === null || _b === void 0 ? void 0 : _b.replace(/^datasquirel_user_\d+_/, "")); diff --git a/package-shared/actions/users/user-auth.ts b/package-shared/actions/users/user-auth.ts index 2eed28b..01c8aee 100644 --- a/package-shared/actions/users/user-auth.ts +++ b/package-shared/actions/users/user-auth.ts @@ -6,7 +6,7 @@ import parseCookies from "../../utils/backend/parseCookies"; import { AuthenticatedUser } from "../../types"; import getCsrfHeaderName from "../../actions/get-csrf-header-name"; import grabHostNames from "../../utils/grab-host-names"; -import debugLog from "@/package-shared/utils/logging/debug-log"; +import debugLog from "../../utils/logging/debug-log"; const minuteInMilliseconds = 60000; const hourInMilliseconds = minuteInMilliseconds * 60; @@ -166,22 +166,6 @@ export default function userAuth({ if ( finalRequest.headers[finalCsrfHeaderName] !== userObject.csrf_k ) { - debugLog({ - log: finalCsrfHeaderName, - addTime: true, - label: "userAuth:finalCsrfHeaderName", - }); - debugLog({ - log: finalRequest.headers[finalCsrfHeaderName], - addTime: true, - label: "userAuth:finalRequest.headers[finalCsrfHeaderName]", - }); - debugLog({ - log: userObject, - addTime: true, - label: "userAuth:userObject", - }); - return { success: false, payload: null, diff --git a/package-shared/functions/backend/cookies/get-auth-cookie-names.ts b/package-shared/functions/backend/cookies/get-auth-cookie-names.ts index 7fd56f3..f4fc13a 100644 --- a/package-shared/functions/backend/cookies/get-auth-cookie-names.ts +++ b/package-shared/functions/backend/cookies/get-auth-cookie-names.ts @@ -1,3 +1,5 @@ +import getCsrfHeaderName from "../../../actions/get-csrf-header-name"; + type Param = { database?: string; userId?: string | number; @@ -15,7 +17,7 @@ type Return = { export default function getAuthCookieNames(params?: Param): Return { const cookiesPrefix = process.env.DSQL_COOKIES_PREFIX || "dsql_"; const cookiesKeyName = process.env.DSQL_COOKIES_KEY_NAME || "key"; - const cookiesCSRFName = process.env.DSQL_COOKIES_CSRF_NAME || "csrf"; + const cookiesCSRFName = getCsrfHeaderName(); const cookieOneTimeCodeName = process.env.DSQL_COOKIES_ONE_TIME_CODE_NAME || "one-time-code"; diff --git a/package.json b/package.json index 2c86b77..2aa75c2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@moduletrace/datasquirel", - "version": "4.5.1", + "version": "4.5.2", "description": "Cloud-based SQL data management tool", "main": "dist/index.js", "bin": {