@djust-b2b/djust-front-sdk 1.15.1 → 1.16.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/lib/services/auth/index.d.ts +133 -117
- package/lib/services/auth/index.js +133 -117
- package/lib/services/cart/index.d.ts +185 -249
- package/lib/services/cart/index.js +198 -252
- package/lib/services/custom-field/index.d.ts +56 -96
- package/lib/services/custom-field/index.js +56 -96
- package/package.json +1 -1
|
@@ -15,146 +15,162 @@
|
|
|
15
15
|
import { LoginResponse, RefreshTokenResponse } from "./definitions";
|
|
16
16
|
import { IsTokenValidParameters, LoginParameters, RefreshTokenParameters, ResetPasswordParameters, SendResetPasswordEmailParameters } from "./definitions.requests";
|
|
17
17
|
/**
|
|
18
|
-
*
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
18
|
+
* 🔐 Validates if a token is still active and unexpired.
|
|
19
|
+
*
|
|
20
|
+
* This function checks whether the provided token is valid, ensuring it has not expired or been invalidated.
|
|
21
|
+
*
|
|
22
|
+
* 🛠 **Endpoint**: `GET /auth/is-token-valid [TOK-200]`
|
|
23
|
+
*
|
|
24
|
+
* | Parameter | Type | Required | Description |
|
|
25
|
+
* |-----------|----------|----------|-------------------------------------|
|
|
26
|
+
* | `token` | `string` | ✅ | The token to validate. |
|
|
27
|
+
*
|
|
28
|
+
* 📤 **Returns**:
|
|
29
|
+
* A `Promise<boolean>` resolving to `true` if the token is valid and active, or `false` otherwise.
|
|
30
|
+
*
|
|
31
|
+
* 🛠 **Example usage**:
|
|
32
|
+
* ```ts
|
|
33
|
+
* const isValid = await isTokenValid({
|
|
34
|
+
* token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c",
|
|
34
35
|
* });
|
|
36
|
+
* console.log(isValid); // true
|
|
35
37
|
* ```
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
38
|
+
*
|
|
39
|
+
* @param {IsTokenValidParameters} params - The parameters for validating the token.
|
|
40
|
+
* @throws {Error} If the required `token` parameter is missing.
|
|
41
|
+
* @returns {Promise<boolean>} A promise that resolves to a boolean indicating whether the token is valid.
|
|
40
42
|
*/
|
|
41
43
|
export declare function isTokenValid({ token, }: IsTokenValidParameters): Promise<boolean>;
|
|
42
44
|
/**
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
* ```
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
* "expireAt": 0,
|
|
62
|
-
* "refreshToken": "string"
|
|
63
|
-
* },
|
|
64
|
-
* "user": {
|
|
65
|
-
* "id": "userID"
|
|
66
|
-
* }
|
|
67
|
-
* }
|
|
45
|
+
* 🔄 Requests a new access token using a refresh token.
|
|
46
|
+
*
|
|
47
|
+
* This function allows you to obtain a new access token by providing a valid refresh token.
|
|
48
|
+
*
|
|
49
|
+
* 🛠 **Endpoint**: `POST /auth/refresh-token [AUTH-102]`
|
|
50
|
+
*
|
|
51
|
+
* | Parameter | Type | Required | Description |
|
|
52
|
+
* |-----------------|----------|----------|--------------------------------------------------|
|
|
53
|
+
* | `refreshToken` | `string` | ✅ | The refresh token used to request a new access token. |
|
|
54
|
+
*
|
|
55
|
+
* 📤 **Returns**:
|
|
56
|
+
* A `Promise<RefreshTokenResponse>` containing the new access token, its expiry time, and a refreshed token.
|
|
57
|
+
*
|
|
58
|
+
* 🛠 **Example usage**:
|
|
59
|
+
* ```ts
|
|
60
|
+
* const response = await refreshToken({
|
|
61
|
+
* refreshToken: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
|
|
62
|
+
* });
|
|
68
63
|
* ```
|
|
64
|
+
*
|
|
65
|
+
* @param {RefreshTokenParameters} params - The parameters for requesting a new token.
|
|
66
|
+
* @throws {Error} If the required `refreshToken` parameter is missing.
|
|
67
|
+
* @returns {Promise<RefreshTokenResponse>} A promise that resolves to the response containing the new token and user details.
|
|
69
68
|
*/
|
|
70
69
|
export declare function refreshToken({ refreshToken, }: RefreshTokenParameters): Promise<RefreshTokenResponse>;
|
|
71
70
|
/**
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
71
|
+
* 🔑 Resets the password of a user.
|
|
72
|
+
*
|
|
73
|
+
* This function allows a user to reset their password by providing a new password along with a valid reset token.
|
|
74
|
+
*
|
|
75
|
+
* 🛠 **Endpoint**: `POST /auth/reset-password [PWD-102]`
|
|
76
|
+
*
|
|
77
|
+
* | Parameter | Type | Required | Description |
|
|
78
|
+
* |-----------------------|----------|----------|--------------------------------------------------------------|
|
|
79
|
+
* | `newPassword` | `string` | ✅ | The new password to set for the user. |
|
|
80
|
+
* | `resetPasswordToken` | `string` | ✅ | The token required to authenticate the password reset process. |
|
|
81
|
+
*
|
|
82
|
+
* 📤 **Returns**:
|
|
83
|
+
* A `Promise<void>` that resolves with a success message `"OK"` if the password is successfully reset.
|
|
84
|
+
*
|
|
85
|
+
* 🛠 **Example usage**:
|
|
86
|
+
* ```ts
|
|
87
|
+
* await resetPassword({
|
|
88
|
+
* newPassword: "mySecurePassword2025!",
|
|
89
|
+
* resetPasswordToken: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
|
|
90
|
+
* });
|
|
90
91
|
* ```
|
|
92
|
+
*
|
|
93
|
+
* @param {ResetPasswordParameters} params - The parameters required for resetting the password.
|
|
94
|
+
* @throws {Error} If the required parameters `newPassword` or `resetPasswordToken` are missing.
|
|
95
|
+
* @returns {Promise<void>} Resolves to `"OK"` if the password reset is successful.
|
|
91
96
|
*/
|
|
92
97
|
export declare function resetPassword({ newPassword, resetPasswordToken, }: ResetPasswordParameters): Promise<void>;
|
|
93
98
|
/**
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
* ```
|
|
109
|
-
*
|
|
99
|
+
* 📧 Sends a reset password email to a user.
|
|
100
|
+
*
|
|
101
|
+
* This function sends an email containing a reset password link to the specified email address.
|
|
102
|
+
*
|
|
103
|
+
* 🛠 **Endpoint**: `POST /auth/send-reset-password-email [PWD-101]`
|
|
104
|
+
*
|
|
105
|
+
* | Parameter | Type | Required | Description |
|
|
106
|
+
* |------------|----------|----------|----------------------------------------------------|
|
|
107
|
+
* | `email` | `string` | ✅ | The email address to which the reset link will be sent. |
|
|
108
|
+
*
|
|
109
|
+
* 📤 **Returns**:
|
|
110
|
+
* A `Promise<void>` that resolves when the reset password email is successfully sent.
|
|
111
|
+
*
|
|
112
|
+
* 🛠 **Example usage**:
|
|
113
|
+
* ```ts
|
|
114
|
+
* await sendResetPasswordEmail({
|
|
115
|
+
* email: "user@example.com",
|
|
116
|
+
* });
|
|
110
117
|
* ```
|
|
118
|
+
*
|
|
119
|
+
* @param {SendResetPasswordEmailParameters} params - The parameters required to send the reset password email.
|
|
120
|
+
* @throws {Error} If the required parameter `email` is missing.
|
|
121
|
+
* @returns {Promise<void>} Resolves when the reset email is successfully sent.
|
|
111
122
|
*/
|
|
112
123
|
export declare function sendResetPasswordEmail({ email, }: SendResetPasswordEmailParameters): Promise<void>;
|
|
113
124
|
/**
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
* },
|
|
137
|
-
* "user": {
|
|
138
|
-
* "id": "userID"
|
|
139
|
-
* }
|
|
140
|
-
* }
|
|
125
|
+
* 🔐 Logs in a user.
|
|
126
|
+
*
|
|
127
|
+
* This function allows a user to log in by providing their username and password, and returns their login information, including an access token and user details.
|
|
128
|
+
*
|
|
129
|
+
* 🛠 **Endpoint**: `POST /auth/token?withUser=true [AUTH-101]`
|
|
130
|
+
*
|
|
131
|
+
* | Parameter | Type | Required | Description |
|
|
132
|
+
* |-------------|----------|----------|--------------------------------------|
|
|
133
|
+
* | `username` | `string` | ✅ | The username of the user to log in. |
|
|
134
|
+
* | `password` | `string` | ✅ | The password of the user to log in. |
|
|
135
|
+
*
|
|
136
|
+
* 📤 **Returns**:
|
|
137
|
+
* A `Promise<LoginResponse>` that resolves to the user's login information, including:
|
|
138
|
+
* - `token` (object): Contains the `accessToken`, `refreshToken`, and `expireAt` timestamp.
|
|
139
|
+
* - `user` (object): Contains the user's `id`.
|
|
140
|
+
*
|
|
141
|
+
* 🛠 **Example usage**:
|
|
142
|
+
* ```ts
|
|
143
|
+
* const loginResponse = await login({
|
|
144
|
+
* username: "user@example.com",
|
|
145
|
+
* password: "password123",
|
|
146
|
+
* });
|
|
141
147
|
* ```
|
|
148
|
+
*
|
|
149
|
+
* @param {LoginParameters} params - The parameters required for logging in the user.
|
|
150
|
+
* @throws {Error} If the required parameters `username` or `password` are missing.
|
|
151
|
+
* @returns {Promise<LoginResponse>} Resolves to an object containing the user's login information.
|
|
142
152
|
*/
|
|
143
153
|
export declare function login({ username, password, }: LoginParameters): Promise<LoginResponse>;
|
|
144
154
|
/**
|
|
145
|
-
*
|
|
146
|
-
* ### APICODE(AUTH-103)
|
|
155
|
+
* 🚪 Logs out the user.
|
|
147
156
|
*
|
|
148
|
-
*
|
|
157
|
+
* This function logs out the user by revoking their authentication token.
|
|
149
158
|
*
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
*
|
|
153
|
-
*
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
*
|
|
157
|
-
*
|
|
159
|
+
* 🛠 **Endpoint**: `POST /auth/revoke-token [AUTH-103]`
|
|
160
|
+
*
|
|
161
|
+
* | Parameter | Type | Required | Description |
|
|
162
|
+
* |-----------|------|----------|-------------|
|
|
163
|
+
* | *(none)* | - | - | This function does not require any parameters. |
|
|
164
|
+
*
|
|
165
|
+
* 📤 **Returns**:
|
|
166
|
+
* A `Promise<void>` that resolves when the user is successfully logged out. No additional data is returned.
|
|
167
|
+
*
|
|
168
|
+
* 🛠 **Example usage**:
|
|
169
|
+
* ```ts
|
|
170
|
+
* await logout();
|
|
158
171
|
* ```
|
|
172
|
+
*
|
|
173
|
+
* @throws {Error} If there is an issue with the logout process (e.g., network error).
|
|
174
|
+
* @returns {Promise<void>} Resolves when the logout is successful.
|
|
159
175
|
*/
|
|
160
176
|
export declare function logout(): Promise<void>;
|
|
@@ -23,28 +23,30 @@ exports.logout = logout;
|
|
|
23
23
|
const parameters_validation_1 = require("../../helpers/parameters-validation");
|
|
24
24
|
const fetch_instance_1 = require("../../settings/fetch-instance");
|
|
25
25
|
/**
|
|
26
|
-
*
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
26
|
+
* 🔐 Validates if a token is still active and unexpired.
|
|
27
|
+
*
|
|
28
|
+
* This function checks whether the provided token is valid, ensuring it has not expired or been invalidated.
|
|
29
|
+
*
|
|
30
|
+
* 🛠 **Endpoint**: `GET /auth/is-token-valid [TOK-200]`
|
|
31
|
+
*
|
|
32
|
+
* | Parameter | Type | Required | Description |
|
|
33
|
+
* |-----------|----------|----------|-------------------------------------|
|
|
34
|
+
* | `token` | `string` | ✅ | The token to validate. |
|
|
35
|
+
*
|
|
36
|
+
* 📤 **Returns**:
|
|
37
|
+
* A `Promise<boolean>` resolving to `true` if the token is valid and active, or `false` otherwise.
|
|
38
|
+
*
|
|
39
|
+
* 🛠 **Example usage**:
|
|
40
|
+
* ```ts
|
|
41
|
+
* const isValid = await isTokenValid({
|
|
42
|
+
* token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c",
|
|
42
43
|
* });
|
|
44
|
+
* console.log(isValid); // true
|
|
43
45
|
* ```
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
46
|
+
*
|
|
47
|
+
* @param {IsTokenValidParameters} params - The parameters for validating the token.
|
|
48
|
+
* @throws {Error} If the required `token` parameter is missing.
|
|
49
|
+
* @returns {Promise<boolean>} A promise that resolves to a boolean indicating whether the token is valid.
|
|
48
50
|
*/
|
|
49
51
|
async function isTokenValid({ token, }) {
|
|
50
52
|
(0, parameters_validation_1.required)({ token });
|
|
@@ -58,32 +60,29 @@ async function isTokenValid({ token, }) {
|
|
|
58
60
|
return response === null || response === void 0 ? void 0 : response.data;
|
|
59
61
|
}
|
|
60
62
|
/**
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
* ```
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
* "expireAt": 0,
|
|
80
|
-
* "refreshToken": "string"
|
|
81
|
-
* },
|
|
82
|
-
* "user": {
|
|
83
|
-
* "id": "userID"
|
|
84
|
-
* }
|
|
85
|
-
* }
|
|
63
|
+
* 🔄 Requests a new access token using a refresh token.
|
|
64
|
+
*
|
|
65
|
+
* This function allows you to obtain a new access token by providing a valid refresh token.
|
|
66
|
+
*
|
|
67
|
+
* 🛠 **Endpoint**: `POST /auth/refresh-token [AUTH-102]`
|
|
68
|
+
*
|
|
69
|
+
* | Parameter | Type | Required | Description |
|
|
70
|
+
* |-----------------|----------|----------|--------------------------------------------------|
|
|
71
|
+
* | `refreshToken` | `string` | ✅ | The refresh token used to request a new access token. |
|
|
72
|
+
*
|
|
73
|
+
* 📤 **Returns**:
|
|
74
|
+
* A `Promise<RefreshTokenResponse>` containing the new access token, its expiry time, and a refreshed token.
|
|
75
|
+
*
|
|
76
|
+
* 🛠 **Example usage**:
|
|
77
|
+
* ```ts
|
|
78
|
+
* const response = await refreshToken({
|
|
79
|
+
* refreshToken: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
|
|
80
|
+
* });
|
|
86
81
|
* ```
|
|
82
|
+
*
|
|
83
|
+
* @param {RefreshTokenParameters} params - The parameters for requesting a new token.
|
|
84
|
+
* @throws {Error} If the required `refreshToken` parameter is missing.
|
|
85
|
+
* @returns {Promise<RefreshTokenResponse>} A promise that resolves to the response containing the new token and user details.
|
|
87
86
|
*/
|
|
88
87
|
async function refreshToken({ refreshToken, }) {
|
|
89
88
|
(0, parameters_validation_1.required)({ refreshToken });
|
|
@@ -97,25 +96,31 @@ async function refreshToken({ refreshToken, }) {
|
|
|
97
96
|
return data;
|
|
98
97
|
}
|
|
99
98
|
/**
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
*
|
|
99
|
+
* 🔑 Resets the password of a user.
|
|
100
|
+
*
|
|
101
|
+
* This function allows a user to reset their password by providing a new password along with a valid reset token.
|
|
102
|
+
*
|
|
103
|
+
* 🛠 **Endpoint**: `POST /auth/reset-password [PWD-102]`
|
|
104
|
+
*
|
|
105
|
+
* | Parameter | Type | Required | Description |
|
|
106
|
+
* |-----------------------|----------|----------|--------------------------------------------------------------|
|
|
107
|
+
* | `newPassword` | `string` | ✅ | The new password to set for the user. |
|
|
108
|
+
* | `resetPasswordToken` | `string` | ✅ | The token required to authenticate the password reset process. |
|
|
109
|
+
*
|
|
110
|
+
* 📤 **Returns**:
|
|
111
|
+
* A `Promise<void>` that resolves with a success message `"OK"` if the password is successfully reset.
|
|
112
|
+
*
|
|
113
|
+
* 🛠 **Example usage**:
|
|
114
|
+
* ```ts
|
|
115
|
+
* await resetPassword({
|
|
116
|
+
* newPassword: "mySecurePassword2025!",
|
|
117
|
+
* resetPasswordToken: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
|
|
118
|
+
* });
|
|
118
119
|
* ```
|
|
120
|
+
*
|
|
121
|
+
* @param {ResetPasswordParameters} params - The parameters required for resetting the password.
|
|
122
|
+
* @throws {Error} If the required parameters `newPassword` or `resetPasswordToken` are missing.
|
|
123
|
+
* @returns {Promise<void>} Resolves to `"OK"` if the password reset is successful.
|
|
119
124
|
*/
|
|
120
125
|
async function resetPassword({ newPassword, resetPasswordToken, }) {
|
|
121
126
|
(0, parameters_validation_1.required)({ newPassword, resetPasswordToken });
|
|
@@ -129,23 +134,29 @@ async function resetPassword({ newPassword, resetPasswordToken, }) {
|
|
|
129
134
|
});
|
|
130
135
|
}
|
|
131
136
|
/**
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
*
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
*
|
|
143
|
-
*
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
* ```
|
|
147
|
-
*
|
|
137
|
+
* 📧 Sends a reset password email to a user.
|
|
138
|
+
*
|
|
139
|
+
* This function sends an email containing a reset password link to the specified email address.
|
|
140
|
+
*
|
|
141
|
+
* 🛠 **Endpoint**: `POST /auth/send-reset-password-email [PWD-101]`
|
|
142
|
+
*
|
|
143
|
+
* | Parameter | Type | Required | Description |
|
|
144
|
+
* |------------|----------|----------|----------------------------------------------------|
|
|
145
|
+
* | `email` | `string` | ✅ | The email address to which the reset link will be sent. |
|
|
146
|
+
*
|
|
147
|
+
* 📤 **Returns**:
|
|
148
|
+
* A `Promise<void>` that resolves when the reset password email is successfully sent.
|
|
149
|
+
*
|
|
150
|
+
* 🛠 **Example usage**:
|
|
151
|
+
* ```ts
|
|
152
|
+
* await sendResetPasswordEmail({
|
|
153
|
+
* email: "user@example.com",
|
|
154
|
+
* });
|
|
148
155
|
* ```
|
|
156
|
+
*
|
|
157
|
+
* @param {SendResetPasswordEmailParameters} params - The parameters required to send the reset password email.
|
|
158
|
+
* @throws {Error} If the required parameter `email` is missing.
|
|
159
|
+
* @returns {Promise<void>} Resolves when the reset email is successfully sent.
|
|
149
160
|
*/
|
|
150
161
|
async function sendResetPasswordEmail({ email, }) {
|
|
151
162
|
(0, parameters_validation_1.required)({ email });
|
|
@@ -158,34 +169,33 @@ async function sendResetPasswordEmail({ email, }) {
|
|
|
158
169
|
});
|
|
159
170
|
}
|
|
160
171
|
/**
|
|
161
|
-
*
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
*
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
-
*
|
|
170
|
-
*
|
|
171
|
-
*
|
|
172
|
-
*
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
*
|
|
176
|
-
*
|
|
177
|
-
*
|
|
178
|
-
*
|
|
179
|
-
*
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
* },
|
|
184
|
-
* "user": {
|
|
185
|
-
* "id": "userID"
|
|
186
|
-
* }
|
|
187
|
-
* }
|
|
172
|
+
* 🔐 Logs in a user.
|
|
173
|
+
*
|
|
174
|
+
* This function allows a user to log in by providing their username and password, and returns their login information, including an access token and user details.
|
|
175
|
+
*
|
|
176
|
+
* 🛠 **Endpoint**: `POST /auth/token?withUser=true [AUTH-101]`
|
|
177
|
+
*
|
|
178
|
+
* | Parameter | Type | Required | Description |
|
|
179
|
+
* |-------------|----------|----------|--------------------------------------|
|
|
180
|
+
* | `username` | `string` | ✅ | The username of the user to log in. |
|
|
181
|
+
* | `password` | `string` | ✅ | The password of the user to log in. |
|
|
182
|
+
*
|
|
183
|
+
* 📤 **Returns**:
|
|
184
|
+
* A `Promise<LoginResponse>` that resolves to the user's login information, including:
|
|
185
|
+
* - `token` (object): Contains the `accessToken`, `refreshToken`, and `expireAt` timestamp.
|
|
186
|
+
* - `user` (object): Contains the user's `id`.
|
|
187
|
+
*
|
|
188
|
+
* 🛠 **Example usage**:
|
|
189
|
+
* ```ts
|
|
190
|
+
* const loginResponse = await login({
|
|
191
|
+
* username: "user@example.com",
|
|
192
|
+
* password: "password123",
|
|
193
|
+
* });
|
|
188
194
|
* ```
|
|
195
|
+
*
|
|
196
|
+
* @param {LoginParameters} params - The parameters required for logging in the user.
|
|
197
|
+
* @throws {Error} If the required parameters `username` or `password` are missing.
|
|
198
|
+
* @returns {Promise<LoginResponse>} Resolves to an object containing the user's login information.
|
|
189
199
|
*/
|
|
190
200
|
async function login({ username, password, }) {
|
|
191
201
|
(0, parameters_validation_1.required)({ username, password });
|
|
@@ -200,20 +210,26 @@ async function login({ username, password, }) {
|
|
|
200
210
|
return data;
|
|
201
211
|
}
|
|
202
212
|
/**
|
|
203
|
-
*
|
|
204
|
-
* ### APICODE(AUTH-103)
|
|
213
|
+
* 🚪 Logs out the user.
|
|
205
214
|
*
|
|
206
|
-
*
|
|
215
|
+
* This function logs out the user by revoking their authentication token.
|
|
207
216
|
*
|
|
208
|
-
*
|
|
209
|
-
*
|
|
210
|
-
*
|
|
211
|
-
*
|
|
212
|
-
*
|
|
213
|
-
*
|
|
214
|
-
*
|
|
215
|
-
*
|
|
217
|
+
* 🛠 **Endpoint**: `POST /auth/revoke-token [AUTH-103]`
|
|
218
|
+
*
|
|
219
|
+
* | Parameter | Type | Required | Description |
|
|
220
|
+
* |-----------|------|----------|-------------|
|
|
221
|
+
* | *(none)* | - | - | This function does not require any parameters. |
|
|
222
|
+
*
|
|
223
|
+
* 📤 **Returns**:
|
|
224
|
+
* A `Promise<void>` that resolves when the user is successfully logged out. No additional data is returned.
|
|
225
|
+
*
|
|
226
|
+
* 🛠 **Example usage**:
|
|
227
|
+
* ```ts
|
|
228
|
+
* await logout();
|
|
216
229
|
* ```
|
|
230
|
+
*
|
|
231
|
+
* @throws {Error} If there is an issue with the logout process (e.g., network error).
|
|
232
|
+
* @returns {Promise<void>} Resolves when the logout is successful.
|
|
217
233
|
*/
|
|
218
234
|
async function logout() {
|
|
219
235
|
await (0, fetch_instance_1.enhancedFetch)({
|