@djangocfg/api 2.1.447 → 2.1.449
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 +1 -2272
- package/dist/auth-server.cjs.map +1 -1
- package/dist/auth-server.d.cts +1 -35
- package/dist/auth-server.d.ts +1 -35
- package/dist/auth-server.mjs +1 -2272
- package/dist/auth-server.mjs.map +1 -1
- package/dist/auth.cjs +207 -128
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.d.cts +135 -2
- package/dist/auth.d.ts +135 -2
- package/dist/auth.mjs +216 -137
- package/dist/auth.mjs.map +1 -1
- package/dist/clients.cjs +35 -0
- package/dist/clients.cjs.map +1 -1
- package/dist/clients.d.cts +147 -2
- package/dist/clients.d.ts +147 -2
- package/dist/clients.mjs +35 -0
- package/dist/clients.mjs.map +1 -1
- package/dist/hooks.cjs +11 -0
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.mjs +11 -0
- package/dist/hooks.mjs.map +1 -1
- package/dist/index.cjs +35 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +169 -6
- package/dist/index.d.ts +169 -6
- package/dist/index.mjs +35 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -4
- package/src/_api/generated/_cfg_accounts/api.ts +8 -0
- package/src/_api/generated/_cfg_accounts/openapi.json +84 -5
- package/src/_api/generated/_cfg_accounts/schemas/OAuthTokenResponse.ts +2 -2
- package/src/_api/generated/_cfg_accounts/schemas/OTPRequestResponse.ts +2 -0
- package/src/_api/generated/_cfg_accounts/schemas/WebmailLink.ts +15 -0
- package/src/_api/generated/_cfg_accounts/schemas/WebmailLinkProviderEnum.ts +9 -0
- package/src/_api/generated/_cfg_accounts/schemas/index.ts +2 -0
- package/src/_api/generated/_cfg_centrifugo/api.ts +8 -0
- package/src/_api/generated/_cfg_totp/api.ts +8 -0
- package/src/_api/generated/helpers/auth.ts +12 -0
- package/src/_api/generated/openapi.json +84 -5
- package/src/_api/generated/types.gen.ts +131 -2
- package/src/auth/__tests__/refreshRotation.test.ts +119 -0
- package/src/auth/context/AuthContext.tsx +10 -1
- package/src/auth/hooks/useAuthForm.ts +5 -2
- package/src/auth/hooks/useAuthFormState.ts +4 -1
- package/src/auth/hooks/useTokenRefresh.ts +29 -45
- package/src/auth/middlewares/index.ts +7 -7
- package/src/auth/refreshHandler.ts +79 -0
- package/src/auth/types/form.ts +10 -0
- package/src/auth/types/index.ts +1 -0
- package/src/auth/middlewares/tokenRefresh.ts +0 -161
package/dist/auth.mjs
CHANGED
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
useContext as useContext2,
|
|
28
28
|
useEffect as useEffect9,
|
|
29
29
|
useMemo as useMemo3,
|
|
30
|
-
useRef as
|
|
30
|
+
useRef as useRef6,
|
|
31
31
|
useState as useState12
|
|
32
32
|
} from "react";
|
|
33
33
|
import { SWRConfig } from "swr";
|
|
@@ -161,6 +161,7 @@ var useAuthFormState = /* @__PURE__ */ __name((initialIdentifier = "") => {
|
|
|
161
161
|
const [acceptedTerms, setAcceptedTerms] = useState2(true);
|
|
162
162
|
const [step, setStep] = useState2("identifier");
|
|
163
163
|
const [error, setError] = useState2("");
|
|
164
|
+
const [webmail, setWebmail] = useState2(null);
|
|
164
165
|
const [twoFactorSessionId, setTwoFactorSessionId] = useState2(null);
|
|
165
166
|
const [shouldPrompt2FA, setShouldPrompt2FA] = useState2(false);
|
|
166
167
|
const [twoFactorCode, setTwoFactorCode] = useState2("");
|
|
@@ -200,6 +201,7 @@ var useAuthFormState = /* @__PURE__ */ __name((initialIdentifier = "") => {
|
|
|
200
201
|
rateLimitSeconds,
|
|
201
202
|
isRateLimited: rateLimitSeconds > 0,
|
|
202
203
|
rateLimitLabel: formatCountdown(rateLimitSeconds),
|
|
204
|
+
webmail,
|
|
203
205
|
// Handlers
|
|
204
206
|
setIdentifier,
|
|
205
207
|
setOtp,
|
|
@@ -212,7 +214,8 @@ var useAuthFormState = /* @__PURE__ */ __name((initialIdentifier = "") => {
|
|
|
212
214
|
setShouldPrompt2FA,
|
|
213
215
|
setTwoFactorCode,
|
|
214
216
|
setUseBackupCode,
|
|
215
|
-
startRateLimitCountdown
|
|
217
|
+
startRateLimitCountdown,
|
|
218
|
+
setWebmail
|
|
216
219
|
};
|
|
217
220
|
}, "useAuthFormState");
|
|
218
221
|
|
|
@@ -598,6 +601,17 @@ var auth = {
|
|
|
598
601
|
*/
|
|
599
602
|
setRefreshHandler(fn) {
|
|
600
603
|
_refreshHandler = fn;
|
|
604
|
+
},
|
|
605
|
+
/**
|
|
606
|
+
* Proactively run the registered refresh handler right now, reusing the
|
|
607
|
+
* SAME single-flight promise as the 401-recovery interceptor. Callers
|
|
608
|
+
* (e.g. an expiry timer / focus / reconnect) get token rotation,
|
|
609
|
+
* de-duplication and rotated-token persistence for free — they must NOT
|
|
610
|
+
* re-implement any of it. Returns the fresh access token, or null if
|
|
611
|
+
* there is no handler / no refresh token / the refresh failed.
|
|
612
|
+
*/
|
|
613
|
+
refreshNow() {
|
|
614
|
+
return tryRefresh();
|
|
601
615
|
}
|
|
602
616
|
};
|
|
603
617
|
async function tryRefresh() {
|
|
@@ -2321,6 +2335,14 @@ var API = class {
|
|
|
2321
2335
|
setRefreshHandler(fn) {
|
|
2322
2336
|
auth.setRefreshHandler(fn);
|
|
2323
2337
|
}
|
|
2338
|
+
/**
|
|
2339
|
+
* Proactively refresh now via the registered handler, sharing the single
|
|
2340
|
+
* 401-recovery flight (rotation + dedup + rotated-token persistence).
|
|
2341
|
+
* See `auth.refreshNow`.
|
|
2342
|
+
*/
|
|
2343
|
+
refreshNow() {
|
|
2344
|
+
return auth.refreshNow();
|
|
2345
|
+
}
|
|
2324
2346
|
};
|
|
2325
2347
|
|
|
2326
2348
|
// src/_api/generated/_cfg_centrifugo/api.ts
|
|
@@ -2385,6 +2407,14 @@ var API2 = class {
|
|
|
2385
2407
|
setRefreshHandler(fn) {
|
|
2386
2408
|
auth.setRefreshHandler(fn);
|
|
2387
2409
|
}
|
|
2410
|
+
/**
|
|
2411
|
+
* Proactively refresh now via the registered handler, sharing the single
|
|
2412
|
+
* 401-recovery flight (rotation + dedup + rotated-token persistence).
|
|
2413
|
+
* See `auth.refreshNow`.
|
|
2414
|
+
*/
|
|
2415
|
+
refreshNow() {
|
|
2416
|
+
return auth.refreshNow();
|
|
2417
|
+
}
|
|
2388
2418
|
};
|
|
2389
2419
|
|
|
2390
2420
|
// src/_api/generated/_cfg_totp/api.ts
|
|
@@ -2452,6 +2482,14 @@ var API3 = class {
|
|
|
2452
2482
|
setRefreshHandler(fn) {
|
|
2453
2483
|
auth.setRefreshHandler(fn);
|
|
2454
2484
|
}
|
|
2485
|
+
/**
|
|
2486
|
+
* Proactively refresh now via the registered handler, sharing the single
|
|
2487
|
+
* 401-recovery flight (rotation + dedup + rotated-token persistence).
|
|
2488
|
+
* See `auth.refreshNow`.
|
|
2489
|
+
*/
|
|
2490
|
+
refreshNow() {
|
|
2491
|
+
return auth.refreshNow();
|
|
2492
|
+
}
|
|
2455
2493
|
};
|
|
2456
2494
|
|
|
2457
2495
|
// src/_api/generated/index.ts
|
|
@@ -2672,7 +2710,8 @@ var useAuthForm = /* @__PURE__ */ __name((options) => {
|
|
|
2672
2710
|
setShouldPrompt2FA,
|
|
2673
2711
|
setTwoFactorCode,
|
|
2674
2712
|
setUseBackupCode,
|
|
2675
|
-
startRateLimitCountdown
|
|
2713
|
+
startRateLimitCountdown,
|
|
2714
|
+
setWebmail
|
|
2676
2715
|
} = formState;
|
|
2677
2716
|
const twoFactor = useTwoFactor({
|
|
2678
2717
|
onSuccess: /* @__PURE__ */ __name(() => {
|
|
@@ -2724,6 +2763,7 @@ var useAuthForm = /* @__PURE__ */ __name((options) => {
|
|
|
2724
2763
|
const result = await requestOTP(identifier, sourceUrl);
|
|
2725
2764
|
if (result.success) {
|
|
2726
2765
|
saveIdentifierToStorage(identifier);
|
|
2766
|
+
setWebmail(result.webmail ?? null);
|
|
2727
2767
|
setStep("otp");
|
|
2728
2768
|
onIdentifierSuccess?.(identifier);
|
|
2729
2769
|
} else {
|
|
@@ -2753,6 +2793,7 @@ var useAuthForm = /* @__PURE__ */ __name((options) => {
|
|
|
2753
2793
|
setIsLoading,
|
|
2754
2794
|
setStep,
|
|
2755
2795
|
clearError,
|
|
2796
|
+
setWebmail,
|
|
2756
2797
|
startRateLimitCountdown,
|
|
2757
2798
|
onIdentifierSuccess,
|
|
2758
2799
|
onError,
|
|
@@ -2808,6 +2849,7 @@ var useAuthForm = /* @__PURE__ */ __name((options) => {
|
|
|
2808
2849
|
const result = await requestOTP(identifier, sourceUrl);
|
|
2809
2850
|
if (result.success) {
|
|
2810
2851
|
saveIdentifierToStorage(identifier);
|
|
2852
|
+
setWebmail(result.webmail ?? null);
|
|
2811
2853
|
setOtp("");
|
|
2812
2854
|
} else {
|
|
2813
2855
|
if (result.retryAfter) {
|
|
@@ -2825,7 +2867,7 @@ var useAuthForm = /* @__PURE__ */ __name((options) => {
|
|
|
2825
2867
|
} finally {
|
|
2826
2868
|
setIsLoading(false);
|
|
2827
2869
|
}
|
|
2828
|
-
}, [identifier, requestOTP, saveIdentifierToStorage, setOtp, setError, setIsLoading, clearError, startRateLimitCountdown, onError, sourceUrl]);
|
|
2870
|
+
}, [identifier, requestOTP, saveIdentifierToStorage, setOtp, setError, setIsLoading, clearError, startRateLimitCountdown, setWebmail, onError, sourceUrl]);
|
|
2829
2871
|
const handleBackToIdentifier = useCallback5(() => {
|
|
2830
2872
|
setStep("identifier");
|
|
2831
2873
|
clearError();
|
|
@@ -3727,7 +3769,40 @@ function getCacheMetadata() {
|
|
|
3727
3769
|
__name(getCacheMetadata, "getCacheMetadata");
|
|
3728
3770
|
|
|
3729
3771
|
// src/auth/hooks/useTokenRefresh.ts
|
|
3730
|
-
import { useCallback as useCallback9, useEffect as useEffect7
|
|
3772
|
+
import { useCallback as useCallback9, useEffect as useEffect7 } from "react";
|
|
3773
|
+
|
|
3774
|
+
// src/auth/refreshHandler.ts
|
|
3775
|
+
var _registered = false;
|
|
3776
|
+
function ensureRefreshHandler() {
|
|
3777
|
+
if (_registered) return;
|
|
3778
|
+
_registered = true;
|
|
3779
|
+
CfgAccountsApi.setRefreshHandler(async (refresh) => {
|
|
3780
|
+
const result = await CfgAccountsAuth.cfgAccountsTokenRefreshCreate({
|
|
3781
|
+
body: { refresh },
|
|
3782
|
+
throwOnError: true
|
|
3783
|
+
});
|
|
3784
|
+
const access = result.data?.access;
|
|
3785
|
+
if (!access) {
|
|
3786
|
+
authLogger.error("Refresh response missing access token");
|
|
3787
|
+
return null;
|
|
3788
|
+
}
|
|
3789
|
+
return { access, refresh: result.data?.refresh ?? refresh };
|
|
3790
|
+
});
|
|
3791
|
+
authLogger.debug("Canonical refresh handler registered");
|
|
3792
|
+
}
|
|
3793
|
+
__name(ensureRefreshHandler, "ensureRefreshHandler");
|
|
3794
|
+
function triggerRefresh() {
|
|
3795
|
+
ensureRefreshHandler();
|
|
3796
|
+
const maybe = CfgAccountsApi;
|
|
3797
|
+
if (typeof maybe.refreshNow === "function") {
|
|
3798
|
+
return maybe.refreshNow();
|
|
3799
|
+
}
|
|
3800
|
+
authLogger.warn("api.refreshNow() unavailable \u2014 run `make generate` to regenerate the client");
|
|
3801
|
+
return Promise.resolve(null);
|
|
3802
|
+
}
|
|
3803
|
+
__name(triggerRefresh, "triggerRefresh");
|
|
3804
|
+
|
|
3805
|
+
// src/auth/hooks/useTokenRefresh.ts
|
|
3731
3806
|
var TOKEN_REFRESH_THRESHOLD_MS = 10 * 60 * 1e3;
|
|
3732
3807
|
var CHECK_INTERVAL_MS = 5 * 60 * 1e3;
|
|
3733
3808
|
function getTokenExpiry(token) {
|
|
@@ -3742,36 +3817,22 @@ __name(getTokenExpiry, "getTokenExpiry");
|
|
|
3742
3817
|
function isTokenExpiringSoon(token, thresholdMs) {
|
|
3743
3818
|
const expiry = getTokenExpiry(token);
|
|
3744
3819
|
if (!expiry) return false;
|
|
3745
|
-
|
|
3746
|
-
return timeUntilExpiry < thresholdMs;
|
|
3820
|
+
return expiry - Date.now() < thresholdMs;
|
|
3747
3821
|
}
|
|
3748
3822
|
__name(isTokenExpiringSoon, "isTokenExpiringSoon");
|
|
3749
3823
|
function useTokenRefresh(options = {}) {
|
|
3750
3824
|
const { enabled = true, onRefresh, onRefreshError } = options;
|
|
3751
|
-
const isRefreshingRef = useRef5(false);
|
|
3752
3825
|
const refreshToken = useCallback9(async () => {
|
|
3753
|
-
if (
|
|
3754
|
-
authLogger.debug("Token refresh already in progress");
|
|
3755
|
-
return false;
|
|
3756
|
-
}
|
|
3757
|
-
const refreshTokenValue = CfgAccountsApi.getRefreshToken();
|
|
3758
|
-
if (!refreshTokenValue) {
|
|
3826
|
+
if (!CfgAccountsApi.getRefreshToken()) {
|
|
3759
3827
|
authLogger.warn("No refresh token available");
|
|
3760
3828
|
return false;
|
|
3761
3829
|
}
|
|
3762
|
-
isRefreshingRef.current = true;
|
|
3763
3830
|
authLogger.info("Refreshing token...");
|
|
3764
3831
|
try {
|
|
3765
|
-
const
|
|
3766
|
-
body: { refresh: refreshTokenValue },
|
|
3767
|
-
throwOnError: true
|
|
3768
|
-
});
|
|
3769
|
-
const newAccessToken = result.data.access;
|
|
3832
|
+
const newAccessToken = await triggerRefresh();
|
|
3770
3833
|
if (!newAccessToken) {
|
|
3771
|
-
throw new Error("
|
|
3834
|
+
throw new Error("Token refresh failed");
|
|
3772
3835
|
}
|
|
3773
|
-
CfgAccountsApi.setToken(newAccessToken);
|
|
3774
|
-
CfgAccountsApi.setRefreshToken(refreshTokenValue);
|
|
3775
3836
|
authLogger.info("Token refreshed successfully");
|
|
3776
3837
|
onRefresh?.(newAccessToken);
|
|
3777
3838
|
return true;
|
|
@@ -3779,8 +3840,6 @@ function useTokenRefresh(options = {}) {
|
|
|
3779
3840
|
authLogger.error("Token refresh error:", error);
|
|
3780
3841
|
onRefreshError?.(error instanceof Error ? error : new Error(String(error)));
|
|
3781
3842
|
return false;
|
|
3782
|
-
} finally {
|
|
3783
|
-
isRefreshingRef.current = false;
|
|
3784
3843
|
}
|
|
3785
3844
|
}, [onRefresh, onRefreshError]);
|
|
3786
3845
|
const checkAndRefresh = useCallback9(async () => {
|
|
@@ -3867,7 +3926,7 @@ import {
|
|
|
3867
3926
|
useContext,
|
|
3868
3927
|
useEffect as useEffect8,
|
|
3869
3928
|
useMemo as useMemo2,
|
|
3870
|
-
useRef as
|
|
3929
|
+
useRef as useRef5,
|
|
3871
3930
|
useState as useState11
|
|
3872
3931
|
} from "react";
|
|
3873
3932
|
|
|
@@ -3971,8 +4030,8 @@ var OAuthTokenResponseSchema = z10.object({
|
|
|
3971
4030
|
access: z10.string().nullable().optional(),
|
|
3972
4031
|
refresh: z10.string().nullable().optional(),
|
|
3973
4032
|
user: z10.object({}).passthrough().nullable().optional(),
|
|
3974
|
-
is_new_user: z10.boolean(),
|
|
3975
|
-
is_new_connection: z10.boolean(),
|
|
4033
|
+
is_new_user: z10.boolean().default(false).optional(),
|
|
4034
|
+
is_new_connection: z10.boolean().default(false).optional(),
|
|
3976
4035
|
should_prompt_2fa: z10.boolean().optional()
|
|
3977
4036
|
});
|
|
3978
4037
|
|
|
@@ -3989,9 +4048,27 @@ var OAuthProvidersResponseSchema = z11.object({
|
|
|
3989
4048
|
import useSWRMutation7 from "swr/mutation";
|
|
3990
4049
|
|
|
3991
4050
|
// src/_api/generated/_cfg_accounts/schemas/OTPRequestResponse.ts
|
|
4051
|
+
import { z as z14 } from "zod";
|
|
4052
|
+
|
|
4053
|
+
// src/_api/generated/_cfg_accounts/schemas/WebmailLink.ts
|
|
4054
|
+
import { z as z13 } from "zod";
|
|
4055
|
+
|
|
4056
|
+
// src/_api/generated/_cfg_accounts/schemas/WebmailLinkProviderEnum.ts
|
|
3992
4057
|
import { z as z12 } from "zod";
|
|
3993
|
-
var
|
|
3994
|
-
|
|
4058
|
+
var WebmailLinkProviderEnumSchema = z12.enum(["gmail", "outlook", "yahoo", "icloud", "proton", "zoho", "aol", "fastmail", "gmx", "mailcom", "mail_ru", "yandex", "rambler", "qq", "netease", "sina", "aliyun", "naver", "daum", "web_de", "tonline", "seznam", "wp_pl", "o2_pl", "interia", "libero", "virgilio", "orange", "laposte", "free_fr", "sfr"]);
|
|
4059
|
+
|
|
4060
|
+
// src/_api/generated/_cfg_accounts/schemas/WebmailLink.ts
|
|
4061
|
+
var WebmailLinkSchema = z13.object({
|
|
4062
|
+
provider: WebmailLinkProviderEnumSchema,
|
|
4063
|
+
provider_name: z13.string(),
|
|
4064
|
+
url: z13.string(),
|
|
4065
|
+
is_search: z13.boolean()
|
|
4066
|
+
});
|
|
4067
|
+
|
|
4068
|
+
// src/_api/generated/_cfg_accounts/schemas/OTPRequestResponse.ts
|
|
4069
|
+
var OTPRequestResponseSchema = z14.object({
|
|
4070
|
+
message: z14.string(),
|
|
4071
|
+
webmail: WebmailLinkSchema.nullable().optional()
|
|
3995
4072
|
});
|
|
3996
4073
|
|
|
3997
4074
|
// src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOtpRequestCreate.ts
|
|
@@ -4045,52 +4122,52 @@ __name(useCfgAccountsOtpRequestCreate, "useCfgAccountsOtpRequestCreate");
|
|
|
4045
4122
|
import useSWRMutation8 from "swr/mutation";
|
|
4046
4123
|
|
|
4047
4124
|
// src/_api/generated/_cfg_accounts/schemas/OTPVerifyResponse.ts
|
|
4048
|
-
import { z as
|
|
4125
|
+
import { z as z17 } from "zod";
|
|
4049
4126
|
|
|
4050
4127
|
// src/_api/generated/_cfg_accounts/schemas/User.ts
|
|
4051
|
-
import { z as
|
|
4128
|
+
import { z as z16 } from "zod";
|
|
4052
4129
|
|
|
4053
4130
|
// src/_api/generated/_cfg_accounts/schemas/CentrifugoToken.ts
|
|
4054
|
-
import { z as
|
|
4055
|
-
var CentrifugoTokenSchema =
|
|
4056
|
-
token:
|
|
4057
|
-
centrifugo_url:
|
|
4058
|
-
expires_at:
|
|
4059
|
-
channels:
|
|
4131
|
+
import { z as z15 } from "zod";
|
|
4132
|
+
var CentrifugoTokenSchema = z15.object({
|
|
4133
|
+
token: z15.string(),
|
|
4134
|
+
centrifugo_url: z15.string(),
|
|
4135
|
+
expires_at: z15.string().datetime({ offset: true }),
|
|
4136
|
+
channels: z15.array(z15.string())
|
|
4060
4137
|
});
|
|
4061
4138
|
|
|
4062
4139
|
// src/_api/generated/_cfg_accounts/schemas/User.ts
|
|
4063
|
-
var UserSchema =
|
|
4064
|
-
id:
|
|
4065
|
-
email:
|
|
4066
|
-
first_name:
|
|
4067
|
-
last_name:
|
|
4068
|
-
full_name:
|
|
4069
|
-
initials:
|
|
4070
|
-
display_username:
|
|
4071
|
-
company:
|
|
4072
|
-
phone:
|
|
4073
|
-
position:
|
|
4074
|
-
language:
|
|
4075
|
-
timezone:
|
|
4076
|
-
avatar:
|
|
4077
|
-
is_staff:
|
|
4078
|
-
is_superuser:
|
|
4079
|
-
date_joined:
|
|
4080
|
-
last_login:
|
|
4081
|
-
unanswered_messages_count:
|
|
4140
|
+
var UserSchema = z16.object({
|
|
4141
|
+
id: z16.number().int(),
|
|
4142
|
+
email: z16.email(),
|
|
4143
|
+
first_name: z16.string().max(50).nullable().optional(),
|
|
4144
|
+
last_name: z16.string().max(50).nullable().optional(),
|
|
4145
|
+
full_name: z16.string(),
|
|
4146
|
+
initials: z16.string(),
|
|
4147
|
+
display_username: z16.string(),
|
|
4148
|
+
company: z16.string().max(100).nullable().optional(),
|
|
4149
|
+
phone: z16.string().max(20).nullable().optional(),
|
|
4150
|
+
position: z16.string().max(100).nullable().optional(),
|
|
4151
|
+
language: z16.string().max(10).nullable().optional(),
|
|
4152
|
+
timezone: z16.string().max(64).nullable().optional(),
|
|
4153
|
+
avatar: z16.string().nullable(),
|
|
4154
|
+
is_staff: z16.boolean(),
|
|
4155
|
+
is_superuser: z16.boolean(),
|
|
4156
|
+
date_joined: z16.string().datetime({ offset: true }),
|
|
4157
|
+
last_login: z16.string().datetime({ offset: true }).nullable(),
|
|
4158
|
+
unanswered_messages_count: z16.number().int().default(0),
|
|
4082
4159
|
centrifugo: CentrifugoTokenSchema.nullable(),
|
|
4083
|
-
api_key:
|
|
4160
|
+
api_key: z16.string().nullable()
|
|
4084
4161
|
});
|
|
4085
4162
|
|
|
4086
4163
|
// src/_api/generated/_cfg_accounts/schemas/OTPVerifyResponse.ts
|
|
4087
|
-
var OTPVerifyResponseSchema =
|
|
4088
|
-
requires_2fa:
|
|
4089
|
-
session_id:
|
|
4090
|
-
refresh:
|
|
4091
|
-
access:
|
|
4164
|
+
var OTPVerifyResponseSchema = z17.object({
|
|
4165
|
+
requires_2fa: z17.boolean().default(false).optional(),
|
|
4166
|
+
session_id: z17.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(),
|
|
4167
|
+
refresh: z17.string().nullable().optional(),
|
|
4168
|
+
access: z17.string().nullable().optional(),
|
|
4092
4169
|
user: UserSchema.nullable().optional(),
|
|
4093
|
-
should_prompt_2fa:
|
|
4170
|
+
should_prompt_2fa: z17.boolean().optional()
|
|
4094
4171
|
});
|
|
4095
4172
|
|
|
4096
4173
|
// src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOtpVerifyCreate.ts
|
|
@@ -4192,10 +4269,10 @@ __name(useCfgAccountsProfileAvatarCreate, "useCfgAccountsProfileAvatarCreate");
|
|
|
4192
4269
|
import useSWRMutation10 from "swr/mutation";
|
|
4193
4270
|
|
|
4194
4271
|
// src/_api/generated/_cfg_accounts/schemas/AccountDeleteResponse.ts
|
|
4195
|
-
import { z as
|
|
4196
|
-
var AccountDeleteResponseSchema =
|
|
4197
|
-
success:
|
|
4198
|
-
message:
|
|
4272
|
+
import { z as z18 } from "zod";
|
|
4273
|
+
var AccountDeleteResponseSchema = z18.object({
|
|
4274
|
+
success: z18.boolean(),
|
|
4275
|
+
message: z18.string()
|
|
4199
4276
|
});
|
|
4200
4277
|
|
|
4201
4278
|
// src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfilePartialPartialUpdate.ts
|
|
@@ -4307,10 +4384,10 @@ __name(useCfgAccountsProfileUpdateUpdate, "useCfgAccountsProfileUpdateUpdate");
|
|
|
4307
4384
|
import useSWRMutation15 from "swr/mutation";
|
|
4308
4385
|
|
|
4309
4386
|
// src/_api/generated/_cfg_accounts/schemas/TokenRefresh.ts
|
|
4310
|
-
import { z as
|
|
4311
|
-
var TokenRefreshSchema =
|
|
4312
|
-
access:
|
|
4313
|
-
refresh:
|
|
4387
|
+
import { z as z19 } from "zod";
|
|
4388
|
+
var TokenRefreshSchema = z19.object({
|
|
4389
|
+
access: z19.string(),
|
|
4390
|
+
refresh: z19.string()
|
|
4314
4391
|
});
|
|
4315
4392
|
|
|
4316
4393
|
// src/_api/generated/_cfg_accounts/hooks/useCfgAccountsTokenRefreshCreate.ts
|
|
@@ -4361,98 +4438,98 @@ function useCfgAccountsTokenRefreshCreate(config) {
|
|
|
4361
4438
|
__name(useCfgAccountsTokenRefreshCreate, "useCfgAccountsTokenRefreshCreate");
|
|
4362
4439
|
|
|
4363
4440
|
// src/_api/generated/_cfg_accounts/schemas/APIKeyRequest.ts
|
|
4364
|
-
import { z as
|
|
4365
|
-
var APIKeyRequestSchema =
|
|
4366
|
-
key:
|
|
4367
|
-
reissued_at:
|
|
4368
|
-
created_at:
|
|
4441
|
+
import { z as z20 } from "zod";
|
|
4442
|
+
var APIKeyRequestSchema = z20.object({
|
|
4443
|
+
key: z20.string().min(1),
|
|
4444
|
+
reissued_at: z20.string().datetime({ offset: true }).nullable(),
|
|
4445
|
+
created_at: z20.string().datetime({ offset: true })
|
|
4369
4446
|
});
|
|
4370
4447
|
|
|
4371
4448
|
// src/_api/generated/_cfg_accounts/schemas/APIKeyTestRequest.ts
|
|
4372
|
-
import { z as
|
|
4373
|
-
var APIKeyTestRequestSchema =
|
|
4374
|
-
key:
|
|
4449
|
+
import { z as z21 } from "zod";
|
|
4450
|
+
var APIKeyTestRequestSchema = z21.object({
|
|
4451
|
+
key: z21.string().min(1)
|
|
4375
4452
|
});
|
|
4376
4453
|
|
|
4377
4454
|
// src/_api/generated/_cfg_accounts/schemas/CfgUserUpdateRequest.ts
|
|
4378
|
-
import { z as
|
|
4379
|
-
var CfgUserUpdateRequestSchema =
|
|
4380
|
-
first_name:
|
|
4381
|
-
last_name:
|
|
4382
|
-
company:
|
|
4383
|
-
phone:
|
|
4384
|
-
position:
|
|
4385
|
-
language:
|
|
4386
|
-
timezone:
|
|
4455
|
+
import { z as z22 } from "zod";
|
|
4456
|
+
var CfgUserUpdateRequestSchema = z22.object({
|
|
4457
|
+
first_name: z22.string().max(50).optional(),
|
|
4458
|
+
last_name: z22.string().max(50).optional(),
|
|
4459
|
+
company: z22.string().max(100).optional(),
|
|
4460
|
+
phone: z22.string().max(20).optional(),
|
|
4461
|
+
position: z22.string().max(100).optional(),
|
|
4462
|
+
language: z22.string().max(10).optional(),
|
|
4463
|
+
timezone: z22.string().max(64).optional()
|
|
4387
4464
|
});
|
|
4388
4465
|
|
|
4389
4466
|
// src/_api/generated/_cfg_accounts/schemas/OAuthAuthorizeRequestRequest.ts
|
|
4390
|
-
import { z as
|
|
4391
|
-
var OAuthAuthorizeRequestRequestSchema =
|
|
4392
|
-
redirect_uri:
|
|
4393
|
-
source_url:
|
|
4467
|
+
import { z as z23 } from "zod";
|
|
4468
|
+
var OAuthAuthorizeRequestRequestSchema = z23.object({
|
|
4469
|
+
redirect_uri: z23.string().optional(),
|
|
4470
|
+
source_url: z23.string().optional()
|
|
4394
4471
|
});
|
|
4395
4472
|
|
|
4396
4473
|
// src/_api/generated/_cfg_accounts/schemas/OAuthCallbackRequestRequest.ts
|
|
4397
|
-
import { z as
|
|
4398
|
-
var OAuthCallbackRequestRequestSchema =
|
|
4399
|
-
code:
|
|
4400
|
-
state:
|
|
4401
|
-
redirect_uri:
|
|
4474
|
+
import { z as z24 } from "zod";
|
|
4475
|
+
var OAuthCallbackRequestRequestSchema = z24.object({
|
|
4476
|
+
code: z24.string().min(10).max(500),
|
|
4477
|
+
state: z24.string().min(20).max(100),
|
|
4478
|
+
redirect_uri: z24.string().optional()
|
|
4402
4479
|
});
|
|
4403
4480
|
|
|
4404
4481
|
// src/_api/generated/_cfg_accounts/schemas/OAuthDisconnectRequestRequest.ts
|
|
4405
|
-
import { z as
|
|
4406
|
-
var OAuthDisconnectRequestRequestSchema =
|
|
4482
|
+
import { z as z25 } from "zod";
|
|
4483
|
+
var OAuthDisconnectRequestRequestSchema = z25.object({
|
|
4407
4484
|
provider: OAuthProviderEnumSchema
|
|
4408
4485
|
});
|
|
4409
4486
|
|
|
4410
4487
|
// src/_api/generated/_cfg_accounts/schemas/OAuthError.ts
|
|
4411
|
-
import { z as
|
|
4412
|
-
var OAuthErrorSchema =
|
|
4413
|
-
error:
|
|
4414
|
-
error_description:
|
|
4488
|
+
import { z as z26 } from "zod";
|
|
4489
|
+
var OAuthErrorSchema = z26.object({
|
|
4490
|
+
error: z26.string(),
|
|
4491
|
+
error_description: z26.string().optional()
|
|
4415
4492
|
});
|
|
4416
4493
|
|
|
4417
4494
|
// src/_api/generated/_cfg_accounts/schemas/OTPErrorResponse.ts
|
|
4418
|
-
import { z as
|
|
4419
|
-
var OTPErrorResponseSchema =
|
|
4420
|
-
error:
|
|
4421
|
-
error_code:
|
|
4422
|
-
retry_after:
|
|
4495
|
+
import { z as z27 } from "zod";
|
|
4496
|
+
var OTPErrorResponseSchema = z27.object({
|
|
4497
|
+
error: z27.string(),
|
|
4498
|
+
error_code: z27.string().nullable().optional(),
|
|
4499
|
+
retry_after: z27.number().int().nullable().optional()
|
|
4423
4500
|
});
|
|
4424
4501
|
|
|
4425
4502
|
// src/_api/generated/_cfg_accounts/schemas/OTPRequestRequest.ts
|
|
4426
|
-
import { z as
|
|
4427
|
-
var OTPRequestRequestSchema =
|
|
4428
|
-
identifier:
|
|
4429
|
-
source_url:
|
|
4503
|
+
import { z as z28 } from "zod";
|
|
4504
|
+
var OTPRequestRequestSchema = z28.object({
|
|
4505
|
+
identifier: z28.string().min(1),
|
|
4506
|
+
source_url: z28.string().optional()
|
|
4430
4507
|
});
|
|
4431
4508
|
|
|
4432
4509
|
// src/_api/generated/_cfg_accounts/schemas/OTPVerifyRequest.ts
|
|
4433
|
-
import { z as
|
|
4434
|
-
var OTPVerifyRequestSchema =
|
|
4435
|
-
identifier:
|
|
4436
|
-
otp:
|
|
4437
|
-
source_url:
|
|
4510
|
+
import { z as z29 } from "zod";
|
|
4511
|
+
var OTPVerifyRequestSchema = z29.object({
|
|
4512
|
+
identifier: z29.string().min(1),
|
|
4513
|
+
otp: z29.string().min(4).max(4),
|
|
4514
|
+
source_url: z29.string().optional()
|
|
4438
4515
|
});
|
|
4439
4516
|
|
|
4440
4517
|
// src/_api/generated/_cfg_accounts/schemas/PatchedCfgUserUpdateRequest.ts
|
|
4441
|
-
import { z as
|
|
4442
|
-
var PatchedCfgUserUpdateRequestSchema =
|
|
4443
|
-
first_name:
|
|
4444
|
-
last_name:
|
|
4445
|
-
company:
|
|
4446
|
-
phone:
|
|
4447
|
-
position:
|
|
4448
|
-
language:
|
|
4449
|
-
timezone:
|
|
4518
|
+
import { z as z30 } from "zod";
|
|
4519
|
+
var PatchedCfgUserUpdateRequestSchema = z30.object({
|
|
4520
|
+
first_name: z30.string().max(50).optional(),
|
|
4521
|
+
last_name: z30.string().max(50).optional(),
|
|
4522
|
+
company: z30.string().max(100).optional(),
|
|
4523
|
+
phone: z30.string().max(20).optional(),
|
|
4524
|
+
position: z30.string().max(100).optional(),
|
|
4525
|
+
language: z30.string().max(10).optional(),
|
|
4526
|
+
timezone: z30.string().max(64).optional()
|
|
4450
4527
|
});
|
|
4451
4528
|
|
|
4452
4529
|
// src/_api/generated/_cfg_accounts/schemas/TokenRefreshRequest.ts
|
|
4453
|
-
import { z as
|
|
4454
|
-
var TokenRefreshRequestSchema =
|
|
4455
|
-
refresh:
|
|
4530
|
+
import { z as z31 } from "zod";
|
|
4531
|
+
var TokenRefreshRequestSchema = z31.object({
|
|
4532
|
+
refresh: z31.string().min(1)
|
|
4456
4533
|
});
|
|
4457
4534
|
|
|
4458
4535
|
// src/auth/context/AccountsContext.tsx
|
|
@@ -4465,8 +4542,8 @@ function AccountsProvider({ children }) {
|
|
|
4465
4542
|
});
|
|
4466
4543
|
const [isLoadingProfile, setIsLoadingProfile] = useState11(false);
|
|
4467
4544
|
const [profileError, setProfileError] = useState11(null);
|
|
4468
|
-
const profileRef =
|
|
4469
|
-
const isLoadingRef =
|
|
4545
|
+
const profileRef = useRef5(profile);
|
|
4546
|
+
const isLoadingRef = useRef5(false);
|
|
4470
4547
|
useEffect8(() => {
|
|
4471
4548
|
profileRef.current = profile;
|
|
4472
4549
|
}, [profile]);
|
|
@@ -4608,6 +4685,7 @@ var hasValidTokens = /* @__PURE__ */ __name(() => {
|
|
|
4608
4685
|
}, "hasValidTokens");
|
|
4609
4686
|
var AuthProviderInternal = /* @__PURE__ */ __name(({ children, config }) => {
|
|
4610
4687
|
const accounts = useAccountsContext();
|
|
4688
|
+
ensureRefreshHandler();
|
|
4611
4689
|
const redirectManager = useAuthRedirectManager({
|
|
4612
4690
|
fallbackUrl: config?.routes?.defaultCallback || defaultRoutes.defaultCallback,
|
|
4613
4691
|
clearOnUse: true
|
|
@@ -4634,9 +4712,9 @@ var AuthProviderInternal = /* @__PURE__ */ __name(({ children, config }) => {
|
|
|
4634
4712
|
}, "onRefreshError")
|
|
4635
4713
|
});
|
|
4636
4714
|
const user = accounts.profile;
|
|
4637
|
-
const userRef =
|
|
4638
|
-
const configRef =
|
|
4639
|
-
const isLoadingProfileRef =
|
|
4715
|
+
const userRef = useRef6(user);
|
|
4716
|
+
const configRef = useRef6(config);
|
|
4717
|
+
const isLoadingProfileRef = useRef6(false);
|
|
4640
4718
|
useEffect9(() => {
|
|
4641
4719
|
userRef.current = user;
|
|
4642
4720
|
}, [user]);
|
|
@@ -4662,7 +4740,7 @@ var AuthProviderInternal = /* @__PURE__ */ __name(({ children, config }) => {
|
|
|
4662
4740
|
}
|
|
4663
4741
|
return false;
|
|
4664
4742
|
}, [clearAuthState]);
|
|
4665
|
-
const isAutoLoggingOutRef =
|
|
4743
|
+
const isAutoLoggingOutRef = useRef6(false);
|
|
4666
4744
|
const swrOnError = useCallback12((error) => {
|
|
4667
4745
|
const isAuthError = error?.status === 401 || error?.statusCode === 401 || error?.code === "token_not_valid" || error?.code === "authentication_failed";
|
|
4668
4746
|
if (isAuthError && !isAutoLoggingOutRef.current) {
|
|
@@ -4826,7 +4904,8 @@ var AuthProviderInternal = /* @__PURE__ */ __name(({ children, config }) => {
|
|
|
4826
4904
|
});
|
|
4827
4905
|
return {
|
|
4828
4906
|
success: true,
|
|
4829
|
-
message: result.message || `OTP code sent to your email address
|
|
4907
|
+
message: result.message || `OTP code sent to your email address`,
|
|
4908
|
+
webmail: result.webmail ?? null
|
|
4830
4909
|
};
|
|
4831
4910
|
} catch (error) {
|
|
4832
4911
|
authLogger.error("Request OTP error:", error);
|