@ucanto/validator
@ucanto/validator
provides validation mechanisms for UCAN-based capabilities, ensuring that invocations comply with defined rules and security policies.
What It Provides
- Capability Validation: Ensures UCANs are properly formatted and authorized.
- Invocation Verification: Checks that invocations conform to defined constraints.
- Security Enforcement: Applies validation policies to prevent unauthorized actions.
How It Fits with Other Modules
@ucanto/core
: Uses validation mechanisms to enforce capability constraints.@ucanto/server
: Ensures only valid UCANs are processed by services.@ucanto/interface
: Defines standard validation-related types.@ucanto/principal
: Verifies cryptographic signatures for UCAN validation.
For an overview and detailed usage information, refer to the main ucanto
README.
Installation
npm install @ucanto/validator
Example Usage
import { capability, URI } from '@ucanto/core';
import { validate } from '@ucanto/validator';
const readFile = capability({
can: 'file/read',
with: URI.match({ protocol: 'file:' })
});
const isValid = validate({
capability: readFile,
proof: someProof,
with: 'file://example.txt'
});
if (isValid) {
console.log('Capability is valid');
} else {
console.error('Invalid capability');
}
For more details, see the ucanto
documentation.