包详细信息

@ucanto/server

web3-storage10.7k(Apache-2.0 AND MIT)11.0.0

UCAN RPC Server

UCAN, RPC, JWT, server

自述文件

@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.

What It Provides

  • UCAN-Based Authorization: Ensures that all invocations are securely verified before execution.
  • Capability Handling: Allows services to define and manage capabilities with fine-grained access control.
  • Pluggable Transport Layer: Supports multiple encoding and transport options.
  • Batch Invocation Processing: Enables efficient handling of multiple invocations in a single request.

How It Fits with Other Modules

For an overview and detailed usage information, refer to the main ucanto README.

Installation

npm install @ucanto/server

Example Usage

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
  });
};

For more details, see the ucanto documentation.

更新日志

Changelog

0.1.0-beta (2022-05-03)

Features

  • improve http transport configuration (#10) (c99be08)

0.0.3-beta (2022-05-02)

Bug Fixes

0.0.2-beta (2022-04-24)

Bug Fixes

0.0.1-beta (2022-04-24)

Features

Bug Fixes

Miscellaneous Chores