Skip to content

Commit

Permalink
fix(region_config): remove mutation of global signatureVersion (#4288)
Browse files Browse the repository at this point in the history
* fix(region_config): remove mutation of global signatureVersion

* Update .changes/next-release/bugfix-region-config-31f590e0.json

Co-authored-by: Trivikram Kamat <16024985+trivikr@users.noreply.github.com>
  • Loading branch information
kuhe and trivikr committed Nov 28, 2022
1 parent b168eaa commit c6c5aab
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changes/next-release/bugfix-region-config-31f590e0.json
@@ -0,0 +1,5 @@
{
"type": "bugfix",
"category": "region_config",
"description": "Set signatureVersion to bearer explcitly when defined in service API"
}
13 changes: 11 additions & 2 deletions lib/region_config.js
Expand Up @@ -64,11 +64,20 @@ function configureEndpoint(service) {

// signature version
if (!config.signatureVersion) {
config.signatureVersion = (service.api && service.api.signatureVersion) || 'v4';
// Note: config is a global object and should not be mutated here.
// However, we are retaining this line for backwards compatibility.
// The non-v4 signatureVersion will be set in a copied object below.
config.signatureVersion = 'v4';
}

var useBearer = (service.api && service.api.signatureVersion) === 'bearer';

// merge config
applyConfig(service, config);
applyConfig(service, Object.assign(
{},
config,
{ signatureVersion: useBearer ? 'bearer' : config.signatureVersion }
));
return;
}
}
Expand Down

0 comments on commit c6c5aab

Please sign in to comment.