Skip to content

Commit 573bbdd

Browse files
committed
Fix #6 - Add support for AWS.Credentials objects
Should be backwards compatible: if for some reason you have an object that has both the old style and new (standard) style creds properties, the old-style will be used. Only possible break in compatibility is if someone for some reason passed in options that have the new style credential properties but not the old ones, and was relying on the previous behavior to load the creds from env vars: now, the new-style credentials will be favored if present over the env vars.
1 parent e83f15a commit 573bbdd

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

lib/utils.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,15 @@ const getUrlAndHeaders = (host, port, credentials, canonicalUri, protocol) => {
5757
if (!host || !port) {
5858
throw new Error('Host and port are required');
5959
}
60-
const accessKey = credentials.accessKey || process.env.AWS_ACCESS_KEY_ID;
61-
const secretKey = credentials.secretKey || process.env.AWS_SECRET_ACCESS_KEY;
60+
61+
const accessKey = credentials.accessKey || credentials.accessKeyId
62+
|| process.env.AWS_ACCESS_KEY_ID;
63+
const secretKey = credentials.secretKey || credentials.secretAccessKey
64+
|| process.env.AWS_SECRET_ACCESS_KEY;
65+
const sessionToken = credentials.sessionToken || credentials.sessionToken
66+
|| process.env.AWS_SESSION_TOKEN;
6267
const region = credentials.region || process.env.AWS_DEFAULT_REGION;
63-
const sessionToken = credentials.sessionToken || process.env.AWS_SESSION_TOKEN;
68+
6469
if (!accessKey || !secretKey) {
6570
throw new Error('Access key and secret key are required');
6671
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"aws4": "^1.8.0",
2525
"debug": "2.6.9",
2626
"gremlin": "3.4.0",
27-
"moment-timezone": "0.5.21",
27+
"moment-timezone": "^0.5.21",
2828
"request": "2.88.0"
2929
},
3030
"devDependencies": {

0 commit comments

Comments
 (0)