Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/aaronhuggins/base64url-xplatform
- Owner: aaronhuggins
- Created: 2020-08-07T19:58:13.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-08-10T18:22:32.000Z (over 4 years ago)
- Last Synced: 2024-10-13T12:27:13.611Z (about 1 month ago)
- Language: TypeScript
- Size: 101 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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
```