@openleash/sdk-ts
v0.3.0
Published
TypeScript SDK for openleash
Readme
@openleash/sdk-ts
TypeScript SDK for OpenLeash — local-first authorization and proof sidecar for AI agents.
Use this package in your agent code to request authorization and verify proof tokens.
Installation
npm install @openleash/sdk-tsAuthorize an action
import { authorize } from '@openleash/sdk-ts';
const result = await authorize({
openleashUrl: 'http://127.0.0.1:8787',
agentId: 'my-agent',
privateKeyB64: process.env.OPENLEASH_AGENT_PRIVATE_KEY_B64!,
action: {
action_id: crypto.randomUUID(),
action_type: 'purchase',
requested_at: new Date().toISOString(),
principal: { agent_id: 'my-agent' },
subject: { principal_id: '<owner-id>' },
relying_party: { domain: 'example.com', trust_profile: 'LOW' },
payload: { amount_minor: 5000, currency: 'USD' },
},
});
console.log(result.decision); // "ALLOW" | "DENY" | "REQUIRE_APPROVAL" | ...
console.log(result.proof_token); // PASETO v4.public token (if allowed)Verify a proof offline
import { verifyProofOffline } from '@openleash/sdk-ts';
const result = await verifyProofOffline({
token: proofToken,
publicKeys: [{ kid: 'key-id', public_key_b64: 'base64...' }],
});
console.log(result.valid, result.claims);Documentation
See the OpenLeash README for full documentation.
