small difference
This commit is contained in:
@@ -8,6 +8,8 @@ Guardian is a powerful JavaScript library designed to fortify your application's
|
||||
|
||||
This library is easy to integrate into your project and offers a comprehensive set of features, making it a reliable choice for enhancing the security of your application.
|
||||
|
||||
you can run it with TypeScript or JavaScript.
|
||||
|
||||
## Installation
|
||||
|
||||
To install Guardian, simply run the following command using npm:
|
||||
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
import PassCheck from "./passwordcheck";
|
||||
import JwtAuth from "jsonwebtoken";
|
||||
import PassPolicy from "./passpolicy";
|
||||
import RateLimit from "./ratelimit";
|
||||
import PasswordGenerator from "./passgen";
|
||||
export { PassCheck, JwtAuth, PassPolicy, RateLimit, PasswordGenerator };
|
||||
Vendored
+37
@@ -0,0 +1,37 @@
|
||||
import * as jwt from 'jsonwebtoken';
|
||||
export default class JwtAuth {
|
||||
private JWTSecretKey;
|
||||
private blacklist;
|
||||
constructor(JWTSecretKey: string);
|
||||
generateJWT(payload: {
|
||||
[key: string]: any;
|
||||
}, settings?: jwt.SignOptions, secretKey?: string): string;
|
||||
verifyJWT(token: string, secretKey?: string): jwt.JwtPayload | undefined;
|
||||
decodeJWT(token: string): string | jwt.JwtPayload | null;
|
||||
getJWTExpirationDate(token: string): any;
|
||||
isJWTExpired(token: string): boolean | {
|
||||
valid: boolean;
|
||||
message: string;
|
||||
};
|
||||
refreshJWT(token: string, settings?: jwt.SignOptions, secretKey?: string): string | {
|
||||
valid: boolean;
|
||||
message: string;
|
||||
};
|
||||
BlackListJWT(token: string): {
|
||||
valid: boolean;
|
||||
message: string;
|
||||
};
|
||||
ClearBlackList(): {
|
||||
valid: boolean;
|
||||
message: string;
|
||||
};
|
||||
GetBlackList(): string[];
|
||||
RemoveFromBlackList(token: string): {
|
||||
valid: boolean;
|
||||
message: string;
|
||||
};
|
||||
IsBlackListed(token: string): {
|
||||
valid: boolean;
|
||||
message: string;
|
||||
};
|
||||
}
|
||||
Vendored
+13
@@ -0,0 +1,13 @@
|
||||
export default class PasswordGenerator {
|
||||
private options;
|
||||
constructor(options: {
|
||||
minLength: number;
|
||||
maxLength: number;
|
||||
minLower: number;
|
||||
minUpper: number;
|
||||
minNum: number;
|
||||
minSpecial: number;
|
||||
specialChars: string;
|
||||
});
|
||||
Generate(length?: number): string;
|
||||
}
|
||||
Vendored
+26
@@ -0,0 +1,26 @@
|
||||
export default class PassPolicy {
|
||||
private options;
|
||||
constructor(options: {
|
||||
minLength: number;
|
||||
maxLength: number;
|
||||
minLower: number;
|
||||
minUpper: number;
|
||||
minNum: number;
|
||||
minSpecial: number;
|
||||
specialChars: string;
|
||||
});
|
||||
validate(password: string): {
|
||||
valid: boolean;
|
||||
message: string;
|
||||
} | {
|
||||
valid: boolean;
|
||||
message?: undefined;
|
||||
};
|
||||
CheckDifference(newPassword: string, oldPassword: string, neededDifference?: number): {
|
||||
valid: boolean;
|
||||
message: string;
|
||||
} | {
|
||||
valid: boolean;
|
||||
message?: undefined;
|
||||
};
|
||||
}
|
||||
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
export default class PassCheck {
|
||||
private BcryptSaltRounds;
|
||||
private PassPolicy;
|
||||
constructor(BcryptSaltRounds: number, PassPolicyOptions: {
|
||||
minLength: number;
|
||||
maxLength: number;
|
||||
minLower: number;
|
||||
minUpper: number;
|
||||
minNum: number;
|
||||
minSpecial: number;
|
||||
specialChars: string;
|
||||
});
|
||||
verifyPassword(password: string, hash: string): Promise<boolean>;
|
||||
hashPassword(password: string): Promise<string>;
|
||||
}
|
||||
Vendored
+46
@@ -0,0 +1,46 @@
|
||||
type Event = {
|
||||
name: string;
|
||||
cooldown: number;
|
||||
maxAttempts: number;
|
||||
lastAttempt?: number;
|
||||
attempts?: number[];
|
||||
};
|
||||
type user = {
|
||||
token: string;
|
||||
events: {
|
||||
[name: string]: Event;
|
||||
};
|
||||
};
|
||||
export default class RateLimit {
|
||||
users: {
|
||||
[token: string]: user;
|
||||
};
|
||||
events: {
|
||||
[name: string]: Event;
|
||||
};
|
||||
constructor(users?: {
|
||||
[token: string]: user;
|
||||
}, events?: {
|
||||
[name: string]: Event;
|
||||
});
|
||||
addEvent(event: Event): boolean;
|
||||
removeEvent(name: string): boolean;
|
||||
addUser(token: string): boolean;
|
||||
removeUser(token: string): boolean;
|
||||
attempt(token: string, name: string): boolean;
|
||||
getEvents(): {
|
||||
[name: string]: Event;
|
||||
};
|
||||
getUsers(): {
|
||||
[token: string]: user;
|
||||
};
|
||||
getEvent(name: string): Event;
|
||||
getUser(token: string): user;
|
||||
remainingAttempts(token: string, name: string): number;
|
||||
resetAttempts(token: string, name: string): boolean;
|
||||
resetAllAttempts(token: string): boolean;
|
||||
resetAllUsers(): boolean;
|
||||
resetEvent(name: string): boolean;
|
||||
resetUser(token: string): boolean;
|
||||
}
|
||||
export {};
|
||||
+5
-3
@@ -1,8 +1,10 @@
|
||||
{
|
||||
"name": "@kajvans/auth-guardian",
|
||||
"version": "2.0.0",
|
||||
"name": "auth-guardian",
|
||||
"version": "2.0.1",
|
||||
"description": "auth-guardian a library for enhancing application security",
|
||||
"main": "index.js",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
"typings": "./dist/index.d.ts",
|
||||
"scripts": {
|
||||
"test": "jest",
|
||||
"build": "tsc"
|
||||
|
||||
+1
-1
@@ -49,7 +49,7 @@
|
||||
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
|
||||
|
||||
/* Emit */
|
||||
// "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
|
||||
"declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
|
||||
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
|
||||
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
|
||||
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
|
||||
|
||||
Reference in New Issue
Block a user