anzar 1.1.12 → 1.2.5
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 +723 -219
- package/dist/index.d.cts +328 -59
- package/dist/index.d.ts +328 -59
- package/dist/index.js +723 -219
- package/package.json +2 -1
package/dist/index.cjs
CHANGED
|
@@ -33,174 +33,732 @@ __export(index_exports, {
|
|
|
33
33
|
Anzar: () => Anzar
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(index_exports);
|
|
36
|
+
var import_axios5 = __toESM(require("axios"), 1);
|
|
37
|
+
|
|
38
|
+
// src/generated/api/auth-api.ts
|
|
39
|
+
var import_axios2 = __toESM(require("axios"), 1);
|
|
40
|
+
|
|
41
|
+
// src/generated/base.ts
|
|
36
42
|
var import_axios = __toESM(require("axios"), 1);
|
|
43
|
+
var BASE_PATH = "http://localhost".replace(/\/+$/, "");
|
|
44
|
+
var BaseAPI = class {
|
|
45
|
+
constructor(configuration, basePath = BASE_PATH, axios2 = import_axios.default) {
|
|
46
|
+
this.basePath = basePath;
|
|
47
|
+
this.axios = axios2;
|
|
48
|
+
if (configuration) {
|
|
49
|
+
this.configuration = configuration;
|
|
50
|
+
this.basePath = configuration.basePath ?? basePath;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
configuration;
|
|
54
|
+
};
|
|
55
|
+
var RequiredError = class extends Error {
|
|
56
|
+
constructor(field, msg) {
|
|
57
|
+
super(msg);
|
|
58
|
+
this.field = field;
|
|
59
|
+
this.name = "RequiredError";
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
var operationServerMap = {};
|
|
37
63
|
|
|
38
|
-
// src/
|
|
39
|
-
var
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
this.httpClient = httpClient;
|
|
44
|
-
this.config = config;
|
|
64
|
+
// src/generated/common.ts
|
|
65
|
+
var DUMMY_BASE_URL = "https://example.com";
|
|
66
|
+
var assertParamExists = function(functionName, paramName, paramValue) {
|
|
67
|
+
if (paramValue === null || paramValue === void 0) {
|
|
68
|
+
throw new RequiredError(paramName, `Required parameter ${paramName} was null or undefined when calling ${functionName}.`);
|
|
45
69
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
70
|
+
};
|
|
71
|
+
var setBearerAuthToObject = async function(object, configuration) {
|
|
72
|
+
if (configuration && configuration.accessToken) {
|
|
73
|
+
const accessToken = typeof configuration.accessToken === "function" ? await configuration.accessToken() : await configuration.accessToken;
|
|
74
|
+
object["Authorization"] = "Bearer " + accessToken;
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
function setFlattenedQueryParams(urlSearchParams, parameter, key = "") {
|
|
78
|
+
if (parameter == null) return;
|
|
79
|
+
if (typeof parameter === "object") {
|
|
80
|
+
if (Array.isArray(parameter) || parameter instanceof Set) {
|
|
81
|
+
parameter.forEach((item) => setFlattenedQueryParams(urlSearchParams, item, key));
|
|
82
|
+
} else {
|
|
83
|
+
Object.keys(parameter).forEach(
|
|
84
|
+
(currentKey) => setFlattenedQueryParams(urlSearchParams, parameter[currentKey], `${key}${key !== "" ? "." : ""}${currentKey}`)
|
|
54
85
|
);
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
86
|
+
}
|
|
87
|
+
} else {
|
|
88
|
+
if (urlSearchParams.has(key)) {
|
|
89
|
+
urlSearchParams.append(key, parameter);
|
|
90
|
+
} else {
|
|
91
|
+
urlSearchParams.set(key, parameter);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
var setSearchParams = function(url, ...objects) {
|
|
96
|
+
const searchParams = new URLSearchParams(url.search);
|
|
97
|
+
setFlattenedQueryParams(searchParams, objects);
|
|
98
|
+
url.search = searchParams.toString();
|
|
99
|
+
};
|
|
100
|
+
var replaceWithSerializableTypeIfNeeded = function(key, value) {
|
|
101
|
+
if (value instanceof Set) {
|
|
102
|
+
return Array.from(value);
|
|
103
|
+
} else {
|
|
104
|
+
return value;
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
var serializeDataIfNeeded = function(value, requestOptions, configuration) {
|
|
108
|
+
const nonString = typeof value !== "string";
|
|
109
|
+
const needsSerialization = nonString && configuration && configuration.isJsonMime ? configuration.isJsonMime(requestOptions.headers["Content-Type"]) : nonString;
|
|
110
|
+
return needsSerialization ? JSON.stringify(value !== void 0 ? value : {}, replaceWithSerializableTypeIfNeeded) : value || "";
|
|
111
|
+
};
|
|
112
|
+
var toPathString = function(url) {
|
|
113
|
+
return url.pathname + url.search + url.hash;
|
|
114
|
+
};
|
|
115
|
+
var createRequestFunction = function(axiosArgs, globalAxios5, BASE_PATH2, configuration) {
|
|
116
|
+
return (axios2 = globalAxios5, basePath = BASE_PATH2) => {
|
|
117
|
+
const axiosRequestArgs = { ...axiosArgs.options, url: (axios2.defaults.baseURL ? "" : configuration?.basePath ?? basePath) + axiosArgs.url };
|
|
118
|
+
return axios2.request(axiosRequestArgs);
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
// src/generated/api/auth-api.ts
|
|
123
|
+
var AuthApiAxiosParamCreator = function(configuration) {
|
|
124
|
+
return {
|
|
125
|
+
/**
|
|
126
|
+
* Returns the currently authenticated user\'s session data. Requires a valid Bearer token.
|
|
127
|
+
* @summary Get current session
|
|
128
|
+
* @param {*} [options] Override http request option.
|
|
129
|
+
* @throws {RequiredError}
|
|
130
|
+
*/
|
|
131
|
+
getSession: async (options = {}) => {
|
|
132
|
+
const localVarPath = `/auth/session`;
|
|
133
|
+
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
|
|
134
|
+
let baseOptions;
|
|
135
|
+
if (configuration) {
|
|
136
|
+
baseOptions = configuration.baseOptions;
|
|
60
137
|
}
|
|
61
|
-
|
|
138
|
+
const localVarRequestOptions = { method: "GET", ...baseOptions, ...options };
|
|
139
|
+
const localVarHeaderParameter = {};
|
|
140
|
+
const localVarQueryParameter = {};
|
|
141
|
+
await setBearerAuthToObject(localVarHeaderParameter, configuration);
|
|
142
|
+
localVarHeaderParameter["Accept"] = "application/json";
|
|
143
|
+
setSearchParams(localVarUrlObj, localVarQueryParameter);
|
|
144
|
+
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
|
145
|
+
localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
|
|
146
|
+
return {
|
|
147
|
+
url: toPathString(localVarUrlObj),
|
|
148
|
+
options: localVarRequestOptions
|
|
149
|
+
};
|
|
62
150
|
},
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
151
|
+
/**
|
|
152
|
+
* Authenticates a user with email and password. Returns an access token and refresh token on success.
|
|
153
|
+
* @summary User login
|
|
154
|
+
* @param {LoginRequest} loginRequest User login credentials
|
|
155
|
+
* @param {*} [options] Override http request option.
|
|
156
|
+
* @throws {RequiredError}
|
|
157
|
+
*/
|
|
158
|
+
login: async (loginRequest, options = {}) => {
|
|
159
|
+
assertParamExists("login", "loginRequest", loginRequest);
|
|
160
|
+
const localVarPath = `/auth/login`;
|
|
161
|
+
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
|
|
162
|
+
let baseOptions;
|
|
163
|
+
if (configuration) {
|
|
164
|
+
baseOptions = configuration.baseOptions;
|
|
72
165
|
}
|
|
73
|
-
|
|
166
|
+
const localVarRequestOptions = { method: "POST", ...baseOptions, ...options };
|
|
167
|
+
const localVarHeaderParameter = {};
|
|
168
|
+
const localVarQueryParameter = {};
|
|
169
|
+
localVarHeaderParameter["Content-Type"] = "application/json";
|
|
170
|
+
localVarHeaderParameter["Accept"] = "application/json";
|
|
171
|
+
setSearchParams(localVarUrlObj, localVarQueryParameter);
|
|
172
|
+
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
|
173
|
+
localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
|
|
174
|
+
localVarRequestOptions.data = serializeDataIfNeeded(loginRequest, localVarRequestOptions, configuration);
|
|
175
|
+
return {
|
|
176
|
+
url: toPathString(localVarUrlObj),
|
|
177
|
+
options: localVarRequestOptions
|
|
178
|
+
};
|
|
74
179
|
},
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
180
|
+
/**
|
|
181
|
+
* Invalidates the current session and refresh token. The client should discard stored tokens.
|
|
182
|
+
* @summary Logout
|
|
183
|
+
* @param {*} [options] Override http request option.
|
|
184
|
+
* @throws {RequiredError}
|
|
185
|
+
*/
|
|
186
|
+
logout: async (options = {}) => {
|
|
187
|
+
const localVarPath = `/auth/logout`;
|
|
188
|
+
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
|
|
189
|
+
let baseOptions;
|
|
190
|
+
if (configuration) {
|
|
191
|
+
baseOptions = configuration.baseOptions;
|
|
83
192
|
}
|
|
84
|
-
|
|
193
|
+
const localVarRequestOptions = { method: "POST", ...baseOptions, ...options };
|
|
194
|
+
const localVarHeaderParameter = {};
|
|
195
|
+
const localVarQueryParameter = {};
|
|
196
|
+
await setBearerAuthToObject(localVarHeaderParameter, configuration);
|
|
197
|
+
localVarHeaderParameter["Accept"] = "application/json";
|
|
198
|
+
setSearchParams(localVarUrlObj, localVarQueryParameter);
|
|
199
|
+
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
|
200
|
+
localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
|
|
201
|
+
return {
|
|
202
|
+
url: toPathString(localVarUrlObj),
|
|
203
|
+
options: localVarRequestOptions
|
|
204
|
+
};
|
|
85
205
|
},
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
206
|
+
/**
|
|
207
|
+
* Issues a new access token using a valid refresh token. Rotate refresh tokens on each call.
|
|
208
|
+
* @summary Refresh access token
|
|
209
|
+
* @param {*} [options] Override http request option.
|
|
210
|
+
* @throws {RequiredError}
|
|
211
|
+
*/
|
|
212
|
+
refreshToken: async (options = {}) => {
|
|
213
|
+
const localVarPath = `/auth/refresh-token`;
|
|
214
|
+
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
|
|
215
|
+
let baseOptions;
|
|
216
|
+
if (configuration) {
|
|
217
|
+
baseOptions = configuration.baseOptions;
|
|
94
218
|
}
|
|
95
|
-
const
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
|
|
219
|
+
const localVarRequestOptions = { method: "POST", ...baseOptions, ...options };
|
|
220
|
+
const localVarHeaderParameter = {};
|
|
221
|
+
const localVarQueryParameter = {};
|
|
222
|
+
await setBearerAuthToObject(localVarHeaderParameter, configuration);
|
|
223
|
+
localVarHeaderParameter["Accept"] = "application/json";
|
|
224
|
+
setSearchParams(localVarUrlObj, localVarQueryParameter);
|
|
225
|
+
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
|
226
|
+
localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
|
|
227
|
+
return {
|
|
228
|
+
url: toPathString(localVarUrlObj),
|
|
229
|
+
options: localVarRequestOptions
|
|
230
|
+
};
|
|
231
|
+
},
|
|
232
|
+
/**
|
|
233
|
+
* Creates a new user account. Sends a verification email upon successful registration.
|
|
234
|
+
* @summary Register a new user
|
|
235
|
+
* @param {RegisterRequest} registerRequest User register credentials
|
|
236
|
+
* @param {*} [options] Override http request option.
|
|
237
|
+
* @throws {RequiredError}
|
|
238
|
+
*/
|
|
239
|
+
register: async (registerRequest, options = {}) => {
|
|
240
|
+
assertParamExists("register", "registerRequest", registerRequest);
|
|
241
|
+
const localVarPath = `/auth/register`;
|
|
242
|
+
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
|
|
243
|
+
let baseOptions;
|
|
244
|
+
if (configuration) {
|
|
245
|
+
baseOptions = configuration.baseOptions;
|
|
99
246
|
}
|
|
247
|
+
const localVarRequestOptions = { method: "POST", ...baseOptions, ...options };
|
|
248
|
+
const localVarHeaderParameter = {};
|
|
249
|
+
const localVarQueryParameter = {};
|
|
250
|
+
localVarHeaderParameter["Content-Type"] = "application/json";
|
|
251
|
+
localVarHeaderParameter["Accept"] = "application/json";
|
|
252
|
+
setSearchParams(localVarUrlObj, localVarQueryParameter);
|
|
253
|
+
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
|
254
|
+
localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
|
|
255
|
+
localVarRequestOptions.data = serializeDataIfNeeded(registerRequest, localVarRequestOptions, configuration);
|
|
100
256
|
return {
|
|
101
|
-
|
|
102
|
-
|
|
257
|
+
url: toPathString(localVarUrlObj),
|
|
258
|
+
options: localVarRequestOptions
|
|
103
259
|
};
|
|
104
260
|
},
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
261
|
+
/**
|
|
262
|
+
* Validates the reset token from the email link and renders the password reset form.
|
|
263
|
+
* @summary Render password reset form
|
|
264
|
+
* @param {TokenQuery} token Password reset token
|
|
265
|
+
* @param {*} [options] Override http request option.
|
|
266
|
+
* @throws {RequiredError}
|
|
267
|
+
*/
|
|
268
|
+
renderResetForm: async (token, options = {}) => {
|
|
269
|
+
assertParamExists("renderResetForm", "token", token);
|
|
270
|
+
const localVarPath = `/auth/password/reset`;
|
|
271
|
+
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
|
|
272
|
+
let baseOptions;
|
|
273
|
+
if (configuration) {
|
|
274
|
+
baseOptions = configuration.baseOptions;
|
|
108
275
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
276
|
+
const localVarRequestOptions = { method: "GET", ...baseOptions, ...options };
|
|
277
|
+
const localVarHeaderParameter = {};
|
|
278
|
+
const localVarQueryParameter = {};
|
|
279
|
+
if (token !== void 0) {
|
|
280
|
+
for (const [key, value] of Object.entries(token)) {
|
|
281
|
+
localVarQueryParameter[key] = value;
|
|
282
|
+
}
|
|
116
283
|
}
|
|
284
|
+
localVarHeaderParameter["Accept"] = "text/html,application/json";
|
|
285
|
+
setSearchParams(localVarUrlObj, localVarQueryParameter);
|
|
286
|
+
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
|
287
|
+
localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
|
|
288
|
+
return {
|
|
289
|
+
url: toPathString(localVarUrlObj),
|
|
290
|
+
options: localVarRequestOptions
|
|
291
|
+
};
|
|
117
292
|
},
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
293
|
+
/**
|
|
294
|
+
* Sends a password reset link to the provided email address if an account exists.
|
|
295
|
+
* @summary Request a password reset
|
|
296
|
+
* @param {EmailRequest} emailRequest Email address to send the reset link to
|
|
297
|
+
* @param {*} [options] Override http request option.
|
|
298
|
+
* @throws {RequiredError}
|
|
299
|
+
*/
|
|
300
|
+
requestPasswordReset: async (emailRequest, options = {}) => {
|
|
301
|
+
assertParamExists("requestPasswordReset", "emailRequest", emailRequest);
|
|
302
|
+
const localVarPath = `/auth/password/forgot`;
|
|
303
|
+
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
|
|
304
|
+
let baseOptions;
|
|
305
|
+
if (configuration) {
|
|
306
|
+
baseOptions = configuration.baseOptions;
|
|
126
307
|
}
|
|
127
|
-
|
|
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(emailRequest, localVarRequestOptions, configuration);
|
|
317
|
+
return {
|
|
318
|
+
url: toPathString(localVarUrlObj),
|
|
319
|
+
options: localVarRequestOptions
|
|
320
|
+
};
|
|
321
|
+
},
|
|
322
|
+
/**
|
|
323
|
+
* Submits a new password using a valid reset token. Invalidates the token after use.
|
|
324
|
+
* @summary Submit new password
|
|
325
|
+
* @param {ResetPasswordRequest} resetPasswordRequest Reset token and the new password
|
|
326
|
+
* @param {*} [options] Override http request option.
|
|
327
|
+
* @throws {RequiredError}
|
|
328
|
+
*/
|
|
329
|
+
submitNewPassword: async (resetPasswordRequest, options = {}) => {
|
|
330
|
+
assertParamExists("submitNewPassword", "resetPasswordRequest", resetPasswordRequest);
|
|
331
|
+
const localVarPath = `/auth/password/reset`;
|
|
332
|
+
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
|
|
333
|
+
let baseOptions;
|
|
334
|
+
if (configuration) {
|
|
335
|
+
baseOptions = configuration.baseOptions;
|
|
336
|
+
}
|
|
337
|
+
const localVarRequestOptions = { method: "POST", ...baseOptions, ...options };
|
|
338
|
+
const localVarHeaderParameter = {};
|
|
339
|
+
const localVarQueryParameter = {};
|
|
340
|
+
localVarHeaderParameter["Content-Type"] = "application/json";
|
|
341
|
+
localVarHeaderParameter["Accept"] = "application/json";
|
|
342
|
+
setSearchParams(localVarUrlObj, localVarQueryParameter);
|
|
343
|
+
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
|
344
|
+
localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
|
|
345
|
+
localVarRequestOptions.data = serializeDataIfNeeded(resetPasswordRequest, localVarRequestOptions, configuration);
|
|
346
|
+
return {
|
|
347
|
+
url: toPathString(localVarUrlObj),
|
|
348
|
+
options: localVarRequestOptions
|
|
349
|
+
};
|
|
128
350
|
}
|
|
129
351
|
};
|
|
130
|
-
// User methods
|
|
131
|
-
// user: {
|
|
132
|
-
// getProfile();
|
|
133
|
-
// updateProfile();
|
|
134
|
-
// // ...
|
|
135
|
-
// };
|
|
136
352
|
};
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
353
|
+
var AuthApiFp = function(configuration) {
|
|
354
|
+
const localVarAxiosParamCreator = AuthApiAxiosParamCreator(configuration);
|
|
355
|
+
return {
|
|
356
|
+
/**
|
|
357
|
+
* Returns the currently authenticated user\'s session data. Requires a valid Bearer token.
|
|
358
|
+
* @summary Get current session
|
|
359
|
+
* @param {*} [options] Override http request option.
|
|
360
|
+
* @throws {RequiredError}
|
|
361
|
+
*/
|
|
362
|
+
async getSession(options) {
|
|
363
|
+
const localVarAxiosArgs = await localVarAxiosParamCreator.getSession(options);
|
|
364
|
+
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
|
|
365
|
+
const localVarOperationServerBasePath = operationServerMap["AuthApi.getSession"]?.[localVarOperationServerIndex]?.url;
|
|
366
|
+
return (axios2, basePath) => createRequestFunction(localVarAxiosArgs, import_axios2.default, BASE_PATH, configuration)(axios2, localVarOperationServerBasePath || basePath);
|
|
367
|
+
},
|
|
368
|
+
/**
|
|
369
|
+
* Authenticates a user with email and password. Returns an access token and refresh token on success.
|
|
370
|
+
* @summary User login
|
|
371
|
+
* @param {LoginRequest} loginRequest User login credentials
|
|
372
|
+
* @param {*} [options] Override http request option.
|
|
373
|
+
* @throws {RequiredError}
|
|
374
|
+
*/
|
|
375
|
+
async login(loginRequest, options) {
|
|
376
|
+
const localVarAxiosArgs = await localVarAxiosParamCreator.login(loginRequest, options);
|
|
377
|
+
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
|
|
378
|
+
const localVarOperationServerBasePath = operationServerMap["AuthApi.login"]?.[localVarOperationServerIndex]?.url;
|
|
379
|
+
return (axios2, basePath) => createRequestFunction(localVarAxiosArgs, import_axios2.default, BASE_PATH, configuration)(axios2, localVarOperationServerBasePath || basePath);
|
|
380
|
+
},
|
|
381
|
+
/**
|
|
382
|
+
* Invalidates the current session and refresh token. The client should discard stored tokens.
|
|
383
|
+
* @summary Logout
|
|
384
|
+
* @param {*} [options] Override http request option.
|
|
385
|
+
* @throws {RequiredError}
|
|
386
|
+
*/
|
|
387
|
+
async logout(options) {
|
|
388
|
+
const localVarAxiosArgs = await localVarAxiosParamCreator.logout(options);
|
|
389
|
+
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
|
|
390
|
+
const localVarOperationServerBasePath = operationServerMap["AuthApi.logout"]?.[localVarOperationServerIndex]?.url;
|
|
391
|
+
return (axios2, basePath) => createRequestFunction(localVarAxiosArgs, import_axios2.default, BASE_PATH, configuration)(axios2, localVarOperationServerBasePath || basePath);
|
|
392
|
+
},
|
|
393
|
+
/**
|
|
394
|
+
* Issues a new access token using a valid refresh token. Rotate refresh tokens on each call.
|
|
395
|
+
* @summary Refresh access token
|
|
396
|
+
* @param {*} [options] Override http request option.
|
|
397
|
+
* @throws {RequiredError}
|
|
398
|
+
*/
|
|
399
|
+
async refreshToken(options) {
|
|
400
|
+
const localVarAxiosArgs = await localVarAxiosParamCreator.refreshToken(options);
|
|
401
|
+
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
|
|
402
|
+
const localVarOperationServerBasePath = operationServerMap["AuthApi.refreshToken"]?.[localVarOperationServerIndex]?.url;
|
|
403
|
+
return (axios2, basePath) => createRequestFunction(localVarAxiosArgs, import_axios2.default, BASE_PATH, configuration)(axios2, localVarOperationServerBasePath || basePath);
|
|
404
|
+
},
|
|
405
|
+
/**
|
|
406
|
+
* Creates a new user account. Sends a verification email upon successful registration.
|
|
407
|
+
* @summary Register a new user
|
|
408
|
+
* @param {RegisterRequest} registerRequest User register credentials
|
|
409
|
+
* @param {*} [options] Override http request option.
|
|
410
|
+
* @throws {RequiredError}
|
|
411
|
+
*/
|
|
412
|
+
async register(registerRequest, options) {
|
|
413
|
+
const localVarAxiosArgs = await localVarAxiosParamCreator.register(registerRequest, options);
|
|
414
|
+
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
|
|
415
|
+
const localVarOperationServerBasePath = operationServerMap["AuthApi.register"]?.[localVarOperationServerIndex]?.url;
|
|
416
|
+
return (axios2, basePath) => createRequestFunction(localVarAxiosArgs, import_axios2.default, BASE_PATH, configuration)(axios2, localVarOperationServerBasePath || basePath);
|
|
417
|
+
},
|
|
418
|
+
/**
|
|
419
|
+
* Validates the reset token from the email link and renders the password reset form.
|
|
420
|
+
* @summary Render password reset form
|
|
421
|
+
* @param {TokenQuery} token Password reset token
|
|
422
|
+
* @param {*} [options] Override http request option.
|
|
423
|
+
* @throws {RequiredError}
|
|
424
|
+
*/
|
|
425
|
+
async renderResetForm(token, options) {
|
|
426
|
+
const localVarAxiosArgs = await localVarAxiosParamCreator.renderResetForm(token, options);
|
|
427
|
+
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
|
|
428
|
+
const localVarOperationServerBasePath = operationServerMap["AuthApi.renderResetForm"]?.[localVarOperationServerIndex]?.url;
|
|
429
|
+
return (axios2, basePath) => createRequestFunction(localVarAxiosArgs, import_axios2.default, BASE_PATH, configuration)(axios2, localVarOperationServerBasePath || basePath);
|
|
430
|
+
},
|
|
431
|
+
/**
|
|
432
|
+
* Sends a password reset link to the provided email address if an account exists.
|
|
433
|
+
* @summary Request a password reset
|
|
434
|
+
* @param {EmailRequest} emailRequest Email address to send the reset link to
|
|
435
|
+
* @param {*} [options] Override http request option.
|
|
436
|
+
* @throws {RequiredError}
|
|
437
|
+
*/
|
|
438
|
+
async requestPasswordReset(emailRequest, options) {
|
|
439
|
+
const localVarAxiosArgs = await localVarAxiosParamCreator.requestPasswordReset(emailRequest, options);
|
|
440
|
+
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
|
|
441
|
+
const localVarOperationServerBasePath = operationServerMap["AuthApi.requestPasswordReset"]?.[localVarOperationServerIndex]?.url;
|
|
442
|
+
return (axios2, basePath) => createRequestFunction(localVarAxiosArgs, import_axios2.default, BASE_PATH, configuration)(axios2, localVarOperationServerBasePath || basePath);
|
|
443
|
+
},
|
|
444
|
+
/**
|
|
445
|
+
* Submits a new password using a valid reset token. Invalidates the token after use.
|
|
446
|
+
* @summary Submit new password
|
|
447
|
+
* @param {ResetPasswordRequest} resetPasswordRequest Reset token and the new password
|
|
448
|
+
* @param {*} [options] Override http request option.
|
|
449
|
+
* @throws {RequiredError}
|
|
450
|
+
*/
|
|
451
|
+
async submitNewPassword(resetPasswordRequest, options) {
|
|
452
|
+
const localVarAxiosArgs = await localVarAxiosParamCreator.submitNewPassword(resetPasswordRequest, options);
|
|
453
|
+
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
|
|
454
|
+
const localVarOperationServerBasePath = operationServerMap["AuthApi.submitNewPassword"]?.[localVarOperationServerIndex]?.url;
|
|
455
|
+
return (axios2, basePath) => createRequestFunction(localVarAxiosArgs, import_axios2.default, BASE_PATH, configuration)(axios2, localVarOperationServerBasePath || basePath);
|
|
456
|
+
}
|
|
457
|
+
};
|
|
141
458
|
};
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
459
|
+
var AuthApi = class extends BaseAPI {
|
|
460
|
+
/**
|
|
461
|
+
* Returns the currently authenticated user\'s session data. Requires a valid Bearer token.
|
|
462
|
+
* @summary Get current session
|
|
463
|
+
* @param {*} [options] Override http request option.
|
|
464
|
+
* @throws {RequiredError}
|
|
465
|
+
*/
|
|
466
|
+
getSession(options) {
|
|
467
|
+
return AuthApiFp(this.configuration).getSession(options).then((request) => request(this.axios, this.basePath));
|
|
468
|
+
}
|
|
469
|
+
/**
|
|
470
|
+
* Authenticates a user with email and password. Returns an access token and refresh token on success.
|
|
471
|
+
* @summary User login
|
|
472
|
+
* @param {LoginRequest} loginRequest User login credentials
|
|
473
|
+
* @param {*} [options] Override http request option.
|
|
474
|
+
* @throws {RequiredError}
|
|
475
|
+
*/
|
|
476
|
+
login(loginRequest, options) {
|
|
477
|
+
return AuthApiFp(this.configuration).login(loginRequest, options).then((request) => request(this.axios, this.basePath));
|
|
478
|
+
}
|
|
479
|
+
/**
|
|
480
|
+
* Invalidates the current session and refresh token. The client should discard stored tokens.
|
|
481
|
+
* @summary Logout
|
|
482
|
+
* @param {*} [options] Override http request option.
|
|
483
|
+
* @throws {RequiredError}
|
|
484
|
+
*/
|
|
485
|
+
logout(options) {
|
|
486
|
+
return AuthApiFp(this.configuration).logout(options).then((request) => request(this.axios, this.basePath));
|
|
148
487
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
488
|
+
/**
|
|
489
|
+
* Issues a new access token using a valid refresh token. Rotate refresh tokens on each call.
|
|
490
|
+
* @summary Refresh access token
|
|
491
|
+
* @param {*} [options] Override http request option.
|
|
492
|
+
* @throws {RequiredError}
|
|
493
|
+
*/
|
|
494
|
+
refreshToken(options) {
|
|
495
|
+
return AuthApiFp(this.configuration).refreshToken(options).then((request) => request(this.axios, this.basePath));
|
|
496
|
+
}
|
|
497
|
+
/**
|
|
498
|
+
* Creates a new user account. Sends a verification email upon successful registration.
|
|
499
|
+
* @summary Register a new user
|
|
500
|
+
* @param {RegisterRequest} registerRequest User register credentials
|
|
501
|
+
* @param {*} [options] Override http request option.
|
|
502
|
+
* @throws {RequiredError}
|
|
503
|
+
*/
|
|
504
|
+
register(registerRequest, options) {
|
|
505
|
+
return AuthApiFp(this.configuration).register(registerRequest, options).then((request) => request(this.axios, this.basePath));
|
|
506
|
+
}
|
|
507
|
+
/**
|
|
508
|
+
* Validates the reset token from the email link and renders the password reset form.
|
|
509
|
+
* @summary Render password reset form
|
|
510
|
+
* @param {TokenQuery} token Password reset token
|
|
511
|
+
* @param {*} [options] Override http request option.
|
|
512
|
+
* @throws {RequiredError}
|
|
513
|
+
*/
|
|
514
|
+
renderResetForm(token, options) {
|
|
515
|
+
return AuthApiFp(this.configuration).renderResetForm(token, options).then((request) => request(this.axios, this.basePath));
|
|
516
|
+
}
|
|
517
|
+
/**
|
|
518
|
+
* Sends a password reset link to the provided email address if an account exists.
|
|
519
|
+
* @summary Request a password reset
|
|
520
|
+
* @param {EmailRequest} emailRequest Email address to send the reset link to
|
|
521
|
+
* @param {*} [options] Override http request option.
|
|
522
|
+
* @throws {RequiredError}
|
|
523
|
+
*/
|
|
524
|
+
requestPasswordReset(emailRequest, options) {
|
|
525
|
+
return AuthApiFp(this.configuration).requestPasswordReset(emailRequest, options).then((request) => request(this.axios, this.basePath));
|
|
526
|
+
}
|
|
527
|
+
/**
|
|
528
|
+
* Submits a new password using a valid reset token. Invalidates the token after use.
|
|
529
|
+
* @summary Submit new password
|
|
530
|
+
* @param {ResetPasswordRequest} resetPasswordRequest Reset token and the new password
|
|
531
|
+
* @param {*} [options] Override http request option.
|
|
532
|
+
* @throws {RequiredError}
|
|
533
|
+
*/
|
|
534
|
+
submitNewPassword(resetPasswordRequest, options) {
|
|
535
|
+
return AuthApiFp(this.configuration).submitNewPassword(resetPasswordRequest, options).then((request) => request(this.axios, this.basePath));
|
|
536
|
+
}
|
|
537
|
+
};
|
|
538
|
+
|
|
539
|
+
// src/generated/api/email-api.ts
|
|
540
|
+
var import_axios3 = __toESM(require("axios"), 1);
|
|
541
|
+
var EmailApiAxiosParamCreator = function(configuration) {
|
|
542
|
+
return {
|
|
543
|
+
/**
|
|
544
|
+
* Validates the email token and update the user account.
|
|
545
|
+
* @summary Verify user email
|
|
546
|
+
* @param {TokenQuery} token Email Verification Token
|
|
547
|
+
* @param {*} [options] Override http request option.
|
|
548
|
+
* @throws {RequiredError}
|
|
549
|
+
*/
|
|
550
|
+
verifyEmail: async (token, options = {}) => {
|
|
551
|
+
assertParamExists("verifyEmail", "token", token);
|
|
552
|
+
const localVarPath = `/email`;
|
|
553
|
+
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
|
|
554
|
+
let baseOptions;
|
|
555
|
+
if (configuration) {
|
|
556
|
+
baseOptions = configuration.baseOptions;
|
|
154
557
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
558
|
+
const localVarRequestOptions = { method: "GET", ...baseOptions, ...options };
|
|
559
|
+
const localVarHeaderParameter = {};
|
|
560
|
+
const localVarQueryParameter = {};
|
|
561
|
+
if (token !== void 0) {
|
|
562
|
+
for (const [key, value] of Object.entries(token)) {
|
|
563
|
+
localVarQueryParameter[key] = value;
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
localVarHeaderParameter["Accept"] = "application/json";
|
|
567
|
+
setSearchParams(localVarUrlObj, localVarQueryParameter);
|
|
568
|
+
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
|
569
|
+
localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
|
|
570
|
+
return {
|
|
571
|
+
url: toPathString(localVarUrlObj),
|
|
572
|
+
options: localVarRequestOptions
|
|
573
|
+
};
|
|
159
574
|
}
|
|
575
|
+
};
|
|
576
|
+
};
|
|
577
|
+
var EmailApiFp = function(configuration) {
|
|
578
|
+
const localVarAxiosParamCreator = EmailApiAxiosParamCreator(configuration);
|
|
579
|
+
return {
|
|
580
|
+
/**
|
|
581
|
+
* Validates the email token and update the user account.
|
|
582
|
+
* @summary Verify user email
|
|
583
|
+
* @param {TokenQuery} token Email Verification Token
|
|
584
|
+
* @param {*} [options] Override http request option.
|
|
585
|
+
* @throws {RequiredError}
|
|
586
|
+
*/
|
|
587
|
+
async verifyEmail(token, options) {
|
|
588
|
+
const localVarAxiosArgs = await localVarAxiosParamCreator.verifyEmail(token, options);
|
|
589
|
+
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
|
|
590
|
+
const localVarOperationServerBasePath = operationServerMap["EmailApi.verifyEmail"]?.[localVarOperationServerIndex]?.url;
|
|
591
|
+
return (axios2, basePath) => createRequestFunction(localVarAxiosArgs, import_axios3.default, BASE_PATH, configuration)(axios2, localVarOperationServerBasePath || basePath);
|
|
592
|
+
}
|
|
593
|
+
};
|
|
594
|
+
};
|
|
595
|
+
var EmailApi = class extends BaseAPI {
|
|
596
|
+
/**
|
|
597
|
+
* Validates the email token and update the user account.
|
|
598
|
+
* @summary Verify user email
|
|
599
|
+
* @param {TokenQuery} token Email Verification Token
|
|
600
|
+
* @param {*} [options] Override http request option.
|
|
601
|
+
* @throws {RequiredError}
|
|
602
|
+
*/
|
|
603
|
+
verifyEmail(token, options) {
|
|
604
|
+
return EmailApiFp(this.configuration).verifyEmail(token, options).then((request) => request(this.axios, this.basePath));
|
|
160
605
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
606
|
+
};
|
|
607
|
+
|
|
608
|
+
// src/generated/api/users-api.ts
|
|
609
|
+
var import_axios4 = __toESM(require("axios"), 1);
|
|
610
|
+
var UsersApiAxiosParamCreator = function(configuration) {
|
|
611
|
+
return {
|
|
612
|
+
/**
|
|
613
|
+
* Returns the currently authenticated user\'s data. Requires a valid Bearer token.
|
|
614
|
+
* @summary Get current User
|
|
615
|
+
* @param {*} [options] Override http request option.
|
|
616
|
+
* @throws {RequiredError}
|
|
617
|
+
*/
|
|
618
|
+
findUser: async (options = {}) => {
|
|
619
|
+
const localVarPath = `/user`;
|
|
620
|
+
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
|
|
621
|
+
let baseOptions;
|
|
622
|
+
if (configuration) {
|
|
623
|
+
baseOptions = configuration.baseOptions;
|
|
167
624
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
625
|
+
const localVarRequestOptions = { method: "GET", ...baseOptions, ...options };
|
|
626
|
+
const localVarHeaderParameter = {};
|
|
627
|
+
const localVarQueryParameter = {};
|
|
628
|
+
await setBearerAuthToObject(localVarHeaderParameter, configuration);
|
|
629
|
+
localVarHeaderParameter["Accept"] = "application/json";
|
|
630
|
+
setSearchParams(localVarUrlObj, localVarQueryParameter);
|
|
631
|
+
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
|
632
|
+
localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
|
|
633
|
+
return {
|
|
634
|
+
url: toPathString(localVarUrlObj),
|
|
635
|
+
options: localVarRequestOptions
|
|
636
|
+
};
|
|
637
|
+
}
|
|
638
|
+
};
|
|
639
|
+
};
|
|
640
|
+
var UsersApiFp = function(configuration) {
|
|
641
|
+
const localVarAxiosParamCreator = UsersApiAxiosParamCreator(configuration);
|
|
642
|
+
return {
|
|
643
|
+
/**
|
|
644
|
+
* Returns the currently authenticated user\'s data. Requires a valid Bearer token.
|
|
645
|
+
* @summary Get current User
|
|
646
|
+
* @param {*} [options] Override http request option.
|
|
647
|
+
* @throws {RequiredError}
|
|
648
|
+
*/
|
|
649
|
+
async findUser(options) {
|
|
650
|
+
const localVarAxiosArgs = await localVarAxiosParamCreator.findUser(options);
|
|
651
|
+
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
|
|
652
|
+
const localVarOperationServerBasePath = operationServerMap["UsersApi.findUser"]?.[localVarOperationServerIndex]?.url;
|
|
653
|
+
return (axios2, basePath) => createRequestFunction(localVarAxiosArgs, import_axios4.default, BASE_PATH, configuration)(axios2, localVarOperationServerBasePath || basePath);
|
|
172
654
|
}
|
|
655
|
+
};
|
|
656
|
+
};
|
|
657
|
+
var UsersApi = class extends BaseAPI {
|
|
658
|
+
/**
|
|
659
|
+
* Returns the currently authenticated user\'s data. Requires a valid Bearer token.
|
|
660
|
+
* @summary Get current User
|
|
661
|
+
* @param {*} [options] Override http request option.
|
|
662
|
+
* @throws {RequiredError}
|
|
663
|
+
*/
|
|
664
|
+
findUser(options) {
|
|
665
|
+
return UsersApiFp(this.configuration).findUser(options).then((request) => request(this.axios, this.basePath));
|
|
173
666
|
}
|
|
174
667
|
};
|
|
175
668
|
|
|
176
|
-
// src/
|
|
177
|
-
var
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
669
|
+
// src/generated/configuration.ts
|
|
670
|
+
var Configuration = class {
|
|
671
|
+
/**
|
|
672
|
+
* parameter for apiKey security
|
|
673
|
+
* @param name security name
|
|
674
|
+
*/
|
|
675
|
+
apiKey;
|
|
676
|
+
/**
|
|
677
|
+
* parameter for basic security
|
|
678
|
+
*/
|
|
679
|
+
username;
|
|
680
|
+
/**
|
|
681
|
+
* parameter for basic security
|
|
682
|
+
*/
|
|
683
|
+
password;
|
|
684
|
+
/**
|
|
685
|
+
* parameter for oauth2 security
|
|
686
|
+
* @param name security name
|
|
687
|
+
* @param scopes oauth2 scope
|
|
688
|
+
*/
|
|
689
|
+
accessToken;
|
|
690
|
+
/**
|
|
691
|
+
* parameter for aws4 signature security
|
|
692
|
+
* @param {Object} AWS4Signature - AWS4 Signature security
|
|
693
|
+
* @param {string} options.region - aws region
|
|
694
|
+
* @param {string} options.service - name of the service.
|
|
695
|
+
* @param {string} credentials.accessKeyId - aws access key id
|
|
696
|
+
* @param {string} credentials.secretAccessKey - aws access key
|
|
697
|
+
* @param {string} credentials.sessionToken - aws session token
|
|
698
|
+
* @memberof Configuration
|
|
699
|
+
*/
|
|
700
|
+
awsv4;
|
|
701
|
+
/**
|
|
702
|
+
* override base path
|
|
703
|
+
*/
|
|
704
|
+
basePath;
|
|
705
|
+
/**
|
|
706
|
+
* override server index
|
|
707
|
+
*/
|
|
708
|
+
serverIndex;
|
|
709
|
+
/**
|
|
710
|
+
* base options for axios calls
|
|
711
|
+
*/
|
|
712
|
+
baseOptions;
|
|
713
|
+
/**
|
|
714
|
+
* The FormData constructor that will be used to create multipart form data
|
|
715
|
+
* requests. You can inject this here so that execution environments that
|
|
716
|
+
* do not support the FormData class can still run the generated client.
|
|
717
|
+
*
|
|
718
|
+
* @type {new () => FormData}
|
|
719
|
+
*/
|
|
720
|
+
formDataCtor;
|
|
721
|
+
constructor(param = {}) {
|
|
722
|
+
this.apiKey = param.apiKey;
|
|
723
|
+
this.username = param.username;
|
|
724
|
+
this.password = param.password;
|
|
725
|
+
this.accessToken = param.accessToken;
|
|
726
|
+
this.awsv4 = param.awsv4;
|
|
727
|
+
this.basePath = param.basePath;
|
|
728
|
+
this.serverIndex = param.serverIndex;
|
|
729
|
+
this.baseOptions = {
|
|
730
|
+
...param.baseOptions,
|
|
731
|
+
headers: {
|
|
732
|
+
...param.baseOptions?.headers
|
|
733
|
+
}
|
|
734
|
+
};
|
|
735
|
+
this.formDataCtor = param.formDataCtor;
|
|
736
|
+
}
|
|
737
|
+
/**
|
|
738
|
+
* Check if the given MIME is a JSON MIME.
|
|
739
|
+
* JSON MIME examples:
|
|
740
|
+
* application/json
|
|
741
|
+
* application/json; charset=UTF8
|
|
742
|
+
* APPLICATION/JSON
|
|
743
|
+
* application/vnd.company+json
|
|
744
|
+
* @param mime - MIME (Multipurpose Internet Mail Extensions)
|
|
745
|
+
* @return True if the given MIME is JSON, false otherwise.
|
|
746
|
+
*/
|
|
747
|
+
isJsonMime(mime) {
|
|
748
|
+
const jsonMime = new RegExp("^(application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(;.*)?$", "i");
|
|
749
|
+
return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === "application/json-patch+json");
|
|
750
|
+
}
|
|
188
751
|
};
|
|
752
|
+
|
|
753
|
+
// src/http/jwt_interceptor.ts
|
|
189
754
|
var JwtInterceptor = class {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
function _extractTokenFromCache(tokenType) {
|
|
193
|
-
const token = localStorage.getItem(tokenType.toString());
|
|
194
|
-
return token ? { value: token, tokenType } : null;
|
|
195
|
-
}
|
|
755
|
+
apply(axiosInstance, options) {
|
|
756
|
+
const REFRESH_URI = "/auth/refreshToken";
|
|
196
757
|
axiosInstance.interceptors.request.use(
|
|
197
758
|
(config) => {
|
|
198
|
-
const
|
|
199
|
-
if (!url)
|
|
200
|
-
|
|
201
|
-
const token = tokenType ? _extractTokenFromCache(tokenType) : null;
|
|
202
|
-
if (token) {
|
|
203
|
-
config.headers.Authorization = `Bearer ${token}`;
|
|
759
|
+
const accessToken = options?.getToken();
|
|
760
|
+
if (!config.url?.includes(REFRESH_URI) && accessToken) {
|
|
761
|
+
config.headers.Authorization = `Bearer ${accessToken}`;
|
|
204
762
|
}
|
|
205
763
|
return config;
|
|
206
764
|
},
|
|
@@ -210,61 +768,26 @@ var JwtInterceptor = class {
|
|
|
210
768
|
}
|
|
211
769
|
);
|
|
212
770
|
axiosInstance.interceptors.response.use(
|
|
213
|
-
(response) =>
|
|
214
|
-
const url = response.config.url;
|
|
215
|
-
if (!url) return response;
|
|
216
|
-
if (url === "/auth/logout") {
|
|
217
|
-
localStorage.removeItem(0 /* AccessToken */.toString());
|
|
218
|
-
localStorage.removeItem(1 /* RefreshToken */.toString());
|
|
219
|
-
return response;
|
|
220
|
-
}
|
|
221
|
-
const value = ENDPOINTS.get(url);
|
|
222
|
-
const token_type = value === void 0 ? 0 /* AccessToken */ : value;
|
|
223
|
-
if (token_type === 0 /* AccessToken */) {
|
|
224
|
-
return response;
|
|
225
|
-
}
|
|
226
|
-
const auth_response = response.data;
|
|
227
|
-
if (auth_response.tokens) {
|
|
228
|
-
localStorage.setItem(
|
|
229
|
-
0 /* AccessToken */.toString(),
|
|
230
|
-
auth_response.tokens.access
|
|
231
|
-
);
|
|
232
|
-
localStorage.setItem(
|
|
233
|
-
1 /* RefreshToken */.toString(),
|
|
234
|
-
auth_response.tokens.refresh
|
|
235
|
-
);
|
|
236
|
-
}
|
|
237
|
-
return response;
|
|
238
|
-
},
|
|
771
|
+
(response) => response,
|
|
239
772
|
async (error) => {
|
|
240
773
|
const originalRequest = error.config;
|
|
241
|
-
if (error.response?.status === 401 && !originalRequest._retry) {
|
|
774
|
+
if (error.response?.status === 401 && !originalRequest._retry && !originalRequest.url?.includes(REFRESH_URI)) {
|
|
242
775
|
originalRequest._retry = true;
|
|
243
776
|
try {
|
|
244
|
-
const refreshToken =
|
|
245
|
-
1 /* RefreshToken */.toString()
|
|
246
|
-
);
|
|
777
|
+
const refreshToken = options?.getRefreshToken();
|
|
247
778
|
const response = await axiosInstance.post(
|
|
248
|
-
|
|
779
|
+
REFRESH_URI,
|
|
249
780
|
{},
|
|
250
781
|
{ headers: { authorization: `Bearer ${refreshToken}` } }
|
|
251
782
|
);
|
|
252
783
|
const auth_response = response.data;
|
|
253
784
|
if (auth_response.tokens) {
|
|
254
|
-
|
|
255
|
-
0 /* AccessToken */.toString(),
|
|
256
|
-
auth_response.tokens.access
|
|
257
|
-
);
|
|
258
|
-
localStorage.setItem(
|
|
259
|
-
1 /* RefreshToken */.toString(),
|
|
260
|
-
auth_response.tokens.refresh
|
|
261
|
-
);
|
|
785
|
+
options?.onTokenRefresh?.(auth_response.tokens);
|
|
262
786
|
}
|
|
263
787
|
originalRequest.headers.Authorization = `Bearer ${auth_response.tokens?.access}`;
|
|
264
788
|
return axiosInstance(originalRequest);
|
|
265
789
|
} catch (e) {
|
|
266
|
-
|
|
267
|
-
window.location.href = "/";
|
|
790
|
+
options?.onSessionExpired?.();
|
|
268
791
|
return Promise.reject(e);
|
|
269
792
|
}
|
|
270
793
|
}
|
|
@@ -274,57 +797,38 @@ var JwtInterceptor = class {
|
|
|
274
797
|
}
|
|
275
798
|
};
|
|
276
799
|
|
|
277
|
-
// src/http/session_interceptor.ts
|
|
278
|
-
var SessionInterceptor = class {
|
|
279
|
-
apply(axios2) {
|
|
280
|
-
axios2.interceptors.request.use(
|
|
281
|
-
(config) => {
|
|
282
|
-
const session_id = localStorage.getItem(
|
|
283
|
-
2 /* SessionToken */.toString()
|
|
284
|
-
);
|
|
285
|
-
if (session_id) {
|
|
286
|
-
config.headers.Cookie = `id=${session_id}`;
|
|
287
|
-
}
|
|
288
|
-
return config;
|
|
289
|
-
},
|
|
290
|
-
(error) => {
|
|
291
|
-
console.error("Request error:", error);
|
|
292
|
-
return Promise.reject(error);
|
|
293
|
-
}
|
|
294
|
-
);
|
|
295
|
-
axios2.interceptors.response.use((response) => {
|
|
296
|
-
if (response.config.url !== "/auth/logout") {
|
|
297
|
-
localStorage.removeItem(2 /* SessionToken */.toString());
|
|
298
|
-
return response;
|
|
299
|
-
}
|
|
300
|
-
const setCookie = response.headers["set-cookie"];
|
|
301
|
-
if (setCookie) {
|
|
302
|
-
const cookie = setCookie.find((c) => c.startsWith("id="));
|
|
303
|
-
if (cookie) {
|
|
304
|
-
const sessionID = cookie.split(";")[0].split("=")[1];
|
|
305
|
-
localStorage.setItem(2 /* SessionToken */.toString(), sessionID);
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
return response;
|
|
309
|
-
});
|
|
310
|
-
}
|
|
311
|
-
};
|
|
312
|
-
|
|
313
800
|
// src/index.ts
|
|
314
|
-
function Anzar(
|
|
315
|
-
const
|
|
316
|
-
|
|
317
|
-
|
|
801
|
+
function Anzar(anzarConfig, options) {
|
|
802
|
+
const basePath = anzarConfig.api_url;
|
|
803
|
+
const configuration = new Configuration({ basePath });
|
|
804
|
+
const axiosInstance = import_axios5.default.create({
|
|
805
|
+
baseURL: basePath,
|
|
806
|
+
withCredentials: true,
|
|
318
807
|
headers: {
|
|
319
808
|
"Content-Type": "application/json",
|
|
320
809
|
Accept: "application/json"
|
|
321
810
|
}
|
|
322
811
|
});
|
|
323
|
-
if (
|
|
324
|
-
|
|
325
|
-
} else {
|
|
326
|
-
new JwtInterceptor().apply(axiosApiInstance);
|
|
812
|
+
if (anzarConfig.auth?.strategy === "Jwt" /* Jwt */) {
|
|
813
|
+
new JwtInterceptor().apply(axiosInstance, options);
|
|
327
814
|
}
|
|
328
|
-
const
|
|
329
|
-
return
|
|
815
|
+
const generatedAuthApi = new AuthApi(configuration, basePath, axiosInstance);
|
|
816
|
+
return {
|
|
817
|
+
Auth: {
|
|
818
|
+
login: (body) => generatedAuthApi.login(body),
|
|
819
|
+
register: (body) => generatedAuthApi.register(body),
|
|
820
|
+
logout: async () => {
|
|
821
|
+
await generatedAuthApi.logout();
|
|
822
|
+
options?.onLogout?.();
|
|
823
|
+
},
|
|
824
|
+
resetPassword: (body) => {
|
|
825
|
+
generatedAuthApi.requestPasswordReset(body);
|
|
826
|
+
},
|
|
827
|
+
...anzarConfig.auth?.strategy === "Session" /* Session */ && {
|
|
828
|
+
session: () => generatedAuthApi.getSession()
|
|
829
|
+
}
|
|
830
|
+
},
|
|
831
|
+
User: new UsersApi(configuration, basePath, axiosInstance),
|
|
832
|
+
Email: new EmailApi(configuration, basePath, axiosInstance)
|
|
833
|
+
};
|
|
330
834
|
}
|