freezerwatch 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (314) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +10 -0
  3. data/CODE_OF_CONDUCT.md +13 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE.txt +21 -0
  6. data/README.md +40 -0
  7. data/Rakefile +1 -0
  8. data/bin/console +14 -0
  9. data/bin/freezerwatch +9 -0
  10. data/bin/setup +7 -0
  11. data/freezerwatch.gemspec +23 -0
  12. data/lib/freezerwatch.rb +5 -0
  13. data/lib/freezerwatch/version.rb +3 -0
  14. data/node_modules/.bin/freezerwatch +139 -0
  15. data/node_modules/freezerwatch/.npmignore +3 -0
  16. data/node_modules/freezerwatch/.ruby-version +1 -0
  17. data/node_modules/freezerwatch/Gemfile +4 -0
  18. data/node_modules/freezerwatch/Gemfile.lock +79 -0
  19. data/node_modules/freezerwatch/LICENSE +23 -0
  20. data/node_modules/freezerwatch/README.md +41 -0
  21. data/node_modules/freezerwatch/Rakefile +13 -0
  22. data/node_modules/freezerwatch/freezerwatch.js +139 -0
  23. data/node_modules/freezerwatch/metrics/bigfiles_high_water_mark +1 -0
  24. data/node_modules/freezerwatch/metrics/cane_high_water_mark +1 -0
  25. data/node_modules/freezerwatch/metrics/flay_high_water_mark +1 -0
  26. data/node_modules/freezerwatch/metrics/flog_high_water_mark +1 -0
  27. data/node_modules/freezerwatch/metrics/punchlist_high_water_mark +2 -0
  28. data/node_modules/freezerwatch/metrics/reek_high_water_mark +1 -0
  29. data/node_modules/freezerwatch/metrics/rubocop_high_water_mark +1 -0
  30. data/node_modules/freezerwatch/node_modules/async/.jshintrc +25 -0
  31. data/node_modules/freezerwatch/node_modules/async/.travis.yml +6 -0
  32. data/node_modules/freezerwatch/node_modules/async/CHANGELOG.md +65 -0
  33. data/node_modules/freezerwatch/node_modules/async/LICENSE +19 -0
  34. data/node_modules/freezerwatch/node_modules/async/README.md +1803 -0
  35. data/node_modules/freezerwatch/node_modules/async/bower.json +43 -0
  36. data/node_modules/freezerwatch/node_modules/async/component.json +17 -0
  37. data/node_modules/freezerwatch/node_modules/async/coverage/base.css +182 -0
  38. data/node_modules/freezerwatch/node_modules/async/coverage/index.html +73 -0
  39. data/node_modules/freezerwatch/node_modules/async/coverage/lcov-report/base.css +182 -0
  40. data/node_modules/freezerwatch/node_modules/async/coverage/lcov-report/index.html +73 -0
  41. data/node_modules/freezerwatch/node_modules/async/coverage/lcov-report/lib/async.js.html +3900 -0
  42. data/node_modules/freezerwatch/node_modules/async/coverage/lcov-report/lib/index.html +73 -0
  43. data/node_modules/freezerwatch/node_modules/async/coverage/lcov-report/prettify.css +1 -0
  44. data/node_modules/freezerwatch/node_modules/async/coverage/lcov-report/prettify.js +1 -0
  45. data/node_modules/freezerwatch/node_modules/async/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  46. data/node_modules/freezerwatch/node_modules/async/coverage/lcov-report/sorter.js +156 -0
  47. data/node_modules/freezerwatch/node_modules/async/coverage/lcov.info +1452 -0
  48. data/node_modules/freezerwatch/node_modules/async/coverage/lib/async.js.html +3597 -0
  49. data/node_modules/freezerwatch/node_modules/async/coverage/lib/index.html +73 -0
  50. data/node_modules/freezerwatch/node_modules/async/coverage/prettify.css +1 -0
  51. data/node_modules/freezerwatch/node_modules/async/coverage/prettify.js +1 -0
  52. data/node_modules/freezerwatch/node_modules/async/coverage/sort-arrow-sprite.png +0 -0
  53. data/node_modules/freezerwatch/node_modules/async/coverage/sorter.js +156 -0
  54. data/node_modules/freezerwatch/node_modules/async/lib/async.js +1191 -0
  55. data/node_modules/freezerwatch/node_modules/async/nyc_output/5074.json +1 -0
  56. data/node_modules/freezerwatch/node_modules/async/package.json +96 -0
  57. data/node_modules/freezerwatch/node_modules/async/support/sync-package-managers.js +53 -0
  58. data/node_modules/freezerwatch/node_modules/lacrosse/.npmignore +15 -0
  59. data/node_modules/freezerwatch/node_modules/lacrosse/Client.js +60 -0
  60. data/node_modules/freezerwatch/node_modules/lacrosse/Device.js +38 -0
  61. data/node_modules/freezerwatch/node_modules/lacrosse/DeviceRawReadStream.js +36 -0
  62. data/node_modules/freezerwatch/node_modules/lacrosse/DeviceSingleRawReadStream.js +29 -0
  63. data/node_modules/freezerwatch/node_modules/lacrosse/DeviceStream.js +35 -0
  64. data/node_modules/freezerwatch/node_modules/lacrosse/LICENSE +23 -0
  65. data/node_modules/freezerwatch/node_modules/lacrosse/README.md +25 -0
  66. data/node_modules/freezerwatch/node_modules/lacrosse/index.js +1 -0
  67. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/.npmignore +2 -0
  68. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/.travis.yml +12 -0
  69. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/LICENSE +55 -0
  70. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/README.md +364 -0
  71. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/index.js +156 -0
  72. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/lib/copy.js +8 -0
  73. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/lib/debug.js +7 -0
  74. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/lib/getSafe.js +34 -0
  75. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/lib/optional.js +5 -0
  76. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/.bin/uuid +26 -0
  77. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/aws-sign2/LICENSE +55 -0
  78. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/aws-sign2/README.md +4 -0
  79. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/aws-sign2/index.js +202 -0
  80. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/aws-sign2/package.json +46 -0
  81. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/forever-agent/LICENSE +55 -0
  82. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/forever-agent/README.md +4 -0
  83. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/forever-agent/index.js +119 -0
  84. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/forever-agent/package.json +45 -0
  85. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/License +19 -0
  86. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/Readme.md +175 -0
  87. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/lib/form_data.js +351 -0
  88. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/async/.travis.yml +5 -0
  89. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/async/LICENSE +19 -0
  90. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/async/README.md +1647 -0
  91. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/async/bower.json +38 -0
  92. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/async/component.json +16 -0
  93. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/async/lib/async.js +1123 -0
  94. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/async/package.json +84 -0
  95. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/async/support/sync-package-managers.js +53 -0
  96. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/License +19 -0
  97. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/Readme.md +132 -0
  98. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/lib/combined_stream.js +188 -0
  99. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/.npmignore +2 -0
  100. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/License +19 -0
  101. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/Makefile +7 -0
  102. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/Readme.md +154 -0
  103. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/lib/delayed_stream.js +99 -0
  104. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/package.json +42 -0
  105. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/common.js +6 -0
  106. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-http-upload.js +38 -0
  107. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-stream-auto-pause.js +21 -0
  108. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-stream-pause.js +14 -0
  109. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-stream.js +48 -0
  110. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-handle-source-errors.js +15 -0
  111. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-max-data-size.js +18 -0
  112. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-pipe-resumes.js +13 -0
  113. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-proxy-readable.js +13 -0
  114. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/run.js +7 -0
  115. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/node_modules/combined-stream/package.json +60 -0
  116. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/form-data/package.json +80 -0
  117. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/.npmignore +18 -0
  118. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/.travis.yml +5 -0
  119. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/LICENSE +24 -0
  120. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/Makefile +10 -0
  121. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/README.md +627 -0
  122. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/example/usage.js +78 -0
  123. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/images/hawk.png +0 -0
  124. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/images/logo.png +0 -0
  125. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/index.js +1 -0
  126. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/lib/browser.js +485 -0
  127. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/lib/client.js +367 -0
  128. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/lib/crypto.js +111 -0
  129. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/lib/index.js +15 -0
  130. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/lib/server.js +524 -0
  131. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/lib/utils.js +183 -0
  132. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/boom/.npmignore +18 -0
  133. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/boom/.travis.yml +5 -0
  134. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/boom/LICENSE +24 -0
  135. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/boom/Makefile +11 -0
  136. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/boom/README.md +6 -0
  137. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/boom/images/boom.png +0 -0
  138. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/boom/index.js +1 -0
  139. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/boom/lib/index.js +207 -0
  140. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/boom/package.json +64 -0
  141. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/boom/test/index.js +245 -0
  142. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/cryptiles/.npmignore +18 -0
  143. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/cryptiles/.travis.yml +5 -0
  144. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/cryptiles/LICENSE +24 -0
  145. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/cryptiles/Makefile +11 -0
  146. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/cryptiles/README.md +6 -0
  147. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/cryptiles/index.js +1 -0
  148. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/cryptiles/lib/index.js +68 -0
  149. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/cryptiles/package.json +65 -0
  150. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/cryptiles/test/index.js +101 -0
  151. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/hoek/.npmignore +18 -0
  152. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/hoek/.travis.yml +5 -0
  153. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/hoek/LICENSE +33 -0
  154. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/hoek/Makefile +10 -0
  155. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/hoek/README.md +436 -0
  156. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/hoek/images/hoek.png +0 -0
  157. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/hoek/index.js +1 -0
  158. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/hoek/lib/escape.js +132 -0
  159. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/hoek/lib/index.js +585 -0
  160. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/hoek/package.json +70 -0
  161. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/hoek/test/escaper.js +86 -0
  162. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/hoek/test/index.js +1078 -0
  163. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/hoek/test/modules/test1.js +1 -0
  164. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/hoek/test/modules/test2.js +1 -0
  165. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/hoek/test/modules/test3.js +1 -0
  166. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/sntp/.npmignore +18 -0
  167. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/sntp/.travis.yml +5 -0
  168. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/sntp/LICENSE +24 -0
  169. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/sntp/Makefile +11 -0
  170. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/sntp/README.md +68 -0
  171. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/sntp/examples/offset.js +16 -0
  172. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/sntp/examples/time.js +25 -0
  173. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/sntp/index.js +1 -0
  174. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/sntp/lib/index.js +409 -0
  175. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/sntp/package.json +65 -0
  176. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/node_modules/sntp/test/index.js +359 -0
  177. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/package.json +70 -0
  178. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/test/browser.js +771 -0
  179. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/test/client.js +206 -0
  180. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/test/crypto.js +86 -0
  181. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/test/index.js +316 -0
  182. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/test/message.js +246 -0
  183. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/test/readme.js +98 -0
  184. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/test/server.js +686 -0
  185. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/test/uri.js +456 -0
  186. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/hawk/test/utils.js +120 -0
  187. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/.dir-locals.el +6 -0
  188. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/.npmignore +7 -0
  189. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/LICENSE +18 -0
  190. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/README.md +79 -0
  191. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/http_signing.md +296 -0
  192. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/lib/index.js +26 -0
  193. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/lib/parser.js +304 -0
  194. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/lib/signer.js +178 -0
  195. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/lib/util.js +304 -0
  196. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/lib/verify.js +42 -0
  197. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/asn1/.npmignore +2 -0
  198. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/asn1/LICENSE +19 -0
  199. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/asn1/README.md +50 -0
  200. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/asn1/lib/ber/errors.js +13 -0
  201. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/asn1/lib/ber/index.js +27 -0
  202. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/asn1/lib/ber/reader.js +267 -0
  203. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/asn1/lib/ber/types.js +36 -0
  204. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/asn1/lib/ber/writer.js +317 -0
  205. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/asn1/lib/index.js +20 -0
  206. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/asn1/package.json +63 -0
  207. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/asn1/tst/ber/reader.test.js +172 -0
  208. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/asn1/tst/ber/writer.test.js +296 -0
  209. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/assert-plus/README.md +126 -0
  210. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/assert-plus/assert.js +245 -0
  211. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/assert-plus/package.json +45 -0
  212. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/ctype/.npmignore +1 -0
  213. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/ctype/CHANGELOG +78 -0
  214. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/ctype/LICENSE +24 -0
  215. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/ctype/README +82 -0
  216. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/ctype/README.old +298 -0
  217. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/ctype/ctf.js +245 -0
  218. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/ctype/ctio.js +1485 -0
  219. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/ctype/ctype.js +944 -0
  220. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/ctype/man/man3ctype/ctio.3ctype +241 -0
  221. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/ctype/package.json +42 -0
  222. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/ctype/tools/jsl.conf +129 -0
  223. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/node_modules/ctype/tools/jsstyle +839 -0
  224. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/http-signature/package.json +72 -0
  225. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/json-stringify-safe/.npmignore +1 -0
  226. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/json-stringify-safe/CHANGELOG.md +14 -0
  227. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/json-stringify-safe/LICENSE +15 -0
  228. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/json-stringify-safe/Makefile +35 -0
  229. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/json-stringify-safe/README.md +52 -0
  230. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/json-stringify-safe/package.json +68 -0
  231. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/json-stringify-safe/stringify.js +27 -0
  232. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/json-stringify-safe/test/mocha.opts +2 -0
  233. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/json-stringify-safe/test/stringify_test.js +246 -0
  234. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/mime/LICENSE +19 -0
  235. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/mime/README.md +66 -0
  236. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/mime/mime.js +114 -0
  237. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/mime/package.json +57 -0
  238. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/mime/test.js +84 -0
  239. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/mime/types/mime.types +1588 -0
  240. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/mime/types/node.types +77 -0
  241. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/node-uuid/.npmignore +2 -0
  242. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/node-uuid/LICENSE.md +21 -0
  243. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/node-uuid/README.md +243 -0
  244. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/node-uuid/benchmark/README.md +53 -0
  245. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/node-uuid/benchmark/bench.gnu +174 -0
  246. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/node-uuid/benchmark/bench.sh +34 -0
  247. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/node-uuid/benchmark/benchmark-native.c +34 -0
  248. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/node-uuid/benchmark/benchmark.js +84 -0
  249. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/node-uuid/bin/uuid +26 -0
  250. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/node-uuid/bower.json +23 -0
  251. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/node-uuid/component.json +18 -0
  252. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/node-uuid/package.json +65 -0
  253. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/node-uuid/test/compare_v1.js +63 -0
  254. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/node-uuid/test/test.html +17 -0
  255. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/node-uuid/test/test.js +228 -0
  256. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/node-uuid/uuid.js +247 -0
  257. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/oauth-sign/LICENSE +55 -0
  258. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/oauth-sign/README.md +4 -0
  259. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/oauth-sign/index.js +43 -0
  260. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/oauth-sign/package.json +48 -0
  261. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/oauth-sign/test.js +49 -0
  262. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/qs/.gitmodules +6 -0
  263. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/qs/.npmignore +7 -0
  264. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/qs/Readme.md +58 -0
  265. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/qs/index.js +366 -0
  266. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/qs/package.json +55 -0
  267. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tough-cookie/.jshintrc +72 -0
  268. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tough-cookie/.npmignore +3 -0
  269. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tough-cookie/LICENSE +78 -0
  270. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tough-cookie/README.md +380 -0
  271. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tough-cookie/generate-pubsuffix.js +230 -0
  272. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tough-cookie/lib/cookie.js +947 -0
  273. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tough-cookie/lib/memstore.js +102 -0
  274. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tough-cookie/lib/pubsuffix.js +69 -0
  275. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tough-cookie/node_modules/punycode/LICENSE-MIT.txt +20 -0
  276. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tough-cookie/node_modules/punycode/README.md +176 -0
  277. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tough-cookie/node_modules/punycode/package.json +81 -0
  278. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tough-cookie/node_modules/punycode/punycode.js +530 -0
  279. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tough-cookie/package.json +63 -0
  280. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tough-cookie/public-suffix.txt +5229 -0
  281. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tough-cookie/test.js +1340 -0
  282. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tunnel-agent/LICENSE +55 -0
  283. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tunnel-agent/README.md +4 -0
  284. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tunnel-agent/index.js +227 -0
  285. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/node_modules/tunnel-agent/package.json +45 -0
  286. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/package.json +74 -0
  287. data/node_modules/freezerwatch/node_modules/lacrosse/node_modules/request/request.js +1244 -0
  288. data/node_modules/freezerwatch/node_modules/lacrosse/package.json +34 -0
  289. data/node_modules/freezerwatch/node_modules/optparse/README.md +163 -0
  290. data/node_modules/freezerwatch/node_modules/optparse/TODO +1 -0
  291. data/node_modules/freezerwatch/node_modules/optparse/examples/browser-test.html +75 -0
  292. data/node_modules/freezerwatch/node_modules/optparse/examples/nodejs-test.js +86 -0
  293. data/node_modules/freezerwatch/node_modules/optparse/lib/optparse.js +309 -0
  294. data/node_modules/freezerwatch/node_modules/optparse/package.json +46 -0
  295. data/node_modules/freezerwatch/node_modules/optparse/seed.yml +5 -0
  296. data/node_modules/freezerwatch/node_modules/osenv/.npmignore +13 -0
  297. data/node_modules/freezerwatch/node_modules/osenv/.travis.yml +9 -0
  298. data/node_modules/freezerwatch/node_modules/osenv/LICENSE +15 -0
  299. data/node_modules/freezerwatch/node_modules/osenv/README.md +63 -0
  300. data/node_modules/freezerwatch/node_modules/osenv/node_modules/os-homedir/index.js +24 -0
  301. data/node_modules/freezerwatch/node_modules/osenv/node_modules/os-homedir/license +21 -0
  302. data/node_modules/freezerwatch/node_modules/osenv/node_modules/os-homedir/package.json +70 -0
  303. data/node_modules/freezerwatch/node_modules/osenv/node_modules/os-homedir/readme.md +33 -0
  304. data/node_modules/freezerwatch/node_modules/osenv/node_modules/os-tmpdir/index.js +25 -0
  305. data/node_modules/freezerwatch/node_modules/osenv/node_modules/os-tmpdir/license +21 -0
  306. data/node_modules/freezerwatch/node_modules/osenv/node_modules/os-tmpdir/package.json +70 -0
  307. data/node_modules/freezerwatch/node_modules/osenv/node_modules/os-tmpdir/readme.md +36 -0
  308. data/node_modules/freezerwatch/node_modules/osenv/osenv.js +72 -0
  309. data/node_modules/freezerwatch/node_modules/osenv/package.json +76 -0
  310. data/node_modules/freezerwatch/node_modules/osenv/test/unix.js +71 -0
  311. data/node_modules/freezerwatch/node_modules/osenv/test/windows.js +74 -0
  312. data/node_modules/freezerwatch/node_modules/osenv/x.tap +39 -0
  313. data/node_modules/freezerwatch/package.json +37 -0
  314. metadata +384 -0
