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,267 @@
1
+ // Copyright 2011 Mark Cavage <mcavage@gmail.com> All rights reserved.
2
+
3
+ var assert = require('assert');
4
+
5
+ var ASN1 = require('./types');
6
+ var errors = require('./errors');
7
+
8
+
9
+ ///--- Globals
10
+
11
+ var newInvalidAsn1Error = errors.newInvalidAsn1Error;
12
+
13
+
14
+
15
+ ///--- API
16
+
17
+ function Reader(data) {
18
+ if (!data || !Buffer.isBuffer(data))
19
+ throw new TypeError('data must be a node Buffer');
20
+
21
+ this._buf = data;
22
+ this._size = data.length;
23
+
24
+ // These hold the "current" state
25
+ this._len = 0;
26
+ this._offset = 0;
27
+
28
+ var self = this;
29
+ this.__defineGetter__('length', function() { return self._len; });
30
+ this.__defineGetter__('offset', function() { return self._offset; });
31
+ this.__defineGetter__('remain', function() {
32
+ return self._size - self._offset;
33
+ });
34
+ this.__defineGetter__('buffer', function() {
35
+ return self._buf.slice(self._offset);
36
+ });
37
+ }
38
+
39
+
40
+ /**
41
+ * Reads a single byte and advances offset; you can pass in `true` to make this
42
+ * a "peek" operation (i.e., get the byte, but don't advance the offset).
43
+ *
44
+ * @param {Boolean} peek true means don't move offset.
45
+ * @return {Number} the next byte, null if not enough data.
46
+ */
47
+ Reader.prototype.readByte = function(peek) {
48
+ if (this._size - this._offset < 1)
49
+ return null;
50
+
51
+ var b = this._buf[this._offset] & 0xff;
52
+
53
+ if (!peek)
54
+ this._offset += 1;
55
+
56
+ return b;
57
+ };
58
+
59
+
60
+ Reader.prototype.peek = function() {
61
+ return this.readByte(true);
62
+ };
63
+
64
+
65
+ /**
66
+ * Reads a (potentially) variable length off the BER buffer. This call is
67
+ * not really meant to be called directly, as callers have to manipulate
68
+ * the internal buffer afterwards.
69
+ *
70
+ * As a result of this call, you can call `Reader.length`, until the
71
+ * next thing called that does a readLength.
72
+ *
73
+ * @return {Number} the amount of offset to advance the buffer.
74
+ * @throws {InvalidAsn1Error} on bad ASN.1
75
+ */
76
+ Reader.prototype.readLength = function(offset) {
77
+ if (offset === undefined)
78
+ offset = this._offset;
79
+
80
+ if (offset >= this._size)
81
+ return null;
82
+
83
+ var lenB = this._buf[offset++] & 0xff;
84
+ if (lenB === null)
85
+ return null;
86
+
87
+ if ((lenB & 0x80) == 0x80) {
88
+ lenB &= 0x7f;
89
+
90
+ if (lenB == 0)
91
+ throw newInvalidAsn1Error('Indefinite length not supported');
92
+
93
+ if (lenB > 4)
94
+ throw newInvalidAsn1Error('encoding too long');
95
+
96
+ if (this._size - offset < lenB)
97
+ return null;
98
+
99
+ this._len = 0;
100
+ for (var i = 0; i < lenB; i++)
101
+ this._len = (this._len << 8) + (this._buf[offset++] & 0xff);
102
+
103
+ } else {
104
+ // Wasn't a variable length
105
+ this._len = lenB;
106
+ }
107
+
108
+ return offset;
109
+ };
110
+
111
+
112
+ /**
113
+ * Parses the next sequence in this BER buffer.
114
+ *
115
+ * To get the length of the sequence, call `Reader.length`.
116
+ *
117
+ * @return {Number} the sequence's tag.
118
+ */
119
+ Reader.prototype.readSequence = function(tag) {
120
+ var seq = this.peek();
121
+ if (seq === null)
122
+ return null;
123
+ if (tag !== undefined && tag !== seq)
124
+ throw newInvalidAsn1Error('Expected 0x' + tag.toString(16) +
125
+ ': got 0x' + seq.toString(16));
126
+
127
+ var o = this.readLength(this._offset + 1); // stored in `length`
128
+ if (o === null)
129
+ return null;
130
+
131
+ this._offset = o;
132
+ return seq;
133
+ };
134
+
135
+
136
+ Reader.prototype.readInt = function() {
137
+ return this._readTag(ASN1.Integer);
138
+ };
139
+
140
+
141
+ Reader.prototype.readBoolean = function() {
142
+ return (this._readTag(ASN1.Boolean) === 0 ? false : true);
143
+ };
144
+
145
+
146
+ Reader.prototype.readEnumeration = function() {
147
+ return this._readTag(ASN1.Enumeration);
148
+ };
149
+
150
+
151
+ Reader.prototype.readString = function(tag, retbuf) {
152
+ if (!tag)
153
+ tag = ASN1.OctetString;
154
+
155
+ var b = this.peek();
156
+ if (b === null)
157
+ return null;
158
+
159
+ if (b !== tag)
160
+ throw newInvalidAsn1Error('Expected 0x' + tag.toString(16) +
161
+ ': got 0x' + b.toString(16));
162
+
163
+ var o = this.readLength(this._offset + 1); // stored in `length`
164
+
165
+ if (o === null)
166
+ return null;
167
+
168
+ if (this.length > this._size - o)
169
+ return null;
170
+
171
+ this._offset = o;
172
+
173
+ if (this.length === 0)
174
+ return '';
175
+
176
+ var str = this._buf.slice(this._offset, this._offset + this.length);
177
+ this._offset += this.length;
178
+
179
+ return retbuf ? str : str.toString('utf8');
180
+ };
181
+
182
+ Reader.prototype.readOID = function(tag) {
183
+ if (!tag)
184
+ tag = ASN1.OID;
185
+
186
+ var b = this.peek();
187
+ if (b === null)
188
+ return null;
189
+
190
+ if (b !== tag)
191
+ throw newInvalidAsn1Error('Expected 0x' + tag.toString(16) +
192
+ ': got 0x' + b.toString(16));
193
+
194
+ var o = this.readLength(this._offset + 1); // stored in `length`
195
+ if (o === null)
196
+ return null;
197
+
198
+ if (this.length > this._size - o)
199
+ return null;
200
+
201
+ this._offset = o;
202
+
203
+ var values = [];
204
+ var value = 0;
205
+
206
+ for (var i = 0; i < this.length; i++) {
207
+ var byte = this._buf[this._offset++] & 0xff;
208
+
209
+ value <<= 7;
210
+ value += byte & 0x7f;
211
+ if ((byte & 0x80) == 0) {
212
+ values.push(value);
213
+ value = 0;
214
+ }
215
+ }
216
+
217
+ value = values.shift();
218
+ values.unshift(value % 40);
219
+ values.unshift((value / 40) >> 0);
220
+
221
+ return values.join('.');
222
+ };
223
+
224
+
225
+ Reader.prototype._readTag = function(tag) {
226
+ assert.ok(tag !== undefined);
227
+
228
+ var b = this.peek();
229
+
230
+ if (b === null)
231
+ return null;
232
+
233
+ if (b !== tag)
234
+ throw newInvalidAsn1Error('Expected 0x' + tag.toString(16) +
235
+ ': got 0x' + b.toString(16));
236
+
237
+ var o = this.readLength(this._offset + 1); // stored in `length`
238
+ if (o === null)
239
+ return null;
240
+
241
+ if (this.length > 4)
242
+ throw newInvalidAsn1Error('Integer too long: ' + this.length);
243
+
244
+ if (this.length > this._size - o)
245
+ return null;
246
+ this._offset = o;
247
+
248
+ var fb = this._buf[this._offset++];
249
+ var value = 0;
250
+
251
+ value = fb & 0x7F;
252
+ for (var i = 1; i < this.length; i++) {
253
+ value <<= 8;
254
+ value |= (this._buf[this._offset++] & 0xff);
255
+ }
256
+
257
+ if ((fb & 0x80) == 0x80)
258
+ value = -value;
259
+
260
+ return value;
261
+ };
262
+
263
+
264
+
265
+ ///--- Exported API
266
+
267
+ module.exports = Reader;
@@ -0,0 +1,36 @@
1
+ // Copyright 2011 Mark Cavage <mcavage@gmail.com> All rights reserved.
2
+
3
+
4
+ module.exports = {
5
+ EOC: 0,
6
+ Boolean: 1,
7
+ Integer: 2,
8
+ BitString: 3,
9
+ OctetString: 4,
10
+ Null: 5,
11
+ OID: 6,
12
+ ObjectDescriptor: 7,
13
+ External: 8,
14
+ Real: 9, // float
15
+ Enumeration: 10,
16
+ PDV: 11,
17
+ Utf8String: 12,
18
+ RelativeOID: 13,
19
+ Sequence: 16,
20
+ Set: 17,
21
+ NumericString: 18,
22
+ PrintableString: 19,
23
+ T61String: 20,
24
+ VideotexString: 21,
25
+ IA5String: 22,
26
+ UTCTime: 23,
27
+ GeneralizedTime: 24,
28
+ GraphicString: 25,
29
+ VisibleString: 26,
30
+ GeneralString: 28,
31
+ UniversalString: 29,
32
+ CharacterString: 30,
33
+ BMPString: 31,
34
+ Constructor: 32,
35
+ Context: 128
36
+ };
@@ -0,0 +1,317 @@
1
+ // Copyright 2011 Mark Cavage <mcavage@gmail.com> All rights reserved.
2
+
3
+ var assert = require('assert');
4
+ var ASN1 = require('./types');
5
+ var errors = require('./errors');
6
+
7
+
8
+ ///--- Globals
9
+
10
+ var newInvalidAsn1Error = errors.newInvalidAsn1Error;
11
+
12
+ var DEFAULT_OPTS = {
13
+ size: 1024,
14
+ growthFactor: 8
15
+ };
16
+
17
+
18
+ ///--- Helpers
19
+
20
+ function merge(from, to) {
21
+ assert.ok(from);
22
+ assert.equal(typeof(from), 'object');
23
+ assert.ok(to);
24
+ assert.equal(typeof(to), 'object');
25
+
26
+ var keys = Object.getOwnPropertyNames(from);
27
+ keys.forEach(function(key) {
28
+ if (to[key])
29
+ return;
30
+
31
+ var value = Object.getOwnPropertyDescriptor(from, key);
32
+ Object.defineProperty(to, key, value);
33
+ });
34
+
35
+ return to;
36
+ }
37
+
38
+
39
+
40
+ ///--- API
41
+
42
+ function Writer(options) {
43
+ options = merge(DEFAULT_OPTS, options || {});
44
+
45
+ this._buf = new Buffer(options.size || 1024);
46
+ this._size = this._buf.length;
47
+ this._offset = 0;
48
+ this._options = options;
49
+
50
+ // A list of offsets in the buffer where we need to insert
51
+ // sequence tag/len pairs.
52
+ this._seq = [];
53
+
54
+ var self = this;
55
+ this.__defineGetter__('buffer', function() {
56
+ if (self._seq.length)
57
+ throw new InvalidAsn1Error(self._seq.length + ' unended sequence(s)');
58
+
59
+ return self._buf.slice(0, self._offset);
60
+ });
61
+ }
62
+
63
+
64
+ Writer.prototype.writeByte = function(b) {
65
+ if (typeof(b) !== 'number')
66
+ throw new TypeError('argument must be a Number');
67
+
68
+ this._ensure(1);
69
+ this._buf[this._offset++] = b;
70
+ };
71
+
72
+
73
+ Writer.prototype.writeInt = function(i, tag) {
74
+ if (typeof(i) !== 'number')
75
+ throw new TypeError('argument must be a Number');
76
+ if (typeof(tag) !== 'number')
77
+ tag = ASN1.Integer;
78
+
79
+ var sz = 4;
80
+
81
+ while ((((i & 0xff800000) === 0) || ((i & 0xff800000) === 0xff800000)) &&
82
+ (sz > 1)) {
83
+ sz--;
84
+ i <<= 8;
85
+ }
86
+
87
+ if (sz > 4)
88
+ throw new InvalidAsn1Error('BER ints cannot be > 0xffffffff');
89
+
90
+ this._ensure(2 + sz);
91
+ this._buf[this._offset++] = tag;
92
+ this._buf[this._offset++] = sz;
93
+
94
+ while (sz-- > 0) {
95
+ this._buf[this._offset++] = ((i & 0xff000000) >> 24);
96
+ i <<= 8;
97
+ }
98
+
99
+ };
100
+
101
+
102
+ Writer.prototype.writeNull = function() {
103
+ this.writeByte(ASN1.Null);
104
+ this.writeByte(0x00);
105
+ };
106
+
107
+
108
+ Writer.prototype.writeEnumeration = function(i, tag) {
109
+ if (typeof(i) !== 'number')
110
+ throw new TypeError('argument must be a Number');
111
+ if (typeof(tag) !== 'number')
112
+ tag = ASN1.Enumeration;
113
+
114
+ return this.writeInt(i, tag);
115
+ };
116
+
117
+
118
+ Writer.prototype.writeBoolean = function(b, tag) {
119
+ if (typeof(b) !== 'boolean')
120
+ throw new TypeError('argument must be a Boolean');
121
+ if (typeof(tag) !== 'number')
122
+ tag = ASN1.Boolean;
123
+
124
+ this._ensure(3);
125
+ this._buf[this._offset++] = tag;
126
+ this._buf[this._offset++] = 0x01;
127
+ this._buf[this._offset++] = b ? 0xff : 0x00;
128
+ };
129
+
130
+
131
+ Writer.prototype.writeString = function(s, tag) {
132
+ if (typeof(s) !== 'string')
133
+ throw new TypeError('argument must be a string (was: ' + typeof(s) + ')');
134
+ if (typeof(tag) !== 'number')
135
+ tag = ASN1.OctetString;
136
+
137
+ var len = Buffer.byteLength(s);
138
+ this.writeByte(tag);
139
+ this.writeLength(len);
140
+ if (len) {
141
+ this._ensure(len);
142
+ this._buf.write(s, this._offset);
143
+ this._offset += len;
144
+ }
145
+ };
146
+
147
+
148
+ Writer.prototype.writeBuffer = function(buf, tag) {
149
+ if (typeof(tag) !== 'number')
150
+ throw new TypeError('tag must be a number');
151
+ if (!Buffer.isBuffer(buf))
152
+ throw new TypeError('argument must be a buffer');
153
+
154
+ this.writeByte(tag);
155
+ this.writeLength(buf.length);
156
+ this._ensure(buf.length);
157
+ buf.copy(this._buf, this._offset, 0, buf.length);
158
+ this._offset += buf.length;
159
+ };
160
+
161
+
162
+ Writer.prototype.writeStringArray = function(strings) {
163
+ if ((!strings instanceof Array))
164
+ throw new TypeError('argument must be an Array[String]');
165
+
166
+ var self = this;
167
+ strings.forEach(function(s) {
168
+ self.writeString(s);
169
+ });
170
+ };
171
+
172
+ // This is really to solve DER cases, but whatever for now
173
+ Writer.prototype.writeOID = function(s, tag) {
174
+ if (typeof(s) !== 'string')
175
+ throw new TypeError('argument must be a string');
176
+ if (typeof(tag) !== 'number')
177
+ tag = ASN1.OID;
178
+
179
+ if (!/^([0-9]+\.){3,}[0-9]+$/.test(s))
180
+ throw new Error('argument is not a valid OID string');
181
+
182
+ function encodeOctet(bytes, octet) {
183
+ if (octet < 128) {
184
+ bytes.push(octet);
185
+ } else if (octet < 16384) {
186
+ bytes.push((octet >>> 7) | 0x80);
187
+ bytes.push(octet & 0x7F);
188
+ } else if (octet < 2097152) {
189
+ bytes.push((octet >>> 14) | 0x80);
190
+ bytes.push(((octet >>> 7) | 0x80) & 0xFF);
191
+ bytes.push(octet & 0x7F);
192
+ } else if (octet < 268435456) {
193
+ bytes.push((octet >>> 21) | 0x80);
194
+ bytes.push(((octet >>> 14) | 0x80) & 0xFF);
195
+ bytes.push(((octet >>> 7) | 0x80) & 0xFF);
196
+ bytes.push(octet & 0x7F);
197
+ } else {
198
+ bytes.push(((octet >>> 28) | 0x80) & 0xFF);
199
+ bytes.push(((octet >>> 21) | 0x80) & 0xFF);
200
+ bytes.push(((octet >>> 14) | 0x80) & 0xFF);
201
+ bytes.push(((octet >>> 7) | 0x80) & 0xFF);
202
+ bytes.push(octet & 0x7F);
203
+ }
204
+ }
205
+
206
+ var tmp = s.split('.');
207
+ var bytes = [];
208
+ bytes.push(parseInt(tmp[0], 10) * 40 + parseInt(tmp[1], 10));
209
+ tmp.slice(2).forEach(function(b) {
210
+ encodeOctet(bytes, parseInt(b, 10));
211
+ });
212
+
213
+ var self = this;
214
+ this._ensure(2 + bytes.length);
215
+ this.writeByte(tag);
216
+ this.writeLength(bytes.length);
217
+ bytes.forEach(function(b) {
218
+ self.writeByte(b);
219
+ });
220
+ };
221
+
222
+
223
+ Writer.prototype.writeLength = function(len) {
224
+ if (typeof(len) !== 'number')
225
+ throw new TypeError('argument must be a Number');
226
+
227
+ this._ensure(4);
228
+
229
+ if (len <= 0x7f) {
230
+ this._buf[this._offset++] = len;
231
+ } else if (len <= 0xff) {
232
+ this._buf[this._offset++] = 0x81;
233
+ this._buf[this._offset++] = len;
234
+ } else if (len <= 0xffff) {
235
+ this._buf[this._offset++] = 0x82;
236
+ this._buf[this._offset++] = len >> 8;
237
+ this._buf[this._offset++] = len;
238
+ } else if (len <= 0xffffff) {
239
+ this._shift(start, len, 1);
240
+ this._buf[this._offset++] = 0x83;
241
+ this._buf[this._offset++] = len >> 16;
242
+ this._buf[this._offset++] = len >> 8;
243
+ this._buf[this._offset++] = len;
244
+ } else {
245
+ throw new InvalidAsn1ERror('Length too long (> 4 bytes)');
246
+ }
247
+ };
248
+
249
+ Writer.prototype.startSequence = function(tag) {
250
+ if (typeof(tag) !== 'number')
251
+ tag = ASN1.Sequence | ASN1.Constructor;
252
+
253
+ this.writeByte(tag);
254
+ this._seq.push(this._offset);
255
+ this._ensure(3);
256
+ this._offset += 3;
257
+ };
258
+
259
+
260
+ Writer.prototype.endSequence = function() {
261
+ var seq = this._seq.pop();
262
+ var start = seq + 3;
263
+ var len = this._offset - start;
264
+
265
+ if (len <= 0x7f) {
266
+ this._shift(start, len, -2);
267
+ this._buf[seq] = len;
268
+ } else if (len <= 0xff) {
269
+ this._shift(start, len, -1);
270
+ this._buf[seq] = 0x81;
271
+ this._buf[seq + 1] = len;
272
+ } else if (len <= 0xffff) {
273
+ this._buf[seq] = 0x82;
274
+ this._buf[seq + 1] = len >> 8;
275
+ this._buf[seq + 2] = len;
276
+ } else if (len <= 0xffffff) {
277
+ this._shift(start, len, 1);
278
+ this._buf[seq] = 0x83;
279
+ this._buf[seq + 1] = len >> 16;
280
+ this._buf[seq + 2] = len >> 8;
281
+ this._buf[seq + 3] = len;
282
+ } else {
283
+ throw new InvalidAsn1Error('Sequence too long');
284
+ }
285
+ };
286
+
287
+
288
+ Writer.prototype._shift = function(start, len, shift) {
289
+ assert.ok(start !== undefined);
290
+ assert.ok(len !== undefined);
291
+ assert.ok(shift);
292
+
293
+ this._buf.copy(this._buf, start + shift, start, start + len);
294
+ this._offset += shift;
295
+ };
296
+
297
+ Writer.prototype._ensure = function(len) {
298
+ assert.ok(len);
299
+
300
+ if (this._size - this._offset < len) {
301
+ var sz = this._size * this._options.growthFactor;
302
+ if (sz - this._offset < len)
303
+ sz += len;
304
+
305
+ var buf = new Buffer(sz);
306
+
307
+ this._buf.copy(buf, 0, 0, this._offset);
308
+ this._buf = buf;
309
+ this._size = sz;
310
+ }
311
+ };
312
+
313
+
314
+
315
+ ///--- Exported API
316
+
317
+ module.exports = Writer;