Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const canBiometricEncryptionBeEnabled = async () => {
if (Platform.OS === 'android') {
return await KeyStoreBridge.canFingerprintEncryptionBeEnabled()
} else if (Platform.OS === 'ios') {
// prettier-ignore
const hasBiometricHardware =
await isBiometricEncryptionHardwareSupported()
const supportedBiometrics = await Keychain.canImplyAuthentication({
authenticationType: Keychain.AUTHENTICATION_TYPE.BIOMETRICS,
})
return supportedBiometrics && hasBiometricHardware
}
throw new Error('Unsupported platform')
}
export const isSystemAuthSupported = async () => {
if (Platform.OS === 'android') {
return await KeyStoreBridge.isSystemAuthSupported()
} else if (Platform.OS === 'ios') {
const supportedSystemAuth = await Keychain.canImplyAuthentication({
authenticationType:
Keychain.AUTHENTICATION_TYPE.DEVICE_PASSCODE_OR_BIOMETRICS,
})
return supportedSystemAuth
}
throw new Error('Unsupported platform')
}
keychainObject.password = decrypted.password;
instance.isAuthenticating = false;
return keychainObject;
}
instance.isAuthenticating = false;
}
return null;
},
async setGenericPassword(key, password, authOptions) {
const encryptedPassword = await instance.encryptPassword(password);
return Keychain.setGenericPassword(key, encryptedPassword, { ...defaultOptions, ...authOptions });
},
ACCESS_CONTROL: Keychain.ACCESS_CONTROL,
ACCESSIBLE: Keychain.ACCESSIBLE,
AUTHENTICATION_TYPE: Keychain.AUTHENTICATION_TYPE
};