0.2.6 • Published 1 year ago

react-native-onfido-auth-sdk v0.2.6

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

react-native-onfido-auth-sdk

Table of contents

Overview

The Onfido Authentication SDK provides a set of screens for React Native applications to capture 3D face scans for the purpose of identity authentication.

Installation

yarn add react-native-onfido-auth-sdk

Usage

You can launch the app with a call to OnfidoAuth.start.

import { OnfidoAuth } from 'react-native-onfido-auth-sdk';
// ...
OnfidoAuth.start({ sdkToken: 'sdkToken' })
  .then(/* ... */)
  .catch(/* ... */);

1. Creating the SDK configuration

Once you have an added the SDK as a dependency and you have a SDK token, you can configure the SDK:

Example configuration:

config = {
  sdkToken: 'EXAMPLE-TOKEN-123',
  retryCount: 2,
}

2. Parameter details

  • sdkToken: Required. This is the JWT sdk token obtained by making a call to the SDK token API.
  • retryCount: Optional. This value is used to set the number of repeat attempts a user can do after the first unsuccessful try.

3. Success Response

Success is when the user has reached the end of the flow. The result has the verified, uuid and token properties. If authentication was successful, verified will be true and token will be the JWT. This JWT token can be used to validate the response.

Example:

{
  token: 'EXAMPLE-TOKEN-456',
  uuid: 'uuid',
  verified: true,
}

4. Failure Response

The SDK will reject the promise any time the OnfidoAuth SDK exits without a success. Error messages are not in a presentable format to the end user and are not localised.

UI Customization

iOS

You can customize the iOS UI by adding a customization.ios.json file to your project at the same level as your node_modules directory. The file should contain a single json object with the desired keys and values. For example:

{
  "onfidoPrimaryTextColor": "",
  "onfidoPrimaryTextDynamicDimmingColor": "",

  "onfidoPrimaryButtonColor": "#4BC0B1",
  "onfidoPrimaryButtonDynamicDimmingColor": "",
  "onfidoPrimaryButtonPressedColor": "#2EAC9C",
  "onfidoPrimaryButtonDisabledColor": "",
  "onfidoPrimaryButtonDisabledDynamicDimmingColor": "",
  "onfidoPrimaryButtonTextColor": "#FFFFFF",
  "onfidoPrimaryButtonTextDynamicDimmingColor": "",
  "onfidoPrimaryButtonTextPressedColor": "",
  "onfidoPrimaryButtonTextDisabledColor": "",
  "onfidoPrimaryButtonTextDisabledDynamicDimmingColor": "",

  "onfidoSecondaryButtonPressedColor": "",
  "onfidoDualSpinnerColor": "",
  "onfidoRetryScreenOvalStrokeColor": "",
  "onfidoUploadProgressFillColor": "",

  "onfidoButtonCornerRadius": 24,

  "onfidoFontRegular": "",
  "onfidoFontMedium": "", 
  "onfidoFontBold": ""
}

Once you've added the customization.ios.json to your project, you should add customization.ios.json file to your xcode project as bundle resource. You can create symbolic link (rather than copy paste) to prevent redundancy. Then when running on an iOS device the values will be picked up dynamically at runtime.

Below is a description of all available keys:

ColorDescription
onfidoPrimaryTextColorColor of most text
onfidoPrimaryTextDynamicDimmingColorColor of text in Dynamic Dimming modeDynamic Dimming mode is automatically enabled in certain lighting conditions and will include UI differences such as the background turning black
onfidoPrimaryButtonColorBackground color of buttons
onfidoPrimaryButtonDynamicDimmingColorBackground color of buttons in Dynamic Dimming modeDynamic Dimming mode is automatically enabled in certain lighting conditions and will include UI differences such as the background turning black
onfidoPrimaryButtonPressedColorBackground color of buttons while being pressed
onfidoPrimaryButtonDisabledColorBackground color of buttons that are disabled
onfidoPrimaryButtonDisabledDynamicDimmingColorBackground color of buttons that are disabled in Dynamic Dimming modeDynamic Dimming mode is automatically enabled in certain lighting conditions and will include UI differences such as the background turning black
onfidoPrimaryButtonTextColorColor of text in buttons
onfidoPrimaryButtonTextDynamicDimmingColorColor of text in buttons in Dynamic Dimming modeDynamic Dimming mode is automatically enabled in certain lighting conditions and will include UI differences such as the background turning black
onfidoPrimaryButtonTextPressedColorColor of text in buttons while being pressed
onfidoPrimaryButtonTextDisabledColorColor of text in buttons that are disabled
onfidoPrimaryButtonTextDisabledDynamicDimmingColorColor of text in buttons that are disabled in Dynamic Dimming modeDynamic Dimming mode is automatically enabled in certain lighting conditions and will include UI differences such as the background turning black
onfidoSecondaryButtonPressedColorBackground color of secondary button (currently this is only the “Do not accept” button in the optional consent screen)
onfidoDualSpinnerColorColor of dual spinner rotating around selfie preview
onfidoRetryScreenOvalStrokeColorStroke color of oval on ideal selfie image in retry screen
onfidoUploadProgressFillColorColor of completed portion of upload progress bar
onfidoButtonCornerRadiusCorner radius of buttons (should be set to 40 maximum, otherwise will not work on some buttons)
onfidoFontRegularName of font to use on regular text
onfidoFontMediumName of font to use on medium text
onfidoFontBoldName of font to use on bold text

