@djangocfg/api 2.1.476 → 2.1.478

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 (42) hide show
  1. package/dist/auth.cjs +173 -121
  2. package/dist/auth.cjs.map +1 -1
  3. package/dist/auth.d.cts +36 -2
  4. package/dist/auth.d.ts +36 -2
  5. package/dist/auth.mjs +173 -121
  6. package/dist/auth.mjs.map +1 -1
  7. package/dist/clients.cjs +18 -0
  8. package/dist/clients.cjs.map +1 -1
  9. package/dist/clients.d.cts +49 -0
  10. package/dist/clients.d.ts +49 -0
  11. package/dist/clients.mjs +18 -0
  12. package/dist/clients.mjs.map +1 -1
  13. package/dist/hooks.cjs +133 -1
  14. package/dist/hooks.cjs.map +1 -1
  15. package/dist/hooks.d.cts +61 -1
  16. package/dist/hooks.d.ts +61 -1
  17. package/dist/hooks.mjs +133 -1
  18. package/dist/hooks.mjs.map +1 -1
  19. package/dist/index.cjs +18 -0
  20. package/dist/index.cjs.map +1 -1
  21. package/dist/index.d.cts +72 -4
  22. package/dist/index.d.ts +72 -4
  23. package/dist/index.mjs +18 -0
  24. package/dist/index.mjs.map +1 -1
  25. package/package.json +2 -2
  26. package/src/_api/generated/_cfg_accounts/hooks/index.ts +1 -0
  27. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOtpConsentPolicyRetrieve.ts +74 -0
  28. package/src/_api/generated/_cfg_accounts/openapi.json +76 -0
  29. package/src/_api/generated/_cfg_accounts/schemas/ConsentPolicy.ts +13 -0
  30. package/src/_api/generated/_cfg_accounts/schemas/MarketingConsentDefaultEnum.ts +9 -0
  31. package/src/_api/generated/_cfg_accounts/schemas/OTPRequestRequest.ts +2 -0
  32. package/src/_api/generated/_cfg_accounts/schemas/index.ts +2 -0
  33. package/src/_api/generated/openapi.json +76 -0
  34. package/src/_api/generated/sdk.gen.ts +40 -21
  35. package/src/_api/generated/types.gen.ts +47 -0
  36. package/src/auth/context/AuthContext.tsx +12 -4
  37. package/src/auth/context/types.ts +2 -2
  38. package/src/auth/hooks/useAuthForm.ts +15 -3
  39. package/src/auth/hooks/useAuthFormState.ts +5 -0
  40. package/src/auth/types/form.ts +27 -0
  41. package/src/auth/types/index.ts +1 -0
  42. package/src/hooks/index.ts +6 -0
