@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.
@@ -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
- * AUTH ENDPOINT
19
- */
20
- /**
21
- * ##R eturns true if the token is valid and not expired, false otherwise
22
- * ### APICODE(TOK-200)
23
- * @param {IsTokenValidParameters} params - The parameters for the function
24
- * #### token - `string` | <strong style={{ color: 'red' }}>required</strong>
25
- * The token to validate.
26
- *
27
- * @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the token is valid or not
28
- *
29
- * @example
30
- * #### input
31
- * ```typescript
32
- * const isValidToken = await isTokenValid({
33
- * token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c",
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
- * #### output
37
- * ```json
38
- * true
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
- * ## Ask for a new token from a refresh token
44
- * ### APICODE(AUTH-102)
45
- * @param {RefreshTokenParameters} params - The parameters for the function, including:
46
- * #### refreshToken - `string` | <strong style={{ color: 'red' }}>required</strong>
47
- * The refresh token to request a new access token (required)
48
- *
49
- * @returns {Promise<RefreshTokenResponse>} - A promise that resolves to the response containing the new token
50
- *
51
- * @example
52
- * #### input
53
- * ```typescript
54
- * const response = await refreshToken({ refreshToken: 'string' });
55
- * ```
56
- * #### output
57
- * ```json
58
- * {
59
- * "token": {
60
- * "accessToken": "string",
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
- * ## Reset the password of a user
73
- * ### APICODE(PWD-102)
74
- * @param {ResetPasswordParameters} params - The parameters for the function
75
- * #### newPassword - `string` | <strong style={{ color: 'red' }}>required</strong>
76
- * The new password to set for the user.
77
- * #### resetPasswordToken - `string` | <strong style={{ color: 'red' }}>required</strong>
78
- * The token required to authenticate the password reset process.
79
- *
80
- * @returns {Promise<void>} - Resolves to a success message `"OK"` when the password is successfully reset
81
- *
82
- * @example
83
- * #### input
84
- * ```typescript
85
- * await resetPassword({ newPassword: 'string', resetPasswordToken: 'string' });
86
- * ```
87
- * #### output
88
- * ```json
89
- * "OK" (No output, resolves on success)
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
- * ## Send an email to the user with a reset password link
95
- * ### APICODE(PWD-101)
96
- * @param {SendResetPasswordEmailParameters} params - The parameters for the function, including:
97
- * #### email - `string` | <strong style={{ color: 'red' }}>required</strong>
98
- * The email address to send the reset link to.
99
- *
100
- * @returns {Promise<void>} - A promise that resolves when the email is sent
101
- *
102
- * @example
103
- * #### input
104
- * ```typescript
105
- * await sendResetPasswordEmail({ email: 'user@example.com' });
106
- * ```
107
- * #### output
108
- * ```json
109
- * "OK" (No output, resolves on success)
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
- * ##Login a user
115
- * ### APICODE(AUTH-101)
116
- * @param {LoginParameters} params - The parameters for the function, including:
117
- * #### username - `string` | <strong style={{ color: 'red' }}>required</strong>
118
- * The username of the user to log in.
119
- * #### password - `string` | <strong style={{ color: 'red' }}>required</strong>
120
- * The password of the user to log in.
121
- *
122
- * @returns {Promise<LoginResponse>} - A promise that resolves to the response containing the user's login information
123
- *
124
- * @example
125
- * #### input
126
- * ```typescript
127
- * const loginResponse = await login({ username: 'user@example.com', password: 'password123' });
128
- * ```
129
- * #### output
130
- * ```json
131
- * {
132
- * "token": {
133
- * "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c",
134
- * "expireAt": 1679022000,
135
- * "refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"
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
- * ### Logout the user
146
- * ### APICODE(AUTH-103)
155
+ * 🚪 Logs out the user.
147
156
  *
148
- * @returns {Promise<void>} - A promise that resolves when the user is logged out
157
+ * This function logs out the user by revoking their authentication token.
149
158
  *
150
- * @example
151
- * #### input
152
- * ```typescript
153
- * await logout();
154
- * ```
155
- * #### output
156
- * ```json
157
- * "OK" (No output, resolves on success)
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
- * AUTH ENDPOINT
27
- */
28
- /**
29
- * ##R eturns true if the token is valid and not expired, false otherwise
30
- * ### APICODE(TOK-200)
31
- * @param {IsTokenValidParameters} params - The parameters for the function
32
- * #### token - `string` | <strong style={{ color: 'red' }}>required</strong>
33
- * The token to validate.
34
- *
35
- * @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the token is valid or not
36
- *
37
- * @example
38
- * #### input
39
- * ```typescript
40
- * const isValidToken = await isTokenValid({
41
- * token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c",
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
- * #### output
45
- * ```json
46
- * true
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
- * ## Ask for a new token from a refresh token
62
- * ### APICODE(AUTH-102)
63
- * @param {RefreshTokenParameters} params - The parameters for the function, including:
64
- * #### refreshToken - `string` | <strong style={{ color: 'red' }}>required</strong>
65
- * The refresh token to request a new access token (required)
66
- *
67
- * @returns {Promise<RefreshTokenResponse>} - A promise that resolves to the response containing the new token
68
- *
69
- * @example
70
- * #### input
71
- * ```typescript
72
- * const response = await refreshToken({ refreshToken: 'string' });
73
- * ```
74
- * #### output
75
- * ```json
76
- * {
77
- * "token": {
78
- * "accessToken": "string",
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
- * ## Reset the password of a user
101
- * ### APICODE(PWD-102)
102
- * @param {ResetPasswordParameters} params - The parameters for the function
103
- * #### newPassword - `string` | <strong style={{ color: 'red' }}>required</strong>
104
- * The new password to set for the user.
105
- * #### resetPasswordToken - `string` | <strong style={{ color: 'red' }}>required</strong>
106
- * The token required to authenticate the password reset process.
107
- *
108
- * @returns {Promise<void>} - Resolves to a success message `"OK"` when the password is successfully reset
109
- *
110
- * @example
111
- * #### input
112
- * ```typescript
113
- * await resetPassword({ newPassword: 'string', resetPasswordToken: 'string' });
114
- * ```
115
- * #### output
116
- * ```json
117
- * "OK" (No output, resolves on success)
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
- * ## Send an email to the user with a reset password link
133
- * ### APICODE(PWD-101)
134
- * @param {SendResetPasswordEmailParameters} params - The parameters for the function, including:
135
- * #### email - `string` | <strong style={{ color: 'red' }}>required</strong>
136
- * The email address to send the reset link to.
137
- *
138
- * @returns {Promise<void>} - A promise that resolves when the email is sent
139
- *
140
- * @example
141
- * #### input
142
- * ```typescript
143
- * await sendResetPasswordEmail({ email: 'user@example.com' });
144
- * ```
145
- * #### output
146
- * ```json
147
- * "OK" (No output, resolves on success)
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
- * ##Login a user
162
- * ### APICODE(AUTH-101)
163
- * @param {LoginParameters} params - The parameters for the function, including:
164
- * #### username - `string` | <strong style={{ color: 'red' }}>required</strong>
165
- * The username of the user to log in.
166
- * #### password - `string` | <strong style={{ color: 'red' }}>required</strong>
167
- * The password of the user to log in.
168
- *
169
- * @returns {Promise<LoginResponse>} - A promise that resolves to the response containing the user's login information
170
- *
171
- * @example
172
- * #### input
173
- * ```typescript
174
- * const loginResponse = await login({ username: 'user@example.com', password: 'password123' });
175
- * ```
176
- * #### output
177
- * ```json
178
- * {
179
- * "token": {
180
- * "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c",
181
- * "expireAt": 1679022000,
182
- * "refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"
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
- * ### Logout the user
204
- * ### APICODE(AUTH-103)
213
+ * 🚪 Logs out the user.
205
214
  *
206
- * @returns {Promise<void>} - A promise that resolves when the user is logged out
215
+ * This function logs out the user by revoking their authentication token.
207
216
  *
208
- * @example
209
- * #### input
210
- * ```typescript
211
- * await logout();
212
- * ```
213
- * #### output
214
- * ```json
215
- * "OK" (No output, resolves on success)
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)({