@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
@@ -177,6 +177,18 @@ function detectLocale() {
177
177
  }
178
178
  __name(detectLocale, "detectLocale");
179
179
  function defaultBaseUrl() {
180
+ if (typeof window !== "undefined") {
181
+ try {
182
+ if (typeof process !== "undefined" && process.env) {
183
+ if (process.env.NEXT_PUBLIC_STATIC_BUILD === "true") return "";
184
+ if (process.env.NEXT_PUBLIC_API_PROXY_URL !== void 0)
185
+ return process.env.NEXT_PUBLIC_API_PROXY_URL;
186
+ return process.env.NEXT_PUBLIC_API_URL || "";
187
+ }
188
+ } catch {
189
+ }
190
+ return "";
191
+ }
180
192
  try {
181
193
  if (typeof process !== "undefined" && process.env) {
182
194
  if (process.env.NEXT_PUBLIC_STATIC_BUILD === "true") return "";
@@ -188,7 +200,6 @@ function defaultBaseUrl() {
188
200
  }
189
201
  __name(defaultBaseUrl, "defaultBaseUrl");
190
202
  function defaultApiKey() {
191
- if (isBrowser) return null;
192
203
  try {
193
204
  if (typeof process !== "undefined" && process.env?.NEXT_PUBLIC_API_KEY) {
194
205
  return process.env.NEXT_PUBLIC_API_KEY;
@@ -344,7 +355,7 @@ function installAuthOnClient(client2) {
344
355
  const locale = auth.getLocale();
345
356
  if (locale) request.headers.set("Accept-Language", locale);
346
357
  const apiKey = auth.getApiKey();
347
- if (apiKey) request.headers.set("X-API-Key", apiKey);
358
+ if (apiKey && !request.headers.has("X-API-Key")) request.headers.set("X-API-Key", apiKey);
348
359
  try {
349
360
  const tz = Intl.DateTimeFormat().resolvedOptions().timeZone;
350
361
  if (tz) request.headers.set("X-Timezone", tz);
@@ -983,11 +994,8 @@ var checkForExistence = /* @__PURE__ */ __name((options, name) => {
983
994
  }
984
995
  return false;
985
996
  }, "checkForExistence");
986
- var setAuthParams = /* @__PURE__ */ __name(async ({
987
- security,
988
- ...options
989
- }) => {
990
- for (const auth2 of security) {
997
+ async function setAuthParams(options) {
998
+ for (const auth2 of options.security ?? []) {
991
999
  if (checkForExistence(options, auth2.name)) {
992
1000
  continue;
993
1001
  }
@@ -1012,7 +1020,8 @@ var setAuthParams = /* @__PURE__ */ __name(async ({
1012
1020
  break;
1013
1021
  }
1014
1022
  }
1015
- }, "setAuthParams");
1023
+ }
1024
+ __name(setAuthParams, "setAuthParams");
1016
1025
  var buildUrl = /* @__PURE__ */ __name((options) => getUrl({
1017
1026
  baseUrl: options.baseUrl,
1018
1027
  path: options.path,
@@ -1141,10 +1150,7 @@ var createClient = /* @__PURE__ */ __name((config = {}) => {
1141
1150
  serializedBody: void 0
1142
1151
  };
1143
1152
  if (opts.security) {
1144
- await setAuthParams({
1145
- ...opts,
1146
- security: opts.security
1147
- });
1153
+ await setAuthParams(opts);
1148
1154
  }
1149
1155
  if (opts.requestValidator) {
1150
1156
  await opts.requestValidator(opts);
@@ -1337,11 +1343,15 @@ var CfgAccountsApiKey = class {
1337
1343
  */
1338
1344
  static cfgAccountsApiKeyRetrieve(options) {
1339
1345
  return (options?.client ?? client).get({
1340
- security: [{ scheme: "bearer", type: "http" }, {
1341
- in: "cookie",
1342
- name: "sessionid",
1343
- type: "apiKey"
1344
- }],
1346
+ security: [
1347
+ { scheme: "bearer", type: "http" },
1348
+ {
1349
+ in: "cookie",
1350
+ name: "sessionid",
1351
+ type: "apiKey"
1352
+ },
1353
+ { name: "X-API-Key", type: "apiKey" }
1354
+ ],
1345
1355
  url: "/cfg/accounts/api-key/",
1346
1356
  ...options
1347
1357
  });
@@ -1353,11 +1363,15 @@ var CfgAccountsApiKey = class {
1353
1363
  */
1354
1364
  static cfgAccountsApiKeyRegenerateCreate(options) {
1355
1365
  return (options.client ?? client).post({
1356
- security: [{ scheme: "bearer", type: "http" }, {
1357
- in: "cookie",
1358
- name: "sessionid",
1359
- type: "apiKey"
1360
- }],
1366
+ security: [
1367
+ { scheme: "bearer", type: "http" },
1368
+ {
1369
+ in: "cookie",
1370
+ name: "sessionid",
1371
+ type: "apiKey"
1372
+ },
1373
+ { name: "X-API-Key", type: "apiKey" }
1374
+ ],
1361
1375
  url: "/cfg/accounts/api-key/regenerate/",
1362
1376
  ...options,
1363
1377
  headers: {
@@ -1373,11 +1387,15 @@ var CfgAccountsApiKey = class {
1373
1387
  */
1374
1388
  static cfgAccountsApiKeyTestCreate(options) {
1375
1389
  return (options.client ?? client).post({
1376
- security: [{ scheme: "bearer", type: "http" }, {
1377
- in: "cookie",
1378
- name: "sessionid",
1379
- type: "apiKey"
1380
- }],
1390
+ security: [
1391
+ { scheme: "bearer", type: "http" },
1392
+ {
1393
+ in: "cookie",
1394
+ name: "sessionid",
1395
+ type: "apiKey"
1396
+ },
1397
+ { name: "X-API-Key", type: "apiKey" }
1398
+ ],
1381
1399
  url: "/cfg/accounts/api-key/test/",
1382
1400
  ...options,
1383
1401
  headers: {