Comparing version
'use strict'; | ||
var version = "1.11.3"; | ||
var version = "1.11.4"; | ||
@@ -838,3 +838,3 @@ const Buffer = require('buffer').Buffer; | ||
var responsePromise = opts._fetch(`${opts.baseUrl}/${path}/`, { | ||
var responsePromise = opts._fetch(`${opts.baseUrl}/${path}`, { | ||
method, headers, body: method == 'GET' ? undefined : JSON.stringify(opts) | ||
@@ -841,0 +841,0 @@ }); |
@@ -1,2 +0,2 @@ | ||
var version = "1.11.3"; | ||
var version = "1.11.4"; | ||
@@ -835,3 +835,3 @@ const fetch = window.fetch.bind(window); | ||
var responsePromise = opts._fetch(`${opts.baseUrl}/${path}/`, { | ||
var responsePromise = opts._fetch(`${opts.baseUrl}/${path}`, { | ||
method, headers, body: method == 'GET' ? undefined : JSON.stringify(opts) | ||
@@ -838,0 +838,0 @@ }); |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).alks=t()}(this,function(){"use strict";var n=window.fetch.bind(window),t=function(e,t){void 0===t&&(t={}),this.defaults=Object.assign({},t,{_fetch:n},e)};t.prototype._base64Encode=function(e){return void 0===e&&(e=""),btoa(e)},t.prototype.create=function(e){return new t(e,this.defaults)},t.prototype.getAccounts=function(e){return this._doFetch("getAccounts",e).then(function(t){return Object.keys(t.accountListRole).map(function(e){return{account:e,role:t.accountListRole[e][0].role,iamKeyActive:t.accountListRole[e][0].iamKeyActive,maxKeyDuration:t.accountListRole[e][0].maxKeyDuration,skypieaAccount:t.accountListRole[e][0].skypieaAccount}})})},t.prototype.getKeys=function(e){return this._doFetch("getKeys",e).then(function(e){return o(e,["accessKey","secretKey","sessionToken","consoleURL"])})},t.prototype.getIAMKeys=function(e){return this._doFetch("getIAMKeys",e).then(function(e){return o(e,["accessKey","secretKey","sessionToken","consoleURL"])})},t.prototype.getAllAWSRoleTypes=function(e){var t=e.getDynamicValues?"allAwsRoleTypes?getDynamicValues=true":"allAwsRoleTypes";return this._doFetch(t,e,"GET").then(function(e){return e.roleTypes})},t.prototype.getAWSRoleTypes=function(e){return this._doFetch("getAWSRoleTypes",e).then(function(e){return JSON.parse(e.roleTypes)})},t.prototype.getNonServiceAWSRoleTypes=function(e){return this._doFetch("getNonServiceAWSRoleTypes",e).then(function(e){return JSON.parse(e.roleTypes)})},t.prototype.createRole=function(e){return this._doFetch("createRole",e).then(function(e){return e.denyArns=e.denyArns.split(","),o(e,["roleArn","denyArns","instanceProfileArn","addedRoleToInstanceProfile"])})},t.prototype.createNonServiceRole=function(e){return this._doFetch("createNonServiceRole",e).then(function(e){return e.denyArns=e.denyArns.split(","),o(e,["roleArn","denyArns","instanceProfileArn","addedRoleToInstanceProfile"])})},t.prototype.awsAccountRoles=function(e){return this._doFetch("awsAccountRoles?account="+e.account,e,"GET").then(function(e){return e.awsRoleList})},t.prototype.listAWSAccountRoles=function(e){return this._doFetch("listAWSAccountRoles",e).then(function(e){return JSON.parse(e.jsonAWSRoleList).map(function(e){return e.split("/").slice(-1)[0]})})},t.prototype.getAccountRole=function(t){return this._doFetch("getAccountRole",t).then(function(e){if(!e.roleExists)throw new Error("Role "+t.roleName+" does not exist in this account");return e.roleARN})},t.prototype.deleteRole=function(e){return this._doFetch("deleteRole",e).then(function(){return!0})},t.prototype.addRoleMachineIdentity=function(e){return this._doFetch("roleMachineIdentity",e).then(function(e){return o(e,["machineIdentityArn"])})},t.prototype.deleteRoleMachineIdentity=function(e){return this._doFetch("roleMachineIdentity",e,"DELETE").then(function(e){return o(e,["machineIdentityArn"])})},t.prototype.getUserAccess=function(e){var t=e.accountId;return this._doFetch("userAccess/"+t,e,"GET").then(function(e){return e.users})},t.prototype.getUserAccessByRole=function(e){var t=e.accountId;return this._doFetch("reports/users-by-role?accountId="+t,e,"GET").then(function(e){return e.users})},t.prototype.getUserRoleAccess=function(e){var t=e.accountId;return this._doFetch("userAccess/roles/"+t,e).then(function(e){return e.roles})},t.prototype.getAccountOwners=function(e){var t=e.accountId;return this._doFetch("userAccess/owners/"+t,e,"GET").then(function(e){return e.accountOwners})},t.prototype.createAccessKeys=function(e){return this._doFetch("accessKeys",e).then(function(e){return o(e,["iamUserArn","accessKey","secretKey","addedIAMUserToGroup"])})},t.prototype.deleteIAMUser=function(e){return this._doFetch("IAMUser",e,"DELETE").then(function(){return!0})},t.prototype.version=function(e){return this._doFetch("version",e,"GET").then(function(e){return o(e,["version"])})},t.prototype.getLoginRole=function(e){var t=e.accountId,n=e.role;return this._doFetch("loginRoles/id/"+t+"/"+n,null).then(function(e){return o(e,["account","role","iamKeyActive","maxKeyDuration"])})},t.prototype.getAccessToken=function(e){return this._doFetch("accessToken",e).then(function(e){return o(e,["accessToken","expiresIn"])})},t.prototype.getRefreshTokens=function(e){return this._doFetch("refreshTokens",e,"GET").then(function(e){return e.refreshTokens.map(function(e){return o(e,["clientId","id","userId","value"])})})},t.prototype.revoke=function(e){return this._doFetch("revoke",e).then(function(e){return"Success"==e.statusMessage})},t.prototype._doFetch=function(e,t,n){void 0===t&&(t={}),void 0===n&&(n="POST");var o=Object.assign({},this.defaults,t),r={"Content-Type":"application/json","User-Agent":"AlksJS/1.11.3"};if(o.accessToken&&(r.Authorization="Bearer "+o.accessToken,delete o.accessToken),o.userid||o.password){console.error("The userid and password properties are deprecated and should be replaced with an access token");var s=this._base64Encode(o.userid+":"+o.password);r.Authorization="Basic "+s,delete o.userid,delete o.password}o.accessKey&&(r["ALKS-STS-Access-Key"]=o.accessKey,delete o.accessKey),o.secretKey&&(r["ALKS-STS-Secret-Key"]=o.secretKey,delete o.secretKey),o.sessionToken&&(r["ALKS-STS-Session-Token"]=o.sessionToken,delete o.sessionToken);var c=o._fetch(o.baseUrl+"/"+e+"/",{method:n,headers:r,body:"GET"==n?void 0:JSON.stringify(o)}),i=c.then(function(e){return e.json()}).catch(function(){});return Promise.all([c,i]).then(function(e){var t=e[0],n=e[1];if(!t.ok)throw new u(t,n);return n})};var o=function(n,e){return e.reduce(function(e,t){return e[t]=n[t],e},{})},u=function(r){function e(e,t){var n=Array.isArray(t.errors)?t.errors:[];e.statusText&&n.unshift(e.statusText);var o=n.join("; ");r.call(this,o),this.status=e.status,this.message=o,Object.assign(this,t)}return r&&(e.__proto__=r),(e.prototype=Object.create(r&&r.prototype)).constructor=e}(Error);return new t}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).alks=t()}(this,function(){"use strict";var n=window.fetch.bind(window),t=function(e,t){void 0===t&&(t={}),this.defaults=Object.assign({},t,{_fetch:n},e)};t.prototype._base64Encode=function(e){return void 0===e&&(e=""),btoa(e)},t.prototype.create=function(e){return new t(e,this.defaults)},t.prototype.getAccounts=function(e){return this._doFetch("getAccounts",e).then(function(t){return Object.keys(t.accountListRole).map(function(e){return{account:e,role:t.accountListRole[e][0].role,iamKeyActive:t.accountListRole[e][0].iamKeyActive,maxKeyDuration:t.accountListRole[e][0].maxKeyDuration,skypieaAccount:t.accountListRole[e][0].skypieaAccount}})})},t.prototype.getKeys=function(e){return this._doFetch("getKeys",e).then(function(e){return o(e,["accessKey","secretKey","sessionToken","consoleURL"])})},t.prototype.getIAMKeys=function(e){return this._doFetch("getIAMKeys",e).then(function(e){return o(e,["accessKey","secretKey","sessionToken","consoleURL"])})},t.prototype.getAllAWSRoleTypes=function(e){var t=e.getDynamicValues?"allAwsRoleTypes?getDynamicValues=true":"allAwsRoleTypes";return this._doFetch(t,e,"GET").then(function(e){return e.roleTypes})},t.prototype.getAWSRoleTypes=function(e){return this._doFetch("getAWSRoleTypes",e).then(function(e){return JSON.parse(e.roleTypes)})},t.prototype.getNonServiceAWSRoleTypes=function(e){return this._doFetch("getNonServiceAWSRoleTypes",e).then(function(e){return JSON.parse(e.roleTypes)})},t.prototype.createRole=function(e){return this._doFetch("createRole",e).then(function(e){return e.denyArns=e.denyArns.split(","),o(e,["roleArn","denyArns","instanceProfileArn","addedRoleToInstanceProfile"])})},t.prototype.createNonServiceRole=function(e){return this._doFetch("createNonServiceRole",e).then(function(e){return e.denyArns=e.denyArns.split(","),o(e,["roleArn","denyArns","instanceProfileArn","addedRoleToInstanceProfile"])})},t.prototype.awsAccountRoles=function(e){return this._doFetch("awsAccountRoles?account="+e.account,e,"GET").then(function(e){return e.awsRoleList})},t.prototype.listAWSAccountRoles=function(e){return this._doFetch("listAWSAccountRoles",e).then(function(e){return JSON.parse(e.jsonAWSRoleList).map(function(e){return e.split("/").slice(-1)[0]})})},t.prototype.getAccountRole=function(t){return this._doFetch("getAccountRole",t).then(function(e){if(!e.roleExists)throw new Error("Role "+t.roleName+" does not exist in this account");return e.roleARN})},t.prototype.deleteRole=function(e){return this._doFetch("deleteRole",e).then(function(){return!0})},t.prototype.addRoleMachineIdentity=function(e){return this._doFetch("roleMachineIdentity",e).then(function(e){return o(e,["machineIdentityArn"])})},t.prototype.deleteRoleMachineIdentity=function(e){return this._doFetch("roleMachineIdentity",e,"DELETE").then(function(e){return o(e,["machineIdentityArn"])})},t.prototype.getUserAccess=function(e){var t=e.accountId;return this._doFetch("userAccess/"+t,e,"GET").then(function(e){return e.users})},t.prototype.getUserAccessByRole=function(e){var t=e.accountId;return this._doFetch("reports/users-by-role?accountId="+t,e,"GET").then(function(e){return e.users})},t.prototype.getUserRoleAccess=function(e){var t=e.accountId;return this._doFetch("userAccess/roles/"+t,e).then(function(e){return e.roles})},t.prototype.getAccountOwners=function(e){var t=e.accountId;return this._doFetch("userAccess/owners/"+t,e,"GET").then(function(e){return e.accountOwners})},t.prototype.createAccessKeys=function(e){return this._doFetch("accessKeys",e).then(function(e){return o(e,["iamUserArn","accessKey","secretKey","addedIAMUserToGroup"])})},t.prototype.deleteIAMUser=function(e){return this._doFetch("IAMUser",e,"DELETE").then(function(){return!0})},t.prototype.version=function(e){return this._doFetch("version",e,"GET").then(function(e){return o(e,["version"])})},t.prototype.getLoginRole=function(e){var t=e.accountId,n=e.role;return this._doFetch("loginRoles/id/"+t+"/"+n,null).then(function(e){return o(e,["account","role","iamKeyActive","maxKeyDuration"])})},t.prototype.getAccessToken=function(e){return this._doFetch("accessToken",e).then(function(e){return o(e,["accessToken","expiresIn"])})},t.prototype.getRefreshTokens=function(e){return this._doFetch("refreshTokens",e,"GET").then(function(e){return e.refreshTokens.map(function(e){return o(e,["clientId","id","userId","value"])})})},t.prototype.revoke=function(e){return this._doFetch("revoke",e).then(function(e){return"Success"==e.statusMessage})},t.prototype._doFetch=function(e,t,n){void 0===t&&(t={}),void 0===n&&(n="POST");var o=Object.assign({},this.defaults,t),r={"Content-Type":"application/json","User-Agent":"AlksJS/1.11.4"};if(o.accessToken&&(r.Authorization="Bearer "+o.accessToken,delete o.accessToken),o.userid||o.password){console.error("The userid and password properties are deprecated and should be replaced with an access token");var s=this._base64Encode(o.userid+":"+o.password);r.Authorization="Basic "+s,delete o.userid,delete o.password}o.accessKey&&(r["ALKS-STS-Access-Key"]=o.accessKey,delete o.accessKey),o.secretKey&&(r["ALKS-STS-Secret-Key"]=o.secretKey,delete o.secretKey),o.sessionToken&&(r["ALKS-STS-Session-Token"]=o.sessionToken,delete o.sessionToken);var c=o._fetch(o.baseUrl+"/"+e,{method:n,headers:r,body:"GET"==n?void 0:JSON.stringify(o)}),i=c.then(function(e){return e.json()}).catch(function(){});return Promise.all([c,i]).then(function(e){var t=e[0],n=e[1];if(!t.ok)throw new u(t,n);return n})};var o=function(n,e){return e.reduce(function(e,t){return e[t]=n[t],e},{})},u=function(r){function e(e,t){var n=Array.isArray(t.errors)?t.errors:[];e.statusText&&n.unshift(e.statusText);var o=n.join("; ");r.call(this,o),this.status=e.status,this.message=o,Object.assign(this,t)}return r&&(e.__proto__=r),(e.prototype=Object.create(r&&r.prototype)).constructor=e}(Error);return new t}); |
@@ -7,3 +7,3 @@ (function (global, factory) { | ||
var version = "1.11.3"; | ||
var version = "1.11.4"; | ||
@@ -833,3 +833,3 @@ var fetch = window.fetch.bind(window); | ||
var responsePromise = opts._fetch(((opts.baseUrl) + "/" + path + "/"), { | ||
var responsePromise = opts._fetch(((opts.baseUrl) + "/" + path), { | ||
method: method, headers: headers, body: method == 'GET' ? undefined : JSON.stringify(opts) | ||
@@ -836,0 +836,0 @@ }); |
{ | ||
"name": "alks.js", | ||
"version": "1.11.3", | ||
"version": "1.11.4", | ||
"description": "JavaScript client for the ALKS API, usable in both modern browsers and node.js", | ||
@@ -5,0 +5,0 @@ "main": "dist/alks.cjs.js", |
123227
-0.01%