@djangocfg/api 2.1.327 → 2.1.332

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