dsql-admin/dsql-app/.local_dist/server/chunks/4480.js

111 lines
3.0 KiB
JavaScript
Raw Normal View History

2024-11-05 14:18:40 +00:00
"use strict";
exports.id = 4480;
exports.ids = [4480];
exports.modules = {
/***/ 5304:
/***/ ((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;
/***/ }),
/***/ 9395:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
// @ts-check
const mysql = __webpack_require__(2261);
2024-11-06 12:57:20 +00:00
const grabDbSSL = __webpack_require__(3260);
2024-11-05 14:18:40 +00:00
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,
2024-11-06 12:06:51 +00:00
port: process.env.DSQL_DB_PORT ? Number(process.env.DSQL_DB_PORT) : undefined,
2024-11-05 14:18:40 +00:00
charset: "utf8mb4",
2024-11-06 12:57:20 +00:00
ssl: grabDbSSL()
2024-11-05 14:18:40 +00:00
}
});
/**
* 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;
2024-11-06 12:57:20 +00:00
/***/ }),
/***/ 3260:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
// @ts-check
const fs = __webpack_require__(7147);
/**
* @returns {string | (import("tls").SecureContextOptions & { rejectUnauthorized?: boolean | undefined;}) | undefined}
*/ module.exports = function grabDbSSL() {
const SSL_DIR = process.env.DSQL_SSL_DIR;
2024-11-11 08:34:43 +00:00
if (!SSL_DIR?.match(/./)) {
// console.log(
// "No SSL certificate provided. Query will run in normal mode. To add SSL add an env path dir `DSQL_SSL_DIR` with a file named `ca-cert.pem`"
// );
return undefined;
}
2024-11-06 12:57:20 +00:00
const caFilePath = `${SSL_DIR}/ca-cert.pem`;
if (!fs.existsSync(caFilePath)) {
console.log(`${caFilePath} does not exist`);
return undefined;
}
return {
ca: fs.readFileSync(`${SSL_DIR}/ca-cert.pem`)
};
};
2024-11-05 14:18:40 +00:00
/***/ })
};
;