node-red-contrib-web-worldmap 2.23.5 → 2.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (202) hide show
  1. package/CHANGELOG.md +1 -0
  2. package/README.md +7 -1
  3. package/node_modules/body-parser/HISTORY.md +15 -0
  4. package/node_modules/body-parser/README.md +25 -12
  5. package/node_modules/body-parser/package.json +32 -35
  6. package/node_modules/{body-parser/node_modules/bytes → bytes}/History.md +5 -0
  7. package/node_modules/{body-parser/node_modules/bytes → bytes}/LICENSE +0 -0
  8. package/node_modules/{raw-body/node_modules/bytes → bytes}/Readme.md +42 -16
  9. package/node_modules/{raw-body/node_modules/bytes → bytes}/index.js +5 -1
  10. package/node_modules/{raw-body/node_modules/bytes → bytes}/package.json +20 -21
  11. package/node_modules/content-disposition/HISTORY.md +5 -0
  12. package/node_modules/content-disposition/README.md +3 -9
  13. package/node_modules/content-disposition/index.js +1 -1
  14. package/node_modules/content-disposition/node_modules/safe-buffer/LICENSE +21 -0
  15. package/node_modules/content-disposition/node_modules/safe-buffer/README.md +584 -0
  16. package/node_modules/content-disposition/node_modules/safe-buffer/index.d.ts +187 -0
  17. package/node_modules/content-disposition/node_modules/safe-buffer/index.js +65 -0
  18. package/node_modules/content-disposition/node_modules/safe-buffer/package.json +76 -0
  19. package/node_modules/content-disposition/package.json +25 -28
  20. package/node_modules/cookie/HISTORY.md +5 -0
  21. package/node_modules/cookie/README.md +4 -0
  22. package/node_modules/cookie/index.js +5 -1
  23. package/node_modules/cookie/package.json +20 -23
  24. package/node_modules/express/History.md +33 -0
  25. package/node_modules/express/Readme.md +8 -5
  26. package/node_modules/express/lib/application.js +1 -1
  27. package/node_modules/express/lib/request.js +1 -1
  28. package/node_modules/express/lib/response.js +16 -11
  29. package/node_modules/express/lib/router/index.js +6 -0
  30. package/node_modules/express/lib/utils.js +2 -6
  31. package/node_modules/express/node_modules/safe-buffer/LICENSE +21 -0
  32. package/node_modules/express/node_modules/safe-buffer/README.md +584 -0
  33. package/node_modules/express/node_modules/safe-buffer/index.d.ts +187 -0
  34. package/node_modules/express/node_modules/safe-buffer/index.js +65 -0
  35. package/node_modules/express/node_modules/safe-buffer/package.json +76 -0
  36. package/node_modules/express/package.json +35 -36
  37. package/node_modules/faye-websocket/CHANGELOG.md +5 -0
  38. package/node_modules/faye-websocket/LICENSE.md +1 -1
  39. package/node_modules/faye-websocket/README.md +13 -13
  40. package/node_modules/faye-websocket/lib/faye/websocket/api.js +10 -8
  41. package/node_modules/faye-websocket/lib/faye/websocket/client.js +4 -4
  42. package/node_modules/faye-websocket/lib/faye/websocket.js +1 -1
  43. package/node_modules/faye-websocket/package.json +14 -17
  44. package/node_modules/forwarded/HISTORY.md +5 -0
  45. package/node_modules/forwarded/README.md +3 -3
  46. package/node_modules/forwarded/index.js +15 -1
  47. package/node_modules/forwarded/package.json +25 -26
  48. package/node_modules/http-errors/HISTORY.md +16 -0
  49. package/node_modules/http-errors/README.md +12 -6
  50. package/node_modules/http-errors/index.js +35 -2
  51. package/node_modules/http-errors/package.json +28 -31
  52. package/node_modules/{websocket-driver/node_modules/http-parser-js → http-parser-js}/LICENSE.md +0 -0
  53. package/node_modules/http-parser-js/README.md +39 -0
  54. package/node_modules/http-parser-js/http-parser.d.ts +175 -0
  55. package/node_modules/{websocket-driver/node_modules/http-parser-js → http-parser-js}/http-parser.js +8 -5
  56. package/node_modules/{websocket-driver/node_modules/http-parser-js → http-parser-js}/package.json +17 -19
  57. package/node_modules/inherits/inherits.js +2 -0
  58. package/node_modules/inherits/inherits_browser.js +18 -14
  59. package/node_modules/inherits/package.json +15 -18
  60. package/node_modules/ipaddr.js/README.md +1 -1
  61. package/node_modules/ipaddr.js/lib/ipaddr.js.d.ts +6 -9
  62. package/node_modules/ipaddr.js/package.json +15 -17
  63. package/node_modules/proxy-addr/HISTORY.md +11 -0
  64. package/node_modules/proxy-addr/README.md +3 -19
  65. package/node_modules/proxy-addr/index.js +1 -1
  66. package/node_modules/proxy-addr/package.json +28 -31
  67. package/node_modules/qs/.editorconfig +9 -0
  68. package/node_modules/qs/.eslintignore +2 -1
  69. package/node_modules/qs/.eslintrc +15 -1
  70. package/node_modules/qs/.github/FUNDING.yml +12 -0
  71. package/node_modules/qs/.nycrc +13 -0
  72. package/node_modules/qs/CHANGELOG.md +103 -0
  73. package/node_modules/qs/LICENSE.md +29 -0
  74. package/node_modules/qs/README.md +34 -0
  75. package/node_modules/qs/dist/qs.js +117 -67
  76. package/node_modules/qs/lib/formats.js +9 -4
  77. package/node_modules/qs/lib/parse.js +29 -14
  78. package/node_modules/qs/lib/stringify.js +55 -46
  79. package/node_modules/qs/lib/utils.js +23 -2
  80. package/node_modules/qs/package.json +39 -31
  81. package/node_modules/qs/test/parse.js +97 -1
  82. package/node_modules/qs/test/stringify.js +115 -1
  83. package/node_modules/qs/test/utils.js +1 -1
  84. package/node_modules/raw-body/HISTORY.md +14 -0
  85. package/node_modules/raw-body/README.md +3 -5
  86. package/node_modules/raw-body/package.json +30 -33
  87. package/node_modules/send/HISTORY.md +10 -0
  88. package/node_modules/send/README.md +4 -6
  89. package/node_modules/send/index.js +7 -3
  90. package/node_modules/send/node_modules/ms/index.js +3 -3
  91. package/node_modules/send/node_modules/ms/license.md +1 -1
  92. package/node_modules/send/node_modules/ms/package.json +19 -21
  93. package/node_modules/send/node_modules/ms/readme.md +1 -2
  94. package/node_modules/send/package.json +28 -31
  95. package/node_modules/serve-static/HISTORY.md +8 -0
  96. package/node_modules/serve-static/README.md +9 -11
  97. package/node_modules/serve-static/package.json +28 -31
  98. package/node_modules/setprototypeof/README.md +1 -1
  99. package/node_modules/setprototypeof/index.js +1 -1
  100. package/node_modules/setprototypeof/package.json +17 -18
  101. package/node_modules/sockjs/Changelog +12 -0
  102. package/node_modules/sockjs/lib/transport.js +1 -1
  103. package/node_modules/sockjs/package.json +14 -16
  104. package/node_modules/toidentifier/HISTORY.md +9 -0
  105. package/node_modules/toidentifier/README.md +3 -3
  106. package/node_modules/toidentifier/index.js +2 -0
  107. package/node_modules/toidentifier/package.json +28 -27
  108. package/node_modules/uuid/CHANGELOG.md +154 -44
  109. package/node_modules/uuid/CONTRIBUTING.md +18 -0
  110. package/node_modules/uuid/LICENSE.md +4 -16
  111. package/node_modules/uuid/README.md +384 -155
  112. package/node_modules/uuid/dist/bin/uuid +2 -0
  113. package/node_modules/uuid/dist/esm-browser/index.js +9 -0
  114. package/node_modules/uuid/{lib/md5-browser.js → dist/esm-browser/md5.js} +70 -71
  115. package/node_modules/uuid/dist/esm-browser/nil.js +1 -0
  116. package/node_modules/uuid/dist/esm-browser/parse.js +35 -0
  117. package/node_modules/uuid/dist/esm-browser/regex.js +1 -0
  118. package/node_modules/uuid/dist/esm-browser/rng.js +19 -0
  119. package/node_modules/uuid/dist/esm-browser/sha1.js +96 -0
  120. package/node_modules/uuid/dist/esm-browser/stringify.js +30 -0
  121. package/node_modules/uuid/{v1.js → dist/esm-browser/v1.js} +36 -50
  122. package/node_modules/uuid/dist/esm-browser/v3.js +4 -0
  123. package/node_modules/uuid/dist/esm-browser/v35.js +64 -0
  124. package/node_modules/uuid/dist/esm-browser/v4.js +24 -0
  125. package/node_modules/uuid/dist/esm-browser/v5.js +4 -0
  126. package/node_modules/uuid/dist/esm-browser/validate.js +7 -0
  127. package/node_modules/uuid/dist/esm-browser/version.js +11 -0
  128. package/node_modules/uuid/dist/esm-node/index.js +9 -0
  129. package/node_modules/uuid/dist/esm-node/md5.js +13 -0
  130. package/node_modules/uuid/dist/esm-node/nil.js +1 -0
  131. package/node_modules/uuid/dist/esm-node/parse.js +35 -0
  132. package/node_modules/uuid/dist/esm-node/regex.js +1 -0
  133. package/node_modules/uuid/dist/esm-node/rng.js +12 -0
  134. package/node_modules/uuid/dist/esm-node/sha1.js +13 -0
  135. package/node_modules/uuid/dist/esm-node/stringify.js +29 -0
  136. package/node_modules/uuid/dist/esm-node/v1.js +95 -0
  137. package/node_modules/uuid/dist/esm-node/v3.js +4 -0
  138. package/node_modules/uuid/dist/esm-node/v35.js +64 -0
  139. package/node_modules/uuid/dist/esm-node/v4.js +24 -0
  140. package/node_modules/uuid/dist/esm-node/v5.js +4 -0
  141. package/node_modules/uuid/dist/esm-node/validate.js +7 -0
  142. package/node_modules/uuid/dist/esm-node/version.js +11 -0
  143. package/node_modules/uuid/dist/index.js +79 -0
  144. package/node_modules/uuid/dist/md5-browser.js +223 -0
  145. package/node_modules/uuid/dist/md5.js +23 -0
  146. package/node_modules/uuid/dist/nil.js +8 -0
  147. package/node_modules/uuid/dist/parse.js +45 -0
  148. package/node_modules/uuid/dist/regex.js +8 -0
  149. package/node_modules/uuid/dist/rng-browser.js +26 -0
  150. package/node_modules/uuid/dist/rng.js +24 -0
  151. package/node_modules/uuid/dist/sha1-browser.js +104 -0
  152. package/node_modules/uuid/dist/sha1.js +23 -0
  153. package/node_modules/uuid/dist/stringify.js +39 -0
  154. package/node_modules/uuid/dist/umd/uuid.min.js +1 -0
  155. package/node_modules/uuid/dist/umd/uuidNIL.min.js +1 -0
  156. package/node_modules/uuid/dist/umd/uuidParse.min.js +1 -0
  157. package/node_modules/uuid/dist/umd/uuidStringify.min.js +1 -0
  158. package/node_modules/uuid/dist/umd/uuidValidate.min.js +1 -0
  159. package/node_modules/uuid/dist/umd/uuidVersion.min.js +1 -0
  160. package/node_modules/uuid/dist/umd/uuidv1.min.js +1 -0
  161. package/node_modules/uuid/dist/umd/uuidv3.min.js +1 -0
  162. package/node_modules/uuid/dist/umd/uuidv4.min.js +1 -0
  163. package/node_modules/uuid/dist/umd/uuidv5.min.js +1 -0
  164. package/node_modules/uuid/dist/uuid-bin.js +85 -0
  165. package/node_modules/uuid/dist/v1.js +107 -0
  166. package/node_modules/uuid/dist/v3.js +16 -0
  167. package/node_modules/uuid/dist/v35.js +78 -0
  168. package/node_modules/uuid/dist/v4.js +37 -0
  169. package/node_modules/uuid/dist/v5.js +16 -0
  170. package/node_modules/uuid/dist/validate.js +17 -0
  171. package/node_modules/uuid/dist/version.js +21 -0
  172. package/node_modules/uuid/package.json +116 -55
  173. package/node_modules/uuid/wrapper.mjs +10 -0
  174. package/package.json +3 -3
  175. package/worldmap/index.html +1 -0
  176. package/worldmap/leaflet/leaflet-arc.min.js +1 -0
  177. package/worldmap/worldmap.js +36 -22
  178. package/worldmap.html +1 -1
  179. package/worldmap.js +2 -2
  180. package/node_modules/body-parser/node_modules/bytes/Readme.md +0 -126
  181. package/node_modules/body-parser/node_modules/bytes/index.js +0 -162
  182. package/node_modules/body-parser/node_modules/bytes/package.json +0 -86
  183. package/node_modules/qs/LICENSE +0 -28
  184. package/node_modules/qs/test/.eslintrc +0 -17
  185. package/node_modules/qs/test/index.js +0 -7
  186. package/node_modules/raw-body/node_modules/bytes/History.md +0 -87
  187. package/node_modules/raw-body/node_modules/bytes/LICENSE +0 -23
  188. package/node_modules/uuid/AUTHORS +0 -5
  189. package/node_modules/uuid/bin/uuid +0 -65
  190. package/node_modules/uuid/index.js +0 -8
  191. package/node_modules/uuid/lib/bytesToUuid.js +0 -26
  192. package/node_modules/uuid/lib/md5.js +0 -25
  193. package/node_modules/uuid/lib/rng-browser.js +0 -34
  194. package/node_modules/uuid/lib/rng.js +0 -8
  195. package/node_modules/uuid/lib/sha1-browser.js +0 -89
  196. package/node_modules/uuid/lib/sha1.js +0 -25
  197. package/node_modules/uuid/lib/v35.js +0 -57
  198. package/node_modules/uuid/v3.js +0 -4
  199. package/node_modules/uuid/v4.js +0 -29
  200. package/node_modules/uuid/v5.js +0 -3
  201. package/node_modules/websocket-driver/node_modules/http-parser-js/CHANGELOG.md +0 -14
  202. package/node_modules/websocket-driver/node_modules/http-parser-js/README.md +0 -31
