@djangocfg/api 2.1.455 → 2.1.456

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