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