fsevents 1.0.5 → 1.0.6

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.

Potentially problematic release.


This version of fsevents might be problematic. Click here for more details.

Files changed (360) hide show
  1. package/Readme.md +12 -13
  2. package/node_modules/ansi/package.json +1 -2
  3. package/node_modules/are-we-there-yet/package.json +1 -2
  4. package/node_modules/asn1/.travis.yml +4 -0
  5. package/node_modules/asn1/lib/ber/reader.js +27 -33
  6. package/node_modules/asn1/lib/ber/writer.js +10 -11
  7. package/node_modules/asn1/package.json +21 -19
  8. package/node_modules/asn1/tst/ber/reader.test.js +36 -0
  9. package/node_modules/asn1/tst/ber/writer.test.js +74 -0
  10. package/node_modules/assert-plus/package.json +1 -0
  11. package/node_modules/{ctype → bl/node_modules/readable-stream/node_modules/core-util-is}/LICENSE +1 -6
  12. package/node_modules/bl/node_modules/readable-stream/node_modules/core-util-is/lib/util.js +11 -11
  13. package/node_modules/bl/node_modules/readable-stream/node_modules/core-util-is/package.json +17 -12
  14. package/node_modules/bl/node_modules/readable-stream/node_modules/core-util-is/test.js +68 -0
  15. package/node_modules/boom/package.json +1 -1
  16. package/node_modules/commander/package.json +1 -1
  17. package/node_modules/core-util-is/LICENSE +19 -0
  18. package/node_modules/core-util-is/lib/util.js +11 -11
  19. package/node_modules/core-util-is/package.json +17 -12
  20. package/node_modules/core-util-is/test.js +68 -0
  21. package/node_modules/dashdash/README.md +508 -0
  22. package/node_modules/dashdash/lib/dashdash.js +813 -0
  23. package/node_modules/dashdash/package.json +87 -0
  24. package/node_modules/deep-extend/LICENSE +1 -1
  25. package/node_modules/deep-extend/README.md +89 -52
  26. package/node_modules/deep-extend/index.js +1 -90
  27. package/node_modules/deep-extend/lib/deep-extend.js +144 -0
  28. package/node_modules/deep-extend/package.json +47 -16
  29. package/node_modules/deep-extend/test/index.spec.js +168 -5
  30. package/node_modules/delegates/package.json +1 -2
  31. package/node_modules/ecc-jsbn/.npmignore +15 -0
  32. package/node_modules/ecc-jsbn/LICENSE +21 -0
  33. package/node_modules/ecc-jsbn/README.md +8 -0
  34. package/node_modules/ecc-jsbn/index.js +57 -0
  35. package/node_modules/ecc-jsbn/lib/LICENSE-jsbn +40 -0
  36. package/node_modules/ecc-jsbn/lib/ec.js +561 -0
  37. package/node_modules/ecc-jsbn/lib/sec.js +170 -0
  38. package/node_modules/ecc-jsbn/package.json +63 -0
  39. package/node_modules/ecc-jsbn/test.js +14 -0
  40. package/node_modules/extsprintf/.gitmodules +6 -0
  41. package/node_modules/{path-is-absolute/license → extsprintf/LICENSE} +2 -4
  42. package/node_modules/extsprintf/Makefile +23 -0
  43. package/node_modules/extsprintf/Makefile.deps +39 -0
  44. package/node_modules/extsprintf/Makefile.targ +285 -0
  45. package/node_modules/extsprintf/README.md +39 -0
  46. package/node_modules/extsprintf/examples/simple.js +2 -0
  47. package/node_modules/{ctype/tools/jsl.conf → extsprintf/jsl.node.conf} +71 -63
  48. package/node_modules/extsprintf/lib/extsprintf.js +166 -0
  49. package/node_modules/extsprintf/package.json +48 -0
  50. package/node_modules/fstream/package.json +1 -2
  51. package/node_modules/{balanced-match → fstream-ignore/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match}/package.json +4 -22
  52. package/node_modules/{concat-map → fstream-ignore/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map}/package.json +3 -21
  53. package/node_modules/{brace-expansion → fstream-ignore/node_modules/minimatch/node_modules/brace-expansion}/package.json +4 -23
  54. package/node_modules/fstream-ignore/node_modules/minimatch/package.json +4 -24
  55. package/node_modules/fstream-ignore/package.json +1 -2
  56. package/node_modules/gauge/package.json +1 -2
  57. package/node_modules/har-validator/package.json +15 -15
  58. package/node_modules/has-unicode/package.json +1 -2
  59. package/node_modules/hawk/dist/client.js +340 -0
  60. package/node_modules/hawk/lib/browser.js +14 -20
  61. package/node_modules/hawk/package.json +10 -10
  62. package/node_modules/hawk/test/browser.js +134 -101
  63. package/node_modules/hawk/test/index.js +61 -61
  64. package/node_modules/hawk/test/server.js +72 -84
  65. package/node_modules/hawk/test/uri.js +52 -63
  66. package/node_modules/http-signature/CHANGES.md +39 -0
  67. package/node_modules/http-signature/http_signing.md +16 -17
  68. package/node_modules/http-signature/lib/index.js +6 -4
  69. package/node_modules/http-signature/lib/parser.js +43 -29
  70. package/node_modules/http-signature/lib/signer.js +290 -74
  71. package/node_modules/http-signature/lib/utils.js +112 -0
  72. package/node_modules/http-signature/lib/verify.js +47 -15
  73. package/node_modules/http-signature/package.json +20 -14
  74. package/node_modules/is-my-json-valid/index.js +16 -14
  75. package/node_modules/is-my-json-valid/package.json +16 -12
  76. package/node_modules/is-typedarray/LICENSE.md +18 -0
  77. package/node_modules/is-typedarray/README.md +16 -0
  78. package/node_modules/is-typedarray/index.js +41 -0
  79. package/node_modules/is-typedarray/package.json +63 -0
  80. package/node_modules/is-typedarray/test.js +34 -0
  81. package/node_modules/jodid25519/.npmignore +11 -0
  82. package/node_modules/jodid25519/.travis.yml +7 -0
  83. package/node_modules/jodid25519/AUTHORS.md +3 -0
  84. package/node_modules/jodid25519/LICENSE +23 -0
  85. package/node_modules/jodid25519/README.md +51 -0
  86. package/node_modules/jodid25519/almond.0 +42 -0
  87. package/node_modules/jodid25519/almond.1 +13 -0
  88. package/node_modules/jodid25519/index.js +35 -0
  89. package/node_modules/jodid25519/jsdoc.json +19 -0
  90. package/node_modules/jodid25519/lib/core.js +481 -0
  91. package/node_modules/jodid25519/lib/curve255.js +221 -0
  92. package/node_modules/jodid25519/lib/dh.js +111 -0
  93. package/node_modules/jodid25519/lib/eddsa.js +573 -0
  94. package/node_modules/jodid25519/lib/utils.js +198 -0
  95. package/node_modules/jodid25519/package.json +77 -0
  96. package/node_modules/jsbn/.npmignore +2 -0
  97. package/node_modules/jsbn/LICENSE +40 -0
  98. package/node_modules/jsbn/README.md +175 -0
  99. package/node_modules/jsbn/example.html +12 -0
  100. package/node_modules/jsbn/example.js +3 -0
  101. package/node_modules/jsbn/index.js +1358 -0
  102. package/node_modules/jsbn/package.json +60 -0
  103. package/node_modules/json-schema/README.md +5 -0
  104. package/node_modules/json-schema/draft-00/hyper-schema +68 -0
  105. package/node_modules/json-schema/draft-00/json-ref +26 -0
  106. package/node_modules/json-schema/draft-00/links +33 -0
  107. package/node_modules/json-schema/draft-00/schema +155 -0
  108. package/node_modules/json-schema/draft-01/hyper-schema +68 -0
  109. package/node_modules/json-schema/draft-01/json-ref +26 -0
  110. package/node_modules/json-schema/draft-01/links +33 -0
  111. package/node_modules/json-schema/draft-01/schema +155 -0
  112. package/node_modules/json-schema/draft-02/hyper-schema +68 -0
  113. package/node_modules/json-schema/draft-02/json-ref +26 -0
  114. package/node_modules/json-schema/draft-02/links +35 -0
  115. package/node_modules/json-schema/draft-02/schema +166 -0
  116. package/node_modules/json-schema/draft-03/examples/address +20 -0
  117. package/node_modules/json-schema/draft-03/examples/calendar +53 -0
  118. package/node_modules/json-schema/draft-03/examples/card +105 -0
  119. package/node_modules/json-schema/draft-03/examples/geo +8 -0
  120. package/node_modules/json-schema/draft-03/examples/interfaces +23 -0
  121. package/node_modules/json-schema/draft-03/hyper-schema +60 -0
  122. package/node_modules/json-schema/draft-03/json-ref +26 -0
  123. package/node_modules/json-schema/draft-03/links +35 -0
  124. package/node_modules/json-schema/draft-03/schema +174 -0
  125. package/node_modules/json-schema/draft-04/hyper-schema +60 -0
  126. package/node_modules/json-schema/draft-04/links +41 -0
  127. package/node_modules/json-schema/draft-04/schema +189 -0
  128. package/node_modules/json-schema/draft-zyp-json-schema-03.xml +1120 -0
  129. package/node_modules/json-schema/draft-zyp-json-schema-04.xml +1072 -0
  130. package/node_modules/json-schema/lib/links.js +52 -0
  131. package/node_modules/json-schema/lib/validate.js +260 -0
  132. package/node_modules/json-schema/package.json +67 -0
  133. package/node_modules/json-schema/test/tests.js +95 -0
  134. package/node_modules/jsprim/CHANGES.md +30 -0
  135. package/node_modules/jsprim/LICENSE +19 -0
  136. package/node_modules/jsprim/README.md +228 -0
  137. package/node_modules/jsprim/lib/jsprim.js +478 -0
  138. package/node_modules/jsprim/package.json +54 -0
  139. package/node_modules/lodash._basetostring/package.json +1 -2
  140. package/node_modules/lodash._createpadding/package.json +1 -2
  141. package/node_modules/lodash.pad/package.json +1 -2
  142. package/node_modules/lodash.padleft/package.json +1 -2
  143. package/node_modules/lodash.padright/package.json +1 -2
  144. package/node_modules/lodash.repeat/package.json +1 -2
  145. package/node_modules/node-pre-gyp/CHANGELOG.md +8 -0
  146. package/node_modules/node-pre-gyp/README.md +570 -0
  147. package/node_modules/node-pre-gyp/lib/util/abi_crosswalk.json +4 -0
  148. package/node_modules/node-pre-gyp/node_modules/nopt/lib/nopt.js +2 -1
  149. package/node_modules/{abbrev → node-pre-gyp/node_modules/nopt/node_modules/abbrev}/package.json +30 -37
  150. package/node_modules/node-pre-gyp/node_modules/nopt/package.json +37 -57
  151. package/node_modules/node-pre-gyp/node_modules/nopt/test/basic.js +22 -0
  152. package/node_modules/node-pre-gyp/package.json +17 -17
  153. package/node_modules/node-uuid/.npmignore +2 -0
  154. package/node_modules/node-uuid/README.md +12 -1
  155. package/node_modules/node-uuid/bower.json +1 -1
  156. package/node_modules/node-uuid/component.json +11 -4
  157. package/node_modules/node-uuid/package.json +25 -12
  158. package/node_modules/node-uuid/test/test.js +3 -0
  159. package/node_modules/node-uuid/uuid.js +70 -45
  160. package/node_modules/npmlog/.travis.yml +14 -0
  161. package/node_modules/npmlog/log.js +3 -0
  162. package/node_modules/npmlog/package.json +23 -20
  163. package/node_modules/npmlog/test/basic.js +8 -1
  164. package/node_modules/once/package.json +2 -3
  165. package/node_modules/pinkie/index.js +23 -7
  166. package/node_modules/pinkie/package.json +22 -15
  167. package/node_modules/pinkie/readme.md +17 -9
  168. package/node_modules/pinkie-promise/package.json +16 -14
  169. package/node_modules/pinkie-promise/readme.md +5 -3
  170. package/node_modules/rc/README.md +1 -1
  171. package/node_modules/rc/index.js +1 -1
  172. package/node_modules/rc/node_modules/minimist/package.json +1 -1
  173. package/node_modules/rc/package.json +12 -12
  174. package/node_modules/request/.eslintrc +1 -1
  175. package/node_modules/request/.travis.yml +4 -4
  176. package/node_modules/request/CHANGELOG.md +25 -0
  177. package/node_modules/request/README.md +12 -13
  178. package/node_modules/request/lib/har.js +84 -75
  179. package/node_modules/request/lib/redirect.js +2 -3
  180. package/node_modules/request/lib/tunnel.js +13 -18
  181. package/node_modules/request/package.json +17 -16
  182. package/node_modules/request/request.js +16 -59
  183. package/node_modules/rimraf/README.md +7 -2
  184. package/node_modules/{wrappy → rimraf/node_modules/glob/node_modules/inflight/node_modules/wrappy}/package.json +5 -25
  185. package/node_modules/{inflight → rimraf/node_modules/glob/node_modules/inflight}/package.json +5 -25
  186. package/node_modules/rimraf/node_modules/glob/node_modules/inherits/LICENSE +16 -0
  187. package/node_modules/rimraf/node_modules/glob/node_modules/inherits/README.md +42 -0
  188. package/node_modules/rimraf/node_modules/glob/node_modules/inherits/inherits.js +1 -0
  189. package/node_modules/rimraf/node_modules/glob/node_modules/inherits/inherits_browser.js +23 -0
  190. package/node_modules/rimraf/node_modules/glob/node_modules/inherits/package.json +58 -0
  191. package/node_modules/rimraf/node_modules/glob/node_modules/inherits/test.js +25 -0
  192. package/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/.npmignore +3 -0
  193. package/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/README.md +122 -0
  194. package/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/example.js +8 -0
  195. package/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/index.js +191 -0
  196. package/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/.npmignore +2 -0
  197. package/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/.travis.yml +3 -0
  198. package/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/LICENSE.md +21 -0
  199. package/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/Makefile +6 -0
  200. package/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/README.md +80 -0
  201. package/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/example.js +5 -0
  202. package/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/index.js +38 -0
  203. package/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/package.json +79 -0
  204. package/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/test/balanced.js +56 -0
  205. package/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/.travis.yml +4 -0
  206. package/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/LICENSE +18 -0
  207. package/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/README.markdown +62 -0
  208. package/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/example/map.js +6 -0
  209. package/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/index.js +13 -0
  210. package/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/package.json +90 -0
  211. package/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/test/map.js +39 -0
  212. package/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/package.json +81 -0
  213. package/node_modules/rimraf/node_modules/{minimatch → glob/node_modules/minimatch}/package.json +3 -21
  214. package/node_modules/rimraf/node_modules/glob/node_modules/once/node_modules/wrappy/README.md +36 -0
  215. package/node_modules/rimraf/node_modules/glob/node_modules/once/node_modules/wrappy/package.json +58 -0
  216. package/node_modules/rimraf/node_modules/glob/node_modules/once/node_modules/wrappy/test/basic.js +51 -0
  217. package/node_modules/rimraf/node_modules/glob/node_modules/once/node_modules/wrappy/wrappy.js +33 -0
  218. package/node_modules/rimraf/node_modules/glob/node_modules/once/package.json +70 -0
  219. package/node_modules/{path-is-absolute → rimraf/node_modules/glob/node_modules/path-is-absolute}/package.json +4 -22
  220. package/node_modules/rimraf/node_modules/glob/package.json +2 -20
  221. package/node_modules/rimraf/package.json +10 -10
  222. package/node_modules/semver/README.md +25 -1
  223. package/node_modules/semver/package.json +10 -10
  224. package/node_modules/semver/range.bnf +16 -0
  225. package/node_modules/semver/semver.js +0 -12
  226. package/node_modules/sshpk/.npmignore +8 -0
  227. package/node_modules/sshpk/.travis.yml +11 -0
  228. package/node_modules/sshpk/LICENSE +18 -0
  229. package/node_modules/sshpk/README.md +436 -0
  230. package/node_modules/sshpk/bin/sshpk-conv +183 -0
  231. package/node_modules/sshpk/lib/algs.js +168 -0
  232. package/node_modules/sshpk/lib/dhe.js +312 -0
  233. package/node_modules/sshpk/lib/ed-compat.js +94 -0
  234. package/node_modules/sshpk/lib/errors.js +58 -0
  235. package/node_modules/sshpk/lib/fingerprint.js +140 -0
  236. package/node_modules/sshpk/lib/formats/auto.js +73 -0
  237. package/node_modules/sshpk/lib/formats/pem.js +152 -0
  238. package/node_modules/sshpk/lib/formats/pkcs1.js +320 -0
  239. package/node_modules/sshpk/lib/formats/pkcs8.js +510 -0
  240. package/node_modules/sshpk/lib/formats/rfc4253.js +145 -0
  241. package/node_modules/sshpk/lib/formats/ssh-private.js +138 -0
  242. package/node_modules/sshpk/lib/formats/ssh.js +114 -0
  243. package/node_modules/sshpk/lib/index.js +25 -0
  244. package/node_modules/sshpk/lib/key.js +260 -0
  245. package/node_modules/sshpk/lib/private-key.js +224 -0
  246. package/node_modules/sshpk/lib/signature.js +237 -0
  247. package/node_modules/sshpk/lib/ssh-buffer.js +123 -0
  248. package/node_modules/sshpk/lib/utils.js +207 -0
  249. package/node_modules/sshpk/node_modules/assert-plus/AUTHORS +6 -0
  250. package/node_modules/sshpk/node_modules/assert-plus/CHANGES.md +8 -0
  251. package/node_modules/sshpk/node_modules/assert-plus/README.md +155 -0
  252. package/node_modules/sshpk/node_modules/assert-plus/assert.js +206 -0
  253. package/node_modules/sshpk/node_modules/assert-plus/package.json +88 -0
  254. package/node_modules/sshpk/package.json +92 -0
  255. package/node_modules/strip-json-comments/cli.js +2 -2
  256. package/node_modules/strip-json-comments/package.json +13 -12
  257. package/node_modules/strip-json-comments/readme.md +11 -5
  258. package/node_modules/strip-json-comments/strip-json-comments.js +16 -7
  259. package/node_modules/tar/package.json +1 -2
  260. package/node_modules/tar-pack/node_modules/readable-stream/node_modules/core-util-is/LICENSE +19 -0
  261. package/node_modules/tar-pack/node_modules/readable-stream/node_modules/core-util-is/lib/util.js +11 -11
  262. package/node_modules/tar-pack/node_modules/readable-stream/node_modules/core-util-is/package.json +17 -12
  263. package/node_modules/tar-pack/node_modules/readable-stream/node_modules/core-util-is/test.js +68 -0
  264. package/node_modules/tar-pack/node_modules/readable-stream/node_modules/inherits/package.json +1 -1
  265. package/node_modules/tar-pack/node_modules/rimraf/package.json +1 -2
  266. package/node_modules/tar-pack/package.json +1 -2
  267. package/node_modules/tough-cookie/lib/cookie.js +1 -1
  268. package/node_modules/tough-cookie/package.json +7 -7
  269. package/node_modules/tweetnacl/.npmignore +4 -0
  270. package/node_modules/tweetnacl/CHANGELOG.md +128 -0
  271. package/node_modules/tweetnacl/README.md +463 -0
  272. package/node_modules/tweetnacl/nacl-fast.js +2418 -0
  273. package/node_modules/tweetnacl/nacl-fast.min.js +2 -0
  274. package/node_modules/tweetnacl/nacl.js +1205 -0
  275. package/node_modules/tweetnacl/nacl.min.js +1 -0
  276. package/node_modules/tweetnacl/package.json +101 -0
  277. package/node_modules/uid-number/package.json +2 -3
  278. package/node_modules/verror/.gitmodules +0 -0
  279. package/node_modules/verror/LICENSE +19 -0
  280. package/node_modules/verror/Makefile +35 -0
  281. package/node_modules/verror/Makefile.targ +285 -0
  282. package/node_modules/verror/README.md +120 -0
  283. package/node_modules/verror/examples/levels-verror.js +36 -0
  284. package/node_modules/verror/examples/levels-werror.js +34 -0
  285. package/node_modules/verror/examples/varargs.js +6 -0
  286. package/node_modules/verror/examples/verror.js +13 -0
  287. package/node_modules/verror/examples/werror.js +14 -0
  288. package/node_modules/verror/jsl.node.conf +139 -0
  289. package/node_modules/verror/lib/verror.js +157 -0
  290. package/node_modules/verror/package.json +51 -0
  291. package/node_modules/verror/tests/tst.inherit.js +100 -0
  292. package/node_modules/verror/tests/tst.verror.js +156 -0
  293. package/node_modules/verror/tests/tst.werror.js +179 -0
  294. package/package.json +3 -3
  295. package/node_modules/bl/node_modules/readable-stream/node_modules/core-util-is/util.js +0 -106
  296. package/node_modules/core-util-is/util.js +0 -106
  297. package/node_modules/ctype/.npmignore +0 -1
  298. package/node_modules/ctype/CHANGELOG +0 -78
  299. package/node_modules/ctype/README +0 -82
  300. package/node_modules/ctype/README.old +0 -298
  301. package/node_modules/ctype/ctf.js +0 -245
  302. package/node_modules/ctype/ctio.js +0 -1485
  303. package/node_modules/ctype/ctype.js +0 -944
  304. package/node_modules/ctype/man/man3ctype/ctio.3ctype +0 -241
  305. package/node_modules/ctype/package.json +0 -51
  306. package/node_modules/ctype/tools/jsstyle +0 -839
  307. package/node_modules/http-signature/lib/util.js +0 -306
  308. package/node_modules/inflight/node_modules/once/package.json +0 -86
  309. package/node_modules/inflight/node_modules/once/test/once.js +0 -23
  310. package/node_modules/rimraf/node_modules/glob/LICENSE +0 -15
  311. package/node_modules/rimraf/node_modules/minimatch/LICENSE +0 -15
  312. package/node_modules/rimraf/node_modules/once/LICENSE +0 -15
  313. package/node_modules/rimraf/node_modules/once/README.md +0 -51
  314. package/node_modules/rimraf/node_modules/once/once.js +0 -21
  315. package/node_modules/rimraf/node_modules/once/package.json +0 -84
  316. package/node_modules/rimraf/node_modules/once/test/once.js +0 -23
  317. package/node_modules/tar-pack/node_modules/readable-stream/node_modules/core-util-is/util.js +0 -106
  318. package/node_modules/wrappy/LICENSE +0 -15
  319. /package/node_modules/{brace-expansion → fstream-ignore/node_modules/minimatch/node_modules/brace-expansion}/.npmignore +0 -0
  320. /package/node_modules/{brace-expansion → fstream-ignore/node_modules/minimatch/node_modules/brace-expansion}/README.md +0 -0
  321. /package/node_modules/{brace-expansion → fstream-ignore/node_modules/minimatch/node_modules/brace-expansion}/example.js +0 -0
  322. /package/node_modules/{brace-expansion → fstream-ignore/node_modules/minimatch/node_modules/brace-expansion}/index.js +0 -0
  323. /package/node_modules/{balanced-match → fstream-ignore/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match}/.npmignore +0 -0
  324. /package/node_modules/{balanced-match → fstream-ignore/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match}/.travis.yml +0 -0
  325. /package/node_modules/{balanced-match → fstream-ignore/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match}/LICENSE.md +0 -0
  326. /package/node_modules/{balanced-match → fstream-ignore/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match}/Makefile +0 -0
  327. /package/node_modules/{balanced-match → fstream-ignore/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match}/README.md +0 -0
  328. /package/node_modules/{balanced-match → fstream-ignore/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match}/example.js +0 -0
  329. /package/node_modules/{balanced-match → fstream-ignore/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match}/index.js +0 -0
  330. /package/node_modules/{balanced-match → fstream-ignore/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match}/test/balanced.js +0 -0
  331. /package/node_modules/{concat-map → fstream-ignore/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map}/.travis.yml +0 -0
  332. /package/node_modules/{concat-map → fstream-ignore/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map}/LICENSE +0 -0
  333. /package/node_modules/{concat-map → fstream-ignore/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map}/README.markdown +0 -0
  334. /package/node_modules/{concat-map → fstream-ignore/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map}/example/map.js +0 -0
  335. /package/node_modules/{concat-map → fstream-ignore/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map}/index.js +0 -0
  336. /package/node_modules/{concat-map → fstream-ignore/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map}/test/map.js +0 -0
  337. /package/node_modules/{abbrev → node-pre-gyp/node_modules/nopt/node_modules/abbrev}/.npmignore +0 -0
  338. /package/node_modules/{abbrev → node-pre-gyp/node_modules/nopt/node_modules/abbrev}/.travis.yml +0 -0
  339. /package/node_modules/{abbrev → node-pre-gyp/node_modules/nopt/node_modules/abbrev}/CONTRIBUTING.md +0 -0
  340. /package/node_modules/{abbrev → node-pre-gyp/node_modules/nopt/node_modules/abbrev}/LICENSE +0 -0
  341. /package/node_modules/{abbrev → node-pre-gyp/node_modules/nopt/node_modules/abbrev}/README.md +0 -0
  342. /package/node_modules/{abbrev → node-pre-gyp/node_modules/nopt/node_modules/abbrev}/abbrev.js +0 -0
  343. /package/node_modules/{abbrev → node-pre-gyp/node_modules/nopt/node_modules/abbrev}/test.js +0 -0
  344. /package/node_modules/{inflight → rimraf/node_modules/glob/node_modules/inflight}/.eslintrc +0 -0
  345. /package/node_modules/{inflight → rimraf/node_modules/glob/node_modules/inflight}/LICENSE +0 -0
  346. /package/node_modules/{inflight → rimraf/node_modules/glob/node_modules/inflight}/README.md +0 -0
  347. /package/node_modules/{inflight → rimraf/node_modules/glob/node_modules/inflight}/inflight.js +0 -0
  348. /package/node_modules/{fstream-ignore/node_modules/minimatch → rimraf/node_modules/glob/node_modules/inflight/node_modules/wrappy}/LICENSE +0 -0
  349. /package/node_modules/{wrappy → rimraf/node_modules/glob/node_modules/inflight/node_modules/wrappy}/README.md +0 -0
  350. /package/node_modules/{wrappy → rimraf/node_modules/glob/node_modules/inflight/node_modules/wrappy}/test/basic.js +0 -0
  351. /package/node_modules/{wrappy → rimraf/node_modules/glob/node_modules/inflight/node_modules/wrappy}/wrappy.js +0 -0
  352. /package/node_modules/{inflight → rimraf/node_modules/glob/node_modules/inflight}/test.js +0 -0
  353. /package/node_modules/rimraf/node_modules/{minimatch → glob/node_modules/minimatch}/README.md +0 -0
  354. /package/node_modules/rimraf/node_modules/{minimatch → glob/node_modules/minimatch}/minimatch.js +0 -0
  355. /package/node_modules/{inflight → rimraf/node_modules/glob}/node_modules/once/README.md +0 -0
  356. /package/node_modules/{inflight/node_modules/once → rimraf/node_modules/glob/node_modules/once/node_modules/wrappy}/LICENSE +0 -0
  357. /package/node_modules/{inflight → rimraf/node_modules/glob}/node_modules/once/once.js +0 -0
  358. /package/node_modules/{path-is-absolute → rimraf/node_modules/glob/node_modules/path-is-absolute}/index.js +0 -0
  359. /package/node_modules/{path-is-absolute → rimraf/node_modules/glob/node_modules/path-is-absolute}/readme.md +0 -0
  360. /package/node_modules/{deep-extend → verror}/.npmignore +0 -0
