forked from auth0/node-jws
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c3d1df9
commit 4cb0187
Showing
13 changed files
with
288 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
language: node_js | ||
node_js: | ||
- 0.8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,58 @@ | ||
node-jws, yo. | ||
# jws [](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 | ||
$ 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, | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
-----BEGIN EC PARAMETERS----- | ||
BgUrgQQACg== | ||
-----END EC PARAMETERS----- | ||
-----BEGIN EC PRIVATE KEY----- | ||
MHQCAQEEIJKbXYfNZzcs7xexXrM3/DY+yABygm3A5nur4H0g2/rRoAcGBSuBBAAK | ||
oUQDQgAEj9p6YO3mW9FiYE3lrEk2oU0g/VXHFuacPexa9GklzNjxdrfceU092nNW | ||
s1Fums+ml2TZSYyA/AQYC/4qlWYDWg== | ||
-----END EC PRIVATE KEY----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
-----BEGIN PUBLIC KEY----- | ||
MFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAEj9p6YO3mW9FiYE3lrEk2oU0g/VXHFuac | ||
Pexa9GklzNjxdrfceU092nNWs1Fums+ml2TZSYyA/AQYC/4qlWYDWg== | ||
-----END PUBLIC KEY----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
-----BEGIN EC PARAMETERS----- | ||
BgUrgQQACg== | ||
-----END EC PARAMETERS----- | ||
-----BEGIN EC PRIVATE KEY----- | ||
MHQCAQEEIAdHMdUXIawPq+15ejwcWWNQQalEW0zP9uC+4tr4s79JoAcGBSuBBAAK | ||
oUQDQgAEBOsRG0YUg9lrFlNF4WUwHkEbntU6ZK4xdJcPf5nctm2gUWSL8J/nLSiR | ||
YZbah8/0x4OfMSuHv1OEVrG8fRhTOg== | ||
-----END EC PRIVATE KEY----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
-----BEGIN PUBLIC KEY----- | ||
MFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAEBOsRG0YUg9lrFlNF4WUwHkEbntU6ZK4x | ||
dJcPf5nctm2gUWSL8J/nLSiRYZbah8/0x4OfMSuHv1OEVrG8fRhTOg== | ||
-----END PUBLIC KEY----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
-----BEGIN RSA PRIVATE KEY----- | ||
MIIEpQIBAAKCAQEAvi9OEYO2+J8PK+rSeB79b59Fy4w3idjZS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8FS8pu+gdguh/H5AoGAf50gQt6j4r+TVtO8Cywb | ||
aAtT4lM09Q2km0S2/8yncbRe8I7ncRPcK4M2EF8Puyu3r4b1JQKW/b+b0rIMRuzo | ||
wNiyvVVpl4FHElsHYshD8Udkj4ag+yyLnFg9xAvgGl1A1dwj7XIc6ZBQ80nGL+ov | ||
e9+LL33iteDtAJ+5demsSVECgYEAlMYiPnuDSNK7GFEem4DUeFwVVANHFa1TXyXf | ||
ZkQqpRhSbXezBWYMSMpjoAfjVsPxqNgcJeE8WxURxpxdsg9NmZbwwHTWyhQb600G | ||
1MwFue+htZ+RWpFjauQkR3zEedfLlUDHdw7duSuFMhqzVNmNkYAHdklxEWESKpCy | ||
EYbhZikCgYEAiNHDBz58sUIqV7awhBzu/9PY4bdOcuZtqNN3iPd/Yt3Sb7Gf4X3d | ||
OC8+9kOVq4wvBTNnBPeXokeNkw8HS7nOG8EmtgpzVqXiXla8gTGYekmqULWJ+Kz7 | ||
MFRQ0zS2zeZHWTDbRu6f70UUTA7sjEXu9yqrxW2mtTMyGc0+VQLMYMY= | ||
-----END RSA PRIVATE KEY----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
-----BEGIN PUBLIC KEY----- | ||
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvi9OEYO2+J8PK+rSeB79 | ||
b59Fy4w3idjZS1ZdFd/UZXyhcJuH6eCBvsui59Ykx6OZg6tcBH9dpjDPKP5Qz7Du | ||
rFwQ7rayJDE7jd7L/JUCTE2SsnHg7LlDGvhJa36E26epOcAj5VJMCOnadU2qyhNN | ||
r1Rkq7raR2sJLOF3hTGvO44KuloKThVwVqZoD/AXiga0EaR8Lrx6q7s10aFUp0zT | ||
fuq0ScZSbH8Mx8L/OtzC5Gr6LogdvVjpJlVgPZ9jOWElSaJpwmaRA4I3HZD/zhrH | ||
zbqHUPQYdv4tzQdrSFIFXysfBT6uXJ9DvSm06Akj9SdzW2LUSxLBDA/oXdF+J4s8 | ||
vQIDAQAB | ||
-----END PUBLIC KEY----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
-----BEGIN RSA PRIVATE KEY----- | ||
MIIEowIBAAKCAQEAzTixT/ku5mPESvklY7wnqKKG/YVlRGY9itb/bLRW7ebUXBvV | ||
aOnAitmjlNSJdzcrkUgsJbvJuWzqlBSG2Z6BbSPiYgheSf4n8Hj8u+hUYsDXU8wq | ||
eF38I1zIXwOMWCRim4UuKrS7jWN3NaBeL5ypQ7qHHLvT/puwDCIfu4dXAFEAbOad | ||
HW63fEuXkSJK+pTavgzaHBs0u9Nl5U2xcofsOuaRyo7QKQr7TJDu8PBNIh3oy+I8 | ||
wxLmlSGoCLM2vVKEL9ThXO5EaPI8Oe4bHOIUF5n/nbXxDj96Ot6MlQ8LaKk52/Ti | ||
vnrR+fz7o2azMZkcDrT0y1MJIscoduitN5iywwIDAQABAoIBAE9jBvRw6HunTF/U | ||
UWprdsv9U0rvN2VmR5hV4ykh+h69lJitC7kx85HC70y7ixHa/beNu8Y9BqP8RiJS | ||
bnfwoRCfOQvDQPZOoxSbOOlXzo0FHEcGS8eUU906HyjiLoBKUvrmYh2THJptR8gu | ||
6UBx0eipV2r+Hdv4TfnjmXLpv/YWrYK9VKfQlh93nTtXX9/6/usF9JK6uumL7hh7 | ||
fai22O30dPF5Z1eEVLgb0mDW+s8LhpftN9MkozkQiTLfHZ9rkG2oblhfcQDU50eA | ||
7AtGw+nKvHEESnSp9CjGYjMlvX7gpCfUXbOKZ3FgoQQ3eRvLYm6ph7hJb2S34zGF | ||
j0qmNoECgYEA+3Z09zohtYxp0OQVBHSOLFwV7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