@djangocfg/api 2.1.261 → 2.1.263
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-server.cjs +9 -0
- package/dist/auth-server.cjs.map +1 -1
- package/dist/auth-server.mjs +9 -0
- package/dist/auth-server.mjs.map +1 -1
- package/dist/auth.cjs +27 -0
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.mjs +27 -0
- package/dist/auth.mjs.map +1 -1
- package/dist/clients.cjs +65 -1
- package/dist/clients.cjs.map +1 -1
- package/dist/clients.d.cts +145 -122
- package/dist/clients.d.ts +145 -122
- package/dist/clients.mjs +65 -1
- package/dist/clients.mjs.map +1 -1
- package/dist/hooks.cjs +47 -1
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.d.cts +91 -68
- package/dist/hooks.d.ts +91 -68
- package/dist/hooks.mjs +47 -1
- package/dist/hooks.mjs.map +1 -1
- package/dist/index.cjs +56 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +89 -89
- package/dist/index.d.ts +89 -89
- package/dist/index.mjs +56 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/_api/generated/cfg_accounts/_utils/fetchers/accounts__oauth.ts +46 -2
- package/src/_api/generated/cfg_accounts/_utils/hooks/accounts__oauth.ts +3 -2
- package/src/_api/generated/cfg_accounts/accounts/models.ts +12 -12
- package/src/_api/generated/cfg_accounts/accounts__oauth/client.ts +1 -1
- package/src/_api/generated/cfg_accounts/accounts__oauth/models.ts +55 -55
- package/src/_api/generated/cfg_accounts/accounts__user_profile/models.ts +23 -23
- package/src/_api/generated/cfg_accounts/client.ts +8 -0
- package/src/_api/generated/cfg_accounts/errors.ts +5 -0
- package/src/_api/generated/cfg_centrifugo/client.ts +8 -0
- package/src/_api/generated/cfg_centrifugo/errors.ts +5 -0
- package/src/_api/generated/cfg_totp/client.ts +8 -0
- package/src/_api/generated/cfg_totp/errors.ts +5 -0
- package/src/_api/generated/cfg_totp/totp__backup_codes/models.ts +14 -14
- package/src/_api/generated/cfg_totp/totp__totp_management/models.ts +10 -10
- package/src/_api/generated/cfg_totp/totp__totp_setup/models.ts +25 -25
- package/src/_api/generated/cfg_totp/totp__totp_verification/models.ts +8 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@djangocfg/api",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.263",
|
|
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
|
"devDependencies": {
|
|
85
85
|
"@types/node": "^24.7.2",
|
|
86
86
|
"@types/react": "^19.1.0",
|
|
87
|
-
"@djangocfg/typescript-config": "^2.1.
|
|
87
|
+
"@djangocfg/typescript-config": "^2.1.263",
|
|
88
88
|
"next": "^16.0.10",
|
|
89
89
|
"react": "^19.1.0",
|
|
90
90
|
"tsup": "^8.5.0",
|
|
@@ -35,6 +35,7 @@ import { consola } from 'consola'
|
|
|
35
35
|
import { OAuthAuthorizeRequestRequestSchema, type OAuthAuthorizeRequestRequest } from '../schemas/OAuthAuthorizeRequestRequest.schema'
|
|
36
36
|
import { OAuthAuthorizeResponseSchema, type OAuthAuthorizeResponse } from '../schemas/OAuthAuthorizeResponse.schema'
|
|
37
37
|
import { OAuthCallbackRequestRequestSchema, type OAuthCallbackRequestRequest } from '../schemas/OAuthCallbackRequestRequest.schema'
|
|
38
|
+
import { OAuthConnectionSchema, type OAuthConnection } from '../schemas/OAuthConnection.schema'
|
|
38
39
|
import { OAuthDisconnectRequestRequestSchema, type OAuthDisconnectRequestRequest } from '../schemas/OAuthDisconnectRequestRequest.schema'
|
|
39
40
|
import { OAuthProvidersResponseSchema, type OAuthProvidersResponse } from '../schemas/OAuthProvidersResponse.schema'
|
|
40
41
|
import { OAuthTokenResponseSchema, type OAuthTokenResponse } from '../schemas/OAuthTokenResponse.schema'
|
|
@@ -47,10 +48,53 @@ import { getAPIInstance } from '../../api-instance'
|
|
|
47
48
|
* @path /cfg/accounts/oauth/connections/
|
|
48
49
|
*/
|
|
49
50
|
export async function getAccountsOauthConnectionsList( client?: any
|
|
50
|
-
): Promise<
|
|
51
|
+
): Promise<OAuthConnection[]> {
|
|
51
52
|
const api = client || getAPIInstance()
|
|
52
53
|
const response = await api.oauth.accountsOauthConnectionsList()
|
|
53
|
-
|
|
54
|
+
try {
|
|
55
|
+
return OAuthConnectionSchema.array().parse(response)
|
|
56
|
+
} catch (error) {
|
|
57
|
+
// Zod validation error - log detailed information
|
|
58
|
+
consola.error('❌ Zod Validation Failed');
|
|
59
|
+
consola.box(`getAccountsOauthConnectionsList\nPath: /cfg/accounts/oauth/connections/\nMethod: GET`);
|
|
60
|
+
|
|
61
|
+
if (error instanceof Error && 'issues' in error && Array.isArray((error as any).issues)) {
|
|
62
|
+
consola.error('Validation Issues:');
|
|
63
|
+
(error as any).issues.forEach((issue: any, index: number) => {
|
|
64
|
+
consola.error(` ${index + 1}. ${issue.path.join('.') || 'root'}`);
|
|
65
|
+
consola.error(` ├─ Message: ${issue.message}`);
|
|
66
|
+
if (issue.expected) consola.error(` ├─ Expected: ${issue.expected}`);
|
|
67
|
+
if (issue.received) consola.error(` └─ Received: ${issue.received}`);
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
consola.error('Response data:', response);
|
|
72
|
+
|
|
73
|
+
// Dispatch browser CustomEvent (only if window is defined)
|
|
74
|
+
if (typeof window !== 'undefined' && error instanceof Error && 'issues' in error) {
|
|
75
|
+
try {
|
|
76
|
+
const event = new CustomEvent('zod-validation-error', {
|
|
77
|
+
detail: {
|
|
78
|
+
operation: 'getAccountsOauthConnectionsList',
|
|
79
|
+
path: '/cfg/accounts/oauth/connections/',
|
|
80
|
+
method: 'GET',
|
|
81
|
+
error: error,
|
|
82
|
+
response: response,
|
|
83
|
+
timestamp: new Date(),
|
|
84
|
+
},
|
|
85
|
+
bubbles: true,
|
|
86
|
+
cancelable: false,
|
|
87
|
+
});
|
|
88
|
+
window.dispatchEvent(event);
|
|
89
|
+
} catch (eventError) {
|
|
90
|
+
// Silently fail - event dispatch should never crash the app
|
|
91
|
+
consola.warn('Failed to dispatch validation error event:', eventError);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Re-throw the error
|
|
96
|
+
throw error;
|
|
97
|
+
}
|
|
54
98
|
}
|
|
55
99
|
|
|
56
100
|
|
|
@@ -25,6 +25,7 @@ import type { API } from '../../index'
|
|
|
25
25
|
import type { OAuthAuthorizeRequestRequest } from '../schemas/OAuthAuthorizeRequestRequest.schema'
|
|
26
26
|
import type { OAuthAuthorizeResponse } from '../schemas/OAuthAuthorizeResponse.schema'
|
|
27
27
|
import type { OAuthCallbackRequestRequest } from '../schemas/OAuthCallbackRequestRequest.schema'
|
|
28
|
+
import type { OAuthConnection } from '../schemas/OAuthConnection.schema'
|
|
28
29
|
import type { OAuthDisconnectRequestRequest } from '../schemas/OAuthDisconnectRequestRequest.schema'
|
|
29
30
|
import type { OAuthProvidersResponse } from '../schemas/OAuthProvidersResponse.schema'
|
|
30
31
|
import type { OAuthTokenResponse } from '../schemas/OAuthTokenResponse.schema'
|
|
@@ -35,8 +36,8 @@ import type { OAuthTokenResponse } from '../schemas/OAuthTokenResponse.schema'
|
|
|
35
36
|
* @method GET
|
|
36
37
|
* @path /cfg/accounts/oauth/connections/
|
|
37
38
|
*/
|
|
38
|
-
export function useAccountsOauthConnectionsList(client?: API): ReturnType<typeof useSWR<
|
|
39
|
-
return useSWR<
|
|
39
|
+
export function useAccountsOauthConnectionsList(client?: API): ReturnType<typeof useSWR<OAuthConnection[]>> {
|
|
40
|
+
return useSWR<OAuthConnection[]>(
|
|
40
41
|
'cfg-accounts-oauth-connections',
|
|
41
42
|
() => Fetchers.getAccountsOauthConnectionsList(client)
|
|
42
43
|
)
|
|
@@ -44,18 +44,6 @@ export interface OTPErrorResponse {
|
|
|
44
44
|
retry_after?: number | null;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
/**
|
|
48
|
-
* Serializer for OTP request.
|
|
49
|
-
*
|
|
50
|
-
* Request model (no read-only fields).
|
|
51
|
-
*/
|
|
52
|
-
export interface OTPRequestRequest {
|
|
53
|
-
/** Email address for OTP delivery */
|
|
54
|
-
identifier: string;
|
|
55
|
-
/** Source URL for tracking registration (e.g., https://my.djangocfg.com) */
|
|
56
|
-
source_url?: string;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
47
|
/**
|
|
60
48
|
* OTP verification response. When 2FA is required: - requires_2fa: True -
|
|
61
49
|
* session_id: UUID of 2FA verification session - refresh/access/user: null
|
|
@@ -78,6 +66,18 @@ export interface OTPVerifyResponse {
|
|
|
78
66
|
should_prompt_2fa?: boolean;
|
|
79
67
|
}
|
|
80
68
|
|
|
69
|
+
/**
|
|
70
|
+
* Serializer for OTP request.
|
|
71
|
+
*
|
|
72
|
+
* Request model (no read-only fields).
|
|
73
|
+
*/
|
|
74
|
+
export interface OTPRequestRequest {
|
|
75
|
+
/** Email address for OTP delivery */
|
|
76
|
+
identifier: string;
|
|
77
|
+
/** Source URL for tracking registration (e.g., https://my.djangocfg.com) */
|
|
78
|
+
source_url?: string;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
81
|
/**
|
|
82
82
|
* Serializer for user details.
|
|
83
83
|
*
|
|
@@ -17,7 +17,7 @@ export class Oauth {
|
|
|
17
17
|
*
|
|
18
18
|
* Get all OAuth connections for the current user.
|
|
19
19
|
*/
|
|
20
|
-
async accountsOauthConnectionsList(): Promise<
|
|
20
|
+
async accountsOauthConnectionsList(): Promise<Models.OAuthConnection[]> {
|
|
21
21
|
const response = await this.client.request('GET', "/cfg/accounts/oauth/connections/");
|
|
22
22
|
return (response as any).results || response;
|
|
23
23
|
}
|
|
@@ -3,13 +3,15 @@
|
|
|
3
3
|
import * as Enums from "../enums";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Request to start OAuth flow.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
8
|
+
* Request model (no read-only fields).
|
|
9
9
|
*/
|
|
10
|
-
export interface
|
|
11
|
-
/**
|
|
12
|
-
|
|
10
|
+
export interface OAuthAuthorizeRequestRequest {
|
|
11
|
+
/** URL to redirect after OAuth authorization. If not provided, uses config's site_url + callback_path */
|
|
12
|
+
redirect_uri?: string;
|
|
13
|
+
/** Optional source URL for registration tracking */
|
|
14
|
+
source_url?: string;
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
/**
|
|
@@ -25,54 +27,39 @@ export interface OAuthDisconnectRequestRequest {
|
|
|
25
27
|
}
|
|
26
28
|
|
|
27
29
|
/**
|
|
28
|
-
*
|
|
30
|
+
* Request to complete OAuth flow (callback handler).
|
|
29
31
|
*
|
|
30
|
-
*
|
|
32
|
+
* Request model (no read-only fields).
|
|
31
33
|
*/
|
|
32
|
-
export interface
|
|
33
|
-
/**
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
|
|
34
|
+
export interface OAuthCallbackRequestRequest {
|
|
35
|
+
/** Authorization code from OAuth provider callback */
|
|
36
|
+
code: string;
|
|
37
|
+
/** State token for CSRF verification (from authorize response) */
|
|
38
|
+
state: string;
|
|
39
|
+
/** Same redirect_uri used in authorize request. If not provided, uses config's site_url + callback_path */
|
|
40
|
+
redirect_uri?: string;
|
|
37
41
|
}
|
|
38
42
|
|
|
39
43
|
/**
|
|
40
|
-
*
|
|
44
|
+
* Response with OAuth authorization URL.
|
|
41
45
|
*
|
|
42
|
-
*
|
|
46
|
+
* Response model (includes read-only fields).
|
|
43
47
|
*/
|
|
44
|
-
export interface
|
|
45
|
-
/** URL to redirect
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
|
|
48
|
+
export interface OAuthAuthorizeResponse {
|
|
49
|
+
/** Full URL to redirect user to OAuth provider */
|
|
50
|
+
authorization_url: string;
|
|
51
|
+
/** State token for CSRF protection. Store this and verify on callback. */
|
|
52
|
+
state: string;
|
|
49
53
|
}
|
|
50
54
|
|
|
51
55
|
/**
|
|
52
|
-
* Response with
|
|
53
|
-
* requires_2fa: True - session_id: UUID of 2FA verification session -
|
|
54
|
-
* access/refresh/user: null When 2FA is not required: - requires_2fa: False -
|
|
55
|
-
* session_id: null - access/refresh/user: populated
|
|
56
|
+
* Response with available OAuth providers.
|
|
56
57
|
*
|
|
57
58
|
* Response model (includes read-only fields).
|
|
58
59
|
*/
|
|
59
|
-
export interface
|
|
60
|
-
/**
|
|
61
|
-
|
|
62
|
-
/** 2FA session ID (only when requires_2fa=True) */
|
|
63
|
-
session_id?: string | null;
|
|
64
|
-
/** JWT access token (null when requires_2fa=True) */
|
|
65
|
-
access?: string | null;
|
|
66
|
-
/** JWT refresh token (null when requires_2fa=True) */
|
|
67
|
-
refresh?: string | null;
|
|
68
|
-
/** Authenticated user info (null when requires_2fa=True) */
|
|
69
|
-
user?: Record<string, any> | null;
|
|
70
|
-
/** True if a new user was created during this OAuth flow */
|
|
71
|
-
is_new_user: boolean;
|
|
72
|
-
/** True if a new OAuth connection was created */
|
|
73
|
-
is_new_connection: boolean;
|
|
74
|
-
/** True if user should be prompted to enable 2FA */
|
|
75
|
-
should_prompt_2fa?: boolean;
|
|
60
|
+
export interface OAuthProvidersResponse {
|
|
61
|
+
/** List of available OAuth providers */
|
|
62
|
+
providers: Array<Record<string, any>>;
|
|
76
63
|
}
|
|
77
64
|
|
|
78
65
|
/**
|
|
@@ -100,28 +87,41 @@ export interface OAuthConnection {
|
|
|
100
87
|
}
|
|
101
88
|
|
|
102
89
|
/**
|
|
103
|
-
* Response with OAuth
|
|
90
|
+
* Response with JWT tokens after OAuth authentication. When 2FA is required: -
|
|
91
|
+
* requires_2fa: True - session_id: UUID of 2FA verification session -
|
|
92
|
+
* access/refresh/user: null When 2FA is not required: - requires_2fa: False -
|
|
93
|
+
* session_id: null - access/refresh/user: populated
|
|
104
94
|
*
|
|
105
95
|
* Response model (includes read-only fields).
|
|
106
96
|
*/
|
|
107
|
-
export interface
|
|
108
|
-
/**
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
|
|
97
|
+
export interface OAuthTokenResponse {
|
|
98
|
+
/** True if 2FA verification is required */
|
|
99
|
+
requires_2fa?: boolean;
|
|
100
|
+
/** 2FA session ID (only when requires_2fa=True) */
|
|
101
|
+
session_id?: string | null;
|
|
102
|
+
/** JWT access token (null when requires_2fa=True) */
|
|
103
|
+
access?: string | null;
|
|
104
|
+
/** JWT refresh token (null when requires_2fa=True) */
|
|
105
|
+
refresh?: string | null;
|
|
106
|
+
/** Authenticated user info (null when requires_2fa=True) */
|
|
107
|
+
user?: Record<string, any> | null;
|
|
108
|
+
/** True if a new user was created during this OAuth flow */
|
|
109
|
+
is_new_user: boolean;
|
|
110
|
+
/** True if a new OAuth connection was created */
|
|
111
|
+
is_new_connection: boolean;
|
|
112
|
+
/** True if user should be prompted to enable 2FA */
|
|
113
|
+
should_prompt_2fa?: boolean;
|
|
112
114
|
}
|
|
113
115
|
|
|
114
116
|
/**
|
|
115
|
-
*
|
|
117
|
+
* Error response for OAuth endpoints.
|
|
116
118
|
*
|
|
117
|
-
*
|
|
119
|
+
* Response model (includes read-only fields).
|
|
118
120
|
*/
|
|
119
|
-
export interface
|
|
120
|
-
/**
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
|
|
124
|
-
/** Same redirect_uri used in authorize request. If not provided, uses config's site_url + callback_path */
|
|
125
|
-
redirect_uri?: string;
|
|
121
|
+
export interface OAuthError {
|
|
122
|
+
/** Error code */
|
|
123
|
+
error: string;
|
|
124
|
+
/** Human-readable error description */
|
|
125
|
+
error_description?: string;
|
|
126
126
|
}
|
|
127
127
|
|
|
@@ -1,19 +1,5 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
2
|
// Auto-generated by DjangoCFG - see CLAUDE.md
|
|
3
|
-
/**
|
|
4
|
-
* Serializer for updating user profile.
|
|
5
|
-
*
|
|
6
|
-
* Request model (no read-only fields).
|
|
7
|
-
*/
|
|
8
|
-
export interface PatchedUserProfileUpdateRequest {
|
|
9
|
-
first_name?: string;
|
|
10
|
-
last_name?: string;
|
|
11
|
-
company?: string;
|
|
12
|
-
phone?: string;
|
|
13
|
-
position?: string;
|
|
14
|
-
language?: string;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
3
|
/**
|
|
18
4
|
* Serializer for user details.
|
|
19
5
|
*
|
|
@@ -45,6 +31,29 @@ export interface User {
|
|
|
45
31
|
centrifugo: CentrifugoToken | null;
|
|
46
32
|
}
|
|
47
33
|
|
|
34
|
+
/**
|
|
35
|
+
* Serializer for updating user profile.
|
|
36
|
+
*
|
|
37
|
+
* Request model (no read-only fields).
|
|
38
|
+
*/
|
|
39
|
+
export interface PatchedUserProfileUpdateRequest {
|
|
40
|
+
first_name?: string;
|
|
41
|
+
last_name?: string;
|
|
42
|
+
company?: string;
|
|
43
|
+
phone?: string;
|
|
44
|
+
position?: string;
|
|
45
|
+
language?: string;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
*
|
|
50
|
+
* Request model (no read-only fields).
|
|
51
|
+
*/
|
|
52
|
+
export interface CfgAccountsProfileAvatarCreateRequest {
|
|
53
|
+
/** Avatar image file (JPEG, PNG, GIF, WebP, max 5MB) */
|
|
54
|
+
avatar: File | Blob;
|
|
55
|
+
}
|
|
56
|
+
|
|
48
57
|
/**
|
|
49
58
|
* Response serializer for account deletion.
|
|
50
59
|
*
|
|
@@ -71,15 +80,6 @@ export interface UserProfileUpdateRequest {
|
|
|
71
80
|
language?: string;
|
|
72
81
|
}
|
|
73
82
|
|
|
74
|
-
/**
|
|
75
|
-
*
|
|
76
|
-
* Request model (no read-only fields).
|
|
77
|
-
*/
|
|
78
|
-
export interface CfgAccountsProfileAvatarCreateRequest {
|
|
79
|
-
/** Avatar image file (JPEG, PNG, GIF, WebP, max 5MB) */
|
|
80
|
-
avatar: File | Blob;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
83
|
/**
|
|
84
84
|
* Nested serializer for Centrifugo WebSocket connection token.
|
|
85
85
|
*
|
|
@@ -166,6 +166,14 @@ export class APIClient {
|
|
|
166
166
|
// CSRF not needed - SessionAuthentication not enabled in DRF config
|
|
167
167
|
// Your API uses JWT/Token authentication (no CSRF required)
|
|
168
168
|
|
|
169
|
+
// Add Authorization header from tokenGetter (Bearer token / API key)
|
|
170
|
+
if (!headers['Authorization']) {
|
|
171
|
+
const token = this.getToken();
|
|
172
|
+
if (token) {
|
|
173
|
+
headers['Authorization'] = `Bearer ${token}`;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
169
177
|
// Log request
|
|
170
178
|
if (this.logger) {
|
|
171
179
|
this.logger.logRequest({
|
|
@@ -78,6 +78,11 @@ export class APIError extends Error {
|
|
|
78
78
|
return Array.isArray(details.detail) ? details.detail.join(', ') : String(details.detail);
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
+
// Check for "error" field (common in custom DRF views)
|
|
82
|
+
if (details.error) {
|
|
83
|
+
return String(details.error);
|
|
84
|
+
}
|
|
85
|
+
|
|
81
86
|
// Check for "message" field
|
|
82
87
|
if (details.message) {
|
|
83
88
|
return String(details.message);
|
|
@@ -157,6 +157,14 @@ export class APIClient {
|
|
|
157
157
|
// CSRF not needed - SessionAuthentication not enabled in DRF config
|
|
158
158
|
// Your API uses JWT/Token authentication (no CSRF required)
|
|
159
159
|
|
|
160
|
+
// Add Authorization header from tokenGetter (Bearer token / API key)
|
|
161
|
+
if (!headers['Authorization']) {
|
|
162
|
+
const token = this.getToken();
|
|
163
|
+
if (token) {
|
|
164
|
+
headers['Authorization'] = `Bearer ${token}`;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
160
168
|
// Log request
|
|
161
169
|
if (this.logger) {
|
|
162
170
|
this.logger.logRequest({
|
|
@@ -78,6 +78,11 @@ export class APIError extends Error {
|
|
|
78
78
|
return Array.isArray(details.detail) ? details.detail.join(', ') : String(details.detail);
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
+
// Check for "error" field (common in custom DRF views)
|
|
82
|
+
if (details.error) {
|
|
83
|
+
return String(details.error);
|
|
84
|
+
}
|
|
85
|
+
|
|
81
86
|
// Check for "message" field
|
|
82
87
|
if (details.message) {
|
|
83
88
|
return String(details.message);
|
|
@@ -169,6 +169,14 @@ export class APIClient {
|
|
|
169
169
|
// CSRF not needed - SessionAuthentication not enabled in DRF config
|
|
170
170
|
// Your API uses JWT/Token authentication (no CSRF required)
|
|
171
171
|
|
|
172
|
+
// Add Authorization header from tokenGetter (Bearer token / API key)
|
|
173
|
+
if (!headers['Authorization']) {
|
|
174
|
+
const token = this.getToken();
|
|
175
|
+
if (token) {
|
|
176
|
+
headers['Authorization'] = `Bearer ${token}`;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
172
180
|
// Log request
|
|
173
181
|
if (this.logger) {
|
|
174
182
|
this.logger.logRequest({
|
|
@@ -78,6 +78,11 @@ export class APIError extends Error {
|
|
|
78
78
|
return Array.isArray(details.detail) ? details.detail.join(', ') : String(details.detail);
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
+
// Check for "error" field (common in custom DRF views)
|
|
82
|
+
if (details.error) {
|
|
83
|
+
return String(details.error);
|
|
84
|
+
}
|
|
85
|
+
|
|
81
86
|
// Check for "message" field
|
|
82
87
|
if (details.message) {
|
|
83
88
|
return String(details.message);
|
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
2
|
// Auto-generated by DjangoCFG - see CLAUDE.md
|
|
3
|
+
/**
|
|
4
|
+
* Serializer for backup codes status.
|
|
5
|
+
*
|
|
6
|
+
* Response model (includes read-only fields).
|
|
7
|
+
*/
|
|
8
|
+
export interface BackupCodesStatus {
|
|
9
|
+
/** Number of unused backup codes */
|
|
10
|
+
remaining_count: number;
|
|
11
|
+
/** Total number of codes generated */
|
|
12
|
+
total_generated: number;
|
|
13
|
+
/** Warning if running low on codes */
|
|
14
|
+
warning?: string | null;
|
|
15
|
+
}
|
|
16
|
+
|
|
3
17
|
/**
|
|
4
18
|
* Response serializer for backup codes regeneration.
|
|
5
19
|
*
|
|
@@ -22,17 +36,3 @@ export interface BackupCodesRegenerateRequest {
|
|
|
22
36
|
code: string;
|
|
23
37
|
}
|
|
24
38
|
|
|
25
|
-
/**
|
|
26
|
-
* Serializer for backup codes status.
|
|
27
|
-
*
|
|
28
|
-
* Response model (includes read-only fields).
|
|
29
|
-
*/
|
|
30
|
-
export interface BackupCodesStatus {
|
|
31
|
-
/** Number of unused backup codes */
|
|
32
|
-
remaining_count: number;
|
|
33
|
-
/** Total number of codes generated */
|
|
34
|
-
total_generated: number;
|
|
35
|
-
/** Warning if running low on codes */
|
|
36
|
-
warning?: string | null;
|
|
37
|
-
}
|
|
38
|
-
|
|
@@ -2,16 +2,6 @@
|
|
|
2
2
|
// Auto-generated by DjangoCFG - see CLAUDE.md
|
|
3
3
|
import * as Enums from "../enums";
|
|
4
4
|
|
|
5
|
-
/**
|
|
6
|
-
* Serializer for completely disabling 2FA.
|
|
7
|
-
*
|
|
8
|
-
* Request model (no read-only fields).
|
|
9
|
-
*/
|
|
10
|
-
export interface DisableRequest {
|
|
11
|
-
/** TOTP code for verification */
|
|
12
|
-
code: string;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
5
|
/**
|
|
16
6
|
*
|
|
17
7
|
* Response model (includes read-only fields).
|
|
@@ -37,6 +27,16 @@ export interface PaginatedDeviceListResponseList {
|
|
|
37
27
|
results: Array<DeviceListResponse>;
|
|
38
28
|
}
|
|
39
29
|
|
|
30
|
+
/**
|
|
31
|
+
* Serializer for completely disabling 2FA.
|
|
32
|
+
*
|
|
33
|
+
* Request model (no read-only fields).
|
|
34
|
+
*/
|
|
35
|
+
export interface DisableRequest {
|
|
36
|
+
/** TOTP code for verification */
|
|
37
|
+
code: string;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
40
|
/**
|
|
41
41
|
* Response serializer for device list endpoint.
|
|
42
42
|
*
|
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
2
|
// Auto-generated by DjangoCFG - see CLAUDE.md
|
|
3
|
+
/**
|
|
4
|
+
* Serializer for confirming 2FA setup with first code.
|
|
5
|
+
*
|
|
6
|
+
* Request model (no read-only fields).
|
|
7
|
+
*/
|
|
8
|
+
export interface ConfirmSetupRequest {
|
|
9
|
+
/** Device ID from setup response */
|
|
10
|
+
device_id: string;
|
|
11
|
+
/** 6-digit TOTP code from authenticator app */
|
|
12
|
+
code: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Response serializer for setup confirmation.
|
|
17
|
+
*
|
|
18
|
+
* Response model (includes read-only fields).
|
|
19
|
+
*/
|
|
20
|
+
export interface ConfirmSetupResponse {
|
|
21
|
+
message: string;
|
|
22
|
+
/** List of backup recovery codes (save these!) */
|
|
23
|
+
backup_codes: Array<string>;
|
|
24
|
+
/** Warning message about backup codes */
|
|
25
|
+
backup_codes_warning: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
3
28
|
/**
|
|
4
29
|
* Response serializer for setup initiation.
|
|
5
30
|
*
|
|
@@ -18,18 +43,6 @@ export interface SetupResponse {
|
|
|
18
43
|
expires_in: number;
|
|
19
44
|
}
|
|
20
45
|
|
|
21
|
-
/**
|
|
22
|
-
* Serializer for confirming 2FA setup with first code.
|
|
23
|
-
*
|
|
24
|
-
* Request model (no read-only fields).
|
|
25
|
-
*/
|
|
26
|
-
export interface ConfirmSetupRequest {
|
|
27
|
-
/** Device ID from setup response */
|
|
28
|
-
device_id: string;
|
|
29
|
-
/** 6-digit TOTP code from authenticator app */
|
|
30
|
-
code: string;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
46
|
/**
|
|
34
47
|
* Serializer for starting 2FA setup.
|
|
35
48
|
*
|
|
@@ -40,16 +53,3 @@ export interface SetupRequest {
|
|
|
40
53
|
device_name?: string;
|
|
41
54
|
}
|
|
42
55
|
|
|
43
|
-
/**
|
|
44
|
-
* Response serializer for setup confirmation.
|
|
45
|
-
*
|
|
46
|
-
* Response model (includes read-only fields).
|
|
47
|
-
*/
|
|
48
|
-
export interface ConfirmSetupResponse {
|
|
49
|
-
message: string;
|
|
50
|
-
/** List of backup recovery codes (save these!) */
|
|
51
|
-
backup_codes: Array<string>;
|
|
52
|
-
/** Warning message about backup codes */
|
|
53
|
-
backup_codes_warning: string;
|
|
54
|
-
}
|
|
55
|
-
|
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
2
|
// Auto-generated by DjangoCFG - see CLAUDE.md
|
|
3
3
|
/**
|
|
4
|
-
* Serializer for
|
|
4
|
+
* Serializer for TOTP code verification during login.
|
|
5
5
|
*
|
|
6
6
|
* Request model (no read-only fields).
|
|
7
7
|
*/
|
|
8
|
-
export interface
|
|
8
|
+
export interface VerifyRequest {
|
|
9
9
|
/** 2FA session ID from login response */
|
|
10
10
|
session_id: string;
|
|
11
|
-
/**
|
|
12
|
-
|
|
11
|
+
/** 6-digit TOTP code from authenticator app */
|
|
12
|
+
code: string;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
|
-
* Serializer for
|
|
16
|
+
* Serializer for backup code verification during login.
|
|
17
17
|
*
|
|
18
18
|
* Request model (no read-only fields).
|
|
19
19
|
*/
|
|
20
|
-
export interface
|
|
20
|
+
export interface VerifyBackupRequest {
|
|
21
21
|
/** 2FA session ID from login response */
|
|
22
22
|
session_id: string;
|
|
23
|
-
/**
|
|
24
|
-
|
|
23
|
+
/** 8-character backup recovery code */
|
|
24
|
+
backup_code: string;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
/**
|