Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nodesolidserver/jose
JSON Object Signing and Encryption for Node.js and the browser
https://github.com/nodesolidserver/jose
running-code
Last synced: 2 months ago
JSON representation
JSON Object Signing and Encryption for Node.js and the browser
- Host: GitHub
- URL: https://github.com/nodesolidserver/jose
- Owner: nodeSolidServer
- License: mit
- Created: 2018-06-06T18:19:17.000Z (over 6 years ago)
- Default Branch: main
- Last Pushed: 2023-03-15T05:18:24.000Z (almost 2 years ago)
- Last Synced: 2024-10-31T15:09:22.651Z (3 months ago)
- Topics: running-code
- Language: JavaScript
- Homepage:
- Size: 816 KB
- Stars: 4
- Watchers: 10
- Forks: 2
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# JSON Object Signing and Encryption (JOSE) _(@solid/jose)_
> Lightweight isomorphic JSON Object Signing and Encryption (JOSE) library for browser and Node.js
## Table of Contents
- [Security](#security)
- [Background](#background)
- [Install](#install)
- [Usage](#usage)
- [License](#license)## Security
TBD
## Background
- Based on Webcrypto API
- Isomorphic (Node.js and Browser)## Install
Requires Node.js 8+.
```
npm install @solid/jose
```## Usage
### Building with Webpack
**Important:**
If you're using this library as a dependency and you plan to use Webpack, don't
forget to add the following lines to your `webpack.config.js` `externals:`
section:```js
externals: {
'@sinonjs/text-encoding': 'TextEncoder',
'isomorphic-webcrypto': 'crypto'
}
```### In Node
```js
const { JWT } = require('@solid/jose')const decoded = JWT.decode(data) // throws an error if invalid
```### In Browser
If you `npm install @solid/jose` as a dependency, the Webpack'd minified bundle will be
available in the `dist/` directory as `jose.min.js`.If you're actively developing/testing this lib, you can `npm run dist`, and the
bundle will be rebuilt.To use in the browser, simply import the bundle in a `` tag, and the lib
will be loaded into the `window.JOSE` global variable.Example `test.html` file, to illustrate:
```html
<html>
<head>
<script src="dist/jose.min.js">
// You can now start using the library
let jwt = new JOSE.JWT({
header: { alg: 'HS256' },
payload: { iss: 'https://forge.anvil.io' }
})
Sample usage of JOSE lib in a browser.