@@ -0,0 +1,230 @@
1
+ /*
2
+ * Copyright GoInstant, Inc. and other contributors. All rights reserved.
3
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ * of this software and associated documentation files (the "Software"), to
5
+ * deal in the Software without restriction, including without limitation the
6
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7
+ * sell copies of the Software, and to permit persons to whom the Software is
8
+ * furnished to do so, subject to the following conditions:
9
+ *
10
+ * The above copyright notice and this permission notice shall be included in
11
+ * all copies or substantial portions of the Software.
12
+ *
13
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
19
+ * IN THE SOFTWARE.
20
+ */
21
+
22
+ var fs = require('fs');
23
+ var assert = require('assert');
24
+ var punycode = require('punycode');
25
+
26
+ fs.readFile('./public-suffix.txt', 'utf8', function(err,string) {
27
+ if (err) throw err;
28
+ var lines = string.split("\n");
29
+ process.nextTick(function() {
30
+ processList(lines);
31
+ });
32
+ });
33
+
34
+ var index = {};
35
+
36
+ var COMMENT = new RegExp('//.+');
37
+ function processList(lines) {
38
+ while (lines.length) {
39
+ var line = lines.shift();
40
+ line = line.replace(COMMENT,'').trim();
41
+ if (!line) continue;
42
+ addToIndex(index,line);
43
+ }
44
+
45
+ pubSufTest();
46
+
47
+ var w = fs.createWriteStream('./lib/pubsuffix.js',{
48
+ flags: 'w',
49
+ encoding: 'utf8',
50
+ mode: 0644,
51
+ });
52
+ w.on('end', process.exit);
53
+ w.write("/****************************************************\n");
54
+ w.write(" * AUTOMATICALLY GENERATED by generate-pubsuffix.js *\n");
55
+ w.write(" * DO NOT EDIT! *\n");
56
+ w.write(" ****************************************************/\n\n");
57
+
58
+ w.write("module.exports.getPublicSuffix = ");
59
+ w.write(getPublicSuffix.toString());
60
+ w.write(";\n\n");
61
+
62
+ w.write("// The following generated structure is used under the MPL version 1.1\n");
63
+ w.write("// See public-suffix.txt for more information\n\n");
64
+ w.write("var index = module.exports.index = Object.freeze(\n");
65
+ w.write(JSON.stringify(index));
66
+ w.write(");\n\n");
67
+ w.write("// END of automatically generated file\n");
68
+
69
+ w.end();
70
+ }
71
+
72
+ function addToIndex(index,line) {
73
+ var prefix = '';
74
+ if (line.replace(/^(!|\*\.)/)) {
75
+ prefix = RegExp.$1;
76
+ line = line.slice(prefix.length);
77
+ }
78
+ line = prefix + punycode.toASCII(line);
79
+
80
+ if (line.substr(0,1) == '!')
81
+ index[line.substr(1)] = false;
82
+ else
83
+ index[line] = true;
84
+ }
85
+
86
+ // include the licence in the function since it gets written to pubsuffix.js
87
+ function getPublicSuffix(domain) {
88
+ /*
89
+ * Copyright GoInstant, Inc. and other contributors. All rights reserved.
90
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
91
+ * of this software and associated documentation files (the "Software"), to
92
+ * deal in the Software without restriction, including without limitation the
93
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
94
+ * sell copies of the Software, and to permit persons to whom the Software is
95
+ * furnished to do so, subject to the following conditions:
96
+ *
97
+ * The above copyright notice and this permission notice shall be included in
98
+ * all copies or substantial portions of the Software.
99
+ *
100
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
101
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
102
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
103
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
104
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
105
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
106
+ * IN THE SOFTWARE.
107
+ */
108
+ if (!domain) return null;
109
+ if (domain.match(/^\./)) return null;
110
+
111
+ domain = domain.toLowerCase();
112
+ var parts = domain.split('.').reverse();
113
+
114
+ var suffix = '';
115
+ var suffixLen = 0;
116
+ for (var i=0; i<parts.length; i++) {
117
+ var part = parts[i];
118
+ var starstr = '*'+suffix;
119
+ var partstr = part+suffix;
120
+
121
+ if (index[starstr]) { // star rule matches
122
+ suffixLen = i+1;
123
+ if (index[partstr] === false) { // exception rule matches (NB: false, not undefined)
124
+ suffixLen--;
125
+ }
126
+ } else if (index[partstr]) { // exact match, not exception
127
+ suffixLen = i+1;
128
+ }
129
+
130
+ suffix = '.'+part+suffix;
131
+ }
132
+
133
+ if (index['*'+suffix]) { // *.domain exists (e.g. *.kyoto.jp for domain='kyoto.jp');
134
+ return null;
135
+ }
136
+
137
+ if (suffixLen && parts.length > suffixLen) {
138
+ return parts.slice(0,suffixLen+1).reverse().join('.');
139
+ }
140
+
141
+ return null;
142
+ }
143
+
144
+ function checkPublicSuffix(give,get) {
145
+ var got = getPublicSuffix(give);
146
+ assert.equal(got, get, give+' should be '+(get==null?'NULL':get)+' but got '+got);
147
+ }
148
+
149
+ // pubSufTest() was converted to JavaScript from http://publicsuffix.org/list/test.txt
150
+ function pubSufTest() {
151
+ // For this function-scope and this function-scope ONLY:
152
+ // Any copyright is dedicated to the Public Domain.
153
+ // http://creativecommons.org/publicdomain/zero/1.0/
154
+
155
+ // NULL input.
156
+ checkPublicSuffix(null, null);
157
+ // Mixed case.
158
+ checkPublicSuffix('COM', null);
159
+ checkPublicSuffix('example.COM', 'example.com');
160
+ checkPublicSuffix('WwW.example.COM', 'example.com');
161
+ // Leading dot.
162
+ checkPublicSuffix('.com', null);
163
+ checkPublicSuffix('.example', null);
164
+ checkPublicSuffix('.example.com', null);
165
+ checkPublicSuffix('.example.example', null);
166
+ // Unlisted TLD.
167
+ checkPublicSuffix('example', null);
168
+ checkPublicSuffix('example.example', null);
169
+ checkPublicSuffix('b.example.example', null);
170
+ checkPublicSuffix('a.b.example.example', null);
171
+ // Listed, but non-Internet, TLD.
172
+ checkPublicSuffix('local', null);
173
+ checkPublicSuffix('example.local', null);
174
+ checkPublicSuffix('b.example.local', null);
175
+ checkPublicSuffix('a.b.example.local', null);
176
+ // TLD with only 1 rule.
177
+ checkPublicSuffix('biz', null);
178
+ checkPublicSuffix('domain.biz', 'domain.biz');
179
+ checkPublicSuffix('b.domain.biz', 'domain.biz');
180
+ checkPublicSuffix('a.b.domain.biz', 'domain.biz');
181
+ // TLD with some 2-level rules.
182
+ checkPublicSuffix('com', null);
183
+ checkPublicSuffix('example.com', 'example.com');
184
+ checkPublicSuffix('b.example.com', 'example.com');
185
+ checkPublicSuffix('a.b.example.com', 'example.com');
186
+ checkPublicSuffix('uk.com', null);
187
+ checkPublicSuffix('example.uk.com', 'example.uk.com');
188
+ checkPublicSuffix('b.example.uk.com', 'example.uk.com');
189
+ checkPublicSuffix('a.b.example.uk.com', 'example.uk.com');
190
+ checkPublicSuffix('test.ac', 'test.ac');
191
+ // TLD with only 1 (wildcard) rule.
192
+ checkPublicSuffix('cy', null);
193
+ checkPublicSuffix('c.cy', null);
194
+ checkPublicSuffix('b.c.cy', 'b.c.cy');
195
+ checkPublicSuffix('a.b.c.cy', 'b.c.cy');
196
+ // More complex TLD.
197
+ checkPublicSuffix('jp', null);
198
+ checkPublicSuffix('test.jp', 'test.jp');
199
+ checkPublicSuffix('www.test.jp', 'test.jp');
200
+ checkPublicSuffix('ac.jp', null);
201
+ checkPublicSuffix('test.ac.jp', 'test.ac.jp');
202
+ checkPublicSuffix('www.test.ac.jp', 'test.ac.jp');
203
+ checkPublicSuffix('kyoto.jp', null);
204
+ checkPublicSuffix('c.kyoto.jp', null);
205
+ checkPublicSuffix('b.c.kyoto.jp', 'b.c.kyoto.jp');
206
+ checkPublicSuffix('a.b.c.kyoto.jp', 'b.c.kyoto.jp');
207
+ checkPublicSuffix('pref.kyoto.jp', 'pref.kyoto.jp'); // Exception rule.
208
+ checkPublicSuffix('www.pref.kyoto.jp', 'pref.kyoto.jp'); // Exception rule.
209
+ checkPublicSuffix('city.kyoto.jp', 'city.kyoto.jp'); // Exception rule.
210
+ checkPublicSuffix('www.city.kyoto.jp', 'city.kyoto.jp'); // Exception rule.
211
+ // TLD with a wildcard rule and exceptions.
212
+ checkPublicSuffix('om', null);
213
+ checkPublicSuffix('test.om', null);
214
+ checkPublicSuffix('b.test.om', 'b.test.om');
215
+ checkPublicSuffix('a.b.test.om', 'b.test.om');
216
+ checkPublicSuffix('songfest.om', 'songfest.om');
217
+ checkPublicSuffix('www.songfest.om', 'songfest.om');
218
+ // US K12.
219
+ checkPublicSuffix('us', null);
220
+ checkPublicSuffix('test.us', 'test.us');
221
+ checkPublicSuffix('www.test.us', 'test.us');
222
+ checkPublicSuffix('ak.us', null);
223
+ checkPublicSuffix('test.ak.us', 'test.ak.us');
224
+ checkPublicSuffix('www.test.ak.us', 'test.ak.us');
225
+ checkPublicSuffix('k12.ak.us', null);
226
+ checkPublicSuffix('test.k12.ak.us', 'test.k12.ak.us');
227
+ checkPublicSuffix('www.test.k12.ak.us', 'test.k12.ak.us');
228
+
229
+
230
+ }
@@ -0,0 +1,947 @@
1
+ /*
2
+ * Copyright GoInstant, Inc. and other contributors. All rights reserved.
3
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ * of this software and associated documentation files (the "Software"), to
5
+ * deal in the Software without restriction, including without limitation the
6
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7
+ * sell copies of the Software, and to permit persons to whom the Software is
8
+ * furnished to do so, subject to the following conditions:
9
+ *
10
+ * The above copyright notice and this permission notice shall be included in
11
+ * all copies or substantial portions of the Software.
12
+ *
13
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
19
+ * IN THE SOFTWARE.
20
+ */
21
+
22
+ /*jshint regexp:false */
23
+ var net = require('net');
24
+ var urlParse = require('url').parse;
25
+ var pubsuffix = require('./pubsuffix');
26
+
27
+ var punycode;
28
+ try {
29
+ punycode = require('punycode');
30
+ } catch(e) {
31
+ console.warn("cookie: can't load punycode; won't use punycode for domain normalization");
32
+ }
33
+
34
+ var DATE_DELIM = /[\x09\x20-\x2F\x3B-\x40\x5B-\x60\x7B-\x7E]/;
35
+
36
+ // From RFC2616 S2.2:
37
+ var TOKEN = /[\x21\x23-\x26\x2A\x2B\x2D\x2E\x30-\x39\x41-\x5A\x5E-\x7A\x7C\x7E]/;
38
+
39
+ // From RFC6265 S4.1.1
40
+ // note that it excludes \x3B ";"
41
+ var COOKIE_OCTET = /[\x21\x23-\x2B\x2D-\x3A\x3C-\x5B\x5D-\x7E]/;
42
+ var COOKIE_OCTETS = /^[\x21\x23-\x2B\x2D-\x3A\x3C-\x5B\x5D-\x7E]+$/;
43
+
44
+ // The name/key cannot be empty but the value can (S5.2):
45
+ var COOKIE_PAIR_STRICT = new RegExp('^('+TOKEN.source+'+)=("?)('+COOKIE_OCTET.source+'*)\\2');
46
+ var COOKIE_PAIR = /^([^=\s]+)\s*=\s*("?)\s*(.*)\s*\2/;
47
+
48
+ // RFC6265 S4.1.1 defines extension-av as 'any CHAR except CTLs or ";"'
49
+ // Note ';' is \x3B
50
+ var NON_CTL_SEMICOLON = /[\x20-\x3A\x3C-\x7E]+/;
51
+ var EXTENSION_AV = NON_CTL_SEMICOLON;
52
+ var PATH_VALUE = NON_CTL_SEMICOLON;
53
+
54
+ // Used for checking whether or not there is a trailing semi-colon
55
+ var TRAILING_SEMICOLON = /;+$/;
56
+
57
+ /* RFC6265 S5.1.1.5:
58
+ * [fail if] the day-of-month-value is less than 1 or greater than 31
59
+ */
60
+ var DAY_OF_MONTH = /^(0?[1-9]|[12][0-9]|3[01])$/;
61
+
62
+ /* RFC6265 S5.1.1.5:
63
+ * [fail if]
64
+ * * the hour-value is greater than 23,
65
+ * * the minute-value is greater than 59, or
66
+ * * the second-value is greater than 59.
67
+ */
68
+ var TIME = /(0?[0-9]|1[0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])/;
69
+ var STRICT_TIME = /^(0?[0-9]|1[0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])$/;
70
+
71
+ var MONTH = /^(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)$/i;
72
+ var MONTH_TO_NUM = {
73
+ jan:0, feb:1, mar:2, apr:3, may:4, jun:5, jul:6, aug:7, sep:8, oct:9, nov:10, dec:11
74
+ };
75
+ var NUM_TO_MONTH = [
76
+ 'Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'
77
+ ];
78
+ var NUM_TO_DAY = [
79
+ 'Sun','Mon','Tue','Wed','Thu','Fri','Sat'
80
+ ];
81
+
82
+ var YEAR = /^([1-9][0-9]{1,3})$/; // 2 to 4 digits (will check range when parsing)
83
+
84
+ var MAX_TIME = 2147483647000; // 31-bit max
85
+ var MAX_DATE = new Date(CookieJar.MAX_TIME); // 31-bit max
86
+ var MIN_TIME = 0; // 31-bit min
87
+ var MIN_DATE = new Date(CookieJar.MIN_TIME); // 31-bit min
88
+
89
+
90
+ // RFC6265 S5.1.1 date parser:
91
+ function parseDate(str,strict) {
92
+ if (!str) return;
93
+ var found_time, found_dom, found_month, found_year;
94
+
95
+ /* RFC6265 S5.1.1:
96
+ * 2. Process each date-token sequentially in the order the date-tokens
97
+ * appear in the cookie-date
98
+ */
99
+ var tokens = str.split(DATE_DELIM);
100
+ if (!tokens) return;
101
+
102
+ var date = new Date();
103
+ date.setMilliseconds(0);
104
+
105
+ for (var i=0; i<tokens.length; i++) {
106
+ var token = tokens[i].trim();
107
+ if (!token.length) continue;
108
+
109
+ var result;
110
+
111
+ /* 2.1. If the found-time flag is not set and the token matches the time
112
+ * production, set the found-time flag and set the hour- value,
113
+ * minute-value, and second-value to the numbers denoted by the digits in
114
+ * the date-token, respectively. Skip the remaining sub-steps and continue
115
+ * to the next date-token.
116
+ */
117
+ if (!found_time) {
118
+ result = (strict ? STRICT_TIME : TIME).exec(token);
119
+ if (result) {
120
+ found_time = true;
121
+ date.setUTCHours(result[1]);
122
+ date.setUTCMinutes(result[2]);
123
+ date.setUTCSeconds(result[3]);
124
+ continue;
125
+ }
126
+ }
127
+
128
+ /* 2.2. If the found-day-of-month flag is not set and the date-token matches
129
+ * the day-of-month production, set the found-day-of- month flag and set
130
+ * the day-of-month-value to the number denoted by the date-token. Skip
131
+ * the remaining sub-steps and continue to the next date-token.
132
+ */
133
+ if (!found_dom) {
134
+ result = DAY_OF_MONTH.exec(token);
135
+ if (result) {
136
+ found_dom = true;
137
+ date.setUTCDate(result[1]);
138
+ continue;
139
+ }
140
+ }
141
+
142
+ /* 2.3. If the found-month flag is not set and the date-token matches the
143
+ * month production, set the found-month flag and set the month-value to
144
+ * the month denoted by the date-token. Skip the remaining sub-steps and
145
+ * continue to the next date-token.
146
+ */
147
+ if (!found_month) {
148
+ result = MONTH.exec(token);
149
+ if (result) {
150
+ found_month = true;
151
+ date.setUTCMonth(MONTH_TO_NUM[result[1].toLowerCase()]);
152
+ continue;
153
+ }
154
+ }
155
+
156
+ /* 2.4. If the found-year flag is not set and the date-token matches the year
157
+ * production, set the found-year flag and set the year-value to the number
158
+ * denoted by the date-token. Skip the remaining sub-steps and continue to
159
+ * the next date-token.
160
+ */
161
+ if (!found_year) {
162
+ result = YEAR.exec(token);
163
+ if (result) {
164
+ var year = result[0];
165
+ /* From S5.1.1:
166
+ * 3. If the year-value is greater than or equal to 70 and less
167
+ * than or equal to 99, increment the year-value by 1900.
168
+ * 4. If the year-value is greater than or equal to 0 and less
169
+ * than or equal to 69, increment the year-value by 2000.
170
+ */
171
+ if (70 <= year && year <= 99)
172
+ year += 1900;
173
+ else if (0 <= year && year <= 69)
174
+ year += 2000;
175
+
176
+ if (year < 1601)
177
+ return; // 5. ... the year-value is less than 1601
178
+
179
+ found_year = true;
180
+ date.setUTCFullYear(year);
181
+ continue;
182
+ }
183
+ }
184
+ }
185
+
186
+ if (!(found_time && found_dom && found_month && found_year)) {
187
+ return; // 5. ... at least one of the found-day-of-month, found-month, found-
188
+ // year, or found-time flags is not set,
189
+ }
190
+
191
+ return date;
192
+ }
193
+
194
+ function formatDate(date) {
195
+ var d = date.getUTCDate(); d = d >= 10 ? d : '0'+d;
196
+ var h = date.getUTCHours(); h = h >= 10 ? h : '0'+h;
197
+ var m = date.getUTCMinutes(); m = m >= 10 ? m : '0'+m;
198
+ var s = date.getUTCSeconds(); s = s >= 10 ? s : '0'+s;
199
+ return NUM_TO_DAY[date.getUTCDay()] + ', ' +
200
+ d+' '+ NUM_TO_MONTH[date.getUTCMonth()] +' '+ date.getUTCFullYear() +' '+
201
+ h+':'+m+':'+s+' GMT';
202
+ }
203
+
204
+ // S5.1.2 Canonicalized Host Names
205
+ function canonicalDomain(str) {
206
+ if (str == null) return null;
207
+ str = str.trim().replace(/^\./,''); // S4.1.2.3 & S5.2.3: ignore leading .
208
+
209
+ // convert to IDN if any non-ASCII characters
210
+ if (punycode && /[^\u0001-\u007f]/.test(str))
211
+ str = punycode.toASCII(str);
212
+
213
+ return str.toLowerCase();
214
+ }
215
+
216
+ // S5.1.3 Domain Matching
217
+ function domainMatch(str, domStr, canonicalize) {
218
+ if (str == null || domStr == null) return null;
219
+ if (canonicalize !== false) {
220
+ str = canonicalDomain(str);
221
+ domStr = canonicalDomain(domStr);
222
+ }
223
+
224
+ /*
225
+ * "The domain string and the string are identical. (Note that both the
226
+ * domain string and the string will have been canonicalized to lower case at
227
+ * this point)"
228
+ */
229
+ if (str == domStr) return true;
230
+
231
+ /* "All of the following [three] conditions hold:" (order adjusted from the RFC) */
232
+
233
+ /* "* The string is a host name (i.e., not an IP address)." */
234
+ if (net.isIP(str)) return false;
235
+
236
+ /* "* The domain string is a suffix of the string" */
237
+ var idx = str.indexOf(domStr);
238
+ if (idx <= 0) return false; // it's a non-match (-1) or prefix (0)
239
+
240
+ // e.g "a.b.c".indexOf("b.c") === 2
241
+ // 5 === 3+2
242
+ if (str.length !== domStr.length + idx) // it's not a suffix
243
+ return false;
244
+
245
+ /* "* The last character of the string that is not included in the domain
246
+ * string is a %x2E (".") character." */
247
+ if (str.substr(idx-1,1) !== '.') return false;
248
+ return true;
249
+ }
250
+
251
+
252
+ // RFC6265 S5.1.4 Paths and Path-Match
253
+
254
+ /*
255
+ * "The user agent MUST use an algorithm equivalent to the following algorithm
256
+ * to compute the default-path of a cookie:"
257
+ *
258
+ * Assumption: the path (and not query part or absolute uri) is passed in.
259
+ */
260
+ function defaultPath(path) {
261
+ // "2. If the uri-path is empty or if the first character of the uri-path is not
262
+ // a %x2F ("/") character, output %x2F ("/") and skip the remaining steps.
263
+ if (!path || path.substr(0,1) !== "/") return "/";
264
+
265
+ // "3. If the uri-path contains no more than one %x2F ("/") character, output
266
+ // %x2F ("/") and skip the remaining step."
267
+ if (path === "/") return path;
268
+
269
+ var rightSlash = path.lastIndexOf("/");
270
+ if (rightSlash === 0) return "/";
271
+
272
+ // "4. Output the characters of the uri-path from the first character up to,
273
+ // but not including, the right-most %x2F ("/")."
274
+ return path.slice(0, rightSlash);
275
+ }
276
+
277
+ /*
278
+ * "A request-path path-matches a given cookie-path if at least one of the
279
+ * following conditions holds:"
280
+ */
281
+ function pathMatch(reqPath,cookiePath) {
282
+ // "o The cookie-path and the request-path are identical."
283
+ if (cookiePath === reqPath)
284
+ return true;
285
+
286
+ var idx = reqPath.indexOf(cookiePath);
287
+ if (idx === 0) {
288
+ // "o The cookie-path is a prefix of the request-path, and the last
289
+ // character of the cookie-path is %x2F ("/")."
290
+ if (cookiePath.substr(-1) === "/")
291
+ return true;
292
+
293
+ // " o The cookie-path is a prefix of the request-path, and the first
294
+ // character of the request-path that is not included in the cookie- path
295
+ // is a %x2F ("/") character."
296
+ if (reqPath.substr(cookiePath.length,1) === "/")
297
+ return true;
298
+ }
299
+
300
+ return false;
301
+ }
302
+
303
+ function parse(str, strict) {
304
+ str = str.trim();
305
+
306
+ // S4.1.1 Trailing semi-colons are not part of the specification.
307
+ // If we are not in strict mode we remove the trailing semi-colons.
308
+ var semiColonCheck = TRAILING_SEMICOLON.exec(str);
309
+ if (semiColonCheck) {
310
+ if (strict) return;
311
+ str = str.slice(0, semiColonCheck.index);
312
+ }
313
+
314
+ // We use a regex to parse the "name-value-pair" part of S5.2
315
+ var firstSemi = str.indexOf(';'); // S5.2 step 1
316
+ var pairRx = strict ? COOKIE_PAIR_STRICT : COOKIE_PAIR;
317
+ var result = pairRx.exec(firstSemi === -1 ? str : str.substr(0,firstSemi));
318
+
319
+ // Rx satisfies the "the name string is empty" and "lacks a %x3D ("=")"
320
+ // constraints as well as trimming any whitespace.
321
+ if (!result) return;
322
+
323
+ var c = new Cookie();
324
+ c.key = result[1]; // the regexp should trim() already
325
+ c.value = result[3]; // [2] is quotes or empty-string
326
+
327
+ if (firstSemi === -1) return c;
328
+
329
+ // S5.2.3 "unparsed-attributes consist of the remainder of the set-cookie-string
330
+ // (including the %x3B (";") in question)." plus later on in the same section
331
+ // "discard the first ";" and trim".
332
+ var unparsed = str.slice(firstSemi).replace(/^\s*;\s*/,'').trim();
333
+
334
+ // "If the unparsed-attributes string is empty, skip the rest of these
335
+ // steps."
336
+ if (unparsed.length === 0) return c;
337
+
338
+ /*
339
+ * S5.2 says that when looping over the items "[p]rocess the attribute-name
340
+ * and attribute-value according to the requirements in the following
341
+ * subsections" for every item. Plus, for many of the individual attributes
342
+ * in S5.3 it says to use the "attribute-value of the last attribute in the
343
+ * cookie-attribute-list". Therefore, in this implementation, we overwrite
344
+ * the previous value.
345
+ */
346
+ var cookie_avs = unparsed.split(/\s*;\s*/);
347
+ while (cookie_avs.length) {
348
+ var av = cookie_avs.shift();
349
+
350
+ if (strict && !EXTENSION_AV.test(av)) return;
351
+
352
+ var av_sep = av.indexOf('=');
353
+ var av_key, av_value;
354
+ if (av_sep === -1) {
355
+ av_key = av;
356
+ av_value = null;
357
+ } else {
358
+ av_key = av.substr(0,av_sep);
359
+ av_value = av.substr(av_sep+1);
360
+ }
361
+
362
+ av_key = av_key.trim().toLowerCase();
363
+ if (av_value) av_value = av_value.trim();
364
+
365
+ switch(av_key) {
366
+ case 'expires': // S5.2.1
367
+ if (!av_value) { if(strict){return}else{break;} }
368
+ var exp = parseDate(av_value,strict);
369
+ // "If the attribute-value failed to parse as a cookie date, ignore the
370
+ // cookie-av."
371
+ if (exp == null) { if(strict){return}else{break;} }
372
+ c.expires = exp;
373
+ // over and underflow not realistically a concern: V8's getTime() seems to
374
+ // store something larger than a 32-bit time_t (even with 32-bit node)
375
+ break;
376
+
377
+ case 'max-age': // S5.2.2
378
+ if (!av_value) { if(strict){return}else{break;} }
379
+ // "If the first character of the attribute-value is not a DIGIT or a "-"
380
+ // character ...[or]... If the remainder of attribute-value contains a
381
+ // non-DIGIT character, ignore the cookie-av."
382
+ if (!/^-?[0-9]+$/.test(av_value)) { if(strict){return}else{break;} }
383
+ var delta = parseInt(av_value,10);
384
+ if (strict && delta <= 0) return; // S4.1.1
385
+ // "If delta-seconds is less than or equal to zero (0), let expiry-time
386
+ // be the earliest representable date and time."
387
+ c.setMaxAge(delta);
388
+ break;
389
+
390
+ case 'domain': // S5.2.3
391
+ // "If the attribute-value is empty, the behavior is undefined. However,
392
+ // the user agent SHOULD ignore the cookie-av entirely."
393
+ if (!av_value) { if(strict){return}else{break;} }
394
+ // S5.2.3 "Let cookie-domain be the attribute-value without the leading %x2E
395
+ // (".") character."
396
+ var domain = av_value.trim().replace(/^\./,'');
397
+ if (!domain) { if(strict){return}else{break;} } // see "is empty" above
398
+ // "Convert the cookie-domain to lower case."
399
+ c.domain = domain.toLowerCase();
400
+ break;
401
+
402
+ case 'path': // S5.2.4
403
+ /*
404
+ * "If the attribute-value is empty or if the first character of the
405
+ * attribute-value is not %x2F ("/"):
406
+ * Let cookie-path be the default-path.
407
+ * Otherwise:
408
+ * Let cookie-path be the attribute-value."
409
+ *
410
+ * We'll represent the default-path as null since it depends on the
411
+ * context of the parsing.
412
+ */
413
+ if (!av_value || av_value.substr(0,1) != "/") { if(strict){return}else{break;} }
414
+ c.path = av_value;
415
+ break;
416
+
417
+ case 'secure': // S5.2.5
418
+ /*
419
+ * "If the attribute-name case-insensitively matches the string "Secure",
420
+ * the user agent MUST append an attribute to the cookie-attribute-list
421
+ * with an attribute-name of Secure and an empty attribute-value."
422
+ */
423
+ if (av_value != null) { if(strict){return} }
424
+ c.secure = true;
425
+ break;
426
+
427
+ case 'httponly': // S5.2.6 -- effectively the same as 'secure'
428
+ if (av_value != null) { if(strict){return} }
429
+ c.httpOnly = true;
430
+ break;
431
+
432
+ default:
433
+ c.extensions = c.extensions || [];
434
+ c.extensions.push(av);
435
+ break;
436
+ }
437
+ }
438
+
439
+ // ensure a default date for sorting:
440
+ c.creation = new Date();
441
+ return c;
442
+ }
443
+
444
+ function fromJSON(str) {
445
+ if (!str) return null;
446
+
447
+ var obj;
448
+ try {
449
+ obj = JSON.parse(str);
450
+ } catch (e) {
451
+ return null;
452
+ }
453
+
454
+ var c = new Cookie();
455
+ for (var i=0; i<numCookieProperties; i++) {
456
+ var prop = cookieProperties[i];
457
+ if (obj[prop] == null) continue;
458
+ if (prop === 'expires' ||
459
+ prop === 'creation' ||
460
+ prop === 'lastAccessed')
461
+ {
462
+ c[prop] = obj[prop] == "Infinity" ? "Infinity" : new Date(obj[prop]);
463
+ } else {
464
+ c[prop] = obj[prop];
465
+ }
466
+ }
467
+
468
+
469
+ // ensure a default date for sorting:
470
+ c.creation = c.creation || new Date();
471
+
472
+ return c;
473
+ }
474
+
475
+ /* Section 5.4 part 2:
476
+ * "* Cookies with longer paths are listed before cookies with
477
+ * shorter paths.
478
+ *
479
+ * * Among cookies that have equal-length path fields, cookies with
480
+ * earlier creation-times are listed before cookies with later
481
+ * creation-times."
482
+ */
483
+
484
+ function cookieCompare(a,b) {
485
+ // descending for length: b CMP a
486
+ var deltaLen = (b.path ? b.path.length : 0) - (a.path ? a.path.length : 0);
487
+ if (deltaLen !== 0) return deltaLen;
488
+ // ascending for time: a CMP b
489
+ return (a.creation ? a.creation.getTime() : MAX_TIME) -
490
+ (b.creation ? b.creation.getTime() : MAX_TIME);
491
+ }
492
+
493
+ // Gives the permutation of all possible domainMatch()es of a given domain. The
494
+ // array is in shortest-to-longest order. Handy for indexing.
495
+ function permuteDomain(domain) {
496
+ var pubSuf = pubsuffix.getPublicSuffix(domain);
497
+ if (!pubSuf) return null;
498
+ if (pubSuf == domain) return [domain];
499
+
500
+ var prefix = domain.slice(0,-(pubSuf.length+1)); // ".example.com"
501
+ var parts = prefix.split('.').reverse();
502
+ var cur = pubSuf;
503
+ var permutations = [cur];
504
+ while (parts.length) {
505
+ cur = parts.shift()+'.'+cur;
506
+ permutations.push(cur);
507
+ }
508
+ return permutations;
509
+ }
510
+
511
+ // Gives the permutation of all possible pathMatch()es of a given path. The
512
+ // array is in longest-to-shortest order. Handy for indexing.
513
+ function permutePath(path) {
514
+ var origPath = path;
515
+ if (path === '/') return ['/'];
516
+ if (path.lastIndexOf('/') === path.length-1)
517
+ path = path.substr(0,path.length-1);
518
+ var permutations = [path];
519
+ while (path.length > 1) {
520
+ var lindex = path.lastIndexOf('/');
521
+ if (lindex === 0) break;
522
+ path = path.substr(0,lindex);
523
+ permutations.push(path);
524
+ }
525
+ permutations.push('/');
526
+ return permutations;
527
+ }
528
+
529
+
530
+ function Cookie (opts) {
531
+ if (typeof opts !== "object") return;
532
+ Object.keys(opts).forEach(function (key) {
533
+ if (Cookie.prototype.hasOwnProperty(key)) {
534
+ this[key] = opts[key] || Cookie.prototype[key];
535
+ }
536
+ }.bind(this));
537
+ }
538
+
539
+ Cookie.parse = parse;
540
+ Cookie.fromJSON = fromJSON;
541
+
542
+ Cookie.prototype.key = "";
543
+ Cookie.prototype.value = "";
544
+
545
+ // the order in which the RFC has them:
546
+ Cookie.prototype.expires = "Infinity"; // coerces to literal Infinity
547
+ Cookie.prototype.maxAge = null; // takes precedence over expires for TTL
548
+ Cookie.prototype.domain = null;
549
+ Cookie.prototype.path = null;
550
+ Cookie.prototype.secure = false;
551
+ Cookie.prototype.httpOnly = false;
552
+ Cookie.prototype.extensions = null;
553
+
554
+ // set by the CookieJar:
555
+ Cookie.prototype.hostOnly = null; // boolean when set
556
+ Cookie.prototype.pathIsDefault = null; // boolean when set
557
+ Cookie.prototype.creation = null; // Date when set; defaulted by Cookie.parse
558
+ Cookie.prototype.lastAccessed = null; // Date when set
559
+
560
+ var cookieProperties = Object.freeze(Object.keys(Cookie.prototype).map(function(p) {
561
+ if (p instanceof Function) return;
562
+ return p;
563
+ }));
564
+ var numCookieProperties = cookieProperties.length;
565
+
566
+ Cookie.prototype.inspect = function inspect() {
567
+ var now = Date.now();
568
+ return 'Cookie="'+this.toString() +
569
+ '; hostOnly='+(this.hostOnly != null ? this.hostOnly : '?') +
570
+ '; aAge='+(this.lastAccessed ? (now-this.lastAccessed.getTime())+'ms' : '?') +
571
+ '; cAge='+(this.creation ? (now-this.creation.getTime())+'ms' : '?') +
572
+ '"';
573
+ };
574
+
575
+ Cookie.prototype.validate = function validate() {
576
+ if (!COOKIE_OCTETS.test(this.value))
577
+ return false;
578
+ if (this.expires != Infinity && !(this.expires instanceof Date) && !parseDate(this.expires,true))
579
+ return false;
580
+ if (this.maxAge != null && this.maxAge <= 0)
581
+ return false; // "Max-Age=" non-zero-digit *DIGIT
582
+ if (this.path != null && !PATH_VALUE.test(this.path))
583
+ return false;
584
+
585
+ var cdomain = this.cdomain();
586
+ if (cdomain) {
587
+ if (cdomain.match(/\.$/))
588
+ return false; // S4.1.2.3 suggests that this is bad. domainMatch() tests confirm this
589
+ var suffix = pubsuffix.getPublicSuffix(cdomain);
590
+ if (suffix == null) // it's a public suffix
591
+ return false;
592
+ }
593
+ return true;
594
+ };
595
+
596
+ Cookie.prototype.setExpires = function setExpires(exp) {
597
+ if (exp instanceof Date) this.expires = exp;
598
+ else this.expires = parseDate(exp) || "Infinity";
599
+ };
600
+
601
+ Cookie.prototype.setMaxAge = function setMaxAge(age) {
602
+ if (age === Infinity || age === -Infinity)
603
+ this.maxAge = age.toString(); // so JSON.stringify() works
604
+ else
605
+ this.maxAge = age;
606
+ };
607
+
608
+ // gives Cookie header format
609
+ Cookie.prototype.cookieString = function cookieString() {
610
+ var val = this.value;
611
+ if (val == null) val = '';
612
+ if (!val.length || COOKIE_OCTETS.test(val))
613
+ return this.key+'='+val;
614
+ else
615
+ return this.key+'="'+val+'"';
616
+ };
617
+
618
+ // gives Set-Cookie header format
619
+ Cookie.prototype.toString = function toString() {
620
+ var str = this.cookieString();
621
+
622
+ if (this.expires != Infinity) {
623
+ if (this.expires instanceof Date)
624
+ str += '; Expires='+formatDate(this.expires);
625
+ else
626
+ str += '; Expires='+this.expires;
627
+ }
628
+
629
+ if (this.maxAge != null && this.maxAge != Infinity)
630
+ str += '; Max-Age='+this.maxAge;
631
+
632
+ if (this.domain && !this.hostOnly)
633
+ str += '; Domain='+this.domain;
634
+ if (this.path)
635
+ str += '; Path='+this.path;
636
+
637
+ if (this.secure) str += '; Secure';
638
+ if (this.httpOnly) str += '; HttpOnly';
639
+ if (this.extensions) {
640
+ this.extensions.forEach(function(ext) {
641
+ str += '; '+ext;
642
+ });
643
+ }
644
+
645
+ return str;
646
+ };
647
+
648
+ // TTL() partially replaces the "expiry-time" parts of S5.3 step 3 (setCookie()
649
+ // elsewhere)
650
+ // S5.3 says to give the "latest representable date" for which we use Infinity
651
+ // For "expired" we use 0
652
+ Cookie.prototype.TTL = function TTL(now) {
653
+ /* RFC6265 S4.1.2.2 If a cookie has both the Max-Age and the Expires
654
+ * attribute, the Max-Age attribute has precedence and controls the
655
+ * expiration date of the cookie.
656
+ * (Concurs with S5.3 step 3)
657
+ */
658
+ if (this.maxAge != null) {
659
+ return this.maxAge<=0 ? 0 : this.maxAge*1000;
660
+ }
661
+
662
+ var expires = this.expires;
663
+ if (expires != Infinity) {
664
+ if (!(expires instanceof Date)) {
665
+ expires = parseDate(expires) || Infinity;
666
+ }
667
+
668
+ if (expires == Infinity)
669
+ return Infinity;
670
+
671
+ return expires.getTime() - (now || Date.now());
672
+ }
673
+
674
+ return Infinity;
675
+ };
676
+
677
+ // expiryTime() replaces the "expiry-time" parts of S5.3 step 3 (setCookie()
678
+ // elsewhere)
679
+ Cookie.prototype.expiryTime = function expiryTime(now) {
680
+ if (this.maxAge != null) {
681
+ var relativeTo = this.creation || now || new Date();
682
+ var age = (this.maxAge <= 0) ? -Infinity : this.maxAge*1000;
683
+ return relativeTo.getTime() + age;
684
+ }
685
+
686
+ if (this.expires == Infinity) return Infinity;
687
+ return this.expires.getTime();
688
+ };
689
+
690
+ // expiryDate() replaces the "expiry-time" parts of S5.3 step 3 (setCookie()
691
+ // elsewhere), except it returns a Date
692
+ Cookie.prototype.expiryDate = function expiryDate(now) {
693
+ var millisec = this.expiryTime(now);
694
+ if (millisec == Infinity) return new Date(MAX_TIME);
695
+ else if (millisec == -Infinity) return new Date(MIN_TIME);
696
+ else return new Date(millisec);
697
+ };
698
+
699
+ // This replaces the "persistent-flag" parts of S5.3 step 3
700
+ Cookie.prototype.isPersistent = function isPersistent() {
701
+ return (this.maxAge != null || this.expires != Infinity);
702
+ };
703
+
704
+ // Mostly S5.1.2 and S5.2.3:
705
+ Cookie.prototype.cdomain =
706
+ Cookie.prototype.canonicalizedDomain = function canonicalizedDomain() {
707
+ if (this.domain == null) return null;
708
+ return canonicalDomain(this.domain);
709
+ };
710
+
711
+
712
+ var memstore;
713
+ function CookieJar(store, rejectPublicSuffixes) {
714
+ if (rejectPublicSuffixes != null) this.rejectPublicSuffixes = rejectPublicSuffixes;
715
+ if (!store) {
716
+ memstore = memstore || require('./memstore');
717
+ store = new memstore.MemoryCookieStore();
718
+ }
719
+ this.store = store;
720
+ }
721
+ CookieJar.prototype.store = null;
722
+ CookieJar.prototype.rejectPublicSuffixes = true;
723
+
724
+ CookieJar.prototype.setCookie = function setCookie(cookie, url, options, cb) {
725
+ var err;
726
+ var context = (url instanceof Object) ? url : urlParse(url);
727
+ if (options instanceof Function) {
728
+ cb = options;
729
+ options = {};
730
+ }
731
+
732
+ var host = canonicalDomain(context.hostname);
733
+
734
+ // S5.3 step 1
735
+ if (!(cookie instanceof Cookie))
736
+ cookie = Cookie.parse(cookie, options.strict === true);
737
+ if (!cookie) {
738
+ err = new Error("Cookie failed to parse");
739
+ return cb(options.ignoreError ? null : err);
740
+ }
741
+
742
+ // S5.3 step 2
743
+ var now = options.now || new Date(); // will assign later to save effort in the face of errors
744
+
745
+ // S5.3 step 3: NOOP; persistent-flag and expiry-time is handled by getCookie()
746
+
747
+ // S5.3 step 4: NOOP; domain is null by default
748
+
749
+ // S5.3 step 5: public suffixes
750
+ if (this.rejectPublicSuffixes && cookie.domain) {
751
+ var suffix = pubsuffix.getPublicSuffix(cookie.cdomain());
752
+ if (suffix == null) { // e.g. "com"
753
+ err = new Error("Cookie has domain set to a public suffix");
754
+ return cb(options.ignoreError ? null : err);
755
+ }
756
+ }
757
+
758
+ // S5.3 step 6:
759
+ if (cookie.domain) {
760
+ if (!domainMatch(host, cookie.cdomain(), false)) {
761
+ err = new Error("Cookie not in this host's domain. Cookie:"+cookie.cdomain()+" Request:"+host);
762
+ return cb(options.ignoreError ? null : err);
763
+ }
764
+
765
+ if (cookie.hostOnly == null) // don't reset if already set
766
+ cookie.hostOnly = false;
767
+
768
+ } else {
769
+ cookie.hostOnly = true;
770
+ cookie.domain = host;
771
+ }
772
+
773
+ // S5.3 step 7: "Otherwise, set the cookie's path to the default-path of the
774
+ // request-uri"
775
+ if (!cookie.path) {
776
+ cookie.path = defaultPath(context.pathname);
777
+ cookie.pathIsDefault = true;
778
+ } else {
779
+ if (cookie.path.length > 1 && cookie.path.substr(-1) == '/')
780
+ cookie.path = cookie.path.slice(0,-1);
781
+ }
782
+
783
+ // S5.3 step 8: NOOP; secure attribute
784
+ // S5.3 step 9: NOOP; httpOnly attribute
785
+
786
+ // S5.3 step 10
787
+ if (options.http === false && cookie.httpOnly) {
788
+ err = new Error("Cookie is HttpOnly and this isn't an HTTP API");
789
+ return cb(options.ignoreError ? null : err);
790
+ }
791
+
792
+ var store = this.store;
793
+
794
+ if (!store.updateCookie) {
795
+ store.updateCookie = function stubUpdateCookie(oldCookie, newCookie, cb) {
796
+ this.putCookie(newCookie, cb);
797
+ };
798
+ }
799
+
800
+ store.findCookie(cookie.domain, cookie.path, cookie.key, function(err,oldCookie) {
801
+ if (err) return cb(err);
802
+
803
+ var next = function(err) {
804
+ if (err) return cb(err);
805
+ else cb(null, cookie);
806
+ };
807
+
808
+ if (oldCookie) {
809
+ // S5.3 step 11 - "If the cookie store contains a cookie with the same name,
810
+ // domain, and path as the newly created cookie:"
811
+ if (options.http === false && oldCookie.httpOnly) { // step 11.2
812
+ err = new Error("old Cookie is HttpOnly and this isn't an HTTP API");
813
+ return cb(options.ignoreError ? null : err);
814
+ }
815
+ cookie.creation = oldCookie.creation; // step 11.3
816
+ cookie.lastAccessed = now;
817
+ // Step 11.4 (delete cookie) is implied by just setting the new one:
818
+ store.updateCookie(oldCookie, cookie, next); // step 12
819
+
820
+ } else {
821
+ cookie.creation = cookie.lastAccessed = now;
822
+ store.putCookie(cookie, next); // step 12
823
+ }
824
+ });
825
+ };
826
+
827
+ // RFC6365 S5.4
828
+ CookieJar.prototype.getCookies = function getCookies(url, options, cb) {
829
+ var context = (url instanceof Object) ? url : urlParse(url);
830
+ if (options instanceof Function) {
831
+ cb = options;
832
+ options = {};
833
+ }
834
+
835
+ var host = canonicalDomain(context.hostname);
836
+ var path = context.pathname || '/';
837
+
838
+ var secure = options.secure;
839
+ if (secure == null && context.protocol &&
840
+ (context.protocol == 'https:' || context.protocol == 'wss:'))
841
+ {
842
+ secure = true;
843
+ }
844
+
845
+ var http = options.http;
846
+ if (http == null) http = true;
847
+
848
+ var now = options.now || Date.now();
849
+ var expireCheck = options.expire !== false;
850
+ var allPaths = !!options.allPaths;
851
+ var store = this.store;
852
+
853
+ function matchingCookie(c) {
854
+ // "Either:
855
+ // The cookie's host-only-flag is true and the canonicalized
856
+ // request-host is identical to the cookie's domain.
857
+ // Or:
858
+ // The cookie's host-only-flag is false and the canonicalized
859
+ // request-host domain-matches the cookie's domain."
860
+ if (c.hostOnly) {
861
+ if (c.domain != host) return false;
862
+ } else {
863
+ if (!domainMatch(host, c.domain, false)) return false;
864
+ }
865
+
866
+ // "The request-uri's path path-matches the cookie's path."
867
+ if (!allPaths && !pathMatch(path, c.path))
868
+ return false;
869
+
870
+ // "If the cookie's secure-only-flag is true, then the request-uri's
871
+ // scheme must denote a "secure" protocol"
872
+ if (c.secure && !secure)
873
+ return false;
874
+
875
+ // "If the cookie's http-only-flag is true, then exclude the cookie if the
876
+ // cookie-string is being generated for a "non-HTTP" API"
877
+ if (c.httpOnly && !http)
878
+ return false;
879
+
880
+ // deferred from S5.3
881
+ // non-RFC: allow retention of expired cookies by choice
882
+ if (expireCheck && c.expiryTime() <= now) {
883
+ store.removeCookie(c.domain, c.path, c.key, function(){}); // result ignored
884
+ return false;
885
+ }
886
+
887
+ return true;
888
+ }
889
+
890
+ store.findCookies(host, allPaths ? null : path, function(err,cookies) {
891
+ if (err) return cb(err);
892
+
893
+ cookies = cookies.filter(matchingCookie);
894
+
895
+ // sorting of S5.4 part 2
896
+ if (options.sort !== false)
897
+ cookies = cookies.sort(cookieCompare);
898
+
899
+ // S5.4 part 3
900
+ var now = new Date();
901
+ cookies.forEach(function(c) { c.lastAccessed = now });
902
+ // TODO persist lastAccessed
903
+
904
+ cb(null,cookies);
905
+ });
906
+ };
907
+
908
+ CookieJar.prototype.getCookieString = function(/*..., cb*/) {
909
+ var args = Array.prototype.slice.call(arguments,0);
910
+ var cb = args.pop();
911
+ var next = function(err,cookies) {
912
+ if (err) cb(err);
913
+ else cb(null, cookies.map(function(c){return c.cookieString()}).join('; '));
914
+ };
915
+ args.push(next);
916
+ this.getCookies.apply(this,args);
917
+ };
918
+
919
+ CookieJar.prototype.getSetCookieStrings = function(/*..., cb*/) {
920
+ var args = Array.prototype.slice.call(arguments,0);
921
+ var cb = args.pop();
922
+ var next = function(err,cookies) {
923
+ if (err) cb(err);
924
+ else cb(null, cookies.map(function(c){return c.toString()}));
925
+ };
926
+ args.push(next);
927
+ this.getCookies.apply(this,args);
928
+ };
929
+
930
+
931
+
932
+ module.exports = {
933
+ CookieJar: CookieJar,
934
+ Cookie: Cookie,
935
+ parseDate: parseDate,
936
+ formatDate: formatDate,
937
+ parse: parse,
938
+ fromJSON: fromJSON,
939
+ domainMatch: domainMatch,
940
+ defaultPath: defaultPath,
941
+ pathMatch: pathMatch,
942
+ getPublicSuffix: pubsuffix.getPublicSuffix,
943
+ cookieCompare: cookieCompare,
944
+ permuteDomain: permuteDomain,
945
+ permutePath: permutePath,
946
+ canonicalDomain: canonicalDomain,
947
+ };