@digitalbazaar/http-client
Advanced tools
Comparing version 3.1.0 to 3.2.0
/*! | ||
* Copyright (c) 2020-2022 Digital Bazaar, Inc. All rights reserved. | ||
*/ | ||
import {convertAgent} from './agentCompatibility.js'; | ||
export const kyOriginalPromise = import('ky-universal') | ||
@@ -30,2 +32,5 @@ .then(({default: ky}) => ky); | ||
} = {}) { | ||
// convert legacy agent options | ||
params = convertAgent(params); | ||
// create new ky instance that will asynchronously resolve | ||
@@ -42,3 +47,3 @@ const kyPromise = parent.then(kyBase => { | ||
// extend parent | ||
ky = kyBase.extend({headers, params}); | ||
ky = kyBase.extend({headers, ...params}); | ||
} | ||
@@ -48,2 +53,6 @@ return ky; | ||
return _createHttpClient(kyPromise); | ||
} | ||
function _createHttpClient(kyPromise) { | ||
async function httpClient(...args) { | ||
@@ -55,2 +64,5 @@ const ky = await kyPromise; | ||
} | ||
// convert legacy agent options | ||
args[1] = convertAgent(args[1]); | ||
return ky.apply(ky, args); | ||
@@ -67,7 +79,7 @@ } | ||
httpClient.create = function({headers = {}, ...params}) { | ||
return createInstance({headers, params}); | ||
return createInstance({headers, ...params}); | ||
}; | ||
httpClient.extend = function({headers = {}, ...params}) { | ||
return createInstance({parent: kyPromise, headers, params}); | ||
return createInstance({parent: kyPromise, headers, ...params}); | ||
}; | ||
@@ -87,2 +99,5 @@ | ||
async function _handleResponse(target, thisArg, args) { | ||
// convert legacy agent options | ||
args[1] = convertAgent(args[1]); | ||
let response; | ||
@@ -89,0 +104,0 @@ const [url] = args; |
{ | ||
"name": "@digitalbazaar/http-client", | ||
"version": "3.1.0", | ||
"version": "3.2.0", | ||
"description": "An opinionated, isomorphic HTTP client.", | ||
@@ -12,2 +12,5 @@ "license": "BSD-3-Clause", | ||
}, | ||
"browser": { | ||
"./lib/agentCompatibility.js": "./lib/agentCompatibility-browser.js" | ||
}, | ||
"scripts": { | ||
@@ -35,3 +38,4 @@ "rollup": "rollup -c rollup.config.js", | ||
"ky": "^0.30.0", | ||
"ky-universal": "^0.10.1" | ||
"ky-universal": "^0.10.1", | ||
"undici": "^5.2.0" | ||
}, | ||
@@ -38,0 +42,0 @@ "devDependencies": { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
19703
8
379
3
8
+ Addedundici@^5.2.0
+ Added@fastify/busboy@2.1.1(transitive)
+ Addedundici@5.28.4(transitive)