This commit is contained in:
2025-12-26 06:37:30 +01:00
parent 98aaa94b80
commit b02399c64d
50 changed files with 112 additions and 105 deletions
+1 -3
View File
@@ -17,7 +17,5 @@ type Param<T = {
*/
export default function queryDSQLAPI<T = {
[k: string]: any;
}, P = {
[k: string]: any;
}>({ body, query, useDefault, path: passedPath, method, apiKey, apiConnectionConfig, grabbedHostnames, }: Param<T>): Promise<APIResponseObject<P>>;
}>({ body, query, useDefault, path: passedPath, method, apiKey, apiConnectionConfig, grabbedHostnames, }: Param<T>): Promise<APIResponseObject>;
export {};
@@ -121,8 +121,8 @@ function handleSocialDb(_a) {
duplicateColumnValue: finalEmail,
data: Object.assign(Object.assign({}, data), { email: finalEmail }),
});
if ((_b = newUser === null || newUser === void 0 ? void 0 : newUser.payload) === null || _b === void 0 ? void 0 : _b.insertId) {
const newUserQueriedQuery = `SELECT * FROM users WHERE id='${newUser.payload.insertId}'`;
if ((_b = newUser === null || newUser === void 0 ? void 0 : newUser.postInsertReturn) === null || _b === void 0 ? void 0 : _b.insertId) {
const newUserQueriedQuery = `SELECT * FROM users WHERE id='${newUser.postInsertReturn.insertId}'`;
const newUserQueried = (yield (0, dbHandler_1.default)({
database: finalDbName,
query: newUserQueriedQuery,
@@ -141,7 +141,7 @@ function handleSocialDb(_a) {
*/
let generatedToken = (0, encrypt_1.default)({
data: JSON.stringify({
id: newUser.payload.insertId,
id: newUser.postInsertReturn.insertId,
email: supEmail,
dateCode: Date.now(),
}),
+2 -2
View File
@@ -138,8 +138,8 @@ function apiCreateUser(_a) {
"/images/user-preset.png", image_thumbnail: process.env.DSQL_DEFAULT_USER_IMAGE ||
"/images/user-preset-thumbnail.png", verification_status: verify ? 1 : 0 }),
});
if ((_b = addUser === null || addUser === void 0 ? void 0 : addUser.payload) === null || _b === void 0 ? void 0 : _b.insertId) {
const newlyAddedUserQuery = `SELECT id,uuid,first_name,last_name,email,username,image,image_thumbnail,verification_status FROM ${dbFullName}.users WHERE id='${addUser.payload.insertId}'`;
if ((_b = addUser === null || addUser === void 0 ? void 0 : addUser.postInsertReturn) === null || _b === void 0 ? void 0 : _b.insertId) {
const newlyAddedUserQuery = `SELECT id,uuid,first_name,last_name,email,username,image,image_thumbnail,verification_status FROM ${dbFullName}.users WHERE id='${addUser.postInsertReturn.insertId}'`;
const newlyAddedUser = (yield (0, dbHandler_1.default)({
query: newlyAddedUserQuery,
values: [],
+1 -1
View File
@@ -153,7 +153,7 @@ function apiLoginUser(_a) {
const resposeObject = {
success: true,
msg: "Login Successful",
payload: userPayload,
singleRes: userPayload,
userId: foundUser[0].id,
csrf: csrfKey,
};
@@ -49,7 +49,7 @@ function apiResetUserPassword(_a) {
});
return {
success: true,
payload: updateUser,
singleRes: updateUser,
};
});
}
+1 -1
View File
@@ -75,7 +75,7 @@ function apiUpdateUser(_a) {
});
return {
success: true,
payload: updateUser,
singleRes: updateUser,
};
});
}
@@ -1,4 +1,4 @@
import { APILoginFunctionReturn } from "../../../../types";
import { APIResponseObject } from "../../../../types";
type Param = {
code?: string;
clientId?: string;
@@ -13,5 +13,5 @@ type Param = {
/**
* # API Login with Github
*/
export default function apiGithubLogin({ code, clientId, clientSecret, database, additionalFields, email, additionalData, }: Param): Promise<APILoginFunctionReturn>;
export default function apiGithubLogin({ code, clientId, clientSecret, database, additionalFields, email, additionalData, }: Param): Promise<APIResponseObject>;
export {};
@@ -20,7 +20,7 @@ function postLoginResponseHandler({ database, httpResponse, response, encryption
const COOKIE_EXPIRY_DATE = (0, grab_cookie_expirt_date_1.default)();
if (httpResponse === null || httpResponse === void 0 ? void 0 : httpResponse.success) {
let encryptedPayload = (0, encrypt_1.default)({
data: JSON.stringify(httpResponse.payload),
data: JSON.stringify(httpResponse.singleRes),
encryptionKey,
encryptionSalt,
});
@@ -35,8 +35,8 @@ function postLoginResponseHandler({ database, httpResponse, response, encryption
database,
});
if (httpResponse.csrf && !skipWriteAuthFile) {
(0, write_auth_files_1.writeAuthFile)(httpResponse.csrf, JSON.stringify(httpResponse.payload), cleanupTokens && ((_a = httpResponse.payload) === null || _a === void 0 ? void 0 : _a.id)
? { userId: httpResponse.payload.id }
(0, write_auth_files_1.writeAuthFile)(httpResponse.csrf, JSON.stringify(httpResponse.singleRes), cleanupTokens && ((_a = httpResponse.singleRes) === null || _a === void 0 ? void 0 : _a.id)
? { userId: httpResponse.singleRes.id }
: undefined);
}
httpResponse["cookieNames"] = cookieNames;
@@ -50,7 +50,7 @@ function postLoginResponseHandler({ database, httpResponse, response, encryption
}
response === null || response === void 0 ? void 0 : response.setHeader("Set-Cookie", [
`${authKeyName}=${encryptedPayload};samesite=strict;path=/;HttpOnly=true;Expires=${COOKIE_EXPIRY_DATE}${secureCookie ? ";Secure=true" : ""}`,
`${csrfName}=${(_b = httpResponse.payload) === null || _b === void 0 ? void 0 : _b.csrf_k};samesite=strict;path=/;HttpOnly=true;Expires=${COOKIE_EXPIRY_DATE}`,
`${csrfName}=${(_b = httpResponse.singleRes) === null || _b === void 0 ? void 0 : _b.csrf_k};samesite=strict;path=/;HttpOnly=true;Expires=${COOKIE_EXPIRY_DATE}`,
]);
if (debug) {
debugFn("Response Sent!");
@@ -38,7 +38,7 @@ function suAddBackup(_a) {
tableName: "backups",
data: newBackup,
});
if (!((_b = newBackupEntry === null || newBackupEntry === void 0 ? void 0 : newBackupEntry.payload) === null || _b === void 0 ? void 0 : _b.insertId)) {
if (!((_b = newBackupEntry === null || newBackupEntry === void 0 ? void 0 : newBackupEntry.postInsertReturn) === null || _b === void 0 ? void 0 : _b.insertId)) {
return {
success: false,
msg: `Couldn't create new backup entry`,
@@ -46,7 +46,7 @@ function suAddBackup(_a) {
}
const { single: newlyAddedBackup } = yield (0, grab_user_resource_1.default)({
tableName: "backups",
targetID: (_c = newBackupEntry.payload) === null || _c === void 0 ? void 0 : _c.insertId,
targetID: (_c = newBackupEntry.postInsertReturn) === null || _c === void 0 ? void 0 : _c.insertId,
isSuperUser: true,
});
if (!(newlyAddedBackup === null || newlyAddedBackup === void 0 ? void 0 : newlyAddedBackup.id)) {
+1 -1
View File
@@ -53,7 +53,7 @@ function deleteDbEntry(_a) {
*/
return {
success: Boolean(deletedEntry.affectedRows),
payload: deletedEntry,
postInsertReturn: deletedEntry,
queryObject: {
sql: (0, sql_formatter_1.format)(query),
params: values,
+1 -1
View File
@@ -115,7 +115,7 @@ function updateDbEntry(_a) {
*/
return {
success: Boolean(updatedEntry === null || updatedEntry === void 0 ? void 0 : updatedEntry.affectedRows),
payload: updatedEntry,
postInsertReturn: updatedEntry,
queryObject: {
sql: (0, sql_formatter_1.format)(query),
params: updateValues,
@@ -61,7 +61,9 @@ function handleMariadbUserRecord(_a) {
query: {
query: {
id: {
value: String((existingRecord === null || existingRecord === void 0 ? void 0 : existingRecord.id) || ((_d = record === null || record === void 0 ? void 0 : record.payload) === null || _d === void 0 ? void 0 : _d.insertId) || 0),
value: String((existingRecord === null || existingRecord === void 0 ? void 0 : existingRecord.id) ||
((_d = record === null || record === void 0 ? void 0 : record.postInsertReturn) === null || _d === void 0 ? void 0 : _d.insertId) ||
0),
},
},
},