client manager complete, client and client channels next
This commit is contained in:
34
node_modules/jws/CHANGELOG.md
generated
vendored
Normal file
34
node_modules/jws/CHANGELOG.md
generated
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
# Change Log
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
## [3.0.0]
|
||||
### Changed
|
||||
- **BREAKING**: `jwt.verify` now requires an `algorithm` parameter, and
|
||||
`jws.createVerify` requires an `algorithm` option. The `"alg"` field
|
||||
signature headers is ignored. This mitigates a critical security flaw
|
||||
in the library which would allow an attacker to generate signatures with
|
||||
arbitrary contents that would be accepted by `jwt.verify`. See
|
||||
https://auth0.com/blog/2015/03/31/critical-vulnerabilities-in-json-web-token-libraries/
|
||||
for details.
|
||||
|
||||
## [2.0.0] - 2015-01-30
|
||||
### Changed
|
||||
- **BREAKING**: Default payload encoding changed from `binary` to
|
||||
`utf8`. `utf8` is a is a more sensible default than `binary` because
|
||||
many payloads, as far as I can tell, will contain user-facing
|
||||
strings that could be in any language. (<code>[6b6de48]</code>)
|
||||
|
||||
- Code reorganization, thanks [@fearphage]! (<code>[7880050]</code>)
|
||||
|
||||
### Added
|
||||
- Option in all relevant methods for `encoding`. For those few users
|
||||
that might be depending on a `binary` encoding of the messages, this
|
||||
is for them. (<code>[6b6de48]</code>)
|
||||
|
||||
[unreleased]: https://github.com/brianloveswords/node-jws/compare/v2.0.0...HEAD
|
||||
[2.0.0]: https://github.com/brianloveswords/node-jws/compare/v1.0.1...v2.0.0
|
||||
|
||||
[7880050]: https://github.com/brianloveswords/node-jws/commit/7880050
|
||||
[6b6de48]: https://github.com/brianloveswords/node-jws/commit/6b6de48
|
||||
|
||||
[@fearphage]: https://github.com/fearphage
|
17
node_modules/jws/LICENSE
generated
vendored
Normal file
17
node_modules/jws/LICENSE
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
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.
|
22
node_modules/jws/index.js
generated
vendored
Normal file
22
node_modules/jws/index.js
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
/*global exports*/
|
||||
var SignStream = require('./lib/sign-stream');
|
||||
var VerifyStream = require('./lib/verify-stream');
|
||||
|
||||
var ALGORITHMS = [
|
||||
'HS256', 'HS384', 'HS512',
|
||||
'RS256', 'RS384', 'RS512',
|
||||
'PS256', 'PS384', 'PS512',
|
||||
'ES256', 'ES384', 'ES512'
|
||||
];
|
||||
|
||||
exports.ALGORITHMS = ALGORITHMS;
|
||||
exports.sign = SignStream.sign;
|
||||
exports.verify = VerifyStream.verify;
|
||||
exports.decode = VerifyStream.decode;
|
||||
exports.isValid = VerifyStream.isValid;
|
||||
exports.createSign = function createSign(opts) {
|
||||
return new SignStream(opts);
|
||||
};
|
||||
exports.createVerify = function createVerify(opts) {
|
||||
return new VerifyStream(opts);
|
||||
};
|
55
node_modules/jws/lib/data-stream.js
generated
vendored
Normal file
55
node_modules/jws/lib/data-stream.js
generated
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
/*global module, process*/
|
||||
var Buffer = require('safe-buffer').Buffer;
|
||||
var Stream = require('stream');
|
||||
var util = require('util');
|
||||
|
||||
function DataStream(data) {
|
||||
this.buffer = null;
|
||||
this.writable = true;
|
||||
this.readable = true;
|
||||
|
||||
// No input
|
||||
if (!data) {
|
||||
this.buffer = Buffer.alloc(0);
|
||||
return this;
|
||||
}
|
||||
|
||||
// Stream
|
||||
if (typeof data.pipe === 'function') {
|
||||
this.buffer = Buffer.alloc(0);
|
||||
data.pipe(this);
|
||||
return this;
|
||||
}
|
||||
|
||||
// Buffer or String
|
||||
// or Object (assumedly a passworded key)
|
||||
if (data.length || typeof data === 'object') {
|
||||
this.buffer = data;
|
||||
this.writable = false;
|
||||
process.nextTick(function () {
|
||||
this.emit('end', data);
|
||||
this.readable = false;
|
||||
this.emit('close');
|
||||
}.bind(this));
|
||||
return this;
|
||||
}
|
||||
|
||||
throw new TypeError('Unexpected data type ('+ typeof data + ')');
|
||||
}
|
||||
util.inherits(DataStream, Stream);
|
||||
|
||||
DataStream.prototype.write = function write(data) {
|
||||
this.buffer = Buffer.concat([this.buffer, Buffer.from(data)]);
|
||||
this.emit('data', data);
|
||||
};
|
||||
|
||||
DataStream.prototype.end = function end(data) {
|
||||
if (data)
|
||||
this.write(data);
|
||||
this.emit('end', data);
|
||||
this.emit('close');
|
||||
this.writable = false;
|
||||
this.readable = false;
|
||||
};
|
||||
|
||||
module.exports = DataStream;
|
78
node_modules/jws/lib/sign-stream.js
generated
vendored
Normal file
78
node_modules/jws/lib/sign-stream.js
generated
vendored
Normal file
@ -0,0 +1,78 @@
|
||||
/*global module*/
|
||||
var Buffer = require('safe-buffer').Buffer;
|
||||
var DataStream = require('./data-stream');
|
||||
var jwa = require('jwa');
|
||||
var Stream = require('stream');
|
||||
var toString = require('./tostring');
|
||||
var util = require('util');
|
||||
|
||||
function base64url(string, encoding) {
|
||||
return Buffer
|
||||
.from(string, encoding)
|
||||
.toString('base64')
|
||||
.replace(/=/g, '')
|
||||
.replace(/\+/g, '-')
|
||||
.replace(/\//g, '_');
|
||||
}
|
||||
|
||||
function jwsSecuredInput(header, payload, encoding) {
|
||||
encoding = encoding || 'utf8';
|
||||
var encodedHeader = base64url(toString(header), 'binary');
|
||||
var encodedPayload = base64url(toString(payload), encoding);
|
||||
return util.format('%s.%s', encodedHeader, encodedPayload);
|
||||
}
|
||||
|
||||
function jwsSign(opts) {
|
||||
var header = opts.header;
|
||||
var payload = opts.payload;
|
||||
var secretOrKey = opts.secret || opts.privateKey;
|
||||
var encoding = opts.encoding;
|
||||
var algo = jwa(header.alg);
|
||||
var securedInput = jwsSecuredInput(header, payload, encoding);
|
||||
var signature = algo.sign(securedInput, secretOrKey);
|
||||
return util.format('%s.%s', securedInput, signature);
|
||||
}
|
||||
|
||||
function SignStream(opts) {
|
||||
var secret = opts.secret||opts.privateKey||opts.key;
|
||||
var secretStream = new DataStream(secret);
|
||||
this.readable = true;
|
||||
this.header = opts.header;
|
||||
this.encoding = opts.encoding;
|
||||
this.secret = this.privateKey = this.key = secretStream;
|
||||
this.payload = new DataStream(opts.payload);
|
||||
this.secret.once('close', function () {
|
||||
if (!this.payload.writable && this.readable)
|
||||
this.sign();
|
||||
}.bind(this));
|
||||
|
||||
this.payload.once('close', function () {
|
||||
if (!this.secret.writable && this.readable)
|
||||
this.sign();
|
||||
}.bind(this));
|
||||
}
|
||||
util.inherits(SignStream, Stream);
|
||||
|
||||
SignStream.prototype.sign = function sign() {
|
||||
try {
|
||||
var signature = jwsSign({
|
||||
header: this.header,
|
||||
payload: this.payload.buffer,
|
||||
secret: this.secret.buffer,
|
||||
encoding: this.encoding
|
||||
});
|
||||
this.emit('done', signature);
|
||||
this.emit('data', signature);
|
||||
this.emit('end');
|
||||
this.readable = false;
|
||||
return signature;
|
||||
} catch (e) {
|
||||
this.readable = false;
|
||||
this.emit('error', e);
|
||||
this.emit('close');
|
||||
}
|
||||
};
|
||||
|
||||
SignStream.sign = jwsSign;
|
||||
|
||||
module.exports = SignStream;
|
10
node_modules/jws/lib/tostring.js
generated
vendored
Normal file
10
node_modules/jws/lib/tostring.js
generated
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
/*global module*/
|
||||
var Buffer = require('buffer').Buffer;
|
||||
|
||||
module.exports = function toString(obj) {
|
||||
if (typeof obj === 'string')
|
||||
return obj;
|
||||
if (typeof obj === 'number' || Buffer.isBuffer(obj))
|
||||
return obj.toString();
|
||||
return JSON.stringify(obj);
|
||||
};
|
120
node_modules/jws/lib/verify-stream.js
generated
vendored
Normal file
120
node_modules/jws/lib/verify-stream.js
generated
vendored
Normal file
@ -0,0 +1,120 @@
|
||||
/*global module*/
|
||||
var Buffer = require('safe-buffer').Buffer;
|
||||
var DataStream = require('./data-stream');
|
||||
var jwa = require('jwa');
|
||||
var Stream = require('stream');
|
||||
var toString = require('./tostring');
|
||||
var util = require('util');
|
||||
var JWS_REGEX = /^[a-zA-Z0-9\-_]+?\.[a-zA-Z0-9\-_]+?\.([a-zA-Z0-9\-_]+)?$/;
|
||||
|
||||
function isObject(thing) {
|
||||
return Object.prototype.toString.call(thing) === '[object Object]';
|
||||
}
|
||||
|
||||
function safeJsonParse(thing) {
|
||||
if (isObject(thing))
|
||||
return thing;
|
||||
try { return JSON.parse(thing); }
|
||||
catch (e) { return undefined; }
|
||||
}
|
||||
|
||||
function headerFromJWS(jwsSig) {
|
||||
var encodedHeader = jwsSig.split('.', 1)[0];
|
||||
return safeJsonParse(Buffer.from(encodedHeader, 'base64').toString('binary'));
|
||||
}
|
||||
|
||||
function securedInputFromJWS(jwsSig) {
|
||||
return jwsSig.split('.', 2).join('.');
|
||||
}
|
||||
|
||||
function signatureFromJWS(jwsSig) {
|
||||
return jwsSig.split('.')[2];
|
||||
}
|
||||
|
||||
function payloadFromJWS(jwsSig, encoding) {
|
||||
encoding = encoding || 'utf8';
|
||||
var payload = jwsSig.split('.')[1];
|
||||
return Buffer.from(payload, 'base64').toString(encoding);
|
||||
}
|
||||
|
||||
function isValidJws(string) {
|
||||
return JWS_REGEX.test(string) && !!headerFromJWS(string);
|
||||
}
|
||||
|
||||
function jwsVerify(jwsSig, algorithm, secretOrKey) {
|
||||
if (!algorithm) {
|
||||
var err = new Error("Missing algorithm parameter for jws.verify");
|
||||
err.code = "MISSING_ALGORITHM";
|
||||
throw err;
|
||||
}
|
||||
jwsSig = toString(jwsSig);
|
||||
var signature = signatureFromJWS(jwsSig);
|
||||
var securedInput = securedInputFromJWS(jwsSig);
|
||||
var algo = jwa(algorithm);
|
||||
return algo.verify(securedInput, signature, secretOrKey);
|
||||
}
|
||||
|
||||
function jwsDecode(jwsSig, opts) {
|
||||
opts = opts || {};
|
||||
jwsSig = toString(jwsSig);
|
||||
|
||||
if (!isValidJws(jwsSig))
|
||||
return null;
|
||||
|
||||
var header = headerFromJWS(jwsSig);
|
||||
|
||||
if (!header)
|
||||
return null;
|
||||
|
||||
var payload = payloadFromJWS(jwsSig);
|
||||
if (header.typ === 'JWT' || opts.json)
|
||||
payload = JSON.parse(payload, opts.encoding);
|
||||
|
||||
return {
|
||||
header: header,
|
||||
payload: payload,
|
||||
signature: signatureFromJWS(jwsSig)
|
||||
};
|
||||
}
|
||||
|
||||
function VerifyStream(opts) {
|
||||
opts = opts || {};
|
||||
var secretOrKey = opts.secret||opts.publicKey||opts.key;
|
||||
var secretStream = new DataStream(secretOrKey);
|
||||
this.readable = true;
|
||||
this.algorithm = opts.algorithm;
|
||||
this.encoding = opts.encoding;
|
||||
this.secret = this.publicKey = this.key = secretStream;
|
||||
this.signature = new DataStream(opts.signature);
|
||||
this.secret.once('close', function () {
|
||||
if (!this.signature.writable && this.readable)
|
||||
this.verify();
|
||||
}.bind(this));
|
||||
|
||||
this.signature.once('close', function () {
|
||||
if (!this.secret.writable && this.readable)
|
||||
this.verify();
|
||||
}.bind(this));
|
||||
}
|
||||
util.inherits(VerifyStream, Stream);
|
||||
VerifyStream.prototype.verify = function verify() {
|
||||
try {
|
||||
var valid = jwsVerify(this.signature.buffer, this.algorithm, this.key.buffer);
|
||||
var obj = jwsDecode(this.signature.buffer, this.encoding);
|
||||
this.emit('done', valid, obj);
|
||||
this.emit('data', valid);
|
||||
this.emit('end');
|
||||
this.readable = false;
|
||||
return valid;
|
||||
} catch (e) {
|
||||
this.readable = false;
|
||||
this.emit('error', e);
|
||||
this.emit('close');
|
||||
}
|
||||
};
|
||||
|
||||
VerifyStream.decode = jwsDecode;
|
||||
VerifyStream.isValid = isValidJws;
|
||||
VerifyStream.verify = jwsVerify;
|
||||
|
||||
module.exports = VerifyStream;
|
64
node_modules/jws/package.json
generated
vendored
Normal file
64
node_modules/jws/package.json
generated
vendored
Normal file
@ -0,0 +1,64 @@
|
||||
{
|
||||
"_from": "jws@^3.2.1",
|
||||
"_id": "jws@3.2.1",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-bGA2omSrFUkd72dhh05bIAN832znP4wOU3lfuXtRBuGTbsmNmDXMQg28f0Vsxaxgk4myF5YkKQpz6qeRpMgX9g==",
|
||||
"_location": "/jws",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "jws@^3.2.1",
|
||||
"name": "jws",
|
||||
"escapedName": "jws",
|
||||
"rawSpec": "^3.2.1",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^3.2.1"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/jsonwebtoken"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/jws/-/jws-3.2.1.tgz",
|
||||
"_shasum": "d79d4216a62c9afa0a3d5e8b5356d75abdeb2be5",
|
||||
"_spec": "jws@^3.2.1",
|
||||
"_where": "/Users/josh.burman/Projects/braid/node_modules/jsonwebtoken",
|
||||
"author": {
|
||||
"name": "Brian J Brennan"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/brianloveswords/node-jws/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"jwa": "^1.2.0",
|
||||
"safe-buffer": "^5.0.1"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Implementation of JSON Web Signatures",
|
||||
"devDependencies": {
|
||||
"semver": "^5.1.0",
|
||||
"tape": "~2.14.0"
|
||||
},
|
||||
"directories": {
|
||||
"test": "test"
|
||||
},
|
||||
"gitHead": "c0f6b27bcea5a2ad2e304d91c2e842e4076a6b03",
|
||||
"homepage": "https://github.com/brianloveswords/node-jws#readme",
|
||||
"keywords": [
|
||||
"jws",
|
||||
"json",
|
||||
"web",
|
||||
"signatures"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"name": "jws",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/brianloveswords/node-jws.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "make test"
|
||||
},
|
||||
"version": "3.2.1"
|
||||
}
|
255
node_modules/jws/readme.md
generated
vendored
Normal file
255
node_modules/jws/readme.md
generated
vendored
Normal file
@ -0,0 +1,255 @@
|
||||
# node-jws [](http://travis-ci.org/brianloveswords/node-jws)
|
||||
|
||||
An implementation of [JSON Web Signatures](http://self-issued.info/docs/draft-ietf-jose-json-web-signature.html).
|
||||
|
||||
This was developed against `draft-ietf-jose-json-web-signature-08` and
|
||||
implements the entire spec **except** X.509 Certificate Chain
|
||||
signing/verifying (patches welcome).
|
||||
|
||||
There are both synchronous (`jws.sign`, `jws.verify`) and streaming
|
||||
(`jws.createSign`, `jws.createVerify`) APIs.
|
||||
|
||||
# Install
|
||||
|
||||
```bash
|
||||
$ npm install jws
|
||||
```
|
||||
|
||||
# Usage
|
||||
|
||||
## jws.ALGORITHMS
|
||||
|
||||
Array of supported algorithms. The following algorithms are currently supported.
|
||||
|
||||
alg Parameter Value | Digital Signature or MAC Algorithm
|
||||
----------------|----------------------------
|
||||
HS256 | HMAC using SHA-256 hash algorithm
|
||||
HS384 | HMAC using SHA-384 hash algorithm
|
||||
HS512 | HMAC using SHA-512 hash algorithm
|
||||
RS256 | RSASSA using SHA-256 hash algorithm
|
||||
RS384 | RSASSA using SHA-384 hash algorithm
|
||||
RS512 | RSASSA using SHA-512 hash algorithm
|
||||
PS256 | RSASSA-PSS using SHA-256 hash algorithm
|
||||
PS384 | RSASSA-PSS using SHA-384 hash algorithm
|
||||
PS512 | RSASSA-PSS using SHA-512 hash algorithm
|
||||
ES256 | ECDSA using P-256 curve and SHA-256 hash algorithm
|
||||
ES384 | ECDSA using P-384 curve and SHA-384 hash algorithm
|
||||
ES512 | ECDSA using P-521 curve and SHA-512 hash algorithm
|
||||
none | No digital signature or MAC value included
|
||||
|
||||
## jws.sign(options)
|
||||
|
||||
(Synchronous) Return a JSON Web Signature for a header and a payload.
|
||||
|
||||
Options:
|
||||
|
||||
* `header`
|
||||
* `payload`
|
||||
* `secret` or `privateKey`
|
||||
* `encoding` (Optional, defaults to 'utf8')
|
||||
|
||||
`header` must be an object with an `alg` property. `header.alg` must be
|
||||
one a value found in `jws.ALGORITHMS`. See above for a table of
|
||||
supported algorithms.
|
||||
|
||||
If `payload` is not a buffer or a string, it will be coerced into a string
|
||||
using `JSON.stringify`.
|
||||
|
||||
Example
|
||||
|
||||
```js
|
||||
const signature = jws.sign({
|
||||
header: { alg: 'HS256' },
|
||||
payload: 'h. jon benjamin',
|
||||
secret: 'has a van',
|
||||
});
|
||||
```
|
||||
|
||||
## jws.verify(signature, algorithm, secretOrKey)
|
||||
|
||||
(Synchronous) Returns `true` or `false` for whether a signature matches a
|
||||
secret or key.
|
||||
|
||||
`signature` is a JWS Signature. `header.alg` must be a value found in `jws.ALGORITHMS`.
|
||||
See above for a table of supported algorithms. `secretOrKey` is a string or
|
||||
buffer containing either the secret for HMAC algorithms, or the PEM
|
||||
encoded public key for RSA and ECDSA.
|
||||
|
||||
Note that the `"alg"` value from the signature header is ignored.
|
||||
|
||||
|
||||
## jws.decode(signature)
|
||||
|
||||
(Synchronous) Returns the decoded header, decoded payload, and signature
|
||||
parts of the JWS Signature.
|
||||
|
||||
Returns an object with three properties, e.g.
|
||||
```js
|
||||
{ header: { alg: 'HS256' },
|
||||
payload: 'h. jon benjamin',
|
||||
signature: 'YOWPewyGHKu4Y_0M_vtlEnNlqmFOclqp4Hy6hVHfFT4'
|
||||
}
|
||||
```
|
||||
|
||||
## jws.createSign(options)
|
||||
|
||||
Returns a new SignStream object.
|
||||
|
||||
Options:
|
||||
|
||||
* `header` (required)
|
||||
* `payload`
|
||||
* `key` || `privateKey` || `secret`
|
||||
* `encoding` (Optional, defaults to 'utf8')
|
||||
|
||||
Other than `header`, all options expect a string or a buffer when the
|
||||
value is known ahead of time, or a stream for convenience.
|
||||
`key`/`privateKey`/`secret` may also be an object when using an encrypted
|
||||
private key, see the [crypto documentation][encrypted-key-docs].
|
||||
|
||||
Example:
|
||||
|
||||
```js
|
||||
|
||||
// This...
|
||||
jws.createSign({
|
||||
header: { alg: 'RS256' },
|
||||
privateKey: privateKeyStream,
|
||||
payload: payloadStream,
|
||||
}).on('done', function(signature) {
|
||||
// ...
|
||||
});
|
||||
|
||||
// is equivalent to this:
|
||||
const signer = jws.createSign({
|
||||
header: { alg: 'RS256' },
|
||||
});
|
||||
privateKeyStream.pipe(signer.privateKey);
|
||||
payloadStream.pipe(signer.payload);
|
||||
signer.on('done', function(signature) {
|
||||
// ...
|
||||
});
|
||||
```
|
||||
|
||||
## jws.createVerify(options)
|
||||
|
||||
Returns a new VerifyStream object.
|
||||
|
||||
Options:
|
||||
|
||||
* `signature`
|
||||
* `algorithm`
|
||||
* `key` || `publicKey` || `secret`
|
||||
* `encoding` (Optional, defaults to 'utf8')
|
||||
|
||||
All options expect a string or a buffer when the value is known ahead of
|
||||
time, or a stream for convenience.
|
||||
|
||||
Example:
|
||||
|
||||
```js
|
||||
|
||||
// This...
|
||||
jws.createVerify({
|
||||
publicKey: pubKeyStream,
|
||||
signature: sigStream,
|
||||
}).on('done', function(verified, obj) {
|
||||
// ...
|
||||
});
|
||||
|
||||
// is equivilant to this:
|
||||
const verifier = jws.createVerify();
|
||||
pubKeyStream.pipe(verifier.publicKey);
|
||||
sigStream.pipe(verifier.signature);
|
||||
verifier.on('done', function(verified, obj) {
|
||||
// ...
|
||||
});
|
||||
```
|
||||
|
||||
## Class: SignStream
|
||||
|
||||
A `Readable Stream` that emits a single data event (the calculated
|
||||
signature) when done.
|
||||
|
||||
### Event: 'done'
|
||||
`function (signature) { }`
|
||||
|
||||
### signer.payload
|
||||
|
||||
A `Writable Stream` that expects the JWS payload. Do *not* use if you
|
||||
passed a `payload` option to the constructor.
|
||||
|
||||
Example:
|
||||
|
||||
```js
|
||||
payloadStream.pipe(signer.payload);
|
||||
```
|
||||
|
||||
### signer.secret<br>signer.key<br>signer.privateKey
|
||||
|
||||
A `Writable Stream`. Expects the JWS secret for HMAC, or the privateKey
|
||||
for ECDSA and RSA. Do *not* use if you passed a `secret` or `key` option
|
||||
to the constructor.
|
||||
|
||||
Example:
|
||||
|
||||
```js
|
||||
privateKeyStream.pipe(signer.privateKey);
|
||||
```
|
||||
|
||||
## Class: VerifyStream
|
||||
|
||||
This is a `Readable Stream` that emits a single data event, the result
|
||||
of whether or not that signature was valid.
|
||||
|
||||
### Event: 'done'
|
||||
`function (valid, obj) { }`
|
||||
|
||||
`valid` is a boolean for whether or not the signature is valid.
|
||||
|
||||
### verifier.signature
|
||||
|
||||
A `Writable Stream` that expects a JWS Signature. Do *not* use if you
|
||||
passed a `signature` option to the constructor.
|
||||
|
||||
### verifier.secret<br>verifier.key<br>verifier.publicKey
|
||||
|
||||
A `Writable Stream` that expects a public key or secret. Do *not* use if you
|
||||
passed a `key` or `secret` option to the constructor.
|
||||
|
||||
# TODO
|
||||
|
||||
* It feels like there should be some convenience options/APIs for
|
||||
defining the algorithm rather than having to define a header object
|
||||
with `{ alg: 'ES512' }` or whatever every time.
|
||||
|
||||
* X.509 support, ugh
|
||||
|
||||
# License
|
||||
|
||||
MIT
|
||||
|
||||
```
|
||||
Copyright (c) 2013-2015 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.
|
||||
```
|
||||
|
||||
[encrypted-key-docs]: https://nodejs.org/api/crypto.html#crypto_sign_sign_private_key_output_format
|
Reference in New Issue
Block a user