NoPass™ SDK for React

This SDK applies to React Native version 0.64.2.

Install the React Native NoPass module: npm install react-native-nopass

NoPass™ serves as a passwordless authentication system. The core workflow here is the authentication itself. A device receives an authentication request as a Firebase push message. The request data is then processed by the NoPass™ SDK framework to generate a picture and a 3-digit code representation a user would have to compare with the ones that appeared on the other side, a web page, for instance. 

 

Add the maven repo URL to your allprojects repositories section in the project level gradle. build file.

allprojects {
    repositories {
        maven {
            url "https://repository.identite.us/repository/maven-public/"
        }
  

Initial setup

To make everything work properly, call the following function:

NoPassManager.initialize();

To make the core functionality work, hook the NoPass™ service to the firebase callbacks.

Place these two methods in the appropriate callbacks in the firebase managing system you use. 

 provideFirebaseToken(token) - provide your project's firebase token for the NoPass to work
 provideFirebaseMessage(message) - provide firebase message data to NoPass to enable the cloud-messaging dependent workflows

Notifee library implementation

To display Firebase push notification, use notifee library.

    1. Install firebase messaging library:

yarn add @react-native-firebase/messaging
yarn add @react-native-firebase/app

    2. Install notify library

yarn add @notifee/react-native

    3. Provide firebase token

const token = await messaging().getToken();Display firebase notification by notifee
NopassManager.provideFirebaseToken(token)
function onMessageReceived(message) {
   NopassManager.provideFirebaseMessage(message)
   notifee.displayNotification(JSON.parse(message.data.notifee));
}
messaging().onMessage(onMessageReceived);

   4. Display notification by Notifee

notifee.displayNotification()

The detailed instruction  is available  here.

Registration

To create a secure user token, serving to authenticate a user, you will need to use NoPassManager. One of its responsibilities is to register a user account, containing all the necessary information. Once you have properly configured it, you will be able to register new accounts.

You will need the parameters string from a QR code, a deep link, or any other way of delivering this data to the application you choose. Once you get it, you can trigger the registration process:

registerUser(initialData, callback) - pass the data you scanned to run user registration flow. The result will be available in the callback.

You will need the following callbacks during the registration process:

NoPassManager.configure({
    onConfirmationCodeRequired: function(code) {
      //the code to enter in browser
    },
    onRegistrationResultListener: function(data) {
      //regitration result data
    },
  });
    

Authentication

Once you have registered the user, your NoPass™ back-end server gets able to send authorization requests. To receive them, perform the following setup.

The NoPassManager class serves to receive authorization requests and send authorization responses.

To be able to receive and process requests do the following:

NoPassManager.configure({
    onAuthRequestReceived: function(data) {
      //auth request data; containg image as base64 and code
    },
    onOTPChanged: function(data) {
      //the otp change data
    },
    onAuthenticationResult: function(data) {
      //auth result data
    },
    onTick: function(data) {
      //timer tick data
    },
    onSessionTimeout: function(data) {
      //session timeout data
    },
  });

When the setup is ready, you can authorize your user during the authentication session by calling the following function:

 authenticate() - initiate authentication during the auth session

or decline the authentication if needed:

decline() - decline the authentication

Other operations

There are additional operation that can be preformed with the NoPassManager

NoPassManager.configure({
    onUserUpdateResult: function(data) {
      //update result data
    },
    onUserDeleteResult: function(data) {
      //deletion result data
    },
    onUsersBackupResult: function(data) {
      //user backup result data
    },
    onUsersRestoreResult: function(data) {
      //user restore result data
    },
    onSyncConfirmationCodeAccepted: function(data) {
      //called when the sync confirmation code is accepted
    },
    onSyncConfirmationCodeRequired: function(data) {
      //called when the sync confirmation code is required
    },
    onSyncResult: function(data) {
      //sync result data
    },
  });
   * syncAccounts(syncData, callback) - synchronize the accounts with the desktop app by passing the data from QR code (or wherever else) here
 * backupAccounts(serverPinHash, devicePinHash, oldBackupData, callback) - call to run the backup flow. Save the data 
from the callback in any secure storage
 * deleteBackup(callback) - invalidate the backup for your accounts
 * restoreAccounts(backupData, devicePinHash, serverPinHash, callback) - pass the previously saved data here to restore the accounts
  * sendDeclineReason(reason) - provide the server with the reason of why the authentication was declined
 * getUsers(callback) - get the users list
 * getAuthenticationHistory(callback) - get the history of authentication attempts
 * deleteUserById(id, callback) - call to delete the user
 * validatePin(encryptedString, password, callback) - validate the pin code for account restoration

next topic: NoPass™ SDK for iOS

previous topic: NoPass™ SDK for Android

 
Suggest edits