@djangocfg/api 2.1.421 → 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
package/dist/index.cjs CHANGED
@@ -189,6 +189,18 @@ function detectLocale() {
189
189
  }
190
190
  __name(detectLocale, "detectLocale");
191
191
  function defaultBaseUrl() {
192
+ if (typeof window !== "undefined") {
193
+ try {
194
+ if (typeof process !== "undefined" && process.env) {
195
+ if (process.env.NEXT_PUBLIC_STATIC_BUILD === "true") return "";
196
+ if (process.env.NEXT_PUBLIC_API_PROXY_URL !== void 0)
197
+ return process.env.NEXT_PUBLIC_API_PROXY_URL;
198
+ return process.env.NEXT_PUBLIC_API_URL || "";
199
+ }
200
+ } catch {
201
+ }
202
+ return "";
203
+ }
192
204
  try {
193
205
  if (typeof process !== "undefined" && process.env) {
194
206
  if (process.env.NEXT_PUBLIC_STATIC_BUILD === "true") return "";
@@ -200,7 +212,6 @@ function defaultBaseUrl() {
200
212
  }
201
213
  __name(defaultBaseUrl, "defaultBaseUrl");
202
214
  function defaultApiKey() {
203
- if (isBrowser) return null;
204
215
  try {
205
216
  if (typeof process !== "undefined" && process.env?.NEXT_PUBLIC_API_KEY) {
206
217
  return process.env.NEXT_PUBLIC_API_KEY;
@@ -356,7 +367,7 @@ function installAuthOnClient(client2) {
356
367
  const locale = auth.getLocale();
357
368
  if (locale) request.headers.set("Accept-Language", locale);
358
369
  const apiKey = auth.getApiKey();
359
- if (apiKey) request.headers.set("X-API-Key", apiKey);
370
+ if (apiKey && !request.headers.has("X-API-Key")) request.headers.set("X-API-Key", apiKey);
360
371
  try {
361
372
  const tz = Intl.DateTimeFormat().resolvedOptions().timeZone;
362
373
  if (tz) request.headers.set("X-Timezone", tz);
@@ -995,11 +1006,8 @@ var checkForExistence = /* @__PURE__ */ __name((options, name) => {
995
1006
  }
996
1007
  return false;
997
1008
  }, "checkForExistence");
998
- var setAuthParams = /* @__PURE__ */ __name(async ({
999
- security,
1000
- ...options
1001
- }) => {
1002
- for (const auth2 of security) {
1009
+ async function setAuthParams(options) {
1010
+ for (const auth2 of options.security ?? []) {
1003
1011
  if (checkForExistence(options, auth2.name)) {
1004
1012
  continue;
1005
1013
  }
@@ -1024,7 +1032,8 @@ var setAuthParams = /* @__PURE__ */ __name(async ({
1024
1032
  break;
1025
1033
  }
1026
1034
  }
1027
- }, "setAuthParams");
1035
+ }
1036
+ __name(setAuthParams, "setAuthParams");
1028
1037
  var buildUrl = /* @__PURE__ */ __name((options) => getUrl({
1029
1038
  baseUrl: options.baseUrl,
1030
1039
  path: options.path,
@@ -1153,10 +1162,7 @@ var createClient = /* @__PURE__ */ __name((config = {}) => {
1153
1162
  serializedBody: void 0
1154
1163
  };
1155
1164
  if (opts.security) {
1156
- await setAuthParams({
1157
- ...opts,
1158
- security: opts.security
1159
- });
1165
+ await setAuthParams(opts);
1160
1166
  }
1161
1167
  if (opts.requestValidator) {
1162
1168
  await opts.requestValidator(opts);
@@ -1349,11 +1355,15 @@ var CfgAccountsApiKey = class {
1349
1355
  */
1350
1356
  static cfgAccountsApiKeyRetrieve(options) {
1351
1357
  return (options?.client ?? client).get({
1352
- security: [{ scheme: "bearer", type: "http" }, {
1353
- in: "cookie",
1354
- name: "sessionid",
1355
- type: "apiKey"
1356
- }],
1358
+ security: [
1359
+ { scheme: "bearer", type: "http" },
1360
+ {
1361
+ in: "cookie",
1362
+ name: "sessionid",
1363
+ type: "apiKey"
1364
+ },
1365
+ { name: "X-API-Key", type: "apiKey" }
1366
+ ],
1357
1367
  url: "/cfg/accounts/api-key/",
1358
1368
  ...options
1359
1369
  });
@@ -1365,11 +1375,15 @@ var CfgAccountsApiKey = class {
1365
1375
  */
1366
1376
  static cfgAccountsApiKeyRegenerateCreate(options) {
1367
1377
  return (options.client ?? client).post({
1368
- security: [{ scheme: "bearer", type: "http" }, {
1369
- in: "cookie",
1370
- name: "sessionid",
1371
- type: "apiKey"
1372
- }],
1378
+ security: [
1379
+ { scheme: "bearer", type: "http" },
1380
+ {
1381
+ in: "cookie",
1382
+ name: "sessionid",
1383
+ type: "apiKey"
1384
+ },
1385
+ { name: "X-API-Key", type: "apiKey" }
1386
+ ],
1373
1387
  url: "/cfg/accounts/api-key/regenerate/",
1374
1388
  ...options,
1375
1389
  headers: {
@@ -1385,11 +1399,15 @@ var CfgAccountsApiKey = class {
1385
1399
  */
1386
1400
  static cfgAccountsApiKeyTestCreate(options) {
1387
1401
  return (options.client ?? client).post({
1388
- security: [{ scheme: "bearer", type: "http" }, {
1389
- in: "cookie",
1390
- name: "sessionid",
1391
- type: "apiKey"
1392
- }],
1402
+ security: [
1403
+ { scheme: "bearer", type: "http" },
1404
+ {
1405
+ in: "cookie",
1406
+ name: "sessionid",
1407
+ type: "apiKey"
1408
+ },
1409
+ { name: "X-API-Key", type: "apiKey" }
1410
+ ],
1393
1411
  url: "/cfg/accounts/api-key/test/",
1394
1412
  ...options,
1395
1413
  headers: {