@autobusal/providers 1.43.3 → 1.43.4
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/Setup/useUserBootstrap.ts +21 -1
- package/index.ts +2 -0
- package/package.json +1 -1
|
@@ -19,9 +19,29 @@ import { UserData } from '../types/users';
|
|
|
19
19
|
// runs when there's an actual signal of a prior login: the bearer token
|
|
20
20
|
// (bearer mode) or the redacted user stub this same store persists (bff
|
|
21
21
|
// mode, where the token itself is an httpOnly cookie invisible to JS).
|
|
22
|
-
|
|
22
|
+
/*
|
|
23
|
+
* Claude - 2026-09-07: the BFF's readable marker, set by /bff/handoff and
|
|
24
|
+
* cleared by /bff/logout (@autobusal/bff 1.7.2).
|
|
25
|
+
*
|
|
26
|
+
* A handoff is the one way into a BFF session that writes NO stub: the
|
|
27
|
+
* browser lands on an origin it has never signed in on - that is what a
|
|
28
|
+
* handoff is for - so localStorage is empty by construction, and this hook
|
|
29
|
+
* stayed disabled. Measured on a clean browser: /bff/session said
|
|
30
|
+
* authenticated and the SPA still sent the visitor to the login form. The
|
|
31
|
+
* marker carries no secret; it is the one bit that makes this hook ask.
|
|
32
|
+
*/
|
|
33
|
+
const hasBffSignal = (): boolean => {
|
|
34
|
+
try {
|
|
35
|
+
return typeof document !== 'undefined' && /(?:^|;\s*)bff_signal=1(?:;|$)/.test(document.cookie);
|
|
36
|
+
} catch {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export const hasLoginSignal = (): boolean => (
|
|
23
42
|
(!isBffMode && localStorage.getItem('token') !== null)
|
|
24
43
|
|| localStorage.getItem('user') !== null
|
|
44
|
+
|| (isBffMode && hasBffSignal())
|
|
25
45
|
);
|
|
26
46
|
|
|
27
47
|
const useUserBootstrap = (): void => {
|
package/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import Providers from './Providers';
|
|
2
2
|
import apiClient, { isBffMode } from './Queries/apiClient';
|
|
3
3
|
import { storedReferral } from './Setup/useReferralTouch';
|
|
4
|
+
import { hasLoginSignal } from './Setup/useUserBootstrap';
|
|
4
5
|
import ErrorBoundary from './Errors/ErrorBoundary';
|
|
5
6
|
import Message from './Errors/Message';
|
|
6
7
|
import useMenuStore from './stores/menu';
|
|
@@ -15,6 +16,7 @@ export {
|
|
|
15
16
|
Message,
|
|
16
17
|
useMenuStore,
|
|
17
18
|
useUserStore,
|
|
19
|
+
hasLoginSignal,
|
|
18
20
|
registerStaleChunkRecovery
|
|
19
21
|
};
|
|
20
22
|
|