Skip to content

Commit

Permalink
update browser check
Browse files Browse the repository at this point in the history
  • Loading branch information
arch1995 committed May 15, 2024
1 parent 2f170c9 commit dcde737
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
10 changes: 5 additions & 5 deletions example/react-app/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { GoogleAuthProvider, getAuth, signInWithPopup, UserCredential } from "fi
import Loading from "./Loading";
import "./App.css";
import { IProvider } from "@web3auth/base";
import { shouldSupportPasskey } from "./utils";
import { browserSupportsWebAuthn } from "./utils";

const verifier = "web3auth-firebase-examples";

Expand Down Expand Up @@ -135,8 +135,8 @@ function App() {
try {
setIsLoggingIn(true);
if (!plugin) throw new Error("Passkey plugin not initialized");
const result = shouldSupportPasskey();
if (!result.isBrowserSupported) {
const result = browserSupportsWebAuthn();
if (!result) {
uiConsole("Browser not supported");
return;
}
Expand Down Expand Up @@ -269,8 +269,8 @@ function App() {
uiConsole("plugin not initialized yet");
return;
}
const result = shouldSupportPasskey();
if (!result.isBrowserSupported) {
const result = browserSupportsWebAuthn();
if (!result) {
uiConsole("Browser not supported");
return;
}
Expand Down
5 changes: 5 additions & 0 deletions example/react-app/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,9 @@ export function shouldSupportPasskey(): { isBrowserSupported: boolean; isOsSuppo
};
const isBrowserSupported = browser.satisfies({ ...browserData }) || false;
return { isBrowserSupported, isOsSupported: true, supportedBrowser: browserData[osName] };
}

export function browserSupportsWebAuthn() {
return (window?.PublicKeyCredential !== undefined &&
typeof window.PublicKeyCredential === 'function');
}

0 comments on commit dcde737

Please sign in to comment.