GoogleOauth2.0 First implementation
First try for GoogleOauth2.0
This commit is contained in:
20
express-server/node_modules/keygrip/HISTORY.md
generated
vendored
Normal file
20
express-server/node_modules/keygrip/HISTORY.md
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
1.0.3 / 2018-09-12
|
||||
==================
|
||||
|
||||
* perf: enable strict mode
|
||||
|
||||
1.0.2 / 2017-08-26
|
||||
==================
|
||||
|
||||
* perf: improve comparison speed
|
||||
|
||||
1.0.1 / 2014-05-07
|
||||
==================
|
||||
|
||||
* Readme changes
|
||||
* Update repository for organization move
|
||||
|
||||
1.0.0 / 2013-12-21
|
||||
==================
|
||||
|
||||
* Remove default key generation and associated expectations
|
21
express-server/node_modules/keygrip/LICENSE
generated
vendored
Normal file
21
express-server/node_modules/keygrip/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2011-2014 Jed Schmidt <where@jed.is> (http://jedschmidt.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.
|
103
express-server/node_modules/keygrip/README.md
generated
vendored
Normal file
103
express-server/node_modules/keygrip/README.md
generated
vendored
Normal file
@ -0,0 +1,103 @@
|
||||
# keygrip
|
||||
|
||||
[![NPM Version][npm-image]][npm-url]
|
||||
[![NPM Downloads][downloads-image]][downloads-url]
|
||||
[![Node.js Version][node-version-image]][node-version-url]
|
||||
[![Build Status][travis-image]][travis-url]
|
||||
[![Test Coverage][coveralls-image]][coveralls-url]
|
||||
|
||||
Keygrip is a [node.js](http://nodejs.org/) module for signing and verifying data (such as cookies or URLs) through a rotating credential system, in which new server keys can be added and old ones removed regularly, without invalidating client credentials.
|
||||
|
||||
## Install
|
||||
|
||||
$ npm install keygrip
|
||||
|
||||
## API
|
||||
|
||||
### keys = new Keygrip([keylist], [hmacAlgorithm], [encoding])
|
||||
|
||||
This creates a new Keygrip based on the provided keylist, an array of secret keys used for SHA1 HMAC digests. `keylist` is obligatory. `hmacAlgorithm` defaults to `'sha1'` and `encoding` defaults to `'base64'`.
|
||||
|
||||
Note that the `new` operator is also optional, so all of the following will work when `Keygrip = require("keygrip")`:
|
||||
|
||||
```javascript
|
||||
keys = new Keygrip(["SEKRIT2", "SEKRIT1"])
|
||||
keys = Keygrip(["SEKRIT2", "SEKRIT1"])
|
||||
keys = require("keygrip")()
|
||||
keys = Keygrip(["SEKRIT2", "SEKRIT1"], 'sha256', 'hex')
|
||||
keys = Keygrip(["SEKRIT2", "SEKRIT1"], 'sha256')
|
||||
keys = Keygrip(["SEKRIT2", "SEKRIT1"], undefined, 'hex')
|
||||
```
|
||||
|
||||
The keylist is an array of all valid keys for signing, in descending order of freshness; new keys should be `unshift`ed into the array and old keys should be `pop`ped.
|
||||
|
||||
The tradeoff here is that adding more keys to the keylist allows for more granular freshness for key validation, at the cost of a more expensive worst-case scenario for old or invalid hashes.
|
||||
|
||||
Keygrip keeps a reference to this array to automatically reflect any changes. This reference is stored using a closure to prevent external access.
|
||||
|
||||
### keys.sign(data)
|
||||
|
||||
This creates a SHA1 HMAC based on the _first_ key in the keylist, and outputs it as a 27-byte url-safe base64 digest (base64 without padding, replacing `+` with `-` and `/` with `_`).
|
||||
|
||||
### keys.index(data, digest)
|
||||
|
||||
This loops through all of the keys currently in the keylist until the digest of the current key matches the given digest, at which point the current index is returned. If no key is matched, `-1` is returned.
|
||||
|
||||
The idea is that if the index returned is greater than `0`, the data should be re-signed to prevent premature credential invalidation, and enable better performance for subsequent challenges.
|
||||
|
||||
### keys.verify(data, digest)
|
||||
|
||||
This uses `index` to return `true` if the digest matches any existing keys, and `false` otherwise.
|
||||
|
||||
## Example
|
||||
|
||||
```javascript
|
||||
// ./test.js
|
||||
var assert = require("assert")
|
||||
, Keygrip = require("keygrip")
|
||||
, keylist, keys, hash, index
|
||||
|
||||
// but we're going to use our list.
|
||||
// (note that the 'new' operator is optional)
|
||||
keylist = ["SEKRIT3", "SEKRIT2", "SEKRIT1"]
|
||||
keys = Keygrip(keylist)
|
||||
// .sign returns the hash for the first key
|
||||
// all hashes are SHA1 HMACs in url-safe base64
|
||||
hash = keys.sign("bieberschnitzel")
|
||||
assert.ok(/^[\w\-]{27}$/.test(hash))
|
||||
|
||||
// .index returns the index of the first matching key
|
||||
index = keys.index("bieberschnitzel", hash)
|
||||
assert.equal(index, 0)
|
||||
|
||||
// .verify returns the a boolean indicating a matched key
|
||||
matched = keys.verify("bieberschnitzel", hash)
|
||||
assert.ok(matched)
|
||||
|
||||
index = keys.index("bieberschnitzel", "o_O")
|
||||
assert.equal(index, -1)
|
||||
|
||||
// rotate a new key in, and an old key out
|
||||
keylist.unshift("SEKRIT4")
|
||||
keylist.pop()
|
||||
|
||||
// if index > 0, it's time to re-sign
|
||||
index = keys.index("bieberschnitzel", hash)
|
||||
assert.equal(index, 1)
|
||||
hash = keys.sign("bieberschnitzel")
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE)
|
||||
|
||||
[npm-image]: https://img.shields.io/npm/v/keygrip.svg
|
||||
[npm-url]: https://npmjs.org/package/keygrip
|
||||
[travis-image]: https://img.shields.io/travis/crypto-utils/keygrip/master.svg
|
||||
[travis-url]: https://travis-ci.org/crypto-utils/keygrip
|
||||
[coveralls-image]: https://img.shields.io/coveralls/crypto-utils/keygrip/master.svg
|
||||
[coveralls-url]: https://coveralls.io/r/crypto-utils/keygrip
|
||||
[downloads-image]: https://img.shields.io/npm/dm/keygrip.svg
|
||||
[downloads-url]: https://npmjs.org/package/keygrip
|
||||
[node-version-image]: https://img.shields.io/node/v/keygrip.svg
|
||||
[node-version-url]: https://nodejs.org/en/download/
|
71
express-server/node_modules/keygrip/index.js
generated
vendored
Normal file
71
express-server/node_modules/keygrip/index.js
generated
vendored
Normal file
@ -0,0 +1,71 @@
|
||||
/*!
|
||||
* keygrip
|
||||
* Copyright(c) 2011-2014 Jed Schmidt
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
'use strict'
|
||||
|
||||
var crypto = require("crypto")
|
||||
|
||||
function Keygrip(keys, algorithm, encoding) {
|
||||
if (!algorithm) algorithm = "sha1";
|
||||
if (!encoding) encoding = "base64";
|
||||
if (!(this instanceof Keygrip)) return new Keygrip(keys, algorithm, encoding)
|
||||
|
||||
if (!keys || !(0 in keys)) {
|
||||
throw new Error("Keys must be provided.")
|
||||
}
|
||||
|
||||
function sign(data, key) {
|
||||
return crypto
|
||||
.createHmac(algorithm, key)
|
||||
.update(data).digest(encoding)
|
||||
.replace(/\/|\+|=/g, function(x) {
|
||||
return ({ "/": "_", "+": "-", "=": "" })[x]
|
||||
})
|
||||
}
|
||||
|
||||
this.sign = function(data){ return sign(data, keys[0]) }
|
||||
|
||||
this.verify = function(data, digest) {
|
||||
return this.index(data, digest) > -1
|
||||
}
|
||||
|
||||
this.index = function(data, digest) {
|
||||
for (var i = 0, l = keys.length; i < l; i++) {
|
||||
if (constantTimeCompare(digest, sign(data, keys[i]))) return i
|
||||
}
|
||||
|
||||
return -1
|
||||
}
|
||||
}
|
||||
|
||||
Keygrip.sign = Keygrip.verify = Keygrip.index = function() {
|
||||
throw new Error("Usage: require('keygrip')(<array-of-keys>)")
|
||||
}
|
||||
|
||||
//http://codahale.com/a-lesson-in-timing-attacks/
|
||||
var constantTimeCompare = function(val1, val2){
|
||||
if(val1 == null && val2 != null){
|
||||
return false;
|
||||
} else if(val2 == null && val1 != null){
|
||||
return false;
|
||||
} else if(val1 == null && val2 == null){
|
||||
return true;
|
||||
}
|
||||
|
||||
if(val1.length !== val2.length){
|
||||
return false;
|
||||
}
|
||||
|
||||
var result = 0;
|
||||
|
||||
for(var i = 0; i < val1.length; i++){
|
||||
result |= val1.charCodeAt(i) ^ val2.charCodeAt(i); //Don't short circuit
|
||||
}
|
||||
|
||||
return result === 0;
|
||||
};
|
||||
|
||||
module.exports = Keygrip
|
57
express-server/node_modules/keygrip/package.json
generated
vendored
Normal file
57
express-server/node_modules/keygrip/package.json
generated
vendored
Normal file
@ -0,0 +1,57 @@
|
||||
{
|
||||
"_from": "keygrip@~1.0.2",
|
||||
"_id": "keygrip@1.0.3",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-/PpesirAIfaklxUzp4Yb7xBper9MwP6hNRA6BGGUFCgbJ+BM5CKBtsoxinNXkLHAr+GXS1/lSlF2rP7cv5Fl+g==",
|
||||
"_location": "/keygrip",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "keygrip@~1.0.2",
|
||||
"name": "keygrip",
|
||||
"escapedName": "keygrip",
|
||||
"rawSpec": "~1.0.2",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "~1.0.2"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/cookies"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/keygrip/-/keygrip-1.0.3.tgz",
|
||||
"_shasum": "399d709f0aed2bab0a059e0cdd3a5023a053e1dc",
|
||||
"_spec": "keygrip@~1.0.2",
|
||||
"_where": "C:\\Users\\Georg\\GitHub\\SmartShopper\\express-server\\node_modules\\cookies",
|
||||
"bugs": {
|
||||
"url": "https://github.com/crypto-utils/keygrip/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"deprecated": false,
|
||||
"description": "Key signing and verification for rotated credentials",
|
||||
"devDependencies": {
|
||||
"istanbul": "0.4.5",
|
||||
"mocha": "1.21.5"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
},
|
||||
"files": [
|
||||
"HISTORY.md",
|
||||
"LICENSE",
|
||||
"README.md",
|
||||
"index.js"
|
||||
],
|
||||
"homepage": "https://github.com/crypto-utils/keygrip#readme",
|
||||
"license": "MIT",
|
||||
"name": "keygrip",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/crypto-utils/keygrip.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha --reporter spec test/",
|
||||
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot test/",
|
||||
"test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter dot test/"
|
||||
},
|
||||
"version": "1.0.3"
|
||||
}
|
Reference in New Issue
Block a user