@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.cjs CHANGED
@@ -102,7 +102,7 @@ __name(withBasePath, "withBasePath");
102
102
  function useCfgRouter() {
103
103
  const router = (0, import_navigation.useRouter)();
104
104
  const basePath = (0, import_react.useMemo)(() => getBasePath(), []);
105
- const isStaticBuild3 = (0, import_react.useMemo)(() => {
105
+ const isStaticBuild2 = (0, import_react.useMemo)(() => {
106
106
  return typeof process !== "undefined" && process.env.NEXT_PUBLIC_STATIC_BUILD === "true";
107
107
  }, []);
108
108
  const push = (0, import_react.useCallback)((href, options) => {
@@ -664,14 +664,14 @@ var defaultPathSerializer = /* @__PURE__ */ __name(({ path, url: _url }) => {
664
664
  return url;
665
665
  }, "defaultPathSerializer");
666
666
  var getUrl = /* @__PURE__ */ __name(({
667
- baseUrl: baseUrl2,
667
+ baseUrl,
668
668
  path,
669
669
  query,
670
670
  querySerializer,
671
671
  url: _url
672
672
  }) => {
673
673
  const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
674
- let url = (baseUrl2 ?? "") + pathUrl;
674
+ let url = (baseUrl ?? "") + pathUrl;
675
675
  if (path) {
676
676
  url = defaultPathSerializer({ path, url });
677
677
  }
@@ -702,15 +702,15 @@ function getValidRequestBody(options) {
702
702
  __name(getValidRequestBody, "getValidRequestBody");
703
703
 
704
704
  // src/_api/generated/core/auth.gen.ts
705
- var getAuthToken = /* @__PURE__ */ __name(async (auth, callback) => {
706
- const token = typeof callback === "function" ? await callback(auth) : callback;
705
+ var getAuthToken = /* @__PURE__ */ __name(async (auth2, callback) => {
706
+ const token = typeof callback === "function" ? await callback(auth2) : callback;
707
707
  if (!token) {
708
708
  return;
709
709
  }
710
- if (auth.scheme === "bearer") {
710
+ if (auth2.scheme === "bearer") {
711
711
  return `Bearer ${token}`;
712
712
  }
713
- if (auth.scheme === "basic") {
713
+ if (auth2.scheme === "basic") {
714
714
  return `Basic ${btoa(token)}`;
715
715
  }
716
716
  return token;
@@ -799,16 +799,16 @@ var setAuthParams = /* @__PURE__ */ __name(async ({
799
799
  security,
800
800
  ...options
801
801
  }) => {
802
- for (const auth of security) {
803
- if (checkForExistence(options, auth.name)) {
802
+ for (const auth2 of security) {
803
+ if (checkForExistence(options, auth2.name)) {
804
804
  continue;
805
805
  }
806
- const token = await getAuthToken(auth, options.auth);
806
+ const token = await getAuthToken(auth2, options.auth);
807
807
  if (!token) {
808
808
  continue;
809
809
  }
810
- const name = auth.name ?? "Authorization";
811
- switch (auth.in) {
810
+ const name = auth2.name ?? "Authorization";
811
+ switch (auth2.in) {
812
812
  case "query":
813
813
  if (!options.query) {
814
814
  options.query = {};
@@ -1136,41 +1136,206 @@ var createClient = /* @__PURE__ */ __name((config = {}) => {
1136
1136
  // src/_api/generated/client.gen.ts
1137
1137
  var client = createClient(createConfig({ baseUrl: "http://localhost:8000" }));
1138
1138
 
1139
- // src/_api/generated/helpers/storage.ts
1140
- var LocalStorageAdapter = class {
1141
- static {
1142
- __name(this, "LocalStorageAdapter");
1143
- }
1144
- getItem(key) {
1145
- if (typeof window === "undefined") return null;
1139
+ // src/_api/generated/helpers/auth.ts
1140
+ var ACCESS_KEY = "cfg.access_token";
1141
+ var REFRESH_KEY = "cfg.refresh_token";
1142
+ var API_KEY_KEY = "cfg.api_key";
1143
+ var isBrowser2 = typeof window !== "undefined";
1144
+ var localStorageBackend = {
1145
+ get(key) {
1146
+ if (!isBrowser2) return null;
1146
1147
  try {
1147
1148
  return window.localStorage.getItem(key);
1148
1149
  } catch {
1149
1150
  return null;
1150
1151
  }
1151
- }
1152
- setItem(key, value) {
1153
- if (typeof window === "undefined") return;
1152
+ },
1153
+ set(key, value) {
1154
+ if (!isBrowser2) return;
1154
1155
  try {
1155
- window.localStorage.setItem(key, value);
1156
+ if (value === null) window.localStorage.removeItem(key);
1157
+ else window.localStorage.setItem(key, value);
1156
1158
  } catch {
1157
1159
  }
1158
1160
  }
1159
- removeItem(key) {
1160
- if (typeof window === "undefined") return;
1161
+ };
1162
+ var COOKIE_MAX_AGE = 60 * 60 * 24 * 30;
1163
+ var cookieBackend = {
1164
+ get(key) {
1165
+ if (!isBrowser2) return null;
1161
1166
  try {
1162
- window.localStorage.removeItem(key);
1167
+ const re = new RegExp(`(?:^|;\\s*)${encodeURIComponent(key)}=([^;]*)`);
1168
+ const m = document.cookie.match(re);
1169
+ return m ? decodeURIComponent(m[1]) : null;
1163
1170
  } catch {
1171
+ return null;
1164
1172
  }
1165
- }
1166
- clear() {
1167
- if (typeof window === "undefined") return;
1173
+ },
1174
+ set(key, value) {
1175
+ if (!isBrowser2) return;
1168
1176
  try {
1169
- window.localStorage.clear();
1177
+ const k = encodeURIComponent(key);
1178
+ const secure = window.location.protocol === "https:" ? "; Secure" : "";
1179
+ if (value === null) {
1180
+ document.cookie = `${k}=; Path=/; Max-Age=0; SameSite=Lax${secure}`;
1181
+ } else {
1182
+ const v = encodeURIComponent(value);
1183
+ document.cookie = `${k}=${v}; Path=/; Max-Age=${COOKIE_MAX_AGE}; SameSite=Lax${secure}`;
1184
+ }
1170
1185
  } catch {
1171
1186
  }
1172
1187
  }
1173
1188
  };
1189
+ var _storage = localStorageBackend;
1190
+ var _storageMode = "localStorage";
1191
+ function detectLocale() {
1192
+ try {
1193
+ if (typeof document !== "undefined") {
1194
+ const m = document.cookie.match(/(?:^|;\s*)NEXT_LOCALE=([^;]*)/);
1195
+ if (m) return decodeURIComponent(m[1]);
1196
+ }
1197
+ if (typeof navigator !== "undefined" && navigator.language) {
1198
+ return navigator.language;
1199
+ }
1200
+ } catch {
1201
+ }
1202
+ return null;
1203
+ }
1204
+ __name(detectLocale, "detectLocale");
1205
+ function defaultBaseUrl() {
1206
+ try {
1207
+ if (typeof process !== "undefined" && process.env) {
1208
+ if (process.env.NEXT_PUBLIC_STATIC_BUILD === "true") return "";
1209
+ return process.env.NEXT_PUBLIC_API_URL || "";
1210
+ }
1211
+ } catch {
1212
+ }
1213
+ return "";
1214
+ }
1215
+ __name(defaultBaseUrl, "defaultBaseUrl");
1216
+ function defaultApiKey() {
1217
+ try {
1218
+ if (typeof process !== "undefined" && process.env?.NEXT_PUBLIC_API_KEY) {
1219
+ return process.env.NEXT_PUBLIC_API_KEY;
1220
+ }
1221
+ } catch {
1222
+ }
1223
+ return null;
1224
+ }
1225
+ __name(defaultApiKey, "defaultApiKey");
1226
+ var _localeOverride = null;
1227
+ var _apiKeyOverride = null;
1228
+ var _baseUrlOverride = null;
1229
+ var _withCredentials = true;
1230
+ var _onUnauthorized = null;
1231
+ var auth = {
1232
+ // ── Storage mode ──────────────────────────────────────────────────
1233
+ getStorageMode() {
1234
+ return _storageMode;
1235
+ },
1236
+ /**
1237
+ * Switch the storage backend. Existing values in the *previous*
1238
+ * backend are NOT migrated — set fresh values after switching.
1239
+ */
1240
+ setStorageMode(mode) {
1241
+ _storageMode = mode;
1242
+ _storage = mode === "cookie" ? cookieBackend : localStorageBackend;
1243
+ },
1244
+ // ── Bearer token ──────────────────────────────────────────────────
1245
+ getToken() {
1246
+ return _storage.get(ACCESS_KEY);
1247
+ },
1248
+ setToken(token) {
1249
+ _storage.set(ACCESS_KEY, token);
1250
+ },
1251
+ getRefreshToken() {
1252
+ return _storage.get(REFRESH_KEY);
1253
+ },
1254
+ setRefreshToken(token) {
1255
+ _storage.set(REFRESH_KEY, token);
1256
+ },
1257
+ clearTokens() {
1258
+ _storage.set(ACCESS_KEY, null);
1259
+ _storage.set(REFRESH_KEY, null);
1260
+ },
1261
+ isAuthenticated() {
1262
+ return _storage.get(ACCESS_KEY) !== null;
1263
+ },
1264
+ // ── API key ───────────────────────────────────────────────────────
1265
+ /** In-memory API key. Falls back to storage, then NEXT_PUBLIC_API_KEY. */
1266
+ getApiKey() {
1267
+ return _apiKeyOverride ?? _storage.get(API_KEY_KEY) ?? defaultApiKey();
1268
+ },
1269
+ /** In-memory only (cleared on reload). */
1270
+ setApiKey(key) {
1271
+ _apiKeyOverride = key;
1272
+ },
1273
+ /** Persist to active storage backend (localStorage or cookie). */
1274
+ setApiKeyPersist(key) {
1275
+ _apiKeyOverride = key;
1276
+ _storage.set(API_KEY_KEY, key);
1277
+ },
1278
+ clearApiKey() {
1279
+ _apiKeyOverride = null;
1280
+ _storage.set(API_KEY_KEY, null);
1281
+ },
1282
+ // ── Locale ────────────────────────────────────────────────────────
1283
+ /** Override locale → falls back to NEXT_LOCALE cookie / navigator.language. */
1284
+ getLocale() {
1285
+ return _localeOverride ?? detectLocale();
1286
+ },
1287
+ setLocale(locale) {
1288
+ _localeOverride = locale;
1289
+ },
1290
+ // ── Base URL ──────────────────────────────────────────────────────
1291
+ getBaseUrl() {
1292
+ const url = _baseUrlOverride ?? defaultBaseUrl();
1293
+ return url.replace(/\/$/, "");
1294
+ },
1295
+ setBaseUrl(url) {
1296
+ _baseUrlOverride = url ? url.replace(/\/$/, "") : null;
1297
+ client.setConfig({ baseUrl: this.getBaseUrl() });
1298
+ },
1299
+ // ── Credentials toggle (Django session/CSRF cross-origin) ─────────
1300
+ getWithCredentials() {
1301
+ return _withCredentials;
1302
+ },
1303
+ setWithCredentials(value) {
1304
+ _withCredentials = value;
1305
+ client.setConfig({ credentials: value ? "include" : "same-origin" });
1306
+ },
1307
+ // ── 401 handler ───────────────────────────────────────────────────
1308
+ /**
1309
+ * Register a callback fired on every 401 response. Use this to wire
1310
+ * a token-refresh flow or a forced logout. Setting `null` removes
1311
+ * the handler.
1312
+ */
1313
+ onUnauthorized(cb) {
1314
+ _onUnauthorized = cb;
1315
+ }
1316
+ };
1317
+ client.setConfig({
1318
+ baseUrl: auth.getBaseUrl(),
1319
+ credentials: _withCredentials ? "include" : "same-origin"
1320
+ });
1321
+ client.interceptors.request.use((request) => {
1322
+ const token = auth.getToken();
1323
+ if (token) request.headers.set("Authorization", `Bearer ${token}`);
1324
+ const locale = auth.getLocale();
1325
+ if (locale) request.headers.set("Accept-Language", locale);
1326
+ const apiKey = auth.getApiKey();
1327
+ if (apiKey) request.headers.set("X-API-Key", apiKey);
1328
+ return request;
1329
+ });
1330
+ client.interceptors.response.use((response) => {
1331
+ if (response.status === 401 && _onUnauthorized) {
1332
+ try {
1333
+ _onUnauthorized(response);
1334
+ } catch {
1335
+ }
1336
+ }
1337
+ return response;
1338
+ });
1174
1339
 
1175
1340
  // src/_api/generated/helpers/logger.ts
1176
1341
  var import_consola2 = require("consola");
@@ -1267,90 +1432,56 @@ var APILogger = class {
1267
1432
  var defaultLogger = new APILogger();
1268
1433
 
1269
1434
  // src/_api/generated/_cfg_accounts/api.ts
1270
- var ACCESS_KEY = "cfg.access_token";
1271
- var REFRESH_KEY = "cfg.refresh_token";
1272
- function detectLocale() {
1273
- try {
1274
- if (typeof document !== "undefined") {
1275
- const m = document.cookie.match(/(?:^|;\s*)NEXT_LOCALE=([^;]*)/);
1276
- if (m) return decodeURIComponent(m[1]);
1277
- }
1278
- if (typeof navigator !== "undefined" && navigator.language) {
1279
- return navigator.language;
1280
- }
1281
- } catch {
1282
- }
1283
- return null;
1284
- }
1285
- __name(detectLocale, "detectLocale");
1286
1435
  var API = class {
1287
1436
  static {
1288
1437
  __name(this, "API");
1289
1438
  }
1290
- baseUrl;
1291
- storage;
1292
- locale;
1293
- apiKey;
1294
1439
  logger;
1295
- constructor(baseUrl2, opts = {}) {
1296
- this.baseUrl = baseUrl2.replace(/\/$/, "");
1297
- this.storage = opts.storage ?? new LocalStorageAdapter();
1440
+ constructor(_baseUrl, opts = {}) {
1298
1441
  this.logger = new APILogger(opts.logger);
1299
- this.locale = opts.locale ?? null;
1300
- this.apiKey = opts.apiKey ?? (typeof process !== "undefined" ? process.env?.NEXT_PUBLIC_API_KEY ?? null : null);
1301
- const credentials = opts.withCredentials ?? true ? "include" : "same-origin";
1302
- client.setConfig({ baseUrl: this.baseUrl, credentials });
1303
- client.interceptors.request.use((request) => {
1304
- const access = this.getToken();
1305
- if (access) request.headers.set("Authorization", `Bearer ${access}`);
1306
- const locale = this.locale ?? detectLocale();
1307
- if (locale) request.headers.set("Accept-Language", locale);
1308
- if (this.apiKey) request.headers.set("X-API-Key", this.apiKey);
1309
- return request;
1310
- });
1442
+ if (_baseUrl) auth.setBaseUrl(_baseUrl);
1443
+ if (opts.locale !== void 0) auth.setLocale(opts.locale);
1444
+ if (opts.apiKey !== void 0) auth.setApiKey(opts.apiKey);
1445
+ if (opts.withCredentials !== void 0) auth.setWithCredentials(opts.withCredentials);
1311
1446
  }
1312
1447
  // ── Base URL ────────────────────────────────────────────────────────────
1313
1448
  getBaseUrl() {
1314
- return this.baseUrl;
1449
+ return auth.getBaseUrl();
1315
1450
  }
1316
1451
  setBaseUrl(url) {
1317
- this.baseUrl = url.replace(/\/$/, "");
1318
- client.setConfig({ baseUrl: this.baseUrl });
1452
+ auth.setBaseUrl(url);
1319
1453
  }
1320
1454
  // ── Tokens ──────────────────────────────────────────────────────────────
1321
1455
  getToken() {
1322
- return this.storage.getItem(ACCESS_KEY);
1456
+ return auth.getToken();
1323
1457
  }
1324
1458
  setToken(token) {
1325
- if (token) this.storage.setItem(ACCESS_KEY, token);
1326
- else this.storage.removeItem(ACCESS_KEY);
1459
+ auth.setToken(token);
1327
1460
  }
1328
1461
  getRefreshToken() {
1329
- return this.storage.getItem(REFRESH_KEY);
1462
+ return auth.getRefreshToken();
1330
1463
  }
1331
1464
  setRefreshToken(token) {
1332
- if (token) this.storage.setItem(REFRESH_KEY, token);
1333
- else this.storage.removeItem(REFRESH_KEY);
1465
+ auth.setRefreshToken(token);
1334
1466
  }
1335
1467
  clearToken() {
1336
- this.storage.removeItem(ACCESS_KEY);
1337
- this.storage.removeItem(REFRESH_KEY);
1468
+ auth.clearTokens();
1338
1469
  }
1339
1470
  isAuthenticated() {
1340
- return this.getToken() !== null;
1471
+ return auth.isAuthenticated();
1341
1472
  }
1342
1473
  // ── Locale / API key ────────────────────────────────────────────────────
1343
1474
  getLocale() {
1344
- return this.locale ?? detectLocale();
1475
+ return auth.getLocale();
1345
1476
  }
1346
1477
  setLocale(locale) {
1347
- this.locale = locale;
1478
+ auth.setLocale(locale);
1348
1479
  }
1349
1480
  getApiKey() {
1350
- return this.apiKey;
1481
+ return auth.getApiKey();
1351
1482
  }
1352
1483
  setApiKey(key) {
1353
- this.apiKey = key;
1484
+ auth.setApiKey(key);
1354
1485
  }
1355
1486
  };
1356
1487
 
@@ -1415,187 +1546,117 @@ var APIError = class extends Error {
1415
1546
  };
1416
1547
 
1417
1548
  // src/_api/generated/_cfg_centrifugo/api.ts
1418
- var ACCESS_KEY2 = "cfg.access_token";
1419
- var REFRESH_KEY2 = "cfg.refresh_token";
1420
- function detectLocale2() {
1421
- try {
1422
- if (typeof document !== "undefined") {
1423
- const m = document.cookie.match(/(?:^|;\s*)NEXT_LOCALE=([^;]*)/);
1424
- if (m) return decodeURIComponent(m[1]);
1425
- }
1426
- if (typeof navigator !== "undefined" && navigator.language) {
1427
- return navigator.language;
1428
- }
1429
- } catch {
1430
- }
1431
- return null;
1432
- }
1433
- __name(detectLocale2, "detectLocale");
1434
1549
  var API2 = class {
1435
1550
  static {
1436
1551
  __name(this, "API");
1437
1552
  }
1438
- baseUrl;
1439
- storage;
1440
- locale;
1441
- apiKey;
1442
1553
  logger;
1443
- constructor(baseUrl2, opts = {}) {
1444
- this.baseUrl = baseUrl2.replace(/\/$/, "");
1445
- this.storage = opts.storage ?? new LocalStorageAdapter();
1554
+ constructor(_baseUrl, opts = {}) {
1446
1555
  this.logger = new APILogger(opts.logger);
1447
- this.locale = opts.locale ?? null;
1448
- this.apiKey = opts.apiKey ?? (typeof process !== "undefined" ? process.env?.NEXT_PUBLIC_API_KEY ?? null : null);
1449
- const credentials = opts.withCredentials ?? true ? "include" : "same-origin";
1450
- client.setConfig({ baseUrl: this.baseUrl, credentials });
1451
- client.interceptors.request.use((request) => {
1452
- const access = this.getToken();
1453
- if (access) request.headers.set("Authorization", `Bearer ${access}`);
1454
- const locale = this.locale ?? detectLocale2();
1455
- if (locale) request.headers.set("Accept-Language", locale);
1456
- if (this.apiKey) request.headers.set("X-API-Key", this.apiKey);
1457
- return request;
1458
- });
1556
+ if (_baseUrl) auth.setBaseUrl(_baseUrl);
1557
+ if (opts.locale !== void 0) auth.setLocale(opts.locale);
1558
+ if (opts.apiKey !== void 0) auth.setApiKey(opts.apiKey);
1559
+ if (opts.withCredentials !== void 0) auth.setWithCredentials(opts.withCredentials);
1459
1560
  }
1460
1561
  // ── Base URL ────────────────────────────────────────────────────────────
1461
1562
  getBaseUrl() {
1462
- return this.baseUrl;
1563
+ return auth.getBaseUrl();
1463
1564
  }
1464
1565
  setBaseUrl(url) {
1465
- this.baseUrl = url.replace(/\/$/, "");
1466
- client.setConfig({ baseUrl: this.baseUrl });
1566
+ auth.setBaseUrl(url);
1467
1567
  }
1468
1568
  // ── Tokens ──────────────────────────────────────────────────────────────
1469
1569
  getToken() {
1470
- return this.storage.getItem(ACCESS_KEY2);
1570
+ return auth.getToken();
1471
1571
  }
1472
1572
  setToken(token) {
1473
- if (token) this.storage.setItem(ACCESS_KEY2, token);
1474
- else this.storage.removeItem(ACCESS_KEY2);
1573
+ auth.setToken(token);
1475
1574
  }
1476
1575
  getRefreshToken() {
1477
- return this.storage.getItem(REFRESH_KEY2);
1576
+ return auth.getRefreshToken();
1478
1577
  }
1479
1578
  setRefreshToken(token) {
1480
- if (token) this.storage.setItem(REFRESH_KEY2, token);
1481
- else this.storage.removeItem(REFRESH_KEY2);
1579
+ auth.setRefreshToken(token);
1482
1580
  }
1483
1581
  clearToken() {
1484
- this.storage.removeItem(ACCESS_KEY2);
1485
- this.storage.removeItem(REFRESH_KEY2);
1582
+ auth.clearTokens();
1486
1583
  }
1487
1584
  isAuthenticated() {
1488
- return this.getToken() !== null;
1585
+ return auth.isAuthenticated();
1489
1586
  }
1490
1587
  // ── Locale / API key ────────────────────────────────────────────────────
1491
1588
  getLocale() {
1492
- return this.locale ?? detectLocale2();
1589
+ return auth.getLocale();
1493
1590
  }
1494
1591
  setLocale(locale) {
1495
- this.locale = locale;
1592
+ auth.setLocale(locale);
1496
1593
  }
1497
1594
  getApiKey() {
1498
- return this.apiKey;
1595
+ return auth.getApiKey();
1499
1596
  }
1500
1597
  setApiKey(key) {
1501
- this.apiKey = key;
1598
+ auth.setApiKey(key);
1502
1599
  }
1503
1600
  };
1504
1601
 
1505
1602
  // src/_api/generated/_cfg_totp/api.ts
1506
- var ACCESS_KEY3 = "cfg.access_token";
1507
- var REFRESH_KEY3 = "cfg.refresh_token";
1508
- function detectLocale3() {
1509
- try {
1510
- if (typeof document !== "undefined") {
1511
- const m = document.cookie.match(/(?:^|;\s*)NEXT_LOCALE=([^;]*)/);
1512
- if (m) return decodeURIComponent(m[1]);
1513
- }
1514
- if (typeof navigator !== "undefined" && navigator.language) {
1515
- return navigator.language;
1516
- }
1517
- } catch {
1518
- }
1519
- return null;
1520
- }
1521
- __name(detectLocale3, "detectLocale");
1522
1603
  var API3 = class {
1523
1604
  static {
1524
1605
  __name(this, "API");
1525
1606
  }
1526
- baseUrl;
1527
- storage;
1528
- locale;
1529
- apiKey;
1530
1607
  logger;
1531
- constructor(baseUrl2, opts = {}) {
1532
- this.baseUrl = baseUrl2.replace(/\/$/, "");
1533
- this.storage = opts.storage ?? new LocalStorageAdapter();
1608
+ constructor(_baseUrl, opts = {}) {
1534
1609
  this.logger = new APILogger(opts.logger);
1535
- this.locale = opts.locale ?? null;
1536
- this.apiKey = opts.apiKey ?? (typeof process !== "undefined" ? process.env?.NEXT_PUBLIC_API_KEY ?? null : null);
1537
- const credentials = opts.withCredentials ?? true ? "include" : "same-origin";
1538
- client.setConfig({ baseUrl: this.baseUrl, credentials });
1539
- client.interceptors.request.use((request) => {
1540
- const access = this.getToken();
1541
- if (access) request.headers.set("Authorization", `Bearer ${access}`);
1542
- const locale = this.locale ?? detectLocale3();
1543
- if (locale) request.headers.set("Accept-Language", locale);
1544
- if (this.apiKey) request.headers.set("X-API-Key", this.apiKey);
1545
- return request;
1546
- });
1610
+ if (_baseUrl) auth.setBaseUrl(_baseUrl);
1611
+ if (opts.locale !== void 0) auth.setLocale(opts.locale);
1612
+ if (opts.apiKey !== void 0) auth.setApiKey(opts.apiKey);
1613
+ if (opts.withCredentials !== void 0) auth.setWithCredentials(opts.withCredentials);
1547
1614
  }
1548
1615
  // ── Base URL ────────────────────────────────────────────────────────────
1549
1616
  getBaseUrl() {
1550
- return this.baseUrl;
1617
+ return auth.getBaseUrl();
1551
1618
  }
1552
1619
  setBaseUrl(url) {
1553
- this.baseUrl = url.replace(/\/$/, "");
1554
- client.setConfig({ baseUrl: this.baseUrl });
1620
+ auth.setBaseUrl(url);
1555
1621
  }
1556
1622
  // ── Tokens ──────────────────────────────────────────────────────────────
1557
1623
  getToken() {
1558
- return this.storage.getItem(ACCESS_KEY3);
1624
+ return auth.getToken();
1559
1625
  }
1560
1626
  setToken(token) {
1561
- if (token) this.storage.setItem(ACCESS_KEY3, token);
1562
- else this.storage.removeItem(ACCESS_KEY3);
1627
+ auth.setToken(token);
1563
1628
  }
1564
1629
  getRefreshToken() {
1565
- return this.storage.getItem(REFRESH_KEY3);
1630
+ return auth.getRefreshToken();
1566
1631
  }
1567
1632
  setRefreshToken(token) {
1568
- if (token) this.storage.setItem(REFRESH_KEY3, token);
1569
- else this.storage.removeItem(REFRESH_KEY3);
1633
+ auth.setRefreshToken(token);
1570
1634
  }
1571
1635
  clearToken() {
1572
- this.storage.removeItem(ACCESS_KEY3);
1573
- this.storage.removeItem(REFRESH_KEY3);
1636
+ auth.clearTokens();
1574
1637
  }
1575
1638
  isAuthenticated() {
1576
- return this.getToken() !== null;
1639
+ return auth.isAuthenticated();
1577
1640
  }
1578
1641
  // ── Locale / API key ────────────────────────────────────────────────────
1579
1642
  getLocale() {
1580
- return this.locale ?? detectLocale3();
1643
+ return auth.getLocale();
1581
1644
  }
1582
1645
  setLocale(locale) {
1583
- this.locale = locale;
1646
+ auth.setLocale(locale);
1584
1647
  }
1585
1648
  getApiKey() {
1586
- return this.apiKey;
1649
+ return auth.getApiKey();
1587
1650
  }
1588
1651
  setApiKey(key) {
1589
- this.apiKey = key;
1652
+ auth.setApiKey(key);
1590
1653
  }
1591
1654
  };
1592
1655
 
1593
1656
  // src/_api/generated/index.ts
1594
- var isStaticBuild2 = process.env.NEXT_PUBLIC_STATIC_BUILD === "true";
1595
- var baseUrl = isStaticBuild2 ? "" : process.env.NEXT_PUBLIC_API_URL || "";
1596
- var CfgAccountsApi = new API(baseUrl, { storage: new LocalStorageAdapter() });
1597
- var CfgCentrifugoApi = new API2(baseUrl, { storage: new LocalStorageAdapter() });
1598
- var CfgTotpApi = new API3(baseUrl, { storage: new LocalStorageAdapter() });
1657
+ var CfgAccountsApi = new API();
1658
+ var CfgCentrifugoApi = new API2();
1659
+ var CfgTotpApi = new API3();
1599
1660
 
1600
1661
  // src/_api/generated/sdk.gen.ts
1601
1662
  var Cfg = class {