Skip to content

Commit

Permalink
fix(region_config): remove mutation of global signatureVersion
Browse files Browse the repository at this point in the history
  • Loading branch information
kuhe committed Nov 28, 2022
1 parent 44bf65a commit c43b266
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": "avoid mutation in global object signatureVersion"
}
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 c43b266

Please sign in to comment.