@@ -1,32 +1,27 @@
1
1
  {
2
- "_args": [
3
- [
4
- "faye-websocket@0.11.3",
5
- "/Users/conway/Projects/worldmap"
6
- ]
7
- ],
8
- "_from": "faye-websocket@0.11.3",
9
- "_id": "faye-websocket@0.11.3",
2
+ "_from": "faye-websocket@^0.11.3",
3
+ "_id": "faye-websocket@0.11.4",
10
4
  "_inBundle": false,
11
- "_integrity": "sha512-D2y4bovYpzziGgbHYtGCMjlJM36vAl/y+xUyn1C+FVx8szd1E+86KwVw6XvYSzOP8iMpm1X0I4xJD+QtUb36OA==",
5
+ "_integrity": "sha512-CzbClwlXAuiRQAlUyfqPgvPoNKTckTPGfwZV4ZdAhVcP2lh9KUxJg2b5GkE7XbjKQ3YJnQ9z6D9ntLAlB+tP8g==",
12
6
  "_location": "/faye-websocket",
13
7
  "_phantomChildren": {},
14
8
  "_requested": {
15
- "type": "version",
9
+ "type": "range",
16
10
  "registry": true,
17
- "raw": "faye-websocket@0.11.3",
11
+ "raw": "faye-websocket@^0.11.3",
18
12
  "name": "faye-websocket",
19
13
  "escapedName": "faye-websocket",
20
- "rawSpec": "0.11.3",
14
+ "rawSpec": "^0.11.3",
21
15
  "saveSpec": null,
22
- "fetchSpec": "0.11.3"
16
+ "fetchSpec": "^0.11.3"
23
17
  },
24
18
  "_requiredBy": [
25
19
  "/sockjs"
26
20
  ],
27
- "_resolved": "https://registry.npmjs.org/faye-websocket/-/faye-websocket-0.11.3.tgz",
28
- "_spec": "0.11.3",
29
- "_where": "/Users/conway/Projects/worldmap",
21
+ "_resolved": "https://registry.npmjs.org/faye-websocket/-/faye-websocket-0.11.4.tgz",
22
+ "_shasum": "7f0d9275cfdd86a1c963dc8b65fcc451edcbb1da",
23
+ "_spec": "faye-websocket@^0.11.3",
24
+ "_where": "/Users/conway/Projects/worldmap/node_modules/sockjs",
30
25
  "author": {
31
26
  "name": "James Coglan",
32
27
  "email": "jcoglan@gmail.com",
@@ -35,9 +30,11 @@
35
30
  "bugs": {
36
31
  "url": "https://github.com/faye/faye-websocket-node/issues"
37
32
  },
33
+ "bundleDependencies": false,
38
34
  "dependencies": {
39
35
  "websocket-driver": ">=0.5.1"
40
36
  },
37
+ "deprecated": false,
41
38
  "description": "Standards-compliant WebSocket server and client",
42
39
  "devDependencies": {
43
40
  "jstest": "*",
@@ -65,5 +62,5 @@
65
62
  "scripts": {
66
63
  "test": "jstest spec/runner.js"
67
64
  },
68
- "version": "0.11.3"
65
+ "version": "0.11.4"
69
66
  }
@@ -1,3 +1,8 @@
1
+ 0.2.0 / 2021-05-31
2
+ ==================
3
+
4
+ * Use `req.socket` over deprecated `req.connection`
5
+
1
6
  0.1.2 / 2017-09-14
2
7
  ==================
3
8
 
@@ -3,7 +3,7 @@
3
3
  [![NPM Version][npm-image]][npm-url]
4
4
  [![NPM Downloads][downloads-image]][downloads-url]
5
5
  [![Node.js Version][node-version-image]][node-version-url]
6
- [![Build Status][travis-image]][travis-url]
6
+ [![Build Status][ci-image]][ci-url]
7
7
  [![Test Coverage][coveralls-image]][coveralls-url]
8
8
 
9
9
  Parse HTTP X-Forwarded-For header
@@ -45,12 +45,12 @@ $ npm test
45
45
 
46
46
  [MIT](LICENSE)
47
47
 
48
+ [ci-image]: https://badgen.net/github/checks/jshttp/forwarded/master?label=ci
49
+ [ci-url]: https://github.com/jshttp/forwarded/actions?query=workflow%3Aci
48
50
  [npm-image]: https://img.shields.io/npm/v/forwarded.svg
49
51
  [npm-url]: https://npmjs.org/package/forwarded
50
52
  [node-version-image]: https://img.shields.io/node/v/forwarded.svg
51
53
  [node-version-url]: https://nodejs.org/en/download/
52
- [travis-image]: https://img.shields.io/travis/jshttp/forwarded/master.svg
53
- [travis-url]: https://travis-ci.org/jshttp/forwarded
54
54
  [coveralls-image]: https://img.shields.io/coveralls/jshttp/forwarded/master.svg
55
55
  [coveralls-url]: https://coveralls.io/r/jshttp/forwarded?branch=master
56
56
  [downloads-image]: https://img.shields.io/npm/dm/forwarded.svg
@@ -28,13 +28,27 @@ function forwarded (req) {
28
28
 
29
29
  // simple header parsing
30
30
  var proxyAddrs = parse(req.headers['x-forwarded-for'] || '')
31
- var socketAddr = req.connection.remoteAddress
31
+ var socketAddr = getSocketAddr(req)
32
32
  var addrs = [socketAddr].concat(proxyAddrs)
33
33
 
34
34
  // return all addresses
35
35
  return addrs
36
36
  }
37
37
 
38
+ /**
39
+ * Get the socket address for a request.
40
+ *
41
+ * @param {object} req
42
+ * @return {string}
43
+ * @private
44
+ */
45
+
46
+ function getSocketAddr (req) {
47
+ return req.socket
48
+ ? req.socket.remoteAddress
49
+ : req.connection.remoteAddress
50
+ }
51
+
38
52
  /**
39
53
  * Parse the X-Forwarded-For header.
40
54
  *
@@ -1,53 +1,51 @@
1
1
  {
2
- "_args": [
3
- [
4
- "forwarded@0.1.2",
5
- "/Users/conway/Projects/worldmap"
6
- ]
7
- ],
8
- "_from": "forwarded@0.1.2",
9
- "_id": "forwarded@0.1.2",
2
+ "_from": "forwarded@0.2.0",
3
+ "_id": "forwarded@0.2.0",
10
4
  "_inBundle": false,
11
- "_integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ=",
5
+ "_integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==",
12
6
  "_location": "/forwarded",
13
7
  "_phantomChildren": {},
14
8
  "_requested": {
15
9
  "type": "version",
16
10
  "registry": true,
17
- "raw": "forwarded@0.1.2",
11
+ "raw": "forwarded@0.2.0",
18
12
  "name": "forwarded",
19
13
  "escapedName": "forwarded",
20
- "rawSpec": "0.1.2",
14
+ "rawSpec": "0.2.0",
21
15
  "saveSpec": null,
22
- "fetchSpec": "0.1.2"
16
+ "fetchSpec": "0.2.0"
23
17
  },
24
18
  "_requiredBy": [
25
19
  "/proxy-addr"
26
20
  ],
27
- "_resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz",
28
- "_spec": "0.1.2",
29
- "_where": "/Users/conway/Projects/worldmap",
21
+ "_resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz",
22
+ "_shasum": "2269936428aad4c15c7ebe9779a84bf0b2a81811",
23
+ "_spec": "forwarded@0.2.0",
24
+ "_where": "/Users/conway/Projects/worldmap/node_modules/proxy-addr",
30
25
  "bugs": {
31
26
  "url": "https://github.com/jshttp/forwarded/issues"
32
27
  },
28
+ "bundleDependencies": false,
33
29
  "contributors": [
34
30
  {
35
31
  "name": "Douglas Christopher Wilson",
36
32
  "email": "doug@somethingdoug.com"
37
33
  }
38
34
  ],
35
+ "deprecated": false,
39
36
  "description": "Parse HTTP X-Forwarded-For header",
40
37
  "devDependencies": {
41
38
  "beautify-benchmark": "0.2.4",
42
39
  "benchmark": "2.1.4",
43
- "eslint": "3.19.0",
44
- "eslint-config-standard": "10.2.1",
45
- "eslint-plugin-import": "2.7.0",
46
- "eslint-plugin-node": "5.1.1",
47
- "eslint-plugin-promise": "3.5.0",
48
- "eslint-plugin-standard": "3.0.1",
49
- "istanbul": "0.4.5",
50
- "mocha": "1.21.5"
40
+ "deep-equal": "1.0.1",
41
+ "eslint": "7.27.0",
42
+ "eslint-config-standard": "14.1.1",
43
+ "eslint-plugin-import": "2.23.4",
44
+ "eslint-plugin-node": "11.1.0",
45
+ "eslint-plugin-promise": "4.3.1",
46
+ "eslint-plugin-standard": "4.1.0",
47
+ "mocha": "8.4.0",
48
+ "nyc": "15.1.0"
51
49
  },
52
50
  "engines": {
53
51
  "node": ">= 0.6"
@@ -74,8 +72,9 @@
74
72
  "bench": "node benchmark/index.js",
75
73
  "lint": "eslint .",
76
74
  "test": "mocha --reporter spec --bail --check-leaks test/",
77
- "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/",
78
- "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/"
75
+ "test-ci": "nyc --reporter=lcov --reporter=text npm test",
76
+ "test-cov": "nyc --reporter=html --reporter=text npm test",
77
+ "version": "node scripts/version-history.js && git add HISTORY.md"
79
78
  },
80
- "version": "0.1.2"
79
+ "version": "0.2.0"
81
80
  }
@@ -1,3 +1,19 @@
1
+ 2021-11-14 / 1.8.1
2
+ ==================
3
+
4
+ * deps: toidentifier@1.0.1
5
+
6
+ 2020-06-29 / 1.8.0
7
+ ==================
8
+
9
+ * Add `isHttpError` export to determine if value is an HTTP error
10
+ * deps: setprototypeof@1.2.0
11
+
12
+ 2019-06-24 / 1.7.3
13
+ ==================
14
+
15
+ * deps: inherits@2.0.4
16
+
1
17
  2019-02-18 / 1.7.2
2
18
  ==================
3
19
 
@@ -3,7 +3,7 @@
3
3
  [![NPM Version][npm-version-image]][npm-url]
4
4
  [![NPM Downloads][npm-downloads-image]][node-url]
5
5
  [![Node.js Version][node-image]][node-url]
6
- [![Build Status][travis-image]][travis-url]
6
+ [![Build Status][ci-image]][ci-url]
7
7
  [![Test Coverage][coveralls-image]][coveralls-url]
8
8
 
9
9
  Create HTTP errors for Express, Koa, Connect, etc. with ease.
@@ -53,8 +53,6 @@ This is the current API, currently extracted from Koa and subject to change.
53
53
  Create a new error object with the given message `msg`.
54
54
  The error object inherits from `createError.HttpError`.
55
55
 
56
- <!-- eslint-disable no-undef, no-unused-vars -->
57
-
58
56
  ```js
59
57
  var err = createError(404, 'This video does not exist!')
60
58
  ```
@@ -70,7 +68,7 @@ properties. This will not alter the inheritance of the given
70
68
  `error` object, and the modified `error` object is the
71
69
  return value.
72
70
 
73
- <!-- eslint-disable no-redeclare, no-undef, no-unused-vars -->
71
+ <!-- eslint-disable no-redeclare -->
74
72
 
75
73
  ```js
76
74
  fs.readFile('foo.txt', function (err, buf) {
@@ -88,13 +86,19 @@ fs.readFile('foo.txt', function (err, buf) {
88
86
  - `error` - the error object to extend
89
87
  - `properties` - custom properties to attach to the object
90
88
 
89
+ ### createError.isHttpError(val)
90
+
91
+ Determine if the provided `val` is an `HttpError`. This will return `true`
92
+ if the error inherits from the `HttpError` constructor of this module or
93
+ matches the "duck type" for an error this module creates. All outputs from
94
+ the `createError` factory will return `true` for this function, including
95
+ if an non-`HttpError` was passed into the factory.
96
+
91
97
  ### new createError\[code || name\](\[msg]\))
92
98
 
93
99
  Create a new error object with the given message `msg`.
94
100
  The error object inherits from `createError.HttpError`.
95
101
 
96
- <!-- eslint-disable no-undef, no-unused-vars -->
97
-
98
102
  ```js
99
103
  var err = new createError.NotFound()
100
104
  ```
@@ -152,6 +156,8 @@ var err = new createError.NotFound()
152
156
 
153
157
  [MIT](LICENSE)
154
158
 
159
+ [ci-image]: https://badgen.net/github/checks/jshttp/http-errors/master?label=ci
160
+ [ci-url]: https://github.com/jshttp/http-errors/actions?query=workflow%3Aci
155
161
  [coveralls-image]: https://badgen.net/coveralls/c/github/jshttp/http-errors/master
156
162
  [coveralls-url]: https://coveralls.io/r/jshttp/http-errors?branch=master
157
163
  [node-image]: https://badgen.net/npm/node/http-errors
@@ -25,6 +25,7 @@ var toIdentifier = require('toidentifier')
25
25
 
26
26
  module.exports = createError
27
27
  module.exports.HttpError = createHttpErrorConstructor()
28
+ module.exports.isHttpError = createIsHttpErrorFunction(module.exports.HttpError)
28
29
 
29
30
  // Populate exports for all constructors
30
31
  populateConstructorExports(module.exports, statuses.codes, module.exports.HttpError)
@@ -130,7 +131,7 @@ function createHttpErrorConstructor () {
130
131
  */
131
132
 
132
133
  function createClientErrorConstructor (HttpError, name, code) {
133
- var className = name.match(/Error$/) ? name : name + 'Error'
134
+ var className = toClassName(name)
134
135
 
135
136
  function ClientError (message) {
136
137
  // create the error object
@@ -172,13 +173,34 @@ function createClientErrorConstructor (HttpError, name, code) {
172
173
  return ClientError
173
174
  }
174
175
 
176
+ /**
177
+ * Create function to test is a value is a HttpError.
178
+ * @private
179
+ */
180
+
181
+ function createIsHttpErrorFunction (HttpError) {
182
+ return function isHttpError (val) {
183
+ if (!val || typeof val !== 'object') {
184
+ return false
185
+ }
186
+
187
+ if (val instanceof HttpError) {
188
+ return true
189
+ }
190
+
191
+ return val instanceof Error &&
192
+ typeof val.expose === 'boolean' &&
193
+ typeof val.statusCode === 'number' && val.status === val.statusCode
194
+ }
195
+ }
196
+
175
197
  /**
176
198
  * Create a constructor for a server error.
177
199
  * @private
178
200
  */
179
201
 
180
202
  function createServerErrorConstructor (HttpError, name, code) {
181
- var className = name.match(/Error$/) ? name : name + 'Error'
203
+ var className = toClassName(name)
182
204
 
183
205
  function ServerError (message) {
184
206
  // create the error object
@@ -264,3 +286,14 @@ function populateConstructorExports (exports, codes, HttpError) {
264
286
  exports["I'mateapot"] = deprecate.function(exports.ImATeapot,
265
287
  '"I\'mateapot"; use "ImATeapot" instead')
266
288
  }
289
+
290
+ /**
291
+ * Get a class name from a name identifier.
292
+ * @private
293
+ */
294
+
295
+ function toClassName (name) {
296
+ return name.substr(-5) !== 'Error'
297
+ ? name + 'Error'
298
+ : name
299
+ }
@@ -1,34 +1,29 @@
1
1
  {
2
- "_args": [
3
- [
4
- "http-errors@1.7.2",
5
- "/Users/conway/Projects/worldmap"
6
- ]
7
- ],
8
- "_from": "http-errors@1.7.2",
9
- "_id": "http-errors@1.7.2",
2
+ "_from": "http-errors@1.8.1",
3
+ "_id": "http-errors@1.8.1",
10
4
  "_inBundle": false,
11
- "_integrity": "sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg==",
5
+ "_integrity": "sha512-Kpk9Sm7NmI+RHhnj6OIWDI1d6fIoFAtFt9RLaTMRlg/8w49juAStsrBgp0Dp4OdxdVbRIeKhtCUvoi/RuAhO4g==",
12
6
  "_location": "/http-errors",
13
7
  "_phantomChildren": {},
14
8
  "_requested": {
15
9
  "type": "version",
16
10
  "registry": true,
17
- "raw": "http-errors@1.7.2",
11
+ "raw": "http-errors@1.8.1",
18
12
  "name": "http-errors",
19
13
  "escapedName": "http-errors",
20
- "rawSpec": "1.7.2",
14
+ "rawSpec": "1.8.1",
21
15
  "saveSpec": null,
22
- "fetchSpec": "1.7.2"
16
+ "fetchSpec": "1.8.1"
23
17
  },
24
18
  "_requiredBy": [
25
19
  "/body-parser",
26
20
  "/raw-body",
27
21
  "/send"
28
22
  ],
29
- "_resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz",
30
- "_spec": "1.7.2",
31
- "_where": "/Users/conway/Projects/worldmap",
23
+ "_resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.8.1.tgz",
24
+ "_shasum": "7c3f28577cbc8a207388455dbd62295ed07bd68c",
25
+ "_spec": "http-errors@1.8.1",
26
+ "_where": "/Users/conway/Projects/worldmap/node_modules/body-parser",
32
27
  "author": {
33
28
  "name": "Jonathan Ong",
34
29
  "email": "me@jongleberry.com",
@@ -37,6 +32,7 @@
37
32
  "bugs": {
38
33
  "url": "https://github.com/jshttp/http-errors/issues"
39
34
  },
35
+ "bundleDependencies": false,
40
36
  "contributors": [
41
37
  {
42
38
  "name": "Alan Plum",
@@ -49,22 +45,23 @@
49
45
  ],
50
46
  "dependencies": {
51
47
  "depd": "~1.1.2",
52
- "inherits": "2.0.3",
53
- "setprototypeof": "1.1.1",
48
+ "inherits": "2.0.4",
49
+ "setprototypeof": "1.2.0",
54
50
  "statuses": ">= 1.5.0 < 2",
55
- "toidentifier": "1.0.0"
51
+ "toidentifier": "1.0.1"
56
52
  },
53
+ "deprecated": false,
57
54
  "description": "Create HTTP error objects",
58
55
  "devDependencies": {
59
- "eslint": "5.13.0",
60
- "eslint-config-standard": "12.0.0",
61
- "eslint-plugin-import": "2.16.0",
62
- "eslint-plugin-markdown": "1.0.0",
63
- "eslint-plugin-node": "7.0.1",
64
- "eslint-plugin-promise": "4.0.1",
65
- "eslint-plugin-standard": "4.0.0",
66
- "istanbul": "0.4.5",
67
- "mocha": "5.2.0"
56
+ "eslint": "7.32.0",
57
+ "eslint-config-standard": "14.1.1",
58
+ "eslint-plugin-import": "2.25.3",
59
+ "eslint-plugin-markdown": "2.2.1",
60
+ "eslint-plugin-node": "11.1.0",
61
+ "eslint-plugin-promise": "5.1.1",
62
+ "eslint-plugin-standard": "4.1.0",
63
+ "mocha": "9.1.3",
64
+ "nyc": "15.1.0"
68
65
  },
69
66
  "engines": {
70
67
  "node": ">= 0.6"
@@ -87,10 +84,10 @@
87
84
  "url": "git+https://github.com/jshttp/http-errors.git"
88
85
  },
89
86
  "scripts": {
90
- "lint": "eslint --plugin markdown --ext js,md . && node ./scripts/lint-readme-list.js",
87
+ "lint": "eslint . && node ./scripts/lint-readme-list.js",
91
88
  "test": "mocha --reporter spec --bail",
92
- "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot",
93
- "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter dot"
89
+ "test-ci": "nyc --reporter=lcov --reporter=text npm test",
90
+ "test-cov": "nyc --reporter=html --reporter=text npm test"
94
91
  },
95
- "version": "1.7.2"
92
+ "version": "1.8.1"
96
93
  }
@@ -0,0 +1,39 @@
1
+ ![Node](https://github.com/creationix/http-parser-js/workflows/Node/badge.svg)
2
+ ![Node-v12](https://github.com/creationix/http-parser-js/workflows/Node-v12/badge.svg)
3
+
4
+ # HTTP Parser
5
+
6
+ This library parses HTTP protocol for requests and responses.
7
+ It was created to replace `http_parser.c` since calling C++ functions from JS is really slow in V8.
8
+ However, it is now primarily useful in having a more flexible/tolerant HTTP parser when dealing with legacy services that do not meet the strict HTTP parsing rules Node's parser follows.
9
+
10
+ This is packaged as a standalone npm module.
11
+ To use in node, monkeypatch HTTPParser.
12
+
13
+ ```js
14
+ // Monkey patch before you require http for the first time.
15
+ process.binding('http_parser').HTTPParser = require('http-parser-js').HTTPParser;
16
+
17
+ var http = require('http');
18
+ // ...
19
+ ```
20
+
21
+ ## Testing
22
+
23
+ Simply run `npm test`.
24
+ The tests are copied from node and mscedex/io.js, with some modifcations.
25
+
26
+ ## Status
27
+
28
+ This should now be usable in any node application, it now supports (nearly) everything `http_parser.c` does while still being tolerant with corrupted headers, and other kinds of malformed data.
29
+
30
+ ### Node versions
31
+
32
+ `http-parser-js` should work via monkey-patching on Node v6-v11, and v13-14.
33
+
34
+ Node v12.x renamed the internal http parser, and did not expose it for monkey-patching, so to be able to monkey-patch on Node v12, you must run `node --http-parser=legacy file.js` to opt in to the old, monkey-patchable http_parser binding.
35
+
36
+ ## License
37
+
38
+ MIT.
39
+ See [LICENSE.md](LICENSE.md)