package/dist/hooks.d.cts CHANGED
@@ -1,3 +1,8 @@
1
+ import * as swr from 'swr';
2
+ import { SWRConfiguration } from 'swr';
3
+ import * as swr__internal from 'swr/_internal';
4
+ import { z } from 'zod';
5
+
1
6
  interface ApiKeyTestResult {
2
7
  valid: boolean;
3
8
  userId: string | null;
@@ -28,4 +33,59 @@ interface UseApiKeyReturn {
28
33
  }
29
34
  declare function useApiKey(): UseApiKeyReturn;
30
35
 
31
- export { type UseApiKeyReturn, useApiKey };
36
+ /**
37
+ * Marketing-consent UI policy derived from the request's geo context.
38
+ */
39
+ type ConsentPolicy$1 = {
40
+ /**
41
+ * Country code seen by the edge (CF-IPCountry), '' if unknown
42
+ */
43
+ country: string;
44
+ /**
45
+ * Default state for the marketing-consent checkbox
46
+ *
47
+ * * `checked` - checked
48
+ * * `unchecked` - unchecked
49
+ */
50
+ marketing_consent_default: MarketingConsentDefaultEnum;
51
+ };
52
+ /**
53
+ * * `checked` - checked
54
+ * * `unchecked` - unchecked
55
+ */
56
+ declare enum MarketingConsentDefaultEnum {
57
+ CHECKED = "checked",
58
+ UNCHECKED = "unchecked"
59
+ }
60
+ type CfgAccountsOtpConsentPolicyRetrieveData = {
61
+ body?: never;
62
+ path?: never;
63
+ query?: never;
64
+ url: '/cfg/accounts/otp/consent-policy/';
65
+ };
66
+ type CfgAccountsOtpConsentPolicyRetrieveResponses = {
67
+ 200: ConsentPolicy$1;
68
+ };
69
+
70
+ type Result = CfgAccountsOtpConsentPolicyRetrieveResponses[keyof CfgAccountsOtpConsentPolicyRetrieveResponses];
71
+ /**
72
+ * Optional `enabled` flag — when `false`, the SWR key becomes `null` and
73
+ * no request is made. Use for gated endpoints (auth-required, feature
74
+ * flags, "fetch only when X is selected"). The flag is stripped before
75
+ * being forwarded to `useSWR` so the underlying SWR config stays pristine.
76
+ */
77
+ type HookConfig = SWRConfiguration<Result> & {
78
+ enabled?: boolean;
79
+ };
80
+ declare function useCfgAccountsOtpConsentPolicyRetrieve(args?: Omit<CfgAccountsOtpConsentPolicyRetrieveData, "url" | "body">, config?: HookConfig): swr.SWRResponse<ConsentPolicy$1, any, SWRConfiguration<ConsentPolicy$1, any, ((arg: readonly [any, ...unknown[]]) => swr__internal.FetcherResponse<ConsentPolicy$1>) | ((arg: readonly [any, ...unknown[]]) => swr__internal.FetcherResponse<ConsentPolicy$1>)>>;
81
+
82
+ declare const ConsentPolicySchema: z.ZodObject<{
83
+ country: z.ZodString;
84
+ marketing_consent_default: z.ZodEnum<{
85
+ checked: "checked";
86
+ unchecked: "unchecked";
87
+ }>;
88
+ }, z.core.$strip>;
89
+ type ConsentPolicy = z.infer<typeof ConsentPolicySchema>;
90
+
91
+ export { type ConsentPolicy, type UseApiKeyReturn, useApiKey, useCfgAccountsOtpConsentPolicyRetrieve };
package/dist/hooks.d.ts CHANGED
@@ -1,3 +1,8 @@
1
+ import * as swr from 'swr';
2
+ import { SWRConfiguration } from 'swr';
3
+ import * as swr__internal from 'swr/_internal';
4
+ import { z } from 'zod';
5
+
1
6
  interface ApiKeyTestResult {
2
7
  valid: boolean;
3
8
  userId: string | null;
@@ -28,4 +33,59 @@ interface UseApiKeyReturn {
28
33
  }
29
34
  declare function useApiKey(): UseApiKeyReturn;
30
35
 
31
- export { type UseApiKeyReturn, useApiKey };
36
+ /**
37
+ * Marketing-consent UI policy derived from the request's geo context.
38
+ */
39
+ type ConsentPolicy$1 = {
40
+ /**
41
+ * Country code seen by the edge (CF-IPCountry), '' if unknown
42
+ */
43
+ country: string;
44
+ /**
45
+ * Default state for the marketing-consent checkbox
46
+ *
47
+ * * `checked` - checked
48
+ * * `unchecked` - unchecked
49
+ */
50
+ marketing_consent_default: MarketingConsentDefaultEnum;
51
+ };
52
+ /**
53
+ * * `checked` - checked
54
+ * * `unchecked` - unchecked
55
+ */
56
+ declare enum MarketingConsentDefaultEnum {
57
+ CHECKED = "checked",
58
+ UNCHECKED = "unchecked"
59
+ }
60
+ type CfgAccountsOtpConsentPolicyRetrieveData = {
61
+ body?: never;
62
+ path?: never;
63
+ query?: never;
64
+ url: '/cfg/accounts/otp/consent-policy/';
65
+ };
66
+ type CfgAccountsOtpConsentPolicyRetrieveResponses = {
67
+ 200: ConsentPolicy$1;
68
+ };
69
+
70
+ type Result = CfgAccountsOtpConsentPolicyRetrieveResponses[keyof CfgAccountsOtpConsentPolicyRetrieveResponses];
71
+ /**
72
+ * Optional `enabled` flag — when `false`, the SWR key becomes `null` and
73
+ * no request is made. Use for gated endpoints (auth-required, feature
74
+ * flags, "fetch only when X is selected"). The flag is stripped before
75
+ * being forwarded to `useSWR` so the underlying SWR config stays pristine.
76
+ */
77
+ type HookConfig = SWRConfiguration<Result> & {
78
+ enabled?: boolean;
79
+ };
80
+ declare function useCfgAccountsOtpConsentPolicyRetrieve(args?: Omit<CfgAccountsOtpConsentPolicyRetrieveData, "url" | "body">, config?: HookConfig): swr.SWRResponse<ConsentPolicy$1, any, SWRConfiguration<ConsentPolicy$1, any, ((arg: readonly [any, ...unknown[]]) => swr__internal.FetcherResponse<ConsentPolicy$1>) | ((arg: readonly [any, ...unknown[]]) => swr__internal.FetcherResponse<ConsentPolicy$1>)>>;
81
+
82
+ declare const ConsentPolicySchema: z.ZodObject<{
83
+ country: z.ZodString;
84
+ marketing_consent_default: z.ZodEnum<{
85
+ checked: "checked";
86
+ unchecked: "unchecked";
87
+ }>;
88
+ }, z.core.$strip>;
89
+ type ConsentPolicy = z.infer<typeof ConsentPolicySchema>;
90
+
91
+ export { type ConsentPolicy, type UseApiKeyReturn, useApiKey, useCfgAccountsOtpConsentPolicyRetrieve };
package/dist/hooks.mjs CHANGED
@@ -1552,6 +1552,72 @@ var CfgAccountsApiKey = class {
1552
1552
  });
1553
1553
  }
