0.1.2 • Published 1 year ago

mt-id-verification-sdk v0.1.2

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

Moneytrans. ID Verification SDK

SDK for embedding an iframe for ID verification.

Installation

You can install the SDK from npm:

npm install mt-id-verification-sdk

Authorization

The SDK can be used by authenticated agent users of Moneytrans.

After this, it will be necessary to obtain authorization for the Wrapper/SDK, which will provide one necessary parameter for the configuration: ekycURL.

curl --location '<API_ENDPOINT>/customer/idverification' \
--header 'Authorization: <SESSION_TOKEN>' \

Example response:

{
  "ekycSessionId": "a6836bf6-xxxx-xxxx-xxxx-5a3ee22cd1ef",
  "ekycURL": "https://idverification-cld-ts.moneytrans.eu/?token=323766c8-xxxx-xxxx-xxxx-f7cd8753bf53"
}

Usage

Basic Setup

HTML: Create a basic HTML structure where the SDK will be integrated.

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>ID Verification Example</title>
</head>
<body>
  <div id="idVerificationSdk"></div>
  <script src="example.js"></script>
</body>
</html>

JavaScript: Use the SDK to load the iframe after requesting camera permission.

// example.js

// Ensure the SDK is available
import { IdVerificationSDK } from 'mt-id-verification-sdk';

// Create a new instance of the SDK
const sdk = new IdVerificationSDK();

// SDK configuration
const config = {
  elementRef: document.getElementById('idVerificationSdk'),
  url: 'https://your-wrapper-url.com?token=XXX&uniqueId=XXX',
  language: 'en',
  needsCameraPermission: true,
  onSuccess: (event) => {
    console.log('Id verification completed:', event);
  },
  onError: (event) => {
    console.error('Error:', event);
  },
};

// Load the SDK
sdk.load(config).catch(error => {
  console.error('Error loading SDK:', error);
});

Usage in Angular

Here is a basic example of how to use the SDK in Angular app:

import { AfterViewInit, Component, ElementRef, OnDestroy, ViewChild } from '@angular/core';
import { IdVerificationSDK, IdVerificationSdkConfig } from 'mt-id-verification-sdk';

@Component({
  selector: 'app-root',
  template: `<div #idVerificationSdk></div>`,
})
export class AppComponent implements AfterViewInit, OnDestroy {
  @ViewChild('idVerificationSdk') idVerificationElement: ElementRef;
  private sdk: IdVerificationSDK = new IdVerificationSDK();

  ngAfterViewInit(): void {
    const config: IdVerificationSdkConfig = {
      elementRef: this.idVerificationElement.nativeElement,
      url: 'https://your-wrapper-url.com?token=XXX&uniqueId=XXX',
      language: 'en',
      needsCameraPermission: true,
      onSuccess: (event) => {
        console.log('Id verification completed:', event);
      },
      onError: (event) => {
        console.error('Error:', event);
      },
    };

    // Load the SDK
    this.sdk.load(config).catch(error => {
      console.error('Error loading SDK:', error);
    });
  }

  ngOnDestroy(): void {
    this.sdk.destroy();
  }
}

API

IdVerificationSDK

The IdVerificationSDK class provides methods to load and destroy the iframe for ID verification.

Methods

  • load(config: IdVerificationSdkConfig): void
    • Loads the iframe with the specified configuration.
  • destroy(): void
    • Destroys the iframe and cleans up event listeners.

IdVerificationSdkConfig

The IdVerificationSdkConfig interface specifies the configuration for loading the iframe.

Properties

  • elementRef: HTMLElement
    • The HTML element where the iframe will be appended.
  • url: string
    • The URL of the wrapper with the token attribute.
    • ekycURL returned in the service /customer/idverification*
  • language?: 'en' | 'es' | 'fr'
    • Defaults to en.
  • needsCameraPermission?: boolean
    • Whether the SDK needs camera permission.
  • onSuccess: (event: any) => void
    • A callback function that is called when the id verification is completed.
  • onError: (event: any) => void
    • A callback function that is called when the id verification fails.
0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago