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

@azify/aziface-mobile

Package Overview
Dependencies
Maintainers
5
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@azify/aziface-mobile

A Aziface sdk adapter to react native. πŸ“±

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
5
Created
Source

@azify/aziface-mobile

Aziface sdk adapter to react native. πŸ“±


Installation

npm install @azify/aziface-mobile

Usage

import * as React from 'react';

import {
  StyleSheet,
  View,
  Text,
  TouchableOpacity,
  ScrollView,
  NativeEventEmitter,
} from 'react-native';
import AzifaceSdk, {
  AzifaceSdkProps,
  initialize,
  faceMatch,
  photoMatch,
} from '@azify/aziface-mobile';

export default function App() {
  const init = async () => {
    /*
     * The SDK must be initialized first
     * so that the rest of the library
     * functions can work!
     *
     * */
    const headers = {
      'clientInfo': 'YUOR_CLIENT_INFO',
      'contentType': 'YOUR_CONTENT_TYPE',
      'device': 'YOUR_DEVICE',
      'deviceid': 'YOUR_DEVICE_ID',
      'deviceip': 'YOUR_DEVICE_IP',
      'locale': 'YOUR_LOCALE',
      'xForwardedFor': 'YOUR_X_FORWARDED_FOR',
      'user-agent': 'YOUR_USER_AGENT',
    };
    const params = {
      device: 'YOUR_DEVICE',
      url: 'YOUR_BASE_URL',
      key: 'YOUR_KEY',
      productionKey: 'YOUR_PRODUCTION_KEY',
    };

    const isInitialized = await initialize({
      params,
      headers,
    });

    console.log(isInitialized);
  };

  const emitter = new NativeEventEmitter(AzifaceSdk);
  emitter.addListener('onCloseModal', (event: boolean) =>
    console.log('onCloseModal', event)
  );

  const onPressPhotoMatch = async () => {
    try {
      const isSuccess = await photoMatch();
      console.log(isSuccess);
    } catch (error: any) {
      console.error(error.message);
    }
  };

  const onPressFaceMatch = async (
    type: AzifaceSdkProps.MatchType,
    data?: AzifaceSdkProps.MatchData
  ) => {
    try {
      const isSuccess = await faceMatch(type, data);
      console.log(isSuccess);
    } catch (error: any) {
      console.error(error.message);
    }
  };

  return (
    <ScrollView style={styles.container}>
      <View style={styles.content}>
        <TouchableOpacity style={styles.button} onPress={init}>
          <Text style={styles.text}>Init Aziface Module</Text>
        </TouchableOpacity>
        <TouchableOpacity style={styles.button} onPress={onPressPhotoMatch}>
          <Text style={styles.text}>Open Photo Match</Text>
        </TouchableOpacity>
        <TouchableOpacity
          style={styles.button}
          onPress={async () => await onPressFaceMatch('enroll')}
        >
          <Text style={styles.text}>Open Enroll</Text>
        </TouchableOpacity>
        <TouchableOpacity
          style={styles.button}
          onPress={async () =>
            await onPressFaceMatch('authenticate', { id: '123456' })
          }
        >
          <Text style={styles.text}>Open Authenticate</Text>
        </TouchableOpacity>
        <TouchableOpacity
          style={styles.button}
          onPress={async () => await onPressFaceMatch('liveness')}
        >
          <Text style={styles.text}>Open Liveness</Text>
        </TouchableOpacity>
      </View>
    </ScrollView>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    padding: 20,
  },
  content: {
    justifyContent: 'center',
    alignItems: 'center',
    marginVertical: 30,
  },
  button: {
    width: '100%',
    backgroundColor: '#4a68b3',
    padding: 20,
    borderRadius: 15,
    alignItems: 'center',
    justifyContent: 'center',
    marginVertical: 20,
  },
  text: {
    color: 'white',
    fontWeight: '700',
    fontSize: 22,
  },
});

API

