remote-server package
Express router for exposing @veramo/remote-client
OpenAPI schema
Example
import express from 'express'
import { agent } from './agent'
import { AgentRouter, ApiSchemaRouter, WebDidDocRouter } from '@veramo/remote-server'
const getAgentForRequest = async (req: express.Request) => agent
const exposedMethods = agent.availableMethods()
const basePath = '/agent'
const schemaPath = '/open-api.json'
const agentRouter = AgentRouter({
getAgentForRequest,
exposedMethods,
})
const schemaRouter = ApiSchemaRouter({
basePath,
getAgentForRequest,
exposedMethods,
})
const didDocRouter = WebDidDocRouter({
getAgentForRequest,
})
const app = express()
app.use(basePath, agentRouter)
app.use(schemaPath, schemaRouter)
app.use(didDocRouter)
app.listen(3002)
Functions
Function | Description |
---|---|
AgentRouter(options) | Creates a router that exposes Agent methods remotely. This can be used by AgentRestClient to instantiate the methods of this agent on the client. |
apiKeyAuth({ apiKey }) | This provides a simple authorization mechanism based on a single pre-shared API key. |
ApiSchemaRouter(options) | Creates a router that exposes Agent OpenAPI schema |
createDefaultDid(options) | (BETA) This can be used to automatically create a did:web with signing and encryption keys and listing messaging and DIDComm service endpoints. |
MessagingRouter(options) | Creates a router for handling incoming messages. Messages posted to this router get sent to the |
RequestWithAgentRouter(options) | Creates an expressjs router that adds a Veramo agent to the request object. This is needed by all other routers provided by this package to be able to perform their functions. |
WebDidDocRouter(options) | Creates a router that serves did:web DID Documents |
Interfaces
Interface | Description |
---|---|
AgentRouterOptions | |
ApiSchemaRouterOptions |
Variables
Variable | Description |
---|---|
didDocEndpoint | The URL path to the DID document, used by did:web when the identifier is a hostname. |