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