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