UCAN RPC Client
npm install @ucanto/client@ucanto/client provides the tools necessary to create, sign, and send UCAN-based RPC invocations. It enables secure communication with UCAN-compliant services while ensuring proper authorization and delegation handling.
@ucanto/core: Defines capability structures and execution logic.@ucanto/server: Processes invocations received from the client.@ucanto/interface: Provides shared types for request and response handling.@ucanto/principal: Manages cryptographic signing for invocations.@ucanto/transport: Handles encoding and sending of requests.For an overview and detailed usage information, refer to the main ucanto README.
sh
npm install @ucanto/client
`Example Usage
`ts
import * as Client from '@ucanto/client';
import { ed25519 } from '@ucanto/principal';const service = ed25519.Verifier.parse(process.env.SERVICE_ID);
const issuer = ed25519.Signer.parse(process.env.CLIENT_KEYPAIR);
const invocation = await Client.invoke({
issuer,
audience: service,
capability: {
can: 'file/read',
with: 'file://example.txt'
}
});
const response = await client.execute(invocation);
if (response.error) {
console.error('Invocation failed:', response.error);
} else {
console.log('Invocation succeeded:', response.result);
}
`ucanto` documentation.