Comparing version 1.0.3 to 1.1.0
36
index.js
@@ -26,2 +26,3 @@ var fs = require('fs'), | ||
exports.loadProfileFromIniFile = loadProfileFromIniFile | ||
exports.merge = merge | ||
@@ -180,2 +181,37 @@ function loadCredentialsAndRegion(options, cb) { | ||
function merge(obj, options, cb) { | ||
if (!cb) { cb = options; options = {} } | ||
var needRegion = !obj.region | ||
var needCreds = !obj.credentials || !obj.credentials.accessKeyId || !obj.credentials.secretAccessKey | ||
function loadCreds(cb) { | ||
if (needRegion && needCreds) { | ||
return loadCredentialsAndRegion(options, cb) | ||
} else if (needRegion) { | ||
return loadRegion(options, function(err, region) { cb(err, {region: region}) }) | ||
} else if (needCreds) { | ||
return loadCredentials(options, function(err, credentials) { cb(err, {credentials: credentials}) }) | ||
} | ||
cb(null, {}) | ||
} | ||
loadCreds(function(err, creds) { | ||
if (err) return cb(err) | ||
if (creds.region) obj.region = creds.region | ||
if (creds.credentials) { | ||
if (!obj.credentials) { | ||
obj.credentials = creds.credentials | ||
} else { | ||
Object.keys(creds.credentials).forEach(function(key) { | ||
if (!obj.credentials[key]) obj.credentials[key] = creds.credentials[key] | ||
}) | ||
} | ||
} | ||
cb() | ||
}) | ||
} | ||
function resolveProfile() { | ||
@@ -182,0 +218,0 @@ return env.AWS_PROFILE || env.AMAZON_PROFILE || 'default' |
{ | ||
"name": "awscred", | ||
"version": "1.0.3", | ||
"version": "1.1.0", | ||
"description": "Resolves AWS credentials (and region) using env, file and IAM strategies", | ||
@@ -15,3 +15,4 @@ "main": "index.js", | ||
"author": "Michael Hart <michael.hart.au@gmail.com>", | ||
"license": "MIT" | ||
"license": "MIT", | ||
"scripts": {} | ||
} |
@@ -86,1 +86,6 @@ awscred | ||
Individual methods to load credentials and region from different sources | ||
### awscred.merge(obj, [options], cb) | ||
Populates the `region` and `credentials` properties of `obj` using the | ||
appropriate `load` method – depending on whether they're already set or not. |
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
12045
215
91