cca-auth-module 0.1.48 → 0.1.50
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.
- package/dist/application/dtos/AdminDTO.d.ts +8 -0
- package/dist/application/dtos/LoginDTO.d.ts +1 -1
- package/dist/application/dtos/UserDTO.d.ts +0 -1
- package/dist/application/useCase/LoginAdminUseCase.d.ts +27 -0
- package/dist/application/useCase/LoginUseCase.d.ts +1 -1
- package/dist/domain/interfaces/IAuthService.d.ts +2 -2
- package/dist/domain/interfaces/IJwtAuth.d.ts +2 -2
- package/dist/index.d.mts +30 -7
- package/dist/index.d.ts +30 -7
- package/dist/index.js +139 -45
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +132 -38
- package/dist/index.mjs.map +1 -1
- package/dist/infrastructure/services/JwtAuthService.d.ts +2 -2
- package/dist/presentation/controller/AuthController.d.ts +4 -1
- package/package.json +2 -2
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { IBaseService } from "cca-core";
|
|
2
|
+
import { AuthRepository } from "../../infrastructure/repository/AuthRepository";
|
|
3
|
+
import { JwtAuthService } from "../../infrastructure/services/JwtAuthService";
|
|
4
|
+
import { UserDTO } from "../dtos/UserDTO";
|
|
5
|
+
import { LoginDTO } from "../dtos/LoginDTO";
|
|
6
|
+
interface TokenPair {
|
|
7
|
+
accessToken: string;
|
|
8
|
+
refreshToken: string;
|
|
9
|
+
}
|
|
10
|
+
interface LoginResponse {
|
|
11
|
+
token: TokenPair;
|
|
12
|
+
user: UserDTO;
|
|
13
|
+
}
|
|
14
|
+
export declare class LoginAdminUseCase implements IBaseService {
|
|
15
|
+
private readonly repository;
|
|
16
|
+
private readonly authService;
|
|
17
|
+
constructor(repository: AuthRepository, authService: JwtAuthService);
|
|
18
|
+
initialize(): Promise<void>;
|
|
19
|
+
execute(loginDTO: LoginDTO, adminPassword: string): Promise<LoginResponse>;
|
|
20
|
+
private validateLogin;
|
|
21
|
+
private handleAuthentication;
|
|
22
|
+
private generateTokens;
|
|
23
|
+
private updateUserStatus;
|
|
24
|
+
private updateUserRefreshToken;
|
|
25
|
+
private mapUserToDTO;
|
|
26
|
+
}
|
|
27
|
+
export {};
|
|
@@ -16,7 +16,7 @@ export declare class LoginUseCase implements IBaseService {
|
|
|
16
16
|
private readonly authService;
|
|
17
17
|
constructor(repository: AuthRepository, authService: JwtAuthService);
|
|
18
18
|
initialize(): Promise<void>;
|
|
19
|
-
execute(loginDTO: LoginDTO
|
|
19
|
+
execute(loginDTO: LoginDTO): Promise<LoginResponse>;
|
|
20
20
|
private validateLogin;
|
|
21
21
|
private handleAuthentication;
|
|
22
22
|
private generateTokens;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { AuthEntity, UserEntity } from "cca-entities";
|
|
1
|
+
import { AuthEntity, UserEntity, UserRole } from "cca-entities";
|
|
2
2
|
import { IDecodedToken } from "./IDecodedToken";
|
|
3
3
|
export interface IAuthService {
|
|
4
4
|
validateUser(email: string, password: string): Promise<AuthEntity | null>;
|
|
5
|
-
generateAccessToken(user: UserEntity): string;
|
|
5
|
+
generateAccessToken(user: UserEntity, role: UserRole): string;
|
|
6
6
|
generateRefreshToken(user: UserEntity): string;
|
|
7
7
|
verifyAccessToken(token: string): Promise<IDecodedToken>;
|
|
8
8
|
verifyRefreshToken(token: string): IDecodedToken;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { AuthEntity, UserEntity } from "cca-entities";
|
|
1
|
+
import { AuthEntity, UserEntity, UserRole } from "cca-entities";
|
|
2
2
|
import { IDecodedToken } from "./IDecodedToken";
|
|
3
3
|
export interface IJwtAuth {
|
|
4
4
|
validateUser(email: string, password: string): Promise<AuthEntity | null>;
|
|
5
|
-
generateAccessToken(user: UserEntity): string;
|
|
5
|
+
generateAccessToken(user: UserEntity, role: UserRole): string;
|
|
6
6
|
generateRefreshToken(user: UserEntity): string;
|
|
7
7
|
verifyAccessToken(token: string): Promise<IDecodedToken>;
|
|
8
8
|
verifyRefreshToken(token: string): IDecodedToken;
|
package/dist/index.d.mts
CHANGED
|
@@ -58,7 +58,7 @@ interface IDecodedToken extends JwtPayload {
|
|
|
58
58
|
|
|
59
59
|
interface IAuthService {
|
|
60
60
|
validateUser(email: string, password: string): Promise<AuthEntity | null>;
|
|
61
|
-
generateAccessToken(user: UserEntity): string;
|
|
61
|
+
generateAccessToken(user: UserEntity, role: UserRole): string;
|
|
62
62
|
generateRefreshToken(user: UserEntity): string;
|
|
63
63
|
verifyAccessToken(token: string): Promise<IDecodedToken>;
|
|
64
64
|
verifyRefreshToken(token: string): IDecodedToken;
|
|
@@ -73,7 +73,7 @@ declare class JwtAuthService implements IBaseService, IAuthService {
|
|
|
73
73
|
private validateConfiguration;
|
|
74
74
|
validateUser(email: string, password: string): Promise<AuthEntity | null>;
|
|
75
75
|
private verifyJwtConfig;
|
|
76
|
-
generateAccessToken(user: UserEntity): string;
|
|
76
|
+
generateAccessToken(user: UserEntity, role: UserRole): string;
|
|
77
77
|
generateRefreshToken(user: UserEntity): string;
|
|
78
78
|
verifyToken(token: string, secret: string): Promise<IDecodedToken>;
|
|
79
79
|
verifyAccessToken(token: string): Promise<IDecodedToken>;
|
|
@@ -85,14 +85,35 @@ declare class UserDTO {
|
|
|
85
85
|
name: string;
|
|
86
86
|
email: string;
|
|
87
87
|
role: UserRole;
|
|
88
|
-
adminPassword?: string;
|
|
89
88
|
}
|
|
90
89
|
|
|
91
90
|
declare class LoginDTO {
|
|
92
91
|
email: string;
|
|
93
92
|
password: string;
|
|
94
93
|
adminPassword?: string;
|
|
95
|
-
role
|
|
94
|
+
role?: UserRole;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
interface TokenPair$1 {
|
|
98
|
+
accessToken: string;
|
|
99
|
+
refreshToken: string;
|
|
100
|
+
}
|
|
101
|
+
interface LoginResponse$1 {
|
|
102
|
+
token: TokenPair$1;
|
|
103
|
+
user: UserDTO;
|
|
104
|
+
}
|
|
105
|
+
declare class LoginUseCase implements IBaseService {
|
|
106
|
+
private readonly repository;
|
|
107
|
+
private readonly authService;
|
|
108
|
+
constructor(repository: AuthRepository, authService: JwtAuthService);
|
|
109
|
+
initialize(): Promise<void>;
|
|
110
|
+
execute(loginDTO: LoginDTO): Promise<LoginResponse$1>;
|
|
111
|
+
private validateLogin;
|
|
112
|
+
private handleAuthentication;
|
|
113
|
+
private generateTokens;
|
|
114
|
+
private updateUserStatus;
|
|
115
|
+
private updateUserRefreshToken;
|
|
116
|
+
private mapUserToDTO;
|
|
96
117
|
}
|
|
97
118
|
|
|
98
119
|
interface TokenPair {
|
|
@@ -103,12 +124,12 @@ interface LoginResponse {
|
|
|
103
124
|
token: TokenPair;
|
|
104
125
|
user: UserDTO;
|
|
105
126
|
}
|
|
106
|
-
declare class
|
|
127
|
+
declare class LoginAdminUseCase implements IBaseService {
|
|
107
128
|
private readonly repository;
|
|
108
129
|
private readonly authService;
|
|
109
130
|
constructor(repository: AuthRepository, authService: JwtAuthService);
|
|
110
131
|
initialize(): Promise<void>;
|
|
111
|
-
execute(loginDTO: LoginDTO, adminPassword
|
|
132
|
+
execute(loginDTO: LoginDTO, adminPassword: string): Promise<LoginResponse>;
|
|
112
133
|
private validateLogin;
|
|
113
134
|
private handleAuthentication;
|
|
114
135
|
private generateTokens;
|
|
@@ -209,6 +230,7 @@ declare class TwoFactorDisableUseCase implements IBaseService {
|
|
|
209
230
|
|
|
210
231
|
declare class AuthController {
|
|
211
232
|
private readonly loginUseCase;
|
|
233
|
+
private readonly adminLoginUseCase;
|
|
212
234
|
private readonly logoutUseCase;
|
|
213
235
|
private readonly registerUseCase;
|
|
214
236
|
private readonly refreshTokenUseCase;
|
|
@@ -216,8 +238,9 @@ declare class AuthController {
|
|
|
216
238
|
private twoFactorEnableUseCase;
|
|
217
239
|
private twoFactorVerifyUseCase;
|
|
218
240
|
private twoFactorDisableUseCase;
|
|
219
|
-
constructor(loginUseCase: LoginUseCase, logoutUseCase: LogoutUseCase, registerUseCase: RegisterUseCase, refreshTokenUseCase: RefreshTokenUseCase, twoFactorSetupUseCase: TwoFactorSetupUseCase, twoFactorEnableUseCase: TwoFactorEnableUseCase, twoFactorVerifyUseCase: TwoFactorVerifyUseCase, twoFactorDisableUseCase: TwoFactorDisableUseCase);
|
|
241
|
+
constructor(loginUseCase: LoginUseCase, adminLoginUseCase: LoginAdminUseCase, logoutUseCase: LogoutUseCase, registerUseCase: RegisterUseCase, refreshTokenUseCase: RefreshTokenUseCase, twoFactorSetupUseCase: TwoFactorSetupUseCase, twoFactorEnableUseCase: TwoFactorEnableUseCase, twoFactorVerifyUseCase: TwoFactorVerifyUseCase, twoFactorDisableUseCase: TwoFactorDisableUseCase);
|
|
220
242
|
login: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
243
|
+
adminLogin: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
221
244
|
logout: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
222
245
|
register: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
223
246
|
refreshToken: (req: Request, res: Response) => Promise<void>;
|
package/dist/index.d.ts
CHANGED
|
@@ -58,7 +58,7 @@ interface IDecodedToken extends JwtPayload {
|
|
|
58
58
|
|
|
59
59
|
interface IAuthService {
|
|
60
60
|
validateUser(email: string, password: string): Promise<AuthEntity | null>;
|
|
61
|
-
generateAccessToken(user: UserEntity): string;
|
|
61
|
+
generateAccessToken(user: UserEntity, role: UserRole): string;
|
|
62
62
|
generateRefreshToken(user: UserEntity): string;
|
|
63
63
|
verifyAccessToken(token: string): Promise<IDecodedToken>;
|
|
64
64
|
verifyRefreshToken(token: string): IDecodedToken;
|
|
@@ -73,7 +73,7 @@ declare class JwtAuthService implements IBaseService, IAuthService {
|
|
|
73
73
|
private validateConfiguration;
|
|
74
74
|
validateUser(email: string, password: string): Promise<AuthEntity | null>;
|
|
75
75
|
private verifyJwtConfig;
|
|
76
|
-
generateAccessToken(user: UserEntity): string;
|
|
76
|
+
generateAccessToken(user: UserEntity, role: UserRole): string;
|
|
77
77
|
generateRefreshToken(user: UserEntity): string;
|
|
78
78
|
verifyToken(token: string, secret: string): Promise<IDecodedToken>;
|
|
79
79
|
verifyAccessToken(token: string): Promise<IDecodedToken>;
|
|
@@ -85,14 +85,35 @@ declare class UserDTO {
|
|
|
85
85
|
name: string;
|
|
86
86
|
email: string;
|
|
87
87
|
role: UserRole;
|
|
88
|
-
adminPassword?: string;
|
|
89
88
|
}
|
|
90
89
|
|
|
91
90
|
declare class LoginDTO {
|
|
92
91
|
email: string;
|
|
93
92
|
password: string;
|
|
94
93
|
adminPassword?: string;
|
|
95
|
-
role
|
|
94
|
+
role?: UserRole;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
interface TokenPair$1 {
|
|
98
|
+
accessToken: string;
|
|
99
|
+
refreshToken: string;
|
|
100
|
+
}
|
|
101
|
+
interface LoginResponse$1 {
|
|
102
|
+
token: TokenPair$1;
|
|
103
|
+
user: UserDTO;
|
|
104
|
+
}
|
|
105
|
+
declare class LoginUseCase implements IBaseService {
|
|
106
|
+
private readonly repository;
|
|
107
|
+
private readonly authService;
|
|
108
|
+
constructor(repository: AuthRepository, authService: JwtAuthService);
|
|
109
|
+
initialize(): Promise<void>;
|
|
110
|
+
execute(loginDTO: LoginDTO): Promise<LoginResponse$1>;
|
|
111
|
+
private validateLogin;
|
|
112
|
+
private handleAuthentication;
|
|
113
|
+
private generateTokens;
|
|
114
|
+
private updateUserStatus;
|
|
115
|
+
private updateUserRefreshToken;
|
|
116
|
+
private mapUserToDTO;
|
|
96
117
|
}
|
|
97
118
|
|
|
98
119
|
interface TokenPair {
|
|
@@ -103,12 +124,12 @@ interface LoginResponse {
|
|
|
103
124
|
token: TokenPair;
|
|
104
125
|
user: UserDTO;
|
|
105
126
|
}
|
|
106
|
-
declare class
|
|
127
|
+
declare class LoginAdminUseCase implements IBaseService {
|
|
107
128
|
private readonly repository;
|
|
108
129
|
private readonly authService;
|
|
109
130
|
constructor(repository: AuthRepository, authService: JwtAuthService);
|
|
110
131
|
initialize(): Promise<void>;
|
|
111
|
-
execute(loginDTO: LoginDTO, adminPassword
|
|
132
|
+
execute(loginDTO: LoginDTO, adminPassword: string): Promise<LoginResponse>;
|
|
112
133
|
private validateLogin;
|
|
113
134
|
private handleAuthentication;
|
|
114
135
|
private generateTokens;
|
|
@@ -209,6 +230,7 @@ declare class TwoFactorDisableUseCase implements IBaseService {
|
|
|
209
230
|
|
|
210
231
|
declare class AuthController {
|
|
211
232
|
private readonly loginUseCase;
|
|
233
|
+
private readonly adminLoginUseCase;
|
|
212
234
|
private readonly logoutUseCase;
|
|
213
235
|
private readonly registerUseCase;
|
|
214
236
|
private readonly refreshTokenUseCase;
|
|
@@ -216,8 +238,9 @@ declare class AuthController {
|
|
|
216
238
|
private twoFactorEnableUseCase;
|
|
217
239
|
private twoFactorVerifyUseCase;
|
|
218
240
|
private twoFactorDisableUseCase;
|
|
219
|
-
constructor(loginUseCase: LoginUseCase, logoutUseCase: LogoutUseCase, registerUseCase: RegisterUseCase, refreshTokenUseCase: RefreshTokenUseCase, twoFactorSetupUseCase: TwoFactorSetupUseCase, twoFactorEnableUseCase: TwoFactorEnableUseCase, twoFactorVerifyUseCase: TwoFactorVerifyUseCase, twoFactorDisableUseCase: TwoFactorDisableUseCase);
|
|
241
|
+
constructor(loginUseCase: LoginUseCase, adminLoginUseCase: LoginAdminUseCase, logoutUseCase: LogoutUseCase, registerUseCase: RegisterUseCase, refreshTokenUseCase: RefreshTokenUseCase, twoFactorSetupUseCase: TwoFactorSetupUseCase, twoFactorEnableUseCase: TwoFactorEnableUseCase, twoFactorVerifyUseCase: TwoFactorVerifyUseCase, twoFactorDisableUseCase: TwoFactorDisableUseCase);
|
|
220
242
|
login: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
243
|
+
adminLogin: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
221
244
|
logout: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
222
245
|
register: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
223
246
|
refreshToken: (req: Request, res: Response) => Promise<void>;
|