Android

You can customize the Android UI by adding a customization.android.json file to your project at the same level as your node_modules directory. The file should contain a single json object with the desired keys and values. For example:

{
  "onfidoColorPrimaryDark": "",
  "onfidoTextColorPrimary": "",

  "onfidoPrimaryButtonTextColor": "#FFFFFF",
  "onfidoPrimaryButtonDisabledTextColor": "#FFFFFF",
  "onfidoPrimaryButtonColor": "#4BC0B1",
  "onfidoPrimaryButtonColorPressed": "#2EAC9C",
  "onfidoPrimaryButtonColorDisabled": "",

  "onfidoSecondaryButtonColor": "",
  "onfidoSecondaryButtonColorPressed": "",

  "onfidoColorAccent": "#4BC0B1",
  "onfidoAuthDualSpinnerColor": "",
  "onfidoAuthRetryScreenOvalStrokeColor": "",
  "onfidoUploadProgressFillColor": "",

  "onfidoPrimaryButtonColorDynamicDimmingMode": "",
  "onfidoPrimaryButtonColorPressedDynamicDimmingMode": "",
  "onfidoPrimaryButtonColorDisabledDynamicDimmingMode": "",

  "onfidoButtonCornerRadius": 32
}

Below is a description of all available keys:

ColorDescription
onfidoColorPrimaryDarkColor of the status bar
onfidoColorAccentDefault color of certain UI elements such as dual spinner around selfie preview, oval around images in retry screen, and upload progress color. These elements can also be customised individually
onfidoTextColorPrimaryPrimary color of the texts used throughout the screens
onfidoPrimaryButtonTextColorColor of the text inside the primary action buttons
onfidoPrimaryButtonDisabledTextColorColor of the text inside the primary action buttons when disabled
onfidoPrimaryButtonColorBackground color of the primary action buttons
onfidoPrimaryButtonColorPressedBackground color of the primary action buttons when pressed
onfidoPrimaryButtonColorDisabledBackground color of the primary action buttons when disabled
onfidoSecondaryButtonColorBackground color of the secondary action buttons
onfidoSecondaryButtonColorPressedBackground color of the secondary action buttons when pressed
onfidoAuthDualSpinnerColorColor of dual spinner rotating around selfie preview. This will override the default color provided by onfidoColorAccent
onfidoAuthRetryScreenOvalStrokeColorStroke color of oval on ideal selfie image in retry screen. This will override the default color provided by onfidoColorAccent
onfidoUploadProgressFillColorFill color of the uploading progress indicator bar. This will override the default color provided by onfidoColorAccent
onfidoPrimaryButtonColorDynamicDimmingModeBackground color of the primary action buttons in dark mode
onfidoPrimaryButtonColorPressedDynamicDimmingModeBackground color of the primary action buttons when pressed in dark mode
onfidoPrimaryButtonColorDisabledDynamicDimmingModeBackground color of the primary action buttons when disabledin dark mode

You can customize the corner radius of all buttons by providing onfidoButtonCornerRadius in your customization.android.json resource file.

Once you've added the customization.android.json to your project, you should run the following command at the same level of your node_modules directory.

$ npm --prefix node_modules/react-native-onfido-auth-sdk/ run customizeAndroid

Contributing

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

License

MIT

0.2.6

1 year ago

0.2.5

2 years ago

0.2.4

2 years ago

0.2.3

2 years ago

0.2.2

2 years ago

0.2.1

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago