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