ai 1.0.0 → 2.0.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 (340) hide show
  1. package/LICENSE +10 -24
  2. package/dist/ai-stream.d.ts +18 -0
  3. package/dist/ai-stream.js +132 -0
  4. package/dist/ai-stream.mjs +13 -0
  5. package/dist/anthropic-stream.d.ts +5 -0
  6. package/dist/anthropic-stream.js +133 -0
  7. package/dist/anthropic-stream.mjs +8 -0
  8. package/dist/chunk-265FSSO4.mjs +91 -0
  9. package/dist/chunk-2L3ZO4UM.mjs +45 -0
  10. package/dist/chunk-EZJ7FC5E.mjs +33 -0
  11. package/dist/chunk-JGDC3BXD.mjs +22 -0
  12. package/dist/chunk-NK2CVBLI.mjs +38 -0
  13. package/dist/chunk-PEYAHBDF.mjs +43 -0
  14. package/dist/chunk-TJMME6CL.mjs +24 -0
  15. package/dist/huggingface-stream.d.ts +5 -0
  16. package/dist/huggingface-stream.js +121 -0
  17. package/dist/huggingface-stream.mjs +8 -0
  18. package/dist/index.d.ts +131 -0
  19. package/dist/index.js +278 -0
  20. package/dist/index.mjs +35 -0
  21. package/dist/index.test.d.ts +2 -0
  22. package/dist/index.test.js +12 -0
  23. package/dist/index.test.mjs +10 -0
  24. package/dist/langchain-stream.d.ts +12 -0
  25. package/dist/langchain-stream.js +102 -0
  26. package/dist/langchain-stream.mjs +8 -0
  27. package/dist/openai-stream.d.ts +5 -0
  28. package/dist/openai-stream.js +144 -0
  29. package/dist/openai-stream.mjs +8 -0
  30. package/dist/streaming-text-response.d.ts +17 -0
  31. package/dist/streaming-text-response.js +75 -0
  32. package/dist/streaming-text-response.mjs +9 -0
  33. package/package.json +78 -29
  34. package/react/dist/chunk-5PP6W52J.mjs +202 -0
  35. package/react/dist/chunk-6EH3SWMP.mjs +55 -0
  36. package/react/dist/chunk-PW6HSU2N.mjs +154 -0
  37. package/react/dist/index.d.ts +3 -0
  38. package/react/dist/index.js +424 -0
  39. package/react/dist/index.mjs +12 -0
  40. package/react/dist/types-f862f74a.d.ts +123 -0
  41. package/react/dist/use-chat.d.ts +42 -0
  42. package/react/dist/use-chat.js +276 -0
  43. package/react/dist/use-chat.mjs +8 -0
  44. package/react/dist/use-completion.d.ts +47 -0
  45. package/react/dist/use-completion.js +229 -0
  46. package/react/dist/use-completion.mjs +8 -0
  47. package/svelte/dist/chunk-6USBQIV6.mjs +177 -0
  48. package/svelte/dist/chunk-BQ64GHZ3.mjs +136 -0
  49. package/svelte/dist/chunk-CENOSGDG.mjs +493 -0
  50. package/svelte/dist/index.d.ts +4 -0
  51. package/svelte/dist/index.js +808 -0
  52. package/svelte/dist/index.mjs +11 -0
  53. package/svelte/dist/types-f862f74a.d.ts +123 -0
  54. package/svelte/dist/use-chat.d.ts +39 -0
  55. package/svelte/dist/use-chat.js +680 -0
  56. package/svelte/dist/use-chat.mjs +7 -0
  57. package/svelte/dist/use-completion.d.ts +38 -0
  58. package/svelte/dist/use-completion.js +640 -0
  59. package/svelte/dist/use-completion.mjs +7 -0
  60. package/.npmignore +0 -15
  61. package/.travis.yml +0 -4
  62. package/README.md +0 -21
  63. package/bin/ai.js +0 -22
  64. package/index.js +0 -32
  65. package/node_modules/request/.npmignore +0 -2
  66. package/node_modules/request/.travis.yml +0 -12
  67. package/node_modules/request/CHANGELOG.md +0 -954
  68. package/node_modules/request/LICENSE +0 -55
  69. package/node_modules/request/README.md +0 -421
  70. package/node_modules/request/index.js +0 -166
  71. package/node_modules/request/lib/cookies.js +0 -40
  72. package/node_modules/request/lib/copy.js +0 -8
  73. package/node_modules/request/lib/debug.js +0 -7
  74. package/node_modules/request/lib/getSafe.js +0 -34
  75. package/node_modules/request/lib/optional.js +0 -5
  76. package/node_modules/request/node_modules/aws-sign2/LICENSE +0 -55
  77. package/node_modules/request/node_modules/aws-sign2/README.md +0 -4
  78. package/node_modules/request/node_modules/aws-sign2/index.js +0 -202
  79. package/node_modules/request/node_modules/aws-sign2/package.json +0 -47
  80. package/node_modules/request/node_modules/forever-agent/LICENSE +0 -55
  81. package/node_modules/request/node_modules/forever-agent/README.md +0 -4
  82. package/node_modules/request/node_modules/forever-agent/index.js +0 -119
  83. package/node_modules/request/node_modules/forever-agent/package.json +0 -46
  84. package/node_modules/request/node_modules/form-data/License +0 -19
  85. package/node_modules/request/node_modules/form-data/Readme.md +0 -175
  86. package/node_modules/request/node_modules/form-data/lib/form_data.js +0 -351
  87. package/node_modules/request/node_modules/form-data/node_modules/async/.travis.yml +0 -3
  88. package/node_modules/request/node_modules/form-data/node_modules/async/LICENSE +0 -19
  89. package/node_modules/request/node_modules/form-data/node_modules/async/README.md +0 -1646
  90. package/node_modules/request/node_modules/form-data/node_modules/async/component.json +0 -11
  91. package/node_modules/request/node_modules/form-data/node_modules/async/lib/async.js +0 -1123
  92. package/node_modules/request/node_modules/form-data/node_modules/async/package.json +0 -60
  93. package/node_modules/request/node_modules/form-data/node_modules/combined-stream/License +0 -19
  94. package/node_modules/request/node_modules/form-data/node_modules/combined-stream/Readme.md +0 -132
  95. package/node_modules/request/node_modules/form-data/node_modules/combined-stream/lib/combined_stream.js +0 -186
  96. package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/.npmignore +0 -2
  97. package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/License +0 -19
  98. package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/Makefile +0 -7
  99. package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/Readme.md +0 -154
  100. package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/lib/delayed_stream.js +0 -99
  101. package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/package.json +0 -42
  102. package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/common.js +0 -6
  103. package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-http-upload.js +0 -38
  104. package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-stream-auto-pause.js +0 -21
  105. package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-stream-pause.js +0 -14
  106. package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-stream.js +0 -48
  107. package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-handle-source-errors.js +0 -15
  108. package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-max-data-size.js +0 -18
  109. package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-pipe-resumes.js +0 -13
  110. package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-proxy-readable.js +0 -13
  111. package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/run.js +0 -7
  112. package/node_modules/request/node_modules/form-data/node_modules/combined-stream/package.json +0 -61
  113. package/node_modules/request/node_modules/form-data/node_modules/mime/LICENSE +0 -19
  114. package/node_modules/request/node_modules/form-data/node_modules/mime/README.md +0 -66
  115. package/node_modules/request/node_modules/form-data/node_modules/mime/mime.js +0 -114
  116. package/node_modules/request/node_modules/form-data/node_modules/mime/package.json +0 -59
  117. package/node_modules/request/node_modules/form-data/node_modules/mime/test.js +0 -84
  118. package/node_modules/request/node_modules/form-data/node_modules/mime/types/mime.types +0 -1588
  119. package/node_modules/request/node_modules/form-data/node_modules/mime/types/node.types +0 -77
  120. package/node_modules/request/node_modules/form-data/package.json +0 -80
  121. package/node_modules/request/node_modules/hawk/.npmignore +0 -18
  122. package/node_modules/request/node_modules/hawk/.travis.yml +0 -5
  123. package/node_modules/request/node_modules/hawk/LICENSE +0 -24
  124. package/node_modules/request/node_modules/hawk/Makefile +0 -10
  125. package/node_modules/request/node_modules/hawk/README.md +0 -625
  126. package/node_modules/request/node_modules/hawk/example/usage.js +0 -78
  127. package/node_modules/request/node_modules/hawk/images/hawk.png +0 -0
  128. package/node_modules/request/node_modules/hawk/images/logo.png +0 -0
  129. package/node_modules/request/node_modules/hawk/index.js +0 -1
  130. package/node_modules/request/node_modules/hawk/lib/browser.js +0 -507
  131. package/node_modules/request/node_modules/hawk/lib/client.js +0 -371
  132. package/node_modules/request/node_modules/hawk/lib/crypto.js +0 -118
  133. package/node_modules/request/node_modules/hawk/lib/index.js +0 -15
  134. package/node_modules/request/node_modules/hawk/lib/server.js +0 -523
  135. package/node_modules/request/node_modules/hawk/lib/utils.js +0 -183
  136. package/node_modules/request/node_modules/hawk/node_modules/boom/.npmignore +0 -18
  137. package/node_modules/request/node_modules/hawk/node_modules/boom/.travis.yml +0 -5
  138. package/node_modules/request/node_modules/hawk/node_modules/boom/LICENSE +0 -24
  139. package/node_modules/request/node_modules/hawk/node_modules/boom/Makefile +0 -11
  140. package/node_modules/request/node_modules/hawk/node_modules/boom/README.md +0 -6
  141. package/node_modules/request/node_modules/hawk/node_modules/boom/images/boom.png +0 -0
  142. package/node_modules/request/node_modules/hawk/node_modules/boom/index.js +0 -1
  143. package/node_modules/request/node_modules/hawk/node_modules/boom/lib/index.js +0 -207
  144. package/node_modules/request/node_modules/hawk/node_modules/boom/package.json +0 -64
  145. package/node_modules/request/node_modules/hawk/node_modules/boom/test/index.js +0 -245
  146. package/node_modules/request/node_modules/hawk/node_modules/cryptiles/.npmignore +0 -18
  147. package/node_modules/request/node_modules/hawk/node_modules/cryptiles/.travis.yml +0 -5
  148. package/node_modules/request/node_modules/hawk/node_modules/cryptiles/LICENSE +0 -24
  149. package/node_modules/request/node_modules/hawk/node_modules/cryptiles/Makefile +0 -11
  150. package/node_modules/request/node_modules/hawk/node_modules/cryptiles/README.md +0 -6
  151. package/node_modules/request/node_modules/hawk/node_modules/cryptiles/index.js +0 -1
  152. package/node_modules/request/node_modules/hawk/node_modules/cryptiles/lib/index.js +0 -68
  153. package/node_modules/request/node_modules/hawk/node_modules/cryptiles/package.json +0 -65
  154. package/node_modules/request/node_modules/hawk/node_modules/cryptiles/test/index.js +0 -101
  155. package/node_modules/request/node_modules/hawk/node_modules/hoek/.npmignore +0 -18
  156. package/node_modules/request/node_modules/hawk/node_modules/hoek/.travis.yml +0 -5
  157. package/node_modules/request/node_modules/hawk/node_modules/hoek/LICENSE +0 -33
  158. package/node_modules/request/node_modules/hawk/node_modules/hoek/Makefile +0 -10
  159. package/node_modules/request/node_modules/hawk/node_modules/hoek/README.md +0 -436
  160. package/node_modules/request/node_modules/hawk/node_modules/hoek/images/hoek.png +0 -0
  161. package/node_modules/request/node_modules/hawk/node_modules/hoek/index.js +0 -1
  162. package/node_modules/request/node_modules/hawk/node_modules/hoek/lib/escape.js +0 -132
  163. package/node_modules/request/node_modules/hawk/node_modules/hoek/lib/index.js +0 -585
  164. package/node_modules/request/node_modules/hawk/node_modules/hoek/package.json +0 -70
  165. package/node_modules/request/node_modules/hawk/node_modules/hoek/test/escaper.js +0 -86
  166. package/node_modules/request/node_modules/hawk/node_modules/hoek/test/index.js +0 -1078
  167. package/node_modules/request/node_modules/hawk/node_modules/hoek/test/modules/test1.js +0 -1
  168. package/node_modules/request/node_modules/hawk/node_modules/hoek/test/modules/test2.js +0 -1
  169. package/node_modules/request/node_modules/hawk/node_modules/hoek/test/modules/test3.js +0 -1
  170. package/node_modules/request/node_modules/hawk/node_modules/sntp/.npmignore +0 -18
  171. package/node_modules/request/node_modules/hawk/node_modules/sntp/.travis.yml +0 -5
  172. package/node_modules/request/node_modules/hawk/node_modules/sntp/LICENSE +0 -24
  173. package/node_modules/request/node_modules/hawk/node_modules/sntp/Makefile +0 -11
  174. package/node_modules/request/node_modules/hawk/node_modules/sntp/README.md +0 -68
  175. package/node_modules/request/node_modules/hawk/node_modules/sntp/examples/offset.js +0 -16
  176. package/node_modules/request/node_modules/hawk/node_modules/sntp/examples/time.js +0 -25
  177. package/node_modules/request/node_modules/hawk/node_modules/sntp/index.js +0 -1
  178. package/node_modules/request/node_modules/hawk/node_modules/sntp/lib/index.js +0 -409
  179. package/node_modules/request/node_modules/hawk/node_modules/sntp/package.json +0 -65
  180. package/node_modules/request/node_modules/hawk/node_modules/sntp/test/index.js +0 -359
  181. package/node_modules/request/node_modules/hawk/package.json +0 -70
  182. package/node_modules/request/node_modules/hawk/test/browser.js +0 -817
  183. package/node_modules/request/node_modules/hawk/test/client.js +0 -206
  184. package/node_modules/request/node_modules/hawk/test/crypto.js +0 -86
  185. package/node_modules/request/node_modules/hawk/test/index.js +0 -316
  186. package/node_modules/request/node_modules/hawk/test/message.js +0 -246
  187. package/node_modules/request/node_modules/hawk/test/readme.js +0 -98
  188. package/node_modules/request/node_modules/hawk/test/server.js +0 -686
  189. package/node_modules/request/node_modules/hawk/test/uri.js +0 -456
  190. package/node_modules/request/node_modules/hawk/test/utils.js +0 -120
  191. package/node_modules/request/node_modules/http-signature/.dir-locals.el +0 -6
  192. package/node_modules/request/node_modules/http-signature/.npmignore +0 -7
  193. package/node_modules/request/node_modules/http-signature/LICENSE +0 -18
  194. package/node_modules/request/node_modules/http-signature/README.md +0 -75
  195. package/node_modules/request/node_modules/http-signature/http_signing.md +0 -296
  196. package/node_modules/request/node_modules/http-signature/lib/index.js +0 -25
  197. package/node_modules/request/node_modules/http-signature/lib/parser.js +0 -304
  198. package/node_modules/request/node_modules/http-signature/lib/signer.js +0 -179
  199. package/node_modules/request/node_modules/http-signature/lib/util.js +0 -249
  200. package/node_modules/request/node_modules/http-signature/lib/verify.js +0 -42
  201. package/node_modules/request/node_modules/http-signature/node_modules/asn1/.npmignore +0 -2
  202. package/node_modules/request/node_modules/http-signature/node_modules/asn1/LICENSE +0 -19
  203. package/node_modules/request/node_modules/http-signature/node_modules/asn1/README.md +0 -50
  204. package/node_modules/request/node_modules/http-signature/node_modules/asn1/lib/ber/errors.js +0 -13
  205. package/node_modules/request/node_modules/http-signature/node_modules/asn1/lib/ber/index.js +0 -27
  206. package/node_modules/request/node_modules/http-signature/node_modules/asn1/lib/ber/reader.js +0 -267
  207. package/node_modules/request/node_modules/http-signature/node_modules/asn1/lib/ber/types.js +0 -36
  208. package/node_modules/request/node_modules/http-signature/node_modules/asn1/lib/ber/writer.js +0 -317
  209. package/node_modules/request/node_modules/http-signature/node_modules/asn1/lib/index.js +0 -20
  210. package/node_modules/request/node_modules/http-signature/node_modules/asn1/package.json +0 -63
  211. package/node_modules/request/node_modules/http-signature/node_modules/asn1/tst/ber/reader.test.js +0 -172
  212. package/node_modules/request/node_modules/http-signature/node_modules/asn1/tst/ber/writer.test.js +0 -296
  213. package/node_modules/request/node_modules/http-signature/node_modules/assert-plus/README.md +0 -126
  214. package/node_modules/request/node_modules/http-signature/node_modules/assert-plus/assert.js +0 -196
  215. package/node_modules/request/node_modules/http-signature/node_modules/assert-plus/package.json +0 -38
  216. package/node_modules/request/node_modules/http-signature/node_modules/ctype/CHANGELOG +0 -71
  217. package/node_modules/request/node_modules/http-signature/node_modules/ctype/LICENSE +0 -24
  218. package/node_modules/request/node_modules/http-signature/node_modules/ctype/README +0 -82
  219. package/node_modules/request/node_modules/http-signature/node_modules/ctype/README.old +0 -298
  220. package/node_modules/request/node_modules/http-signature/node_modules/ctype/ctf.js +0 -245
  221. package/node_modules/request/node_modules/http-signature/node_modules/ctype/ctio.js +0 -1485
  222. package/node_modules/request/node_modules/http-signature/node_modules/ctype/ctype.js +0 -944
  223. package/node_modules/request/node_modules/http-signature/node_modules/ctype/man/man3ctype/ctio.3ctype +0 -241
  224. package/node_modules/request/node_modules/http-signature/node_modules/ctype/package.json +0 -36
  225. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tools/jsl.conf +0 -129
  226. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tools/jsstyle +0 -839
  227. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/float.json +0 -13
  228. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/int.json +0 -13
  229. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/psinfo.json +0 -104
  230. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/struct.json +0 -19
  231. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/tst.fail.js +0 -39
  232. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/tst.float.js +0 -14
  233. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/tst.int.js +0 -14
  234. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/tst.psinfo.js +0 -17
  235. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/tst.struct.js +0 -18
  236. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/tst.typedef.js +0 -15
  237. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/typedef.json +0 -14
  238. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctio/float/tst.rfloat.js +0 -767
  239. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctio/float/tst.wfloat.js +0 -753
  240. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctio/int/tst.64.js +0 -638
  241. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctio/int/tst.rint.js +0 -101
  242. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctio/int/tst.wbounds.js +0 -53
  243. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctio/int/tst.wint.js +0 -92
  244. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctio/uint/tst.64.js +0 -451
  245. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctio/uint/tst.roundtrip.js +0 -81
  246. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctio/uint/tst.ruint.js +0 -95
  247. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctio/uint/tst.wuint.js +0 -156
  248. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctype/tst.basicr.js +0 -50
  249. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctype/tst.basicw.js +0 -44
  250. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctype/tst.char.js +0 -42
  251. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctype/tst.endian.js +0 -45
  252. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctype/tst.oldwrite.js +0 -28
  253. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctype/tst.readSize.js +0 -128
  254. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctype/tst.structw.js +0 -28
  255. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctype/tst.writeStruct.js +0 -31
  256. package/node_modules/request/node_modules/http-signature/package.json +0 -54
  257. package/node_modules/request/node_modules/json-stringify-safe/LICENSE +0 -27
  258. package/node_modules/request/node_modules/json-stringify-safe/README.md +0 -49
  259. package/node_modules/request/node_modules/json-stringify-safe/package.json +0 -51
  260. package/node_modules/request/node_modules/json-stringify-safe/stringify.js +0 -39
  261. package/node_modules/request/node_modules/json-stringify-safe/test.js +0 -128
  262. package/node_modules/request/node_modules/mime-types/.npmignore +0 -14
  263. package/node_modules/request/node_modules/mime-types/.travis.yml +0 -12
  264. package/node_modules/request/node_modules/mime-types/LICENSE +0 -22
  265. package/node_modules/request/node_modules/mime-types/Makefile +0 -9
  266. package/node_modules/request/node_modules/mime-types/README.md +0 -101
  267. package/node_modules/request/node_modules/mime-types/SOURCES.md +0 -17
  268. package/node_modules/request/node_modules/mime-types/component.json +0 -16
  269. package/node_modules/request/node_modules/mime-types/lib/custom.json +0 -27
  270. package/node_modules/request/node_modules/mime-types/lib/index.js +0 -75
  271. package/node_modules/request/node_modules/mime-types/lib/mime.json +0 -3317
  272. package/node_modules/request/node_modules/mime-types/lib/node.json +0 -55
  273. package/node_modules/request/node_modules/mime-types/package.json +0 -69
  274. package/node_modules/request/node_modules/node-uuid/.npmignore +0 -2
  275. package/node_modules/request/node_modules/node-uuid/LICENSE.md +0 -2
  276. package/node_modules/request/node_modules/node-uuid/README.md +0 -207
  277. package/node_modules/request/node_modules/node-uuid/benchmark/README.md +0 -53
  278. package/node_modules/request/node_modules/node-uuid/benchmark/bench.gnu +0 -174
  279. package/node_modules/request/node_modules/node-uuid/benchmark/bench.sh +0 -34
  280. package/node_modules/request/node_modules/node-uuid/benchmark/benchmark-native.c +0 -34
  281. package/node_modules/request/node_modules/node-uuid/benchmark/benchmark.js +0 -84
  282. package/node_modules/request/node_modules/node-uuid/component.json +0 -18
  283. package/node_modules/request/node_modules/node-uuid/package.json +0 -54
  284. package/node_modules/request/node_modules/node-uuid/test/compare_v1.js +0 -63
  285. package/node_modules/request/node_modules/node-uuid/test/test.html +0 -17
  286. package/node_modules/request/node_modules/node-uuid/test/test.js +0 -228
  287. package/node_modules/request/node_modules/node-uuid/uuid.js +0 -245
  288. package/node_modules/request/node_modules/oauth-sign/LICENSE +0 -55
  289. package/node_modules/request/node_modules/oauth-sign/README.md +0 -4
  290. package/node_modules/request/node_modules/oauth-sign/index.js +0 -43
  291. package/node_modules/request/node_modules/oauth-sign/package.json +0 -49
  292. package/node_modules/request/node_modules/oauth-sign/test.js +0 -49
  293. package/node_modules/request/node_modules/qs/.jshintignore +0 -1
  294. package/node_modules/request/node_modules/qs/.jshintrc +0 -10
  295. package/node_modules/request/node_modules/qs/.npmignore +0 -18
  296. package/node_modules/request/node_modules/qs/.travis.yml +0 -4
  297. package/node_modules/request/node_modules/qs/LICENSE +0 -28
  298. package/node_modules/request/node_modules/qs/Makefile +0 -8
  299. package/node_modules/request/node_modules/qs/Readme.md +0 -120
  300. package/node_modules/request/node_modules/qs/index.js +0 -1
  301. package/node_modules/request/node_modules/qs/lib/index.js +0 -15
  302. package/node_modules/request/node_modules/qs/lib/parse.js +0 -151
  303. package/node_modules/request/node_modules/qs/lib/stringify.js +0 -52
  304. package/node_modules/request/node_modules/qs/lib/utils.js +0 -131
  305. package/node_modules/request/node_modules/qs/package.json +0 -61
  306. package/node_modules/request/node_modules/qs/test/parse.js +0 -236
  307. package/node_modules/request/node_modules/qs/test/stringify.js +0 -123
  308. package/node_modules/request/node_modules/stringstream/.npmignore +0 -15
  309. package/node_modules/request/node_modules/stringstream/.travis.yml +0 -4
  310. package/node_modules/request/node_modules/stringstream/LICENSE.txt +0 -4
  311. package/node_modules/request/node_modules/stringstream/README.md +0 -38
  312. package/node_modules/request/node_modules/stringstream/example.js +0 -27
  313. package/node_modules/request/node_modules/stringstream/package.json +0 -48
  314. package/node_modules/request/node_modules/stringstream/stringstream.js +0 -102
  315. package/node_modules/request/node_modules/tough-cookie/.jshintrc +0 -70
  316. package/node_modules/request/node_modules/tough-cookie/.npmignore +0 -3
  317. package/node_modules/request/node_modules/tough-cookie/.travis.yml +0 -8
  318. package/node_modules/request/node_modules/tough-cookie/LICENSE +0 -78
  319. package/node_modules/request/node_modules/tough-cookie/README.md +0 -412
  320. package/node_modules/request/node_modules/tough-cookie/generate-pubsuffix.js +0 -239
  321. package/node_modules/request/node_modules/tough-cookie/lib/cookie.js +0 -1107
  322. package/node_modules/request/node_modules/tough-cookie/lib/memstore.js +0 -123
  323. package/node_modules/request/node_modules/tough-cookie/lib/pubsuffix.js +0 -69
  324. package/node_modules/request/node_modules/tough-cookie/lib/store.js +0 -37
  325. package/node_modules/request/node_modules/tough-cookie/node_modules/punycode/LICENSE-MIT.txt +0 -20
  326. package/node_modules/request/node_modules/tough-cookie/node_modules/punycode/README.md +0 -176
  327. package/node_modules/request/node_modules/tough-cookie/node_modules/punycode/package.json +0 -87
  328. package/node_modules/request/node_modules/tough-cookie/node_modules/punycode/punycode.js +0 -528
  329. package/node_modules/request/node_modules/tough-cookie/package.json +0 -67
  330. package/node_modules/request/node_modules/tough-cookie/public-suffix.txt +0 -5229
  331. package/node_modules/request/node_modules/tough-cookie/test.js +0 -1625
  332. package/node_modules/request/node_modules/tunnel-agent/.jshintrc +0 -5
  333. package/node_modules/request/node_modules/tunnel-agent/LICENSE +0 -55
  334. package/node_modules/request/node_modules/tunnel-agent/README.md +0 -4
  335. package/node_modules/request/node_modules/tunnel-agent/index.js +0 -236
  336. package/node_modules/request/node_modules/tunnel-agent/package.json +0 -46
  337. package/node_modules/request/package.json +0 -77
  338. package/node_modules/request/request.js +0 -1428
  339. package/test/fixtures/github-response.json +0 -1367
  340. package/test/index.js +0 -55
