@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/auth.cjs CHANGED
@@ -102,7 +102,7 @@ __name(withBasePath, "withBasePath");
102
102
  function useCfgRouter() {
103
103
  const router = (0, import_navigation.useRouter)();
104
104
  const basePath = (0, import_react.useMemo)(() => getBasePath(), []);
105
- const isStaticBuild3 = (0, import_react.useMemo)(() => {
105
+ const isStaticBuild2 = (0, import_react.useMemo)(() => {
106
106
  return typeof process !== "undefined" && process.env.NEXT_PUBLIC_STATIC_BUILD === "true";
107
107
  }, []);
108
108
  const push = (0, import_react.useCallback)((href, options) => {
@@ -312,7 +312,7 @@ var useAutoAuth = /* @__PURE__ */ __name((options = {}) => {
312
312
  // src/auth/hooks/useTwoFactor.ts
313
313
  var import_react6 = require("react");
314
314
 
315
- // src/_api/generated/cfg_accounts/core/bodySerializer.gen.ts
315
+ // src/_api/generated/core/bodySerializer.gen.ts
316
316
  var serializeFormDataPair = /* @__PURE__ */ __name((data, key, value) => {
317
317
  if (typeof value === "string" || value instanceof Blob) {
318
318
  data.append(key, value);
@@ -342,7 +342,7 @@ var jsonBodySerializer = {
342
342
  bodySerializer: /* @__PURE__ */ __name((body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value), "bodySerializer")
343
343
  };
344
344
 
345
- // src/_api/generated/cfg_accounts/core/params.gen.ts
345
+ // src/_api/generated/core/params.gen.ts
346
346
  var extraPrefixesMap = {
347
347
  $body_: "body",
348
348
  $headers_: "headers",
@@ -351,7 +351,7 @@ var extraPrefixesMap = {
351
351
  };
352
352
  var extraPrefixes = Object.entries(extraPrefixesMap);
353
353
 
354
- // src/_api/generated/cfg_accounts/core/serverSentEvents.gen.ts
354
+ // src/_api/generated/core/serverSentEvents.gen.ts
355
355
  function createSseClient({
356
356
  onRequest,
357
357
  onSseError,
@@ -479,7 +479,7 @@ function createSseClient({
479
479
  }
480
480
  __name(createSseClient, "createSseClient");
481
481
 
482
- // src/_api/generated/cfg_accounts/core/pathSerializer.gen.ts
482
+ // src/_api/generated/core/pathSerializer.gen.ts
483
483
  var separatorArrayExplode = /* @__PURE__ */ __name((style) => {
484
484
  switch (style) {
485
485
  case "label":
@@ -603,7 +603,7 @@ var serializeObjectParam = /* @__PURE__ */ __name(({
603
603
  return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
604
604
  }, "serializeObjectParam");
605
605
 
606
- // src/_api/generated/cfg_accounts/core/utils.gen.ts
606
+ // src/_api/generated/core/utils.gen.ts
607
607
  var PATH_PARAM_RE = /\{[^{}]+\}/g;
608
608
  var defaultPathSerializer = /* @__PURE__ */ __name(({ path, url: _url }) => {
609
609
  let url = _url;
@@ -664,14 +664,14 @@ var defaultPathSerializer = /* @__PURE__ */ __name(({ path, url: _url }) => {
664
664
  return url;
665
665
  }, "defaultPathSerializer");
666
666
  var getUrl = /* @__PURE__ */ __name(({
667
- baseUrl: baseUrl2,
667
+ baseUrl,
668
668
  path,
669
669
  query,
670
670
  querySerializer,
671
671
  url: _url
672
672
  }) => {
673
673
  const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
674
- let url = (baseUrl2 ?? "") + pathUrl;
674
+ let url = (baseUrl ?? "") + pathUrl;
675
675
  if (path) {
676
676
  url = defaultPathSerializer({ path, url });
677
677
  }
@@ -701,22 +701,22 @@ function getValidRequestBody(options) {
701
701
  }
702
702
  __name(getValidRequestBody, "getValidRequestBody");
703
703
 
704
- // src/_api/generated/cfg_accounts/core/auth.gen.ts
705
- var getAuthToken = /* @__PURE__ */ __name(async (auth, callback) => {
706
- const token = typeof callback === "function" ? await callback(auth) : callback;
704
+ // src/_api/generated/core/auth.gen.ts
705
+ var getAuthToken = /* @__PURE__ */ __name(async (auth2, callback) => {
706
+ const token = typeof callback === "function" ? await callback(auth2) : callback;
707
707
  if (!token) {
708
708
  return;
709
709
  }
710
- if (auth.scheme === "bearer") {
710
+ if (auth2.scheme === "bearer") {
711
711
  return `Bearer ${token}`;
712
712
  }
713
- if (auth.scheme === "basic") {
713
+ if (auth2.scheme === "basic") {
714
714
  return `Basic ${btoa(token)}`;
715
715
  }
716
716
  return token;
717
717
  }, "getAuthToken");
718
718
 
719
- // src/_api/generated/cfg_accounts/client/utils.gen.ts
719
+ // src/_api/generated/client/utils.gen.ts
720
720
  var createQuerySerializer = /* @__PURE__ */ __name(({
721
721
  parameters = {},
722
722
  ...args
@@ -799,16 +799,16 @@ var setAuthParams = /* @__PURE__ */ __name(async ({
799
799
  security,
800
800
  ...options
801
801
  }) => {
802
- for (const auth of security) {
803
- if (checkForExistence(options, auth.name)) {
802
+ for (const auth2 of security) {
803
+ if (checkForExistence(options, auth2.name)) {
804
804
  continue;
805
805
  }
806
- const token = await getAuthToken(auth, options.auth);
806
+ const token = await getAuthToken(auth2, options.auth);
807
807
  if (!token) {
808
808
  continue;
809
809
  }
810
- const name = auth.name ?? "Authorization";
811
- switch (auth.in) {
810
+ const name = auth2.name ?? "Authorization";
811
+ switch (auth2.in) {
812
812
  case "query":
813
813
  if (!options.query) {
814
814
  options.query = {};
@@ -935,7 +935,7 @@ var createConfig = /* @__PURE__ */ __name((override = {}) => ({
935
935
  ...override
936
936
  }), "createConfig");
937
937
 
938
- // src/_api/generated/cfg_accounts/client/client.gen.ts
938
+ // src/_api/generated/client/client.gen.ts
939
939
  var createClient = /* @__PURE__ */ __name((config = {}) => {
940
940
  let _config = mergeConfigs(createConfig(), config);
941
941
  const getConfig = /* @__PURE__ */ __name(() => ({ ..._config }), "getConfig");
@@ -1133,46 +1133,211 @@ var createClient = /* @__PURE__ */ __name((config = {}) => {
1133
1133
  };
1134
1134
  }, "createClient");
1135
1135
 
1136
- // src/_api/generated/cfg_accounts/client.gen.ts
1136
+ // src/_api/generated/client.gen.ts
1137
1137
  var client = createClient(createConfig({ baseUrl: "http://localhost:8000" }));
1138
1138
 
1139
- // src/_api/generated/_shared/storage.ts
1140
- var LocalStorageAdapter = class {
1141
- static {
1142
- __name(this, "LocalStorageAdapter");
1143
- }
1144
- getItem(key) {
1145
- if (typeof window === "undefined") return null;
1139
+ // src/_api/generated/helpers/auth.ts
1140
+ var ACCESS_KEY = "cfg.access_token";
1141
+ var REFRESH_KEY = "cfg.refresh_token";
1142
+ var API_KEY_KEY = "cfg.api_key";
1143
+ var isBrowser2 = typeof window !== "undefined";
1144
+ var localStorageBackend = {
1145
+ get(key) {
1146
+ if (!isBrowser2) return null;
1146
1147
  try {
1147
1148
  return window.localStorage.getItem(key);
1148
1149
  } catch {
1149
1150
  return null;
1150
1151
  }
1151
- }
1152
- setItem(key, value) {
1153
- if (typeof window === "undefined") return;
1152
+ },
1153
+ set(key, value) {
1154
+ if (!isBrowser2) return;
1154
1155
  try {
1155
- window.localStorage.setItem(key, value);
1156
+ if (value === null) window.localStorage.removeItem(key);
1157
+ else window.localStorage.setItem(key, value);
1156
1158
  } catch {
1157
1159
  }
1158
1160
  }
1159
- removeItem(key) {
1160
- if (typeof window === "undefined") return;
1161
+ };
1162
+ var COOKIE_MAX_AGE = 60 * 60 * 24 * 30;
1163
+ var cookieBackend = {
1164
+ get(key) {
1165
+ if (!isBrowser2) return null;
1161
1166
  try {
1162
- window.localStorage.removeItem(key);
1167
+ const re = new RegExp(`(?:^|;\\s*)${encodeURIComponent(key)}=([^;]*)`);
1168
+ const m = document.cookie.match(re);
1169
+ return m ? decodeURIComponent(m[1]) : null;
1163
1170
  } catch {
1171
+ return null;
1164
1172
  }
1165
- }
1166
- clear() {
1167
- if (typeof window === "undefined") return;
1173
+ },
1174
+ set(key, value) {
1175
+ if (!isBrowser2) return;
1168
1176
  try {
1169
- window.localStorage.clear();
1177
+ const k = encodeURIComponent(key);
1178
+ const secure = window.location.protocol === "https:" ? "; Secure" : "";
1179
+ if (value === null) {
1180
+ document.cookie = `${k}=; Path=/; Max-Age=0; SameSite=Lax${secure}`;
1181
+ } else {
1182
+ const v = encodeURIComponent(value);
1183
+ document.cookie = `${k}=${v}; Path=/; Max-Age=${COOKIE_MAX_AGE}; SameSite=Lax${secure}`;
1184
+ }
1170
1185
  } catch {
1171
1186
  }
1172
1187
  }
1173
1188
  };
1189
+ var _storage = localStorageBackend;
1190
+ var _storageMode = "localStorage";
1191
+ function detectLocale() {
1192
+ try {
1193
+ if (typeof document !== "undefined") {
1194
+ const m = document.cookie.match(/(?:^|;\s*)NEXT_LOCALE=([^;]*)/);
1195
+ if (m) return decodeURIComponent(m[1]);
1196
+ }
1197
+ if (typeof navigator !== "undefined" && navigator.language) {
1198
+ return navigator.language;
1199
+ }
1200
+ } catch {
1201
+ }
1202
+ return null;
1203
+ }
1204
+ __name(detectLocale, "detectLocale");
1205
+ function defaultBaseUrl() {
1206
+ try {
1207
+ if (typeof process !== "undefined" && process.env) {
1208
+ if (process.env.NEXT_PUBLIC_STATIC_BUILD === "true") return "";
1209
+ return process.env.NEXT_PUBLIC_API_URL || "";
1210
+ }
1211
+ } catch {
1212
+ }
1213
+ return "";
1214
+ }
1215
+ __name(defaultBaseUrl, "defaultBaseUrl");
1216
+ function defaultApiKey() {
1217
+ try {
1218
+ if (typeof process !== "undefined" && process.env?.NEXT_PUBLIC_API_KEY) {
1219
+ return process.env.NEXT_PUBLIC_API_KEY;
1220
+ }
1221
+ } catch {
1222
+ }
1223
+ return null;
1224
+ }
1225
+ __name(defaultApiKey, "defaultApiKey");
1226
+ var _localeOverride = null;
1227
+ var _apiKeyOverride = null;
1228
+ var _baseUrlOverride = null;
1229
+ var _withCredentials = true;
1230
+ var _onUnauthorized = null;
1231
+ var auth = {
1232
+ // ── Storage mode ──────────────────────────────────────────────────
1233
+ getStorageMode() {
1234
+ return _storageMode;
1235
+ },
1236
+ /**
1237
+ * Switch the storage backend. Existing values in the *previous*
1238
+ * backend are NOT migrated — set fresh values after switching.
1239
+ */
1240
+ setStorageMode(mode) {
1241
+ _storageMode = mode;
1242
+ _storage = mode === "cookie" ? cookieBackend : localStorageBackend;
1243
+ },
1244
+ // ── Bearer token ──────────────────────────────────────────────────
1245
+ getToken() {
1246
+ return _storage.get(ACCESS_KEY);
1247
+ },
1248
+ setToken(token) {
1249
+ _storage.set(ACCESS_KEY, token);
1250
+ },
1251
+ getRefreshToken() {
1252
+ return _storage.get(REFRESH_KEY);
1253
+ },
1254
+ setRefreshToken(token) {
1255
+ _storage.set(REFRESH_KEY, token);
1256
+ },
1257
+ clearTokens() {
1258
+ _storage.set(ACCESS_KEY, null);
1259
+ _storage.set(REFRESH_KEY, null);
1260
+ },
1261
+ isAuthenticated() {
1262
+ return _storage.get(ACCESS_KEY) !== null;
1263
+ },
1264
+ // ── API key ───────────────────────────────────────────────────────
1265
+ /** In-memory API key. Falls back to storage, then NEXT_PUBLIC_API_KEY. */
1266
+ getApiKey() {
1267
+ return _apiKeyOverride ?? _storage.get(API_KEY_KEY) ?? defaultApiKey();
1268
+ },
1269
+ /** In-memory only (cleared on reload). */
1270
+ setApiKey(key) {
1271
+ _apiKeyOverride = key;
1272
+ },
1273
+ /** Persist to active storage backend (localStorage or cookie). */
1274
+ setApiKeyPersist(key) {
1275
+ _apiKeyOverride = key;
1276
+ _storage.set(API_KEY_KEY, key);
1277
+ },
1278
+ clearApiKey() {
1279
+ _apiKeyOverride = null;
1280
+ _storage.set(API_KEY_KEY, null);
1281
+ },
1282
+ // ── Locale ────────────────────────────────────────────────────────
1283
+ /** Override locale → falls back to NEXT_LOCALE cookie / navigator.language. */
1284
+ getLocale() {
1285
+ return _localeOverride ?? detectLocale();
1286
+ },
1287
+ setLocale(locale) {
1288
+ _localeOverride = locale;
1289
+ },
1290
+ // ── Base URL ──────────────────────────────────────────────────────
1291
+ getBaseUrl() {
1292
+ const url = _baseUrlOverride ?? defaultBaseUrl();
1293
+ return url.replace(/\/$/, "");
1294
+ },
1295
+ setBaseUrl(url) {
1296
+ _baseUrlOverride = url ? url.replace(/\/$/, "") : null;
1297
+ client.setConfig({ baseUrl: this.getBaseUrl() });
1298
+ },
1299
+ // ── Credentials toggle (Django session/CSRF cross-origin) ─────────
1300
+ getWithCredentials() {
1301
+ return _withCredentials;
1302
+ },
1303
+ setWithCredentials(value) {
1304
+ _withCredentials = value;
1305
+ client.setConfig({ credentials: value ? "include" : "same-origin" });
1306
+ },
1307
+ // ── 401 handler ───────────────────────────────────────────────────
1308
+ /**
1309
+ * Register a callback fired on every 401 response. Use this to wire
1310
+ * a token-refresh flow or a forced logout. Setting `null` removes
1311
+ * the handler.
1312
+ */
1313
+ onUnauthorized(cb) {
1314
+ _onUnauthorized = cb;
1315
+ }
1316
+ };
1317
+ client.setConfig({
1318
+ baseUrl: auth.getBaseUrl(),
1319
+ credentials: _withCredentials ? "include" : "same-origin"
1320
+ });
1321
+ client.interceptors.request.use((request) => {
1322
+ const token = auth.getToken();
1323
+ if (token) request.headers.set("Authorization", `Bearer ${token}`);
1324
+ const locale = auth.getLocale();
1325
+ if (locale) request.headers.set("Accept-Language", locale);
1326
+ const apiKey = auth.getApiKey();
1327
+ if (apiKey) request.headers.set("X-API-Key", apiKey);
1328
+ return request;
1329
+ });
1330
+ client.interceptors.response.use((response) => {
1331
+ if (response.status === 401 && _onUnauthorized) {
1332
+ try {
1333
+ _onUnauthorized(response);
1334
+ } catch {
1335
+ }
1336
+ }
1337
+ return response;
1338
+ });
1174
1339
 
1175
- // src/_api/generated/_shared/logger.ts
1340
+ // src/_api/generated/helpers/logger.ts
1176
1341
  var import_consola2 = require("consola");
1177
1342
  var DEFAULT_CONFIG = {
1178
1343
  enabled: typeof process !== "undefined" && process.env.NODE_ENV !== "production",
@@ -1266,7 +1431,234 @@ var APILogger = class {
1266
1431
  };
1267
1432
  var defaultLogger = new APILogger();
1268
1433
 
1269
- // src/_api/generated/cfg_accounts/sdk.gen.ts
1434
+ // src/_api/generated/_cfg_accounts/api.ts
1435
+ var API = class {
1436
+ static {
1437
+ __name(this, "API");
1438
+ }
1439
+ logger;
1440
+ constructor(_baseUrl, opts = {}) {
1441
+ this.logger = new APILogger(opts.logger);
1442
+ if (_baseUrl) auth.setBaseUrl(_baseUrl);
1443
+ if (opts.locale !== void 0) auth.setLocale(opts.locale);
1444
+ if (opts.apiKey !== void 0) auth.setApiKey(opts.apiKey);
1445
+ if (opts.withCredentials !== void 0) auth.setWithCredentials(opts.withCredentials);
1446
+ }
1447
+ // ── Base URL ────────────────────────────────────────────────────────────
1448
+ getBaseUrl() {
1449
+ return auth.getBaseUrl();
1450
+ }
1451
+ setBaseUrl(url) {
1452
+ auth.setBaseUrl(url);
1453
+ }
1454
+ // ── Tokens ──────────────────────────────────────────────────────────────
1455
+ getToken() {
1456
+ return auth.getToken();
1457
+ }
1458
+ setToken(token) {
1459
+ auth.setToken(token);
1460
+ }
1461
+ getRefreshToken() {
1462
+ return auth.getRefreshToken();
1463
+ }
1464
+ setRefreshToken(token) {
1465
+ auth.setRefreshToken(token);
1466
+ }
1467
+ clearToken() {
1468
+ auth.clearTokens();
1469
+ }
1470
+ isAuthenticated() {
1471
+ return auth.isAuthenticated();
1472
+ }
1473
+ // ── Locale / API key ────────────────────────────────────────────────────
1474
+ getLocale() {
1475
+ return auth.getLocale();
1476
+ }
1477
+ setLocale(locale) {
1478
+ auth.setLocale(locale);
1479
+ }
1480
+ getApiKey() {
1481
+ return auth.getApiKey();
1482
+ }
1483
+ setApiKey(key) {
1484
+ auth.setApiKey(key);
1485
+ }
1486
+ };
1487
+
1488
+ // src/_api/generated/helpers/errors.ts
1489
+ var APIError = class extends Error {
1490
+ constructor(statusCode, statusText, response, url, message) {
1491
+ super(message || `HTTP ${statusCode}: ${statusText}`);
1492
+ this.statusCode = statusCode;
1493
+ this.statusText = statusText;
1494
+ this.response = response;
1495
+ this.url = url;
1496
+ this.name = "APIError";
1497
+ }
1498
+ static {
1499
+ __name(this, "APIError");
1500
+ }
1501
+ get details() {
1502
+ if (typeof this.response === "object" && this.response !== null) {
1503
+ return this.response;
1504
+ }
1505
+ return null;
1506
+ }
1507
+ get fieldErrors() {
1508
+ const details = this.details;
1509
+ if (!details) return null;
1510
+ const fieldErrors = {};
1511
+ for (const [key, value] of Object.entries(details)) {
1512
+ if (Array.isArray(value)) fieldErrors[key] = value;
1513
+ }
1514
+ return Object.keys(fieldErrors).length > 0 ? fieldErrors : null;
1515
+ }
1516
+ get errorMessage() {
1517
+ const details = this.details;
1518
+ if (!details) return this.message;
1519
+ if (details.detail) {
1520
+ return Array.isArray(details.detail) ? details.detail.join(", ") : String(details.detail);
1521
+ }
1522
+ if (details.error) return String(details.error);
1523
+ if (details.message) return String(details.message);
1524
+ const fieldErrors = this.fieldErrors;
1525
+ if (fieldErrors) {
1526
+ const firstField = Object.keys(fieldErrors)[0];
1527
+ if (firstField) return `${firstField}: ${fieldErrors[firstField]?.join(", ")}`;
1528
+ }
1529
+ return this.message;
1530
+ }
1531
+ get isValidationError() {
1532
+ return this.statusCode === 400;
1533
+ }
1534
+ get isAuthError() {
1535
+ return this.statusCode === 401;
1536
+ }
1537
+ get isPermissionError() {
1538
+ return this.statusCode === 403;
1539
+ }
1540
+ get isNotFoundError() {
1541
+ return this.statusCode === 404;
1542
+ }
1543
+ get isServerError() {
1544
+ return this.statusCode >= 500 && this.statusCode < 600;
1545
+ }
1546
+ };
1547
+
1548
+ // src/_api/generated/_cfg_centrifugo/api.ts
1549
+ var API2 = class {
1550
+ static {
1551
+ __name(this, "API");
1552
+ }
1553
+ logger;
1554
+ constructor(_baseUrl, opts = {}) {
1555
+ this.logger = new APILogger(opts.logger);
1556
+ if (_baseUrl) auth.setBaseUrl(_baseUrl);
1557
+ if (opts.locale !== void 0) auth.setLocale(opts.locale);
1558
+ if (opts.apiKey !== void 0) auth.setApiKey(opts.apiKey);
1559
+ if (opts.withCredentials !== void 0) auth.setWithCredentials(opts.withCredentials);
1560
+ }
1561
+ // ── Base URL ────────────────────────────────────────────────────────────
1562
+ getBaseUrl() {
1563
+ return auth.getBaseUrl();
1564
+ }
1565
+ setBaseUrl(url) {
1566
+ auth.setBaseUrl(url);
1567
+ }
1568
+ // ── Tokens ──────────────────────────────────────────────────────────────
1569
+ getToken() {
1570
+ return auth.getToken();
1571
+ }
1572
+ setToken(token) {
1573
+ auth.setToken(token);
1574
+ }
1575
+ getRefreshToken() {
1576
+ return auth.getRefreshToken();
1577
+ }
1578
+ setRefreshToken(token) {
1579
+ auth.setRefreshToken(token);
1580
+ }
1581
+ clearToken() {
1582
+ auth.clearTokens();
1583
+ }
1584
+ isAuthenticated() {
1585
+ return auth.isAuthenticated();
1586
+ }
1587
+ // ── Locale / API key ────────────────────────────────────────────────────
1588
+ getLocale() {
1589
+ return auth.getLocale();
1590
+ }
1591
+ setLocale(locale) {
1592
+ auth.setLocale(locale);
1593
+ }
1594
+ getApiKey() {
1595
+ return auth.getApiKey();
1596
+ }
1597
+ setApiKey(key) {
1598
+ auth.setApiKey(key);
1599
+ }
1600
+ };
1601
+
1602
+ // src/_api/generated/_cfg_totp/api.ts
1603
+ var API3 = class {
1604
+ static {
1605
+ __name(this, "API");
1606
+ }
1607
+ logger;
1608
+ constructor(_baseUrl, opts = {}) {
1609
+ this.logger = new APILogger(opts.logger);
1610
+ if (_baseUrl) auth.setBaseUrl(_baseUrl);
1611
+ if (opts.locale !== void 0) auth.setLocale(opts.locale);
1612
+ if (opts.apiKey !== void 0) auth.setApiKey(opts.apiKey);
1613
+ if (opts.withCredentials !== void 0) auth.setWithCredentials(opts.withCredentials);
1614
+ }
1615
+ // ── Base URL ────────────────────────────────────────────────────────────
1616
+ getBaseUrl() {
1617
+ return auth.getBaseUrl();
1618
+ }
1619
+ setBaseUrl(url) {
1620
+ auth.setBaseUrl(url);
1621
+ }
1622
+ // ── Tokens ──────────────────────────────────────────────────────────────
1623
+ getToken() {
1624
+ return auth.getToken();
1625
+ }
1626
+ setToken(token) {
1627
+ auth.setToken(token);
1628
+ }
1629
+ getRefreshToken() {
1630
+ return auth.getRefreshToken();
1631
+ }
1632
+ setRefreshToken(token) {
1633
+ auth.setRefreshToken(token);
1634
+ }
1635
+ clearToken() {
1636
+ auth.clearTokens();
1637
+ }
1638
+ isAuthenticated() {
1639
+ return auth.isAuthenticated();
1640
+ }
1641
+ // ── Locale / API key ────────────────────────────────────────────────────
1642
+ getLocale() {
1643
+ return auth.getLocale();
1644
+ }
1645
+ setLocale(locale) {
1646
+ auth.setLocale(locale);
1647
+ }
1648
+ getApiKey() {
1649
+ return auth.getApiKey();
1650
+ }
1651
+ setApiKey(key) {
1652
+ auth.setApiKey(key);
1653
+ }
1654
+ };
1655
+
1656
+ // src/_api/generated/index.ts
1657
+ var CfgAccountsApi = new API();
1658
+ var CfgCentrifugoApi = new API2();
1659
+ var CfgTotpApi = new API3();
1660
+
1661
+ // src/_api/generated/sdk.gen.ts
1270
1662
  var Cfg = class {
1271
1663
  static {
1272
1664
  __name(this, "Cfg");
@@ -1524,105 +1916,38 @@ var Cfg = class {
1524
1916
  }
1525
1917
  });
1526
1918
  }
1527
- };
1528
- var Accounts = class {
1529
- static {
1530
- __name(this, "Accounts");
1531
- }
1532
1919
  /**
1533
- * List OAuth connections
1920
+ * Get Centrifugo connection token
1534
1921
  *
1535
- * Get all OAuth connections for the current user.
1922
+ * Generate JWT token for WebSocket connection to Centrifugo. Token includes user's allowed channels based on their permissions. Requires authentication.
1536
1923
  */
1537
- static cfgAccountsOauthConnectionsList(options) {
1924
+ static cfgCentrifugoAuthTokenRetrieve(options) {
1538
1925
  return (options?.client ?? client).get({
1539
1926
  security: [{ scheme: "bearer", type: "http" }],
1540
- url: "/cfg/accounts/oauth/connections/",
1927
+ url: "/cfg/centrifugo/auth/token/",
1541
1928
  ...options
1542
1929
  });
1543
1930
  }
1544
1931
  /**
1545
- * Disconnect OAuth provider
1546
- *
1547
- * Remove OAuth connection for the specified provider.
1548
- */
1549
- static cfgAccountsOauthDisconnectCreate(options) {
1550
- return (options.client ?? client).post({
1551
- security: [{ scheme: "bearer", type: "http" }],
1552
- url: "/cfg/accounts/oauth/disconnect/",
1553
- ...options,
1554
- headers: {
1555
- "Content-Type": "application/json",
1556
- ...options.headers
1557
- }
1558
- });
1559
- }
1560
- /**
1561
- * Start GitHub OAuth
1562
- *
1563
- * Generate GitHub OAuth authorization URL. Redirect user to this URL to start authentication.
1564
- */
1565
- static cfgAccountsOauthGithubAuthorizeCreate(options) {
1566
- return (options?.client ?? client).post({
1567
- url: "/cfg/accounts/oauth/github/authorize/",
1568
- ...options,
1569
- headers: {
1570
- "Content-Type": "application/json",
1571
- ...options?.headers
1572
- }
1573
- });
1574
- }
1575
- /**
1576
- * Complete GitHub OAuth
1577
- *
1578
- * Exchange authorization code for JWT tokens. Call this after GitHub redirects back with code.
1579
- */
1580
- static cfgAccountsOauthGithubCallbackCreate(options) {
1581
- return (options.client ?? client).post({
1582
- url: "/cfg/accounts/oauth/github/callback/",
1583
- ...options,
1584
- headers: {
1585
- "Content-Type": "application/json",
1586
- ...options.headers
1587
- }
1588
- });
1589
- }
1590
- /**
1591
- * List OAuth providers
1592
- *
1593
- * Get list of available OAuth providers for authentication.
1594
- */
1595
- static cfgAccountsOauthProvidersRetrieve(options) {
1596
- return (options?.client ?? client).get({ url: "/cfg/accounts/oauth/providers/", ...options });
1597
- }
1598
- /**
1599
- * Request OTP code to email.
1932
+ * Get backup codes status for user.
1600
1933
  */
1601
- static cfgAccountsOtpRequestCreate(options) {
1602
- return (options.client ?? client).post({
1934
+ static cfgTotpBackupCodesRetrieve(options) {
1935
+ return (options?.client ?? client).get({
1603
1936
  security: [{ scheme: "bearer", type: "http" }],
1604
- url: "/cfg/accounts/otp/request/",
1605
- ...options,
1606
- headers: {
1607
- "Content-Type": "application/json",
1608
- ...options.headers
1609
- }
1937
+ url: "/cfg/totp/backup-codes/",
1938
+ ...options
1610
1939
  });
1611
1940
  }
1612
1941
  /**
1613
- * Verify OTP code and return JWT tokens or 2FA session.
1614
- *
1615
- * If user has 2FA enabled:
1616
- * - Returns requires_2fa=True with session_id
1617
- * - Client must complete 2FA verification at /cfg/totp/verify/
1942
+ * Regenerate backup codes.
1618
1943
  *
1619
- * If user has no 2FA:
1620
- * - Returns JWT tokens and user data directly
1944
+ * Requires TOTP code for verification.
1945
+ * Invalidates all existing codes.
1621
1946
  */
1622
- static cfgAccountsOtpVerifyCreate(options) {
1947
+ static cfgTotpBackupCodesRegenerateCreate(options) {
1623
1948
  return (options.client ?? client).post({
1624
1949
  security: [{ scheme: "bearer", type: "http" }],
1625
- url: "/cfg/accounts/otp/verify/",
1950
+ url: "/cfg/totp/backup-codes/regenerate/",
1626
1951
  ...options,
1627
1952
  headers: {
1628
1953
  "Content-Type": "application/json",
@@ -1631,97 +1956,52 @@ var Accounts = class {
1631
1956
  });
1632
1957
  }
1633
1958
  /**
1634
- * Get current user profile
1635
- *
1636
- * Retrieve the current authenticated user's profile information.
1959
+ * List all TOTP devices for user.
1637
1960
  */
1638
- static cfgAccountsProfileRetrieve(options) {
1961
+ static cfgTotpDevicesRetrieve(options) {
1639
1962
  return (options?.client ?? client).get({
1640
- security: [{ scheme: "bearer", type: "http" }, {
1641
- in: "cookie",
1642
- name: "sessionid",
1643
- type: "apiKey"
1644
- }],
1645
- url: "/cfg/accounts/profile/",
1963
+ security: [{ scheme: "bearer", type: "http" }],
1964
+ url: "/cfg/totp/devices/",
1646
1965
  ...options
1647
1966
  });
1648
1967
  }
1649
1968
  /**
1650
- * Upload user avatar
1969
+ * Delete a TOTP device.
1651
1970
  *
1652
- * Upload avatar image for the current authenticated user. Accepts multipart/form-data with 'avatar' field.
1971
+ * Requires verification code if removing the last/primary device.
1653
1972
  */
1654
- static cfgAccountsProfileAvatarCreate(options) {
1655
- return (options?.client ?? client).post({
1656
- ...formDataBodySerializer,
1973
+ static cfgTotpDevicesDestroy(options) {
1974
+ return (options.client ?? client).delete({
1657
1975
  security: [{ scheme: "bearer", type: "http" }],
1658
- url: "/cfg/accounts/profile/avatar/",
1659
- ...options,
1660
- headers: {
1661
- "Content-Type": null,
1662
- ...options?.headers
1663
- }
1664
- });
1665
- }
1666
- /**
1667
- * Delete user account
1668
- *
1669
- *
1670
- * Permanently delete the current user's account.
1671
- *
1672
- * This operation:
1673
- * - Deactivates the account (user cannot log in)
1674
- * - Anonymizes personal data (GDPR compliance)
1675
- * - Frees up the email address for re-registration
1676
- * - Preserves audit trail
1677
- *
1678
- * The account can be restored by an administrator if needed.
1679
- *
1680
- */
1681
- static cfgAccountsProfileDeleteCreate(options) {
1682
- return (options?.client ?? client).post({
1683
- security: [{ scheme: "bearer", type: "http" }, {
1684
- in: "cookie",
1685
- name: "sessionid",
1686
- type: "apiKey"
1687
- }],
1688
- url: "/cfg/accounts/profile/delete/",
1976
+ url: "/cfg/totp/devices/{id}/",
1689
1977
  ...options
1690
1978
  });
1691
1979
  }
1692
1980
  /**
1693
- * Partial update user profile
1981
+ * Completely disable 2FA for account.
1694
1982
  *
1695
- * Partially update the current authenticated user's profile information. Supports avatar upload.
1983
+ * Requires verification code.
1696
1984
  */
1697
- static cfgAccountsProfilePartialPartialUpdate(options) {
1698
- return (options?.client ?? client).patch({
1699
- security: [{ scheme: "bearer", type: "http" }, {
1700
- in: "cookie",
1701
- name: "sessionid",
1702
- type: "apiKey"
1703
- }],
1704
- url: "/cfg/accounts/profile/partial/",
1985
+ static cfgTotpDisableCreate(options) {
1986
+ return (options.client ?? client).post({
1987
+ security: [{ scheme: "bearer", type: "http" }],
1988
+ url: "/cfg/totp/disable/",
1705
1989
  ...options,
1706
1990
  headers: {
1707
1991
  "Content-Type": "application/json",
1708
- ...options?.headers
1992
+ ...options.headers
1709
1993
  }
1710
1994
  });
1711
1995
  }
1712
1996
  /**
1713
- * Partial update user profile
1997
+ * Start 2FA setup process.
1714
1998
  *
1715
- * Partially update the current authenticated user's profile information. Supports avatar upload.
1999
+ * Creates a new TOTP device and returns QR code for scanning.
1716
2000
  */
1717
- static cfgAccountsProfilePartialUpdate(options) {
1718
- return (options?.client ?? client).put({
1719
- security: [{ scheme: "bearer", type: "http" }, {
1720
- in: "cookie",
1721
- name: "sessionid",
1722
- type: "apiKey"
1723
- }],
1724
- url: "/cfg/accounts/profile/partial/",
2001
+ static cfgTotpSetupCreate(options) {
2002
+ return (options?.client ?? client).post({
2003
+ security: [{ scheme: "bearer", type: "http" }],
2004
+ url: "/cfg/totp/setup/",
1725
2005
  ...options,
1726
2006
  headers: {
1727
2007
  "Content-Type": "application/json",
@@ -1730,51 +2010,46 @@ var Accounts = class {
1730
2010
  });
1731
2011
  }
1732
2012
  /**
1733
- * Update user profile
2013
+ * Confirm 2FA setup with first valid code.
1734
2014
  *
1735
- * Update the current authenticated user's profile information.
2015
+ * Activates the device and generates backup codes.
1736
2016
  */
1737
- static cfgAccountsProfileUpdatePartialUpdate(options) {
1738
- return (options?.client ?? client).patch({
1739
- security: [{ scheme: "bearer", type: "http" }, {
1740
- in: "cookie",
1741
- name: "sessionid",
1742
- type: "apiKey"
1743
- }],
1744
- url: "/cfg/accounts/profile/update/",
2017
+ static cfgTotpSetupConfirmCreate(options) {
2018
+ return (options.client ?? client).post({
2019
+ security: [{ scheme: "bearer", type: "http" }],
2020
+ url: "/cfg/totp/setup/confirm/",
1745
2021
  ...options,
1746
2022
  headers: {
1747
2023
  "Content-Type": "application/json",
1748
- ...options?.headers
2024
+ ...options.headers
1749
2025
  }
1750
2026
  });
1751
2027
  }
1752
2028
  /**
1753
- * Update user profile
2029
+ * Verify TOTP code for 2FA session.
1754
2030
  *
1755
- * Update the current authenticated user's profile information.
2031
+ * Completes authentication and returns JWT tokens on success.
1756
2032
  */
1757
- static cfgAccountsProfileUpdateUpdate(options) {
1758
- return (options?.client ?? client).put({
1759
- security: [{ scheme: "bearer", type: "http" }, {
1760
- in: "cookie",
1761
- name: "sessionid",
1762
- type: "apiKey"
1763
- }],
1764
- url: "/cfg/accounts/profile/update/",
2033
+ static cfgTotpVerifyCreate(options) {
2034
+ return (options.client ?? client).post({
2035
+ security: [{ scheme: "bearer", type: "http" }],
2036
+ url: "/cfg/totp/verify/",
1765
2037
  ...options,
1766
2038
  headers: {
1767
2039
  "Content-Type": "application/json",
1768
- ...options?.headers
2040
+ ...options.headers
1769
2041
  }
1770
2042
  });
1771
2043
  }
1772
2044
  /**
1773
- * Refresh JWT token.
2045
+ * Verify backup recovery code for 2FA session.
2046
+ *
2047
+ * Alternative verification method when TOTP device unavailable.
1774
2048
  */
1775
- static cfgAccountsTokenRefreshCreate(options) {
2049
+ static cfgTotpVerifyBackupCreate(options) {
1776
2050
  return (options.client ?? client).post({
1777
- url: "/cfg/accounts/token/refresh/",
2051
+ security: [{ scheme: "bearer", type: "http" }],
2052
+ url: "/cfg/totp/verify/backup/",
1778
2053
  ...options,
1779
2054
  headers: {
1780
2055
  "Content-Type": "application/json",
@@ -1997,2504 +2272,17 @@ var UserProfile = class {
1997
2272
  }
1998
2273
  });
1999
2274
  }
2000
- };
2001
- var Auth = class {
2002
- static {
2003
- __name(this, "Auth");
2004
- }
2005
- /**
2006
- * Refresh JWT token.
2007
- */
2008
- static cfgAccountsTokenRefreshCreate(options) {
2009
- return (options.client ?? client).post({
2010
- url: "/cfg/accounts/token/refresh/",
2011
- ...options,
2012
- headers: {
2013
- "Content-Type": "application/json",
2014
- ...options.headers
2015
- }
2016
- });
2017
- }
2018
- };
2019
-
2020
- // src/_api/generated/cfg_accounts/schemas/AccountDeleteResponse.ts
2021
- var import_zod = require("zod");
2022
- var AccountDeleteResponseSchema = import_zod.z.object({
2023
- success: import_zod.z.boolean(),
2024
- message: import_zod.z.string()
2025
- });
2026
-
2027
- // src/_api/generated/cfg_accounts/schemas/CentrifugoToken.ts
2028
- var import_zod2 = require("zod");
2029
- var CentrifugoTokenSchema = import_zod2.z.object({
2030
- token: import_zod2.z.string(),
2031
- centrifugo_url: import_zod2.z.string(),
2032
- expires_at: import_zod2.z.string().datetime({ offset: true }),
2033
- channels: import_zod2.z.array(import_zod2.z.string())
2034
- });
2035
-
2036
- // src/_api/generated/cfg_accounts/schemas/CfgUserUpdateRequest.ts
2037
- var import_zod3 = require("zod");
2038
- var CfgUserUpdateRequestSchema = import_zod3.z.object({
2039
- first_name: import_zod3.z.string().max(50).optional(),
2040
- last_name: import_zod3.z.string().max(50).optional(),
2041
- company: import_zod3.z.string().max(100).optional(),
2042
- phone: import_zod3.z.string().max(20).optional(),
2043
- position: import_zod3.z.string().max(100).optional(),
2044
- language: import_zod3.z.string().max(10).optional()
2045
- });
2046
-
2047
- // src/_api/generated/cfg_accounts/schemas/OAuthAuthorizeRequestRequest.ts
2048
- var import_zod4 = require("zod");
2049
- var OAuthAuthorizeRequestRequestSchema = import_zod4.z.object({
2050
- redirect_uri: import_zod4.z.string().optional(),
2051
- source_url: import_zod4.z.string().optional()
2052
- });
2053
-
2054
- // src/_api/generated/cfg_accounts/schemas/OAuthAuthorizeResponse.ts
2055
- var import_zod5 = require("zod");
2056
- var OAuthAuthorizeResponseSchema = import_zod5.z.object({
2057
- authorization_url: import_zod5.z.string(),
2058
- state: import_zod5.z.string()
2059
- });
2060
-
2061
- // src/_api/generated/cfg_accounts/schemas/OAuthCallbackRequestRequest.ts
2062
- var import_zod6 = require("zod");
2063
- var OAuthCallbackRequestRequestSchema = import_zod6.z.object({
2064
- code: import_zod6.z.string().min(10).max(500),
2065
- state: import_zod6.z.string().min(20).max(100),
2066
- redirect_uri: import_zod6.z.string().optional()
2067
- });
2068
-
2069
- // src/_api/generated/cfg_accounts/schemas/OAuthConnection.ts
2070
- var import_zod8 = require("zod");
2071
-
2072
- // src/_api/generated/cfg_accounts/schemas/ProviderEnum.ts
2073
- var import_zod7 = require("zod");
2074
- var ProviderEnumSchema = import_zod7.z.enum(["github"]);
2075
-
2076
- // src/_api/generated/cfg_accounts/schemas/OAuthConnection.ts
2077
- var OAuthConnectionSchema = import_zod8.z.object({
2078
- id: import_zod8.z.number().int(),
2079
- provider: ProviderEnumSchema,
2080
- provider_display: import_zod8.z.string(),
2081
- provider_username: import_zod8.z.string(),
2082
- provider_email: import_zod8.z.email(),
2083
- provider_avatar_url: import_zod8.z.string(),
2084
- connected_at: import_zod8.z.string().datetime({ offset: true }),
2085
- last_login_at: import_zod8.z.string().datetime({ offset: true })
2086
- });
2087
-
2088
- // src/_api/generated/cfg_accounts/schemas/OAuthDisconnectRequestRequest.ts
2089
- var import_zod9 = require("zod");
2090
- var OAuthDisconnectRequestRequestSchema = import_zod9.z.object({
2091
- provider: ProviderEnumSchema
2092
- });
2093
-
2094
- // src/_api/generated/cfg_accounts/schemas/OAuthError.ts
2095
- var import_zod10 = require("zod");
2096
- var OAuthErrorSchema = import_zod10.z.object({
2097
- error: import_zod10.z.string(),
2098
- error_description: import_zod10.z.string().optional()
2099
- });
2100
-
2101
- // src/_api/generated/cfg_accounts/schemas/OAuthProvidersResponse.ts
2102
- var import_zod11 = require("zod");
2103
- var OAuthProvidersResponseSchema = import_zod11.z.object({
2104
- providers: import_zod11.z.array(import_zod11.z.object({}))
2105
- });
2106
-
2107
- // src/_api/generated/cfg_accounts/schemas/OAuthTokenResponse.ts
2108
- var import_zod12 = require("zod");
2109
- var OAuthTokenResponseSchema = import_zod12.z.object({
2110
- requires_2fa: import_zod12.z.boolean().optional(),
2111
- session_id: import_zod12.z.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(),
2112
- access: import_zod12.z.string().nullable().optional(),
2113
- refresh: import_zod12.z.string().nullable().optional(),
2114
- user: import_zod12.z.object({}).nullable().optional(),
2115
- is_new_user: import_zod12.z.boolean(),
2116
- is_new_connection: import_zod12.z.boolean(),
2117
- should_prompt_2fa: import_zod12.z.boolean().optional()
2118
- });
2119
-
2120
- // src/_api/generated/cfg_accounts/schemas/OTPErrorResponse.ts
2121
- var import_zod13 = require("zod");
2122
- var OTPErrorResponseSchema = import_zod13.z.object({
2123
- error: import_zod13.z.string(),
2124
- error_code: import_zod13.z.string().nullable().optional(),
2125
- retry_after: import_zod13.z.number().int().nullable().optional()
2126
- });
2127
-
2128
- // src/_api/generated/cfg_accounts/schemas/OTPRequestRequest.ts
2129
- var import_zod14 = require("zod");
2130
- var OTPRequestRequestSchema = import_zod14.z.object({
2131
- identifier: import_zod14.z.string().min(1),
2132
- source_url: import_zod14.z.string().optional()
2133
- });
2134
-
2135
- // src/_api/generated/cfg_accounts/schemas/OTPRequestResponse.ts
2136
- var import_zod15 = require("zod");
2137
- var OTPRequestResponseSchema = import_zod15.z.object({
2138
- message: import_zod15.z.string()
2139
- });
2140
-
2141
- // src/_api/generated/cfg_accounts/schemas/OTPVerifyRequest.ts
2142
- var import_zod16 = require("zod");
2143
- var OTPVerifyRequestSchema = import_zod16.z.object({
2144
- identifier: import_zod16.z.string().min(1),
2145
- otp: import_zod16.z.string().min(6).max(6),
2146
- source_url: import_zod16.z.string().optional()
2147
- });
2148
-
2149
- // src/_api/generated/cfg_accounts/schemas/OTPVerifyResponse.ts
2150
- var import_zod18 = require("zod");
2151
-
2152
- // src/_api/generated/cfg_accounts/schemas/User.ts
2153
- var import_zod17 = require("zod");
2154
- var UserSchema = import_zod17.z.object({
2155
- id: import_zod17.z.number().int(),
2156
- email: import_zod17.z.email(),
2157
- first_name: import_zod17.z.string().max(50).optional(),
2158
- last_name: import_zod17.z.string().max(50).optional(),
2159
- full_name: import_zod17.z.string(),
2160
- initials: import_zod17.z.string(),
2161
- display_username: import_zod17.z.string(),
2162
- company: import_zod17.z.string().max(100).optional(),
2163
- phone: import_zod17.z.string().max(20).optional(),
2164
- position: import_zod17.z.string().max(100).optional(),
2165
- language: import_zod17.z.string().max(10).optional(),
2166
- avatar: import_zod17.z.string().nullable(),
2167
- is_staff: import_zod17.z.boolean(),
2168
- is_superuser: import_zod17.z.boolean(),
2169
- date_joined: import_zod17.z.string().datetime({ offset: true }),
2170
- last_login: import_zod17.z.string().datetime({ offset: true }).nullable(),
2171
- unanswered_messages_count: import_zod17.z.number().int(),
2172
- centrifugo: CentrifugoTokenSchema.nullable()
2173
- });
2174
-
2175
- // src/_api/generated/cfg_accounts/schemas/OTPVerifyResponse.ts
2176
- var OTPVerifyResponseSchema = import_zod18.z.object({
2177
- requires_2fa: import_zod18.z.boolean().optional(),
2178
- session_id: import_zod18.z.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(),
2179
- refresh: import_zod18.z.string().nullable().optional(),
2180
- access: import_zod18.z.string().nullable().optional(),
2181
- user: UserSchema.nullable().optional(),
2182
- should_prompt_2fa: import_zod18.z.boolean().optional()
2183
- });
2184
-
2185
- // src/_api/generated/cfg_accounts/schemas/PatchedCfgUserUpdateRequest.ts
2186
- var import_zod19 = require("zod");
2187
- var PatchedCfgUserUpdateRequestSchema = import_zod19.z.object({
2188
- first_name: import_zod19.z.string().max(50).optional(),
2189
- last_name: import_zod19.z.string().max(50).optional(),
2190
- company: import_zod19.z.string().max(100).optional(),
2191
- phone: import_zod19.z.string().max(20).optional(),
2192
- position: import_zod19.z.string().max(100).optional(),
2193
- language: import_zod19.z.string().max(10).optional()
2194
- });
2195
-
2196
- // src/_api/generated/cfg_accounts/schemas/TokenRefresh.ts
2197
- var import_zod20 = require("zod");
2198
- var TokenRefreshSchema = import_zod20.z.object({
2199
- access: import_zod20.z.string(),
2200
- refresh: import_zod20.z.string()
2201
- });
2202
-
2203
- // src/_api/generated/cfg_accounts/schemas/TokenRefreshRequest.ts
2204
- var import_zod21 = require("zod");
2205
- var TokenRefreshRequestSchema = import_zod21.z.object({
2206
- refresh: import_zod21.z.string().min(1)
2207
- });
2208
-
2209
- // src/_api/generated/_shared/validation-events.ts
2210
- function dispatchValidationError(detail) {
2211
- if (typeof window === "undefined") return;
2212
- try {
2213
- const event = new CustomEvent("zod-validation-error", {
2214
- detail,
2215
- bubbles: true,
2216
- cancelable: false
2217
- });
2218
- window.dispatchEvent(event);
2219
- } catch (error) {
2220
- console.warn("Failed to dispatch validation error event:", error);
2221
- }
2222
- }
2223
- __name(dispatchValidationError, "dispatchValidationError");
2224
-
2225
- // src/_api/generated/cfg_accounts/api.ts
2226
- var ACCESS_KEY = "cfg.access_token";
2227
- var REFRESH_KEY = "cfg.refresh_token";
2228
- var VALIDATION_ROUTES = [
2229
- { method: "POST", re: new RegExp("^/cfg/accounts/oauth/github/authorize/?$"), schema: OAuthAuthorizeResponseSchema, path: "/cfg/accounts/oauth/github/authorize/" },
2230
- { method: "POST", re: new RegExp("^/cfg/accounts/oauth/github/callback/?$"), schema: OAuthTokenResponseSchema, path: "/cfg/accounts/oauth/github/callback/" },
2231
- { method: "GET", re: new RegExp("^/cfg/accounts/oauth/providers/?$"), schema: OAuthProvidersResponseSchema, path: "/cfg/accounts/oauth/providers/" },
2232
- { method: "POST", re: new RegExp("^/cfg/accounts/otp/request/?$"), schema: OTPRequestResponseSchema, path: "/cfg/accounts/otp/request/" },
2233
- { method: "POST", re: new RegExp("^/cfg/accounts/otp/verify/?$"), schema: OTPVerifyResponseSchema, path: "/cfg/accounts/otp/verify/" },
2234
- { method: "GET", re: new RegExp("^/cfg/accounts/profile/?$"), schema: UserSchema, path: "/cfg/accounts/profile/" },
2235
- { method: "POST", re: new RegExp("^/cfg/accounts/profile/avatar/?$"), schema: UserSchema, path: "/cfg/accounts/profile/avatar/" },
2236
- { method: "POST", re: new RegExp("^/cfg/accounts/profile/delete/?$"), schema: AccountDeleteResponseSchema, path: "/cfg/accounts/profile/delete/" },
2237
- { method: "PUT", re: new RegExp("^/cfg/accounts/profile/partial/?$"), schema: UserSchema, path: "/cfg/accounts/profile/partial/" },
2238
- { method: "PATCH", re: new RegExp("^/cfg/accounts/profile/partial/?$"), schema: UserSchema, path: "/cfg/accounts/profile/partial/" },
2239
- { method: "PUT", re: new RegExp("^/cfg/accounts/profile/update/?$"), schema: UserSchema, path: "/cfg/accounts/profile/update/" },
2240
- { method: "PATCH", re: new RegExp("^/cfg/accounts/profile/update/?$"), schema: UserSchema, path: "/cfg/accounts/profile/update/" },
2241
- { method: "POST", re: new RegExp("^/cfg/accounts/token/refresh/?$"), schema: TokenRefreshSchema, path: "/cfg/accounts/token/refresh/" }
2242
- ];
2243
- function detectLocale() {
2244
- try {
2245
- if (typeof document !== "undefined") {
2246
- const m = document.cookie.match(/(?:^|;\s*)NEXT_LOCALE=([^;]*)/);
2247
- if (m) return decodeURIComponent(m[1]);
2248
- }
2249
- if (typeof navigator !== "undefined" && navigator.language) {
2250
- return navigator.language;
2251
- }
2252
- } catch {
2253
- }
2254
- return null;
2255
- }
2256
- __name(detectLocale, "detectLocale");
2257
- var API = class {
2258
- static {
2259
- __name(this, "API");
2260
- }
2261
- baseUrl;
2262
- storage;
2263
- locale;
2264
- apiKey;
2265
- logger;
2266
- cfg = Cfg;
2267
- accounts = Accounts;
2268
- oAuth = OAuth;
2269
- userProfile = UserProfile;
2270
- auth = Auth;
2271
- constructor(baseUrl2, opts = {}) {
2272
- this.baseUrl = baseUrl2.replace(/\/$/, "");
2273
- this.storage = opts.storage ?? new LocalStorageAdapter();
2274
- this.logger = new APILogger(opts.logger);
2275
- this.locale = opts.locale ?? null;
2276
- this.apiKey = opts.apiKey ?? (typeof process !== "undefined" ? process.env?.NEXT_PUBLIC_API_KEY ?? null : null);
2277
- const credentials = opts.withCredentials ?? true ? "include" : "same-origin";
2278
- client.setConfig({ baseUrl: this.baseUrl, credentials });
2279
- client.interceptors.request.use((request) => {
2280
- const access = this.getToken();
2281
- if (access) request.headers.set("Authorization", `Bearer ${access}`);
2282
- const locale = this.locale ?? detectLocale();
2283
- if (locale) request.headers.set("Accept-Language", locale);
2284
- if (this.apiKey) request.headers.set("X-API-Key", this.apiKey);
2285
- return request;
2286
- });
2287
- client.interceptors.response.use(async (response, request) => {
2288
- if (!response.ok) return response;
2289
- const ct = response.headers.get("content-type") || "";
2290
- if (!ct.includes("application/json")) return response;
2291
- const url = new URL(request.url);
2292
- const method = request.method.toUpperCase();
2293
- const route = VALIDATION_ROUTES.find(
2294
- (r) => r.method === method && r.re.test(url.pathname)
2295
- );
2296
- if (!route) return response;
2297
- let payload;
2298
- try {
2299
- payload = await response.clone().json();
2300
- } catch {
2301
- return response;
2302
- }
2303
- const result = route.schema.safeParse(payload);
2304
- if (!result.success) {
2305
- dispatchValidationError({
2306
- operation: `${method} ${route.path}`,
2307
- path: route.path,
2308
- method,
2309
- error: result.error,
2310
- response: payload,
2311
- timestamp: /* @__PURE__ */ new Date()
2312
- });
2313
- }
2314
- return response;
2315
- });
2316
- }
2317
- // ── Base URL ────────────────────────────────────────────────────────────
2318
- getBaseUrl() {
2319
- return this.baseUrl;
2320
- }
2321
- setBaseUrl(url) {
2322
- this.baseUrl = url.replace(/\/$/, "");
2323
- client.setConfig({ baseUrl: this.baseUrl });
2324
- }
2325
- // ── Tokens ──────────────────────────────────────────────────────────────
2326
- getToken() {
2327
- return this.storage.getItem(ACCESS_KEY);
2328
- }
2329
- setToken(token) {
2330
- if (token) this.storage.setItem(ACCESS_KEY, token);
2331
- else this.storage.removeItem(ACCESS_KEY);
2332
- }
2333
- getRefreshToken() {
2334
- return this.storage.getItem(REFRESH_KEY);
2335
- }
2336
- setRefreshToken(token) {
2337
- if (token) this.storage.setItem(REFRESH_KEY, token);
2338
- else this.storage.removeItem(REFRESH_KEY);
2339
- }
2340
- clearToken() {
2341
- this.storage.removeItem(ACCESS_KEY);
2342
- this.storage.removeItem(REFRESH_KEY);
2343
- }
2344
- isAuthenticated() {
2345
- return this.getToken() !== null;
2346
- }
2347
- // ── Locale / API key ────────────────────────────────────────────────────
2348
- getLocale() {
2349
- return this.locale ?? detectLocale();
2350
- }
2351
- setLocale(locale) {
2352
- this.locale = locale;
2353
- }
2354
- getApiKey() {
2355
- return this.apiKey;
2356
- }
2357
- setApiKey(key) {
2358
- this.apiKey = key;
2359
- }
2360
- };
2361
-
2362
- // src/_api/generated/_shared/errors.ts
2363
- var APIError = class extends Error {
2364
- constructor(statusCode, statusText, response, url, message) {
2365
- super(message || `HTTP ${statusCode}: ${statusText}`);
2366
- this.statusCode = statusCode;
2367
- this.statusText = statusText;
2368
- this.response = response;
2369
- this.url = url;
2370
- this.name = "APIError";
2371
- }
2372
- static {
2373
- __name(this, "APIError");
2374
- }
2375
- get details() {
2376
- if (typeof this.response === "object" && this.response !== null) {
2377
- return this.response;
2378
- }
2379
- return null;
2380
- }
2381
- get fieldErrors() {
2382
- const details = this.details;
2383
- if (!details) return null;
2384
- const fieldErrors = {};
2385
- for (const [key, value] of Object.entries(details)) {
2386
- if (Array.isArray(value)) fieldErrors[key] = value;
2387
- }
2388
- return Object.keys(fieldErrors).length > 0 ? fieldErrors : null;
2389
- }
2390
- get errorMessage() {
2391
- const details = this.details;
2392
- if (!details) return this.message;
2393
- if (details.detail) {
2394
- return Array.isArray(details.detail) ? details.detail.join(", ") : String(details.detail);
2395
- }
2396
- if (details.error) return String(details.error);
2397
- if (details.message) return String(details.message);
2398
- const fieldErrors = this.fieldErrors;
2399
- if (fieldErrors) {
2400
- const firstField = Object.keys(fieldErrors)[0];
2401
- if (firstField) return `${firstField}: ${fieldErrors[firstField]?.join(", ")}`;
2402
- }
2403
- return this.message;
2404
- }
2405
- get isValidationError() {
2406
- return this.statusCode === 400;
2407
- }
2408
- get isAuthError() {
2409
- return this.statusCode === 401;
2410
- }
2411
- get isPermissionError() {
2412
- return this.statusCode === 403;
2413
- }
2414
- get isNotFoundError() {
2415
- return this.statusCode === 404;
2416
- }
2417
- get isServerError() {
2418
- return this.statusCode >= 500 && this.statusCode < 600;
2419
- }
2420
- };
2421
-
2422
- // src/_api/generated/cfg_centrifugo/core/bodySerializer.gen.ts
2423
- var jsonBodySerializer2 = {
2424
- bodySerializer: /* @__PURE__ */ __name((body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value), "bodySerializer")
2425
- };
2426
-
2427
- // src/_api/generated/cfg_centrifugo/core/params.gen.ts
2428
- var extraPrefixesMap2 = {
2429
- $body_: "body",
2430
- $headers_: "headers",
2431
- $path_: "path",
2432
- $query_: "query"
2433
- };
2434
- var extraPrefixes2 = Object.entries(extraPrefixesMap2);
2435
-
2436
- // src/_api/generated/cfg_centrifugo/core/serverSentEvents.gen.ts
2437
- function createSseClient2({
2438
- onRequest,
2439
- onSseError,
2440
- onSseEvent,
2441
- responseTransformer,
2442
- responseValidator,
2443
- sseDefaultRetryDelay,
2444
- sseMaxRetryAttempts,
2445
- sseMaxRetryDelay,
2446
- sseSleepFn,
2447
- url,
2448
- ...options
2449
- }) {
2450
- let lastEventId;
2451
- const sleep = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
2452
- const createStream = /* @__PURE__ */ __name(async function* () {
2453
- let retryDelay = sseDefaultRetryDelay ?? 3e3;
2454
- let attempt = 0;
2455
- const signal = options.signal ?? new AbortController().signal;
2456
- while (true) {
2457
- if (signal.aborted) break;
2458
- attempt++;
2459
- const headers = options.headers instanceof Headers ? options.headers : new Headers(options.headers);
2460
- if (lastEventId !== void 0) {
2461
- headers.set("Last-Event-ID", lastEventId);
2462
- }
2463
- try {
2464
- const requestInit = {
2465
- redirect: "follow",
2466
- ...options,
2467
- body: options.serializedBody,
2468
- headers,
2469
- signal
2470
- };
2471
- let request = new Request(url, requestInit);
2472
- if (onRequest) {
2473
- request = await onRequest(url, requestInit);
2474
- }
2475
- const _fetch = options.fetch ?? globalThis.fetch;
2476
- const response = await _fetch(request);
2477
- if (!response.ok) throw new Error(`SSE failed: ${response.status} ${response.statusText}`);
2478
- if (!response.body) throw new Error("No body in SSE response");
2479
- const reader = response.body.pipeThrough(new TextDecoderStream()).getReader();
2480
- let buffer = "";
2481
- const abortHandler = /* @__PURE__ */ __name(() => {
2482
- try {
2483
- reader.cancel();
2484
- } catch {
2485
- }
2486
- }, "abortHandler");
2487
- signal.addEventListener("abort", abortHandler);
2488
- try {
2489
- while (true) {
2490
- const { done, value } = await reader.read();
2491
- if (done) break;
2492
- buffer += value;
2493
- buffer = buffer.replace(/\r\n?/g, "\n");
2494
- const chunks = buffer.split("\n\n");
2495
- buffer = chunks.pop() ?? "";
2496
- for (const chunk of chunks) {
2497
- const lines = chunk.split("\n");
2498
- const dataLines = [];
2499
- let eventName;
2500
- for (const line of lines) {
2501
- if (line.startsWith("data:")) {
2502
- dataLines.push(line.replace(/^data:\s*/, ""));
2503
- } else if (line.startsWith("event:")) {
2504
- eventName = line.replace(/^event:\s*/, "");
2505
- } else if (line.startsWith("id:")) {
2506
- lastEventId = line.replace(/^id:\s*/, "");
2507
- } else if (line.startsWith("retry:")) {
2508
- const parsed = Number.parseInt(line.replace(/^retry:\s*/, ""), 10);
2509
- if (!Number.isNaN(parsed)) {
2510
- retryDelay = parsed;
2511
- }
2512
- }
2513
- }
2514
- let data;
2515
- let parsedJson = false;
2516
- if (dataLines.length) {
2517
- const rawData = dataLines.join("\n");
2518
- try {
2519
- data = JSON.parse(rawData);
2520
- parsedJson = true;
2521
- } catch {
2522
- data = rawData;
2523
- }
2524
- }
2525
- if (parsedJson) {
2526
- if (responseValidator) {
2527
- await responseValidator(data);
2528
- }
2529
- if (responseTransformer) {
2530
- data = await responseTransformer(data);
2531
- }
2532
- }
2533
- onSseEvent?.({
2534
- data,
2535
- event: eventName,
2536
- id: lastEventId,
2537
- retry: retryDelay
2538
- });
2539
- if (dataLines.length) {
2540
- yield data;
2541
- }
2542
- }
2543
- }
2544
- } finally {
2545
- signal.removeEventListener("abort", abortHandler);
2546
- reader.releaseLock();
2547
- }
2548
- break;
2549
- } catch (error) {
2550
- onSseError?.(error);
2551
- if (sseMaxRetryAttempts !== void 0 && attempt >= sseMaxRetryAttempts) {
2552
- break;
2553
- }
2554
- const backoff = Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 3e4);
2555
- await sleep(backoff);
2556
- }
2557
- }
2558
- }, "createStream");
2559
- const stream = createStream();
2560
- return { stream };
2561
- }
2562
- __name(createSseClient2, "createSseClient");
2563
-
2564
- // src/_api/generated/cfg_centrifugo/core/pathSerializer.gen.ts
2565
- var separatorArrayExplode2 = /* @__PURE__ */ __name((style) => {
2566
- switch (style) {
2567
- case "label":
2568
- return ".";
2569
- case "matrix":
2570
- return ";";
2571
- case "simple":
2572
- return ",";
2573
- default:
2574
- return "&";
2575
- }
2576
- }, "separatorArrayExplode");
2577
- var separatorArrayNoExplode2 = /* @__PURE__ */ __name((style) => {
2578
- switch (style) {
2579
- case "form":
2580
- return ",";
2581
- case "pipeDelimited":
2582
- return "|";
2583
- case "spaceDelimited":
2584
- return "%20";
2585
- default:
2586
- return ",";
2587
- }
2588
- }, "separatorArrayNoExplode");
2589
- var separatorObjectExplode2 = /* @__PURE__ */ __name((style) => {
2590
- switch (style) {
2591
- case "label":
2592
- return ".";
2593
- case "matrix":
2594
- return ";";
2595
- case "simple":
2596
- return ",";
2597
- default:
2598
- return "&";
2599
- }
2600
- }, "separatorObjectExplode");
2601
- var serializeArrayParam2 = /* @__PURE__ */ __name(({
2602
- allowReserved,
2603
- explode,
2604
- name,
2605
- style,
2606
- value
2607
- }) => {
2608
- if (!explode) {
2609
- const joinedValues2 = (allowReserved ? value : value.map((v) => encodeURIComponent(v))).join(separatorArrayNoExplode2(style));
2610
- switch (style) {
2611
- case "label":
2612
- return `.${joinedValues2}`;
2613
- case "matrix":
2614
- return `;${name}=${joinedValues2}`;
2615
- case "simple":
2616
- return joinedValues2;
2617
- default:
2618
- return `${name}=${joinedValues2}`;
2619
- }
2620
- }
2621
- const separator = separatorArrayExplode2(style);
2622
- const joinedValues = value.map((v) => {
2623
- if (style === "label" || style === "simple") {
2624
- return allowReserved ? v : encodeURIComponent(v);
2625
- }
2626
- return serializePrimitiveParam2({
2627
- allowReserved,
2628
- name,
2629
- value: v
2630
- });
2631
- }).join(separator);
2632
- return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
2633
- }, "serializeArrayParam");
2634
- var serializePrimitiveParam2 = /* @__PURE__ */ __name(({
2635
- allowReserved,
2636
- name,
2637
- value
2638
- }) => {
2639
- if (value === void 0 || value === null) {
2640
- return "";
2641
- }
2642
- if (typeof value === "object") {
2643
- throw new Error(
2644
- "Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these."
2645
- );
2646
- }
2647
- return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
2648
- }, "serializePrimitiveParam");
2649
- var serializeObjectParam2 = /* @__PURE__ */ __name(({
2650
- allowReserved,
2651
- explode,
2652
- name,
2653
- style,
2654
- value,
2655
- valueOnly
2656
- }) => {
2657
- if (value instanceof Date) {
2658
- return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
2659
- }
2660
- if (style !== "deepObject" && !explode) {
2661
- let values = [];
2662
- Object.entries(value).forEach(([key, v]) => {
2663
- values = [...values, key, allowReserved ? v : encodeURIComponent(v)];
2664
- });
2665
- const joinedValues2 = values.join(",");
2666
- switch (style) {
2667
- case "form":
2668
- return `${name}=${joinedValues2}`;
2669
- case "label":
2670
- return `.${joinedValues2}`;
2671
- case "matrix":
2672
- return `;${name}=${joinedValues2}`;
2673
- default:
2674
- return joinedValues2;
2675
- }
2676
- }
2677
- const separator = separatorObjectExplode2(style);
2678
- const joinedValues = Object.entries(value).map(
2679
- ([key, v]) => serializePrimitiveParam2({
2680
- allowReserved,
2681
- name: style === "deepObject" ? `${name}[${key}]` : key,
2682
- value: v
2683
- })
2684
- ).join(separator);
2685
- return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
2686
- }, "serializeObjectParam");
2687
-
2688
- // src/_api/generated/cfg_centrifugo/core/utils.gen.ts
2689
- var PATH_PARAM_RE2 = /\{[^{}]+\}/g;
2690
- var defaultPathSerializer2 = /* @__PURE__ */ __name(({ path, url: _url }) => {
2691
- let url = _url;
2692
- const matches = _url.match(PATH_PARAM_RE2);
2693
- if (matches) {
2694
- for (const match of matches) {
2695
- let explode = false;
2696
- let name = match.substring(1, match.length - 1);
2697
- let style = "simple";
2698
- if (name.endsWith("*")) {
2699
- explode = true;
2700
- name = name.substring(0, name.length - 1);
2701
- }
2702
- if (name.startsWith(".")) {
2703
- name = name.substring(1);
2704
- style = "label";
2705
- } else if (name.startsWith(";")) {
2706
- name = name.substring(1);
2707
- style = "matrix";
2708
- }
2709
- const value = path[name];
2710
- if (value === void 0 || value === null) {
2711
- continue;
2712
- }
2713
- if (Array.isArray(value)) {
2714
- url = url.replace(match, serializeArrayParam2({ explode, name, style, value }));
2715
- continue;
2716
- }
2717
- if (typeof value === "object") {
2718
- url = url.replace(
2719
- match,
2720
- serializeObjectParam2({
2721
- explode,
2722
- name,
2723
- style,
2724
- value,
2725
- valueOnly: true
2726
- })
2727
- );
2728
- continue;
2729
- }
2730
- if (style === "matrix") {
2731
- url = url.replace(
2732
- match,
2733
- `;${serializePrimitiveParam2({
2734
- name,
2735
- value
2736
- })}`
2737
- );
2738
- continue;
2739
- }
2740
- const replaceValue = encodeURIComponent(
2741
- style === "label" ? `.${value}` : value
2742
- );
2743
- url = url.replace(match, replaceValue);
2744
- }
2745
- }
2746
- return url;
2747
- }, "defaultPathSerializer");
2748
- var getUrl2 = /* @__PURE__ */ __name(({
2749
- baseUrl: baseUrl2,
2750
- path,
2751
- query,
2752
- querySerializer,
2753
- url: _url
2754
- }) => {
2755
- const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
2756
- let url = (baseUrl2 ?? "") + pathUrl;
2757
- if (path) {
2758
- url = defaultPathSerializer2({ path, url });
2759
- }
2760
- let search = query ? querySerializer(query) : "";
2761
- if (search.startsWith("?")) {
2762
- search = search.substring(1);
2763
- }
2764
- if (search) {
2765
- url += `?${search}`;
2766
- }
2767
- return url;
2768
- }, "getUrl");
2769
- function getValidRequestBody2(options) {
2770
- const hasBody = options.body !== void 0;
2771
- const isSerializedBody = hasBody && options.bodySerializer;
2772
- if (isSerializedBody) {
2773
- if ("serializedBody" in options) {
2774
- const hasSerializedBody = options.serializedBody !== void 0 && options.serializedBody !== "";
2775
- return hasSerializedBody ? options.serializedBody : null;
2776
- }
2777
- return options.body !== "" ? options.body : null;
2778
- }
2779
- if (hasBody) {
2780
- return options.body;
2781
- }
2782
- return void 0;
2783
- }
2784
- __name(getValidRequestBody2, "getValidRequestBody");
2785
-
2786
- // src/_api/generated/cfg_centrifugo/core/auth.gen.ts
2787
- var getAuthToken2 = /* @__PURE__ */ __name(async (auth, callback) => {
2788
- const token = typeof callback === "function" ? await callback(auth) : callback;
2789
- if (!token) {
2790
- return;
2791
- }
2792
- if (auth.scheme === "bearer") {
2793
- return `Bearer ${token}`;
2794
- }
2795
- if (auth.scheme === "basic") {
2796
- return `Basic ${btoa(token)}`;
2797
- }
2798
- return token;
2799
- }, "getAuthToken");
2800
-
2801
- // src/_api/generated/cfg_centrifugo/client/utils.gen.ts
2802
- var createQuerySerializer2 = /* @__PURE__ */ __name(({
2803
- parameters = {},
2804
- ...args
2805
- } = {}) => {
2806
- const querySerializer = /* @__PURE__ */ __name((queryParams) => {
2807
- const search = [];
2808
- if (queryParams && typeof queryParams === "object") {
2809
- for (const name in queryParams) {
2810
- const value = queryParams[name];
2811
- if (value === void 0 || value === null) {
2812
- continue;
2813
- }
2814
- const options = parameters[name] || args;
2815
- if (Array.isArray(value)) {
2816
- const serializedArray = serializeArrayParam2({
2817
- allowReserved: options.allowReserved,
2818
- explode: true,
2819
- name,
2820
- style: "form",
2821
- value,
2822
- ...options.array
2823
- });
2824
- if (serializedArray) search.push(serializedArray);
2825
- } else if (typeof value === "object") {
2826
- const serializedObject = serializeObjectParam2({
2827
- allowReserved: options.allowReserved,
2828
- explode: true,
2829
- name,
2830
- style: "deepObject",
2831
- value,
2832
- ...options.object
2833
- });
2834
- if (serializedObject) search.push(serializedObject);
2835
- } else {
2836
- const serializedPrimitive = serializePrimitiveParam2({
2837
- allowReserved: options.allowReserved,
2838
- name,
2839
- value
2840
- });
2841
- if (serializedPrimitive) search.push(serializedPrimitive);
2842
- }
2843
- }
2844
- }
2845
- return search.join("&");
2846
- }, "querySerializer");
2847
- return querySerializer;
2848
- }, "createQuerySerializer");
2849
- var getParseAs2 = /* @__PURE__ */ __name((contentType) => {
2850
- if (!contentType) {
2851
- return "stream";
2852
- }
2853
- const cleanContent = contentType.split(";")[0]?.trim();
2854
- if (!cleanContent) {
2855
- return;
2856
- }
2857
- if (cleanContent.startsWith("application/json") || cleanContent.endsWith("+json")) {
2858
- return "json";
2859
- }
2860
- if (cleanContent === "multipart/form-data") {
2861
- return "formData";
2862
- }
2863
- if (["application/", "audio/", "image/", "video/"].some((type) => cleanContent.startsWith(type))) {
2864
- return "blob";
2865
- }
2866
- if (cleanContent.startsWith("text/")) {
2867
- return "text";
2868
- }
2869
- return;
2870
- }, "getParseAs");
2871
- var checkForExistence2 = /* @__PURE__ */ __name((options, name) => {
2872
- if (!name) {
2873
- return false;
2874
- }
2875
- if (options.headers.has(name) || options.query?.[name] || options.headers.get("Cookie")?.includes(`${name}=`)) {
2876
- return true;
2877
- }
2878
- return false;
2879
- }, "checkForExistence");
2880
- var setAuthParams2 = /* @__PURE__ */ __name(async ({
2881
- security,
2882
- ...options
2883
- }) => {
2884
- for (const auth of security) {
2885
- if (checkForExistence2(options, auth.name)) {
2886
- continue;
2887
- }
2888
- const token = await getAuthToken2(auth, options.auth);
2889
- if (!token) {
2890
- continue;
2891
- }
2892
- const name = auth.name ?? "Authorization";
2893
- switch (auth.in) {
2894
- case "query":
2895
- if (!options.query) {
2896
- options.query = {};
2897
- }
2898
- options.query[name] = token;
2899
- break;
2900
- case "cookie":
2901
- options.headers.append("Cookie", `${name}=${token}`);
2902
- break;
2903
- case "header":
2904
- default:
2905
- options.headers.set(name, token);
2906
- break;
2907
- }
2908
- }
2909
- }, "setAuthParams");
2910
- var buildUrl2 = /* @__PURE__ */ __name((options) => getUrl2({
2911
- baseUrl: options.baseUrl,
2912
- path: options.path,
2913
- query: options.query,
2914
- querySerializer: typeof options.querySerializer === "function" ? options.querySerializer : createQuerySerializer2(options.querySerializer),
2915
- url: options.url
2916
- }), "buildUrl");
2917
- var mergeConfigs2 = /* @__PURE__ */ __name((a, b) => {
2918
- const config = { ...a, ...b };
2919
- if (config.baseUrl?.endsWith("/")) {
2920
- config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
2921
- }
2922
- config.headers = mergeHeaders2(a.headers, b.headers);
2923
- return config;
2924
- }, "mergeConfigs");
2925
- var headersEntries2 = /* @__PURE__ */ __name((headers) => {
2926
- const entries = [];
2927
- headers.forEach((value, key) => {
2928
- entries.push([key, value]);
2929
- });
2930
- return entries;
2931
- }, "headersEntries");
2932
- var mergeHeaders2 = /* @__PURE__ */ __name((...headers) => {
2933
- const mergedHeaders = new Headers();
2934
- for (const header of headers) {
2935
- if (!header) {
2936
- continue;
2937
- }
2938
- const iterator = header instanceof Headers ? headersEntries2(header) : Object.entries(header);
2939
- for (const [key, value] of iterator) {
2940
- if (value === null) {
2941
- mergedHeaders.delete(key);
2942
- } else if (Array.isArray(value)) {
2943
- for (const v of value) {
2944
- mergedHeaders.append(key, v);
2945
- }
2946
- } else if (value !== void 0) {
2947
- mergedHeaders.set(
2948
- key,
2949
- typeof value === "object" ? JSON.stringify(value) : value
2950
- );
2951
- }
2952
- }
2953
- }
2954
- return mergedHeaders;
2955
- }, "mergeHeaders");
2956
- var Interceptors2 = class {
2957
- static {
2958
- __name(this, "Interceptors");
2959
- }
2960
- fns = [];
2961
- clear() {
2962
- this.fns = [];
2963
- }
2964
- eject(id) {
2965
- const index = this.getInterceptorIndex(id);
2966
- if (this.fns[index]) {
2967
- this.fns[index] = null;
2968
- }
2969
- }
2970
- exists(id) {
2971
- const index = this.getInterceptorIndex(id);
2972
- return Boolean(this.fns[index]);
2973
- }
2974
- getInterceptorIndex(id) {
2975
- if (typeof id === "number") {
2976
- return this.fns[id] ? id : -1;
2977
- }
2978
- return this.fns.indexOf(id);
2979
- }
2980
- update(id, fn) {
2981
- const index = this.getInterceptorIndex(id);
2982
- if (this.fns[index]) {
2983
- this.fns[index] = fn;
2984
- return id;
2985
- }
2986
- return false;
2987
- }
2988
- use(fn) {
2989
- this.fns.push(fn);
2990
- return this.fns.length - 1;
2991
- }
2992
- };
2993
- var createInterceptors2 = /* @__PURE__ */ __name(() => ({
2994
- error: new Interceptors2(),
2995
- request: new Interceptors2(),
2996
- response: new Interceptors2()
2997
- }), "createInterceptors");
2998
- var defaultQuerySerializer2 = createQuerySerializer2({
2999
- allowReserved: false,
3000
- array: {
3001
- explode: true,
3002
- style: "form"
3003
- },
3004
- object: {
3005
- explode: true,
3006
- style: "deepObject"
3007
- }
3008
- });
3009
- var defaultHeaders2 = {
3010
- "Content-Type": "application/json"
3011
- };
3012
- var createConfig2 = /* @__PURE__ */ __name((override = {}) => ({
3013
- ...jsonBodySerializer2,
3014
- headers: defaultHeaders2,
3015
- parseAs: "auto",
3016
- querySerializer: defaultQuerySerializer2,
3017
- ...override
3018
- }), "createConfig");
3019
-
3020
- // src/_api/generated/cfg_centrifugo/client/client.gen.ts
3021
- var createClient2 = /* @__PURE__ */ __name((config = {}) => {
3022
- let _config = mergeConfigs2(createConfig2(), config);
3023
- const getConfig = /* @__PURE__ */ __name(() => ({ ..._config }), "getConfig");
3024
- const setConfig = /* @__PURE__ */ __name((config2) => {
3025
- _config = mergeConfigs2(_config, config2);
3026
- return getConfig();
3027
- }, "setConfig");
3028
- const interceptors = createInterceptors2();
3029
- const beforeRequest = /* @__PURE__ */ __name(async (options) => {
3030
- const opts = {
3031
- ..._config,
3032
- ...options,
3033
- fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
3034
- headers: mergeHeaders2(_config.headers, options.headers),
3035
- serializedBody: void 0
3036
- };
3037
- if (opts.security) {
3038
- await setAuthParams2({
3039
- ...opts,
3040
- security: opts.security
3041
- });
3042
- }
3043
- if (opts.requestValidator) {
3044
- await opts.requestValidator(opts);
3045
- }
3046
- if (opts.body !== void 0 && opts.bodySerializer) {
3047
- opts.serializedBody = opts.bodySerializer(opts.body);
3048
- }
3049
- if (opts.body === void 0 || opts.serializedBody === "") {
3050
- opts.headers.delete("Content-Type");
3051
- }
3052
- const resolvedOpts = opts;
3053
- const url = buildUrl2(resolvedOpts);
3054
- return { opts: resolvedOpts, url };
3055
- }, "beforeRequest");
3056
- const request = /* @__PURE__ */ __name(async (options) => {
3057
- const throwOnError = options.throwOnError ?? _config.throwOnError;
3058
- const responseStyle = options.responseStyle ?? _config.responseStyle;
3059
- let request2;
3060
- let response;
3061
- try {
3062
- const { opts, url } = await beforeRequest(options);
3063
- const requestInit = {
3064
- redirect: "follow",
3065
- ...opts,
3066
- body: getValidRequestBody2(opts)
3067
- };
3068
- request2 = new Request(url, requestInit);
3069
- for (const fn of interceptors.request.fns) {
3070
- if (fn) {
3071
- request2 = await fn(request2, opts);
3072
- }
3073
- }
3074
- const _fetch = opts.fetch;
3075
- response = await _fetch(request2);
3076
- for (const fn of interceptors.response.fns) {
3077
- if (fn) {
3078
- response = await fn(response, request2, opts);
3079
- }
3080
- }
3081
- const result = {
3082
- request: request2,
3083
- response
3084
- };
3085
- if (response.ok) {
3086
- const parseAs = (opts.parseAs === "auto" ? getParseAs2(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
3087
- if (response.status === 204 || response.headers.get("Content-Length") === "0") {
3088
- let emptyData;
3089
- switch (parseAs) {
3090
- case "arrayBuffer":
3091
- case "blob":
3092
- case "text":
3093
- emptyData = await response[parseAs]();
3094
- break;
3095
- case "formData":
3096
- emptyData = new FormData();
3097
- break;
3098
- case "stream":
3099
- emptyData = response.body;
3100
- break;
3101
- case "json":
3102
- default:
3103
- emptyData = {};
3104
- break;
3105
- }
3106
- return opts.responseStyle === "data" ? emptyData : {
3107
- data: emptyData,
3108
- ...result
3109
- };
3110
- }
3111
- let data;
3112
- switch (parseAs) {
3113
- case "arrayBuffer":
3114
- case "blob":
3115
- case "formData":
3116
- case "text":
3117
- data = await response[parseAs]();
3118
- break;
3119
- case "json": {
3120
- const text = await response.text();
3121
- data = text ? JSON.parse(text) : {};
3122
- break;
3123
- }
3124
- case "stream":
3125
- return opts.responseStyle === "data" ? response.body : {
3126
- data: response.body,
3127
- ...result
3128
- };
3129
- }
3130
- if (parseAs === "json") {
3131
- if (opts.responseValidator) {
3132
- await opts.responseValidator(data);
3133
- }
3134
- if (opts.responseTransformer) {
3135
- data = await opts.responseTransformer(data);
3136
- }
3137
- }
3138
- return opts.responseStyle === "data" ? data : {
3139
- data,
3140
- ...result
3141
- };
3142
- }
3143
- const textError = await response.text();
3144
- let jsonError;
3145
- try {
3146
- jsonError = JSON.parse(textError);
3147
- } catch {
3148
- }
3149
- throw jsonError ?? textError;
3150
- } catch (error) {
3151
- let finalError = error;
3152
- for (const fn of interceptors.error.fns) {
3153
- if (fn) {
3154
- finalError = await fn(finalError, response, request2, options);
3155
- }
3156
- }
3157
- finalError = finalError || {};
3158
- if (throwOnError) {
3159
- throw finalError;
3160
- }
3161
- return responseStyle === "data" ? void 0 : {
3162
- error: finalError,
3163
- request: request2,
3164
- response
3165
- };
3166
- }
3167
- }, "request");
3168
- const makeMethodFn = /* @__PURE__ */ __name((method) => (options) => request({ ...options, method }), "makeMethodFn");
3169
- const makeSseFn = /* @__PURE__ */ __name((method) => async (options) => {
3170
- const { opts, url } = await beforeRequest(options);
3171
- return createSseClient2({
3172
- ...opts,
3173
- body: opts.body,
3174
- method,
3175
- onRequest: /* @__PURE__ */ __name(async (url2, init) => {
3176
- let request2 = new Request(url2, init);
3177
- for (const fn of interceptors.request.fns) {
3178
- if (fn) {
3179
- request2 = await fn(request2, opts);
3180
- }
3181
- }
3182
- return request2;
3183
- }, "onRequest"),
3184
- serializedBody: getValidRequestBody2(opts),
3185
- url
3186
- });
3187
- }, "makeSseFn");
3188
- const _buildUrl = /* @__PURE__ */ __name((options) => buildUrl2({ ..._config, ...options }), "_buildUrl");
3189
- return {
3190
- buildUrl: _buildUrl,
3191
- connect: makeMethodFn("CONNECT"),
3192
- delete: makeMethodFn("DELETE"),
3193
- get: makeMethodFn("GET"),
3194
- getConfig,
3195
- head: makeMethodFn("HEAD"),
3196
- interceptors,
3197
- options: makeMethodFn("OPTIONS"),
3198
- patch: makeMethodFn("PATCH"),
3199
- post: makeMethodFn("POST"),
3200
- put: makeMethodFn("PUT"),
3201
- request,
3202
- setConfig,
3203
- sse: {
3204
- connect: makeSseFn("CONNECT"),
3205
- delete: makeSseFn("DELETE"),
3206
- get: makeSseFn("GET"),
3207
- head: makeSseFn("HEAD"),
3208
- options: makeSseFn("OPTIONS"),
3209
- patch: makeSseFn("PATCH"),
3210
- post: makeSseFn("POST"),
3211
- put: makeSseFn("PUT"),
3212
- trace: makeSseFn("TRACE")
3213
- },
3214
- trace: makeMethodFn("TRACE")
3215
- };
3216
- }, "createClient");
3217
-
3218
- // src/_api/generated/cfg_centrifugo/client.gen.ts
3219
- var client2 = createClient2(createConfig2({ baseUrl: "http://localhost:8000" }));
3220
-
3221
- // src/_api/generated/cfg_centrifugo/sdk.gen.ts
3222
- var Cfg2 = class {
3223
- static {
3224
- __name(this, "Cfg");
3225
- }
3226
- /**
3227
- * Get Centrifugo connection token
3228
- *
3229
- * Generate JWT token for WebSocket connection to Centrifugo. Token includes user's allowed channels based on their permissions. Requires authentication.
3230
- */
3231
- static cfgCentrifugoAuthTokenRetrieve(options) {
3232
- return (options?.client ?? client2).get({
3233
- security: [{ scheme: "bearer", type: "http" }],
3234
- url: "/cfg/centrifugo/auth/token/",
3235
- ...options
3236
- });
3237
- }
3238
- };
3239
- var Centrifugo = class {
3240
- static {
3241
- __name(this, "Centrifugo");
3242
- }
3243
- /**
3244
- * Get Centrifugo connection token
3245
- *
3246
- * Generate JWT token for WebSocket connection to Centrifugo. Token includes user's allowed channels based on their permissions. Requires authentication.
3247
- */
3248
- static cfgCentrifugoAuthTokenRetrieve(options) {
3249
- return (options?.client ?? client2).get({
3250
- security: [{ scheme: "bearer", type: "http" }],
3251
- url: "/cfg/centrifugo/auth/token/",
3252
- ...options
3253
- });
3254
- }
3255
- };
3256
- var CentrifugoAuth = class {
3257
- static {
3258
- __name(this, "CentrifugoAuth");
3259
- }
3260
- /**
3261
- * Get Centrifugo connection token
3262
- *
3263
- * Generate JWT token for WebSocket connection to Centrifugo. Token includes user's allowed channels based on their permissions. Requires authentication.
3264
- */
3265
- static cfgCentrifugoAuthTokenRetrieve(options) {
3266
- return (options?.client ?? client2).get({
3267
- security: [{ scheme: "bearer", type: "http" }],
3268
- url: "/cfg/centrifugo/auth/token/",
3269
- ...options
3270
- });
3271
- }
3272
- };
3273
-
3274
- // src/_api/generated/cfg_centrifugo/schemas/ConnectionTokenResponse.ts
3275
- var import_zod22 = require("zod");
3276
- var ConnectionTokenResponseSchema = import_zod22.z.object({
3277
- token: import_zod22.z.string(),
3278
- centrifugo_url: import_zod22.z.string(),
3279
- expires_at: import_zod22.z.string(),
3280
- channels: import_zod22.z.array(import_zod22.z.string())
3281
- });
3282
-
3283
- // src/_api/generated/cfg_centrifugo/api.ts
3284
- var ACCESS_KEY2 = "cfg.access_token";
3285
- var REFRESH_KEY2 = "cfg.refresh_token";
3286
- var VALIDATION_ROUTES2 = [
3287
- { method: "GET", re: new RegExp("^/cfg/centrifugo/auth/token/?$"), schema: ConnectionTokenResponseSchema, path: "/cfg/centrifugo/auth/token/" }
3288
- ];
3289
- function detectLocale2() {
3290
- try {
3291
- if (typeof document !== "undefined") {
3292
- const m = document.cookie.match(/(?:^|;\s*)NEXT_LOCALE=([^;]*)/);
3293
- if (m) return decodeURIComponent(m[1]);
3294
- }
3295
- if (typeof navigator !== "undefined" && navigator.language) {
3296
- return navigator.language;
3297
- }
3298
- } catch {
3299
- }
3300
- return null;
3301
- }
3302
- __name(detectLocale2, "detectLocale");
3303
- var API2 = class {
3304
- static {
3305
- __name(this, "API");
3306
- }
3307
- baseUrl;
3308
- storage;
3309
- locale;
3310
- apiKey;
3311
- logger;
3312
- cfg = Cfg2;
3313
- centrifugo = Centrifugo;
3314
- centrifugoAuth = CentrifugoAuth;
3315
- constructor(baseUrl2, opts = {}) {
3316
- this.baseUrl = baseUrl2.replace(/\/$/, "");
3317
- this.storage = opts.storage ?? new LocalStorageAdapter();
3318
- this.logger = new APILogger(opts.logger);
3319
- this.locale = opts.locale ?? null;
3320
- this.apiKey = opts.apiKey ?? (typeof process !== "undefined" ? process.env?.NEXT_PUBLIC_API_KEY ?? null : null);
3321
- const credentials = opts.withCredentials ?? true ? "include" : "same-origin";
3322
- client2.setConfig({ baseUrl: this.baseUrl, credentials });
3323
- client2.interceptors.request.use((request) => {
3324
- const access = this.getToken();
3325
- if (access) request.headers.set("Authorization", `Bearer ${access}`);
3326
- const locale = this.locale ?? detectLocale2();
3327
- if (locale) request.headers.set("Accept-Language", locale);
3328
- if (this.apiKey) request.headers.set("X-API-Key", this.apiKey);
3329
- return request;
3330
- });
3331
- client2.interceptors.response.use(async (response, request) => {
3332
- if (!response.ok) return response;
3333
- const ct = response.headers.get("content-type") || "";
3334
- if (!ct.includes("application/json")) return response;
3335
- const url = new URL(request.url);
3336
- const method = request.method.toUpperCase();
3337
- const route = VALIDATION_ROUTES2.find(
3338
- (r) => r.method === method && r.re.test(url.pathname)
3339
- );
3340
- if (!route) return response;
3341
- let payload;
3342
- try {
3343
- payload = await response.clone().json();
3344
- } catch {
3345
- return response;
3346
- }
3347
- const result = route.schema.safeParse(payload);
3348
- if (!result.success) {
3349
- dispatchValidationError({
3350
- operation: `${method} ${route.path}`,
3351
- path: route.path,
3352
- method,
3353
- error: result.error,
3354
- response: payload,
3355
- timestamp: /* @__PURE__ */ new Date()
3356
- });
3357
- }
3358
- return response;
3359
- });
3360
- }
3361
- // ── Base URL ────────────────────────────────────────────────────────────
3362
- getBaseUrl() {
3363
- return this.baseUrl;
3364
- }
3365
- setBaseUrl(url) {
3366
- this.baseUrl = url.replace(/\/$/, "");
3367
- client2.setConfig({ baseUrl: this.baseUrl });
3368
- }
3369
- // ── Tokens ──────────────────────────────────────────────────────────────
3370
- getToken() {
3371
- return this.storage.getItem(ACCESS_KEY2);
3372
- }
3373
- setToken(token) {
3374
- if (token) this.storage.setItem(ACCESS_KEY2, token);
3375
- else this.storage.removeItem(ACCESS_KEY2);
3376
- }
3377
- getRefreshToken() {
3378
- return this.storage.getItem(REFRESH_KEY2);
3379
- }
3380
- setRefreshToken(token) {
3381
- if (token) this.storage.setItem(REFRESH_KEY2, token);
3382
- else this.storage.removeItem(REFRESH_KEY2);
3383
- }
3384
- clearToken() {
3385
- this.storage.removeItem(ACCESS_KEY2);
3386
- this.storage.removeItem(REFRESH_KEY2);
3387
- }
3388
- isAuthenticated() {
3389
- return this.getToken() !== null;
3390
- }
3391
- // ── Locale / API key ────────────────────────────────────────────────────
3392
- getLocale() {
3393
- return this.locale ?? detectLocale2();
3394
- }
3395
- setLocale(locale) {
3396
- this.locale = locale;
3397
- }
3398
- getApiKey() {
3399
- return this.apiKey;
3400
- }
3401
- setApiKey(key) {
3402
- this.apiKey = key;
3403
- }
3404
- };
3405
-
3406
- // src/_api/generated/cfg_totp/core/bodySerializer.gen.ts
3407
- var jsonBodySerializer3 = {
3408
- bodySerializer: /* @__PURE__ */ __name((body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value), "bodySerializer")
3409
- };
3410
-
3411
- // src/_api/generated/cfg_totp/core/params.gen.ts
3412
- var extraPrefixesMap3 = {
3413
- $body_: "body",
3414
- $headers_: "headers",
3415
- $path_: "path",
3416
- $query_: "query"
3417
- };
3418
- var extraPrefixes3 = Object.entries(extraPrefixesMap3);
3419
-
3420
- // src/_api/generated/cfg_totp/core/serverSentEvents.gen.ts
3421
- function createSseClient3({
3422
- onRequest,
3423
- onSseError,
3424
- onSseEvent,
3425
- responseTransformer,
3426
- responseValidator,
3427
- sseDefaultRetryDelay,
3428
- sseMaxRetryAttempts,
3429
- sseMaxRetryDelay,
3430
- sseSleepFn,
3431
- url,
3432
- ...options
3433
- }) {
3434
- let lastEventId;
3435
- const sleep = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
3436
- const createStream = /* @__PURE__ */ __name(async function* () {
3437
- let retryDelay = sseDefaultRetryDelay ?? 3e3;
3438
- let attempt = 0;
3439
- const signal = options.signal ?? new AbortController().signal;
3440
- while (true) {
3441
- if (signal.aborted) break;
3442
- attempt++;
3443
- const headers = options.headers instanceof Headers ? options.headers : new Headers(options.headers);
3444
- if (lastEventId !== void 0) {
3445
- headers.set("Last-Event-ID", lastEventId);
3446
- }
3447
- try {
3448
- const requestInit = {
3449
- redirect: "follow",
3450
- ...options,
3451
- body: options.serializedBody,
3452
- headers,
3453
- signal
3454
- };
3455
- let request = new Request(url, requestInit);
3456
- if (onRequest) {
3457
- request = await onRequest(url, requestInit);
3458
- }
3459
- const _fetch = options.fetch ?? globalThis.fetch;
3460
- const response = await _fetch(request);
3461
- if (!response.ok) throw new Error(`SSE failed: ${response.status} ${response.statusText}`);
3462
- if (!response.body) throw new Error("No body in SSE response");
3463
- const reader = response.body.pipeThrough(new TextDecoderStream()).getReader();
3464
- let buffer = "";
3465
- const abortHandler = /* @__PURE__ */ __name(() => {
3466
- try {
3467
- reader.cancel();
3468
- } catch {
3469
- }
3470
- }, "abortHandler");
3471
- signal.addEventListener("abort", abortHandler);
3472
- try {
3473
- while (true) {
3474
- const { done, value } = await reader.read();
3475
- if (done) break;
3476
- buffer += value;
3477
- buffer = buffer.replace(/\r\n?/g, "\n");
3478
- const chunks = buffer.split("\n\n");
3479
- buffer = chunks.pop() ?? "";
3480
- for (const chunk of chunks) {
3481
- const lines = chunk.split("\n");
3482
- const dataLines = [];
3483
- let eventName;
3484
- for (const line of lines) {
3485
- if (line.startsWith("data:")) {
3486
- dataLines.push(line.replace(/^data:\s*/, ""));
3487
- } else if (line.startsWith("event:")) {
3488
- eventName = line.replace(/^event:\s*/, "");
3489
- } else if (line.startsWith("id:")) {
3490
- lastEventId = line.replace(/^id:\s*/, "");
3491
- } else if (line.startsWith("retry:")) {
3492
- const parsed = Number.parseInt(line.replace(/^retry:\s*/, ""), 10);
3493
- if (!Number.isNaN(parsed)) {
3494
- retryDelay = parsed;
3495
- }
3496
- }
3497
- }
3498
- let data;
3499
- let parsedJson = false;
3500
- if (dataLines.length) {
3501
- const rawData = dataLines.join("\n");
3502
- try {
3503
- data = JSON.parse(rawData);
3504
- parsedJson = true;
3505
- } catch {
3506
- data = rawData;
3507
- }
3508
- }
3509
- if (parsedJson) {
3510
- if (responseValidator) {
3511
- await responseValidator(data);
3512
- }
3513
- if (responseTransformer) {
3514
- data = await responseTransformer(data);
3515
- }
3516
- }
3517
- onSseEvent?.({
3518
- data,
3519
- event: eventName,
3520
- id: lastEventId,
3521
- retry: retryDelay
3522
- });
3523
- if (dataLines.length) {
3524
- yield data;
3525
- }
3526
- }
3527
- }
3528
- } finally {
3529
- signal.removeEventListener("abort", abortHandler);
3530
- reader.releaseLock();
3531
- }
3532
- break;
3533
- } catch (error) {
3534
- onSseError?.(error);
3535
- if (sseMaxRetryAttempts !== void 0 && attempt >= sseMaxRetryAttempts) {
3536
- break;
3537
- }
3538
- const backoff = Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 3e4);
3539
- await sleep(backoff);
3540
- }
3541
- }
3542
- }, "createStream");
3543
- const stream = createStream();
3544
- return { stream };
3545
- }
3546
- __name(createSseClient3, "createSseClient");
3547
-
3548
- // src/_api/generated/cfg_totp/core/pathSerializer.gen.ts
3549
- var separatorArrayExplode3 = /* @__PURE__ */ __name((style) => {
3550
- switch (style) {
3551
- case "label":
3552
- return ".";
3553
- case "matrix":
3554
- return ";";
3555
- case "simple":
3556
- return ",";
3557
- default:
3558
- return "&";
3559
- }
3560
- }, "separatorArrayExplode");
3561
- var separatorArrayNoExplode3 = /* @__PURE__ */ __name((style) => {
3562
- switch (style) {
3563
- case "form":
3564
- return ",";
3565
- case "pipeDelimited":
3566
- return "|";
3567
- case "spaceDelimited":
3568
- return "%20";
3569
- default:
3570
- return ",";
3571
- }
3572
- }, "separatorArrayNoExplode");
3573
- var separatorObjectExplode3 = /* @__PURE__ */ __name((style) => {
3574
- switch (style) {
3575
- case "label":
3576
- return ".";
3577
- case "matrix":
3578
- return ";";
3579
- case "simple":
3580
- return ",";
3581
- default:
3582
- return "&";
3583
- }
3584
- }, "separatorObjectExplode");
3585
- var serializeArrayParam3 = /* @__PURE__ */ __name(({
3586
- allowReserved,
3587
- explode,
3588
- name,
3589
- style,
3590
- value
3591
- }) => {
3592
- if (!explode) {
3593
- const joinedValues2 = (allowReserved ? value : value.map((v) => encodeURIComponent(v))).join(separatorArrayNoExplode3(style));
3594
- switch (style) {
3595
- case "label":
3596
- return `.${joinedValues2}`;
3597
- case "matrix":
3598
- return `;${name}=${joinedValues2}`;
3599
- case "simple":
3600
- return joinedValues2;
3601
- default:
3602
- return `${name}=${joinedValues2}`;
3603
- }
3604
- }
3605
- const separator = separatorArrayExplode3(style);
3606
- const joinedValues = value.map((v) => {
3607
- if (style === "label" || style === "simple") {
3608
- return allowReserved ? v : encodeURIComponent(v);
3609
- }
3610
- return serializePrimitiveParam3({
3611
- allowReserved,
3612
- name,
3613
- value: v
3614
- });
3615
- }).join(separator);
3616
- return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
3617
- }, "serializeArrayParam");
3618
- var serializePrimitiveParam3 = /* @__PURE__ */ __name(({
3619
- allowReserved,
3620
- name,
3621
- value
3622
- }) => {
3623
- if (value === void 0 || value === null) {
3624
- return "";
3625
- }
3626
- if (typeof value === "object") {
3627
- throw new Error(
3628
- "Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these."
3629
- );
3630
- }
3631
- return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
3632
- }, "serializePrimitiveParam");
3633
- var serializeObjectParam3 = /* @__PURE__ */ __name(({
3634
- allowReserved,
3635
- explode,
3636
- name,
3637
- style,
3638
- value,
3639
- valueOnly
3640
- }) => {
3641
- if (value instanceof Date) {
3642
- return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
3643
- }
3644
- if (style !== "deepObject" && !explode) {
3645
- let values = [];
3646
- Object.entries(value).forEach(([key, v]) => {
3647
- values = [...values, key, allowReserved ? v : encodeURIComponent(v)];
3648
- });
3649
- const joinedValues2 = values.join(",");
3650
- switch (style) {
3651
- case "form":
3652
- return `${name}=${joinedValues2}`;
3653
- case "label":
3654
- return `.${joinedValues2}`;
3655
- case "matrix":
3656
- return `;${name}=${joinedValues2}`;
3657
- default:
3658
- return joinedValues2;
3659
- }
3660
- }
3661
- const separator = separatorObjectExplode3(style);
3662
- const joinedValues = Object.entries(value).map(
3663
- ([key, v]) => serializePrimitiveParam3({
3664
- allowReserved,
3665
- name: style === "deepObject" ? `${name}[${key}]` : key,
3666
- value: v
3667
- })
3668
- ).join(separator);
3669
- return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
3670
- }, "serializeObjectParam");
3671
-
3672
- // src/_api/generated/cfg_totp/core/utils.gen.ts
3673
- var PATH_PARAM_RE3 = /\{[^{}]+\}/g;
3674
- var defaultPathSerializer3 = /* @__PURE__ */ __name(({ path, url: _url }) => {
3675
- let url = _url;
3676
- const matches = _url.match(PATH_PARAM_RE3);
3677
- if (matches) {
3678
- for (const match of matches) {
3679
- let explode = false;
3680
- let name = match.substring(1, match.length - 1);
3681
- let style = "simple";
3682
- if (name.endsWith("*")) {
3683
- explode = true;
3684
- name = name.substring(0, name.length - 1);
3685
- }
3686
- if (name.startsWith(".")) {
3687
- name = name.substring(1);
3688
- style = "label";
3689
- } else if (name.startsWith(";")) {
3690
- name = name.substring(1);
3691
- style = "matrix";
3692
- }
3693
- const value = path[name];
3694
- if (value === void 0 || value === null) {
3695
- continue;
3696
- }
3697
- if (Array.isArray(value)) {
3698
- url = url.replace(match, serializeArrayParam3({ explode, name, style, value }));
3699
- continue;
3700
- }
3701
- if (typeof value === "object") {
3702
- url = url.replace(
3703
- match,
3704
- serializeObjectParam3({
3705
- explode,
3706
- name,
3707
- style,
3708
- value,
3709
- valueOnly: true
3710
- })
3711
- );
3712
- continue;
3713
- }
3714
- if (style === "matrix") {
3715
- url = url.replace(
3716
- match,
3717
- `;${serializePrimitiveParam3({
3718
- name,
3719
- value
3720
- })}`
3721
- );
3722
- continue;
3723
- }
3724
- const replaceValue = encodeURIComponent(
3725
- style === "label" ? `.${value}` : value
3726
- );
3727
- url = url.replace(match, replaceValue);
3728
- }
3729
- }
3730
- return url;
3731
- }, "defaultPathSerializer");
3732
- var getUrl3 = /* @__PURE__ */ __name(({
3733
- baseUrl: baseUrl2,
3734
- path,
3735
- query,
3736
- querySerializer,
3737
- url: _url
3738
- }) => {
3739
- const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
3740
- let url = (baseUrl2 ?? "") + pathUrl;
3741
- if (path) {
3742
- url = defaultPathSerializer3({ path, url });
3743
- }
3744
- let search = query ? querySerializer(query) : "";
3745
- if (search.startsWith("?")) {
3746
- search = search.substring(1);
3747
- }
3748
- if (search) {
3749
- url += `?${search}`;
3750
- }
3751
- return url;
3752
- }, "getUrl");
3753
- function getValidRequestBody3(options) {
3754
- const hasBody = options.body !== void 0;
3755
- const isSerializedBody = hasBody && options.bodySerializer;
3756
- if (isSerializedBody) {
3757
- if ("serializedBody" in options) {
3758
- const hasSerializedBody = options.serializedBody !== void 0 && options.serializedBody !== "";
3759
- return hasSerializedBody ? options.serializedBody : null;
3760
- }
3761
- return options.body !== "" ? options.body : null;
3762
- }
3763
- if (hasBody) {
3764
- return options.body;
3765
- }
3766
- return void 0;
3767
- }
3768
- __name(getValidRequestBody3, "getValidRequestBody");
3769
-
3770
- // src/_api/generated/cfg_totp/core/auth.gen.ts
3771
- var getAuthToken3 = /* @__PURE__ */ __name(async (auth, callback) => {
3772
- const token = typeof callback === "function" ? await callback(auth) : callback;
3773
- if (!token) {
3774
- return;
3775
- }
3776
- if (auth.scheme === "bearer") {
3777
- return `Bearer ${token}`;
3778
- }
3779
- if (auth.scheme === "basic") {
3780
- return `Basic ${btoa(token)}`;
3781
- }
3782
- return token;
3783
- }, "getAuthToken");
3784
-
3785
- // src/_api/generated/cfg_totp/client/utils.gen.ts
3786
- var createQuerySerializer3 = /* @__PURE__ */ __name(({
3787
- parameters = {},
3788
- ...args
3789
- } = {}) => {
3790
- const querySerializer = /* @__PURE__ */ __name((queryParams) => {
3791
- const search = [];
3792
- if (queryParams && typeof queryParams === "object") {
3793
- for (const name in queryParams) {
3794
- const value = queryParams[name];
3795
- if (value === void 0 || value === null) {
3796
- continue;
3797
- }
3798
- const options = parameters[name] || args;
3799
- if (Array.isArray(value)) {
3800
- const serializedArray = serializeArrayParam3({
3801
- allowReserved: options.allowReserved,
3802
- explode: true,
3803
- name,
3804
- style: "form",
3805
- value,
3806
- ...options.array
3807
- });
3808
- if (serializedArray) search.push(serializedArray);
3809
- } else if (typeof value === "object") {
3810
- const serializedObject = serializeObjectParam3({
3811
- allowReserved: options.allowReserved,
3812
- explode: true,
3813
- name,
3814
- style: "deepObject",
3815
- value,
3816
- ...options.object
3817
- });
3818
- if (serializedObject) search.push(serializedObject);
3819
- } else {
3820
- const serializedPrimitive = serializePrimitiveParam3({
3821
- allowReserved: options.allowReserved,
3822
- name,
3823
- value
3824
- });
3825
- if (serializedPrimitive) search.push(serializedPrimitive);
3826
- }
3827
- }
3828
- }
3829
- return search.join("&");
3830
- }, "querySerializer");
3831
- return querySerializer;
3832
- }, "createQuerySerializer");
3833
- var getParseAs3 = /* @__PURE__ */ __name((contentType) => {
3834
- if (!contentType) {
3835
- return "stream";
3836
- }
3837
- const cleanContent = contentType.split(";")[0]?.trim();
3838
- if (!cleanContent) {
3839
- return;
3840
- }
3841
- if (cleanContent.startsWith("application/json") || cleanContent.endsWith("+json")) {
3842
- return "json";
3843
- }
3844
- if (cleanContent === "multipart/form-data") {
3845
- return "formData";
3846
- }
3847
- if (["application/", "audio/", "image/", "video/"].some((type) => cleanContent.startsWith(type))) {
3848
- return "blob";
3849
- }
3850
- if (cleanContent.startsWith("text/")) {
3851
- return "text";
3852
- }
3853
- return;
3854
- }, "getParseAs");
3855
- var checkForExistence3 = /* @__PURE__ */ __name((options, name) => {
3856
- if (!name) {
3857
- return false;
3858
- }
3859
- if (options.headers.has(name) || options.query?.[name] || options.headers.get("Cookie")?.includes(`${name}=`)) {
3860
- return true;
3861
- }
3862
- return false;
3863
- }, "checkForExistence");
3864
- var setAuthParams3 = /* @__PURE__ */ __name(async ({
3865
- security,
3866
- ...options
3867
- }) => {
3868
- for (const auth of security) {
3869
- if (checkForExistence3(options, auth.name)) {
3870
- continue;
3871
- }
3872
- const token = await getAuthToken3(auth, options.auth);
3873
- if (!token) {
3874
- continue;
3875
- }
3876
- const name = auth.name ?? "Authorization";
3877
- switch (auth.in) {
3878
- case "query":
3879
- if (!options.query) {
3880
- options.query = {};
3881
- }
3882
- options.query[name] = token;
3883
- break;
3884
- case "cookie":
3885
- options.headers.append("Cookie", `${name}=${token}`);
3886
- break;
3887
- case "header":
3888
- default:
3889
- options.headers.set(name, token);
3890
- break;
3891
- }
3892
- }
3893
- }, "setAuthParams");
3894
- var buildUrl3 = /* @__PURE__ */ __name((options) => getUrl3({
3895
- baseUrl: options.baseUrl,
3896
- path: options.path,
3897
- query: options.query,
3898
- querySerializer: typeof options.querySerializer === "function" ? options.querySerializer : createQuerySerializer3(options.querySerializer),
3899
- url: options.url
3900
- }), "buildUrl");
3901
- var mergeConfigs3 = /* @__PURE__ */ __name((a, b) => {
3902
- const config = { ...a, ...b };
3903
- if (config.baseUrl?.endsWith("/")) {
3904
- config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
3905
- }
3906
- config.headers = mergeHeaders3(a.headers, b.headers);
3907
- return config;
3908
- }, "mergeConfigs");
3909
- var headersEntries3 = /* @__PURE__ */ __name((headers) => {
3910
- const entries = [];
3911
- headers.forEach((value, key) => {
3912
- entries.push([key, value]);
3913
- });
3914
- return entries;
3915
- }, "headersEntries");
3916
- var mergeHeaders3 = /* @__PURE__ */ __name((...headers) => {
3917
- const mergedHeaders = new Headers();
3918
- for (const header of headers) {
3919
- if (!header) {
3920
- continue;
3921
- }
3922
- const iterator = header instanceof Headers ? headersEntries3(header) : Object.entries(header);
3923
- for (const [key, value] of iterator) {
3924
- if (value === null) {
3925
- mergedHeaders.delete(key);
3926
- } else if (Array.isArray(value)) {
3927
- for (const v of value) {
3928
- mergedHeaders.append(key, v);
3929
- }
3930
- } else if (value !== void 0) {
3931
- mergedHeaders.set(
3932
- key,
3933
- typeof value === "object" ? JSON.stringify(value) : value
3934
- );
3935
- }
3936
- }
3937
- }
3938
- return mergedHeaders;
3939
- }, "mergeHeaders");
3940
- var Interceptors3 = class {
3941
- static {
3942
- __name(this, "Interceptors");
3943
- }
3944
- fns = [];
3945
- clear() {
3946
- this.fns = [];
3947
- }
3948
- eject(id) {
3949
- const index = this.getInterceptorIndex(id);
3950
- if (this.fns[index]) {
3951
- this.fns[index] = null;
3952
- }
3953
- }
3954
- exists(id) {
3955
- const index = this.getInterceptorIndex(id);
3956
- return Boolean(this.fns[index]);
3957
- }
3958
- getInterceptorIndex(id) {
3959
- if (typeof id === "number") {
3960
- return this.fns[id] ? id : -1;
3961
- }
3962
- return this.fns.indexOf(id);
3963
- }
3964
- update(id, fn) {
3965
- const index = this.getInterceptorIndex(id);
3966
- if (this.fns[index]) {
3967
- this.fns[index] = fn;
3968
- return id;
3969
- }
3970
- return false;
3971
- }
3972
- use(fn) {
3973
- this.fns.push(fn);
3974
- return this.fns.length - 1;
3975
- }
3976
- };
3977
- var createInterceptors3 = /* @__PURE__ */ __name(() => ({
3978
- error: new Interceptors3(),
3979
- request: new Interceptors3(),
3980
- response: new Interceptors3()
3981
- }), "createInterceptors");
3982
- var defaultQuerySerializer3 = createQuerySerializer3({
3983
- allowReserved: false,
3984
- array: {
3985
- explode: true,
3986
- style: "form"
3987
- },
3988
- object: {
3989
- explode: true,
3990
- style: "deepObject"
3991
- }
3992
- });
3993
- var defaultHeaders3 = {
3994
- "Content-Type": "application/json"
3995
- };
3996
- var createConfig3 = /* @__PURE__ */ __name((override = {}) => ({
3997
- ...jsonBodySerializer3,
3998
- headers: defaultHeaders3,
3999
- parseAs: "auto",
4000
- querySerializer: defaultQuerySerializer3,
4001
- ...override
4002
- }), "createConfig");
4003
-
4004
- // src/_api/generated/cfg_totp/client/client.gen.ts
4005
- var createClient3 = /* @__PURE__ */ __name((config = {}) => {
4006
- let _config = mergeConfigs3(createConfig3(), config);
4007
- const getConfig = /* @__PURE__ */ __name(() => ({ ..._config }), "getConfig");
4008
- const setConfig = /* @__PURE__ */ __name((config2) => {
4009
- _config = mergeConfigs3(_config, config2);
4010
- return getConfig();
4011
- }, "setConfig");
4012
- const interceptors = createInterceptors3();
4013
- const beforeRequest = /* @__PURE__ */ __name(async (options) => {
4014
- const opts = {
4015
- ..._config,
4016
- ...options,
4017
- fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
4018
- headers: mergeHeaders3(_config.headers, options.headers),
4019
- serializedBody: void 0
4020
- };
4021
- if (opts.security) {
4022
- await setAuthParams3({
4023
- ...opts,
4024
- security: opts.security
4025
- });
4026
- }
4027
- if (opts.requestValidator) {
4028
- await opts.requestValidator(opts);
4029
- }
4030
- if (opts.body !== void 0 && opts.bodySerializer) {
4031
- opts.serializedBody = opts.bodySerializer(opts.body);
4032
- }
4033
- if (opts.body === void 0 || opts.serializedBody === "") {
4034
- opts.headers.delete("Content-Type");
4035
- }
4036
- const resolvedOpts = opts;
4037
- const url = buildUrl3(resolvedOpts);
4038
- return { opts: resolvedOpts, url };
4039
- }, "beforeRequest");
4040
- const request = /* @__PURE__ */ __name(async (options) => {
4041
- const throwOnError = options.throwOnError ?? _config.throwOnError;
4042
- const responseStyle = options.responseStyle ?? _config.responseStyle;
4043
- let request2;
4044
- let response;
4045
- try {
4046
- const { opts, url } = await beforeRequest(options);
4047
- const requestInit = {
4048
- redirect: "follow",
4049
- ...opts,
4050
- body: getValidRequestBody3(opts)
4051
- };
4052
- request2 = new Request(url, requestInit);
4053
- for (const fn of interceptors.request.fns) {
4054
- if (fn) {
4055
- request2 = await fn(request2, opts);
4056
- }
4057
- }
4058
- const _fetch = opts.fetch;
4059
- response = await _fetch(request2);
4060
- for (const fn of interceptors.response.fns) {
4061
- if (fn) {
4062
- response = await fn(response, request2, opts);
4063
- }
4064
- }
4065
- const result = {
4066
- request: request2,
4067
- response
4068
- };
4069
- if (response.ok) {
4070
- const parseAs = (opts.parseAs === "auto" ? getParseAs3(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
4071
- if (response.status === 204 || response.headers.get("Content-Length") === "0") {
4072
- let emptyData;
4073
- switch (parseAs) {
4074
- case "arrayBuffer":
4075
- case "blob":
4076
- case "text":
4077
- emptyData = await response[parseAs]();
4078
- break;
4079
- case "formData":
4080
- emptyData = new FormData();
4081
- break;
4082
- case "stream":
4083
- emptyData = response.body;
4084
- break;
4085
- case "json":
4086
- default:
4087
- emptyData = {};
4088
- break;
4089
- }
4090
- return opts.responseStyle === "data" ? emptyData : {
4091
- data: emptyData,
4092
- ...result
4093
- };
4094
- }
4095
- let data;
4096
- switch (parseAs) {
4097
- case "arrayBuffer":
4098
- case "blob":
4099
- case "formData":
4100
- case "text":
4101
- data = await response[parseAs]();
4102
- break;
4103
- case "json": {
4104
- const text = await response.text();
4105
- data = text ? JSON.parse(text) : {};
4106
- break;
4107
- }
4108
- case "stream":
4109
- return opts.responseStyle === "data" ? response.body : {
4110
- data: response.body,
4111
- ...result
4112
- };
4113
- }
4114
- if (parseAs === "json") {
4115
- if (opts.responseValidator) {
4116
- await opts.responseValidator(data);
4117
- }
4118
- if (opts.responseTransformer) {
4119
- data = await opts.responseTransformer(data);
4120
- }
4121
- }
4122
- return opts.responseStyle === "data" ? data : {
4123
- data,
4124
- ...result
4125
- };
4126
- }
4127
- const textError = await response.text();
4128
- let jsonError;
4129
- try {
4130
- jsonError = JSON.parse(textError);
4131
- } catch {
4132
- }
4133
- throw jsonError ?? textError;
4134
- } catch (error) {
4135
- let finalError = error;
4136
- for (const fn of interceptors.error.fns) {
4137
- if (fn) {
4138
- finalError = await fn(finalError, response, request2, options);
4139
- }
4140
- }
4141
- finalError = finalError || {};
4142
- if (throwOnError) {
4143
- throw finalError;
4144
- }
4145
- return responseStyle === "data" ? void 0 : {
4146
- error: finalError,
4147
- request: request2,
4148
- response
4149
- };
4150
- }
4151
- }, "request");
4152
- const makeMethodFn = /* @__PURE__ */ __name((method) => (options) => request({ ...options, method }), "makeMethodFn");
4153
- const makeSseFn = /* @__PURE__ */ __name((method) => async (options) => {
4154
- const { opts, url } = await beforeRequest(options);
4155
- return createSseClient3({
4156
- ...opts,
4157
- body: opts.body,
4158
- method,
4159
- onRequest: /* @__PURE__ */ __name(async (url2, init) => {
4160
- let request2 = new Request(url2, init);
4161
- for (const fn of interceptors.request.fns) {
4162
- if (fn) {
4163
- request2 = await fn(request2, opts);
4164
- }
4165
- }
4166
- return request2;
4167
- }, "onRequest"),
4168
- serializedBody: getValidRequestBody3(opts),
4169
- url
4170
- });
4171
- }, "makeSseFn");
4172
- const _buildUrl = /* @__PURE__ */ __name((options) => buildUrl3({ ..._config, ...options }), "_buildUrl");
4173
- return {
4174
- buildUrl: _buildUrl,
4175
- connect: makeMethodFn("CONNECT"),
4176
- delete: makeMethodFn("DELETE"),
4177
- get: makeMethodFn("GET"),
4178
- getConfig,
4179
- head: makeMethodFn("HEAD"),
4180
- interceptors,
4181
- options: makeMethodFn("OPTIONS"),
4182
- patch: makeMethodFn("PATCH"),
4183
- post: makeMethodFn("POST"),
4184
- put: makeMethodFn("PUT"),
4185
- request,
4186
- setConfig,
4187
- sse: {
4188
- connect: makeSseFn("CONNECT"),
4189
- delete: makeSseFn("DELETE"),
4190
- get: makeSseFn("GET"),
4191
- head: makeSseFn("HEAD"),
4192
- options: makeSseFn("OPTIONS"),
4193
- patch: makeSseFn("PATCH"),
4194
- post: makeSseFn("POST"),
4195
- put: makeSseFn("PUT"),
4196
- trace: makeSseFn("TRACE")
4197
- },
4198
- trace: makeMethodFn("TRACE")
4199
- };
4200
- }, "createClient");
4201
-
4202
- // src/_api/generated/cfg_totp/client.gen.ts
4203
- var client3 = createClient3(createConfig3({ baseUrl: "http://localhost:8000" }));
4204
-
4205
- // src/_api/generated/cfg_totp/sdk.gen.ts
4206
- var Cfg3 = class {
4207
- static {
4208
- __name(this, "Cfg");
4209
- }
4210
- /**
4211
- * Get backup codes status for user.
4212
- */
4213
- static cfgTotpBackupCodesRetrieve(options) {
4214
- return (options?.client ?? client3).get({
4215
- security: [{ scheme: "bearer", type: "http" }],
4216
- url: "/cfg/totp/backup-codes/",
4217
- ...options
4218
- });
4219
- }
4220
- /**
4221
- * Regenerate backup codes.
4222
- *
4223
- * Requires TOTP code for verification.
4224
- * Invalidates all existing codes.
4225
- */
4226
- static cfgTotpBackupCodesRegenerateCreate(options) {
4227
- return (options.client ?? client3).post({
4228
- security: [{ scheme: "bearer", type: "http" }],
4229
- url: "/cfg/totp/backup-codes/regenerate/",
4230
- ...options,
4231
- headers: {
4232
- "Content-Type": "application/json",
4233
- ...options.headers
4234
- }
4235
- });
4236
- }
4237
- /**
4238
- * List all TOTP devices for user.
4239
- */
4240
- static cfgTotpDevicesRetrieve(options) {
4241
- return (options?.client ?? client3).get({
4242
- security: [{ scheme: "bearer", type: "http" }],
4243
- url: "/cfg/totp/devices/",
4244
- ...options
4245
- });
4246
- }
4247
- /**
4248
- * Delete a TOTP device.
4249
- *
4250
- * Requires verification code if removing the last/primary device.
4251
- */
4252
- static cfgTotpDevicesDestroy(options) {
4253
- return (options.client ?? client3).delete({
4254
- security: [{ scheme: "bearer", type: "http" }],
4255
- url: "/cfg/totp/devices/{id}/",
4256
- ...options
4257
- });
4258
- }
4259
- /**
4260
- * Completely disable 2FA for account.
4261
- *
4262
- * Requires verification code.
4263
- */
4264
- static cfgTotpDisableCreate(options) {
4265
- return (options.client ?? client3).post({
4266
- security: [{ scheme: "bearer", type: "http" }],
4267
- url: "/cfg/totp/disable/",
4268
- ...options,
4269
- headers: {
4270
- "Content-Type": "application/json",
4271
- ...options.headers
4272
- }
4273
- });
4274
- }
4275
- /**
4276
- * Start 2FA setup process.
4277
- *
4278
- * Creates a new TOTP device and returns QR code for scanning.
4279
- */
4280
- static cfgTotpSetupCreate(options) {
4281
- return (options?.client ?? client3).post({
4282
- security: [{ scheme: "bearer", type: "http" }],
4283
- url: "/cfg/totp/setup/",
4284
- ...options,
4285
- headers: {
4286
- "Content-Type": "application/json",
4287
- ...options?.headers
4288
- }
4289
- });
4290
- }
4291
- /**
4292
- * Confirm 2FA setup with first valid code.
4293
- *
4294
- * Activates the device and generates backup codes.
4295
- */
4296
- static cfgTotpSetupConfirmCreate(options) {
4297
- return (options.client ?? client3).post({
4298
- security: [{ scheme: "bearer", type: "http" }],
4299
- url: "/cfg/totp/setup/confirm/",
4300
- ...options,
4301
- headers: {
4302
- "Content-Type": "application/json",
4303
- ...options.headers
4304
- }
4305
- });
4306
- }
4307
- /**
4308
- * Verify TOTP code for 2FA session.
4309
- *
4310
- * Completes authentication and returns JWT tokens on success.
4311
- */
4312
- static cfgTotpVerifyCreate(options) {
4313
- return (options.client ?? client3).post({
4314
- security: [{ scheme: "bearer", type: "http" }],
4315
- url: "/cfg/totp/verify/",
4316
- ...options,
4317
- headers: {
4318
- "Content-Type": "application/json",
4319
- ...options.headers
4320
- }
4321
- });
4322
- }
4323
- /**
4324
- * Verify backup recovery code for 2FA session.
4325
- *
4326
- * Alternative verification method when TOTP device unavailable.
4327
- */
4328
- static cfgTotpVerifyBackupCreate(options) {
4329
- return (options.client ?? client3).post({
4330
- security: [{ scheme: "bearer", type: "http" }],
4331
- url: "/cfg/totp/verify/backup/",
4332
- ...options,
4333
- headers: {
4334
- "Content-Type": "application/json",
4335
- ...options.headers
4336
- }
4337
- });
4338
- }
4339
- };
4340
- var Totp = class {
4341
- static {
4342
- __name(this, "Totp");
4343
- }
4344
- /**
4345
- * Get backup codes status for user.
4346
- */
4347
- static cfgTotpBackupCodesRetrieve(options) {
4348
- return (options?.client ?? client3).get({
4349
- security: [{ scheme: "bearer", type: "http" }],
4350
- url: "/cfg/totp/backup-codes/",
4351
- ...options
4352
- });
4353
- }
4354
- /**
4355
- * Regenerate backup codes.
4356
- *
4357
- * Requires TOTP code for verification.
4358
- * Invalidates all existing codes.
4359
- */
4360
- static cfgTotpBackupCodesRegenerateCreate(options) {
4361
- return (options.client ?? client3).post({
4362
- security: [{ scheme: "bearer", type: "http" }],
4363
- url: "/cfg/totp/backup-codes/regenerate/",
4364
- ...options,
4365
- headers: {
4366
- "Content-Type": "application/json",
4367
- ...options.headers
4368
- }
4369
- });
4370
- }
4371
- /**
4372
- * List all TOTP devices for user.
4373
- */
4374
- static cfgTotpDevicesRetrieve(options) {
4375
- return (options?.client ?? client3).get({
4376
- security: [{ scheme: "bearer", type: "http" }],
4377
- url: "/cfg/totp/devices/",
4378
- ...options
4379
- });
4380
- }
4381
- /**
4382
- * Delete a TOTP device.
4383
- *
4384
- * Requires verification code if removing the last/primary device.
4385
- */
4386
- static cfgTotpDevicesDestroy(options) {
4387
- return (options.client ?? client3).delete({
4388
- security: [{ scheme: "bearer", type: "http" }],
4389
- url: "/cfg/totp/devices/{id}/",
4390
- ...options
4391
- });
4392
- }
4393
- /**
4394
- * Completely disable 2FA for account.
4395
- *
4396
- * Requires verification code.
4397
- */
4398
- static cfgTotpDisableCreate(options) {
4399
- return (options.client ?? client3).post({
4400
- security: [{ scheme: "bearer", type: "http" }],
4401
- url: "/cfg/totp/disable/",
4402
- ...options,
4403
- headers: {
4404
- "Content-Type": "application/json",
4405
- ...options.headers
4406
- }
4407
- });
4408
- }
4409
- /**
4410
- * Start 2FA setup process.
4411
- *
4412
- * Creates a new TOTP device and returns QR code for scanning.
4413
- */
4414
- static cfgTotpSetupCreate(options) {
4415
- return (options?.client ?? client3).post({
4416
- security: [{ scheme: "bearer", type: "http" }],
4417
- url: "/cfg/totp/setup/",
4418
- ...options,
4419
- headers: {
4420
- "Content-Type": "application/json",
4421
- ...options?.headers
4422
- }
4423
- });
4424
- }
4425
- /**
4426
- * Confirm 2FA setup with first valid code.
4427
- *
4428
- * Activates the device and generates backup codes.
4429
- */
4430
- static cfgTotpSetupConfirmCreate(options) {
4431
- return (options.client ?? client3).post({
4432
- security: [{ scheme: "bearer", type: "http" }],
4433
- url: "/cfg/totp/setup/confirm/",
4434
- ...options,
4435
- headers: {
4436
- "Content-Type": "application/json",
4437
- ...options.headers
4438
- }
4439
- });
4440
- }
4441
- /**
4442
- * Verify TOTP code for 2FA session.
4443
- *
4444
- * Completes authentication and returns JWT tokens on success.
4445
- */
4446
- static cfgTotpVerifyCreate(options) {
4447
- return (options.client ?? client3).post({
4448
- security: [{ scheme: "bearer", type: "http" }],
4449
- url: "/cfg/totp/verify/",
4450
- ...options,
4451
- headers: {
4452
- "Content-Type": "application/json",
4453
- ...options.headers
4454
- }
4455
- });
4456
- }
4457
- /**
4458
- * Verify backup recovery code for 2FA session.
4459
- *
4460
- * Alternative verification method when TOTP device unavailable.
4461
- */
4462
- static cfgTotpVerifyBackupCreate(options) {
4463
- return (options.client ?? client3).post({
4464
- security: [{ scheme: "bearer", type: "http" }],
4465
- url: "/cfg/totp/verify/backup/",
4466
- ...options,
4467
- headers: {
4468
- "Content-Type": "application/json",
4469
- ...options.headers
4470
- }
4471
- });
4472
- }
4473
- };
4474
- var BackupCodes = class {
4475
- static {
4476
- __name(this, "BackupCodes");
4477
- }
4478
- /**
4479
- * Get backup codes status for user.
4480
- */
4481
- static cfgTotpBackupCodesRetrieve(options) {
4482
- return (options?.client ?? client3).get({
4483
- security: [{ scheme: "bearer", type: "http" }],
4484
- url: "/cfg/totp/backup-codes/",
4485
- ...options
4486
- });
4487
- }
2275
+ };
2276
+ var Auth = class {
2277
+ static {
2278
+ __name(this, "Auth");
2279
+ }
4488
2280
  /**
4489
- * Regenerate backup codes.
4490
- *
4491
- * Requires TOTP code for verification.
4492
- * Invalidates all existing codes.
2281
+ * Refresh JWT token.
4493
2282
  */
4494
- static cfgTotpBackupCodesRegenerateCreate(options) {
4495
- return (options.client ?? client3).post({
4496
- security: [{ scheme: "bearer", type: "http" }],
4497
- url: "/cfg/totp/backup-codes/regenerate/",
2283
+ static cfgAccountsTokenRefreshCreate(options) {
2284
+ return (options.client ?? client).post({
2285
+ url: "/cfg/accounts/token/refresh/",
4498
2286
  ...options,
4499
2287
  headers: {
4500
2288
  "Content-Type": "application/json",
@@ -4511,7 +2299,7 @@ var TotpManagement = class {
4511
2299
  * List all TOTP devices for user.
4512
2300
  */
4513
2301
  static cfgTotpDevicesRetrieve(options) {
4514
- return (options?.client ?? client3).get({
2302
+ return (options?.client ?? client).get({
4515
2303
  security: [{ scheme: "bearer", type: "http" }],
4516
2304
  url: "/cfg/totp/devices/",
4517
2305
  ...options
@@ -4523,7 +2311,7 @@ var TotpManagement = class {
4523
2311
  * Requires verification code.
4524
2312
  */
4525
2313
  static cfgTotpDisableCreate(options) {
4526
- return (options.client ?? client3).post({
2314
+ return (options.client ?? client).post({
4527
2315
  security: [{ scheme: "bearer", type: "http" }],
4528
2316
  url: "/cfg/totp/disable/",
4529
2317
  ...options,
@@ -4544,7 +2332,7 @@ var TotpSetup = class {
4544
2332
  * Creates a new TOTP device and returns QR code for scanning.
4545
2333
  */
4546
2334
  static cfgTotpSetupCreate(options) {
4547
- return (options?.client ?? client3).post({
2335
+ return (options?.client ?? client).post({
4548
2336
  security: [{ scheme: "bearer", type: "http" }],
4549
2337
  url: "/cfg/totp/setup/",
4550
2338
  ...options,
@@ -4560,7 +2348,7 @@ var TotpSetup = class {
4560
2348
  * Activates the device and generates backup codes.
4561
2349
  */
4562
2350
  static cfgTotpSetupConfirmCreate(options) {
4563
- return (options.client ?? client3).post({
2351
+ return (options.client ?? client).post({
4564
2352
  security: [{ scheme: "bearer", type: "http" }],
4565
2353
  url: "/cfg/totp/setup/confirm/",
4566
2354
  ...options,
@@ -4581,7 +2369,7 @@ var TotpVerification = class {
4581
2369
  * Completes authentication and returns JWT tokens on success.
4582
2370
  */
4583
2371
  static cfgTotpVerifyCreate(options) {
4584
- return (options.client ?? client3).post({
2372
+ return (options.client ?? client).post({
4585
2373
  security: [{ scheme: "bearer", type: "http" }],
4586
2374
  url: "/cfg/totp/verify/",
4587
2375
  ...options,
@@ -4597,7 +2385,7 @@ var TotpVerification = class {
4597
2385
  * Alternative verification method when TOTP device unavailable.
4598
2386
  */
4599
2387
  static cfgTotpVerifyBackupCreate(options) {
4600
- return (options.client ?? client3).post({
2388
+ return (options.client ?? client).post({
4601
2389
  security: [{ scheme: "bearer", type: "http" }],
4602
2390
  url: "/cfg/totp/verify/backup/",
4603
2391
  ...options,
@@ -4609,275 +2397,6 @@ var TotpVerification = class {
4609
2397
  }
4610
2398
  };
4611
2399
 
4612
- // src/_api/generated/cfg_totp/schemas/BackupCodesRegenerateRequest.ts
4613
- var import_zod23 = require("zod");
4614
- var BackupCodesRegenerateRequestSchema = import_zod23.z.object({
4615
- code: import_zod23.z.string().min(6).max(6)
4616
- });
4617
-
4618
- // src/_api/generated/cfg_totp/schemas/BackupCodesRegenerateResponse.ts
4619
- var import_zod24 = require("zod");
4620
- var BackupCodesRegenerateResponseSchema = import_zod24.z.object({
4621
- backup_codes: import_zod24.z.array(import_zod24.z.string()),
4622
- warning: import_zod24.z.string()
4623
- });
4624
-
4625
- // src/_api/generated/cfg_totp/schemas/BackupCodesStatus.ts
4626
- var import_zod25 = require("zod");
4627
- var BackupCodesStatusSchema = import_zod25.z.object({
4628
- remaining_count: import_zod25.z.number().int(),
4629
- total_generated: import_zod25.z.number().int(),
4630
- warning: import_zod25.z.string().nullable().optional()
4631
- });
4632
-
4633
- // src/_api/generated/cfg_totp/schemas/ConfirmSetupRequest.ts
4634
- var import_zod26 = require("zod");
4635
- var ConfirmSetupRequestSchema = import_zod26.z.object({
4636
- device_id: import_zod26.z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
4637
- code: import_zod26.z.string().min(6).max(6)
4638
- });
4639
-
4640
- // src/_api/generated/cfg_totp/schemas/ConfirmSetupResponse.ts
4641
- var import_zod27 = require("zod");
4642
- var ConfirmSetupResponseSchema = import_zod27.z.object({
4643
- message: import_zod27.z.string(),
4644
- backup_codes: import_zod27.z.array(import_zod27.z.string()),
4645
- backup_codes_warning: import_zod27.z.string()
4646
- });
4647
-
4648
- // src/_api/generated/cfg_totp/schemas/DeviceList.ts
4649
- var import_zod29 = require("zod");
4650
-
4651
- // src/_api/generated/cfg_totp/schemas/DeviceListStatusEnum.ts
4652
- var import_zod28 = require("zod");
4653
- var DeviceListStatusEnumSchema = import_zod28.z.enum(["pending", "active", "disabled"]);
4654
-
4655
- // src/_api/generated/cfg_totp/schemas/DeviceList.ts
4656
- var DeviceListSchema = import_zod29.z.object({
4657
- id: import_zod29.z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
4658
- name: import_zod29.z.string(),
4659
- is_primary: import_zod29.z.boolean(),
4660
- status: DeviceListStatusEnumSchema,
4661
- created_at: import_zod29.z.string().datetime({ offset: true }),
4662
- confirmed_at: import_zod29.z.string().datetime({ offset: true }).nullable(),
4663
- last_used_at: import_zod29.z.string().datetime({ offset: true }).nullable()
4664
- });
4665
-
4666
- // src/_api/generated/cfg_totp/schemas/DeviceListResponse.ts
4667
- var import_zod30 = require("zod");
4668
- var DeviceListResponseSchema = import_zod30.z.object({
4669
- devices: import_zod30.z.array(DeviceListSchema),
4670
- has_2fa_enabled: import_zod30.z.boolean()
4671
- });
4672
-
4673
- // src/_api/generated/cfg_totp/schemas/DisableRequest.ts
4674
- var import_zod31 = require("zod");
4675
- var DisableRequestSchema = import_zod31.z.object({
4676
- code: import_zod31.z.string().min(6).max(6)
4677
- });
4678
-
4679
- // src/_api/generated/cfg_totp/schemas/SetupRequest.ts
4680
- var import_zod32 = require("zod");
4681
- var SetupRequestSchema = import_zod32.z.object({
4682
- device_name: import_zod32.z.string().min(1).max(100).optional()
4683
- });
4684
-
4685
- // src/_api/generated/cfg_totp/schemas/SetupResponse.ts
4686
- var import_zod33 = require("zod");
4687
- var SetupResponseSchema = import_zod33.z.object({
4688
- device_id: import_zod33.z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
4689
- secret: import_zod33.z.string(),
4690
- provisioning_uri: import_zod33.z.string(),
4691
- qr_code_base64: import_zod33.z.string(),
4692
- expires_in: import_zod33.z.number().int()
4693
- });
4694
-
4695
- // src/_api/generated/cfg_totp/schemas/TotpVerifyUser.ts
4696
- var import_zod34 = require("zod");
4697
- var TotpVerifyUserSchema = import_zod34.z.object({
4698
- id: import_zod34.z.number().int(),
4699
- email: import_zod34.z.email(),
4700
- first_name: import_zod34.z.string().max(50).optional(),
4701
- last_name: import_zod34.z.string().max(50).optional(),
4702
- full_name: import_zod34.z.string(),
4703
- initials: import_zod34.z.string(),
4704
- display_username: import_zod34.z.string(),
4705
- company: import_zod34.z.string().max(100).optional(),
4706
- phone: import_zod34.z.string().max(20).optional(),
4707
- position: import_zod34.z.string().max(100).optional(),
4708
- language: import_zod34.z.string().max(10).optional(),
4709
- avatar: import_zod34.z.string().nullable(),
4710
- is_staff: import_zod34.z.boolean(),
4711
- is_superuser: import_zod34.z.boolean(),
4712
- date_joined: import_zod34.z.string().datetime({ offset: true }),
4713
- last_login: import_zod34.z.string().datetime({ offset: true }).nullable(),
4714
- unanswered_messages_count: import_zod34.z.number().int()
4715
- });
4716
-
4717
- // src/_api/generated/cfg_totp/schemas/VerifyBackupRequest.ts
4718
- var import_zod35 = require("zod");
4719
- var VerifyBackupRequestSchema = import_zod35.z.object({
4720
- session_id: import_zod35.z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
4721
- backup_code: import_zod35.z.string().min(8).max(8)
4722
- });
4723
-
4724
- // src/_api/generated/cfg_totp/schemas/VerifyRequest.ts
4725
- var import_zod36 = require("zod");
4726
- var VerifyRequestSchema = import_zod36.z.object({
4727
- session_id: import_zod36.z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
4728
- code: import_zod36.z.string().min(6).max(6)
4729
- });
4730
-
4731
- // src/_api/generated/cfg_totp/schemas/VerifyResponse.ts
4732
- var import_zod37 = require("zod");
4733
- var VerifyResponseSchema = import_zod37.z.object({
4734
- message: import_zod37.z.string(),
4735
- access_token: import_zod37.z.string(),
4736
- refresh_token: import_zod37.z.string(),
4737
- user: TotpVerifyUserSchema,
4738
- remaining_backup_codes: import_zod37.z.number().int().optional(),
4739
- warning: import_zod37.z.string().optional()
4740
- });
4741
-
4742
- // src/_api/generated/cfg_totp/api.ts
4743
- var ACCESS_KEY3 = "cfg.access_token";
4744
- var REFRESH_KEY3 = "cfg.refresh_token";
4745
- var VALIDATION_ROUTES3 = [
4746
- { method: "GET", re: new RegExp("^/cfg/totp/backup\\-codes/?$"), schema: BackupCodesStatusSchema, path: "/cfg/totp/backup-codes/" },
4747
- { method: "POST", re: new RegExp("^/cfg/totp/backup\\-codes/regenerate/?$"), schema: BackupCodesRegenerateResponseSchema, path: "/cfg/totp/backup-codes/regenerate/" },
4748
- { method: "GET", re: new RegExp("^/cfg/totp/devices/?$"), schema: DeviceListResponseSchema, path: "/cfg/totp/devices/" },
4749
- { method: "POST", re: new RegExp("^/cfg/totp/setup/?$"), schema: SetupResponseSchema, path: "/cfg/totp/setup/" },
4750
- { method: "POST", re: new RegExp("^/cfg/totp/setup/confirm/?$"), schema: ConfirmSetupResponseSchema, path: "/cfg/totp/setup/confirm/" },
4751
- { method: "POST", re: new RegExp("^/cfg/totp/verify/?$"), schema: VerifyResponseSchema, path: "/cfg/totp/verify/" },
4752
- { method: "POST", re: new RegExp("^/cfg/totp/verify/backup/?$"), schema: VerifyResponseSchema, path: "/cfg/totp/verify/backup/" }
4753
- ];
4754
- function detectLocale3() {
4755
- try {
4756
- if (typeof document !== "undefined") {
4757
- const m = document.cookie.match(/(?:^|;\s*)NEXT_LOCALE=([^;]*)/);
4758
- if (m) return decodeURIComponent(m[1]);
4759
- }
4760
- if (typeof navigator !== "undefined" && navigator.language) {
4761
- return navigator.language;
4762
- }
4763
- } catch {
4764
- }
4765
- return null;
4766
- }
4767
- __name(detectLocale3, "detectLocale");
4768
- var API3 = class {
4769
- static {
4770
- __name(this, "API");
4771
- }
4772
- baseUrl;
4773
- storage;
4774
- locale;
4775
- apiKey;
4776
- logger;
4777
- cfg = Cfg3;
4778
- totp = Totp;
4779
- backupCodes = BackupCodes;
4780
- totpManagement = TotpManagement;
4781
- totpSetup = TotpSetup;
4782
- totpVerification = TotpVerification;
4783
- constructor(baseUrl2, opts = {}) {
4784
- this.baseUrl = baseUrl2.replace(/\/$/, "");
4785
- this.storage = opts.storage ?? new LocalStorageAdapter();
4786
- this.logger = new APILogger(opts.logger);
4787
- this.locale = opts.locale ?? null;
4788
- this.apiKey = opts.apiKey ?? (typeof process !== "undefined" ? process.env?.NEXT_PUBLIC_API_KEY ?? null : null);
4789
- const credentials = opts.withCredentials ?? true ? "include" : "same-origin";
4790
- client3.setConfig({ baseUrl: this.baseUrl, credentials });
4791
- client3.interceptors.request.use((request) => {
4792
- const access = this.getToken();
4793
- if (access) request.headers.set("Authorization", `Bearer ${access}`);
4794
- const locale = this.locale ?? detectLocale3();
4795
- if (locale) request.headers.set("Accept-Language", locale);
4796
- if (this.apiKey) request.headers.set("X-API-Key", this.apiKey);
4797
- return request;
4798
- });
4799
- client3.interceptors.response.use(async (response, request) => {
4800
- if (!response.ok) return response;
4801
- const ct = response.headers.get("content-type") || "";
4802
- if (!ct.includes("application/json")) return response;
4803
- const url = new URL(request.url);
4804
- const method = request.method.toUpperCase();
4805
- const route = VALIDATION_ROUTES3.find(
4806
- (r) => r.method === method && r.re.test(url.pathname)
4807
- );
4808
- if (!route) return response;
4809
- let payload;
4810
- try {
4811
- payload = await response.clone().json();
4812
- } catch {
4813
- return response;
4814
- }
4815
- const result = route.schema.safeParse(payload);
4816
- if (!result.success) {
4817
- dispatchValidationError({
4818
- operation: `${method} ${route.path}`,
4819
- path: route.path,
4820
- method,
4821
- error: result.error,
4822
- response: payload,
4823
- timestamp: /* @__PURE__ */ new Date()
4824
- });
4825
- }
4826
- return response;
4827
- });
4828
- }
4829
- // ── Base URL ────────────────────────────────────────────────────────────
4830
- getBaseUrl() {
4831
- return this.baseUrl;
4832
- }
4833
- setBaseUrl(url) {
4834
- this.baseUrl = url.replace(/\/$/, "");
4835
- client3.setConfig({ baseUrl: this.baseUrl });
4836
- }
4837
- // ── Tokens ──────────────────────────────────────────────────────────────
4838
- getToken() {
4839
- return this.storage.getItem(ACCESS_KEY3);
4840
- }
4841
- setToken(token) {
4842
- if (token) this.storage.setItem(ACCESS_KEY3, token);
4843
- else this.storage.removeItem(ACCESS_KEY3);
4844
- }
4845
- getRefreshToken() {
4846
- return this.storage.getItem(REFRESH_KEY3);
4847
- }
4848
- setRefreshToken(token) {
4849
- if (token) this.storage.setItem(REFRESH_KEY3, token);
4850
- else this.storage.removeItem(REFRESH_KEY3);
4851
- }
4852
- clearToken() {
4853
- this.storage.removeItem(ACCESS_KEY3);
4854
- this.storage.removeItem(REFRESH_KEY3);
4855
- }
4856
- isAuthenticated() {
4857
- return this.getToken() !== null;
4858
- }
4859
- // ── Locale / API key ────────────────────────────────────────────────────
4860
- getLocale() {
4861
- return this.locale ?? detectLocale3();
4862
- }
4863
- setLocale(locale) {
4864
- this.locale = locale;
4865
- }
4866
- getApiKey() {
4867
- return this.apiKey;
4868
- }
4869
- setApiKey(key) {
4870
- this.apiKey = key;
4871
- }
4872
- };
4873
-
4874
- // src/_api/generated/index.ts
4875
- var isStaticBuild2 = process.env.NEXT_PUBLIC_STATIC_BUILD === "true";
4876
- var baseUrl = isStaticBuild2 ? "" : process.env.NEXT_PUBLIC_API_URL || "";
4877
- var cfgAccountsApi = new API(baseUrl, { storage: new LocalStorageAdapter() });
4878
- var cfgCentrifugoApi = new API2(baseUrl, { storage: new LocalStorageAdapter() });
4879
- var cfgTotpApi = new API3(baseUrl, { storage: new LocalStorageAdapter() });
4880
-
4881
2400
  // src/auth/utils/analytics.ts
4882
2401
  var AnalyticsEvent = /* @__PURE__ */ ((AnalyticsEvent2) => {
4883
2402
  AnalyticsEvent2["AUTH_OTP_REQUEST"] = "auth_otp_request";
@@ -4927,8 +2446,8 @@ var useTwoFactor = /* @__PURE__ */ __name((options = {}) => {
4927
2446
  setError(null);
4928
2447
  }, []);
4929
2448
  const handleSuccess = (0, import_react6.useCallback)((response) => {
4930
- cfgAccountsApi.setToken(response.access_token);
4931
- cfgAccountsApi.setRefreshToken(response.refresh_token);
2449
+ CfgAccountsApi.setToken(response.access_token);
2450
+ CfgAccountsApi.setRefreshToken(response.refresh_token);
4932
2451
  if (response.warning) {
4933
2452
  setWarning(response.warning);
4934
2453
  }
@@ -4966,7 +2485,7 @@ var useTwoFactor = /* @__PURE__ */ __name((options = {}) => {
4966
2485
  setError(null);
4967
2486
  try {
4968
2487
  authLogger.info("Verifying TOTP code...");
4969
- const result = await cfgTotpApi.totpVerification.cfgTotpVerifyCreate({
2488
+ const result = await TotpVerification.cfgTotpVerifyCreate({
4970
2489
  body: { session_id: sessionId, code },
4971
2490
  throwOnError: true
4972
2491
  });
@@ -5010,7 +2529,7 @@ var useTwoFactor = /* @__PURE__ */ __name((options = {}) => {
5010
2529
  setError(null);
5011
2530
  try {
5012
2531
  authLogger.info("Verifying backup code...");
5013
- const result = await cfgTotpApi.totpVerification.cfgTotpVerifyBackupCreate({
2532
+ const result = await TotpVerification.cfgTotpVerifyBackupCreate({
5014
2533
  body: {
5015
2534
  session_id: sessionId,
5016
2535
  backup_code: backupCode.replace(/\s+/g, "")
@@ -5354,7 +2873,7 @@ var useGithubAuth = /* @__PURE__ */ __name((options = {}) => {
5354
2873
  category: "auth" /* AUTH */,
5355
2874
  label: "github"
5356
2875
  });
5357
- const result = await cfgAccountsApi.oAuth.cfgAccountsOauthGithubAuthorizeCreate({
2876
+ const result = await OAuth.cfgAccountsOauthGithubAuthorizeCreate({
5358
2877
  body: {
5359
2878
  source_url: sourceUrl || (typeof window !== "undefined" ? window.location.href : "")
5360
2879
  },
@@ -5396,7 +2915,7 @@ var useGithubAuth = /* @__PURE__ */ __name((options = {}) => {
5396
2915
  sessionStorage.removeItem("oauth_state");
5397
2916
  sessionStorage.removeItem("oauth_provider");
5398
2917
  }
5399
- const result = await cfgAccountsApi.oAuth.cfgAccountsOauthGithubCallbackCreate({
2918
+ const result = await OAuth.cfgAccountsOauthGithubCallbackCreate({
5400
2919
  body: { code, state },
5401
2920
  throwOnError: true
5402
2921
  });
@@ -5414,8 +2933,8 @@ var useGithubAuth = /* @__PURE__ */ __name((options = {}) => {
5414
2933
  throw new Error("Invalid response from OAuth callback");
5415
2934
  }
5416
2935
  authLogger.info("GitHub OAuth successful, user:", response.user);
5417
- cfgAccountsApi.setToken(response.access);
5418
- cfgAccountsApi.setRefreshToken(response.refresh);
2936
+ CfgAccountsApi.setToken(response.access);
2937
+ CfgAccountsApi.setRefreshToken(response.refresh);
5419
2938
  Analytics.event("auth_login_success" /* AUTH_LOGIN_SUCCESS */, {
5420
2939
  category: "auth" /* AUTH */,
5421
2940
  label: "github"
@@ -5475,7 +2994,7 @@ var useTwoFactorSetup = /* @__PURE__ */ __name((options = {}) => {
5475
2994
  setSetupStep("scanning");
5476
2995
  try {
5477
2996
  authLogger.info("Starting 2FA setup...");
5478
- const result = await cfgTotpApi.totpSetup.cfgTotpSetupCreate({
2997
+ const result = await TotpSetup.cfgTotpSetupCreate({
5479
2998
  body: { device_name: deviceName },
5480
2999
  throwOnError: true
5481
3000
  });
@@ -5519,7 +3038,7 @@ var useTwoFactorSetup = /* @__PURE__ */ __name((options = {}) => {
5519
3038
  setSetupStep("confirming");
5520
3039
  try {
5521
3040
  authLogger.info("Confirming 2FA setup...");
5522
- const result = await cfgTotpApi.totpSetup.cfgTotpSetupConfirmCreate({
3041
+ const result = await TotpSetup.cfgTotpSetupConfirmCreate({
5523
3042
  body: { device_id: setupData.deviceId, code },
5524
3043
  throwOnError: true
5525
3044
  });
@@ -5582,7 +3101,7 @@ var useTwoFactorStatus = /* @__PURE__ */ __name(() => {
5582
3101
  setError(null);
5583
3102
  try {
5584
3103
  authLogger.info("Fetching 2FA status...");
5585
- const result = await cfgTotpApi.totpManagement.cfgTotpDevicesRetrieve({ throwOnError: true });
3104
+ const result = await TotpManagement.cfgTotpDevicesRetrieve({ throwOnError: true });
5586
3105
  const response = result.data;
5587
3106
  const mappedDevices = response.devices.map((device) => ({
5588
3107
  id: device.id,
@@ -5611,7 +3130,7 @@ var useTwoFactorStatus = /* @__PURE__ */ __name(() => {
5611
3130
  setError(null);
5612
3131
  try {
5613
3132
  authLogger.info("Disabling 2FA...");
5614
- await cfgTotpApi.totpManagement.cfgTotpDisableCreate({ body: { code }, throwOnError: true });
3133
+ await TotpManagement.cfgTotpDisableCreate({ body: { code }, throwOnError: true });
5615
3134
  setHas2FAEnabled(false);
5616
3135
  setDevices([]);
5617
3136
  authLogger.info("2FA disabled successfully");
@@ -6182,7 +3701,7 @@ function useTokenRefresh(options = {}) {
6182
3701
  authLogger.debug("Token refresh already in progress");
6183
3702
  return false;
6184
3703
  }
6185
- const refreshTokenValue = cfgAccountsApi.getRefreshToken();
3704
+ const refreshTokenValue = CfgAccountsApi.getRefreshToken();
6186
3705
  if (!refreshTokenValue) {
6187
3706
  authLogger.warn("No refresh token available");
6188
3707
  return false;
@@ -6190,7 +3709,7 @@ function useTokenRefresh(options = {}) {
6190
3709
  isRefreshingRef.current = true;
6191
3710
  authLogger.info("Refreshing token...");
6192
3711
  try {
6193
- const result = await cfgAccountsApi.auth.cfgAccountsTokenRefreshCreate({
3712
+ const result = await Auth.cfgAccountsTokenRefreshCreate({
6194
3713
  body: { refresh: refreshTokenValue },
6195
3714
  throwOnError: true
6196
3715
  });
@@ -6198,8 +3717,8 @@ function useTokenRefresh(options = {}) {
6198
3717
  if (!newAccessToken) {
6199
3718
  throw new Error("No access token in refresh response");
6200
3719
  }
6201
- cfgAccountsApi.setToken(newAccessToken);
6202
- cfgAccountsApi.setRefreshToken(refreshTokenValue);
3720
+ CfgAccountsApi.setToken(newAccessToken);
3721
+ CfgAccountsApi.setRefreshToken(refreshTokenValue);
6203
3722
  authLogger.info("Token refreshed successfully");
6204
3723
  onRefresh?.(newAccessToken);
6205
3724
  return true;
@@ -6212,7 +3731,7 @@ function useTokenRefresh(options = {}) {
6212
3731
  }
6213
3732
  }, [onRefresh, onRefreshError]);
6214
3733
  const checkAndRefresh = (0, import_react14.useCallback)(async () => {
6215
- const token = cfgAccountsApi.getToken();
3734
+ const token = CfgAccountsApi.getToken();
6216
3735
  if (!token) return;
6217
3736
  if (isTokenExpiringSoon(token, TOKEN_REFRESH_THRESHOLD_MS)) {
6218
3737
  authLogger.info("Token expiring soon, refreshing proactively");
@@ -6264,7 +3783,7 @@ var useDeleteAccount = /* @__PURE__ */ __name(() => {
6264
3783
  setError(null);
6265
3784
  try {
6266
3785
  authLogger.info("Deleting account...");
6267
- const result = await cfgAccountsApi.userProfile.cfgAccountsProfileDeleteCreate({ throwOnError: true });
3786
+ const result = await UserProfile.cfgAccountsProfileDeleteCreate({ throwOnError: true });
6268
3787
  const response = result.data;
6269
3788
  if (!response.success) {
6270
3789
  authLogger.error("Failed to delete account:", response.message);
@@ -6291,22 +3810,22 @@ var useDeleteAccount = /* @__PURE__ */ __name(() => {
6291
3810
  // src/auth/context/AccountsContext.tsx
6292
3811
  var import_react16 = require("react");
6293
3812
 
6294
- // src/_api/generated/cfg_accounts/hooks/useCfgAccountsOauthConnectionsList.ts
3813
+ // src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthConnectionsList.ts
6295
3814
  var import_swr = __toESM(require("swr"), 1);
6296
3815
 
6297
- // src/_api/generated/cfg_accounts/hooks/useCfgAccountsOauthDisconnectCreate.ts
3816
+ // src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthDisconnectCreate.ts
6298
3817
  var import_mutation = __toESM(require("swr/mutation"), 1);
6299
3818
 
6300
- // src/_api/generated/cfg_accounts/hooks/useCfgAccountsOauthGithubAuthorizeCreate.ts
3819
+ // src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthGithubAuthorizeCreate.ts
6301
3820
  var import_mutation2 = __toESM(require("swr/mutation"), 1);
6302
3821
 
6303
- // src/_api/generated/cfg_accounts/hooks/useCfgAccountsOauthGithubCallbackCreate.ts
3822
+ // src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthGithubCallbackCreate.ts
6304
3823
  var import_mutation3 = __toESM(require("swr/mutation"), 1);
6305
3824
 
6306
- // src/_api/generated/cfg_accounts/hooks/useCfgAccountsOauthProvidersRetrieve.ts
3825
+ // src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthProvidersRetrieve.ts
6307
3826
  var import_swr2 = __toESM(require("swr"), 1);
6308
3827
 
6309
- // src/_api/generated/cfg_accounts/hooks/useCfgAccountsOtpRequestCreate.ts
3828
+ // src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOtpRequestCreate.ts
6310
3829
  var import_mutation4 = __toESM(require("swr/mutation"), 1);
6311
3830
  function useCfgAccountsOtpRequestCreate(config) {
6312
3831
  return (0, import_mutation4.default)(
@@ -6320,7 +3839,7 @@ function useCfgAccountsOtpRequestCreate(config) {
6320
3839
  }
6321
3840
  __name(useCfgAccountsOtpRequestCreate, "useCfgAccountsOtpRequestCreate");
6322
3841
 
6323
- // src/_api/generated/cfg_accounts/hooks/useCfgAccountsOtpVerifyCreate.ts
3842
+ // src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOtpVerifyCreate.ts
6324
3843
  var import_mutation5 = __toESM(require("swr/mutation"), 1);
6325
3844
  function useCfgAccountsOtpVerifyCreate(config) {
6326
3845
  return (0, import_mutation5.default)(
@@ -6334,7 +3853,7 @@ function useCfgAccountsOtpVerifyCreate(config) {
6334
3853
  }
6335
3854
  __name(useCfgAccountsOtpVerifyCreate, "useCfgAccountsOtpVerifyCreate");
6336
3855
 
6337
- // src/_api/generated/cfg_accounts/hooks/useCfgAccountsProfileAvatarCreate.ts
3856
+ // src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileAvatarCreate.ts
6338
3857
  var import_mutation6 = __toESM(require("swr/mutation"), 1);
6339
3858
  function useCfgAccountsProfileAvatarCreate(config) {
6340
3859
  return (0, import_mutation6.default)(
@@ -6348,13 +3867,13 @@ function useCfgAccountsProfileAvatarCreate(config) {
6348
3867
  }
6349
3868
  __name(useCfgAccountsProfileAvatarCreate, "useCfgAccountsProfileAvatarCreate");
6350
3869
 
6351
- // src/_api/generated/cfg_accounts/hooks/useCfgAccountsProfileDeleteCreate.ts
3870
+ // src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileDeleteCreate.ts
6352
3871
  var import_mutation7 = __toESM(require("swr/mutation"), 1);
6353
3872
 
6354
- // src/_api/generated/cfg_accounts/hooks/useCfgAccountsProfilePartialPartialUpdate.ts
3873
+ // src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfilePartialPartialUpdate.ts
6355
3874
  var import_mutation8 = __toESM(require("swr/mutation"), 1);
6356
3875
 
6357
- // src/_api/generated/cfg_accounts/hooks/useCfgAccountsProfilePartialUpdate.ts
3876
+ // src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfilePartialUpdate.ts
6358
3877
  var import_mutation9 = __toESM(require("swr/mutation"), 1);
6359
3878
  function useCfgAccountsProfilePartialUpdate(config) {
6360
3879
  return (0, import_mutation9.default)(
@@ -6368,13 +3887,13 @@ function useCfgAccountsProfilePartialUpdate(config) {
6368
3887
  }
6369
3888
  __name(useCfgAccountsProfilePartialUpdate, "useCfgAccountsProfilePartialUpdate");
6370
3889
 
6371
- // src/_api/generated/cfg_accounts/hooks/useCfgAccountsProfileRetrieve.ts
3890
+ // src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileRetrieve.ts
6372
3891
  var import_swr3 = __toESM(require("swr"), 1);
6373
3892
 
6374
- // src/_api/generated/cfg_accounts/hooks/useCfgAccountsProfileUpdatePartialUpdate.ts
3893
+ // src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileUpdatePartialUpdate.ts
6375
3894
  var import_mutation10 = __toESM(require("swr/mutation"), 1);
6376
3895
 
6377
- // src/_api/generated/cfg_accounts/hooks/useCfgAccountsProfileUpdateUpdate.ts
3896
+ // src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileUpdateUpdate.ts
6378
3897
  var import_mutation11 = __toESM(require("swr/mutation"), 1);
6379
3898
  function useCfgAccountsProfileUpdateUpdate(config) {
6380
3899
  return (0, import_mutation11.default)(
@@ -6388,7 +3907,7 @@ function useCfgAccountsProfileUpdateUpdate(config) {
6388
3907
  }
6389
3908
  __name(useCfgAccountsProfileUpdateUpdate, "useCfgAccountsProfileUpdateUpdate");
6390
3909
 
6391
- // src/_api/generated/cfg_accounts/hooks/useCfgAccountsTokenRefreshCreate.ts
3910
+ // src/_api/generated/_cfg_accounts/hooks/useCfgAccountsTokenRefreshCreate.ts
6392
3911
  var import_mutation12 = __toESM(require("swr/mutation"), 1);
6393
3912
  function useCfgAccountsTokenRefreshCreate(config) {
6394
3913
  return (0, import_mutation12.default)(
@@ -6402,6 +3921,195 @@ function useCfgAccountsTokenRefreshCreate(config) {
6402
3921
  }
6403
3922
  __name(useCfgAccountsTokenRefreshCreate, "useCfgAccountsTokenRefreshCreate");
6404
3923
 
3924
+ // src/_api/generated/_cfg_accounts/schemas/AccountDeleteResponse.ts
3925
+ var import_zod = require("zod");
3926
+ var AccountDeleteResponseSchema = import_zod.z.object({
3927
+ message: import_zod.z.string(),
3928
+ success: import_zod.z.boolean()
3929
+ });
3930
+
3931
+ // src/_api/generated/_cfg_accounts/schemas/CentrifugoToken.ts
3932
+ var import_zod2 = require("zod");
3933
+ var CentrifugoTokenSchema = import_zod2.z.object({
3934
+ centrifugo_url: import_zod2.z.string(),
3935
+ channels: import_zod2.z.array(import_zod2.z.string()),
3936
+ expires_at: import_zod2.z.string().datetime({ offset: true }),
3937
+ token: import_zod2.z.string()
3938
+ });
3939
+
3940
+ // src/_api/generated/_cfg_accounts/schemas/CfgUserUpdateRequest.ts
3941
+ var import_zod3 = require("zod");
3942
+ var CfgUserUpdateRequestSchema = import_zod3.z.object({
3943
+ company: import_zod3.z.string().max(100).optional(),
3944
+ first_name: import_zod3.z.string().max(50).optional(),
3945
+ language: import_zod3.z.string().max(10).optional(),
3946
+ last_name: import_zod3.z.string().max(50).optional(),
3947
+ phone: import_zod3.z.string().max(20).optional(),
3948
+ position: import_zod3.z.string().max(100).optional()
3949
+ });
3950
+
3951
+ // src/_api/generated/_cfg_accounts/schemas/OAuthAuthorizeRequestRequest.ts
3952
+ var import_zod4 = require("zod");
3953
+ var OAuthAuthorizeRequestRequestSchema = import_zod4.z.object({
3954
+ redirect_uri: import_zod4.z.string().optional(),
3955
+ source_url: import_zod4.z.string().optional()
3956
+ });
3957
+
3958
+ // src/_api/generated/_cfg_accounts/schemas/OAuthAuthorizeResponse.ts
3959
+ var import_zod5 = require("zod");
3960
+ var OAuthAuthorizeResponseSchema = import_zod5.z.object({
3961
+ authorization_url: import_zod5.z.string(),
3962
+ state: import_zod5.z.string()
3963
+ });
3964
+
3965
+ // src/_api/generated/_cfg_accounts/schemas/OAuthCallbackRequestRequest.ts
3966
+ var import_zod6 = require("zod");
3967
+ var OAuthCallbackRequestRequestSchema = import_zod6.z.object({
3968
+ code: import_zod6.z.string().min(10).max(500),
3969
+ redirect_uri: import_zod6.z.string().optional(),
3970
+ state: import_zod6.z.string().min(20).max(100)
3971
+ });
3972
+
3973
+ // src/_api/generated/_cfg_accounts/schemas/OAuthConnection.ts
3974
+ var import_zod8 = require("zod");
3975
+
3976
+ // src/_api/generated/_cfg_accounts/schemas/ProviderEnum.ts
3977
+ var import_zod7 = require("zod");
3978
+ var ProviderEnumSchema = import_zod7.z.enum(["github"]);
3979
+
3980
+ // src/_api/generated/_cfg_accounts/schemas/OAuthConnection.ts
3981
+ var OAuthConnectionSchema = import_zod8.z.object({
3982
+ connected_at: import_zod8.z.string().datetime({ offset: true }),
3983
+ id: import_zod8.z.number().int(),
3984
+ last_login_at: import_zod8.z.string().datetime({ offset: true }),
3985
+ provider: ProviderEnumSchema,
3986
+ provider_avatar_url: import_zod8.z.string(),
3987
+ provider_display: import_zod8.z.string(),
3988
+ provider_email: import_zod8.z.email(),
3989
+ provider_username: import_zod8.z.string()
3990
+ });
3991
+
3992
+ // src/_api/generated/_cfg_accounts/schemas/OAuthDisconnectRequestRequest.ts
3993
+ var import_zod9 = require("zod");
3994
+ var OAuthDisconnectRequestRequestSchema = import_zod9.z.object({
3995
+ provider: ProviderEnumSchema
3996
+ });
3997
+
3998
+ // src/_api/generated/_cfg_accounts/schemas/OAuthError.ts
3999
+ var import_zod10 = require("zod");
4000
+ var OAuthErrorSchema = import_zod10.z.object({
4001
+ error: import_zod10.z.string(),
4002
+ error_description: import_zod10.z.string().optional()
4003
+ });
4004
+
4005
+ // src/_api/generated/_cfg_accounts/schemas/OAuthProvidersResponse.ts
4006
+ var import_zod11 = require("zod");
4007
+ var OAuthProvidersResponseSchema = import_zod11.z.object({
4008
+ providers: import_zod11.z.array(import_zod11.z.object({}).passthrough())
4009
+ });
4010
+
4011
+ // src/_api/generated/_cfg_accounts/schemas/OAuthTokenResponse.ts
4012
+ var import_zod12 = require("zod");
4013
+ var OAuthTokenResponseSchema = import_zod12.z.object({
4014
+ access: import_zod12.z.string().nullable().optional(),
4015
+ is_new_connection: import_zod12.z.boolean(),
4016
+ is_new_user: import_zod12.z.boolean(),
4017
+ refresh: import_zod12.z.string().nullable().optional(),
4018
+ requires_2fa: import_zod12.z.boolean().default(false).optional(),
4019
+ session_id: import_zod12.z.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(),
4020
+ should_prompt_2fa: import_zod12.z.boolean().optional(),
4021
+ user: import_zod12.z.object({}).passthrough().nullable().optional()
4022
+ });
4023
+
4024
+ // src/_api/generated/_cfg_accounts/schemas/OTPErrorResponse.ts
4025
+ var import_zod13 = require("zod");
4026
+ var OTPErrorResponseSchema = import_zod13.z.object({
4027
+ error: import_zod13.z.string(),
4028
+ error_code: import_zod13.z.string().nullable().optional(),
4029
+ retry_after: import_zod13.z.number().int().nullable().optional()
4030
+ });
4031
+
4032
+ // src/_api/generated/_cfg_accounts/schemas/OTPRequestRequest.ts
4033
+ var import_zod14 = require("zod");
4034
+ var OTPRequestRequestSchema = import_zod14.z.object({
4035
+ identifier: import_zod14.z.string().min(1),
4036
+ source_url: import_zod14.z.string().optional()
4037
+ });
4038
+
4039
+ // src/_api/generated/_cfg_accounts/schemas/OTPRequestResponse.ts
4040
+ var import_zod15 = require("zod");
4041
+ var OTPRequestResponseSchema = import_zod15.z.object({
4042
+ message: import_zod15.z.string()
4043
+ });
4044
+
4045
+ // src/_api/generated/_cfg_accounts/schemas/OTPVerifyRequest.ts
4046
+ var import_zod16 = require("zod");
4047
+ var OTPVerifyRequestSchema = import_zod16.z.object({
4048
+ identifier: import_zod16.z.string().min(1),
4049
+ otp: import_zod16.z.string().min(6).max(6),
4050
+ source_url: import_zod16.z.string().optional()
4051
+ });
4052
+
4053
+ // src/_api/generated/_cfg_accounts/schemas/OTPVerifyResponse.ts
4054
+ var import_zod18 = require("zod");
4055
+
4056
+ // src/_api/generated/_cfg_accounts/schemas/User.ts
4057
+ var import_zod17 = require("zod");
4058
+ var UserSchema = import_zod17.z.object({
4059
+ avatar: import_zod17.z.string().nullable(),
4060
+ centrifugo: CentrifugoTokenSchema.nullable(),
4061
+ company: import_zod17.z.string().max(100).optional(),
4062
+ date_joined: import_zod17.z.string().datetime({ offset: true }),
4063
+ display_username: import_zod17.z.string(),
4064
+ email: import_zod17.z.email(),
4065
+ first_name: import_zod17.z.string().max(50).optional(),
4066
+ full_name: import_zod17.z.string(),
4067
+ id: import_zod17.z.number().int(),
4068
+ initials: import_zod17.z.string(),
4069
+ is_staff: import_zod17.z.boolean(),
4070
+ is_superuser: import_zod17.z.boolean(),
4071
+ language: import_zod17.z.string().max(10).optional(),
4072
+ last_login: import_zod17.z.string().datetime({ offset: true }).nullable(),
4073
+ last_name: import_zod17.z.string().max(50).optional(),
4074
+ phone: import_zod17.z.string().max(20).optional(),
4075
+ position: import_zod17.z.string().max(100).optional(),
4076
+ unanswered_messages_count: import_zod17.z.number().int().default(0)
4077
+ });
4078
+
4079
+ // src/_api/generated/_cfg_accounts/schemas/OTPVerifyResponse.ts
4080
+ var OTPVerifyResponseSchema = import_zod18.z.object({
4081
+ access: import_zod18.z.string().nullable().optional(),
4082
+ refresh: import_zod18.z.string().nullable().optional(),
4083
+ requires_2fa: import_zod18.z.boolean().default(false).optional(),
4084
+ session_id: import_zod18.z.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(),
4085
+ should_prompt_2fa: import_zod18.z.boolean().optional(),
4086
+ user: UserSchema.nullable().optional()
4087
+ });
4088
+
4089
+ // src/_api/generated/_cfg_accounts/schemas/PatchedCfgUserUpdateRequest.ts
4090
+ var import_zod19 = require("zod");
4091
+ var PatchedCfgUserUpdateRequestSchema = import_zod19.z.object({
4092
+ company: import_zod19.z.string().max(100).optional(),
4093
+ first_name: import_zod19.z.string().max(50).optional(),
4094
+ language: import_zod19.z.string().max(10).optional(),
4095
+ last_name: import_zod19.z.string().max(50).optional(),
4096
+ phone: import_zod19.z.string().max(20).optional(),
4097
+ position: import_zod19.z.string().max(100).optional()
4098
+ });
4099
+
4100
+ // src/_api/generated/_cfg_accounts/schemas/TokenRefresh.ts
4101
+ var import_zod20 = require("zod");
4102
+ var TokenRefreshSchema = import_zod20.z.object({
4103
+ access: import_zod20.z.string(),
4104
+ refresh: import_zod20.z.string()
4105
+ });
4106
+
4107
+ // src/_api/generated/_cfg_accounts/schemas/TokenRefreshRequest.ts
4108
+ var import_zod21 = require("zod");
4109
+ var TokenRefreshRequestSchema = import_zod21.z.object({
4110
+ refresh: import_zod21.z.string().min(1)
4111
+ });
4112
+
6405
4113
  // src/auth/context/AccountsContext.tsx
6406
4114
  var import_jsx_runtime = require("react/jsx-runtime");
6407
4115
  var AccountsContext = (0, import_react16.createContext)(void 0);
@@ -6478,8 +4186,8 @@ function AccountsProvider({ children }) {
6478
4186
  return result;
6479
4187
  }
6480
4188
  if (result.access && result.refresh) {
6481
- cfgAccountsApi.setToken(result.access);
6482
- cfgAccountsApi.setRefreshToken(result.refresh);
4189
+ CfgAccountsApi.setToken(result.access);
4190
+ CfgAccountsApi.setRefreshToken(result.refresh);
6483
4191
  try {
6484
4192
  await refreshProfile({ callerId: "verifyOTP", force: true });
6485
4193
  } catch (profileError2) {
@@ -6492,13 +4200,13 @@ function AccountsProvider({ children }) {
6492
4200
  const body = { refresh };
6493
4201
  const result = await triggerTokenRefresh({ body });
6494
4202
  if (result.access) {
6495
- cfgAccountsApi.setToken(result.access);
6496
- cfgAccountsApi.setRefreshToken(refresh);
4203
+ CfgAccountsApi.setToken(result.access);
4204
+ CfgAccountsApi.setRefreshToken(refresh);
6497
4205
  }
6498
4206
  return result;
6499
4207
  }, "refreshToken");
6500
4208
  const logout = (0, import_react16.useCallback)(() => {
6501
- cfgAccountsApi.clearToken();
4209
+ CfgAccountsApi.clearToken();
6502
4210
  setProfile(void 0);
6503
4211
  setProfileError(null);
6504
4212
  clearProfileCache();
@@ -6539,7 +4247,7 @@ var AuthContext = (0, import_react17.createContext)(void 0);
6539
4247
  var EMAIL_STORAGE_KEY = "auth_email";
6540
4248
  var hasValidTokens = /* @__PURE__ */ __name(() => {
6541
4249
  if (typeof window === "undefined") return false;
6542
- return cfgAccountsApi.isAuthenticated();
4250
+ return CfgAccountsApi.isAuthenticated();
6543
4251
  }, "hasValidTokens");
6544
4252
  var AuthProviderInternal = /* @__PURE__ */ __name(({ children, config }) => {
6545
4253
  const accounts = useAccountsContext();
@@ -6580,7 +4288,7 @@ var AuthProviderInternal = /* @__PURE__ */ __name(({ children, config }) => {
6580
4288
  }, [config]);
6581
4289
  const clearAuthState = (0, import_react17.useCallback)((caller) => {
6582
4290
  authLogger.info("clearAuthState >> caller", caller);
6583
- cfgAccountsApi.clearToken();
4291
+ CfgAccountsApi.clearToken();
6584
4292
  clearProfileCache();
6585
4293
  setInitialized(true);
6586
4294
  setIsLoading(false);
@@ -6618,8 +4326,8 @@ var AuthProviderInternal = /* @__PURE__ */ __name(({ children, config }) => {
6618
4326
  authLogger.debug(`loadCurrentProfile called by: ${finalCallerId}`);
6619
4327
  try {
6620
4328
  isLoadingProfileRef.current = true;
6621
- const isAuth = cfgAccountsApi.isAuthenticated();
6622
- const token = cfgAccountsApi.getToken();
4329
+ const isAuth = CfgAccountsApi.isAuthenticated();
4330
+ const token = CfgAccountsApi.getToken();
6623
4331
  if (!isAuth) {
6624
4332
  authLogger.warn("No valid authentication token, throwing error");
6625
4333
  throw new Error("No valid authentication token");
@@ -6656,8 +4364,8 @@ var AuthProviderInternal = /* @__PURE__ */ __name(({ children, config }) => {
6656
4364
  authLogger.info("Initializing auth...");
6657
4365
  const isInIframe = typeof window !== "undefined" && window.self !== window.top;
6658
4366
  authLogger.info("Is in iframe:", isInIframe);
6659
- const token = cfgAccountsApi.getToken();
6660
- const refreshToken2 = cfgAccountsApi.getRefreshToken();
4367
+ const token = CfgAccountsApi.getToken();
4368
+ const refreshToken2 = CfgAccountsApi.getRefreshToken();
6661
4369
  authLogger.info("Token from API:", token ? `${token.substring(0, 20)}...` : "null");
6662
4370
  authLogger.info("Refresh token from API:", refreshToken2 ? `${refreshToken2.substring(0, 20)}...` : "null");
6663
4371
  authLogger.info("localStorage keys:", Object.keys(localStorage).filter((k) => k.includes("token") || k.includes("auth")));
@@ -6708,7 +4416,7 @@ var AuthProviderInternal = /* @__PURE__ */ __name(({ children, config }) => {
6708
4416
  }, [initialized]);
6709
4417
  (0, import_react17.useEffect)(() => {
6710
4418
  if (!initialized) return;
6711
- const isAuthenticated = cfgAccountsApi.isAuthenticated();
4419
+ const isAuthenticated = CfgAccountsApi.isAuthenticated();
6712
4420
  const authRoute = config?.routes?.auth || defaultRoutes.auth;
6713
4421
  const isAuthPage = pathname === authRoute;
6714
4422
  const flowParam = queryParams.get("flow");
@@ -6728,7 +4436,7 @@ var AuthProviderInternal = /* @__PURE__ */ __name(({ children, config }) => {
6728
4436
  const checkAuthAndRedirect = (0, import_react17.useCallback)(async () => {
6729
4437
  try {
6730
4438
  setIsLoading(true);
6731
- const isAuthenticated = cfgAccountsApi.isAuthenticated();
4439
+ const isAuthenticated = CfgAccountsApi.isAuthenticated();
6732
4440
  if (isAuthenticated) {
6733
4441
  await loadCurrentProfile();
6734
4442
  if (userRef.current) {
@@ -6749,7 +4457,7 @@ var AuthProviderInternal = /* @__PURE__ */ __name(({ children, config }) => {
6749
4457
  }, [loadCurrentProfile, clearAuthState, pushToDefaultCallbackUrl, pushToDefaultAuthCallbackUrl, handleGlobalAuthError]);
6750
4458
  const requestOTP = (0, import_react17.useCallback)(
6751
4459
  async (identifier, sourceUrl) => {
6752
- cfgAccountsApi.clearToken();
4460
+ CfgAccountsApi.clearToken();
6753
4461
  try {
6754
4462
  const result = await accounts.requestOTP({
6755
4463
  identifier,
@@ -6851,7 +4559,7 @@ var AuthProviderInternal = /* @__PURE__ */ __name(({ children, config }) => {
6851
4559
  );
6852
4560
  const refreshToken = (0, import_react17.useCallback)(async () => {
6853
4561
  try {
6854
- const refreshTokenValue = cfgAccountsApi.getRefreshToken();
4562
+ const refreshTokenValue = CfgAccountsApi.getRefreshToken();
6855
4563
  if (!refreshTokenValue) {
6856
4564
  clearAuthState("refreshToken:noToken");
6857
4565
  Analytics.event("auth_session_expired" /* AUTH_SESSION_EXPIRED */, {
@@ -6914,12 +4622,12 @@ var AuthProviderInternal = /* @__PURE__ */ __name(({ children, config }) => {
6914
4622
  user,
6915
4623
  isLoading,
6916
4624
  // Consider authenticated if we have valid tokens, even without user profile
6917
- isAuthenticated: cfgAccountsApi.isAuthenticated(),
4625
+ isAuthenticated: CfgAccountsApi.isAuthenticated(),
6918
4626
  isAdminUser,
6919
4627
  loadCurrentProfile,
6920
4628
  checkAuthAndRedirect,
6921
- getToken: /* @__PURE__ */ __name(() => cfgAccountsApi.getToken(), "getToken"),
6922
- getRefreshToken: /* @__PURE__ */ __name(() => cfgAccountsApi.getRefreshToken(), "getRefreshToken"),
4629
+ getToken: /* @__PURE__ */ __name(() => CfgAccountsApi.getToken(), "getToken"),
4630
+ getRefreshToken: /* @__PURE__ */ __name(() => CfgAccountsApi.getRefreshToken(), "getRefreshToken"),
6923
4631
  getSavedEmail: /* @__PURE__ */ __name(() => storedEmail, "getSavedEmail"),
6924
4632
  saveEmail: setStoredEmail,
6925
4633
  clearSavedEmail: clearStoredEmail,