@anzar-auth/core 1.5.11 → 1.7.3

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