@@ -1,55 +0,0 @@
1
- Apache License
2
-
3
- Version 2.0, January 2004
4
-
5
- http://www.apache.org/licenses/
6
-
7
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
8
-
9
- 1. Definitions.
10
-
11
- "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
12
-
13
- "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
14
-
15
- "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
16
-
17
- "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
18
-
19
- "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
20
-
21
- "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
22
-
23
- "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
24
-
25
- "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
26
-
27
- "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
28
-
29
- "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
30
-
31
- 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
32
-
33
- 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
34
-
35
- 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
36
-
37
- You must give any other recipients of the Work or Derivative Works a copy of this License; and
38
-
39
- You must cause any modified files to carry prominent notices stating that You changed the files; and
40
-
41
- You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
42
-
43
- If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
44
-
45
- 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
46
-
47
- 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
48
-
49
- 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
50
-
51
- 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
52
-
53
- 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
54
-
55
- END OF TERMS AND CONDITIONS
@@ -1,421 +0,0 @@
1
- # Request — Simplified HTTP client
2
-
3
- [![NPM](https://nodei.co/npm/request.png)](https://nodei.co/npm/request/)
4
-
5
- ## Super simple to use
6
-
7
- Request is designed to be the simplest way possible to make http calls. It supports HTTPS and follows redirects by default.
8
-
9
- ```javascript
10
- var request = require('request');
11
- request('http://www.google.com', function (error, response, body) {
12
- if (!error && response.statusCode == 200) {
13
- console.log(body) // Print the google web page.
14
- }
15
- })
16
- ```
17
-
18
- ## Streaming
19
-
20
- You can stream any response to a file stream.
21
-
22
- ```javascript
23
- request('http://google.com/doodle.png').pipe(fs.createWriteStream('doodle.png'))
24
- ```
25
-
26
- You can also stream a file to a PUT or POST request. This method will also check the file extension against a mapping of file extensions to content-types (in this case `application/json`) and use the proper `content-type` in the PUT request (if the headers don’t already provide one).
27
-
28
- ```javascript
29
- fs.createReadStream('file.json').pipe(request.put('http://mysite.com/obj.json'))
30
- ```
31
-
32
- Request can also `pipe` to itself. When doing so, `content-type` and `content-length` are preserved in the PUT headers.
33
-
34
- ```javascript
35
- request.get('http://google.com/img.png').pipe(request.put('http://mysite.com/img.png'))
36
- ```
37
-
38
- Now let’s get fancy.
39
-
40
- ```javascript
41
- http.createServer(function (req, resp) {
42
- if (req.url === '/doodle.png') {
43
- if (req.method === 'PUT') {
44
- req.pipe(request.put('http://mysite.com/doodle.png'))
45
- } else if (req.method === 'GET' || req.method === 'HEAD') {
46
- request.get('http://mysite.com/doodle.png').pipe(resp)
47
- }
48
- }
49
- })
50
- ```
51
-
52
- You can also `pipe()` from `http.ServerRequest` instances, as well as to `http.ServerResponse` instances. The HTTP method, headers, and entity-body data will be sent. Which means that, if you don't really care about security, you can do:
53
-
54
- ```javascript
55
- http.createServer(function (req, resp) {
56
- if (req.url === '/doodle.png') {
57
- var x = request('http://mysite.com/doodle.png')
58
- req.pipe(x)
59
- x.pipe(resp)
60
- }
61
- })
62
- ```
63
-
64
- And since `pipe()` returns the destination stream in ≥ Node 0.5.x you can do one line proxying. :)
65
-
66
- ```javascript
67
- req.pipe(request('http://mysite.com/doodle.png')).pipe(resp)
68
- ```
69
-
70
- Also, none of this new functionality conflicts with requests previous features, it just expands them.
71
-
72
- ```javascript
73
- var r = request.defaults({'proxy':'http://localproxy.com'})
74
-
75
- http.createServer(function (req, resp) {
76
- if (req.url === '/doodle.png') {
77
- r.get('http://google.com/doodle.png').pipe(resp)
78
- }
79
- })
80
- ```
81
-
82
- You can still use intermediate proxies, the requests will still follow HTTP forwards, etc.
83
-
84
- ## UNIX Socket
85
-
86
- `request` supports the `unix://` protocol for all requests. The path is assumed to be absolute to the root of the host file system.
87
-
88
- HTTP paths are extracted from the supplied URL by testing each level of the full URL against net.connect for a socket response.
89
-
90
- Thus the following request will GET `/httppath` from the HTTP server listening on `/tmp/unix.socket`
91
-
92
- ```javascript
93
- request.get('unix://tmp/unix.socket/httppath')
94
- ```
95
-
96
- ## Forms
97
-
98
- `request` supports `application/x-www-form-urlencoded` and `multipart/form-data` form uploads. For `multipart/related` refer to the `multipart` API.
99
-
100
- URL-encoded forms are simple.
101
-
102
- ```javascript
103
- request.post('http://service.com/upload', {form:{key:'value'}})
104
- // or
105
- request.post('http://service.com/upload').form({key:'value'})
106
- ```
107
-
108
- For `multipart/form-data` we use the [form-data](https://github.com/felixge/node-form-data) library by [@felixge](https://github.com/felixge). You don’t need to worry about piping the form object or setting the headers, `request` will handle that for you.
109
-
110
- ```javascript
111
- var r = request.post('http://service.com/upload', function optionalCallback (err, httpResponse, body) {
112
- if (err) {
113
- return console.error('upload failed:', err);
114
- }
115
- console.log('Upload successful! Server responded with:', body);
116
- })
117
- var form = r.form()
118
- form.append('my_field', 'my_value')
119
- form.append('my_buffer', new Buffer([1, 2, 3]))
120
- form.append('my_file', fs.createReadStream(path.join(__dirname, 'doodle.png')))
121
- form.append('remote_file', request('http://google.com/doodle.png'))
122
-
123
- // Just like always, `r` is a writable stream, and can be used as such (you have until nextTick to pipe it, etc.)
124
- // Alternatively, you can provide a callback (that's what this example does — see `optionalCallback` above).
125
- ```
126
-
127
- ## HTTP Authentication
128
-
129
- ```javascript
130
- request.get('http://some.server.com/').auth('username', 'password', false);
131
- // or
132
- request.get('http://some.server.com/', {
133
- 'auth': {
134
- 'user': 'username',
135
- 'pass': 'password',
136
- 'sendImmediately': false
137
- }
138
- });
139
- // or
140
- request.get('http://some.server.com/').auth(null, null, true, 'bearerToken');
141
- // or
142
- request.get('http://some.server.com/', {
143
- 'auth': {
144
- 'bearer': 'bearerToken'
145
- }
146
- });
147
- ```
148
-
149
- If passed as an option, `auth` should be a hash containing values `user` || `username`, `pass` || `password`, and `sendImmediately` (optional). The method form takes parameters `auth(username, password, sendImmediately)`.
150
-
151
- `sendImmediately` defaults to `true`, which causes a basic authentication header to be sent. If `sendImmediately` is `false`, then `request` will retry with a proper authentication header after receiving a `401` response from the server (which must contain a `WWW-Authenticate` header indicating the required authentication method).
152
-
153
- Note that you can also use for basic authentication a trick using the URL itself, as specified in [RFC 1738](http://www.ietf.org/rfc/rfc1738.txt).
154
- Simply pass the `user:password` before the host with an `@` sign.
155
-
156
- ```javascript
157
- var username = 'username',
158
- password = 'password',
159
- url = 'http://' + username + ':' + password + '@some.server.com';
160
-
161
- request({url: url}, function (error, response, body) {
162
- // Do more stuff with 'body' here
163
- });
164
- ```
165
-
166
- Digest authentication is supported, but it only works with `sendImmediately` set to `false`; otherwise `request` will send basic authentication on the initial request, which will probably cause the request to fail.
167
-
168
- Bearer authentication is supported, and is activated when the `bearer` value is available. The value may be either a `String` or a `Function` returning a `String`. Using a function to supply the bearer token is particularly useful if used in conjuction with `defaults` to allow a single function to supply the last known token at the time or sending a request or to compute one on the fly.
169
-
170
- ## OAuth Signing
171
-
172
- ```javascript
173
- // Twitter OAuth
174
- var qs = require('querystring')
175
- , oauth =
176
- { callback: 'http://mysite.com/callback/'
177
- , consumer_key: CONSUMER_KEY
178
- , consumer_secret: CONSUMER_SECRET
179
- }
180
- , url = 'https://api.twitter.com/oauth/request_token'
181
- ;
182
- request.post({url:url, oauth:oauth}, function (e, r, body) {
183
- // Ideally, you would take the body in the response
184
- // and construct a URL that a user clicks on (like a sign in button).
185
- // The verifier is only available in the response after a user has
186
- // verified with twitter that they are authorizing your app.
187
- var access_token = qs.parse(body)
188
- , oauth =
189
- { consumer_key: CONSUMER_KEY
190
- , consumer_secret: CONSUMER_SECRET
191
- , token: access_token.oauth_token
192
- , verifier: access_token.oauth_verifier
193
- }
194
- , url = 'https://api.twitter.com/oauth/access_token'
195
- ;
196
- request.post({url:url, oauth:oauth}, function (e, r, body) {
197
- var perm_token = qs.parse(body)
198
- , oauth =
199
- { consumer_key: CONSUMER_KEY
200
- , consumer_secret: CONSUMER_SECRET
201
- , token: perm_token.oauth_token
202
- , token_secret: perm_token.oauth_token_secret
203
- }
204
- , url = 'https://api.twitter.com/1.1/users/show.json?'
205
- , params =
206
- { screen_name: perm_token.screen_name
207
- , user_id: perm_token.user_id
208
- }
209
- ;
210
- url += qs.stringify(params)
211
- request.get({url:url, oauth:oauth, json:true}, function (e, r, user) {
212
- console.log(user)
213
- })
214
- })
215
- })
216
- ```
217
-
218
- ### Custom HTTP Headers
219
-
220
- HTTP Headers, such as `User-Agent`, can be set in the `options` object.
221
- In the example below, we call the github API to find out the number
222
- of stars and forks for the request repository. This requires a
223
- custom `User-Agent` header as well as https.
224
-
225
- ```javascript
226
- var request = require('request');
227
-
228
- var options = {
229
- url: 'https://api.github.com/repos/mikeal/request',
230
- headers: {
231
- 'User-Agent': 'request'
232
- }
233
- };
234
-
235
- function callback(error, response, body) {
236
- if (!error && response.statusCode == 200) {
237
- var info = JSON.parse(body);
238
- console.log(info.stargazers_count + " Stars");
239
- console.log(info.forks_count + " Forks");
240
- }
241
- }
242
-
243
- request(options, callback);
244
- ```
245
-
246
- ### request(options, callback)
247
-
248
- The first argument can be either a `url` or an `options` object. The only required option is `uri`; all others are optional.
249
-
250
- * `uri` || `url` - fully qualified uri or a parsed url object from `url.parse()`
251
- * `qs` - object containing querystring values to be appended to the `uri`
252
- * `method` - http method (default: `"GET"`)
253
- * `headers` - http headers (default: `{}`)
254
- * `body` - entity body for PATCH, POST and PUT requests. Must be a `Buffer` or `String`.
255
- * `form` - when passed an object or a querystring, this sets `body` to a querystring representation of value, and adds `Content-type: application/x-www-form-urlencoded; charset=utf-8` header. When passed no options, a `FormData` instance is returned (and is piped to request).
256
- * `auth` - A hash containing values `user` || `username`, `pass` || `password`, and `sendImmediately` (optional). See documentation above.
257
- * `json` - sets `body` but to JSON representation of value and adds `Content-type: application/json` header. Additionally, parses the response body as JSON.
258
- * `multipart` - (experimental) array of objects which contains their own headers and `body` attribute. Sends `multipart/related` request. See example below.
259
- * `followRedirect` - follow HTTP 3xx responses as redirects (default: `true`)
260
- * `followAllRedirects` - follow non-GET HTTP 3xx responses as redirects (default: `false`)
261
- * `maxRedirects` - the maximum number of redirects to follow (default: `10`)
262
- * `encoding` - Encoding to be used on `setEncoding` of response data. If `null`, the `body` is returned as a `Buffer`.
263
- * `pool` - A hash object containing the agents for these requests. If omitted, the request will use the global pool (which is set to node's default `maxSockets`)
264
- * `pool.maxSockets` - Integer containing the maximum amount of sockets in the pool.
265
- * `timeout` - Integer containing the number of milliseconds to wait for a request to respond before aborting the request
266
- * `proxy` - An HTTP proxy to be used. Supports proxy Auth with Basic Auth, identical to support for the `url` parameter (by embedding the auth info in the `uri`)
267
- * `oauth` - Options for OAuth HMAC-SHA1 signing. See documentation above.
268
- * `hawk` - Options for [Hawk signing](https://github.com/hueniverse/hawk). The `credentials` key must contain the necessary signing info, [see hawk docs for details](https://github.com/hueniverse/hawk#usage-example).
269
- * `strictSSL` - If `true`, requires SSL certificates be valid. **Note:** to use your own certificate authority, you need to specify an agent that was created with that CA as an option.
270
- * `jar` - If `true` and `tough-cookie` is installed, remember cookies for future use (or define your custom cookie jar; see examples section)
271
- * `aws` - `object` containing AWS signing information. Should have the properties `key`, `secret`. Also requires the property `bucket`, unless you’re specifying your `bucket` as part of the path, or the request doesn’t use a bucket (i.e. GET Services)
272
- * `httpSignature` - Options for the [HTTP Signature Scheme](https://github.com/joyent/node-http-signature/blob/master/http_signing.md) using [Joyent's library](https://github.com/joyent/node-http-signature). The `keyId` and `key` properties must be specified. See the docs for other options.
273
- * `localAddress` - Local interface to bind for network connections.
274
- * `gzip` - If `true`, add an `Accept-Encoding` header to request compressed content encodings from the server (if not already present) and decode supported content encodings in the response.
275
-
276
-
277
- The callback argument gets 3 arguments:
278
-
279
- 1. An `error` when applicable (usually from [`http.ClientRequest`](http://nodejs.org/api/http.html#http_class_http_clientrequest) object)
280
- 2. An [`http.IncomingMessage`](http://nodejs.org/api/http.html#http_http_incomingmessage) object
281
- 3. The third is the `response` body (`String` or `Buffer`, or JSON object if the `json` option is supplied)
282
-
283
- ## Convenience methods
284
-
285
- There are also shorthand methods for different HTTP METHODs and some other conveniences.
286
-
287
- ### request.defaults(options)
288
-
289
- This method returns a wrapper around the normal request API that defaults to whatever options you pass in to it.
290
-
291
- ### request.put
292
-
293
- Same as `request()`, but defaults to `method: "PUT"`.
294
-
295
- ```javascript
296
- request.put(url)
297
- ```
298
-
299
- ### request.patch
300
-
301
- Same as `request()`, but defaults to `method: "PATCH"`.
302
-
303
- ```javascript
304
- request.patch(url)
305
- ```
306
-
307
- ### request.post
308
-
309
- Same as `request()`, but defaults to `method: "POST"`.
310
-
311
- ```javascript
312
- request.post(url)
313
- ```
314
-
315
- ### request.head
316
-
317
- Same as request() but defaults to `method: "HEAD"`.
318
-
319
- ```javascript
320
- request.head(url)
321
- ```
322
-
323
- ### request.del
324
-
325
- Same as `request()`, but defaults to `method: "DELETE"`.
326
-
327
- ```javascript
328
- request.del(url)
329
- ```
330
-
331
- ### request.get
332
-
333
- Same as `request()` (for uniformity).
334
-
335
- ```javascript
336
- request.get(url)
337
- ```
338
- ### request.cookie
339
-
340
- Function that creates a new cookie.
341
-
342
- ```javascript
343
- request.cookie('cookie_string_here')
344
- ```
345
- ### request.jar
346
-
347
- Function that creates a new cookie jar.
348
-
349
- ```javascript
350
- request.jar()
351
- ```
352
-
353
-
354
- ## Examples:
355
-
356
- ```javascript
357
- var request = require('request')
358
- , rand = Math.floor(Math.random()*100000000).toString()
359
- ;
360
- request(
361
- { method: 'PUT'
362
- , uri: 'http://mikeal.iriscouch.com/testjs/' + rand
363
- , multipart:
364
- [ { 'content-type': 'application/json'
365
- , body: JSON.stringify({foo: 'bar', _attachments: {'message.txt': {follows: true, length: 18, 'content_type': 'text/plain' }}})
366
- }
367
- , { body: 'I am an attachment' }
368
- ]
369
- }
370
- , function (error, response, body) {
371
- if(response.statusCode == 201){
372
- console.log('document saved as: http://mikeal.iriscouch.com/testjs/'+ rand)
373
- } else {
374
- console.log('error: '+ response.statusCode)
375
- console.log(body)
376
- }
377
- }
378
- )
379
- ```
380
-
381
- Cookies are disabled by default (else, they would be used in subsequent requests). To enable cookies, set `jar` to `true` (either in `defaults` or `options`) and install `tough-cookie`.
382
-
383
- ```javascript
384
- var request = request.defaults({jar: true})
385
- request('http://www.google.com', function () {
386
- request('http://images.google.com')
387
- })
388
- ```
389
-
390
- To use a custom cookie jar (instead of `request`’s global cookie jar), set `jar` to an instance of `request.jar()` (either in `defaults` or `options`)
391
-
392
- ```javascript
393
- var j = request.jar()
394
- var request = request.defaults({jar:j})
395
- request('http://www.google.com', function () {
396
- request('http://images.google.com')
397
- })
398
- ```
399
-
400
- OR
401
-
402
- ```javascript
403
- // `npm install --save tough-cookie` before this works
404
- var j = request.jar()
405
- var cookie = request.cookie('your_cookie_here')
406
- j.setCookie(cookie, uri);
407
- request({url: 'http://www.google.com', jar: j}, function () {
408
- request('http://images.google.com')
409
- })
410
- ```
411
-
412
- To inspect your cookie jar after a request
413
-
414
- ```javascript
415
- var j = request.jar()
416
- request({url: 'http://www.google.com', jar: j}, function () {
417
- var cookie_string = j.getCookieString(uri); // "key1=value1; key2=value2; ..."
418
- var cookies = j.getCookies(uri);
419
- // [{key: 'key1', value: 'value1', domain: "www.google.com", ...}, ...]
420
- })
421
- ```
@@ -1,166 +0,0 @@
1
- // Copyright 2010-2012 Mikeal Rogers
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License");
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
14
-
15
- var cookies = require('./lib/cookies')
16
- , copy = require('./lib/copy')
17
- , Request = require('./request')
18
- , util = require('util')
19
- ;
20
-
21
-
22
-
23
- // organize params for patch, post, put, head, del
24
- function initParams(uri, options, callback) {
25
- var opts;
26
- if ((typeof options === 'function') && !callback) callback = options
27
- if (options && typeof options === 'object') {
28
- opts = util._extend({}, options);
29
- opts.uri = uri
30
- } else if (typeof uri === 'string') {
31
- opts = {uri:uri}
32
- } else {
33
- opts = util._extend({}, uri);
34
- uri = opts.uri
35
- }
36
-
37
- return { uri: uri, options: opts, callback: callback }
38
- }
39
-
40
- function request (uri, options, callback) {
41
- var opts;
42
- if (typeof uri === 'undefined') throw new Error('undefined is not a valid uri or options object.')
43
- if ((typeof options === 'function') && !callback) callback = options
44
- if (options && typeof options === 'object') {
45
- opts = util._extend({}, options);
46
- opts.uri = uri
47
- } else if (typeof uri === 'string') {
48
- opts = {uri:uri}
49
- } else {
50
- opts = util._extend({}, uri);
51
- }
52
-
53
- if (callback) opts.callback = callback
54
- var r = new Request(opts)
55
- return r
56
- }
57
-
58
- module.exports = request
59
-
60
- request.Request = Request;
61
-
62
- request.debug = process.env.NODE_DEBUG && /request/.test(process.env.NODE_DEBUG)
63
-
64
- request.initParams = initParams
65
-
66
- request.defaults = function (options, requester) {
67
- var def = function (method) {
68
- var d = function (uri, opts, callback) {
69
- var params = initParams(uri, opts, callback)
70
- Object.keys(options).forEach(function (key) {
71
- if (key !== 'headers' && params.options[key] === undefined) {
72
- params.options[key] = options[key]
73
- }
74
- })
75
- if (options.headers) {
76
- var headers = {}
77
- util._extend(headers, options.headers)
78
- util._extend(headers, params.options.headers)
79
- params.options.headers = headers
80
- }
81
- if(typeof requester === 'function') {
82
- if(method === request) {
83
- method = requester
84
- } else {
85
- params.options._requester = requester
86
- }
87
- }
88
- return method(params.options, params.callback)
89
- }
90
- return d
91
- }
92
- var de = def(request)
93
- de.get = def(request.get)
94
- de.patch = def(request.patch)
95
- de.post = def(request.post)
96
- de.put = def(request.put)
97
- de.head = def(request.head)
98
- de.del = def(request.del)
99
- de.cookie = def(request.cookie)
100
- de.jar = request.jar
101
- return de
102
- }
103
-
104
- function requester(params) {
105
- if(typeof params.options._requester === 'function') {
106
- return params.options._requester
107
- } else {
108
- return request
109
- }
110
- }
111
-
112
- request.forever = function (agentOptions, optionsArg) {
113
- var options = {}
114
- if (optionsArg) {
115
- for (var option in optionsArg) {
116
- options[option] = optionsArg[option]
117
- }
118
- }
119
- if (agentOptions) options.agentOptions = agentOptions
120
- options.forever = true
121
- return request.defaults(options)
122
- }
123
-
124
- request.get = function (uri, options, callback) {
125
- var params = initParams(uri, options, callback)
126
- params.options.method = 'GET'
127
- return requester(params)(params.uri || null, params.options, params.callback)
128
- }
129
- request.post = function (uri, options, callback) {
130
- var params = initParams(uri, options, callback)
131
- params.options.method = 'POST'
132
- return requester(params)(params.uri || null, params.options, params.callback)
133
- }
134
- request.put = function (uri, options, callback) {
135
- var params = initParams(uri, options, callback)
136
- params.options.method = 'PUT'
137
- return requester(params)(params.uri || null, params.options, params.callback)
138
- }
139
- request.patch = function (uri, options, callback) {
140
- var params = initParams(uri, options, callback)
141
- params.options.method = 'PATCH'
142
- return requester(params)(params.uri || null, params.options, params.callback)
143
- }
144
- request.head = function (uri, options, callback) {
145
- var params = initParams(uri, options, callback)
146
- params.options.method = 'HEAD'
147
- if (params.options.body ||
148
- params.options.requestBodyStream ||
149
- (params.options.json && typeof params.options.json !== 'boolean') ||
150
- params.options.multipart) {
151
- throw new Error("HTTP HEAD requests MUST NOT include a request body.")
152
- }
153
-
154
- return requester(params)(params.uri || null, params.options, params.callback)
155
- }
156
- request.del = function (uri, options, callback) {
157
- var params = initParams(uri, options, callback)
158
- params.options.method = 'DELETE'
159
- return requester(params)(params.uri || null, params.options, params.callback)
160
- }
161
- request.jar = function () {
162
- return cookies.jar();
163
- }
164
- request.cookie = function (str) {
165
- return cookies.parse(str);
166
- }
@@ -1,40 +0,0 @@
1
- var optional = require('./optional')
2
- , tough = optional('tough-cookie')
3
- , Cookie = tough && tough.Cookie
4
- , CookieJar = tough && tough.CookieJar
5
- ;
6
-
7
- exports.parse = function(str) {
8
- if (str && str.uri) str = str.uri
9
- if (typeof str !== 'string') throw new Error("The cookie function only accepts STRING as param")
10
- if (!Cookie) {
11
- return null;
12
- }
13
- return Cookie.parse(str)
14
- };
15
-
16
- // Adapt the sometimes-Async api of tough.CookieJar to our requirements
17
- function RequestJar() {
18
- this._jar = new CookieJar();
19
- }
20
- RequestJar.prototype.setCookie = function(cookieOrStr, uri, options) {
21
- return this._jar.setCookieSync(cookieOrStr, uri, options || {});
22
- };
23
- RequestJar.prototype.getCookieString = function(uri) {
24
- return this._jar.getCookieStringSync(uri);
25
- };
26
- RequestJar.prototype.getCookies = function(uri) {
27
- return this._jar.getCookiesSync(uri);
28
- };
29
-
30
- exports.jar = function() {
31
- if (!CookieJar) {
32
- // tough-cookie not loaded, return a stub object:
33
- return {
34
- setCookie: function(){},
35
- getCookieString: function(){},
36
- getCookies: function(){}
37
- };
38
- }
39
- return new RequestJar();
40
- };