Showing
428 changed files
with
3525 additions
and
774 deletions
... | @@ -12,7 +12,7 @@ var http = require('http'); | ... | @@ -12,7 +12,7 @@ var http = require('http'); |
12 | * Get port from environment and store in Express. | 12 | * Get port from environment and store in Express. |
13 | */ | 13 | */ |
14 | 14 | ||
15 | -var port = normalizePort(process.env.PORT || '80'); | 15 | +var port = normalizePort(process.env.PORT || '3000'); |
16 | app.set('port', port); | 16 | app.set('port', port); |
17 | 17 | ||
18 | /** | 18 | /** | ... | ... |
1 | { | 1 | { |
2 | - "_from": "accepts@~1.3.4", | 2 | + "_from": "accepts@~1.3.5", |
3 | - "_id": "accepts@1.3.4", | 3 | + "_id": "accepts@1.3.5", |
4 | "_inBundle": false, | 4 | "_inBundle": false, |
5 | - "_integrity": "sha1-hiRnWMfdbSGmR0/whKR0DsBesh8=", | 5 | + "_integrity": "sha1-63d99gEXI6OxTopywIBcjoZ0a9I=", |
6 | "_location": "/accepts", | 6 | "_location": "/accepts", |
7 | "_phantomChildren": {}, | 7 | "_phantomChildren": {}, |
8 | "_requested": { | 8 | "_requested": { |
9 | "type": "range", | 9 | "type": "range", |
10 | "registry": true, | 10 | "registry": true, |
11 | - "raw": "accepts@~1.3.4", | 11 | + "raw": "accepts@~1.3.5", |
12 | "name": "accepts", | 12 | "name": "accepts", |
13 | "escapedName": "accepts", | 13 | "escapedName": "accepts", |
14 | - "rawSpec": "~1.3.4", | 14 | + "rawSpec": "~1.3.5", |
15 | "saveSpec": null, | 15 | "saveSpec": null, |
16 | - "fetchSpec": "~1.3.4" | 16 | + "fetchSpec": "~1.3.5" |
17 | }, | 17 | }, |
18 | "_requiredBy": [ | 18 | "_requiredBy": [ |
19 | "/express" | 19 | "/express" |
20 | ], | 20 | ], |
21 | - "_resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.4.tgz", | 21 | + "_resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.5.tgz", |
22 | - "_shasum": "86246758c7dd6d21a6474ff084a4740ec05eb21f", | 22 | + "_shasum": "eb777df6011723a3b14e8a72c0805c8e86746bd2", |
23 | - "_spec": "accepts@~1.3.4", | 23 | + "_spec": "accepts@~1.3.5", |
24 | - "_where": "/home/ubuntu/Opensource/node_modules/express", | 24 | + "_where": "/home/jin/opensource/kakaoBot/node_modules/express", |
25 | "bugs": { | 25 | "bugs": { |
26 | "url": "https://github.com/jshttp/accepts/issues" | 26 | "url": "https://github.com/jshttp/accepts/issues" |
27 | }, | 27 | }, |
... | @@ -38,18 +38,18 @@ | ... | @@ -38,18 +38,18 @@ |
38 | } | 38 | } |
39 | ], | 39 | ], |
40 | "dependencies": { | 40 | "dependencies": { |
41 | - "mime-types": "~2.1.16", | 41 | + "mime-types": "~2.1.18", |
42 | "negotiator": "0.6.1" | 42 | "negotiator": "0.6.1" |
43 | }, | 43 | }, |
44 | "deprecated": false, | 44 | "deprecated": false, |
45 | "description": "Higher-level content negotiation", | 45 | "description": "Higher-level content negotiation", |
46 | "devDependencies": { | 46 | "devDependencies": { |
47 | - "eslint": "3.19.0", | 47 | + "eslint": "4.18.1", |
48 | - "eslint-config-standard": "10.2.1", | 48 | + "eslint-config-standard": "11.0.0", |
49 | - "eslint-plugin-import": "2.7.0", | 49 | + "eslint-plugin-import": "2.9.0", |
50 | "eslint-plugin-markdown": "1.0.0-beta.6", | 50 | "eslint-plugin-markdown": "1.0.0-beta.6", |
51 | - "eslint-plugin-node": "5.1.1", | 51 | + "eslint-plugin-node": "6.0.1", |
52 | - "eslint-plugin-promise": "3.5.0", | 52 | + "eslint-plugin-promise": "3.6.0", |
53 | "eslint-plugin-standard": "3.0.1", | 53 | "eslint-plugin-standard": "3.0.1", |
54 | "istanbul": "0.4.5", | 54 | "istanbul": "0.4.5", |
55 | "mocha": "~1.21.5" | 55 | "mocha": "~1.21.5" |
... | @@ -81,5 +81,5 @@ | ... | @@ -81,5 +81,5 @@ |
81 | "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks 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/" | 82 | "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" |
83 | }, | 83 | }, |
84 | - "version": "1.3.4" | 84 | + "version": "1.3.5" |
85 | } | 85 | } | ... | ... |
... | @@ -74,7 +74,7 @@ Currently Ajv is the fastest and the most standard compliant validator according | ... | @@ -74,7 +74,7 @@ Currently Ajv is the fastest and the most standard compliant validator according |
74 | 74 | ||
75 | Performance of different validators by [json-schema-benchmark](https://github.com/ebdrup/json-schema-benchmark): | 75 | Performance of different validators by [json-schema-benchmark](https://github.com/ebdrup/json-schema-benchmark): |
76 | 76 | ||
77 | -[![performance](https://chart.googleapis.com/chart?chxt=x,y&cht=bhs&chco=76A4FB&chls=2.0&chbh=32,4,1&chs=600x416&chxl=-1:%7Cajv%7Cis-my-json-valid%7Cjsen%7Cschemasaurus%7Cthemis%7Cz-schema%7Cjsck%7Cjsonschema%7Cskeemas%7Ctv4%7Cjayschema&chd=t:100,68,61,22.8,17.6,6.6,2.7,0.9,0.7,0.4,0.1)](https://github.com/ebdrup/json-schema-benchmark/blob/master/README.md#performance) | 77 | +[![performance](https://chart.googleapis.com/chart?chxt=x,y&cht=bhs&chco=76A4FB&chls=2.0&chbh=32,4,1&chs=600x416&chxl=-1:|djv|ajv|json-schema-validator-generator|jsen|is-my-json-valid|themis|z-schema|jsck|skeemas|json-schema-library|tv4&chd=t:100,98,72.1,66.8,50.1,15.1,6.1,3.8,1.2,0.7,0.2)](https://github.com/ebdrup/json-schema-benchmark/blob/master/README.md#performance) |
78 | 78 | ||
79 | 79 | ||
80 | ## Features | 80 | ## Features | ... | ... |
... | @@ -6971,7 +6971,7 @@ function compile(schema, _meta) { | ... | @@ -6971,7 +6971,7 @@ function compile(schema, _meta) { |
6971 | function addSchema(schema, key, _skipValidation, _meta) { | 6971 | function addSchema(schema, key, _skipValidation, _meta) { |
6972 | if (Array.isArray(schema)){ | 6972 | if (Array.isArray(schema)){ |
6973 | for (var i=0; i<schema.length; i++) this.addSchema(schema[i], undefined, _skipValidation, _meta); | 6973 | for (var i=0; i<schema.length; i++) this.addSchema(schema[i], undefined, _skipValidation, _meta); |
6974 | - return; | 6974 | + return this; |
6975 | } | 6975 | } |
6976 | var id = this._getId(schema); | 6976 | var id = this._getId(schema); |
6977 | if (id !== undefined && typeof id != 'string') | 6977 | if (id !== undefined && typeof id != 'string') | ... | ... |
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 could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
... | @@ -131,7 +131,7 @@ function compile(schema, _meta) { | ... | @@ -131,7 +131,7 @@ function compile(schema, _meta) { |
131 | function addSchema(schema, key, _skipValidation, _meta) { | 131 | function addSchema(schema, key, _skipValidation, _meta) { |
132 | if (Array.isArray(schema)){ | 132 | if (Array.isArray(schema)){ |
133 | for (var i=0; i<schema.length; i++) this.addSchema(schema[i], undefined, _skipValidation, _meta); | 133 | for (var i=0; i<schema.length; i++) this.addSchema(schema[i], undefined, _skipValidation, _meta); |
134 | - return; | 134 | + return this; |
135 | } | 135 | } |
136 | var id = this._getId(schema); | 136 | var id = this._getId(schema); |
137 | if (id !== undefined && typeof id != 'string') | 137 | if (id !== undefined && typeof id != 'string') | ... | ... |
1 | { | 1 | { |
2 | - "_from": "ajv@^5.1.0", | 2 | + "_from": "ajv@^5.3.0", |
3 | - "_id": "ajv@5.5.0", | 3 | + "_id": "ajv@5.5.2", |
4 | "_inBundle": false, | 4 | "_inBundle": false, |
5 | - "_integrity": "sha1-6yhAdG6dxIvV4GOjbj/UAMXqtak=", | 5 | + "_integrity": "sha1-c7Xuyj+rZT49P5Qis0GtQiBdyWU=", |
6 | "_location": "/ajv", | 6 | "_location": "/ajv", |
7 | "_phantomChildren": {}, | 7 | "_phantomChildren": {}, |
8 | "_requested": { | 8 | "_requested": { |
9 | "type": "range", | 9 | "type": "range", |
10 | "registry": true, | 10 | "registry": true, |
11 | - "raw": "ajv@^5.1.0", | 11 | + "raw": "ajv@^5.3.0", |
12 | "name": "ajv", | 12 | "name": "ajv", |
13 | "escapedName": "ajv", | 13 | "escapedName": "ajv", |
14 | - "rawSpec": "^5.1.0", | 14 | + "rawSpec": "^5.3.0", |
15 | "saveSpec": null, | 15 | "saveSpec": null, |
16 | - "fetchSpec": "^5.1.0" | 16 | + "fetchSpec": "^5.3.0" |
17 | }, | 17 | }, |
18 | "_requiredBy": [ | 18 | "_requiredBy": [ |
19 | "/har-validator" | 19 | "/har-validator" |
20 | ], | 20 | ], |
21 | - "_resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.0.tgz", | 21 | + "_resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz", |
22 | - "_shasum": "eb2840746e9dc48bd5e063a36e3fd400c5eab5a9", | 22 | + "_shasum": "73b5eeca3fab653e3d3f9422b341ad42205dc965", |
23 | - "_spec": "ajv@^5.1.0", | 23 | + "_spec": "ajv@^5.3.0", |
24 | - "_where": "/home/ubuntu/Opensource/node_modules/har-validator", | 24 | + "_where": "/home/jin/opensource/kakaoBot/node_modules/har-validator", |
25 | "author": { | 25 | "author": { |
26 | "name": "Evgeny Poberezkin" | 26 | "name": "Evgeny Poberezkin" |
27 | }, | 27 | }, |
... | @@ -52,7 +52,7 @@ | ... | @@ -52,7 +52,7 @@ |
52 | "if-node-version": "^1.0.0", | 52 | "if-node-version": "^1.0.0", |
53 | "js-beautify": "^1.7.3", | 53 | "js-beautify": "^1.7.3", |
54 | "jshint": "^2.9.4", | 54 | "jshint": "^2.9.4", |
55 | - "json-schema-test": "^1.3.0", | 55 | + "json-schema-test": "^2.0.0", |
56 | "karma": "^1.0.0", | 56 | "karma": "^1.0.0", |
57 | "karma-chrome-launcher": "^2.0.0", | 57 | "karma-chrome-launcher": "^2.0.0", |
58 | "karma-mocha": "^1.1.1", | 58 | "karma-mocha": "^1.1.1", |
... | @@ -63,9 +63,9 @@ | ... | @@ -63,9 +63,9 @@ |
63 | "nyc": "^11.0.2", | 63 | "nyc": "^11.0.2", |
64 | "phantomjs-prebuilt": "^2.1.4", | 64 | "phantomjs-prebuilt": "^2.1.4", |
65 | "pre-commit": "^1.1.1", | 65 | "pre-commit": "^1.1.1", |
66 | - "regenerator": "0.11.1", | 66 | + "regenerator": "^0.12.2", |
67 | "require-globify": "^1.3.0", | 67 | "require-globify": "^1.3.0", |
68 | - "typescript": "^2.0.3", | 68 | + "typescript": "^2.6.2", |
69 | "uglify-js": "^3.1.5", | 69 | "uglify-js": "^3.1.5", |
70 | "watch": "^1.0.0" | 70 | "watch": "^1.0.0" |
71 | }, | 71 | }, |
... | @@ -111,7 +111,7 @@ | ... | @@ -111,7 +111,7 @@ |
111 | "bundle-beautify": "node ./scripts/bundle.js js-beautify", | 111 | "bundle-beautify": "node ./scripts/bundle.js js-beautify", |
112 | "bundle-nodent": "node ./scripts/bundle.js nodent", | 112 | "bundle-nodent": "node ./scripts/bundle.js nodent", |
113 | "bundle-regenerator": "node ./scripts/bundle.js regenerator", | 113 | "bundle-regenerator": "node ./scripts/bundle.js regenerator", |
114 | - "eslint": "if-node-version \">=4\" eslint lib/*.js lib/compile/*.js spec scripts", | 114 | + "eslint": "if-node-version \">=4\" eslint lib/*.js lib/compile/*.js spec/*.js scripts", |
115 | "jshint": "jshint lib/*.js lib/**/*.js --exclude lib/dotjs/**/*", | 115 | "jshint": "jshint lib/*.js lib/**/*.js --exclude lib/dotjs/**/*", |
116 | "prepublish": "npm run build && npm run bundle-all", | 116 | "prepublish": "npm run build && npm run bundle-all", |
117 | "test": "npm run jshint && npm run eslint && npm run test-ts && npm run build && npm run test-cov && if-node-version 4 npm run test-browser", | 117 | "test": "npm run jshint && npm run eslint && npm run test-ts && npm run build && npm run test-cov && if-node-version 4 npm run test-browser", |
... | @@ -126,5 +126,5 @@ | ... | @@ -126,5 +126,5 @@ |
126 | }, | 126 | }, |
127 | "tonicExampleFilename": ".tonic_example.js", | 127 | "tonicExampleFilename": ".tonic_example.js", |
128 | "typings": "lib/ajv.d.ts", | 128 | "typings": "lib/ajv.d.ts", |
129 | - "version": "5.5.0" | 129 | + "version": "5.5.2" |
130 | } | 130 | } | ... | ... |
... | @@ -21,7 +21,7 @@ | ... | @@ -21,7 +21,7 @@ |
21 | "_resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", | 21 | "_resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", |
22 | "_shasum": "9a5f699051b1e7073328f2a008968b64ea2955d2", | 22 | "_shasum": "9a5f699051b1e7073328f2a008968b64ea2955d2", |
23 | "_spec": "array-flatten@1.1.1", | 23 | "_spec": "array-flatten@1.1.1", |
24 | - "_where": "/home/ubuntu/Opensource/node_modules/express", | 24 | + "_where": "/home/jin/opensource/kakaoBot/node_modules/express", |
25 | "author": { | 25 | "author": { |
26 | "name": "Blake Embrey", | 26 | "name": "Blake Embrey", |
27 | "email": "hello@blakeembrey.com", | 27 | "email": "hello@blakeembrey.com", | ... | ... |
node_modules/asn1/.npmignore
deleted
100644 → 0
node_modules/asn1/.travis.yml
deleted
100644 → 0
... | @@ -16,7 +16,7 @@ The following reads an ASN.1 sequence with a boolean. | ... | @@ -16,7 +16,7 @@ The following reads an ASN.1 sequence with a boolean. |
16 | 16 | ||
17 | var Ber = require('asn1').Ber; | 17 | var Ber = require('asn1').Ber; |
18 | 18 | ||
19 | - var reader = new Ber.Reader(new Buffer([0x30, 0x03, 0x01, 0x01, 0xff])); | 19 | + var reader = new Ber.Reader(Buffer.from([0x30, 0x03, 0x01, 0x01, 0xff])); |
20 | 20 | ||
21 | reader.readSequence(); | 21 | reader.readSequence(); |
22 | console.log('Sequence len: ' + reader.length); | 22 | console.log('Sequence len: ' + reader.length); |
... | @@ -47,4 +47,4 @@ MIT. | ... | @@ -47,4 +47,4 @@ MIT. |
47 | 47 | ||
48 | ## Bugs | 48 | ## Bugs |
49 | 49 | ||
50 | -See <https://github.com/mcavage/node-asn1/issues>. | 50 | +See <https://github.com/joyent/node-asn1/issues>. | ... | ... |
... | @@ -3,7 +3,7 @@ | ... | @@ -3,7 +3,7 @@ |
3 | 3 | ||
4 | module.exports = { | 4 | module.exports = { |
5 | 5 | ||
6 | - newInvalidAsn1Error: function(msg) { | 6 | + newInvalidAsn1Error: function (msg) { |
7 | var e = new Error(); | 7 | var e = new Error(); |
8 | e.name = 'InvalidAsn1Error'; | 8 | e.name = 'InvalidAsn1Error'; |
9 | e.message = msg || ''; | 9 | e.message = msg || ''; | ... | ... |
1 | // Copyright 2011 Mark Cavage <mcavage@gmail.com> All rights reserved. | 1 | // Copyright 2011 Mark Cavage <mcavage@gmail.com> All rights reserved. |
2 | 2 | ||
3 | var assert = require('assert'); | 3 | var assert = require('assert'); |
4 | +var Buffer = require('safer-buffer').Buffer; | ||
4 | 5 | ||
5 | var ASN1 = require('./types'); | 6 | var ASN1 = require('./types'); |
6 | var errors = require('./errors'); | 7 | var errors = require('./errors'); |
7 | 8 | ||
8 | 9 | ||
9 | -///--- Globals | 10 | +// --- Globals |
10 | 11 | ||
11 | var newInvalidAsn1Error = errors.newInvalidAsn1Error; | 12 | var newInvalidAsn1Error = errors.newInvalidAsn1Error; |
12 | 13 | ||
13 | 14 | ||
14 | 15 | ||
15 | -///--- API | 16 | +// --- API |
16 | 17 | ||
17 | function Reader(data) { | 18 | function Reader(data) { |
18 | if (!data || !Buffer.isBuffer(data)) | 19 | if (!data || !Buffer.isBuffer(data)) |
... | @@ -52,7 +53,7 @@ Object.defineProperty(Reader.prototype, 'buffer', { | ... | @@ -52,7 +53,7 @@ Object.defineProperty(Reader.prototype, 'buffer', { |
52 | * @param {Boolean} peek true means don't move offset. | 53 | * @param {Boolean} peek true means don't move offset. |
53 | * @return {Number} the next byte, null if not enough data. | 54 | * @return {Number} the next byte, null if not enough data. |
54 | */ | 55 | */ |
55 | -Reader.prototype.readByte = function(peek) { | 56 | +Reader.prototype.readByte = function (peek) { |
56 | if (this._size - this._offset < 1) | 57 | if (this._size - this._offset < 1) |
57 | return null; | 58 | return null; |
58 | 59 | ||
... | @@ -65,7 +66,7 @@ Reader.prototype.readByte = function(peek) { | ... | @@ -65,7 +66,7 @@ Reader.prototype.readByte = function(peek) { |
65 | }; | 66 | }; |
66 | 67 | ||
67 | 68 | ||
68 | -Reader.prototype.peek = function() { | 69 | +Reader.prototype.peek = function () { |
69 | return this.readByte(true); | 70 | return this.readByte(true); |
70 | }; | 71 | }; |
71 | 72 | ||
... | @@ -81,7 +82,7 @@ Reader.prototype.peek = function() { | ... | @@ -81,7 +82,7 @@ Reader.prototype.peek = function() { |
81 | * @return {Number} the amount of offset to advance the buffer. | 82 | * @return {Number} the amount of offset to advance the buffer. |
82 | * @throws {InvalidAsn1Error} on bad ASN.1 | 83 | * @throws {InvalidAsn1Error} on bad ASN.1 |
83 | */ | 84 | */ |
84 | -Reader.prototype.readLength = function(offset) { | 85 | +Reader.prototype.readLength = function (offset) { |
85 | if (offset === undefined) | 86 | if (offset === undefined) |
86 | offset = this._offset; | 87 | offset = this._offset; |
87 | 88 | ||
... | @@ -92,10 +93,10 @@ Reader.prototype.readLength = function(offset) { | ... | @@ -92,10 +93,10 @@ Reader.prototype.readLength = function(offset) { |
92 | if (lenB === null) | 93 | if (lenB === null) |
93 | return null; | 94 | return null; |
94 | 95 | ||
95 | - if ((lenB & 0x80) == 0x80) { | 96 | + if ((lenB & 0x80) === 0x80) { |
96 | lenB &= 0x7f; | 97 | lenB &= 0x7f; |
97 | 98 | ||
98 | - if (lenB == 0) | 99 | + if (lenB === 0) |
99 | throw newInvalidAsn1Error('Indefinite length not supported'); | 100 | throw newInvalidAsn1Error('Indefinite length not supported'); |
100 | 101 | ||
101 | if (lenB > 4) | 102 | if (lenB > 4) |
... | @@ -124,7 +125,7 @@ Reader.prototype.readLength = function(offset) { | ... | @@ -124,7 +125,7 @@ Reader.prototype.readLength = function(offset) { |
124 | * | 125 | * |
125 | * @return {Number} the sequence's tag. | 126 | * @return {Number} the sequence's tag. |
126 | */ | 127 | */ |
127 | -Reader.prototype.readSequence = function(tag) { | 128 | +Reader.prototype.readSequence = function (tag) { |
128 | var seq = this.peek(); | 129 | var seq = this.peek(); |
129 | if (seq === null) | 130 | if (seq === null) |
130 | return null; | 131 | return null; |
... | @@ -141,22 +142,22 @@ Reader.prototype.readSequence = function(tag) { | ... | @@ -141,22 +142,22 @@ Reader.prototype.readSequence = function(tag) { |
141 | }; | 142 | }; |
142 | 143 | ||
143 | 144 | ||
144 | -Reader.prototype.readInt = function() { | 145 | +Reader.prototype.readInt = function () { |
145 | return this._readTag(ASN1.Integer); | 146 | return this._readTag(ASN1.Integer); |
146 | }; | 147 | }; |
147 | 148 | ||
148 | 149 | ||
149 | -Reader.prototype.readBoolean = function() { | 150 | +Reader.prototype.readBoolean = function () { |
150 | return (this._readTag(ASN1.Boolean) === 0 ? false : true); | 151 | return (this._readTag(ASN1.Boolean) === 0 ? false : true); |
151 | }; | 152 | }; |
152 | 153 | ||
153 | 154 | ||
154 | -Reader.prototype.readEnumeration = function() { | 155 | +Reader.prototype.readEnumeration = function () { |
155 | return this._readTag(ASN1.Enumeration); | 156 | return this._readTag(ASN1.Enumeration); |
156 | }; | 157 | }; |
157 | 158 | ||
158 | 159 | ||
159 | -Reader.prototype.readString = function(tag, retbuf) { | 160 | +Reader.prototype.readString = function (tag, retbuf) { |
160 | if (!tag) | 161 | if (!tag) |
161 | tag = ASN1.OctetString; | 162 | tag = ASN1.OctetString; |
162 | 163 | ||
... | @@ -179,7 +180,7 @@ Reader.prototype.readString = function(tag, retbuf) { | ... | @@ -179,7 +180,7 @@ Reader.prototype.readString = function(tag, retbuf) { |
179 | this._offset = o; | 180 | this._offset = o; |
180 | 181 | ||
181 | if (this.length === 0) | 182 | if (this.length === 0) |
182 | - return retbuf ? new Buffer(0) : ''; | 183 | + return retbuf ? Buffer.alloc(0) : ''; |
183 | 184 | ||
184 | var str = this._buf.slice(this._offset, this._offset + this.length); | 185 | var str = this._buf.slice(this._offset, this._offset + this.length); |
185 | this._offset += this.length; | 186 | this._offset += this.length; |
... | @@ -187,7 +188,7 @@ Reader.prototype.readString = function(tag, retbuf) { | ... | @@ -187,7 +188,7 @@ Reader.prototype.readString = function(tag, retbuf) { |
187 | return retbuf ? str : str.toString('utf8'); | 188 | return retbuf ? str : str.toString('utf8'); |
188 | }; | 189 | }; |
189 | 190 | ||
190 | -Reader.prototype.readOID = function(tag) { | 191 | +Reader.prototype.readOID = function (tag) { |
191 | if (!tag) | 192 | if (!tag) |
192 | tag = ASN1.OID; | 193 | tag = ASN1.OID; |
193 | 194 | ||
... | @@ -203,7 +204,7 @@ Reader.prototype.readOID = function(tag) { | ... | @@ -203,7 +204,7 @@ Reader.prototype.readOID = function(tag) { |
203 | 204 | ||
204 | value <<= 7; | 205 | value <<= 7; |
205 | value += byte & 0x7f; | 206 | value += byte & 0x7f; |
206 | - if ((byte & 0x80) == 0) { | 207 | + if ((byte & 0x80) === 0) { |
207 | values.push(value); | 208 | values.push(value); |
208 | value = 0; | 209 | value = 0; |
209 | } | 210 | } |
... | @@ -217,7 +218,7 @@ Reader.prototype.readOID = function(tag) { | ... | @@ -217,7 +218,7 @@ Reader.prototype.readOID = function(tag) { |
217 | }; | 218 | }; |
218 | 219 | ||
219 | 220 | ||
220 | -Reader.prototype._readTag = function(tag) { | 221 | +Reader.prototype._readTag = function (tag) { |
221 | assert.ok(tag !== undefined); | 222 | assert.ok(tag !== undefined); |
222 | 223 | ||
223 | var b = this.peek(); | 224 | var b = this.peek(); |
... | @@ -248,7 +249,7 @@ Reader.prototype._readTag = function(tag) { | ... | @@ -248,7 +249,7 @@ Reader.prototype._readTag = function(tag) { |
248 | value |= (this._buf[this._offset++] & 0xff); | 249 | value |= (this._buf[this._offset++] & 0xff); |
249 | } | 250 | } |
250 | 251 | ||
251 | - if ((fb & 0x80) == 0x80 && i !== 4) | 252 | + if ((fb & 0x80) === 0x80 && i !== 4) |
252 | value -= (1 << (i * 8)); | 253 | value -= (1 << (i * 8)); |
253 | 254 | ||
254 | return value >> 0; | 255 | return value >> 0; |
... | @@ -256,6 +257,6 @@ Reader.prototype._readTag = function(tag) { | ... | @@ -256,6 +257,6 @@ Reader.prototype._readTag = function(tag) { |
256 | 257 | ||
257 | 258 | ||
258 | 259 | ||
259 | -///--- Exported API | 260 | +// --- Exported API |
260 | 261 | ||
261 | module.exports = Reader; | 262 | module.exports = Reader; | ... | ... |
1 | // Copyright 2011 Mark Cavage <mcavage@gmail.com> All rights reserved. | 1 | // Copyright 2011 Mark Cavage <mcavage@gmail.com> All rights reserved. |
2 | 2 | ||
3 | var assert = require('assert'); | 3 | var assert = require('assert'); |
4 | +var Buffer = require('safer-buffer').Buffer; | ||
4 | var ASN1 = require('./types'); | 5 | var ASN1 = require('./types'); |
5 | var errors = require('./errors'); | 6 | var errors = require('./errors'); |
6 | 7 | ||
7 | 8 | ||
8 | -///--- Globals | 9 | +// --- Globals |
9 | 10 | ||
10 | var newInvalidAsn1Error = errors.newInvalidAsn1Error; | 11 | var newInvalidAsn1Error = errors.newInvalidAsn1Error; |
11 | 12 | ||
... | @@ -15,16 +16,16 @@ var DEFAULT_OPTS = { | ... | @@ -15,16 +16,16 @@ var DEFAULT_OPTS = { |
15 | }; | 16 | }; |
16 | 17 | ||
17 | 18 | ||
18 | -///--- Helpers | 19 | +// --- Helpers |
19 | 20 | ||
20 | function merge(from, to) { | 21 | function merge(from, to) { |
21 | assert.ok(from); | 22 | assert.ok(from); |
22 | - assert.equal(typeof(from), 'object'); | 23 | + assert.equal(typeof (from), 'object'); |
23 | assert.ok(to); | 24 | assert.ok(to); |
24 | - assert.equal(typeof(to), 'object'); | 25 | + assert.equal(typeof (to), 'object'); |
25 | 26 | ||
26 | var keys = Object.getOwnPropertyNames(from); | 27 | var keys = Object.getOwnPropertyNames(from); |
27 | - keys.forEach(function(key) { | 28 | + keys.forEach(function (key) { |
28 | if (to[key]) | 29 | if (to[key]) |
29 | return; | 30 | return; |
30 | 31 | ||
... | @@ -37,12 +38,12 @@ function merge(from, to) { | ... | @@ -37,12 +38,12 @@ function merge(from, to) { |
37 | 38 | ||
38 | 39 | ||
39 | 40 | ||
40 | -///--- API | 41 | +// --- API |
41 | 42 | ||
42 | function Writer(options) { | 43 | function Writer(options) { |
43 | options = merge(DEFAULT_OPTS, options || {}); | 44 | options = merge(DEFAULT_OPTS, options || {}); |
44 | 45 | ||
45 | - this._buf = new Buffer(options.size || 1024); | 46 | + this._buf = Buffer.alloc(options.size || 1024); |
46 | this._size = this._buf.length; | 47 | this._size = this._buf.length; |
47 | this._offset = 0; | 48 | this._offset = 0; |
48 | this._options = options; | 49 | this._options = options; |
... | @@ -55,14 +56,14 @@ function Writer(options) { | ... | @@ -55,14 +56,14 @@ function Writer(options) { |
55 | Object.defineProperty(Writer.prototype, 'buffer', { | 56 | Object.defineProperty(Writer.prototype, 'buffer', { |
56 | get: function () { | 57 | get: function () { |
57 | if (this._seq.length) | 58 | if (this._seq.length) |
58 | - throw new InvalidAsn1Error(this._seq.length + ' unended sequence(s)'); | 59 | + throw newInvalidAsn1Error(this._seq.length + ' unended sequence(s)'); |
59 | 60 | ||
60 | return (this._buf.slice(0, this._offset)); | 61 | return (this._buf.slice(0, this._offset)); |
61 | } | 62 | } |
62 | }); | 63 | }); |
63 | 64 | ||
64 | -Writer.prototype.writeByte = function(b) { | 65 | +Writer.prototype.writeByte = function (b) { |
65 | - if (typeof(b) !== 'number') | 66 | + if (typeof (b) !== 'number') |
66 | throw new TypeError('argument must be a Number'); | 67 | throw new TypeError('argument must be a Number'); |
67 | 68 | ||
68 | this._ensure(1); | 69 | this._ensure(1); |
... | @@ -70,10 +71,10 @@ Writer.prototype.writeByte = function(b) { | ... | @@ -70,10 +71,10 @@ Writer.prototype.writeByte = function(b) { |
70 | }; | 71 | }; |
71 | 72 | ||
72 | 73 | ||
73 | -Writer.prototype.writeInt = function(i, tag) { | 74 | +Writer.prototype.writeInt = function (i, tag) { |
74 | - if (typeof(i) !== 'number') | 75 | + if (typeof (i) !== 'number') |
75 | throw new TypeError('argument must be a Number'); | 76 | throw new TypeError('argument must be a Number'); |
76 | - if (typeof(tag) !== 'number') | 77 | + if (typeof (tag) !== 'number') |
77 | tag = ASN1.Integer; | 78 | tag = ASN1.Integer; |
78 | 79 | ||
79 | var sz = 4; | 80 | var sz = 4; |
... | @@ -85,7 +86,7 @@ Writer.prototype.writeInt = function(i, tag) { | ... | @@ -85,7 +86,7 @@ Writer.prototype.writeInt = function(i, tag) { |
85 | } | 86 | } |
86 | 87 | ||
87 | if (sz > 4) | 88 | if (sz > 4) |
88 | - throw new InvalidAsn1Error('BER ints cannot be > 0xffffffff'); | 89 | + throw newInvalidAsn1Error('BER ints cannot be > 0xffffffff'); |
89 | 90 | ||
90 | this._ensure(2 + sz); | 91 | this._ensure(2 + sz); |
91 | this._buf[this._offset++] = tag; | 92 | this._buf[this._offset++] = tag; |
... | @@ -99,26 +100,26 @@ Writer.prototype.writeInt = function(i, tag) { | ... | @@ -99,26 +100,26 @@ Writer.prototype.writeInt = function(i, tag) { |
99 | }; | 100 | }; |
100 | 101 | ||
101 | 102 | ||
102 | -Writer.prototype.writeNull = function() { | 103 | +Writer.prototype.writeNull = function () { |
103 | this.writeByte(ASN1.Null); | 104 | this.writeByte(ASN1.Null); |
104 | this.writeByte(0x00); | 105 | this.writeByte(0x00); |
105 | }; | 106 | }; |
106 | 107 | ||
107 | 108 | ||
108 | -Writer.prototype.writeEnumeration = function(i, tag) { | 109 | +Writer.prototype.writeEnumeration = function (i, tag) { |
109 | - if (typeof(i) !== 'number') | 110 | + if (typeof (i) !== 'number') |
110 | throw new TypeError('argument must be a Number'); | 111 | throw new TypeError('argument must be a Number'); |
111 | - if (typeof(tag) !== 'number') | 112 | + if (typeof (tag) !== 'number') |
112 | tag = ASN1.Enumeration; | 113 | tag = ASN1.Enumeration; |
113 | 114 | ||
114 | return this.writeInt(i, tag); | 115 | return this.writeInt(i, tag); |
115 | }; | 116 | }; |
116 | 117 | ||
117 | 118 | ||
118 | -Writer.prototype.writeBoolean = function(b, tag) { | 119 | +Writer.prototype.writeBoolean = function (b, tag) { |
119 | - if (typeof(b) !== 'boolean') | 120 | + if (typeof (b) !== 'boolean') |
120 | throw new TypeError('argument must be a Boolean'); | 121 | throw new TypeError('argument must be a Boolean'); |
121 | - if (typeof(tag) !== 'number') | 122 | + if (typeof (tag) !== 'number') |
122 | tag = ASN1.Boolean; | 123 | tag = ASN1.Boolean; |
123 | 124 | ||
124 | this._ensure(3); | 125 | this._ensure(3); |
... | @@ -128,10 +129,10 @@ Writer.prototype.writeBoolean = function(b, tag) { | ... | @@ -128,10 +129,10 @@ Writer.prototype.writeBoolean = function(b, tag) { |
128 | }; | 129 | }; |
129 | 130 | ||
130 | 131 | ||
131 | -Writer.prototype.writeString = function(s, tag) { | 132 | +Writer.prototype.writeString = function (s, tag) { |
132 | - if (typeof(s) !== 'string') | 133 | + if (typeof (s) !== 'string') |
133 | - throw new TypeError('argument must be a string (was: ' + typeof(s) + ')'); | 134 | + throw new TypeError('argument must be a string (was: ' + typeof (s) + ')'); |
134 | - if (typeof(tag) !== 'number') | 135 | + if (typeof (tag) !== 'number') |
135 | tag = ASN1.OctetString; | 136 | tag = ASN1.OctetString; |
136 | 137 | ||
137 | var len = Buffer.byteLength(s); | 138 | var len = Buffer.byteLength(s); |
... | @@ -145,8 +146,8 @@ Writer.prototype.writeString = function(s, tag) { | ... | @@ -145,8 +146,8 @@ Writer.prototype.writeString = function(s, tag) { |
145 | }; | 146 | }; |
146 | 147 | ||
147 | 148 | ||
148 | -Writer.prototype.writeBuffer = function(buf, tag) { | 149 | +Writer.prototype.writeBuffer = function (buf, tag) { |
149 | - if (typeof(tag) !== 'number') | 150 | + if (typeof (tag) !== 'number') |
150 | throw new TypeError('tag must be a number'); | 151 | throw new TypeError('tag must be a number'); |
151 | if (!Buffer.isBuffer(buf)) | 152 | if (!Buffer.isBuffer(buf)) |
152 | throw new TypeError('argument must be a buffer'); | 153 | throw new TypeError('argument must be a buffer'); |
... | @@ -159,21 +160,21 @@ Writer.prototype.writeBuffer = function(buf, tag) { | ... | @@ -159,21 +160,21 @@ Writer.prototype.writeBuffer = function(buf, tag) { |
159 | }; | 160 | }; |
160 | 161 | ||
161 | 162 | ||
162 | -Writer.prototype.writeStringArray = function(strings) { | 163 | +Writer.prototype.writeStringArray = function (strings) { |
163 | if ((!strings instanceof Array)) | 164 | if ((!strings instanceof Array)) |
164 | throw new TypeError('argument must be an Array[String]'); | 165 | throw new TypeError('argument must be an Array[String]'); |
165 | 166 | ||
166 | var self = this; | 167 | var self = this; |
167 | - strings.forEach(function(s) { | 168 | + strings.forEach(function (s) { |
168 | self.writeString(s); | 169 | self.writeString(s); |
169 | }); | 170 | }); |
170 | }; | 171 | }; |
171 | 172 | ||
172 | // This is really to solve DER cases, but whatever for now | 173 | // This is really to solve DER cases, but whatever for now |
173 | -Writer.prototype.writeOID = function(s, tag) { | 174 | +Writer.prototype.writeOID = function (s, tag) { |
174 | - if (typeof(s) !== 'string') | 175 | + if (typeof (s) !== 'string') |
175 | throw new TypeError('argument must be a string'); | 176 | throw new TypeError('argument must be a string'); |
176 | - if (typeof(tag) !== 'number') | 177 | + if (typeof (tag) !== 'number') |
177 | tag = ASN1.OID; | 178 | tag = ASN1.OID; |
178 | 179 | ||
179 | if (!/^([0-9]+\.){3,}[0-9]+$/.test(s)) | 180 | if (!/^([0-9]+\.){3,}[0-9]+$/.test(s)) |
... | @@ -206,7 +207,7 @@ Writer.prototype.writeOID = function(s, tag) { | ... | @@ -206,7 +207,7 @@ Writer.prototype.writeOID = function(s, tag) { |
206 | var tmp = s.split('.'); | 207 | var tmp = s.split('.'); |
207 | var bytes = []; | 208 | var bytes = []; |
208 | bytes.push(parseInt(tmp[0], 10) * 40 + parseInt(tmp[1], 10)); | 209 | bytes.push(parseInt(tmp[0], 10) * 40 + parseInt(tmp[1], 10)); |
209 | - tmp.slice(2).forEach(function(b) { | 210 | + tmp.slice(2).forEach(function (b) { |
210 | encodeOctet(bytes, parseInt(b, 10)); | 211 | encodeOctet(bytes, parseInt(b, 10)); |
211 | }); | 212 | }); |
212 | 213 | ||
... | @@ -214,14 +215,14 @@ Writer.prototype.writeOID = function(s, tag) { | ... | @@ -214,14 +215,14 @@ Writer.prototype.writeOID = function(s, tag) { |
214 | this._ensure(2 + bytes.length); | 215 | this._ensure(2 + bytes.length); |
215 | this.writeByte(tag); | 216 | this.writeByte(tag); |
216 | this.writeLength(bytes.length); | 217 | this.writeLength(bytes.length); |
217 | - bytes.forEach(function(b) { | 218 | + bytes.forEach(function (b) { |
218 | self.writeByte(b); | 219 | self.writeByte(b); |
219 | }); | 220 | }); |
220 | }; | 221 | }; |
221 | 222 | ||
222 | 223 | ||
223 | -Writer.prototype.writeLength = function(len) { | 224 | +Writer.prototype.writeLength = function (len) { |
224 | - if (typeof(len) !== 'number') | 225 | + if (typeof (len) !== 'number') |
225 | throw new TypeError('argument must be a Number'); | 226 | throw new TypeError('argument must be a Number'); |
226 | 227 | ||
227 | this._ensure(4); | 228 | this._ensure(4); |
... | @@ -241,12 +242,12 @@ Writer.prototype.writeLength = function(len) { | ... | @@ -241,12 +242,12 @@ Writer.prototype.writeLength = function(len) { |
241 | this._buf[this._offset++] = len >> 8; | 242 | this._buf[this._offset++] = len >> 8; |
242 | this._buf[this._offset++] = len; | 243 | this._buf[this._offset++] = len; |
243 | } else { | 244 | } else { |
244 | - throw new InvalidAsn1ERror('Length too long (> 4 bytes)'); | 245 | + throw newInvalidAsn1Error('Length too long (> 4 bytes)'); |
245 | } | 246 | } |
246 | }; | 247 | }; |
247 | 248 | ||
248 | -Writer.prototype.startSequence = function(tag) { | 249 | +Writer.prototype.startSequence = function (tag) { |
249 | - if (typeof(tag) !== 'number') | 250 | + if (typeof (tag) !== 'number') |
250 | tag = ASN1.Sequence | ASN1.Constructor; | 251 | tag = ASN1.Sequence | ASN1.Constructor; |
251 | 252 | ||
252 | this.writeByte(tag); | 253 | this.writeByte(tag); |
... | @@ -256,7 +257,7 @@ Writer.prototype.startSequence = function(tag) { | ... | @@ -256,7 +257,7 @@ Writer.prototype.startSequence = function(tag) { |
256 | }; | 257 | }; |
257 | 258 | ||
258 | 259 | ||
259 | -Writer.prototype.endSequence = function() { | 260 | +Writer.prototype.endSequence = function () { |
260 | var seq = this._seq.pop(); | 261 | var seq = this._seq.pop(); |
261 | var start = seq + 3; | 262 | var start = seq + 3; |
262 | var len = this._offset - start; | 263 | var len = this._offset - start; |
... | @@ -279,12 +280,12 @@ Writer.prototype.endSequence = function() { | ... | @@ -279,12 +280,12 @@ Writer.prototype.endSequence = function() { |
279 | this._buf[seq + 2] = len >> 8; | 280 | this._buf[seq + 2] = len >> 8; |
280 | this._buf[seq + 3] = len; | 281 | this._buf[seq + 3] = len; |
281 | } else { | 282 | } else { |
282 | - throw new InvalidAsn1Error('Sequence too long'); | 283 | + throw newInvalidAsn1Error('Sequence too long'); |
283 | } | 284 | } |
284 | }; | 285 | }; |
285 | 286 | ||
286 | 287 | ||
287 | -Writer.prototype._shift = function(start, len, shift) { | 288 | +Writer.prototype._shift = function (start, len, shift) { |
288 | assert.ok(start !== undefined); | 289 | assert.ok(start !== undefined); |
289 | assert.ok(len !== undefined); | 290 | assert.ok(len !== undefined); |
290 | assert.ok(shift); | 291 | assert.ok(shift); |
... | @@ -293,7 +294,7 @@ Writer.prototype._shift = function(start, len, shift) { | ... | @@ -293,7 +294,7 @@ Writer.prototype._shift = function(start, len, shift) { |
293 | this._offset += shift; | 294 | this._offset += shift; |
294 | }; | 295 | }; |
295 | 296 | ||
296 | -Writer.prototype._ensure = function(len) { | 297 | +Writer.prototype._ensure = function (len) { |
297 | assert.ok(len); | 298 | assert.ok(len); |
298 | 299 | ||
299 | if (this._size - this._offset < len) { | 300 | if (this._size - this._offset < len) { |
... | @@ -301,7 +302,7 @@ Writer.prototype._ensure = function(len) { | ... | @@ -301,7 +302,7 @@ Writer.prototype._ensure = function(len) { |
301 | if (sz - this._offset < len) | 302 | if (sz - this._offset < len) |
302 | sz += len; | 303 | sz += len; |
303 | 304 | ||
304 | - var buf = new Buffer(sz); | 305 | + var buf = Buffer.alloc(sz); |
305 | 306 | ||
306 | this._buf.copy(buf, 0, 0, this._offset); | 307 | this._buf.copy(buf, 0, 0, this._offset); |
307 | this._buf = buf; | 308 | this._buf = buf; |
... | @@ -311,6 +312,6 @@ Writer.prototype._ensure = function(len) { | ... | @@ -311,6 +312,6 @@ Writer.prototype._ensure = function(len) { |
311 | 312 | ||
312 | 313 | ||
313 | 314 | ||
314 | -///--- Exported API | 315 | +// --- Exported API |
315 | 316 | ||
316 | module.exports = Writer; | 317 | module.exports = Writer; | ... | ... |
1 | { | 1 | { |
2 | "_from": "asn1@~0.2.3", | 2 | "_from": "asn1@~0.2.3", |
3 | - "_id": "asn1@0.2.3", | 3 | + "_id": "asn1@0.2.4", |
4 | "_inBundle": false, | 4 | "_inBundle": false, |
5 | - "_integrity": "sha1-2sh4dxPJlmhJ/IGAd36+nB3fO4Y=", | 5 | + "_integrity": "sha512-jxwzQpLQjSmWXgwaCZE9Nz+glAG01yF1QnWgbhGwHI5A6FRIEY6IVqtHhIepHqI7/kyEyQEagBC5mBEFlIYvdg==", |
6 | "_location": "/asn1", | 6 | "_location": "/asn1", |
7 | "_phantomChildren": {}, | 7 | "_phantomChildren": {}, |
8 | "_requested": { | 8 | "_requested": { |
... | @@ -18,20 +18,24 @@ | ... | @@ -18,20 +18,24 @@ |
18 | "_requiredBy": [ | 18 | "_requiredBy": [ |
19 | "/sshpk" | 19 | "/sshpk" |
20 | ], | 20 | ], |
21 | - "_resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.3.tgz", | 21 | + "_resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz", |
22 | - "_shasum": "dac8787713c9966849fc8180777ebe9c1ddf3b86", | 22 | + "_shasum": "8d2475dfab553bb33e77b54e59e880bb8ce23136", |
23 | "_spec": "asn1@~0.2.3", | 23 | "_spec": "asn1@~0.2.3", |
24 | - "_where": "/home/ubuntu/Opensource/node_modules/sshpk", | 24 | + "_where": "/home/jin/opensource/kakaoBot/node_modules/sshpk", |
25 | "author": { | 25 | "author": { |
26 | - "name": "Mark Cavage", | 26 | + "name": "Joyent", |
27 | - "email": "mcavage@gmail.com" | 27 | + "url": "joyent.com" |
28 | }, | 28 | }, |
29 | "bugs": { | 29 | "bugs": { |
30 | - "url": "https://github.com/mcavage/node-asn1/issues" | 30 | + "url": "https://github.com/joyent/node-asn1/issues" |
31 | }, | 31 | }, |
32 | "bundleDependencies": false, | 32 | "bundleDependencies": false, |
33 | "contributors": [ | 33 | "contributors": [ |
34 | { | 34 | { |
35 | + "name": "Mark Cavage", | ||
36 | + "email": "mcavage@gmail.com" | ||
37 | + }, | ||
38 | + { | ||
35 | "name": "David Gwynne", | 39 | "name": "David Gwynne", |
36 | "email": "loki@animata.net" | 40 | "email": "loki@animata.net" |
37 | }, | 41 | }, |
... | @@ -44,22 +48,28 @@ | ... | @@ -44,22 +48,28 @@ |
44 | "email": "alex.wilson@joyent.com" | 48 | "email": "alex.wilson@joyent.com" |
45 | } | 49 | } |
46 | ], | 50 | ], |
47 | - "dependencies": {}, | 51 | + "dependencies": { |
52 | + "safer-buffer": "~2.1.0" | ||
53 | + }, | ||
48 | "deprecated": false, | 54 | "deprecated": false, |
49 | "description": "Contains parsers and serializers for ASN.1 (currently BER only)", | 55 | "description": "Contains parsers and serializers for ASN.1 (currently BER only)", |
50 | "devDependencies": { | 56 | "devDependencies": { |
51 | - "tap": "0.4.8" | 57 | + "eslint": "2.13.1", |
58 | + "eslint-plugin-joyent": "~1.3.0", | ||
59 | + "faucet": "0.0.1", | ||
60 | + "istanbul": "^0.3.6", | ||
61 | + "tape": "^3.5.0" | ||
52 | }, | 62 | }, |
53 | - "homepage": "https://github.com/mcavage/node-asn1#readme", | 63 | + "homepage": "https://github.com/joyent/node-asn1#readme", |
54 | "license": "MIT", | 64 | "license": "MIT", |
55 | "main": "lib/index.js", | 65 | "main": "lib/index.js", |
56 | "name": "asn1", | 66 | "name": "asn1", |
57 | "repository": { | 67 | "repository": { |
58 | "type": "git", | 68 | "type": "git", |
59 | - "url": "git://github.com/mcavage/node-asn1.git" | 69 | + "url": "git://github.com/joyent/node-asn1.git" |
60 | }, | 70 | }, |
61 | "scripts": { | 71 | "scripts": { |
62 | - "test": "tap ./tst" | 72 | + "test": "tape ./test/ber/*.test.js" |
63 | }, | 73 | }, |
64 | - "version": "0.2.3" | 74 | + "version": "0.2.4" |
65 | } | 75 | } | ... | ... |
1 | -// Copyright 2011 Mark Cavage <mcavage@gmail.com> All rights reserved. | ||
2 | - | ||
3 | -var test = require('tap').test; | ||
4 | - | ||
5 | - | ||
6 | - | ||
7 | -///--- Globals | ||
8 | - | ||
9 | -var BerReader; | ||
10 | - | ||
11 | - | ||
12 | - | ||
13 | -///--- Tests | ||
14 | - | ||
15 | -test('load library', function(t) { | ||
16 | - BerReader = require('../../lib/index').BerReader; | ||
17 | - t.ok(BerReader); | ||
18 | - try { | ||
19 | - new BerReader(); | ||
20 | - t.fail('Should have thrown'); | ||
21 | - } catch (e) { | ||
22 | - t.ok(e instanceof TypeError, 'Should have been a type error'); | ||
23 | - } | ||
24 | - t.end(); | ||
25 | -}); | ||
26 | - | ||
27 | - | ||
28 | -test('read byte', function(t) { | ||
29 | - var reader = new BerReader(new Buffer([0xde])); | ||
30 | - t.ok(reader); | ||
31 | - t.equal(reader.readByte(), 0xde, 'wrong value'); | ||
32 | - t.end(); | ||
33 | -}); | ||
34 | - | ||
35 | - | ||
36 | -test('read 1 byte int', function(t) { | ||
37 | - var reader = new BerReader(new Buffer([0x02, 0x01, 0x03])); | ||
38 | - t.ok(reader); | ||
39 | - t.equal(reader.readInt(), 0x03, 'wrong value'); | ||
40 | - t.equal(reader.length, 0x01, 'wrong length'); | ||
41 | - t.end(); | ||
42 | -}); | ||
43 | - | ||
44 | - | ||
45 | -test('read 2 byte int', function(t) { | ||
46 | - var reader = new BerReader(new Buffer([0x02, 0x02, 0x7e, 0xde])); | ||
47 | - t.ok(reader); | ||
48 | - t.equal(reader.readInt(), 0x7ede, 'wrong value'); | ||
49 | - t.equal(reader.length, 0x02, 'wrong length'); | ||
50 | - t.end(); | ||
51 | -}); | ||
52 | - | ||
53 | - | ||
54 | -test('read 3 byte int', function(t) { | ||
55 | - var reader = new BerReader(new Buffer([0x02, 0x03, 0x7e, 0xde, 0x03])); | ||
56 | - t.ok(reader); | ||
57 | - t.equal(reader.readInt(), 0x7ede03, 'wrong value'); | ||
58 | - t.equal(reader.length, 0x03, 'wrong length'); | ||
59 | - t.end(); | ||
60 | -}); | ||
61 | - | ||
62 | - | ||
63 | -test('read 4 byte int', function(t) { | ||
64 | - var reader = new BerReader(new Buffer([0x02, 0x04, 0x7e, 0xde, 0x03, 0x01])); | ||
65 | - t.ok(reader); | ||
66 | - t.equal(reader.readInt(), 0x7ede0301, 'wrong value'); | ||
67 | - t.equal(reader.length, 0x04, 'wrong length'); | ||
68 | - t.end(); | ||
69 | -}); | ||
70 | - | ||
71 | - | ||
72 | -test('read 1 byte negative int', function(t) { | ||
73 | - var reader = new BerReader(new Buffer([0x02, 0x01, 0xdc])); | ||
74 | - t.ok(reader); | ||
75 | - t.equal(reader.readInt(), -36, 'wrong value'); | ||
76 | - t.equal(reader.length, 0x01, 'wrong length'); | ||
77 | - t.end(); | ||
78 | -}); | ||
79 | - | ||
80 | - | ||
81 | -test('read 2 byte negative int', function(t) { | ||
82 | - var reader = new BerReader(new Buffer([0x02, 0x02, 0xc0, 0x4e])); | ||
83 | - t.ok(reader); | ||
84 | - t.equal(reader.readInt(), -16306, 'wrong value'); | ||
85 | - t.equal(reader.length, 0x02, 'wrong length'); | ||
86 | - t.end(); | ||
87 | -}); | ||
88 | - | ||
89 | - | ||
90 | -test('read 3 byte negative int', function(t) { | ||
91 | - var reader = new BerReader(new Buffer([0x02, 0x03, 0xff, 0x00, 0x19])); | ||
92 | - t.ok(reader); | ||
93 | - t.equal(reader.readInt(), -65511, 'wrong value'); | ||
94 | - t.equal(reader.length, 0x03, 'wrong length'); | ||
95 | - t.end(); | ||
96 | -}); | ||
97 | - | ||
98 | - | ||
99 | -test('read 4 byte negative int', function(t) { | ||
100 | - var reader = new BerReader(new Buffer([0x02, 0x04, 0x91, 0x7c, 0x22, 0x1f])); | ||
101 | - t.ok(reader); | ||
102 | - t.equal(reader.readInt(), -1854135777, 'wrong value'); | ||
103 | - t.equal(reader.length, 0x04, 'wrong length'); | ||
104 | - t.end(); | ||
105 | -}); | ||
106 | - | ||
107 | - | ||
108 | -test('read boolean true', function(t) { | ||
109 | - var reader = new BerReader(new Buffer([0x01, 0x01, 0xff])); | ||
110 | - t.ok(reader); | ||
111 | - t.equal(reader.readBoolean(), true, 'wrong value'); | ||
112 | - t.equal(reader.length, 0x01, 'wrong length'); | ||
113 | - t.end(); | ||
114 | -}); | ||
115 | - | ||
116 | - | ||
117 | -test('read boolean false', function(t) { | ||
118 | - var reader = new BerReader(new Buffer([0x01, 0x01, 0x00])); | ||
119 | - t.ok(reader); | ||
120 | - t.equal(reader.readBoolean(), false, 'wrong value'); | ||
121 | - t.equal(reader.length, 0x01, 'wrong length'); | ||
122 | - t.end(); | ||
123 | -}); | ||
124 | - | ||
125 | - | ||
126 | -test('read enumeration', function(t) { | ||
127 | - var reader = new BerReader(new Buffer([0x0a, 0x01, 0x20])); | ||
128 | - t.ok(reader); | ||
129 | - t.equal(reader.readEnumeration(), 0x20, 'wrong value'); | ||
130 | - t.equal(reader.length, 0x01, 'wrong length'); | ||
131 | - t.end(); | ||
132 | -}); | ||
133 | - | ||
134 | - | ||
135 | -test('read string', function(t) { | ||
136 | - var dn = 'cn=foo,ou=unit,o=test'; | ||
137 | - var buf = new Buffer(dn.length + 2); | ||
138 | - buf[0] = 0x04; | ||
139 | - buf[1] = Buffer.byteLength(dn); | ||
140 | - buf.write(dn, 2); | ||
141 | - var reader = new BerReader(buf); | ||
142 | - t.ok(reader); | ||
143 | - t.equal(reader.readString(), dn, 'wrong value'); | ||
144 | - t.equal(reader.length, dn.length, 'wrong length'); | ||
145 | - t.end(); | ||
146 | -}); | ||
147 | - | ||
148 | - | ||
149 | -test('read sequence', function(t) { | ||
150 | - var reader = new BerReader(new Buffer([0x30, 0x03, 0x01, 0x01, 0xff])); | ||
151 | - t.ok(reader); | ||
152 | - t.equal(reader.readSequence(), 0x30, 'wrong value'); | ||
153 | - t.equal(reader.length, 0x03, 'wrong length'); | ||
154 | - t.equal(reader.readBoolean(), true, 'wrong value'); | ||
155 | - t.equal(reader.length, 0x01, 'wrong length'); | ||
156 | - t.end(); | ||
157 | -}); | ||
158 | - | ||
159 | - | ||
160 | -test('anonymous LDAPv3 bind', function(t) { | ||
161 | - var BIND = new Buffer(14); | ||
162 | - BIND[0] = 0x30; // Sequence | ||
163 | - BIND[1] = 12; // len | ||
164 | - BIND[2] = 0x02; // ASN.1 Integer | ||
165 | - BIND[3] = 1; // len | ||
166 | - BIND[4] = 0x04; // msgid (make up 4) | ||
167 | - BIND[5] = 0x60; // Bind Request | ||
168 | - BIND[6] = 7; // len | ||
169 | - BIND[7] = 0x02; // ASN.1 Integer | ||
170 | - BIND[8] = 1; // len | ||
171 | - BIND[9] = 0x03; // v3 | ||
172 | - BIND[10] = 0x04; // String (bind dn) | ||
173 | - BIND[11] = 0; // len | ||
174 | - BIND[12] = 0x80; // ContextSpecific (choice) | ||
175 | - BIND[13] = 0; // simple bind | ||
176 | - | ||
177 | - // Start testing ^^ | ||
178 | - var ber = new BerReader(BIND); | ||
179 | - t.equal(ber.readSequence(), 48, 'Not an ASN.1 Sequence'); | ||
180 | - t.equal(ber.length, 12, 'Message length should be 12'); | ||
181 | - t.equal(ber.readInt(), 4, 'Message id should have been 4'); | ||
182 | - t.equal(ber.readSequence(), 96, 'Bind Request should have been 96'); | ||
183 | - t.equal(ber.length, 7, 'Bind length should have been 7'); | ||
184 | - t.equal(ber.readInt(), 3, 'LDAP version should have been 3'); | ||
185 | - t.equal(ber.readString(), '', 'Bind DN should have been empty'); | ||
186 | - t.equal(ber.length, 0, 'string length should have been 0'); | ||
187 | - t.equal(ber.readByte(), 0x80, 'Should have been ContextSpecific (choice)'); | ||
188 | - t.equal(ber.readByte(), 0, 'Should have been simple bind'); | ||
189 | - t.equal(null, ber.readByte(), 'Should be out of data'); | ||
190 | - t.end(); | ||
191 | -}); | ||
192 | - | ||
193 | - | ||
194 | -test('long string', function(t) { | ||
195 | - var buf = new Buffer(256); | ||
196 | - var o; | ||
197 | - var s = | ||
198 | - '2;649;CN=Red Hat CS 71GA Demo,O=Red Hat CS 71GA Demo,C=US;' + | ||
199 | - 'CN=RHCS Agent - admin01,UID=admin01,O=redhat,C=US [1] This is ' + | ||
200 | - 'Teena Vradmin\'s description.'; | ||
201 | - buf[0] = 0x04; | ||
202 | - buf[1] = 0x81; | ||
203 | - buf[2] = 0x94; | ||
204 | - buf.write(s, 3); | ||
205 | - var ber = new BerReader(buf.slice(0, 3 + s.length)); | ||
206 | - t.equal(ber.readString(), s); | ||
207 | - t.end(); | ||
208 | -}); |
1 | -// Copyright 2011 Mark Cavage <mcavage@gmail.com> All rights reserved. | ||
2 | - | ||
3 | -var test = require('tap').test; | ||
4 | -var sys = require('sys'); | ||
5 | - | ||
6 | -///--- Globals | ||
7 | - | ||
8 | -var BerWriter; | ||
9 | - | ||
10 | -var BerReader; | ||
11 | - | ||
12 | - | ||
13 | -///--- Tests | ||
14 | - | ||
15 | -test('load library', function(t) { | ||
16 | - BerWriter = require('../../lib/index').BerWriter; | ||
17 | - t.ok(BerWriter); | ||
18 | - t.ok(new BerWriter()); | ||
19 | - t.end(); | ||
20 | -}); | ||
21 | - | ||
22 | - | ||
23 | -test('write byte', function(t) { | ||
24 | - var writer = new BerWriter(); | ||
25 | - | ||
26 | - writer.writeByte(0xC2); | ||
27 | - var ber = writer.buffer; | ||
28 | - | ||
29 | - t.ok(ber); | ||
30 | - t.equal(ber.length, 1, 'Wrong length'); | ||
31 | - t.equal(ber[0], 0xC2, 'value wrong'); | ||
32 | - | ||
33 | - t.end(); | ||
34 | -}); | ||
35 | - | ||
36 | - | ||
37 | -test('write 1 byte int', function(t) { | ||
38 | - var writer = new BerWriter(); | ||
39 | - | ||
40 | - writer.writeInt(0x7f); | ||
41 | - var ber = writer.buffer; | ||
42 | - | ||
43 | - t.ok(ber); | ||
44 | - t.equal(ber.length, 3, 'Wrong length for an int: ' + ber.length); | ||
45 | - t.equal(ber[0], 0x02, 'ASN.1 tag wrong (2) -> ' + ber[0]); | ||
46 | - t.equal(ber[1], 0x01, 'length wrong(1) -> ' + ber[1]); | ||
47 | - t.equal(ber[2], 0x7f, 'value wrong(3) -> ' + ber[2]); | ||
48 | - | ||
49 | - t.end(); | ||
50 | -}); | ||
51 | - | ||
52 | - | ||
53 | -test('write 2 byte int', function(t) { | ||
54 | - var writer = new BerWriter(); | ||
55 | - | ||
56 | - writer.writeInt(0x7ffe); | ||
57 | - var ber = writer.buffer; | ||
58 | - | ||
59 | - t.ok(ber); | ||
60 | - t.equal(ber.length, 4, 'Wrong length for an int'); | ||
61 | - t.equal(ber[0], 0x02, 'ASN.1 tag wrong'); | ||
62 | - t.equal(ber[1], 0x02, 'length wrong'); | ||
63 | - t.equal(ber[2], 0x7f, 'value wrong (byte 1)'); | ||
64 | - t.equal(ber[3], 0xfe, 'value wrong (byte 2)'); | ||
65 | - | ||
66 | - t.end(); | ||
67 | -}); | ||
68 | - | ||
69 | - | ||
70 | -test('write 3 byte int', function(t) { | ||
71 | - var writer = new BerWriter(); | ||
72 | - | ||
73 | - writer.writeInt(0x7ffffe); | ||
74 | - var ber = writer.buffer; | ||
75 | - | ||
76 | - t.ok(ber); | ||
77 | - t.equal(ber.length, 5, 'Wrong length for an int'); | ||
78 | - t.equal(ber[0], 0x02, 'ASN.1 tag wrong'); | ||
79 | - t.equal(ber[1], 0x03, 'length wrong'); | ||
80 | - t.equal(ber[2], 0x7f, 'value wrong (byte 1)'); | ||
81 | - t.equal(ber[3], 0xff, 'value wrong (byte 2)'); | ||
82 | - t.equal(ber[4], 0xfe, 'value wrong (byte 3)'); | ||
83 | - | ||
84 | - t.end(); | ||
85 | -}); | ||
86 | - | ||
87 | - | ||
88 | -test('write 4 byte int', function(t) { | ||
89 | - var writer = new BerWriter(); | ||
90 | - | ||
91 | - writer.writeInt(0x7ffffffe); | ||
92 | - var ber = writer.buffer; | ||
93 | - | ||
94 | - t.ok(ber); | ||
95 | - | ||
96 | - t.equal(ber.length, 6, 'Wrong length for an int'); | ||
97 | - t.equal(ber[0], 0x02, 'ASN.1 tag wrong'); | ||
98 | - t.equal(ber[1], 0x04, 'length wrong'); | ||
99 | - t.equal(ber[2], 0x7f, 'value wrong (byte 1)'); | ||
100 | - t.equal(ber[3], 0xff, 'value wrong (byte 2)'); | ||
101 | - t.equal(ber[4], 0xff, 'value wrong (byte 3)'); | ||
102 | - t.equal(ber[5], 0xfe, 'value wrong (byte 4)'); | ||
103 | - | ||
104 | - t.end(); | ||
105 | -}); | ||
106 | - | ||
107 | - | ||
108 | -test('write 1 byte negative int', function(t) { | ||
109 | - var writer = new BerWriter(); | ||
110 | - | ||
111 | - writer.writeInt(-128); | ||
112 | - var ber = writer.buffer; | ||
113 | - | ||
114 | - t.ok(ber); | ||
115 | - | ||
116 | - t.equal(ber.length, 3, 'Wrong length for an int'); | ||
117 | - t.equal(ber[0], 0x02, 'ASN.1 tag wrong'); | ||
118 | - t.equal(ber[1], 0x01, 'length wrong'); | ||
119 | - t.equal(ber[2], 0x80, 'value wrong (byte 1)'); | ||
120 | - | ||
121 | - t.end(); | ||
122 | -}); | ||
123 | - | ||
124 | - | ||
125 | -test('write 2 byte negative int', function(t) { | ||
126 | - var writer = new BerWriter(); | ||
127 | - | ||
128 | - writer.writeInt(-22400); | ||
129 | - var ber = writer.buffer; | ||
130 | - | ||
131 | - t.ok(ber); | ||
132 | - | ||
133 | - t.equal(ber.length, 4, 'Wrong length for an int'); | ||
134 | - t.equal(ber[0], 0x02, 'ASN.1 tag wrong'); | ||
135 | - t.equal(ber[1], 0x02, 'length wrong'); | ||
136 | - t.equal(ber[2], 0xa8, 'value wrong (byte 1)'); | ||
137 | - t.equal(ber[3], 0x80, 'value wrong (byte 2)'); | ||
138 | - | ||
139 | - t.end(); | ||
140 | -}); | ||
141 | - | ||
142 | - | ||
143 | -test('write 3 byte negative int', function(t) { | ||
144 | - var writer = new BerWriter(); | ||
145 | - | ||
146 | - writer.writeInt(-481653); | ||
147 | - var ber = writer.buffer; | ||
148 | - | ||
149 | - t.ok(ber); | ||
150 | - | ||
151 | - t.equal(ber.length, 5, 'Wrong length for an int'); | ||
152 | - t.equal(ber[0], 0x02, 'ASN.1 tag wrong'); | ||
153 | - t.equal(ber[1], 0x03, 'length wrong'); | ||
154 | - t.equal(ber[2], 0xf8, 'value wrong (byte 1)'); | ||
155 | - t.equal(ber[3], 0xa6, 'value wrong (byte 2)'); | ||
156 | - t.equal(ber[4], 0x8b, 'value wrong (byte 3)'); | ||
157 | - | ||
158 | - t.end(); | ||
159 | -}); | ||
160 | - | ||
161 | - | ||
162 | -test('write 4 byte negative int', function(t) { | ||
163 | - var writer = new BerWriter(); | ||
164 | - | ||
165 | - writer.writeInt(-1522904131); | ||
166 | - var ber = writer.buffer; | ||
167 | - | ||
168 | - t.ok(ber); | ||
169 | - | ||
170 | - t.equal(ber.length, 6, 'Wrong length for an int'); | ||
171 | - t.equal(ber[0], 0x02, 'ASN.1 tag wrong'); | ||
172 | - t.equal(ber[1], 0x04, 'length wrong'); | ||
173 | - t.equal(ber[2], 0xa5, 'value wrong (byte 1)'); | ||
174 | - t.equal(ber[3], 0x3a, 'value wrong (byte 2)'); | ||
175 | - t.equal(ber[4], 0x53, 'value wrong (byte 3)'); | ||
176 | - t.equal(ber[5], 0xbd, 'value wrong (byte 4)'); | ||
177 | - | ||
178 | - t.end(); | ||
179 | -}); | ||
180 | - | ||
181 | - | ||
182 | -test('write boolean', function(t) { | ||
183 | - var writer = new BerWriter(); | ||
184 | - | ||
185 | - writer.writeBoolean(true); | ||
186 | - writer.writeBoolean(false); | ||
187 | - var ber = writer.buffer; | ||
188 | - | ||
189 | - t.ok(ber); | ||
190 | - t.equal(ber.length, 6, 'Wrong length'); | ||
191 | - t.equal(ber[0], 0x01, 'tag wrong'); | ||
192 | - t.equal(ber[1], 0x01, 'length wrong'); | ||
193 | - t.equal(ber[2], 0xff, 'value wrong'); | ||
194 | - t.equal(ber[3], 0x01, 'tag wrong'); | ||
195 | - t.equal(ber[4], 0x01, 'length wrong'); | ||
196 | - t.equal(ber[5], 0x00, 'value wrong'); | ||
197 | - | ||
198 | - t.end(); | ||
199 | -}); | ||
200 | - | ||
201 | - | ||
202 | -test('write string', function(t) { | ||
203 | - var writer = new BerWriter(); | ||
204 | - writer.writeString('hello world'); | ||
205 | - var ber = writer.buffer; | ||
206 | - | ||
207 | - t.ok(ber); | ||
208 | - t.equal(ber.length, 13, 'wrong length'); | ||
209 | - t.equal(ber[0], 0x04, 'wrong tag'); | ||
210 | - t.equal(ber[1], 11, 'wrong length'); | ||
211 | - t.equal(ber.slice(2).toString('utf8'), 'hello world', 'wrong value'); | ||
212 | - | ||
213 | - t.end(); | ||
214 | -}); | ||
215 | - | ||
216 | -test('write buffer', function(t) { | ||
217 | - var writer = new BerWriter(); | ||
218 | - // write some stuff to start with | ||
219 | - writer.writeString('hello world'); | ||
220 | - var ber = writer.buffer; | ||
221 | - var buf = new Buffer([0x04, 0x0b, 0x30, 0x09, 0x02, 0x01, 0x0f, 0x01, 0x01, | ||
222 | - 0xff, 0x01, 0x01, 0xff]); | ||
223 | - writer.writeBuffer(buf.slice(2, buf.length), 0x04); | ||
224 | - ber = writer.buffer; | ||
225 | - | ||
226 | - t.ok(ber); | ||
227 | - t.equal(ber.length, 26, 'wrong length'); | ||
228 | - t.equal(ber[0], 0x04, 'wrong tag'); | ||
229 | - t.equal(ber[1], 11, 'wrong length'); | ||
230 | - t.equal(ber.slice(2, 13).toString('utf8'), 'hello world', 'wrong value'); | ||
231 | - t.equal(ber[13], buf[0], 'wrong tag'); | ||
232 | - t.equal(ber[14], buf[1], 'wrong length'); | ||
233 | - for (var i = 13, j = 0; i < ber.length && j < buf.length; i++, j++) { | ||
234 | - t.equal(ber[i], buf[j], 'buffer contents not identical'); | ||
235 | - } | ||
236 | - t.end(); | ||
237 | -}); | ||
238 | - | ||
239 | -test('write string array', function(t) { | ||
240 | - var writer = new BerWriter(); | ||
241 | - writer.writeStringArray(['hello world', 'fubar!']); | ||
242 | - var ber = writer.buffer; | ||
243 | - | ||
244 | - t.ok(ber); | ||
245 | - | ||
246 | - t.equal(ber.length, 21, 'wrong length'); | ||
247 | - t.equal(ber[0], 0x04, 'wrong tag'); | ||
248 | - t.equal(ber[1], 11, 'wrong length'); | ||
249 | - t.equal(ber.slice(2, 13).toString('utf8'), 'hello world', 'wrong value'); | ||
250 | - | ||
251 | - t.equal(ber[13], 0x04, 'wrong tag'); | ||
252 | - t.equal(ber[14], 6, 'wrong length'); | ||
253 | - t.equal(ber.slice(15).toString('utf8'), 'fubar!', 'wrong value'); | ||
254 | - | ||
255 | - t.end(); | ||
256 | -}); | ||
257 | - | ||
258 | - | ||
259 | -test('resize internal buffer', function(t) { | ||
260 | - var writer = new BerWriter({size: 2}); | ||
261 | - writer.writeString('hello world'); | ||
262 | - var ber = writer.buffer; | ||
263 | - | ||
264 | - t.ok(ber); | ||
265 | - t.equal(ber.length, 13, 'wrong length'); | ||
266 | - t.equal(ber[0], 0x04, 'wrong tag'); | ||
267 | - t.equal(ber[1], 11, 'wrong length'); | ||
268 | - t.equal(ber.slice(2).toString('utf8'), 'hello world', 'wrong value'); | ||
269 | - | ||
270 | - t.end(); | ||
271 | -}); | ||
272 | - | ||
273 | - | ||
274 | -test('sequence', function(t) { | ||
275 | - var writer = new BerWriter({size: 25}); | ||
276 | - writer.startSequence(); | ||
277 | - writer.writeString('hello world'); | ||
278 | - writer.endSequence(); | ||
279 | - var ber = writer.buffer; | ||
280 | - | ||
281 | - t.ok(ber); | ||
282 | - console.log(ber); | ||
283 | - t.equal(ber.length, 15, 'wrong length'); | ||
284 | - t.equal(ber[0], 0x30, 'wrong tag'); | ||
285 | - t.equal(ber[1], 13, 'wrong length'); | ||
286 | - t.equal(ber[2], 0x04, 'wrong tag'); | ||
287 | - t.equal(ber[3], 11, 'wrong length'); | ||
288 | - t.equal(ber.slice(4).toString('utf8'), 'hello world', 'wrong value'); | ||
289 | - | ||
290 | - t.end(); | ||
291 | -}); | ||
292 | - | ||
293 | - | ||
294 | -test('nested sequence', function(t) { | ||
295 | - var writer = new BerWriter({size: 25}); | ||
296 | - writer.startSequence(); | ||
297 | - writer.writeString('hello world'); | ||
298 | - writer.startSequence(); | ||
299 | - writer.writeString('hello world'); | ||
300 | - writer.endSequence(); | ||
301 | - writer.endSequence(); | ||
302 | - var ber = writer.buffer; | ||
303 | - | ||
304 | - t.ok(ber); | ||
305 | - t.equal(ber.length, 30, 'wrong length'); | ||
306 | - t.equal(ber[0], 0x30, 'wrong tag'); | ||
307 | - t.equal(ber[1], 28, 'wrong length'); | ||
308 | - t.equal(ber[2], 0x04, 'wrong tag'); | ||
309 | - t.equal(ber[3], 11, 'wrong length'); | ||
310 | - t.equal(ber.slice(4, 15).toString('utf8'), 'hello world', 'wrong value'); | ||
311 | - t.equal(ber[15], 0x30, 'wrong tag'); | ||
312 | - t.equal(ber[16], 13, 'wrong length'); | ||
313 | - t.equal(ber[17], 0x04, 'wrong tag'); | ||
314 | - t.equal(ber[18], 11, 'wrong length'); | ||
315 | - t.equal(ber.slice(19, 30).toString('utf8'), 'hello world', 'wrong value'); | ||
316 | - | ||
317 | - t.end(); | ||
318 | -}); | ||
319 | - | ||
320 | - | ||
321 | -test('LDAP bind message', function(t) { | ||
322 | - var dn = 'cn=foo,ou=unit,o=test'; | ||
323 | - var writer = new BerWriter(); | ||
324 | - writer.startSequence(); | ||
325 | - writer.writeInt(3); // msgid = 3 | ||
326 | - writer.startSequence(0x60); // ldap bind | ||
327 | - writer.writeInt(3); // ldap v3 | ||
328 | - writer.writeString(dn); | ||
329 | - writer.writeByte(0x80); | ||
330 | - writer.writeByte(0x00); | ||
331 | - writer.endSequence(); | ||
332 | - writer.endSequence(); | ||
333 | - var ber = writer.buffer; | ||
334 | - | ||
335 | - t.ok(ber); | ||
336 | - t.equal(ber.length, 35, 'wrong length (buffer)'); | ||
337 | - t.equal(ber[0], 0x30, 'wrong tag'); | ||
338 | - t.equal(ber[1], 33, 'wrong length'); | ||
339 | - t.equal(ber[2], 0x02, 'wrong tag'); | ||
340 | - t.equal(ber[3], 1, 'wrong length'); | ||
341 | - t.equal(ber[4], 0x03, 'wrong value'); | ||
342 | - t.equal(ber[5], 0x60, 'wrong tag'); | ||
343 | - t.equal(ber[6], 28, 'wrong length'); | ||
344 | - t.equal(ber[7], 0x02, 'wrong tag'); | ||
345 | - t.equal(ber[8], 1, 'wrong length'); | ||
346 | - t.equal(ber[9], 0x03, 'wrong value'); | ||
347 | - t.equal(ber[10], 0x04, 'wrong tag'); | ||
348 | - t.equal(ber[11], dn.length, 'wrong length'); | ||
349 | - t.equal(ber.slice(12, 33).toString('utf8'), dn, 'wrong value'); | ||
350 | - t.equal(ber[33], 0x80, 'wrong tag'); | ||
351 | - t.equal(ber[34], 0x00, 'wrong len'); | ||
352 | - | ||
353 | - t.end(); | ||
354 | -}); | ||
355 | - | ||
356 | - | ||
357 | -test('Write OID', function(t) { | ||
358 | - var oid = '1.2.840.113549.1.1.1'; | ||
359 | - var writer = new BerWriter(); | ||
360 | - writer.writeOID(oid); | ||
361 | - | ||
362 | - var ber = writer.buffer; | ||
363 | - t.ok(ber); | ||
364 | - console.log(require('util').inspect(ber)); | ||
365 | - console.log(require('util').inspect(new Buffer([0x06, 0x09, 0x2a, 0x86, | ||
366 | - 0x48, 0x86, 0xf7, 0x0d, | ||
367 | - 0x01, 0x01, 0x01]))); | ||
368 | - | ||
369 | - t.end(); | ||
370 | -}); |
... | @@ -26,7 +26,7 @@ | ... | @@ -26,7 +26,7 @@ |
26 | "_resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", | 26 | "_resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", |
27 | "_shasum": "f12e0f3c5d77b0b1cdd9146942e4e96c1e4dd525", | 27 | "_shasum": "f12e0f3c5d77b0b1cdd9146942e4e96c1e4dd525", |
28 | "_spec": "assert-plus@^1.0.0", | 28 | "_spec": "assert-plus@^1.0.0", |
29 | - "_where": "/home/ubuntu/Opensource/node_modules/http-signature", | 29 | + "_where": "/home/jin/opensource/kakaoBot/node_modules/http-signature", |
30 | "author": { | 30 | "author": { |
31 | "name": "Mark Cavage", | 31 | "name": "Mark Cavage", |
32 | "email": "mcavage@gmail.com" | 32 | "email": "mcavage@gmail.com" | ... | ... |
... | @@ -21,7 +21,7 @@ | ... | @@ -21,7 +21,7 @@ |
21 | "_resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", | 21 | "_resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", |
22 | "_shasum": "c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79", | 22 | "_shasum": "c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79", |
23 | "_spec": "asynckit@^0.4.0", | 23 | "_spec": "asynckit@^0.4.0", |
24 | - "_where": "/home/ubuntu/Opensource/node_modules/form-data", | 24 | + "_where": "/home/jin/opensource/kakaoBot/node_modules/form-data", |
25 | "author": { | 25 | "author": { |
26 | "name": "Alex Indigo", | 26 | "name": "Alex Indigo", |
27 | "email": "iam@alexindigo.com" | 27 | "email": "iam@alexindigo.com" | ... | ... |
... | @@ -21,7 +21,7 @@ | ... | @@ -21,7 +21,7 @@ |
21 | "_resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", | 21 | "_resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", |
22 | "_shasum": "b46e890934a9591f2d2f6f86d7e6a9f1b3fe76a8", | 22 | "_shasum": "b46e890934a9591f2d2f6f86d7e6a9f1b3fe76a8", |
23 | "_spec": "aws-sign2@~0.7.0", | 23 | "_spec": "aws-sign2@~0.7.0", |
24 | - "_where": "/home/ubuntu/Opensource/node_modules/request", | 24 | + "_where": "/home/jin/opensource/kakaoBot/node_modules/request", |
25 | "author": { | 25 | "author": { |
26 | "name": "Mikeal Rogers", | 26 | "name": "Mikeal Rogers", |
27 | "email": "mikeal.rogers@gmail.com", | 27 | "email": "mikeal.rogers@gmail.com", | ... | ... |
node_modules/aws4/.npmignore
deleted
100644 → 0
node_modules/aws4/.tern-port
deleted
100644 → 0
1 | -62638 | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
... | @@ -57,7 +57,7 @@ function RequestSigner(request, credentials) { | ... | @@ -57,7 +57,7 @@ function RequestSigner(request, credentials) { |
57 | } | 57 | } |
58 | 58 | ||
59 | RequestSigner.prototype.matchHost = function(host) { | 59 | RequestSigner.prototype.matchHost = function(host) { |
60 | - var match = (host || '').match(/([^\.]+)\.(?:([^\.]*)\.)?amazonaws\.com$/) | 60 | + var match = (host || '').match(/([^\.]+)\.(?:([^\.]*)\.)?amazonaws\.com(\.cn)?$/) |
61 | var hostParts = (match || []).slice(1, 3) | 61 | var hostParts = (match || []).slice(1, 3) |
62 | 62 | ||
63 | // ES's hostParts are sometimes the other way round, if the value that is expected | 63 | // ES's hostParts are sometimes the other way round, if the value that is expected |
... | @@ -233,8 +233,8 @@ RequestSigner.prototype.canonicalString = function() { | ... | @@ -233,8 +233,8 @@ RequestSigner.prototype.canonicalString = function() { |
233 | if (normalizePath && piece === '..') { | 233 | if (normalizePath && piece === '..') { |
234 | path.pop() | 234 | path.pop() |
235 | } else if (!normalizePath || piece !== '.') { | 235 | } else if (!normalizePath || piece !== '.') { |
236 | - if (decodePath) piece = querystring.unescape(piece) | 236 | + if (decodePath) piece = decodeURIComponent(piece) |
237 | - path.push(encodeRfc3986(querystring.escape(piece))) | 237 | + path.push(encodeRfc3986(encodeURIComponent(piece))) |
238 | } | 238 | } |
239 | return path | 239 | return path |
240 | }, []).join('/') | 240 | }, []).join('/') |
... | @@ -303,7 +303,7 @@ RequestSigner.prototype.parsePath = function() { | ... | @@ -303,7 +303,7 @@ RequestSigner.prototype.parsePath = function() { |
303 | // So if there are non-reserved chars (and it's not already all % encoded), just encode them all | 303 | // So if there are non-reserved chars (and it's not already all % encoded), just encode them all |
304 | if (/[^0-9A-Za-z!'()*\-._~%/]/.test(path)) { | 304 | if (/[^0-9A-Za-z!'()*\-._~%/]/.test(path)) { |
305 | path = path.split('/').map(function(piece) { | 305 | path = path.split('/').map(function(piece) { |
306 | - return querystring.escape(querystring.unescape(piece)) | 306 | + return encodeURIComponent(decodeURIComponent(piece)) |
307 | }).join('/') | 307 | }).join('/') |
308 | } | 308 | } |
309 | 309 | ... | ... |
1 | { | 1 | { |
2 | - "_from": "aws4@^1.6.0", | 2 | + "_from": "aws4@^1.8.0", |
3 | - "_id": "aws4@1.6.0", | 3 | + "_id": "aws4@1.8.0", |
4 | "_inBundle": false, | 4 | "_inBundle": false, |
5 | - "_integrity": "sha1-g+9cqGCysy5KDe7e6MdxudtXRx4=", | 5 | + "_integrity": "sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ==", |
6 | "_location": "/aws4", | 6 | "_location": "/aws4", |
7 | "_phantomChildren": {}, | 7 | "_phantomChildren": {}, |
8 | "_requested": { | 8 | "_requested": { |
9 | "type": "range", | 9 | "type": "range", |
10 | "registry": true, | 10 | "registry": true, |
11 | - "raw": "aws4@^1.6.0", | 11 | + "raw": "aws4@^1.8.0", |
12 | "name": "aws4", | 12 | "name": "aws4", |
13 | "escapedName": "aws4", | 13 | "escapedName": "aws4", |
14 | - "rawSpec": "^1.6.0", | 14 | + "rawSpec": "^1.8.0", |
15 | "saveSpec": null, | 15 | "saveSpec": null, |
16 | - "fetchSpec": "^1.6.0" | 16 | + "fetchSpec": "^1.8.0" |
17 | }, | 17 | }, |
18 | "_requiredBy": [ | 18 | "_requiredBy": [ |
19 | "/request" | 19 | "/request" |
20 | ], | 20 | ], |
21 | - "_resolved": "https://registry.npmjs.org/aws4/-/aws4-1.6.0.tgz", | 21 | + "_resolved": "https://registry.npmjs.org/aws4/-/aws4-1.8.0.tgz", |
22 | - "_shasum": "83ef5ca860b2b32e4a0deedee8c771b9db57471e", | 22 | + "_shasum": "f0e003d9ca9e7f59c7a508945d7b2ef9a04a542f", |
23 | - "_spec": "aws4@^1.6.0", | 23 | + "_spec": "aws4@^1.8.0", |
24 | - "_where": "/home/ubuntu/Opensource/node_modules/request", | 24 | + "_where": "/home/jin/opensource/kakaoBot/node_modules/request", |
25 | "author": { | 25 | "author": { |
26 | "name": "Michael Hart", | 26 | "name": "Michael Hart", |
27 | "email": "michael.hart.au@gmail.com", | 27 | "email": "michael.hart.au@gmail.com", |
... | @@ -100,5 +100,5 @@ | ... | @@ -100,5 +100,5 @@ |
100 | "scripts": { | 100 | "scripts": { |
101 | "test": "mocha ./test/fast.js ./test/slow.js -b -t 100s -R list" | 101 | "test": "mocha ./test/fast.js ./test/slow.js -b -t 100s -R list" |
102 | }, | 102 | }, |
103 | - "version": "1.6.0" | 103 | + "version": "1.8.0" |
104 | } | 104 | } | ... | ... |
1 | { | 1 | { |
2 | - "_from": "basic-auth@~2.0.0", | 2 | + "_args": [ |
3 | + [ | ||
4 | + "basic-auth@~2.0.0", | ||
5 | + "/home/jin/opensource/kakaoBot/node_modules/morgan" | ||
6 | + ] | ||
7 | + ], | ||
8 | + "_from": "basic-auth@>=2.0.0 <2.1.0", | ||
3 | "_id": "basic-auth@2.0.0", | 9 | "_id": "basic-auth@2.0.0", |
4 | - "_inBundle": false, | 10 | + "_inCache": true, |
5 | - "_integrity": "sha1-AV2z81PgLlY3d1X5YnQuiYHnu7o=", | 11 | + "_installable": true, |
6 | "_location": "/basic-auth", | 12 | "_location": "/basic-auth", |
13 | + "_nodeVersion": "6.11.1", | ||
14 | + "_npmOperationalInternal": { | ||
15 | + "host": "s3://npm-registry-packages", | ||
16 | + "tmp": "tmp/basic-auth-2.0.0.tgz_1505275895449_0.5881294559221715" | ||
17 | + }, | ||
18 | + "_npmUser": { | ||
19 | + "email": "doug@somethingdoug.com", | ||
20 | + "name": "dougwilson" | ||
21 | + }, | ||
22 | + "_npmVersion": "3.10.10", | ||
7 | "_phantomChildren": {}, | 23 | "_phantomChildren": {}, |
8 | "_requested": { | 24 | "_requested": { |
9 | - "type": "range", | ||
10 | - "registry": true, | ||
11 | - "raw": "basic-auth@~2.0.0", | ||
12 | "name": "basic-auth", | 25 | "name": "basic-auth", |
13 | - "escapedName": "basic-auth", | 26 | + "raw": "basic-auth@~2.0.0", |
14 | "rawSpec": "~2.0.0", | 27 | "rawSpec": "~2.0.0", |
15 | - "saveSpec": null, | 28 | + "scope": null, |
16 | - "fetchSpec": "~2.0.0" | 29 | + "spec": ">=2.0.0 <2.1.0", |
30 | + "type": "range" | ||
17 | }, | 31 | }, |
18 | "_requiredBy": [ | 32 | "_requiredBy": [ |
19 | "/morgan" | 33 | "/morgan" |
20 | ], | 34 | ], |
21 | "_resolved": "https://registry.npmjs.org/basic-auth/-/basic-auth-2.0.0.tgz", | 35 | "_resolved": "https://registry.npmjs.org/basic-auth/-/basic-auth-2.0.0.tgz", |
22 | "_shasum": "015db3f353e02e56377755f962742e8981e7bbba", | 36 | "_shasum": "015db3f353e02e56377755f962742e8981e7bbba", |
37 | + "_shrinkwrap": null, | ||
23 | "_spec": "basic-auth@~2.0.0", | 38 | "_spec": "basic-auth@~2.0.0", |
24 | - "_where": "/home/ubuntu/OpenSource_Project/node_modules/morgan", | 39 | + "_where": "/home/jin/opensource/kakaoBot/node_modules/morgan", |
25 | "bugs": { | 40 | "bugs": { |
26 | "url": "https://github.com/jshttp/basic-auth/issues" | 41 | "url": "https://github.com/jshttp/basic-auth/issues" |
27 | }, | 42 | }, |
28 | - "bundleDependencies": false, | ||
29 | "dependencies": { | 43 | "dependencies": { |
30 | "safe-buffer": "5.1.1" | 44 | "safe-buffer": "5.1.1" |
31 | }, | 45 | }, |
32 | - "deprecated": false, | ||
33 | "description": "node.js basic auth parser", | 46 | "description": "node.js basic auth parser", |
34 | "devDependencies": { | 47 | "devDependencies": { |
35 | "eslint": "3.19.0", | 48 | "eslint": "3.19.0", |
... | @@ -42,6 +55,11 @@ | ... | @@ -42,6 +55,11 @@ |
42 | "istanbul": "0.4.5", | 55 | "istanbul": "0.4.5", |
43 | "mocha": "2.5.3" | 56 | "mocha": "2.5.3" |
44 | }, | 57 | }, |
58 | + "directories": {}, | ||
59 | + "dist": { | ||
60 | + "shasum": "015db3f353e02e56377755f962742e8981e7bbba", | ||
61 | + "tarball": "https://registry.npmjs.org/basic-auth/-/basic-auth-2.0.0.tgz" | ||
62 | + }, | ||
45 | "engines": { | 63 | "engines": { |
46 | "node": ">= 0.8" | 64 | "node": ">= 0.8" |
47 | }, | 65 | }, |
... | @@ -50,15 +68,36 @@ | ... | @@ -50,15 +68,36 @@ |
50 | "LICENSE", | 68 | "LICENSE", |
51 | "index.js" | 69 | "index.js" |
52 | ], | 70 | ], |
71 | + "gitHead": "704457317b54809b750274cc794d05d43cbb190c", | ||
53 | "homepage": "https://github.com/jshttp/basic-auth#readme", | 72 | "homepage": "https://github.com/jshttp/basic-auth#readme", |
54 | "keywords": [ | 73 | "keywords": [ |
55 | - "basic", | ||
56 | "auth", | 74 | "auth", |
57 | "authorization", | 75 | "authorization", |
76 | + "basic", | ||
58 | "basicauth" | 77 | "basicauth" |
59 | ], | 78 | ], |
60 | "license": "MIT", | 79 | "license": "MIT", |
80 | + "maintainers": [ | ||
81 | + { | ||
82 | + "name": "tjholowaychuk", | ||
83 | + "email": "tj@vision-media.ca" | ||
84 | + }, | ||
85 | + { | ||
86 | + "name": "jonathanong", | ||
87 | + "email": "jonathanrichardong@gmail.com" | ||
88 | + }, | ||
89 | + { | ||
90 | + "name": "dougwilson", | ||
91 | + "email": "doug@somethingdoug.com" | ||
92 | + }, | ||
93 | + { | ||
94 | + "name": "jongleberry", | ||
95 | + "email": "jonathanrichardong@gmail.com" | ||
96 | + } | ||
97 | + ], | ||
61 | "name": "basic-auth", | 98 | "name": "basic-auth", |
99 | + "optionalDependencies": {}, | ||
100 | + "readme": "ERROR: No README data found!", | ||
62 | "repository": { | 101 | "repository": { |
63 | "type": "git", | 102 | "type": "git", |
64 | "url": "git+https://github.com/jshttp/basic-auth.git" | 103 | "url": "git+https://github.com/jshttp/basic-auth.git" | ... | ... |
node_modules/bcrypt-pbkdf/CONTRIBUTING.md
0 → 100644
1 | +# Contributing | ||
2 | + | ||
3 | +This repository uses [cr.joyent.us](https://cr.joyent.us) (Gerrit) for new | ||
4 | +changes. Anyone can submit changes. To get started, see the [cr.joyent.us user | ||
5 | +guide](https://github.com/joyent/joyent-gerrit/blob/master/docs/user/README.md). | ||
6 | +This repo does not use GitHub pull requests. | ||
7 | + | ||
8 | +See the [Joyent Engineering | ||
9 | +Guidelines](https://github.com/joyent/eng/blob/master/docs/index.md) for general | ||
10 | +best practices expected in this repository. | ||
11 | + | ||
12 | +If you're changing something non-trivial or user-facing, you may want to submit | ||
13 | +an issue first. |
node_modules/bcrypt-pbkdf/LICENSE
0 → 100644
1 | +The Blowfish portions are under the following license: | ||
2 | + | ||
3 | +Blowfish block cipher for OpenBSD | ||
4 | +Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de> | ||
5 | +All rights reserved. | ||
6 | + | ||
7 | +Implementation advice by David Mazieres <dm@lcs.mit.edu>. | ||
8 | + | ||
9 | +Redistribution and use in source and binary forms, with or without | ||
10 | +modification, are permitted provided that the following conditions | ||
11 | +are met: | ||
12 | +1. Redistributions of source code must retain the above copyright | ||
13 | + notice, this list of conditions and the following disclaimer. | ||
14 | +2. Redistributions in binary form must reproduce the above copyright | ||
15 | + notice, this list of conditions and the following disclaimer in the | ||
16 | + documentation and/or other materials provided with the distribution. | ||
17 | +3. The name of the author may not be used to endorse or promote products | ||
18 | + derived from this software without specific prior written permission. | ||
19 | + | ||
20 | +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | ||
21 | +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
22 | +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||
23 | +IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
24 | +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
25 | +NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
26 | +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
27 | +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
28 | +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
29 | +THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
30 | + | ||
31 | + | ||
32 | + | ||
33 | +The bcrypt_pbkdf portions are under the following license: | ||
34 | + | ||
35 | +Copyright (c) 2013 Ted Unangst <tedu@openbsd.org> | ||
36 | + | ||
37 | +Permission to use, copy, modify, and distribute this software for any | ||
38 | +purpose with or without fee is hereby granted, provided that the above | ||
39 | +copyright notice and this permission notice appear in all copies. | ||
40 | + | ||
41 | +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
42 | +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
43 | +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
44 | +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
45 | +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
46 | +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
47 | +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
48 | + | ||
49 | + | ||
50 | + | ||
51 | +Performance improvements (Javascript-specific): | ||
52 | + | ||
53 | +Copyright 2016, Joyent Inc | ||
54 | +Author: Alex Wilson <alex.wilson@joyent.com> | ||
55 | + | ||
56 | +Permission to use, copy, modify, and distribute this software for any | ||
57 | +purpose with or without fee is hereby granted, provided that the above | ||
58 | +copyright notice and this permission notice appear in all copies. | ||
59 | + | ||
60 | +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
61 | +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
62 | +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
63 | +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
64 | +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
65 | +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
66 | +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
1 | Port of the OpenBSD `bcrypt_pbkdf` function to pure Javascript. `npm`-ified | 1 | Port of the OpenBSD `bcrypt_pbkdf` function to pure Javascript. `npm`-ified |
2 | -version of [Devi Mandiri's port] | 2 | +version of [Devi Mandiri's port](https://github.com/devi/tmp/blob/master/js/bcrypt_pbkdf.js), |
3 | -(https://github.com/devi/tmp/blob/master/js/bcrypt_pbkdf.js), | ||
4 | with some minor performance improvements. The code is copied verbatim (and | 3 | with some minor performance improvements. The code is copied verbatim (and |
5 | un-styled) from Devi's work. | 4 | un-styled) from Devi's work. |
6 | 5 | ||
... | @@ -37,3 +36,10 @@ Parameters: | ... | @@ -37,3 +36,10 @@ Parameters: |
37 | * `sha2pass`, a Uint8Array of length 64 | 36 | * `sha2pass`, a Uint8Array of length 64 |
38 | * `sha2salt`, a Uint8Array of length 64 | 37 | * `sha2salt`, a Uint8Array of length 64 |
39 | * `out`, a Uint8Array of length 32, will be filled with output | 38 | * `out`, a Uint8Array of length 32, will be filled with output |
39 | + | ||
40 | +## License | ||
41 | + | ||
42 | +This source form is a 1:1 port from the OpenBSD `blowfish.c` and `bcrypt_pbkdf.c`. | ||
43 | +As a result, it retains the original copyright and license. The two files are | ||
44 | +under slightly different (but compatible) licenses, and are here combined in | ||
45 | +one file. For each of the full license texts see `LICENSE`. | ... | ... |
1 | { | 1 | { |
2 | "_from": "bcrypt-pbkdf@^1.0.0", | 2 | "_from": "bcrypt-pbkdf@^1.0.0", |
3 | - "_id": "bcrypt-pbkdf@1.0.1", | 3 | + "_id": "bcrypt-pbkdf@1.0.2", |
4 | "_inBundle": false, | 4 | "_inBundle": false, |
5 | - "_integrity": "sha1-Y7xdy2EzG5K8Bf1SiVPDNGKgb40=", | 5 | + "_integrity": "sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4=", |
6 | "_location": "/bcrypt-pbkdf", | 6 | "_location": "/bcrypt-pbkdf", |
7 | "_phantomChildren": {}, | 7 | "_phantomChildren": {}, |
8 | "_requested": { | 8 | "_requested": { |
... | @@ -18,10 +18,13 @@ | ... | @@ -18,10 +18,13 @@ |
18 | "_requiredBy": [ | 18 | "_requiredBy": [ |
19 | "/sshpk" | 19 | "/sshpk" |
20 | ], | 20 | ], |
21 | - "_resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.1.tgz", | 21 | + "_resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", |
22 | - "_shasum": "63bc5dcb61331b92bc05fd528953c33462a06f8d", | 22 | + "_shasum": "a4301d389b6a43f9b67ff3ca11a3f6637e360e9e", |
23 | "_spec": "bcrypt-pbkdf@^1.0.0", | 23 | "_spec": "bcrypt-pbkdf@^1.0.0", |
24 | - "_where": "/home/ubuntu/Opensource/node_modules/sshpk", | 24 | + "_where": "/home/jin/opensource/kakaoBot/node_modules/sshpk", |
25 | + "bugs": { | ||
26 | + "url": "https://github.com/joyent/node-bcrypt-pbkdf/issues" | ||
27 | + }, | ||
25 | "bundleDependencies": false, | 28 | "bundleDependencies": false, |
26 | "dependencies": { | 29 | "dependencies": { |
27 | "tweetnacl": "^0.14.3" | 30 | "tweetnacl": "^0.14.3" |
... | @@ -29,8 +32,13 @@ | ... | @@ -29,8 +32,13 @@ |
29 | "deprecated": false, | 32 | "deprecated": false, |
30 | "description": "Port of the OpenBSD bcrypt_pbkdf function to pure JS", | 33 | "description": "Port of the OpenBSD bcrypt_pbkdf function to pure JS", |
31 | "devDependencies": {}, | 34 | "devDependencies": {}, |
35 | + "homepage": "https://github.com/joyent/node-bcrypt-pbkdf#readme", | ||
32 | "license": "BSD-3-Clause", | 36 | "license": "BSD-3-Clause", |
33 | "main": "index.js", | 37 | "main": "index.js", |
34 | "name": "bcrypt-pbkdf", | 38 | "name": "bcrypt-pbkdf", |
35 | - "version": "1.0.1" | 39 | + "repository": { |
40 | + "type": "git", | ||
41 | + "url": "git://github.com/joyent/node-bcrypt-pbkdf.git" | ||
42 | + }, | ||
43 | + "version": "1.0.2" | ||
36 | } | 44 | } | ... | ... |
1 | +1.18.3 / 2018-05-14 | ||
2 | +=================== | ||
3 | + | ||
4 | + * Fix stack trace for strict json parse error | ||
5 | + * deps: depd@~1.1.2 | ||
6 | + - perf: remove argument reassignment | ||
7 | + * deps: http-errors@~1.6.3 | ||
8 | + - deps: depd@~1.1.2 | ||
9 | + - deps: setprototypeof@1.1.0 | ||
10 | + - deps: statuses@'>= 1.3.1 < 2' | ||
11 | + * deps: iconv-lite@0.4.23 | ||
12 | + - Fix loading encoding with year appended | ||
13 | + - Fix deprecation warnings on Node.js 10+ | ||
14 | + * deps: qs@6.5.2 | ||
15 | + * deps: raw-body@2.3.3 | ||
16 | + - deps: http-errors@1.6.3 | ||
17 | + - deps: iconv-lite@0.4.23 | ||
18 | + * deps: type-is@~1.6.16 | ||
19 | + - deps: mime-types@~2.1.18 | ||
20 | + | ||
1 | 1.18.2 / 2017-09-22 | 21 | 1.18.2 / 2017-09-22 |
2 | =================== | 22 | =================== |
3 | 23 | ... | ... |
... | @@ -4,13 +4,18 @@ | ... | @@ -4,13 +4,18 @@ |
4 | [![NPM Downloads][downloads-image]][downloads-url] | 4 | [![NPM Downloads][downloads-image]][downloads-url] |
5 | [![Build Status][travis-image]][travis-url] | 5 | [![Build Status][travis-image]][travis-url] |
6 | [![Test Coverage][coveralls-image]][coveralls-url] | 6 | [![Test Coverage][coveralls-image]][coveralls-url] |
7 | -[![Gratipay][gratipay-image]][gratipay-url] | ||
8 | 7 | ||
9 | Node.js body parsing middleware. | 8 | Node.js body parsing middleware. |
10 | 9 | ||
11 | Parse incoming request bodies in a middleware before your handlers, available | 10 | Parse incoming request bodies in a middleware before your handlers, available |
12 | under the `req.body` property. | 11 | under the `req.body` property. |
13 | 12 | ||
13 | +**Note** As `req.body`'s shape is based on user-controlled input, all | ||
14 | +properties and values in this object are untrusted and should be validated | ||
15 | +before trusting. For example, `req.body.foo.toString()` may fail in multiple | ||
16 | +ways, for example the `foo` property may not be there or may not be a string, | ||
17 | +and `toString` may not be a function and instead a string or other user input. | ||
18 | + | ||
14 | [Learn about the anatomy of an HTTP transaction in Node.js](https://nodejs.org/en/docs/guides/anatomy-of-an-http-transaction/). | 19 | [Learn about the anatomy of an HTTP transaction in Node.js](https://nodejs.org/en/docs/guides/anatomy-of-an-http-transaction/). |
15 | 20 | ||
16 | _This does not handle multipart bodies_, due to their complex and typically | 21 | _This does not handle multipart bodies_, due to their complex and typically |
... | @@ -100,12 +105,13 @@ accept anything `JSON.parse` accepts. Defaults to `true`. | ... | @@ -100,12 +105,13 @@ accept anything `JSON.parse` accepts. Defaults to `true`. |
100 | ##### type | 105 | ##### type |
101 | 106 | ||
102 | The `type` option is used to determine what media type the middleware will | 107 | The `type` option is used to determine what media type the middleware will |
103 | -parse. This option can be a function or a string. If a string, `type` option | 108 | +parse. This option can be a string, array of strings, or a function. If not a |
104 | -is passed directly to the [type-is](https://www.npmjs.org/package/type-is#readme) | 109 | +function, `type` option is passed directly to the |
105 | -library and this can be an extension name (like `json`), a mime type (like | 110 | +[type-is](https://www.npmjs.org/package/type-is#readme) library and this can |
106 | -`application/json`), or a mime type with a wildcard (like `*/*` or `*/json`). | 111 | +be an extension name (like `json`), a mime type (like `application/json`), or |
107 | -If a function, the `type` option is called as `fn(req)` and the request is | 112 | +a mime type with a wildcard (like `*/*` or `*/json`). If a function, the `type` |
108 | -parsed if it returns a truthy value. Defaults to `application/json`. | 113 | +option is called as `fn(req)` and the request is parsed if it returns a truthy |
114 | +value. Defaults to `application/json`. | ||
109 | 115 | ||
110 | ##### verify | 116 | ##### verify |
111 | 117 | ||
... | @@ -143,9 +149,10 @@ to `'100kb'`. | ... | @@ -143,9 +149,10 @@ to `'100kb'`. |
143 | ##### type | 149 | ##### type |
144 | 150 | ||
145 | The `type` option is used to determine what media type the middleware will | 151 | The `type` option is used to determine what media type the middleware will |
146 | -parse. This option can be a function or a string. If a string, `type` option | 152 | +parse. This option can be a string, array of strings, or a function. |
147 | -is passed directly to the [type-is](https://www.npmjs.org/package/type-is#readme) | 153 | +If not a function, `type` option is passed directly to the |
148 | -library and this can be an extension name (like `bin`), a mime type (like | 154 | +[type-is](https://www.npmjs.org/package/type-is#readme) library and this |
155 | +can be an extension name (like `bin`), a mime type (like | ||
149 | `application/octet-stream`), or a mime type with a wildcard (like `*/*` or | 156 | `application/octet-stream`), or a mime type with a wildcard (like `*/*` or |
150 | `application/*`). If a function, the `type` option is called as `fn(req)` | 157 | `application/*`). If a function, the `type` option is called as `fn(req)` |
151 | and the request is parsed if it returns a truthy value. Defaults to | 158 | and the request is parsed if it returns a truthy value. Defaults to |
... | @@ -192,12 +199,13 @@ to `'100kb'`. | ... | @@ -192,12 +199,13 @@ to `'100kb'`. |
192 | ##### type | 199 | ##### type |
193 | 200 | ||
194 | The `type` option is used to determine what media type the middleware will | 201 | The `type` option is used to determine what media type the middleware will |
195 | -parse. This option can be a function or a string. If a string, `type` option | 202 | +parse. This option can be a string, array of strings, or a function. If not |
196 | -is passed directly to the [type-is](https://www.npmjs.org/package/type-is#readme) | 203 | +a function, `type` option is passed directly to the |
197 | -library and this can be an extension name (like `txt`), a mime type (like | 204 | +[type-is](https://www.npmjs.org/package/type-is#readme) library and this can |
198 | -`text/plain`), or a mime type with a wildcard (like `*/*` or `text/*`). | 205 | +be an extension name (like `txt`), a mime type (like `text/plain`), or a mime |
199 | -If a function, the `type` option is called as `fn(req)` and the request is | 206 | +type with a wildcard (like `*/*` or `text/*`). If a function, the `type` |
200 | -parsed if it returns a truthy value. Defaults to `text/plain`. | 207 | +option is called as `fn(req)` and the request is parsed if it returns a |
208 | +truthy value. Defaults to `text/plain`. | ||
201 | 209 | ||
202 | ##### verify | 210 | ##### verify |
203 | 211 | ||
... | @@ -256,9 +264,10 @@ than this value, a 413 will be returned to the client. Defaults to `1000`. | ... | @@ -256,9 +264,10 @@ than this value, a 413 will be returned to the client. Defaults to `1000`. |
256 | ##### type | 264 | ##### type |
257 | 265 | ||
258 | The `type` option is used to determine what media type the middleware will | 266 | The `type` option is used to determine what media type the middleware will |
259 | -parse. This option can be a function or a string. If a string, `type` option | 267 | +parse. This option can be a string, array of strings, or a function. If not |
260 | -is passed directly to the [type-is](https://www.npmjs.org/package/type-is#readme) | 268 | +a function, `type` option is passed directly to the |
261 | -library and this can be an extension name (like `urlencoded`), a mime type (like | 269 | +[type-is](https://www.npmjs.org/package/type-is#readme) library and this can |
270 | +be an extension name (like `urlencoded`), a mime type (like | ||
262 | `application/x-www-form-urlencoded`), or a mime type with a wildcard (like | 271 | `application/x-www-form-urlencoded`), or a mime type with a wildcard (like |
263 | `*/x-www-form-urlencoded`). If a function, the `type` option is called as | 272 | `*/x-www-form-urlencoded`). If a function, the `type` option is called as |
264 | `fn(req)` and the request is parsed if it returns a truthy value. Defaults | 273 | `fn(req)` and the request is parsed if it returns a truthy value. Defaults |
... | @@ -434,5 +443,3 @@ app.use(bodyParser.text({ type: 'text/html' })) | ... | @@ -434,5 +443,3 @@ app.use(bodyParser.text({ type: 'text/html' })) |
434 | [coveralls-url]: https://coveralls.io/r/expressjs/body-parser?branch=master | 443 | [coveralls-url]: https://coveralls.io/r/expressjs/body-parser?branch=master |
435 | [downloads-image]: https://img.shields.io/npm/dm/body-parser.svg | 444 | [downloads-image]: https://img.shields.io/npm/dm/body-parser.svg |
436 | [downloads-url]: https://npmjs.org/package/body-parser | 445 | [downloads-url]: https://npmjs.org/package/body-parser |
437 | -[gratipay-image]: https://img.shields.io/gratipay/dougwilson.svg | ||
438 | -[gratipay-url]: https://www.gratipay.com/dougwilson/ | ... | ... |
... | @@ -89,6 +89,7 @@ function json (options) { | ... | @@ -89,6 +89,7 @@ function json (options) { |
89 | return JSON.parse(body, reviver) | 89 | return JSON.parse(body, reviver) |
90 | } catch (e) { | 90 | } catch (e) { |
91 | throw normalizeJsonSyntaxError(e, { | 91 | throw normalizeJsonSyntaxError(e, { |
92 | + message: e.message, | ||
92 | stack: e.stack | 93 | stack: e.stack |
93 | }) | 94 | }) |
94 | } | 95 | } |
... | @@ -208,12 +209,9 @@ function normalizeJsonSyntaxError (error, obj) { | ... | @@ -208,12 +209,9 @@ function normalizeJsonSyntaxError (error, obj) { |
208 | } | 209 | } |
209 | } | 210 | } |
210 | 211 | ||
211 | - var props = Object.keys(obj) | 212 | + // replace stack before message for Node.js 0.10 and below |
212 | - | 213 | + error.stack = obj.stack.replace(error.message, obj.message) |
213 | - for (var j = 0; j < props.length; j++) { | 214 | + error.message = obj.message |
214 | - var prop = props[j] | ||
215 | - error[prop] = obj[prop] | ||
216 | - } | ||
217 | 215 | ||
218 | return error | 216 | return error |
219 | } | 217 | } | ... | ... |
1 | +1.1.2 / 2018-01-11 | ||
2 | +================== | ||
3 | + | ||
4 | + * perf: remove argument reassignment | ||
5 | + * Support Node.js 0.6 to 9.x | ||
6 | + | ||
7 | +1.1.1 / 2017-07-27 | ||
8 | +================== | ||
9 | + | ||
10 | + * Remove unnecessary `Buffer` loading | ||
11 | + * Support Node.js 0.6 to 8.x | ||
12 | + | ||
13 | +1.1.0 / 2015-09-14 | ||
14 | +================== | ||
15 | + | ||
16 | + * Enable strict mode in more places | ||
17 | + * Support io.js 3.x | ||
18 | + * Support io.js 2.x | ||
19 | + * Support web browser loading | ||
20 | + - Requires bundler like Browserify or webpack | ||
21 | + | ||
22 | +1.0.1 / 2015-04-07 | ||
23 | +================== | ||
24 | + | ||
25 | + * Fix `TypeError`s when under `'use strict'` code | ||
26 | + * Fix useless type name on auto-generated messages | ||
27 | + * Support io.js 1.x | ||
28 | + * Support Node.js 0.12 | ||
29 | + | ||
30 | +1.0.0 / 2014-09-17 | ||
31 | +================== | ||
32 | + | ||
33 | + * No changes | ||
34 | + | ||
35 | +0.4.5 / 2014-09-09 | ||
36 | +================== | ||
37 | + | ||
38 | + * Improve call speed to functions using the function wrapper | ||
39 | + * Support Node.js 0.6 | ||
40 | + | ||
41 | +0.4.4 / 2014-07-27 | ||
42 | +================== | ||
43 | + | ||
44 | + * Work-around v8 generating empty stack traces | ||
45 | + | ||
46 | +0.4.3 / 2014-07-26 | ||
47 | +================== | ||
48 | + | ||
49 | + * Fix exception when global `Error.stackTraceLimit` is too low | ||
50 | + | ||
51 | +0.4.2 / 2014-07-19 | ||
52 | +================== | ||
53 | + | ||
54 | + * Correct call site for wrapped functions and properties | ||
55 | + | ||
56 | +0.4.1 / 2014-07-19 | ||
57 | +================== | ||
58 | + | ||
59 | + * Improve automatic message generation for function properties | ||
60 | + | ||
61 | +0.4.0 / 2014-07-19 | ||
62 | +================== | ||
63 | + | ||
64 | + * Add `TRACE_DEPRECATION` environment variable | ||
65 | + * Remove non-standard grey color from color output | ||
66 | + * Support `--no-deprecation` argument | ||
67 | + * Support `--trace-deprecation` argument | ||
68 | + * Support `deprecate.property(fn, prop, message)` | ||
69 | + | ||
70 | +0.3.0 / 2014-06-16 | ||
71 | +================== | ||
72 | + | ||
73 | + * Add `NO_DEPRECATION` environment variable | ||
74 | + | ||
75 | +0.2.0 / 2014-06-15 | ||
76 | +================== | ||
77 | + | ||
78 | + * Add `deprecate.property(obj, prop, message)` | ||
79 | + * Remove `supports-color` dependency for node.js 0.8 | ||
80 | + | ||
81 | +0.1.0 / 2014-06-15 | ||
82 | +================== | ||
83 | + | ||
84 | + * Add `deprecate.function(fn, message)` | ||
85 | + * Add `process.on('deprecation', fn)` emitter | ||
86 | + * Automatically generate message when omitted from `deprecate()` | ||
87 | + | ||
88 | +0.0.1 / 2014-06-15 | ||
89 | +================== | ||
90 | + | ||
91 | + * Fix warning for dynamic calls at singe call site | ||
92 | + | ||
93 | +0.0.0 / 2014-06-15 | ||
94 | +================== | ||
95 | + | ||
96 | + * 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 | + | ||
10 | +Deprecate all the things | ||
11 | + | ||
12 | +> With great modules comes great responsibility; mark things deprecated! | ||
13 | + | ||
14 | +## Install | ||
15 | + | ||
16 | +This module is installed directly using `npm`: | ||
17 | + | ||
18 | +```sh | ||
19 | +$ npm install depd | ||
20 | +``` | ||
21 | + | ||
22 | +This module can also be bundled with systems like | ||
23 | +[Browserify](http://browserify.org/) or [webpack](https://webpack.github.io/), | ||
24 | +though by default this module will alter it's API to no longer display or | ||
25 | +track deprecations. | ||
26 | + | ||
27 | +## API | ||
28 | + | ||
29 | +<!-- eslint-disable no-unused-vars --> | ||
30 | + | ||
31 | +```js | ||
32 | +var deprecate = require('depd')('my-module') | ||
33 | +``` | ||
34 | + | ||
35 | +This library allows you to display deprecation messages to your users. | ||
36 | +This library goes above and beyond with deprecation warnings by | ||
37 | +introspection of the call stack (but only the bits that it is interested | ||
38 | +in). | ||
39 | + | ||
40 | +Instead of just warning on the first invocation of a deprecated | ||
41 | +function and never again, this module will warn on the first invocation | ||
42 | +of a deprecated function per unique call site, making it ideal to alert | ||
43 | +users of all deprecated uses across the code base, rather than just | ||
44 | +whatever happens to execute first. | ||
45 | + | ||
46 | +The deprecation warnings from this module also include the file and line | ||
47 | +information for the call into the module that the deprecated function was | ||
48 | +in. | ||
49 | + | ||
50 | +**NOTE** this library has a similar interface to the `debug` module, and | ||
51 | +this module uses the calling file to get the boundary for the call stacks, | ||
52 | +so you should always create a new `deprecate` object in each file and not | ||
53 | +within some central file. | ||
54 | + | ||
55 | +### depd(namespace) | ||
56 | + | ||
57 | +Create a new deprecate function that uses the given namespace name in the | ||
58 | +messages and will display the call site prior to the stack entering the | ||
59 | +file this function was called from. It is highly suggested you use the | ||
60 | +name of your module as the namespace. | ||
61 | + | ||
62 | +### deprecate(message) | ||
63 | + | ||
64 | +Call this function from deprecated code to display a deprecation message. | ||
65 | +This message will appear once per unique caller site. Caller site is the | ||
66 | +first call site in the stack in a different file from the caller of this | ||
67 | +function. | ||
68 | + | ||
69 | +If the message is omitted, a message is generated for you based on the site | ||
70 | +of the `deprecate()` call and will display the name of the function called, | ||
71 | +similar to the name displayed in a stack trace. | ||
72 | + | ||
73 | +### deprecate.function(fn, message) | ||
74 | + | ||
75 | +Call this function to wrap a given function in a deprecation message on any | ||
76 | +call to the function. An optional message can be supplied to provide a custom | ||
77 | +message. | ||
78 | + | ||
79 | +### deprecate.property(obj, prop, message) | ||
80 | + | ||
81 | +Call this function to wrap a given property on object in a deprecation message | ||
82 | +on any accessing or setting of the property. An optional message can be supplied | ||
83 | +to provide a custom message. | ||
84 | + | ||
85 | +The method must be called on the object where the property belongs (not | ||
86 | +inherited from the prototype). | ||
87 | + | ||
88 | +If the property is a data descriptor, it will be converted to an accessor | ||
89 | +descriptor in order to display the deprecation message. | ||
90 | + | ||
91 | +### process.on('deprecation', fn) | ||
92 | + | ||
93 | +This module will allow easy capturing of deprecation errors by emitting the | ||
94 | +errors as the type "deprecation" on the global `process`. If there are no | ||
95 | +listeners for this type, the errors are written to STDERR as normal, but if | ||
96 | +there are any listeners, nothing will be written to STDERR and instead only | ||
97 | +emitted. From there, you can write the errors in a different format or to a | ||
98 | +logging source. | ||
99 | + | ||
100 | +The error represents the deprecation and is emitted only once with the same | ||
101 | +rules as writing to STDERR. The error has the following properties: | ||
102 | + | ||
103 | + - `message` - This is the message given by the library | ||
104 | + - `name` - This is always `'DeprecationError'` | ||
105 | + - `namespace` - This is the namespace the deprecation came from | ||
106 | + - `stack` - This is the stack of the call to the deprecated thing | ||
107 | + | ||
108 | +Example `error.stack` output: | ||
109 | + | ||
110 | +``` | ||
111 | +DeprecationError: my-cool-module deprecated oldfunction | ||
112 | + at Object.<anonymous> ([eval]-wrapper:6:22) | ||
113 | + at Module._compile (module.js:456:26) | ||
114 | + at evalScript (node.js:532:25) | ||
115 | + at startup (node.js:80:7) | ||
116 | + at node.js:902:3 | ||
117 | +``` | ||
118 | + | ||
119 | +### process.env.NO_DEPRECATION | ||
120 | + | ||
121 | +As a user of modules that are deprecated, the environment variable `NO_DEPRECATION` | ||
122 | +is provided as a quick solution to silencing deprecation warnings from being | ||
123 | +output. The format of this is similar to that of `DEBUG`: | ||
124 | + | ||
125 | +```sh | ||
126 | +$ NO_DEPRECATION=my-module,othermod node app.js | ||
127 | +``` | ||
128 | + | ||
129 | +This will suppress deprecations from being output for "my-module" and "othermod". | ||
130 | +The value is a list of comma-separated namespaces. To suppress every warning | ||
131 | +across all namespaces, use the value `*` for a namespace. | ||
132 | + | ||
133 | +Providing the argument `--no-deprecation` to the `node` executable will suppress | ||
134 | +all deprecations (only available in Node.js 0.8 or higher). | ||
135 | + | ||
136 | +**NOTE** This will not suppress the deperecations given to any "deprecation" | ||
137 | +event listeners, just the output to STDERR. | ||
138 | + | ||
139 | +### process.env.TRACE_DEPRECATION | ||
140 | + | ||
141 | +As a user of modules that are deprecated, the environment variable `TRACE_DEPRECATION` | ||
142 | +is provided as a solution to getting more detailed location information in deprecation | ||
143 | +warnings by including the entire stack trace. The format of this is the same as | ||
144 | +`NO_DEPRECATION`: | ||
145 | + | ||
146 | +```sh | ||
147 | +$ TRACE_DEPRECATION=my-module,othermod node app.js | ||
148 | +``` | ||
149 | + | ||
150 | +This will include stack traces for deprecations being output for "my-module" and | ||
151 | +"othermod". The value is a list of comma-separated namespaces. To trace every | ||
152 | +warning across all namespaces, use the value `*` for a namespace. | ||
153 | + | ||
154 | +Providing the argument `--trace-deprecation` to the `node` executable will trace | ||
155 | +all deprecations (only available in Node.js 0.8 or higher). | ||
156 | + | ||
157 | +**NOTE** This will not trace the deperecations silenced by `NO_DEPRECATION`. | ||
158 | + | ||
159 | +## Display | ||
160 | + | ||
161 | +![message](files/message.png) | ||
162 | + | ||
163 | +When a user calls a function in your library that you mark deprecated, they | ||
164 | +will see the following written to STDERR (in the given colors, similar colors | ||
165 | +and layout to the `debug` module): | ||
166 | + | ||
167 | +``` | ||
168 | +bright cyan bright yellow | ||
169 | +| | reset cyan | ||
170 | +| | | | | ||
171 | +▼ ▼ ▼ ▼ | ||
172 | +my-cool-module deprecated oldfunction [eval]-wrapper:6:22 | ||
173 | +▲ ▲ ▲ ▲ | ||
174 | +| | | | | ||
175 | +namespace | | location of mycoolmod.oldfunction() call | ||
176 | + | deprecation message | ||
177 | + the word "deprecated" | ||
178 | +``` | ||
179 | + | ||
180 | +If the user redirects their STDERR to a file or somewhere that does not support | ||
181 | +colors, they see (similar layout to the `debug` module): | ||
182 | + | ||
183 | +``` | ||
184 | +Sun, 15 Jun 2014 05:21:37 GMT my-cool-module deprecated oldfunction at [eval]-wrapper:6:22 | ||
185 | +▲ ▲ ▲ ▲ ▲ | ||
186 | +| | | | | | ||
187 | +timestamp of message namespace | | location of mycoolmod.oldfunction() call | ||
188 | + | deprecation message | ||
189 | + the word "deprecated" | ||
190 | +``` | ||
191 | + | ||
192 | +## Examples | ||
193 | + | ||
194 | +### Deprecating all calls to a function | ||
195 | + | ||
196 | +This will display a deprecated message about "oldfunction" being deprecated | ||
197 | +from "my-module" on STDERR. | ||
198 | + | ||
199 | +```js | ||
200 | +var deprecate = require('depd')('my-cool-module') | ||
201 | + | ||
202 | +// message automatically derived from function name | ||
203 | +// Object.oldfunction | ||
204 | +exports.oldfunction = deprecate.function(function oldfunction () { | ||
205 | + // all calls to function are deprecated | ||
206 | +}) | ||
207 | + | ||
208 | +// specific message | ||
209 | +exports.oldfunction = deprecate.function(function () { | ||
210 | + // all calls to function are deprecated | ||
211 | +}, 'oldfunction') | ||
212 | +``` | ||
213 | + | ||
214 | +### Conditionally deprecating a function call | ||
215 | + | ||
216 | +This will display a deprecated message about "weirdfunction" being deprecated | ||
217 | +from "my-module" on STDERR when called with less than 2 arguments. | ||
218 | + | ||
219 | +```js | ||
220 | +var deprecate = require('depd')('my-cool-module') | ||
221 | + | ||
222 | +exports.weirdfunction = function () { | ||
223 | + if (arguments.length < 2) { | ||
224 | + // calls with 0 or 1 args are deprecated | ||
225 | + deprecate('weirdfunction args < 2') | ||
226 | + } | ||
227 | +} | ||
228 | +``` | ||
229 | + | ||
230 | +When calling `deprecate` as a function, the warning is counted per call site | ||
231 | +within your own module, so you can display different deprecations depending | ||
232 | +on different situations and the users will still get all the warnings: | ||
233 | + | ||
234 | +```js | ||
235 | +var deprecate = require('depd')('my-cool-module') | ||
236 | + | ||
237 | +exports.weirdfunction = function () { | ||
238 | + if (arguments.length < 2) { | ||
239 | + // calls with 0 or 1 args are deprecated | ||
240 | + deprecate('weirdfunction args < 2') | ||
241 | + } else if (typeof arguments[0] !== 'string') { | ||
242 | + // calls with non-string first argument are deprecated | ||
243 | + deprecate('weirdfunction non-string first arg') | ||
244 | + } | ||
245 | +} | ||
246 | +``` | ||
247 | + | ||
248 | +### Deprecating property access | ||
249 | + | ||
250 | +This will display a deprecated message about "oldprop" being deprecated | ||
251 | +from "my-module" on STDERR when accessed. A deprecation will be displayed | ||
252 | +when setting the value and when getting the value. | ||
253 | + | ||
254 | +```js | ||
255 | +var deprecate = require('depd')('my-cool-module') | ||
256 | + | ||
257 | +exports.oldprop = 'something' | ||
258 | + | ||
259 | +// message automatically derives from property name | ||
260 | +deprecate.property(exports, 'oldprop') | ||
261 | + | ||
262 | +// explicit message | ||
263 | +deprecate.property(exports, 'oldprop', 'oldprop >= 0.10') | ||
264 | +``` | ||
265 | + | ||
266 | +## License | ||
267 | + | ||
268 | +[MIT](LICENSE) | ||
269 | + | ||
270 | +[npm-version-image]: https://img.shields.io/npm/v/depd.svg | ||
271 | +[npm-downloads-image]: https://img.shields.io/npm/dm/depd.svg | ||
272 | +[npm-url]: https://npmjs.org/package/depd | ||
273 | +[travis-image]: https://img.shields.io/travis/dougwilson/nodejs-depd/master.svg?label=linux | ||
274 | +[travis-url]: https://travis-ci.org/dougwilson/nodejs-depd | ||
275 | +[appveyor-image]: https://img.shields.io/appveyor/ci/dougwilson/nodejs-depd/master.svg?label=windows | ||
276 | +[appveyor-url]: https://ci.appveyor.com/project/dougwilson/nodejs-depd | ||
277 | +[coveralls-image]: https://img.shields.io/coveralls/dougwilson/nodejs-depd/master.svg | ||
278 | +[coveralls-url]: https://coveralls.io/r/dougwilson/nodejs-depd?branch=master | ||
279 | +[node-image]: https://img.shields.io/node/v/depd.svg | ||
280 | +[node-url]: https://nodejs.org/en/download/ |
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 | +} |
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 = eventListenerCount | ||
15 | + | ||
16 | +/** | ||
17 | + * Get the count of listeners on an event emitter of a specific type. | ||
18 | + */ | ||
19 | + | ||
20 | +function eventListenerCount (emitter, type) { | ||
21 | + return emitter.listeners(type).length | ||
22 | +} |
1 | +/*! | ||
2 | + * depd | ||
3 | + * Copyright(c) 2014-2015 Douglas Christopher Wilson | ||
4 | + * MIT Licensed | ||
5 | + */ | ||
6 | + | ||
7 | +'use strict' | ||
8 | + | ||
9 | +/** | ||
10 | + * Module dependencies. | ||
11 | + * @private | ||
12 | + */ | ||
13 | + | ||
14 | +var EventEmitter = require('events').EventEmitter | ||
15 | + | ||
16 | +/** | ||
17 | + * Module exports. | ||
18 | + * @public | ||
19 | + */ | ||
20 | + | ||
21 | +lazyProperty(module.exports, 'callSiteToString', function callSiteToString () { | ||
22 | + var limit = Error.stackTraceLimit | ||
23 | + var obj = {} | ||
24 | + var prep = Error.prepareStackTrace | ||
25 | + | ||
26 | + function prepareObjectStackTrace (obj, stack) { | ||
27 | + return stack | ||
28 | + } | ||
29 | + | ||
30 | + Error.prepareStackTrace = prepareObjectStackTrace | ||
31 | + Error.stackTraceLimit = 2 | ||
32 | + | ||
33 | + // capture the stack | ||
34 | + Error.captureStackTrace(obj) | ||
35 | + | ||
36 | + // slice the stack | ||
37 | + var stack = obj.stack.slice() | ||
38 | + | ||
39 | + Error.prepareStackTrace = prep | ||
40 | + Error.stackTraceLimit = limit | ||
41 | + | ||
42 | + return stack[0].toString ? toString : require('./callsite-tostring') | ||
43 | +}) | ||
44 | + | ||
45 | +lazyProperty(module.exports, 'eventListenerCount', function eventListenerCount () { | ||
46 | + return EventEmitter.listenerCount || require('./event-listener-count') | ||
47 | +}) | ||
48 | + | ||
49 | +/** | ||
50 | + * Define a lazy property. | ||
51 | + */ | ||
52 | + | ||
53 | +function lazyProperty (obj, prop, getter) { | ||
54 | + function get () { | ||
55 | + var val = getter() | ||
56 | + | ||
57 | + Object.defineProperty(obj, prop, { | ||
58 | + configurable: true, | ||
59 | + enumerable: true, | ||
60 | + value: val | ||
61 | + }) | ||
62 | + | ||
63 | + return val | ||
64 | + } | ||
65 | + | ||
66 | + Object.defineProperty(obj, prop, { | ||
67 | + configurable: true, | ||
68 | + enumerable: true, | ||
69 | + get: get | ||
70 | + }) | ||
71 | +} | ||
72 | + | ||
73 | +/** | ||
74 | + * Call toString() on the obj | ||
75 | + */ | ||
76 | + | ||
77 | +function toString (obj) { | ||
78 | + return obj.toString() | ||
79 | +} |
1 | +{ | ||
2 | + "_from": "depd@~1.1.2", | ||
3 | + "_id": "depd@1.1.2", | ||
4 | + "_inBundle": false, | ||
5 | + "_integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=", | ||
6 | + "_location": "/body-parser/depd", | ||
7 | + "_phantomChildren": {}, | ||
8 | + "_requested": { | ||
9 | + "type": "range", | ||
10 | + "registry": true, | ||
11 | + "raw": "depd@~1.1.2", | ||
12 | + "name": "depd", | ||
13 | + "escapedName": "depd", | ||
14 | + "rawSpec": "~1.1.2", | ||
15 | + "saveSpec": null, | ||
16 | + "fetchSpec": "~1.1.2" | ||
17 | + }, | ||
18 | + "_requiredBy": [ | ||
19 | + "/body-parser" | ||
20 | + ], | ||
21 | + "_resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", | ||
22 | + "_shasum": "9bcd52e14c097763e749b274c4346ed2e560b5a9", | ||
23 | + "_spec": "depd@~1.1.2", | ||
24 | + "_where": "/home/jin/opensource/kakaoBot/node_modules/body-parser", | ||
25 | + "author": { | ||
26 | + "name": "Douglas Christopher Wilson", | ||
27 | + "email": "doug@somethingdoug.com" | ||
28 | + }, | ||
29 | + "browser": "lib/browser/index.js", | ||
30 | + "bugs": { | ||
31 | + "url": "https://github.com/dougwilson/nodejs-depd/issues" | ||
32 | + }, | ||
33 | + "bundleDependencies": false, | ||
34 | + "deprecated": false, | ||
35 | + "description": "Deprecate all the things", | ||
36 | + "devDependencies": { | ||
37 | + "beautify-benchmark": "0.2.4", | ||
38 | + "benchmark": "2.1.4", | ||
39 | + "eslint": "3.19.0", | ||
40 | + "eslint-config-standard": "7.1.0", | ||
41 | + "eslint-plugin-markdown": "1.0.0-beta.7", | ||
42 | + "eslint-plugin-promise": "3.6.0", | ||
43 | + "eslint-plugin-standard": "3.0.1", | ||
44 | + "istanbul": "0.4.5", | ||
45 | + "mocha": "~1.21.5" | ||
46 | + }, | ||
47 | + "engines": { | ||
48 | + "node": ">= 0.6" | ||
49 | + }, | ||
50 | + "files": [ | ||
51 | + "lib/", | ||
52 | + "History.md", | ||
53 | + "LICENSE", | ||
54 | + "index.js", | ||
55 | + "Readme.md" | ||
56 | + ], | ||
57 | + "homepage": "https://github.com/dougwilson/nodejs-depd#readme", | ||
58 | + "keywords": [ | ||
59 | + "deprecate", | ||
60 | + "deprecated" | ||
61 | + ], | ||
62 | + "license": "MIT", | ||
63 | + "name": "depd", | ||
64 | + "repository": { | ||
65 | + "type": "git", | ||
66 | + "url": "git+https://github.com/dougwilson/nodejs-depd.git" | ||
67 | + }, | ||
68 | + "scripts": { | ||
69 | + "bench": "node benchmark/index.js", | ||
70 | + "lint": "eslint --plugin markdown --ext js,md .", | ||
71 | + "test": "mocha --reporter spec --bail test/", | ||
72 | + "test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --no-exit test/", | ||
73 | + "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot test/" | ||
74 | + }, | ||
75 | + "version": "1.1.2" | ||
76 | +} |
1 | + sudo: false | ||
2 | + language: node_js | ||
3 | + node_js: | ||
4 | + - "0.10" | ||
5 | + - "0.11" | ||
6 | + - "0.12" | ||
7 | + - "iojs" | ||
8 | + - "4" | ||
9 | + - "6" | ||
10 | + - "8" | ||
11 | + - "node" | ||
12 | + | ||
13 | + | ||
14 | + env: | ||
15 | + - CXX=g++-4.8 | ||
16 | + addons: | ||
17 | + apt: | ||
18 | + sources: | ||
19 | + - ubuntu-toolchain-r-test | ||
20 | + packages: | ||
21 | + - gcc-4.8 | ||
22 | + - g++-4.8 | ||
23 | + |
1 | + | ||
2 | +# 0.4.23 / 2018-05-07 | ||
3 | + | ||
4 | + * Fix deprecation warning in Node v10 due to the last usage of `new Buffer` (#185, by @felixbuenemann) | ||
5 | + * Switched from NodeBuffer to Buffer in typings (#155 by @felixfbecker, #186 by @larssn) | ||
6 | + | ||
7 | + | ||
8 | +# 0.4.22 / 2018-05-05 | ||
9 | + | ||
10 | + * Use older semver style for dependencies to be compatible with Node version 0.10 (#182, by @dougwilson) | ||
11 | + * Fix tests to accomodate fixes in Node v10 (#182, by @dougwilson) | ||
12 | + | ||
13 | + | ||
14 | +# 0.4.21 / 2018-04-06 | ||
15 | + | ||
16 | + * Fix encoding canonicalization (#156) | ||
17 | + * Fix the paths in the "browser" field in package.json (#174 by @LMLB) | ||
18 | + * Removed "contributors" section in package.json - see Git history instead. | ||
19 | + | ||
20 | + | ||
21 | +# 0.4.20 / 2018-04-06 | ||
22 | + | ||
23 | + * Updated `new Buffer()` usages with recommended replacements as it's being deprecated in Node v10 (#176, #178 by @ChALkeR) | ||
24 | + | ||
25 | + | ||
26 | +# 0.4.19 / 2017-09-09 | ||
27 | + | ||
28 | + * Fixed iso8859-1 codec regression in handling untranslatable characters (#162, caused by #147) | ||
29 | + * Re-generated windows1255 codec, because it was updated in iconv project | ||
30 | + * Fixed grammar in error message when iconv-lite is loaded with encoding other than utf8 | ||
31 | + | ||
32 | + | ||
33 | +# 0.4.18 / 2017-06-13 | ||
34 | + | ||
35 | + * Fixed CESU-8 regression in Node v8. | ||
36 | + | ||
37 | + | ||
38 | +# 0.4.17 / 2017-04-22 | ||
39 | + | ||
40 | + * Updated typescript definition file to support Angular 2 AoT mode (#153 by @larssn) | ||
41 | + | ||
42 | + | ||
43 | +# 0.4.16 / 2017-04-22 | ||
44 | + | ||
45 | + * Added support for React Native (#150) | ||
46 | + * Changed iso8859-1 encoding to usine internal 'binary' encoding, as it's the same thing (#147 by @mscdex) | ||
47 | + * Fixed typo in Readme (#138 by @jiangzhuo) | ||
48 | + * Fixed build for Node v6.10+ by making correct version comparison | ||
49 | + * Added a warning if iconv-lite is loaded not as utf-8 (see #142) | ||
50 | + | ||
51 | + | ||
52 | +# 0.4.15 / 2016-11-21 | ||
53 | + | ||
54 | + * Fixed typescript type definition (#137) | ||
55 | + | ||
56 | + | ||
57 | +# 0.4.14 / 2016-11-20 | ||
58 | + | ||
59 | + * Preparation for v1.0 | ||
60 | + * Added Node v6 and latest Node versions to Travis CI test rig | ||
61 | + * Deprecated Node v0.8 support | ||
62 | + * Typescript typings (@larssn) | ||
63 | + * Fix encoding of Euro character in GB 18030 (inspired by @lygstate) | ||
64 | + * Add ms prefix to dbcs windows encodings (@rokoroku) | ||
65 | + | ||
66 | + | ||
67 | +# 0.4.13 / 2015-10-01 | ||
68 | + | ||
69 | + * Fix silly mistake in deprecation notice. | ||
70 | + | ||
71 | + | ||
72 | +# 0.4.12 / 2015-09-26 | ||
73 | + | ||
74 | + * Node v4 support: | ||
75 | + * Added CESU-8 decoding (#106) | ||
76 | + * Added deprecation notice for `extendNodeEncodings` | ||
77 | + * Added Travis tests for Node v4 and io.js latest (#105 by @Mithgol) | ||
78 | + | ||
79 | + | ||
80 | +# 0.4.11 / 2015-07-03 | ||
81 | + | ||
82 | + * Added CESU-8 encoding. | ||
83 | + | ||
84 | + | ||
85 | +# 0.4.10 / 2015-05-26 | ||
86 | + | ||
87 | + * Changed UTF-16 endianness heuristic to take into account any ASCII chars, not | ||
88 | + just spaces. This should minimize the importance of "default" endianness. | ||
89 | + | ||
90 | + | ||
91 | +# 0.4.9 / 2015-05-24 | ||
92 | + | ||
93 | + * Streamlined BOM handling: strip BOM by default, add BOM when encoding if | ||
94 | + addBOM: true. Added docs to Readme. | ||
95 | + * UTF16 now uses UTF16-LE by default. | ||
96 | + * Fixed minor issue with big5 encoding. | ||
97 | + * Added io.js testing on Travis; updated node-iconv version to test against. | ||
98 | + Now we just skip testing SBCS encodings that node-iconv doesn't support. | ||
99 | + * (internal refactoring) Updated codec interface to use classes. | ||
100 | + * Use strict mode in all files. | ||
101 | + | ||
102 | + | ||
103 | +# 0.4.8 / 2015-04-14 | ||
104 | + | ||
105 | + * added alias UNICODE-1-1-UTF-7 for UTF-7 encoding (#94) | ||
106 | + | ||
107 | + | ||
108 | +# 0.4.7 / 2015-02-05 | ||
109 | + | ||
110 | + * stop official support of Node.js v0.8. Should still work, but no guarantees. | ||
111 | + reason: Packages needed for testing are hard to get on Travis CI. | ||
112 | + * work in environment where Object.prototype is monkey patched with enumerable | ||
113 | + props (#89). | ||
114 | + | ||
115 | + | ||
116 | +# 0.4.6 / 2015-01-12 | ||
117 | + | ||
118 | + * fix rare aliases of single-byte encodings (thanks @mscdex) | ||
119 | + * double the timeout for dbcs tests to make them less flaky on travis | ||
120 | + | ||
121 | + | ||
122 | +# 0.4.5 / 2014-11-20 | ||
123 | + | ||
124 | + * fix windows-31j and x-sjis encoding support (@nleush) | ||
125 | + * minor fix: undefined variable reference when internal error happens | ||
126 | + | ||
127 | + | ||
128 | +# 0.4.4 / 2014-07-16 | ||
129 | + | ||
130 | + * added encodings UTF-7 (RFC2152) and UTF-7-IMAP (RFC3501 Section 5.1.3) | ||
131 | + * fixed streaming base64 encoding | ||
132 | + | ||
133 | + | ||
134 | +# 0.4.3 / 2014-06-14 | ||
135 | + | ||
136 | + * added encodings UTF-16BE and UTF-16 with BOM | ||
137 | + | ||
138 | + | ||
139 | +# 0.4.2 / 2014-06-12 | ||
140 | + | ||
141 | + * don't throw exception if `extendNodeEncodings()` is called more than once | ||
142 | + | ||
143 | + | ||
144 | +# 0.4.1 / 2014-06-11 | ||
145 | + | ||
146 | + * codepage 808 added | ||
147 | + | ||
148 | + | ||
149 | +# 0.4.0 / 2014-06-10 | ||
150 | + | ||
151 | + * code is rewritten from scratch | ||
152 | + * all widespread encodings are supported | ||
153 | + * streaming interface added | ||
154 | + * browserify compatibility added | ||
155 | + * (optional) extend core primitive encodings to make usage even simpler | ||
156 | + * moved from vows to mocha as the testing framework | ||
157 | + | ||
158 | + |
1 | +Copyright (c) 2011 Alexander Shtuchkin | ||
2 | + | ||
3 | +Permission is hereby granted, free of charge, to any person obtaining | ||
4 | +a copy of this software and associated documentation files (the | ||
5 | +"Software"), to deal in the Software without restriction, including | ||
6 | +without limitation the rights to use, copy, modify, merge, publish, | ||
7 | +distribute, sublicense, and/or sell copies of the Software, and to | ||
8 | +permit persons to whom the Software is furnished to do so, subject to | ||
9 | +the following conditions: | ||
10 | + | ||
11 | +The above copyright notice and this permission notice shall be | ||
12 | +included in all copies or substantial portions of the Software. | ||
13 | + | ||
14 | +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
15 | +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
16 | +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
17 | +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
18 | +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
19 | +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
20 | +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
21 | + |
1 | +## Pure JS character encoding conversion [![Build Status](https://travis-ci.org/ashtuchkin/iconv-lite.svg?branch=master)](https://travis-ci.org/ashtuchkin/iconv-lite) | ||
2 | + | ||
3 | + * Doesn't need native code compilation. Works on Windows and in sandboxed environments like [Cloud9](http://c9.io). | ||
4 | + * Used in popular projects like [Express.js (body_parser)](https://github.com/expressjs/body-parser), | ||
5 | + [Grunt](http://gruntjs.com/), [Nodemailer](http://www.nodemailer.com/), [Yeoman](http://yeoman.io/) and others. | ||
6 | + * Faster than [node-iconv](https://github.com/bnoordhuis/node-iconv) (see below for performance comparison). | ||
7 | + * Intuitive encode/decode API | ||
8 | + * Streaming support for Node v0.10+ | ||
9 | + * [Deprecated] Can extend Node.js primitives (buffers, streams) to support all iconv-lite encodings. | ||
10 | + * In-browser usage via [Browserify](https://github.com/substack/node-browserify) (~180k gzip compressed with Buffer shim included). | ||
11 | + * Typescript [type definition file](https://github.com/ashtuchkin/iconv-lite/blob/master/lib/index.d.ts) included. | ||
12 | + * React Native is supported (need to explicitly `npm install` two more modules: `buffer` and `stream`). | ||
13 | + * License: MIT. | ||
14 | + | ||
15 | +[![NPM Stats](https://nodei.co/npm/iconv-lite.png?downloads=true&downloadRank=true)](https://npmjs.org/packages/iconv-lite/) | ||
16 | + | ||
17 | +## Usage | ||
18 | +### Basic API | ||
19 | +```javascript | ||
20 | +var iconv = require('iconv-lite'); | ||
21 | + | ||
22 | +// Convert from an encoded buffer to js string. | ||
23 | +str = iconv.decode(Buffer.from([0x68, 0x65, 0x6c, 0x6c, 0x6f]), 'win1251'); | ||
24 | + | ||
25 | +// Convert from js string to an encoded buffer. | ||
26 | +buf = iconv.encode("Sample input string", 'win1251'); | ||
27 | + | ||
28 | +// Check if encoding is supported | ||
29 | +iconv.encodingExists("us-ascii") | ||
30 | +``` | ||
31 | + | ||
32 | +### Streaming API (Node v0.10+) | ||
33 | +```javascript | ||
34 | + | ||
35 | +// Decode stream (from binary stream to js strings) | ||
36 | +http.createServer(function(req, res) { | ||
37 | + var converterStream = iconv.decodeStream('win1251'); | ||
38 | + req.pipe(converterStream); | ||
39 | + | ||
40 | + converterStream.on('data', function(str) { | ||
41 | + console.log(str); // Do something with decoded strings, chunk-by-chunk. | ||
42 | + }); | ||
43 | +}); | ||
44 | + | ||
45 | +// Convert encoding streaming example | ||
46 | +fs.createReadStream('file-in-win1251.txt') | ||
47 | + .pipe(iconv.decodeStream('win1251')) | ||
48 | + .pipe(iconv.encodeStream('ucs2')) | ||
49 | + .pipe(fs.createWriteStream('file-in-ucs2.txt')); | ||
50 | + | ||
51 | +// Sugar: all encode/decode streams have .collect(cb) method to accumulate data. | ||
52 | +http.createServer(function(req, res) { | ||
53 | + req.pipe(iconv.decodeStream('win1251')).collect(function(err, body) { | ||
54 | + assert(typeof body == 'string'); | ||
55 | + console.log(body); // full request body string | ||
56 | + }); | ||
57 | +}); | ||
58 | +``` | ||
59 | + | ||
60 | +### [Deprecated] Extend Node.js own encodings | ||
61 | +> NOTE: This doesn't work on latest Node versions. See [details](https://github.com/ashtuchkin/iconv-lite/wiki/Node-v4-compatibility). | ||
62 | + | ||
63 | +```javascript | ||
64 | +// After this call all Node basic primitives will understand iconv-lite encodings. | ||
65 | +iconv.extendNodeEncodings(); | ||
66 | + | ||
67 | +// Examples: | ||
68 | +buf = new Buffer(str, 'win1251'); | ||
69 | +buf.write(str, 'gbk'); | ||
70 | +str = buf.toString('latin1'); | ||
71 | +assert(Buffer.isEncoding('iso-8859-15')); | ||
72 | +Buffer.byteLength(str, 'us-ascii'); | ||
73 | + | ||
74 | +http.createServer(function(req, res) { | ||
75 | + req.setEncoding('big5'); | ||
76 | + req.collect(function(err, body) { | ||
77 | + console.log(body); | ||
78 | + }); | ||
79 | +}); | ||
80 | + | ||
81 | +fs.createReadStream("file.txt", "shift_jis"); | ||
82 | + | ||
83 | +// External modules are also supported (if they use Node primitives, which they probably do). | ||
84 | +request = require('request'); | ||
85 | +request({ | ||
86 | + url: "http://github.com/", | ||
87 | + encoding: "cp932" | ||
88 | +}); | ||
89 | + | ||
90 | +// To remove extensions | ||
91 | +iconv.undoExtendNodeEncodings(); | ||
92 | +``` | ||
93 | + | ||
94 | +## Supported encodings | ||
95 | + | ||
96 | + * All node.js native encodings: utf8, ucs2 / utf16-le, ascii, binary, base64, hex. | ||
97 | + * Additional unicode encodings: utf16, utf16-be, utf-7, utf-7-imap. | ||
98 | + * All widespread singlebyte encodings: Windows 125x family, ISO-8859 family, | ||
99 | + IBM/DOS codepages, Macintosh family, KOI8 family, all others supported by iconv library. | ||
100 | + Aliases like 'latin1', 'us-ascii' also supported. | ||
101 | + * All widespread multibyte encodings: CP932, CP936, CP949, CP950, GB2312, GBK, GB18030, Big5, Shift_JIS, EUC-JP. | ||
102 | + | ||
103 | +See [all supported encodings on wiki](https://github.com/ashtuchkin/iconv-lite/wiki/Supported-Encodings). | ||
104 | + | ||
105 | +Most singlebyte encodings are generated automatically from [node-iconv](https://github.com/bnoordhuis/node-iconv). Thank you Ben Noordhuis and libiconv authors! | ||
106 | + | ||
107 | +Multibyte encodings are generated from [Unicode.org mappings](http://www.unicode.org/Public/MAPPINGS/) and [WHATWG Encoding Standard mappings](http://encoding.spec.whatwg.org/). Thank you, respective authors! | ||
108 | + | ||
109 | + | ||
110 | +## Encoding/decoding speed | ||
111 | + | ||
112 | +Comparison with node-iconv module (1000x256kb, on MacBook Pro, Core i5/2.6 GHz, Node v0.12.0). | ||
113 | +Note: your results may vary, so please always check on your hardware. | ||
114 | + | ||
115 | + operation iconv@2.1.4 iconv-lite@0.4.7 | ||
116 | + ---------------------------------------------------------- | ||
117 | + encode('win1251') ~96 Mb/s ~320 Mb/s | ||
118 | + decode('win1251') ~95 Mb/s ~246 Mb/s | ||
119 | + | ||
120 | +## BOM handling | ||
121 | + | ||
122 | + * Decoding: BOM is stripped by default, unless overridden by passing `stripBOM: false` in options | ||
123 | + (f.ex. `iconv.decode(buf, enc, {stripBOM: false})`). | ||
124 | + A callback might also be given as a `stripBOM` parameter - it'll be called if BOM character was actually found. | ||
125 | + * If you want to detect UTF-8 BOM when decoding other encodings, use [node-autodetect-decoder-stream](https://github.com/danielgindi/node-autodetect-decoder-stream) module. | ||
126 | + * Encoding: No BOM added, unless overridden by `addBOM: true` option. | ||
127 | + | ||
128 | +## UTF-16 Encodings | ||
129 | + | ||
130 | +This library supports UTF-16LE, UTF-16BE and UTF-16 encodings. First two are straightforward, but UTF-16 is trying to be | ||
131 | +smart about endianness in the following ways: | ||
132 | + * Decoding: uses BOM and 'spaces heuristic' to determine input endianness. Default is UTF-16LE, but can be | ||
133 | + overridden with `defaultEncoding: 'utf-16be'` option. Strips BOM unless `stripBOM: false`. | ||
134 | + * Encoding: uses UTF-16LE and writes BOM by default. Use `addBOM: false` to override. | ||
135 | + | ||
136 | +## Other notes | ||
137 | + | ||
138 | +When decoding, be sure to supply a Buffer to decode() method, otherwise [bad things usually happen](https://github.com/ashtuchkin/iconv-lite/wiki/Use-Buffers-when-decoding). | ||
139 | +Untranslatable characters are set to � or ?. No transliteration is currently supported. | ||
140 | +Node versions 0.10.31 and 0.11.13 are buggy, don't use them (see #65, #77). | ||
141 | + | ||
142 | +## Testing | ||
143 | + | ||
144 | +```bash | ||
145 | +$ git clone git@github.com:ashtuchkin/iconv-lite.git | ||
146 | +$ cd iconv-lite | ||
147 | +$ npm install | ||
148 | +$ npm test | ||
149 | + | ||
150 | +$ # To view performance: | ||
151 | +$ node test/performance.js | ||
152 | + | ||
153 | +$ # To view test coverage: | ||
154 | +$ npm run coverage | ||
155 | +$ open coverage/lcov-report/index.html | ||
156 | +``` |
This diff is collapsed. Click to expand it.
1 | +"use strict"; | ||
2 | + | ||
3 | +// Description of supported double byte encodings and aliases. | ||
4 | +// Tables are not require()-d until they are needed to speed up library load. | ||
5 | +// require()-s are direct to support Browserify. | ||
6 | + | ||
7 | +module.exports = { | ||
8 | + | ||
9 | + // == Japanese/ShiftJIS ==================================================== | ||
10 | + // All japanese encodings are based on JIS X set of standards: | ||
11 | + // JIS X 0201 - Single-byte encoding of ASCII + ¥ + Kana chars at 0xA1-0xDF. | ||
12 | + // JIS X 0208 - Main set of 6879 characters, placed in 94x94 plane, to be encoded by 2 bytes. | ||
13 | + // Has several variations in 1978, 1983, 1990 and 1997. | ||
14 | + // JIS X 0212 - Supplementary plane of 6067 chars in 94x94 plane. 1990. Effectively dead. | ||
15 | + // JIS X 0213 - Extension and modern replacement of 0208 and 0212. Total chars: 11233. | ||
16 | + // 2 planes, first is superset of 0208, second - revised 0212. | ||
17 | + // Introduced in 2000, revised 2004. Some characters are in Unicode Plane 2 (0x2xxxx) | ||
18 | + | ||
19 | + // Byte encodings are: | ||
20 | + // * Shift_JIS: Compatible with 0201, uses not defined chars in top half as lead bytes for double-byte | ||
21 | + // encoding of 0208. Lead byte ranges: 0x81-0x9F, 0xE0-0xEF; Trail byte ranges: 0x40-0x7E, 0x80-0x9E, 0x9F-0xFC. | ||
22 | + // Windows CP932 is a superset of Shift_JIS. Some companies added more chars, notably KDDI. | ||
23 | + // * EUC-JP: Up to 3 bytes per character. Used mostly on *nixes. | ||
24 | + // 0x00-0x7F - lower part of 0201 | ||
25 | + // 0x8E, 0xA1-0xDF - upper part of 0201 | ||
26 | + // (0xA1-0xFE)x2 - 0208 plane (94x94). | ||
27 | + // 0x8F, (0xA1-0xFE)x2 - 0212 plane (94x94). | ||
28 | + // * JIS X 208: 7-bit, direct encoding of 0208. Byte ranges: 0x21-0x7E (94 values). Uncommon. | ||
29 | + // Used as-is in ISO2022 family. | ||
30 | + // * ISO2022-JP: Stateful encoding, with escape sequences to switch between ASCII, | ||
31 | + // 0201-1976 Roman, 0208-1978, 0208-1983. | ||
32 | + // * ISO2022-JP-1: Adds esc seq for 0212-1990. | ||
33 | + // * ISO2022-JP-2: Adds esc seq for GB2313-1980, KSX1001-1992, ISO8859-1, ISO8859-7. | ||
34 | + // * ISO2022-JP-3: Adds esc seq for 0201-1976 Kana set, 0213-2000 Planes 1, 2. | ||
35 | + // * ISO2022-JP-2004: Adds 0213-2004 Plane 1. | ||
36 | + // | ||
37 | + // After JIS X 0213 appeared, Shift_JIS-2004, EUC-JISX0213 and ISO2022-JP-2004 followed, with just changing the planes. | ||
38 | + // | ||
39 | + // Overall, it seems that it's a mess :( http://www8.plala.or.jp/tkubota1/unicode-symbols-map2.html | ||
40 | + | ||
41 | + 'shiftjis': { | ||
42 | + type: '_dbcs', | ||
43 | + table: function() { return require('./tables/shiftjis.json') }, | ||
44 | + encodeAdd: {'\u00a5': 0x5C, '\u203E': 0x7E}, | ||
45 | + encodeSkipVals: [{from: 0xED40, to: 0xF940}], | ||
46 | + }, | ||
47 | + 'csshiftjis': 'shiftjis', | ||
48 | + 'mskanji': 'shiftjis', | ||
49 | + 'sjis': 'shiftjis', | ||
50 | + 'windows31j': 'shiftjis', | ||
51 | + 'ms31j': 'shiftjis', | ||
52 | + 'xsjis': 'shiftjis', | ||
53 | + 'windows932': 'shiftjis', | ||
54 | + 'ms932': 'shiftjis', | ||
55 | + '932': 'shiftjis', | ||
56 | + 'cp932': 'shiftjis', | ||
57 | + | ||
58 | + 'eucjp': { | ||
59 | + type: '_dbcs', | ||
60 | + table: function() { return require('./tables/eucjp.json') }, | ||
61 | + encodeAdd: {'\u00a5': 0x5C, '\u203E': 0x7E}, | ||
62 | + }, | ||
63 | + | ||
64 | + // TODO: KDDI extension to Shift_JIS | ||
65 | + // TODO: IBM CCSID 942 = CP932, but F0-F9 custom chars and other char changes. | ||
66 | + // TODO: IBM CCSID 943 = Shift_JIS = CP932 with original Shift_JIS lower 128 chars. | ||
67 | + | ||
68 | + | ||
69 | + // == Chinese/GBK ========================================================== | ||
70 | + // http://en.wikipedia.org/wiki/GBK | ||
71 | + // We mostly implement W3C recommendation: https://www.w3.org/TR/encoding/#gbk-encoder | ||
72 | + | ||
73 | + // Oldest GB2312 (1981, ~7600 chars) is a subset of CP936 | ||
74 | + 'gb2312': 'cp936', | ||
75 | + 'gb231280': 'cp936', | ||
76 | + 'gb23121980': 'cp936', | ||
77 | + 'csgb2312': 'cp936', | ||
78 | + 'csiso58gb231280': 'cp936', | ||
79 | + 'euccn': 'cp936', | ||
80 | + | ||
81 | + // Microsoft's CP936 is a subset and approximation of GBK. | ||
82 | + 'windows936': 'cp936', | ||
83 | + 'ms936': 'cp936', | ||
84 | + '936': 'cp936', | ||
85 | + 'cp936': { | ||
86 | + type: '_dbcs', | ||
87 | + table: function() { return require('./tables/cp936.json') }, | ||
88 | + }, | ||
89 | + | ||
90 | + // GBK (~22000 chars) is an extension of CP936 that added user-mapped chars and some other. | ||
91 | + 'gbk': { | ||
92 | + type: '_dbcs', | ||
93 | + table: function() { return require('./tables/cp936.json').concat(require('./tables/gbk-added.json')) }, | ||
94 | + }, | ||
95 | + 'xgbk': 'gbk', | ||
96 | + 'isoir58': 'gbk', | ||
97 | + | ||
98 | + // GB18030 is an algorithmic extension of GBK. | ||
99 | + // Main source: https://www.w3.org/TR/encoding/#gbk-encoder | ||
100 | + // http://icu-project.org/docs/papers/gb18030.html | ||
101 | + // http://source.icu-project.org/repos/icu/data/trunk/charset/data/xml/gb-18030-2000.xml | ||
102 | + // http://www.khngai.com/chinese/charmap/tblgbk.php?page=0 | ||
103 | + 'gb18030': { | ||
104 | + type: '_dbcs', | ||
105 | + table: function() { return require('./tables/cp936.json').concat(require('./tables/gbk-added.json')) }, | ||
106 | + gb18030: function() { return require('./tables/gb18030-ranges.json') }, | ||
107 | + encodeSkipVals: [0x80], | ||
108 | + encodeAdd: {'€': 0xA2E3}, | ||
109 | + }, | ||
110 | + | ||
111 | + 'chinese': 'gb18030', | ||
112 | + | ||
113 | + | ||
114 | + // == Korean =============================================================== | ||
115 | + // EUC-KR, KS_C_5601 and KS X 1001 are exactly the same. | ||
116 | + 'windows949': 'cp949', | ||
117 | + 'ms949': 'cp949', | ||
118 | + '949': 'cp949', | ||
119 | + 'cp949': { | ||
120 | + type: '_dbcs', | ||
121 | + table: function() { return require('./tables/cp949.json') }, | ||
122 | + }, | ||
123 | + | ||
124 | + 'cseuckr': 'cp949', | ||
125 | + 'csksc56011987': 'cp949', | ||
126 | + 'euckr': 'cp949', | ||
127 | + 'isoir149': 'cp949', | ||
128 | + 'korean': 'cp949', | ||
129 | + 'ksc56011987': 'cp949', | ||
130 | + 'ksc56011989': 'cp949', | ||
131 | + 'ksc5601': 'cp949', | ||
132 | + | ||
133 | + | ||
134 | + // == Big5/Taiwan/Hong Kong ================================================ | ||
135 | + // There are lots of tables for Big5 and cp950. Please see the following links for history: | ||
136 | + // http://moztw.org/docs/big5/ http://www.haible.de/bruno/charsets/conversion-tables/Big5.html | ||
137 | + // Variations, in roughly number of defined chars: | ||
138 | + // * Windows CP 950: Microsoft variant of Big5. Canonical: http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP950.TXT | ||
139 | + // * Windows CP 951: Microsoft variant of Big5-HKSCS-2001. Seems to be never public. http://me.abelcheung.org/articles/research/what-is-cp951/ | ||
140 | + // * Big5-2003 (Taiwan standard) almost superset of cp950. | ||
141 | + // * Unicode-at-on (UAO) / Mozilla 1.8. Falling out of use on the Web. Not supported by other browsers. | ||
142 | + // * Big5-HKSCS (-2001, -2004, -2008). Hong Kong standard. | ||
143 | + // many unicode code points moved from PUA to Supplementary plane (U+2XXXX) over the years. | ||
144 | + // Plus, it has 4 combining sequences. | ||
145 | + // Seems that Mozilla refused to support it for 10 yrs. https://bugzilla.mozilla.org/show_bug.cgi?id=162431 https://bugzilla.mozilla.org/show_bug.cgi?id=310299 | ||
146 | + // because big5-hkscs is the only encoding to include astral characters in non-algorithmic way. | ||
147 | + // Implementations are not consistent within browsers; sometimes labeled as just big5. | ||
148 | + // MS Internet Explorer switches from big5 to big5-hkscs when a patch applied. | ||
149 | + // Great discussion & recap of what's going on https://bugzilla.mozilla.org/show_bug.cgi?id=912470#c31 | ||
150 | + // In the encoder, it might make sense to support encoding old PUA mappings to Big5 bytes seq-s. | ||
151 | + // Official spec: http://www.ogcio.gov.hk/en/business/tech_promotion/ccli/terms/doc/2003cmp_2008.txt | ||
152 | + // http://www.ogcio.gov.hk/tc/business/tech_promotion/ccli/terms/doc/hkscs-2008-big5-iso.txt | ||
153 | + // | ||
154 | + // Current understanding of how to deal with Big5(-HKSCS) is in the Encoding Standard, http://encoding.spec.whatwg.org/#big5-encoder | ||
155 | + // Unicode mapping (http://www.unicode.org/Public/MAPPINGS/OBSOLETE/EASTASIA/OTHER/BIG5.TXT) is said to be wrong. | ||
156 | + | ||
157 | + 'windows950': 'cp950', | ||
158 | + 'ms950': 'cp950', | ||
159 | + '950': 'cp950', | ||
160 | + 'cp950': { | ||
161 | + type: '_dbcs', | ||
162 | + table: function() { return require('./tables/cp950.json') }, | ||
163 | + }, | ||
164 | + | ||
165 | + // Big5 has many variations and is an extension of cp950. We use Encoding Standard's as a consensus. | ||
166 | + 'big5': 'big5hkscs', | ||
167 | + 'big5hkscs': { | ||
168 | + type: '_dbcs', | ||
169 | + table: function() { return require('./tables/cp950.json').concat(require('./tables/big5-added.json')) }, | ||
170 | + encodeSkipVals: [0xa2cc], | ||
171 | + }, | ||
172 | + | ||
173 | + 'cnbig5': 'big5hkscs', | ||
174 | + 'csbig5': 'big5hkscs', | ||
175 | + 'xxbig5': 'big5hkscs', | ||
176 | +}; |
1 | +"use strict"; | ||
2 | + | ||
3 | +// Update this array if you add/rename/remove files in this directory. | ||
4 | +// We support Browserify by skipping automatic module discovery and requiring modules directly. | ||
5 | +var modules = [ | ||
6 | + require("./internal"), | ||
7 | + require("./utf16"), | ||
8 | + require("./utf7"), | ||
9 | + require("./sbcs-codec"), | ||
10 | + require("./sbcs-data"), | ||
11 | + require("./sbcs-data-generated"), | ||
12 | + require("./dbcs-codec"), | ||
13 | + require("./dbcs-data"), | ||
14 | +]; | ||
15 | + | ||
16 | +// Put all encoding/alias/codec definitions to single object and export it. | ||
17 | +for (var i = 0; i < modules.length; i++) { | ||
18 | + var module = modules[i]; | ||
19 | + for (var enc in module) | ||
20 | + if (Object.prototype.hasOwnProperty.call(module, enc)) | ||
21 | + exports[enc] = module[enc]; | ||
22 | +} |
1 | +"use strict"; | ||
2 | +var Buffer = require("safer-buffer").Buffer; | ||
3 | + | ||
4 | +// Export Node.js internal encodings. | ||
5 | + | ||
6 | +module.exports = { | ||
7 | + // Encodings | ||
8 | + utf8: { type: "_internal", bomAware: true}, | ||
9 | + cesu8: { type: "_internal", bomAware: true}, | ||
10 | + unicode11utf8: "utf8", | ||
11 | + | ||
12 | + ucs2: { type: "_internal", bomAware: true}, | ||
13 | + utf16le: "ucs2", | ||
14 | + | ||
15 | + binary: { type: "_internal" }, | ||
16 | + base64: { type: "_internal" }, | ||
17 | + hex: { type: "_internal" }, | ||
18 | + | ||
19 | + // Codec. | ||
20 | + _internal: InternalCodec, | ||
21 | +}; | ||
22 | + | ||
23 | +//------------------------------------------------------------------------------ | ||
24 | + | ||
25 | +function InternalCodec(codecOptions, iconv) { | ||
26 | + this.enc = codecOptions.encodingName; | ||
27 | + this.bomAware = codecOptions.bomAware; | ||
28 | + | ||
29 | + if (this.enc === "base64") | ||
30 | + this.encoder = InternalEncoderBase64; | ||
31 | + else if (this.enc === "cesu8") { | ||
32 | + this.enc = "utf8"; // Use utf8 for decoding. | ||
33 | + this.encoder = InternalEncoderCesu8; | ||
34 | + | ||
35 | + // Add decoder for versions of Node not supporting CESU-8 | ||
36 | + if (Buffer.from('eda0bdedb2a9', 'hex').toString() !== '💩') { | ||
37 | + this.decoder = InternalDecoderCesu8; | ||
38 | + this.defaultCharUnicode = iconv.defaultCharUnicode; | ||
39 | + } | ||
40 | + } | ||
41 | +} | ||
42 | + | ||
43 | +InternalCodec.prototype.encoder = InternalEncoder; | ||
44 | +InternalCodec.prototype.decoder = InternalDecoder; | ||
45 | + | ||
46 | +//------------------------------------------------------------------------------ | ||
47 | + | ||
48 | +// We use node.js internal decoder. Its signature is the same as ours. | ||
49 | +var StringDecoder = require('string_decoder').StringDecoder; | ||
50 | + | ||
51 | +if (!StringDecoder.prototype.end) // Node v0.8 doesn't have this method. | ||
52 | + StringDecoder.prototype.end = function() {}; | ||
53 | + | ||
54 | + | ||
55 | +function InternalDecoder(options, codec) { | ||
56 | + StringDecoder.call(this, codec.enc); | ||
57 | +} | ||
58 | + | ||
59 | +InternalDecoder.prototype = StringDecoder.prototype; | ||
60 | + | ||
61 | + | ||
62 | +//------------------------------------------------------------------------------ | ||
63 | +// Encoder is mostly trivial | ||
64 | + | ||
65 | +function InternalEncoder(options, codec) { | ||
66 | + this.enc = codec.enc; | ||
67 | +} | ||
68 | + | ||
69 | +InternalEncoder.prototype.write = function(str) { | ||
70 | + return Buffer.from(str, this.enc); | ||
71 | +} | ||
72 | + | ||
73 | +InternalEncoder.prototype.end = function() { | ||
74 | +} | ||
75 | + | ||
76 | + | ||
77 | +//------------------------------------------------------------------------------ | ||
78 | +// Except base64 encoder, which must keep its state. | ||
79 | + | ||
80 | +function InternalEncoderBase64(options, codec) { | ||
81 | + this.prevStr = ''; | ||
82 | +} | ||
83 | + | ||
84 | +InternalEncoderBase64.prototype.write = function(str) { | ||
85 | + str = this.prevStr + str; | ||
86 | + var completeQuads = str.length - (str.length % 4); | ||
87 | + this.prevStr = str.slice(completeQuads); | ||
88 | + str = str.slice(0, completeQuads); | ||
89 | + | ||
90 | + return Buffer.from(str, "base64"); | ||
91 | +} | ||
92 | + | ||
93 | +InternalEncoderBase64.prototype.end = function() { | ||
94 | + return Buffer.from(this.prevStr, "base64"); | ||
95 | +} | ||
96 | + | ||
97 | + | ||
98 | +//------------------------------------------------------------------------------ | ||
99 | +// CESU-8 encoder is also special. | ||
100 | + | ||
101 | +function InternalEncoderCesu8(options, codec) { | ||
102 | +} | ||
103 | + | ||
104 | +InternalEncoderCesu8.prototype.write = function(str) { | ||
105 | + var buf = Buffer.alloc(str.length * 3), bufIdx = 0; | ||
106 | + for (var i = 0; i < str.length; i++) { | ||
107 | + var charCode = str.charCodeAt(i); | ||
108 | + // Naive implementation, but it works because CESU-8 is especially easy | ||
109 | + // to convert from UTF-16 (which all JS strings are encoded in). | ||
110 | + if (charCode < 0x80) | ||
111 | + buf[bufIdx++] = charCode; | ||
112 | + else if (charCode < 0x800) { | ||
113 | + buf[bufIdx++] = 0xC0 + (charCode >>> 6); | ||
114 | + buf[bufIdx++] = 0x80 + (charCode & 0x3f); | ||
115 | + } | ||
116 | + else { // charCode will always be < 0x10000 in javascript. | ||
117 | + buf[bufIdx++] = 0xE0 + (charCode >>> 12); | ||
118 | + buf[bufIdx++] = 0x80 + ((charCode >>> 6) & 0x3f); | ||
119 | + buf[bufIdx++] = 0x80 + (charCode & 0x3f); | ||
120 | + } | ||
121 | + } | ||
122 | + return buf.slice(0, bufIdx); | ||
123 | +} | ||
124 | + | ||
125 | +InternalEncoderCesu8.prototype.end = function() { | ||
126 | +} | ||
127 | + | ||
128 | +//------------------------------------------------------------------------------ | ||
129 | +// CESU-8 decoder is not implemented in Node v4.0+ | ||
130 | + | ||
131 | +function InternalDecoderCesu8(options, codec) { | ||
132 | + this.acc = 0; | ||
133 | + this.contBytes = 0; | ||
134 | + this.accBytes = 0; | ||
135 | + this.defaultCharUnicode = codec.defaultCharUnicode; | ||
136 | +} | ||
137 | + | ||
138 | +InternalDecoderCesu8.prototype.write = function(buf) { | ||
139 | + var acc = this.acc, contBytes = this.contBytes, accBytes = this.accBytes, | ||
140 | + res = ''; | ||
141 | + for (var i = 0; i < buf.length; i++) { | ||
142 | + var curByte = buf[i]; | ||
143 | + if ((curByte & 0xC0) !== 0x80) { // Leading byte | ||
144 | + if (contBytes > 0) { // Previous code is invalid | ||
145 | + res += this.defaultCharUnicode; | ||
146 | + contBytes = 0; | ||
147 | + } | ||
148 | + | ||
149 | + if (curByte < 0x80) { // Single-byte code | ||
150 | + res += String.fromCharCode(curByte); | ||
151 | + } else if (curByte < 0xE0) { // Two-byte code | ||
152 | + acc = curByte & 0x1F; | ||
153 | + contBytes = 1; accBytes = 1; | ||
154 | + } else if (curByte < 0xF0) { // Three-byte code | ||
155 | + acc = curByte & 0x0F; | ||
156 | + contBytes = 2; accBytes = 1; | ||
157 | + } else { // Four or more are not supported for CESU-8. | ||
158 | + res += this.defaultCharUnicode; | ||
159 | + } | ||
160 | + } else { // Continuation byte | ||
161 | + if (contBytes > 0) { // We're waiting for it. | ||
162 | + acc = (acc << 6) | (curByte & 0x3f); | ||
163 | + contBytes--; accBytes++; | ||
164 | + if (contBytes === 0) { | ||
165 | + // Check for overlong encoding, but support Modified UTF-8 (encoding NULL as C0 80) | ||
166 | + if (accBytes === 2 && acc < 0x80 && acc > 0) | ||
167 | + res += this.defaultCharUnicode; | ||
168 | + else if (accBytes === 3 && acc < 0x800) | ||
169 | + res += this.defaultCharUnicode; | ||
170 | + else | ||
171 | + // Actually add character. | ||
172 | + res += String.fromCharCode(acc); | ||
173 | + } | ||
174 | + } else { // Unexpected continuation byte | ||
175 | + res += this.defaultCharUnicode; | ||
176 | + } | ||
177 | + } | ||
178 | + } | ||
179 | + this.acc = acc; this.contBytes = contBytes; this.accBytes = accBytes; | ||
180 | + return res; | ||
181 | +} | ||
182 | + | ||
183 | +InternalDecoderCesu8.prototype.end = function() { | ||
184 | + var res = 0; | ||
185 | + if (this.contBytes > 0) | ||
186 | + res += this.defaultCharUnicode; | ||
187 | + return res; | ||
188 | +} |
1 | +"use strict"; | ||
2 | +var Buffer = require("safer-buffer").Buffer; | ||
3 | + | ||
4 | +// Single-byte codec. Needs a 'chars' string parameter that contains 256 or 128 chars that | ||
5 | +// correspond to encoded bytes (if 128 - then lower half is ASCII). | ||
6 | + | ||
7 | +exports._sbcs = SBCSCodec; | ||
8 | +function SBCSCodec(codecOptions, iconv) { | ||
9 | + if (!codecOptions) | ||
10 | + throw new Error("SBCS codec is called without the data.") | ||
11 | + | ||
12 | + // Prepare char buffer for decoding. | ||
13 | + if (!codecOptions.chars || (codecOptions.chars.length !== 128 && codecOptions.chars.length !== 256)) | ||
14 | + throw new Error("Encoding '"+codecOptions.type+"' has incorrect 'chars' (must be of len 128 or 256)"); | ||
15 | + | ||
16 | + if (codecOptions.chars.length === 128) { | ||
17 | + var asciiString = ""; | ||
18 | + for (var i = 0; i < 128; i++) | ||
19 | + asciiString += String.fromCharCode(i); | ||
20 | + codecOptions.chars = asciiString + codecOptions.chars; | ||
21 | + } | ||
22 | + | ||
23 | + this.decodeBuf = new Buffer.from(codecOptions.chars, 'ucs2'); | ||
24 | + | ||
25 | + // Encoding buffer. | ||
26 | + var encodeBuf = new Buffer.alloc(65536, iconv.defaultCharSingleByte.charCodeAt(0)); | ||
27 | + | ||
28 | + for (var i = 0; i < codecOptions.chars.length; i++) | ||
29 | + encodeBuf[codecOptions.chars.charCodeAt(i)] = i; | ||
30 | + | ||
31 | + this.encodeBuf = encodeBuf; | ||
32 | +} | ||
33 | + | ||
34 | +SBCSCodec.prototype.encoder = SBCSEncoder; | ||
35 | +SBCSCodec.prototype.decoder = SBCSDecoder; | ||
36 | + | ||
37 | + | ||
38 | +function SBCSEncoder(options, codec) { | ||
39 | + this.encodeBuf = codec.encodeBuf; | ||
40 | +} | ||
41 | + | ||
42 | +SBCSEncoder.prototype.write = function(str) { | ||
43 | + var buf = Buffer.alloc(str.length); | ||
44 | + for (var i = 0; i < str.length; i++) | ||
45 | + buf[i] = this.encodeBuf[str.charCodeAt(i)]; | ||
46 | + | ||
47 | + return buf; | ||
48 | +} | ||
49 | + | ||
50 | +SBCSEncoder.prototype.end = function() { | ||
51 | +} | ||
52 | + | ||
53 | + | ||
54 | +function SBCSDecoder(options, codec) { | ||
55 | + this.decodeBuf = codec.decodeBuf; | ||
56 | +} | ||
57 | + | ||
58 | +SBCSDecoder.prototype.write = function(buf) { | ||
59 | + // Strings are immutable in JS -> we use ucs2 buffer to speed up computations. | ||
60 | + var decodeBuf = this.decodeBuf; | ||
61 | + var newBuf = Buffer.alloc(buf.length*2); | ||
62 | + var idx1 = 0, idx2 = 0; | ||
63 | + for (var i = 0; i < buf.length; i++) { | ||
64 | + idx1 = buf[i]*2; idx2 = i*2; | ||
65 | + newBuf[idx2] = decodeBuf[idx1]; | ||
66 | + newBuf[idx2+1] = decodeBuf[idx1+1]; | ||
67 | + } | ||
68 | + return newBuf.toString('ucs2'); | ||
69 | +} | ||
70 | + | ||
71 | +SBCSDecoder.prototype.end = function() { | ||
72 | +} |
This diff is collapsed. Click to expand it.
1 | +"use strict"; | ||
2 | + | ||
3 | +// Manually added data to be used by sbcs codec in addition to generated one. | ||
4 | + | ||
5 | +module.exports = { | ||
6 | + // Not supported by iconv, not sure why. | ||
7 | + "10029": "maccenteuro", | ||
8 | + "maccenteuro": { | ||
9 | + "type": "_sbcs", | ||
10 | + "chars": "ÄĀāÉĄÖÜáąČäčĆć鏟ĎíďĒēĖóėôöõúĚěü†°Ę£§•¶ß®©™ę¨≠ģĮįĪ≤≥īĶ∂∑łĻļĽľĹĺŅņѬ√ńŇ∆«»… ňŐÕőŌ–—“”‘’÷◊ōŔŕŘ‹›řŖŗŠ‚„šŚśÁŤťÍŽžŪÓÔūŮÚůŰűŲųÝýķŻŁżĢˇ" | ||
11 | + }, | ||
12 | + | ||
13 | + "808": "cp808", | ||
14 | + "ibm808": "cp808", | ||
15 | + "cp808": { | ||
16 | + "type": "_sbcs", | ||
17 | + "chars": "АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмноп░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀рстуфхцчшщъыьэюяЁёЄєЇїЎў°∙·√№€■ " | ||
18 | + }, | ||
19 | + | ||
20 | + // Aliases of generated encodings. | ||
21 | + "ascii8bit": "ascii", | ||
22 | + "usascii": "ascii", | ||
23 | + "ansix34": "ascii", | ||
24 | + "ansix341968": "ascii", | ||
25 | + "ansix341986": "ascii", | ||
26 | + "csascii": "ascii", | ||
27 | + "cp367": "ascii", | ||
28 | + "ibm367": "ascii", | ||
29 | + "isoir6": "ascii", | ||
30 | + "iso646us": "ascii", | ||
31 | + "iso646irv": "ascii", | ||
32 | + "us": "ascii", | ||
33 | + | ||
34 | + "latin1": "iso88591", | ||
35 | + "latin2": "iso88592", | ||
36 | + "latin3": "iso88593", | ||
37 | + "latin4": "iso88594", | ||
38 | + "latin5": "iso88599", | ||
39 | + "latin6": "iso885910", | ||
40 | + "latin7": "iso885913", | ||
41 | + "latin8": "iso885914", | ||
42 | + "latin9": "iso885915", | ||
43 | + "latin10": "iso885916", | ||
44 | + | ||
45 | + "csisolatin1": "iso88591", | ||
46 | + "csisolatin2": "iso88592", | ||
47 | + "csisolatin3": "iso88593", | ||
48 | + "csisolatin4": "iso88594", | ||
49 | + "csisolatincyrillic": "iso88595", | ||
50 | + "csisolatinarabic": "iso88596", | ||
51 | + "csisolatingreek" : "iso88597", | ||
52 | + "csisolatinhebrew": "iso88598", | ||
53 | + "csisolatin5": "iso88599", | ||
54 | + "csisolatin6": "iso885910", | ||
55 | + | ||
56 | + "l1": "iso88591", | ||
57 | + "l2": "iso88592", | ||
58 | + "l3": "iso88593", | ||
59 | + "l4": "iso88594", | ||
60 | + "l5": "iso88599", | ||
61 | + "l6": "iso885910", | ||
62 | + "l7": "iso885913", | ||
63 | + "l8": "iso885914", | ||
64 | + "l9": "iso885915", | ||
65 | + "l10": "iso885916", | ||
66 | + | ||
67 | + "isoir14": "iso646jp", | ||
68 | + "isoir57": "iso646cn", | ||
69 | + "isoir100": "iso88591", | ||
70 | + "isoir101": "iso88592", | ||
71 | + "isoir109": "iso88593", | ||
72 | + "isoir110": "iso88594", | ||
73 | + "isoir144": "iso88595", | ||
74 | + "isoir127": "iso88596", | ||
75 | + "isoir126": "iso88597", | ||
76 | + "isoir138": "iso88598", | ||
77 | + "isoir148": "iso88599", | ||
78 | + "isoir157": "iso885910", | ||
79 | + "isoir166": "tis620", | ||
80 | + "isoir179": "iso885913", | ||
81 | + "isoir199": "iso885914", | ||
82 | + "isoir203": "iso885915", | ||
83 | + "isoir226": "iso885916", | ||
84 | + | ||
85 | + "cp819": "iso88591", | ||
86 | + "ibm819": "iso88591", | ||
87 | + | ||
88 | + "cyrillic": "iso88595", | ||
89 | + | ||
90 | + "arabic": "iso88596", | ||
91 | + "arabic8": "iso88596", | ||
92 | + "ecma114": "iso88596", | ||
93 | + "asmo708": "iso88596", | ||
94 | + | ||
95 | + "greek" : "iso88597", | ||
96 | + "greek8" : "iso88597", | ||
97 | + "ecma118" : "iso88597", | ||
98 | + "elot928" : "iso88597", | ||
99 | + | ||
100 | + "hebrew": "iso88598", | ||
101 | + "hebrew8": "iso88598", | ||
102 | + | ||
103 | + "turkish": "iso88599", | ||
104 | + "turkish8": "iso88599", | ||
105 | + | ||
106 | + "thai": "iso885911", | ||
107 | + "thai8": "iso885911", | ||
108 | + | ||
109 | + "celtic": "iso885914", | ||
110 | + "celtic8": "iso885914", | ||
111 | + "isoceltic": "iso885914", | ||
112 | + | ||
113 | + "tis6200": "tis620", | ||
114 | + "tis62025291": "tis620", | ||
115 | + "tis62025330": "tis620", | ||
116 | + | ||
117 | + "10000": "macroman", | ||
118 | + "10006": "macgreek", | ||
119 | + "10007": "maccyrillic", | ||
120 | + "10079": "maciceland", | ||
121 | + "10081": "macturkish", | ||
122 | + | ||
123 | + "cspc8codepage437": "cp437", | ||
124 | + "cspc775baltic": "cp775", | ||
125 | + "cspc850multilingual": "cp850", | ||
126 | + "cspcp852": "cp852", | ||
127 | + "cspc862latinhebrew": "cp862", | ||
128 | + "cpgr": "cp869", | ||
129 | + | ||
130 | + "msee": "cp1250", | ||
131 | + "mscyrl": "cp1251", | ||
132 | + "msansi": "cp1252", | ||
133 | + "msgreek": "cp1253", | ||
134 | + "msturk": "cp1254", | ||
135 | + "mshebr": "cp1255", | ||
136 | + "msarab": "cp1256", | ||
137 | + "winbaltrim": "cp1257", | ||
138 | + | ||
139 | + "cp20866": "koi8r", | ||
140 | + "20866": "koi8r", | ||
141 | + "ibm878": "koi8r", | ||
142 | + "cskoi8r": "koi8r", | ||
143 | + | ||
144 | + "cp21866": "koi8u", | ||
145 | + "21866": "koi8u", | ||
146 | + "ibm1168": "koi8u", | ||
147 | + | ||
148 | + "strk10482002": "rk1048", | ||
149 | + | ||
150 | + "tcvn5712": "tcvn", | ||
151 | + "tcvn57121": "tcvn", | ||
152 | + | ||
153 | + "gb198880": "iso646cn", | ||
154 | + "cn": "iso646cn", | ||
155 | + | ||
156 | + "csiso14jisc6220ro": "iso646jp", | ||
157 | + "jisc62201969ro": "iso646jp", | ||
158 | + "jp": "iso646jp", | ||
159 | + | ||
160 | + "cshproman8": "hproman8", | ||
161 | + "r8": "hproman8", | ||
162 | + "roman8": "hproman8", | ||
163 | + "xroman8": "hproman8", | ||
164 | + "ibm1051": "hproman8", | ||
165 | + | ||
166 | + "mac": "macintosh", | ||
167 | + "csmacintosh": "macintosh", | ||
168 | +}; | ||
169 | + |
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
1 | +{"uChars":[128,165,169,178,184,216,226,235,238,244,248,251,253,258,276,284,300,325,329,334,364,463,465,467,469,471,473,475,477,506,594,610,712,716,730,930,938,962,970,1026,1104,1106,8209,8215,8218,8222,8231,8241,8244,8246,8252,8365,8452,8454,8458,8471,8482,8556,8570,8596,8602,8713,8720,8722,8726,8731,8737,8740,8742,8748,8751,8760,8766,8777,8781,8787,8802,8808,8816,8854,8858,8870,8896,8979,9322,9372,9548,9588,9616,9622,9634,9652,9662,9672,9676,9680,9702,9735,9738,9793,9795,11906,11909,11913,11917,11928,11944,11947,11951,11956,11960,11964,11979,12284,12292,12312,12319,12330,12351,12436,12447,12535,12543,12586,12842,12850,12964,13200,13215,13218,13253,13263,13267,13270,13384,13428,13727,13839,13851,14617,14703,14801,14816,14964,15183,15471,15585,16471,16736,17208,17325,17330,17374,17623,17997,18018,18212,18218,18301,18318,18760,18811,18814,18820,18823,18844,18848,18872,19576,19620,19738,19887,40870,59244,59336,59367,59413,59417,59423,59431,59437,59443,59452,59460,59478,59493,63789,63866,63894,63976,63986,64016,64018,64021,64025,64034,64037,64042,65074,65093,65107,65112,65127,65132,65375,65510,65536],"gbChars":[0,36,38,45,50,81,89,95,96,100,103,104,105,109,126,133,148,172,175,179,208,306,307,308,309,310,311,312,313,341,428,443,544,545,558,741,742,749,750,805,819,820,7922,7924,7925,7927,7934,7943,7944,7945,7950,8062,8148,8149,8152,8164,8174,8236,8240,8262,8264,8374,8380,8381,8384,8388,8390,8392,8393,8394,8396,8401,8406,8416,8419,8424,8437,8439,8445,8482,8485,8496,8521,8603,8936,8946,9046,9050,9063,9066,9076,9092,9100,9108,9111,9113,9131,9162,9164,9218,9219,11329,11331,11334,11336,11346,11361,11363,11366,11370,11372,11375,11389,11682,11686,11687,11692,11694,11714,11716,11723,11725,11730,11736,11982,11989,12102,12336,12348,12350,12384,12393,12395,12397,12510,12553,12851,12962,12973,13738,13823,13919,13933,14080,14298,14585,14698,15583,15847,16318,16434,16438,16481,16729,17102,17122,17315,17320,17402,17418,17859,17909,17911,17915,17916,17936,17939,17961,18664,18703,18814,18962,19043,33469,33470,33471,33484,33485,33490,33497,33501,33505,33513,33520,33536,33550,37845,37921,37948,38029,38038,38064,38065,38066,38069,38075,38076,38078,39108,39109,39113,39114,39115,39116,39265,39394,189000]} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | +[ | ||
2 | +["a140","",62], | ||
3 | +["a180","",32], | ||
4 | +["a240","",62], | ||
5 | +["a280","",32], | ||
6 | +["a2ab","",5], | ||
7 | +["a2e3","€"], | ||
8 | +["a2ef",""], | ||
9 | +["a2fd",""], | ||
10 | +["a340","",62], | ||
11 | +["a380","",31," "], | ||
12 | +["a440","",62], | ||
13 | +["a480","",32], | ||
14 | +["a4f4","",10], | ||
15 | +["a540","",62], | ||
16 | +["a580","",32], | ||
17 | +["a5f7","",7], | ||
18 | +["a640","",62], | ||
19 | +["a680","",32], | ||
20 | +["a6b9","",7], | ||
21 | +["a6d9","",6], | ||
22 | +["a6ec",""], | ||
23 | +["a6f3",""], | ||
24 | +["a6f6","",8], | ||
25 | +["a740","",62], | ||
26 | +["a780","",32], | ||
27 | +["a7c2","",14], | ||
28 | +["a7f2","",12], | ||
29 | +["a896","",10], | ||
30 | +["a8bc",""], | ||
31 | +["a8bf","ǹ"], | ||
32 | +["a8c1",""], | ||
33 | +["a8ea","",20], | ||
34 | +["a958",""], | ||
35 | +["a95b",""], | ||
36 | +["a95d",""], | ||
37 | +["a989","〾⿰",11], | ||
38 | +["a997","",12], | ||
39 | +["a9f0","",14], | ||
40 | +["aaa1","",93], | ||
41 | +["aba1","",93], | ||
42 | +["aca1","",93], | ||
43 | +["ada1","",93], | ||
44 | +["aea1","",93], | ||
45 | +["afa1","",93], | ||
46 | +["d7fa","",4], | ||
47 | +["f8a1","",93], | ||
48 | +["f9a1","",93], | ||
49 | +["faa1","",93], | ||
50 | +["fba1","",93], | ||
51 | +["fca1","",93], | ||
52 | +["fda1","",93], | ||
53 | +["fe50","⺁⺄㑳㑇⺈⺋㖞㘚㘎⺌⺗㥮㤘㧏㧟㩳㧐㭎㱮㳠⺧⺪䁖䅟⺮䌷⺳⺶⺷䎱䎬⺻䏝䓖䙡䙌"], | ||
54 | +["fe80","䜣䜩䝼䞍⻊䥇䥺䥽䦂䦃䦅䦆䦟䦛䦷䦶䲣䲟䲠䲡䱷䲢䴓",6,"䶮",93] | ||
55 | +] |
This diff is collapsed. Click to expand it.
1 | +"use strict"; | ||
2 | +var Buffer = require("safer-buffer").Buffer; | ||
3 | + | ||
4 | +// Note: UTF16-LE (or UCS2) codec is Node.js native. See encodings/internal.js | ||
5 | + | ||
6 | +// == UTF16-BE codec. ========================================================== | ||
7 | + | ||
8 | +exports.utf16be = Utf16BECodec; | ||
9 | +function Utf16BECodec() { | ||
10 | +} | ||
11 | + | ||
12 | +Utf16BECodec.prototype.encoder = Utf16BEEncoder; | ||
13 | +Utf16BECodec.prototype.decoder = Utf16BEDecoder; | ||
14 | +Utf16BECodec.prototype.bomAware = true; | ||
15 | + | ||
16 | + | ||
17 | +// -- Encoding | ||
18 | + | ||
19 | +function Utf16BEEncoder() { | ||
20 | +} | ||
21 | + | ||
22 | +Utf16BEEncoder.prototype.write = function(str) { | ||
23 | + var buf = Buffer.from(str, 'ucs2'); | ||
24 | + for (var i = 0; i < buf.length; i += 2) { | ||
25 | + var tmp = buf[i]; buf[i] = buf[i+1]; buf[i+1] = tmp; | ||
26 | + } | ||
27 | + return buf; | ||
28 | +} | ||
29 | + | ||
30 | +Utf16BEEncoder.prototype.end = function() { | ||
31 | +} | ||
32 | + | ||
33 | + | ||
34 | +// -- Decoding | ||
35 | + | ||
36 | +function Utf16BEDecoder() { | ||
37 | + this.overflowByte = -1; | ||
38 | +} | ||
39 | + | ||
40 | +Utf16BEDecoder.prototype.write = function(buf) { | ||
41 | + if (buf.length == 0) | ||
42 | + return ''; | ||
43 | + | ||
44 | + var buf2 = Buffer.alloc(buf.length + 1), | ||
45 | + i = 0, j = 0; | ||
46 | + | ||
47 | + if (this.overflowByte !== -1) { | ||
48 | + buf2[0] = buf[0]; | ||
49 | + buf2[1] = this.overflowByte; | ||
50 | + i = 1; j = 2; | ||
51 | + } | ||
52 | + | ||
53 | + for (; i < buf.length-1; i += 2, j+= 2) { | ||
54 | + buf2[j] = buf[i+1]; | ||
55 | + buf2[j+1] = buf[i]; | ||
56 | + } | ||
57 | + | ||
58 | + this.overflowByte = (i == buf.length-1) ? buf[buf.length-1] : -1; | ||
59 | + | ||
60 | + return buf2.slice(0, j).toString('ucs2'); | ||
61 | +} | ||
62 | + | ||
63 | +Utf16BEDecoder.prototype.end = function() { | ||
64 | +} | ||
65 | + | ||
66 | + | ||
67 | +// == UTF-16 codec ============================================================= | ||
68 | +// Decoder chooses automatically from UTF-16LE and UTF-16BE using BOM and space-based heuristic. | ||
69 | +// Defaults to UTF-16LE, as it's prevalent and default in Node. | ||
70 | +// http://en.wikipedia.org/wiki/UTF-16 and http://encoding.spec.whatwg.org/#utf-16le | ||
71 | +// Decoder default can be changed: iconv.decode(buf, 'utf16', {defaultEncoding: 'utf-16be'}); | ||
72 | + | ||
73 | +// Encoder uses UTF-16LE and prepends BOM (which can be overridden with addBOM: false). | ||
74 | + | ||
75 | +exports.utf16 = Utf16Codec; | ||
76 | +function Utf16Codec(codecOptions, iconv) { | ||
77 | + this.iconv = iconv; | ||
78 | +} | ||
79 | + | ||
80 | +Utf16Codec.prototype.encoder = Utf16Encoder; | ||
81 | +Utf16Codec.prototype.decoder = Utf16Decoder; | ||
82 | + | ||
83 | + | ||
84 | +// -- Encoding (pass-through) | ||
85 | + | ||
86 | +function Utf16Encoder(options, codec) { | ||
87 | + options = options || {}; | ||
88 | + if (options.addBOM === undefined) | ||
89 | + options.addBOM = true; | ||
90 | + this.encoder = codec.iconv.getEncoder('utf-16le', options); | ||
91 | +} | ||
92 | + | ||
93 | +Utf16Encoder.prototype.write = function(str) { | ||
94 | + return this.encoder.write(str); | ||
95 | +} | ||
96 | + | ||
97 | +Utf16Encoder.prototype.end = function() { | ||
98 | + return this.encoder.end(); | ||
99 | +} | ||
100 | + | ||
101 | + | ||
102 | +// -- Decoding | ||
103 | + | ||
104 | +function Utf16Decoder(options, codec) { | ||
105 | + this.decoder = null; | ||
106 | + this.initialBytes = []; | ||
107 | + this.initialBytesLen = 0; | ||
108 | + | ||
109 | + this.options = options || {}; | ||
110 | + this.iconv = codec.iconv; | ||
111 | +} | ||
112 | + | ||
113 | +Utf16Decoder.prototype.write = function(buf) { | ||
114 | + if (!this.decoder) { | ||
115 | + // Codec is not chosen yet. Accumulate initial bytes. | ||
116 | + this.initialBytes.push(buf); | ||
117 | + this.initialBytesLen += buf.length; | ||
118 | + | ||
119 | + if (this.initialBytesLen < 16) // We need more bytes to use space heuristic (see below) | ||
120 | + return ''; | ||
121 | + | ||
122 | + // We have enough bytes -> detect endianness. | ||
123 | + var buf = Buffer.concat(this.initialBytes), | ||
124 | + encoding = detectEncoding(buf, this.options.defaultEncoding); | ||
125 | + this.decoder = this.iconv.getDecoder(encoding, this.options); | ||
126 | + this.initialBytes.length = this.initialBytesLen = 0; | ||
127 | + } | ||
128 | + | ||
129 | + return this.decoder.write(buf); | ||
130 | +} | ||
131 | + | ||
132 | +Utf16Decoder.prototype.end = function() { | ||
133 | + if (!this.decoder) { | ||
134 | + var buf = Buffer.concat(this.initialBytes), | ||
135 | + encoding = detectEncoding(buf, this.options.defaultEncoding); | ||
136 | + this.decoder = this.iconv.getDecoder(encoding, this.options); | ||
137 | + | ||
138 | + var res = this.decoder.write(buf), | ||
139 | + trail = this.decoder.end(); | ||
140 | + | ||
141 | + return trail ? (res + trail) : res; | ||
142 | + } | ||
143 | + return this.decoder.end(); | ||
144 | +} | ||
145 | + | ||
146 | +function detectEncoding(buf, defaultEncoding) { | ||
147 | + var enc = defaultEncoding || 'utf-16le'; | ||
148 | + | ||
149 | + if (buf.length >= 2) { | ||
150 | + // Check BOM. | ||
151 | + if (buf[0] == 0xFE && buf[1] == 0xFF) // UTF-16BE BOM | ||
152 | + enc = 'utf-16be'; | ||
153 | + else if (buf[0] == 0xFF && buf[1] == 0xFE) // UTF-16LE BOM | ||
154 | + enc = 'utf-16le'; | ||
155 | + else { | ||
156 | + // No BOM found. Try to deduce encoding from initial content. | ||
157 | + // Most of the time, the content has ASCII chars (U+00**), but the opposite (U+**00) is uncommon. | ||
158 | + // So, we count ASCII as if it was LE or BE, and decide from that. | ||
159 | + var asciiCharsLE = 0, asciiCharsBE = 0, // Counts of chars in both positions | ||
160 | + _len = Math.min(buf.length - (buf.length % 2), 64); // Len is always even. | ||
161 | + | ||
162 | + for (var i = 0; i < _len; i += 2) { | ||
163 | + if (buf[i] === 0 && buf[i+1] !== 0) asciiCharsBE++; | ||
164 | + if (buf[i] !== 0 && buf[i+1] === 0) asciiCharsLE++; | ||
165 | + } | ||
166 | + | ||
167 | + if (asciiCharsBE > asciiCharsLE) | ||
168 | + enc = 'utf-16be'; | ||
169 | + else if (asciiCharsBE < asciiCharsLE) | ||
170 | + enc = 'utf-16le'; | ||
171 | + } | ||
172 | + } | ||
173 | + | ||
174 | + return enc; | ||
175 | +} | ||
176 | + | ||
177 | + |
1 | +"use strict"; | ||
2 | +var Buffer = require("safer-buffer").Buffer; | ||
3 | + | ||
4 | +// UTF-7 codec, according to https://tools.ietf.org/html/rfc2152 | ||
5 | +// See also below a UTF-7-IMAP codec, according to http://tools.ietf.org/html/rfc3501#section-5.1.3 | ||
6 | + | ||
7 | +exports.utf7 = Utf7Codec; | ||
8 | +exports.unicode11utf7 = 'utf7'; // Alias UNICODE-1-1-UTF-7 | ||
9 | +function Utf7Codec(codecOptions, iconv) { | ||
10 | + this.iconv = iconv; | ||
11 | +}; | ||
12 | + | ||
13 | +Utf7Codec.prototype.encoder = Utf7Encoder; | ||
14 | +Utf7Codec.prototype.decoder = Utf7Decoder; | ||
15 | +Utf7Codec.prototype.bomAware = true; | ||
16 | + | ||
17 | + | ||
18 | +// -- Encoding | ||
19 | + | ||
20 | +var nonDirectChars = /[^A-Za-z0-9'\(\),-\.\/:\? \n\r\t]+/g; | ||
21 | + | ||
22 | +function Utf7Encoder(options, codec) { | ||
23 | + this.iconv = codec.iconv; | ||
24 | +} | ||
25 | + | ||
26 | +Utf7Encoder.prototype.write = function(str) { | ||
27 | + // Naive implementation. | ||
28 | + // Non-direct chars are encoded as "+<base64>-"; single "+" char is encoded as "+-". | ||
29 | + return Buffer.from(str.replace(nonDirectChars, function(chunk) { | ||
30 | + return "+" + (chunk === '+' ? '' : | ||
31 | + this.iconv.encode(chunk, 'utf16-be').toString('base64').replace(/=+$/, '')) | ||
32 | + + "-"; | ||
33 | + }.bind(this))); | ||
34 | +} | ||
35 | + | ||
36 | +Utf7Encoder.prototype.end = function() { | ||
37 | +} | ||
38 | + | ||
39 | + | ||
40 | +// -- Decoding | ||
41 | + | ||
42 | +function Utf7Decoder(options, codec) { | ||
43 | + this.iconv = codec.iconv; | ||
44 | + this.inBase64 = false; | ||
45 | + this.base64Accum = ''; | ||
46 | +} | ||
47 | + | ||
48 | +var base64Regex = /[A-Za-z0-9\/+]/; | ||
49 | +var base64Chars = []; | ||
50 | +for (var i = 0; i < 256; i++) | ||
51 | + base64Chars[i] = base64Regex.test(String.fromCharCode(i)); | ||
52 | + | ||
53 | +var plusChar = '+'.charCodeAt(0), | ||
54 | + minusChar = '-'.charCodeAt(0), | ||
55 | + andChar = '&'.charCodeAt(0); | ||
56 | + | ||
57 | +Utf7Decoder.prototype.write = function(buf) { | ||
58 | + var res = "", lastI = 0, | ||
59 | + inBase64 = this.inBase64, | ||
60 | + base64Accum = this.base64Accum; | ||
61 | + | ||
62 | + // The decoder is more involved as we must handle chunks in stream. | ||
63 | + | ||
64 | + for (var i = 0; i < buf.length; i++) { | ||
65 | + if (!inBase64) { // We're in direct mode. | ||
66 | + // Write direct chars until '+' | ||
67 | + if (buf[i] == plusChar) { | ||
68 | + res += this.iconv.decode(buf.slice(lastI, i), "ascii"); // Write direct chars. | ||
69 | + lastI = i+1; | ||
70 | + inBase64 = true; | ||
71 | + } | ||
72 | + } else { // We decode base64. | ||
73 | + if (!base64Chars[buf[i]]) { // Base64 ended. | ||
74 | + if (i == lastI && buf[i] == minusChar) {// "+-" -> "+" | ||
75 | + res += "+"; | ||
76 | + } else { | ||
77 | + var b64str = base64Accum + buf.slice(lastI, i).toString(); | ||
78 | + res += this.iconv.decode(Buffer.from(b64str, 'base64'), "utf16-be"); | ||
79 | + } | ||
80 | + | ||
81 | + if (buf[i] != minusChar) // Minus is absorbed after base64. | ||
82 | + i--; | ||
83 | + | ||
84 | + lastI = i+1; | ||
85 | + inBase64 = false; | ||
86 | + base64Accum = ''; | ||
87 | + } | ||
88 | + } | ||
89 | + } | ||
90 | + | ||
91 | + if (!inBase64) { | ||
92 | + res += this.iconv.decode(buf.slice(lastI), "ascii"); // Write direct chars. | ||
93 | + } else { | ||
94 | + var b64str = base64Accum + buf.slice(lastI).toString(); | ||
95 | + | ||
96 | + var canBeDecoded = b64str.length - (b64str.length % 8); // Minimal chunk: 2 quads -> 2x3 bytes -> 3 chars. | ||
97 | + base64Accum = b64str.slice(canBeDecoded); // The rest will be decoded in future. | ||
98 | + b64str = b64str.slice(0, canBeDecoded); | ||
99 | + | ||
100 | + res += this.iconv.decode(Buffer.from(b64str, 'base64'), "utf16-be"); | ||
101 | + } | ||
102 | + | ||
103 | + this.inBase64 = inBase64; | ||
104 | + this.base64Accum = base64Accum; | ||
105 | + | ||
106 | + return res; | ||
107 | +} | ||
108 | + | ||
109 | +Utf7Decoder.prototype.end = function() { | ||
110 | + var res = ""; | ||
111 | + if (this.inBase64 && this.base64Accum.length > 0) | ||
112 | + res = this.iconv.decode(Buffer.from(this.base64Accum, 'base64'), "utf16-be"); | ||
113 | + | ||
114 | + this.inBase64 = false; | ||
115 | + this.base64Accum = ''; | ||
116 | + return res; | ||
117 | +} | ||
118 | + | ||
119 | + | ||
120 | +// UTF-7-IMAP codec. | ||
121 | +// RFC3501 Sec. 5.1.3 Modified UTF-7 (http://tools.ietf.org/html/rfc3501#section-5.1.3) | ||
122 | +// Differences: | ||
123 | +// * Base64 part is started by "&" instead of "+" | ||
124 | +// * Direct characters are 0x20-0x7E, except "&" (0x26) | ||
125 | +// * In Base64, "," is used instead of "/" | ||
126 | +// * Base64 must not be used to represent direct characters. | ||
127 | +// * No implicit shift back from Base64 (should always end with '-') | ||
128 | +// * String must end in non-shifted position. | ||
129 | +// * "-&" while in base64 is not allowed. | ||
130 | + | ||
131 | + | ||
132 | +exports.utf7imap = Utf7IMAPCodec; | ||
133 | +function Utf7IMAPCodec(codecOptions, iconv) { | ||
134 | + this.iconv = iconv; | ||
135 | +}; | ||
136 | + | ||
137 | +Utf7IMAPCodec.prototype.encoder = Utf7IMAPEncoder; | ||
138 | +Utf7IMAPCodec.prototype.decoder = Utf7IMAPDecoder; | ||
139 | +Utf7IMAPCodec.prototype.bomAware = true; | ||
140 | + | ||
141 | + | ||
142 | +// -- Encoding | ||
143 | + | ||
144 | +function Utf7IMAPEncoder(options, codec) { | ||
145 | + this.iconv = codec.iconv; | ||
146 | + this.inBase64 = false; | ||
147 | + this.base64Accum = Buffer.alloc(6); | ||
148 | + this.base64AccumIdx = 0; | ||
149 | +} | ||
150 | + | ||
151 | +Utf7IMAPEncoder.prototype.write = function(str) { | ||
152 | + var inBase64 = this.inBase64, | ||
153 | + base64Accum = this.base64Accum, | ||
154 | + base64AccumIdx = this.base64AccumIdx, | ||
155 | + buf = Buffer.alloc(str.length*5 + 10), bufIdx = 0; | ||
156 | + | ||
157 | + for (var i = 0; i < str.length; i++) { | ||
158 | + var uChar = str.charCodeAt(i); | ||
159 | + if (0x20 <= uChar && uChar <= 0x7E) { // Direct character or '&'. | ||
160 | + if (inBase64) { | ||
161 | + if (base64AccumIdx > 0) { | ||
162 | + bufIdx += buf.write(base64Accum.slice(0, base64AccumIdx).toString('base64').replace(/\//g, ',').replace(/=+$/, ''), bufIdx); | ||
163 | + base64AccumIdx = 0; | ||
164 | + } | ||
165 | + | ||
166 | + buf[bufIdx++] = minusChar; // Write '-', then go to direct mode. | ||
167 | + inBase64 = false; | ||
168 | + } | ||
169 | + | ||
170 | + if (!inBase64) { | ||
171 | + buf[bufIdx++] = uChar; // Write direct character | ||
172 | + | ||
173 | + if (uChar === andChar) // Ampersand -> '&-' | ||
174 | + buf[bufIdx++] = minusChar; | ||
175 | + } | ||
176 | + | ||
177 | + } else { // Non-direct character | ||
178 | + if (!inBase64) { | ||
179 | + buf[bufIdx++] = andChar; // Write '&', then go to base64 mode. | ||
180 | + inBase64 = true; | ||
181 | + } | ||
182 | + if (inBase64) { | ||
183 | + base64Accum[base64AccumIdx++] = uChar >> 8; | ||
184 | + base64Accum[base64AccumIdx++] = uChar & 0xFF; | ||
185 | + | ||
186 | + if (base64AccumIdx == base64Accum.length) { | ||
187 | + bufIdx += buf.write(base64Accum.toString('base64').replace(/\//g, ','), bufIdx); | ||
188 | + base64AccumIdx = 0; | ||
189 | + } | ||
190 | + } | ||
191 | + } | ||
192 | + } | ||
193 | + | ||
194 | + this.inBase64 = inBase64; | ||
195 | + this.base64AccumIdx = base64AccumIdx; | ||
196 | + | ||
197 | + return buf.slice(0, bufIdx); | ||
198 | +} | ||
199 | + | ||
200 | +Utf7IMAPEncoder.prototype.end = function() { | ||
201 | + var buf = Buffer.alloc(10), bufIdx = 0; | ||
202 | + if (this.inBase64) { | ||
203 | + if (this.base64AccumIdx > 0) { | ||
204 | + bufIdx += buf.write(this.base64Accum.slice(0, this.base64AccumIdx).toString('base64').replace(/\//g, ',').replace(/=+$/, ''), bufIdx); | ||
205 | + this.base64AccumIdx = 0; | ||
206 | + } | ||
207 | + | ||
208 | + buf[bufIdx++] = minusChar; // Write '-', then go to direct mode. | ||
209 | + this.inBase64 = false; | ||
210 | + } | ||
211 | + | ||
212 | + return buf.slice(0, bufIdx); | ||
213 | +} | ||
214 | + | ||
215 | + | ||
216 | +// -- Decoding | ||
217 | + | ||
218 | +function Utf7IMAPDecoder(options, codec) { | ||
219 | + this.iconv = codec.iconv; | ||
220 | + this.inBase64 = false; | ||
221 | + this.base64Accum = ''; | ||
222 | +} | ||
223 | + | ||
224 | +var base64IMAPChars = base64Chars.slice(); | ||
225 | +base64IMAPChars[','.charCodeAt(0)] = true; | ||
226 | + | ||
227 | +Utf7IMAPDecoder.prototype.write = function(buf) { | ||
228 | + var res = "", lastI = 0, | ||
229 | + inBase64 = this.inBase64, | ||
230 | + base64Accum = this.base64Accum; | ||
231 | + | ||
232 | + // The decoder is more involved as we must handle chunks in stream. | ||
233 | + // It is forgiving, closer to standard UTF-7 (for example, '-' is optional at the end). | ||
234 | + | ||
235 | + for (var i = 0; i < buf.length; i++) { | ||
236 | + if (!inBase64) { // We're in direct mode. | ||
237 | + // Write direct chars until '&' | ||
238 | + if (buf[i] == andChar) { | ||
239 | + res += this.iconv.decode(buf.slice(lastI, i), "ascii"); // Write direct chars. | ||
240 | + lastI = i+1; | ||
241 | + inBase64 = true; | ||
242 | + } | ||
243 | + } else { // We decode base64. | ||
244 | + if (!base64IMAPChars[buf[i]]) { // Base64 ended. | ||
245 | + if (i == lastI && buf[i] == minusChar) { // "&-" -> "&" | ||
246 | + res += "&"; | ||
247 | + } else { | ||
248 | + var b64str = base64Accum + buf.slice(lastI, i).toString().replace(/,/g, '/'); | ||
249 | + res += this.iconv.decode(Buffer.from(b64str, 'base64'), "utf16-be"); | ||
250 | + } | ||
251 | + | ||
252 | + if (buf[i] != minusChar) // Minus may be absorbed after base64. | ||
253 | + i--; | ||
254 | + | ||
255 | + lastI = i+1; | ||
256 | + inBase64 = false; | ||
257 | + base64Accum = ''; | ||
258 | + } | ||
259 | + } | ||
260 | + } | ||
261 | + | ||
262 | + if (!inBase64) { | ||
263 | + res += this.iconv.decode(buf.slice(lastI), "ascii"); // Write direct chars. | ||
264 | + } else { | ||
265 | + var b64str = base64Accum + buf.slice(lastI).toString().replace(/,/g, '/'); | ||
266 | + | ||
267 | + var canBeDecoded = b64str.length - (b64str.length % 8); // Minimal chunk: 2 quads -> 2x3 bytes -> 3 chars. | ||
268 | + base64Accum = b64str.slice(canBeDecoded); // The rest will be decoded in future. | ||
269 | + b64str = b64str.slice(0, canBeDecoded); | ||
270 | + | ||
271 | + res += this.iconv.decode(Buffer.from(b64str, 'base64'), "utf16-be"); | ||
272 | + } | ||
273 | + | ||
274 | + this.inBase64 = inBase64; | ||
275 | + this.base64Accum = base64Accum; | ||
276 | + | ||
277 | + return res; | ||
278 | +} | ||
279 | + | ||
280 | +Utf7IMAPDecoder.prototype.end = function() { | ||
281 | + var res = ""; | ||
282 | + if (this.inBase64 && this.base64Accum.length > 0) | ||
283 | + res = this.iconv.decode(Buffer.from(this.base64Accum, 'base64'), "utf16-be"); | ||
284 | + | ||
285 | + this.inBase64 = false; | ||
286 | + this.base64Accum = ''; | ||
287 | + return res; | ||
288 | +} | ||
289 | + | ||
290 | + |
1 | +"use strict"; | ||
2 | + | ||
3 | +var BOMChar = '\uFEFF'; | ||
4 | + | ||
5 | +exports.PrependBOM = PrependBOMWrapper | ||
6 | +function PrependBOMWrapper(encoder, options) { | ||
7 | + this.encoder = encoder; | ||
8 | + this.addBOM = true; | ||
9 | +} | ||
10 | + | ||
11 | +PrependBOMWrapper.prototype.write = function(str) { | ||
12 | + if (this.addBOM) { | ||
13 | + str = BOMChar + str; | ||
14 | + this.addBOM = false; | ||
15 | + } | ||
16 | + | ||
17 | + return this.encoder.write(str); | ||
18 | +} | ||
19 | + | ||
20 | +PrependBOMWrapper.prototype.end = function() { | ||
21 | + return this.encoder.end(); | ||
22 | +} | ||
23 | + | ||
24 | + | ||
25 | +//------------------------------------------------------------------------------ | ||
26 | + | ||
27 | +exports.StripBOM = StripBOMWrapper; | ||
28 | +function StripBOMWrapper(decoder, options) { | ||
29 | + this.decoder = decoder; | ||
30 | + this.pass = false; | ||
31 | + this.options = options || {}; | ||
32 | +} | ||
33 | + | ||
34 | +StripBOMWrapper.prototype.write = function(buf) { | ||
35 | + var res = this.decoder.write(buf); | ||
36 | + if (this.pass || !res) | ||
37 | + return res; | ||
38 | + | ||
39 | + if (res[0] === BOMChar) { | ||
40 | + res = res.slice(1); | ||
41 | + if (typeof this.options.stripBOM === 'function') | ||
42 | + this.options.stripBOM(); | ||
43 | + } | ||
44 | + | ||
45 | + this.pass = true; | ||
46 | + return res; | ||
47 | +} | ||
48 | + | ||
49 | +StripBOMWrapper.prototype.end = function() { | ||
50 | + return this.decoder.end(); | ||
51 | +} | ||
52 | + |
1 | +"use strict"; | ||
2 | +var Buffer = require("buffer").Buffer; | ||
3 | +// Note: not polyfilled with safer-buffer on a purpose, as overrides Buffer | ||
4 | + | ||
5 | +// == Extend Node primitives to use iconv-lite ================================= | ||
6 | + | ||
7 | +module.exports = function (iconv) { | ||
8 | + var original = undefined; // Place to keep original methods. | ||
9 | + | ||
10 | + // Node authors rewrote Buffer internals to make it compatible with | ||
11 | + // Uint8Array and we cannot patch key functions since then. | ||
12 | + // Note: this does use older Buffer API on a purpose | ||
13 | + iconv.supportsNodeEncodingsExtension = !(Buffer.from || new Buffer(0) instanceof Uint8Array); | ||
14 | + | ||
15 | + iconv.extendNodeEncodings = function extendNodeEncodings() { | ||
16 | + if (original) return; | ||
17 | + original = {}; | ||
18 | + | ||
19 | + if (!iconv.supportsNodeEncodingsExtension) { | ||
20 | + console.error("ACTION NEEDED: require('iconv-lite').extendNodeEncodings() is not supported in your version of Node"); | ||
21 | + console.error("See more info at https://github.com/ashtuchkin/iconv-lite/wiki/Node-v4-compatibility"); | ||
22 | + return; | ||
23 | + } | ||
24 | + | ||
25 | + var nodeNativeEncodings = { | ||
26 | + 'hex': true, 'utf8': true, 'utf-8': true, 'ascii': true, 'binary': true, | ||
27 | + 'base64': true, 'ucs2': true, 'ucs-2': true, 'utf16le': true, 'utf-16le': true, | ||
28 | + }; | ||
29 | + | ||
30 | + Buffer.isNativeEncoding = function(enc) { | ||
31 | + return enc && nodeNativeEncodings[enc.toLowerCase()]; | ||
32 | + } | ||
33 | + | ||
34 | + // -- SlowBuffer ----------------------------------------------------------- | ||
35 | + var SlowBuffer = require('buffer').SlowBuffer; | ||
36 | + | ||
37 | + original.SlowBufferToString = SlowBuffer.prototype.toString; | ||
38 | + SlowBuffer.prototype.toString = function(encoding, start, end) { | ||
39 | + encoding = String(encoding || 'utf8').toLowerCase(); | ||
40 | + | ||
41 | + // Use native conversion when possible | ||
42 | + if (Buffer.isNativeEncoding(encoding)) | ||
43 | + return original.SlowBufferToString.call(this, encoding, start, end); | ||
44 | + | ||
45 | + // Otherwise, use our decoding method. | ||
46 | + if (typeof start == 'undefined') start = 0; | ||
47 | + if (typeof end == 'undefined') end = this.length; | ||
48 | + return iconv.decode(this.slice(start, end), encoding); | ||
49 | + } | ||
50 | + | ||
51 | + original.SlowBufferWrite = SlowBuffer.prototype.write; | ||
52 | + SlowBuffer.prototype.write = function(string, offset, length, encoding) { | ||
53 | + // Support both (string, offset, length, encoding) | ||
54 | + // and the legacy (string, encoding, offset, length) | ||
55 | + if (isFinite(offset)) { | ||
56 | + if (!isFinite(length)) { | ||
57 | + encoding = length; | ||
58 | + length = undefined; | ||
59 | + } | ||
60 | + } else { // legacy | ||
61 | + var swap = encoding; | ||
62 | + encoding = offset; | ||
63 | + offset = length; | ||
64 | + length = swap; | ||
65 | + } | ||
66 | + | ||
67 | + offset = +offset || 0; | ||
68 | + var remaining = this.length - offset; | ||
69 | + if (!length) { | ||
70 | + length = remaining; | ||
71 | + } else { | ||
72 | + length = +length; | ||
73 | + if (length > remaining) { | ||
74 | + length = remaining; | ||
75 | + } | ||
76 | + } | ||
77 | + encoding = String(encoding || 'utf8').toLowerCase(); | ||
78 | + | ||
79 | + // Use native conversion when possible | ||
80 | + if (Buffer.isNativeEncoding(encoding)) | ||
81 | + return original.SlowBufferWrite.call(this, string, offset, length, encoding); | ||
82 | + | ||
83 | + if (string.length > 0 && (length < 0 || offset < 0)) | ||
84 | + throw new RangeError('attempt to write beyond buffer bounds'); | ||
85 | + | ||
86 | + // Otherwise, use our encoding method. | ||
87 | + var buf = iconv.encode(string, encoding); | ||
88 | + if (buf.length < length) length = buf.length; | ||
89 | + buf.copy(this, offset, 0, length); | ||
90 | + return length; | ||
91 | + } | ||
92 | + | ||
93 | + // -- Buffer --------------------------------------------------------------- | ||
94 | + | ||
95 | + original.BufferIsEncoding = Buffer.isEncoding; | ||
96 | + Buffer.isEncoding = function(encoding) { | ||
97 | + return Buffer.isNativeEncoding(encoding) || iconv.encodingExists(encoding); | ||
98 | + } | ||
99 | + | ||
100 | + original.BufferByteLength = Buffer.byteLength; | ||
101 | + Buffer.byteLength = SlowBuffer.byteLength = function(str, encoding) { | ||
102 | + encoding = String(encoding || 'utf8').toLowerCase(); | ||
103 | + | ||
104 | + // Use native conversion when possible | ||
105 | + if (Buffer.isNativeEncoding(encoding)) | ||
106 | + return original.BufferByteLength.call(this, str, encoding); | ||
107 | + | ||
108 | + // Slow, I know, but we don't have a better way yet. | ||
109 | + return iconv.encode(str, encoding).length; | ||
110 | + } | ||
111 | + | ||
112 | + original.BufferToString = Buffer.prototype.toString; | ||
113 | + Buffer.prototype.toString = function(encoding, start, end) { | ||
114 | + encoding = String(encoding || 'utf8').toLowerCase(); | ||
115 | + | ||
116 | + // Use native conversion when possible | ||
117 | + if (Buffer.isNativeEncoding(encoding)) | ||
118 | + return original.BufferToString.call(this, encoding, start, end); | ||
119 | + | ||
120 | + // Otherwise, use our decoding method. | ||
121 | + if (typeof start == 'undefined') start = 0; | ||
122 | + if (typeof end == 'undefined') end = this.length; | ||
123 | + return iconv.decode(this.slice(start, end), encoding); | ||
124 | + } | ||
125 | + | ||
126 | + original.BufferWrite = Buffer.prototype.write; | ||
127 | + Buffer.prototype.write = function(string, offset, length, encoding) { | ||
128 | + var _offset = offset, _length = length, _encoding = encoding; | ||
129 | + // Support both (string, offset, length, encoding) | ||
130 | + // and the legacy (string, encoding, offset, length) | ||
131 | + if (isFinite(offset)) { | ||
132 | + if (!isFinite(length)) { | ||
133 | + encoding = length; | ||
134 | + length = undefined; | ||
135 | + } | ||
136 | + } else { // legacy | ||
137 | + var swap = encoding; | ||
138 | + encoding = offset; | ||
139 | + offset = length; | ||
140 | + length = swap; | ||
141 | + } | ||
142 | + | ||
143 | + encoding = String(encoding || 'utf8').toLowerCase(); | ||
144 | + | ||
145 | + // Use native conversion when possible | ||
146 | + if (Buffer.isNativeEncoding(encoding)) | ||
147 | + return original.BufferWrite.call(this, string, _offset, _length, _encoding); | ||
148 | + | ||
149 | + offset = +offset || 0; | ||
150 | + var remaining = this.length - offset; | ||
151 | + if (!length) { | ||
152 | + length = remaining; | ||
153 | + } else { | ||
154 | + length = +length; | ||
155 | + if (length > remaining) { | ||
156 | + length = remaining; | ||
157 | + } | ||
158 | + } | ||
159 | + | ||
160 | + if (string.length > 0 && (length < 0 || offset < 0)) | ||
161 | + throw new RangeError('attempt to write beyond buffer bounds'); | ||
162 | + | ||
163 | + // Otherwise, use our encoding method. | ||
164 | + var buf = iconv.encode(string, encoding); | ||
165 | + if (buf.length < length) length = buf.length; | ||
166 | + buf.copy(this, offset, 0, length); | ||
167 | + return length; | ||
168 | + | ||
169 | + // TODO: Set _charsWritten. | ||
170 | + } | ||
171 | + | ||
172 | + | ||
173 | + // -- Readable ------------------------------------------------------------- | ||
174 | + if (iconv.supportsStreams) { | ||
175 | + var Readable = require('stream').Readable; | ||
176 | + | ||
177 | + original.ReadableSetEncoding = Readable.prototype.setEncoding; | ||
178 | + Readable.prototype.setEncoding = function setEncoding(enc, options) { | ||
179 | + // Use our own decoder, it has the same interface. | ||
180 | + // We cannot use original function as it doesn't handle BOM-s. | ||
181 | + this._readableState.decoder = iconv.getDecoder(enc, options); | ||
182 | + this._readableState.encoding = enc; | ||
183 | + } | ||
184 | + | ||
185 | + Readable.prototype.collect = iconv._collect; | ||
186 | + } | ||
187 | + } | ||
188 | + | ||
189 | + // Remove iconv-lite Node primitive extensions. | ||
190 | + iconv.undoExtendNodeEncodings = function undoExtendNodeEncodings() { | ||
191 | + if (!iconv.supportsNodeEncodingsExtension) | ||
192 | + return; | ||
193 | + if (!original) | ||
194 | + throw new Error("require('iconv-lite').undoExtendNodeEncodings(): Nothing to undo; extendNodeEncodings() is not called.") | ||
195 | + | ||
196 | + delete Buffer.isNativeEncoding; | ||
197 | + | ||
198 | + var SlowBuffer = require('buffer').SlowBuffer; | ||
199 | + | ||
200 | + SlowBuffer.prototype.toString = original.SlowBufferToString; | ||
201 | + SlowBuffer.prototype.write = original.SlowBufferWrite; | ||
202 | + | ||
203 | + Buffer.isEncoding = original.BufferIsEncoding; | ||
204 | + Buffer.byteLength = original.BufferByteLength; | ||
205 | + Buffer.prototype.toString = original.BufferToString; | ||
206 | + Buffer.prototype.write = original.BufferWrite; | ||
207 | + | ||
208 | + if (iconv.supportsStreams) { | ||
209 | + var Readable = require('stream').Readable; | ||
210 | + | ||
211 | + Readable.prototype.setEncoding = original.ReadableSetEncoding; | ||
212 | + delete Readable.prototype.collect; | ||
213 | + } | ||
214 | + | ||
215 | + original = undefined; | ||
216 | + } | ||
217 | +} |
1 | +/*--------------------------------------------------------------------------------------------- | ||
2 | + * Copyright (c) Microsoft Corporation. All rights reserved. | ||
3 | + * Licensed under the MIT License. | ||
4 | + * REQUIREMENT: This definition is dependent on the @types/node definition. | ||
5 | + * Install with `npm install @types/node --save-dev` | ||
6 | + *--------------------------------------------------------------------------------------------*/ | ||
7 | + | ||
8 | +declare module 'iconv-lite' { | ||
9 | + export function decode(buffer: Buffer, encoding: string, options?: Options): string; | ||
10 | + | ||
11 | + export function encode(content: string, encoding: string, options?: Options): Buffer; | ||
12 | + | ||
13 | + export function encodingExists(encoding: string): boolean; | ||
14 | + | ||
15 | + export function decodeStream(encoding: string, options?: Options): NodeJS.ReadWriteStream; | ||
16 | + | ||
17 | + export function encodeStream(encoding: string, options?: Options): NodeJS.ReadWriteStream; | ||
18 | +} | ||
19 | + | ||
20 | +export interface Options { | ||
21 | + stripBOM?: boolean; | ||
22 | + addBOM?: boolean; | ||
23 | + defaultEncoding?: string; | ||
24 | +} |
1 | +"use strict"; | ||
2 | + | ||
3 | +// Some environments don't have global Buffer (e.g. React Native). | ||
4 | +// Solution would be installing npm modules "buffer" and "stream" explicitly. | ||
5 | +var Buffer = require("safer-buffer").Buffer; | ||
6 | + | ||
7 | +var bomHandling = require("./bom-handling"), | ||
8 | + iconv = module.exports; | ||
9 | + | ||
10 | +// All codecs and aliases are kept here, keyed by encoding name/alias. | ||
11 | +// They are lazy loaded in `iconv.getCodec` from `encodings/index.js`. | ||
12 | +iconv.encodings = null; | ||
13 | + | ||
14 | +// Characters emitted in case of error. | ||
15 | +iconv.defaultCharUnicode = '�'; | ||
16 | +iconv.defaultCharSingleByte = '?'; | ||
17 | + | ||
18 | +// Public API. | ||
19 | +iconv.encode = function encode(str, encoding, options) { | ||
20 | + str = "" + (str || ""); // Ensure string. | ||
21 | + | ||
22 | + var encoder = iconv.getEncoder(encoding, options); | ||
23 | + | ||
24 | + var res = encoder.write(str); | ||
25 | + var trail = encoder.end(); | ||
26 | + | ||
27 | + return (trail && trail.length > 0) ? Buffer.concat([res, trail]) : res; | ||
28 | +} | ||
29 | + | ||
30 | +iconv.decode = function decode(buf, encoding, options) { | ||
31 | + if (typeof buf === 'string') { | ||
32 | + if (!iconv.skipDecodeWarning) { | ||
33 | + console.error('Iconv-lite warning: decode()-ing strings is deprecated. Refer to https://github.com/ashtuchkin/iconv-lite/wiki/Use-Buffers-when-decoding'); | ||
34 | + iconv.skipDecodeWarning = true; | ||
35 | + } | ||
36 | + | ||
37 | + buf = Buffer.from("" + (buf || ""), "binary"); // Ensure buffer. | ||
38 | + } | ||
39 | + | ||
40 | + var decoder = iconv.getDecoder(encoding, options); | ||
41 | + | ||
42 | + var res = decoder.write(buf); | ||
43 | + var trail = decoder.end(); | ||
44 | + | ||
45 | + return trail ? (res + trail) : res; | ||
46 | +} | ||
47 | + | ||
48 | +iconv.encodingExists = function encodingExists(enc) { | ||
49 | + try { | ||
50 | + iconv.getCodec(enc); | ||
51 | + return true; | ||
52 | + } catch (e) { | ||
53 | + return false; | ||
54 | + } | ||
55 | +} | ||
56 | + | ||
57 | +// Legacy aliases to convert functions | ||
58 | +iconv.toEncoding = iconv.encode; | ||
59 | +iconv.fromEncoding = iconv.decode; | ||
60 | + | ||
61 | +// Search for a codec in iconv.encodings. Cache codec data in iconv._codecDataCache. | ||
62 | +iconv._codecDataCache = {}; | ||
63 | +iconv.getCodec = function getCodec(encoding) { | ||
64 | + if (!iconv.encodings) | ||
65 | + iconv.encodings = require("../encodings"); // Lazy load all encoding definitions. | ||
66 | + | ||
67 | + // Canonicalize encoding name: strip all non-alphanumeric chars and appended year. | ||
68 | + var enc = iconv._canonicalizeEncoding(encoding); | ||
69 | + | ||
70 | + // Traverse iconv.encodings to find actual codec. | ||
71 | + var codecOptions = {}; | ||
72 | + while (true) { | ||
73 | + var codec = iconv._codecDataCache[enc]; | ||
74 | + if (codec) | ||
75 | + return codec; | ||
76 | + | ||
77 | + var codecDef = iconv.encodings[enc]; | ||
78 | + | ||
79 | + switch (typeof codecDef) { | ||
80 | + case "string": // Direct alias to other encoding. | ||
81 | + enc = codecDef; | ||
82 | + break; | ||
83 | + | ||
84 | + case "object": // Alias with options. Can be layered. | ||
85 | + for (var key in codecDef) | ||
86 | + codecOptions[key] = codecDef[key]; | ||
87 | + | ||
88 | + if (!codecOptions.encodingName) | ||
89 | + codecOptions.encodingName = enc; | ||
90 | + | ||
91 | + enc = codecDef.type; | ||
92 | + break; | ||
93 | + | ||
94 | + case "function": // Codec itself. | ||
95 | + if (!codecOptions.encodingName) | ||
96 | + codecOptions.encodingName = enc; | ||
97 | + | ||
98 | + // The codec function must load all tables and return object with .encoder and .decoder methods. | ||
99 | + // It'll be called only once (for each different options object). | ||
100 | + codec = new codecDef(codecOptions, iconv); | ||
101 | + | ||
102 | + iconv._codecDataCache[codecOptions.encodingName] = codec; // Save it to be reused later. | ||
103 | + return codec; | ||
104 | + | ||
105 | + default: | ||
106 | + throw new Error("Encoding not recognized: '" + encoding + "' (searched as: '"+enc+"')"); | ||
107 | + } | ||
108 | + } | ||
109 | +} | ||
110 | + | ||
111 | +iconv._canonicalizeEncoding = function(encoding) { | ||
112 | + // Canonicalize encoding name: strip all non-alphanumeric chars and appended year. | ||
113 | + return (''+encoding).toLowerCase().replace(/:\d{4}$|[^0-9a-z]/g, ""); | ||
114 | +} | ||
115 | + | ||
116 | +iconv.getEncoder = function getEncoder(encoding, options) { | ||
117 | + var codec = iconv.getCodec(encoding), | ||
118 | + encoder = new codec.encoder(options, codec); | ||
119 | + | ||
120 | + if (codec.bomAware && options && options.addBOM) | ||
121 | + encoder = new bomHandling.PrependBOM(encoder, options); | ||
122 | + | ||
123 | + return encoder; | ||
124 | +} | ||
125 | + | ||
126 | +iconv.getDecoder = function getDecoder(encoding, options) { | ||
127 | + var codec = iconv.getCodec(encoding), | ||
128 | + decoder = new codec.decoder(options, codec); | ||
129 | + | ||
130 | + if (codec.bomAware && !(options && options.stripBOM === false)) | ||
131 | + decoder = new bomHandling.StripBOM(decoder, options); | ||
132 | + | ||
133 | + return decoder; | ||
134 | +} | ||
135 | + | ||
136 | + | ||
137 | +// Load extensions in Node. All of them are omitted in Browserify build via 'browser' field in package.json. | ||
138 | +var nodeVer = typeof process !== 'undefined' && process.versions && process.versions.node; | ||
139 | +if (nodeVer) { | ||
140 | + | ||
141 | + // Load streaming support in Node v0.10+ | ||
142 | + var nodeVerArr = nodeVer.split(".").map(Number); | ||
143 | + if (nodeVerArr[0] > 0 || nodeVerArr[1] >= 10) { | ||
144 | + require("./streams")(iconv); | ||
145 | + } | ||
146 | + | ||
147 | + // Load Node primitive extensions. | ||
148 | + require("./extend-node")(iconv); | ||
149 | +} | ||
150 | + | ||
151 | +if ("Ā" != "\u0100") { | ||
152 | + console.error("iconv-lite warning: javascript files use encoding different from utf-8. See https://github.com/ashtuchkin/iconv-lite/wiki/Javascript-source-file-encodings for more info."); | ||
153 | +} |
1 | +"use strict"; | ||
2 | + | ||
3 | +var Buffer = require("buffer").Buffer, | ||
4 | + Transform = require("stream").Transform; | ||
5 | + | ||
6 | + | ||
7 | +// == Exports ================================================================== | ||
8 | +module.exports = function(iconv) { | ||
9 | + | ||
10 | + // Additional Public API. | ||
11 | + iconv.encodeStream = function encodeStream(encoding, options) { | ||
12 | + return new IconvLiteEncoderStream(iconv.getEncoder(encoding, options), options); | ||
13 | + } | ||
14 | + | ||
15 | + iconv.decodeStream = function decodeStream(encoding, options) { | ||
16 | + return new IconvLiteDecoderStream(iconv.getDecoder(encoding, options), options); | ||
17 | + } | ||
18 | + | ||
19 | + iconv.supportsStreams = true; | ||
20 | + | ||
21 | + | ||
22 | + // Not published yet. | ||
23 | + iconv.IconvLiteEncoderStream = IconvLiteEncoderStream; | ||
24 | + iconv.IconvLiteDecoderStream = IconvLiteDecoderStream; | ||
25 | + iconv._collect = IconvLiteDecoderStream.prototype.collect; | ||
26 | +}; | ||
27 | + | ||
28 | + | ||
29 | +// == Encoder stream ======================================================= | ||
30 | +function IconvLiteEncoderStream(conv, options) { | ||
31 | + this.conv = conv; | ||
32 | + options = options || {}; | ||
33 | + options.decodeStrings = false; // We accept only strings, so we don't need to decode them. | ||
34 | + Transform.call(this, options); | ||
35 | +} | ||
36 | + | ||
37 | +IconvLiteEncoderStream.prototype = Object.create(Transform.prototype, { | ||
38 | + constructor: { value: IconvLiteEncoderStream } | ||
39 | +}); | ||
40 | + | ||
41 | +IconvLiteEncoderStream.prototype._transform = function(chunk, encoding, done) { | ||
42 | + if (typeof chunk != 'string') | ||
43 | + return done(new Error("Iconv encoding stream needs strings as its input.")); | ||
44 | + try { | ||
45 | + var res = this.conv.write(chunk); | ||
46 | + if (res && res.length) this.push(res); | ||
47 | + done(); | ||
48 | + } | ||
49 | + catch (e) { | ||
50 | + done(e); | ||
51 | + } | ||
52 | +} | ||
53 | + | ||
54 | +IconvLiteEncoderStream.prototype._flush = function(done) { | ||
55 | + try { | ||
56 | + var res = this.conv.end(); | ||
57 | + if (res && res.length) this.push(res); | ||
58 | + done(); | ||
59 | + } | ||
60 | + catch (e) { | ||
61 | + done(e); | ||
62 | + } | ||
63 | +} | ||
64 | + | ||
65 | +IconvLiteEncoderStream.prototype.collect = function(cb) { | ||
66 | + var chunks = []; | ||
67 | + this.on('error', cb); | ||
68 | + this.on('data', function(chunk) { chunks.push(chunk); }); | ||
69 | + this.on('end', function() { | ||
70 | + cb(null, Buffer.concat(chunks)); | ||
71 | + }); | ||
72 | + return this; | ||
73 | +} | ||
74 | + | ||
75 | + | ||
76 | +// == Decoder stream ======================================================= | ||
77 | +function IconvLiteDecoderStream(conv, options) { | ||
78 | + this.conv = conv; | ||
79 | + options = options || {}; | ||
80 | + options.encoding = this.encoding = 'utf8'; // We output strings. | ||
81 | + Transform.call(this, options); | ||
82 | +} | ||
83 | + | ||
84 | +IconvLiteDecoderStream.prototype = Object.create(Transform.prototype, { | ||
85 | + constructor: { value: IconvLiteDecoderStream } | ||
86 | +}); | ||
87 | + | ||
88 | +IconvLiteDecoderStream.prototype._transform = function(chunk, encoding, done) { | ||
89 | + if (!Buffer.isBuffer(chunk)) | ||
90 | + return done(new Error("Iconv decoding stream needs buffers as its input.")); | ||
91 | + try { | ||
92 | + var res = this.conv.write(chunk); | ||
93 | + if (res && res.length) this.push(res, this.encoding); | ||
94 | + done(); | ||
95 | + } | ||
96 | + catch (e) { | ||
97 | + done(e); | ||
98 | + } | ||
99 | +} | ||
100 | + | ||
101 | +IconvLiteDecoderStream.prototype._flush = function(done) { | ||
102 | + try { | ||
103 | + var res = this.conv.end(); | ||
104 | + if (res && res.length) this.push(res, this.encoding); | ||
105 | + done(); | ||
106 | + } | ||
107 | + catch (e) { | ||
108 | + done(e); | ||
109 | + } | ||
110 | +} | ||
111 | + | ||
112 | +IconvLiteDecoderStream.prototype.collect = function(cb) { | ||
113 | + var res = ''; | ||
114 | + this.on('error', cb); | ||
115 | + this.on('data', function(chunk) { res += chunk; }); | ||
116 | + this.on('end', function() { | ||
117 | + cb(null, res); | ||
118 | + }); | ||
119 | + return this; | ||
120 | +} | ||
121 | + |
1 | +{ | ||
2 | + "_from": "iconv-lite@0.4.23", | ||
3 | + "_id": "iconv-lite@0.4.23", | ||
4 | + "_inBundle": false, | ||
5 | + "_integrity": "sha512-neyTUVFtahjf0mB3dZT77u+8O0QB89jFdnBkd5P1JgYPbPaia3gXXOVL2fq8VyU2gMMD7SaN7QukTB/pmXYvDA==", | ||
6 | + "_location": "/body-parser/iconv-lite", | ||
7 | + "_phantomChildren": {}, | ||
8 | + "_requested": { | ||
9 | + "type": "version", | ||
10 | + "registry": true, | ||
11 | + "raw": "iconv-lite@0.4.23", | ||
12 | + "name": "iconv-lite", | ||
13 | + "escapedName": "iconv-lite", | ||
14 | + "rawSpec": "0.4.23", | ||
15 | + "saveSpec": null, | ||
16 | + "fetchSpec": "0.4.23" | ||
17 | + }, | ||
18 | + "_requiredBy": [ | ||
19 | + "/body-parser", | ||
20 | + "/body-parser/raw-body" | ||
21 | + ], | ||
22 | + "_resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.23.tgz", | ||
23 | + "_shasum": "297871f63be507adcfbfca715d0cd0eed84e9a63", | ||
24 | + "_spec": "iconv-lite@0.4.23", | ||
25 | + "_where": "/home/jin/opensource/kakaoBot/node_modules/body-parser", | ||
26 | + "author": { | ||
27 | + "name": "Alexander Shtuchkin", | ||
28 | + "email": "ashtuchkin@gmail.com" | ||
29 | + }, | ||
30 | + "browser": { | ||
31 | + "./lib/extend-node": false, | ||
32 | + "./lib/streams": false | ||
33 | + }, | ||
34 | + "bugs": { | ||
35 | + "url": "https://github.com/ashtuchkin/iconv-lite/issues" | ||
36 | + }, | ||
37 | + "bundleDependencies": false, | ||
38 | + "dependencies": { | ||
39 | + "safer-buffer": ">= 2.1.2 < 3" | ||
40 | + }, | ||
41 | + "deprecated": false, | ||
42 | + "description": "Convert character encodings in pure javascript.", | ||
43 | + "devDependencies": { | ||
44 | + "async": "*", | ||
45 | + "errto": "*", | ||
46 | + "iconv": "*", | ||
47 | + "istanbul": "*", | ||
48 | + "mocha": "^3.1.0", | ||
49 | + "request": "~2.81.0", | ||
50 | + "semver": "*", | ||
51 | + "unorm": "*" | ||
52 | + }, | ||
53 | + "engines": { | ||
54 | + "node": ">=0.10.0" | ||
55 | + }, | ||
56 | + "homepage": "https://github.com/ashtuchkin/iconv-lite", | ||
57 | + "keywords": [ | ||
58 | + "iconv", | ||
59 | + "convert", | ||
60 | + "charset", | ||
61 | + "icu" | ||
62 | + ], | ||
63 | + "license": "MIT", | ||
64 | + "main": "./lib/index.js", | ||
65 | + "name": "iconv-lite", | ||
66 | + "repository": { | ||
67 | + "type": "git", | ||
68 | + "url": "git://github.com/ashtuchkin/iconv-lite.git" | ||
69 | + }, | ||
70 | + "scripts": { | ||
71 | + "coverage": "istanbul cover _mocha -- --grep .", | ||
72 | + "coverage-open": "open coverage/lcov-report/index.html", | ||
73 | + "test": "mocha --reporter spec --grep ." | ||
74 | + }, | ||
75 | + "typings": "./lib/index.d.ts", | ||
76 | + "version": "0.4.23" | ||
77 | +} |
1 | +2.3.3 / 2018-05-08 | ||
2 | +================== | ||
3 | + | ||
4 | + * deps: http-errors@1.6.3 | ||
5 | + - deps: depd@~1.1.2 | ||
6 | + - deps: setprototypeof@1.1.0 | ||
7 | + - deps: statuses@'>= 1.3.1 < 2' | ||
8 | + * deps: iconv-lite@0.4.23 | ||
9 | + - Fix loading encoding with year appended | ||
10 | + - Fix deprecation warnings on Node.js 10+ | ||
11 | + | ||
12 | +2.3.2 / 2017-09-09 | ||
13 | +================== | ||
14 | + | ||
15 | + * deps: iconv-lite@0.4.19 | ||
16 | + - Fix ISO-8859-1regression | ||
17 | + - Update Windows-1255 | ||
18 | + | ||
19 | +2.3.1 / 2017-09-07 | ||
20 | +================== | ||
21 | + | ||
22 | + * deps: bytes@3.0.0 | ||
23 | + * deps: http-errors@1.6.2 | ||
24 | + - deps: depd@1.1.1 | ||
25 | + * perf: skip buffer decoding on overage chunk | ||
26 | + | ||
27 | +2.3.0 / 2017-08-04 | ||
28 | +================== | ||
29 | + | ||
30 | + * Add TypeScript definitions | ||
31 | + * Use `http-errors` for standard emitted errors | ||
32 | + * deps: bytes@2.5.0 | ||
33 | + * deps: iconv-lite@0.4.18 | ||
34 | + - Add support for React Native | ||
35 | + - Add a warning if not loaded as utf-8 | ||
36 | + - Fix CESU-8 decoding in Node.js 8 | ||
37 | + - Improve speed of ISO-8859-1 encoding | ||
38 | + | ||
39 | +2.2.0 / 2017-01-02 | ||
40 | +================== | ||
41 | + | ||
42 | + * deps: iconv-lite@0.4.15 | ||
43 | + - Added encoding MS-31J | ||
44 | + - Added encoding MS-932 | ||
45 | + - Added encoding MS-936 | ||
46 | + - Added encoding MS-949 | ||
47 | + - Added encoding MS-950 | ||
48 | + - Fix GBK/GB18030 handling of Euro character | ||
49 | + | ||
50 | +2.1.7 / 2016-06-19 | ||
51 | +================== | ||
52 | + | ||
53 | + * deps: bytes@2.4.0 | ||
54 | + * perf: remove double-cleanup on happy path | ||
55 | + | ||
56 | +2.1.6 / 2016-03-07 | ||
57 | +================== | ||
58 | + | ||
59 | + * deps: bytes@2.3.0 | ||
60 | + - Drop partial bytes on all parsed units | ||
61 | + - Fix parsing byte string that looks like hex | ||
62 | + | ||
63 | +2.1.5 / 2015-11-30 | ||
64 | +================== | ||
65 | + | ||
66 | + * deps: bytes@2.2.0 | ||
67 | + * deps: iconv-lite@0.4.13 | ||
68 | + | ||
69 | +2.1.4 / 2015-09-27 | ||
70 | +================== | ||
71 | + | ||
72 | + * Fix masking critical errors from `iconv-lite` | ||
73 | + * deps: iconv-lite@0.4.12 | ||
74 | + - Fix CESU-8 decoding in Node.js 4.x | ||
75 | + | ||
76 | +2.1.3 / 2015-09-12 | ||
77 | +================== | ||
78 | + | ||
79 | + * Fix sync callback when attaching data listener causes sync read | ||
80 | + - Node.js 0.10 compatibility issue | ||
81 | + | ||
82 | +2.1.2 / 2015-07-05 | ||
83 | +================== | ||
84 | + | ||
85 | + * Fix error stack traces to skip `makeError` | ||
86 | + * deps: iconv-lite@0.4.11 | ||
87 | + - Add encoding CESU-8 | ||
88 | + | ||
89 | +2.1.1 / 2015-06-14 | ||
90 | +================== | ||
91 | + | ||
92 | + * Use `unpipe` module for unpiping requests | ||
93 | + | ||
94 | +2.1.0 / 2015-05-28 | ||
95 | +================== | ||
96 | + | ||
97 | + * deps: iconv-lite@0.4.10 | ||
98 | + - Improved UTF-16 endianness detection | ||
99 | + - Leading BOM is now removed when decoding | ||
100 | + - The encoding UTF-16 without BOM now defaults to UTF-16LE when detection fails | ||
101 | + | ||
102 | +2.0.2 / 2015-05-21 | ||
103 | +================== | ||
104 | + | ||
105 | + * deps: bytes@2.1.0 | ||
106 | + - Slight optimizations | ||
107 | + | ||
108 | +2.0.1 / 2015-05-10 | ||
109 | +================== | ||
110 | + | ||
111 | + * Fix a false-positive when unpiping in Node.js 0.8 | ||
112 | + | ||
113 | +2.0.0 / 2015-05-08 | ||
114 | +================== | ||
115 | + | ||
116 | + * Return a promise without callback instead of thunk | ||
117 | + * deps: bytes@2.0.1 | ||
118 | + - units no longer case sensitive when parsing | ||
119 | + | ||
120 | +1.3.4 / 2015-04-15 | ||
121 | +================== | ||
122 | + | ||
123 | + * Fix hanging callback if request aborts during read | ||
124 | + * deps: iconv-lite@0.4.8 | ||
125 | + - Add encoding alias UNICODE-1-1-UTF-7 | ||
126 | + | ||
127 | +1.3.3 / 2015-02-08 | ||
128 | +================== | ||
129 | + | ||
130 | + * deps: iconv-lite@0.4.7 | ||
131 | + - Gracefully support enumerables on `Object.prototype` | ||
132 | + | ||
133 | +1.3.2 / 2015-01-20 | ||
134 | +================== | ||
135 | + | ||
136 | + * deps: iconv-lite@0.4.6 | ||
137 | + - Fix rare aliases of single-byte encodings | ||
138 | + | ||
139 | +1.3.1 / 2014-11-21 | ||
140 | +================== | ||
141 | + | ||
142 | + * deps: iconv-lite@0.4.5 | ||
143 | + - Fix Windows-31J and X-SJIS encoding support | ||
144 | + | ||
145 | +1.3.0 / 2014-07-20 | ||
146 | +================== | ||
147 | + | ||
148 | + * Fully unpipe the stream on error | ||
149 | + - Fixes `Cannot switch to old mode now` error on Node.js 0.10+ | ||
150 | + | ||
151 | +1.2.3 / 2014-07-20 | ||
152 | +================== | ||
153 | + | ||
154 | + * deps: iconv-lite@0.4.4 | ||
155 | + - Added encoding UTF-7 | ||
156 | + | ||
157 | +1.2.2 / 2014-06-19 | ||
158 | +================== | ||
159 | + | ||
160 | + * Send invalid encoding error to callback | ||
161 | + | ||
162 | +1.2.1 / 2014-06-15 | ||
163 | +================== | ||
164 | + | ||
165 | + * deps: iconv-lite@0.4.3 | ||
166 | + - Added encodings UTF-16BE and UTF-16 with BOM | ||
167 | + | ||
168 | +1.2.0 / 2014-06-13 | ||
169 | +================== | ||
170 | + | ||
171 | + * Passing string as `options` interpreted as encoding | ||
172 | + * Support all encodings from `iconv-lite` | ||
173 | + | ||
174 | +1.1.7 / 2014-06-12 | ||
175 | +================== | ||
176 | + | ||
177 | + * use `string_decoder` module from npm | ||
178 | + | ||
179 | +1.1.6 / 2014-05-27 | ||
180 | +================== | ||
181 | + | ||
182 | + * check encoding for old streams1 | ||
183 | + * support node.js < 0.10.6 | ||
184 | + | ||
185 | +1.1.5 / 2014-05-14 | ||
186 | +================== | ||
187 | + | ||
188 | + * bump bytes | ||
189 | + | ||
190 | +1.1.4 / 2014-04-19 | ||
191 | +================== | ||
192 | + | ||
193 | + * allow true as an option | ||
194 | + * bump bytes | ||
195 | + | ||
196 | +1.1.3 / 2014-03-02 | ||
197 | +================== | ||
198 | + | ||
199 | + * fix case when length=null | ||
200 | + | ||
201 | +1.1.2 / 2013-12-01 | ||
202 | +================== | ||
203 | + | ||
204 | + * be less strict on state.encoding check | ||
205 | + | ||
206 | +1.1.1 / 2013-11-27 | ||
207 | +================== | ||
208 | + | ||
209 | + * add engines | ||
210 | + | ||
211 | +1.1.0 / 2013-11-27 | ||
212 | +================== | ||
213 | + | ||
214 | + * add err.statusCode and err.type | ||
215 | + * allow for encoding option to be true | ||
216 | + * pause the stream instead of dumping on error | ||
217 | + * throw if the stream's encoding is set | ||
218 | + | ||
219 | +1.0.1 / 2013-11-19 | ||
220 | +================== | ||
221 | + | ||
222 | + * dont support streams1, throw if dev set encoding | ||
223 | + | ||
224 | +1.0.0 / 2013-11-17 | ||
225 | +================== | ||
226 | + | ||
227 | + * rename `expected` option to `length` | ||
228 | + | ||
229 | +0.2.0 / 2013-11-15 | ||
230 | +================== | ||
231 | + | ||
232 | + * republish | ||
233 | + | ||
234 | +0.1.1 / 2013-11-15 | ||
235 | +================== | ||
236 | + | ||
237 | + * use bytes | ||
238 | + | ||
239 | +0.1.0 / 2013-11-11 | ||
240 | +================== | ||
241 | + | ||
242 | + * generator support | ||
243 | + | ||
244 | +0.0.3 / 2013-10-10 | ||
245 | +================== | ||
246 | + | ||
247 | + * update repo | ||
248 | + | ||
249 | +0.0.2 / 2013-09-14 | ||
250 | +================== | ||
251 | + | ||
252 | + * dump stream on bad headers | ||
253 | + * listen to events after defining received and buffers | ||
254 | + | ||
255 | +0.0.1 / 2013-09-14 | ||
256 | +================== | ||
257 | + | ||
258 | + * Initial release |
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
node_modules/boom/LICENSE
deleted
100755 → 0
This diff is collapsed. Click to expand it.
node_modules/boom/README.md
deleted
100755 → 0
This diff is collapsed. Click to expand it.
node_modules/boom/lib/index.js
deleted
100755 → 0
This diff is collapsed. Click to expand it.
node_modules/boom/package.json
deleted
100644 → 0
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
node_modules/combined-stream/lib/defer.js
0 → 100644
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
node_modules/cryptiles/.npmignore
deleted
100644 → 0
This diff is collapsed. Click to expand it.
node_modules/cryptiles/README.md
deleted
100755 → 0
This diff is collapsed. Click to expand it.
node_modules/cryptiles/lib/index.js
deleted
100755 → 0
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
node_modules/cryptiles/package.json
deleted
100755 → 0
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
node_modules/ecc-jsbn/.npmignore
deleted
100644 → 0
This diff is collapsed. Click to expand it.
node_modules/ecc-jsbn/LICENSE
100644 → 100755
This diff is collapsed. Click to expand it.
node_modules/ecc-jsbn/README.md
100644 → 100755
This diff is collapsed. Click to expand it.
node_modules/ecc-jsbn/index.js
100644 → 100755
This diff is collapsed. Click to expand it.
node_modules/ecc-jsbn/lib/LICENSE-jsbn
100644 → 100755
This diff is collapsed. Click to expand it.
node_modules/ecc-jsbn/lib/ec.js
100644 → 100755
This diff is collapsed. Click to expand it.
node_modules/ecc-jsbn/lib/sec.js
100644 → 100755
This diff is collapsed. Click to expand it.
node_modules/ecc-jsbn/package.json
100644 → 100755
This diff is collapsed. Click to expand it.
node_modules/ecc-jsbn/test.js
100644 → 100755
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
node_modules/extend/.editorconfig
0 → 100644
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
node_modules/extend/.npmignore
deleted
100644 → 0
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
node_modules/fast-deep-equal/index.d.ts
0 → 100644
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
node_modules/hawk/.npmignore
deleted
100755 → 0
This diff is collapsed. Click to expand it.
node_modules/hawk/LICENSE
deleted
100755 → 0
This diff is collapsed. Click to expand it.
node_modules/hawk/README.md
deleted
100755 → 0
This diff is collapsed. Click to expand it.
node_modules/hawk/client.js
deleted
100755 → 0
This diff is collapsed. Click to expand it.
node_modules/hawk/dist/browser.js
deleted
100644 → 0
This diff is collapsed. Click to expand it.
node_modules/hawk/lib/browser.js
deleted
100755 → 0
This diff is collapsed. Click to expand it.
node_modules/hawk/lib/client.js
deleted
100755 → 0
This diff is collapsed. Click to expand it.
node_modules/hawk/lib/crypto.js
deleted
100755 → 0
This diff is collapsed. Click to expand it.
node_modules/hawk/lib/index.js
deleted
100755 → 0
This diff is collapsed. Click to expand it.
node_modules/hawk/lib/server.js
deleted
100755 → 0
This diff is collapsed. Click to expand it.
node_modules/hawk/lib/utils.js
deleted
100755 → 0
This diff is collapsed. Click to expand it.
node_modules/hawk/package.json
deleted
100755 → 0
This diff is collapsed. Click to expand it.
node_modules/hoek/.npmignore
deleted
100644 → 0
This diff is collapsed. Click to expand it.
node_modules/hoek/LICENSE
deleted
100644 → 0
This diff is collapsed. Click to expand it.
node_modules/hoek/README.md
deleted
100644 → 0
This diff is collapsed. Click to expand it.
node_modules/hoek/lib/escape.js
deleted
100755 → 0
This diff is collapsed. Click to expand it.
node_modules/hoek/lib/index.js
deleted
100755 → 0
This diff is collapsed. Click to expand it.
node_modules/hoek/package.json
deleted
100644 → 0
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
node_modules/ipaddr.js/.npmignore
deleted
100644 → 0
This diff is collapsed. Click to expand it.
node_modules/ipaddr.js/.travis.yml
deleted
100644 → 0
This diff is collapsed. Click to expand it.
node_modules/ipaddr.js/Cakefile
deleted
100644 → 0
This diff is collapsed. Click to expand it.
node_modules/ipaddr.js/bower.json
deleted
100644 → 0
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
node_modules/ipaddr.js/lib/ipaddr.js.d.ts
0 → 100644
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
node_modules/psl/.eslintignore
0 → 100644
This diff is collapsed. Click to expand it.
node_modules/psl/.eslintrc
0 → 100644
This diff is collapsed. Click to expand it.
node_modules/psl/.travis.yml
0 → 100644
This diff is collapsed. Click to expand it.
node_modules/psl/README.md
0 → 100644
This diff is collapsed. Click to expand it.
node_modules/psl/data/rules.json
0 → 100644
This diff could not be displayed because it is too large.
node_modules/psl/dist/psl.js
0 → 100644
This diff could not be displayed because it is too large.
node_modules/psl/dist/psl.min.js
0 → 100644
This diff could not be displayed because it is too large.
node_modules/psl/index.js
0 → 100644
This diff is collapsed. Click to expand it.
node_modules/psl/karma.conf.js
0 → 100644
This diff is collapsed. Click to expand it.
node_modules/psl/package.json
0 → 100644
This diff is collapsed. Click to expand it.
node_modules/psl/yarn.lock
0 → 100644
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.
node_modules/request/lib/hawk.js
0 → 100644
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
node_modules/safer-buffer/LICENSE
0 → 100644
This diff is collapsed. Click to expand it.
node_modules/safer-buffer/Porting-Buffer.md
0 → 100644
This diff is collapsed. Click to expand it.
node_modules/safer-buffer/Readme.md
0 → 100644
This diff is collapsed. Click to expand it.
node_modules/safer-buffer/dangerous.js
0 → 100644
This diff is collapsed. Click to expand it.
node_modules/safer-buffer/package.json
0 → 100644
This diff is collapsed. Click to expand it.
node_modules/safer-buffer/safer.js
0 → 100644
This diff is collapsed. Click to expand it.
node_modules/safer-buffer/tests.js
0 → 100644
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
node_modules/send/node_modules/depd/LICENSE
0 → 100644
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
node_modules/send/node_modules/depd/index.js
0 → 100644
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
node_modules/sntp/.npmignore
deleted
100755 → 0
This diff is collapsed. Click to expand it.
node_modules/sntp/LICENSE
deleted
100755 → 0
This diff is collapsed. Click to expand it.
node_modules/sntp/README.md
deleted
100755 → 0
This diff is collapsed. Click to expand it.
node_modules/sntp/lib/index.js
deleted
100755 → 0
This diff is collapsed. Click to expand it.
node_modules/sntp/package.json
deleted
100755 → 0
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
node_modules/sshpk/lib/formats/dnssec.js
0 → 100644
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
node_modules/stringstream/.npmignore
deleted
100644 → 0
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
node_modules/stringstream/README.md
deleted
100644 → 0
This diff is collapsed. Click to expand it.
node_modules/stringstream/example.js
deleted
100644 → 0
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff 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.
node_modules/uuid/CHANGELOG.md
0 → 100644
This diff is collapsed. Click to expand it.
node_modules/uuid/HISTORY.md
deleted
100644 → 0
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
node_modules/uuid/README_js.md
0 → 100644
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
node_modules/uuid/lib/md5-browser.js
0 → 100644
This diff is collapsed. Click to expand it.
node_modules/uuid/lib/md5.js
0 → 100644
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
node_modules/uuid/lib/v35.js
0 → 100644
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
node_modules/uuid/v3.js
0 → 100644
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
-
Please register or login to post a comment