waves_lib 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1222) hide show
  1. checksums.yaml +7 -0
  2. data/.rspec +3 -0
  3. data/.rubocop.yml +22 -0
  4. data/CHANGELOG.md +5 -0
  5. data/CODE_OF_CONDUCT.md +84 -0
  6. data/LICENSE.txt +19 -0
  7. data/README.md +39 -0
  8. data/Rakefile +12 -0
  9. data/js/node_modules/@protobufjs/aspromise/LICENSE +26 -0
  10. data/js/node_modules/@protobufjs/aspromise/README.md +13 -0
  11. data/js/node_modules/@protobufjs/aspromise/index.d.ts +13 -0
  12. data/js/node_modules/@protobufjs/aspromise/index.js +52 -0
  13. data/js/node_modules/@protobufjs/aspromise/package.json +21 -0
  14. data/js/node_modules/@protobufjs/aspromise/tests/index.js +130 -0
  15. data/js/node_modules/@protobufjs/base64/LICENSE +26 -0
  16. data/js/node_modules/@protobufjs/base64/README.md +19 -0
  17. data/js/node_modules/@protobufjs/base64/index.d.ts +32 -0
  18. data/js/node_modules/@protobufjs/base64/index.js +139 -0
  19. data/js/node_modules/@protobufjs/base64/package.json +21 -0
  20. data/js/node_modules/@protobufjs/base64/tests/index.js +46 -0
  21. data/js/node_modules/@protobufjs/codegen/LICENSE +26 -0
  22. data/js/node_modules/@protobufjs/codegen/README.md +49 -0
  23. data/js/node_modules/@protobufjs/codegen/index.d.ts +31 -0
  24. data/js/node_modules/@protobufjs/codegen/index.js +99 -0
  25. data/js/node_modules/@protobufjs/codegen/package.json +13 -0
  26. data/js/node_modules/@protobufjs/codegen/tests/index.js +13 -0
  27. data/js/node_modules/@protobufjs/eventemitter/LICENSE +26 -0
  28. data/js/node_modules/@protobufjs/eventemitter/README.md +22 -0
  29. data/js/node_modules/@protobufjs/eventemitter/index.d.ts +43 -0
  30. data/js/node_modules/@protobufjs/eventemitter/index.js +76 -0
  31. data/js/node_modules/@protobufjs/eventemitter/package.json +21 -0
  32. data/js/node_modules/@protobufjs/eventemitter/tests/index.js +47 -0
  33. data/js/node_modules/@protobufjs/fetch/LICENSE +26 -0
  34. data/js/node_modules/@protobufjs/fetch/README.md +13 -0
  35. data/js/node_modules/@protobufjs/fetch/index.d.ts +56 -0
  36. data/js/node_modules/@protobufjs/fetch/index.js +115 -0
  37. data/js/node_modules/@protobufjs/fetch/package.json +25 -0
  38. data/js/node_modules/@protobufjs/fetch/tests/index.js +16 -0
  39. data/js/node_modules/@protobufjs/float/LICENSE +26 -0
  40. data/js/node_modules/@protobufjs/float/README.md +102 -0
  41. data/js/node_modules/@protobufjs/float/bench/index.js +87 -0
  42. data/js/node_modules/@protobufjs/float/bench/suite.js +46 -0
  43. data/js/node_modules/@protobufjs/float/index.d.ts +83 -0
  44. data/js/node_modules/@protobufjs/float/index.js +335 -0
  45. data/js/node_modules/@protobufjs/float/package.json +26 -0
  46. data/js/node_modules/@protobufjs/float/tests/index.js +100 -0
  47. data/js/node_modules/@protobufjs/inquire/LICENSE +26 -0
  48. data/js/node_modules/@protobufjs/inquire/README.md +13 -0
  49. data/js/node_modules/@protobufjs/inquire/index.d.ts +9 -0
  50. data/js/node_modules/@protobufjs/inquire/index.js +17 -0
  51. data/js/node_modules/@protobufjs/inquire/package.json +21 -0
  52. data/js/node_modules/@protobufjs/inquire/tests/data/array.js +1 -0
  53. data/js/node_modules/@protobufjs/inquire/tests/data/emptyArray.js +1 -0
  54. data/js/node_modules/@protobufjs/inquire/tests/data/emptyObject.js +1 -0
  55. data/js/node_modules/@protobufjs/inquire/tests/data/object.js +1 -0
  56. data/js/node_modules/@protobufjs/inquire/tests/index.js +20 -0
  57. data/js/node_modules/@protobufjs/path/LICENSE +26 -0
  58. data/js/node_modules/@protobufjs/path/README.md +19 -0
  59. data/js/node_modules/@protobufjs/path/index.d.ts +22 -0
  60. data/js/node_modules/@protobufjs/path/index.js +65 -0
  61. data/js/node_modules/@protobufjs/path/package.json +21 -0
  62. data/js/node_modules/@protobufjs/path/tests/index.js +60 -0
  63. data/js/node_modules/@protobufjs/pool/LICENSE +26 -0
  64. data/js/node_modules/@protobufjs/pool/README.md +13 -0
  65. data/js/node_modules/@protobufjs/pool/index.d.ts +32 -0
  66. data/js/node_modules/@protobufjs/pool/index.js +48 -0
  67. data/js/node_modules/@protobufjs/pool/package.json +21 -0
  68. data/js/node_modules/@protobufjs/pool/tests/index.js +33 -0
  69. data/js/node_modules/@protobufjs/utf8/LICENSE +26 -0
  70. data/js/node_modules/@protobufjs/utf8/README.md +20 -0
  71. data/js/node_modules/@protobufjs/utf8/index.d.ts +24 -0
  72. data/js/node_modules/@protobufjs/utf8/index.js +105 -0
  73. data/js/node_modules/@protobufjs/utf8/package.json +21 -0
  74. data/js/node_modules/@protobufjs/utf8/tests/data/utf8.txt +216 -0
  75. data/js/node_modules/@protobufjs/utf8/tests/index.js +57 -0
  76. data/js/node_modules/@types/base64-js/LICENSE +21 -0
  77. data/js/node_modules/@types/base64-js/README.md +16 -0
  78. data/js/node_modules/@types/base64-js/index.d.ts +23 -0
  79. data/js/node_modules/@types/base64-js/package.json +29 -0
  80. data/js/node_modules/@types/long/LICENSE +21 -0
  81. data/js/node_modules/@types/long/README.md +16 -0
  82. data/js/node_modules/@types/long/index.d.ts +389 -0
  83. data/js/node_modules/@types/long/package.json +25 -0
  84. data/js/node_modules/@types/node/LICENSE +21 -0
  85. data/js/node_modules/@types/node/README.md +16 -0
  86. data/js/node_modules/@types/node/assert/strict.d.ts +8 -0
  87. data/js/node_modules/@types/node/assert.d.ts +972 -0
  88. data/js/node_modules/@types/node/async_hooks.d.ts +530 -0
  89. data/js/node_modules/@types/node/buffer.d.ts +2354 -0
  90. data/js/node_modules/@types/node/child_process.d.ts +1395 -0
  91. data/js/node_modules/@types/node/cluster.d.ts +414 -0
  92. data/js/node_modules/@types/node/console.d.ts +412 -0
  93. data/js/node_modules/@types/node/constants.d.ts +18 -0
  94. data/js/node_modules/@types/node/crypto.d.ts +3978 -0
  95. data/js/node_modules/@types/node/dgram.d.ts +545 -0
  96. data/js/node_modules/@types/node/diagnostics_channel.d.ts +191 -0
  97. data/js/node_modules/@types/node/dns/promises.d.ts +414 -0
  98. data/js/node_modules/@types/node/dns.d.ts +668 -0
  99. data/js/node_modules/@types/node/dom-events.d.ts +126 -0
  100. data/js/node_modules/@types/node/domain.d.ts +170 -0
  101. data/js/node_modules/@types/node/events.d.ts +724 -0
  102. data/js/node_modules/@types/node/fs/promises.d.ts +1190 -0
  103. data/js/node_modules/@types/node/fs.d.ts +4044 -0
  104. data/js/node_modules/@types/node/globals.d.ts +303 -0
  105. data/js/node_modules/@types/node/globals.global.d.ts +1 -0
  106. data/js/node_modules/@types/node/http.d.ts +1724 -0
  107. data/js/node_modules/@types/node/http2.d.ts +2129 -0
  108. data/js/node_modules/@types/node/https.d.ts +441 -0
  109. data/js/node_modules/@types/node/index.d.ts +134 -0
  110. data/js/node_modules/@types/node/inspector.d.ts +2748 -0
  111. data/js/node_modules/@types/node/module.d.ts +129 -0
  112. data/js/node_modules/@types/node/net.d.ts +888 -0
  113. data/js/node_modules/@types/node/os.d.ts +477 -0
  114. data/js/node_modules/@types/node/package.json +237 -0
  115. data/js/node_modules/@types/node/path.d.ts +191 -0
  116. data/js/node_modules/@types/node/perf_hooks.d.ts +638 -0
  117. data/js/node_modules/@types/node/process.d.ts +1494 -0
  118. data/js/node_modules/@types/node/punycode.d.ts +117 -0
  119. data/js/node_modules/@types/node/querystring.d.ts +131 -0
  120. data/js/node_modules/@types/node/readline/promises.d.ts +145 -0
  121. data/js/node_modules/@types/node/readline.d.ts +526 -0
  122. data/js/node_modules/@types/node/repl.d.ts +424 -0
  123. data/js/node_modules/@types/node/stream/consumers.d.ts +12 -0
  124. data/js/node_modules/@types/node/stream/promises.d.ts +42 -0
  125. data/js/node_modules/@types/node/stream/web.d.ts +330 -0
  126. data/js/node_modules/@types/node/stream.d.ts +1421 -0
  127. data/js/node_modules/@types/node/string_decoder.d.ts +67 -0
  128. data/js/node_modules/@types/node/test.d.ts +1383 -0
  129. data/js/node_modules/@types/node/timers/promises.d.ts +93 -0
  130. data/js/node_modules/@types/node/timers.d.ts +215 -0
  131. data/js/node_modules/@types/node/tls.d.ts +1130 -0
  132. data/js/node_modules/@types/node/trace_events.d.ts +182 -0
  133. data/js/node_modules/@types/node/ts4.8/assert/strict.d.ts +8 -0
  134. data/js/node_modules/@types/node/ts4.8/assert.d.ts +972 -0
  135. data/js/node_modules/@types/node/ts4.8/async_hooks.d.ts +530 -0
  136. data/js/node_modules/@types/node/ts4.8/buffer.d.ts +2354 -0
  137. data/js/node_modules/@types/node/ts4.8/child_process.d.ts +1395 -0
  138. data/js/node_modules/@types/node/ts4.8/cluster.d.ts +414 -0
  139. data/js/node_modules/@types/node/ts4.8/console.d.ts +412 -0
  140. data/js/node_modules/@types/node/ts4.8/constants.d.ts +18 -0
  141. data/js/node_modules/@types/node/ts4.8/crypto.d.ts +3977 -0
  142. data/js/node_modules/@types/node/ts4.8/dgram.d.ts +545 -0
  143. data/js/node_modules/@types/node/ts4.8/diagnostics_channel.d.ts +191 -0
  144. data/js/node_modules/@types/node/ts4.8/dns/promises.d.ts +414 -0
  145. data/js/node_modules/@types/node/ts4.8/dns.d.ts +668 -0
  146. data/js/node_modules/@types/node/ts4.8/dom-events.d.ts +126 -0
  147. data/js/node_modules/@types/node/ts4.8/domain.d.ts +170 -0
  148. data/js/node_modules/@types/node/ts4.8/events.d.ts +724 -0
  149. data/js/node_modules/@types/node/ts4.8/fs/promises.d.ts +1189 -0
  150. data/js/node_modules/@types/node/ts4.8/fs.d.ts +4044 -0
  151. data/js/node_modules/@types/node/ts4.8/globals.d.ts +303 -0
  152. data/js/node_modules/@types/node/ts4.8/globals.global.d.ts +1 -0
  153. data/js/node_modules/@types/node/ts4.8/http.d.ts +1724 -0
  154. data/js/node_modules/@types/node/ts4.8/http2.d.ts +2129 -0
  155. data/js/node_modules/@types/node/ts4.8/https.d.ts +441 -0
  156. data/js/node_modules/@types/node/ts4.8/index.d.ts +88 -0
  157. data/js/node_modules/@types/node/ts4.8/inspector.d.ts +2748 -0
  158. data/js/node_modules/@types/node/ts4.8/module.d.ts +129 -0
  159. data/js/node_modules/@types/node/ts4.8/net.d.ts +888 -0
  160. data/js/node_modules/@types/node/ts4.8/os.d.ts +477 -0
  161. data/js/node_modules/@types/node/ts4.8/path.d.ts +191 -0
  162. data/js/node_modules/@types/node/ts4.8/perf_hooks.d.ts +638 -0
  163. data/js/node_modules/@types/node/ts4.8/process.d.ts +1494 -0
  164. data/js/node_modules/@types/node/ts4.8/punycode.d.ts +117 -0
  165. data/js/node_modules/@types/node/ts4.8/querystring.d.ts +131 -0
  166. data/js/node_modules/@types/node/ts4.8/readline/promises.d.ts +145 -0
  167. data/js/node_modules/@types/node/ts4.8/readline.d.ts +526 -0
  168. data/js/node_modules/@types/node/ts4.8/repl.d.ts +424 -0
  169. data/js/node_modules/@types/node/ts4.8/stream/consumers.d.ts +12 -0
  170. data/js/node_modules/@types/node/ts4.8/stream/promises.d.ts +42 -0
  171. data/js/node_modules/@types/node/ts4.8/stream/web.d.ts +330 -0
  172. data/js/node_modules/@types/node/ts4.8/stream.d.ts +1392 -0
  173. data/js/node_modules/@types/node/ts4.8/string_decoder.d.ts +67 -0
  174. data/js/node_modules/@types/node/ts4.8/test.d.ts +1365 -0
  175. data/js/node_modules/@types/node/ts4.8/timers/promises.d.ts +93 -0
  176. data/js/node_modules/@types/node/ts4.8/timers.d.ts +215 -0
  177. data/js/node_modules/@types/node/ts4.8/tls.d.ts +1130 -0
  178. data/js/node_modules/@types/node/ts4.8/trace_events.d.ts +182 -0
  179. data/js/node_modules/@types/node/ts4.8/tty.d.ts +208 -0
  180. data/js/node_modules/@types/node/ts4.8/url.d.ts +901 -0
  181. data/js/node_modules/@types/node/ts4.8/util.d.ts +2116 -0
  182. data/js/node_modules/@types/node/ts4.8/v8.d.ts +635 -0
  183. data/js/node_modules/@types/node/ts4.8/vm.d.ts +894 -0
  184. data/js/node_modules/@types/node/ts4.8/wasi.d.ts +152 -0
  185. data/js/node_modules/@types/node/ts4.8/worker_threads.d.ts +693 -0
  186. data/js/node_modules/@types/node/ts4.8/zlib.d.ts +517 -0
  187. data/js/node_modules/@types/node/tty.d.ts +208 -0
  188. data/js/node_modules/@types/node/url.d.ts +901 -0
  189. data/js/node_modules/@types/node/util.d.ts +2116 -0
  190. data/js/node_modules/@types/node/v8.d.ts +635 -0
  191. data/js/node_modules/@types/node/vm.d.ts +894 -0
  192. data/js/node_modules/@types/node/wasi.d.ts +152 -0
  193. data/js/node_modules/@types/node/worker_threads.d.ts +693 -0
  194. data/js/node_modules/@types/node/zlib.d.ts +517 -0
  195. data/js/node_modules/@types/node-fetch/LICENSE +21 -0
  196. data/js/node_modules/@types/node-fetch/README.md +16 -0
  197. data/js/node_modules/@types/node-fetch/externals.d.ts +24 -0
  198. data/js/node_modules/@types/node-fetch/index.d.ts +224 -0
  199. data/js/node_modules/@types/node-fetch/package.json +83 -0
  200. data/js/node_modules/@waves/bignumber/dist/BigNumber.d.ts +74 -0
  201. data/js/node_modules/@waves/bignumber/dist/BigNumber.js +252 -0
  202. data/js/node_modules/@waves/bignumber/dist/BigNumber.js.map +1 -0
  203. data/js/node_modules/@waves/bignumber/dist/Config.d.ts +22 -0
  204. data/js/node_modules/@waves/bignumber/dist/Config.js +43 -0
  205. data/js/node_modules/@waves/bignumber/dist/Config.js.map +1 -0
  206. data/js/node_modules/@waves/bignumber/dist/bignumber.umd.js +3194 -0
  207. data/js/node_modules/@waves/bignumber/dist/bignumber.umd.min.js +1 -0
  208. data/js/node_modules/@waves/bignumber/dist/index.d.ts +3 -0
  209. data/js/node_modules/@waves/bignumber/dist/index.js +9 -0
  210. data/js/node_modules/@waves/bignumber/dist/index.js.map +1 -0
  211. data/js/node_modules/@waves/bignumber/package.json +64 -0
  212. data/js/node_modules/@waves/bignumber/readme.md +285 -0
  213. data/js/node_modules/@waves/marshall/LICENSE +9 -0
  214. data/js/node_modules/@waves/marshall/README.md +39 -0
  215. data/js/node_modules/@waves/marshall/dist/index.d.ts +26 -0
  216. data/js/node_modules/@waves/marshall/dist/index.js +45 -0
  217. data/js/node_modules/@waves/marshall/dist/index.js.map +1 -0
  218. data/js/node_modules/@waves/marshall/dist/jsonMethods.d.ts +36 -0
  219. data/js/node_modules/@waves/marshall/dist/jsonMethods.js +194 -0
  220. data/js/node_modules/@waves/marshall/dist/jsonMethods.js.map +1 -0
  221. data/js/node_modules/@waves/marshall/dist/libs/Utf8ArrayToStr.d.ts +1 -0
  222. data/js/node_modules/@waves/marshall/dist/libs/Utf8ArrayToStr.js +35 -0
  223. data/js/node_modules/@waves/marshall/dist/libs/Utf8ArrayToStr.js.map +1 -0
  224. data/js/node_modules/@waves/marshall/dist/libs/base58.d.ts +5 -0
  225. data/js/node_modules/@waves/marshall/dist/libs/base58.js +66 -0
  226. data/js/node_modules/@waves/marshall/dist/libs/base58.js.map +1 -0
  227. data/js/node_modules/@waves/marshall/dist/libs/utils.d.ts +2 -0
  228. data/js/node_modules/@waves/marshall/dist/libs/utils.js +6 -0
  229. data/js/node_modules/@waves/marshall/dist/libs/utils.js.map +1 -0
  230. data/js/node_modules/@waves/marshall/dist/min/waves-marshall.min.js +1 -0
  231. data/js/node_modules/@waves/marshall/dist/parse.d.ts +21 -0
  232. data/js/node_modules/@waves/marshall/dist/parse.js +142 -0
  233. data/js/node_modules/@waves/marshall/dist/parse.js.map +1 -0
  234. data/js/node_modules/@waves/marshall/dist/parsePrimitives.d.ts +57 -0
  235. data/js/node_modules/@waves/marshall/dist/parsePrimitives.js +96 -0
  236. data/js/node_modules/@waves/marshall/dist/parsePrimitives.js.map +1 -0
  237. data/js/node_modules/@waves/marshall/dist/schemaTypes.d.ts +62 -0
  238. data/js/node_modules/@waves/marshall/dist/schemaTypes.js +41 -0
  239. data/js/node_modules/@waves/marshall/dist/schemaTypes.js.map +1 -0
  240. data/js/node_modules/@waves/marshall/dist/schemas.d.ts +128 -0
  241. data/js/node_modules/@waves/marshall/dist/schemas.js +542 -0
  242. data/js/node_modules/@waves/marshall/dist/schemas.js.map +1 -0
  243. data/js/node_modules/@waves/marshall/dist/serialize.d.ts +11 -0
  244. data/js/node_modules/@waves/marshall/dist/serialize.js +102 -0
  245. data/js/node_modules/@waves/marshall/dist/serialize.js.map +1 -0
  246. data/js/node_modules/@waves/marshall/dist/serializePrimitives.d.ts +21 -0
  247. data/js/node_modules/@waves/marshall/dist/serializePrimitives.js +63 -0
  248. data/js/node_modules/@waves/marshall/dist/serializePrimitives.js.map +1 -0
  249. data/js/node_modules/@waves/marshall/package.json +45 -0
  250. data/js/node_modules/@waves/marshall/src/index.ts +51 -0
  251. data/js/node_modules/@waves/marshall/src/jsonMethods.ts +231 -0
  252. data/js/node_modules/@waves/marshall/src/libs/Utf8ArrayToStr.ts +35 -0
  253. data/js/node_modules/@waves/marshall/src/libs/base58.ts +88 -0
  254. data/js/node_modules/@waves/marshall/src/libs/utils.ts +6 -0
  255. data/js/node_modules/@waves/marshall/src/parse.ts +157 -0
  256. data/js/node_modules/@waves/marshall/src/parsePrimitives.ts +118 -0
  257. data/js/node_modules/@waves/marshall/src/schemaTypes.ts +91 -0
  258. data/js/node_modules/@waves/marshall/src/schemas.ts +630 -0
  259. data/js/node_modules/@waves/marshall/src/serialize.ts +110 -0
  260. data/js/node_modules/@waves/marshall/src/serializePrimitives.ts +80 -0
  261. data/js/node_modules/@waves/node-api-js/README.md +2 -0
  262. data/js/node_modules/@waves/node-api-js/cjs/api-node/activation/index.d.ts +21 -0
  263. data/js/node_modules/@waves/node-api-js/cjs/api-node/activation/index.js +20 -0
  264. data/js/node_modules/@waves/node-api-js/cjs/api-node/activation/index.js.map +1 -0
  265. data/js/node_modules/@waves/node-api-js/cjs/api-node/addresses/index.d.ts +81 -0
  266. data/js/node_modules/@waves/node-api-js/cjs/api-node/addresses/index.js +174 -0
  267. data/js/node_modules/@waves/node-api-js/cjs/api-node/addresses/index.js.map +1 -0
  268. data/js/node_modules/@waves/node-api-js/cjs/api-node/alias/index.d.ts +6 -0
  269. data/js/node_modules/@waves/node-api-js/cjs/api-node/alias/index.js +22 -0
  270. data/js/node_modules/@waves/node-api-js/cjs/api-node/alias/index.js.map +1 -0
  271. data/js/node_modules/@waves/node-api-js/cjs/api-node/assets/index.d.ts +79 -0
  272. data/js/node_modules/@waves/node-api-js/cjs/api-node/assets/index.js +172 -0
  273. data/js/node_modules/@waves/node-api-js/cjs/api-node/assets/index.js.map +1 -0
  274. data/js/node_modules/@waves/node-api-js/cjs/api-node/blocks/index.d.ts +131 -0
  275. data/js/node_modules/@waves/node-api-js/cjs/api-node/blocks/index.js +210 -0
  276. data/js/node_modules/@waves/node-api-js/cjs/api-node/blocks/index.js.map +1 -0
  277. data/js/node_modules/@waves/node-api-js/cjs/api-node/consensus/index.d.ts +39 -0
  278. data/js/node_modules/@waves/node-api-js/cjs/api-node/consensus/index.js +37 -0
  279. data/js/node_modules/@waves/node-api-js/cjs/api-node/consensus/index.js.map +1 -0
  280. data/js/node_modules/@waves/node-api-js/cjs/api-node/debug/index.d.ts +189 -0
  281. data/js/node_modules/@waves/node-api-js/cjs/api-node/debug/index.js +245 -0
  282. data/js/node_modules/@waves/node-api-js/cjs/api-node/debug/index.js.map +1 -0
  283. data/js/node_modules/@waves/node-api-js/cjs/api-node/eth/index.d.ts +3 -0
  284. data/js/node_modules/@waves/node-api-js/cjs/api-node/eth/index.js +15 -0
  285. data/js/node_modules/@waves/node-api-js/cjs/api-node/eth/index.js.map +1 -0
  286. data/js/node_modules/@waves/node-api-js/cjs/api-node/leasing/index.d.ts +22 -0
  287. data/js/node_modules/@waves/node-api-js/cjs/api-node/leasing/index.js +42 -0
  288. data/js/node_modules/@waves/node-api-js/cjs/api-node/leasing/index.js.map +1 -0
  289. data/js/node_modules/@waves/node-api-js/cjs/api-node/node/index.d.ts +11 -0
  290. data/js/node_modules/@waves/node-api-js/cjs/api-node/node/index.js +20 -0
  291. data/js/node_modules/@waves/node-api-js/cjs/api-node/node/index.js.map +1 -0
  292. data/js/node_modules/@waves/node-api-js/cjs/api-node/peers/index.d.ts +46 -0
  293. data/js/node_modules/@waves/node-api-js/cjs/api-node/peers/index.js +60 -0
  294. data/js/node_modules/@waves/node-api-js/cjs/api-node/peers/index.js.map +1 -0
  295. data/js/node_modules/@waves/node-api-js/cjs/api-node/rewards/index.d.ts +21 -0
  296. data/js/node_modules/@waves/node-api-js/cjs/api-node/rewards/index.js +21 -0
  297. data/js/node_modules/@waves/node-api-js/cjs/api-node/rewards/index.js.map +1 -0
  298. data/js/node_modules/@waves/node-api-js/cjs/api-node/transactions/index.d.ts +73 -0
  299. data/js/node_modules/@waves/node-api-js/cjs/api-node/transactions/index.js +193 -0
  300. data/js/node_modules/@waves/node-api-js/cjs/api-node/transactions/index.js.map +1 -0
  301. data/js/node_modules/@waves/node-api-js/cjs/api-node/utils/index.d.ts +110 -0
  302. data/js/node_modules/@waves/node-api-js/cjs/api-node/utils/index.js +211 -0
  303. data/js/node_modules/@waves/node-api-js/cjs/api-node/utils/index.js.map +1 -0
  304. data/js/node_modules/@waves/node-api-js/cjs/api-node/wallet/index.d.ts +5 -0
  305. data/js/node_modules/@waves/node-api-js/cjs/api-node/wallet/index.js +7 -0
  306. data/js/node_modules/@waves/node-api-js/cjs/api-node/wallet/index.js.map +1 -0
  307. data/js/node_modules/@waves/node-api-js/cjs/constants.d.ts +40 -0
  308. data/js/node_modules/@waves/node-api-js/cjs/constants.js +43 -0
  309. data/js/node_modules/@waves/node-api-js/cjs/constants.js.map +1 -0
  310. data/js/node_modules/@waves/node-api-js/cjs/create.d.ts +1240 -0
  311. data/js/node_modules/@waves/node-api-js/cjs/create.js +119 -0
  312. data/js/node_modules/@waves/node-api-js/cjs/create.js.map +1 -0
  313. data/js/node_modules/@waves/node-api-js/cjs/index.d.ts +9 -0
  314. data/js/node_modules/@waves/node-api-js/cjs/index.js +18 -0
  315. data/js/node_modules/@waves/node-api-js/cjs/index.js.map +1 -0
  316. data/js/node_modules/@waves/node-api-js/cjs/interface.d.ts +44 -0
  317. data/js/node_modules/@waves/node-api-js/cjs/interface.js +10 -0
  318. data/js/node_modules/@waves/node-api-js/cjs/interface.js.map +1 -0
  319. data/js/node_modules/@waves/node-api-js/cjs/tools/adresses/availableSponsoredBalances.d.ts +7 -0
  320. data/js/node_modules/@waves/node-api-js/cjs/tools/adresses/availableSponsoredBalances.js +30 -0
  321. data/js/node_modules/@waves/node-api-js/cjs/tools/adresses/availableSponsoredBalances.js.map +1 -0
  322. data/js/node_modules/@waves/node-api-js/cjs/tools/adresses/ethAddress2waves.d.ts +1 -0
  323. data/js/node_modules/@waves/node-api-js/cjs/tools/adresses/ethAddress2waves.js +47 -0
  324. data/js/node_modules/@waves/node-api-js/cjs/tools/adresses/ethAddress2waves.js.map +1 -0
  325. data/js/node_modules/@waves/node-api-js/cjs/tools/adresses/getAssetIdListByTx.d.ts +2 -0
  326. data/js/node_modules/@waves/node-api-js/cjs/tools/adresses/getAssetIdListByTx.js +48 -0
  327. data/js/node_modules/@waves/node-api-js/cjs/tools/adresses/getAssetIdListByTx.js.map +1 -0
  328. data/js/node_modules/@waves/node-api-js/cjs/tools/adresses/getAssetsByTransaction.d.ts +3 -0
  329. data/js/node_modules/@waves/node-api-js/cjs/tools/adresses/getAssetsByTransaction.js +14 -0
  330. data/js/node_modules/@waves/node-api-js/cjs/tools/adresses/getAssetsByTransaction.js.map +1 -0
  331. data/js/node_modules/@waves/node-api-js/cjs/tools/adresses/getTransactionsWithAssets.d.ts +6 -0
  332. data/js/node_modules/@waves/node-api-js/cjs/tools/adresses/getTransactionsWithAssets.js +13 -0
  333. data/js/node_modules/@waves/node-api-js/cjs/tools/adresses/getTransactionsWithAssets.js.map +1 -0
  334. data/js/node_modules/@waves/node-api-js/cjs/tools/adresses/watch.d.ts +24 -0
  335. data/js/node_modules/@waves/node-api-js/cjs/tools/adresses/watch.js +168 -0
  336. data/js/node_modules/@waves/node-api-js/cjs/tools/adresses/watch.js.map +1 -0
  337. data/js/node_modules/@waves/node-api-js/cjs/tools/adresses/wavesAddress2eth.d.ts +1 -0
  338. data/js/node_modules/@waves/node-api-js/cjs/tools/adresses/wavesAddress2eth.js +10 -0
  339. data/js/node_modules/@waves/node-api-js/cjs/tools/adresses/wavesAddress2eth.js.map +1 -0
  340. data/js/node_modules/@waves/node-api-js/cjs/tools/assets/wavesAsset2eth.d.ts +1 -0
  341. data/js/node_modules/@waves/node-api-js/cjs/tools/assets/wavesAsset2eth.js +10 -0
  342. data/js/node_modules/@waves/node-api-js/cjs/tools/assets/wavesAsset2eth.js.map +1 -0
  343. data/js/node_modules/@waves/node-api-js/cjs/tools/blocks/detectInterval.d.ts +1 -0
  344. data/js/node_modules/@waves/node-api-js/cjs/tools/blocks/detectInterval.js +12 -0
  345. data/js/node_modules/@waves/node-api-js/cjs/tools/blocks/detectInterval.js.map +1 -0
  346. data/js/node_modules/@waves/node-api-js/cjs/tools/blocks/getNetworkByte.d.ts +1 -0
  347. data/js/node_modules/@waves/node-api-js/cjs/tools/blocks/getNetworkByte.js +54 -0
  348. data/js/node_modules/@waves/node-api-js/cjs/tools/blocks/getNetworkByte.js.map +1 -0
  349. data/js/node_modules/@waves/node-api-js/cjs/tools/blocks/getNetworkCode.d.ts +1 -0
  350. data/js/node_modules/@waves/node-api-js/cjs/tools/blocks/getNetworkCode.js +11 -0
  351. data/js/node_modules/@waves/node-api-js/cjs/tools/blocks/getNetworkCode.js.map +1 -0
  352. data/js/node_modules/@waves/node-api-js/cjs/tools/blocks/waitHeight.d.ts +3 -0
  353. data/js/node_modules/@waves/node-api-js/cjs/tools/blocks/waitHeight.js +65 -0
  354. data/js/node_modules/@waves/node-api-js/cjs/tools/blocks/waitHeight.js.map +1 -0
  355. data/js/node_modules/@waves/node-api-js/cjs/tools/parse.d.ts +1 -0
  356. data/js/node_modules/@waves/node-api-js/cjs/tools/parse.js +8 -0
  357. data/js/node_modules/@waves/node-api-js/cjs/tools/parse.js.map +1 -0
  358. data/js/node_modules/@waves/node-api-js/cjs/tools/query.d.ts +4 -0
  359. data/js/node_modules/@waves/node-api-js/cjs/tools/query.js +41 -0
  360. data/js/node_modules/@waves/node-api-js/cjs/tools/query.js.map +1 -0
  361. data/js/node_modules/@waves/node-api-js/cjs/tools/request.d.ts +64 -0
  362. data/js/node_modules/@waves/node-api-js/cjs/tools/request.js +42 -0
  363. data/js/node_modules/@waves/node-api-js/cjs/tools/request.js.map +1 -0
  364. data/js/node_modules/@waves/node-api-js/cjs/tools/resolve.d.ts +1 -0
  365. data/js/node_modules/@waves/node-api-js/cjs/tools/resolve.js +7 -0
  366. data/js/node_modules/@waves/node-api-js/cjs/tools/resolve.js.map +1 -0
  367. data/js/node_modules/@waves/node-api-js/cjs/tools/stringify.d.ts +1 -0
  368. data/js/node_modules/@waves/node-api-js/cjs/tools/stringify.js +21 -0
  369. data/js/node_modules/@waves/node-api-js/cjs/tools/stringify.js.map +1 -0
  370. data/js/node_modules/@waves/node-api-js/cjs/tools/transactions/broadcast.d.ts +14 -0
  371. data/js/node_modules/@waves/node-api-js/cjs/tools/transactions/broadcast.js +60 -0
  372. data/js/node_modules/@waves/node-api-js/cjs/tools/transactions/broadcast.js.map +1 -0
  373. data/js/node_modules/@waves/node-api-js/cjs/tools/transactions/ethTxId2waves.d.ts +1 -0
  374. data/js/node_modules/@waves/node-api-js/cjs/tools/transactions/ethTxId2waves.js +11 -0
  375. data/js/node_modules/@waves/node-api-js/cjs/tools/transactions/ethTxId2waves.js.map +1 -0
  376. data/js/node_modules/@waves/node-api-js/cjs/tools/transactions/transactions.d.ts +0 -0
  377. data/js/node_modules/@waves/node-api-js/cjs/tools/transactions/transactions.js +2 -0
  378. data/js/node_modules/@waves/node-api-js/cjs/tools/transactions/transactions.js.map +1 -0
  379. data/js/node_modules/@waves/node-api-js/cjs/tools/transactions/wait.d.ts +10 -0
  380. data/js/node_modules/@waves/node-api-js/cjs/tools/transactions/wait.js +42 -0
  381. data/js/node_modules/@waves/node-api-js/cjs/tools/transactions/wait.js.map +1 -0
  382. data/js/node_modules/@waves/node-api-js/cjs/tools/utils.d.ts +32 -0
  383. data/js/node_modules/@waves/node-api-js/cjs/tools/utils.js +118 -0
  384. data/js/node_modules/@waves/node-api-js/cjs/tools/utils.js.map +1 -0
  385. data/js/node_modules/@waves/node-api-js/dist/0.node-api.js +467 -0
  386. data/js/node_modules/@waves/node-api-js/dist/node-api.js +30544 -0
  387. data/js/node_modules/@waves/node-api-js/dist/node-api.min.js +26 -0
  388. data/js/node_modules/@waves/node-api-js/dist/node-api.min.js.LICENSE.txt +17 -0
  389. data/js/node_modules/@waves/node-api-js/dist/node_fs-node_path.node-api.js +23 -0
  390. data/js/node_modules/@waves/node-api-js/dist/vendors-node_modules_node-fetch_src_utils_multipart-parser_js.node-api.js +599 -0
  391. data/js/node_modules/@waves/node-api-js/es/api-node/activation/index.d.ts +21 -0
  392. data/js/node_modules/@waves/node-api-js/es/api-node/activation/index.js +13 -0
  393. data/js/node_modules/@waves/node-api-js/es/api-node/activation/index.js.map +1 -0
  394. data/js/node_modules/@waves/node-api-js/es/api-node/addresses/index.d.ts +81 -0
  395. data/js/node_modules/@waves/node-api-js/es/api-node/addresses/index.js +111 -0
  396. data/js/node_modules/@waves/node-api-js/es/api-node/addresses/index.js.map +1 -0
  397. data/js/node_modules/@waves/node-api-js/es/api-node/alias/index.d.ts +6 -0
  398. data/js/node_modules/@waves/node-api-js/es/api-node/alias/index.js +14 -0
  399. data/js/node_modules/@waves/node-api-js/es/api-node/alias/index.js.map +1 -0
  400. data/js/node_modules/@waves/node-api-js/es/api-node/assets/index.d.ts +79 -0
  401. data/js/node_modules/@waves/node-api-js/es/api-node/assets/index.js +103 -0
  402. data/js/node_modules/@waves/node-api-js/es/api-node/assets/index.js.map +1 -0
  403. data/js/node_modules/@waves/node-api-js/es/api-node/blocks/index.d.ts +131 -0
  404. data/js/node_modules/@waves/node-api-js/es/api-node/blocks/index.js +179 -0
  405. data/js/node_modules/@waves/node-api-js/es/api-node/blocks/index.js.map +1 -0
  406. data/js/node_modules/@waves/node-api-js/es/api-node/consensus/index.d.ts +39 -0
  407. data/js/node_modules/@waves/node-api-js/es/api-node/consensus/index.js +27 -0
  408. data/js/node_modules/@waves/node-api-js/es/api-node/consensus/index.js.map +1 -0
  409. data/js/node_modules/@waves/node-api-js/es/api-node/debug/index.d.ts +189 -0
  410. data/js/node_modules/@waves/node-api-js/es/api-node/debug/index.js +201 -0
  411. data/js/node_modules/@waves/node-api-js/es/api-node/debug/index.js.map +1 -0
  412. data/js/node_modules/@waves/node-api-js/es/api-node/eth/index.d.ts +3 -0
  413. data/js/node_modules/@waves/node-api-js/es/api-node/eth/index.js +8 -0
  414. data/js/node_modules/@waves/node-api-js/es/api-node/eth/index.js.map +1 -0
  415. data/js/node_modules/@waves/node-api-js/es/api-node/leasing/index.d.ts +22 -0
  416. data/js/node_modules/@waves/node-api-js/es/api-node/leasing/index.js +22 -0
  417. data/js/node_modules/@waves/node-api-js/es/api-node/leasing/index.js.map +1 -0
  418. data/js/node_modules/@waves/node-api-js/es/api-node/node/index.d.ts +11 -0
  419. data/js/node_modules/@waves/node-api-js/es/api-node/node/index.js +10 -0
  420. data/js/node_modules/@waves/node-api-js/es/api-node/node/index.js.map +1 -0
  421. data/js/node_modules/@waves/node-api-js/es/api-node/peers/index.d.ts +46 -0
  422. data/js/node_modules/@waves/node-api-js/es/api-node/peers/index.js +46 -0
  423. data/js/node_modules/@waves/node-api-js/es/api-node/peers/index.js.map +1 -0
  424. data/js/node_modules/@waves/node-api-js/es/api-node/rewards/index.d.ts +21 -0
  425. data/js/node_modules/@waves/node-api-js/es/api-node/rewards/index.js +13 -0
  426. data/js/node_modules/@waves/node-api-js/es/api-node/rewards/index.js.map +1 -0
  427. data/js/node_modules/@waves/node-api-js/es/api-node/transactions/index.d.ts +73 -0
  428. data/js/node_modules/@waves/node-api-js/es/api-node/transactions/index.js +137 -0
  429. data/js/node_modules/@waves/node-api-js/es/api-node/transactions/index.js.map +1 -0
  430. data/js/node_modules/@waves/node-api-js/es/api-node/utils/index.d.ts +110 -0
  431. data/js/node_modules/@waves/node-api-js/es/api-node/utils/index.js +193 -0
  432. data/js/node_modules/@waves/node-api-js/es/api-node/utils/index.js.map +1 -0
  433. data/js/node_modules/@waves/node-api-js/es/api-node/wallet/index.d.ts +5 -0
  434. data/js/node_modules/@waves/node-api-js/es/api-node/wallet/index.js +7 -0
  435. data/js/node_modules/@waves/node-api-js/es/api-node/wallet/index.js.map +1 -0
  436. data/js/node_modules/@waves/node-api-js/es/constants.d.ts +40 -0
  437. data/js/node_modules/@waves/node-api-js/es/constants.js +40 -0
  438. data/js/node_modules/@waves/node-api-js/es/constants.js.map +1 -0
  439. data/js/node_modules/@waves/node-api-js/es/create.d.ts +1240 -0
  440. data/js/node_modules/@waves/node-api-js/es/create.js +93 -0
  441. data/js/node_modules/@waves/node-api-js/es/create.js.map +1 -0
  442. data/js/node_modules/@waves/node-api-js/es/index.d.ts +9 -0
  443. data/js/node_modules/@waves/node-api-js/es/index.js +9 -0
  444. data/js/node_modules/@waves/node-api-js/es/index.js.map +1 -0
  445. data/js/node_modules/@waves/node-api-js/es/interface.d.ts +44 -0
  446. data/js/node_modules/@waves/node-api-js/es/interface.js +3 -0
  447. data/js/node_modules/@waves/node-api-js/es/interface.js.map +1 -0
  448. data/js/node_modules/@waves/node-api-js/es/tools/adresses/availableSponsoredBalances.d.ts +7 -0
  449. data/js/node_modules/@waves/node-api-js/es/tools/adresses/availableSponsoredBalances.js +27 -0
  450. data/js/node_modules/@waves/node-api-js/es/tools/adresses/availableSponsoredBalances.js.map +1 -0
  451. data/js/node_modules/@waves/node-api-js/es/tools/adresses/ethAddress2waves.d.ts +1 -0
  452. data/js/node_modules/@waves/node-api-js/es/tools/adresses/ethAddress2waves.js +31 -0
  453. data/js/node_modules/@waves/node-api-js/es/tools/adresses/ethAddress2waves.js.map +1 -0
  454. data/js/node_modules/@waves/node-api-js/es/tools/adresses/getAssetIdListByTx.d.ts +2 -0
  455. data/js/node_modules/@waves/node-api-js/es/tools/adresses/getAssetIdListByTx.js +24 -0
  456. data/js/node_modules/@waves/node-api-js/es/tools/adresses/getAssetIdListByTx.js.map +1 -0
  457. data/js/node_modules/@waves/node-api-js/es/tools/adresses/getAssetsByTransaction.d.ts +3 -0
  458. data/js/node_modules/@waves/node-api-js/es/tools/adresses/getAssetsByTransaction.js +8 -0
  459. data/js/node_modules/@waves/node-api-js/es/tools/adresses/getAssetsByTransaction.js.map +1 -0
  460. data/js/node_modules/@waves/node-api-js/es/tools/adresses/getTransactionsWithAssets.d.ts +6 -0
  461. data/js/node_modules/@waves/node-api-js/es/tools/adresses/getTransactionsWithAssets.js +7 -0
  462. data/js/node_modules/@waves/node-api-js/es/tools/adresses/getTransactionsWithAssets.js.map +1 -0
  463. data/js/node_modules/@waves/node-api-js/es/tools/adresses/watch.d.ts +24 -0
  464. data/js/node_modules/@waves/node-api-js/es/tools/adresses/watch.js +134 -0
  465. data/js/node_modules/@waves/node-api-js/es/tools/adresses/watch.js.map +1 -0
  466. data/js/node_modules/@waves/node-api-js/es/tools/adresses/wavesAddress2eth.d.ts +1 -0
  467. data/js/node_modules/@waves/node-api-js/es/tools/adresses/wavesAddress2eth.js +7 -0
  468. data/js/node_modules/@waves/node-api-js/es/tools/adresses/wavesAddress2eth.js.map +1 -0
  469. data/js/node_modules/@waves/node-api-js/es/tools/assets/wavesAsset2eth.d.ts +1 -0
  470. data/js/node_modules/@waves/node-api-js/es/tools/assets/wavesAsset2eth.js +7 -0
  471. data/js/node_modules/@waves/node-api-js/es/tools/assets/wavesAsset2eth.js.map +1 -0
  472. data/js/node_modules/@waves/node-api-js/es/tools/blocks/detectInterval.d.ts +1 -0
  473. data/js/node_modules/@waves/node-api-js/es/tools/blocks/detectInterval.js +9 -0
  474. data/js/node_modules/@waves/node-api-js/es/tools/blocks/detectInterval.js.map +1 -0
  475. data/js/node_modules/@waves/node-api-js/es/tools/blocks/getNetworkByte.d.ts +1 -0
  476. data/js/node_modules/@waves/node-api-js/es/tools/blocks/getNetworkByte.js +51 -0
  477. data/js/node_modules/@waves/node-api-js/es/tools/blocks/getNetworkByte.js.map +1 -0
  478. data/js/node_modules/@waves/node-api-js/es/tools/blocks/getNetworkCode.d.ts +1 -0
  479. data/js/node_modules/@waves/node-api-js/es/tools/blocks/getNetworkCode.js +5 -0
  480. data/js/node_modules/@waves/node-api-js/es/tools/blocks/getNetworkCode.js.map +1 -0
  481. data/js/node_modules/@waves/node-api-js/es/tools/blocks/waitHeight.d.ts +3 -0
  482. data/js/node_modules/@waves/node-api-js/es/tools/blocks/waitHeight.js +36 -0
  483. data/js/node_modules/@waves/node-api-js/es/tools/blocks/waitHeight.js.map +1 -0
  484. data/js/node_modules/@waves/node-api-js/es/tools/parse.d.ts +1 -0
  485. data/js/node_modules/@waves/node-api-js/es/tools/parse.js +5 -0
  486. data/js/node_modules/@waves/node-api-js/es/tools/parse.js.map +1 -0
  487. data/js/node_modules/@waves/node-api-js/es/tools/query.d.ts +4 -0
  488. data/js/node_modules/@waves/node-api-js/es/tools/query.js +12 -0
  489. data/js/node_modules/@waves/node-api-js/es/tools/query.js.map +1 -0
  490. data/js/node_modules/@waves/node-api-js/es/tools/request.d.ts +64 -0
  491. data/js/node_modules/@waves/node-api-js/es/tools/request.js +22 -0
  492. data/js/node_modules/@waves/node-api-js/es/tools/request.js.map +1 -0
  493. data/js/node_modules/@waves/node-api-js/es/tools/resolve.d.ts +1 -0
  494. data/js/node_modules/@waves/node-api-js/es/tools/resolve.js +4 -0
  495. data/js/node_modules/@waves/node-api-js/es/tools/resolve.js.map +1 -0
  496. data/js/node_modules/@waves/node-api-js/es/tools/stringify.d.ts +1 -0
  497. data/js/node_modules/@waves/node-api-js/es/tools/stringify.js +18 -0
  498. data/js/node_modules/@waves/node-api-js/es/tools/stringify.js.map +1 -0
  499. data/js/node_modules/@waves/node-api-js/es/tools/transactions/broadcast.d.ts +14 -0
  500. data/js/node_modules/@waves/node-api-js/es/tools/transactions/broadcast.js +43 -0
  501. data/js/node_modules/@waves/node-api-js/es/tools/transactions/broadcast.js.map +1 -0
  502. data/js/node_modules/@waves/node-api-js/es/tools/transactions/ethTxId2waves.d.ts +1 -0
  503. data/js/node_modules/@waves/node-api-js/es/tools/transactions/ethTxId2waves.js +8 -0
  504. data/js/node_modules/@waves/node-api-js/es/tools/transactions/ethTxId2waves.js.map +1 -0
  505. data/js/node_modules/@waves/node-api-js/es/tools/transactions/transactions.d.ts +0 -0
  506. data/js/node_modules/@waves/node-api-js/es/tools/transactions/transactions.js +2 -0
  507. data/js/node_modules/@waves/node-api-js/es/tools/transactions/transactions.js.map +1 -0
  508. data/js/node_modules/@waves/node-api-js/es/tools/transactions/wait.d.ts +10 -0
  509. data/js/node_modules/@waves/node-api-js/es/tools/transactions/wait.js +39 -0
  510. data/js/node_modules/@waves/node-api-js/es/tools/transactions/wait.js.map +1 -0
  511. data/js/node_modules/@waves/node-api-js/es/tools/utils.d.ts +32 -0
  512. data/js/node_modules/@waves/node-api-js/es/tools/utils.js +73 -0
  513. data/js/node_modules/@waves/node-api-js/es/tools/utils.js.map +1 -0
  514. data/js/node_modules/@waves/node-api-js/package.json +66 -0
  515. data/js/node_modules/@waves/parse-json-bignumber/coverage/clover.xml +225 -0
  516. data/js/node_modules/@waves/parse-json-bignumber/coverage/coverage-final.json +2 -0
  517. data/js/node_modules/@waves/parse-json-bignumber/coverage/lcov-report/base.css +212 -0
  518. data/js/node_modules/@waves/parse-json-bignumber/coverage/lcov-report/index.html +93 -0
  519. data/js/node_modules/@waves/parse-json-bignumber/coverage/lcov-report/parse-json-bignumber.ts.html +1598 -0
  520. data/js/node_modules/@waves/parse-json-bignumber/coverage/lcov-report/prettify.css +1 -0
  521. data/js/node_modules/@waves/parse-json-bignumber/coverage/lcov-report/prettify.js +1 -0
  522. data/js/node_modules/@waves/parse-json-bignumber/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  523. data/js/node_modules/@waves/parse-json-bignumber/coverage/lcov-report/sorter.js +158 -0
  524. data/js/node_modules/@waves/parse-json-bignumber/coverage/lcov.info +415 -0
  525. data/js/node_modules/@waves/parse-json-bignumber/dist/parse-json-bignumber.d.ts +11 -0
  526. data/js/node_modules/@waves/parse-json-bignumber/dist/parse-json-bignumber.js +412 -0
  527. data/js/node_modules/@waves/parse-json-bignumber/dist/parse-json-bignumber.min.js +1 -0
  528. data/js/node_modules/@waves/parse-json-bignumber/package.json +40 -0
  529. data/js/node_modules/@waves/parse-json-bignumber/src/parse-json-bignumber.ts +511 -0
  530. data/js/node_modules/@waves/parse-json-bignumber/test/index.ts +130 -0
  531. data/js/node_modules/@waves/parse-json-bignumber/test/tsconfig.json +14 -0
  532. data/js/node_modules/@waves/parse-json-bignumber/tsconfig.json +15 -0
  533. data/js/node_modules/@waves/protobuf-serialization/README.MD +116 -0
  534. data/js/node_modules/@waves/protobuf-serialization/dist/index.d.ts +2005 -0
  535. data/js/node_modules/@waves/protobuf-serialization/dist/index.js +6636 -0
  536. data/js/node_modules/@waves/protobuf-serialization/package.json +30 -0
  537. data/js/node_modules/@waves/protobuf-serialization/proto/waves/amount.proto +10 -0
  538. data/js/node_modules/@waves/protobuf-serialization/proto/waves/block.proto +40 -0
  539. data/js/node_modules/@waves/protobuf-serialization/proto/waves/events/events.proto +213 -0
  540. data/js/node_modules/@waves/protobuf-serialization/proto/waves/events/grpc/blockchain_updates.proto +42 -0
  541. data/js/node_modules/@waves/protobuf-serialization/proto/waves/invoke_script_result.proto +98 -0
  542. data/js/node_modules/@waves/protobuf-serialization/proto/waves/lang/dapp_meta.proto +21 -0
  543. data/js/node_modules/@waves/protobuf-serialization/proto/waves/node/grpc/accounts_api.proto +68 -0
  544. data/js/node_modules/@waves/protobuf-serialization/proto/waves/node/grpc/assets_api.proto +41 -0
  545. data/js/node_modules/@waves/protobuf-serialization/proto/waves/node/grpc/blockchain_api.proto +54 -0
  546. data/js/node_modules/@waves/protobuf-serialization/proto/waves/node/grpc/blocks_api.proto +41 -0
  547. data/js/node_modules/@waves/protobuf-serialization/proto/waves/node/grpc/transactions_api.proto +73 -0
  548. data/js/node_modules/@waves/protobuf-serialization/proto/waves/order.proto +43 -0
  549. data/js/node_modules/@waves/protobuf-serialization/proto/waves/recipient.proto +13 -0
  550. data/js/node_modules/@waves/protobuf-serialization/proto/waves/transaction.proto +156 -0
  551. data/js/node_modules/@waves/ts-lib-crypto/README.md +492 -0
  552. data/js/node_modules/@waves/ts-lib-crypto/bytes.d.ts +10 -0
  553. data/js/node_modules/@waves/ts-lib-crypto/bytes.js +21 -0
  554. data/js/node_modules/@waves/ts-lib-crypto/bytes.js.map +1 -0
  555. data/js/node_modules/@waves/ts-lib-crypto/conversions/base-xx.d.ts +7 -0
  556. data/js/node_modules/@waves/ts-lib-crypto/conversions/base-xx.js +27 -0
  557. data/js/node_modules/@waves/ts-lib-crypto/conversions/base-xx.js.map +1 -0
  558. data/js/node_modules/@waves/ts-lib-crypto/conversions/param.d.ts +3 -0
  559. data/js/node_modules/@waves/ts-lib-crypto/conversions/param.js +24 -0
  560. data/js/node_modules/@waves/ts-lib-crypto/conversions/param.js.map +1 -0
  561. data/js/node_modules/@waves/ts-lib-crypto/conversions/string-bytes.d.ts +11 -0
  562. data/js/node_modules/@waves/ts-lib-crypto/conversions/string-bytes.js +65 -0
  563. data/js/node_modules/@waves/ts-lib-crypto/conversions/string-bytes.js.map +1 -0
  564. data/js/node_modules/@waves/ts-lib-crypto/crypto/address-keys-seed.d.ts +7 -0
  565. data/js/node_modules/@waves/ts-lib-crypto/crypto/address-keys-seed.js +58 -0
  566. data/js/node_modules/@waves/ts-lib-crypto/crypto/address-keys-seed.js.map +1 -0
  567. data/js/node_modules/@waves/ts-lib-crypto/crypto/concat-split.d.ts +3 -0
  568. data/js/node_modules/@waves/ts-lib-crypto/crypto/concat-split.js +39 -0
  569. data/js/node_modules/@waves/ts-lib-crypto/crypto/concat-split.js.map +1 -0
  570. data/js/node_modules/@waves/ts-lib-crypto/crypto/crypto.d.ts +13 -0
  571. data/js/node_modules/@waves/ts-lib-crypto/crypto/crypto.js +117 -0
  572. data/js/node_modules/@waves/ts-lib-crypto/crypto/crypto.js.map +1 -0
  573. data/js/node_modules/@waves/ts-lib-crypto/crypto/encryption.d.ts +6 -0
  574. data/js/node_modules/@waves/ts-lib-crypto/crypto/encryption.js +89 -0
  575. data/js/node_modules/@waves/ts-lib-crypto/crypto/encryption.js.map +1 -0
  576. data/js/node_modules/@waves/ts-lib-crypto/crypto/hashing.d.ts +7 -0
  577. data/js/node_modules/@waves/ts-lib-crypto/crypto/hashing.js +39 -0
  578. data/js/node_modules/@waves/ts-lib-crypto/crypto/hashing.js.map +1 -0
  579. data/js/node_modules/@waves/ts-lib-crypto/crypto/interface.d.ts +98 -0
  580. data/js/node_modules/@waves/ts-lib-crypto/crypto/interface.js +9 -0
  581. data/js/node_modules/@waves/ts-lib-crypto/crypto/interface.js.map +1 -0
  582. data/js/node_modules/@waves/ts-lib-crypto/crypto/merkle-verify.d.ts +7 -0
  583. data/js/node_modules/@waves/ts-lib-crypto/crypto/merkle-verify.js +51 -0
  584. data/js/node_modules/@waves/ts-lib-crypto/crypto/merkle-verify.js.map +1 -0
  585. data/js/node_modules/@waves/ts-lib-crypto/crypto/random.d.ts +4 -0
  586. data/js/node_modules/@waves/ts-lib-crypto/crypto/random.js +51 -0
  587. data/js/node_modules/@waves/ts-lib-crypto/crypto/random.js.map +1 -0
  588. data/js/node_modules/@waves/ts-lib-crypto/crypto/rsa.d.ts +7 -0
  589. data/js/node_modules/@waves/ts-lib-crypto/crypto/rsa.js +159 -0
  590. data/js/node_modules/@waves/ts-lib-crypto/crypto/rsa.js.map +1 -0
  591. data/js/node_modules/@waves/ts-lib-crypto/crypto/seed-ecryption.d.ts +9 -0
  592. data/js/node_modules/@waves/ts-lib-crypto/crypto/seed-ecryption.js +62 -0
  593. data/js/node_modules/@waves/ts-lib-crypto/crypto/seed-ecryption.js.map +1 -0
  594. data/js/node_modules/@waves/ts-lib-crypto/crypto/seed-words-list.d.ts +1 -0
  595. data/js/node_modules/@waves/ts-lib-crypto/crypto/seed-words-list.js +189 -0
  596. data/js/node_modules/@waves/ts-lib-crypto/crypto/seed-words-list.js.map +1 -0
  597. data/js/node_modules/@waves/ts-lib-crypto/crypto/sign.d.ts +2 -0
  598. data/js/node_modules/@waves/ts-lib-crypto/crypto/sign.js +16 -0
  599. data/js/node_modules/@waves/ts-lib-crypto/crypto/sign.js.map +1 -0
  600. data/js/node_modules/@waves/ts-lib-crypto/crypto/util.d.ts +3 -0
  601. data/js/node_modules/@waves/ts-lib-crypto/crypto/util.js +9 -0
  602. data/js/node_modules/@waves/ts-lib-crypto/crypto/util.js.map +1 -0
  603. data/js/node_modules/@waves/ts-lib-crypto/crypto/verification.d.ts +7 -0
  604. data/js/node_modules/@waves/ts-lib-crypto/crypto/verification.js +49 -0
  605. data/js/node_modules/@waves/ts-lib-crypto/crypto/verification.js.map +1 -0
  606. data/js/node_modules/@waves/ts-lib-crypto/extensions/chain-id.d.ts +5 -0
  607. data/js/node_modules/@waves/ts-lib-crypto/extensions/chain-id.js +16 -0
  608. data/js/node_modules/@waves/ts-lib-crypto/extensions/chain-id.js.map +1 -0
  609. data/js/node_modules/@waves/ts-lib-crypto/extensions/seed.d.ts +6 -0
  610. data/js/node_modules/@waves/ts-lib-crypto/extensions/seed.js +18 -0
  611. data/js/node_modules/@waves/ts-lib-crypto/extensions/seed.js.map +1 -0
  612. data/js/node_modules/@waves/ts-lib-crypto/index.d.ts +10 -0
  613. data/js/node_modules/@waves/ts-lib-crypto/index.js +21 -0
  614. data/js/node_modules/@waves/ts-lib-crypto/index.js.map +1 -0
  615. data/js/node_modules/@waves/ts-lib-crypto/libs/Utf8.d.ts +2 -0
  616. data/js/node_modules/@waves/ts-lib-crypto/libs/Utf8.js +61 -0
  617. data/js/node_modules/@waves/ts-lib-crypto/libs/Utf8.js.map +1 -0
  618. data/js/node_modules/@waves/ts-lib-crypto/libs/axlsign.js +1374 -0
  619. data/js/node_modules/@waves/ts-lib-crypto/libs/base58.d.ts +5 -0
  620. data/js/node_modules/@waves/ts-lib-crypto/libs/base58.js +66 -0
  621. data/js/node_modules/@waves/ts-lib-crypto/libs/base58.js.map +1 -0
  622. data/js/node_modules/@waves/ts-lib-crypto/libs/blake2b.js +308 -0
  623. data/js/node_modules/@waves/ts-lib-crypto/libs/sha3.js +441 -0
  624. data/js/node_modules/@waves/ts-lib-crypto/min/waves-lib-crypto.js +33 -0
  625. data/js/node_modules/@waves/ts-lib-crypto/package.json +31 -0
  626. data/js/node_modules/@waves/ts-types/dist/src/common.d.ts +59 -0
  627. data/js/node_modules/@waves/ts-types/dist/src/common.js +53 -0
  628. data/js/node_modules/@waves/ts-types/dist/src/exchange.d.ts +47 -0
  629. data/js/node_modules/@waves/ts-types/dist/src/exchange.js +2 -0
  630. data/js/node_modules/@waves/ts-types/dist/src/index.d.ts +52 -0
  631. data/js/node_modules/@waves/ts-types/dist/src/index.js +63 -0
  632. data/js/node_modules/@waves/ts-types/dist/src/invoke.d.ts +22 -0
  633. data/js/node_modules/@waves/ts-types/dist/src/invoke.js +2 -0
  634. data/js/node_modules/@waves/ts-types/dist/src/network.d.ts +6 -0
  635. data/js/node_modules/@waves/ts-types/dist/src/network.js +10 -0
  636. data/js/node_modules/@waves/ts-types/dist/src/parts.d.ts +159 -0
  637. data/js/node_modules/@waves/ts-types/dist/src/parts.js +2 -0
  638. data/js/node_modules/@waves/ts-types/dist/transactions/index.d.ts +363 -0
  639. data/js/node_modules/@waves/ts-types/dist/transactions/index.js +3 -0
  640. data/js/node_modules/@waves/ts-types/index.ts +1 -0
  641. data/js/node_modules/@waves/ts-types/package.json +41 -0
  642. data/js/node_modules/@waves/ts-types/src/index.ts +57 -0
  643. data/js/node_modules/@waves/ts-types/src/parts.ts +247 -0
  644. data/js/node_modules/@waves/ts-types/transactions/index.ts +789 -0
  645. data/js/node_modules/@waves/ts-types/tsconfig.json +16 -0
  646. data/js/node_modules/@waves/waves-transactions/README.md +432 -0
  647. data/js/node_modules/@waves/waves-transactions/dist/defaultVersions.d.ts +18 -0
  648. data/js/node_modules/@waves/waves-transactions/dist/defaultVersions.js +22 -0
  649. data/js/node_modules/@waves/waves-transactions/dist/defaultVersions.js.map +1 -0
  650. data/js/node_modules/@waves/waves-transactions/dist/general.d.ts +68 -0
  651. data/js/node_modules/@waves/waves-transactions/dist/general.js +135 -0
  652. data/js/node_modules/@waves/waves-transactions/dist/general.js.map +1 -0
  653. data/js/node_modules/@waves/waves-transactions/dist/generic.d.ts +28 -0
  654. data/js/node_modules/@waves/waves-transactions/dist/generic.js +88 -0
  655. data/js/node_modules/@waves/waves-transactions/dist/generic.js.map +1 -0
  656. data/js/node_modules/@waves/waves-transactions/dist/index.d.ts +37 -0
  657. data/js/node_modules/@waves/waves-transactions/dist/index.js +98 -0
  658. data/js/node_modules/@waves/waves-transactions/dist/index.js.map +1 -0
  659. data/js/node_modules/@waves/waves-transactions/dist/make-tx.d.ts +50 -0
  660. data/js/node_modules/@waves/waves-transactions/dist/make-tx.js +106 -0
  661. data/js/node_modules/@waves/waves-transactions/dist/make-tx.js.map +1 -0
  662. data/js/node_modules/@waves/waves-transactions/dist/min/waves-transactions.min.js +26 -0
  663. data/js/node_modules/@waves/waves-transactions/dist/nodeInteraction.d.ts +116 -0
  664. data/js/node_modules/@waves/waves-transactions/dist/nodeInteraction.js +277 -0
  665. data/js/node_modules/@waves/waves-transactions/dist/nodeInteraction.js.map +1 -0
  666. data/js/node_modules/@waves/waves-transactions/dist/proto-serialize.d.ts +62 -0
  667. data/js/node_modules/@waves/waves-transactions/dist/proto-serialize.js +514 -0
  668. data/js/node_modules/@waves/waves-transactions/dist/proto-serialize.js.map +1 -0
  669. data/js/node_modules/@waves/waves-transactions/dist/requests/auth.d.ts +7 -0
  670. data/js/node_modules/@waves/waves-transactions/dist/requests/auth.js +31 -0
  671. data/js/node_modules/@waves/waves-transactions/dist/requests/auth.js.map +1 -0
  672. data/js/node_modules/@waves/waves-transactions/dist/requests/cancel-order.d.ts +7 -0
  673. data/js/node_modules/@waves/waves-transactions/dist/requests/cancel-order.js +29 -0
  674. data/js/node_modules/@waves/waves-transactions/dist/requests/cancel-order.js.map +1 -0
  675. data/js/node_modules/@waves/waves-transactions/dist/requests/custom-data.d.ts +40 -0
  676. data/js/node_modules/@waves/waves-transactions/dist/requests/custom-data.js +37 -0
  677. data/js/node_modules/@waves/waves-transactions/dist/requests/custom-data.js.map +1 -0
  678. data/js/node_modules/@waves/waves-transactions/dist/requests/order.d.ts +50 -0
  679. data/js/node_modules/@waves/waves-transactions/dist/requests/order.js +62 -0
  680. data/js/node_modules/@waves/waves-transactions/dist/requests/order.js.map +1 -0
  681. data/js/node_modules/@waves/waves-transactions/dist/requests/wavesAuth.d.ts +7 -0
  682. data/js/node_modules/@waves/waves-transactions/dist/requests/wavesAuth.js +31 -0
  683. data/js/node_modules/@waves/waves-transactions/dist/requests/wavesAuth.js.map +1 -0
  684. data/js/node_modules/@waves/waves-transactions/dist/seedUtils/index.d.ts +21 -0
  685. data/js/node_modules/@waves/waves-transactions/dist/seedUtils/index.js +85 -0
  686. data/js/node_modules/@waves/waves-transactions/dist/seedUtils/index.js.map +1 -0
  687. data/js/node_modules/@waves/waves-transactions/dist/transactions/alias.d.ts +8 -0
  688. data/js/node_modules/@waves/waves-transactions/dist/transactions/alias.js +35 -0
  689. data/js/node_modules/@waves/waves-transactions/dist/transactions/alias.js.map +1 -0
  690. data/js/node_modules/@waves/waves-transactions/dist/transactions/burn.d.ts +8 -0
  691. data/js/node_modules/@waves/waves-transactions/dist/transactions/burn.js +35 -0
  692. data/js/node_modules/@waves/waves-transactions/dist/transactions/burn.js.map +1 -0
  693. data/js/node_modules/@waves/waves-transactions/dist/transactions/cancel-lease.d.ts +8 -0
  694. data/js/node_modules/@waves/waves-transactions/dist/transactions/cancel-lease.js +34 -0
  695. data/js/node_modules/@waves/waves-transactions/dist/transactions/cancel-lease.js.map +1 -0
  696. data/js/node_modules/@waves/waves-transactions/dist/transactions/data.d.ts +5 -0
  697. data/js/node_modules/@waves/waves-transactions/dist/transactions/data.js +112 -0
  698. data/js/node_modules/@waves/waves-transactions/dist/transactions/data.js.map +1 -0
  699. data/js/node_modules/@waves/waves-transactions/dist/transactions/exchange.d.ts +7 -0
  700. data/js/node_modules/@waves/waves-transactions/dist/transactions/exchange.js +39 -0
  701. data/js/node_modules/@waves/waves-transactions/dist/transactions/exchange.js.map +1 -0
  702. data/js/node_modules/@waves/waves-transactions/dist/transactions/invoke-expression.d.ts +0 -0
  703. data/js/node_modules/@waves/waves-transactions/dist/transactions/invoke-expression.js +52 -0
  704. data/js/node_modules/@waves/waves-transactions/dist/transactions/invoke-expression.js.map +1 -0
  705. data/js/node_modules/@waves/waves-transactions/dist/transactions/invoke-script.d.ts +8 -0
  706. data/js/node_modules/@waves/waves-transactions/dist/transactions/invoke-script.js +43 -0
  707. data/js/node_modules/@waves/waves-transactions/dist/transactions/invoke-script.js.map +1 -0
  708. data/js/node_modules/@waves/waves-transactions/dist/transactions/issue.d.ts +8 -0
  709. data/js/node_modules/@waves/waves-transactions/dist/transactions/issue.js +42 -0
  710. data/js/node_modules/@waves/waves-transactions/dist/transactions/issue.js.map +1 -0
  711. data/js/node_modules/@waves/waves-transactions/dist/transactions/lease.d.ts +8 -0
  712. data/js/node_modules/@waves/waves-transactions/dist/transactions/lease.js +35 -0
  713. data/js/node_modules/@waves/waves-transactions/dist/transactions/lease.js.map +1 -0
  714. data/js/node_modules/@waves/waves-transactions/dist/transactions/mass-transfer.d.ts +8 -0
  715. data/js/node_modules/@waves/waves-transactions/dist/transactions/mass-transfer.js +39 -0
  716. data/js/node_modules/@waves/waves-transactions/dist/transactions/mass-transfer.js.map +1 -0
  717. data/js/node_modules/@waves/waves-transactions/dist/transactions/reissue.d.ts +8 -0
  718. data/js/node_modules/@waves/waves-transactions/dist/transactions/reissue.js +36 -0
  719. data/js/node_modules/@waves/waves-transactions/dist/transactions/reissue.js.map +1 -0
  720. data/js/node_modules/@waves/waves-transactions/dist/transactions/set-asset-script.d.ts +8 -0
  721. data/js/node_modules/@waves/waves-transactions/dist/transactions/set-asset-script.js +37 -0
  722. data/js/node_modules/@waves/waves-transactions/dist/transactions/set-asset-script.js.map +1 -0
  723. data/js/node_modules/@waves/waves-transactions/dist/transactions/set-script.d.ts +8 -0
  724. data/js/node_modules/@waves/waves-transactions/dist/transactions/set-script.js +38 -0
  725. data/js/node_modules/@waves/waves-transactions/dist/transactions/set-script.js.map +1 -0
  726. data/js/node_modules/@waves/waves-transactions/dist/transactions/sponsorship.d.ts +8 -0
  727. data/js/node_modules/@waves/waves-transactions/dist/transactions/sponsorship.js +35 -0
  728. data/js/node_modules/@waves/waves-transactions/dist/transactions/sponsorship.js.map +1 -0
  729. data/js/node_modules/@waves/waves-transactions/dist/transactions/transfer.d.ts +8 -0
  730. data/js/node_modules/@waves/waves-transactions/dist/transactions/transfer.js +38 -0
  731. data/js/node_modules/@waves/waves-transactions/dist/transactions/transfer.js.map +1 -0
  732. data/js/node_modules/@waves/waves-transactions/dist/transactions/update-asset-info.d.ts +8 -0
  733. data/js/node_modules/@waves/waves-transactions/dist/transactions/update-asset-info.js +35 -0
  734. data/js/node_modules/@waves/waves-transactions/dist/transactions/update-asset-info.js.map +1 -0
  735. data/js/node_modules/@waves/waves-transactions/dist/transactions.d.ts +277 -0
  736. data/js/node_modules/@waves/waves-transactions/dist/transactions.js +3 -0
  737. data/js/node_modules/@waves/waves-transactions/dist/transactions.js.map +1 -0
  738. data/js/node_modules/@waves/waves-transactions/dist/types.d.ts +11 -0
  739. data/js/node_modules/@waves/waves-transactions/dist/types.js +6 -0
  740. data/js/node_modules/@waves/waves-transactions/dist/types.js.map +1 -0
  741. data/js/node_modules/@waves/waves-transactions/dist/validators/alias.d.ts +1 -0
  742. data/js/node_modules/@waves/waves-transactions/dist/validators/alias.js +17 -0
  743. data/js/node_modules/@waves/waves-transactions/dist/validators/alias.js.map +1 -0
  744. data/js/node_modules/@waves/waves-transactions/dist/validators/auth.d.ts +1 -0
  745. data/js/node_modules/@waves/waves-transactions/dist/validators/auth.js +10 -0
  746. data/js/node_modules/@waves/waves-transactions/dist/validators/auth.js.map +1 -0
  747. data/js/node_modules/@waves/waves-transactions/dist/validators/burn.d.ts +1 -0
  748. data/js/node_modules/@waves/waves-transactions/dist/validators/burn.js +18 -0
  749. data/js/node_modules/@waves/waves-transactions/dist/validators/burn.js.map +1 -0
  750. data/js/node_modules/@waves/waves-transactions/dist/validators/cancel-lease.d.ts +1 -0
  751. data/js/node_modules/@waves/waves-transactions/dist/validators/cancel-lease.js +17 -0
  752. data/js/node_modules/@waves/waves-transactions/dist/validators/cancel-lease.js.map +1 -0
  753. data/js/node_modules/@waves/waves-transactions/dist/validators/cancel-order.d.ts +1 -0
  754. data/js/node_modules/@waves/waves-transactions/dist/validators/cancel-order.js +12 -0
  755. data/js/node_modules/@waves/waves-transactions/dist/validators/cancel-order.js.map +1 -0
  756. data/js/node_modules/@waves/waves-transactions/dist/validators/custom-data.d.ts +1 -0
  757. data/js/node_modules/@waves/waves-transactions/dist/validators/custom-data.js +16 -0
  758. data/js/node_modules/@waves/waves-transactions/dist/validators/custom-data.js.map +1 -0
  759. data/js/node_modules/@waves/waves-transactions/dist/validators/data.d.ts +2 -0
  760. data/js/node_modules/@waves/waves-transactions/dist/validators/data.js +18 -0
  761. data/js/node_modules/@waves/waves-transactions/dist/validators/data.js.map +1 -0
  762. data/js/node_modules/@waves/waves-transactions/dist/validators/exchange.d.ts +1 -0
  763. data/js/node_modules/@waves/waves-transactions/dist/validators/exchange.js +22 -0
  764. data/js/node_modules/@waves/waves-transactions/dist/validators/exchange.js.map +1 -0
  765. data/js/node_modules/@waves/waves-transactions/dist/validators/index.d.ts +24 -0
  766. data/js/node_modules/@waves/waves-transactions/dist/validators/index.js +60 -0
  767. data/js/node_modules/@waves/waves-transactions/dist/validators/index.js.map +1 -0
  768. data/js/node_modules/@waves/waves-transactions/dist/validators/invoke-expression.d.ts +0 -0
  769. data/js/node_modules/@waves/waves-transactions/dist/validators/invoke-expression.js +33 -0
  770. data/js/node_modules/@waves/waves-transactions/dist/validators/invoke-expression.js.map +1 -0
  771. data/js/node_modules/@waves/waves-transactions/dist/validators/invoke-script.d.ts +1 -0
  772. data/js/node_modules/@waves/waves-transactions/dist/validators/invoke-script.js +20 -0
  773. data/js/node_modules/@waves/waves-transactions/dist/validators/invoke-script.js.map +1 -0
  774. data/js/node_modules/@waves/waves-transactions/dist/validators/issue.d.ts +1 -0
  775. data/js/node_modules/@waves/waves-transactions/dist/validators/issue.js +22 -0
  776. data/js/node_modules/@waves/waves-transactions/dist/validators/issue.js.map +1 -0
  777. data/js/node_modules/@waves/waves-transactions/dist/validators/lease.d.ts +1 -0
  778. data/js/node_modules/@waves/waves-transactions/dist/validators/lease.js +17 -0
  779. data/js/node_modules/@waves/waves-transactions/dist/validators/lease.js.map +1 -0
  780. data/js/node_modules/@waves/waves-transactions/dist/validators/mass-transfer.d.ts +1 -0
  781. data/js/node_modules/@waves/waves-transactions/dist/validators/mass-transfer.js +18 -0
  782. data/js/node_modules/@waves/waves-transactions/dist/validators/mass-transfer.js.map +1 -0
  783. data/js/node_modules/@waves/waves-transactions/dist/validators/order.d.ts +1 -0
  784. data/js/node_modules/@waves/waves-transactions/dist/validators/order.js +34 -0
  785. data/js/node_modules/@waves/waves-transactions/dist/validators/order.js.map +1 -0
  786. data/js/node_modules/@waves/waves-transactions/dist/validators/reissue.d.ts +1 -0
  787. data/js/node_modules/@waves/waves-transactions/dist/validators/reissue.js +19 -0
  788. data/js/node_modules/@waves/waves-transactions/dist/validators/reissue.js.map +1 -0
  789. data/js/node_modules/@waves/waves-transactions/dist/validators/set-asset-script.d.ts +1 -0
  790. data/js/node_modules/@waves/waves-transactions/dist/validators/set-asset-script.js +18 -0
  791. data/js/node_modules/@waves/waves-transactions/dist/validators/set-asset-script.js.map +1 -0
  792. data/js/node_modules/@waves/waves-transactions/dist/validators/set-script.d.ts +1 -0
  793. data/js/node_modules/@waves/waves-transactions/dist/validators/set-script.js +17 -0
  794. data/js/node_modules/@waves/waves-transactions/dist/validators/set-script.js.map +1 -0
  795. data/js/node_modules/@waves/waves-transactions/dist/validators/sponsorship.d.ts +1 -0
  796. data/js/node_modules/@waves/waves-transactions/dist/validators/sponsorship.js +17 -0
  797. data/js/node_modules/@waves/waves-transactions/dist/validators/sponsorship.js.map +1 -0
  798. data/js/node_modules/@waves/waves-transactions/dist/validators/transfer.d.ts +1 -0
  799. data/js/node_modules/@waves/waves-transactions/dist/validators/transfer.js +20 -0
  800. data/js/node_modules/@waves/waves-transactions/dist/validators/transfer.js.map +1 -0
  801. data/js/node_modules/@waves/waves-transactions/dist/validators/update-asset-info.d.ts +1 -0
  802. data/js/node_modules/@waves/waves-transactions/dist/validators/update-asset-info.js +18 -0
  803. data/js/node_modules/@waves/waves-transactions/dist/validators/update-asset-info.js.map +1 -0
  804. data/js/node_modules/@waves/waves-transactions/dist/validators/validators.d.ts +52 -0
  805. data/js/node_modules/@waves/waves-transactions/dist/validators/validators.js +160 -0
  806. data/js/node_modules/@waves/waves-transactions/dist/validators/validators.js.map +1 -0
  807. data/js/node_modules/@waves/waves-transactions/dist/validators/wavesAuth.d.ts +1 -0
  808. data/js/node_modules/@waves/waves-transactions/dist/validators/wavesAuth.js +10 -0
  809. data/js/node_modules/@waves/waves-transactions/dist/validators/wavesAuth.js.map +1 -0
  810. data/js/node_modules/@waves/waves-transactions/package.json +83 -0
  811. data/js/node_modules/@waves/waves-transactions/src/defaultVersions.ts +18 -0
  812. data/js/node_modules/@waves/waves-transactions/src/general.ts +165 -0
  813. data/js/node_modules/@waves/waves-transactions/src/generic.ts +88 -0
  814. data/js/node_modules/@waves/waves-transactions/src/index.ts +87 -0
  815. data/js/node_modules/@waves/waves-transactions/src/make-tx.ts +179 -0
  816. data/js/node_modules/@waves/waves-transactions/src/nodeInteraction.ts +297 -0
  817. data/js/node_modules/@waves/waves-transactions/src/proto-serialize.ts +571 -0
  818. data/js/node_modules/@waves/waves-transactions/src/requests/auth.ts +42 -0
  819. data/js/node_modules/@waves/waves-transactions/src/requests/cancel-order.ts +37 -0
  820. data/js/node_modules/@waves/waves-transactions/src/requests/custom-data.ts +73 -0
  821. data/js/node_modules/@waves/waves-transactions/src/requests/order.ts +121 -0
  822. data/js/node_modules/@waves/waves-transactions/src/requests/wavesAuth.ts +40 -0
  823. data/js/node_modules/@waves/waves-transactions/src/seedUtils/index.ts +124 -0
  824. data/js/node_modules/@waves/waves-transactions/src/transactions/alias.ts +46 -0
  825. data/js/node_modules/@waves/waves-transactions/src/transactions/burn.ts +45 -0
  826. data/js/node_modules/@waves/waves-transactions/src/transactions/cancel-lease.ts +44 -0
  827. data/js/node_modules/@waves/waves-transactions/src/transactions/data.ts +122 -0
  828. data/js/node_modules/@waves/waves-transactions/src/transactions/exchange.ts +47 -0
  829. data/js/node_modules/@waves/waves-transactions/src/transactions/invoke-expression.ts +50 -0
  830. data/js/node_modules/@waves/waves-transactions/src/transactions/invoke-script.ts +54 -0
  831. data/js/node_modules/@waves/waves-transactions/src/transactions/issue.ts +52 -0
  832. data/js/node_modules/@waves/waves-transactions/src/transactions/lease.ts +45 -0
  833. data/js/node_modules/@waves/waves-transactions/src/transactions/mass-transfer.ts +55 -0
  834. data/js/node_modules/@waves/waves-transactions/src/transactions/reissue.ts +46 -0
  835. data/js/node_modules/@waves/waves-transactions/src/transactions/set-asset-script.ts +57 -0
  836. data/js/node_modules/@waves/waves-transactions/src/transactions/set-script.ts +54 -0
  837. data/js/node_modules/@waves/waves-transactions/src/transactions/sponsorship.ts +45 -0
  838. data/js/node_modules/@waves/waves-transactions/src/transactions/transfer.ts +55 -0
  839. data/js/node_modules/@waves/waves-transactions/src/transactions/update-asset-info.ts +44 -0
  840. data/js/node_modules/@waves/waves-transactions/src/transactions.ts +352 -0
  841. data/js/node_modules/@waves/waves-transactions/src/types.ts +12 -0
  842. data/js/node_modules/@waves/waves-transactions/src/validators/alias.ts +28 -0
  843. data/js/node_modules/@waves/waves-transactions/src/validators/auth.ts +14 -0
  844. data/js/node_modules/@waves/waves-transactions/src/validators/burn.ts +29 -0
  845. data/js/node_modules/@waves/waves-transactions/src/validators/cancel-lease.ts +27 -0
  846. data/js/node_modules/@waves/waves-transactions/src/validators/cancel-order.ts +17 -0
  847. data/js/node_modules/@waves/waves-transactions/src/validators/custom-data.ts +40 -0
  848. data/js/node_modules/@waves/waves-transactions/src/validators/data.ts +33 -0
  849. data/js/node_modules/@waves/waves-transactions/src/validators/exchange.ts +36 -0
  850. data/js/node_modules/@waves/waves-transactions/src/validators/index.ts +50 -0
  851. data/js/node_modules/@waves/waves-transactions/src/validators/invoke-expression.ts +31 -0
  852. data/js/node_modules/@waves/waves-transactions/src/validators/invoke-script.ts +64 -0
  853. data/js/node_modules/@waves/waves-transactions/src/validators/issue.ts +41 -0
  854. data/js/node_modules/@waves/waves-transactions/src/validators/lease.ts +29 -0
  855. data/js/node_modules/@waves/waves-transactions/src/validators/mass-transfer.ts +47 -0
  856. data/js/node_modules/@waves/waves-transactions/src/validators/order.ts +68 -0
  857. data/js/node_modules/@waves/waves-transactions/src/validators/reissue.ts +31 -0
  858. data/js/node_modules/@waves/waves-transactions/src/validators/set-asset-script.ts +28 -0
  859. data/js/node_modules/@waves/waves-transactions/src/validators/set-script.ts +28 -0
  860. data/js/node_modules/@waves/waves-transactions/src/validators/sponsorship.ts +28 -0
  861. data/js/node_modules/@waves/waves-transactions/src/validators/transfer.ts +32 -0
  862. data/js/node_modules/@waves/waves-transactions/src/validators/update-asset-info.ts +32 -0
  863. data/js/node_modules/@waves/waves-transactions/src/validators/validators.ts +306 -0
  864. data/js/node_modules/@waves/waves-transactions/src/validators/wavesAuth.ts +15 -0
  865. data/js/node_modules/asynckit/LICENSE +21 -0
  866. data/js/node_modules/asynckit/README.md +233 -0
  867. data/js/node_modules/asynckit/bench.js +76 -0
  868. data/js/node_modules/asynckit/index.js +6 -0
  869. data/js/node_modules/asynckit/lib/abort.js +29 -0
  870. data/js/node_modules/asynckit/lib/async.js +34 -0
  871. data/js/node_modules/asynckit/lib/defer.js +26 -0
  872. data/js/node_modules/asynckit/lib/iterate.js +75 -0
  873. data/js/node_modules/asynckit/lib/readable_asynckit.js +91 -0
  874. data/js/node_modules/asynckit/lib/readable_parallel.js +25 -0
  875. data/js/node_modules/asynckit/lib/readable_serial.js +25 -0
  876. data/js/node_modules/asynckit/lib/readable_serial_ordered.js +29 -0
  877. data/js/node_modules/asynckit/lib/state.js +37 -0
  878. data/js/node_modules/asynckit/lib/streamify.js +141 -0
  879. data/js/node_modules/asynckit/lib/terminator.js +29 -0
  880. data/js/node_modules/asynckit/package.json +63 -0
  881. data/js/node_modules/asynckit/parallel.js +43 -0
  882. data/js/node_modules/asynckit/serial.js +17 -0
  883. data/js/node_modules/asynckit/serialOrdered.js +75 -0
  884. data/js/node_modules/asynckit/stream.js +21 -0
  885. data/js/node_modules/axios/CHANGELOG.md +413 -0
  886. data/js/node_modules/axios/LICENSE +19 -0
  887. data/js/node_modules/axios/README.md +709 -0
  888. data/js/node_modules/axios/UPGRADE_GUIDE.md +162 -0
  889. data/js/node_modules/axios/dist/axios.js +1715 -0
  890. data/js/node_modules/axios/dist/axios.map +1 -0
  891. data/js/node_modules/axios/dist/axios.min.js +3 -0
  892. data/js/node_modules/axios/dist/axios.min.map +1 -0
  893. data/js/node_modules/axios/index.d.ts +157 -0
  894. data/js/node_modules/axios/index.js +1 -0
  895. data/js/node_modules/axios/lib/adapters/README.md +37 -0
  896. data/js/node_modules/axios/lib/adapters/http.js +279 -0
  897. data/js/node_modules/axios/lib/adapters/xhr.js +180 -0
  898. data/js/node_modules/axios/lib/axios.js +53 -0
  899. data/js/node_modules/axios/lib/cancel/Cancel.js +19 -0
  900. data/js/node_modules/axios/lib/cancel/CancelToken.js +57 -0
  901. data/js/node_modules/axios/lib/cancel/isCancel.js +5 -0
  902. data/js/node_modules/axios/lib/core/Axios.js +94 -0
  903. data/js/node_modules/axios/lib/core/InterceptorManager.js +52 -0
  904. data/js/node_modules/axios/lib/core/README.md +7 -0
  905. data/js/node_modules/axios/lib/core/buildFullPath.js +20 -0
  906. data/js/node_modules/axios/lib/core/createError.js +18 -0
  907. data/js/node_modules/axios/lib/core/dispatchRequest.js +79 -0
  908. data/js/node_modules/axios/lib/core/enhanceError.js +42 -0
  909. data/js/node_modules/axios/lib/core/mergeConfig.js +73 -0
  910. data/js/node_modules/axios/lib/core/settle.js +25 -0
  911. data/js/node_modules/axios/lib/core/transformData.js +20 -0
  912. data/js/node_modules/axios/lib/defaults.js +97 -0
  913. data/js/node_modules/axios/lib/helpers/README.md +7 -0
  914. data/js/node_modules/axios/lib/helpers/bind.js +11 -0
  915. data/js/node_modules/axios/lib/helpers/buildURL.js +71 -0
  916. data/js/node_modules/axios/lib/helpers/combineURLs.js +14 -0
  917. data/js/node_modules/axios/lib/helpers/cookies.js +53 -0
  918. data/js/node_modules/axios/lib/helpers/deprecatedMethod.js +24 -0
  919. data/js/node_modules/axios/lib/helpers/isAbsoluteURL.js +14 -0
  920. data/js/node_modules/axios/lib/helpers/isURLSameOrigin.js +68 -0
  921. data/js/node_modules/axios/lib/helpers/normalizeHeaderName.js +12 -0
  922. data/js/node_modules/axios/lib/helpers/parseHeaders.js +53 -0
  923. data/js/node_modules/axios/lib/helpers/spread.js +27 -0
  924. data/js/node_modules/axios/lib/utils.js +344 -0
  925. data/js/node_modules/axios/package.json +84 -0
  926. data/js/node_modules/base64-js/LICENSE +21 -0
  927. data/js/node_modules/base64-js/README.md +34 -0
  928. data/js/node_modules/base64-js/base64js.min.js +1 -0
  929. data/js/node_modules/base64-js/index.d.ts +3 -0
  930. data/js/node_modules/base64-js/index.js +150 -0
  931. data/js/node_modules/base64-js/package.json +47 -0
  932. data/js/node_modules/bignumber.js/CHANGELOG.md +290 -0
  933. data/js/node_modules/bignumber.js/LICENCE.md +26 -0
  934. data/js/node_modules/bignumber.js/README.md +286 -0
  935. data/js/node_modules/bignumber.js/bignumber.d.ts +1831 -0
  936. data/js/node_modules/bignumber.js/bignumber.js +2926 -0
  937. data/js/node_modules/bignumber.js/bignumber.mjs +2889 -0
  938. data/js/node_modules/bignumber.js/doc/API.html +2249 -0
  939. data/js/node_modules/bignumber.js/package.json +50 -0
  940. data/js/node_modules/combined-stream/License +19 -0
  941. data/js/node_modules/combined-stream/Readme.md +138 -0
  942. data/js/node_modules/combined-stream/lib/combined_stream.js +208 -0
  943. data/js/node_modules/combined-stream/package.json +25 -0
  944. data/js/node_modules/combined-stream/yarn.lock +17 -0
  945. data/js/node_modules/debug/CHANGELOG.md +395 -0
  946. data/js/node_modules/debug/LICENSE +19 -0
  947. data/js/node_modules/debug/Makefile +58 -0
  948. data/js/node_modules/debug/README.md +368 -0
  949. data/js/node_modules/debug/karma.conf.js +70 -0
  950. data/js/node_modules/debug/node.js +1 -0
  951. data/js/node_modules/debug/package.json +43 -0
  952. data/js/node_modules/debug/src/browser.js +195 -0
  953. data/js/node_modules/debug/src/debug.js +225 -0
  954. data/js/node_modules/debug/src/index.js +10 -0
  955. data/js/node_modules/debug/src/node.js +186 -0
  956. data/js/node_modules/delayed-stream/License +19 -0
  957. data/js/node_modules/delayed-stream/Makefile +7 -0
  958. data/js/node_modules/delayed-stream/Readme.md +141 -0
  959. data/js/node_modules/delayed-stream/lib/delayed_stream.js +107 -0
  960. data/js/node_modules/delayed-stream/package.json +27 -0
  961. data/js/node_modules/follow-redirects/LICENSE +18 -0
  962. data/js/node_modules/follow-redirects/README.md +155 -0
  963. data/js/node_modules/follow-redirects/http.js +1 -0
  964. data/js/node_modules/follow-redirects/https.js +1 -0
  965. data/js/node_modules/follow-redirects/index.js +322 -0
  966. data/js/node_modules/follow-redirects/package.json +60 -0
  967. data/js/node_modules/form-data/License +19 -0
  968. data/js/node_modules/form-data/README.md.bak +356 -0
  969. data/js/node_modules/form-data/Readme.md +356 -0
  970. data/js/node_modules/form-data/index.d.ts +62 -0
  971. data/js/node_modules/form-data/lib/browser.js +2 -0
  972. data/js/node_modules/form-data/lib/form_data.js +498 -0
  973. data/js/node_modules/form-data/lib/populate.js +10 -0
  974. data/js/node_modules/form-data/package.json +68 -0
  975. data/js/node_modules/js-sha3/CHANGELOG.md +106 -0
  976. data/js/node_modules/js-sha3/LICENSE.txt +20 -0
  977. data/js/node_modules/js-sha3/README.md +241 -0
  978. data/js/node_modules/js-sha3/build/sha3.min.js +9 -0
  979. data/js/node_modules/js-sha3/index.d.ts +317 -0
  980. data/js/node_modules/js-sha3/package.json +45 -0
  981. data/js/node_modules/js-sha3/src/sha3.js +656 -0
  982. data/js/node_modules/long/LICENSE +202 -0
  983. data/js/node_modules/long/README.md +246 -0
  984. data/js/node_modules/long/dist/long.js +2 -0
  985. data/js/node_modules/long/dist/long.js.map +1 -0
  986. data/js/node_modules/long/index.js +1 -0
  987. data/js/node_modules/long/package.json +34 -0
  988. data/js/node_modules/long/src/long.js +1323 -0
  989. data/js/node_modules/mime-db/HISTORY.md +507 -0
  990. data/js/node_modules/mime-db/LICENSE +23 -0
  991. data/js/node_modules/mime-db/README.md +100 -0
  992. data/js/node_modules/mime-db/db.json +8519 -0
  993. data/js/node_modules/mime-db/index.js +12 -0
  994. data/js/node_modules/mime-db/package.json +60 -0
  995. data/js/node_modules/mime-types/HISTORY.md +397 -0
  996. data/js/node_modules/mime-types/LICENSE +23 -0
  997. data/js/node_modules/mime-types/README.md +113 -0
  998. data/js/node_modules/mime-types/index.js +188 -0
  999. data/js/node_modules/mime-types/package.json +44 -0
  1000. data/js/node_modules/ms/index.js +152 -0
  1001. data/js/node_modules/ms/license.md +21 -0
  1002. data/js/node_modules/ms/package.json +37 -0
  1003. data/js/node_modules/ms/readme.md +51 -0
  1004. data/js/node_modules/node-fetch/LICENSE.md +22 -0
  1005. data/js/node_modules/node-fetch/README.md +633 -0
  1006. data/js/node_modules/node-fetch/browser.js +25 -0
  1007. data/js/node_modules/node-fetch/lib/index.es.js +1781 -0
  1008. data/js/node_modules/node-fetch/lib/index.js +1790 -0
  1009. data/js/node_modules/node-fetch/lib/index.mjs +1779 -0
  1010. data/js/node_modules/node-fetch/package.json +89 -0
  1011. data/js/node_modules/node-forge/CHANGELOG.md +211 -0
  1012. data/js/node_modules/node-forge/LICENSE +331 -0
  1013. data/js/node_modules/node-forge/README.md +2097 -0
  1014. data/js/node_modules/node-forge/dist/forge.all.min.js +2 -0
  1015. data/js/node_modules/node-forge/dist/forge.all.min.js.map +1 -0
  1016. data/js/node_modules/node-forge/dist/forge.min.js +2 -0
  1017. data/js/node_modules/node-forge/dist/forge.min.js.map +1 -0
  1018. data/js/node_modules/node-forge/dist/prime.worker.min.js +2 -0
  1019. data/js/node_modules/node-forge/dist/prime.worker.min.js.map +1 -0
  1020. data/js/node_modules/node-forge/flash/README.md +48 -0
  1021. data/js/node_modules/node-forge/flash/package.json +28 -0
  1022. data/js/node_modules/node-forge/flash/swf/SocketPool.swf +0 -0
  1023. data/js/node_modules/node-forge/lib/aes.js +1091 -0
  1024. data/js/node_modules/node-forge/lib/aesCipherSuites.js +282 -0
  1025. data/js/node_modules/node-forge/lib/asn1.js +1408 -0
  1026. data/js/node_modules/node-forge/lib/baseN.js +186 -0
  1027. data/js/node_modules/node-forge/lib/cipher.js +230 -0
  1028. data/js/node_modules/node-forge/lib/cipherModes.js +987 -0
  1029. data/js/node_modules/node-forge/lib/debug.js +78 -0
  1030. data/js/node_modules/node-forge/lib/des.js +496 -0
  1031. data/js/node_modules/node-forge/lib/ed25519.js +996 -0
  1032. data/js/node_modules/node-forge/lib/forge.js +13 -0
  1033. data/js/node_modules/node-forge/lib/form.js +149 -0
  1034. data/js/node_modules/node-forge/lib/hmac.js +146 -0
  1035. data/js/node_modules/node-forge/lib/http.js +1364 -0
  1036. data/js/node_modules/node-forge/lib/index.all.js +16 -0
  1037. data/js/node_modules/node-forge/lib/index.js +35 -0
  1038. data/js/node_modules/node-forge/lib/jsbn.js +1264 -0
  1039. data/js/node_modules/node-forge/lib/kem.js +168 -0
  1040. data/js/node_modules/node-forge/lib/log.js +317 -0
  1041. data/js/node_modules/node-forge/lib/md.all.js +13 -0
  1042. data/js/node_modules/node-forge/lib/md.js +11 -0
  1043. data/js/node_modules/node-forge/lib/md5.js +289 -0
  1044. data/js/node_modules/node-forge/lib/mgf.js +12 -0
  1045. data/js/node_modules/node-forge/lib/mgf1.js +57 -0
  1046. data/js/node_modules/node-forge/lib/oids.js +163 -0
  1047. data/js/node_modules/node-forge/lib/pbe.js +1023 -0
  1048. data/js/node_modules/node-forge/lib/pbkdf2.js +211 -0
  1049. data/js/node_modules/node-forge/lib/pem.js +230 -0
  1050. data/js/node_modules/node-forge/lib/pkcs1.js +276 -0
  1051. data/js/node_modules/node-forge/lib/pkcs12.js +1074 -0
  1052. data/js/node_modules/node-forge/lib/pkcs7.js +1257 -0
  1053. data/js/node_modules/node-forge/lib/pkcs7asn1.js +409 -0
  1054. data/js/node_modules/node-forge/lib/pki.js +102 -0
  1055. data/js/node_modules/node-forge/lib/prime.js +297 -0
  1056. data/js/node_modules/node-forge/lib/prime.worker.js +168 -0
  1057. data/js/node_modules/node-forge/lib/prng.js +419 -0
  1058. data/js/node_modules/node-forge/lib/pss.js +241 -0
  1059. data/js/node_modules/node-forge/lib/random.js +191 -0
  1060. data/js/node_modules/node-forge/lib/rc2.js +410 -0
  1061. data/js/node_modules/node-forge/lib/rsa.js +1858 -0
  1062. data/js/node_modules/node-forge/lib/sha1.js +319 -0
  1063. data/js/node_modules/node-forge/lib/sha256.js +327 -0
  1064. data/js/node_modules/node-forge/lib/sha512.js +561 -0
  1065. data/js/node_modules/node-forge/lib/socket.js +287 -0
  1066. data/js/node_modules/node-forge/lib/ssh.js +236 -0
  1067. data/js/node_modules/node-forge/lib/task.js +725 -0
  1068. data/js/node_modules/node-forge/lib/tls.js +4282 -0
  1069. data/js/node_modules/node-forge/lib/tlssocket.js +249 -0
  1070. data/js/node_modules/node-forge/lib/util.js +2993 -0
  1071. data/js/node_modules/node-forge/lib/x509.js +3333 -0
  1072. data/js/node_modules/node-forge/lib/xhr.js +736 -0
  1073. data/js/node_modules/node-forge/package.json +120 -0
  1074. data/js/node_modules/protobufjs/CHANGELOG.md +1027 -0
  1075. data/js/node_modules/protobufjs/LICENSE +39 -0
  1076. data/js/node_modules/protobufjs/README.md +905 -0
  1077. data/js/node_modules/protobufjs/bin/pbjs +6 -0
  1078. data/js/node_modules/protobufjs/bin/pbts +6 -0
  1079. data/js/node_modules/protobufjs/cli/LICENSE +33 -0
  1080. data/js/node_modules/protobufjs/cli/README.md +174 -0
  1081. data/js/node_modules/protobufjs/cli/bin/pbjs +6 -0
  1082. data/js/node_modules/protobufjs/cli/bin/pbts +6 -0
  1083. data/js/node_modules/protobufjs/cli/index.d.ts +3 -0
  1084. data/js/node_modules/protobufjs/cli/index.js +3 -0
  1085. data/js/node_modules/protobufjs/cli/lib/tsd-jsdoc/LICENSE +21 -0
  1086. data/js/node_modules/protobufjs/cli/lib/tsd-jsdoc/README.md +23 -0
  1087. data/js/node_modules/protobufjs/cli/lib/tsd-jsdoc/plugin.js +21 -0
  1088. data/js/node_modules/protobufjs/cli/lib/tsd-jsdoc/publish.js +705 -0
  1089. data/js/node_modules/protobufjs/cli/lib/tsd-jsdoc.json +18 -0
  1090. data/js/node_modules/protobufjs/cli/package.json +8 -0
  1091. data/js/node_modules/protobufjs/cli/package.standalone.json +32 -0
  1092. data/js/node_modules/protobufjs/cli/pbjs.d.ts +9 -0
  1093. data/js/node_modules/protobufjs/cli/pbjs.js +330 -0
  1094. data/js/node_modules/protobufjs/cli/pbts.d.ts +9 -0
  1095. data/js/node_modules/protobufjs/cli/pbts.js +197 -0
  1096. data/js/node_modules/protobufjs/cli/targets/json-module.js +38 -0
  1097. data/js/node_modules/protobufjs/cli/targets/json.js +8 -0
  1098. data/js/node_modules/protobufjs/cli/targets/proto.js +326 -0
  1099. data/js/node_modules/protobufjs/cli/targets/proto2.js +10 -0
  1100. data/js/node_modules/protobufjs/cli/targets/proto3.js +10 -0
  1101. data/js/node_modules/protobufjs/cli/targets/static-module.js +29 -0
  1102. data/js/node_modules/protobufjs/cli/targets/static.js +711 -0
  1103. data/js/node_modules/protobufjs/cli/util.js +183 -0
  1104. data/js/node_modules/protobufjs/cli/wrappers/amd.js +7 -0
  1105. data/js/node_modules/protobufjs/cli/wrappers/closure.js +7 -0
  1106. data/js/node_modules/protobufjs/cli/wrappers/commonjs.js +7 -0
  1107. data/js/node_modules/protobufjs/cli/wrappers/default.js +15 -0
  1108. data/js/node_modules/protobufjs/cli/wrappers/es6.js +5 -0
  1109. data/js/node_modules/protobufjs/dist/README.md +31 -0
  1110. data/js/node_modules/protobufjs/dist/light/README.md +31 -0
  1111. data/js/node_modules/protobufjs/dist/light/protobuf.js +7322 -0
  1112. data/js/node_modules/protobufjs/dist/light/protobuf.js.map +1 -0
  1113. data/js/node_modules/protobufjs/dist/light/protobuf.min.js +8 -0
  1114. data/js/node_modules/protobufjs/dist/light/protobuf.min.js.map +1 -0
  1115. data/js/node_modules/protobufjs/dist/minimal/README.md +31 -0
  1116. data/js/node_modules/protobufjs/dist/minimal/protobuf.js +2714 -0
  1117. data/js/node_modules/protobufjs/dist/minimal/protobuf.js.map +1 -0
  1118. data/js/node_modules/protobufjs/dist/minimal/protobuf.min.js +8 -0
  1119. data/js/node_modules/protobufjs/dist/minimal/protobuf.min.js.map +1 -0
  1120. data/js/node_modules/protobufjs/dist/protobuf.js +8964 -0
  1121. data/js/node_modules/protobufjs/dist/protobuf.js.map +1 -0
  1122. data/js/node_modules/protobufjs/dist/protobuf.min.js +8 -0
  1123. data/js/node_modules/protobufjs/dist/protobuf.min.js.map +1 -0
  1124. data/js/node_modules/protobufjs/ext/debug/README.md +4 -0
  1125. data/js/node_modules/protobufjs/ext/debug/index.js +71 -0
  1126. data/js/node_modules/protobufjs/ext/descriptor/README.md +72 -0
  1127. data/js/node_modules/protobufjs/ext/descriptor/index.d.ts +191 -0
  1128. data/js/node_modules/protobufjs/ext/descriptor/index.js +1052 -0
  1129. data/js/node_modules/protobufjs/ext/descriptor/test.js +54 -0
  1130. data/js/node_modules/protobufjs/google/LICENSE +27 -0
  1131. data/js/node_modules/protobufjs/google/README.md +1 -0
  1132. data/js/node_modules/protobufjs/google/api/annotations.json +83 -0
  1133. data/js/node_modules/protobufjs/google/api/annotations.proto +11 -0
  1134. data/js/node_modules/protobufjs/google/api/http.json +86 -0
  1135. data/js/node_modules/protobufjs/google/api/http.proto +31 -0
  1136. data/js/node_modules/protobufjs/google/protobuf/api.json +118 -0
  1137. data/js/node_modules/protobufjs/google/protobuf/api.proto +34 -0
  1138. data/js/node_modules/protobufjs/google/protobuf/descriptor.json +739 -0
  1139. data/js/node_modules/protobufjs/google/protobuf/descriptor.proto +286 -0
  1140. data/js/node_modules/protobufjs/google/protobuf/source_context.json +20 -0
  1141. data/js/node_modules/protobufjs/google/protobuf/source_context.proto +7 -0
  1142. data/js/node_modules/protobufjs/google/protobuf/type.json +202 -0
  1143. data/js/node_modules/protobufjs/google/protobuf/type.proto +89 -0
  1144. data/js/node_modules/protobufjs/index.d.ts +2739 -0
  1145. data/js/node_modules/protobufjs/index.js +4 -0
  1146. data/js/node_modules/protobufjs/light.d.ts +2 -0
  1147. data/js/node_modules/protobufjs/light.js +4 -0
  1148. data/js/node_modules/protobufjs/minimal.d.ts +2 -0
  1149. data/js/node_modules/protobufjs/minimal.js +4 -0
  1150. data/js/node_modules/protobufjs/package-lock.json +7870 -0
  1151. data/js/node_modules/protobufjs/package.json +122 -0
  1152. data/js/node_modules/protobufjs/scripts/changelog.js +150 -0
  1153. data/js/node_modules/protobufjs/scripts/postinstall.js +35 -0
  1154. data/js/node_modules/protobufjs/src/common.js +399 -0
  1155. data/js/node_modules/protobufjs/src/converter.js +293 -0
  1156. data/js/node_modules/protobufjs/src/decoder.js +128 -0
  1157. data/js/node_modules/protobufjs/src/encoder.js +100 -0
  1158. data/js/node_modules/protobufjs/src/enum.js +181 -0
  1159. data/js/node_modules/protobufjs/src/field.js +374 -0
  1160. data/js/node_modules/protobufjs/src/index-light.js +104 -0
  1161. data/js/node_modules/protobufjs/src/index-minimal.js +36 -0
  1162. data/js/node_modules/protobufjs/src/index.js +12 -0
  1163. data/js/node_modules/protobufjs/src/mapfield.js +126 -0
  1164. data/js/node_modules/protobufjs/src/message.js +139 -0
  1165. data/js/node_modules/protobufjs/src/method.js +160 -0
  1166. data/js/node_modules/protobufjs/src/namespace.js +434 -0
  1167. data/js/node_modules/protobufjs/src/object.js +243 -0
  1168. data/js/node_modules/protobufjs/src/oneof.js +203 -0
  1169. data/js/node_modules/protobufjs/src/parse.js +820 -0
  1170. data/js/node_modules/protobufjs/src/reader.js +411 -0
  1171. data/js/node_modules/protobufjs/src/reader_buffer.js +51 -0
  1172. data/js/node_modules/protobufjs/src/root.js +363 -0
  1173. data/js/node_modules/protobufjs/src/roots.js +18 -0
  1174. data/js/node_modules/protobufjs/src/rpc/service.js +142 -0
  1175. data/js/node_modules/protobufjs/src/rpc.js +36 -0
  1176. data/js/node_modules/protobufjs/src/service.js +167 -0
  1177. data/js/node_modules/protobufjs/src/tokenize.js +403 -0
  1178. data/js/node_modules/protobufjs/src/type.js +589 -0
  1179. data/js/node_modules/protobufjs/src/types.js +196 -0
  1180. data/js/node_modules/protobufjs/src/typescript.jsdoc +15 -0
  1181. data/js/node_modules/protobufjs/src/util/longbits.js +200 -0
  1182. data/js/node_modules/protobufjs/src/util/minimal.js +421 -0
  1183. data/js/node_modules/protobufjs/src/util.js +212 -0
  1184. data/js/node_modules/protobufjs/src/verifier.js +177 -0
  1185. data/js/node_modules/protobufjs/src/wrappers.js +102 -0
  1186. data/js/node_modules/protobufjs/src/writer.js +465 -0
  1187. data/js/node_modules/protobufjs/src/writer_buffer.js +85 -0
  1188. data/js/node_modules/protobufjs/tsconfig.json +7 -0
  1189. data/js/node_modules/tr46/index.js +193 -0
  1190. data/js/node_modules/tr46/lib/mappingTable.json +1 -0
  1191. data/js/node_modules/tr46/package.json +31 -0
  1192. data/js/node_modules/typed-ts-events/dist/EventEmitter.d.ts +23 -0
  1193. data/js/node_modules/typed-ts-events/dist/events.js +145 -0
  1194. data/js/node_modules/typed-ts-events/dist/events.js.map +1 -0
  1195. data/js/node_modules/typed-ts-events/dist/events.min.js +2 -0
  1196. data/js/node_modules/typed-ts-events/dist/events.min.js.map +1 -0
  1197. data/js/node_modules/typed-ts-events/dist/index.d.ts +3 -0
  1198. data/js/node_modules/typed-ts-events/package.json +64 -0
  1199. data/js/node_modules/typed-ts-events/readme.md +77 -0
  1200. data/js/node_modules/webidl-conversions/LICENSE.md +12 -0
  1201. data/js/node_modules/webidl-conversions/README.md +53 -0
  1202. data/js/node_modules/webidl-conversions/lib/index.js +189 -0
  1203. data/js/node_modules/webidl-conversions/package.json +23 -0
  1204. data/js/node_modules/whatwg-url/LICENSE.txt +21 -0
  1205. data/js/node_modules/whatwg-url/README.md +67 -0
  1206. data/js/node_modules/whatwg-url/lib/URL-impl.js +200 -0
  1207. data/js/node_modules/whatwg-url/lib/URL.js +196 -0
  1208. data/js/node_modules/whatwg-url/lib/public-api.js +11 -0
  1209. data/js/node_modules/whatwg-url/lib/url-state-machine.js +1297 -0
  1210. data/js/node_modules/whatwg-url/lib/utils.js +20 -0
  1211. data/js/node_modules/whatwg-url/package.json +32 -0
  1212. data/js/package-lock.json +706 -0
  1213. data/js/package.json +15 -0
  1214. data/js/worker.js +109 -0
  1215. data/js/yarn.lock +285 -0
  1216. data/lib/waves_lib/map.rb +211 -0
  1217. data/lib/waves_lib/root_wrapper.rb +85 -0
  1218. data/lib/waves_lib/version.rb +6 -0
  1219. data/lib/waves_lib/wrapped_buffer.rb +26 -0
  1220. data/lib/waves_lib/wrapper.rb +82 -0
  1221. data/lib/waves_lib.rb +10 -0
  1222. metadata +1264 -0
