@djangocfg/api 2.1.448 → 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.
Files changed (51) hide show
  1. package/dist/auth-server.cjs +1 -2272
  2. package/dist/auth-server.cjs.map +1 -1
  3. package/dist/auth-server.d.cts +1 -35
  4. package/dist/auth-server.d.ts +1 -35
  5. package/dist/auth-server.mjs +1 -2272
  6. package/dist/auth-server.mjs.map +1 -1
  7. package/dist/auth.cjs +207 -128
  8. package/dist/auth.cjs.map +1 -1
  9. package/dist/auth.d.cts +135 -2
  10. package/dist/auth.d.ts +135 -2
  11. package/dist/auth.mjs +216 -137
  12. package/dist/auth.mjs.map +1 -1
  13. package/dist/clients.cjs +35 -0
  14. package/dist/clients.cjs.map +1 -1
  15. package/dist/clients.d.cts +147 -2
  16. package/dist/clients.d.ts +147 -2
  17. package/dist/clients.mjs +35 -0
  18. package/dist/clients.mjs.map +1 -1
  19. package/dist/hooks.cjs +11 -0
  20. package/dist/hooks.cjs.map +1 -1
  21. package/dist/hooks.mjs +11 -0
  22. package/dist/hooks.mjs.map +1 -1
  23. package/dist/index.cjs +35 -0
  24. package/dist/index.cjs.map +1 -1
  25. package/dist/index.d.cts +169 -6
  26. package/dist/index.d.ts +169 -6
  27. package/dist/index.mjs +35 -0
  28. package/dist/index.mjs.map +1 -1
  29. package/package.json +7 -4
  30. package/src/_api/generated/_cfg_accounts/api.ts +8 -0
  31. package/src/_api/generated/_cfg_accounts/openapi.json +84 -5
  32. package/src/_api/generated/_cfg_accounts/schemas/OAuthTokenResponse.ts +2 -2
  33. package/src/_api/generated/_cfg_accounts/schemas/OTPRequestResponse.ts +2 -0
  34. package/src/_api/generated/_cfg_accounts/schemas/WebmailLink.ts +15 -0
  35. package/src/_api/generated/_cfg_accounts/schemas/WebmailLinkProviderEnum.ts +9 -0
  36. package/src/_api/generated/_cfg_accounts/schemas/index.ts +2 -0
  37. package/src/_api/generated/_cfg_centrifugo/api.ts +8 -0
  38. package/src/_api/generated/_cfg_totp/api.ts +8 -0
  39. package/src/_api/generated/helpers/auth.ts +12 -0
  40. package/src/_api/generated/openapi.json +84 -5
  41. package/src/_api/generated/types.gen.ts +131 -2
  42. package/src/auth/__tests__/refreshRotation.test.ts +119 -0
  43. package/src/auth/context/AuthContext.tsx +10 -1
  44. package/src/auth/hooks/useAuthForm.ts +5 -2
  45. package/src/auth/hooks/useAuthFormState.ts +4 -1
  46. package/src/auth/hooks/useTokenRefresh.ts +29 -45
  47. package/src/auth/middlewares/index.ts +7 -7
  48. package/src/auth/refreshHandler.ts +79 -0
  49. package/src/auth/types/form.ts +10 -0
  50. package/src/auth/types/index.ts +1 -0
  51. package/src/auth/middlewares/tokenRefresh.ts +0 -161
