datasquirel/users/user-auth.d.ts

43 lines
2.0 KiB
TypeScript
Raw Normal View History

2024-11-08 15:44:31 +00:00
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
2024-12-08 08:58:57 +00:00
* @param {http.IncomingMessage & Object<string, any>} [params.request] - Http request object
* @param {http.IncomingMessage & Object<string, any>} [params.req] - Http request object
2024-12-13 13:08:41 +00:00
* @param {string} [params.cookieString]
2024-12-08 08:58:57 +00:00
* @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
2024-11-08 15:44:31 +00:00
* @param {("deep" | "normal")} [params.level] - Optional. "Deep" value indicates an extra layer of security
2024-12-08 08:58:57 +00:00
* @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
2024-12-14 15:23:16 +00:00
* @param {string} [params.csrfHeaderName] - Optional. CSRF Header Name
* @param {boolean} [params.csrfHeaderIsValue] - If the csrf value is the name of the request http header
2024-11-08 15:44:31 +00:00
*
* @returns { import("../package-shared/types").AuthenticatedUser }
*/
2024-12-14 15:23:16 +00:00
declare function userAuth({ request, req, encryptionKey, encryptionSalt, level, database, dsqlUserId, encryptedUserString, expiry, cookieString, csrfHeaderIsValue, csrfHeaderName, }: {
2024-12-08 08:58:57 +00:00
request?: http.IncomingMessage & {
[x: string]: any;
};
req?: http.IncomingMessage & {
[x: string]: any;
};
2024-12-13 13:08:41 +00:00
cookieString?: string;
2024-12-08 08:58:57 +00:00
encryptedUserString?: string;
encryptionKey?: string;
encryptionSalt?: string;
2024-11-08 15:44:31 +00:00
level?: ("deep" | "normal");
2024-12-08 08:58:57 +00:00
database?: string;
dsqlUserId?: string | number;
expiry?: number;
2024-12-14 15:23:16 +00:00
csrfHeaderName?: string;
csrfHeaderIsValue?: boolean;
2024-11-08 15:44:31 +00:00
}): import("../package-shared/types").AuthenticatedUser;
import http = require("http");