Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@kenetto/react-native-pincode

Package Overview
Dependencies
Maintainers
2
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@kenetto/react-native-pincode

React native PIN code component

  • 1.22.8
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
17
increased by70%
Maintainers
2
Weekly downloads
 
Created
Source

react-native-pincode

npm npm code style: prettier

A customizable PIN Code component for react native

Using:

Installation

npm install --save @haskkor/react-native-pincode

or

yarn add @haskkor/react-native-pincode

Please note that:

Async storage uses the react-native-async-storage library which has to be linked

react-native link @react-native-community/async-storage

If you wish to use the TouchID/FaceID authentication you will have to link the library:

react-native link react-native-touch-id

If you wish to use Keychain/Keystore to store the PIN code you will have to link the library:

react-native link react-native-keychain

If you wish to use FaceID you'll need to add the permission in your info.plist

<key>NSFaceIDUsageDescription</key>
<string>Enabling Face ID allows you quick and secure access to your account.</string>

Please note that you might have to link those libraries manually.

IMPORTANT: If you decide not to use Keychain/Keystore, you will have to provide a storePin property to the PINCode component.

The library uses the Vibration from React Native. Please note that on Android it requires the Vibrate permission as stated in the doc. (add to AndroidManifest.xml)

Demo

choose-confirm enter-locked

Usage

Basic usage requires choosing between the choose, enter and locked modes.

  • choose : requires the user to choose and to confirm a PIN code
  • enter : requires the user to enter the PIN code he previously chose
  • locked : prints a locked screen for a given time if the user failed to enter his/her PIN code too many times
import PINCode from '@haskkor/react-native-pincode'
<PINCode status={'choose'}/>

Package provides a promise to know if a PIN code has been set by the user. The serviceName parameter is optional. If provided, it should match the pinCodeKeychainName property.

import {hasUserSetPinCode} from '@haskkor/react-native-pincode'
await hasUserSetPinCode(serviceName)

One can also use a provided function to delete a PIN code previously set in the Keychain. The service name parameter is optional. If provided, it should match the pinCodeKeychainName property.

import {deleteUserPinCode} from '@haskkor/react-native-pincode'
await deleteUserPinCode(serviceName)

If needed, the internal states that record the number of attemps and time of last attempt can be reset in addition to user pin code deletion.

import {resetPinCodeInternalStates} from '@haskkor/react-native-pincode'
await resetPinCodeInternalStates()

Options

