@djangocfg/api 2.1.322 → 2.1.331

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 (272) hide show
  1. package/dist/auth-server.cjs +1037 -1227
  2. package/dist/auth-server.cjs.map +1 -1
  3. package/dist/auth-server.mjs +1037 -1217
  4. package/dist/auth-server.mjs.map +1 -1
  5. package/dist/auth.cjs +2142 -3398
  6. package/dist/auth.cjs.map +1 -1
  7. package/dist/auth.d.cts +158 -209
  8. package/dist/auth.d.ts +158 -209
  9. package/dist/auth.mjs +2136 -3392
  10. package/dist/auth.mjs.map +1 -1
  11. package/dist/clients.cjs +1018 -4423
  12. package/dist/clients.cjs.map +1 -1
  13. package/dist/clients.d.cts +151 -2918
  14. package/dist/clients.d.ts +151 -2918
  15. package/dist/clients.mjs +1018 -4417
  16. package/dist/clients.mjs.map +1 -1
  17. package/dist/index.cjs +2253 -2819
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.d.cts +2408 -1872
  20. package/dist/index.d.ts +2408 -1872
  21. package/dist/index.mjs +2235 -2795
  22. package/dist/index.mjs.map +1 -1
  23. package/package.json +2 -7
  24. package/src/_api/generated/_cfg_accounts/api.ts +120 -0
  25. package/src/_api/generated/_cfg_accounts/events.ts +198 -0
  26. package/src/_api/generated/_cfg_accounts/hooks/index.ts +18 -0
  27. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthConnectionsList.ts +25 -0
  28. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthDisconnectCreate.ts +24 -0
  29. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthGithubAuthorizeCreate.ts +24 -0
  30. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthGithubCallbackCreate.ts +24 -0
  31. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthProvidersRetrieve.ts +25 -0
  32. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOtpRequestCreate.ts +24 -0
  33. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOtpVerifyCreate.ts +24 -0
  34. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileAvatarCreate.ts +24 -0
  35. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileDeleteCreate.ts +24 -0
  36. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfilePartialPartialUpdate.ts +24 -0
  37. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfilePartialUpdate.ts +24 -0
  38. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileRetrieve.ts +25 -0
  39. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileUpdatePartialUpdate.ts +24 -0
  40. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileUpdateUpdate.ts +24 -0
  41. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsTokenRefreshCreate.ts +24 -0
  42. package/src/_api/generated/_cfg_accounts/index.ts +29 -0
  43. package/src/_api/generated/_cfg_accounts/schemas/AccountDeleteResponse.ts +12 -0
  44. package/src/_api/generated/_cfg_accounts/schemas/CentrifugoToken.ts +14 -0
  45. package/src/_api/generated/_cfg_accounts/schemas/CfgUserUpdateRequest.ts +16 -0
  46. package/src/_api/generated/_cfg_accounts/schemas/OAuthAuthorizeRequestRequest.ts +12 -0
  47. package/src/_api/generated/_cfg_accounts/schemas/OAuthAuthorizeResponse.ts +12 -0
  48. package/src/_api/generated/_cfg_accounts/schemas/OAuthCallbackRequestRequest.ts +13 -0
  49. package/src/_api/generated/_cfg_accounts/schemas/OAuthConnection.ts +19 -0
  50. package/src/_api/generated/_cfg_accounts/schemas/OAuthDisconnectRequestRequest.ts +12 -0
  51. package/src/_api/generated/_cfg_accounts/schemas/OAuthError.ts +12 -0
  52. package/src/_api/generated/_cfg_accounts/schemas/OAuthProvidersResponse.ts +11 -0
  53. package/src/_api/generated/_cfg_accounts/schemas/OAuthTokenResponse.ts +18 -0
  54. package/src/_api/generated/_cfg_accounts/schemas/OTPErrorResponse.ts +13 -0
  55. package/src/_api/generated/_cfg_accounts/schemas/OTPRequestRequest.ts +12 -0
  56. package/src/_api/generated/_cfg_accounts/schemas/OTPRequestResponse.ts +11 -0
  57. package/src/_api/generated/_cfg_accounts/schemas/OTPVerifyRequest.ts +13 -0
  58. package/src/_api/generated/_cfg_accounts/schemas/OTPVerifyResponse.ts +17 -0
  59. package/src/_api/generated/_cfg_accounts/schemas/PatchedCfgUserUpdateRequest.ts +16 -0
  60. package/src/_api/generated/_cfg_accounts/schemas/ProviderEnum.ts +9 -0
  61. package/src/_api/generated/_cfg_accounts/schemas/TokenRefresh.ts +12 -0
  62. package/src/_api/generated/_cfg_accounts/schemas/TokenRefreshRequest.ts +11 -0
  63. package/src/_api/generated/{cfg_accounts/_utils/schemas/User.schema.ts → _cfg_accounts/schemas/User.ts} +19 -27
  64. package/src/_api/generated/_cfg_accounts/schemas/index.ts +24 -0
  65. package/src/_api/generated/_cfg_accounts/sdk.gen.ts +5 -0
  66. package/src/_api/generated/_cfg_accounts/types.gen.ts +5 -0
  67. package/src/_api/generated/_cfg_centrifugo/api.ts +120 -0
  68. package/src/_api/generated/_cfg_centrifugo/events.ts +198 -0
  69. package/src/_api/generated/_cfg_centrifugo/hooks/index.ts +4 -0
  70. package/src/_api/generated/_cfg_centrifugo/hooks/useCfgCentrifugoAuthTokenRetrieve.ts +25 -0
  71. package/src/_api/generated/_cfg_centrifugo/index.ts +29 -0
  72. package/src/_api/generated/_cfg_centrifugo/schemas/ConnectionTokenResponse.ts +14 -0
  73. package/src/_api/generated/_cfg_centrifugo/schemas/index.ts +4 -0
  74. package/src/_api/generated/_cfg_centrifugo/sdk.gen.ts +5 -0
  75. package/src/_api/generated/_cfg_centrifugo/types.gen.ts +5 -0
  76. package/src/_api/generated/_cfg_totp/api.ts +120 -0
  77. package/src/_api/generated/_cfg_totp/events.ts +198 -0
  78. package/src/_api/generated/_cfg_totp/hooks/index.ts +12 -0
  79. package/src/_api/generated/_cfg_totp/hooks/useCfgTotpBackupCodesRegenerateCreate.ts +24 -0
  80. package/src/_api/generated/_cfg_totp/hooks/useCfgTotpBackupCodesRetrieve.ts +25 -0
  81. package/src/_api/generated/_cfg_totp/hooks/useCfgTotpDevicesDestroy.ts +24 -0
  82. package/src/_api/generated/_cfg_totp/hooks/useCfgTotpDevicesRetrieve.ts +25 -0
  83. package/src/_api/generated/_cfg_totp/hooks/useCfgTotpDisableCreate.ts +24 -0
  84. package/src/_api/generated/_cfg_totp/hooks/useCfgTotpSetupConfirmCreate.ts +24 -0
  85. package/src/_api/generated/_cfg_totp/hooks/useCfgTotpSetupCreate.ts +24 -0
  86. package/src/_api/generated/_cfg_totp/hooks/useCfgTotpVerifyBackupCreate.ts +24 -0
  87. package/src/_api/generated/_cfg_totp/hooks/useCfgTotpVerifyCreate.ts +24 -0
  88. package/src/_api/generated/_cfg_totp/index.ts +29 -0
  89. package/src/_api/generated/_cfg_totp/schemas/BackupCodesRegenerateRequest.ts +11 -0
  90. package/src/_api/generated/_cfg_totp/schemas/BackupCodesRegenerateResponse.ts +12 -0
  91. package/src/_api/generated/_cfg_totp/schemas/BackupCodesStatus.ts +13 -0
  92. package/src/_api/generated/_cfg_totp/schemas/ConfirmSetupRequest.ts +12 -0
  93. package/src/_api/generated/_cfg_totp/schemas/ConfirmSetupResponse.ts +13 -0
  94. package/src/_api/generated/_cfg_totp/schemas/DeviceList.ts +18 -0
  95. package/src/_api/generated/_cfg_totp/schemas/DeviceListResponse.ts +13 -0
  96. package/src/_api/generated/_cfg_totp/schemas/DeviceListStatusEnum.ts +9 -0
  97. package/src/_api/generated/_cfg_totp/schemas/DisableRequest.ts +11 -0
  98. package/src/_api/generated/_cfg_totp/schemas/SetupRequest.ts +11 -0
  99. package/src/_api/generated/_cfg_totp/schemas/SetupResponse.ts +15 -0
  100. package/src/_api/generated/{cfg_totp/_utils/schemas/TotpVerifyUser.schema.ts → _cfg_totp/schemas/TotpVerifyUser.ts} +17 -25
  101. package/src/_api/generated/_cfg_totp/schemas/VerifyBackupRequest.ts +12 -0
  102. package/src/_api/generated/_cfg_totp/schemas/VerifyRequest.ts +12 -0
  103. package/src/_api/generated/_cfg_totp/schemas/VerifyResponse.ts +17 -0
  104. package/src/_api/generated/_cfg_totp/schemas/index.ts +18 -0
  105. package/src/_api/generated/_cfg_totp/sdk.gen.ts +5 -0
  106. package/src/_api/generated/_cfg_totp/types.gen.ts +5 -0
  107. package/src/_api/generated/client/client.gen.ts +280 -0
  108. package/src/_api/generated/client/index.ts +25 -0
  109. package/src/_api/generated/client/types.gen.ts +217 -0
  110. package/src/_api/generated/client/utils.gen.ts +318 -0
  111. package/src/_api/generated/client.gen.ts +16 -0
  112. package/src/_api/generated/core/auth.gen.ts +41 -0
  113. package/src/_api/generated/core/bodySerializer.gen.ts +82 -0
  114. package/src/_api/generated/core/params.gen.ts +169 -0
  115. package/src/_api/generated/core/pathSerializer.gen.ts +171 -0
  116. package/src/_api/generated/core/queryKeySerializer.gen.ts +117 -0
  117. package/src/_api/generated/core/serverSentEvents.gen.ts +242 -0
  118. package/src/_api/generated/core/types.gen.ts +104 -0
  119. package/src/_api/generated/core/utils.gen.ts +140 -0
  120. package/src/_api/generated/helpers/errors.ts +70 -0
  121. package/src/_api/generated/helpers/index.ts +25 -0
  122. package/src/_api/generated/helpers/logger.ts +123 -0
  123. package/src/_api/generated/helpers/storage.ts +83 -0
  124. package/src/_api/generated/helpers/validation-events.ts +52 -0
  125. package/src/_api/generated/index.ts +28 -0
  126. package/src/_api/generated/sdk.gen.ts +1250 -0
  127. package/src/_api/generated/types.gen.ts +1294 -0
  128. package/src/_api/index.ts +5 -23
  129. package/src/auth/context/AccountsContext.tsx +58 -89
  130. package/src/auth/context/AuthContext.tsx +3 -3
  131. package/src/auth/context/index.ts +2 -2
  132. package/src/auth/hooks/useDeleteAccount.ts +3 -1
  133. package/src/auth/hooks/useGithubAuth.ts +13 -11
  134. package/src/auth/hooks/useTokenRefresh.ts +7 -4
  135. package/src/auth/hooks/useTwoFactor.ts +15 -8
  136. package/src/auth/hooks/useTwoFactorSetup.ts +9 -5
  137. package/src/auth/hooks/useTwoFactorStatus.ts +5 -3
  138. package/src/auth/middlewares/tokenRefresh.ts +7 -4
  139. package/src/clients.ts +14 -51
  140. package/src/index.ts +35 -60
  141. package/src/server.ts +25 -23
  142. package/src/_api/BaseClient.ts +0 -22
  143. package/src/_api/generated/cfg_accounts/CLAUDE.md +0 -86
  144. package/src/_api/generated/cfg_accounts/_utils/fetchers/accounts.ts +0 -154
  145. package/src/_api/generated/cfg_accounts/_utils/fetchers/accounts__auth.ts +0 -95
  146. package/src/_api/generated/cfg_accounts/_utils/fetchers/accounts__oauth.ts +0 -285
  147. package/src/_api/generated/cfg_accounts/_utils/fetchers/accounts__user_profile.ts +0 -440
  148. package/src/_api/generated/cfg_accounts/_utils/fetchers/index.ts +0 -33
  149. package/src/_api/generated/cfg_accounts/_utils/hooks/accounts.ts +0 -64
  150. package/src/_api/generated/cfg_accounts/_utils/hooks/accounts__auth.ts +0 -44
  151. package/src/_api/generated/cfg_accounts/_utils/hooks/accounts__oauth.ts +0 -114
  152. package/src/_api/generated/cfg_accounts/_utils/hooks/accounts__user_profile.ts +0 -152
  153. package/src/_api/generated/cfg_accounts/_utils/hooks/index.ts +0 -33
  154. package/src/_api/generated/cfg_accounts/_utils/schemas/AccountDeleteResponse.schema.ts +0 -20
  155. package/src/_api/generated/cfg_accounts/_utils/schemas/CentrifugoToken.schema.ts +0 -22
  156. package/src/_api/generated/cfg_accounts/_utils/schemas/CfgAccountsProfileAvatarCreateRequest.schema.ts +0 -15
  157. package/src/_api/generated/cfg_accounts/_utils/schemas/OAuthAuthorizeRequestRequest.schema.ts +0 -20
  158. package/src/_api/generated/cfg_accounts/_utils/schemas/OAuthAuthorizeResponse.schema.ts +0 -20
  159. package/src/_api/generated/cfg_accounts/_utils/schemas/OAuthCallbackRequestRequest.schema.ts +0 -21
  160. package/src/_api/generated/cfg_accounts/_utils/schemas/OAuthConnection.schema.ts +0 -27
  161. package/src/_api/generated/cfg_accounts/_utils/schemas/OAuthDisconnectRequestRequest.schema.ts +0 -20
  162. package/src/_api/generated/cfg_accounts/_utils/schemas/OAuthError.schema.ts +0 -20
  163. package/src/_api/generated/cfg_accounts/_utils/schemas/OAuthProvidersResponse.schema.ts +0 -19
  164. package/src/_api/generated/cfg_accounts/_utils/schemas/OAuthTokenResponse.schema.ts +0 -46
  165. package/src/_api/generated/cfg_accounts/_utils/schemas/OTPErrorResponse.schema.ts +0 -41
  166. package/src/_api/generated/cfg_accounts/_utils/schemas/OTPRequestRequest.schema.ts +0 -20
  167. package/src/_api/generated/cfg_accounts/_utils/schemas/OTPRequestResponse.schema.ts +0 -19
  168. package/src/_api/generated/cfg_accounts/_utils/schemas/OTPVerifyRequest.schema.ts +0 -21
  169. package/src/_api/generated/cfg_accounts/_utils/schemas/OTPVerifyResponse.schema.ts +0 -45
  170. package/src/_api/generated/cfg_accounts/_utils/schemas/PatchedUserProfileUpdateRequest.schema.ts +0 -24
  171. package/src/_api/generated/cfg_accounts/_utils/schemas/TokenRefresh.schema.ts +0 -16
  172. package/src/_api/generated/cfg_accounts/_utils/schemas/TokenRefreshRequest.schema.ts +0 -15
  173. package/src/_api/generated/cfg_accounts/_utils/schemas/UserProfileUpdateRequest.schema.ts +0 -24
  174. package/src/_api/generated/cfg_accounts/_utils/schemas/index.ts +0 -41
  175. package/src/_api/generated/cfg_accounts/accounts/client.ts +0 -34
  176. package/src/_api/generated/cfg_accounts/accounts/index.ts +0 -4
  177. package/src/_api/generated/cfg_accounts/accounts/models.ts +0 -127
  178. package/src/_api/generated/cfg_accounts/accounts__auth/client.ts +0 -23
  179. package/src/_api/generated/cfg_accounts/accounts__auth/index.ts +0 -4
  180. package/src/_api/generated/cfg_accounts/accounts__auth/models.ts +0 -19
  181. package/src/_api/generated/cfg_accounts/accounts__oauth/client.ts +0 -67
  182. package/src/_api/generated/cfg_accounts/accounts__oauth/index.ts +0 -4
  183. package/src/_api/generated/cfg_accounts/accounts__oauth/models.ts +0 -127
  184. package/src/_api/generated/cfg_accounts/accounts__user_profile/client.ts +0 -94
  185. package/src/_api/generated/cfg_accounts/accounts__user_profile/index.ts +0 -4
  186. package/src/_api/generated/cfg_accounts/accounts__user_profile/models.ts +0 -98
  187. package/src/_api/generated/cfg_accounts/api-instance.ts +0 -181
  188. package/src/_api/generated/cfg_accounts/client.ts +0 -339
  189. package/src/_api/generated/cfg_accounts/enums.ts +0 -10
  190. package/src/_api/generated/cfg_accounts/errors.ts +0 -123
  191. package/src/_api/generated/cfg_accounts/http.ts +0 -160
  192. package/src/_api/generated/cfg_accounts/index.ts +0 -338
  193. package/src/_api/generated/cfg_accounts/logger.ts +0 -261
  194. package/src/_api/generated/cfg_accounts/retry.ts +0 -177
  195. package/src/_api/generated/cfg_accounts/schema.json +0 -1576
  196. package/src/_api/generated/cfg_accounts/storage.ts +0 -163
  197. package/src/_api/generated/cfg_accounts/validation-events.ts +0 -135
  198. package/src/_api/generated/cfg_centrifugo/CLAUDE.md +0 -60
  199. package/src/_api/generated/cfg_centrifugo/_utils/fetchers/centrifugo__centrifugo_auth.ts +0 -94
  200. package/src/_api/generated/cfg_centrifugo/_utils/fetchers/index.ts +0 -30
  201. package/src/_api/generated/cfg_centrifugo/_utils/hooks/centrifugo__centrifugo_auth.ts +0 -39
  202. package/src/_api/generated/cfg_centrifugo/_utils/hooks/index.ts +0 -30
  203. package/src/_api/generated/cfg_centrifugo/_utils/schemas/ConnectionTokenResponse.schema.ts +0 -22
  204. package/src/_api/generated/cfg_centrifugo/_utils/schemas/index.ts +0 -21
  205. package/src/_api/generated/cfg_centrifugo/api-instance.ts +0 -181
  206. package/src/_api/generated/cfg_centrifugo/centrifugo__centrifugo_auth/client.ts +0 -27
  207. package/src/_api/generated/cfg_centrifugo/centrifugo__centrifugo_auth/index.ts +0 -4
  208. package/src/_api/generated/cfg_centrifugo/centrifugo__centrifugo_auth/models.ts +0 -18
  209. package/src/_api/generated/cfg_centrifugo/client.ts +0 -330
  210. package/src/_api/generated/cfg_centrifugo/errors.ts +0 -123
  211. package/src/_api/generated/cfg_centrifugo/http.ts +0 -160
  212. package/src/_api/generated/cfg_centrifugo/index.ts +0 -316
  213. package/src/_api/generated/cfg_centrifugo/logger.ts +0 -261
  214. package/src/_api/generated/cfg_centrifugo/retry.ts +0 -177
  215. package/src/_api/generated/cfg_centrifugo/schema.json +0 -118
  216. package/src/_api/generated/cfg_centrifugo/storage.ts +0 -163
  217. package/src/_api/generated/cfg_centrifugo/validation-events.ts +0 -135
  218. package/src/_api/generated/cfg_totp/CLAUDE.md +0 -83
  219. package/src/_api/generated/cfg_totp/_utils/fetchers/index.ts +0 -34
  220. package/src/_api/generated/cfg_totp/_utils/fetchers/totp.ts +0 -50
  221. package/src/_api/generated/cfg_totp/_utils/fetchers/totp__backup_codes.ts +0 -153
  222. package/src/_api/generated/cfg_totp/_utils/fetchers/totp__totp_management.ts +0 -109
  223. package/src/_api/generated/cfg_totp/_utils/fetchers/totp__totp_setup.ts +0 -154
  224. package/src/_api/generated/cfg_totp/_utils/fetchers/totp__totp_verification.ts +0 -153
  225. package/src/_api/generated/cfg_totp/_utils/hooks/index.ts +0 -34
  226. package/src/_api/generated/cfg_totp/_utils/hooks/totp.ts +0 -43
  227. package/src/_api/generated/cfg_totp/_utils/hooks/totp__backup_codes.ts +0 -60
  228. package/src/_api/generated/cfg_totp/_utils/hooks/totp__totp_management.ts +0 -59
  229. package/src/_api/generated/cfg_totp/_utils/hooks/totp__totp_setup.ts +0 -64
  230. package/src/_api/generated/cfg_totp/_utils/hooks/totp__totp_verification.ts +0 -63
  231. package/src/_api/generated/cfg_totp/_utils/schemas/BackupCodesRegenerateRequest.schema.ts +0 -19
  232. package/src/_api/generated/cfg_totp/_utils/schemas/BackupCodesRegenerateResponse.schema.ts +0 -20
  233. package/src/_api/generated/cfg_totp/_utils/schemas/BackupCodesStatus.schema.ts +0 -21
  234. package/src/_api/generated/cfg_totp/_utils/schemas/ConfirmSetupRequest.schema.ts +0 -20
  235. package/src/_api/generated/cfg_totp/_utils/schemas/ConfirmSetupResponse.schema.ts +0 -21
  236. package/src/_api/generated/cfg_totp/_utils/schemas/DeviceList.schema.ts +0 -26
  237. package/src/_api/generated/cfg_totp/_utils/schemas/DeviceListResponse.schema.ts +0 -21
  238. package/src/_api/generated/cfg_totp/_utils/schemas/DisableRequest.schema.ts +0 -19
  239. package/src/_api/generated/cfg_totp/_utils/schemas/SetupRequest.schema.ts +0 -19
  240. package/src/_api/generated/cfg_totp/_utils/schemas/SetupResponse.schema.ts +0 -23
  241. package/src/_api/generated/cfg_totp/_utils/schemas/VerifyBackupRequest.schema.ts +0 -20
  242. package/src/_api/generated/cfg_totp/_utils/schemas/VerifyRequest.schema.ts +0 -20
  243. package/src/_api/generated/cfg_totp/_utils/schemas/VerifyResponse.schema.ts +0 -25
  244. package/src/_api/generated/cfg_totp/_utils/schemas/index.ts +0 -34
  245. package/src/_api/generated/cfg_totp/api-instance.ts +0 -181
  246. package/src/_api/generated/cfg_totp/client.ts +0 -342
  247. package/src/_api/generated/cfg_totp/enums.ts +0 -13
  248. package/src/_api/generated/cfg_totp/errors.ts +0 -123
  249. package/src/_api/generated/cfg_totp/http.ts +0 -160
  250. package/src/_api/generated/cfg_totp/index.ts +0 -345
  251. package/src/_api/generated/cfg_totp/logger.ts +0 -261
  252. package/src/_api/generated/cfg_totp/retry.ts +0 -177
  253. package/src/_api/generated/cfg_totp/schema.json +0 -910
  254. package/src/_api/generated/cfg_totp/storage.ts +0 -163
  255. package/src/_api/generated/cfg_totp/totp/client.ts +0 -24
  256. package/src/_api/generated/cfg_totp/totp/index.ts +0 -4
  257. package/src/_api/generated/cfg_totp/totp/models.ts +0 -4
  258. package/src/_api/generated/cfg_totp/totp__backup_codes/client.ts +0 -32
  259. package/src/_api/generated/cfg_totp/totp__backup_codes/index.ts +0 -4
  260. package/src/_api/generated/cfg_totp/totp__backup_codes/models.ts +0 -38
  261. package/src/_api/generated/cfg_totp/totp__totp_management/client.ts +0 -31
  262. package/src/_api/generated/cfg_totp/totp__totp_management/index.ts +0 -4
  263. package/src/_api/generated/cfg_totp/totp__totp_management/models.ts +0 -46
  264. package/src/_api/generated/cfg_totp/totp__totp_setup/client.ts +0 -33
  265. package/src/_api/generated/cfg_totp/totp__totp_setup/index.ts +0 -4
  266. package/src/_api/generated/cfg_totp/totp__totp_setup/models.ts +0 -55
  267. package/src/_api/generated/cfg_totp/totp__totp_verification/client.ts +0 -33
  268. package/src/_api/generated/cfg_totp/totp__totp_verification/index.ts +0 -4
  269. package/src/_api/generated/cfg_totp/totp__totp_verification/models.ts +0 -74
  270. package/src/_api/generated/cfg_totp/validation-events.ts +0 -135
  271. package/src/hooks/accounts.ts +0 -8
  272. package/src/hooks/index.ts +0 -10