1554
1554
  };
1555
+ var CfgAccounts = class {
1556
+ static {
1557
+ __name(this, "CfgAccounts");
1558
+ }
1559
+ /**
1560
+ * Marketing-consent checkbox policy for the caller's jurisdiction.
1561
+ *
1562
+ * Derived from the edge-provided CF-IPCountry — the same signal stored
1563
+ * as consent evidence at request time. Unknown country fails safe to
1564
+ * "unchecked".
1565
+ */
1566
+ static cfgAccountsOtpConsentPolicyRetrieve(options) {
1567
+ return (options?.client ?? client).get({
1568
+ security: [
1569
+ { name: "X-API-Key", type: "apiKey" },
1570
+ { scheme: "bearer", type: "http" },
1571
+ { name: "Authorization", type: "apiKey" }
1572
+ ],
1573
+ url: "/cfg/accounts/otp/consent-policy/",
1574
+ ...options
1575
+ });
1576
+ }
1577
+ /**
1578
+ * Request OTP code to email.
1579
+ */
1580
+ static cfgAccountsOtpRequestCreate(options) {
1581
+ return (options.client ?? client).post({
1582
+ security: [
1583
+ { name: "X-API-Key", type: "apiKey" },
1584
+ { scheme: "bearer", type: "http" },
1585
+ { name: "Authorization", type: "apiKey" }
1586
+ ],
1587
+ url: "/cfg/accounts/otp/request/",
1588
+ ...options,
1589
+ headers: {
1590
+ "Content-Type": "application/json",
1591
+ ...options.headers
1592
+ }
1593
+ });
1594
+ }
1595
+ /**
1596
+ * Verify OTP code and return JWT tokens or 2FA session.
1597
+ *
1598
+ * If user has 2FA enabled:
1599
+ * - Returns requires_2fa=True with session_id
1600
+ * - Client must complete 2FA verification at /cfg/totp/verify/
1601
+ *
1602
+ * If user has no 2FA:
1603
+ * - Returns JWT tokens and user data directly
1604
+ */
1605
+ static cfgAccountsOtpVerifyCreate(options) {
1606
+ return (options.client ?? client).post({
1607
+ security: [
1608
+ { name: "X-API-Key", type: "apiKey" },
1609
+ { scheme: "bearer", type: "http" },
1610
+ { name: "Authorization", type: "apiKey" }
1611
+ ],
1612
+ url: "/cfg/accounts/otp/verify/",
1613
+ ...options,
1614
+ headers: {
1615
+ "Content-Type": "application/json",
1616
+ ...options.headers
1617
+ }
1618
+ });
1619
+ }
1620
+ };
1555
1621
 
