2024-11-05 11:12:42 +00:00
|
|
|
"use strict";
|
|
|
|
exports.id = 4432;
|
|
|
|
exports.ids = [4432];
|
|
|
|
exports.modules = {
|
|
|
|
|
|
|
|
/***/ 4432:
|
|
|
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
|
|
|
|
|
|
// @ts-check
|
|
|
|
|
|
|
|
const { IncomingMessage } = __webpack_require__(3685);
|
|
|
|
const decrypt = __webpack_require__(5425);
|
|
|
|
/**
|
|
|
|
* @async
|
|
|
|
* @param {import("next").NextApiRequest | IncomingMessage & { cookies: Partial<{ [key: string]: string; }>} } req - https request object
|
|
|
|
*
|
|
|
|
* @returns {Promise<({ email: string, password: string, authKey: string, logged_in_status: boolean, date: number } | null)>}
|
|
|
|
*/ module.exports = async function(req) {
|
|
|
|
/** ********************* Check for existence of required cookie */ if (!req.cookies?.datasquirelSuAdminUserAuthKey) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
/** ********************* Grab the payload */ let userPayload = decrypt(req.cookies.datasquirelSuAdminUserAuthKey);
|
|
|
|
/** ********************* Return if no payload */ if (!userPayload) return null;
|
|
|
|
/** ********************* Parse the payload */ let userObject = JSON.parse(userPayload);
|
|
|
|
if (userObject.password !== process.env.DSQL_USER_KEY) return null;
|
|
|
|
if (userObject.authKey !== process.env.DSQL_SPECIAL_KEY) return null;
|
|
|
|
////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
/** ********************* return user object */ return userObject;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2024-11-05 14:18:40 +00:00
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
/***/ 5425:
|
|
|
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
|
|
|
|
|
|
// @ts-check
|
|
|
|
|
|
|
|
const { scryptSync , createDecipheriv } = __webpack_require__(6113);
|
|
|
|
const { Buffer } = __webpack_require__(4300);
|
|
|
|
/**
|
|
|
|
* @param {string} encryptedString
|
|
|
|
* @returns {string | null}
|
|
|
|
*/ const decrypt = (encryptedString)=>{
|
|
|
|
const algorithm = "aes-192-cbc";
|
|
|
|
const password = process.env.DSQL_ENCRYPTION_PASSWORD || "";
|
|
|
|
const salt = process.env.DSQL_ENCRYPTION_SALT || "";
|
|
|
|
let key = scryptSync(password, salt, 24);
|
|
|
|
let iv = Buffer.alloc(16, 0);
|
|
|
|
// @ts-ignore
|
|
|
|
const decipher = createDecipheriv(algorithm, key, iv);
|
|
|
|
try {
|
|
|
|
let decrypted = decipher.update(encryptedString, "hex", "utf8");
|
|
|
|
decrypted += decipher.final("utf8");
|
|
|
|
return decrypted;
|
|
|
|
} catch (error) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
module.exports = decrypt;
|
|
|
|
|
|
|
|
|
2024-11-05 11:12:42 +00:00
|
|
|
/***/ })
|
|
|
|
|
|
|
|
};
|
|
|
|
;
|