@djangocfg/api 2.1.621 → 2.1.623

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.d.cts CHANGED
@@ -29,6 +29,7 @@ declare const AUTH_CONSTANTS: {
29
29
  * __cfgAuth.dump() // copy-ready text with a header; paste it into the report
30
30
  * __cfgAuth.trace() // the raw array
31
31
  * __cfgAuth.clear() // empty it before reproducing
32
+ * __cfgAuth.copy() // dump to the clipboard; __cfgAuth.download() saves the raw JSON
32
33
  *
33
34
  * What is recorded is the decision, never the secret: no token, code, address, cookie value or password.
34
35
  * Values are primitives, strings are cut, and keys that look sensitive are dropped (`SENSITIVE`).
@@ -44,10 +45,14 @@ interface TraceEntry {
44
45
  tab: string;
45
46
  ev: string;
46
47
  f?: TraceFields;
48
+ /** Times this exact event repeated back to back (absent = once). A loop must not push the start of the chain out of the buffer. */
49
+ n?: number;
47
50
  }
48
51
  /** Record one auth event. Safe anywhere: it never throws and does nothing on the server. */
49
52
  declare function authTrace(ev: string, fields?: TraceFields): void;
50
53
  /** The recorded events, oldest first. */
54
+ /** @internal for tests */
55
+ declare function resetAuthTraceForTests(): void;
51
56
  declare function readAuthTrace(): TraceEntry[];
52
57
  /** Empty the trace. */
53
58
  declare function clearAuthTrace(): void;
@@ -1604,5 +1609,5 @@ declare const Analytics: {
1604
1609
  setUser(userId: string | null): void;
1605
1610
  };
1606
1611
 
1607
- export { AUTH_CONSTANTS, AUTH_ERROR_KEYS, AccountsProvider, Analytics, AnalyticsCategory, AnalyticsEvent, AuthContext, AuthProvider, OAUTH_PROVIDER_IDS, authLogger, authTrace, beginTwoFactorChallenge, clearAuthTrace, clearOAuthAttempt, clearProfileCache, consumeSavedRedirect, decodeBase64, dumpAuthTrace, encodeBase64, endTwoFactorChallenge, formatAuthError, getCacheMetadata, getCachedProfile, hasValidCache, installAuthTrace, isAllowedAuthPath, isForbidden, isOAuthProviderId, logAuthFailure, logger, normalizePath, peekSavedRedirect, readAuthTrace, readOAuthFailure, resolveAuthError, resolveAuthStatus, resolveGuardIsAuthenticated, resolveGuardIsLoading, setAnalyticsSink, setCachedProfile, shouldRedirectToAuth, useAccountsContext, useAuth, useAuthForm, useAuthFormState, useAuthRedirectManager, useAuthValidation, useAutoAuth, useBase64, useCfgRouter, useDeleteAccount, useGithubAuth, useLocalStorage, useOAuthLogin, useOAuthProviders, useQueryParams, useSession, useSessionStorage, useTimezone, useTwoFactor, useTwoFactorChallenge, useTwoFactorSetup, useTwoFactorStatus, useTwoFactorVerify, validateEmail, validateIdentifier };
1612
+ export { AUTH_CONSTANTS, AUTH_ERROR_KEYS, AccountsProvider, Analytics, AnalyticsCategory, AnalyticsEvent, AuthContext, AuthProvider, OAUTH_PROVIDER_IDS, authLogger, authTrace, beginTwoFactorChallenge, clearAuthTrace, clearOAuthAttempt, clearProfileCache, consumeSavedRedirect, decodeBase64, dumpAuthTrace, encodeBase64, endTwoFactorChallenge, formatAuthError, getCacheMetadata, getCachedProfile, hasValidCache, installAuthTrace, isAllowedAuthPath, isForbidden, isOAuthProviderId, logAuthFailure, logger, normalizePath, peekSavedRedirect, readAuthTrace, readOAuthFailure, resetAuthTraceForTests, resolveAuthError, resolveAuthStatus, resolveGuardIsAuthenticated, resolveGuardIsLoading, setAnalyticsSink, setCachedProfile, shouldRedirectToAuth, useAccountsContext, useAuth, useAuthForm, useAuthFormState, useAuthRedirectManager, useAuthValidation, useAutoAuth, useBase64, useCfgRouter, useDeleteAccount, useGithubAuth, useLocalStorage, useOAuthLogin, useOAuthProviders, useQueryParams, useSession, useSessionStorage, useTimezone, useTwoFactor, useTwoFactorChallenge, useTwoFactorSetup, useTwoFactorStatus, useTwoFactorVerify, validateEmail, validateIdentifier };
1608
1613
  export type { AccountsContextValue, AnalyticsCategoryType, AnalyticsEventType, AnalyticsSink, AuthConfig, AuthContextType, AuthErrorCopy, AuthErrorKey, AuthFormAutoSubmit, AuthFormReturn, AuthFormState, AuthFormStateHandlers, AuthFormSubmitHandlers, AuthFormValidation, AuthProviderProps, AuthStateInput, AuthStatus, AuthStep, DeleteAccountResult, GuardInput, OAuthClientErrorCode, OAuthErrorCode, OAuthFailure, OAuthFailureCode, OAuthProviderId, OAuthUser, OTPRequestConsent, OTPRequestResult, PasswordLoginOptions, PasswordLoginResult, PatchedCfgUserUpdateRequest, ProfileCacheOptions, SessionSnapshot, SessionStatus, TraceEntry, TraceFields, TwoFactorChallenge, TwoFactorDevice, TwoFactorSetupData, UseAuthFormOptions, UseAuthFormStateReturn, UseAutoAuthOptions, UseDeleteAccountReturn, UseGithubAuthOptions, UseGithubAuthReturn, UseOAuthLoginOptions, UseOAuthLoginReturn, UseOAuthProvidersReturn, UseTimezoneReturn, UseTwoFactorOptions, UseTwoFactorReturn, UseTwoFactorSetupOptions, UseTwoFactorSetupReturn, UseTwoFactorStatusReturn, UseTwoFactorVerifyOptions, UseTwoFactorVerifyReturn, UserProfile, WebmailLink };
package/dist/auth.d.ts CHANGED
@@ -29,6 +29,7 @@ declare const AUTH_CONSTANTS: {
29
29
  * __cfgAuth.dump() // copy-ready text with a header; paste it into the report
30
30
  * __cfgAuth.trace() // the raw array
31
31
  * __cfgAuth.clear() // empty it before reproducing
32
+ * __cfgAuth.copy() // dump to the clipboard; __cfgAuth.download() saves the raw JSON
32
33
  *
33
34
  * What is recorded is the decision, never the secret: no token, code, address, cookie value or password.
34
35
  * Values are primitives, strings are cut, and keys that look sensitive are dropped (`SENSITIVE`).
@@ -44,10 +45,14 @@ interface TraceEntry {
44
45
  tab: string;
45
46
  ev: string;
46
47
  f?: TraceFields;
48
+ /** Times this exact event repeated back to back (absent = once). A loop must not push the start of the chain out of the buffer. */
49
+ n?: number;
47
50
  }
48
51
  /** Record one auth event. Safe anywhere: it never throws and does nothing on the server. */
49
52
  declare function authTrace(ev: string, fields?: TraceFields): void;
50
53
  /** The recorded events, oldest first. */
54
+ /** @internal for tests */
55
+ declare function resetAuthTraceForTests(): void;
51
56
  declare function readAuthTrace(): TraceEntry[];
52
57
  /** Empty the trace. */
53
58
  declare function clearAuthTrace(): void;
@@ -1604,5 +1609,5 @@ declare const Analytics: {
1604
1609
  setUser(userId: string | null): void;
1605
1610
  };
1606
1611
 
1607
- export { AUTH_CONSTANTS, AUTH_ERROR_KEYS, AccountsProvider, Analytics, AnalyticsCategory, AnalyticsEvent, AuthContext, AuthProvider, OAUTH_PROVIDER_IDS, authLogger, authTrace, beginTwoFactorChallenge, clearAuthTrace, clearOAuthAttempt, clearProfileCache, consumeSavedRedirect, decodeBase64, dumpAuthTrace, encodeBase64, endTwoFactorChallenge, formatAuthError, getCacheMetadata, getCachedProfile, hasValidCache, installAuthTrace, isAllowedAuthPath, isForbidden, isOAuthProviderId, logAuthFailure, logger, normalizePath, peekSavedRedirect, readAuthTrace, readOAuthFailure, resolveAuthError, resolveAuthStatus, resolveGuardIsAuthenticated, resolveGuardIsLoading, setAnalyticsSink, setCachedProfile, shouldRedirectToAuth, useAccountsContext, useAuth, useAuthForm, useAuthFormState, useAuthRedirectManager, useAuthValidation, useAutoAuth, useBase64, useCfgRouter, useDeleteAccount, useGithubAuth, useLocalStorage, useOAuthLogin, useOAuthProviders, useQueryParams, useSession, useSessionStorage, useTimezone, useTwoFactor, useTwoFactorChallenge, useTwoFactorSetup, useTwoFactorStatus, useTwoFactorVerify, validateEmail, validateIdentifier };
1612
+ export { AUTH_CONSTANTS, AUTH_ERROR_KEYS, AccountsProvider, Analytics, AnalyticsCategory, AnalyticsEvent, AuthContext, AuthProvider, OAUTH_PROVIDER_IDS, authLogger, authTrace, beginTwoFactorChallenge, clearAuthTrace, clearOAuthAttempt, clearProfileCache, consumeSavedRedirect, decodeBase64, dumpAuthTrace, encodeBase64, endTwoFactorChallenge, formatAuthError, getCacheMetadata, getCachedProfile, hasValidCache, installAuthTrace, isAllowedAuthPath, isForbidden, isOAuthProviderId, logAuthFailure, logger, normalizePath, peekSavedRedirect, readAuthTrace, readOAuthFailure, resetAuthTraceForTests, resolveAuthError, resolveAuthStatus, resolveGuardIsAuthenticated, resolveGuardIsLoading, setAnalyticsSink, setCachedProfile, shouldRedirectToAuth, useAccountsContext, useAuth, useAuthForm, useAuthFormState, useAuthRedirectManager, useAuthValidation, useAutoAuth, useBase64, useCfgRouter, useDeleteAccount, useGithubAuth, useLocalStorage, useOAuthLogin, useOAuthProviders, useQueryParams, useSession, useSessionStorage, useTimezone, useTwoFactor, useTwoFactorChallenge, useTwoFactorSetup, useTwoFactorStatus, useTwoFactorVerify, validateEmail, validateIdentifier };
1608
1613
  export type { AccountsContextValue, AnalyticsCategoryType, AnalyticsEventType, AnalyticsSink, AuthConfig, AuthContextType, AuthErrorCopy, AuthErrorKey, AuthFormAutoSubmit, AuthFormReturn, AuthFormState, AuthFormStateHandlers, AuthFormSubmitHandlers, AuthFormValidation, AuthProviderProps, AuthStateInput, AuthStatus, AuthStep, DeleteAccountResult, GuardInput, OAuthClientErrorCode, OAuthErrorCode, OAuthFailure, OAuthFailureCode, OAuthProviderId, OAuthUser, OTPRequestConsent, OTPRequestResult, PasswordLoginOptions, PasswordLoginResult, PatchedCfgUserUpdateRequest, ProfileCacheOptions, SessionSnapshot, SessionStatus, TraceEntry, TraceFields, TwoFactorChallenge, TwoFactorDevice, TwoFactorSetupData, UseAuthFormOptions, UseAuthFormStateReturn, UseAutoAuthOptions, UseDeleteAccountReturn, UseGithubAuthOptions, UseGithubAuthReturn, UseOAuthLoginOptions, UseOAuthLoginReturn, UseOAuthProvidersReturn, UseTimezoneReturn, UseTwoFactorOptions, UseTwoFactorReturn, UseTwoFactorSetupOptions, UseTwoFactorSetupReturn, UseTwoFactorStatusReturn, UseTwoFactorVerifyOptions, UseTwoFactorVerifyReturn, UserProfile, WebmailLink };
package/dist/auth.mjs CHANGED
@@ -20,7 +20,10 @@ var KEY = "cfg.auth.trace";
20
20
  var MAX = 200;
21
21
  var MAX_STRING = 120;
22
22
  var SENSITIVE = /token|otp|code|email|password|secret|cookie|authorization|key|identifier/i;
23
- var TAB = Math.random().toString(36).slice(2, 6);
23
+ var TAB = (() => {
24
+ const g = globalThis;
25
+ return g.__cfgAuthTab ??= Math.random().toString(36).slice(2, 6);
26
+ })();
24
27
  var hasWindow = typeof window !== "undefined";
25
28
  var memory = [];
26
29
  var loaded = false;
@@ -69,10 +72,30 @@ function clean(fields) {
69
72
  return Object.keys(out).length ? out : void 0;
70
73
  }
71
74
  __name(clean, "clean");
75
+ function refresh() {
76
+ try {
77
+ const raw = backend()?.getItem(KEY);
78
+ const parsed = raw ? JSON.parse(raw) : null;
79
+ if (Array.isArray(parsed)) memory = parsed.filter((e) => typeof e === "object" && e !== null);
80
+ } catch {
81
+ }
82
+ }
83
+ __name(refresh, "refresh");
72
84
  function record(at, ev, fields) {
73
- const entries = load();
85
+ load();
86
+ refresh();
87
+ const entries = memory;
74
88
  const p = hasWindow && typeof performance !== "undefined" ? Math.round(performance.now()) : 0;
75
- entries.push({ t: at, p, tab: TAB, ev, f: clean(fields) });
89
+ const f2 = clean(fields);
90
+ const last = entries[entries.length - 1];
91
+ if (last && last.tab === TAB && last.ev === ev && JSON.stringify(last.f) === JSON.stringify(f2)) {
92
+ last.n = (last.n ?? 1) + 1;
93
+ last.t = at;
94
+ last.p = p;
95
+ persist();
96
+ return;
97
+ }
98
+ entries.push({ t: at, p, tab: TAB, ev, f: f2 });
76
99
  if (entries.length > MAX) entries.splice(0, entries.length - MAX);
77
100
  persist();
78
101
  }
@@ -85,6 +108,11 @@ function authTrace(ev, fields) {
85
108
  }
86
109
  }
87
110
  __name(authTrace, "authTrace");
111
+ function resetAuthTraceForTests() {
112
+ memory = [];
113
+ loaded = true;
114
+ }
115
+ __name(resetAuthTraceForTests, "resetAuthTraceForTests");
88
116
  function readAuthTrace() {
89
117
  return load().slice();
90
118
  }
@@ -100,7 +128,8 @@ function clearAuthTrace() {
100
128
  __name(clearAuthTrace, "clearAuthTrace");
101
129
  function context() {
102
130
  if (!hasWindow) return [];
103
- const lines = [`url: ${window.location.href.split("?")[0]}`, `online: ${navigator.onLine}`, `ua: ${navigator.userAgent}`];
131
+ const copies = globalThis.__cfgAuthCopies ?? 1;
132
+ const lines = [`url: ${window.location.href.split("?")[0]}`, `copies: ${String(copies)}`, `online: ${navigator.onLine}`, `ua: ${navigator.userAgent}`];
104
133
  try {
105
134
  const auth2 = globalThis.__cfgAuthNow;
106
135
  const now = auth2?.();
@@ -116,7 +145,7 @@ function dumpAuthTrace() {
116
145
  const rows = entries.map((e) => {
117
146
  const fields = e.f ? ` ${Object.entries(e.f).map(([k2, v]) => `${k2}=${String(v)}`).join(" ")}` : "";
118
147
  const at = new Date(e.t).toISOString().slice(11, 23);
119
- return `${at} +${String(e.t - first).padStart(6)}ms [${e.tab} p${e.p}] ${e.ev}${fields}`;
148
+ return `${at} +${String(e.t - first).padStart(6)}ms [${e.tab} p${e.p}] ${e.ev}${fields}${e.n && e.n > 1 ? ` x${e.n}` : ""}`;
120
149
  });
121
150
  return [`# cfg auth trace, ${entries.length} events`, ...context(), "", ...rows].join("\n");
122
151
  }
@@ -132,7 +161,21 @@ function installAuthTrace() {
132
161
  console.log(text);
133
162
  return text;
134
163
  }, "dump"),
135
- clear: clearAuthTrace
164
+ clear: clearAuthTrace,
165
+ /** Put the dump on the clipboard (works when the console output is blocked or too long to select). */
166
+ copy: /* @__PURE__ */ __name(() => {
167
+ const text = dumpAuthTrace();
168
+ void navigator.clipboard?.writeText(text);
169
+ return `${text.split("\n").length} lines copied`;
170
+ }, "copy"),
171
+ /** Download the raw trace as a JSON file. */
172
+ download: /* @__PURE__ */ __name(() => {
173
+ const blob = new Blob([JSON.stringify(readAuthTrace(), null, 1)], { type: "application/json" });
174
+ const a = document.createElement("a");
175
+ a.href = URL.createObjectURL(blob);
176
+ a.download = `auth-trace-${Date.now()}.json`;
177
+ a.click();
178
+ }, "download")
136
179
  };
137
180
  const queued = g.__cfgAuthTraceQ;
138
181
  if (Array.isArray(queued)) {
@@ -148,12 +191,25 @@ function installAuthTrace() {
148
191
  }
149
192
  }
150
193
  __name(installAuthTrace, "installAuthTrace");
194
+ function registerCopy() {
195
+ if (!hasWindow) return;
196
+ const g = globalThis;
197
+ const n = (g.__cfgAuthCopies ?? 0) + 1;
198
+ g.__cfgAuthCopies = n;
199
+ if (n > 1) {
200
+ authTrace("dup.copy", { copies: n });
201
+ if (n === 2) {
202
+ console.warn("[@djangocfg/api] more than one copy of the auth package is loaded; see __cfgAuth.dump() (dup.copy). Align the peer set so pnpm installs one instance.");
203
+ }
204
+ }
205
+ }
206
+ __name(registerCopy, "registerCopy");
207
+ registerCopy();
151
208
  installAuthTrace();
152
209
 
153
210
  // src/auth/context/AuthContext.tsx
154
211
  import { usePathname as usePathname3 } from "next/navigation";
155
212
  import {
156
- createContext as createContext2,
157
213
  memo,
158
214
  useCallback as useCallback13,
159
215
  useContext as useContext2,
@@ -563,10 +619,10 @@ function adoptLegacySession() {
563
619
  if (_storage.get(ACCESS_KEY) !== null || _storage.get(REFRESH_KEY) !== null) return;
564
620
  const legacy = backendFor("localStorage");
565
621
  const access = legacy.get(ACCESS_KEY);
566
- const refresh = legacy.get(REFRESH_KEY);
567
- if (access === null && refresh === null) return;
622
+ const refresh2 = legacy.get(REFRESH_KEY);
623
+ if (access === null && refresh2 === null) return;
568
624
  if (access !== null) _storage.set(ACCESS_KEY, access);
569
- if (refresh !== null) _storage.set(REFRESH_KEY, refresh);
625
+ if (refresh2 !== null) _storage.set(REFRESH_KEY, refresh2);
570
626
  legacy.set(ACCESS_KEY, null);
571
627
  legacy.set(REFRESH_KEY, null);
572
628
  } catch {
@@ -651,12 +707,12 @@ function jwtExpMs(token) {
651
707
  __name(jwtExpMs, "jwtExpMs");
652
708
  function computeSnapshot() {
653
709
  const access = _storage.get(ACCESS_KEY);
654
- const refresh = _storage.get(REFRESH_KEY);
710
+ const refresh2 = _storage.get(REFRESH_KEY);
655
711
  const now = Date.now();
656
712
  const accessExp = access ? jwtExpMs(access) : null;
657
713
  const accessAlive = access !== null && (accessExp === null || accessExp > now);
658
- const refreshExp = refresh ? jwtExpMs(refresh) : null;
659
- const refreshAlive = refresh !== null && (refreshExp === null || refreshExp > now);
714
+ const refreshExp = refresh2 ? jwtExpMs(refresh2) : null;
715
+ const refreshAlive = refresh2 !== null && (refreshExp === null || refreshExp > now);
660
716
  return {
661
717
  status: accessAlive || refreshAlive ? "authenticated" : "anonymous",
662
718
  accessExpiresAt: accessExp
@@ -679,9 +735,9 @@ function scheduleExpiryFlip() {
679
735
  const now = Date.now();
680
736
  const exps = [];
681
737
  const access = _storage.get(ACCESS_KEY);
682
- const refresh = _storage.get(REFRESH_KEY);
738
+ const refresh2 = _storage.get(REFRESH_KEY);
683
739
  const accessExp = access ? jwtExpMs(access) : null;
684
- const refreshExp = refresh ? jwtExpMs(refresh) : null;
740
+ const refreshExp = refresh2 ? jwtExpMs(refresh2) : null;
685
741
  if (accessExp !== null && accessExp > now) exps.push(accessExp);
686
742
  if (refreshExp !== null && refreshExp > now) exps.push(refreshExp);
687
743
  if (!exps.length) return;
@@ -950,9 +1006,9 @@ async function tryRefresh() {
950
1006
  if (_refreshInflight) return _refreshInflight;
951
1007
  if (!_refreshHandler) return null;
952
1008
  const runRefresh = /* @__PURE__ */ __name(async () => {
953
- const refresh = auth.getRefreshToken();
954
- if (!refresh) return null;
955
- const result = await _refreshHandler(refresh);
1009
+ const refresh2 = auth.getRefreshToken();
1010
+ if (!refresh2) return null;
1011
+ const result = await _refreshHandler(refresh2);
956
1012
  if (!result?.access) {
957
1013
  trace("refresh", { ok: false, why: "no-access" });
958
1014
  return null;
@@ -1153,7 +1209,7 @@ function installAuthOnClient(client2) {
1153
1209
  }
1154
1210
  __name(installAuthOnClient, "installAuthOnClient");
1155
1211
  var REFRESH_ENDPOINT = "/cfg/accounts/token/refresh/";
1156
- auth.setRefreshHandler(async (refresh) => {
1212
+ auth.setRefreshHandler(async (refresh2) => {
1157
1213
  try {
1158
1214
  const url = `${auth.getBaseUrl()}${REFRESH_ENDPOINT}`;
1159
1215
  const headers = { "Content-Type": "application/json" };
@@ -1165,11 +1221,11 @@ auth.setRefreshHandler(async (refresh) => {
1165
1221
  method: "POST",
1166
1222
  headers,
1167
1223
  credentials: auth.getWithCredentials() ? "include" : "same-origin",
1168
- body: JSON.stringify({ refresh })
1224
+ body: JSON.stringify({ refresh: refresh2 })
1169
1225
  });
1170
1226
  if (!res.ok) return null;
1171
1227
  const data = await res.json();
1172
- return data?.access ? { access: data.access, refresh: data.refresh ?? refresh } : null;
1228
+ return data?.access ? { access: data.access, refresh: data.refresh ?? refresh2 } : null;
1173
1229
  } catch {
1174
1230
  return null;
1175
1231
  }
@@ -1440,7 +1496,7 @@ function useCfgRouter() {
1440
1496
  const forward = useCallback2(() => {
1441
1497
  router.forward();
1442
1498
  }, [router]);
1443
- const refresh = useCallback2(() => {
1499
+ const refresh2 = useCallback2(() => {
1444
1500
  router.refresh();
1445
1501
  }, [router]);
1446
1502
  return {
@@ -1451,7 +1507,7 @@ function useCfgRouter() {
1451
1507
  prefetch,
1452
1508
  back,
1453
1509
  forward,
1454
- refresh
1510
+ refresh: refresh2
1455
1511
  };
1456
1512
  }
1457
1513
  __name(useCfgRouter, "useCfgRouter");
@@ -4631,7 +4687,6 @@ __name(resolveAuthStatus, "resolveAuthStatus");
4631
4687
 
4632
4688
  // src/auth/context/AccountsContext.tsx
4633
4689
  import {
4634
- createContext,
4635
4690
  useCallback as useCallback12,
4636
4691
  useContext,
4637
4692
  useEffect as useEffect6,
@@ -4985,6 +5040,15 @@ __name(useCfgAccountsTokenCreate, "useCfgAccountsTokenCreate");
4985
5040
  // src/_api/generated/_cfg_accounts/hooks/useCfgAccountsTokenRefreshCreate.ts
4986
5041
  import useSWRMutation19 from "swr/mutation";
4987
5042
 
5043
+ // src/auth/context/sharedContext.ts
5044
+ import { createContext } from "react";
5045
+ function sharedContext(key, initial) {
5046
+ const g = globalThis;
5047
+ const registry = g.__cfgAuthContexts ??= {};
5048
+ return registry[key] ??= createContext(initial);
5049
+ }
5050
+ __name(sharedContext, "sharedContext");
5051
+
4988
5052
  // src/auth/context/AccountsContext.tsx
4989
5053
  import { jsx } from "react/jsx-runtime";
4990
5054
  function hasApiOrigin() {
@@ -4998,7 +5062,7 @@ function hasApiOrigin() {
4998
5062
  }
4999
5063
  }
5000
5064
  __name(hasApiOrigin, "hasApiOrigin");
5001
- var AccountsContext = createContext(void 0);
5065
+ var AccountsContext = sharedContext("accounts", void 0);
5002
5066
  function AccountsProvider({ children }) {
5003
5067
  const [profile, setProfile] = useState11(() => {
5004
5068
  if (!auth.isAuthenticated()) {
@@ -5104,9 +5168,9 @@ function AccountsProvider({ children }) {
5104
5168
  return result;
5105
5169
  }, [triggerPasswordLogin, settleLoginEnvelope]);
5106
5170
  const logout = useCallback12(() => {
5107
- const refresh = auth.getRefreshToken();
5108
- if (refresh) {
5109
- CfgAccountsAuth.cfgAccountsTokenBlacklistCreate({ body: { refresh } }).catch(() => {
5171
+ const refresh2 = auth.getRefreshToken();
5172
+ if (refresh2) {
5173
+ CfgAccountsAuth.cfgAccountsTokenBlacklistCreate({ body: { refresh: refresh2 } }).catch(() => {
5110
5174
  authLogger.warn("Refresh-token blacklist failed (logged out locally anyway)");
5111
5175
  });
5112
5176
  }
@@ -5166,7 +5230,7 @@ var resolveAuthRoutes = /* @__PURE__ */ __name((routes) => ({
5166
5230
  defaultAuthCallback: routes?.defaultAuthCallback || routes?.auth || defaultRoutes.defaultAuthCallback
5167
5231
  }), "resolveAuthRoutes");
5168
5232
  var EMAIL_STORAGE_KEY = CFG_KEYS.email.key;
5169
- var AuthContext = createContext2(void 0);
5233
+ var AuthContext = sharedContext("auth", void 0);
5170
5234
  var AuthProviderInternal = /* @__PURE__ */ __name(({ children, config }) => {
5171
5235
  const accounts = useAccountsContext();
5172
5236
  const session = useSession();
@@ -5712,6 +5776,7 @@ export {
5712
5776
  peekSavedRedirect,
5713
5777
  readAuthTrace,
5714
5778
  readOAuthFailure,
5779
+ resetAuthTraceForTests,
5715
5780
  resolveAuthError,
5716
5781
  resolveAuthStatus,
5717
5782
  resolveGuardIsAuthenticated,