// Ref: https://en.wikipedia.org/wiki/JSON_Web_Token
const jws = require('jws')
const privateKey = 'dante-signature'
const encoding = 'utf8'
const header = {
alg: "HS256",
typ: "JWT"
}
const payload = {
sub: "1234567890",
name: "John Doe",
admin: true,
iat: 1596239022
}
const toBase64 = (data) => {
return Buffer.from(JSON.stringify(data)).toString('base64')
}
const result = jws.createSign({
header,
privateKey,
payload,
encoding
}).once()
console.log(result)