@djangocfg/api 2.1.456 → 2.1.457

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