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