Install, configure, and use Attesta in TypeScript with full type safety
Attesta ships a first-class TypeScript SDK under the @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.
If you use a specific integration, install the peer dependency alongside it:
npm install @kyberon/attesta ai
The @kyberon/attesta package has zero runtime dependencies. Integration modules import peer dependencies lazily, so they are only required if you actually use them.
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.
import { gate } from "@kyberon/attesta";const deleteUser = gate(async (userId: string): Promise<string> => { // This only executes if Attesta approves return `Deleted user ${userId}`;});// Triggers risk assessment + approval promptconst result = await deleteUser("usr_12345");
For production use, create an Attesta instance that holds shared defaults for risk scoring, rendering, audit logging, and trust. All gates created from the instance inherit these defaults.
import { Attesta, gate } from "@kyberon/attesta";// Create an Attesta instance with shared defaultsconst attesta = new Attesta();// gate() is a standalone function — pass the attesta instance as an optionconst readConfig = gate(async (key: string) => { return `Value for ${key}`;}, { attesta });const deleteUser = gate( async (userId: string) => { return `Deleted ${userId}`; }, { attesta, riskHints: { destructive: true, pii: true } });
Or configure with custom components:
import { Attesta } from "@kyberon/attesta";const attesta = new Attesta({ riskScorer: myCustomScorer, renderer: myCustomRenderer, auditLogger: myCustomLogger, minReviewSeconds: 3.0,});