An open API service indexing awesome lists of open source software.

https://github.com/torxed/javascript-olife

JavaScript bindings for
https://github.com/torxed/javascript-olife

Last synced: about 2 months ago
JSON representation

JavaScript bindings for

Awesome Lists containing this project

README

        

# javascript-olife
JavaScript bindings for [obtain.life](https://github.com/Torxed/obtain.life).

Used in back-end services or front-end to get SSO *(single Sign On)* or to communicate with the obtain.life Identity Management suit *(self-hosted or otherwise)*.

On its own, it only creates valid data structures for `obtain.life`.

To send them, use HTTP or WebSocket requests, via for instance [slimWebSocket](https://github.com/Torxed/slimWebSocket).

# Features

* [HS256](https://github.com/Torxed/javascript-olife/wiki/HS256)
* HS384
* HS512
* RS256
* RS384
* RS512
* ES256
* ES384
* ES512
* PS256
* PS384
* PS512
* EdDSA

# Installation

```html

```

Or via GitHub as CDN:

```html

// Loading JavaScript from a cross-site resource is blocked on GitHub.
// But there's nothing stopping us from downloading the script as a
// text-blob and placing it within the <script> </ script> tags,
// which causes the browser to parse it, but not as a forrain object.
//
// #LoadingScriptsFromGithub

let xhr = new XMLHttpRequest();
xhr.open("GET", 'https://raw.githubusercontent.com/Torxed/javascript-olife/master/olife.js', true);
xhr.onreadystatechange = function() {
if (this.readyState === XMLHttpRequest.DONE && this.status === 200) {
let script = document.createElement('script');
script.type = 'text/javascript';
script.innerHTML = this.responseText;
document.head.appendChild(script);
}
}
xhr.send();

```
# Example usecases

```html

let secret = "rather secret key";

let life = new olife('obtain.life', 'HS256', secret);
life.login('username', 'password');

let payload = {
"algo": "HS256",
"something": "to be sent"
};
life.sign(payload, function(signature) {
payload['sign'] = signature
external_socket.send(payload);
})

```