cca-auth-module 0.1.54 → 0.1.55

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,27 +1,10 @@
1
1
  import { IBaseService } from "cca-core";
2
2
  import { AuthRepository } from "../../infrastructure/repository/AuthRepository";
3
- import { JwtAuthService } from "../../infrastructure/services/JwtAuthService";
4
- import { UserDTO } from "../dtos/UserDTO";
5
3
  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
4
  export declare class LoginAdminUseCase implements IBaseService {
15
5
  private readonly repository;
16
- private readonly authService;
17
- constructor(repository: AuthRepository, authService: JwtAuthService);
6
+ constructor(repository: AuthRepository);
18
7
  initialize(): Promise<void>;
19
- execute(loginDTO: LoginDTO, adminPassword: string): Promise<LoginResponse>;
8
+ execute(loginDTO: LoginDTO, adminPassword: string): Promise<string>;
20
9
  private validateLogin;
21
- private handleAuthentication;
22
- private generateTokens;
23
- private updateUserStatus;
24
- private updateUserRefreshToken;
25
- private mapUserToDTO;
26
10
  }
27
- export {};
@@ -1,27 +1,10 @@
1
1
  import { IBaseService } from "cca-core";
2
2
  import { AuthRepository } from "../../infrastructure/repository/AuthRepository";
3
- import { JwtAuthService } from "../../infrastructure/services/JwtAuthService";
4
- import { UserDTO } from "../dtos/UserDTO";
5
3
  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
4
  export declare class LoginUseCase implements IBaseService {
15
5
  private readonly repository;
16
- private readonly authService;
17
- constructor(repository: AuthRepository, authService: JwtAuthService);
6
+ constructor(repository: AuthRepository);
18
7
  initialize(): Promise<void>;
19
- execute(loginDTO: LoginDTO): Promise<LoginResponse>;
8
+ execute(loginDTO: LoginDTO): Promise<string>;
20
9
  private validateLogin;
21
- private handleAuthentication;
22
- private generateTokens;
23
- private updateUserStatus;
24
- private updateUserRefreshToken;
25
- private mapUserToDTO;
26
10
  }
27
- export {};
@@ -1,15 +1,11 @@
1
1
  import { IBaseService } from "cca-core";
2
- import { IDecodedToken } from "../../domain/interfaces/IDecodedToken";
3
2
  import { JwtAuthService } from "../../infrastructure/services/JwtAuthService";
4
3
  import { AuthRepository } from "../../infrastructure/repository/AuthRepository";
4
+ import { TokenPair } from "../../domain/interfaces/TokenPair";
5
5
  export declare class RefreshTokenUseCase implements IBaseService {
6
6
  private readonly repository;
7
7
  private readonly service;
8
8
  constructor(repository: AuthRepository, service: JwtAuthService);
9
9
  initialize(): Promise<void>;
10
- execute(refreshToken: string): Promise<{
11
- accessToken: string;
12
- refreshToken: string;
13
- } | null>;
14
- verityToken(token: string): Promise<IDecodedToken>;
10
+ execute(refreshToken: string): Promise<TokenPair | null>;
15
11
  }
@@ -3,15 +3,23 @@ import { TwoFactorService } from '../../infrastructure/services/TwoFactorService
3
3
  import { AuthRepository } from '../../infrastructure/repository/AuthRepository';
4
4
  import { JwtAuthService } from '../../infrastructure/services/JwtAuthService';
5
5
  import { ITwoFactorVerify } from '../../domain/interfaces/ITwoFactorVerify';
