@kyberon/attesta package. It provides the same approval pipeline as the Python SDK — risk scoring, escalating challenges, tamper-proof audit trails, and adaptive trust — with idiomatic TypeScript conventions and full generic type safety.
Installation
The
@kyberon/attesta package has zero runtime dependencies. Integration modules import peer dependencies lazily, so they are only required if you actually use them.Basic Usage
Protecting a Function with gate
The gate function wraps any async function with the Attesta approval pipeline. When the wrapped function is called, Attesta intercepts the invocation, scores the risk, presents the appropriate challenge, and either allows or blocks execution.
Passing Options
Provide a configuration object as the first argument to customize risk scoring, hints, and metadata:Curried Factory
You can also create a pre-configured gate factory and reuse it across multiple functions:Using the Attesta Class
For production use, create anAttesta instance that holds shared defaults for risk scoring, rendering, audit logging, and trust. All gates created from the instance inherit these defaults.
Type Definitions
The TypeScript SDK exports all core types for full type safety. Here are the most commonly used types:Key Interfaces
Generics
Thegate function preserves the original function’s type signature using TypeScript generics:
Handling Denials
When an operator denies an action or fails a challenge, the wrapped function throws anAttestaDenied error. The protected function is never executed.
Python vs TypeScript at a Glance
For a detailed comparison, see the Python vs TypeScript API page.
Next Steps
Python vs TypeScript API
Detailed side-by-side comparison of both SDKs
@gate Decorator
Full parameter reference for the gate function
Vercel AI SDK
TypeScript-native Vercel AI integration
Protocols
Implement custom scorers, renderers, and loggers