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 0.4.0-beta-2-gc07b199 to 0.4.0-beta-21-gc49dcd4

dist/accessKeys/accessKeys.js

14

dist/accessKeys/index.js

@@ -7,12 +7,16 @@ 'use strict';

var _createAccessKey = require('./createAccessKey');
var _accessKeys = require('./accessKeys');
Object.defineProperty(exports, 'createAccessKey', {
Object.defineProperty(exports, 'createAccessKeyForTenant', {
enumerable: true,
get: function get() {
return _interopRequireDefault(_createAccessKey).default;
return _accessKeys.createAccessKeyForTenant;
}
});
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
Object.defineProperty(exports, 'getAccessKeyForTenant', {
enumerable: true,
get: function get() {
return _accessKeys.getAccessKeyForTenant;
}
});
//# sourceMappingURL=index.js.map

@@ -13,8 +13,8 @@ 'use strict';

var _require = require('../rcfile'),
getUser = _require.getUser;
var _require = require('../accessKeys'),
getAccessKeyForTenant = _require.getAccessKeyForTenant;
var getApp = function () {
var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(data) {
var token, user, response, text;
var token, response, text;
return regeneratorRuntime.wrap(function _callee$(_context) {

@@ -26,21 +26,8 @@ while (1) {

if (token) {
_context.next = 6;
break;
}
user = getUser();
if (user) {
_context.next = 5;
break;
if (!token) {
token = getAccessKeyForTenant(data.tenant);
}
return _context.abrupt('return', Promise.reject('User is not logged in to the Platform.'));
case 5:
token = user.idToken;
case 6:
_context.next = 8;
_context.next = 4;
return fetch(`${platformConfig.backendUrl}tenants/${data.tenant}/applications/${data.app}`, {

@@ -55,21 +42,21 @@ method: 'GET',

case 8:
case 4:
response = _context.sent;
if (response.ok) {
_context.next = 14;
_context.next = 10;
break;
}
_context.next = 12;
_context.next = 8;
return response.text();
case 12:
case 8:
text = _context.sent;
throw new Error(text);
case 14:
case 10:
return _context.abrupt('return', response.json());
case 15:
case 11:
case 'end':

@@ -76,0 +63,0 @@ return _context.stop();

@@ -8,4 +8,4 @@ 'use strict';

frontendUrl: 'http://localhost:3000/',
backendUrl: 'https://a0xpn0swpd.execute-api.us-east-1.amazonaws.com/dev/',
logDestinationUrl: 'https://7zwgcvkt9k.execute-api.us-east-1.amazonaws.com/dev/',
backendUrl: 'https://api.serverless-dev.com/core/',
logDestinationUrl: 'https://api.serverless-dev.com/malt/',
auth0Domain: 'serverlessdev.auth0.com',

@@ -16,4 +16,4 @@ auth0ClientId: 'EMAtx5b2Bf3PB94c3pm9nrADxpFvyZcm'

frontendUrl: 'https://deploy-preview-281--eg-dashboard-dev.netlify.com/',
backendUrl: 'https://a0xpn0swpd.execute-api.us-east-1.amazonaws.com/dev/',
logDestinationUrl: 'https://7zwgcvkt9k.execute-api.us-east-1.amazonaws.com/dev/',
backendUrl: 'https://api.serverless-dev.com/core/',
logDestinationUrl: 'https://api.serverless-dev.com/malt/',
auth0Domain: 'serverlessdev.auth0.com',

@@ -24,4 +24,4 @@ auth0ClientId: 'EMAtx5b2Bf3PB94c3pm9nrADxpFvyZcm'

frontendUrl: 'https://dashboard.serverless-dev.com/',
backendUrl: 'https://a0xpn0swpd.execute-api.us-east-1.amazonaws.com/dev/',
logDestinationUrl: 'https://7zwgcvkt9k.execute-api.us-east-1.amazonaws.com/dev/',
backendUrl: 'https://api.serverless-dev.com/core/',
logDestinationUrl: 'https://api.serverless-dev.com/malt/',
auth0Domain: 'serverlessdev.auth0.com',

@@ -32,3 +32,4 @@ auth0ClientId: 'EMAtx5b2Bf3PB94c3pm9nrADxpFvyZcm'

frontendUrl: 'https://dashboard.serverless.com/',
backendUrl: 'https://jnvhp1any0.execute-api.us-east-1.amazonaws.com/prod/',
backendUrl: 'https://api.serverless.com/core/',
logDestinationUrl: 'https://api.serverless.com/malt/',
auth0Domain: 'serverlessinc.auth0.com',

@@ -35,0 +36,0 @@ auth0ClientId: 'YAHOG8papb1tkrLttNVoVOSs4YLOjrNj'

@@ -9,5 +9,10 @@ 'use strict';

/*
* Create Deployment
* - Creates a deployment record on the Serverless Enterprise Platform
*/
var fetch = require('isomorphic-fetch');
var currentVersion = require('../../package.json').version;
var platformConfig = require('../config');
var currentVersion = require('../../package.json').version;

@@ -25,3 +30,4 @@ var createDeployment = function () {

_context.next = 3;
return fetch(`${platformConfig.backendUrl}tenants/${data.tenant}/applications/${data.app}/services/${data.serviceName}/deployments`, {
return fetch(`${platformConfig.backendUrl}tenants/${data.tenant}/applications/${data.app}/services/${data.serviceName}/deployments`, // eslint-disable-line
{
method: 'POST',

@@ -28,0 +34,0 @@ body: JSON.stringify(body),

@@ -17,7 +17,8 @@ 'use strict';

var login = require('./login');
var logout = require('./logout');
var credentials = require('./credentials');
var rcfile = require('./rcfile');
var utils = require('./utils');
var logs = require('./logs');
module.exports = Object.assign({}, service, deployments, apps, tenants, accessKeys, login, credentials, rcfile, logs);
module.exports = Object.assign({}, service, deployments, apps, tenants, accessKeys, login, logout, credentials, utils, logs);
//# sourceMappingURL=index.js.map

@@ -5,2 +5,8 @@ 'use strict';

/*
* Login
* - Logs user in via CLI.
* - Loads and updates data in user's .serverlessrc.
*/
var express = require('express');

@@ -10,3 +16,10 @@ var bodyParser = require('body-parser');

var querystring = require('querystring');
var jwtDecode = require('jwt-decode');
var currentSdkVersion = require('../../package.json').version;
var utils = require('../utils');
var openBrowser = require('./openBrowser');
var _require = require('../accessKeys'),
createAccessKeyForTenant = _require.createAccessKeyForTenant;
var getTokens = require('./getTokens');

@@ -16,8 +29,21 @@ var platformConfig = require('../config');

var login = function () {
var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
var app, server, refreshToken, scope, AUTH0_DOMAIN, auth0Queries, auth0Endpoint, opnRes;
return regeneratorRuntime.wrap(function _callee2$(_context2) {
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) {
while (1) {
switch (_context2.prev = _context2.next) {
switch (_context3.prev = _context3.next) {
case 0:
// Load local configuration file
configFile = utils.readConfigFile();
if (configFile) {
_context3.next = 3;
break;
}
throw new Error(`Serverless Enterprise requires a .serverlessrc file in the project's directory or root directory of this machine.`);
case 3:
// Start local server to aide CLI sign-in/up
app = express();

@@ -39,8 +65,8 @@

auth0Endpoint = `https://${AUTH0_DOMAIN}/authorize?${auth0Queries}`;
_context2.next = 11;
_context3.next = 14;
return openBrowser(auth0Endpoint);
case 11:
opnRes = _context2.sent;
return _context2.abrupt('return', new Promise(function (resolve) {
case 14:
opnRes = _context3.sent;
return _context3.abrupt('return', new Promise(function (resolve) {
app.get('/', function () {

@@ -109,17 +135,85 @@ var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(req, res) {

return function (_x, _x2) {
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 = jwtDecode(data.idToken);
id = decoded.tracking_id || decoded.sub;
case 13:
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 = currentSdkVersion;
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) {
_context2.next = 16;
break;
}
_context2.next = 14;
return 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 16:
case 'end':
return _context2.stop();
return _context3.stop();
}
}
}, _callee2, undefined);
}, _callee3, undefined);
}));
return function login() {
return function login(_x) {
return _ref.apply(this, arguments);

@@ -126,0 +220,0 @@ };

@@ -15,2 +15,6 @@ 'use strict';

var _utils = require('../utils');
var _utils2 = _interopRequireDefault(_utils);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -27,4 +31,5 @@

regionName = _ref.regionName,
accountId = _ref.accountId;
var body, response, text;
accountId = _ref.accountId,
token = _ref.token;
var user, body, response, text;
return regeneratorRuntime.wrap(function _callee$(_context) {

@@ -34,2 +39,20 @@ while (1) {

case 0:
if (token) {
_context.next = 5;
break;
}
user = _utils2.default.getLoggedInUser();
if (user) {
_context.next = 4;
break;
}
return _context.abrupt('return', Promise.reject('User is not logged in to the Platform.'));
case 4:
token = user.idToken;
case 5:
body = JSON.stringify({

@@ -43,3 +66,3 @@ tenantUid,

});
_context.next = 3;
_context.next = 8;
return (0, _isomorphicFetch2.default)(`${_config2.default.logDestinationUrl}destinations/create`, {

@@ -49,25 +72,26 @@ method: 'POST',

headers: {
'Content-Type': 'application/json'
'Content-Type': 'application/json',
Authorization: `bearer ${token}`
}
});
case 3:
case 8:
response = _context.sent;
if (response.ok) {
_context.next = 9;
_context.next = 14;
break;
}
_context.next = 7;
_context.next = 12;
return response.text();
case 7:
case 12:
text = _context.sent;
throw new Error(text);
case 9:
case 14:
return _context.abrupt('return', response.json());
case 10:
case 15:
case 'end':

@@ -74,0 +98,0 @@ return _context.stop();

@@ -15,2 +15,6 @@ 'use strict';

var _utils = require('../utils');
var _utils2 = _interopRequireDefault(_utils);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -26,4 +30,5 @@

stageName = _ref.stageName,
regionName = _ref.regionName;
var body, response, text;
regionName = _ref.regionName,
token = _ref.token;
var user, body, response, text;
return regeneratorRuntime.wrap(function _callee$(_context) {

@@ -33,2 +38,20 @@ while (1) {

case 0:
if (token) {
_context.next = 5;
break;
}
user = _utils2.default.getLoggedInUser();
if (user) {
_context.next = 4;
break;
}
return _context.abrupt('return', Promise.reject('User is not logged in to the Platform.'));
case 4:
token = user.idToken;
case 5:
body = JSON.stringify({

@@ -41,3 +64,3 @@ tenantUid,

});
_context.next = 3;
_context.next = 8;
return (0, _isomorphicFetch2.default)(`${_config2.default.logDestinationUrl}destinations/delete`, {

@@ -47,25 +70,26 @@ method: 'POST',

headers: {
'Content-Type': 'application/json'
'Content-Type': 'application/json',
Authorization: `bearer ${token}`
}
});
case 3:
case 8:
response = _context.sent;
if (response.ok) {
_context.next = 9;
_context.next = 14;
break;
}
_context.next = 7;
_context.next = 12;
return response.text();
case 7:
case 12:
text = _context.sent;
throw new Error(text);
case 9:
case 14:
return _context.abrupt('return');
case 10:
case 15:
case 'end':

@@ -72,0 +96,0 @@ return _context.stop();

{
"name": "@serverless/platform-sdk",
"version": "0.4.0-beta-2-gc07b199",
"version": "0.4.0-beta-21-gc49dcd4",
"description": "Serverless Platform SDK",

@@ -31,3 +31,2 @@ "author": "Serverless, Inc.",

"babel-polyfill": "^6.26.0",
"source-map-support": "^0.5.5",
"body-parser": "^1.18.3",

@@ -39,5 +38,9 @@ "chalk": "^2.4.1",

"isomorphic-fetch": "^2.2.1",
"jwt-decode": "^2.2.0",
"opn": "^5.3.0",
"querystring": "^0.2.0",
"ramda": "^0.25.0"
"ramda": "^0.25.0",
"rc": "^1.2.8",
"source-map-support": "^0.5.5",
"write-file-atomic": "^2.3.0"
},

@@ -44,0 +47,0 @@ "devDependencies": {

# Platform SDK
Functional SDK for the Serverless Platfrom.

@@ -3,0 +4,0 @@

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

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