From f26df487f05392846efde829b1bc23364f0aaa89 Mon Sep 17 00:00:00 2001 From: Anmol Verma Date: Thu, 4 Apr 2024 20:36:47 +0530 Subject: [PATCH 01/45] Biometric authentication --- .../android/app/src/main/AndroidManifest.xml | 2 + apps/expo/app/_layout.tsx | 87 +++++++++++++++++-- apps/expo/package.json | 1 + packages/app/auth/hooks/useBiometricSignIn.ts | 0 yarn.lock | 12 +++ 5 files changed, 96 insertions(+), 6 deletions(-) create mode 100644 packages/app/auth/hooks/useBiometricSignIn.ts diff --git a/apps/expo/android/app/src/main/AndroidManifest.xml b/apps/expo/android/app/src/main/AndroidManifest.xml index 93b702dca..a13bbe6b9 100644 --- a/apps/expo/android/app/src/main/AndroidManifest.xml +++ b/apps/expo/android/app/src/main/AndroidManifest.xml @@ -8,6 +8,8 @@ + + diff --git a/apps/expo/app/_layout.tsx b/apps/expo/app/_layout.tsx index 15d3b3b82..e1f4b7bbf 100644 --- a/apps/expo/app/_layout.tsx +++ b/apps/expo/app/_layout.tsx @@ -1,14 +1,89 @@ import { Provider } from 'app/provider'; import { Stack } from 'expo-router'; +import * as LocalAuthentication from 'expo-local-authentication'; +import { useState, useEffect } from "react"; +import { Alert, Button, StyleSheet, Text, View } from "react-native"; export default function HomeLayout() { + + const [authenticated, setAuthenticated] = useState(false); + + + + const checkDeviceForHardware = async () => { + let compatible = await LocalAuthentication.hasHardwareAsync(); + console.log("compatible", compatible); + }; + + const checkForBiometrics = async () => { + let biometricRecords = await LocalAuthentication.isEnrolledAsync(); + console.log("biometricRecords", biometricRecords); + }; + + const authenticate = async () => { + let result = await LocalAuthentication.authenticateAsync(); + if (result.success) { + setAuthenticated(true); + } else { + Alert.alert("Authentication failed"); + } + }; + + useEffect(()=> { + checkDeviceForHardware(); + checkForBiometrics(); + authenticate(); + }, []) + + + + return ( - + {/* + + Biometric Authentication + +