npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@kora-protocol/sdk

v1.3.0

Published

TypeScript SDK for the Kora authorization engine — deterministic spend authorization for AI agents

Readme

Kora TypeScript SDK

TypeScript SDK for the Kora authorization engine. Handles Ed25519 signing, nonce generation, canonical JSON serialization, idempotent retry, and offline seal verification.

Installation

npm install @kora/sdk

Requirements: Node.js >= 18

Quick Start

import { Kora } from '@kora/sdk';

const kora = new Kora(process.env.KORA_AGENT_KEY!);

const auth = await kora.authorize({
  mandate: 'mandate_abc123',
  amount: 50_00,        // EUR 50.00
  currency: 'EUR',
  vendor: 'aws',
  category: 'compute',
});

if (auth.approved) {
  console.log(`Approved: ${auth.decisionId}`);
} else {
  console.log(`Denied: ${auth.reasonCode} — ${auth.denial.hint}`);
}

Usage

Initialize

import { Kora } from '@kora/sdk';

const kora = new Kora('kora_agent_sk_...', {
  baseUrl: 'http://localhost:8000',  // default
  ttl: 300,         // default TTL in seconds
  maxRetries: 2,    // automatic idempotent retry on network error
});

Authorize a Spend

const auth = await kora.authorize({
  mandate: 'mandate_abc123',
  amount: 50_00,
  currency: 'EUR',
  vendor: 'aws',
  category: 'compute',  // required if mandate has category_allowlist
});

Result Properties

auth.approved        // boolean — true if APPROVED
auth.decision        // "APPROVED" | "DENIED"
auth.decisionId      // UUID of the authorization decision
auth.reasonCode      // "OK", "DAILY_LIMIT_EXCEEDED", etc.
auth.executable      // boolean — true if payment can be executed
auth.isValid         // boolean — true if TTL has not expired
auth.isEnforced      // boolean — true if enforcement_mode == "enforce"
auth.enforcementMode // "enforce" | "log_only"

// On denial:
auth.denial.hint            // Human-readable suggestion
auth.denial.actionable      // Machine-readable corrective values
auth.denial.failedCheck     // Which pipeline step failed

// On approval:
auth.limitsAfterApproval    // Remaining daily/monthly budget

// Evaluation trace:
auth.evaluationTrace.steps           // Array of pipeline step results
auth.evaluationTrace.totalDurationMs // Total evaluation time

// Notary seal:
auth.notarySeal.signature    // Ed25519 signature (base64)
auth.notarySeal.publicKeyId
auth.notarySeal.algorithm    // "Ed25519"

// Trace URL (for debugging denials):
auth.traceUrl  // e.g. http://localhost:8000/v1/authorizations/<id>/trace

Handle Denials

const auth = await kora.authorize({
  mandate: 'mandate_abc123',
  amount: 999_99,
  currency: 'EUR',
  vendor: 'aws',
});

if (!auth.approved) {
  console.log(`Denied: ${auth.reasonCode}`);
  console.log(`Hint: ${auth.denial.hint}`);

  if (auth.reasonCode === 'DAILY_LIMIT_EXCEEDED') {
    const available = auth.denial.actionable.available_cents;
    console.log(`Available budget: ${available} cents`);
  }

  if (auth.reasonCode === 'VENDOR_NOT_ALLOWED') {
    const allowed = auth.denial.actionable.allowed_vendors;
    console.log(`Allowed vendors: ${allowed}`);
  }

  console.log(`Trace: ${auth.traceUrl}`);
}

Verify Notary Seal (Offline)

const koraPublicKey = Buffer.from('...', 'base64');
const isValid = kora.verifySeal(auth, koraPublicKey);
console.log(`Seal valid: ${isValid}`);

Simulation Mode

Test denial scenarios without affecting state. Requires an admin key with simulation_access=true.

const auth = await kora.authorize({
  mandate: 'mandate_abc123',
  amount: 100,
  currency: 'EUR',
  vendor: 'aws',
}, {
  simulate: 'DAILY_LIMIT_EXCEEDED',
  adminKey: 'kora_admin_...',
});

console.log(auth.simulated);   // true
console.log(auth.decision);    // "DENIED"
console.log(auth.notarySeal);  // null (no seal in simulation)

OpenAI Function Tool Schema

Generate an OpenAI-compatible function tool definition:

const tool = kora.asTool('mandate_abc123');
// Returns:
// {
//   type: "function",
//   function: {
//     name: "kora_authorize_spend",
//     description: "Authorize a spend against a Kora mandate...",
//     parameters: {
//       type: "object",
//       properties: {
//         amount_cents: { type: "integer", description: "..." },
//         currency: { type: "string", description: "..." },
//         vendor_id: { type: "string", description: "..." },
//       },
//       required: ["amount_cents", "currency", "vendor_id"]
//     }
//   }
// }

Use with OpenAI:

import OpenAI from 'openai';

const openai = new OpenAI();
const response = await openai.chat.completions.create({
  model: 'gpt-4',
  messages: [{ role: 'user', content: 'Buy $50 of AWS compute' }],
  tools: [kora.asTool('mandate_abc123')],
});

Agent Self-Correction Pattern

import { Kora } from '@kora/sdk';

const kora = new Kora(process.env.KORA_AGENT_KEY!);

// First attempt — too large
let auth = await kora.authorize({
  mandate: 'mandate_abc123',
  amount: 999_99,
  currency: 'EUR',
  vendor: 'aws',
});

if (!auth.approved && auth.reasonCode === 'DAILY_LIMIT_EXCEEDED') {
  const available = auth.denial.actionable.available_cents;
  console.log(`Budget available: ${available} cents, retrying...`);

  // Retry with corrected amount
  auth = await kora.authorize({
    mandate: 'mandate_abc123',
    amount: available,
    currency: 'EUR',
    vendor: 'aws',
  });
  console.log(`Second attempt: ${auth.decision}`);  // APPROVED
}

API Reference

new Kora(keyString, options?)

| Parameter | Type | Default | Description | |-----------|------|---------|-------------| | keyString | string | required | Agent secret key (kora_agent_sk_...) | | options.baseUrl | string | http://localhost:8000 | Kora API base URL | | options.ttl | number | 300 | Default TTL for decisions (seconds) | | options.maxRetries | number | 2 | Automatic retries on network error |

kora.authorize(params, options?) -> Promise<AuthorizationResult>

| Parameter | Type | Required | Description | |-----------|------|----------|-------------| | params.mandate | string | yes | Mandate ID | | params.amount | number | yes | Amount in cents | | params.currency | string | yes | 3-letter currency code | | params.vendor | string | yes | Vendor identifier | | params.category | string | no | Spending category | | options.simulate | string | no | Force denial reason code | | options.adminKey | string | no | Admin key for simulation |

kora.verifySeal(result, publicKey) -> boolean

Verify the Ed25519 notary seal offline.

kora.asTool(mandate, options?) -> object

Generate OpenAI function tool schema.