@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
@@ -0,0 +1,198 @@
1
+ // AUTO-GENERATED by cmdop_server / devtools.generator.ts_extras.events
2
+ // Hooks Hey API client interceptors → typed CustomEvents on `window`.
3
+ // DO NOT EDIT — re-run `make gen-clients`.
4
+ //
5
+ // Usage:
6
+ // import "./generated/events" // side-effect: registers interceptors
7
+ //
8
+ // window.addEventListener("cmdop:network-error", (e) => {
9
+ // console.log(e.detail.status, e.detail.method, e.detail.url);
10
+ // });
11
+
12
+ import { client } from "../client.gen";
13
+
14
+ // ─────────────────────────────────────────────────────────────────────────────
15
+ // Event names + detail types
16
+ // ─────────────────────────────────────────────────────────────────────────────
17
+
18
+ export const NETWORK_ERROR_EVENT = "cmdop:network-error" as const;
19
+ export const VALIDATION_ERROR_EVENT = "cmdop:validation-error" as const;
20
+ export const RUNTIME_ERROR_EVENT = "cmdop:runtime-error" as const;
21
+
22
+ export interface NetworkErrorDetail {
23
+ /** HTTP method (GET/POST/...). */
24
+ method: string;
25
+ /** Request URL. */
26
+ url: string;
27
+ /** HTTP status if response arrived; null on transport failure. */
28
+ status: number | null;
29
+ /** Response body parsed as text (best-effort, may be empty). */
30
+ body?: string;
31
+ /** Underlying error message (network failures, abort, etc.). */
32
+ error?: string;
33
+ /** Heuristic: did the request likely fail due to CORS? */
34
+ possiblyCors: boolean;
35
+ timestamp: Date;
36
+ }
37
+
38
+ export interface ValidationErrorDetail {
39
+ /** Operation ID this validation applies to (from the OpenAPI spec). */
40
+ operation: string;
41
+ /** Schema name that failed (if known). */
42
+ schema?: string;
43
+ /** Issues array — shape mirrors zod's ZodIssue but kept opaque here to
44
+ * avoid forcing a hard zod dep on consumers that don't use schemas. */
45
+ issues: unknown;
46
+ /** Raw response data that failed validation. */
47
+ data: unknown;
48
+ timestamp: Date;
49
+ }
50
+
51
+ export interface RuntimeErrorDetail {
52
+ /** Free-form source identifier — component name, hook name, etc. */
53
+ source: string;
54
+ message: string;
55
+ /** Original Error object (may be undefined when caller lacks one). */
56
+ error?: Error;
57
+ /** Arbitrary context payload from the caller. */
58
+ context?: Record<string, unknown>;
59
+ timestamp: Date;
60
+ }
61
+
62
+ // Augment the global WindowEventMap so addEventListener gets typed details.
63
+ declare global {
64
+ interface WindowEventMap {
65
+ "cmdop:network-error": CustomEvent<NetworkErrorDetail>;
66
+ "cmdop:validation-error": CustomEvent<ValidationErrorDetail>;
67
+ "cmdop:runtime-error": CustomEvent<RuntimeErrorDetail>;
68
+ }
69
+ }
70
+
71
+ // ─────────────────────────────────────────────────────────────────────────────
72
+ // Dispatch helpers
73
+ // ─────────────────────────────────────────────────────────────────────────────
74
+
75
+ function _dispatch<T>(name: string, detail: T): void {
76
+ if (typeof window === "undefined") return;
77
+ try {
78
+ window.dispatchEvent(new CustomEvent(name, { detail, bubbles: true }));
79
+ } catch {
80
+ // Event dispatch must never crash the app.
81
+ }
82
+ }
83
+
84
+ /** Emit a runtime error from anywhere in app code. */
85
+ export function emitRuntimeError(
86
+ source: string,
87
+ message: string,
88
+ error?: Error,
89
+ context?: Record<string, unknown>,
90
+ ): void {
91
+ _dispatch<RuntimeErrorDetail>(RUNTIME_ERROR_EVENT, {
92
+ source,
93
+ message,
94
+ error,
95
+ context,
96
+ timestamp: new Date(),
97
+ });
98
+ }
99
+
100
+ /** Emit a zod validation failure. Called by hooks when `validate` is provided. */
101
+ export function dispatchValidationError(
102
+ operation: string,
103
+ data: unknown,
104
+ issues: unknown,
105
+ schema?: string,
106
+ ): void {
107
+ _dispatch<ValidationErrorDetail>(VALIDATION_ERROR_EVENT, {
108
+ operation,
109
+ schema,
110
+ issues,
111
+ data,
112
+ timestamp: new Date(),
113
+ });
114
+ }
115
+
116
+ // ─────────────────────────────────────────────────────────────────────────────
117
+ // Listen helpers — typed wrappers over addEventListener, return cleanup fn.
118
+ // ─────────────────────────────────────────────────────────────────────────────
119
+
120
+ export function onNetworkError(
121
+ cb: (detail: NetworkErrorDetail) => void,
122
+ ): () => void {
123
+ if (typeof window === "undefined") return () => {};
124
+ const handler = (e: CustomEvent<NetworkErrorDetail>) => cb(e.detail);
125
+ window.addEventListener(NETWORK_ERROR_EVENT, handler);
126
+ return () => window.removeEventListener(NETWORK_ERROR_EVENT, handler);
127
+ }
128
+
129
+ export function onValidationError(
130
+ cb: (detail: ValidationErrorDetail) => void,
131
+ ): () => void {
132
+ if (typeof window === "undefined") return () => {};
133
+ const handler = (e: CustomEvent<ValidationErrorDetail>) => cb(e.detail);
134
+ window.addEventListener(VALIDATION_ERROR_EVENT, handler);
135
+ return () => window.removeEventListener(VALIDATION_ERROR_EVENT, handler);
136
+ }
137
+
138
+ export function onRuntimeError(
139
+ cb: (detail: RuntimeErrorDetail) => void,
140
+ ): () => void {
141
+ if (typeof window === "undefined") return () => {};
142
+ const handler = (e: CustomEvent<RuntimeErrorDetail>) => cb(e.detail);
143
+ window.addEventListener(RUNTIME_ERROR_EVENT, handler);
144
+ return () => window.removeEventListener(RUNTIME_ERROR_EVENT, handler);
145
+ }
146
+
147
+ // ─────────────────────────────────────────────────────────────────────────────
148
+ // Hey API interceptors — wire once, emit on response/error.
149
+ // ─────────────────────────────────────────────────────────────────────────────
150
+
151
+ let _wired = false;
152
+
153
+ function _wire(): void {
154
+ if (_wired) return;
155
+ _wired = true;
156
+
157
+ // response interceptor: every response, OK or not, lets us see status.
158
+ // We only emit for non-2xx — successful requests are silent.
159
+ client.interceptors.response.use(async (response, request) => {
160
+ if (!response.ok) {
161
+ let body: string | undefined;
162
+ try {
163
+ body = await response.clone().text();
164
+ if (body.length > 4000) body = body.slice(0, 4000) + "…";
165
+ } catch {
166
+ // ignore — body inaccessible
167
+ }
168
+ _dispatch<NetworkErrorDetail>(NETWORK_ERROR_EVENT, {
169
+ method: request.method,
170
+ url: request.url,
171
+ status: response.status,
172
+ body,
173
+ possiblyCors: false,
174
+ timestamp: new Date(),
175
+ });
176
+ }
177
+ return response;
178
+ });
179
+
180
+ // error interceptor: transport-level failures (abort, DNS, CORS, offline).
181
+ client.interceptors.error.use((error, _response, request) => {
182
+ const msg = error instanceof Error ? error.message : String(error);
183
+ // Heuristic: CORS-blocked fetches usually surface as "Failed to fetch"
184
+ // without a status. Not perfect, but catches the common case.
185
+ const possiblyCors = /failed to fetch|network error|cors/i.test(msg);
186
+ _dispatch<NetworkErrorDetail>(NETWORK_ERROR_EVENT, {
187
+ method: request?.method ?? "UNKNOWN",
188
+ url: request?.url ?? "",
189
+ status: null,
190
+ error: msg,
191
+ possiblyCors,
192
+ timestamp: new Date(),
193
+ });
194
+ return error;
195
+ });
196
+ }
197
+
198
+ _wire();
@@ -0,0 +1,4 @@
1
+ // AUTO-GENERATED — barrel for all hooks.
2
+ // DO NOT EDIT.
3
+
4
+ export { useCfgCentrifugoAuthTokenRetrieve } from "./useCfgCentrifugoAuthTokenRetrieve";
@@ -0,0 +1,25 @@
1
+ // AUTO-GENERATED by openapi_processor / ts.hooks
2
+ // Get Centrifugo connection token
3
+ // DO NOT EDIT — re-run `make gen`.
4
+
5
+ import useSWR from "swr";
6
+ import type { SWRConfiguration } from "swr";
7
+ import { Cfg } from "../../sdk.gen";
8
+ import type { CfgCentrifugoAuthTokenRetrieveData, CfgCentrifugoAuthTokenRetrieveResponses } from "../../types.gen";
9
+
10
+ type Result = CfgCentrifugoAuthTokenRetrieveResponses[keyof CfgCentrifugoAuthTokenRetrieveResponses];
11
+
12
+ export function useCfgCentrifugoAuthTokenRetrieve(
13
+ args?: Omit<CfgCentrifugoAuthTokenRetrieveData, "url" | "body">,
14
+ config?: SWRConfiguration<Result>,
15
+ ) {
16
+ const key = ["cfg_centrifugo_auth_token_retrieve", args ?? {}] as const;
17
+ return useSWR<Result>(
18
+ key,
19
+ async () => {
20
+ const res = await Cfg.cfgCentrifugoAuthTokenRetrieve({ ...(args ?? {}), throwOnError: true } as never);
21
+ return res.data as Result;
22
+ },
23
+ config,
24
+ );
25
+ }
@@ -0,0 +1,29 @@
1
+ // AUTO-GENERATED by django_generator / ts_extras.wrapper
2
+ // Group barrel. DO NOT EDIT — re-run `make gen`.
3
+
4
+ // Wrapper class + per-group SDK re-exports
5
+ export { API, type APIOptions, } from './api';
6
+
7
+ // Shared utilities (storage / errors / logger / validation events)
8
+ export {
9
+ type StorageAdapter,
10
+ LocalStorageAdapter,
11
+ MemoryStorageAdapter,
12
+ CookieStorageAdapter,
13
+ APIError,
14
+ NetworkError,
15
+ APILogger,
16
+ defaultLogger,
17
+ type LoggerConfig,
18
+ type RequestLog,
19
+ type ResponseLog,
20
+ type ErrorLog,
21
+ dispatchValidationError,
22
+ onValidationError,
23
+ formatZodError,
24
+ type ValidationErrorDetail,
25
+ type ValidationErrorEvent,
26
+ } from '../helpers';
27
+
28
+ // Generated artifacts (Hey API)
29
+ export type * from '../types.gen';
@@ -0,0 +1,14 @@
1
+ // AUTO-GENERATED by cmdop_server / devtools.generator.ts_extras
2
+ // Source: OpenAPI 3.1 components.schemas
3
+ // DO NOT EDIT — re-run `make gen-clients`.
4
+
5
+ import { z } from "zod";
6
+
7
+ export const ConnectionTokenResponseSchema = z.object({
8
+ centrifugo_url: z.string(),
9
+ channels: z.array(z.string()),
10
+ expires_at: z.string(),
11
+ token: z.string(),
12
+ });
13
+
14
+ export type ConnectionTokenResponse = z.infer<typeof ConnectionTokenResponseSchema>;
@@ -0,0 +1,4 @@
1
+ // AUTO-GENERATED — barrel for zod schemas.
2
+ // DO NOT EDIT.
3
+
4
+ export * from "./ConnectionTokenResponse";
@@ -0,0 +1,5 @@
1
+ // AUTO-GENERATED by openapi_processor / ts.tool
2
+ // Re-exports the top-level Hey API SDK so group-scoped imports work:
3
+ // import { Foo } from "@api/generated/_<group>/sdk.gen";
4
+ // DO NOT EDIT — re-run `make gen`.
5
+ export * from "../sdk.gen";
@@ -0,0 +1,5 @@
1
+ // AUTO-GENERATED by openapi_processor / ts.tool
2
+ // Re-exports the top-level Hey API types so group-scoped imports work:
3
+ // import type { Foo } from "@api/generated/_<group>/types.gen";
4
+ // DO NOT EDIT — re-run `make gen`.
5
+ export * from "../types.gen";
@@ -0,0 +1,120 @@
1
+ // AUTO-GENERATED by django_generator / ts_extras.wrapper
2
+ // Self-contained API wrapper for this group. DO NOT EDIT — re-run `make gen`.
3
+
4
+ import { client } from '../client.gen';
5
+ import type { StorageAdapter } from '../helpers/storage';
6
+ import { LocalStorageAdapter } from '../helpers/storage';
7
+ import { APILogger, type LoggerConfig } from '../helpers/logger';
8
+
9
+
10
+
11
+
12
+ const ACCESS_KEY = 'cfg.access_token';
13
+ const REFRESH_KEY = 'cfg.refresh_token';
14
+
15
+
16
+
17
+ /** Auto-detect locale from cookie NEXT_LOCALE or navigator.language. */
18
+ function detectLocale(): string | null {
19
+ try {
20
+ if (typeof document !== 'undefined') {
21
+ const m = document.cookie.match(/(?:^|;\s*)NEXT_LOCALE=([^;]*)/);
22
+ if (m) return decodeURIComponent(m[1]);
23
+ }
24
+ if (typeof navigator !== 'undefined' && navigator.language) {
25
+ return navigator.language;
26
+ }
27
+ } catch {}
28
+ return null;
29
+ }
30
+
31
+ export interface APIOptions {
32
+ /** Override storage backend (LocalStorage by default; Memory for SSR/tests). */
33
+ storage?: StorageAdapter;
34
+ /** Logger config (defaults to dev-only). */
35
+ logger?: Partial<LoggerConfig>;
36
+ /** Locale for `Accept-Language`. If omitted, auto-detected from cookie/navigator. */
37
+ locale?: string;
38
+ /** API key sent as `X-API-Key`. Falls back to NEXT_PUBLIC_API_KEY. */
39
+ apiKey?: string;
40
+ /** Send Django session/CSRF cookies cross-origin. Defaults to true. */
41
+ withCredentials?: boolean;
42
+ }
43
+
44
+ /**
45
+ * Self-contained API wrapper for this group.
46
+ *
47
+ * Each group has its own client + interceptor + token store. The interceptor
48
+ * automatically attaches:
49
+ * - `Authorization: Bearer <jwt>` from storage
50
+ * - `Accept-Language` from `opts.locale` or `NEXT_LOCALE` cookie
51
+ * - `X-API-Key` from `opts.apiKey` or `NEXT_PUBLIC_API_KEY`
52
+ * - `credentials: 'include'` for Django session/CSRF cookies (toggle via opts)
53
+ */
54
+ export class API {
55
+ private baseUrl: string;
56
+ private storage: StorageAdapter;
57
+ private locale: string | null;
58
+ private apiKey: string | null;
59
+ readonly logger: APILogger;
60
+
61
+
62
+
63
+ constructor(baseUrl: string, opts: APIOptions = {}) {
64
+ this.baseUrl = baseUrl.replace(/\/$/, '');
65
+ this.storage = opts.storage ?? new LocalStorageAdapter();
66
+ this.logger = new APILogger(opts.logger);
67
+ this.locale = opts.locale ?? null;
68
+ this.apiKey = opts.apiKey ?? (typeof process !== 'undefined' ? (process.env?.NEXT_PUBLIC_API_KEY ?? null) : null);
69
+
70
+ const credentials: RequestCredentials = (opts.withCredentials ?? true) ? 'include' : 'same-origin';
71
+ client.setConfig({ baseUrl: this.baseUrl, credentials });
72
+
73
+ client.interceptors.request.use((request) => {
74
+ const access = this.getToken();
75
+ if (access) request.headers.set('Authorization', `Bearer ${access}`);
76
+
77
+ const locale = this.locale ?? detectLocale();
78
+ if (locale) request.headers.set('Accept-Language', locale);
79
+
80
+ if (this.apiKey) request.headers.set('X-API-Key', this.apiKey);
81
+
82
+ return request;
83
+ });
84
+
85
+
86
+ }
87
+
88
+ // ── Base URL ────────────────────────────────────────────────────────────
89
+ getBaseUrl(): string { return this.baseUrl; }
90
+ setBaseUrl(url: string): void {
91
+ this.baseUrl = url.replace(/\/$/, '');
92
+ client.setConfig({ baseUrl: this.baseUrl });
93
+ }
94
+
95
+ // ── Tokens ──────────────────────────────────────────────────────────────
96
+ getToken(): string | null { return this.storage.getItem(ACCESS_KEY); }
97
+ setToken(token: string | null): void {
98
+ if (token) this.storage.setItem(ACCESS_KEY, token);
99
+ else this.storage.removeItem(ACCESS_KEY);
100
+ }
101
+ getRefreshToken(): string | null { return this.storage.getItem(REFRESH_KEY); }
102
+ setRefreshToken(token: string | null): void {
103
+ if (token) this.storage.setItem(REFRESH_KEY, token);
104
+ else this.storage.removeItem(REFRESH_KEY);
105
+ }
106
+ clearToken(): void {
107
+ this.storage.removeItem(ACCESS_KEY);
108
+ this.storage.removeItem(REFRESH_KEY);
109
+ }
110
+ isAuthenticated(): boolean { return this.getToken() !== null; }
111
+
112
+ // ── Locale / API key ────────────────────────────────────────────────────
113
+ getLocale(): string | null { return this.locale ?? detectLocale(); }
114
+ setLocale(locale: string | null): void { this.locale = locale; }
115
+ getApiKey(): string | null { return this.apiKey; }
116
+ setApiKey(key: string | null): void { this.apiKey = key; }
117
+ }
118
+
119
+ export { };
120
+ export { client };
@@ -0,0 +1,198 @@
1
+ // AUTO-GENERATED by cmdop_server / devtools.generator.ts_extras.events
2
+ // Hooks Hey API client interceptors → typed CustomEvents on `window`.
3
+ // DO NOT EDIT — re-run `make gen-clients`.
4
+ //
5
+ // Usage:
6
+ // import "./generated/events" // side-effect: registers interceptors
7
+ //
8
+ // window.addEventListener("cmdop:network-error", (e) => {
9
+ // console.log(e.detail.status, e.detail.method, e.detail.url);
10
+ // });
11
+
12
+ import { client } from "../client.gen";
13
+
14
+ // ─────────────────────────────────────────────────────────────────────────────
15
+ // Event names + detail types
16
+ // ─────────────────────────────────────────────────────────────────────────────
17
+
18
+ export const NETWORK_ERROR_EVENT = "cmdop:network-error" as const;
19
+ export const VALIDATION_ERROR_EVENT = "cmdop:validation-error" as const;
20
+ export const RUNTIME_ERROR_EVENT = "cmdop:runtime-error" as const;
21
+
22
+ export interface NetworkErrorDetail {
23
+ /** HTTP method (GET/POST/...). */
24
+ method: string;
25
+ /** Request URL. */
26
+ url: string;
27
+ /** HTTP status if response arrived; null on transport failure. */
28
+ status: number | null;
29
+ /** Response body parsed as text (best-effort, may be empty). */
30
+ body?: string;
31
+ /** Underlying error message (network failures, abort, etc.). */
32
+ error?: string;
33
+ /** Heuristic: did the request likely fail due to CORS? */
34
+ possiblyCors: boolean;
35
+ timestamp: Date;
36
+ }
37
+
38
+ export interface ValidationErrorDetail {
39
+ /** Operation ID this validation applies to (from the OpenAPI spec). */
40
+ operation: string;
41
+ /** Schema name that failed (if known). */
42
+ schema?: string;
43
+ /** Issues array — shape mirrors zod's ZodIssue but kept opaque here to
44
+ * avoid forcing a hard zod dep on consumers that don't use schemas. */
45
+ issues: unknown;
46
+ /** Raw response data that failed validation. */
47
+ data: unknown;
48
+ timestamp: Date;
49
+ }
50
+
51
+ export interface RuntimeErrorDetail {
52
+ /** Free-form source identifier — component name, hook name, etc. */
53
+ source: string;
54
+ message: string;
55
+ /** Original Error object (may be undefined when caller lacks one). */
56
+ error?: Error;
57
+ /** Arbitrary context payload from the caller. */
58
+ context?: Record<string, unknown>;
59
+ timestamp: Date;
60
+ }
61
+
62
+ // Augment the global WindowEventMap so addEventListener gets typed details.
63
+ declare global {
64
+ interface WindowEventMap {
65
+ "cmdop:network-error": CustomEvent<NetworkErrorDetail>;
66
+ "cmdop:validation-error": CustomEvent<ValidationErrorDetail>;
67
+ "cmdop:runtime-error": CustomEvent<RuntimeErrorDetail>;
68
+ }
69
+ }
70
+
71
+ // ─────────────────────────────────────────────────────────────────────────────
72
+ // Dispatch helpers
73
+ // ─────────────────────────────────────────────────────────────────────────────
74
+
75
+ function _dispatch<T>(name: string, detail: T): void {
76
+ if (typeof window === "undefined") return;
77
+ try {
78
+ window.dispatchEvent(new CustomEvent(name, { detail, bubbles: true }));
79
+ } catch {
80
+ // Event dispatch must never crash the app.
81
+ }
82
+ }
83
+
84
+ /** Emit a runtime error from anywhere in app code. */
85
+ export function emitRuntimeError(
86
+ source: string,
87
+ message: string,
88
+ error?: Error,
89
+ context?: Record<string, unknown>,
90
+ ): void {
91
+ _dispatch<RuntimeErrorDetail>(RUNTIME_ERROR_EVENT, {
92
+ source,
93
+ message,
94
+ error,
95
+ context,
96
+ timestamp: new Date(),
97
+ });
98
+ }
99
+
100
+ /** Emit a zod validation failure. Called by hooks when `validate` is provided. */
101
+ export function dispatchValidationError(
102
+ operation: string,
103
+ data: unknown,
104
+ issues: unknown,
105
+ schema?: string,
106
+ ): void {
107
+ _dispatch<ValidationErrorDetail>(VALIDATION_ERROR_EVENT, {
108
+ operation,
109
+ schema,
110
+ issues,
111
+ data,
112
+ timestamp: new Date(),
113
+ });
114
+ }
115
+
116
+ // ─────────────────────────────────────────────────────────────────────────────
117
+ // Listen helpers — typed wrappers over addEventListener, return cleanup fn.
118
+ // ─────────────────────────────────────────────────────────────────────────────
119
+
120
+ export function onNetworkError(
121
+ cb: (detail: NetworkErrorDetail) => void,
122
+ ): () => void {
123
+ if (typeof window === "undefined") return () => {};
124
+ const handler = (e: CustomEvent<NetworkErrorDetail>) => cb(e.detail);
125
+ window.addEventListener(NETWORK_ERROR_EVENT, handler);
126
+ return () => window.removeEventListener(NETWORK_ERROR_EVENT, handler);
127
+ }
128
+
129
+ export function onValidationError(
130
+ cb: (detail: ValidationErrorDetail) => void,
131
+ ): () => void {
132
+ if (typeof window === "undefined") return () => {};
133
+ const handler = (e: CustomEvent<ValidationErrorDetail>) => cb(e.detail);
134
+ window.addEventListener(VALIDATION_ERROR_EVENT, handler);
135
+ return () => window.removeEventListener(VALIDATION_ERROR_EVENT, handler);
136
+ }
137
+
138
+ export function onRuntimeError(
139
+ cb: (detail: RuntimeErrorDetail) => void,
140
+ ): () => void {
141
+ if (typeof window === "undefined") return () => {};
142
+ const handler = (e: CustomEvent<RuntimeErrorDetail>) => cb(e.detail);
143
+ window.addEventListener(RUNTIME_ERROR_EVENT, handler);
144
+ return () => window.removeEventListener(RUNTIME_ERROR_EVENT, handler);
145
+ }
146
+
147
+ // ─────────────────────────────────────────────────────────────────────────────
148
+ // Hey API interceptors — wire once, emit on response/error.
149
+ // ─────────────────────────────────────────────────────────────────────────────
150
+
151
+ let _wired = false;
152
+
153
+ function _wire(): void {
154
+ if (_wired) return;
155
+ _wired = true;
156
+
157
+ // response interceptor: every response, OK or not, lets us see status.
158
+ // We only emit for non-2xx — successful requests are silent.
159
+ client.interceptors.response.use(async (response, request) => {
160
+ if (!response.ok) {
161
+ let body: string | undefined;
162
+ try {
163
+ body = await response.clone().text();
164
+ if (body.length > 4000) body = body.slice(0, 4000) + "…";
165
+ } catch {
166
+ // ignore — body inaccessible
167
+ }
168
+ _dispatch<NetworkErrorDetail>(NETWORK_ERROR_EVENT, {
169
+ method: request.method,
170
+ url: request.url,
171
+ status: response.status,
172
+ body,
173
+ possiblyCors: false,
174
+ timestamp: new Date(),
175
+ });
176
+ }
177
+ return response;
178
+ });
179
+
180
+ // error interceptor: transport-level failures (abort, DNS, CORS, offline).
181
+ client.interceptors.error.use((error, _response, request) => {
182
+ const msg = error instanceof Error ? error.message : String(error);
183
+ // Heuristic: CORS-blocked fetches usually surface as "Failed to fetch"
184
+ // without a status. Not perfect, but catches the common case.
185
+ const possiblyCors = /failed to fetch|network error|cors/i.test(msg);
186
+ _dispatch<NetworkErrorDetail>(NETWORK_ERROR_EVENT, {
187
+ method: request?.method ?? "UNKNOWN",
188
+ url: request?.url ?? "",
189
+ status: null,
190
+ error: msg,
191
+ possiblyCors,
192
+ timestamp: new Date(),
193
+ });
194
+ return error;
195
+ });
196
+ }
197
+
198
+ _wire();
@@ -0,0 +1,12 @@
1
+ // AUTO-GENERATED — barrel for all hooks.
2
+ // DO NOT EDIT.
3
+
4
+ export { useCfgTotpBackupCodesRegenerateCreate } from "./useCfgTotpBackupCodesRegenerateCreate";
5
+ export { useCfgTotpBackupCodesRetrieve } from "./useCfgTotpBackupCodesRetrieve";
6
+ export { useCfgTotpDevicesDestroy } from "./useCfgTotpDevicesDestroy";
7
+ export { useCfgTotpDevicesRetrieve } from "./useCfgTotpDevicesRetrieve";
8
+ export { useCfgTotpDisableCreate } from "./useCfgTotpDisableCreate";
9
+ export { useCfgTotpSetupConfirmCreate } from "./useCfgTotpSetupConfirmCreate";
10
+ export { useCfgTotpSetupCreate } from "./useCfgTotpSetupCreate";
11
+ export { useCfgTotpVerifyBackupCreate } from "./useCfgTotpVerifyBackupCreate";
12
+ export { useCfgTotpVerifyCreate } from "./useCfgTotpVerifyCreate";
@@ -0,0 +1,24 @@
1
+ // AUTO-GENERATED by openapi_processor / ts.hooks
2
+ // POST /cfg/totp/backup-codes/regenerate/
3
+ // DO NOT EDIT — re-run `make gen`.
4
+
5
+ import useSWRMutation from "swr/mutation";
6
+ import type { SWRMutationConfiguration } from "swr/mutation";
7
+ import { Cfg } from "../../sdk.gen";
8
+ import type { CfgTotpBackupCodesRegenerateCreateData, CfgTotpBackupCodesRegenerateCreateResponses } from "../../types.gen";
9
+
10
+ type Args = Omit<CfgTotpBackupCodesRegenerateCreateData, "url">;
11
+ type Result = CfgTotpBackupCodesRegenerateCreateResponses[keyof CfgTotpBackupCodesRegenerateCreateResponses];
12
+
13
+ export function useCfgTotpBackupCodesRegenerateCreate(
14
+ config?: SWRMutationConfiguration<Result, Error, readonly ["cfg_totp_backup_codes_regenerate_create"], Args>,
15
+ ) {
16
+ return useSWRMutation<Result, Error, readonly ["cfg_totp_backup_codes_regenerate_create"], Args>(
17
+ ["cfg_totp_backup_codes_regenerate_create"] as const,
18
+ async (_key, { arg }: { arg: Args }) => {
19
+ const res = await Cfg.cfgTotpBackupCodesRegenerateCreate({ ...arg, throwOnError: true } as never);
20
+ return res.data as Result;
21
+ },
22
+ config,
23
+ );
24
+ }
@@ -0,0 +1,25 @@
1
+ // AUTO-GENERATED by openapi_processor / ts.hooks
2
+ // GET /cfg/totp/backup-codes/
3
+ // DO NOT EDIT — re-run `make gen`.
4
+
5
+ import useSWR from "swr";
6
+ import type { SWRConfiguration } from "swr";
7
+ import { Cfg } from "../../sdk.gen";
8
+ import type { CfgTotpBackupCodesRetrieveData, CfgTotpBackupCodesRetrieveResponses } from "../../types.gen";
9
+
10
+ type Result = CfgTotpBackupCodesRetrieveResponses[keyof CfgTotpBackupCodesRetrieveResponses];
11
+
12
+ export function useCfgTotpBackupCodesRetrieve(
13
+ args?: Omit<CfgTotpBackupCodesRetrieveData, "url" | "body">,
14
+ config?: SWRConfiguration<Result>,
15
+ ) {
16
+ const key = ["cfg_totp_backup_codes_retrieve", args ?? {}] as const;
17
+ return useSWR<Result>(
18
+ key,
19
+ async () => {
20
+ const res = await Cfg.cfgTotpBackupCodesRetrieve({ ...(args ?? {}), throwOnError: true } as never);
21
+ return res.data as Result;
22
+ },
23
+ config,
24
+ );
25
+ }