1.1.0 • Published 3 years ago
react-native-biometry-module v1.1.0
react-native-biometry-module
A UI library support biometry authentication with passcode fallback for React Native
Installation
yarn add git+https://github.com/dangttp97/rn-biometry-module Example
import {Biometry, ScreenType} from 'react-native-biometry-module'
/*
Your render method
*/
return <Biometry type={ScreenType.select} biometryEnabled />Enumerations
ScreenType
Type of screen to show. Includes:
selectSet passcode screen.inputInput passcode screen.changePasscodeChange passcode screen.
Props
Generals
Key Type Default Description type ScreenTypeType of screen to display numberOfAttempts numberundefined3 Number of max attempts before screen is locked lockedTime numberundefined300000 Locked time in millisecond before screen unlocked. alphabetCharsVisible booleanundefinedfalse Is alphabet characters show below numeric char in keypad biometryEnabled booleanIs using biometry for authenticate user passcodeVisible booleanundefinedfalse Is passcode input visible timePasscodeLockedAsyncStorageName stringundefinedundefined Locked time AsyncStorage save key passcodeKeychainName stringundefinedundefined Key for saving passcode to keychain system passcodeAttemptsAsyncStorageName stringundefinedundefined Key for saving number of failed attempts in AsyncStorage onSuccess (passcode: string) => voidundefinedundefined Handler for confirm passcode success, input passcode success, biometry success onFailed (error?: any) => voidundefinedundefined Handler for confirm failed, input passcode failed, biometry failed passcodeSelectTitle stringundefinedundefined Title for select passcode screen passcodeSelectSubtitle stringundefinedundefined Subtitle for select passcode screen passcodeSelectErrorTitle stringundefinedundefined Title for select passcode screen when error passcodeSelectErrorSubtitle stringundefinedundefined Subtitle for select passcode screen when error passcodeConfirmTitle stringundefinedundefined Title for confirm passcode screen passcodeConfirmSubtitle stringundefinedundefined Subtitle for confirm passcode screen passcodeConfirmErrorTitle stringundefinedundefined Title for confirm passcode screen when error passcodeConfirmErrorSubtitle stringundefinedundefined Subtitle for confirm passcode screen when error passcodeInputTitle stringundefinedundefined Title for input passcode screen passcodeInputSubtitle stringundefinedundefined Subtitle for input passcode screen passcodeInputErrorTitle stringundefinedundefined Title for input passcode screen when error passcodeInputErrorSubtitle stringundefinedundefined Subtitle for input passcode screen when error lockedTitle stringundefinedundefined Title for locked screen lockedSubtitle (timer: number) => stringundefinedundefined Subtitle with remain locked time for locked screen Custom components
Key Type Default Description deleteButtonIcon JSX.Elementundefinedundefined Set icon for delete button keypad biometryButtonIcon JSX.Elementundefinedundefined Set icon for biometry trigger keypad (bottom left button) lockedButton JSX.Elementundefinedundefined Locked page button lockedPage JSX.Elementundefinedundefined Custom locked page bottomLeftButton JSX.Elementundefinedundefined Custom bottom left button (biometry trigger button) deleteButton (handler: () => void) => JSX.Elementundefinedundefined Custom delete button keypad with handler method in module keypadButton (index: number, handler: (buttonIndex: string) => void) => JSX.Elementundefinedundefined Custom keypad button with handler and button index Styles
Key Type Default Description styleLockedContainer StyleProp<ViewStyle>undefinedundefined Style of locked screen's container styleLockedTextContainer StyleProp<ViewStyle>undefinedundefined Style of locked screen text container styleLockedTitle StyleProp<TextStyle>undefinedundefined Style of locked screen's container styleLockedSubtitle StyleProp<TextStyle>undefinedundefined Style of locked screen's container styleLockedTimerContainer StyleProp<ViewStyle>undefinedundefined Style of locked screen's timer container styleLockedTimerText StyleProp<TextStyle>undefinedundefined Style of locked screen's timer text styleLockedIconContainer StyleProp<ViewStyle>undefinedundefined Style of locked screen's center icon container stylePasscodeContainer StyleProp<ViewStyle>undefinedundefined Style of passcode container stylePasscodeTitle StyleProp<TextStyle>undefinedundefined Style of passcode title stylePasscodeSubtitle StyleProp<TextStyle>undefinedundefined Style of passcode subtitle stylePasscodeHidden StyleProp<ViewStyle>undefinedundefined Style of passcode indicator when hidden stylePasscodeText StyleProp<TextStyle>undefinedundefined Style of passcode indicator when show text styleKeypadAlphabetCharHighlighted StyleProp<TextStyle>undefinedundefined Style of alphabet chars when keypad pressed styleKeypadNumberCharHighlighted StyleProp<TextStyle>undefinedundefined Style of numeric chars when keypad pressed styleKeypadAlphabetCharNormal StyleProp<TextStyle>undefinedundefined Style of alphabet chars when keypad normal styleKeypadNumberCharNormal StyleProp<TextStyle>undefinedundefined Style of numeric chars when keypad normal
Helper functions
async hasUserSetPasscode(serviceName?: string) => Promise<boolean>
Returns a promise contains if passcode had been set or not
async deleteUserPasscode(serviceName?: string) => Promise<void>
Delete keychain stored passcode if existed
async resetPasscodeInternalStates = (passcodeAttempsStorageName?: string, timePasscodeLockedStorageName?: string) => Promise<void>
Reset all app internal state (time countdown for lock screen, number of fail attempts)