mirror of
https://github.com/atlanticbiomedical/biomedjs.git
synced 2025-07-02 00:47:26 -04:00
Deps updates
This commit is contained in:
3
node_modules/jwt-simple/.npmignore
generated
vendored
Normal file
3
node_modules/jwt-simple/.npmignore
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
.vimrc*
|
||||
.git*
|
||||
.travis.yml
|
11
node_modules/jwt-simple/History.md
generated
vendored
Normal file
11
node_modules/jwt-simple/History.md
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
## 0.3.1
|
||||
|
||||
* Check for lack of token #23
|
||||
|
||||
## 0.3.0
|
||||
|
||||
* Add an algorithm parameter to the decode method #16 @gregorypratt
|
||||
|
||||
## 0.2.0
|
||||
|
||||
* Add the RS256 alg #7 [thedufer]
|
22
node_modules/jwt-simple/LICENSE
generated
vendored
Normal file
22
node_modules/jwt-simple/LICENSE
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2011 Kazuhito Hokamura <k.hokamura@gmail.com>
|
||||
|
||||
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.
|
33
node_modules/jwt-simple/README.md
generated
vendored
Normal file
33
node_modules/jwt-simple/README.md
generated
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
# node-jwt-simple
|
||||
|
||||
[JWT(JSON Web Token)](http://self-issued.info/docs/draft-jones-json-web-token.html) encode and decode module for node.js.
|
||||
|
||||
## Install
|
||||
|
||||
$ npm install jwt-simple
|
||||
|
||||
## Usage
|
||||
|
||||
```javascript
|
||||
var jwt = require('jwt-simple');
|
||||
var payload = { foo: 'bar' };
|
||||
var secret = 'xxx';
|
||||
|
||||
// encode
|
||||
var token = jwt.encode(payload, secret);
|
||||
|
||||
// decode
|
||||
var decoded = jwt.decode(token, secret);
|
||||
console.log(decoded); //=> { foo: 'bar' }
|
||||
```
|
||||
|
||||
### Algorithms
|
||||
|
||||
By default the algorithm to encode is `HS256`.
|
||||
|
||||
The supported algorithms for encoding and decoding are `HS256`, `HS384`, `HS512` and `RS256`.
|
||||
|
||||
```javascript
|
||||
// encode using HS512
|
||||
jwt.encode(payload, secret, 'HS512')
|
||||
```
|
1
node_modules/jwt-simple/index.js
generated
vendored
Normal file
1
node_modules/jwt-simple/index.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
module.exports = require('./lib/jwt');
|
183
node_modules/jwt-simple/lib/jwt.js
generated
vendored
Normal file
183
node_modules/jwt-simple/lib/jwt.js
generated
vendored
Normal file
@ -0,0 +1,183 @@
|
||||
/*
|
||||
* jwt-simple
|
||||
*
|
||||
* JSON Web Token encode and decode module for node.js
|
||||
*
|
||||
* Copyright(c) 2011 Kazuhito Hokamura
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* module dependencies
|
||||
*/
|
||||
var crypto = require('crypto');
|
||||
|
||||
|
||||
/**
|
||||
* support algorithm mapping
|
||||
*/
|
||||
var algorithmMap = {
|
||||
HS256: 'sha256',
|
||||
HS384: 'sha384',
|
||||
HS512: 'sha512',
|
||||
RS256: 'RSA-SHA256'
|
||||
};
|
||||
|
||||
/**
|
||||
* Map algorithm to hmac or sign type, to determine which crypto function to use
|
||||
*/
|
||||
var typeMap = {
|
||||
HS256: 'hmac',
|
||||
HS384: 'hmac',
|
||||
HS512: 'hmac',
|
||||
RS256: 'sign'
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* expose object
|
||||
*/
|
||||
var jwt = module.exports;
|
||||
|
||||
|
||||
/**
|
||||
* version
|
||||
*/
|
||||
jwt.version = '0.2.0';
|
||||
|
||||
/**
|
||||
* Decode jwt
|
||||
*
|
||||
* @param {Object} token
|
||||
* @param {String} key
|
||||
* @param {Boolean} noVerify
|
||||
* @param {String} algorithm
|
||||
* @return {Object} payload
|
||||
* @api public
|
||||
*/
|
||||
jwt.decode = function jwt_decode(token, key, noVerify, algorithm) {
|
||||
// check token
|
||||
if (!token) {
|
||||
throw new Error('No token supplied');
|
||||
}
|
||||
// check segments
|
||||
var segments = token.split('.');
|
||||
if (segments.length !== 3) {
|
||||
throw new Error('Not enough or too many segments');
|
||||
}
|
||||
|
||||
// All segment should be base64
|
||||
var headerSeg = segments[0];
|
||||
var payloadSeg = segments[1];
|
||||
var signatureSeg = segments[2];
|
||||
|
||||
// base64 decode and parse JSON
|
||||
var header = JSON.parse(base64urlDecode(headerSeg));
|
||||
var payload = JSON.parse(base64urlDecode(payloadSeg));
|
||||
|
||||
if (!noVerify) {
|
||||
var signingMethod = algorithmMap[algorithm || header.alg];
|
||||
var signingType = typeMap[algorithm || header.alg];
|
||||
if (!signingMethod || !signingType) {
|
||||
throw new Error('Algorithm not supported');
|
||||
}
|
||||
|
||||
// verify signature. `sign` will return base64 string.
|
||||
var signingInput = [headerSeg, payloadSeg].join('.');
|
||||
if (!verify(signingInput, key, signingMethod, signingType, signatureSeg)) {
|
||||
throw new Error('Signature verification failed');
|
||||
}
|
||||
}
|
||||
|
||||
return payload;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Encode jwt
|
||||
*
|
||||
* @param {Object} payload
|
||||
* @param {String} key
|
||||
* @param {String} algorithm
|
||||
* @return {String} token
|
||||
* @api public
|
||||
*/
|
||||
jwt.encode = function jwt_encode(payload, key, algorithm) {
|
||||
// Check key
|
||||
if (!key) {
|
||||
throw new Error('Require key');
|
||||
}
|
||||
|
||||
// Check algorithm, default is HS256
|
||||
if (!algorithm) {
|
||||
algorithm = 'HS256';
|
||||
}
|
||||
|
||||
var signingMethod = algorithmMap[algorithm];
|
||||
var signingType = typeMap[algorithm];
|
||||
if (!signingMethod || !signingType) {
|
||||
throw new Error('Algorithm not supported');
|
||||
}
|
||||
|
||||
// header, typ is fixed value.
|
||||
var header = { typ: 'JWT', alg: algorithm };
|
||||
|
||||
// create segments, all segments should be base64 string
|
||||
var segments = [];
|
||||
segments.push(base64urlEncode(JSON.stringify(header)));
|
||||
segments.push(base64urlEncode(JSON.stringify(payload)));
|
||||
segments.push(sign(segments.join('.'), key, signingMethod, signingType));
|
||||
|
||||
return segments.join('.');
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* private util functions
|
||||
*/
|
||||
|
||||
function verify(input, key, method, type, signature) {
|
||||
if(type === "hmac") {
|
||||
return (signature === sign(input, key, method, type));
|
||||
}
|
||||
else if(type == "sign") {
|
||||
return crypto.createVerify(method)
|
||||
.update(input)
|
||||
.verify(key, base64urlUnescape(signature), 'base64');
|
||||
}
|
||||
else {
|
||||
throw new Error('Algorithm type not recognized');
|
||||
}
|
||||
}
|
||||
|
||||
function sign(input, key, method, type) {
|
||||
var base64str;
|
||||
if(type === "hmac") {
|
||||
base64str = crypto.createHmac(method, key).update(input).digest('base64');
|
||||
}
|
||||
else if(type == "sign") {
|
||||
base64str = crypto.createSign(method).update(input).sign(key, 'base64');
|
||||
}
|
||||
else {
|
||||
throw new Error('Algorithm type not recognized');
|
||||
}
|
||||
|
||||
return base64urlEscape(base64str);
|
||||
}
|
||||
|
||||
function base64urlDecode(str) {
|
||||
return new Buffer(base64urlUnescape(str), 'base64').toString();
|
||||
}
|
||||
|
||||
function base64urlUnescape(str) {
|
||||
str += new Array(5 - str.length % 4).join('=');
|
||||
return str.replace(/\-/g, '+').replace(/_/g, '/');
|
||||
}
|
||||
|
||||
function base64urlEncode(str) {
|
||||
return base64urlEscape(new Buffer(str).toString('base64'));
|
||||
}
|
||||
|
||||
function base64urlEscape(str) {
|
||||
return str.replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, '');
|
||||
}
|
57
node_modules/jwt-simple/package.json
generated
vendored
Normal file
57
node_modules/jwt-simple/package.json
generated
vendored
Normal file
@ -0,0 +1,57 @@
|
||||
{
|
||||
"name": "jwt-simple",
|
||||
"description": "JWT(JSON Web Token) encode and decode module",
|
||||
"version": "0.3.1",
|
||||
"author": {
|
||||
"name": "Kazuhito Hokamura",
|
||||
"email": "k.hokamura@gmail.com"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+ssh://git@github.com/hokaccha/node-jwt-simple.git"
|
||||
},
|
||||
"devDependencies": {
|
||||
"mocha": "*",
|
||||
"expect.js": "*"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha test/*.js"
|
||||
},
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.4.0"
|
||||
},
|
||||
"keywords": [
|
||||
"jwt",
|
||||
"encode",
|
||||
"decode"
|
||||
],
|
||||
"main": "./index",
|
||||
"gitHead": "8367ebca9379efa3116e57702ecc48bdeedd9841",
|
||||
"bugs": {
|
||||
"url": "https://github.com/hokaccha/node-jwt-simple/issues"
|
||||
},
|
||||
"homepage": "https://github.com/hokaccha/node-jwt-simple#readme",
|
||||
"_id": "jwt-simple@0.3.1",
|
||||
"_shasum": "86e0b121d149534423dbd8044a727e3cf1eb939e",
|
||||
"_from": "jwt-simple@*",
|
||||
"_npmVersion": "2.11.0",
|
||||
"_nodeVersion": "0.10.33",
|
||||
"_npmUser": {
|
||||
"name": "hokaccha",
|
||||
"email": "k.hokamura@gmail.com"
|
||||
},
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "hokaccha",
|
||||
"email": "k.hokamura@gmail.com"
|
||||
}
|
||||
],
|
||||
"dist": {
|
||||
"shasum": "86e0b121d149534423dbd8044a727e3cf1eb939e",
|
||||
"tarball": "http://registry.npmjs.org/jwt-simple/-/jwt-simple-0.3.1.tgz"
|
||||
},
|
||||
"directories": {},
|
||||
"_resolved": "https://registry.npmjs.org/jwt-simple/-/jwt-simple-0.3.1.tgz",
|
||||
"readme": "ERROR: No README data found!"
|
||||
}
|
67
node_modules/jwt-simple/test/basic.js
generated
vendored
Normal file
67
node_modules/jwt-simple/test/basic.js
generated
vendored
Normal file
@ -0,0 +1,67 @@
|
||||
var jwt = require('../index');
|
||||
var expect = require('expect.js');
|
||||
var fs = require('fs');
|
||||
|
||||
describe('method and property', function() {
|
||||
it('jwt has version property', function() {
|
||||
expect(jwt.version).to.be.a('string');
|
||||
});
|
||||
|
||||
it('jwt has encode and decode method', function() {
|
||||
expect(jwt.encode).to.be.a('function');
|
||||
expect(jwt.decode).to.be.a('function');
|
||||
});
|
||||
});
|
||||
|
||||
describe('encode and decode', function() {
|
||||
it('encode token', function() {
|
||||
var token = jwt.encode({ foo: 'bar' }, 'key');
|
||||
expect(token).to.be.a('string');
|
||||
expect(token.split('.')).to.have.length(3);
|
||||
});
|
||||
|
||||
it('key is required', function() {
|
||||
var fn = jwt.encode.bind(null, { foo: 'bar' });
|
||||
expect(fn).to.throwException();
|
||||
});
|
||||
|
||||
it('decode token', function() {
|
||||
var obj = { foo: 'bar' };
|
||||
var key = 'key';
|
||||
var token = jwt.encode(obj, key);
|
||||
var obj2 = jwt.decode(token, key);
|
||||
expect(obj2).to.eql(obj);
|
||||
expect(jwt.decode.bind(null, token, 'invalid_key')).to.throwException();
|
||||
});
|
||||
|
||||
it('decode no verify', function() {
|
||||
var obj = { foo: 'bar' };
|
||||
var key = 'key';
|
||||
var token = jwt.encode(obj, key);
|
||||
var fn1 = jwt.decode.bind(null, token, null);
|
||||
var fn2 = jwt.decode.bind(null, token, null, true);
|
||||
expect(fn1).to.throwException();
|
||||
expect(fn2()).to.eql(obj);
|
||||
});
|
||||
|
||||
it('decode token given algorithm', function() {
|
||||
var obj = { foo: 'bar' };
|
||||
var key = 'key';
|
||||
var token = jwt.encode(obj, key, 'HS512');
|
||||
var obj2 = jwt.decode(token, key, false, 'HS512');
|
||||
expect(obj2).to.eql(obj);
|
||||
expect(jwt.decode.bind(null, token, key, false, 'HS256')).to.throwException();
|
||||
expect(jwt.decode.bind(null, token, 'invalid_key')).to.throwException();
|
||||
});
|
||||
|
||||
it('RS256', function() {
|
||||
var obj = { foo: 'bar' };
|
||||
var pem = fs.readFileSync(__dirname + '/test.pem').toString('ascii');
|
||||
var cert = fs.readFileSync(__dirname + '/test.crt').toString('ascii');
|
||||
var alg = 'RS256';
|
||||
var token = jwt.encode(obj, pem, alg);
|
||||
var obj2 = jwt.decode(token, cert);
|
||||
expect(obj2).to.eql(obj);
|
||||
expect(jwt.decode.bind(null, token, 'invalid_key')).to.throwException();
|
||||
});
|
||||
});
|
13
node_modules/jwt-simple/test/test.crt
generated
vendored
Normal file
13
node_modules/jwt-simple/test/test.crt
generated
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIICATCCAWoCCQDoLzF89AVR9jANBgkqhkiG9w0BAQUFADBFMQswCQYDVQQGEwJB
|
||||
VTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0
|
||||
cyBQdHkgTHRkMB4XDTE0MDMxODA5MzgzOVoXDTE1MDMxODA5MzgzOVowRTELMAkG
|
||||
A1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNVBAoTGEludGVybmV0
|
||||
IFdpZGdpdHMgUHR5IEx0ZDCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAxkf+
|
||||
aQuof/FiI1ejRl/385JhGbOq9ZUD0Ma7FELpkW+Wb9k3dxFRXjIeZgbMr5kUtzGv
|
||||
jMA+IJpMPmqHOLMUG731xxmXoHphlhWKV1TTR8OXduIxRB+frVhYfp0nOAZroO+5
|
||||
sXBrGwCcFFjsDBhLLf7R1d9WdkS/LQ0rBi7GvaMCAwEAATANBgkqhkiG9w0BAQUF
|
||||
AAOBgQCNxfthoxLOFZidvviG6aFjFgY35eFqv3RLHWAVBWQBHfjczph/r5mlT06z
|
||||
AOKO7yp23Gi2dyBYaeq1u6n7iyMp9htYee8Y+Erlp6vurvi9S+/8mNVAPBtQ1kNw
|
||||
KvzMTvylD2zWjopwMb9bfSKKT5pe7pZ7CS6Y5T8lM9yZlMBhHQ==
|
||||
-----END CERTIFICATE-----
|
15
node_modules/jwt-simple/test/test.pem
generated
vendored
Normal file
15
node_modules/jwt-simple/test/test.pem
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIICXQIBAAKBgQDGR/5pC6h/8WIjV6NGX/fzkmEZs6r1lQPQxrsUQumRb5Zv2Td3
|
||||
EVFeMh5mBsyvmRS3Ma+MwD4gmkw+aoc4sxQbvfXHGZegemGWFYpXVNNHw5d24jFE
|
||||
H5+tWFh+nSc4Bmug77mxcGsbAJwUWOwMGEst/tHV31Z2RL8tDSsGLsa9owIDAQAB
|
||||
AoGAasmbWzfMKBv4ntA0P1KwV54ebZk2Gc2HoIlneCIRaSKQAu0Z0iahi/myJYDD
|
||||
/E6VuZQo18UxsJ1pMrRs3zyTNunD0hzVgnqz46nMGeMFdrsFcFQIFEtTtxngEyiy
|
||||
zJrO+5oUKX6CIpRZhIBGWk0hKETm9WJ5LMPf48A9PcQGvgECQQD5k7NOy72adPt9
|
||||
9CSOIsaXeovu0ADmA6sDPTtCMzyXWiq6igN9q4gwBHmEfq/272l8CSfbVHAZL1ym
|
||||
WtuLb0srAkEAy2JW3NgxNHn2DdcodEz7QBnRd7qO+qddNv+MoimsbFCpM+lUOXPn
|
||||
IlFVA7IZYMDONwK+qHUIR8kWB2pKqGo7aQJACjqReMNE7BWrUQg2j1TBiufM4GbK
|
||||
AqNX2PQjf50V+KYLZkXNytLC7CTizhlbIOXDDwBZD9YwGfgk9fR3VwmirQJBALbm
|
||||
IKdJ5DYE17lqm/66m9fxX+YD50CR8cnb1mSehWiCwSbl1dA04s6BxaolJ51Sxh/C
|
||||
YCKt3FxyAVV5yNnbbsECQQCZCrGcqIqFHuEYOhLMw0JGlRxVeR2PhWCaPX5M0s+9
|
||||
coyZRyO5MAWBfXDPF552Yqah1FRk+DX2qidkc27P+1QT
|
||||
-----END RSA PRIVATE KEY-----
|
Reference in New Issue
Block a user