@djangocfg/api 2.1.355 → 2.1.357

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 (112) hide show
  1. package/README.md +53 -632
  2. package/dist/auth-server.cjs +717 -200
  3. package/dist/auth-server.cjs.map +1 -1
  4. package/dist/auth-server.mjs +717 -200
  5. package/dist/auth-server.mjs.map +1 -1
  6. package/dist/auth.cjs +843 -783
  7. package/dist/auth.cjs.map +1 -1
  8. package/dist/auth.d.cts +58 -37
  9. package/dist/auth.d.ts +58 -37
  10. package/dist/auth.mjs +846 -784
  11. package/dist/auth.mjs.map +1 -1
  12. package/dist/clients.cjs +1427 -0
  13. package/dist/clients.cjs.map +1 -1
  14. package/dist/clients.d.cts +1686 -0
  15. package/dist/clients.d.ts +1686 -0
  16. package/dist/clients.mjs +1427 -0
  17. package/dist/clients.mjs.map +1 -1
  18. package/dist/hooks.cjs +1277 -1924
  19. package/dist/hooks.cjs.map +1 -1
  20. package/dist/hooks.d.cts +18 -1206
  21. package/dist/hooks.d.ts +18 -1206
  22. package/dist/hooks.mjs +1253 -1900
  23. package/dist/hooks.mjs.map +1 -1
  24. package/dist/index.cjs +545 -1232
  25. package/dist/index.cjs.map +1 -1
  26. package/dist/index.d.cts +1389 -1455
  27. package/dist/index.d.ts +1389 -1455
  28. package/dist/index.mjs +545 -1232
  29. package/dist/index.mjs.map +1 -1
  30. package/package.json +7 -2
  31. package/src/_api/generated/_cfg_accounts/api.ts +11 -3
  32. package/src/_api/generated/_cfg_accounts/hooks/index.ts +3 -0
  33. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsApiKeyRegenerateCreate.ts +64 -0
  34. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsApiKeyRetrieve.ts +65 -0
  35. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsApiKeyTestCreate.ts +64 -0
  36. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthConnectionsList.ts +43 -3
  37. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthDisconnectCreate.ts +43 -3
  38. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthGithubAuthorizeCreate.ts +43 -3
  39. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthGithubCallbackCreate.ts +43 -3
  40. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthProvidersRetrieve.ts +43 -3
  41. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOtpRequestCreate.ts +43 -3
  42. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOtpVerifyCreate.ts +43 -3
  43. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileAvatarCreate.ts +43 -3
  44. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileDeleteCreate.ts +43 -3
  45. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfilePartialPartialUpdate.ts +43 -3
  46. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfilePartialUpdate.ts +43 -3
  47. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileRetrieve.ts +43 -3
  48. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileUpdatePartialUpdate.ts +43 -3
  49. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileUpdateUpdate.ts +43 -3
  50. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsTokenRefreshCreate.ts +43 -3
  51. package/src/_api/generated/_cfg_accounts/index.ts +1 -1
  52. package/src/_api/generated/_cfg_accounts/schemas/APIKey.ts +13 -0
  53. package/src/_api/generated/_cfg_accounts/schemas/APIKeyRegenerate.ts +12 -0
  54. package/src/_api/generated/_cfg_accounts/schemas/APIKeyRequest.ts +13 -0
  55. package/src/_api/generated/{_cfg_totp/schemas/DeviceListStatusEnum.ts → _cfg_accounts/schemas/APIKeyTestRequest.ts} +4 -2
  56. package/src/_api/generated/_cfg_accounts/schemas/APIKeyTestResult.ts +12 -0
  57. package/src/_api/generated/_cfg_accounts/schemas/AccountDeleteResponse.ts +1 -1
  58. package/src/_api/generated/_cfg_accounts/schemas/CentrifugoToken.ts +2 -2
  59. package/src/_api/generated/_cfg_accounts/schemas/CfgUserUpdateRequest.ts +3 -2
  60. package/src/_api/generated/_cfg_accounts/schemas/OAuthCallbackRequestRequest.ts +1 -1
  61. package/src/_api/generated/_cfg_accounts/schemas/OAuthConnection.ts +6 -6
  62. package/src/_api/generated/_cfg_accounts/schemas/OAuthDisconnectRequestRequest.ts +2 -2
  63. package/src/_api/generated/_cfg_accounts/schemas/{ProviderEnum.ts → OAuthProviderEnum.ts} +2 -2
  64. package/src/_api/generated/_cfg_accounts/schemas/OAuthTokenResponse.ts +5 -5
  65. package/src/_api/generated/_cfg_accounts/schemas/OTPVerifyRequest.ts +1 -1
  66. package/src/_api/generated/_cfg_accounts/schemas/OTPVerifyResponse.ts +3 -3
  67. package/src/_api/generated/_cfg_accounts/schemas/PatchedCfgUserUpdateRequest.ts +3 -2
  68. package/src/_api/generated/_cfg_accounts/schemas/User.ts +12 -10
  69. package/src/_api/generated/_cfg_accounts/schemas/cfg_accounts_oauth_connections_response_200_AutoRef.ts +10 -0
  70. package/src/_api/generated/_cfg_accounts/schemas/cfg_accounts_oauth_disconnect_response_200_AutoRef.ts +11 -0
  71. package/src/_api/generated/_cfg_accounts/schemas/index.ts +8 -1
  72. package/src/_api/generated/_cfg_centrifugo/api.ts +3 -3
  73. package/src/_api/generated/_cfg_centrifugo/hooks/useCfgCentrifugoAuthTokenRetrieve.ts +43 -3
  74. package/src/_api/generated/_cfg_centrifugo/index.ts +1 -1
  75. package/src/_api/generated/_cfg_centrifugo/schemas/ConnectionTokenResponse.ts +2 -2
  76. package/src/_api/generated/_cfg_totp/api.ts +9 -3
  77. package/src/_api/generated/_cfg_totp/hooks/useCfgTotpBackupCodesRegenerateCreate.ts +43 -3
  78. package/src/_api/generated/_cfg_totp/hooks/useCfgTotpBackupCodesRetrieve.ts +43 -3
  79. package/src/_api/generated/_cfg_totp/hooks/useCfgTotpDevicesDestroy.ts +7 -3
  80. package/src/_api/generated/_cfg_totp/hooks/useCfgTotpDevicesRetrieve.ts +43 -3
  81. package/src/_api/generated/_cfg_totp/hooks/useCfgTotpDisableCreate.ts +43 -3
  82. package/src/_api/generated/_cfg_totp/hooks/useCfgTotpSetupConfirmCreate.ts +43 -3
  83. package/src/_api/generated/_cfg_totp/hooks/useCfgTotpSetupCreate.ts +43 -3
  84. package/src/_api/generated/_cfg_totp/hooks/useCfgTotpVerifyBackupCreate.ts +43 -3
  85. package/src/_api/generated/_cfg_totp/hooks/useCfgTotpVerifyCreate.ts +43 -3
  86. package/src/_api/generated/_cfg_totp/index.ts +1 -1
  87. package/src/_api/generated/_cfg_totp/schemas/ConfirmSetupRequest.ts +1 -1
  88. package/src/_api/generated/_cfg_totp/schemas/ConfirmSetupResponse.ts +1 -1
  89. package/src/_api/generated/_cfg_totp/schemas/DeviceList.ts +5 -5
  90. package/src/_api/generated/_cfg_totp/schemas/DeviceStatusEnum.ts +9 -0
  91. package/src/_api/generated/_cfg_totp/schemas/SetupResponse.ts +2 -2
  92. package/src/_api/generated/_cfg_totp/schemas/TotpVerifyUser.ts +11 -9
  93. package/src/_api/generated/_cfg_totp/schemas/VerifyBackupRequest.ts +1 -1
  94. package/src/_api/generated/_cfg_totp/schemas/VerifyRequest.ts +1 -1
  95. package/src/_api/generated/_cfg_totp/schemas/VerifyResponse.ts +2 -2
  96. package/src/_api/generated/_cfg_totp/schemas/cfg_totp_disable_response_200_AutoRef.ts +9 -0
  97. package/src/_api/generated/_cfg_totp/schemas/index.ts +2 -1
  98. package/src/_api/generated/index.ts +3 -1
  99. package/src/_api/generated/sdk.gen.ts +80 -813
  100. package/src/_api/generated/types.gen.ts +320 -159
  101. package/src/auth/context/AccountsContext.tsx +18 -6
  102. package/src/auth/context/AuthContext.tsx +11 -3
  103. package/src/auth/hooks/useDeleteAccount.ts +2 -2
  104. package/src/auth/hooks/useGithubAuth.ts +3 -3
  105. package/src/auth/hooks/useTokenRefresh.ts +2 -2
  106. package/src/auth/hooks/useTwoFactor.ts +3 -3
  107. package/src/auth/hooks/useTwoFactorSetup.ts +3 -3
  108. package/src/auth/hooks/useTwoFactorStatus.ts +3 -3
  109. package/src/auth/middlewares/tokenRefresh.ts +2 -2
  110. package/src/hooks/index.ts +1 -0
  111. package/src/hooks/useApiKey.ts +73 -0
  112. package/src/index.ts +12 -16
