@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
@@ -21,37 +21,12 @@ var proxyMiddlewareConfig = {
21
21
  matcher: ["/media/:path*", "/api/:path*"]
22
22
  };
23
23
 
24
- // src/_api/generated/cfg_accounts/core/bodySerializer.gen.ts
25
- var serializeFormDataPair = /* @__PURE__ */ __name((data, key, value) => {
26
- if (typeof value === "string" || value instanceof Blob) {
27
- data.append(key, value);
28
- } else if (value instanceof Date) {
29
- data.append(key, value.toISOString());
30
- } else {
31
- data.append(key, JSON.stringify(value));
32
- }
33
- }, "serializeFormDataPair");
34
- var formDataBodySerializer = {
35
- bodySerializer: /* @__PURE__ */ __name((body) => {
36
- const data = new FormData();
37
- Object.entries(body).forEach(([key, value]) => {
38
- if (value === void 0 || value === null) {
39
- return;
40
- }
41
- if (Array.isArray(value)) {
42
- value.forEach((v) => serializeFormDataPair(data, key, v));
43
- } else {
44
- serializeFormDataPair(data, key, value);
45
- }
46
- });
47
- return data;
48
- }, "bodySerializer")
49
- };
24
+ // src/_api/generated/core/bodySerializer.gen.ts
50
25
  var jsonBodySerializer = {
51
26
  bodySerializer: /* @__PURE__ */ __name((body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value), "bodySerializer")
52
27
  };
53
28
 