MethodsReturn TypeiOSAndroid
initialize(init: AzifaceSdkProps.Initialize)Promise<boolean>βœ…βœ…
faceMatch(type: AzifaceSdkProps.MatchType, data?: AzifaceSdkProps.MatchDataPromise<boolean>βœ…βœ…
photoMatch(data?: Object)Promise<boolean>βœ…βœ…
setTheme(options?: AzifaceSdkProps.Theme)voidβœ…βœ…

initialize(init: AzifaceSdkProps.Initialize)

This is the principal method to be called, he must be called first to initialize the Aziface SDK. If he doens't be called the other methods don't works!

AzifaceSdkProps.InitializetypeRequiredDefault
paramsAzifaceSdkProps.Paramsβœ…-
headersAzifaceSdkProps.Headers❌undefined

faceMatch(type: AzifaceSdkProps.MatchType, data?: AzifaceSdkProps.MatchData)

This method is called to make enrollment, authenticate and liveness available. The type is required and it must provided to select which flow you are interested.

  • Enrollment: This method makes a 3D reading of the user's face. But, you must use to subscribe user in Aziface SDK or in your server.
  • Authenticate: This method makes a 3D reading of the user's face. But, you must use to authenticate user in Aziface SDK or in your server.
  • Liveness: This method makes a 3D reading of the user's face.
ObjecttypeRequiredDefault
typeAzifaceSdkProps.MatchTypeβœ…-
dataAzifaceSdkProps.MatchData❌undefined

photoMatch(data?: Object)

This method make to read from face and documents for user, after comparate face and face documents from user to check veracity.

ObjecttypeRequiredDefault
dataObject❌undefined

setTheme(options?: AzifaceSdkProps.Theme)

This method must be used to set the theme of the Aziface SDK screen.

AzifaceSdkProps.ThemetypeRequiredDefault
optionsAzifaceSdkProps.Theme❌undefined

Types

AzifaceSdkProps - TypesiOSAndroid
AzifaceSdkProps.Paramsβœ…βœ…
AzifaceSdkProps.Headersβœ…βœ…
AzifaceSdkProps.Themeβœ…βœ…
AzifaceSdkProps.ButtonLocationβœ…βœ…
AzifaceSdkProps.StatusBarColorβœ…βŒ
AzifaceSdkProps.FeedbackBackgroundColorβœ…βŒ
AzifaceSdkProps.Pointβœ…βŒ
AzifaceSdkProps.DefaultMessageβœ…βœ…
AzifaceSdkProps.Errorsβœ…βœ…
AzifaceSdkProps.MatchTypeβœ…βœ…
AzifaceSdkProps.MatchDataβœ…βœ…

AzifaceSdkProps.Params

Here must be passed to initialize the Aziface SDK! Case the parameters isn't provided the Aziface SDK goes to be not initialized.

AzifaceSdkProps.ParamstypeRequired
devicestringβœ…
urlstringβœ…
keystringβœ…
productionKeystringβœ…
isDeveloperModeboolean❌

AzifaceSdkProps.Headers

Here you can add your headers to send request when some method is called. Only values from type string, null or undefined are accepts!

AzifaceSdkProps.HeaderstypeRequiredDefault
[key: string]string, null or undefined❌undefined

AzifaceSdkProps.Theme

This is a list of theme properties that can be used to styling. We recommend that you use hexadecimal values for colors. RGB, RGBA, HSL and HSLA colors are also supported.

AzifaceSdkProps.ThemetypeiOSAndroidRequiredDefault
logoImagestringβœ…βœ…βŒfacetec_your_app_logo.png
cancelImagestringβœ…βœ…βŒfacetec_cancel.png
cancelButtonLocationAzifaceSdkProps.ButtonLocationβœ…βœ…βŒTOP_RIGHT
defaultStatusBarColorIosAzifaceSdkProps.StatusBarColorβœ…βŒβŒDARK_CONTENT
frameCornerRadiusnumberβœ…βœ…βŒ10 (iOS) and 20 (Android)
frameBackgroundColorstringβœ…βœ…βŒ#FFFFFF
frameBorderColorstringβœ…βœ…βŒ#FFFFFF
overlayBackgroundColorstringβœ…βœ…βŒ#FFFFFF
guidanceBackgroundColorsAndroidstringβŒβœ…βŒ#FFFFFF
guidanceBackgroundColorsIosstring[]βœ…βŒβŒ["#FFFFFF", "#FFFFFF"]
guidanceForegroundColorstringβœ…βœ…βŒ#272937
guidanceButtonBackgroundNormalColorstringβœ…βœ…βŒ#026FF4
guidanceButtonBackgroundDisabledColorstringβœ…βœ…βŒ#B3D4FC
guidanceButtonBackgroundHighlightColorstringβœ…βœ…βŒ#0264DC
guidanceButtonTextNormalColorstringβœ…βœ…βŒ#FFFFFF
guidanceButtonTextDisabledColorstringβœ…βœ…βŒ#FFFFFF
guidanceButtonTextHighlightColorstringβœ…βœ…βŒ#FFFFFF
guidanceRetryScreenImageBorderColorstringβœ…βœ…βŒ#FFFFFF
guidanceRetryScreenOvalStrokeColorstringβœ…βœ…βŒ#FFFFFF
ovalStrokeColorstringβœ…βœ…βŒ#026FF4
ovalFirstProgressColorstringβœ…βœ…βŒ#0264DC
ovalSecondProgressColorstringβœ…βœ…βŒ#0264DC
feedbackBackgroundColorsAndroidstringβŒβœ…βŒ#026FF4
feedbackBackgroundColorsIosAzifaceSdkProps.FeedbackBackgroundColor βœ…βŒβŒFeedbackBackgroundColor
feedbackTextColorstringβœ…βœ…βŒ#FFFFFF
resultScreenBackgroundColorsAndroidstringβŒβœ…βŒ#FFFFFF
resultScreenBackgroundColorsIosstring[]βœ…βŒβŒ["#FFFFFF", "#FFFFFF"]
resultScreenForegroundColorstringβœ…βœ…βŒ#272937
resultScreenActivityIndicatorColorstringβœ…βœ…βŒ#026FF4
resultScreenResultAnimationBackgroundColorstringβœ…βœ…βŒ#026FF4
resultScreenResultAnimationForegroundColorstringβœ…βœ…βŒ#FFFFFF
resultScreenUploadProgressFillColorstringβœ…βœ…βŒ#026FF4
idScanSelectionScreenBackgroundColorsAndroidstringβŒβœ…βŒ#FFFFFF
idScanSelectionScreenBackgroundColorsIosstring[]βœ…βŒβŒ["#FFFFFF", "#FFFFFF"]
idScanSelectionScreenForegroundColorstringβœ…βœ…βŒ#272937
idScanReviewScreenForegroundColorstringβœ…βœ…βŒ#FFFFFF
idScanReviewScreenTextBackgroundColorstringβœ…βœ…βŒ#026FF4
idScanCaptureScreenForegroundColorstringβœ…βœ…βŒ#FFFFFF
idScanCaptureScreenTextBackgroundColorstringβœ…βœ…βŒ#026FF4
idScanButtonBackgroundNormalColorstringβœ…βœ…βŒ#026FF4
idScanButtonBackgroundDisabledColorstringβœ…βœ…βŒ#B3D4FC
idScanButtonBackgroundHighlightColorstringβœ…βœ…βŒ#0264DC
idScanButtonTextNormalColorstringβœ…βœ…βŒ#FFFFFF
idScanButtonTextDisabledColorstringβœ…βœ…βŒ#FFFFFF
idScanButtonTextHighlightColorstringβœ…βœ…βŒ#FFFFFF
idScanCaptureScreenBackgroundColorstringβœ…βœ…βŒ#FFFFFF
idScanCaptureFrameStrokeColorstringβœ…βœ…βŒ#FFFFFF
autheticanteMessageAzifaceSdkProps.DefaultMessageβœ…βœ…βŒDefaultMessage
enrollMessageAzifaceSdkProps.DefaultMessageβœ…βœ…βŒDefaultMessage
livenessMessageAzifaceSdkProps.DefaultMessageβœ…βœ…βŒDefaultMessage
photoIdMatchMessageAzifaceSdkProps.DefaultScanMessage and AzifaceSdkProps.DefaultMessageβœ…βœ…βŒDefaultScanMessage and DefaultMessage

AzifaceSdkProps.ButtonLocation

This type must be used to position of the cancel button on screen.

AzifaceSdkProps.ButtonLocationDescription
DISABLEDDisable cancel button and doesn't show it.
TOP_LEFTPosition cancel button in top right.
TOP_RIGHTPosition cancel button in top right. It's default position.

AzifaceSdkProps.StatusBarColor (iOS only)

This type must be used to status bar color.

AzifaceSdkProps.StatusBarColorDescription
DARK_CONTENTDefault color to status bar.
DEFAULTStatus bar color that's set from the device.
LIGHT_CONTENTLight color to status bar.

AzifaceSdkProps.FeedbackBackgroundColor (iOS only)

This type must be used to set the theme of the feedback box.

AzifaceSdkProps.FeedbackBackgroundColorDescriptiontypeRequiredDefault
colorsAn array of colors defining the color of each gradient stop.string[]❌["#026FF4", "#026FF4"]
locationsIt's accepts only two values between 0 and 1 that defining the location of each gradient stop.[number, number]❌[0, 1]
startPointThe start point of the gradient when drawn in the layer’s coordinate space.Point❌x: 0 and y: 0
endPointThe end point of the gradient when drawn in the layer’s coordinate space.Point❌x: 1 and y: 0

AzifaceSdkProps.Point (iOS only)

This interface defines the drawn in the layer's coordinate space.

AzifaceSdkProps.PointtypeRequiredDefault
xnumber❌undefined
ynumber❌undefined

AzifaceSdkProps.DefaultMessage

This interface represents the success message and loading data message during to AzifaceSDK flow. It interface is used more by processors's authenticate and enroll processors.

AzifaceSdkProps.DefaultMessagetypeiOSAndroidRequiredDefault
successMessagestringβœ…βœ…βŒLiveness Confirmed (Exception to authenticate method: Autheticated)
uploadMessageIosstringβœ…βŒβŒStill Uploading...

AzifaceSdkProps.DefaultScanMessage

This interface represents the all scan messages during to AzifaceSDK flow. It interface is used by photoMatch processors.

AzifaceSdkProps.DefaultScanMessagetypeiOSAndroidRequiredDefault
frontSideUploadStartedstringβœ…βœ…βŒUploading Encrypted ID Scan
frontSideStillUploadingstringβœ…βœ…βŒStill Uploading... Slow Connection
frontSideUploadCompleteAwaitingResponsestringβœ…βœ…βŒUpload Complete
frontSideUploadCompleteAwaitingResponsestringβœ…βœ…βŒProcessing ID Scan
backSideUploadStartedstringβœ…βœ…βŒUploading Encrypted Back of ID
backSideStillUploadingstringβœ…βœ…βŒStill Uploading... Slow Connection
backSideUploadCompleteAwaitingResponsestringβœ…βœ…βŒUpload Complete
backSideUploadCompleteAwaitingProcessingstringβœ…βœ…βŒProcessing Back of ID
userConfirmedInfoUploadStartedstringβœ…βœ…βŒUploading Your Confirmed Info
userConfirmedInfoStillUploadingstringβœ…βœ…βŒStill Uploading... Slow Connection
userConfirmedInfoUploadCompleteAwaitingResponsestringβœ…βœ…βŒUpload Complete
userConfirmedInfoUploadCompleteAwaitingProcessingstringβœ…βœ…βŒProcessing
nfcUploadStartedstringβœ…βœ…βŒUploading Encrypted NFC Details
nfcStillUploadingstringβœ…βœ…βŒStill Uploading... Slow Connection
nfcUploadCompleteAwaitingResponsestringβœ…βœ…βŒUpload Complete
nfcUploadCompleteAwaitingProcessingstringβœ…βœ…βŒProcessing NFC Details
skippedNFCUploadStartedstringβœ…βœ…βŒUploading Encrypted ID Details
skippedNFCStillUploadingstringβœ…βœ…βŒStill Uploading... Slow Connection
skippedNFCUploadCompleteAwaitingResponsestringβœ…βœ…βŒUpload Complete
skippedNFCUploadCompleteAwaitingProcessingstringβœ…βœ…βŒProcessing ID Details
successFrontSidestringβœ…βœ…βŒID Scan Complete
successFrontSideBackNextstringβœ…βœ…βŒFront of ID Scanned
successFrontSideNFCNextstringβœ…βœ…βŒFront of ID Scanned
successBackSidestringβœ…βœ…βŒID Scan Complete
successBackSideNFCNextstringβœ…βœ…βŒBack of ID Scanned
successPassportstringβœ…βœ…βŒPassport Scan Complete
successPassportNFCNextstringβœ…βœ…βŒPassport Scanned
successUserConfirmationstringβœ…βœ…βŒPhoto ID Scan Complete
successNFCstringβœ…βœ…βŒID Scan Complete
retryFaceDidNotMatchstringβœ…βœ…βŒFace Didn’t Match Highly Enough
retryIDNotFullyVisiblestringβœ…βœ…βŒID Document Not Fully Visible
retryOCRResultsNotGoodEnoughstringβœ…βœ…βŒID Text Not Legible
retryIDTypeNotSupportedstringβœ…βœ…βŒID Type Mismatch Please Try Again
skipOrErrorNFCstringβœ…βœ…βŒID Details Uploaded

AzifaceSdkProps.Errors

This enum represents all errors that are encountered on the AziFace SDK.

AzifaceSdkProps.ErrorsDescriptioniOSAndroid
AziFaceHasNotBeenInitializedWhen some processors method is runned, but AzifaceSDK has not been initialized.βœ…βœ…
AziFaceValuesWereNotProcessedWhen the image sent to the processors cannot be processed due to inconsistency.βœ…βœ…
HTTPSErrorWhen exists some network error.βœ…βœ…
JSONErrorWhen exists some problem in getting data in request of base URL information.βœ…βœ…
NoConfigurationsProvidedWhen the configurations faceMatch doesn't provided.βŒβœ…
AziFaceInvalidSessionWhen session status is invalid.βŒβœ…
AziFaceLivenessWasntProcessedWhen the image user sent to the processors cannot be processed due to inconsistency.βŒβœ…
AziFaceScanWasntProcessedWhen the image ID sent to the processors cannot be processed due to inconsistency.βŒβœ…

AzifaceSdkProps.MatchType

This enum represents all the possible types of flow that can be used on the faceMatch method.

AzifaceSdkProps.MatchTypeDescriptioniOSAndroid
authenticateWhen you want to make authenticate flow.βœ…βœ…
enrollWhen you want to make enrollment flow.βœ…βœ…
livenessWhen you want to make liveness flow.βœ…βœ…

The authenticate flow depends on to enrollment flow to work because the authenticate flow is done using an UUID that's was created by enrollment flow.

AzifaceSdkProps.MatchData

The object with properties that will be sent to native modules to make the requests, change text labels and sent parameters via headers.

AzifaceSdkProps.MatchDatatypeiOSAndroidRequiredDefault
endpointstring or nullβœ…βœ…βŒAuthenticated (authenticate) or Liveness\nConfirmed (enrollment and liveness)
parametersstring or nullβœ…βœ…βŒnull
successMessagestring or nullβœ…βœ…βŒ/match-3d-3d (authenticate) or /enrollment-3d (enrollment) or /liveness-3d (liveness)
uploadMessageIosstring or nullβœ…βœ…βŒStill Uploading...

Native Events

MethodsReturn TypeiOSAndroid
addListener(eventType: string, callback: (event: boolean) => void)EmitterSubscriptionβœ…βœ…

Event Types

This is a list of event types that can be used on addListener.

eventTypeReturnDescription
onCloseModalbooleanThis event listener verify if Aziface modal biometric is open. Return true if modal is open, false otherwise.

How to add images in AzifaceSDK module?

The logoImage and cancelImage properties represents your logo and icon of the button cancel. Does not possible to remove them from the module. Default are Azify images and .png format. By default in Android the logo image is shown, but on iOS it isn't shown, It's necessary to add manually.

How to add images in Android?

To add your images in Android, you must go to your project's android/src/main/res/drawable directory. If in your project drawable folder doesn't exist, it create one. Inside the drawable folder, you must put your images and done!

How to add images in iOS?

In iOS, open your XCode and go to your project's ios/<YOUR_PROJECT_NAME>/Images.xcassets directory. Open the Images.xcassets folder and only put your images inside there.

Example with images added

Now, go back to where you want to apply the styles, import setTheme method and add only the image name, no extension format, in image property (logoImage or cancelImage). Note: If the image is not founded the default image will be showed. Check the code example below:

import React, { useEffect } from 'react';
import { View, TouchableOpacity, Text } from 'react-native';
import {
  initialize,
  faceMatch,
  setTheme,
} from '@azify/aziface-mobile';

export default function App() {
  useEffect(() => {
    const params = {
      device: 'YOUR_DEVICE',
      url: 'YOUR_URL',
      key: 'YOUR_PUBLIC_KEY',
      productionKey: 'YOUR_PRODUCTION_KEY',
    };

    async function initialize() {
      await initialize({ params });
      setTheme({
        logoImage: 'yourLogoImage', // yourLogoImage.png
        cancelImage: 'yourCancelImage', // yourCancelImage.png
      });
    }

    initialize();
  }, []);

  return (
    <View
      style={{
        flex: 1,
        justifyContent: 'center',
        alignItems: 'center',
        paddingHorizontal: 20,
      }}
    >
      <TouchableOpacity
        style={{
          width: '100%',
          height: 64,
          justifyContent: 'center',
          alignItems: 'center',
          backgroundColor: 'black',
        }}
        onPress={async () => {
          try {
            const isSuccess = await faceMatch('enroll');
            console.log(isSuccess);
          } catch (error: any) {
            console.error(error);
          }
        }}
      >
        <Text style={{ textAlign: 'center', fontSize: 24, color: 'white' }}>
          Open!
        </Text>
      </TouchableOpacity>
    </View>
  );
}

Limitations, Features or Camera Problems

See the native implementation to learn more about the limitations and features that will need improving in the aziface-mobile-sdk.


Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.


License

MIT License. πŸ™‚


Made with create-react-native-library. 😊

FAQs

Package last updated on 18 Apr 2024

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