@djangocfg/api 2.1.327 → 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 (170) hide show
  1. package/dist/auth-server.cjs +185 -3471
  2. package/dist/auth-server.cjs.map +1 -1
  3. package/dist/auth-server.mjs +185 -3471
  4. package/dist/auth-server.mjs.map +1 -1
  5. package/dist/auth.cjs +952 -3305
  6. package/dist/auth.cjs.map +1 -1
  7. package/dist/auth.d.cts +35 -35
  8. package/dist/auth.d.ts +35 -35
  9. package/dist/auth.mjs +952 -3305
  10. package/dist/auth.mjs.map +1 -1
  11. package/dist/clients.cjs +90 -3396
  12. package/dist/clients.cjs.map +1 -1
  13. package/dist/clients.d.cts +4 -2508
  14. package/dist/clients.d.ts +4 -2508
  15. package/dist/clients.mjs +90 -3396
  16. package/dist/clients.mjs.map +1 -1
  17. package/dist/index.cjs +985 -3052
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.d.cts +1544 -1938
  20. package/dist/index.d.ts +1544 -1938
  21. package/dist/index.mjs +985 -3052
  22. package/dist/index.mjs.map +1 -1
  23. package/package.json +2 -2
  24. package/src/_api/generated/{cfg_centrifugo → _cfg_accounts}/api.ts +11 -55
  25. package/src/_api/generated/{cfg_totp → _cfg_accounts}/events.ts +3 -3
  26. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/index.ts +1 -1
  27. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsOauthConnectionsList.ts +5 -6
  28. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsOauthDisconnectCreate.ts +3 -3
  29. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsOauthGithubAuthorizeCreate.ts +3 -3
  30. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsOauthGithubCallbackCreate.ts +3 -3
  31. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsOauthProvidersRetrieve.ts +5 -6
  32. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsOtpRequestCreate.ts +3 -3
  33. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsOtpVerifyCreate.ts +3 -3
  34. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsProfileAvatarCreate.ts +3 -3
  35. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsProfileDeleteCreate.ts +3 -3
  36. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsProfilePartialPartialUpdate.ts +3 -3
  37. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsProfilePartialUpdate.ts +3 -3
  38. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsProfileRetrieve.ts +5 -6
  39. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsProfileUpdatePartialUpdate.ts +3 -3
  40. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsProfileUpdateUpdate.ts +3 -3
  41. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsTokenRefreshCreate.ts +3 -3
  42. package/src/_api/generated/{cfg_centrifugo → _cfg_accounts}/index.ts +3 -3
  43. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/AccountDeleteResponse.ts +3 -3
  44. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/CentrifugoToken.ts +4 -4
  45. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/CfgUserUpdateRequest.ts +4 -4
  46. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/OAuthAuthorizeRequestRequest.ts +2 -2
  47. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/OAuthAuthorizeResponse.ts +2 -2
  48. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/OAuthCallbackRequestRequest.ts +3 -3
  49. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/OAuthConnection.ts +6 -6
  50. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/OAuthDisconnectRequestRequest.ts +2 -2
  51. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/OAuthError.ts +2 -2
  52. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/OAuthProvidersResponse.ts +3 -3
  53. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/OAuthTokenResponse.ts +7 -7
  54. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/OTPErrorResponse.ts +2 -2
  55. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/OTPRequestRequest.ts +2 -2
  56. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/OTPRequestResponse.ts +2 -2
  57. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/OTPVerifyRequest.ts +2 -2
  58. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/OTPVerifyResponse.ts +6 -6
  59. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/PatchedCfgUserUpdateRequest.ts +4 -4
  60. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/ProviderEnum.ts +2 -2
  61. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/TokenRefresh.ts +2 -2
  62. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/TokenRefreshRequest.ts +2 -2
  63. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/User.ts +13 -13
  64. package/src/_api/generated/_cfg_accounts/sdk.gen.ts +5 -0
  65. package/src/_api/generated/_cfg_accounts/types.gen.ts +5 -0
  66. package/src/_api/generated/{cfg_totp → _cfg_centrifugo}/api.ts +11 -72
  67. package/src/_api/generated/{cfg_centrifugo → _cfg_centrifugo}/events.ts +3 -3
  68. package/src/_api/generated/{cfg_centrifugo → _cfg_centrifugo}/hooks/index.ts +1 -1
  69. package/src/_api/generated/{cfg_centrifugo → _cfg_centrifugo}/hooks/useCfgCentrifugoAuthTokenRetrieve.ts +5 -6
  70. package/src/_api/generated/{cfg_accounts → _cfg_centrifugo}/index.ts +3 -3
  71. package/src/_api/generated/{cfg_centrifugo → _cfg_centrifugo}/schemas/ConnectionTokenResponse.ts +4 -4
  72. package/src/_api/generated/_cfg_centrifugo/sdk.gen.ts +5 -0
  73. package/src/_api/generated/_cfg_centrifugo/types.gen.ts +5 -0
  74. package/src/_api/generated/{cfg_accounts → _cfg_totp}/api.ts +11 -78
  75. package/src/_api/generated/{cfg_accounts → _cfg_totp}/events.ts +3 -3
  76. package/src/_api/generated/{cfg_totp → _cfg_totp}/hooks/index.ts +1 -1
  77. package/src/_api/generated/{cfg_totp → _cfg_totp}/hooks/useCfgTotpBackupCodesRegenerateCreate.ts +3 -3
  78. package/src/_api/generated/{cfg_totp → _cfg_totp}/hooks/useCfgTotpBackupCodesRetrieve.ts +5 -6
  79. package/src/_api/generated/{cfg_totp → _cfg_totp}/hooks/useCfgTotpDevicesDestroy.ts +3 -3
  80. package/src/_api/generated/{cfg_totp → _cfg_totp}/hooks/useCfgTotpDevicesRetrieve.ts +5 -6
  81. package/src/_api/generated/{cfg_totp → _cfg_totp}/hooks/useCfgTotpDisableCreate.ts +3 -3
  82. package/src/_api/generated/{cfg_totp → _cfg_totp}/hooks/useCfgTotpSetupConfirmCreate.ts +3 -3
  83. package/src/_api/generated/{cfg_totp → _cfg_totp}/hooks/useCfgTotpSetupCreate.ts +3 -3
  84. package/src/_api/generated/{cfg_totp → _cfg_totp}/hooks/useCfgTotpVerifyBackupCreate.ts +3 -3
  85. package/src/_api/generated/{cfg_totp → _cfg_totp}/hooks/useCfgTotpVerifyCreate.ts +3 -3
  86. package/src/_api/generated/{cfg_totp → _cfg_totp}/index.ts +3 -3
  87. package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/BackupCodesRegenerateRequest.ts +2 -2
  88. package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/BackupCodesRegenerateResponse.ts +2 -2
  89. package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/BackupCodesStatus.ts +2 -2
  90. package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/ConfirmSetupRequest.ts +3 -3
  91. package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/ConfirmSetupResponse.ts +3 -3
  92. package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/DeviceList.ts +6 -6
  93. package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/DeviceListResponse.ts +2 -2
  94. package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/DeviceListStatusEnum.ts +2 -2
  95. package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/DisableRequest.ts +2 -2
  96. package/src/_api/generated/_cfg_totp/schemas/SetupRequest.ts +11 -0
  97. package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/SetupResponse.ts +4 -4
  98. package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/TotpVerifyUser.ts +12 -12
  99. package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/VerifyBackupRequest.ts +3 -3
  100. package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/VerifyRequest.ts +3 -3
  101. package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/VerifyResponse.ts +4 -4
  102. package/src/_api/generated/_cfg_totp/sdk.gen.ts +5 -0
  103. package/src/_api/generated/_cfg_totp/types.gen.ts +5 -0
  104. package/src/_api/generated/index.ts +11 -13
  105. package/src/_api/generated/{cfg_accounts/sdk.gen.ts → sdk.gen.ts} +455 -1
  106. package/src/_api/generated/{cfg_accounts/types.gen.ts → types.gen.ts} +607 -77
  107. package/src/auth/context/AccountsContext.tsx +10 -10
  108. package/src/auth/context/AuthContext.tsx +1 -1
  109. package/src/auth/hooks/useDeleteAccount.ts +2 -1
  110. package/src/auth/hooks/useGithubAuth.ts +3 -2
  111. package/src/auth/hooks/useTokenRefresh.ts +2 -1
  112. package/src/auth/hooks/useTwoFactor.ts +4 -3
  113. package/src/auth/hooks/useTwoFactorSetup.ts +3 -2
  114. package/src/auth/hooks/useTwoFactorStatus.ts +4 -3
  115. package/src/auth/middlewares/tokenRefresh.ts +2 -1
  116. package/src/clients.ts +3 -3
  117. package/src/index.ts +22 -5
  118. package/src/server.ts +9 -9
  119. package/src/_api/generated/cfg_centrifugo/client/client.gen.ts +0 -280
  120. package/src/_api/generated/cfg_centrifugo/client/index.ts +0 -25
  121. package/src/_api/generated/cfg_centrifugo/client/types.gen.ts +0 -217
  122. package/src/_api/generated/cfg_centrifugo/client/utils.gen.ts +0 -318
  123. package/src/_api/generated/cfg_centrifugo/client.gen.ts +0 -16
  124. package/src/_api/generated/cfg_centrifugo/core/auth.gen.ts +0 -41
  125. package/src/_api/generated/cfg_centrifugo/core/bodySerializer.gen.ts +0 -82
  126. package/src/_api/generated/cfg_centrifugo/core/params.gen.ts +0 -169
  127. package/src/_api/generated/cfg_centrifugo/core/pathSerializer.gen.ts +0 -171
  128. package/src/_api/generated/cfg_centrifugo/core/queryKeySerializer.gen.ts +0 -117
  129. package/src/_api/generated/cfg_centrifugo/core/serverSentEvents.gen.ts +0 -242
  130. package/src/_api/generated/cfg_centrifugo/core/types.gen.ts +0 -104
  131. package/src/_api/generated/cfg_centrifugo/core/utils.gen.ts +0 -140
  132. package/src/_api/generated/cfg_centrifugo/sdk.gen.ts +0 -64
  133. package/src/_api/generated/cfg_centrifugo/types.gen.ts +0 -61
  134. package/src/_api/generated/cfg_totp/client/client.gen.ts +0 -280
  135. package/src/_api/generated/cfg_totp/client/index.ts +0 -25
  136. package/src/_api/generated/cfg_totp/client/types.gen.ts +0 -217
  137. package/src/_api/generated/cfg_totp/client/utils.gen.ts +0 -318
  138. package/src/_api/generated/cfg_totp/client.gen.ts +0 -16
  139. package/src/_api/generated/cfg_totp/core/auth.gen.ts +0 -41
  140. package/src/_api/generated/cfg_totp/core/bodySerializer.gen.ts +0 -82
  141. package/src/_api/generated/cfg_totp/core/params.gen.ts +0 -169
  142. package/src/_api/generated/cfg_totp/core/pathSerializer.gen.ts +0 -171
  143. package/src/_api/generated/cfg_totp/core/queryKeySerializer.gen.ts +0 -117
  144. package/src/_api/generated/cfg_totp/core/serverSentEvents.gen.ts +0 -242
  145. package/src/_api/generated/cfg_totp/core/types.gen.ts +0 -104
  146. package/src/_api/generated/cfg_totp/core/utils.gen.ts +0 -140
  147. package/src/_api/generated/cfg_totp/schemas/SetupRequest.ts +0 -11
  148. package/src/_api/generated/cfg_totp/sdk.gen.ts +0 -432
  149. package/src/_api/generated/cfg_totp/types.gen.ts +0 -479
  150. /package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/index.ts +0 -0
  151. /package/src/_api/generated/{cfg_centrifugo → _cfg_centrifugo}/schemas/index.ts +0 -0
  152. /package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/index.ts +0 -0
  153. /package/src/_api/generated/{cfg_accounts/client → client}/client.gen.ts +0 -0
  154. /package/src/_api/generated/{cfg_accounts/client → client}/index.ts +0 -0
  155. /package/src/_api/generated/{cfg_accounts/client → client}/types.gen.ts +0 -0
  156. /package/src/_api/generated/{cfg_accounts/client → client}/utils.gen.ts +0 -0
  157. /package/src/_api/generated/{cfg_accounts/client.gen.ts → client.gen.ts} +0 -0
  158. /package/src/_api/generated/{cfg_accounts/core → core}/auth.gen.ts +0 -0
  159. /package/src/_api/generated/{cfg_accounts/core → core}/bodySerializer.gen.ts +0 -0
  160. /package/src/_api/generated/{cfg_accounts/core → core}/params.gen.ts +0 -0
  161. /package/src/_api/generated/{cfg_accounts/core → core}/pathSerializer.gen.ts +0 -0
  162. /package/src/_api/generated/{cfg_accounts/core → core}/queryKeySerializer.gen.ts +0 -0
  163. /package/src/_api/generated/{cfg_accounts/core → core}/serverSentEvents.gen.ts +0 -0
  164. /package/src/_api/generated/{cfg_accounts/core → core}/types.gen.ts +0 -0
  165. /package/src/_api/generated/{cfg_accounts/core → core}/utils.gen.ts +0 -0
  166. /package/src/_api/generated/{_shared → helpers}/errors.ts +0 -0
  167. /package/src/_api/generated/{_shared → helpers}/index.ts +0 -0
  168. /package/src/_api/generated/{_shared → helpers}/logger.ts +0 -0
  169. /package/src/_api/generated/{_shared → helpers}/storage.ts +0 -0
  170. /package/src/_api/generated/{_shared → helpers}/validation-events.ts +0 -0
