@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
package/dist/clients.d.ts CHANGED
@@ -1,2959 +1,192 @@
1
1
  import { ConsolaInstance } from 'consola';
2
- import { z } from 'zod';
3
- import useSWR from 'swr';
4
2
 
5
- /**
6
- *
7
- * Request model (no read-only fields).
8
- */
9
- interface TokenRefreshRequest$1 {
10
- refresh: string;
11
- }
12
- /**
13
- *
14
- * Response model (includes read-only fields).
15
- */
16
- interface TokenRefresh$1 {
17
- access: string;
18
- refresh: string;
19
- }
20
-
21
- /**
22
- * API endpoints for Auth.
23
- */
24
- declare class Auth {
25
- private client;
26
- constructor(client: any);
27
- /**
28
- * Refresh JWT token.
29
- */
30
- accountsTokenRefreshCreate(data: TokenRefreshRequest$1): Promise<TokenRefresh$1>;
31
- }
32
-
33
- /**
34
- * OAuth provider to disconnect
35
- * * `github` - GitHub
36
- */
37
- declare enum OAuthConnectionProvider {
38
- GITHUB = "github"
39
- }
40
-
41
- type enums_OAuthConnectionProvider = OAuthConnectionProvider;
42
- declare const enums_OAuthConnectionProvider: typeof OAuthConnectionProvider;
43
- declare namespace enums {
44
- export { enums_OAuthConnectionProvider as OAuthConnectionProvider };
45
- }
46
-
47
- /**
48
- * Request to start OAuth flow.
49
- *
50
- * Request model (no read-only fields).
51
- */
52
- interface OAuthAuthorizeRequestRequest$1 {
53
- /** URL to redirect after OAuth authorization. If not provided, uses config's site_url + callback_path */
54
- redirect_uri?: string;
55
- /** Optional source URL for registration tracking */
56
- source_url?: string;
57
- }
58
- /**
59
- * Request to complete OAuth flow (callback handler).
60
- *
61
- * Request model (no read-only fields).
62
- */
63
- interface OAuthCallbackRequestRequest$1 {
64
- /** Authorization code from OAuth provider callback */
65
- code: string;
66
- /** State token for CSRF verification (from authorize response) */
67
- state: string;
68
- /** Same redirect_uri used in authorize request. If not provided, uses config's site_url + callback_path */
69
- redirect_uri?: string;
70
- }
71
- /**
72
- * Response with JWT tokens after OAuth authentication. When 2FA is required: -
73
- * requires_2fa: True - session_id: UUID of 2FA verification session -
74
- * access/refresh/user: null When 2FA is not required: - requires_2fa: False -
75
- * session_id: null - access/refresh/user: populated
76
- *
77
- * Response model (includes read-only fields).
78
- */
79
- interface OAuthTokenResponse$1 {
80
- /** True if 2FA verification is required */
81
- requires_2fa?: boolean;
82
- /** 2FA session ID (only when requires_2fa=True) */
83
- session_id?: string | null;
84
- /** JWT access token (null when requires_2fa=True) */
85
- access?: string | null;
86
- /** JWT refresh token (null when requires_2fa=True) */
87
- refresh?: string | null;
88
- /** Authenticated user info (null when requires_2fa=True) */
89
- user?: Record<string, any> | null;
90
- /** True if a new user was created during this OAuth flow */
91
- is_new_user: boolean;
92
- /** True if a new OAuth connection was created */
93
- is_new_connection: boolean;
94
- /** True if user should be prompted to enable 2FA */
95
- should_prompt_2fa?: boolean;
96
- }
97
- /**
98
- * Serializer for OAuth connection info (user-facing).
99
- *
100
- * Response model (includes read-only fields).
101
- */
102
- interface OAuthConnection$1 {
103
- id: number;
104
- /** OAuth provider name (github, google, etc.)
105
-
106
- * `github` - GitHub */
107
- provider: OAuthConnectionProvider;
108
- provider_display: string;
109
- /** Username on the OAuth provider platform */
110
- provider_username: string;
111
- /** Email from OAuth provider (may differ from user.email) */
112
- provider_email: string;
113
- /** Avatar URL from OAuth provider */
114
- provider_avatar_url: string;
115
- /** When this OAuth connection was created */
116
- connected_at: string;
117
- /** Last time this OAuth connection was used for login */
118
- last_login_at: string;
119
- }
120
- /**
121
- * Response with OAuth authorization URL.
122
- *
123
- * Response model (includes read-only fields).
124
- */
125
- interface OAuthAuthorizeResponse$1 {
126
- /** Full URL to redirect user to OAuth provider */
127
- authorization_url: string;
128
- /** State token for CSRF protection. Store this and verify on callback. */
129
- state: string;
130
- }
131
- /**
132
- * Request to disconnect OAuth provider.
133
- *
134
- * Request model (no read-only fields).
135
- */
136
- interface OAuthDisconnectRequestRequest$1 {
137
- /** OAuth provider to disconnect
138
-
139
- * `github` - GitHub */
140
- provider: OAuthConnectionProvider;
141
- }
142
- /**
143
- * Response with available OAuth providers.
144
- *
145
- * Response model (includes read-only fields).
146
- */
147
- interface OAuthProvidersResponse$1 {
148
- /** List of available OAuth providers */
149
- providers: Array<Record<string, any>>;
150
- }
151
-
152
- /**
153
- * API endpoints for Oauth.
154
- */
155
- declare class Oauth {
156
- private client;
157
- constructor(client: any);
158
- /**
159
- * List OAuth connections
160
- *
161
- * Get all OAuth connections for the current user.
162
- */
163
- accountsOauthConnectionsList(): Promise<OAuthConnection$1[]>;
164
- /**
165
- * Disconnect OAuth provider
166
- *
167
- * Remove OAuth connection for the specified provider.
168
- */
169
- accountsOauthDisconnectCreate(data: OAuthDisconnectRequestRequest$1): Promise<any>;
170
- /**
171
- * Start GitHub OAuth
172
- *
173
- * Generate GitHub OAuth authorization URL. Redirect user to this URL to
174
- * start authentication.
175
- */
176
- accountsOauthGithubAuthorizeCreate(data: OAuthAuthorizeRequestRequest$1): Promise<OAuthAuthorizeResponse$1>;
177
- /**
178
- * Complete GitHub OAuth
179
- *
180
- * Exchange authorization code for JWT tokens. Call this after GitHub
181
- * redirects back with code.
182
- */
183
- accountsOauthGithubCallbackCreate(data: OAuthCallbackRequestRequest$1): Promise<OAuthTokenResponse$1>;
184
- /**
185
- * List OAuth providers
186
- *
187
- * Get list of available OAuth providers for authentication.
188
- */
189
- accountsOauthProvidersRetrieve(): Promise<OAuthProvidersResponse$1>;
190
- }
191
-
192
- /**
193
- * Serializer for updating user profile.
194
- *
195
- * Request model (no read-only fields).
196
- */
197
- interface PatchedUserProfileUpdateRequest$1 {
198
- first_name?: string;
199
- last_name?: string;
200
- company?: string;
201
- phone?: string;
202
- position?: string;
203
- language?: string;
204
- }
205
- /**
206
- *
207
- * Request model (no read-only fields).
208
- */
209
- interface CfgAccountsProfileAvatarCreateRequest$1 {
210
- /** Avatar image file (JPEG, PNG, GIF, WebP, max 5MB) */
211
- avatar: File | Blob;
212
- }
213
- /**
214
- * Response serializer for account deletion.
215
- *
216
- * Response model (includes read-only fields).
217
- */
218
- interface AccountDeleteResponse$1 {
219
- /** Whether the account was successfully deleted */
220
- success: boolean;
221
- /** Human-readable message about the deletion */
222
- message: string;
223
- }
224
- /**
225
- * Serializer for user details.
226
- *
227
- * Response model (includes read-only fields).
228
- */
229
- interface User$2 {
230
- id: number;
231
- email: string;
232
- first_name?: string;
233
- last_name?: string;
234
- /** Get user's full name. */
235
- full_name: string;
236
- /** Get user's initials for avatar fallback. */
237
- initials: string;
238
- /** Get formatted username for display. */
239
- display_username: string;
240
- company?: string;
241
- phone?: string;
242
- position?: string;
243
- language?: string;
244
- avatar?: string | null;
245
- /** Designates whether the user can log into this admin site. */
246
- is_staff: boolean;
247
- /** Designates that this user has all permissions without explicitly assigning them. */
248
- is_superuser: boolean;
249
- date_joined: string;
250
- last_login?: string | null;
251
- unanswered_messages_count: number;
252
- centrifugo: CentrifugoToken$2 | null;
253
- }
254
- /**
255
- * Serializer for updating user profile.
256
- *
257
- * Request model (no read-only fields).
258
- */
259
- interface UserProfileUpdateRequest$1 {
260
- first_name?: string;
261
- last_name?: string;
262
- company?: string;
263
- phone?: string;
264
- position?: string;
265
- language?: string;
266
- }
267
- /**
268
- * Nested serializer for Centrifugo WebSocket connection token.
269
- *
270
- * Response model (includes read-only fields).
271
- */
272
- interface CentrifugoToken$2 {
273
- /** JWT token for Centrifugo WebSocket connection */
274
- token: string;
275
- /** Centrifugo WebSocket URL */
276
- centrifugo_url: string;
277
- /** Token expiration time (ISO 8601) */
278
- expires_at: string;
279
- /** List of allowed channels for this user */
280
- channels: Array<string>;
3
+ interface StorageAdapter {
4
+ getItem(key: string): string | null;
5
+ setItem(key: string, value: string): void;
6
+ removeItem(key: string): void;
7
+ clear?(): void;
281
8
  }
282
9
 
283
- /**
284
- * API endpoints for User Profile.
285
- */
286
- declare class UserProfile {
287
- private client;
288
- constructor(client: any);
289
- /**
290
- * Get current user profile
291
- *
292
- * Retrieve the current authenticated user's profile information.
293
- */
294
- accountsProfileRetrieve(): Promise<User$2>;
295
- /**
296
- * Upload user avatar
297
- *
298
- * Upload avatar image for the current authenticated user. Accepts
299
- * multipart/form-data with 'avatar' field.
300
- */
301
- accountsProfileAvatarCreate(data: CfgAccountsProfileAvatarCreateRequest$1): Promise<User$2>;
302
- /**
303
- * Delete user account
304
- *
305
- * Permanently delete the current user's account. This operation: -
306
- * Deactivates the account (user cannot log in) - Anonymizes personal data
307
- * (GDPR compliance) - Frees up the email address for re-registration -
308
- * Preserves audit trail The account can be restored by an administrator if
309
- * needed.
310
- */
311
- accountsProfileDeleteCreate(): Promise<AccountDeleteResponse$1>;
312
- /**
313
- * Partial update user profile
314
- *
315
- * Partially update the current authenticated user's profile information.
316
- * Supports avatar upload.
317
- */
318
- accountsProfilePartialUpdate(data: UserProfileUpdateRequest$1): Promise<User$2>;
319
- /**
320
- * Partial update user profile
321
- *
322
- * Partially update the current authenticated user's profile information.
323
- * Supports avatar upload.
324
- */
325
- accountsProfilePartialPartialUpdate(data?: PatchedUserProfileUpdateRequest$1): Promise<User$2>;
326
- /**
327
- * Update user profile
328
- *
329
- * Update the current authenticated user's profile information.
330
- */
331
- accountsProfileUpdateUpdate(data: UserProfileUpdateRequest$1): Promise<User$2>;
332
- /**
333
- * Update user profile
334
- *
335
- * Update the current authenticated user's profile information.
336
- */
337
- accountsProfileUpdatePartialUpdate(data?: PatchedUserProfileUpdateRequest$1): Promise<User$2>;
10
+ interface RequestLog {
11
+ method: string;
12
+ url: string;
13
+ headers?: Record<string, string>;
14
+ body?: any;
15
+ timestamp: number;
338
16
  }
339
-
340
- /**
341
- * OTP verification response. When 2FA is required: - requires_2fa: True -
342
- * session_id: UUID of 2FA verification session - refresh/access/user: null
343
- * When 2FA is not required: - requires_2fa: False - session_id: null -
344
- * refresh/access/user: populated
345
- *
346
- * Response model (includes read-only fields).
347
- */
348
- interface OTPVerifyResponse$1 {
349
- /** Whether 2FA verification is required */
350
- requires_2fa?: boolean;
351
- /** 2FA session ID (if requires_2fa is True) */
352
- session_id?: string | null;
353
- /** JWT refresh token (if requires_2fa is False) */
354
- refresh?: string | null;
355
- /** JWT access token (if requires_2fa is False) */
356
- access?: string | null;
357
- user?: User$1 | null;
358
- /** Whether user should be prompted to enable 2FA */
359
- should_prompt_2fa?: boolean;
17
+ interface ResponseLog {
18
+ status: number;
19
+ statusText: string;
20
+ data?: any;
21
+ duration: number;
22
+ timestamp: number;
360
23
  }
361
- /**
362
- * OTP request response.
363
- *
364
- * Response model (includes read-only fields).
365
- */
366
- interface OTPRequestResponse$1 {
367
- /** Success message */
24
+ interface ErrorLog {
368
25
  message: string;
26
+ statusCode?: number;
27
+ fieldErrors?: Record<string, string[]>;
28
+ duration: number;
29
+ timestamp: number;
369
30
  }
370
- /**
371
- * Serializer for OTP verification.
372
- *
373
- * Request model (no read-only fields).
374
- */
375
- interface OTPVerifyRequest$1 {
376
- /** Email address used for OTP request */
377
- identifier: string;
378
- otp: string;
379
- /** Source URL for tracking login (e.g., https://my.djangocfg.com) */
380
- source_url?: string;
381
- }
382
- /**
383
- * Serializer for OTP request.
384
- *
385
- * Request model (no read-only fields).
386
- */
387
- interface OTPRequestRequest$1 {
388
- /** Email address for OTP delivery */
389
- identifier: string;
390
- /** Source URL for tracking registration (e.g., https://my.djangocfg.com) */
391
- source_url?: string;
392
- }
393
- /**
394
- * Serializer for user details.
395
- *
396
- * Response model (includes read-only fields).
397
- */
398
- interface User$1 {
399
- id: number;
400
- email: string;
401
- first_name?: string;
402
- last_name?: string;
403
- /** Get user's full name. */
404
- full_name: string;
405
- /** Get user's initials for avatar fallback. */
406
- initials: string;
407
- /** Get formatted username for display. */
408
- display_username: string;
409
- company?: string;
410
- phone?: string;
411
- position?: string;
412
- language?: string;
413
- avatar?: string | null;
414
- /** Designates whether the user can log into this admin site. */
415
- is_staff: boolean;
416
- /** Designates that this user has all permissions without explicitly assigning them. */
417
- is_superuser: boolean;
418
- date_joined: string;
419
- last_login?: string | null;
420
- unanswered_messages_count: number;
421
- centrifugo: CentrifugoToken$1 | null;
422
- }
423
- /**
424
- * Nested serializer for Centrifugo WebSocket connection token.
425
- *
426
- * Response model (includes read-only fields).
427
- */
428
- interface CentrifugoToken$1 {
429
- /** JWT token for Centrifugo WebSocket connection */
430
- token: string;
431
- /** Centrifugo WebSocket URL */
432
- centrifugo_url: string;
433
- /** Token expiration time (ISO 8601) */
434
- expires_at: string;
435
- /** List of allowed channels for this user */
436
- channels: Array<string>;
437
- }
438
-
439
- /**
440
- * API endpoints for Accounts.
441
- */
442
- declare class Accounts {
443
- private client;
444
- constructor(client: any);
445
- /**
446
- * Request OTP code to email.
447
- */
448
- otpRequestCreate(data: OTPRequestRequest$1): Promise<OTPRequestResponse$1>;
449
- /**
450
- * Verify OTP code and return JWT tokens or 2FA session. If user has 2FA
451
- * enabled: - Returns requires_2fa=True with session_id - Client must
452
- * complete 2FA verification at /cfg/totp/verify/ If user has no 2FA: -
453
- * Returns JWT tokens and user data directly
454
- */
455
- otpVerifyCreate(data: OTPVerifyRequest$1): Promise<OTPVerifyResponse$1>;
456
- }
457
-
458
- /**
459
- * API Logger with Consola
460
- * Beautiful console logging for API requests and responses
461
- *
462
- * Installation:
463
- * npm install consola
464
- */
465
-
466
- /**
467
- * Logger configuration
468
- */
469
- interface LoggerConfig$2 {
470
- /** Enable logging */
31
+ interface LoggerConfig {
471
32
  enabled: boolean;
472
- /** Log requests */
473
33
  logRequests: boolean;
474
- /** Log responses */
475
34
  logResponses: boolean;
476
- /** Log errors */
477
35
  logErrors: boolean;
478
- /** Log request/response bodies */
479
36
  logBodies: boolean;
480
- /** Log headers (excluding sensitive ones) */
481
37
  logHeaders: boolean;
482
- /** Custom consola instance */
483
38
  consola?: ConsolaInstance;
484
39
  }
40
+ declare class APILogger {
41
+ private config;
42
+ private consola;
43
+ constructor(config?: Partial<LoggerConfig>);
44
+ enable(): void;
45
+ disable(): void;
46
+ setConfig(config: Partial<LoggerConfig>): void;
47
+ private filterHeaders;
48
+ logRequest(request: RequestLog): void;
49
+ logResponse(request: RequestLog, response: ResponseLog): void;
50
+ logError(request: RequestLog, error: ErrorLog): void;
51
+ info(message: string, ...args: any[]): void;
52
+ warn(message: string, ...args: any[]): void;
53
+ error(message: string, ...args: any[]): void;
54
+ debug(message: string, ...args: any[]): void;
55
+ success(message: string, ...args: any[]): void;
56
+ withTag(tag: string): ConsolaInstance;
57
+ }
485
58
 
486
- /**
487
- * Retry Configuration and Utilities
488
- *
489
- * Provides automatic retry logic for failed HTTP requests using p-retry.
490
- * Retries only on network errors and server errors (5xx), not client errors (4xx).
491
- */
492
- /**
493
- * Information about a failed retry attempt.
494
- */
495
- interface FailedAttemptInfo$2 {
496
- /** The error that caused the failure */
497
- error: Error;
498
- /** The attempt number (1-indexed) */
499
- attemptNumber: number;
500
- /** Number of retries left */
501
- retriesLeft: number;
59
+ interface APIOptions$2 {
60
+ /** Override storage backend (LocalStorage by default; Memory for SSR/tests). */
61
+ storage?: StorageAdapter;
62
+ /** Logger config (defaults to dev-only). */
63
+ logger?: Partial<LoggerConfig>;
64
+ /** Locale for `Accept-Language`. If omitted, auto-detected from cookie/navigator. */
65
+ locale?: string;
66
+ /** API key sent as `X-API-Key`. Falls back to NEXT_PUBLIC_API_KEY. */
67
+ apiKey?: string;
68
+ /** Send Django session/CSRF cookies cross-origin. Defaults to true. */
69
+ withCredentials?: boolean;
502
70
  }
503
71
  /**
504
- * Retry configuration options.
72
+ * Self-contained API wrapper for this group.
505
73
  *
506
- * Uses exponential backoff with jitter by default to avoid thundering herd.
74
+ * Each group has its own client + interceptor + token store. The interceptor
75
+ * automatically attaches:
76
+ * - `Authorization: Bearer <jwt>` from storage
77
+ * - `Accept-Language` from `opts.locale` or `NEXT_LOCALE` cookie
78
+ * - `X-API-Key` from `opts.apiKey` or `NEXT_PUBLIC_API_KEY`
79
+ * - `credentials: 'include'` for Django session/CSRF cookies (toggle via opts)
507
80
  */
508
- interface RetryConfig$2 {
509
- /**
510
- * Maximum number of retry attempts.
511
- * @default 3
512
- */
513
- retries?: number;
514
- /**
515
- * Exponential backoff factor.
516
- * @default 2
517
- */
518
- factor?: number;
519
- /**
520
- * Minimum wait time between retries (ms).
521
- * @default 1000
522
- */
523
- minTimeout?: number;
524
- /**
525
- * Maximum wait time between retries (ms).
526
- * @default 60000
527
- */
528
- maxTimeout?: number;
529
- /**
530
- * Add randomness to wait times (jitter).
531
- * Helps avoid thundering herd problem.
532
- * @default true
533
- */
534
- randomize?: boolean;
535
- /**
536
- * Callback called on each failed attempt.
537
- */
538
- onFailedAttempt?: (info: FailedAttemptInfo$2) => void;
81
+ declare class API$2 {
82
+ private baseUrl;
83
+ private storage;
84
+ private locale;
85
+ private apiKey;
86
+ readonly logger: APILogger;
87
+ constructor(baseUrl: string, opts?: APIOptions$2);
88
+ getBaseUrl(): string;
89
+ setBaseUrl(url: string): void;
90
+ getToken(): string | null;
91
+ setToken(token: string | null): void;
92
+ getRefreshToken(): string | null;
93
+ setRefreshToken(token: string | null): void;
94
+ clearToken(): void;
95
+ isAuthenticated(): boolean;
96
+ getLocale(): string | null;
97
+ setLocale(locale: string | null): void;
98
+ getApiKey(): string | null;
99
+ setApiKey(key: string | null): void;
539
100
  }
540
101
 
541
- /**
542
- * Storage adapters for cross-platform token storage.
543
- *
544
- * Supports:
545
- * - LocalStorage (browser)
546
- * - Cookies (SSR/browser)
547
- * - Memory (Node.js/Electron/testing)
548
- */
549
-
550
- /**
551
- * Storage adapter interface for cross-platform token storage.
552
- */
553
- interface StorageAdapter$2 {
554
- getItem(key: string): string | null;
555
- setItem(key: string, value: string): void;
556
- removeItem(key: string): void;
102
+ interface APIOptions$1 {
103
+ /** Override storage backend (LocalStorage by default; Memory for SSR/tests). */
104
+ storage?: StorageAdapter;
105
+ /** Logger config (defaults to dev-only). */
106
+ logger?: Partial<LoggerConfig>;
107
+ /** Locale for `Accept-Language`. If omitted, auto-detected from cookie/navigator. */
108
+ locale?: string;
109
+ /** API key sent as `X-API-Key`. Falls back to NEXT_PUBLIC_API_KEY. */
110
+ apiKey?: string;
111
+ /** Send Django session/CSRF cookies cross-origin. Defaults to true. */
112
+ withCredentials?: boolean;
557
113
  }
558
-
559
- /**
560
- * Zod schema for AccountDeleteResponse
561
- *
562
- * This schema provides runtime validation and type inference.
563
- * * Response serializer for account deletion.
564
- * */
565
-
566
- /**
567
- * Response serializer for account deletion.
568
- */
569
- declare const AccountDeleteResponseSchema: z.ZodObject<{
570
- success: z.ZodBoolean;
571
- message: z.ZodString;
572
- }, z.core.$strip>;
573
- /**
574
- * Infer TypeScript type from Zod schema
575
- */
576
- type AccountDeleteResponse = z.infer<typeof AccountDeleteResponseSchema>;
577
-
578
- /**
579
- * Zod schema for CentrifugoToken
580
- *
581
- * This schema provides runtime validation and type inference.
582
- * * Nested serializer for Centrifugo WebSocket connection token.
583
- * */
584
-
585
- /**
586
- * Nested serializer for Centrifugo WebSocket connection token.
587
- */
588
- declare const CentrifugoTokenSchema: z.ZodObject<{
589
- token: z.ZodString;
590
- centrifugo_url: z.ZodString;
591
- expires_at: z.ZodString;
592
- channels: z.ZodArray<z.ZodString>;
593
- }, z.core.$strip>;
594
- /**
595
- * Infer TypeScript type from Zod schema
596
- */
597
- type CentrifugoToken = z.infer<typeof CentrifugoTokenSchema>;
598
-
599
- /**
600
- * Zod schema for CfgAccountsProfileAvatarCreateRequest
601
- *
602
- * This schema provides runtime validation and type inference.
603
- * */
604
-
605
- declare const CfgAccountsProfileAvatarCreateRequestSchema: z.ZodObject<{
606
- avatar: z.ZodUnion<readonly [z.ZodCustom<File, File>, z.ZodCustom<Blob, Blob>]>;
607
- }, z.core.$strip>;
608
- /**
609
- * Infer TypeScript type from Zod schema
610
- */
611
- type CfgAccountsProfileAvatarCreateRequest = z.infer<typeof CfgAccountsProfileAvatarCreateRequestSchema>;
612
-
613
- /**
614
- * Zod schema for OAuthAuthorizeRequestRequest
615
- *
616
- * This schema provides runtime validation and type inference.
617
- * * Request to start OAuth flow.
618
- * */
619
-
620
- /**
621
- * Request to start OAuth flow.
622
- */
623
- declare const OAuthAuthorizeRequestRequestSchema: z.ZodObject<{
624
- redirect_uri: z.ZodOptional<z.ZodString>;
625
- source_url: z.ZodOptional<z.ZodString>;
626
- }, z.core.$strip>;
627
- /**
628
- * Infer TypeScript type from Zod schema
629
- */
630
- type OAuthAuthorizeRequestRequest = z.infer<typeof OAuthAuthorizeRequestRequestSchema>;
631
-
632
- /**
633
- * Zod schema for OAuthAuthorizeResponse
634
- *
635
- * This schema provides runtime validation and type inference.
636
- * * Response with OAuth authorization URL.
637
- * */
638
-
639
- /**
640
- * Response with OAuth authorization URL.
641
- */
642
- declare const OAuthAuthorizeResponseSchema: z.ZodObject<{
643
- authorization_url: z.ZodString;
644
- state: z.ZodString;
645
- }, z.core.$strip>;
646
- /**
647
- * Infer TypeScript type from Zod schema
648
- */
649
- type OAuthAuthorizeResponse = z.infer<typeof OAuthAuthorizeResponseSchema>;
650
-
651
- /**
652
- * Zod schema for OAuthCallbackRequestRequest
653
- *
654
- * This schema provides runtime validation and type inference.
655
- * * Request to complete OAuth flow (callback handler).
656
- * */
657
-
658
- /**
659
- * Request to complete OAuth flow (callback handler).
660
- */
661
- declare const OAuthCallbackRequestRequestSchema: z.ZodObject<{
662
- code: z.ZodString;
663
- state: z.ZodString;
664
- redirect_uri: z.ZodOptional<z.ZodString>;
665
- }, z.core.$strip>;
666
114
  /**
667
- * Infer TypeScript type from Zod schema
668
- */
669
- type OAuthCallbackRequestRequest = z.infer<typeof OAuthCallbackRequestRequestSchema>;
670
-
671
- /**
672
- * Zod schema for OAuthConnection
673
- *
674
- * This schema provides runtime validation and type inference.
675
- * * Serializer for OAuth connection info (user-facing).
676
- * */
677
-
678
- /**
679
- * Serializer for OAuth connection info (user-facing).
680
- */
681
- declare const OAuthConnectionSchema: z.ZodObject<{
682
- id: z.ZodNumber;
683
- provider: z.ZodEnum<typeof OAuthConnectionProvider>;
684
- provider_display: z.ZodString;
685
- provider_username: z.ZodString;
686
- provider_email: z.ZodEmail;
687
- provider_avatar_url: z.ZodString;
688
- connected_at: z.ZodString;
689
- last_login_at: z.ZodString;
690
- }, z.core.$strip>;
691
- /**
692
- * Infer TypeScript type from Zod schema
693
- */
694
- type OAuthConnection = z.infer<typeof OAuthConnectionSchema>;
695
-
696
- /**
697
- * Zod schema for OAuthDisconnectRequestRequest
698
- *
699
- * This schema provides runtime validation and type inference.
700
- * * Request to disconnect OAuth provider.
701
- * */
702
-
703
- /**
704
- * Request to disconnect OAuth provider.
705
- */
706
- declare const OAuthDisconnectRequestRequestSchema: z.ZodObject<{
707
- provider: z.ZodEnum<typeof OAuthConnectionProvider>;
708
- }, z.core.$strip>;
709
- /**
710
- * Infer TypeScript type from Zod schema
711
- */
712
- type OAuthDisconnectRequestRequest = z.infer<typeof OAuthDisconnectRequestRequestSchema>;
713
-
714
- /**
715
- * Zod schema for OAuthError
716
- *
717
- * This schema provides runtime validation and type inference.
718
- * * Error response for OAuth endpoints.
719
- * */
720
-
721
- /**
722
- * Error response for OAuth endpoints.
723
- */
724
- declare const OAuthErrorSchema: z.ZodObject<{
725
- error: z.ZodString;
726
- error_description: z.ZodOptional<z.ZodString>;
727
- }, z.core.$strip>;
728
- /**
729
- * Infer TypeScript type from Zod schema
730
- */
731
- type OAuthError = z.infer<typeof OAuthErrorSchema>;
732
-
733
- /**
734
- * Zod schema for OAuthProvidersResponse
735
- *
736
- * This schema provides runtime validation and type inference.
737
- * * Response with available OAuth providers.
738
- * */
739
-
740
- /**
741
- * Response with available OAuth providers.
742
- */
743
- declare const OAuthProvidersResponseSchema: z.ZodObject<{
744
- providers: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodAny>>;
745
- }, z.core.$strip>;
746
- /**
747
- * Infer TypeScript type from Zod schema
748
- */
749
- type OAuthProvidersResponse = z.infer<typeof OAuthProvidersResponseSchema>;
750
-
751
- /**
752
- * Zod schema for OAuthTokenResponse
115
+ * Self-contained API wrapper for this group.
753
116
  *
754
- * This schema provides runtime validation and type inference.
755
- * * Response with JWT tokens after OAuth authentication.
756
-
757
- When 2FA is required:
758
- - requires_2fa: True
759
- - session_id: UUID of 2FA verification session
760
- - access/refresh/user: null
761
-
762
- When 2FA is not required:
763
- - requires_2fa: False
764
- - session_id: null
765
- - access/refresh/user: populated
766
- * */
767
-
768
- /**
769
- * Response with JWT tokens after OAuth authentication.
770
-
771
- When 2FA is required:
772
- - requires_2fa: True
773
- - session_id: UUID of 2FA verification session
774
- - access/refresh/user: null
775
-
776
- When 2FA is not required:
777
- - requires_2fa: False
778
- - session_id: null
779
- - access/refresh/user: populated
780
- */
781
- declare const OAuthTokenResponseSchema: z.ZodObject<{
782
- requires_2fa: z.ZodOptional<z.ZodBoolean>;
783
- session_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
784
- access: z.ZodOptional<z.ZodNullable<z.ZodString>>;
785
- refresh: z.ZodOptional<z.ZodNullable<z.ZodString>>;
786
- user: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodAny>>>;
787
- is_new_user: z.ZodBoolean;
788
- is_new_connection: z.ZodBoolean;
789
- should_prompt_2fa: z.ZodOptional<z.ZodBoolean>;
790
- }, z.core.$strip>;
791
- /**
792
- * Infer TypeScript type from Zod schema
117
+ * Each group has its own client + interceptor + token store. The interceptor
118
+ * automatically attaches:
119
+ * - `Authorization: Bearer <jwt>` from storage
120
+ * - `Accept-Language` from `opts.locale` or `NEXT_LOCALE` cookie
121
+ * - `X-API-Key` from `opts.apiKey` or `NEXT_PUBLIC_API_KEY`
122
+ * - `credentials: 'include'` for Django session/CSRF cookies (toggle via opts)
793
123
  */
794
- type OAuthTokenResponse = z.infer<typeof OAuthTokenResponseSchema>;
124
+ declare class API$1 {
125
+ private baseUrl;
126
+ private storage;
127
+ private locale;
128
+ private apiKey;
129
+ readonly logger: APILogger;
130
+ constructor(baseUrl: string, opts?: APIOptions$1);
131
+ getBaseUrl(): string;
132
+ setBaseUrl(url: string): void;
133
+ getToken(): string | null;
134
+ setToken(token: string | null): void;
135
+ getRefreshToken(): string | null;
136
+ setRefreshToken(token: string | null): void;
137
+ clearToken(): void;
138
+ isAuthenticated(): boolean;
139
+ getLocale(): string | null;
140
+ setLocale(locale: string | null): void;
141
+ getApiKey(): string | null;
142
+ setApiKey(key: string | null): void;
143
+ }
795
144
 
145
+ interface APIOptions {
146
+ /** Override storage backend (LocalStorage by default; Memory for SSR/tests). */
147
+ storage?: StorageAdapter;
148
+ /** Logger config (defaults to dev-only). */
149
+ logger?: Partial<LoggerConfig>;
150
+ /** Locale for `Accept-Language`. If omitted, auto-detected from cookie/navigator. */
151
+ locale?: string;
152
+ /** API key sent as `X-API-Key`. Falls back to NEXT_PUBLIC_API_KEY. */
153
+ apiKey?: string;
154
+ /** Send Django session/CSRF cookies cross-origin. Defaults to true. */
155
+ withCredentials?: boolean;
156
+ }
796
157
  /**
797
- * Zod schema for OTPErrorResponse
158
+ * Self-contained API wrapper for this group.
798
159
  *
799
- * This schema provides runtime validation and type inference.
800
- * * Typed error response for OTP operations.
801
-
802
- error_code values:
803
- - invalid_identifier malformed email
804
- - cooldown — too soon after last request (retry_after = seconds)
805
- - hourly_limit — hourly quota exceeded (retry_after = seconds until reset)
806
- - daily_limit — daily quota exceeded (retry_after = seconds until reset)
807
- - rate_limited — IP-level rate limit hit (no retry_after)
808
- - user_creation_failed — internal error creating account
809
- - send_failed — transport error (email / SMS)
810
- - internal_error — unexpected server error
811
- * */
812
-
813
- /**
814
- * Typed error response for OTP operations.
815
-
816
- error_code values:
817
- - invalid_identifier — malformed email
818
- - cooldown — too soon after last request (retry_after = seconds)
819
- - hourly_limit — hourly quota exceeded (retry_after = seconds until reset)
820
- - daily_limit — daily quota exceeded (retry_after = seconds until reset)
821
- - rate_limited — IP-level rate limit hit (no retry_after)
822
- - user_creation_failed — internal error creating account
823
- - send_failed — transport error (email / SMS)
824
- - internal_error — unexpected server error
825
- */
826
- declare const OTPErrorResponseSchema: z.ZodObject<{
827
- error: z.ZodString;
828
- error_code: z.ZodOptional<z.ZodNullable<z.ZodString>>;
829
- retry_after: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
830
- }, z.core.$strip>;
831
- /**
832
- * Infer TypeScript type from Zod schema
160
+ * Each group has its own client + interceptor + token store. The interceptor
161
+ * automatically attaches:
162
+ * - `Authorization: Bearer <jwt>` from storage
163
+ * - `Accept-Language` from `opts.locale` or `NEXT_LOCALE` cookie
164
+ * - `X-API-Key` from `opts.apiKey` or `NEXT_PUBLIC_API_KEY`
165
+ * - `credentials: 'include'` for Django session/CSRF cookies (toggle via opts)
833
166
  */
834
- type OTPErrorResponse = z.infer<typeof OTPErrorResponseSchema>;
835
-
836
- /**
837
- * Zod schema for OTPRequestRequest
838
- *
839
- * This schema provides runtime validation and type inference.
840
- * * Serializer for OTP request.
841
- * */
842
-
843
- /**
844
- * Serializer for OTP request.
845
- */
846
- declare const OTPRequestRequestSchema: z.ZodObject<{
847
- identifier: z.ZodString;
848
- source_url: z.ZodOptional<z.ZodString>;
849
- }, z.core.$strip>;
850
- /**
851
- * Infer TypeScript type from Zod schema
852
- */
853
- type OTPRequestRequest = z.infer<typeof OTPRequestRequestSchema>;
854
-
855
- /**
856
- * Zod schema for OTPRequestResponse
857
- *
858
- * This schema provides runtime validation and type inference.
859
- * * OTP request response.
860
- * */
861
-
862
- /**
863
- * OTP request response.
864
- */
865
- declare const OTPRequestResponseSchema: z.ZodObject<{
866
- message: z.ZodString;
867
- }, z.core.$strip>;
868
- /**
869
- * Infer TypeScript type from Zod schema
870
- */
871
- type OTPRequestResponse = z.infer<typeof OTPRequestResponseSchema>;
872
-
873
- /**
874
- * Zod schema for OTPVerifyRequest
875
- *
876
- * This schema provides runtime validation and type inference.
877
- * * Serializer for OTP verification.
878
- * */
879
-
880
- /**
881
- * Serializer for OTP verification.
882
- */
883
- declare const OTPVerifyRequestSchema: z.ZodObject<{
884
- identifier: z.ZodString;
885
- otp: z.ZodString;
886
- source_url: z.ZodOptional<z.ZodString>;
887
- }, z.core.$strip>;
888
- /**
889
- * Infer TypeScript type from Zod schema
890
- */
891
- type OTPVerifyRequest = z.infer<typeof OTPVerifyRequestSchema>;
892
-
893
- /**
894
- * Zod schema for OTPVerifyResponse
895
- *
896
- * This schema provides runtime validation and type inference.
897
- * * OTP verification response.
898
-
899
- When 2FA is required:
900
- - requires_2fa: True
901
- - session_id: UUID of 2FA verification session
902
- - refresh/access/user: null
903
-
904
- When 2FA is not required:
905
- - requires_2fa: False
906
- - session_id: null
907
- - refresh/access/user: populated
908
- * */
909
-
910
- /**
911
- * OTP verification response.
912
-
913
- When 2FA is required:
914
- - requires_2fa: True
915
- - session_id: UUID of 2FA verification session
916
- - refresh/access/user: null
917
-
918
- When 2FA is not required:
919
- - requires_2fa: False
920
- - session_id: null
921
- - refresh/access/user: populated
922
- */
923
- declare const OTPVerifyResponseSchema: z.ZodObject<{
924
- requires_2fa: z.ZodOptional<z.ZodBoolean>;
925
- session_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
926
- refresh: z.ZodOptional<z.ZodNullable<z.ZodString>>;
927
- access: z.ZodOptional<z.ZodNullable<z.ZodString>>;
928
- user: z.ZodOptional<z.ZodNullable<z.ZodObject<{
929
- id: z.ZodNumber;
930
- email: z.ZodEmail;
931
- first_name: z.ZodOptional<z.ZodString>;
932
- last_name: z.ZodOptional<z.ZodString>;
933
- full_name: z.ZodString;
934
- initials: z.ZodString;
935
- display_username: z.ZodString;
936
- company: z.ZodOptional<z.ZodString>;
937
- phone: z.ZodOptional<z.ZodString>;
938
- position: z.ZodOptional<z.ZodString>;
939
- language: z.ZodOptional<z.ZodString>;
940
- avatar: z.ZodNullable<z.ZodString>;
941
- is_staff: z.ZodBoolean;
942
- is_superuser: z.ZodBoolean;
943
- date_joined: z.ZodString;
944
- last_login: z.ZodNullable<z.ZodString>;
945
- unanswered_messages_count: z.ZodNumber;
946
- centrifugo: z.ZodNullable<z.ZodObject<{
947
- token: z.ZodString;
948
- centrifugo_url: z.ZodString;
949
- expires_at: z.ZodString;
950
- channels: z.ZodArray<z.ZodString>;
951
- }, z.core.$strip>>;
952
- }, z.core.$strip>>>;
953
- should_prompt_2fa: z.ZodOptional<z.ZodBoolean>;
954
- }, z.core.$strip>;
955
- /**
956
- * Infer TypeScript type from Zod schema
957
- */
958
- type OTPVerifyResponse = z.infer<typeof OTPVerifyResponseSchema>;
959
-
960
- /**
961
- * Zod schema for PatchedUserProfileUpdateRequest
962
- *
963
- * This schema provides runtime validation and type inference.
964
- * * Serializer for updating user profile.
965
- * */
966
-
967
- /**
968
- * Serializer for updating user profile.
969
- */
970
- declare const PatchedUserProfileUpdateRequestSchema: z.ZodObject<{
971
- first_name: z.ZodOptional<z.ZodString>;
972
- last_name: z.ZodOptional<z.ZodString>;
973
- company: z.ZodOptional<z.ZodString>;
974
- phone: z.ZodOptional<z.ZodString>;
975
- position: z.ZodOptional<z.ZodString>;
976
- language: z.ZodOptional<z.ZodString>;
977
- }, z.core.$strip>;
978
- /**
979
- * Infer TypeScript type from Zod schema
980
- */
981
- type PatchedUserProfileUpdateRequest = z.infer<typeof PatchedUserProfileUpdateRequestSchema>;
982
-
983
- /**
984
- * Zod schema for TokenRefresh
985
- *
986
- * This schema provides runtime validation and type inference.
987
- * */
988
-
989
- declare const TokenRefreshSchema: z.ZodObject<{
990
- access: z.ZodString;
991
- refresh: z.ZodString;
992
- }, z.core.$strip>;
993
- /**
994
- * Infer TypeScript type from Zod schema
995
- */
996
- type TokenRefresh = z.infer<typeof TokenRefreshSchema>;
997
-
998
- /**
999
- * Zod schema for TokenRefreshRequest
1000
- *
1001
- * This schema provides runtime validation and type inference.
1002
- * */
1003
-
1004
- declare const TokenRefreshRequestSchema: z.ZodObject<{
1005
- refresh: z.ZodString;
1006
- }, z.core.$strip>;
1007
- /**
1008
- * Infer TypeScript type from Zod schema
1009
- */
1010
- type TokenRefreshRequest = z.infer<typeof TokenRefreshRequestSchema>;
1011
-
1012
- /**
1013
- * Zod schema for User
1014
- *
1015
- * This schema provides runtime validation and type inference.
1016
- * * Serializer for user details.
1017
- * */
1018
-
1019
- /**
1020
- * Serializer for user details.
1021
- */
1022
- declare const UserSchema: z.ZodObject<{
1023
- id: z.ZodNumber;
1024
- email: z.ZodEmail;
1025
- first_name: z.ZodOptional<z.ZodString>;
1026
- last_name: z.ZodOptional<z.ZodString>;
1027
- full_name: z.ZodString;
1028
- initials: z.ZodString;
1029
- display_username: z.ZodString;
1030
- company: z.ZodOptional<z.ZodString>;
1031
- phone: z.ZodOptional<z.ZodString>;
1032
- position: z.ZodOptional<z.ZodString>;
1033
- language: z.ZodOptional<z.ZodString>;
1034
- avatar: z.ZodNullable<z.ZodString>;
1035
- is_staff: z.ZodBoolean;
1036
- is_superuser: z.ZodBoolean;
1037
- date_joined: z.ZodString;
1038
- last_login: z.ZodNullable<z.ZodString>;
1039
- unanswered_messages_count: z.ZodNumber;
1040
- centrifugo: z.ZodNullable<z.ZodObject<{
1041
- token: z.ZodString;
1042
- centrifugo_url: z.ZodString;
1043
- expires_at: z.ZodString;
1044
- channels: z.ZodArray<z.ZodString>;
1045
- }, z.core.$strip>>;
1046
- }, z.core.$strip>;
1047
- /**
1048
- * Infer TypeScript type from Zod schema
1049
- */
1050
- type User = z.infer<typeof UserSchema>;
1051
-
1052
- /**
1053
- * Zod schema for UserProfileUpdateRequest
1054
- *
1055
- * This schema provides runtime validation and type inference.
1056
- * * Serializer for updating user profile.
1057
- * */
1058
-
1059
- /**
1060
- * Serializer for updating user profile.
1061
- */
1062
- declare const UserProfileUpdateRequestSchema: z.ZodObject<{
1063
- first_name: z.ZodOptional<z.ZodString>;
1064
- last_name: z.ZodOptional<z.ZodString>;
1065
- company: z.ZodOptional<z.ZodString>;
1066
- phone: z.ZodOptional<z.ZodString>;
1067
- position: z.ZodOptional<z.ZodString>;
1068
- language: z.ZodOptional<z.ZodString>;
1069
- }, z.core.$strip>;
1070
- /**
1071
- * Infer TypeScript type from Zod schema
1072
- */
1073
- type UserProfileUpdateRequest = z.infer<typeof UserProfileUpdateRequestSchema>;
1074
-
1075
- /**
1076
- * API operation
1077
- *
1078
- * @method POST
1079
- * @path /cfg/accounts/otp/request/
1080
- */
1081
- declare function createAccountsOtpRequestCreate(data: OTPRequestRequest, client?: any): Promise<OTPRequestResponse>;
1082
- /**
1083
- * API operation
1084
- *
1085
- * @method POST
1086
- * @path /cfg/accounts/otp/verify/
1087
- */
1088
- declare function createAccountsOtpVerifyCreate(data: OTPVerifyRequest, client?: any): Promise<OTPVerifyResponse>;
1089
-
1090
- /**
1091
- * API operation
1092
- *
1093
- * @method POST
1094
- * @path /cfg/accounts/token/refresh/
1095
- */
1096
- declare function createAccountsTokenRefreshCreate(data: TokenRefreshRequest, client?: any): Promise<TokenRefresh>;
1097
-
1098
- /**
1099
- * List OAuth connections
1100
- *
1101
- * @method GET
1102
- * @path /cfg/accounts/oauth/connections/
1103
- */
1104
- declare function getAccountsOauthConnectionsList(client?: any): Promise<OAuthConnection[]>;
1105
- /**
1106
- * Disconnect OAuth provider
1107
- *
1108
- * @method POST
1109
- * @path /cfg/accounts/oauth/disconnect/
1110
- */
1111
- declare function createAccountsOauthDisconnectCreate(data: OAuthDisconnectRequestRequest, client?: any): Promise<any>;
1112
- /**
1113
- * Start GitHub OAuth
1114
- *
1115
- * @method POST
1116
- * @path /cfg/accounts/oauth/github/authorize/
1117
- */
1118
- declare function createAccountsOauthGithubAuthorizeCreate(data: OAuthAuthorizeRequestRequest, client?: any): Promise<OAuthAuthorizeResponse>;
1119
- /**
1120
- * Complete GitHub OAuth
1121
- *
1122
- * @method POST
1123
- * @path /cfg/accounts/oauth/github/callback/
1124
- */
1125
- declare function createAccountsOauthGithubCallbackCreate(data: OAuthCallbackRequestRequest, client?: any): Promise<OAuthTokenResponse>;
1126
- /**
1127
- * List OAuth providers
1128
- *
1129
- * @method GET
1130
- * @path /cfg/accounts/oauth/providers/
1131
- */
1132
- declare function getAccountsOauthProvidersRetrieve(client?: any): Promise<OAuthProvidersResponse>;
1133
-
1134
- /**
1135
- * Get current user profile
1136
- *
1137
- * @method GET
1138
- * @path /cfg/accounts/profile/
1139
- */
1140
- declare function getAccountsProfileRetrieve(client?: any): Promise<User>;
1141
- /**
1142
- * Upload user avatar
1143
- *
1144
- * @method POST
1145
- * @path /cfg/accounts/profile/avatar/
1146
- */
1147
- declare function createAccountsProfileAvatarCreate(data: CfgAccountsProfileAvatarCreateRequest, client?: any): Promise<User>;
1148
- /**
1149
- * Delete user account
1150
- *
1151
- * @method POST
1152
- * @path /cfg/accounts/profile/delete/
1153
- */
1154
- declare function createAccountsProfileDeleteCreate(client?: any): Promise<AccountDeleteResponse>;
1155
- /**
1156
- * Partial update user profile
1157
- *
1158
- * @method PUT
1159
- * @path /cfg/accounts/profile/partial/
1160
- */
1161
- declare function partialUpdateAccountsProfilePartialUpdate(data: UserProfileUpdateRequest, client?: any): Promise<User>;
1162
- /**
1163
- * Partial update user profile
1164
- *
1165
- * @method PATCH
1166
- * @path /cfg/accounts/profile/partial/
1167
- */
1168
- declare function partialUpdateAccountsProfilePartialPartialUpdate(data?: PatchedUserProfileUpdateRequest, client?: any): Promise<User>;
1169
- /**
1170
- * Update user profile
1171
- *
1172
- * @method PUT
1173
- * @path /cfg/accounts/profile/update/
1174
- */
1175
- declare function updateAccountsProfileUpdateUpdate(data: UserProfileUpdateRequest, client?: any): Promise<User>;
1176
- /**
1177
- * Update user profile
1178
- *
1179
- * @method PATCH
1180
- * @path /cfg/accounts/profile/update/
1181
- */
1182
- declare function partialUpdateAccountsProfileUpdatePartialUpdate(data?: PatchedUserProfileUpdateRequest, client?: any): Promise<User>;
1183
-
1184
- /**
1185
- * Django CFG API - API Client with JWT Management
1186
- *
1187
- * Usage:
1188
- * ```typescript
1189
- * import { API } from './api';
1190
- *
1191
- * const api = new API('https://api.example.com');
1192
- *
1193
- * // Set JWT token
1194
- * api.setToken('your-jwt-token', 'refresh-token');
1195
- *
1196
- * // Use API
1197
- * const posts = await api.posts.list();
1198
- * const user = await api.users.retrieve(1);
1199
- *
1200
- * // Check authentication
1201
- * if (api.isAuthenticated()) {
1202
- * // ...
1203
- * }
1204
- *
1205
- * // Custom storage with logging (for Electron/Node.js)
1206
- * import { MemoryStorageAdapter, APILogger } from './storage';
1207
- * const logger = new APILogger({ enabled: true, logLevel: 'debug' });
1208
- * const api = new API('https://api.example.com', {
1209
- * storage: new MemoryStorageAdapter(logger),
1210
- * loggerConfig: { enabled: true, logLevel: 'debug' }
1211
- * });
1212
- *
1213
- * // Get OpenAPI schema
1214
- * const schema = api.getSchema();
1215
- * ```
1216
- */
1217
-
1218
- interface APIOptions$2 {
1219
- /** Custom storage adapter (defaults to LocalStorageAdapter) */
1220
- storage?: StorageAdapter$2;
1221
- /** Custom HTTP client adapter (defaults to FetchAdapter) */
1222
- httpClient?: HttpClientAdapter;
1223
- /** Retry configuration for failed requests */
1224
- retryConfig?: RetryConfig$2;
1225
- /** Logger configuration */
1226
- loggerConfig?: Partial<LoggerConfig$2>;
1227
- /** Locale for Accept-Language header (e.g. 'en', 'ko', 'ru') */
1228
- locale?: string;
1229
- }
1230
- declare class API$2 {
1231
- private baseUrl;
1232
- private _client;
1233
- private _token;
1234
- private _refreshToken;
1235
- private _locale;
1236
- private storage;
1237
- private options?;
1238
- auth: Auth;
1239
- oauth: Oauth;
1240
- user_profile: UserProfile;
1241
- accounts: Accounts;
1242
- constructor(baseUrl: string, options?: APIOptions$2);
1243
- private _loadTokensFromStorage;
1244
- private _reinitClients;
1245
- private _injectAuthHeader;
1246
- /**
1247
- * Get current JWT token
1248
- */
1249
- getToken(): string | null;
1250
- /**
1251
- * Get current refresh token
1252
- */
1253
- getRefreshToken(): string | null;
1254
- /**
1255
- * Set JWT token and refresh token
1256
- * @param token - JWT access token
1257
- * @param refreshToken - JWT refresh token (optional)
1258
- */
1259
- setToken(token: string, refreshToken?: string): void;
1260
- /**
1261
- * Clear all tokens
1262
- */
1263
- clearTokens(): void;
1264
- /**
1265
- * Check if user is authenticated
1266
- */
1267
- isAuthenticated(): boolean;
1268
- /**
1269
- * Update base URL and reinitialize clients
1270
- * @param url - New base URL
1271
- */
1272
- setBaseUrl(url: string): void;
1273
- /**
1274
- * Get current base URL
1275
- */
1276
- getBaseUrl(): string;
1277
- /**
1278
- * Set locale for Accept-Language header
1279
- * @param locale - Locale string (e.g. 'en', 'ko', 'ru') or null to clear
1280
- */
1281
- setLocale(locale: string | null): void;
1282
- /**
1283
- * Get current locale
1284
- */
1285
- getLocale(): string | null;
1286
- /**
1287
- * Get OpenAPI schema path
1288
- * @returns Path to the OpenAPI schema JSON file
1289
- *
1290
- * Note: The OpenAPI schema is available in the schema.json file.
1291
- * You can load it dynamically using:
1292
- * ```typescript
1293
- * const schema = await fetch('./schema.json').then(r => r.json());
1294
- * // or using fs in Node.js:
1295
- * // const schema = JSON.parse(fs.readFileSync('./schema.json', 'utf-8'));
1296
- * ```
1297
- */
1298
- getSchemaPath(): string;
1299
- }
1300
-
1301
- /**
1302
- * Response model for Centrifugo connection token.
1303
- *
1304
- * Response model (includes read-only fields).
1305
- */
1306
- interface ConnectionTokenResponse$1 {
1307
- /** JWT token for Centrifugo connection */
1308
- token: string;
1309
- /** Centrifugo WebSocket URL */
1310
- centrifugo_url: string;
1311
- /** Token expiration time (ISO 8601) */
1312
- expires_at: string;
1313
- /** List of allowed channels */
1314
- channels: Array<string>;
1315
- }
1316
-
1317
- /**
1318
- * API endpoints for Centrifugo Auth.
1319
- */
1320
- declare class CentrifugoAuth {
1321
- private client;
1322
- constructor(client: any);
1323
- /**
1324
- * Get Centrifugo connection token
1325
- *
1326
- * Generate JWT token for WebSocket connection to Centrifugo. Token
1327
- * includes user's allowed channels based on their permissions. Requires
1328
- * authentication.
1329
- */
1330
- tokenRetrieve(): Promise<ConnectionTokenResponse$1>;
1331
- }
1332
-
1333
- /**
1334
- * API Logger with Consola
1335
- * Beautiful console logging for API requests and responses
1336
- *
1337
- * Installation:
1338
- * npm install consola
1339
- */
1340
-
1341
- /**
1342
- * Logger configuration
1343
- */
1344
- interface LoggerConfig$1 {
1345
- /** Enable logging */
1346
- enabled: boolean;
1347
- /** Log requests */
1348
- logRequests: boolean;
1349
- /** Log responses */
1350
- logResponses: boolean;
1351
- /** Log errors */
1352
- logErrors: boolean;
1353
- /** Log request/response bodies */
1354
- logBodies: boolean;
1355
- /** Log headers (excluding sensitive ones) */
1356
- logHeaders: boolean;
1357
- /** Custom consola instance */
1358
- consola?: ConsolaInstance;
1359
- }
1360
-
1361
- /**
1362
- * Retry Configuration and Utilities
1363
- *
1364
- * Provides automatic retry logic for failed HTTP requests using p-retry.
1365
- * Retries only on network errors and server errors (5xx), not client errors (4xx).
1366
- */
1367
- /**
1368
- * Information about a failed retry attempt.
1369
- */
1370
- interface FailedAttemptInfo$1 {
1371
- /** The error that caused the failure */
1372
- error: Error;
1373
- /** The attempt number (1-indexed) */
1374
- attemptNumber: number;
1375
- /** Number of retries left */
1376
- retriesLeft: number;
1377
- }
1378
- /**
1379
- * Retry configuration options.
1380
- *
1381
- * Uses exponential backoff with jitter by default to avoid thundering herd.
1382
- */
1383
- interface RetryConfig$1 {
1384
- /**
1385
- * Maximum number of retry attempts.
1386
- * @default 3
1387
- */
1388
- retries?: number;
1389
- /**
1390
- * Exponential backoff factor.
1391
- * @default 2
1392
- */
1393
- factor?: number;
1394
- /**
1395
- * Minimum wait time between retries (ms).
1396
- * @default 1000
1397
- */
1398
- minTimeout?: number;
1399
- /**
1400
- * Maximum wait time between retries (ms).
1401
- * @default 60000
1402
- */
1403
- maxTimeout?: number;
1404
- /**
1405
- * Add randomness to wait times (jitter).
1406
- * Helps avoid thundering herd problem.
1407
- * @default true
1408
- */
1409
- randomize?: boolean;
1410
- /**
1411
- * Callback called on each failed attempt.
1412
- */
1413
- onFailedAttempt?: (info: FailedAttemptInfo$1) => void;
1414
- }
1415
-
1416
- /**
1417
- * Storage adapters for cross-platform token storage.
1418
- *
1419
- * Supports:
1420
- * - LocalStorage (browser)
1421
- * - Cookies (SSR/browser)
1422
- * - Memory (Node.js/Electron/testing)
1423
- */
1424
-
1425
- /**
1426
- * Storage adapter interface for cross-platform token storage.
1427
- */
1428
- interface StorageAdapter$1 {
1429
- getItem(key: string): string | null;
1430
- setItem(key: string, value: string): void;
1431
- removeItem(key: string): void;
1432
- }
1433
-
1434
- /**
1435
- * Zod schema for ConnectionTokenResponse
1436
- *
1437
- * This schema provides runtime validation and type inference.
1438
- * * Response model for Centrifugo connection token.
1439
- * */
1440
-
1441
- /**
1442
- * Response model for Centrifugo connection token.
1443
- */
1444
- declare const ConnectionTokenResponseSchema: z.ZodObject<{
1445
- token: z.ZodString;
1446
- centrifugo_url: z.ZodString;
1447
- expires_at: z.ZodString;
1448
- channels: z.ZodArray<z.ZodString>;
1449
- }, z.core.$strip>;
1450
- /**
1451
- * Infer TypeScript type from Zod schema
1452
- */
1453
- type ConnectionTokenResponse = z.infer<typeof ConnectionTokenResponseSchema>;
1454
-
1455
- /**
1456
- * Zod Schemas - Runtime validation and type inference
1457
- *
1458
- * Auto-generated from OpenAPI specification.
1459
- * Provides runtime validation for API requests and responses.
1460
- *
1461
- * Usage:
1462
- * ```typescript
1463
- * import { UserSchema } from './schemas'
1464
- *
1465
- * // Validate data
1466
- * const user = UserSchema.parse(data)
1467
- *
1468
- * // Type inference
1469
- * type User = z.infer<typeof UserSchema>
1470
- * ```
1471
- */
1472
-
1473
- type index$5_ConnectionTokenResponse = ConnectionTokenResponse;
1474
- declare const index$5_ConnectionTokenResponseSchema: typeof ConnectionTokenResponseSchema;
1475
- declare namespace index$5 {
1476
- export { type index$5_ConnectionTokenResponse as ConnectionTokenResponse, index$5_ConnectionTokenResponseSchema as ConnectionTokenResponseSchema };
1477
- }
1478
-
1479
- /**
1480
- * Get Centrifugo connection token
1481
- *
1482
- * @method GET
1483
- * @path /cfg/centrifugo/auth/token/
1484
- */
1485
- declare function getCentrifugoAuthTokenRetrieve(client?: any): Promise<ConnectionTokenResponse>;
1486
-
1487
- /**
1488
- * Typed Fetchers - Universal API functions
1489
- *
1490
- * Auto-generated from OpenAPI specification.
1491
- * These functions work in any JavaScript environment.
1492
- *
1493
- * Features:
1494
- * - Runtime validation with Zod
1495
- * - Type-safe parameters and responses
1496
- * - Works with any data-fetching library (SWR, React Query, etc)
1497
- * - Server Component compatible
1498
- *
1499
- * Usage:
1500
- * ```typescript
1501
- * import * as fetchers from './fetchers'
1502
- *
1503
- * // Direct usage
1504
- * const user = await fetchers.getUser(1)
1505
- *
1506
- * // With SWR
1507
- * const { data } = useSWR('user-1', () => fetchers.getUser(1))
1508
- *
1509
- * // With React Query
1510
- * const { data } = useQuery(['user', 1], () => fetchers.getUser(1))
1511
- * ```
1512
- */
1513
-
1514
- declare const index$4_getCentrifugoAuthTokenRetrieve: typeof getCentrifugoAuthTokenRetrieve;
1515
- declare namespace index$4 {
1516
- export { index$4_getCentrifugoAuthTokenRetrieve as getCentrifugoAuthTokenRetrieve };
1517
- }
1518
-
1519
- /**
1520
- * Django CFG API - API Client with JWT Management
1521
- *
1522
- * Usage:
1523
- * ```typescript
1524
- * import { API } from './api';
1525
- *
1526
- * const api = new API('https://api.example.com');
1527
- *
1528
- * // Set JWT token
1529
- * api.setToken('your-jwt-token', 'refresh-token');
1530
- *
1531
- * // Use API
1532
- * const posts = await api.posts.list();
1533
- * const user = await api.users.retrieve(1);
1534
- *
1535
- * // Check authentication
1536
- * if (api.isAuthenticated()) {
1537
- * // ...
1538
- * }
1539
- *
1540
- * // Custom storage with logging (for Electron/Node.js)
1541
- * import { MemoryStorageAdapter, APILogger } from './storage';
1542
- * const logger = new APILogger({ enabled: true, logLevel: 'debug' });
1543
- * const api = new API('https://api.example.com', {
1544
- * storage: new MemoryStorageAdapter(logger),
1545
- * loggerConfig: { enabled: true, logLevel: 'debug' }
1546
- * });
1547
- *
1548
- * // Get OpenAPI schema
1549
- * const schema = api.getSchema();
1550
- * ```
1551
- */
1552
-
1553
- interface APIOptions$1 {
1554
- /** Custom storage adapter (defaults to LocalStorageAdapter) */
1555
- storage?: StorageAdapter$1;
1556
- /** Custom HTTP client adapter (defaults to FetchAdapter) */
1557
- httpClient?: HttpClientAdapter;
1558
- /** Retry configuration for failed requests */
1559
- retryConfig?: RetryConfig$1;
1560
- /** Logger configuration */
1561
- loggerConfig?: Partial<LoggerConfig$1>;
1562
- /** Locale for Accept-Language header (e.g. 'en', 'ko', 'ru') */
1563
- locale?: string;
1564
- }
1565
- declare class API$1 {
1566
- private baseUrl;
1567
- private _client;
1568
- private _token;
1569
- private _refreshToken;
1570
- private _locale;
1571
- private storage;
1572
- private options?;
1573
- centrifugo_auth: CentrifugoAuth;
1574
- constructor(baseUrl: string, options?: APIOptions$1);
1575
- private _loadTokensFromStorage;
1576
- private _reinitClients;
1577
- private _injectAuthHeader;
1578
- /**
1579
- * Get current JWT token
1580
- */
1581
- getToken(): string | null;
1582
- /**
1583
- * Get current refresh token
1584
- */
1585
- getRefreshToken(): string | null;
1586
- /**
1587
- * Set JWT token and refresh token
1588
- * @param token - JWT access token
1589
- * @param refreshToken - JWT refresh token (optional)
1590
- */
1591
- setToken(token: string, refreshToken?: string): void;
1592
- /**
1593
- * Clear all tokens
1594
- */
1595
- clearTokens(): void;
1596
- /**
1597
- * Check if user is authenticated
1598
- */
1599
- isAuthenticated(): boolean;
1600
- /**
1601
- * Update base URL and reinitialize clients
1602
- * @param url - New base URL
1603
- */
1604
- setBaseUrl(url: string): void;
1605
- /**
1606
- * Get current base URL
1607
- */
1608
- getBaseUrl(): string;
1609
- /**
1610
- * Set locale for Accept-Language header
1611
- * @param locale - Locale string (e.g. 'en', 'ko', 'ru') or null to clear
1612
- */
1613
- setLocale(locale: string | null): void;
1614
- /**
1615
- * Get current locale
1616
- */
1617
- getLocale(): string | null;
1618
- /**
1619
- * Get OpenAPI schema path
1620
- * @returns Path to the OpenAPI schema JSON file
1621
- *
1622
- * Note: The OpenAPI schema is available in the schema.json file.
1623
- * You can load it dynamically using:
1624
- * ```typescript
1625
- * const schema = await fetch('./schema.json').then(r => r.json());
1626
- * // or using fs in Node.js:
1627
- * // const schema = JSON.parse(fs.readFileSync('./schema.json', 'utf-8'));
1628
- * ```
1629
- */
1630
- getSchemaPath(): string;
1631
- }
1632
-
1633
- /**
1634
- * Response serializer for backup codes regeneration.
1635
- *
1636
- * Response model (includes read-only fields).
1637
- */
1638
- interface BackupCodesRegenerateResponse$1 {
1639
- /** List of new backup codes (save these!) */
1640
- backup_codes: Array<string>;
1641
- /** Warning about previous codes being invalidated */
1642
- warning: string;
1643
- }
1644
- /**
1645
- * Serializer for backup codes status.
1646
- *
1647
- * Response model (includes read-only fields).
1648
- */
1649
- interface BackupCodesStatus$1 {
1650
- /** Number of unused backup codes */
1651
- remaining_count: number;
1652
- /** Total number of codes generated */
1653
- total_generated: number;
1654
- /** Warning if running low on codes */
1655
- warning?: string | null;
1656
- }
1657
- /**
1658
- * Serializer for regenerating backup codes.
1659
- *
1660
- * Request model (no read-only fields).
1661
- */
1662
- interface BackupCodesRegenerateRequest$1 {
1663
- /** TOTP code for verification */
1664
- code: string;
1665
- }
1666
-
1667
- /**
1668
- * API endpoints for Backup Codes.
1669
- */
1670
- declare class BackupCodes {
1671
- private client;
1672
- constructor(client: any);
1673
- /**
1674
- * Get backup codes status for user.
1675
- */
1676
- totpBackupCodesRetrieve(): Promise<BackupCodesStatus$1>;
1677
- /**
1678
- * Regenerate backup codes. Requires TOTP code for verification.
1679
- * Invalidates all existing codes.
1680
- */
1681
- totpBackupCodesRegenerateCreate(data: BackupCodesRegenerateRequest$1): Promise<BackupCodesRegenerateResponse$1>;
1682
- }
1683
-
1684
- /**
1685
- * * `pending` - Pending Confirmation
1686
- * * `active` - Active
1687
- * * `disabled` - Disabled
1688
- */
1689
- declare enum DeviceListStatus {
1690
- PENDING = "pending",
1691
- ACTIVE = "active",
1692
- DISABLED = "disabled"
1693
- }
1694
-
1695
- /**
1696
- * Serializer for completely disabling 2FA.
1697
- *
1698
- * Request model (no read-only fields).
1699
- */
1700
- interface DisableRequest$1 {
1701
- /** TOTP code for verification */
1702
- code: string;
1703
- }
1704
- /**
1705
- * Response serializer for device list endpoint.
1706
- *
1707
- * Response model (includes read-only fields).
1708
- */
1709
- interface DeviceListResponse$1 {
1710
- devices: Array<DeviceList$1>;
1711
- has_2fa_enabled: boolean;
1712
- }
1713
- /**
1714
- * Serializer for listing TOTP devices.
1715
- *
1716
- * Response model (includes read-only fields).
1717
- */
1718
- interface DeviceList$1 {
1719
- id: string;
1720
- /** Device name for identification */
1721
- name: string;
1722
- /** Primary device used for verification */
1723
- is_primary: boolean;
1724
- /** * `pending` - Pending Confirmation
1725
- * `active` - Active
1726
- * `disabled` - Disabled */
1727
- status: DeviceListStatus;
1728
- created_at: string;
1729
- /** When device setup was confirmed */
1730
- confirmed_at?: string | null;
1731
- /** Last successful verification */
1732
- last_used_at?: string | null;
1733
- }
1734
-
1735
- /**
1736
- * API endpoints for TOTP Management.
1737
- */
1738
- declare class TotpManagement {
1739
- private client;
1740
- constructor(client: any);
1741
- /**
1742
- * List all TOTP devices for user.
1743
- */
1744
- totpDevicesRetrieve(): Promise<DeviceListResponse$1>;
1745
- /**
1746
- * Completely disable 2FA for account. Requires verification code.
1747
- */
1748
- totpDisableCreate(data: DisableRequest$1): Promise<any>;
1749
- }
1750
-
1751
- /**
1752
- * Serializer for confirming 2FA setup with first code.
1753
- *
1754
- * Request model (no read-only fields).
1755
- */
1756
- interface ConfirmSetupRequest$1 {
1757
- /** Device ID from setup response */
1758
- device_id: string;
1759
- /** 6-digit TOTP code from authenticator app */
1760
- code: string;
1761
- }
1762
- /**
1763
- * Serializer for starting 2FA setup.
1764
- *
1765
- * Request model (no read-only fields).
1766
- */
1767
- interface SetupRequest$1 {
1768
- /** Device name for identification (e.g., 'My iPhone') */
1769
- device_name?: string;
1770
- }
1771
- /**
1772
- * Response serializer for setup confirmation.
1773
- *
1774
- * Response model (includes read-only fields).
1775
- */
1776
- interface ConfirmSetupResponse$1 {
1777
- message: string;
1778
- /** List of backup recovery codes (save these!) */
1779
- backup_codes: Array<string>;
1780
- /** Warning message about backup codes */
1781
- backup_codes_warning: string;
1782
- }
1783
- /**
1784
- * Response serializer for setup initiation.
1785
- *
1786
- * Response model (includes read-only fields).
1787
- */
1788
- interface SetupResponse$1 {
1789
- /** Device ID to use for confirmation */
1790
- device_id: string;
1791
- /** Base32-encoded TOTP secret (for manual entry) */
1792
- secret: string;
1793
- /** otpauth:// URI for QR code generation */
1794
- provisioning_uri: string;
1795
- /** Base64-encoded QR code image (data URI) */
1796
- qr_code_base64: string;
1797
- /** Seconds until setup expires (typically 600 = 10 minutes) */
1798
- expires_in: number;
1799
- }
1800
-
1801
- /**
1802
- * API endpoints for TOTP Setup.
1803
- */
1804
- declare class TotpSetup {
1805
- private client;
1806
- constructor(client: any);
1807
- /**
1808
- * Start 2FA setup process. Creates a new TOTP device and returns QR code
1809
- * for scanning.
1810
- */
1811
- create(data: SetupRequest$1): Promise<SetupResponse$1>;
1812
- /**
1813
- * Confirm 2FA setup with first valid code. Activates the device and
1814
- * generates backup codes.
1815
- */
1816
- confirmCreate(data: ConfirmSetupRequest$1): Promise<ConfirmSetupResponse$1>;
1817
- }
1818
-
1819
- /**
1820
- * Response serializer for successful 2FA verification.
1821
- *
1822
- * Response model (includes read-only fields).
1823
- */
1824
- interface VerifyResponse$1 {
1825
- message: string;
1826
- /** JWT access token */
1827
- access_token: string;
1828
- /** JWT refresh token */
1829
- refresh_token: string;
1830
- user: TotpVerifyUser$1;
1831
- /** Number of remaining backup codes (if backup code was used) */
1832
- remaining_backup_codes?: number;
1833
- /** Warning message (e.g., low backup codes) */
1834
- warning?: string;
1835
- }
1836
- /**
1837
- * Serializer for TOTP code verification during login.
1838
- *
1839
- * Request model (no read-only fields).
1840
- */
1841
- interface VerifyRequest$1 {
1842
- /** 2FA session ID from login response */
1843
- session_id: string;
1844
- /** 6-digit TOTP code from authenticator app */
1845
- code: string;
1846
- }
1847
- /**
1848
- * Serializer for backup code verification during login.
1849
- *
1850
- * Request model (no read-only fields).
1851
- */
1852
- interface VerifyBackupRequest$1 {
1853
- /** 2FA session ID from login response */
1854
- session_id: string;
1855
- /** 8-character backup recovery code */
1856
- backup_code: string;
1857
- }
1858
- /**
1859
- * User data returned after 2FA verification.
1860
- *
1861
- * Response model (includes read-only fields).
1862
- */
1863
- interface TotpVerifyUser$1 {
1864
- id: number;
1865
- email: string;
1866
- first_name?: string;
1867
- last_name?: string;
1868
- /** Get user's full name. */
1869
- full_name: string;
1870
- /** Get user's initials for avatar fallback. */
1871
- initials: string;
1872
- /** Get formatted username for display. */
1873
- display_username: string;
1874
- company?: string;
1875
- phone?: string;
1876
- position?: string;
1877
- language?: string;
1878
- avatar?: string | null;
1879
- /** Designates whether the user can log into this admin site. */
1880
- is_staff: boolean;
1881
- /** Designates that this user has all permissions without explicitly assigning them. */
1882
- is_superuser: boolean;
1883
- date_joined: string;
1884
- last_login?: string | null;
1885
- unanswered_messages_count: number;
1886
- }
1887
-
1888
- /**
1889
- * API endpoints for TOTP Verification.
1890
- */
1891
- declare class TotpVerification {
1892
- private client;
1893
- constructor(client: any);
1894
- /**
1895
- * Verify TOTP code for 2FA session. Completes authentication and returns
1896
- * JWT tokens on success.
1897
- */
1898
- totpVerifyCreate(data: VerifyRequest$1): Promise<VerifyResponse$1>;
1899
- /**
1900
- * Verify backup recovery code for 2FA session. Alternative verification
1901
- * method when TOTP device unavailable.
1902
- */
1903
- totpVerifyBackupCreate(data: VerifyBackupRequest$1): Promise<VerifyResponse$1>;
1904
- }
1905
-
1906
- /**
1907
- * API endpoints for Totp.
1908
- */
1909
- declare class Totp {
1910
- private client;
1911
- constructor(client: any);
1912
- /**
1913
- * Delete a TOTP device. Requires verification code if removing the
1914
- * last/primary device.
1915
- */
1916
- devicesDestroy(id: string): Promise<void>;
1917
- }
1918
-
1919
- /**
1920
- * API Logger with Consola
1921
- * Beautiful console logging for API requests and responses
1922
- *
1923
- * Installation:
1924
- * npm install consola
1925
- */
1926
-
1927
- /**
1928
- * Logger configuration
1929
- */
1930
- interface LoggerConfig {
1931
- /** Enable logging */
1932
- enabled: boolean;
1933
- /** Log requests */
1934
- logRequests: boolean;
1935
- /** Log responses */
1936
- logResponses: boolean;
1937
- /** Log errors */
1938
- logErrors: boolean;
1939
- /** Log request/response bodies */
1940
- logBodies: boolean;
1941
- /** Log headers (excluding sensitive ones) */
1942
- logHeaders: boolean;
1943
- /** Custom consola instance */
1944
- consola?: ConsolaInstance;
1945
- }
1946
-
1947
- /**
1948
- * Retry Configuration and Utilities
1949
- *
1950
- * Provides automatic retry logic for failed HTTP requests using p-retry.
1951
- * Retries only on network errors and server errors (5xx), not client errors (4xx).
1952
- */
1953
- /**
1954
- * Information about a failed retry attempt.
1955
- */
1956
- interface FailedAttemptInfo {
1957
- /** The error that caused the failure */
1958
- error: Error;
1959
- /** The attempt number (1-indexed) */
1960
- attemptNumber: number;
1961
- /** Number of retries left */
1962
- retriesLeft: number;
1963
- }
1964
- /**
1965
- * Retry configuration options.
1966
- *
1967
- * Uses exponential backoff with jitter by default to avoid thundering herd.
1968
- */
1969
- interface RetryConfig {
1970
- /**
1971
- * Maximum number of retry attempts.
1972
- * @default 3
1973
- */
1974
- retries?: number;
1975
- /**
1976
- * Exponential backoff factor.
1977
- * @default 2
1978
- */
1979
- factor?: number;
1980
- /**
1981
- * Minimum wait time between retries (ms).
1982
- * @default 1000
1983
- */
1984
- minTimeout?: number;
1985
- /**
1986
- * Maximum wait time between retries (ms).
1987
- * @default 60000
1988
- */
1989
- maxTimeout?: number;
1990
- /**
1991
- * Add randomness to wait times (jitter).
1992
- * Helps avoid thundering herd problem.
1993
- * @default true
1994
- */
1995
- randomize?: boolean;
1996
- /**
1997
- * Callback called on each failed attempt.
1998
- */
1999
- onFailedAttempt?: (info: FailedAttemptInfo) => void;
2000
- }
2001
-
2002
- /**
2003
- * Storage adapters for cross-platform token storage.
2004
- *
2005
- * Supports:
2006
- * - LocalStorage (browser)
2007
- * - Cookies (SSR/browser)
2008
- * - Memory (Node.js/Electron/testing)
2009
- */
2010
-
2011
- /**
2012
- * Storage adapter interface for cross-platform token storage.
2013
- */
2014
- interface StorageAdapter {
2015
- getItem(key: string): string | null;
2016
- setItem(key: string, value: string): void;
2017
- removeItem(key: string): void;
2018
- }
2019
-
2020
- /**
2021
- * Zod schema for BackupCodesRegenerateRequest
2022
- *
2023
- * This schema provides runtime validation and type inference.
2024
- * * Serializer for regenerating backup codes.
2025
- * */
2026
-
2027
- /**
2028
- * Serializer for regenerating backup codes.
2029
- */
2030
- declare const BackupCodesRegenerateRequestSchema: z.ZodObject<{
2031
- code: z.ZodString;
2032
- }, z.core.$strip>;
2033
- /**
2034
- * Infer TypeScript type from Zod schema
2035
- */
2036
- type BackupCodesRegenerateRequest = z.infer<typeof BackupCodesRegenerateRequestSchema>;
2037
-
2038
- /**
2039
- * Zod schema for BackupCodesRegenerateResponse
2040
- *
2041
- * This schema provides runtime validation and type inference.
2042
- * * Response serializer for backup codes regeneration.
2043
- * */
2044
-
2045
- /**
2046
- * Response serializer for backup codes regeneration.
2047
- */
2048
- declare const BackupCodesRegenerateResponseSchema: z.ZodObject<{
2049
- backup_codes: z.ZodArray<z.ZodString>;
2050
- warning: z.ZodString;
2051
- }, z.core.$strip>;
2052
- /**
2053
- * Infer TypeScript type from Zod schema
2054
- */
2055
- type BackupCodesRegenerateResponse = z.infer<typeof BackupCodesRegenerateResponseSchema>;
2056
-
2057
- /**
2058
- * Zod schema for BackupCodesStatus
2059
- *
2060
- * This schema provides runtime validation and type inference.
2061
- * * Serializer for backup codes status.
2062
- * */
2063
-
2064
- /**
2065
- * Serializer for backup codes status.
2066
- */
2067
- declare const BackupCodesStatusSchema: z.ZodObject<{
2068
- remaining_count: z.ZodNumber;
2069
- total_generated: z.ZodNumber;
2070
- warning: z.ZodOptional<z.ZodNullable<z.ZodString>>;
2071
- }, z.core.$strip>;
2072
- /**
2073
- * Infer TypeScript type from Zod schema
2074
- */
2075
- type BackupCodesStatus = z.infer<typeof BackupCodesStatusSchema>;
2076
-
2077
- /**
2078
- * Zod schema for ConfirmSetupRequest
2079
- *
2080
- * This schema provides runtime validation and type inference.
2081
- * * Serializer for confirming 2FA setup with first code.
2082
- * */
2083
-
2084
- /**
2085
- * Serializer for confirming 2FA setup with first code.
2086
- */
2087
- declare const ConfirmSetupRequestSchema: z.ZodObject<{
2088
- device_id: z.ZodString;
2089
- code: z.ZodString;
2090
- }, z.core.$strip>;
2091
- /**
2092
- * Infer TypeScript type from Zod schema
2093
- */
2094
- type ConfirmSetupRequest = z.infer<typeof ConfirmSetupRequestSchema>;
2095
-
2096
- /**
2097
- * Zod schema for ConfirmSetupResponse
2098
- *
2099
- * This schema provides runtime validation and type inference.
2100
- * * Response serializer for setup confirmation.
2101
- * */
2102
-
2103
- /**
2104
- * Response serializer for setup confirmation.
2105
- */
2106
- declare const ConfirmSetupResponseSchema: z.ZodObject<{
2107
- message: z.ZodString;
2108
- backup_codes: z.ZodArray<z.ZodString>;
2109
- backup_codes_warning: z.ZodString;
2110
- }, z.core.$strip>;
2111
- /**
2112
- * Infer TypeScript type from Zod schema
2113
- */
2114
- type ConfirmSetupResponse = z.infer<typeof ConfirmSetupResponseSchema>;
2115
-
2116
- /**
2117
- * Zod schema for DeviceList
2118
- *
2119
- * This schema provides runtime validation and type inference.
2120
- * * Serializer for listing TOTP devices.
2121
- * */
2122
-
2123
- /**
2124
- * Serializer for listing TOTP devices.
2125
- */
2126
- declare const DeviceListSchema: z.ZodObject<{
2127
- id: z.ZodString;
2128
- name: z.ZodString;
2129
- is_primary: z.ZodBoolean;
2130
- status: z.ZodEnum<typeof DeviceListStatus>;
2131
- created_at: z.ZodString;
2132
- confirmed_at: z.ZodNullable<z.ZodString>;
2133
- last_used_at: z.ZodNullable<z.ZodString>;
2134
- }, z.core.$strip>;
2135
- /**
2136
- * Infer TypeScript type from Zod schema
2137
- */
2138
- type DeviceList = z.infer<typeof DeviceListSchema>;
2139
-
2140
- /**
2141
- * Response serializer for device list endpoint.
2142
- */
2143
- declare const DeviceListResponseSchema: z.ZodObject<{
2144
- devices: z.ZodArray<z.ZodObject<{
2145
- id: z.ZodString;
2146
- name: z.ZodString;
2147
- is_primary: z.ZodBoolean;
2148
- status: z.ZodEnum<typeof DeviceListStatus>;
2149
- created_at: z.ZodString;
2150
- confirmed_at: z.ZodNullable<z.ZodString>;
2151
- last_used_at: z.ZodNullable<z.ZodString>;
2152
- }, z.core.$strip>>;
2153
- has_2fa_enabled: z.ZodBoolean;
2154
- }, z.core.$strip>;
2155
- /**
2156
- * Infer TypeScript type from Zod schema
2157
- */
2158
- type DeviceListResponse = z.infer<typeof DeviceListResponseSchema>;
2159
-
2160
- /**
2161
- * Zod schema for DisableRequest
2162
- *
2163
- * This schema provides runtime validation and type inference.
2164
- * * Serializer for completely disabling 2FA.
2165
- * */
2166
-
2167
- /**
2168
- * Serializer for completely disabling 2FA.
2169
- */
2170
- declare const DisableRequestSchema: z.ZodObject<{
2171
- code: z.ZodString;
2172
- }, z.core.$strip>;
2173
- /**
2174
- * Infer TypeScript type from Zod schema
2175
- */
2176
- type DisableRequest = z.infer<typeof DisableRequestSchema>;
2177
-
2178
- /**
2179
- * Zod schema for SetupRequest
2180
- *
2181
- * This schema provides runtime validation and type inference.
2182
- * * Serializer for starting 2FA setup.
2183
- * */
2184
-
2185
- /**
2186
- * Serializer for starting 2FA setup.
2187
- */
2188
- declare const SetupRequestSchema: z.ZodObject<{
2189
- device_name: z.ZodOptional<z.ZodString>;
2190
- }, z.core.$strip>;
2191
- /**
2192
- * Infer TypeScript type from Zod schema
2193
- */
2194
- type SetupRequest = z.infer<typeof SetupRequestSchema>;
2195
-
2196
- /**
2197
- * Zod schema for SetupResponse
2198
- *
2199
- * This schema provides runtime validation and type inference.
2200
- * * Response serializer for setup initiation.
2201
- * */
2202
-
2203
- /**
2204
- * Response serializer for setup initiation.
2205
- */
2206
- declare const SetupResponseSchema: z.ZodObject<{
2207
- device_id: z.ZodString;
2208
- secret: z.ZodString;
2209
- provisioning_uri: z.ZodString;
2210
- qr_code_base64: z.ZodString;
2211
- expires_in: z.ZodNumber;
2212
- }, z.core.$strip>;
2213
- /**
2214
- * Infer TypeScript type from Zod schema
2215
- */
2216
- type SetupResponse = z.infer<typeof SetupResponseSchema>;
2217
-
2218
- /**
2219
- * Zod schema for TotpVerifyUser
2220
- *
2221
- * This schema provides runtime validation and type inference.
2222
- * * User data returned after 2FA verification.
2223
- * */
2224
-
2225
- /**
2226
- * User data returned after 2FA verification.
2227
- */
2228
- declare const TotpVerifyUserSchema: z.ZodObject<{
2229
- id: z.ZodNumber;
2230
- email: z.ZodEmail;
2231
- first_name: z.ZodOptional<z.ZodString>;
2232
- last_name: z.ZodOptional<z.ZodString>;
2233
- full_name: z.ZodString;
2234
- initials: z.ZodString;
2235
- display_username: z.ZodString;
2236
- company: z.ZodOptional<z.ZodString>;
2237
- phone: z.ZodOptional<z.ZodString>;
2238
- position: z.ZodOptional<z.ZodString>;
2239
- language: z.ZodOptional<z.ZodString>;
2240
- avatar: z.ZodNullable<z.ZodString>;
2241
- is_staff: z.ZodBoolean;
2242
- is_superuser: z.ZodBoolean;
2243
- date_joined: z.ZodString;
2244
- last_login: z.ZodNullable<z.ZodString>;
2245
- unanswered_messages_count: z.ZodNumber;
2246
- }, z.core.$strip>;
2247
- /**
2248
- * Infer TypeScript type from Zod schema
2249
- */
2250
- type TotpVerifyUser = z.infer<typeof TotpVerifyUserSchema>;
2251
-
2252
- /**
2253
- * Zod schema for VerifyBackupRequest
2254
- *
2255
- * This schema provides runtime validation and type inference.
2256
- * * Serializer for backup code verification during login.
2257
- * */
2258
-
2259
- /**
2260
- * Serializer for backup code verification during login.
2261
- */
2262
- declare const VerifyBackupRequestSchema: z.ZodObject<{
2263
- session_id: z.ZodString;
2264
- backup_code: z.ZodString;
2265
- }, z.core.$strip>;
2266
- /**
2267
- * Infer TypeScript type from Zod schema
2268
- */
2269
- type VerifyBackupRequest = z.infer<typeof VerifyBackupRequestSchema>;
2270
-
2271
- /**
2272
- * Zod schema for VerifyRequest
2273
- *
2274
- * This schema provides runtime validation and type inference.
2275
- * * Serializer for TOTP code verification during login.
2276
- * */
2277
-
2278
- /**
2279
- * Serializer for TOTP code verification during login.
2280
- */
2281
- declare const VerifyRequestSchema: z.ZodObject<{
2282
- session_id: z.ZodString;
2283
- code: z.ZodString;
2284
- }, z.core.$strip>;
2285
- /**
2286
- * Infer TypeScript type from Zod schema
2287
- */
2288
- type VerifyRequest = z.infer<typeof VerifyRequestSchema>;
2289
-
2290
- /**
2291
- * Zod schema for VerifyResponse
2292
- *
2293
- * This schema provides runtime validation and type inference.
2294
- * * Response serializer for successful 2FA verification.
2295
- * */
2296
-
2297
- /**
2298
- * Response serializer for successful 2FA verification.
2299
- */
2300
- declare const VerifyResponseSchema: z.ZodObject<{
2301
- message: z.ZodString;
2302
- access_token: z.ZodString;
2303
- refresh_token: z.ZodString;
2304
- user: z.ZodObject<{
2305
- id: z.ZodNumber;
2306
- email: z.ZodEmail;
2307
- first_name: z.ZodOptional<z.ZodString>;
2308
- last_name: z.ZodOptional<z.ZodString>;
2309
- full_name: z.ZodString;
2310
- initials: z.ZodString;
2311
- display_username: z.ZodString;
2312
- company: z.ZodOptional<z.ZodString>;
2313
- phone: z.ZodOptional<z.ZodString>;
2314
- position: z.ZodOptional<z.ZodString>;
2315
- language: z.ZodOptional<z.ZodString>;
2316
- avatar: z.ZodNullable<z.ZodString>;
2317
- is_staff: z.ZodBoolean;
2318
- is_superuser: z.ZodBoolean;
2319
- date_joined: z.ZodString;
2320
- last_login: z.ZodNullable<z.ZodString>;
2321
- unanswered_messages_count: z.ZodNumber;
2322
- }, z.core.$strip>;
2323
- remaining_backup_codes: z.ZodOptional<z.ZodNumber>;
2324
- warning: z.ZodOptional<z.ZodString>;
2325
- }, z.core.$strip>;
2326
- /**
2327
- * Infer TypeScript type from Zod schema
2328
- */
2329
- type VerifyResponse = z.infer<typeof VerifyResponseSchema>;
2330
-
2331
- /**
2332
- * Zod Schemas - Runtime validation and type inference
2333
- *
2334
- * Auto-generated from OpenAPI specification.
2335
- * Provides runtime validation for API requests and responses.
2336
- *
2337
- * Usage:
2338
- * ```typescript
2339
- * import { UserSchema } from './schemas'
2340
- *
2341
- * // Validate data
2342
- * const user = UserSchema.parse(data)
2343
- *
2344
- * // Type inference
2345
- * type User = z.infer<typeof UserSchema>
2346
- * ```
2347
- */
2348
-
2349
- type index$3_BackupCodesRegenerateRequest = BackupCodesRegenerateRequest;
2350
- declare const index$3_BackupCodesRegenerateRequestSchema: typeof BackupCodesRegenerateRequestSchema;
2351
- type index$3_BackupCodesRegenerateResponse = BackupCodesRegenerateResponse;
2352
- declare const index$3_BackupCodesRegenerateResponseSchema: typeof BackupCodesRegenerateResponseSchema;
2353
- type index$3_BackupCodesStatus = BackupCodesStatus;
2354
- declare const index$3_BackupCodesStatusSchema: typeof BackupCodesStatusSchema;
2355
- type index$3_ConfirmSetupRequest = ConfirmSetupRequest;
2356
- declare const index$3_ConfirmSetupRequestSchema: typeof ConfirmSetupRequestSchema;
2357
- type index$3_ConfirmSetupResponse = ConfirmSetupResponse;
2358
- declare const index$3_ConfirmSetupResponseSchema: typeof ConfirmSetupResponseSchema;
2359
- type index$3_DeviceList = DeviceList;
2360
- type index$3_DeviceListResponse = DeviceListResponse;
2361
- declare const index$3_DeviceListResponseSchema: typeof DeviceListResponseSchema;
2362
- declare const index$3_DeviceListSchema: typeof DeviceListSchema;
2363
- type index$3_DisableRequest = DisableRequest;
2364
- declare const index$3_DisableRequestSchema: typeof DisableRequestSchema;
2365
- type index$3_SetupRequest = SetupRequest;
2366
- declare const index$3_SetupRequestSchema: typeof SetupRequestSchema;
2367
- type index$3_SetupResponse = SetupResponse;
2368
- declare const index$3_SetupResponseSchema: typeof SetupResponseSchema;
2369
- type index$3_TotpVerifyUser = TotpVerifyUser;
2370
- declare const index$3_TotpVerifyUserSchema: typeof TotpVerifyUserSchema;
2371
- type index$3_VerifyBackupRequest = VerifyBackupRequest;
2372
- declare const index$3_VerifyBackupRequestSchema: typeof VerifyBackupRequestSchema;
2373
- type index$3_VerifyRequest = VerifyRequest;
2374
- declare const index$3_VerifyRequestSchema: typeof VerifyRequestSchema;
2375
- type index$3_VerifyResponse = VerifyResponse;
2376
- declare const index$3_VerifyResponseSchema: typeof VerifyResponseSchema;
2377
- declare namespace index$3 {
2378
- export { type index$3_BackupCodesRegenerateRequest as BackupCodesRegenerateRequest, index$3_BackupCodesRegenerateRequestSchema as BackupCodesRegenerateRequestSchema, type index$3_BackupCodesRegenerateResponse as BackupCodesRegenerateResponse, index$3_BackupCodesRegenerateResponseSchema as BackupCodesRegenerateResponseSchema, type index$3_BackupCodesStatus as BackupCodesStatus, index$3_BackupCodesStatusSchema as BackupCodesStatusSchema, type index$3_ConfirmSetupRequest as ConfirmSetupRequest, index$3_ConfirmSetupRequestSchema as ConfirmSetupRequestSchema, type index$3_ConfirmSetupResponse as ConfirmSetupResponse, index$3_ConfirmSetupResponseSchema as ConfirmSetupResponseSchema, type index$3_DeviceList as DeviceList, type index$3_DeviceListResponse as DeviceListResponse, index$3_DeviceListResponseSchema as DeviceListResponseSchema, index$3_DeviceListSchema as DeviceListSchema, type index$3_DisableRequest as DisableRequest, index$3_DisableRequestSchema as DisableRequestSchema, type index$3_SetupRequest as SetupRequest, index$3_SetupRequestSchema as SetupRequestSchema, type index$3_SetupResponse as SetupResponse, index$3_SetupResponseSchema as SetupResponseSchema, type index$3_TotpVerifyUser as TotpVerifyUser, index$3_TotpVerifyUserSchema as TotpVerifyUserSchema, type index$3_VerifyBackupRequest as VerifyBackupRequest, index$3_VerifyBackupRequestSchema as VerifyBackupRequestSchema, type index$3_VerifyRequest as VerifyRequest, index$3_VerifyRequestSchema as VerifyRequestSchema, type index$3_VerifyResponse as VerifyResponse, index$3_VerifyResponseSchema as VerifyResponseSchema };
2379
- }
2380
-
2381
- /**
2382
- * API operation
2383
- *
2384
- * @method DELETE
2385
- * @path /cfg/totp/devices/{id}/
2386
- */
2387
- declare function deleteTotpDevicesDestroy(id: string, client?: any): Promise<void>;
2388
-
2389
- /**
2390
- * API operation
2391
- *
2392
- * @method GET
2393
- * @path /cfg/totp/backup-codes/
2394
- */
2395
- declare function getTotpBackupCodesRetrieve(client?: any): Promise<BackupCodesStatus>;
2396
- /**
2397
- * API operation
2398
- *
2399
- * @method POST
2400
- * @path /cfg/totp/backup-codes/regenerate/
2401
- */
2402
- declare function createTotpBackupCodesRegenerateCreate(data: BackupCodesRegenerateRequest, client?: any): Promise<BackupCodesRegenerateResponse>;
2403
-
2404
- /**
2405
- * API operation
2406
- *
2407
- * @method GET
2408
- * @path /cfg/totp/devices/
2409
- */
2410
- declare function getTotpDevicesRetrieve(client?: any): Promise<DeviceListResponse>;
2411
- /**
2412
- * API operation
2413
- *
2414
- * @method POST
2415
- * @path /cfg/totp/disable/
2416
- */
2417
- declare function createTotpDisableCreate(data: DisableRequest, client?: any): Promise<any>;
2418
-
2419
- /**
2420
- * API operation
2421
- *
2422
- * @method POST
2423
- * @path /cfg/totp/setup/
2424
- */
2425
- declare function createTotpSetupCreate(data: SetupRequest, client?: any): Promise<SetupResponse>;
2426
- /**
2427
- * API operation
2428
- *
2429
- * @method POST
2430
- * @path /cfg/totp/setup/confirm/
2431
- */
2432
- declare function createTotpSetupConfirmCreate(data: ConfirmSetupRequest, client?: any): Promise<ConfirmSetupResponse>;
2433
-
2434
- /**
2435
- * API operation
2436
- *
2437
- * @method POST
2438
- * @path /cfg/totp/verify/
2439
- */
2440
- declare function createTotpVerifyCreate(data: VerifyRequest, client?: any): Promise<VerifyResponse>;
2441
- /**
2442
- * API operation
2443
- *
2444
- * @method POST
2445
- * @path /cfg/totp/verify/backup/
2446
- */
2447
- declare function createTotpVerifyBackupCreate(data: VerifyBackupRequest, client?: any): Promise<VerifyResponse>;
2448
-
2449
- /**
2450
- * Typed Fetchers - Universal API functions
2451
- *
2452
- * Auto-generated from OpenAPI specification.
2453
- * These functions work in any JavaScript environment.
2454
- *
2455
- * Features:
2456
- * - Runtime validation with Zod
2457
- * - Type-safe parameters and responses
2458
- * - Works with any data-fetching library (SWR, React Query, etc)
2459
- * - Server Component compatible
2460
- *
2461
- * Usage:
2462
- * ```typescript
2463
- * import * as fetchers from './fetchers'
2464
- *
2465
- * // Direct usage
2466
- * const user = await fetchers.getUser(1)
2467
- *
2468
- * // With SWR
2469
- * const { data } = useSWR('user-1', () => fetchers.getUser(1))
2470
- *
2471
- * // With React Query
2472
- * const { data } = useQuery(['user', 1], () => fetchers.getUser(1))
2473
- * ```
2474
- */
2475
-
2476
- declare const index$2_createTotpBackupCodesRegenerateCreate: typeof createTotpBackupCodesRegenerateCreate;
2477
- declare const index$2_createTotpDisableCreate: typeof createTotpDisableCreate;
2478
- declare const index$2_createTotpSetupConfirmCreate: typeof createTotpSetupConfirmCreate;
2479
- declare const index$2_createTotpSetupCreate: typeof createTotpSetupCreate;
2480
- declare const index$2_createTotpVerifyBackupCreate: typeof createTotpVerifyBackupCreate;
2481
- declare const index$2_createTotpVerifyCreate: typeof createTotpVerifyCreate;
2482
- declare const index$2_deleteTotpDevicesDestroy: typeof deleteTotpDevicesDestroy;
2483
- declare const index$2_getTotpBackupCodesRetrieve: typeof getTotpBackupCodesRetrieve;
2484
- declare const index$2_getTotpDevicesRetrieve: typeof getTotpDevicesRetrieve;
2485
- declare namespace index$2 {
2486
- export { index$2_createTotpBackupCodesRegenerateCreate as createTotpBackupCodesRegenerateCreate, index$2_createTotpDisableCreate as createTotpDisableCreate, index$2_createTotpSetupConfirmCreate as createTotpSetupConfirmCreate, index$2_createTotpSetupCreate as createTotpSetupCreate, index$2_createTotpVerifyBackupCreate as createTotpVerifyBackupCreate, index$2_createTotpVerifyCreate as createTotpVerifyCreate, index$2_deleteTotpDevicesDestroy as deleteTotpDevicesDestroy, index$2_getTotpBackupCodesRetrieve as getTotpBackupCodesRetrieve, index$2_getTotpDevicesRetrieve as getTotpDevicesRetrieve };
2487
- }
2488
-
2489
- /**
2490
- * Django CFG API - API Client with JWT Management
2491
- *
2492
- * Usage:
2493
- * ```typescript
2494
- * import { API } from './api';
2495
- *
2496
- * const api = new API('https://api.example.com');
2497
- *
2498
- * // Set JWT token
2499
- * api.setToken('your-jwt-token', 'refresh-token');
2500
- *
2501
- * // Use API
2502
- * const posts = await api.posts.list();
2503
- * const user = await api.users.retrieve(1);
2504
- *
2505
- * // Check authentication
2506
- * if (api.isAuthenticated()) {
2507
- * // ...
2508
- * }
2509
- *
2510
- * // Custom storage with logging (for Electron/Node.js)
2511
- * import { MemoryStorageAdapter, APILogger } from './storage';
2512
- * const logger = new APILogger({ enabled: true, logLevel: 'debug' });
2513
- * const api = new API('https://api.example.com', {
2514
- * storage: new MemoryStorageAdapter(logger),
2515
- * loggerConfig: { enabled: true, logLevel: 'debug' }
2516
- * });
2517
- *
2518
- * // Get OpenAPI schema
2519
- * const schema = api.getSchema();
2520
- * ```
2521
- */
2522
-
2523
- interface APIOptions {
2524
- /** Custom storage adapter (defaults to LocalStorageAdapter) */
2525
- storage?: StorageAdapter;
2526
- /** Custom HTTP client adapter (defaults to FetchAdapter) */
2527
- httpClient?: HttpClientAdapter;
2528
- /** Retry configuration for failed requests */
2529
- retryConfig?: RetryConfig;
2530
- /** Logger configuration */
2531
- loggerConfig?: Partial<LoggerConfig>;
2532
- /** Locale for Accept-Language header (e.g. 'en', 'ko', 'ru') */
2533
- locale?: string;
2534
- }
2535
167
  declare class API {
2536
168
  private baseUrl;
2537
- private _client;
2538
- private _token;
2539
- private _refreshToken;
2540
- private _locale;
2541
169
  private storage;
2542
- private options?;
2543
- backup_codes: BackupCodes;
2544
- totp_management: TotpManagement;
2545
- totp_setup: TotpSetup;
2546
- totp_verification: TotpVerification;
2547
- totp: Totp;
2548
- constructor(baseUrl: string, options?: APIOptions);
2549
- private _loadTokensFromStorage;
2550
- private _reinitClients;
2551
- private _injectAuthHeader;
2552
- /**
2553
- * Get current JWT token
2554
- */
170
+ private locale;
171
+ private apiKey;
172
+ readonly logger: APILogger;
173
+ constructor(baseUrl: string, opts?: APIOptions);
174
+ getBaseUrl(): string;
175
+ setBaseUrl(url: string): void;
2555
176
  getToken(): string | null;
2556
- /**
2557
- * Get current refresh token
2558
- */
177
+ setToken(token: string | null): void;
2559
178
  getRefreshToken(): string | null;
2560
- /**
2561
- * Set JWT token and refresh token
2562
- * @param token - JWT access token
2563
- * @param refreshToken - JWT refresh token (optional)
2564
- */
2565
- setToken(token: string, refreshToken?: string): void;
2566
- /**
2567
- * Clear all tokens
2568
- */
2569
- clearTokens(): void;
2570
- /**
2571
- * Check if user is authenticated
2572
- */
179
+ setRefreshToken(token: string | null): void;
180
+ clearToken(): void;
2573
181
  isAuthenticated(): boolean;
2574
- /**
2575
- * Update base URL and reinitialize clients
2576
- * @param url - New base URL
2577
- */
2578
- setBaseUrl(url: string): void;
2579
- /**
2580
- * Get current base URL
2581
- */
2582
- getBaseUrl(): string;
2583
- /**
2584
- * Set locale for Accept-Language header
2585
- * @param locale - Locale string (e.g. 'en', 'ko', 'ru') or null to clear
2586
- */
2587
- setLocale(locale: string | null): void;
2588
- /**
2589
- * Get current locale
2590
- */
2591
182
  getLocale(): string | null;
2592
- /**
2593
- * Get OpenAPI schema path
2594
- * @returns Path to the OpenAPI schema JSON file
2595
- *
2596
- * Note: The OpenAPI schema is available in the schema.json file.
2597
- * You can load it dynamically using:
2598
- * ```typescript
2599
- * const schema = await fetch('./schema.json').then(r => r.json());
2600
- * // or using fs in Node.js:
2601
- * // const schema = JSON.parse(fs.readFileSync('./schema.json', 'utf-8'));
2602
- * ```
2603
- */
2604
- getSchemaPath(): string;
2605
- }
2606
-
2607
- /**
2608
- * API operation
2609
- *
2610
- * @method POST
2611
- * @path /cfg/accounts/token/refresh/
2612
- */
2613
- declare function useCreateAccountsTokenRefreshCreate(): (data: TokenRefreshRequest, client?: API$2) => Promise<TokenRefresh>;
2614
-
2615
- /**
2616
- * SWR Hooks for Oauth
2617
- *
2618
- * React hooks powered by SWR for data fetching with automatic caching,
2619
- * revalidation, and optimistic updates.
2620
- *
2621
- * Usage:
2622
- * ```typescript
2623
- * // Query hooks (GET)
2624
- * const { data, error, isLoading } = useUsers({ page: 1 })
2625
- *
2626
- * // Mutation hooks (POST/PUT/PATCH/DELETE)
2627
- * const createUser = useCreateUser()
2628
- * await createUser({ name: 'John', email: 'john@example.com' })
2629
- * ```
2630
- */
2631
-
2632
- /**
2633
- * List OAuth connections
2634
- *
2635
- * @method GET
2636
- * @path /cfg/accounts/oauth/connections/
2637
- */
2638
- declare function useAccountsOauthConnectionsList(client?: API$2): ReturnType<typeof useSWR<OAuthConnection[]>>;
2639
- /**
2640
- * Disconnect OAuth provider
2641
- *
2642
- * @method POST
2643
- * @path /cfg/accounts/oauth/disconnect/
2644
- */
2645
- declare function useCreateAccountsOauthDisconnectCreate(): (data: OAuthDisconnectRequestRequest, client?: API$2) => Promise<any>;
2646
- /**
2647
- * Start GitHub OAuth
2648
- *
2649
- * @method POST
2650
- * @path /cfg/accounts/oauth/github/authorize/
2651
- */
2652
- declare function useCreateAccountsOauthGithubAuthorizeCreate(): (data: OAuthAuthorizeRequestRequest, client?: API$2) => Promise<OAuthAuthorizeResponse>;
2653
- /**
2654
- * Complete GitHub OAuth
2655
- *
2656
- * @method POST
2657
- * @path /cfg/accounts/oauth/github/callback/
2658
- */
2659
- declare function useCreateAccountsOauthGithubCallbackCreate(): (data: OAuthCallbackRequestRequest, client?: API$2) => Promise<OAuthTokenResponse>;
2660
- /**
2661
- * List OAuth providers
2662
- *
2663
- * @method GET
2664
- * @path /cfg/accounts/oauth/providers/
2665
- */
2666
- declare function useAccountsOauthProvidersRetrieve(client?: API$2): ReturnType<typeof useSWR<OAuthProvidersResponse>>;
2667
-
2668
- /**
2669
- * SWR Hooks for User Profile
2670
- *
2671
- * React hooks powered by SWR for data fetching with automatic caching,
2672
- * revalidation, and optimistic updates.
2673
- *
2674
- * Usage:
2675
- * ```typescript
2676
- * // Query hooks (GET)
2677
- * const { data, error, isLoading } = useUsers({ page: 1 })
2678
- *
2679
- * // Mutation hooks (POST/PUT/PATCH/DELETE)
2680
- * const createUser = useCreateUser()
2681
- * await createUser({ name: 'John', email: 'john@example.com' })
2682
- * ```
2683
- */
2684
-
2685
- /**
2686
- * Get current user profile
2687
- *
2688
- * @method GET
2689
- * @path /cfg/accounts/profile/
2690
- */
2691
- declare function useAccountsProfileRetrieve(client?: API$2): ReturnType<typeof useSWR<User>>;
2692
- /**
2693
- * Upload user avatar
2694
- *
2695
- * @method POST
2696
- * @path /cfg/accounts/profile/avatar/
2697
- */
2698
- declare function useCreateAccountsProfileAvatarCreate(): (data: CfgAccountsProfileAvatarCreateRequest, client?: API$2) => Promise<User>;
2699
- /**
2700
- * Delete user account
2701
- *
2702
- * @method POST
2703
- * @path /cfg/accounts/profile/delete/
2704
- */
2705
- declare function useCreateAccountsProfileDeleteCreate(): (client?: API$2) => Promise<AccountDeleteResponse>;
2706
- /**
2707
- * Partial update user profile
2708
- *
2709
- * @method PUT
2710
- * @path /cfg/accounts/profile/partial/
2711
- */
2712
- declare function usePartialUpdateAccountsProfilePartialUpdate(): (data: UserProfileUpdateRequest, client?: API$2) => Promise<User>;
2713
- /**
2714
- * Partial update user profile
2715
- *
2716
- * @method PATCH
2717
- * @path /cfg/accounts/profile/partial/
2718
- */
2719
- declare function usePartialUpdateAccountsProfilePartialPartialUpdate(): (data?: PatchedUserProfileUpdateRequest, client?: API$2) => Promise<User>;
2720
- /**
2721
- * Update user profile
2722
- *
2723
- * @method PUT
2724
- * @path /cfg/accounts/profile/update/
2725
- */
2726
- declare function useUpdateAccountsProfileUpdateUpdate(): (data: UserProfileUpdateRequest, client?: API$2) => Promise<User>;
2727
- /**
2728
- * Update user profile
2729
- *
2730
- * @method PATCH
2731
- * @path /cfg/accounts/profile/update/
2732
- */
2733
- declare function usePartialUpdateAccountsProfileUpdatePartialUpdate(): (data?: PatchedUserProfileUpdateRequest, client?: API$2) => Promise<User>;
2734
-
2735
- /**
2736
- * API operation
2737
- *
2738
- * @method POST
2739
- * @path /cfg/accounts/otp/request/
2740
- */
2741
- declare function useCreateAccountsOtpRequestCreate(): (data: OTPRequestRequest, client?: API$2) => Promise<OTPRequestResponse>;
2742
- /**
2743
- * API operation
2744
- *
2745
- * @method POST
2746
- * @path /cfg/accounts/otp/verify/
2747
- */
2748
- declare function useCreateAccountsOtpVerifyCreate(): (data: OTPVerifyRequest, client?: API$2) => Promise<OTPVerifyResponse>;
2749
-
2750
- /**
2751
- * SWR Hooks for Centrifugo Auth
2752
- *
2753
- * React hooks powered by SWR for data fetching with automatic caching,
2754
- * revalidation, and optimistic updates.
2755
- *
2756
- * Usage:
2757
- * ```typescript
2758
- * // Query hooks (GET)
2759
- * const { data, error, isLoading } = useUsers({ page: 1 })
2760
- *
2761
- * // Mutation hooks (POST/PUT/PATCH/DELETE)
2762
- * const createUser = useCreateUser()
2763
- * await createUser({ name: 'John', email: 'john@example.com' })
2764
- * ```
2765
- */
2766
-
2767
- /**
2768
- * Get Centrifugo connection token
2769
- *
2770
- * @method GET
2771
- * @path /cfg/centrifugo/auth/token/
2772
- */
2773
- declare function useCentrifugoAuthTokenRetrieve(client?: API$1): ReturnType<typeof useSWR<ConnectionTokenResponse>>;
2774
-
2775
- /**
2776
- * SWR Hooks - React data fetching hooks
2777
- *
2778
- * Auto-generated from OpenAPI specification.
2779
- * Powered by SWR for automatic caching and revalidation.
2780
- *
2781
- * Features:
2782
- * - Automatic caching and deduplication
2783
- * - Revalidation on focus/reconnect
2784
- * - Optimistic updates
2785
- * - Type-safe parameters and responses
2786
- *
2787
- * Usage:
2788
- * ```typescript
2789
- * import * as hooks from './hooks'
2790
- *
2791
- * // Query hooks (GET)
2792
- * const { data, error, isLoading } = hooks.useUsers({ page: 1 })
2793
- *
2794
- * // Mutation hooks (POST/PUT/PATCH/DELETE)
2795
- * const createUser = hooks.useCreateUser()
2796
- * await createUser({ name: 'John' })
2797
- * ```
2798
- */
2799
-
2800
- declare const index$1_useCentrifugoAuthTokenRetrieve: typeof useCentrifugoAuthTokenRetrieve;
2801
- declare namespace index$1 {
2802
- export { index$1_useCentrifugoAuthTokenRetrieve as useCentrifugoAuthTokenRetrieve };
2803
- }
2804
-
2805
- /**
2806
- * SWR Hooks for Backup Codes
2807
- *
2808
- * React hooks powered by SWR for data fetching with automatic caching,
2809
- * revalidation, and optimistic updates.
2810
- *
2811
- * Usage:
2812
- * ```typescript
2813
- * // Query hooks (GET)
2814
- * const { data, error, isLoading } = useUsers({ page: 1 })
2815
- *
2816
- * // Mutation hooks (POST/PUT/PATCH/DELETE)
2817
- * const createUser = useCreateUser()
2818
- * await createUser({ name: 'John', email: 'john@example.com' })
2819
- * ```
2820
- */
2821
-
2822
- /**
2823
- * API operation
2824
- *
2825
- * @method GET
2826
- * @path /cfg/totp/backup-codes/
2827
- */
2828
- declare function useTotpBackupCodesRetrieve(client?: API): ReturnType<typeof useSWR<BackupCodesStatus>>;
2829
- /**
2830
- * API operation
2831
- *
2832
- * @method POST
2833
- * @path /cfg/totp/backup-codes/regenerate/
2834
- */
2835
- declare function useCreateTotpBackupCodesRegenerateCreate(): (data: BackupCodesRegenerateRequest, client?: API) => Promise<BackupCodesRegenerateResponse>;
2836
-
2837
- /**
2838
- * SWR Hooks for TOTP Management
2839
- *
2840
- * React hooks powered by SWR for data fetching with automatic caching,
2841
- * revalidation, and optimistic updates.
2842
- *
2843
- * Usage:
2844
- * ```typescript
2845
- * // Query hooks (GET)
2846
- * const { data, error, isLoading } = useUsers({ page: 1 })
2847
- *
2848
- * // Mutation hooks (POST/PUT/PATCH/DELETE)
2849
- * const createUser = useCreateUser()
2850
- * await createUser({ name: 'John', email: 'john@example.com' })
2851
- * ```
2852
- */
2853
-
2854
- /**
2855
- * API operation
2856
- *
2857
- * @method GET
2858
- * @path /cfg/totp/devices/
2859
- */
2860
- declare function useTotpDevicesRetrieve(client?: API): ReturnType<typeof useSWR<DeviceListResponse>>;
2861
- /**
2862
- * API operation
2863
- *
2864
- * @method POST
2865
- * @path /cfg/totp/disable/
2866
- */
2867
- declare function useCreateTotpDisableCreate(): (data: DisableRequest, client?: API) => Promise<any>;
2868
-
2869
- /**
2870
- * API operation
2871
- *
2872
- * @method POST
2873
- * @path /cfg/totp/setup/
2874
- */
2875
- declare function useCreateTotpSetupCreate(): (data: SetupRequest, client?: API) => Promise<SetupResponse>;
2876
- /**
2877
- * API operation
2878
- *
2879
- * @method POST
2880
- * @path /cfg/totp/setup/confirm/
2881
- */
2882
- declare function useCreateTotpSetupConfirmCreate(): (data: ConfirmSetupRequest, client?: API) => Promise<ConfirmSetupResponse>;
2883
-
2884
- /**
2885
- * API operation
2886
- *
2887
- * @method POST
2888
- * @path /cfg/totp/verify/
2889
- */
2890
- declare function useCreateTotpVerifyCreate(): (data: VerifyRequest, client?: API) => Promise<VerifyResponse>;
2891
- /**
2892
- * API operation
2893
- *
2894
- * @method POST
2895
- * @path /cfg/totp/verify/backup/
2896
- */
2897
- declare function useCreateTotpVerifyBackupCreate(): (data: VerifyBackupRequest, client?: API) => Promise<VerifyResponse>;
2898
-
2899
- /**
2900
- * API operation
2901
- *
2902
- * @method DELETE
2903
- * @path /cfg/totp/devices/{id}/
2904
- */
2905
- declare function useDeleteTotpDevicesDestroy(): (id: string, client?: API) => Promise<void>;
2906
-
2907
- /**
2908
- * SWR Hooks - React data fetching hooks
2909
- *
2910
- * Auto-generated from OpenAPI specification.
2911
- * Powered by SWR for automatic caching and revalidation.
2912
- *
2913
- * Features:
2914
- * - Automatic caching and deduplication
2915
- * - Revalidation on focus/reconnect
2916
- * - Optimistic updates
2917
- * - Type-safe parameters and responses
2918
- *
2919
- * Usage:
2920
- * ```typescript
2921
- * import * as hooks from './hooks'
2922
- *
2923
- * // Query hooks (GET)
2924
- * const { data, error, isLoading } = hooks.useUsers({ page: 1 })
2925
- *
2926
- * // Mutation hooks (POST/PUT/PATCH/DELETE)
2927
- * const createUser = hooks.useCreateUser()
2928
- * await createUser({ name: 'John' })
2929
- * ```
2930
- */
2931
-
2932
- declare const index_useCreateTotpBackupCodesRegenerateCreate: typeof useCreateTotpBackupCodesRegenerateCreate;
2933
- declare const index_useCreateTotpDisableCreate: typeof useCreateTotpDisableCreate;
2934
- declare const index_useCreateTotpSetupConfirmCreate: typeof useCreateTotpSetupConfirmCreate;
2935
- declare const index_useCreateTotpSetupCreate: typeof useCreateTotpSetupCreate;
2936
- declare const index_useCreateTotpVerifyBackupCreate: typeof useCreateTotpVerifyBackupCreate;
2937
- declare const index_useCreateTotpVerifyCreate: typeof useCreateTotpVerifyCreate;
2938
- declare const index_useDeleteTotpDevicesDestroy: typeof useDeleteTotpDevicesDestroy;
2939
- declare const index_useTotpBackupCodesRetrieve: typeof useTotpBackupCodesRetrieve;
2940
- declare const index_useTotpDevicesRetrieve: typeof useTotpDevicesRetrieve;
2941
- declare namespace index {
2942
- export { index_useCreateTotpBackupCodesRegenerateCreate as useCreateTotpBackupCodesRegenerateCreate, index_useCreateTotpDisableCreate as useCreateTotpDisableCreate, index_useCreateTotpSetupConfirmCreate as useCreateTotpSetupConfirmCreate, index_useCreateTotpSetupCreate as useCreateTotpSetupCreate, index_useCreateTotpVerifyBackupCreate as useCreateTotpVerifyBackupCreate, index_useCreateTotpVerifyCreate as useCreateTotpVerifyCreate, index_useDeleteTotpDevicesDestroy as useDeleteTotpDevicesDestroy, index_useTotpBackupCodesRetrieve as useTotpBackupCodesRetrieve, index_useTotpDevicesRetrieve as useTotpDevicesRetrieve };
183
+ setLocale(locale: string | null): void;
184
+ getApiKey(): string | null;
185
+ setApiKey(key: string | null): void;
2943
186
  }
2944
187
 
2945
- /**
2946
- * @djangocfg/api - Pre-configured API Clients
2947
- *
2948
- * Ready-to-use API instances for accounts and centrifugo.
2949
- *
2950
- * Usage:
2951
- * import { apiAccounts, apiCentrifugo } from '@djangocfg/api/clients';
2952
- * import { useAccountsOauthGithubCallbackCreate } from '@djangocfg/api/clients';
2953
- */
2954
-
2955
- declare const apiAccounts: API$2;
2956
- declare const apiTotp: API;
2957
- declare const apiCentrifugo: API$1;
188
+ declare const CfgAccountsApi: API$2;
189
+ declare const CfgCentrifugoApi: API$1;
190
+ declare const CfgTotpApi: API;
2958
191
 
2959
- export { type AccountDeleteResponse, AccountDeleteResponseSchema, API$2 as AccountsAPI, API$1 as CentrifugoAPI, index$4 as CentrifugoFetchers, index$1 as CentrifugoHooks, type CentrifugoToken, CentrifugoTokenSchema, index$5 as CentrifugoTypes, type CfgAccountsProfileAvatarCreateRequest, CfgAccountsProfileAvatarCreateRequestSchema, enums as Enums, type OAuthAuthorizeRequestRequest, OAuthAuthorizeRequestRequestSchema, type OAuthAuthorizeResponse, OAuthAuthorizeResponseSchema, type OAuthCallbackRequestRequest, OAuthCallbackRequestRequestSchema, type OAuthConnection, OAuthConnectionSchema, type OAuthDisconnectRequestRequest, OAuthDisconnectRequestRequestSchema, type OAuthError, OAuthErrorSchema, type OAuthProvidersResponse, OAuthProvidersResponseSchema, type OAuthTokenResponse, OAuthTokenResponseSchema, type OTPErrorResponse, OTPErrorResponseSchema, type OTPRequestRequest, OTPRequestRequestSchema, type OTPRequestResponse, OTPRequestResponseSchema, type OTPVerifyRequest, OTPVerifyRequestSchema, type OTPVerifyResponse, OTPVerifyResponseSchema, type PatchedUserProfileUpdateRequest, PatchedUserProfileUpdateRequestSchema, type TokenRefresh, type TokenRefreshRequest, TokenRefreshRequestSchema, TokenRefreshSchema, API as TotpAPI, index$2 as TotpFetchers, index as TotpHooks, index$3 as TotpTypes, type User, type UserProfileUpdateRequest, UserProfileUpdateRequestSchema, UserSchema, apiAccounts, apiCentrifugo, apiTotp, createAccountsOauthDisconnectCreate, createAccountsOauthGithubAuthorizeCreate, createAccountsOauthGithubCallbackCreate, createAccountsOtpRequestCreate, createAccountsOtpVerifyCreate, createAccountsProfileAvatarCreate, createAccountsProfileDeleteCreate, createAccountsTokenRefreshCreate, getAccountsOauthConnectionsList, getAccountsOauthProvidersRetrieve, getAccountsProfileRetrieve, partialUpdateAccountsProfilePartialPartialUpdate, partialUpdateAccountsProfilePartialUpdate, partialUpdateAccountsProfileUpdatePartialUpdate, updateAccountsProfileUpdateUpdate, useAccountsOauthConnectionsList, useAccountsOauthProvidersRetrieve, useAccountsProfileRetrieve, useCreateAccountsOauthDisconnectCreate, useCreateAccountsOauthGithubAuthorizeCreate, useCreateAccountsOauthGithubCallbackCreate, useCreateAccountsOtpRequestCreate, useCreateAccountsOtpVerifyCreate, useCreateAccountsProfileAvatarCreate, useCreateAccountsProfileDeleteCreate, useCreateAccountsTokenRefreshCreate, usePartialUpdateAccountsProfilePartialPartialUpdate, usePartialUpdateAccountsProfilePartialUpdate, usePartialUpdateAccountsProfileUpdatePartialUpdate, useUpdateAccountsProfileUpdateUpdate };
192
+ export { API$2 as AccountsAPI, API$1 as CentrifugoAPI, API as TotpAPI, CfgAccountsApi as apiAccounts, CfgCentrifugoApi as apiCentrifugo, CfgTotpApi as apiTotp };