npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-passcode-auth

v1.0.0

Published

React Native authentication with iOS Passcode.

Downloads

4,205

Readme

React Native Passcode Auth

npm version npm downloads

React Native Passcode Auth is a React Native library for authenticating users with iOS Passcode.

react-native-passcode-auth

Documentation

Install

npm i --save react-native-passcode-auth

Usage

Linking the Library

In order to use Passcode Auth, you must first link the library to your project. There's excellent documentation on how to do this in the React Native Docs.

Requesting Passcode Authentication

Once you've linked the library, you'll want to make it available to your app by requiring it:

import PasscodeAuth from 'react-native-passcode-auth';

Requesting Passcode authentication is as simple as calling:

PasscodeAuth.authenticate('to demo this react-native component')
  .then(success => {
    // Success code
  })
  .catch(error => {
    // Failure code
  });

Example

Using PasscodeAuth in your app will usually look like this:

import React, { Component, AlertIOS, TouchableHighlight, View, Text } from 'react-native';
import PasscodeAuth form 'react-native-passcode-auth';

class YourComponent extends Component {
  _pressHandler() {
    PasscodeAuth.authenticate('to demo this react-native component')
      .then(success => {
        AlertIOS.alert('Authenticated Successfully');
      })
      .catch(error => {
        AlertIOS.alert('Authentication Failed');
      });
  }

  render() {
    return (
      <View>
        ...
        <TouchableHighlight onPress={this._pressHandler}>
          <Text>
            Authenticate with Passcode
          </Text>
        </TouchableHighlight>
      </View>
    );
  }
});

Methods

authenticate(reason)

Attempts to authenticate with Passcode. Returns a Promise object.

Arguments

  • reason - An optional String that provides a clear reason for requesting authentication.

Examples

PasscodeAuth.authenticate('to demo this react-native component')
  .then(success => {
    // Success code
    console.log('User authenticated with Passcode');
  })
  .catch(error => {
    // Failure code
    console.log(error);
  });

isSupported()

Verify's that Passcode Auth is supported and that Passcode is set. Returns a Promise object.

Examples

PasscodeAuth.isSupported()
  .then(supported => {
    // Success code
    console.log('Passcode Auth is supported.');
  })
  .catch(error => {
    // Failure code
    console.log(error);
  });

Errors

There are various reasons why authenticating with Passcode may fail. Whenever calling Passcode authentication fails, PasscodeAuth.authenticate will return an error code representing the reason.

Below is a list of error codes that can be returned:

| Code | Description | |---|---| | LAErrorAuthenticationFailed | Authentication was not successful because the user failed to provide valid credentials. | | LAErrorUserCancel | Authentication was canceled by the user—for example, the user tapped Cancel in the dialog. | | LAErrorUserFallback | Authentication was canceled because the user tapped the fallback button (Enter Password). | | LAErrorSystemCancel | Authentication was canceled by system—for example, if another application came to foreground while the authentication dialog was up. | | LAErrorPasscodeNotSet | Authentication could not start because the passcode is not set on the device. | | PasscodeAuthNotSet | Authentication could not start because the passcode is not set on the device. | | PasscodeAuthNotSupported | Device does not support Passcode Auth. |

More information on errors can be found in Apple's Documentation.

License

Copyright (c) 2015, Naoufal Kadhom

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.