정지윤

Initial commit : 초기 화면 및 메일링 추가

Showing 657 changed files with 4846 additions and 0 deletions
1 +var express = require('express');
2 +var path = require('path');
3 +var favicon = require('serve-favicon');
4 +var logger = require('morgan');
5 +var cookieParser = require('cookie-parser');
6 +var bodyParser = require('body-parser');
7 +var engine = require('ejs-locals');
8 +
9 +var index = require('./routes/index');
10 +var users = require('./routes/users');
11 +var mail = require('./routes/mail');
12 +
13 +var app = express();
14 +
15 +// view engine setup
16 +app.set('views', path.join(__dirname, 'views'));
17 +app.set('view engine', 'ejs');
18 +
19 +// uncomment after placing your favicon in /public
20 +//app.use(favicon(path.join(__dirname, 'public', 'favicon.ico')));
21 +app.use(logger('dev'));
22 +app.use(bodyParser.json());
23 +app.use(bodyParser.urlencoded({ extended: false }));
24 +app.use(cookieParser());
25 +app.use(express.static(path.join(__dirname, 'public')));
26 +
27 +app.engine('ejs', engine);
28 +
29 +app.use('/', index);
30 +app.use('/users', users);
31 +app.use('/mail', mail);
32 +
33 +// catch 404 and forward to error handler
34 +app.use(function(req, res, next) {
35 + var err = new Error('Not Found');
36 + err.status = 404;
37 + next(err);
38 +});
39 +// error handler
40 +app.use(function(err, req, res, next) {
41 + // set locals, only providing error in development
42 + res.locals.message = err.message;
43 + res.locals.error = req.app.get('env') === 'development' ? err : {};
44 +
45 + // render the error page
46 + res.status(err.status || 500);
47 + res.render('error');
48 +});
49 +
50 +app.set('port', process.env.PORT || 3306);
51 +app.listen(app.get('port'), function () {
52 + console.log('Express server listening on port ' + app.get('port'));
53 +});
54 +
55 +module.exports = app;
1 +#!/usr/bin/env node
2 +
3 +/**
4 + * Module dependencies.
5 + */
6 +
7 +var app = require('../app');
8 +var debug = require('debug')('project-opensource:server');
9 +var http = require('http');
10 +
11 +/**
12 + * Get port from environment and store in Express.
13 + */
14 +
15 +var port = normalizePort(process.env.PORT || '3000');
16 +app.set('port', port);
17 +
18 +/**
19 + * Create HTTP server.
20 + */
21 +
22 +var server = http.createServer(app);
23 +
24 +/**
25 + * Listen on provided port, on all network interfaces.
26 + */
27 +
28 +server.listen(port);
29 +server.on('error', onError);
30 +server.on('listening', onListening);
31 +
32 +/**
33 + * Normalize a port into a number, string, or false.
34 + */
35 +
36 +function normalizePort(val) {
37 + var port = parseInt(val, 10);
38 +
39 + if (isNaN(port)) {
40 + // named pipe
41 + return val;
42 + }
43 +
44 + if (port >= 0) {
45 + // port number
46 + return port;
47 + }
48 +
49 + return false;
50 +}
51 +
52 +/**
53 + * Event listener for HTTP server "error" event.
54 + */
55 +
56 +function onError(error) {
57 + if (error.syscall !== 'listen') {
58 + throw error;
59 + }
60 +
61 + var bind = typeof port === 'string'
62 + ? 'Pipe ' + port
63 + : 'Port ' + port;
64 +
65 + // handle specific listen errors with friendly messages
66 + switch (error.code) {
67 + case 'EACCES':
68 + console.error(bind + ' requires elevated privileges');
69 + process.exit(1);
70 + break;
71 + case 'EADDRINUSE':
72 + console.error(bind + ' is already in use');
73 + process.exit(1);
74 + break;
75 + default:
76 + throw error;
77 + }
78 +}
79 +
80 +/**
81 + * Event listener for HTTP server "listening" event.
82 + */
83 +
84 +function onListening() {
85 + var addr = server.address();
86 + var bind = typeof addr === 'string'
87 + ? 'pipe ' + addr
88 + : 'port ' + addr.port;
89 + debug('Listening on ' + bind);
90 +}
1 +// config/database.js
2 +module.exports = {
3 + host : 'localhost',
4 + user : 'root',
5 + password : 'apmsetup',
6 + port : 3306,
7 + database : 'my_db'
8 +};
1 +// config/database.js
2 +module.exports = {
3 + host : 'localhost',
4 + user : 'root',
5 + password : 'apmsetup',
6 + port : 3306,
7 + database : 'board'
8 +};
1 +// config/database.js
2 +module.exports = {
3 + host : 'localhost',
4 + user : 'root',
5 + password : 'apmsetup',
6 + port : 3306,
7 + database : 'menu_res'
8 +};
1 +CREATE TABLE db2 (
2 + idx INT NOT NULL AUTO_INCREMENT,
3 + creator_id VARCHAR(20) NOT NULL,
4 + title VARCHAR(20) NOT NULL,
5 + content VARCHAR(200),
6 + modidate TIMESTAMP default current_timestamp,
7 + PRIMARY KEY(idx)
8 +)
9 +COLLATE='utf8_general_ci'
10 +;
1 +#!/bin/sh
2 +basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3 +
4 +case `uname` in
5 + *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
6 +esac
7 +
8 +if [ -x "$basedir/node" ]; then
9 + "$basedir/node" "$basedir/../mime/cli.js" "$@"
10 + ret=$?
11 +else
12 + node "$basedir/../mime/cli.js" "$@"
13 + ret=$?
14 +fi
15 +exit $ret
1 +@IF EXIST "%~dp0\node.exe" (
2 + "%~dp0\node.exe" "%~dp0\..\mime\cli.js" %*
3 +) ELSE (
4 + @SETLOCAL
5 + @SET PATHEXT=%PATHEXT:;.JS;=;%
6 + node "%~dp0\..\mime\cli.js" %*
7 +)
...\ No newline at end of file ...\ No newline at end of file
1 +1.3.4 / 2017-08-22
2 +==================
3 +
4 + * deps: mime-types@~2.1.16
5 + - deps: mime-db@~1.29.0
6 +
7 +1.3.3 / 2016-05-02
8 +==================
9 +
10 + * deps: mime-types@~2.1.11
11 + - deps: mime-db@~1.23.0
12 + * deps: negotiator@0.6.1
13 + - perf: improve `Accept` parsing speed
14 + - perf: improve `Accept-Charset` parsing speed
15 + - perf: improve `Accept-Encoding` parsing speed
16 + - perf: improve `Accept-Language` parsing speed
17 +
18 +1.3.2 / 2016-03-08
19 +==================
20 +
21 + * deps: mime-types@~2.1.10
22 + - Fix extension of `application/dash+xml`
23 + - Update primary extension for `audio/mp4`
24 + - deps: mime-db@~1.22.0
25 +
26 +1.3.1 / 2016-01-19
27 +==================
28 +
29 + * deps: mime-types@~2.1.9
30 + - deps: mime-db@~1.21.0
31 +
32 +1.3.0 / 2015-09-29
33 +==================
34 +
35 + * deps: mime-types@~2.1.7
36 + - deps: mime-db@~1.19.0
37 + * deps: negotiator@0.6.0
38 + - Fix including type extensions in parameters in `Accept` parsing
39 + - Fix parsing `Accept` parameters with quoted equals
40 + - Fix parsing `Accept` parameters with quoted semicolons
41 + - Lazy-load modules from main entry point
42 + - perf: delay type concatenation until needed
43 + - perf: enable strict mode
44 + - perf: hoist regular expressions
45 + - perf: remove closures getting spec properties
46 + - perf: remove a closure from media type parsing
47 + - perf: remove property delete from media type parsing
48 +
49 +1.2.13 / 2015-09-06
50 +===================
51 +
52 + * deps: mime-types@~2.1.6
53 + - deps: mime-db@~1.18.0
54 +
55 +1.2.12 / 2015-07-30
56 +===================
57 +
58 + * deps: mime-types@~2.1.4
59 + - deps: mime-db@~1.16.0
60 +
61 +1.2.11 / 2015-07-16
62 +===================
63 +
64 + * deps: mime-types@~2.1.3
65 + - deps: mime-db@~1.15.0
66 +
67 +1.2.10 / 2015-07-01
68 +===================
69 +
70 + * deps: mime-types@~2.1.2
71 + - deps: mime-db@~1.14.0
72 +
73 +1.2.9 / 2015-06-08
74 +==================
75 +
76 + * deps: mime-types@~2.1.1
77 + - perf: fix deopt during mapping
78 +
79 +1.2.8 / 2015-06-07
80 +==================
81 +
82 + * deps: mime-types@~2.1.0
83 + - deps: mime-db@~1.13.0
84 + * perf: avoid argument reassignment & argument slice
85 + * perf: avoid negotiator recursive construction
86 + * perf: enable strict mode
87 + * perf: remove unnecessary bitwise operator
88 +
89 +1.2.7 / 2015-05-10
90 +==================
91 +
92 + * deps: negotiator@0.5.3
93 + - Fix media type parameter matching to be case-insensitive
94 +
95 +1.2.6 / 2015-05-07
96 +==================
97 +
98 + * deps: mime-types@~2.0.11
99 + - deps: mime-db@~1.9.1
100 + * deps: negotiator@0.5.2
101 + - Fix comparing media types with quoted values
102 + - Fix splitting media types with quoted commas
103 +
104 +1.2.5 / 2015-03-13
105 +==================
106 +
107 + * deps: mime-types@~2.0.10
108 + - deps: mime-db@~1.8.0
109 +
110 +1.2.4 / 2015-02-14
111 +==================
112 +
113 + * Support Node.js 0.6
114 + * deps: mime-types@~2.0.9
115 + - deps: mime-db@~1.7.0
116 + * deps: negotiator@0.5.1
117 + - Fix preference sorting to be stable for long acceptable lists
118 +
119 +1.2.3 / 2015-01-31
120 +==================
121 +
122 + * deps: mime-types@~2.0.8
123 + - deps: mime-db@~1.6.0
124 +
125 +1.2.2 / 2014-12-30
126 +==================
127 +
128 + * deps: mime-types@~2.0.7
129 + - deps: mime-db@~1.5.0
130 +
131 +1.2.1 / 2014-12-30
132 +==================
133 +
134 + * deps: mime-types@~2.0.5
135 + - deps: mime-db@~1.3.1
136 +
137 +1.2.0 / 2014-12-19
138 +==================
139 +
140 + * deps: negotiator@0.5.0
141 + - Fix list return order when large accepted list
142 + - Fix missing identity encoding when q=0 exists
143 + - Remove dynamic building of Negotiator class
144 +
145 +1.1.4 / 2014-12-10
146 +==================
147 +
148 + * deps: mime-types@~2.0.4
149 + - deps: mime-db@~1.3.0
150 +
151 +1.1.3 / 2014-11-09
152 +==================
153 +
154 + * deps: mime-types@~2.0.3
155 + - deps: mime-db@~1.2.0
156 +
157 +1.1.2 / 2014-10-14
158 +==================
159 +
160 + * deps: negotiator@0.4.9
161 + - Fix error when media type has invalid parameter
162 +
163 +1.1.1 / 2014-09-28
164 +==================
165 +
166 + * deps: mime-types@~2.0.2
167 + - deps: mime-db@~1.1.0
168 + * deps: negotiator@0.4.8
169 + - Fix all negotiations to be case-insensitive
170 + - Stable sort preferences of same quality according to client order
171 +
172 +1.1.0 / 2014-09-02
173 +==================
174 +
175 + * update `mime-types`
176 +
177 +1.0.7 / 2014-07-04
178 +==================
179 +
180 + * Fix wrong type returned from `type` when match after unknown extension
181 +
182 +1.0.6 / 2014-06-24
183 +==================
184 +
185 + * deps: negotiator@0.4.7
186 +
187 +1.0.5 / 2014-06-20
188 +==================
189 +
190 + * fix crash when unknown extension given
191 +
192 +1.0.4 / 2014-06-19
193 +==================
194 +
195 + * use `mime-types`
196 +
197 +1.0.3 / 2014-06-11
198 +==================
199 +
200 + * deps: negotiator@0.4.6
201 + - Order by specificity when quality is the same
202 +
203 +1.0.2 / 2014-05-29
204 +==================
205 +
206 + * Fix interpretation when header not in request
207 + * deps: pin negotiator@0.4.5
208 +
209 +1.0.1 / 2014-01-18
210 +==================
211 +
212 + * Identity encoding isn't always acceptable
213 + * deps: negotiator@~0.4.0
214 +
215 +1.0.0 / 2013-12-27
216 +==================
217 +
218 + * Genesis
1 +(The MIT License)
2 +
3 +Copyright (c) 2014 Jonathan Ong <me@jongleberry.com>
4 +Copyright (c) 2015 Douglas Christopher Wilson <doug@somethingdoug.com>
5 +
6 +Permission is hereby granted, free of charge, to any person obtaining
7 +a copy of this software and associated documentation files (the
8 +'Software'), to deal in the Software without restriction, including
9 +without limitation the rights to use, copy, modify, merge, publish,
10 +distribute, sublicense, and/or sell copies of the Software, and to
11 +permit persons to whom the Software is furnished to do so, subject to
12 +the following conditions:
13 +
14 +The above copyright notice and this permission notice shall be
15 +included in all copies or substantial portions of the Software.
16 +
17 +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
18 +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1 +# accepts
2 +
3 +[![NPM Version][npm-image]][npm-url]
4 +[![NPM Downloads][downloads-image]][downloads-url]
5 +[![Node.js Version][node-version-image]][node-version-url]
6 +[![Build Status][travis-image]][travis-url]
7 +[![Test Coverage][coveralls-image]][coveralls-url]
8 +
9 +Higher level content negotiation based on [negotiator](https://www.npmjs.com/package/negotiator).
10 +Extracted from [koa](https://www.npmjs.com/package/koa) for general use.
11 +
12 +In addition to negotiator, it allows:
13 +
14 +- Allows types as an array or arguments list, ie `(['text/html', 'application/json'])`
15 + as well as `('text/html', 'application/json')`.
16 +- Allows type shorthands such as `json`.
17 +- Returns `false` when no types match
18 +- Treats non-existent headers as `*`
19 +
20 +## Installation
21 +
22 +This is a [Node.js](https://nodejs.org/en/) module available through the
23 +[npm registry](https://www.npmjs.com/). Installation is done using the
24 +[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):
25 +
26 +```sh
27 +$ npm install accepts
28 +```
29 +
30 +## API
31 +
32 +<!-- eslint-disable no-unused-vars -->
33 +
34 +```js
35 +var accepts = require('accepts')
36 +```
37 +
38 +### accepts(req)
39 +
40 +Create a new `Accepts` object for the given `req`.
41 +
42 +#### .charset(charsets)
43 +
44 +Return the first accepted charset. If nothing in `charsets` is accepted,
45 +then `false` is returned.
46 +
47 +#### .charsets()
48 +
49 +Return the charsets that the request accepts, in the order of the client's
50 +preference (most preferred first).
51 +
52 +#### .encoding(encodings)
53 +
54 +Return the first accepted encoding. If nothing in `encodings` is accepted,
55 +then `false` is returned.
56 +
57 +#### .encodings()
58 +
59 +Return the encodings that the request accepts, in the order of the client's
60 +preference (most preferred first).
61 +
62 +#### .language(languages)
63 +
64 +Return the first accepted language. If nothing in `languages` is accepted,
65 +then `false` is returned.
66 +
67 +#### .languages()
68 +
69 +Return the languages that the request accepts, in the order of the client's
70 +preference (most preferred first).
71 +
72 +#### .type(types)
73 +
74 +Return the first accepted type (and it is returned as the same text as what
75 +appears in the `types` array). If nothing in `types` is accepted, then `false`
76 +is returned.
77 +
78 +The `types` array can contain full MIME types or file extensions. Any value
79 +that is not a full MIME types is passed to `require('mime-types').lookup`.
80 +
81 +#### .types()
82 +
83 +Return the types that the request accepts, in the order of the client's
84 +preference (most preferred first).
85 +
86 +## Examples
87 +
88 +### Simple type negotiation
89 +
90 +This simple example shows how to use `accepts` to return a different typed
91 +respond body based on what the client wants to accept. The server lists it's
92 +preferences in order and will get back the best match between the client and
93 +server.
94 +
95 +```js
96 +var accepts = require('accepts')
97 +var http = require('http')
98 +
99 +function app (req, res) {
100 + var accept = accepts(req)
101 +
102 + // the order of this list is significant; should be server preferred order
103 + switch (accept.type(['json', 'html'])) {
104 + case 'json':
105 + res.setHeader('Content-Type', 'application/json')
106 + res.write('{"hello":"world!"}')
107 + break
108 + case 'html':
109 + res.setHeader('Content-Type', 'text/html')
110 + res.write('<b>hello, world!</b>')
111 + break
112 + default:
113 + // the fallback is text/plain, so no need to specify it above
114 + res.setHeader('Content-Type', 'text/plain')
115 + res.write('hello, world!')
116 + break
117 + }
118 +
119 + res.end()
120 +}
121 +
122 +http.createServer(app).listen(3000)
123 +```
124 +
125 +You can test this out with the cURL program:
126 +```sh
127 +curl -I -H'Accept: text/html' http://localhost:3000/
128 +```
129 +
130 +## License
131 +
132 +[MIT](LICENSE)
133 +
134 +[npm-image]: https://img.shields.io/npm/v/accepts.svg
135 +[npm-url]: https://npmjs.org/package/accepts
136 +[node-version-image]: https://img.shields.io/node/v/accepts.svg
137 +[node-version-url]: https://nodejs.org/en/download/
138 +[travis-image]: https://img.shields.io/travis/jshttp/accepts/master.svg
139 +[travis-url]: https://travis-ci.org/jshttp/accepts
140 +[coveralls-image]: https://img.shields.io/coveralls/jshttp/accepts/master.svg
141 +[coveralls-url]: https://coveralls.io/r/jshttp/accepts
142 +[downloads-image]: https://img.shields.io/npm/dm/accepts.svg
143 +[downloads-url]: https://npmjs.org/package/accepts
1 +/*!
2 + * accepts
3 + * Copyright(c) 2014 Jonathan Ong
4 + * Copyright(c) 2015 Douglas Christopher Wilson
5 + * MIT Licensed
6 + */
7 +
8 +'use strict'
9 +
10 +/**
11 + * Module dependencies.
12 + * @private
13 + */
14 +
15 +var Negotiator = require('negotiator')
16 +var mime = require('mime-types')
17 +
18 +/**
19 + * Module exports.
20 + * @public
21 + */
22 +
23 +module.exports = Accepts
24 +
25 +/**
26 + * Create a new Accepts object for the given req.
27 + *
28 + * @param {object} req
29 + * @public
30 + */
31 +
32 +function Accepts (req) {
33 + if (!(this instanceof Accepts)) {
34 + return new Accepts(req)
35 + }
36 +
37 + this.headers = req.headers
38 + this.negotiator = new Negotiator(req)
39 +}
40 +
41 +/**
42 + * Check if the given `type(s)` is acceptable, returning
43 + * the best match when true, otherwise `undefined`, in which
44 + * case you should respond with 406 "Not Acceptable".
45 + *
46 + * The `type` value may be a single mime type string
47 + * such as "application/json", the extension name
48 + * such as "json" or an array `["json", "html", "text/plain"]`. When a list
49 + * or array is given the _best_ match, if any is returned.
50 + *
51 + * Examples:
52 + *
53 + * // Accept: text/html
54 + * this.types('html');
55 + * // => "html"
56 + *
57 + * // Accept: text/*, application/json
58 + * this.types('html');
59 + * // => "html"
60 + * this.types('text/html');
61 + * // => "text/html"
62 + * this.types('json', 'text');
63 + * // => "json"
64 + * this.types('application/json');
65 + * // => "application/json"
66 + *
67 + * // Accept: text/*, application/json
68 + * this.types('image/png');
69 + * this.types('png');
70 + * // => undefined
71 + *
72 + * // Accept: text/*;q=.5, application/json
73 + * this.types(['html', 'json']);
74 + * this.types('html', 'json');
75 + * // => "json"
76 + *
77 + * @param {String|Array} types...
78 + * @return {String|Array|Boolean}
79 + * @public
80 + */
81 +
82 +Accepts.prototype.type =
83 +Accepts.prototype.types = function (types_) {
84 + var types = types_
85 +
86 + // support flattened arguments
87 + if (types && !Array.isArray(types)) {
88 + types = new Array(arguments.length)
89 + for (var i = 0; i < types.length; i++) {
90 + types[i] = arguments[i]
91 + }
92 + }
93 +
94 + // no types, return all requested types
95 + if (!types || types.length === 0) {
96 + return this.negotiator.mediaTypes()
97 + }
98 +
99 + // no accept header, return first given type
100 + if (!this.headers.accept) {
101 + return types[0]
102 + }
103 +
104 + var mimes = types.map(extToMime)
105 + var accepts = this.negotiator.mediaTypes(mimes.filter(validMime))
106 + var first = accepts[0]
107 +
108 + return first
109 + ? types[mimes.indexOf(first)]
110 + : false
111 +}
112 +
113 +/**
114 + * Return accepted encodings or best fit based on `encodings`.
115 + *
116 + * Given `Accept-Encoding: gzip, deflate`
117 + * an array sorted by quality is returned:
118 + *
119 + * ['gzip', 'deflate']
120 + *
121 + * @param {String|Array} encodings...
122 + * @return {String|Array}
123 + * @public
124 + */
125 +
126 +Accepts.prototype.encoding =
127 +Accepts.prototype.encodings = function (encodings_) {
128 + var encodings = encodings_
129 +
130 + // support flattened arguments
131 + if (encodings && !Array.isArray(encodings)) {
132 + encodings = new Array(arguments.length)
133 + for (var i = 0; i < encodings.length; i++) {
134 + encodings[i] = arguments[i]
135 + }
136 + }
137 +
138 + // no encodings, return all requested encodings
139 + if (!encodings || encodings.length === 0) {
140 + return this.negotiator.encodings()
141 + }
142 +
143 + return this.negotiator.encodings(encodings)[0] || false
144 +}
145 +
146 +/**
147 + * Return accepted charsets or best fit based on `charsets`.
148 + *
149 + * Given `Accept-Charset: utf-8, iso-8859-1;q=0.2, utf-7;q=0.5`
150 + * an array sorted by quality is returned:
151 + *
152 + * ['utf-8', 'utf-7', 'iso-8859-1']
153 + *
154 + * @param {String|Array} charsets...
155 + * @return {String|Array}
156 + * @public
157 + */
158 +
159 +Accepts.prototype.charset =
160 +Accepts.prototype.charsets = function (charsets_) {
161 + var charsets = charsets_
162 +
163 + // support flattened arguments
164 + if (charsets && !Array.isArray(charsets)) {
165 + charsets = new Array(arguments.length)
166 + for (var i = 0; i < charsets.length; i++) {
167 + charsets[i] = arguments[i]
168 + }
169 + }
170 +
171 + // no charsets, return all requested charsets
172 + if (!charsets || charsets.length === 0) {
173 + return this.negotiator.charsets()
174 + }
175 +
176 + return this.negotiator.charsets(charsets)[0] || false
177 +}
178 +
179 +/**
180 + * Return accepted languages or best fit based on `langs`.
181 + *
182 + * Given `Accept-Language: en;q=0.8, es, pt`
183 + * an array sorted by quality is returned:
184 + *
185 + * ['es', 'pt', 'en']
186 + *
187 + * @param {String|Array} langs...
188 + * @return {Array|String}
189 + * @public
190 + */
191 +
192 +Accepts.prototype.lang =
193 +Accepts.prototype.langs =
194 +Accepts.prototype.language =
195 +Accepts.prototype.languages = function (languages_) {
196 + var languages = languages_
197 +
198 + // support flattened arguments
199 + if (languages && !Array.isArray(languages)) {
200 + languages = new Array(arguments.length)
201 + for (var i = 0; i < languages.length; i++) {
202 + languages[i] = arguments[i]
203 + }
204 + }
205 +
206 + // no languages, return all requested languages
207 + if (!languages || languages.length === 0) {
208 + return this.negotiator.languages()
209 + }
210 +
211 + return this.negotiator.languages(languages)[0] || false
212 +}
213 +
214 +/**
215 + * Convert extnames to mime.
216 + *
217 + * @param {String} type
218 + * @return {String}
219 + * @private
220 + */
221 +
222 +function extToMime (type) {
223 + return type.indexOf('/') === -1
224 + ? mime.lookup(type)
225 + : type
226 +}
227 +
228 +/**
229 + * Check if mime is valid.
230 + *
231 + * @param {String} type
232 + * @return {String}
233 + * @private
234 + */
235 +
236 +function validMime (type) {
237 + return typeof type === 'string'
238 +}
1 +{
2 + "_from": "accepts@~1.3.3",
3 + "_id": "accepts@1.3.4",
4 + "_inBundle": false,
5 + "_integrity": "sha1-hiRnWMfdbSGmR0/whKR0DsBesh8=",
6 + "_location": "/accepts",
7 + "_phantomChildren": {},
8 + "_requested": {
9 + "type": "range",
10 + "registry": true,
11 + "raw": "accepts@~1.3.3",
12 + "name": "accepts",
13 + "escapedName": "accepts",
14 + "rawSpec": "~1.3.3",
15 + "saveSpec": null,
16 + "fetchSpec": "~1.3.3"
17 + },
18 + "_requiredBy": [
19 + "/express"
20 + ],
21 + "_resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.4.tgz",
22 + "_shasum": "86246758c7dd6d21a6474ff084a4740ec05eb21f",
23 + "_spec": "accepts@~1.3.3",
24 + "_where": "C:\\Users\\지윤\\project_opensource\\node_modules\\express",
25 + "bugs": {
26 + "url": "https://github.com/jshttp/accepts/issues"
27 + },
28 + "bundleDependencies": false,
29 + "contributors": [
30 + {
31 + "name": "Douglas Christopher Wilson",
32 + "email": "doug@somethingdoug.com"
33 + },
34 + {
35 + "name": "Jonathan Ong",
36 + "email": "me@jongleberry.com",
37 + "url": "http://jongleberry.com"
38 + }
39 + ],
40 + "dependencies": {
41 + "mime-types": "~2.1.16",
42 + "negotiator": "0.6.1"
43 + },
44 + "deprecated": false,
45 + "description": "Higher-level content negotiation",
46 + "devDependencies": {
47 + "eslint": "3.19.0",
48 + "eslint-config-standard": "10.2.1",
49 + "eslint-plugin-import": "2.7.0",
50 + "eslint-plugin-markdown": "1.0.0-beta.6",
51 + "eslint-plugin-node": "5.1.1",
52 + "eslint-plugin-promise": "3.5.0",
53 + "eslint-plugin-standard": "3.0.1",
54 + "istanbul": "0.4.5",
55 + "mocha": "~1.21.5"
56 + },
57 + "engines": {
58 + "node": ">= 0.6"
59 + },
60 + "files": [
61 + "LICENSE",
62 + "HISTORY.md",
63 + "index.js"
64 + ],
65 + "homepage": "https://github.com/jshttp/accepts#readme",
66 + "keywords": [
67 + "content",
68 + "negotiation",
69 + "accept",
70 + "accepts"
71 + ],
72 + "license": "MIT",
73 + "name": "accepts",
74 + "repository": {
75 + "type": "git",
76 + "url": "git+https://github.com/jshttp/accepts.git"
77 + },
78 + "scripts": {
79 + "lint": "eslint --plugin markdown --ext js,md .",
80 + "test": "mocha --reporter spec --check-leaks --bail test/",
81 + "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/",
82 + "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/"
83 + },
84 + "version": "1.3.4"
85 +}
1 +The MIT License (MIT)
2 +
3 +Copyright (c) 2014 Blake Embrey (hello@blakeembrey.com)
4 +
5 +Permission is hereby granted, free of charge, to any person obtaining a copy
6 +of this software and associated documentation files (the "Software"), to deal
7 +in the Software without restriction, including without limitation the rights
8 +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 +copies of the Software, and to permit persons to whom the Software is
10 +furnished to do so, subject to the following conditions:
11 +
12 +The above copyright notice and this permission notice shall be included in
13 +all copies or substantial portions of the Software.
14 +
15 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 +THE SOFTWARE.
1 +# Array Flatten
2 +
3 +[![NPM version][npm-image]][npm-url]
4 +[![NPM downloads][downloads-image]][downloads-url]
5 +[![Build status][travis-image]][travis-url]
6 +[![Test coverage][coveralls-image]][coveralls-url]
7 +
8 +> Flatten an array of nested arrays into a single flat array. Accepts an optional depth.
9 +
10 +## Installation
11 +
12 +```
13 +npm install array-flatten --save
14 +```
15 +
16 +## Usage
17 +
18 +```javascript
19 +var flatten = require('array-flatten')
20 +
21 +flatten([1, [2, [3, [4, [5], 6], 7], 8], 9])
22 +//=> [1, 2, 3, 4, 5, 6, 7, 8, 9]
23 +
24 +flatten([1, [2, [3, [4, [5], 6], 7], 8], 9], 2)
25 +//=> [1, 2, 3, [4, [5], 6], 7, 8, 9]
26 +
27 +(function () {
28 + flatten(arguments) //=> [1, 2, 3]
29 +})(1, [2, 3])
30 +```
31 +
32 +## License
33 +
34 +MIT
35 +
36 +[npm-image]: https://img.shields.io/npm/v/array-flatten.svg?style=flat
37 +[npm-url]: https://npmjs.org/package/array-flatten
38 +[downloads-image]: https://img.shields.io/npm/dm/array-flatten.svg?style=flat
39 +[downloads-url]: https://npmjs.org/package/array-flatten
40 +[travis-image]: https://img.shields.io/travis/blakeembrey/array-flatten.svg?style=flat
41 +[travis-url]: https://travis-ci.org/blakeembrey/array-flatten
42 +[coveralls-image]: https://img.shields.io/coveralls/blakeembrey/array-flatten.svg?style=flat
43 +[coveralls-url]: https://coveralls.io/r/blakeembrey/array-flatten?branch=master
1 +'use strict'
2 +
3 +/**
4 + * Expose `arrayFlatten`.
5 + */
6 +module.exports = arrayFlatten
7 +
8 +/**
9 + * Recursive flatten function with depth.
10 + *
11 + * @param {Array} array
12 + * @param {Array} result
13 + * @param {Number} depth
14 + * @return {Array}
15 + */
16 +function flattenWithDepth (array, result, depth) {
17 + for (var i = 0; i < array.length; i++) {
18 + var value = array[i]
19 +
20 + if (depth > 0 && Array.isArray(value)) {
21 + flattenWithDepth(value, result, depth - 1)
22 + } else {
23 + result.push(value)
24 + }
25 + }
26 +
27 + return result
28 +}
29 +
30 +/**
31 + * Recursive flatten function. Omitting depth is slightly faster.
32 + *
33 + * @param {Array} array
34 + * @param {Array} result
35 + * @return {Array}
36 + */
37 +function flattenForever (array, result) {
38 + for (var i = 0; i < array.length; i++) {
39 + var value = array[i]
40 +
41 + if (Array.isArray(value)) {
42 + flattenForever(value, result)
43 + } else {
44 + result.push(value)
45 + }
46 + }
47 +
48 + return result
49 +}
50 +
51 +/**
52 + * Flatten an array, with the ability to define a depth.
53 + *
54 + * @param {Array} array
55 + * @param {Number} depth
56 + * @return {Array}
57 + */
58 +function arrayFlatten (array, depth) {
59 + if (depth == null) {
60 + return flattenForever(array, [])
61 + }
62 +
63 + return flattenWithDepth(array, [], depth)
64 +}
1 +{
2 + "_from": "array-flatten@1.1.1",
3 + "_id": "array-flatten@1.1.1",
4 + "_inBundle": false,
5 + "_integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=",
6 + "_location": "/array-flatten",
7 + "_phantomChildren": {},
8 + "_requested": {
9 + "type": "version",
10 + "registry": true,
11 + "raw": "array-flatten@1.1.1",
12 + "name": "array-flatten",
13 + "escapedName": "array-flatten",
14 + "rawSpec": "1.1.1",
15 + "saveSpec": null,
16 + "fetchSpec": "1.1.1"
17 + },
18 + "_requiredBy": [
19 + "/express"
20 + ],
21 + "_resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
22 + "_shasum": "9a5f699051b1e7073328f2a008968b64ea2955d2",
23 + "_spec": "array-flatten@1.1.1",
24 + "_where": "C:\\Users\\지윤\\project_opensource\\node_modules\\express",
25 + "author": {
26 + "name": "Blake Embrey",
27 + "email": "hello@blakeembrey.com",
28 + "url": "http://blakeembrey.me"
29 + },
30 + "bugs": {
31 + "url": "https://github.com/blakeembrey/array-flatten/issues"
32 + },
33 + "bundleDependencies": false,
34 + "deprecated": false,
35 + "description": "Flatten an array of nested arrays into a single flat array",
36 + "devDependencies": {
37 + "istanbul": "^0.3.13",
38 + "mocha": "^2.2.4",
39 + "pre-commit": "^1.0.7",
40 + "standard": "^3.7.3"
41 + },
42 + "files": [
43 + "array-flatten.js",
44 + "LICENSE"
45 + ],
46 + "homepage": "https://github.com/blakeembrey/array-flatten",
47 + "keywords": [
48 + "array",
49 + "flatten",
50 + "arguments",
51 + "depth"
52 + ],
53 + "license": "MIT",
54 + "main": "array-flatten.js",
55 + "name": "array-flatten",
56 + "repository": {
57 + "type": "git",
58 + "url": "git://github.com/blakeembrey/array-flatten.git"
59 + },
60 + "scripts": {
61 + "test": "istanbul cover _mocha -- -R spec"
62 + },
63 + "version": "1.1.1"
64 +}
1 +2.0.0 / 2017-09-12
2 +==================
3 +
4 + * Drop support for Node.js below 0.8
5 + * Remove `auth(ctx)` signature -- pass in header or `auth(ctx.req)`
6 + * Use `safe-buffer` for improved Buffer API
7 +
8 +1.1.0 / 2016-11-18
9 +==================
10 +
11 + * Add `auth.parse` for low-level string parsing
12 +
13 +1.0.4 / 2016-05-10
14 +==================
15 +
16 + * Improve error message when `req` argument is not an object
17 + * Improve error message when `req` missing `headers` property
18 +
19 +1.0.3 / 2015-07-01
20 +==================
21 +
22 + * Fix regression accepting a Koa context
23 +
24 +1.0.2 / 2015-06-12
25 +==================
26 +
27 + * Improve error message when `req` argument missing
28 + * perf: enable strict mode
29 + * perf: hoist regular expression
30 + * perf: parse with regular expressions
31 + * perf: remove argument reassignment
32 +
33 +1.0.1 / 2015-05-04
34 +==================
35 +
36 + * Update readme
37 +
38 +1.0.0 / 2014-07-01
39 +==================
40 +
41 + * Support empty password
42 + * Support empty username
43 +
44 +0.0.1 / 2013-11-30
45 +==================
46 +
47 + * Initial release
1 +(The MIT License)
2 +
3 +Copyright (c) 2013 TJ Holowaychuk
4 +Copyright (c) 2014 Jonathan Ong <me@jongleberry.com>
5 +Copyright (c) 2015-2016 Douglas Christopher Wilson <doug@somethingdoug.com>
6 +
7 +Permission is hereby granted, free of charge, to any person obtaining
8 +a copy of this software and associated documentation files (the
9 +'Software'), to deal in the Software without restriction, including
10 +without limitation the rights to use, copy, modify, merge, publish,
11 +distribute, sublicense, and/or sell copies of the Software, and to
12 +permit persons to whom the Software is furnished to do so, subject to
13 +the following conditions:
14 +
15 +The above copyright notice and this permission notice shall be
16 +included in all copies or substantial portions of the Software.
17 +
18 +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
19 +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21 +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
22 +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1 +# basic-auth
2 +
3 +[![NPM Version][npm-image]][npm-url]
4 +[![NPM Downloads][downloads-image]][downloads-url]
5 +[![Node.js Version][node-version-image]][node-version-url]
6 +[![Build Status][travis-image]][travis-url]
7 +[![Test Coverage][coveralls-image]][coveralls-url]
8 +
9 +Generic basic auth Authorization header field parser for whatever.
10 +
11 +## Installation
12 +
13 +This is a [Node.js](https://nodejs.org/en/) module available through the
14 +[npm registry](https://www.npmjs.com/). Installation is done using the
15 +[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):
16 +
17 +```
18 +$ npm install basic-auth
19 +```
20 +
21 +## API
22 +
23 +<!-- eslint-disable no-unused-vars -->
24 +
25 +```js
26 +var auth = require('basic-auth')
27 +```
28 +
29 +### auth(req)
30 +
31 +Get the basic auth credentials from the given request. The `Authorization`
32 +header is parsed and if the header is invalid, `undefined` is returned,
33 +otherwise an object with `name` and `pass` properties.
34 +
35 +### auth.parse(string)
36 +
37 +Parse a basic auth authorization header string. This will return an object
38 +with `name` and `pass` properties, or `undefined` if the string is invalid.
39 +
40 +## Example
41 +
42 +Pass a Node.js request object to the module export. If parsing fails
43 +`undefined` is returned, otherwise an object with `.name` and `.pass`.
44 +
45 +<!-- eslint-disable no-unused-vars, no-undef -->
46 +
47 +```js
48 +var auth = require('basic-auth')
49 +var user = auth(req)
50 +// => { name: 'something', pass: 'whatever' }
51 +```
52 +
53 +A header string from any other location can also be parsed with
54 +`auth.parse`, for example a `Proxy-Authorization` header:
55 +
56 +<!-- eslint-disable no-unused-vars, no-undef -->
57 +
58 +```js
59 +var auth = require('basic-auth')
60 +var user = auth.parse(req.getHeader('Proxy-Authorization'))
61 +```
62 +
63 +### With vanilla node.js http server
64 +
65 +```js
66 +var http = require('http')
67 +var auth = require('basic-auth')
68 +
69 +// Create server
70 +var server = http.createServer(function (req, res) {
71 + var credentials = auth(req)
72 +
73 + if (!credentials || credentials.name !== 'john' || credentials.pass !== 'secret') {
74 + res.statusCode = 401
75 + res.setHeader('WWW-Authenticate', 'Basic realm="example"')
76 + res.end('Access denied')
77 + } else {
78 + res.end('Access granted')
79 + }
80 +})
81 +
82 +// Listen
83 +server.listen(3000)
84 +```
85 +
86 +# License
87 +
88 +[MIT](LICENSE)
89 +
90 +[npm-image]: https://img.shields.io/npm/v/basic-auth.svg
91 +[npm-url]: https://npmjs.org/package/basic-auth
92 +[node-version-image]: https://img.shields.io/node/v/basic-auth.svg
93 +[node-version-url]: https://nodejs.org/en/download
94 +[travis-image]: https://img.shields.io/travis/jshttp/basic-auth/master.svg
95 +[travis-url]: https://travis-ci.org/jshttp/basic-auth
96 +[coveralls-image]: https://img.shields.io/coveralls/jshttp/basic-auth/master.svg
97 +[coveralls-url]: https://coveralls.io/r/jshttp/basic-auth?branch=master
98 +[downloads-image]: https://img.shields.io/npm/dm/basic-auth.svg
99 +[downloads-url]: https://npmjs.org/package/basic-auth
1 +/*!
2 + * basic-auth
3 + * Copyright(c) 2013 TJ Holowaychuk
4 + * Copyright(c) 2014 Jonathan Ong
5 + * Copyright(c) 2015-2016 Douglas Christopher Wilson
6 + * MIT Licensed
7 + */
8 +
9 +'use strict'
10 +
11 +/**
12 + * Module dependencies.
13 + * @private
14 + */
15 +
16 +var Buffer = require('safe-buffer').Buffer
17 +
18 +/**
19 + * Module exports.
20 + * @public
21 + */
22 +
23 +module.exports = auth
24 +module.exports.parse = parse
25 +
26 +/**
27 + * RegExp for basic auth credentials
28 + *
29 + * credentials = auth-scheme 1*SP token68
30 + * auth-scheme = "Basic" ; case insensitive
31 + * token68 = 1*( ALPHA / DIGIT / "-" / "." / "_" / "~" / "+" / "/" ) *"="
32 + * @private
33 + */
34 +
35 +var CREDENTIALS_REGEXP = /^ *(?:[Bb][Aa][Ss][Ii][Cc]) +([A-Za-z0-9._~+/-]+=*) *$/
36 +
37 +/**
38 + * RegExp for basic auth user/pass
39 + *
40 + * user-pass = userid ":" password
41 + * userid = *<TEXT excluding ":">
42 + * password = *TEXT
43 + * @private
44 + */
45 +
46 +var USER_PASS_REGEXP = /^([^:]*):(.*)$/
47 +
48 +/**
49 + * Parse the Authorization header field of a request.
50 + *
51 + * @param {object} req
52 + * @return {object} with .name and .pass
53 + * @public
54 + */
55 +
56 +function auth (req) {
57 + if (!req) {
58 + throw new TypeError('argument req is required')
59 + }
60 +
61 + if (typeof req !== 'object') {
62 + throw new TypeError('argument req is required to be an object')
63 + }
64 +
65 + // get header
66 + var header = getAuthorization(req)
67 +
68 + // parse header
69 + return parse(header)
70 +}
71 +
72 +/**
73 + * Decode base64 string.
74 + * @private
75 + */
76 +
77 +function decodeBase64 (str) {
78 + return Buffer.from(str, 'base64').toString()
79 +}
80 +
81 +/**
82 + * Get the Authorization header from request object.
83 + * @private
84 + */
85 +
86 +function getAuthorization (req) {
87 + if (!req.headers || typeof req.headers !== 'object') {
88 + throw new TypeError('argument req is required to have headers property')
89 + }
90 +
91 + return req.headers.authorization
92 +}
93 +
94 +/**
95 + * Parse basic auth to object.
96 + *
97 + * @param {string} string
98 + * @return {object}
99 + * @public
100 + */
101 +
102 +function parse (string) {
103 + if (typeof string !== 'string') {
104 + return undefined
105 + }
106 +
107 + // parse header
108 + var match = CREDENTIALS_REGEXP.exec(string)
109 +
110 + if (!match) {
111 + return undefined
112 + }
113 +
114 + // decode user pass
115 + var userPass = USER_PASS_REGEXP.exec(decodeBase64(match[1]))
116 +
117 + if (!userPass) {
118 + return undefined
119 + }
120 +
121 + // return credentials object
122 + return new Credentials(userPass[1], userPass[2])
123 +}
124 +
125 +/**
126 + * Object to represent user credentials.
127 + * @private
128 + */
129 +
130 +function Credentials (name, pass) {
131 + this.name = name
132 + this.pass = pass
133 +}
1 +{
2 + "_from": "basic-auth@~2.0.0",
3 + "_id": "basic-auth@2.0.0",
4 + "_inBundle": false,
5 + "_integrity": "sha1-AV2z81PgLlY3d1X5YnQuiYHnu7o=",
6 + "_location": "/basic-auth",
7 + "_phantomChildren": {},
8 + "_requested": {
9 + "type": "range",
10 + "registry": true,
11 + "raw": "basic-auth@~2.0.0",
12 + "name": "basic-auth",
13 + "escapedName": "basic-auth",
14 + "rawSpec": "~2.0.0",
15 + "saveSpec": null,
16 + "fetchSpec": "~2.0.0"
17 + },
18 + "_requiredBy": [
19 + "/morgan"
20 + ],
21 + "_resolved": "https://registry.npmjs.org/basic-auth/-/basic-auth-2.0.0.tgz",
22 + "_shasum": "015db3f353e02e56377755f962742e8981e7bbba",
23 + "_spec": "basic-auth@~2.0.0",
24 + "_where": "C:\\Users\\지윤\\project_opensource\\node_modules\\morgan",
25 + "bugs": {
26 + "url": "https://github.com/jshttp/basic-auth/issues"
27 + },
28 + "bundleDependencies": false,
29 + "dependencies": {
30 + "safe-buffer": "5.1.1"
31 + },
32 + "deprecated": false,
33 + "description": "node.js basic auth parser",
34 + "devDependencies": {
35 + "eslint": "3.19.0",
36 + "eslint-config-standard": "10.2.1",
37 + "eslint-plugin-import": "2.7.0",
38 + "eslint-plugin-markdown": "1.0.0-beta.6",
39 + "eslint-plugin-node": "5.1.1",
40 + "eslint-plugin-promise": "3.5.0",
41 + "eslint-plugin-standard": "3.0.1",
42 + "istanbul": "0.4.5",
43 + "mocha": "2.5.3"
44 + },
45 + "engines": {
46 + "node": ">= 0.8"
47 + },
48 + "files": [
49 + "HISTORY.md",
50 + "LICENSE",
51 + "index.js"
52 + ],
53 + "homepage": "https://github.com/jshttp/basic-auth#readme",
54 + "keywords": [
55 + "basic",
56 + "auth",
57 + "authorization",
58 + "basicauth"
59 + ],
60 + "license": "MIT",
61 + "name": "basic-auth",
62 + "repository": {
63 + "type": "git",
64 + "url": "git+https://github.com/jshttp/basic-auth.git"
65 + },
66 + "scripts": {
67 + "lint": "eslint --plugin markdown --ext js,md .",
68 + "test": "mocha --check-leaks --reporter spec --bail",
69 + "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/",
70 + "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/"
71 + },
72 + "version": "2.0.0"
73 +}
1 +language: "node_js"
2 +node_js:
3 + - 0.4
4 + - 0.6
5 + - 0.8
6 +
...\ No newline at end of file ...\ No newline at end of file
1 +(The MIT License)
2 +
3 +Copyright (c) 2012-2013 Jared Hanson
4 +
5 +Permission is hereby granted, free of charge, to any person obtaining a copy of
6 +this software and associated documentation files (the "Software"), to deal in
7 +the Software without restriction, including without limitation the rights to
8 +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 +the Software, and to permit persons to whom the Software is furnished to do so,
10 +subject to the following conditions:
11 +
12 +The above copyright notice and this permission notice shall be included in all
13 +copies or substantial portions of the Software.
14 +
15 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1 +# connect-flash
2 +
3 +The flash is a special area of the session used for storing messages. Messages
4 +are written to the flash and cleared after being displayed to the user. The
5 +flash is typically used in combination with redirects, ensuring that the message
6 +is available to the next page that is to be rendered.
7 +
8 +This middleware was extracted from [Express](http://expressjs.com/) 2.x, after
9 +Express 3.x removed direct support for the flash. connect-flash brings this
10 +functionality back to Express 3.x, as well as any other middleware-compatible
11 +framework or application. +1 for [radical reusability](http://substack.net/posts/b96642/the-node-js-aesthetic).
12 +
13 +## Install
14 +
15 + $ npm install connect-flash
16 +
17 +## Usage
18 +
19 +#### Express 3.x
20 +
21 +Flash messages are stored in the session. First, setup sessions as usual by
22 +enabling `cookieParser` and `session` middleware. Then, use `flash` middleware
23 +provided by connect-flash.
24 +
25 +```javascript
26 +var flash = require('connect-flash');
27 +var app = express();
28 +
29 +app.configure(function() {
30 + app.use(express.cookieParser('keyboard cat'));
31 + app.use(express.session({ cookie: { maxAge: 60000 }}));
32 + app.use(flash());
33 +});
34 +```
35 +
36 +With the `flash` middleware in place, all requests will have a `req.flash()` function
37 +that can be used for flash messages.
38 +
39 +```javascript
40 +app.get('/flash', function(req, res){
41 + // Set a flash message by passing the key, followed by the value, to req.flash().
42 + req.flash('info', 'Flash is back!')
43 + res.redirect('/');
44 +});
45 +
46 +app.get('/', function(req, res){
47 + // Get an array of flash messages by passing the key to req.flash()
48 + res.render('index', { messages: req.flash('info') });
49 +});
50 +```
51 +
52 +## Examples
53 +
54 +For an example using connect-flash in an Express 3.x app, refer to the [express3](https://github.com/jaredhanson/connect-flash/tree/master/examples/express3)
55 +example.
56 +
57 +## Tests
58 +
59 + $ npm install --dev
60 + $ make test
61 +
62 +[![Build Status](https://secure.travis-ci.org/jaredhanson/connect-flash.png)](http://travis-ci.org/jaredhanson/connect-flash)
63 +
64 +## Credits
65 +
66 + - [Jared Hanson](http://github.com/jaredhanson)
67 + - [TJ Holowaychuk](https://github.com/visionmedia)
68 +
69 +## License
70 +
71 +[The MIT License](http://opensource.org/licenses/MIT)
72 +
73 +Copyright (c) 2012-2013 Jared Hanson <[http://jaredhanson.net/](http://jaredhanson.net/)>
1 +/**
2 + * Module dependencies.
3 + */
4 +var format = require('util').format;
5 +var isArray = require('util').isArray;
6 +
7 +
8 +/**
9 + * Expose `flash()` function on requests.
10 + *
11 + * @return {Function}
12 + * @api public
13 + */
14 +module.exports = function flash(options) {
15 + options = options || {};
16 + var safe = (options.unsafe === undefined) ? true : !options.unsafe;
17 +
18 + return function(req, res, next) {
19 + if (req.flash && safe) { return next(); }
20 + req.flash = _flash;
21 + next();
22 + }
23 +}
24 +
25 +/**
26 + * Queue flash `msg` of the given `type`.
27 + *
28 + * Examples:
29 + *
30 + * req.flash('info', 'email sent');
31 + * req.flash('error', 'email delivery failed');
32 + * req.flash('info', 'email re-sent');
33 + * // => 2
34 + *
35 + * req.flash('info');
36 + * // => ['email sent', 'email re-sent']
37 + *
38 + * req.flash('info');
39 + * // => []
40 + *
41 + * req.flash();
42 + * // => { error: ['email delivery failed'], info: [] }
43 + *
44 + * Formatting:
45 + *
46 + * Flash notifications also support arbitrary formatting support.
47 + * For example you may pass variable arguments to `req.flash()`
48 + * and use the %s specifier to be replaced by the associated argument:
49 + *
50 + * req.flash('info', 'email has been sent to %s.', userName);
51 + *
52 + * Formatting uses `util.format()`, which is available on Node 0.6+.
53 + *
54 + * @param {String} type
55 + * @param {String} msg
56 + * @return {Array|Object|Number}
57 + * @api public
58 + */
59 +function _flash(type, msg) {
60 + if (this.session === undefined) throw Error('req.flash() requires sessions');
61 + var msgs = this.session.flash = this.session.flash || {};
62 + if (type && msg) {
63 + // util.format is available in Node.js 0.6+
64 + if (arguments.length > 2 && format) {
65 + var args = Array.prototype.slice.call(arguments, 1);
66 + msg = format.apply(undefined, args);
67 + } else if (isArray(msg)) {
68 + msg.forEach(function(val){
69 + (msgs[type] = msgs[type] || []).push(val);
70 + });
71 + return msgs[type].length;
72 + }
73 + return (msgs[type] = msgs[type] || []).push(msg);
74 + } else if (type) {
75 + var arr = msgs[type];
76 + delete msgs[type];
77 + return arr || [];
78 + } else {
79 + this.session.flash = {};
80 + return msgs;
81 + }
82 +}
1 +/**
2 + * Expose middleware.
3 + */
4 +exports = module.exports = require('./flash');
1 +{
2 + "_from": "connect-flash",
3 + "_id": "connect-flash@0.1.1",
4 + "_inBundle": false,
5 + "_integrity": "sha1-2GMPJtlaf4UfmVax6MxnMvO2qjA=",
6 + "_location": "/connect-flash",
7 + "_phantomChildren": {},
8 + "_requested": {
9 + "type": "tag",
10 + "registry": true,
11 + "raw": "connect-flash",
12 + "name": "connect-flash",
13 + "escapedName": "connect-flash",
14 + "rawSpec": "",
15 + "saveSpec": null,
16 + "fetchSpec": "latest"
17 + },
18 + "_requiredBy": [
19 + "#USER",
20 + "/"
21 + ],
22 + "_resolved": "https://registry.npmjs.org/connect-flash/-/connect-flash-0.1.1.tgz",
23 + "_shasum": "d8630f26d95a7f851f9956b1e8cc6732f3b6aa30",
24 + "_spec": "connect-flash",
25 + "_where": "C:\\Users\\지윤\\project_opensource",
26 + "author": {
27 + "name": "Jared Hanson",
28 + "email": "jaredhanson@gmail.com",
29 + "url": "http://www.jaredhanson.net/"
30 + },
31 + "bugs": {
32 + "url": "http://github.com/jaredhanson/connect-flash/issues"
33 + },
34 + "bundleDependencies": false,
35 + "dependencies": {},
36 + "deprecated": false,
37 + "description": "Flash message middleware for Connect.",
38 + "devDependencies": {
39 + "vows": "0.6.x"
40 + },
41 + "engines": {
42 + "node": ">= 0.4.0"
43 + },
44 + "homepage": "https://github.com/jaredhanson/connect-flash#readme",
45 + "keywords": [
46 + "connect",
47 + "express",
48 + "flash",
49 + "messages"
50 + ],
51 + "licenses": [
52 + {
53 + "type": "MIT",
54 + "url": "http://www.opensource.org/licenses/MIT"
55 + }
56 + ],
57 + "main": "./lib",
58 + "name": "connect-flash",
59 + "repository": {
60 + "type": "git",
61 + "url": "git://github.com/jaredhanson/connect-flash.git"
62 + },
63 + "scripts": {
64 + "test": "NODE_PATH=lib node_modules/.bin/vows test/*-test.js"
65 + },
66 + "version": "0.1.1"
67 +}
1 +0.5.2 / 2016-12-08
2 +==================
3 +
4 + * Fix `parse` to accept any linear whitespace character
5 +
6 +0.5.1 / 2016-01-17
7 +==================
8 +
9 + * perf: enable strict mode
10 +
11 +0.5.0 / 2014-10-11
12 +==================
13 +
14 + * Add `parse` function
15 +
16 +0.4.0 / 2014-09-21
17 +==================
18 +
19 + * Expand non-Unicode `filename` to the full ISO-8859-1 charset
20 +
21 +0.3.0 / 2014-09-20
22 +==================
23 +
24 + * Add `fallback` option
25 + * Add `type` option
26 +
27 +0.2.0 / 2014-09-19
28 +==================
29 +
30 + * Reduce ambiguity of file names with hex escape in buggy browsers
31 +
32 +0.1.2 / 2014-09-19
33 +==================
34 +
35 + * Fix periodic invalid Unicode filename header
36 +
37 +0.1.1 / 2014-09-19
38 +==================
39 +
40 + * Fix invalid characters appearing in `filename*` parameter
41 +
42 +0.1.0 / 2014-09-18
43 +==================
44 +
45 + * Make the `filename` argument optional
46 +
47 +0.0.0 / 2014-09-18
48 +==================
49 +
50 + * Initial release
1 +(The MIT License)
2 +
3 +Copyright (c) 2014 Douglas Christopher Wilson
4 +
5 +Permission is hereby granted, free of charge, to any person obtaining
6 +a copy of this software and associated documentation files (the
7 +'Software'), to deal in the Software without restriction, including
8 +without limitation the rights to use, copy, modify, merge, publish,
9 +distribute, sublicense, and/or sell copies of the Software, and to
10 +permit persons to whom the Software is furnished to do so, subject to
11 +the following conditions:
12 +
13 +The above copyright notice and this permission notice shall be
14 +included in all copies or substantial portions of the Software.
15 +
16 +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
17 +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20 +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21 +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22 +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1 +# content-disposition
2 +
3 +[![NPM Version][npm-image]][npm-url]
4 +[![NPM Downloads][downloads-image]][downloads-url]
5 +[![Node.js Version][node-version-image]][node-version-url]
6 +[![Build Status][travis-image]][travis-url]
7 +[![Test Coverage][coveralls-image]][coveralls-url]
8 +
9 +Create and parse HTTP `Content-Disposition` header
10 +
11 +## Installation
12 +
13 +```sh
14 +$ npm install content-disposition
15 +```
16 +
17 +## API
18 +
19 +```js
20 +var contentDisposition = require('content-disposition')
21 +```
22 +
23 +### contentDisposition(filename, options)
24 +
25 +Create an attachment `Content-Disposition` header value using the given file name,
26 +if supplied. The `filename` is optional and if no file name is desired, but you
27 +want to specify `options`, set `filename` to `undefined`.
28 +
29 +```js
30 +res.setHeader('Content-Disposition', contentDisposition('∫ maths.pdf'))
31 +```
32 +
33 +**note** HTTP headers are of the ISO-8859-1 character set. If you are writing this
34 +header through a means different from `setHeader` in Node.js, you'll want to specify
35 +the `'binary'` encoding in Node.js.
36 +
37 +#### Options
38 +
39 +`contentDisposition` accepts these properties in the options object.
40 +
41 +##### fallback
42 +
43 +If the `filename` option is outside ISO-8859-1, then the file name is actually
44 +stored in a supplemental field for clients that support Unicode file names and
45 +a ISO-8859-1 version of the file name is automatically generated.
46 +
47 +This specifies the ISO-8859-1 file name to override the automatic generation or
48 +disables the generation all together, defaults to `true`.
49 +
50 + - A string will specify the ISO-8859-1 file name to use in place of automatic
51 + generation.
52 + - `false` will disable including a ISO-8859-1 file name and only include the
53 + Unicode version (unless the file name is already ISO-8859-1).
54 + - `true` will enable automatic generation if the file name is outside ISO-8859-1.
55 +
56 +If the `filename` option is ISO-8859-1 and this option is specified and has a
57 +different value, then the `filename` option is encoded in the extended field
58 +and this set as the fallback field, even though they are both ISO-8859-1.
59 +
60 +##### type
61 +
62 +Specifies the disposition type, defaults to `"attachment"`. This can also be
63 +`"inline"`, or any other value (all values except inline are treated like
64 +`attachment`, but can convey additional information if both parties agree to
65 +it). The type is normalized to lower-case.
66 +
67 +### contentDisposition.parse(string)
68 +
69 +```js
70 +var disposition = contentDisposition.parse('attachment; filename="EURO rates.txt"; filename*=UTF-8\'\'%e2%82%ac%20rates.txt');
71 +```
72 +
73 +Parse a `Content-Disposition` header string. This automatically handles extended
74 +("Unicode") parameters by decoding them and providing them under the standard
75 +parameter name. This will return an object with the following properties (examples
76 +are shown for the string `'attachment; filename="EURO rates.txt"; filename*=UTF-8\'\'%e2%82%ac%20rates.txt'`):
77 +
78 + - `type`: The disposition type (always lower case). Example: `'attachment'`
79 +
80 + - `parameters`: An object of the parameters in the disposition (name of parameter
81 + always lower case and extended versions replace non-extended versions). Example:
82 + `{filename: "€ rates.txt"}`
83 +
84 +## Examples
85 +
86 +### Send a file for download
87 +
88 +```js
89 +var contentDisposition = require('content-disposition')
90 +var destroy = require('destroy')
91 +var http = require('http')
92 +var onFinished = require('on-finished')
93 +
94 +var filePath = '/path/to/public/plans.pdf'
95 +
96 +http.createServer(function onRequest(req, res) {
97 + // set headers
98 + res.setHeader('Content-Type', 'application/pdf')
99 + res.setHeader('Content-Disposition', contentDisposition(filePath))
100 +
101 + // send file
102 + var stream = fs.createReadStream(filePath)
103 + stream.pipe(res)
104 + onFinished(res, function (err) {
105 + destroy(stream)
106 + })
107 +})
108 +```
109 +
110 +## Testing
111 +
112 +```sh
113 +$ npm test
114 +```
115 +
116 +## References
117 +
118 +- [RFC 2616: Hypertext Transfer Protocol -- HTTP/1.1][rfc-2616]
119 +- [RFC 5987: Character Set and Language Encoding for Hypertext Transfer Protocol (HTTP) Header Field Parameters][rfc-5987]
120 +- [RFC 6266: Use of the Content-Disposition Header Field in the Hypertext Transfer Protocol (HTTP)][rfc-6266]
121 +- [Test Cases for HTTP Content-Disposition header field (RFC 6266) and the Encodings defined in RFCs 2047, 2231 and 5987][tc-2231]
122 +
123 +[rfc-2616]: https://tools.ietf.org/html/rfc2616
124 +[rfc-5987]: https://tools.ietf.org/html/rfc5987
125 +[rfc-6266]: https://tools.ietf.org/html/rfc6266
126 +[tc-2231]: http://greenbytes.de/tech/tc2231/
127 +
128 +## License
129 +
130 +[MIT](LICENSE)
131 +
132 +[npm-image]: https://img.shields.io/npm/v/content-disposition.svg?style=flat
133 +[npm-url]: https://npmjs.org/package/content-disposition
134 +[node-version-image]: https://img.shields.io/node/v/content-disposition.svg?style=flat
135 +[node-version-url]: https://nodejs.org/en/download
136 +[travis-image]: https://img.shields.io/travis/jshttp/content-disposition.svg?style=flat
137 +[travis-url]: https://travis-ci.org/jshttp/content-disposition
138 +[coveralls-image]: https://img.shields.io/coveralls/jshttp/content-disposition.svg?style=flat
139 +[coveralls-url]: https://coveralls.io/r/jshttp/content-disposition?branch=master
140 +[downloads-image]: https://img.shields.io/npm/dm/content-disposition.svg?style=flat
141 +[downloads-url]: https://npmjs.org/package/content-disposition
This diff is collapsed. Click to expand it.
1 +{
2 + "_from": "content-disposition@0.5.2",
3 + "_id": "content-disposition@0.5.2",
4 + "_inBundle": false,
5 + "_integrity": "sha1-DPaLud318r55YcOoUXjLhdunjLQ=",
6 + "_location": "/content-disposition",
7 + "_phantomChildren": {},
8 + "_requested": {
9 + "type": "version",
10 + "registry": true,
11 + "raw": "content-disposition@0.5.2",
12 + "name": "content-disposition",
13 + "escapedName": "content-disposition",
14 + "rawSpec": "0.5.2",
15 + "saveSpec": null,
16 + "fetchSpec": "0.5.2"
17 + },
18 + "_requiredBy": [
19 + "/express"
20 + ],
21 + "_resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.2.tgz",
22 + "_shasum": "0cf68bb9ddf5f2be7961c3a85178cb85dba78cb4",
23 + "_spec": "content-disposition@0.5.2",
24 + "_where": "C:\\Users\\지윤\\project_opensource\\node_modules\\express",
25 + "bugs": {
26 + "url": "https://github.com/jshttp/content-disposition/issues"
27 + },
28 + "bundleDependencies": false,
29 + "contributors": [
30 + {
31 + "name": "Douglas Christopher Wilson",
32 + "email": "doug@somethingdoug.com"
33 + }
34 + ],
35 + "deprecated": false,
36 + "description": "Create and parse Content-Disposition header",
37 + "devDependencies": {
38 + "eslint": "3.11.1",
39 + "eslint-config-standard": "6.2.1",
40 + "eslint-plugin-promise": "3.3.0",
41 + "eslint-plugin-standard": "2.0.1",
42 + "istanbul": "0.4.5",
43 + "mocha": "1.21.5"
44 + },
45 + "engines": {
46 + "node": ">= 0.6"
47 + },
48 + "files": [
49 + "LICENSE",
50 + "HISTORY.md",
51 + "README.md",
52 + "index.js"
53 + ],
54 + "homepage": "https://github.com/jshttp/content-disposition#readme",
55 + "keywords": [
56 + "content-disposition",
57 + "http",
58 + "rfc6266",
59 + "res"
60 + ],
61 + "license": "MIT",
62 + "name": "content-disposition",
63 + "repository": {
64 + "type": "git",
65 + "url": "git+https://github.com/jshttp/content-disposition.git"
66 + },
67 + "scripts": {
68 + "lint": "eslint .",
69 + "test": "mocha --reporter spec --bail --check-leaks test/",
70 + "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/",
71 + "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/"
72 + },
73 + "version": "0.5.2"
74 +}
1 +1.0.4 / 2017-09-11
2 +==================
3 +
4 + * perf: skip parameter parsing when no parameters
5 +
6 +1.0.3 / 2017-09-10
7 +==================
8 +
9 + * perf: remove argument reassignment
10 +
11 +1.0.2 / 2016-05-09
12 +==================
13 +
14 + * perf: enable strict mode
15 +
16 +1.0.1 / 2015-02-13
17 +==================
18 +
19 + * Improve missing `Content-Type` header error message
20 +
21 +1.0.0 / 2015-02-01
22 +==================
23 +
24 + * Initial implementation, derived from `media-typer@0.3.0`
1 +(The MIT License)
2 +
3 +Copyright (c) 2015 Douglas Christopher Wilson
4 +
5 +Permission is hereby granted, free of charge, to any person obtaining
6 +a copy of this software and associated documentation files (the
7 +'Software'), to deal in the Software without restriction, including
8 +without limitation the rights to use, copy, modify, merge, publish,
9 +distribute, sublicense, and/or sell copies of the Software, and to
10 +permit persons to whom the Software is furnished to do so, subject to
11 +the following conditions:
12 +
13 +The above copyright notice and this permission notice shall be
14 +included in all copies or substantial portions of the Software.
15 +
16 +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
17 +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20 +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21 +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22 +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1 +# content-type
2 +
3 +[![NPM Version][npm-image]][npm-url]
4 +[![NPM Downloads][downloads-image]][downloads-url]
5 +[![Node.js Version][node-version-image]][node-version-url]
6 +[![Build Status][travis-image]][travis-url]
7 +[![Test Coverage][coveralls-image]][coveralls-url]
8 +
9 +Create and parse HTTP Content-Type header according to RFC 7231
10 +
11 +## Installation
12 +
13 +```sh
14 +$ npm install content-type
15 +```
16 +
17 +## API
18 +
19 +```js
20 +var contentType = require('content-type')
21 +```
22 +
23 +### contentType.parse(string)
24 +
25 +```js
26 +var obj = contentType.parse('image/svg+xml; charset=utf-8')
27 +```
28 +
29 +Parse a content type string. This will return an object with the following
30 +properties (examples are shown for the string `'image/svg+xml; charset=utf-8'`):
31 +
32 + - `type`: The media type (the type and subtype, always lower case).
33 + Example: `'image/svg+xml'`
34 +
35 + - `parameters`: An object of the parameters in the media type (name of parameter
36 + always lower case). Example: `{charset: 'utf-8'}`
37 +
38 +Throws a `TypeError` if the string is missing or invalid.
39 +
40 +### contentType.parse(req)
41 +
42 +```js
43 +var obj = contentType.parse(req)
44 +```
45 +
46 +Parse the `content-type` header from the given `req`. Short-cut for
47 +`contentType.parse(req.headers['content-type'])`.
48 +
49 +Throws a `TypeError` if the `Content-Type` header is missing or invalid.
50 +
51 +### contentType.parse(res)
52 +
53 +```js
54 +var obj = contentType.parse(res)
55 +```
56 +
57 +Parse the `content-type` header set on the given `res`. Short-cut for
58 +`contentType.parse(res.getHeader('content-type'))`.
59 +
60 +Throws a `TypeError` if the `Content-Type` header is missing or invalid.
61 +
62 +### contentType.format(obj)
63 +
64 +```js
65 +var str = contentType.format({type: 'image/svg+xml'})
66 +```
67 +
68 +Format an object into a content type string. This will return a string of the
69 +content type for the given object with the following properties (examples are
70 +shown that produce the string `'image/svg+xml; charset=utf-8'`):
71 +
72 + - `type`: The media type (will be lower-cased). Example: `'image/svg+xml'`
73 +
74 + - `parameters`: An object of the parameters in the media type (name of the
75 + parameter will be lower-cased). Example: `{charset: 'utf-8'}`
76 +
77 +Throws a `TypeError` if the object contains an invalid type or parameter names.
78 +
79 +## License
80 +
81 +[MIT](LICENSE)
82 +
83 +[npm-image]: https://img.shields.io/npm/v/content-type.svg
84 +[npm-url]: https://npmjs.org/package/content-type
85 +[node-version-image]: https://img.shields.io/node/v/content-type.svg
86 +[node-version-url]: http://nodejs.org/download/
87 +[travis-image]: https://img.shields.io/travis/jshttp/content-type/master.svg
88 +[travis-url]: https://travis-ci.org/jshttp/content-type
89 +[coveralls-image]: https://img.shields.io/coveralls/jshttp/content-type/master.svg
90 +[coveralls-url]: https://coveralls.io/r/jshttp/content-type
91 +[downloads-image]: https://img.shields.io/npm/dm/content-type.svg
92 +[downloads-url]: https://npmjs.org/package/content-type
1 +/*!
2 + * content-type
3 + * Copyright(c) 2015 Douglas Christopher Wilson
4 + * MIT Licensed
5 + */
6 +
7 +'use strict'
8 +
9 +/**
10 + * RegExp to match *( ";" parameter ) in RFC 7231 sec 3.1.1.1
11 + *
12 + * parameter = token "=" ( token / quoted-string )
13 + * token = 1*tchar
14 + * tchar = "!" / "#" / "$" / "%" / "&" / "'" / "*"
15 + * / "+" / "-" / "." / "^" / "_" / "`" / "|" / "~"
16 + * / DIGIT / ALPHA
17 + * ; any VCHAR, except delimiters
18 + * quoted-string = DQUOTE *( qdtext / quoted-pair ) DQUOTE
19 + * qdtext = HTAB / SP / %x21 / %x23-5B / %x5D-7E / obs-text
20 + * obs-text = %x80-FF
21 + * quoted-pair = "\" ( HTAB / SP / VCHAR / obs-text )
22 + */
23 +var PARAM_REGEXP = /; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g
24 +var TEXT_REGEXP = /^[\u000b\u0020-\u007e\u0080-\u00ff]+$/
25 +var TOKEN_REGEXP = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/
26 +
27 +/**
28 + * RegExp to match quoted-pair in RFC 7230 sec 3.2.6
29 + *
30 + * quoted-pair = "\" ( HTAB / SP / VCHAR / obs-text )
31 + * obs-text = %x80-FF
32 + */
33 +var QESC_REGEXP = /\\([\u000b\u0020-\u00ff])/g
34 +
35 +/**
36 + * RegExp to match chars that must be quoted-pair in RFC 7230 sec 3.2.6
37 + */
38 +var QUOTE_REGEXP = /([\\"])/g
39 +
40 +/**
41 + * RegExp to match type in RFC 7231 sec 3.1.1.1
42 + *
43 + * media-type = type "/" subtype
44 + * type = token
45 + * subtype = token
46 + */
47 +var TYPE_REGEXP = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/
48 +
49 +/**
50 + * Module exports.
51 + * @public
52 + */
53 +
54 +exports.format = format
55 +exports.parse = parse
56 +
57 +/**
58 + * Format object to media type.
59 + *
60 + * @param {object} obj
61 + * @return {string}
62 + * @public
63 + */
64 +
65 +function format (obj) {
66 + if (!obj || typeof obj !== 'object') {
67 + throw new TypeError('argument obj is required')
68 + }
69 +
70 + var parameters = obj.parameters
71 + var type = obj.type
72 +
73 + if (!type || !TYPE_REGEXP.test(type)) {
74 + throw new TypeError('invalid type')
75 + }
76 +
77 + var string = type
78 +
79 + // append parameters
80 + if (parameters && typeof parameters === 'object') {
81 + var param
82 + var params = Object.keys(parameters).sort()
83 +
84 + for (var i = 0; i < params.length; i++) {
85 + param = params[i]
86 +
87 + if (!TOKEN_REGEXP.test(param)) {
88 + throw new TypeError('invalid parameter name')
89 + }
90 +
91 + string += '; ' + param + '=' + qstring(parameters[param])
92 + }
93 + }
94 +
95 + return string
96 +}
97 +
98 +/**
99 + * Parse media type to object.
100 + *
101 + * @param {string|object} string
102 + * @return {Object}
103 + * @public
104 + */
105 +
106 +function parse (string) {
107 + if (!string) {
108 + throw new TypeError('argument string is required')
109 + }
110 +
111 + // support req/res-like objects as argument
112 + var header = typeof string === 'object'
113 + ? getcontenttype(string)
114 + : string
115 +
116 + if (typeof header !== 'string') {
117 + throw new TypeError('argument string is required to be a string')
118 + }
119 +
120 + var index = header.indexOf(';')
121 + var type = index !== -1
122 + ? header.substr(0, index).trim()
123 + : header.trim()
124 +
125 + if (!TYPE_REGEXP.test(type)) {
126 + throw new TypeError('invalid media type')
127 + }
128 +
129 + var obj = new ContentType(type.toLowerCase())
130 +
131 + // parse parameters
132 + if (index !== -1) {
133 + var key
134 + var match
135 + var value
136 +
137 + PARAM_REGEXP.lastIndex = index
138 +
139 + while ((match = PARAM_REGEXP.exec(header))) {
140 + if (match.index !== index) {
141 + throw new TypeError('invalid parameter format')
142 + }
143 +
144 + index += match[0].length
145 + key = match[1].toLowerCase()
146 + value = match[2]
147 +
148 + if (value[0] === '"') {
149 + // remove quotes and escapes
150 + value = value
151 + .substr(1, value.length - 2)
152 + .replace(QESC_REGEXP, '$1')
153 + }
154 +
155 + obj.parameters[key] = value
156 + }
157 +
158 + if (index !== header.length) {
159 + throw new TypeError('invalid parameter format')
160 + }
161 + }
162 +
163 + return obj
164 +}
165 +
166 +/**
167 + * Get content-type from req/res objects.
168 + *
169 + * @param {object}
170 + * @return {Object}
171 + * @private
172 + */
173 +
174 +function getcontenttype (obj) {
175 + var header
176 +
177 + if (typeof obj.getHeader === 'function') {
178 + // res-like
179 + header = obj.getHeader('content-type')
180 + } else if (typeof obj.headers === 'object') {
181 + // req-like
182 + header = obj.headers && obj.headers['content-type']
183 + }
184 +
185 + if (typeof header !== 'string') {
186 + throw new TypeError('content-type header is missing from object')
187 + }
188 +
189 + return header
190 +}
191 +
192 +/**
193 + * Quote a string if necessary.
194 + *
195 + * @param {string} val
196 + * @return {string}
197 + * @private
198 + */
199 +
200 +function qstring (val) {
201 + var str = String(val)
202 +
203 + // no need to quote tokens
204 + if (TOKEN_REGEXP.test(str)) {
205 + return str
206 + }
207 +
208 + if (str.length > 0 && !TEXT_REGEXP.test(str)) {
209 + throw new TypeError('invalid parameter value')
210 + }
211 +
212 + return '"' + str.replace(QUOTE_REGEXP, '\\$1') + '"'
213 +}
214 +
215 +/**
216 + * Class to represent a content type.
217 + * @private
218 + */
219 +function ContentType (type) {
220 + this.parameters = Object.create(null)
221 + this.type = type
222 +}
1 +{
2 + "_from": "content-type@~1.0.2",
3 + "_id": "content-type@1.0.4",
4 + "_inBundle": false,
5 + "_integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==",
6 + "_location": "/content-type",
7 + "_phantomChildren": {},
8 + "_requested": {
9 + "type": "range",
10 + "registry": true,
11 + "raw": "content-type@~1.0.2",
12 + "name": "content-type",
13 + "escapedName": "content-type",
14 + "rawSpec": "~1.0.2",
15 + "saveSpec": null,
16 + "fetchSpec": "~1.0.2"
17 + },
18 + "_requiredBy": [
19 + "/express"
20 + ],
21 + "_resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz",
22 + "_shasum": "e138cc75e040c727b1966fe5e5f8c9aee256fe3b",
23 + "_spec": "content-type@~1.0.2",
24 + "_where": "C:\\Users\\지윤\\project_opensource\\node_modules\\express",
25 + "author": {
26 + "name": "Douglas Christopher Wilson",
27 + "email": "doug@somethingdoug.com"
28 + },
29 + "bugs": {
30 + "url": "https://github.com/jshttp/content-type/issues"
31 + },
32 + "bundleDependencies": false,
33 + "deprecated": false,
34 + "description": "Create and parse HTTP Content-Type header",
35 + "devDependencies": {
36 + "eslint": "3.19.0",
37 + "eslint-config-standard": "10.2.1",
38 + "eslint-plugin-import": "2.7.0",
39 + "eslint-plugin-node": "5.1.1",
40 + "eslint-plugin-promise": "3.5.0",
41 + "eslint-plugin-standard": "3.0.1",
42 + "istanbul": "0.4.5",
43 + "mocha": "~1.21.5"
44 + },
45 + "engines": {
46 + "node": ">= 0.6"
47 + },
48 + "files": [
49 + "LICENSE",
50 + "HISTORY.md",
51 + "README.md",
52 + "index.js"
53 + ],
54 + "homepage": "https://github.com/jshttp/content-type#readme",
55 + "keywords": [
56 + "content-type",
57 + "http",
58 + "req",
59 + "res",
60 + "rfc7231"
61 + ],
62 + "license": "MIT",
63 + "name": "content-type",
64 + "repository": {
65 + "type": "git",
66 + "url": "git+https://github.com/jshttp/content-type.git"
67 + },
68 + "scripts": {
69 + "lint": "eslint .",
70 + "test": "mocha --reporter spec --check-leaks --bail test/",
71 + "test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/",
72 + "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/"
73 + },
74 + "version": "1.0.4"
75 +}
1 +1.4.3 / 2016-05-26
2 +==================
3 +
4 + * deps: cookie@0.3.1
5 + - perf: use for loop in parse
6 +
7 +1.4.2 / 2016-05-20
8 +==================
9 +
10 + * deps: cookie@0.2.4
11 + - perf: enable strict mode
12 + - perf: use for loop in parse
13 + - perf: use string concatination for serialization
14 +
15 +1.4.1 / 2016-01-11
16 +==================
17 +
18 + * deps: cookie@0.2.3
19 + * perf: enable strict mode
20 +
21 +1.4.0 / 2015-09-18
22 +==================
23 +
24 + * Accept array of secrets in addition to a single secret
25 + * Fix `JSONCookie` to return `undefined` for non-string arguments
26 + * Fix `signedCookie` to return `undefined` for non-string arguments
27 + * deps: cookie@0.2.2
28 +
29 +1.3.5 / 2015-05-19
30 +==================
31 +
32 + * deps: cookie@0.1.3
33 + - Slight optimizations
34 +
35 +1.3.4 / 2015-02-15
36 +==================
37 +
38 + * deps: cookie-signature@1.0.6
39 +
40 +1.3.3 / 2014-09-05
41 +==================
42 +
43 + * deps: cookie-signature@1.0.5
44 +
45 +1.3.2 / 2014-06-26
46 +==================
47 +
48 + * deps: cookie-signature@1.0.4
49 + - fix for timing attacks
50 +
51 +1.3.1 / 2014-06-17
52 +==================
53 +
54 + * actually export `signedCookie`
55 +
56 +1.3.0 / 2014-06-17
57 +==================
58 +
59 + * add `signedCookie` export for single cookie unsigning
60 +
61 +1.2.0 / 2014-06-17
62 +==================
63 +
64 + * export parsing functions
65 + * `req.cookies` and `req.signedCookies` are now plain objects
66 + * slightly faster parsing of many cookies
67 +
68 +1.1.0 / 2014-05-12
69 +==================
70 +
71 + * Support for NodeJS version 0.8
72 + * deps: cookie@0.1.2
73 + - Fix for maxAge == 0
74 + - made compat with expires field
75 + - tweak maxAge NaN error message
76 +
77 +1.0.1 / 2014-02-20
78 +==================
79 +
80 + * add missing dependencies
81 +
82 +1.0.0 / 2014-02-15
83 +==================
84 +
85 + * Genesis from `connect`
1 +(The MIT License)
2 +
3 +Copyright (c) 2014 TJ Holowaychuk <tj@vision-media.ca>
4 +Copyright (c) 2015 Douglas Christopher Wilson <doug@somethingdoug.com>
5 +
6 +Permission is hereby granted, free of charge, to any person obtaining
7 +a copy of this software and associated documentation files (the
8 +'Software'), to deal in the Software without restriction, including
9 +without limitation the rights to use, copy, modify, merge, publish,
10 +distribute, sublicense, and/or sell copies of the Software, and to
11 +permit persons to whom the Software is furnished to do so, subject to
12 +the following conditions:
13 +
14 +The above copyright notice and this permission notice shall be
15 +included in all copies or substantial portions of the Software.
16 +
17 +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
18 +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1 +# cookie-parser
2 +
3 +[![NPM Version][npm-image]][npm-url]
4 +[![NPM Downloads][downloads-image]][downloads-url]
5 +[![Node.js Version][node-version-image]][node-version-url]
6 +[![Build Status][travis-image]][travis-url]
7 +[![Test Coverage][coveralls-image]][coveralls-url]
8 +
9 +Parse `Cookie` header and populate `req.cookies` with an object keyed by the cookie
10 +names. Optionally you may enable signed cookie support by passing a `secret` string,
11 +which assigns `req.secret` so it may be used by other middleware.
12 +
13 +## Installation
14 +
15 +```sh
16 +$ npm install cookie-parser
17 +```
18 +
19 +## API
20 +
21 +```js
22 +var express = require('express')
23 +var cookieParser = require('cookie-parser')
24 +
25 +var app = express()
26 +app.use(cookieParser())
27 +```
28 +
29 +### cookieParser(secret, options)
30 +
31 +- `secret` a string or array used for signing cookies. This is optional and if not specified, will not parse signed cookies. If a string is provided, this is used as the secret. If an array is provided, an attempt will be made to unsign the cookie with each secret in order.
32 +- `options` an object that is passed to `cookie.parse` as the second option. See [cookie](https://www.npmjs.org/package/cookie) for more information.
33 + - `decode` a function to decode the value of the cookie
34 +
35 +### cookieParser.JSONCookie(str)
36 +
37 +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.
38 +
39 +### cookieParser.JSONCookies(cookies)
40 +
41 +Given an object, this will iterate over the keys and call `JSONCookie` on each value. This will return the same object passed in.
42 +
43 +### cookieParser.signedCookie(str, secret)
44 +
45 +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.
46 +
47 +The `secret` argument can be an array or string. If a string is provided, this is used as the secret. If an array is provided, an attempt will be made to unsign the cookie with each secret in order.
48 +
49 +### cookieParser.signedCookies(cookies, secret)
50 +
51 +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.
52 +
53 +The `secret` argument can be an array or string. If a string is provided, this is used as the secret. If an array is provided, an attempt will be made to unsign the cookie with each secret in order.
54 +
55 +## Example
56 +
57 +```js
58 +var express = require('express')
59 +var cookieParser = require('cookie-parser')
60 +
61 +var app = express()
62 +app.use(cookieParser())
63 +
64 +app.get('/', function(req, res) {
65 + console.log('Cookies: ', req.cookies)
66 +})
67 +
68 +app.listen(8080)
69 +
70 +// curl command that sends an HTTP request with two cookies
71 +// curl http://127.0.0.1:8080 --cookie "Cho=Kim;Greet=Hello"
72 +```
73 +
74 +### [MIT Licensed](LICENSE)
75 +
76 +[npm-image]: https://img.shields.io/npm/v/cookie-parser.svg
77 +[npm-url]: https://npmjs.org/package/cookie-parser
78 +[node-version-image]: https://img.shields.io/node/v/cookie-parser.svg
79 +[node-version-url]: https://nodejs.org/en/download
80 +[travis-image]: https://img.shields.io/travis/expressjs/cookie-parser/master.svg
81 +[travis-url]: https://travis-ci.org/expressjs/cookie-parser
82 +[coveralls-image]: https://img.shields.io/coveralls/expressjs/cookie-parser/master.svg
83 +[coveralls-url]: https://coveralls.io/r/expressjs/cookie-parser?branch=master
84 +[downloads-image]: https://img.shields.io/npm/dm/cookie-parser.svg
85 +[downloads-url]: https://npmjs.org/package/cookie-parser
1 +/*!
2 + * cookie-parser
3 + * Copyright(c) 2014 TJ Holowaychuk
4 + * Copyright(c) 2015 Douglas Christopher Wilson
5 + * MIT Licensed
6 + */
7 +
8 +'use strict';
9 +
10 +/**
11 + * Module dependencies.
12 + * @private
13 + */
14 +
15 +var cookie = require('cookie');
16 +var signature = require('cookie-signature');
17 +
18 +/**
19 + * Module exports.
20 + * @public
21 + */
22 +
23 +module.exports = cookieParser;
24 +module.exports.JSONCookie = JSONCookie;
25 +module.exports.JSONCookies = JSONCookies;
26 +module.exports.signedCookie = signedCookie;
27 +module.exports.signedCookies = signedCookies;
28 +
29 +/**
30 + * Parse Cookie header and populate `req.cookies`
31 + * with an object keyed by the cookie names.
32 + *
33 + * @param {string|array} [secret] A string (or array of strings) representing cookie signing secret(s).
34 + * @param {Object} [options]
35 + * @return {Function}
36 + * @public
37 + */
38 +
39 +function cookieParser(secret, options) {
40 + return function cookieParser(req, res, next) {
41 + if (req.cookies) {
42 + return next();
43 + }
44 +
45 + var cookies = req.headers.cookie;
46 + var secrets = !secret || Array.isArray(secret)
47 + ? (secret || [])
48 + : [secret];
49 +
50 + req.secret = secrets[0];
51 + req.cookies = Object.create(null);
52 + req.signedCookies = Object.create(null);
53 +
54 + // no cookies
55 + if (!cookies) {
56 + return next();
57 + }
58 +
59 + req.cookies = cookie.parse(cookies, options);
60 +
61 + // parse signed cookies
62 + if (secrets.length !== 0) {
63 + req.signedCookies = signedCookies(req.cookies, secrets);
64 + req.signedCookies = JSONCookies(req.signedCookies);
65 + }
66 +
67 + // parse JSON cookies
68 + req.cookies = JSONCookies(req.cookies);
69 +
70 + next();
71 + };
72 +}
73 +
74 +/**
75 + * Parse JSON cookie string.
76 + *
77 + * @param {String} str
78 + * @return {Object} Parsed object or undefined if not json cookie
79 + * @public
80 + */
81 +
82 +function JSONCookie(str) {
83 + if (typeof str !== 'string' || str.substr(0, 2) !== 'j:') {
84 + return undefined;
85 + }
86 +
87 + try {
88 + return JSON.parse(str.slice(2));
89 + } catch (err) {
90 + return undefined;
91 + }
92 +}
93 +
94 +/**
95 + * Parse JSON cookies.
96 + *
97 + * @param {Object} obj
98 + * @return {Object}
99 + * @public
100 + */
101 +
102 +function JSONCookies(obj) {
103 + var cookies = Object.keys(obj);
104 + var key;
105 + var val;
106 +
107 + for (var i = 0; i < cookies.length; i++) {
108 + key = cookies[i];
109 + val = JSONCookie(obj[key]);
110 +
111 + if (val) {
112 + obj[key] = val;
113 + }
114 + }
115 +
116 + return obj;
117 +}
118 +
119 +/**
120 + * Parse a signed cookie string, return the decoded value.
121 + *
122 + * @param {String} str signed cookie string
123 + * @param {string|array} secret
124 + * @return {String} decoded value
125 + * @public
126 + */
127 +
128 +function signedCookie(str, secret) {
129 + if (typeof str !== 'string') {
130 + return undefined;
131 + }
132 +
133 + if (str.substr(0, 2) !== 's:') {
134 + return str;
135 + }
136 +
137 + var secrets = !secret || Array.isArray(secret)
138 + ? (secret || [])
139 + : [secret];
140 +
141 + for (var i = 0; i < secrets.length; i++) {
142 + var val = signature.unsign(str.slice(2), secrets[i]);
143 +
144 + if (val !== false) {
145 + return val;
146 + }
147 + }
148 +
149 + return false;
150 +}
151 +
152 +/**
153 + * Parse signed cookies, returning an object containing the decoded key/value
154 + * pairs, while removing the signed key from obj.
155 + *
156 + * @param {Object} obj
157 + * @param {string|array} secret
158 + * @return {Object}
159 + * @public
160 + */
161 +
162 +function signedCookies(obj, secret) {
163 + var cookies = Object.keys(obj);
164 + var dec;
165 + var key;
166 + var ret = Object.create(null);
167 + var val;
168 +
169 + for (var i = 0; i < cookies.length; i++) {
170 + key = cookies[i];
171 + val = obj[key];
172 + dec = signedCookie(val, secret);
173 +
174 + if (val !== dec) {
175 + ret[key] = dec;
176 + delete obj[key];
177 + }
178 + }
179 +
180 + return ret;
181 +}
1 +{
2 + "_from": "cookie-parser@~1.4.3",
3 + "_id": "cookie-parser@1.4.3",
4 + "_inBundle": false,
5 + "_integrity": "sha1-D+MfoZ0AC5X0qt8fU/3CuKIDuqU=",
6 + "_location": "/cookie-parser",
7 + "_phantomChildren": {},
8 + "_requested": {
9 + "type": "range",
10 + "registry": true,
11 + "raw": "cookie-parser@~1.4.3",
12 + "name": "cookie-parser",
13 + "escapedName": "cookie-parser",
14 + "rawSpec": "~1.4.3",
15 + "saveSpec": null,
16 + "fetchSpec": "~1.4.3"
17 + },
18 + "_requiredBy": [
19 + "#USER",
20 + "/"
21 + ],
22 + "_resolved": "https://registry.npmjs.org/cookie-parser/-/cookie-parser-1.4.3.tgz",
23 + "_shasum": "0fe31fa19d000b95f4aadf1f53fdc2b8a203baa5",
24 + "_spec": "cookie-parser@~1.4.3",
25 + "_where": "C:\\Users\\지윤\\project_opensource",
26 + "author": {
27 + "name": "TJ Holowaychuk",
28 + "email": "tj@vision-media.ca",
29 + "url": "http://tjholowaychuk.com"
30 + },
31 + "bugs": {
32 + "url": "https://github.com/expressjs/cookie-parser/issues"
33 + },
34 + "bundleDependencies": false,
35 + "contributors": [
36 + {
37 + "name": "Douglas Christopher Wilson",
38 + "email": "doug@somethingdoug.com"
39 + }
40 + ],
41 + "dependencies": {
42 + "cookie": "0.3.1",
43 + "cookie-signature": "1.0.6"
44 + },
45 + "deprecated": false,
46 + "description": "cookie parsing with signatures",
47 + "devDependencies": {
48 + "istanbul": "0.4.3",
49 + "mocha": "2.5.3",
50 + "supertest": "1.1.0"
51 + },
52 + "engines": {
53 + "node": ">= 0.8.0"
54 + },
55 + "files": [
56 + "LICENSE",
57 + "HISTORY.md",
58 + "index.js"
59 + ],
60 + "homepage": "https://github.com/expressjs/cookie-parser#readme",
61 + "keywords": [
62 + "cookie",
63 + "middleware"
64 + ],
65 + "license": "MIT",
66 + "name": "cookie-parser",
67 + "repository": {
68 + "type": "git",
69 + "url": "git+https://github.com/expressjs/cookie-parser.git"
70 + },
71 + "scripts": {
72 + "test": "mocha --reporter spec --bail --check-leaks test/",
73 + "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/",
74 + "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/"
75 + },
76 + "version": "1.4.3"
77 +}
1 +support
2 +test
3 +examples
4 +*.sock
1 +1.0.6 / 2015-02-03
2 +==================
3 +
4 +* use `npm test` instead of `make test` to run tests
5 +* clearer assertion messages when checking input
6 +
7 +
8 +1.0.5 / 2014-09-05
9 +==================
10 +
11 +* add license to package.json
12 +
13 +1.0.4 / 2014-06-25
14 +==================
15 +
16 + * corrected avoidance of timing attacks (thanks @tenbits!)
17 +
18 +1.0.3 / 2014-01-28
19 +==================
20 +
21 + * [incorrect] fix for timing attacks
22 +
23 +1.0.2 / 2014-01-28
24 +==================
25 +
26 + * fix missing repository warning
27 + * fix typo in test
28 +
29 +1.0.1 / 2013-04-15
30 +==================
31 +
32 + * Revert "Changed underlying HMAC algo. to sha512."
33 + * Revert "Fix for timing attacks on MAC verification."
34 +
35 +0.0.1 / 2010-01-03
36 +==================
37 +
38 + * Initial release
1 +
2 +# cookie-signature
3 +
4 + Sign and unsign cookies.
5 +
6 +## Example
7 +
8 +```js
9 +var cookie = require('cookie-signature');
10 +
11 +var val = cookie.sign('hello', 'tobiiscool');
12 +val.should.equal('hello.DGDUkGlIkCzPz+C0B064FNgHdEjox7ch8tOBGslZ5QI');
13 +
14 +var val = cookie.sign('hello', 'tobiiscool');
15 +cookie.unsign(val, 'tobiiscool').should.equal('hello');
16 +cookie.unsign(val, 'luna').should.be.false;
17 +```
18 +
19 +## License
20 +
21 +(The MIT License)
22 +
23 +Copyright (c) 2012 LearnBoost &lt;tj@learnboost.com&gt;
24 +
25 +Permission is hereby granted, free of charge, to any person obtaining
26 +a copy of this software and associated documentation files (the
27 +'Software'), to deal in the Software without restriction, including
28 +without limitation the rights to use, copy, modify, merge, publish,
29 +distribute, sublicense, and/or sell copies of the Software, and to
30 +permit persons to whom the Software is furnished to do so, subject to
31 +the following conditions:
32 +
33 +The above copyright notice and this permission notice shall be
34 +included in all copies or substantial portions of the Software.
35 +
36 +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
37 +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
38 +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
39 +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
40 +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
41 +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
42 +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
...\ No newline at end of file ...\ No newline at end of file
1 +/**
2 + * Module dependencies.
3 + */
4 +
5 +var crypto = require('crypto');
6 +
7 +/**
8 + * Sign the given `val` with `secret`.
9 + *
10 + * @param {String} val
11 + * @param {String} secret
12 + * @return {String}
13 + * @api private
14 + */
15 +
16 +exports.sign = function(val, secret){
17 + if ('string' != typeof val) throw new TypeError("Cookie value must be provided as a string.");
18 + if ('string' != typeof secret) throw new TypeError("Secret string must be provided.");
19 + return val + '.' + crypto
20 + .createHmac('sha256', secret)
21 + .update(val)
22 + .digest('base64')
23 + .replace(/\=+$/, '');
24 +};
25 +
26 +/**
27 + * Unsign and decode the given `val` with `secret`,
28 + * returning `false` if the signature is invalid.
29 + *
30 + * @param {String} val
31 + * @param {String} secret
32 + * @return {String|Boolean}
33 + * @api private
34 + */
35 +
36 +exports.unsign = function(val, secret){
37 + if ('string' != typeof val) throw new TypeError("Signed cookie string must be provided.");
38 + if ('string' != typeof secret) throw new TypeError("Secret string must be provided.");
39 + var str = val.slice(0, val.lastIndexOf('.'))
40 + , mac = exports.sign(str, secret);
41 +
42 + return sha1(mac) == sha1(val) ? str : false;
43 +};
44 +
45 +/**
46 + * Private
47 + */
48 +
49 +function sha1(str){
50 + return crypto.createHash('sha1').update(str).digest('hex');
51 +}
1 +{
2 + "_from": "cookie-signature@1.0.6",
3 + "_id": "cookie-signature@1.0.6",
4 + "_inBundle": false,
5 + "_integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw=",
6 + "_location": "/cookie-signature",
7 + "_phantomChildren": {},
8 + "_requested": {
9 + "type": "version",
10 + "registry": true,
11 + "raw": "cookie-signature@1.0.6",
12 + "name": "cookie-signature",
13 + "escapedName": "cookie-signature",
14 + "rawSpec": "1.0.6",
15 + "saveSpec": null,
16 + "fetchSpec": "1.0.6"
17 + },
18 + "_requiredBy": [
19 + "/cookie-parser"
20 + ],
21 + "_resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz",
22 + "_shasum": "e303a882b342cc3ee8ca513a79999734dab3ae2c",
23 + "_spec": "cookie-signature@1.0.6",
24 + "_where": "C:\\Users\\지윤\\project_opensource\\node_modules\\cookie-parser",
25 + "author": {
26 + "name": "TJ Holowaychuk",
27 + "email": "tj@learnboost.com"
28 + },
29 + "bugs": {
30 + "url": "https://github.com/visionmedia/node-cookie-signature/issues"
31 + },
32 + "bundleDependencies": false,
33 + "dependencies": {},
34 + "deprecated": false,
35 + "description": "Sign and unsign cookies",
36 + "devDependencies": {
37 + "mocha": "*",
38 + "should": "*"
39 + },
40 + "homepage": "https://github.com/visionmedia/node-cookie-signature#readme",
41 + "keywords": [
42 + "cookie",
43 + "sign",
44 + "unsign"
45 + ],
46 + "license": "MIT",
47 + "main": "index",
48 + "name": "cookie-signature",
49 + "repository": {
50 + "type": "git",
51 + "url": "git+https://github.com/visionmedia/node-cookie-signature.git"
52 + },
53 + "scripts": {
54 + "test": "mocha --require should --reporter spec"
55 + },
56 + "version": "1.0.6"
57 +}
1 +0.3.1 / 2016-05-26
2 +==================
3 +
4 + * Fix `sameSite: true` to work with draft-7 clients
5 + - `true` now sends `SameSite=Strict` instead of `SameSite`
6 +
7 +0.3.0 / 2016-05-26
8 +==================
9 +
10 + * Add `sameSite` option
11 + - Replaces `firstPartyOnly` option, never implemented by browsers
12 + * Improve error message when `encode` is not a function
13 + * Improve error message when `expires` is not a `Date`
14 +
15 +0.2.4 / 2016-05-20
16 +==================
17 +
18 + * perf: enable strict mode
19 + * perf: use for loop in parse
20 + * perf: use string concatination for serialization
21 +
22 +0.2.3 / 2015-10-25
23 +==================
24 +
25 + * Fix cookie `Max-Age` to never be a floating point number
26 +
27 +0.2.2 / 2015-09-17
28 +==================
29 +
30 + * Fix regression when setting empty cookie value
31 + - Ease the new restriction, which is just basic header-level validation
32 + * Fix typo in invalid value errors
33 +
34 +0.2.1 / 2015-09-17
35 +==================
36 +
37 + * Throw on invalid values provided to `serialize`
38 + - Ensures the resulting string is a valid HTTP header value
39 +
40 +0.2.0 / 2015-08-13
41 +==================
42 +
43 + * Add `firstPartyOnly` option
44 + * Throw better error for invalid argument to parse
45 + * perf: hoist regular expression
46 +
47 +0.1.5 / 2015-09-17
48 +==================
49 +
50 + * Fix regression when setting empty cookie value
51 + - Ease the new restriction, which is just basic header-level validation
52 + * Fix typo in invalid value errors
53 +
54 +0.1.4 / 2015-09-17
55 +==================
56 +
57 + * Throw better error for invalid argument to parse
58 + * Throw on invalid values provided to `serialize`
59 + - Ensures the resulting string is a valid HTTP header value
60 +
61 +0.1.3 / 2015-05-19
62 +==================
63 +
64 + * Reduce the scope of try-catch deopt
65 + * Remove argument reassignments
66 +
67 +0.1.2 / 2014-04-16
68 +==================
69 +
70 + * Remove unnecessary files from npm package
71 +
72 +0.1.1 / 2014-02-23
73 +==================
74 +
75 + * Fix bad parse when cookie value contained a comma
76 + * Fix support for `maxAge` of `0`
77 +
78 +0.1.0 / 2013-05-01
79 +==================
80 +
81 + * Add `decode` option
82 + * Add `encode` option
83 +
84 +0.0.6 / 2013-04-08
85 +==================
86 +
87 + * Ignore cookie parts missing `=`
88 +
89 +0.0.5 / 2012-10-29
90 +==================
91 +
92 + * Return raw cookie value if value unescape errors
93 +
94 +0.0.4 / 2012-06-21
95 +==================
96 +
97 + * Use encode/decodeURIComponent for cookie encoding/decoding
98 + - Improve server/client interoperability
99 +
100 +0.0.3 / 2012-06-06
101 +==================
102 +
103 + * Only escape special characters per the cookie RFC
104 +
105 +0.0.2 / 2012-06-01
106 +==================
107 +
108 + * Fix `maxAge` option to not throw error
109 +
110 +0.0.1 / 2012-05-28
111 +==================
112 +
113 + * Add more tests
114 +
115 +0.0.0 / 2012-05-28
116 +==================
117 +
118 + * Initial release
1 +(The MIT License)
2 +
3 +Copyright (c) 2012-2014 Roman Shtylman <shtylman@gmail.com>
4 +Copyright (c) 2015 Douglas Christopher Wilson <doug@somethingdoug.com>
5 +
6 +Permission is hereby granted, free of charge, to any person obtaining
7 +a copy of this software and associated documentation files (the
8 +'Software'), to deal in the Software without restriction, including
9 +without limitation the rights to use, copy, modify, merge, publish,
10 +distribute, sublicense, and/or sell copies of the Software, and to
11 +permit persons to whom the Software is furnished to do so, subject to
12 +the following conditions:
13 +
14 +The above copyright notice and this permission notice shall be
15 +included in all copies or substantial portions of the Software.
16 +
17 +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
18 +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 +
1 +# cookie
2 +
3 +[![NPM Version][npm-image]][npm-url]
4 +[![NPM Downloads][downloads-image]][downloads-url]
5 +[![Node.js Version][node-version-image]][node-version-url]
6 +[![Build Status][travis-image]][travis-url]
7 +[![Test Coverage][coveralls-image]][coveralls-url]
8 +
9 +Basic HTTP cookie parser and serializer for HTTP servers.
10 +
11 +## Installation
12 +
13 +```sh
14 +$ npm install cookie
15 +```
16 +
17 +## API
18 +
19 +```js
20 +var cookie = require('cookie');
21 +```
22 +
23 +### cookie.parse(str, options)
24 +
25 +Parse an HTTP `Cookie` header string and returning an object of all cookie name-value pairs.
26 +The `str` argument is the string representing a `Cookie` header value and `options` is an
27 +optional object containing additional parsing options.
28 +
29 +```js
30 +var cookies = cookie.parse('foo=bar; equation=E%3Dmc%5E2');
31 +// { foo: 'bar', equation: 'E=mc^2' }
32 +```
33 +
34 +#### Options
35 +
36 +`cookie.parse` accepts these properties in the options object.
37 +
38 +##### decode
39 +
40 +Specifies a function that will be used to decode a cookie's value. Since the value of a cookie
41 +has a limited character set (and must be a simple string), this function can be used to decode
42 +a previously-encoded cookie value into a JavaScript string or other object.
43 +
44 +The default function is the global `decodeURIComponent`, which will decode any URL-encoded
45 +sequences into their byte representations.
46 +
47 +**note** if an error is thrown from this function, the original, non-decoded cookie value will
48 +be returned as the cookie's value.
49 +
50 +### cookie.serialize(name, value, options)
51 +
52 +Serialize a cookie name-value pair into a `Set-Cookie` header string. The `name` argument is the
53 +name for the cookie, the `value` argument is the value to set the cookie to, and the `options`
54 +argument is an optional object containing additional serialization options.
55 +
56 +```js
57 +var setCookie = cookie.serialize('foo', 'bar');
58 +// foo=bar
59 +```
60 +
61 +#### Options
62 +
63 +`cookie.serialize` accepts these properties in the options object.
64 +
65 +##### domain
66 +
67 +Specifies the value for the [`Domain` `Set-Cookie` attribute][rfc-6266-5.2.3]. By default, no
68 +domain is set, and most clients will consider the cookie to apply to only the current domain.
69 +
70 +##### encode
71 +
72 +Specifies a function that will be used to encode a cookie's value. Since value of a cookie
73 +has a limited character set (and must be a simple string), this function can be used to encode
74 +a value into a string suited for a cookie's value.
75 +
76 +The default function is the global `ecodeURIComponent`, which will encode a JavaScript string
77 +into UTF-8 byte sequences and then URL-encode any that fall outside of the cookie range.
78 +
79 +##### expires
80 +
81 +Specifies the `Date` object to be the value for the [`Expires` `Set-Cookie` attribute][rfc-6266-5.2.1].
82 +By default, no expiration is set, and most clients will consider this a "non-persistent cookie" and
83 +will delete it on a condition like exiting a web browser application.
84 +
85 +**note** the [cookie storage model specification][rfc-6266-5.3] states that if both `expires` and
86 +`magAge` are set, then `maxAge` takes precedence, but it is possiblke not all clients by obey this,
87 +so if both are set, they should point to the same date and time.
88 +
89 +##### httpOnly
90 +
91 +Specifies the `boolean` value for the [`HttpOnly` `Set-Cookie` attribute][rfc-6266-5.2.6]. When truthy,
92 +the `HttpOnly` attribute is set, otherwise it is not. By default, the `HttpOnly` attribute is not set.
93 +
94 +**note** be careful when setting this to `true`, as compliant clients will not allow client-side
95 +JavaScript to see the cookie in `document.cookie`.
96 +
97 +##### maxAge
98 +
99 +Specifies the `number` (in seconds) to be the value for the [`Max-Age` `Set-Cookie` attribute][rfc-6266-5.2.2].
100 +The given number will be converted to an integer by rounding down. By default, no maximum age is set.
101 +
102 +**note** the [cookie storage model specification][rfc-6266-5.3] states that if both `expires` and
103 +`magAge` are set, then `maxAge` takes precedence, but it is possiblke not all clients by obey this,
104 +so if both are set, they should point to the same date and time.
105 +
106 +##### path
107 +
108 +Specifies the value for the [`Path` `Set-Cookie` attribute][rfc-6266-5.2.4]. By default, the path
109 +is considered the ["default path"][rfc-6266-5.1.4]. By default, no maximum age is set, and most
110 +clients will consider this a "non-persistent cookie" and will delete it on a condition like exiting
111 +a web browser application.
112 +
113 +##### sameSite
114 +
115 +Specifies the `boolean` or `string` to be the value for the [`SameSite` `Set-Cookie` attribute][draft-west-first-party-cookies-07].
116 +
117 + - `true` will set the `SameSite` attribute to `Strict` for strict same site enforcement.
118 + - `false` will not set the `SameSite` attribute.
119 + - `'lax'` will set the `SameSite` attribute to `Lax` for lax same site enforcement.
120 + - `'strict'` will set the `SameSite` attribute to `Strict` for strict same site enforcement.
121 +
122 +More information about the different enforcement levels can be found in the specification
123 +https://tools.ietf.org/html/draft-west-first-party-cookies-07#section-4.1.1
124 +
125 +**note** This is an attribute that has not yet been fully standardized, and may change in the future.
126 +This also means many clients may ignore this attribute until they understand it.
127 +
128 +##### secure
129 +
130 +Specifies the `boolean` value for the [`Secure` `Set-Cookie` attribute][rfc-6266-5.2.5]. When truthy,
131 +the `Secure` attribute is set, otherwise it is not. By default, the `Secure` attribute is not set.
132 +
133 +**note** be careful when setting this to `true`, as compliant clients will not send the cookie back to
134 +the server in the future if the browser does not have an HTTPS connection.
135 +
136 +## Example
137 +
138 +The following example uses this module in conjunction with the Node.js core HTTP server
139 +to prompt a user for their name and display it back on future visits.
140 +
141 +```js
142 +var cookie = require('cookie');
143 +var escapeHtml = require('escape-html');
144 +var http = require('http');
145 +var url = require('url');
146 +
147 +function onRequest(req, res) {
148 + // Parse the query string
149 + var query = url.parse(req.url, true, true).query;
150 +
151 + if (query && query.name) {
152 + // Set a new cookie with the name
153 + res.setHeader('Set-Cookie', cookie.serialize('name', String(query.name), {
154 + httpOnly: true,
155 + maxAge: 60 * 60 * 24 * 7 // 1 week
156 + }));
157 +
158 + // Redirect back after setting cookie
159 + res.statusCode = 302;
160 + res.setHeader('Location', req.headers.referer || '/');
161 + res.end();
162 + return;
163 + }
164 +
165 + // Parse the cookies on the request
166 + var cookies = cookie.parse(req.headers.cookie || '');
167 +
168 + // Get the visitor name set in the cookie
169 + var name = cookies.name;
170 +
171 + res.setHeader('Content-Type', 'text/html; charset=UTF-8');
172 +
173 + if (name) {
174 + res.write('<p>Welcome back, <b>' + escapeHtml(name) + '</b>!</p>');
175 + } else {
176 + res.write('<p>Hello, new visitor!</p>');
177 + }
178 +
179 + res.write('<form method="GET">');
180 + res.write('<input placeholder="enter your name" name="name"> <input type="submit" value="Set Name">');
181 + res.end('</form');
182 +}
183 +
184 +http.createServer(onRequest).listen(3000);
185 +```
186 +
187 +## Testing
188 +
189 +```sh
190 +$ npm test
191 +```
192 +
193 +## References
194 +
195 +- [RFC 6266: HTTP State Management Mechanism][rfc-6266]
196 +- [Same-site Cookies][draft-west-first-party-cookies-07]
197 +
198 +[draft-west-first-party-cookies-07]: https://tools.ietf.org/html/draft-west-first-party-cookies-07
199 +[rfc-6266]: https://tools.ietf.org/html/rfc6266
200 +[rfc-6266-5.1.4]: https://tools.ietf.org/html/rfc6266#section-5.1.4
201 +[rfc-6266-5.2.1]: https://tools.ietf.org/html/rfc6266#section-5.2.1
202 +[rfc-6266-5.2.2]: https://tools.ietf.org/html/rfc6266#section-5.2.2
203 +[rfc-6266-5.2.3]: https://tools.ietf.org/html/rfc6266#section-5.2.3
204 +[rfc-6266-5.2.4]: https://tools.ietf.org/html/rfc6266#section-5.2.4
205 +[rfc-6266-5.3]: https://tools.ietf.org/html/rfc6266#section-5.3
206 +
207 +## License
208 +
209 +[MIT](LICENSE)
210 +
211 +[npm-image]: https://img.shields.io/npm/v/cookie.svg
212 +[npm-url]: https://npmjs.org/package/cookie
213 +[node-version-image]: https://img.shields.io/node/v/cookie.svg
214 +[node-version-url]: https://nodejs.org/en/download
215 +[travis-image]: https://img.shields.io/travis/jshttp/cookie/master.svg
216 +[travis-url]: https://travis-ci.org/jshttp/cookie
217 +[coveralls-image]: https://img.shields.io/coveralls/jshttp/cookie/master.svg
218 +[coveralls-url]: https://coveralls.io/r/jshttp/cookie?branch=master
219 +[downloads-image]: https://img.shields.io/npm/dm/cookie.svg
220 +[downloads-url]: https://npmjs.org/package/cookie
1 +/*!
2 + * cookie
3 + * Copyright(c) 2012-2014 Roman Shtylman
4 + * Copyright(c) 2015 Douglas Christopher Wilson
5 + * MIT Licensed
6 + */
7 +
8 +'use strict';
9 +
10 +/**
11 + * Module exports.
12 + * @public
13 + */
14 +
15 +exports.parse = parse;
16 +exports.serialize = serialize;
17 +
18 +/**
19 + * Module variables.
20 + * @private
21 + */
22 +
23 +var decode = decodeURIComponent;
24 +var encode = encodeURIComponent;
25 +var pairSplitRegExp = /; */;
26 +
27 +/**
28 + * RegExp to match field-content in RFC 7230 sec 3.2
29 + *
30 + * field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ]
31 + * field-vchar = VCHAR / obs-text
32 + * obs-text = %x80-FF
33 + */
34 +
35 +var fieldContentRegExp = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
36 +
37 +/**
38 + * Parse a cookie header.
39 + *
40 + * Parse the given cookie header string into an object
41 + * The object has the various cookies as keys(names) => values
42 + *
43 + * @param {string} str
44 + * @param {object} [options]
45 + * @return {object}
46 + * @public
47 + */
48 +
49 +function parse(str, options) {
50 + if (typeof str !== 'string') {
51 + throw new TypeError('argument str must be a string');
52 + }
53 +
54 + var obj = {}
55 + var opt = options || {};
56 + var pairs = str.split(pairSplitRegExp);
57 + var dec = opt.decode || decode;
58 +
59 + for (var i = 0; i < pairs.length; i++) {
60 + var pair = pairs[i];
61 + var eq_idx = pair.indexOf('=');
62 +
63 + // skip things that don't look like key=value
64 + if (eq_idx < 0) {
65 + continue;
66 + }
67 +
68 + var key = pair.substr(0, eq_idx).trim()
69 + var val = pair.substr(++eq_idx, pair.length).trim();
70 +
71 + // quoted values
72 + if ('"' == val[0]) {
73 + val = val.slice(1, -1);
74 + }
75 +
76 + // only assign once
77 + if (undefined == obj[key]) {
78 + obj[key] = tryDecode(val, dec);
79 + }
80 + }
81 +
82 + return obj;
83 +}
84 +
85 +/**
86 + * Serialize data into a cookie header.
87 + *
88 + * Serialize the a name value pair into a cookie string suitable for
89 + * http headers. An optional options object specified cookie parameters.
90 + *
91 + * serialize('foo', 'bar', { httpOnly: true })
92 + * => "foo=bar; httpOnly"
93 + *
94 + * @param {string} name
95 + * @param {string} val
96 + * @param {object} [options]
97 + * @return {string}
98 + * @public
99 + */
100 +
101 +function serialize(name, val, options) {
102 + var opt = options || {};
103 + var enc = opt.encode || encode;
104 +
105 + if (typeof enc !== 'function') {
106 + throw new TypeError('option encode is invalid');
107 + }
108 +
109 + if (!fieldContentRegExp.test(name)) {
110 + throw new TypeError('argument name is invalid');
111 + }
112 +
113 + var value = enc(val);
114 +
115 + if (value && !fieldContentRegExp.test(value)) {
116 + throw new TypeError('argument val is invalid');
117 + }
118 +
119 + var str = name + '=' + value;
120 +
121 + if (null != opt.maxAge) {
122 + var maxAge = opt.maxAge - 0;
123 + if (isNaN(maxAge)) throw new Error('maxAge should be a Number');
124 + str += '; Max-Age=' + Math.floor(maxAge);
125 + }
126 +
127 + if (opt.domain) {
128 + if (!fieldContentRegExp.test(opt.domain)) {
129 + throw new TypeError('option domain is invalid');
130 + }
131 +
132 + str += '; Domain=' + opt.domain;
133 + }
134 +
135 + if (opt.path) {
136 + if (!fieldContentRegExp.test(opt.path)) {
137 + throw new TypeError('option path is invalid');
138 + }
139 +
140 + str += '; Path=' + opt.path;
141 + }
142 +
143 + if (opt.expires) {
144 + if (typeof opt.expires.toUTCString !== 'function') {
145 + throw new TypeError('option expires is invalid');
146 + }
147 +
148 + str += '; Expires=' + opt.expires.toUTCString();
149 + }
150 +
151 + if (opt.httpOnly) {
152 + str += '; HttpOnly';
153 + }
154 +
155 + if (opt.secure) {
156 + str += '; Secure';
157 + }
158 +
159 + if (opt.sameSite) {
160 + var sameSite = typeof opt.sameSite === 'string'
161 + ? opt.sameSite.toLowerCase() : opt.sameSite;
162 +
163 + switch (sameSite) {
164 + case true:
165 + str += '; SameSite=Strict';
166 + break;
167 + case 'lax':
168 + str += '; SameSite=Lax';
169 + break;
170 + case 'strict':
171 + str += '; SameSite=Strict';
172 + break;
173 + default:
174 + throw new TypeError('option sameSite is invalid');
175 + }
176 + }
177 +
178 + return str;
179 +}
180 +
181 +/**
182 + * Try decoding a string using a decoding function.
183 + *
184 + * @param {string} str
185 + * @param {function} decode
186 + * @private
187 + */
188 +
189 +function tryDecode(str, decode) {
190 + try {
191 + return decode(str);
192 + } catch (e) {
193 + return str;
194 + }
195 +}
1 +{
2 + "_from": "cookie@0.3.1",
3 + "_id": "cookie@0.3.1",
4 + "_inBundle": false,
5 + "_integrity": "sha1-5+Ch+e9DtMi6klxcWpboBtFoc7s=",
6 + "_location": "/cookie",
7 + "_phantomChildren": {},
8 + "_requested": {
9 + "type": "version",
10 + "registry": true,
11 + "raw": "cookie@0.3.1",
12 + "name": "cookie",
13 + "escapedName": "cookie",
14 + "rawSpec": "0.3.1",
15 + "saveSpec": null,
16 + "fetchSpec": "0.3.1"
17 + },
18 + "_requiredBy": [
19 + "/cookie-parser"
20 + ],
21 + "_resolved": "https://registry.npmjs.org/cookie/-/cookie-0.3.1.tgz",
22 + "_shasum": "e7e0a1f9ef43b4c8ba925c5c5a96e806d16873bb",
23 + "_spec": "cookie@0.3.1",
24 + "_where": "C:\\Users\\지윤\\project_opensource\\node_modules\\cookie-parser",
25 + "author": {
26 + "name": "Roman Shtylman",
27 + "email": "shtylman@gmail.com"
28 + },
29 + "bugs": {
30 + "url": "https://github.com/jshttp/cookie/issues"
31 + },
32 + "bundleDependencies": false,
33 + "contributors": [
34 + {
35 + "name": "Douglas Christopher Wilson",
36 + "email": "doug@somethingdoug.com"
37 + }
38 + ],
39 + "deprecated": false,
40 + "description": "HTTP server cookie parsing and serialization",
41 + "devDependencies": {
42 + "istanbul": "0.4.3",
43 + "mocha": "1.21.5"
44 + },
45 + "engines": {
46 + "node": ">= 0.6"
47 + },
48 + "files": [
49 + "HISTORY.md",
50 + "LICENSE",
51 + "README.md",
52 + "index.js"
53 + ],
54 + "homepage": "https://github.com/jshttp/cookie#readme",
55 + "keywords": [
56 + "cookie",
57 + "cookies"
58 + ],
59 + "license": "MIT",
60 + "name": "cookie",
61 + "repository": {
62 + "type": "git",
63 + "url": "git+https://github.com/jshttp/cookie.git"
64 + },
65 + "scripts": {
66 + "test": "mocha --reporter spec --bail --check-leaks test/",
67 + "test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/",
68 + "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/"
69 + },
70 + "version": "0.3.1"
71 +}
1 +The MIT License (MIT)
2 +
3 +Copyright 2014 Alex Gorbatchev
4 +
5 +Permission is hereby granted, free of charge, to any person obtaining
6 +a copy of this software and associated documentation files (the
7 +"Software"), to deal in the Software without restriction, including
8 +without limitation the rights to use, copy, modify, merge, publish,
9 +distribute, sublicense, and/or sell copies of the Software, and to
10 +permit persons to whom the Software is furnished to do so, subject to
11 +the following conditions:
12 +
13 +The above copyright notice and this permission notice shall be
14 +included in all copies or substantial portions of the Software.
15 +
16 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1 +# crc
2 +
3 +[![GitTip](http://img.shields.io/gittip/alexgorbatchev.svg?style=flat)](https://www.gittip.com/alexgorbatchev/)
4 +[![Dependency status](http://img.shields.io/david/alexgorbatchev/node-crc.svg?style=flat)](https://david-dm.org/alexgorbatchev/node-crc)
5 +[![devDependency Status](http://img.shields.io/david/dev/alexgorbatchev/node-crc.svg?style=flat)](https://david-dm.org/alexgorbatchev/node-crc?type=dev)
6 +[![Build Status](http://img.shields.io/travis/alexgorbatchev/node-crc.svg?style=flat&branch=master)](https://travis-ci.org/alexgorbatchev/node-crc)
7 +
8 +[![NPM](https://nodei.co/npm/crc.svg?style=flat)](https://npmjs.org/package/crc)
9 +
10 +Module for calculating Cyclic Redundancy Check (CRC) for Node.js and the Browser.
11 +
12 +# Important: Node >= 6.3.0 < 6.9.2
13 +
14 +There's was a bug in Node [#9342](https://github.com/nodejs/node/issues/9342) that affected CRC calculation if `Buffer.split()` is used (see issue discussion for details). This affected all version starting from `6.3.0` up to but not including `6.9.2`. The patch [#9341](https://github.com/nodejs/node/pull/9341) was released in `6.9.2`. If you are upgrading and seeing odd CRC calculation mismatches, this might be the reason.
15 +
16 +## Features
17 +
18 +* Full test suite comparing values against reference `pycrc` implementation.
19 +* Pure JavaScript implementation, no dependencies.
20 +* Provides CRC tables for optimized calculations.
21 +* Provides support for the following CRC algorithms:
22 + * CRC1 `crc.crc1(…)`
23 + * CRC8 `crc.crc8(…)`
24 + * CRC8 1-Wire `crc.crc81wire(…)`
25 + * CRC16 `crc.crc16(…)`
26 + * CRC16 CCITT `crc.crc16ccitt(…)`
27 + * CRC16 Modbus `crc.crc16modbus(…)`
28 + * CRC16 Kermit `crc.crc16kermit(…)`
29 + * CRC16 XModem `crc.crc16xmodem(…)`
30 + * CRC24 `crc.crc24(…)`
31 + * CRC32 `crc.crc32(…)`
32 +
33 +## Installation
34 +
35 +```
36 +npm install crc
37 +```
38 +
39 +## Usage
40 +
41 +Calculate a CRC32:
42 +
43 +```js
44 +var crc = require('crc');
45 +
46 +crc.crc32('hello').toString(16);
47 +// "3610a686"
48 +```
49 +
50 +Calculate a CRC32 of a file:
51 +
52 +```js
53 +crc.crc32(fs.readFileSync('README.md', 'utf8')).toString(16);
54 +// "127ad531"
55 +```
56 +
57 +Or using a `Buffer`:
58 +
59 +```js
60 +crc.crc32(fs.readFileSync('README.md')).toString(16);
61 +// "127ad531"
62 +```
63 +
64 +Incrementally calculate a CRC32:
65 +
66 +```js
67 +value = crc.crc32('one');
68 +value = crc.crc32('two', value);
69 +value = crc.crc32('three', value);
70 +value.toString(16);
71 +// "9e1c092"
72 +```
73 +
74 +## Running tests
75 +
76 +```
77 +npm test
78 +```
79 +
80 +## Thanks!
81 +
82 +[pycrc](http://www.tty1.net/pycrc/) library is which the source of all of the CRC tables.
83 +
84 +# License
85 +
86 +The MIT License (MIT)
87 +
88 +Copyright (c) 2014 Alex Gorbatchev
89 +
90 +Permission is hereby granted, free of charge, to any person obtaining a copy
91 +of this software and associated documentation files (the "Software"), to deal
92 +in the Software without restriction, including without limitation the rights
93 +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
94 +copies of the Software, and to permit persons to whom the Software is
95 +furnished to do so, subject to the following conditions:
96 +
97 +The above copyright notice and this permission notice shall be included in
98 +all copies or substantial portions of the Software.
99 +
100 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
101 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
102 +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
103 +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
104 +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
105 +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
106 +THE SOFTWARE.
1 +'use strict';
2 +
3 +var _buffer = require('buffer');
4 +
5 +var _create_buffer = require('./create_buffer');
6 +
7 +var _create_buffer2 = _interopRequireDefault(_create_buffer);
8 +
9 +var _define_crc = require('./define_crc');
10 +
11 +var _define_crc2 = _interopRequireDefault(_define_crc);
12 +
13 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14 +
15 +module.exports = (0, _define_crc2.default)('crc1', function (buf, previous) {
16 + if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf);
17 +
18 + var crc = ~~previous;
19 + var accum = 0;
20 +
21 + for (var index = 0; index < buf.length; index++) {
22 + var byte = buf[index];
23 + accum += byte;
24 + }
25 +
26 + crc += accum % 256;
27 + return crc % 256;
28 +});
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +var _buffer = require('buffer');
4 +
5 +var _create_buffer = require('./create_buffer');
6 +
7 +var _create_buffer2 = _interopRequireDefault(_create_buffer);
8 +
9 +var _define_crc = require('./define_crc');
10 +
11 +var _define_crc2 = _interopRequireDefault(_define_crc);
12 +
13 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14 +
15 +// Generated by `./pycrc.py --algorithm=table-driven --model=crc-16 --generate=c`
16 +var TABLE = [0x0000, 0xc0c1, 0xc181, 0x0140, 0xc301, 0x03c0, 0x0280, 0xc241, 0xc601, 0x06c0, 0x0780, 0xc741, 0x0500, 0xc5c1, 0xc481, 0x0440, 0xcc01, 0x0cc0, 0x0d80, 0xcd41, 0x0f00, 0xcfc1, 0xce81, 0x0e40, 0x0a00, 0xcac1, 0xcb81, 0x0b40, 0xc901, 0x09c0, 0x0880, 0xc841, 0xd801, 0x18c0, 0x1980, 0xd941, 0x1b00, 0xdbc1, 0xda81, 0x1a40, 0x1e00, 0xdec1, 0xdf81, 0x1f40, 0xdd01, 0x1dc0, 0x1c80, 0xdc41, 0x1400, 0xd4c1, 0xd581, 0x1540, 0xd701, 0x17c0, 0x1680, 0xd641, 0xd201, 0x12c0, 0x1380, 0xd341, 0x1100, 0xd1c1, 0xd081, 0x1040, 0xf001, 0x30c0, 0x3180, 0xf141, 0x3300, 0xf3c1, 0xf281, 0x3240, 0x3600, 0xf6c1, 0xf781, 0x3740, 0xf501, 0x35c0, 0x3480, 0xf441, 0x3c00, 0xfcc1, 0xfd81, 0x3d40, 0xff01, 0x3fc0, 0x3e80, 0xfe41, 0xfa01, 0x3ac0, 0x3b80, 0xfb41, 0x3900, 0xf9c1, 0xf881, 0x3840, 0x2800, 0xe8c1, 0xe981, 0x2940, 0xeb01, 0x2bc0, 0x2a80, 0xea41, 0xee01, 0x2ec0, 0x2f80, 0xef41, 0x2d00, 0xedc1, 0xec81, 0x2c40, 0xe401, 0x24c0, 0x2580, 0xe541, 0x2700, 0xe7c1, 0xe681, 0x2640, 0x2200, 0xe2c1, 0xe381, 0x2340, 0xe101, 0x21c0, 0x2080, 0xe041, 0xa001, 0x60c0, 0x6180, 0xa141, 0x6300, 0xa3c1, 0xa281, 0x6240, 0x6600, 0xa6c1, 0xa781, 0x6740, 0xa501, 0x65c0, 0x6480, 0xa441, 0x6c00, 0xacc1, 0xad81, 0x6d40, 0xaf01, 0x6fc0, 0x6e80, 0xae41, 0xaa01, 0x6ac0, 0x6b80, 0xab41, 0x6900, 0xa9c1, 0xa881, 0x6840, 0x7800, 0xb8c1, 0xb981, 0x7940, 0xbb01, 0x7bc0, 0x7a80, 0xba41, 0xbe01, 0x7ec0, 0x7f80, 0xbf41, 0x7d00, 0xbdc1, 0xbc81, 0x7c40, 0xb401, 0x74c0, 0x7580, 0xb541, 0x7700, 0xb7c1, 0xb681, 0x7640, 0x7200, 0xb2c1, 0xb381, 0x7340, 0xb101, 0x71c0, 0x7080, 0xb041, 0x5000, 0x90c1, 0x9181, 0x5140, 0x9301, 0x53c0, 0x5280, 0x9241, 0x9601, 0x56c0, 0x5780, 0x9741, 0x5500, 0x95c1, 0x9481, 0x5440, 0x9c01, 0x5cc0, 0x5d80, 0x9d41, 0x5f00, 0x9fc1, 0x9e81, 0x5e40, 0x5a00, 0x9ac1, 0x9b81, 0x5b40, 0x9901, 0x59c0, 0x5880, 0x9841, 0x8801, 0x48c0, 0x4980, 0x8941, 0x4b00, 0x8bc1, 0x8a81, 0x4a40, 0x4e00, 0x8ec1, 0x8f81, 0x4f40, 0x8d01, 0x4dc0, 0x4c80, 0x8c41, 0x4400, 0x84c1, 0x8581, 0x4540, 0x8701, 0x47c0, 0x4680, 0x8641, 0x8201, 0x42c0, 0x4380, 0x8341, 0x4100, 0x81c1, 0x8081, 0x4040];
17 +
18 +if (typeof Int32Array !== 'undefined') TABLE = new Int32Array(TABLE);
19 +
20 +module.exports = (0, _define_crc2.default)('crc-16', function (buf, previous) {
21 + if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf);
22 +
23 + var crc = ~~previous;
24 +
25 + for (var index = 0; index < buf.length; index++) {
26 + var byte = buf[index];
27 + crc = (TABLE[(crc ^ byte) & 0xff] ^ crc >> 8) & 0xffff;
28 + }
29 +
30 + return crc;
31 +});
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +var _buffer = require('buffer');
4 +
5 +var _create_buffer = require('./create_buffer');
6 +
7 +var _create_buffer2 = _interopRequireDefault(_create_buffer);
8 +
9 +var _define_crc = require('./define_crc');
10 +
11 +var _define_crc2 = _interopRequireDefault(_define_crc);
12 +
13 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14 +
15 +// Generated by `./pycrc.py --algorithm=table-driven --model=ccitt --generate=c`
16 +var TABLE = [0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7, 0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef, 0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6, 0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de, 0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485, 0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d, 0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4, 0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc, 0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823, 0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, 0xb92b, 0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12, 0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a, 0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41, 0xedae, 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49, 0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70, 0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78, 0x9188, 0x81a9, 0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f, 0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067, 0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e, 0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214, 0x6277, 0x7256, 0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d, 0x34e2, 0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405, 0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e, 0xc71d, 0xd73c, 0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634, 0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab, 0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3, 0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a, 0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0, 0x2ab3, 0x3a92, 0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9, 0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1, 0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8, 0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0];
17 +
18 +if (typeof Int32Array !== 'undefined') TABLE = new Int32Array(TABLE);
19 +
20 +module.exports = (0, _define_crc2.default)('ccitt', function (buf, previous) {
21 + if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf);
22 +
23 + var crc = typeof previous !== 'undefined' ? ~~previous : 0xffff;
24 +
25 + for (var index = 0; index < buf.length; index++) {
26 + var byte = buf[index];
27 + crc = (TABLE[(crc >> 8 ^ byte) & 0xff] ^ crc << 8) & 0xffff;
28 + }
29 +
30 + return crc;
31 +});
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +var _buffer = require('buffer');
4 +
5 +var _create_buffer = require('./create_buffer');
6 +
7 +var _create_buffer2 = _interopRequireDefault(_create_buffer);
8 +
9 +var _define_crc = require('./define_crc');
10 +
11 +var _define_crc2 = _interopRequireDefault(_define_crc);
12 +
13 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14 +
15 +// Generated by `./pycrc.py --algorithm=table-driven --model=kermit --generate=c`
16 +var TABLE = [0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf, 0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7, 0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e, 0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed, 0xcb64, 0xf9ff, 0xe876, 0x2102, 0x308b, 0x0210, 0x1399, 0x6726, 0x76af, 0x4434, 0x55bd, 0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5, 0x3183, 0x200a, 0x1291, 0x0318, 0x77a7, 0x662e, 0x54b5, 0x453c, 0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef, 0xea66, 0xd8fd, 0xc974, 0x4204, 0x538d, 0x6116, 0x709f, 0x0420, 0x15a9, 0x2732, 0x36bb, 0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868, 0x99e1, 0xab7a, 0xbaf3, 0x5285, 0x430c, 0x7197, 0x601e, 0x14a1, 0x0528, 0x37b3, 0x263a, 0xdecd, 0xcf44, 0xfddf, 0xec56, 0x98e9, 0x8960, 0xbbfb, 0xaa72, 0x6306, 0x728f, 0x4014, 0x519d, 0x2522, 0x34ab, 0x0630, 0x17b9, 0xef4e, 0xfec7, 0xcc5c, 0xddd5, 0xa96a, 0xb8e3, 0x8a78, 0x9bf1, 0x7387, 0x620e, 0x5095, 0x411c, 0x35a3, 0x242a, 0x16b1, 0x0738, 0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb, 0xa862, 0x9af9, 0x8b70, 0x8408, 0x9581, 0xa71a, 0xb693, 0xc22c, 0xd3a5, 0xe13e, 0xf0b7, 0x0840, 0x19c9, 0x2b52, 0x3adb, 0x4e64, 0x5fed, 0x6d76, 0x7cff, 0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad, 0xc324, 0xf1bf, 0xe036, 0x18c1, 0x0948, 0x3bd3, 0x2a5a, 0x5ee5, 0x4f6c, 0x7df7, 0x6c7e, 0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e, 0xf2a7, 0xc03c, 0xd1b5, 0x2942, 0x38cb, 0x0a50, 0x1bd9, 0x6f66, 0x7eef, 0x4c74, 0x5dfd, 0xb58b, 0xa402, 0x9699, 0x8710, 0xf3af, 0xe226, 0xd0bd, 0xc134, 0x39c3, 0x284a, 0x1ad1, 0x0b58, 0x7fe7, 0x6e6e, 0x5cf5, 0x4d7c, 0xc60c, 0xd785, 0xe51e, 0xf497, 0x8028, 0x91a1, 0xa33a, 0xb2b3, 0x4a44, 0x5bcd, 0x6956, 0x78df, 0x0c60, 0x1de9, 0x2f72, 0x3efb, 0xd68d, 0xc704, 0xf59f, 0xe416, 0x90a9, 0x8120, 0xb3bb, 0xa232, 0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1, 0x0d68, 0x3ff3, 0x2e7a, 0xe70e, 0xf687, 0xc41c, 0xd595, 0xa12a, 0xb0a3, 0x8238, 0x93b1, 0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9, 0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330, 0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78];
17 +
18 +if (typeof Int32Array !== 'undefined') TABLE = new Int32Array(TABLE);
19 +
20 +module.exports = (0, _define_crc2.default)('kermit', function (buf, previous) {
21 + if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf);
22 +
23 + var crc = typeof previous !== 'undefined' ? ~~previous : 0x0000;
24 +
25 + for (var index = 0; index < buf.length; index++) {
26 + var byte = buf[index];
27 + crc = (TABLE[(crc ^ byte) & 0xff] ^ crc >> 8) & 0xffff;
28 + }
29 +
30 + return crc;
31 +});
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +var _buffer = require('buffer');
4 +
5 +var _create_buffer = require('./create_buffer');
6 +
7 +var _create_buffer2 = _interopRequireDefault(_create_buffer);
8 +
9 +var _define_crc = require('./define_crc');
10 +
11 +var _define_crc2 = _interopRequireDefault(_define_crc);
12 +
13 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14 +
15 +// Generated by `./pycrc.py --algorithm=table-driven --model=crc-16-modbus --generate=c`
16 +var TABLE = [0x0000, 0xc0c1, 0xc181, 0x0140, 0xc301, 0x03c0, 0x0280, 0xc241, 0xc601, 0x06c0, 0x0780, 0xc741, 0x0500, 0xc5c1, 0xc481, 0x0440, 0xcc01, 0x0cc0, 0x0d80, 0xcd41, 0x0f00, 0xcfc1, 0xce81, 0x0e40, 0x0a00, 0xcac1, 0xcb81, 0x0b40, 0xc901, 0x09c0, 0x0880, 0xc841, 0xd801, 0x18c0, 0x1980, 0xd941, 0x1b00, 0xdbc1, 0xda81, 0x1a40, 0x1e00, 0xdec1, 0xdf81, 0x1f40, 0xdd01, 0x1dc0, 0x1c80, 0xdc41, 0x1400, 0xd4c1, 0xd581, 0x1540, 0xd701, 0x17c0, 0x1680, 0xd641, 0xd201, 0x12c0, 0x1380, 0xd341, 0x1100, 0xd1c1, 0xd081, 0x1040, 0xf001, 0x30c0, 0x3180, 0xf141, 0x3300, 0xf3c1, 0xf281, 0x3240, 0x3600, 0xf6c1, 0xf781, 0x3740, 0xf501, 0x35c0, 0x3480, 0xf441, 0x3c00, 0xfcc1, 0xfd81, 0x3d40, 0xff01, 0x3fc0, 0x3e80, 0xfe41, 0xfa01, 0x3ac0, 0x3b80, 0xfb41, 0x3900, 0xf9c1, 0xf881, 0x3840, 0x2800, 0xe8c1, 0xe981, 0x2940, 0xeb01, 0x2bc0, 0x2a80, 0xea41, 0xee01, 0x2ec0, 0x2f80, 0xef41, 0x2d00, 0xedc1, 0xec81, 0x2c40, 0xe401, 0x24c0, 0x2580, 0xe541, 0x2700, 0xe7c1, 0xe681, 0x2640, 0x2200, 0xe2c1, 0xe381, 0x2340, 0xe101, 0x21c0, 0x2080, 0xe041, 0xa001, 0x60c0, 0x6180, 0xa141, 0x6300, 0xa3c1, 0xa281, 0x6240, 0x6600, 0xa6c1, 0xa781, 0x6740, 0xa501, 0x65c0, 0x6480, 0xa441, 0x6c00, 0xacc1, 0xad81, 0x6d40, 0xaf01, 0x6fc0, 0x6e80, 0xae41, 0xaa01, 0x6ac0, 0x6b80, 0xab41, 0x6900, 0xa9c1, 0xa881, 0x6840, 0x7800, 0xb8c1, 0xb981, 0x7940, 0xbb01, 0x7bc0, 0x7a80, 0xba41, 0xbe01, 0x7ec0, 0x7f80, 0xbf41, 0x7d00, 0xbdc1, 0xbc81, 0x7c40, 0xb401, 0x74c0, 0x7580, 0xb541, 0x7700, 0xb7c1, 0xb681, 0x7640, 0x7200, 0xb2c1, 0xb381, 0x7340, 0xb101, 0x71c0, 0x7080, 0xb041, 0x5000, 0x90c1, 0x9181, 0x5140, 0x9301, 0x53c0, 0x5280, 0x9241, 0x9601, 0x56c0, 0x5780, 0x9741, 0x5500, 0x95c1, 0x9481, 0x5440, 0x9c01, 0x5cc0, 0x5d80, 0x9d41, 0x5f00, 0x9fc1, 0x9e81, 0x5e40, 0x5a00, 0x9ac1, 0x9b81, 0x5b40, 0x9901, 0x59c0, 0x5880, 0x9841, 0x8801, 0x48c0, 0x4980, 0x8941, 0x4b00, 0x8bc1, 0x8a81, 0x4a40, 0x4e00, 0x8ec1, 0x8f81, 0x4f40, 0x8d01, 0x4dc0, 0x4c80, 0x8c41, 0x4400, 0x84c1, 0x8581, 0x4540, 0x8701, 0x47c0, 0x4680, 0x8641, 0x8201, 0x42c0, 0x4380, 0x8341, 0x4100, 0x81c1, 0x8081, 0x4040];
17 +
18 +if (typeof Int32Array !== 'undefined') TABLE = new Int32Array(TABLE);
19 +
20 +module.exports = (0, _define_crc2.default)('crc-16-modbus', function (buf, previous) {
21 + if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf);
22 +
23 + var crc = typeof previous !== 'undefined' ? ~~previous : 0xffff;
24 +
25 + for (var index = 0; index < buf.length; index++) {
26 + var byte = buf[index];
27 + crc = (TABLE[(crc ^ byte) & 0xff] ^ crc >> 8) & 0xffff;
28 + }
29 +
30 + return crc;
31 +});
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +var _buffer = require('buffer');
4 +
5 +var _create_buffer = require('./create_buffer');
6 +
7 +var _create_buffer2 = _interopRequireDefault(_create_buffer);
8 +
9 +var _define_crc = require('./define_crc');
10 +
11 +var _define_crc2 = _interopRequireDefault(_define_crc);
12 +
13 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14 +
15 +module.exports = (0, _define_crc2.default)('xmodem', function (buf, previous) {
16 + if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf);
17 +
18 + var crc = typeof previous !== 'undefined' ? ~~previous : 0x0;
19 +
20 + for (var index = 0; index < buf.length; index++) {
21 + var byte = buf[index];
22 + var code = crc >>> 8 & 0xFF;
23 +
24 + code ^= byte & 0xFF;
25 + code ^= code >>> 4;
26 + crc = crc << 8 & 0xFFFF;
27 + crc ^= code;
28 + code = code << 5 & 0xFFFF;
29 + crc ^= code;
30 + code = code << 7 & 0xFFFF;
31 + crc ^= code;
32 + }
33 +
34 + return crc;
35 +});
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +var _buffer = require('buffer');
4 +
5 +var _create_buffer = require('./create_buffer');
6 +
7 +var _create_buffer2 = _interopRequireDefault(_create_buffer);
8 +
9 +var _define_crc = require('./define_crc');
10 +
11 +var _define_crc2 = _interopRequireDefault(_define_crc);
12 +
13 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14 +
15 +// Generated by `./pycrc.py --algorithm=table-drive --model=crc-24 --generate=c`
16 +var TABLE = [0x000000, 0x864cfb, 0x8ad50d, 0x0c99f6, 0x93e6e1, 0x15aa1a, 0x1933ec, 0x9f7f17, 0xa18139, 0x27cdc2, 0x2b5434, 0xad18cf, 0x3267d8, 0xb42b23, 0xb8b2d5, 0x3efe2e, 0xc54e89, 0x430272, 0x4f9b84, 0xc9d77f, 0x56a868, 0xd0e493, 0xdc7d65, 0x5a319e, 0x64cfb0, 0xe2834b, 0xee1abd, 0x685646, 0xf72951, 0x7165aa, 0x7dfc5c, 0xfbb0a7, 0x0cd1e9, 0x8a9d12, 0x8604e4, 0x00481f, 0x9f3708, 0x197bf3, 0x15e205, 0x93aefe, 0xad50d0, 0x2b1c2b, 0x2785dd, 0xa1c926, 0x3eb631, 0xb8faca, 0xb4633c, 0x322fc7, 0xc99f60, 0x4fd39b, 0x434a6d, 0xc50696, 0x5a7981, 0xdc357a, 0xd0ac8c, 0x56e077, 0x681e59, 0xee52a2, 0xe2cb54, 0x6487af, 0xfbf8b8, 0x7db443, 0x712db5, 0xf7614e, 0x19a3d2, 0x9fef29, 0x9376df, 0x153a24, 0x8a4533, 0x0c09c8, 0x00903e, 0x86dcc5, 0xb822eb, 0x3e6e10, 0x32f7e6, 0xb4bb1d, 0x2bc40a, 0xad88f1, 0xa11107, 0x275dfc, 0xdced5b, 0x5aa1a0, 0x563856, 0xd074ad, 0x4f0bba, 0xc94741, 0xc5deb7, 0x43924c, 0x7d6c62, 0xfb2099, 0xf7b96f, 0x71f594, 0xee8a83, 0x68c678, 0x645f8e, 0xe21375, 0x15723b, 0x933ec0, 0x9fa736, 0x19ebcd, 0x8694da, 0x00d821, 0x0c41d7, 0x8a0d2c, 0xb4f302, 0x32bff9, 0x3e260f, 0xb86af4, 0x2715e3, 0xa15918, 0xadc0ee, 0x2b8c15, 0xd03cb2, 0x567049, 0x5ae9bf, 0xdca544, 0x43da53, 0xc596a8, 0xc90f5e, 0x4f43a5, 0x71bd8b, 0xf7f170, 0xfb6886, 0x7d247d, 0xe25b6a, 0x641791, 0x688e67, 0xeec29c, 0x3347a4, 0xb50b5f, 0xb992a9, 0x3fde52, 0xa0a145, 0x26edbe, 0x2a7448, 0xac38b3, 0x92c69d, 0x148a66, 0x181390, 0x9e5f6b, 0x01207c, 0x876c87, 0x8bf571, 0x0db98a, 0xf6092d, 0x7045d6, 0x7cdc20, 0xfa90db, 0x65efcc, 0xe3a337, 0xef3ac1, 0x69763a, 0x578814, 0xd1c4ef, 0xdd5d19, 0x5b11e2, 0xc46ef5, 0x42220e, 0x4ebbf8, 0xc8f703, 0x3f964d, 0xb9dab6, 0xb54340, 0x330fbb, 0xac70ac, 0x2a3c57, 0x26a5a1, 0xa0e95a, 0x9e1774, 0x185b8f, 0x14c279, 0x928e82, 0x0df195, 0x8bbd6e, 0x872498, 0x016863, 0xfad8c4, 0x7c943f, 0x700dc9, 0xf64132, 0x693e25, 0xef72de, 0xe3eb28, 0x65a7d3, 0x5b59fd, 0xdd1506, 0xd18cf0, 0x57c00b, 0xc8bf1c, 0x4ef3e7, 0x426a11, 0xc426ea, 0x2ae476, 0xaca88d, 0xa0317b, 0x267d80, 0xb90297, 0x3f4e6c, 0x33d79a, 0xb59b61, 0x8b654f, 0x0d29b4, 0x01b042, 0x87fcb9, 0x1883ae, 0x9ecf55, 0x9256a3, 0x141a58, 0xefaaff, 0x69e604, 0x657ff2, 0xe33309, 0x7c4c1e, 0xfa00e5, 0xf69913, 0x70d5e8, 0x4e2bc6, 0xc8673d, 0xc4fecb, 0x42b230, 0xddcd27, 0x5b81dc, 0x57182a, 0xd154d1, 0x26359f, 0xa07964, 0xace092, 0x2aac69, 0xb5d37e, 0x339f85, 0x3f0673, 0xb94a88, 0x87b4a6, 0x01f85d, 0x0d61ab, 0x8b2d50, 0x145247, 0x921ebc, 0x9e874a, 0x18cbb1, 0xe37b16, 0x6537ed, 0x69ae1b, 0xefe2e0, 0x709df7, 0xf6d10c, 0xfa48fa, 0x7c0401, 0x42fa2f, 0xc4b6d4, 0xc82f22, 0x4e63d9, 0xd11cce, 0x575035, 0x5bc9c3, 0xdd8538];
17 +
18 +if (typeof Int32Array !== 'undefined') TABLE = new Int32Array(TABLE);
19 +
20 +module.exports = (0, _define_crc2.default)('crc-24', function (buf, previous) {
21 + if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf);
22 +
23 + var crc = typeof previous !== 'undefined' ? ~~previous : 0xb704ce;
24 +
25 + for (var index = 0; index < buf.length; index++) {
26 + var byte = buf[index];
27 + crc = (TABLE[(crc >> 16 ^ byte) & 0xff] ^ crc << 8) & 0xffffff;
28 + }
29 +
30 + return crc;
31 +});
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +var _buffer = require('buffer');
4 +
5 +var _create_buffer = require('./create_buffer');
6 +
7 +var _create_buffer2 = _interopRequireDefault(_create_buffer);
8 +
9 +var _define_crc = require('./define_crc');
10 +
11 +var _define_crc2 = _interopRequireDefault(_define_crc);
12 +
13 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14 +
15 +// Generated by `./pycrc.py --algorithm=table-driven --model=crc-32 --generate=c`
16 +var TABLE = [0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d];
17 +
18 +if (typeof Int32Array !== 'undefined') TABLE = new Int32Array(TABLE);
19 +
20 +module.exports = (0, _define_crc2.default)('crc-32', function (buf, previous) {
21 + if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf);
22 +
23 + var crc = previous === 0 ? 0 : ~~previous ^ -1;
24 +
25 + for (var index = 0; index < buf.length; index++) {
26 + var byte = buf[index];
27 + crc = TABLE[(crc ^ byte) & 0xff] ^ crc >>> 8;
28 + }
29 +
30 + return crc ^ -1;
31 +});
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +var _buffer = require('buffer');
4 +
5 +var _create_buffer = require('./create_buffer');
6 +
7 +var _create_buffer2 = _interopRequireDefault(_create_buffer);
8 +
9 +var _define_crc = require('./define_crc');
10 +
11 +var _define_crc2 = _interopRequireDefault(_define_crc);
12 +
13 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14 +
15 +// Generated by `./pycrc.py --algorithm=table-driven --model=crc-8 --generate=c`
16 +var TABLE = [0x00, 0x07, 0x0e, 0x09, 0x1c, 0x1b, 0x12, 0x15, 0x38, 0x3f, 0x36, 0x31, 0x24, 0x23, 0x2a, 0x2d, 0x70, 0x77, 0x7e, 0x79, 0x6c, 0x6b, 0x62, 0x65, 0x48, 0x4f, 0x46, 0x41, 0x54, 0x53, 0x5a, 0x5d, 0xe0, 0xe7, 0xee, 0xe9, 0xfc, 0xfb, 0xf2, 0xf5, 0xd8, 0xdf, 0xd6, 0xd1, 0xc4, 0xc3, 0xca, 0xcd, 0x90, 0x97, 0x9e, 0x99, 0x8c, 0x8b, 0x82, 0x85, 0xa8, 0xaf, 0xa6, 0xa1, 0xb4, 0xb3, 0xba, 0xbd, 0xc7, 0xc0, 0xc9, 0xce, 0xdb, 0xdc, 0xd5, 0xd2, 0xff, 0xf8, 0xf1, 0xf6, 0xe3, 0xe4, 0xed, 0xea, 0xb7, 0xb0, 0xb9, 0xbe, 0xab, 0xac, 0xa5, 0xa2, 0x8f, 0x88, 0x81, 0x86, 0x93, 0x94, 0x9d, 0x9a, 0x27, 0x20, 0x29, 0x2e, 0x3b, 0x3c, 0x35, 0x32, 0x1f, 0x18, 0x11, 0x16, 0x03, 0x04, 0x0d, 0x0a, 0x57, 0x50, 0x59, 0x5e, 0x4b, 0x4c, 0x45, 0x42, 0x6f, 0x68, 0x61, 0x66, 0x73, 0x74, 0x7d, 0x7a, 0x89, 0x8e, 0x87, 0x80, 0x95, 0x92, 0x9b, 0x9c, 0xb1, 0xb6, 0xbf, 0xb8, 0xad, 0xaa, 0xa3, 0xa4, 0xf9, 0xfe, 0xf7, 0xf0, 0xe5, 0xe2, 0xeb, 0xec, 0xc1, 0xc6, 0xcf, 0xc8, 0xdd, 0xda, 0xd3, 0xd4, 0x69, 0x6e, 0x67, 0x60, 0x75, 0x72, 0x7b, 0x7c, 0x51, 0x56, 0x5f, 0x58, 0x4d, 0x4a, 0x43, 0x44, 0x19, 0x1e, 0x17, 0x10, 0x05, 0x02, 0x0b, 0x0c, 0x21, 0x26, 0x2f, 0x28, 0x3d, 0x3a, 0x33, 0x34, 0x4e, 0x49, 0x40, 0x47, 0x52, 0x55, 0x5c, 0x5b, 0x76, 0x71, 0x78, 0x7f, 0x6a, 0x6d, 0x64, 0x63, 0x3e, 0x39, 0x30, 0x37, 0x22, 0x25, 0x2c, 0x2b, 0x06, 0x01, 0x08, 0x0f, 0x1a, 0x1d, 0x14, 0x13, 0xae, 0xa9, 0xa0, 0xa7, 0xb2, 0xb5, 0xbc, 0xbb, 0x96, 0x91, 0x98, 0x9f, 0x8a, 0x8d, 0x84, 0x83, 0xde, 0xd9, 0xd0, 0xd7, 0xc2, 0xc5, 0xcc, 0xcb, 0xe6, 0xe1, 0xe8, 0xef, 0xfa, 0xfd, 0xf4, 0xf3];
17 +
18 +if (typeof Int32Array !== 'undefined') TABLE = new Int32Array(TABLE);
19 +
20 +module.exports = (0, _define_crc2.default)('crc-8', function (buf, previous) {
21 + if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf);
22 +
23 + var crc = ~~previous;
24 +
25 + for (var index = 0; index < buf.length; index++) {
26 + var byte = buf[index];
27 + crc = TABLE[(crc ^ byte) & 0xff] & 0xff;
28 + }
29 +
30 + return crc;
31 +});
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +var _buffer = require('buffer');
4 +
5 +var _create_buffer = require('./create_buffer');
6 +
7 +var _create_buffer2 = _interopRequireDefault(_create_buffer);
8 +
9 +var _define_crc = require('./define_crc');
10 +
11 +var _define_crc2 = _interopRequireDefault(_define_crc);
12 +
13 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14 +
15 +// Generated by `./pycrc.py --algorithm=table-driven --model=dallas-1-wire --generate=c`
16 +var TABLE = [0x00, 0x5e, 0xbc, 0xe2, 0x61, 0x3f, 0xdd, 0x83, 0xc2, 0x9c, 0x7e, 0x20, 0xa3, 0xfd, 0x1f, 0x41, 0x9d, 0xc3, 0x21, 0x7f, 0xfc, 0xa2, 0x40, 0x1e, 0x5f, 0x01, 0xe3, 0xbd, 0x3e, 0x60, 0x82, 0xdc, 0x23, 0x7d, 0x9f, 0xc1, 0x42, 0x1c, 0xfe, 0xa0, 0xe1, 0xbf, 0x5d, 0x03, 0x80, 0xde, 0x3c, 0x62, 0xbe, 0xe0, 0x02, 0x5c, 0xdf, 0x81, 0x63, 0x3d, 0x7c, 0x22, 0xc0, 0x9e, 0x1d, 0x43, 0xa1, 0xff, 0x46, 0x18, 0xfa, 0xa4, 0x27, 0x79, 0x9b, 0xc5, 0x84, 0xda, 0x38, 0x66, 0xe5, 0xbb, 0x59, 0x07, 0xdb, 0x85, 0x67, 0x39, 0xba, 0xe4, 0x06, 0x58, 0x19, 0x47, 0xa5, 0xfb, 0x78, 0x26, 0xc4, 0x9a, 0x65, 0x3b, 0xd9, 0x87, 0x04, 0x5a, 0xb8, 0xe6, 0xa7, 0xf9, 0x1b, 0x45, 0xc6, 0x98, 0x7a, 0x24, 0xf8, 0xa6, 0x44, 0x1a, 0x99, 0xc7, 0x25, 0x7b, 0x3a, 0x64, 0x86, 0xd8, 0x5b, 0x05, 0xe7, 0xb9, 0x8c, 0xd2, 0x30, 0x6e, 0xed, 0xb3, 0x51, 0x0f, 0x4e, 0x10, 0xf2, 0xac, 0x2f, 0x71, 0x93, 0xcd, 0x11, 0x4f, 0xad, 0xf3, 0x70, 0x2e, 0xcc, 0x92, 0xd3, 0x8d, 0x6f, 0x31, 0xb2, 0xec, 0x0e, 0x50, 0xaf, 0xf1, 0x13, 0x4d, 0xce, 0x90, 0x72, 0x2c, 0x6d, 0x33, 0xd1, 0x8f, 0x0c, 0x52, 0xb0, 0xee, 0x32, 0x6c, 0x8e, 0xd0, 0x53, 0x0d, 0xef, 0xb1, 0xf0, 0xae, 0x4c, 0x12, 0x91, 0xcf, 0x2d, 0x73, 0xca, 0x94, 0x76, 0x28, 0xab, 0xf5, 0x17, 0x49, 0x08, 0x56, 0xb4, 0xea, 0x69, 0x37, 0xd5, 0x8b, 0x57, 0x09, 0xeb, 0xb5, 0x36, 0x68, 0x8a, 0xd4, 0x95, 0xcb, 0x29, 0x77, 0xf4, 0xaa, 0x48, 0x16, 0xe9, 0xb7, 0x55, 0x0b, 0x88, 0xd6, 0x34, 0x6a, 0x2b, 0x75, 0x97, 0xc9, 0x4a, 0x14, 0xf6, 0xa8, 0x74, 0x2a, 0xc8, 0x96, 0x15, 0x4b, 0xa9, 0xf7, 0xb6, 0xe8, 0x0a, 0x54, 0xd7, 0x89, 0x6b, 0x35];
17 +
18 +if (typeof Int32Array !== 'undefined') TABLE = new Int32Array(TABLE);
19 +
20 +module.exports = (0, _define_crc2.default)('dallas-1-wire', function (buf, previous) {
21 + if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf);
22 +
23 + var crc = ~~previous;
24 +
25 + for (var index = 0; index < buf.length; index++) {
26 + var byte = buf[index];
27 + crc = TABLE[(crc ^ byte) & 0xff] & 0xff;
28 + }
29 +
30 + return crc;
31 +});
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _buffer = require('buffer');
8 +
9 +var createBuffer = _buffer.Buffer.from && _buffer.Buffer.alloc && _buffer.Buffer.allocUnsafe && _buffer.Buffer.allocUnsafeSlow ? _buffer.Buffer.from
10 +
11 +// support for Node < 5.10
12 +: function (val) {
13 + return new _buffer.Buffer(val);
14 +};
15 +
16 +exports.default = createBuffer;
...\ No newline at end of file ...\ No newline at end of file
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +exports.default = function (model, calc) {
8 + var fn = function fn(buf, previous) {
9 + return calc(buf, previous) >>> 0;
10 + };
11 + fn.signed = calc;
12 + fn.unsigned = fn;
13 + fn.model = model;
14 +
15 + return fn;
16 +};
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +module.exports = {
4 + crc1: require('./crc1'),
5 + crc8: require('./crc8'),
6 + crc81wire: require('./crc8_1wire'),
7 + crc16: require('./crc16'),
8 + crc16ccitt: require('./crc16_ccitt'),
9 + crc16modbus: require('./crc16_modbus'),
10 + crc16xmodem: require('./crc16_xmodem'),
11 + crc16kermit: require('./crc16_kermit'),
12 + crc24: require('./crc24'),
13 + crc32: require('./crc32')
14 +};
...\ No newline at end of file ...\ No newline at end of file
1 +{
2 + "_from": "crc@3.4.4",
3 + "_id": "crc@3.4.4",
4 + "_inBundle": false,
5 + "_integrity": "sha1-naHpgOO9RPxck79as9ozeNheRms=",
6 + "_location": "/crc",
7 + "_phantomChildren": {},
8 + "_requested": {
9 + "type": "version",
10 + "registry": true,
11 + "raw": "crc@3.4.4",
12 + "name": "crc",
13 + "escapedName": "crc",
14 + "rawSpec": "3.4.4",
15 + "saveSpec": null,
16 + "fetchSpec": "3.4.4"
17 + },
18 + "_requiredBy": [
19 + "/express-session"
20 + ],
21 + "_resolved": "https://registry.npmjs.org/crc/-/crc-3.4.4.tgz",
22 + "_shasum": "9da1e980e3bd44fc5c93bf5ab3da3378d85e466b",
23 + "_spec": "crc@3.4.4",
24 + "_where": "C:\\Users\\지윤\\project_opensource\\node_modules\\express-session",
25 + "author": {
26 + "name": "Alex Gorbatchev",
27 + "url": "https://github.com/alexgorbatchev"
28 + },
29 + "bugs": {
30 + "url": "https://github.com/alexgorbatchev/node-crc/issues"
31 + },
32 + "bundleDependencies": false,
33 + "deprecated": false,
34 + "description": "Module for calculating Cyclic Redundancy Check (CRC) for Node.js and the Browser.",
35 + "devDependencies": {
36 + "babel-cli": "^6.3.15",
37 + "babel-core": "^6.1.21",
38 + "babel-preset-es2015": "^6.1.18",
39 + "beautify-benchmark": "^0.2.4",
40 + "benchmark": "^1.0.0",
41 + "buffer-crc32": "^0.2.3",
42 + "chai": "^3.4.1",
43 + "mocha": "*",
44 + "seedrandom": "^2.3.6"
45 + },
46 + "files": [
47 + "lib"
48 + ],
49 + "homepage": "https://github.com/alexgorbatchev/node-crc",
50 + "keywords": [
51 + "crc"
52 + ],
53 + "license": "MIT",
54 + "main": "./lib/index.js",
55 + "name": "crc",
56 + "repository": {
57 + "type": "git",
58 + "url": "git://github.com/alexgorbatchev/node-crc.git"
59 + },
60 + "scripts": {
61 + "pretest": "cd src && babel --out-dir ../lib *.js",
62 + "test": "mocha test/*.test.js"
63 + },
64 + "version": "3.4.4"
65 +}
1 +1.1.1 / 2017-07-27
2 +==================
3 +
4 + * Remove unnecessary `Buffer` loading
5 + * Support Node.js 0.6 to 8.x
6 +
7 +1.1.0 / 2015-09-14
8 +==================
9 +
10 + * Enable strict mode in more places
11 + * Support io.js 3.x
12 + * Support io.js 2.x
13 + * Support web browser loading
14 + - Requires bundler like Browserify or webpack
15 +
16 +1.0.1 / 2015-04-07
17 +==================
18 +
19 + * Fix `TypeError`s when under `'use strict'` code
20 + * Fix useless type name on auto-generated messages
21 + * Support io.js 1.x
22 + * Support Node.js 0.12
23 +
24 +1.0.0 / 2014-09-17
25 +==================
26 +
27 + * No changes
28 +
29 +0.4.5 / 2014-09-09
30 +==================
31 +
32 + * Improve call speed to functions using the function wrapper
33 + * Support Node.js 0.6
34 +
35 +0.4.4 / 2014-07-27
36 +==================
37 +
38 + * Work-around v8 generating empty stack traces
39 +
40 +0.4.3 / 2014-07-26
41 +==================
42 +
43 + * Fix exception when global `Error.stackTraceLimit` is too low
44 +
45 +0.4.2 / 2014-07-19
46 +==================
47 +
48 + * Correct call site for wrapped functions and properties
49 +
50 +0.4.1 / 2014-07-19
51 +==================
52 +
53 + * Improve automatic message generation for function properties
54 +
55 +0.4.0 / 2014-07-19
56 +==================
57 +
58 + * Add `TRACE_DEPRECATION` environment variable
59 + * Remove non-standard grey color from color output
60 + * Support `--no-deprecation` argument
61 + * Support `--trace-deprecation` argument
62 + * Support `deprecate.property(fn, prop, message)`
63 +
64 +0.3.0 / 2014-06-16
65 +==================
66 +
67 + * Add `NO_DEPRECATION` environment variable
68 +
69 +0.2.0 / 2014-06-15
70 +==================
71 +
72 + * Add `deprecate.property(obj, prop, message)`
73 + * Remove `supports-color` dependency for node.js 0.8
74 +
75 +0.1.0 / 2014-06-15
76 +==================
77 +
78 + * Add `deprecate.function(fn, message)`
79 + * Add `process.on('deprecation', fn)` emitter
80 + * Automatically generate message when omitted from `deprecate()`
81 +
82 +0.0.1 / 2014-06-15
83 +==================
84 +
85 + * Fix warning for dynamic calls at singe call site
86 +
87 +0.0.0 / 2014-06-15
88 +==================
89 +
90 + * Initial implementation
1 +(The MIT License)
2 +
3 +Copyright (c) 2014-2017 Douglas Christopher Wilson
4 +
5 +Permission is hereby granted, free of charge, to any person obtaining
6 +a copy of this software and associated documentation files (the
7 +'Software'), to deal in the Software without restriction, including
8 +without limitation the rights to use, copy, modify, merge, publish,
9 +distribute, sublicense, and/or sell copies of the Software, and to
10 +permit persons to whom the Software is furnished to do so, subject to
11 +the following conditions:
12 +
13 +The above copyright notice and this permission notice shall be
14 +included in all copies or substantial portions of the Software.
15 +
16 +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
17 +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20 +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21 +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22 +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1 +# depd
2 +
3 +[![NPM Version][npm-version-image]][npm-url]
4 +[![NPM Downloads][npm-downloads-image]][npm-url]
5 +[![Node.js Version][node-image]][node-url]
6 +[![Linux Build][travis-image]][travis-url]
7 +[![Windows Build][appveyor-image]][appveyor-url]
8 +[![Coverage Status][coveralls-image]][coveralls-url]
9 +[![Gratipay][gratipay-image]][gratipay-url]
10 +
11 +Deprecate all the things
12 +
13 +> With great modules comes great responsibility; mark things deprecated!
14 +
15 +## Install
16 +
17 +This module is installed directly using `npm`:
18 +
19 +```sh
20 +$ npm install depd
21 +```
22 +
23 +This module can also be bundled with systems like
24 +[Browserify](http://browserify.org/) or [webpack](https://webpack.github.io/),
25 +though by default this module will alter it's API to no longer display or
26 +track deprecations.
27 +
28 +## API
29 +
30 +<!-- eslint-disable no-unused-vars -->
31 +
32 +```js
33 +var deprecate = require('depd')('my-module')
34 +```
35 +
36 +This library allows you to display deprecation messages to your users.
37 +This library goes above and beyond with deprecation warnings by
38 +introspection of the call stack (but only the bits that it is interested
39 +in).
40 +
41 +Instead of just warning on the first invocation of a deprecated
42 +function and never again, this module will warn on the first invocation
43 +of a deprecated function per unique call site, making it ideal to alert
44 +users of all deprecated uses across the code base, rather than just
45 +whatever happens to execute first.
46 +
47 +The deprecation warnings from this module also include the file and line
48 +information for the call into the module that the deprecated function was
49 +in.
50 +
51 +**NOTE** this library has a similar interface to the `debug` module, and
52 +this module uses the calling file to get the boundary for the call stacks,
53 +so you should always create a new `deprecate` object in each file and not
54 +within some central file.
55 +
56 +### depd(namespace)
57 +
58 +Create a new deprecate function that uses the given namespace name in the
59 +messages and will display the call site prior to the stack entering the
60 +file this function was called from. It is highly suggested you use the
61 +name of your module as the namespace.
62 +
63 +### deprecate(message)
64 +
65 +Call this function from deprecated code to display a deprecation message.
66 +This message will appear once per unique caller site. Caller site is the
67 +first call site in the stack in a different file from the caller of this
68 +function.
69 +
70 +If the message is omitted, a message is generated for you based on the site
71 +of the `deprecate()` call and will display the name of the function called,
72 +similar to the name displayed in a stack trace.
73 +
74 +### deprecate.function(fn, message)
75 +
76 +Call this function to wrap a given function in a deprecation message on any
77 +call to the function. An optional message can be supplied to provide a custom
78 +message.
79 +
80 +### deprecate.property(obj, prop, message)
81 +
82 +Call this function to wrap a given property on object in a deprecation message
83 +on any accessing or setting of the property. An optional message can be supplied
84 +to provide a custom message.
85 +
86 +The method must be called on the object where the property belongs (not
87 +inherited from the prototype).
88 +
89 +If the property is a data descriptor, it will be converted to an accessor
90 +descriptor in order to display the deprecation message.
91 +
92 +### process.on('deprecation', fn)
93 +
94 +This module will allow easy capturing of deprecation errors by emitting the
95 +errors as the type "deprecation" on the global `process`. If there are no
96 +listeners for this type, the errors are written to STDERR as normal, but if
97 +there are any listeners, nothing will be written to STDERR and instead only
98 +emitted. From there, you can write the errors in a different format or to a
99 +logging source.
100 +
101 +The error represents the deprecation and is emitted only once with the same
102 +rules as writing to STDERR. The error has the following properties:
103 +
104 + - `message` - This is the message given by the library
105 + - `name` - This is always `'DeprecationError'`
106 + - `namespace` - This is the namespace the deprecation came from
107 + - `stack` - This is the stack of the call to the deprecated thing
108 +
109 +Example `error.stack` output:
110 +
111 +```
112 +DeprecationError: my-cool-module deprecated oldfunction
113 + at Object.<anonymous> ([eval]-wrapper:6:22)
114 + at Module._compile (module.js:456:26)
115 + at evalScript (node.js:532:25)
116 + at startup (node.js:80:7)
117 + at node.js:902:3
118 +```
119 +
120 +### process.env.NO_DEPRECATION
121 +
122 +As a user of modules that are deprecated, the environment variable `NO_DEPRECATION`
123 +is provided as a quick solution to silencing deprecation warnings from being
124 +output. The format of this is similar to that of `DEBUG`:
125 +
126 +```sh
127 +$ NO_DEPRECATION=my-module,othermod node app.js
128 +```
129 +
130 +This will suppress deprecations from being output for "my-module" and "othermod".
131 +The value is a list of comma-separated namespaces. To suppress every warning
132 +across all namespaces, use the value `*` for a namespace.
133 +
134 +Providing the argument `--no-deprecation` to the `node` executable will suppress
135 +all deprecations (only available in Node.js 0.8 or higher).
136 +
137 +**NOTE** This will not suppress the deperecations given to any "deprecation"
138 +event listeners, just the output to STDERR.
139 +
140 +### process.env.TRACE_DEPRECATION
141 +
142 +As a user of modules that are deprecated, the environment variable `TRACE_DEPRECATION`
143 +is provided as a solution to getting more detailed location information in deprecation
144 +warnings by including the entire stack trace. The format of this is the same as
145 +`NO_DEPRECATION`:
146 +
147 +```sh
148 +$ TRACE_DEPRECATION=my-module,othermod node app.js
149 +```
150 +
151 +This will include stack traces for deprecations being output for "my-module" and
152 +"othermod". The value is a list of comma-separated namespaces. To trace every
153 +warning across all namespaces, use the value `*` for a namespace.
154 +
155 +Providing the argument `--trace-deprecation` to the `node` executable will trace
156 +all deprecations (only available in Node.js 0.8 or higher).
157 +
158 +**NOTE** This will not trace the deperecations silenced by `NO_DEPRECATION`.
159 +
160 +## Display
161 +
162 +![message](files/message.png)
163 +
164 +When a user calls a function in your library that you mark deprecated, they
165 +will see the following written to STDERR (in the given colors, similar colors
166 +and layout to the `debug` module):
167 +
168 +```
169 +bright cyan bright yellow
170 +| | reset cyan
171 +| | | |
172 +▼ ▼ ▼ ▼
173 +my-cool-module deprecated oldfunction [eval]-wrapper:6:22
174 +▲ ▲ ▲ ▲
175 +| | | |
176 +namespace | | location of mycoolmod.oldfunction() call
177 + | deprecation message
178 + the word "deprecated"
179 +```
180 +
181 +If the user redirects their STDERR to a file or somewhere that does not support
182 +colors, they see (similar layout to the `debug` module):
183 +
184 +```
185 +Sun, 15 Jun 2014 05:21:37 GMT my-cool-module deprecated oldfunction at [eval]-wrapper:6:22
186 +▲ ▲ ▲ ▲ ▲
187 +| | | | |
188 +timestamp of message namespace | | location of mycoolmod.oldfunction() call
189 + | deprecation message
190 + the word "deprecated"
191 +```
192 +
193 +## Examples
194 +
195 +### Deprecating all calls to a function
196 +
197 +This will display a deprecated message about "oldfunction" being deprecated
198 +from "my-module" on STDERR.
199 +
200 +```js
201 +var deprecate = require('depd')('my-cool-module')
202 +
203 +// message automatically derived from function name
204 +// Object.oldfunction
205 +exports.oldfunction = deprecate.function(function oldfunction () {
206 + // all calls to function are deprecated
207 +})
208 +
209 +// specific message
210 +exports.oldfunction = deprecate.function(function () {
211 + // all calls to function are deprecated
212 +}, 'oldfunction')
213 +```
214 +
215 +### Conditionally deprecating a function call
216 +
217 +This will display a deprecated message about "weirdfunction" being deprecated
218 +from "my-module" on STDERR when called with less than 2 arguments.
219 +
220 +```js
221 +var deprecate = require('depd')('my-cool-module')
222 +
223 +exports.weirdfunction = function () {
224 + if (arguments.length < 2) {
225 + // calls with 0 or 1 args are deprecated
226 + deprecate('weirdfunction args < 2')
227 + }
228 +}
229 +```
230 +
231 +When calling `deprecate` as a function, the warning is counted per call site
232 +within your own module, so you can display different deprecations depending
233 +on different situations and the users will still get all the warnings:
234 +
235 +```js
236 +var deprecate = require('depd')('my-cool-module')
237 +
238 +exports.weirdfunction = function () {
239 + if (arguments.length < 2) {
240 + // calls with 0 or 1 args are deprecated
241 + deprecate('weirdfunction args < 2')
242 + } else if (typeof arguments[0] !== 'string') {
243 + // calls with non-string first argument are deprecated
244 + deprecate('weirdfunction non-string first arg')
245 + }
246 +}
247 +```
248 +
249 +### Deprecating property access
250 +
251 +This will display a deprecated message about "oldprop" being deprecated
252 +from "my-module" on STDERR when accessed. A deprecation will be displayed
253 +when setting the value and when getting the value.
254 +
255 +```js
256 +var deprecate = require('depd')('my-cool-module')
257 +
258 +exports.oldprop = 'something'
259 +
260 +// message automatically derives from property name
261 +deprecate.property(exports, 'oldprop')
262 +
263 +// explicit message
264 +deprecate.property(exports, 'oldprop', 'oldprop >= 0.10')
265 +```
266 +
267 +## License
268 +
269 +[MIT](LICENSE)
270 +
271 +[npm-version-image]: https://img.shields.io/npm/v/depd.svg
272 +[npm-downloads-image]: https://img.shields.io/npm/dm/depd.svg
273 +[npm-url]: https://npmjs.org/package/depd
274 +[travis-image]: https://img.shields.io/travis/dougwilson/nodejs-depd/master.svg?label=linux
275 +[travis-url]: https://travis-ci.org/dougwilson/nodejs-depd
276 +[appveyor-image]: https://img.shields.io/appveyor/ci/dougwilson/nodejs-depd/master.svg?label=windows
277 +[appveyor-url]: https://ci.appveyor.com/project/dougwilson/nodejs-depd
278 +[coveralls-image]: https://img.shields.io/coveralls/dougwilson/nodejs-depd/master.svg
279 +[coveralls-url]: https://coveralls.io/r/dougwilson/nodejs-depd?branch=master
280 +[node-image]: https://img.shields.io/node/v/depd.svg
281 +[node-url]: https://nodejs.org/en/download/
282 +[gratipay-image]: https://img.shields.io/gratipay/dougwilson.svg
283 +[gratipay-url]: https://www.gratipay.com/dougwilson/
This diff is collapsed. Click to expand it.
1 +/*!
2 + * depd
3 + * Copyright(c) 2015 Douglas Christopher Wilson
4 + * MIT Licensed
5 + */
6 +
7 +'use strict'
8 +
9 +/**
10 + * Module exports.
11 + * @public
12 + */
13 +
14 +module.exports = depd
15 +
16 +/**
17 + * Create deprecate for namespace in caller.
18 + */
19 +
20 +function depd (namespace) {
21 + if (!namespace) {
22 + throw new TypeError('argument namespace is required')
23 + }
24 +
25 + function deprecate (message) {
26 + // no-op in browser
27 + }
28 +
29 + deprecate._file = undefined
30 + deprecate._ignored = true
31 + deprecate._namespace = namespace
32 + deprecate._traced = false
33 + deprecate._warned = Object.create(null)
34 +
35 + deprecate.function = wrapfunction
36 + deprecate.property = wrapproperty
37 +
38 + return deprecate
39 +}
40 +
41 +/**
42 + * Return a wrapped function in a deprecation message.
43 + *
44 + * This is a no-op version of the wrapper, which does nothing but call
45 + * validation.
46 + */
47 +
48 +function wrapfunction (fn, message) {
49 + if (typeof fn !== 'function') {
50 + throw new TypeError('argument fn must be a function')
51 + }
52 +
53 + return fn
54 +}
55 +
56 +/**
57 + * Wrap property in a deprecation message.
58 + *
59 + * This is a no-op version of the wrapper, which does nothing but call
60 + * validation.
61 + */
62 +
63 +function wrapproperty (obj, prop, message) {
64 + if (!obj || (typeof obj !== 'object' && typeof obj !== 'function')) {
65 + throw new TypeError('argument obj must be object')
66 + }
67 +
68 + var descriptor = Object.getOwnPropertyDescriptor(obj, prop)
69 +
70 + if (!descriptor) {
71 + throw new TypeError('must call property on owner object')
72 + }
73 +
74 + if (!descriptor.configurable) {
75 + throw new TypeError('property must be configurable')
76 + }
77 +}
1 +/*!
2 + * depd
3 + * Copyright(c) 2014 Douglas Christopher Wilson
4 + * MIT Licensed
5 + */
6 +
7 +'use strict'
8 +
9 +/**
10 + * Module exports.
11 + */
12 +
13 +module.exports = callSiteToString
14 +
15 +/**
16 + * Format a CallSite file location to a string.
17 + */
18 +
19 +function callSiteFileLocation (callSite) {
20 + var fileName
21 + var fileLocation = ''
22 +
23 + if (callSite.isNative()) {
24 + fileLocation = 'native'
25 + } else if (callSite.isEval()) {
26 + fileName = callSite.getScriptNameOrSourceURL()
27 + if (!fileName) {
28 + fileLocation = callSite.getEvalOrigin()
29 + }
30 + } else {
31 + fileName = callSite.getFileName()
32 + }
33 +
34 + if (fileName) {
35 + fileLocation += fileName
36 +
37 + var lineNumber = callSite.getLineNumber()
38 + if (lineNumber != null) {
39 + fileLocation += ':' + lineNumber
40 +
41 + var columnNumber = callSite.getColumnNumber()
42 + if (columnNumber) {
43 + fileLocation += ':' + columnNumber
44 + }
45 + }
46 + }
47 +
48 + return fileLocation || 'unknown source'
49 +}
50 +
51 +/**
52 + * Format a CallSite to a string.
53 + */
54 +
55 +function callSiteToString (callSite) {
56 + var addSuffix = true
57 + var fileLocation = callSiteFileLocation(callSite)
58 + var functionName = callSite.getFunctionName()
59 + var isConstructor = callSite.isConstructor()
60 + var isMethodCall = !(callSite.isToplevel() || isConstructor)
61 + var line = ''
62 +
63 + if (isMethodCall) {
64 + var methodName = callSite.getMethodName()
65 + var typeName = getConstructorName(callSite)
66 +
67 + if (functionName) {
68 + if (typeName && functionName.indexOf(typeName) !== 0) {
69 + line += typeName + '.'
70 + }
71 +
72 + line += functionName
73 +
74 + if (methodName && functionName.lastIndexOf('.' + methodName) !== functionName.length - methodName.length - 1) {
75 + line += ' [as ' + methodName + ']'
76 + }
77 + } else {
78 + line += typeName + '.' + (methodName || '<anonymous>')
79 + }
80 + } else if (isConstructor) {
81 + line += 'new ' + (functionName || '<anonymous>')
82 + } else if (functionName) {
83 + line += functionName
84 + } else {
85 + addSuffix = false
86 + line += fileLocation
87 + }
88 +
89 + if (addSuffix) {
90 + line += ' (' + fileLocation + ')'
91 + }
92 +
93 + return line
94 +}
95 +
96 +/**
97 + * Get constructor name of reviver.
98 + */
99 +
100 +function getConstructorName (obj) {
101 + var receiver = obj.receiver
102 + return (receiver.constructor && receiver.constructor.name) || null
103 +}
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
No preview for this file type
No preview for this file type
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
No preview for this file type
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.