dauth-context-react 6.6.1 → 6.6.3
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/index.js +15 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +15 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/index.tsx +21 -0
- package/src/reducer/dauth.actions.ts +3 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dauth-context-react",
|
|
3
|
-
"version": "6.6.
|
|
3
|
+
"version": "6.6.3",
|
|
4
4
|
"description": "React provider and hook for passwordless authentication via the Dauth service (BFF pattern with httpOnly cookies)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "David T. Pizarro Frick",
|
package/src/index.tsx
CHANGED
|
@@ -77,6 +77,27 @@ export const DauthProvider: React.FC<IDauthProviderProps> = (
|
|
|
77
77
|
}
|
|
78
78
|
}, []);
|
|
79
79
|
|
|
80
|
+
// Re-check session when tab becomes visible again (handles mobile CCT flow:
|
|
81
|
+
// user confirms magic link in Chrome Custom Tab which sets cookies, then
|
|
82
|
+
// returns to this tab — we need to detect the new session)
|
|
83
|
+
useEffect(() => {
|
|
84
|
+
const handleVisibilityChange = () => {
|
|
85
|
+
if (
|
|
86
|
+
document.visibilityState === 'visible' &&
|
|
87
|
+
!dauthState.isAuthenticated &&
|
|
88
|
+
!dauthState.isLoading
|
|
89
|
+
) {
|
|
90
|
+
action.autoLoginAction(ctx);
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
document.addEventListener('visibilitychange', handleVisibilityChange);
|
|
94
|
+
return () =>
|
|
95
|
+
document.removeEventListener(
|
|
96
|
+
'visibilitychange',
|
|
97
|
+
handleVisibilityChange
|
|
98
|
+
);
|
|
99
|
+
}, [ctx, dauthState.isAuthenticated, dauthState.isLoading]);
|
|
100
|
+
|
|
80
101
|
const loginWithRedirect = useCallback(() => {
|
|
81
102
|
const base = `${getClientBasePath()}/${domainName}/${routes.signin}`;
|
|
82
103
|
const url = env ? `${base}?env=${encodeURIComponent(env)}` : base;
|
|
@@ -191,7 +191,9 @@ export async function registerPasskeyAction(
|
|
|
191
191
|
}
|
|
192
192
|
|
|
193
193
|
// Step 2: Execute WebAuthn ceremony in the browser
|
|
194
|
-
const credential = await createPasskeyCredential(
|
|
194
|
+
const credential = await createPasskeyCredential(
|
|
195
|
+
startResult.data.options as Record<string, unknown>
|
|
196
|
+
);
|
|
195
197
|
|
|
196
198
|
// Step 3: Send the credential back to the server
|
|
197
199
|
const finishResult = await finishPasskeyRegistrationAPI(authProxyPath, {
|