@serverless/platform-sdk
Advanced tools
Comparing version 2.0.4 to 2.1.0-2-g9c4c9d4
@@ -116,15 +116,37 @@ 'use strict'; | ||
// Check if in config file, return that next... | ||
// Check if in config file, if not, & if possible, create one | ||
if (!(!user.accessKeys || !user.accessKeys[tenant])) { | ||
_context2.next = 9; | ||
_context2.next = 16; | ||
break; | ||
} | ||
throw new Error(`Could not find an access key for tenant ${tenant}. Log out and log in again to create a new access key for this tenant.`); | ||
if (!user.idToken) { | ||
_context2.next = 15; | ||
break; | ||
} | ||
case 9: | ||
_context2.next = 11; | ||
return createAccessKeyForTenant(tenant); | ||
case 11: | ||
user.accessKeys[tenant] = _context2.sent; | ||
utils.writeConfigFile({ | ||
users: { | ||
[user.userId]: { | ||
dashboard: { accessKeys: { [tenant]: user.accessKeys[tenant] } } | ||
} | ||
} | ||
}); | ||
_context2.next = 16; | ||
break; | ||
case 15: | ||
throw new Error(`Could not find an access key for tenant ${tenant}. Log out and log in again to create a new acce ss key for this tenant.`); | ||
case 16: | ||
return _context2.abrupt('return', user.accessKeys[tenant]); | ||
case 10: | ||
case 17: | ||
case 'end': | ||
@@ -131,0 +153,0 @@ return _context2.stop(); |
@@ -16,3 +16,30 @@ 'use strict'; | ||
var _getDeployProfiles = require('./getDeployProfiles'); | ||
Object.defineProperty(exports, 'getDeployProfiles', { | ||
enumerable: true, | ||
get: function get() { | ||
return _interopRequireDefault(_getDeployProfiles).default; | ||
} | ||
}); | ||
var _setDefaultDeploymentProfile = require('./setDefaultDeploymentProfile'); | ||
Object.defineProperty(exports, 'setDefaultDeploymentProfile', { | ||
enumerable: true, | ||
get: function get() { | ||
return _interopRequireDefault(_setDefaultDeploymentProfile).default; | ||
} | ||
}); | ||
var _createDeploymentProfile = require('./createDeploymentProfile'); | ||
Object.defineProperty(exports, 'createDeploymentProfile', { | ||
enumerable: true, | ||
get: function get() { | ||
return _interopRequireDefault(_createDeploymentProfile).default; | ||
} | ||
}); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
//# sourceMappingURL=index.js.map |
@@ -20,2 +20,6 @@ 'use strict'; | ||
var _httpsProxyAgent = require('https-proxy-agent'); | ||
var _httpsProxyAgent2 = _interopRequireDefault(_httpsProxyAgent); | ||
var _utils = require('./utils'); | ||
@@ -25,2 +29,4 @@ | ||
var _url = require('url'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -34,2 +40,10 @@ | ||
function configureFetchDefaults() { | ||
// Use HTTPS Proxy (Optional) | ||
var proxy = process.env.proxy || process.env.HTTP_PROXY || process.env.http_proxy || process.env.HTTPS_PROXY || process.env.https_proxy; | ||
var agentOptions = {}; | ||
if (proxy) { | ||
Object.assign(agentOptions, (0, _url.parse)(proxy)); | ||
} | ||
var ca = process.env.ca || process.env.HTTPS_CA || process.env.https_ca; | ||
@@ -59,9 +73,14 @@ | ||
if (caCerts.length > 0) { | ||
var caOptions = { | ||
Object.assign(agentOptions, { | ||
rejectUnauthorized: true, | ||
ca: caCerts | ||
// Update the agent -- http://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/node-registering-certs.html | ||
};agent = new _https2.default.Agent(caOptions); | ||
}); | ||
} | ||
if (proxy) { | ||
agent = new _httpsProxyAgent2.default(agentOptions); | ||
} else if (agentOptions.ca) { | ||
agent = new _https2.default.Agent(agentOptions); | ||
} | ||
headers = { | ||
@@ -68,0 +87,0 @@ 'Content-Type': 'application/json', |
@@ -15,2 +15,6 @@ 'use strict'; | ||
var _jwtDecode = require('jwt-decode'); | ||
var _jwtDecode2 = _interopRequireDefault(_jwtDecode); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
@@ -24,3 +28,3 @@ | ||
var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() { | ||
var configFile, currentId, body, response, tokens, expiresAt; | ||
var configFile, currentId, decoded, body, response, tokens, expiresAt; | ||
return regeneratorRuntime.wrap(function _callee$(_context) { | ||
@@ -41,4 +45,8 @@ while (1) { | ||
case 4: | ||
if (!(Number(configFile.users[currentId].dashboard.expiresAt) > Date.now())) { | ||
_context.next = 6; | ||
// id token not expired, no need to renew | ||
decoded = (0, _jwtDecode2.default)(configFile.users[currentId].dashboard.idToken); | ||
if (!(Number(decoded.exp) * 1000 > Date.now())) { | ||
_context.next = 7; | ||
break; | ||
@@ -49,5 +57,5 @@ } | ||
case 6: | ||
case 7: | ||
body = JSON.stringify({ refreshToken: configFile.users[currentId].dashboard.refreshToken }); | ||
_context.next = 9; | ||
_context.next = 10; | ||
return (0, _fetch2.default)(`${_config2.default.backendUrl}tokens/refresh`, { | ||
@@ -58,8 +66,8 @@ method: 'POST', | ||
case 9: | ||
case 10: | ||
response = _context.sent; | ||
_context.next = 12; | ||
_context.next = 13; | ||
return response.json(); | ||
case 12: | ||
case 13: | ||
tokens = _context.sent; | ||
@@ -73,3 +81,3 @@ expiresAt = tokens.expires_in * 1000 + Date.now(); | ||
case 18: | ||
case 19: | ||
case 'end': | ||
@@ -76,0 +84,0 @@ return _context.stop(); |
{ | ||
"name": "@serverless/platform-sdk", | ||
"version": "2.0.4", | ||
"version": "2.1.0-2-g9c4c9d4", | ||
"description": "Serverless Platform SDK", | ||
@@ -33,2 +33,3 @@ "author": "Serverless, Inc.", | ||
"express": "^4.16.3", | ||
"https-proxy-agent": "^2.2.2", | ||
"is-docker": "^1.1.0", | ||
@@ -35,0 +36,0 @@ "isomorphic-fetch": "^2.2.1", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 5 instances in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
187471
91
2078
15
2
21
2
+ Addedhttps-proxy-agent@^2.2.2
+ Addedagent-base@4.3.0(transitive)
+ Addeddebug@3.2.7(transitive)
+ Addedes6-promise@4.2.8(transitive)
+ Addedes6-promisify@5.0.0(transitive)
+ Addedhttps-proxy-agent@2.2.4(transitive)