@djangocfg/api 2.1.321 → 2.1.327

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 (293) hide show
  1. package/dist/auth-server.cjs +4265 -1169
  2. package/dist/auth-server.cjs.map +1 -1
  3. package/dist/auth-server.mjs +4265 -1159
  4. package/dist/auth-server.mjs.map +1 -1
  5. package/dist/auth.cjs +4150 -3053
  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 +4139 -3042
  10. package/dist/auth.mjs.map +1 -1
  11. package/dist/clients.cjs +3932 -4031
  12. package/dist/clients.cjs.map +1 -1
  13. package/dist/clients.d.cts +2408 -2671
  14. package/dist/clients.d.ts +2408 -2671
  15. package/dist/clients.mjs +3945 -4038
  16. package/dist/clients.mjs.map +1 -1
  17. package/dist/index.cjs +4214 -2713
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.d.cts +2758 -1828
  20. package/dist/index.d.ts +2758 -1828
  21. package/dist/index.mjs +4183 -2676
  22. package/dist/index.mjs.map +1 -1
  23. package/package.json +2 -7
  24. package/src/_api/generated/_shared/errors.ts +70 -0
  25. package/src/_api/generated/_shared/index.ts +25 -0
  26. package/src/_api/generated/_shared/logger.ts +123 -0
  27. package/src/_api/generated/_shared/storage.ts +83 -0
  28. package/src/_api/generated/_shared/validation-events.ts +52 -0
  29. package/src/_api/generated/cfg_accounts/api.ts +187 -0
  30. package/src/_api/generated/cfg_accounts/client/client.gen.ts +280 -0
  31. package/src/_api/generated/cfg_accounts/client/index.ts +25 -0
  32. package/src/_api/generated/cfg_accounts/client/types.gen.ts +217 -0
  33. package/src/_api/generated/cfg_accounts/client/utils.gen.ts +318 -0
  34. package/src/_api/generated/cfg_accounts/client.gen.ts +16 -0
  35. package/src/_api/generated/cfg_accounts/core/auth.gen.ts +41 -0
  36. package/src/_api/generated/cfg_accounts/core/bodySerializer.gen.ts +82 -0
  37. package/src/_api/generated/cfg_accounts/core/params.gen.ts +169 -0
  38. package/src/_api/generated/cfg_accounts/core/pathSerializer.gen.ts +171 -0
  39. package/src/_api/generated/cfg_accounts/core/queryKeySerializer.gen.ts +117 -0
  40. package/src/_api/generated/cfg_accounts/core/serverSentEvents.gen.ts +242 -0
  41. package/src/_api/generated/cfg_accounts/core/types.gen.ts +104 -0
  42. package/src/_api/generated/cfg_accounts/core/utils.gen.ts +140 -0
  43. package/src/_api/generated/cfg_accounts/events.ts +198 -0
  44. package/src/_api/generated/cfg_accounts/hooks/index.ts +18 -0
  45. package/src/_api/generated/cfg_accounts/hooks/useCfgAccountsOauthConnectionsList.ts +26 -0
  46. package/src/_api/generated/cfg_accounts/hooks/useCfgAccountsOauthDisconnectCreate.ts +24 -0
  47. package/src/_api/generated/cfg_accounts/hooks/useCfgAccountsOauthGithubAuthorizeCreate.ts +24 -0
  48. package/src/_api/generated/cfg_accounts/hooks/useCfgAccountsOauthGithubCallbackCreate.ts +24 -0
  49. package/src/_api/generated/cfg_accounts/hooks/useCfgAccountsOauthProvidersRetrieve.ts +26 -0
  50. package/src/_api/generated/cfg_accounts/hooks/useCfgAccountsOtpRequestCreate.ts +24 -0
  51. package/src/_api/generated/cfg_accounts/hooks/useCfgAccountsOtpVerifyCreate.ts +24 -0
  52. package/src/_api/generated/cfg_accounts/hooks/useCfgAccountsProfileAvatarCreate.ts +24 -0
  53. package/src/_api/generated/cfg_accounts/hooks/useCfgAccountsProfileDeleteCreate.ts +24 -0
  54. package/src/_api/generated/cfg_accounts/hooks/useCfgAccountsProfilePartialPartialUpdate.ts +24 -0
  55. package/src/_api/generated/cfg_accounts/hooks/useCfgAccountsProfilePartialUpdate.ts +24 -0
  56. package/src/_api/generated/cfg_accounts/hooks/useCfgAccountsProfileRetrieve.ts +26 -0
  57. package/src/_api/generated/cfg_accounts/hooks/useCfgAccountsProfileUpdatePartialUpdate.ts +24 -0
  58. package/src/_api/generated/cfg_accounts/hooks/useCfgAccountsProfileUpdateUpdate.ts +24 -0
  59. package/src/_api/generated/cfg_accounts/hooks/useCfgAccountsTokenRefreshCreate.ts +24 -0
  60. package/src/_api/generated/cfg_accounts/index.ts +26 -335
  61. package/src/_api/generated/cfg_accounts/schemas/AccountDeleteResponse.ts +12 -0
  62. package/src/_api/generated/cfg_accounts/schemas/CentrifugoToken.ts +14 -0
  63. package/src/_api/generated/cfg_accounts/schemas/CfgUserUpdateRequest.ts +16 -0
  64. package/src/_api/generated/cfg_accounts/schemas/OAuthAuthorizeRequestRequest.ts +12 -0
  65. package/src/_api/generated/cfg_accounts/schemas/OAuthAuthorizeResponse.ts +12 -0
  66. package/src/_api/generated/cfg_accounts/schemas/OAuthCallbackRequestRequest.ts +13 -0
  67. package/src/_api/generated/cfg_accounts/schemas/OAuthConnection.ts +19 -0
  68. package/src/_api/generated/cfg_accounts/schemas/OAuthDisconnectRequestRequest.ts +12 -0
  69. package/src/_api/generated/cfg_accounts/schemas/OAuthError.ts +12 -0
  70. package/src/_api/generated/cfg_accounts/schemas/OAuthProvidersResponse.ts +11 -0
  71. package/src/_api/generated/cfg_accounts/schemas/OAuthTokenResponse.ts +18 -0
  72. package/src/_api/generated/cfg_accounts/schemas/OTPErrorResponse.ts +13 -0
  73. package/src/_api/generated/cfg_accounts/schemas/OTPRequestRequest.ts +12 -0
  74. package/src/_api/generated/cfg_accounts/schemas/OTPRequestResponse.ts +11 -0
  75. package/src/_api/generated/cfg_accounts/schemas/OTPVerifyRequest.ts +13 -0
  76. package/src/_api/generated/cfg_accounts/schemas/OTPVerifyResponse.ts +17 -0
  77. package/src/_api/generated/cfg_accounts/schemas/PatchedCfgUserUpdateRequest.ts +16 -0
  78. package/src/_api/generated/cfg_accounts/schemas/ProviderEnum.ts +9 -0
  79. package/src/_api/generated/cfg_accounts/schemas/TokenRefresh.ts +12 -0
  80. package/src/_api/generated/cfg_accounts/schemas/TokenRefreshRequest.ts +11 -0
  81. package/src/_api/generated/cfg_accounts/{_utils/schemas/User.schema.ts → schemas/User.ts} +8 -16
  82. package/src/_api/generated/cfg_accounts/schemas/index.ts +24 -0
  83. package/src/_api/generated/cfg_accounts/sdk.gen.ts +796 -0
  84. package/src/_api/generated/cfg_accounts/types.gen.ts +764 -0
  85. package/src/_api/generated/cfg_centrifugo/api.ts +164 -0
  86. package/src/_api/generated/cfg_centrifugo/client/client.gen.ts +280 -0
  87. package/src/_api/generated/cfg_centrifugo/client/index.ts +25 -0
  88. package/src/_api/generated/cfg_centrifugo/client/types.gen.ts +217 -0
  89. package/src/_api/generated/cfg_centrifugo/client/utils.gen.ts +318 -0
  90. package/src/_api/generated/cfg_centrifugo/client.gen.ts +16 -0
  91. package/src/_api/generated/cfg_centrifugo/core/auth.gen.ts +41 -0
  92. package/src/_api/generated/cfg_centrifugo/core/bodySerializer.gen.ts +82 -0
  93. package/src/_api/generated/cfg_centrifugo/core/params.gen.ts +169 -0
  94. package/src/_api/generated/cfg_centrifugo/core/pathSerializer.gen.ts +171 -0
  95. package/src/_api/generated/cfg_centrifugo/core/queryKeySerializer.gen.ts +117 -0
  96. package/src/_api/generated/cfg_centrifugo/core/serverSentEvents.gen.ts +242 -0
  97. package/src/_api/generated/cfg_centrifugo/core/types.gen.ts +104 -0
  98. package/src/_api/generated/cfg_centrifugo/core/utils.gen.ts +140 -0
  99. package/src/_api/generated/cfg_centrifugo/events.ts +198 -0
  100. package/src/_api/generated/cfg_centrifugo/hooks/index.ts +4 -0
  101. package/src/_api/generated/cfg_centrifugo/hooks/useCfgCentrifugoAuthTokenRetrieve.ts +26 -0
  102. package/src/_api/generated/cfg_centrifugo/index.ts +26 -313
  103. package/src/_api/generated/cfg_centrifugo/schemas/ConnectionTokenResponse.ts +14 -0
  104. package/src/_api/generated/cfg_centrifugo/schemas/index.ts +4 -0
  105. package/src/_api/generated/cfg_centrifugo/sdk.gen.ts +64 -0
  106. package/src/_api/generated/cfg_centrifugo/types.gen.ts +61 -0
  107. package/src/_api/generated/cfg_totp/api.ts +181 -0
  108. package/src/_api/generated/cfg_totp/client/client.gen.ts +280 -0
  109. package/src/_api/generated/cfg_totp/client/index.ts +25 -0
  110. package/src/_api/generated/cfg_totp/client/types.gen.ts +217 -0
  111. package/src/_api/generated/cfg_totp/client/utils.gen.ts +318 -0
  112. package/src/_api/generated/cfg_totp/client.gen.ts +16 -0
  113. package/src/_api/generated/cfg_totp/core/auth.gen.ts +41 -0
  114. package/src/_api/generated/cfg_totp/core/bodySerializer.gen.ts +82 -0
  115. package/src/_api/generated/cfg_totp/core/params.gen.ts +169 -0
  116. package/src/_api/generated/cfg_totp/core/pathSerializer.gen.ts +171 -0
  117. package/src/_api/generated/cfg_totp/core/queryKeySerializer.gen.ts +117 -0
  118. package/src/_api/generated/cfg_totp/core/serverSentEvents.gen.ts +242 -0
  119. package/src/_api/generated/cfg_totp/core/types.gen.ts +104 -0
  120. package/src/_api/generated/cfg_totp/core/utils.gen.ts +140 -0
  121. package/src/_api/generated/cfg_totp/events.ts +198 -0
  122. package/src/_api/generated/cfg_totp/hooks/index.ts +12 -0
  123. package/src/_api/generated/cfg_totp/hooks/useCfgTotpBackupCodesRegenerateCreate.ts +24 -0
  124. package/src/_api/generated/cfg_totp/hooks/useCfgTotpBackupCodesRetrieve.ts +26 -0
  125. package/src/_api/generated/cfg_totp/hooks/useCfgTotpDevicesDestroy.ts +24 -0
  126. package/src/_api/generated/cfg_totp/hooks/useCfgTotpDevicesRetrieve.ts +26 -0
  127. package/src/_api/generated/cfg_totp/hooks/useCfgTotpDisableCreate.ts +24 -0
  128. package/src/_api/generated/cfg_totp/hooks/useCfgTotpSetupConfirmCreate.ts +24 -0
  129. package/src/_api/generated/cfg_totp/hooks/useCfgTotpSetupCreate.ts +24 -0
  130. package/src/_api/generated/cfg_totp/hooks/useCfgTotpVerifyBackupCreate.ts +24 -0
  131. package/src/_api/generated/cfg_totp/hooks/useCfgTotpVerifyCreate.ts +24 -0
  132. package/src/_api/generated/cfg_totp/index.ts +26 -342
  133. package/src/_api/generated/cfg_totp/schemas/BackupCodesRegenerateRequest.ts +11 -0
  134. package/src/_api/generated/cfg_totp/schemas/BackupCodesRegenerateResponse.ts +12 -0
  135. package/src/_api/generated/cfg_totp/schemas/BackupCodesStatus.ts +13 -0
  136. package/src/_api/generated/cfg_totp/schemas/ConfirmSetupRequest.ts +12 -0
  137. package/src/_api/generated/cfg_totp/schemas/ConfirmSetupResponse.ts +13 -0
  138. package/src/_api/generated/cfg_totp/schemas/DeviceList.ts +18 -0
  139. package/src/_api/generated/cfg_totp/schemas/DeviceListResponse.ts +13 -0
  140. package/src/_api/generated/cfg_totp/schemas/DeviceListStatusEnum.ts +9 -0
  141. package/src/_api/generated/cfg_totp/schemas/DisableRequest.ts +11 -0
  142. package/src/_api/generated/cfg_totp/schemas/SetupRequest.ts +11 -0
  143. package/src/_api/generated/cfg_totp/schemas/SetupResponse.ts +15 -0
  144. package/src/_api/generated/cfg_totp/{_utils/schemas/TotpVerifyUser.schema.ts → schemas/TotpVerifyUser.ts} +7 -15
  145. package/src/_api/generated/cfg_totp/schemas/VerifyBackupRequest.ts +12 -0
  146. package/src/_api/generated/cfg_totp/schemas/VerifyRequest.ts +12 -0
  147. package/src/_api/generated/cfg_totp/schemas/VerifyResponse.ts +17 -0
  148. package/src/_api/generated/cfg_totp/schemas/index.ts +18 -0
  149. package/src/_api/generated/cfg_totp/sdk.gen.ts +432 -0
  150. package/src/_api/generated/cfg_totp/types.gen.ts +479 -0
  151. package/src/_api/generated/index.ts +30 -0
  152. package/src/_api/index.ts +5 -23
  153. package/src/auth/context/AccountsContext.tsx +58 -89
  154. package/src/auth/context/AuthContext.tsx +3 -3
  155. package/src/auth/context/index.ts +2 -2
  156. package/src/auth/hooks/useDeleteAccount.ts +2 -1
  157. package/src/auth/hooks/useGithubAuth.ts +12 -11
  158. package/src/auth/hooks/useTokenRefresh.ts +6 -4
  159. package/src/auth/hooks/useTwoFactor.ts +14 -8
  160. package/src/auth/hooks/useTwoFactorSetup.ts +8 -5
  161. package/src/auth/hooks/useTwoFactorStatus.ts +3 -2
  162. package/src/auth/middlewares/tokenRefresh.ts +6 -4
  163. package/src/clients.ts +14 -51
  164. package/src/index.ts +15 -57
  165. package/src/server.ts +25 -23
  166. package/src/_api/BaseClient.ts +0 -22
  167. package/src/_api/generated/cfg_accounts/CLAUDE.md +0 -86
  168. package/src/_api/generated/cfg_accounts/_utils/fetchers/accounts.ts +0 -154
  169. package/src/_api/generated/cfg_accounts/_utils/fetchers/accounts__auth.ts +0 -95
  170. package/src/_api/generated/cfg_accounts/_utils/fetchers/accounts__oauth.ts +0 -285
  171. package/src/_api/generated/cfg_accounts/_utils/fetchers/accounts__user_profile.ts +0 -440
  172. package/src/_api/generated/cfg_accounts/_utils/fetchers/index.ts +0 -33
  173. package/src/_api/generated/cfg_accounts/_utils/hooks/accounts.ts +0 -64
  174. package/src/_api/generated/cfg_accounts/_utils/hooks/accounts__auth.ts +0 -44
  175. package/src/_api/generated/cfg_accounts/_utils/hooks/accounts__oauth.ts +0 -114
  176. package/src/_api/generated/cfg_accounts/_utils/hooks/accounts__user_profile.ts +0 -152
  177. package/src/_api/generated/cfg_accounts/_utils/hooks/index.ts +0 -33
  178. package/src/_api/generated/cfg_accounts/_utils/schemas/AccountDeleteResponse.schema.ts +0 -20
  179. package/src/_api/generated/cfg_accounts/_utils/schemas/CentrifugoToken.schema.ts +0 -22
  180. package/src/_api/generated/cfg_accounts/_utils/schemas/CfgAccountsProfileAvatarCreateRequest.schema.ts +0 -15
  181. package/src/_api/generated/cfg_accounts/_utils/schemas/OAuthAuthorizeRequestRequest.schema.ts +0 -20
  182. package/src/_api/generated/cfg_accounts/_utils/schemas/OAuthAuthorizeResponse.schema.ts +0 -20
  183. package/src/_api/generated/cfg_accounts/_utils/schemas/OAuthCallbackRequestRequest.schema.ts +0 -21
  184. package/src/_api/generated/cfg_accounts/_utils/schemas/OAuthConnection.schema.ts +0 -27
  185. package/src/_api/generated/cfg_accounts/_utils/schemas/OAuthDisconnectRequestRequest.schema.ts +0 -20
  186. package/src/_api/generated/cfg_accounts/_utils/schemas/OAuthError.schema.ts +0 -20
  187. package/src/_api/generated/cfg_accounts/_utils/schemas/OAuthProvidersResponse.schema.ts +0 -19
  188. package/src/_api/generated/cfg_accounts/_utils/schemas/OAuthTokenResponse.schema.ts +0 -46
  189. package/src/_api/generated/cfg_accounts/_utils/schemas/OTPErrorResponse.schema.ts +0 -41
  190. package/src/_api/generated/cfg_accounts/_utils/schemas/OTPRequestRequest.schema.ts +0 -20
  191. package/src/_api/generated/cfg_accounts/_utils/schemas/OTPRequestResponse.schema.ts +0 -19
  192. package/src/_api/generated/cfg_accounts/_utils/schemas/OTPVerifyRequest.schema.ts +0 -21
  193. package/src/_api/generated/cfg_accounts/_utils/schemas/OTPVerifyResponse.schema.ts +0 -45
  194. package/src/_api/generated/cfg_accounts/_utils/schemas/PatchedUserProfileUpdateRequest.schema.ts +0 -24
  195. package/src/_api/generated/cfg_accounts/_utils/schemas/TokenRefresh.schema.ts +0 -16
  196. package/src/_api/generated/cfg_accounts/_utils/schemas/TokenRefreshRequest.schema.ts +0 -15
  197. package/src/_api/generated/cfg_accounts/_utils/schemas/UserProfileUpdateRequest.schema.ts +0 -24
  198. package/src/_api/generated/cfg_accounts/_utils/schemas/index.ts +0 -41
  199. package/src/_api/generated/cfg_accounts/accounts/client.ts +0 -34
  200. package/src/_api/generated/cfg_accounts/accounts/index.ts +0 -4
  201. package/src/_api/generated/cfg_accounts/accounts/models.ts +0 -127
  202. package/src/_api/generated/cfg_accounts/accounts__auth/client.ts +0 -23
  203. package/src/_api/generated/cfg_accounts/accounts__auth/index.ts +0 -4
  204. package/src/_api/generated/cfg_accounts/accounts__auth/models.ts +0 -19
  205. package/src/_api/generated/cfg_accounts/accounts__oauth/client.ts +0 -67
  206. package/src/_api/generated/cfg_accounts/accounts__oauth/index.ts +0 -4
  207. package/src/_api/generated/cfg_accounts/accounts__oauth/models.ts +0 -127
  208. package/src/_api/generated/cfg_accounts/accounts__user_profile/client.ts +0 -94
  209. package/src/_api/generated/cfg_accounts/accounts__user_profile/index.ts +0 -4
  210. package/src/_api/generated/cfg_accounts/accounts__user_profile/models.ts +0 -98
  211. package/src/_api/generated/cfg_accounts/api-instance.ts +0 -181
  212. package/src/_api/generated/cfg_accounts/client.ts +0 -339
  213. package/src/_api/generated/cfg_accounts/enums.ts +0 -10
  214. package/src/_api/generated/cfg_accounts/errors.ts +0 -123
  215. package/src/_api/generated/cfg_accounts/http.ts +0 -160
  216. package/src/_api/generated/cfg_accounts/logger.ts +0 -261
  217. package/src/_api/generated/cfg_accounts/retry.ts +0 -177
  218. package/src/_api/generated/cfg_accounts/schema.json +0 -1576
  219. package/src/_api/generated/cfg_accounts/storage.ts +0 -163
  220. package/src/_api/generated/cfg_accounts/validation-events.ts +0 -135
  221. package/src/_api/generated/cfg_centrifugo/CLAUDE.md +0 -60
  222. package/src/_api/generated/cfg_centrifugo/_utils/fetchers/centrifugo__centrifugo_auth.ts +0 -94
  223. package/src/_api/generated/cfg_centrifugo/_utils/fetchers/index.ts +0 -30
  224. package/src/_api/generated/cfg_centrifugo/_utils/hooks/centrifugo__centrifugo_auth.ts +0 -39
  225. package/src/_api/generated/cfg_centrifugo/_utils/hooks/index.ts +0 -30
  226. package/src/_api/generated/cfg_centrifugo/_utils/schemas/ConnectionTokenResponse.schema.ts +0 -22
  227. package/src/_api/generated/cfg_centrifugo/_utils/schemas/index.ts +0 -21
  228. package/src/_api/generated/cfg_centrifugo/api-instance.ts +0 -181
  229. package/src/_api/generated/cfg_centrifugo/centrifugo__centrifugo_auth/client.ts +0 -27
  230. package/src/_api/generated/cfg_centrifugo/centrifugo__centrifugo_auth/index.ts +0 -4
  231. package/src/_api/generated/cfg_centrifugo/centrifugo__centrifugo_auth/models.ts +0 -18
  232. package/src/_api/generated/cfg_centrifugo/client.ts +0 -330
  233. package/src/_api/generated/cfg_centrifugo/errors.ts +0 -123
  234. package/src/_api/generated/cfg_centrifugo/http.ts +0 -160
  235. package/src/_api/generated/cfg_centrifugo/logger.ts +0 -261
  236. package/src/_api/generated/cfg_centrifugo/retry.ts +0 -177
  237. package/src/_api/generated/cfg_centrifugo/schema.json +0 -118
  238. package/src/_api/generated/cfg_centrifugo/storage.ts +0 -163
  239. package/src/_api/generated/cfg_centrifugo/validation-events.ts +0 -135
  240. package/src/_api/generated/cfg_totp/CLAUDE.md +0 -83
  241. package/src/_api/generated/cfg_totp/_utils/fetchers/index.ts +0 -34
  242. package/src/_api/generated/cfg_totp/_utils/fetchers/totp.ts +0 -50
  243. package/src/_api/generated/cfg_totp/_utils/fetchers/totp__backup_codes.ts +0 -153
  244. package/src/_api/generated/cfg_totp/_utils/fetchers/totp__totp_management.ts +0 -109
  245. package/src/_api/generated/cfg_totp/_utils/fetchers/totp__totp_setup.ts +0 -154
  246. package/src/_api/generated/cfg_totp/_utils/fetchers/totp__totp_verification.ts +0 -153
  247. package/src/_api/generated/cfg_totp/_utils/hooks/index.ts +0 -34
  248. package/src/_api/generated/cfg_totp/_utils/hooks/totp.ts +0 -43
  249. package/src/_api/generated/cfg_totp/_utils/hooks/totp__backup_codes.ts +0 -60
  250. package/src/_api/generated/cfg_totp/_utils/hooks/totp__totp_management.ts +0 -59
  251. package/src/_api/generated/cfg_totp/_utils/hooks/totp__totp_setup.ts +0 -64
  252. package/src/_api/generated/cfg_totp/_utils/hooks/totp__totp_verification.ts +0 -63
  253. package/src/_api/generated/cfg_totp/_utils/schemas/BackupCodesRegenerateRequest.schema.ts +0 -19
  254. package/src/_api/generated/cfg_totp/_utils/schemas/BackupCodesRegenerateResponse.schema.ts +0 -20
  255. package/src/_api/generated/cfg_totp/_utils/schemas/BackupCodesStatus.schema.ts +0 -21
  256. package/src/_api/generated/cfg_totp/_utils/schemas/ConfirmSetupRequest.schema.ts +0 -20
  257. package/src/_api/generated/cfg_totp/_utils/schemas/ConfirmSetupResponse.schema.ts +0 -21
  258. package/src/_api/generated/cfg_totp/_utils/schemas/DeviceList.schema.ts +0 -26
  259. package/src/_api/generated/cfg_totp/_utils/schemas/DeviceListResponse.schema.ts +0 -21
  260. package/src/_api/generated/cfg_totp/_utils/schemas/DisableRequest.schema.ts +0 -19
  261. package/src/_api/generated/cfg_totp/_utils/schemas/SetupRequest.schema.ts +0 -19
  262. package/src/_api/generated/cfg_totp/_utils/schemas/SetupResponse.schema.ts +0 -23
  263. package/src/_api/generated/cfg_totp/_utils/schemas/VerifyBackupRequest.schema.ts +0 -20
  264. package/src/_api/generated/cfg_totp/_utils/schemas/VerifyRequest.schema.ts +0 -20
  265. package/src/_api/generated/cfg_totp/_utils/schemas/VerifyResponse.schema.ts +0 -25
  266. package/src/_api/generated/cfg_totp/_utils/schemas/index.ts +0 -34
  267. package/src/_api/generated/cfg_totp/api-instance.ts +0 -181
  268. package/src/_api/generated/cfg_totp/client.ts +0 -342
  269. package/src/_api/generated/cfg_totp/enums.ts +0 -13
  270. package/src/_api/generated/cfg_totp/errors.ts +0 -123
  271. package/src/_api/generated/cfg_totp/http.ts +0 -160
  272. package/src/_api/generated/cfg_totp/logger.ts +0 -261
  273. package/src/_api/generated/cfg_totp/retry.ts +0 -177
  274. package/src/_api/generated/cfg_totp/schema.json +0 -910
  275. package/src/_api/generated/cfg_totp/storage.ts +0 -163
  276. package/src/_api/generated/cfg_totp/totp/client.ts +0 -24
  277. package/src/_api/generated/cfg_totp/totp/index.ts +0 -4
  278. package/src/_api/generated/cfg_totp/totp/models.ts +0 -4
  279. package/src/_api/generated/cfg_totp/totp__backup_codes/client.ts +0 -32
  280. package/src/_api/generated/cfg_totp/totp__backup_codes/index.ts +0 -4
  281. package/src/_api/generated/cfg_totp/totp__backup_codes/models.ts +0 -38
  282. package/src/_api/generated/cfg_totp/totp__totp_management/client.ts +0 -31
  283. package/src/_api/generated/cfg_totp/totp__totp_management/index.ts +0 -4
  284. package/src/_api/generated/cfg_totp/totp__totp_management/models.ts +0 -46
  285. package/src/_api/generated/cfg_totp/totp__totp_setup/client.ts +0 -33
  286. package/src/_api/generated/cfg_totp/totp__totp_setup/index.ts +0 -4
  287. package/src/_api/generated/cfg_totp/totp__totp_setup/models.ts +0 -55
  288. package/src/_api/generated/cfg_totp/totp__totp_verification/client.ts +0 -33
  289. package/src/_api/generated/cfg_totp/totp__totp_verification/index.ts +0 -4
  290. package/src/_api/generated/cfg_totp/totp__totp_verification/models.ts +0 -74
  291. package/src/_api/generated/cfg_totp/validation-events.ts +0 -135
  292. package/src/hooks/accounts.ts +0 -8
  293. package/src/hooks/index.ts +0 -10
