@djangocfg/api 2.1.356 → 2.1.358
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/README.md +53 -632
- package/dist/auth-server.cjs +717 -200
- package/dist/auth-server.cjs.map +1 -1
- package/dist/auth-server.mjs +717 -200
- package/dist/auth-server.mjs.map +1 -1
- package/dist/auth.cjs +843 -783
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.d.cts +58 -37
- package/dist/auth.d.ts +58 -37
- package/dist/auth.mjs +846 -784
- package/dist/auth.mjs.map +1 -1
- package/dist/clients.cjs +1427 -0
- package/dist/clients.cjs.map +1 -1
- package/dist/clients.d.cts +1686 -0
- package/dist/clients.d.ts +1686 -0
- package/dist/clients.mjs +1427 -0
- package/dist/clients.mjs.map +1 -1
- package/dist/hooks.cjs +1277 -1924
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.d.cts +18 -1206
- package/dist/hooks.d.ts +18 -1206
- package/dist/hooks.mjs +1253 -1900
- package/dist/hooks.mjs.map +1 -1
- package/dist/index.cjs +545 -1232
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1389 -1455
- package/dist/index.d.ts +1389 -1455
- package/dist/index.mjs +545 -1232
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -2
- package/src/_api/generated/_cfg_accounts/api.ts +11 -3
- package/src/_api/generated/_cfg_accounts/hooks/index.ts +3 -0
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsApiKeyRegenerateCreate.ts +64 -0
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsApiKeyRetrieve.ts +65 -0
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsApiKeyTestCreate.ts +64 -0
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthConnectionsList.ts +43 -3
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthDisconnectCreate.ts +43 -3
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthGithubAuthorizeCreate.ts +43 -3
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthGithubCallbackCreate.ts +43 -3
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthProvidersRetrieve.ts +43 -3
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOtpRequestCreate.ts +43 -3
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOtpVerifyCreate.ts +43 -3
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileAvatarCreate.ts +43 -3
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileDeleteCreate.ts +43 -3
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfilePartialPartialUpdate.ts +43 -3
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfilePartialUpdate.ts +43 -3
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileRetrieve.ts +43 -3
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileUpdatePartialUpdate.ts +43 -3
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileUpdateUpdate.ts +43 -3
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsTokenRefreshCreate.ts +43 -3
- package/src/_api/generated/_cfg_accounts/index.ts +1 -1
- package/src/_api/generated/_cfg_accounts/schemas/APIKey.ts +13 -0
- package/src/_api/generated/_cfg_accounts/schemas/APIKeyRegenerate.ts +12 -0
- package/src/_api/generated/_cfg_accounts/schemas/APIKeyRequest.ts +13 -0
- package/src/_api/generated/{_cfg_totp/schemas/DeviceListStatusEnum.ts → _cfg_accounts/schemas/APIKeyTestRequest.ts} +4 -2
- package/src/_api/generated/_cfg_accounts/schemas/APIKeyTestResult.ts +12 -0
- package/src/_api/generated/_cfg_accounts/schemas/AccountDeleteResponse.ts +1 -1
- package/src/_api/generated/_cfg_accounts/schemas/CentrifugoToken.ts +2 -2
- package/src/_api/generated/_cfg_accounts/schemas/CfgUserUpdateRequest.ts +3 -2
- package/src/_api/generated/_cfg_accounts/schemas/OAuthCallbackRequestRequest.ts +1 -1
- package/src/_api/generated/_cfg_accounts/schemas/OAuthConnection.ts +6 -6
- package/src/_api/generated/_cfg_accounts/schemas/OAuthDisconnectRequestRequest.ts +2 -2
- package/src/_api/generated/_cfg_accounts/schemas/{ProviderEnum.ts → OAuthProviderEnum.ts} +2 -2
- package/src/_api/generated/_cfg_accounts/schemas/OAuthTokenResponse.ts +5 -5
- package/src/_api/generated/_cfg_accounts/schemas/OTPVerifyRequest.ts +1 -1
- package/src/_api/generated/_cfg_accounts/schemas/OTPVerifyResponse.ts +3 -3
- package/src/_api/generated/_cfg_accounts/schemas/PatchedCfgUserUpdateRequest.ts +3 -2
- package/src/_api/generated/_cfg_accounts/schemas/User.ts +12 -10
- package/src/_api/generated/_cfg_accounts/schemas/cfg_accounts_oauth_connections_response_200_AutoRef.ts +10 -0
- package/src/_api/generated/_cfg_accounts/schemas/cfg_accounts_oauth_disconnect_response_200_AutoRef.ts +11 -0
- package/src/_api/generated/_cfg_accounts/schemas/index.ts +8 -1
- package/src/_api/generated/_cfg_centrifugo/api.ts +3 -3
- package/src/_api/generated/_cfg_centrifugo/hooks/useCfgCentrifugoAuthTokenRetrieve.ts +43 -3
- package/src/_api/generated/_cfg_centrifugo/index.ts +1 -1
- package/src/_api/generated/_cfg_centrifugo/schemas/ConnectionTokenResponse.ts +2 -2
- package/src/_api/generated/_cfg_totp/api.ts +9 -3
- package/src/_api/generated/_cfg_totp/hooks/useCfgTotpBackupCodesRegenerateCreate.ts +43 -3
- package/src/_api/generated/_cfg_totp/hooks/useCfgTotpBackupCodesRetrieve.ts +43 -3
- package/src/_api/generated/_cfg_totp/hooks/useCfgTotpDevicesDestroy.ts +7 -3
- package/src/_api/generated/_cfg_totp/hooks/useCfgTotpDevicesRetrieve.ts +43 -3
- package/src/_api/generated/_cfg_totp/hooks/useCfgTotpDisableCreate.ts +43 -3
- package/src/_api/generated/_cfg_totp/hooks/useCfgTotpSetupConfirmCreate.ts +43 -3
- package/src/_api/generated/_cfg_totp/hooks/useCfgTotpSetupCreate.ts +43 -3
- package/src/_api/generated/_cfg_totp/hooks/useCfgTotpVerifyBackupCreate.ts +43 -3
- package/src/_api/generated/_cfg_totp/hooks/useCfgTotpVerifyCreate.ts +43 -3
- package/src/_api/generated/_cfg_totp/index.ts +1 -1
- package/src/_api/generated/_cfg_totp/schemas/ConfirmSetupRequest.ts +1 -1
- package/src/_api/generated/_cfg_totp/schemas/ConfirmSetupResponse.ts +1 -1
- package/src/_api/generated/_cfg_totp/schemas/DeviceList.ts +5 -5
- package/src/_api/generated/_cfg_totp/schemas/DeviceStatusEnum.ts +9 -0
- package/src/_api/generated/_cfg_totp/schemas/SetupResponse.ts +2 -2
- package/src/_api/generated/_cfg_totp/schemas/TotpVerifyUser.ts +11 -9
- package/src/_api/generated/_cfg_totp/schemas/VerifyBackupRequest.ts +1 -1
- package/src/_api/generated/_cfg_totp/schemas/VerifyRequest.ts +1 -1
- package/src/_api/generated/_cfg_totp/schemas/VerifyResponse.ts +2 -2
- package/src/_api/generated/_cfg_totp/schemas/cfg_totp_disable_response_200_AutoRef.ts +9 -0
- package/src/_api/generated/_cfg_totp/schemas/index.ts +2 -1
- package/src/_api/generated/index.ts +3 -1
- package/src/_api/generated/sdk.gen.ts +80 -813
- package/src/_api/generated/types.gen.ts +320 -159
- package/src/auth/context/AccountsContext.tsx +18 -6
- package/src/auth/context/AuthContext.tsx +11 -3
- package/src/auth/hooks/useDeleteAccount.ts +2 -2
- package/src/auth/hooks/useGithubAuth.ts +3 -3
- package/src/auth/hooks/useTokenRefresh.ts +2 -2
- package/src/auth/hooks/useTwoFactor.ts +3 -3
- package/src/auth/hooks/useTwoFactorSetup.ts +3 -3
- package/src/auth/hooks/useTwoFactorStatus.ts +3 -3
- package/src/auth/middlewares/tokenRefresh.ts +2 -2
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useApiKey.ts +73 -0
- package/src/index.ts +12 -16
- package/src/lib/env.ts +10 -0
|
@@ -1,11 +1,14 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
1
3
|
// AUTO-GENERATED by openapi_processor / ts.hooks
|
|
2
4
|
// POST /cfg/totp/disable/
|
|
3
5
|
// DO NOT EDIT — re-run `make gen`.
|
|
4
6
|
|
|
5
7
|
import useSWRMutation from "swr/mutation";
|
|
6
8
|
import type { SWRMutationConfiguration } from "swr/mutation";
|
|
7
|
-
import {
|
|
9
|
+
import { CfgTotp } from "../../sdk.gen";
|
|
8
10
|
import type { CfgTotpDisableCreateData, CfgTotpDisableCreateResponses } from "../../types.gen";
|
|
11
|
+
import { cfg_totp_disable_response_200_AutoRefSchema } from "../schemas/cfg_totp_disable_response_200_AutoRef";
|
|
9
12
|
|
|
10
13
|
type Args = Omit<CfgTotpDisableCreateData, "url">;
|
|
11
14
|
type Result = CfgTotpDisableCreateResponses[keyof CfgTotpDisableCreateResponses];
|
|
@@ -16,8 +19,45 @@ export function useCfgTotpDisableCreate(
|
|
|
16
19
|
return useSWRMutation<Result, Error, readonly ["cfg_totp_disable_create"], Args>(
|
|
17
20
|
["cfg_totp_disable_create"] as const,
|
|
18
21
|
async (_key, { arg }: { arg: Args }) => {
|
|
19
|
-
const res = await
|
|
20
|
-
|
|
22
|
+
const res = await CfgTotp.cfgTotpDisableCreate({ ...arg, throwOnError: true } as never);
|
|
23
|
+
const data = res.data as Result;
|
|
24
|
+
const parsed = cfg_totp_disable_response_200_AutoRefSchema.safeParse(data);
|
|
25
|
+
if (!parsed.success) {
|
|
26
|
+
// Log first so the failure is always visible, even if the
|
|
27
|
+
// event handler swallows it.
|
|
28
|
+
console.warn(
|
|
29
|
+
"[zod] response did not match schema",
|
|
30
|
+
{
|
|
31
|
+
operation: "cfg_totp_disable_create",
|
|
32
|
+
method: "POST",
|
|
33
|
+
path: "/cfg/totp/disable/",
|
|
34
|
+
issues: parsed.error.issues,
|
|
35
|
+
data,
|
|
36
|
+
},
|
|
37
|
+
);
|
|
38
|
+
if (typeof window !== "undefined") {
|
|
39
|
+
try {
|
|
40
|
+
window.dispatchEvent(
|
|
41
|
+
new CustomEvent("zod-validation-error", {
|
|
42
|
+
detail: {
|
|
43
|
+
operation: "cfg_totp_disable_create",
|
|
44
|
+
method: "POST",
|
|
45
|
+
path: "/cfg/totp/disable/",
|
|
46
|
+
issues: parsed.error.issues,
|
|
47
|
+
data,
|
|
48
|
+
timestamp: new Date(),
|
|
49
|
+
},
|
|
50
|
+
bubbles: true,
|
|
51
|
+
cancelable: false,
|
|
52
|
+
}),
|
|
53
|
+
);
|
|
54
|
+
} catch {
|
|
55
|
+
// Event dispatch is best-effort.
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return data;
|
|
59
|
+
}
|
|
60
|
+
return parsed.data as Result;
|
|
21
61
|
},
|
|
22
62
|
config,
|
|
23
63
|
);
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
1
3
|
// AUTO-GENERATED by openapi_processor / ts.hooks
|
|
2
4
|
// POST /cfg/totp/setup/confirm/
|
|
3
5
|
// DO NOT EDIT — re-run `make gen`.
|
|
4
6
|
|
|
5
7
|
import useSWRMutation from "swr/mutation";
|
|
6
8
|
import type { SWRMutationConfiguration } from "swr/mutation";
|
|
7
|
-
import {
|
|
9
|
+
import { CfgTotpSetup } from "../../sdk.gen";
|
|
8
10
|
import type { CfgTotpSetupConfirmCreateData, CfgTotpSetupConfirmCreateResponses } from "../../types.gen";
|
|
11
|
+
import { ConfirmSetupResponseSchema } from "../schemas/ConfirmSetupResponse";
|
|
9
12
|
|
|
10
13
|
type Args = Omit<CfgTotpSetupConfirmCreateData, "url">;
|
|
11
14
|
type Result = CfgTotpSetupConfirmCreateResponses[keyof CfgTotpSetupConfirmCreateResponses];
|
|
@@ -16,8 +19,45 @@ export function useCfgTotpSetupConfirmCreate(
|
|
|
16
19
|
return useSWRMutation<Result, Error, readonly ["cfg_totp_setup_confirm_create"], Args>(
|
|
17
20
|
["cfg_totp_setup_confirm_create"] as const,
|
|
18
21
|
async (_key, { arg }: { arg: Args }) => {
|
|
19
|
-
const res = await
|
|
20
|
-
|
|
22
|
+
const res = await CfgTotpSetup.cfgTotpSetupConfirmCreate({ ...arg, throwOnError: true } as never);
|
|
23
|
+
const data = res.data as Result;
|
|
24
|
+
const parsed = ConfirmSetupResponseSchema.safeParse(data);
|
|
25
|
+
if (!parsed.success) {
|
|
26
|
+
// Log first so the failure is always visible, even if the
|
|
27
|
+
// event handler swallows it.
|
|
28
|
+
console.warn(
|
|
29
|
+
"[zod] response did not match schema",
|
|
30
|
+
{
|
|
31
|
+
operation: "cfg_totp_setup_confirm_create",
|
|
32
|
+
method: "POST",
|
|
33
|
+
path: "/cfg/totp/setup/confirm/",
|
|
34
|
+
issues: parsed.error.issues,
|
|
35
|
+
data,
|
|
36
|
+
},
|
|
37
|
+
);
|
|
38
|
+
if (typeof window !== "undefined") {
|
|
39
|
+
try {
|
|
40
|
+
window.dispatchEvent(
|
|
41
|
+
new CustomEvent("zod-validation-error", {
|
|
42
|
+
detail: {
|
|
43
|
+
operation: "cfg_totp_setup_confirm_create",
|
|
44
|
+
method: "POST",
|
|
45
|
+
path: "/cfg/totp/setup/confirm/",
|
|
46
|
+
issues: parsed.error.issues,
|
|
47
|
+
data,
|
|
48
|
+
timestamp: new Date(),
|
|
49
|
+
},
|
|
50
|
+
bubbles: true,
|
|
51
|
+
cancelable: false,
|
|
52
|
+
}),
|
|
53
|
+
);
|
|
54
|
+
} catch {
|
|
55
|
+
// Event dispatch is best-effort.
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return data;
|
|
59
|
+
}
|
|
60
|
+
return parsed.data as Result;
|
|
21
61
|
},
|
|
22
62
|
config,
|
|
23
63
|
);
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
1
3
|
// AUTO-GENERATED by openapi_processor / ts.hooks
|
|
2
4
|
// POST /cfg/totp/setup/
|
|
3
5
|
// DO NOT EDIT — re-run `make gen`.
|
|
4
6
|
|
|
5
7
|
import useSWRMutation from "swr/mutation";
|
|
6
8
|
import type { SWRMutationConfiguration } from "swr/mutation";
|
|
7
|
-
import {
|
|
9
|
+
import { CfgTotpSetup } from "../../sdk.gen";
|
|
8
10
|
import type { CfgTotpSetupCreateData, CfgTotpSetupCreateResponses } from "../../types.gen";
|
|
11
|
+
import { SetupResponseSchema } from "../schemas/SetupResponse";
|
|
9
12
|
|
|
10
13
|
type Args = Omit<CfgTotpSetupCreateData, "url">;
|
|
11
14
|
type Result = CfgTotpSetupCreateResponses[keyof CfgTotpSetupCreateResponses];
|
|
@@ -16,8 +19,45 @@ export function useCfgTotpSetupCreate(
|
|
|
16
19
|
return useSWRMutation<Result, Error, readonly ["cfg_totp_setup_create"], Args>(
|
|
17
20
|
["cfg_totp_setup_create"] as const,
|
|
18
21
|
async (_key, { arg }: { arg: Args }) => {
|
|
19
|
-
const res = await
|
|
20
|
-
|
|
22
|
+
const res = await CfgTotpSetup.cfgTotpSetupCreate({ ...arg, throwOnError: true } as never);
|
|
23
|
+
const data = res.data as Result;
|
|
24
|
+
const parsed = SetupResponseSchema.safeParse(data);
|
|
25
|
+
if (!parsed.success) {
|
|
26
|
+
// Log first so the failure is always visible, even if the
|
|
27
|
+
// event handler swallows it.
|
|
28
|
+
console.warn(
|
|
29
|
+
"[zod] response did not match schema",
|
|
30
|
+
{
|
|
31
|
+
operation: "cfg_totp_setup_create",
|
|
32
|
+
method: "POST",
|
|
33
|
+
path: "/cfg/totp/setup/",
|
|
34
|
+
issues: parsed.error.issues,
|
|
35
|
+
data,
|
|
36
|
+
},
|
|
37
|
+
);
|
|
38
|
+
if (typeof window !== "undefined") {
|
|
39
|
+
try {
|
|
40
|
+
window.dispatchEvent(
|
|
41
|
+
new CustomEvent("zod-validation-error", {
|
|
42
|
+
detail: {
|
|
43
|
+
operation: "cfg_totp_setup_create",
|
|
44
|
+
method: "POST",
|
|
45
|
+
path: "/cfg/totp/setup/",
|
|
46
|
+
issues: parsed.error.issues,
|
|
47
|
+
data,
|
|
48
|
+
timestamp: new Date(),
|
|
49
|
+
},
|
|
50
|
+
bubbles: true,
|
|
51
|
+
cancelable: false,
|
|
52
|
+
}),
|
|
53
|
+
);
|
|
54
|
+
} catch {
|
|
55
|
+
// Event dispatch is best-effort.
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return data;
|
|
59
|
+
}
|
|
60
|
+
return parsed.data as Result;
|
|
21
61
|
},
|
|
22
62
|
config,
|
|
23
63
|
);
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
1
3
|
// AUTO-GENERATED by openapi_processor / ts.hooks
|
|
2
4
|
// POST /cfg/totp/verify/backup/
|
|
3
5
|
// DO NOT EDIT — re-run `make gen`.
|
|
4
6
|
|
|
5
7
|
import useSWRMutation from "swr/mutation";
|
|
6
8
|
import type { SWRMutationConfiguration } from "swr/mutation";
|
|
7
|
-
import {
|
|
9
|
+
import { CfgTotpVerify } from "../../sdk.gen";
|
|
8
10
|
import type { CfgTotpVerifyBackupCreateData, CfgTotpVerifyBackupCreateResponses } from "../../types.gen";
|
|
11
|
+
import { VerifyResponseSchema } from "../schemas/VerifyResponse";
|
|
9
12
|
|
|
10
13
|
type Args = Omit<CfgTotpVerifyBackupCreateData, "url">;
|
|
11
14
|
type Result = CfgTotpVerifyBackupCreateResponses[keyof CfgTotpVerifyBackupCreateResponses];
|
|
@@ -16,8 +19,45 @@ export function useCfgTotpVerifyBackupCreate(
|
|
|
16
19
|
return useSWRMutation<Result, Error, readonly ["cfg_totp_verify_backup_create"], Args>(
|
|
17
20
|
["cfg_totp_verify_backup_create"] as const,
|
|
18
21
|
async (_key, { arg }: { arg: Args }) => {
|
|
19
|
-
const res = await
|
|
20
|
-
|
|
22
|
+
const res = await CfgTotpVerify.cfgTotpVerifyBackupCreate({ ...arg, throwOnError: true } as never);
|
|
23
|
+
const data = res.data as Result;
|
|
24
|
+
const parsed = VerifyResponseSchema.safeParse(data);
|
|
25
|
+
if (!parsed.success) {
|
|
26
|
+
// Log first so the failure is always visible, even if the
|
|
27
|
+
// event handler swallows it.
|
|
28
|
+
console.warn(
|
|
29
|
+
"[zod] response did not match schema",
|
|
30
|
+
{
|
|
31
|
+
operation: "cfg_totp_verify_backup_create",
|
|
32
|
+
method: "POST",
|
|
33
|
+
path: "/cfg/totp/verify/backup/",
|
|
34
|
+
issues: parsed.error.issues,
|
|
35
|
+
data,
|
|
36
|
+
},
|
|
37
|
+
);
|
|
38
|
+
if (typeof window !== "undefined") {
|
|
39
|
+
try {
|
|
40
|
+
window.dispatchEvent(
|
|
41
|
+
new CustomEvent("zod-validation-error", {
|
|
42
|
+
detail: {
|
|
43
|
+
operation: "cfg_totp_verify_backup_create",
|
|
44
|
+
method: "POST",
|
|
45
|
+
path: "/cfg/totp/verify/backup/",
|
|
46
|
+
issues: parsed.error.issues,
|
|
47
|
+
data,
|
|
48
|
+
timestamp: new Date(),
|
|
49
|
+
},
|
|
50
|
+
bubbles: true,
|
|
51
|
+
cancelable: false,
|
|
52
|
+
}),
|
|
53
|
+
);
|
|
54
|
+
} catch {
|
|
55
|
+
// Event dispatch is best-effort.
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return data;
|
|
59
|
+
}
|
|
60
|
+
return parsed.data as Result;
|
|
21
61
|
},
|
|
22
62
|
config,
|
|
23
63
|
);
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
1
3
|
// AUTO-GENERATED by openapi_processor / ts.hooks
|
|
2
4
|
// POST /cfg/totp/verify/
|
|
3
5
|
// DO NOT EDIT — re-run `make gen`.
|
|
4
6
|
|
|
5
7
|
import useSWRMutation from "swr/mutation";
|
|
6
8
|
import type { SWRMutationConfiguration } from "swr/mutation";
|
|
7
|
-
import {
|
|
9
|
+
import { CfgTotpVerify } from "../../sdk.gen";
|
|
8
10
|
import type { CfgTotpVerifyCreateData, CfgTotpVerifyCreateResponses } from "../../types.gen";
|
|
11
|
+
import { VerifyResponseSchema } from "../schemas/VerifyResponse";
|
|
9
12
|
|
|
10
13
|
type Args = Omit<CfgTotpVerifyCreateData, "url">;
|
|
11
14
|
type Result = CfgTotpVerifyCreateResponses[keyof CfgTotpVerifyCreateResponses];
|
|
@@ -16,8 +19,45 @@ export function useCfgTotpVerifyCreate(
|
|
|
16
19
|
return useSWRMutation<Result, Error, readonly ["cfg_totp_verify_create"], Args>(
|
|
17
20
|
["cfg_totp_verify_create"] as const,
|
|
18
21
|
async (_key, { arg }: { arg: Args }) => {
|
|
19
|
-
const res = await
|
|
20
|
-
|
|
22
|
+
const res = await CfgTotpVerify.cfgTotpVerifyCreate({ ...arg, throwOnError: true } as never);
|
|
23
|
+
const data = res.data as Result;
|
|
24
|
+
const parsed = VerifyResponseSchema.safeParse(data);
|
|
25
|
+
if (!parsed.success) {
|
|
26
|
+
// Log first so the failure is always visible, even if the
|
|
27
|
+
// event handler swallows it.
|
|
28
|
+
console.warn(
|
|
29
|
+
"[zod] response did not match schema",
|
|
30
|
+
{
|
|
31
|
+
operation: "cfg_totp_verify_create",
|
|
32
|
+
method: "POST",
|
|
33
|
+
path: "/cfg/totp/verify/",
|
|
34
|
+
issues: parsed.error.issues,
|
|
35
|
+
data,
|
|
36
|
+
},
|
|
37
|
+
);
|
|
38
|
+
if (typeof window !== "undefined") {
|
|
39
|
+
try {
|
|
40
|
+
window.dispatchEvent(
|
|
41
|
+
new CustomEvent("zod-validation-error", {
|
|
42
|
+
detail: {
|
|
43
|
+
operation: "cfg_totp_verify_create",
|
|
44
|
+
method: "POST",
|
|
45
|
+
path: "/cfg/totp/verify/",
|
|
46
|
+
issues: parsed.error.issues,
|
|
47
|
+
data,
|
|
48
|
+
timestamp: new Date(),
|
|
49
|
+
},
|
|
50
|
+
bubbles: true,
|
|
51
|
+
cancelable: false,
|
|
52
|
+
}),
|
|
53
|
+
);
|
|
54
|
+
} catch {
|
|
55
|
+
// Event dispatch is best-effort.
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return data;
|
|
59
|
+
}
|
|
60
|
+
return parsed.data as Result;
|
|
21
61
|
},
|
|
22
62
|
config,
|
|
23
63
|
);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Group barrel. DO NOT EDIT — re-run `make gen`.
|
|
3
3
|
|
|
4
4
|
// Wrapper class + per-group SDK re-exports + global auth.
|
|
5
|
-
export { API, type APIOptions, auth,
|
|
5
|
+
export { API, type APIOptions, auth, CfgTotpBackupCodes, CfgTotp, CfgTotpSetup, CfgTotpVerify } from './api';
|
|
6
6
|
|
|
7
7
|
// Shared utilities.
|
|
8
8
|
export {
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
import { z } from "zod";
|
|
6
6
|
|
|
7
7
|
export const ConfirmSetupRequestSchema = z.object({
|
|
8
|
-
code: z.string().min(6).max(6),
|
|
9
8
|
device_id: z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
|
|
9
|
+
code: z.string().min(6).max(6),
|
|
10
10
|
});
|
|
11
11
|
|
|
12
12
|
export type ConfirmSetupRequest = z.infer<typeof ConfirmSetupRequestSchema>;
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
import { z } from "zod";
|
|
6
6
|
|
|
7
7
|
export const ConfirmSetupResponseSchema = z.object({
|
|
8
|
+
message: z.string(),
|
|
8
9
|
backup_codes: z.array(z.string()),
|
|
9
10
|
backup_codes_warning: z.string(),
|
|
10
|
-
message: z.string(),
|
|
11
11
|
});
|
|
12
12
|
|
|
13
13
|
export type ConfirmSetupResponse = z.infer<typeof ConfirmSetupResponseSchema>;
|
|
@@ -3,16 +3,16 @@
|
|
|
3
3
|
// DO NOT EDIT — re-run `make gen-clients`.
|
|
4
4
|
|
|
5
5
|
import { z } from "zod";
|
|
6
|
-
import {
|
|
6
|
+
import { DeviceStatusEnumSchema } from "./DeviceStatusEnum";
|
|
7
7
|
|
|
8
8
|
export const DeviceListSchema = z.object({
|
|
9
|
-
confirmed_at: z.string().datetime({ offset: true }).nullable(),
|
|
10
|
-
created_at: z.string().datetime({ offset: true }),
|
|
11
9
|
id: z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
|
|
10
|
+
name: z.string(),
|
|
12
11
|
is_primary: z.boolean(),
|
|
12
|
+
status: DeviceStatusEnumSchema,
|
|
13
|
+
created_at: z.string().datetime({ offset: true }),
|
|
14
|
+
confirmed_at: z.string().datetime({ offset: true }).nullable(),
|
|
13
15
|
last_used_at: z.string().datetime({ offset: true }).nullable(),
|
|
14
|
-
name: z.string(),
|
|
15
|
-
status: DeviceListStatusEnumSchema,
|
|
16
16
|
});
|
|
17
17
|
|
|
18
18
|
export type DeviceList = z.infer<typeof DeviceListSchema>;
|
|
@@ -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 DeviceStatusEnumSchema = z.enum(["pending", "active", "disabled"]);
|
|
8
|
+
|
|
9
|
+
export type DeviceStatusEnum = z.infer<typeof DeviceStatusEnumSchema>;
|
|
@@ -6,10 +6,10 @@ import { z } from "zod";
|
|
|
6
6
|
|
|
7
7
|
export const SetupResponseSchema = z.object({
|
|
8
8
|
device_id: z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
|
|
9
|
-
|
|
9
|
+
secret: z.string(),
|
|
10
10
|
provisioning_uri: z.string(),
|
|
11
11
|
qr_code_base64: z.string(),
|
|
12
|
-
|
|
12
|
+
expires_in: z.number().int(),
|
|
13
13
|
});
|
|
14
14
|
|
|
15
15
|
export type SetupResponse = z.infer<typeof SetupResponseSchema>;
|
|
@@ -5,23 +5,25 @@
|
|
|
5
5
|
import { z } from "zod";
|
|
6
6
|
|
|
7
7
|
export const TotpVerifyUserSchema = z.object({
|
|
8
|
-
|
|
9
|
-
company: z.string().max(100).optional(),
|
|
10
|
-
date_joined: z.string().datetime({ offset: true }),
|
|
11
|
-
display_username: z.string(),
|
|
8
|
+
id: z.number().int(),
|
|
12
9
|
email: z.email(),
|
|
13
10
|
first_name: z.string().max(50).optional(),
|
|
11
|
+
last_name: z.string().max(50).optional(),
|
|
14
12
|
full_name: z.string(),
|
|
15
|
-
id: z.number().int(),
|
|
16
13
|
initials: z.string(),
|
|
14
|
+
display_username: z.string(),
|
|
15
|
+
company: z.string().max(100).optional(),
|
|
16
|
+
phone: z.string().max(20).optional(),
|
|
17
|
+
position: z.string().max(100).optional(),
|
|
18
|
+
language: z.string().max(10).optional(),
|
|
19
|
+
timezone: z.string().max(64).optional(),
|
|
20
|
+
avatar: z.string().nullable(),
|
|
17
21
|
is_staff: z.boolean(),
|
|
18
22
|
is_superuser: z.boolean(),
|
|
19
|
-
|
|
23
|
+
date_joined: z.string().datetime({ offset: true }),
|
|
20
24
|
last_login: z.string().datetime({ offset: true }).nullable(),
|
|
21
|
-
last_name: z.string().max(50).optional(),
|
|
22
|
-
phone: z.string().max(20).optional(),
|
|
23
|
-
position: z.string().max(100).optional(),
|
|
24
25
|
unanswered_messages_count: z.number().int().default(0),
|
|
26
|
+
api_key: z.string().nullable(),
|
|
25
27
|
});
|
|
26
28
|
|
|
27
29
|
export type TotpVerifyUser = z.infer<typeof TotpVerifyUserSchema>;
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
import { z } from "zod";
|
|
6
6
|
|
|
7
7
|
export const VerifyBackupRequestSchema = z.object({
|
|
8
|
-
backup_code: z.string().min(8).max(8),
|
|
9
8
|
session_id: z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
|
|
9
|
+
backup_code: z.string().min(8).max(8),
|
|
10
10
|
});
|
|
11
11
|
|
|
12
12
|
export type VerifyBackupRequest = z.infer<typeof VerifyBackupRequestSchema>;
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
import { z } from "zod";
|
|
6
6
|
|
|
7
7
|
export const VerifyRequestSchema = z.object({
|
|
8
|
-
code: z.string().min(6).max(6),
|
|
9
8
|
session_id: z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
|
|
9
|
+
code: z.string().min(6).max(6),
|
|
10
10
|
});
|
|
11
11
|
|
|
12
12
|
export type VerifyRequest = z.infer<typeof VerifyRequestSchema>;
|
|
@@ -6,11 +6,11 @@ import { z } from "zod";
|
|
|
6
6
|
import { TotpVerifyUserSchema } from "./TotpVerifyUser";
|
|
7
7
|
|
|
8
8
|
export const VerifyResponseSchema = z.object({
|
|
9
|
-
access_token: z.string(),
|
|
10
9
|
message: z.string(),
|
|
10
|
+
access_token: z.string(),
|
|
11
11
|
refresh_token: z.string(),
|
|
12
|
-
remaining_backup_codes: z.number().int().optional(),
|
|
13
12
|
user: TotpVerifyUserSchema,
|
|
13
|
+
remaining_backup_codes: z.number().int().optional(),
|
|
14
14
|
warning: z.string().optional(),
|
|
15
15
|
});
|
|
16
16
|
|
|
@@ -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 cfg_totp_disable_response_200_AutoRefSchema = z.unknown();
|
|
8
|
+
|
|
9
|
+
export type cfg_totp_disable_response_200_AutoRef = z.infer<typeof cfg_totp_disable_response_200_AutoRefSchema>;
|
|
@@ -8,7 +8,7 @@ export * from "./ConfirmSetupRequest";
|
|
|
8
8
|
export * from "./ConfirmSetupResponse";
|
|
9
9
|
export * from "./DeviceList";
|
|
10
10
|
export * from "./DeviceListResponse";
|
|
11
|
-
export * from "./
|
|
11
|
+
export * from "./DeviceStatusEnum";
|
|
12
12
|
export * from "./DisableRequest";
|
|
13
13
|
export * from "./SetupRequest";
|
|
14
14
|
export * from "./SetupResponse";
|
|
@@ -16,3 +16,4 @@ export * from "./TotpVerifyUser";
|
|
|
16
16
|
export * from "./VerifyBackupRequest";
|
|
17
17
|
export * from "./VerifyRequest";
|
|
18
18
|
export * from "./VerifyResponse";
|
|
19
|
+
export * from "./cfg_totp_disable_response_200_AutoRef";
|
|
@@ -33,7 +33,9 @@ export { API as CfgTotpAPI } from './_cfg_totp';
|
|
|
33
33
|
// available via the per-group import: `import { Auth } from
|
|
34
34
|
// '<api>/_auth'`. To remove the alias, rename the OpenAPI tag on the
|
|
35
35
|
// backend so the SDK class doesn't collide.
|
|
36
|
-
|
|
36
|
+
export { CfgAccountsApiKey, CfgAccountsOauth, CfgAccounts, CfgAccountsProfile, CfgAccountsAuth } from './_cfg_accounts';
|
|
37
|
+
export { CfgCentrifugo } from './_cfg_centrifugo';
|
|
38
|
+
export { CfgTotpBackupCodes, CfgTotp, CfgTotpSetup, CfgTotpVerify } from './_cfg_totp';
|
|
37
39
|
|
|
38
40
|
// Shared utilities (errors, storage adapters, logger).
|
|
39
41
|
export * from './helpers';
|