Sign In

@countersign/ap2

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@countersign/ap2

Govern AP2 (the Agent Payments Protocol) with Countersign — guard an agent's mandate against policy before it signs the PaymentMandate.

latest
Source
npmnpm
Version
0.1.3
Version published
Weekly downloads
63
-10%
Maintainers
1
Weekly downloads
 
Created
Source

@countersign/ap2

Govern AP2 (the Agent Payments Protocol) with Countersign — guard an agent's mandate against policy before it signs the PaymentMandate.

When an agent is about to commit to a merchant-signed Cart/Checkout Mandate — the moment a final amount and payee are known but funds have not moved — route it through Countersign's pre-flight spend guard: parse the mandate → evaluate against one unified policy (per-call caps + payee allowlist + daily metering, fail-closed) → only sign/send the PaymentMandate if allowed. Countersign decides; it never signs a mandate or moves funds.

import { parseAp2, withAp2Guard } from "@countersign/ap2";
import { CountersignClient } from "@countersign/sdk";

const cs = new CountersignClient({ baseUrl, apiKey });

// `mandate` is a merchant-signed AP2 Cart/Checkout Mandate (or a PaymentMandate).
const charge = parseAp2(mandate);                 // normalized: amount (minor units) + currency + payee
if (charge) {
  // Only signs/sends if Countersign allows — a rogue or over-budget agent never pays.
  await withAp2Guard(cs, agentId, charge, (c) => signAndSendPaymentMandate(c));
}
  • parseAp2(mandate) — normalize an AP2 mandate to a single charge. Handles both spec generations: Gen-1 (W3C-PaymentRequest, float major units) and Gen-2/v0.2 (SD-JWT VC, int minor units); the amount is always returned as an integer minor-unit string.
  • guardAp2(api, agentId, charge) — ask Countersign: allow / deny / needs_approval.
  • withAp2Guard(api, agentId, charge, pay) — evaluate, then run pay only on allow; throws Ap2Denied otherwise.

AP2 has no official npm/TS SDK yet and the spec (v0.2) is still evolving — the mandate types here are transcribed from the reference schemas. Pairs with @countersign/sdk, @countersign/mcp, and @countersign/x402.

Apache-2.0.

Keywords

countersign

FAQs

Package last updated on 11 Jul 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts