Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@serverless/platform-sdk

Package Overview
Dependencies
Maintainers
1
Versions
102
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@serverless/platform-sdk - npm Package Compare versions

Comparing version 2.1.1 to 2.1.2-9-g14cd43f

dist/login/loginIdentity.js

9

dist/config.js

@@ -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

12

dist/fetch.js

@@ -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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc