@spruceid/ssx-server
TypeScript icon, indicating that this package has built-in type declarations

2.1.0 • Public • Published

ssx-server

SSX Server is a server-side library made to work with the SSX client libraries. SSX-Server provides authentication and session management, which can be enabled via an ExpressJS middleware or using the methods provided on the SSXServer class.

Full documentation for the SSX-Server SDK can be found at docs.ssx.id.

Quickstart

You can add SSX to your server from npm:

yarn add @spruceid/ssx-server
# or
npm install @spruceid/ssx-server
# or
pnpm add @spruceid/ssx-server

Note: Looking for SSX support for other servers besides Express? Check out Configuring SSX on other Servers.

On your server, you'll need to create an instance of ssx-server and pass it to an Express middleware layer, as seen below. ssx-server doesn't require configuration parameters to use, however it's recommended to have the following variables set:

import express from 'express';
import { SSXServer, SSXExpressMiddleware } from '@spruceid/ssx-server';

const ssx = new SSXServer({
  signingKey: process.env.SSX_SIGNING_KEY,
  provider: {
    rpc: {
      service: 'infura',
      network: 'homestead',
      apiKey: process.env.INFURA_API_KEY ?? '',
    },
    metrics: {
      service: 'ssx',
      apiKey: process.env.SSX_API_TOKEN ?? '',
    },
  },
});

const app = express();

app.use(SSXExpressMiddleware(ssx));
app.listen(3001, () => {
  console.log(`⚡️[server]: Server is running at http://localhost:${3001}`);
});

Readme

Keywords

none

Package Sidebar

Install

npm i @spruceid/ssx-server

Weekly Downloads

7

Version

2.1.0

License

Apache-2.0 OR MIT

Unpacked Size

62.7 kB

Total Files

35

Last publish

Collaborators

  • obstropolos
  • jszersze
  • skgbafa
  • chunningham
  • wycjs
  • sbihel
  • w4ll3
  • xtheosirian