@djangocfg/api 2.1.331 → 2.1.332

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/auth.mjs CHANGED
@@ -41,7 +41,7 @@ __name(withBasePath, "withBasePath");
41
41
  function useCfgRouter() {
42
42
  const router = useNextRouter();
43
43
  const basePath = useMemo(() => getBasePath(), []);
44
- const isStaticBuild3 = useMemo(() => {
44
+ const isStaticBuild2 = useMemo(() => {
45
45
  return typeof process !== "undefined" && process.env.NEXT_PUBLIC_STATIC_BUILD === "true";
46
46
  }, []);
47
47
  const push = useCallback((href, options) => {
@@ -603,14 +603,14 @@ var defaultPathSerializer = /* @__PURE__ */ __name(({ path, url: _url }) => {
603
603
  return url;
604
604
  }, "defaultPathSerializer");
605
605
  var getUrl = /* @__PURE__ */ __name(({
606
- baseUrl: baseUrl2,
606
+ baseUrl,
607
607
  path,
608
608
  query,
609
609
  querySerializer,
610
610
  url: _url
611
611
  }) => {
612
612
  const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
613
- let url = (baseUrl2 ?? "") + pathUrl;
613
+ let url = (baseUrl ?? "") + pathUrl;
614
614
  if (path) {
615
615
  url = defaultPathSerializer({ path, url });
616
616
  }
@@ -641,15 +641,15 @@ function getValidRequestBody(options) {
641
641
  __name(getValidRequestBody, "getValidRequestBody");
642
642
 
643
643
  // src/_api/generated/core/auth.gen.ts
644
- var getAuthToken = /* @__PURE__ */ __name(async (auth, callback) => {
645
- const token = typeof callback === "function" ? await callback(auth) : callback;
644
+ var getAuthToken = /* @__PURE__ */ __name(async (auth2, callback) => {
645
+ const token = typeof callback === "function" ? await callback(auth2) : callback;
646
646
  if (!token) {
647
647
  return;
648
648
  }
649
- if (auth.scheme === "bearer") {
649
+ if (auth2.scheme === "bearer") {
650
650
  return `Bearer ${token}`;
651
651
  }
652
- if (auth.scheme === "basic") {
652
+ if (auth2.scheme === "basic") {
653
653
  return `Basic ${btoa(token)}`;
654
654
  }
655
655
  return token;
@@ -738,16 +738,16 @@ var setAuthParams = /* @__PURE__ */ __name(async ({
738
738
  security,
739
739
  ...options
740
740
  }) => {
741
- for (const auth of security) {
742
- if (checkForExistence(options, auth.name)) {
741
+ for (const auth2 of security) {
742
+ if (checkForExistence(options, auth2.name)) {
743
743
  continue;
744
744
  }
745
- const token = await getAuthToken(auth, options.auth);
745
+ const token = await getAuthToken(auth2, options.auth);
746
746
  if (!token) {
747
747
  continue;
748
748
  }
749
- const name = auth.name ?? "Authorization";
750
- switch (auth.in) {
749
+ const name = auth2.name ?? "Authorization";
750
+ switch (auth2.in) {
751
751
  case "query":
752
752
  if (!options.query) {
753
753
  options.query = {};
@@ -1075,41 +1075,206 @@ var createClient = /* @__PURE__ */ __name((config = {}) => {
1075
1075
  // src/_api/generated/client.gen.ts
1076
1076
  var client = createClient(createConfig({ baseUrl: "http://localhost:8000" }));
1077
1077
 
1078
- // src/_api/generated/helpers/storage.ts
1079
- var LocalStorageAdapter = class {
1080
- static {
1081
- __name(this, "LocalStorageAdapter");
1082
- }
1083
- getItem(key) {
1084
- if (typeof window === "undefined") return null;
1078
+ // src/_api/generated/helpers/auth.ts
1079
+ var ACCESS_KEY = "cfg.access_token";
1080
+ var REFRESH_KEY = "cfg.refresh_token";
1081
+ var API_KEY_KEY = "cfg.api_key";
1082
+ var isBrowser2 = typeof window !== "undefined";
1083
+ var localStorageBackend = {
1084
+ get(key) {
1085
+ if (!isBrowser2) return null;
1085
1086
  try {
1086
1087
  return window.localStorage.getItem(key);
1087
1088
  } catch {
1088
1089
  return null;
1089
1090
  }
1090
- }
1091
- setItem(key, value) {
1092
- if (typeof window === "undefined") return;
1091
+ },
1092
+ set(key, value) {
1093
+ if (!isBrowser2) return;
1093
1094
  try {
1094
- window.localStorage.setItem(key, value);
1095
+ if (value === null) window.localStorage.removeItem(key);
1096
+ else window.localStorage.setItem(key, value);
1095
1097
  } catch {
1096
1098
  }
1097
1099
  }
1098
- removeItem(key) {
1099
- if (typeof window === "undefined") return;
1100
+ };
1101
+ var COOKIE_MAX_AGE = 60 * 60 * 24 * 30;
1102
+ var cookieBackend = {
1103
+ get(key) {
1104
+ if (!isBrowser2) return null;
1100
1105
  try {
1101
- window.localStorage.removeItem(key);
1106
+ const re = new RegExp(`(?:^|;\\s*)${encodeURIComponent(key)}=([^;]*)`);
1107
+ const m = document.cookie.match(re);
1108
+ return m ? decodeURIComponent(m[1]) : null;
1102
1109
  } catch {
1110
+ return null;
1103
1111
  }
1104
- }
1105
- clear() {
1106
- if (typeof window === "undefined") return;
1112
+ },
1113
+ set(key, value) {
1114
+ if (!isBrowser2) return;
1107
1115
  try {
1108
- window.localStorage.clear();
1116
+ const k = encodeURIComponent(key);
1117
+ const secure = window.location.protocol === "https:" ? "; Secure" : "";
1118
+ if (value === null) {
1119
+ document.cookie = `${k}=; Path=/; Max-Age=0; SameSite=Lax${secure}`;
1120
+ } else {
1121
+ const v = encodeURIComponent(value);
1122
+ document.cookie = `${k}=${v}; Path=/; Max-Age=${COOKIE_MAX_AGE}; SameSite=Lax${secure}`;
1123
+ }
1109
1124
  } catch {
1110
1125
  }
1111
1126
  }
1112
1127
  };
1128
+ var _storage = localStorageBackend;
1129
+ var _storageMode = "localStorage";
1130
+ function detectLocale() {
1131
+ try {
1132
+ if (typeof document !== "undefined") {
1133
+ const m = document.cookie.match(/(?:^|;\s*)NEXT_LOCALE=([^;]*)/);
1134
+ if (m) return decodeURIComponent(m[1]);
1135
+ }
1136
+ if (typeof navigator !== "undefined" && navigator.language) {
1137
+ return navigator.language;
1138
+ }
1139
+ } catch {
1140
+ }
1141
+ return null;
1142
+ }
1143
+ __name(detectLocale, "detectLocale");
1144
+ function defaultBaseUrl() {
1145
+ try {
1146
+ if (typeof process !== "undefined" && process.env) {
1147
+ if (process.env.NEXT_PUBLIC_STATIC_BUILD === "true") return "";
1148
+ return process.env.NEXT_PUBLIC_API_URL || "";
1149
+ }
1150
+ } catch {
1151
+ }
1152
+ return "";
1153
+ }
1154
+ __name(defaultBaseUrl, "defaultBaseUrl");
1155
+ function defaultApiKey() {
1156
+ try {
1157
+ if (typeof process !== "undefined" && process.env?.NEXT_PUBLIC_API_KEY) {
1158
+ return process.env.NEXT_PUBLIC_API_KEY;
1159
+ }
1160
+ } catch {
1161
+ }
1162
+ return null;
1163
+ }
1164
+ __name(defaultApiKey, "defaultApiKey");
1165
+ var _localeOverride = null;
1166
+ var _apiKeyOverride = null;
1167
+ var _baseUrlOverride = null;
1168
+ var _withCredentials = true;
1169
+ var _onUnauthorized = null;
1170
+ var auth = {
1171
+ // ── Storage mode ──────────────────────────────────────────────────
1172
+ getStorageMode() {
1173
+ return _storageMode;
1174
+ },
1175
+ /**
1176
+ * Switch the storage backend. Existing values in the *previous*
1177
+ * backend are NOT migrated — set fresh values after switching.
1178
+ */
1179
+ setStorageMode(mode) {
1180
+ _storageMode = mode;
1181
+ _storage = mode === "cookie" ? cookieBackend : localStorageBackend;
1182
+ },
1183
+ // ── Bearer token ──────────────────────────────────────────────────
1184
+ getToken() {
1185
+ return _storage.get(ACCESS_KEY);
1186
+ },
1187
+ setToken(token) {
1188
+ _storage.set(ACCESS_KEY, token);
1189
+ },
1190
+ getRefreshToken() {
1191
+ return _storage.get(REFRESH_KEY);
1192
+ },
1193
+ setRefreshToken(token) {
1194
+ _storage.set(REFRESH_KEY, token);
1195
+ },
1196
+ clearTokens() {
1197
+ _storage.set(ACCESS_KEY, null);
1198
+ _storage.set(REFRESH_KEY, null);
1199
+ },
1200
+ isAuthenticated() {
1201
+ return _storage.get(ACCESS_KEY) !== null;
1202
+ },
1203
+ // ── API key ───────────────────────────────────────────────────────
1204
+ /** In-memory API key. Falls back to storage, then NEXT_PUBLIC_API_KEY. */
1205
+ getApiKey() {
1206
+ return _apiKeyOverride ?? _storage.get(API_KEY_KEY) ?? defaultApiKey();
1207
+ },
1208
+ /** In-memory only (cleared on reload). */
1209
+ setApiKey(key) {
1210
+ _apiKeyOverride = key;
1211
+ },
1212
+ /** Persist to active storage backend (localStorage or cookie). */
1213
+ setApiKeyPersist(key) {
1214
+ _apiKeyOverride = key;
1215
+ _storage.set(API_KEY_KEY, key);
1216
+ },
1217
+ clearApiKey() {
1218
+ _apiKeyOverride = null;
1219
+ _storage.set(API_KEY_KEY, null);
1220
+ },
1221
+ // ── Locale ────────────────────────────────────────────────────────
1222
+ /** Override locale → falls back to NEXT_LOCALE cookie / navigator.language. */
1223
+ getLocale() {
1224
+ return _localeOverride ?? detectLocale();
1225
+ },
1226
+ setLocale(locale) {
1227
+ _localeOverride = locale;
1228
+ },
1229
+ // ── Base URL ──────────────────────────────────────────────────────
1230
+ getBaseUrl() {
1231
+ const url = _baseUrlOverride ?? defaultBaseUrl();
1232
+ return url.replace(/\/$/, "");
1233
+ },
1234
+ setBaseUrl(url) {
1235
+ _baseUrlOverride = url ? url.replace(/\/$/, "") : null;
1236
+ client.setConfig({ baseUrl: this.getBaseUrl() });
1237
+ },
1238
+ // ── Credentials toggle (Django session/CSRF cross-origin) ─────────
1239
+ getWithCredentials() {
1240
+ return _withCredentials;
1241
+ },
1242
+ setWithCredentials(value) {
1243
+ _withCredentials = value;
1244
+ client.setConfig({ credentials: value ? "include" : "same-origin" });
1245
+ },
1246
+ // ── 401 handler ───────────────────────────────────────────────────
1247
+ /**
1248
+ * Register a callback fired on every 401 response. Use this to wire
1249
+ * a token-refresh flow or a forced logout. Setting `null` removes
1250
+ * the handler.
1251
+ */
1252
+ onUnauthorized(cb) {
1253
+ _onUnauthorized = cb;
1254
+ }
1255
+ };
1256
+ client.setConfig({
1257
+ baseUrl: auth.getBaseUrl(),
1258
+ credentials: _withCredentials ? "include" : "same-origin"
1259
+ });
1260
+ client.interceptors.request.use((request) => {
1261
+ const token = auth.getToken();
1262
+ if (token) request.headers.set("Authorization", `Bearer ${token}`);
1263
+ const locale = auth.getLocale();
1264
+ if (locale) request.headers.set("Accept-Language", locale);
1265
+ const apiKey = auth.getApiKey();
1266
+ if (apiKey) request.headers.set("X-API-Key", apiKey);
1267
+ return request;
1268
+ });
1269
+ client.interceptors.response.use((response) => {
1270
+ if (response.status === 401 && _onUnauthorized) {
1271
+ try {
1272
+ _onUnauthorized(response);
1273
+ } catch {
1274
+ }
1275
+ }
1276
+ return response;
1277
+ });
1113
1278
 
1114
1279
  // src/_api/generated/helpers/logger.ts
1115
1280
  import { createConsola as createConsola2 } from "consola";
@@ -1206,90 +1371,56 @@ var APILogger = class {
1206
1371
  var defaultLogger = new APILogger();
1207
1372
 
1208
1373
  // src/_api/generated/_cfg_accounts/api.ts
1209
- var ACCESS_KEY = "cfg.access_token";
1210
- var REFRESH_KEY = "cfg.refresh_token";
1211
- function detectLocale() {
1212
- try {
1213
- if (typeof document !== "undefined") {
1214
- const m = document.cookie.match(/(?:^|;\s*)NEXT_LOCALE=([^;]*)/);
1215
- if (m) return decodeURIComponent(m[1]);
1216
- }
1217
- if (typeof navigator !== "undefined" && navigator.language) {
1218
- return navigator.language;
1219
- }
1220
- } catch {
1221
- }
1222
- return null;
1223
- }
1224
- __name(detectLocale, "detectLocale");
1225
1374
  var API = class {
1226
1375
  static {
1227
1376
  __name(this, "API");
1228
1377
  }
1229
- baseUrl;
1230
- storage;
1231
- locale;
1232
- apiKey;
1233
1378
  logger;
1234
- constructor(baseUrl2, opts = {}) {
1235
- this.baseUrl = baseUrl2.replace(/\/$/, "");
1236
- this.storage = opts.storage ?? new LocalStorageAdapter();
1379
+ constructor(_baseUrl, opts = {}) {
1237
1380
  this.logger = new APILogger(opts.logger);
1238
- this.locale = opts.locale ?? null;
1239
- this.apiKey = opts.apiKey ?? (typeof process !== "undefined" ? process.env?.NEXT_PUBLIC_API_KEY ?? null : null);
1240
- const credentials = opts.withCredentials ?? true ? "include" : "same-origin";
1241
- client.setConfig({ baseUrl: this.baseUrl, credentials });
1242
- client.interceptors.request.use((request) => {
1243
- const access = this.getToken();
1244
- if (access) request.headers.set("Authorization", `Bearer ${access}`);
1245
- const locale = this.locale ?? detectLocale();
1246
- if (locale) request.headers.set("Accept-Language", locale);
1247
- if (this.apiKey) request.headers.set("X-API-Key", this.apiKey);
1248
- return request;
1249
- });
1381
+ if (_baseUrl) auth.setBaseUrl(_baseUrl);
1382
+ if (opts.locale !== void 0) auth.setLocale(opts.locale);
1383
+ if (opts.apiKey !== void 0) auth.setApiKey(opts.apiKey);
1384
+ if (opts.withCredentials !== void 0) auth.setWithCredentials(opts.withCredentials);
1250
1385
  }
1251
1386
  // ── Base URL ────────────────────────────────────────────────────────────
1252
1387
  getBaseUrl() {
1253
- return this.baseUrl;
1388
+ return auth.getBaseUrl();
1254
1389
  }
1255
1390
  setBaseUrl(url) {
1256
- this.baseUrl = url.replace(/\/$/, "");
1257
- client.setConfig({ baseUrl: this.baseUrl });
1391
+ auth.setBaseUrl(url);
1258
1392
  }
1259
1393
  // ── Tokens ──────────────────────────────────────────────────────────────
1260
1394
  getToken() {
1261
- return this.storage.getItem(ACCESS_KEY);
1395
+ return auth.getToken();
1262
1396
  }
1263
1397
  setToken(token) {
1264
- if (token) this.storage.setItem(ACCESS_KEY, token);
1265
- else this.storage.removeItem(ACCESS_KEY);
1398
+ auth.setToken(token);
1266
1399
  }
1267
1400
  getRefreshToken() {
1268
- return this.storage.getItem(REFRESH_KEY);
1401
+ return auth.getRefreshToken();
1269
1402
  }
1270
1403
  setRefreshToken(token) {
1271
- if (token) this.storage.setItem(REFRESH_KEY, token);
1272
- else this.storage.removeItem(REFRESH_KEY);
1404
+ auth.setRefreshToken(token);
1273
1405
  }
1274
1406
  clearToken() {
1275
- this.storage.removeItem(ACCESS_KEY);
1276
- this.storage.removeItem(REFRESH_KEY);
1407
+ auth.clearTokens();
1277
1408
  }
1278
1409
  isAuthenticated() {
1279
- return this.getToken() !== null;
1410
+ return auth.isAuthenticated();
1280
1411
  }
1281
1412
  // ── Locale / API key ────────────────────────────────────────────────────
1282
1413
  getLocale() {
1283
- return this.locale ?? detectLocale();
1414
+ return auth.getLocale();
1284
1415
  }
1285
1416
  setLocale(locale) {
1286
- this.locale = locale;
1417
+ auth.setLocale(locale);
1287
1418
  }
1288
1419
  getApiKey() {
1289
- return this.apiKey;
1420
+ return auth.getApiKey();
1290
1421
  }
1291
1422
  setApiKey(key) {
1292
- this.apiKey = key;
1423
+ auth.setApiKey(key);
1293
1424
  }
1294
1425
  };
1295
1426
 
@@ -1354,187 +1485,117 @@ var APIError = class extends Error {
1354
1485
  };
1355
1486
 
1356
1487
  // src/_api/generated/_cfg_centrifugo/api.ts
1357
- var ACCESS_KEY2 = "cfg.access_token";
1358
- var REFRESH_KEY2 = "cfg.refresh_token";
1359
- function detectLocale2() {
1360
- try {
1361
- if (typeof document !== "undefined") {
1362
- const m = document.cookie.match(/(?:^|;\s*)NEXT_LOCALE=([^;]*)/);
1363
- if (m) return decodeURIComponent(m[1]);
1364
- }
1365
- if (typeof navigator !== "undefined" && navigator.language) {
1366
- return navigator.language;
1367
- }
1368
- } catch {
1369
- }
1370
- return null;
1371
- }
1372
- __name(detectLocale2, "detectLocale");
1373
1488
  var API2 = class {
1374
1489
  static {
1375
1490
  __name(this, "API");
1376
1491
  }
1377
- baseUrl;
1378
- storage;
1379
- locale;
1380
- apiKey;
1381
1492
  logger;
1382
- constructor(baseUrl2, opts = {}) {
1383
- this.baseUrl = baseUrl2.replace(/\/$/, "");
1384
- this.storage = opts.storage ?? new LocalStorageAdapter();
1493
+ constructor(_baseUrl, opts = {}) {
1385
1494
  this.logger = new APILogger(opts.logger);
1386
- this.locale = opts.locale ?? null;
1387
- this.apiKey = opts.apiKey ?? (typeof process !== "undefined" ? process.env?.NEXT_PUBLIC_API_KEY ?? null : null);
1388
- const credentials = opts.withCredentials ?? true ? "include" : "same-origin";
1389
- client.setConfig({ baseUrl: this.baseUrl, credentials });
1390
- client.interceptors.request.use((request) => {
1391
- const access = this.getToken();
1392
- if (access) request.headers.set("Authorization", `Bearer ${access}`);
1393
- const locale = this.locale ?? detectLocale2();
1394
- if (locale) request.headers.set("Accept-Language", locale);
1395
- if (this.apiKey) request.headers.set("X-API-Key", this.apiKey);
1396
- return request;
1397
- });
1495
+ if (_baseUrl) auth.setBaseUrl(_baseUrl);
1496
+ if (opts.locale !== void 0) auth.setLocale(opts.locale);
1497
+ if (opts.apiKey !== void 0) auth.setApiKey(opts.apiKey);
1498
+ if (opts.withCredentials !== void 0) auth.setWithCredentials(opts.withCredentials);
1398
1499
  }
1399
1500
  // ── Base URL ────────────────────────────────────────────────────────────
1400
1501
  getBaseUrl() {
1401
- return this.baseUrl;
1502
+ return auth.getBaseUrl();
1402
1503
  }
1403
1504
  setBaseUrl(url) {
1404
- this.baseUrl = url.replace(/\/$/, "");
1405
- client.setConfig({ baseUrl: this.baseUrl });
1505
+ auth.setBaseUrl(url);
1406
1506
  }
1407
1507
  // ── Tokens ──────────────────────────────────────────────────────────────
1408
1508
  getToken() {
1409
- return this.storage.getItem(ACCESS_KEY2);
1509
+ return auth.getToken();
1410
1510
  }
1411
1511
  setToken(token) {
1412
- if (token) this.storage.setItem(ACCESS_KEY2, token);
1413
- else this.storage.removeItem(ACCESS_KEY2);
1512
+ auth.setToken(token);
1414
1513
  }
1415
1514
  getRefreshToken() {
1416
- return this.storage.getItem(REFRESH_KEY2);
1515
+ return auth.getRefreshToken();
1417
1516
  }
1418
1517
  setRefreshToken(token) {
1419
- if (token) this.storage.setItem(REFRESH_KEY2, token);
1420
- else this.storage.removeItem(REFRESH_KEY2);
1518
+ auth.setRefreshToken(token);
1421
1519
  }
1422
1520
  clearToken() {
1423
- this.storage.removeItem(ACCESS_KEY2);
1424
- this.storage.removeItem(REFRESH_KEY2);
1521
+ auth.clearTokens();
1425
1522
  }
1426
1523
  isAuthenticated() {
1427
- return this.getToken() !== null;
1524
+ return auth.isAuthenticated();
1428
1525
  }
1429
1526
  // ── Locale / API key ────────────────────────────────────────────────────
1430
1527
  getLocale() {
1431
- return this.locale ?? detectLocale2();
1528
+ return auth.getLocale();
1432
1529
  }
1433
1530
  setLocale(locale) {
1434
- this.locale = locale;
1531
+ auth.setLocale(locale);
1435
1532
  }
1436
1533
  getApiKey() {
1437
- return this.apiKey;
1534
+ return auth.getApiKey();
1438
1535
  }
1439
1536
  setApiKey(key) {
1440
- this.apiKey = key;
1537
+ auth.setApiKey(key);
1441
1538
  }
1442
1539
  };
1443
1540
 
1444
1541
  // src/_api/generated/_cfg_totp/api.ts
1445
- var ACCESS_KEY3 = "cfg.access_token";
1446
- var REFRESH_KEY3 = "cfg.refresh_token";
1447
- function detectLocale3() {
1448
- try {
1449
- if (typeof document !== "undefined") {
1450
- const m = document.cookie.match(/(?:^|;\s*)NEXT_LOCALE=([^;]*)/);
1451
- if (m) return decodeURIComponent(m[1]);
1452
- }
1453
- if (typeof navigator !== "undefined" && navigator.language) {
1454
- return navigator.language;
1455
- }
1456
- } catch {
1457
- }
1458
- return null;
1459
- }
1460
- __name(detectLocale3, "detectLocale");
1461
1542
  var API3 = class {
1462
1543
  static {
1463
1544
  __name(this, "API");
1464
1545
  }
1465
- baseUrl;
1466
- storage;
1467
- locale;
1468
- apiKey;
1469
1546
  logger;
1470
- constructor(baseUrl2, opts = {}) {
1471
- this.baseUrl = baseUrl2.replace(/\/$/, "");
1472
- this.storage = opts.storage ?? new LocalStorageAdapter();
1547
+ constructor(_baseUrl, opts = {}) {
1473
1548
  this.logger = new APILogger(opts.logger);
1474
- this.locale = opts.locale ?? null;
1475
- this.apiKey = opts.apiKey ?? (typeof process !== "undefined" ? process.env?.NEXT_PUBLIC_API_KEY ?? null : null);
1476
- const credentials = opts.withCredentials ?? true ? "include" : "same-origin";
1477
- client.setConfig({ baseUrl: this.baseUrl, credentials });
1478
- client.interceptors.request.use((request) => {
1479
- const access = this.getToken();
1480
- if (access) request.headers.set("Authorization", `Bearer ${access}`);
1481
- const locale = this.locale ?? detectLocale3();
1482
- if (locale) request.headers.set("Accept-Language", locale);
1483
- if (this.apiKey) request.headers.set("X-API-Key", this.apiKey);
1484
- return request;
1485
- });
1549
+ if (_baseUrl) auth.setBaseUrl(_baseUrl);
1550
+ if (opts.locale !== void 0) auth.setLocale(opts.locale);
1551
+ if (opts.apiKey !== void 0) auth.setApiKey(opts.apiKey);
1552
+ if (opts.withCredentials !== void 0) auth.setWithCredentials(opts.withCredentials);
1486
1553
  }
1487
1554
  // ── Base URL ────────────────────────────────────────────────────────────
1488
1555
  getBaseUrl() {
1489
- return this.baseUrl;
1556
+ return auth.getBaseUrl();
1490
1557
  }
1491
1558
  setBaseUrl(url) {
1492
- this.baseUrl = url.replace(/\/$/, "");
1493
- client.setConfig({ baseUrl: this.baseUrl });
1559
+ auth.setBaseUrl(url);
1494
1560
  }
1495
1561
  // ── Tokens ──────────────────────────────────────────────────────────────
1496
1562
  getToken() {
1497
- return this.storage.getItem(ACCESS_KEY3);
1563
+ return auth.getToken();
1498
1564
  }
1499
1565
  setToken(token) {
1500
- if (token) this.storage.setItem(ACCESS_KEY3, token);
1501
- else this.storage.removeItem(ACCESS_KEY3);
1566
+ auth.setToken(token);
1502
1567
  }
1503
1568
  getRefreshToken() {
1504
- return this.storage.getItem(REFRESH_KEY3);
1569
+ return auth.getRefreshToken();
1505
1570
  }
1506
1571
  setRefreshToken(token) {
1507
- if (token) this.storage.setItem(REFRESH_KEY3, token);
1508
- else this.storage.removeItem(REFRESH_KEY3);
1572
+ auth.setRefreshToken(token);
1509
1573
  }
1510
1574
  clearToken() {
1511
- this.storage.removeItem(ACCESS_KEY3);
1512
- this.storage.removeItem(REFRESH_KEY3);
1575
+ auth.clearTokens();
1513
1576
  }
1514
1577
  isAuthenticated() {
1515
- return this.getToken() !== null;
1578
+ return auth.isAuthenticated();
1516
1579
  }
1517
1580
  // ── Locale / API key ────────────────────────────────────────────────────
1518
1581
  getLocale() {
1519
- return this.locale ?? detectLocale3();
1582
+ return auth.getLocale();
1520
1583
  }
1521
1584
  setLocale(locale) {
1522
- this.locale = locale;
1585
+ auth.setLocale(locale);
1523
1586
  }
1524
1587
  getApiKey() {
1525
- return this.apiKey;
1588
+ return auth.getApiKey();
1526
1589
  }
1527
1590
  setApiKey(key) {
1528
- this.apiKey = key;
1591
+ auth.setApiKey(key);
1529
1592
  }
1530
1593
  };
1531
1594
 
1532
1595
  // src/_api/generated/index.ts
1533
- var isStaticBuild2 = process.env.NEXT_PUBLIC_STATIC_BUILD === "true";
1534
- var baseUrl = isStaticBuild2 ? "" : process.env.NEXT_PUBLIC_API_URL || "";
1535
- var CfgAccountsApi = new API(baseUrl, { storage: new LocalStorageAdapter() });
1536
- var CfgCentrifugoApi = new API2(baseUrl, { storage: new LocalStorageAdapter() });
1537
- var CfgTotpApi = new API3(baseUrl, { storage: new LocalStorageAdapter() });
1596
+ var CfgAccountsApi = new API();
1597
+ var CfgCentrifugoApi = new API2();
1598
+ var CfgTotpApi = new API3();
1538
1599
 
1539
1600
  // src/_api/generated/sdk.gen.ts
1540
1601
  var Cfg = class {