1.1.0 • Published 2 years ago

react-native-biometry-module v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

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:

  • select Set passcode screen.
  • input Input passcode screen.
  • changePasscode Change passcode screen.

Props

  • Generals

    KeyTypeDefaultDescription
    typeScreenTypeType of screen to display
    numberOfAttemptsnumber undefined3Number of max attempts before screen is locked
    lockedTimenumber undefined300000Locked time in millisecond before screen unlocked.
    alphabetCharsVisibleboolean undefinedfalseIs alphabet characters show below numeric char in keypad
    biometryEnabledbooleanIs using biometry for authenticate user
    passcodeVisibleboolean undefinedfalseIs passcode input visible
    timePasscodeLockedAsyncStorageNamestring undefinedundefinedLocked time AsyncStorage save key
    passcodeKeychainNamestring undefinedundefinedKey for saving passcode to keychain system
    passcodeAttemptsAsyncStorageNamestring undefinedundefinedKey for saving number of failed attempts in AsyncStorage
    onSuccess(passcode: string) => void undefinedundefinedHandler for confirm passcode success, input passcode success, biometry success
    onFailed(error?: any) => void undefinedundefinedHandler for confirm failed, input passcode failed, biometry failed
    passcodeSelectTitlestring undefinedundefinedTitle for select passcode screen
    passcodeSelectSubtitlestring undefinedundefinedSubtitle for select passcode screen
    passcodeSelectErrorTitlestring undefinedundefinedTitle for select passcode screen when error
    passcodeSelectErrorSubtitlestring undefinedundefinedSubtitle for select passcode screen when error
    passcodeConfirmTitlestring undefinedundefinedTitle for confirm passcode screen
    passcodeConfirmSubtitlestring undefinedundefinedSubtitle for confirm passcode screen
    passcodeConfirmErrorTitlestring undefinedundefinedTitle for confirm passcode screen when error
    passcodeConfirmErrorSubtitlestring undefinedundefinedSubtitle for confirm passcode screen when error
    passcodeInputTitlestring undefinedundefinedTitle for input passcode screen
    passcodeInputSubtitlestring undefinedundefinedSubtitle for input passcode screen
    passcodeInputErrorTitlestring undefinedundefinedTitle for input passcode screen when error
    passcodeInputErrorSubtitlestring undefinedundefinedSubtitle for input passcode screen when error
    lockedTitlestring undefinedundefinedTitle for locked screen
    lockedSubtitle(timer: number) => string undefinedundefinedSubtitle with remain locked time for locked screen
  • Custom components

    KeyTypeDefaultDescription
    deleteButtonIconJSX.Element undefinedundefinedSet icon for delete button keypad
    biometryButtonIconJSX.Element undefinedundefinedSet icon for biometry trigger keypad (bottom left button)
    lockedButtonJSX.Element undefinedundefinedLocked page button
    lockedPageJSX.Element undefinedundefinedCustom locked page
    bottomLeftButtonJSX.Element undefinedundefinedCustom bottom left button (biometry trigger button)
    deleteButton(handler: () => void) => JSX.Element undefinedundefinedCustom delete button keypad with handler method in module
    keypadButton(index: number, handler: (buttonIndex: string) => void) => JSX.Element undefinedundefinedCustom keypad button with handler and button index
  • Styles

    KeyTypeDefaultDescription
    styleLockedContainerStyleProp<ViewStyle> undefinedundefinedStyle of locked screen's container
    styleLockedTextContainerStyleProp<ViewStyle> undefinedundefinedStyle of locked screen text container
    styleLockedTitleStyleProp<TextStyle> undefinedundefinedStyle of locked screen's container
    styleLockedSubtitleStyleProp<TextStyle> undefinedundefinedStyle of locked screen's container
    styleLockedTimerContainerStyleProp<ViewStyle> undefinedundefinedStyle of locked screen's timer container
    styleLockedTimerTextStyleProp<TextStyle> undefinedundefinedStyle of locked screen's timer text
    styleLockedIconContainerStyleProp<ViewStyle> undefinedundefinedStyle of locked screen's center icon container
    stylePasscodeContainerStyleProp<ViewStyle> undefinedundefinedStyle of passcode container
    stylePasscodeTitleStyleProp<TextStyle> undefinedundefinedStyle of passcode title
    stylePasscodeSubtitleStyleProp<TextStyle> undefinedundefinedStyle of passcode subtitle
    stylePasscodeHiddenStyleProp<ViewStyle> undefinedundefinedStyle of passcode indicator when hidden
    stylePasscodeTextStyleProp<TextStyle> undefinedundefinedStyle of passcode indicator when show text
    styleKeypadAlphabetCharHighlightedStyleProp<TextStyle> undefinedundefinedStyle of alphabet chars when keypad pressed
    styleKeypadNumberCharHighlightedStyleProp<TextStyle> undefinedundefinedStyle of numeric chars when keypad pressed
    styleKeypadAlphabetCharNormalStyleProp<TextStyle> undefinedundefinedStyle of alphabet chars when keypad normal
    styleKeypadNumberCharNormalStyleProp<TextStyle> undefinedundefinedStyle 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)