@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/hooks.mjs CHANGED
@@ -466,11 +466,8 @@ var checkForExistence = /* @__PURE__ */ __name((options, name) => {
466
466
  }
467
467
  return false;
468
468
  }, "checkForExistence");
469
- var setAuthParams = /* @__PURE__ */ __name(async ({
470
- security,
471
- ...options
472
- }) => {
473
- for (const auth2 of security) {
469
+ async function setAuthParams(options) {
470
+ for (const auth2 of options.security ?? []) {
474
471
  if (checkForExistence(options, auth2.name)) {
475
472
  continue;
476
473
  }
@@ -495,7 +492,8 @@ var setAuthParams = /* @__PURE__ */ __name(async ({
495
492
  break;
496
493
  }
497
494
  }
498
- }, "setAuthParams");
495
+ }
496
+ __name(setAuthParams, "setAuthParams");
499
497
  var buildUrl = /* @__PURE__ */ __name((options) => getUrl({
500
498
  baseUrl: options.baseUrl,
501
499
  path: options.path,
@@ -624,10 +622,7 @@ var createClient = /* @__PURE__ */ __name((config = {}) => {
624
622
  serializedBody: void 0
625
623
  };
626
624
  if (opts.security) {
627
- await setAuthParams({
628
- ...opts,
629
- security: opts.security
630
- });
625
+ await setAuthParams(opts);
631
626
  }
632
627
  if (opts.requestValidator) {
633
628
  await opts.requestValidator(opts);
@@ -931,6 +926,18 @@ function detectLocale() {
931
926
  }
932
927
  __name(detectLocale, "detectLocale");
933
928
  function defaultBaseUrl() {
929
+ if (typeof window !== "undefined") {
930
+ try {
931
+ if (typeof process !== "undefined" && process.env) {
932
+ if (process.env.NEXT_PUBLIC_STATIC_BUILD === "true") return "";
933
+ if (process.env.NEXT_PUBLIC_API_PROXY_URL !== void 0)
934
+ return process.env.NEXT_PUBLIC_API_PROXY_URL;
935
+ return process.env.NEXT_PUBLIC_API_URL || "";
936
+ }
937
+ } catch {
938
+ }
939
+ return "";
940
+ }
934
941
  try {
935
942
  if (typeof process !== "undefined" && process.env) {
936
943
  if (process.env.NEXT_PUBLIC_STATIC_BUILD === "true") return "";
@@ -942,7 +949,6 @@ function defaultBaseUrl() {
942
949
  }
943
950
  __name(defaultBaseUrl, "defaultBaseUrl");
944
951
  function defaultApiKey() {
945
- if (isBrowser) return null;
946
952
  try {
947
953
  if (typeof process !== "undefined" && process.env?.NEXT_PUBLIC_API_KEY) {
948
954
  return process.env.NEXT_PUBLIC_API_KEY;
@@ -1098,7 +1104,7 @@ function installAuthOnClient(client2) {
1098
1104
  const locale = auth.getLocale();
1099
1105
  if (locale) request.headers.set("Accept-Language", locale);
1100
1106
  const apiKey = auth.getApiKey();
1101
- if (apiKey) request.headers.set("X-API-Key", apiKey);
1107
+ if (apiKey && !request.headers.has("X-API-Key")) request.headers.set("X-API-Key", apiKey);
1102
1108
  try {
1103
1109
  const tz = Intl.DateTimeFormat().resolvedOptions().timeZone;
1104
1110
  if (tz) request.headers.set("X-Timezone", tz);
@@ -1176,11 +1182,15 @@ var CfgAccountsApiKey = class {
1176
1182
  */
1177
1183
  static cfgAccountsApiKeyRetrieve(options) {
1178
1184
  return (options?.client ?? client).get({
1179
- security: [{ scheme: "bearer", type: "http" }, {
1180
- in: "cookie",
1181
- name: "sessionid",
1182
- type: "apiKey"
1183
- }],
1185
+ security: [
1186
+ { scheme: "bearer", type: "http" },
1187
+ {
1188
+ in: "cookie",
1189
+ name: "sessionid",
1190
+ type: "apiKey"
1191
+ },
1192
+ { name: "X-API-Key", type: "apiKey" }
1193
+ ],
1184
1194
  url: "/cfg/accounts/api-key/",
1185
1195
  ...options
1186
1196
  });
@@ -1192,11 +1202,15 @@ var CfgAccountsApiKey = class {
1192
1202
  */
1193
1203
  static cfgAccountsApiKeyRegenerateCreate(options) {
1194
1204
  return (options.client ?? client).post({
1195
- security: [{ scheme: "bearer", type: "http" }, {
1196
- in: "cookie",
1197
- name: "sessionid",
1198
- type: "apiKey"
1199
- }],
1205
+ security: [
1206
+ { scheme: "bearer", type: "http" },
1207
+ {
1208
+ in: "cookie",
1209
+ name: "sessionid",
1210
+ type: "apiKey"
1211
+ },
1212
+ { name: "X-API-Key", type: "apiKey" }
1213
+ ],
1200
1214
  url: "/cfg/accounts/api-key/regenerate/",
1201
1215
  ...options,
1202
1216
  headers: {
@@ -1212,11 +1226,15 @@ var CfgAccountsApiKey = class {
1212
1226
  */
1213
1227
  static cfgAccountsApiKeyTestCreate(options) {
1214
1228
  return (options.client ?? client).post({
1215
- security: [{ scheme: "bearer", type: "http" }, {
1216
- in: "cookie",
1217
- name: "sessionid",
1218
- type: "apiKey"
1219
- }],
1229
+ security: [
1230
+ { scheme: "bearer", type: "http" },
1231
+ {
1232
+ in: "cookie",
1233
+ name: "sessionid",
1234
+ type: "apiKey"
1235
+ },
1236
+ { name: "X-API-Key", type: "apiKey" }
1237
+ ],
1220
1238
  url: "/cfg/accounts/api-key/test/",
1221
1239
  ...options,
1222
1240
  headers: {
@@ -1294,7 +1312,8 @@ var APIKeySchema = z2.object({
1294
1312
 
1295
1313
  // src/_api/generated/_cfg_accounts/hooks/useCfgAccountsApiKeyRetrieve.ts
1296
1314
  function useCfgAccountsApiKeyRetrieve(args, config) {
1297
- const key = ["cfg_accounts_api_key_retrieve", args ?? {}];
1315
+ const { enabled = true, ...swrConfig } = config ?? {};
1316
+ const key = enabled ? ["cfg_accounts_api_key_retrieve", args ?? {}] : null;
1298
1317
  return useSWR(
1299
1318
  key,
1300
1319
  async () => {
@@ -1335,7 +1354,7 @@ function useCfgAccountsApiKeyRetrieve(args, config) {
1335
1354
  }
1336
1355
  return parsed.data;
1337
1356
  },
1338
- config
1357
+ swrConfig
1339
1358
  );
1340
1359
  }
1341
1360
  __name(useCfgAccountsApiKeyRetrieve, "useCfgAccountsApiKeyRetrieve");