Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

awscred

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

awscred - npm Package Compare versions

Comparing version 1.2.0 to 1.3.0

38

index.js

@@ -10,2 +10,3 @@ var fs = require('fs'),

loadCredentialsFromEc2Metadata,
loadCredentialsFromEcs,
]

@@ -144,3 +145,40 @@

var ec2Callbacks = []
var ecsCallbacks = []
function loadCredentialsFromEcs(options, cb) {
if (!cb) { cb = options; options = {} }
ecsCallbacks.push(cb)
if (ecsCallbacks.length > 1) return // only want one caller at a time
cb = function(err, credentials) {
ecsCallbacks.forEach(function(cb) { cb(err, credentials) })
ecsCallbacks = []
}
if (options.timeout == null) options.timeout = 5000
options.host = '169.254.170.2'
options.path = process.env.AWS_CONTAINER_CREDENTIALS_RELATIVE_URI
return request(options, function(err, res, data) {
if (err && ~TIMEOUT_CODES.indexOf(err.code)) return cb(null, {})
if (err) return cb(err)
if (res.statusCode != 200)
return cb(new Error('Failed to fetch IAM role: ' + res.statusCode + ' ' + data))
try { data = JSON.parse(data) } catch (e) { }
if (res.statusCode != 200)
return cb(new Error('Failed to fetch IAM credentials: ' + res.statusCode + ' ' + data))
cb(null, {
accessKeyId: data.AccessKeyId,
secretAccessKey: data.SecretAccessKey,
sessionToken: data.Token,
expiration: new Date(data.Expiration),
})
})
}
function loadCredentialsFromEc2Metadata(options, cb) {

@@ -147,0 +185,0 @@ if (!cb) { cb = options; options = {} }

2

package.json
{
"name": "awscred",
"version": "1.2.0",
"version": "1.3.0",
"description": "Resolves AWS credentials (and region) using env, file and IAM strategies",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -49,3 +49,3 @@ awscred

- `filename`: the name of the INI file to parse, defaults to `'~/.aws/config'`
- `filename`: the name of the INI file to parse, defaults to `'~/.aws/credentials'` for credentials and `'~/.aws/config'` for region
- `profile`: the name of the INI profile to use, defaults to `'default'`

@@ -52,0 +52,0 @@ - `timeout`: the ms timeout on the http call to the EC2 metadata service, defaults to `5000`

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc