New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

react-native-expo-auth

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-expo-auth

A simple and fully customizable React Native Expo component that implements Sign In and Sign Up flows including Biometric Unlock.

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

react-native-expo-auth

React Native Expo Component that provides Sign In, Sign Up, Reset Password flows for user authentication. The component includes an API for FaceID and TouchID (iOS) and Fingerprint API (Android) to authenticate the user with a face or fingerprint scan.

Autocomplete Example

Installation

$ npm install --save react-native-expo-auth

or

$ yarn add react-native-expo-auth

Usage

// ...


import React, { useState } from "react";
import { Authenticate } from "react-native-expo-auth";

const ExampleApp = props => {

    const [isVisible, setIsVisible] = useState(true);
    const [logins, setLogins] = useState(["test@gmail.com"]);

    /**
     * Each callback should return object that contains success and/or error.
     * @param {Object} data
     * @returns {{ success: Boolean, error: String }}
     */
    const submitAuth = async(data, route) => {
        const signUpRaw = await fetch(`http://test.com/${route}`, {
            method: "POST", 
            body: JSON.stringify(data)
        });
        if(signUpRaw.status !== 200) {
            return {
                success: false,
                error: await signUpRaw.text()
            };
        }
        const { emails } = await signUpRaw.json();
        setLogins(emails);
        return {
            success: true
        };
    };

    const submitSignIn = async (data) => await submitAuth(data, "signin");
    const submitSignUp = async (data) => await submitAuth(data, "signup");
    const submitBioLogin = async (data) => await submitAuth(data, "biologin");
    const submitPinCodeRequest = async (data) => await submitAuth(data, "reset");
    const submitNewPassword = async (data) => await submitAuth(data, "doreset");

    render() {
        return (
            <Authenticate
                visible={isVisible}
                onLogin={submitSignIn} 
                onSignUp={submitSignUp}
                onBioLogin={submitBioLogin}
                logins={logins}
                onPinCodeRequest={submitPinCodeRequest}
                onSubmitNewPassword={submitNewPassword}
                enableBio={true}
            >
                <Text>YOUR LOGO</Text>
                <Image
                    source={require("./images/logo.png")}
                />
            </Authenticate>
        );
    }

};

// ...

Props

PropTypeDescription
visiblebooleanSet to true to show the component. By default visible is set to true.
onLoginfunctionCallback will be called once user submits login form.
onSignUpfunctionCallback will be called once user submits submit form.
onBioLoginfunctionCallback will be called once user uses Mobile Biometric Check( faceId, fingerprint or Pin Code).
loginsarrayAn array of logins which a user is allowed to use during bioLogin. Logins get populated when a user signs in/up using a specific device.
onPinCodeRequestfunctionCallback that will be called if a user submits forgot password form.
onSubmitNewPasswordfunctionCallback will be called once a user submits a new password after resetting the old one.
enableBiobooleanEnables/Disables Mobile Biometric Check.

Contribute

Feel free to open issues or do a PR!

Keywords

react-native

FAQs

Package last updated on 29 Jan 2020

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