@@ -3,88 +3,252 @@
3
3
  var assert = require('assert-plus');
4
4
  var crypto = require('crypto');
5
5
  var http = require('http');
6
+ var util = require('util');
7
+ var sshpk = require('sshpk');
8
+ var jsprim = require('jsprim');
9
+ var utils = require('./utils');
6
10
 
7
11
  var sprintf = require('util').format;
8
12
 
9
-
13
+ var HASH_ALGOS = utils.HASH_ALGOS;
14
+ var PK_ALGOS = utils.PK_ALGOS;
15
+ var InvalidAlgorithmError = utils.InvalidAlgorithmError;
16
+ var HttpSignatureError = utils.HttpSignatureError;
17
+ var validateAlgorithm = utils.validateAlgorithm;
10
18
 
11
19
  ///--- Globals
12
20
 
13
- var Algorithms = {
14
- 'rsa-sha1': true,
15
- 'rsa-sha256': true,
16
- 'rsa-sha512': true,
17
- 'dsa-sha1': true,
18
- 'hmac-sha1': true,
19
- 'hmac-sha256': true,
20
- 'hmac-sha512': true
21
- };
22
-
23
- var Authorization =
21
+ var AUTHZ_FMT =
24
22
  'Signature keyId="%s",algorithm="%s",headers="%s",signature="%s"';
