datasquirel/users/user-auth.d.ts
Benjamin Toby 0880526f44 Updates
2024-12-14 16:23:16 +01:00

43 lines
2.0 KiB
TypeScript

export = userAuth;
/**
* Authenticate User from request
* ==============================================================================
* @description This Function takes in a request object and returns a user object
* with the user's data
*
* @param {Object} params - Arg
* @param {http.IncomingMessage & Object<string, any>} [params.request] - Http request object
* @param {http.IncomingMessage & Object<string, any>} [params.req] - Http request object
* @param {string} [params.cookieString]
* @param {string} [params.encryptedUserString] - Encrypted user string to use instead of getting from cookie header
* @param {string} [params.encryptionKey] - Encryption Key: alt env: DSQL_ENCRYPTION_PASSWORD
* @param {string} [params.encryptionSalt] - Encryption Salt: alt env: DSQL_ENCRYPTION_SALT
* @param {("deep" | "normal")} [params.level] - Optional. "Deep" value indicates an extra layer of security
* @param {string} [params.database] - Database Name (slug)
* @param {string | number} [params.dsqlUserId] - alt env: DSQL_API_USER_ID
* @param {number} [params.expiry] - Expiry time in milliseconds
* @param {string} [params.csrfHeaderName] - Optional. CSRF Header Name
* @param {boolean} [params.csrfHeaderIsValue] - If the csrf value is the name of the request http header
*
* @returns { import("../package-shared/types").AuthenticatedUser }
*/
declare function userAuth({ request, req, encryptionKey, encryptionSalt, level, database, dsqlUserId, encryptedUserString, expiry, cookieString, csrfHeaderIsValue, csrfHeaderName, }: {
request?: http.IncomingMessage & {
[x: string]: any;
};
req?: http.IncomingMessage & {
[x: string]: any;
};
cookieString?: string;
encryptedUserString?: string;
encryptionKey?: string;
encryptionSalt?: string;
level?: ("deep" | "normal");
database?: string;
dsqlUserId?: string | number;
expiry?: number;
csrfHeaderName?: string;
csrfHeaderIsValue?: boolean;
}): import("../package-shared/types").AuthenticatedUser;
import http = require("http");