@anzar-auth/core 1.5.10

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/index.js ADDED
@@ -0,0 +1,934 @@
1
+ // src/generated/api/auth-api.ts
2
+ import globalAxios2 from "axios";
3
+
4
+ // src/generated/base.ts
5
+ import globalAxios from "axios";
6
+ var BASE_PATH = "http://localhost".replace(/\/+$/, "");
7
+ var BaseAPI = class {
8
+ constructor(configuration, basePath = BASE_PATH, axios = globalAxios) {
9
+ this.basePath = basePath;
10
+ this.axios = axios;
11
+ if (configuration) {
12
+ this.configuration = configuration;
13
+ this.basePath = configuration.basePath ?? basePath;
14
+ }
15
+ }
16
+ configuration;
17
+ };
18
+ var RequiredError = class extends Error {
19
+ constructor(field, msg) {
20
+ super(msg);
21
+ this.field = field;
22
+ this.name = "RequiredError";
23
+ }
24
+ };
25
+ var operationServerMap = {};
26
+
27
+ // src/generated/common.ts
28
+ var DUMMY_BASE_URL = "https://example.com";
29
+ var assertParamExists = function(functionName, paramName, paramValue) {
30
+ if (paramValue === null || paramValue === void 0) {
31
+ throw new RequiredError(paramName, `Required parameter ${paramName} was null or undefined when calling ${functionName}.`);
32
+ }
33
+ };
34
+ var setBearerAuthToObject = async function(object, configuration) {
35
+ if (configuration && configuration.accessToken) {
36
+ const accessToken = typeof configuration.accessToken === "function" ? await configuration.accessToken() : await configuration.accessToken;
37
+ object["Authorization"] = "Bearer " + accessToken;
38
+ }
39
+ };
40
+ function setFlattenedQueryParams(urlSearchParams, parameter, key = "") {
41
+ if (parameter == null) return;
42
+ if (typeof parameter === "object") {
43
+ if (Array.isArray(parameter) || parameter instanceof Set) {
44
+ parameter.forEach((item) => setFlattenedQueryParams(urlSearchParams, item, key));
45
+ } else {
46
+ Object.keys(parameter).forEach(
47
+ (currentKey) => setFlattenedQueryParams(urlSearchParams, parameter[currentKey], `${key}${key !== "" ? "." : ""}${currentKey}`)
48
+ );
49
+ }
50
+ } else {
51
+ if (urlSearchParams.has(key)) {
52
+ urlSearchParams.append(key, parameter);
53
+ } else {
54
+ urlSearchParams.set(key, parameter);
55
+ }
56
+ }
57
+ }
58
+ var setSearchParams = function(url, ...objects) {
59
+ const searchParams = new URLSearchParams(url.search);
60
+ setFlattenedQueryParams(searchParams, objects);
61
+ url.search = searchParams.toString();
62
+ };
63
+ var replaceWithSerializableTypeIfNeeded = function(key, value) {
64
+ if (value instanceof Set) {
65
+ return Array.from(value);
66
+ } else {
67
+ return value;
68
+ }
69
+ };
70
+ var serializeDataIfNeeded = function(value, requestOptions, configuration) {
71
+ const nonString = typeof value !== "string";
72
+ const needsSerialization = nonString && configuration && configuration.isJsonMime ? configuration.isJsonMime(requestOptions.headers["Content-Type"]) : nonString;
73
+ return needsSerialization ? JSON.stringify(value !== void 0 ? value : {}, replaceWithSerializableTypeIfNeeded) : value || "";
74
+ };
75
+ var toPathString = function(url) {
76
+ return url.pathname + url.search + url.hash;
77
+ };
78
+ var createRequestFunction = function(axiosArgs, globalAxios5, BASE_PATH2, configuration) {
79
+ return (axios = globalAxios5, basePath = BASE_PATH2) => {
80
+ const axiosRequestArgs = { ...axiosArgs.options, url: (axios.defaults.baseURL ? "" : configuration?.basePath ?? basePath) + axiosArgs.url };
81
+ return axios.request(axiosRequestArgs);
82
+ };
83
+ };
84
+
85
+ // src/generated/api/auth-api.ts
86
+ var AuthApiAxiosParamCreator = function(configuration) {
87
+ return {
88
+ /**
89
+ * Returns the currently authenticated user\'s session data. Requires a valid Bearer token.
90
+ * @summary Get current session
91
+ * @param {*} [options] Override http request option.
92
+ * @throws {RequiredError}
93
+ */
94
+ getSession: async (options = {}) => {
95
+ const localVarPath = `/auth/session`;
96
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
97
+ let baseOptions;
98
+ if (configuration) {
99
+ baseOptions = configuration.baseOptions;
100
+ }
101
+ const localVarRequestOptions = { method: "GET", ...baseOptions, ...options };
102
+ const localVarHeaderParameter = {};
103
+ const localVarQueryParameter = {};
104
+ await setBearerAuthToObject(localVarHeaderParameter, configuration);
105
+ localVarHeaderParameter["Accept"] = "application/json";
106
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
107
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
108
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
109
+ return {
110
+ url: toPathString(localVarUrlObj),
111
+ options: localVarRequestOptions
112
+ };
113
+ },
114
+ /**
115
+ * Authenticates a user with email and password. **Session strategy**: Returns a session cookie (`id`) managed by the server. **JWT strategy**: Returns `access` and `refresh` in the response body.
116
+ * @summary User login
117
+ * @param {LoginRequest} loginRequest User login credentials
118
+ * @param {*} [options] Override http request option.
119
+ * @throws {RequiredError}
120
+ */
121
+ login: async (loginRequest, options = {}) => {
122
+ assertParamExists("login", "loginRequest", loginRequest);
123
+ const localVarPath = `/auth/login`;
124
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
125
+ let baseOptions;
126
+ if (configuration) {
127
+ baseOptions = configuration.baseOptions;
128
+ }
129
+ const localVarRequestOptions = { method: "POST", ...baseOptions, ...options };
130
+ const localVarHeaderParameter = {};
131
+ const localVarQueryParameter = {};
132
+ localVarHeaderParameter["Content-Type"] = "application/json";
133
+ localVarHeaderParameter["Accept"] = "application/json";
134
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
135
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
136
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
137
+ localVarRequestOptions.data = serializeDataIfNeeded(loginRequest, localVarRequestOptions, configuration);
138
+ return {
139
+ url: toPathString(localVarUrlObj),
140
+ options: localVarRequestOptions
141
+ };
142
+ },
143
+ /**
144
+ * Invalidates the current session and refresh token. The client should discard stored tokens.
145
+ * @summary Logout
146
+ * @param {RefreshTokenRequest} refreshTokenRequest
147
+ * @param {*} [options] Override http request option.
148
+ * @throws {RequiredError}
149
+ */
150
+ logout: async (refreshTokenRequest, options = {}) => {
151
+ assertParamExists("logout", "refreshTokenRequest", refreshTokenRequest);
152
+ const localVarPath = `/auth/logout`;
153
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
154
+ let baseOptions;
155
+ if (configuration) {
156
+ baseOptions = configuration.baseOptions;
157
+ }
158
+ const localVarRequestOptions = { method: "POST", ...baseOptions, ...options };
159
+ const localVarHeaderParameter = {};
160
+ const localVarQueryParameter = {};
161
+ await setBearerAuthToObject(localVarHeaderParameter, configuration);
162
+ localVarHeaderParameter["Content-Type"] = "application/json";
163
+ localVarHeaderParameter["Accept"] = "application/json";
164
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
165
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
166
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
167
+ localVarRequestOptions.data = serializeDataIfNeeded(refreshTokenRequest, localVarRequestOptions, configuration);
168
+ return {
169
+ url: toPathString(localVarUrlObj),
170
+ options: localVarRequestOptions
171
+ };
172
+ },
173
+ /**
174
+ * Issues a new access token using a valid refresh token. Rotate refresh tokens on each call.
175
+ * @summary Refresh access token
176
+ * @param {RefreshTokenRequest} refreshTokenRequest
177
+ * @param {*} [options] Override http request option.
178
+ * @throws {RequiredError}
179
+ */
180
+ refreshToken: async (refreshTokenRequest, options = {}) => {
181
+ assertParamExists("refreshToken", "refreshTokenRequest", refreshTokenRequest);
182
+ const localVarPath = `/auth/refresh-token`;
183
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
184
+ let baseOptions;
185
+ if (configuration) {
186
+ baseOptions = configuration.baseOptions;
187
+ }
188
+ const localVarRequestOptions = { method: "POST", ...baseOptions, ...options };
189
+ const localVarHeaderParameter = {};
190
+ const localVarQueryParameter = {};
191
+ await setBearerAuthToObject(localVarHeaderParameter, configuration);
192
+ localVarHeaderParameter["Content-Type"] = "application/json";
193
+ localVarHeaderParameter["Accept"] = "application/json";
194
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
195
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
196
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
197
+ localVarRequestOptions.data = serializeDataIfNeeded(refreshTokenRequest, localVarRequestOptions, configuration);
198
+ return {
199
+ url: toPathString(localVarUrlObj),
200
+ options: localVarRequestOptions
201
+ };
202
+ },
203
+ /**
204
+ * Creates a new user account with email and password. **Session strategy**: Returns a session cookie (`id`) managed by the server. **JWT strategy**: Returns `access` and `refresh` in the response body.
205
+ * @summary Register a new user
206
+ * @param {RegisterRequest} registerRequest User register credentials
207
+ * @param {*} [options] Override http request option.
208
+ * @throws {RequiredError}
209
+ */
210
+ register: async (registerRequest, options = {}) => {
211
+ assertParamExists("register", "registerRequest", registerRequest);
212
+ const localVarPath = `/auth/register`;
213
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
214
+ let baseOptions;
215
+ if (configuration) {
216
+ baseOptions = configuration.baseOptions;
217
+ }
218
+ const localVarRequestOptions = { method: "POST", ...baseOptions, ...options };
219
+ const localVarHeaderParameter = {};
220
+ const localVarQueryParameter = {};
221
+ localVarHeaderParameter["Content-Type"] = "application/json";
222
+ localVarHeaderParameter["Accept"] = "application/json";
223
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
224
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
225
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
226
+ localVarRequestOptions.data = serializeDataIfNeeded(registerRequest, localVarRequestOptions, configuration);
227
+ return {
228
+ url: toPathString(localVarUrlObj),
229
+ options: localVarRequestOptions
230
+ };
231
+ },
232
+ /**
233
+ * Validates the reset token from the email link and renders the password reset form.
234
+ * @summary Render password reset form
235
+ * @param {TokenQuery} token Password reset token
236
+ * @param {*} [options] Override http request option.
237
+ * @throws {RequiredError}
238
+ */
239
+ renderResetForm: async (token, options = {}) => {
240
+ assertParamExists("renderResetForm", "token", token);
241
+ const localVarPath = `/auth/password/reset`;
242
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
243
+ let baseOptions;
244
+ if (configuration) {
245
+ baseOptions = configuration.baseOptions;
246
+ }
247
+ const localVarRequestOptions = { method: "GET", ...baseOptions, ...options };
248
+ const localVarHeaderParameter = {};
249
+ const localVarQueryParameter = {};
250
+ if (token !== void 0) {
251
+ for (const [key, value] of Object.entries(token)) {
252
+ localVarQueryParameter[key] = value;
253
+ }
254
+ }
255
+ localVarHeaderParameter["Accept"] = "text/html,application/json";
256
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
257
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
258
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
259
+ return {
260
+ url: toPathString(localVarUrlObj),
261
+ options: localVarRequestOptions
262
+ };
263
+ },
264
+ /**
265
+ * Sends a password reset link to the provided email address if an account exists.
266
+ * @summary Request a password reset
267
+ * @param {EmailRequest} emailRequest Email address to send the reset link to
268
+ * @param {*} [options] Override http request option.
269
+ * @throws {RequiredError}
270
+ */
271
+ requestPasswordReset: async (emailRequest, options = {}) => {
272
+ assertParamExists("requestPasswordReset", "emailRequest", emailRequest);
273
+ const localVarPath = `/auth/password/forgot`;
274
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
275
+ let baseOptions;
276
+ if (configuration) {
277
+ baseOptions = configuration.baseOptions;
278
+ }
279
+ const localVarRequestOptions = { method: "POST", ...baseOptions, ...options };
280
+ const localVarHeaderParameter = {};
281
+ const localVarQueryParameter = {};
282
+ localVarHeaderParameter["Content-Type"] = "application/json";
283
+ localVarHeaderParameter["Accept"] = "application/json";
284
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
285
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
286
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
287
+ localVarRequestOptions.data = serializeDataIfNeeded(emailRequest, localVarRequestOptions, configuration);
288
+ return {
289
+ url: toPathString(localVarUrlObj),
290
+ options: localVarRequestOptions
291
+ };
292
+ },
293
+ /**
294
+ * Submits a new password using a valid reset token. Invalidates the token after use.
295
+ * @summary Submit new password
296
+ * @param {ResetPasswordRequest} resetPasswordRequest Reset token and the new password
297
+ * @param {*} [options] Override http request option.
298
+ * @throws {RequiredError}
299
+ */
300
+ submitNewPassword: async (resetPasswordRequest, options = {}) => {
301
+ assertParamExists("submitNewPassword", "resetPasswordRequest", resetPasswordRequest);
302
+ const localVarPath = `/auth/password/reset`;
303
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
304
+ let baseOptions;
305
+ if (configuration) {
306
+ baseOptions = configuration.baseOptions;
307
+ }
308
+ const localVarRequestOptions = { method: "POST", ...baseOptions, ...options };
309
+ const localVarHeaderParameter = {};
310
+ const localVarQueryParameter = {};
311
+ localVarHeaderParameter["Content-Type"] = "application/json";
312
+ localVarHeaderParameter["Accept"] = "application/json";
313
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
314
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
315
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
316
+ localVarRequestOptions.data = serializeDataIfNeeded(resetPasswordRequest, localVarRequestOptions, configuration);
317
+ return {
318
+ url: toPathString(localVarUrlObj),
319
+ options: localVarRequestOptions
320
+ };
321
+ }
322
+ };
323
+ };
324
+ var AuthApiFp = function(configuration) {
325
+ const localVarAxiosParamCreator = AuthApiAxiosParamCreator(configuration);
326
+ return {
327
+ /**
328
+ * Returns the currently authenticated user\'s session data. Requires a valid Bearer token.
329
+ * @summary Get current session
330
+ * @param {*} [options] Override http request option.
331
+ * @throws {RequiredError}
332
+ */
333
+ async getSession(options) {
334
+ const localVarAxiosArgs = await localVarAxiosParamCreator.getSession(options);
335
+ const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
336
+ const localVarOperationServerBasePath = operationServerMap["AuthApi.getSession"]?.[localVarOperationServerIndex]?.url;
337
+ return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios2, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
338
+ },
339
+ /**
340
+ * Authenticates a user with email and password. **Session strategy**: Returns a session cookie (`id`) managed by the server. **JWT strategy**: Returns `access` and `refresh` in the response body.
341
+ * @summary User login
342
+ * @param {LoginRequest} loginRequest User login credentials
343
+ * @param {*} [options] Override http request option.
344
+ * @throws {RequiredError}
345
+ */
346
+ async login(loginRequest, options) {
347
+ const localVarAxiosArgs = await localVarAxiosParamCreator.login(loginRequest, options);
348
+ const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
349
+ const localVarOperationServerBasePath = operationServerMap["AuthApi.login"]?.[localVarOperationServerIndex]?.url;
350
+ return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios2, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
351
+ },
352
+ /**
353
+ * Invalidates the current session and refresh token. The client should discard stored tokens.
354
+ * @summary Logout
355
+ * @param {RefreshTokenRequest} refreshTokenRequest
356
+ * @param {*} [options] Override http request option.
357
+ * @throws {RequiredError}
358
+ */
359
+ async logout(refreshTokenRequest, options) {
360
+ const localVarAxiosArgs = await localVarAxiosParamCreator.logout(refreshTokenRequest, options);
361
+ const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
362
+ const localVarOperationServerBasePath = operationServerMap["AuthApi.logout"]?.[localVarOperationServerIndex]?.url;
363
+ return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios2, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
364
+ },
365
+ /**
366
+ * Issues a new access token using a valid refresh token. Rotate refresh tokens on each call.
367
+ * @summary Refresh access token
368
+ * @param {RefreshTokenRequest} refreshTokenRequest
369
+ * @param {*} [options] Override http request option.
370
+ * @throws {RequiredError}
371
+ */
372
+ async refreshToken(refreshTokenRequest, options) {
373
+ const localVarAxiosArgs = await localVarAxiosParamCreator.refreshToken(refreshTokenRequest, options);
374
+ const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
375
+ const localVarOperationServerBasePath = operationServerMap["AuthApi.refreshToken"]?.[localVarOperationServerIndex]?.url;
376
+ return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios2, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
377
+ },
378
+ /**
379
+ * Creates a new user account with email and password. **Session strategy**: Returns a session cookie (`id`) managed by the server. **JWT strategy**: Returns `access` and `refresh` in the response body.
380
+ * @summary Register a new user
381
+ * @param {RegisterRequest} registerRequest User register credentials
382
+ * @param {*} [options] Override http request option.
383
+ * @throws {RequiredError}
384
+ */
385
+ async register(registerRequest, options) {
386
+ const localVarAxiosArgs = await localVarAxiosParamCreator.register(registerRequest, options);
387
+ const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
388
+ const localVarOperationServerBasePath = operationServerMap["AuthApi.register"]?.[localVarOperationServerIndex]?.url;
389
+ return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios2, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
390
+ },
391
+ /**
392
+ * Validates the reset token from the email link and renders the password reset form.
393
+ * @summary Render password reset form
394
+ * @param {TokenQuery} token Password reset token
395
+ * @param {*} [options] Override http request option.
396
+ * @throws {RequiredError}
397
+ */
398
+ async renderResetForm(token, options) {
399
+ const localVarAxiosArgs = await localVarAxiosParamCreator.renderResetForm(token, options);
400
+ const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
401
+ const localVarOperationServerBasePath = operationServerMap["AuthApi.renderResetForm"]?.[localVarOperationServerIndex]?.url;
402
+ return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios2, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
403
+ },
404
+ /**
405
+ * Sends a password reset link to the provided email address if an account exists.
406
+ * @summary Request a password reset
407
+ * @param {EmailRequest} emailRequest Email address to send the reset link to
408
+ * @param {*} [options] Override http request option.
409
+ * @throws {RequiredError}
410
+ */
411
+ async requestPasswordReset(emailRequest, options) {
412
+ const localVarAxiosArgs = await localVarAxiosParamCreator.requestPasswordReset(emailRequest, options);
413
+ const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
414
+ const localVarOperationServerBasePath = operationServerMap["AuthApi.requestPasswordReset"]?.[localVarOperationServerIndex]?.url;
415
+ return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios2, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
416
+ },
417
+ /**
418
+ * Submits a new password using a valid reset token. Invalidates the token after use.
419
+ * @summary Submit new password
420
+ * @param {ResetPasswordRequest} resetPasswordRequest Reset token and the new password
421
+ * @param {*} [options] Override http request option.
422
+ * @throws {RequiredError}
423
+ */
424
+ async submitNewPassword(resetPasswordRequest, options) {
425
+ const localVarAxiosArgs = await localVarAxiosParamCreator.submitNewPassword(resetPasswordRequest, options);
426
+ const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
427
+ const localVarOperationServerBasePath = operationServerMap["AuthApi.submitNewPassword"]?.[localVarOperationServerIndex]?.url;
428
+ return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios2, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
429
+ }
430
+ };
431
+ };
432
+ var AuthApiFactory = function(configuration, basePath, axios) {
433
+ const localVarFp = AuthApiFp(configuration);
434
+ return {
435
+ /**
436
+ * Returns the currently authenticated user\'s session data. Requires a valid Bearer token.
437
+ * @summary Get current session
438
+ * @param {*} [options] Override http request option.
439
+ * @throws {RequiredError}
440
+ */
441
+ getSession(options) {
442
+ return localVarFp.getSession(options).then((request) => request(axios, basePath));
443
+ },
444
+ /**
445
+ * Authenticates a user with email and password. **Session strategy**: Returns a session cookie (`id`) managed by the server. **JWT strategy**: Returns `access` and `refresh` in the response body.
446
+ * @summary User login
447
+ * @param {LoginRequest} loginRequest User login credentials
448
+ * @param {*} [options] Override http request option.
449
+ * @throws {RequiredError}
450
+ */
451
+ login(loginRequest, options) {
452
+ return localVarFp.login(loginRequest, options).then((request) => request(axios, basePath));
453
+ },
454
+ /**
455
+ * Invalidates the current session and refresh token. The client should discard stored tokens.
456
+ * @summary Logout
457
+ * @param {RefreshTokenRequest} refreshTokenRequest
458
+ * @param {*} [options] Override http request option.
459
+ * @throws {RequiredError}
460
+ */
461
+ logout(refreshTokenRequest, options) {
462
+ return localVarFp.logout(refreshTokenRequest, options).then((request) => request(axios, basePath));
463
+ },
464
+ /**
465
+ * Issues a new access token using a valid refresh token. Rotate refresh tokens on each call.
466
+ * @summary Refresh access token
467
+ * @param {RefreshTokenRequest} refreshTokenRequest
468
+ * @param {*} [options] Override http request option.
469
+ * @throws {RequiredError}
470
+ */
471
+ refreshToken(refreshTokenRequest, options) {
472
+ return localVarFp.refreshToken(refreshTokenRequest, options).then((request) => request(axios, basePath));
473
+ },
474
+ /**
475
+ * Creates a new user account with email and password. **Session strategy**: Returns a session cookie (`id`) managed by the server. **JWT strategy**: Returns `access` and `refresh` in the response body.
476
+ * @summary Register a new user
477
+ * @param {RegisterRequest} registerRequest User register credentials
478
+ * @param {*} [options] Override http request option.
479
+ * @throws {RequiredError}
480
+ */
481
+ register(registerRequest, options) {
482
+ return localVarFp.register(registerRequest, options).then((request) => request(axios, basePath));
483
+ },
484
+ /**
485
+ * Validates the reset token from the email link and renders the password reset form.
486
+ * @summary Render password reset form
487
+ * @param {TokenQuery} token Password reset token
488
+ * @param {*} [options] Override http request option.
489
+ * @throws {RequiredError}
490
+ */
491
+ renderResetForm(token, options) {
492
+ return localVarFp.renderResetForm(token, options).then((request) => request(axios, basePath));
493
+ },
494
+ /**
495
+ * Sends a password reset link to the provided email address if an account exists.
496
+ * @summary Request a password reset
497
+ * @param {EmailRequest} emailRequest Email address to send the reset link to
498
+ * @param {*} [options] Override http request option.
499
+ * @throws {RequiredError}
500
+ */
501
+ requestPasswordReset(emailRequest, options) {
502
+ return localVarFp.requestPasswordReset(emailRequest, options).then((request) => request(axios, basePath));
503
+ },
504
+ /**
505
+ * Submits a new password using a valid reset token. Invalidates the token after use.
506
+ * @summary Submit new password
507
+ * @param {ResetPasswordRequest} resetPasswordRequest Reset token and the new password
508
+ * @param {*} [options] Override http request option.
509
+ * @throws {RequiredError}
510
+ */
511
+ submitNewPassword(resetPasswordRequest, options) {
512
+ return localVarFp.submitNewPassword(resetPasswordRequest, options).then((request) => request(axios, basePath));
513
+ }
514
+ };
515
+ };
516
+ var AuthApi = class extends BaseAPI {
517
+ /**
518
+ * Returns the currently authenticated user\'s session data. Requires a valid Bearer token.
519
+ * @summary Get current session
520
+ * @param {*} [options] Override http request option.
521
+ * @throws {RequiredError}
522
+ */
523
+ getSession(options) {
524
+ return AuthApiFp(this.configuration).getSession(options).then((request) => request(this.axios, this.basePath));
525
+ }
526
+ /**
527
+ * Authenticates a user with email and password. **Session strategy**: Returns a session cookie (`id`) managed by the server. **JWT strategy**: Returns `access` and `refresh` in the response body.
528
+ * @summary User login
529
+ * @param {LoginRequest} loginRequest User login credentials
530
+ * @param {*} [options] Override http request option.
531
+ * @throws {RequiredError}
532
+ */
533
+ login(loginRequest, options) {
534
+ return AuthApiFp(this.configuration).login(loginRequest, options).then((request) => request(this.axios, this.basePath));
535
+ }
536
+ /**
537
+ * Invalidates the current session and refresh token. The client should discard stored tokens.
538
+ * @summary Logout
539
+ * @param {RefreshTokenRequest} refreshTokenRequest
540
+ * @param {*} [options] Override http request option.
541
+ * @throws {RequiredError}
542
+ */
543
+ logout(refreshTokenRequest, options) {
544
+ return AuthApiFp(this.configuration).logout(refreshTokenRequest, options).then((request) => request(this.axios, this.basePath));
545
+ }
546
+ /**
547
+ * Issues a new access token using a valid refresh token. Rotate refresh tokens on each call.
548
+ * @summary Refresh access token
549
+ * @param {RefreshTokenRequest} refreshTokenRequest
550
+ * @param {*} [options] Override http request option.
551
+ * @throws {RequiredError}
552
+ */
553
+ refreshToken(refreshTokenRequest, options) {
554
+ return AuthApiFp(this.configuration).refreshToken(refreshTokenRequest, options).then((request) => request(this.axios, this.basePath));
555
+ }
556
+ /**
557
+ * Creates a new user account with email and password. **Session strategy**: Returns a session cookie (`id`) managed by the server. **JWT strategy**: Returns `access` and `refresh` in the response body.
558
+ * @summary Register a new user
559
+ * @param {RegisterRequest} registerRequest User register credentials
560
+ * @param {*} [options] Override http request option.
561
+ * @throws {RequiredError}
562
+ */
563
+ register(registerRequest, options) {
564
+ return AuthApiFp(this.configuration).register(registerRequest, options).then((request) => request(this.axios, this.basePath));
565
+ }
566
+ /**
567
+ * Validates the reset token from the email link and renders the password reset form.
568
+ * @summary Render password reset form
569
+ * @param {TokenQuery} token Password reset token
570
+ * @param {*} [options] Override http request option.
571
+ * @throws {RequiredError}
572
+ */
573
+ renderResetForm(token, options) {
574
+ return AuthApiFp(this.configuration).renderResetForm(token, options).then((request) => request(this.axios, this.basePath));
575
+ }
576
+ /**
577
+ * Sends a password reset link to the provided email address if an account exists.
578
+ * @summary Request a password reset
579
+ * @param {EmailRequest} emailRequest Email address to send the reset link to
580
+ * @param {*} [options] Override http request option.
581
+ * @throws {RequiredError}
582
+ */
583
+ requestPasswordReset(emailRequest, options) {
584
+ return AuthApiFp(this.configuration).requestPasswordReset(emailRequest, options).then((request) => request(this.axios, this.basePath));
585
+ }
586
+ /**
587
+ * Submits a new password using a valid reset token. Invalidates the token after use.
588
+ * @summary Submit new password
589
+ * @param {ResetPasswordRequest} resetPasswordRequest Reset token and the new password
590
+ * @param {*} [options] Override http request option.
591
+ * @throws {RequiredError}
592
+ */
593
+ submitNewPassword(resetPasswordRequest, options) {
594
+ return AuthApiFp(this.configuration).submitNewPassword(resetPasswordRequest, options).then((request) => request(this.axios, this.basePath));
595
+ }
596
+ };
597
+
598
+ // src/generated/api/email-api.ts
599
+ import globalAxios3 from "axios";
600
+ var EmailApiAxiosParamCreator = function(configuration) {
601
+ return {
602
+ /**
603
+ * Validates the email token and update the user account.
604
+ * @summary Verify user email
605
+ * @param {TokenQuery} token Email Verification Token
606
+ * @param {*} [options] Override http request option.
607
+ * @throws {RequiredError}
608
+ */
609
+ verifyEmail: async (token, options = {}) => {
610
+ assertParamExists("verifyEmail", "token", token);
611
+ const localVarPath = `/email`;
612
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
613
+ let baseOptions;
614
+ if (configuration) {
615
+ baseOptions = configuration.baseOptions;
616
+ }
617
+ const localVarRequestOptions = { method: "GET", ...baseOptions, ...options };
618
+ const localVarHeaderParameter = {};
619
+ const localVarQueryParameter = {};
620
+ if (token !== void 0) {
621
+ for (const [key, value] of Object.entries(token)) {
622
+ localVarQueryParameter[key] = value;
623
+ }
624
+ }
625
+ localVarHeaderParameter["Accept"] = "application/json";
626
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
627
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
628
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
629
+ return {
630
+ url: toPathString(localVarUrlObj),
631
+ options: localVarRequestOptions
632
+ };
633
+ }
634
+ };
635
+ };
636
+ var EmailApiFp = function(configuration) {
637
+ const localVarAxiosParamCreator = EmailApiAxiosParamCreator(configuration);
638
+ return {
639
+ /**
640
+ * Validates the email token and update the user account.
641
+ * @summary Verify user email
642
+ * @param {TokenQuery} token Email Verification Token
643
+ * @param {*} [options] Override http request option.
644
+ * @throws {RequiredError}
645
+ */
646
+ async verifyEmail(token, options) {
647
+ const localVarAxiosArgs = await localVarAxiosParamCreator.verifyEmail(token, options);
648
+ const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
649
+ const localVarOperationServerBasePath = operationServerMap["EmailApi.verifyEmail"]?.[localVarOperationServerIndex]?.url;
650
+ return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios3, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
651
+ }
652
+ };
653
+ };
654
+ var EmailApiFactory = function(configuration, basePath, axios) {
655
+ const localVarFp = EmailApiFp(configuration);
656
+ return {
657
+ /**
658
+ * Validates the email token and update the user account.
659
+ * @summary Verify user email
660
+ * @param {TokenQuery} token Email Verification Token
661
+ * @param {*} [options] Override http request option.
662
+ * @throws {RequiredError}
663
+ */
664
+ verifyEmail(token, options) {
665
+ return localVarFp.verifyEmail(token, options).then((request) => request(axios, basePath));
666
+ }
667
+ };
668
+ };
669
+ var EmailApi = class extends BaseAPI {
670
+ /**
671
+ * Validates the email token and update the user account.
672
+ * @summary Verify user email
673
+ * @param {TokenQuery} token Email Verification Token
674
+ * @param {*} [options] Override http request option.
675
+ * @throws {RequiredError}
676
+ */
677
+ verifyEmail(token, options) {
678
+ return EmailApiFp(this.configuration).verifyEmail(token, options).then((request) => request(this.axios, this.basePath));
679
+ }
680
+ };
681
+
682
+ // src/generated/api/users-api.ts
683
+ import globalAxios4 from "axios";
684
+ var UsersApiAxiosParamCreator = function(configuration) {
685
+ return {
686
+ /**
687
+ * Returns the currently authenticated user\'s data. Requires a valid Bearer token.
688
+ * @summary Get current User
689
+ * @param {*} [options] Override http request option.
690
+ * @throws {RequiredError}
691
+ */
692
+ findUser: async (options = {}) => {
693
+ const localVarPath = `/user`;
694
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
695
+ let baseOptions;
696
+ if (configuration) {
697
+ baseOptions = configuration.baseOptions;
698
+ }
699
+ const localVarRequestOptions = { method: "GET", ...baseOptions, ...options };
700
+ const localVarHeaderParameter = {};
701
+ const localVarQueryParameter = {};
702
+ await setBearerAuthToObject(localVarHeaderParameter, configuration);
703
+ localVarHeaderParameter["Accept"] = "application/json";
704
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
705
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
706
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
707
+ return {
708
+ url: toPathString(localVarUrlObj),
709
+ options: localVarRequestOptions
710
+ };
711
+ }
712
+ };
713
+ };
714
+ var UsersApiFp = function(configuration) {
715
+ const localVarAxiosParamCreator = UsersApiAxiosParamCreator(configuration);
716
+ return {
717
+ /**
718
+ * Returns the currently authenticated user\'s data. Requires a valid Bearer token.
719
+ * @summary Get current User
720
+ * @param {*} [options] Override http request option.
721
+ * @throws {RequiredError}
722
+ */
723
+ async findUser(options) {
724
+ const localVarAxiosArgs = await localVarAxiosParamCreator.findUser(options);
725
+ const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
726
+ const localVarOperationServerBasePath = operationServerMap["UsersApi.findUser"]?.[localVarOperationServerIndex]?.url;
727
+ return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios4, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
728
+ }
729
+ };
730
+ };
731
+ var UsersApiFactory = function(configuration, basePath, axios) {
732
+ const localVarFp = UsersApiFp(configuration);
733
+ return {
734
+ /**
735
+ * Returns the currently authenticated user\'s data. Requires a valid Bearer token.
736
+ * @summary Get current User
737
+ * @param {*} [options] Override http request option.
738
+ * @throws {RequiredError}
739
+ */
740
+ findUser(options) {
741
+ return localVarFp.findUser(options).then((request) => request(axios, basePath));
742
+ }
743
+ };
744
+ };
745
+ var UsersApi = class extends BaseAPI {
746
+ /**
747
+ * Returns the currently authenticated user\'s data. Requires a valid Bearer token.
748
+ * @summary Get current User
749
+ * @param {*} [options] Override http request option.
750
+ * @throws {RequiredError}
751
+ */
752
+ findUser(options) {
753
+ return UsersApiFp(this.configuration).findUser(options).then((request) => request(this.axios, this.basePath));
754
+ }
755
+ };
756
+
757
+ // src/generated/configuration.ts
758
+ var Configuration = class {
759
+ /**
760
+ * parameter for apiKey security
761
+ * @param name security name
762
+ */
763
+ apiKey;
764
+ /**
765
+ * parameter for basic security
766
+ */
767
+ username;
768
+ /**
769
+ * parameter for basic security
770
+ */
771
+ password;
772
+ /**
773
+ * parameter for oauth2 security
774
+ * @param name security name
775
+ * @param scopes oauth2 scope
776
+ */
777
+ accessToken;
778
+ /**
779
+ * parameter for aws4 signature security
780
+ * @param {Object} AWS4Signature - AWS4 Signature security
781
+ * @param {string} options.region - aws region
782
+ * @param {string} options.service - name of the service.
783
+ * @param {string} credentials.accessKeyId - aws access key id
784
+ * @param {string} credentials.secretAccessKey - aws access key
785
+ * @param {string} credentials.sessionToken - aws session token
786
+ * @memberof Configuration
787
+ */
788
+ awsv4;
789
+ /**
790
+ * override base path
791
+ */
792
+ basePath;
793
+ /**
794
+ * override server index
795
+ */
796
+ serverIndex;
797
+ /**
798
+ * base options for axios calls
799
+ */
800
+ baseOptions;
801
+ /**
802
+ * The FormData constructor that will be used to create multipart form data
803
+ * requests. You can inject this here so that execution environments that
804
+ * do not support the FormData class can still run the generated client.
805
+ *
806
+ * @type {new () => FormData}
807
+ */
808
+ formDataCtor;
809
+ constructor(param = {}) {
810
+ this.apiKey = param.apiKey;
811
+ this.username = param.username;
812
+ this.password = param.password;
813
+ this.accessToken = param.accessToken;
814
+ this.awsv4 = param.awsv4;
815
+ this.basePath = param.basePath;
816
+ this.serverIndex = param.serverIndex;
817
+ this.baseOptions = {
818
+ ...param.baseOptions,
819
+ headers: {
820
+ ...param.baseOptions?.headers
821
+ }
822
+ };
823
+ this.formDataCtor = param.formDataCtor;
824
+ }
825
+ /**
826
+ * Check if the given MIME is a JSON MIME.
827
+ * JSON MIME examples:
828
+ * application/json
829
+ * application/json; charset=UTF8
830
+ * APPLICATION/JSON
831
+ * application/vnd.company+json
832
+ * @param mime - MIME (Multipurpose Internet Mail Extensions)
833
+ * @return True if the given MIME is JSON, false otherwise.
834
+ */
835
+ isJsonMime(mime) {
836
+ const jsonMime = new RegExp("^(application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(;.*)?$", "i");
837
+ return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === "application/json-patch+json");
838
+ }
839
+ };
840
+
841
+ // src/generated/models/algorithm-config.ts
842
+ var AlgorithmConfig = {
843
+ Hs256: "HS256",
844
+ Hs384: "HS384",
845
+ Hs512: "HS512",
846
+ Es256: "ES256",
847
+ Es384: "ES384",
848
+ Rs256: "RS256",
849
+ Rs384: "RS384",
850
+ Rs512: "RS512",
851
+ Ps256: "PS256",
852
+ Ps384: "PS384",
853
+ Ps512: "PS512",
854
+ EdDsa: "EdDSA"
855
+ };
856
+
857
+ // src/generated/models/auth-strategy.ts
858
+ var AuthStrategy = {
859
+ Session: "Session",
860
+ Jwt: "Jwt"
861
+ };
862
+
863
+ // src/generated/models/cache-driver.ts
864
+ var CacheDriver = {
865
+ MemCached: "MemCached",
866
+ Redis: "Redis"
867
+ };
868
+
869
+ // src/generated/models/database-driver.ts
870
+ var DatabaseDriver = {
871
+ SqLite: "SQLite",
872
+ PostgreSql: "PostgreSQL",
873
+ MongoDb: "MongoDB"
874
+ };
875
+
876
+ // src/generated/models/error-code.ts
877
+ var ErrorCode = {
878
+ InvalidToken: "InvalidToken",
879
+ TokenNotFound: "TokenNotFound",
880
+ TokenExpired: "TokenExpired",
881
+ TokenAlreadyUsed: "TokenAlreadyUsed",
882
+ TokenCreationFailed: "TokenCreationFailed",
883
+ TokenRevocationFailed: "TokenRevocationFailed",
884
+ AccountNotVerified: "AccountNotVerified",
885
+ InvalidCredentials: "InvalidCredentials",
886
+ MissingCredentials: "MissingCredentials",
887
+ AccountSuspended: "AccountSuspended",
888
+ UserNotFound: "UserNotFound",
889
+ RateLimitExceeded: "RateLimitExceeded",
890
+ EmailSendFailed: "EmailSendFailed",
891
+ TlsConfig: "TlsConfig",
892
+ HashingFailure: "HashingFailure",
893
+ MalformedData: "MalformedData",
894
+ DatabaseError: "DatabaseError",
895
+ InvalidRequest: "InvalidRequest",
896
+ UnsupportedMediaType: "UnsupportedMediaType",
897
+ BadRequest: "BadRequest",
898
+ InternalServerError: "InternalServerError"
899
+ };
900
+
901
+ // src/generated/models/role.ts
902
+ var Role = {
903
+ User: "User",
904
+ Admin: "Admin"
905
+ };
906
+
907
+ // src/generated/models/same-site-config.ts
908
+ var SameSiteConfig = {
909
+ Strict: "Strict",
910
+ Lax: "Lax",
911
+ None: "None"
912
+ };
913
+ export {
914
+ AlgorithmConfig,
915
+ AuthApi,
916
+ AuthApiAxiosParamCreator,
917
+ AuthApiFactory,
918
+ AuthApiFp,
919
+ AuthStrategy,
920
+ CacheDriver,
921
+ Configuration,
922
+ DatabaseDriver,
923
+ EmailApi,
924
+ EmailApiAxiosParamCreator,
925
+ EmailApiFactory,
926
+ EmailApiFp,
927
+ ErrorCode,
928
+ Role,
929
+ SameSiteConfig,
930
+ UsersApi,
931
+ UsersApiAxiosParamCreator,
932
+ UsersApiFactory,
933
+ UsersApiFp
934
+ };