54
- // src/_api/generated/cfg_accounts/core/params.gen.ts
29
+ // src/_api/generated/core/params.gen.ts
55
30
  var extraPrefixesMap = {
56
31
  $body_: "body",
57
32
  $headers_: "headers",
@@ -60,7 +35,7 @@ var extraPrefixesMap = {
60
35
  };
61
36
  var extraPrefixes = Object.entries(extraPrefixesMap);
62
37
 
63
- // src/_api/generated/cfg_accounts/core/serverSentEvents.gen.ts
38
+ // src/_api/generated/core/serverSentEvents.gen.ts
64
39
  function createSseClient({
65
40
  onRequest,
66
41
  onSseError,
@@ -188,7 +163,7 @@ function createSseClient({
188
163
  }
189
164
  __name(createSseClient, "createSseClient");
190
165
 
191
- // src/_api/generated/cfg_accounts/core/pathSerializer.gen.ts
166
+ // src/_api/generated/core/pathSerializer.gen.ts
192
167
  var separatorArrayExplode = /* @__PURE__ */ __name((style) => {
193
168
  switch (style) {
194
169
  case "label":
@@ -312,7 +287,7 @@ var serializeObjectParam = /* @__PURE__ */ __name(({
312
287
  return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
313
288
  }, "serializeObjectParam");
314
289
 
315
- // src/_api/generated/cfg_accounts/core/utils.gen.ts
290
+ // src/_api/generated/core/utils.gen.ts
316
291
  var PATH_PARAM_RE = /\{[^{}]+\}/g;
317
292
  var defaultPathSerializer = /* @__PURE__ */ __name(({ path, url: _url }) => {
318
293
  let url = _url;
@@ -410,7 +385,7 @@ function getValidRequestBody(options) {
410
385
  }
411
386
  __name(getValidRequestBody, "getValidRequestBody");
412
387
 
413
- // src/_api/generated/cfg_accounts/core/auth.gen.ts
388
+ // src/_api/generated/core/auth.gen.ts
414
389
  var getAuthToken = /* @__PURE__ */ __name(async (auth, callback) => {
415
390
  const token = typeof callback === "function" ? await callback(auth) : callback;
416
391
  if (!token) {
@@ -425,7 +400,7 @@ var getAuthToken = /* @__PURE__ */ __name(async (auth, callback) => {
425
400
  return token;
426
401
  }, "getAuthToken");
427
402
 
428
- // src/_api/generated/cfg_accounts/client/utils.gen.ts
403
+ // src/_api/generated/client/utils.gen.ts
429
404
  var createQuerySerializer = /* @__PURE__ */ __name(({
430
405
  parameters = {},
431
406
  ...args
@@ -644,7 +619,7 @@ var createConfig = /* @__PURE__ */ __name((override = {}) => ({
644
619
  ...override
645
620
  }), "createConfig");
646
621
 
647
- // src/_api/generated/cfg_accounts/client/client.gen.ts
622
+ // src/_api/generated/client/client.gen.ts
648
623
  var createClient = /* @__PURE__ */ __name((config = {}) => {
649
624
  let _config = mergeConfigs(createConfig(), config);
650
625
  const getConfig = /* @__PURE__ */ __name(() => ({ ..._config }), "getConfig");
@@ -842,10 +817,10 @@ var createClient = /* @__PURE__ */ __name((config = {}) => {
842
817
  };
843
818
  }, "createClient");
844
819
 
845
- // src/_api/generated/cfg_accounts/client.gen.ts
820
+ // src/_api/generated/client.gen.ts
846
821
  var client = createClient(createConfig({ baseUrl: "http://localhost:8000" }));
847
822
 
848
- // src/_api/generated/_shared/storage.ts
823
+ // src/_api/generated/helpers/storage.ts
849
824
  var LocalStorageAdapter = class {
850
825
  static {
851
826
  __name(this, "LocalStorageAdapter");
@@ -881,7 +856,7 @@ var LocalStorageAdapter = class {
881
856
  }
882
857
  };
883
858
 
884
- // src/_api/generated/_shared/logger.ts
859
+ // src/_api/generated/helpers/logger.ts
885
860
  import { createConsola } from "consola";
886
861
  var DEFAULT_CONFIG = {
887
862
  enabled: typeof process !== "undefined" && process.env.NODE_ENV !== "production",
@@ -975,3431 +950,185 @@ var APILogger = class {
975
950
  };
976
951
  var defaultLogger = new APILogger();
977
952
 
978
- // src/_api/generated/cfg_accounts/sdk.gen.ts
979
- var Cfg = class {
980
- static {
981
- __name(this, "Cfg");
982
- }
983
- /**
984
- * List OAuth connections
985
- *
986
- * Get all OAuth connections for the current user.
987
- */
988
- static cfgAccountsOauthConnectionsList(options) {
989
- return (options?.client ?? client).get({
990
- security: [{ scheme: "bearer", type: "http" }],
991
- url: "/cfg/accounts/oauth/connections/",
992
- ...options
993
- });
953
+ // src/_api/generated/_cfg_accounts/api.ts
954
+ var ACCESS_KEY = "cfg.access_token";
955
+ var REFRESH_KEY = "cfg.refresh_token";
956
+ function detectLocale() {
957
+ try {
958
+ if (typeof document !== "undefined") {
959
+ const m = document.cookie.match(/(?:^|;\s*)NEXT_LOCALE=([^;]*)/);
960
+ if (m) return decodeURIComponent(m[1]);
961
+ }
962
+ if (typeof navigator !== "undefined" && navigator.language) {
963
+ return navigator.language;
964
+ }
965
+ } catch {
994
966
  }
995
- /**
996
- * Disconnect OAuth provider
997
- *
998
- * Remove OAuth connection for the specified provider.
999
- */
1000
- static cfgAccountsOauthDisconnectCreate(options) {
1001
- return (options.client ?? client).post({
1002
- security: [{ scheme: "bearer", type: "http" }],
1003
- url: "/cfg/accounts/oauth/disconnect/",
1004
- ...options,
1005
- headers: {
1006
- "Content-Type": "application/json",
1007
- ...options.headers
1008
- }
1009
- });
967
+ return null;
968
+ }
969
+ __name(detectLocale, "detectLocale");
970
+ var API = class {
971
+ static {
972
+ __name(this, "API");
1010
973
  }
1011
- /**
1012
- * Start GitHub OAuth
1013
- *
1014
- * Generate GitHub OAuth authorization URL. Redirect user to this URL to start authentication.
1015
- */
1016
- static cfgAccountsOauthGithubAuthorizeCreate(options) {
1017
- return (options?.client ?? client).post({
1018
- url: "/cfg/accounts/oauth/github/authorize/",
1019
- ...options,
1020
- headers: {
1021
- "Content-Type": "application/json",
1022
- ...options?.headers
1023
- }
974
+ baseUrl;
975
+ storage;
976
+ locale;
977
+ apiKey;
978
+ logger;
979
+ constructor(baseUrl2, opts = {}) {
980
+ this.baseUrl = baseUrl2.replace(/\/$/, "");
981
+ this.storage = opts.storage ?? new LocalStorageAdapter();
982
+ this.logger = new APILogger(opts.logger);
983
+ this.locale = opts.locale ?? null;
984
+ this.apiKey = opts.apiKey ?? (typeof process !== "undefined" ? process.env?.NEXT_PUBLIC_API_KEY ?? null : null);
985
+ const credentials = opts.withCredentials ?? true ? "include" : "same-origin";
986
+ client.setConfig({ baseUrl: this.baseUrl, credentials });
987
+ client.interceptors.request.use((request) => {
988
+ const access = this.getToken();
989
+ if (access) request.headers.set("Authorization", `Bearer ${access}`);
990
+ const locale = this.locale ?? detectLocale();
991
+ if (locale) request.headers.set("Accept-Language", locale);
992
+ if (this.apiKey) request.headers.set("X-API-Key", this.apiKey);
993
+ return request;
1024
994
  });
1025
995
  }
1026
- /**
1027
- * Complete GitHub OAuth
1028
- *
1029
- * Exchange authorization code for JWT tokens. Call this after GitHub redirects back with code.
1030
- */
1031
- static cfgAccountsOauthGithubCallbackCreate(options) {
1032
- return (options.client ?? client).post({
1033
- url: "/cfg/accounts/oauth/github/callback/",
1034
- ...options,
1035
- headers: {
1036
- "Content-Type": "application/json",
1037
- ...options.headers
1038
- }
1039
- });
996
+ // ── Base URL ────────────────────────────────────────────────────────────
997
+ getBaseUrl() {
998
+ return this.baseUrl;
1040
999
  }
1041
- /**
1042
- * List OAuth providers
1043
- *
1044
- * Get list of available OAuth providers for authentication.
1045
- */
1046
- static cfgAccountsOauthProvidersRetrieve(options) {
1047
- return (options?.client ?? client).get({ url: "/cfg/accounts/oauth/providers/", ...options });
1000
+ setBaseUrl(url) {
1001
+ this.baseUrl = url.replace(/\/$/, "");
1002
+ client.setConfig({ baseUrl: this.baseUrl });
1048
1003
  }
1049
- /**
1050
- * Request OTP code to email.
1051
- */
1052
- static cfgAccountsOtpRequestCreate(options) {
1053
- return (options.client ?? client).post({
1054
- security: [{ scheme: "bearer", type: "http" }],
1055
- url: "/cfg/accounts/otp/request/",
1056
- ...options,
1057
- headers: {
1058
- "Content-Type": "application/json",
1059
- ...options.headers
1060
- }
1061
- });
1004
+ // ── Tokens ──────────────────────────────────────────────────────────────
1005
+ getToken() {
1006
+ return this.storage.getItem(ACCESS_KEY);
1062
1007
  }
1063
- /**
1064
- * Verify OTP code and return JWT tokens or 2FA session.
1065
- *
1066
- * If user has 2FA enabled:
1067
- * - Returns requires_2fa=True with session_id
1068
- * - Client must complete 2FA verification at /cfg/totp/verify/
1069
- *
1070
- * If user has no 2FA:
1071
- * - Returns JWT tokens and user data directly
1072
- */
1073
- static cfgAccountsOtpVerifyCreate(options) {
1074
- return (options.client ?? client).post({
1075
- security: [{ scheme: "bearer", type: "http" }],
1076
- url: "/cfg/accounts/otp/verify/",
1077
- ...options,
1078
- headers: {
1079
- "Content-Type": "application/json",
1080
- ...options.headers
1081
- }
1082
- });
1008
+ setToken(token) {
1009
+ if (token) this.storage.setItem(ACCESS_KEY, token);
1010
+ else this.storage.removeItem(ACCESS_KEY);
1083
1011
  }
1084
- /**
1085
- * Get current user profile
1086
- *
1087
- * Retrieve the current authenticated user's profile information.
1088
- */
1089
- static cfgAccountsProfileRetrieve(options) {
1090
- return (options?.client ?? client).get({
1091
- security: [{ scheme: "bearer", type: "http" }, {
1092
- in: "cookie",
1093
- name: "sessionid",
1094
- type: "apiKey"
1095
- }],
1096
- url: "/cfg/accounts/profile/",
1097
- ...options
1098
- });
1012
+ getRefreshToken() {
1013
+ return this.storage.getItem(REFRESH_KEY);
1099
1014
  }
1100
- /**
1101
- * Upload user avatar
1102
- *
1103
- * Upload avatar image for the current authenticated user. Accepts multipart/form-data with 'avatar' field.
1104
- */
1105
- static cfgAccountsProfileAvatarCreate(options) {
1106
- return (options?.client ?? client).post({
1107
- ...formDataBodySerializer,
1108
- security: [{ scheme: "bearer", type: "http" }],
1109
- url: "/cfg/accounts/profile/avatar/",
1110
- ...options,
1111
- headers: {
1112
- "Content-Type": null,
1113
- ...options?.headers
1114
- }
1115
- });
1015
+ setRefreshToken(token) {
1016
+ if (token) this.storage.setItem(REFRESH_KEY, token);
1017
+ else this.storage.removeItem(REFRESH_KEY);
1116
1018
  }
1117
- /**
1118
- * Delete user account
1119
- *
1120
- *
1121
- * Permanently delete the current user's account.
1122
- *
1123
- * This operation:
1124
- * - Deactivates the account (user cannot log in)
1125
- * - Anonymizes personal data (GDPR compliance)
1126
- * - Frees up the email address for re-registration
1127
- * - Preserves audit trail
1128
- *
1129
- * The account can be restored by an administrator if needed.
1130
- *
1131
- */
1132
- static cfgAccountsProfileDeleteCreate(options) {
1133
- return (options?.client ?? client).post({
1134
- security: [{ scheme: "bearer", type: "http" }, {
1135
- in: "cookie",
1136
- name: "sessionid",
1137
- type: "apiKey"
1138
- }],
1139
- url: "/cfg/accounts/profile/delete/",
1140
- ...options
1141
- });
1019
+ clearToken() {
1020
+ this.storage.removeItem(ACCESS_KEY);
1021
+ this.storage.removeItem(REFRESH_KEY);
1142
1022
  }
1143
- /**
1144
- * Partial update user profile
1145
- *
1146
- * Partially update the current authenticated user's profile information. Supports avatar upload.
1147
- */
1148
- static cfgAccountsProfilePartialPartialUpdate(options) {
1149
- return (options?.client ?? client).patch({
1150
- security: [{ scheme: "bearer", type: "http" }, {
1151
- in: "cookie",
1152
- name: "sessionid",
1153
- type: "apiKey"
1154
- }],
1155
- url: "/cfg/accounts/profile/partial/",
1156
- ...options,
1157
- headers: {
1158
- "Content-Type": "application/json",
1159
- ...options?.headers
1160
- }
1161
- });
1023
+ isAuthenticated() {
1024
+ return this.getToken() !== null;
1162
1025
  }
1163
- /**
1164
- * Partial update user profile
1165
- *
1166
- * Partially update the current authenticated user's profile information. Supports avatar upload.
1167
- */
1168
- static cfgAccountsProfilePartialUpdate(options) {
1169
- return (options?.client ?? client).put({
1170
- security: [{ scheme: "bearer", type: "http" }, {
1171
- in: "cookie",
1172
- name: "sessionid",
1173
- type: "apiKey"
1174
- }],
1175
- url: "/cfg/accounts/profile/partial/",
1176
- ...options,
1177
- headers: {
1178
- "Content-Type": "application/json",
1179
- ...options?.headers
1180
- }
1181
- });
1026
+ // ── Locale / API key ────────────────────────────────────────────────────
1027
+ getLocale() {
1028
+ return this.locale ?? detectLocale();
1182
1029
  }
1183
- /**
1184
- * Update user profile
1185
- *
1186
- * Update the current authenticated user's profile information.
1187
- */
1188
- static cfgAccountsProfileUpdatePartialUpdate(options) {
1189
- return (options?.client ?? client).patch({
1190
- security: [{ scheme: "bearer", type: "http" }, {
1191
- in: "cookie",
1192
- name: "sessionid",
1193
- type: "apiKey"
1194
- }],
1195
- url: "/cfg/accounts/profile/update/",
1196
- ...options,
1197
- headers: {
1198
- "Content-Type": "application/json",
1199
- ...options?.headers
1200
- }
1201
- });
1030
+ setLocale(locale) {
1031
+ this.locale = locale;
1202
1032
  }
1203
- /**
1204
- * Update user profile
1205
- *
1206
- * Update the current authenticated user's profile information.
1207
- */
1208
- static cfgAccountsProfileUpdateUpdate(options) {
1209
- return (options?.client ?? client).put({
1210
- security: [{ scheme: "bearer", type: "http" }, {
1211
- in: "cookie",
1212
- name: "sessionid",
1213
- type: "apiKey"
1214
- }],
1215
- url: "/cfg/accounts/profile/update/",
1216
- ...options,
1217
- headers: {
1218
- "Content-Type": "application/json",
1219
- ...options?.headers
1220
- }
1221
- });
1033
+ getApiKey() {
1034
+ return this.apiKey;
1222
1035
  }
1223
- /**
1224
- * Refresh JWT token.
1225
- */
1226
- static cfgAccountsTokenRefreshCreate(options) {
1227
- return (options.client ?? client).post({
1228
- url: "/cfg/accounts/token/refresh/",
1229
- ...options,
1230
- headers: {
1231
- "Content-Type": "application/json",
1232
- ...options.headers
1233
- }
1234
- });
1036
+ setApiKey(key) {
1037
+ this.apiKey = key;
1235
1038
  }
1236
1039
  };
1237
- var Accounts = class {
1238
- static {
1239
- __name(this, "Accounts");
1040
+
1041
+ // src/_api/generated/_cfg_centrifugo/api.ts
1042
+ var ACCESS_KEY2 = "cfg.access_token";
1043
+ var REFRESH_KEY2 = "cfg.refresh_token";
1044
+ function detectLocale2() {
1045
+ try {
1046
+ if (typeof document !== "undefined") {
1047
+ const m = document.cookie.match(/(?:^|;\s*)NEXT_LOCALE=([^;]*)/);
1048
+ if (m) return decodeURIComponent(m[1]);
1049
+ }
1050
+ if (typeof navigator !== "undefined" && navigator.language) {
1051
+ return navigator.language;
1052
+ }
1053
+ } catch {
1240
1054
  }
1241
- /**
1242
- * List OAuth connections
1243
- *
1244
- * Get all OAuth connections for the current user.
1245
- */
1246
- static cfgAccountsOauthConnectionsList(options) {
1247
- return (options?.client ?? client).get({
1248
- security: [{ scheme: "bearer", type: "http" }],
1249
- url: "/cfg/accounts/oauth/connections/",
1250
- ...options
1251
- });
1055
+ return null;
1056
+ }
1057
+ __name(detectLocale2, "detectLocale");
1058
+ var API2 = class {
1059
+ static {
1060
+ __name(this, "API");
1252
1061
  }
1253
- /**
1254
- * Disconnect OAuth provider
1255
- *
1256
- * Remove OAuth connection for the specified provider.
1257
- */
1258
- static cfgAccountsOauthDisconnectCreate(options) {
1259
- return (options.client ?? client).post({
1260
- security: [{ scheme: "bearer", type: "http" }],
1261
- url: "/cfg/accounts/oauth/disconnect/",
1262
- ...options,
1263
- headers: {
1264
- "Content-Type": "application/json",
1265
- ...options.headers
1266
- }
1062
+ baseUrl;
1063
+ storage;
1064
+ locale;
1065
+ apiKey;
1066
+ logger;
1067
+ constructor(baseUrl2, opts = {}) {
1068
+ this.baseUrl = baseUrl2.replace(/\/$/, "");
1069
+ this.storage = opts.storage ?? new LocalStorageAdapter();
1070
+ this.logger = new APILogger(opts.logger);
1071
+ this.locale = opts.locale ?? null;
1072
+ this.apiKey = opts.apiKey ?? (typeof process !== "undefined" ? process.env?.NEXT_PUBLIC_API_KEY ?? null : null);
1073
+ const credentials = opts.withCredentials ?? true ? "include" : "same-origin";
1074
+ client.setConfig({ baseUrl: this.baseUrl, credentials });
1075
+ client.interceptors.request.use((request) => {
1076
+ const access = this.getToken();
1077
+ if (access) request.headers.set("Authorization", `Bearer ${access}`);
1078
+ const locale = this.locale ?? detectLocale2();
1079
+ if (locale) request.headers.set("Accept-Language", locale);
1080
+ if (this.apiKey) request.headers.set("X-API-Key", this.apiKey);
1081
+ return request;
1267
1082
  });
1268
1083
  }
1269
- /**
1270
- * Start GitHub OAuth
1271
- *
1272
- * Generate GitHub OAuth authorization URL. Redirect user to this URL to start authentication.
1273
- */
1274
- static cfgAccountsOauthGithubAuthorizeCreate(options) {
1275
- return (options?.client ?? client).post({
1276
- url: "/cfg/accounts/oauth/github/authorize/",
1277
- ...options,
1278
- headers: {
1279
- "Content-Type": "application/json",
1280
- ...options?.headers
1281
- }
1282
- });
1084
+ // ── Base URL ────────────────────────────────────────────────────────────
1085
+ getBaseUrl() {
1086
+ return this.baseUrl;
1283
1087
  }
1284
- /**
1285
- * Complete GitHub OAuth
1286
- *
1287
- * Exchange authorization code for JWT tokens. Call this after GitHub redirects back with code.
1288
- */
1289
- static cfgAccountsOauthGithubCallbackCreate(options) {
1290
- return (options.client ?? client).post({
1291
- url: "/cfg/accounts/oauth/github/callback/",
1292
- ...options,
1293
- headers: {
1294
- "Content-Type": "application/json",
1295
- ...options.headers
1296
- }
1297
- });
1088
+ setBaseUrl(url) {
1089
+ this.baseUrl = url.replace(/\/$/, "");
1090
+ client.setConfig({ baseUrl: this.baseUrl });
1298
1091
  }
1299
- /**
1300
- * List OAuth providers
1301
- *
1302
- * Get list of available OAuth providers for authentication.
1303
- */
1304
- static cfgAccountsOauthProvidersRetrieve(options) {
1305
- return (options?.client ?? client).get({ url: "/cfg/accounts/oauth/providers/", ...options });
1092
+ // ── Tokens ──────────────────────────────────────────────────────────────
1093
+ getToken() {
1094
+ return this.storage.getItem(ACCESS_KEY2);
1306
1095
  }
1307
- /**
1308
- * Request OTP code to email.
1309
- */
1310
- static cfgAccountsOtpRequestCreate(options) {
1311
- return (options.client ?? client).post({
1312
- security: [{ scheme: "bearer", type: "http" }],
1313
- url: "/cfg/accounts/otp/request/",
1314
- ...options,
1315
- headers: {
1316
- "Content-Type": "application/json",
1317
- ...options.headers
1318
- }
1319
- });
1320
- }
1321
- /**
1322
- * Verify OTP code and return JWT tokens or 2FA session.
1323
- *
1324
- * If user has 2FA enabled:
1325
- * - Returns requires_2fa=True with session_id
1326
- * - Client must complete 2FA verification at /cfg/totp/verify/
1327
- *
1328
- * If user has no 2FA:
1329
- * - Returns JWT tokens and user data directly
1330
- */
1331
- static cfgAccountsOtpVerifyCreate(options) {
1332
- return (options.client ?? client).post({
1333
- security: [{ scheme: "bearer", type: "http" }],
1334
- url: "/cfg/accounts/otp/verify/",
1335
- ...options,
1336
- headers: {
1337
- "Content-Type": "application/json",
1338
- ...options.headers
1339
- }
1340
- });
1341
- }
1342
- /**
1343
- * Get current user profile
1344
- *
1345
- * Retrieve the current authenticated user's profile information.
1346
- */
1347
- static cfgAccountsProfileRetrieve(options) {
1348
- return (options?.client ?? client).get({
1349
- security: [{ scheme: "bearer", type: "http" }, {
1350
- in: "cookie",
1351
- name: "sessionid",
1352
- type: "apiKey"
1353
- }],
1354
- url: "/cfg/accounts/profile/",
1355
- ...options
1356
- });
1357
- }
1358
- /**
1359
- * Upload user avatar
1360
- *
1361
- * Upload avatar image for the current authenticated user. Accepts multipart/form-data with 'avatar' field.
1362
- */
1363
- static cfgAccountsProfileAvatarCreate(options) {
1364
- return (options?.client ?? client).post({
1365
- ...formDataBodySerializer,
1366
- security: [{ scheme: "bearer", type: "http" }],
1367
- url: "/cfg/accounts/profile/avatar/",
1368
- ...options,
1369
- headers: {
1370
- "Content-Type": null,
1371
- ...options?.headers
1372
- }
1373
- });
1374
- }
1375
- /**
1376
- * Delete user account
1377
- *
1378
- *
1379
- * Permanently delete the current user's account.
1380
- *
1381
- * This operation:
1382
- * - Deactivates the account (user cannot log in)
1383
- * - Anonymizes personal data (GDPR compliance)
1384
- * - Frees up the email address for re-registration
1385
- * - Preserves audit trail
1386
- *
1387
- * The account can be restored by an administrator if needed.
1388
- *
1389
- */
1390
- static cfgAccountsProfileDeleteCreate(options) {
1391
- return (options?.client ?? client).post({
1392
- security: [{ scheme: "bearer", type: "http" }, {
1393
- in: "cookie",
1394
- name: "sessionid",
1395
- type: "apiKey"
1396
- }],
1397
- url: "/cfg/accounts/profile/delete/",
1398
- ...options
1399
- });
1400
- }
1401
- /**
1402
- * Partial update user profile
1403
- *
1404
- * Partially update the current authenticated user's profile information. Supports avatar upload.
1405
- */
1406
- static cfgAccountsProfilePartialPartialUpdate(options) {
1407
- return (options?.client ?? client).patch({
1408
- security: [{ scheme: "bearer", type: "http" }, {
1409
- in: "cookie",
1410
- name: "sessionid",
1411
- type: "apiKey"
1412
- }],
1413
- url: "/cfg/accounts/profile/partial/",
1414
- ...options,
1415
- headers: {
1416
- "Content-Type": "application/json",
1417
- ...options?.headers
1418
- }
1419
- });
1420
- }
1421
- /**
1422
- * Partial update user profile
1423
- *
1424
- * Partially update the current authenticated user's profile information. Supports avatar upload.
1425
- */
1426
- static cfgAccountsProfilePartialUpdate(options) {
1427
- return (options?.client ?? client).put({
1428
- security: [{ scheme: "bearer", type: "http" }, {
1429
- in: "cookie",
1430
- name: "sessionid",
1431
- type: "apiKey"
1432
- }],
1433
- url: "/cfg/accounts/profile/partial/",
1434
- ...options,
1435
- headers: {
1436
- "Content-Type": "application/json",
1437
- ...options?.headers
1438
- }
1439
- });
1440
- }
1441
- /**
1442
- * Update user profile
1443
- *
1444
- * Update the current authenticated user's profile information.
1445
- */
1446
- static cfgAccountsProfileUpdatePartialUpdate(options) {
1447
- return (options?.client ?? client).patch({
1448
- security: [{ scheme: "bearer", type: "http" }, {
1449
- in: "cookie",
1450
- name: "sessionid",
1451
- type: "apiKey"
1452
- }],
1453
- url: "/cfg/accounts/profile/update/",
1454
- ...options,
1455
- headers: {
1456
- "Content-Type": "application/json",
1457
- ...options?.headers
1458
- }
1459
- });
1460
- }
1461
- /**
1462
- * Update user profile
1463
- *
1464
- * Update the current authenticated user's profile information.
1465
- */
1466
- static cfgAccountsProfileUpdateUpdate(options) {
1467
- return (options?.client ?? client).put({
1468
- security: [{ scheme: "bearer", type: "http" }, {
1469
- in: "cookie",
1470
- name: "sessionid",
1471
- type: "apiKey"
1472
- }],
1473
- url: "/cfg/accounts/profile/update/",
1474
- ...options,
1475
- headers: {
1476
- "Content-Type": "application/json",
1477
- ...options?.headers
1478
- }
1479
- });
1480
- }
1481
- /**
1482
- * Refresh JWT token.
1483
- */
1484
- static cfgAccountsTokenRefreshCreate(options) {
1485
- return (options.client ?? client).post({
1486
- url: "/cfg/accounts/token/refresh/",
1487
- ...options,
1488
- headers: {
1489
- "Content-Type": "application/json",
1490
- ...options.headers
1491
- }
1492
- });
1493
- }
1494
- };
1495
- var OAuth = class {
1496
- static {
1497
- __name(this, "OAuth");
1498
- }
1499
- /**
1500
- * List OAuth connections
1501
- *
1502
- * Get all OAuth connections for the current user.
1503
- */
1504
- static cfgAccountsOauthConnectionsList(options) {
1505
- return (options?.client ?? client).get({
1506
- security: [{ scheme: "bearer", type: "http" }],
1507
- url: "/cfg/accounts/oauth/connections/",
1508
- ...options
1509
- });
1510
- }
1511
- /**
1512
- * Disconnect OAuth provider
1513
- *
1514
- * Remove OAuth connection for the specified provider.
1515
- */
1516
- static cfgAccountsOauthDisconnectCreate(options) {
1517
- return (options.client ?? client).post({
1518
- security: [{ scheme: "bearer", type: "http" }],
1519
- url: "/cfg/accounts/oauth/disconnect/",
1520
- ...options,
1521
- headers: {
1522
- "Content-Type": "application/json",
1523
- ...options.headers
1524
- }
1525
- });
1526
- }
1527
- /**
1528
- * Start GitHub OAuth
1529
- *
1530
- * Generate GitHub OAuth authorization URL. Redirect user to this URL to start authentication.
1531
- */
1532
- static cfgAccountsOauthGithubAuthorizeCreate(options) {
1533
- return (options?.client ?? client).post({
1534
- url: "/cfg/accounts/oauth/github/authorize/",
1535
- ...options,
1536
- headers: {
1537
- "Content-Type": "application/json",
1538
- ...options?.headers
1539
- }
1540
- });
1541
- }
1542
- /**
1543
- * Complete GitHub OAuth
1544
- *
1545
- * Exchange authorization code for JWT tokens. Call this after GitHub redirects back with code.
1546
- */
1547
- static cfgAccountsOauthGithubCallbackCreate(options) {
1548
- return (options.client ?? client).post({
1549
- url: "/cfg/accounts/oauth/github/callback/",
1550
- ...options,
1551
- headers: {
1552
- "Content-Type": "application/json",
1553
- ...options.headers
1554
- }
1555
- });
1556
- }
1557
- /**
1558
- * List OAuth providers
1559
- *
1560
- * Get list of available OAuth providers for authentication.
1561
- */
1562
- static cfgAccountsOauthProvidersRetrieve(options) {
1563
- return (options?.client ?? client).get({ url: "/cfg/accounts/oauth/providers/", ...options });
1564
- }
1565
- };
1566
- var UserProfile = class {
1567
- static {
1568
- __name(this, "UserProfile");
1569
- }
1570
- /**
1571
- * Get current user profile
1572
- *
1573
- * Retrieve the current authenticated user's profile information.
1574
- */
1575
- static cfgAccountsProfileRetrieve(options) {
1576
- return (options?.client ?? client).get({
1577
- security: [{ scheme: "bearer", type: "http" }, {
1578
- in: "cookie",
1579
- name: "sessionid",
1580
- type: "apiKey"
1581
- }],
1582
- url: "/cfg/accounts/profile/",
1583
- ...options
1584
- });
1585
- }
1586
- /**
1587
- * Upload user avatar
1588
- *
1589
- * Upload avatar image for the current authenticated user. Accepts multipart/form-data with 'avatar' field.
1590
- */
1591
- static cfgAccountsProfileAvatarCreate(options) {
1592
- return (options?.client ?? client).post({
1593
- ...formDataBodySerializer,
1594
- security: [{ scheme: "bearer", type: "http" }],
1595
- url: "/cfg/accounts/profile/avatar/",
1596
- ...options,
1597
- headers: {
1598
- "Content-Type": null,
1599
- ...options?.headers
1600
- }
1601
- });
1602
- }
1603
- /**
1604
- * Delete user account
1605
- *
1606
- *
1607
- * Permanently delete the current user's account.
1608
- *
1609
- * This operation:
1610
- * - Deactivates the account (user cannot log in)
1611
- * - Anonymizes personal data (GDPR compliance)
1612
- * - Frees up the email address for re-registration
1613
- * - Preserves audit trail
1614
- *
1615
- * The account can be restored by an administrator if needed.
1616
- *
1617
- */
1618
- static cfgAccountsProfileDeleteCreate(options) {
1619
- return (options?.client ?? client).post({
1620
- security: [{ scheme: "bearer", type: "http" }, {
1621
- in: "cookie",
1622
- name: "sessionid",
1623
- type: "apiKey"
1624
- }],
1625
- url: "/cfg/accounts/profile/delete/",
1626
- ...options
1627
- });
1628
- }
1629
- /**
1630
- * Partial update user profile
1631
- *
1632
- * Partially update the current authenticated user's profile information. Supports avatar upload.
1633
- */
1634
- static cfgAccountsProfilePartialPartialUpdate(options) {
1635
- return (options?.client ?? client).patch({
1636
- security: [{ scheme: "bearer", type: "http" }, {
1637
- in: "cookie",
1638
- name: "sessionid",
1639
- type: "apiKey"
1640
- }],
1641
- url: "/cfg/accounts/profile/partial/",
1642
- ...options,
1643
- headers: {
1644
- "Content-Type": "application/json",
1645
- ...options?.headers
1646
- }
1647
- });
1648
- }
1649
- /**
1650
- * Partial update user profile
1651
- *
1652
- * Partially update the current authenticated user's profile information. Supports avatar upload.
1653
- */
1654
- static cfgAccountsProfilePartialUpdate(options) {
1655
- return (options?.client ?? client).put({
1656
- security: [{ scheme: "bearer", type: "http" }, {
1657
- in: "cookie",
1658
- name: "sessionid",
1659
- type: "apiKey"
1660
- }],
1661
- url: "/cfg/accounts/profile/partial/",
1662
- ...options,
1663
- headers: {
1664
- "Content-Type": "application/json",
1665
- ...options?.headers
1666
- }
1667
- });
1668
- }
1669
- /**
1670
- * Update user profile
1671
- *
1672
- * Update the current authenticated user's profile information.
1673
- */
1674
- static cfgAccountsProfileUpdatePartialUpdate(options) {
1675
- return (options?.client ?? client).patch({
1676
- security: [{ scheme: "bearer", type: "http" }, {
1677
- in: "cookie",
1678
- name: "sessionid",
1679
- type: "apiKey"
1680
- }],
1681
- url: "/cfg/accounts/profile/update/",
1682
- ...options,
1683
- headers: {
1684
- "Content-Type": "application/json",
1685
- ...options?.headers
1686
- }
1687
- });
1688
- }
1689
- /**
1690
- * Update user profile
1691
- *
1692
- * Update the current authenticated user's profile information.
1693
- */
1694
- static cfgAccountsProfileUpdateUpdate(options) {
1695
- return (options?.client ?? client).put({
1696
- security: [{ scheme: "bearer", type: "http" }, {
1697
- in: "cookie",
1698
- name: "sessionid",
1699
- type: "apiKey"
1700
- }],
1701
- url: "/cfg/accounts/profile/update/",
1702
- ...options,
1703
- headers: {
1704
- "Content-Type": "application/json",
1705
- ...options?.headers
1706
- }
1707
- });
1708
- }
1709
- };
1710
- var Auth = class {
1711
- static {
1712
- __name(this, "Auth");
1713
- }
1714
- /**
1715
- * Refresh JWT token.
1716
- */
1717
- static cfgAccountsTokenRefreshCreate(options) {
1718
- return (options.client ?? client).post({
1719
- url: "/cfg/accounts/token/refresh/",
1720
- ...options,
1721
- headers: {
1722
- "Content-Type": "application/json",
1723
- ...options.headers
1724
- }
1725
- });
1726
- }
1727
- };
1728
-
1729
- // src/_api/generated/cfg_accounts/schemas/AccountDeleteResponse.ts
1730
- import { z } from "zod";
1731
- var AccountDeleteResponseSchema = z.object({
1732
- success: z.boolean(),
1733
- message: z.string()
1734
- });
1735
-
1736
- // src/_api/generated/cfg_accounts/schemas/CentrifugoToken.ts
1737
- import { z as z2 } from "zod";
1738
- var CentrifugoTokenSchema = z2.object({
1739
- token: z2.string(),
1740
- centrifugo_url: z2.string(),
1741
- expires_at: z2.string().datetime({ offset: true }),
1742
- channels: z2.array(z2.string())
1743
- });
1744
-
1745
- // src/_api/generated/cfg_accounts/schemas/CfgUserUpdateRequest.ts
1746
- import { z as z3 } from "zod";
1747
- var CfgUserUpdateRequestSchema = z3.object({
1748
- first_name: z3.string().max(50).optional(),
1749
- last_name: z3.string().max(50).optional(),
1750
- company: z3.string().max(100).optional(),
1751
- phone: z3.string().max(20).optional(),
1752
- position: z3.string().max(100).optional(),
1753
- language: z3.string().max(10).optional()
1754
- });
1755
-
1756
- // src/_api/generated/cfg_accounts/schemas/OAuthAuthorizeRequestRequest.ts
1757
- import { z as z4 } from "zod";
1758
- var OAuthAuthorizeRequestRequestSchema = z4.object({
1759
- redirect_uri: z4.string().optional(),
1760
- source_url: z4.string().optional()
1761
- });
1762
-
1763
- // src/_api/generated/cfg_accounts/schemas/OAuthAuthorizeResponse.ts
1764
- import { z as z5 } from "zod";
1765
- var OAuthAuthorizeResponseSchema = z5.object({
1766
- authorization_url: z5.string(),
1767
- state: z5.string()
1768
- });
1769
-
1770
- // src/_api/generated/cfg_accounts/schemas/OAuthCallbackRequestRequest.ts
1771
- import { z as z6 } from "zod";
1772
- var OAuthCallbackRequestRequestSchema = z6.object({
1773
- code: z6.string().min(10).max(500),
1774
- state: z6.string().min(20).max(100),
1775
- redirect_uri: z6.string().optional()
1776
- });
1777
-
1778
- // src/_api/generated/cfg_accounts/schemas/OAuthConnection.ts
1779
- import { z as z8 } from "zod";
1780
-
1781
- // src/_api/generated/cfg_accounts/schemas/ProviderEnum.ts
1782
- import { z as z7 } from "zod";
1783
- var ProviderEnumSchema = z7.enum(["github"]);
1784
-
1785
- // src/_api/generated/cfg_accounts/schemas/OAuthConnection.ts
1786
- var OAuthConnectionSchema = z8.object({
1787
- id: z8.number().int(),
1788
- provider: ProviderEnumSchema,
1789
- provider_display: z8.string(),
1790
- provider_username: z8.string(),
1791
- provider_email: z8.email(),
1792
- provider_avatar_url: z8.string(),
1793
- connected_at: z8.string().datetime({ offset: true }),
1794
- last_login_at: z8.string().datetime({ offset: true })
1795
- });
1796
-
1797
- // src/_api/generated/cfg_accounts/schemas/OAuthDisconnectRequestRequest.ts
1798
- import { z as z9 } from "zod";
1799
- var OAuthDisconnectRequestRequestSchema = z9.object({
1800
- provider: ProviderEnumSchema
1801
- });
1802
-
1803
- // src/_api/generated/cfg_accounts/schemas/OAuthError.ts
1804
- import { z as z10 } from "zod";
1805
- var OAuthErrorSchema = z10.object({
1806
- error: z10.string(),
1807
- error_description: z10.string().optional()
1808
- });
1809
-
1810
- // src/_api/generated/cfg_accounts/schemas/OAuthProvidersResponse.ts
1811
- import { z as z11 } from "zod";
1812
- var OAuthProvidersResponseSchema = z11.object({
1813
- providers: z11.array(z11.object({}))
1814
- });
1815
-
1816
- // src/_api/generated/cfg_accounts/schemas/OAuthTokenResponse.ts
1817
- import { z as z12 } from "zod";
1818
- var OAuthTokenResponseSchema = z12.object({
1819
- requires_2fa: z12.boolean().optional(),
1820
- 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(),
1821
- access: z12.string().nullable().optional(),
1822
- refresh: z12.string().nullable().optional(),
1823
- user: z12.object({}).nullable().optional(),
1824
- is_new_user: z12.boolean(),
1825
- is_new_connection: z12.boolean(),
1826
- should_prompt_2fa: z12.boolean().optional()
1827
- });
1828
-
1829
- // src/_api/generated/cfg_accounts/schemas/OTPErrorResponse.ts
1830
- import { z as z13 } from "zod";
1831
- var OTPErrorResponseSchema = z13.object({
1832
- error: z13.string(),
1833
- error_code: z13.string().nullable().optional(),
1834
- retry_after: z13.number().int().nullable().optional()
1835
- });
1836
-
1837
- // src/_api/generated/cfg_accounts/schemas/OTPRequestRequest.ts
1838
- import { z as z14 } from "zod";
1839
- var OTPRequestRequestSchema = z14.object({
1840
- identifier: z14.string().min(1),
1841
- source_url: z14.string().optional()
1842
- });
1843
-
1844
- // src/_api/generated/cfg_accounts/schemas/OTPRequestResponse.ts
1845
- import { z as z15 } from "zod";
1846
- var OTPRequestResponseSchema = z15.object({
1847
- message: z15.string()
1848
- });
1849
-
1850
- // src/_api/generated/cfg_accounts/schemas/OTPVerifyRequest.ts
1851
- import { z as z16 } from "zod";
1852
- var OTPVerifyRequestSchema = z16.object({
1853
- identifier: z16.string().min(1),
1854
- otp: z16.string().min(6).max(6),
1855
- source_url: z16.string().optional()
1856
- });
1857
-
1858
- // src/_api/generated/cfg_accounts/schemas/OTPVerifyResponse.ts
1859
- import { z as z18 } from "zod";
1860
-
1861
- // src/_api/generated/cfg_accounts/schemas/User.ts
1862
- import { z as z17 } from "zod";
1863
- var UserSchema = z17.object({
1864
- id: z17.number().int(),
1865
- email: z17.email(),
1866
- first_name: z17.string().max(50).optional(),
1867
- last_name: z17.string().max(50).optional(),
1868
- full_name: z17.string(),
1869
- initials: z17.string(),
1870
- display_username: z17.string(),
1871
- company: z17.string().max(100).optional(),
1872
- phone: z17.string().max(20).optional(),
1873
- position: z17.string().max(100).optional(),
1874
- language: z17.string().max(10).optional(),
1875
- avatar: z17.string().nullable(),
1876
- is_staff: z17.boolean(),
1877
- is_superuser: z17.boolean(),
1878
- date_joined: z17.string().datetime({ offset: true }),
1879
- last_login: z17.string().datetime({ offset: true }).nullable(),
1880
- unanswered_messages_count: z17.number().int(),
1881
- centrifugo: CentrifugoTokenSchema.nullable()
1882
- });
1883
-
1884
- // src/_api/generated/cfg_accounts/schemas/OTPVerifyResponse.ts
1885
- var OTPVerifyResponseSchema = z18.object({
1886
- requires_2fa: z18.boolean().optional(),
1887
- 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(),
1888
- refresh: z18.string().nullable().optional(),
1889
- access: z18.string().nullable().optional(),
1890
- user: UserSchema.nullable().optional(),
1891
- should_prompt_2fa: z18.boolean().optional()
1892
- });
1893
-
1894
- // src/_api/generated/cfg_accounts/schemas/PatchedCfgUserUpdateRequest.ts
1895
- import { z as z19 } from "zod";
1896
- var PatchedCfgUserUpdateRequestSchema = z19.object({
1897
- first_name: z19.string().max(50).optional(),
1898
- last_name: z19.string().max(50).optional(),
1899
- company: z19.string().max(100).optional(),
1900
- phone: z19.string().max(20).optional(),
1901
- position: z19.string().max(100).optional(),
1902
- language: z19.string().max(10).optional()
1903
- });
1904
-
1905
- // src/_api/generated/cfg_accounts/schemas/TokenRefresh.ts
1906
- import { z as z20 } from "zod";
1907
- var TokenRefreshSchema = z20.object({
1908
- access: z20.string(),
1909
- refresh: z20.string()
1910
- });
1911
-
1912
- // src/_api/generated/cfg_accounts/schemas/TokenRefreshRequest.ts
1913
- import { z as z21 } from "zod";
1914
- var TokenRefreshRequestSchema = z21.object({
1915
- refresh: z21.string().min(1)
1916
- });
1917
-
1918
- // src/_api/generated/_shared/validation-events.ts
1919
- function dispatchValidationError(detail) {
1920
- if (typeof window === "undefined") return;
1921
- try {
1922
- const event = new CustomEvent("zod-validation-error", {
1923
- detail,
1924
- bubbles: true,
1925
- cancelable: false
1926
- });
1927
- window.dispatchEvent(event);
1928
- } catch (error) {
1929
- console.warn("Failed to dispatch validation error event:", error);
1930
- }
1931
- }
1932
- __name(dispatchValidationError, "dispatchValidationError");
1933
-
1934
- // src/_api/generated/cfg_accounts/api.ts
1935
- var ACCESS_KEY = "cfg.access_token";
1936
- var REFRESH_KEY = "cfg.refresh_token";
1937
- var VALIDATION_ROUTES = [
1938
- { method: "POST", re: new RegExp("^/cfg/accounts/oauth/github/authorize/?$"), schema: OAuthAuthorizeResponseSchema, path: "/cfg/accounts/oauth/github/authorize/" },
1939
- { method: "POST", re: new RegExp("^/cfg/accounts/oauth/github/callback/?$"), schema: OAuthTokenResponseSchema, path: "/cfg/accounts/oauth/github/callback/" },
1940
- { method: "GET", re: new RegExp("^/cfg/accounts/oauth/providers/?$"), schema: OAuthProvidersResponseSchema, path: "/cfg/accounts/oauth/providers/" },
1941
- { method: "POST", re: new RegExp("^/cfg/accounts/otp/request/?$"), schema: OTPRequestResponseSchema, path: "/cfg/accounts/otp/request/" },
1942
- { method: "POST", re: new RegExp("^/cfg/accounts/otp/verify/?$"), schema: OTPVerifyResponseSchema, path: "/cfg/accounts/otp/verify/" },
1943
- { method: "GET", re: new RegExp("^/cfg/accounts/profile/?$"), schema: UserSchema, path: "/cfg/accounts/profile/" },
1944
- { method: "POST", re: new RegExp("^/cfg/accounts/profile/avatar/?$"), schema: UserSchema, path: "/cfg/accounts/profile/avatar/" },
1945
- { method: "POST", re: new RegExp("^/cfg/accounts/profile/delete/?$"), schema: AccountDeleteResponseSchema, path: "/cfg/accounts/profile/delete/" },
1946
- { method: "PUT", re: new RegExp("^/cfg/accounts/profile/partial/?$"), schema: UserSchema, path: "/cfg/accounts/profile/partial/" },
1947
- { method: "PATCH", re: new RegExp("^/cfg/accounts/profile/partial/?$"), schema: UserSchema, path: "/cfg/accounts/profile/partial/" },
1948
- { method: "PUT", re: new RegExp("^/cfg/accounts/profile/update/?$"), schema: UserSchema, path: "/cfg/accounts/profile/update/" },
1949
- { method: "PATCH", re: new RegExp("^/cfg/accounts/profile/update/?$"), schema: UserSchema, path: "/cfg/accounts/profile/update/" },
1950
- { method: "POST", re: new RegExp("^/cfg/accounts/token/refresh/?$"), schema: TokenRefreshSchema, path: "/cfg/accounts/token/refresh/" }
1951
- ];
1952
- function detectLocale() {
1953
- try {
1954
- if (typeof document !== "undefined") {
1955
- const m = document.cookie.match(/(?:^|;\s*)NEXT_LOCALE=([^;]*)/);
1956
- if (m) return decodeURIComponent(m[1]);
1957
- }
1958
- if (typeof navigator !== "undefined" && navigator.language) {
1959
- return navigator.language;
1960
- }
1961
- } catch {
1962
- }
1963
- return null;
1964
- }
1965
- __name(detectLocale, "detectLocale");
1966
- var API = class {
1967
- static {
1968
- __name(this, "API");
1969
- }
1970
- baseUrl;
1971
- storage;
1972
- locale;
1973
- apiKey;
1974
- logger;
1975
- cfg = Cfg;
1976
- accounts = Accounts;
1977
- oAuth = OAuth;
1978
- userProfile = UserProfile;
1979
- auth = Auth;
1980
- constructor(baseUrl2, opts = {}) {
1981
- this.baseUrl = baseUrl2.replace(/\/$/, "");
1982
- this.storage = opts.storage ?? new LocalStorageAdapter();
1983
- this.logger = new APILogger(opts.logger);
1984
- this.locale = opts.locale ?? null;
1985
- this.apiKey = opts.apiKey ?? (typeof process !== "undefined" ? process.env?.NEXT_PUBLIC_API_KEY ?? null : null);
1986
- const credentials = opts.withCredentials ?? true ? "include" : "same-origin";
1987
- client.setConfig({ baseUrl: this.baseUrl, credentials });
1988
- client.interceptors.request.use((request) => {
1989
- const access = this.getToken();
1990
- if (access) request.headers.set("Authorization", `Bearer ${access}`);
1991
- const locale = this.locale ?? detectLocale();
1992
- if (locale) request.headers.set("Accept-Language", locale);
1993
- if (this.apiKey) request.headers.set("X-API-Key", this.apiKey);
1994
- return request;
1995
- });
1996
- client.interceptors.response.use(async (response, request) => {
1997
- if (!response.ok) return response;
1998
- const ct = response.headers.get("content-type") || "";
1999
- if (!ct.includes("application/json")) return response;
2000
- const url = new URL(request.url);
2001
- const method = request.method.toUpperCase();
2002
- const route = VALIDATION_ROUTES.find(
2003
- (r) => r.method === method && r.re.test(url.pathname)
2004
- );
2005
- if (!route) return response;
2006
- let payload;
2007
- try {
2008
- payload = await response.clone().json();
2009
- } catch {
2010
- return response;
2011
- }
2012
- const result = route.schema.safeParse(payload);
2013
- if (!result.success) {
2014
- dispatchValidationError({
2015
- operation: `${method} ${route.path}`,
2016
- path: route.path,
2017
- method,
2018
- error: result.error,
2019
- response: payload,
2020
- timestamp: /* @__PURE__ */ new Date()
2021
- });
2022
- }
2023
- return response;
2024
- });
2025
- }
2026
- // ── Base URL ────────────────────────────────────────────────────────────
2027
- getBaseUrl() {
2028
- return this.baseUrl;
2029
- }
2030
- setBaseUrl(url) {
2031
- this.baseUrl = url.replace(/\/$/, "");
2032
- client.setConfig({ baseUrl: this.baseUrl });
2033
- }
2034
- // ── Tokens ──────────────────────────────────────────────────────────────
2035
- getToken() {
2036
- return this.storage.getItem(ACCESS_KEY);
2037
- }
2038
- setToken(token) {
2039
- if (token) this.storage.setItem(ACCESS_KEY, token);
2040
- else this.storage.removeItem(ACCESS_KEY);
2041
- }
2042
- getRefreshToken() {
2043
- return this.storage.getItem(REFRESH_KEY);
2044
- }
2045
- setRefreshToken(token) {
2046
- if (token) this.storage.setItem(REFRESH_KEY, token);
2047
- else this.storage.removeItem(REFRESH_KEY);
2048
- }
2049
- clearToken() {
2050
- this.storage.removeItem(ACCESS_KEY);
2051
- this.storage.removeItem(REFRESH_KEY);
2052
- }
2053
- isAuthenticated() {
2054
- return this.getToken() !== null;
2055
- }
2056
- // ── Locale / API key ────────────────────────────────────────────────────
2057
- getLocale() {
2058
- return this.locale ?? detectLocale();
2059
- }
2060
- setLocale(locale) {
2061
- this.locale = locale;
2062
- }
2063
- getApiKey() {
2064
- return this.apiKey;
2065
- }
2066
- setApiKey(key) {
2067
- this.apiKey = key;
2068
- }
2069
- };
2070
-
2071
- // src/_api/generated/cfg_centrifugo/core/bodySerializer.gen.ts
2072
- var jsonBodySerializer2 = {
2073
- bodySerializer: /* @__PURE__ */ __name((body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value), "bodySerializer")
2074
- };
2075
-
2076
- // src/_api/generated/cfg_centrifugo/core/params.gen.ts
2077
- var extraPrefixesMap2 = {
2078
- $body_: "body",
2079
- $headers_: "headers",
2080
- $path_: "path",
2081
- $query_: "query"
2082
- };
2083
- var extraPrefixes2 = Object.entries(extraPrefixesMap2);
2084
-
2085
- // src/_api/generated/cfg_centrifugo/core/serverSentEvents.gen.ts
2086
- function createSseClient2({
2087
- onRequest,
2088
- onSseError,
2089
- onSseEvent,
2090
- responseTransformer,
2091
- responseValidator,
2092
- sseDefaultRetryDelay,
2093
- sseMaxRetryAttempts,
2094
- sseMaxRetryDelay,
2095
- sseSleepFn,
2096
- url,
2097
- ...options
2098
- }) {
2099
- let lastEventId;
2100
- const sleep = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
2101
- const createStream = /* @__PURE__ */ __name(async function* () {
2102
- let retryDelay = sseDefaultRetryDelay ?? 3e3;
2103
- let attempt = 0;
2104
- const signal = options.signal ?? new AbortController().signal;
2105
- while (true) {
2106
- if (signal.aborted) break;
2107
- attempt++;
2108
- const headers = options.headers instanceof Headers ? options.headers : new Headers(options.headers);
2109
- if (lastEventId !== void 0) {
2110
- headers.set("Last-Event-ID", lastEventId);
2111
- }
2112
- try {
2113
- const requestInit = {
2114
- redirect: "follow",
2115
- ...options,
2116
- body: options.serializedBody,
2117
- headers,
2118
- signal
2119
- };
2120
- let request = new Request(url, requestInit);
2121
- if (onRequest) {
2122
- request = await onRequest(url, requestInit);
2123
- }
2124
- const _fetch = options.fetch ?? globalThis.fetch;
2125
- const response = await _fetch(request);
2126
- if (!response.ok) throw new Error(`SSE failed: ${response.status} ${response.statusText}`);
2127
- if (!response.body) throw new Error("No body in SSE response");
2128
- const reader = response.body.pipeThrough(new TextDecoderStream()).getReader();
2129
- let buffer = "";
2130
- const abortHandler = /* @__PURE__ */ __name(() => {
2131
- try {
2132
- reader.cancel();
2133
- } catch {
2134
- }
2135
- }, "abortHandler");
2136
- signal.addEventListener("abort", abortHandler);
2137
- try {
2138
- while (true) {
2139
- const { done, value } = await reader.read();
2140
- if (done) break;
2141
- buffer += value;
2142
- buffer = buffer.replace(/\r\n?/g, "\n");
2143
- const chunks = buffer.split("\n\n");
2144
- buffer = chunks.pop() ?? "";
2145
- for (const chunk of chunks) {
2146
- const lines = chunk.split("\n");
2147
- const dataLines = [];
2148
- let eventName;
2149
- for (const line of lines) {
2150
- if (line.startsWith("data:")) {
2151
- dataLines.push(line.replace(/^data:\s*/, ""));
2152
- } else if (line.startsWith("event:")) {
2153
- eventName = line.replace(/^event:\s*/, "");
2154
- } else if (line.startsWith("id:")) {
2155
- lastEventId = line.replace(/^id:\s*/, "");
2156
- } else if (line.startsWith("retry:")) {
2157
- const parsed = Number.parseInt(line.replace(/^retry:\s*/, ""), 10);
2158
- if (!Number.isNaN(parsed)) {
2159
- retryDelay = parsed;
2160
- }
2161
- }
2162
- }
2163
- let data;
2164
- let parsedJson = false;
2165
- if (dataLines.length) {
2166
- const rawData = dataLines.join("\n");
2167
- try {
2168
- data = JSON.parse(rawData);
2169
- parsedJson = true;
2170
- } catch {
2171
- data = rawData;
2172
- }
2173
- }
2174
- if (parsedJson) {
2175
- if (responseValidator) {
2176
- await responseValidator(data);
2177
- }
2178
- if (responseTransformer) {
2179
- data = await responseTransformer(data);
2180
- }
2181
- }
2182
- onSseEvent?.({
2183
- data,
2184
- event: eventName,
2185
- id: lastEventId,
2186
- retry: retryDelay
2187
- });
2188
- if (dataLines.length) {
2189
- yield data;
2190
- }
2191
- }
2192
- }
2193
- } finally {
2194
- signal.removeEventListener("abort", abortHandler);
2195
- reader.releaseLock();
2196
- }
2197
- break;
2198
- } catch (error) {
2199
- onSseError?.(error);
2200
- if (sseMaxRetryAttempts !== void 0 && attempt >= sseMaxRetryAttempts) {
2201
- break;
2202
- }
2203
- const backoff = Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 3e4);
2204
- await sleep(backoff);
2205
- }
2206
- }
2207
- }, "createStream");
2208
- const stream = createStream();
2209
- return { stream };
2210
- }
2211
- __name(createSseClient2, "createSseClient");
2212
-
2213
- // src/_api/generated/cfg_centrifugo/core/pathSerializer.gen.ts
2214
- var separatorArrayExplode2 = /* @__PURE__ */ __name((style) => {
2215
- switch (style) {
2216
- case "label":
2217
- return ".";
2218
- case "matrix":
2219
- return ";";
2220
- case "simple":
2221
- return ",";
2222
- default:
2223
- return "&";
2224
- }
2225
- }, "separatorArrayExplode");
2226
- var separatorArrayNoExplode2 = /* @__PURE__ */ __name((style) => {
2227
- switch (style) {
2228
- case "form":
2229
- return ",";
2230
- case "pipeDelimited":
2231
- return "|";
2232
- case "spaceDelimited":
2233
- return "%20";
2234
- default:
2235
- return ",";
2236
- }
2237
- }, "separatorArrayNoExplode");
2238
- var separatorObjectExplode2 = /* @__PURE__ */ __name((style) => {
2239
- switch (style) {
2240
- case "label":
2241
- return ".";
2242
- case "matrix":
2243
- return ";";
2244
- case "simple":
2245
- return ",";
2246
- default:
2247
- return "&";
2248
- }
2249
- }, "separatorObjectExplode");
2250
- var serializeArrayParam2 = /* @__PURE__ */ __name(({
2251
- allowReserved,
2252
- explode,
2253
- name,
2254
- style,
2255
- value
2256
- }) => {
2257
- if (!explode) {
2258
- const joinedValues2 = (allowReserved ? value : value.map((v) => encodeURIComponent(v))).join(separatorArrayNoExplode2(style));
2259
- switch (style) {
2260
- case "label":
2261
- return `.${joinedValues2}`;
2262
- case "matrix":
2263
- return `;${name}=${joinedValues2}`;
2264
- case "simple":
2265
- return joinedValues2;
2266
- default:
2267
- return `${name}=${joinedValues2}`;
2268
- }
2269
- }
2270
- const separator = separatorArrayExplode2(style);
2271
- const joinedValues = value.map((v) => {
2272
- if (style === "label" || style === "simple") {
2273
- return allowReserved ? v : encodeURIComponent(v);
2274
- }
2275
- return serializePrimitiveParam2({
2276
- allowReserved,
2277
- name,
2278
- value: v
2279
- });
2280
- }).join(separator);
2281
- return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
2282
- }, "serializeArrayParam");
2283
- var serializePrimitiveParam2 = /* @__PURE__ */ __name(({
2284
- allowReserved,
2285
- name,
2286
- value
2287
- }) => {
2288
- if (value === void 0 || value === null) {
2289
- return "";
2290
- }
2291
- if (typeof value === "object") {
2292
- throw new Error(
2293
- "Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these."
2294
- );
2295
- }
2296
- return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
2297
- }, "serializePrimitiveParam");
2298
- var serializeObjectParam2 = /* @__PURE__ */ __name(({
2299
- allowReserved,
2300
- explode,
2301
- name,
2302
- style,
2303
- value,
2304
- valueOnly
2305
- }) => {
2306
- if (value instanceof Date) {
2307
- return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
2308
- }
2309
- if (style !== "deepObject" && !explode) {
2310
- let values = [];
2311
- Object.entries(value).forEach(([key, v]) => {
2312
- values = [...values, key, allowReserved ? v : encodeURIComponent(v)];
2313
- });
2314
- const joinedValues2 = values.join(",");
2315
- switch (style) {
2316
- case "form":
2317
- return `${name}=${joinedValues2}`;
2318
- case "label":
2319
- return `.${joinedValues2}`;
2320
- case "matrix":
2321
- return `;${name}=${joinedValues2}`;
2322
- default:
2323
- return joinedValues2;
2324
- }
2325
- }
2326
- const separator = separatorObjectExplode2(style);
2327
- const joinedValues = Object.entries(value).map(
2328
- ([key, v]) => serializePrimitiveParam2({
2329
- allowReserved,
2330
- name: style === "deepObject" ? `${name}[${key}]` : key,
2331
- value: v
2332
- })
2333
- ).join(separator);
2334
- return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
2335
- }, "serializeObjectParam");
2336
-
2337
- // src/_api/generated/cfg_centrifugo/core/utils.gen.ts
2338
- var PATH_PARAM_RE2 = /\{[^{}]+\}/g;
2339
- var defaultPathSerializer2 = /* @__PURE__ */ __name(({ path, url: _url }) => {
2340
- let url = _url;
2341
- const matches = _url.match(PATH_PARAM_RE2);
2342
- if (matches) {
2343
- for (const match of matches) {
2344
- let explode = false;
2345
- let name = match.substring(1, match.length - 1);
2346
- let style = "simple";
2347
- if (name.endsWith("*")) {
2348
- explode = true;
2349
- name = name.substring(0, name.length - 1);
2350
- }
2351
- if (name.startsWith(".")) {
2352
- name = name.substring(1);
2353
- style = "label";
2354
- } else if (name.startsWith(";")) {
2355
- name = name.substring(1);
2356
- style = "matrix";
2357
- }
2358
- const value = path[name];
2359
- if (value === void 0 || value === null) {
2360
- continue;
2361
- }
2362
- if (Array.isArray(value)) {
2363
- url = url.replace(match, serializeArrayParam2({ explode, name, style, value }));
2364
- continue;
2365
- }
2366
- if (typeof value === "object") {
2367
- url = url.replace(
2368
- match,
2369
- serializeObjectParam2({
2370
- explode,
2371
- name,
2372
- style,
2373
- value,
2374
- valueOnly: true
2375
- })
2376
- );
2377
- continue;
2378
- }
2379
- if (style === "matrix") {
2380
- url = url.replace(
2381
- match,
2382
- `;${serializePrimitiveParam2({
2383
- name,
2384
- value
2385
- })}`
2386
- );
2387
- continue;
2388
- }
2389
- const replaceValue = encodeURIComponent(
2390
- style === "label" ? `.${value}` : value
2391
- );
2392
- url = url.replace(match, replaceValue);
2393
- }
2394
- }
2395
- return url;
2396
- }, "defaultPathSerializer");
2397
- var getUrl2 = /* @__PURE__ */ __name(({
2398
- baseUrl: baseUrl2,
2399
- path,
2400
- query,
2401
- querySerializer,
2402
- url: _url
2403
- }) => {
2404
- const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
2405
- let url = (baseUrl2 ?? "") + pathUrl;
2406
- if (path) {
2407
- url = defaultPathSerializer2({ path, url });
2408
- }
2409
- let search = query ? querySerializer(query) : "";
2410
- if (search.startsWith("?")) {
2411
- search = search.substring(1);
2412
- }
2413
- if (search) {
2414
- url += `?${search}`;
2415
- }
2416
- return url;
2417
- }, "getUrl");
2418
- function getValidRequestBody2(options) {
2419
- const hasBody = options.body !== void 0;
2420
- const isSerializedBody = hasBody && options.bodySerializer;
2421
- if (isSerializedBody) {
2422
- if ("serializedBody" in options) {
2423
- const hasSerializedBody = options.serializedBody !== void 0 && options.serializedBody !== "";
2424
- return hasSerializedBody ? options.serializedBody : null;
2425
- }
2426
- return options.body !== "" ? options.body : null;
2427
- }
2428
- if (hasBody) {
2429
- return options.body;
2430
- }
2431
- return void 0;
2432
- }
2433
- __name(getValidRequestBody2, "getValidRequestBody");
2434
-
2435
- // src/_api/generated/cfg_centrifugo/core/auth.gen.ts
2436
- var getAuthToken2 = /* @__PURE__ */ __name(async (auth, callback) => {
2437
- const token = typeof callback === "function" ? await callback(auth) : callback;
2438
- if (!token) {
2439
- return;
2440
- }
2441
- if (auth.scheme === "bearer") {
2442
- return `Bearer ${token}`;
2443
- }
2444
- if (auth.scheme === "basic") {
2445
- return `Basic ${btoa(token)}`;
2446
- }
2447
- return token;
2448
- }, "getAuthToken");
2449
-
2450
- // src/_api/generated/cfg_centrifugo/client/utils.gen.ts
2451
- var createQuerySerializer2 = /* @__PURE__ */ __name(({
2452
- parameters = {},
2453
- ...args
2454
- } = {}) => {
2455
- const querySerializer = /* @__PURE__ */ __name((queryParams) => {
2456
- const search = [];
2457
- if (queryParams && typeof queryParams === "object") {
2458
- for (const name in queryParams) {
2459
- const value = queryParams[name];
2460
- if (value === void 0 || value === null) {
2461
- continue;
2462
- }
2463
- const options = parameters[name] || args;
2464
- if (Array.isArray(value)) {
2465
- const serializedArray = serializeArrayParam2({
2466
- allowReserved: options.allowReserved,
2467
- explode: true,
2468
- name,
2469
- style: "form",
2470
- value,
2471
- ...options.array
2472
- });
2473
- if (serializedArray) search.push(serializedArray);
2474
- } else if (typeof value === "object") {
2475
- const serializedObject = serializeObjectParam2({
2476
- allowReserved: options.allowReserved,
2477
- explode: true,
2478
- name,
2479
- style: "deepObject",
2480
- value,
2481
- ...options.object
2482
- });
2483
- if (serializedObject) search.push(serializedObject);
2484
- } else {
2485
- const serializedPrimitive = serializePrimitiveParam2({
2486
- allowReserved: options.allowReserved,
2487
- name,
2488
- value
2489
- });
2490
- if (serializedPrimitive) search.push(serializedPrimitive);
2491
- }
2492
- }
2493
- }
2494
- return search.join("&");
2495
- }, "querySerializer");
2496
- return querySerializer;
2497
- }, "createQuerySerializer");
2498
- var getParseAs2 = /* @__PURE__ */ __name((contentType) => {
2499
- if (!contentType) {
2500
- return "stream";
2501
- }
2502
- const cleanContent = contentType.split(";")[0]?.trim();
2503
- if (!cleanContent) {
2504
- return;
2505
- }
2506
- if (cleanContent.startsWith("application/json") || cleanContent.endsWith("+json")) {
2507
- return "json";
2508
- }
2509
- if (cleanContent === "multipart/form-data") {
2510
- return "formData";
2511
- }
2512
- if (["application/", "audio/", "image/", "video/"].some((type) => cleanContent.startsWith(type))) {
2513
- return "blob";
2514
- }
2515
- if (cleanContent.startsWith("text/")) {
2516
- return "text";
2517
- }
2518
- return;
2519
- }, "getParseAs");
2520
- var checkForExistence2 = /* @__PURE__ */ __name((options, name) => {
2521
- if (!name) {
2522
- return false;
2523
- }
2524
- if (options.headers.has(name) || options.query?.[name] || options.headers.get("Cookie")?.includes(`${name}=`)) {
2525
- return true;
2526
- }
2527
- return false;
2528
- }, "checkForExistence");
2529
- var setAuthParams2 = /* @__PURE__ */ __name(async ({
2530
- security,
2531
- ...options
2532
- }) => {
2533
- for (const auth of security) {
2534
- if (checkForExistence2(options, auth.name)) {
2535
- continue;
2536
- }
2537
- const token = await getAuthToken2(auth, options.auth);
2538
- if (!token) {
2539
- continue;
2540
- }
2541
- const name = auth.name ?? "Authorization";
2542
- switch (auth.in) {
2543
- case "query":
2544
- if (!options.query) {
2545
- options.query = {};
2546
- }
2547
- options.query[name] = token;
2548
- break;
2549
- case "cookie":
2550
- options.headers.append("Cookie", `${name}=${token}`);
2551
- break;
2552
- case "header":
2553
- default:
2554
- options.headers.set(name, token);
2555
- break;
2556
- }
2557
- }
2558
- }, "setAuthParams");
2559
- var buildUrl2 = /* @__PURE__ */ __name((options) => getUrl2({
2560
- baseUrl: options.baseUrl,
2561
- path: options.path,
2562
- query: options.query,
2563
- querySerializer: typeof options.querySerializer === "function" ? options.querySerializer : createQuerySerializer2(options.querySerializer),
2564
- url: options.url
2565
- }), "buildUrl");
2566
- var mergeConfigs2 = /* @__PURE__ */ __name((a, b) => {
2567
- const config = { ...a, ...b };
2568
- if (config.baseUrl?.endsWith("/")) {
2569
- config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
2570
- }
2571
- config.headers = mergeHeaders2(a.headers, b.headers);
2572
- return config;
2573
- }, "mergeConfigs");
2574
- var headersEntries2 = /* @__PURE__ */ __name((headers) => {
2575
- const entries = [];
2576
- headers.forEach((value, key) => {
2577
- entries.push([key, value]);
2578
- });
2579
- return entries;
2580
- }, "headersEntries");
2581
- var mergeHeaders2 = /* @__PURE__ */ __name((...headers) => {
2582
- const mergedHeaders = new Headers();
2583
- for (const header of headers) {
2584
- if (!header) {
2585
- continue;
2586
- }
2587
- const iterator = header instanceof Headers ? headersEntries2(header) : Object.entries(header);
2588
- for (const [key, value] of iterator) {
2589
- if (value === null) {
2590
- mergedHeaders.delete(key);
2591
- } else if (Array.isArray(value)) {
2592
- for (const v of value) {
2593
- mergedHeaders.append(key, v);
2594
- }
2595
- } else if (value !== void 0) {
2596
- mergedHeaders.set(
2597
- key,
2598
- typeof value === "object" ? JSON.stringify(value) : value
2599
- );
2600
- }
2601
- }
2602
- }
2603
- return mergedHeaders;
2604
- }, "mergeHeaders");
2605
- var Interceptors2 = class {
2606
- static {
2607
- __name(this, "Interceptors");
2608
- }
2609
- fns = [];
2610
- clear() {
2611
- this.fns = [];
2612
- }
2613
- eject(id) {
2614
- const index = this.getInterceptorIndex(id);
2615
- if (this.fns[index]) {
2616
- this.fns[index] = null;
2617
- }
2618
- }
2619
- exists(id) {
2620
- const index = this.getInterceptorIndex(id);
2621
- return Boolean(this.fns[index]);
2622
- }
2623
- getInterceptorIndex(id) {
2624
- if (typeof id === "number") {
2625
- return this.fns[id] ? id : -1;
2626
- }
2627
- return this.fns.indexOf(id);
2628
- }
2629
- update(id, fn) {
2630
- const index = this.getInterceptorIndex(id);
2631
- if (this.fns[index]) {
2632
- this.fns[index] = fn;
2633
- return id;
2634
- }
2635
- return false;
2636
- }
2637
- use(fn) {
2638
- this.fns.push(fn);
2639
- return this.fns.length - 1;
2640
- }
2641
- };
2642
- var createInterceptors2 = /* @__PURE__ */ __name(() => ({
2643
- error: new Interceptors2(),
2644
- request: new Interceptors2(),
2645
- response: new Interceptors2()
2646
- }), "createInterceptors");
2647
- var defaultQuerySerializer2 = createQuerySerializer2({
2648
- allowReserved: false,
2649
- array: {
2650
- explode: true,
2651
- style: "form"
2652
- },
2653
- object: {
2654
- explode: true,
2655
- style: "deepObject"
2656
- }
2657
- });
2658
- var defaultHeaders2 = {
2659
- "Content-Type": "application/json"
2660
- };
2661
- var createConfig2 = /* @__PURE__ */ __name((override = {}) => ({
2662
- ...jsonBodySerializer2,
2663
- headers: defaultHeaders2,
2664
- parseAs: "auto",
2665
- querySerializer: defaultQuerySerializer2,
2666
- ...override
2667
- }), "createConfig");
2668
-
2669
- // src/_api/generated/cfg_centrifugo/client/client.gen.ts
2670
- var createClient2 = /* @__PURE__ */ __name((config = {}) => {
2671
- let _config = mergeConfigs2(createConfig2(), config);
2672
- const getConfig = /* @__PURE__ */ __name(() => ({ ..._config }), "getConfig");
2673
- const setConfig = /* @__PURE__ */ __name((config2) => {
2674
- _config = mergeConfigs2(_config, config2);
2675
- return getConfig();
2676
- }, "setConfig");
2677
- const interceptors = createInterceptors2();
2678
- const beforeRequest = /* @__PURE__ */ __name(async (options) => {
2679
- const opts = {
2680
- ..._config,
2681
- ...options,
2682
- fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
2683
- headers: mergeHeaders2(_config.headers, options.headers),
2684
- serializedBody: void 0
2685
- };
2686
- if (opts.security) {
2687
- await setAuthParams2({
2688
- ...opts,
2689
- security: opts.security
2690
- });
2691
- }
2692
- if (opts.requestValidator) {
2693
- await opts.requestValidator(opts);
2694
- }
2695
- if (opts.body !== void 0 && opts.bodySerializer) {
2696
- opts.serializedBody = opts.bodySerializer(opts.body);
2697
- }
2698
- if (opts.body === void 0 || opts.serializedBody === "") {
2699
- opts.headers.delete("Content-Type");
2700
- }
2701
- const resolvedOpts = opts;
2702
- const url = buildUrl2(resolvedOpts);
2703
- return { opts: resolvedOpts, url };
2704
- }, "beforeRequest");
2705
- const request = /* @__PURE__ */ __name(async (options) => {
2706
- const throwOnError = options.throwOnError ?? _config.throwOnError;
2707
- const responseStyle = options.responseStyle ?? _config.responseStyle;
2708
- let request2;
2709
- let response;
2710
- try {
2711
- const { opts, url } = await beforeRequest(options);
2712
- const requestInit = {
2713
- redirect: "follow",
2714
- ...opts,
2715
- body: getValidRequestBody2(opts)
2716
- };
2717
- request2 = new Request(url, requestInit);
2718
- for (const fn of interceptors.request.fns) {
2719
- if (fn) {
2720
- request2 = await fn(request2, opts);
2721
- }
2722
- }
2723
- const _fetch = opts.fetch;
2724
- response = await _fetch(request2);
2725
- for (const fn of interceptors.response.fns) {
2726
- if (fn) {
2727
- response = await fn(response, request2, opts);
2728
- }
2729
- }
2730
- const result = {
2731
- request: request2,
2732
- response
2733
- };
2734
- if (response.ok) {
2735
- const parseAs = (opts.parseAs === "auto" ? getParseAs2(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
2736
- if (response.status === 204 || response.headers.get("Content-Length") === "0") {
2737
- let emptyData;
2738
- switch (parseAs) {
2739
- case "arrayBuffer":
2740
- case "blob":
2741
- case "text":
2742
- emptyData = await response[parseAs]();
2743
- break;
2744
- case "formData":
2745
- emptyData = new FormData();
2746
- break;
2747
- case "stream":
2748
- emptyData = response.body;
2749
- break;
2750
- case "json":
2751
- default:
2752
- emptyData = {};
2753
- break;
2754
- }
2755
- return opts.responseStyle === "data" ? emptyData : {
2756
- data: emptyData,
2757
- ...result
2758
- };
2759
- }
2760
- let data;
2761
- switch (parseAs) {
2762
- case "arrayBuffer":
2763
- case "blob":
2764
- case "formData":
2765
- case "text":
2766
- data = await response[parseAs]();
2767
- break;
2768
- case "json": {
2769
- const text = await response.text();
2770
- data = text ? JSON.parse(text) : {};
2771
- break;
2772
- }
2773
- case "stream":
2774
- return opts.responseStyle === "data" ? response.body : {
2775
- data: response.body,
2776
- ...result
2777
- };
2778
- }
2779
- if (parseAs === "json") {
2780
- if (opts.responseValidator) {
2781
- await opts.responseValidator(data);
2782
- }
2783
- if (opts.responseTransformer) {
2784
- data = await opts.responseTransformer(data);
2785
- }
2786
- }
2787
- return opts.responseStyle === "data" ? data : {
2788
- data,
2789
- ...result
2790
- };
2791
- }
2792
- const textError = await response.text();
2793
- let jsonError;
2794
- try {
2795
- jsonError = JSON.parse(textError);
2796
- } catch {
2797
- }
2798
- throw jsonError ?? textError;
2799
- } catch (error) {
2800
- let finalError = error;
2801
- for (const fn of interceptors.error.fns) {
2802
- if (fn) {
2803
- finalError = await fn(finalError, response, request2, options);
2804
- }
2805
- }
2806
- finalError = finalError || {};
2807
- if (throwOnError) {
2808
- throw finalError;
2809
- }
2810
- return responseStyle === "data" ? void 0 : {
2811
- error: finalError,
2812
- request: request2,
2813
- response
2814
- };
2815
- }
2816
- }, "request");
2817
- const makeMethodFn = /* @__PURE__ */ __name((method) => (options) => request({ ...options, method }), "makeMethodFn");
2818
- const makeSseFn = /* @__PURE__ */ __name((method) => async (options) => {
2819
- const { opts, url } = await beforeRequest(options);
2820
- return createSseClient2({
2821
- ...opts,
2822
- body: opts.body,
2823
- method,
2824
- onRequest: /* @__PURE__ */ __name(async (url2, init) => {
2825
- let request2 = new Request(url2, init);
2826
- for (const fn of interceptors.request.fns) {
2827
- if (fn) {
2828
- request2 = await fn(request2, opts);
2829
- }
2830
- }
2831
- return request2;
2832
- }, "onRequest"),
2833
- serializedBody: getValidRequestBody2(opts),
2834
- url
2835
- });
2836
- }, "makeSseFn");
2837
- const _buildUrl = /* @__PURE__ */ __name((options) => buildUrl2({ ..._config, ...options }), "_buildUrl");
2838
- return {
2839
- buildUrl: _buildUrl,
2840
- connect: makeMethodFn("CONNECT"),
2841
- delete: makeMethodFn("DELETE"),
2842
- get: makeMethodFn("GET"),
2843
- getConfig,
2844
- head: makeMethodFn("HEAD"),
2845
- interceptors,
2846
- options: makeMethodFn("OPTIONS"),
2847
- patch: makeMethodFn("PATCH"),
2848
- post: makeMethodFn("POST"),
2849
- put: makeMethodFn("PUT"),
2850
- request,
2851
- setConfig,
2852
- sse: {
2853
- connect: makeSseFn("CONNECT"),
2854
- delete: makeSseFn("DELETE"),
2855
- get: makeSseFn("GET"),
2856
- head: makeSseFn("HEAD"),
2857
- options: makeSseFn("OPTIONS"),
2858
- patch: makeSseFn("PATCH"),
2859
- post: makeSseFn("POST"),
2860
- put: makeSseFn("PUT"),
2861
- trace: makeSseFn("TRACE")
2862
- },
2863
- trace: makeMethodFn("TRACE")
2864
- };
2865
- }, "createClient");
2866
-
2867
- // src/_api/generated/cfg_centrifugo/client.gen.ts
2868
- var client2 = createClient2(createConfig2({ baseUrl: "http://localhost:8000" }));
2869
-
2870
- // src/_api/generated/cfg_centrifugo/sdk.gen.ts
2871
- var Cfg2 = class {
2872
- static {
2873
- __name(this, "Cfg");
2874
- }
2875
- /**
2876
- * Get Centrifugo connection token
2877
- *
2878
- * Generate JWT token for WebSocket connection to Centrifugo. Token includes user's allowed channels based on their permissions. Requires authentication.
2879
- */
2880
- static cfgCentrifugoAuthTokenRetrieve(options) {
2881
- return (options?.client ?? client2).get({
2882
- security: [{ scheme: "bearer", type: "http" }],
2883
- url: "/cfg/centrifugo/auth/token/",
2884
- ...options
2885
- });
2886
- }
2887
- };
2888
- var Centrifugo = class {
2889
- static {
2890
- __name(this, "Centrifugo");
2891
- }
2892
- /**
2893
- * Get Centrifugo connection token
2894
- *
2895
- * Generate JWT token for WebSocket connection to Centrifugo. Token includes user's allowed channels based on their permissions. Requires authentication.
2896
- */
2897
- static cfgCentrifugoAuthTokenRetrieve(options) {
2898
- return (options?.client ?? client2).get({
2899
- security: [{ scheme: "bearer", type: "http" }],
2900
- url: "/cfg/centrifugo/auth/token/",
2901
- ...options
2902
- });
2903
- }
2904
- };
2905
- var CentrifugoAuth = class {
2906
- static {
2907
- __name(this, "CentrifugoAuth");
2908
- }
2909
- /**
2910
- * Get Centrifugo connection token
2911
- *
2912
- * Generate JWT token for WebSocket connection to Centrifugo. Token includes user's allowed channels based on their permissions. Requires authentication.
2913
- */
2914
- static cfgCentrifugoAuthTokenRetrieve(options) {
2915
- return (options?.client ?? client2).get({
2916
- security: [{ scheme: "bearer", type: "http" }],
2917
- url: "/cfg/centrifugo/auth/token/",
2918
- ...options
2919
- });
2920
- }
2921
- };
2922
-
2923
- // src/_api/generated/cfg_centrifugo/schemas/ConnectionTokenResponse.ts
2924
- import { z as z22 } from "zod";
2925
- var ConnectionTokenResponseSchema = z22.object({
2926
- token: z22.string(),
2927
- centrifugo_url: z22.string(),
2928
- expires_at: z22.string(),
2929
- channels: z22.array(z22.string())
2930
- });
2931
-
2932
- // src/_api/generated/cfg_centrifugo/api.ts
2933
- var ACCESS_KEY2 = "cfg.access_token";
2934
- var REFRESH_KEY2 = "cfg.refresh_token";
2935
- var VALIDATION_ROUTES2 = [
2936
- { method: "GET", re: new RegExp("^/cfg/centrifugo/auth/token/?$"), schema: ConnectionTokenResponseSchema, path: "/cfg/centrifugo/auth/token/" }
2937
- ];
2938
- function detectLocale2() {
2939
- try {
2940
- if (typeof document !== "undefined") {
2941
- const m = document.cookie.match(/(?:^|;\s*)NEXT_LOCALE=([^;]*)/);
2942
- if (m) return decodeURIComponent(m[1]);
2943
- }
2944
- if (typeof navigator !== "undefined" && navigator.language) {
2945
- return navigator.language;
2946
- }
2947
- } catch {
2948
- }
2949
- return null;
2950
- }
2951
- __name(detectLocale2, "detectLocale");
2952
- var API2 = class {
2953
- static {
2954
- __name(this, "API");
2955
- }
2956
- baseUrl;
2957
- storage;
2958
- locale;
2959
- apiKey;
2960
- logger;
2961
- cfg = Cfg2;
2962
- centrifugo = Centrifugo;
2963
- centrifugoAuth = CentrifugoAuth;
2964
- constructor(baseUrl2, opts = {}) {
2965
- this.baseUrl = baseUrl2.replace(/\/$/, "");
2966
- this.storage = opts.storage ?? new LocalStorageAdapter();
2967
- this.logger = new APILogger(opts.logger);
2968
- this.locale = opts.locale ?? null;
2969
- this.apiKey = opts.apiKey ?? (typeof process !== "undefined" ? process.env?.NEXT_PUBLIC_API_KEY ?? null : null);
2970
- const credentials = opts.withCredentials ?? true ? "include" : "same-origin";
2971
- client2.setConfig({ baseUrl: this.baseUrl, credentials });
2972
- client2.interceptors.request.use((request) => {
2973
- const access = this.getToken();
2974
- if (access) request.headers.set("Authorization", `Bearer ${access}`);
2975
- const locale = this.locale ?? detectLocale2();
2976
- if (locale) request.headers.set("Accept-Language", locale);
2977
- if (this.apiKey) request.headers.set("X-API-Key", this.apiKey);
2978
- return request;
2979
- });
2980
- client2.interceptors.response.use(async (response, request) => {
2981
- if (!response.ok) return response;
2982
- const ct = response.headers.get("content-type") || "";
2983
- if (!ct.includes("application/json")) return response;
2984
- const url = new URL(request.url);
2985
- const method = request.method.toUpperCase();
2986
- const route = VALIDATION_ROUTES2.find(
2987
- (r) => r.method === method && r.re.test(url.pathname)
2988
- );
2989
- if (!route) return response;
2990
- let payload;
2991
- try {
2992
- payload = await response.clone().json();
2993
- } catch {
2994
- return response;
2995
- }
2996
- const result = route.schema.safeParse(payload);
2997
- if (!result.success) {
2998
- dispatchValidationError({
2999
- operation: `${method} ${route.path}`,
3000
- path: route.path,
3001
- method,
3002
- error: result.error,
3003
- response: payload,
3004
- timestamp: /* @__PURE__ */ new Date()
3005
- });
3006
- }
3007
- return response;
3008
- });
3009
- }
3010
- // ── Base URL ────────────────────────────────────────────────────────────
3011
- getBaseUrl() {
3012
- return this.baseUrl;
3013
- }
3014
- setBaseUrl(url) {
3015
- this.baseUrl = url.replace(/\/$/, "");
3016
- client2.setConfig({ baseUrl: this.baseUrl });
3017
- }
3018
- // ── Tokens ──────────────────────────────────────────────────────────────
3019
- getToken() {
3020
- return this.storage.getItem(ACCESS_KEY2);
3021
- }
3022
- setToken(token) {
3023
- if (token) this.storage.setItem(ACCESS_KEY2, token);
3024
- else this.storage.removeItem(ACCESS_KEY2);
3025
- }
3026
- getRefreshToken() {
3027
- return this.storage.getItem(REFRESH_KEY2);
3028
- }
3029
- setRefreshToken(token) {
3030
- if (token) this.storage.setItem(REFRESH_KEY2, token);
3031
- else this.storage.removeItem(REFRESH_KEY2);
3032
- }
3033
- clearToken() {
3034
- this.storage.removeItem(ACCESS_KEY2);
3035
- this.storage.removeItem(REFRESH_KEY2);
3036
- }
3037
- isAuthenticated() {
3038
- return this.getToken() !== null;
3039
- }
3040
- // ── Locale / API key ────────────────────────────────────────────────────
3041
- getLocale() {
3042
- return this.locale ?? detectLocale2();
3043
- }
3044
- setLocale(locale) {
3045
- this.locale = locale;
3046
- }
3047
- getApiKey() {
3048
- return this.apiKey;
3049
- }
3050
- setApiKey(key) {
3051
- this.apiKey = key;
3052
- }
3053
- };
3054
-
3055
- // src/_api/generated/cfg_totp/core/bodySerializer.gen.ts
3056
- var jsonBodySerializer3 = {
3057
- bodySerializer: /* @__PURE__ */ __name((body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value), "bodySerializer")
3058
- };
3059
-
3060
- // src/_api/generated/cfg_totp/core/params.gen.ts
3061
- var extraPrefixesMap3 = {
3062
- $body_: "body",
3063
- $headers_: "headers",
3064
- $path_: "path",
3065
- $query_: "query"
3066
- };
3067
- var extraPrefixes3 = Object.entries(extraPrefixesMap3);
3068
-
3069
- // src/_api/generated/cfg_totp/core/serverSentEvents.gen.ts
3070
- function createSseClient3({
3071
- onRequest,
3072
- onSseError,
3073
- onSseEvent,
3074
- responseTransformer,
3075
- responseValidator,
3076
- sseDefaultRetryDelay,
3077
- sseMaxRetryAttempts,
3078
- sseMaxRetryDelay,
3079
- sseSleepFn,
3080
- url,
3081
- ...options
3082
- }) {
3083
- let lastEventId;
3084
- const sleep = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
3085
- const createStream = /* @__PURE__ */ __name(async function* () {
3086
- let retryDelay = sseDefaultRetryDelay ?? 3e3;
3087
- let attempt = 0;
3088
- const signal = options.signal ?? new AbortController().signal;
3089
- while (true) {
3090
- if (signal.aborted) break;
3091
- attempt++;
3092
- const headers = options.headers instanceof Headers ? options.headers : new Headers(options.headers);
3093
- if (lastEventId !== void 0) {
3094
- headers.set("Last-Event-ID", lastEventId);
3095
- }
3096
- try {
3097
- const requestInit = {
3098
- redirect: "follow",
3099
- ...options,
3100
- body: options.serializedBody,
3101
- headers,
3102
- signal
3103
- };
3104
- let request = new Request(url, requestInit);
3105
- if (onRequest) {
3106
- request = await onRequest(url, requestInit);
3107
- }
3108
- const _fetch = options.fetch ?? globalThis.fetch;
3109
- const response = await _fetch(request);
3110
- if (!response.ok) throw new Error(`SSE failed: ${response.status} ${response.statusText}`);
3111
- if (!response.body) throw new Error("No body in SSE response");
3112
- const reader = response.body.pipeThrough(new TextDecoderStream()).getReader();
3113
- let buffer = "";
3114
- const abortHandler = /* @__PURE__ */ __name(() => {
3115
- try {
3116
- reader.cancel();
3117
- } catch {
3118
- }
3119
- }, "abortHandler");
3120
- signal.addEventListener("abort", abortHandler);
3121
- try {
3122
- while (true) {
3123
- const { done, value } = await reader.read();
3124
- if (done) break;
3125
- buffer += value;
3126
- buffer = buffer.replace(/\r\n?/g, "\n");
3127
- const chunks = buffer.split("\n\n");
3128
- buffer = chunks.pop() ?? "";
3129
- for (const chunk of chunks) {
3130
- const lines = chunk.split("\n");
3131
- const dataLines = [];
3132
- let eventName;
3133
- for (const line of lines) {
3134
- if (line.startsWith("data:")) {
3135
- dataLines.push(line.replace(/^data:\s*/, ""));
3136
- } else if (line.startsWith("event:")) {
3137
- eventName = line.replace(/^event:\s*/, "");
3138
- } else if (line.startsWith("id:")) {
3139
- lastEventId = line.replace(/^id:\s*/, "");
3140
- } else if (line.startsWith("retry:")) {
3141
- const parsed = Number.parseInt(line.replace(/^retry:\s*/, ""), 10);
3142
- if (!Number.isNaN(parsed)) {
3143
- retryDelay = parsed;
3144
- }
3145
- }
3146
- }
3147
- let data;
3148
- let parsedJson = false;
3149
- if (dataLines.length) {
3150
- const rawData = dataLines.join("\n");
3151
- try {
3152
- data = JSON.parse(rawData);
3153
- parsedJson = true;
3154
- } catch {
3155
- data = rawData;
3156
- }
3157
- }
3158
- if (parsedJson) {
3159
- if (responseValidator) {
3160
- await responseValidator(data);
3161
- }
3162
- if (responseTransformer) {
3163
- data = await responseTransformer(data);
3164
- }
3165
- }
3166
- onSseEvent?.({
3167
- data,
3168
- event: eventName,
3169
- id: lastEventId,
3170
- retry: retryDelay
3171
- });
3172
- if (dataLines.length) {
3173
- yield data;
3174
- }
3175
- }
3176
- }
3177
- } finally {
3178
- signal.removeEventListener("abort", abortHandler);
3179
- reader.releaseLock();
3180
- }
3181
- break;
3182
- } catch (error) {
3183
- onSseError?.(error);
3184
- if (sseMaxRetryAttempts !== void 0 && attempt >= sseMaxRetryAttempts) {
3185
- break;
3186
- }
3187
- const backoff = Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 3e4);
3188
- await sleep(backoff);
3189
- }
3190
- }
3191
- }, "createStream");
3192
- const stream = createStream();
3193
- return { stream };
3194
- }
3195
- __name(createSseClient3, "createSseClient");
3196
-
3197
- // src/_api/generated/cfg_totp/core/pathSerializer.gen.ts
3198
- var separatorArrayExplode3 = /* @__PURE__ */ __name((style) => {
3199
- switch (style) {
3200
- case "label":
3201
- return ".";
3202
- case "matrix":
3203
- return ";";
3204
- case "simple":
3205
- return ",";
3206
- default:
3207
- return "&";
3208
- }
3209
- }, "separatorArrayExplode");
3210
- var separatorArrayNoExplode3 = /* @__PURE__ */ __name((style) => {
3211
- switch (style) {
3212
- case "form":
3213
- return ",";
3214
- case "pipeDelimited":
3215
- return "|";
3216
- case "spaceDelimited":
3217
- return "%20";
3218
- default:
3219
- return ",";
3220
- }
3221
- }, "separatorArrayNoExplode");
3222
- var separatorObjectExplode3 = /* @__PURE__ */ __name((style) => {
3223
- switch (style) {
3224
- case "label":
3225
- return ".";
3226
- case "matrix":
3227
- return ";";
3228
- case "simple":
3229
- return ",";
3230
- default:
3231
- return "&";
3232
- }
3233
- }, "separatorObjectExplode");
3234
- var serializeArrayParam3 = /* @__PURE__ */ __name(({
3235
- allowReserved,
3236
- explode,
3237
- name,
3238
- style,
3239
- value
3240
- }) => {
3241
- if (!explode) {
3242
- const joinedValues2 = (allowReserved ? value : value.map((v) => encodeURIComponent(v))).join(separatorArrayNoExplode3(style));
3243
- switch (style) {
3244
- case "label":
3245
- return `.${joinedValues2}`;
3246
- case "matrix":
3247
- return `;${name}=${joinedValues2}`;
3248
- case "simple":
3249
- return joinedValues2;
3250
- default:
3251
- return `${name}=${joinedValues2}`;
3252
- }
3253
- }
3254
- const separator = separatorArrayExplode3(style);
3255
- const joinedValues = value.map((v) => {
3256
- if (style === "label" || style === "simple") {
3257
- return allowReserved ? v : encodeURIComponent(v);
3258
- }
3259
- return serializePrimitiveParam3({
3260
- allowReserved,
3261
- name,
3262
- value: v
3263
- });
3264
- }).join(separator);
3265
- return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
3266
- }, "serializeArrayParam");
3267
- var serializePrimitiveParam3 = /* @__PURE__ */ __name(({
3268
- allowReserved,
3269
- name,
3270
- value
3271
- }) => {
3272
- if (value === void 0 || value === null) {
3273
- return "";
3274
- }
3275
- if (typeof value === "object") {
3276
- throw new Error(
3277
- "Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these."
3278
- );
3279
- }
3280
- return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
3281
- }, "serializePrimitiveParam");
3282
- var serializeObjectParam3 = /* @__PURE__ */ __name(({
3283
- allowReserved,
3284
- explode,
3285
- name,
3286
- style,
3287
- value,
3288
- valueOnly
3289
- }) => {
3290
- if (value instanceof Date) {
3291
- return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
3292
- }
3293
- if (style !== "deepObject" && !explode) {
3294
- let values = [];
3295
- Object.entries(value).forEach(([key, v]) => {
3296
- values = [...values, key, allowReserved ? v : encodeURIComponent(v)];
3297
- });
3298
- const joinedValues2 = values.join(",");
3299
- switch (style) {
3300
- case "form":
3301
- return `${name}=${joinedValues2}`;
3302
- case "label":
3303
- return `.${joinedValues2}`;
3304
- case "matrix":
3305
- return `;${name}=${joinedValues2}`;
3306
- default:
3307
- return joinedValues2;
3308
- }
3309
- }
3310
- const separator = separatorObjectExplode3(style);
3311
- const joinedValues = Object.entries(value).map(
3312
- ([key, v]) => serializePrimitiveParam3({
3313
- allowReserved,
3314
- name: style === "deepObject" ? `${name}[${key}]` : key,
3315
- value: v
3316
- })
3317
- ).join(separator);
3318
- return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
3319
- }, "serializeObjectParam");
3320
-
3321
- // src/_api/generated/cfg_totp/core/utils.gen.ts
3322
- var PATH_PARAM_RE3 = /\{[^{}]+\}/g;
3323
- var defaultPathSerializer3 = /* @__PURE__ */ __name(({ path, url: _url }) => {
3324
- let url = _url;
3325
- const matches = _url.match(PATH_PARAM_RE3);
3326
- if (matches) {
3327
- for (const match of matches) {
3328
- let explode = false;
3329
- let name = match.substring(1, match.length - 1);
3330
- let style = "simple";
3331
- if (name.endsWith("*")) {
3332
- explode = true;
3333
- name = name.substring(0, name.length - 1);
3334
- }
3335
- if (name.startsWith(".")) {
3336
- name = name.substring(1);
3337
- style = "label";
3338
- } else if (name.startsWith(";")) {
3339
- name = name.substring(1);
3340
- style = "matrix";
3341
- }
3342
- const value = path[name];
3343
- if (value === void 0 || value === null) {
3344
- continue;
3345
- }
3346
- if (Array.isArray(value)) {
3347
- url = url.replace(match, serializeArrayParam3({ explode, name, style, value }));
3348
- continue;
3349
- }
3350
- if (typeof value === "object") {
3351
- url = url.replace(
3352
- match,
3353
- serializeObjectParam3({
3354
- explode,
3355
- name,
3356
- style,
3357
- value,
3358
- valueOnly: true
3359
- })
3360
- );
3361
- continue;
3362
- }
3363
- if (style === "matrix") {
3364
- url = url.replace(
3365
- match,
3366
- `;${serializePrimitiveParam3({
3367
- name,
3368
- value
3369
- })}`
3370
- );
3371
- continue;
3372
- }
3373
- const replaceValue = encodeURIComponent(
3374
- style === "label" ? `.${value}` : value
3375
- );
3376
- url = url.replace(match, replaceValue);
3377
- }
3378
- }
3379
- return url;
3380
- }, "defaultPathSerializer");
3381
- var getUrl3 = /* @__PURE__ */ __name(({
3382
- baseUrl: baseUrl2,
3383
- path,
3384
- query,
3385
- querySerializer,
3386
- url: _url
3387
- }) => {
3388
- const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
3389
- let url = (baseUrl2 ?? "") + pathUrl;
3390
- if (path) {
3391
- url = defaultPathSerializer3({ path, url });
3392
- }
3393
- let search = query ? querySerializer(query) : "";
3394
- if (search.startsWith("?")) {
3395
- search = search.substring(1);
3396
- }
3397
- if (search) {
3398
- url += `?${search}`;
3399
- }
3400
- return url;
3401
- }, "getUrl");
3402
- function getValidRequestBody3(options) {
3403
- const hasBody = options.body !== void 0;
3404
- const isSerializedBody = hasBody && options.bodySerializer;
3405
- if (isSerializedBody) {
3406
- if ("serializedBody" in options) {
3407
- const hasSerializedBody = options.serializedBody !== void 0 && options.serializedBody !== "";
3408
- return hasSerializedBody ? options.serializedBody : null;
3409
- }
3410
- return options.body !== "" ? options.body : null;
3411
- }
3412
- if (hasBody) {
3413
- return options.body;
3414
- }
3415
- return void 0;
3416
- }
3417
- __name(getValidRequestBody3, "getValidRequestBody");
3418
-
3419
- // src/_api/generated/cfg_totp/core/auth.gen.ts
3420
- var getAuthToken3 = /* @__PURE__ */ __name(async (auth, callback) => {
3421
- const token = typeof callback === "function" ? await callback(auth) : callback;
3422
- if (!token) {
3423
- return;
3424
- }
3425
- if (auth.scheme === "bearer") {
3426
- return `Bearer ${token}`;
3427
- }
3428
- if (auth.scheme === "basic") {
3429
- return `Basic ${btoa(token)}`;
3430
- }
3431
- return token;
3432
- }, "getAuthToken");
3433
-
3434
- // src/_api/generated/cfg_totp/client/utils.gen.ts
3435
- var createQuerySerializer3 = /* @__PURE__ */ __name(({
3436
- parameters = {},
3437
- ...args
3438
- } = {}) => {
3439
- const querySerializer = /* @__PURE__ */ __name((queryParams) => {
3440
- const search = [];
3441
- if (queryParams && typeof queryParams === "object") {
3442
- for (const name in queryParams) {
3443
- const value = queryParams[name];
3444
- if (value === void 0 || value === null) {
3445
- continue;
3446
- }
3447
- const options = parameters[name] || args;
3448
- if (Array.isArray(value)) {
3449
- const serializedArray = serializeArrayParam3({
3450
- allowReserved: options.allowReserved,
3451
- explode: true,
3452
- name,
3453
- style: "form",
3454
- value,
3455
- ...options.array
3456
- });
3457
- if (serializedArray) search.push(serializedArray);
3458
- } else if (typeof value === "object") {
3459
- const serializedObject = serializeObjectParam3({
3460
- allowReserved: options.allowReserved,
3461
- explode: true,
3462
- name,
3463
- style: "deepObject",
3464
- value,
3465
- ...options.object
3466
- });
3467
- if (serializedObject) search.push(serializedObject);
3468
- } else {
3469
- const serializedPrimitive = serializePrimitiveParam3({
3470
- allowReserved: options.allowReserved,
3471
- name,
3472
- value
3473
- });
3474
- if (serializedPrimitive) search.push(serializedPrimitive);
3475
- }
3476
- }
3477
- }
3478
- return search.join("&");
3479
- }, "querySerializer");
3480
- return querySerializer;
3481
- }, "createQuerySerializer");
3482
- var getParseAs3 = /* @__PURE__ */ __name((contentType) => {
3483
- if (!contentType) {
3484
- return "stream";
3485
- }
3486
- const cleanContent = contentType.split(";")[0]?.trim();
3487
- if (!cleanContent) {
3488
- return;
3489
- }
3490
- if (cleanContent.startsWith("application/json") || cleanContent.endsWith("+json")) {
3491
- return "json";
3492
- }
3493
- if (cleanContent === "multipart/form-data") {
3494
- return "formData";
3495
- }
3496
- if (["application/", "audio/", "image/", "video/"].some((type) => cleanContent.startsWith(type))) {
3497
- return "blob";
3498
- }
3499
- if (cleanContent.startsWith("text/")) {
3500
- return "text";
3501
- }
3502
- return;
3503
- }, "getParseAs");
3504
- var checkForExistence3 = /* @__PURE__ */ __name((options, name) => {
3505
- if (!name) {
3506
- return false;
3507
- }
3508
- if (options.headers.has(name) || options.query?.[name] || options.headers.get("Cookie")?.includes(`${name}=`)) {
3509
- return true;
3510
- }
3511
- return false;
3512
- }, "checkForExistence");
3513
- var setAuthParams3 = /* @__PURE__ */ __name(async ({
3514
- security,
3515
- ...options
3516
- }) => {
3517
- for (const auth of security) {
3518
- if (checkForExistence3(options, auth.name)) {
3519
- continue;
3520
- }
3521
- const token = await getAuthToken3(auth, options.auth);
3522
- if (!token) {
3523
- continue;
3524
- }
3525
- const name = auth.name ?? "Authorization";
3526
- switch (auth.in) {
3527
- case "query":
3528
- if (!options.query) {
3529
- options.query = {};
3530
- }
3531
- options.query[name] = token;
3532
- break;
3533
- case "cookie":
3534
- options.headers.append("Cookie", `${name}=${token}`);
3535
- break;
3536
- case "header":
3537
- default:
3538
- options.headers.set(name, token);
3539
- break;
3540
- }
3541
- }
3542
- }, "setAuthParams");
3543
- var buildUrl3 = /* @__PURE__ */ __name((options) => getUrl3({
3544
- baseUrl: options.baseUrl,
3545
- path: options.path,
3546
- query: options.query,
3547
- querySerializer: typeof options.querySerializer === "function" ? options.querySerializer : createQuerySerializer3(options.querySerializer),
3548
- url: options.url
3549
- }), "buildUrl");
3550
- var mergeConfigs3 = /* @__PURE__ */ __name((a, b) => {
3551
- const config = { ...a, ...b };
3552
- if (config.baseUrl?.endsWith("/")) {
3553
- config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
3554
- }
3555
- config.headers = mergeHeaders3(a.headers, b.headers);
3556
- return config;
3557
- }, "mergeConfigs");
3558
- var headersEntries3 = /* @__PURE__ */ __name((headers) => {
3559
- const entries = [];
3560
- headers.forEach((value, key) => {
3561
- entries.push([key, value]);
3562
- });
3563
- return entries;
3564
- }, "headersEntries");
3565
- var mergeHeaders3 = /* @__PURE__ */ __name((...headers) => {
3566
- const mergedHeaders = new Headers();
3567
- for (const header of headers) {
3568
- if (!header) {
3569
- continue;
3570
- }
3571
- const iterator = header instanceof Headers ? headersEntries3(header) : Object.entries(header);
3572
- for (const [key, value] of iterator) {
3573
- if (value === null) {
3574
- mergedHeaders.delete(key);
3575
- } else if (Array.isArray(value)) {
3576
- for (const v of value) {
3577
- mergedHeaders.append(key, v);
3578
- }
3579
- } else if (value !== void 0) {
3580
- mergedHeaders.set(
3581
- key,
3582
- typeof value === "object" ? JSON.stringify(value) : value
3583
- );
3584
- }
3585
- }
3586
- }
3587
- return mergedHeaders;
3588
- }, "mergeHeaders");
3589
- var Interceptors3 = class {
3590
- static {
3591
- __name(this, "Interceptors");
3592
- }
3593
- fns = [];
3594
- clear() {
3595
- this.fns = [];
3596
- }
3597
- eject(id) {
3598
- const index = this.getInterceptorIndex(id);
3599
- if (this.fns[index]) {
3600
- this.fns[index] = null;
3601
- }
3602
- }
3603
- exists(id) {
3604
- const index = this.getInterceptorIndex(id);
3605
- return Boolean(this.fns[index]);
3606
- }
3607
- getInterceptorIndex(id) {
3608
- if (typeof id === "number") {
3609
- return this.fns[id] ? id : -1;
3610
- }
3611
- return this.fns.indexOf(id);
3612
- }
3613
- update(id, fn) {
3614
- const index = this.getInterceptorIndex(id);
3615
- if (this.fns[index]) {
3616
- this.fns[index] = fn;
3617
- return id;
3618
- }
3619
- return false;
3620
- }
3621
- use(fn) {
3622
- this.fns.push(fn);
3623
- return this.fns.length - 1;
3624
- }
3625
- };
3626
- var createInterceptors3 = /* @__PURE__ */ __name(() => ({
3627
- error: new Interceptors3(),
3628
- request: new Interceptors3(),
3629
- response: new Interceptors3()
3630
- }), "createInterceptors");
3631
- var defaultQuerySerializer3 = createQuerySerializer3({
3632
- allowReserved: false,
3633
- array: {
3634
- explode: true,
3635
- style: "form"
3636
- },
3637
- object: {
3638
- explode: true,
3639
- style: "deepObject"
3640
- }
3641
- });
3642
- var defaultHeaders3 = {
3643
- "Content-Type": "application/json"
3644
- };
3645
- var createConfig3 = /* @__PURE__ */ __name((override = {}) => ({
3646
- ...jsonBodySerializer3,
3647
- headers: defaultHeaders3,
3648
- parseAs: "auto",
3649
- querySerializer: defaultQuerySerializer3,
3650
- ...override
3651
- }), "createConfig");
3652
-
3653
- // src/_api/generated/cfg_totp/client/client.gen.ts
3654
- var createClient3 = /* @__PURE__ */ __name((config = {}) => {
3655
- let _config = mergeConfigs3(createConfig3(), config);
3656
- const getConfig = /* @__PURE__ */ __name(() => ({ ..._config }), "getConfig");
3657
- const setConfig = /* @__PURE__ */ __name((config2) => {
3658
- _config = mergeConfigs3(_config, config2);
3659
- return getConfig();
3660
- }, "setConfig");
3661
- const interceptors = createInterceptors3();
3662
- const beforeRequest = /* @__PURE__ */ __name(async (options) => {
3663
- const opts = {
3664
- ..._config,
3665
- ...options,
3666
- fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
3667
- headers: mergeHeaders3(_config.headers, options.headers),
3668
- serializedBody: void 0
3669
- };
3670
- if (opts.security) {
3671
- await setAuthParams3({
3672
- ...opts,
3673
- security: opts.security
3674
- });
3675
- }
3676
- if (opts.requestValidator) {
3677
- await opts.requestValidator(opts);
3678
- }
3679
- if (opts.body !== void 0 && opts.bodySerializer) {
3680
- opts.serializedBody = opts.bodySerializer(opts.body);
3681
- }
3682
- if (opts.body === void 0 || opts.serializedBody === "") {
3683
- opts.headers.delete("Content-Type");
3684
- }
3685
- const resolvedOpts = opts;
3686
- const url = buildUrl3(resolvedOpts);
3687
- return { opts: resolvedOpts, url };
3688
- }, "beforeRequest");
3689
- const request = /* @__PURE__ */ __name(async (options) => {
3690
- const throwOnError = options.throwOnError ?? _config.throwOnError;
3691
- const responseStyle = options.responseStyle ?? _config.responseStyle;
3692
- let request2;
3693
- let response;
3694
- try {
3695
- const { opts, url } = await beforeRequest(options);
3696
- const requestInit = {
3697
- redirect: "follow",
3698
- ...opts,
3699
- body: getValidRequestBody3(opts)
3700
- };
3701
- request2 = new Request(url, requestInit);
3702
- for (const fn of interceptors.request.fns) {
3703
- if (fn) {
3704
- request2 = await fn(request2, opts);
3705
- }
3706
- }
3707
- const _fetch = opts.fetch;
3708
- response = await _fetch(request2);
3709
- for (const fn of interceptors.response.fns) {
3710
- if (fn) {
3711
- response = await fn(response, request2, opts);
3712
- }
3713
- }
3714
- const result = {
3715
- request: request2,
3716
- response
3717
- };
3718
- if (response.ok) {
3719
- const parseAs = (opts.parseAs === "auto" ? getParseAs3(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
3720
- if (response.status === 204 || response.headers.get("Content-Length") === "0") {
3721
- let emptyData;
3722
- switch (parseAs) {
3723
- case "arrayBuffer":
3724
- case "blob":
3725
- case "text":
3726
- emptyData = await response[parseAs]();
3727
- break;
3728
- case "formData":
3729
- emptyData = new FormData();
3730
- break;
3731
- case "stream":
3732
- emptyData = response.body;
3733
- break;
3734
- case "json":
3735
- default:
3736
- emptyData = {};
3737
- break;
3738
- }
3739
- return opts.responseStyle === "data" ? emptyData : {
3740
- data: emptyData,
3741
- ...result
3742
- };
3743
- }
3744
- let data;
3745
- switch (parseAs) {
3746
- case "arrayBuffer":
3747
- case "blob":
3748
- case "formData":
3749
- case "text":
3750
- data = await response[parseAs]();
3751
- break;
3752
- case "json": {
3753
- const text = await response.text();
3754
- data = text ? JSON.parse(text) : {};
3755
- break;
3756
- }
3757
- case "stream":
3758
- return opts.responseStyle === "data" ? response.body : {
3759
- data: response.body,
3760
- ...result
3761
- };
3762
- }
3763
- if (parseAs === "json") {
3764
- if (opts.responseValidator) {
3765
- await opts.responseValidator(data);
3766
- }
3767
- if (opts.responseTransformer) {
3768
- data = await opts.responseTransformer(data);
3769
- }
3770
- }
3771
- return opts.responseStyle === "data" ? data : {
3772
- data,
3773
- ...result
3774
- };
3775
- }
3776
- const textError = await response.text();
3777
- let jsonError;
3778
- try {
3779
- jsonError = JSON.parse(textError);
3780
- } catch {
3781
- }
3782
- throw jsonError ?? textError;
3783
- } catch (error) {
3784
- let finalError = error;
3785
- for (const fn of interceptors.error.fns) {
3786
- if (fn) {
3787
- finalError = await fn(finalError, response, request2, options);
3788
- }
3789
- }
3790
- finalError = finalError || {};
3791
- if (throwOnError) {
3792
- throw finalError;
3793
- }
3794
- return responseStyle === "data" ? void 0 : {
3795
- error: finalError,
3796
- request: request2,
3797
- response
3798
- };
3799
- }
3800
- }, "request");
3801
- const makeMethodFn = /* @__PURE__ */ __name((method) => (options) => request({ ...options, method }), "makeMethodFn");
3802
- const makeSseFn = /* @__PURE__ */ __name((method) => async (options) => {
3803
- const { opts, url } = await beforeRequest(options);
3804
- return createSseClient3({
3805
- ...opts,
3806
- body: opts.body,
3807
- method,
3808
- onRequest: /* @__PURE__ */ __name(async (url2, init) => {
3809
- let request2 = new Request(url2, init);
3810
- for (const fn of interceptors.request.fns) {
3811
- if (fn) {
3812
- request2 = await fn(request2, opts);
3813
- }
3814
- }
3815
- return request2;
3816
- }, "onRequest"),
3817
- serializedBody: getValidRequestBody3(opts),
3818
- url
3819
- });
3820
- }, "makeSseFn");
3821
- const _buildUrl = /* @__PURE__ */ __name((options) => buildUrl3({ ..._config, ...options }), "_buildUrl");
3822
- return {
3823
- buildUrl: _buildUrl,
3824
- connect: makeMethodFn("CONNECT"),
3825
- delete: makeMethodFn("DELETE"),
3826
- get: makeMethodFn("GET"),
3827
- getConfig,
3828
- head: makeMethodFn("HEAD"),
3829
- interceptors,
3830
- options: makeMethodFn("OPTIONS"),
3831
- patch: makeMethodFn("PATCH"),
3832
- post: makeMethodFn("POST"),
3833
- put: makeMethodFn("PUT"),
3834
- request,
3835
- setConfig,
3836
- sse: {
3837
- connect: makeSseFn("CONNECT"),
3838
- delete: makeSseFn("DELETE"),
3839
- get: makeSseFn("GET"),
3840
- head: makeSseFn("HEAD"),
3841
- options: makeSseFn("OPTIONS"),
3842
- patch: makeSseFn("PATCH"),
3843
- post: makeSseFn("POST"),
3844
- put: makeSseFn("PUT"),
3845
- trace: makeSseFn("TRACE")
3846
- },
3847
- trace: makeMethodFn("TRACE")
3848
- };
3849
- }, "createClient");
3850
-
3851
- // src/_api/generated/cfg_totp/client.gen.ts
3852
- var client3 = createClient3(createConfig3({ baseUrl: "http://localhost:8000" }));
3853
-
3854
- // src/_api/generated/cfg_totp/sdk.gen.ts
3855
- var Cfg3 = class {
3856
- static {
3857
- __name(this, "Cfg");
3858
- }
3859
- /**
3860
- * Get backup codes status for user.
3861
- */
3862
- static cfgTotpBackupCodesRetrieve(options) {
3863
- return (options?.client ?? client3).get({
3864
- security: [{ scheme: "bearer", type: "http" }],
3865
- url: "/cfg/totp/backup-codes/",
3866
- ...options
3867
- });
3868
- }
3869
- /**
3870
- * Regenerate backup codes.
3871
- *
3872
- * Requires TOTP code for verification.
3873
- * Invalidates all existing codes.
3874
- */
3875
- static cfgTotpBackupCodesRegenerateCreate(options) {
3876
- return (options.client ?? client3).post({
3877
- security: [{ scheme: "bearer", type: "http" }],
3878
- url: "/cfg/totp/backup-codes/regenerate/",
3879
- ...options,
3880
- headers: {
3881
- "Content-Type": "application/json",
3882
- ...options.headers
3883
- }
3884
- });
3885
- }
3886
- /**
3887
- * List all TOTP devices for user.
3888
- */
3889
- static cfgTotpDevicesRetrieve(options) {
3890
- return (options?.client ?? client3).get({
3891
- security: [{ scheme: "bearer", type: "http" }],
3892
- url: "/cfg/totp/devices/",
3893
- ...options
3894
- });
3895
- }
3896
- /**
3897
- * Delete a TOTP device.
3898
- *
3899
- * Requires verification code if removing the last/primary device.
3900
- */
3901
- static cfgTotpDevicesDestroy(options) {
3902
- return (options.client ?? client3).delete({
3903
- security: [{ scheme: "bearer", type: "http" }],
3904
- url: "/cfg/totp/devices/{id}/",
3905
- ...options
3906
- });
3907
- }
3908
- /**
3909
- * Completely disable 2FA for account.
3910
- *
3911
- * Requires verification code.
3912
- */
3913
- static cfgTotpDisableCreate(options) {
3914
- return (options.client ?? client3).post({
3915
- security: [{ scheme: "bearer", type: "http" }],
3916
- url: "/cfg/totp/disable/",
3917
- ...options,
3918
- headers: {
3919
- "Content-Type": "application/json",
3920
- ...options.headers
3921
- }
3922
- });
3923
- }
3924
- /**
3925
- * Start 2FA setup process.
3926
- *
3927
- * Creates a new TOTP device and returns QR code for scanning.
3928
- */
3929
- static cfgTotpSetupCreate(options) {
3930
- return (options?.client ?? client3).post({
3931
- security: [{ scheme: "bearer", type: "http" }],
3932
- url: "/cfg/totp/setup/",
3933
- ...options,
3934
- headers: {
3935
- "Content-Type": "application/json",
3936
- ...options?.headers
3937
- }
3938
- });
3939
- }
3940
- /**
3941
- * Confirm 2FA setup with first valid code.
3942
- *
3943
- * Activates the device and generates backup codes.
3944
- */
3945
- static cfgTotpSetupConfirmCreate(options) {
3946
- return (options.client ?? client3).post({
3947
- security: [{ scheme: "bearer", type: "http" }],
3948
- url: "/cfg/totp/setup/confirm/",
3949
- ...options,
3950
- headers: {
3951
- "Content-Type": "application/json",
3952
- ...options.headers
3953
- }
3954
- });
3955
- }
3956
- /**
3957
- * Verify TOTP code for 2FA session.
3958
- *
3959
- * Completes authentication and returns JWT tokens on success.
3960
- */
3961
- static cfgTotpVerifyCreate(options) {
3962
- return (options.client ?? client3).post({
3963
- security: [{ scheme: "bearer", type: "http" }],
3964
- url: "/cfg/totp/verify/",
3965
- ...options,
3966
- headers: {
3967
- "Content-Type": "application/json",
3968
- ...options.headers
3969
- }
3970
- });
3971
- }
3972
- /**
3973
- * Verify backup recovery code for 2FA session.
3974
- *
3975
- * Alternative verification method when TOTP device unavailable.
3976
- */
3977
- static cfgTotpVerifyBackupCreate(options) {
3978
- return (options.client ?? client3).post({
3979
- security: [{ scheme: "bearer", type: "http" }],
3980
- url: "/cfg/totp/verify/backup/",
3981
- ...options,
3982
- headers: {
3983
- "Content-Type": "application/json",
3984
- ...options.headers
3985
- }
3986
- });
3987
- }
3988
- };
3989
- var Totp = class {
3990
- static {
3991
- __name(this, "Totp");
3992
- }
3993
- /**
3994
- * Get backup codes status for user.
3995
- */
3996
- static cfgTotpBackupCodesRetrieve(options) {
3997
- return (options?.client ?? client3).get({
3998
- security: [{ scheme: "bearer", type: "http" }],
3999
- url: "/cfg/totp/backup-codes/",
4000
- ...options
4001
- });
4002
- }
4003
- /**
4004
- * Regenerate backup codes.
4005
- *
4006
- * Requires TOTP code for verification.
4007
- * Invalidates all existing codes.
4008
- */
4009
- static cfgTotpBackupCodesRegenerateCreate(options) {
4010
- return (options.client ?? client3).post({
4011
- security: [{ scheme: "bearer", type: "http" }],
4012
- url: "/cfg/totp/backup-codes/regenerate/",
4013
- ...options,
4014
- headers: {
4015
- "Content-Type": "application/json",
4016
- ...options.headers
4017
- }
4018
- });
4019
- }
4020
- /**
4021
- * List all TOTP devices for user.
4022
- */
4023
- static cfgTotpDevicesRetrieve(options) {
4024
- return (options?.client ?? client3).get({
4025
- security: [{ scheme: "bearer", type: "http" }],
4026
- url: "/cfg/totp/devices/",
4027
- ...options
4028
- });
4029
- }
4030
- /**
4031
- * Delete a TOTP device.
4032
- *
4033
- * Requires verification code if removing the last/primary device.
4034
- */
4035
- static cfgTotpDevicesDestroy(options) {
4036
- return (options.client ?? client3).delete({
4037
- security: [{ scheme: "bearer", type: "http" }],
4038
- url: "/cfg/totp/devices/{id}/",
4039
- ...options
4040
- });
4041
- }
4042
- /**
4043
- * Completely disable 2FA for account.
4044
- *
4045
- * Requires verification code.
4046
- */
4047
- static cfgTotpDisableCreate(options) {
4048
- return (options.client ?? client3).post({
4049
- security: [{ scheme: "bearer", type: "http" }],
4050
- url: "/cfg/totp/disable/",
4051
- ...options,
4052
- headers: {
4053
- "Content-Type": "application/json",
4054
- ...options.headers
4055
- }
4056
- });
4057
- }
4058
- /**
4059
- * Start 2FA setup process.
4060
- *
4061
- * Creates a new TOTP device and returns QR code for scanning.
4062
- */
4063
- static cfgTotpSetupCreate(options) {
4064
- return (options?.client ?? client3).post({
4065
- security: [{ scheme: "bearer", type: "http" }],
4066
- url: "/cfg/totp/setup/",
4067
- ...options,
4068
- headers: {
4069
- "Content-Type": "application/json",
4070
- ...options?.headers
4071
- }
4072
- });
4073
- }
4074
- /**
4075
- * Confirm 2FA setup with first valid code.
4076
- *
4077
- * Activates the device and generates backup codes.
4078
- */
4079
- static cfgTotpSetupConfirmCreate(options) {
4080
- return (options.client ?? client3).post({
4081
- security: [{ scheme: "bearer", type: "http" }],
4082
- url: "/cfg/totp/setup/confirm/",
4083
- ...options,
4084
- headers: {
4085
- "Content-Type": "application/json",
4086
- ...options.headers
4087
- }
4088
- });
4089
- }
4090
- /**
4091
- * Verify TOTP code for 2FA session.
4092
- *
4093
- * Completes authentication and returns JWT tokens on success.
4094
- */
4095
- static cfgTotpVerifyCreate(options) {
4096
- return (options.client ?? client3).post({
4097
- security: [{ scheme: "bearer", type: "http" }],
4098
- url: "/cfg/totp/verify/",
4099
- ...options,
4100
- headers: {
4101
- "Content-Type": "application/json",
4102
- ...options.headers
4103
- }
4104
- });
4105
- }
4106
- /**
4107
- * Verify backup recovery code for 2FA session.
4108
- *
4109
- * Alternative verification method when TOTP device unavailable.
4110
- */
4111
- static cfgTotpVerifyBackupCreate(options) {
4112
- return (options.client ?? client3).post({
4113
- security: [{ scheme: "bearer", type: "http" }],
4114
- url: "/cfg/totp/verify/backup/",
4115
- ...options,
4116
- headers: {
4117
- "Content-Type": "application/json",
4118
- ...options.headers
4119
- }
4120
- });
4121
- }
4122
- };
4123
- var BackupCodes = class {
4124
- static {
4125
- __name(this, "BackupCodes");
4126
- }
4127
- /**
4128
- * Get backup codes status for user.
4129
- */
4130
- static cfgTotpBackupCodesRetrieve(options) {
4131
- return (options?.client ?? client3).get({
4132
- security: [{ scheme: "bearer", type: "http" }],
4133
- url: "/cfg/totp/backup-codes/",
4134
- ...options
4135
- });
4136
- }
4137
- /**
4138
- * Regenerate backup codes.
4139
- *
4140
- * Requires TOTP code for verification.
4141
- * Invalidates all existing codes.
4142
- */
4143
- static cfgTotpBackupCodesRegenerateCreate(options) {
4144
- return (options.client ?? client3).post({
4145
- security: [{ scheme: "bearer", type: "http" }],
4146
- url: "/cfg/totp/backup-codes/regenerate/",
4147
- ...options,
4148
- headers: {
4149
- "Content-Type": "application/json",
4150
- ...options.headers
4151
- }
4152
- });
4153
- }
4154
- };
4155
- var TotpManagement = class {
4156
- static {
4157
- __name(this, "TotpManagement");
1096
+ setToken(token) {
1097
+ if (token) this.storage.setItem(ACCESS_KEY2, token);
1098
+ else this.storage.removeItem(ACCESS_KEY2);
4158
1099
  }
4159
- /**
4160
- * List all TOTP devices for user.
4161
- */
4162
- static cfgTotpDevicesRetrieve(options) {
4163
- return (options?.client ?? client3).get({
4164
- security: [{ scheme: "bearer", type: "http" }],
4165
- url: "/cfg/totp/devices/",
4166
- ...options
4167
- });
1100
+ getRefreshToken() {
1101
+ return this.storage.getItem(REFRESH_KEY2);
4168
1102
  }
4169
- /**
4170
- * Completely disable 2FA for account.
4171
- *
4172
- * Requires verification code.
4173
- */
4174
- static cfgTotpDisableCreate(options) {
4175
- return (options.client ?? client3).post({
4176
- security: [{ scheme: "bearer", type: "http" }],
4177
- url: "/cfg/totp/disable/",
4178
- ...options,
4179
- headers: {
4180
- "Content-Type": "application/json",
4181
- ...options.headers
4182
- }
4183
- });
1103
+ setRefreshToken(token) {
1104
+ if (token) this.storage.setItem(REFRESH_KEY2, token);
1105
+ else this.storage.removeItem(REFRESH_KEY2);
4184
1106
  }
4185
- };
4186
- var TotpSetup = class {
4187
- static {
4188
- __name(this, "TotpSetup");
1107
+ clearToken() {
1108
+ this.storage.removeItem(ACCESS_KEY2);
1109
+ this.storage.removeItem(REFRESH_KEY2);
4189
1110
  }
4190
- /**
4191
- * Start 2FA setup process.
4192
- *
4193
- * Creates a new TOTP device and returns QR code for scanning.
4194
- */
4195
- static cfgTotpSetupCreate(options) {
4196
- return (options?.client ?? client3).post({
4197
- security: [{ scheme: "bearer", type: "http" }],
4198
- url: "/cfg/totp/setup/",
4199
- ...options,
4200
- headers: {
4201
- "Content-Type": "application/json",
4202
- ...options?.headers
4203
- }
4204
- });
1111
+ isAuthenticated() {
1112
+ return this.getToken() !== null;
4205
1113
  }
4206
- /**
4207
- * Confirm 2FA setup with first valid code.
4208
- *
4209
- * Activates the device and generates backup codes.
4210
- */
4211
- static cfgTotpSetupConfirmCreate(options) {
4212
- return (options.client ?? client3).post({
4213
- security: [{ scheme: "bearer", type: "http" }],
4214
- url: "/cfg/totp/setup/confirm/",
4215
- ...options,
4216
- headers: {
4217
- "Content-Type": "application/json",
4218
- ...options.headers
4219
- }
4220
- });
1114
+ // ── Locale / API key ────────────────────────────────────────────────────
1115
+ getLocale() {
1116
+ return this.locale ?? detectLocale2();
4221
1117
  }
4222
- };
4223
- var TotpVerification = class {
4224
- static {
4225
- __name(this, "TotpVerification");
1118
+ setLocale(locale) {
1119
+ this.locale = locale;
4226
1120
  }
4227
- /**
4228
- * Verify TOTP code for 2FA session.
4229
- *
4230
- * Completes authentication and returns JWT tokens on success.
4231
- */
4232
- static cfgTotpVerifyCreate(options) {
4233
- return (options.client ?? client3).post({
4234
- security: [{ scheme: "bearer", type: "http" }],
4235
- url: "/cfg/totp/verify/",
4236
- ...options,
4237
- headers: {
4238
- "Content-Type": "application/json",
4239
- ...options.headers
4240
- }
4241
- });
1121
+ getApiKey() {
1122
+ return this.apiKey;
4242
1123
  }
4243
- /**
4244
- * Verify backup recovery code for 2FA session.
4245
- *
4246
- * Alternative verification method when TOTP device unavailable.
4247
- */
4248
- static cfgTotpVerifyBackupCreate(options) {
4249
- return (options.client ?? client3).post({
4250
- security: [{ scheme: "bearer", type: "http" }],
4251
- url: "/cfg/totp/verify/backup/",
4252
- ...options,
4253
- headers: {
4254
- "Content-Type": "application/json",
4255
- ...options.headers
4256
- }
4257
- });
1124
+ setApiKey(key) {
1125
+ this.apiKey = key;
4258
1126
  }
4259
1127
  };
4260
1128
 
4261
- // src/_api/generated/cfg_totp/schemas/BackupCodesRegenerateRequest.ts
4262
- import { z as z23 } from "zod";
4263
- var BackupCodesRegenerateRequestSchema = z23.object({
4264
- code: z23.string().min(6).max(6)
4265
- });
4266
-
4267
- // src/_api/generated/cfg_totp/schemas/BackupCodesRegenerateResponse.ts
4268
- import { z as z24 } from "zod";
4269
- var BackupCodesRegenerateResponseSchema = z24.object({
4270
- backup_codes: z24.array(z24.string()),
4271
- warning: z24.string()
4272
- });
4273
-
4274
- // src/_api/generated/cfg_totp/schemas/BackupCodesStatus.ts
4275
- import { z as z25 } from "zod";
4276
- var BackupCodesStatusSchema = z25.object({
4277
- remaining_count: z25.number().int(),
4278
- total_generated: z25.number().int(),
4279
- warning: z25.string().nullable().optional()
4280
- });
4281
-
4282
- // src/_api/generated/cfg_totp/schemas/ConfirmSetupRequest.ts
4283
- import { z as z26 } from "zod";
4284
- var ConfirmSetupRequestSchema = z26.object({
4285
- 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),
4286
- code: z26.string().min(6).max(6)
4287
- });
4288
-
4289
- // src/_api/generated/cfg_totp/schemas/ConfirmSetupResponse.ts
4290
- import { z as z27 } from "zod";
4291
- var ConfirmSetupResponseSchema = z27.object({
4292
- message: z27.string(),
4293
- backup_codes: z27.array(z27.string()),
4294
- backup_codes_warning: z27.string()
4295
- });
4296
-
4297
- // src/_api/generated/cfg_totp/schemas/DeviceList.ts
4298
- import { z as z29 } from "zod";
4299
-
4300
- // src/_api/generated/cfg_totp/schemas/DeviceListStatusEnum.ts
4301
- import { z as z28 } from "zod";
4302
- var DeviceListStatusEnumSchema = z28.enum(["pending", "active", "disabled"]);
4303
-
4304
- // src/_api/generated/cfg_totp/schemas/DeviceList.ts
4305
- var DeviceListSchema = z29.object({
4306
- 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),
4307
- name: z29.string(),
4308
- is_primary: z29.boolean(),
4309
- status: DeviceListStatusEnumSchema,
4310
- created_at: z29.string().datetime({ offset: true }),
4311
- confirmed_at: z29.string().datetime({ offset: true }).nullable(),
4312
- last_used_at: z29.string().datetime({ offset: true }).nullable()
4313
- });
4314
-
4315
- // src/_api/generated/cfg_totp/schemas/DeviceListResponse.ts
4316
- import { z as z30 } from "zod";
4317
- var DeviceListResponseSchema = z30.object({
4318
- devices: z30.array(DeviceListSchema),
4319
- has_2fa_enabled: z30.boolean()
4320
- });
4321
-
4322
- // src/_api/generated/cfg_totp/schemas/DisableRequest.ts
4323
- import { z as z31 } from "zod";
4324
- var DisableRequestSchema = z31.object({
4325
- code: z31.string().min(6).max(6)
4326
- });
4327
-
4328
- // src/_api/generated/cfg_totp/schemas/SetupRequest.ts
4329
- import { z as z32 } from "zod";
4330
- var SetupRequestSchema = z32.object({
4331
- device_name: z32.string().min(1).max(100).optional()
4332
- });
4333
-
4334
- // src/_api/generated/cfg_totp/schemas/SetupResponse.ts
4335
- import { z as z33 } from "zod";
4336
- var SetupResponseSchema = z33.object({
4337
- 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),
4338
- secret: z33.string(),
4339
- provisioning_uri: z33.string(),
4340
- qr_code_base64: z33.string(),
4341
- expires_in: z33.number().int()
4342
- });
4343
-
4344
- // src/_api/generated/cfg_totp/schemas/TotpVerifyUser.ts
4345
- import { z as z34 } from "zod";
4346
- var TotpVerifyUserSchema = z34.object({
4347
- id: z34.number().int(),
4348
- email: z34.email(),
4349
- first_name: z34.string().max(50).optional(),
4350
- last_name: z34.string().max(50).optional(),
4351
- full_name: z34.string(),
4352
- initials: z34.string(),
4353
- display_username: z34.string(),
4354
- company: z34.string().max(100).optional(),
4355
- phone: z34.string().max(20).optional(),
4356
- position: z34.string().max(100).optional(),
4357
- language: z34.string().max(10).optional(),
4358
- avatar: z34.string().nullable(),
4359
- is_staff: z34.boolean(),
4360
- is_superuser: z34.boolean(),
4361
- date_joined: z34.string().datetime({ offset: true }),
4362
- last_login: z34.string().datetime({ offset: true }).nullable(),
4363
- unanswered_messages_count: z34.number().int()
4364
- });
4365
-
4366
- // src/_api/generated/cfg_totp/schemas/VerifyBackupRequest.ts
4367
- import { z as z35 } from "zod";
4368
- var VerifyBackupRequestSchema = z35.object({
4369
- 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),
4370
- backup_code: z35.string().min(8).max(8)
4371
- });
4372
-
4373
- // src/_api/generated/cfg_totp/schemas/VerifyRequest.ts
4374
- import { z as z36 } from "zod";
4375
- var VerifyRequestSchema = z36.object({
4376
- 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),
4377
- code: z36.string().min(6).max(6)
4378
- });
4379
-
4380
- // src/_api/generated/cfg_totp/schemas/VerifyResponse.ts
4381
- import { z as z37 } from "zod";
4382
- var VerifyResponseSchema = z37.object({
4383
- message: z37.string(),
4384
- access_token: z37.string(),
4385
- refresh_token: z37.string(),
4386
- user: TotpVerifyUserSchema,
4387
- remaining_backup_codes: z37.number().int().optional(),
4388
- warning: z37.string().optional()
4389
- });
4390
-
4391
- // src/_api/generated/cfg_totp/api.ts
1129
+ // src/_api/generated/_cfg_totp/api.ts
4392
1130
  var ACCESS_KEY3 = "cfg.access_token";
4393
1131
  var REFRESH_KEY3 = "cfg.refresh_token";
4394
- var VALIDATION_ROUTES3 = [
4395
- { method: "GET", re: new RegExp("^/cfg/totp/backup\\-codes/?$"), schema: BackupCodesStatusSchema, path: "/cfg/totp/backup-codes/" },
4396
- { method: "POST", re: new RegExp("^/cfg/totp/backup\\-codes/regenerate/?$"), schema: BackupCodesRegenerateResponseSchema, path: "/cfg/totp/backup-codes/regenerate/" },
4397
- { method: "GET", re: new RegExp("^/cfg/totp/devices/?$"), schema: DeviceListResponseSchema, path: "/cfg/totp/devices/" },
4398
- { method: "POST", re: new RegExp("^/cfg/totp/setup/?$"), schema: SetupResponseSchema, path: "/cfg/totp/setup/" },
4399
- { method: "POST", re: new RegExp("^/cfg/totp/setup/confirm/?$"), schema: ConfirmSetupResponseSchema, path: "/cfg/totp/setup/confirm/" },
4400
- { method: "POST", re: new RegExp("^/cfg/totp/verify/?$"), schema: VerifyResponseSchema, path: "/cfg/totp/verify/" },
4401
- { method: "POST", re: new RegExp("^/cfg/totp/verify/backup/?$"), schema: VerifyResponseSchema, path: "/cfg/totp/verify/backup/" }
4402
- ];
4403
1132
  function detectLocale3() {
4404
1133
  try {
4405
1134
  if (typeof document !== "undefined") {
@@ -4423,12 +1152,6 @@ var API3 = class {
4423
1152
  locale;
4424
1153
  apiKey;
4425
1154
  logger;
4426
- cfg = Cfg3;
4427
- totp = Totp;
4428
- backupCodes = BackupCodes;
4429
- totpManagement = TotpManagement;
4430
- totpSetup = TotpSetup;
4431
- totpVerification = TotpVerification;
4432
1155
  constructor(baseUrl2, opts = {}) {
4433
1156
  this.baseUrl = baseUrl2.replace(/\/$/, "");
4434
1157
  this.storage = opts.storage ?? new LocalStorageAdapter();
@@ -4436,8 +1159,8 @@ var API3 = class {
4436
1159
  this.locale = opts.locale ?? null;
4437
1160
  this.apiKey = opts.apiKey ?? (typeof process !== "undefined" ? process.env?.NEXT_PUBLIC_API_KEY ?? null : null);
4438
1161
  const credentials = opts.withCredentials ?? true ? "include" : "same-origin";
4439
- client3.setConfig({ baseUrl: this.baseUrl, credentials });
4440
- client3.interceptors.request.use((request) => {
1162
+ client.setConfig({ baseUrl: this.baseUrl, credentials });
1163
+ client.interceptors.request.use((request) => {
4441
1164
  const access = this.getToken();
4442
1165
  if (access) request.headers.set("Authorization", `Bearer ${access}`);
4443
1166
  const locale = this.locale ?? detectLocale3();
@@ -4445,35 +1168,6 @@ var API3 = class {
4445
1168
  if (this.apiKey) request.headers.set("X-API-Key", this.apiKey);
4446
1169
  return request;
4447
1170
  });
4448
- client3.interceptors.response.use(async (response, request) => {
4449
- if (!response.ok) return response;
4450
- const ct = response.headers.get("content-type") || "";
4451
- if (!ct.includes("application/json")) return response;
4452
- const url = new URL(request.url);
4453
- const method = request.method.toUpperCase();
4454
- const route = VALIDATION_ROUTES3.find(
4455
- (r) => r.method === method && r.re.test(url.pathname)
4456
- );
4457
- if (!route) return response;
4458
- let payload;
4459
- try {
4460
- payload = await response.clone().json();
4461
- } catch {
4462
- return response;
4463
- }
4464
- const result = route.schema.safeParse(payload);
4465
- if (!result.success) {
4466
- dispatchValidationError({
4467
- operation: `${method} ${route.path}`,
4468
- path: route.path,
4469
- method,
4470
- error: result.error,
4471
- response: payload,
4472
- timestamp: /* @__PURE__ */ new Date()
4473
- });
4474
- }
4475
- return response;
4476
- });
4477
1171
  }
4478
1172
  // ── Base URL ────────────────────────────────────────────────────────────
4479
1173
  getBaseUrl() {
@@ -4481,7 +1175,7 @@ var API3 = class {
4481
1175
  }
4482
1176
  setBaseUrl(url) {
4483
1177
  this.baseUrl = url.replace(/\/$/, "");
4484
- client3.setConfig({ baseUrl: this.baseUrl });
1178
+ client.setConfig({ baseUrl: this.baseUrl });
4485
1179
  }
4486
1180
  // ── Tokens ──────────────────────────────────────────────────────────────
4487
1181
  getToken() {
@@ -4523,9 +1217,29 @@ var API3 = class {
4523
1217
  // src/_api/generated/index.ts
4524
1218
  var isStaticBuild = process.env.NEXT_PUBLIC_STATIC_BUILD === "true";
4525
1219
  var baseUrl = isStaticBuild ? "" : process.env.NEXT_PUBLIC_API_URL || "";
4526
- var cfgAccountsApi = new API(baseUrl, { storage: new LocalStorageAdapter() });
4527
- var cfgCentrifugoApi = new API2(baseUrl, { storage: new LocalStorageAdapter() });
4528
- var cfgTotpApi = new API3(baseUrl, { storage: new LocalStorageAdapter() });
1220
+ var CfgAccountsApi = new API(baseUrl, { storage: new LocalStorageAdapter() });
1221
+ var CfgCentrifugoApi = new API2(baseUrl, { storage: new LocalStorageAdapter() });
1222
+ var CfgTotpApi = new API3(baseUrl, { storage: new LocalStorageAdapter() });
1223
+
1224
+ // src/_api/generated/sdk.gen.ts
1225
+ var Auth = class {
1226
+ static {
1227
+ __name(this, "Auth");
1228
+ }
1229
+ /**
1230
+ * Refresh JWT token.
1231
+ */
1232
+ static cfgAccountsTokenRefreshCreate(options) {
1233
+ return (options.client ?? client).post({
1234
+ url: "/cfg/accounts/token/refresh/",
1235
+ ...options,
1236
+ headers: {
1237
+ "Content-Type": "application/json",
1238
+ ...options.headers
1239
+ }
1240
+ });
1241
+ }
1242
+ };
4529
1243
 
4530
1244
  // src/auth/utils/logger.ts
4531
1245
  import { createConsola as createConsola2 } from "consola";
@@ -4563,13 +1277,13 @@ async function refreshAccessToken() {
4563
1277
  isRefreshing = true;
4564
1278
  authLogger.info("Starting token refresh...");
4565
1279
  try {
4566
- const refreshToken = cfgAccountsApi.getRefreshToken();
1280
+ const refreshToken = CfgAccountsApi.getRefreshToken();
4567
1281
  if (!refreshToken) {
4568
1282
  authLogger.warn("No refresh token available for refresh");
4569
1283
  onTokenRefreshed(null);
4570
1284
  return null;
4571
1285
  }
4572
- const result = await cfgAccountsApi.auth.cfgAccountsTokenRefreshCreate({
1286
+ const result = await Auth.cfgAccountsTokenRefreshCreate({
4573
1287
  body: { refresh: refreshToken },
4574
1288
  throwOnError: true
4575
1289
  });
@@ -4579,8 +1293,8 @@ async function refreshAccessToken() {
4579
1293
  onTokenRefreshed(null);
4580
1294
  return null;
4581
1295
  }
4582
- cfgAccountsApi.setToken(newAccessToken);
4583
- cfgAccountsApi.setRefreshToken(refreshToken);
1296
+ CfgAccountsApi.setToken(newAccessToken);
1297
+ CfgAccountsApi.setRefreshToken(refreshToken);
4584
1298
  authLogger.info("Token refreshed successfully");
4585
1299
  onTokenRefreshed(newAccessToken);
4586
1300
  return newAccessToken;
@@ -4600,7 +1314,7 @@ __name(isAuthenticationError, "isAuthenticationError");
4600
1314
  function createAutoRefreshFetch(originalFetch) {
4601
1315
  return async (input, init) => {
4602
1316
  let response = await originalFetch(input, init);
4603
- if (isAuthenticationError(response) && cfgAccountsApi.getRefreshToken()) {
1317
+ if (isAuthenticationError(response) && CfgAccountsApi.getRefreshToken()) {
4604
1318
  authLogger.info("Received 401, attempting token refresh...");
4605
1319
  const newToken = await refreshAccessToken();
4606
1320
  if (newToken) {
@@ -4622,7 +1336,7 @@ function createAutoRefreshFetch(originalFetch) {
4622
1336
  }
4623
1337
  __name(createAutoRefreshFetch, "createAutoRefreshFetch");
4624
1338
  function isTokenExpiringSoon(thresholdMs = 5 * 60 * 1e3) {
4625
- const token = cfgAccountsApi.getToken();
1339
+ const token = CfgAccountsApi.getToken();
4626
1340
  if (!token) return false;
4627
1341
  try {
4628
1342
  const payload = JSON.parse(atob(token.split(".")[1]));