Skip to content

Commit

Permalink
Strip readme for now.
Browse files Browse the repository at this point in the history
  • Loading branch information
brianloveswords committed Feb 10, 2013
1 parent f480ca4 commit 16ac936
Showing 1 changed file with 22 additions and 47 deletions.
69 changes: 22 additions & 47 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,5 @@
# jws [![Build Status](https://secure.travis-ci.org/brianloveswords/node-jws.png)](http://travis-ci.org/brianloveswords/node-jws)

[JSON Web Signatures](http://self-issued.info/docs/draft-ietf-jose-json-web-signature.html)
for node.

This was implemented against `draft-ietf-jose-json-web-signature-08`.

The following algorithms are supported:
* HMAC SHA-256 (HS256)
* RSA SHA-256 (RS256)

We yet support ECDSA yet (ES256/384/512) because OpenSSL doesn't support
it as a message digest algorithm (it only supports `ecdsa-with-sha1`)
which means we can't load it with `crypto.createSign` or
`crypto.createVerify`. Hopefully this is forthcoming.

# install

```js
Expand All @@ -22,37 +8,26 @@ $ npm install jws

# example

```js
const jws = require('jws');

// By default we use HMAC SHA-256
var payload = 'everybody dance NOW.';
var secret = 'supersecrettech';
var jwsObject = jws.sign(payload, secret);

jws.verify(jwsObject, secret) // === true
jws.verify(jwsObject, 'hax') // === false

// If the `secret` is a RSA key, it will figure that out and sign it appropriately.
var privateKey = fs.readFileSync(process.env.HOME + '/.ssh/id_rsa');
var publicKey = fs.readFileSync(process.env.HOME + '/.ssh/id_rsa.pub');
var jwsObject = jws.sign(payload, privateKey);

jws.verify(jwsObject, publicKey) // === true

// By default, the header will just include the algorithm detected by
// the secret or key. If you want to add more info the the header, you
// can do so explicitly.

var jwsHmacObject = jws.sign({
header: { alg: 'HS256', typ: 'JWT' },
payload: payload,
secret: secret,
});

var jwsRsaSignedObject = jws.sign({
header: { alg: 'RS256', typ: 'Ham+Cheese' },
payload: payload,
key: privateKey,
});
# license

MIT

```
Copyright (c) 2013 Brian J. Brennan
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
```

0 comments on commit 16ac936

Please sign in to comment.