6
+ import { AdminDTO } from '../dtos/AdminDTO';
7
+ import { UserDTO } from '../dtos/UserDTO';
6
8
  export declare class TwoFactorVerifyUseCase implements IBaseService {
7
- private twoFactorService;
8
- private authRepository;
9
- private jwtService;
9
+ private readonly twoFactorService;
10
+ private readonly authRepository;
11
+ private readonly jwtService;
10
12
  private isInitialized;
11
13
  constructor(twoFactorService: TwoFactorService, authRepository: AuthRepository, jwtService: JwtAuthService);
12
14
  initialize(): Promise<void>;
13
15
  execute(dto: ITwoFactorVerify): Promise<{
14
16
  token: string;
15
17
  refreshToken: string;
16
- }>;
18
+ data?: AdminDTO | UserDTO;
19
+ } | null>;
20
+ private mapAdminToDTO;
21
+ private mapUserToDTO;
22
+ private updateUserStatus;
23
+ private updateUserRefreshToken;
24
+ private generateTokens;
17
25
  }
@@ -0,0 +1,4 @@
1
+ export interface TokenPair {
2
+ accessToken: string;
3
+ refreshToken: string;
4
+ }
package/dist/index.d.mts CHANGED
@@ -43,6 +43,36 @@ declare class RegisterUseCase implements IBaseService {
43
43
  private createAuthEntity;
44
44
  }
45
45
 
