"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = validateToken; const decrypt_1 = __importDefault(require("../../functions/dsql/decrypt")); /** * Validate Token * ====================================== * @description This Function takes in a encrypted token and returns a user object */ function validateToken({ token, encryptionKey, encryptionSalt, }) { try { /** * Grab the payload * * @description Grab the payload */ const key = token; /** * Grab the payload * * @description Grab the payload */ let userPayload = (0, decrypt_1.default)({ encryptedString: key, encryptionKey, encryptionSalt, }); /** * Grab the payload * * @description Grab the payload */ if (!userPayload) { return null; } /** * Grab the payload * * @description Grab the payload */ let userObject = JSON.parse(userPayload); if (!userObject.csrf_k) { return null; } /** * Return User Object * * @description Return User Object */ return userObject; } catch (error) { /** * Return User Object * * @description Return User Object */ return null; } }