@@ -1,345 +0,0 @@
1
- // @ts-nocheck
2
- // Auto-generated by DjangoCFG - see CLAUDE.md
3
- /**
4
- * Django CFG API - API Client with JWT Management
5
- *
6
- * Usage:
7
- * ```typescript
8
- * import { API } from './api';
9
- *
10
- * const api = new API('https://api.example.com');
11
- *
12
- * // Set JWT token
13
- * api.setToken('your-jwt-token', 'refresh-token');
14
- *
15
- * // Use API
16
- * const posts = await api.posts.list();
17
- * const user = await api.users.retrieve(1);
18
- *
19
- * // Check authentication
20
- * if (api.isAuthenticated()) {
21
- * // ...
22
- * }
23
- *
24
- * // Custom storage with logging (for Electron/Node.js)
25
- * import { MemoryStorageAdapter, APILogger } from './storage';
26
- * const logger = new APILogger({ enabled: true, logLevel: 'debug' });
27
- * const api = new API('https://api.example.com', {
28
- * storage: new MemoryStorageAdapter(logger),
29
- * loggerConfig: { enabled: true, logLevel: 'debug' }
30
- * });
31
- *
32
- * // Get OpenAPI schema
33
- * const schema = api.getSchema();
34
- * ```
35
- */
36
-
37
- import { APIClient } from "./client";
38
- import {
39
- StorageAdapter,
40
- LocalStorageAdapter,
41
- CookieStorageAdapter,
42
- MemoryStorageAdapter
43
- } from "./storage";
44
- import type { RetryConfig } from "./retry";
45
- import type { LoggerConfig } from "./logger";
46
- import { APILogger } from "./logger";
47
- import { BackupCodes } from "./totp__backup_codes/client";
48
- import { TotpManagement } from "./totp__totp_management/client";
49
- import { TotpSetup } from "./totp__totp_setup/client";
50
- import { TotpVerification } from "./totp__totp_verification/client";
51
- import { Totp } from "./totp/client";
52
- export * as BackupCodesTypes from "./totp__backup_codes/models";
53
- // Note: Direct exports (export * from) are removed to avoid duplicate type conflicts
54
- // Use namespace exports like CfgAccountsTypes.User or import from specific modules
55
- export * as TotpManagementTypes from "./totp__totp_management/models";
56
- // Note: Direct exports (export * from) are removed to avoid duplicate type conflicts
57
- // Use namespace exports like CfgAccountsTypes.User or import from specific modules
58
- export * as TotpSetupTypes from "./totp__totp_setup/models";
59
- // Note: Direct exports (export * from) are removed to avoid duplicate type conflicts
60
- // Use namespace exports like CfgAccountsTypes.User or import from specific modules
61
- export * as TotpVerificationTypes from "./totp__totp_verification/models";
62
- // Note: Direct exports (export * from) are removed to avoid duplicate type conflicts
63
- // Use namespace exports like CfgAccountsTypes.User or import from specific modules
64
- export * as TotpTypes from "./totp/models";
65
- // Note: Direct exports (export * from) are removed to avoid duplicate type conflicts
66
- // Use namespace exports like CfgAccountsTypes.User or import from specific modules
67
- export * as Enums from "./enums";
68
-
69
- // Re-export Zod schemas for runtime validation
70
- export * as Schemas from "./_utils/schemas";
71
- // Also export all schemas directly for convenience
72
- export * from "./_utils/schemas";
73
-
74
- // Re-export Zod validation events for browser integration
75
- export type { ValidationErrorDetail, ValidationErrorEvent } from "./validation-events";
76
- export { dispatchValidationError, onValidationError, formatZodError } from "./validation-events";
77
-
78
- // Re-export typed fetchers for universal usage
79
- export * as Fetchers from "./_utils/fetchers";
80
- export * from "./_utils/fetchers";
81
-
82
- // Re-export API instance configuration functions
83
- export {
84
- configureAPI,
85
- getAPIInstance,
86
- reconfigureAPI,
87
- clearAPITokens,
88
- resetAPI,
89
- isAPIConfigured
90
- } from "./api-instance";
91
- // NOTE: SWR hooks are generated in ./_utils/hooks/ but NOT exported here to keep
92
- // the main bundle server-safe. Import hooks directly from the hooks directory:
93
- // import { useUsers } from './_utils/hooks';
94
- // Or use a separate entry point like '@djangocfg/api/hooks' for client components.
95
-
96
- // Re-export core client
97
- export { APIClient };
98
-
99
- // Re-export storage adapters for convenience
100
- export type { StorageAdapter };
101
- export { LocalStorageAdapter, CookieStorageAdapter, MemoryStorageAdapter };
102
-
103
- // Re-export error classes for convenience
104
- export { APIError, NetworkError } from "./errors";
105
-
106
- // Re-export HTTP adapters for custom implementations
107
- export type { HttpClientAdapter, HttpRequest, HttpResponse } from "./http";
108
- export { FetchAdapter, KeepAliveFetchAdapter } from "./http";
109
-
110
- // Re-export logger types and classes
111
- export type { LoggerConfig, RequestLog, ResponseLog, ErrorLog } from "./logger";
112
- export { APILogger } from "./logger";
113
-
114
- // Re-export retry configuration and utilities
115
- export type { RetryConfig, FailedAttemptInfo } from "./retry";
116
- export { withRetry, shouldRetry, DEFAULT_RETRY_CONFIG } from "./retry";
117
-
118
- export const TOKEN_KEY = "auth_token";
119
- export const REFRESH_TOKEN_KEY = "refresh_token";
120
-
121
- /** Auto-detect locale from cookie NEXT_LOCALE or navigator.language */
122
- function detectLocale(): string | null {
123
- try {
124
- if (typeof document !== 'undefined') {
125
- const match = document.cookie.match(/(?:^|;\s*)NEXT_LOCALE=([^;]*)/);
126
- if (match) return match[1];
127
- }
128
- if (typeof navigator !== 'undefined' && navigator.language) {
129
- return navigator.language;
130
- }
131
- } catch {}
132
- return null;
133
- }
134
-
135
- export interface APIOptions {
136
- /** Custom storage adapter (defaults to LocalStorageAdapter) */
137
- storage?: StorageAdapter;
138
- /** Custom HTTP client adapter (defaults to FetchAdapter) */
139
- httpClient?: HttpClientAdapter;
140
- /** Retry configuration for failed requests */
141
- retryConfig?: RetryConfig;
142
- /** Logger configuration */
143
- loggerConfig?: Partial<LoggerConfig>;
144
- /** Locale for Accept-Language header (e.g. 'en', 'ko', 'ru') */
145
- locale?: string;
146
- }
147
-
148
- export class API {
149
- private baseUrl: string;
150
- private _client: APIClient;
151
- private _token: string | null = null;
152
- private _refreshToken: string | null = null;
153
- private _locale: string | null = null;
154
- private storage: StorageAdapter;
155
- private options?: APIOptions;
156
-
157
- // Sub-clients
158
- public backup_codes!: BackupCodes;
159
- public totp_management!: TotpManagement;
160
- public totp_setup!: TotpSetup;
161
- public totp_verification!: TotpVerification;
162
- public totp!: Totp;
163
-
164
- constructor(baseUrl: string, options?: APIOptions) {
165
- this.baseUrl = baseUrl;
166
- this.options = options;
167
-
168
- // Create logger if config provided
169
- const logger = options?.loggerConfig ? new APILogger(options.loggerConfig) : undefined;
170
-
171
- // Initialize storage with logger
172
- this.storage = options?.storage || new LocalStorageAdapter(logger);
173
-
174
- this._locale = options?.locale || null;
175
-
176
- this._loadTokensFromStorage();
177
-
178
- // Initialize APIClient with token getter for URL authentication
179
- this._client = new APIClient(this.baseUrl, {
180
- httpClient: this.options?.httpClient,
181
- retryConfig: this.options?.retryConfig,
182
- loggerConfig: this.options?.loggerConfig,
183
- tokenGetter: () => this.getToken(),
184
- });
185
-
186
- // Always inject auth header wrapper (reads token dynamically from storage)
187
- this._injectAuthHeader();
188
-
189
- // Initialize sub-clients from APIClient
190
- this.backup_codes = this._client.backup_codes;
191
- this.totp_management = this._client.totp_management;
192
- this.totp_setup = this._client.totp_setup;
193
- this.totp_verification = this._client.totp_verification;
194
- this.totp = this._client.totp;
195
- }
196
-
197
- private _loadTokensFromStorage(): void {
198
- this._token = this.storage.getItem(TOKEN_KEY);
199
- this._refreshToken = this.storage.getItem(REFRESH_TOKEN_KEY);
200
- }
201
-
202
- private _reinitClients(): void {
203
- this._client = new APIClient(this.baseUrl, {
204
- httpClient: this.options?.httpClient,
205
- retryConfig: this.options?.retryConfig,
206
- loggerConfig: this.options?.loggerConfig,
207
- tokenGetter: () => this.getToken(),
208
- });
209
-
210
- // Always inject auth header wrapper (reads token dynamically from storage)
211
- this._injectAuthHeader();
212
-
213
- // Reinitialize sub-clients
214
- this.backup_codes = this._client.backup_codes;
215
- this.totp_management = this._client.totp_management;
216
- this.totp_setup = this._client.totp_setup;
217
- this.totp_verification = this._client.totp_verification;
218
- this.totp = this._client.totp;
219
- }
220
-
221
- private _injectAuthHeader(): void {
222
- // Override request method to inject auth header
223
- const originalRequest = this._client.request.bind(this._client);
224
- this._client.request = async <T>(
225
- method: string,
226
- path: string,
227
- options?: { params?: Record<string, any>; body?: any; formData?: FormData; headers?: Record<string, string> }
228
- ): Promise<T> => {
229
- // Read token from storage dynamically (supports JWT injection after instantiation)
230
- const token = this.getToken();
231
- const locale = this._locale || detectLocale();
232
- const mergedOptions = {
233
- ...options,
234
- headers: {
235
- ...(options?.headers || {}),
236
- ...(token ? { 'Authorization': `Bearer ${token}` } : {}),
237
- ...(locale ? { 'Accept-Language': locale } : {}),
238
- },
239
- };
240
-
241
- return originalRequest(method, path, mergedOptions);
242
- };
243
- }
244
-
245
- /**
246
- * Get current JWT token
247
- */
248
- getToken(): string | null {
249
- return this.storage.getItem(TOKEN_KEY);
250
- }
251
-
252
- /**
253
- * Get current refresh token
254
- */
255
- getRefreshToken(): string | null {
256
- return this.storage.getItem(REFRESH_TOKEN_KEY);
257
- }
258
-
259
- /**
260
- * Set JWT token and refresh token
261
- * @param token - JWT access token
262
- * @param refreshToken - JWT refresh token (optional)
263
- */
264
- setToken(token: string, refreshToken?: string): void {
265
- this._token = token;
266
- this.storage.setItem(TOKEN_KEY, token);
267
-
268
- if (refreshToken) {
269
- this._refreshToken = refreshToken;
270
- this.storage.setItem(REFRESH_TOKEN_KEY, refreshToken);
271
- }
272
-
273
- // Reinitialize clients with new token
274
- this._reinitClients();
275
- }
276
-
277
- /**
278
- * Clear all tokens
279
- */
280
- clearTokens(): void {
281
- this._token = null;
282
- this._refreshToken = null;
283
- this.storage.removeItem(TOKEN_KEY);
284
- this.storage.removeItem(REFRESH_TOKEN_KEY);
285
-
286
- // Reinitialize clients without token
287
- this._reinitClients();
288
- }
289
-
290
- /**
291
- * Check if user is authenticated
292
- */
293
- isAuthenticated(): boolean {
294
- return !!this.getToken();
295
- }
296
-
297
- /**
298
- * Update base URL and reinitialize clients
299
- * @param url - New base URL
300
- */
301
- setBaseUrl(url: string): void {
302
- this.baseUrl = url;
303
- this._reinitClients();
304
- }
305
-
306
- /**
307
- * Get current base URL
308
- */
309
- getBaseUrl(): string {
310
- return this.baseUrl;
311
- }
312
-
313
- /**
314
- * Set locale for Accept-Language header
315
- * @param locale - Locale string (e.g. 'en', 'ko', 'ru') or null to clear
316
- */
317
- setLocale(locale: string | null): void {
318
- this._locale = locale;
319
- }
320
-
321
- /**
322
- * Get current locale
323
- */
324
- getLocale(): string | null {
325
- return this._locale;
326
- }
327
-
328
- /**
329
- * Get OpenAPI schema path
330
- * @returns Path to the OpenAPI schema JSON file
331
- *
332
- * Note: The OpenAPI schema is available in the schema.json file.
333
- * You can load it dynamically using:
334
- * ```typescript
335
- * const schema = await fetch('./schema.json').then(r => r.json());
336
- * // or using fs in Node.js:
337
- * // const schema = JSON.parse(fs.readFileSync('./schema.json', 'utf-8'));
338
- * ```
339
- */
340
- getSchemaPath(): string {
341
- return './schema.json';
342
- }
343
- }
344
-
345
- export default API;
@@ -1,261 +0,0 @@
1
- // @ts-nocheck
2
- // Auto-generated by DjangoCFG - see CLAUDE.md
3
- /**
4
- * API Logger with Consola
5
- * Beautiful console logging for API requests and responses
6
- *
7
- * Installation:
8
- * npm install consola
9
- */
10
-
11
- import { type ConsolaInstance, createConsola } from 'consola';
12
-
13
- /**
14
- * Request log data
15
- */
16
- export interface RequestLog {
17
- method: string;
18
- url: string;
19
- headers?: Record<string, string>;
20
- body?: any;
21
- timestamp: number;
22
- }
23
-
24
- /**
25
- * Response log data
26
- */
27
- export interface ResponseLog {
28
- status: number;
29
- statusText: string;
30
- data?: any;
31
- duration: number;
32
- timestamp: number;
33
- }
34
-
35
- /**
36
- * Error log data
37
- */
38
- export interface ErrorLog {
39
- message: string;
40
- statusCode?: number;
41
- fieldErrors?: Record<string, string[]>;
42
- duration: number;
43
- timestamp: number;
44
- }
45
-
46
- /**
47
- * Logger configuration
48
- */
49
- export interface LoggerConfig {
50
- /** Enable logging */
51
- enabled: boolean;
52
- /** Log requests */
53
- logRequests: boolean;
54
- /** Log responses */
55
- logResponses: boolean;
56
- /** Log errors */
57
- logErrors: boolean;
58
- /** Log request/response bodies */
59
- logBodies: boolean;
60
- /** Log headers (excluding sensitive ones) */
61
- logHeaders: boolean;
62
- /** Custom consola instance */
63
- consola?: ConsolaInstance;
64
- }
65
-
66
- /**
67
- * Default logger configuration
68
- */
69
- const DEFAULT_CONFIG: LoggerConfig = {
70
- enabled: process.env.NODE_ENV !== 'production',
71
- logRequests: true,
72
- logResponses: true,
73
- logErrors: true,
74
- logBodies: true,
75
- logHeaders: false,
76
- };
77
-
78
- /**
79
- * Sensitive header names to filter out
80
- */
81
- const SENSITIVE_HEADERS = [
82
- 'authorization',
83
- 'cookie',
84
- 'set-cookie',
85
- 'x-api-key',
86
- 'x-csrf-token',
87
- ];
88
-
89
- /**
90
- * API Logger class
91
- */
92
- export class APILogger {
93
- private config: LoggerConfig;
94
- private consola: ConsolaInstance;
95
-
96
- constructor(config: Partial<LoggerConfig> = {}) {
97
- this.config = { ...DEFAULT_CONFIG, ...config };
98
- this.consola = config.consola || createConsola({
99
- level: this.config.enabled ? 4 : 0,
100
- });
101
- }
102
-
103
- /**
104
- * Enable logging
105
- */
106
- enable(): void {
107
- this.config.enabled = true;
108
- }
109
-
110
- /**
111
- * Disable logging
112
- */
113
- disable(): void {
114
- this.config.enabled = false;
115
- }
116
-
117
- /**
118
- * Update configuration
119
- */
120
- setConfig(config: Partial<LoggerConfig>): void {
121
- this.config = { ...this.config, ...config };
122
- }
123
-
124
- /**
125
- * Filter sensitive headers
126
- */
127
- private filterHeaders(headers?: Record<string, string>): Record<string, string> {
128
- if (!headers) return {};
129
-
130
- const filtered: Record<string, string> = {};
131
- Object.keys(headers).forEach((key) => {
132
- const lowerKey = key.toLowerCase();
133
- if (SENSITIVE_HEADERS.includes(lowerKey)) {
134
- filtered[key] = '***';
135
- } else {
136
- filtered[key] = headers[key] || '';
137
- }
138
- });
139
-
140
- return filtered;
141
- }
142
-
143
- /**
144
- * Log request
145
- */
146
- logRequest(request: RequestLog): void {
147
- if (!this.config.enabled || !this.config.logRequests) return;
148
-
149
- const { method, url, headers, body } = request;
150
-
151
- this.consola.start(`${method} ${url}`);
152
-
153
- if (this.config.logHeaders && headers) {
154
- this.consola.debug('Headers:', this.filterHeaders(headers));
155
- }
156
-
157
- if (this.config.logBodies && body) {
158
- this.consola.debug('Body:', body);
159
- }
160
- }
161
-
162
- /**
163
- * Log response
164
- */
165
- logResponse(request: RequestLog, response: ResponseLog): void {
166
- if (!this.config.enabled || !this.config.logResponses) return;
167
-
168
- const { method, url } = request;
169
- const { status, statusText, data, duration } = response;
170
-
171
- const statusColor = status >= 500 ? 'red'
172
- : status >= 400 ? 'yellow'
173
- : status >= 300 ? 'cyan'
174
- : 'green';
175
-
176
- this.consola.success(
177
- `${method} ${url} ${status} ${statusText} (${duration}ms)`
178
- );
179
-
180
- if (this.config.logBodies && data) {
181
- this.consola.debug('Response:', data);
182
- }
183
- }
184
-
185
- /**
186
- * Log error
187
- */
188
- logError(request: RequestLog, error: ErrorLog): void {
189
- if (!this.config.enabled || !this.config.logErrors) return;
190
-
191
- const { method, url } = request;
192
- const { message, statusCode, fieldErrors, duration } = error;
193
-
194
- this.consola.error(
195
- `${method} ${url} ${statusCode || 'Network'} Error (${duration}ms)`
196
- );
197
-
198
- this.consola.error('Message:', message);
199
-
200
- if (fieldErrors && Object.keys(fieldErrors).length > 0) {
201
- this.consola.error('Field Errors:');
202
- Object.entries(fieldErrors).forEach(([field, errors]) => {
203
- errors.forEach((err) => {
204
- this.consola.error(` • ${field}: ${err}`);
205
- });
206
- });
207
- }
208
- }
209
-
210
- /**
211
- * Log general info
212
- */
213
- info(message: string, ...args: any[]): void {
214
- if (!this.config.enabled) return;
215
- this.consola.info(message, ...args);
216
- }
217
-
218
- /**
219
- * Log warning
220
- */
221
- warn(message: string, ...args: any[]): void {
222
- if (!this.config.enabled) return;
223
- this.consola.warn(message, ...args);
224
- }
225
-
226
- /**
227
- * Log error
228
- */
229
- error(message: string, ...args: any[]): void {
230
- if (!this.config.enabled) return;
231
- this.consola.error(message, ...args);
232
- }
233
-
234
- /**
235
- * Log debug
236
- */
237
- debug(message: string, ...args: any[]): void {
238
- if (!this.config.enabled) return;
239
- this.consola.debug(message, ...args);
240
- }
241
-
242
- /**
243
- * Log success
244
- */
245
- success(message: string, ...args: any[]): void {
246
- if (!this.config.enabled) return;
247
- this.consola.success(message, ...args);
248
- }
249
-
250
- /**
251
- * Create a sub-logger with prefix
252
- */
253
- withTag(tag: string): ConsolaInstance {
254
- return this.consola.withTag(tag);
255
- }
256
- }
257
-
258
- /**
259
- * Default logger instance
260
- */
261
- export const defaultLogger = new APILogger();