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

sanction-sdk

v0.9.0

Published

TypeScript SDK for Sanction — authorize spend and tools, inject scoped credentials, manage policy. The tool runs behind the decision.

Readme

sanction-sdk

TypeScript SDK for Sanction — the independent authorization plane for AI agents. Gate spend, authorize tools before they run, inject scoped credentials, and manage policy from agent or owner code.

npm install sanction-sdk

Zero runtime dependencies (uses the global fetch, Node ≥ 18). Ships ESM + types. License: FSL-1.1-MIT (same as the Sanction server source — see Commercial License).

Two clients

| Client | Key | Use from | |--------|-----|----------| | SanctionClient | agent key pxy_… | inside the agent — authorize, logTokens, exec tokens, credential injection, tool gate | | SanctionAdminClient | management key sk_… | owner/control side — create wallets, register agents, manage policy. Never ship this key in an agent. |

Data plane — gate an action before it happens

import { SanctionClient } from "sanction-sdk"

const sanction = new SanctionClient(process.env.SANCTION_API_KEY!) // pxy_...

const decision = await sanction.authorize({
  action: "purchase",
  amountUsd: 3.5,
  merchant: "anthropic",
  category: "software",
  description: "claude tokens for backlog task #42",
  idempotencyKey: "job-42-step-3", // safe to retry
})

// A `denied` decision is RETURNED, not thrown — branch on it and replan:
if (decision.status === "denied") {
  console.warn(`blocked: ${decision.code} — ${decision.remediation}`)
} else if (decision.status === "escalated") {
  // Poll until the owner approves, then retry with the grant:
  const status = await sanction.getAuthorization(decision.requestId)
  if (status.grantId) {
    // retry authorize / authorizeTool with grantId: status.grantId
  }
} else {
  // approved — proceed
}

Tool gate — the tool runs behind the decision

import { SanctionClient, SanctionMiddleware, sanctionTool, SanctionToolBlocked } from "sanction-sdk"

const client = new SanctionClient(process.env.SANCTION_API_KEY!)
const runTool = SanctionMiddleware(client)

try {
  await runTool({
    server: "github",
    tool: "create_pr",
    input: { title, body },
    run: () => octokit.pulls.create({ ... }), // runs ONLY if approved
  })
} catch (e) {
  if (e instanceof SanctionToolBlocked) {
    // e.status: "escalated" → poll e.requestId via getAuthorization, then retry with grantId
    // e.status: "denied" → replan
  }
}

// Vercel AI SDK: wrap tool() so execute is gated
import { tool } from "ai"
const deploy = sanctionTool(client, "deploy", tool({ /* ... */ }), { server: "ci" })

authorizeTool fails closed — if Sanction is unreachable it returns denied, so an ungoverned tool never runs.

Scoped credential access (15-min execution JWT)

const result = await sanction.withCredential(
  { scope: ["github"], budgetUsd: 0, label: "github" },
  async (token) => {
    return fetch("https://api.github.com/...", { headers: { authorization: `Bearer ${token}` } })
  },
)

Management plane — provision + set policy

import { SanctionAdminClient } from "sanction-sdk"

const wallet = await SanctionAdminClient.createWallet({ name: "nightly-coding", ownerEmail: "[email protected]" })
const admin = new SanctionAdminClient(wallet.managementKey)
const agent = await admin.registerAgent({ walletId: wallet.id, name: "nightly-coder" })
await admin.updatePolicy(wallet.id, {
  dailySpendBudgetUsd: 75,
  autoApproveUnderUsd: 5,
  escalateOverUsd: 25,
  perTransactionMaxUsd: 100,
  blockedCategories: ["crypto"],
})

Errors

  • SanctionError — any non-2xx that isn't a normal decision (status, code, body).
  • AuthorizationDeniedError — only when you opt into authorize(..., { throwOnDeny: true }).
  • SanctionToolBlocked — thrown by middleware / sanctionTool on non-approved tool decisions.

Config

new SanctionClient(key, { baseUrl, fetch }) // baseUrl defaults to https://getsanction.com/api/v1

Develop (from the monorepo)

cd sdk && npm run typecheck && npm run build
# from repo root:
npx vitest run sdk/src

All monetary policy fields are in dollars. The SDK speaks camelCase; the wire is snake_case, mapped internally.