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 CHANGED
@@ -478,7 +478,9 @@ async function registerPasskeyAction(ctx, name) {
478
478
  onError(new Error("Failed to start passkey registration"));
479
479
  return null;
480
480
  }
481
- const credential = await createPasskeyCredential(startResult.data.options);
481
+ const credential = await createPasskeyCredential(
482
+ startResult.data.options
483
+ );
482
484
  const finishResult = await finishPasskeyRegistrationAPI(authProxyPath, {
483
485
  credential,
484
486
  name
@@ -2211,6 +2213,18 @@ var DauthProvider = (props) => {
2211
2213
  autoLoginAction(ctx);
2212
2214
  }
2213
2215
  }, []);
2216
+ (0, import_react2.useEffect)(() => {
2217
+ const handleVisibilityChange = () => {
2218
+ if (document.visibilityState === "visible" && !dauthState.isAuthenticated && !dauthState.isLoading) {
2219
+ autoLoginAction(ctx);
2220
+ }
2221
+ };
2222
+ document.addEventListener("visibilitychange", handleVisibilityChange);
2223
+ return () => document.removeEventListener(
2224
+ "visibilitychange",
2225
+ handleVisibilityChange
2226
+ );
2227
+ }, [ctx, dauthState.isAuthenticated, dauthState.isLoading]);
2214
2228
  const loginWithRedirect = (0, import_react2.useCallback)(() => {
2215
2229
  const base = `${getClientBasePath()}/${domainName}/${routes.signin}`;
2216
2230
  const url = env ? `${base}?env=${encodeURIComponent(env)}` : base;