0.0.2 β€’ Published 4 years ago

capacitor-persona v0.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

Persona Native Plugin

This Plugin is still under development. Feel free to contribute, ask questions and

This plugin is a simple bridge to the native implementations of Persona Identity Verification


Features / Roadmap

Feat / PlatformAndroidiOSWeb
Start InquiryπŸš§βœ…βŒ
Modify the theme🚧🚧❌

βœ… = Supported, 🚧 = Planned, ❌ = No support

Why is no Web implementation provided?

Personas embedded flow might be added at a later stage, but for now the focus is on the native SDK integration.

A feature is missing

Feel free to open an issue or implement it yourself & contribute.


Installation

Run npm install capacitor-persona to add the latest version to your npm project.

Please follow the additional steps for each platform

Android

The configuration follows the Persona Android SDK Integration Guide

  1. Add add(PersonaNative.class) to the init call in your apps MainActivity. This could look like the following:

    // Other imports...
    import com.example.myapp.EchoPlugin;
    
    public class MainActivity extends BridgeActivity {
    
      @Override
      public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    
        // Initializes the Bridge
        this.init(
            savedInstanceState,
            new ArrayList<Class<? extends Plugin>>() {
              {
                // Additional plugins you've installed go here
                // Ex: add(TotallyAwesomePlugin.class);
    
                // INSERT START
                add(PersonaNative.class);
                // INSERT END
              }
            }
          );
      }
    }
  2. (OPTIONAL: Replace strings) To replace strings with your own content, create a strings.xml file in your project dir. Add any strings you want to modify, following this example:

    <resources>
      <!-- some of your strings.xml strings -->
      <string name="persona_inquiry_start_title">This is the start screen title.</string>
      <string name="persona_inquiry_start_body">This is below that in the body.</string>
      <string name="persona_inquiry_start_button">I\'m a button!</string>
      <!-- more of your strings.xml strings -->
    </resources>

iOS

The configuration follows the Persona iOS SDK Integration Guide

  1. Permissions: Persona needs permissions to access the camera and photo
    • Navigate to your project's settings in Xcode and click the Info tab
    • Add a new "Privacy - Camera Usage Description" (NSCameraUsageDescription) entry (if not already present) to enable camera access.
    • Add a new "Privacy - Photo Library Usage Description" (NSPhotoLibraryUsageDescription) entry (if not already present) to enable photo library access.
  2. (OPTIONAL: Replace strings) Create a file called Persona.strings in your app bundle with the strings you want to replace:

    /*
      Persona.strings
    */
    
    "inquiryStartTitle" = "Verify your identity";
    "inquiryStartBody" = "Let’s make sure you’re you!";
    "inquiryStartButton" = "Get started";

Usage

Import the PersonaNative Plugin from Capacitor's Plugins:

import { Plugins } from '@capacitor/core';

const { PersonaNative } = Plugins;

If you want to have a typed version, you can use the following code instead:

  import { Plugins } from '@capacitor/core';
  import { PersonaNativePlugin } from 'capacitor-persona';

  const PersonaNative = Plugins.PersonaNative as PersonaNativePlugin;

startInquiry(config: InquiryConfig)

Starts an inquiry. You can pass the following arguments in the config:

ParameterTypeDescription
inquiryIdstringStarts an inquiry from an existing inquiryId
templateIdstringStarts an inquiry with the specified template. Only used, if inquiryId is not specified.
referenceIdstringProvides a referenceId that is added to the inquiry. E.g. a user identifier. Only used with templateId
accountIdstringLinks the inquiry to an existing account in Persona. Only used with templateId and if referenceId is not specified
environment'sandbox' \| 'production'Default: production, The environment to use. In sandbox, real verifications are not performed.

Returns Promise<InquiryResult>

The InquiryResult contains data about the inquiry process. It can be one of InquirySuccessResult, InquiryCancelledResult, InquiryFailedResult or InquiryErrorResult. You can identify it by the type property, that is either success, cancelled, ...