From 2863feb356cdf5285bb0f6b388228c802f8ff5ef Mon Sep 17 00:00:00 2001 From: Markin Igor <markin.io210@gmail.com> Date: Fri, 9 Nov 2018 13:59:42 +0300 Subject: [PATCH] Add usage examples --- README.md | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/README.md b/README.md index e0dc73a..b456008 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,49 @@ Vereign’s JavaScript library is an asynchronous library that allows for digitally signing your email and in-browser documents, data encryption, and key-based authentication. +## Usage +Add library as inline script. +```html +<script type="text/javascript" src="./viamapi-client.js"/> +``` + +Initialize library +```js +// Target container used to append iframe +const containerId = "root"; + +// Required methods used to be called within iframe. +const methods = { + onEvent(event) { console.log(event) } +}; + +// Iframe URL to connect +const iframeUrl = "https://test.org/iframe"; + +// API url used to access endpoints +const apiUrl = "https://test.org/api"; + +this.library = setupViamAPI(containerId, methods, iframeUrl, apiUrl); + +this.library.then(lib => { + this.listenerUUID = this.addListener({ + callback: function(event) { + handleEvent(event); + }, + filters: [ + "IdentityNotLoaded", + "ActionConfirmedAndExecuted", + "Authenticated" + ] + }); + + lib.listIdentities().then(response => { + this.setState({ identities: response.data }); + }); +}); +``` + + ## Development ### Running -- GitLab