1.0.0 • Published 8 months ago

@mono.co/prove.js v1.0.0

Weekly downloads
-
License
-
Repository
-
Last release
8 months ago

Mono Prove.js

Mono Prove.js is a quick and secure way to verify identity from within your app. Mono Prove is a drop-in framework that handles identity verification of costumers using your app (personal information, documents, and bank accounts, etc). It works with all major javascript frameworks.

For verifying customer identity and interacting with Mono's API use the documentation Mono API.

Documentation

For complete information about Mono Project, head to the docs.

Requirements

Node 10 or higher.

Getting Started

  1. Register on the Mono website and get your public and secret keys.
  2. Setup a server to exchange tokens to access user identity information with your Mono secret key.

Installation

You can install the package using NPM or Yarn;

npm install @mono.co/prove.js

or

yarn add @mono.co/prove.js

Usage

Click the links below for detailed examples on how to use prove.js with your favourite framework;

NOTE
The list above is not exhaustive, you can use this package in other frontend javascript frameworks.

Parameters

requestId

The requestId is the param ID attached at the end of the link generated after initiating a request using the mono prove initiation API.

new Connect({
  requestId: 'prove_request_id',
});

onSuccess

Required This function is called when a user has successfully verified their identity.

new Prove({
  requestId: 'prove_request_id',
  onSuccess: () => {
    // fetch user identity information from server
  }
});

onClose

The optional closure is called when a user has specifically exited the Mono Prove flow (i.e. the widget is not visible to the user). It does not take any arguments.

new Connect({
  requestId: 'prove_request_id'
  onClose: () => console.log("widget has been closed")
});

onLoad

This function is invoked the widget has been mounted unto the DOM. You can handle toggling your trigger button within this callback.

new Connect({
  requestId: 'prove_request_id',
  onLoad: () => console.log("widget loaded successfully")
});

onEvent

This optional function is called when certain events in the Mono Prove flow

See the data object below for details.

new Connect({
  requestId: 'prove_request_id',
  onEvent: (eventName, data) => {
    console.log(eventName);
    console.log(data);
  }
});

API Reference

setup()

This method is used to load the widget unto the DOM, the widget remains hidden after invoking this function until the open() method is called.

const connect = new Connect({
  requestId: 'prove_request_id',
  onSuccess: () => console.log("Identity verified successfully"),
  onLoad: () => console.log("widget loaded successfully"),
  onClose: () => console.log("widget has been closed"),
  onEvent: (eventName, data) => {
    console.log(eventName);
    console.log(data);
  },
});

connect.setup();

open()

This method makes the widget visible to the user.

const connect = new Connect({
  requestId: 'prove_request_id',
  onSuccess: () => console.log("Identity verified successfully"),
});

connect.setup();
connect.open();

close()

This method programatically hides the widget after it's been opened.

const connect = new Connect({
  requestId: 'prove_request_id',
  onSuccess: () => console.log("Identity verified successfully"),
});

connect.setup();
connect.open();

// this closes the widget 5seconds after it has been opened
setTimeout(() => connect.close(), 5000)

onEvent Callback

The onEvent callback returns two paramters, eventName a string containing the event name and data an object that contains event metadata.

const connect = new Connect({
  requestId: 'prove_request_id'
  onSuccess: ({code}) => console.log("code", code),
  onEvent: (eventName, data) => {
   // handle event
  }
});

eventName

Event names corespond to the type key returned by the raw event data. Possible options are in the table below.

Event NameDescription

data

The data object returned from the onEvent callback.

{

}

Support

If you're having general trouble with Mono Prove.js or your Mono integration, please reach out to us at support@mono.co or come chat with us on Slack. We're proud of our level of service, and we're more than happy to help you out with your integration to Mono.

Contributing

If you find any issue using this package please let us know by filing an issue right here.

If you would like to contribute to the Mono Connect.js, please make sure to read our contributor guidelines.

License

MIT for more information.