dauth-context-react 6.6.0 → 6.6.2

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