1.1.2 • Published 4 years ago
base64url-xplatform v1.1.2
Base64Url Cross-Platform
A cross-platform implementation of base64 URL, with typescript definitions included.
Usage
Install via NPM and require in your project. There is also an ESM export, for use with browser or Deno.
const { Base64Url } = require('base64url-xplatform')
const header = { alg: 'RS256' }
const claimsSet = {
iss: 'iss',
sub: 'sub',
aud: 'aud',
exp: Math.floor(Date.now() / 1000) + 60 * 5
}
const encodedJWTHeader = Base64Url.encode(JSON.stringify(header))
const encodedJWTClaimsSet = Base64Url.encode(JSON.stringify(claimsSet))
const existingString = encodedJWTHeader + '.' + encodedJWTClaimsSet