New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

aws-assume

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aws-assume - npm Package Compare versions

Comparing version

to
0.1.5

70

lib/aws-assume.js

@@ -11,2 +11,4 @@ #!/usr/bin/env node

require('babel-polyfill');
var _awsSdk = require('aws-sdk');

@@ -23,14 +25,14 @@

function assume(profile) {
const creds = new _awsSdk.SharedIniFileCredentials({ profile });
const file = process.env.AWS_CONFIG_FILE || (0, _path.join)((0, _path.dirname)(creds.filename), 'config');
const config = (0, _ini.parse)((0, _fs.readFileSync)(file, 'utf-8'))[`profile ${ profile }`];
const sts = new _awsSdk.STS();
var creds = new _awsSdk.SharedIniFileCredentials({ profile: profile });
var file = process.env.AWS_CONFIG_FILE || (0, _path.join)((0, _path.dirname)(creds.filename), 'config');
var config = (0, _ini.parse)((0, _fs.readFileSync)(file, 'utf-8'))['profile ' + profile];
var sts = new _awsSdk.STS();
const options = {
var options = {
RoleArn: config.role_arn,
RoleSessionName: `${ profile }-${ Date.now() }`
RoleSessionName: profile + '-' + Date.now()
};
return new Promise((resolve, reject) => {
sts.assumeRole(options, (error, response) => {
return new Promise(function (resolve, reject) {
sts.assumeRole(options, function (error, response) {
if (error) reject(error);else resolve(response.Credentials);

@@ -50,19 +52,45 @@ });

exports.default = (() => {
var _ref = _asyncToGenerator(function* (profile) {
process.stderr.write(`Using the "${ profile }" aws profile.\n`);
process.stdin.setEncoding('utf8');
exports.default = function () {
var _ref = _asyncToGenerator(regeneratorRuntime.mark(function _callee(profile) {
var _ref2, AccessKeyId, SecretAccessKey, SessionToken;
try {
const { AccessKeyId, SecretAccessKey, SessionToken } = yield assume(profile);
process.stdout.write(`AWS_ACCESS_KEY_ID=${ AccessKeyId } AWS_SECRET_ACCESS_KEY=${ SecretAccessKey } AWS_SESSION_TOKEN=${ SessionToken }`);
} catch (e) {
process.stderr.write(e.message + "\n");
process.exitCode = 1;
}
});
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
process.stderr.write('Using the "' + profile + '" aws profile.\n');
process.stdin.setEncoding('utf8');
_context.prev = 2;
_context.next = 5;
return assume(profile);
case 5:
_ref2 = _context.sent;
AccessKeyId = _ref2.AccessKeyId;
SecretAccessKey = _ref2.SecretAccessKey;
SessionToken = _ref2.SessionToken;
process.stdout.write('AWS_ACCESS_KEY_ID=' + AccessKeyId + ' AWS_SECRET_ACCESS_KEY=' + SecretAccessKey + ' AWS_SESSION_TOKEN=' + SessionToken);
_context.next = 16;
break;
case 12:
_context.prev = 12;
_context.t0 = _context['catch'](2);
process.stderr.write(_context.t0.message + "\n");
process.exitCode = 1;
case 16:
case 'end':
return _context.stop();
}
}
}, _callee, undefined, [[2, 12]]);
}));
return function (_x) {
return _ref.apply(this, arguments);
};
})();
}();
{
"name": "aws-assume",
"description": "Generate teporary credentials for aws assumed roles.",
"version": "0.1.4",
"version": "0.1.5",
"author": "Jonathan Brumley <cayasso@gmail.com>",

@@ -19,3 +19,5 @@ "keywords": [

"scripts": {
"build": "make build"
"build": "npm run clean && ./node_modules/.bin/babel src -d lib",
"prepublish": "npm run build",
"clean": "rm -rf lib/"
},

@@ -29,2 +31,3 @@ "repository": {

"aws-sdk": "^2.7.7",
"babel-polyfill": "^6.16.0",
"ini": "^1.3.4"

@@ -34,5 +37,8 @@ },

"babel-cli": "^6.9.0",
"babel-plugin-transform-async-to-generator": "6.8.0",
"babel-plugin-transform-es2015-modules-commonjs": "6.11.5",
"babel-plugin-transform-object-rest-spread": "^6.8.0",
"babel-plugin-transform-es2015-modules-commonjs": "6.11.5",
"babel-plugin-transform-async-to-generator": "6.8.0",
"babel-plugin-transform-es2015-destructuring": "^6.19.0",
"babel-preset-es2015": "^6.3.13",
"babel-preset-stage-0": "^6.3.13",
"pre-commit": "^1.1.3"

@@ -39,0 +45,0 @@ },

@@ -73,1 +73,25 @@ # aws-assume

This project is heavely based on [aws-auth-helper](https://github.com/CoffeeAndCode/aws-auth-helper) but without the MFA part and some small variations.
# License
The MIT License (MIT)
Copyright (c) 2016 Jonathan Brumley
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Sorry, the diff of this file is not supported yet