@@ -0,0 +1,3333 @@
1
+ /**
2
+ * Javascript implementation of X.509 and related components (such as
3
+ * Certification Signing Requests) of a Public Key Infrastructure.
4
+ *
5
+ * @author Dave Longley
6
+ *
7
+ * Copyright (c) 2010-2014 Digital Bazaar, Inc.
8
+ *
9
+ * The ASN.1 representation of an X.509v3 certificate is as follows
10
+ * (see RFC 2459):
11
+ *
12
+ * Certificate ::= SEQUENCE {
13
+ * tbsCertificate TBSCertificate,
14
+ * signatureAlgorithm AlgorithmIdentifier,
15
+ * signatureValue BIT STRING
16
+ * }
17
+ *
18
+ * TBSCertificate ::= SEQUENCE {
19
+ * version [0] EXPLICIT Version DEFAULT v1,
20
+ * serialNumber CertificateSerialNumber,
21
+ * signature AlgorithmIdentifier,
22
+ * issuer Name,
23
+ * validity Validity,
24
+ * subject Name,
25
+ * subjectPublicKeyInfo SubjectPublicKeyInfo,
26
+ * issuerUniqueID [1] IMPLICIT UniqueIdentifier OPTIONAL,
27
+ * -- If present, version shall be v2 or v3
28
+ * subjectUniqueID [2] IMPLICIT UniqueIdentifier OPTIONAL,
29
+ * -- If present, version shall be v2 or v3
30
+ * extensions [3] EXPLICIT Extensions OPTIONAL
31
+ * -- If present, version shall be v3
32
+ * }
33
+ *
34
+ * Version ::= INTEGER { v1(0), v2(1), v3(2) }
35
+ *
36
+ * CertificateSerialNumber ::= INTEGER
37
+ *
38
+ * Name ::= CHOICE {
39
+ * // only one possible choice for now
40
+ * RDNSequence
41
+ * }
42
+ *
43
+ * RDNSequence ::= SEQUENCE OF RelativeDistinguishedName
44
+ *
45
+ * RelativeDistinguishedName ::= SET OF AttributeTypeAndValue
46
+ *
47
+ * AttributeTypeAndValue ::= SEQUENCE {
48
+ * type AttributeType,
49
+ * value AttributeValue
50
+ * }
51
+ * AttributeType ::= OBJECT IDENTIFIER
52
+ * AttributeValue ::= ANY DEFINED BY AttributeType
53
+ *
54
+ * Validity ::= SEQUENCE {
55
+ * notBefore Time,
56
+ * notAfter Time
57
+ * }
58
+ *
59
+ * Time ::= CHOICE {
60
+ * utcTime UTCTime,
61
+ * generalTime GeneralizedTime
62
+ * }
63
+ *
64
+ * UniqueIdentifier ::= BIT STRING
65
+ *
66
+ * SubjectPublicKeyInfo ::= SEQUENCE {
67
+ * algorithm AlgorithmIdentifier,
68
+ * subjectPublicKey BIT STRING
69
+ * }
70
+ *
71
+ * Extensions ::= SEQUENCE SIZE (1..MAX) OF Extension
72
+ *
73
+ * Extension ::= SEQUENCE {
74
+ * extnID OBJECT IDENTIFIER,
75
+ * critical BOOLEAN DEFAULT FALSE,
76
+ * extnValue OCTET STRING
77
+ * }
78
+ *
79
+ * The only key algorithm currently supported for PKI is RSA.
80
+ *
81
+ * RSASSA-PSS signatures are described in RFC 3447 and RFC 4055.
82
+ *
83
+ * PKCS#10 v1.7 describes certificate signing requests:
84
+ *
85
+ * CertificationRequestInfo:
86
+ *
87
+ * CertificationRequestInfo ::= SEQUENCE {
88
+ * version INTEGER { v1(0) } (v1,...),
89
+ * subject Name,
90
+ * subjectPKInfo SubjectPublicKeyInfo{{ PKInfoAlgorithms }},
91
+ * attributes [0] Attributes{{ CRIAttributes }}
92
+ * }
93
+ *
94
+ * Attributes { ATTRIBUTE:IOSet } ::= SET OF Attribute{{ IOSet }}
95
+ *
96
+ * CRIAttributes ATTRIBUTE ::= {
97
+ * ... -- add any locally defined attributes here -- }
98
+ *
99
+ * Attribute { ATTRIBUTE:IOSet } ::= SEQUENCE {
100
+ * type ATTRIBUTE.&id({IOSet}),
101
+ * values SET SIZE(1..MAX) OF ATTRIBUTE.&Type({IOSet}{@type})
102
+ * }
103
+ *
104
+ * CertificationRequest ::= SEQUENCE {
105
+ * certificationRequestInfo CertificationRequestInfo,
106
+ * signatureAlgorithm AlgorithmIdentifier{{ SignatureAlgorithms }},
107
+ * signature BIT STRING
108
+ * }
109
+ */
110
+ var forge = require('./forge');
111
+ require('./aes');
112
+ require('./asn1');
113
+ require('./des');
114
+ require('./md');
115
+ require('./mgf');
116
+ require('./oids');
117
+ require('./pem');
118
+ require('./pss');
119
+ require('./rsa');
120
+ require('./util');
121
+
122
+ // shortcut for asn.1 API
123
+ var asn1 = forge.asn1;
124
+
125
+ /* Public Key Infrastructure (PKI) implementation. */
126
+ var pki = module.exports = forge.pki = forge.pki || {};
127
+ var oids = pki.oids;
128
+
129
+ // short name OID mappings
130
+ var _shortNames = {};
131
+ _shortNames['CN'] = oids['commonName'];
132
+ _shortNames['commonName'] = 'CN';
133
+ _shortNames['C'] = oids['countryName'];
134
+ _shortNames['countryName'] = 'C';
135
+ _shortNames['L'] = oids['localityName'];
136
+ _shortNames['localityName'] = 'L';
137
+ _shortNames['ST'] = oids['stateOrProvinceName'];
138
+ _shortNames['stateOrProvinceName'] = 'ST';
139
+ _shortNames['O'] = oids['organizationName'];
140
+ _shortNames['organizationName'] = 'O';
141
+ _shortNames['OU'] = oids['organizationalUnitName'];
142
+ _shortNames['organizationalUnitName'] = 'OU';
143
+ _shortNames['E'] = oids['emailAddress'];
144
+ _shortNames['emailAddress'] = 'E';
145
+
146
+ // validator for an SubjectPublicKeyInfo structure
147
+ // Note: Currently only works with an RSA public key
148
+ var publicKeyValidator = forge.pki.rsa.publicKeyValidator;
149
+
150
+ // validator for an X.509v3 certificate
151
+ var x509CertificateValidator = {
152
+ name: 'Certificate',
153
+ tagClass: asn1.Class.UNIVERSAL,
154
+ type: asn1.Type.SEQUENCE,
155
+ constructed: true,
156
+ value: [{
157
+ name: 'Certificate.TBSCertificate',
158
+ tagClass: asn1.Class.UNIVERSAL,
159
+ type: asn1.Type.SEQUENCE,
160
+ constructed: true,
161
+ captureAsn1: 'tbsCertificate',
162
+ value: [{
163
+ name: 'Certificate.TBSCertificate.version',
164
+ tagClass: asn1.Class.CONTEXT_SPECIFIC,
165
+ type: 0,
166
+ constructed: true,
167
+ optional: true,
168
+ value: [{
169
+ name: 'Certificate.TBSCertificate.version.integer',
170
+ tagClass: asn1.Class.UNIVERSAL,
171
+ type: asn1.Type.INTEGER,
172
+ constructed: false,
173
+ capture: 'certVersion'
174
+ }]
175
+ }, {
176
+ name: 'Certificate.TBSCertificate.serialNumber',
177
+ tagClass: asn1.Class.UNIVERSAL,
178
+ type: asn1.Type.INTEGER,
179
+ constructed: false,
180
+ capture: 'certSerialNumber'
181
+ }, {
182
+ name: 'Certificate.TBSCertificate.signature',
183
+ tagClass: asn1.Class.UNIVERSAL,
184
+ type: asn1.Type.SEQUENCE,
185
+ constructed: true,
186
+ value: [{
187
+ name: 'Certificate.TBSCertificate.signature.algorithm',
188
+ tagClass: asn1.Class.UNIVERSAL,
189
+ type: asn1.Type.OID,
190
+ constructed: false,
191
+ capture: 'certinfoSignatureOid'
192
+ }, {
193
+ name: 'Certificate.TBSCertificate.signature.parameters',
194
+ tagClass: asn1.Class.UNIVERSAL,
195
+ optional: true,
196
+ captureAsn1: 'certinfoSignatureParams'
197
+ }]
198
+ }, {
199
+ name: 'Certificate.TBSCertificate.issuer',
200
+ tagClass: asn1.Class.UNIVERSAL,
201
+ type: asn1.Type.SEQUENCE,
202
+ constructed: true,
203
+ captureAsn1: 'certIssuer'
204
+ }, {
205
+ name: 'Certificate.TBSCertificate.validity',
206
+ tagClass: asn1.Class.UNIVERSAL,
207
+ type: asn1.Type.SEQUENCE,
208
+ constructed: true,
209
+ // Note: UTC and generalized times may both appear so the capture
210
+ // names are based on their detected order, the names used below
211
+ // are only for the common case, which validity time really means
212
+ // "notBefore" and which means "notAfter" will be determined by order
213
+ value: [{
214
+ // notBefore (Time) (UTC time case)
215
+ name: 'Certificate.TBSCertificate.validity.notBefore (utc)',
216
+ tagClass: asn1.Class.UNIVERSAL,
217
+ type: asn1.Type.UTCTIME,
218
+ constructed: false,
219
+ optional: true,
220
+ capture: 'certValidity1UTCTime'
221
+ }, {
222
+ // notBefore (Time) (generalized time case)
223
+ name: 'Certificate.TBSCertificate.validity.notBefore (generalized)',
224
+ tagClass: asn1.Class.UNIVERSAL,
225
+ type: asn1.Type.GENERALIZEDTIME,
226
+ constructed: false,
227
+ optional: true,
228
+ capture: 'certValidity2GeneralizedTime'
229
+ }, {
230
+ // notAfter (Time) (only UTC time is supported)
231
+ name: 'Certificate.TBSCertificate.validity.notAfter (utc)',
232
+ tagClass: asn1.Class.UNIVERSAL,
233
+ type: asn1.Type.UTCTIME,
234
+ constructed: false,
235
+ optional: true,
236
+ capture: 'certValidity3UTCTime'
237
+ }, {
238
+ // notAfter (Time) (only UTC time is supported)
239
+ name: 'Certificate.TBSCertificate.validity.notAfter (generalized)',
240
+ tagClass: asn1.Class.UNIVERSAL,
241
+ type: asn1.Type.GENERALIZEDTIME,
242
+ constructed: false,
243
+ optional: true,
244
+ capture: 'certValidity4GeneralizedTime'
245
+ }]
246
+ }, {
247
+ // Name (subject) (RDNSequence)
248
+ name: 'Certificate.TBSCertificate.subject',
249
+ tagClass: asn1.Class.UNIVERSAL,
250
+ type: asn1.Type.SEQUENCE,
251
+ constructed: true,
252
+ captureAsn1: 'certSubject'
253
+ },
254
+ // SubjectPublicKeyInfo
255
+ publicKeyValidator,
256
+ {
257
+ // issuerUniqueID (optional)
258
+ name: 'Certificate.TBSCertificate.issuerUniqueID',
259
+ tagClass: asn1.Class.CONTEXT_SPECIFIC,
260
+ type: 1,
261
+ constructed: true,
262
+ optional: true,
263
+ value: [{
264
+ name: 'Certificate.TBSCertificate.issuerUniqueID.id',
265
+ tagClass: asn1.Class.UNIVERSAL,
266
+ type: asn1.Type.BITSTRING,
267
+ constructed: false,
268
+ // TODO: support arbitrary bit length ids
269
+ captureBitStringValue: 'certIssuerUniqueId'
270
+ }]
271
+ }, {
272
+ // subjectUniqueID (optional)
273
+ name: 'Certificate.TBSCertificate.subjectUniqueID',
274
+ tagClass: asn1.Class.CONTEXT_SPECIFIC,
275
+ type: 2,
276
+ constructed: true,
277
+ optional: true,
278
+ value: [{
279
+ name: 'Certificate.TBSCertificate.subjectUniqueID.id',
280
+ tagClass: asn1.Class.UNIVERSAL,
281
+ type: asn1.Type.BITSTRING,
282
+ constructed: false,
283
+ // TODO: support arbitrary bit length ids
284
+ captureBitStringValue: 'certSubjectUniqueId'
285
+ }]
286
+ }, {
287
+ // Extensions (optional)
288
+ name: 'Certificate.TBSCertificate.extensions',
289
+ tagClass: asn1.Class.CONTEXT_SPECIFIC,
290
+ type: 3,
291
+ constructed: true,
292
+ captureAsn1: 'certExtensions',
293
+ optional: true
294
+ }]
295
+ }, {
296
+ // AlgorithmIdentifier (signature algorithm)
297
+ name: 'Certificate.signatureAlgorithm',
298
+ tagClass: asn1.Class.UNIVERSAL,
299
+ type: asn1.Type.SEQUENCE,
300
+ constructed: true,
301
+ value: [{
302
+ // algorithm
303
+ name: 'Certificate.signatureAlgorithm.algorithm',
304
+ tagClass: asn1.Class.UNIVERSAL,
305
+ type: asn1.Type.OID,
306
+ constructed: false,
307
+ capture: 'certSignatureOid'
308
+ }, {
309
+ name: 'Certificate.TBSCertificate.signature.parameters',
310
+ tagClass: asn1.Class.UNIVERSAL,
311
+ optional: true,
312
+ captureAsn1: 'certSignatureParams'
313
+ }]
314
+ }, {
315
+ // SignatureValue
316
+ name: 'Certificate.signatureValue',
317
+ tagClass: asn1.Class.UNIVERSAL,
318
+ type: asn1.Type.BITSTRING,
319
+ constructed: false,
320
+ captureBitStringValue: 'certSignature'
321
+ }]
322
+ };
323
+
324
+ var rsassaPssParameterValidator = {
325
+ name: 'rsapss',
326
+ tagClass: asn1.Class.UNIVERSAL,
327
+ type: asn1.Type.SEQUENCE,
328
+ constructed: true,
329
+ value: [{
330
+ name: 'rsapss.hashAlgorithm',
331
+ tagClass: asn1.Class.CONTEXT_SPECIFIC,
332
+ type: 0,
333
+ constructed: true,
334
+ value: [{
335
+ name: 'rsapss.hashAlgorithm.AlgorithmIdentifier',
336
+ tagClass: asn1.Class.UNIVERSAL,
337
+ type: asn1.Class.SEQUENCE,
338
+ constructed: true,
339
+ optional: true,
340
+ value: [{
341
+ name: 'rsapss.hashAlgorithm.AlgorithmIdentifier.algorithm',
342
+ tagClass: asn1.Class.UNIVERSAL,
343
+ type: asn1.Type.OID,
344
+ constructed: false,
345
+ capture: 'hashOid'
346
+ /* parameter block omitted, for SHA1 NULL anyhow. */
347
+ }]
348
+ }]
349
+ }, {
350
+ name: 'rsapss.maskGenAlgorithm',
351
+ tagClass: asn1.Class.CONTEXT_SPECIFIC,
352
+ type: 1,
353
+ constructed: true,
354
+ value: [{
355
+ name: 'rsapss.maskGenAlgorithm.AlgorithmIdentifier',
356
+ tagClass: asn1.Class.UNIVERSAL,
357
+ type: asn1.Class.SEQUENCE,
358
+ constructed: true,
359
+ optional: true,
360
+ value: [{
361
+ name: 'rsapss.maskGenAlgorithm.AlgorithmIdentifier.algorithm',
362
+ tagClass: asn1.Class.UNIVERSAL,
363
+ type: asn1.Type.OID,
364
+ constructed: false,
365
+ capture: 'maskGenOid'
366
+ }, {
367
+ name: 'rsapss.maskGenAlgorithm.AlgorithmIdentifier.params',
368
+ tagClass: asn1.Class.UNIVERSAL,
369
+ type: asn1.Type.SEQUENCE,
370
+ constructed: true,
371
+ value: [{
372
+ name: 'rsapss.maskGenAlgorithm.AlgorithmIdentifier.params.algorithm',
373
+ tagClass: asn1.Class.UNIVERSAL,
374
+ type: asn1.Type.OID,
375
+ constructed: false,
376
+ capture: 'maskGenHashOid'
377
+ /* parameter block omitted, for SHA1 NULL anyhow. */
378
+ }]
379
+ }]
380
+ }]
381
+ }, {
382
+ name: 'rsapss.saltLength',
383
+ tagClass: asn1.Class.CONTEXT_SPECIFIC,
384
+ type: 2,
385
+ optional: true,
386
+ value: [{
387
+ name: 'rsapss.saltLength.saltLength',
388
+ tagClass: asn1.Class.UNIVERSAL,
389
+ type: asn1.Class.INTEGER,
390
+ constructed: false,
391
+ capture: 'saltLength'
392
+ }]
393
+ }, {
394
+ name: 'rsapss.trailerField',
395
+ tagClass: asn1.Class.CONTEXT_SPECIFIC,
396
+ type: 3,
397
+ optional: true,
398
+ value: [{
399
+ name: 'rsapss.trailer.trailer',
400
+ tagClass: asn1.Class.UNIVERSAL,
401
+ type: asn1.Class.INTEGER,
402
+ constructed: false,
403
+ capture: 'trailer'
404
+ }]
405
+ }]
406
+ };
407
+
408
+ // validator for a CertificationRequestInfo structure
409
+ var certificationRequestInfoValidator = {
410
+ name: 'CertificationRequestInfo',
411
+ tagClass: asn1.Class.UNIVERSAL,
412
+ type: asn1.Type.SEQUENCE,
413
+ constructed: true,
414
+ captureAsn1: 'certificationRequestInfo',
415
+ value: [{
416
+ name: 'CertificationRequestInfo.integer',
417
+ tagClass: asn1.Class.UNIVERSAL,
418
+ type: asn1.Type.INTEGER,
419
+ constructed: false,
420
+ capture: 'certificationRequestInfoVersion'
421
+ }, {
422
+ // Name (subject) (RDNSequence)
423
+ name: 'CertificationRequestInfo.subject',
424
+ tagClass: asn1.Class.UNIVERSAL,
425
+ type: asn1.Type.SEQUENCE,
426
+ constructed: true,
427
+ captureAsn1: 'certificationRequestInfoSubject'
428
+ },
429
+ // SubjectPublicKeyInfo
430
+ publicKeyValidator,
431
+ {
432
+ name: 'CertificationRequestInfo.attributes',
433
+ tagClass: asn1.Class.CONTEXT_SPECIFIC,
434
+ type: 0,
435
+ constructed: true,
436
+ optional: true,
437
+ capture: 'certificationRequestInfoAttributes',
438
+ value: [{
439
+ name: 'CertificationRequestInfo.attributes',
440
+ tagClass: asn1.Class.UNIVERSAL,
441
+ type: asn1.Type.SEQUENCE,
442
+ constructed: true,
443
+ value: [{
444
+ name: 'CertificationRequestInfo.attributes.type',
445
+ tagClass: asn1.Class.UNIVERSAL,
446
+ type: asn1.Type.OID,
447
+ constructed: false
448
+ }, {
449
+ name: 'CertificationRequestInfo.attributes.value',
450
+ tagClass: asn1.Class.UNIVERSAL,
451
+ type: asn1.Type.SET,
452
+ constructed: true
453
+ }]
454
+ }]
455
+ }]
456
+ };
457
+
458
+ // validator for a CertificationRequest structure
459
+ var certificationRequestValidator = {
460
+ name: 'CertificationRequest',
461
+ tagClass: asn1.Class.UNIVERSAL,
462
+ type: asn1.Type.SEQUENCE,
463
+ constructed: true,
464
+ captureAsn1: 'csr',
465
+ value: [
466
+ certificationRequestInfoValidator, {
467
+ // AlgorithmIdentifier (signature algorithm)
468
+ name: 'CertificationRequest.signatureAlgorithm',
469
+ tagClass: asn1.Class.UNIVERSAL,
470
+ type: asn1.Type.SEQUENCE,
471
+ constructed: true,
472
+ value: [{
473
+ // algorithm
474
+ name: 'CertificationRequest.signatureAlgorithm.algorithm',
475
+ tagClass: asn1.Class.UNIVERSAL,
476
+ type: asn1.Type.OID,
477
+ constructed: false,
478
+ capture: 'csrSignatureOid'
479
+ }, {
480
+ name: 'CertificationRequest.signatureAlgorithm.parameters',
481
+ tagClass: asn1.Class.UNIVERSAL,
482
+ optional: true,
483
+ captureAsn1: 'csrSignatureParams'
484
+ }]
485
+ }, {
486
+ // signature
487
+ name: 'CertificationRequest.signature',
488
+ tagClass: asn1.Class.UNIVERSAL,
489
+ type: asn1.Type.BITSTRING,
490
+ constructed: false,
491
+ captureBitStringValue: 'csrSignature'
492
+ }
493
+ ]
494
+ };
495
+
496
+ /**
497
+ * Converts an RDNSequence of ASN.1 DER-encoded RelativeDistinguishedName
498
+ * sets into an array with objects that have type and value properties.
499
+ *
500
+ * @param rdn the RDNSequence to convert.
501
+ * @param md a message digest to append type and value to if provided.
502
+ */
503
+ pki.RDNAttributesAsArray = function(rdn, md) {
504
+ var rval = [];
505
+
506
+ // each value in 'rdn' in is a SET of RelativeDistinguishedName
507
+ var set, attr, obj;
508
+ for(var si = 0; si < rdn.value.length; ++si) {
509
+ // get the RelativeDistinguishedName set
510
+ set = rdn.value[si];
511
+
512
+ // each value in the SET is an AttributeTypeAndValue sequence
513
+ // containing first a type (an OID) and second a value (defined by
514
+ // the OID)
515
+ for(var i = 0; i < set.value.length; ++i) {
516
+ obj = {};
517
+ attr = set.value[i];
518
+ obj.type = asn1.derToOid(attr.value[0].value);
519
+ obj.value = attr.value[1].value;
520
+ obj.valueTagClass = attr.value[1].type;
521
+ // if the OID is known, get its name and short name
522
+ if(obj.type in oids) {
523
+ obj.name = oids[obj.type];
524
+ if(obj.name in _shortNames) {
525
+ obj.shortName = _shortNames[obj.name];
526
+ }
527
+ }
528
+ if(md) {
529
+ md.update(obj.type);
530
+ md.update(obj.value);
531
+ }
532
+ rval.push(obj);
533
+ }
534
+ }
535
+
536
+ return rval;
537
+ };
538
+
539
+ /**
540
+ * Converts ASN.1 CRIAttributes into an array with objects that have type and
541
+ * value properties.
542
+ *
543
+ * @param attributes the CRIAttributes to convert.
544
+ */
545
+ pki.CRIAttributesAsArray = function(attributes) {
546
+ var rval = [];
547
+
548
+ // each value in 'attributes' in is a SEQUENCE with an OID and a SET
549
+ for(var si = 0; si < attributes.length; ++si) {
550
+ // get the attribute sequence
551
+ var seq = attributes[si];
552
+
553
+ // each value in the SEQUENCE containing first a type (an OID) and
554
+ // second a set of values (defined by the OID)
555
+ var type = asn1.derToOid(seq.value[0].value);
556
+ var values = seq.value[1].value;
557
+ for(var vi = 0; vi < values.length; ++vi) {
558
+ var obj = {};
559
+ obj.type = type;
560
+ obj.value = values[vi].value;
561
+ obj.valueTagClass = values[vi].type;
562
+ // if the OID is known, get its name and short name
563
+ if(obj.type in oids) {
564
+ obj.name = oids[obj.type];
565
+ if(obj.name in _shortNames) {
566
+ obj.shortName = _shortNames[obj.name];
567
+ }
568
+ }
569
+ // parse extensions
570
+ if(obj.type === oids.extensionRequest) {
571
+ obj.extensions = [];
572
+ for(var ei = 0; ei < obj.value.length; ++ei) {
573
+ obj.extensions.push(pki.certificateExtensionFromAsn1(obj.value[ei]));
574
+ }
575
+ }
576
+ rval.push(obj);
577
+ }
578
+ }
579
+
580
+ return rval;
581
+ };
582
+
583
+ /**
584
+ * Gets an issuer or subject attribute from its name, type, or short name.
585
+ *
586
+ * @param obj the issuer or subject object.
587
+ * @param options a short name string or an object with:
588
+ * shortName the short name for the attribute.
589
+ * name the name for the attribute.
590
+ * type the type for the attribute.
591
+ *
592
+ * @return the attribute.
593
+ */
594
+ function _getAttribute(obj, options) {
595
+ if(typeof options === 'string') {
596
+ options = {shortName: options};
597
+ }
598
+
599
+ var rval = null;
600
+ var attr;
601
+ for(var i = 0; rval === null && i < obj.attributes.length; ++i) {
602
+ attr = obj.attributes[i];
603
+ if(options.type && options.type === attr.type) {
604
+ rval = attr;
605
+ } else if(options.name && options.name === attr.name) {
606
+ rval = attr;
607
+ } else if(options.shortName && options.shortName === attr.shortName) {
608
+ rval = attr;
609
+ }
610
+ }
611
+ return rval;
612
+ }
613
+
614
+ /**
615
+ * Converts signature parameters from ASN.1 structure.
616
+ *
617
+ * Currently only RSASSA-PSS supported. The PKCS#1 v1.5 signature scheme had
618
+ * no parameters.
619
+ *
620
+ * RSASSA-PSS-params ::= SEQUENCE {
621
+ * hashAlgorithm [0] HashAlgorithm DEFAULT
622
+ * sha1Identifier,
623
+ * maskGenAlgorithm [1] MaskGenAlgorithm DEFAULT
624
+ * mgf1SHA1Identifier,
625
+ * saltLength [2] INTEGER DEFAULT 20,
626
+ * trailerField [3] INTEGER DEFAULT 1
627
+ * }
628
+ *
629
+ * HashAlgorithm ::= AlgorithmIdentifier
630
+ *
631
+ * MaskGenAlgorithm ::= AlgorithmIdentifier
632
+ *
633
+ * AlgorithmIdentifer ::= SEQUENCE {
634
+ * algorithm OBJECT IDENTIFIER,
635
+ * parameters ANY DEFINED BY algorithm OPTIONAL
636
+ * }
637
+ *
638
+ * @param oid The OID specifying the signature algorithm
639
+ * @param obj The ASN.1 structure holding the parameters
640
+ * @param fillDefaults Whether to use return default values where omitted
641
+ * @return signature parameter object
642
+ */
643
+ var _readSignatureParameters = function(oid, obj, fillDefaults) {
644
+ var params = {};
645
+
646
+ if(oid !== oids['RSASSA-PSS']) {
647
+ return params;
648
+ }
649
+
650
+ if(fillDefaults) {
651
+ params = {
652
+ hash: {
653
+ algorithmOid: oids['sha1']
654
+ },
655
+ mgf: {
656
+ algorithmOid: oids['mgf1'],
657
+ hash: {
658
+ algorithmOid: oids['sha1']
659
+ }
660
+ },
661
+ saltLength: 20
662
+ };
663
+ }
664
+
665
+ var capture = {};
666
+ var errors = [];
667
+ if(!asn1.validate(obj, rsassaPssParameterValidator, capture, errors)) {
668
+ var error = new Error('Cannot read RSASSA-PSS parameter block.');
669
+ error.errors = errors;
670
+ throw error;
671
+ }
672
+
673
+ if(capture.hashOid !== undefined) {
674
+ params.hash = params.hash || {};
675
+ params.hash.algorithmOid = asn1.derToOid(capture.hashOid);
676
+ }
677
+
678
+ if(capture.maskGenOid !== undefined) {
679
+ params.mgf = params.mgf || {};
680
+ params.mgf.algorithmOid = asn1.derToOid(capture.maskGenOid);
681
+ params.mgf.hash = params.mgf.hash || {};
682
+ params.mgf.hash.algorithmOid = asn1.derToOid(capture.maskGenHashOid);
683
+ }
684
+
685
+ if(capture.saltLength !== undefined) {
686
+ params.saltLength = capture.saltLength.charCodeAt(0);
687
+ }
688
+
689
+ return params;
690
+ };
691
+
692
+ /**
693
+ * Converts an X.509 certificate from PEM format.
694
+ *
695
+ * Note: If the certificate is to be verified then compute hash should
696
+ * be set to true. This will scan the TBSCertificate part of the ASN.1
697
+ * object while it is converted so it doesn't need to be converted back
698
+ * to ASN.1-DER-encoding later.
699
+ *
700
+ * @param pem the PEM-formatted certificate.
701
+ * @param computeHash true to compute the hash for verification.
702
+ * @param strict true to be strict when checking ASN.1 value lengths, false to
703
+ * allow truncated values (default: true).
704
+ *
705
+ * @return the certificate.
706
+ */
707
+ pki.certificateFromPem = function(pem, computeHash, strict) {
708
+ var msg = forge.pem.decode(pem)[0];
709
+
710
+ if(msg.type !== 'CERTIFICATE' &&
711
+ msg.type !== 'X509 CERTIFICATE' &&
712
+ msg.type !== 'TRUSTED CERTIFICATE') {
713
+ var error = new Error(
714
+ 'Could not convert certificate from PEM; PEM header type ' +
715
+ 'is not "CERTIFICATE", "X509 CERTIFICATE", or "TRUSTED CERTIFICATE".');
716
+ error.headerType = msg.type;
717
+ throw error;
718
+ }
719
+ if(msg.procType && msg.procType.type === 'ENCRYPTED') {
720
+ throw new Error(
721
+ 'Could not convert certificate from PEM; PEM is encrypted.');
722
+ }
723
+
724
+ // convert DER to ASN.1 object
725
+ var obj = asn1.fromDer(msg.body, strict);
726
+
727
+ return pki.certificateFromAsn1(obj, computeHash);
728
+ };
729
+
730
+ /**
731
+ * Converts an X.509 certificate to PEM format.
732
+ *
733
+ * @param cert the certificate.
734
+ * @param maxline the maximum characters per line, defaults to 64.
735
+ *
736
+ * @return the PEM-formatted certificate.
737
+ */
738
+ pki.certificateToPem = function(cert, maxline) {
739
+ // convert to ASN.1, then DER, then PEM-encode
740
+ var msg = {
741
+ type: 'CERTIFICATE',
742
+ body: asn1.toDer(pki.certificateToAsn1(cert)).getBytes()
743
+ };
744
+ return forge.pem.encode(msg, {maxline: maxline});
745
+ };
746
+
747
+ /**
748
+ * Converts an RSA public key from PEM format.
749
+ *
750
+ * @param pem the PEM-formatted public key.
751
+ *
752
+ * @return the public key.
753
+ */
754
+ pki.publicKeyFromPem = function(pem) {
755
+ var msg = forge.pem.decode(pem)[0];
756
+
757
+ if(msg.type !== 'PUBLIC KEY' && msg.type !== 'RSA PUBLIC KEY') {
758
+ var error = new Error('Could not convert public key from PEM; PEM header ' +
759
+ 'type is not "PUBLIC KEY" or "RSA PUBLIC KEY".');
760
+ error.headerType = msg.type;
761
+ throw error;
762
+ }
763
+ if(msg.procType && msg.procType.type === 'ENCRYPTED') {
764
+ throw new Error('Could not convert public key from PEM; PEM is encrypted.');
765
+ }
766
+
767
+ // convert DER to ASN.1 object
768
+ var obj = asn1.fromDer(msg.body);
769
+
770
+ return pki.publicKeyFromAsn1(obj);
771
+ };
772
+
773
+ /**
774
+ * Converts an RSA public key to PEM format (using a SubjectPublicKeyInfo).
775
+ *
776
+ * @param key the public key.
777
+ * @param maxline the maximum characters per line, defaults to 64.
778
+ *
779
+ * @return the PEM-formatted public key.
780
+ */
781
+ pki.publicKeyToPem = function(key, maxline) {
782
+ // convert to ASN.1, then DER, then PEM-encode
783
+ var msg = {
784
+ type: 'PUBLIC KEY',
785
+ body: asn1.toDer(pki.publicKeyToAsn1(key)).getBytes()
786
+ };
787
+ return forge.pem.encode(msg, {maxline: maxline});
788
+ };
789
+
790
+ /**
791
+ * Converts an RSA public key to PEM format (using an RSAPublicKey).
792
+ *
793
+ * @param key the public key.
794
+ * @param maxline the maximum characters per line, defaults to 64.
795
+ *
796
+ * @return the PEM-formatted public key.
797
+ */
798
+ pki.publicKeyToRSAPublicKeyPem = function(key, maxline) {
799
+ // convert to ASN.1, then DER, then PEM-encode
800
+ var msg = {
801
+ type: 'RSA PUBLIC KEY',
802
+ body: asn1.toDer(pki.publicKeyToRSAPublicKey(key)).getBytes()
803
+ };
804
+ return forge.pem.encode(msg, {maxline: maxline});
805
+ };
806
+
807
+ /**
808
+ * Gets a fingerprint for the given public key.
809
+ *
810
+ * @param options the options to use.
811
+ * [md] the message digest object to use (defaults to forge.md.sha1).
812
+ * [type] the type of fingerprint, such as 'RSAPublicKey',
813
+ * 'SubjectPublicKeyInfo' (defaults to 'RSAPublicKey').
814
+ * [encoding] an alternative output encoding, such as 'hex'
815
+ * (defaults to none, outputs a byte buffer).
816
+ * [delimiter] the delimiter to use between bytes for 'hex' encoded
817
+ * output, eg: ':' (defaults to none).
818
+ *
819
+ * @return the fingerprint as a byte buffer or other encoding based on options.
820
+ */
821
+ pki.getPublicKeyFingerprint = function(key, options) {
822
+ options = options || {};
823
+ var md = options.md || forge.md.sha1.create();
824
+ var type = options.type || 'RSAPublicKey';
825
+
826
+ var bytes;
827
+ switch(type) {
828
+ case 'RSAPublicKey':
829
+ bytes = asn1.toDer(pki.publicKeyToRSAPublicKey(key)).getBytes();
830
+ break;
831
+ case 'SubjectPublicKeyInfo':
832
+ bytes = asn1.toDer(pki.publicKeyToAsn1(key)).getBytes();
833
+ break;
834
+ default:
835
+ throw new Error('Unknown fingerprint type "' + options.type + '".');
836
+ }
837
+
838
+ // hash public key bytes
839
+ md.start();
840
+ md.update(bytes);
841
+ var digest = md.digest();
842
+ if(options.encoding === 'hex') {
843
+ var hex = digest.toHex();
844
+ if(options.delimiter) {
845
+ return hex.match(/.{2}/g).join(options.delimiter);
846
+ }
847
+ return hex;
848
+ } else if(options.encoding === 'binary') {
849
+ return digest.getBytes();
850
+ } else if(options.encoding) {
851
+ throw new Error('Unknown encoding "' + options.encoding + '".');
852
+ }
853
+ return digest;
854
+ };
855
+
856
+ /**
857
+ * Converts a PKCS#10 certification request (CSR) from PEM format.
858
+ *
859
+ * Note: If the certification request is to be verified then compute hash
860
+ * should be set to true. This will scan the CertificationRequestInfo part of
861
+ * the ASN.1 object while it is converted so it doesn't need to be converted
862
+ * back to ASN.1-DER-encoding later.
863
+ *
864
+ * @param pem the PEM-formatted certificate.
865
+ * @param computeHash true to compute the hash for verification.
866
+ * @param strict true to be strict when checking ASN.1 value lengths, false to
867
+ * allow truncated values (default: true).
868
+ *
869
+ * @return the certification request (CSR).
870
+ */
871
+ pki.certificationRequestFromPem = function(pem, computeHash, strict) {
872
+ var msg = forge.pem.decode(pem)[0];
873
+
874
+ if(msg.type !== 'CERTIFICATE REQUEST') {
875
+ var error = new Error('Could not convert certification request from PEM; ' +
876
+ 'PEM header type is not "CERTIFICATE REQUEST".');
877
+ error.headerType = msg.type;
878
+ throw error;
879
+ }
880
+ if(msg.procType && msg.procType.type === 'ENCRYPTED') {
881
+ throw new Error('Could not convert certification request from PEM; ' +
882
+ 'PEM is encrypted.');
883
+ }
884
+
885
+ // convert DER to ASN.1 object
886
+ var obj = asn1.fromDer(msg.body, strict);
887
+
888
+ return pki.certificationRequestFromAsn1(obj, computeHash);
889
+ };
890
+
891
+ /**
892
+ * Converts a PKCS#10 certification request (CSR) to PEM format.
893
+ *
894
+ * @param csr the certification request.
895
+ * @param maxline the maximum characters per line, defaults to 64.
896
+ *
897
+ * @return the PEM-formatted certification request.
898
+ */
899
+ pki.certificationRequestToPem = function(csr, maxline) {
900
+ // convert to ASN.1, then DER, then PEM-encode
901
+ var msg = {
902
+ type: 'CERTIFICATE REQUEST',
903
+ body: asn1.toDer(pki.certificationRequestToAsn1(csr)).getBytes()
904
+ };
905
+ return forge.pem.encode(msg, {maxline: maxline});
906
+ };
907
+
908
+ /**
909
+ * Creates an empty X.509v3 RSA certificate.
910
+ *
911
+ * @return the certificate.
912
+ */
913
+ pki.createCertificate = function() {
914
+ var cert = {};
915
+ cert.version = 0x02;
916
+ cert.serialNumber = '00';
917
+ cert.signatureOid = null;
918
+ cert.signature = null;
919
+ cert.siginfo = {};
920
+ cert.siginfo.algorithmOid = null;
921
+ cert.validity = {};
922
+ cert.validity.notBefore = new Date();
923
+ cert.validity.notAfter = new Date();
924
+
925
+ cert.issuer = {};
926
+ cert.issuer.getField = function(sn) {
927
+ return _getAttribute(cert.issuer, sn);
928
+ };
929
+ cert.issuer.addField = function(attr) {
930
+ _fillMissingFields([attr]);
931
+ cert.issuer.attributes.push(attr);
932
+ };
933
+ cert.issuer.attributes = [];
934
+ cert.issuer.hash = null;
935
+
936
+ cert.subject = {};
937
+ cert.subject.getField = function(sn) {
938
+ return _getAttribute(cert.subject, sn);
939
+ };
940
+ cert.subject.addField = function(attr) {
941
+ _fillMissingFields([attr]);
942
+ cert.subject.attributes.push(attr);
943
+ };
944
+ cert.subject.attributes = [];
945
+ cert.subject.hash = null;
946
+
947
+ cert.extensions = [];
948
+ cert.publicKey = null;
949
+ cert.md = null;
950
+
951
+ /**
952
+ * Sets the subject of this certificate.
953
+ *
954
+ * @param attrs the array of subject attributes to use.
955
+ * @param uniqueId an optional a unique ID to use.
956
+ */
957
+ cert.setSubject = function(attrs, uniqueId) {
958
+ // set new attributes, clear hash
959
+ _fillMissingFields(attrs);
960
+ cert.subject.attributes = attrs;
961
+ delete cert.subject.uniqueId;
962
+ if(uniqueId) {
963
+ // TODO: support arbitrary bit length ids
964
+ cert.subject.uniqueId = uniqueId;
965
+ }
966
+ cert.subject.hash = null;
967
+ };
968
+
969
+ /**
970
+ * Sets the issuer of this certificate.
971
+ *
972
+ * @param attrs the array of issuer attributes to use.
973
+ * @param uniqueId an optional a unique ID to use.
974
+ */
975
+ cert.setIssuer = function(attrs, uniqueId) {
976
+ // set new attributes, clear hash
977
+ _fillMissingFields(attrs);
978
+ cert.issuer.attributes = attrs;
979
+ delete cert.issuer.uniqueId;
980
+ if(uniqueId) {
981
+ // TODO: support arbitrary bit length ids
982
+ cert.issuer.uniqueId = uniqueId;
983
+ }
984
+ cert.issuer.hash = null;
985
+ };
986
+
987
+ /**
988
+ * Sets the extensions of this certificate.
989
+ *
990
+ * @param exts the array of extensions to use.
991
+ */
992
+ cert.setExtensions = function(exts) {
993
+ for(var i = 0; i < exts.length; ++i) {
994
+ _fillMissingExtensionFields(exts[i], {cert: cert});
995
+ }
996
+ // set new extensions
997
+ cert.extensions = exts;
998
+ };
999
+
1000
+ /**
1001
+ * Gets an extension by its name or id.
1002
+ *
1003
+ * @param options the name to use or an object with:
1004
+ * name the name to use.
1005
+ * id the id to use.
1006
+ *
1007
+ * @return the extension or null if not found.
1008
+ */
1009
+ cert.getExtension = function(options) {
1010
+ if(typeof options === 'string') {
1011
+ options = {name: options};
1012
+ }
1013
+
1014
+ var rval = null;
1015
+ var ext;
1016
+ for(var i = 0; rval === null && i < cert.extensions.length; ++i) {
1017
+ ext = cert.extensions[i];
1018
+ if(options.id && ext.id === options.id) {
1019
+ rval = ext;
1020
+ } else if(options.name && ext.name === options.name) {
1021
+ rval = ext;
1022
+ }
1023
+ }
1024
+ return rval;
1025
+ };
1026
+
1027
+ /**
1028
+ * Signs this certificate using the given private key.
1029
+ *
1030
+ * @param key the private key to sign with.
1031
+ * @param md the message digest object to use (defaults to forge.md.sha1).
1032
+ */
1033
+ cert.sign = function(key, md) {
1034
+ // TODO: get signature OID from private key
1035
+ cert.md = md || forge.md.sha1.create();
1036
+ var algorithmOid = oids[cert.md.algorithm + 'WithRSAEncryption'];
1037
+ if(!algorithmOid) {
1038
+ var error = new Error('Could not compute certificate digest. ' +
1039
+ 'Unknown message digest algorithm OID.');
1040
+ error.algorithm = cert.md.algorithm;
1041
+ throw error;
1042
+ }
1043
+ cert.signatureOid = cert.siginfo.algorithmOid = algorithmOid;
1044
+
1045
+ // get TBSCertificate, convert to DER
1046
+ cert.tbsCertificate = pki.getTBSCertificate(cert);
1047
+ var bytes = asn1.toDer(cert.tbsCertificate);
1048
+
1049
+ // digest and sign
1050
+ cert.md.update(bytes.getBytes());
1051
+ cert.signature = key.sign(cert.md);
1052
+ };
1053
+
1054
+ /**
1055
+ * Attempts verify the signature on the passed certificate using this
1056
+ * certificate's public key.
1057
+ *
1058
+ * @param child the certificate to verify.
1059
+ *
1060
+ * @return true if verified, false if not.
1061
+ */
1062
+ cert.verify = function(child) {
1063
+ var rval = false;
1064
+
1065
+ if(!cert.issued(child)) {
1066
+ var issuer = child.issuer;
1067
+ var subject = cert.subject;
1068
+ var error = new Error(
1069
+ 'The parent certificate did not issue the given child ' +
1070
+ 'certificate; the child certificate\'s issuer does not match the ' +
1071
+ 'parent\'s subject.');
1072
+ error.expectedIssuer = issuer.attributes;
1073
+ error.actualIssuer = subject.attributes;
1074
+ throw error;
1075
+ }
1076
+
1077
+ var md = child.md;
1078
+ if(md === null) {
1079
+ // check signature OID for supported signature types
1080
+ if(child.signatureOid in oids) {
1081
+ var oid = oids[child.signatureOid];
1082
+ switch(oid) {
1083
+ case 'sha1WithRSAEncryption':
1084
+ md = forge.md.sha1.create();
1085
+ break;
1086
+ case 'md5WithRSAEncryption':
1087
+ md = forge.md.md5.create();
1088
+ break;
1089
+ case 'sha256WithRSAEncryption':
1090
+ md = forge.md.sha256.create();
1091
+ break;
1092
+ case 'sha384WithRSAEncryption':
1093
+ md = forge.md.sha384.create();
1094
+ break;
1095
+ case 'sha512WithRSAEncryption':
1096
+ md = forge.md.sha512.create();
1097
+ break;
1098
+ case 'RSASSA-PSS':
1099
+ md = forge.md.sha256.create();
1100
+ break;
1101
+ }
1102
+ }
1103
+ if(md === null) {
1104
+ var error = new Error('Could not compute certificate digest. ' +
1105
+ 'Unknown signature OID.');
1106
+ error.signatureOid = child.signatureOid;
1107
+ throw error;
1108
+ }
1109
+
1110
+ // produce DER formatted TBSCertificate and digest it
1111
+ var tbsCertificate = child.tbsCertificate || pki.getTBSCertificate(child);
1112
+ var bytes = asn1.toDer(tbsCertificate);
1113
+ md.update(bytes.getBytes());
1114
+ }
1115
+
1116
+ if(md !== null) {
1117
+ var scheme;
1118
+
1119
+ switch(child.signatureOid) {
1120
+ case oids.sha1WithRSAEncryption:
1121
+ scheme = undefined; /* use PKCS#1 v1.5 padding scheme */
1122
+ break;
1123
+ case oids['RSASSA-PSS']:
1124
+ var hash, mgf;
1125
+
1126
+ /* initialize mgf */
1127
+ hash = oids[child.signatureParameters.mgf.hash.algorithmOid];
1128
+ if(hash === undefined || forge.md[hash] === undefined) {
1129
+ var error = new Error('Unsupported MGF hash function.');
1130
+ error.oid = child.signatureParameters.mgf.hash.algorithmOid;
1131
+ error.name = hash;
1132
+ throw error;
1133
+ }
1134
+
1135
+ mgf = oids[child.signatureParameters.mgf.algorithmOid];
1136
+ if(mgf === undefined || forge.mgf[mgf] === undefined) {
1137
+ var error = new Error('Unsupported MGF function.');
1138
+ error.oid = child.signatureParameters.mgf.algorithmOid;
1139
+ error.name = mgf;
1140
+ throw error;
1141
+ }
1142
+
1143
+ mgf = forge.mgf[mgf].create(forge.md[hash].create());
1144
+
1145
+ /* initialize hash function */
1146
+ hash = oids[child.signatureParameters.hash.algorithmOid];
1147
+ if(hash === undefined || forge.md[hash] === undefined) {
1148
+ throw {
1149
+ message: 'Unsupported RSASSA-PSS hash function.',
1150
+ oid: child.signatureParameters.hash.algorithmOid,
1151
+ name: hash
1152
+ };
1153
+ }
1154
+
1155
+ scheme = forge.pss.create(forge.md[hash].create(), mgf,
1156
+ child.signatureParameters.saltLength);
1157
+ break;
1158
+ }
1159
+
1160
+ // verify signature on cert using public key
1161
+ rval = cert.publicKey.verify(
1162
+ md.digest().getBytes(), child.signature, scheme);
1163
+ }
1164
+
1165
+ return rval;
1166
+ };
1167
+
1168
+ /**
1169
+ * Returns true if this certificate's issuer matches the passed
1170
+ * certificate's subject. Note that no signature check is performed.
1171
+ *
1172
+ * @param parent the certificate to check.
1173
+ *
1174
+ * @return true if this certificate's issuer matches the passed certificate's
1175
+ * subject.
1176
+ */
1177
+ cert.isIssuer = function(parent) {
1178
+ var rval = false;
1179
+
1180
+ var i = cert.issuer;
1181
+ var s = parent.subject;
1182
+
1183
+ // compare hashes if present
1184
+ if(i.hash && s.hash) {
1185
+ rval = (i.hash === s.hash);
1186
+ } else if(i.attributes.length === s.attributes.length) {
1187
+ // all attributes are the same so issuer matches subject
1188
+ rval = true;
1189
+ var iattr, sattr;
1190
+ for(var n = 0; rval && n < i.attributes.length; ++n) {
1191
+ iattr = i.attributes[n];
1192
+ sattr = s.attributes[n];
1193
+ if(iattr.type !== sattr.type || iattr.value !== sattr.value) {
1194
+ // attribute mismatch
1195
+ rval = false;
1196
+ }
1197
+ }
1198
+ }
1199
+
1200
+ return rval;
1201
+ };
1202
+
1203
+ /**
1204
+ * Returns true if this certificate's subject matches the issuer of the
1205
+ * given certificate). Note that not signature check is performed.
1206
+ *
1207
+ * @param child the certificate to check.
1208
+ *
1209
+ * @return true if this certificate's subject matches the passed
1210
+ * certificate's issuer.
1211
+ */
1212
+ cert.issued = function(child) {
1213
+ return child.isIssuer(cert);
1214
+ };
1215
+
1216
+ /**
1217
+ * Generates the subjectKeyIdentifier for this certificate as byte buffer.
1218
+ *
1219
+ * @return the subjectKeyIdentifier for this certificate as byte buffer.
1220
+ */
1221
+ cert.generateSubjectKeyIdentifier = function() {
1222
+ /* See: 4.2.1.2 section of the the RFC3280, keyIdentifier is either:
1223
+
1224
+ (1) The keyIdentifier is composed of the 160-bit SHA-1 hash of the
1225
+ value of the BIT STRING subjectPublicKey (excluding the tag,
1226
+ length, and number of unused bits).
1227
+
1228
+ (2) The keyIdentifier is composed of a four bit type field with
1229
+ the value 0100 followed by the least significant 60 bits of the
1230
+ SHA-1 hash of the value of the BIT STRING subjectPublicKey
1231
+ (excluding the tag, length, and number of unused bit string bits).
1232
+ */
1233
+
1234
+ // skipping the tag, length, and number of unused bits is the same
1235
+ // as just using the RSAPublicKey (for RSA keys, which are the
1236
+ // only ones supported)
1237
+ return pki.getPublicKeyFingerprint(cert.publicKey, {type: 'RSAPublicKey'});
1238
+ };
1239
+
1240
+ /**
1241
+ * Verifies the subjectKeyIdentifier extension value for this certificate
1242
+ * against its public key. If no extension is found, false will be
1243
+ * returned.
1244
+ *
1245
+ * @return true if verified, false if not.
1246
+ */
1247
+ cert.verifySubjectKeyIdentifier = function() {
1248
+ var oid = oids['subjectKeyIdentifier'];
1249
+ for(var i = 0; i < cert.extensions.length; ++i) {
1250
+ var ext = cert.extensions[i];
1251
+ if(ext.id === oid) {
1252
+ var ski = cert.generateSubjectKeyIdentifier().getBytes();
1253
+ return (forge.util.hexToBytes(ext.subjectKeyIdentifier) === ski);
1254
+ }
1255
+ }
1256
+ return false;
1257
+ };
1258
+
1259
+ return cert;
1260
+ };
1261
+
1262
+ /**
1263
+ * Converts an X.509v3 RSA certificate from an ASN.1 object.
1264
+ *
1265
+ * Note: If the certificate is to be verified then compute hash should
1266
+ * be set to true. There is currently no implementation for converting
1267
+ * a certificate back to ASN.1 so the TBSCertificate part of the ASN.1
1268
+ * object needs to be scanned before the cert object is created.
1269
+ *
1270
+ * @param obj the asn1 representation of an X.509v3 RSA certificate.
1271
+ * @param computeHash true to compute the hash for verification.
1272
+ *
1273
+ * @return the certificate.
1274
+ */
1275
+ pki.certificateFromAsn1 = function(obj, computeHash) {
1276
+ // validate certificate and capture data
1277
+ var capture = {};
1278
+ var errors = [];
1279
+ if(!asn1.validate(obj, x509CertificateValidator, capture, errors)) {
1280
+ var error = new Error('Cannot read X.509 certificate. ' +
1281
+ 'ASN.1 object is not an X509v3 Certificate.');
1282
+ error.errors = errors;
1283
+ throw error;
1284
+ }
1285
+
1286
+ // get oid
1287
+ var oid = asn1.derToOid(capture.publicKeyOid);
1288
+ if(oid !== pki.oids.rsaEncryption) {
1289
+ throw new Error('Cannot read public key. OID is not RSA.');
1290
+ }
1291
+
1292
+ // create certificate
1293
+ var cert = pki.createCertificate();
1294
+ cert.version = capture.certVersion ?
1295
+ capture.certVersion.charCodeAt(0) : 0;
1296
+ var serial = forge.util.createBuffer(capture.certSerialNumber);
1297
+ cert.serialNumber = serial.toHex();
1298
+ cert.signatureOid = forge.asn1.derToOid(capture.certSignatureOid);
1299
+ cert.signatureParameters = _readSignatureParameters(
1300
+ cert.signatureOid, capture.certSignatureParams, true);
1301
+ cert.siginfo.algorithmOid = forge.asn1.derToOid(capture.certinfoSignatureOid);
1302
+ cert.siginfo.parameters = _readSignatureParameters(cert.siginfo.algorithmOid,
1303
+ capture.certinfoSignatureParams, false);
1304
+ cert.signature = capture.certSignature;
1305
+
1306
+ var validity = [];
1307
+ if(capture.certValidity1UTCTime !== undefined) {
1308
+ validity.push(asn1.utcTimeToDate(capture.certValidity1UTCTime));
1309
+ }
1310
+ if(capture.certValidity2GeneralizedTime !== undefined) {
1311
+ validity.push(asn1.generalizedTimeToDate(
1312
+ capture.certValidity2GeneralizedTime));
1313
+ }
1314
+ if(capture.certValidity3UTCTime !== undefined) {
1315
+ validity.push(asn1.utcTimeToDate(capture.certValidity3UTCTime));
1316
+ }
1317
+ if(capture.certValidity4GeneralizedTime !== undefined) {
1318
+ validity.push(asn1.generalizedTimeToDate(
1319
+ capture.certValidity4GeneralizedTime));
1320
+ }
1321
+ if(validity.length > 2) {
1322
+ throw new Error('Cannot read notBefore/notAfter validity times; more ' +
1323
+ 'than two times were provided in the certificate.');
1324
+ }
1325
+ if(validity.length < 2) {
1326
+ throw new Error('Cannot read notBefore/notAfter validity times; they ' +
1327
+ 'were not provided as either UTCTime or GeneralizedTime.');
1328
+ }
1329
+ cert.validity.notBefore = validity[0];
1330
+ cert.validity.notAfter = validity[1];
1331
+
1332
+ // keep TBSCertificate to preserve signature when exporting
1333
+ cert.tbsCertificate = capture.tbsCertificate;
1334
+
1335
+ if(computeHash) {
1336
+ // check signature OID for supported signature types
1337
+ cert.md = null;
1338
+ if(cert.signatureOid in oids) {
1339
+ var oid = oids[cert.signatureOid];
1340
+ switch(oid) {
1341
+ case 'sha1WithRSAEncryption':
1342
+ cert.md = forge.md.sha1.create();
1343
+ break;
1344
+ case 'md5WithRSAEncryption':
1345
+ cert.md = forge.md.md5.create();
1346
+ break;
1347
+ case 'sha256WithRSAEncryption':
1348
+ cert.md = forge.md.sha256.create();
1349
+ break;
1350
+ case 'sha384WithRSAEncryption':
1351
+ cert.md = forge.md.sha384.create();
1352
+ break;
1353
+ case 'sha512WithRSAEncryption':
1354
+ cert.md = forge.md.sha512.create();
1355
+ break;
1356
+ case 'RSASSA-PSS':
1357
+ cert.md = forge.md.sha256.create();
1358
+ break;
1359
+ }
1360
+ }
1361
+ if(cert.md === null) {
1362
+ var error = new Error('Could not compute certificate digest. ' +
1363
+ 'Unknown signature OID.');
1364
+ error.signatureOid = cert.signatureOid;
1365
+ throw error;
1366
+ }
1367
+
1368
+ // produce DER formatted TBSCertificate and digest it
1369
+ var bytes = asn1.toDer(cert.tbsCertificate);
1370
+ cert.md.update(bytes.getBytes());
1371
+ }
1372
+
1373
+ // handle issuer, build issuer message digest
1374
+ var imd = forge.md.sha1.create();
1375
+ cert.issuer.getField = function(sn) {
1376
+ return _getAttribute(cert.issuer, sn);
1377
+ };
1378
+ cert.issuer.addField = function(attr) {
1379
+ _fillMissingFields([attr]);
1380
+ cert.issuer.attributes.push(attr);
1381
+ };
1382
+ cert.issuer.attributes = pki.RDNAttributesAsArray(capture.certIssuer, imd);
1383
+ if(capture.certIssuerUniqueId) {
1384
+ cert.issuer.uniqueId = capture.certIssuerUniqueId;
1385
+ }
1386
+ cert.issuer.hash = imd.digest().toHex();
1387
+
1388
+ // handle subject, build subject message digest
1389
+ var smd = forge.md.sha1.create();
1390
+ cert.subject.getField = function(sn) {
1391
+ return _getAttribute(cert.subject, sn);
1392
+ };
1393
+ cert.subject.addField = function(attr) {
1394
+ _fillMissingFields([attr]);
1395
+ cert.subject.attributes.push(attr);
1396
+ };
1397
+ cert.subject.attributes = pki.RDNAttributesAsArray(capture.certSubject, smd);
1398
+ if(capture.certSubjectUniqueId) {
1399
+ cert.subject.uniqueId = capture.certSubjectUniqueId;
1400
+ }
1401
+ cert.subject.hash = smd.digest().toHex();
1402
+
1403
+ // handle extensions
1404
+ if(capture.certExtensions) {
1405
+ cert.extensions = pki.certificateExtensionsFromAsn1(capture.certExtensions);
1406
+ } else {
1407
+ cert.extensions = [];
1408
+ }
1409
+
1410
+ // convert RSA public key from ASN.1
1411
+ cert.publicKey = pki.publicKeyFromAsn1(capture.subjectPublicKeyInfo);
1412
+
1413
+ return cert;
1414
+ };
1415
+
1416
+ /**
1417
+ * Converts an ASN.1 extensions object (with extension sequences as its
1418
+ * values) into an array of extension objects with types and values.
1419
+ *
1420
+ * Supported extensions:
1421
+ *
1422
+ * id-ce-keyUsage OBJECT IDENTIFIER ::= { id-ce 15 }
1423
+ * KeyUsage ::= BIT STRING {
1424
+ * digitalSignature (0),
1425
+ * nonRepudiation (1),
1426
+ * keyEncipherment (2),
1427
+ * dataEncipherment (3),
1428
+ * keyAgreement (4),
1429
+ * keyCertSign (5),
1430
+ * cRLSign (6),
1431
+ * encipherOnly (7),
1432
+ * decipherOnly (8)
1433
+ * }
1434
+ *
1435
+ * id-ce-basicConstraints OBJECT IDENTIFIER ::= { id-ce 19 }
1436
+ * BasicConstraints ::= SEQUENCE {
1437
+ * cA BOOLEAN DEFAULT FALSE,
1438
+ * pathLenConstraint INTEGER (0..MAX) OPTIONAL
1439
+ * }
1440
+ *
1441
+ * subjectAltName EXTENSION ::= {
1442
+ * SYNTAX GeneralNames
1443
+ * IDENTIFIED BY id-ce-subjectAltName
1444
+ * }
1445
+ *
1446
+ * GeneralNames ::= SEQUENCE SIZE (1..MAX) OF GeneralName
1447
+ *
1448
+ * GeneralName ::= CHOICE {
1449
+ * otherName [0] INSTANCE OF OTHER-NAME,
1450
+ * rfc822Name [1] IA5String,
1451
+ * dNSName [2] IA5String,
1452
+ * x400Address [3] ORAddress,
1453
+ * directoryName [4] Name,
1454
+ * ediPartyName [5] EDIPartyName,
1455
+ * uniformResourceIdentifier [6] IA5String,
1456
+ * IPAddress [7] OCTET STRING,
1457
+ * registeredID [8] OBJECT IDENTIFIER
1458
+ * }
1459
+ *
1460
+ * OTHER-NAME ::= TYPE-IDENTIFIER
1461
+ *
1462
+ * EDIPartyName ::= SEQUENCE {
1463
+ * nameAssigner [0] DirectoryString {ub-name} OPTIONAL,
1464
+ * partyName [1] DirectoryString {ub-name}
1465
+ * }
1466
+ *
1467
+ * @param exts the extensions ASN.1 with extension sequences to parse.
1468
+ *
1469
+ * @return the array.
1470
+ */
1471
+ pki.certificateExtensionsFromAsn1 = function(exts) {
1472
+ var rval = [];
1473
+ for(var i = 0; i < exts.value.length; ++i) {
1474
+ // get extension sequence
1475
+ var extseq = exts.value[i];
1476
+ for(var ei = 0; ei < extseq.value.length; ++ei) {
1477
+ rval.push(pki.certificateExtensionFromAsn1(extseq.value[ei]));
1478
+ }
1479
+ }
1480
+
1481
+ return rval;
1482
+ };
1483
+
1484
+ /**
1485
+ * Parses a single certificate extension from ASN.1.
1486
+ *
1487
+ * @param ext the extension in ASN.1 format.
1488
+ *
1489
+ * @return the parsed extension as an object.
1490
+ */
1491
+ pki.certificateExtensionFromAsn1 = function(ext) {
1492
+ // an extension has:
1493
+ // [0] extnID OBJECT IDENTIFIER
1494
+ // [1] critical BOOLEAN DEFAULT FALSE
1495
+ // [2] extnValue OCTET STRING
1496
+ var e = {};
1497
+ e.id = asn1.derToOid(ext.value[0].value);
1498
+ e.critical = false;
1499
+ if(ext.value[1].type === asn1.Type.BOOLEAN) {
1500
+ e.critical = (ext.value[1].value.charCodeAt(0) !== 0x00);
1501
+ e.value = ext.value[2].value;
1502
+ } else {
1503
+ e.value = ext.value[1].value;
1504
+ }
1505
+ // if the oid is known, get its name
1506
+ if(e.id in oids) {
1507
+ e.name = oids[e.id];
1508
+
1509
+ // handle key usage
1510
+ if(e.name === 'keyUsage') {
1511
+ // get value as BIT STRING
1512
+ var ev = asn1.fromDer(e.value);
1513
+ var b2 = 0x00;
1514
+ var b3 = 0x00;
1515
+ if(ev.value.length > 1) {
1516
+ // skip first byte, just indicates unused bits which
1517
+ // will be padded with 0s anyway
1518
+ // get bytes with flag bits
1519
+ b2 = ev.value.charCodeAt(1);
1520
+ b3 = ev.value.length > 2 ? ev.value.charCodeAt(2) : 0;
1521
+ }
1522
+ // set flags
1523
+ e.digitalSignature = (b2 & 0x80) === 0x80;
1524
+ e.nonRepudiation = (b2 & 0x40) === 0x40;
1525
+ e.keyEncipherment = (b2 & 0x20) === 0x20;
1526
+ e.dataEncipherment = (b2 & 0x10) === 0x10;
1527
+ e.keyAgreement = (b2 & 0x08) === 0x08;
1528
+ e.keyCertSign = (b2 & 0x04) === 0x04;
1529
+ e.cRLSign = (b2 & 0x02) === 0x02;
1530
+ e.encipherOnly = (b2 & 0x01) === 0x01;
1531
+ e.decipherOnly = (b3 & 0x80) === 0x80;
1532
+ } else if(e.name === 'basicConstraints') {
1533
+ // handle basic constraints
1534
+ // get value as SEQUENCE
1535
+ var ev = asn1.fromDer(e.value);
1536
+ // get cA BOOLEAN flag (defaults to false)
1537
+ if(ev.value.length > 0 && ev.value[0].type === asn1.Type.BOOLEAN) {
1538
+ e.cA = (ev.value[0].value.charCodeAt(0) !== 0x00);
1539
+ } else {
1540
+ e.cA = false;
1541
+ }
1542
+ // get path length constraint
1543
+ var value = null;
1544
+ if(ev.value.length > 0 && ev.value[0].type === asn1.Type.INTEGER) {
1545
+ value = ev.value[0].value;
1546
+ } else if(ev.value.length > 1) {
1547
+ value = ev.value[1].value;
1548
+ }
1549
+ if(value !== null) {
1550
+ e.pathLenConstraint = asn1.derToInteger(value);
1551
+ }
1552
+ } else if(e.name === 'extKeyUsage') {
1553
+ // handle extKeyUsage
1554
+ // value is a SEQUENCE of OIDs
1555
+ var ev = asn1.fromDer(e.value);
1556
+ for(var vi = 0; vi < ev.value.length; ++vi) {
1557
+ var oid = asn1.derToOid(ev.value[vi].value);
1558
+ if(oid in oids) {
1559
+ e[oids[oid]] = true;
1560
+ } else {
1561
+ e[oid] = true;
1562
+ }
1563
+ }
1564
+ } else if(e.name === 'nsCertType') {
1565
+ // handle nsCertType
1566
+ // get value as BIT STRING
1567
+ var ev = asn1.fromDer(e.value);
1568
+ var b2 = 0x00;
1569
+ if(ev.value.length > 1) {
1570
+ // skip first byte, just indicates unused bits which
1571
+ // will be padded with 0s anyway
1572
+ // get bytes with flag bits
1573
+ b2 = ev.value.charCodeAt(1);
1574
+ }
1575
+ // set flags
1576
+ e.client = (b2 & 0x80) === 0x80;
1577
+ e.server = (b2 & 0x40) === 0x40;
1578
+ e.email = (b2 & 0x20) === 0x20;
1579
+ e.objsign = (b2 & 0x10) === 0x10;
1580
+ e.reserved = (b2 & 0x08) === 0x08;
1581
+ e.sslCA = (b2 & 0x04) === 0x04;
1582
+ e.emailCA = (b2 & 0x02) === 0x02;
1583
+ e.objCA = (b2 & 0x01) === 0x01;
1584
+ } else if(
1585
+ e.name === 'subjectAltName' ||
1586
+ e.name === 'issuerAltName') {
1587
+ // handle subjectAltName/issuerAltName
1588
+ e.altNames = [];
1589
+
1590
+ // ev is a SYNTAX SEQUENCE
1591
+ var gn;
1592
+ var ev = asn1.fromDer(e.value);
1593
+ for(var n = 0; n < ev.value.length; ++n) {
1594
+ // get GeneralName
1595
+ gn = ev.value[n];
1596
+
1597
+ var altName = {
1598
+ type: gn.type,
1599
+ value: gn.value
1600
+ };
1601
+ e.altNames.push(altName);
1602
+
1603
+ // Note: Support for types 1,2,6,7,8
1604
+ switch(gn.type) {
1605
+ // rfc822Name
1606
+ case 1:
1607
+ // dNSName
1608
+ case 2:
1609
+ // uniformResourceIdentifier (URI)
1610
+ case 6:
1611
+ break;
1612
+ // IPAddress
1613
+ case 7:
1614
+ // convert to IPv4/IPv6 string representation
1615
+ altName.ip = forge.util.bytesToIP(gn.value);
1616
+ break;
1617
+ // registeredID
1618
+ case 8:
1619
+ altName.oid = asn1.derToOid(gn.value);
1620
+ break;
1621
+ default:
1622
+ // unsupported
1623
+ }
1624
+ }
1625
+ } else if(e.name === 'subjectKeyIdentifier') {
1626
+ // value is an OCTETSTRING w/the hash of the key-type specific
1627
+ // public key structure (eg: RSAPublicKey)
1628
+ var ev = asn1.fromDer(e.value);
1629
+ e.subjectKeyIdentifier = forge.util.bytesToHex(ev.value);
1630
+ }
1631
+ }
1632
+ return e;
1633
+ };
1634
+
1635
+ /**
1636
+ * Converts a PKCS#10 certification request (CSR) from an ASN.1 object.
1637
+ *
1638
+ * Note: If the certification request is to be verified then compute hash
1639
+ * should be set to true. There is currently no implementation for converting
1640
+ * a certificate back to ASN.1 so the CertificationRequestInfo part of the
1641
+ * ASN.1 object needs to be scanned before the csr object is created.
1642
+ *
1643
+ * @param obj the asn1 representation of a PKCS#10 certification request (CSR).
1644
+ * @param computeHash true to compute the hash for verification.
1645
+ *
1646
+ * @return the certification request (CSR).
1647
+ */
1648
+ pki.certificationRequestFromAsn1 = function(obj, computeHash) {
1649
+ // validate certification request and capture data
1650
+ var capture = {};
1651
+ var errors = [];
1652
+ if(!asn1.validate(obj, certificationRequestValidator, capture, errors)) {
1653
+ var error = new Error('Cannot read PKCS#10 certificate request. ' +
1654
+ 'ASN.1 object is not a PKCS#10 CertificationRequest.');
1655
+ error.errors = errors;
1656
+ throw error;
1657
+ }
1658
+
1659
+ // get oid
1660
+ var oid = asn1.derToOid(capture.publicKeyOid);
1661
+ if(oid !== pki.oids.rsaEncryption) {
1662
+ throw new Error('Cannot read public key. OID is not RSA.');
1663
+ }
1664
+
1665
+ // create certification request
1666
+ var csr = pki.createCertificationRequest();
1667
+ csr.version = capture.csrVersion ? capture.csrVersion.charCodeAt(0) : 0;
1668
+ csr.signatureOid = forge.asn1.derToOid(capture.csrSignatureOid);
1669
+ csr.signatureParameters = _readSignatureParameters(
1670
+ csr.signatureOid, capture.csrSignatureParams, true);
1671
+ csr.siginfo.algorithmOid = forge.asn1.derToOid(capture.csrSignatureOid);
1672
+ csr.siginfo.parameters = _readSignatureParameters(
1673
+ csr.siginfo.algorithmOid, capture.csrSignatureParams, false);
1674
+ csr.signature = capture.csrSignature;
1675
+
1676
+ // keep CertificationRequestInfo to preserve signature when exporting
1677
+ csr.certificationRequestInfo = capture.certificationRequestInfo;
1678
+
1679
+ if(computeHash) {
1680
+ // check signature OID for supported signature types
1681
+ csr.md = null;
1682
+ if(csr.signatureOid in oids) {
1683
+ var oid = oids[csr.signatureOid];
1684
+ switch(oid) {
1685
+ case 'sha1WithRSAEncryption':
1686
+ csr.md = forge.md.sha1.create();
1687
+ break;
1688
+ case 'md5WithRSAEncryption':
1689
+ csr.md = forge.md.md5.create();
1690
+ break;
1691
+ case 'sha256WithRSAEncryption':
1692
+ csr.md = forge.md.sha256.create();
1693
+ break;
1694
+ case 'sha384WithRSAEncryption':
1695
+ csr.md = forge.md.sha384.create();
1696
+ break;
1697
+ case 'sha512WithRSAEncryption':
1698
+ csr.md = forge.md.sha512.create();
1699
+ break;
1700
+ case 'RSASSA-PSS':
1701
+ csr.md = forge.md.sha256.create();
1702
+ break;
1703
+ }
1704
+ }
1705
+ if(csr.md === null) {
1706
+ var error = new Error('Could not compute certification request digest. ' +
1707
+ 'Unknown signature OID.');
1708
+ error.signatureOid = csr.signatureOid;
1709
+ throw error;
1710
+ }
1711
+
1712
+ // produce DER formatted CertificationRequestInfo and digest it
1713
+ var bytes = asn1.toDer(csr.certificationRequestInfo);
1714
+ csr.md.update(bytes.getBytes());
1715
+ }
1716
+
1717
+ // handle subject, build subject message digest
1718
+ var smd = forge.md.sha1.create();
1719
+ csr.subject.getField = function(sn) {
1720
+ return _getAttribute(csr.subject, sn);
1721
+ };
1722
+ csr.subject.addField = function(attr) {
1723
+ _fillMissingFields([attr]);
1724
+ csr.subject.attributes.push(attr);
1725
+ };
1726
+ csr.subject.attributes = pki.RDNAttributesAsArray(
1727
+ capture.certificationRequestInfoSubject, smd);
1728
+ csr.subject.hash = smd.digest().toHex();
1729
+
1730
+ // convert RSA public key from ASN.1
1731
+ csr.publicKey = pki.publicKeyFromAsn1(capture.subjectPublicKeyInfo);
1732
+
1733
+ // convert attributes from ASN.1
1734
+ csr.getAttribute = function(sn) {
1735
+ return _getAttribute(csr, sn);
1736
+ };
1737
+ csr.addAttribute = function(attr) {
1738
+ _fillMissingFields([attr]);
1739
+ csr.attributes.push(attr);
1740
+ };
1741
+ csr.attributes = pki.CRIAttributesAsArray(
1742
+ capture.certificationRequestInfoAttributes || []);
1743
+
1744
+ return csr;
1745
+ };
1746
+
1747
+ /**
1748
+ * Creates an empty certification request (a CSR or certificate signing
1749
+ * request). Once created, its public key and attributes can be set and then
1750
+ * it can be signed.
1751
+ *
1752
+ * @return the empty certification request.
1753
+ */
1754
+ pki.createCertificationRequest = function() {
1755
+ var csr = {};
1756
+ csr.version = 0x00;
1757
+ csr.signatureOid = null;
1758
+ csr.signature = null;
1759
+ csr.siginfo = {};
1760
+ csr.siginfo.algorithmOid = null;
1761
+
1762
+ csr.subject = {};
1763
+ csr.subject.getField = function(sn) {
1764
+ return _getAttribute(csr.subject, sn);
1765
+ };
1766
+ csr.subject.addField = function(attr) {
1767
+ _fillMissingFields([attr]);
1768
+ csr.subject.attributes.push(attr);
1769
+ };
1770
+ csr.subject.attributes = [];
1771
+ csr.subject.hash = null;
1772
+
1773
+ csr.publicKey = null;
1774
+ csr.attributes = [];
1775
+ csr.getAttribute = function(sn) {
1776
+ return _getAttribute(csr, sn);
1777
+ };
1778
+ csr.addAttribute = function(attr) {
1779
+ _fillMissingFields([attr]);
1780
+ csr.attributes.push(attr);
1781
+ };
1782
+ csr.md = null;
1783
+
1784
+ /**
1785
+ * Sets the subject of this certification request.
1786
+ *
1787
+ * @param attrs the array of subject attributes to use.
1788
+ */
1789
+ csr.setSubject = function(attrs) {
1790
+ // set new attributes
1791
+ _fillMissingFields(attrs);
1792
+ csr.subject.attributes = attrs;
1793
+ csr.subject.hash = null;
1794
+ };
1795
+
1796
+ /**
1797
+ * Sets the attributes of this certification request.
1798
+ *
1799
+ * @param attrs the array of attributes to use.
1800
+ */
1801
+ csr.setAttributes = function(attrs) {
1802
+ // set new attributes
1803
+ _fillMissingFields(attrs);
1804
+ csr.attributes = attrs;
1805
+ };
1806
+
1807
+ /**
1808
+ * Signs this certification request using the given private key.
1809
+ *
1810
+ * @param key the private key to sign with.
1811
+ * @param md the message digest object to use (defaults to forge.md.sha1).
1812
+ */
1813
+ csr.sign = function(key, md) {
1814
+ // TODO: get signature OID from private key
1815
+ csr.md = md || forge.md.sha1.create();
1816
+ var algorithmOid = oids[csr.md.algorithm + 'WithRSAEncryption'];
1817
+ if(!algorithmOid) {
1818
+ var error = new Error('Could not compute certification request digest. ' +
1819
+ 'Unknown message digest algorithm OID.');
1820
+ error.algorithm = csr.md.algorithm;
1821
+ throw error;
1822
+ }
1823
+ csr.signatureOid = csr.siginfo.algorithmOid = algorithmOid;
1824
+
1825
+ // get CertificationRequestInfo, convert to DER
1826
+ csr.certificationRequestInfo = pki.getCertificationRequestInfo(csr);
1827
+ var bytes = asn1.toDer(csr.certificationRequestInfo);
1828
+
1829
+ // digest and sign
1830
+ csr.md.update(bytes.getBytes());
1831
+ csr.signature = key.sign(csr.md);
1832
+ };
1833
+
1834
+ /**
1835
+ * Attempts verify the signature on the passed certification request using
1836
+ * its public key.
1837
+ *
1838
+ * A CSR that has been exported to a file in PEM format can be verified using
1839
+ * OpenSSL using this command:
1840
+ *
1841
+ * openssl req -in <the-csr-pem-file> -verify -noout -text
1842
+ *
1843
+ * @return true if verified, false if not.
1844
+ */
1845
+ csr.verify = function() {
1846
+ var rval = false;
1847
+
1848
+ var md = csr.md;
1849
+ if(md === null) {
1850
+ // check signature OID for supported signature types
1851
+ if(csr.signatureOid in oids) {
1852
+ // TODO: create DRY `OID to md` function
1853
+ var oid = oids[csr.signatureOid];
1854
+ switch(oid) {
1855
+ case 'sha1WithRSAEncryption':
1856
+ md = forge.md.sha1.create();
1857
+ break;
1858
+ case 'md5WithRSAEncryption':
1859
+ md = forge.md.md5.create();
1860
+ break;
1861
+ case 'sha256WithRSAEncryption':
1862
+ md = forge.md.sha256.create();
1863
+ break;
1864
+ case 'sha384WithRSAEncryption':
1865
+ md = forge.md.sha384.create();
1866
+ break;
1867
+ case 'sha512WithRSAEncryption':
1868
+ md = forge.md.sha512.create();
1869
+ break;
1870
+ case 'RSASSA-PSS':
1871
+ md = forge.md.sha256.create();
1872
+ break;
1873
+ }
1874
+ }
1875
+ if(md === null) {
1876
+ var error = new Error(
1877
+ 'Could not compute certification request digest. ' +
1878
+ 'Unknown signature OID.');
1879
+ error.signatureOid = csr.signatureOid;
1880
+ throw error;
1881
+ }
1882
+
1883
+ // produce DER formatted CertificationRequestInfo and digest it
1884
+ var cri = csr.certificationRequestInfo ||
1885
+ pki.getCertificationRequestInfo(csr);
1886
+ var bytes = asn1.toDer(cri);
1887
+ md.update(bytes.getBytes());
1888
+ }
1889
+
1890
+ if(md !== null) {
1891
+ var scheme;
1892
+
1893
+ switch(csr.signatureOid) {
1894
+ case oids.sha1WithRSAEncryption:
1895
+ /* use PKCS#1 v1.5 padding scheme */
1896
+ break;
1897
+ case oids['RSASSA-PSS']:
1898
+ var hash, mgf;
1899
+
1900
+ /* initialize mgf */
1901
+ hash = oids[csr.signatureParameters.mgf.hash.algorithmOid];
1902
+ if(hash === undefined || forge.md[hash] === undefined) {
1903
+ var error = new Error('Unsupported MGF hash function.');
1904
+ error.oid = csr.signatureParameters.mgf.hash.algorithmOid;
1905
+ error.name = hash;
1906
+ throw error;
1907
+ }
1908
+
1909
+ mgf = oids[csr.signatureParameters.mgf.algorithmOid];
1910
+ if(mgf === undefined || forge.mgf[mgf] === undefined) {
1911
+ var error = new Error('Unsupported MGF function.');
1912
+ error.oid = csr.signatureParameters.mgf.algorithmOid;
1913
+ error.name = mgf;
1914
+ throw error;
1915
+ }
1916
+
1917
+ mgf = forge.mgf[mgf].create(forge.md[hash].create());
1918
+
1919
+ /* initialize hash function */
1920
+ hash = oids[csr.signatureParameters.hash.algorithmOid];
1921
+ if(hash === undefined || forge.md[hash] === undefined) {
1922
+ var error = new Error('Unsupported RSASSA-PSS hash function.');
1923
+ error.oid = csr.signatureParameters.hash.algorithmOid;
1924
+ error.name = hash;
1925
+ throw error;
1926
+ }
1927
+
1928
+ scheme = forge.pss.create(forge.md[hash].create(), mgf,
1929
+ csr.signatureParameters.saltLength);
1930
+ break;
1931
+ }
1932
+
1933
+ // verify signature on csr using its public key
1934
+ rval = csr.publicKey.verify(
1935
+ md.digest().getBytes(), csr.signature, scheme);
1936
+ }
1937
+
1938
+ return rval;
1939
+ };
1940
+
1941
+ return csr;
1942
+ };
1943
+
1944
+ /**
1945
+ * Converts an X.509 subject or issuer to an ASN.1 RDNSequence.
1946
+ *
1947
+ * @param obj the subject or issuer (distinguished name).
1948
+ *
1949
+ * @return the ASN.1 RDNSequence.
1950
+ */
1951
+ function _dnToAsn1(obj) {
1952
+ // create an empty RDNSequence
1953
+ var rval = asn1.create(
1954
+ asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, []);
1955
+
1956
+ // iterate over attributes
1957
+ var attr, set;
1958
+ var attrs = obj.attributes;
1959
+ for(var i = 0; i < attrs.length; ++i) {
1960
+ attr = attrs[i];
1961
+ var value = attr.value;
1962
+
1963
+ // reuse tag class for attribute value if available
1964
+ var valueTagClass = asn1.Type.PRINTABLESTRING;
1965
+ if('valueTagClass' in attr) {
1966
+ valueTagClass = attr.valueTagClass;
1967
+
1968
+ if(valueTagClass === asn1.Type.UTF8) {
1969
+ value = forge.util.encodeUtf8(value);
1970
+ }
1971
+ // FIXME: handle more encodings
1972
+ }
1973
+
1974
+ // create a RelativeDistinguishedName set
1975
+ // each value in the set is an AttributeTypeAndValue first
1976
+ // containing the type (an OID) and second the value
1977
+ set = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SET, true, [
1978
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
1979
+ // AttributeType
1980
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
1981
+ asn1.oidToDer(attr.type).getBytes()),
1982
+ // AttributeValue
1983
+ asn1.create(asn1.Class.UNIVERSAL, valueTagClass, false, value)
1984
+ ])
1985
+ ]);
1986
+ rval.value.push(set);
1987
+ }
1988
+
1989
+ return rval;
1990
+ }
1991
+
1992
+ /**
1993
+ * Gets all printable attributes (typically of an issuer or subject) in a
1994
+ * simplified JSON format for display.
1995
+ *
1996
+ * @param attrs the attributes.
1997
+ *
1998
+ * @return the JSON for display.
1999
+ */
2000
+ function _getAttributesAsJson(attrs) {
2001
+ var rval = {};
2002
+ for(var i = 0; i < attrs.length; ++i) {
2003
+ var attr = attrs[i];
2004
+ if(attr.shortName && (
2005
+ attr.valueTagClass === asn1.Type.UTF8 ||
2006
+ attr.valueTagClass === asn1.Type.PRINTABLESTRING ||
2007
+ attr.valueTagClass === asn1.Type.IA5STRING)) {
2008
+ var value = attr.value;
2009
+ if(attr.valueTagClass === asn1.Type.UTF8) {
2010
+ value = forge.util.encodeUtf8(attr.value);
2011
+ }
2012
+ if(!(attr.shortName in rval)) {
2013
+ rval[attr.shortName] = value;
2014
+ } else if(forge.util.isArray(rval[attr.shortName])) {
2015
+ rval[attr.shortName].push(value);
2016
+ } else {
2017
+ rval[attr.shortName] = [rval[attr.shortName], value];
2018
+ }
2019
+ }
2020
+ }
2021
+ return rval;
2022
+ }
2023
+
2024
+ /**
2025
+ * Fills in missing fields in attributes.
2026
+ *
2027
+ * @param attrs the attributes to fill missing fields in.
2028
+ */
2029
+ function _fillMissingFields(attrs) {
2030
+ var attr;
2031
+ for(var i = 0; i < attrs.length; ++i) {
2032
+ attr = attrs[i];
2033
+
2034
+ // populate missing name
2035
+ if(typeof attr.name === 'undefined') {
2036
+ if(attr.type && attr.type in pki.oids) {
2037
+ attr.name = pki.oids[attr.type];
2038
+ } else if(attr.shortName && attr.shortName in _shortNames) {
2039
+ attr.name = pki.oids[_shortNames[attr.shortName]];
2040
+ }
2041
+ }
2042
+
2043
+ // populate missing type (OID)
2044
+ if(typeof attr.type === 'undefined') {
2045
+ if(attr.name && attr.name in pki.oids) {
2046
+ attr.type = pki.oids[attr.name];
2047
+ } else {
2048
+ var error = new Error('Attribute type not specified.');
2049
+ error.attribute = attr;
2050
+ throw error;
2051
+ }
2052
+ }
2053
+
2054
+ // populate missing shortname
2055
+ if(typeof attr.shortName === 'undefined') {
2056
+ if(attr.name && attr.name in _shortNames) {
2057
+ attr.shortName = _shortNames[attr.name];
2058
+ }
2059
+ }
2060
+
2061
+ // convert extensions to value
2062
+ if(attr.type === oids.extensionRequest) {
2063
+ attr.valueConstructed = true;
2064
+ attr.valueTagClass = asn1.Type.SEQUENCE;
2065
+ if(!attr.value && attr.extensions) {
2066
+ attr.value = [];
2067
+ for(var ei = 0; ei < attr.extensions.length; ++ei) {
2068
+ attr.value.push(pki.certificateExtensionToAsn1(
2069
+ _fillMissingExtensionFields(attr.extensions[ei])));
2070
+ }
2071
+ }
2072
+ }
2073
+
2074
+ if(typeof attr.value === 'undefined') {
2075
+ var error = new Error('Attribute value not specified.');
2076
+ error.attribute = attr;
2077
+ throw error;
2078
+ }
2079
+ }
2080
+ }
2081
+
2082
+ /**
2083
+ * Fills in missing fields in certificate extensions.
2084
+ *
2085
+ * @param e the extension.
2086
+ * @param [options] the options to use.
2087
+ * [cert] the certificate the extensions are for.
2088
+ *
2089
+ * @return the extension.
2090
+ */
2091
+ function _fillMissingExtensionFields(e, options) {
2092
+ options = options || {};
2093
+
2094
+ // populate missing name
2095
+ if(typeof e.name === 'undefined') {
2096
+ if(e.id && e.id in pki.oids) {
2097
+ e.name = pki.oids[e.id];
2098
+ }
2099
+ }
2100
+
2101
+ // populate missing id
2102
+ if(typeof e.id === 'undefined') {
2103
+ if(e.name && e.name in pki.oids) {
2104
+ e.id = pki.oids[e.name];
2105
+ } else {
2106
+ var error = new Error('Extension ID not specified.');
2107
+ error.extension = e;
2108
+ throw error;
2109
+ }
2110
+ }
2111
+
2112
+ if(typeof e.value !== 'undefined') {
2113
+ return e;
2114
+ }
2115
+
2116
+ // handle missing value:
2117
+
2118
+ // value is a BIT STRING
2119
+ if(e.name === 'keyUsage') {
2120
+ // build flags
2121
+ var unused = 0;
2122
+ var b2 = 0x00;
2123
+ var b3 = 0x00;
2124
+ if(e.digitalSignature) {
2125
+ b2 |= 0x80;
2126
+ unused = 7;
2127
+ }
2128
+ if(e.nonRepudiation) {
2129
+ b2 |= 0x40;
2130
+ unused = 6;
2131
+ }
2132
+ if(e.keyEncipherment) {
2133
+ b2 |= 0x20;
2134
+ unused = 5;
2135
+ }
2136
+ if(e.dataEncipherment) {
2137
+ b2 |= 0x10;
2138
+ unused = 4;
2139
+ }
2140
+ if(e.keyAgreement) {
2141
+ b2 |= 0x08;
2142
+ unused = 3;
2143
+ }
2144
+ if(e.keyCertSign) {
2145
+ b2 |= 0x04;
2146
+ unused = 2;
2147
+ }
2148
+ if(e.cRLSign) {
2149
+ b2 |= 0x02;
2150
+ unused = 1;
2151
+ }
2152
+ if(e.encipherOnly) {
2153
+ b2 |= 0x01;
2154
+ unused = 0;
2155
+ }
2156
+ if(e.decipherOnly) {
2157
+ b3 |= 0x80;
2158
+ unused = 7;
2159
+ }
2160
+
2161
+ // create bit string
2162
+ var value = String.fromCharCode(unused);
2163
+ if(b3 !== 0) {
2164
+ value += String.fromCharCode(b2) + String.fromCharCode(b3);
2165
+ } else if(b2 !== 0) {
2166
+ value += String.fromCharCode(b2);
2167
+ }
2168
+ e.value = asn1.create(
2169
+ asn1.Class.UNIVERSAL, asn1.Type.BITSTRING, false, value);
2170
+ } else if(e.name === 'basicConstraints') {
2171
+ // basicConstraints is a SEQUENCE
2172
+ e.value = asn1.create(
2173
+ asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, []);
2174
+ // cA BOOLEAN flag defaults to false
2175
+ if(e.cA) {
2176
+ e.value.value.push(asn1.create(
2177
+ asn1.Class.UNIVERSAL, asn1.Type.BOOLEAN, false,
2178
+ String.fromCharCode(0xFF)));
2179
+ }
2180
+ if('pathLenConstraint' in e) {
2181
+ e.value.value.push(asn1.create(
2182
+ asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,
2183
+ asn1.integerToDer(e.pathLenConstraint).getBytes()));
2184
+ }
2185
+ } else if(e.name === 'extKeyUsage') {
2186
+ // extKeyUsage is a SEQUENCE of OIDs
2187
+ e.value = asn1.create(
2188
+ asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, []);
2189
+ var seq = e.value.value;
2190
+ for(var key in e) {
2191
+ if(e[key] !== true) {
2192
+ continue;
2193
+ }
2194
+ // key is name in OID map
2195
+ if(key in oids) {
2196
+ seq.push(asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID,
2197
+ false, asn1.oidToDer(oids[key]).getBytes()));
2198
+ } else if(key.indexOf('.') !== -1) {
2199
+ // assume key is an OID
2200
+ seq.push(asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID,
2201
+ false, asn1.oidToDer(key).getBytes()));
2202
+ }
2203
+ }
2204
+ } else if(e.name === 'nsCertType') {
2205
+ // nsCertType is a BIT STRING
2206
+ // build flags
2207
+ var unused = 0;
2208
+ var b2 = 0x00;
2209
+
2210
+ if(e.client) {
2211
+ b2 |= 0x80;
2212
+ unused = 7;
2213
+ }
2214
+ if(e.server) {
2215
+ b2 |= 0x40;
2216
+ unused = 6;
2217
+ }
2218
+ if(e.email) {
2219
+ b2 |= 0x20;
2220
+ unused = 5;
2221
+ }
2222
+ if(e.objsign) {
2223
+ b2 |= 0x10;
2224
+ unused = 4;
2225
+ }
2226
+ if(e.reserved) {
2227
+ b2 |= 0x08;
2228
+ unused = 3;
2229
+ }
2230
+ if(e.sslCA) {
2231
+ b2 |= 0x04;
2232
+ unused = 2;
2233
+ }
2234
+ if(e.emailCA) {
2235
+ b2 |= 0x02;
2236
+ unused = 1;
2237
+ }
2238
+ if(e.objCA) {
2239
+ b2 |= 0x01;
2240
+ unused = 0;
2241
+ }
2242
+
2243
+ // create bit string
2244
+ var value = String.fromCharCode(unused);
2245
+ if(b2 !== 0) {
2246
+ value += String.fromCharCode(b2);
2247
+ }
2248
+ e.value = asn1.create(
2249
+ asn1.Class.UNIVERSAL, asn1.Type.BITSTRING, false, value);
2250
+ } else if(e.name === 'subjectAltName' || e.name === 'issuerAltName') {
2251
+ // SYNTAX SEQUENCE
2252
+ e.value = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, []);
2253
+
2254
+ var altName;
2255
+ for(var n = 0; n < e.altNames.length; ++n) {
2256
+ altName = e.altNames[n];
2257
+ var value = altName.value;
2258
+ // handle IP
2259
+ if(altName.type === 7 && altName.ip) {
2260
+ value = forge.util.bytesFromIP(altName.ip);
2261
+ if(value === null) {
2262
+ var error = new Error(
2263
+ 'Extension "ip" value is not a valid IPv4 or IPv6 address.');
2264
+ error.extension = e;
2265
+ throw error;
2266
+ }
2267
+ } else if(altName.type === 8) {
2268
+ // handle OID
2269
+ if(altName.oid) {
2270
+ value = asn1.oidToDer(asn1.oidToDer(altName.oid));
2271
+ } else {
2272
+ // deprecated ... convert value to OID
2273
+ value = asn1.oidToDer(value);
2274
+ }
2275
+ }
2276
+ e.value.value.push(asn1.create(
2277
+ asn1.Class.CONTEXT_SPECIFIC, altName.type, false,
2278
+ value));
2279
+ }
2280
+ } else if(e.name === 'nsComment' && options.cert) {
2281
+ // sanity check value is ASCII (req'd) and not too big
2282
+ if(!(/^[\x00-\x7F]*$/.test(e.comment)) ||
2283
+ (e.comment.length < 1) || (e.comment.length > 128)) {
2284
+ throw new Error('Invalid "nsComment" content.');
2285
+ }
2286
+ // IA5STRING opaque comment
2287
+ e.value = asn1.create(
2288
+ asn1.Class.UNIVERSAL, asn1.Type.IA5STRING, false, e.comment);
2289
+ } else if(e.name === 'subjectKeyIdentifier' && options.cert) {
2290
+ var ski = options.cert.generateSubjectKeyIdentifier();
2291
+ e.subjectKeyIdentifier = ski.toHex();
2292
+ // OCTETSTRING w/digest
2293
+ e.value = asn1.create(
2294
+ asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false, ski.getBytes());
2295
+ } else if(e.name === 'authorityKeyIdentifier' && options.cert) {
2296
+ // SYNTAX SEQUENCE
2297
+ e.value = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, []);
2298
+ var seq = e.value.value;
2299
+
2300
+ if(e.keyIdentifier) {
2301
+ var keyIdentifier = (e.keyIdentifier === true ?
2302
+ options.cert.generateSubjectKeyIdentifier().getBytes() :
2303
+ e.keyIdentifier);
2304
+ seq.push(
2305
+ asn1.create(asn1.Class.CONTEXT_SPECIFIC, 0, false, keyIdentifier));
2306
+ }
2307
+
2308
+ if(e.authorityCertIssuer) {
2309
+ var authorityCertIssuer = [
2310
+ asn1.create(asn1.Class.CONTEXT_SPECIFIC, 4, true, [
2311
+ _dnToAsn1(e.authorityCertIssuer === true ?
2312
+ options.cert.issuer : e.authorityCertIssuer)
2313
+ ])
2314
+ ];
2315
+ seq.push(
2316
+ asn1.create(asn1.Class.CONTEXT_SPECIFIC, 1, true, authorityCertIssuer));
2317
+ }
2318
+
2319
+ if(e.serialNumber) {
2320
+ var serialNumber = forge.util.hexToBytes(e.serialNumber === true ?
2321
+ options.cert.serialNumber : e.serialNumber);
2322
+ seq.push(
2323
+ asn1.create(asn1.Class.CONTEXT_SPECIFIC, 2, false, serialNumber));
2324
+ }
2325
+ } else if(e.name === 'cRLDistributionPoints') {
2326
+ e.value = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, []);
2327
+ var seq = e.value.value;
2328
+
2329
+ // Create sub SEQUENCE of DistributionPointName
2330
+ var subSeq = asn1.create(
2331
+ asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, []);
2332
+
2333
+ // Create fullName CHOICE
2334
+ var fullNameGeneralNames = asn1.create(
2335
+ asn1.Class.CONTEXT_SPECIFIC, 0, true, []);
2336
+ var altName;
2337
+ for(var n = 0; n < e.altNames.length; ++n) {
2338
+ altName = e.altNames[n];
2339
+ var value = altName.value;
2340
+ // handle IP
2341
+ if(altName.type === 7 && altName.ip) {
2342
+ value = forge.util.bytesFromIP(altName.ip);
2343
+ if(value === null) {
2344
+ var error = new Error(
2345
+ 'Extension "ip" value is not a valid IPv4 or IPv6 address.');
2346
+ error.extension = e;
2347
+ throw error;
2348
+ }
2349
+ } else if(altName.type === 8) {
2350
+ // handle OID
2351
+ if(altName.oid) {
2352
+ value = asn1.oidToDer(asn1.oidToDer(altName.oid));
2353
+ } else {
2354
+ // deprecated ... convert value to OID
2355
+ value = asn1.oidToDer(value);
2356
+ }
2357
+ }
2358
+ fullNameGeneralNames.value.push(asn1.create(
2359
+ asn1.Class.CONTEXT_SPECIFIC, altName.type, false,
2360
+ value));
2361
+ }
2362
+
2363
+ // Add to the parent SEQUENCE
2364
+ subSeq.value.push(asn1.create(
2365
+ asn1.Class.CONTEXT_SPECIFIC, 0, true, [fullNameGeneralNames]));
2366
+ seq.push(subSeq);
2367
+ }
2368
+
2369
+ // ensure value has been defined by now
2370
+ if(typeof e.value === 'undefined') {
2371
+ var error = new Error('Extension value not specified.');
2372
+ error.extension = e;
2373
+ throw error;
2374
+ }
2375
+
2376
+ return e;
2377
+ }
2378
+
2379
+ /**
2380
+ * Convert signature parameters object to ASN.1
2381
+ *
2382
+ * @param {String} oid Signature algorithm OID
2383
+ * @param params The signature parametrs object
2384
+ * @return ASN.1 object representing signature parameters
2385
+ */
2386
+ function _signatureParametersToAsn1(oid, params) {
2387
+ switch(oid) {
2388
+ case oids['RSASSA-PSS']:
2389
+ var parts = [];
2390
+
2391
+ if(params.hash.algorithmOid !== undefined) {
2392
+ parts.push(asn1.create(asn1.Class.CONTEXT_SPECIFIC, 0, true, [
2393
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
2394
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
2395
+ asn1.oidToDer(params.hash.algorithmOid).getBytes()),
2396
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.NULL, false, '')
2397
+ ])
2398
+ ]));
2399
+ }
2400
+
2401
+ if(params.mgf.algorithmOid !== undefined) {
2402
+ parts.push(asn1.create(asn1.Class.CONTEXT_SPECIFIC, 1, true, [
2403
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
2404
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
2405
+ asn1.oidToDer(params.mgf.algorithmOid).getBytes()),
2406
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
2407
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
2408
+ asn1.oidToDer(params.mgf.hash.algorithmOid).getBytes()),
2409
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.NULL, false, '')
2410
+ ])
2411
+ ])
2412
+ ]));
2413
+ }
2414
+
2415
+ if(params.saltLength !== undefined) {
2416
+ parts.push(asn1.create(asn1.Class.CONTEXT_SPECIFIC, 2, true, [
2417
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,
2418
+ asn1.integerToDer(params.saltLength).getBytes())
2419
+ ]));
2420
+ }
2421
+
2422
+ return asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, parts);
2423
+
2424
+ default:
2425
+ return asn1.create(asn1.Class.UNIVERSAL, asn1.Type.NULL, false, '');
2426
+ }
2427
+ }
2428
+
2429
+ /**
2430
+ * Converts a certification request's attributes to an ASN.1 set of
2431
+ * CRIAttributes.
2432
+ *
2433
+ * @param csr certification request.
2434
+ *
2435
+ * @return the ASN.1 set of CRIAttributes.
2436
+ */
2437
+ function _CRIAttributesToAsn1(csr) {
2438
+ // create an empty context-specific container
2439
+ var rval = asn1.create(asn1.Class.CONTEXT_SPECIFIC, 0, true, []);
2440
+
2441
+ // no attributes, return empty container
2442
+ if(csr.attributes.length === 0) {
2443
+ return rval;
2444
+ }
2445
+
2446
+ // each attribute has a sequence with a type and a set of values
2447
+ var attrs = csr.attributes;
2448
+ for(var i = 0; i < attrs.length; ++i) {
2449
+ var attr = attrs[i];
2450
+ var value = attr.value;
2451
+
2452
+ // reuse tag class for attribute value if available
2453
+ var valueTagClass = asn1.Type.UTF8;
2454
+ if('valueTagClass' in attr) {
2455
+ valueTagClass = attr.valueTagClass;
2456
+ }
2457
+ if(valueTagClass === asn1.Type.UTF8) {
2458
+ value = forge.util.encodeUtf8(value);
2459
+ }
2460
+ var valueConstructed = false;
2461
+ if('valueConstructed' in attr) {
2462
+ valueConstructed = attr.valueConstructed;
2463
+ }
2464
+ // FIXME: handle more encodings
2465
+
2466
+ // create a RelativeDistinguishedName set
2467
+ // each value in the set is an AttributeTypeAndValue first
2468
+ // containing the type (an OID) and second the value
2469
+ var seq = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
2470
+ // AttributeType
2471
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
2472
+ asn1.oidToDer(attr.type).getBytes()),
2473
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SET, true, [
2474
+ // AttributeValue
2475
+ asn1.create(
2476
+ asn1.Class.UNIVERSAL, valueTagClass, valueConstructed, value)
2477
+ ])
2478
+ ]);
2479
+ rval.value.push(seq);
2480
+ }
2481
+
2482
+ return rval;
2483
+ }
2484
+
2485
+ var jan_1_1950 = new Date('1950-01-01T00:00:00Z');
2486
+ var jan_1_2050 = new Date('2050-01-01T00:00:00Z');
2487
+
2488
+ /**
2489
+ * Converts a Date object to ASN.1
2490
+ * Handles the different format before and after 1st January 2050
2491
+ *
2492
+ * @param date date object.
2493
+ *
2494
+ * @return the ASN.1 object representing the date.
2495
+ */
2496
+ function _dateToAsn1(date) {
2497
+ if(date >= jan_1_1950 && date < jan_1_2050) {
2498
+ return asn1.create(
2499
+ asn1.Class.UNIVERSAL, asn1.Type.UTCTIME, false,
2500
+ asn1.dateToUtcTime(date));
2501
+ } else {
2502
+ return asn1.create(
2503
+ asn1.Class.UNIVERSAL, asn1.Type.GENERALIZEDTIME, false,
2504
+ asn1.dateToGeneralizedTime(date));
2505
+ }
2506
+ }
2507
+
2508
+ /**
2509
+ * Gets the ASN.1 TBSCertificate part of an X.509v3 certificate.
2510
+ *
2511
+ * @param cert the certificate.
2512
+ *
2513
+ * @return the asn1 TBSCertificate.
2514
+ */
2515
+ pki.getTBSCertificate = function(cert) {
2516
+ // TBSCertificate
2517
+ var notBefore = _dateToAsn1(cert.validity.notBefore);
2518
+ var notAfter = _dateToAsn1(cert.validity.notAfter);
2519
+ var tbs = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
2520
+ // version
2521
+ asn1.create(asn1.Class.CONTEXT_SPECIFIC, 0, true, [
2522
+ // integer
2523
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,
2524
+ asn1.integerToDer(cert.version).getBytes())
2525
+ ]),
2526
+ // serialNumber
2527
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,
2528
+ forge.util.hexToBytes(cert.serialNumber)),
2529
+ // signature
2530
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
2531
+ // algorithm
2532
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
2533
+ asn1.oidToDer(cert.siginfo.algorithmOid).getBytes()),
2534
+ // parameters
2535
+ _signatureParametersToAsn1(
2536
+ cert.siginfo.algorithmOid, cert.siginfo.parameters)
2537
+ ]),
2538
+ // issuer
2539
+ _dnToAsn1(cert.issuer),
2540
+ // validity
2541
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
2542
+ notBefore,
2543
+ notAfter
2544
+ ]),
2545
+ // subject
2546
+ _dnToAsn1(cert.subject),
2547
+ // SubjectPublicKeyInfo
2548
+ pki.publicKeyToAsn1(cert.publicKey)
2549
+ ]);
2550
+
2551
+ if(cert.issuer.uniqueId) {
2552
+ // issuerUniqueID (optional)
2553
+ tbs.value.push(
2554
+ asn1.create(asn1.Class.CONTEXT_SPECIFIC, 1, true, [
2555
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.BITSTRING, false,
2556
+ // TODO: support arbitrary bit length ids
2557
+ String.fromCharCode(0x00) +
2558
+ cert.issuer.uniqueId
2559
+ )
2560
+ ])
2561
+ );
2562
+ }
2563
+ if(cert.subject.uniqueId) {
2564
+ // subjectUniqueID (optional)
2565
+ tbs.value.push(
2566
+ asn1.create(asn1.Class.CONTEXT_SPECIFIC, 2, true, [
2567
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.BITSTRING, false,
2568
+ // TODO: support arbitrary bit length ids
2569
+ String.fromCharCode(0x00) +
2570
+ cert.subject.uniqueId
2571
+ )
2572
+ ])
2573
+ );
2574
+ }
2575
+
2576
+ if(cert.extensions.length > 0) {
2577
+ // extensions (optional)
2578
+ tbs.value.push(pki.certificateExtensionsToAsn1(cert.extensions));
2579
+ }
2580
+
2581
+ return tbs;
2582
+ };
2583
+
2584
+ /**
2585
+ * Gets the ASN.1 CertificationRequestInfo part of a
2586
+ * PKCS#10 CertificationRequest.
2587
+ *
2588
+ * @param csr the certification request.
2589
+ *
2590
+ * @return the asn1 CertificationRequestInfo.
2591
+ */
2592
+ pki.getCertificationRequestInfo = function(csr) {
2593
+ // CertificationRequestInfo
2594
+ var cri = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
2595
+ // version
2596
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.INTEGER, false,
2597
+ asn1.integerToDer(csr.version).getBytes()),
2598
+ // subject
2599
+ _dnToAsn1(csr.subject),
2600
+ // SubjectPublicKeyInfo
2601
+ pki.publicKeyToAsn1(csr.publicKey),
2602
+ // attributes
2603
+ _CRIAttributesToAsn1(csr)
2604
+ ]);
2605
+
2606
+ return cri;
2607
+ };
2608
+
2609
+ /**
2610
+ * Converts a DistinguishedName (subject or issuer) to an ASN.1 object.
2611
+ *
2612
+ * @param dn the DistinguishedName.
2613
+ *
2614
+ * @return the asn1 representation of a DistinguishedName.
2615
+ */
2616
+ pki.distinguishedNameToAsn1 = function(dn) {
2617
+ return _dnToAsn1(dn);
2618
+ };
2619
+
2620
+ /**
2621
+ * Converts an X.509v3 RSA certificate to an ASN.1 object.
2622
+ *
2623
+ * @param cert the certificate.
2624
+ *
2625
+ * @return the asn1 representation of an X.509v3 RSA certificate.
2626
+ */
2627
+ pki.certificateToAsn1 = function(cert) {
2628
+ // prefer cached TBSCertificate over generating one
2629
+ var tbsCertificate = cert.tbsCertificate || pki.getTBSCertificate(cert);
2630
+
2631
+ // Certificate
2632
+ return asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
2633
+ // TBSCertificate
2634
+ tbsCertificate,
2635
+ // AlgorithmIdentifier (signature algorithm)
2636
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
2637
+ // algorithm
2638
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
2639
+ asn1.oidToDer(cert.signatureOid).getBytes()),
2640
+ // parameters
2641
+ _signatureParametersToAsn1(cert.signatureOid, cert.signatureParameters)
2642
+ ]),
2643
+ // SignatureValue
2644
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.BITSTRING, false,
2645
+ String.fromCharCode(0x00) + cert.signature)
2646
+ ]);
2647
+ };
2648
+
2649
+ /**
2650
+ * Converts X.509v3 certificate extensions to ASN.1.
2651
+ *
2652
+ * @param exts the extensions to convert.
2653
+ *
2654
+ * @return the extensions in ASN.1 format.
2655
+ */
2656
+ pki.certificateExtensionsToAsn1 = function(exts) {
2657
+ // create top-level extension container
2658
+ var rval = asn1.create(asn1.Class.CONTEXT_SPECIFIC, 3, true, []);
2659
+
2660
+ // create extension sequence (stores a sequence for each extension)
2661
+ var seq = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, []);
2662
+ rval.value.push(seq);
2663
+
2664
+ for(var i = 0; i < exts.length; ++i) {
2665
+ seq.value.push(pki.certificateExtensionToAsn1(exts[i]));
2666
+ }
2667
+
2668
+ return rval;
2669
+ };
2670
+
2671
+ /**
2672
+ * Converts a single certificate extension to ASN.1.
2673
+ *
2674
+ * @param ext the extension to convert.
2675
+ *
2676
+ * @return the extension in ASN.1 format.
2677
+ */
2678
+ pki.certificateExtensionToAsn1 = function(ext) {
2679
+ // create a sequence for each extension
2680
+ var extseq = asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, []);
2681
+
2682
+ // extnID (OID)
2683
+ extseq.value.push(asn1.create(
2684
+ asn1.Class.UNIVERSAL, asn1.Type.OID, false,
2685
+ asn1.oidToDer(ext.id).getBytes()));
2686
+
2687
+ // critical defaults to false
2688
+ if(ext.critical) {
2689
+ // critical BOOLEAN DEFAULT FALSE
2690
+ extseq.value.push(asn1.create(
2691
+ asn1.Class.UNIVERSAL, asn1.Type.BOOLEAN, false,
2692
+ String.fromCharCode(0xFF)));
2693
+ }
2694
+
2695
+ var value = ext.value;
2696
+ if(typeof ext.value !== 'string') {
2697
+ // value is asn.1
2698
+ value = asn1.toDer(value).getBytes();
2699
+ }
2700
+
2701
+ // extnValue (OCTET STRING)
2702
+ extseq.value.push(asn1.create(
2703
+ asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false, value));
2704
+
2705
+ return extseq;
2706
+ };
2707
+
2708
+ /**
2709
+ * Converts a PKCS#10 certification request to an ASN.1 object.
2710
+ *
2711
+ * @param csr the certification request.
2712
+ *
2713
+ * @return the asn1 representation of a certification request.
2714
+ */
2715
+ pki.certificationRequestToAsn1 = function(csr) {
2716
+ // prefer cached CertificationRequestInfo over generating one
2717
+ var cri = csr.certificationRequestInfo ||
2718
+ pki.getCertificationRequestInfo(csr);
2719
+
2720
+ // Certificate
2721
+ return asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
2722
+ // CertificationRequestInfo
2723
+ cri,
2724
+ // AlgorithmIdentifier (signature algorithm)
2725
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.SEQUENCE, true, [
2726
+ // algorithm
2727
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OID, false,
2728
+ asn1.oidToDer(csr.signatureOid).getBytes()),
2729
+ // parameters
2730
+ _signatureParametersToAsn1(csr.signatureOid, csr.signatureParameters)
2731
+ ]),
2732
+ // signature
2733
+ asn1.create(asn1.Class.UNIVERSAL, asn1.Type.BITSTRING, false,
2734
+ String.fromCharCode(0x00) + csr.signature)
2735
+ ]);
2736
+ };
2737
+
2738
+ /**
2739
+ * Creates a CA store.
2740
+ *
2741
+ * @param certs an optional array of certificate objects or PEM-formatted
2742
+ * certificate strings to add to the CA store.
2743
+ *
2744
+ * @return the CA store.
2745
+ */
2746
+ pki.createCaStore = function(certs) {
2747
+ // create CA store
2748
+ var caStore = {
2749
+ // stored certificates
2750
+ certs: {}
2751
+ };
2752
+
2753
+ /**
2754
+ * Gets the certificate that issued the passed certificate or its
2755
+ * 'parent'.
2756
+ *
2757
+ * @param cert the certificate to get the parent for.
2758
+ *
2759
+ * @return the parent certificate or null if none was found.
2760
+ */
2761
+ caStore.getIssuer = function(cert) {
2762
+ var rval = getBySubject(cert.issuer);
2763
+
2764
+ // see if there are multiple matches
2765
+ /*if(forge.util.isArray(rval)) {
2766
+ // TODO: resolve multiple matches by checking
2767
+ // authorityKey/subjectKey/issuerUniqueID/other identifiers, etc.
2768
+ // FIXME: or alternatively do authority key mapping
2769
+ // if possible (X.509v1 certs can't work?)
2770
+ throw new Error('Resolving multiple issuer matches not implemented yet.');
2771
+ }*/
2772
+
2773
+ return rval;
2774
+ };
2775
+
2776
+ /**
2777
+ * Adds a trusted certificate to the store.
2778
+ *
2779
+ * @param cert the certificate to add as a trusted certificate (either a
2780
+ * pki.certificate object or a PEM-formatted certificate).
2781
+ */
2782
+ caStore.addCertificate = function(cert) {
2783
+ // convert from pem if necessary
2784
+ if(typeof cert === 'string') {
2785
+ cert = forge.pki.certificateFromPem(cert);
2786
+ }
2787
+
2788
+ ensureSubjectHasHash(cert.subject);
2789
+
2790
+ if(!caStore.hasCertificate(cert)) { // avoid duplicate certificates in store
2791
+ if(cert.subject.hash in caStore.certs) {
2792
+ // subject hash already exists, append to array
2793
+ var tmp = caStore.certs[cert.subject.hash];
2794
+ if(!forge.util.isArray(tmp)) {
2795
+ tmp = [tmp];
2796
+ }
2797
+ tmp.push(cert);
2798
+ caStore.certs[cert.subject.hash] = tmp;
2799
+ } else {
2800
+ caStore.certs[cert.subject.hash] = cert;
2801
+ }
2802
+ }
2803
+ };
2804
+
2805
+ /**
2806
+ * Checks to see if the given certificate is in the store.
2807
+ *
2808
+ * @param cert the certificate to check (either a pki.certificate or a
2809
+ * PEM-formatted certificate).
2810
+ *
2811
+ * @return true if the certificate is in the store, false if not.
2812
+ */
2813
+ caStore.hasCertificate = function(cert) {
2814
+ // convert from pem if necessary
2815
+ if(typeof cert === 'string') {
2816
+ cert = forge.pki.certificateFromPem(cert);
2817
+ }
2818
+
2819
+ var match = getBySubject(cert.subject);
2820
+ if(!match) {
2821
+ return false;
2822
+ }
2823
+ if(!forge.util.isArray(match)) {
2824
+ match = [match];
2825
+ }
2826
+ // compare DER-encoding of certificates
2827
+ var der1 = asn1.toDer(pki.certificateToAsn1(cert)).getBytes();
2828
+ for(var i = 0; i < match.length; ++i) {
2829
+ var der2 = asn1.toDer(pki.certificateToAsn1(match[i])).getBytes();
2830
+ if(der1 === der2) {
2831
+ return true;
2832
+ }
2833
+ }
2834
+ return false;
2835
+ };
2836
+
2837
+ /**
2838
+ * Lists all of the certificates kept in the store.
2839
+ *
2840
+ * @return an array of all of the pki.certificate objects in the store.
2841
+ */
2842
+ caStore.listAllCertificates = function() {
2843
+ var certList = [];
2844
+
2845
+ for(var hash in caStore.certs) {
2846
+ if(caStore.certs.hasOwnProperty(hash)) {
2847
+ var value = caStore.certs[hash];
2848
+ if(!forge.util.isArray(value)) {
2849
+ certList.push(value);
2850
+ } else {
2851
+ for(var i = 0; i < value.length; ++i) {
2852
+ certList.push(value[i]);
2853
+ }
2854
+ }
2855
+ }
2856
+ }
2857
+
2858
+ return certList;
2859
+ };
2860
+
2861
+ /**
2862
+ * Removes a certificate from the store.
2863
+ *
2864
+ * @param cert the certificate to remove (either a pki.certificate or a
2865
+ * PEM-formatted certificate).
2866
+ *
2867
+ * @return the certificate that was removed or null if the certificate
2868
+ * wasn't in store.
2869
+ */
2870
+ caStore.removeCertificate = function(cert) {
2871
+ var result;
2872
+
2873
+ // convert from pem if necessary
2874
+ if(typeof cert === 'string') {
2875
+ cert = forge.pki.certificateFromPem(cert);
2876
+ }
2877
+ ensureSubjectHasHash(cert.subject);
2878
+ if(!caStore.hasCertificate(cert)) {
2879
+ return null;
2880
+ }
2881
+
2882
+ var match = getBySubject(cert.subject);
2883
+
2884
+ if(!forge.util.isArray(match)) {
2885
+ result = caStore.certs[cert.subject.hash];
2886
+ delete caStore.certs[cert.subject.hash];
2887
+ return result;
2888
+ }
2889
+
2890
+ // compare DER-encoding of certificates
2891
+ var der1 = asn1.toDer(pki.certificateToAsn1(cert)).getBytes();
2892
+ for(var i = 0; i < match.length; ++i) {
2893
+ var der2 = asn1.toDer(pki.certificateToAsn1(match[i])).getBytes();
2894
+ if(der1 === der2) {
2895
+ result = match[i];
2896
+ match.splice(i, 1);
2897
+ }
2898
+ }
2899
+ if(match.length === 0) {
2900
+ delete caStore.certs[cert.subject.hash];
2901
+ }
2902
+
2903
+ return result;
2904
+ };
2905
+
2906
+ function getBySubject(subject) {
2907
+ ensureSubjectHasHash(subject);
2908
+ return caStore.certs[subject.hash] || null;
2909
+ }
2910
+
2911
+ function ensureSubjectHasHash(subject) {
2912
+ // produce subject hash if it doesn't exist
2913
+ if(!subject.hash) {
2914
+ var md = forge.md.sha1.create();
2915
+ subject.attributes = pki.RDNAttributesAsArray(_dnToAsn1(subject), md);
2916
+ subject.hash = md.digest().toHex();
2917
+ }
2918
+ }
2919
+
2920
+ // auto-add passed in certs
2921
+ if(certs) {
2922
+ // parse PEM-formatted certificates as necessary
2923
+ for(var i = 0; i < certs.length; ++i) {
2924
+ var cert = certs[i];
2925
+ caStore.addCertificate(cert);
2926
+ }
2927
+ }
2928
+
2929
+ return caStore;
2930
+ };
2931
+
2932
+ /**
2933
+ * Certificate verification errors, based on TLS.
2934
+ */
2935
+ pki.certificateError = {
2936
+ bad_certificate: 'forge.pki.BadCertificate',
2937
+ unsupported_certificate: 'forge.pki.UnsupportedCertificate',
2938
+ certificate_revoked: 'forge.pki.CertificateRevoked',
2939
+ certificate_expired: 'forge.pki.CertificateExpired',
2940
+ certificate_unknown: 'forge.pki.CertificateUnknown',
2941
+ unknown_ca: 'forge.pki.UnknownCertificateAuthority'
2942
+ };
2943
+
2944
+ /**
2945
+ * Verifies a certificate chain against the given Certificate Authority store
2946
+ * with an optional custom verify callback.
2947
+ *
2948
+ * @param caStore a certificate store to verify against.
2949
+ * @param chain the certificate chain to verify, with the root or highest
2950
+ * authority at the end (an array of certificates).
2951
+ * @param options a callback to be called for every certificate in the chain or
2952
+ * an object with:
2953
+ * verify a callback to be called for every certificate in the
2954
+ * chain
2955
+ * validityCheckDate the date against which the certificate
2956
+ * validity period should be checked. Pass null to not check
2957
+ * the validity period. By default, the current date is used.
2958
+ *
2959
+ * The verify callback has the following signature:
2960
+ *
2961
+ * verified - Set to true if certificate was verified, otherwise the
2962
+ * pki.certificateError for why the certificate failed.
2963
+ * depth - The current index in the chain, where 0 is the end point's cert.
2964
+ * certs - The certificate chain, *NOTE* an empty chain indicates an anonymous
2965
+ * end point.
2966
+ *
2967
+ * The function returns true on success and on failure either the appropriate
2968
+ * pki.certificateError or an object with 'error' set to the appropriate
2969
+ * pki.certificateError and 'message' set to a custom error message.
2970
+ *
2971
+ * @return true if successful, error thrown if not.
2972
+ */
2973
+ pki.verifyCertificateChain = function(caStore, chain, options) {
2974
+ /* From: RFC3280 - Internet X.509 Public Key Infrastructure Certificate
2975
+ Section 6: Certification Path Validation
2976
+ See inline parentheticals related to this particular implementation.
2977
+
2978
+ The primary goal of path validation is to verify the binding between
2979
+ a subject distinguished name or a subject alternative name and subject
2980
+ public key, as represented in the end entity certificate, based on the
2981
+ public key of the trust anchor. This requires obtaining a sequence of
2982
+ certificates that support that binding. That sequence should be provided
2983
+ in the passed 'chain'. The trust anchor should be in the given CA
2984
+ store. The 'end entity' certificate is the certificate provided by the
2985
+ end point (typically a server) and is the first in the chain.
2986
+
2987
+ To meet this goal, the path validation process verifies, among other
2988
+ things, that a prospective certification path (a sequence of n
2989
+ certificates or a 'chain') satisfies the following conditions:
2990
+
2991
+ (a) for all x in {1, ..., n-1}, the subject of certificate x is
2992
+ the issuer of certificate x+1;
2993
+
2994
+ (b) certificate 1 is issued by the trust anchor;
2995
+
2996
+ (c) certificate n is the certificate to be validated; and
2997
+
2998
+ (d) for all x in {1, ..., n}, the certificate was valid at the
2999
+ time in question.
3000
+
3001
+ Note that here 'n' is index 0 in the chain and 1 is the last certificate
3002
+ in the chain and it must be signed by a certificate in the connection's
3003
+ CA store.
3004
+
3005
+ The path validation process also determines the set of certificate
3006
+ policies that are valid for this path, based on the certificate policies
3007
+ extension, policy mapping extension, policy constraints extension, and
3008
+ inhibit any-policy extension.
3009
+
3010
+ Note: Policy mapping extension not supported (Not Required).
3011
+
3012
+ Note: If the certificate has an unsupported critical extension, then it
3013
+ must be rejected.
3014
+
3015
+ Note: A certificate is self-issued if the DNs that appear in the subject
3016
+ and issuer fields are identical and are not empty.
3017
+
3018
+ The path validation algorithm assumes the following seven inputs are
3019
+ provided to the path processing logic. What this specific implementation
3020
+ will use is provided parenthetically:
3021
+
3022
+ (a) a prospective certification path of length n (the 'chain')
3023
+ (b) the current date/time: ('now').
3024
+ (c) user-initial-policy-set: A set of certificate policy identifiers
3025
+ naming the policies that are acceptable to the certificate user.
3026
+ The user-initial-policy-set contains the special value any-policy
3027
+ if the user is not concerned about certificate policy
3028
+ (Not implemented. Any policy is accepted).
3029
+ (d) trust anchor information, describing a CA that serves as a trust
3030
+ anchor for the certification path. The trust anchor information
3031
+ includes:
3032
+
3033
+ (1) the trusted issuer name,
3034
+ (2) the trusted public key algorithm,
3035
+ (3) the trusted public key, and
3036
+ (4) optionally, the trusted public key parameters associated
3037
+ with the public key.
3038
+
3039
+ (Trust anchors are provided via certificates in the CA store).
3040
+
3041
+ The trust anchor information may be provided to the path processing
3042
+ procedure in the form of a self-signed certificate. The trusted anchor
3043
+ information is trusted because it was delivered to the path processing
3044
+ procedure by some trustworthy out-of-band procedure. If the trusted
3045
+ public key algorithm requires parameters, then the parameters are
3046
+ provided along with the trusted public key (No parameters used in this
3047
+ implementation).
3048
+
3049
+ (e) initial-policy-mapping-inhibit, which indicates if policy mapping is
3050
+ allowed in the certification path.
3051
+ (Not implemented, no policy checking)
3052
+
3053
+ (f) initial-explicit-policy, which indicates if the path must be valid
3054
+ for at least one of the certificate policies in the user-initial-
3055
+ policy-set.
3056
+ (Not implemented, no policy checking)
3057
+
3058
+ (g) initial-any-policy-inhibit, which indicates whether the
3059
+ anyPolicy OID should be processed if it is included in a
3060
+ certificate.
3061
+ (Not implemented, so any policy is valid provided that it is
3062
+ not marked as critical) */
3063
+
3064
+ /* Basic Path Processing:
3065
+
3066
+ For each certificate in the 'chain', the following is checked:
3067
+
3068
+ 1. The certificate validity period includes the current time.
3069
+ 2. The certificate was signed by its parent (where the parent is either
3070
+ the next in the chain or from the CA store). Allow processing to
3071
+ continue to the next step if no parent is found but the certificate is
3072
+ in the CA store.
3073
+ 3. TODO: The certificate has not been revoked.
3074
+ 4. The certificate issuer name matches the parent's subject name.
3075
+ 5. TODO: If the certificate is self-issued and not the final certificate
3076
+ in the chain, skip this step, otherwise verify that the subject name
3077
+ is within one of the permitted subtrees of X.500 distinguished names
3078
+ and that each of the alternative names in the subjectAltName extension
3079
+ (critical or non-critical) is within one of the permitted subtrees for
3080
+ that name type.
3081
+ 6. TODO: If the certificate is self-issued and not the final certificate
3082
+ in the chain, skip this step, otherwise verify that the subject name
3083
+ is not within one of the excluded subtrees for X.500 distinguished
3084
+ names and none of the subjectAltName extension names are excluded for
3085
+ that name type.
3086
+ 7. The other steps in the algorithm for basic path processing involve
3087
+ handling the policy extension which is not presently supported in this
3088
+ implementation. Instead, if a critical policy extension is found, the
3089
+ certificate is rejected as not supported.
3090
+ 8. If the certificate is not the first or if its the only certificate in
3091
+ the chain (having no parent from the CA store or is self-signed) and it
3092
+ has a critical key usage extension, verify that the keyCertSign bit is
3093
+ set. If the key usage extension exists, verify that the basic
3094
+ constraints extension exists. If the basic constraints extension exists,
3095
+ verify that the cA flag is set. If pathLenConstraint is set, ensure that
3096
+ the number of certificates that precede in the chain (come earlier
3097
+ in the chain as implemented below), excluding the very first in the
3098
+ chain (typically the end-entity one), isn't greater than the
3099
+ pathLenConstraint. This constraint limits the number of intermediate
3100
+ CAs that may appear below a CA before only end-entity certificates
3101
+ may be issued. */
3102
+
3103
+ // if a verify callback is passed as the third parameter, package it within
3104
+ // the options object. This is to support a legacy function signature that
3105
+ // expected the verify callback as the third parameter.
3106
+ if(typeof options === 'function') {
3107
+ options = {verify: options};
3108
+ }
3109
+ options = options || {};
3110
+
3111
+ // copy cert chain references to another array to protect against changes
3112
+ // in verify callback
3113
+ chain = chain.slice(0);
3114
+ var certs = chain.slice(0);
3115
+
3116
+ var validityCheckDate = options.validityCheckDate;
3117
+ // if no validityCheckDate is specified, default to the current date. Make
3118
+ // sure to maintain the value null because it indicates that the validity
3119
+ // period should not be checked.
3120
+ if(typeof validityCheckDate === 'undefined') {
3121
+ validityCheckDate = new Date();
3122
+ }
3123
+
3124
+ // verify each cert in the chain using its parent, where the parent
3125
+ // is either the next in the chain or from the CA store
3126
+ var first = true;
3127
+ var error = null;
3128
+ var depth = 0;
3129
+ do {
3130
+ var cert = chain.shift();
3131
+ var parent = null;
3132
+ var selfSigned = false;
3133
+
3134
+ if(validityCheckDate) {
3135
+ // 1. check valid time
3136
+ if(validityCheckDate < cert.validity.notBefore ||
3137
+ validityCheckDate > cert.validity.notAfter) {
3138
+ error = {
3139
+ message: 'Certificate is not valid yet or has expired.',
3140
+ error: pki.certificateError.certificate_expired,
3141
+ notBefore: cert.validity.notBefore,
3142
+ notAfter: cert.validity.notAfter,
3143
+ // TODO: we might want to reconsider renaming 'now' to
3144
+ // 'validityCheckDate' should this API be changed in the future.
3145
+ now: validityCheckDate
3146
+ };
3147
+ }
3148
+ }
3149
+
3150
+ // 2. verify with parent from chain or CA store
3151
+ if(error === null) {
3152
+ parent = chain[0] || caStore.getIssuer(cert);
3153
+ if(parent === null) {
3154
+ // check for self-signed cert
3155
+ if(cert.isIssuer(cert)) {
3156
+ selfSigned = true;
3157
+ parent = cert;
3158
+ }
3159
+ }
3160
+
3161
+ if(parent) {
3162
+ // FIXME: current CA store implementation might have multiple
3163
+ // certificates where the issuer can't be determined from the
3164
+ // certificate (happens rarely with, eg: old certificates) so normalize
3165
+ // by always putting parents into an array
3166
+ // TODO: there's may be an extreme degenerate case currently uncovered
3167
+ // where an old intermediate certificate seems to have a matching parent
3168
+ // but none of the parents actually verify ... but the intermediate
3169
+ // is in the CA and it should pass this check; needs investigation
3170
+ var parents = parent;
3171
+ if(!forge.util.isArray(parents)) {
3172
+ parents = [parents];
3173
+ }
3174
+
3175
+ // try to verify with each possible parent (typically only one)
3176
+ var verified = false;
3177
+ while(!verified && parents.length > 0) {
3178
+ parent = parents.shift();
3179
+ try {
3180
+ verified = parent.verify(cert);
3181
+ } catch(ex) {
3182
+ // failure to verify, don't care why, try next one
3183
+ }
3184
+ }
3185
+
3186
+ if(!verified) {
3187
+ error = {
3188
+ message: 'Certificate signature is invalid.',
3189
+ error: pki.certificateError.bad_certificate
3190
+ };
3191
+ }
3192
+ }
3193
+
3194
+ if(error === null && (!parent || selfSigned) &&
3195
+ !caStore.hasCertificate(cert)) {
3196
+ // no parent issuer and certificate itself is not trusted
3197
+ error = {
3198
+ message: 'Certificate is not trusted.',
3199
+ error: pki.certificateError.unknown_ca
3200
+ };
3201
+ }
3202
+ }
3203
+
3204
+ // TODO: 3. check revoked
3205
+
3206
+ // 4. check for matching issuer/subject
3207
+ if(error === null && parent && !cert.isIssuer(parent)) {
3208
+ // parent is not issuer
3209
+ error = {
3210
+ message: 'Certificate issuer is invalid.',
3211
+ error: pki.certificateError.bad_certificate
3212
+ };
3213
+ }
3214
+
3215
+ // 5. TODO: check names with permitted names tree
3216
+
3217
+ // 6. TODO: check names against excluded names tree
3218
+
3219
+ // 7. check for unsupported critical extensions
3220
+ if(error === null) {
3221
+ // supported extensions
3222
+ var se = {
3223
+ keyUsage: true,
3224
+ basicConstraints: true
3225
+ };
3226
+ for(var i = 0; error === null && i < cert.extensions.length; ++i) {
3227
+ var ext = cert.extensions[i];
3228
+ if(ext.critical && !(ext.name in se)) {
3229
+ error = {
3230
+ message:
3231
+ 'Certificate has an unsupported critical extension.',
3232
+ error: pki.certificateError.unsupported_certificate
3233
+ };
3234
+ }
3235
+ }
3236
+ }
3237
+
3238
+ // 8. check for CA if cert is not first or is the only certificate
3239
+ // remaining in chain with no parent or is self-signed
3240
+ if(error === null &&
3241
+ (!first || (chain.length === 0 && (!parent || selfSigned)))) {
3242
+ // first check keyUsage extension and then basic constraints
3243
+ var bcExt = cert.getExtension('basicConstraints');
3244
+ var keyUsageExt = cert.getExtension('keyUsage');
3245
+ if(keyUsageExt !== null) {
3246
+ // keyCertSign must be true and there must be a basic
3247
+ // constraints extension
3248
+ if(!keyUsageExt.keyCertSign || bcExt === null) {
3249
+ // bad certificate
3250
+ error = {
3251
+ message:
3252
+ 'Certificate keyUsage or basicConstraints conflict ' +
3253
+ 'or indicate that the certificate is not a CA. ' +
3254
+ 'If the certificate is the only one in the chain or ' +
3255
+ 'isn\'t the first then the certificate must be a ' +
3256
+ 'valid CA.',
3257
+ error: pki.certificateError.bad_certificate
3258
+ };
3259
+ }
3260
+ }
3261
+ // basic constraints cA flag must be set
3262
+ if(error === null && bcExt !== null && !bcExt.cA) {
3263
+ // bad certificate
3264
+ error = {
3265
+ message:
3266
+ 'Certificate basicConstraints indicates the certificate ' +
3267
+ 'is not a CA.',
3268
+ error: pki.certificateError.bad_certificate
3269
+ };
3270
+ }
3271
+ // if error is not null and keyUsage is available, then we know it
3272
+ // has keyCertSign and there is a basic constraints extension too,
3273
+ // which means we can check pathLenConstraint (if it exists)
3274
+ if(error === null && keyUsageExt !== null &&
3275
+ 'pathLenConstraint' in bcExt) {
3276
+ // pathLen is the maximum # of intermediate CA certs that can be
3277
+ // found between the current certificate and the end-entity (depth 0)
3278
+ // certificate; this number does not include the end-entity (depth 0,
3279
+ // last in the chain) even if it happens to be a CA certificate itself
3280
+ var pathLen = depth - 1;
3281
+ if(pathLen > bcExt.pathLenConstraint) {
3282
+ // pathLenConstraint violated, bad certificate
3283
+ error = {
3284
+ message:
3285
+ 'Certificate basicConstraints pathLenConstraint violated.',
3286
+ error: pki.certificateError.bad_certificate
3287
+ };
3288
+ }
3289
+ }
3290
+ }
3291
+
3292
+ // call application callback
3293
+ var vfd = (error === null) ? true : error.error;
3294
+ var ret = options.verify ? options.verify(vfd, depth, certs) : vfd;
3295
+ if(ret === true) {
3296
+ // clear any set error
3297
+ error = null;
3298
+ } else {
3299
+ // if passed basic tests, set default message and alert
3300
+ if(vfd === true) {
3301
+ error = {
3302
+ message: 'The application rejected the certificate.',
3303
+ error: pki.certificateError.bad_certificate
3304
+ };
3305
+ }
3306
+
3307
+ // check for custom error info
3308
+ if(ret || ret === 0) {
3309
+ // set custom message and error
3310
+ if(typeof ret === 'object' && !forge.util.isArray(ret)) {
3311
+ if(ret.message) {
3312
+ error.message = ret.message;
3313
+ }
3314
+ if(ret.error) {
3315
+ error.error = ret.error;
3316
+ }
3317
+ } else if(typeof ret === 'string') {
3318
+ // set custom error
3319
+ error.error = ret;
3320
+ }
3321
+ }
3322
+
3323
+ // throw error
3324
+ throw error;
3325
+ }
3326
+
3327
+ // no longer first cert in chain
3328
+ first = false;
3329
+ ++depth;
3330
+ } while(chain.length > 0);
3331
+
3332
+ return true;
3333
+ };