@serverless/platform-sdk
Advanced tools
Comparing version 2.1.1 to 2.1.2-9-g14cd43f
@@ -9,2 +9,3 @@ 'use strict'; | ||
backendUrl: 'https://api.serverless-dev.com/core/', | ||
loginBrokerUrl: 'https://api.serverless-dev.com/login/', | ||
logDestinationUrl: 'https://api.serverless-dev.com/malt/', | ||
@@ -17,2 +18,3 @@ auth0Domain: 'serverlessdev.auth0.com', | ||
backendUrl: 'https://api.serverless-dev.com/core/', | ||
loginBrokerUrl: 'https://api.serverless-dev.com/login/', | ||
logDestinationUrl: 'https://api.serverless-dev.com/malt/', | ||
@@ -25,2 +27,3 @@ auth0Domain: 'serverlessdev.auth0.com', | ||
backendUrl: 'https://api.serverless-dev.com/core/', | ||
loginBrokerUrl: 'https://api.serverless-dev.com/login/', | ||
logDestinationUrl: 'https://api.serverless-dev.com/malt/', | ||
@@ -33,2 +36,3 @@ auth0Domain: 'serverlessdev.auth0.com', | ||
backendUrl: 'https://api.serverless-qa.com/core/', | ||
loginBrokerUrl: 'https://api.serverless-qa.com/login/', | ||
logDestinationUrl: 'https://api.serverless-qa.com/malt/', | ||
@@ -41,2 +45,3 @@ auth0Domain: 'serverlessdev.auth0.com', | ||
backendUrl: 'https://api.serverless.com/core/', | ||
loginBrokerUrl: 'https://api.serverless.com/login/', | ||
logDestinationUrl: 'https://api.serverless.com/malt/', | ||
@@ -49,2 +54,6 @@ auth0Domain: 'serverlessinc.auth0.com', | ||
module.exports = config[platformStage]; | ||
if (process.env.SERVERLESS_PLATFORM_FRONTEND_URL) { | ||
module.exports.frontendUrl = process.env.SERVERLESS_PLATFORM_FRONTEND_URL; | ||
} | ||
//# sourceMappingURL=config.js.map |
@@ -6,2 +6,3 @@ 'use strict'; | ||
}); | ||
exports.getAgent = getAgent; | ||
exports.configureFetchDefaults = configureFetchDefaults; | ||
@@ -38,3 +39,3 @@ | ||
function configureFetchDefaults() { | ||
function getAgent() { | ||
// Use HTTPS Proxy (Optional) | ||
@@ -79,7 +80,12 @@ var proxy = process.env.proxy || process.env.HTTP_PROXY || process.env.http_proxy || process.env.HTTPS_PROXY || process.env.https_proxy; | ||
if (proxy) { | ||
agent = new _httpsProxyAgent2.default(agentOptions); | ||
return new _httpsProxyAgent2.default(agentOptions); | ||
} else if (agentOptions.ca) { | ||
agent = new _https2.default.Agent(agentOptions); | ||
return new _https2.default.Agent(agentOptions); | ||
} | ||
return undefined; | ||
} | ||
function configureFetchDefaults() { | ||
agent = getAgent(); | ||
headers = { | ||
@@ -86,0 +92,0 @@ 'Content-Type': 'application/json', |
@@ -16,2 +16,11 @@ 'use strict'; | ||
var _loginIdentity = require('./loginIdentity'); | ||
Object.defineProperty(exports, 'loginIdentity', { | ||
enumerable: true, | ||
get: function get() { | ||
return _interopRequireDefault(_loginIdentity).default; | ||
} | ||
}); | ||
var _getTokens = require('./getTokens'); | ||
@@ -18,0 +27,0 @@ |
'use strict'; | ||
var _express = require('express'); | ||
var _express2 = _interopRequireDefault(_express); | ||
var _bodyParser = require('body-parser'); | ||
var _bodyParser2 = _interopRequireDefault(_bodyParser); | ||
var _querystring = require('querystring'); | ||
@@ -31,6 +23,2 @@ | ||
var _getTokens = require('./getTokens'); | ||
var _getTokens2 = _interopRequireDefault(_getTokens); | ||
var _config = require('../config'); | ||
@@ -40,2 +28,6 @@ | ||
var _loginIdentity = require('./loginIdentity'); | ||
var _loginIdentity2 = _interopRequireDefault(_loginIdentity); | ||
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; } } | ||
@@ -52,7 +44,7 @@ | ||
var login = function () { | ||
var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(tenant) { | ||
var configFile, app, server, refreshToken, scope, AUTH0_DOMAIN, auth0Queries, auth0Endpoint, opnRes; | ||
return regeneratorRuntime.wrap(function _callee3$(_context3) { | ||
var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(tenant) { | ||
var configFile, loginIdentityPromises, transactionId, scope, AUTH0_DOMAIN, auth0Queries, auth0Endpoint, data, decoded, id, updatedConfigFile, accessKey; | ||
return regeneratorRuntime.wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context3.prev = _context3.next) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
@@ -63,3 +55,3 @@ // Load local configuration file | ||
if (configFile) { | ||
_context3.next = 3; | ||
_context.next = 3; | ||
break; | ||
@@ -71,9 +63,8 @@ } | ||
case 3: | ||
loginIdentityPromises = (0, _loginIdentity2.default)(); | ||
_context.next = 6; | ||
return loginIdentityPromises.transactionId; | ||
// Start local server to aide CLI sign-in/up | ||
app = (0, _express2.default)(); | ||
app.use(_bodyParser2.default.json()); | ||
server = app.listen(8000); | ||
refreshToken = void 0; | ||
case 6: | ||
transactionId = _context.sent; | ||
scope = ['openid', 'email_verified', 'email', 'profile', 'name', 'offline_access']; | ||
@@ -85,165 +76,76 @@ AUTH0_DOMAIN = _config2.default.auth0Domain; | ||
client_id: _config2.default.auth0ClientId, | ||
redirect_uri: `${_config2.default.frontendUrl}callback`, | ||
redirect_uri: `${_config2.default.frontendUrl}callback?transactionId=${transactionId}`, | ||
scope: scope.join(' ') | ||
}); | ||
auth0Endpoint = `https://${AUTH0_DOMAIN}/authorize?${auth0Queries}`; | ||
_context3.next = 13; | ||
_context.next = 13; | ||
return (0, _openBrowser2.default)(auth0Endpoint); | ||
case 13: | ||
opnRes = _context3.sent; | ||
return _context3.abrupt('return', new Promise(function (resolve, reject) { | ||
app.get('/', function () { | ||
var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(req, res) { | ||
var tokens, queriesObj, tokensQueries, endLoginQueries, _tokens; | ||
_context.next = 15; | ||
return loginIdentityPromises.loginData; | ||
return regeneratorRuntime.wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
// eslint-disable-line | ||
if (opnRes) { | ||
opnRes.kill(); | ||
} | ||
case 15: | ||
data = _context.sent; | ||
decoded = (0, _jwtDecode2.default)(data.id_token); | ||
id = decoded.tracking_id || decoded.sub; | ||
if (!req.query.unverified) { | ||
_context.next = 5; | ||
break; | ||
} | ||
configFile.userId = id; | ||
configFile.users = configFile.users || {}; | ||
configFile.users[id] = { | ||
userId: id, | ||
name: decoded.name, | ||
email: decoded.email, | ||
username: data.username, | ||
dashboard: { | ||
refreshToken: data.refresh_token, | ||
accessToken: data.access_token, | ||
idToken: data.id_token, | ||
expiresAt: Date.now() + data.expires_in, | ||
username: decoded.nickname | ||
} | ||
res.end(); | ||
server.close(); | ||
return _context.abrupt('return', reject('Complete sign-up before logging in.')); | ||
// Ensure accessKeys object exists | ||
};if (!configFile.users[id].dashboard.accessKeys) { | ||
configFile.users[id].dashboard.accessKeys = {}; | ||
} | ||
case 5: | ||
if (!req.query.code) { | ||
_context.next = 16; | ||
break; | ||
} | ||
// Add enterprise object | ||
configFile.users[id].enterprise = configFile.users[id].enterprise || {}; | ||
configFile.users[id].enterprise.versionSDK = _package.version; | ||
configFile.users[id].enterprise.timeLastLogin = Math.round(+new Date() / 1000); | ||
_context.next = 8; | ||
return (0, _getTokens2.default)(req.query.code); | ||
// Write updated data to .serverlessrc | ||
updatedConfigFile = utils.writeConfigFile(configFile); | ||
case 8: | ||
tokens = _context.sent; | ||
// If tenant is included, update config w/ new accesskey for that tenant | ||
refreshToken = tokens.refresh_token; | ||
queriesObj = { | ||
idToken: tokens.id_token, | ||
accessToken: tokens.access_token, | ||
expiresIn: tokens.expires_in, | ||
cli: true, | ||
cliAuthed: true | ||
}; | ||
tokensQueries = _querystring2.default.stringify(queriesObj); | ||
accessKey = void 0; | ||
res.redirect(`${_config2.default.frontendUrl}callback?${tokensQueries}`); | ||
res.end(); | ||
_context.next = 23; | ||
break; | ||
if (!(tenant && tenant !== 'tenantname')) { | ||
_context.next = 32; | ||
break; | ||
} | ||
case 16: | ||
endLoginQueries = _querystring2.default.stringify({ | ||
cli: 'true', | ||
cliLoginSuccessful: 'true' | ||
}); | ||
_context.next = 30; | ||
return (0, _accessKeys.createAccessKeyForTenant)(tenant); | ||
res.redirect(`${_config2.default.frontendUrl}?${endLoginQueries}`); | ||
res.end(); | ||
server.close(); | ||
_tokens = Object.assign({ | ||
refreshToken | ||
}, req.query); | ||
case 30: | ||
accessKey = _context.sent; | ||
_tokens.expiresAt = Number(req.query.expiresAt); | ||
return _context.abrupt('return', resolve(_tokens)); | ||
if (accessKey) { | ||
configFile = utils.readConfigFile(); | ||
configFile.users[id].dashboard.accessKeys[tenant] = accessKey; | ||
updatedConfigFile = utils.writeConfigFile(configFile); | ||
} | ||
case 23: | ||
case 'end': | ||
return _context.stop(); | ||
} | ||
} | ||
}, _callee, undefined); | ||
})); | ||
case 32: | ||
return _context.abrupt('return', updatedConfigFile); | ||
return function (_x2, _x3) { | ||
return _ref2.apply(this, arguments); | ||
}; | ||
}()); | ||
}).then(function () { | ||
var _ref3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(data) { | ||
var decoded, id, updatedConfigFile, accessKey; | ||
return regeneratorRuntime.wrap(function _callee2$(_context2) { | ||
while (1) { | ||
switch (_context2.prev = _context2.next) { | ||
case 0: | ||
// Update user's config file (.serverlessrc) | ||
decoded = (0, _jwtDecode2.default)(data.idToken); | ||
id = decoded.tracking_id || decoded.sub; | ||
configFile.userId = id; | ||
configFile.users = configFile.users || {}; | ||
configFile.users[id] = { | ||
userId: id, | ||
name: decoded.name, | ||
email: decoded.email, | ||
username: data.username, | ||
dashboard: data | ||
// Ensure accessKeys object exists | ||
};if (!configFile.users[id].dashboard.accessKeys) { | ||
configFile.users[id].dashboard.accessKeys = {}; | ||
} | ||
// Add enterprise object | ||
configFile.users[id].enterprise = configFile.users[id].enterprise || {}; | ||
configFile.users[id].enterprise.versionSDK = _package.version; | ||
configFile.users[id].enterprise.timeLastLogin = Math.round(+new Date() / 1000); | ||
// Write updated data to .serverlessrc | ||
updatedConfigFile = utils.writeConfigFile(configFile); | ||
// If tenant is included, update config w/ new accesskey for that tenant | ||
accessKey = void 0; | ||
if (!(tenant && tenant !== 'tenantname')) { | ||
_context2.next = 16; | ||
break; | ||
} | ||
_context2.next = 14; | ||
return (0, _accessKeys.createAccessKeyForTenant)(tenant); | ||
case 14: | ||
accessKey = _context2.sent; | ||
if (accessKey) { | ||
configFile = utils.readConfigFile(); | ||
configFile.users[id].dashboard.accessKeys[tenant] = accessKey; | ||
updatedConfigFile = utils.writeConfigFile(configFile); | ||
} | ||
case 16: | ||
return _context2.abrupt('return', updatedConfigFile); | ||
case 17: | ||
case 'end': | ||
return _context2.stop(); | ||
} | ||
} | ||
}, _callee2, undefined); | ||
})); | ||
return function (_x4) { | ||
return _ref3.apply(this, arguments); | ||
}; | ||
}())); | ||
case 15: | ||
case 33: | ||
case 'end': | ||
return _context3.stop(); | ||
return _context.stop(); | ||
} | ||
} | ||
}, _callee3, undefined); | ||
}, _callee, undefined); | ||
})); | ||
@@ -250,0 +152,0 @@ |
{ | ||
"name": "@serverless/platform-sdk", | ||
"version": "2.1.1", | ||
"version": "2.1.2-9-g14cd43f", | ||
"description": "Serverless Platform SDK", | ||
@@ -30,6 +30,4 @@ "author": "Serverless, Inc.", | ||
"dependencies": { | ||
"body-parser": "^1.19.0", | ||
"chalk": "^2.4.1", | ||
"express": "^4.16.3", | ||
"https-proxy-agent": "^2.2.2", | ||
"https-proxy-agent": "^3.0.0", | ||
"is-docker": "^1.1.0", | ||
@@ -45,3 +43,4 @@ "isomorphic-fetch": "^2.2.1", | ||
"uuid": "^3.3.2", | ||
"write-file-atomic": "^2.4.2" | ||
"write-file-atomic": "^2.4.2", | ||
"ws": "<7.0.0" | ||
}, | ||
@@ -48,0 +47,0 @@ "devDependencies": { |
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
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
187630
14
93
2077
1
+ Addedws@<7.0.0
+ Addedasync-limiter@1.0.1(transitive)
+ Addedhttps-proxy-agent@3.0.1(transitive)
+ Addedws@6.2.3(transitive)
- Removedbody-parser@^1.19.0
- Removedexpress@^4.16.3
- Removedaccepts@1.3.8(transitive)
- Removedarray-flatten@1.1.1(transitive)
- Removedbody-parser@1.20.3(transitive)
- Removedbytes@3.1.2(transitive)
- Removedcall-bind@1.0.7(transitive)
- Removedcontent-disposition@0.5.4(transitive)
- Removedcontent-type@1.0.5(transitive)
- Removedcookie@0.7.1(transitive)
- Removedcookie-signature@1.0.6(transitive)
- Removeddebug@2.6.9(transitive)
- Removeddefine-data-property@1.1.4(transitive)
- Removeddepd@2.0.0(transitive)
- Removeddestroy@1.2.0(transitive)
- Removedee-first@1.1.1(transitive)
- Removedencodeurl@1.0.22.0.0(transitive)
- Removedes-define-property@1.0.0(transitive)
- Removedes-errors@1.3.0(transitive)
- Removedescape-html@1.0.3(transitive)
- Removedetag@1.8.1(transitive)
- Removedexpress@4.21.1(transitive)
- Removedfinalhandler@1.3.1(transitive)
- Removedforwarded@0.2.0(transitive)
- Removedfresh@0.5.2(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedget-intrinsic@1.2.4(transitive)
- Removedgopd@1.1.0(transitive)
- Removedhas-property-descriptors@1.0.2(transitive)
- Removedhas-proto@1.1.0(transitive)
- Removedhas-symbols@1.1.0(transitive)
- Removedhasown@2.0.2(transitive)
- Removedhttp-errors@2.0.0(transitive)
- Removedhttps-proxy-agent@2.2.4(transitive)
- Removediconv-lite@0.4.24(transitive)
- Removedinherits@2.0.4(transitive)
- Removedipaddr.js@1.9.1(transitive)
- Removedmedia-typer@0.3.0(transitive)
- Removedmerge-descriptors@1.0.3(transitive)
- Removedmethods@1.1.2(transitive)
- Removedmime@1.6.0(transitive)
- Removedmime-db@1.52.0(transitive)
- Removedmime-types@2.1.35(transitive)
- Removedms@2.0.0(transitive)
- Removednegotiator@0.6.3(transitive)
- Removedobject-inspect@1.13.3(transitive)
- Removedon-finished@2.4.1(transitive)
- Removedparseurl@1.3.3(transitive)
- Removedpath-to-regexp@0.1.10(transitive)
- Removedproxy-addr@2.0.7(transitive)
- Removedqs@6.13.0(transitive)
- Removedrange-parser@1.2.1(transitive)
- Removedraw-body@2.5.2(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedsend@0.19.0(transitive)
- Removedserve-static@1.16.2(transitive)
- Removedset-function-length@1.2.2(transitive)
- Removedsetprototypeof@1.2.0(transitive)
- Removedside-channel@1.0.6(transitive)
- Removedstatuses@2.0.1(transitive)
- Removedtoidentifier@1.0.1(transitive)
- Removedtype-is@1.6.18(transitive)
- Removedunpipe@1.0.0(transitive)
- Removedutils-merge@1.0.1(transitive)
- Removedvary@1.1.2(transitive)
Updatedhttps-proxy-agent@^3.0.0