1556
1622
  // src/_api/generated/_cfg_accounts/schemas/APIKeyRegenerate.ts
1557
1623
  import { z } from "zod";
@@ -1835,7 +1901,73 @@ function useApiKey() {
1835
1901
  };
1836
1902
  }
1837
1903
  __name(useApiKey, "useApiKey");
1904
+
1905
+ // src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOtpConsentPolicyRetrieve.ts
1906
+ import useSWR2 from "swr";
1907
+
1908
+ // src/_api/generated/_cfg_accounts/schemas/ConsentPolicy.ts
1909
+ import { z as z6 } from "zod";
1910
+
1911
+ // src/_api/generated/_cfg_accounts/schemas/MarketingConsentDefaultEnum.ts
1912
+ import { z as z5 } from "zod";
1913
+ var MarketingConsentDefaultEnumSchema = z5.enum(["checked", "unchecked"]);
1914
+
1915
+ // src/_api/generated/_cfg_accounts/schemas/ConsentPolicy.ts
1916
+ var ConsentPolicySchema = z6.object({
1917
+ country: z6.string(),
1918
+ marketing_consent_default: MarketingConsentDefaultEnumSchema
1919
+ });
1920
+
1921
+ // src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOtpConsentPolicyRetrieve.ts
1922
+ function useCfgAccountsOtpConsentPolicyRetrieve(args, config) {
1923
+ const { enabled = true, ...swrConfig } = config ?? {};
1924
+ const key = enabled ? ["cfg_accounts_otp_consent_policy_retrieve", args ?? {}] : null;
1925
+ return useSWR2(
1926
+ key,
1927
+ async () => {
1928
+ const res = await CfgAccounts.cfgAccountsOtpConsentPolicyRetrieve({ ...args ?? {}, throwOnError: true });
1929
+ const data = res.data;
1930
+ const parsed = ConsentPolicySchema.safeParse(data);
1931
+ if (!parsed.success) {
1932
+ console.warn(
1933
+ "[zod] response did not match schema",
1934
+ {
1935
+ operation: "cfg_accounts_otp_consent_policy_retrieve",
1936
+ method: "GET",
1937
+ path: "/cfg/accounts/otp/consent-policy/",
1938
+ issues: parsed.error.issues,
1939
+ data
1940
+ }
1941
+ );
1942
+ if (typeof window !== "undefined") {
1943
+ try {
1944
+ window.dispatchEvent(
1945
+ new CustomEvent("zod-validation-error", {
1946
+ detail: {
1947
+ operation: "cfg_accounts_otp_consent_policy_retrieve",
1948
+ method: "GET",
1949
+ path: "/cfg/accounts/otp/consent-policy/",
1950
+ issues: parsed.error.issues,
1951
+ data,
1952
+ timestamp: /* @__PURE__ */ new Date()
1953
+ },
1954
+ bubbles: true,
1955
+ cancelable: false
1956
+ })
1957
+ );
1958
+ } catch {
1959
+ }
1960
+ }
1961
+ return data;
1962
+ }
1963
+ return parsed.data;
1964
+ },
1965
+ swrConfig
1966
+ );
1967
+ }
1968
+ __name(useCfgAccountsOtpConsentPolicyRetrieve, "useCfgAccountsOtpConsentPolicyRetrieve");
1838
1969
  export {
1839
- useApiKey
1970
+ useApiKey,
1971
+ useCfgAccountsOtpConsentPolicyRetrieve
1840
1972
  };
1841
1973
  //# sourceMappingURL=hooks.mjs.map