0.0.5 • Published 5 years ago

singlesource.js v0.0.5

Weekly downloads
1
License
Apache-2.0
Repository
-
Last release
5 years ago

SingleSource.js

Useage

  1. Install package.
npm install singlesource.js
  1. Import it in your code.
import * as singlesource from 'singlesource.js';

Opening a JWT

Opening a signed JWT, recieved from a SingleSource service. eg. A Identity Disclosure Request object. Opening a JWT first encures authenticity (using the public key to verify the JWT was sent by the private key holder) and integrity of the message (making sure the content of the JWT has not been alterd by a third party, by application of a Message Authentication Code in the signing algorithm)

import { openJWT } from 'singlesource.js';

// Public key is an object containing x coordinate from a Ed255119 key, encoded as Base64URL strings
let publicKey = {
    'x': '11qYAYKxCrfVS_7TyWQHOg7hcvPapiMlrwIaaPcHURo',
};

let JWT = "eyJhbGciOiJFUzI1NksiLCJ0eXAiOiJKV1QifQ.eyJhYmMiOiIxMjMiLCJmb28iOiJiYXIifQ.S-j1tB6EZMY_qnpgMnlaXLFzGANjSuc9PudcTsza3amoXFmislxwkcfavzbRXzQLBBbMozSjM857FIXAYO0fDQ";

let openedJWT = openJWT(JWT, publicKey);
header: {
    "alg": "ES256K",
    "typ": "JWT",
}
payload: {
    "abc": "123",
    "foo": "bar"
    }

Creating a JWT (using Ed25519)

Creates a signed JWT, for sending to a SingleSource service. eg. A Selective Disclosure object.

import { createJWT } from 'singlesource.js';

const payload = {
    "foo": "bar",
    "answer": 42,
};
// Any extra headers to add to the JWT
const extraHeader = { "author": "Mischa" };

// key must be a Base64URL encoded String representation of the secret value (called d) of a secp256k1 keypair;
const key = "aRx7IhkeN6u77hCepIXssdZ3up0rt1Dybj_EOZ8CVhM";

let JWT = createJWT(payload, extraHeader, key);

// JWT = "Header"."Payload"."Signature"
0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago