@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.
- package/dist/auth.cjs +173 -121
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.d.cts +36 -2
- package/dist/auth.d.ts +36 -2
- package/dist/auth.mjs +173 -121
- package/dist/auth.mjs.map +1 -1
- package/dist/clients.cjs +18 -0
- package/dist/clients.cjs.map +1 -1
- package/dist/clients.d.cts +49 -0
- package/dist/clients.d.ts +49 -0
- package/dist/clients.mjs +18 -0
- package/dist/clients.mjs.map +1 -1
- package/dist/hooks.cjs +133 -1
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.d.cts +61 -1
- package/dist/hooks.d.ts +61 -1
- package/dist/hooks.mjs +133 -1
- package/dist/hooks.mjs.map +1 -1
- package/dist/index.cjs +18 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +72 -4
- package/dist/index.d.ts +72 -4
- package/dist/index.mjs +18 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/_api/generated/_cfg_accounts/hooks/index.ts +1 -0
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOtpConsentPolicyRetrieve.ts +74 -0
- package/src/_api/generated/_cfg_accounts/openapi.json +76 -0
- package/src/_api/generated/_cfg_accounts/schemas/ConsentPolicy.ts +13 -0
- package/src/_api/generated/_cfg_accounts/schemas/MarketingConsentDefaultEnum.ts +9 -0
- package/src/_api/generated/_cfg_accounts/schemas/OTPRequestRequest.ts +2 -0
- package/src/_api/generated/_cfg_accounts/schemas/index.ts +2 -0
- package/src/_api/generated/openapi.json +76 -0
- package/src/_api/generated/sdk.gen.ts +40 -21
- package/src/_api/generated/types.gen.ts +47 -0
- package/src/auth/context/AuthContext.tsx +12 -4
- package/src/auth/context/types.ts +2 -2
- package/src/auth/hooks/useAuthForm.ts +15 -3
- package/src/auth/hooks/useAuthFormState.ts +5 -0
- package/src/auth/types/form.ts +27 -0
- package/src/auth/types/index.ts +1 -0
- package/src/hooks/index.ts +6 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@djangocfg/api",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.478",
|
|
4
4
|
"description": "Auto-generated TypeScript API client with React hooks, SWR integration, and Zod validation for Django REST Framework backends",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"django",
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
"zod": "^4.3.6"
|
|
85
85
|
},
|
|
86
86
|
"devDependencies": {
|
|
87
|
-
"@djangocfg/typescript-config": "^2.1.
|
|
87
|
+
"@djangocfg/typescript-config": "^2.1.478",
|
|
88
88
|
"@testing-library/react": "^16.3.2",
|
|
89
89
|
"@types/node": "^25.9.5",
|
|
90
90
|
"@types/react": "19.2.15",
|
|
@@ -10,6 +10,7 @@ export { useCfgAccountsOauthDisconnectCreate } from "./useCfgAccountsOauthDiscon
|
|
|
10
10
|
export { useCfgAccountsOauthGithubAuthorizeCreate } from "./useCfgAccountsOauthGithubAuthorizeCreate";
|
|
11
11
|
export { useCfgAccountsOauthGithubCallbackCreate } from "./useCfgAccountsOauthGithubCallbackCreate";
|
|
12
12
|
export { useCfgAccountsOauthProvidersRetrieve } from "./useCfgAccountsOauthProvidersRetrieve";
|
|
13
|
+
export { useCfgAccountsOtpConsentPolicyRetrieve } from "./useCfgAccountsOtpConsentPolicyRetrieve";
|
|
13
14
|
export { useCfgAccountsOtpRequestCreate } from "./useCfgAccountsOtpRequestCreate";
|
|
14
15
|
export { useCfgAccountsOtpVerifyCreate } from "./useCfgAccountsOtpVerifyCreate";
|
|
15
16
|
export { useCfgAccountsProfileAvatarCreate } from "./useCfgAccountsProfileAvatarCreate";
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
// AUTO-GENERATED by openapi_processor / ts.hooks
|
|
4
|
+
// GET /cfg/accounts/otp/consent-policy/
|
|
5
|
+
// DO NOT EDIT — re-run `make gen`.
|
|
6
|
+
|
|
7
|
+
import useSWR from "swr";
|
|
8
|
+
import type { SWRConfiguration } from "swr";
|
|
9
|
+
import { CfgAccounts } from "../../sdk.gen";
|
|
10
|
+
import type { CfgAccountsOtpConsentPolicyRetrieveData, CfgAccountsOtpConsentPolicyRetrieveResponses } from "../../types.gen";
|
|
11
|
+
import { ConsentPolicySchema } from "../schemas/ConsentPolicy";
|
|
12
|
+
|
|
13
|
+
type Result = CfgAccountsOtpConsentPolicyRetrieveResponses[keyof CfgAccountsOtpConsentPolicyRetrieveResponses];
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Optional `enabled` flag — when `false`, the SWR key becomes `null` and
|
|
17
|
+
* no request is made. Use for gated endpoints (auth-required, feature
|
|
18
|
+
* flags, "fetch only when X is selected"). The flag is stripped before
|
|
19
|
+
* being forwarded to `useSWR` so the underlying SWR config stays pristine.
|
|
20
|
+
*/
|
|
21
|
+
type HookConfig = SWRConfiguration<Result> & { enabled?: boolean };
|
|
22
|
+
|
|
23
|
+
export function useCfgAccountsOtpConsentPolicyRetrieve(
|
|
24
|
+
args?: Omit<CfgAccountsOtpConsentPolicyRetrieveData, "url" | "body">,
|
|
25
|
+
config?: HookConfig,
|
|
26
|
+
) {
|
|
27
|
+
const { enabled = true, ...swrConfig } = config ?? {};
|
|
28
|
+
const key = enabled ? ["cfg_accounts_otp_consent_policy_retrieve", args ?? {}] as const : null;
|
|
29
|
+
return useSWR<Result>(
|
|
30
|
+
key,
|
|
31
|
+
async () => {
|
|
32
|
+
const res = await CfgAccounts.cfgAccountsOtpConsentPolicyRetrieve({ ...(args ?? {}), throwOnError: true } as never);
|
|
33
|
+
const data = res.data as Result;
|
|
34
|
+
const parsed = ConsentPolicySchema.safeParse(data);
|
|
35
|
+
if (!parsed.success) {
|
|
36
|
+
// Log first so the failure is always visible, even if the
|
|
37
|
+
// event handler swallows it.
|
|
38
|
+
console.warn(
|
|
39
|
+
"[zod] response did not match schema",
|
|
40
|
+
{
|
|
41
|
+
operation: "cfg_accounts_otp_consent_policy_retrieve",
|
|
42
|
+
method: "GET",
|
|
43
|
+
path: "/cfg/accounts/otp/consent-policy/",
|
|
44
|
+
issues: parsed.error.issues,
|
|
45
|
+
data,
|
|
46
|
+
},
|
|
47
|
+
);
|
|
48
|
+
if (typeof window !== "undefined") {
|
|
49
|
+
try {
|
|
50
|
+
window.dispatchEvent(
|
|
51
|
+
new CustomEvent("zod-validation-error", {
|
|
52
|
+
detail: {
|
|
53
|
+
operation: "cfg_accounts_otp_consent_policy_retrieve",
|
|
54
|
+
method: "GET",
|
|
55
|
+
path: "/cfg/accounts/otp/consent-policy/",
|
|
56
|
+
issues: parsed.error.issues,
|
|
57
|
+
data,
|
|
58
|
+
timestamp: new Date(),
|
|
59
|
+
},
|
|
60
|
+
bubbles: true,
|
|
61
|
+
cancelable: false,
|
|
62
|
+
}),
|
|
63
|
+
);
|
|
64
|
+
} catch {
|
|
65
|
+
// Event dispatch is best-effort.
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return data;
|
|
69
|
+
}
|
|
70
|
+
return parsed.data as unknown as Result;
|
|
71
|
+
},
|
|
72
|
+
swrConfig,
|
|
73
|
+
);
|
|
74
|
+
}
|
|
@@ -450,6 +450,40 @@
|
|
|
450
450
|
"x-async-capable": false
|
|
451
451
|
}
|
|
452
452
|
},
|
|
453
|
+
"/cfg/accounts/otp/consent-policy/": {
|
|
454
|
+
"get": {
|
|
455
|
+
"operationId": "cfg_accounts_otp_consent_policy_retrieve",
|
|
456
|
+
"description": "Marketing-consent checkbox policy for the caller's jurisdiction.\n\nDerived from the edge-provided CF-IPCountry — the same signal stored\nas consent evidence at request time. Unknown country fails safe to\n\"unchecked\".",
|
|
457
|
+
"tags": [
|
|
458
|
+
"cfg_accounts"
|
|
459
|
+
],
|
|
460
|
+
"security": [
|
|
461
|
+
{
|
|
462
|
+
"apiKeyAuth": []
|
|
463
|
+
},
|
|
464
|
+
{
|
|
465
|
+
"jwtAuthWithLastLogin": []
|
|
466
|
+
},
|
|
467
|
+
{
|
|
468
|
+
"tokenAuth": []
|
|
469
|
+
},
|
|
470
|
+
{}
|
|
471
|
+
],
|
|
472
|
+
"responses": {
|
|
473
|
+
"200": {
|
|
474
|
+
"content": {
|
|
475
|
+
"application/json": {
|
|
476
|
+
"schema": {
|
|
477
|
+
"$ref": "#/components/schemas/ConsentPolicy"
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
},
|
|
481
|
+
"description": ""
|
|
482
|
+
}
|
|
483
|
+
},
|
|
484
|
+
"x-async-capable": false
|
|
485
|
+
}
|
|
486
|
+
},
|
|
453
487
|
"/cfg/accounts/otp/request/": {
|
|
454
488
|
"post": {
|
|
455
489
|
"operationId": "cfg_accounts_otp_request_create",
|
|
@@ -1362,6 +1396,36 @@
|
|
|
1362
1396
|
}
|
|
1363
1397
|
}
|
|
1364
1398
|
},
|
|
1399
|
+
"ConsentPolicy": {
|
|
1400
|
+
"type": "object",
|
|
1401
|
+
"description": "Marketing-consent UI policy derived from the request's geo context.",
|
|
1402
|
+
"properties": {
|
|
1403
|
+
"country": {
|
|
1404
|
+
"type": "string",
|
|
1405
|
+
"description": "Country code seen by the edge (CF-IPCountry), '' if unknown"
|
|
1406
|
+
},
|
|
1407
|
+
"marketing_consent_default": {
|
|
1408
|
+
"allOf": [
|
|
1409
|
+
{
|
|
1410
|
+
"$ref": "#/components/schemas/MarketingConsentDefaultEnum"
|
|
1411
|
+
}
|
|
1412
|
+
],
|
|
1413
|
+
"description": "Default state for the marketing-consent checkbox\n\n* `checked` - checked\n* `unchecked` - unchecked"
|
|
1414
|
+
}
|
|
1415
|
+
},
|
|
1416
|
+
"required": [
|
|
1417
|
+
"country",
|
|
1418
|
+
"marketing_consent_default"
|
|
1419
|
+
]
|
|
1420
|
+
},
|
|
1421
|
+
"MarketingConsentDefaultEnum": {
|
|
1422
|
+
"enum": [
|
|
1423
|
+
"checked",
|
|
1424
|
+
"unchecked"
|
|
1425
|
+
],
|
|
1426
|
+
"type": "string",
|
|
1427
|
+
"description": "* `checked` - checked\n* `unchecked` - unchecked"
|
|
1428
|
+
},
|
|
1365
1429
|
"OAuthAuthorizeRequestRequest": {
|
|
1366
1430
|
"type": "object",
|
|
1367
1431
|
"description": "Request to start OAuth flow.",
|
|
@@ -1639,6 +1703,18 @@
|
|
|
1639
1703
|
"type": "string",
|
|
1640
1704
|
"format": "uri",
|
|
1641
1705
|
"description": "Source URL for tracking registration (e.g., https://my.djangocfg.com)"
|
|
1706
|
+
},
|
|
1707
|
+
"marketing_consent": {
|
|
1708
|
+
"type": [
|
|
1709
|
+
"boolean",
|
|
1710
|
+
"null"
|
|
1711
|
+
],
|
|
1712
|
+
"description": "Marketing-consent choice made at signup (absent/null = not asked, false = declined)"
|
|
1713
|
+
},
|
|
1714
|
+
"consent_disclosure_version": {
|
|
1715
|
+
"type": "string",
|
|
1716
|
+
"description": "Version of the consent disclosure text shown (e.g. product-updates-reg-v1)",
|
|
1717
|
+
"maxLength": 64
|
|
1642
1718
|
}
|
|
1643
1719
|
},
|
|
1644
1720
|
"required": [
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// AUTO-GENERATED by cmdop_server / devtools.generator.ts_extras
|
|
2
|
+
// Source: OpenAPI 3.1 components.schemas
|
|
3
|
+
// DO NOT EDIT — re-run `make gen-clients`.
|
|
4
|
+
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
import { MarketingConsentDefaultEnumSchema } from "./MarketingConsentDefaultEnum";
|
|
7
|
+
|
|
8
|
+
export const ConsentPolicySchema = z.object({
|
|
9
|
+
country: z.string(),
|
|
10
|
+
marketing_consent_default: MarketingConsentDefaultEnumSchema,
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export type ConsentPolicy = z.infer<typeof ConsentPolicySchema>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// AUTO-GENERATED by cmdop_server / devtools.generator.ts_extras
|
|
2
|
+
// Source: OpenAPI 3.1 components.schemas
|
|
3
|
+
// DO NOT EDIT — re-run `make gen-clients`.
|
|
4
|
+
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
|
|
7
|
+
export const MarketingConsentDefaultEnumSchema = z.enum(["checked", "unchecked"]);
|
|
8
|
+
|
|
9
|
+
export type MarketingConsentDefaultEnum = z.infer<typeof MarketingConsentDefaultEnumSchema>;
|
|
@@ -7,6 +7,8 @@ import { z } from "zod";
|
|
|
7
7
|
export const OTPRequestRequestSchema = z.object({
|
|
8
8
|
identifier: z.string().min(1),
|
|
9
9
|
source_url: z.string().optional(),
|
|
10
|
+
marketing_consent: z.boolean().nullable().optional(),
|
|
11
|
+
consent_disclosure_version: z.string().max(64).optional(),
|
|
10
12
|
});
|
|
11
13
|
|
|
12
14
|
export type OTPRequestRequest = z.infer<typeof OTPRequestRequestSchema>;
|
|
@@ -10,6 +10,8 @@ export * from "./APIKeyTestResult";
|
|
|
10
10
|
export * from "./AccountDeleteResponse";
|
|
11
11
|
export * from "./CentrifugoToken";
|
|
12
12
|
export * from "./CfgUserUpdateRequest";
|
|
13
|
+
export * from "./ConsentPolicy";
|
|
14
|
+
export * from "./MarketingConsentDefaultEnum";
|
|
13
15
|
export * from "./OAuthAuthorizeRequestRequest";
|
|
14
16
|
export * from "./OAuthAuthorizeResponse";
|
|
15
17
|
export * from "./OAuthCallbackRequestRequest";
|
|
@@ -442,6 +442,40 @@
|
|
|
442
442
|
"x-async-capable": false
|
|
443
443
|
}
|
|
444
444
|
},
|
|
445
|
+
"/cfg/accounts/otp/consent-policy/": {
|
|
446
|
+
"get": {
|
|
447
|
+
"operationId": "cfg_accounts_otp_consent_policy_retrieve",
|
|
448
|
+
"description": "Marketing-consent checkbox policy for the caller's jurisdiction.\n\nDerived from the edge-provided CF-IPCountry — the same signal stored\nas consent evidence at request time. Unknown country fails safe to\n\"unchecked\".",
|
|
449
|
+
"tags": [
|
|
450
|
+
"cfg_accounts"
|
|
451
|
+
],
|
|
452
|
+
"security": [
|
|
453
|
+
{
|
|
454
|
+
"apiKeyAuth": []
|
|
455
|
+
},
|
|
456
|
+
{
|
|
457
|
+
"jwtAuthWithLastLogin": []
|
|
458
|
+
},
|
|
459
|
+
{
|
|
460
|
+
"tokenAuth": []
|
|
461
|
+
},
|
|
462
|
+
{}
|
|
463
|
+
],
|
|
464
|
+
"responses": {
|
|
465
|
+
"200": {
|
|
466
|
+
"content": {
|
|
467
|
+
"application/json": {
|
|
468
|
+
"schema": {
|
|
469
|
+
"$ref": "#/components/schemas/ConsentPolicy"
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
},
|
|
473
|
+
"description": ""
|
|
474
|
+
}
|
|
475
|
+
},
|
|
476
|
+
"x-async-capable": false
|
|
477
|
+
}
|
|
478
|
+
},
|
|
445
479
|
"/cfg/accounts/otp/request/": {
|
|
446
480
|
"post": {
|
|
447
481
|
"operationId": "cfg_accounts_otp_request_create",
|
|
@@ -1983,6 +2017,28 @@
|
|
|
1983
2017
|
"title": "ConnectionTokenResponse",
|
|
1984
2018
|
"type": "object"
|
|
1985
2019
|
},
|
|
2020
|
+
"ConsentPolicy": {
|
|
2021
|
+
"type": "object",
|
|
2022
|
+
"description": "Marketing-consent UI policy derived from the request's geo context.",
|
|
2023
|
+
"properties": {
|
|
2024
|
+
"country": {
|
|
2025
|
+
"type": "string",
|
|
2026
|
+
"description": "Country code seen by the edge (CF-IPCountry), '' if unknown"
|
|
2027
|
+
},
|
|
2028
|
+
"marketing_consent_default": {
|
|
2029
|
+
"allOf": [
|
|
2030
|
+
{
|
|
2031
|
+
"$ref": "#/components/schemas/MarketingConsentDefaultEnum"
|
|
2032
|
+
}
|
|
2033
|
+
],
|
|
2034
|
+
"description": "Default state for the marketing-consent checkbox\n\n* `checked` - checked\n* `unchecked` - unchecked"
|
|
2035
|
+
}
|
|
2036
|
+
},
|
|
2037
|
+
"required": [
|
|
2038
|
+
"country",
|
|
2039
|
+
"marketing_consent_default"
|
|
2040
|
+
]
|
|
2041
|
+
},
|
|
1986
2042
|
"DeviceList": {
|
|
1987
2043
|
"type": "object",
|
|
1988
2044
|
"description": "Serializer for listing TOTP devices.",
|
|
@@ -2087,6 +2143,14 @@
|
|
|
2087
2143
|
"code"
|
|
2088
2144
|
]
|
|
2089
2145
|
},
|
|
2146
|
+
"MarketingConsentDefaultEnum": {
|
|
2147
|
+
"enum": [
|
|
2148
|
+
"checked",
|
|
2149
|
+
"unchecked"
|
|
2150
|
+
],
|
|
2151
|
+
"type": "string",
|
|
2152
|
+
"description": "* `checked` - checked\n* `unchecked` - unchecked"
|
|
2153
|
+
},
|
|
2090
2154
|
"OAuthAuthorizeRequestRequest": {
|
|
2091
2155
|
"type": "object",
|
|
2092
2156
|
"description": "Request to start OAuth flow.",
|
|
@@ -2364,6 +2428,18 @@
|
|
|
2364
2428
|
"type": "string",
|
|
2365
2429
|
"format": "uri",
|
|
2366
2430
|
"description": "Source URL for tracking registration (e.g., https://my.djangocfg.com)"
|
|
2431
|
+
},
|
|
2432
|
+
"marketing_consent": {
|
|
2433
|
+
"type": [
|
|
2434
|
+
"boolean",
|
|
2435
|
+
"null"
|
|
2436
|
+
],
|
|
2437
|
+
"description": "Marketing-consent choice made at signup (absent/null = not asked, false = declined)"
|
|
2438
|
+
},
|
|
2439
|
+
"consent_disclosure_version": {
|
|
2440
|
+
"type": "string",
|
|
2441
|
+
"description": "Version of the consent disclosure text shown (e.g. product-updates-reg-v1)",
|
|
2442
|
+
"maxLength": 64
|
|
2367
2443
|
}
|
|
2368
2444
|
},
|
|
2369
2445
|
"required": [
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { type Client, type ClientMeta, formDataBodySerializer, type Options as Options2, type RequestResult, type TDataShape } from './client';
|
|
4
4
|
import { client } from './client.gen';
|
|
5
|
-
import type { CfgAccountsApiKeyRegenerateCreateData, CfgAccountsApiKeyRegenerateCreateErrors, CfgAccountsApiKeyRegenerateCreateResponses, CfgAccountsApiKeyRetrieveData, CfgAccountsApiKeyRetrieveErrors, CfgAccountsApiKeyRetrieveResponses, CfgAccountsApiKeyRevealCreateData, CfgAccountsApiKeyRevealCreateErrors, CfgAccountsApiKeyRevealCreateResponses, CfgAccountsApiKeyTestCreateData, CfgAccountsApiKeyTestCreateResponses, CfgAccountsOauthConnectionsListData, CfgAccountsOauthConnectionsListResponses, CfgAccountsOauthDisconnectCreateData, CfgAccountsOauthDisconnectCreateErrors, CfgAccountsOauthDisconnectCreateResponses, CfgAccountsOauthGithubAuthorizeCreateData, CfgAccountsOauthGithubAuthorizeCreateErrors, CfgAccountsOauthGithubAuthorizeCreateResponses, CfgAccountsOauthGithubCallbackCreateData, CfgAccountsOauthGithubCallbackCreateErrors, CfgAccountsOauthGithubCallbackCreateResponses, CfgAccountsOauthProvidersRetrieveData, CfgAccountsOauthProvidersRetrieveResponses, CfgAccountsOtpRequestCreateData, CfgAccountsOtpRequestCreateErrors, CfgAccountsOtpRequestCreateResponses, CfgAccountsOtpVerifyCreateData, CfgAccountsOtpVerifyCreateErrors, CfgAccountsOtpVerifyCreateResponses, CfgAccountsProfileAvatarCreateData, CfgAccountsProfileAvatarCreateErrors, CfgAccountsProfileAvatarCreateResponses, CfgAccountsProfileDeleteCreateData, CfgAccountsProfileDeleteCreateErrors, CfgAccountsProfileDeleteCreateResponses, CfgAccountsProfilePartialPartialUpdateData, CfgAccountsProfilePartialPartialUpdateErrors, CfgAccountsProfilePartialPartialUpdateResponses, CfgAccountsProfilePartialUpdateData, CfgAccountsProfilePartialUpdateErrors, CfgAccountsProfilePartialUpdateResponses, CfgAccountsProfileRetrieveData, CfgAccountsProfileRetrieveErrors, CfgAccountsProfileRetrieveResponses, CfgAccountsProfileUpdatePartialUpdateData, CfgAccountsProfileUpdatePartialUpdateErrors, CfgAccountsProfileUpdatePartialUpdateResponses, CfgAccountsProfileUpdateUpdateData, CfgAccountsProfileUpdateUpdateErrors, CfgAccountsProfileUpdateUpdateResponses, CfgAccountsTokenBlacklistCreateData, CfgAccountsTokenBlacklistCreateResponses, CfgAccountsTokenRefreshCreateData, CfgAccountsTokenRefreshCreateResponses, CfgCentrifugoAuthTokenRetrieveData, CfgCentrifugoAuthTokenRetrieveErrors, CfgCentrifugoAuthTokenRetrieveResponses, CfgTotpBackupCodesRegenerateCreateData, CfgTotpBackupCodesRegenerateCreateErrors, CfgTotpBackupCodesRegenerateCreateResponses, CfgTotpBackupCodesRetrieveData, CfgTotpBackupCodesRetrieveResponses, CfgTotpDevicesDestroyData, CfgTotpDevicesDestroyResponses, CfgTotpDevicesRetrieveData, CfgTotpDevicesRetrieveResponses, CfgTotpDisableCreateData, CfgTotpDisableCreateErrors, CfgTotpDisableCreateResponses, CfgTotpSetupConfirmCreateData, CfgTotpSetupConfirmCreateErrors, CfgTotpSetupConfirmCreateResponses, CfgTotpSetupCreateData, CfgTotpSetupCreateErrors, CfgTotpSetupCreateResponses, CfgTotpVerifyBackupCreateData, CfgTotpVerifyBackupCreateErrors, CfgTotpVerifyBackupCreateResponses, CfgTotpVerifyCreateData, CfgTotpVerifyCreateErrors, CfgTotpVerifyCreateResponses } from './types.gen';
|
|
5
|
+
import type { CfgAccountsApiKeyRegenerateCreateData, CfgAccountsApiKeyRegenerateCreateErrors, CfgAccountsApiKeyRegenerateCreateResponses, CfgAccountsApiKeyRetrieveData, CfgAccountsApiKeyRetrieveErrors, CfgAccountsApiKeyRetrieveResponses, CfgAccountsApiKeyRevealCreateData, CfgAccountsApiKeyRevealCreateErrors, CfgAccountsApiKeyRevealCreateResponses, CfgAccountsApiKeyTestCreateData, CfgAccountsApiKeyTestCreateResponses, CfgAccountsOauthConnectionsListData, CfgAccountsOauthConnectionsListResponses, CfgAccountsOauthDisconnectCreateData, CfgAccountsOauthDisconnectCreateErrors, CfgAccountsOauthDisconnectCreateResponses, CfgAccountsOauthGithubAuthorizeCreateData, CfgAccountsOauthGithubAuthorizeCreateErrors, CfgAccountsOauthGithubAuthorizeCreateResponses, CfgAccountsOauthGithubCallbackCreateData, CfgAccountsOauthGithubCallbackCreateErrors, CfgAccountsOauthGithubCallbackCreateResponses, CfgAccountsOauthProvidersRetrieveData, CfgAccountsOauthProvidersRetrieveResponses, CfgAccountsOtpConsentPolicyRetrieveData, CfgAccountsOtpConsentPolicyRetrieveResponses, CfgAccountsOtpRequestCreateData, CfgAccountsOtpRequestCreateErrors, CfgAccountsOtpRequestCreateResponses, CfgAccountsOtpVerifyCreateData, CfgAccountsOtpVerifyCreateErrors, CfgAccountsOtpVerifyCreateResponses, CfgAccountsProfileAvatarCreateData, CfgAccountsProfileAvatarCreateErrors, CfgAccountsProfileAvatarCreateResponses, CfgAccountsProfileDeleteCreateData, CfgAccountsProfileDeleteCreateErrors, CfgAccountsProfileDeleteCreateResponses, CfgAccountsProfilePartialPartialUpdateData, CfgAccountsProfilePartialPartialUpdateErrors, CfgAccountsProfilePartialPartialUpdateResponses, CfgAccountsProfilePartialUpdateData, CfgAccountsProfilePartialUpdateErrors, CfgAccountsProfilePartialUpdateResponses, CfgAccountsProfileRetrieveData, CfgAccountsProfileRetrieveErrors, CfgAccountsProfileRetrieveResponses, CfgAccountsProfileUpdatePartialUpdateData, CfgAccountsProfileUpdatePartialUpdateErrors, CfgAccountsProfileUpdatePartialUpdateResponses, CfgAccountsProfileUpdateUpdateData, CfgAccountsProfileUpdateUpdateErrors, CfgAccountsProfileUpdateUpdateResponses, CfgAccountsTokenBlacklistCreateData, CfgAccountsTokenBlacklistCreateResponses, CfgAccountsTokenRefreshCreateData, CfgAccountsTokenRefreshCreateResponses, CfgCentrifugoAuthTokenRetrieveData, CfgCentrifugoAuthTokenRetrieveErrors, CfgCentrifugoAuthTokenRetrieveResponses, CfgTotpBackupCodesRegenerateCreateData, CfgTotpBackupCodesRegenerateCreateErrors, CfgTotpBackupCodesRegenerateCreateResponses, CfgTotpBackupCodesRetrieveData, CfgTotpBackupCodesRetrieveResponses, CfgTotpDevicesDestroyData, CfgTotpDevicesDestroyResponses, CfgTotpDevicesRetrieveData, CfgTotpDevicesRetrieveResponses, CfgTotpDisableCreateData, CfgTotpDisableCreateErrors, CfgTotpDisableCreateResponses, CfgTotpSetupConfirmCreateData, CfgTotpSetupConfirmCreateErrors, CfgTotpSetupConfirmCreateResponses, CfgTotpSetupCreateData, CfgTotpSetupCreateErrors, CfgTotpSetupCreateResponses, CfgTotpVerifyBackupCreateData, CfgTotpVerifyBackupCreateErrors, CfgTotpVerifyBackupCreateResponses, CfgTotpVerifyCreateData, CfgTotpVerifyCreateErrors, CfgTotpVerifyCreateResponses } from './types.gen';
|
|
6
6
|
|
|
7
7
|
export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean, TResponse = unknown> = Options2<TData, ThrowOnError, TResponse> & {
|
|
8
8
|
/**
|
|
@@ -39,7 +39,7 @@ export class CfgAccountsApiKey {
|
|
|
39
39
|
...options
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
|
-
|
|
42
|
+
|
|
43
43
|
/**
|
|
44
44
|
* Regenerate API key
|
|
45
45
|
*
|
|
@@ -64,7 +64,7 @@ export class CfgAccountsApiKey {
|
|
|
64
64
|
}
|
|
65
65
|
});
|
|
66
66
|
}
|
|
67
|
-
|
|
67
|
+
|
|
68
68
|
/**
|
|
69
69
|
* Reveal API key
|
|
70
70
|
*
|
|
@@ -89,7 +89,7 @@ export class CfgAccountsApiKey {
|
|
|
89
89
|
}
|
|
90
90
|
});
|
|
91
91
|
}
|
|
92
|
-
|
|
92
|
+
|
|
93
93
|
/**
|
|
94
94
|
* Test API key
|
|
95
95
|
*
|
|
@@ -133,7 +133,7 @@ export class CfgAccountsOauth {
|
|
|
133
133
|
...options
|
|
134
134
|
});
|
|
135
135
|
}
|
|
136
|
-
|
|
136
|
+
|
|
137
137
|
/**
|
|
138
138
|
* Disconnect OAuth provider
|
|
139
139
|
*
|
|
@@ -154,7 +154,7 @@ export class CfgAccountsOauth {
|
|
|
154
154
|
}
|
|
155
155
|
});
|
|
156
156
|
}
|
|
157
|
-
|
|
157
|
+
|
|
158
158
|
/**
|
|
159
159
|
* Start GitHub OAuth
|
|
160
160
|
*
|
|
@@ -170,7 +170,7 @@ export class CfgAccountsOauth {
|
|
|
170
170
|
}
|
|
171
171
|
});
|
|
172
172
|
}
|
|
173
|
-
|
|
173
|
+
|
|
174
174
|
/**
|
|
175
175
|
* Complete GitHub OAuth
|
|
176
176
|
*
|
|
@@ -186,7 +186,7 @@ export class CfgAccountsOauth {
|
|
|
186
186
|
}
|
|
187
187
|
});
|
|
188
188
|
}
|
|
189
|
-
|
|
189
|
+
|
|
190
190
|
/**
|
|
191
191
|
* List OAuth providers
|
|
192
192
|
*
|
|
@@ -198,6 +198,25 @@ export class CfgAccountsOauth {
|
|
|
198
198
|
}
|
|
199
199
|
|
|
200
200
|
export class CfgAccounts {
|
|
201
|
+
/**
|
|
202
|
+
* Marketing-consent checkbox policy for the caller's jurisdiction.
|
|
203
|
+
*
|
|
204
|
+
* Derived from the edge-provided CF-IPCountry — the same signal stored
|
|
205
|
+
* as consent evidence at request time. Unknown country fails safe to
|
|
206
|
+
* "unchecked".
|
|
207
|
+
*/
|
|
208
|
+
public static cfgAccountsOtpConsentPolicyRetrieve<ThrowOnError extends boolean = false>(options?: Options<CfgAccountsOtpConsentPolicyRetrieveData, ThrowOnError>): RequestResult<CfgAccountsOtpConsentPolicyRetrieveResponses, unknown, ThrowOnError> {
|
|
209
|
+
return (options?.client ?? client).get<CfgAccountsOtpConsentPolicyRetrieveResponses, unknown, ThrowOnError>({
|
|
210
|
+
security: [
|
|
211
|
+
{ name: 'X-API-Key', type: 'apiKey' },
|
|
212
|
+
{ scheme: 'bearer', type: 'http' },
|
|
213
|
+
{ name: 'Authorization', type: 'apiKey' }
|
|
214
|
+
],
|
|
215
|
+
url: '/cfg/accounts/otp/consent-policy/',
|
|
216
|
+
...options
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
|
|
201
220
|
/**
|
|
202
221
|
* Request OTP code to email.
|
|
203
222
|
*/
|
|
@@ -216,7 +235,7 @@ export class CfgAccounts {
|
|
|
216
235
|
}
|
|
217
236
|
});
|
|
218
237
|
}
|
|
219
|
-
|
|
238
|
+
|
|
220
239
|
/**
|
|
221
240
|
* Verify OTP code and return JWT tokens or 2FA session.
|
|
222
241
|
*
|
|
@@ -261,7 +280,7 @@ export class CfgAccountsProfile {
|
|
|
261
280
|
...options
|
|
262
281
|
});
|
|
263
282
|
}
|
|
264
|
-
|
|
283
|
+
|
|
265
284
|
/**
|
|
266
285
|
* Upload user avatar
|
|
267
286
|
*
|
|
@@ -283,7 +302,7 @@ export class CfgAccountsProfile {
|
|
|
283
302
|
}
|
|
284
303
|
});
|
|
285
304
|
}
|
|
286
|
-
|
|
305
|
+
|
|
287
306
|
/**
|
|
288
307
|
* Delete user account
|
|
289
308
|
*
|
|
@@ -310,7 +329,7 @@ export class CfgAccountsProfile {
|
|
|
310
329
|
...options
|
|
311
330
|
});
|
|
312
331
|
}
|
|
313
|
-
|
|
332
|
+
|
|
314
333
|
/**
|
|
315
334
|
* Partial update user profile
|
|
316
335
|
*
|
|
@@ -331,7 +350,7 @@ export class CfgAccountsProfile {
|
|
|
331
350
|
}
|
|
332
351
|
});
|
|
333
352
|
}
|
|
334
|
-
|
|
353
|
+
|
|
335
354
|
/**
|
|
336
355
|
* Partial update user profile
|
|
337
356
|
*
|
|
@@ -352,7 +371,7 @@ export class CfgAccountsProfile {
|
|
|
352
371
|
}
|
|
353
372
|
});
|
|
354
373
|
}
|
|
355
|
-
|
|
374
|
+
|
|
356
375
|
/**
|
|
357
376
|
* Update user profile
|
|
358
377
|
*
|
|
@@ -373,7 +392,7 @@ export class CfgAccountsProfile {
|
|
|
373
392
|
}
|
|
374
393
|
});
|
|
375
394
|
}
|
|
376
|
-
|
|
395
|
+
|
|
377
396
|
/**
|
|
378
397
|
* Update user profile
|
|
379
398
|
*
|
|
@@ -414,7 +433,7 @@ export class CfgAccountsAuth {
|
|
|
414
433
|
}
|
|
415
434
|
});
|
|
416
435
|
}
|
|
417
|
-
|
|
436
|
+
|
|
418
437
|
/**
|
|
419
438
|
* Refresh JWT token.
|
|
420
439
|
*
|
|
@@ -470,7 +489,7 @@ export class CfgTotpBackupCodes {
|
|
|
470
489
|
...options
|
|
471
490
|
});
|
|
472
491
|
}
|
|
473
|
-
|
|
492
|
+
|
|
474
493
|
/**
|
|
475
494
|
* Regenerate backup codes.
|
|
476
495
|
*
|
|
@@ -509,7 +528,7 @@ export class CfgTotp {
|
|
|
509
528
|
...options
|
|
510
529
|
});
|
|
511
530
|
}
|
|
512
|
-
|
|
531
|
+
|
|
513
532
|
/**
|
|
514
533
|
* Delete a TOTP device.
|
|
515
534
|
*
|
|
@@ -526,7 +545,7 @@ export class CfgTotp {
|
|
|
526
545
|
...options
|
|
527
546
|
});
|
|
528
547
|
}
|
|
529
|
-
|
|
548
|
+
|
|
530
549
|
/**
|
|
531
550
|
* Completely disable 2FA for account.
|
|
532
551
|
*
|
|
@@ -570,7 +589,7 @@ export class CfgTotpSetup {
|
|
|
570
589
|
}
|
|
571
590
|
});
|
|
572
591
|
}
|
|
573
|
-
|
|
592
|
+
|
|
574
593
|
/**
|
|
575
594
|
* Confirm 2FA setup with first valid code.
|
|
576
595
|
*
|
|
@@ -614,7 +633,7 @@ export class CfgTotpVerify {
|
|
|
614
633
|
}
|
|
615
634
|
});
|
|
616
635
|
}
|
|
617
|
-
|
|
636
|
+
|
|
618
637
|
/**
|
|
619
638
|
* Verify backup recovery code for 2FA session.
|
|
620
639
|
*
|
|
@@ -251,6 +251,23 @@ export type ConnectionTokenResponse = {
|
|
|
251
251
|
channels: Array<string>;
|
|
252
252
|
};
|
|
253
253
|
|
|
254
|
+
/**
|
|
255
|
+
* Marketing-consent UI policy derived from the request's geo context.
|
|
256
|
+
*/
|
|
257
|
+
export type ConsentPolicy = {
|
|
258
|
+
/**
|
|
259
|
+
* Country code seen by the edge (CF-IPCountry), '' if unknown
|
|
260
|
+
*/
|
|
261
|
+
country: string;
|
|
262
|
+
/**
|
|
263
|
+
* Default state for the marketing-consent checkbox
|
|
264
|
+
*
|
|
265
|
+
* * `checked` - checked
|
|
266
|
+
* * `unchecked` - unchecked
|
|
267
|
+
*/
|
|
268
|
+
marketing_consent_default: MarketingConsentDefaultEnum;
|
|
269
|
+
};
|
|
270
|
+
|
|
254
271
|
/**
|
|
255
272
|
* Serializer for listing TOTP devices.
|
|
256
273
|
*/
|
|
@@ -305,6 +322,15 @@ export type DisableRequest = {
|
|
|
305
322
|
code: string;
|
|
306
323
|
};
|
|
307
324
|
|
|
325
|
+
/**
|
|
326
|
+
* * `checked` - checked
|
|
327
|
+
* * `unchecked` - unchecked
|
|
328
|
+
*/
|
|
329
|
+
export enum MarketingConsentDefaultEnum {
|
|
330
|
+
CHECKED = 'checked',
|
|
331
|
+
UNCHECKED = 'unchecked'
|
|
332
|
+
}
|
|
333
|
+
|
|
308
334
|
/**
|
|
309
335
|
* Request to start OAuth flow.
|
|
310
336
|
*/
|
|
@@ -520,6 +546,14 @@ export type OtpRequestRequest = {
|
|
|
520
546
|
* Source URL for tracking registration (e.g., https://my.djangocfg.com)
|
|
521
547
|
*/
|
|
522
548
|
source_url?: string;
|
|
549
|
+
/**
|
|
550
|
+
* Marketing-consent choice made at signup (absent/null = not asked, false = declined)
|
|
551
|
+
*/
|
|
552
|
+
marketing_consent?: boolean | null;
|
|
553
|
+
/**
|
|
554
|
+
* Version of the consent disclosure text shown (e.g. product-updates-reg-v1)
|
|
555
|
+
*/
|
|
556
|
+
consent_disclosure_version?: string;
|
|
523
557
|
};
|
|
524
558
|
|
|
525
559
|
/**
|
|
@@ -1198,6 +1232,19 @@ export type CfgAccountsOauthProvidersRetrieveResponses = {
|
|
|
1198
1232
|
|
|
1199
1233
|
export type CfgAccountsOauthProvidersRetrieveResponse = CfgAccountsOauthProvidersRetrieveResponses[keyof CfgAccountsOauthProvidersRetrieveResponses];
|
|
1200
1234
|
|
|
1235
|
+
export type CfgAccountsOtpConsentPolicyRetrieveData = {
|
|
1236
|
+
body?: never;
|
|
1237
|
+
path?: never;
|
|
1238
|
+
query?: never;
|
|
1239
|
+
url: '/cfg/accounts/otp/consent-policy/';
|
|
1240
|
+
};
|
|
1241
|
+
|
|
1242
|
+
export type CfgAccountsOtpConsentPolicyRetrieveResponses = {
|
|
1243
|
+
200: ConsentPolicy;
|
|
1244
|
+
};
|
|
1245
|
+
|
|
1246
|
+
export type CfgAccountsOtpConsentPolicyRetrieveResponse = CfgAccountsOtpConsentPolicyRetrieveResponses[keyof CfgAccountsOtpConsentPolicyRetrieveResponses];
|
|
1247
|
+
|
|
1201
1248
|
export type CfgAccountsOtpRequestCreateData = {
|
|
1202
1249
|
body: OtpRequestRequest;
|
|
1203
1250
|
path?: never;
|
|
@@ -40,7 +40,8 @@ import { authLogger } from '../utils/logger';
|
|
|
40
40
|
import { AccountsProvider, useAccountsContext } from './AccountsContext';
|
|
41
41
|
|
|
42
42
|
import type { AuthContextType, AuthProviderProps, UserProfile } from './types';
|
|
43
|
-
import type { OTPRequestResult } from '../types';
|
|
43
|
+
import type { OTPRequestConsent, OTPRequestResult } from '../types';
|
|
44
|
+
import type { OtpRequestRequest } from '../../_api/generated/_cfg_accounts/types.gen';
|
|
44
45
|
|
|
45
46
|
// The ONLY place route conventions are declared. '/auth' is the sign-in page
|
|
46
47
|
// convention; the framework has no opinion about where an app's "home" is, so
|
|
@@ -232,15 +233,22 @@ const AuthProviderInternal: React.FC<AuthProviderProps> = ({ children, config })
|
|
|
232
233
|
// ── OTP login flow ─────────────────────────────────────────────────────────
|
|
233
234
|
|
|
234
235
|
const requestOTP = useCallback(
|
|
235
|
-
async (identifier: string, sourceUrl?: string): Promise<OTPRequestResult> => {
|
|
236
|
+
async (identifier: string, sourceUrl?: string, consent?: OTPRequestConsent): Promise<OTPRequestResult> => {
|
|
236
237
|
// A login attempt invalidates whatever session was lying around.
|
|
237
238
|
auth.clearSession();
|
|
238
239
|
|
|
239
240
|
try {
|
|
240
|
-
const
|
|
241
|
+
const body: OtpRequestRequest = {
|
|
241
242
|
identifier,
|
|
242
243
|
source_url: sourceUrl,
|
|
243
|
-
|
|
244
|
+
// Absent when the consuming app didn't enable the opt-in checkbox —
|
|
245
|
+
// the backend treats absent/null as "not asked".
|
|
246
|
+
...(consent && {
|
|
247
|
+
marketing_consent: consent.marketingConsent,
|
|
248
|
+
consent_disclosure_version: consent.disclosureVersion,
|
|
249
|
+
}),
|
|
250
|
+
};
|
|
251
|
+
const result = await accountsRef.current.requestOTP(body);
|
|
244
252
|
|
|
245
253
|
Analytics.event(AnalyticsEvent.AUTH_OTP_REQUEST, {
|
|
246
254
|
category: AnalyticsCategory.AUTH,
|