@@ -1,181 +0,0 @@
1
- // @ts-nocheck
2
- // Auto-generated by DjangoCFG - see CLAUDE.md
3
- /**
4
- * Global API Instance - Singleton configuration with auto-configuration support
5
- *
6
- * This module provides a global API instance that auto-configures from
7
- * environment variables or can be configured manually.
8
- *
9
- * AUTO-CONFIGURATION (recommended):
10
- * Set one of these environment variables and the API will auto-configure:
11
- * - NEXT_PUBLIC_API_URL (Next.js)
12
- * - VITE_API_URL (Vite)
13
- * - REACT_APP_API_URL (Create React App)
14
- * - API_URL (generic)
15
- *
16
- * Then just use fetchers and hooks directly:
17
- * ```typescript
18
- * import { getUsers } from './_utils/fetchers'
19
- * const users = await getUsers({ page: 1 })
20
- * ```
21
- *
22
- * MANUAL CONFIGURATION:
23
- * ```typescript
24
- * import { configureAPI } from './api-instance'
25
- *
26
- * configureAPI({
27
- * baseUrl: 'https://api.example.com',
28
- * token: 'your-jwt-token'
29
- * })
30
- * ```
31
- *
32
- * For SSR or multiple instances:
33
- * ```typescript
34
- * import { API } from './index'
35
- * import { getUsers } from './_utils/fetchers'
36
- *
37
- * const api = new API('https://api.example.com')
38
- * const users = await getUsers({ page: 1 }, api)
39
- * ```
40
- */
41
-
42
- import { API, type APIOptions } from './index'
43
-
44
- let globalAPI: API | null = null
45
- let autoConfigAttempted = false
46
-
47
- /**
48
- * Auto-configure from environment variable if available (Next.js pattern)
49
- * This allows hooks and fetchers to work without explicit configureAPI() call
50
- *
51
- * Supported environment variables:
52
- * - NEXT_PUBLIC_API_URL (Next.js)
53
- * - VITE_API_URL (Vite)
54
- * - REACT_APP_API_URL (Create React App)
55
- * - API_URL (generic)
56
- */
57
- function tryAutoConfigureFromEnv(): void {
58
- // Only attempt once
59
- if (autoConfigAttempted) return
60
- autoConfigAttempted = true
61
-
62
- // Skip if already configured
63
- if (globalAPI) return
64
-
65
- // Skip if process is not available (pure browser without bundler)
66
- if (typeof process === 'undefined' || !process.env) return
67
-
68
- // Try different environment variable patterns
69
- const baseUrl =
70
- process.env.NEXT_PUBLIC_API_URL ||
71
- process.env.VITE_API_URL ||
72
- process.env.REACT_APP_API_URL ||
73
- process.env.API_URL
74
-
75
- if (baseUrl) {
76
- globalAPI = new API(baseUrl)
77
- }
78
- }
79
-
80
- /**
81
- * Get the global API instance
82
- * Auto-configures from environment variables on first call if not manually configured.
83
- * @throws Error if API is not configured and no env variable is set
84
- */
85
- export function getAPIInstance(): API {
86
- // Try auto-configuration on first access (lazy initialization)
87
- tryAutoConfigureFromEnv()
88
-
89
- if (!globalAPI) {
90
- throw new Error(
91
- 'API not configured. Call configureAPI() with your base URL before using fetchers or hooks.\n\n' +
92
- 'Example:\n' +
93
- ' import { configureAPI } from "./api-instance"\n' +
94
- ' configureAPI({ baseUrl: "https://api.example.com" })\n\n' +
95
- 'Or set environment variable: NEXT_PUBLIC_API_URL, VITE_API_URL, or REACT_APP_API_URL'
96
- )
97
- }
98
- return globalAPI
99
- }
100
-
101
- /**
102
- * Check if API is configured (or can be auto-configured)
103
- */
104
- export function isAPIConfigured(): boolean {
105
- tryAutoConfigureFromEnv()
106
- return globalAPI !== null
107
- }
108
-
109
- /**
110
- * Configure the global API instance
111
- *
112
- * @param baseUrl - Base URL for the API
113
- * @param options - Optional configuration (storage, retry, logger)
114
- *
115
- * @example
116
- * ```typescript
117
- * configureAPI({
118
- * baseUrl: 'https://api.example.com',
119
- * token: 'jwt-token',
120
- * options: {
121
- * retryConfig: { maxRetries: 3 },
122
- * loggerConfig: { enabled: true }
123
- * }
124
- * })
125
- * ```
126
- */
127
- export function configureAPI(config: {
128
- baseUrl: string
129
- token?: string
130
- refreshToken?: string
131
- options?: APIOptions
132
- }): API {
133
- globalAPI = new API(config.baseUrl, config.options)
134
-
135
- if (config.token) {
136
- globalAPI.setToken(config.token, config.refreshToken)
137
- }
138
-
139
- return globalAPI
140
- }
141
-
142
- /**
143
- * Reconfigure the global API instance with new settings
144
- * Useful for updating tokens or base URL
145
- */
146
- export function reconfigureAPI(updates: {
147
- baseUrl?: string
148
- token?: string
149
- refreshToken?: string
150
- }): API {
151
- const instance = getAPIInstance()
152
-
153
- if (updates.baseUrl) {
154
- instance.setBaseUrl(updates.baseUrl)
155
- }
156
-
157
- if (updates.token) {
158
- instance.setToken(updates.token, updates.refreshToken)
159
- }
160
-
161
- return instance
162
- }
163
-
164
- /**
165
- * Clear tokens from the global API instance
166
- */
167
- export function clearAPITokens(): void {
168
- const instance = getAPIInstance()
169
- instance.clearTokens()
170
- }
171
-
172
- /**
173
- * Reset the global API instance
174
- * Useful for testing or logout scenarios
175
- */
176
- export function resetAPI(): void {
177
- if (globalAPI) {
178
- globalAPI.clearTokens()
179
- }
180
- globalAPI = null
181
- }
@@ -1,339 +0,0 @@
1
- import { Auth } from "./accounts__auth";
2
- import { Oauth } from "./accounts__oauth";
3
- import { UserProfile } from "./accounts__user_profile";
4
- import { Accounts } from "./accounts";
5
- import { HttpClientAdapter, FetchAdapter } from "./http";
6
- import { APIError, NetworkError } from "./errors";
7
- import { APILogger, type LoggerConfig } from "./logger";
8
- import { withRetry, type RetryConfig } from "./retry";
9
-
10
-
11
- /**
12
- * Async API client for Django CFG API.
13
- *
14
- * Usage:
15
- * ```typescript
16
- * const client = new APIClient('https://api.example.com');
17
- * const users = await client.users.list();
18
- * const post = await client.posts.create(newPost);
19
- *
20
- * // Custom HTTP adapter (e.g., Axios)
21
- * const client = new APIClient('https://api.example.com', {
22
- * httpClient: new AxiosAdapter()
23
- * });
24
- * ```
25
- */
26
- export class APIClient {
27
- private baseUrl: string;
28
- private httpClient: HttpClientAdapter;
29
- private logger: APILogger | null = null;
30
- private retryConfig: RetryConfig | null = null;
31
- private tokenGetter: (() => string | null) | null = null;
32
-
33
- // Sub-clients
34
- public auth: Auth;
35
- public oauth: Oauth;
36
- public user_profile: UserProfile;
37
- public accounts: Accounts;
38
-
39
- constructor(
40
- baseUrl: string,
41
- options?: {
42
- httpClient?: HttpClientAdapter;
43
- loggerConfig?: Partial<LoggerConfig>;
44
- retryConfig?: RetryConfig;
45
- tokenGetter?: () => string | null;
46
- }
47
- ) {
48
- this.baseUrl = baseUrl.replace(/\/$/, '');
49
- this.httpClient = options?.httpClient || new FetchAdapter();
50
- this.tokenGetter = options?.tokenGetter || null;
51
-
52
- // Initialize logger if config provided
53
- if (options?.loggerConfig !== undefined) {
54
- this.logger = new APILogger(options.loggerConfig);
55
- }
56
-
57
- // Store retry configuration
58
- if (options?.retryConfig !== undefined) {
59
- this.retryConfig = options.retryConfig;
60
- }
61
-
62
- // Initialize sub-clients
63
- this.auth = new Auth(this);
64
- this.oauth = new Oauth(this);
65
- this.user_profile = new UserProfile(this);
66
- this.accounts = new Accounts(this);
67
- }
68
-
69
- /**
70
- * Get CSRF token from cookies (for SessionAuthentication).
71
- *
72
- * Returns null if cookie doesn't exist (JWT-only auth).
73
- */
74
- getCsrfToken(): string | null {
75
- const name = 'csrftoken';
76
- const value = `; ${document.cookie}`;
77
- const parts = value.split(`; ${name}=`);
78
- if (parts.length === 2) {
79
- return parts.pop()?.split(';').shift() || null;
80
- }
81
- return null;
82
- }
83
-
84
- /**
85
- * Get the base URL for building streaming/download URLs.
86
- */
87
- getBaseUrl(): string {
88
- return this.baseUrl;
89
- }
90
-
91
- /**
92
- * Get JWT token for URL authentication (used in streaming endpoints).
93
- * Returns null if no token getter is configured or no token is available.
94
- */
95
- getToken(): string | null {
96
- return this.tokenGetter ? this.tokenGetter() : null;
97
- }
98
-
99
- /**
100
- * Make HTTP request with Django CSRF and session handling.
101
- * Automatically retries on network errors and 5xx server errors.
102
- */
103
- async request<T>(
104
- method: string,
105
- path: string,
106
- options?: {
107
- params?: Record<string, any>;
108
- body?: any;
109
- formData?: FormData;
110
- binaryBody?: Blob | ArrayBuffer;
111
- headers?: Record<string, string>;
112
- responseType?: 'json' | 'text' | 'blob';
113
- }
114
- ): Promise<T> {
115
- // Wrap request in retry logic if configured
116
- if (this.retryConfig) {
117
- return withRetry(() => this._makeRequest<T>(method, path, options), {
118
- ...this.retryConfig,
119
- onFailedAttempt: (info) => {
120
- // Log retry attempts
121
- if (this.logger) {
122
- this.logger.warn(
123
- `Retry attempt ${info.attemptNumber}/${info.retriesLeft + info.attemptNumber} ` +
124
- `for ${method} ${path}: ${info.error.message}`
125
- );
126
- }
127
- // Call user's onFailedAttempt if provided
128
- this.retryConfig?.onFailedAttempt?.(info);
129
- },
130
- });
131
- }
132
-
133
- // No retry configured, make request directly
134
- return this._makeRequest<T>(method, path, options);
135
- }
136
-
137
- /**
138
- * Internal request method (without retry wrapper).
139
- * Used by request() method with optional retry logic.
140
- */
141
- private async _makeRequest<T>(
142
- method: string,
143
- path: string,
144
- options?: {
145
- params?: Record<string, any>;
146
- body?: any;
147
- formData?: FormData;
148
- binaryBody?: Blob | ArrayBuffer;
149
- headers?: Record<string, string>;
150
- responseType?: 'json' | 'text' | 'blob';
151
- }
152
- ): Promise<T> {
153
- // Build URL - handle both absolute and relative paths
154
- // When baseUrl is empty (static builds), path is used as-is (relative to current origin)
155
- const url = this.baseUrl ? `${this.baseUrl}${path}` : path;
156
- const startTime = Date.now();
157
-
158
- // Build headers - start with custom headers from options
159
- const headers: Record<string, string> = {
160
- ...(options?.headers || {})
161
- };
162
-
163
- // Don't set Content-Type for FormData/binaryBody (browser will set it with boundary)
164
- if (!options?.formData && !options?.binaryBody && !headers['Content-Type']) {
165
- headers['Content-Type'] = 'application/json';
166
- }
167
-
168
- // CSRF not needed - SessionAuthentication not enabled in DRF config
169
- // Your API uses JWT/Token authentication (no CSRF required)
170
-
171
- // Add Authorization header from tokenGetter (Bearer token / API key)
172
- if (!headers['Authorization']) {
173
- const token = this.getToken();
174
- if (token) {
175
- headers['Authorization'] = `Bearer ${token}`;
176
- }
177
- }
178
-
179
- // Log request
180
- if (this.logger) {
181
- this.logger.logRequest({
182
- method,
183
- url: url,
184
- headers,
185
- body: options?.formData || options?.body,
186
- timestamp: startTime,
187
- });
188
- }
189
-
190
- try {
191
- // Make request via HTTP adapter
192
- const response = await this.httpClient.request<T>({
193
- method,
194
- url: url,
195
- headers,
196
- params: options?.params,
197
- body: options?.body,
198
- formData: options?.formData,
199
- binaryBody: options?.binaryBody,
200
- responseType: options?.responseType,
201
- });
202
-
203
- const duration = Date.now() - startTime;
204
-
205
- // Check for HTTP errors
206
- if (response.status >= 400) {
207
- const error = new APIError(
208
- response.status,
209
- response.statusText,
210
- response.data,
211
- url
212
- );
213
-
214
- // Log error
215
- if (this.logger) {
216
- this.logger.logError(
217
- {
218
- method,
219
- url: url,
220
- headers,
221
- body: options?.formData || options?.body,
222
- timestamp: startTime,
223
- },
224
- {
225
- message: error.message,
226
- statusCode: response.status,
227
- duration,
228
- timestamp: Date.now(),
229
- }
230
- );
231
- }
232
-
233
- throw error;
234
- }
235
-
236
- // Log successful response
237
- if (this.logger) {
238
- this.logger.logResponse(
239
- {
240
- method,
241
- url: url,
242
- headers,
243
- body: options?.formData || options?.body,
244
- timestamp: startTime,
245
- },
246
- {
247
- status: response.status,
248
- statusText: response.statusText,
249
- data: response.data,
250
- duration,
251
- timestamp: Date.now(),
252
- }
253
- );
254
- }
255
-
256
- return response.data as T;
257
- } catch (error) {
258
- const duration = Date.now() - startTime;
259
-
260
- // Re-throw APIError as-is
261
- if (error instanceof APIError) {
262
- throw error;
263
- }
264
-
265
- // Classify network error using PerformanceResourceTiming.
266
- // Browser intentionally makes CORS errors indistinguishable from network failures
267
- // (same TypeError: "Failed to fetch") for security reasons. We use PerformanceResourceTiming
268
- // as the best available heuristic:
269
- // - Entry exists with responseStatus === 0 → request reached server, JS blocked → likely CORS
270
- // - No entry / entry missing → connection never established → server unavailable / DNS / offline
271
- // All cases are dispatched as 'network-error' with a `possibly_cors` flag.
272
- let possiblyCors = false;
273
- if (error instanceof TypeError && typeof window !== 'undefined') {
274
- try {
275
- const isCrossOrigin = (() => {
276
- try { return new URL(url).origin !== window.location.origin; } catch { return false; }
277
- })();
278
- if (isCrossOrigin) {
279
- const entries = performance.getEntriesByName(url, 'resource');
280
- if (entries.length > 0) {
281
- const last = entries[entries.length - 1] as PerformanceResourceTiming;
282
- possiblyCors = 'responseStatus' in last && (last as any).responseStatus === 0;
283
- }
284
- }
285
- } catch { /* ignore — PerformanceResourceTiming not available */ }
286
- }
287
-
288
- if (this.logger) {
289
- this.logger.error(`⚠️ Network Error: ${method} ${url}`);
290
- this.logger.error(` → ${error instanceof Error ? error.message : String(error)}`);
291
- if (possiblyCors) {
292
- this.logger.error(` → Possibly blocked by CORS policy (configure CORS on the server)`);
293
- }
294
- }
295
-
296
- // Dispatch network-error event with possibly_cors hint
297
- if (typeof window !== 'undefined') {
298
- try {
299
- window.dispatchEvent(new CustomEvent('network-error', {
300
- detail: {
301
- url: url,
302
- method: method,
303
- error: error instanceof Error ? error.message : String(error),
304
- possibly_cors: possiblyCors,
305
- timestamp: new Date(),
306
- },
307
- bubbles: true,
308
- cancelable: false,
309
- }));
310
- } catch { /* silently ignore — event dispatch must never crash the app */ }
311
- }
312
-
313
- // Wrap other errors as NetworkError
314
- const networkError = error instanceof Error
315
- ? new NetworkError(error.message, url, error)
316
- : new NetworkError('Unknown error', url);
317
-
318
- // Detailed logging via logger.logError
319
- if (this.logger) {
320
- this.logger.logError(
321
- {
322
- method,
323
- url: url,
324
- headers,
325
- body: options?.formData || options?.body,
326
- timestamp: startTime,
327
- },
328
- {
329
- message: networkError.message,
330
- duration,
331
- timestamp: Date.now(),
332
- }
333
- );
334
- }
335
-
336
- throw networkError;
337
- }
338
- }
339
- }
@@ -1,10 +0,0 @@
1
- // @ts-nocheck
2
- // Auto-generated by DjangoCFG - see CLAUDE.md
3
- /**
4
- * OAuth provider to disconnect
5
- * * `github` - GitHub
6
- */
7
- export enum OAuthConnectionProvider {
8
- GITHUB = "github",
9
- }
10
-
@@ -1,123 +0,0 @@
1
- // @ts-nocheck
2
- // Auto-generated by DjangoCFG - see CLAUDE.md
3
- /**
4
- * API Error Classes
5
- *
6
- * Typed error classes with Django REST Framework support.
7
- */
8
-
9
- /**
10
- * HTTP API Error with DRF field-specific validation errors.
11
- *
12
- * Usage:
13
- * ```typescript
14
- * try {
15
- * await api.users.create(userData);
16
- * } catch (error) {
17
- * if (error instanceof APIError) {
18
- * if (error.isValidationError) {
19
- * console.log('Field errors:', error.fieldErrors);
20
- * // { "email": ["Email already exists"], "username": ["Required"] }
21
- * }
22
- * }
23
- * }
24
- * ```
25
- */
26
- export class APIError extends Error {
27
- constructor(
28
- public statusCode: number,
29
- public statusText: string,
30
- public response: any,
31
- public url: string,
32
- message?: string
33
- ) {
34
- super(message || `HTTP ${statusCode}: ${statusText}`);
35
- this.name = 'APIError';
36
- }
37
-
38
- /**
39
- * Get error details from response.
40
- * DRF typically returns: { "detail": "Error message" } or { "field": ["error1", "error2"] }
41
- */
42
- get details(): Record<string, any> | null {
43
- if (typeof this.response === 'object' && this.response !== null) {
44
- return this.response;
45
- }
46
- return null;
47
- }
48
-
49
- /**
50
- * Get field-specific validation errors from DRF.
51
- * Returns: { "field_name": ["error1", "error2"], ... }
52
- */
53
- get fieldErrors(): Record<string, string[]> | null {
54
- const details = this.details;
55
- if (!details) return null;
56
-
57
- // DRF typically returns: { "field": ["error1", "error2"] }
58
- const fieldErrors: Record<string, string[]> = {};
59
- for (const [key, value] of Object.entries(details)) {
60
- if (Array.isArray(value)) {
61
- fieldErrors[key] = value;
62
- }
63
- }
64
-
65
- return Object.keys(fieldErrors).length > 0 ? fieldErrors : null;
66
- }
67
-
68
- /**
69
- * Get single error message from DRF.
70
- * Checks for "detail", "message", or first field error.
71
- */
72
- get errorMessage(): string {
73
- const details = this.details;
74
- if (!details) return this.message;
75
-
76
- // Check for "detail" field (common in DRF)
77
- if (details.detail) {
78
- return Array.isArray(details.detail) ? details.detail.join(', ') : String(details.detail);
79
- }
80
-
81
- // Check for "error" field (common in custom DRF views)
82
- if (details.error) {
83
- return String(details.error);
84
- }
85
-
86
- // Check for "message" field
87
- if (details.message) {
88
- return String(details.message);
89
- }
90
-
91
- // Return first field error
92
- const fieldErrors = this.fieldErrors;
93
- if (fieldErrors) {
94
- const firstField = Object.keys(fieldErrors)[0];
95
- if (firstField) {
96
- return `${firstField}: ${fieldErrors[firstField]?.join(', ')}`;
97
- }
98
- }
99
-
100
- return this.message;
101
- }
102
-
103
- // Helper methods for common HTTP status codes
104
- get isValidationError(): boolean { return this.statusCode === 400; }
105
- get isAuthError(): boolean { return this.statusCode === 401; }
106
- get isPermissionError(): boolean { return this.statusCode === 403; }
107
- get isNotFoundError(): boolean { return this.statusCode === 404; }
108
- get isServerError(): boolean { return this.statusCode >= 500 && this.statusCode < 600; }
109
- }
110
-
111
- /**
112
- * Network Error (connection failed, timeout, etc.)
113
- */
114
- export class NetworkError extends Error {
115
- constructor(
116
- message: string,
117
- public url: string,
118
- public originalError?: Error
119
- ) {
120
- super(message);
121
- this.name = 'NetworkError';
122
- }
123
- }