0.0.7 • Published 5 years ago

layers-capacitor-biometric-auth v0.0.7

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

Capacitor Biometric Auth

Build Status

Installation

  • npm i capacitor-biometric-auth
  • yarn add capacitor-biometric-auth

Usage

import { Plugins } from "@capacitor/core";

const { BiometricAuth } = Plugins;

const available = await BiometricAuth.isAvailable()

if (available.has) {
  const authResult = await BiometricAuth.verify({...})
  if (authResult.verified) {
    // success authentication
  } else {
    // fail authentication
  }
} else {
  // biometric not available
}

Methods

verify(options)

Open biometric popup

optionvaluesdecription
reasonany stringPopup label
const result = await BiometricAuth.verify({reason: "Message ..."})

result

{
  verified: true // true if biometric auth was succes or false otherwise,
  status: {} // an object with errors matching biometric auth fails (on if verified === false)
}

status

errordescription
10The user failed to provide valid credentials
11Authentication was cancelled by application
12The context is invalid
13Not interactive
14Passcode is not set on the device
15Authentication was cancelled by the system
16The user did cancel
17The user chose to use the fallback

isAvailable()

Checks if biometric is enabled

const result = await BiometricAuth.isAvailable()

result

{
  has: true, // true if has biometric auth enabled, false otherwise
  status: {...} // an object with errors
}

status

errordescription
1Biometric not available
2Authentication could not continue because the user has been locked out of biometric authentication, due to failing authentication too many times.
3Authentication could not start because the user has not enrolled in biometric authentication.
0.0.7

5 years ago