@djangocfg/api 2.1.456 → 2.1.459
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/README.md +1 -1
- package/dist/auth.cjs +2109 -2380
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.d.cts +24 -5
- package/dist/auth.d.ts +24 -5
- package/dist/auth.mjs +2229 -290
- package/dist/auth.mjs.map +1 -1
- package/dist/clients.cjs +1906 -2024
- package/dist/clients.cjs.map +1 -1
- package/dist/clients.mjs +2090 -14
- package/dist/clients.mjs.map +1 -1
- package/dist/hooks.cjs +1026 -1672
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.mjs +1543 -4
- package/dist/hooks.mjs.map +1 -1
- package/dist/index.cjs +1892 -2015
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +2105 -20
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/_api/generated/helpers/auth.ts +24 -12
- package/src/auth/constants.ts +5 -5
- package/src/auth/context/AuthContext.tsx +67 -28
- package/src/auth/context/types.ts +13 -0
- package/src/auth/hooks/index.ts +5 -1
- package/src/auth/hooks/useAuthRedirect.ts +17 -0
- package/src/auth/hooks/useTwoFactor.ts +4 -2
package/dist/hooks.cjs
CHANGED
|
@@ -6,9 +6,6 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
8
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
|
-
var __esm = (fn, res) => function __init() {
|
|
10
|
-
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
11
|
-
};
|
|
12
9
|
var __export = (target, all) => {
|
|
13
10
|
for (var name in all)
|
|
14
11
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -31,60 +28,32 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
31
28
|
));
|
|
32
29
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
33
30
|
|
|
34
|
-
// src/
|
|
35
|
-
var
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
serializeFormDataPair = /* @__PURE__ */ __name((data, key, value) => {
|
|
39
|
-
if (typeof value === "string" || value instanceof Blob) {
|
|
40
|
-
data.append(key, value);
|
|
41
|
-
} else if (value instanceof Date) {
|
|
42
|
-
data.append(key, value.toISOString());
|
|
43
|
-
} else {
|
|
44
|
-
data.append(key, JSON.stringify(value));
|
|
45
|
-
}
|
|
46
|
-
}, "serializeFormDataPair");
|
|
47
|
-
formDataBodySerializer = {
|
|
48
|
-
bodySerializer: /* @__PURE__ */ __name((body) => {
|
|
49
|
-
const data = new FormData();
|
|
50
|
-
Object.entries(body).forEach(([key, value]) => {
|
|
51
|
-
if (value === void 0 || value === null) {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
if (Array.isArray(value)) {
|
|
55
|
-
value.forEach((v) => serializeFormDataPair(data, key, v));
|
|
56
|
-
} else {
|
|
57
|
-
serializeFormDataPair(data, key, value);
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
return data;
|
|
61
|
-
}, "bodySerializer")
|
|
62
|
-
};
|
|
63
|
-
jsonBodySerializer = {
|
|
64
|
-
bodySerializer: /* @__PURE__ */ __name((body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value), "bodySerializer")
|
|
65
|
-
};
|
|
66
|
-
}
|
|
31
|
+
// src/hooks/index.ts
|
|
32
|
+
var hooks_exports = {};
|
|
33
|
+
__export(hooks_exports, {
|
|
34
|
+
useApiKey: () => useApiKey
|
|
67
35
|
});
|
|
36
|
+
module.exports = __toCommonJS(hooks_exports);
|
|
68
37
|
|
|
69
|
-
// src/
|
|
70
|
-
var
|
|
71
|
-
var init_params_gen = __esm({
|
|
72
|
-
"src/_api/generated/core/params.gen.ts"() {
|
|
73
|
-
extraPrefixesMap = {
|
|
74
|
-
$body_: "body",
|
|
75
|
-
$headers_: "headers",
|
|
76
|
-
$path_: "path",
|
|
77
|
-
$query_: "query"
|
|
78
|
-
};
|
|
79
|
-
extraPrefixes = Object.entries(extraPrefixesMap);
|
|
80
|
-
}
|
|
81
|
-
});
|
|
38
|
+
// src/hooks/useApiKey.ts
|
|
39
|
+
var import_react = require("react");
|
|
82
40
|
|
|
83
|
-
// src/_api/generated/
|
|
84
|
-
var
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
41
|
+
// src/_api/generated/_cfg_accounts/hooks/useCfgAccountsApiKeyRegenerateCreate.ts
|
|
42
|
+
var import_mutation = __toESM(require("swr/mutation"), 1);
|
|
43
|
+
|
|
44
|
+
// src/_api/generated/core/bodySerializer.gen.ts
|
|
45
|
+
var jsonBodySerializer = {
|
|
46
|
+
bodySerializer: /* @__PURE__ */ __name((body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value), "bodySerializer")
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
// src/_api/generated/core/params.gen.ts
|
|
50
|
+
var extraPrefixesMap = {
|
|
51
|
+
$body_: "body",
|
|
52
|
+
$headers_: "headers",
|
|
53
|
+
$path_: "path",
|
|
54
|
+
$query_: "query"
|
|
55
|
+
};
|
|
56
|
+
var extraPrefixes = Object.entries(extraPrefixesMap);
|
|
88
57
|
|
|
89
58
|
// src/_api/generated/core/serverSentEvents.gen.ts
|
|
90
59
|
function createSseClient({
|
|
@@ -212,142 +181,213 @@ function createSseClient({
|
|
|
212
181
|
const stream = createStream();
|
|
213
182
|
return { stream };
|
|
214
183
|
}
|
|
215
|
-
|
|
216
|
-
"src/_api/generated/core/serverSentEvents.gen.ts"() {
|
|
217
|
-
__name(createSseClient, "createSseClient");
|
|
218
|
-
}
|
|
219
|
-
});
|
|
184
|
+
__name(createSseClient, "createSseClient");
|
|
220
185
|
|
|
221
186
|
// src/_api/generated/core/pathSerializer.gen.ts
|
|
222
|
-
var separatorArrayExplode
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
187
|
+
var separatorArrayExplode = /* @__PURE__ */ __name((style) => {
|
|
188
|
+
switch (style) {
|
|
189
|
+
case "label":
|
|
190
|
+
return ".";
|
|
191
|
+
case "matrix":
|
|
192
|
+
return ";";
|
|
193
|
+
case "simple":
|
|
194
|
+
return ",";
|
|
195
|
+
default:
|
|
196
|
+
return "&";
|
|
197
|
+
}
|
|
198
|
+
}, "separatorArrayExplode");
|
|
199
|
+
var separatorArrayNoExplode = /* @__PURE__ */ __name((style) => {
|
|
200
|
+
switch (style) {
|
|
201
|
+
case "form":
|
|
202
|
+
return ",";
|
|
203
|
+
case "pipeDelimited":
|
|
204
|
+
return "|";
|
|
205
|
+
case "spaceDelimited":
|
|
206
|
+
return "%20";
|
|
207
|
+
default:
|
|
208
|
+
return ",";
|
|
209
|
+
}
|
|
210
|
+
}, "separatorArrayNoExplode");
|
|
211
|
+
var separatorObjectExplode = /* @__PURE__ */ __name((style) => {
|
|
212
|
+
switch (style) {
|
|
213
|
+
case "label":
|
|
214
|
+
return ".";
|
|
215
|
+
case "matrix":
|
|
216
|
+
return ";";
|
|
217
|
+
case "simple":
|
|
218
|
+
return ",";
|
|
219
|
+
default:
|
|
220
|
+
return "&";
|
|
221
|
+
}
|
|
222
|
+
}, "separatorObjectExplode");
|
|
223
|
+
var serializeArrayParam = /* @__PURE__ */ __name(({
|
|
224
|
+
allowReserved,
|
|
225
|
+
explode,
|
|
226
|
+
name,
|
|
227
|
+
style,
|
|
228
|
+
value
|
|
229
|
+
}) => {
|
|
230
|
+
if (!explode) {
|
|
231
|
+
const joinedValues2 = (allowReserved ? value : value.map((v) => encodeURIComponent(v))).join(separatorArrayNoExplode(style));
|
|
232
|
+
switch (style) {
|
|
233
|
+
case "label":
|
|
234
|
+
return `.${joinedValues2}`;
|
|
235
|
+
case "matrix":
|
|
236
|
+
return `;${name}=${joinedValues2}`;
|
|
237
|
+
case "simple":
|
|
238
|
+
return joinedValues2;
|
|
239
|
+
default:
|
|
240
|
+
return `${name}=${joinedValues2}`;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
const separator = separatorArrayExplode(style);
|
|
244
|
+
const joinedValues = value.map((v) => {
|
|
245
|
+
if (style === "label" || style === "simple") {
|
|
246
|
+
return allowReserved ? v : encodeURIComponent(v);
|
|
247
|
+
}
|
|
248
|
+
return serializePrimitiveParam({
|
|
262
249
|
allowReserved,
|
|
263
|
-
explode,
|
|
264
250
|
name,
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
251
|
+
value: v
|
|
252
|
+
});
|
|
253
|
+
}).join(separator);
|
|
254
|
+
return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
|
|
255
|
+
}, "serializeArrayParam");
|
|
256
|
+
var serializePrimitiveParam = /* @__PURE__ */ __name(({
|
|
257
|
+
allowReserved,
|
|
258
|
+
name,
|
|
259
|
+
value
|
|
260
|
+
}) => {
|
|
261
|
+
if (value === void 0 || value === null) {
|
|
262
|
+
return "";
|
|
263
|
+
}
|
|
264
|
+
if (typeof value === "object") {
|
|
265
|
+
throw new Error(
|
|
266
|
+
"Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these."
|
|
267
|
+
);
|
|
268
|
+
}
|
|
269
|
+
return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
|
|
270
|
+
}, "serializePrimitiveParam");
|
|
271
|
+
var serializeObjectParam = /* @__PURE__ */ __name(({
|
|
272
|
+
allowReserved,
|
|
273
|
+
explode,
|
|
274
|
+
name,
|
|
275
|
+
style,
|
|
276
|
+
value,
|
|
277
|
+
valueOnly
|
|
278
|
+
}) => {
|
|
279
|
+
if (value instanceof Date) {
|
|
280
|
+
return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
|
|
281
|
+
}
|
|
282
|
+
if (style !== "deepObject" && !explode) {
|
|
283
|
+
let values = [];
|
|
284
|
+
Object.entries(value).forEach(([key, v]) => {
|
|
285
|
+
values = [...values, key, allowReserved ? v : encodeURIComponent(v)];
|
|
286
|
+
});
|
|
287
|
+
const joinedValues2 = values.join(",");
|
|
288
|
+
switch (style) {
|
|
289
|
+
case "form":
|
|
290
|
+
return `${name}=${joinedValues2}`;
|
|
291
|
+
case "label":
|
|
292
|
+
return `.${joinedValues2}`;
|
|
293
|
+
case "matrix":
|
|
294
|
+
return `;${name}=${joinedValues2}`;
|
|
295
|
+
default:
|
|
296
|
+
return joinedValues2;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
const separator = separatorObjectExplode(style);
|
|
300
|
+
const joinedValues = Object.entries(value).map(
|
|
301
|
+
([key, v]) => serializePrimitiveParam({
|
|
295
302
|
allowReserved,
|
|
296
|
-
name,
|
|
297
|
-
value
|
|
298
|
-
})
|
|
303
|
+
name: style === "deepObject" ? `${name}[${key}]` : key,
|
|
304
|
+
value: v
|
|
305
|
+
})
|
|
306
|
+
).join(separator);
|
|
307
|
+
return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
|
|
308
|
+
}, "serializeObjectParam");
|
|
309
|
+
|
|
310
|
+
// src/_api/generated/core/utils.gen.ts
|
|
311
|
+
var PATH_PARAM_RE = /\{[^{}]+\}/g;
|
|
312
|
+
var defaultPathSerializer = /* @__PURE__ */ __name(({ path, url: _url }) => {
|
|
313
|
+
let url = _url;
|
|
314
|
+
const matches = _url.match(PATH_PARAM_RE);
|
|
315
|
+
if (matches) {
|
|
316
|
+
for (const match of matches) {
|
|
317
|
+
let explode = false;
|
|
318
|
+
let name = match.substring(1, match.length - 1);
|
|
319
|
+
let style = "simple";
|
|
320
|
+
if (name.endsWith("*")) {
|
|
321
|
+
explode = true;
|
|
322
|
+
name = name.substring(0, name.length - 1);
|
|
323
|
+
}
|
|
324
|
+
if (name.startsWith(".")) {
|
|
325
|
+
name = name.substring(1);
|
|
326
|
+
style = "label";
|
|
327
|
+
} else if (name.startsWith(";")) {
|
|
328
|
+
name = name.substring(1);
|
|
329
|
+
style = "matrix";
|
|
330
|
+
}
|
|
331
|
+
const value = path[name];
|
|
299
332
|
if (value === void 0 || value === null) {
|
|
300
|
-
|
|
333
|
+
continue;
|
|
334
|
+
}
|
|
335
|
+
if (Array.isArray(value)) {
|
|
336
|
+
url = url.replace(match, serializeArrayParam({ explode, name, style, value }));
|
|
337
|
+
continue;
|
|
301
338
|
}
|
|
302
339
|
if (typeof value === "object") {
|
|
303
|
-
|
|
304
|
-
|
|
340
|
+
url = url.replace(
|
|
341
|
+
match,
|
|
342
|
+
serializeObjectParam({
|
|
343
|
+
explode,
|
|
344
|
+
name,
|
|
345
|
+
style,
|
|
346
|
+
value,
|
|
347
|
+
valueOnly: true
|
|
348
|
+
})
|
|
305
349
|
);
|
|
350
|
+
continue;
|
|
351
|
+
}
|
|
352
|
+
if (style === "matrix") {
|
|
353
|
+
url = url.replace(
|
|
354
|
+
match,
|
|
355
|
+
`;${serializePrimitiveParam({
|
|
356
|
+
name,
|
|
357
|
+
value
|
|
358
|
+
})}`
|
|
359
|
+
);
|
|
360
|
+
continue;
|
|
306
361
|
}
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
name,
|
|
313
|
-
style,
|
|
314
|
-
value,
|
|
315
|
-
valueOnly
|
|
316
|
-
}) => {
|
|
317
|
-
if (value instanceof Date) {
|
|
318
|
-
return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
|
|
319
|
-
}
|
|
320
|
-
if (style !== "deepObject" && !explode) {
|
|
321
|
-
let values = [];
|
|
322
|
-
Object.entries(value).forEach(([key, v]) => {
|
|
323
|
-
values = [...values, key, allowReserved ? v : encodeURIComponent(v)];
|
|
324
|
-
});
|
|
325
|
-
const joinedValues2 = values.join(",");
|
|
326
|
-
switch (style) {
|
|
327
|
-
case "form":
|
|
328
|
-
return `${name}=${joinedValues2}`;
|
|
329
|
-
case "label":
|
|
330
|
-
return `.${joinedValues2}`;
|
|
331
|
-
case "matrix":
|
|
332
|
-
return `;${name}=${joinedValues2}`;
|
|
333
|
-
default:
|
|
334
|
-
return joinedValues2;
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
const separator = separatorObjectExplode(style);
|
|
338
|
-
const joinedValues = Object.entries(value).map(
|
|
339
|
-
([key, v]) => serializePrimitiveParam({
|
|
340
|
-
allowReserved,
|
|
341
|
-
name: style === "deepObject" ? `${name}[${key}]` : key,
|
|
342
|
-
value: v
|
|
343
|
-
})
|
|
344
|
-
).join(separator);
|
|
345
|
-
return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
|
|
346
|
-
}, "serializeObjectParam");
|
|
362
|
+
const replaceValue = encodeURIComponent(
|
|
363
|
+
style === "label" ? `.${value}` : value
|
|
364
|
+
);
|
|
365
|
+
url = url.replace(match, replaceValue);
|
|
366
|
+
}
|
|
347
367
|
}
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
368
|
+
return url;
|
|
369
|
+
}, "defaultPathSerializer");
|
|
370
|
+
var getUrl = /* @__PURE__ */ __name(({
|
|
371
|
+
baseUrl,
|
|
372
|
+
path,
|
|
373
|
+
query,
|
|
374
|
+
querySerializer,
|
|
375
|
+
url: _url
|
|
376
|
+
}) => {
|
|
377
|
+
const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
|
|
378
|
+
let url = (baseUrl ?? "") + pathUrl;
|
|
379
|
+
if (path) {
|
|
380
|
+
url = defaultPathSerializer({ path, url });
|
|
381
|
+
}
|
|
382
|
+
let search = query ? querySerializer(query) : "";
|
|
383
|
+
if (search.startsWith("?")) {
|
|
384
|
+
search = search.substring(1);
|
|
385
|
+
}
|
|
386
|
+
if (search) {
|
|
387
|
+
url += `?${search}`;
|
|
388
|
+
}
|
|
389
|
+
return url;
|
|
390
|
+
}, "getUrl");
|
|
351
391
|
function getValidRequestBody(options) {
|
|
352
392
|
const hasBody = options.body !== void 0;
|
|
353
393
|
const isSerializedBody = hasBody && options.bodySerializer;
|
|
@@ -363,115 +403,102 @@ function getValidRequestBody(options) {
|
|
|
363
403
|
}
|
|
364
404
|
return void 0;
|
|
365
405
|
}
|
|
366
|
-
|
|
367
|
-
var init_utils_gen = __esm({
|
|
368
|
-
"src/_api/generated/core/utils.gen.ts"() {
|
|
369
|
-
init_pathSerializer_gen();
|
|
370
|
-
PATH_PARAM_RE = /\{[^{}]+\}/g;
|
|
371
|
-
defaultPathSerializer = /* @__PURE__ */ __name(({ path, url: _url }) => {
|
|
372
|
-
let url = _url;
|
|
373
|
-
const matches = _url.match(PATH_PARAM_RE);
|
|
374
|
-
if (matches) {
|
|
375
|
-
for (const match of matches) {
|
|
376
|
-
let explode = false;
|
|
377
|
-
let name = match.substring(1, match.length - 1);
|
|
378
|
-
let style = "simple";
|
|
379
|
-
if (name.endsWith("*")) {
|
|
380
|
-
explode = true;
|
|
381
|
-
name = name.substring(0, name.length - 1);
|
|
382
|
-
}
|
|
383
|
-
if (name.startsWith(".")) {
|
|
384
|
-
name = name.substring(1);
|
|
385
|
-
style = "label";
|
|
386
|
-
} else if (name.startsWith(";")) {
|
|
387
|
-
name = name.substring(1);
|
|
388
|
-
style = "matrix";
|
|
389
|
-
}
|
|
390
|
-
const value = path[name];
|
|
391
|
-
if (value === void 0 || value === null) {
|
|
392
|
-
continue;
|
|
393
|
-
}
|
|
394
|
-
if (Array.isArray(value)) {
|
|
395
|
-
url = url.replace(match, serializeArrayParam({ explode, name, style, value }));
|
|
396
|
-
continue;
|
|
397
|
-
}
|
|
398
|
-
if (typeof value === "object") {
|
|
399
|
-
url = url.replace(
|
|
400
|
-
match,
|
|
401
|
-
serializeObjectParam({
|
|
402
|
-
explode,
|
|
403
|
-
name,
|
|
404
|
-
style,
|
|
405
|
-
value,
|
|
406
|
-
valueOnly: true
|
|
407
|
-
})
|
|
408
|
-
);
|
|
409
|
-
continue;
|
|
410
|
-
}
|
|
411
|
-
if (style === "matrix") {
|
|
412
|
-
url = url.replace(
|
|
413
|
-
match,
|
|
414
|
-
`;${serializePrimitiveParam({
|
|
415
|
-
name,
|
|
416
|
-
value
|
|
417
|
-
})}`
|
|
418
|
-
);
|
|
419
|
-
continue;
|
|
420
|
-
}
|
|
421
|
-
const replaceValue = encodeURIComponent(
|
|
422
|
-
style === "label" ? `.${value}` : value
|
|
423
|
-
);
|
|
424
|
-
url = url.replace(match, replaceValue);
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
return url;
|
|
428
|
-
}, "defaultPathSerializer");
|
|
429
|
-
getUrl = /* @__PURE__ */ __name(({
|
|
430
|
-
baseUrl,
|
|
431
|
-
path,
|
|
432
|
-
query,
|
|
433
|
-
querySerializer,
|
|
434
|
-
url: _url
|
|
435
|
-
}) => {
|
|
436
|
-
const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
|
|
437
|
-
let url = (baseUrl ?? "") + pathUrl;
|
|
438
|
-
if (path) {
|
|
439
|
-
url = defaultPathSerializer({ path, url });
|
|
440
|
-
}
|
|
441
|
-
let search = query ? querySerializer(query) : "";
|
|
442
|
-
if (search.startsWith("?")) {
|
|
443
|
-
search = search.substring(1);
|
|
444
|
-
}
|
|
445
|
-
if (search) {
|
|
446
|
-
url += `?${search}`;
|
|
447
|
-
}
|
|
448
|
-
return url;
|
|
449
|
-
}, "getUrl");
|
|
450
|
-
__name(getValidRequestBody, "getValidRequestBody");
|
|
451
|
-
}
|
|
452
|
-
});
|
|
406
|
+
__name(getValidRequestBody, "getValidRequestBody");
|
|
453
407
|
|
|
454
408
|
// src/_api/generated/core/auth.gen.ts
|
|
455
|
-
var getAuthToken
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
const token = typeof callback === "function" ? await callback(auth2) : callback;
|
|
460
|
-
if (!token) {
|
|
461
|
-
return;
|
|
462
|
-
}
|
|
463
|
-
if (auth2.scheme === "bearer") {
|
|
464
|
-
return `Bearer ${token}`;
|
|
465
|
-
}
|
|
466
|
-
if (auth2.scheme === "basic") {
|
|
467
|
-
return `Basic ${btoa(token)}`;
|
|
468
|
-
}
|
|
469
|
-
return token;
|
|
470
|
-
}, "getAuthToken");
|
|
409
|
+
var getAuthToken = /* @__PURE__ */ __name(async (auth2, callback) => {
|
|
410
|
+
const token = typeof callback === "function" ? await callback(auth2) : callback;
|
|
411
|
+
if (!token) {
|
|
412
|
+
return;
|
|
471
413
|
}
|
|
472
|
-
|
|
414
|
+
if (auth2.scheme === "bearer") {
|
|
415
|
+
return `Bearer ${token}`;
|
|
416
|
+
}
|
|
417
|
+
if (auth2.scheme === "basic") {
|
|
418
|
+
return `Basic ${btoa(token)}`;
|
|
419
|
+
}
|
|
420
|
+
return token;
|
|
421
|
+
}, "getAuthToken");
|
|
473
422
|
|
|
474
423
|
// src/_api/generated/client/utils.gen.ts
|
|
424
|
+
var createQuerySerializer = /* @__PURE__ */ __name(({
|
|
425
|
+
parameters = {},
|
|
426
|
+
...args
|
|
427
|
+
} = {}) => {
|
|
428
|
+
const querySerializer = /* @__PURE__ */ __name((queryParams) => {
|
|
429
|
+
const search = [];
|
|
430
|
+
if (queryParams && typeof queryParams === "object") {
|
|
431
|
+
for (const name in queryParams) {
|
|
432
|
+
const value = queryParams[name];
|
|
433
|
+
if (value === void 0 || value === null) {
|
|
434
|
+
continue;
|
|
435
|
+
}
|
|
436
|
+
const options = parameters[name] || args;
|
|
437
|
+
if (Array.isArray(value)) {
|
|
438
|
+
const serializedArray = serializeArrayParam({
|
|
439
|
+
allowReserved: options.allowReserved,
|
|
440
|
+
explode: true,
|
|
441
|
+
name,
|
|
442
|
+
style: "form",
|
|
443
|
+
value,
|
|
444
|
+
...options.array
|
|
445
|
+
});
|
|
446
|
+
if (serializedArray) search.push(serializedArray);
|
|
447
|
+
} else if (typeof value === "object") {
|
|
448
|
+
const serializedObject = serializeObjectParam({
|
|
449
|
+
allowReserved: options.allowReserved,
|
|
450
|
+
explode: true,
|
|
451
|
+
name,
|
|
452
|
+
style: "deepObject",
|
|
453
|
+
value,
|
|
454
|
+
...options.object
|
|
455
|
+
});
|
|
456
|
+
if (serializedObject) search.push(serializedObject);
|
|
457
|
+
} else {
|
|
458
|
+
const serializedPrimitive = serializePrimitiveParam({
|
|
459
|
+
allowReserved: options.allowReserved,
|
|
460
|
+
name,
|
|
461
|
+
value
|
|
462
|
+
});
|
|
463
|
+
if (serializedPrimitive) search.push(serializedPrimitive);
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
return search.join("&");
|
|
468
|
+
}, "querySerializer");
|
|
469
|
+
return querySerializer;
|
|
470
|
+
}, "createQuerySerializer");
|
|
471
|
+
var getParseAs = /* @__PURE__ */ __name((contentType) => {
|
|
472
|
+
if (!contentType) {
|
|
473
|
+
return "stream";
|
|
474
|
+
}
|
|
475
|
+
const cleanContent = contentType.split(";")[0]?.trim();
|
|
476
|
+
if (!cleanContent) {
|
|
477
|
+
return;
|
|
478
|
+
}
|
|
479
|
+
if (cleanContent.startsWith("application/json") || cleanContent.endsWith("+json")) {
|
|
480
|
+
return "json";
|
|
481
|
+
}
|
|
482
|
+
if (cleanContent === "multipart/form-data") {
|
|
483
|
+
return "formData";
|
|
484
|
+
}
|
|
485
|
+
if (["application/", "audio/", "image/", "video/"].some((type) => cleanContent.startsWith(type))) {
|
|
486
|
+
return "blob";
|
|
487
|
+
}
|
|
488
|
+
if (cleanContent.startsWith("text/")) {
|
|
489
|
+
return "text";
|
|
490
|
+
}
|
|
491
|
+
return;
|
|
492
|
+
}, "getParseAs");
|
|
493
|
+
var checkForExistence = /* @__PURE__ */ __name((options, name) => {
|
|
494
|
+
if (!name) {
|
|
495
|
+
return false;
|
|
496
|
+
}
|
|
497
|
+
if (options.headers.has(name) || options.query?.[name] || options.headers.get("Cookie")?.includes(`${name}=`)) {
|
|
498
|
+
return true;
|
|
499
|
+
}
|
|
500
|
+
return false;
|
|
501
|
+
}, "checkForExistence");
|
|
475
502
|
async function setAuthParams(options) {
|
|
476
503
|
for (const auth2 of options.security ?? []) {
|
|
477
504
|
if (checkForExistence(options, auth2.name)) {
|
|
@@ -499,484 +526,424 @@ async function setAuthParams(options) {
|
|
|
499
526
|
}
|
|
500
527
|
}
|
|
501
528
|
}
|
|
502
|
-
|
|
503
|
-
var
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
value,
|
|
539
|
-
...options.object
|
|
540
|
-
});
|
|
541
|
-
if (serializedObject) search.push(serializedObject);
|
|
542
|
-
} else {
|
|
543
|
-
const serializedPrimitive = serializePrimitiveParam({
|
|
544
|
-
allowReserved: options.allowReserved,
|
|
545
|
-
name,
|
|
546
|
-
value
|
|
547
|
-
});
|
|
548
|
-
if (serializedPrimitive) search.push(serializedPrimitive);
|
|
549
|
-
}
|
|
550
|
-
}
|
|
551
|
-
}
|
|
552
|
-
return search.join("&");
|
|
553
|
-
}, "querySerializer");
|
|
554
|
-
return querySerializer;
|
|
555
|
-
}, "createQuerySerializer");
|
|
556
|
-
getParseAs = /* @__PURE__ */ __name((contentType) => {
|
|
557
|
-
if (!contentType) {
|
|
558
|
-
return "stream";
|
|
559
|
-
}
|
|
560
|
-
const cleanContent = contentType.split(";")[0]?.trim();
|
|
561
|
-
if (!cleanContent) {
|
|
562
|
-
return;
|
|
563
|
-
}
|
|
564
|
-
if (cleanContent.startsWith("application/json") || cleanContent.endsWith("+json")) {
|
|
565
|
-
return "json";
|
|
566
|
-
}
|
|
567
|
-
if (cleanContent === "multipart/form-data") {
|
|
568
|
-
return "formData";
|
|
569
|
-
}
|
|
570
|
-
if (["application/", "audio/", "image/", "video/"].some((type) => cleanContent.startsWith(type))) {
|
|
571
|
-
return "blob";
|
|
572
|
-
}
|
|
573
|
-
if (cleanContent.startsWith("text/")) {
|
|
574
|
-
return "text";
|
|
575
|
-
}
|
|
576
|
-
return;
|
|
577
|
-
}, "getParseAs");
|
|
578
|
-
checkForExistence = /* @__PURE__ */ __name((options, name) => {
|
|
579
|
-
if (!name) {
|
|
580
|
-
return false;
|
|
581
|
-
}
|
|
582
|
-
if (options.headers.has(name) || options.query?.[name] || options.headers.get("Cookie")?.includes(`${name}=`)) {
|
|
583
|
-
return true;
|
|
584
|
-
}
|
|
585
|
-
return false;
|
|
586
|
-
}, "checkForExistence");
|
|
587
|
-
__name(setAuthParams, "setAuthParams");
|
|
588
|
-
buildUrl = /* @__PURE__ */ __name((options) => getUrl({
|
|
589
|
-
baseUrl: options.baseUrl,
|
|
590
|
-
path: options.path,
|
|
591
|
-
query: options.query,
|
|
592
|
-
querySerializer: typeof options.querySerializer === "function" ? options.querySerializer : createQuerySerializer(options.querySerializer),
|
|
593
|
-
url: options.url
|
|
594
|
-
}), "buildUrl");
|
|
595
|
-
mergeConfigs = /* @__PURE__ */ __name((a, b) => {
|
|
596
|
-
const config = { ...a, ...b };
|
|
597
|
-
if (config.baseUrl?.endsWith("/")) {
|
|
598
|
-
config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
|
|
599
|
-
}
|
|
600
|
-
config.headers = mergeHeaders(a.headers, b.headers);
|
|
601
|
-
return config;
|
|
602
|
-
}, "mergeConfigs");
|
|
603
|
-
headersEntries = /* @__PURE__ */ __name((headers) => {
|
|
604
|
-
const entries = [];
|
|
605
|
-
headers.forEach((value, key) => {
|
|
606
|
-
entries.push([key, value]);
|
|
607
|
-
});
|
|
608
|
-
return entries;
|
|
609
|
-
}, "headersEntries");
|
|
610
|
-
mergeHeaders = /* @__PURE__ */ __name((...headers) => {
|
|
611
|
-
const mergedHeaders = new Headers();
|
|
612
|
-
for (const header of headers) {
|
|
613
|
-
if (!header) {
|
|
614
|
-
continue;
|
|
615
|
-
}
|
|
616
|
-
const iterator = header instanceof Headers ? headersEntries(header) : Object.entries(header);
|
|
617
|
-
for (const [key, value] of iterator) {
|
|
618
|
-
if (value === null) {
|
|
619
|
-
mergedHeaders.delete(key);
|
|
620
|
-
} else if (Array.isArray(value)) {
|
|
621
|
-
for (const v of value) {
|
|
622
|
-
mergedHeaders.append(key, v);
|
|
623
|
-
}
|
|
624
|
-
} else if (value !== void 0) {
|
|
625
|
-
mergedHeaders.set(
|
|
626
|
-
key,
|
|
627
|
-
typeof value === "object" ? JSON.stringify(value) : value
|
|
628
|
-
);
|
|
629
|
-
}
|
|
630
|
-
}
|
|
631
|
-
}
|
|
632
|
-
return mergedHeaders;
|
|
633
|
-
}, "mergeHeaders");
|
|
634
|
-
Interceptors = class {
|
|
635
|
-
static {
|
|
636
|
-
__name(this, "Interceptors");
|
|
637
|
-
}
|
|
638
|
-
fns = [];
|
|
639
|
-
clear() {
|
|
640
|
-
this.fns = [];
|
|
641
|
-
}
|
|
642
|
-
eject(id) {
|
|
643
|
-
const index = this.getInterceptorIndex(id);
|
|
644
|
-
if (this.fns[index]) {
|
|
645
|
-
this.fns[index] = null;
|
|
646
|
-
}
|
|
647
|
-
}
|
|
648
|
-
exists(id) {
|
|
649
|
-
const index = this.getInterceptorIndex(id);
|
|
650
|
-
return Boolean(this.fns[index]);
|
|
651
|
-
}
|
|
652
|
-
getInterceptorIndex(id) {
|
|
653
|
-
if (typeof id === "number") {
|
|
654
|
-
return this.fns[id] ? id : -1;
|
|
655
|
-
}
|
|
656
|
-
return this.fns.indexOf(id);
|
|
657
|
-
}
|
|
658
|
-
update(id, fn) {
|
|
659
|
-
const index = this.getInterceptorIndex(id);
|
|
660
|
-
if (this.fns[index]) {
|
|
661
|
-
this.fns[index] = fn;
|
|
662
|
-
return id;
|
|
529
|
+
__name(setAuthParams, "setAuthParams");
|
|
530
|
+
var buildUrl = /* @__PURE__ */ __name((options) => getUrl({
|
|
531
|
+
baseUrl: options.baseUrl,
|
|
532
|
+
path: options.path,
|
|
533
|
+
query: options.query,
|
|
534
|
+
querySerializer: typeof options.querySerializer === "function" ? options.querySerializer : createQuerySerializer(options.querySerializer),
|
|
535
|
+
url: options.url
|
|
536
|
+
}), "buildUrl");
|
|
537
|
+
var mergeConfigs = /* @__PURE__ */ __name((a, b) => {
|
|
538
|
+
const config = { ...a, ...b };
|
|
539
|
+
if (config.baseUrl?.endsWith("/")) {
|
|
540
|
+
config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
|
|
541
|
+
}
|
|
542
|
+
config.headers = mergeHeaders(a.headers, b.headers);
|
|
543
|
+
return config;
|
|
544
|
+
}, "mergeConfigs");
|
|
545
|
+
var headersEntries = /* @__PURE__ */ __name((headers) => {
|
|
546
|
+
const entries = [];
|
|
547
|
+
headers.forEach((value, key) => {
|
|
548
|
+
entries.push([key, value]);
|
|
549
|
+
});
|
|
550
|
+
return entries;
|
|
551
|
+
}, "headersEntries");
|
|
552
|
+
var mergeHeaders = /* @__PURE__ */ __name((...headers) => {
|
|
553
|
+
const mergedHeaders = new Headers();
|
|
554
|
+
for (const header of headers) {
|
|
555
|
+
if (!header) {
|
|
556
|
+
continue;
|
|
557
|
+
}
|
|
558
|
+
const iterator = header instanceof Headers ? headersEntries(header) : Object.entries(header);
|
|
559
|
+
for (const [key, value] of iterator) {
|
|
560
|
+
if (value === null) {
|
|
561
|
+
mergedHeaders.delete(key);
|
|
562
|
+
} else if (Array.isArray(value)) {
|
|
563
|
+
for (const v of value) {
|
|
564
|
+
mergedHeaders.append(key, v);
|
|
663
565
|
}
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
}
|
|
670
|
-
};
|
|
671
|
-
createInterceptors = /* @__PURE__ */ __name(() => ({
|
|
672
|
-
error: new Interceptors(),
|
|
673
|
-
request: new Interceptors(),
|
|
674
|
-
response: new Interceptors()
|
|
675
|
-
}), "createInterceptors");
|
|
676
|
-
defaultQuerySerializer = createQuerySerializer({
|
|
677
|
-
allowReserved: false,
|
|
678
|
-
array: {
|
|
679
|
-
explode: true,
|
|
680
|
-
style: "form"
|
|
681
|
-
},
|
|
682
|
-
object: {
|
|
683
|
-
explode: true,
|
|
684
|
-
style: "deepObject"
|
|
566
|
+
} else if (value !== void 0) {
|
|
567
|
+
mergedHeaders.set(
|
|
568
|
+
key,
|
|
569
|
+
typeof value === "object" ? JSON.stringify(value) : value
|
|
570
|
+
);
|
|
685
571
|
}
|
|
686
|
-
}
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
return mergedHeaders;
|
|
575
|
+
}, "mergeHeaders");
|
|
576
|
+
var Interceptors = class {
|
|
577
|
+
static {
|
|
578
|
+
__name(this, "Interceptors");
|
|
579
|
+
}
|
|
580
|
+
fns = [];
|
|
581
|
+
clear() {
|
|
582
|
+
this.fns = [];
|
|
583
|
+
}
|
|
584
|
+
eject(id) {
|
|
585
|
+
const index = this.getInterceptorIndex(id);
|
|
586
|
+
if (this.fns[index]) {
|
|
587
|
+
this.fns[index] = null;
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
exists(id) {
|
|
591
|
+
const index = this.getInterceptorIndex(id);
|
|
592
|
+
return Boolean(this.fns[index]);
|
|
593
|
+
}
|
|
594
|
+
getInterceptorIndex(id) {
|
|
595
|
+
if (typeof id === "number") {
|
|
596
|
+
return this.fns[id] ? id : -1;
|
|
597
|
+
}
|
|
598
|
+
return this.fns.indexOf(id);
|
|
599
|
+
}
|
|
600
|
+
update(id, fn) {
|
|
601
|
+
const index = this.getInterceptorIndex(id);
|
|
602
|
+
if (this.fns[index]) {
|
|
603
|
+
this.fns[index] = fn;
|
|
604
|
+
return id;
|
|
605
|
+
}
|
|
606
|
+
return false;
|
|
607
|
+
}
|
|
608
|
+
use(fn) {
|
|
609
|
+
this.fns.push(fn);
|
|
610
|
+
return this.fns.length - 1;
|
|
611
|
+
}
|
|
612
|
+
};
|
|
613
|
+
var createInterceptors = /* @__PURE__ */ __name(() => ({
|
|
614
|
+
error: new Interceptors(),
|
|
615
|
+
request: new Interceptors(),
|
|
616
|
+
response: new Interceptors()
|
|
617
|
+
}), "createInterceptors");
|
|
618
|
+
var defaultQuerySerializer = createQuerySerializer({
|
|
619
|
+
allowReserved: false,
|
|
620
|
+
array: {
|
|
621
|
+
explode: true,
|
|
622
|
+
style: "form"
|
|
623
|
+
},
|
|
624
|
+
object: {
|
|
625
|
+
explode: true,
|
|
626
|
+
style: "deepObject"
|
|
697
627
|
}
|
|
698
628
|
});
|
|
629
|
+
var defaultHeaders = {
|
|
630
|
+
"Content-Type": "application/json"
|
|
631
|
+
};
|
|
632
|
+
var createConfig = /* @__PURE__ */ __name((override = {}) => ({
|
|
633
|
+
...jsonBodySerializer,
|
|
634
|
+
headers: defaultHeaders,
|
|
635
|
+
parseAs: "auto",
|
|
636
|
+
querySerializer: defaultQuerySerializer,
|
|
637
|
+
...override
|
|
638
|
+
}), "createConfig");
|
|
699
639
|
|
|
700
640
|
// src/_api/generated/client/client.gen.ts
|
|
701
|
-
var createClient
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
641
|
+
var createClient = /* @__PURE__ */ __name((config = {}) => {
|
|
642
|
+
let _config = mergeConfigs(createConfig(), config);
|
|
643
|
+
const getConfig = /* @__PURE__ */ __name(() => ({ ..._config }), "getConfig");
|
|
644
|
+
const setConfig = /* @__PURE__ */ __name((config2) => {
|
|
645
|
+
_config = mergeConfigs(_config, config2);
|
|
646
|
+
return getConfig();
|
|
647
|
+
}, "setConfig");
|
|
648
|
+
const interceptors = createInterceptors();
|
|
649
|
+
const beforeRequest = /* @__PURE__ */ __name(async (options) => {
|
|
650
|
+
const opts = {
|
|
651
|
+
..._config,
|
|
652
|
+
...options,
|
|
653
|
+
fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
|
|
654
|
+
headers: mergeHeaders(_config.headers, options.headers),
|
|
655
|
+
serializedBody: void 0
|
|
656
|
+
};
|
|
657
|
+
if (opts.security) {
|
|
658
|
+
await setAuthParams(opts);
|
|
659
|
+
}
|
|
660
|
+
if (opts.requestValidator) {
|
|
661
|
+
await opts.requestValidator(opts);
|
|
662
|
+
}
|
|
663
|
+
if (opts.body !== void 0 && opts.bodySerializer) {
|
|
664
|
+
opts.serializedBody = opts.bodySerializer(opts.body);
|
|
665
|
+
}
|
|
666
|
+
if (opts.body === void 0 || opts.serializedBody === "") {
|
|
667
|
+
opts.headers.delete("Content-Type");
|
|
668
|
+
}
|
|
669
|
+
const resolvedOpts = opts;
|
|
670
|
+
const url = buildUrl(resolvedOpts);
|
|
671
|
+
return { opts: resolvedOpts, url };
|
|
672
|
+
}, "beforeRequest");
|
|
673
|
+
const request = /* @__PURE__ */ __name(async (options) => {
|
|
674
|
+
const throwOnError = options.throwOnError ?? _config.throwOnError;
|
|
675
|
+
const responseStyle = options.responseStyle ?? _config.responseStyle;
|
|
676
|
+
let request2;
|
|
677
|
+
let response;
|
|
678
|
+
try {
|
|
679
|
+
const { opts, url } = await beforeRequest(options);
|
|
680
|
+
const requestInit = {
|
|
681
|
+
redirect: "follow",
|
|
682
|
+
...opts,
|
|
683
|
+
body: getValidRequestBody(opts)
|
|
684
|
+
};
|
|
685
|
+
request2 = new Request(url, requestInit);
|
|
686
|
+
for (const fn of interceptors.request.fns) {
|
|
687
|
+
if (fn) {
|
|
688
|
+
request2 = await fn(request2, opts);
|
|
731
689
|
}
|
|
732
|
-
|
|
733
|
-
|
|
690
|
+
}
|
|
691
|
+
const _fetch = opts.fetch;
|
|
692
|
+
response = await _fetch(request2);
|
|
693
|
+
for (const fn of interceptors.response.fns) {
|
|
694
|
+
if (fn) {
|
|
695
|
+
response = await fn(response, request2, opts);
|
|
734
696
|
}
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
const
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
if (fn) {
|
|
761
|
-
response = await fn(response, request2, opts);
|
|
762
|
-
}
|
|
697
|
+
}
|
|
698
|
+
const result = {
|
|
699
|
+
request: request2,
|
|
700
|
+
response
|
|
701
|
+
};
|
|
702
|
+
if (response.ok) {
|
|
703
|
+
const parseAs = (opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
|
|
704
|
+
if (response.status === 204 || response.headers.get("Content-Length") === "0") {
|
|
705
|
+
let emptyData;
|
|
706
|
+
switch (parseAs) {
|
|
707
|
+
case "arrayBuffer":
|
|
708
|
+
case "blob":
|
|
709
|
+
case "text":
|
|
710
|
+
emptyData = await response[parseAs]();
|
|
711
|
+
break;
|
|
712
|
+
case "formData":
|
|
713
|
+
emptyData = new FormData();
|
|
714
|
+
break;
|
|
715
|
+
case "stream":
|
|
716
|
+
emptyData = response.body;
|
|
717
|
+
break;
|
|
718
|
+
case "json":
|
|
719
|
+
default:
|
|
720
|
+
emptyData = {};
|
|
721
|
+
break;
|
|
763
722
|
}
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
723
|
+
return opts.responseStyle === "data" ? emptyData : {
|
|
724
|
+
data: emptyData,
|
|
725
|
+
...result
|
|
767
726
|
};
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
default:
|
|
786
|
-
emptyData = {};
|
|
787
|
-
break;
|
|
788
|
-
}
|
|
789
|
-
return opts.responseStyle === "data" ? emptyData : {
|
|
790
|
-
data: emptyData,
|
|
791
|
-
...result
|
|
792
|
-
};
|
|
793
|
-
}
|
|
794
|
-
let data;
|
|
795
|
-
switch (parseAs) {
|
|
796
|
-
case "arrayBuffer":
|
|
797
|
-
case "blob":
|
|
798
|
-
case "formData":
|
|
799
|
-
case "text":
|
|
800
|
-
data = await response[parseAs]();
|
|
801
|
-
break;
|
|
802
|
-
case "json": {
|
|
803
|
-
const text = await response.text();
|
|
804
|
-
data = text ? JSON.parse(text) : {};
|
|
805
|
-
break;
|
|
806
|
-
}
|
|
807
|
-
case "stream":
|
|
808
|
-
return opts.responseStyle === "data" ? response.body : {
|
|
809
|
-
data: response.body,
|
|
810
|
-
...result
|
|
811
|
-
};
|
|
812
|
-
}
|
|
813
|
-
if (parseAs === "json") {
|
|
814
|
-
if (opts.responseValidator) {
|
|
815
|
-
await opts.responseValidator(data);
|
|
816
|
-
}
|
|
817
|
-
if (opts.responseTransformer) {
|
|
818
|
-
data = await opts.responseTransformer(data);
|
|
819
|
-
}
|
|
820
|
-
}
|
|
821
|
-
return opts.responseStyle === "data" ? data : {
|
|
822
|
-
data,
|
|
727
|
+
}
|
|
728
|
+
let data;
|
|
729
|
+
switch (parseAs) {
|
|
730
|
+
case "arrayBuffer":
|
|
731
|
+
case "blob":
|
|
732
|
+
case "formData":
|
|
733
|
+
case "text":
|
|
734
|
+
data = await response[parseAs]();
|
|
735
|
+
break;
|
|
736
|
+
case "json": {
|
|
737
|
+
const text = await response.text();
|
|
738
|
+
data = text ? JSON.parse(text) : {};
|
|
739
|
+
break;
|
|
740
|
+
}
|
|
741
|
+
case "stream":
|
|
742
|
+
return opts.responseStyle === "data" ? response.body : {
|
|
743
|
+
data: response.body,
|
|
823
744
|
...result
|
|
824
745
|
};
|
|
746
|
+
}
|
|
747
|
+
if (parseAs === "json") {
|
|
748
|
+
if (opts.responseValidator) {
|
|
749
|
+
await opts.responseValidator(data);
|
|
825
750
|
}
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
try {
|
|
829
|
-
jsonError = JSON.parse(textError);
|
|
830
|
-
} catch {
|
|
831
|
-
}
|
|
832
|
-
throw jsonError ?? textError;
|
|
833
|
-
} catch (error) {
|
|
834
|
-
let finalError = error;
|
|
835
|
-
for (const fn of interceptors.error.fns) {
|
|
836
|
-
if (fn) {
|
|
837
|
-
finalError = await fn(finalError, response, request2, options);
|
|
838
|
-
}
|
|
839
|
-
}
|
|
840
|
-
finalError = finalError || {};
|
|
841
|
-
if (throwOnError) {
|
|
842
|
-
throw finalError;
|
|
751
|
+
if (opts.responseTransformer) {
|
|
752
|
+
data = await opts.responseTransformer(data);
|
|
843
753
|
}
|
|
844
|
-
return responseStyle === "data" ? void 0 : {
|
|
845
|
-
error: finalError,
|
|
846
|
-
request: request2,
|
|
847
|
-
response
|
|
848
|
-
};
|
|
849
754
|
}
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
return createSseClient({
|
|
855
|
-
...opts,
|
|
856
|
-
body: opts.body,
|
|
857
|
-
method,
|
|
858
|
-
onRequest: /* @__PURE__ */ __name(async (url2, init) => {
|
|
859
|
-
let request2 = new Request(url2, init);
|
|
860
|
-
for (const fn of interceptors.request.fns) {
|
|
861
|
-
if (fn) {
|
|
862
|
-
request2 = await fn(request2, opts);
|
|
863
|
-
}
|
|
864
|
-
}
|
|
865
|
-
return request2;
|
|
866
|
-
}, "onRequest"),
|
|
867
|
-
serializedBody: getValidRequestBody(opts),
|
|
868
|
-
url
|
|
869
|
-
});
|
|
870
|
-
}, "makeSseFn");
|
|
871
|
-
const _buildUrl = /* @__PURE__ */ __name((options) => buildUrl({ ..._config, ...options }), "_buildUrl");
|
|
872
|
-
return {
|
|
873
|
-
buildUrl: _buildUrl,
|
|
874
|
-
connect: makeMethodFn("CONNECT"),
|
|
875
|
-
delete: makeMethodFn("DELETE"),
|
|
876
|
-
get: makeMethodFn("GET"),
|
|
877
|
-
getConfig,
|
|
878
|
-
head: makeMethodFn("HEAD"),
|
|
879
|
-
interceptors,
|
|
880
|
-
options: makeMethodFn("OPTIONS"),
|
|
881
|
-
patch: makeMethodFn("PATCH"),
|
|
882
|
-
post: makeMethodFn("POST"),
|
|
883
|
-
put: makeMethodFn("PUT"),
|
|
884
|
-
request,
|
|
885
|
-
setConfig,
|
|
886
|
-
sse: {
|
|
887
|
-
connect: makeSseFn("CONNECT"),
|
|
888
|
-
delete: makeSseFn("DELETE"),
|
|
889
|
-
get: makeSseFn("GET"),
|
|
890
|
-
head: makeSseFn("HEAD"),
|
|
891
|
-
options: makeSseFn("OPTIONS"),
|
|
892
|
-
patch: makeSseFn("PATCH"),
|
|
893
|
-
post: makeSseFn("POST"),
|
|
894
|
-
put: makeSseFn("PUT"),
|
|
895
|
-
trace: makeSseFn("TRACE")
|
|
896
|
-
},
|
|
897
|
-
trace: makeMethodFn("TRACE")
|
|
898
|
-
};
|
|
899
|
-
}, "createClient");
|
|
900
|
-
}
|
|
901
|
-
});
|
|
902
|
-
|
|
903
|
-
// src/_api/generated/client/index.ts
|
|
904
|
-
var init_client = __esm({
|
|
905
|
-
"src/_api/generated/client/index.ts"() {
|
|
906
|
-
init_bodySerializer_gen();
|
|
907
|
-
init_params_gen();
|
|
908
|
-
init_queryKeySerializer_gen();
|
|
909
|
-
init_client_gen();
|
|
910
|
-
init_utils_gen2();
|
|
911
|
-
}
|
|
912
|
-
});
|
|
913
|
-
|
|
914
|
-
// src/_api/generated/helpers/errors.ts
|
|
915
|
-
var APIError;
|
|
916
|
-
var init_errors = __esm({
|
|
917
|
-
"src/_api/generated/helpers/errors.ts"() {
|
|
918
|
-
APIError = class extends Error {
|
|
919
|
-
constructor(statusCode, statusText, response, url, message) {
|
|
920
|
-
super(message || `HTTP ${statusCode}: ${statusText}`);
|
|
921
|
-
this.statusCode = statusCode;
|
|
922
|
-
this.statusText = statusText;
|
|
923
|
-
this.response = response;
|
|
924
|
-
this.url = url;
|
|
925
|
-
this.name = "APIError";
|
|
755
|
+
return opts.responseStyle === "data" ? data : {
|
|
756
|
+
data,
|
|
757
|
+
...result
|
|
758
|
+
};
|
|
926
759
|
}
|
|
927
|
-
|
|
928
|
-
|
|
760
|
+
const textError = await response.text();
|
|
761
|
+
let jsonError;
|
|
762
|
+
try {
|
|
763
|
+
jsonError = JSON.parse(textError);
|
|
764
|
+
} catch {
|
|
929
765
|
}
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
766
|
+
throw jsonError ?? textError;
|
|
767
|
+
} catch (error) {
|
|
768
|
+
let finalError = error;
|
|
769
|
+
for (const fn of interceptors.error.fns) {
|
|
770
|
+
if (fn) {
|
|
771
|
+
finalError = await fn(finalError, response, request2, options);
|
|
933
772
|
}
|
|
934
|
-
return null;
|
|
935
773
|
}
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
const fieldErrors = {};
|
|
940
|
-
for (const [key, value] of Object.entries(details)) {
|
|
941
|
-
if (Array.isArray(value)) fieldErrors[key] = value;
|
|
942
|
-
}
|
|
943
|
-
return Object.keys(fieldErrors).length > 0 ? fieldErrors : null;
|
|
774
|
+
finalError = finalError || {};
|
|
775
|
+
if (throwOnError) {
|
|
776
|
+
throw finalError;
|
|
944
777
|
}
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
778
|
+
return responseStyle === "data" ? void 0 : {
|
|
779
|
+
error: finalError,
|
|
780
|
+
request: request2,
|
|
781
|
+
response
|
|
782
|
+
};
|
|
783
|
+
}
|
|
784
|
+
}, "request");
|
|
785
|
+
const makeMethodFn = /* @__PURE__ */ __name((method) => (options) => request({ ...options, method }), "makeMethodFn");
|
|
786
|
+
const makeSseFn = /* @__PURE__ */ __name((method) => async (options) => {
|
|
787
|
+
const { opts, url } = await beforeRequest(options);
|
|
788
|
+
return createSseClient({
|
|
789
|
+
...opts,
|
|
790
|
+
body: opts.body,
|
|
791
|
+
method,
|
|
792
|
+
onRequest: /* @__PURE__ */ __name(async (url2, init) => {
|
|
793
|
+
let request2 = new Request(url2, init);
|
|
794
|
+
for (const fn of interceptors.request.fns) {
|
|
795
|
+
if (fn) {
|
|
796
|
+
request2 = await fn(request2, opts);
|
|
797
|
+
}
|
|
957
798
|
}
|
|
958
|
-
return
|
|
959
|
-
}
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
799
|
+
return request2;
|
|
800
|
+
}, "onRequest"),
|
|
801
|
+
serializedBody: getValidRequestBody(opts),
|
|
802
|
+
url
|
|
803
|
+
});
|
|
804
|
+
}, "makeSseFn");
|
|
805
|
+
const _buildUrl = /* @__PURE__ */ __name((options) => buildUrl({ ..._config, ...options }), "_buildUrl");
|
|
806
|
+
return {
|
|
807
|
+
buildUrl: _buildUrl,
|
|
808
|
+
connect: makeMethodFn("CONNECT"),
|
|
809
|
+
delete: makeMethodFn("DELETE"),
|
|
810
|
+
get: makeMethodFn("GET"),
|
|
811
|
+
getConfig,
|
|
812
|
+
head: makeMethodFn("HEAD"),
|
|
813
|
+
interceptors,
|
|
814
|
+
options: makeMethodFn("OPTIONS"),
|
|
815
|
+
patch: makeMethodFn("PATCH"),
|
|
816
|
+
post: makeMethodFn("POST"),
|
|
817
|
+
put: makeMethodFn("PUT"),
|
|
818
|
+
request,
|
|
819
|
+
setConfig,
|
|
820
|
+
sse: {
|
|
821
|
+
connect: makeSseFn("CONNECT"),
|
|
822
|
+
delete: makeSseFn("DELETE"),
|
|
823
|
+
get: makeSseFn("GET"),
|
|
824
|
+
head: makeSseFn("HEAD"),
|
|
825
|
+
options: makeSseFn("OPTIONS"),
|
|
826
|
+
patch: makeSseFn("PATCH"),
|
|
827
|
+
post: makeSseFn("POST"),
|
|
828
|
+
put: makeSseFn("PUT"),
|
|
829
|
+
trace: makeSseFn("TRACE")
|
|
830
|
+
},
|
|
831
|
+
trace: makeMethodFn("TRACE")
|
|
832
|
+
};
|
|
833
|
+
}, "createClient");
|
|
834
|
+
|
|
835
|
+
// src/_api/generated/helpers/errors.ts
|
|
836
|
+
var APIError = class extends Error {
|
|
837
|
+
constructor(statusCode, statusText, response, url, message) {
|
|
838
|
+
super(message || `HTTP ${statusCode}: ${statusText}`);
|
|
839
|
+
this.statusCode = statusCode;
|
|
840
|
+
this.statusText = statusText;
|
|
841
|
+
this.response = response;
|
|
842
|
+
this.url = url;
|
|
843
|
+
this.name = "APIError";
|
|
976
844
|
}
|
|
977
|
-
|
|
845
|
+
static {
|
|
846
|
+
__name(this, "APIError");
|
|
847
|
+
}
|
|
848
|
+
get details() {
|
|
849
|
+
if (typeof this.response === "object" && this.response !== null) {
|
|
850
|
+
return this.response;
|
|
851
|
+
}
|
|
852
|
+
return null;
|
|
853
|
+
}
|
|
854
|
+
get fieldErrors() {
|
|
855
|
+
const details = this.details;
|
|
856
|
+
if (!details) return null;
|
|
857
|
+
const fieldErrors = {};
|
|
858
|
+
for (const [key, value] of Object.entries(details)) {
|
|
859
|
+
if (Array.isArray(value)) fieldErrors[key] = value;
|
|
860
|
+
}
|
|
861
|
+
return Object.keys(fieldErrors).length > 0 ? fieldErrors : null;
|
|
862
|
+
}
|
|
863
|
+
get errorMessage() {
|
|
864
|
+
const details = this.details;
|
|
865
|
+
if (!details) return this.message;
|
|
866
|
+
if (details.detail) {
|
|
867
|
+
return Array.isArray(details.detail) ? details.detail.join(", ") : String(details.detail);
|
|
868
|
+
}
|
|
869
|
+
if (details.error) return String(details.error);
|
|
870
|
+
if (details.message) return String(details.message);
|
|
871
|
+
const fieldErrors = this.fieldErrors;
|
|
872
|
+
if (fieldErrors) {
|
|
873
|
+
const firstField = Object.keys(fieldErrors)[0];
|
|
874
|
+
if (firstField) return `${firstField}: ${fieldErrors[firstField]?.join(", ")}`;
|
|
875
|
+
}
|
|
876
|
+
return this.message;
|
|
877
|
+
}
|
|
878
|
+
get isValidationError() {
|
|
879
|
+
return this.statusCode === 400;
|
|
880
|
+
}
|
|
881
|
+
get isAuthError() {
|
|
882
|
+
return this.statusCode === 401;
|
|
883
|
+
}
|
|
884
|
+
get isPermissionError() {
|
|
885
|
+
return this.statusCode === 403;
|
|
886
|
+
}
|
|
887
|
+
get isNotFoundError() {
|
|
888
|
+
return this.statusCode === 404;
|
|
889
|
+
}
|
|
890
|
+
get isServerError() {
|
|
891
|
+
return this.statusCode >= 500 && this.statusCode < 600;
|
|
892
|
+
}
|
|
893
|
+
};
|
|
978
894
|
|
|
979
895
|
// src/_api/generated/helpers/auth.ts
|
|
896
|
+
var ACCESS_KEY = "cfg.access_token";
|
|
897
|
+
var REFRESH_KEY = "cfg.refresh_token";
|
|
898
|
+
var API_KEY_KEY = "cfg.api_key";
|
|
899
|
+
var isBrowser = typeof window !== "undefined";
|
|
900
|
+
var localStorageBackend = {
|
|
901
|
+
get(key) {
|
|
902
|
+
if (!isBrowser) return null;
|
|
903
|
+
try {
|
|
904
|
+
return window.localStorage.getItem(key);
|
|
905
|
+
} catch {
|
|
906
|
+
return null;
|
|
907
|
+
}
|
|
908
|
+
},
|
|
909
|
+
set(key, value) {
|
|
910
|
+
if (!isBrowser) return;
|
|
911
|
+
try {
|
|
912
|
+
if (value === null) window.localStorage.removeItem(key);
|
|
913
|
+
else window.localStorage.setItem(key, value);
|
|
914
|
+
} catch {
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
};
|
|
918
|
+
var COOKIE_MAX_AGE = 60 * 60 * 24 * 30;
|
|
919
|
+
var cookieBackend = {
|
|
920
|
+
get(key) {
|
|
921
|
+
if (!isBrowser) return null;
|
|
922
|
+
try {
|
|
923
|
+
const re = new RegExp(`(?:^|;\\s*)${encodeURIComponent(key)}=([^;]*)`);
|
|
924
|
+
const m = document.cookie.match(re);
|
|
925
|
+
return m ? decodeURIComponent(m[1]) : null;
|
|
926
|
+
} catch {
|
|
927
|
+
return null;
|
|
928
|
+
}
|
|
929
|
+
},
|
|
930
|
+
set(key, value) {
|
|
931
|
+
if (!isBrowser) return;
|
|
932
|
+
try {
|
|
933
|
+
const k = encodeURIComponent(key);
|
|
934
|
+
const secure = window.location.protocol === "https:" ? "; Secure" : "";
|
|
935
|
+
if (value === null) {
|
|
936
|
+
document.cookie = `${k}=; Path=/; Max-Age=0; SameSite=Lax${secure}`;
|
|
937
|
+
} else {
|
|
938
|
+
const v = encodeURIComponent(value);
|
|
939
|
+
document.cookie = `${k}=${v}; Path=/; Max-Age=${COOKIE_MAX_AGE}; SameSite=Lax${secure}`;
|
|
940
|
+
}
|
|
941
|
+
} catch {
|
|
942
|
+
}
|
|
943
|
+
}
|
|
944
|
+
};
|
|
945
|
+
var _storage = localStorageBackend;
|
|
946
|
+
var _storageMode = "localStorage";
|
|
980
947
|
function detectLocale() {
|
|
981
948
|
try {
|
|
982
949
|
if (typeof document !== "undefined") {
|
|
@@ -990,6 +957,7 @@ function detectLocale() {
|
|
|
990
957
|
}
|
|
991
958
|
return null;
|
|
992
959
|
}
|
|
960
|
+
__name(detectLocale, "detectLocale");
|
|
993
961
|
function defaultBaseUrl() {
|
|
994
962
|
if (typeof window !== "undefined") {
|
|
995
963
|
try {
|
|
@@ -1012,6 +980,7 @@ function defaultBaseUrl() {
|
|
|
1012
980
|
}
|
|
1013
981
|
return "";
|
|
1014
982
|
}
|
|
983
|
+
__name(defaultBaseUrl, "defaultBaseUrl");
|
|
1015
984
|
function defaultApiKey() {
|
|
1016
985
|
try {
|
|
1017
986
|
if (typeof process !== "undefined" && process.env?.NEXT_PUBLIC_API_KEY) {
|
|
@@ -1021,6 +990,15 @@ function defaultApiKey() {
|
|
|
1021
990
|
}
|
|
1022
991
|
return null;
|
|
1023
992
|
}
|
|
993
|
+
__name(defaultApiKey, "defaultApiKey");
|
|
994
|
+
var _localeOverride = null;
|
|
995
|
+
var _apiKeyOverride = null;
|
|
996
|
+
var _baseUrlOverride = null;
|
|
997
|
+
var _withCredentials = true;
|
|
998
|
+
var _onUnauthorized = null;
|
|
999
|
+
var _refreshHandler = null;
|
|
1000
|
+
var _refreshInflight = null;
|
|
1001
|
+
var RETRY_MARKER = "X-Auth-Retry";
|
|
1024
1002
|
function jwtExpMs(token) {
|
|
1025
1003
|
try {
|
|
1026
1004
|
const payload = token.split(".")[1];
|
|
@@ -1031,6 +1009,7 @@ function jwtExpMs(token) {
|
|
|
1031
1009
|
return null;
|
|
1032
1010
|
}
|
|
1033
1011
|
}
|
|
1012
|
+
__name(jwtExpMs, "jwtExpMs");
|
|
1034
1013
|
function computeSnapshot() {
|
|
1035
1014
|
const access = _storage.get(ACCESS_KEY);
|
|
1036
1015
|
const refresh = _storage.get(REFRESH_KEY);
|
|
@@ -1044,6 +1023,13 @@ function computeSnapshot() {
|
|
|
1044
1023
|
accessExpiresAt: accessExp
|
|
1045
1024
|
};
|
|
1046
1025
|
}
|
|
1026
|
+
__name(computeSnapshot, "computeSnapshot");
|
|
1027
|
+
var SERVER_SNAPSHOT = { status: "anonymous", accessExpiresAt: null };
|
|
1028
|
+
var SESSION_SYNC_EVENT = `cfg-auth:changed:${ACCESS_KEY}`;
|
|
1029
|
+
var _snapshot = computeSnapshot();
|
|
1030
|
+
var _sessionListeners = /* @__PURE__ */ new Set();
|
|
1031
|
+
var _expiryTimer = null;
|
|
1032
|
+
var _storageListenerInstalled = false;
|
|
1047
1033
|
function scheduleExpiryFlip() {
|
|
1048
1034
|
if (!isBrowser) return;
|
|
1049
1035
|
if (_expiryTimer !== null) {
|
|
@@ -1063,6 +1049,7 @@ function scheduleExpiryFlip() {
|
|
|
1063
1049
|
const delay = Math.min(Math.min(...exps) - now + 250, 2147483647);
|
|
1064
1050
|
_expiryTimer = setTimeout(notifySessionChanged, delay);
|
|
1065
1051
|
}
|
|
1052
|
+
__name(scheduleExpiryFlip, "scheduleExpiryFlip");
|
|
1066
1053
|
function notifySessionChanged() {
|
|
1067
1054
|
const next = computeSnapshot();
|
|
1068
1055
|
const changed = next.status !== _snapshot.status || next.accessExpiresAt !== _snapshot.accessExpiresAt;
|
|
@@ -1082,6 +1069,7 @@ function notifySessionChanged() {
|
|
|
1082
1069
|
}
|
|
1083
1070
|
}
|
|
1084
1071
|
}
|
|
1072
|
+
__name(notifySessionChanged, "notifySessionChanged");
|
|
1085
1073
|
function ensureStorageSync() {
|
|
1086
1074
|
if (!isBrowser || _storageListenerInstalled) return;
|
|
1087
1075
|
_storageListenerInstalled = true;
|
|
@@ -1092,6 +1080,9 @@ function ensureStorageSync() {
|
|
|
1092
1080
|
});
|
|
1093
1081
|
window.addEventListener(SESSION_SYNC_EVENT, () => notifySessionChanged());
|
|
1094
1082
|
}
|
|
1083
|
+
__name(ensureStorageSync, "ensureStorageSync");
|
|
1084
|
+
var _sessionExpiredHandlers = /* @__PURE__ */ new Set();
|
|
1085
|
+
var _client = null;
|
|
1095
1086
|
function pushClientConfig() {
|
|
1096
1087
|
if (!_client) return;
|
|
1097
1088
|
_client.setConfig({
|
|
@@ -1099,6 +1090,174 @@ function pushClientConfig() {
|
|
|
1099
1090
|
credentials: _withCredentials ? "include" : "same-origin"
|
|
1100
1091
|
});
|
|
1101
1092
|
}
|
|
1093
|
+
__name(pushClientConfig, "pushClientConfig");
|
|
1094
|
+
var auth = {
|
|
1095
|
+
// ── Storage mode ──────────────────────────────────────────────────
|
|
1096
|
+
getStorageMode() {
|
|
1097
|
+
return _storageMode;
|
|
1098
|
+
},
|
|
1099
|
+
setStorageMode(mode) {
|
|
1100
|
+
_storageMode = mode;
|
|
1101
|
+
_storage = mode === "cookie" ? cookieBackend : localStorageBackend;
|
|
1102
|
+
notifySessionChanged();
|
|
1103
|
+
},
|
|
1104
|
+
// ── Bearer token ──────────────────────────────────────────────────
|
|
1105
|
+
getToken() {
|
|
1106
|
+
return _storage.get(ACCESS_KEY);
|
|
1107
|
+
},
|
|
1108
|
+
setToken(token) {
|
|
1109
|
+
_storage.set(ACCESS_KEY, token);
|
|
1110
|
+
notifySessionChanged();
|
|
1111
|
+
},
|
|
1112
|
+
getRefreshToken() {
|
|
1113
|
+
return _storage.get(REFRESH_KEY);
|
|
1114
|
+
},
|
|
1115
|
+
setRefreshToken(token) {
|
|
1116
|
+
_storage.set(REFRESH_KEY, token);
|
|
1117
|
+
notifySessionChanged();
|
|
1118
|
+
},
|
|
1119
|
+
clearTokens() {
|
|
1120
|
+
_storage.set(ACCESS_KEY, null);
|
|
1121
|
+
_storage.set(REFRESH_KEY, null);
|
|
1122
|
+
notifySessionChanged();
|
|
1123
|
+
},
|
|
1124
|
+
/** Session-aware: token PRESENT and not past its `exp` (or a live refresh
|
|
1125
|
+
* token exists that can mint one). Prefer `getSnapshot().status` in React. */
|
|
1126
|
+
isAuthenticated() {
|
|
1127
|
+
return computeSnapshot().status === "authenticated";
|
|
1128
|
+
},
|
|
1129
|
+
// ── Session (the ONE write path for login/logout flows) ──────────
|
|
1130
|
+
/**
|
|
1131
|
+
* Persist a token pair atomically. Every login flow (OTP verify, 2FA,
|
|
1132
|
+
* OAuth callback) and the refresh handler should end here — do NOT
|
|
1133
|
+
* scatter `setToken`/`setRefreshToken` pairs through app code.
|
|
1134
|
+
* `refresh: undefined` keeps the current refresh token (access-only
|
|
1135
|
+
* rotation); `refresh: null` explicitly drops it.
|
|
1136
|
+
*/
|
|
1137
|
+
setSession(tokens) {
|
|
1138
|
+
_storage.set(ACCESS_KEY, tokens.access);
|
|
1139
|
+
if (tokens.refresh !== void 0) _storage.set(REFRESH_KEY, tokens.refresh);
|
|
1140
|
+
notifySessionChanged();
|
|
1141
|
+
},
|
|
1142
|
+
clearSession() {
|
|
1143
|
+
auth.clearTokens();
|
|
1144
|
+
},
|
|
1145
|
+
// ── Reactive snapshot (for useSyncExternalStore) ──────────────────
|
|
1146
|
+
/**
|
|
1147
|
+
* @example React:
|
|
1148
|
+
* const session = useSyncExternalStore(
|
|
1149
|
+
* auth.subscribe, auth.getSnapshot, auth.getServerSnapshot,
|
|
1150
|
+
* );
|
|
1151
|
+
* const isAuthenticated = session.status === 'authenticated';
|
|
1152
|
+
*/
|
|
1153
|
+
getSnapshot() {
|
|
1154
|
+
return _snapshot;
|
|
1155
|
+
},
|
|
1156
|
+
getServerSnapshot() {
|
|
1157
|
+
return SERVER_SNAPSHOT;
|
|
1158
|
+
},
|
|
1159
|
+
subscribe(listener) {
|
|
1160
|
+
ensureStorageSync();
|
|
1161
|
+
_sessionListeners.add(listener);
|
|
1162
|
+
notifySessionChanged();
|
|
1163
|
+
return () => {
|
|
1164
|
+
_sessionListeners.delete(listener);
|
|
1165
|
+
if (_sessionListeners.size === 0 && _expiryTimer !== null) {
|
|
1166
|
+
clearTimeout(_expiryTimer);
|
|
1167
|
+
_expiryTimer = null;
|
|
1168
|
+
}
|
|
1169
|
+
};
|
|
1170
|
+
},
|
|
1171
|
+
/**
|
|
1172
|
+
* Fired on TERMINAL 401 — after the refresh+retry path is exhausted.
|
|
1173
|
+
* The store has already cleared the session before calling back, so
|
|
1174
|
+
* handlers only need to route to login (no clear-then-redirect
|
|
1175
|
+
* ordering to get wrong). Returns an unsubscribe function; multiple
|
|
1176
|
+
* handlers compose (unlike the legacy single-slot `onUnauthorized`).
|
|
1177
|
+
*/
|
|
1178
|
+
onSessionExpired(cb) {
|
|
1179
|
+
_sessionExpiredHandlers.add(cb);
|
|
1180
|
+
return () => {
|
|
1181
|
+
_sessionExpiredHandlers.delete(cb);
|
|
1182
|
+
};
|
|
1183
|
+
},
|
|
1184
|
+
// ── API key ───────────────────────────────────────────────────────
|
|
1185
|
+
getApiKey() {
|
|
1186
|
+
return _apiKeyOverride ?? _storage.get(API_KEY_KEY) ?? defaultApiKey();
|
|
1187
|
+
},
|
|
1188
|
+
setApiKey(key) {
|
|
1189
|
+
_apiKeyOverride = key;
|
|
1190
|
+
},
|
|
1191
|
+
setApiKeyPersist(key) {
|
|
1192
|
+
_apiKeyOverride = key;
|
|
1193
|
+
_storage.set(API_KEY_KEY, key);
|
|
1194
|
+
},
|
|
1195
|
+
clearApiKey() {
|
|
1196
|
+
_apiKeyOverride = null;
|
|
1197
|
+
_storage.set(API_KEY_KEY, null);
|
|
1198
|
+
},
|
|
1199
|
+
// ── Locale ────────────────────────────────────────────────────────
|
|
1200
|
+
getLocale() {
|
|
1201
|
+
return _localeOverride ?? detectLocale();
|
|
1202
|
+
},
|
|
1203
|
+
setLocale(locale) {
|
|
1204
|
+
_localeOverride = locale;
|
|
1205
|
+
},
|
|
1206
|
+
// ── Base URL ──────────────────────────────────────────────────────
|
|
1207
|
+
getBaseUrl() {
|
|
1208
|
+
const url = _baseUrlOverride ?? defaultBaseUrl();
|
|
1209
|
+
return url.replace(/\/$/, "");
|
|
1210
|
+
},
|
|
1211
|
+
setBaseUrl(url) {
|
|
1212
|
+
_baseUrlOverride = url ? url.replace(/\/$/, "") : null;
|
|
1213
|
+
pushClientConfig();
|
|
1214
|
+
},
|
|
1215
|
+
// ── Credentials toggle ────────────────────────────────────────────
|
|
1216
|
+
getWithCredentials() {
|
|
1217
|
+
return _withCredentials;
|
|
1218
|
+
},
|
|
1219
|
+
setWithCredentials(value) {
|
|
1220
|
+
_withCredentials = value;
|
|
1221
|
+
pushClientConfig();
|
|
1222
|
+
},
|
|
1223
|
+
// ── 401 handler ───────────────────────────────────────────────────
|
|
1224
|
+
/**
|
|
1225
|
+
* Fired when the server returns 401 AND no refresh path recovers it
|
|
1226
|
+
* (no refresh token, no refresh handler, refresh failed, or retry
|
|
1227
|
+
* still 401). The app should clear local state and redirect to login.
|
|
1228
|
+
*
|
|
1229
|
+
* NOT fired for 401 that gets transparently recovered by the refresh
|
|
1230
|
+
* handler — those are invisible to callers.
|
|
1231
|
+
*/
|
|
1232
|
+
onUnauthorized(cb) {
|
|
1233
|
+
_onUnauthorized = cb;
|
|
1234
|
+
},
|
|
1235
|
+
/**
|
|
1236
|
+
* Register the refresh strategy. The handler receives the current
|
|
1237
|
+
* refresh token and must call your refresh endpoint, returning
|
|
1238
|
+
* `{ access, refresh? }` on success or `null` on failure.
|
|
1239
|
+
*
|
|
1240
|
+
* @example
|
|
1241
|
+
* auth.setRefreshHandler(async (refresh) => {
|
|
1242
|
+
* const { data } = await Auth.tokenRefreshCreate({ body: { refresh } });
|
|
1243
|
+
* return data ? { access: data.access, refresh: data.refresh } : null;
|
|
1244
|
+
* });
|
|
1245
|
+
*/
|
|
1246
|
+
setRefreshHandler(fn) {
|
|
1247
|
+
_refreshHandler = fn;
|
|
1248
|
+
},
|
|
1249
|
+
/**
|
|
1250
|
+
* Proactively run the registered refresh handler right now, reusing the
|
|
1251
|
+
* SAME single-flight promise as the 401-recovery interceptor. Callers
|
|
1252
|
+
* (e.g. an expiry timer / focus / reconnect) get token rotation,
|
|
1253
|
+
* de-duplication and rotated-token persistence for free — they must NOT
|
|
1254
|
+
* re-implement any of it. Returns the fresh access token, or null if
|
|
1255
|
+
* there is no handler / no refresh token / the refresh failed.
|
|
1256
|
+
*/
|
|
1257
|
+
refreshNow() {
|
|
1258
|
+
return tryRefresh();
|
|
1259
|
+
}
|
|
1260
|
+
};
|
|
1102
1261
|
async function tryRefresh() {
|
|
1103
1262
|
if (_refreshInflight) return _refreshInflight;
|
|
1104
1263
|
if (!_refreshHandler) return null;
|
|
@@ -1126,6 +1285,7 @@ async function tryRefresh() {
|
|
|
1126
1285
|
})();
|
|
1127
1286
|
return _refreshInflight;
|
|
1128
1287
|
}
|
|
1288
|
+
__name(tryRefresh, "tryRefresh");
|
|
1129
1289
|
function expireSession(response) {
|
|
1130
1290
|
auth.clearTokens();
|
|
1131
1291
|
for (const cb of Array.from(_sessionExpiredHandlers)) {
|
|
@@ -1141,6 +1301,7 @@ function expireSession(response) {
|
|
|
1141
1301
|
}
|
|
1142
1302
|
}
|
|
1143
1303
|
}
|
|
1304
|
+
__name(expireSession, "expireSession");
|
|
1144
1305
|
function dpopEnabled() {
|
|
1145
1306
|
try {
|
|
1146
1307
|
return typeof process !== "undefined" && process.env?.NEXT_PUBLIC_DPOP_ENABLED === "true";
|
|
@@ -1148,6 +1309,10 @@ function dpopEnabled() {
|
|
|
1148
1309
|
return false;
|
|
1149
1310
|
}
|
|
1150
1311
|
}
|
|
1312
|
+
__name(dpopEnabled, "dpopEnabled");
|
|
1313
|
+
var _DPOP_DB = "cfg-auth";
|
|
1314
|
+
var _DPOP_STORE = "keys";
|
|
1315
|
+
var _DPOP_KEY_ID = "dpop-ec-p256";
|
|
1151
1316
|
function _idbOpen() {
|
|
1152
1317
|
return new Promise((resolve, reject) => {
|
|
1153
1318
|
const req = indexedDB.open(_DPOP_DB, 1);
|
|
@@ -1156,6 +1321,7 @@ function _idbOpen() {
|
|
|
1156
1321
|
req.onerror = () => reject(req.error);
|
|
1157
1322
|
});
|
|
1158
1323
|
}
|
|
1324
|
+
__name(_idbOpen, "_idbOpen");
|
|
1159
1325
|
function _idbGet(key) {
|
|
1160
1326
|
return _idbOpen().then((db) => new Promise((resolve, reject) => {
|
|
1161
1327
|
const tx = db.transaction(_DPOP_STORE, "readonly");
|
|
@@ -1164,6 +1330,7 @@ function _idbGet(key) {
|
|
|
1164
1330
|
req.onerror = () => reject(req.error);
|
|
1165
1331
|
}));
|
|
1166
1332
|
}
|
|
1333
|
+
__name(_idbGet, "_idbGet");
|
|
1167
1334
|
function _idbPut(key, value) {
|
|
1168
1335
|
return _idbOpen().then((db) => new Promise((resolve, reject) => {
|
|
1169
1336
|
const tx = db.transaction(_DPOP_STORE, "readwrite");
|
|
@@ -1172,6 +1339,8 @@ function _idbPut(key, value) {
|
|
|
1172
1339
|
tx.onerror = () => reject(tx.error);
|
|
1173
1340
|
}));
|
|
1174
1341
|
}
|
|
1342
|
+
__name(_idbPut, "_idbPut");
|
|
1343
|
+
var _dpopKeyPromise = null;
|
|
1175
1344
|
function _getDpopKeyPair() {
|
|
1176
1345
|
if (_dpopKeyPromise) return _dpopKeyPromise;
|
|
1177
1346
|
_dpopKeyPromise = (async () => {
|
|
@@ -1189,19 +1358,23 @@ function _getDpopKeyPair() {
|
|
|
1189
1358
|
})();
|
|
1190
1359
|
return _dpopKeyPromise;
|
|
1191
1360
|
}
|
|
1361
|
+
__name(_getDpopKeyPair, "_getDpopKeyPair");
|
|
1192
1362
|
function _b64urlFromBytes(bytes) {
|
|
1193
1363
|
const arr = bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes);
|
|
1194
1364
|
let s = "";
|
|
1195
1365
|
for (let i = 0; i < arr.length; i++) s += String.fromCharCode(arr[i]);
|
|
1196
1366
|
return btoa(s).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
1197
1367
|
}
|
|
1368
|
+
__name(_b64urlFromBytes, "_b64urlFromBytes");
|
|
1198
1369
|
function _b64urlFromString(str) {
|
|
1199
1370
|
return _b64urlFromBytes(new TextEncoder().encode(str));
|
|
1200
1371
|
}
|
|
1372
|
+
__name(_b64urlFromString, "_b64urlFromString");
|
|
1201
1373
|
async function _publicJwk(pub) {
|
|
1202
1374
|
const jwk = await crypto.subtle.exportKey("jwk", pub);
|
|
1203
1375
|
return { kty: "EC", crv: "P-256", x: jwk.x, y: jwk.y };
|
|
1204
1376
|
}
|
|
1377
|
+
__name(_publicJwk, "_publicJwk");
|
|
1205
1378
|
async function _makeDpopProof(method, url) {
|
|
1206
1379
|
try {
|
|
1207
1380
|
const pair = await _getDpopKeyPair();
|
|
@@ -1221,6 +1394,7 @@ async function _makeDpopProof(method, url) {
|
|
|
1221
1394
|
return null;
|
|
1222
1395
|
}
|
|
1223
1396
|
}
|
|
1397
|
+
__name(_makeDpopProof, "_makeDpopProof");
|
|
1224
1398
|
function installAuthOnClient(client2) {
|
|
1225
1399
|
if (_client) return;
|
|
1226
1400
|
_client = client2;
|
|
@@ -1281,949 +1455,132 @@ function installAuthOnClient(client2) {
|
|
|
1281
1455
|
}
|
|
1282
1456
|
});
|
|
1283
1457
|
}
|
|
1284
|
-
|
|
1285
|
-
var
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
}
|
|
1300
|
-
},
|
|
1301
|
-
set(key, value) {
|
|
1302
|
-
if (!isBrowser) return;
|
|
1303
|
-
try {
|
|
1304
|
-
if (value === null) window.localStorage.removeItem(key);
|
|
1305
|
-
else window.localStorage.setItem(key, value);
|
|
1306
|
-
} catch {
|
|
1307
|
-
}
|
|
1308
|
-
}
|
|
1309
|
-
};
|
|
1310
|
-
COOKIE_MAX_AGE = 60 * 60 * 24 * 30;
|
|
1311
|
-
cookieBackend = {
|
|
1312
|
-
get(key) {
|
|
1313
|
-
if (!isBrowser) return null;
|
|
1314
|
-
try {
|
|
1315
|
-
const re = new RegExp(`(?:^|;\\s*)${encodeURIComponent(key)}=([^;]*)`);
|
|
1316
|
-
const m = document.cookie.match(re);
|
|
1317
|
-
return m ? decodeURIComponent(m[1]) : null;
|
|
1318
|
-
} catch {
|
|
1319
|
-
return null;
|
|
1320
|
-
}
|
|
1321
|
-
},
|
|
1322
|
-
set(key, value) {
|
|
1323
|
-
if (!isBrowser) return;
|
|
1324
|
-
try {
|
|
1325
|
-
const k = encodeURIComponent(key);
|
|
1326
|
-
const secure = window.location.protocol === "https:" ? "; Secure" : "";
|
|
1327
|
-
if (value === null) {
|
|
1328
|
-
document.cookie = `${k}=; Path=/; Max-Age=0; SameSite=Lax${secure}`;
|
|
1329
|
-
} else {
|
|
1330
|
-
const v = encodeURIComponent(value);
|
|
1331
|
-
document.cookie = `${k}=${v}; Path=/; Max-Age=${COOKIE_MAX_AGE}; SameSite=Lax${secure}`;
|
|
1332
|
-
}
|
|
1333
|
-
} catch {
|
|
1334
|
-
}
|
|
1335
|
-
}
|
|
1336
|
-
};
|
|
1337
|
-
_storage = localStorageBackend;
|
|
1338
|
-
_storageMode = "localStorage";
|
|
1339
|
-
__name(detectLocale, "detectLocale");
|
|
1340
|
-
__name(defaultBaseUrl, "defaultBaseUrl");
|
|
1341
|
-
__name(defaultApiKey, "defaultApiKey");
|
|
1342
|
-
_localeOverride = null;
|
|
1343
|
-
_apiKeyOverride = null;
|
|
1344
|
-
_baseUrlOverride = null;
|
|
1345
|
-
_withCredentials = true;
|
|
1346
|
-
_onUnauthorized = null;
|
|
1347
|
-
_refreshHandler = null;
|
|
1348
|
-
_refreshInflight = null;
|
|
1349
|
-
RETRY_MARKER = "X-Auth-Retry";
|
|
1350
|
-
__name(jwtExpMs, "jwtExpMs");
|
|
1351
|
-
__name(computeSnapshot, "computeSnapshot");
|
|
1352
|
-
SERVER_SNAPSHOT = { status: "anonymous", accessExpiresAt: null };
|
|
1353
|
-
SESSION_SYNC_EVENT = `cfg-auth:changed:${ACCESS_KEY}`;
|
|
1354
|
-
_snapshot = computeSnapshot();
|
|
1355
|
-
_sessionListeners = /* @__PURE__ */ new Set();
|
|
1356
|
-
_expiryTimer = null;
|
|
1357
|
-
_storageListenerInstalled = false;
|
|
1358
|
-
__name(scheduleExpiryFlip, "scheduleExpiryFlip");
|
|
1359
|
-
__name(notifySessionChanged, "notifySessionChanged");
|
|
1360
|
-
__name(ensureStorageSync, "ensureStorageSync");
|
|
1361
|
-
_sessionExpiredHandlers = /* @__PURE__ */ new Set();
|
|
1362
|
-
_client = null;
|
|
1363
|
-
__name(pushClientConfig, "pushClientConfig");
|
|
1364
|
-
auth = {
|
|
1365
|
-
// ── Storage mode ──────────────────────────────────────────────────
|
|
1366
|
-
getStorageMode() {
|
|
1367
|
-
return _storageMode;
|
|
1368
|
-
},
|
|
1369
|
-
setStorageMode(mode) {
|
|
1370
|
-
_storageMode = mode;
|
|
1371
|
-
_storage = mode === "cookie" ? cookieBackend : localStorageBackend;
|
|
1372
|
-
notifySessionChanged();
|
|
1373
|
-
},
|
|
1374
|
-
// ── Bearer token ──────────────────────────────────────────────────
|
|
1375
|
-
getToken() {
|
|
1376
|
-
return _storage.get(ACCESS_KEY);
|
|
1377
|
-
},
|
|
1378
|
-
setToken(token) {
|
|
1379
|
-
_storage.set(ACCESS_KEY, token);
|
|
1380
|
-
notifySessionChanged();
|
|
1381
|
-
},
|
|
1382
|
-
getRefreshToken() {
|
|
1383
|
-
return _storage.get(REFRESH_KEY);
|
|
1384
|
-
},
|
|
1385
|
-
setRefreshToken(token) {
|
|
1386
|
-
_storage.set(REFRESH_KEY, token);
|
|
1387
|
-
notifySessionChanged();
|
|
1388
|
-
},
|
|
1389
|
-
clearTokens() {
|
|
1390
|
-
_storage.set(ACCESS_KEY, null);
|
|
1391
|
-
_storage.set(REFRESH_KEY, null);
|
|
1392
|
-
notifySessionChanged();
|
|
1393
|
-
},
|
|
1394
|
-
/** Session-aware: token PRESENT and not past its `exp` (or a live refresh
|
|
1395
|
-
* token exists that can mint one). Prefer `getSnapshot().status` in React. */
|
|
1396
|
-
isAuthenticated() {
|
|
1397
|
-
return computeSnapshot().status === "authenticated";
|
|
1398
|
-
},
|
|
1399
|
-
// ── Session (the ONE write path for login/logout flows) ──────────
|
|
1400
|
-
/**
|
|
1401
|
-
* Persist a token pair atomically. Every login flow (OTP verify, 2FA,
|
|
1402
|
-
* OAuth callback) and the refresh handler should end here — do NOT
|
|
1403
|
-
* scatter `setToken`/`setRefreshToken` pairs through app code.
|
|
1404
|
-
* `refresh: undefined` keeps the current refresh token (access-only
|
|
1405
|
-
* rotation); `refresh: null` explicitly drops it.
|
|
1406
|
-
*/
|
|
1407
|
-
setSession(tokens) {
|
|
1408
|
-
_storage.set(ACCESS_KEY, tokens.access);
|
|
1409
|
-
if (tokens.refresh !== void 0) _storage.set(REFRESH_KEY, tokens.refresh);
|
|
1410
|
-
notifySessionChanged();
|
|
1411
|
-
},
|
|
1412
|
-
clearSession() {
|
|
1413
|
-
auth.clearTokens();
|
|
1414
|
-
},
|
|
1415
|
-
// ── Reactive snapshot (for useSyncExternalStore) ──────────────────
|
|
1416
|
-
/**
|
|
1417
|
-
* @example React:
|
|
1418
|
-
* const session = useSyncExternalStore(
|
|
1419
|
-
* auth.subscribe, auth.getSnapshot, auth.getServerSnapshot,
|
|
1420
|
-
* );
|
|
1421
|
-
* const isAuthenticated = session.status === 'authenticated';
|
|
1422
|
-
*/
|
|
1423
|
-
getSnapshot() {
|
|
1424
|
-
return _snapshot;
|
|
1425
|
-
},
|
|
1426
|
-
getServerSnapshot() {
|
|
1427
|
-
return SERVER_SNAPSHOT;
|
|
1428
|
-
},
|
|
1429
|
-
subscribe(listener) {
|
|
1430
|
-
ensureStorageSync();
|
|
1431
|
-
_sessionListeners.add(listener);
|
|
1432
|
-
notifySessionChanged();
|
|
1433
|
-
return () => {
|
|
1434
|
-
_sessionListeners.delete(listener);
|
|
1435
|
-
if (_sessionListeners.size === 0 && _expiryTimer !== null) {
|
|
1436
|
-
clearTimeout(_expiryTimer);
|
|
1437
|
-
_expiryTimer = null;
|
|
1438
|
-
}
|
|
1439
|
-
};
|
|
1440
|
-
},
|
|
1441
|
-
/**
|
|
1442
|
-
* Fired on TERMINAL 401 — after the refresh+retry path is exhausted.
|
|
1443
|
-
* The store has already cleared the session before calling back, so
|
|
1444
|
-
* handlers only need to route to login (no clear-then-redirect
|
|
1445
|
-
* ordering to get wrong). Returns an unsubscribe function; multiple
|
|
1446
|
-
* handlers compose (unlike the legacy single-slot `onUnauthorized`).
|
|
1447
|
-
*/
|
|
1448
|
-
onSessionExpired(cb) {
|
|
1449
|
-
_sessionExpiredHandlers.add(cb);
|
|
1450
|
-
return () => {
|
|
1451
|
-
_sessionExpiredHandlers.delete(cb);
|
|
1452
|
-
};
|
|
1453
|
-
},
|
|
1454
|
-
// ── API key ───────────────────────────────────────────────────────
|
|
1455
|
-
getApiKey() {
|
|
1456
|
-
return _apiKeyOverride ?? _storage.get(API_KEY_KEY) ?? defaultApiKey();
|
|
1457
|
-
},
|
|
1458
|
-
setApiKey(key) {
|
|
1459
|
-
_apiKeyOverride = key;
|
|
1460
|
-
},
|
|
1461
|
-
setApiKeyPersist(key) {
|
|
1462
|
-
_apiKeyOverride = key;
|
|
1463
|
-
_storage.set(API_KEY_KEY, key);
|
|
1464
|
-
},
|
|
1465
|
-
clearApiKey() {
|
|
1466
|
-
_apiKeyOverride = null;
|
|
1467
|
-
_storage.set(API_KEY_KEY, null);
|
|
1468
|
-
},
|
|
1469
|
-
// ── Locale ────────────────────────────────────────────────────────
|
|
1470
|
-
getLocale() {
|
|
1471
|
-
return _localeOverride ?? detectLocale();
|
|
1472
|
-
},
|
|
1473
|
-
setLocale(locale) {
|
|
1474
|
-
_localeOverride = locale;
|
|
1475
|
-
},
|
|
1476
|
-
// ── Base URL ──────────────────────────────────────────────────────
|
|
1477
|
-
getBaseUrl() {
|
|
1478
|
-
const url = _baseUrlOverride ?? defaultBaseUrl();
|
|
1479
|
-
return url.replace(/\/$/, "");
|
|
1480
|
-
},
|
|
1481
|
-
setBaseUrl(url) {
|
|
1482
|
-
_baseUrlOverride = url ? url.replace(/\/$/, "") : null;
|
|
1483
|
-
pushClientConfig();
|
|
1484
|
-
},
|
|
1485
|
-
// ── Credentials toggle ────────────────────────────────────────────
|
|
1486
|
-
getWithCredentials() {
|
|
1487
|
-
return _withCredentials;
|
|
1488
|
-
},
|
|
1489
|
-
setWithCredentials(value) {
|
|
1490
|
-
_withCredentials = value;
|
|
1491
|
-
pushClientConfig();
|
|
1492
|
-
},
|
|
1493
|
-
// ── 401 handler ───────────────────────────────────────────────────
|
|
1494
|
-
/**
|
|
1495
|
-
* Fired when the server returns 401 AND no refresh path recovers it
|
|
1496
|
-
* (no refresh token, no refresh handler, refresh failed, or retry
|
|
1497
|
-
* still 401). The app should clear local state and redirect to login.
|
|
1498
|
-
*
|
|
1499
|
-
* NOT fired for 401 that gets transparently recovered by the refresh
|
|
1500
|
-
* handler — those are invisible to callers.
|
|
1501
|
-
*/
|
|
1502
|
-
onUnauthorized(cb) {
|
|
1503
|
-
_onUnauthorized = cb;
|
|
1504
|
-
},
|
|
1505
|
-
/**
|
|
1506
|
-
* Register the refresh strategy. The handler receives the current
|
|
1507
|
-
* refresh token and must call your refresh endpoint, returning
|
|
1508
|
-
* `{ access, refresh? }` on success or `null` on failure.
|
|
1509
|
-
*
|
|
1510
|
-
* @example
|
|
1511
|
-
* auth.setRefreshHandler(async (refresh) => {
|
|
1512
|
-
* const { data } = await Auth.tokenRefreshCreate({ body: { refresh } });
|
|
1513
|
-
* return data ? { access: data.access, refresh: data.refresh } : null;
|
|
1514
|
-
* });
|
|
1515
|
-
*/
|
|
1516
|
-
setRefreshHandler(fn) {
|
|
1517
|
-
_refreshHandler = fn;
|
|
1518
|
-
},
|
|
1519
|
-
/**
|
|
1520
|
-
* Proactively run the registered refresh handler right now, reusing the
|
|
1521
|
-
* SAME single-flight promise as the 401-recovery interceptor. Callers
|
|
1522
|
-
* (e.g. an expiry timer / focus / reconnect) get token rotation,
|
|
1523
|
-
* de-duplication and rotated-token persistence for free — they must NOT
|
|
1524
|
-
* re-implement any of it. Returns the fresh access token, or null if
|
|
1525
|
-
* there is no handler / no refresh token / the refresh failed.
|
|
1526
|
-
*/
|
|
1527
|
-
refreshNow() {
|
|
1528
|
-
return tryRefresh();
|
|
1529
|
-
}
|
|
1530
|
-
};
|
|
1531
|
-
__name(tryRefresh, "tryRefresh");
|
|
1532
|
-
__name(expireSession, "expireSession");
|
|
1533
|
-
__name(dpopEnabled, "dpopEnabled");
|
|
1534
|
-
_DPOP_DB = "cfg-auth";
|
|
1535
|
-
_DPOP_STORE = "keys";
|
|
1536
|
-
_DPOP_KEY_ID = "dpop-ec-p256";
|
|
1537
|
-
__name(_idbOpen, "_idbOpen");
|
|
1538
|
-
__name(_idbGet, "_idbGet");
|
|
1539
|
-
__name(_idbPut, "_idbPut");
|
|
1540
|
-
_dpopKeyPromise = null;
|
|
1541
|
-
__name(_getDpopKeyPair, "_getDpopKeyPair");
|
|
1542
|
-
__name(_b64urlFromBytes, "_b64urlFromBytes");
|
|
1543
|
-
__name(_b64urlFromString, "_b64urlFromString");
|
|
1544
|
-
__name(_publicJwk, "_publicJwk");
|
|
1545
|
-
__name(_makeDpopProof, "_makeDpopProof");
|
|
1546
|
-
__name(installAuthOnClient, "installAuthOnClient");
|
|
1547
|
-
auth.setRefreshHandler(async (refresh) => {
|
|
1548
|
-
try {
|
|
1549
|
-
const { CfgAccountsAuth: CfgAccountsAuth2 } = await Promise.resolve().then(() => (init_sdk_gen(), sdk_gen_exports));
|
|
1550
|
-
const { data } = await CfgAccountsAuth2.cfgAccountsTokenRefreshCreate({
|
|
1551
|
-
body: { refresh },
|
|
1552
|
-
throwOnError: true
|
|
1553
|
-
});
|
|
1554
|
-
return data?.access ? { access: data.access, refresh: data.refresh ?? refresh } : null;
|
|
1555
|
-
} catch {
|
|
1556
|
-
return null;
|
|
1557
|
-
}
|
|
1458
|
+
__name(installAuthOnClient, "installAuthOnClient");
|
|
1459
|
+
var REFRESH_ENDPOINT = "/cfg/accounts/token/refresh/";
|
|
1460
|
+
auth.setRefreshHandler(async (refresh) => {
|
|
1461
|
+
try {
|
|
1462
|
+
const url = `${auth.getBaseUrl()}${REFRESH_ENDPOINT}`;
|
|
1463
|
+
const headers = { "Content-Type": "application/json" };
|
|
1464
|
+
if (dpopEnabled() && typeof window !== "undefined") {
|
|
1465
|
+
const proof = await _makeDpopProof("POST", url);
|
|
1466
|
+
if (proof) headers["DPoP"] = proof;
|
|
1467
|
+
}
|
|
1468
|
+
const res = await fetch(url, {
|
|
1469
|
+
method: "POST",
|
|
1470
|
+
headers,
|
|
1471
|
+
credentials: auth.getWithCredentials() ? "include" : "same-origin",
|
|
1472
|
+
body: JSON.stringify({ refresh })
|
|
1558
1473
|
});
|
|
1474
|
+
if (!res.ok) return null;
|
|
1475
|
+
const data = await res.json();
|
|
1476
|
+
return data?.access ? { access: data.access, refresh: data.refresh ?? refresh } : null;
|
|
1477
|
+
} catch {
|
|
1478
|
+
return null;
|
|
1559
1479
|
}
|
|
1560
1480
|
});
|
|
1561
1481
|
|
|
1562
1482
|
// src/_api/generated/client.gen.ts
|
|
1563
|
-
var client;
|
|
1564
|
-
|
|
1565
|
-
"src/_api/generated/client.gen.ts"() {
|
|
1566
|
-
init_client();
|
|
1567
|
-
init_auth();
|
|
1568
|
-
client = createClient(createConfig({ baseUrl: "http://localhost:8000" }));
|
|
1569
|
-
installAuthOnClient(client);
|
|
1570
|
-
}
|
|
1571
|
-
});
|
|
1483
|
+
var client = createClient(createConfig({ baseUrl: "http://localhost:8000" }));
|
|
1484
|
+
installAuthOnClient(client);
|
|
1572
1485
|
|
|
1573
1486
|
// src/_api/generated/sdk.gen.ts
|
|
1574
|
-
var
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
}
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
* Generate a new API key. The full key is returned only once.
|
|
1620
|
-
*/
|
|
1621
|
-
static cfgAccountsApiKeyRegenerateCreate(options) {
|
|
1622
|
-
return (options.client ?? client).post({
|
|
1623
|
-
security: [
|
|
1624
|
-
{ scheme: "bearer", type: "http" },
|
|
1625
|
-
{
|
|
1626
|
-
in: "cookie",
|
|
1627
|
-
name: "sessionid",
|
|
1628
|
-
type: "apiKey"
|
|
1629
|
-
},
|
|
1630
|
-
{ name: "X-API-Key", type: "apiKey" }
|
|
1631
|
-
],
|
|
1632
|
-
url: "/cfg/accounts/api-key/regenerate/",
|
|
1633
|
-
...options,
|
|
1634
|
-
headers: {
|
|
1635
|
-
"Content-Type": "application/json",
|
|
1636
|
-
...options.headers
|
|
1637
|
-
}
|
|
1638
|
-
});
|
|
1639
|
-
}
|
|
1640
|
-
/**
|
|
1641
|
-
* Reveal API key
|
|
1642
|
-
*
|
|
1643
|
-
* Return the current full API key WITHOUT rotating it. The same durable value every one of the user's agents uses — for the signed-in user to copy and paste into agent onboarding. Default GET stays masked; this is the explicit reveal action.
|
|
1644
|
-
*/
|
|
1645
|
-
static cfgAccountsApiKeyRevealCreate(options) {
|
|
1646
|
-
return (options.client ?? client).post({
|
|
1647
|
-
security: [
|
|
1648
|
-
{ scheme: "bearer", type: "http" },
|
|
1649
|
-
{
|
|
1650
|
-
in: "cookie",
|
|
1651
|
-
name: "sessionid",
|
|
1652
|
-
type: "apiKey"
|
|
1653
|
-
},
|
|
1654
|
-
{ name: "X-API-Key", type: "apiKey" }
|
|
1655
|
-
],
|
|
1656
|
-
url: "/cfg/accounts/api-key/reveal/",
|
|
1657
|
-
...options,
|
|
1658
|
-
headers: {
|
|
1659
|
-
"Content-Type": "application/json",
|
|
1660
|
-
...options.headers
|
|
1661
|
-
}
|
|
1662
|
-
});
|
|
1663
|
-
}
|
|
1664
|
-
/**
|
|
1665
|
-
* Test API key
|
|
1666
|
-
*
|
|
1667
|
-
* Test whether an API key is valid without consuming it.
|
|
1668
|
-
*/
|
|
1669
|
-
static cfgAccountsApiKeyTestCreate(options) {
|
|
1670
|
-
return (options.client ?? client).post({
|
|
1671
|
-
security: [
|
|
1672
|
-
{ scheme: "bearer", type: "http" },
|
|
1673
|
-
{
|
|
1674
|
-
in: "cookie",
|
|
1675
|
-
name: "sessionid",
|
|
1676
|
-
type: "apiKey"
|
|
1677
|
-
},
|
|
1678
|
-
{ name: "X-API-Key", type: "apiKey" }
|
|
1679
|
-
],
|
|
1680
|
-
url: "/cfg/accounts/api-key/test/",
|
|
1681
|
-
...options,
|
|
1682
|
-
headers: {
|
|
1683
|
-
"Content-Type": "application/json",
|
|
1684
|
-
...options.headers
|
|
1685
|
-
}
|
|
1686
|
-
});
|
|
1687
|
-
}
|
|
1688
|
-
};
|
|
1689
|
-
CfgAccountsOauth = class {
|
|
1690
|
-
static {
|
|
1691
|
-
__name(this, "CfgAccountsOauth");
|
|
1692
|
-
}
|
|
1693
|
-
/**
|
|
1694
|
-
* List OAuth connections
|
|
1695
|
-
*
|
|
1696
|
-
* Get all OAuth connections for the current user.
|
|
1697
|
-
*/
|
|
1698
|
-
static cfgAccountsOauthConnectionsList(options) {
|
|
1699
|
-
return (options?.client ?? client).get({
|
|
1700
|
-
security: [
|
|
1701
|
-
{ name: "X-API-Key", type: "apiKey" },
|
|
1702
|
-
{ scheme: "bearer", type: "http" },
|
|
1703
|
-
{ name: "Authorization", type: "apiKey" }
|
|
1704
|
-
],
|
|
1705
|
-
url: "/cfg/accounts/oauth/connections/",
|
|
1706
|
-
...options
|
|
1707
|
-
});
|
|
1708
|
-
}
|
|
1709
|
-
/**
|
|
1710
|
-
* Disconnect OAuth provider
|
|
1711
|
-
*
|
|
1712
|
-
* Remove OAuth connection for the specified provider.
|
|
1713
|
-
*/
|
|
1714
|
-
static cfgAccountsOauthDisconnectCreate(options) {
|
|
1715
|
-
return (options.client ?? client).post({
|
|
1716
|
-
security: [
|
|
1717
|
-
{ name: "X-API-Key", type: "apiKey" },
|
|
1718
|
-
{ scheme: "bearer", type: "http" },
|
|
1719
|
-
{ name: "Authorization", type: "apiKey" }
|
|
1720
|
-
],
|
|
1721
|
-
url: "/cfg/accounts/oauth/disconnect/",
|
|
1722
|
-
...options,
|
|
1723
|
-
headers: {
|
|
1724
|
-
"Content-Type": "application/json",
|
|
1725
|
-
...options.headers
|
|
1726
|
-
}
|
|
1727
|
-
});
|
|
1728
|
-
}
|
|
1729
|
-
/**
|
|
1730
|
-
* Start GitHub OAuth
|
|
1731
|
-
*
|
|
1732
|
-
* Generate GitHub OAuth authorization URL. Redirect user to this URL to start authentication.
|
|
1733
|
-
*/
|
|
1734
|
-
static cfgAccountsOauthGithubAuthorizeCreate(options) {
|
|
1735
|
-
return (options?.client ?? client).post({
|
|
1736
|
-
url: "/cfg/accounts/oauth/github/authorize/",
|
|
1737
|
-
...options,
|
|
1738
|
-
headers: {
|
|
1739
|
-
"Content-Type": "application/json",
|
|
1740
|
-
...options?.headers
|
|
1741
|
-
}
|
|
1742
|
-
});
|
|
1743
|
-
}
|
|
1744
|
-
/**
|
|
1745
|
-
* Complete GitHub OAuth
|
|
1746
|
-
*
|
|
1747
|
-
* Exchange authorization code for JWT tokens. Call this after GitHub redirects back with code.
|
|
1748
|
-
*/
|
|
1749
|
-
static cfgAccountsOauthGithubCallbackCreate(options) {
|
|
1750
|
-
return (options.client ?? client).post({
|
|
1751
|
-
url: "/cfg/accounts/oauth/github/callback/",
|
|
1752
|
-
...options,
|
|
1753
|
-
headers: {
|
|
1754
|
-
"Content-Type": "application/json",
|
|
1755
|
-
...options.headers
|
|
1756
|
-
}
|
|
1757
|
-
});
|
|
1758
|
-
}
|
|
1759
|
-
/**
|
|
1760
|
-
* List OAuth providers
|
|
1761
|
-
*
|
|
1762
|
-
* Get list of available OAuth providers for authentication.
|
|
1763
|
-
*/
|
|
1764
|
-
static cfgAccountsOauthProvidersRetrieve(options) {
|
|
1765
|
-
return (options?.client ?? client).get({ url: "/cfg/accounts/oauth/providers/", ...options });
|
|
1766
|
-
}
|
|
1767
|
-
};
|
|
1768
|
-
CfgAccounts = class {
|
|
1769
|
-
static {
|
|
1770
|
-
__name(this, "CfgAccounts");
|
|
1771
|
-
}
|
|
1772
|
-
/**
|
|
1773
|
-
* Request OTP code to email.
|
|
1774
|
-
*/
|
|
1775
|
-
static cfgAccountsOtpRequestCreate(options) {
|
|
1776
|
-
return (options.client ?? client).post({
|
|
1777
|
-
security: [
|
|
1778
|
-
{ name: "X-API-Key", type: "apiKey" },
|
|
1779
|
-
{ scheme: "bearer", type: "http" },
|
|
1780
|
-
{ name: "Authorization", type: "apiKey" }
|
|
1781
|
-
],
|
|
1782
|
-
url: "/cfg/accounts/otp/request/",
|
|
1783
|
-
...options,
|
|
1784
|
-
headers: {
|
|
1785
|
-
"Content-Type": "application/json",
|
|
1786
|
-
...options.headers
|
|
1787
|
-
}
|
|
1788
|
-
});
|
|
1789
|
-
}
|
|
1790
|
-
/**
|
|
1791
|
-
* Verify OTP code and return JWT tokens or 2FA session.
|
|
1792
|
-
*
|
|
1793
|
-
* If user has 2FA enabled:
|
|
1794
|
-
* - Returns requires_2fa=True with session_id
|
|
1795
|
-
* - Client must complete 2FA verification at /cfg/totp/verify/
|
|
1796
|
-
*
|
|
1797
|
-
* If user has no 2FA:
|
|
1798
|
-
* - Returns JWT tokens and user data directly
|
|
1799
|
-
*/
|
|
1800
|
-
static cfgAccountsOtpVerifyCreate(options) {
|
|
1801
|
-
return (options.client ?? client).post({
|
|
1802
|
-
security: [
|
|
1803
|
-
{ name: "X-API-Key", type: "apiKey" },
|
|
1804
|
-
{ scheme: "bearer", type: "http" },
|
|
1805
|
-
{ name: "Authorization", type: "apiKey" }
|
|
1806
|
-
],
|
|
1807
|
-
url: "/cfg/accounts/otp/verify/",
|
|
1808
|
-
...options,
|
|
1809
|
-
headers: {
|
|
1810
|
-
"Content-Type": "application/json",
|
|
1811
|
-
...options.headers
|
|
1812
|
-
}
|
|
1813
|
-
});
|
|
1814
|
-
}
|
|
1815
|
-
};
|
|
1816
|
-
CfgAccountsProfile = class {
|
|
1817
|
-
static {
|
|
1818
|
-
__name(this, "CfgAccountsProfile");
|
|
1819
|
-
}
|
|
1820
|
-
/**
|
|
1821
|
-
* Get current user profile
|
|
1822
|
-
*
|
|
1823
|
-
* Retrieve the current authenticated user's profile information.
|
|
1824
|
-
*/
|
|
1825
|
-
static cfgAccountsProfileRetrieve(options) {
|
|
1826
|
-
return (options?.client ?? client).get({
|
|
1827
|
-
security: [{ scheme: "bearer", type: "http" }, {
|
|
1828
|
-
in: "cookie",
|
|
1829
|
-
name: "sessionid",
|
|
1830
|
-
type: "apiKey"
|
|
1831
|
-
}],
|
|
1832
|
-
url: "/cfg/accounts/profile/",
|
|
1833
|
-
...options
|
|
1834
|
-
});
|
|
1835
|
-
}
|
|
1836
|
-
/**
|
|
1837
|
-
* Upload user avatar
|
|
1838
|
-
*
|
|
1839
|
-
* Upload avatar image for the current authenticated user. Accepts multipart/form-data with 'avatar' field.
|
|
1840
|
-
*/
|
|
1841
|
-
static cfgAccountsProfileAvatarCreate(options) {
|
|
1842
|
-
return (options?.client ?? client).post({
|
|
1843
|
-
...formDataBodySerializer,
|
|
1844
|
-
security: [
|
|
1845
|
-
{ name: "X-API-Key", type: "apiKey" },
|
|
1846
|
-
{ scheme: "bearer", type: "http" },
|
|
1847
|
-
{ name: "Authorization", type: "apiKey" }
|
|
1848
|
-
],
|
|
1849
|
-
url: "/cfg/accounts/profile/avatar/",
|
|
1850
|
-
...options,
|
|
1851
|
-
headers: {
|
|
1852
|
-
"Content-Type": null,
|
|
1853
|
-
...options?.headers
|
|
1854
|
-
}
|
|
1855
|
-
});
|
|
1856
|
-
}
|
|
1857
|
-
/**
|
|
1858
|
-
* Delete user account
|
|
1859
|
-
*
|
|
1860
|
-
*
|
|
1861
|
-
* Permanently delete the current user's account.
|
|
1862
|
-
*
|
|
1863
|
-
* This operation:
|
|
1864
|
-
* - Deactivates the account (user cannot log in)
|
|
1865
|
-
* - Anonymizes personal data (GDPR compliance)
|
|
1866
|
-
* - Frees up the email address for re-registration
|
|
1867
|
-
* - Preserves audit trail
|
|
1868
|
-
*
|
|
1869
|
-
* The account can be restored by an administrator if needed.
|
|
1870
|
-
*
|
|
1871
|
-
*/
|
|
1872
|
-
static cfgAccountsProfileDeleteCreate(options) {
|
|
1873
|
-
return (options?.client ?? client).post({
|
|
1874
|
-
security: [{ scheme: "bearer", type: "http" }, {
|
|
1875
|
-
in: "cookie",
|
|
1876
|
-
name: "sessionid",
|
|
1877
|
-
type: "apiKey"
|
|
1878
|
-
}],
|
|
1879
|
-
url: "/cfg/accounts/profile/delete/",
|
|
1880
|
-
...options
|
|
1881
|
-
});
|
|
1882
|
-
}
|
|
1883
|
-
/**
|
|
1884
|
-
* Partial update user profile
|
|
1885
|
-
*
|
|
1886
|
-
* Partially update the current authenticated user's profile information. Supports avatar upload.
|
|
1887
|
-
*/
|
|
1888
|
-
static cfgAccountsProfilePartialPartialUpdate(options) {
|
|
1889
|
-
return (options?.client ?? client).patch({
|
|
1890
|
-
security: [{ scheme: "bearer", type: "http" }, {
|
|
1891
|
-
in: "cookie",
|
|
1892
|
-
name: "sessionid",
|
|
1893
|
-
type: "apiKey"
|
|
1894
|
-
}],
|
|
1895
|
-
url: "/cfg/accounts/profile/partial/",
|
|
1896
|
-
...options,
|
|
1897
|
-
headers: {
|
|
1898
|
-
"Content-Type": "application/json",
|
|
1899
|
-
...options?.headers
|
|
1900
|
-
}
|
|
1901
|
-
});
|
|
1902
|
-
}
|
|
1903
|
-
/**
|
|
1904
|
-
* Partial update user profile
|
|
1905
|
-
*
|
|
1906
|
-
* Partially update the current authenticated user's profile information. Supports avatar upload.
|
|
1907
|
-
*/
|
|
1908
|
-
static cfgAccountsProfilePartialUpdate(options) {
|
|
1909
|
-
return (options?.client ?? client).put({
|
|
1910
|
-
security: [{ scheme: "bearer", type: "http" }, {
|
|
1911
|
-
in: "cookie",
|
|
1912
|
-
name: "sessionid",
|
|
1913
|
-
type: "apiKey"
|
|
1914
|
-
}],
|
|
1915
|
-
url: "/cfg/accounts/profile/partial/",
|
|
1916
|
-
...options,
|
|
1917
|
-
headers: {
|
|
1918
|
-
"Content-Type": "application/json",
|
|
1919
|
-
...options?.headers
|
|
1920
|
-
}
|
|
1921
|
-
});
|
|
1922
|
-
}
|
|
1923
|
-
/**
|
|
1924
|
-
* Update user profile
|
|
1925
|
-
*
|
|
1926
|
-
* Update the current authenticated user's profile information.
|
|
1927
|
-
*/
|
|
1928
|
-
static cfgAccountsProfileUpdatePartialUpdate(options) {
|
|
1929
|
-
return (options?.client ?? client).patch({
|
|
1930
|
-
security: [{ scheme: "bearer", type: "http" }, {
|
|
1931
|
-
in: "cookie",
|
|
1932
|
-
name: "sessionid",
|
|
1933
|
-
type: "apiKey"
|
|
1934
|
-
}],
|
|
1935
|
-
url: "/cfg/accounts/profile/update/",
|
|
1936
|
-
...options,
|
|
1937
|
-
headers: {
|
|
1938
|
-
"Content-Type": "application/json",
|
|
1939
|
-
...options?.headers
|
|
1940
|
-
}
|
|
1941
|
-
});
|
|
1942
|
-
}
|
|
1943
|
-
/**
|
|
1944
|
-
* Update user profile
|
|
1945
|
-
*
|
|
1946
|
-
* Update the current authenticated user's profile information.
|
|
1947
|
-
*/
|
|
1948
|
-
static cfgAccountsProfileUpdateUpdate(options) {
|
|
1949
|
-
return (options?.client ?? client).put({
|
|
1950
|
-
security: [{ scheme: "bearer", type: "http" }, {
|
|
1951
|
-
in: "cookie",
|
|
1952
|
-
name: "sessionid",
|
|
1953
|
-
type: "apiKey"
|
|
1954
|
-
}],
|
|
1955
|
-
url: "/cfg/accounts/profile/update/",
|
|
1956
|
-
...options,
|
|
1957
|
-
headers: {
|
|
1958
|
-
"Content-Type": "application/json",
|
|
1959
|
-
...options?.headers
|
|
1960
|
-
}
|
|
1961
|
-
});
|
|
1962
|
-
}
|
|
1963
|
-
};
|
|
1964
|
-
CfgAccountsAuth = class {
|
|
1965
|
-
static {
|
|
1966
|
-
__name(this, "CfgAccountsAuth");
|
|
1967
|
-
}
|
|
1968
|
-
/**
|
|
1969
|
-
* Revoke a refresh token (logout).
|
|
1970
|
-
*
|
|
1971
|
-
* Blacklists the posted refresh token so it can never mint another access
|
|
1972
|
-
* token. Called best-effort by the client's logout — without it, "logout"
|
|
1973
|
-
* is purely client-side and a stolen refresh token survives until expiry.
|
|
1974
|
-
*/
|
|
1975
|
-
static cfgAccountsTokenBlacklistCreate(options) {
|
|
1976
|
-
return (options.client ?? client).post({
|
|
1977
|
-
url: "/cfg/accounts/token/blacklist/",
|
|
1978
|
-
...options,
|
|
1979
|
-
headers: {
|
|
1980
|
-
"Content-Type": "application/json",
|
|
1981
|
-
...options.headers
|
|
1982
|
-
}
|
|
1983
|
-
});
|
|
1984
|
-
}
|
|
1985
|
-
/**
|
|
1986
|
-
* Refresh JWT token.
|
|
1987
|
-
*
|
|
1988
|
-
* DPoP-aware: when the incoming refresh token is key-bound (`cnf.jkt`), the
|
|
1989
|
-
* rotated access/refresh in the response are re-stamped with the same `cnf`
|
|
1990
|
-
* (stock SimpleJWT drops it from the derived access), and a matching DPoP
|
|
1991
|
-
* proof is required on the refresh request — so a stolen refresh token can't
|
|
1992
|
-
* be used to mint fresh tokens.
|
|
1993
|
-
*/
|
|
1994
|
-
static cfgAccountsTokenRefreshCreate(options) {
|
|
1995
|
-
return (options.client ?? client).post({
|
|
1996
|
-
url: "/cfg/accounts/token/refresh/",
|
|
1997
|
-
...options,
|
|
1998
|
-
headers: {
|
|
1999
|
-
"Content-Type": "application/json",
|
|
2000
|
-
...options.headers
|
|
2001
|
-
}
|
|
2002
|
-
});
|
|
2003
|
-
}
|
|
2004
|
-
};
|
|
2005
|
-
CfgCentrifugo = class {
|
|
2006
|
-
static {
|
|
2007
|
-
__name(this, "CfgCentrifugo");
|
|
2008
|
-
}
|
|
2009
|
-
/**
|
|
2010
|
-
* Get Centrifugo connection token
|
|
2011
|
-
*
|
|
2012
|
-
* Generate JWT token for WebSocket connection to Centrifugo. Token includes user's allowed channels based on their permissions. Requires authentication.
|
|
2013
|
-
*/
|
|
2014
|
-
static cfgCentrifugoAuthTokenRetrieve(options) {
|
|
2015
|
-
return (options?.client ?? client).get({
|
|
2016
|
-
security: [
|
|
2017
|
-
{ name: "X-API-Key", type: "apiKey" },
|
|
2018
|
-
{ scheme: "bearer", type: "http" },
|
|
2019
|
-
{ name: "Authorization", type: "apiKey" }
|
|
2020
|
-
],
|
|
2021
|
-
url: "/cfg/centrifugo/auth/token/",
|
|
2022
|
-
...options
|
|
2023
|
-
});
|
|
2024
|
-
}
|
|
2025
|
-
};
|
|
2026
|
-
CfgTotpBackupCodes = class {
|
|
2027
|
-
static {
|
|
2028
|
-
__name(this, "CfgTotpBackupCodes");
|
|
2029
|
-
}
|
|
2030
|
-
/**
|
|
2031
|
-
* Get backup codes status for user.
|
|
2032
|
-
*/
|
|
2033
|
-
static cfgTotpBackupCodesRetrieve(options) {
|
|
2034
|
-
return (options?.client ?? client).get({
|
|
2035
|
-
security: [
|
|
2036
|
-
{ name: "X-API-Key", type: "apiKey" },
|
|
2037
|
-
{ scheme: "bearer", type: "http" },
|
|
2038
|
-
{ name: "Authorization", type: "apiKey" }
|
|
2039
|
-
],
|
|
2040
|
-
url: "/cfg/totp/backup-codes/",
|
|
2041
|
-
...options
|
|
2042
|
-
});
|
|
2043
|
-
}
|
|
2044
|
-
/**
|
|
2045
|
-
* Regenerate backup codes.
|
|
2046
|
-
*
|
|
2047
|
-
* Requires TOTP code for verification.
|
|
2048
|
-
* Invalidates all existing codes.
|
|
2049
|
-
*/
|
|
2050
|
-
static cfgTotpBackupCodesRegenerateCreate(options) {
|
|
2051
|
-
return (options.client ?? client).post({
|
|
2052
|
-
security: [
|
|
2053
|
-
{ name: "X-API-Key", type: "apiKey" },
|
|
2054
|
-
{ scheme: "bearer", type: "http" },
|
|
2055
|
-
{ name: "Authorization", type: "apiKey" }
|
|
2056
|
-
],
|
|
2057
|
-
url: "/cfg/totp/backup-codes/regenerate/",
|
|
2058
|
-
...options,
|
|
2059
|
-
headers: {
|
|
2060
|
-
"Content-Type": "application/json",
|
|
2061
|
-
...options.headers
|
|
2062
|
-
}
|
|
2063
|
-
});
|
|
2064
|
-
}
|
|
2065
|
-
};
|
|
2066
|
-
CfgTotp = class {
|
|
2067
|
-
static {
|
|
2068
|
-
__name(this, "CfgTotp");
|
|
2069
|
-
}
|
|
2070
|
-
/**
|
|
2071
|
-
* List all TOTP devices for user.
|
|
2072
|
-
*/
|
|
2073
|
-
static cfgTotpDevicesRetrieve(options) {
|
|
2074
|
-
return (options?.client ?? client).get({
|
|
2075
|
-
security: [
|
|
2076
|
-
{ name: "X-API-Key", type: "apiKey" },
|
|
2077
|
-
{ scheme: "bearer", type: "http" },
|
|
2078
|
-
{ name: "Authorization", type: "apiKey" }
|
|
2079
|
-
],
|
|
2080
|
-
url: "/cfg/totp/devices/",
|
|
2081
|
-
...options
|
|
2082
|
-
});
|
|
2083
|
-
}
|
|
2084
|
-
/**
|
|
2085
|
-
* Delete a TOTP device.
|
|
2086
|
-
*
|
|
2087
|
-
* Requires verification code if removing the last/primary device.
|
|
2088
|
-
*/
|
|
2089
|
-
static cfgTotpDevicesDestroy(options) {
|
|
2090
|
-
return (options.client ?? client).delete({
|
|
2091
|
-
security: [
|
|
2092
|
-
{ name: "X-API-Key", type: "apiKey" },
|
|
2093
|
-
{ scheme: "bearer", type: "http" },
|
|
2094
|
-
{ name: "Authorization", type: "apiKey" }
|
|
2095
|
-
],
|
|
2096
|
-
url: "/cfg/totp/devices/{id}/",
|
|
2097
|
-
...options
|
|
2098
|
-
});
|
|
2099
|
-
}
|
|
2100
|
-
/**
|
|
2101
|
-
* Completely disable 2FA for account.
|
|
2102
|
-
*
|
|
2103
|
-
* Requires verification code.
|
|
2104
|
-
*/
|
|
2105
|
-
static cfgTotpDisableCreate(options) {
|
|
2106
|
-
return (options.client ?? client).post({
|
|
2107
|
-
security: [
|
|
2108
|
-
{ name: "X-API-Key", type: "apiKey" },
|
|
2109
|
-
{ scheme: "bearer", type: "http" },
|
|
2110
|
-
{ name: "Authorization", type: "apiKey" }
|
|
2111
|
-
],
|
|
2112
|
-
url: "/cfg/totp/disable/",
|
|
2113
|
-
...options,
|
|
2114
|
-
headers: {
|
|
2115
|
-
"Content-Type": "application/json",
|
|
2116
|
-
...options.headers
|
|
2117
|
-
}
|
|
2118
|
-
});
|
|
2119
|
-
}
|
|
2120
|
-
};
|
|
2121
|
-
CfgTotpSetup = class {
|
|
2122
|
-
static {
|
|
2123
|
-
__name(this, "CfgTotpSetup");
|
|
2124
|
-
}
|
|
2125
|
-
/**
|
|
2126
|
-
* Start 2FA setup process.
|
|
2127
|
-
*
|
|
2128
|
-
* Creates a new TOTP device and returns QR code for scanning.
|
|
2129
|
-
*/
|
|
2130
|
-
static cfgTotpSetupCreate(options) {
|
|
2131
|
-
return (options?.client ?? client).post({
|
|
2132
|
-
security: [
|
|
2133
|
-
{ name: "X-API-Key", type: "apiKey" },
|
|
2134
|
-
{ scheme: "bearer", type: "http" },
|
|
2135
|
-
{ name: "Authorization", type: "apiKey" }
|
|
2136
|
-
],
|
|
2137
|
-
url: "/cfg/totp/setup/",
|
|
2138
|
-
...options,
|
|
2139
|
-
headers: {
|
|
2140
|
-
"Content-Type": "application/json",
|
|
2141
|
-
...options?.headers
|
|
2142
|
-
}
|
|
2143
|
-
});
|
|
2144
|
-
}
|
|
2145
|
-
/**
|
|
2146
|
-
* Confirm 2FA setup with first valid code.
|
|
2147
|
-
*
|
|
2148
|
-
* Activates the device and generates backup codes.
|
|
2149
|
-
*/
|
|
2150
|
-
static cfgTotpSetupConfirmCreate(options) {
|
|
2151
|
-
return (options.client ?? client).post({
|
|
2152
|
-
security: [
|
|
2153
|
-
{ name: "X-API-Key", type: "apiKey" },
|
|
2154
|
-
{ scheme: "bearer", type: "http" },
|
|
2155
|
-
{ name: "Authorization", type: "apiKey" }
|
|
2156
|
-
],
|
|
2157
|
-
url: "/cfg/totp/setup/confirm/",
|
|
2158
|
-
...options,
|
|
2159
|
-
headers: {
|
|
2160
|
-
"Content-Type": "application/json",
|
|
2161
|
-
...options.headers
|
|
2162
|
-
}
|
|
2163
|
-
});
|
|
2164
|
-
}
|
|
2165
|
-
};
|
|
2166
|
-
CfgTotpVerify = class {
|
|
2167
|
-
static {
|
|
2168
|
-
__name(this, "CfgTotpVerify");
|
|
1487
|
+
var CfgAccountsApiKey = class {
|
|
1488
|
+
static {
|
|
1489
|
+
__name(this, "CfgAccountsApiKey");
|
|
1490
|
+
}
|
|
1491
|
+
/**
|
|
1492
|
+
* Get API key details
|
|
1493
|
+
*
|
|
1494
|
+
* Retrieve the current user's API key (masked) and metadata.
|
|
1495
|
+
*/
|
|
1496
|
+
static cfgAccountsApiKeyRetrieve(options) {
|
|
1497
|
+
return (options?.client ?? client).get({
|
|
1498
|
+
security: [
|
|
1499
|
+
{ scheme: "bearer", type: "http" },
|
|
1500
|
+
{
|
|
1501
|
+
in: "cookie",
|
|
1502
|
+
name: "sessionid",
|
|
1503
|
+
type: "apiKey"
|
|
1504
|
+
},
|
|
1505
|
+
{ name: "X-API-Key", type: "apiKey" }
|
|
1506
|
+
],
|
|
1507
|
+
url: "/cfg/accounts/api-key/",
|
|
1508
|
+
...options
|
|
1509
|
+
});
|
|
1510
|
+
}
|
|
1511
|
+
/**
|
|
1512
|
+
* Regenerate API key
|
|
1513
|
+
*
|
|
1514
|
+
* Generate a new API key. The full key is returned only once.
|
|
1515
|
+
*/
|
|
1516
|
+
static cfgAccountsApiKeyRegenerateCreate(options) {
|
|
1517
|
+
return (options.client ?? client).post({
|
|
1518
|
+
security: [
|
|
1519
|
+
{ scheme: "bearer", type: "http" },
|
|
1520
|
+
{
|
|
1521
|
+
in: "cookie",
|
|
1522
|
+
name: "sessionid",
|
|
1523
|
+
type: "apiKey"
|
|
1524
|
+
},
|
|
1525
|
+
{ name: "X-API-Key", type: "apiKey" }
|
|
1526
|
+
],
|
|
1527
|
+
url: "/cfg/accounts/api-key/regenerate/",
|
|
1528
|
+
...options,
|
|
1529
|
+
headers: {
|
|
1530
|
+
"Content-Type": "application/json",
|
|
1531
|
+
...options.headers
|
|
2169
1532
|
}
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
1533
|
+
});
|
|
1534
|
+
}
|
|
1535
|
+
/**
|
|
1536
|
+
* Reveal API key
|
|
1537
|
+
*
|
|
1538
|
+
* Return the current full API key WITHOUT rotating it. The same durable value every one of the user's agents uses — for the signed-in user to copy and paste into agent onboarding. Default GET stays masked; this is the explicit reveal action.
|
|
1539
|
+
*/
|
|
1540
|
+
static cfgAccountsApiKeyRevealCreate(options) {
|
|
1541
|
+
return (options.client ?? client).post({
|
|
1542
|
+
security: [
|
|
1543
|
+
{ scheme: "bearer", type: "http" },
|
|
1544
|
+
{
|
|
1545
|
+
in: "cookie",
|
|
1546
|
+
name: "sessionid",
|
|
1547
|
+
type: "apiKey"
|
|
1548
|
+
},
|
|
1549
|
+
{ name: "X-API-Key", type: "apiKey" }
|
|
1550
|
+
],
|
|
1551
|
+
url: "/cfg/accounts/api-key/reveal/",
|
|
1552
|
+
...options,
|
|
1553
|
+
headers: {
|
|
1554
|
+
"Content-Type": "application/json",
|
|
1555
|
+
...options.headers
|
|
2189
1556
|
}
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
1557
|
+
});
|
|
1558
|
+
}
|
|
1559
|
+
/**
|
|
1560
|
+
* Test API key
|
|
1561
|
+
*
|
|
1562
|
+
* Test whether an API key is valid without consuming it.
|
|
1563
|
+
*/
|
|
1564
|
+
static cfgAccountsApiKeyTestCreate(options) {
|
|
1565
|
+
return (options.client ?? client).post({
|
|
1566
|
+
security: [
|
|
1567
|
+
{ scheme: "bearer", type: "http" },
|
|
1568
|
+
{
|
|
1569
|
+
in: "cookie",
|
|
1570
|
+
name: "sessionid",
|
|
1571
|
+
type: "apiKey"
|
|
1572
|
+
},
|
|
1573
|
+
{ name: "X-API-Key", type: "apiKey" }
|
|
1574
|
+
],
|
|
1575
|
+
url: "/cfg/accounts/api-key/test/",
|
|
1576
|
+
...options,
|
|
1577
|
+
headers: {
|
|
1578
|
+
"Content-Type": "application/json",
|
|
1579
|
+
...options.headers
|
|
2209
1580
|
}
|
|
2210
|
-
};
|
|
1581
|
+
});
|
|
2211
1582
|
}
|
|
2212
|
-
}
|
|
2213
|
-
|
|
2214
|
-
// src/hooks/index.ts
|
|
2215
|
-
var hooks_exports = {};
|
|
2216
|
-
__export(hooks_exports, {
|
|
2217
|
-
useApiKey: () => useApiKey
|
|
2218
|
-
});
|
|
2219
|
-
module.exports = __toCommonJS(hooks_exports);
|
|
2220
|
-
|
|
2221
|
-
// src/hooks/useApiKey.ts
|
|
2222
|
-
var import_react = require("react");
|
|
2223
|
-
|
|
2224
|
-
// src/_api/generated/_cfg_accounts/hooks/useCfgAccountsApiKeyRegenerateCreate.ts
|
|
2225
|
-
var import_mutation = __toESM(require("swr/mutation"), 1);
|
|
2226
|
-
init_sdk_gen();
|
|
1583
|
+
};
|
|
2227
1584
|
|
|
2228
1585
|
// src/_api/generated/_cfg_accounts/schemas/APIKeyRegenerate.ts
|
|
2229
1586
|
var import_zod = require("zod");
|
|
@@ -2281,7 +1638,6 @@ __name(useCfgAccountsApiKeyRegenerateCreate, "useCfgAccountsApiKeyRegenerateCrea
|
|
|
2281
1638
|
|
|
2282
1639
|
// src/_api/generated/_cfg_accounts/hooks/useCfgAccountsApiKeyRetrieve.ts
|
|
2283
1640
|
var import_swr = __toESM(require("swr"), 1);
|
|
2284
|
-
init_sdk_gen();
|
|
2285
1641
|
|
|
2286
1642
|
// src/_api/generated/_cfg_accounts/schemas/APIKey.ts
|
|
2287
1643
|
var import_zod2 = require("zod");
|
|
@@ -2342,7 +1698,6 @@ __name(useCfgAccountsApiKeyRetrieve, "useCfgAccountsApiKeyRetrieve");
|
|
|
2342
1698
|
|
|
2343
1699
|
// src/_api/generated/_cfg_accounts/hooks/useCfgAccountsApiKeyRevealCreate.ts
|
|
2344
1700
|
var import_mutation2 = __toESM(require("swr/mutation"), 1);
|
|
2345
|
-
init_sdk_gen();
|
|
2346
1701
|
|
|
2347
1702
|
// src/_api/generated/_cfg_accounts/schemas/APIKeyReveal.ts
|
|
2348
1703
|
var import_zod3 = require("zod");
|
|
@@ -2401,7 +1756,6 @@ __name(useCfgAccountsApiKeyRevealCreate, "useCfgAccountsApiKeyRevealCreate");
|
|
|
2401
1756
|
|
|
2402
1757
|
// src/_api/generated/_cfg_accounts/hooks/useCfgAccountsApiKeyTestCreate.ts
|
|
2403
1758
|
var import_mutation3 = __toESM(require("swr/mutation"), 1);
|
|
2404
|
-
init_sdk_gen();
|
|
2405
1759
|
|
|
2406
1760
|
// src/_api/generated/_cfg_accounts/schemas/APIKeyTestResult.ts
|
|
2407
1761
|
var import_zod4 = require("zod");
|