@serverless/platform-sdk
Advanced tools
Comparing version 2.0.4 to 2.1.0
@@ -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 |
@@ -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", | ||
"description": "Serverless Platform SDK", | ||
@@ -5,0 +5,0 @@ "author": "Serverless, Inc.", |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
186103
91
2065