@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
@@ -5,13 +5,13 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
5
5
  import { NextResponse } from "next/server";
6
6
  function proxyMiddleware(request) {
7
7
  const { pathname, search } = request.nextUrl;
8
- const apiUrl2 = process.env.NEXT_PUBLIC_API_URL;
8
+ const apiUrl = process.env.NEXT_PUBLIC_API_URL;
9
9
  if (pathname.startsWith("/media/")) {
10
- const targetUrl = `${apiUrl2}${pathname}${search}`;
10
+ const targetUrl = `${apiUrl}${pathname}${search}`;
11
11
  return NextResponse.rewrite(targetUrl, { request: { headers: request.headers } });
12
12
  }
13
13
  if (pathname.startsWith("/api/")) {
14
- const targetUrl = `${apiUrl2}${pathname}${search}`;
14
+ const targetUrl = `${apiUrl}${pathname}${search}`;
15
15
  return NextResponse.rewrite(targetUrl, { request: { headers: request.headers } });
16
16
  }
17
17
  return NextResponse.next();
@@ -21,357 +21,845 @@ var proxyMiddlewareConfig = {
21
21
  matcher: ["/media/:path*", "/api/:path*"]
22
22
  };
23
23
 
24
- // src/_api/generated/cfg_accounts/accounts__auth/client.ts
25
- var Auth = class {
26
- static {
27
- __name(this, "Auth");
24
+ // src/_api/generated/core/bodySerializer.gen.ts
25
+ var jsonBodySerializer = {
26
+ bodySerializer: /* @__PURE__ */ __name((body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value), "bodySerializer")
27
+ };
28
+
29
+ // src/_api/generated/core/params.gen.ts
30
+ var extraPrefixesMap = {
31
+ $body_: "body",
32
+ $headers_: "headers",
33
+ $path_: "path",
34
+ $query_: "query"
35
+ };
36
+ var extraPrefixes = Object.entries(extraPrefixesMap);
37
+
38
+ // src/_api/generated/core/serverSentEvents.gen.ts
39
+ function createSseClient({
40
+ onRequest,
41
+ onSseError,
42
+ onSseEvent,
43
+ responseTransformer,
44
+ responseValidator,
45
+ sseDefaultRetryDelay,
46
+ sseMaxRetryAttempts,
47
+ sseMaxRetryDelay,
48
+ sseSleepFn,
49
+ url,
50
+ ...options
51
+ }) {
52
+ let lastEventId;
53
+ const sleep = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
54
+ const createStream = /* @__PURE__ */ __name(async function* () {
55
+ let retryDelay = sseDefaultRetryDelay ?? 3e3;
56
+ let attempt = 0;
57
+ const signal = options.signal ?? new AbortController().signal;
58
+ while (true) {
59
+ if (signal.aborted) break;
60
+ attempt++;
61
+ const headers = options.headers instanceof Headers ? options.headers : new Headers(options.headers);
62
+ if (lastEventId !== void 0) {
63
+ headers.set("Last-Event-ID", lastEventId);
64
+ }
65
+ try {
66
+ const requestInit = {
67
+ redirect: "follow",
68
+ ...options,
69
+ body: options.serializedBody,
70
+ headers,
71
+ signal
72
+ };
73
+ let request = new Request(url, requestInit);
74
+ if (onRequest) {
75
+ request = await onRequest(url, requestInit);
76
+ }
77
+ const _fetch = options.fetch ?? globalThis.fetch;
78
+ const response = await _fetch(request);
79
+ if (!response.ok) throw new Error(`SSE failed: ${response.status} ${response.statusText}`);
80
+ if (!response.body) throw new Error("No body in SSE response");
81
+ const reader = response.body.pipeThrough(new TextDecoderStream()).getReader();
82
+ let buffer = "";
83
+ const abortHandler = /* @__PURE__ */ __name(() => {
84
+ try {
85
+ reader.cancel();
86
+ } catch {
87
+ }
88
+ }, "abortHandler");
89
+ signal.addEventListener("abort", abortHandler);
90
+ try {
91
+ while (true) {
92
+ const { done, value } = await reader.read();
93
+ if (done) break;
94
+ buffer += value;
95
+ buffer = buffer.replace(/\r\n?/g, "\n");
96
+ const chunks = buffer.split("\n\n");
97
+ buffer = chunks.pop() ?? "";
98
+ for (const chunk of chunks) {
99
+ const lines = chunk.split("\n");
100
+ const dataLines = [];
101
+ let eventName;
102
+ for (const line of lines) {
103
+ if (line.startsWith("data:")) {
104
+ dataLines.push(line.replace(/^data:\s*/, ""));
105
+ } else if (line.startsWith("event:")) {
106
+ eventName = line.replace(/^event:\s*/, "");
107
+ } else if (line.startsWith("id:")) {
108
+ lastEventId = line.replace(/^id:\s*/, "");
109
+ } else if (line.startsWith("retry:")) {
110
+ const parsed = Number.parseInt(line.replace(/^retry:\s*/, ""), 10);
111
+ if (!Number.isNaN(parsed)) {
112
+ retryDelay = parsed;
113
+ }
114
+ }
115
+ }
116
+ let data;
117
+ let parsedJson = false;
118
+ if (dataLines.length) {
119
+ const rawData = dataLines.join("\n");
120
+ try {
121
+ data = JSON.parse(rawData);
122
+ parsedJson = true;
123
+ } catch {
124
+ data = rawData;
125
+ }
126
+ }
127
+ if (parsedJson) {
128
+ if (responseValidator) {
129
+ await responseValidator(data);
130
+ }
131
+ if (responseTransformer) {
132
+ data = await responseTransformer(data);
133
+ }
134
+ }
135
+ onSseEvent?.({
136
+ data,
137
+ event: eventName,
138
+ id: lastEventId,
139
+ retry: retryDelay
140
+ });
141
+ if (dataLines.length) {
142
+ yield data;
143
+ }
144
+ }
145
+ }
146
+ } finally {
147
+ signal.removeEventListener("abort", abortHandler);
148
+ reader.releaseLock();
149
+ }
150
+ break;
151
+ } catch (error) {
152
+ onSseError?.(error);
153
+ if (sseMaxRetryAttempts !== void 0 && attempt >= sseMaxRetryAttempts) {
154
+ break;
155
+ }
156
+ const backoff = Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 3e4);
157
+ await sleep(backoff);
158
+ }
159
+ }
160
+ }, "createStream");
161
+ const stream = createStream();
162
+ return { stream };
163
+ }
164
+ __name(createSseClient, "createSseClient");
165
+
166
+ // src/_api/generated/core/pathSerializer.gen.ts
167
+ var separatorArrayExplode = /* @__PURE__ */ __name((style) => {
168
+ switch (style) {
169
+ case "label":
170
+ return ".";
171
+ case "matrix":
172
+ return ";";
173
+ case "simple":
174
+ return ",";
175
+ default:
176
+ return "&";
177
+ }
178
+ }, "separatorArrayExplode");
179
+ var separatorArrayNoExplode = /* @__PURE__ */ __name((style) => {
180
+ switch (style) {
181
+ case "form":
182
+ return ",";
183
+ case "pipeDelimited":
184
+ return "|";
185
+ case "spaceDelimited":
186
+ return "%20";
187
+ default:
188
+ return ",";
189
+ }
190
+ }, "separatorArrayNoExplode");
191
+ var separatorObjectExplode = /* @__PURE__ */ __name((style) => {
192
+ switch (style) {
193
+ case "label":
194
+ return ".";
195
+ case "matrix":
196
+ return ";";
197
+ case "simple":
198
+ return ",";
199
+ default:
200
+ return "&";
201
+ }
202
+ }, "separatorObjectExplode");
203
+ var serializeArrayParam = /* @__PURE__ */ __name(({
204
+ allowReserved,
205
+ explode,
206
+ name,
207
+ style,
208
+ value
209
+ }) => {
210
+ if (!explode) {
211
+ const joinedValues2 = (allowReserved ? value : value.map((v) => encodeURIComponent(v))).join(separatorArrayNoExplode(style));
212
+ switch (style) {
213
+ case "label":
214
+ return `.${joinedValues2}`;
215
+ case "matrix":
216
+ return `;${name}=${joinedValues2}`;
217
+ case "simple":
218
+ return joinedValues2;
219
+ default:
220
+ return `${name}=${joinedValues2}`;
221
+ }
28
222
  }
29
- client;
30
- constructor(client) {
31
- this.client = client;
223
+ const separator = separatorArrayExplode(style);
224
+ const joinedValues = value.map((v) => {
225
+ if (style === "label" || style === "simple") {
226
+ return allowReserved ? v : encodeURIComponent(v);
227
+ }
228
+ return serializePrimitiveParam({
229
+ allowReserved,
230
+ name,
231
+ value: v
232
+ });
233
+ }).join(separator);
234
+ return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
235
+ }, "serializeArrayParam");
236
+ var serializePrimitiveParam = /* @__PURE__ */ __name(({
237
+ allowReserved,
238
+ name,
239
+ value
240
+ }) => {
241
+ if (value === void 0 || value === null) {
242
+ return "";
243
+ }
244
+ if (typeof value === "object") {
245
+ throw new Error(
246
+ "Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these."
247
+ );
32
248
  }
33
- /**
34
- * Refresh JWT token.
35
- */
36
- async accountsTokenRefreshCreate(data) {
37
- const response = await this.client.request("POST", "/cfg/accounts/token/refresh/", { body: data });
38
- return response;
249
+ return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
250
+ }, "serializePrimitiveParam");
251
+ var serializeObjectParam = /* @__PURE__ */ __name(({
252
+ allowReserved,
253
+ explode,
254
+ name,
255
+ style,
256
+ value,
257
+ valueOnly
258
+ }) => {
259
+ if (value instanceof Date) {
260
+ return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
261
+ }
262
+ if (style !== "deepObject" && !explode) {
263
+ let values = [];
264
+ Object.entries(value).forEach(([key, v]) => {
265
+ values = [...values, key, allowReserved ? v : encodeURIComponent(v)];
266
+ });
267
+ const joinedValues2 = values.join(",");
268
+ switch (style) {
269
+ case "form":
270
+ return `${name}=${joinedValues2}`;
271
+ case "label":
272
+ return `.${joinedValues2}`;
273
+ case "matrix":
274
+ return `;${name}=${joinedValues2}`;
275
+ default:
276
+ return joinedValues2;
277
+ }
39
278
  }
40
- };
279
+ const separator = separatorObjectExplode(style);
280
+ const joinedValues = Object.entries(value).map(
281
+ ([key, v]) => serializePrimitiveParam({
282
+ allowReserved,
283
+ name: style === "deepObject" ? `${name}[${key}]` : key,
284
+ value: v
285
+ })
286
+ ).join(separator);
287
+ return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
288
+ }, "serializeObjectParam");
41
289
 
42
- // src/_api/generated/cfg_accounts/accounts__oauth/client.ts
43
- var Oauth = class {
44
- static {
45
- __name(this, "Oauth");
46
- }
47
- client;
48
- constructor(client) {
49
- this.client = client;
290
+ // src/_api/generated/core/utils.gen.ts
291
+ var PATH_PARAM_RE = /\{[^{}]+\}/g;
292
+ var defaultPathSerializer = /* @__PURE__ */ __name(({ path, url: _url }) => {
293
+ let url = _url;
294
+ const matches = _url.match(PATH_PARAM_RE);
295
+ if (matches) {
296
+ for (const match of matches) {
297
+ let explode = false;
298
+ let name = match.substring(1, match.length - 1);
299
+ let style = "simple";
300
+ if (name.endsWith("*")) {
301
+ explode = true;
302
+ name = name.substring(0, name.length - 1);
303
+ }
304
+ if (name.startsWith(".")) {
305
+ name = name.substring(1);
306
+ style = "label";
307
+ } else if (name.startsWith(";")) {
308
+ name = name.substring(1);
309
+ style = "matrix";
310
+ }
311
+ const value = path[name];
312
+ if (value === void 0 || value === null) {
313
+ continue;
314
+ }
315
+ if (Array.isArray(value)) {
316
+ url = url.replace(match, serializeArrayParam({ explode, name, style, value }));
317
+ continue;
318
+ }
319
+ if (typeof value === "object") {
320
+ url = url.replace(
321
+ match,
322
+ serializeObjectParam({
323
+ explode,
324
+ name,
325
+ style,
326
+ value,
327
+ valueOnly: true
328
+ })
329
+ );
330
+ continue;
331
+ }
332
+ if (style === "matrix") {
333
+ url = url.replace(
334
+ match,
335
+ `;${serializePrimitiveParam({
336
+ name,
337
+ value
338
+ })}`
339
+ );
340
+ continue;
341
+ }
342
+ const replaceValue = encodeURIComponent(
343
+ style === "label" ? `.${value}` : value
344
+ );
345
+ url = url.replace(match, replaceValue);
346
+ }
50
347
  }
51
- /**
52
- * List OAuth connections
53
- *
54
- * Get all OAuth connections for the current user.
55
- */
56
- async accountsOauthConnectionsList() {
57
- const response = await this.client.request("GET", "/cfg/accounts/oauth/connections/");
58
- return response.results || response;
348
+ return url;
349
+ }, "defaultPathSerializer");
350
+ var getUrl = /* @__PURE__ */ __name(({
351
+ baseUrl: baseUrl2,
352
+ path,
353
+ query,
354
+ querySerializer,
355
+ url: _url
356
+ }) => {
357
+ const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
358
+ let url = (baseUrl2 ?? "") + pathUrl;
359
+ if (path) {
360
+ url = defaultPathSerializer({ path, url });
361
+ }
362
+ let search = query ? querySerializer(query) : "";
363
+ if (search.startsWith("?")) {
364
+ search = search.substring(1);
365
+ }
366
+ if (search) {
367
+ url += `?${search}`;
368
+ }
369
+ return url;
370
+ }, "getUrl");
371
+ function getValidRequestBody(options) {
372
+ const hasBody = options.body !== void 0;
373
+ const isSerializedBody = hasBody && options.bodySerializer;
374
+ if (isSerializedBody) {
375
+ if ("serializedBody" in options) {
376
+ const hasSerializedBody = options.serializedBody !== void 0 && options.serializedBody !== "";
377
+ return hasSerializedBody ? options.serializedBody : null;
378
+ }
379
+ return options.body !== "" ? options.body : null;
59
380
  }
60
- /**
61
- * Disconnect OAuth provider
62
- *
63
- * Remove OAuth connection for the specified provider.
64
- */
65
- async accountsOauthDisconnectCreate(data) {
66
- const response = await this.client.request("POST", "/cfg/accounts/oauth/disconnect/", { body: data });
67
- return response;
381
+ if (hasBody) {
382
+ return options.body;
68
383
  }
69
- /**
70
- * Start GitHub OAuth
71
- *
72
- * Generate GitHub OAuth authorization URL. Redirect user to this URL to
73
- * start authentication.
74
- */
75
- async accountsOauthGithubAuthorizeCreate(data) {
76
- const response = await this.client.request("POST", "/cfg/accounts/oauth/github/authorize/", { body: data });
77
- return response;
384
+ return void 0;
385
+ }
386
+ __name(getValidRequestBody, "getValidRequestBody");
387
+
388
+ // src/_api/generated/core/auth.gen.ts
389
+ var getAuthToken = /* @__PURE__ */ __name(async (auth, callback) => {
390
+ const token = typeof callback === "function" ? await callback(auth) : callback;
391
+ if (!token) {
392
+ return;
78
393
  }
79
- /**
80
- * Complete GitHub OAuth
81
- *
82
- * Exchange authorization code for JWT tokens. Call this after GitHub
83
- * redirects back with code.
84
- */
85
- async accountsOauthGithubCallbackCreate(data) {
86
- const response = await this.client.request("POST", "/cfg/accounts/oauth/github/callback/", { body: data });
87
- return response;
394
+ if (auth.scheme === "bearer") {
395
+ return `Bearer ${token}`;
88
396
  }
89
- /**
90
- * List OAuth providers
91
- *
92
- * Get list of available OAuth providers for authentication.
93
- */
94
- async accountsOauthProvidersRetrieve() {
95
- const response = await this.client.request("GET", "/cfg/accounts/oauth/providers/");
96
- return response;
397
+ if (auth.scheme === "basic") {
398
+ return `Basic ${btoa(token)}`;
97
399
  }
98
- };
400
+ return token;
401
+ }, "getAuthToken");
99
402
 
100
- // src/_api/generated/cfg_accounts/accounts__user_profile/client.ts
101
- var UserProfile = class {
102
- static {
103
- __name(this, "UserProfile");
104
- }
105
- client;
106
- constructor(client) {
107
- this.client = client;
403
+ // src/_api/generated/client/utils.gen.ts
404
+ var createQuerySerializer = /* @__PURE__ */ __name(({
405
+ parameters = {},
406
+ ...args
407
+ } = {}) => {
408
+ const querySerializer = /* @__PURE__ */ __name((queryParams) => {
409
+ const search = [];
410
+ if (queryParams && typeof queryParams === "object") {
411
+ for (const name in queryParams) {
412
+ const value = queryParams[name];
413
+ if (value === void 0 || value === null) {
414
+ continue;
415
+ }
416
+ const options = parameters[name] || args;
417
+ if (Array.isArray(value)) {
418
+ const serializedArray = serializeArrayParam({
419
+ allowReserved: options.allowReserved,
420
+ explode: true,
421
+ name,
422
+ style: "form",
423
+ value,
424
+ ...options.array
425
+ });
426
+ if (serializedArray) search.push(serializedArray);
427
+ } else if (typeof value === "object") {
428
+ const serializedObject = serializeObjectParam({
429
+ allowReserved: options.allowReserved,
430
+ explode: true,
431
+ name,
432
+ style: "deepObject",
433
+ value,
434
+ ...options.object
435
+ });
436
+ if (serializedObject) search.push(serializedObject);
437
+ } else {
438
+ const serializedPrimitive = serializePrimitiveParam({
439
+ allowReserved: options.allowReserved,
440
+ name,
441
+ value
442
+ });
443
+ if (serializedPrimitive) search.push(serializedPrimitive);
444
+ }
445
+ }
446
+ }
447
+ return search.join("&");
448
+ }, "querySerializer");
449
+ return querySerializer;
450
+ }, "createQuerySerializer");
451
+ var getParseAs = /* @__PURE__ */ __name((contentType) => {
452
+ if (!contentType) {
453
+ return "stream";
454
+ }
455
+ const cleanContent = contentType.split(";")[0]?.trim();
456
+ if (!cleanContent) {
457
+ return;
458
+ }
459
+ if (cleanContent.startsWith("application/json") || cleanContent.endsWith("+json")) {
460
+ return "json";
461
+ }
462
+ if (cleanContent === "multipart/form-data") {
463
+ return "formData";
464
+ }
465
+ if (["application/", "audio/", "image/", "video/"].some((type) => cleanContent.startsWith(type))) {
466
+ return "blob";
467
+ }
468
+ if (cleanContent.startsWith("text/")) {
469
+ return "text";
470
+ }
471
+ return;
472
+ }, "getParseAs");
473
+ var checkForExistence = /* @__PURE__ */ __name((options, name) => {
474
+ if (!name) {
475
+ return false;
108
476
  }
109
- /**
110
- * Get current user profile
111
- *
112
- * Retrieve the current authenticated user's profile information.
113
- */
114
- async accountsProfileRetrieve() {
115
- const response = await this.client.request("GET", "/cfg/accounts/profile/");
116
- return response;
477
+ if (options.headers.has(name) || options.query?.[name] || options.headers.get("Cookie")?.includes(`${name}=`)) {
478
+ return true;
117
479
  }
118
- /**
119
- * Upload user avatar
120
- *
121
- * Upload avatar image for the current authenticated user. Accepts
122
- * multipart/form-data with 'avatar' field.
123
- */
124
- async accountsProfileAvatarCreate(data) {
125
- const formData = new FormData();
126
- formData.append("avatar", data.avatar);
127
- const response = await this.client.request("POST", "/cfg/accounts/profile/avatar/", { formData });
128
- return response;
480
+ return false;
481
+ }, "checkForExistence");
482
+ var setAuthParams = /* @__PURE__ */ __name(async ({
483
+ security,
484
+ ...options
485
+ }) => {
486
+ for (const auth of security) {
487
+ if (checkForExistence(options, auth.name)) {
488
+ continue;
489
+ }
490
+ const token = await getAuthToken(auth, options.auth);
491
+ if (!token) {
492
+ continue;
493
+ }
494
+ const name = auth.name ?? "Authorization";
495
+ switch (auth.in) {
496
+ case "query":
497
+ if (!options.query) {
498
+ options.query = {};
499
+ }
500
+ options.query[name] = token;
501
+ break;
502
+ case "cookie":
503
+ options.headers.append("Cookie", `${name}=${token}`);
504
+ break;
505
+ case "header":
506
+ default:
507
+ options.headers.set(name, token);
508
+ break;
509
+ }
129
510
  }
130
- /**
131
- * Delete user account
132
- *
133
- * Permanently delete the current user's account. This operation: -
134
- * Deactivates the account (user cannot log in) - Anonymizes personal data
135
- * (GDPR compliance) - Frees up the email address for re-registration -
136
- * Preserves audit trail The account can be restored by an administrator if
137
- * needed.
138
- */
139
- async accountsProfileDeleteCreate() {
140
- const response = await this.client.request("POST", "/cfg/accounts/profile/delete/");
141
- return response;
511
+ }, "setAuthParams");
512
+ var buildUrl = /* @__PURE__ */ __name((options) => getUrl({
513
+ baseUrl: options.baseUrl,
514
+ path: options.path,
515
+ query: options.query,
516
+ querySerializer: typeof options.querySerializer === "function" ? options.querySerializer : createQuerySerializer(options.querySerializer),
517
+ url: options.url
518
+ }), "buildUrl");
519
+ var mergeConfigs = /* @__PURE__ */ __name((a, b) => {
520
+ const config = { ...a, ...b };
521
+ if (config.baseUrl?.endsWith("/")) {
522
+ config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
523
+ }
524
+ config.headers = mergeHeaders(a.headers, b.headers);
525
+ return config;
526
+ }, "mergeConfigs");
527
+ var headersEntries = /* @__PURE__ */ __name((headers) => {
528
+ const entries = [];
529
+ headers.forEach((value, key) => {
530
+ entries.push([key, value]);
531
+ });
532
+ return entries;
533
+ }, "headersEntries");
534
+ var mergeHeaders = /* @__PURE__ */ __name((...headers) => {
535
+ const mergedHeaders = new Headers();
536
+ for (const header of headers) {
537
+ if (!header) {
538
+ continue;
539
+ }
540
+ const iterator = header instanceof Headers ? headersEntries(header) : Object.entries(header);
541
+ for (const [key, value] of iterator) {
542
+ if (value === null) {
543
+ mergedHeaders.delete(key);
544
+ } else if (Array.isArray(value)) {
545
+ for (const v of value) {
546
+ mergedHeaders.append(key, v);
547
+ }
548
+ } else if (value !== void 0) {
549
+ mergedHeaders.set(
550
+ key,
551
+ typeof value === "object" ? JSON.stringify(value) : value
552
+ );
553
+ }
554
+ }
142
555
  }
143
- /**
144
- * Partial update user profile
145
- *
146
- * Partially update the current authenticated user's profile information.
147
- * Supports avatar upload.
148
- */
149
- async accountsProfilePartialUpdate(data) {
150
- const response = await this.client.request("PUT", "/cfg/accounts/profile/partial/", { body: data });
151
- return response;
556
+ return mergedHeaders;
557
+ }, "mergeHeaders");
558
+ var Interceptors = class {
559
+ static {
560
+ __name(this, "Interceptors");
152
561
  }
153
- /**
154
- * Partial update user profile
155
- *
156
- * Partially update the current authenticated user's profile information.
157
- * Supports avatar upload.
158
- */
159
- async accountsProfilePartialPartialUpdate(data) {
160
- const response = await this.client.request("PATCH", "/cfg/accounts/profile/partial/", { body: data });
161
- return response;
562
+ fns = [];
563
+ clear() {
564
+ this.fns = [];
162
565
  }
163
- /**
164
- * Update user profile
165
- *
166
- * Update the current authenticated user's profile information.
167
- */
168
- async accountsProfileUpdateUpdate(data) {
169
- const response = await this.client.request("PUT", "/cfg/accounts/profile/update/", { body: data });
170
- return response;
566
+ eject(id) {
567
+ const index = this.getInterceptorIndex(id);
568
+ if (this.fns[index]) {
569
+ this.fns[index] = null;
570
+ }
171
571
  }
172
- /**
173
- * Update user profile
174
- *
175
- * Update the current authenticated user's profile information.
176
- */
177
- async accountsProfileUpdatePartialUpdate(data) {
178
- const response = await this.client.request("PATCH", "/cfg/accounts/profile/update/", { body: data });
179
- return response;
572
+ exists(id) {
573
+ const index = this.getInterceptorIndex(id);
574
+ return Boolean(this.fns[index]);
180
575
  }
181
- };
182
-
183
- // src/_api/generated/cfg_accounts/accounts/client.ts
184
- var Accounts = class {
185
- static {
186
- __name(this, "Accounts");
576
+ getInterceptorIndex(id) {
577
+ if (typeof id === "number") {
578
+ return this.fns[id] ? id : -1;
579
+ }
580
+ return this.fns.indexOf(id);
187
581
  }
188
- client;
189
- constructor(client) {
190
- this.client = client;
582
+ update(id, fn) {
583
+ const index = this.getInterceptorIndex(id);
584
+ if (this.fns[index]) {
585
+ this.fns[index] = fn;
586
+ return id;
587
+ }
588
+ return false;
191
589
  }
192
- /**
193
- * Request OTP code to email.
194
- */
195
- async otpRequestCreate(data) {
196
- const response = await this.client.request("POST", "/cfg/accounts/otp/request/", { body: data });
197
- return response;
590
+ use(fn) {
591
+ this.fns.push(fn);
592
+ return this.fns.length - 1;
198
593
  }
199
- /**
200
- * Verify OTP code and return JWT tokens or 2FA session. If user has 2FA
201
- * enabled: - Returns requires_2fa=True with session_id - Client must
202
- * complete 2FA verification at /cfg/totp/verify/ If user has no 2FA: -
203
- * Returns JWT tokens and user data directly
204
- */
205
- async otpVerifyCreate(data) {
206
- const response = await this.client.request("POST", "/cfg/accounts/otp/verify/", { body: data });
207
- return response;
594
+ };
595
+ var createInterceptors = /* @__PURE__ */ __name(() => ({
596
+ error: new Interceptors(),
597
+ request: new Interceptors(),
598
+ response: new Interceptors()
599
+ }), "createInterceptors");
600
+ var defaultQuerySerializer = createQuerySerializer({
601
+ allowReserved: false,
602
+ array: {
603
+ explode: true,
604
+ style: "form"
605
+ },
606
+ object: {
607
+ explode: true,
608
+ style: "deepObject"
208
609
  }
610
+ });
611
+ var defaultHeaders = {
612
+ "Content-Type": "application/json"
209
613
  };
614
+ var createConfig = /* @__PURE__ */ __name((override = {}) => ({
615
+ ...jsonBodySerializer,
616
+ headers: defaultHeaders,
617
+ parseAs: "auto",
618
+ querySerializer: defaultQuerySerializer,
619
+ ...override
620
+ }), "createConfig");
210
621
 
211
- // src/_api/generated/cfg_accounts/http.ts
212
- var FetchAdapter = class {
213
- static {
214
- __name(this, "FetchAdapter");
215
- }
216
- async request(request) {
217
- const { method, url, headers, body, params, formData, binaryBody, responseType } = request;
218
- let finalUrl = url;
219
- if (params) {
220
- const searchParams = new URLSearchParams();
221
- Object.entries(params).forEach(([key, value]) => {
222
- if (value !== null && value !== void 0) {
223
- searchParams.append(key, String(value));
224
- }
622
+ // src/_api/generated/client/client.gen.ts
623
+ var createClient = /* @__PURE__ */ __name((config = {}) => {
624
+ let _config = mergeConfigs(createConfig(), config);
625
+ const getConfig = /* @__PURE__ */ __name(() => ({ ..._config }), "getConfig");
626
+ const setConfig = /* @__PURE__ */ __name((config2) => {
627
+ _config = mergeConfigs(_config, config2);
628
+ return getConfig();
629
+ }, "setConfig");
630
+ const interceptors = createInterceptors();
631
+ const beforeRequest = /* @__PURE__ */ __name(async (options) => {
632
+ const opts = {
633
+ ..._config,
634
+ ...options,
635
+ fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
636
+ headers: mergeHeaders(_config.headers, options.headers),
637
+ serializedBody: void 0
638
+ };
639
+ if (opts.security) {
640
+ await setAuthParams({
641
+ ...opts,
642
+ security: opts.security
225
643
  });
226
- const queryString = searchParams.toString();
227
- if (queryString) {
228
- finalUrl = url.includes("?") ? `${url}&${queryString}` : `${url}?${queryString}`;
229
- }
230
644
  }
231
- const finalHeaders = { ...headers };
232
- let requestBody;
233
- if (formData) {
234
- requestBody = formData;
235
- } else if (binaryBody) {
236
- finalHeaders["Content-Type"] = "application/octet-stream";
237
- requestBody = binaryBody;
238
- } else if (body) {
239
- finalHeaders["Content-Type"] = "application/json";
240
- requestBody = JSON.stringify(body);
645
+ if (opts.requestValidator) {
646
+ await opts.requestValidator(opts);
241
647
  }
242
- const response = await fetch(finalUrl, {
243
- method,
244
- headers: finalHeaders,
245
- body: requestBody,
246
- credentials: "include"
247
- // Include Django session cookies
248
- });
249
- let data = null;
250
- const contentType = response.headers.get("content-type") ?? "";
251
- if (response.status !== 204) {
252
- if (responseType === "blob") {
253
- data = await response.blob();
254
- } else if (responseType === "text") {
255
- data = await response.text();
256
- } else if (responseType === "json") {
257
- data = await response.json();
258
- } else if (contentType.includes("application/json")) {
259
- data = await response.json();
260
- } else if (contentType.startsWith("text/")) {
261
- data = await response.text();
262
- } else {
263
- data = await response.blob();
648
+ if (opts.body !== void 0 && opts.bodySerializer) {
649
+ opts.serializedBody = opts.bodySerializer(opts.body);
650
+ }
651
+ if (opts.body === void 0 || opts.serializedBody === "") {
652
+ opts.headers.delete("Content-Type");
653
+ }
654
+ const resolvedOpts = opts;
655
+ const url = buildUrl(resolvedOpts);
656
+ return { opts: resolvedOpts, url };
657
+ }, "beforeRequest");
658
+ const request = /* @__PURE__ */ __name(async (options) => {
659
+ const throwOnError = options.throwOnError ?? _config.throwOnError;
660
+ const responseStyle = options.responseStyle ?? _config.responseStyle;
661
+ let request2;
662
+ let response;
663
+ try {
664
+ const { opts, url } = await beforeRequest(options);
665
+ const requestInit = {
666
+ redirect: "follow",
667
+ ...opts,
668
+ body: getValidRequestBody(opts)
669
+ };
670
+ request2 = new Request(url, requestInit);
671
+ for (const fn of interceptors.request.fns) {
672
+ if (fn) {
673
+ request2 = await fn(request2, opts);
674
+ }
675
+ }
676
+ const _fetch = opts.fetch;
677
+ response = await _fetch(request2);
678
+ for (const fn of interceptors.response.fns) {
679
+ if (fn) {
680
+ response = await fn(response, request2, opts);
681
+ }
682
+ }
683
+ const result = {
684
+ request: request2,
685
+ response
686
+ };
687
+ if (response.ok) {
688
+ const parseAs = (opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
689
+ if (response.status === 204 || response.headers.get("Content-Length") === "0") {
690
+ let emptyData;
691
+ switch (parseAs) {
692
+ case "arrayBuffer":
693
+ case "blob":
694
+ case "text":
695
+ emptyData = await response[parseAs]();
696
+ break;
697
+ case "formData":
698
+ emptyData = new FormData();
699
+ break;
700
+ case "stream":
701
+ emptyData = response.body;
702
+ break;
703
+ case "json":
704
+ default:
705
+ emptyData = {};
706
+ break;
707
+ }
708
+ return opts.responseStyle === "data" ? emptyData : {
709
+ data: emptyData,
710
+ ...result
711
+ };
712
+ }
713
+ let data;
714
+ switch (parseAs) {
715
+ case "arrayBuffer":
716
+ case "blob":
717
+ case "formData":
718
+ case "text":
719
+ data = await response[parseAs]();
720
+ break;
721
+ case "json": {
722
+ const text = await response.text();
723
+ data = text ? JSON.parse(text) : {};
724
+ break;
725
+ }
726
+ case "stream":
727
+ return opts.responseStyle === "data" ? response.body : {
728
+ data: response.body,
729
+ ...result
730
+ };
731
+ }
732
+ if (parseAs === "json") {
733
+ if (opts.responseValidator) {
734
+ await opts.responseValidator(data);
735
+ }
736
+ if (opts.responseTransformer) {
737
+ data = await opts.responseTransformer(data);
738
+ }
739
+ }
740
+ return opts.responseStyle === "data" ? data : {
741
+ data,
742
+ ...result
743
+ };
744
+ }
745
+ const textError = await response.text();
746
+ let jsonError;
747
+ try {
748
+ jsonError = JSON.parse(textError);
749
+ } catch {
750
+ }
751
+ throw jsonError ?? textError;
752
+ } catch (error) {
753
+ let finalError = error;
754
+ for (const fn of interceptors.error.fns) {
755
+ if (fn) {
756
+ finalError = await fn(finalError, response, request2, options);
757
+ }
264
758
  }
759
+ finalError = finalError || {};
760
+ if (throwOnError) {
761
+ throw finalError;
762
+ }
763
+ return responseStyle === "data" ? void 0 : {
764
+ error: finalError,
765
+ request: request2,
766
+ response
767
+ };
265
768
  }
266
- const responseHeaders = {};
267
- response.headers.forEach((value, key) => {
268
- responseHeaders[key] = value;
769
+ }, "request");
770
+ const makeMethodFn = /* @__PURE__ */ __name((method) => (options) => request({ ...options, method }), "makeMethodFn");
771
+ const makeSseFn = /* @__PURE__ */ __name((method) => async (options) => {
772
+ const { opts, url } = await beforeRequest(options);
773
+ return createSseClient({
774
+ ...opts,
775
+ body: opts.body,
776
+ method,
777
+ onRequest: /* @__PURE__ */ __name(async (url2, init) => {
778
+ let request2 = new Request(url2, init);
779
+ for (const fn of interceptors.request.fns) {
780
+ if (fn) {
781
+ request2 = await fn(request2, opts);
782
+ }
783
+ }
784
+ return request2;
785
+ }, "onRequest"),
786
+ serializedBody: getValidRequestBody(opts),
787
+ url
269
788
  });
270
- return {
271
- data,
272
- status: response.status,
273
- statusText: response.statusText,
274
- headers: responseHeaders
275
- };
276
- }
277
- };
789
+ }, "makeSseFn");
790
+ const _buildUrl = /* @__PURE__ */ __name((options) => buildUrl({ ..._config, ...options }), "_buildUrl");
791
+ return {
792
+ buildUrl: _buildUrl,
793
+ connect: makeMethodFn("CONNECT"),
794
+ delete: makeMethodFn("DELETE"),
795
+ get: makeMethodFn("GET"),
796
+ getConfig,
797
+ head: makeMethodFn("HEAD"),
798
+ interceptors,
799
+ options: makeMethodFn("OPTIONS"),
800
+ patch: makeMethodFn("PATCH"),
801
+ post: makeMethodFn("POST"),
802
+ put: makeMethodFn("PUT"),
803
+ request,
804
+ setConfig,
805
+ sse: {
806
+ connect: makeSseFn("CONNECT"),
807
+ delete: makeSseFn("DELETE"),
808
+ get: makeSseFn("GET"),
809
+ head: makeSseFn("HEAD"),
810
+ options: makeSseFn("OPTIONS"),
811
+ patch: makeSseFn("PATCH"),
812
+ post: makeSseFn("POST"),
813
+ put: makeSseFn("PUT"),
814
+ trace: makeSseFn("TRACE")
815
+ },
816
+ trace: makeMethodFn("TRACE")
817
+ };
818
+ }, "createClient");
278
819
 
279
- // src/_api/generated/cfg_accounts/errors.ts
280
- var APIError = class extends Error {
281
- constructor(statusCode, statusText, response, url, message) {
282
- super(message || `HTTP ${statusCode}: ${statusText}`);
283
- this.statusCode = statusCode;
284
- this.statusText = statusText;
285
- this.response = response;
286
- this.url = url;
287
- this.name = "APIError";
288
- }
820
+ // src/_api/generated/client.gen.ts
821
+ var client = createClient(createConfig({ baseUrl: "http://localhost:8000" }));
822
+
823
+ // src/_api/generated/helpers/storage.ts
824
+ var LocalStorageAdapter = class {
289
825
  static {
290
- __name(this, "APIError");
826
+ __name(this, "LocalStorageAdapter");
291
827
  }
292
- /**
293
- * Get error details from response.
294
- * DRF typically returns: { "detail": "Error message" } or { "field": ["error1", "error2"] }
295
- */
296
- get details() {
297
- if (typeof this.response === "object" && this.response !== null) {
298
- return this.response;
828
+ getItem(key) {
829
+ if (typeof window === "undefined") return null;
830
+ try {
831
+ return window.localStorage.getItem(key);
832
+ } catch {
833
+ return null;
299
834
  }
300
- return null;
301
835
  }
302
- /**
303
- * Get field-specific validation errors from DRF.
304
- * Returns: { "field_name": ["error1", "error2"], ... }
305
- */
306
- get fieldErrors() {
307
- const details = this.details;
308
- if (!details) return null;
309
- const fieldErrors = {};
310
- for (const [key, value] of Object.entries(details)) {
311
- if (Array.isArray(value)) {
312
- fieldErrors[key] = value;
313
- }
836
+ setItem(key, value) {
837
+ if (typeof window === "undefined") return;
838
+ try {
839
+ window.localStorage.setItem(key, value);
840
+ } catch {
314
841
  }
315
- return Object.keys(fieldErrors).length > 0 ? fieldErrors : null;
316
842
  }
317
- /**
318
- * Get single error message from DRF.
319
- * Checks for "detail", "message", or first field error.
320
- */
321
- get errorMessage() {
322
- const details = this.details;
323
- if (!details) return this.message;
324
- if (details.detail) {
325
- return Array.isArray(details.detail) ? details.detail.join(", ") : String(details.detail);
326
- }
327
- if (details.error) {
328
- return String(details.error);
329
- }
330
- if (details.message) {
331
- return String(details.message);
332
- }
333
- const fieldErrors = this.fieldErrors;
334
- if (fieldErrors) {
335
- const firstField = Object.keys(fieldErrors)[0];
336
- if (firstField) {
337
- return `${firstField}: ${fieldErrors[firstField]?.join(", ")}`;
338
- }
843
+ removeItem(key) {
844
+ if (typeof window === "undefined") return;
845
+ try {
846
+ window.localStorage.removeItem(key);
847
+ } catch {
339
848
  }
340
- return this.message;
341
- }
342
- // Helper methods for common HTTP status codes
343
- get isValidationError() {
344
- return this.statusCode === 400;
345
- }
346
- get isAuthError() {
347
- return this.statusCode === 401;
348
- }
349
- get isPermissionError() {
350
- return this.statusCode === 403;
351
- }
352
- get isNotFoundError() {
353
- return this.statusCode === 404;
354
849
  }
355
- get isServerError() {
356
- return this.statusCode >= 500 && this.statusCode < 600;
357
- }
358
- };
359
- var NetworkError = class extends Error {
360
- constructor(message, url, originalError) {
361
- super(message);
362
- this.url = url;
363
- this.originalError = originalError;
364
- this.name = "NetworkError";
365
- }
366
- static {
367
- __name(this, "NetworkError");
850
+ clear() {
851
+ if (typeof window === "undefined") return;
852
+ try {
853
+ window.localStorage.clear();
854
+ } catch {
855
+ }
368
856
  }
369
857
  };
370
858
 
371
- // src/_api/generated/cfg_accounts/logger.ts
859
+ // src/_api/generated/helpers/logger.ts
372
860
  import { createConsola } from "consola";
373
861
  var DEFAULT_CONFIG = {
374
- enabled: process.env.NODE_ENV !== "production",
862
+ enabled: typeof process !== "undefined" && process.env.NODE_ENV !== "production",
375
863
  logRequests: true,
376
864
  logResponses: true,
377
865
  logErrors: true,
@@ -397,688 +885,167 @@ var APILogger = class {
397
885
  level: this.config.enabled ? 4 : 0
398
886
  });
399
887
  }
400
- /**
401
- * Enable logging
402
- */
403
888
  enable() {
404
889
  this.config.enabled = true;
405
890
  }
406
- /**
407
- * Disable logging
408
- */
409
891
  disable() {
410
892
  this.config.enabled = false;
411
893
  }
412
- /**
413
- * Update configuration
414
- */
415
894
  setConfig(config) {
416
895
  this.config = { ...this.config, ...config };
417
896
  }
418
- /**
419
- * Filter sensitive headers
420
- */
421
897
  filterHeaders(headers) {
422
898
  if (!headers) return {};
423
899
  const filtered = {};
424
900
  Object.keys(headers).forEach((key) => {
425
- const lowerKey = key.toLowerCase();
426
- if (SENSITIVE_HEADERS.includes(lowerKey)) {
427
- filtered[key] = "***";
428
- } else {
429
- filtered[key] = headers[key] || "";
430
- }
901
+ filtered[key] = SENSITIVE_HEADERS.includes(key.toLowerCase()) ? "***" : headers[key] || "";
431
902
  });
432
903
  return filtered;
433
904
  }
434
- /**
435
- * Log request
436
- */
437
905
  logRequest(request) {
438
906
  if (!this.config.enabled || !this.config.logRequests) return;
439
907
  const { method, url, headers, body } = request;
440
908
  this.consola.start(`${method} ${url}`);
441
- if (this.config.logHeaders && headers) {
442
- this.consola.debug("Headers:", this.filterHeaders(headers));
443
- }
444
- if (this.config.logBodies && body) {
445
- this.consola.debug("Body:", body);
446
- }
909
+ if (this.config.logHeaders && headers) this.consola.debug("Headers:", this.filterHeaders(headers));
910
+ if (this.config.logBodies && body) this.consola.debug("Body:", body);
447
911
  }
448
- /**
449
- * Log response
450
- */
451
912
  logResponse(request, response) {
452
913
  if (!this.config.enabled || !this.config.logResponses) return;
453
914
  const { method, url } = request;
454
915
  const { status, statusText, data, duration } = response;
455
- const statusColor = status >= 500 ? "red" : status >= 400 ? "yellow" : status >= 300 ? "cyan" : "green";
456
- this.consola.success(
457
- `${method} ${url} ${status} ${statusText} (${duration}ms)`
458
- );
459
- if (this.config.logBodies && data) {
460
- this.consola.debug("Response:", data);
461
- }
916
+ this.consola.success(`${method} ${url} ${status} ${statusText} (${duration}ms)`);
917
+ if (this.config.logBodies && data) this.consola.debug("Response:", data);
462
918
  }
463
- /**
464
- * Log error
465
- */
466
919
  logError(request, error) {
467
920
  if (!this.config.enabled || !this.config.logErrors) return;
468
921
  const { method, url } = request;
469
922
  const { message, statusCode, fieldErrors, duration } = error;
470
- this.consola.error(
471
- `${method} ${url} ${statusCode || "Network"} Error (${duration}ms)`
472
- );
923
+ this.consola.error(`${method} ${url} ${statusCode || "Network"} Error (${duration}ms)`);
473
924
  this.consola.error("Message:", message);
474
925
  if (fieldErrors && Object.keys(fieldErrors).length > 0) {
475
926
  this.consola.error("Field Errors:");
476
927
  Object.entries(fieldErrors).forEach(([field, errors]) => {
477
- errors.forEach((err) => {
478
- this.consola.error(` \u2022 ${field}: ${err}`);
479
- });
928
+ errors.forEach((err) => this.consola.error(` \u2022 ${field}: ${err}`));
480
929
  });
481
930
  }
482
931
  }
483
- /**
484
- * Log general info
485
- */
486
932
  info(message, ...args) {
487
- if (!this.config.enabled) return;
488
- this.consola.info(message, ...args);
933
+ if (this.config.enabled) this.consola.info(message, ...args);
489
934
  }
490
- /**
491
- * Log warning
492
- */
493
935
  warn(message, ...args) {
494
- if (!this.config.enabled) return;
495
- this.consola.warn(message, ...args);
936
+ if (this.config.enabled) this.consola.warn(message, ...args);
496
937
  }
497
- /**
498
- * Log error
499
- */
500
938
  error(message, ...args) {
501
- if (!this.config.enabled) return;
502
- this.consola.error(message, ...args);
939
+ if (this.config.enabled) this.consola.error(message, ...args);
503
940
  }
504
- /**
505
- * Log debug
506
- */
507
941
  debug(message, ...args) {
508
- if (!this.config.enabled) return;
509
- this.consola.debug(message, ...args);
942
+ if (this.config.enabled) this.consola.debug(message, ...args);
510
943
  }
511
- /**
512
- * Log success
513
- */
514
944
  success(message, ...args) {
515
- if (!this.config.enabled) return;
516
- this.consola.success(message, ...args);
945
+ if (this.config.enabled) this.consola.success(message, ...args);
517
946
  }
518
- /**
519
- * Create a sub-logger with prefix
520
- */
521
947
  withTag(tag) {
522
948
  return this.consola.withTag(tag);
523
949
  }
524
950
  };
525
951
  var defaultLogger = new APILogger();
526
952
 
527
- // src/_api/generated/cfg_accounts/retry.ts
528
- import pRetry, { AbortError } from "p-retry";
529
- var DEFAULT_RETRY_CONFIG = {
530
- retries: 3,
531
- factor: 2,
532
- minTimeout: 1e3,
533
- maxTimeout: 6e4,
534
- randomize: true,
535
- onFailedAttempt: /* @__PURE__ */ __name(() => {
536
- }, "onFailedAttempt")
537
- };
538
- function shouldRetry(error) {
539
- if (error instanceof NetworkError) {
540
- return true;
541
- }
542
- if (error instanceof APIError) {
543
- const status = error.statusCode;
544
- if (status >= 500 && status < 600) {
545
- return true;
953
+ // src/_api/generated/_cfg_accounts/api.ts
954
+ var ACCESS_KEY = "cfg.access_token";
955
+ var REFRESH_KEY = "cfg.refresh_token";
956
+ function detectLocale() {
957
+ try {
958
+ if (typeof document !== "undefined") {
959
+ const m = document.cookie.match(/(?:^|;\s*)NEXT_LOCALE=([^;]*)/);
960
+ if (m) return decodeURIComponent(m[1]);
546
961
  }
547
- if (status === 429) {
548
- return true;
962
+ if (typeof navigator !== "undefined" && navigator.language) {
963
+ return navigator.language;
549
964
  }
550
- return false;
965
+ } catch {
551
966
  }
552
- return true;
553
- }
554
- __name(shouldRetry, "shouldRetry");
555
- async function withRetry(fn, config) {
556
- const finalConfig = { ...DEFAULT_RETRY_CONFIG, ...config };
557
- return pRetry(
558
- async () => {
559
- try {
560
- return await fn();
561
- } catch (error) {
562
- if (!shouldRetry(error)) {
563
- throw new AbortError(error);
564
- }
565
- throw error;
566
- }
567
- },
568
- {
569
- retries: finalConfig.retries,
570
- factor: finalConfig.factor,
571
- minTimeout: finalConfig.minTimeout,
572
- maxTimeout: finalConfig.maxTimeout,
573
- randomize: finalConfig.randomize,
574
- onFailedAttempt: finalConfig.onFailedAttempt ? (error) => {
575
- const pRetryError = error;
576
- finalConfig.onFailedAttempt({
577
- error: pRetryError,
578
- attemptNumber: pRetryError.attemptNumber,
579
- retriesLeft: pRetryError.retriesLeft
580
- });
581
- } : void 0
582
- }
583
- );
967
+ return null;
584
968
  }
585
- __name(withRetry, "withRetry");
586
-
587
- // src/_api/generated/cfg_accounts/client.ts
588
- var APIClient = class {
969
+ __name(detectLocale, "detectLocale");
970
+ var API = class {
589
971
  static {
590
- __name(this, "APIClient");
972
+ __name(this, "API");
591
973
  }
592
974
  baseUrl;
593
- httpClient;
594
- logger = null;
595
- retryConfig = null;
596
- tokenGetter = null;
597
- // Sub-clients
598
- auth;
599
- oauth;
600
- user_profile;
601
- accounts;
602
- constructor(baseUrl, options) {
603
- this.baseUrl = baseUrl.replace(/\/$/, "");
604
- this.httpClient = options?.httpClient || new FetchAdapter();
605
- this.tokenGetter = options?.tokenGetter || null;
606
- if (options?.loggerConfig !== void 0) {
607
- this.logger = new APILogger(options.loggerConfig);
608
- }
609
- if (options?.retryConfig !== void 0) {
610
- this.retryConfig = options.retryConfig;
611
- }
612
- this.auth = new Auth(this);
613
- this.oauth = new Oauth(this);
614
- this.user_profile = new UserProfile(this);
615
- this.accounts = new Accounts(this);
975
+ storage;
976
+ locale;
977
+ apiKey;
978
+ logger;
979
+ constructor(baseUrl2, opts = {}) {
980
+ this.baseUrl = baseUrl2.replace(/\/$/, "");
981
+ this.storage = opts.storage ?? new LocalStorageAdapter();
982
+ this.logger = new APILogger(opts.logger);
983
+ this.locale = opts.locale ?? null;
984
+ this.apiKey = opts.apiKey ?? (typeof process !== "undefined" ? process.env?.NEXT_PUBLIC_API_KEY ?? null : null);
985
+ const credentials = opts.withCredentials ?? true ? "include" : "same-origin";
986
+ client.setConfig({ baseUrl: this.baseUrl, credentials });
987
+ client.interceptors.request.use((request) => {
988
+ const access = this.getToken();
989
+ if (access) request.headers.set("Authorization", `Bearer ${access}`);
990
+ const locale = this.locale ?? detectLocale();
991
+ if (locale) request.headers.set("Accept-Language", locale);
992
+ if (this.apiKey) request.headers.set("X-API-Key", this.apiKey);
993
+ return request;
994
+ });
616
995
  }
617
- /**
618
- * Get CSRF token from cookies (for SessionAuthentication).
619
- *
620
- * Returns null if cookie doesn't exist (JWT-only auth).
621
- */
622
- getCsrfToken() {
623
- const name = "csrftoken";
624
- const value = `; ${document.cookie}`;
625
- const parts = value.split(`; ${name}=`);
626
- if (parts.length === 2) {
627
- return parts.pop()?.split(";").shift() || null;
628
- }
629
- return null;
996
+ // ── Base URL ────────────────────────────────────────────────────────────
997
+ getBaseUrl() {
998
+ return this.baseUrl;
630
999
  }
631
- /**
632
- * Get the base URL for building streaming/download URLs.
633
- */
634
- getBaseUrl() {
635
- return this.baseUrl;
1000
+ setBaseUrl(url) {
1001
+ this.baseUrl = url.replace(/\/$/, "");
1002
+ client.setConfig({ baseUrl: this.baseUrl });
636
1003
  }
637
- /**
638
- * Get JWT token for URL authentication (used in streaming endpoints).
639
- * Returns null if no token getter is configured or no token is available.
640
- */
1004
+ // ── Tokens ──────────────────────────────────────────────────────────────
641
1005
  getToken() {
642
- return this.tokenGetter ? this.tokenGetter() : null;
1006
+ return this.storage.getItem(ACCESS_KEY);
643
1007
  }
644
- /**
645
- * Make HTTP request with Django CSRF and session handling.
646
- * Automatically retries on network errors and 5xx server errors.
647
- */
648
- async request(method, path, options) {
649
- if (this.retryConfig) {
650
- return withRetry(() => this._makeRequest(method, path, options), {
651
- ...this.retryConfig,
652
- onFailedAttempt: /* @__PURE__ */ __name((info) => {
653
- if (this.logger) {
654
- this.logger.warn(
655
- `Retry attempt ${info.attemptNumber}/${info.retriesLeft + info.attemptNumber} for ${method} ${path}: ${info.error.message}`
656
- );
657
- }
658
- this.retryConfig?.onFailedAttempt?.(info);
659
- }, "onFailedAttempt")
660
- });
661
- }
662
- return this._makeRequest(method, path, options);
1008
+ setToken(token) {
1009
+ if (token) this.storage.setItem(ACCESS_KEY, token);
1010
+ else this.storage.removeItem(ACCESS_KEY);
663
1011
  }
664
- /**
665
- * Internal request method (without retry wrapper).
666
- * Used by request() method with optional retry logic.
667
- */
668
- async _makeRequest(method, path, options) {
669
- const url = this.baseUrl ? `${this.baseUrl}${path}` : path;
670
- const startTime = Date.now();
671
- const headers = {
672
- ...options?.headers || {}
673
- };
674
- if (!options?.formData && !options?.binaryBody && !headers["Content-Type"]) {
675
- headers["Content-Type"] = "application/json";
676
- }
677
- if (!headers["Authorization"]) {
678
- const token = this.getToken();
679
- if (token) {
680
- headers["Authorization"] = `Bearer ${token}`;
681
- }
682
- }
683
- if (this.logger) {
684
- this.logger.logRequest({
685
- method,
686
- url,
687
- headers,
688
- body: options?.formData || options?.body,
689
- timestamp: startTime
690
- });
691
- }
692
- try {
693
- const response = await this.httpClient.request({
694
- method,
695
- url,
696
- headers,
697
- params: options?.params,
698
- body: options?.body,
699
- formData: options?.formData,
700
- binaryBody: options?.binaryBody,
701
- responseType: options?.responseType
702
- });
703
- const duration = Date.now() - startTime;
704
- if (response.status >= 400) {
705
- const error = new APIError(
706
- response.status,
707
- response.statusText,
708
- response.data,
709
- url
710
- );
711
- if (this.logger) {
712
- this.logger.logError(
713
- {
714
- method,
715
- url,
716
- headers,
717
- body: options?.formData || options?.body,
718
- timestamp: startTime
719
- },
720
- {
721
- message: error.message,
722
- statusCode: response.status,
723
- duration,
724
- timestamp: Date.now()
725
- }
726
- );
727
- }
728
- throw error;
729
- }
730
- if (this.logger) {
731
- this.logger.logResponse(
732
- {
733
- method,
734
- url,
735
- headers,
736
- body: options?.formData || options?.body,
737
- timestamp: startTime
738
- },
739
- {
740
- status: response.status,
741
- statusText: response.statusText,
742
- data: response.data,
743
- duration,
744
- timestamp: Date.now()
745
- }
746
- );
747
- }
748
- return response.data;
749
- } catch (error) {
750
- const duration = Date.now() - startTime;
751
- if (error instanceof APIError) {
752
- throw error;
753
- }
754
- let possiblyCors = false;
755
- if (error instanceof TypeError && typeof window !== "undefined") {
756
- try {
757
- const isCrossOrigin = (() => {
758
- try {
759
- return new URL(url).origin !== window.location.origin;
760
- } catch {
761
- return false;
762
- }
763
- })();
764
- if (isCrossOrigin) {
765
- const entries = performance.getEntriesByName(url, "resource");
766
- if (entries.length > 0) {
767
- const last = entries[entries.length - 1];
768
- possiblyCors = "responseStatus" in last && last.responseStatus === 0;
769
- }
770
- }
771
- } catch {
772
- }
773
- }
774
- if (this.logger) {
775
- this.logger.error(`\u26A0\uFE0F Network Error: ${method} ${url}`);
776
- this.logger.error(` \u2192 ${error instanceof Error ? error.message : String(error)}`);
777
- if (possiblyCors) {
778
- this.logger.error(` \u2192 Possibly blocked by CORS policy (configure CORS on the server)`);
779
- }
780
- }
781
- if (typeof window !== "undefined") {
782
- try {
783
- window.dispatchEvent(new CustomEvent("network-error", {
784
- detail: {
785
- url,
786
- method,
787
- error: error instanceof Error ? error.message : String(error),
788
- possibly_cors: possiblyCors,
789
- timestamp: /* @__PURE__ */ new Date()
790
- },
791
- bubbles: true,
792
- cancelable: false
793
- }));
794
- } catch {
795
- }
796
- }
797
- const networkError = error instanceof Error ? new NetworkError(error.message, url, error) : new NetworkError("Unknown error", url);
798
- if (this.logger) {
799
- this.logger.logError(
800
- {
801
- method,
802
- url,
803
- headers,
804
- body: options?.formData || options?.body,
805
- timestamp: startTime
806
- },
807
- {
808
- message: networkError.message,
809
- duration,
810
- timestamp: Date.now()
811
- }
812
- );
813
- }
814
- throw networkError;
815
- }
1012
+ getRefreshToken() {
1013
+ return this.storage.getItem(REFRESH_KEY);
816
1014
  }
817
- };
818
-
819
- // src/_api/generated/cfg_accounts/storage.ts
820
- var LocalStorageAdapter = class {
821
- static {
822
- __name(this, "LocalStorageAdapter");
1015
+ setRefreshToken(token) {
1016
+ if (token) this.storage.setItem(REFRESH_KEY, token);
1017
+ else this.storage.removeItem(REFRESH_KEY);
823
1018
  }
824
- logger;
825
- constructor(logger2) {
826
- this.logger = logger2;
1019
+ clearToken() {
1020
+ this.storage.removeItem(ACCESS_KEY);
1021
+ this.storage.removeItem(REFRESH_KEY);
827
1022
  }
828
- getItem(key) {
829
- try {
830
- if (typeof window !== "undefined" && window.localStorage) {
831
- const value = localStorage.getItem(key);
832
- this.logger?.debug(`LocalStorage.getItem("${key}"): ${value ? "found" : "not found"}`);
833
- return value;
834
- }
835
- this.logger?.warn("LocalStorage not available: window.localStorage is undefined");
836
- } catch (error) {
837
- this.logger?.error("LocalStorage.getItem failed:", error);
838
- }
839
- return null;
1023
+ isAuthenticated() {
1024
+ return this.getToken() !== null;
840
1025
  }
841
- setItem(key, value) {
842
- try {
843
- if (typeof window !== "undefined" && window.localStorage) {
844
- localStorage.setItem(key, value);
845
- this.logger?.debug(`LocalStorage.setItem("${key}"): success`);
846
- } else {
847
- this.logger?.warn("LocalStorage not available: window.localStorage is undefined");
848
- }
849
- } catch (error) {
850
- this.logger?.error("LocalStorage.setItem failed:", error);
851
- }
1026
+ // ── Locale / API key ────────────────────────────────────────────────────
1027
+ getLocale() {
1028
+ return this.locale ?? detectLocale();
852
1029
  }
853
- removeItem(key) {
854
- try {
855
- if (typeof window !== "undefined" && window.localStorage) {
856
- localStorage.removeItem(key);
857
- this.logger?.debug(`LocalStorage.removeItem("${key}"): success`);
858
- } else {
859
- this.logger?.warn("LocalStorage not available: window.localStorage is undefined");
860
- }
861
- } catch (error) {
862
- this.logger?.error("LocalStorage.removeItem failed:", error);
863
- }
1030
+ setLocale(locale) {
1031
+ this.locale = locale;
1032
+ }
1033
+ getApiKey() {
1034
+ return this.apiKey;
1035
+ }
1036
+ setApiKey(key) {
1037
+ this.apiKey = key;
864
1038
  }
865
1039
  };
866
1040
 
867
- // src/_api/generated/cfg_accounts/enums.ts
868
- var OAuthConnectionProvider = /* @__PURE__ */ ((OAuthConnectionProvider2) => {
869
- OAuthConnectionProvider2["GITHUB"] = "github";
870
- return OAuthConnectionProvider2;
871
- })(OAuthConnectionProvider || {});
872
-
873
- // src/_api/generated/cfg_accounts/_utils/schemas/AccountDeleteResponse.schema.ts
874
- import { z } from "zod";
875
- var AccountDeleteResponseSchema = z.object({
876
- success: z.boolean(),
877
- message: z.string()
878
- });
879
-
880
- // src/_api/generated/cfg_accounts/_utils/schemas/CentrifugoToken.schema.ts
881
- import { z as z2 } from "zod";
882
- var CentrifugoTokenSchema = z2.object({
883
- token: z2.string(),
884
- centrifugo_url: z2.string(),
885
- expires_at: z2.string().datetime({ offset: true }),
886
- channels: z2.array(z2.string())
887
- });
888
-
889
- // src/_api/generated/cfg_accounts/_utils/schemas/CfgAccountsProfileAvatarCreateRequest.schema.ts
890
- import { z as z3 } from "zod";
891
- var CfgAccountsProfileAvatarCreateRequestSchema = z3.object({
892
- avatar: z3.union([z3.instanceof(File), z3.instanceof(Blob)])
893
- });
894
-
895
- // src/_api/generated/cfg_accounts/_utils/schemas/OAuthAuthorizeRequestRequest.schema.ts
896
- import { z as z4 } from "zod";
897
- var OAuthAuthorizeRequestRequestSchema = z4.object({
898
- redirect_uri: z4.string().optional(),
899
- source_url: z4.string().optional()
900
- });
901
-
902
- // src/_api/generated/cfg_accounts/_utils/schemas/OAuthAuthorizeResponse.schema.ts
903
- import { z as z5 } from "zod";
904
- var OAuthAuthorizeResponseSchema = z5.object({
905
- authorization_url: z5.string(),
906
- state: z5.string()
907
- });
908
-
909
- // src/_api/generated/cfg_accounts/_utils/schemas/OAuthCallbackRequestRequest.schema.ts
910
- import { z as z6 } from "zod";
911
- var OAuthCallbackRequestRequestSchema = z6.object({
912
- code: z6.string().min(10).max(500),
913
- state: z6.string().min(20).max(100),
914
- redirect_uri: z6.string().optional()
915
- });
916
-
917
- // src/_api/generated/cfg_accounts/_utils/schemas/OAuthConnection.schema.ts
918
- import { z as z7 } from "zod";
919
- var OAuthConnectionSchema = z7.object({
920
- id: z7.number().int(),
921
- provider: z7.nativeEnum(OAuthConnectionProvider),
922
- provider_display: z7.string(),
923
- provider_username: z7.string(),
924
- provider_email: z7.email(),
925
- provider_avatar_url: z7.string(),
926
- connected_at: z7.string().datetime({ offset: true }),
927
- last_login_at: z7.string().datetime({ offset: true })
928
- });
929
-
930
- // src/_api/generated/cfg_accounts/_utils/schemas/OAuthDisconnectRequestRequest.schema.ts
931
- import { z as z8 } from "zod";
932
- var OAuthDisconnectRequestRequestSchema = z8.object({
933
- provider: z8.nativeEnum(OAuthConnectionProvider)
934
- });
935
-
936
- // src/_api/generated/cfg_accounts/_utils/schemas/OAuthError.schema.ts
937
- import { z as z9 } from "zod";
938
- var OAuthErrorSchema = z9.object({
939
- error: z9.string(),
940
- error_description: z9.string().optional()
941
- });
942
-
943
- // src/_api/generated/cfg_accounts/_utils/schemas/OAuthProvidersResponse.schema.ts
944
- import { z as z10 } from "zod";
945
- var OAuthProvidersResponseSchema = z10.object({
946
- providers: z10.array(z10.record(z10.string(), z10.any()))
947
- });
948
-
949
- // src/_api/generated/cfg_accounts/_utils/schemas/OAuthTokenResponse.schema.ts
950
- import { z as z11 } from "zod";
951
- var OAuthTokenResponseSchema = z11.object({
952
- requires_2fa: z11.boolean().optional(),
953
- session_id: z11.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i).nullable().optional(),
954
- access: z11.string().nullable().optional(),
955
- refresh: z11.string().nullable().optional(),
956
- user: z11.record(z11.string(), z11.any()).nullable().optional(),
957
- is_new_user: z11.boolean(),
958
- is_new_connection: z11.boolean(),
959
- should_prompt_2fa: z11.boolean().optional()
960
- });
961
-
962
- // src/_api/generated/cfg_accounts/_utils/schemas/OTPErrorResponse.schema.ts
963
- import { z as z12 } from "zod";
964
- var OTPErrorResponseSchema = z12.object({
965
- error: z12.string(),
966
- error_code: z12.string().nullable().optional(),
967
- retry_after: z12.number().int().nullable().optional()
968
- });
969
-
970
- // src/_api/generated/cfg_accounts/_utils/schemas/OTPRequestRequest.schema.ts
971
- import { z as z13 } from "zod";
972
- var OTPRequestRequestSchema = z13.object({
973
- identifier: z13.string().min(1),
974
- source_url: z13.string().optional()
975
- });
976
-
977
- // src/_api/generated/cfg_accounts/_utils/schemas/OTPRequestResponse.schema.ts
978
- import { z as z14 } from "zod";
979
- var OTPRequestResponseSchema = z14.object({
980
- message: z14.string()
981
- });
982
-
983
- // src/_api/generated/cfg_accounts/_utils/schemas/OTPVerifyRequest.schema.ts
984
- import { z as z15 } from "zod";
985
- var OTPVerifyRequestSchema = z15.object({
986
- identifier: z15.string().min(1),
987
- otp: z15.string().min(6).max(6),
988
- source_url: z15.string().optional()
989
- });
990
-
991
- // src/_api/generated/cfg_accounts/_utils/schemas/OTPVerifyResponse.schema.ts
992
- import { z as z17 } from "zod";
993
-
994
- // src/_api/generated/cfg_accounts/_utils/schemas/User.schema.ts
995
- import { z as z16 } from "zod";
996
- var UserSchema = z16.object({
997
- id: z16.number().int(),
998
- email: z16.email(),
999
- first_name: z16.string().max(50).optional(),
1000
- last_name: z16.string().max(50).optional(),
1001
- full_name: z16.string(),
1002
- initials: z16.string(),
1003
- display_username: z16.string(),
1004
- company: z16.string().max(100).optional(),
1005
- phone: z16.string().max(20).optional(),
1006
- position: z16.string().max(100).optional(),
1007
- language: z16.string().max(10).optional(),
1008
- avatar: z16.string().nullable(),
1009
- is_staff: z16.boolean(),
1010
- is_superuser: z16.boolean(),
1011
- date_joined: z16.string().datetime({ offset: true }),
1012
- last_login: z16.string().datetime({ offset: true }).nullable(),
1013
- unanswered_messages_count: z16.number().int(),
1014
- centrifugo: CentrifugoTokenSchema.nullable()
1015
- });
1016
-
1017
- // src/_api/generated/cfg_accounts/_utils/schemas/OTPVerifyResponse.schema.ts
1018
- var OTPVerifyResponseSchema = z17.object({
1019
- requires_2fa: z17.boolean().optional(),
1020
- session_id: z17.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i).nullable().optional(),
1021
- refresh: z17.string().nullable().optional(),
1022
- access: z17.string().nullable().optional(),
1023
- user: UserSchema.nullable().optional(),
1024
- should_prompt_2fa: z17.boolean().optional()
1025
- });
1026
-
1027
- // src/_api/generated/cfg_accounts/_utils/schemas/PatchedUserProfileUpdateRequest.schema.ts
1028
- import { z as z18 } from "zod";
1029
- var PatchedUserProfileUpdateRequestSchema = z18.object({
1030
- first_name: z18.string().max(50).optional(),
1031
- last_name: z18.string().max(50).optional(),
1032
- company: z18.string().max(100).optional(),
1033
- phone: z18.string().max(20).optional(),
1034
- position: z18.string().max(100).optional(),
1035
- language: z18.string().max(10).optional()
1036
- });
1037
-
1038
- // src/_api/generated/cfg_accounts/_utils/schemas/TokenRefresh.schema.ts
1039
- import { z as z19 } from "zod";
1040
- var TokenRefreshSchema = z19.object({
1041
- access: z19.string(),
1042
- refresh: z19.string()
1043
- });
1044
-
1045
- // src/_api/generated/cfg_accounts/_utils/schemas/TokenRefreshRequest.schema.ts
1046
- import { z as z20 } from "zod";
1047
- var TokenRefreshRequestSchema = z20.object({
1048
- refresh: z20.string().min(1)
1049
- });
1050
-
1051
- // src/_api/generated/cfg_accounts/_utils/schemas/UserProfileUpdateRequest.schema.ts
1052
- import { z as z21 } from "zod";
1053
- var UserProfileUpdateRequestSchema = z21.object({
1054
- first_name: z21.string().max(50).optional(),
1055
- last_name: z21.string().max(50).optional(),
1056
- company: z21.string().max(100).optional(),
1057
- phone: z21.string().max(20).optional(),
1058
- position: z21.string().max(100).optional(),
1059
- language: z21.string().max(10).optional()
1060
- });
1061
-
1062
- // src/_api/generated/cfg_accounts/_utils/fetchers/accounts.ts
1063
- import { consola } from "consola";
1064
-
1065
- // src/_api/generated/cfg_accounts/_utils/fetchers/accounts__auth.ts
1066
- import { consola as consola2 } from "consola";
1067
-
1068
- // src/_api/generated/cfg_accounts/_utils/fetchers/accounts__oauth.ts
1069
- import { consola as consola3 } from "consola";
1070
-
1071
- // src/_api/generated/cfg_accounts/_utils/fetchers/accounts__user_profile.ts
1072
- import { consola as consola4 } from "consola";
1073
-
1074
- // src/_api/generated/cfg_accounts/index.ts
1075
- var TOKEN_KEY = "auth_token";
1076
- var REFRESH_TOKEN_KEY = "refresh_token";
1077
- function detectLocale() {
1041
+ // src/_api/generated/_cfg_centrifugo/api.ts
1042
+ var ACCESS_KEY2 = "cfg.access_token";
1043
+ var REFRESH_KEY2 = "cfg.refresh_token";
1044
+ function detectLocale2() {
1078
1045
  try {
1079
1046
  if (typeof document !== "undefined") {
1080
- const match = document.cookie.match(/(?:^|;\s*)NEXT_LOCALE=([^;]*)/);
1081
- if (match) return match[1];
1047
+ const m = document.cookie.match(/(?:^|;\s*)NEXT_LOCALE=([^;]*)/);
1048
+ if (m) return decodeURIComponent(m[1]);
1082
1049
  }
1083
1050
  if (typeof navigator !== "undefined" && navigator.language) {
1084
1051
  return navigator.language;
@@ -1087,344 +1054,195 @@ function detectLocale() {
1087
1054
  }
1088
1055
  return null;
1089
1056
  }
1090
- __name(detectLocale, "detectLocale");
1091
- var API = class {
1057
+ __name(detectLocale2, "detectLocale");
1058
+ var API2 = class {
1092
1059
  static {
1093
1060
  __name(this, "API");
1094
1061
  }
1095
1062
  baseUrl;
1096
- _client;
1097
- _token = null;
1098
- _refreshToken = null;
1099
- _locale = null;
1100
1063
  storage;
1101
- options;
1102
- // Sub-clients
1103
- auth;
1104
- oauth;
1105
- user_profile;
1106
- accounts;
1107
- constructor(baseUrl, options) {
1108
- this.baseUrl = baseUrl;
1109
- this.options = options;
1110
- const logger2 = options?.loggerConfig ? new APILogger(options.loggerConfig) : void 0;
1111
- this.storage = options?.storage || new LocalStorageAdapter(logger2);
1112
- this._locale = options?.locale || null;
1113
- this._loadTokensFromStorage();
1114
- this._client = new APIClient(this.baseUrl, {
1115
- httpClient: this.options?.httpClient,
1116
- retryConfig: this.options?.retryConfig,
1117
- loggerConfig: this.options?.loggerConfig,
1118
- tokenGetter: /* @__PURE__ */ __name(() => this.getToken(), "tokenGetter")
1119
- });
1120
- this._injectAuthHeader();
1121
- this.auth = this._client.auth;
1122
- this.oauth = this._client.oauth;
1123
- this.user_profile = this._client.user_profile;
1124
- this.accounts = this._client.accounts;
1125
- }
1126
- _loadTokensFromStorage() {
1127
- this._token = this.storage.getItem(TOKEN_KEY);
1128
- this._refreshToken = this.storage.getItem(REFRESH_TOKEN_KEY);
1129
- }
1130
- _reinitClients() {
1131
- this._client = new APIClient(this.baseUrl, {
1132
- httpClient: this.options?.httpClient,
1133
- retryConfig: this.options?.retryConfig,
1134
- loggerConfig: this.options?.loggerConfig,
1135
- tokenGetter: /* @__PURE__ */ __name(() => this.getToken(), "tokenGetter")
1064
+ locale;
1065
+ apiKey;
1066
+ logger;
1067
+ constructor(baseUrl2, opts = {}) {
1068
+ this.baseUrl = baseUrl2.replace(/\/$/, "");
1069
+ this.storage = opts.storage ?? new LocalStorageAdapter();
1070
+ this.logger = new APILogger(opts.logger);
1071
+ this.locale = opts.locale ?? null;
1072
+ this.apiKey = opts.apiKey ?? (typeof process !== "undefined" ? process.env?.NEXT_PUBLIC_API_KEY ?? null : null);
1073
+ const credentials = opts.withCredentials ?? true ? "include" : "same-origin";
1074
+ client.setConfig({ baseUrl: this.baseUrl, credentials });
1075
+ client.interceptors.request.use((request) => {
1076
+ const access = this.getToken();
1077
+ if (access) request.headers.set("Authorization", `Bearer ${access}`);
1078
+ const locale = this.locale ?? detectLocale2();
1079
+ if (locale) request.headers.set("Accept-Language", locale);
1080
+ if (this.apiKey) request.headers.set("X-API-Key", this.apiKey);
1081
+ return request;
1136
1082
  });
1137
- this._injectAuthHeader();
1138
- this.auth = this._client.auth;
1139
- this.oauth = this._client.oauth;
1140
- this.user_profile = this._client.user_profile;
1141
- this.accounts = this._client.accounts;
1142
- }
1143
- _injectAuthHeader() {
1144
- const originalRequest = this._client.request.bind(this._client);
1145
- this._client.request = async (method, path, options) => {
1146
- const token = this.getToken();
1147
- const locale = this._locale || detectLocale();
1148
- const mergedOptions = {
1149
- ...options,
1150
- headers: {
1151
- ...options?.headers || {},
1152
- ...token ? { "Authorization": `Bearer ${token}` } : {},
1153
- ...locale ? { "Accept-Language": locale } : {}
1154
- }
1155
- };
1156
- return originalRequest(method, path, mergedOptions);
1157
- };
1158
1083
  }
1159
- /**
1160
- * Get current JWT token
1161
- */
1084
+ // ── Base URL ────────────────────────────────────────────────────────────
1085
+ getBaseUrl() {
1086
+ return this.baseUrl;
1087
+ }
1088
+ setBaseUrl(url) {
1089
+ this.baseUrl = url.replace(/\/$/, "");
1090
+ client.setConfig({ baseUrl: this.baseUrl });
1091
+ }
1092
+ // ── Tokens ──────────────────────────────────────────────────────────────
1162
1093
  getToken() {
1163
- return this.storage.getItem(TOKEN_KEY);
1094
+ return this.storage.getItem(ACCESS_KEY2);
1095
+ }
1096
+ setToken(token) {
1097
+ if (token) this.storage.setItem(ACCESS_KEY2, token);
1098
+ else this.storage.removeItem(ACCESS_KEY2);
1164
1099
  }
1165
- /**
1166
- * Get current refresh token
1167
- */
1168
1100
  getRefreshToken() {
1169
- return this.storage.getItem(REFRESH_TOKEN_KEY);
1101
+ return this.storage.getItem(REFRESH_KEY2);
1170
1102
  }
1171
- /**
1172
- * Set JWT token and refresh token
1173
- * @param token - JWT access token
1174
- * @param refreshToken - JWT refresh token (optional)
1175
- */
1176
- setToken(token, refreshToken) {
1177
- this._token = token;
1178
- this.storage.setItem(TOKEN_KEY, token);
1179
- if (refreshToken) {
1180
- this._refreshToken = refreshToken;
1181
- this.storage.setItem(REFRESH_TOKEN_KEY, refreshToken);
1182
- }
1183
- this._reinitClients();
1103
+ setRefreshToken(token) {
1104
+ if (token) this.storage.setItem(REFRESH_KEY2, token);
1105
+ else this.storage.removeItem(REFRESH_KEY2);
1184
1106
  }
1185
- /**
1186
- * Clear all tokens
1187
- */
1188
- clearTokens() {
1189
- this._token = null;
1190
- this._refreshToken = null;
1191
- this.storage.removeItem(TOKEN_KEY);
1192
- this.storage.removeItem(REFRESH_TOKEN_KEY);
1193
- this._reinitClients();
1107
+ clearToken() {
1108
+ this.storage.removeItem(ACCESS_KEY2);
1109
+ this.storage.removeItem(REFRESH_KEY2);
1194
1110
  }
1195
- /**
1196
- * Check if user is authenticated
1197
- */
1198
1111
  isAuthenticated() {
1199
- return !!this.getToken();
1200
- }
1201
- /**
1202
- * Update base URL and reinitialize clients
1203
- * @param url - New base URL
1204
- */
1205
- setBaseUrl(url) {
1206
- this.baseUrl = url;
1207
- this._reinitClients();
1112
+ return this.getToken() !== null;
1208
1113
  }
1209
- /**
1210
- * Get current base URL
1211
- */
1212
- getBaseUrl() {
1213
- return this.baseUrl;
1114
+ // ── Locale / API key ────────────────────────────────────────────────────
1115
+ getLocale() {
1116
+ return this.locale ?? detectLocale2();
1214
1117
  }
1215
- /**
1216
- * Set locale for Accept-Language header
1217
- * @param locale - Locale string (e.g. 'en', 'ko', 'ru') or null to clear
1218
- */
1219
1118
  setLocale(locale) {
1220
- this._locale = locale;
1119
+ this.locale = locale;
1221
1120
  }
1222
- /**
1223
- * Get current locale
1224
- */
1225
- getLocale() {
1226
- return this._locale;
1121
+ getApiKey() {
1122
+ return this.apiKey;
1227
1123
  }
1228
- /**
1229
- * Get OpenAPI schema path
1230
- * @returns Path to the OpenAPI schema JSON file
1231
- *
1232
- * Note: The OpenAPI schema is available in the schema.json file.
1233
- * You can load it dynamically using:
1234
- * ```typescript
1235
- * const schema = await fetch('./schema.json').then(r => r.json());
1236
- * // or using fs in Node.js:
1237
- * // const schema = JSON.parse(fs.readFileSync('./schema.json', 'utf-8'));
1238
- * ```
1239
- */
1240
- getSchemaPath() {
1241
- return "./schema.json";
1124
+ setApiKey(key) {
1125
+ this.apiKey = key;
1242
1126
  }
1243
1127
  };
1244
1128
 
1245
- // src/_api/generated/cfg_centrifugo/logger.ts
1246
- import { createConsola as createConsola2 } from "consola";
1247
- var DEFAULT_CONFIG2 = {
1248
- enabled: process.env.NODE_ENV !== "production",
1249
- logRequests: true,
1250
- logResponses: true,
1251
- logErrors: true,
1252
- logBodies: true,
1253
- logHeaders: false
1254
- };
1255
- var SENSITIVE_HEADERS2 = [
1256
- "authorization",
1257
- "cookie",
1258
- "set-cookie",
1259
- "x-api-key",
1260
- "x-csrf-token"
1261
- ];
1262
- var APILogger2 = class {
1129
+ // src/_api/generated/_cfg_totp/api.ts
1130
+ var ACCESS_KEY3 = "cfg.access_token";
1131
+ var REFRESH_KEY3 = "cfg.refresh_token";
1132
+ function detectLocale3() {
1133
+ try {
1134
+ if (typeof document !== "undefined") {
1135
+ const m = document.cookie.match(/(?:^|;\s*)NEXT_LOCALE=([^;]*)/);
1136
+ if (m) return decodeURIComponent(m[1]);
1137
+ }
1138
+ if (typeof navigator !== "undefined" && navigator.language) {
1139
+ return navigator.language;
1140
+ }
1141
+ } catch {
1142
+ }
1143
+ return null;
1144
+ }
1145
+ __name(detectLocale3, "detectLocale");
1146
+ var API3 = class {
1263
1147
  static {
1264
- __name(this, "APILogger");
1148
+ __name(this, "API");
1265
1149
  }
1266
- config;
1267
- consola;
1268
- constructor(config = {}) {
1269
- this.config = { ...DEFAULT_CONFIG2, ...config };
1270
- this.consola = config.consola || createConsola2({
1271
- level: this.config.enabled ? 4 : 0
1150
+ baseUrl;
1151
+ storage;
1152
+ locale;
1153
+ apiKey;
1154
+ logger;
1155
+ constructor(baseUrl2, opts = {}) {
1156
+ this.baseUrl = baseUrl2.replace(/\/$/, "");
1157
+ this.storage = opts.storage ?? new LocalStorageAdapter();
1158
+ this.logger = new APILogger(opts.logger);
1159
+ this.locale = opts.locale ?? null;
1160
+ this.apiKey = opts.apiKey ?? (typeof process !== "undefined" ? process.env?.NEXT_PUBLIC_API_KEY ?? null : null);
1161
+ const credentials = opts.withCredentials ?? true ? "include" : "same-origin";
1162
+ client.setConfig({ baseUrl: this.baseUrl, credentials });
1163
+ client.interceptors.request.use((request) => {
1164
+ const access = this.getToken();
1165
+ if (access) request.headers.set("Authorization", `Bearer ${access}`);
1166
+ const locale = this.locale ?? detectLocale3();
1167
+ if (locale) request.headers.set("Accept-Language", locale);
1168
+ if (this.apiKey) request.headers.set("X-API-Key", this.apiKey);
1169
+ return request;
1272
1170
  });
1273
1171
  }
1274
- /**
1275
- * Enable logging
1276
- */
1277
- enable() {
1278
- this.config.enabled = true;
1279
- }
1280
- /**
1281
- * Disable logging
1282
- */
1283
- disable() {
1284
- this.config.enabled = false;
1172
+ // ── Base URL ────────────────────────────────────────────────────────────
1173
+ getBaseUrl() {
1174
+ return this.baseUrl;
1285
1175
  }
1286
- /**
1287
- * Update configuration
1288
- */
1289
- setConfig(config) {
1290
- this.config = { ...this.config, ...config };
1176
+ setBaseUrl(url) {
1177
+ this.baseUrl = url.replace(/\/$/, "");
1178
+ client.setConfig({ baseUrl: this.baseUrl });
1291
1179
  }
1292
- /**
1293
- * Filter sensitive headers
1294
- */
1295
- filterHeaders(headers) {
1296
- if (!headers) return {};
1297
- const filtered = {};
1298
- Object.keys(headers).forEach((key) => {
1299
- const lowerKey = key.toLowerCase();
1300
- if (SENSITIVE_HEADERS2.includes(lowerKey)) {
1301
- filtered[key] = "***";
1302
- } else {
1303
- filtered[key] = headers[key] || "";
1304
- }
1305
- });
1306
- return filtered;
1180
+ // ── Tokens ──────────────────────────────────────────────────────────────
1181
+ getToken() {
1182
+ return this.storage.getItem(ACCESS_KEY3);
1307
1183
  }
1308
- /**
1309
- * Log request
1310
- */
1311
- logRequest(request) {
1312
- if (!this.config.enabled || !this.config.logRequests) return;
1313
- const { method, url, headers, body } = request;
1314
- this.consola.start(`${method} ${url}`);
1315
- if (this.config.logHeaders && headers) {
1316
- this.consola.debug("Headers:", this.filterHeaders(headers));
1317
- }
1318
- if (this.config.logBodies && body) {
1319
- this.consola.debug("Body:", body);
1320
- }
1184
+ setToken(token) {
1185
+ if (token) this.storage.setItem(ACCESS_KEY3, token);
1186
+ else this.storage.removeItem(ACCESS_KEY3);
1321
1187
  }
1322
- /**
1323
- * Log response
1324
- */
1325
- logResponse(request, response) {
1326
- if (!this.config.enabled || !this.config.logResponses) return;
1327
- const { method, url } = request;
1328
- const { status, statusText, data, duration } = response;
1329
- const statusColor = status >= 500 ? "red" : status >= 400 ? "yellow" : status >= 300 ? "cyan" : "green";
1330
- this.consola.success(
1331
- `${method} ${url} ${status} ${statusText} (${duration}ms)`
1332
- );
1333
- if (this.config.logBodies && data) {
1334
- this.consola.debug("Response:", data);
1335
- }
1188
+ getRefreshToken() {
1189
+ return this.storage.getItem(REFRESH_KEY3);
1336
1190
  }
1337
- /**
1338
- * Log error
1339
- */
1340
- logError(request, error) {
1341
- if (!this.config.enabled || !this.config.logErrors) return;
1342
- const { method, url } = request;
1343
- const { message, statusCode, fieldErrors, duration } = error;
1344
- this.consola.error(
1345
- `${method} ${url} ${statusCode || "Network"} Error (${duration}ms)`
1346
- );
1347
- this.consola.error("Message:", message);
1348
- if (fieldErrors && Object.keys(fieldErrors).length > 0) {
1349
- this.consola.error("Field Errors:");
1350
- Object.entries(fieldErrors).forEach(([field, errors]) => {
1351
- errors.forEach((err) => {
1352
- this.consola.error(` \u2022 ${field}: ${err}`);
1353
- });
1354
- });
1355
- }
1191
+ setRefreshToken(token) {
1192
+ if (token) this.storage.setItem(REFRESH_KEY3, token);
1193
+ else this.storage.removeItem(REFRESH_KEY3);
1356
1194
  }
1357
- /**
1358
- * Log general info
1359
- */
1360
- info(message, ...args) {
1361
- if (!this.config.enabled) return;
1362
- this.consola.info(message, ...args);
1195
+ clearToken() {
1196
+ this.storage.removeItem(ACCESS_KEY3);
1197
+ this.storage.removeItem(REFRESH_KEY3);
1363
1198
  }
1364
- /**
1365
- * Log warning
1366
- */
1367
- warn(message, ...args) {
1368
- if (!this.config.enabled) return;
1369
- this.consola.warn(message, ...args);
1199
+ isAuthenticated() {
1200
+ return this.getToken() !== null;
1370
1201
  }
1371
- /**
1372
- * Log error
1373
- */
1374
- error(message, ...args) {
1375
- if (!this.config.enabled) return;
1376
- this.consola.error(message, ...args);
1202
+ // ── Locale / API key ────────────────────────────────────────────────────
1203
+ getLocale() {
1204
+ return this.locale ?? detectLocale3();
1377
1205
  }
1378
- /**
1379
- * Log debug
1380
- */
1381
- debug(message, ...args) {
1382
- if (!this.config.enabled) return;
1383
- this.consola.debug(message, ...args);
1206
+ setLocale(locale) {
1207
+ this.locale = locale;
1384
1208
  }
1385
- /**
1386
- * Log success
1387
- */
1388
- success(message, ...args) {
1389
- if (!this.config.enabled) return;
1390
- this.consola.success(message, ...args);
1209
+ getApiKey() {
1210
+ return this.apiKey;
1391
1211
  }
1392
- /**
1393
- * Create a sub-logger with prefix
1394
- */
1395
- withTag(tag) {
1396
- return this.consola.withTag(tag);
1212
+ setApiKey(key) {
1213
+ this.apiKey = key;
1397
1214
  }
1398
1215
  };
1399
- var defaultLogger2 = new APILogger2();
1400
-
1401
- // src/_api/generated/cfg_centrifugo/retry.ts
1402
- import pRetry2, { AbortError as AbortError2 } from "p-retry";
1403
-
1404
- // src/_api/generated/cfg_centrifugo/_utils/schemas/ConnectionTokenResponse.schema.ts
1405
- import { z as z22 } from "zod";
1406
- var ConnectionTokenResponseSchema = z22.object({
1407
- token: z22.string(),
1408
- centrifugo_url: z22.string(),
1409
- expires_at: z22.string(),
1410
- channels: z22.array(z22.string())
1411
- });
1412
1216
 
1413
- // src/_api/generated/cfg_centrifugo/_utils/fetchers/centrifugo__centrifugo_auth.ts
1414
- import { consola as consola5 } from "consola";
1415
-
1416
- // src/index.ts
1217
+ // src/_api/generated/index.ts
1417
1218
  var isStaticBuild = process.env.NEXT_PUBLIC_STATIC_BUILD === "true";
1418
- var apiUrl = isStaticBuild ? "" : process.env.NEXT_PUBLIC_API_URL || "";
1419
- var api = new API(
1420
- apiUrl,
1421
- {
1422
- storage: new LocalStorageAdapter()
1219
+ var baseUrl = isStaticBuild ? "" : process.env.NEXT_PUBLIC_API_URL || "";
1220
+ var CfgAccountsApi = new API(baseUrl, { storage: new LocalStorageAdapter() });
1221
+ var CfgCentrifugoApi = new API2(baseUrl, { storage: new LocalStorageAdapter() });
1222
+ var CfgTotpApi = new API3(baseUrl, { storage: new LocalStorageAdapter() });
1223
+
1224
+ // src/_api/generated/sdk.gen.ts
1225
+ var Auth = class {
1226
+ static {
1227
+ __name(this, "Auth");
1423
1228
  }
1424
- );
1229
+ /**
1230
+ * Refresh JWT token.
1231
+ */
1232
+ static cfgAccountsTokenRefreshCreate(options) {
1233
+ return (options.client ?? client).post({
1234
+ url: "/cfg/accounts/token/refresh/",
1235
+ ...options,
1236
+ headers: {
1237
+ "Content-Type": "application/json",
1238
+ ...options.headers
1239
+ }
1240
+ });
1241
+ }
1242
+ };
1425
1243
 
1426
1244
  // src/auth/utils/logger.ts
1427
- import { createConsola as createConsola3 } from "consola";
1245
+ import { createConsola as createConsola2 } from "consola";
1428
1246
 
1429
1247
  // src/auth/utils/env.ts
1430
1248
  var isDev = process.env.NODE_ENV === "development";
@@ -1432,7 +1250,7 @@ var isDev = process.env.NODE_ENV === "development";
1432
1250
  // src/auth/utils/logger.ts
1433
1251
  var isStaticBuild2 = process.env.NEXT_PUBLIC_STATIC_BUILD === "true";
1434
1252
  var showLogs = isDev || isStaticBuild2;
1435
- var logger = createConsola3({
1253
+ var logger = createConsola2({
1436
1254
  level: showLogs ? 4 : 1
1437
1255
  // dev: debug, production: errors only
1438
1256
  }).withTag("api");
@@ -1459,22 +1277,24 @@ async function refreshAccessToken() {
1459
1277
  isRefreshing = true;
1460
1278
  authLogger.info("Starting token refresh...");
1461
1279
  try {
1462
- const refreshToken = api.getRefreshToken();
1280
+ const refreshToken = CfgAccountsApi.getRefreshToken();
1463
1281
  if (!refreshToken) {
1464
1282
  authLogger.warn("No refresh token available for refresh");
1465
1283
  onTokenRefreshed(null);
1466
1284
  return null;
1467
1285
  }
1468
- const result = await api.auth.accountsTokenRefreshCreate({
1469
- refresh: refreshToken
1286
+ const result = await Auth.cfgAccountsTokenRefreshCreate({
1287
+ body: { refresh: refreshToken },
1288
+ throwOnError: true
1470
1289
  });
1471
- const newAccessToken = result.access;
1290
+ const newAccessToken = result.data.access;
1472
1291
  if (!newAccessToken) {
1473
1292
  authLogger.error("Token refresh response missing access token");
1474
1293
  onTokenRefreshed(null);
1475
1294
  return null;
1476
1295
  }
1477
- api.setToken(newAccessToken, refreshToken);
1296
+ CfgAccountsApi.setToken(newAccessToken);
1297
+ CfgAccountsApi.setRefreshToken(refreshToken);
1478
1298
  authLogger.info("Token refreshed successfully");
1479
1299
  onTokenRefreshed(newAccessToken);
1480
1300
  return newAccessToken;
@@ -1494,7 +1314,7 @@ __name(isAuthenticationError, "isAuthenticationError");
1494
1314
  function createAutoRefreshFetch(originalFetch) {
1495
1315
  return async (input, init) => {
1496
1316
  let response = await originalFetch(input, init);
1497
- if (isAuthenticationError(response) && api.getRefreshToken()) {
1317
+ if (isAuthenticationError(response) && CfgAccountsApi.getRefreshToken()) {
1498
1318
  authLogger.info("Received 401, attempting token refresh...");
1499
1319
  const newToken = await refreshAccessToken();
1500
1320
  if (newToken) {
@@ -1516,7 +1336,7 @@ function createAutoRefreshFetch(originalFetch) {
1516
1336
  }
1517
1337
  __name(createAutoRefreshFetch, "createAutoRefreshFetch");
1518
1338
  function isTokenExpiringSoon(thresholdMs = 5 * 60 * 1e3) {
1519
- const token = api.getToken();
1339
+ const token = CfgAccountsApi.getToken();
1520
1340
  if (!token) return false;
1521
1341
  try {
1522
1342
  const payload = JSON.parse(atob(token.split(".")[1]));