UCAN RPC Server
npm install @ucanto/server@ucanto/server provides the necessary components to build a UCAN-based RPC server. It enables services to define capabilities, validate UCANs, and process invocations securely and efficiently. This package builds on ucanto/core and integrates seamlessly with other ucanto modules.
@ucanto/core: Provides the fundamental capability execution and validation logic.@ucanto/interface: Defines shared type definitions and contracts.@ucanto/transport: Implements encoding and transport mechanisms.@ucanto/principal: Handles identity management and cryptographic operations.For an overview and detailed usage information, refer to the main ucanto README.
sh
npm install @ucanto/server
`Example Usage
`ts
import * as Server from '@ucanto/server';
import * as CAR from '@ucanto/transport/car';
import * as CBOR from '@ucanto/transport/cbor';
import { ed25519 } from '@ucanto/principal';
import { capability, URI } from '@ucanto/core';const ReadFile = capability({
can: 'file/read',
with: URI.match({ protocol: 'file:' })
});
export const createServer = () => {
const read = Server.provide(ReadFile, ({ capability }) => {
return { path: capability.with };
});
return Server.create({
id: ed25519.Signer.parse(process.env.SERVICE_SECRET),
service: { file: { read } },
decoder: CAR,
encoder: CBOR
});
};
`ucanto` documentation.