aboutsummaryrefslogtreecommitdiffstats
path: root/node_modules/simple-get
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/simple-get')
-rw-r--r--node_modules/simple-get/.github/dependabot.yml15
-rw-r--r--node_modules/simple-get/.github/workflows/ci.yml23
-rw-r--r--node_modules/simple-get/LICENSE20
-rw-r--r--node_modules/simple-get/README.md333
-rw-r--r--node_modules/simple-get/index.js108
-rw-r--r--node_modules/simple-get/package.json67
6 files changed, 566 insertions, 0 deletions
diff --git a/node_modules/simple-get/.github/dependabot.yml b/node_modules/simple-get/.github/dependabot.yml
new file mode 100644
index 0000000..0221fbc
--- /dev/null
+++ b/node_modules/simple-get/.github/dependabot.yml
@@ -0,0 +1,15 @@
+version: 2
+updates:
+ - package-ecosystem: npm
+ directory: /
+ schedule:
+ interval: daily
+ labels:
+ - dependency
+ versioning-strategy: increase-if-necessary
+ - package-ecosystem: github-actions
+ directory: /
+ schedule:
+ interval: daily
+ labels:
+ - dependency
diff --git a/node_modules/simple-get/.github/workflows/ci.yml b/node_modules/simple-get/.github/workflows/ci.yml
new file mode 100644
index 0000000..822d21c
--- /dev/null
+++ b/node_modules/simple-get/.github/workflows/ci.yml
@@ -0,0 +1,23 @@
+name: ci
+'on':
+ - push
+ - pull_request
+jobs:
+ test:
+ name: Node ${{ matrix.node }} / ${{ matrix.os }}
+ runs-on: ${{ matrix.os }}
+ strategy:
+ fail-fast: false
+ matrix:
+ os:
+ - ubuntu-latest
+ node:
+ - '14'
+ steps:
+ - uses: actions/checkout@v2
+ - uses: actions/setup-node@v2
+ with:
+ node-version: ${{ matrix.node }}
+ - run: npm install
+ - run: npm run build --if-present
+ - run: npm test
diff --git a/node_modules/simple-get/LICENSE b/node_modules/simple-get/LICENSE
new file mode 100644
index 0000000..c7e6852
--- /dev/null
+++ b/node_modules/simple-get/LICENSE
@@ -0,0 +1,20 @@
+The MIT License (MIT)
+
+Copyright (c) Feross Aboukhadijeh
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/node_modules/simple-get/README.md b/node_modules/simple-get/README.md
new file mode 100644
index 0000000..63c6a6b
--- /dev/null
+++ b/node_modules/simple-get/README.md
@@ -0,0 +1,333 @@
+# simple-get [![ci][ci-image]][ci-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url] [![javascript style guide][standard-image]][standard-url]
+
+[ci-image]: https://img.shields.io/github/workflow/status/feross/simple-get/ci/master
+[ci-url]: https://github.com/feross/simple-get/actions
+[npm-image]: https://img.shields.io/npm/v/simple-get.svg
+[npm-url]: https://npmjs.org/package/simple-get
+[downloads-image]: https://img.shields.io/npm/dm/simple-get.svg
+[downloads-url]: https://npmjs.org/package/simple-get
+[standard-image]: https://img.shields.io/badge/code_style-standard-brightgreen.svg
+[standard-url]: https://standardjs.com
+
+### Simplest way to make http get requests
+
+## features
+
+This module is the lightest possible wrapper on top of node.js `http`, but supporting these essential features:
+
+- follows redirects
+- automatically handles gzip/deflate responses
+- supports HTTPS
+- supports specifying a timeout
+- supports convenience `url` key so there's no need to use `url.parse` on the url when specifying options
+- composes well with npm packages for features like cookies, proxies, form data, & OAuth
+
+All this in < 100 lines of code.
+
+## install
+
+```
+npm install simple-get
+```
+
+## usage
+
+Note, all these examples also work in the browser with [browserify](http://browserify.org/).
+
+### simple GET request
+
+Doesn't get easier than this:
+
+```js
+const get = require('simple-get')
+
+get('http://example.com', function (err, res) {
+ if (err) throw err
+ console.log(res.statusCode) // 200
+ res.pipe(process.stdout) // `res` is a stream
+})
+```
+
+### even simpler GET request
+
+If you just want the data, and don't want to deal with streams:
+
+```js
+const get = require('simple-get')
+
+get.concat('http://example.com', function (err, res, data) {
+ if (err) throw err
+ console.log(res.statusCode) // 200
+ console.log(data) // Buffer('this is the server response')
+})
+```
+
+### POST, PUT, PATCH, HEAD, DELETE support
+
+For `POST`, call `get.post` or use option `{ method: 'POST' }`.
+
+```js
+const get = require('simple-get')
+
+const opts = {
+ url: 'http://example.com',
+ body: 'this is the POST body'
+}
+get.post(opts, function (err, res) {
+ if (err) throw err
+ res.pipe(process.stdout) // `res` is a stream
+})
+```
+
+#### A more complex example:
+
+```js
+const get = require('simple-get')
+
+get({
+ url: 'http://example.com',
+ method: 'POST',
+ body: 'this is the POST body',
+
+ // simple-get accepts all options that node.js `http` accepts
+ // See: http://nodejs.org/api/http.html#http_http_request_options_callback
+ headers: {
+ 'user-agent': 'my cool app'
+ }
+}, function (err, res) {
+ if (err) throw err
+
+ // All properties/methods from http.IncomingResponse are available,
+ // even if a gunzip/inflate transform stream was returned.
+ // See: http://nodejs.org/api/http.html#http_http_incomingmessage
+ res.setTimeout(10000)
+ console.log(res.headers)
+
+ res.on('data', function (chunk) {
+ // `chunk` is the decoded response, after it's been gunzipped or inflated
+ // (if applicable)
+ console.log('got a chunk of the response: ' + chunk)
+ }))
+
+})
+```
+
+### JSON
+
+You can serialize/deserialize request and response with JSON:
+
+```js
+const get = require('simple-get')
+
+const opts = {
+ method: 'POST',
+ url: 'http://example.com',
+ body: {
+ key: 'value'
+ },
+ json: true
+}
+get.concat(opts, function (err, res, data) {
+ if (err) throw err
+ console.log(data.key) // `data` is an object
+})
+```
+
+### Timeout
+
+You can set a timeout (in milliseconds) on the request with the `timeout` option.
+If the request takes longer than `timeout` to complete, then the entire request
+will fail with an `Error`.
+
+```js
+const get = require('simple-get')
+
+const opts = {
+ url: 'http://example.com',
+ timeout: 2000 // 2 second timeout
+}
+
+get(opts, function (err, res) {})
+```
+
+### One Quick Tip
+
+It's a good idea to set the `'user-agent'` header so the provider can more easily
+see how their resource is used.
+
+```js
+const get = require('simple-get')
+const pkg = require('./package.json')
+
+get('http://example.com', {
+ headers: {
+ 'user-agent': `my-module/${pkg.version} (https://github.com/username/my-module)`
+ }
+})
+```
+
+### Proxies
+
+You can use the [`tunnel`](https://github.com/koichik/node-tunnel) module with the
+`agent` option to work with proxies:
+
+```js
+const get = require('simple-get')
+const tunnel = require('tunnel')
+
+const opts = {
+ url: 'http://example.com',
+ agent: tunnel.httpOverHttp({
+ proxy: {
+ host: 'localhost'
+ }
+ })
+}
+
+get(opts, function (err, res) {})
+```
+
+### Cookies
+
+You can use the [`cookie`](https://github.com/jshttp/cookie) module to include
+cookies in a request:
+
+```js
+const get = require('simple-get')
+const cookie = require('cookie')
+
+const opts = {
+ url: 'http://example.com',
+ headers: {
+ cookie: cookie.serialize('foo', 'bar')
+ }
+}
+
+get(opts, function (err, res) {})
+```
+
+### Form data
+
+You can use the [`form-data`](https://github.com/form-data/form-data) module to
+create POST request with form data:
+
+```js
+const fs = require('fs')
+const get = require('simple-get')
+const FormData = require('form-data')
+const form = new FormData()
+
+form.append('my_file', fs.createReadStream('/foo/bar.jpg'))
+
+const opts = {
+ url: 'http://example.com',
+ body: form
+}
+
+get.post(opts, function (err, res) {})
+```
+
+#### Or, include `application/x-www-form-urlencoded` form data manually:
+
+```js
+const get = require('simple-get')
+
+const opts = {
+ url: 'http://example.com',
+ form: {
+ key: 'value'
+ }
+}
+get.post(opts, function (err, res) {})
+```
+
+### Specifically disallowing redirects
+
+```js
+const get = require('simple-get')
+
+const opts = {
+ url: 'http://example.com/will-redirect-elsewhere',
+ followRedirects: false
+}
+// res.statusCode will be 301, no error thrown
+get(opts, function (err, res) {})
+```
+
+### Basic Auth
+
+```js
+const user = 'someuser'
+const pass = 'pa$$word'
+const encodedAuth = Buffer.from(`${user}:${pass}`).toString('base64')
+
+get('http://example.com', {
+ headers: {
+ authorization: `Basic ${encodedAuth}`
+ }
+})
+```
+
+### OAuth
+
+You can use the [`oauth-1.0a`](https://github.com/ddo/oauth-1.0a) module to create
+a signed OAuth request:
+
+```js
+const get = require('simple-get')
+const crypto = require('crypto')
+const OAuth = require('oauth-1.0a')
+
+const oauth = OAuth({
+ consumer: {
+ key: process.env.CONSUMER_KEY,
+ secret: process.env.CONSUMER_SECRET
+ },
+ signature_method: 'HMAC-SHA1',
+ hash_function: (baseString, key) => crypto.createHmac('sha1', key).update(baseString).digest('base64')
+})
+
+const token = {
+ key: process.env.ACCESS_TOKEN,
+ secret: process.env.ACCESS_TOKEN_SECRET
+}
+
+const url = 'https://api.twitter.com/1.1/statuses/home_timeline.json'
+
+const opts = {
+ url: url,
+ headers: oauth.toHeader(oauth.authorize({url, method: 'GET'}, token)),
+ json: true
+}
+
+get(opts, function (err, res) {})
+```
+
+### Throttle requests
+
+You can use [limiter](https://github.com/jhurliman/node-rate-limiter) to throttle requests. This is useful when calling an API that is rate limited.
+
+```js
+const simpleGet = require('simple-get')
+const RateLimiter = require('limiter').RateLimiter
+const limiter = new RateLimiter(1, 'second')
+
+const get = (opts, cb) => limiter.removeTokens(1, () => simpleGet(opts, cb))
+get.concat = (opts, cb) => limiter.removeTokens(1, () => simpleGet.concat(opts, cb))
+
+var opts = {
+ url: 'http://example.com'
+}
+
+get.concat(opts, processResult)
+get.concat(opts, processResult)
+
+function processResult (err, res, data) {
+ if (err) throw err
+ console.log(data.toString())
+}
+```
+
+## license
+
+MIT. Copyright (c) [Feross Aboukhadijeh](http://feross.org).
diff --git a/node_modules/simple-get/index.js b/node_modules/simple-get/index.js
new file mode 100644
index 0000000..80e52e8
--- /dev/null
+++ b/node_modules/simple-get/index.js
@@ -0,0 +1,108 @@
+/*! simple-get. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
+module.exports = simpleGet
+
+const concat = require('simple-concat')
+const decompressResponse = require('decompress-response') // excluded from browser build
+const http = require('http')
+const https = require('https')
+const once = require('once')
+const querystring = require('querystring')
+const url = require('url')
+
+const isStream = o => o !== null && typeof o === 'object' && typeof o.pipe === 'function'
+
+function simpleGet (opts, cb) {
+ opts = Object.assign({ maxRedirects: 10 }, typeof opts === 'string' ? { url: opts } : opts)
+ cb = once(cb)
+
+ if (opts.url) {
+ const { hostname, port, protocol, auth, path } = url.parse(opts.url) // eslint-disable-line node/no-deprecated-api
+ delete opts.url
+ if (!hostname && !port && !protocol && !auth) opts.path = path // Relative redirect
+ else Object.assign(opts, { hostname, port, protocol, auth, path }) // Absolute redirect
+ }
+
+ const headers = { 'accept-encoding': 'gzip, deflate' }
+ if (opts.headers) Object.keys(opts.headers).forEach(k => (headers[k.toLowerCase()] = opts.headers[k]))
+ opts.headers = headers
+
+ let body
+ if (opts.body) {
+ body = opts.json && !isStream(opts.body) ? JSON.stringify(opts.body) : opts.body
+ } else if (opts.form) {
+ body = typeof opts.form === 'string' ? opts.form : querystring.stringify(opts.form)
+ opts.headers['content-type'] = 'application/x-www-form-urlencoded'
+ }
+
+ if (body) {
+ if (!opts.method) opts.method = 'POST'
+ if (!isStream(body)) opts.headers['content-length'] = Buffer.byteLength(body)
+ if (opts.json && !opts.form) opts.headers['content-type'] = 'application/json'
+ }
+ delete opts.body; delete opts.form
+
+ if (opts.json) opts.headers.accept = 'application/json'
+ if (opts.method) opts.method = opts.method.toUpperCase()
+
+ const originalHost = opts.hostname // hostname before potential redirect
+ const protocol = opts.protocol === 'https:' ? https : http // Support http/https urls
+ const req = protocol.request(opts, res => {
+ if (opts.followRedirects !== false && res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
+ opts.url = res.headers.location // Follow 3xx redirects
+ delete opts.headers.host // Discard `host` header on redirect (see #32)
+ res.resume() // Discard response
+
+ const redirectHost = url.parse(opts.url).hostname // eslint-disable-line node/no-deprecated-api
+ // If redirected host is different than original host, drop headers to prevent cookie leak (#73)
+ if (redirectHost !== null && redirectHost !== originalHost) {
+ delete opts.headers.cookie
+ delete opts.headers.authorization
+ }
+
+ if (opts.method === 'POST' && [301, 302].includes(res.statusCode)) {
+ opts.method = 'GET' // On 301/302 redirect, change POST to GET (see #35)
+ delete opts.headers['content-length']; delete opts.headers['content-type']
+ }
+
+ if (opts.maxRedirects-- === 0) return cb(new Error('too many redirects'))
+ else return simpleGet(opts, cb)
+ }
+
+ const tryUnzip = typeof decompressResponse === 'function' && opts.method !== 'HEAD'
+ cb(null, tryUnzip ? decompressResponse(res) : res)
+ })
+ req.on('timeout', () => {
+ req.abort()
+ cb(new Error('Request timed out'))
+ })
+ req.on('error', cb)
+
+ if (isStream(body)) body.on('error', cb).pipe(req)
+ else req.end(body)
+
+ return req
+}
+
+simpleGet.concat = (opts, cb) => {
+ return simpleGet(opts, (err, res) => {
+ if (err) return cb(err)
+ concat(res, (err, data) => {
+ if (err) return cb(err)
+ if (opts.json) {
+ try {
+ data = JSON.parse(data.toString())
+ } catch (err) {
+ return cb(err, res, data)
+ }
+ }
+ cb(null, res, data)
+ })
+ })
+}
+
+;['get', 'post', 'put', 'patch', 'head', 'delete'].forEach(method => {
+ simpleGet[method] = (opts, cb) => {
+ if (typeof opts === 'string') opts = { url: opts }
+ return simpleGet(Object.assign({ method: method.toUpperCase() }, opts), cb)
+ }
+})
diff --git a/node_modules/simple-get/package.json b/node_modules/simple-get/package.json
new file mode 100644
index 0000000..e80fc5e
--- /dev/null
+++ b/node_modules/simple-get/package.json
@@ -0,0 +1,67 @@
+{
+ "name": "simple-get",
+ "description": "Simplest way to make http get requests. Supports HTTPS, redirects, gzip/deflate, streams in < 100 lines.",
+ "version": "4.0.1",
+ "author": {
+ "name": "Feross Aboukhadijeh",
+ "email": "feross@feross.org",
+ "url": "https://feross.org"
+ },
+ "browser": {
+ "decompress-response": false
+ },
+ "bugs": {
+ "url": "https://github.com/feross/simple-get/issues"
+ },
+ "dependencies": {
+ "decompress-response": "^6.0.0",
+ "once": "^1.3.1",
+ "simple-concat": "^1.0.0"
+ },
+ "devDependencies": {
+ "self-signed-https": "^1.0.5",
+ "standard": "*",
+ "string-to-stream": "^3.0.0",
+ "tape": "^5.0.0"
+ },
+ "homepage": "https://github.com/feross/simple-get",
+ "keywords": [
+ "request",
+ "http",
+ "GET",
+ "get request",
+ "http.get",
+ "redirects",
+ "follow redirects",
+ "gzip",
+ "deflate",
+ "https",
+ "http-https",
+ "stream",
+ "simple request",
+ "simple get"
+ ],
+ "license": "MIT",
+ "main": "index.js",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/feross/simple-get.git"
+ },
+ "scripts": {
+ "test": "standard && tape test/*.js"
+ },
+ "funding": [
+ {
+ "type": "github",
+ "url": "https://github.com/sponsors/feross"
+ },
+ {
+ "type": "patreon",
+ "url": "https://www.patreon.com/feross"
+ },
+ {
+ "type": "consulting",
+ "url": "https://feross.org/support"
+ }
+ ]
+}