Comparing version 1.1.0 to 1.2.0
33
index.js
@@ -20,8 +20,12 @@ var fs = require('fs'), | ||
exports.loadRegion = loadRegion | ||
exports.loadRegionSync = loadRegionSync | ||
exports.loadCredentialsFromEnv = loadCredentialsFromEnv | ||
exports.loadRegionFromEnv = loadRegionFromEnv | ||
exports.loadRegionFromEnvSync = loadRegionFromEnvSync | ||
exports.loadCredentialsFromIniFile = loadCredentialsFromIniFile | ||
exports.loadRegionFromIniFile = loadRegionFromIniFile | ||
exports.loadRegionFromIniFileSync = loadRegionFromIniFileSync | ||
exports.loadCredentialsFromEc2Metadata = loadCredentialsFromEc2Metadata | ||
exports.loadProfileFromIniFile = loadProfileFromIniFile | ||
exports.loadProfileFromIniFileSync = loadProfileFromIniFileSync | ||
exports.merge = merge | ||
@@ -88,2 +92,6 @@ | ||
function loadRegionSync(options) { | ||
return loadRegionFromEnvSync(options) || loadRegionFromIniFileSync(options) | ||
} | ||
function loadCredentialsFromEnv(options, cb) { | ||
@@ -102,5 +110,9 @@ if (!cb) { cb = options; options = {} } | ||
cb(null, env.AWS_REGION || env.AMAZON_REGION || env.AWS_DEFAULT_REGION) | ||
cb(null, loadRegionFromEnvSync()) | ||
} | ||
function loadRegionFromEnvSync() { | ||
return env.AWS_REGION || env.AMAZON_REGION || env.AWS_DEFAULT_REGION | ||
} | ||
function loadCredentialsFromIniFile(options, cb) { | ||
@@ -128,2 +140,6 @@ if (!cb) { cb = options; options = {} } | ||
function loadRegionFromIniFileSync(options) { | ||
return loadProfileFromIniFileSync(options || {}, 'config').region | ||
} | ||
var TIMEOUT_CODES = ['ECONNRESET', 'ETIMEDOUT', 'EHOSTUNREACH', 'Unknown system errno 64'] | ||
@@ -184,2 +200,17 @@ var ec2Callbacks = [] | ||
function loadProfileFromIniFileSync(options, defaultFilename) { | ||
var filename = options.filename || path.join(resolveHome(), '.aws', defaultFilename), | ||
profile = options.profile || resolveProfile(), | ||
data | ||
try { | ||
data = fs.readFileSync(filename, 'utf8') | ||
} catch (err) { | ||
if (err.code == 'ENOENT') return {} | ||
throw err | ||
} | ||
return parseAwsIni(data)[profile] || {} | ||
} | ||
function merge(obj, options, cb) { | ||
@@ -186,0 +217,0 @@ if (!cb) { cb = options; options = {} } |
{ | ||
"name": "awscred", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "Resolves AWS credentials (and region) using env, file and IAM strategies", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -29,2 +29,11 @@ awscred | ||
Or just load the region, synchronously: | ||
```js | ||
console.log(awscred.loadRegionSync()) | ||
// us-east-1 | ||
``` | ||
API | ||
@@ -69,2 +78,6 @@ --- | ||
### awscred.loadRegionSync([options]) | ||
As above, but returns the region directly from this function using synchronous calls. | ||
### awscred.credentialsCallChain | ||
@@ -82,6 +95,9 @@ | ||
### awscred.loadRegionFromEnv | ||
### awscred.loadRegionFromEnvSync | ||
### awscred.loadCredentialsFromIniFile | ||
### awscred.loadRegionFromIniFile | ||
### awscred.loadRegionFromIniFileSync | ||
### awscred.loadCredentialsFromEc2Metadata | ||
### awscred.loadProfileFromIniFile | ||
### awscred.loadProfileFromIniFileSync | ||
@@ -88,0 +104,0 @@ Individual methods to load credentials and region from different sources |
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
13303
240
107