@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/clients.cjs CHANGED
@@ -357,14 +357,14 @@ var defaultPathSerializer = /* @__PURE__ */ __name(({ path, url: _url }) => {
357
357
  return url;
358
358
  }, "defaultPathSerializer");
359
359
  var getUrl = /* @__PURE__ */ __name(({
360
- baseUrl: baseUrl2,
360
+ baseUrl,
361
361
  path,
362
362
  query,
363
363
  querySerializer,
364
364
  url: _url
365
365
  }) => {
366
366
  const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
367
- let url = (baseUrl2 ?? "") + pathUrl;
367
+ let url = (baseUrl ?? "") + pathUrl;
368
368
  if (path) {
369
369
  url = defaultPathSerializer({ path, url });
370
370
  }
@@ -395,15 +395,15 @@ function getValidRequestBody(options) {
395
395
  __name(getValidRequestBody, "getValidRequestBody");
396
396
 
397
397
  // src/_api/generated/core/auth.gen.ts
398
- var getAuthToken = /* @__PURE__ */ __name(async (auth, callback) => {
399
- const token = typeof callback === "function" ? await callback(auth) : callback;
398
+ var getAuthToken = /* @__PURE__ */ __name(async (auth2, callback) => {
399
+ const token = typeof callback === "function" ? await callback(auth2) : callback;
400
400
  if (!token) {
401
401
  return;
402
402
  }
403
- if (auth.scheme === "bearer") {
403
+ if (auth2.scheme === "bearer") {
404
404
  return `Bearer ${token}`;
405
405
  }
406
- if (auth.scheme === "basic") {
406
+ if (auth2.scheme === "basic") {
407
407
  return `Basic ${btoa(token)}`;
408
408
  }
409
409
  return token;
@@ -492,16 +492,16 @@ var setAuthParams = /* @__PURE__ */ __name(async ({
492
492
  security,
493
493
  ...options
494
494
  }) => {
495
- for (const auth of security) {
496
- if (checkForExistence(options, auth.name)) {
495
+ for (const auth2 of security) {
496
+ if (checkForExistence(options, auth2.name)) {
497
497
  continue;
498
498
  }
499
- const token = await getAuthToken(auth, options.auth);
499
+ const token = await getAuthToken(auth2, options.auth);
500
500
  if (!token) {
501
501
  continue;
502
502
  }
503
- const name = auth.name ?? "Authorization";
504
- switch (auth.in) {
503
+ const name = auth2.name ?? "Authorization";
504
+ switch (auth2.in) {
505
505
  case "query":
506
506
  if (!options.query) {
507
507
  options.query = {};
@@ -829,41 +829,206 @@ var createClient = /* @__PURE__ */ __name((config = {}) => {
829
829
  // src/_api/generated/client.gen.ts
830
830
  var client = createClient(createConfig({ baseUrl: "http://localhost:8000" }));
831
831
 
832
- // src/_api/generated/helpers/storage.ts
833
- var LocalStorageAdapter = class {
834
- static {
835
- __name(this, "LocalStorageAdapter");
836
- }
837
- getItem(key) {
838
- if (typeof window === "undefined") return null;
832
+ // src/_api/generated/helpers/auth.ts
833
+ var ACCESS_KEY = "cfg.access_token";
834
+ var REFRESH_KEY = "cfg.refresh_token";
835
+ var API_KEY_KEY = "cfg.api_key";
836
+ var isBrowser = typeof window !== "undefined";
837
+ var localStorageBackend = {
838
+ get(key) {
839
+ if (!isBrowser) return null;
839
840
  try {
840
841
  return window.localStorage.getItem(key);
841
842
  } catch {
842
843
  return null;
843
844
  }
844
- }
845
- setItem(key, value) {
846
- if (typeof window === "undefined") return;
845
+ },
846
+ set(key, value) {
847
+ if (!isBrowser) return;
847
848
  try {
848
- window.localStorage.setItem(key, value);
849
+ if (value === null) window.localStorage.removeItem(key);
850
+ else window.localStorage.setItem(key, value);
849
851
  } catch {
850
852
  }
851
853
  }
852
- removeItem(key) {
853
- if (typeof window === "undefined") return;
854
+ };
855
+ var COOKIE_MAX_AGE = 60 * 60 * 24 * 30;
856
+ var cookieBackend = {
857
+ get(key) {
858
+ if (!isBrowser) return null;
854
859
  try {
855
- window.localStorage.removeItem(key);
860
+ const re = new RegExp(`(?:^|;\\s*)${encodeURIComponent(key)}=([^;]*)`);
861
+ const m = document.cookie.match(re);
862
+ return m ? decodeURIComponent(m[1]) : null;
856
863
  } catch {
864
+ return null;
857
865
  }
858
- }
859
- clear() {
860
- if (typeof window === "undefined") return;
866
+ },
867
+ set(key, value) {
868
+ if (!isBrowser) return;
861
869
  try {
862
- window.localStorage.clear();
870
+ const k = encodeURIComponent(key);
871
+ const secure = window.location.protocol === "https:" ? "; Secure" : "";
872
+ if (value === null) {
873
+ document.cookie = `${k}=; Path=/; Max-Age=0; SameSite=Lax${secure}`;
874
+ } else {
875
+ const v = encodeURIComponent(value);
876
+ document.cookie = `${k}=${v}; Path=/; Max-Age=${COOKIE_MAX_AGE}; SameSite=Lax${secure}`;
877
+ }
863
878
  } catch {
864
879
  }
865
880
  }
866
881
  };
882
+ var _storage = localStorageBackend;
883
+ var _storageMode = "localStorage";
884
+ function detectLocale() {
885
+ try {
886
+ if (typeof document !== "undefined") {
887
+ const m = document.cookie.match(/(?:^|;\s*)NEXT_LOCALE=([^;]*)/);
888
+ if (m) return decodeURIComponent(m[1]);
889
+ }
890
+ if (typeof navigator !== "undefined" && navigator.language) {
891
+ return navigator.language;
892
+ }
893
+ } catch {
894
+ }
895
+ return null;
896
+ }
897
+ __name(detectLocale, "detectLocale");
898
+ function defaultBaseUrl() {
899
+ try {
900
+ if (typeof process !== "undefined" && process.env) {
901
+ if (process.env.NEXT_PUBLIC_STATIC_BUILD === "true") return "";
902
+ return process.env.NEXT_PUBLIC_API_URL || "";
903
+ }
904
+ } catch {
905
+ }
906
+ return "";
907
+ }
908
+ __name(defaultBaseUrl, "defaultBaseUrl");
909
+ function defaultApiKey() {
910
+ try {
911
+ if (typeof process !== "undefined" && process.env?.NEXT_PUBLIC_API_KEY) {
912
+ return process.env.NEXT_PUBLIC_API_KEY;
913
+ }
914
+ } catch {
915
+ }
916
+ return null;
917
+ }
918
+ __name(defaultApiKey, "defaultApiKey");
919
+ var _localeOverride = null;
920
+ var _apiKeyOverride = null;
921
+ var _baseUrlOverride = null;
922
+ var _withCredentials = true;
923
+ var _onUnauthorized = null;
924
+ var auth = {
925
+ // ── Storage mode ──────────────────────────────────────────────────
926
+ getStorageMode() {
927
+ return _storageMode;
928
+ },
929
+ /**
930
+ * Switch the storage backend. Existing values in the *previous*
931
+ * backend are NOT migrated — set fresh values after switching.
932
+ */
933
+ setStorageMode(mode) {
934
+ _storageMode = mode;
935
+ _storage = mode === "cookie" ? cookieBackend : localStorageBackend;
936
+ },
937
+ // ── Bearer token ──────────────────────────────────────────────────
938
+ getToken() {
939
+ return _storage.get(ACCESS_KEY);
940
+ },
941
+ setToken(token) {
942
+ _storage.set(ACCESS_KEY, token);
943
+ },
944
+ getRefreshToken() {
945
+ return _storage.get(REFRESH_KEY);
946
+ },
947
+ setRefreshToken(token) {
948
+ _storage.set(REFRESH_KEY, token);
949
+ },
950
+ clearTokens() {
951
+ _storage.set(ACCESS_KEY, null);
952
+ _storage.set(REFRESH_KEY, null);
953
+ },
954
+ isAuthenticated() {
955
+ return _storage.get(ACCESS_KEY) !== null;
956
+ },
957
+ // ── API key ───────────────────────────────────────────────────────
958
+ /** In-memory API key. Falls back to storage, then NEXT_PUBLIC_API_KEY. */
959
+ getApiKey() {
960
+ return _apiKeyOverride ?? _storage.get(API_KEY_KEY) ?? defaultApiKey();
961
+ },
962
+ /** In-memory only (cleared on reload). */
963
+ setApiKey(key) {
964
+ _apiKeyOverride = key;
965
+ },
966
+ /** Persist to active storage backend (localStorage or cookie). */
967
+ setApiKeyPersist(key) {
968
+ _apiKeyOverride = key;
969
+ _storage.set(API_KEY_KEY, key);
970
+ },
971
+ clearApiKey() {
972
+ _apiKeyOverride = null;
973
+ _storage.set(API_KEY_KEY, null);
974
+ },
975
+ // ── Locale ────────────────────────────────────────────────────────
976
+ /** Override locale → falls back to NEXT_LOCALE cookie / navigator.language. */
977
+ getLocale() {
978
+ return _localeOverride ?? detectLocale();
979
+ },
980
+ setLocale(locale) {
981
+ _localeOverride = locale;
982
+ },
983
+ // ── Base URL ──────────────────────────────────────────────────────
984
+ getBaseUrl() {
985
+ const url = _baseUrlOverride ?? defaultBaseUrl();
986
+ return url.replace(/\/$/, "");
987
+ },
988
+ setBaseUrl(url) {
989
+ _baseUrlOverride = url ? url.replace(/\/$/, "") : null;
990
+ client.setConfig({ baseUrl: this.getBaseUrl() });
991
+ },
992
+ // ── Credentials toggle (Django session/CSRF cross-origin) ─────────
993
+ getWithCredentials() {
994
+ return _withCredentials;
995
+ },
996
+ setWithCredentials(value) {
997
+ _withCredentials = value;
998
+ client.setConfig({ credentials: value ? "include" : "same-origin" });
999
+ },
1000
+ // ── 401 handler ───────────────────────────────────────────────────
1001
+ /**
1002
+ * Register a callback fired on every 401 response. Use this to wire
1003
+ * a token-refresh flow or a forced logout. Setting `null` removes
1004
+ * the handler.
1005
+ */
1006
+ onUnauthorized(cb) {
1007
+ _onUnauthorized = cb;
1008
+ }
1009
+ };
1010
+ client.setConfig({
1011
+ baseUrl: auth.getBaseUrl(),
1012
+ credentials: _withCredentials ? "include" : "same-origin"
1013
+ });
1014
+ client.interceptors.request.use((request) => {
1015
+ const token = auth.getToken();
1016
+ if (token) request.headers.set("Authorization", `Bearer ${token}`);
1017
+ const locale = auth.getLocale();
1018
+ if (locale) request.headers.set("Accept-Language", locale);
1019
+ const apiKey = auth.getApiKey();
1020
+ if (apiKey) request.headers.set("X-API-Key", apiKey);
1021
+ return request;
1022
+ });
1023
+ client.interceptors.response.use((response) => {
1024
+ if (response.status === 401 && _onUnauthorized) {
1025
+ try {
1026
+ _onUnauthorized(response);
1027
+ } catch {
1028
+ }
1029
+ }
1030
+ return response;
1031
+ });
867
1032
 
868
1033
  // src/_api/generated/helpers/logger.ts
869
1034
  var import_consola = require("consola");
@@ -960,273 +1125,169 @@ var APILogger = class {
960
1125
  var defaultLogger = new APILogger();
961
1126
 
962
1127
  // src/_api/generated/_cfg_accounts/api.ts
963
- var ACCESS_KEY = "cfg.access_token";
964
- var REFRESH_KEY = "cfg.refresh_token";
965
- function detectLocale() {
966
- try {
967
- if (typeof document !== "undefined") {
968
- const m = document.cookie.match(/(?:^|;\s*)NEXT_LOCALE=([^;]*)/);
969
- if (m) return decodeURIComponent(m[1]);
970
- }
971
- if (typeof navigator !== "undefined" && navigator.language) {
972
- return navigator.language;
973
- }
974
- } catch {
975
- }
976
- return null;
977
- }
978
- __name(detectLocale, "detectLocale");
979
1128
  var API = class {
980
1129
  static {
981
1130
  __name(this, "API");
982
1131
  }
983
- baseUrl;
984
- storage;
985
- locale;
986
- apiKey;
987
1132
  logger;
988
- constructor(baseUrl2, opts = {}) {
989
- this.baseUrl = baseUrl2.replace(/\/$/, "");
990
- this.storage = opts.storage ?? new LocalStorageAdapter();
1133
+ constructor(_baseUrl, opts = {}) {
991
1134
  this.logger = new APILogger(opts.logger);
992
- this.locale = opts.locale ?? null;
993
- this.apiKey = opts.apiKey ?? (typeof process !== "undefined" ? process.env?.NEXT_PUBLIC_API_KEY ?? null : null);
994
- const credentials = opts.withCredentials ?? true ? "include" : "same-origin";
995
- client.setConfig({ baseUrl: this.baseUrl, credentials });
996
- client.interceptors.request.use((request) => {
997
- const access = this.getToken();
998
- if (access) request.headers.set("Authorization", `Bearer ${access}`);
999
- const locale = this.locale ?? detectLocale();
1000
- if (locale) request.headers.set("Accept-Language", locale);
1001
- if (this.apiKey) request.headers.set("X-API-Key", this.apiKey);
1002
- return request;
1003
- });
1135
+ if (_baseUrl) auth.setBaseUrl(_baseUrl);
1136
+ if (opts.locale !== void 0) auth.setLocale(opts.locale);
1137
+ if (opts.apiKey !== void 0) auth.setApiKey(opts.apiKey);
1138
+ if (opts.withCredentials !== void 0) auth.setWithCredentials(opts.withCredentials);
1004
1139
  }
1005
1140
  // ── Base URL ────────────────────────────────────────────────────────────
1006
1141
  getBaseUrl() {
1007
- return this.baseUrl;
1142
+ return auth.getBaseUrl();
1008
1143
  }
1009
1144
  setBaseUrl(url) {
1010
- this.baseUrl = url.replace(/\/$/, "");
1011
- client.setConfig({ baseUrl: this.baseUrl });
1145
+ auth.setBaseUrl(url);
1012
1146
  }
1013
1147
  // ── Tokens ──────────────────────────────────────────────────────────────
1014
1148
  getToken() {
1015
- return this.storage.getItem(ACCESS_KEY);
1149
+ return auth.getToken();
1016
1150
  }
1017
1151
  setToken(token) {
1018
- if (token) this.storage.setItem(ACCESS_KEY, token);
1019
- else this.storage.removeItem(ACCESS_KEY);
1152
+ auth.setToken(token);
1020
1153
  }
1021
1154
  getRefreshToken() {
1022
- return this.storage.getItem(REFRESH_KEY);
1155
+ return auth.getRefreshToken();
1023
1156
  }
1024
1157
  setRefreshToken(token) {
1025
- if (token) this.storage.setItem(REFRESH_KEY, token);
1026
- else this.storage.removeItem(REFRESH_KEY);
1158
+ auth.setRefreshToken(token);
1027
1159
  }
1028
1160
  clearToken() {
1029
- this.storage.removeItem(ACCESS_KEY);
1030
- this.storage.removeItem(REFRESH_KEY);
1161
+ auth.clearTokens();
1031
1162
  }
1032
1163
  isAuthenticated() {
1033
- return this.getToken() !== null;
1164
+ return auth.isAuthenticated();
1034
1165
  }
1035
1166
  // ── Locale / API key ────────────────────────────────────────────────────
1036
1167
  getLocale() {
1037
- return this.locale ?? detectLocale();
1168
+ return auth.getLocale();
1038
1169
  }
1039
1170
  setLocale(locale) {
1040
- this.locale = locale;
1171
+ auth.setLocale(locale);
1041
1172
  }
1042
1173
  getApiKey() {
1043
- return this.apiKey;
1174
+ return auth.getApiKey();
1044
1175
  }
1045
1176
  setApiKey(key) {
1046
- this.apiKey = key;
1177
+ auth.setApiKey(key);
1047
1178
  }
1048
1179
  };
1049
1180
 
1050
1181
  // src/_api/generated/_cfg_centrifugo/api.ts
1051
- var ACCESS_KEY2 = "cfg.access_token";
1052
- var REFRESH_KEY2 = "cfg.refresh_token";
1053
- function detectLocale2() {
1054
- try {
1055
- if (typeof document !== "undefined") {
1056
- const m = document.cookie.match(/(?:^|;\s*)NEXT_LOCALE=([^;]*)/);
1057
- if (m) return decodeURIComponent(m[1]);
1058
- }
1059
- if (typeof navigator !== "undefined" && navigator.language) {
1060
- return navigator.language;
1061
- }
1062
- } catch {
1063
- }
1064
- return null;
1065
- }
1066
- __name(detectLocale2, "detectLocale");
1067
1182
  var API2 = class {
1068
1183
  static {
1069
1184
  __name(this, "API");
1070
1185
  }
1071
- baseUrl;
1072
- storage;
1073
- locale;
1074
- apiKey;
1075
1186
  logger;
1076
- constructor(baseUrl2, opts = {}) {
1077
- this.baseUrl = baseUrl2.replace(/\/$/, "");
1078
- this.storage = opts.storage ?? new LocalStorageAdapter();
1187
+ constructor(_baseUrl, opts = {}) {
1079
1188
  this.logger = new APILogger(opts.logger);
1080
- this.locale = opts.locale ?? null;
1081
- this.apiKey = opts.apiKey ?? (typeof process !== "undefined" ? process.env?.NEXT_PUBLIC_API_KEY ?? null : null);
1082
- const credentials = opts.withCredentials ?? true ? "include" : "same-origin";
1083
- client.setConfig({ baseUrl: this.baseUrl, credentials });
1084
- client.interceptors.request.use((request) => {
1085
- const access = this.getToken();
1086
- if (access) request.headers.set("Authorization", `Bearer ${access}`);
1087
- const locale = this.locale ?? detectLocale2();
1088
- if (locale) request.headers.set("Accept-Language", locale);
1089
- if (this.apiKey) request.headers.set("X-API-Key", this.apiKey);
1090
- return request;
1091
- });
1189
+ if (_baseUrl) auth.setBaseUrl(_baseUrl);
1190
+ if (opts.locale !== void 0) auth.setLocale(opts.locale);
1191
+ if (opts.apiKey !== void 0) auth.setApiKey(opts.apiKey);
1192
+ if (opts.withCredentials !== void 0) auth.setWithCredentials(opts.withCredentials);
1092
1193
  }
1093
1194
  // ── Base URL ────────────────────────────────────────────────────────────
1094
1195
  getBaseUrl() {
1095
- return this.baseUrl;
1196
+ return auth.getBaseUrl();
1096
1197
  }
1097
1198
  setBaseUrl(url) {
1098
- this.baseUrl = url.replace(/\/$/, "");
1099
- client.setConfig({ baseUrl: this.baseUrl });
1199
+ auth.setBaseUrl(url);
1100
1200
  }
1101
1201
  // ── Tokens ──────────────────────────────────────────────────────────────
1102
1202
  getToken() {
1103
- return this.storage.getItem(ACCESS_KEY2);
1203
+ return auth.getToken();
1104
1204
  }
1105
1205
  setToken(token) {
1106
- if (token) this.storage.setItem(ACCESS_KEY2, token);
1107
- else this.storage.removeItem(ACCESS_KEY2);
1206
+ auth.setToken(token);
1108
1207
  }
1109
1208
  getRefreshToken() {
1110
- return this.storage.getItem(REFRESH_KEY2);
1209
+ return auth.getRefreshToken();
1111
1210
  }
1112
1211
  setRefreshToken(token) {
1113
- if (token) this.storage.setItem(REFRESH_KEY2, token);
1114
- else this.storage.removeItem(REFRESH_KEY2);
1212
+ auth.setRefreshToken(token);
1115
1213
  }
1116
1214
  clearToken() {
1117
- this.storage.removeItem(ACCESS_KEY2);
1118
- this.storage.removeItem(REFRESH_KEY2);
1215
+ auth.clearTokens();
1119
1216
  }
1120
1217
  isAuthenticated() {
1121
- return this.getToken() !== null;
1218
+ return auth.isAuthenticated();
1122
1219
  }
1123
1220
  // ── Locale / API key ────────────────────────────────────────────────────
1124
1221
  getLocale() {
1125
- return this.locale ?? detectLocale2();
1222
+ return auth.getLocale();
1126
1223
  }
1127
1224
  setLocale(locale) {
1128
- this.locale = locale;
1225
+ auth.setLocale(locale);
1129
1226
  }
1130
1227
  getApiKey() {
1131
- return this.apiKey;
1228
+ return auth.getApiKey();
1132
1229
  }
1133
1230
  setApiKey(key) {
1134
- this.apiKey = key;
1231
+ auth.setApiKey(key);
1135
1232
  }
1136
1233
  };
1137
1234
 
1138
1235
  // src/_api/generated/_cfg_totp/api.ts
1139
- var ACCESS_KEY3 = "cfg.access_token";
1140
- var REFRESH_KEY3 = "cfg.refresh_token";
1141
- function detectLocale3() {
1142
- try {
1143
- if (typeof document !== "undefined") {
1144
- const m = document.cookie.match(/(?:^|;\s*)NEXT_LOCALE=([^;]*)/);
1145
- if (m) return decodeURIComponent(m[1]);
1146
- }
1147
- if (typeof navigator !== "undefined" && navigator.language) {
1148
- return navigator.language;
1149
- }
1150
- } catch {
1151
- }
1152
- return null;
1153
- }
1154
- __name(detectLocale3, "detectLocale");
1155
1236
  var API3 = class {
1156
1237
  static {
1157
1238
  __name(this, "API");
1158
1239
  }
1159
- baseUrl;
1160
- storage;
1161
- locale;
1162
- apiKey;
1163
1240
  logger;
1164
- constructor(baseUrl2, opts = {}) {
1165
- this.baseUrl = baseUrl2.replace(/\/$/, "");
1166
- this.storage = opts.storage ?? new LocalStorageAdapter();
1241
+ constructor(_baseUrl, opts = {}) {
1167
1242
  this.logger = new APILogger(opts.logger);
1168
- this.locale = opts.locale ?? null;
1169
- this.apiKey = opts.apiKey ?? (typeof process !== "undefined" ? process.env?.NEXT_PUBLIC_API_KEY ?? null : null);
1170
- const credentials = opts.withCredentials ?? true ? "include" : "same-origin";
1171
- client.setConfig({ baseUrl: this.baseUrl, credentials });
1172
- client.interceptors.request.use((request) => {
1173
- const access = this.getToken();
1174
- if (access) request.headers.set("Authorization", `Bearer ${access}`);
1175
- const locale = this.locale ?? detectLocale3();
1176
- if (locale) request.headers.set("Accept-Language", locale);
1177
- if (this.apiKey) request.headers.set("X-API-Key", this.apiKey);
1178
- return request;
1179
- });
1243
+ if (_baseUrl) auth.setBaseUrl(_baseUrl);
1244
+ if (opts.locale !== void 0) auth.setLocale(opts.locale);
1245
+ if (opts.apiKey !== void 0) auth.setApiKey(opts.apiKey);
1246
+ if (opts.withCredentials !== void 0) auth.setWithCredentials(opts.withCredentials);
1180
1247
  }
1181
1248
  // ── Base URL ────────────────────────────────────────────────────────────
1182
1249
  getBaseUrl() {
1183
- return this.baseUrl;
1250
+ return auth.getBaseUrl();
1184
1251
  }
1185
1252
  setBaseUrl(url) {
1186
- this.baseUrl = url.replace(/\/$/, "");
1187
- client.setConfig({ baseUrl: this.baseUrl });
1253
+ auth.setBaseUrl(url);
1188
1254
  }
1189
1255
  // ── Tokens ──────────────────────────────────────────────────────────────
1190
1256
  getToken() {
1191
- return this.storage.getItem(ACCESS_KEY3);
1257
+ return auth.getToken();
1192
1258
  }
1193
1259
  setToken(token) {
1194
- if (token) this.storage.setItem(ACCESS_KEY3, token);
1195
- else this.storage.removeItem(ACCESS_KEY3);
1260
+ auth.setToken(token);
1196
1261
  }
1197
1262
  getRefreshToken() {
1198
- return this.storage.getItem(REFRESH_KEY3);
1263
+ return auth.getRefreshToken();
1199
1264
  }
1200
1265
  setRefreshToken(token) {
1201
- if (token) this.storage.setItem(REFRESH_KEY3, token);
1202
- else this.storage.removeItem(REFRESH_KEY3);
1266
+ auth.setRefreshToken(token);
1203
1267
  }
1204
1268
  clearToken() {
1205
- this.storage.removeItem(ACCESS_KEY3);
1206
- this.storage.removeItem(REFRESH_KEY3);
1269
+ auth.clearTokens();
1207
1270
  }
1208
1271
  isAuthenticated() {
1209
- return this.getToken() !== null;
1272
+ return auth.isAuthenticated();
1210
1273
  }
1211
1274
  // ── Locale / API key ────────────────────────────────────────────────────
1212
1275
  getLocale() {
1213
- return this.locale ?? detectLocale3();
1276
+ return auth.getLocale();
1214
1277
  }
1215
1278
  setLocale(locale) {
1216
- this.locale = locale;
1279
+ auth.setLocale(locale);
1217
1280
  }
1218
1281
  getApiKey() {
1219
- return this.apiKey;
1282
+ return auth.getApiKey();
1220
1283
  }
1221
1284
  setApiKey(key) {
1222
- this.apiKey = key;
1285
+ auth.setApiKey(key);
1223
1286
  }
1224
1287
  };
1225
1288
 
1226
1289
  // src/_api/generated/index.ts
1227
- var isStaticBuild = process.env.NEXT_PUBLIC_STATIC_BUILD === "true";
1228
- var baseUrl = isStaticBuild ? "" : process.env.NEXT_PUBLIC_API_URL || "";
1229
- var CfgAccountsApi = new API(baseUrl, { storage: new LocalStorageAdapter() });
1230
- var CfgCentrifugoApi = new API2(baseUrl, { storage: new LocalStorageAdapter() });
1231
- var CfgTotpApi = new API3(baseUrl, { storage: new LocalStorageAdapter() });
1290
+ var CfgAccountsApi = new API();
1291
+ var CfgCentrifugoApi = new API2();
1292
+ var CfgTotpApi = new API3();
1232
1293
  //# sourceMappingURL=clients.cjs.map