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