@tc-libs/user 0.43.0 → 0.45.0
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/package.json +4 -4
- package/src/interfaces/services/user.admin.service.interface.d.ts +24 -1
- package/src/interfaces/services/user.auth.service.interface.d.ts +45 -0
- package/src/interfaces/services/user.base.service.interface.d.ts +39 -5
- package/src/interfaces/services/user.confirm.service.interface.d.ts +29 -0
- package/src/interfaces/services/user.reset-password.service.interface.d.ts +23 -0
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tc-libs/user",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.45.0",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"tslib": "^2.3.0",
|
|
6
|
-
"@tc-libs/authentication": "0.
|
|
7
|
-
"@tc-libs/service": "0.
|
|
8
|
-
"@tc-libs/database": "0.
|
|
6
|
+
"@tc-libs/authentication": "0.45.0",
|
|
7
|
+
"@tc-libs/service": "0.45.0",
|
|
8
|
+
"@tc-libs/database": "0.45.0",
|
|
9
9
|
"@nestjs/common": "^10.0.2"
|
|
10
10
|
},
|
|
11
11
|
"type": "commonjs",
|
|
@@ -1,6 +1,29 @@
|
|
|
1
1
|
import { IBaseUser } from '../user.base.interface';
|
|
2
2
|
import { IUserService } from './user.base.service.interface';
|
|
3
|
+
/**
|
|
4
|
+
* Interface representing the administrative services for user management.
|
|
5
|
+
* Extends the basic user service interface.
|
|
6
|
+
*/
|
|
3
7
|
export interface IUserAdminService extends IUserService {
|
|
8
|
+
/**
|
|
9
|
+
* Toggles the confirmation status of a user.
|
|
10
|
+
*
|
|
11
|
+
* @param user - The user whose confirmation status is to be toggled.
|
|
12
|
+
* @returns A promise that resolves to a boolean indicating the success of the operation.
|
|
13
|
+
*/
|
|
4
14
|
toggleConfirm(user: IBaseUser): Promise<boolean>;
|
|
5
|
-
|
|
15
|
+
/**
|
|
16
|
+
* Blocks a user.
|
|
17
|
+
*
|
|
18
|
+
* @param user - The user to be blocked.
|
|
19
|
+
* @returns A promise that resolves to the blocked user.
|
|
20
|
+
*/
|
|
21
|
+
blocked(user: IBaseUser): Promise<IBaseUser>;
|
|
22
|
+
/**
|
|
23
|
+
* Unblocks a user.
|
|
24
|
+
*
|
|
25
|
+
* @param user - The user to be unblocked.
|
|
26
|
+
* @returns A promise that resolves to the unblocked user.
|
|
27
|
+
*/
|
|
28
|
+
unblocked(user: IBaseUser): Promise<IBaseUser>;
|
|
6
29
|
}
|
|
@@ -1,21 +1,66 @@
|
|
|
1
1
|
import { IBaseUser } from '../user.base.interface';
|
|
2
2
|
import { IUserPayloadSerialization } from '../serializations/user.payload.serialization.interface';
|
|
3
3
|
import { IUserService } from './user.base.service.interface';
|
|
4
|
+
/**
|
|
5
|
+
* Interface representing the user authentication service.
|
|
6
|
+
* Extends the IUserService interface.
|
|
7
|
+
*/
|
|
4
8
|
export interface IUserAuthService extends IUserService {
|
|
9
|
+
/**
|
|
10
|
+
* Serializes the payload data.
|
|
11
|
+
* @param data - The data to be serialized.
|
|
12
|
+
* @returns The serialized user payload.
|
|
13
|
+
*/
|
|
5
14
|
payloadSerialization(data: any): IUserPayloadSerialization;
|
|
15
|
+
/**
|
|
16
|
+
* Signs in a user with the provided credentials.
|
|
17
|
+
* @param email - The email of the user.
|
|
18
|
+
* @param password - The password of the user.
|
|
19
|
+
* @param rememberMe - Whether to remember the user for future sessions.
|
|
20
|
+
* @param ip - The IP address of the user.
|
|
21
|
+
* @param ua - The user agent of the user.
|
|
22
|
+
* @returns A promise that resolves to an object containing token information.
|
|
23
|
+
*/
|
|
6
24
|
signin(email: string, password: string, rememberMe: boolean, ip: string, ua: string): Promise<{
|
|
7
25
|
tokenType: string;
|
|
8
26
|
expiresIn: number;
|
|
9
27
|
accessToken: string;
|
|
10
28
|
refreshToken: string;
|
|
11
29
|
}>;
|
|
30
|
+
/**
|
|
31
|
+
* Refreshes the authentication token for a user.
|
|
32
|
+
* @param user - The user object.
|
|
33
|
+
* @param refreshToken - The refresh token.
|
|
34
|
+
* @param rememberMe - Whether to remember the user for future sessions.
|
|
35
|
+
* @param loginDate - The date of the login.
|
|
36
|
+
* @returns A promise that resolves to an object containing token information.
|
|
37
|
+
*/
|
|
12
38
|
refreshToken(user: IBaseUser, refreshToken: string, rememberMe: boolean, loginDate: Date): Promise<{
|
|
13
39
|
tokenType: string;
|
|
14
40
|
expiresIn: number;
|
|
15
41
|
accessToken: string;
|
|
16
42
|
refreshToken: string;
|
|
17
43
|
}>;
|
|
44
|
+
/**
|
|
45
|
+
* Signs up a new user with the provided information.
|
|
46
|
+
* @param body - The signup information.
|
|
47
|
+
* @param forceConfirmed - Whether to force the user to be confirmed.
|
|
48
|
+
* @param forceRole - The role to be assigned to the user, if any.
|
|
49
|
+
* @returns A promise that resolves to the signup result.
|
|
50
|
+
*/
|
|
18
51
|
signup(body: any, forceConfirmed: boolean, forceRole: string | null): Promise<any>;
|
|
52
|
+
/**
|
|
53
|
+
* Increases the password attempt count for a user.
|
|
54
|
+
* @param userId - The ID of the user.
|
|
55
|
+
* @returns A promise that resolves when the operation is complete.
|
|
56
|
+
*/
|
|
19
57
|
increasePasswordAttempt(userId: string): Promise<void>;
|
|
58
|
+
/**
|
|
59
|
+
* Updates the login data after a successful signin.
|
|
60
|
+
* @param userId - The ID of the user.
|
|
61
|
+
* @param ip - The IP address of the user.
|
|
62
|
+
* @param ua - The user agent of the user.
|
|
63
|
+
* @returns A promise that resolves when the operation is complete.
|
|
64
|
+
*/
|
|
20
65
|
updateLoginDataAfterSignin(userId: string, ip: string, ua: string): Promise<void>;
|
|
21
66
|
}
|
|
@@ -1,11 +1,45 @@
|
|
|
1
1
|
import { IService } from '@tc-libs/service';
|
|
2
2
|
import { IBaseUser, IUserBirthday } from '../user.base.interface';
|
|
3
|
+
/**
|
|
4
|
+
* Interface representing the user service.
|
|
5
|
+
* Extends the generic IService interface with IBaseUser as the type parameter.
|
|
6
|
+
*/
|
|
3
7
|
export interface IUserService extends IService<IBaseUser> {
|
|
8
|
+
/**
|
|
9
|
+
* Finds a user by their email address.
|
|
10
|
+
*
|
|
11
|
+
* @param email - The email address of the user to find.
|
|
12
|
+
* @returns A promise that resolves to the found user.
|
|
13
|
+
*/
|
|
4
14
|
findByEmail(email: string): Promise<IBaseUser>;
|
|
15
|
+
/**
|
|
16
|
+
* Computes the birthday details of a user.
|
|
17
|
+
*
|
|
18
|
+
* @param day - The day of the month.
|
|
19
|
+
* @param month - The month of the year.
|
|
20
|
+
* @param year - The year.
|
|
21
|
+
* @returns An object representing the user's birthday.
|
|
22
|
+
*/
|
|
5
23
|
computeBDay(day: number, month: number, year: number): IUserBirthday;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
24
|
+
/**
|
|
25
|
+
* Marks a user as inactive.
|
|
26
|
+
*
|
|
27
|
+
* @param user - The user to mark as inactive.
|
|
28
|
+
* @returns A promise that resolves to the updated user.
|
|
29
|
+
*/
|
|
30
|
+
inactive(user: IBaseUser): Promise<IBaseUser>;
|
|
31
|
+
/**
|
|
32
|
+
* Marks a user as active.
|
|
33
|
+
*
|
|
34
|
+
* @param user - The user to mark as active.
|
|
35
|
+
* @returns A promise that resolves to the updated user.
|
|
36
|
+
*/
|
|
37
|
+
active(user: IBaseUser): Promise<IBaseUser>;
|
|
38
|
+
/**
|
|
39
|
+
* Joins a user with their role.
|
|
40
|
+
*
|
|
41
|
+
* @param user - The user to join with a role.
|
|
42
|
+
* @returns A promise that resolves to the updated user.
|
|
43
|
+
*/
|
|
44
|
+
joinWithRole(user: IBaseUser): Promise<IBaseUser>;
|
|
11
45
|
}
|
|
@@ -1,9 +1,38 @@
|
|
|
1
1
|
import { IUserConfirmResendSerialization, IUserConfirmSerialization } from '../serializations/user.confirm.serialization.interface';
|
|
2
2
|
import { IBaseUser } from '../user.base.interface';
|
|
3
3
|
import { IUserService } from './user.base.service.interface';
|
|
4
|
+
/**
|
|
5
|
+
* Interface representing the user confirmation service.
|
|
6
|
+
* Extends the base user service interface.
|
|
7
|
+
*/
|
|
4
8
|
export interface IUserConfirmService extends IUserService {
|
|
9
|
+
/**
|
|
10
|
+
* Resets the confirmation code for a given email.
|
|
11
|
+
*
|
|
12
|
+
* @param email - The email address for which to reset the confirmation code.
|
|
13
|
+
* @returns A promise that resolves to the new confirmation code as a string.
|
|
14
|
+
*/
|
|
5
15
|
resetConfirmCode(email: string): Promise<string>;
|
|
16
|
+
/**
|
|
17
|
+
* Resends the confirmation details to the user.
|
|
18
|
+
*
|
|
19
|
+
* @param user - The user object containing the necessary information.
|
|
20
|
+
* @returns A promise that resolves to the serialization of the resend confirmation response.
|
|
21
|
+
*/
|
|
6
22
|
resendConfirm(user: IBaseUser): Promise<IUserConfirmResendSerialization>;
|
|
23
|
+
/**
|
|
24
|
+
* Retrieves a user by their email and confirmation code.
|
|
25
|
+
*
|
|
26
|
+
* @param email - The email address of the user.
|
|
27
|
+
* @param uuid - The confirmation code associated with the user.
|
|
28
|
+
* @returns A promise that resolves to the base user object.
|
|
29
|
+
*/
|
|
7
30
|
getUserByEmailAndConfirmCode(email: string, uuid: string): Promise<IBaseUser>;
|
|
31
|
+
/**
|
|
32
|
+
* Confirms the user.
|
|
33
|
+
*
|
|
34
|
+
* @param user - The user object to be confirmed.
|
|
35
|
+
* @returns A promise that resolves to the serialization of the confirmation response.
|
|
36
|
+
*/
|
|
8
37
|
confirm(user: IBaseUser): Promise<IUserConfirmSerialization>;
|
|
9
38
|
}
|
|
@@ -2,8 +2,31 @@ import { IUserResetPasswordDto } from '../dtos/user.reset-password.dto.interface
|
|
|
2
2
|
import { IUserResetPasswordConfirmSerialization, IUserResetPasswordSerialization } from '../serializations/user.reset-password.serialization.interface';
|
|
3
3
|
import { IBaseUser } from '../user.base.interface';
|
|
4
4
|
import { IUserService } from './user.base.service.interface';
|
|
5
|
+
/**
|
|
6
|
+
* Interface representing the user reset password service.
|
|
7
|
+
* Extends the base user service interface.
|
|
8
|
+
*/
|
|
5
9
|
export interface IUserResetPasswordService extends IUserService {
|
|
10
|
+
/**
|
|
11
|
+
* Retrieves a user by their email and reset confirmation code.
|
|
12
|
+
*
|
|
13
|
+
* @param email - The email of the user.
|
|
14
|
+
* @param uuid - The reset confirmation code.
|
|
15
|
+
* @returns A promise that resolves to the base user object.
|
|
16
|
+
*/
|
|
6
17
|
getUserByEmailAndResetConfirmCode(email: string, uuid: string): Promise<IBaseUser>;
|
|
18
|
+
/**
|
|
19
|
+
* Resets the user's password.
|
|
20
|
+
*
|
|
21
|
+
* @param resetPasswordDto - The data transfer object containing the reset password information.
|
|
22
|
+
* @returns A promise that resolves to the reset password serialization object.
|
|
23
|
+
*/
|
|
7
24
|
resetPassword(resetPasswordDto: IUserResetPasswordDto): Promise<IUserResetPasswordSerialization>;
|
|
25
|
+
/**
|
|
26
|
+
* Confirms the user's password reset.
|
|
27
|
+
*
|
|
28
|
+
* @param user - The base user object.
|
|
29
|
+
* @returns A promise that resolves to the reset password confirmation serialization object.
|
|
30
|
+
*/
|
|
8
31
|
confirmResetPassword(user: IBaseUser): Promise<IUserResetPasswordConfirmSerialization>;
|
|
9
32
|
}
|