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

@apoa/a2a

v0.1.8

Published

APOA authorization for A2A agent-to-agent communication — scoped delegation tokens, capability attenuation, audit trails

Readme

APOA on A2A

@apoa/a2a

APOA authorization for A2A agent-to-agent communication. Scoped delegation tokens, capability attenuation, audit trails.

A2A handles authentication (who are you?). This package adds authorization (what can you do, on whose behalf, for how long?).

Install

npm install @apoa/a2a

Quick Start

Client: attach an APOA token to an A2A message

import { attachToken, apoaHeaders } from '@apoa/a2a';
import { APOA, generateKeyPair } from '@apoa/core';

const keys = await generateKeyPair();
const apoa = new APOA({ privateKey: keys.privateKey });

const token = await apoa.tokens.createGrant({
  principal: 'did:apoa:jane',
  agent: 'did:apoa:travel-planner',
  service: 'flights',
  scopes: ['book', 'search'],
  expiresIn: '24h',
});

const message = {
  messageId: 'msg-001',
  role: 'user',
  parts: [{ kind: 'text', text: 'Book me a flight to Helsinki' }],
};

// Attach token to message metadata (keyed by APOA extension URI)
attachToken(message, token.raw);

// Send with APOA extension header
await fetch('https://agent.example.com/message:send', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json', ...apoaHeaders() },
  body: JSON.stringify({ jsonrpc: '2.0', id: 1, method: 'SendMessage', params: { message } }),
});

Server: verify APOA tokens on incoming messages

import { createA2AGuard } from '@apoa/a2a';

const guard = createA2AGuard({
  key: publicKey,
  mappings: {
    'book-flight':    'flights:book',
    'search-flights': 'flights:search',
    'cancel-flight':  'flights:cancel',
  },
});

// In your A2A agent's message handler:
const result = await guard.authorize(incomingMessage, 'book-flight');
if (!result.authorized) {
  // Transition task to AUTH_REQUIRED or reject
}

Agent Card: declare APOA support

import { apoaExtension, apoaSkillRequirement } from '@apoa/a2a';

const agentCard = {
  name: 'Travel Agent',
  version: '1.0.0',
  capabilities: {
    extensions: [apoaExtension()],
  },
  skills: [
    {
      id: 'book-flight',
      name: 'Flight Booking',
      description: 'Books flights on behalf of the user',
      securityRequirements: [apoaSkillRequirement(['flights:book'])],
    },
  ],
  // ...
};

How It Works

  1. Client attaches an APOA token to the A2A message's metadata, keyed by the APOA extension URI
  2. Client sends the A2A-Extensions header to activate the APOA extension
  3. Server extracts the token from message metadata
  4. Server maps the target skill to an APOA service:scope pair
  5. Server verifies: signature, expiration, revocation, scope, constraints, rules
  6. If authorized, the skill executes. If not, the task transitions to AUTH_REQUIRED or is rejected

Skill Mappings

Simple format:

createA2AGuard({
  key: publicKey,
  mappings: {
    'book-flight':    'flights:book',
    'search-flights': 'flights:search',
  },
});

Auto-mapping (no config):

createA2AGuard({ key: publicKey });
// book-flight -> book-flight:invoke

Delegation Across A2A Hops

When Agent A delegates a task to Agent B, it can include an attenuated APOA token:

import { delegate } from '@apoa/core';
import { attachToken } from '@apoa/a2a';

// Agent A delegates narrower permissions to Agent B
const childToken = await delegate(parentToken, {
  agent: { id: 'agent-b' },
  services: [{ service: 'flights', scopes: ['search'] }], // narrower than parent
}, signingOptions);

// Attach to the A2A message with the delegation chain
const message = { messageId: 'msg-002', role: 'user', parts: [{ kind: 'text', text: 'Search for flights' }] };
attachToken(message, childToken.raw, [parentToken.jti]);

Agent B's server verifies the token and checks the delegation chain for revocation.

What This Adds to A2A

| Capability | A2A Native | @apoa/a2a | |---|---|---| | Transport auth (OAuth, API keys) | Yes | N/A (complementary) | | Per-task scoped authorization | No ("implementation-specific") | Yes | | Delegation chains with attenuation | No | Yes | | Constraint checking | No | Yes | | Hard/soft rules | No | Yes | | Cascade revocation | No | Yes | | Audit trail | No (recommended, not specified) | Yes |

Part of the APOA Standard

License

Apache-2.0