Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/aaronhuggins/base64url-xplatform

A cross-platform implementation of base64 URL.
https://github.com/aaronhuggins/base64url-xplatform

Last synced: 9 days ago
JSON representation

A cross-platform implementation of base64 URL.

Awesome Lists containing this project

README

        

# Base64Url Cross-Platform

A cross-platform implementation of base64 URL, with typescript definitions included.

## Usage

Install via [NPM](https://www.npmjs.com/package/base64url-xplatform) and require in your project. There is also an ESM export, for use with browser or Deno.

```js
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
```