@aamp/protocol
v1.1.11
Published
TypeScript reference implementation of AAMP v1.1
Downloads
58
Readme
@aamp/protocol
The official TypeScript reference implementation of the Automated Agent Monetization Protocol (AAMP).
AAMP is an open standard that enables "Transactional Content Negotiation" between AI Agents and Web Publishers. replacing robots.txt with cryptographic signatures and micro-payments.
Website: https://aamp.dev
Repository: GitHub
📦 Installation
npm install @aamp/protocol
# Optional: Install 'jose' for crypto signing if you are building a custom implementation
npm install jose🚀 Usage
1. For AI Agents (Clients)
Use AAMPAgent to crawl websites with automatic protocol negotiation.
import { AAMPAgent } from '@aamp/protocol';
async function main() {
// 1. Initialize Identity (Loads from AAMP_PRIVATE_KEY env var)
const agent = await AAMPAgent.init();
// 2. Fetch URL (Automatically signs request if AAMP is detected)
const response = await agent.fetch('https://example.com/article', {
purpose: 'RAG_RETRIEVAL'
});
if (response.status === 200) {
console.log('Success:', response.data);
} else {
console.error('Blocked:', response.status);
}
}2. For Publishers (Next.js Middleware)
Use AAMPNext to protect your routes.
// src/middleware.ts
import { AAMPNext } from '@aamp/protocol';
const aamp = AAMPNext.init({
policy: {
// Security: Verify DNS Binding
requireIdentityBinding: true,
// Economics: Connect to Broker
monetization: {
brokerUrl: "https://broker.aamp.network"
}
}
});
export const middleware = aamp.withProtection();
export const config = {
matcher: ['/api/premium/:path*', '/articles/:path*']
};🔑 Key Features
- Zero Dependencies: The core logic is dependency-free.
- Isomorphic: Works in Node.js, Edge Runtime (Vercel/Cloudflare), and Browsers.
- Cryptographically Secure: Implements
ECDSA P-256signatures andJSON Web Tokens. - Type Safe: Written in strict TypeScript with full definition files included.
📚 API Reference
AAMPAgent
init(options?): Create a new agent instance.fetch(url, options): AAMP-aware fetch wrapper.sendFeedback(url, feedback): Send Quality/Spam reports.
AAMPNext (Adapter)
init(config): Configure the Publisher Policy Engine.withProtection(handler): Wrap a Next.js Middleware or Route Handler.
📄 License
Apache 2.0
By the AAMP Community.
