{"name":"@digitalbazaar/http-client","version":"3.3.0","description":"An opinionated, isomorphic HTTP client.","license":"BSD-3-Clause","type":"module","main":"./dist/cjs/index.cjs","exports":{"require":"./dist/cjs/index.cjs","import":"./lib/index.js"},"browser":{"./lib/agentCompatibility.js":"./lib/agentCompatibility-browser.js"},"scripts":{"rollup":"rollup -c rollup.config.js","build":"npm run clear && npm run rollup","clear":"rimraf dist/ && mkdir dist","prepare":"npm run build","rebuild":"npm run clear && npm run build","test":"npm run test-node && npm run test-node-cjs","test-node":"cross-env NODE_ENV=test mocha --preserve-symlinks -t 30000 -A -R ${REPORTER:-spec} --require tests/test-mocha.js tests/*.spec.js","test-node-cjs":"cross-env NODE_ENV=test mocha --preserve-symlinks -t 30000 -A -R ${REPORTER:-spec} --require tests/test-mocha.cjs tests/*.spec.cjs","test-karma":"karma start karma.conf.cjs","test-watch":"cross-env NODE_ENV=test mocha --watch --parallel --preserve-symlinks -t 30000 -A -R ${REPORTER:-spec} --require tests/test-mocha.js tests/*.spec.js","coverage":"cross-env NODE_ENV=test c8 --reporter=lcov --reporter=text-summary npm run test-node","coverage-ci":"cross-env NODE_ENV=test c8 --reporter=lcovonly npm run test-node","coverage-report":"c8 report","lint":"eslint --ignore-pattern rollup.config.js ."},"dependencies":{"ky":"^0.33.2","ky-universal":"^0.11.0","undici":"^5.15.0"},"devDependencies":{"c8":"^7.12.0","chai":"^4.3.7","cross-env":"^7.0.3","detect-node":"^2.1.0","eslint":"^8.32.0","eslint-config-digitalbazaar":"^4.2.0","eslint-plugin-jsdoc":"^39.6.4","eslint-plugin-unicorn":"^45.0.2","karma":"^6.4.1","karma-chai":"^0.1.0","karma-chrome-launcher":"^3.1.1","karma-mocha":"^2.0.1","karma-mocha-reporter":"^2.2.5","karma-sourcemap-loader":"^0.3.8","karma-webpack":"^5.0.0","mocha":"^10.2.0","rimraf":"^4.0.7","rollup":"^3.10.0","webpack":"^5.75.0"},"repository":{"type":"git","url":"git+https://github.com/digitalbazaar/http-client.git"},"keywords":["http","isomorphic","http client"],"author":{"name":"Digital Bazaar, Inc.","email":"support@digitalbazaar.com","url":"https://digitalbazaar.com/"},"bugs":{"url":"https://github.com/digitalbazaar/http-client/issues"},"homepage":"https://github.com/digitalbazaar/http-client","engines":{"node":">=14.0"},"c8":{"exclude":["tests","node_modules"]},"gitHead":"38fc0c5f4d6f8000678874f664d8b0f5a422d6d7","_id":"@digitalbazaar/http-client@3.3.0","_nodeVersion":"16.19.0","_npmVersion":"9.3.0","dist":{"integrity":"sha512-xg/DFl+TsgkFi7xsH9AIU0wGPaw3AhwhVC8Gs2/v1h/XnvImIc8fKFGpW9uU0nP9EXw/N4jEEhkOY1oe8Nv4Cw==","shasum":"2748c647fc002c022b4b808aaf487b53f1a57667","tarball":"http://registry-npm.ywwl.com/@digitalbazaar/http-client/download/@digitalbazaar/http-client-3.3.0.tgz","fileCount":8,"unpackedSize":19677,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCID/5qcXe+hW99U9KjZRhqKNcU8OFHf9VigdreZTIYB8ZAiBnvarX7dYV12HH0C45TfKC89EaLP/rGDqCXNcruN8kYw=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjxyDMACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmruOxAAgeGCI7FSTZ1Z/9tamZH4q7Equ90yuIEdamPb1AWqrB9KM6Ew\r\njljYvRRdS4zdV7e4+eNqoYA9C2YSjUJMLRI5tH5eO/XLSKr8f0k0e/jE0TBo\r\ntwmJHLBiRJKUo8e9sWLU2UN51jbEVFKAZSJC23A2+lOC+9PnV6GdNDRXTOsA\r\nfLaRwE59o0DkPUqwDMoyGT6TfKsLKUK2ny21CLD86h6/BxzHR4dbozQo2mog\r\nxpg57kadzPpZ4lSRPo7CcJ+7r7QM83Ss9z8ti8mBcenSYDxGdfc6+HBVl3GL\r\nBhv8E6fb+GNG8fgf82NtsltE5DZtDYtnhZpMvLDsc7FRQ5QI/kBO1lBDIEWy\r\nBJLxzShYo2Imx5VdTqHDEtqbf8plVZXQFZPTPR6/zFbCNTtRM1LgJHCb67qv\r\nM+PIG7MmigbAnTlL5lWFv8oVRxvfqkAJBNF4jQgMbgOz1rTkPhKlUtzvvLFD\r\n68MJSb+XYGzDB7d9XGi27kDEvqhh17krz/LneIs93R+FhOyIT/BvWLIX5Owb\r\nM2Q6aclwyikMF0ddE7SCVQR4il6jAucvXZwlVcrvIQF64Z9VtGOdZBzQmYSd\r\nfRM9lJLkMybNPTrJInpyaRdaZyeMhgTT8KyXmgWyk4Kx1zQkbKuGieQKu3bw\r\nU6EQNRyI5YHDEW52iyXcKbCvOdlAAwtx3ZE=\r\n=oTDo\r\n-----END PGP SIGNATURE-----\r\n","size":4991,"noattachment":false,"key":"/@digitalbazaar/http-client/-/@digitalbazaar/http-client-3.3.0.tgz"},"_npmUser":{"name":"davidlehn","email":"dil@lehn.org"},"directories":{},"maintainers":[{"name":"dlongley","email":"dlongley@digitalbazaar.com"},{"name":"msporny","email":"msporny@digitalbazaar.com"},{"name":"davidlehn","email":"dil@lehn.org"},{"name":"mattcollier","email":"mcollier@digitalbazaar.com"},{"name":"gannan","email":"gannan@digitalbazaar.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/http-client_3.3.0_1673994444432_0.8142514266206533"},"_hasShrinkwrap":false,"readme":"# http-client\nAn opinionated, isomorphic HTTP client for Node.js, browsers, and React Native.\n\n### Usage\n\n#### Import httpClient (Node.js)\n```js\nimport https from 'https';\nimport {httpClient} from '@digitalbazaar/http-client';\n```\n\n#### Import httpClient (browsers or React Native)\n```js\nimport {httpClient} from '@digitalbazaar/http-client';\n```\n\n#### Import and initialize a custom Bearer Token client\n```js\nimport {httpClient} from '@digitalbazaar/http-client';\n\nconst httpsAgent = new https.Agent({rejectUnauthorized: false});\n\nconst accessToken = '12345';\nconst headers = {Authorization: `Bearer ${accessToken}`};\n\nconst client = httpClient.extend({headers, httpsAgent});\n\n// subsequent http calls will include an 'Authorization: Bearer 12345' header,\n// and use the provided httpsAgent\n```\n\n#### GET a JSON response in the browser\n```js\ntry {\n  const response = await httpClient.get('http://httpbin.org/json');\n  return response.data;\n} catch(e) {\n  // status is HTTP status code\n  // data is JSON error from the server\n  const {data, status} = e;\n  throw e;\n}\n```\n\n#### GET a JSON response in Node with an HTTP Agent\n```js\nimport https from 'https';\n// use an agent to avoid self-signed certificate errors\nconst agent = new https.Agent({rejectUnauthorized: false});\ntry {\n  const response = await httpClient.get('http://httpbin.org/json', {agent});\n  return response.data;\n} catch(e) {\n  // status is HTTP status code\n  // data is JSON error from the server if available\n  const {data, status} = e;\n  throw e;\n}\n```\n\n#### GET HTML by overriding default headers\n```js\nconst headers = {Accept: 'text/html'};\ntry {\n  const response = await httpClient.get('http://httpbin.org/html', {headers});\n  // see: https://developer.mozilla.org/en-US/docs/Web/API/Response#methods\n  return response.text();\n} catch(e) {\n  // status is HTTP status code\n  // any message from the server can be parsed from the response if present\n  const {response, status} = e;\n  throw e;\n}\n```\n\n#### POST a JSON payload\n```js\ntry {\n  const response = await httpClient.post('http://httpbin.org/json', {\n    // `json` is the payload or body of the POST request\n    json: {some: 'data'}\n  });\n  return response.data;\n} catch(e) {\n  // status is HTTP status code\n  // data is JSON error from the server\n  const {data, status} = e;\n  throw e;\n}\n```\n\n#### POST a JSON payload in Node with an HTTP Agent\n```js\nimport https from 'https';\n// use an agent to avoid self-signed certificate errors\nconst agent = new https.Agent({rejectUnauthorized: false});\ntry {\n  const response = await httpClient.post('http://httpbin.org/json', {\n    agent,\n    // `json` is the payload or body of the POST request\n    json: {some: 'data'}\n  });\n  return response.data;\n} catch(e) {\n  // status is HTTP status code\n  // data is JSON error from the server\n  const {data, status} = e;\n  throw e;\n}\n```\n","publish_time":1673994444600,"_cnpm_publish_time":1673994444600,"dist-tags":{"latest":"4.4.0"}}