package/dist/auth.mjs CHANGED
@@ -251,7 +251,7 @@ var useAutoAuth = /* @__PURE__ */ __name((options = {}) => {
251
251
  // src/auth/hooks/useTwoFactor.ts
252
252
  import { useCallback as useCallback4, useState as useState3 } from "react";
253
253
 
254
- // src/_api/generated/cfg_accounts/core/bodySerializer.gen.ts
254
+ // src/_api/generated/core/bodySerializer.gen.ts
255
255
  var serializeFormDataPair = /* @__PURE__ */ __name((data, key, value) => {
256
256
  if (typeof value === "string" || value instanceof Blob) {
257
257
  data.append(key, value);
@@ -281,7 +281,7 @@ var jsonBodySerializer = {
281
281
  bodySerializer: /* @__PURE__ */ __name((body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value), "bodySerializer")
282
282
  };
283
283
 
284
- // src/_api/generated/cfg_accounts/core/params.gen.ts
284
+ // src/_api/generated/core/params.gen.ts
285
285
  var extraPrefixesMap = {
286
286
  $body_: "body",
287
287
  $headers_: "headers",
@@ -290,7 +290,7 @@ var extraPrefixesMap = {
290
290
  };
291
291
  var extraPrefixes = Object.entries(extraPrefixesMap);
292
292
 
293
- // src/_api/generated/cfg_accounts/core/serverSentEvents.gen.ts
293
+ // src/_api/generated/core/serverSentEvents.gen.ts
294
294
  function createSseClient({
295
295
  onRequest,
296
296
  onSseError,
@@ -418,7 +418,7 @@ function createSseClient({
418
418
  }
419
419
  __name(createSseClient, "createSseClient");
420
420
 
421
- // src/_api/generated/cfg_accounts/core/pathSerializer.gen.ts
421
+ // src/_api/generated/core/pathSerializer.gen.ts
422
422
  var separatorArrayExplode = /* @__PURE__ */ __name((style) => {
423
423
  switch (style) {
424
424
  case "label":
@@ -542,7 +542,7 @@ var serializeObjectParam = /* @__PURE__ */ __name(({
542
542
  return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
543
543
  }, "serializeObjectParam");
544
544
 
545
- // src/_api/generated/cfg_accounts/core/utils.gen.ts
545
+ // src/_api/generated/core/utils.gen.ts
546
546
  var PATH_PARAM_RE = /\{[^{}]+\}/g;
547
547
  var defaultPathSerializer = /* @__PURE__ */ __name(({ path, url: _url }) => {
548
548
  let url = _url;
@@ -640,7 +640,7 @@ function getValidRequestBody(options) {
640
640
  }
641
641
  __name(getValidRequestBody, "getValidRequestBody");
642
642
 
643
- // src/_api/generated/cfg_accounts/core/auth.gen.ts
643
+ // src/_api/generated/core/auth.gen.ts
644
644
  var getAuthToken = /* @__PURE__ */ __name(async (auth, callback) => {
645
645
  const token = typeof callback === "function" ? await callback(auth) : callback;
646
646
  if (!token) {
@@ -655,7 +655,7 @@ var getAuthToken = /* @__PURE__ */ __name(async (auth, callback) => {
655
655
  return token;
656
656
  }, "getAuthToken");
657
657
 
658
- // src/_api/generated/cfg_accounts/client/utils.gen.ts
658
+ // src/_api/generated/client/utils.gen.ts
659
659
  var createQuerySerializer = /* @__PURE__ */ __name(({
660
660
  parameters = {},
661
661
  ...args
@@ -874,7 +874,7 @@ var createConfig = /* @__PURE__ */ __name((override = {}) => ({
874
874
  ...override
875
875
  }), "createConfig");
876
876
 
877
- // src/_api/generated/cfg_accounts/client/client.gen.ts
877
+ // src/_api/generated/client/client.gen.ts
878
878
  var createClient = /* @__PURE__ */ __name((config = {}) => {
879
879
  let _config = mergeConfigs(createConfig(), config);
880
880
  const getConfig = /* @__PURE__ */ __name(() => ({ ..._config }), "getConfig");
@@ -1072,10 +1072,10 @@ var createClient = /* @__PURE__ */ __name((config = {}) => {
1072
1072
  };
1073
1073
  }, "createClient");
1074
1074
 
1075
- // src/_api/generated/cfg_accounts/client.gen.ts
1075
+ // src/_api/generated/client.gen.ts
1076
1076
  var client = createClient(createConfig({ baseUrl: "http://localhost:8000" }));
1077
1077
 
1078
- // src/_api/generated/_shared/storage.ts
1078
+ // src/_api/generated/helpers/storage.ts
1079
1079
  var LocalStorageAdapter = class {
1080
1080
  static {
1081
1081
  __name(this, "LocalStorageAdapter");
@@ -1111,7 +1111,7 @@ var LocalStorageAdapter = class {
1111
1111
  }
1112
1112
  };
1113
1113
 
1114
- // src/_api/generated/_shared/logger.ts
1114
+ // src/_api/generated/helpers/logger.ts
1115
1115
  import { createConsola as createConsola2 } from "consola";
1116
1116
  var DEFAULT_CONFIG = {
1117
1117
  enabled: typeof process !== "undefined" && process.env.NODE_ENV !== "production",
@@ -1205,526 +1205,341 @@ var APILogger = class {
1205
1205
  };
1206
1206
  var defaultLogger = new APILogger();
1207
1207
 
1208
- // src/_api/generated/cfg_accounts/sdk.gen.ts
1209
- var Cfg = class {
1208
+ // src/_api/generated/_cfg_accounts/api.ts
1209
+ var ACCESS_KEY = "cfg.access_token";
1210
+ var REFRESH_KEY = "cfg.refresh_token";
1211
+ function detectLocale() {
1212
+ try {
1213
+ if (typeof document !== "undefined") {
1214
+ const m = document.cookie.match(/(?:^|;\s*)NEXT_LOCALE=([^;]*)/);
1215
+ if (m) return decodeURIComponent(m[1]);
1216
+ }
1217
+ if (typeof navigator !== "undefined" && navigator.language) {
1218
+ return navigator.language;
1219
+ }
1220
+ } catch {
1221
+ }
1222
+ return null;
1223
+ }
1224
+ __name(detectLocale, "detectLocale");
1225
+ var API = class {
1210
1226
  static {
1211
- __name(this, "Cfg");
1227
+ __name(this, "API");
1212
1228
  }
1213
- /**
1214
- * List OAuth connections
1215
- *
1216
- * Get all OAuth connections for the current user.
1217
- */
1218
- static cfgAccountsOauthConnectionsList(options) {
1219
- return (options?.client ?? client).get({
1220
- security: [{ scheme: "bearer", type: "http" }],
1221
- url: "/cfg/accounts/oauth/connections/",
1222
- ...options
1229
+ baseUrl;
1230
+ storage;
1231
+ locale;
1232
+ apiKey;
1233
+ logger;
1234
+ constructor(baseUrl2, opts = {}) {
1235
+ this.baseUrl = baseUrl2.replace(/\/$/, "");
1236
+ this.storage = opts.storage ?? new LocalStorageAdapter();
1237
+ this.logger = new APILogger(opts.logger);
1238
+ this.locale = opts.locale ?? null;
1239
+ this.apiKey = opts.apiKey ?? (typeof process !== "undefined" ? process.env?.NEXT_PUBLIC_API_KEY ?? null : null);
1240
+ const credentials = opts.withCredentials ?? true ? "include" : "same-origin";
1241
+ client.setConfig({ baseUrl: this.baseUrl, credentials });
1242
+ client.interceptors.request.use((request) => {
1243
+ const access = this.getToken();
1244
+ if (access) request.headers.set("Authorization", `Bearer ${access}`);
1245
+ const locale = this.locale ?? detectLocale();
1246
+ if (locale) request.headers.set("Accept-Language", locale);
1247
+ if (this.apiKey) request.headers.set("X-API-Key", this.apiKey);
1248
+ return request;
1223
1249
  });
1224
1250
  }
1225
- /**
1226
- * Disconnect OAuth provider
1227
- *
1228
- * Remove OAuth connection for the specified provider.
1229
- */
1230
- static cfgAccountsOauthDisconnectCreate(options) {
1231
- return (options.client ?? client).post({
1232
- security: [{ scheme: "bearer", type: "http" }],
1233
- url: "/cfg/accounts/oauth/disconnect/",
1234
- ...options,
1235
- headers: {
1236
- "Content-Type": "application/json",
1237
- ...options.headers
1238
- }
1239
- });
1251
+ // ── Base URL ────────────────────────────────────────────────────────────
1252
+ getBaseUrl() {
1253
+ return this.baseUrl;
1240
1254
  }
1241
- /**
1242
- * Start GitHub OAuth
1243
- *
1244
- * Generate GitHub OAuth authorization URL. Redirect user to this URL to start authentication.
1245
- */
1246
- static cfgAccountsOauthGithubAuthorizeCreate(options) {
1247
- return (options?.client ?? client).post({
1248
- url: "/cfg/accounts/oauth/github/authorize/",
1249
- ...options,
1250
- headers: {
1251
- "Content-Type": "application/json",
1252
- ...options?.headers
1253
- }
1254
- });
1255
+ setBaseUrl(url) {
1256
+ this.baseUrl = url.replace(/\/$/, "");
1257
+ client.setConfig({ baseUrl: this.baseUrl });
1255
1258
  }
1256
- /**
1257
- * Complete GitHub OAuth
1258
- *
1259
- * Exchange authorization code for JWT tokens. Call this after GitHub redirects back with code.
1260
- */
1261
- static cfgAccountsOauthGithubCallbackCreate(options) {
1262
- return (options.client ?? client).post({
1263
- url: "/cfg/accounts/oauth/github/callback/",
1264
- ...options,
1265
- headers: {
1266
- "Content-Type": "application/json",
1267
- ...options.headers
1268
- }
1269
- });
1259
+ // ── Tokens ──────────────────────────────────────────────────────────────
1260
+ getToken() {
1261
+ return this.storage.getItem(ACCESS_KEY);
1270
1262
  }
1271
- /**
1272
- * List OAuth providers
1273
- *
1274
- * Get list of available OAuth providers for authentication.
1275
- */
1276
- static cfgAccountsOauthProvidersRetrieve(options) {
1277
- return (options?.client ?? client).get({ url: "/cfg/accounts/oauth/providers/", ...options });
1263
+ setToken(token) {
1264
+ if (token) this.storage.setItem(ACCESS_KEY, token);
1265
+ else this.storage.removeItem(ACCESS_KEY);
1278
1266
  }
1279
- /**
1280
- * Request OTP code to email.
1281
- */
1282
- static cfgAccountsOtpRequestCreate(options) {
1283
- return (options.client ?? client).post({
1284
- security: [{ scheme: "bearer", type: "http" }],
1285
- url: "/cfg/accounts/otp/request/",
1286
- ...options,
1287
- headers: {
1288
- "Content-Type": "application/json",
1289
- ...options.headers
1290
- }
1291
- });
1267
+ getRefreshToken() {
1268
+ return this.storage.getItem(REFRESH_KEY);
1292
1269
  }
1293
- /**
1294
- * Verify OTP code and return JWT tokens or 2FA session.
1295
- *
1296
- * If user has 2FA enabled:
1297
- * - Returns requires_2fa=True with session_id
1298
- * - Client must complete 2FA verification at /cfg/totp/verify/
1299
- *
1300
- * If user has no 2FA:
1301
- * - Returns JWT tokens and user data directly
1302
- */
1303
- static cfgAccountsOtpVerifyCreate(options) {
1304
- return (options.client ?? client).post({
1305
- security: [{ scheme: "bearer", type: "http" }],
1306
- url: "/cfg/accounts/otp/verify/",
1307
- ...options,
1308
- headers: {
1309
- "Content-Type": "application/json",
1310
- ...options.headers
1311
- }
1312
- });
1270
+ setRefreshToken(token) {
1271
+ if (token) this.storage.setItem(REFRESH_KEY, token);
1272
+ else this.storage.removeItem(REFRESH_KEY);
1313
1273
  }
1314
- /**
1315
- * Get current user profile
1316
- *
1317
- * Retrieve the current authenticated user's profile information.
1318
- */
1319
- static cfgAccountsProfileRetrieve(options) {
1320
- return (options?.client ?? client).get({
1321
- security: [{ scheme: "bearer", type: "http" }, {
1322
- in: "cookie",
1323
- name: "sessionid",
1324
- type: "apiKey"
1325
- }],
1326
- url: "/cfg/accounts/profile/",
1327
- ...options
1328
- });
1274
+ clearToken() {
1275
+ this.storage.removeItem(ACCESS_KEY);
1276
+ this.storage.removeItem(REFRESH_KEY);
1329
1277
  }
1330
- /**
1331
- * Upload user avatar
1332
- *
1333
- * Upload avatar image for the current authenticated user. Accepts multipart/form-data with 'avatar' field.
1334
- */
1335
- static cfgAccountsProfileAvatarCreate(options) {
1336
- return (options?.client ?? client).post({
1337
- ...formDataBodySerializer,
1338
- security: [{ scheme: "bearer", type: "http" }],
1339
- url: "/cfg/accounts/profile/avatar/",
1340
- ...options,
1341
- headers: {
1342
- "Content-Type": null,
1343
- ...options?.headers
1344
- }
1345
- });
1278
+ isAuthenticated() {
1279
+ return this.getToken() !== null;
1346
1280
  }
1347
- /**
1348
- * Delete user account
1349
- *
1350
- *
1351
- * Permanently delete the current user's account.
1352
- *
1353
- * This operation:
1354
- * - Deactivates the account (user cannot log in)
1355
- * - Anonymizes personal data (GDPR compliance)
1356
- * - Frees up the email address for re-registration
1357
- * - Preserves audit trail
1358
- *
1359
- * The account can be restored by an administrator if needed.
1360
- *
1361
- */
1362
- static cfgAccountsProfileDeleteCreate(options) {
1363
- return (options?.client ?? client).post({
1364
- security: [{ scheme: "bearer", type: "http" }, {
1365
- in: "cookie",
1366
- name: "sessionid",
1367
- type: "apiKey"
1368
- }],
1369
- url: "/cfg/accounts/profile/delete/",
1370
- ...options
1371
- });
1281
+ // ── Locale / API key ────────────────────────────────────────────────────
1282
+ getLocale() {
1283
+ return this.locale ?? detectLocale();
1372
1284
  }
1373
- /**
1374
- * Partial update user profile
1375
- *
1376
- * Partially update the current authenticated user's profile information. Supports avatar upload.
1377
- */
1378
- static cfgAccountsProfilePartialPartialUpdate(options) {
1379
- return (options?.client ?? client).patch({
1380
- security: [{ scheme: "bearer", type: "http" }, {
1381
- in: "cookie",
1382
- name: "sessionid",
1383
- type: "apiKey"
1384
- }],
1385
- url: "/cfg/accounts/profile/partial/",
1386
- ...options,
1387
- headers: {
1388
- "Content-Type": "application/json",
1389
- ...options?.headers
1390
- }
1391
- });
1285
+ setLocale(locale) {
1286
+ this.locale = locale;
1392
1287
  }
1393
- /**
1394
- * Partial update user profile
1395
- *
1396
- * Partially update the current authenticated user's profile information. Supports avatar upload.
1397
- */
1398
- static cfgAccountsProfilePartialUpdate(options) {
1399
- return (options?.client ?? client).put({
1400
- security: [{ scheme: "bearer", type: "http" }, {
1401
- in: "cookie",
1402
- name: "sessionid",
1403
- type: "apiKey"
1404
- }],
1405
- url: "/cfg/accounts/profile/partial/",
1406
- ...options,
1407
- headers: {
1408
- "Content-Type": "application/json",
1409
- ...options?.headers
1410
- }
1411
- });
1288
+ getApiKey() {
1289
+ return this.apiKey;
1412
1290
  }
1413
- /**
1414
- * Update user profile
1415
- *
1416
- * Update the current authenticated user's profile information.
1417
- */
1418
- static cfgAccountsProfileUpdatePartialUpdate(options) {
1419
- return (options?.client ?? client).patch({
1420
- security: [{ scheme: "bearer", type: "http" }, {
1421
- in: "cookie",
1422
- name: "sessionid",
1423
- type: "apiKey"
1424
- }],
1425
- url: "/cfg/accounts/profile/update/",
1426
- ...options,
1427
- headers: {
1428
- "Content-Type": "application/json",
1429
- ...options?.headers
1430
- }
1431
- });
1432
- }
1433
- /**
1434
- * Update user profile
1435
- *
1436
- * Update the current authenticated user's profile information.
1437
- */
1438
- static cfgAccountsProfileUpdateUpdate(options) {
1439
- return (options?.client ?? client).put({
1440
- security: [{ scheme: "bearer", type: "http" }, {
1441
- in: "cookie",
1442
- name: "sessionid",
1443
- type: "apiKey"
1444
- }],
1445
- url: "/cfg/accounts/profile/update/",
1446
- ...options,
1447
- headers: {
1448
- "Content-Type": "application/json",
1449
- ...options?.headers
1450
- }
1451
- });
1452
- }
1453
- /**
1454
- * Refresh JWT token.
1455
- */
1456
- static cfgAccountsTokenRefreshCreate(options) {
1457
- return (options.client ?? client).post({
1458
- url: "/cfg/accounts/token/refresh/",
1459
- ...options,
1460
- headers: {
1461
- "Content-Type": "application/json",
1462
- ...options.headers
1463
- }
1464
- });
1291
+ setApiKey(key) {
1292
+ this.apiKey = key;
1465
1293
  }
1466
1294
  };
1467
- var Accounts = class {
1295
+
1296
+ // src/_api/generated/helpers/errors.ts
1297
+ var APIError = class extends Error {
1298
+ constructor(statusCode, statusText, response, url, message) {
1299
+ super(message || `HTTP ${statusCode}: ${statusText}`);
1300
+ this.statusCode = statusCode;
1301
+ this.statusText = statusText;
1302
+ this.response = response;
1303
+ this.url = url;
1304
+ this.name = "APIError";
1305
+ }
1468
1306
  static {
1469
- __name(this, "Accounts");
1307
+ __name(this, "APIError");
1470
1308
  }
1471
- /**
1472
- * List OAuth connections
1473
- *
1474
- * Get all OAuth connections for the current user.
1475
- */
1476
- static cfgAccountsOauthConnectionsList(options) {
1477
- return (options?.client ?? client).get({
1478
- security: [{ scheme: "bearer", type: "http" }],
1479
- url: "/cfg/accounts/oauth/connections/",
1480
- ...options
1481
- });
1309
+ get details() {
1310
+ if (typeof this.response === "object" && this.response !== null) {
1311
+ return this.response;
1312
+ }
1313
+ return null;
1482
1314
  }
1483
- /**
1484
- * Disconnect OAuth provider
1485
- *
1486
- * Remove OAuth connection for the specified provider.
1487
- */
1488
- static cfgAccountsOauthDisconnectCreate(options) {
1489
- return (options.client ?? client).post({
1490
- security: [{ scheme: "bearer", type: "http" }],
1491
- url: "/cfg/accounts/oauth/disconnect/",
1492
- ...options,
1493
- headers: {
1494
- "Content-Type": "application/json",
1495
- ...options.headers
1496
- }
1497
- });
1315
+ get fieldErrors() {
1316
+ const details = this.details;
1317
+ if (!details) return null;
1318
+ const fieldErrors = {};
1319
+ for (const [key, value] of Object.entries(details)) {
1320
+ if (Array.isArray(value)) fieldErrors[key] = value;
1321
+ }
1322
+ return Object.keys(fieldErrors).length > 0 ? fieldErrors : null;
1498
1323
  }
1499
- /**
1500
- * Start GitHub OAuth
1501
- *
1502
- * Generate GitHub OAuth authorization URL. Redirect user to this URL to start authentication.
1503
- */
1504
- static cfgAccountsOauthGithubAuthorizeCreate(options) {
1505
- return (options?.client ?? client).post({
1506
- url: "/cfg/accounts/oauth/github/authorize/",
1507
- ...options,
1508
- headers: {
1509
- "Content-Type": "application/json",
1510
- ...options?.headers
1511
- }
1512
- });
1324
+ get errorMessage() {
1325
+ const details = this.details;
1326
+ if (!details) return this.message;
1327
+ if (details.detail) {
1328
+ return Array.isArray(details.detail) ? details.detail.join(", ") : String(details.detail);
1329
+ }
1330
+ if (details.error) return String(details.error);
1331
+ if (details.message) return String(details.message);
1332
+ const fieldErrors = this.fieldErrors;
1333
+ if (fieldErrors) {
1334
+ const firstField = Object.keys(fieldErrors)[0];
1335
+ if (firstField) return `${firstField}: ${fieldErrors[firstField]?.join(", ")}`;
1336
+ }
1337
+ return this.message;
1513
1338
  }
1514
- /**
1515
- * Complete GitHub OAuth
1516
- *
1517
- * Exchange authorization code for JWT tokens. Call this after GitHub redirects back with code.
1518
- */
1519
- static cfgAccountsOauthGithubCallbackCreate(options) {
1520
- return (options.client ?? client).post({
1521
- url: "/cfg/accounts/oauth/github/callback/",
1522
- ...options,
1523
- headers: {
1524
- "Content-Type": "application/json",
1525
- ...options.headers
1526
- }
1527
- });
1339
+ get isValidationError() {
1340
+ return this.statusCode === 400;
1528
1341
  }
1529
- /**
1530
- * List OAuth providers
1531
- *
1532
- * Get list of available OAuth providers for authentication.
1533
- */
1534
- static cfgAccountsOauthProvidersRetrieve(options) {
1535
- return (options?.client ?? client).get({ url: "/cfg/accounts/oauth/providers/", ...options });
1342
+ get isAuthError() {
1343
+ return this.statusCode === 401;
1536
1344
  }
1537
- /**
1538
- * Request OTP code to email.
1539
- */
1540
- static cfgAccountsOtpRequestCreate(options) {
1541
- return (options.client ?? client).post({
1542
- security: [{ scheme: "bearer", type: "http" }],
1543
- url: "/cfg/accounts/otp/request/",
1544
- ...options,
1545
- headers: {
1546
- "Content-Type": "application/json",
1547
- ...options.headers
1548
- }
1549
- });
1345
+ get isPermissionError() {
1346
+ return this.statusCode === 403;
1550
1347
  }
1551
- /**
1552
- * Verify OTP code and return JWT tokens or 2FA session.
1553
- *
1554
- * If user has 2FA enabled:
1555
- * - Returns requires_2fa=True with session_id
1556
- * - Client must complete 2FA verification at /cfg/totp/verify/
1557
- *
1558
- * If user has no 2FA:
1559
- * - Returns JWT tokens and user data directly
1560
- */
1561
- static cfgAccountsOtpVerifyCreate(options) {
1562
- return (options.client ?? client).post({
1563
- security: [{ scheme: "bearer", type: "http" }],
1564
- url: "/cfg/accounts/otp/verify/",
1565
- ...options,
1566
- headers: {
1567
- "Content-Type": "application/json",
1568
- ...options.headers
1569
- }
1570
- });
1348
+ get isNotFoundError() {
1349
+ return this.statusCode === 404;
1571
1350
  }
1572
- /**
1573
- * Get current user profile
1574
- *
1575
- * Retrieve the current authenticated user's profile information.
1576
- */
1577
- static cfgAccountsProfileRetrieve(options) {
1578
- return (options?.client ?? client).get({
1579
- security: [{ scheme: "bearer", type: "http" }, {
1580
- in: "cookie",
1581
- name: "sessionid",
1582
- type: "apiKey"
1583
- }],
1584
- url: "/cfg/accounts/profile/",
1585
- ...options
1586
- });
1351
+ get isServerError() {
1352
+ return this.statusCode >= 500 && this.statusCode < 600;
1587
1353
  }
1588
- /**
1589
- * Upload user avatar
1590
- *
1591
- * Upload avatar image for the current authenticated user. Accepts multipart/form-data with 'avatar' field.
1592
- */
1593
- static cfgAccountsProfileAvatarCreate(options) {
1594
- return (options?.client ?? client).post({
1595
- ...formDataBodySerializer,
1596
- security: [{ scheme: "bearer", type: "http" }],
1597
- url: "/cfg/accounts/profile/avatar/",
1598
- ...options,
1599
- headers: {
1600
- "Content-Type": null,
1601
- ...options?.headers
1602
- }
1603
- });
1354
+ };
1355
+
1356
+ // src/_api/generated/_cfg_centrifugo/api.ts
1357
+ var ACCESS_KEY2 = "cfg.access_token";
1358
+ var REFRESH_KEY2 = "cfg.refresh_token";
1359
+ function detectLocale2() {
1360
+ try {
1361
+ if (typeof document !== "undefined") {
1362
+ const m = document.cookie.match(/(?:^|;\s*)NEXT_LOCALE=([^;]*)/);
1363
+ if (m) return decodeURIComponent(m[1]);
1364
+ }
1365
+ if (typeof navigator !== "undefined" && navigator.language) {
1366
+ return navigator.language;
1367
+ }
1368
+ } catch {
1604
1369
  }
1605
- /**
1606
- * Delete user account
1607
- *
1608
- *
1609
- * Permanently delete the current user's account.
1610
- *
1611
- * This operation:
1612
- * - Deactivates the account (user cannot log in)
1613
- * - Anonymizes personal data (GDPR compliance)
1614
- * - Frees up the email address for re-registration
1615
- * - Preserves audit trail
1616
- *
1617
- * The account can be restored by an administrator if needed.
1618
- *
1619
- */
1620
- static cfgAccountsProfileDeleteCreate(options) {
1621
- return (options?.client ?? client).post({
1622
- security: [{ scheme: "bearer", type: "http" }, {
1623
- in: "cookie",
1624
- name: "sessionid",
1625
- type: "apiKey"
1626
- }],
1627
- url: "/cfg/accounts/profile/delete/",
1628
- ...options
1629
- });
1370
+ return null;
1371
+ }
1372
+ __name(detectLocale2, "detectLocale");
1373
+ var API2 = class {
1374
+ static {
1375
+ __name(this, "API");
1630
1376
  }
1631
- /**
1632
- * Partial update user profile
1633
- *
1634
- * Partially update the current authenticated user's profile information. Supports avatar upload.
1635
- */
1636
- static cfgAccountsProfilePartialPartialUpdate(options) {
1637
- return (options?.client ?? client).patch({
1638
- security: [{ scheme: "bearer", type: "http" }, {
1639
- in: "cookie",
1640
- name: "sessionid",
1641
- type: "apiKey"
1642
- }],
1643
- url: "/cfg/accounts/profile/partial/",
1644
- ...options,
1645
- headers: {
1646
- "Content-Type": "application/json",
1647
- ...options?.headers
1648
- }
1377
+ baseUrl;
1378
+ storage;
1379
+ locale;
1380
+ apiKey;
1381
+ logger;
1382
+ constructor(baseUrl2, opts = {}) {
1383
+ this.baseUrl = baseUrl2.replace(/\/$/, "");
1384
+ this.storage = opts.storage ?? new LocalStorageAdapter();
1385
+ this.logger = new APILogger(opts.logger);
1386
+ this.locale = opts.locale ?? null;
1387
+ this.apiKey = opts.apiKey ?? (typeof process !== "undefined" ? process.env?.NEXT_PUBLIC_API_KEY ?? null : null);
1388
+ const credentials = opts.withCredentials ?? true ? "include" : "same-origin";
1389
+ client.setConfig({ baseUrl: this.baseUrl, credentials });
1390
+ client.interceptors.request.use((request) => {
1391
+ const access = this.getToken();
1392
+ if (access) request.headers.set("Authorization", `Bearer ${access}`);
1393
+ const locale = this.locale ?? detectLocale2();
1394
+ if (locale) request.headers.set("Accept-Language", locale);
1395
+ if (this.apiKey) request.headers.set("X-API-Key", this.apiKey);
1396
+ return request;
1649
1397
  });
1650
1398
  }
1651
- /**
1652
- * Partial update user profile
1653
- *
1654
- * Partially update the current authenticated user's profile information. Supports avatar upload.
1655
- */
1656
- static cfgAccountsProfilePartialUpdate(options) {
1657
- return (options?.client ?? client).put({
1658
- security: [{ scheme: "bearer", type: "http" }, {
1659
- in: "cookie",
1660
- name: "sessionid",
1661
- type: "apiKey"
1662
- }],
1663
- url: "/cfg/accounts/profile/partial/",
1664
- ...options,
1665
- headers: {
1666
- "Content-Type": "application/json",
1667
- ...options?.headers
1668
- }
1669
- });
1399
+ // ── Base URL ────────────────────────────────────────────────────────────
1400
+ getBaseUrl() {
1401
+ return this.baseUrl;
1670
1402
  }
1671
- /**
1672
- * Update user profile
1673
- *
1674
- * Update the current authenticated user's profile information.
1675
- */
1676
- static cfgAccountsProfileUpdatePartialUpdate(options) {
1677
- return (options?.client ?? client).patch({
1678
- security: [{ scheme: "bearer", type: "http" }, {
1679
- in: "cookie",
1680
- name: "sessionid",
1681
- type: "apiKey"
1682
- }],
1683
- url: "/cfg/accounts/profile/update/",
1684
- ...options,
1685
- headers: {
1686
- "Content-Type": "application/json",
1687
- ...options?.headers
1688
- }
1689
- });
1403
+ setBaseUrl(url) {
1404
+ this.baseUrl = url.replace(/\/$/, "");
1405
+ client.setConfig({ baseUrl: this.baseUrl });
1690
1406
  }
1691
- /**
1692
- * Update user profile
1693
- *
1694
- * Update the current authenticated user's profile information.
1695
- */
1696
- static cfgAccountsProfileUpdateUpdate(options) {
1697
- return (options?.client ?? client).put({
1698
- security: [{ scheme: "bearer", type: "http" }, {
1699
- in: "cookie",
1700
- name: "sessionid",
1701
- type: "apiKey"
1702
- }],
1703
- url: "/cfg/accounts/profile/update/",
1704
- ...options,
1705
- headers: {
1706
- "Content-Type": "application/json",
1707
- ...options?.headers
1708
- }
1709
- });
1407
+ // ── Tokens ──────────────────────────────────────────────────────────────
1408
+ getToken() {
1409
+ return this.storage.getItem(ACCESS_KEY2);
1710
1410
  }
1711
- /**
1712
- * Refresh JWT token.
1713
- */
1714
- static cfgAccountsTokenRefreshCreate(options) {
1715
- return (options.client ?? client).post({
1716
- url: "/cfg/accounts/token/refresh/",
1717
- ...options,
1718
- headers: {
1719
- "Content-Type": "application/json",
1720
- ...options.headers
1721
- }
1411
+ setToken(token) {
1412
+ if (token) this.storage.setItem(ACCESS_KEY2, token);
1413
+ else this.storage.removeItem(ACCESS_KEY2);
1414
+ }
1415
+ getRefreshToken() {
1416
+ return this.storage.getItem(REFRESH_KEY2);
1417
+ }
1418
+ setRefreshToken(token) {
1419
+ if (token) this.storage.setItem(REFRESH_KEY2, token);
1420
+ else this.storage.removeItem(REFRESH_KEY2);
1421
+ }
1422
+ clearToken() {
1423
+ this.storage.removeItem(ACCESS_KEY2);
1424
+ this.storage.removeItem(REFRESH_KEY2);
1425
+ }
1426
+ isAuthenticated() {
1427
+ return this.getToken() !== null;
1428
+ }
1429
+ // ── Locale / API key ────────────────────────────────────────────────────
1430
+ getLocale() {
1431
+ return this.locale ?? detectLocale2();
1432
+ }
1433
+ setLocale(locale) {
1434
+ this.locale = locale;
1435
+ }
1436
+ getApiKey() {
1437
+ return this.apiKey;
1438
+ }
1439
+ setApiKey(key) {
1440
+ this.apiKey = key;
1441
+ }
1442
+ };
1443
+
1444
+ // src/_api/generated/_cfg_totp/api.ts
1445
+ var ACCESS_KEY3 = "cfg.access_token";
1446
+ var REFRESH_KEY3 = "cfg.refresh_token";
1447
+ function detectLocale3() {
1448
+ try {
1449
+ if (typeof document !== "undefined") {
1450
+ const m = document.cookie.match(/(?:^|;\s*)NEXT_LOCALE=([^;]*)/);
1451
+ if (m) return decodeURIComponent(m[1]);
1452
+ }
1453
+ if (typeof navigator !== "undefined" && navigator.language) {
1454
+ return navigator.language;
1455
+ }
1456
+ } catch {
1457
+ }
1458
+ return null;
1459
+ }
1460
+ __name(detectLocale3, "detectLocale");
1461
+ var API3 = class {
1462
+ static {
1463
+ __name(this, "API");
1464
+ }
1465
+ baseUrl;
1466
+ storage;
1467
+ locale;
1468
+ apiKey;
1469
+ logger;
1470
+ constructor(baseUrl2, opts = {}) {
1471
+ this.baseUrl = baseUrl2.replace(/\/$/, "");
1472
+ this.storage = opts.storage ?? new LocalStorageAdapter();
1473
+ this.logger = new APILogger(opts.logger);
1474
+ this.locale = opts.locale ?? null;
1475
+ this.apiKey = opts.apiKey ?? (typeof process !== "undefined" ? process.env?.NEXT_PUBLIC_API_KEY ?? null : null);
1476
+ const credentials = opts.withCredentials ?? true ? "include" : "same-origin";
1477
+ client.setConfig({ baseUrl: this.baseUrl, credentials });
1478
+ client.interceptors.request.use((request) => {
1479
+ const access = this.getToken();
1480
+ if (access) request.headers.set("Authorization", `Bearer ${access}`);
1481
+ const locale = this.locale ?? detectLocale3();
1482
+ if (locale) request.headers.set("Accept-Language", locale);
1483
+ if (this.apiKey) request.headers.set("X-API-Key", this.apiKey);
1484
+ return request;
1722
1485
  });
1723
1486
  }
1487
+ // ── Base URL ────────────────────────────────────────────────────────────
1488
+ getBaseUrl() {
1489
+ return this.baseUrl;
1490
+ }
1491
+ setBaseUrl(url) {
1492
+ this.baseUrl = url.replace(/\/$/, "");
1493
+ client.setConfig({ baseUrl: this.baseUrl });
1494
+ }
1495
+ // ── Tokens ──────────────────────────────────────────────────────────────
1496
+ getToken() {
1497
+ return this.storage.getItem(ACCESS_KEY3);
1498
+ }
1499
+ setToken(token) {
1500
+ if (token) this.storage.setItem(ACCESS_KEY3, token);
1501
+ else this.storage.removeItem(ACCESS_KEY3);
1502
+ }
1503
+ getRefreshToken() {
1504
+ return this.storage.getItem(REFRESH_KEY3);
1505
+ }
1506
+ setRefreshToken(token) {
1507
+ if (token) this.storage.setItem(REFRESH_KEY3, token);
1508
+ else this.storage.removeItem(REFRESH_KEY3);
1509
+ }
1510
+ clearToken() {
1511
+ this.storage.removeItem(ACCESS_KEY3);
1512
+ this.storage.removeItem(REFRESH_KEY3);
1513
+ }
1514
+ isAuthenticated() {
1515
+ return this.getToken() !== null;
1516
+ }
1517
+ // ── Locale / API key ────────────────────────────────────────────────────
1518
+ getLocale() {
1519
+ return this.locale ?? detectLocale3();
1520
+ }
1521
+ setLocale(locale) {
1522
+ this.locale = locale;
1523
+ }
1524
+ getApiKey() {
1525
+ return this.apiKey;
1526
+ }
1527
+ setApiKey(key) {
1528
+ this.apiKey = key;
1529
+ }
1724
1530
  };
1725
- var OAuth = class {
1531
+
1532
+ // src/_api/generated/index.ts
1533
+ var isStaticBuild2 = process.env.NEXT_PUBLIC_STATIC_BUILD === "true";
1534
+ var baseUrl = isStaticBuild2 ? "" : process.env.NEXT_PUBLIC_API_URL || "";
1535
+ var CfgAccountsApi = new API(baseUrl, { storage: new LocalStorageAdapter() });
1536
+ var CfgCentrifugoApi = new API2(baseUrl, { storage: new LocalStorageAdapter() });
1537
+ var CfgTotpApi = new API3(baseUrl, { storage: new LocalStorageAdapter() });
1538
+
1539
+ // src/_api/generated/sdk.gen.ts
1540
+ var Cfg = class {
1726
1541
  static {
1727
- __name(this, "OAuth");
1542
+ __name(this, "Cfg");
1728
1543
  }
1729
1544
  /**
1730
1545
  * List OAuth connections
@@ -1777,2395 +1592,49 @@ var OAuth = class {
1777
1592
  static cfgAccountsOauthGithubCallbackCreate(options) {
1778
1593
  return (options.client ?? client).post({
1779
1594
  url: "/cfg/accounts/oauth/github/callback/",
1780
- ...options,
1781
- headers: {
1782
- "Content-Type": "application/json",
1783
- ...options.headers
1784
- }
1785
- });
1786
- }
1787
- /**
1788
- * List OAuth providers
1789
- *
1790
- * Get list of available OAuth providers for authentication.
1791
- */
1792
- static cfgAccountsOauthProvidersRetrieve(options) {
1793
- return (options?.client ?? client).get({ url: "/cfg/accounts/oauth/providers/", ...options });
1794
- }
1795
- };
1796
- var UserProfile = class {
1797
- static {
1798
- __name(this, "UserProfile");
1799
- }
1800
- /**
1801
- * Get current user profile
1802
- *
1803
- * Retrieve the current authenticated user's profile information.
1804
- */
1805
- static cfgAccountsProfileRetrieve(options) {
1806
- return (options?.client ?? client).get({
1807
- security: [{ scheme: "bearer", type: "http" }, {
1808
- in: "cookie",
1809
- name: "sessionid",
1810
- type: "apiKey"
1811
- }],
1812
- url: "/cfg/accounts/profile/",
1813
- ...options
1814
- });
1815
- }
1816
- /**
1817
- * Upload user avatar
1818
- *
1819
- * Upload avatar image for the current authenticated user. Accepts multipart/form-data with 'avatar' field.
1820
- */
1821
- static cfgAccountsProfileAvatarCreate(options) {
1822
- return (options?.client ?? client).post({
1823
- ...formDataBodySerializer,
1824
- security: [{ scheme: "bearer", type: "http" }],
1825
- url: "/cfg/accounts/profile/avatar/",
1826
- ...options,
1827
- headers: {
1828
- "Content-Type": null,
1829
- ...options?.headers
1830
- }
1831
- });
1832
- }
1833
- /**
1834
- * Delete user account
1835
- *
1836
- *
1837
- * Permanently delete the current user's account.
1838
- *
1839
- * This operation:
1840
- * - Deactivates the account (user cannot log in)
1841
- * - Anonymizes personal data (GDPR compliance)
1842
- * - Frees up the email address for re-registration
1843
- * - Preserves audit trail
1844
- *
1845
- * The account can be restored by an administrator if needed.
1846
- *
1847
- */
1848
- static cfgAccountsProfileDeleteCreate(options) {
1849
- return (options?.client ?? client).post({
1850
- security: [{ scheme: "bearer", type: "http" }, {
1851
- in: "cookie",
1852
- name: "sessionid",
1853
- type: "apiKey"
1854
- }],
1855
- url: "/cfg/accounts/profile/delete/",
1856
- ...options
1857
- });
1858
- }
1859
- /**
1860
- * Partial update user profile
1861
- *
1862
- * Partially update the current authenticated user's profile information. Supports avatar upload.
1863
- */
1864
- static cfgAccountsProfilePartialPartialUpdate(options) {
1865
- return (options?.client ?? client).patch({
1866
- security: [{ scheme: "bearer", type: "http" }, {
1867
- in: "cookie",
1868
- name: "sessionid",
1869
- type: "apiKey"
1870
- }],
1871
- url: "/cfg/accounts/profile/partial/",
1872
- ...options,
1873
- headers: {
1874
- "Content-Type": "application/json",
1875
- ...options?.headers
1876
- }
1877
- });
1878
- }
1879
- /**
1880
- * Partial update user profile
1881
- *
1882
- * Partially update the current authenticated user's profile information. Supports avatar upload.
1883
- */
1884
- static cfgAccountsProfilePartialUpdate(options) {
1885
- return (options?.client ?? client).put({
1886
- security: [{ scheme: "bearer", type: "http" }, {
1887
- in: "cookie",
1888
- name: "sessionid",
1889
- type: "apiKey"
1890
- }],
1891
- url: "/cfg/accounts/profile/partial/",
1892
- ...options,
1893
- headers: {
1894
- "Content-Type": "application/json",
1895
- ...options?.headers
1896
- }
1897
- });
1898
- }
1899
- /**
1900
- * Update user profile
1901
- *
1902
- * Update the current authenticated user's profile information.
1903
- */
1904
- static cfgAccountsProfileUpdatePartialUpdate(options) {
1905
- return (options?.client ?? client).patch({
1906
- security: [{ scheme: "bearer", type: "http" }, {
1907
- in: "cookie",
1908
- name: "sessionid",
1909
- type: "apiKey"
1910
- }],
1911
- url: "/cfg/accounts/profile/update/",
1912
- ...options,
1913
- headers: {
1914
- "Content-Type": "application/json",
1915
- ...options?.headers
1916
- }
1917
- });
1918
- }
1919
- /**
1920
- * Update user profile
1921
- *
1922
- * Update the current authenticated user's profile information.
1923
- */
1924
- static cfgAccountsProfileUpdateUpdate(options) {
1925
- return (options?.client ?? client).put({
1926
- security: [{ scheme: "bearer", type: "http" }, {
1927
- in: "cookie",
1928
- name: "sessionid",
1929
- type: "apiKey"
1930
- }],
1931
- url: "/cfg/accounts/profile/update/",
1932
- ...options,
1933
- headers: {
1934
- "Content-Type": "application/json",
1935
- ...options?.headers
1936
- }
1937
- });
1938
- }
1939
- };
1940
- var Auth = class {
1941
- static {
1942
- __name(this, "Auth");
1943
- }
1944
- /**
1945
- * Refresh JWT token.
1946
- */
1947
- static cfgAccountsTokenRefreshCreate(options) {
1948
- return (options.client ?? client).post({
1949
- url: "/cfg/accounts/token/refresh/",
1950
- ...options,
1951
- headers: {
1952
- "Content-Type": "application/json",
1953
- ...options.headers
1954
- }
1955
- });
1956
- }
1957
- };
1958
-
1959
- // src/_api/generated/cfg_accounts/schemas/AccountDeleteResponse.ts
1960
- import { z } from "zod";
1961
- var AccountDeleteResponseSchema = z.object({
1962
- success: z.boolean(),
1963
- message: z.string()
1964
- });
1965
-
1966
- // src/_api/generated/cfg_accounts/schemas/CentrifugoToken.ts
1967
- import { z as z2 } from "zod";
1968
- var CentrifugoTokenSchema = z2.object({
1969
- token: z2.string(),
1970
- centrifugo_url: z2.string(),
1971
- expires_at: z2.string().datetime({ offset: true }),
1972
- channels: z2.array(z2.string())
1973
- });
1974
-
1975
- // src/_api/generated/cfg_accounts/schemas/CfgUserUpdateRequest.ts
1976
- import { z as z3 } from "zod";
1977
- var CfgUserUpdateRequestSchema = z3.object({
1978
- first_name: z3.string().max(50).optional(),
1979
- last_name: z3.string().max(50).optional(),
1980
- company: z3.string().max(100).optional(),
1981
- phone: z3.string().max(20).optional(),
1982
- position: z3.string().max(100).optional(),
1983
- language: z3.string().max(10).optional()
1984
- });
1985
-
1986
- // src/_api/generated/cfg_accounts/schemas/OAuthAuthorizeRequestRequest.ts
1987
- import { z as z4 } from "zod";
1988
- var OAuthAuthorizeRequestRequestSchema = z4.object({
1989
- redirect_uri: z4.string().optional(),
1990
- source_url: z4.string().optional()
1991
- });
1992
-
1993
- // src/_api/generated/cfg_accounts/schemas/OAuthAuthorizeResponse.ts
1994
- import { z as z5 } from "zod";
1995
- var OAuthAuthorizeResponseSchema = z5.object({
1996
- authorization_url: z5.string(),
1997
- state: z5.string()
1998
- });
1999
-
2000
- // src/_api/generated/cfg_accounts/schemas/OAuthCallbackRequestRequest.ts
2001
- import { z as z6 } from "zod";
2002
- var OAuthCallbackRequestRequestSchema = z6.object({
2003
- code: z6.string().min(10).max(500),
2004
- state: z6.string().min(20).max(100),
2005
- redirect_uri: z6.string().optional()
2006
- });
2007
-
2008
- // src/_api/generated/cfg_accounts/schemas/OAuthConnection.ts
2009
- import { z as z8 } from "zod";
2010
-
2011
- // src/_api/generated/cfg_accounts/schemas/ProviderEnum.ts
2012
- import { z as z7 } from "zod";
2013
- var ProviderEnumSchema = z7.enum(["github"]);
2014
-
2015
- // src/_api/generated/cfg_accounts/schemas/OAuthConnection.ts
2016
- var OAuthConnectionSchema = z8.object({
2017
- id: z8.number().int(),
2018
- provider: ProviderEnumSchema,
2019
- provider_display: z8.string(),
2020
- provider_username: z8.string(),
2021
- provider_email: z8.email(),
2022
- provider_avatar_url: z8.string(),
2023
- connected_at: z8.string().datetime({ offset: true }),
2024
- last_login_at: z8.string().datetime({ offset: true })
2025
- });
2026
-
2027
- // src/_api/generated/cfg_accounts/schemas/OAuthDisconnectRequestRequest.ts
2028
- import { z as z9 } from "zod";
2029
- var OAuthDisconnectRequestRequestSchema = z9.object({
2030
- provider: ProviderEnumSchema
2031
- });
2032
-
2033
- // src/_api/generated/cfg_accounts/schemas/OAuthError.ts
2034
- import { z as z10 } from "zod";
2035
- var OAuthErrorSchema = z10.object({
2036
- error: z10.string(),
2037
- error_description: z10.string().optional()
2038
- });
2039
-
2040
- // src/_api/generated/cfg_accounts/schemas/OAuthProvidersResponse.ts
2041
- import { z as z11 } from "zod";
2042
- var OAuthProvidersResponseSchema = z11.object({
2043
- providers: z11.array(z11.object({}))
2044
- });
2045
-
2046
- // src/_api/generated/cfg_accounts/schemas/OAuthTokenResponse.ts
2047
- import { z as z12 } from "zod";
2048
- var OAuthTokenResponseSchema = z12.object({
2049
- requires_2fa: z12.boolean().optional(),
2050
- session_id: z12.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(),
2051
- access: z12.string().nullable().optional(),
2052
- refresh: z12.string().nullable().optional(),
2053
- user: z12.object({}).nullable().optional(),
2054
- is_new_user: z12.boolean(),
2055
- is_new_connection: z12.boolean(),
2056
- should_prompt_2fa: z12.boolean().optional()
2057
- });
2058
-
2059
- // src/_api/generated/cfg_accounts/schemas/OTPErrorResponse.ts
2060
- import { z as z13 } from "zod";
2061
- var OTPErrorResponseSchema = z13.object({
2062
- error: z13.string(),
2063
- error_code: z13.string().nullable().optional(),
2064
- retry_after: z13.number().int().nullable().optional()
2065
- });
2066
-
2067
- // src/_api/generated/cfg_accounts/schemas/OTPRequestRequest.ts
2068
- import { z as z14 } from "zod";
2069
- var OTPRequestRequestSchema = z14.object({
2070
- identifier: z14.string().min(1),
2071
- source_url: z14.string().optional()
2072
- });
2073
-
2074
- // src/_api/generated/cfg_accounts/schemas/OTPRequestResponse.ts
2075
- import { z as z15 } from "zod";
2076
- var OTPRequestResponseSchema = z15.object({
2077
- message: z15.string()
2078
- });
2079
-
2080
- // src/_api/generated/cfg_accounts/schemas/OTPVerifyRequest.ts
2081
- import { z as z16 } from "zod";
2082
- var OTPVerifyRequestSchema = z16.object({
2083
- identifier: z16.string().min(1),
2084
- otp: z16.string().min(6).max(6),
2085
- source_url: z16.string().optional()
2086
- });
2087
-
2088
- // src/_api/generated/cfg_accounts/schemas/OTPVerifyResponse.ts
2089
- import { z as z18 } from "zod";
2090
-
2091
- // src/_api/generated/cfg_accounts/schemas/User.ts
2092
- import { z as z17 } from "zod";
2093
- var UserSchema = z17.object({
2094
- id: z17.number().int(),
2095
- email: z17.email(),
2096
- first_name: z17.string().max(50).optional(),
2097
- last_name: z17.string().max(50).optional(),
2098
- full_name: z17.string(),
2099
- initials: z17.string(),
2100
- display_username: z17.string(),
2101
- company: z17.string().max(100).optional(),
2102
- phone: z17.string().max(20).optional(),
2103
- position: z17.string().max(100).optional(),
2104
- language: z17.string().max(10).optional(),
2105
- avatar: z17.string().nullable(),
2106
- is_staff: z17.boolean(),
2107
- is_superuser: z17.boolean(),
2108
- date_joined: z17.string().datetime({ offset: true }),
2109
- last_login: z17.string().datetime({ offset: true }).nullable(),
2110
- unanswered_messages_count: z17.number().int(),
2111
- centrifugo: CentrifugoTokenSchema.nullable()
2112
- });
2113
-
2114
- // src/_api/generated/cfg_accounts/schemas/OTPVerifyResponse.ts
2115
- var OTPVerifyResponseSchema = z18.object({
2116
- requires_2fa: z18.boolean().optional(),
2117
- session_id: z18.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(),
2118
- refresh: z18.string().nullable().optional(),
2119
- access: z18.string().nullable().optional(),
2120
- user: UserSchema.nullable().optional(),
2121
- should_prompt_2fa: z18.boolean().optional()
2122
- });
2123
-
2124
- // src/_api/generated/cfg_accounts/schemas/PatchedCfgUserUpdateRequest.ts
2125
- import { z as z19 } from "zod";
2126
- var PatchedCfgUserUpdateRequestSchema = z19.object({
2127
- first_name: z19.string().max(50).optional(),
2128
- last_name: z19.string().max(50).optional(),
2129
- company: z19.string().max(100).optional(),
2130
- phone: z19.string().max(20).optional(),
2131
- position: z19.string().max(100).optional(),
2132
- language: z19.string().max(10).optional()
2133
- });
2134
-
2135
- // src/_api/generated/cfg_accounts/schemas/TokenRefresh.ts
2136
- import { z as z20 } from "zod";
2137
- var TokenRefreshSchema = z20.object({
2138
- access: z20.string(),
2139
- refresh: z20.string()
2140
- });
2141
-
2142
- // src/_api/generated/cfg_accounts/schemas/TokenRefreshRequest.ts
2143
- import { z as z21 } from "zod";
2144
- var TokenRefreshRequestSchema = z21.object({
2145
- refresh: z21.string().min(1)
2146
- });
2147
-
2148
- // src/_api/generated/_shared/validation-events.ts
2149
- function dispatchValidationError(detail) {
2150
- if (typeof window === "undefined") return;
2151
- try {
2152
- const event = new CustomEvent("zod-validation-error", {
2153
- detail,
2154
- bubbles: true,
2155
- cancelable: false
2156
- });
2157
- window.dispatchEvent(event);
2158
- } catch (error) {
2159
- console.warn("Failed to dispatch validation error event:", error);
2160
- }
2161
- }
2162
- __name(dispatchValidationError, "dispatchValidationError");
2163
-
2164
- // src/_api/generated/cfg_accounts/api.ts
2165
- var ACCESS_KEY = "cfg.access_token";
2166
- var REFRESH_KEY = "cfg.refresh_token";
2167
- var VALIDATION_ROUTES = [
2168
- { method: "POST", re: new RegExp("^/cfg/accounts/oauth/github/authorize/?$"), schema: OAuthAuthorizeResponseSchema, path: "/cfg/accounts/oauth/github/authorize/" },
2169
- { method: "POST", re: new RegExp("^/cfg/accounts/oauth/github/callback/?$"), schema: OAuthTokenResponseSchema, path: "/cfg/accounts/oauth/github/callback/" },
2170
- { method: "GET", re: new RegExp("^/cfg/accounts/oauth/providers/?$"), schema: OAuthProvidersResponseSchema, path: "/cfg/accounts/oauth/providers/" },
2171
- { method: "POST", re: new RegExp("^/cfg/accounts/otp/request/?$"), schema: OTPRequestResponseSchema, path: "/cfg/accounts/otp/request/" },
2172
- { method: "POST", re: new RegExp("^/cfg/accounts/otp/verify/?$"), schema: OTPVerifyResponseSchema, path: "/cfg/accounts/otp/verify/" },
2173
- { method: "GET", re: new RegExp("^/cfg/accounts/profile/?$"), schema: UserSchema, path: "/cfg/accounts/profile/" },
2174
- { method: "POST", re: new RegExp("^/cfg/accounts/profile/avatar/?$"), schema: UserSchema, path: "/cfg/accounts/profile/avatar/" },
2175
- { method: "POST", re: new RegExp("^/cfg/accounts/profile/delete/?$"), schema: AccountDeleteResponseSchema, path: "/cfg/accounts/profile/delete/" },
2176
- { method: "PUT", re: new RegExp("^/cfg/accounts/profile/partial/?$"), schema: UserSchema, path: "/cfg/accounts/profile/partial/" },
2177
- { method: "PATCH", re: new RegExp("^/cfg/accounts/profile/partial/?$"), schema: UserSchema, path: "/cfg/accounts/profile/partial/" },
2178
- { method: "PUT", re: new RegExp("^/cfg/accounts/profile/update/?$"), schema: UserSchema, path: "/cfg/accounts/profile/update/" },
2179
- { method: "PATCH", re: new RegExp("^/cfg/accounts/profile/update/?$"), schema: UserSchema, path: "/cfg/accounts/profile/update/" },
2180
- { method: "POST", re: new RegExp("^/cfg/accounts/token/refresh/?$"), schema: TokenRefreshSchema, path: "/cfg/accounts/token/refresh/" }
2181
- ];
2182
- function detectLocale() {
2183
- try {
2184
- if (typeof document !== "undefined") {
2185
- const m = document.cookie.match(/(?:^|;\s*)NEXT_LOCALE=([^;]*)/);
2186
- if (m) return decodeURIComponent(m[1]);
2187
- }
2188
- if (typeof navigator !== "undefined" && navigator.language) {
2189
- return navigator.language;
2190
- }
2191
- } catch {
2192
- }
2193
- return null;
2194
- }
2195
- __name(detectLocale, "detectLocale");
2196
- var API = class {
2197
- static {
2198
- __name(this, "API");
2199
- }
2200
- baseUrl;
2201
- storage;
2202
- locale;
2203
- apiKey;
2204
- logger;
2205
- cfg = Cfg;
2206
- accounts = Accounts;
2207
- oAuth = OAuth;
2208
- userProfile = UserProfile;
2209
- auth = Auth;
2210
- constructor(baseUrl2, opts = {}) {
2211
- this.baseUrl = baseUrl2.replace(/\/$/, "");
2212
- this.storage = opts.storage ?? new LocalStorageAdapter();
2213
- this.logger = new APILogger(opts.logger);
2214
- this.locale = opts.locale ?? null;
2215
- this.apiKey = opts.apiKey ?? (typeof process !== "undefined" ? process.env?.NEXT_PUBLIC_API_KEY ?? null : null);
2216
- const credentials = opts.withCredentials ?? true ? "include" : "same-origin";
2217
- client.setConfig({ baseUrl: this.baseUrl, credentials });
2218
- client.interceptors.request.use((request) => {
2219
- const access = this.getToken();
2220
- if (access) request.headers.set("Authorization", `Bearer ${access}`);
2221
- const locale = this.locale ?? detectLocale();
2222
- if (locale) request.headers.set("Accept-Language", locale);
2223
- if (this.apiKey) request.headers.set("X-API-Key", this.apiKey);
2224
- return request;
2225
- });
2226
- client.interceptors.response.use(async (response, request) => {
2227
- if (!response.ok) return response;
2228
- const ct = response.headers.get("content-type") || "";
2229
- if (!ct.includes("application/json")) return response;
2230
- const url = new URL(request.url);
2231
- const method = request.method.toUpperCase();
2232
- const route = VALIDATION_ROUTES.find(
2233
- (r) => r.method === method && r.re.test(url.pathname)
2234
- );
2235
- if (!route) return response;
2236
- let payload;
2237
- try {
2238
- payload = await response.clone().json();
2239
- } catch {
2240
- return response;
2241
- }
2242
- const result = route.schema.safeParse(payload);
2243
- if (!result.success) {
2244
- dispatchValidationError({
2245
- operation: `${method} ${route.path}`,
2246
- path: route.path,
2247
- method,
2248
- error: result.error,
2249
- response: payload,
2250
- timestamp: /* @__PURE__ */ new Date()
2251
- });
2252
- }
2253
- return response;
2254
- });
2255
- }
2256
- // ── Base URL ────────────────────────────────────────────────────────────
2257
- getBaseUrl() {
2258
- return this.baseUrl;
2259
- }
2260
- setBaseUrl(url) {
2261
- this.baseUrl = url.replace(/\/$/, "");
2262
- client.setConfig({ baseUrl: this.baseUrl });
2263
- }
2264
- // ── Tokens ──────────────────────────────────────────────────────────────
2265
- getToken() {
2266
- return this.storage.getItem(ACCESS_KEY);
2267
- }
2268
- setToken(token) {
2269
- if (token) this.storage.setItem(ACCESS_KEY, token);
2270
- else this.storage.removeItem(ACCESS_KEY);
2271
- }
2272
- getRefreshToken() {
2273
- return this.storage.getItem(REFRESH_KEY);
2274
- }
2275
- setRefreshToken(token) {
2276
- if (token) this.storage.setItem(REFRESH_KEY, token);
2277
- else this.storage.removeItem(REFRESH_KEY);
2278
- }
2279
- clearToken() {
2280
- this.storage.removeItem(ACCESS_KEY);
2281
- this.storage.removeItem(REFRESH_KEY);
2282
- }
2283
- isAuthenticated() {
2284
- return this.getToken() !== null;
2285
- }
2286
- // ── Locale / API key ────────────────────────────────────────────────────
2287
- getLocale() {
2288
- return this.locale ?? detectLocale();
2289
- }
2290
- setLocale(locale) {
2291
- this.locale = locale;
2292
- }
2293
- getApiKey() {
2294
- return this.apiKey;
2295
- }
2296
- setApiKey(key) {
2297
- this.apiKey = key;
2298
- }
2299
- };
2300
-
2301
- // src/_api/generated/_shared/errors.ts
2302
- var APIError = class extends Error {
2303
- constructor(statusCode, statusText, response, url, message) {
2304
- super(message || `HTTP ${statusCode}: ${statusText}`);
2305
- this.statusCode = statusCode;
2306
- this.statusText = statusText;
2307
- this.response = response;
2308
- this.url = url;
2309
- this.name = "APIError";
2310
- }
2311
- static {
2312
- __name(this, "APIError");
2313
- }
2314
- get details() {
2315
- if (typeof this.response === "object" && this.response !== null) {
2316
- return this.response;
2317
- }
2318
- return null;
2319
- }
2320
- get fieldErrors() {
2321
- const details = this.details;
2322
- if (!details) return null;
2323
- const fieldErrors = {};
2324
- for (const [key, value] of Object.entries(details)) {
2325
- if (Array.isArray(value)) fieldErrors[key] = value;
2326
- }
2327
- return Object.keys(fieldErrors).length > 0 ? fieldErrors : null;
2328
- }
2329
- get errorMessage() {
2330
- const details = this.details;
2331
- if (!details) return this.message;
2332
- if (details.detail) {
2333
- return Array.isArray(details.detail) ? details.detail.join(", ") : String(details.detail);
2334
- }
2335
- if (details.error) return String(details.error);
2336
- if (details.message) return String(details.message);
2337
- const fieldErrors = this.fieldErrors;
2338
- if (fieldErrors) {
2339
- const firstField = Object.keys(fieldErrors)[0];
2340
- if (firstField) return `${firstField}: ${fieldErrors[firstField]?.join(", ")}`;
2341
- }
2342
- return this.message;
2343
- }
2344
- get isValidationError() {
2345
- return this.statusCode === 400;
2346
- }
2347
- get isAuthError() {
2348
- return this.statusCode === 401;
2349
- }
2350
- get isPermissionError() {
2351
- return this.statusCode === 403;
2352
- }
2353
- get isNotFoundError() {
2354
- return this.statusCode === 404;
2355
- }
2356
- get isServerError() {
2357
- return this.statusCode >= 500 && this.statusCode < 600;
2358
- }
2359
- };
2360
-
2361
- // src/_api/generated/cfg_centrifugo/core/bodySerializer.gen.ts
2362
- var jsonBodySerializer2 = {
2363
- bodySerializer: /* @__PURE__ */ __name((body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value), "bodySerializer")
2364
- };
2365
-
2366
- // src/_api/generated/cfg_centrifugo/core/params.gen.ts
2367
- var extraPrefixesMap2 = {
2368
- $body_: "body",
2369
- $headers_: "headers",
2370
- $path_: "path",
2371
- $query_: "query"
2372
- };
2373
- var extraPrefixes2 = Object.entries(extraPrefixesMap2);
2374
-
2375
- // src/_api/generated/cfg_centrifugo/core/serverSentEvents.gen.ts
2376
- function createSseClient2({
2377
- onRequest,
2378
- onSseError,
2379
- onSseEvent,
2380
- responseTransformer,
2381
- responseValidator,
2382
- sseDefaultRetryDelay,
2383
- sseMaxRetryAttempts,
2384
- sseMaxRetryDelay,
2385
- sseSleepFn,
2386
- url,
2387
- ...options
2388
- }) {
2389
- let lastEventId;
2390
- const sleep = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
2391
- const createStream = /* @__PURE__ */ __name(async function* () {
2392
- let retryDelay = sseDefaultRetryDelay ?? 3e3;
2393
- let attempt = 0;
2394
- const signal = options.signal ?? new AbortController().signal;
2395
- while (true) {
2396
- if (signal.aborted) break;
2397
- attempt++;
2398
- const headers = options.headers instanceof Headers ? options.headers : new Headers(options.headers);
2399
- if (lastEventId !== void 0) {
2400
- headers.set("Last-Event-ID", lastEventId);
2401
- }
2402
- try {
2403
- const requestInit = {
2404
- redirect: "follow",
2405
- ...options,
2406
- body: options.serializedBody,
2407
- headers,
2408
- signal
2409
- };
2410
- let request = new Request(url, requestInit);
2411
- if (onRequest) {
2412
- request = await onRequest(url, requestInit);
2413
- }
2414
- const _fetch = options.fetch ?? globalThis.fetch;
2415
- const response = await _fetch(request);
2416
- if (!response.ok) throw new Error(`SSE failed: ${response.status} ${response.statusText}`);
2417
- if (!response.body) throw new Error("No body in SSE response");
2418
- const reader = response.body.pipeThrough(new TextDecoderStream()).getReader();
2419
- let buffer = "";
2420
- const abortHandler = /* @__PURE__ */ __name(() => {
2421
- try {
2422
- reader.cancel();
2423
- } catch {
2424
- }
2425
- }, "abortHandler");
2426
- signal.addEventListener("abort", abortHandler);
2427
- try {
2428
- while (true) {
2429
- const { done, value } = await reader.read();
2430
- if (done) break;
2431
- buffer += value;
2432
- buffer = buffer.replace(/\r\n?/g, "\n");
2433
- const chunks = buffer.split("\n\n");
2434
- buffer = chunks.pop() ?? "";
2435
- for (const chunk of chunks) {
2436
- const lines = chunk.split("\n");
2437
- const dataLines = [];
2438
- let eventName;
2439
- for (const line of lines) {
2440
- if (line.startsWith("data:")) {
2441
- dataLines.push(line.replace(/^data:\s*/, ""));
2442
- } else if (line.startsWith("event:")) {
2443
- eventName = line.replace(/^event:\s*/, "");
2444
- } else if (line.startsWith("id:")) {
2445
- lastEventId = line.replace(/^id:\s*/, "");
2446
- } else if (line.startsWith("retry:")) {
2447
- const parsed = Number.parseInt(line.replace(/^retry:\s*/, ""), 10);
2448
- if (!Number.isNaN(parsed)) {
2449
- retryDelay = parsed;
2450
- }
2451
- }
2452
- }
2453
- let data;
2454
- let parsedJson = false;
2455
- if (dataLines.length) {
2456
- const rawData = dataLines.join("\n");
2457
- try {
2458
- data = JSON.parse(rawData);
2459
- parsedJson = true;
2460
- } catch {
2461
- data = rawData;
2462
- }
2463
- }
2464
- if (parsedJson) {
2465
- if (responseValidator) {
2466
- await responseValidator(data);
2467
- }
2468
- if (responseTransformer) {
2469
- data = await responseTransformer(data);
2470
- }
2471
- }
2472
- onSseEvent?.({
2473
- data,
2474
- event: eventName,
2475
- id: lastEventId,
2476
- retry: retryDelay
2477
- });
2478
- if (dataLines.length) {
2479
- yield data;
2480
- }
2481
- }
2482
- }
2483
- } finally {
2484
- signal.removeEventListener("abort", abortHandler);
2485
- reader.releaseLock();
2486
- }
2487
- break;
2488
- } catch (error) {
2489
- onSseError?.(error);
2490
- if (sseMaxRetryAttempts !== void 0 && attempt >= sseMaxRetryAttempts) {
2491
- break;
2492
- }
2493
- const backoff = Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 3e4);
2494
- await sleep(backoff);
2495
- }
2496
- }
2497
- }, "createStream");
2498
- const stream = createStream();
2499
- return { stream };
2500
- }
2501
- __name(createSseClient2, "createSseClient");
2502
-
2503
- // src/_api/generated/cfg_centrifugo/core/pathSerializer.gen.ts
2504
- var separatorArrayExplode2 = /* @__PURE__ */ __name((style) => {
2505
- switch (style) {
2506
- case "label":
2507
- return ".";
2508
- case "matrix":
2509
- return ";";
2510
- case "simple":
2511
- return ",";
2512
- default:
2513
- return "&";
2514
- }
2515
- }, "separatorArrayExplode");
2516
- var separatorArrayNoExplode2 = /* @__PURE__ */ __name((style) => {
2517
- switch (style) {
2518
- case "form":
2519
- return ",";
2520
- case "pipeDelimited":
2521
- return "|";
2522
- case "spaceDelimited":
2523
- return "%20";
2524
- default:
2525
- return ",";
2526
- }
2527
- }, "separatorArrayNoExplode");
2528
- var separatorObjectExplode2 = /* @__PURE__ */ __name((style) => {
2529
- switch (style) {
2530
- case "label":
2531
- return ".";
2532
- case "matrix":
2533
- return ";";
2534
- case "simple":
2535
- return ",";
2536
- default:
2537
- return "&";
2538
- }
2539
- }, "separatorObjectExplode");
2540
- var serializeArrayParam2 = /* @__PURE__ */ __name(({
2541
- allowReserved,
2542
- explode,
2543
- name,
2544
- style,
2545
- value
2546
- }) => {
2547
- if (!explode) {
2548
- const joinedValues2 = (allowReserved ? value : value.map((v) => encodeURIComponent(v))).join(separatorArrayNoExplode2(style));
2549
- switch (style) {
2550
- case "label":
2551
- return `.${joinedValues2}`;
2552
- case "matrix":
2553
- return `;${name}=${joinedValues2}`;
2554
- case "simple":
2555
- return joinedValues2;
2556
- default:
2557
- return `${name}=${joinedValues2}`;
2558
- }
2559
- }
2560
- const separator = separatorArrayExplode2(style);
2561
- const joinedValues = value.map((v) => {
2562
- if (style === "label" || style === "simple") {
2563
- return allowReserved ? v : encodeURIComponent(v);
2564
- }
2565
- return serializePrimitiveParam2({
2566
- allowReserved,
2567
- name,
2568
- value: v
2569
- });
2570
- }).join(separator);
2571
- return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
2572
- }, "serializeArrayParam");
2573
- var serializePrimitiveParam2 = /* @__PURE__ */ __name(({
2574
- allowReserved,
2575
- name,
2576
- value
2577
- }) => {
2578
- if (value === void 0 || value === null) {
2579
- return "";
2580
- }
2581
- if (typeof value === "object") {
2582
- throw new Error(
2583
- "Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these."
2584
- );
2585
- }
2586
- return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
2587
- }, "serializePrimitiveParam");
2588
- var serializeObjectParam2 = /* @__PURE__ */ __name(({
2589
- allowReserved,
2590
- explode,
2591
- name,
2592
- style,
2593
- value,
2594
- valueOnly
2595
- }) => {
2596
- if (value instanceof Date) {
2597
- return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
2598
- }
2599
- if (style !== "deepObject" && !explode) {
2600
- let values = [];
2601
- Object.entries(value).forEach(([key, v]) => {
2602
- values = [...values, key, allowReserved ? v : encodeURIComponent(v)];
2603
- });
2604
- const joinedValues2 = values.join(",");
2605
- switch (style) {
2606
- case "form":
2607
- return `${name}=${joinedValues2}`;
2608
- case "label":
2609
- return `.${joinedValues2}`;
2610
- case "matrix":
2611
- return `;${name}=${joinedValues2}`;
2612
- default:
2613
- return joinedValues2;
2614
- }
2615
- }
2616
- const separator = separatorObjectExplode2(style);
2617
- const joinedValues = Object.entries(value).map(
2618
- ([key, v]) => serializePrimitiveParam2({
2619
- allowReserved,
2620
- name: style === "deepObject" ? `${name}[${key}]` : key,
2621
- value: v
2622
- })
2623
- ).join(separator);
2624
- return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
2625
- }, "serializeObjectParam");
2626
-
2627
- // src/_api/generated/cfg_centrifugo/core/utils.gen.ts
2628
- var PATH_PARAM_RE2 = /\{[^{}]+\}/g;
2629
- var defaultPathSerializer2 = /* @__PURE__ */ __name(({ path, url: _url }) => {
2630
- let url = _url;
2631
- const matches = _url.match(PATH_PARAM_RE2);
2632
- if (matches) {
2633
- for (const match of matches) {
2634
- let explode = false;
2635
- let name = match.substring(1, match.length - 1);
2636
- let style = "simple";
2637
- if (name.endsWith("*")) {
2638
- explode = true;
2639
- name = name.substring(0, name.length - 1);
2640
- }
2641
- if (name.startsWith(".")) {
2642
- name = name.substring(1);
2643
- style = "label";
2644
- } else if (name.startsWith(";")) {
2645
- name = name.substring(1);
2646
- style = "matrix";
2647
- }
2648
- const value = path[name];
2649
- if (value === void 0 || value === null) {
2650
- continue;
2651
- }
2652
- if (Array.isArray(value)) {
2653
- url = url.replace(match, serializeArrayParam2({ explode, name, style, value }));
2654
- continue;
2655
- }
2656
- if (typeof value === "object") {
2657
- url = url.replace(
2658
- match,
2659
- serializeObjectParam2({
2660
- explode,
2661
- name,
2662
- style,
2663
- value,
2664
- valueOnly: true
2665
- })
2666
- );
2667
- continue;
2668
- }
2669
- if (style === "matrix") {
2670
- url = url.replace(
2671
- match,
2672
- `;${serializePrimitiveParam2({
2673
- name,
2674
- value
2675
- })}`
2676
- );
2677
- continue;
2678
- }
2679
- const replaceValue = encodeURIComponent(
2680
- style === "label" ? `.${value}` : value
2681
- );
2682
- url = url.replace(match, replaceValue);
2683
- }
2684
- }
2685
- return url;
2686
- }, "defaultPathSerializer");
2687
- var getUrl2 = /* @__PURE__ */ __name(({
2688
- baseUrl: baseUrl2,
2689
- path,
2690
- query,
2691
- querySerializer,
2692
- url: _url
2693
- }) => {
2694
- const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
2695
- let url = (baseUrl2 ?? "") + pathUrl;
2696
- if (path) {
2697
- url = defaultPathSerializer2({ path, url });
2698
- }
2699
- let search = query ? querySerializer(query) : "";
2700
- if (search.startsWith("?")) {
2701
- search = search.substring(1);
2702
- }
2703
- if (search) {
2704
- url += `?${search}`;
2705
- }
2706
- return url;
2707
- }, "getUrl");
2708
- function getValidRequestBody2(options) {
2709
- const hasBody = options.body !== void 0;
2710
- const isSerializedBody = hasBody && options.bodySerializer;
2711
- if (isSerializedBody) {
2712
- if ("serializedBody" in options) {
2713
- const hasSerializedBody = options.serializedBody !== void 0 && options.serializedBody !== "";
2714
- return hasSerializedBody ? options.serializedBody : null;
2715
- }
2716
- return options.body !== "" ? options.body : null;
2717
- }
2718
- if (hasBody) {
2719
- return options.body;
2720
- }
2721
- return void 0;
2722
- }
2723
- __name(getValidRequestBody2, "getValidRequestBody");
2724
-
2725
- // src/_api/generated/cfg_centrifugo/core/auth.gen.ts
2726
- var getAuthToken2 = /* @__PURE__ */ __name(async (auth, callback) => {
2727
- const token = typeof callback === "function" ? await callback(auth) : callback;
2728
- if (!token) {
2729
- return;
2730
- }
2731
- if (auth.scheme === "bearer") {
2732
- return `Bearer ${token}`;
2733
- }
2734
- if (auth.scheme === "basic") {
2735
- return `Basic ${btoa(token)}`;
2736
- }
2737
- return token;
2738
- }, "getAuthToken");
2739
-
2740
- // src/_api/generated/cfg_centrifugo/client/utils.gen.ts
2741
- var createQuerySerializer2 = /* @__PURE__ */ __name(({
2742
- parameters = {},
2743
- ...args
2744
- } = {}) => {
2745
- const querySerializer = /* @__PURE__ */ __name((queryParams) => {
2746
- const search = [];
2747
- if (queryParams && typeof queryParams === "object") {
2748
- for (const name in queryParams) {
2749
- const value = queryParams[name];
2750
- if (value === void 0 || value === null) {
2751
- continue;
2752
- }
2753
- const options = parameters[name] || args;
2754
- if (Array.isArray(value)) {
2755
- const serializedArray = serializeArrayParam2({
2756
- allowReserved: options.allowReserved,
2757
- explode: true,
2758
- name,
2759
- style: "form",
2760
- value,
2761
- ...options.array
2762
- });
2763
- if (serializedArray) search.push(serializedArray);
2764
- } else if (typeof value === "object") {
2765
- const serializedObject = serializeObjectParam2({
2766
- allowReserved: options.allowReserved,
2767
- explode: true,
2768
- name,
2769
- style: "deepObject",
2770
- value,
2771
- ...options.object
2772
- });
2773
- if (serializedObject) search.push(serializedObject);
2774
- } else {
2775
- const serializedPrimitive = serializePrimitiveParam2({
2776
- allowReserved: options.allowReserved,
2777
- name,
2778
- value
2779
- });
2780
- if (serializedPrimitive) search.push(serializedPrimitive);
2781
- }
2782
- }
2783
- }
2784
- return search.join("&");
2785
- }, "querySerializer");
2786
- return querySerializer;
2787
- }, "createQuerySerializer");
2788
- var getParseAs2 = /* @__PURE__ */ __name((contentType) => {
2789
- if (!contentType) {
2790
- return "stream";
2791
- }
2792
- const cleanContent = contentType.split(";")[0]?.trim();
2793
- if (!cleanContent) {
2794
- return;
2795
- }
2796
- if (cleanContent.startsWith("application/json") || cleanContent.endsWith("+json")) {
2797
- return "json";
2798
- }
2799
- if (cleanContent === "multipart/form-data") {
2800
- return "formData";
2801
- }
2802
- if (["application/", "audio/", "image/", "video/"].some((type) => cleanContent.startsWith(type))) {
2803
- return "blob";
2804
- }
2805
- if (cleanContent.startsWith("text/")) {
2806
- return "text";
2807
- }
2808
- return;
2809
- }, "getParseAs");
2810
- var checkForExistence2 = /* @__PURE__ */ __name((options, name) => {
2811
- if (!name) {
2812
- return false;
2813
- }
2814
- if (options.headers.has(name) || options.query?.[name] || options.headers.get("Cookie")?.includes(`${name}=`)) {
2815
- return true;
2816
- }
2817
- return false;
2818
- }, "checkForExistence");
2819
- var setAuthParams2 = /* @__PURE__ */ __name(async ({
2820
- security,
2821
- ...options
2822
- }) => {
2823
- for (const auth of security) {
2824
- if (checkForExistence2(options, auth.name)) {
2825
- continue;
2826
- }
2827
- const token = await getAuthToken2(auth, options.auth);
2828
- if (!token) {
2829
- continue;
2830
- }
2831
- const name = auth.name ?? "Authorization";
2832
- switch (auth.in) {
2833
- case "query":
2834
- if (!options.query) {
2835
- options.query = {};
2836
- }
2837
- options.query[name] = token;
2838
- break;
2839
- case "cookie":
2840
- options.headers.append("Cookie", `${name}=${token}`);
2841
- break;
2842
- case "header":
2843
- default:
2844
- options.headers.set(name, token);
2845
- break;
2846
- }
2847
- }
2848
- }, "setAuthParams");
2849
- var buildUrl2 = /* @__PURE__ */ __name((options) => getUrl2({
2850
- baseUrl: options.baseUrl,
2851
- path: options.path,
2852
- query: options.query,
2853
- querySerializer: typeof options.querySerializer === "function" ? options.querySerializer : createQuerySerializer2(options.querySerializer),
2854
- url: options.url
2855
- }), "buildUrl");
2856
- var mergeConfigs2 = /* @__PURE__ */ __name((a, b) => {
2857
- const config = { ...a, ...b };
2858
- if (config.baseUrl?.endsWith("/")) {
2859
- config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
2860
- }
2861
- config.headers = mergeHeaders2(a.headers, b.headers);
2862
- return config;
2863
- }, "mergeConfigs");
2864
- var headersEntries2 = /* @__PURE__ */ __name((headers) => {
2865
- const entries = [];
2866
- headers.forEach((value, key) => {
2867
- entries.push([key, value]);
2868
- });
2869
- return entries;
2870
- }, "headersEntries");
2871
- var mergeHeaders2 = /* @__PURE__ */ __name((...headers) => {
2872
- const mergedHeaders = new Headers();
2873
- for (const header of headers) {
2874
- if (!header) {
2875
- continue;
2876
- }
2877
- const iterator = header instanceof Headers ? headersEntries2(header) : Object.entries(header);
2878
- for (const [key, value] of iterator) {
2879
- if (value === null) {
2880
- mergedHeaders.delete(key);
2881
- } else if (Array.isArray(value)) {
2882
- for (const v of value) {
2883
- mergedHeaders.append(key, v);
2884
- }
2885
- } else if (value !== void 0) {
2886
- mergedHeaders.set(
2887
- key,
2888
- typeof value === "object" ? JSON.stringify(value) : value
2889
- );
2890
- }
2891
- }
2892
- }
2893
- return mergedHeaders;
2894
- }, "mergeHeaders");
2895
- var Interceptors2 = class {
2896
- static {
2897
- __name(this, "Interceptors");
2898
- }
2899
- fns = [];
2900
- clear() {
2901
- this.fns = [];
2902
- }
2903
- eject(id) {
2904
- const index = this.getInterceptorIndex(id);
2905
- if (this.fns[index]) {
2906
- this.fns[index] = null;
2907
- }
2908
- }
2909
- exists(id) {
2910
- const index = this.getInterceptorIndex(id);
2911
- return Boolean(this.fns[index]);
2912
- }
2913
- getInterceptorIndex(id) {
2914
- if (typeof id === "number") {
2915
- return this.fns[id] ? id : -1;
2916
- }
2917
- return this.fns.indexOf(id);
2918
- }
2919
- update(id, fn) {
2920
- const index = this.getInterceptorIndex(id);
2921
- if (this.fns[index]) {
2922
- this.fns[index] = fn;
2923
- return id;
2924
- }
2925
- return false;
2926
- }
2927
- use(fn) {
2928
- this.fns.push(fn);
2929
- return this.fns.length - 1;
2930
- }
2931
- };
2932
- var createInterceptors2 = /* @__PURE__ */ __name(() => ({
2933
- error: new Interceptors2(),
2934
- request: new Interceptors2(),
2935
- response: new Interceptors2()
2936
- }), "createInterceptors");
2937
- var defaultQuerySerializer2 = createQuerySerializer2({
2938
- allowReserved: false,
2939
- array: {
2940
- explode: true,
2941
- style: "form"
2942
- },
2943
- object: {
2944
- explode: true,
2945
- style: "deepObject"
2946
- }
2947
- });
2948
- var defaultHeaders2 = {
2949
- "Content-Type": "application/json"
2950
- };
2951
- var createConfig2 = /* @__PURE__ */ __name((override = {}) => ({
2952
- ...jsonBodySerializer2,
2953
- headers: defaultHeaders2,
2954
- parseAs: "auto",
2955
- querySerializer: defaultQuerySerializer2,
2956
- ...override
2957
- }), "createConfig");
2958
-
2959
- // src/_api/generated/cfg_centrifugo/client/client.gen.ts
2960
- var createClient2 = /* @__PURE__ */ __name((config = {}) => {
2961
- let _config = mergeConfigs2(createConfig2(), config);
2962
- const getConfig = /* @__PURE__ */ __name(() => ({ ..._config }), "getConfig");
2963
- const setConfig = /* @__PURE__ */ __name((config2) => {
2964
- _config = mergeConfigs2(_config, config2);
2965
- return getConfig();
2966
- }, "setConfig");
2967
- const interceptors = createInterceptors2();
2968
- const beforeRequest = /* @__PURE__ */ __name(async (options) => {
2969
- const opts = {
2970
- ..._config,
2971
- ...options,
2972
- fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
2973
- headers: mergeHeaders2(_config.headers, options.headers),
2974
- serializedBody: void 0
2975
- };
2976
- if (opts.security) {
2977
- await setAuthParams2({
2978
- ...opts,
2979
- security: opts.security
2980
- });
2981
- }
2982
- if (opts.requestValidator) {
2983
- await opts.requestValidator(opts);
2984
- }
2985
- if (opts.body !== void 0 && opts.bodySerializer) {
2986
- opts.serializedBody = opts.bodySerializer(opts.body);
2987
- }
2988
- if (opts.body === void 0 || opts.serializedBody === "") {
2989
- opts.headers.delete("Content-Type");
2990
- }
2991
- const resolvedOpts = opts;
2992
- const url = buildUrl2(resolvedOpts);
2993
- return { opts: resolvedOpts, url };
2994
- }, "beforeRequest");
2995
- const request = /* @__PURE__ */ __name(async (options) => {
2996
- const throwOnError = options.throwOnError ?? _config.throwOnError;
2997
- const responseStyle = options.responseStyle ?? _config.responseStyle;
2998
- let request2;
2999
- let response;
3000
- try {
3001
- const { opts, url } = await beforeRequest(options);
3002
- const requestInit = {
3003
- redirect: "follow",
3004
- ...opts,
3005
- body: getValidRequestBody2(opts)
3006
- };
3007
- request2 = new Request(url, requestInit);
3008
- for (const fn of interceptors.request.fns) {
3009
- if (fn) {
3010
- request2 = await fn(request2, opts);
3011
- }
3012
- }
3013
- const _fetch = opts.fetch;
3014
- response = await _fetch(request2);
3015
- for (const fn of interceptors.response.fns) {
3016
- if (fn) {
3017
- response = await fn(response, request2, opts);
3018
- }
3019
- }
3020
- const result = {
3021
- request: request2,
3022
- response
3023
- };
3024
- if (response.ok) {
3025
- const parseAs = (opts.parseAs === "auto" ? getParseAs2(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
3026
- if (response.status === 204 || response.headers.get("Content-Length") === "0") {
3027
- let emptyData;
3028
- switch (parseAs) {
3029
- case "arrayBuffer":
3030
- case "blob":
3031
- case "text":
3032
- emptyData = await response[parseAs]();
3033
- break;
3034
- case "formData":
3035
- emptyData = new FormData();
3036
- break;
3037
- case "stream":
3038
- emptyData = response.body;
3039
- break;
3040
- case "json":
3041
- default:
3042
- emptyData = {};
3043
- break;
3044
- }
3045
- return opts.responseStyle === "data" ? emptyData : {
3046
- data: emptyData,
3047
- ...result
3048
- };
3049
- }
3050
- let data;
3051
- switch (parseAs) {
3052
- case "arrayBuffer":
3053
- case "blob":
3054
- case "formData":
3055
- case "text":
3056
- data = await response[parseAs]();
3057
- break;
3058
- case "json": {
3059
- const text = await response.text();
3060
- data = text ? JSON.parse(text) : {};
3061
- break;
3062
- }
3063
- case "stream":
3064
- return opts.responseStyle === "data" ? response.body : {
3065
- data: response.body,
3066
- ...result
3067
- };
3068
- }
3069
- if (parseAs === "json") {
3070
- if (opts.responseValidator) {
3071
- await opts.responseValidator(data);
3072
- }
3073
- if (opts.responseTransformer) {
3074
- data = await opts.responseTransformer(data);
3075
- }
3076
- }
3077
- return opts.responseStyle === "data" ? data : {
3078
- data,
3079
- ...result
3080
- };
3081
- }
3082
- const textError = await response.text();
3083
- let jsonError;
3084
- try {
3085
- jsonError = JSON.parse(textError);
3086
- } catch {
3087
- }
3088
- throw jsonError ?? textError;
3089
- } catch (error) {
3090
- let finalError = error;
3091
- for (const fn of interceptors.error.fns) {
3092
- if (fn) {
3093
- finalError = await fn(finalError, response, request2, options);
3094
- }
3095
- }
3096
- finalError = finalError || {};
3097
- if (throwOnError) {
3098
- throw finalError;
3099
- }
3100
- return responseStyle === "data" ? void 0 : {
3101
- error: finalError,
3102
- request: request2,
3103
- response
3104
- };
3105
- }
3106
- }, "request");
3107
- const makeMethodFn = /* @__PURE__ */ __name((method) => (options) => request({ ...options, method }), "makeMethodFn");
3108
- const makeSseFn = /* @__PURE__ */ __name((method) => async (options) => {
3109
- const { opts, url } = await beforeRequest(options);
3110
- return createSseClient2({
3111
- ...opts,
3112
- body: opts.body,
3113
- method,
3114
- onRequest: /* @__PURE__ */ __name(async (url2, init) => {
3115
- let request2 = new Request(url2, init);
3116
- for (const fn of interceptors.request.fns) {
3117
- if (fn) {
3118
- request2 = await fn(request2, opts);
3119
- }
3120
- }
3121
- return request2;
3122
- }, "onRequest"),
3123
- serializedBody: getValidRequestBody2(opts),
3124
- url
3125
- });
3126
- }, "makeSseFn");
3127
- const _buildUrl = /* @__PURE__ */ __name((options) => buildUrl2({ ..._config, ...options }), "_buildUrl");
3128
- return {
3129
- buildUrl: _buildUrl,
3130
- connect: makeMethodFn("CONNECT"),
3131
- delete: makeMethodFn("DELETE"),
3132
- get: makeMethodFn("GET"),
3133
- getConfig,
3134
- head: makeMethodFn("HEAD"),
3135
- interceptors,
3136
- options: makeMethodFn("OPTIONS"),
3137
- patch: makeMethodFn("PATCH"),
3138
- post: makeMethodFn("POST"),
3139
- put: makeMethodFn("PUT"),
3140
- request,
3141
- setConfig,
3142
- sse: {
3143
- connect: makeSseFn("CONNECT"),
3144
- delete: makeSseFn("DELETE"),
3145
- get: makeSseFn("GET"),
3146
- head: makeSseFn("HEAD"),
3147
- options: makeSseFn("OPTIONS"),
3148
- patch: makeSseFn("PATCH"),
3149
- post: makeSseFn("POST"),
3150
- put: makeSseFn("PUT"),
3151
- trace: makeSseFn("TRACE")
3152
- },
3153
- trace: makeMethodFn("TRACE")
3154
- };
3155
- }, "createClient");
3156
-
3157
- // src/_api/generated/cfg_centrifugo/client.gen.ts
3158
- var client2 = createClient2(createConfig2({ baseUrl: "http://localhost:8000" }));
3159
-
3160
- // src/_api/generated/cfg_centrifugo/sdk.gen.ts
3161
- var Cfg2 = class {
3162
- static {
3163
- __name(this, "Cfg");
3164
- }
3165
- /**
3166
- * Get Centrifugo connection token
3167
- *
3168
- * Generate JWT token for WebSocket connection to Centrifugo. Token includes user's allowed channels based on their permissions. Requires authentication.
3169
- */
3170
- static cfgCentrifugoAuthTokenRetrieve(options) {
3171
- return (options?.client ?? client2).get({
3172
- security: [{ scheme: "bearer", type: "http" }],
3173
- url: "/cfg/centrifugo/auth/token/",
3174
- ...options
3175
- });
3176
- }
3177
- };
3178
- var Centrifugo = class {
3179
- static {
3180
- __name(this, "Centrifugo");
3181
- }
3182
- /**
3183
- * Get Centrifugo connection token
3184
- *
3185
- * Generate JWT token for WebSocket connection to Centrifugo. Token includes user's allowed channels based on their permissions. Requires authentication.
3186
- */
3187
- static cfgCentrifugoAuthTokenRetrieve(options) {
3188
- return (options?.client ?? client2).get({
3189
- security: [{ scheme: "bearer", type: "http" }],
3190
- url: "/cfg/centrifugo/auth/token/",
3191
- ...options
3192
- });
3193
- }
3194
- };
3195
- var CentrifugoAuth = class {
3196
- static {
3197
- __name(this, "CentrifugoAuth");
3198
- }
3199
- /**
3200
- * Get Centrifugo connection token
3201
- *
3202
- * Generate JWT token for WebSocket connection to Centrifugo. Token includes user's allowed channels based on their permissions. Requires authentication.
3203
- */
3204
- static cfgCentrifugoAuthTokenRetrieve(options) {
3205
- return (options?.client ?? client2).get({
3206
- security: [{ scheme: "bearer", type: "http" }],
3207
- url: "/cfg/centrifugo/auth/token/",
3208
- ...options
3209
- });
3210
- }
3211
- };
3212
-
3213
- // src/_api/generated/cfg_centrifugo/schemas/ConnectionTokenResponse.ts
3214
- import { z as z22 } from "zod";
3215
- var ConnectionTokenResponseSchema = z22.object({
3216
- token: z22.string(),
3217
- centrifugo_url: z22.string(),
3218
- expires_at: z22.string(),
3219
- channels: z22.array(z22.string())
3220
- });
3221
-
3222
- // src/_api/generated/cfg_centrifugo/api.ts
3223
- var ACCESS_KEY2 = "cfg.access_token";
3224
- var REFRESH_KEY2 = "cfg.refresh_token";
3225
- var VALIDATION_ROUTES2 = [
3226
- { method: "GET", re: new RegExp("^/cfg/centrifugo/auth/token/?$"), schema: ConnectionTokenResponseSchema, path: "/cfg/centrifugo/auth/token/" }
3227
- ];
3228
- function detectLocale2() {
3229
- try {
3230
- if (typeof document !== "undefined") {
3231
- const m = document.cookie.match(/(?:^|;\s*)NEXT_LOCALE=([^;]*)/);
3232
- if (m) return decodeURIComponent(m[1]);
3233
- }
3234
- if (typeof navigator !== "undefined" && navigator.language) {
3235
- return navigator.language;
3236
- }
3237
- } catch {
3238
- }
3239
- return null;
3240
- }
3241
- __name(detectLocale2, "detectLocale");
3242
- var API2 = class {
3243
- static {
3244
- __name(this, "API");
3245
- }
3246
- baseUrl;
3247
- storage;
3248
- locale;
3249
- apiKey;
3250
- logger;
3251
- cfg = Cfg2;
3252
- centrifugo = Centrifugo;
3253
- centrifugoAuth = CentrifugoAuth;
3254
- constructor(baseUrl2, opts = {}) {
3255
- this.baseUrl = baseUrl2.replace(/\/$/, "");
3256
- this.storage = opts.storage ?? new LocalStorageAdapter();
3257
- this.logger = new APILogger(opts.logger);
3258
- this.locale = opts.locale ?? null;
3259
- this.apiKey = opts.apiKey ?? (typeof process !== "undefined" ? process.env?.NEXT_PUBLIC_API_KEY ?? null : null);
3260
- const credentials = opts.withCredentials ?? true ? "include" : "same-origin";
3261
- client2.setConfig({ baseUrl: this.baseUrl, credentials });
3262
- client2.interceptors.request.use((request) => {
3263
- const access = this.getToken();
3264
- if (access) request.headers.set("Authorization", `Bearer ${access}`);
3265
- const locale = this.locale ?? detectLocale2();
3266
- if (locale) request.headers.set("Accept-Language", locale);
3267
- if (this.apiKey) request.headers.set("X-API-Key", this.apiKey);
3268
- return request;
3269
- });
3270
- client2.interceptors.response.use(async (response, request) => {
3271
- if (!response.ok) return response;
3272
- const ct = response.headers.get("content-type") || "";
3273
- if (!ct.includes("application/json")) return response;
3274
- const url = new URL(request.url);
3275
- const method = request.method.toUpperCase();
3276
- const route = VALIDATION_ROUTES2.find(
3277
- (r) => r.method === method && r.re.test(url.pathname)
3278
- );
3279
- if (!route) return response;
3280
- let payload;
3281
- try {
3282
- payload = await response.clone().json();
3283
- } catch {
3284
- return response;
3285
- }
3286
- const result = route.schema.safeParse(payload);
3287
- if (!result.success) {
3288
- dispatchValidationError({
3289
- operation: `${method} ${route.path}`,
3290
- path: route.path,
3291
- method,
3292
- error: result.error,
3293
- response: payload,
3294
- timestamp: /* @__PURE__ */ new Date()
3295
- });
3296
- }
3297
- return response;
3298
- });
3299
- }
3300
- // ── Base URL ────────────────────────────────────────────────────────────
3301
- getBaseUrl() {
3302
- return this.baseUrl;
3303
- }
3304
- setBaseUrl(url) {
3305
- this.baseUrl = url.replace(/\/$/, "");
3306
- client2.setConfig({ baseUrl: this.baseUrl });
3307
- }
3308
- // ── Tokens ──────────────────────────────────────────────────────────────
3309
- getToken() {
3310
- return this.storage.getItem(ACCESS_KEY2);
3311
- }
3312
- setToken(token) {
3313
- if (token) this.storage.setItem(ACCESS_KEY2, token);
3314
- else this.storage.removeItem(ACCESS_KEY2);
3315
- }
3316
- getRefreshToken() {
3317
- return this.storage.getItem(REFRESH_KEY2);
3318
- }
3319
- setRefreshToken(token) {
3320
- if (token) this.storage.setItem(REFRESH_KEY2, token);
3321
- else this.storage.removeItem(REFRESH_KEY2);
3322
- }
3323
- clearToken() {
3324
- this.storage.removeItem(ACCESS_KEY2);
3325
- this.storage.removeItem(REFRESH_KEY2);
3326
- }
3327
- isAuthenticated() {
3328
- return this.getToken() !== null;
3329
- }
3330
- // ── Locale / API key ────────────────────────────────────────────────────
3331
- getLocale() {
3332
- return this.locale ?? detectLocale2();
3333
- }
3334
- setLocale(locale) {
3335
- this.locale = locale;
3336
- }
3337
- getApiKey() {
3338
- return this.apiKey;
3339
- }
3340
- setApiKey(key) {
3341
- this.apiKey = key;
3342
- }
3343
- };
3344
-
3345
- // src/_api/generated/cfg_totp/core/bodySerializer.gen.ts
3346
- var jsonBodySerializer3 = {
3347
- bodySerializer: /* @__PURE__ */ __name((body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value), "bodySerializer")
3348
- };
3349
-
3350
- // src/_api/generated/cfg_totp/core/params.gen.ts
3351
- var extraPrefixesMap3 = {
3352
- $body_: "body",
3353
- $headers_: "headers",
3354
- $path_: "path",
3355
- $query_: "query"
3356
- };
3357
- var extraPrefixes3 = Object.entries(extraPrefixesMap3);
3358
-
3359
- // src/_api/generated/cfg_totp/core/serverSentEvents.gen.ts
3360
- function createSseClient3({
3361
- onRequest,
3362
- onSseError,
3363
- onSseEvent,
3364
- responseTransformer,
3365
- responseValidator,
3366
- sseDefaultRetryDelay,
3367
- sseMaxRetryAttempts,
3368
- sseMaxRetryDelay,
3369
- sseSleepFn,
3370
- url,
3371
- ...options
3372
- }) {
3373
- let lastEventId;
3374
- const sleep = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
3375
- const createStream = /* @__PURE__ */ __name(async function* () {
3376
- let retryDelay = sseDefaultRetryDelay ?? 3e3;
3377
- let attempt = 0;
3378
- const signal = options.signal ?? new AbortController().signal;
3379
- while (true) {
3380
- if (signal.aborted) break;
3381
- attempt++;
3382
- const headers = options.headers instanceof Headers ? options.headers : new Headers(options.headers);
3383
- if (lastEventId !== void 0) {
3384
- headers.set("Last-Event-ID", lastEventId);
3385
- }
3386
- try {
3387
- const requestInit = {
3388
- redirect: "follow",
3389
- ...options,
3390
- body: options.serializedBody,
3391
- headers,
3392
- signal
3393
- };
3394
- let request = new Request(url, requestInit);
3395
- if (onRequest) {
3396
- request = await onRequest(url, requestInit);
3397
- }
3398
- const _fetch = options.fetch ?? globalThis.fetch;
3399
- const response = await _fetch(request);
3400
- if (!response.ok) throw new Error(`SSE failed: ${response.status} ${response.statusText}`);
3401
- if (!response.body) throw new Error("No body in SSE response");
3402
- const reader = response.body.pipeThrough(new TextDecoderStream()).getReader();
3403
- let buffer = "";
3404
- const abortHandler = /* @__PURE__ */ __name(() => {
3405
- try {
3406
- reader.cancel();
3407
- } catch {
3408
- }
3409
- }, "abortHandler");
3410
- signal.addEventListener("abort", abortHandler);
3411
- try {
3412
- while (true) {
3413
- const { done, value } = await reader.read();
3414
- if (done) break;
3415
- buffer += value;
3416
- buffer = buffer.replace(/\r\n?/g, "\n");
3417
- const chunks = buffer.split("\n\n");
3418
- buffer = chunks.pop() ?? "";
3419
- for (const chunk of chunks) {
3420
- const lines = chunk.split("\n");
3421
- const dataLines = [];
3422
- let eventName;
3423
- for (const line of lines) {
3424
- if (line.startsWith("data:")) {
3425
- dataLines.push(line.replace(/^data:\s*/, ""));
3426
- } else if (line.startsWith("event:")) {
3427
- eventName = line.replace(/^event:\s*/, "");
3428
- } else if (line.startsWith("id:")) {
3429
- lastEventId = line.replace(/^id:\s*/, "");
3430
- } else if (line.startsWith("retry:")) {
3431
- const parsed = Number.parseInt(line.replace(/^retry:\s*/, ""), 10);
3432
- if (!Number.isNaN(parsed)) {
3433
- retryDelay = parsed;
3434
- }
3435
- }
3436
- }
3437
- let data;
3438
- let parsedJson = false;
3439
- if (dataLines.length) {
3440
- const rawData = dataLines.join("\n");
3441
- try {
3442
- data = JSON.parse(rawData);
3443
- parsedJson = true;
3444
- } catch {
3445
- data = rawData;
3446
- }
3447
- }
3448
- if (parsedJson) {
3449
- if (responseValidator) {
3450
- await responseValidator(data);
3451
- }
3452
- if (responseTransformer) {
3453
- data = await responseTransformer(data);
3454
- }
3455
- }
3456
- onSseEvent?.({
3457
- data,
3458
- event: eventName,
3459
- id: lastEventId,
3460
- retry: retryDelay
3461
- });
3462
- if (dataLines.length) {
3463
- yield data;
3464
- }
3465
- }
3466
- }
3467
- } finally {
3468
- signal.removeEventListener("abort", abortHandler);
3469
- reader.releaseLock();
3470
- }
3471
- break;
3472
- } catch (error) {
3473
- onSseError?.(error);
3474
- if (sseMaxRetryAttempts !== void 0 && attempt >= sseMaxRetryAttempts) {
3475
- break;
3476
- }
3477
- const backoff = Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 3e4);
3478
- await sleep(backoff);
3479
- }
3480
- }
3481
- }, "createStream");
3482
- const stream = createStream();
3483
- return { stream };
3484
- }
3485
- __name(createSseClient3, "createSseClient");
3486
-
3487
- // src/_api/generated/cfg_totp/core/pathSerializer.gen.ts
3488
- var separatorArrayExplode3 = /* @__PURE__ */ __name((style) => {
3489
- switch (style) {
3490
- case "label":
3491
- return ".";
3492
- case "matrix":
3493
- return ";";
3494
- case "simple":
3495
- return ",";
3496
- default:
3497
- return "&";
3498
- }
3499
- }, "separatorArrayExplode");
3500
- var separatorArrayNoExplode3 = /* @__PURE__ */ __name((style) => {
3501
- switch (style) {
3502
- case "form":
3503
- return ",";
3504
- case "pipeDelimited":
3505
- return "|";
3506
- case "spaceDelimited":
3507
- return "%20";
3508
- default:
3509
- return ",";
3510
- }
3511
- }, "separatorArrayNoExplode");
3512
- var separatorObjectExplode3 = /* @__PURE__ */ __name((style) => {
3513
- switch (style) {
3514
- case "label":
3515
- return ".";
3516
- case "matrix":
3517
- return ";";
3518
- case "simple":
3519
- return ",";
3520
- default:
3521
- return "&";
3522
- }
3523
- }, "separatorObjectExplode");
3524
- var serializeArrayParam3 = /* @__PURE__ */ __name(({
3525
- allowReserved,
3526
- explode,
3527
- name,
3528
- style,
3529
- value
3530
- }) => {
3531
- if (!explode) {
3532
- const joinedValues2 = (allowReserved ? value : value.map((v) => encodeURIComponent(v))).join(separatorArrayNoExplode3(style));
3533
- switch (style) {
3534
- case "label":
3535
- return `.${joinedValues2}`;
3536
- case "matrix":
3537
- return `;${name}=${joinedValues2}`;
3538
- case "simple":
3539
- return joinedValues2;
3540
- default:
3541
- return `${name}=${joinedValues2}`;
3542
- }
3543
- }
3544
- const separator = separatorArrayExplode3(style);
3545
- const joinedValues = value.map((v) => {
3546
- if (style === "label" || style === "simple") {
3547
- return allowReserved ? v : encodeURIComponent(v);
3548
- }
3549
- return serializePrimitiveParam3({
3550
- allowReserved,
3551
- name,
3552
- value: v
3553
- });
3554
- }).join(separator);
3555
- return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
3556
- }, "serializeArrayParam");
3557
- var serializePrimitiveParam3 = /* @__PURE__ */ __name(({
3558
- allowReserved,
3559
- name,
3560
- value
3561
- }) => {
3562
- if (value === void 0 || value === null) {
3563
- return "";
3564
- }
3565
- if (typeof value === "object") {
3566
- throw new Error(
3567
- "Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these."
3568
- );
3569
- }
3570
- return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
3571
- }, "serializePrimitiveParam");
3572
- var serializeObjectParam3 = /* @__PURE__ */ __name(({
3573
- allowReserved,
3574
- explode,
3575
- name,
3576
- style,
3577
- value,
3578
- valueOnly
3579
- }) => {
3580
- if (value instanceof Date) {
3581
- return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
3582
- }
3583
- if (style !== "deepObject" && !explode) {
3584
- let values = [];
3585
- Object.entries(value).forEach(([key, v]) => {
3586
- values = [...values, key, allowReserved ? v : encodeURIComponent(v)];
3587
- });
3588
- const joinedValues2 = values.join(",");
3589
- switch (style) {
3590
- case "form":
3591
- return `${name}=${joinedValues2}`;
3592
- case "label":
3593
- return `.${joinedValues2}`;
3594
- case "matrix":
3595
- return `;${name}=${joinedValues2}`;
3596
- default:
3597
- return joinedValues2;
3598
- }
3599
- }
3600
- const separator = separatorObjectExplode3(style);
3601
- const joinedValues = Object.entries(value).map(
3602
- ([key, v]) => serializePrimitiveParam3({
3603
- allowReserved,
3604
- name: style === "deepObject" ? `${name}[${key}]` : key,
3605
- value: v
3606
- })
3607
- ).join(separator);
3608
- return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
3609
- }, "serializeObjectParam");
3610
-
3611
- // src/_api/generated/cfg_totp/core/utils.gen.ts
3612
- var PATH_PARAM_RE3 = /\{[^{}]+\}/g;
3613
- var defaultPathSerializer3 = /* @__PURE__ */ __name(({ path, url: _url }) => {
3614
- let url = _url;
3615
- const matches = _url.match(PATH_PARAM_RE3);
3616
- if (matches) {
3617
- for (const match of matches) {
3618
- let explode = false;
3619
- let name = match.substring(1, match.length - 1);
3620
- let style = "simple";
3621
- if (name.endsWith("*")) {
3622
- explode = true;
3623
- name = name.substring(0, name.length - 1);
3624
- }
3625
- if (name.startsWith(".")) {
3626
- name = name.substring(1);
3627
- style = "label";
3628
- } else if (name.startsWith(";")) {
3629
- name = name.substring(1);
3630
- style = "matrix";
3631
- }
3632
- const value = path[name];
3633
- if (value === void 0 || value === null) {
3634
- continue;
3635
- }
3636
- if (Array.isArray(value)) {
3637
- url = url.replace(match, serializeArrayParam3({ explode, name, style, value }));
3638
- continue;
3639
- }
3640
- if (typeof value === "object") {
3641
- url = url.replace(
3642
- match,
3643
- serializeObjectParam3({
3644
- explode,
3645
- name,
3646
- style,
3647
- value,
3648
- valueOnly: true
3649
- })
3650
- );
3651
- continue;
3652
- }
3653
- if (style === "matrix") {
3654
- url = url.replace(
3655
- match,
3656
- `;${serializePrimitiveParam3({
3657
- name,
3658
- value
3659
- })}`
3660
- );
3661
- continue;
3662
- }
3663
- const replaceValue = encodeURIComponent(
3664
- style === "label" ? `.${value}` : value
3665
- );
3666
- url = url.replace(match, replaceValue);
3667
- }
3668
- }
3669
- return url;
3670
- }, "defaultPathSerializer");
3671
- var getUrl3 = /* @__PURE__ */ __name(({
3672
- baseUrl: baseUrl2,
3673
- path,
3674
- query,
3675
- querySerializer,
3676
- url: _url
3677
- }) => {
3678
- const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
3679
- let url = (baseUrl2 ?? "") + pathUrl;
3680
- if (path) {
3681
- url = defaultPathSerializer3({ path, url });
3682
- }
3683
- let search = query ? querySerializer(query) : "";
3684
- if (search.startsWith("?")) {
3685
- search = search.substring(1);
3686
- }
3687
- if (search) {
3688
- url += `?${search}`;
3689
- }
3690
- return url;
3691
- }, "getUrl");
3692
- function getValidRequestBody3(options) {
3693
- const hasBody = options.body !== void 0;
3694
- const isSerializedBody = hasBody && options.bodySerializer;
3695
- if (isSerializedBody) {
3696
- if ("serializedBody" in options) {
3697
- const hasSerializedBody = options.serializedBody !== void 0 && options.serializedBody !== "";
3698
- return hasSerializedBody ? options.serializedBody : null;
3699
- }
3700
- return options.body !== "" ? options.body : null;
3701
- }
3702
- if (hasBody) {
3703
- return options.body;
3704
- }
3705
- return void 0;
3706
- }
3707
- __name(getValidRequestBody3, "getValidRequestBody");
3708
-
3709
- // src/_api/generated/cfg_totp/core/auth.gen.ts
3710
- var getAuthToken3 = /* @__PURE__ */ __name(async (auth, callback) => {
3711
- const token = typeof callback === "function" ? await callback(auth) : callback;
3712
- if (!token) {
3713
- return;
3714
- }
3715
- if (auth.scheme === "bearer") {
3716
- return `Bearer ${token}`;
3717
- }
3718
- if (auth.scheme === "basic") {
3719
- return `Basic ${btoa(token)}`;
3720
- }
3721
- return token;
3722
- }, "getAuthToken");
3723
-
3724
- // src/_api/generated/cfg_totp/client/utils.gen.ts
3725
- var createQuerySerializer3 = /* @__PURE__ */ __name(({
3726
- parameters = {},
3727
- ...args
3728
- } = {}) => {
3729
- const querySerializer = /* @__PURE__ */ __name((queryParams) => {
3730
- const search = [];
3731
- if (queryParams && typeof queryParams === "object") {
3732
- for (const name in queryParams) {
3733
- const value = queryParams[name];
3734
- if (value === void 0 || value === null) {
3735
- continue;
3736
- }
3737
- const options = parameters[name] || args;
3738
- if (Array.isArray(value)) {
3739
- const serializedArray = serializeArrayParam3({
3740
- allowReserved: options.allowReserved,
3741
- explode: true,
3742
- name,
3743
- style: "form",
3744
- value,
3745
- ...options.array
3746
- });
3747
- if (serializedArray) search.push(serializedArray);
3748
- } else if (typeof value === "object") {
3749
- const serializedObject = serializeObjectParam3({
3750
- allowReserved: options.allowReserved,
3751
- explode: true,
3752
- name,
3753
- style: "deepObject",
3754
- value,
3755
- ...options.object
3756
- });
3757
- if (serializedObject) search.push(serializedObject);
3758
- } else {
3759
- const serializedPrimitive = serializePrimitiveParam3({
3760
- allowReserved: options.allowReserved,
3761
- name,
3762
- value
3763
- });
3764
- if (serializedPrimitive) search.push(serializedPrimitive);
3765
- }
3766
- }
3767
- }
3768
- return search.join("&");
3769
- }, "querySerializer");
3770
- return querySerializer;
3771
- }, "createQuerySerializer");
3772
- var getParseAs3 = /* @__PURE__ */ __name((contentType) => {
3773
- if (!contentType) {
3774
- return "stream";
3775
- }
3776
- const cleanContent = contentType.split(";")[0]?.trim();
3777
- if (!cleanContent) {
3778
- return;
3779
- }
3780
- if (cleanContent.startsWith("application/json") || cleanContent.endsWith("+json")) {
3781
- return "json";
3782
- }
3783
- if (cleanContent === "multipart/form-data") {
3784
- return "formData";
3785
- }
3786
- if (["application/", "audio/", "image/", "video/"].some((type) => cleanContent.startsWith(type))) {
3787
- return "blob";
3788
- }
3789
- if (cleanContent.startsWith("text/")) {
3790
- return "text";
3791
- }
3792
- return;
3793
- }, "getParseAs");
3794
- var checkForExistence3 = /* @__PURE__ */ __name((options, name) => {
3795
- if (!name) {
3796
- return false;
3797
- }
3798
- if (options.headers.has(name) || options.query?.[name] || options.headers.get("Cookie")?.includes(`${name}=`)) {
3799
- return true;
3800
- }
3801
- return false;
3802
- }, "checkForExistence");
3803
- var setAuthParams3 = /* @__PURE__ */ __name(async ({
3804
- security,
3805
- ...options
3806
- }) => {
3807
- for (const auth of security) {
3808
- if (checkForExistence3(options, auth.name)) {
3809
- continue;
3810
- }
3811
- const token = await getAuthToken3(auth, options.auth);
3812
- if (!token) {
3813
- continue;
3814
- }
3815
- const name = auth.name ?? "Authorization";
3816
- switch (auth.in) {
3817
- case "query":
3818
- if (!options.query) {
3819
- options.query = {};
3820
- }
3821
- options.query[name] = token;
3822
- break;
3823
- case "cookie":
3824
- options.headers.append("Cookie", `${name}=${token}`);
3825
- break;
3826
- case "header":
3827
- default:
3828
- options.headers.set(name, token);
3829
- break;
3830
- }
3831
- }
3832
- }, "setAuthParams");
3833
- var buildUrl3 = /* @__PURE__ */ __name((options) => getUrl3({
3834
- baseUrl: options.baseUrl,
3835
- path: options.path,
3836
- query: options.query,
3837
- querySerializer: typeof options.querySerializer === "function" ? options.querySerializer : createQuerySerializer3(options.querySerializer),
3838
- url: options.url
3839
- }), "buildUrl");
3840
- var mergeConfigs3 = /* @__PURE__ */ __name((a, b) => {
3841
- const config = { ...a, ...b };
3842
- if (config.baseUrl?.endsWith("/")) {
3843
- config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
3844
- }
3845
- config.headers = mergeHeaders3(a.headers, b.headers);
3846
- return config;
3847
- }, "mergeConfigs");
3848
- var headersEntries3 = /* @__PURE__ */ __name((headers) => {
3849
- const entries = [];
3850
- headers.forEach((value, key) => {
3851
- entries.push([key, value]);
3852
- });
3853
- return entries;
3854
- }, "headersEntries");
3855
- var mergeHeaders3 = /* @__PURE__ */ __name((...headers) => {
3856
- const mergedHeaders = new Headers();
3857
- for (const header of headers) {
3858
- if (!header) {
3859
- continue;
3860
- }
3861
- const iterator = header instanceof Headers ? headersEntries3(header) : Object.entries(header);
3862
- for (const [key, value] of iterator) {
3863
- if (value === null) {
3864
- mergedHeaders.delete(key);
3865
- } else if (Array.isArray(value)) {
3866
- for (const v of value) {
3867
- mergedHeaders.append(key, v);
3868
- }
3869
- } else if (value !== void 0) {
3870
- mergedHeaders.set(
3871
- key,
3872
- typeof value === "object" ? JSON.stringify(value) : value
3873
- );
3874
- }
3875
- }
3876
- }
3877
- return mergedHeaders;
3878
- }, "mergeHeaders");
3879
- var Interceptors3 = class {
3880
- static {
3881
- __name(this, "Interceptors");
3882
- }
3883
- fns = [];
3884
- clear() {
3885
- this.fns = [];
3886
- }
3887
- eject(id) {
3888
- const index = this.getInterceptorIndex(id);
3889
- if (this.fns[index]) {
3890
- this.fns[index] = null;
3891
- }
3892
- }
3893
- exists(id) {
3894
- const index = this.getInterceptorIndex(id);
3895
- return Boolean(this.fns[index]);
3896
- }
3897
- getInterceptorIndex(id) {
3898
- if (typeof id === "number") {
3899
- return this.fns[id] ? id : -1;
3900
- }
3901
- return this.fns.indexOf(id);
3902
- }
3903
- update(id, fn) {
3904
- const index = this.getInterceptorIndex(id);
3905
- if (this.fns[index]) {
3906
- this.fns[index] = fn;
3907
- return id;
3908
- }
3909
- return false;
3910
- }
3911
- use(fn) {
3912
- this.fns.push(fn);
3913
- return this.fns.length - 1;
3914
- }
3915
- };
3916
- var createInterceptors3 = /* @__PURE__ */ __name(() => ({
3917
- error: new Interceptors3(),
3918
- request: new Interceptors3(),
3919
- response: new Interceptors3()
3920
- }), "createInterceptors");
3921
- var defaultQuerySerializer3 = createQuerySerializer3({
3922
- allowReserved: false,
3923
- array: {
3924
- explode: true,
3925
- style: "form"
3926
- },
3927
- object: {
3928
- explode: true,
3929
- style: "deepObject"
3930
- }
3931
- });
3932
- var defaultHeaders3 = {
3933
- "Content-Type": "application/json"
3934
- };
3935
- var createConfig3 = /* @__PURE__ */ __name((override = {}) => ({
3936
- ...jsonBodySerializer3,
3937
- headers: defaultHeaders3,
3938
- parseAs: "auto",
3939
- querySerializer: defaultQuerySerializer3,
3940
- ...override
3941
- }), "createConfig");
3942
-
3943
- // src/_api/generated/cfg_totp/client/client.gen.ts
3944
- var createClient3 = /* @__PURE__ */ __name((config = {}) => {
3945
- let _config = mergeConfigs3(createConfig3(), config);
3946
- const getConfig = /* @__PURE__ */ __name(() => ({ ..._config }), "getConfig");
3947
- const setConfig = /* @__PURE__ */ __name((config2) => {
3948
- _config = mergeConfigs3(_config, config2);
3949
- return getConfig();
3950
- }, "setConfig");
3951
- const interceptors = createInterceptors3();
3952
- const beforeRequest = /* @__PURE__ */ __name(async (options) => {
3953
- const opts = {
3954
- ..._config,
3955
- ...options,
3956
- fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
3957
- headers: mergeHeaders3(_config.headers, options.headers),
3958
- serializedBody: void 0
3959
- };
3960
- if (opts.security) {
3961
- await setAuthParams3({
3962
- ...opts,
3963
- security: opts.security
3964
- });
3965
- }
3966
- if (opts.requestValidator) {
3967
- await opts.requestValidator(opts);
3968
- }
3969
- if (opts.body !== void 0 && opts.bodySerializer) {
3970
- opts.serializedBody = opts.bodySerializer(opts.body);
3971
- }
3972
- if (opts.body === void 0 || opts.serializedBody === "") {
3973
- opts.headers.delete("Content-Type");
3974
- }
3975
- const resolvedOpts = opts;
3976
- const url = buildUrl3(resolvedOpts);
3977
- return { opts: resolvedOpts, url };
3978
- }, "beforeRequest");
3979
- const request = /* @__PURE__ */ __name(async (options) => {
3980
- const throwOnError = options.throwOnError ?? _config.throwOnError;
3981
- const responseStyle = options.responseStyle ?? _config.responseStyle;
3982
- let request2;
3983
- let response;
3984
- try {
3985
- const { opts, url } = await beforeRequest(options);
3986
- const requestInit = {
3987
- redirect: "follow",
3988
- ...opts,
3989
- body: getValidRequestBody3(opts)
3990
- };
3991
- request2 = new Request(url, requestInit);
3992
- for (const fn of interceptors.request.fns) {
3993
- if (fn) {
3994
- request2 = await fn(request2, opts);
3995
- }
3996
- }
3997
- const _fetch = opts.fetch;
3998
- response = await _fetch(request2);
3999
- for (const fn of interceptors.response.fns) {
4000
- if (fn) {
4001
- response = await fn(response, request2, opts);
4002
- }
4003
- }
4004
- const result = {
4005
- request: request2,
4006
- response
4007
- };
4008
- if (response.ok) {
4009
- const parseAs = (opts.parseAs === "auto" ? getParseAs3(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
4010
- if (response.status === 204 || response.headers.get("Content-Length") === "0") {
4011
- let emptyData;
4012
- switch (parseAs) {
4013
- case "arrayBuffer":
4014
- case "blob":
4015
- case "text":
4016
- emptyData = await response[parseAs]();
4017
- break;
4018
- case "formData":
4019
- emptyData = new FormData();
4020
- break;
4021
- case "stream":
4022
- emptyData = response.body;
4023
- break;
4024
- case "json":
4025
- default:
4026
- emptyData = {};
4027
- break;
4028
- }
4029
- return opts.responseStyle === "data" ? emptyData : {
4030
- data: emptyData,
4031
- ...result
4032
- };
4033
- }
4034
- let data;
4035
- switch (parseAs) {
4036
- case "arrayBuffer":
4037
- case "blob":
4038
- case "formData":
4039
- case "text":
4040
- data = await response[parseAs]();
4041
- break;
4042
- case "json": {
4043
- const text = await response.text();
4044
- data = text ? JSON.parse(text) : {};
4045
- break;
4046
- }
4047
- case "stream":
4048
- return opts.responseStyle === "data" ? response.body : {
4049
- data: response.body,
4050
- ...result
4051
- };
4052
- }
4053
- if (parseAs === "json") {
4054
- if (opts.responseValidator) {
4055
- await opts.responseValidator(data);
4056
- }
4057
- if (opts.responseTransformer) {
4058
- data = await opts.responseTransformer(data);
4059
- }
4060
- }
4061
- return opts.responseStyle === "data" ? data : {
4062
- data,
4063
- ...result
4064
- };
4065
- }
4066
- const textError = await response.text();
4067
- let jsonError;
4068
- try {
4069
- jsonError = JSON.parse(textError);
4070
- } catch {
4071
- }
4072
- throw jsonError ?? textError;
4073
- } catch (error) {
4074
- let finalError = error;
4075
- for (const fn of interceptors.error.fns) {
4076
- if (fn) {
4077
- finalError = await fn(finalError, response, request2, options);
4078
- }
4079
- }
4080
- finalError = finalError || {};
4081
- if (throwOnError) {
4082
- throw finalError;
4083
- }
4084
- return responseStyle === "data" ? void 0 : {
4085
- error: finalError,
4086
- request: request2,
4087
- response
4088
- };
4089
- }
4090
- }, "request");
4091
- const makeMethodFn = /* @__PURE__ */ __name((method) => (options) => request({ ...options, method }), "makeMethodFn");
4092
- const makeSseFn = /* @__PURE__ */ __name((method) => async (options) => {
4093
- const { opts, url } = await beforeRequest(options);
4094
- return createSseClient3({
4095
- ...opts,
4096
- body: opts.body,
4097
- method,
4098
- onRequest: /* @__PURE__ */ __name(async (url2, init) => {
4099
- let request2 = new Request(url2, init);
4100
- for (const fn of interceptors.request.fns) {
4101
- if (fn) {
4102
- request2 = await fn(request2, opts);
4103
- }
4104
- }
4105
- return request2;
4106
- }, "onRequest"),
4107
- serializedBody: getValidRequestBody3(opts),
4108
- url
4109
- });
4110
- }, "makeSseFn");
4111
- const _buildUrl = /* @__PURE__ */ __name((options) => buildUrl3({ ..._config, ...options }), "_buildUrl");
4112
- return {
4113
- buildUrl: _buildUrl,
4114
- connect: makeMethodFn("CONNECT"),
4115
- delete: makeMethodFn("DELETE"),
4116
- get: makeMethodFn("GET"),
4117
- getConfig,
4118
- head: makeMethodFn("HEAD"),
4119
- interceptors,
4120
- options: makeMethodFn("OPTIONS"),
4121
- patch: makeMethodFn("PATCH"),
4122
- post: makeMethodFn("POST"),
4123
- put: makeMethodFn("PUT"),
4124
- request,
4125
- setConfig,
4126
- sse: {
4127
- connect: makeSseFn("CONNECT"),
4128
- delete: makeSseFn("DELETE"),
4129
- get: makeSseFn("GET"),
4130
- head: makeSseFn("HEAD"),
4131
- options: makeSseFn("OPTIONS"),
4132
- patch: makeSseFn("PATCH"),
4133
- post: makeSseFn("POST"),
4134
- put: makeSseFn("PUT"),
4135
- trace: makeSseFn("TRACE")
4136
- },
4137
- trace: makeMethodFn("TRACE")
4138
- };
4139
- }, "createClient");
4140
-
4141
- // src/_api/generated/cfg_totp/client.gen.ts
4142
- var client3 = createClient3(createConfig3({ baseUrl: "http://localhost:8000" }));
4143
-
4144
- // src/_api/generated/cfg_totp/sdk.gen.ts
4145
- var Cfg3 = class {
4146
- static {
4147
- __name(this, "Cfg");
1595
+ ...options,
1596
+ headers: {
1597
+ "Content-Type": "application/json",
1598
+ ...options.headers
1599
+ }
1600
+ });
4148
1601
  }
4149
1602
  /**
4150
- * Get backup codes status for user.
1603
+ * List OAuth providers
1604
+ *
1605
+ * Get list of available OAuth providers for authentication.
4151
1606
  */
4152
- static cfgTotpBackupCodesRetrieve(options) {
4153
- return (options?.client ?? client3).get({
1607
+ static cfgAccountsOauthProvidersRetrieve(options) {
1608
+ return (options?.client ?? client).get({ url: "/cfg/accounts/oauth/providers/", ...options });
1609
+ }
1610
+ /**
1611
+ * Request OTP code to email.
1612
+ */
1613
+ static cfgAccountsOtpRequestCreate(options) {
1614
+ return (options.client ?? client).post({
4154
1615
  security: [{ scheme: "bearer", type: "http" }],
4155
- url: "/cfg/totp/backup-codes/",
4156
- ...options
1616
+ url: "/cfg/accounts/otp/request/",
1617
+ ...options,
1618
+ headers: {
1619
+ "Content-Type": "application/json",
1620
+ ...options.headers
1621
+ }
4157
1622
  });
4158
1623
  }
4159
1624
  /**
4160
- * Regenerate backup codes.
1625
+ * Verify OTP code and return JWT tokens or 2FA session.
4161
1626
  *
4162
- * Requires TOTP code for verification.
4163
- * Invalidates all existing codes.
1627
+ * If user has 2FA enabled:
1628
+ * - Returns requires_2fa=True with session_id
1629
+ * - Client must complete 2FA verification at /cfg/totp/verify/
1630
+ *
1631
+ * If user has no 2FA:
1632
+ * - Returns JWT tokens and user data directly
4164
1633
  */
4165
- static cfgTotpBackupCodesRegenerateCreate(options) {
4166
- return (options.client ?? client3).post({
1634
+ static cfgAccountsOtpVerifyCreate(options) {
1635
+ return (options.client ?? client).post({
4167
1636
  security: [{ scheme: "bearer", type: "http" }],
4168
- url: "/cfg/totp/backup-codes/regenerate/",
1637
+ url: "/cfg/accounts/otp/verify/",
4169
1638
  ...options,
4170
1639
  headers: {
4171
1640
  "Content-Type": "application/json",
@@ -4174,52 +1643,97 @@ var Cfg3 = class {
4174
1643
  });
4175
1644
  }
4176
1645
  /**
4177
- * List all TOTP devices for user.
1646
+ * Get current user profile
1647
+ *
1648
+ * Retrieve the current authenticated user's profile information.
4178
1649
  */
4179
- static cfgTotpDevicesRetrieve(options) {
4180
- return (options?.client ?? client3).get({
4181
- security: [{ scheme: "bearer", type: "http" }],
4182
- url: "/cfg/totp/devices/",
1650
+ static cfgAccountsProfileRetrieve(options) {
1651
+ return (options?.client ?? client).get({
1652
+ security: [{ scheme: "bearer", type: "http" }, {
1653
+ in: "cookie",
1654
+ name: "sessionid",
1655
+ type: "apiKey"
1656
+ }],
1657
+ url: "/cfg/accounts/profile/",
4183
1658
  ...options
4184
1659
  });
4185
1660
  }
4186
1661
  /**
4187
- * Delete a TOTP device.
1662
+ * Upload user avatar
4188
1663
  *
4189
- * Requires verification code if removing the last/primary device.
1664
+ * Upload avatar image for the current authenticated user. Accepts multipart/form-data with 'avatar' field.
4190
1665
  */
4191
- static cfgTotpDevicesDestroy(options) {
4192
- return (options.client ?? client3).delete({
1666
+ static cfgAccountsProfileAvatarCreate(options) {
1667
+ return (options?.client ?? client).post({
1668
+ ...formDataBodySerializer,
4193
1669
  security: [{ scheme: "bearer", type: "http" }],
4194
- url: "/cfg/totp/devices/{id}/",
1670
+ url: "/cfg/accounts/profile/avatar/",
1671
+ ...options,
1672
+ headers: {
1673
+ "Content-Type": null,
1674
+ ...options?.headers
1675
+ }
1676
+ });
1677
+ }
1678
+ /**
1679
+ * Delete user account
1680
+ *
1681
+ *
1682
+ * Permanently delete the current user's account.
1683
+ *
1684
+ * This operation:
1685
+ * - Deactivates the account (user cannot log in)
1686
+ * - Anonymizes personal data (GDPR compliance)
1687
+ * - Frees up the email address for re-registration
1688
+ * - Preserves audit trail
1689
+ *
1690
+ * The account can be restored by an administrator if needed.
1691
+ *
1692
+ */
1693
+ static cfgAccountsProfileDeleteCreate(options) {
1694
+ return (options?.client ?? client).post({
1695
+ security: [{ scheme: "bearer", type: "http" }, {
1696
+ in: "cookie",
1697
+ name: "sessionid",
1698
+ type: "apiKey"
1699
+ }],
1700
+ url: "/cfg/accounts/profile/delete/",
4195
1701
  ...options
4196
1702
  });
4197
1703
  }
4198
1704
  /**
4199
- * Completely disable 2FA for account.
1705
+ * Partial update user profile
4200
1706
  *
4201
- * Requires verification code.
1707
+ * Partially update the current authenticated user's profile information. Supports avatar upload.
4202
1708
  */
4203
- static cfgTotpDisableCreate(options) {
4204
- return (options.client ?? client3).post({
4205
- security: [{ scheme: "bearer", type: "http" }],
4206
- url: "/cfg/totp/disable/",
1709
+ static cfgAccountsProfilePartialPartialUpdate(options) {
1710
+ return (options?.client ?? client).patch({
1711
+ security: [{ scheme: "bearer", type: "http" }, {
1712
+ in: "cookie",
1713
+ name: "sessionid",
1714
+ type: "apiKey"
1715
+ }],
1716
+ url: "/cfg/accounts/profile/partial/",
4207
1717
  ...options,
4208
1718
  headers: {
4209
1719
  "Content-Type": "application/json",
4210
- ...options.headers
1720
+ ...options?.headers
4211
1721
  }
4212
1722
  });
4213
1723
  }
4214
1724
  /**
4215
- * Start 2FA setup process.
1725
+ * Partial update user profile
4216
1726
  *
4217
- * Creates a new TOTP device and returns QR code for scanning.
1727
+ * Partially update the current authenticated user's profile information. Supports avatar upload.
4218
1728
  */
4219
- static cfgTotpSetupCreate(options) {
4220
- return (options?.client ?? client3).post({
4221
- security: [{ scheme: "bearer", type: "http" }],
4222
- url: "/cfg/totp/setup/",
1729
+ static cfgAccountsProfilePartialUpdate(options) {
1730
+ return (options?.client ?? client).put({
1731
+ security: [{ scheme: "bearer", type: "http" }, {
1732
+ in: "cookie",
1733
+ name: "sessionid",
1734
+ type: "apiKey"
1735
+ }],
1736
+ url: "/cfg/accounts/profile/partial/",
4223
1737
  ...options,
4224
1738
  headers: {
4225
1739
  "Content-Type": "application/json",
@@ -4228,46 +1742,51 @@ var Cfg3 = class {
4228
1742
  });
4229
1743
  }
4230
1744
  /**
4231
- * Confirm 2FA setup with first valid code.
1745
+ * Update user profile
4232
1746
  *
4233
- * Activates the device and generates backup codes.
1747
+ * Update the current authenticated user's profile information.
4234
1748
  */
4235
- static cfgTotpSetupConfirmCreate(options) {
4236
- return (options.client ?? client3).post({
4237
- security: [{ scheme: "bearer", type: "http" }],
4238
- url: "/cfg/totp/setup/confirm/",
1749
+ static cfgAccountsProfileUpdatePartialUpdate(options) {
1750
+ return (options?.client ?? client).patch({
1751
+ security: [{ scheme: "bearer", type: "http" }, {
1752
+ in: "cookie",
1753
+ name: "sessionid",
1754
+ type: "apiKey"
1755
+ }],
1756
+ url: "/cfg/accounts/profile/update/",
4239
1757
  ...options,
4240
1758
  headers: {
4241
1759
  "Content-Type": "application/json",
4242
- ...options.headers
1760
+ ...options?.headers
4243
1761
  }
4244
1762
  });
4245
1763
  }
4246
1764
  /**
4247
- * Verify TOTP code for 2FA session.
1765
+ * Update user profile
4248
1766
  *
4249
- * Completes authentication and returns JWT tokens on success.
1767
+ * Update the current authenticated user's profile information.
4250
1768
  */
4251
- static cfgTotpVerifyCreate(options) {
4252
- return (options.client ?? client3).post({
4253
- security: [{ scheme: "bearer", type: "http" }],
4254
- url: "/cfg/totp/verify/",
1769
+ static cfgAccountsProfileUpdateUpdate(options) {
1770
+ return (options?.client ?? client).put({
1771
+ security: [{ scheme: "bearer", type: "http" }, {
1772
+ in: "cookie",
1773
+ name: "sessionid",
1774
+ type: "apiKey"
1775
+ }],
1776
+ url: "/cfg/accounts/profile/update/",
4255
1777
  ...options,
4256
1778
  headers: {
4257
1779
  "Content-Type": "application/json",
4258
- ...options.headers
1780
+ ...options?.headers
4259
1781
  }
4260
1782
  });
4261
1783
  }
4262
1784
  /**
4263
- * Verify backup recovery code for 2FA session.
4264
- *
4265
- * Alternative verification method when TOTP device unavailable.
1785
+ * Refresh JWT token.
4266
1786
  */
4267
- static cfgTotpVerifyBackupCreate(options) {
4268
- return (options.client ?? client3).post({
4269
- security: [{ scheme: "bearer", type: "http" }],
4270
- url: "/cfg/totp/verify/backup/",
1787
+ static cfgAccountsTokenRefreshCreate(options) {
1788
+ return (options.client ?? client).post({
1789
+ url: "/cfg/accounts/token/refresh/",
4271
1790
  ...options,
4272
1791
  headers: {
4273
1792
  "Content-Type": "application/json",
@@ -4275,16 +1794,23 @@ var Cfg3 = class {
4275
1794
  }
4276
1795
  });
4277
1796
  }
4278
- };
4279
- var Totp = class {
4280
- static {
4281
- __name(this, "Totp");
1797
+ /**
1798
+ * Get Centrifugo connection token
1799
+ *
1800
+ * Generate JWT token for WebSocket connection to Centrifugo. Token includes user's allowed channels based on their permissions. Requires authentication.
1801
+ */
1802
+ static cfgCentrifugoAuthTokenRetrieve(options) {
1803
+ return (options?.client ?? client).get({
1804
+ security: [{ scheme: "bearer", type: "http" }],
1805
+ url: "/cfg/centrifugo/auth/token/",
1806
+ ...options
1807
+ });
4282
1808
  }
4283
1809
  /**
4284
1810
  * Get backup codes status for user.
4285
1811
  */
4286
1812
  static cfgTotpBackupCodesRetrieve(options) {
4287
- return (options?.client ?? client3).get({
1813
+ return (options?.client ?? client).get({
4288
1814
  security: [{ scheme: "bearer", type: "http" }],
4289
1815
  url: "/cfg/totp/backup-codes/",
4290
1816
  ...options
@@ -4297,7 +1823,7 @@ var Totp = class {
4297
1823
  * Invalidates all existing codes.
4298
1824
  */
4299
1825
  static cfgTotpBackupCodesRegenerateCreate(options) {
4300
- return (options.client ?? client3).post({
1826
+ return (options.client ?? client).post({
4301
1827
  security: [{ scheme: "bearer", type: "http" }],
4302
1828
  url: "/cfg/totp/backup-codes/regenerate/",
4303
1829
  ...options,
@@ -4311,7 +1837,7 @@ var Totp = class {
4311
1837
  * List all TOTP devices for user.
4312
1838
  */
4313
1839
  static cfgTotpDevicesRetrieve(options) {
4314
- return (options?.client ?? client3).get({
1840
+ return (options?.client ?? client).get({
4315
1841
  security: [{ scheme: "bearer", type: "http" }],
4316
1842
  url: "/cfg/totp/devices/",
4317
1843
  ...options
@@ -4323,7 +1849,7 @@ var Totp = class {
4323
1849
  * Requires verification code if removing the last/primary device.
4324
1850
  */
4325
1851
  static cfgTotpDevicesDestroy(options) {
4326
- return (options.client ?? client3).delete({
1852
+ return (options.client ?? client).delete({
4327
1853
  security: [{ scheme: "bearer", type: "http" }],
4328
1854
  url: "/cfg/totp/devices/{id}/",
4329
1855
  ...options
@@ -4335,7 +1861,7 @@ var Totp = class {
4335
1861
  * Requires verification code.
4336
1862
  */
4337
1863
  static cfgTotpDisableCreate(options) {
4338
- return (options.client ?? client3).post({
1864
+ return (options.client ?? client).post({
4339
1865
  security: [{ scheme: "bearer", type: "http" }],
4340
1866
  url: "/cfg/totp/disable/",
4341
1867
  ...options,
@@ -4351,7 +1877,7 @@ var Totp = class {
4351
1877
  * Creates a new TOTP device and returns QR code for scanning.
4352
1878
  */
4353
1879
  static cfgTotpSetupCreate(options) {
4354
- return (options?.client ?? client3).post({
1880
+ return (options?.client ?? client).post({
4355
1881
  security: [{ scheme: "bearer", type: "http" }],
4356
1882
  url: "/cfg/totp/setup/",
4357
1883
  ...options,
@@ -4367,7 +1893,7 @@ var Totp = class {
4367
1893
  * Activates the device and generates backup codes.
4368
1894
  */
4369
1895
  static cfgTotpSetupConfirmCreate(options) {
4370
- return (options.client ?? client3).post({
1896
+ return (options.client ?? client).post({
4371
1897
  security: [{ scheme: "bearer", type: "http" }],
4372
1898
  url: "/cfg/totp/setup/confirm/",
4373
1899
  ...options,
@@ -4383,7 +1909,7 @@ var Totp = class {
4383
1909
  * Completes authentication and returns JWT tokens on success.
4384
1910
  */
4385
1911
  static cfgTotpVerifyCreate(options) {
4386
- return (options.client ?? client3).post({
1912
+ return (options.client ?? client).post({
4387
1913
  security: [{ scheme: "bearer", type: "http" }],
4388
1914
  url: "/cfg/totp/verify/",
4389
1915
  ...options,
@@ -4399,7 +1925,7 @@ var Totp = class {
4399
1925
  * Alternative verification method when TOTP device unavailable.
4400
1926
  */
4401
1927
  static cfgTotpVerifyBackupCreate(options) {
4402
- return (options.client ?? client3).post({
1928
+ return (options.client ?? client).post({
4403
1929
  security: [{ scheme: "bearer", type: "http" }],
4404
1930
  url: "/cfg/totp/verify/backup/",
4405
1931
  ...options,
@@ -4410,82 +1936,173 @@ var Totp = class {
4410
1936
  });
4411
1937
  }
4412
1938
  };
4413
- var BackupCodes = class {
1939
+ var OAuth = class {
1940
+ static {
1941
+ __name(this, "OAuth");
1942
+ }
1943
+ /**
1944
+ * List OAuth connections
1945
+ *
1946
+ * Get all OAuth connections for the current user.
1947
+ */
1948
+ static cfgAccountsOauthConnectionsList(options) {
1949
+ return (options?.client ?? client).get({
1950
+ security: [{ scheme: "bearer", type: "http" }],
1951
+ url: "/cfg/accounts/oauth/connections/",
1952
+ ...options
1953
+ });
1954
+ }
1955
+ /**
1956
+ * Disconnect OAuth provider
1957
+ *
1958
+ * Remove OAuth connection for the specified provider.
1959
+ */
1960
+ static cfgAccountsOauthDisconnectCreate(options) {
1961
+ return (options.client ?? client).post({
1962
+ security: [{ scheme: "bearer", type: "http" }],
1963
+ url: "/cfg/accounts/oauth/disconnect/",
1964
+ ...options,
1965
+ headers: {
1966
+ "Content-Type": "application/json",
1967
+ ...options.headers
1968
+ }
1969
+ });
1970
+ }
1971
+ /**
1972
+ * Start GitHub OAuth
1973
+ *
1974
+ * Generate GitHub OAuth authorization URL. Redirect user to this URL to start authentication.
1975
+ */
1976
+ static cfgAccountsOauthGithubAuthorizeCreate(options) {
1977
+ return (options?.client ?? client).post({
1978
+ url: "/cfg/accounts/oauth/github/authorize/",
1979
+ ...options,
1980
+ headers: {
1981
+ "Content-Type": "application/json",
1982
+ ...options?.headers
1983
+ }
1984
+ });
1985
+ }
1986
+ /**
1987
+ * Complete GitHub OAuth
1988
+ *
1989
+ * Exchange authorization code for JWT tokens. Call this after GitHub redirects back with code.
1990
+ */
1991
+ static cfgAccountsOauthGithubCallbackCreate(options) {
1992
+ return (options.client ?? client).post({
1993
+ url: "/cfg/accounts/oauth/github/callback/",
1994
+ ...options,
1995
+ headers: {
1996
+ "Content-Type": "application/json",
1997
+ ...options.headers
1998
+ }
1999
+ });
2000
+ }
2001
+ /**
2002
+ * List OAuth providers
2003
+ *
2004
+ * Get list of available OAuth providers for authentication.
2005
+ */
2006
+ static cfgAccountsOauthProvidersRetrieve(options) {
2007
+ return (options?.client ?? client).get({ url: "/cfg/accounts/oauth/providers/", ...options });
2008
+ }
2009
+ };
2010
+ var UserProfile = class {
4414
2011
  static {
4415
- __name(this, "BackupCodes");
2012
+ __name(this, "UserProfile");
4416
2013
  }
4417
2014
  /**
4418
- * Get backup codes status for user.
2015
+ * Get current user profile
2016
+ *
2017
+ * Retrieve the current authenticated user's profile information.
4419
2018
  */
4420
- static cfgTotpBackupCodesRetrieve(options) {
4421
- return (options?.client ?? client3).get({
4422
- security: [{ scheme: "bearer", type: "http" }],
4423
- url: "/cfg/totp/backup-codes/",
2019
+ static cfgAccountsProfileRetrieve(options) {
2020
+ return (options?.client ?? client).get({
2021
+ security: [{ scheme: "bearer", type: "http" }, {
2022
+ in: "cookie",
2023
+ name: "sessionid",
2024
+ type: "apiKey"
2025
+ }],
2026
+ url: "/cfg/accounts/profile/",
4424
2027
  ...options
4425
2028
  });
4426
2029
  }
4427
2030
  /**
4428
- * Regenerate backup codes.
2031
+ * Upload user avatar
4429
2032
  *
4430
- * Requires TOTP code for verification.
4431
- * Invalidates all existing codes.
2033
+ * Upload avatar image for the current authenticated user. Accepts multipart/form-data with 'avatar' field.
4432
2034
  */
4433
- static cfgTotpBackupCodesRegenerateCreate(options) {
4434
- return (options.client ?? client3).post({
2035
+ static cfgAccountsProfileAvatarCreate(options) {
2036
+ return (options?.client ?? client).post({
2037
+ ...formDataBodySerializer,
4435
2038
  security: [{ scheme: "bearer", type: "http" }],
4436
- url: "/cfg/totp/backup-codes/regenerate/",
2039
+ url: "/cfg/accounts/profile/avatar/",
4437
2040
  ...options,
4438
2041
  headers: {
4439
- "Content-Type": "application/json",
4440
- ...options.headers
2042
+ "Content-Type": null,
2043
+ ...options?.headers
4441
2044
  }
4442
2045
  });
4443
2046
  }
4444
- };
4445
- var TotpManagement = class {
4446
- static {
4447
- __name(this, "TotpManagement");
4448
- }
4449
2047
  /**
4450
- * List all TOTP devices for user.
2048
+ * Delete user account
2049
+ *
2050
+ *
2051
+ * Permanently delete the current user's account.
2052
+ *
2053
+ * This operation:
2054
+ * - Deactivates the account (user cannot log in)
2055
+ * - Anonymizes personal data (GDPR compliance)
2056
+ * - Frees up the email address for re-registration
2057
+ * - Preserves audit trail
2058
+ *
2059
+ * The account can be restored by an administrator if needed.
2060
+ *
4451
2061
  */
4452
- static cfgTotpDevicesRetrieve(options) {
4453
- return (options?.client ?? client3).get({
4454
- security: [{ scheme: "bearer", type: "http" }],
4455
- url: "/cfg/totp/devices/",
2062
+ static cfgAccountsProfileDeleteCreate(options) {
2063
+ return (options?.client ?? client).post({
2064
+ security: [{ scheme: "bearer", type: "http" }, {
2065
+ in: "cookie",
2066
+ name: "sessionid",
2067
+ type: "apiKey"
2068
+ }],
2069
+ url: "/cfg/accounts/profile/delete/",
4456
2070
  ...options
4457
2071
  });
4458
2072
  }
4459
2073
  /**
4460
- * Completely disable 2FA for account.
2074
+ * Partial update user profile
4461
2075
  *
4462
- * Requires verification code.
2076
+ * Partially update the current authenticated user's profile information. Supports avatar upload.
4463
2077
  */
4464
- static cfgTotpDisableCreate(options) {
4465
- return (options.client ?? client3).post({
4466
- security: [{ scheme: "bearer", type: "http" }],
4467
- url: "/cfg/totp/disable/",
2078
+ static cfgAccountsProfilePartialPartialUpdate(options) {
2079
+ return (options?.client ?? client).patch({
2080
+ security: [{ scheme: "bearer", type: "http" }, {
2081
+ in: "cookie",
2082
+ name: "sessionid",
2083
+ type: "apiKey"
2084
+ }],
2085
+ url: "/cfg/accounts/profile/partial/",
4468
2086
  ...options,
4469
2087
  headers: {
4470
2088
  "Content-Type": "application/json",
4471
- ...options.headers
2089
+ ...options?.headers
4472
2090
  }
4473
2091
  });
4474
2092
  }
4475
- };
4476
- var TotpSetup = class {
4477
- static {
4478
- __name(this, "TotpSetup");
4479
- }
4480
2093
  /**
4481
- * Start 2FA setup process.
2094
+ * Partial update user profile
4482
2095
  *
4483
- * Creates a new TOTP device and returns QR code for scanning.
2096
+ * Partially update the current authenticated user's profile information. Supports avatar upload.
4484
2097
  */
4485
- static cfgTotpSetupCreate(options) {
4486
- return (options?.client ?? client3).post({
4487
- security: [{ scheme: "bearer", type: "http" }],
4488
- url: "/cfg/totp/setup/",
2098
+ static cfgAccountsProfilePartialUpdate(options) {
2099
+ return (options?.client ?? client).put({
2100
+ security: [{ scheme: "bearer", type: "http" }, {
2101
+ in: "cookie",
2102
+ name: "sessionid",
2103
+ type: "apiKey"
2104
+ }],
2105
+ url: "/cfg/accounts/profile/partial/",
4489
2106
  ...options,
4490
2107
  headers: {
4491
2108
  "Content-Type": "application/json",
@@ -4494,51 +2111,56 @@ var TotpSetup = class {
4494
2111
  });
4495
2112
  }
4496
2113
  /**
4497
- * Confirm 2FA setup with first valid code.
2114
+ * Update user profile
4498
2115
  *
4499
- * Activates the device and generates backup codes.
2116
+ * Update the current authenticated user's profile information.
4500
2117
  */
4501
- static cfgTotpSetupConfirmCreate(options) {
4502
- return (options.client ?? client3).post({
4503
- security: [{ scheme: "bearer", type: "http" }],
4504
- url: "/cfg/totp/setup/confirm/",
2118
+ static cfgAccountsProfileUpdatePartialUpdate(options) {
2119
+ return (options?.client ?? client).patch({
2120
+ security: [{ scheme: "bearer", type: "http" }, {
2121
+ in: "cookie",
2122
+ name: "sessionid",
2123
+ type: "apiKey"
2124
+ }],
2125
+ url: "/cfg/accounts/profile/update/",
4505
2126
  ...options,
4506
2127
  headers: {
4507
2128
  "Content-Type": "application/json",
4508
- ...options.headers
2129
+ ...options?.headers
4509
2130
  }
4510
2131
  });
4511
2132
  }
4512
- };
4513
- var TotpVerification = class {
4514
- static {
4515
- __name(this, "TotpVerification");
4516
- }
4517
2133
  /**
4518
- * Verify TOTP code for 2FA session.
2134
+ * Update user profile
4519
2135
  *
4520
- * Completes authentication and returns JWT tokens on success.
2136
+ * Update the current authenticated user's profile information.
4521
2137
  */
4522
- static cfgTotpVerifyCreate(options) {
4523
- return (options.client ?? client3).post({
4524
- security: [{ scheme: "bearer", type: "http" }],
4525
- url: "/cfg/totp/verify/",
2138
+ static cfgAccountsProfileUpdateUpdate(options) {
2139
+ return (options?.client ?? client).put({
2140
+ security: [{ scheme: "bearer", type: "http" }, {
2141
+ in: "cookie",
2142
+ name: "sessionid",
2143
+ type: "apiKey"
2144
+ }],
2145
+ url: "/cfg/accounts/profile/update/",
4526
2146
  ...options,
4527
2147
  headers: {
4528
2148
  "Content-Type": "application/json",
4529
- ...options.headers
2149
+ ...options?.headers
4530
2150
  }
4531
2151
  });
4532
2152
  }
2153
+ };
2154
+ var Auth = class {
2155
+ static {
2156
+ __name(this, "Auth");
2157
+ }
4533
2158
  /**
4534
- * Verify backup recovery code for 2FA session.
4535
- *
4536
- * Alternative verification method when TOTP device unavailable.
2159
+ * Refresh JWT token.
4537
2160
  */
4538
- static cfgTotpVerifyBackupCreate(options) {
4539
- return (options.client ?? client3).post({
4540
- security: [{ scheme: "bearer", type: "http" }],
4541
- url: "/cfg/totp/verify/backup/",
2161
+ static cfgAccountsTokenRefreshCreate(options) {
2162
+ return (options.client ?? client).post({
2163
+ url: "/cfg/accounts/token/refresh/",
4542
2164
  ...options,
4543
2165
  headers: {
4544
2166
  "Content-Type": "application/json",
@@ -4547,276 +2169,112 @@ var TotpVerification = class {
4547
2169
  });
4548
2170
  }
4549
2171
  };
4550
-
4551
- // src/_api/generated/cfg_totp/schemas/BackupCodesRegenerateRequest.ts
4552
- import { z as z23 } from "zod";
4553
- var BackupCodesRegenerateRequestSchema = z23.object({
4554
- code: z23.string().min(6).max(6)
4555
- });
4556
-
4557
- // src/_api/generated/cfg_totp/schemas/BackupCodesRegenerateResponse.ts
4558
- import { z as z24 } from "zod";
4559
- var BackupCodesRegenerateResponseSchema = z24.object({
4560
- backup_codes: z24.array(z24.string()),
4561
- warning: z24.string()
4562
- });
4563
-
4564
- // src/_api/generated/cfg_totp/schemas/BackupCodesStatus.ts
4565
- import { z as z25 } from "zod";
4566
- var BackupCodesStatusSchema = z25.object({
4567
- remaining_count: z25.number().int(),
4568
- total_generated: z25.number().int(),
4569
- warning: z25.string().nullable().optional()
4570
- });
4571
-
4572
- // src/_api/generated/cfg_totp/schemas/ConfirmSetupRequest.ts
4573
- import { z as z26 } from "zod";
4574
- var ConfirmSetupRequestSchema = z26.object({
4575
- device_id: z26.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
4576
- code: z26.string().min(6).max(6)
4577
- });
4578
-
4579
- // src/_api/generated/cfg_totp/schemas/ConfirmSetupResponse.ts
4580
- import { z as z27 } from "zod";
4581
- var ConfirmSetupResponseSchema = z27.object({
4582
- message: z27.string(),
4583
- backup_codes: z27.array(z27.string()),
4584
- backup_codes_warning: z27.string()
4585
- });
4586
-
4587
- // src/_api/generated/cfg_totp/schemas/DeviceList.ts
4588
- import { z as z29 } from "zod";
4589
-
4590
- // src/_api/generated/cfg_totp/schemas/DeviceListStatusEnum.ts
4591
- import { z as z28 } from "zod";
4592
- var DeviceListStatusEnumSchema = z28.enum(["pending", "active", "disabled"]);
4593
-
4594
- // src/_api/generated/cfg_totp/schemas/DeviceList.ts
4595
- var DeviceListSchema = z29.object({
4596
- id: z29.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
4597
- name: z29.string(),
4598
- is_primary: z29.boolean(),
4599
- status: DeviceListStatusEnumSchema,
4600
- created_at: z29.string().datetime({ offset: true }),
4601
- confirmed_at: z29.string().datetime({ offset: true }).nullable(),
4602
- last_used_at: z29.string().datetime({ offset: true }).nullable()
4603
- });
4604
-
4605
- // src/_api/generated/cfg_totp/schemas/DeviceListResponse.ts
4606
- import { z as z30 } from "zod";
4607
- var DeviceListResponseSchema = z30.object({
4608
- devices: z30.array(DeviceListSchema),
4609
- has_2fa_enabled: z30.boolean()
4610
- });
4611
-
4612
- // src/_api/generated/cfg_totp/schemas/DisableRequest.ts
4613
- import { z as z31 } from "zod";
4614
- var DisableRequestSchema = z31.object({
4615
- code: z31.string().min(6).max(6)
4616
- });
4617
-
4618
- // src/_api/generated/cfg_totp/schemas/SetupRequest.ts
4619
- import { z as z32 } from "zod";
4620
- var SetupRequestSchema = z32.object({
4621
- device_name: z32.string().min(1).max(100).optional()
4622
- });
4623
-
4624
- // src/_api/generated/cfg_totp/schemas/SetupResponse.ts
4625
- import { z as z33 } from "zod";
4626
- var SetupResponseSchema = z33.object({
4627
- device_id: z33.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
4628
- secret: z33.string(),
4629
- provisioning_uri: z33.string(),
4630
- qr_code_base64: z33.string(),
4631
- expires_in: z33.number().int()
4632
- });
4633
-
4634
- // src/_api/generated/cfg_totp/schemas/TotpVerifyUser.ts
4635
- import { z as z34 } from "zod";
4636
- var TotpVerifyUserSchema = z34.object({
4637
- id: z34.number().int(),
4638
- email: z34.email(),
4639
- first_name: z34.string().max(50).optional(),
4640
- last_name: z34.string().max(50).optional(),
4641
- full_name: z34.string(),
4642
- initials: z34.string(),
4643
- display_username: z34.string(),
4644
- company: z34.string().max(100).optional(),
4645
- phone: z34.string().max(20).optional(),
4646
- position: z34.string().max(100).optional(),
4647
- language: z34.string().max(10).optional(),
4648
- avatar: z34.string().nullable(),
4649
- is_staff: z34.boolean(),
4650
- is_superuser: z34.boolean(),
4651
- date_joined: z34.string().datetime({ offset: true }),
4652
- last_login: z34.string().datetime({ offset: true }).nullable(),
4653
- unanswered_messages_count: z34.number().int()
4654
- });
4655
-
4656
- // src/_api/generated/cfg_totp/schemas/VerifyBackupRequest.ts
4657
- import { z as z35 } from "zod";
4658
- var VerifyBackupRequestSchema = z35.object({
4659
- session_id: z35.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
4660
- backup_code: z35.string().min(8).max(8)
4661
- });
4662
-
4663
- // src/_api/generated/cfg_totp/schemas/VerifyRequest.ts
4664
- import { z as z36 } from "zod";
4665
- var VerifyRequestSchema = z36.object({
4666
- session_id: z36.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
4667
- code: z36.string().min(6).max(6)
4668
- });
4669
-
4670
- // src/_api/generated/cfg_totp/schemas/VerifyResponse.ts
4671
- import { z as z37 } from "zod";
4672
- var VerifyResponseSchema = z37.object({
4673
- message: z37.string(),
4674
- access_token: z37.string(),
4675
- refresh_token: z37.string(),
4676
- user: TotpVerifyUserSchema,
4677
- remaining_backup_codes: z37.number().int().optional(),
4678
- warning: z37.string().optional()
4679
- });
4680
-
4681
- // src/_api/generated/cfg_totp/api.ts
4682
- var ACCESS_KEY3 = "cfg.access_token";
4683
- var REFRESH_KEY3 = "cfg.refresh_token";
4684
- var VALIDATION_ROUTES3 = [
4685
- { method: "GET", re: new RegExp("^/cfg/totp/backup\\-codes/?$"), schema: BackupCodesStatusSchema, path: "/cfg/totp/backup-codes/" },
4686
- { method: "POST", re: new RegExp("^/cfg/totp/backup\\-codes/regenerate/?$"), schema: BackupCodesRegenerateResponseSchema, path: "/cfg/totp/backup-codes/regenerate/" },
4687
- { method: "GET", re: new RegExp("^/cfg/totp/devices/?$"), schema: DeviceListResponseSchema, path: "/cfg/totp/devices/" },
4688
- { method: "POST", re: new RegExp("^/cfg/totp/setup/?$"), schema: SetupResponseSchema, path: "/cfg/totp/setup/" },
4689
- { method: "POST", re: new RegExp("^/cfg/totp/setup/confirm/?$"), schema: ConfirmSetupResponseSchema, path: "/cfg/totp/setup/confirm/" },
4690
- { method: "POST", re: new RegExp("^/cfg/totp/verify/?$"), schema: VerifyResponseSchema, path: "/cfg/totp/verify/" },
4691
- { method: "POST", re: new RegExp("^/cfg/totp/verify/backup/?$"), schema: VerifyResponseSchema, path: "/cfg/totp/verify/backup/" }
4692
- ];
4693
- function detectLocale3() {
4694
- try {
4695
- if (typeof document !== "undefined") {
4696
- const m = document.cookie.match(/(?:^|;\s*)NEXT_LOCALE=([^;]*)/);
4697
- if (m) return decodeURIComponent(m[1]);
4698
- }
4699
- if (typeof navigator !== "undefined" && navigator.language) {
4700
- return navigator.language;
4701
- }
4702
- } catch {
4703
- }
4704
- return null;
4705
- }
4706
- __name(detectLocale3, "detectLocale");
4707
- var API3 = class {
2172
+ var TotpManagement = class {
4708
2173
  static {
4709
- __name(this, "API");
2174
+ __name(this, "TotpManagement");
4710
2175
  }
4711
- baseUrl;
4712
- storage;
4713
- locale;
4714
- apiKey;
4715
- logger;
4716
- cfg = Cfg3;
4717
- totp = Totp;
4718
- backupCodes = BackupCodes;
4719
- totpManagement = TotpManagement;
4720
- totpSetup = TotpSetup;
4721
- totpVerification = TotpVerification;
4722
- constructor(baseUrl2, opts = {}) {
4723
- this.baseUrl = baseUrl2.replace(/\/$/, "");
4724
- this.storage = opts.storage ?? new LocalStorageAdapter();
4725
- this.logger = new APILogger(opts.logger);
4726
- this.locale = opts.locale ?? null;
4727
- this.apiKey = opts.apiKey ?? (typeof process !== "undefined" ? process.env?.NEXT_PUBLIC_API_KEY ?? null : null);
4728
- const credentials = opts.withCredentials ?? true ? "include" : "same-origin";
4729
- client3.setConfig({ baseUrl: this.baseUrl, credentials });
4730
- client3.interceptors.request.use((request) => {
4731
- const access = this.getToken();
4732
- if (access) request.headers.set("Authorization", `Bearer ${access}`);
4733
- const locale = this.locale ?? detectLocale3();
4734
- if (locale) request.headers.set("Accept-Language", locale);
4735
- if (this.apiKey) request.headers.set("X-API-Key", this.apiKey);
4736
- return request;
2176
+ /**
2177
+ * List all TOTP devices for user.
2178
+ */
2179
+ static cfgTotpDevicesRetrieve(options) {
2180
+ return (options?.client ?? client).get({
2181
+ security: [{ scheme: "bearer", type: "http" }],
2182
+ url: "/cfg/totp/devices/",
2183
+ ...options
4737
2184
  });
4738
- client3.interceptors.response.use(async (response, request) => {
4739
- if (!response.ok) return response;
4740
- const ct = response.headers.get("content-type") || "";
4741
- if (!ct.includes("application/json")) return response;
4742
- const url = new URL(request.url);
4743
- const method = request.method.toUpperCase();
4744
- const route = VALIDATION_ROUTES3.find(
4745
- (r) => r.method === method && r.re.test(url.pathname)
4746
- );
4747
- if (!route) return response;
4748
- let payload;
4749
- try {
4750
- payload = await response.clone().json();
4751
- } catch {
4752
- return response;
4753
- }
4754
- const result = route.schema.safeParse(payload);
4755
- if (!result.success) {
4756
- dispatchValidationError({
4757
- operation: `${method} ${route.path}`,
4758
- path: route.path,
4759
- method,
4760
- error: result.error,
4761
- response: payload,
4762
- timestamp: /* @__PURE__ */ new Date()
4763
- });
2185
+ }
2186
+ /**
2187
+ * Completely disable 2FA for account.
2188
+ *
2189
+ * Requires verification code.
2190
+ */
2191
+ static cfgTotpDisableCreate(options) {
2192
+ return (options.client ?? client).post({
2193
+ security: [{ scheme: "bearer", type: "http" }],
2194
+ url: "/cfg/totp/disable/",
2195
+ ...options,
2196
+ headers: {
2197
+ "Content-Type": "application/json",
2198
+ ...options.headers
4764
2199
  }
4765
- return response;
4766
2200
  });
4767
2201
  }
4768
- // ── Base URL ────────────────────────────────────────────────────────────
4769
- getBaseUrl() {
4770
- return this.baseUrl;
4771
- }
4772
- setBaseUrl(url) {
4773
- this.baseUrl = url.replace(/\/$/, "");
4774
- client3.setConfig({ baseUrl: this.baseUrl });
4775
- }
4776
- // ── Tokens ──────────────────────────────────────────────────────────────
4777
- getToken() {
4778
- return this.storage.getItem(ACCESS_KEY3);
4779
- }
4780
- setToken(token) {
4781
- if (token) this.storage.setItem(ACCESS_KEY3, token);
4782
- else this.storage.removeItem(ACCESS_KEY3);
4783
- }
4784
- getRefreshToken() {
4785
- return this.storage.getItem(REFRESH_KEY3);
4786
- }
4787
- setRefreshToken(token) {
4788
- if (token) this.storage.setItem(REFRESH_KEY3, token);
4789
- else this.storage.removeItem(REFRESH_KEY3);
4790
- }
4791
- clearToken() {
4792
- this.storage.removeItem(ACCESS_KEY3);
4793
- this.storage.removeItem(REFRESH_KEY3);
2202
+ };
2203
+ var TotpSetup = class {
2204
+ static {
2205
+ __name(this, "TotpSetup");
4794
2206
  }
4795
- isAuthenticated() {
4796
- return this.getToken() !== null;
2207
+ /**
2208
+ * Start 2FA setup process.
2209
+ *
2210
+ * Creates a new TOTP device and returns QR code for scanning.
2211
+ */
2212
+ static cfgTotpSetupCreate(options) {
2213
+ return (options?.client ?? client).post({
2214
+ security: [{ scheme: "bearer", type: "http" }],
2215
+ url: "/cfg/totp/setup/",
2216
+ ...options,
2217
+ headers: {
2218
+ "Content-Type": "application/json",
2219
+ ...options?.headers
2220
+ }
2221
+ });
4797
2222
  }
4798
- // ── Locale / API key ────────────────────────────────────────────────────
4799
- getLocale() {
4800
- return this.locale ?? detectLocale3();
2223
+ /**
2224
+ * Confirm 2FA setup with first valid code.
2225
+ *
2226
+ * Activates the device and generates backup codes.
2227
+ */
2228
+ static cfgTotpSetupConfirmCreate(options) {
2229
+ return (options.client ?? client).post({
2230
+ security: [{ scheme: "bearer", type: "http" }],
2231
+ url: "/cfg/totp/setup/confirm/",
2232
+ ...options,
2233
+ headers: {
2234
+ "Content-Type": "application/json",
2235
+ ...options.headers
2236
+ }
2237
+ });
4801
2238
  }
4802
- setLocale(locale) {
4803
- this.locale = locale;
2239
+ };
2240
+ var TotpVerification = class {
2241
+ static {
2242
+ __name(this, "TotpVerification");
4804
2243
  }
4805
- getApiKey() {
4806
- return this.apiKey;
2244
+ /**
2245
+ * Verify TOTP code for 2FA session.
2246
+ *
2247
+ * Completes authentication and returns JWT tokens on success.
2248
+ */
2249
+ static cfgTotpVerifyCreate(options) {
2250
+ return (options.client ?? client).post({
2251
+ security: [{ scheme: "bearer", type: "http" }],
2252
+ url: "/cfg/totp/verify/",
2253
+ ...options,
2254
+ headers: {
2255
+ "Content-Type": "application/json",
2256
+ ...options.headers
2257
+ }
2258
+ });
4807
2259
  }
4808
- setApiKey(key) {
4809
- this.apiKey = key;
2260
+ /**
2261
+ * Verify backup recovery code for 2FA session.
2262
+ *
2263
+ * Alternative verification method when TOTP device unavailable.
2264
+ */
2265
+ static cfgTotpVerifyBackupCreate(options) {
2266
+ return (options.client ?? client).post({
2267
+ security: [{ scheme: "bearer", type: "http" }],
2268
+ url: "/cfg/totp/verify/backup/",
2269
+ ...options,
2270
+ headers: {
2271
+ "Content-Type": "application/json",
2272
+ ...options.headers
2273
+ }
2274
+ });
4810
2275
  }
4811
2276
  };
4812
2277
 
4813
- // src/_api/generated/index.ts
4814
- var isStaticBuild2 = process.env.NEXT_PUBLIC_STATIC_BUILD === "true";
4815
- var baseUrl = isStaticBuild2 ? "" : process.env.NEXT_PUBLIC_API_URL || "";
4816
- var cfgAccountsApi = new API(baseUrl, { storage: new LocalStorageAdapter() });
4817
- var cfgCentrifugoApi = new API2(baseUrl, { storage: new LocalStorageAdapter() });
4818
- var cfgTotpApi = new API3(baseUrl, { storage: new LocalStorageAdapter() });
4819
-
4820
2278
  // src/auth/utils/analytics.ts
4821
2279
  var AnalyticsEvent = /* @__PURE__ */ ((AnalyticsEvent2) => {
4822
2280
  AnalyticsEvent2["AUTH_OTP_REQUEST"] = "auth_otp_request";
@@ -4866,8 +2324,8 @@ var useTwoFactor = /* @__PURE__ */ __name((options = {}) => {
4866
2324
  setError(null);
4867
2325
  }, []);
4868
2326
  const handleSuccess = useCallback4((response) => {
4869
- cfgAccountsApi.setToken(response.access_token);
4870
- cfgAccountsApi.setRefreshToken(response.refresh_token);
2327
+ CfgAccountsApi.setToken(response.access_token);
2328
+ CfgAccountsApi.setRefreshToken(response.refresh_token);
4871
2329
  if (response.warning) {
4872
2330
  setWarning(response.warning);
4873
2331
  }
@@ -4905,7 +2363,7 @@ var useTwoFactor = /* @__PURE__ */ __name((options = {}) => {
4905
2363
  setError(null);
4906
2364
  try {
4907
2365
  authLogger.info("Verifying TOTP code...");
4908
- const result = await cfgTotpApi.totpVerification.cfgTotpVerifyCreate({
2366
+ const result = await TotpVerification.cfgTotpVerifyCreate({
4909
2367
  body: { session_id: sessionId, code },
4910
2368
  throwOnError: true
4911
2369
  });
@@ -4949,7 +2407,7 @@ var useTwoFactor = /* @__PURE__ */ __name((options = {}) => {
4949
2407
  setError(null);
4950
2408
  try {
4951
2409
  authLogger.info("Verifying backup code...");
4952
- const result = await cfgTotpApi.totpVerification.cfgTotpVerifyBackupCreate({
2410
+ const result = await TotpVerification.cfgTotpVerifyBackupCreate({
4953
2411
  body: {
4954
2412
  session_id: sessionId,
4955
2413
  backup_code: backupCode.replace(/\s+/g, "")
@@ -5293,7 +2751,7 @@ var useGithubAuth = /* @__PURE__ */ __name((options = {}) => {
5293
2751
  category: "auth" /* AUTH */,
5294
2752
  label: "github"
5295
2753
  });
5296
- const result = await cfgAccountsApi.oAuth.cfgAccountsOauthGithubAuthorizeCreate({
2754
+ const result = await OAuth.cfgAccountsOauthGithubAuthorizeCreate({
5297
2755
  body: {
5298
2756
  source_url: sourceUrl || (typeof window !== "undefined" ? window.location.href : "")
5299
2757
  },
@@ -5335,7 +2793,7 @@ var useGithubAuth = /* @__PURE__ */ __name((options = {}) => {
5335
2793
  sessionStorage.removeItem("oauth_state");
5336
2794
  sessionStorage.removeItem("oauth_provider");
5337
2795
  }
5338
- const result = await cfgAccountsApi.oAuth.cfgAccountsOauthGithubCallbackCreate({
2796
+ const result = await OAuth.cfgAccountsOauthGithubCallbackCreate({
5339
2797
  body: { code, state },
5340
2798
  throwOnError: true
5341
2799
  });
@@ -5353,8 +2811,8 @@ var useGithubAuth = /* @__PURE__ */ __name((options = {}) => {
5353
2811
  throw new Error("Invalid response from OAuth callback");
5354
2812
  }
5355
2813
  authLogger.info("GitHub OAuth successful, user:", response.user);
5356
- cfgAccountsApi.setToken(response.access);
5357
- cfgAccountsApi.setRefreshToken(response.refresh);
2814
+ CfgAccountsApi.setToken(response.access);
2815
+ CfgAccountsApi.setRefreshToken(response.refresh);
5358
2816
  Analytics.event("auth_login_success" /* AUTH_LOGIN_SUCCESS */, {
5359
2817
  category: "auth" /* AUTH */,
5360
2818
  label: "github"
@@ -5414,7 +2872,7 @@ var useTwoFactorSetup = /* @__PURE__ */ __name((options = {}) => {
5414
2872
  setSetupStep("scanning");
5415
2873
  try {
5416
2874
  authLogger.info("Starting 2FA setup...");
5417
- const result = await cfgTotpApi.totpSetup.cfgTotpSetupCreate({
2875
+ const result = await TotpSetup.cfgTotpSetupCreate({
5418
2876
  body: { device_name: deviceName },
5419
2877
  throwOnError: true
5420
2878
  });
@@ -5458,7 +2916,7 @@ var useTwoFactorSetup = /* @__PURE__ */ __name((options = {}) => {
5458
2916
  setSetupStep("confirming");
5459
2917
  try {
5460
2918
  authLogger.info("Confirming 2FA setup...");
5461
- const result = await cfgTotpApi.totpSetup.cfgTotpSetupConfirmCreate({
2919
+ const result = await TotpSetup.cfgTotpSetupConfirmCreate({
5462
2920
  body: { device_id: setupData.deviceId, code },
5463
2921
  throwOnError: true
5464
2922
  });
@@ -5521,7 +2979,7 @@ var useTwoFactorStatus = /* @__PURE__ */ __name(() => {
5521
2979
  setError(null);
5522
2980
  try {
5523
2981
  authLogger.info("Fetching 2FA status...");
5524
- const result = await cfgTotpApi.totpManagement.cfgTotpDevicesRetrieve({ throwOnError: true });
2982
+ const result = await TotpManagement.cfgTotpDevicesRetrieve({ throwOnError: true });
5525
2983
  const response = result.data;
5526
2984
  const mappedDevices = response.devices.map((device) => ({
5527
2985
  id: device.id,
@@ -5550,7 +3008,7 @@ var useTwoFactorStatus = /* @__PURE__ */ __name(() => {
5550
3008
  setError(null);
5551
3009
  try {
5552
3010
  authLogger.info("Disabling 2FA...");
5553
- await cfgTotpApi.totpManagement.cfgTotpDisableCreate({ body: { code }, throwOnError: true });
3011
+ await TotpManagement.cfgTotpDisableCreate({ body: { code }, throwOnError: true });
5554
3012
  setHas2FAEnabled(false);
5555
3013
  setDevices([]);
5556
3014
  authLogger.info("2FA disabled successfully");
@@ -6121,7 +3579,7 @@ function useTokenRefresh(options = {}) {
6121
3579
  authLogger.debug("Token refresh already in progress");
6122
3580
  return false;
6123
3581
  }
6124
- const refreshTokenValue = cfgAccountsApi.getRefreshToken();
3582
+ const refreshTokenValue = CfgAccountsApi.getRefreshToken();
6125
3583
  if (!refreshTokenValue) {
6126
3584
  authLogger.warn("No refresh token available");
6127
3585
  return false;
@@ -6129,7 +3587,7 @@ function useTokenRefresh(options = {}) {
6129
3587
  isRefreshingRef.current = true;
6130
3588
  authLogger.info("Refreshing token...");
6131
3589
  try {
6132
- const result = await cfgAccountsApi.auth.cfgAccountsTokenRefreshCreate({
3590
+ const result = await Auth.cfgAccountsTokenRefreshCreate({
6133
3591
  body: { refresh: refreshTokenValue },
6134
3592
  throwOnError: true
6135
3593
  });
@@ -6137,8 +3595,8 @@ function useTokenRefresh(options = {}) {
6137
3595
  if (!newAccessToken) {
6138
3596
  throw new Error("No access token in refresh response");
6139
3597
  }
6140
- cfgAccountsApi.setToken(newAccessToken);
6141
- cfgAccountsApi.setRefreshToken(refreshTokenValue);
3598
+ CfgAccountsApi.setToken(newAccessToken);
3599
+ CfgAccountsApi.setRefreshToken(refreshTokenValue);
6142
3600
  authLogger.info("Token refreshed successfully");
6143
3601
  onRefresh?.(newAccessToken);
6144
3602
  return true;
@@ -6151,7 +3609,7 @@ function useTokenRefresh(options = {}) {
6151
3609
  }
6152
3610
  }, [onRefresh, onRefreshError]);
6153
3611
  const checkAndRefresh = useCallback9(async () => {
6154
- const token = cfgAccountsApi.getToken();
3612
+ const token = CfgAccountsApi.getToken();
6155
3613
  if (!token) return;
6156
3614
  if (isTokenExpiringSoon(token, TOKEN_REFRESH_THRESHOLD_MS)) {
6157
3615
  authLogger.info("Token expiring soon, refreshing proactively");
@@ -6203,7 +3661,7 @@ var useDeleteAccount = /* @__PURE__ */ __name(() => {
6203
3661
  setError(null);
6204
3662
  try {
6205
3663
  authLogger.info("Deleting account...");
6206
- const result = await cfgAccountsApi.userProfile.cfgAccountsProfileDeleteCreate({ throwOnError: true });
3664
+ const result = await UserProfile.cfgAccountsProfileDeleteCreate({ throwOnError: true });
6207
3665
  const response = result.data;
6208
3666
  if (!response.success) {
6209
3667
  authLogger.error("Failed to delete account:", response.message);
@@ -6237,22 +3695,22 @@ import {
6237
3695
  useState as useState11
6238
3696
  } from "react";
6239
3697
 
6240
- // src/_api/generated/cfg_accounts/hooks/useCfgAccountsOauthConnectionsList.ts
3698
+ // src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthConnectionsList.ts
6241
3699
  import useSWR from "swr";
6242
3700
 
6243
- // src/_api/generated/cfg_accounts/hooks/useCfgAccountsOauthDisconnectCreate.ts
3701
+ // src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthDisconnectCreate.ts
6244
3702
  import useSWRMutation from "swr/mutation";
6245
3703
 
6246
- // src/_api/generated/cfg_accounts/hooks/useCfgAccountsOauthGithubAuthorizeCreate.ts
3704
+ // src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthGithubAuthorizeCreate.ts
6247
3705
  import useSWRMutation2 from "swr/mutation";
6248
3706
 
6249
- // src/_api/generated/cfg_accounts/hooks/useCfgAccountsOauthGithubCallbackCreate.ts
3707
+ // src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthGithubCallbackCreate.ts
6250
3708
  import useSWRMutation3 from "swr/mutation";
6251
3709
 
6252
- // src/_api/generated/cfg_accounts/hooks/useCfgAccountsOauthProvidersRetrieve.ts
3710
+ // src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthProvidersRetrieve.ts
6253
3711
  import useSWR2 from "swr";
6254
3712
 
6255
- // src/_api/generated/cfg_accounts/hooks/useCfgAccountsOtpRequestCreate.ts
3713
+ // src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOtpRequestCreate.ts
6256
3714
  import useSWRMutation4 from "swr/mutation";
6257
3715
  function useCfgAccountsOtpRequestCreate(config) {
6258
3716
  return useSWRMutation4(
@@ -6266,7 +3724,7 @@ function useCfgAccountsOtpRequestCreate(config) {
6266
3724
  }
6267
3725
  __name(useCfgAccountsOtpRequestCreate, "useCfgAccountsOtpRequestCreate");
6268
3726
 
6269
- // src/_api/generated/cfg_accounts/hooks/useCfgAccountsOtpVerifyCreate.ts
3727
+ // src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOtpVerifyCreate.ts
6270
3728
  import useSWRMutation5 from "swr/mutation";
6271
3729
  function useCfgAccountsOtpVerifyCreate(config) {
6272
3730
  return useSWRMutation5(
@@ -6280,7 +3738,7 @@ function useCfgAccountsOtpVerifyCreate(config) {
6280
3738
  }
6281
3739
  __name(useCfgAccountsOtpVerifyCreate, "useCfgAccountsOtpVerifyCreate");
6282
3740
 
6283
- // src/_api/generated/cfg_accounts/hooks/useCfgAccountsProfileAvatarCreate.ts
3741
+ // src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileAvatarCreate.ts
6284
3742
  import useSWRMutation6 from "swr/mutation";
6285
3743
  function useCfgAccountsProfileAvatarCreate(config) {
6286
3744
  return useSWRMutation6(
@@ -6294,13 +3752,13 @@ function useCfgAccountsProfileAvatarCreate(config) {
6294
3752
  }
6295
3753
  __name(useCfgAccountsProfileAvatarCreate, "useCfgAccountsProfileAvatarCreate");
6296
3754
 
6297
- // src/_api/generated/cfg_accounts/hooks/useCfgAccountsProfileDeleteCreate.ts
3755
+ // src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileDeleteCreate.ts
6298
3756
  import useSWRMutation7 from "swr/mutation";
6299
3757
 
6300
- // src/_api/generated/cfg_accounts/hooks/useCfgAccountsProfilePartialPartialUpdate.ts
3758
+ // src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfilePartialPartialUpdate.ts
6301
3759
  import useSWRMutation8 from "swr/mutation";
6302
3760
 
6303
- // src/_api/generated/cfg_accounts/hooks/useCfgAccountsProfilePartialUpdate.ts
3761
+ // src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfilePartialUpdate.ts
6304
3762
  import useSWRMutation9 from "swr/mutation";
6305
3763
  function useCfgAccountsProfilePartialUpdate(config) {
6306
3764
  return useSWRMutation9(
@@ -6314,13 +3772,13 @@ function useCfgAccountsProfilePartialUpdate(config) {
6314
3772
  }
6315
3773
  __name(useCfgAccountsProfilePartialUpdate, "useCfgAccountsProfilePartialUpdate");
6316
3774
 
6317
- // src/_api/generated/cfg_accounts/hooks/useCfgAccountsProfileRetrieve.ts
3775
+ // src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileRetrieve.ts
6318
3776
  import useSWR3 from "swr";
6319
3777
 
6320
- // src/_api/generated/cfg_accounts/hooks/useCfgAccountsProfileUpdatePartialUpdate.ts
3778
+ // src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileUpdatePartialUpdate.ts
6321
3779
  import useSWRMutation10 from "swr/mutation";
6322
3780
 
6323
- // src/_api/generated/cfg_accounts/hooks/useCfgAccountsProfileUpdateUpdate.ts
3781
+ // src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileUpdateUpdate.ts
6324
3782
  import useSWRMutation11 from "swr/mutation";
6325
3783
  function useCfgAccountsProfileUpdateUpdate(config) {
6326
3784
  return useSWRMutation11(
@@ -6334,7 +3792,7 @@ function useCfgAccountsProfileUpdateUpdate(config) {
6334
3792
  }
6335
3793
  __name(useCfgAccountsProfileUpdateUpdate, "useCfgAccountsProfileUpdateUpdate");
6336
3794
 
6337
- // src/_api/generated/cfg_accounts/hooks/useCfgAccountsTokenRefreshCreate.ts
3795
+ // src/_api/generated/_cfg_accounts/hooks/useCfgAccountsTokenRefreshCreate.ts
6338
3796
  import useSWRMutation12 from "swr/mutation";
6339
3797
  function useCfgAccountsTokenRefreshCreate(config) {
6340
3798
  return useSWRMutation12(
@@ -6348,6 +3806,195 @@ function useCfgAccountsTokenRefreshCreate(config) {
6348
3806
  }
6349
3807
  __name(useCfgAccountsTokenRefreshCreate, "useCfgAccountsTokenRefreshCreate");
6350
3808
 
3809
+ // src/_api/generated/_cfg_accounts/schemas/AccountDeleteResponse.ts
3810
+ import { z } from "zod";
3811
+ var AccountDeleteResponseSchema = z.object({
3812
+ message: z.string(),
3813
+ success: z.boolean()
3814
+ });
3815
+
3816
+ // src/_api/generated/_cfg_accounts/schemas/CentrifugoToken.ts
3817
+ import { z as z2 } from "zod";
3818
+ var CentrifugoTokenSchema = z2.object({
3819
+ centrifugo_url: z2.string(),
3820
+ channels: z2.array(z2.string()),
3821
+ expires_at: z2.string().datetime({ offset: true }),
3822
+ token: z2.string()
3823
+ });
3824
+
3825
+ // src/_api/generated/_cfg_accounts/schemas/CfgUserUpdateRequest.ts
3826
+ import { z as z3 } from "zod";
3827
+ var CfgUserUpdateRequestSchema = z3.object({
3828
+ company: z3.string().max(100).optional(),
3829
+ first_name: z3.string().max(50).optional(),
3830
+ language: z3.string().max(10).optional(),
3831
+ last_name: z3.string().max(50).optional(),
3832
+ phone: z3.string().max(20).optional(),
3833
+ position: z3.string().max(100).optional()
3834
+ });
3835
+
3836
+ // src/_api/generated/_cfg_accounts/schemas/OAuthAuthorizeRequestRequest.ts
3837
+ import { z as z4 } from "zod";
3838
+ var OAuthAuthorizeRequestRequestSchema = z4.object({
3839
+ redirect_uri: z4.string().optional(),
3840
+ source_url: z4.string().optional()
3841
+ });
3842
+
3843
+ // src/_api/generated/_cfg_accounts/schemas/OAuthAuthorizeResponse.ts
3844
+ import { z as z5 } from "zod";
3845
+ var OAuthAuthorizeResponseSchema = z5.object({
3846
+ authorization_url: z5.string(),
3847
+ state: z5.string()
3848
+ });
3849
+
3850
+ // src/_api/generated/_cfg_accounts/schemas/OAuthCallbackRequestRequest.ts
3851
+ import { z as z6 } from "zod";
3852
+ var OAuthCallbackRequestRequestSchema = z6.object({
3853
+ code: z6.string().min(10).max(500),
3854
+ redirect_uri: z6.string().optional(),
3855
+ state: z6.string().min(20).max(100)
3856
+ });
3857
+
3858
+ // src/_api/generated/_cfg_accounts/schemas/OAuthConnection.ts
3859
+ import { z as z8 } from "zod";
3860
+
3861
+ // src/_api/generated/_cfg_accounts/schemas/ProviderEnum.ts
3862
+ import { z as z7 } from "zod";
3863
+ var ProviderEnumSchema = z7.enum(["github"]);
3864
+
3865
+ // src/_api/generated/_cfg_accounts/schemas/OAuthConnection.ts
3866
+ var OAuthConnectionSchema = z8.object({
3867
+ connected_at: z8.string().datetime({ offset: true }),
3868
+ id: z8.number().int(),
3869
+ last_login_at: z8.string().datetime({ offset: true }),
3870
+ provider: ProviderEnumSchema,
3871
+ provider_avatar_url: z8.string(),
3872
+ provider_display: z8.string(),
3873
+ provider_email: z8.email(),
3874
+ provider_username: z8.string()
3875
+ });
3876
+
3877
+ // src/_api/generated/_cfg_accounts/schemas/OAuthDisconnectRequestRequest.ts
3878
+ import { z as z9 } from "zod";
3879
+ var OAuthDisconnectRequestRequestSchema = z9.object({
3880
+ provider: ProviderEnumSchema
3881
+ });
3882
+
3883
+ // src/_api/generated/_cfg_accounts/schemas/OAuthError.ts
3884
+ import { z as z10 } from "zod";
3885
+ var OAuthErrorSchema = z10.object({
3886
+ error: z10.string(),
3887
+ error_description: z10.string().optional()
3888
+ });
3889
+
3890
+ // src/_api/generated/_cfg_accounts/schemas/OAuthProvidersResponse.ts
3891
+ import { z as z11 } from "zod";
3892
+ var OAuthProvidersResponseSchema = z11.object({
3893
+ providers: z11.array(z11.object({}).passthrough())
3894
+ });
3895
+
3896
+ // src/_api/generated/_cfg_accounts/schemas/OAuthTokenResponse.ts
3897
+ import { z as z12 } from "zod";
3898
+ var OAuthTokenResponseSchema = z12.object({
3899
+ access: z12.string().nullable().optional(),
3900
+ is_new_connection: z12.boolean(),
3901
+ is_new_user: z12.boolean(),
3902
+ refresh: z12.string().nullable().optional(),
3903
+ requires_2fa: z12.boolean().default(false).optional(),
3904
+ session_id: z12.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(),
3905
+ should_prompt_2fa: z12.boolean().optional(),
3906
+ user: z12.object({}).passthrough().nullable().optional()
3907
+ });
3908
+
3909
+ // src/_api/generated/_cfg_accounts/schemas/OTPErrorResponse.ts
3910
+ import { z as z13 } from "zod";
3911
+ var OTPErrorResponseSchema = z13.object({
3912
+ error: z13.string(),
3913
+ error_code: z13.string().nullable().optional(),
3914
+ retry_after: z13.number().int().nullable().optional()
3915
+ });
3916
+
3917
+ // src/_api/generated/_cfg_accounts/schemas/OTPRequestRequest.ts
3918
+ import { z as z14 } from "zod";
3919
+ var OTPRequestRequestSchema = z14.object({
3920
+ identifier: z14.string().min(1),
3921
+ source_url: z14.string().optional()
3922
+ });
3923
+
3924
+ // src/_api/generated/_cfg_accounts/schemas/OTPRequestResponse.ts
3925
+ import { z as z15 } from "zod";
3926
+ var OTPRequestResponseSchema = z15.object({
3927
+ message: z15.string()
3928
+ });
3929
+
3930
+ // src/_api/generated/_cfg_accounts/schemas/OTPVerifyRequest.ts
3931
+ import { z as z16 } from "zod";
3932
+ var OTPVerifyRequestSchema = z16.object({
3933
+ identifier: z16.string().min(1),
3934
+ otp: z16.string().min(6).max(6),
3935
+ source_url: z16.string().optional()
3936
+ });
3937
+
3938
+ // src/_api/generated/_cfg_accounts/schemas/OTPVerifyResponse.ts
3939
+ import { z as z18 } from "zod";
3940
+
3941
+ // src/_api/generated/_cfg_accounts/schemas/User.ts
3942
+ import { z as z17 } from "zod";
3943
+ var UserSchema = z17.object({
3944
+ avatar: z17.string().nullable(),
3945
+ centrifugo: CentrifugoTokenSchema.nullable(),
3946
+ company: z17.string().max(100).optional(),
3947
+ date_joined: z17.string().datetime({ offset: true }),
3948
+ display_username: z17.string(),
3949
+ email: z17.email(),
3950
+ first_name: z17.string().max(50).optional(),
3951
+ full_name: z17.string(),
3952
+ id: z17.number().int(),
3953
+ initials: z17.string(),
3954
+ is_staff: z17.boolean(),
3955
+ is_superuser: z17.boolean(),
3956
+ language: z17.string().max(10).optional(),
3957
+ last_login: z17.string().datetime({ offset: true }).nullable(),
3958
+ last_name: z17.string().max(50).optional(),
3959
+ phone: z17.string().max(20).optional(),
3960
+ position: z17.string().max(100).optional(),
3961
+ unanswered_messages_count: z17.number().int().default(0)
3962
+ });
3963
+
3964
+ // src/_api/generated/_cfg_accounts/schemas/OTPVerifyResponse.ts
3965
+ var OTPVerifyResponseSchema = z18.object({
3966
+ access: z18.string().nullable().optional(),
3967
+ refresh: z18.string().nullable().optional(),
3968
+ requires_2fa: z18.boolean().default(false).optional(),
3969
+ session_id: z18.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(),
3970
+ should_prompt_2fa: z18.boolean().optional(),
3971
+ user: UserSchema.nullable().optional()
3972
+ });
3973
+
3974
+ // src/_api/generated/_cfg_accounts/schemas/PatchedCfgUserUpdateRequest.ts
3975
+ import { z as z19 } from "zod";
3976
+ var PatchedCfgUserUpdateRequestSchema = z19.object({
3977
+ company: z19.string().max(100).optional(),
3978
+ first_name: z19.string().max(50).optional(),
3979
+ language: z19.string().max(10).optional(),
3980
+ last_name: z19.string().max(50).optional(),
3981
+ phone: z19.string().max(20).optional(),
3982
+ position: z19.string().max(100).optional()
3983
+ });
3984
+
3985
+ // src/_api/generated/_cfg_accounts/schemas/TokenRefresh.ts
3986
+ import { z as z20 } from "zod";
3987
+ var TokenRefreshSchema = z20.object({
3988
+ access: z20.string(),
3989
+ refresh: z20.string()
3990
+ });
3991
+
3992
+ // src/_api/generated/_cfg_accounts/schemas/TokenRefreshRequest.ts
3993
+ import { z as z21 } from "zod";
3994
+ var TokenRefreshRequestSchema = z21.object({
3995
+ refresh: z21.string().min(1)
3996
+ });
3997
+
6351
3998
  // src/auth/context/AccountsContext.tsx
6352
3999
  import { jsx } from "react/jsx-runtime";
6353
4000
  var AccountsContext = createContext(void 0);
@@ -6424,8 +4071,8 @@ function AccountsProvider({ children }) {
6424
4071
  return result;
6425
4072
  }
6426
4073
  if (result.access && result.refresh) {
6427
- cfgAccountsApi.setToken(result.access);
6428
- cfgAccountsApi.setRefreshToken(result.refresh);
4074
+ CfgAccountsApi.setToken(result.access);
4075
+ CfgAccountsApi.setRefreshToken(result.refresh);
6429
4076
  try {
6430
4077
  await refreshProfile({ callerId: "verifyOTP", force: true });
6431
4078
  } catch (profileError2) {
@@ -6438,13 +4085,13 @@ function AccountsProvider({ children }) {
6438
4085
  const body = { refresh };
6439
4086
  const result = await triggerTokenRefresh({ body });
6440
4087
  if (result.access) {
6441
- cfgAccountsApi.setToken(result.access);
6442
- cfgAccountsApi.setRefreshToken(refresh);
4088
+ CfgAccountsApi.setToken(result.access);
4089
+ CfgAccountsApi.setRefreshToken(refresh);
6443
4090
  }
6444
4091
  return result;
6445
4092
  }, "refreshToken");
6446
4093
  const logout = useCallback11(() => {
6447
- cfgAccountsApi.clearToken();
4094
+ CfgAccountsApi.clearToken();
6448
4095
  setProfile(void 0);
6449
4096
  setProfileError(null);
6450
4097
  clearProfileCache();
@@ -6485,7 +4132,7 @@ var AuthContext = createContext2(void 0);
6485
4132
  var EMAIL_STORAGE_KEY = "auth_email";
6486
4133
  var hasValidTokens = /* @__PURE__ */ __name(() => {
6487
4134
  if (typeof window === "undefined") return false;
6488
- return cfgAccountsApi.isAuthenticated();
4135
+ return CfgAccountsApi.isAuthenticated();
6489
4136
  }, "hasValidTokens");
6490
4137
  var AuthProviderInternal = /* @__PURE__ */ __name(({ children, config }) => {
6491
4138
  const accounts = useAccountsContext();
@@ -6526,7 +4173,7 @@ var AuthProviderInternal = /* @__PURE__ */ __name(({ children, config }) => {
6526
4173
  }, [config]);
6527
4174
  const clearAuthState = useCallback12((caller) => {
6528
4175
  authLogger.info("clearAuthState >> caller", caller);
6529
- cfgAccountsApi.clearToken();
4176
+ CfgAccountsApi.clearToken();
6530
4177
  clearProfileCache();
6531
4178
  setInitialized(true);
6532
4179
  setIsLoading(false);
@@ -6564,8 +4211,8 @@ var AuthProviderInternal = /* @__PURE__ */ __name(({ children, config }) => {
6564
4211
  authLogger.debug(`loadCurrentProfile called by: ${finalCallerId}`);
6565
4212
  try {
6566
4213
  isLoadingProfileRef.current = true;
6567
- const isAuth = cfgAccountsApi.isAuthenticated();
6568
- const token = cfgAccountsApi.getToken();
4214
+ const isAuth = CfgAccountsApi.isAuthenticated();
4215
+ const token = CfgAccountsApi.getToken();
6569
4216
  if (!isAuth) {
6570
4217
  authLogger.warn("No valid authentication token, throwing error");
6571
4218
  throw new Error("No valid authentication token");
@@ -6602,8 +4249,8 @@ var AuthProviderInternal = /* @__PURE__ */ __name(({ children, config }) => {
6602
4249
  authLogger.info("Initializing auth...");
6603
4250
  const isInIframe = typeof window !== "undefined" && window.self !== window.top;
6604
4251
  authLogger.info("Is in iframe:", isInIframe);
6605
- const token = cfgAccountsApi.getToken();
6606
- const refreshToken2 = cfgAccountsApi.getRefreshToken();
4252
+ const token = CfgAccountsApi.getToken();
4253
+ const refreshToken2 = CfgAccountsApi.getRefreshToken();
6607
4254
  authLogger.info("Token from API:", token ? `${token.substring(0, 20)}...` : "null");
6608
4255
  authLogger.info("Refresh token from API:", refreshToken2 ? `${refreshToken2.substring(0, 20)}...` : "null");
6609
4256
  authLogger.info("localStorage keys:", Object.keys(localStorage).filter((k) => k.includes("token") || k.includes("auth")));
@@ -6654,7 +4301,7 @@ var AuthProviderInternal = /* @__PURE__ */ __name(({ children, config }) => {
6654
4301
  }, [initialized]);
6655
4302
  useEffect9(() => {
6656
4303
  if (!initialized) return;
6657
- const isAuthenticated = cfgAccountsApi.isAuthenticated();
4304
+ const isAuthenticated = CfgAccountsApi.isAuthenticated();
6658
4305
  const authRoute = config?.routes?.auth || defaultRoutes.auth;
6659
4306
  const isAuthPage = pathname === authRoute;
6660
4307
  const flowParam = queryParams.get("flow");
@@ -6674,7 +4321,7 @@ var AuthProviderInternal = /* @__PURE__ */ __name(({ children, config }) => {
6674
4321
  const checkAuthAndRedirect = useCallback12(async () => {
6675
4322
  try {
6676
4323
  setIsLoading(true);
6677
- const isAuthenticated = cfgAccountsApi.isAuthenticated();
4324
+ const isAuthenticated = CfgAccountsApi.isAuthenticated();
6678
4325
  if (isAuthenticated) {
6679
4326
  await loadCurrentProfile();
6680
4327
  if (userRef.current) {
@@ -6695,7 +4342,7 @@ var AuthProviderInternal = /* @__PURE__ */ __name(({ children, config }) => {
6695
4342
  }, [loadCurrentProfile, clearAuthState, pushToDefaultCallbackUrl, pushToDefaultAuthCallbackUrl, handleGlobalAuthError]);
6696
4343
  const requestOTP = useCallback12(
6697
4344
  async (identifier, sourceUrl) => {
6698
- cfgAccountsApi.clearToken();
4345
+ CfgAccountsApi.clearToken();
6699
4346
  try {
6700
4347
  const result = await accounts.requestOTP({
6701
4348
  identifier,
@@ -6797,7 +4444,7 @@ var AuthProviderInternal = /* @__PURE__ */ __name(({ children, config }) => {
6797
4444
  );
6798
4445
  const refreshToken = useCallback12(async () => {
6799
4446
  try {
6800
- const refreshTokenValue = cfgAccountsApi.getRefreshToken();
4447
+ const refreshTokenValue = CfgAccountsApi.getRefreshToken();
6801
4448
  if (!refreshTokenValue) {
6802
4449
  clearAuthState("refreshToken:noToken");
6803
4450
  Analytics.event("auth_session_expired" /* AUTH_SESSION_EXPIRED */, {
@@ -6860,12 +4507,12 @@ var AuthProviderInternal = /* @__PURE__ */ __name(({ children, config }) => {
6860
4507
  user,
6861
4508
  isLoading,
6862
4509
  // Consider authenticated if we have valid tokens, even without user profile
6863
- isAuthenticated: cfgAccountsApi.isAuthenticated(),
4510
+ isAuthenticated: CfgAccountsApi.isAuthenticated(),
6864
4511
  isAdminUser,
6865
4512
  loadCurrentProfile,
6866
4513
  checkAuthAndRedirect,
6867
- getToken: /* @__PURE__ */ __name(() => cfgAccountsApi.getToken(), "getToken"),
6868
- getRefreshToken: /* @__PURE__ */ __name(() => cfgAccountsApi.getRefreshToken(), "getRefreshToken"),
4514
+ getToken: /* @__PURE__ */ __name(() => CfgAccountsApi.getToken(), "getToken"),
4515
+ getRefreshToken: /* @__PURE__ */ __name(() => CfgAccountsApi.getRefreshToken(), "getRefreshToken"),
6869
4516
  getSavedEmail: /* @__PURE__ */ __name(() => storedEmail, "getSavedEmail"),
6870
4517
  saveEmail: setStoredEmail,
6871
4518
  clearSavedEmail: clearStoredEmail,