Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async defineDefaultAuthMethod() {
const { password } = await getPassphraseFromKeyChain();
let sensorType = null;
try {
sensorType = await FingerprintScanner.isSensorAvailable();
} catch (error) {
sensorType = null;
}
const signOut = this.props.navigation.getParam('signOut');
const delay = this.state.view === 'splash' && !signOut ? 1100 : 0;
// Update the store
this.props.settingsUpdated({
sensorType,
hasStoredPassphrase: !!password,
});
// Update the component state
this.timeout = setTimeout(() => {
if (password && sensorType) {
this.setState({
view: 'biometricAuth',
checkTouchIdSupport = async () => {
try {
const isSensorAvailable = await FingerprintScanner.isSensorAvailable();
if (isSensorAvailable) {
this.setState({
isTouchIdSupported: true,
});
this.onTouchIdClick();
}
} catch (error) {
// An error happened during biometric detection
}
};
it("passes when used properly", () => {
FingerprintScanner.isSensorAvailable().then(type => {
(type: "Fingerprint" | "Face ID" | "Touch ID");
});
});
});
activateFingerprintScanner() {
const { t } = this.props;
return FingerprintScanner.isSensorAvailable()
.then(() => {
FingerprintScanner.authenticate({
description: t('instructionsEnable'),
})
.then(() => {
this.onSuccess();
})
.catch(() => {
this.onFailure();
});
})
.catch((err) => {
this.props.generateAlert(
'error',
t('fingerprintUnavailable'),
t('fingerprintUnavailableExplanation'),
export const bioMetricAuthentication = async ({
successCallback,
errorCallback = err => err,
description,
androidError,
}) => {
const authConfig =
Platform.OS === 'ios'
? {
description:
description ||
'Scan your fingerprint on the device scanner to sign in',
}
: { onAttempt: androidError };
try {
await FingerprintScanner.isSensorAvailable();
try {
await FingerprintScanner.authenticate(authConfig);
successCallback();
} catch (error) {
errorCallback(error);
}
} catch (error) {
errorCallback(error);
}
};
async componentDidMount() {
let sensorType;
try {
sensorType = await FingerprintScanner.isSensorAvailable();
} catch (error) {
sensorType = 'biometric authentication';
}
this.setState({ sensorType });
}
componentDidMount() {
FingerprintScanner
.isSensorAvailable()
.catch(error => this.setState({ errorMessage: error.message }));
}
async componentDidMount () {
if (!this.props.isLocked) {
this.props.history.push('/dashboard')
return
}
try {
let isAvailable = await FingerprintScanner.isSensorAvailable()
if (!isAvailable) {
this.setState({ sensorAvail: isAvailable })
} else {
await FingerprintScanner.authenticate({ onAttempt: this.setError })
await this.setState({ isError: false })
setTimeout(this.goBack, 400)
}
} catch (err) {
this.setError(err)
}
}