@djangocfg/api 2.1.420 → 2.1.422

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.
Files changed (45) hide show
  1. package/dist/auth-server.cjs +45 -27
  2. package/dist/auth-server.cjs.map +1 -1
  3. package/dist/auth-server.mjs +45 -27
  4. package/dist/auth-server.mjs.map +1 -1
  5. package/dist/auth.cjs +61 -33
  6. package/dist/auth.cjs.map +1 -1
  7. package/dist/auth.d.cts +2 -1
  8. package/dist/auth.d.ts +2 -1
  9. package/dist/auth.mjs +61 -33
  10. package/dist/auth.mjs.map +1 -1
  11. package/dist/clients.cjs +45 -27
  12. package/dist/clients.cjs.map +1 -1
  13. package/dist/clients.d.cts +1 -1
  14. package/dist/clients.d.ts +1 -1
  15. package/dist/clients.mjs +45 -27
  16. package/dist/clients.mjs.map +1 -1
  17. package/dist/hooks.cjs +48 -29
  18. package/dist/hooks.cjs.map +1 -1
  19. package/dist/hooks.mjs +48 -29
  20. package/dist/hooks.mjs.map +1 -1
  21. package/dist/index.cjs +45 -27
  22. package/dist/index.cjs.map +1 -1
  23. package/dist/index.d.cts +2 -2
  24. package/dist/index.d.ts +2 -2
  25. package/dist/index.mjs +45 -27
  26. package/dist/index.mjs.map +1 -1
  27. package/package.json +2 -2
  28. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsApiKeyRetrieve.ts +12 -3
  29. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthConnectionsList.ts +12 -3
  30. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthProvidersRetrieve.ts +12 -3
  31. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileRetrieve.ts +12 -3
  32. package/src/_api/generated/_cfg_accounts/openapi.json +9 -0
  33. package/src/_api/generated/_cfg_centrifugo/hooks/useCfgCentrifugoAuthTokenRetrieve.ts +12 -3
  34. package/src/_api/generated/_cfg_totp/hooks/useCfgTotpBackupCodesRetrieve.ts +12 -3
  35. package/src/_api/generated/_cfg_totp/hooks/useCfgTotpDevicesRetrieve.ts +12 -3
  36. package/src/_api/generated/client/client.gen.ts +1 -4
  37. package/src/_api/generated/client/types.gen.ts +3 -2
  38. package/src/_api/generated/client/utils.gen.ts +6 -8
  39. package/src/_api/generated/core/params.gen.ts +4 -4
  40. package/src/_api/generated/helpers/auth.ts +58 -9
  41. package/src/_api/generated/index.ts +6 -0
  42. package/src/_api/generated/openapi.json +9 -0
  43. package/src/_api/generated/sdk.gen.ts +18 -6
  44. package/src/auth/hooks/useAuthForm.ts +5 -4
  45. package/src/auth/hooks/useAutoAuth.ts +23 -4
@@ -148,6 +148,18 @@ function detectLocale() {
148
148
  }
149
149
  __name(detectLocale, "detectLocale");