25
23
 
26
-
27
-
28
24
  ///--- Specific Errors
29
25
 
30
26
  function MissingHeaderError(message) {
31
- this.name = 'MissingHeaderError';
32
- this.message = message;
33
- this.stack = (new Error()).stack;
27
+ HttpSignatureError.call(this, message, MissingHeaderError);
34
28
  }
35
- MissingHeaderError.prototype = new Error();
36
-
29
+ util.inherits(MissingHeaderError, HttpSignatureError);
37
30
 
38
- function InvalidAlgorithmError(message) {
39
- this.name = 'InvalidAlgorithmError';
40
- this.message = message;
41
- this.stack = (new Error()).stack;
31
+ function StrictParsingError(message) {
32
+ HttpSignatureError.call(this, message, StrictParsingError);
42
33
  }
43
- InvalidAlgorithmError.prototype = new Error();
34
+ util.inherits(StrictParsingError, HttpSignatureError);
35
+
36
+ /* See createSigner() */
37
+ function RequestSigner(options) {
38
+ assert.object(options, 'options');
44
39
 
40
+ var alg = [];
41
+ if (options.algorithm !== undefined) {
42
+ assert.string(options.algorithm, 'options.algorithm');
43
+ alg = validateAlgorithm(options.algorithm);
44
+ }
45
+ this.rs_alg = alg;
45
46
 
47
+ /*
48
+ * RequestSigners come in two varieties: ones with an rs_signFunc, and ones
49
+ * with an rs_signer.
50
+ *
51
+ * rs_signFunc-based RequestSigners have to build up their entire signing
52
+ * string within the rs_lines array and give it to rs_signFunc as a single
53
+ * concat'd blob. rs_signer-based RequestSigners can add a line at a time to
54
+ * their signing state by using rs_signer.update(), thus only needing to
55
+ * buffer the hash function state and one line at a time.
56
+ */
57
+ if (options.sign !== undefined) {
58
+ assert.func(options.sign, 'options.sign');
59
+ this.rs_signFunc = options.sign;
46
60
 
47
- ///--- Internal Functions
61
+ } else if (alg[0] === 'hmac' && options.key !== undefined) {
62
+ assert.string(options.keyId, 'options.keyId');
63
+ this.rs_keyId = options.keyId;
64
+
65
+ if (typeof (options.key) !== 'string' && !Buffer.isBuffer(options.key))
66
+ throw (new TypeError('options.key for HMAC must be a string or Buffer'));
67
+
68
+ /*
69
+ * Make an rs_signer for HMACs, not a rs_signFunc -- HMACs digest their
70
+ * data in chunks rather than requiring it all to be given in one go
71
+ * at the end, so they are more similar to signers than signFuncs.
72
+ */
73
+ this.rs_signer = crypto.createHmac(alg[1].toUpperCase(), options.key);
74
+ this.rs_signer.sign = function () {
75
+ var digest = this.digest('base64');
76
+ return ({
77
+ hashAlgorithm: alg[1],
78
+ toString: function () { return (digest); }
79
+ });
80
+ };
81
+
82
+ } else if (options.key !== undefined) {
83
+ var key = options.key;
84
+ if (typeof (key) === 'string' || Buffer.isBuffer(key))
85
+ key = sshpk.parsePrivateKey(key);
86
+
87
+ assert.ok(sshpk.PrivateKey.isPrivateKey(key, [1, 2]),
88
+ 'options.key must be a sshpk.PrivateKey');
89
+ this.rs_key = key;
48
90
 
49
- function _pad(val) {
50
- if (parseInt(val, 10) < 10) {
51
- val = '0' + val;
91
+ assert.string(options.keyId, 'options.keyId');
92
+ this.rs_keyId = options.keyId;
93
+
94
+ if (!PK_ALGOS[key.type]) {
95
+ throw (new InvalidAlgorithmError(key.type.toUpperCase() + ' type ' +
96
+ 'keys are not supported'));
97
+ }
98
+
99
+ if (alg[0] !== undefined && key.type !== alg[0]) {
100
+ throw (new InvalidAlgorithmError('options.key must be a ' +
101
+ alg[0].toUpperCase() + ' key, was given a ' +
102
+ key.type.toUpperCase() + ' key instead'));
103
+ }
104
+
105
+ this.rs_signer = key.createSign(alg[1]);
106
+
107
+ } else {
108
+ throw (new TypeError('options.sign (func) or options.key is required'));
52
109
  }
53
- return val;
110
+
111
+ this.rs_headers = [];
112
+ this.rs_lines = [];
54
113
  }
55
114
 
115
+ /**
116
+ * Adds a header to be signed, with its value, into this signer.
117
+ *
118
+ * @param {String} header
119
+ * @param {String} value
120
+ * @return {String} value written
121
+ */
122
+ RequestSigner.prototype.writeHeader = function (header, value) {
123
+ assert.string(header, 'header');
124
+ header = header.toLowerCase();
125
+ assert.string(value, 'value');
126
+
127
+ this.rs_headers.push(header);
128
+
129
+ if (this.rs_signFunc) {
130
+ this.rs_lines.push(header + ': ' + value);
131
+
132
+ } else {
133
+ var line = header + ': ' + value;
134
+ if (this.rs_headers.length > 0)
135
+ line = '\n' + line;
136
+ this.rs_signer.update(line);
137
+ }
56
138
 
57
- function _rfc1123() {
58
- var date = new Date();
59
-
60
- var months = ['Jan',
61
- 'Feb',
62
- 'Mar',
63
- 'Apr',
64
- 'May',
65
- 'Jun',
66
- 'Jul',
67
- 'Aug',
68
- 'Sep',
69
- 'Oct',
70
- 'Nov',
71
- 'Dec'];
72
- var days = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
73
- return days[date.getUTCDay()] + ', ' +
74
- _pad(date.getUTCDate()) + ' ' +
75
- months[date.getUTCMonth()] + ' ' +
76
- date.getUTCFullYear() + ' ' +
77
- _pad(date.getUTCHours()) + ':' +
78
- _pad(date.getUTCMinutes()) + ':' +
79
- _pad(date.getUTCSeconds()) +
80
- ' GMT';
81
- }
139
+ return (value);
140
+ };
141
+
142
+ /**
143
+ * Adds a default Date header, returning its value.
144
+ *
145
+ * @return {String}
146
+ */
147
+ RequestSigner.prototype.writeDateHeader = function () {
148
+ return (this.writeHeader('date', jsprim.rfc1123(new Date())));
149
+ };
82
150
 
151
+ /**
152
+ * Adds the request target line to be signed.
153
+ *
154
+ * @param {String} method, HTTP method (e.g. 'get', 'post', 'put')
155
+ * @param {String} path
156
+ */
157
+ RequestSigner.prototype.writeTarget = function (method, path) {
158
+ assert.string(method, 'method');
159
+ assert.string(path, 'path');
160
+ method = method.toLowerCase();
161
+ this.writeHeader('(request-target)', method + ' ' + path);
162
+ };
83
163
 
164
+ /**
165
+ * Calculate the value for the Authorization header on this request
166
+ * asynchronously.
167
+ *
168
+ * @param {Func} callback (err, authz)
169
+ */
170
+ RequestSigner.prototype.sign = function (cb) {
171
+ assert.func(cb, 'callback');
172
+
173
+ if (this.rs_headers.length < 1)
174
+ throw (new Error('At least one header must be signed'));
175
+
176
+ var alg, authz;
177
+ if (this.rs_signFunc) {
178
+ var data = this.rs_lines.join('\n');
179
+ var self = this;
180
+ this.rs_signFunc(data, function (err, sig) {
181
+ if (err) {
182
+ cb(err);
183
+ return;
184
+ }
185
+ try {
186
+ assert.object(sig, 'signature');
187
+ assert.string(sig.keyId, 'signature.keyId');
188
+ assert.string(sig.algorithm, 'signature.algorithm');
189
+ assert.string(sig.signature, 'signature.signature');
190
+ alg = validateAlgorithm(sig.algorithm);
191
+
192
+ authz = sprintf(AUTHZ_FMT,
193
+ sig.keyId,
194
+ sig.algorithm,
195
+ self.rs_headers.join(' '),
196
+ sig.signature);
197
+ } catch (e) {
198
+ cb(e);
199
+ return;
200
+ }
201
+ cb(null, authz);
202
+ });
203
+
204
+ } else {
205
+ try {
206
+ var sigObj = this.rs_signer.sign();
207
+ } catch (e) {
208
+ cb(e);
209
+ return;
210
+ }
211
+ alg = (this.rs_alg[0] || this.rs_key.type) + '-' + sigObj.hashAlgorithm;
212
+ var signature = sigObj.toString();
213
+ authz = sprintf(AUTHZ_FMT,
214
+ this.rs_keyId,
215
+ alg,
216
+ this.rs_headers.join(' '),
217
+ signature);
218
+ cb(null, authz);
219
+ }
220
+ };
84
221
 
85
222
  ///--- Exported API
86
223
 
87
224
  module.exports = {
225
+ /**
226
+ * Identifies whether a given object is a request signer or not.
227
+ *
228
+ * @param {Object} object, the object to identify
229
+ * @returns {Boolean}
230
+ */
231
+ isSigner: function (obj) {
232
+ if (typeof (obj) === 'object' && obj instanceof RequestSigner)
233
+ return (true);
234
+ return (false);
235
+ },
236
+
237
+ /**
238
+ * Creates a request signer, used to asynchronously build a signature
239
+ * for a request (does not have to be an http.ClientRequest).
240
+ *
241
+ * @param {Object} options, either:
242
+ * - {String} keyId
243
+ * - {String|Buffer} key
244
+ * - {String} algorithm (optional, required for HMAC)
245
+ * or:
246
+ * - {Func} sign (data, cb)
247
+ * @return {RequestSigner}
248
+ */
249
+ createSigner: function createSigner(options) {
250
+ return (new RequestSigner(options));
251
+ },
88
252
 
89
253
  /**
90
254
  * Adds an 'Authorization' header to an http.ClientRequest object.
@@ -96,16 +260,26 @@ module.exports = {
96
260
  * You shouldn't need to check the return type; it's just there if you want
97
261
  * to be pedantic.
98
262
  *
263
+ * The optional flag indicates whether parsing should use strict enforcement
264
+ * of the version draft-cavage-http-signatures-04 of the spec or beyond.
265
+ * The default is to be loose and support
266
+ * older versions for compatibility.
267
+ *
99
268
  * @param {Object} request an instance of http.ClientRequest.
100
269
  * @param {Object} options signing parameters object:
101
270
  * - {String} keyId required.
102
271
  * - {String} key required (either a PEM or HMAC key).
103
272
  * - {Array} headers optional; defaults to ['date'].
104
- * - {String} algorithm optional; defaults to 'rsa-sha256'.
273
+ * - {String} algorithm optional (unless key is HMAC);
274
+ * default is the same as the sshpk default
275
+ * signing algorithm for the type of key given
105
276
  * - {String} httpVersion optional; defaults to '1.1'.
277
+ * - {Boolean} strict optional; defaults to 'false'.
106
278
  * @return {Boolean} true if Authorization (and optionally Date) were added.
107
279
  * @throws {TypeError} on bad parameter types (input).
108
- * @throws {InvalidAlgorithmError} if algorithm was bad.
280
+ * @throws {InvalidAlgorithmError} if algorithm was bad or incompatible with
281
+ * the given key.
282
+ * @throws {sshpk.KeyParseError} if key was bad.
109
283
  * @throws {MissingHeaderError} if a header to be signed was specified but
110
284
  * was not present.
111
285
  */
@@ -118,18 +292,17 @@ module.exports = {
118
292
  assert.optionalString(options.httpVersion, 'options.httpVersion');
119
293
 
120
294
  if (!request.getHeader('Date'))
121
- request.setHeader('Date', _rfc1123());
295
+ request.setHeader('Date', jsprim.rfc1123(new Date()));
122
296
  if (!options.headers)
123
297
  options.headers = ['date'];
124
- if (!options.algorithm)
125
- options.algorithm = 'rsa-sha256';
126
298
  if (!options.httpVersion)
127
299
  options.httpVersion = '1.1';
128
300
 
129
- options.algorithm = options.algorithm.toLowerCase();
130
-
131
- if (!Algorithms[options.algorithm])
132
- throw new InvalidAlgorithmError(options.algorithm + ' is not supported');
301
+ var alg = [];
302
+ if (options.algorithm) {
303
+ options.algorithm = options.algorithm.toLowerCase();
304
+ alg = validateAlgorithm(options.algorithm);
305
+ }
133
306
 
134
307
  var i;
135
308
  var stringToSign = '';
@@ -139,34 +312,77 @@ module.exports = {
139
312
 
140
313
  var h = options.headers[i].toLowerCase();
141
314
 
142
- if (h !== 'request-line') {
315
+ if (h === 'request-line') {
316
+ if (!options.strict) {
317
+ /**
318
+ * We allow headers from the older spec drafts if strict parsing isn't
319
+ * specified in options.
320
+ */
321
+ stringToSign +=
322
+ request.method + ' ' + request.path + ' HTTP/' +
323
+ options.httpVersion;
324
+ } else {
325
+ /* Strict parsing doesn't allow older draft headers. */
326
+ throw (new StrictParsingError('request-line is not a valid header ' +
327
+ 'with strict parsing enabled.'));
328
+ }
329
+ } else if (h === '(request-target)') {
330
+ stringToSign +=
331
+ '(request-target): ' + request.method.toLowerCase() + ' ' +
332
+ request.path;
333
+ } else {
143
334
  var value = request.getHeader(h);
144
- if (!value) {
335
+ if (value === undefined || value === '') {
145
336
  throw new MissingHeaderError(h + ' was not in the request');
146
337
  }
147
338
  stringToSign += h + ': ' + value;
148
- } else {
149
- stringToSign +=
150
- request.method + ' ' + request.path + ' HTTP/' + options.httpVersion;
151
339
  }
152
340
 
153
341
  if ((i + 1) < options.headers.length)
154
342
  stringToSign += '\n';
155
343
  }
156
344
 
157
- var alg = options.algorithm.match(/(hmac|rsa)-(\w+)/);
158
345
  var signature;
159
- if (alg[1] === 'hmac') {
160
- var hmac = crypto.createHmac(alg[2].toUpperCase(), options.key);
346
+ if (alg[0] === 'hmac') {
347
+ if (typeof (options.key) !== 'string' && !Buffer.isBuffer(options.key))
348
+ throw (new TypeError('options.key must be a string or Buffer'));
349
+
350
+ var hmac = crypto.createHmac(alg[1].toUpperCase(), options.key);
161
351
  hmac.update(stringToSign);
162
352
  signature = hmac.digest('base64');
353
+
163
354
  } else {
164
- var signer = crypto.createSign(options.algorithm.toUpperCase());
355
+ var key = options.key;
356
+ if (typeof (key) === 'string' || Buffer.isBuffer(key))
357
+ key = sshpk.parsePrivateKey(options.key);
358
+
359
+ assert.ok(sshpk.PrivateKey.isPrivateKey(key, [1, 2]),
360
+ 'options.key must be a sshpk.PrivateKey');
361
+
362
+ if (!PK_ALGOS[key.type]) {
363
+ throw (new InvalidAlgorithmError(key.type.toUpperCase() + ' type ' +
364
+ 'keys are not supported'));
365
+ }
366
+
367
+ if (alg[0] !== undefined && key.type !== alg[0]) {
368
+ throw (new InvalidAlgorithmError('options.key must be a ' +
369
+ alg[0].toUpperCase() + ' key, was given a ' +
370
+ key.type.toUpperCase() + ' key instead'));
371
+ }
372
+
373
+ var signer = key.createSign(alg[1]);
165
374
  signer.update(stringToSign);
166
- signature = signer.sign(options.key, 'base64');
375
+ var sigObj = signer.sign();
376
+ if (!HASH_ALGOS[sigObj.hashAlgorithm]) {
377
+ throw (new InvalidAlgorithmError(sigObj.hashAlgorithm.toUpperCase() +
378
+ ' is not a supported hash algorithm'));
379
+ }
380
+ options.algorithm = key.type + '-' + sigObj.hashAlgorithm;
381
+ signature = sigObj.toString();
382
+ assert.notStrictEqual(signature, '', 'empty signature produced');
167
383
  }
168
384
 
169
- request.setHeader('Authorization', sprintf(Authorization,
385
+ request.setHeader('Authorization', sprintf(AUTHZ_FMT,
170
386
  options.keyId,
171
387
  options.algorithm,
172
388
  options.headers.join(' '),
@@ -0,0 +1,112 @@
1
+ // Copyright 2012 Joyent, Inc. All rights reserved.
2
+
3
+ var assert = require('assert-plus');
4
+ var sshpk = require('sshpk');
5
+ var util = require('util');
6
+
7
+ var HASH_ALGOS = {
8
+ 'sha1': true,
9
+ 'sha256': true,
10
+ 'sha512': true
11
+ };
12
+
13
+ var PK_ALGOS = {
14
+ 'rsa': true,
15
+ 'dsa': true,
16
+ 'ecdsa': true
17
+ };
18
+
19
+ function HttpSignatureError(message, caller) {
20
+ if (Error.captureStackTrace)
21
+ Error.captureStackTrace(this, caller || HttpSignatureError);
22
+
23
+ this.message = message;
24
+ this.name = caller.name;
25
+ }
26
+ util.inherits(HttpSignatureError, Error);
27
+
28
+ function InvalidAlgorithmError(message) {
29
+ HttpSignatureError.call(this, message, InvalidAlgorithmError);
30
+ }
31
+ util.inherits(InvalidAlgorithmError, HttpSignatureError);
32
+
33
+ function validateAlgorithm(algorithm) {
34
+ var alg = algorithm.toLowerCase().split('-');
35
+
36
+ if (alg.length !== 2) {
37
+ throw (new InvalidAlgorithmError(alg[0].toUpperCase() + ' is not a ' +
38
+ 'valid algorithm'));
39
+ }
40
+
41
+ if (alg[0] !== 'hmac' && !PK_ALGOS[alg[0]]) {
42
+ throw (new InvalidAlgorithmError(alg[0].toUpperCase() + ' type keys ' +
43
+ 'are not supported'));
44
+ }
45
+
46
+ if (!HASH_ALGOS[alg[1]]) {
47
+ throw (new InvalidAlgorithmError(alg[1].toUpperCase() + ' is not a ' +
48
+ 'supported hash algorithm'));
49
+ }
50
+
51
+ return (alg);
52
+ }
53
+
54
+ ///--- API
55
+
56
+ module.exports = {
57
+
58
+ HASH_ALGOS: HASH_ALGOS,
59
+ PK_ALGOS: PK_ALGOS,
60
+
61
+ HttpSignatureError: HttpSignatureError,
62
+ InvalidAlgorithmError: InvalidAlgorithmError,
63
+
64
+ validateAlgorithm: validateAlgorithm,
65
+
66
+ /**
67
+ * Converts an OpenSSH public key (rsa only) to a PKCS#8 PEM file.
68
+ *
69
+ * The intent of this module is to interoperate with OpenSSL only,
70
+ * specifically the node crypto module's `verify` method.
71
+ *
72
+ * @param {String} key an OpenSSH public key.
73
+ * @return {String} PEM encoded form of the RSA public key.
74
+ * @throws {TypeError} on bad input.
75
+ * @throws {Error} on invalid ssh key formatted data.
76
+ */
77
+ sshKeyToPEM: function sshKeyToPEM(key) {
78
+ assert.string(key, 'ssh_key');
79
+
80
+ var k = sshpk.parseKey(key, 'ssh');
81
+ return (k.toString('pem'));
82
+ },
83
+
84
+
85
+ /**
86
+ * Generates an OpenSSH fingerprint from an ssh public key.
87
+ *
88
+ * @param {String} key an OpenSSH public key.
89
+ * @return {String} key fingerprint.
90
+ * @throws {TypeError} on bad input.
91
+ * @throws {Error} if what you passed doesn't look like an ssh public key.
92
+ */
93
+ fingerprint: function fingerprint(key) {
94
+ assert.string(key, 'ssh_key');
95
+
96
+ var k = sshpk.parseKey(key, 'ssh');
97
+ return (k.fingerprint('md5').toString('hex'));
98
+ },
99
+
100
+ /**
101
+ * Converts a PKGCS#8 PEM file to an OpenSSH public key (rsa)
102
+ *
103
+ * The reverse of the above function.
104
+ */
105
+ pemToRsaSSHKey: function pemToRsaSSHKey(pem, comment) {
106
+ assert.equal('string', typeof (pem), 'typeof pem');
107
+
108
+ var k = sshpk.parseKey(pem, 'pem');
109
+ k.comment = comment;
110
+ return (k.toString('ssh'));
111
+ }
112
+ };
@@ -2,8 +2,14 @@
2
2
 
3
3
  var assert = require('assert-plus');
4
4
  var crypto = require('crypto');
5
+ var sshpk = require('sshpk');
6
+ var utils = require('./utils');
5
7
 
6
-
8
+ var HASH_ALGOS = utils.HASH_ALGOS;
9
+ var PK_ALGOS = utils.PK_ALGOS;
10
+ var InvalidAlgorithmError = utils.InvalidAlgorithmError;
11
+ var HttpSignatureError = utils.HttpSignatureError;
12
+ var validateAlgorithm = utils.validateAlgorithm;
7
13
 
8
14
  ///--- Exported API
9
15
 
@@ -16,19 +22,21 @@ module.exports = {
16
22
  * @param {String} pubkey RSA/DSA private key PEM.
17
23
  * @return {Boolean} true if valid, false otherwise.
18
24
  * @throws {TypeError} if you pass in bad arguments.
25
+ * @throws {InvalidAlgorithmError}
19
26
  */
20
27
  verifySignature: function verifySignature(parsedSignature, pubkey) {
21
28
  assert.object(parsedSignature, 'parsedSignature');
22
- assert.string(pubkey, 'pubkey');
29
+ if (typeof (pubkey) === 'string' || Buffer.isBuffer(pubkey))
30
+ pubkey = sshpk.parseKey(pubkey);
31
+ assert.ok(sshpk.Key.isKey(pubkey, [1, 1]), 'pubkey must be a sshpk.Key');
23
32
 
24
- var alg = parsedSignature.algorithm.match(/^(RSA|DSA)-(\w+)/);
25
- if (!alg || alg.length !== 3)
26
- throw new TypeError('parsedSignature: unsupported algorithm ' +
27
- parsedSignature.algorithm);
33
+ var alg = validateAlgorithm(parsedSignature.algorithm);
34
+ if (alg[0] === 'hmac' || alg[0] !== pubkey.type)
35
+ return (false);
28
36
 
29
- var verify = crypto.createVerify(alg[0]);
30
- verify.update(parsedSignature.signingString);
31
- return verify.verify(pubkey, parsedSignature.params.signature, 'base64');
37
+ var v = pubkey.createVerify(alg[1]);
38
+ v.update(parsedSignature.signingString);
39
+ return (v.verify(parsedSignature.params.signature, 'base64'));
32
40
  },
33
41
 
34
42
  /**
@@ -39,18 +47,42 @@ module.exports = {
39
47
  * @param {String} secret HMAC shared secret.
40
48
  * @return {Boolean} true if valid, false otherwise.
41
49
  * @throws {TypeError} if you pass in bad arguments.
50
+ * @throws {InvalidAlgorithmError}
42
51
  */
43
52
  verifyHMAC: function verifyHMAC(parsedSignature, secret) {
44
53
  assert.object(parsedSignature, 'parsedHMAC');
45
54
  assert.string(secret, 'secret');
46
55
 
47
- var alg = parsedSignature.algorithm.match(/^HMAC-(\w+)/);
48
- if (!alg || alg.length !== 2)
49
- throw new TypeError('parsedSignature: unsupported algorithm ' +
50
- parsedSignature.algorithm);
56
+ var alg = validateAlgorithm(parsedSignature.algorithm);
57
+ if (alg[0] !== 'hmac')
58
+ return (false);
59
+
60
+ var hashAlg = alg[1].toUpperCase();
51
61
 
52
- var hmac = crypto.createHmac(alg[1].toUpperCase(), secret);
62
+ var hmac = crypto.createHmac(hashAlg, secret);
53
63
  hmac.update(parsedSignature.signingString);
54
- return (hmac.digest('base64') === parsedSignature.params.signature);
64
+
65
+ /*
66
+ * Now double-hash to avoid leaking timing information - there's
67
+ * no easy constant-time compare in JS, so we use this approach
68
+ * instead. See for more info:
69
+ * https://www.isecpartners.com/blog/2011/february/double-hmac-
70
+ * verification.aspx
71
+ */
72
+ var h1 = crypto.createHmac(hashAlg, secret);
73
+ h1.update(hmac.digest());
74
+ h1 = h1.digest();
75
+ var h2 = crypto.createHmac(hashAlg, secret);
76
+ h2.update(new Buffer(parsedSignature.params.signature, 'base64'));
77
+ h2 = h2.digest();
78
+
79
+ /* Node 0.8 returns strings from .digest(). */
80
+ if (typeof (h1) === 'string')
81
+ return (h1 === h2);
82
+ /* And node 0.10 lacks the .equals() method on Buffers. */
83
+ if (Buffer.isBuffer(h1) && !h1.equals)
84
+ return (h1.toString('binary') === h2.toString('binary'));
85
+
86
+ return (h1.equals(h2));
55
87
  }
56
88
  };