diff --git a/examples/react_native/src/screens/Main.tsx b/examples/react_native/src/screens/Main.tsx index 5171d2ad22..50555b9e7b 100644 --- a/examples/react_native/src/screens/Main.tsx +++ b/examples/react_native/src/screens/Main.tsx @@ -5,6 +5,7 @@ import {NavigationContainer} from '@react-navigation/native'; import {createNativeStackNavigator} from '@react-navigation/native-stack'; import Profile from '@screens/Profile'; import SignIn from '@screens/SignIn'; +import SignUpWithPassKeys from '@screens/SignUpWithPassKeys'; import SignUp from '@screens/SignUp'; import Storage from '@screens/Storage'; import Todos from '@screens/Todos'; @@ -41,6 +42,10 @@ function Main() { <> + ) : ( diff --git a/examples/react_native/src/screens/SignIn.tsx b/examples/react_native/src/screens/SignIn.tsx index f46bb9d1f3..801dafabb0 100644 --- a/examples/react_native/src/screens/SignIn.tsx +++ b/examples/react_native/src/screens/SignIn.tsx @@ -62,79 +62,6 @@ export default function SignIn({ } }; - const handleSignInWithSecurityKey = async () => { - const isSupported = Passkey.isSupported(); - - if (isSupported) { - try { - const res = await fetch( - 'https://local.auth.nhost.run/v1/signup/webauthn', - { - method: 'POST', - headers: { - 'content-type': 'application/json', - }, - body: JSON.stringify({ - email: 'hsanbenjobrane@gmail.com', - }), - }, - ); - - if (!res.ok) { - throw new Error('Request to sign in failed'); - } - - const challengeRequest = await res.json(); - - console.log({ - challengeRequest, - }); - - // Call the `register` method with the retrieved request in JSON format - // A native overlay will be displayed - const result: PasskeyRegistrationResult = await Passkey.register( - challengeRequest, - ); - - console.log({ - result, - }); - - // const verification = await fetch( - // 'https://local.auth.nhost.run/signin/webauthn/verify', - // { - // headers: { - // 'content-type': 'application/json', - // }, - // body: JSON.stringify({ - // email: 'hsanbenjobrane@gmail.com', - // credential: result, - // }), - // }, - // ); - - // if (!verification.ok) { - // throw new Error('Verification failed'); - // } - - // const session = await verification.json(); - - // console.log({ - // session, - // }); - - // The `register` method returns a FIDO2 attestation result - // Pass it to your server for verification - } catch (error) { - console.log({error}); - // Handle Error... - Alert.alert('webauthn', `An error has occurred`); - } - } else { - Alert.alert('webauthn', `${isSupported}`); - } - }; - const handleSignInWithOAuth = async (providerLink: string) => { try { const response = await InAppBrowser.openAuth( @@ -163,6 +90,9 @@ export default function SignIn({ } }; + const navigateToSignUpWithPassKeys = () => + navigation.navigate('signUpWithPassKeys'); + const handleSignInWithApple = () => handleSignInWithOAuth(apple); const handleSignInWithGoogle = () => handleSignInWithOAuth(google); @@ -227,8 +157,8 @@ export default function SignIn({