150
150
  function defaultBaseUrl() {
151
+ if (typeof window !== "undefined") {
152
+ try {
153
+ if (typeof process !== "undefined" && process.env) {
154
+ if (process.env.NEXT_PUBLIC_STATIC_BUILD === "true") return "";
155
+ if (process.env.NEXT_PUBLIC_API_PROXY_URL !== void 0)
156
+ return process.env.NEXT_PUBLIC_API_PROXY_URL;
157
+ return process.env.NEXT_PUBLIC_API_URL || "";
158
+ }
159
+ } catch {
160
+ }
161
+ return "";
162
+ }
151
163
  try {
152
164
  if (typeof process !== "undefined" && process.env) {
153
165
  if (process.env.NEXT_PUBLIC_STATIC_BUILD === "true") return "";
@@ -159,7 +171,6 @@ function defaultBaseUrl() {
159
171
  }
160
172
  __name(defaultBaseUrl, "defaultBaseUrl");
161
173
  function defaultApiKey() {
162
- if (isBrowser) return null;
163
174
  try {
164
175
  if (typeof process !== "undefined" && process.env?.NEXT_PUBLIC_API_KEY) {
165
176
  return process.env.NEXT_PUBLIC_API_KEY;
@@ -315,7 +326,7 @@ function installAuthOnClient(client2) {
315
326
  const locale = auth.getLocale();
316
327
  if (locale) request.headers.set("Accept-Language", locale);
317
328
  const apiKey = auth.getApiKey();
318
- if (apiKey) request.headers.set("X-API-Key", apiKey);
329
+ if (apiKey && !request.headers.has("X-API-Key")) request.headers.set("X-API-Key", apiKey);
319
330
  try {
320
331
  const tz = Intl.DateTimeFormat().resolvedOptions().timeZone;
321
332
  if (tz) request.headers.set("X-Timezone", tz);
@@ -954,11 +965,8 @@ var checkForExistence = /* @__PURE__ */ __name((options, name) => {
954
965
  }
955
966
  return false;
956
967
  }, "checkForExistence");
957
- var setAuthParams = /* @__PURE__ */ __name(async ({
958
- security,
959
- ...options
960
- }) => {
961
- for (const auth2 of security) {
968
+ async function setAuthParams(options) {
969
+ for (const auth2 of options.security ?? []) {
962
970
  if (checkForExistence(options, auth2.name)) {
963
971
  continue;
964
972
  }
@@ -983,7 +991,8 @@ var setAuthParams = /* @__PURE__ */ __name(async ({
983
991
  break;
984
992
  }
985
993
  }
986
- }, "setAuthParams");
994
+ }
995
+ __name(setAuthParams, "setAuthParams");
987
996
  var buildUrl = /* @__PURE__ */ __name((options) => getUrl({
988
997
  baseUrl: options.baseUrl,
989
998
  path: options.path,
@@ -1112,10 +1121,7 @@ var createClient = /* @__PURE__ */ __name((config = {}) => {
1112
1121
  serializedBody: void 0
1113
1122
  };
1114
1123
  if (opts.security) {
1115
- await setAuthParams({
1116
- ...opts,
1117
- security: opts.security
1118
- });
1124
+ await setAuthParams(opts);
1119
1125
  }
1120
1126
  if (opts.requestValidator) {
1121
1127
  await opts.requestValidator(opts);
@@ -1308,11 +1314,15 @@ var CfgAccountsApiKey = class {
1308
1314
  */
1309
1315
  static cfgAccountsApiKeyRetrieve(options) {
1310
1316
  return (options?.client ?? client).get({
1311
- security: [{ scheme: "bearer", type: "http" }, {
1312
- in: "cookie",
1313
- name: "sessionid",
1314
- type: "apiKey"
1315
- }],
1317
+ security: [
1318
+ { scheme: "bearer", type: "http" },
1319
+ {
1320
+ in: "cookie",
1321
+ name: "sessionid",
1322
+ type: "apiKey"
1323
+ },
1324
+ { name: "X-API-Key", type: "apiKey" }
1325
+ ],
1316
1326
  url: "/cfg/accounts/api-key/",
1317
1327
  ...options
1318
1328
  });
@@ -1324,11 +1334,15 @@ var CfgAccountsApiKey = class {
1324
1334
  */
1325
1335
  static cfgAccountsApiKeyRegenerateCreate(options) {
1326
1336
  return (options.client ?? client).post({
1327
- security: [{ scheme: "bearer", type: "http" }, {
1328
- in: "cookie",
1329
- name: "sessionid",
1330
- type: "apiKey"
1331
- }],
1337
+ security: [
1338
+ { scheme: "bearer", type: "http" },
1339
+ {
1340
+ in: "cookie",
1341
+ name: "sessionid",
1342
+ type: "apiKey"
1343
+ },
1344
+ { name: "X-API-Key", type: "apiKey" }
1345
+ ],
1332
1346
  url: "/cfg/accounts/api-key/regenerate/",
1333
1347
  ...options,
1334
1348
  headers: {
@@ -1344,11 +1358,15 @@ var CfgAccountsApiKey = class {
1344
1358
  */
1345
1359
  static cfgAccountsApiKeyTestCreate(options) {
1346
1360
  return (options.client ?? client).post({
1347
- security: [{ scheme: "bearer", type: "http" }, {
1348
- in: "cookie",
1349
- name: "sessionid",
1350
- type: "apiKey"
1351
- }],
1361
+ security: [
1362
+ { scheme: "bearer", type: "http" },
1363
+ {
1364
+ in: "cookie",
1365
+ name: "sessionid",
1366
+ type: "apiKey"
1367
+ },
1368
+ { name: "X-API-Key", type: "apiKey" }
1369
+ ],
1352
1370
  url: "/cfg/accounts/api-key/test/",
1353
1371
  ...options,
1354
1372
  headers: {