heimdallJS
Heimdall API client & utils for javascript technologies.
Prerequisites
To use this client, you must first have an admin user on the Heimdall API.
Installation
npm -i --save @owlnext/heimdall-js
Usage
import Heimdall from '@owlnext/heimdall-js'
const heimdall: Heimdall = new Heimdall();
heimdall.authenticate({
login: '<your login>',
password: '<your password>',
application_uuid: '<your application UUID>'
});
if(true === heimdall.isAuthenticated()) {
}
if('my_user_login' === heimdall.api.getCurrentLoggedIn()) {
}
let encrypted: string;
heimdall.createKey(['<a group iri>']).then(key => {
heimdall.getCipherKey(key.id).then(cipher => {
encrypted = heimdall.encrypt('<your message>', cipher.cipherKey);
});
});
let decrypted: string;
heimdall.getCipherKey('<key id>').then(cipher => {
decrypted = heimdall.decrypt('<your encrypted message>', cipher.cipherKey);
});
Note: You also have access to the full API implementation with the api
getter from the Heimdall
object.
Integration environment
To use integration environment, simply add the server_environment
as a property to your authentication.
import Heimdall from '@owlnext/heimdall-js'
const heimdall: Heimdall = new Heimdall();
heimdall.authenticate({
login: '<your login>',
password: '<your password>',
application_uuid: '<your application UUID>',
server_environment: Heimdall.SERVER_ENVIRONMENT_INTEGRATION
});
heimdall.reconnect({
refresh_token: '<your refresh token>',
application_uuid: '<your application UUID>',
server_environment: Heimdall.SERVER_ENVIRONMENT_INTEGRATION
});
If left untouched, the default behaviour points the API to the production environment.