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

@serverless/platform-sdk

Package Overview
Dependencies
Maintainers
2
Versions
102
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@serverless/platform-sdk

Serverless Platform SDK

  • 0.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
37K
decreased by-26.3%
Maintainers
2
Weekly downloads
 
Created
Source

Platform SDK

Functional SDK for the Serverless Platfrom.

Project Status

Build Status license coverage

Contents

installation

npm i -s @serverless/platform-sdk

Functions

login

Opens a browser for the user to login, along with a running server awaiting auth data once the user logs in.

Parameters

None

Returns

Promise resolving to the following object:

  • username - string - dashboard username
  • accessToken - string - Auth0 access token
  • idToken - string - Auth0 idToken
  • refreshToken - string - Auth0 refreshToken
  • expiresAt - string - epoch time at which the idToken expires

Example

const { login } = require('@serverless/platform-sdk')

const { username, accessToken, idToken, expiresAt } = await login()

refreshToken

Refreshes Auth0 idToken

Parameters

refresh token string

Returns

Promise resolving to the following object:

  • id_token - string - new Auth0 id token
  • access_token - string - new Auth0 access token
  • expires_in - string - number of seconds until token expiration

Example

const { refreshToken } = require('@serverless/platform-sdk')

const { id_token, access_token, expires_in } = await refreshToken('some-refresh-token')

createAccessKey

Creates a platform access key for the authenticated user.

Parameters

Object

  • username - string - dashboard username
  • tenant - string - dashboard tenant
  • idToken - string - Auth0 idToken
  • title - string - title of the access key

Returns

Promise resolving to an accessKey string, that is the access key.

Example

const { createAccessKey } = require('@serverless/platform-sdk')

const data = {
  username: 'eahefnawy',
  tenant: 'eahefnawy',
  idToken: 'abc',
  title: 'Framework'
}

const accessKey = await createAccessKey(data)

publishService

Publishes a service to the platform.

Parameters

Object

  • tenant - string - dashboard tenant
  • accessKey - string - dashboard access key
  • app - string - service app
  • service - object - service object
    • name - string - service name
    • stage - string - service stage
    • ...any other service meta data
  • functions - array - list of functions to publish. Each array item is an object with the following structure:
    • functionId - string - unique function identifier
    • details - object - function details data
    • package - object - package details data
  • subscriptions - array - list of functions to publish. Each array item is an object with the following structure:
    • functionId - string - unique function identifier this subscription belongs to
    • subscriptionId - string - unique subscription identifier
    • type - string - type of subscription (ie. aws.s3.objectCreated or user.created)
    • event - object - event data

Returns

Promise resolving to a serviceUrl string that is the service url.

Example

const { publishService } = require('@serverless/platform-sdk')

const data = {
  tenant: 'eahefnawy',
  accessKey: 'abc',
  app: 'my-app',
  service: {
    name: 'my-service',
  },
  functions: [{
    functionId: 'abc',
    memory: 512
    ...
  }],
  subscriptions: [{
    functionId: 'abc',
    subscriptionId: 'abc',
    type: 'aws.apigateway.http',
    event: {
      path: 'users',
      method: 'get',
      ...
    }
  }]
}

const serviceUrl = await publishService(data)

archiveService

Archives a service in the platform.

Parameters

Object

  • tenant - string - dashboard tenant
  • accessKey - string - dashboard access key
  • app - string - service app
  • name - string - service name

Returns

None

Example

const { archiveService } = require('@serverless/platform-sdk')

const data = {
  tenant: 'eahefnawy',
  accessKey: 'abc',
  app: 'my-app',
  name: 'my-service'
}

await archiveService(data)

getServiceUrl

Constructs a service url based on passed-in data.

Parameters

Object

  • tenant - string - dashboard tenant
  • app - string - service app
  • name - string - service name

Returns

The service url string.

Example

const { getServiceUrl } = require('@serverless/platform-sdk')

const data = {
  tenant: 'eahefnawy',
  app: 'my-app',
  name: 'my-service'
}

const serviceUrl = getServiceUrl(data)

listTenants

Lists the tenants for a given username

Parameters

Object

  • username - string - dashboard username
  • idToken - string - auth0 user id token

Returns

Array of objects, each represents a single tenant data model.

Example

const { listTenants } = require('@serverless/platform-sdk')

const data = {
  username: 'eahefnawy',
  idToken: 'abc'
}

const tenants = await listTenants(data)

createDeploymnet

Creates a platform deployment

Parameters

Object

  • tenant - string - dashboard tenant name
  • app - string - app name
  • serviceName - string - service name
  • accessKey - string - dashboard access key

Returns

Object - Deployment model

Example

const { createDeployment } = require('@serverless/platform-sdk')

const data = {
  tenant: 'eahefnawy',
  app: 'my-app',
  serviceName: 'my-service',
  accessKey: 'abc'
}

const { id } = await createDeployment(data)

updateDeployment

Updates a platform deployment

Parameters

Object

  • tenant - string - dashboard tenant name
  • app - string - app name
  • serviceName - string - service name
  • deploymentId - string - id of the previously created deployment
  • status - string - status of the deployment to update
  • accessKey - string - dashboard access key
  • state - object - optional - state of the successful deployment.

Returns

Object - Deployment model

Example

const { updateDeployment } = require('@serverless/platform-sdk')

const data = {
  tenant: 'eahefnawy',
  app: 'my-app',
  serviceName: 'my-service',
  deploymentId: 'abc',
  status: 'Failed',
  accessKey: 'abc'
}

const { id } = await updateDeployment(data)

getApp

Gets a platform app

Parameters

Object

  • tenant - string - dashboard tenant name
  • app - string - app name
  • token - string - Auth0 id token

Returns

Object - App model

Example

const { getApp } = require('@serverless/platform-sdk')

const data = {
  tenant: 'eahefnawy',
  app: 'my-app',
  token: 'abc'
}

const app = await getApp(data)

createApp

Creates a platform app

Parameters

Object

  • tenant - string - dashboard tenant name
  • app - string - app name
  • token - string - Auth0 id token

Returns

Object - App model

Example

const { createApp } = require('@serverless/platform-sdk')

const data = {
  tenant: 'eahefnawy',
  app: 'my-app',
  token: 'abc'
}

const app = await createApp(data)

FAQs

Package last updated on 24 Jul 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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