KeyDescriptionDefaultRequiredType
alphabetCharsVisibleBoolean to hide/show English alphabet on PIN panelfalsefalseboolean
bottomLeftComponentComponent to replace the empty space at the bottom left of the numpadEmpty spacefalseany
buttonComponentLockedPageButton component to be used at the bottom of the page on the locked application pageTouchableOpacity exit button killing the applicationfalseany
buttonDeleteComponentButton component to be used at the bottom right of the PIN panel to delete a previous entryTouchableHighlight button with a delete text and the backspace material iconfalseany
buttonDeleteTextText of the of the button used to delete a previous entry on the PIN paneldeletefalsestring
buttonNumberComponentButton component to be used on the PIN panel to select a character for the PINTouchableHighlight button with a number textfalseany
callbackErrorTouchIdCallback to be used when the TouchID authenticate method throws an errorconsole.log('TouchID error', e)false(error: Error) => void
customBackSpaceIconFunction, that returns custom backspace component to be used to replace the default backspace one on the PIN screenFunction
disableLockScreenBoolean to disable the lock screenfalsefalseboolean
endProcessFunctionFunction to handle the end of the processNonefalse(pinCode: string) => void
finishProcessFunction to be used when the user enters the right PIN codeRemoves the values in AsyncStorage and set the status to successfalse(pinCode?: string) => void
getCurrentPinLengthFunction returning the length of the current PIN codeNonefalse(length: number) => void
handleResultEnterPinFunction to be used to handle the PIN code entered by the user. To be used with the pinStatus propsFunctions that checks the validity of the give PIN code, stores the number of failed attempts in the AsyncStorage and the time the application was locked if neededfalseany
iconComponentLockedPageView component to be used between the timer and the text on the locked application pageA circular red View using the lock material iconfalseany
iconButtonDeleteDisabledBoolean to remove the icon on the delete button of the PIN panelfalsefalseboolean
launchTouchIDFunction to manually trigger the touchIDundefinedfalse() => void
lockedIconComponentComponent to replace the locked icon on the locked application pageMaterial lock iconfalseany
lockedPageView component used as a locked page if the user fails to provide the correct PIN code maxAttempts timesA application locked page with a timer indicating to the user the remaining time locked and a button closing the applicationfalseany
maxAttemptsNumber of attempts the user is given before locking the application3falsenumber
onClickButtonLockedPageFunction to be used when the user taps the button on the locked application pageKills the app by throwing Quit applicationfalseany
onFailFunction to be used when the user enters the wrong PIN codeReturns number of failed attemptsfalseany
passwordComponentComponent to be used to indicate to the user how many characters he/she typed. To be used with the getCurrentPinLength propDots growing or shrinking when the user adds or removes a character in the PIN codefalseany
passwordLengthLength of the password the user has to enter4falsenumber
pinAttemptsAsyncStorageNameString to be used as a key in AsyncStorage to store the number of attempts the user already madepinAttemptsRNPinfalsestring
pinCodeKeychainNameString to be used as a key to store the PIN code in Keychain/KeystorereactNativePinCodefalsestring
pinCodeVisibleBoolean to show/hide the PIN code typed by the userNonefalseboolean
pinStatusStatus coming back to the PIN component after the handleResultEnterPin function. The status type is a value of the PinResultStatus enum (initial, success, failure, locked)NonefalsePinResultStatus enum
statusIndicates the mode that should be used (see Usage section for the different modes available)Nonetruechoose or enter or locked
storedPinThe PIN code previously stored with the storePin functionThe PIN Code previously stored in the Keychain/Keystorefalsestring
storePinFunction that will be used to store the PIN (pin is given as a string argument)Stores the PIN in Keychain/Keystorefalseany
subtitleChooseString used as a subtitle on the PIN code choose pageto keep your information securefalsestring
subtitleComponentComponent to be used as a subtitle on all the PIN code pagesLight grey Text componentfalseany
subtitleConfirmString used as a subtitle on the PIN code confirmation pageNonefalsestring
subtitleEnterString used as a subtitle on the PIN code enter pageNonefalsestring
subtitleErrorString used as a subtitle on the PIN code pages when an error occurs (wrong PIN code used for enter or confirm modes)Please try againfalsestring
textButtonLockedPageString to be used as text on the button in the locked application pageQuitfalsestring
textCancelButtonTouchIDString to be used as text on the cancel button of the touchID popup. Only for AndroidCancelfalsestring
textDescriptionLockedPageString to be used as a description on the locked application pageTo protect your information, access has been locked for {timeLocked} minutes.falsestring
textSubDescriptionLockedPageString to be used as a subtitle on the locked application pageCome back later and try again.falsestring
textPasswordVisibleFamilyFont to be used for the PIN code numbers when pinCodeVisible is truesystem fontfalsestring
textPasswordVisibleSizeSize of the font used for the PIN code numbers when pinCodeVisible is true22falsenumber
textTitleLockedPageString to be used as a title on the locked application pageMaximum attempts reachedfalsestring
timeLockedNumber of milliseconds where the application should be locked after maxAttempts failed attempts from the user300000 (5 minutes)falsenumber
timePinLockedAsyncStorageNameString to be used as a key in AsyncStorage to store the time when the user locks the applicationtimePinLockedRNPinfalsestring
timerComponentLockedPageComponent to be used on the application locked page to indicates the remaining locked time to the userA Text component displaying a timer with the remaining locked time on the application locked pagefalseany
titleAttemptFailedString used as a title on the PIN enter page when the user enters a wrong PIN codeIncorrect PIN Codefalsestring
titleChooseString used as a title on the PIN choose page1 - Enter a PIN Codefalsestring
titleComponentComponent to be used as a title on all the PIN code pagesLight grey Text componentfalseany
titleComponentLockedPageComponent to be used as a title on the application locked pageLight grey Text componentfalseany
titleConfirmString used as a title on the PIN confirm page2 - Confirm your PIN Codefalsestring
titleConfirmFailedString used as a title on the PIN confirm page when the user enters a wrong PIN codeYour entries did not matchfalsestring
titleEnterString used as a title on the PIN enter pageEnter your PIN Codefalsestring
titleValidationFailedString used as a title on the PIN choose page when the PIN code entered by the user does not match the provided RegExp (use with validationRegex propertyPIN code unsafefalsestring
touchIDDisabledBoolean disabling the TouchID/FaceID on the PIN code enter pagefalsefalseboolean
touchIDSentenceString to be used in the TouchID/FaceID popupTo unlock your applicationfalsestring
touchIDTitleANDROID ONLY. String to be used in the TouchID/FaceID popup title.Authentication Requiredfalsestring
validationRegexRegex to be used to validate the PIN code entered by the user on choose modeNonefalseRegExp
vibrationEnabledBoolean enabling vibration feedback when an incorrect PIN is enteredtruefalseboolean
delayBetweenAttemptsDelay when an incorrect PIN is entered3000falsenumber

Styles

KeyDescriptionDefaultType
colorCircleButtonsColor of the circle buttonsrgb(242, 245, 251)string
colorPasswordColor of the dots used for the password componentturquoisestring
colorPasswordEmptyColor of the dots used for the password component when smallturquoisestring
colorPasswordErrorColor of the dots used for the password component on error state#9DAFC8string
numbersButtonOverlayColorColor of the PIN panel buttons when highlightedturquoisestring
styleAlphabetText of English letters on PIN panel. (First, set alphabetCharsVisible={true})fontSize: grid.unit/2, fontWeight: "300"StyleProp<TextStyle>
styleMainContainerMain container of index fileflex: 1, justifyContent: 'center', alignItems: 'center'StyleProp<ViewStyle>
stylePinCodeChooseContainerMain container of PinCodeChoose fileflex: 1, justifyContent: 'center', alignItems: 'center'StyleProp<ViewStyle>
stylePinCodeEnterContainerMain container of PinCodeEnter fileflex: 1, justifyContent: 'center', alignItems: 'center'StyleProp<ViewStyle>
styleLockScreenButtonButton of the lock screenbackgroundColor: colors.turquoise, borderRadius: grid.border, paddingLeft: grid.unit * 2, paddingRight: grid.unit * 2, paddingBottom: grid.unit, paddingTop: grid.unitStyleProp<ViewStyle>
styleLockScreenColorIconColor of the icon on the lock screenwhitestring
styleLockScreenMainContainerMain container of the lock screenposition: 'absolute', top: 0, backgroundColor: colors.background, flexBasis: 0, left: 0, height: '100%', width: '100%', alignItems: 'center', flex: 1, justifyContent: 'center'StyleProp<ViewStyle>
styleLockScreenNameIconName of the material icon to be used on the lock screenlockstring
styleLockScreenSizeIconSize of the icon on the lock screen24number
styleLockScreenTextText on the lock screen (Come back..., To protect...)fontSize: grid.unit, color: colors.base, lineHeight: grid.unit * grid.lineHeight, textAlign: 'center'StyleProp<TextStyle>
styleLockScreenTextButtonText of the button of the lock screencolor: colors.white, fontWeight: 'bold', fontSize: 14StyleProp<TextStyle>
styleLockScreenTextTimerText of the timer of the lock screenfontFamily: Platform.OS === 'ios' ? 'Courier' : 'monospace', fontSize: 20, color: colors.baseStyleProp<TextStyle>
styleLockScreenTitleTitle of the lock screenfontSize: grid.navIcon, color: colors.base, opacity: grid.mediumOpacity, fontWeight: '200', marginBottom: grid.unit * 4StyleProp<TextStyle>
styleLockScreenViewCloseButtonView of the button close of the lock screenalignItems: 'center', opacity: grid.mediumOpacity, justifyContent: 'center', marginTop: grid.unit * 2StyleProp<ViewStyle>
styleLockScreenViewIconView containing the icon of the lock screenwidth: grid.unit * 4, justifyContent: 'center', alignItems: 'center', height: grid.unit * 4, borderRadius: grid.unit * 2, opacity: grid.mediumOpacity, backgroundColor: colors.alert, overflow: 'hidden', marginBottom: grid.unit * 4StyleProp<ViewStyle>
styleLockScreenViewTextLockView containing all the text of the lock screenjustifyContent: 'center', alignItems: 'center', paddingLeft: grid.unit * 3, paddingRight: grid.unit * 3, flex: 3StyleProp<ViewStyle>
styleLockScreenViewTimerView of the timer of the lock screenpaddingLeft: 30, paddingRight: 30, paddingBottom: 10, paddingTop: 10, borderRadius: 4, borderWidth: 2, borderColor: 'rgb(230, 231, 233)', marginBottom: grid.unit * 4StyleProp<ViewStyle>
stylePinCodeButtonCircleCircle button TouchableHighlight of the PinCode filealignItems: 'center', justifyContent: 'center', width: grid.unit * 4, height: grid.unit * 4, backgroundColor: 'rgb(242, 245, 251)', borderRadius: grid.unit * 2StyleProp<ViewStyle>
stylePinCodeButtonNumberColor of the number buttons on the Pin code page'white'string
stylePinCodeButtonNumberPressedColor of the number buttons on the Pin code page when pressed#9DAFC8string
stylePinCodeCircleStyle of the pinCode dotsleft, height, width, opacity, borderRadius, marginLeft, marginRight, and backgroundColor inherited from the animationStyleProp<ViewStyle>
stylePinCodeColorSubtitleColor of the PinCode page subtitle in normal state#9DAFC8string
stylePinCodeColorSubtitleErrorColor of the the PinCode page subtitle in error state#FC4349string
stylePinCodeColorTitleColor of the the PinCode page title in normal state#9DAFC8string
stylePinCodeColorTitleErrorColor of the the PinCode page title in error state#9DAFC8string
stylePinCodeColumnButtonsColumn of buttons of the PinCode filealignItems: 'center', width: 'auto'StyleProp<ViewStyle>
stylePinCodeColumnDeleteButtonColumn of the delete button of the PinCode filewidth: grid.unit * 4, height: grid.unit * 4, marginLeft: grid.unit / 2, marginRight: grid.unit / 2, justifyContent: 'center', alignItems: 'center', flexDirection: 'column'StyleProp<ViewStyle>
stylePinCodeDeleteButtonColorHideUnderlayColor of the delete button when underlay is hidden of the PinCode filergb(211, 213, 218)string
stylePinCodeDeleteButtonColorShowUnderlayColor of the delete button when underlay is shown of the PinCode filecolors.turquoisestring
stylePinCodeDeleteButtonIconName of the icon of the delete button of the PinCode filebackspacestring
stylePinCodeDeleteButtonSizeSize of the icon of the delete button of the PinCode file30number
stylePinCodeDeleteButtonTextText of the delete button of the PinCode filefontWeight: '200', marginTop: 5StyleProp<TextStyle>
stylePinCodeEmptyColumnEmpty column of the last line of buttons of the PinCode filewidth: grid.unit * 4, height: grid.unit * 4StyleProp<ViewStyle>
stylePinCodeHiddenPasswordCircleCircle representing the hidden password of the PinCode fileflexDirection: 'row', height: 'auto', justifyContent: 'center', alignItems: 'center'StyleProp<ViewStyle>
stylePinCodeHiddenPasswordSizeEmptySize of the circle representing the hidden password of the PinCode file when empty4number
stylePinCodeHiddenPasswordSizeFullSize of the circle representing the hidden password of the PinCode file when full8number
stylePinCodeMainContainerMain container of the PinCode fileflex: 1, justifyContent: 'center', alignItems: 'center'StyleProp<ViewStyle>
stylePinCodeRowButtonsRow of buttons of the PinCode filejustifyContent: 'center', alignItems: 'center', width: '100%', height: grid.unit * 5.5StyleProp<ViewStyle>
stylePinCodeTextButtonCircleText of circle button TouchableHighlight of the PinCode filefontSize: grid.unit * 2, fontWeight: '200'StyleProp<TextStyle>
stylePinCodeTextSubtitleTitle of the PinCode filefontSize: 20, fontWeight: '200', lineHeight: grid.unit * 2.5StyleProp<TextStyle>
stylePinCodeTextTitleSubtitle of the PinCode filefontSize: grid.unit, fontWeight: '200', textAlign: 'center'StyleProp<TextStyle>
stylePinCodeViewTitleView of the title of the PinCode fileflexDirection: 'column', justifyContent: 'center', alignItems: 'center', minHeight: grid.unit * 4StyleProp<TextStyle>

Changelog

Contributing

Pull requests are welcome.

License

FAQs

Package last updated on 23 Feb 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc