|
1 | | -# JSON Object Signing and Encryption (JOSE) |
| 1 | +# JSON Object Signing and Encryption (JOSE) _(@solid/jose)_ |
2 | 2 |
|
3 | | -## Planned Features |
| 3 | +> Lightweight isomorphic JSON Object Signing and Encryption (JOSE) library for browser and Node.js |
4 | 4 |
|
5 | | -- [x] Based on Webcrypto API |
6 | | -- [ ] CryptoKey as expected key argument |
7 | | -- [x] Isomorphic (Node.js and Browser) |
8 | | -- [ ] Extensible JWT/JWS/JWE classes |
| 5 | +## Table of Contents |
9 | 6 |
|
10 | | -## Dependencies |
| 7 | +- [Security](#security) |
| 8 | +- [Background](#background) |
| 9 | +- [Install](#install) |
| 10 | +- [Usage](#usage) |
| 11 | +- [License](#license) |
11 | 12 |
|
12 | | -This package is a work in progress, dependent on other ongoing projects. Code |
13 | | -contained herein will be completed when the following dependencies are ready to |
14 | | -release: |
| 13 | +## Security |
15 | 14 |
|
16 | | -- [anvilresearch/webcrypto](https://github.com/anvilresearch/webcrypto) |
| 15 | +TBD |
17 | 16 |
|
18 | | -The current contents of the repository should be considered a "sketch". |
| 17 | +## Background |
19 | 18 |
|
20 | | -## Scope of implementation |
| 19 | +- Based on Webcrypto API |
| 20 | +- Isomorphic (Node.js and Browser) |
21 | 21 |
|
22 | | -- [JWA][jwa] – **RFC7518** |
23 | | - - [ ] Cryptographic Algorithms for Digital Signatures and MACs |
24 | | - - [ ] Cryptographic Algorithms for Key Management |
25 | | - - [ ] Cryptographic Algorithms for Content Encryption |
26 | | -- [JWK][jwk] – **RFC7517** |
27 | | - - [ ] JSON Web Key (JWK) Format |
28 | | - - [ ] JWK Set Format |
29 | | - - [ ] JSON Web Key (JWK) Thumbprint (RFC7638) |
30 | | - - [ ] Conversion from JWK to PEM and PEM to JWK |
31 | | -- [JWT][jwt] – **RFC7519** |
32 | | -- [JWS][jws] – **RFC7515** |
33 | | -- [JWE][jwe] – **RFC7516** |
| 22 | +## Install |
34 | 23 |
|
35 | | -[jwa]: https://tools.ietf.org/html/rfc7518 |
36 | | -[jwk]: https://tools.ietf.org/html/rfc7517 |
37 | | -[jwt]: https://tools.ietf.org/html/rfc7519 |
38 | | -[jws]: https://tools.ietf.org/html/rfc7515 |
39 | | -[jwe]: https://tools.ietf.org/html/rfc7516 |
| 24 | +Requires Node.js 8+. |
40 | 25 |
|
41 | | -## Usage in Browser |
| 26 | +``` |
| 27 | +npm install @solid/jose |
| 28 | +``` |
| 29 | + |
| 30 | +## Usage |
| 31 | + |
| 32 | +### Building with Webpack |
| 33 | + |
| 34 | +**Important:** |
| 35 | +If you're using this library as a dependency and you plan to use Webpack, don't |
| 36 | +forget to add the following lines to your `webpack.config.js` `externals:` |
| 37 | +section: |
| 38 | + |
| 39 | +```js |
| 40 | + externals: { |
| 41 | + '@sinonjs/text-encoding': 'TextEncoder', |
| 42 | + 'isomorphic-webcrypto': 'crypto' |
| 43 | + } |
| 44 | +``` |
| 45 | + |
| 46 | +### In Node |
42 | 47 |
|
43 | | -If you `npm install jose` as a dependency, the Webpack'd minified bundle will be |
| 48 | +```js |
| 49 | +const { JWT } = require('@solid/jose') |
| 50 | + |
| 51 | +const decoded = JWT.decode(data) // throws an error if invalid |
| 52 | +``` |
| 53 | + |
| 54 | +### In Browser |
| 55 | + |
| 56 | +If you `npm install @solid/jose` as a dependency, the Webpack'd minified bundle will be |
44 | 57 | available in the `dist/` directory as `jose.min.js`. |
45 | 58 |
|
46 | 59 | If you're actively developing/testing this lib, you can `npm run dist`, and the |
@@ -69,21 +82,15 @@ Sample usage of JOSE lib in a browser. |
69 | 82 | </html> |
70 | 83 | ``` |
71 | 84 |
|
72 | | -## Running tests |
| 85 | +## Testing |
73 | 86 |
|
74 | 87 | ### Nodejs |
75 | 88 |
|
76 | 89 | ```bash |
77 | 90 | $ npm test |
78 | 91 | ``` |
79 | 92 |
|
80 | | -### Browser (karma) |
81 | | - |
82 | | -```bash |
83 | | -$ npm run karma |
84 | | -``` |
85 | | - |
86 | | -## MIT License |
| 93 | +## License |
87 | 94 |
|
88 | 95 | [The MIT License](LICENSE.md) |
89 | 96 |
|
|
0 commit comments