package/dist/auth.cjs CHANGED
@@ -223,6 +223,7 @@ var useAuthFormState = /* @__PURE__ */ __name((initialIdentifier = "") => {
223
223
  const [acceptedTerms, setAcceptedTerms] = (0, import_react3.useState)(true);
224
224
  const [step, setStep] = (0, import_react3.useState)("identifier");
225
225
  const [error, setError] = (0, import_react3.useState)("");
226
+ const [webmail, setWebmail] = (0, import_react3.useState)(null);
226
227
  const [twoFactorSessionId, setTwoFactorSessionId] = (0, import_react3.useState)(null);
227
228
  const [shouldPrompt2FA, setShouldPrompt2FA] = (0, import_react3.useState)(false);
228
229
  const [twoFactorCode, setTwoFactorCode] = (0, import_react3.useState)("");
@@ -262,6 +263,7 @@ var useAuthFormState = /* @__PURE__ */ __name((initialIdentifier = "") => {
262
263
  rateLimitSeconds,
263
264
  isRateLimited: rateLimitSeconds > 0,
264
265
  rateLimitLabel: formatCountdown(rateLimitSeconds),
266
+ webmail,
265
267
  // Handlers
266
268
  setIdentifier,
267
269
  setOtp,
@@ -274,7 +276,8 @@ var useAuthFormState = /* @__PURE__ */ __name((initialIdentifier = "") => {
274
276
  setShouldPrompt2FA,
275
277
  setTwoFactorCode,
276
278
  setUseBackupCode,
277
- startRateLimitCountdown
279
+ startRateLimitCountdown,
280
+ setWebmail
278
281
  };
279
282
  }, "useAuthFormState");
280
283
 
@@ -660,6 +663,17 @@ var auth = {
660
663
  */
661
664
  setRefreshHandler(fn) {
662
665
  _refreshHandler = fn;
666
+ },
667
+ /**
668
+ * Proactively run the registered refresh handler right now, reusing the
669
+ * SAME single-flight promise as the 401-recovery interceptor. Callers
670
+ * (e.g. an expiry timer / focus / reconnect) get token rotation,
671
+ * de-duplication and rotated-token persistence for free — they must NOT
672
+ * re-implement any of it. Returns the fresh access token, or null if
673
+ * there is no handler / no refresh token / the refresh failed.
674
+ */
675
+ refreshNow() {
676
+ return tryRefresh();
663
677
  }
664
678
  };
665
679
  async function tryRefresh() {
@@ -2383,6 +2397,14 @@ var API = class {
2383
2397
  setRefreshHandler(fn) {
2384
2398
  auth.setRefreshHandler(fn);
2385
2399
  }
2400
+ /**
2401
+ * Proactively refresh now via the registered handler, sharing the single
2402
+ * 401-recovery flight (rotation + dedup + rotated-token persistence).
2403
+ * See `auth.refreshNow`.
2404
+ */
2405
+ refreshNow() {
2406
+ return auth.refreshNow();
2407
+ }
2386
2408
  };
2387
2409
 
2388
2410
  // src/_api/generated/_cfg_centrifugo/api.ts
@@ -2447,6 +2469,14 @@ var API2 = class {
2447
2469
  setRefreshHandler(fn) {
2448
2470
  auth.setRefreshHandler(fn);
2449
2471
  }
2472
+ /**
2473
+ * Proactively refresh now via the registered handler, sharing the single
2474
+ * 401-recovery flight (rotation + dedup + rotated-token persistence).
2475
+ * See `auth.refreshNow`.
2476
+ */
2477
+ refreshNow() {
2478
+ return auth.refreshNow();
2479
+ }
2450
2480
  };
2451
2481
 
2452
2482
  // src/_api/generated/_cfg_totp/api.ts
@@ -2514,6 +2544,14 @@ var API3 = class {
2514
2544
  setRefreshHandler(fn) {
2515
2545
  auth.setRefreshHandler(fn);
2516
2546
  }
2547
+ /**
2548
+ * Proactively refresh now via the registered handler, sharing the single
2549
+ * 401-recovery flight (rotation + dedup + rotated-token persistence).
2550
+ * See `auth.refreshNow`.
2551
+ */
2552
+ refreshNow() {
2553
+ return auth.refreshNow();
2554
+ }
2517
2555
  };
2518
2556
 
2519
2557
  // src/_api/generated/index.ts
@@ -2734,7 +2772,8 @@ var useAuthForm = /* @__PURE__ */ __name((options) => {
2734
2772
  setShouldPrompt2FA,
2735
2773
  setTwoFactorCode,
2736
2774
  setUseBackupCode,
2737
- startRateLimitCountdown
2775
+ startRateLimitCountdown,
2776
+ setWebmail
2738
2777
  } = formState;
2739
2778
  const twoFactor = useTwoFactor({
2740
2779
  onSuccess: /* @__PURE__ */ __name(() => {
@@ -2786,6 +2825,7 @@ var useAuthForm = /* @__PURE__ */ __name((options) => {
2786
2825
  const result = await requestOTP(identifier, sourceUrl);
2787
2826
  if (result.success) {
2788
2827
  saveIdentifierToStorage(identifier);
2828
+ setWebmail(result.webmail ?? null);
2789
2829
  setStep("otp");
2790
2830
  onIdentifierSuccess?.(identifier);
2791
2831
  } else {
@@ -2815,6 +2855,7 @@ var useAuthForm = /* @__PURE__ */ __name((options) => {
2815
2855
  setIsLoading,
2816
2856
  setStep,
2817
2857
  clearError,
2858
+ setWebmail,
2818
2859
  startRateLimitCountdown,
2819
2860
  onIdentifierSuccess,
2820
2861
  onError,
@@ -2870,6 +2911,7 @@ var useAuthForm = /* @__PURE__ */ __name((options) => {
2870
2911
  const result = await requestOTP(identifier, sourceUrl);
2871
2912
  if (result.success) {
2872
2913
  saveIdentifierToStorage(identifier);
2914
+ setWebmail(result.webmail ?? null);
2873
2915
  setOtp("");
2874
2916
  } else {
2875
2917
  if (result.retryAfter) {
@@ -2887,7 +2929,7 @@ var useAuthForm = /* @__PURE__ */ __name((options) => {
2887
2929
  } finally {
2888
2930
  setIsLoading(false);
2889
2931
  }
2890
- }, [identifier, requestOTP, saveIdentifierToStorage, setOtp, setError, setIsLoading, clearError, startRateLimitCountdown, onError, sourceUrl]);
2932
+ }, [identifier, requestOTP, saveIdentifierToStorage, setOtp, setError, setIsLoading, clearError, startRateLimitCountdown, setWebmail, onError, sourceUrl]);
2891
2933
  const handleBackToIdentifier = (0, import_react7.useCallback)(() => {
2892
2934
  setStep("identifier");
2893
2935
  clearError();
@@ -3790,6 +3832,39 @@ __name(getCacheMetadata, "getCacheMetadata");
3790
3832
 
3791
3833
  // src/auth/hooks/useTokenRefresh.ts
3792
3834
  var import_react14 = require("react");
3835
+
3836
+ // src/auth/refreshHandler.ts
3837
+ var _registered = false;
3838
+ function ensureRefreshHandler() {
3839
+ if (_registered) return;
3840
+ _registered = true;
3841
+ CfgAccountsApi.setRefreshHandler(async (refresh) => {
3842
+ const result = await CfgAccountsAuth.cfgAccountsTokenRefreshCreate({
3843
+ body: { refresh },
3844
+ throwOnError: true
3845
+ });
3846
+ const access = result.data?.access;
3847
+ if (!access) {
3848
+ authLogger.error("Refresh response missing access token");
3849
+ return null;
3850
+ }
3851
+ return { access, refresh: result.data?.refresh ?? refresh };
3852
+ });
3853
+ authLogger.debug("Canonical refresh handler registered");
3854
+ }
3855
+ __name(ensureRefreshHandler, "ensureRefreshHandler");
3856
+ function triggerRefresh() {
3857
+ ensureRefreshHandler();
3858
+ const maybe = CfgAccountsApi;
3859
+ if (typeof maybe.refreshNow === "function") {
3860
+ return maybe.refreshNow();
3861
+ }
3862
+ authLogger.warn("api.refreshNow() unavailable \u2014 run `make generate` to regenerate the client");
3863
+ return Promise.resolve(null);
3864
+ }
3865
+ __name(triggerRefresh, "triggerRefresh");
3866
+
3867
+ // src/auth/hooks/useTokenRefresh.ts
3793
3868
  var TOKEN_REFRESH_THRESHOLD_MS = 10 * 60 * 1e3;
3794
3869
  var CHECK_INTERVAL_MS = 5 * 60 * 1e3;
3795
3870
  function getTokenExpiry(token) {
@@ -3804,36 +3879,22 @@ __name(getTokenExpiry, "getTokenExpiry");
3804
3879
  function isTokenExpiringSoon(token, thresholdMs) {
3805
3880
  const expiry = getTokenExpiry(token);
3806
3881
  if (!expiry) return false;
3807
- const timeUntilExpiry = expiry - Date.now();
3808
- return timeUntilExpiry < thresholdMs;
3882
+ return expiry - Date.now() < thresholdMs;
3809
3883
  }
3810
3884
  __name(isTokenExpiringSoon, "isTokenExpiringSoon");
3811
3885
  function useTokenRefresh(options = {}) {
3812
3886
  const { enabled = true, onRefresh, onRefreshError } = options;
3813
- const isRefreshingRef = (0, import_react14.useRef)(false);
3814
3887
  const refreshToken = (0, import_react14.useCallback)(async () => {
3815
- if (isRefreshingRef.current) {
3816
- authLogger.debug("Token refresh already in progress");
3817
- return false;
3818
- }
3819
- const refreshTokenValue = CfgAccountsApi.getRefreshToken();
3820
- if (!refreshTokenValue) {
3888
+ if (!CfgAccountsApi.getRefreshToken()) {
3821
3889
  authLogger.warn("No refresh token available");
3822
3890
  return false;
3823
3891
  }
3824
- isRefreshingRef.current = true;
3825
3892
  authLogger.info("Refreshing token...");
3826
3893
  try {
3827
- const result = await CfgAccountsAuth.cfgAccountsTokenRefreshCreate({
3828
- body: { refresh: refreshTokenValue },
3829
- throwOnError: true
3830
- });
3831
- const newAccessToken = result.data.access;
3894
+ const newAccessToken = await triggerRefresh();
3832
3895
  if (!newAccessToken) {
3833
- throw new Error("No access token in refresh response");
3896
+ throw new Error("Token refresh failed");
3834
3897
  }
3835
- CfgAccountsApi.setToken(newAccessToken);
3836
- CfgAccountsApi.setRefreshToken(refreshTokenValue);
3837
3898
  authLogger.info("Token refreshed successfully");
3838
3899
  onRefresh?.(newAccessToken);
3839
3900
  return true;
@@ -3841,8 +3902,6 @@ function useTokenRefresh(options = {}) {
3841
3902
  authLogger.error("Token refresh error:", error);
3842
3903
  onRefreshError?.(error instanceof Error ? error : new Error(String(error)));
3843
3904
  return false;
3844
- } finally {
3845
- isRefreshingRef.current = false;
3846
3905
  }
3847
3906
  }, [onRefresh, onRefreshError]);
3848
3907
  const checkAndRefresh = (0, import_react14.useCallback)(async () => {
@@ -4025,8 +4084,8 @@ var OAuthTokenResponseSchema = import_zod10.z.object({
4025
4084
  access: import_zod10.z.string().nullable().optional(),
4026
4085
  refresh: import_zod10.z.string().nullable().optional(),
4027
4086
  user: import_zod10.z.object({}).passthrough().nullable().optional(),
4028
- is_new_user: import_zod10.z.boolean(),
4029
- is_new_connection: import_zod10.z.boolean(),
4087
+ is_new_user: import_zod10.z.boolean().default(false).optional(),
4088
+ is_new_connection: import_zod10.z.boolean().default(false).optional(),
4030
4089
  should_prompt_2fa: import_zod10.z.boolean().optional()
4031
4090
  });
4032
4091
 
@@ -4043,9 +4102,27 @@ var OAuthProvidersResponseSchema = import_zod11.z.object({
4043
4102
  var import_mutation7 = __toESM(require("swr/mutation"), 1);
4044
4103
 
4045
4104
  // src/_api/generated/_cfg_accounts/schemas/OTPRequestResponse.ts
4105
+ var import_zod14 = require("zod");
4106
+
4107
+ // src/_api/generated/_cfg_accounts/schemas/WebmailLink.ts
4108
+ var import_zod13 = require("zod");
4109
+
4110
+ // src/_api/generated/_cfg_accounts/schemas/WebmailLinkProviderEnum.ts
4046
4111
  var import_zod12 = require("zod");
4047
- var OTPRequestResponseSchema = import_zod12.z.object({
4048
- message: import_zod12.z.string()
4112
+ var WebmailLinkProviderEnumSchema = import_zod12.z.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"]);
4113
+
4114
+ // src/_api/generated/_cfg_accounts/schemas/WebmailLink.ts
4115
+ var WebmailLinkSchema = import_zod13.z.object({
4116
+ provider: WebmailLinkProviderEnumSchema,
4117
+ provider_name: import_zod13.z.string(),
4118
+ url: import_zod13.z.string(),
4119
+ is_search: import_zod13.z.boolean()
4120
+ });
4121
+
4122
+ // src/_api/generated/_cfg_accounts/schemas/OTPRequestResponse.ts
4123
+ var OTPRequestResponseSchema = import_zod14.z.object({
4124
+ message: import_zod14.z.string(),
4125
+ webmail: WebmailLinkSchema.nullable().optional()
4049
4126
  });
4050
4127
 
4051
4128
  // src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOtpRequestCreate.ts
@@ -4099,52 +4176,52 @@ __name(useCfgAccountsOtpRequestCreate, "useCfgAccountsOtpRequestCreate");
4099
4176
  var import_mutation8 = __toESM(require("swr/mutation"), 1);
4100
4177
 
4101
4178
  // src/_api/generated/_cfg_accounts/schemas/OTPVerifyResponse.ts
4102
- var import_zod15 = require("zod");
4179
+ var import_zod17 = require("zod");
4103
4180
 
4104
4181
  // src/_api/generated/_cfg_accounts/schemas/User.ts
4105
- var import_zod14 = require("zod");
4182
+ var import_zod16 = require("zod");
4106
4183
 
4107
4184
  // src/_api/generated/_cfg_accounts/schemas/CentrifugoToken.ts
4108
- var import_zod13 = require("zod");
4109
- var CentrifugoTokenSchema = import_zod13.z.object({
4110
- token: import_zod13.z.string(),
4111
- centrifugo_url: import_zod13.z.string(),
4112
- expires_at: import_zod13.z.string().datetime({ offset: true }),
4113
- channels: import_zod13.z.array(import_zod13.z.string())
4185
+ var import_zod15 = require("zod");
4186
+ var CentrifugoTokenSchema = import_zod15.z.object({
4187
+ token: import_zod15.z.string(),
4188
+ centrifugo_url: import_zod15.z.string(),
4189
+ expires_at: import_zod15.z.string().datetime({ offset: true }),
4190
+ channels: import_zod15.z.array(import_zod15.z.string())
4114
4191
  });
4115
4192
 
4116
4193
  // src/_api/generated/_cfg_accounts/schemas/User.ts
4117
- var UserSchema = import_zod14.z.object({
4118
- id: import_zod14.z.number().int(),
4119
- email: import_zod14.z.email(),
4120
- first_name: import_zod14.z.string().max(50).nullable().optional(),
4121
- last_name: import_zod14.z.string().max(50).nullable().optional(),
4122
- full_name: import_zod14.z.string(),
4123
- initials: import_zod14.z.string(),
4124
- display_username: import_zod14.z.string(),
4125
- company: import_zod14.z.string().max(100).nullable().optional(),
4126
- phone: import_zod14.z.string().max(20).nullable().optional(),
4127
- position: import_zod14.z.string().max(100).nullable().optional(),
4128
- language: import_zod14.z.string().max(10).nullable().optional(),
4129
- timezone: import_zod14.z.string().max(64).nullable().optional(),
4130
- avatar: import_zod14.z.string().nullable(),
4131
- is_staff: import_zod14.z.boolean(),
4132
- is_superuser: import_zod14.z.boolean(),
4133
- date_joined: import_zod14.z.string().datetime({ offset: true }),
4134
- last_login: import_zod14.z.string().datetime({ offset: true }).nullable(),
4135
- unanswered_messages_count: import_zod14.z.number().int().default(0),
4194
+ var UserSchema = import_zod16.z.object({
4195
+ id: import_zod16.z.number().int(),
4196
+ email: import_zod16.z.email(),
4197
+ first_name: import_zod16.z.string().max(50).nullable().optional(),
4198
+ last_name: import_zod16.z.string().max(50).nullable().optional(),
4199
+ full_name: import_zod16.z.string(),
4200
+ initials: import_zod16.z.string(),
4201
+ display_username: import_zod16.z.string(),
4202
+ company: import_zod16.z.string().max(100).nullable().optional(),
4203
+ phone: import_zod16.z.string().max(20).nullable().optional(),
4204
+ position: import_zod16.z.string().max(100).nullable().optional(),
4205
+ language: import_zod16.z.string().max(10).nullable().optional(),
4206
+ timezone: import_zod16.z.string().max(64).nullable().optional(),
4207
+ avatar: import_zod16.z.string().nullable(),
4208
+ is_staff: import_zod16.z.boolean(),
4209
+ is_superuser: import_zod16.z.boolean(),
4210
+ date_joined: import_zod16.z.string().datetime({ offset: true }),
4211
+ last_login: import_zod16.z.string().datetime({ offset: true }).nullable(),
4212
+ unanswered_messages_count: import_zod16.z.number().int().default(0),
4136
4213
  centrifugo: CentrifugoTokenSchema.nullable(),
4137
- api_key: import_zod14.z.string().nullable()
4214
+ api_key: import_zod16.z.string().nullable()
4138
4215
  });
4139
4216
 
4140
4217
  // src/_api/generated/_cfg_accounts/schemas/OTPVerifyResponse.ts
4141
- var OTPVerifyResponseSchema = import_zod15.z.object({
4142
- requires_2fa: import_zod15.z.boolean().default(false).optional(),
4143
- session_id: import_zod15.z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i).nullable().optional(),
4144
- refresh: import_zod15.z.string().nullable().optional(),
4145
- access: import_zod15.z.string().nullable().optional(),
4218
+ var OTPVerifyResponseSchema = import_zod17.z.object({
4219
+ requires_2fa: import_zod17.z.boolean().default(false).optional(),
4220
+ session_id: import_zod17.z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i).nullable().optional(),
4221
+ refresh: import_zod17.z.string().nullable().optional(),
4222
+ access: import_zod17.z.string().nullable().optional(),
4146
4223
  user: UserSchema.nullable().optional(),
4147
- should_prompt_2fa: import_zod15.z.boolean().optional()
4224
+ should_prompt_2fa: import_zod17.z.boolean().optional()
4148
4225
  });
4149
4226
 
4150
4227
  // src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOtpVerifyCreate.ts
@@ -4246,10 +4323,10 @@ __name(useCfgAccountsProfileAvatarCreate, "useCfgAccountsProfileAvatarCreate");
4246
4323
  var import_mutation10 = __toESM(require("swr/mutation"), 1);
4247
4324
 
4248
4325
  // src/_api/generated/_cfg_accounts/schemas/AccountDeleteResponse.ts
4249
- var import_zod16 = require("zod");
4250
- var AccountDeleteResponseSchema = import_zod16.z.object({
4251
- success: import_zod16.z.boolean(),
4252
- message: import_zod16.z.string()
4326
+ var import_zod18 = require("zod");
4327
+ var AccountDeleteResponseSchema = import_zod18.z.object({
4328
+ success: import_zod18.z.boolean(),
4329
+ message: import_zod18.z.string()
4253
4330
  });
4254
4331
 
4255
4332
  // src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfilePartialPartialUpdate.ts
@@ -4361,10 +4438,10 @@ __name(useCfgAccountsProfileUpdateUpdate, "useCfgAccountsProfileUpdateUpdate");
4361
4438
  var import_mutation15 = __toESM(require("swr/mutation"), 1);
4362
4439
 
4363
4440
  // src/_api/generated/_cfg_accounts/schemas/TokenRefresh.ts
4364
- var import_zod17 = require("zod");
4365
- var TokenRefreshSchema = import_zod17.z.object({
4366
- access: import_zod17.z.string(),
4367
- refresh: import_zod17.z.string()
4441
+ var import_zod19 = require("zod");
4442
+ var TokenRefreshSchema = import_zod19.z.object({
4443
+ access: import_zod19.z.string(),
4444
+ refresh: import_zod19.z.string()
4368
4445
  });
4369
4446
 
4370
4447
  // src/_api/generated/_cfg_accounts/hooks/useCfgAccountsTokenRefreshCreate.ts
@@ -4415,98 +4492,98 @@ function useCfgAccountsTokenRefreshCreate(config) {
4415
4492
  __name(useCfgAccountsTokenRefreshCreate, "useCfgAccountsTokenRefreshCreate");
4416
4493
 
4417
4494
  // src/_api/generated/_cfg_accounts/schemas/APIKeyRequest.ts
4418
- var import_zod18 = require("zod");
4419
- var APIKeyRequestSchema = import_zod18.z.object({
4420
- key: import_zod18.z.string().min(1),
4421
- reissued_at: import_zod18.z.string().datetime({ offset: true }).nullable(),
4422
- created_at: import_zod18.z.string().datetime({ offset: true })
4495
+ var import_zod20 = require("zod");
4496
+ var APIKeyRequestSchema = import_zod20.z.object({
4497
+ key: import_zod20.z.string().min(1),
4498
+ reissued_at: import_zod20.z.string().datetime({ offset: true }).nullable(),
4499
+ created_at: import_zod20.z.string().datetime({ offset: true })
4423
4500
  });
4424
4501
 
4425
4502
  // src/_api/generated/_cfg_accounts/schemas/APIKeyTestRequest.ts
4426
- var import_zod19 = require("zod");
4427
- var APIKeyTestRequestSchema = import_zod19.z.object({
4428
- key: import_zod19.z.string().min(1)
4503
+ var import_zod21 = require("zod");
4504
+ var APIKeyTestRequestSchema = import_zod21.z.object({
4505
+ key: import_zod21.z.string().min(1)
4429
4506
  });
4430
4507
 
4431
4508
  // src/_api/generated/_cfg_accounts/schemas/CfgUserUpdateRequest.ts
4432
- var import_zod20 = require("zod");
4433
- var CfgUserUpdateRequestSchema = import_zod20.z.object({
4434
- first_name: import_zod20.z.string().max(50).optional(),
4435
- last_name: import_zod20.z.string().max(50).optional(),
4436
- company: import_zod20.z.string().max(100).optional(),
4437
- phone: import_zod20.z.string().max(20).optional(),
4438
- position: import_zod20.z.string().max(100).optional(),
4439
- language: import_zod20.z.string().max(10).optional(),
4440
- timezone: import_zod20.z.string().max(64).optional()
4509
+ var import_zod22 = require("zod");
4510
+ var CfgUserUpdateRequestSchema = import_zod22.z.object({
4511
+ first_name: import_zod22.z.string().max(50).optional(),
4512
+ last_name: import_zod22.z.string().max(50).optional(),
4513
+ company: import_zod22.z.string().max(100).optional(),
4514
+ phone: import_zod22.z.string().max(20).optional(),
4515
+ position: import_zod22.z.string().max(100).optional(),
4516
+ language: import_zod22.z.string().max(10).optional(),
4517
+ timezone: import_zod22.z.string().max(64).optional()
4441
4518
  });
4442
4519
 
4443
4520
  // src/_api/generated/_cfg_accounts/schemas/OAuthAuthorizeRequestRequest.ts
4444
- var import_zod21 = require("zod");
4445
- var OAuthAuthorizeRequestRequestSchema = import_zod21.z.object({
4446
- redirect_uri: import_zod21.z.string().optional(),
4447
- source_url: import_zod21.z.string().optional()
4521
+ var import_zod23 = require("zod");
4522
+ var OAuthAuthorizeRequestRequestSchema = import_zod23.z.object({
4523
+ redirect_uri: import_zod23.z.string().optional(),
4524
+ source_url: import_zod23.z.string().optional()
4448
4525
  });
4449
4526
 
4450
4527
  // src/_api/generated/_cfg_accounts/schemas/OAuthCallbackRequestRequest.ts
4451
- var import_zod22 = require("zod");
4452
- var OAuthCallbackRequestRequestSchema = import_zod22.z.object({
4453
- code: import_zod22.z.string().min(10).max(500),
4454
- state: import_zod22.z.string().min(20).max(100),
4455
- redirect_uri: import_zod22.z.string().optional()
4528
+ var import_zod24 = require("zod");
4529
+ var OAuthCallbackRequestRequestSchema = import_zod24.z.object({
4530
+ code: import_zod24.z.string().min(10).max(500),
4531
+ state: import_zod24.z.string().min(20).max(100),
4532
+ redirect_uri: import_zod24.z.string().optional()
4456
4533
  });
4457
4534
 
4458
4535
  // src/_api/generated/_cfg_accounts/schemas/OAuthDisconnectRequestRequest.ts
4459
- var import_zod23 = require("zod");
4460
- var OAuthDisconnectRequestRequestSchema = import_zod23.z.object({
4536
+ var import_zod25 = require("zod");
4537
+ var OAuthDisconnectRequestRequestSchema = import_zod25.z.object({
4461
4538
  provider: OAuthProviderEnumSchema
4462
4539
  });
4463
4540
 
4464
4541
  // src/_api/generated/_cfg_accounts/schemas/OAuthError.ts
4465
- var import_zod24 = require("zod");
4466
- var OAuthErrorSchema = import_zod24.z.object({
4467
- error: import_zod24.z.string(),
4468
- error_description: import_zod24.z.string().optional()
4542
+ var import_zod26 = require("zod");
4543
+ var OAuthErrorSchema = import_zod26.z.object({
4544
+ error: import_zod26.z.string(),
4545
+ error_description: import_zod26.z.string().optional()
4469
4546
  });
4470
4547
 
4471
4548
  // src/_api/generated/_cfg_accounts/schemas/OTPErrorResponse.ts
4472
- var import_zod25 = require("zod");
4473
- var OTPErrorResponseSchema = import_zod25.z.object({
4474
- error: import_zod25.z.string(),
4475
- error_code: import_zod25.z.string().nullable().optional(),
4476
- retry_after: import_zod25.z.number().int().nullable().optional()
4549
+ var import_zod27 = require("zod");
4550
+ var OTPErrorResponseSchema = import_zod27.z.object({
4551
+ error: import_zod27.z.string(),
4552
+ error_code: import_zod27.z.string().nullable().optional(),
4553
+ retry_after: import_zod27.z.number().int().nullable().optional()
4477
4554
  });
4478
4555
 
4479
4556
  // src/_api/generated/_cfg_accounts/schemas/OTPRequestRequest.ts
4480
- var import_zod26 = require("zod");
4481
- var OTPRequestRequestSchema = import_zod26.z.object({
4482
- identifier: import_zod26.z.string().min(1),
4483
- source_url: import_zod26.z.string().optional()
4557
+ var import_zod28 = require("zod");
4558
+ var OTPRequestRequestSchema = import_zod28.z.object({
4559
+ identifier: import_zod28.z.string().min(1),
4560
+ source_url: import_zod28.z.string().optional()
4484
4561
  });
4485
4562
 
4486
4563
  // src/_api/generated/_cfg_accounts/schemas/OTPVerifyRequest.ts
4487
- var import_zod27 = require("zod");
4488
- var OTPVerifyRequestSchema = import_zod27.z.object({
4489
- identifier: import_zod27.z.string().min(1),
4490
- otp: import_zod27.z.string().min(4).max(4),
4491
- source_url: import_zod27.z.string().optional()
4564
+ var import_zod29 = require("zod");
4565
+ var OTPVerifyRequestSchema = import_zod29.z.object({
4566
+ identifier: import_zod29.z.string().min(1),
4567
+ otp: import_zod29.z.string().min(4).max(4),
4568
+ source_url: import_zod29.z.string().optional()
4492
4569
  });
4493
4570
 
4494
4571
  // src/_api/generated/_cfg_accounts/schemas/PatchedCfgUserUpdateRequest.ts
4495
- var import_zod28 = require("zod");
4496
- var PatchedCfgUserUpdateRequestSchema = import_zod28.z.object({
4497
- first_name: import_zod28.z.string().max(50).optional(),
4498
- last_name: import_zod28.z.string().max(50).optional(),
4499
- company: import_zod28.z.string().max(100).optional(),
4500
- phone: import_zod28.z.string().max(20).optional(),
4501
- position: import_zod28.z.string().max(100).optional(),
4502
- language: import_zod28.z.string().max(10).optional(),
4503
- timezone: import_zod28.z.string().max(64).optional()
4572
+ var import_zod30 = require("zod");
4573
+ var PatchedCfgUserUpdateRequestSchema = import_zod30.z.object({
4574
+ first_name: import_zod30.z.string().max(50).optional(),
4575
+ last_name: import_zod30.z.string().max(50).optional(),
4576
+ company: import_zod30.z.string().max(100).optional(),
4577
+ phone: import_zod30.z.string().max(20).optional(),
4578
+ position: import_zod30.z.string().max(100).optional(),
4579
+ language: import_zod30.z.string().max(10).optional(),
4580
+ timezone: import_zod30.z.string().max(64).optional()
4504
4581
  });
4505
4582
 
4506
4583
  // src/_api/generated/_cfg_accounts/schemas/TokenRefreshRequest.ts
4507
- var import_zod29 = require("zod");
4508
- var TokenRefreshRequestSchema = import_zod29.z.object({
4509
- refresh: import_zod29.z.string().min(1)
4584
+ var import_zod31 = require("zod");
4585
+ var TokenRefreshRequestSchema = import_zod31.z.object({
4586
+ refresh: import_zod31.z.string().min(1)
4510
4587
  });
4511
4588
 
4512
4589
  // src/auth/context/AccountsContext.tsx
@@ -4662,6 +4739,7 @@ var hasValidTokens = /* @__PURE__ */ __name(() => {
4662
4739
  }, "hasValidTokens");
4663
4740
  var AuthProviderInternal = /* @__PURE__ */ __name(({ children, config }) => {
4664
4741
  const accounts = useAccountsContext();
4742
+ ensureRefreshHandler();
4665
4743
  const redirectManager = useAuthRedirectManager({
4666
4744
  fallbackUrl: config?.routes?.defaultCallback || defaultRoutes.defaultCallback,
4667
4745
  clearOnUse: true
@@ -4880,7 +4958,8 @@ var AuthProviderInternal = /* @__PURE__ */ __name(({ children, config }) => {
4880
4958
  });
4881
4959
  return {
4882
4960
  success: true,
4883
- message: result.message || `OTP code sent to your email address`
4961
+ message: result.message || `OTP code sent to your email address`,
4962
+ webmail: result.webmail ?? null
4884
4963
  };
4885
4964
  } catch (error) {
4886
4965
  authLogger.error("Request OTP error:", error);