Updates
This commit is contained in:
@@ -3,7 +3,7 @@ exports.id = 3314;
|
||||
exports.ids = [3314];
|
||||
exports.modules = {
|
||||
|
||||
/***/ 2527:
|
||||
/***/ 3314:
|
||||
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
||||
|
||||
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||||
|
||||
@@ -237,7 +237,14 @@ exports.modules = {
|
||||
}),
|
||||
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_CopySlug__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .Z, {
|
||||
slugText: database.db_slug,
|
||||
title: `Copy Database Slug`
|
||||
title: `Db Slug`
|
||||
}),
|
||||
true && /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
|
||||
className: "-mt-1 gap-1",
|
||||
children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_CopySlug__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .Z, {
|
||||
slugText: database.db_full_name,
|
||||
title: "Full DB Name"
|
||||
})
|
||||
}),
|
||||
!isDelegated && /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)((react__WEBPACK_IMPORTED_MODULE_1___default().Fragment), {
|
||||
children: [
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
"use strict";
|
||||
exports.id = 5304;
|
||||
exports.ids = [5304];
|
||||
exports.modules = {
|
||||
|
||||
/***/ 5304:
|
||||
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
||||
|
||||
// @ts-check
|
||||
|
||||
const { scryptSync , createDecipheriv } = __webpack_require__(6113);
|
||||
const { Buffer } = __webpack_require__(4300);
|
||||
// const serverError = require("./serverError");
|
||||
/**
|
||||
* @param {string} encryptedString
|
||||
* @returns {string | null}
|
||||
*/ const decrypt = (encryptedString)=>{
|
||||
// /** @type {import("crypto").CipherCCMTypes} */
|
||||
const algorithm = "aes-192-cbc";
|
||||
const password = process.env.DSQL_ENCRYPTION_PASSWORD || "";
|
||||
const salt = process.env.DSQL_ENCRYPTION_SALT || "";
|
||||
// /** @type {import("crypto").CipherKey} */
|
||||
let key = scryptSync(password, salt, 24);
|
||||
let iv = Buffer.alloc(16, 0);
|
||||
// @ts-ignore
|
||||
const decipher = createDecipheriv(algorithm, key, iv);
|
||||
/** ********************* Decrypt String */ try {
|
||||
let decrypted = decipher.update(encryptedString, "hex", "utf8");
|
||||
decrypted += decipher.final("utf8");
|
||||
return decrypted;
|
||||
} catch (error) {
|
||||
// serverError({
|
||||
// component: "decrypt",
|
||||
// message: error.message,
|
||||
// user: {},
|
||||
// });
|
||||
return null;
|
||||
}
|
||||
};
|
||||
module.exports = decrypt;
|
||||
|
||||
|
||||
/***/ })
|
||||
|
||||
};
|
||||
;
|
||||
@@ -1,46 +0,0 @@
|
||||
"use strict";
|
||||
exports.id = 5425;
|
||||
exports.ids = [5425];
|
||||
exports.modules = {
|
||||
|
||||
/***/ 5425:
|
||||
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
||||
|
||||
// @ts-check
|
||||
|
||||
const { scryptSync , createDecipheriv } = __webpack_require__(6113);
|
||||
const { Buffer } = __webpack_require__(4300);
|
||||
// const serverError = require("./serverError");
|
||||
/**
|
||||
* @param {string} encryptedString
|
||||
* @returns {string | null}
|
||||
*/ const decrypt = (encryptedString)=>{
|
||||
// /** @type {import("crypto").CipherCCMTypes} */
|
||||
const algorithm = "aes-192-cbc";
|
||||
const password = process.env.DSQL_ENCRYPTION_PASSWORD || "";
|
||||
const salt = process.env.DSQL_ENCRYPTION_SALT || "";
|
||||
// /** @type {import("crypto").CipherKey} */
|
||||
let key = scryptSync(password, salt, 24);
|
||||
let iv = Buffer.alloc(16, 0);
|
||||
// @ts-ignore
|
||||
const decipher = createDecipheriv(algorithm, key, iv);
|
||||
/** ********************* Decrypt String */ try {
|
||||
let decrypted = decipher.update(encryptedString, "hex", "utf8");
|
||||
decrypted += decipher.final("utf8");
|
||||
return decrypted;
|
||||
} catch (error) {
|
||||
// serverError({
|
||||
// component: "decrypt",
|
||||
// message: error.message,
|
||||
// user: {},
|
||||
// });
|
||||
return null;
|
||||
}
|
||||
};
|
||||
module.exports = decrypt;
|
||||
|
||||
|
||||
/***/ })
|
||||
|
||||
};
|
||||
;
|
||||
@@ -1,142 +0,0 @@
|
||||
"use strict";
|
||||
exports.id = 6251;
|
||||
exports.ids = [6251];
|
||||
exports.modules = {
|
||||
|
||||
/***/ 6251:
|
||||
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
||||
|
||||
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||||
/* harmony export */ "Z": () => (/* binding */ SuErrorLogsContent)
|
||||
/* harmony export */ });
|
||||
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(997);
|
||||
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__);
|
||||
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(6689);
|
||||
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
|
||||
/* harmony import */ var _functions_frontend_fetchApi__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(6729);
|
||||
/* harmony import */ var _general_LoadingBlock__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(5264);
|
||||
// @ts-check
|
||||
/**
|
||||
* ==============================================================================
|
||||
* Imports
|
||||
* ==============================================================================
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
|
||||
* ==============================================================================
|
||||
* Main Component { Functional }
|
||||
* ==============================================================================
|
||||
* @param {Object} props - Server props
|
||||
*/ function SuErrorLogsContent(props) {
|
||||
/**
|
||||
* Get Contexts
|
||||
*
|
||||
* @abstract { React.useContext }
|
||||
*/ ////////////////////////////////////////
|
||||
////////////////////////////////////////
|
||||
////////////////////////////////////////
|
||||
/**
|
||||
* Javascript Variables
|
||||
*
|
||||
* @abstract Non hook variables and functions
|
||||
*/ ////////////////////////////////////////
|
||||
////////////////////////////////////////
|
||||
////////////////////////////////////////
|
||||
/**
|
||||
* React Hooks
|
||||
*
|
||||
* @abstract { useState, useEffect, useRef, etc ... }
|
||||
*/ /** @type {[ errorLog: string | null, setErrorLog: React.Dispatch<React.SetStateAction<string | null>> ]} */ // @ts-ignore
|
||||
const [errorLog, setErrorLog] = react__WEBPACK_IMPORTED_MODULE_1___default().useState(null);
|
||||
const [loading, setLoading] = react__WEBPACK_IMPORTED_MODULE_1___default().useState(false);
|
||||
const [refresh, setRefresh] = react__WEBPACK_IMPORTED_MODULE_1___default().useState(0);
|
||||
function fetchErrorLogs() {
|
||||
(0,_functions_frontend_fetchApi__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z)("/api/admin/grabErrorLogs").then((res)=>{
|
||||
if (typeof res.log === "string" && !res.log?.match(/./)) {
|
||||
setErrorLog("No Logs Yet");
|
||||
return;
|
||||
} else {
|
||||
setErrorLog("");
|
||||
}
|
||||
setErrorLog(res.log.replace(/\n|\r|\n\r|\\n/gm, "<br/>"));
|
||||
});
|
||||
}
|
||||
react__WEBPACK_IMPORTED_MODULE_1___default().useEffect(()=>{
|
||||
fetchErrorLogs();
|
||||
if (refresh === 0) {
|
||||
setInterval(()=>{
|
||||
fetchErrorLogs();
|
||||
}, 10000);
|
||||
}
|
||||
}, [
|
||||
refresh
|
||||
]);
|
||||
////////////////////////////////////////
|
||||
////////////////////////////////////////
|
||||
////////////////////////////////////////
|
||||
/**
|
||||
* Function Return
|
||||
*
|
||||
* @abstract Main Function Return
|
||||
*/ return /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)((react__WEBPACK_IMPORTED_MODULE_1___default().Fragment), {
|
||||
children: [
|
||||
/*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
|
||||
className: "w-full justify-between",
|
||||
children: [
|
||||
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("h2", {
|
||||
className: "text-xl m-0",
|
||||
children: "Error Logs"
|
||||
}),
|
||||
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
|
||||
children: /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("button", {
|
||||
onClick: (e)=>{
|
||||
if (window.confirm("Clear Error Logs?")) {
|
||||
setLoading(true);
|
||||
(0,_functions_frontend_fetchApi__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z)("/api/admin/clearErrorLogs", "post").then((res)=>{
|
||||
console.log(res);
|
||||
setRefresh((prev)=>prev + 1);
|
||||
});
|
||||
setTimeout(()=>{
|
||||
setLoading(false);
|
||||
}, 2000);
|
||||
}
|
||||
},
|
||||
className: "outlined gray relative",
|
||||
children: [
|
||||
loading && /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_general_LoadingBlock__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .Z, {
|
||||
width: "20px"
|
||||
}),
|
||||
"Clear Error Log"
|
||||
]
|
||||
})
|
||||
})
|
||||
]
|
||||
}),
|
||||
/*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("section", {
|
||||
className: "paper",
|
||||
children: [
|
||||
errorLog && /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("p", {
|
||||
dangerouslySetInnerHTML: {
|
||||
__html: errorLog ? errorLog : "No Log"
|
||||
}
|
||||
}),
|
||||
!errorLog && /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_general_LoadingBlock__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .Z, {
|
||||
position: "relative",
|
||||
width: "25px"
|
||||
})
|
||||
]
|
||||
})
|
||||
]
|
||||
});
|
||||
////////////////////////////////////////
|
||||
////////////////////////////////////////
|
||||
////////////////////////////////////////
|
||||
} /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */
|
||||
|
||||
|
||||
/***/ })
|
||||
|
||||
};
|
||||
;
|
||||
@@ -1927,7 +1927,7 @@ var AssignmentTwoTone_default = /*#__PURE__*/__webpack_require__.n(AssignmentTwo
|
||||
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__);
|
||||
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(6689);
|
||||
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
|
||||
/* harmony import */ var _functions_frontend_inputFileToBase64__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(3314);
|
||||
/* harmony import */ var _functions_frontend_inputFileToBase64__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(8345);
|
||||
// @ts-check
|
||||
/**
|
||||
* ==============================================================================
|
||||
@@ -2125,7 +2125,7 @@ var AssignmentTwoTone_default = /*#__PURE__*/__webpack_require__.n(AssignmentTwo
|
||||
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__);
|
||||
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(6689);
|
||||
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
|
||||
/* harmony import */ var _functions_frontend_inputFileToBase64__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(3314);
|
||||
/* harmony import */ var _functions_frontend_inputFileToBase64__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(8345);
|
||||
// @ts-check
|
||||
/**
|
||||
* ==============================================================================
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
"use strict";
|
||||
exports.id = 7192;
|
||||
exports.ids = [7192];
|
||||
exports.modules = {
|
||||
|
||||
/***/ 7192:
|
||||
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
||||
|
||||
// @ts-check
|
||||
/**
|
||||
* ==============================================================================
|
||||
* Imports
|
||||
* ==============================================================================
|
||||
*/
|
||||
const generator = __webpack_require__(3785);
|
||||
const DB_HANDLER = __webpack_require__(2224);
|
||||
const NO_DB_HANDLER = __webpack_require__(7487);
|
||||
const encrypt = __webpack_require__(7547);
|
||||
const addDbEntry = __webpack_require__(5338);
|
||||
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
|
||||
* Add Mariadb User
|
||||
* ==============================================================================
|
||||
*
|
||||
* @description this function adds a Mariadb user to the database server
|
||||
*
|
||||
* @param {object} params - parameters object *
|
||||
* @param {number | string} params.userId - invited user object
|
||||
*
|
||||
* @returns {Promise<any>} new user auth object payload
|
||||
*/ module.exports = async function addMariadbUser({ userId }) {
|
||||
try {
|
||||
const defaultMariadbUserHost = process.env.DSQL_DB_HOST || "127.0.0.1";
|
||||
const username = `dsql_user_${userId}`;
|
||||
const password = generator.generate({
|
||||
length: 16,
|
||||
numbers: true,
|
||||
symbols: true,
|
||||
uppercase: true,
|
||||
exclude: "*#.'`\""
|
||||
});
|
||||
const encryptedPassword = encrypt(password);
|
||||
await NO_DB_HANDLER(`CREATE USER IF NOT EXISTS '${username}'@'127.0.0.1' IDENTIFIED BY '${password}' REQUIRE SSL`);
|
||||
const updateUser = await DB_HANDLER(`UPDATE users SET mariadb_user = ?, mariadb_host = '127.0.0.1', mariadb_pass = ? WHERE id = ?`, [
|
||||
username,
|
||||
encryptedPassword,
|
||||
userId
|
||||
]);
|
||||
const addMariadbUser1 = await addDbEntry({
|
||||
tableName: "mariadb_users",
|
||||
data: {
|
||||
user_id: userId,
|
||||
username,
|
||||
host: defaultMariadbUserHost,
|
||||
password: encryptedPassword,
|
||||
primary: "1",
|
||||
grants: '[{"database":"*","table":"*","privileges":["ALL"]}]'
|
||||
},
|
||||
dbContext: "Master"
|
||||
});
|
||||
console.log("addMariadbUser =>", addMariadbUser1);
|
||||
console.log(`User ${userId} SQL credentials successfully added.`);
|
||||
} catch (/** @type {any} */ error) {
|
||||
console.log(`Error in adding SQL user in 'addMariadbUser' function =>`, error.message);
|
||||
}
|
||||
}; ////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////
|
||||
|
||||
|
||||
/***/ })
|
||||
|
||||
};
|
||||
;
|
||||
@@ -30,15 +30,20 @@ exports.modules = {
|
||||
* slugText: string,
|
||||
* smaller?: boolean,
|
||||
* outlined?: boolean,
|
||||
* full?:boolean
|
||||
* }} props - React component props including { children }
|
||||
*/ function DatabaseSlugCopy({ slugText , smaller , outlined }) {
|
||||
*/ function DatabaseSlugCopy({ slugText , smaller , outlined , full , }) {
|
||||
return /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("span", {
|
||||
className: "button " + (outlined ? " outlined gray" : "light-gray") + (smaller ? " small-text" : ""),
|
||||
className: "button break-words text-wrap cancel-link " + (outlined ? " outlined gray" : "light-gray") + (smaller ? " small-text" : ""),
|
||||
onClick: (e)=>{
|
||||
navigator.clipboard.writeText(slugText).then(()=>{
|
||||
alert(`Database Slug "${slugText}" Copied to Clipboard. Use this as the database name when querying data`);
|
||||
alert(`${full ? "Database Full name" : "Database Slug"} "${slugText}" Copied to Clipboard. Use this as the database name when querying data`);
|
||||
});
|
||||
},
|
||||
style: {
|
||||
wordWrap: "break-word",
|
||||
wordBreak: "break-all"
|
||||
},
|
||||
children: [
|
||||
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx((_mui_icons_material_CopyAllTwoTone__WEBPACK_IMPORTED_MODULE_2___default()), {
|
||||
color: "action",
|
||||
|
||||
@@ -1,350 +0,0 @@
|
||||
"use strict";
|
||||
exports.id = 7839;
|
||||
exports.ids = [7839];
|
||||
exports.modules = {
|
||||
|
||||
/***/ 7839:
|
||||
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
||||
|
||||
// @ts-check
|
||||
/**
|
||||
* ==============================================================================
|
||||
* Imports
|
||||
* ==============================================================================
|
||||
*/
|
||||
const fs = __webpack_require__(7147);
|
||||
////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////
|
||||
const addAdminUserOnLogin = __webpack_require__(613);
|
||||
const handleNodemailer = __webpack_require__(6926);
|
||||
const { ServerResponse } = __webpack_require__(3685);
|
||||
const path = __webpack_require__(1017);
|
||||
const addMariadbUser = __webpack_require__(4294);
|
||||
const varDatabaseDbHandler = __webpack_require__(1311);
|
||||
const encrypt = __webpack_require__(7547);
|
||||
const addDbEntry = __webpack_require__(5338);
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* @typedef {object} FunctionReturn
|
||||
* @property {boolean} success - Did the operation complete successfully or not?
|
||||
* @property {{
|
||||
* id: number,
|
||||
* first_name: string,
|
||||
* last_name: string,
|
||||
* }|null} user - User payload object: or "null"
|
||||
*/ /**
|
||||
* Handle Social User Auth on Datasquirel Database
|
||||
* ==============================================================================
|
||||
*
|
||||
* @description This function handles all social login logic after the social user
|
||||
* has been authenticated and userpayload is present. The payload MUST contain the
|
||||
* specified fields because this funciton will create a new user if the authenticated
|
||||
* user does not exist.
|
||||
*
|
||||
* @param {{
|
||||
* database?: string,
|
||||
* social_id: string|number,
|
||||
* email: string,
|
||||
* social_platform: string,
|
||||
* payload: any,
|
||||
* res?: ServerResponse,
|
||||
* invitation?: any,
|
||||
* supEmail?: string,
|
||||
* additionalFields?: object,
|
||||
* }} params - function parameters inside an object
|
||||
*
|
||||
* @returns {Promise<any>} - Response object
|
||||
*/ module.exports = async function handleSocialDb({ database , social_id , email , social_platform , payload , res , invitation , supEmail , additionalFields , }) {
|
||||
////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////
|
||||
try {
|
||||
////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////
|
||||
let existingSocialIdUser = await varDatabaseDbHandler({
|
||||
database: database ? database : "datasquirel",
|
||||
queryString: `SELECT * FROM users WHERE social_id = ? AND social_login='1' AND social_platform = ? `,
|
||||
queryValuesArray: [
|
||||
social_id.toString(),
|
||||
social_platform
|
||||
]
|
||||
});
|
||||
if (existingSocialIdUser && existingSocialIdUser[0]) {
|
||||
return await loginSocialUser({
|
||||
user: existingSocialIdUser[0],
|
||||
social_platform,
|
||||
res,
|
||||
invitation,
|
||||
database,
|
||||
additionalFields
|
||||
});
|
||||
}
|
||||
////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////
|
||||
const finalEmail = email ? email : supEmail ? supEmail : null;
|
||||
if (!finalEmail) {
|
||||
return {
|
||||
success: false,
|
||||
user: null,
|
||||
msg: "No Email Present",
|
||||
social_id,
|
||||
social_platform,
|
||||
payload
|
||||
};
|
||||
}
|
||||
////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////
|
||||
let existingEmailOnly = await varDatabaseDbHandler({
|
||||
database: database ? database : "datasquirel",
|
||||
queryString: `SELECT * FROM users WHERE email='${finalEmail}'`
|
||||
});
|
||||
if (existingEmailOnly && existingEmailOnly[0]) {
|
||||
return {
|
||||
user: null,
|
||||
msg: "This Email is already taken",
|
||||
alert: true
|
||||
};
|
||||
}
|
||||
////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////
|
||||
const foundUser = await varDatabaseDbHandler({
|
||||
database: database ? database : "datasquirel",
|
||||
queryString: `SELECT * FROM users WHERE email='${finalEmail}' AND social_login='1' AND social_platform='${social_platform}' AND social_id='${social_id}'`
|
||||
});
|
||||
if (foundUser && foundUser[0]) {
|
||||
return await loginSocialUser({
|
||||
user: payload,
|
||||
social_platform,
|
||||
res,
|
||||
invitation,
|
||||
database,
|
||||
additionalFields
|
||||
});
|
||||
}
|
||||
////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////
|
||||
const socialHashedPassword = encrypt(social_id.toString());
|
||||
/** @type {any} */ const data = {
|
||||
social_login: "1",
|
||||
verification_status: supEmail ? "0" : "1",
|
||||
password: socialHashedPassword
|
||||
};
|
||||
Object.keys(payload).forEach((key)=>{
|
||||
data[key] = payload[key];
|
||||
});
|
||||
/** @type {any} */ const newUser = await addDbEntry({
|
||||
dbContext: database ? "Dsql User" : undefined,
|
||||
paradigm: database ? "Full Access" : undefined,
|
||||
dbFullName: database ? database : "datasquirel",
|
||||
tableName: "users",
|
||||
duplicateColumnName: "email",
|
||||
duplicateColumnValue: finalEmail,
|
||||
data: {
|
||||
...data,
|
||||
email: finalEmail
|
||||
}
|
||||
});
|
||||
if (newUser?.insertId) {
|
||||
if (!database) {
|
||||
/**
|
||||
* Add a Mariadb User for this User
|
||||
*/ await addMariadbUser({
|
||||
userId: newUser.insertId
|
||||
});
|
||||
}
|
||||
const newUserQueried = await varDatabaseDbHandler({
|
||||
database: database ? database : "datasquirel",
|
||||
queryString: `SELECT * FROM users WHERE id='${newUser.insertId}'`
|
||||
});
|
||||
if (!newUserQueried || !newUserQueried[0]) return {
|
||||
user: null,
|
||||
msg: "User Insertion Failed!"
|
||||
};
|
||||
////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////
|
||||
if (supEmail && database?.match(/^datasquirel$/)) {
|
||||
/**
|
||||
* Send email Verification
|
||||
*
|
||||
* @description Send verification email to newly created agent
|
||||
*/ let generatedToken = encrypt(JSON.stringify({
|
||||
id: newUser.insertId,
|
||||
email: supEmail,
|
||||
dateCode: Date.now()
|
||||
}));
|
||||
handleNodemailer({
|
||||
to: supEmail,
|
||||
subject: "Verify Email Address",
|
||||
text: "Please click the link to verify your email address",
|
||||
html: fs.readFileSync("./email/send-email-verification-link.html", "utf8").replace(/{{host}}/, process.env.DSQL_HOST || "").replace(/{{token}}/, generatedToken || "")
|
||||
}).then((mail)=>{});
|
||||
}
|
||||
////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////
|
||||
const STATIC_ROOT = process.env.DSQL_STATIC_SERVER_DIR;
|
||||
if (!STATIC_ROOT) {
|
||||
console.log("Static File ENV not Found!");
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Create new user folder and file
|
||||
*
|
||||
* @description Create new user folder and file
|
||||
*/ if (!database || database?.match(/^datasquirel$/)) {
|
||||
let newUserSchemaFolderPath = `${process.env.DSQL_USER_DB_SCHEMA_PATH}/user-${newUser.insertId}`;
|
||||
let newUserMediaFolderPath = path.join(STATIC_ROOT, `images/user-images/user-${newUser.insertId}`);
|
||||
fs.mkdirSync(newUserSchemaFolderPath);
|
||||
fs.mkdirSync(newUserMediaFolderPath);
|
||||
fs.writeFileSync(`${newUserSchemaFolderPath}/main.json`, JSON.stringify([]), "utf8");
|
||||
}
|
||||
////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////
|
||||
return await loginSocialUser({
|
||||
user: newUserQueried[0],
|
||||
social_platform,
|
||||
res,
|
||||
invitation,
|
||||
database,
|
||||
additionalFields
|
||||
});
|
||||
////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////
|
||||
} else {
|
||||
console.log("Social User Failed to insert in 'handleSocialDb.js' backend function =>", newUser);
|
||||
return {
|
||||
success: false,
|
||||
user: null,
|
||||
msg: "Social User Failed to insert in 'handleSocialDb.js' backend function => ",
|
||||
newUser: newUser
|
||||
};
|
||||
}
|
||||
////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////
|
||||
} catch (/** @type {any} */ error) {
|
||||
console.log("ERROR in 'handleSocialDb.js' backend function =>", error.message);
|
||||
return {
|
||||
success: false,
|
||||
user: null,
|
||||
error: error.message
|
||||
};
|
||||
// serverError({
|
||||
// component: "/functions/backend/social-login/handleSocialDb.js - main-catch-error",
|
||||
// message: error.message,
|
||||
// user: { first_name, last_name },
|
||||
// });
|
||||
}
|
||||
////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////
|
||||
return {
|
||||
user: null,
|
||||
msg: "User Login Failed!"
|
||||
};
|
||||
};
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* Function to login social user
|
||||
* ==============================================================================
|
||||
* @description This function logs in the user after 'handleSocialDb' function finishes
|
||||
* the user creation or confirmation process
|
||||
*
|
||||
* @async
|
||||
*
|
||||
* @param {object} params - function parameters inside an object
|
||||
* @param {{
|
||||
* first_name: string,
|
||||
* last_name: string,
|
||||
* email: string,
|
||||
* social_id: string|number,
|
||||
* }} params.user - user object
|
||||
* @param {string} params.social_platform - Whether its "google" or "facebook" or "github"
|
||||
* @param {ServerResponse} [params.res] - Https response object
|
||||
* @param {any} [params.invitation] - A query object if user was invited
|
||||
* @param {string} [params.database] - Target Database
|
||||
* @param {object} [params.additionalFields] - Additional fields to be added to the user payload
|
||||
*
|
||||
* @returns {Promise<any>}
|
||||
*/ async function loginSocialUser({ user , social_platform , res , invitation , database , additionalFields , }) {
|
||||
const foundUser = await varDatabaseDbHandler({
|
||||
database: database ? database : "datasquirel",
|
||||
queryString: `SELECT * FROM users WHERE email='${user.email}' AND social_id='${user.social_id}' AND social_platform='${social_platform}'`
|
||||
});
|
||||
if (!foundUser?.[0]) return {
|
||||
success: false,
|
||||
user: null
|
||||
};
|
||||
let csrfKey = Math.random().toString(36).substring(2) + "-" + Math.random().toString(36).substring(2);
|
||||
/** @type {any} */ let userPayload = {
|
||||
id: foundUser[0].id,
|
||||
type: foundUser[0].type || "",
|
||||
stripe_id: foundUser[0].stripe_id || "",
|
||||
first_name: foundUser[0].first_name,
|
||||
last_name: foundUser[0].last_name,
|
||||
username: foundUser[0].username,
|
||||
email: foundUser[0].email,
|
||||
social_id: foundUser[0].social_id,
|
||||
image: foundUser[0].image,
|
||||
image_thumbnail: foundUser[0].image_thumbnail,
|
||||
verification_status: foundUser[0].verification_status,
|
||||
social_login: foundUser[0].social_login,
|
||||
social_platform: foundUser[0].social_platform,
|
||||
csrf_k: csrfKey,
|
||||
logged_in_status: true,
|
||||
date: Date.now()
|
||||
};
|
||||
if (additionalFields && Object.keys(additionalFields).length > 0) {
|
||||
Object.keys(additionalFields).forEach((key)=>{
|
||||
userPayload[key] = foundUser[0][key];
|
||||
});
|
||||
}
|
||||
let encryptedPayload = encrypt(JSON.stringify(userPayload));
|
||||
if (res?.setHeader) {
|
||||
res.setHeader("Set-Cookie", [
|
||||
`datasquirelAuthKey=${encryptedPayload};samesite=strict;path=/;HttpOnly=true;Secure=true`,
|
||||
`csrf=${csrfKey};samesite=strict;path=/;HttpOnly=true`,
|
||||
]);
|
||||
}
|
||||
////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////
|
||||
if (invitation && (!database || database?.match(/^datasquirel$/))) {
|
||||
addAdminUserOnLogin({
|
||||
query: invitation,
|
||||
user: userPayload
|
||||
});
|
||||
}
|
||||
////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////
|
||||
return {
|
||||
success: true,
|
||||
user: userPayload
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/***/ })
|
||||
|
||||
};
|
||||
;
|
||||
@@ -347,7 +347,7 @@ var TableViewTwoTone_default = /*#__PURE__*/__webpack_require__.n(TableViewTwoTo
|
||||
// EXTERNAL MODULE: ./functions/frontend/fetchApi.js
|
||||
var fetchApi = __webpack_require__(6729);
|
||||
// EXTERNAL MODULE: ./functions/frontend/inputFileToBase64.js
|
||||
var inputFileToBase64 = __webpack_require__(3314);
|
||||
var inputFileToBase64 = __webpack_require__(8345);
|
||||
// EXTERNAL MODULE: ./components/general/LoadingBlock.jsx
|
||||
var LoadingBlock = __webpack_require__(5264);
|
||||
;// CONCATENATED MODULE: ./components/admin/databases/ImportDbComponent.jsx
|
||||
|
||||
@@ -3,7 +3,7 @@ exports.id = 8345;
|
||||
exports.ids = [8345];
|
||||
exports.modules = {
|
||||
|
||||
/***/ 3314:
|
||||
/***/ 8345:
|
||||
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
||||
|
||||
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||||
|
||||
@@ -1,284 +0,0 @@
|
||||
"use strict";
|
||||
exports.id = 8499;
|
||||
exports.ids = [8499];
|
||||
exports.modules = {
|
||||
|
||||
/***/ 8499:
|
||||
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
||||
|
||||
/** # MODULE TRACE
|
||||
======================================================================
|
||||
* Detected 3 files that call this module. The files are listed below:
|
||||
======================================================================
|
||||
* `import` Statement Found in [get.js] => file:///d:\GitHub\datasquirel\pages\api\query\get.js
|
||||
* `import` Statement Found in [post.js] => file:///d:\GitHub\datasquirel\pages\api\query\post.js
|
||||
* `import` Statement Found in [add-user.js] => file:///d:\GitHub\datasquirel\pages\api\user\add-user.js
|
||||
==== MODULE TRACE END ==== */ // @ts-check
|
||||
|
||||
const fs = __webpack_require__(7147);
|
||||
const fullAccessDbHandler = __webpack_require__(8539);
|
||||
const varReadOnlyDatabaseDbHandler = __webpack_require__(3118);
|
||||
const serverError = __webpack_require__(3017);
|
||||
const addDbEntry = __webpack_require__(5338);
|
||||
const updateDbEntry = __webpack_require__(5886);
|
||||
const deleteDbEntry = __webpack_require__(6147);
|
||||
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
|
||||
* Run DSQL users queries
|
||||
* ==============================================================================
|
||||
* @param {object} params - An object containing the function parameters.
|
||||
* @param {string} params.dbFullName - Database full name. Eg. "datasquire_user_2_test"
|
||||
* @param {string|any} params.query - Query string or object
|
||||
* @param {boolean} [params.readOnly] - Is this operation read only?
|
||||
* @param {import("../../../types").DSQL_DatabaseSchemaType} [params.dbSchema] - Database schema
|
||||
* @param {string[]} [params.queryValuesArray] - An optional array of query values if "?" is used in the query string
|
||||
* @param {string} [params.tableName] - Table Name
|
||||
*
|
||||
* @return {Promise<any>}
|
||||
*/ async function runQuery({ dbFullName , query , readOnly , dbSchema , queryValuesArray , tableName , }) {
|
||||
/**
|
||||
* Declare variables
|
||||
*
|
||||
* @description Declare "results" variable
|
||||
*/ /** @type {any} */ let result;
|
||||
/** @type {any} */ let error;
|
||||
/** @type {import("../../../types").DSQL_TableSchemaType | undefined} */ let tableSchema;
|
||||
if (dbSchema) {
|
||||
try {
|
||||
const table = tableName ? tableName : typeof query == "string" ? null : query ? query?.table : null;
|
||||
if (!table) throw new Error("No table name provided");
|
||||
tableSchema = dbSchema.tables.filter((tb)=>tb?.tableName === table)[0];
|
||||
} catch (_err) {
|
||||
// console.log("ERROR getting tableSchema: ", _err.message);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Declare variables
|
||||
*
|
||||
* @description Declare "results" variable
|
||||
*/ try {
|
||||
if (typeof query === "string") {
|
||||
if (readOnly) {
|
||||
result = await varReadOnlyDatabaseDbHandler({
|
||||
queryString: query,
|
||||
queryValuesArray,
|
||||
database: dbFullName,
|
||||
tableSchema
|
||||
});
|
||||
} else {
|
||||
result = await fullAccessDbHandler({
|
||||
queryString: query,
|
||||
queryValuesArray,
|
||||
database: dbFullName,
|
||||
tableSchema
|
||||
});
|
||||
}
|
||||
} else if (typeof query === "object") {
|
||||
/**
|
||||
* Declare variables
|
||||
*
|
||||
* @description Declare "results" variable
|
||||
*/ const { data , action , table: table1 , identifierColumnName , identifierValue , update , duplicateColumnName , duplicateColumnValue , } = query;
|
||||
switch(action.toLowerCase()){
|
||||
case "insert":
|
||||
result = await addDbEntry({
|
||||
dbContext: "Dsql User",
|
||||
paradigm: "Full Access",
|
||||
dbFullName: dbFullName,
|
||||
tableName: table1,
|
||||
data: data,
|
||||
update,
|
||||
duplicateColumnName,
|
||||
duplicateColumnValue,
|
||||
tableSchema
|
||||
});
|
||||
if (!result?.insertId) {
|
||||
error = new Error("Couldn't insert data");
|
||||
}
|
||||
break;
|
||||
case "update":
|
||||
result = await updateDbEntry({
|
||||
dbContext: "Dsql User",
|
||||
paradigm: "Full Access",
|
||||
dbFullName: dbFullName,
|
||||
tableName: table1,
|
||||
data: data,
|
||||
identifierColumnName,
|
||||
identifierValue,
|
||||
tableSchema
|
||||
});
|
||||
break;
|
||||
case "delete":
|
||||
result = await deleteDbEntry({
|
||||
dbContext: "Dsql User",
|
||||
paradigm: "Full Access",
|
||||
dbFullName: dbFullName,
|
||||
tableName: table1,
|
||||
identifierColumnName,
|
||||
identifierValue,
|
||||
tableSchema
|
||||
});
|
||||
break;
|
||||
default:
|
||||
result = null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
////////////////////////////////////////
|
||||
////////////////////////////////////////
|
||||
////////////////////////////////////////
|
||||
} catch (/** @type {any} */ error1) {
|
||||
serverError({
|
||||
component: "functions/backend/runQuery",
|
||||
message: error1.message
|
||||
});
|
||||
result = null;
|
||||
error1 = error1.message;
|
||||
}
|
||||
////////////////////////////////////////
|
||||
////////////////////////////////////////
|
||||
////////////////////////////////////////
|
||||
return {
|
||||
result,
|
||||
error
|
||||
};
|
||||
////////////////////////////////////////
|
||||
////////////////////////////////////////
|
||||
////////////////////////////////////////
|
||||
}
|
||||
module.exports = runQuery;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 8539:
|
||||
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
||||
|
||||
// @ts-check
|
||||
|
||||
const DSQL_USER_DB_HANDLER = __webpack_require__(3403);
|
||||
const parseDbResults = __webpack_require__(8326);
|
||||
const serverError = __webpack_require__(3017);
|
||||
/**
|
||||
*
|
||||
* @param {object} param0
|
||||
* @param {string} param0.queryString
|
||||
* @param {string} param0.database
|
||||
* @param {import("../../types").DSQL_TableSchemaType | null} [param0.tableSchema]
|
||||
* @param {string[]} [param0.queryValuesArray]
|
||||
* @returns
|
||||
*/ module.exports = async function fullAccessDbHandler({ queryString , database , tableSchema , queryValuesArray , }) {
|
||||
/**
|
||||
* Declare variables
|
||||
*
|
||||
* @description Declare "results" variable
|
||||
*/ let results;
|
||||
/**
|
||||
* Fetch from db
|
||||
*
|
||||
* @description Fetch data from db if no cache
|
||||
*/ try {
|
||||
/** ********************* Run Query */ results = await DSQL_USER_DB_HANDLER({
|
||||
paradigm: "Full Access",
|
||||
database,
|
||||
queryString,
|
||||
queryValues: queryValuesArray
|
||||
});
|
||||
////////////////////////////////////////
|
||||
} catch (/** @type {any} */ error) {
|
||||
////////////////////////////////////////
|
||||
serverError({
|
||||
component: "fullAccessDbHandler",
|
||||
message: error.message
|
||||
});
|
||||
/**
|
||||
* Return error
|
||||
*/ return error.message;
|
||||
}
|
||||
/**
|
||||
* Return results
|
||||
*
|
||||
* @description Return results add to cache if "req" param is passed
|
||||
*/ if (results && tableSchema) {
|
||||
const unparsedResults = results;
|
||||
const parsedResults = await parseDbResults({
|
||||
unparsedResults: unparsedResults,
|
||||
tableSchema: tableSchema
|
||||
});
|
||||
return parsedResults;
|
||||
} else if (results) {
|
||||
return results;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 3118:
|
||||
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
||||
|
||||
// @ts-check
|
||||
|
||||
const fs = __webpack_require__(7147);
|
||||
const serverError = __webpack_require__(3017);
|
||||
const parseDbResults = __webpack_require__(8326);
|
||||
const DSQL_USER_DB_HANDLER = __webpack_require__(3403);
|
||||
/**
|
||||
*
|
||||
* @param {object} param0
|
||||
* @param {string} param0.queryString
|
||||
* @param {string} param0.database
|
||||
* @param {string[]} [param0.queryValuesArray]
|
||||
* @param {import("../../types").DSQL_TableSchemaType} [param0.tableSchema]
|
||||
* @returns
|
||||
*/ module.exports = async function varReadOnlyDatabaseDbHandler({ queryString , database , queryValuesArray , tableSchema , }) {
|
||||
/**
|
||||
* Declare variables
|
||||
*
|
||||
* @description Declare "results" variable
|
||||
*/ let results;
|
||||
/**
|
||||
* Fetch from db
|
||||
*
|
||||
* @description Fetch data from db if no cache
|
||||
*/ try {
|
||||
results = await DSQL_USER_DB_HANDLER({
|
||||
paradigm: "Read Only",
|
||||
database,
|
||||
queryString,
|
||||
queryValues: queryValuesArray
|
||||
});
|
||||
////////////////////////////////////////
|
||||
} catch (/** @type {any} */ error) {
|
||||
////////////////////////////////////////
|
||||
serverError({
|
||||
component: "varReadOnlyDatabaseDbHandler",
|
||||
message: error.message,
|
||||
noMail: true
|
||||
});
|
||||
/**
|
||||
* Return error
|
||||
*/ return error.message;
|
||||
}
|
||||
/**
|
||||
* Return results
|
||||
*
|
||||
* @description Return results add to cache if "req" param is passed
|
||||
*/ if (results) {
|
||||
const unparsedResults = results;
|
||||
const parsedResults = await parseDbResults({
|
||||
unparsedResults: unparsedResults,
|
||||
tableSchema: tableSchema
|
||||
});
|
||||
return parsedResults;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/***/ })
|
||||
|
||||
};
|
||||
;
|
||||
@@ -20,7 +20,7 @@ var external_react_default = /*#__PURE__*/__webpack_require__.n(external_react_)
|
||||
// EXTERNAL MODULE: ./components/general/LoadingBlock.jsx
|
||||
var LoadingBlock = __webpack_require__(5264);
|
||||
// EXTERNAL MODULE: ./functions/frontend/inputFileToBase64.js
|
||||
var inputFileToBase64 = __webpack_require__(3314);
|
||||
var inputFileToBase64 = __webpack_require__(8345);
|
||||
// EXTERNAL MODULE: ./functions/frontend/fetchApi.js
|
||||
var fetchApi = __webpack_require__(6729);
|
||||
;// CONCATENATED MODULE: ./components/admin/databases/functions/import-export-handler.js
|
||||
|
||||
@@ -76,8 +76,9 @@ exports.modules = {
|
||||
href: url,
|
||||
className: "card",
|
||||
onClick: (e)=>{
|
||||
// @ts-ignore
|
||||
if (e.target.closest(".db-list-item-actions-block")) {
|
||||
if (// @ts-ignore
|
||||
e.target.closest(".db-list-item-actions-block") || // @ts-ignore
|
||||
e.target.closest(".cancel-link")) {
|
||||
e.preventDefault();
|
||||
}
|
||||
if (delegated) {
|
||||
@@ -133,6 +134,14 @@ exports.modules = {
|
||||
slugText: database.db_slug,
|
||||
smaller: true
|
||||
})
|
||||
}),
|
||||
true && /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
|
||||
className: "-mt-1 gap-1",
|
||||
children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_general_DatabaseSlugCopy__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .Z, {
|
||||
slugText: database.db_full_name,
|
||||
smaller: true,
|
||||
full: true
|
||||
})
|
||||
}),
|
||||
!delegated && /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("span", {
|
||||
className: "text-sm text-slate-400",
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
"use strict";
|
||||
exports.id = 9395;
|
||||
exports.ids = [9395];
|
||||
exports.modules = {
|
||||
|
||||
/***/ 9395:
|
||||
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
||||
|
||||
// @ts-check
|
||||
|
||||
const fs = __webpack_require__(7147);
|
||||
const path = __webpack_require__(1017);
|
||||
const mysql = __webpack_require__(2261);
|
||||
const SSL_DIR = "/app/ssl";
|
||||
const MASTER = mysql({
|
||||
config: {
|
||||
host: process.env.DSQL_DB_HOST,
|
||||
user: process.env.DSQL_DB_USERNAME,
|
||||
password: process.env.DSQL_DB_PASSWORD,
|
||||
database: process.env.DSQL_DB_NAME,
|
||||
port: process.env.DB_PORT ? Number(process.env.DB_PORT) : undefined,
|
||||
charset: "utf8mb4",
|
||||
ssl: {
|
||||
ca: fs.readFileSync(`${SSL_DIR}/ca-cert.pem`)
|
||||
}
|
||||
}
|
||||
});
|
||||
/**
|
||||
* DSQL user read-only DB handler
|
||||
* @param {object} params
|
||||
* @param {string} params.paradigm
|
||||
* @param {string} params.database
|
||||
* @param {string} params.queryString
|
||||
* @param {string[]} [params.queryValues]
|
||||
*/ // @ts-ignore
|
||||
async function DB_HANDLER(...args) {
|
||||
try {
|
||||
const results = await MASTER.query(...args);
|
||||
/** ********************* Clean up */ await MASTER.end();
|
||||
return JSON.parse(JSON.stringify(results));
|
||||
} catch (/** @type {any} */ error) {
|
||||
console.log("DB Error =>", error);
|
||||
return {
|
||||
success: false,
|
||||
error: error.message
|
||||
};
|
||||
}
|
||||
}
|
||||
module.exports = DB_HANDLER;
|
||||
|
||||
|
||||
/***/ })
|
||||
|
||||
};
|
||||
;
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user