googleapis-common
Advanced tools
Comparing version 4.2.0 to 4.2.1
@@ -51,33 +51,16 @@ "use strict"; | ||
async function createAPIRequestAsync(parameters) { | ||
const options = Object.assign({}, parameters.options); | ||
// Create a new params object so it can no longer be modified from outside | ||
// code Also support global and per-client params, but allow them to be | ||
// overriden per-request | ||
const globalParams = parameters.context.google && | ||
parameters.context.google._options && | ||
parameters.context.google._options.params | ||
? parameters.context.google._options.params | ||
: {}; | ||
const clientParams = parameters.context && | ||
parameters.context._options && | ||
parameters.context._options.params | ||
? parameters.context._options.params | ||
: {}; | ||
const params = Object.assign({}, // New base object | ||
globalParams, // Global params | ||
clientParams, // Per-client params | ||
var _a; | ||
// Combine the GaxiosOptions options passed with this specific | ||
// API call with the global options configured at the API Context | ||
// level, or at the global level. | ||
const options = extend(true, {}, // Ensure we don't leak settings upstream | ||
((_a = parameters.context.google) === null || _a === void 0 ? void 0 : _a._options) || {}, // Google level options | ||
parameters.context._options || {}, // Per-API options | ||
parameters.options // API call params | ||
); | ||
const params = extend(true, {}, // New base object | ||
options.params, // Combined global/per-api params | ||
parameters.params // API call params | ||
); | ||
// Check for user specified user agents at all levels of config | ||
const userAgentGlobal = parameters.context.google && | ||
parameters.context.google._options && | ||
parameters.context.google._options.userAgentDirectives | ||
? parameters.context.google._options.userAgentDirectives | ||
: []; | ||
const userAgentClient = parameters.context && | ||
parameters.context._options && | ||
parameters.context._options.userAgentDirectives | ||
? parameters.context._options.userAgentDirectives | ||
: []; | ||
const userAgentDirectives = Object.assign([], userAgentGlobal, userAgentClient, parameters.options.userAgentDirectives) || []; | ||
options.userAgentDirectives = options.userAgentDirectives || []; | ||
const media = params.media || {}; | ||
@@ -107,7 +90,3 @@ /** | ||
delete params.requestBody; | ||
let authClient = params.auth || | ||
parameters.context._options.auth || | ||
(parameters.context.google | ||
? parameters.context.google._options.auth | ||
: null); | ||
let authClient = params.auth || options.auth; | ||
const defaultMime = typeof media.body === 'string' ? 'text/plain' : 'application/octet-stream'; | ||
@@ -156,12 +135,4 @@ delete params.media; | ||
}; | ||
// delete path parameters from the params object so they do not end up in | ||
// query | ||
parameters.pathParams.forEach(param => { | ||
delete params[param]; | ||
if (parameters.context && | ||
parameters.context._options && | ||
parameters.context._options.params) { | ||
delete parameters.context._options.params[param]; | ||
} | ||
}); | ||
// delete path params from the params object so they do not end up in query | ||
parameters.pathParams.forEach(param => delete params[param]); | ||
// if authClient is actually a string, use it as an API KEY | ||
@@ -259,3 +230,3 @@ if (typeof authClient === 'string') { | ||
options.headers['Accept-Encoding'] = 'gzip'; | ||
userAgentDirectives.push({ | ||
options.userAgentDirectives.push({ | ||
product: 'google-api-nodejs-client', | ||
@@ -265,3 +236,3 @@ version: pkg.version, | ||
}); | ||
const userAgent = userAgentDirectives | ||
const userAgent = options.userAgentDirectives | ||
.map(d => { | ||
@@ -287,7 +258,3 @@ let line = `${d.product}/${d.version}`; | ||
options.retry = options.retry === undefined ? true : options.retry; | ||
// Combine the GaxiosOptions options passed with this specific | ||
// API call witht the global options configured at the API Context | ||
// level, or at the global level. | ||
const mergedOptions = extend(true, {}, parameters.context.google ? parameters.context.google._options : {}, parameters.context._options, options); | ||
delete mergedOptions.auth; // is overridden by our auth code | ||
delete options.auth; // is overridden by our auth code | ||
// Perform the HTTP request. NOTE: this function used to return a | ||
@@ -298,6 +265,6 @@ // mikeal/request object. Since the transition to Axios, the method is | ||
if (authClient && typeof authClient === 'object') { | ||
return authClient.request(mergedOptions); | ||
return authClient.request(options); | ||
} | ||
else { | ||
return new google_auth_library_1.DefaultTransporter().request(mergedOptions); | ||
return new google_auth_library_1.DefaultTransporter().request(options); | ||
} | ||
@@ -304,0 +271,0 @@ } |
@@ -7,2 +7,9 @@ # Changelog | ||
### [4.2.1](https://www.github.com/googleapis/nodejs-googleapis-common/compare/v4.2.0...v4.2.1) (2020-06-02) | ||
### Bug Fixes | ||
* ensure options changes do not leak upstream ([#285](https://www.github.com/googleapis/nodejs-googleapis-common/issues/285)) ([8d4de8a](https://www.github.com/googleapis/nodejs-googleapis-common/commit/8d4de8a03b56d1063aac5f072436917247afc9f1)) | ||
## [4.2.0](https://www.github.com/googleapis/nodejs-googleapis-common/compare/v4.1.1...v4.2.0) (2020-05-26) | ||
@@ -9,0 +16,0 @@ |
{ | ||
"name": "googleapis-common", | ||
"version": "4.2.0", | ||
"version": "4.2.1", | ||
"description": "A common tooling library used by the googleapis npm module. You probably don't want to use this directly.", | ||
@@ -5,0 +5,0 @@ "repository": "googleapis/nodejs-googleapis-common", |
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
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
72091
1032