package/dist/auth.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import React$1, { MutableRefObject, ReactNode } from 'react';
2
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import React$1, { MutableRefObject, ReactNode } from 'react';
3
3
  import * as consola from 'consola';
4
4
  import { z } from 'zod';
5
5
 
@@ -21,32 +21,36 @@ declare const AUTH_CONSTANTS: {
21
21
  */
22
22
  type CentrifugoToken = {
23
23
  /**
24
- * Centrifugo WebSocket URL
24
+ * JWT token for Centrifugo WebSocket connection
25
25
  */
26
- centrifugo_url: string;
26
+ token: string;
27
27
  /**
28
- * List of allowed channels for this user
28
+ * Centrifugo WebSocket URL
29
29
  */
30
- channels: Array<string>;
30
+ centrifugo_url: string;
31
31
  /**
32
32
  * Token expiration time (ISO 8601)
33
33
  */
34
34
  expires_at: string;
35
35
  /**
36
- * JWT token for Centrifugo WebSocket connection
36
+ * List of allowed channels for this user
37
37
  */
38
- token: string;
38
+ channels: Array<string>;
39
39
  };
40
40
  /**
41
41
  * Serializer for updating user profile.
42
42
  */
43
43
  type CfgUserUpdateRequest = {
44
- company?: string;
45
44
  first_name?: string;
46
- language?: string;
47
45
  last_name?: string;
46
+ company?: string;
48
47
  phone?: string;
49
48
  position?: string;
49
+ language?: string;
50
+ /**
51
+ * IANA timezone name (e.g. 'Asia/Seoul'). Auto-detected from browser via X-Timezone header.
52
+ */
53
+ timezone?: string;
50
54
  };
51
55
  /**
52
56
  * Serializer for OTP request.
@@ -98,14 +102,6 @@ type OtpVerifyRequest = {
98
102
  * - refresh/access/user: populated
99
103
  */
100
104
  type OtpVerifyResponse = {
101
- /**
102
- * JWT access token (if requires_2fa is False)
103
- */
104
- access?: string | null;
105
- /**
106
- * JWT refresh token (if requires_2fa is False)
107
- */
108
- refresh?: string | null;
109
105
  /**
110
106
  * Whether 2FA verification is required
111
107
  */
@@ -115,24 +111,36 @@ type OtpVerifyResponse = {
115
111
  */
116
112
  session_id?: string | null;
117
113
  /**
118
- * Whether user should be prompted to enable 2FA
114
+ * JWT refresh token (if requires_2fa is False)
119
115
  */
120
- should_prompt_2fa?: boolean;
116
+ refresh?: string | null;
117
+ /**
118
+ * JWT access token (if requires_2fa is False)
119
+ */
120
+ access?: string | null;
121
121
  /**
122
122
  * User information (if requires_2fa is False)
123
123
  */
124
124
  user?: User | null;
125
+ /**
126
+ * Whether user should be prompted to enable 2FA
127
+ */
128
+ should_prompt_2fa?: boolean;
125
129
  };
126
130
  /**
127
131
  * Serializer for updating user profile.
128
132
  */
129
133
  type PatchedCfgUserUpdateRequest = {
130
- company?: string;
131
134
  first_name?: string;
132
- language?: string;
133
135
  last_name?: string;
136
+ company?: string;
134
137
  phone?: string;
135
138
  position?: string;
139
+ language?: string;
140
+ /**
141
+ * IANA timezone name (e.g. 'Asia/Seoul'). Auto-detected from browser via X-Timezone header.
142
+ */
143
+ timezone?: string;
136
144
  };
137
145
  type TokenRefresh = {
138
146
  readonly access: string;
@@ -142,25 +150,31 @@ type TokenRefresh = {
142
150
  * Serializer for user details.
143
151
  */
144
152
  type User = {
145
- readonly avatar: string | null;
146
- readonly centrifugo: CentrifugoToken | null;
147
- company?: string;
148
- readonly date_joined: string;
149
- /**
150
- * Get formatted username for display.
151
- */
152
- readonly display_username: string;
153
+ readonly id: number;
153
154
  readonly email: string;
154
155
  first_name?: string;
156
+ last_name?: string;
155
157
  /**
156
158
  * Get user's full name.
157
159
  */
158
160
  readonly full_name: string;
159
- readonly id: number;
160
161
  /**
161
162
  * Get user's initials for avatar fallback.
162
163
  */
163
164
  readonly initials: string;
165
+ /**
166
+ * Get formatted username for display.
167
+ */
168
+ readonly display_username: string;
169
+ company?: string;
170
+ phone?: string;
171
+ position?: string;
172
+ language?: string;
173
+ /**
174
+ * IANA timezone name (e.g. 'Asia/Seoul'). Auto-detected from browser via X-Timezone header.
175
+ */
176
+ timezone?: string;
177
+ readonly avatar: string | null;
164
178
  /**
165
179
  * Staff status
166
180
  *
@@ -173,12 +187,11 @@ type User = {
173
187
  * Designates that this user has all permissions without explicitly assigning them.
174
188
  */
175
189
  readonly is_superuser: boolean;
176
- language?: string;
190
+ readonly date_joined: string;
177
191
  readonly last_login: string | null;
178
- last_name?: string;
179
- phone?: string;
180
- position?: string;
181
192
  readonly unanswered_messages_count: number;
193
+ readonly centrifugo: CentrifugoToken | null;
194
+ readonly api_key: string | null;
182
195
  };
183
196
 
184
197
  /**
@@ -345,7 +358,14 @@ interface AuthProviderProps {
345
358
  config?: AuthConfig;
346
359
  }
347
360
 
348
- declare const AuthProvider: React$1.FC<AuthProviderProps>;
361
+ /**
362
+ * AuthProvider — wraps AccountsProvider + AuthProviderInternal.
363
+ *
364
+ * Memoised: re-renders only when `config` reference or `children` change.
365
+ * Internal auth state is isolated inside AuthProviderInternal.
366
+ */
367
+ declare function AuthProviderRaw({ children, config }: AuthProviderProps): react_jsx_runtime.JSX.Element;
368
+ declare const AuthProvider: React$1.MemoExoticComponent<typeof AuthProviderRaw>;
349
369
  /**
350
370
  * Hook to access auth context
351
371
  *
@@ -355,12 +375,13 @@ declare const AuthProvider: React$1.FC<AuthProviderProps>;
355
375
  declare const useAuth: () => AuthContextType;
356
376
 
357
377
  declare const PatchedCfgUserUpdateRequestSchema: z.ZodObject<{
358
- company: z.ZodOptional<z.ZodString>;
359
378
  first_name: z.ZodOptional<z.ZodString>;
360
- language: z.ZodOptional<z.ZodString>;
361
379
  last_name: z.ZodOptional<z.ZodString>;
380
+ company: z.ZodOptional<z.ZodString>;
362
381
  phone: z.ZodOptional<z.ZodString>;
363
382
  position: z.ZodOptional<z.ZodString>;
383
+ language: z.ZodOptional<z.ZodString>;
384
+ timezone: z.ZodOptional<z.ZodString>;
364
385
  }, z.core.$strip>;
365
386
 
366
387
  interface AccountsContextValue {
package/dist/auth.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import React$1, { MutableRefObject, ReactNode } from 'react';
2
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import React$1, { MutableRefObject, ReactNode } from 'react';
3
3
  import * as consola from 'consola';
4
4
  import { z } from 'zod';
5
5
 
@@ -21,32 +21,36 @@ declare const AUTH_CONSTANTS: {
21
21
  */
22
22
  type CentrifugoToken = {
23
23
  /**
24
- * Centrifugo WebSocket URL
24
+ * JWT token for Centrifugo WebSocket connection
25
25
  */
26
- centrifugo_url: string;
26
+ token: string;
27
27
  /**
28
- * List of allowed channels for this user
28
+ * Centrifugo WebSocket URL
29
29
  */
30
- channels: Array<string>;
30
+ centrifugo_url: string;
31
31
  /**
32
32
  * Token expiration time (ISO 8601)
33
33
  */
34
34
  expires_at: string;
35
35
  /**
36
- * JWT token for Centrifugo WebSocket connection
36
+ * List of allowed channels for this user
37
37
  */
38
- token: string;
38
+ channels: Array<string>;
39
39
  };
40
40
  /**
41
41
  * Serializer for updating user profile.
42
42
  */
43
43
  type CfgUserUpdateRequest = {
44
- company?: string;
45
44
  first_name?: string;
46
- language?: string;
47
45
  last_name?: string;
46
+ company?: string;
48
47
  phone?: string;
49
48
  position?: string;
49
+ language?: string;
50
+ /**
51
+ * IANA timezone name (e.g. 'Asia/Seoul'). Auto-detected from browser via X-Timezone header.
52
+ */
53
+ timezone?: string;
50
54
  };
51
55
  /**
52
56
  * Serializer for OTP request.
@@ -98,14 +102,6 @@ type OtpVerifyRequest = {
98
102
  * - refresh/access/user: populated
99
103
  */
100
104
  type OtpVerifyResponse = {
101
- /**
102
- * JWT access token (if requires_2fa is False)
103
- */
104
- access?: string | null;
105
- /**
106
- * JWT refresh token (if requires_2fa is False)
107
- */
108
- refresh?: string | null;
109
105
  /**
110
106
  * Whether 2FA verification is required
111
107
  */
@@ -115,24 +111,36 @@ type OtpVerifyResponse = {
115
111
  */
116
112
  session_id?: string | null;
117
113
  /**
118
- * Whether user should be prompted to enable 2FA
114
+ * JWT refresh token (if requires_2fa is False)
119
115
  */
120
- should_prompt_2fa?: boolean;
116
+ refresh?: string | null;
117
+ /**
118
+ * JWT access token (if requires_2fa is False)
119
+ */
120
+ access?: string | null;
121
121
  /**
122
122
  * User information (if requires_2fa is False)
123
123
  */
124
124
  user?: User | null;
125
+ /**
126
+ * Whether user should be prompted to enable 2FA
127
+ */
128
+ should_prompt_2fa?: boolean;
125
129
  };
126
130
  /**
127
131
  * Serializer for updating user profile.
128
132
  */
129
133
  type PatchedCfgUserUpdateRequest = {
130
- company?: string;
131
134
  first_name?: string;
132
- language?: string;
133
135
  last_name?: string;
136
+ company?: string;
134
137
  phone?: string;
135
138
  position?: string;
139
+ language?: string;
140
+ /**
141
+ * IANA timezone name (e.g. 'Asia/Seoul'). Auto-detected from browser via X-Timezone header.
142
+ */
143
+ timezone?: string;
136
144
  };
137
145
  type TokenRefresh = {
138
146
  readonly access: string;
@@ -142,25 +150,31 @@ type TokenRefresh = {
142
150
  * Serializer for user details.
143
151
  */
144
152
  type User = {
145
- readonly avatar: string | null;
146
- readonly centrifugo: CentrifugoToken | null;
147
- company?: string;
148
- readonly date_joined: string;
149
- /**
150
- * Get formatted username for display.
151
- */
152
- readonly display_username: string;
153
+ readonly id: number;
153
154
  readonly email: string;
154
155
  first_name?: string;
156
+ last_name?: string;
155
157
  /**
156
158
  * Get user's full name.
157
159
  */
158
160
  readonly full_name: string;
159
- readonly id: number;
160
161
  /**
161
162
  * Get user's initials for avatar fallback.
162
163
  */
163
164
  readonly initials: string;
165
+ /**
166
+ * Get formatted username for display.
167
+ */
168
+ readonly display_username: string;
169
+ company?: string;
170
+ phone?: string;
171
+ position?: string;
172
+ language?: string;
173
+ /**
174
+ * IANA timezone name (e.g. 'Asia/Seoul'). Auto-detected from browser via X-Timezone header.
175
+ */
176
+ timezone?: string;
177
+ readonly avatar: string | null;
164
178
  /**
165
179
  * Staff status
166
180
  *
@@ -173,12 +187,11 @@ type User = {
173
187
  * Designates that this user has all permissions without explicitly assigning them.
174
188
  */
175
189
  readonly is_superuser: boolean;
176
- language?: string;
190
+ readonly date_joined: string;
177
191
  readonly last_login: string | null;
178
- last_name?: string;
179
- phone?: string;
180
- position?: string;
181
192
  readonly unanswered_messages_count: number;
193
+ readonly centrifugo: CentrifugoToken | null;
194
+ readonly api_key: string | null;
182
195
  };
183
196
 
184
197
  /**
@@ -345,7 +358,14 @@ interface AuthProviderProps {
345
358
  config?: AuthConfig;
346
359
  }
347
360
 
348
- declare const AuthProvider: React$1.FC<AuthProviderProps>;
361
+ /**
362
+ * AuthProvider — wraps AccountsProvider + AuthProviderInternal.
363
+ *
364
+ * Memoised: re-renders only when `config` reference or `children` change.
365
+ * Internal auth state is isolated inside AuthProviderInternal.
366
+ */
367
+ declare function AuthProviderRaw({ children, config }: AuthProviderProps): react_jsx_runtime.JSX.Element;
368
+ declare const AuthProvider: React$1.MemoExoticComponent<typeof AuthProviderRaw>;
349
369
  /**
350
370
  * Hook to access auth context
351
371
  *
@@ -355,12 +375,13 @@ declare const AuthProvider: React$1.FC<AuthProviderProps>;
355
375
  declare const useAuth: () => AuthContextType;
356
376
 
357
377
  declare const PatchedCfgUserUpdateRequestSchema: z.ZodObject<{
358
- company: z.ZodOptional<z.ZodString>;
359
378
  first_name: z.ZodOptional<z.ZodString>;
360
- language: z.ZodOptional<z.ZodString>;
361
379
  last_name: z.ZodOptional<z.ZodString>;
380
+ company: z.ZodOptional<z.ZodString>;
362
381
  phone: z.ZodOptional<z.ZodString>;
363
382
  position: z.ZodOptional<z.ZodString>;
383
+ language: z.ZodOptional<z.ZodString>;
384
+ timezone: z.ZodOptional<z.ZodString>;
364
385
  }, z.core.$strip>;
365
386
 
366
387
  interface AccountsContextValue {