const handleBiometricLogin = async () => { try { const { userId } = await verifyUserCredentials(); const askForBiometrics = async () => await LocalAuthentication.authenticateAsync({ //disableDeviceFallback: true, promptMessage: 'Enable biometrics login', cancelLabel: 'Not now', }); const savedBiometrics = await LocalAuthentication.isEnrolledAsync(); if (!savedBiometrics) return Alert.alert('No Biometrics Found', 'Please ensure you have set up biometrics in your device settings.'); const biometricsResult = await askForBiometrics(); console.log('biometricsResult', biometricsResult?.success); if (biometricsResult?.success) { const bits = 1024; const exponent = '10001'; // decimal = 65537 const rsa = new RSAKey(); Alert.alert('Face ID', 'Would you like to enable Face ID authentication for the next time?', [ { text: 'Yes please', onPress: async () => { rsa.generate(bits, exponent); const publicKey = rsa.getPublicString(); const privateKey = rsa.getPrivateString(); console.log('publicKey', publicKey); console.log('privateKey', privateKey); await SecureStore.setItemAsync('USER_BIOMETRIC_KEY', privateKey); // await SecureStore.setItemAsync('USER_PUBLIC_KEY', publicKey); await sendPublicKeyToServer({ userId, publicKey }); }, }, { text: 'Cancel', style: 'cancel' }, ]); } } catch (error: any) { showSnackbar(`bao loi:${error.response}`, 'error'); } }; const handleBiometricLogin = async () => { try { const { userId } = await verifyUserCredentials(); const askForBiometrics = async () => await LocalAuthentication.authenticateAsync({ //disableDeviceFallback: true, promptMessage: 'Enable biometrics login', cancelLabel: 'Not now', }); const savedBiometrics = await LocalAuthentication.isEnrolledAsync(); if (!savedBiometrics) return Alert.alert('No Biometrics Found', 'Please ensure you have set up biometrics in your device settings.'); const biometricsResult = await askForBiometrics(); console.log('biometricsResult', biometricsResult?.success); if (biometricsResult?.success) { const bits = 1024; const exponent = '10001'; // decimal = 65537 const rsa = new RSAKey(); Alert.alert('Face ID', 'Would you like to enable Face ID authentication for the next time?', [ { text: 'Yes please', onPress: async () => { rsa.generate(bits, exponent); const publicKey = rsa.getPublicString(); const privateKey = rsa.getPrivateString(); console.log('publicKey', publicKey); console.log('privateKey', privateKey); await SecureStore.setItemAsync('USER_BIOMETRIC_KEY', privateKey); // await SecureStore.setItemAsync('USER_PUBLIC_KEY', publicKey); await sendPublicKeyToServer({ userId, publicKey }); }, }, { text: 'Cancel', style: 'cancel' }, ]); } } catch (error: any) { showSnackbar(`bao loi:${error.response}`, 'error'); } };