Skip to content

Commit c6c5aab

Browse files
kuhetrivikr
andauthored
fix(region_config): remove mutation of global signatureVersion (#4288)
* fix(region_config): remove mutation of global signatureVersion * Update .changes/next-release/bugfix-region-config-31f590e0.json Co-authored-by: Trivikram Kamat <[email protected]>
1 parent b168eaa commit c6c5aab

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"type": "bugfix",
3+
"category": "region_config",
4+
"description": "Set signatureVersion to bearer explcitly when defined in service API"
5+
}

lib/region_config.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,20 @@ function configureEndpoint(service) {
6464

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

73+
var useBearer = (service.api && service.api.signatureVersion) === 'bearer';
74+
7075
// merge config
71-
applyConfig(service, config);
76+
applyConfig(service, Object.assign(
77+
{},
78+
config,
79+
{ signatureVersion: useBearer ? 'bearer' : config.signatureVersion }
80+
));
7281
return;
7382
}
7483
}

0 commit comments

Comments
 (0)