Newer
Older
1. [Introduction](#introduction)
1. [Setup](#setup)
1. [Usage](#usage)
1. [License](#license)
# Introduction
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.
# Setup
Run `make` and get client library and iframe bundles from `javascript/dist`
# 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, wopiUrl);
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 });
});
});
```
Run `make dev` to enter development mode. Library will be built with all Restful API endpoints and served from `localhost:9000`. If you edit JS libs code, it will be reloaded on the fly.
- Client being served from `http://localhost:9000/viamapi-client.js`
- Iframe being served from `http://localhost:9000/viamapi-iframe.html`
You can specify these URLs in the clients.
If you have to do changes in `main.go`, you need interrupt current process and do `make dev` again.
Since libs and restful-api being served within different ports during the development,
it worth mention that responses from restful-api in dev mode must include `"Access-Control-Allow-Origin": "http://localhost:9000"`
and `"Access-Control-Allow-Headers": "*"` headers.
This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details.