Comparing version 0.3.1 to 0.4.0
@@ -11,3 +11,2 @@ /*jslint node: true */ | ||
var ALKS_DURATIONS = [ 2, 6, 12, 18 ], // reducing due to EB not honoring long sessions: , 24, 36 ], | ||
ACCOUNT_SELECTION_DELIMITER = ' :: ', | ||
AWS_SIGNIN_URL = 'https://signin.aws.amazon.com/federation', | ||
@@ -22,6 +21,2 @@ AWS_CONSOLE_URL = 'https://console.aws.amazon.com/', | ||
exports.getAccountSelectorDelimiter = function(){ | ||
return ACCOUNT_SELECTION_DELIMITER; | ||
}; | ||
var getMessageFromBadResponse = function(results){ | ||
@@ -183,3 +178,2 @@ if(results.body){ | ||
options = _.extend({ | ||
filters: {}, | ||
debug: false, | ||
@@ -212,15 +206,11 @@ ua: DEFAULT_UA | ||
if(results.body.accountListRole){ | ||
var accountRolesFitlered = {}; | ||
var accounts = []; | ||
_.each(results.body.accountListRole, function(role, acct){ | ||
if((options.filters.iamOnly && !role[0].iamKeyActive) | ||
|| (!options.filters.iamOnly && role[0].iamKeyActive)){ | ||
return; | ||
} | ||
accountRolesFitlered[acct] = role; | ||
accounts.push({ | ||
account: acct, | ||
role: role[0].role, | ||
iam: role[0].iamKeyActive | ||
}); | ||
}); | ||
var accounts = []; | ||
_.each(accountRolesFitlered, function(role, acct){ | ||
accounts.push([acct, role[0].role].join(ACCOUNT_SELECTION_DELIMITER)); | ||
}); | ||
} | ||
@@ -230,7 +220,11 @@ // v1 API style without IAM | ||
_.each(results.body.accountRoles, function(role, acct){ | ||
accounts.push([acct, role[0]].join(ACCOUNT_SELECTION_DELIMITER)); | ||
accounts.push({ | ||
account: acct, | ||
role: role[0], | ||
iam: false | ||
}); | ||
}); | ||
} | ||
accounts = _.sortBy(accounts, function(account){ return account; }); | ||
accounts = _.sortBy(accounts, function(account){ return account.account; }); | ||
@@ -237,0 +231,0 @@ callback(null, accounts); |
{ | ||
"name": "alks-node", | ||
"version": "0.3.1", | ||
"version": "0.4.0", | ||
"description": "Node client for ALKS", | ||
@@ -5,0 +5,0 @@ "main": "lib/alks-api.js", |
@@ -8,3 +8,3 @@ #ALKS Node Client | ||
## About | ||
Node client for interfacting with the [ALKS](https://github.com/Cox-Automotive/ALKS) services. | ||
Node client for interfacting with ALKS services. | ||
@@ -27,13 +27,5 @@ ## Usage | ||
### getAccountSelectorDelimiter() | ||
Returns string dilimeter used for account/role seperation. | ||
```js | ||
alks.getAccountSelectorDelimiter(); | ||
``` | ||
## Methods | ||
### createKey(account, password, duration, callback) | ||
### createKey(account, password, duration, options, callback) | ||
@@ -60,6 +52,6 @@ Creates a new session key with the provided information. Returns a JSON document. | ||
Returns a collection of accounts. Options filter allows you to switch between IAM and non-IAM accounts. | ||
Returns a collection of accounts. | ||
```js | ||
alks.getAccounts('server', 'username', 'password', {filters: { iamOnly: false }}, function(err, accounts){ | ||
alks.getAccounts('server', 'username', 'password', {}, function(err, accounts){ | ||
if(err) console.error(err); | ||
@@ -70,3 +62,3 @@ else console.log(JSON.stringify(accounts)); | ||
### generateConsoleUrl(key, callback) | ||
### generateConsoleUrl(key, options, callback) | ||
@@ -82,12 +74,12 @@ Returns a AWS console URL for a given key. The URL is good for 15 minutes. | ||
### getIamRoleTypes(server, userid, password, callback) | ||
### getIamRoleTypes(server, userid, password, options, callback) | ||
Returns a list of current IAM role types. | ||
### createIamKey(account, password, callback) | ||
### createIamKey(account, password, options, callback) | ||
Generates a new session for use in creating IAM roles and console sessions. | ||
### createIamRole(account, password, roleName, roleType, includeDefaultPolicies, callback) | ||
### createIamRole(account, password, roleName, roleType, includeDefaultPolicies, options, callback) | ||
Creates a new IAM role, provided account must contain valid ALKS IAM session. |
14916
279
80