增加node_modules

This commit is contained in:
wushenghua
2016-11-29 17:40:27 +08:00
parent 9d9eb91211
commit 350f5f35b2
1499 changed files with 256576 additions and 2 deletions
+57
View File
@@ -0,0 +1,57 @@
1.3.5 / 2015-05-19
==================
* deps: cookie@0.1.3
- Slight optimizations
1.3.4 / 2015-02-15
==================
* deps: cookie-signature@1.0.6
1.3.3 / 2014-09-05
==================
* deps: cookie-signature@1.0.5
1.3.2 / 2014-06-26
==================
* deps: cookie-signature@1.0.4
- fix for timing attacks
1.3.1 / 2014-06-17
==================
* actually export `signedCookie`
1.3.0 / 2014-06-17
==================
* add `signedCookie` export for single cookie unsigning
1.2.0 / 2014-06-17
==================
* export parsing functions
* `req.cookies` and `req.signedCookies` are now plain objects
* slightly faster parsing of many cookies
1.1.0 / 2014-05-12
==================
* Support for NodeJS version 0.8
* deps: cookie@0.1.2
- Fix for maxAge == 0
- made compat with expires field
- tweak maxAge NaN error message
1.0.1 / 2014-02-20
==================
* add missing dependencies
1.0.0 / 2014-02-15
==================
* Genesis from `connect`
+22
View File
@@ -0,0 +1,22 @@
(The MIT License)
Copyright (c) 2014 TJ Holowaychuk <tj@vision-media.ca>
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.
+78
View File
@@ -0,0 +1,78 @@
# cookie-parser
[![NPM Version][npm-image]][npm-url]
[![NPM Downloads][downloads-image]][downloads-url]
[![Build Status][travis-image]][travis-url]
[![Test Coverage][coveralls-image]][coveralls-url]
Parse `Cookie` header and populate `req.cookies` with an object keyed by the cookie
names. Optionally you may enable signed cookie support by passing a `secret` string,
which assigns `req.secret` so it may be used by other middleware.
## Installation
```sh
$ npm install cookie-parser
```
## API
```js
var express = require('express')
var cookieParser = require('cookie-parser')
var app = express()
app.use(cookieParser())
```
### cookieParser(secret, options)
- `secret` a string used for signing cookies. This is optional and if not specified, will not parse signed cookies.
- `options` an object that is passed to `cookie.parse` as the second option. See [cookie](https://www.npmjs.org/package/cookie) for more information.
- `decode` a function to decode the value of the cookie
### cookieParser.JSONCookie(str)
Parse a cookie value as a JSON cookie. This will return the parsed JSON value if it was a JSON cookie, otherwise it will return the passed value.
### cookieParser.JSONCookies(cookies)
Given an object, this will iterate over the keys and call `JSONCookie` on each value. This will return the same object passed in.
### cookieParser.signedCookie(str, secret)
Parse a cookie value as a signed cookie. This will return the parsed unsigned value if it was a signed cookie and the signature was valid, otherwise it will return the passed value.
### cookieParser.signedCookies(cookies, secret)
Given an object, this will iterate over the keys and check if any value is a signed cookie. If it is a signed cookie and the signature is valid, the key will be deleted from the object and added to the new object that is returned.
## Example
```js
var express = require('express')
var cookieParser = require('cookie-parser')
var app = express()
app.use(cookieParser())
app.get('/', function(req, res) {
console.log("Cookies: ", req.cookies)
})
app.listen(8080)
// curl command that sends an HTTP request with two cookies
// curl http://127.0.0.1:8080 --cookie "Cho=Kim;Greet=Hello"
```
### [MIT Licensed](LICENSE)
[npm-image]: https://img.shields.io/npm/v/cookie-parser.svg
[npm-url]: https://npmjs.org/package/cookie-parser
[travis-image]: https://img.shields.io/travis/expressjs/cookie-parser/master.svg
[travis-url]: https://travis-ci.org/expressjs/cookie-parser
[coveralls-image]: https://img.shields.io/coveralls/expressjs/cookie-parser/master.svg
[coveralls-url]: https://coveralls.io/r/expressjs/cookie-parser?branch=master
[downloads-image]: https://img.shields.io/npm/dm/cookie-parser.svg
[downloads-url]: https://npmjs.org/package/cookie-parser
+59
View File
@@ -0,0 +1,59 @@
/*!
* cookie-parser
* MIT Licensed
*/
/**
* Module dependencies.
*/
var cookie = require('cookie');
var parse = require('./lib/parse');
/**
* Parse Cookie header and populate `req.cookies`
* with an object keyed by the cookie names.
*
* @param {String} [secret]
* @param {Object} [options]
* @return {Function}
* @api public
*/
exports = module.exports = function cookieParser(secret, options){
return function cookieParser(req, res, next) {
if (req.cookies) return next();
var cookies = req.headers.cookie;
req.secret = secret;
req.cookies = Object.create(null);
req.signedCookies = Object.create(null);
// no cookies
if (!cookies) {
return next();
}
req.cookies = cookie.parse(cookies, options);
// parse signed cookies
if (secret) {
req.signedCookies = parse.signedCookies(req.cookies, secret);
req.signedCookies = parse.JSONCookies(req.signedCookies);
}
// parse JSON cookies
req.cookies = parse.JSONCookies(req.cookies);
next();
};
};
/**
* Export parsing functions.
*/
exports.JSONCookie = parse.JSONCookie;
exports.JSONCookies = parse.JSONCookies;
exports.signedCookie = parse.signedCookie;
exports.signedCookies = parse.signedCookies;
+90
View File
@@ -0,0 +1,90 @@
var signature = require('cookie-signature');
/**
* Parse signed cookies, returning an object
* containing the decoded key/value pairs,
* while removing the signed key from `obj`.
*
* @param {Object} obj
* @return {Object}
* @api private
*/
exports.signedCookies = function(obj, secret){
var cookies = Object.keys(obj);
var dec;
var key;
var ret = Object.create(null);
var val;
for (var i = 0; i < cookies.length; i++) {
key = cookies[i];
val = obj[key];
dec = exports.signedCookie(val, secret);
if (val !== dec) {
ret[key] = dec;
delete obj[key];
}
}
return ret;
};
/**
* Parse a signed cookie string, return the decoded value
*
* @param {String} str signed cookie string
* @param {String} secret
* @return {String} decoded value
* @api private
*/
exports.signedCookie = function(str, secret){
return str.substr(0, 2) === 's:'
? signature.unsign(str.slice(2), secret)
: str;
};
/**
* Parse JSON cookies.
*
* @param {Object} obj
* @return {Object}
* @api private
*/
exports.JSONCookies = function(obj){
var cookies = Object.keys(obj);
var key;
var val;
for (var i = 0; i < cookies.length; i++) {
key = cookies[i];
val = exports.JSONCookie(obj[key]);
if (val) {
obj[key] = val;
}
}
return obj;
};
/**
* Parse JSON cookie string
*
* @param {String} str
* @return {Object} Parsed object or null if not json cookie
* @api private
*/
exports.JSONCookie = function(str) {
if (!str || str.substr(0, 2) !== 'j:') return;
try {
return JSON.parse(str.slice(2));
} catch (err) {
// no op
}
};
+101
View File
@@ -0,0 +1,101 @@
{
"_args": [
[
"cookie-parser@~1.3.5",
"/Users/xmfish/Desktop/test/RN_AWord/server"
]
],
"_cnpm_publish_time": 1432086160288,
"_from": "cookie-parser@>=1.3.5 <1.4.0",
"_id": "cookie-parser@1.3.5",
"_inCache": true,
"_installable": true,
"_location": "/cookie-parser",
"_npmUser": {
"email": "doug@somethingdoug.com",
"name": "dougwilson"
},
"_npmVersion": "1.4.28",
"_phantomChildren": {},
"_requested": {
"name": "cookie-parser",
"raw": "cookie-parser@~1.3.5",
"rawSpec": "~1.3.5",
"scope": null,
"spec": ">=1.3.5 <1.4.0",
"type": "range"
},
"_requiredBy": [
"/"
],
"_resolved": "https://registry.npmjs.org/cookie-parser/-/cookie-parser-1.3.5.tgz",
"_shasum": "9d755570fb5d17890771227a02314d9be7cf8356",
"_shrinkwrap": null,
"_spec": "cookie-parser@~1.3.5",
"_where": "/Users/xmfish/Desktop/test/RN_AWord/server",
"author": {
"email": "tj@vision-media.ca",
"name": "TJ Holowaychuk",
"url": "http://tjholowaychuk.com"
},
"bugs": {
"url": "https://github.com/expressjs/cookie-parser/issues"
},
"dependencies": {
"cookie": "0.1.3",
"cookie-signature": "1.0.6"
},
"description": "cookie parsing with signatures",
"devDependencies": {
"istanbul": "0.3.9",
"mocha": "2.2.5",
"supertest": "1.0.1"
},
"directories": {},
"dist": {
"noattachment": false,
"shasum": "9d755570fb5d17890771227a02314d9be7cf8356",
"size": 3396,
"tarball": "http://registry.npm.taobao.org/cookie-parser/download/cookie-parser-1.3.5.tgz"
},
"engines": {
"node": ">= 0.8.0"
},
"files": [
"HISTORY.md",
"LICENSE",
"index.js",
"lib/"
],
"gitHead": "8133968c429c3f48eb8e3ed54932c52743ac9034",
"homepage": "https://github.com/expressjs/cookie-parser",
"keywords": [
"cookie",
"middleware"
],
"license": "MIT",
"maintainers": [
{
"name": "defunctzombie",
"email": "shtylman@gmail.com"
},
{
"name": "dougwilson",
"email": "doug@somethingdoug.com"
}
],
"name": "cookie-parser",
"optionalDependencies": {},
"publish_time": 1432086160288,
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git+https://github.com/expressjs/cookie-parser.git"
},
"scripts": {
"test": "mocha --reporter spec --bail --check-leaks test/",
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/",
"test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/"
},
"version": "1.3.5"
}