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
- Host: GitHub
- URL: https://github.com/torxed/javascript-olife
- Owner: Torxed
- License: gpl-3.0
- Created: 2019-12-15T00:54:34.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-12-24T15:16:34.000Z (over 5 years ago)
- Last Synced: 2025-01-25T17:15:50.783Z (4 months ago)
- Language: JavaScript
- Homepage: https://github.com/Torxed/obtain.life
- Size: 49.8 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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.
//
// #LoadingScriptsFromGithublet 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);
})```