46
+ declare class LoginDTO {
47
+ email: string;
48
+ password: string;
49
+ adminPassword?: string;
50
+ role?: UserRole;
51
+ }
52
+
53
+ declare class LoginUseCase implements IBaseService {
54
+ private readonly repository;
55
+ constructor(repository: AuthRepository);
56
+ initialize(): Promise<void>;
57
+ execute(loginDTO: LoginDTO): Promise<string>;
58
+ private validateLogin;
59
+ }
60
+
61
+ declare class LoginAdminUseCase implements IBaseService {
62
+ private readonly repository;
63
+ constructor(repository: AuthRepository);
64
+ initialize(): Promise<void>;
65
+ execute(loginDTO: LoginDTO, adminPassword: string): Promise<string>;
66
+ private validateLogin;
67
+ }
68
+
69
+ declare class LogoutUseCase implements IBaseService {
70
+ private readonly repository;
71
+ constructor(repository: AuthRepository);
72
+ initialize(): Promise<void>;
73
+ execute(authId: string): Promise<void>;
74
+ }
75
+
46
76
  interface IJwtConfig {
47
77
  accessTokenSecret: string;
48
78
  refreshTokenSecret: string;
@@ -80,81 +110,17 @@ declare class JwtAuthService implements IBaseService, IAuthService {
80
110
  verifyRefreshToken(token: string): Promise<IDecodedToken>;
81
111
  }
82
112
 
83
- declare class UserDTO {
84
- id: string;
85
- name: string;
86
- email: string;
87
- role: UserRole;
88
- }
89
-
90
- declare class LoginDTO {
91
- email: string;
92
- password: string;
93
- adminPassword?: string;
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;
117
- }
118
-
119
113
  interface TokenPair {
120
114
  accessToken: string;
121
115
  refreshToken: string;
122
116
  }
123
- interface LoginResponse {
124
- token: TokenPair;
125
- user: UserDTO;
126
- }
127
- declare class LoginAdminUseCase implements IBaseService {
128
- private readonly repository;
129
- private readonly authService;
130
- constructor(repository: AuthRepository, authService: JwtAuthService);
131
- initialize(): Promise<void>;
132
- execute(loginDTO: LoginDTO, adminPassword: string): Promise<LoginResponse>;
133
- private validateLogin;
134
- private handleAuthentication;
135
- private generateTokens;
136
- private updateUserStatus;
137
- private updateUserRefreshToken;
138
- private mapUserToDTO;
139
- }
140
-
141
- declare class LogoutUseCase implements IBaseService {
142
- private readonly repository;
143
- constructor(repository: AuthRepository);
144
- initialize(): Promise<void>;
145
- execute(authId: string): Promise<void>;
146
- }
147
117
 
148
118
  declare class RefreshTokenUseCase implements IBaseService {
149
119
  private readonly repository;
150
120
  private readonly service;
151
121
  constructor(repository: AuthRepository, service: JwtAuthService);
152
122
  initialize(): Promise<void>;
153
- execute(refreshToken: string): Promise<{
154
- accessToken: string;
155
- refreshToken: string;
156
- } | null>;
157
- verityToken(token: string): Promise<IDecodedToken>;
123
+ execute(refreshToken: string): Promise<TokenPair | null>;
158
124
  }
159
125
 
160
126
  declare class TwoFactorService implements IBaseService {
@@ -207,17 +173,38 @@ interface ITwoFactorVerify {
207
173
  token: string;
208
174
  }
209
175
 
176
+ declare class AdminDTO {
177
+ id: string;
178
+ name: string;
179
+ email: string;
180
+ role: UserRole;
181
+ adminPassword: string;
182
+ }
183
+
184
+ declare class UserDTO {
185
+ id: string;
186
+ name: string;
187
+ email: string;
188
+ role: UserRole;
189
+ }
190
+
210
191
  declare class TwoFactorVerifyUseCase implements IBaseService {
211
- private twoFactorService;
212
- private authRepository;
213
- private jwtService;
192
+ private readonly twoFactorService;
193
+ private readonly authRepository;
194
+ private readonly jwtService;
214
195
  private isInitialized;
215
196
  constructor(twoFactorService: TwoFactorService, authRepository: AuthRepository, jwtService: JwtAuthService);
216
197
  initialize(): Promise<void>;
217
198
  execute(dto: ITwoFactorVerify): Promise<{
218
199
  token: string;
219
200
  refreshToken: string;
220
- }>;
201
+ data?: AdminDTO | UserDTO;
202
+ } | null>;
203
+ private mapAdminToDTO;
204
+ private mapUserToDTO;
205
+ private updateUserStatus;
206
+ private updateUserRefreshToken;
207
+ private generateTokens;
221
208
  }
222
209
 
223
210
  declare class TwoFactorDisableUseCase implements IBaseService {
@@ -245,7 +232,6 @@ declare class AuthController {
245
232
  logout: (req: Request, res: Response, next: NextFunction) => Promise<void>;
246
233
  register: (req: Request, res: Response, next: NextFunction) => Promise<void>;
247
234
  refreshToken: (req: Request, res: Response) => Promise<void>;
248
- verifyToken: (token: string) => Promise<IDecodedToken>;
249
235
  setup2FA: (req: Request, res: Response, next: NextFunction) => Promise<void>;
250
236
  enable2FA: (req: Request, res: Response, next: NextFunction) => Promise<void>;
251
237
  verify2FA: (req: Request, res: Response, next: NextFunction) => Promise<void>;
package/dist/index.d.ts CHANGED
@@ -43,6 +43,36 @@ declare class RegisterUseCase implements IBaseService {
43
43
  private createAuthEntity;
44
44
  }
45
45
 
46
+ declare class LoginDTO {
47
+ email: string;
48
+ password: string;
49
+ adminPassword?: string;
50
+ role?: UserRole;
51
+ }
52
+
53
+ declare class LoginUseCase implements IBaseService {
54
+ private readonly repository;
55
+ constructor(repository: AuthRepository);
56
+ initialize(): Promise<void>;
57
+ execute(loginDTO: LoginDTO): Promise<string>;
58
+ private validateLogin;
59
+ }
60
+
61
+ declare class LoginAdminUseCase implements IBaseService {
62
+ private readonly repository;
63
+ constructor(repository: AuthRepository);
64
+ initialize(): Promise<void>;
65
+ execute(loginDTO: LoginDTO, adminPassword: string): Promise<string>;
66
+ private validateLogin;
67
+ }
68
+
69
+ declare class LogoutUseCase implements IBaseService {
70
+ private readonly repository;
71
+ constructor(repository: AuthRepository);
72
+ initialize(): Promise<void>;
73
+ execute(authId: string): Promise<void>;
74
+ }
75
+
46
76
  interface IJwtConfig {
47
77
  accessTokenSecret: string;
48
78
  refreshTokenSecret: string;
@@ -80,81 +110,17 @@ declare class JwtAuthService implements IBaseService, IAuthService {
80
110
  verifyRefreshToken(token: string): Promise<IDecodedToken>;
81
111
  }
82
112
 
83
- declare class UserDTO {
84
- id: string;
85
- name: string;
86
- email: string;
87
- role: UserRole;
88
- }
89
-
90
- declare class LoginDTO {
91
- email: string;
92
- password: string;
93
- adminPassword?: string;
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;
117
- }
118
-
119
113
  interface TokenPair {
120
114
  accessToken: string;
121
115
  refreshToken: string;
122
116
  }
123
- interface LoginResponse {
124
- token: TokenPair;
125
- user: UserDTO;
126
- }
127
- declare class LoginAdminUseCase implements IBaseService {
128
- private readonly repository;
129
- private readonly authService;
130
- constructor(repository: AuthRepository, authService: JwtAuthService);
131
- initialize(): Promise<void>;
132
- execute(loginDTO: LoginDTO, adminPassword: string): Promise<LoginResponse>;
133
- private validateLogin;
134
- private handleAuthentication;
135
- private generateTokens;
136
- private updateUserStatus;
137
- private updateUserRefreshToken;
138
- private mapUserToDTO;
139
- }
140
-
141
- declare class LogoutUseCase implements IBaseService {
142
- private readonly repository;
143
- constructor(repository: AuthRepository);
144
- initialize(): Promise<void>;
145
- execute(authId: string): Promise<void>;
146
- }
147
117
 
148
118
  declare class RefreshTokenUseCase implements IBaseService {
149
119
  private readonly repository;
150
120
  private readonly service;
151
121
  constructor(repository: AuthRepository, service: JwtAuthService);
152
122
  initialize(): Promise<void>;
153
- execute(refreshToken: string): Promise<{
154
- accessToken: string;
155
- refreshToken: string;
156
- } | null>;
157
- verityToken(token: string): Promise<IDecodedToken>;
123
+ execute(refreshToken: string): Promise<TokenPair | null>;
158
124
  }
159
125
 
160
126
  declare class TwoFactorService implements IBaseService {
@@ -207,17 +173,38 @@ interface ITwoFactorVerify {
207
173
  token: string;
208
174
  }
209
175
 
176
+ declare class AdminDTO {
177
+ id: string;
178
+ name: string;
179
+ email: string;
180
+ role: UserRole;
181
+ adminPassword: string;
182
+ }
183
+
184
+ declare class UserDTO {
185
+ id: string;
186
+ name: string;
187
+ email: string;
188
+ role: UserRole;
189
+ }
190
+
210
191
  declare class TwoFactorVerifyUseCase implements IBaseService {
211
- private twoFactorService;
212
- private authRepository;
213
- private jwtService;
192
+ private readonly twoFactorService;
193
+ private readonly authRepository;
194
+ private readonly jwtService;
214
195
  private isInitialized;
215
196
  constructor(twoFactorService: TwoFactorService, authRepository: AuthRepository, jwtService: JwtAuthService);
216
197
  initialize(): Promise<void>;
217
198
  execute(dto: ITwoFactorVerify): Promise<{
218
199
  token: string;
219
200
  refreshToken: string;
220
- }>;
201
+ data?: AdminDTO | UserDTO;
202
+ } | null>;
203
+ private mapAdminToDTO;
204
+ private mapUserToDTO;
205
+ private updateUserStatus;
206
+ private updateUserRefreshToken;
207
+ private generateTokens;
221
208
  }
222
209
 
223
210
  declare class TwoFactorDisableUseCase implements IBaseService {
@@ -245,7 +232,6 @@ declare class AuthController {
245
232
  logout: (req: Request, res: Response, next: NextFunction) => Promise<void>;
246
233
  register: (req: Request, res: Response, next: NextFunction) => Promise<void>;
247
234
  refreshToken: (req: Request, res: Response) => Promise<void>;
248
- verifyToken: (token: string) => Promise<IDecodedToken>;
249
235
  setup2FA: (req: Request, res: Response, next: NextFunction) => Promise<void>;
250
236
  enable2FA: (req: Request, res: Response, next: NextFunction) => Promise<void>;
251
237
  verify2FA: (req: Request, res: Response, next: NextFunction) => Promise<void>;