fiberx-backend-toolkit 0.0.47 → 0.0.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { Model } from "sequelize";
|
|
2
2
|
import { Request, Response, NextFunction, RequestHandler } from "express";
|
|
3
3
|
import { AuthenticatorOptions, DefaultRequestInfo, DefaultAccessTokenPayload, DefaultRefreshTokenPayload } from "../types/middle_ware_type";
|
|
4
|
-
declare class AuthenicationMiddleWare {
|
|
4
|
+
declare class AuthenicationMiddleWare<TRequestInfo extends DefaultRequestInfo = DefaultRequestInfo, TAccessPayload extends DefaultAccessTokenPayload = DefaultAccessTokenPayload, TRefreshPayload extends DefaultRefreshTokenPayload = DefaultRefreshTokenPayload, TSessionModel extends Model = Model, TLoginChallengeModel extends Model = Model, TActorModel extends Model = Model> {
|
|
5
5
|
private name;
|
|
6
6
|
private logger;
|
|
7
7
|
private readonly options;
|
|
8
|
-
constructor(options: AuthenticatorOptions);
|
|
8
|
+
constructor(options: AuthenticatorOptions<TRequestInfo, TAccessPayload, TRefreshPayload, TSessionModel, TLoginChallengeModel, TActorModel>);
|
|
9
9
|
/** Extract tokens + device info from request */
|
|
10
|
-
protected extractRequestInfo(req: Request): Promise<
|
|
11
|
-
protected validateAccessToken(access_token: string, request_info?:
|
|
12
|
-
protected validateRefreshToken(refresh_token: string, request_info?:
|
|
13
|
-
protected LoadActor(actor_type: string, actor_id: number | string, request_info?:
|
|
14
|
-
protected loadMemberSession(member_id: number | string, session_id: number | string, request_info?:
|
|
15
|
-
protected loadMemberLoginChallenge(member_id: number | string, challenge_id: number | string, request_info?:
|
|
10
|
+
protected extractRequestInfo(req: Request): Promise<TRequestInfo | null>;
|
|
11
|
+
protected validateAccessToken(access_token: string, request_info?: TRequestInfo): Promise<DefaultAccessTokenPayload | null>;
|
|
12
|
+
protected validateRefreshToken(refresh_token: string, request_info?: TRequestInfo): Promise<DefaultRefreshTokenPayload | null>;
|
|
13
|
+
protected LoadActor(actor_type: string, actor_id: number | string, request_info?: TRequestInfo): Promise<Model | null>;
|
|
14
|
+
protected loadMemberSession(member_id: number | string, session_id: number | string, request_info?: TRequestInfo, is_2fa_validated?: boolean): Promise<Model | null>;
|
|
15
|
+
protected loadMemberLoginChallenge(member_id: number | string, challenge_id: number | string, request_info?: TRequestInfo, is_2fa_validated?: boolean): Promise<Model | null>;
|
|
16
16
|
protected getActorPermissions(actor_id: number | string, role_ids: (number | string)[]): Promise<string[]>;
|
|
17
|
-
protected validateHasPermission(request_info:
|
|
17
|
+
protected validateHasPermission(request_info: TRequestInfo): Promise<boolean>;
|
|
18
18
|
setPermissionName(permission_name: string): RequestHandler;
|
|
19
19
|
requireNoAuth(req: Request, res: Response, next: NextFunction): Promise<void | Response>;
|
|
20
20
|
requirePartialAuth(req: Request, res: Response, next: NextFunction): Promise<void | Response>;
|
|
@@ -49,5 +49,6 @@ declare class InputValidatorUtil {
|
|
|
49
49
|
/** ✅ Validate ReCaptcha */
|
|
50
50
|
static isValidReCaptcha(recpatcha_token: string): Promise<any>;
|
|
51
51
|
static dirExists(directory: string, create_directory?: boolean, return_dir_path?: boolean): boolean | string;
|
|
52
|
+
static isSafeHashCompare(a: string, b: string): boolean;
|
|
52
53
|
}
|
|
53
54
|
export default InputValidatorUtil;
|
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const fs_1 = __importDefault(require("fs"));
|
|
7
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
7
8
|
const dayjs_1 = __importDefault(require("dayjs"));
|
|
8
9
|
const isSameOrAfter_1 = __importDefault(require("dayjs/plugin/isSameOrAfter"));
|
|
9
10
|
const bcrypt_1 = __importDefault(require("bcrypt"));
|
|
@@ -117,5 +118,13 @@ class InputValidatorUtil {
|
|
|
117
118
|
}
|
|
118
119
|
return return_dir_path ? directory : true;
|
|
119
120
|
}
|
|
121
|
+
static isSafeHashCompare(a, b) {
|
|
122
|
+
const buf1 = Buffer.from(a);
|
|
123
|
+
const buf2 = Buffer.from(b);
|
|
124
|
+
if (buf1.length !== buf2.length) {
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
return crypto_1.default.timingSafeEqual(buf1, buf2);
|
|
128
|
+
}
|
|
120
129
|
}
|
|
121
130
|
exports.default = InputValidatorUtil;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fiberx-backend-toolkit",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.49",
|
|
4
4
|
"description": "A TypeScript backend toolkit providing shared domain logic, infrastructure helpers, and utilities for FiberX server-side applications and services.",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "./dist/index.js",
|