@aamp/protocol 1.1.5 → 1.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/aamp-protocol-1.1.5.tgz +0 -0
- package/dist/agent.d.ts +1 -1
- package/dist/agent.js +9 -13
- package/dist/constants.d.ts +3 -0
- package/dist/constants.js +12 -9
- package/dist/crypto.js +5 -12
- package/dist/express.d.ts +1 -1
- package/dist/express.js +9 -12
- package/dist/index.d.ts +7 -7
- package/dist/index.js +7 -25
- package/dist/nextjs.d.ts +1 -1
- package/dist/nextjs.js +9 -12
- package/dist/proof.d.ts +9 -0
- package/dist/proof.js +27 -0
- package/dist/publisher.d.ts +6 -1
- package/dist/publisher.js +101 -29
- package/dist/types.d.ts +21 -2
- package/dist/types.js +6 -9
- package/package.json +10 -5
- package/src/agent.ts +8 -8
- package/src/constants.ts +13 -4
- package/src/express.ts +8 -7
- package/src/index.ts +7 -7
- package/src/nextjs.ts +11 -10
- package/src/proof.ts +36 -0
- package/src/publisher.ts +130 -40
- package/src/types.ts +42 -9
- package/test/handshake.spec.ts +6 -6
- package/tsconfig.json +9 -3
package/src/types.ts
CHANGED
|
@@ -43,14 +43,35 @@ export interface IdentityCache {
|
|
|
43
43
|
set(key: string, value: string, ttlSeconds: number): Promise<void>;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
/**
|
|
47
|
+
* Optional Monetization (The Settlement Layer)
|
|
48
|
+
*/
|
|
46
49
|
/**
|
|
47
50
|
* Optional Monetization (The Settlement Layer)
|
|
48
51
|
*/
|
|
49
52
|
export interface MonetizationConfig {
|
|
50
|
-
|
|
51
|
-
|
|
53
|
+
// Method 1: Payments (Flexible Callback)
|
|
54
|
+
// Developers implement their own logic (Database check, CMS lookup, etc.)
|
|
55
|
+
// Returns TRUE if the agent is a paid subscriber for this specific purpose.
|
|
56
|
+
checkPayment?: (agentId: string, purpose: string) => boolean | Promise<boolean>;
|
|
57
|
+
|
|
58
|
+
// Method 2: Ads (Proof Verification)
|
|
59
|
+
// Configuration to verify tokens from your Ad Provider (e.g. Google)
|
|
60
|
+
adNetwork?: {
|
|
61
|
+
jwksUrl: string; // e.g. "https://www.googleapis.com/oauth2/v3/certs"
|
|
62
|
+
issuer: string; // e.g. "https://accounts.google.com"
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
// Method 3: Payment Credentials (Unified JWT)
|
|
66
|
+
// Verifies "x-aamp-credential" for Broker or Direct payments.
|
|
67
|
+
paymentConfig?: {
|
|
68
|
+
jwksUrl: string; // e.g. "https://my-site.com/.well-known/jwks.json"
|
|
69
|
+
issuer: string; // e.g. "my-site.com"
|
|
70
|
+
};
|
|
52
71
|
}
|
|
53
72
|
|
|
73
|
+
|
|
74
|
+
|
|
54
75
|
/**
|
|
55
76
|
* Handling Non-AAMP Visitors
|
|
56
77
|
*
|
|
@@ -65,15 +86,15 @@ export interface AccessPolicy {
|
|
|
65
86
|
allowTraining: boolean;
|
|
66
87
|
allowRAG: boolean;
|
|
67
88
|
attributionRequired: boolean;
|
|
68
|
-
|
|
89
|
+
|
|
69
90
|
// Economic Signals
|
|
70
|
-
allowAdSupportedAccess: boolean;
|
|
71
|
-
requiresPayment: boolean;
|
|
91
|
+
allowAdSupportedAccess: boolean;
|
|
92
|
+
requiresPayment: boolean;
|
|
72
93
|
paymentPointer?: string;
|
|
73
94
|
|
|
74
95
|
// Identity Strictness
|
|
75
|
-
requireIdentityBinding?: boolean;
|
|
76
|
-
|
|
96
|
+
requireIdentityBinding?: boolean;
|
|
97
|
+
|
|
77
98
|
// V1.1: Optional Settlement Info
|
|
78
99
|
monetization?: MonetizationConfig;
|
|
79
100
|
}
|
|
@@ -81,7 +102,7 @@ export interface AccessPolicy {
|
|
|
81
102
|
export interface ProtocolHeader {
|
|
82
103
|
v: '1.1';
|
|
83
104
|
ts: string;
|
|
84
|
-
agent_id: string;
|
|
105
|
+
agent_id: string;
|
|
85
106
|
resource: string;
|
|
86
107
|
purpose: AccessPurpose;
|
|
87
108
|
context: {
|
|
@@ -98,11 +119,12 @@ export interface SignedAccessRequest {
|
|
|
98
119
|
export interface FeedbackSignal {
|
|
99
120
|
target_resource: string;
|
|
100
121
|
agent_id: string;
|
|
101
|
-
quality_score: number;
|
|
122
|
+
quality_score: number;
|
|
102
123
|
flags: QualityFlag[];
|
|
103
124
|
timestamp: string;
|
|
104
125
|
}
|
|
105
126
|
|
|
127
|
+
// Result of the full evaluation pipeline
|
|
106
128
|
// Result of the full evaluation pipeline
|
|
107
129
|
export interface EvaluationResult {
|
|
108
130
|
allowed: boolean;
|
|
@@ -110,4 +132,15 @@ export interface EvaluationResult {
|
|
|
110
132
|
reason: string;
|
|
111
133
|
visitorType: 'VERIFIED_AGENT' | 'LIKELY_HUMAN' | 'UNIDENTIFIED_BOT';
|
|
112
134
|
metadata?: any;
|
|
135
|
+
payment_status?: 'PAID_SUBSCRIBER' | 'AD_FUNDED' | 'UNPAID';
|
|
136
|
+
proofUsed?: string;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// Signed Quality Feedback (The "Report Card")
|
|
140
|
+
export interface FeedbackSignalToken {
|
|
141
|
+
url: string; // The resource being flagged
|
|
142
|
+
agent_id: string; // Who is flagging it (e.g. "bot.openai.com")
|
|
143
|
+
quality_score: number; // 0.0 to 1.0
|
|
144
|
+
reason: string; // e.g. "SEO_SPAM", "HATE_SPEECH"
|
|
145
|
+
timestamp: number;
|
|
113
146
|
}
|
package/test/handshake.spec.ts
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
* Run using: npm test
|
|
4
4
|
* Location: sdk/typescript/test/handshake.spec.ts
|
|
5
5
|
*/
|
|
6
|
-
import { AAMPAgent } from '../src/agent';
|
|
7
|
-
import { AAMPPublisher } from '../src/publisher';
|
|
8
|
-
import { AccessPurpose } from '../src/types';
|
|
9
|
-
import { HEADERS } from '../src/constants';
|
|
6
|
+
import { AAMPAgent } from '../src/agent.js';
|
|
7
|
+
import { AAMPPublisher } from '../src/publisher.js';
|
|
8
|
+
import { AccessPurpose } from '../src/types.js';
|
|
9
|
+
import { HEADERS } from '../src/constants.js';
|
|
10
10
|
|
|
11
11
|
async function runTest() {
|
|
12
12
|
console.log("--- STARTING AAMP HANDSHAKE TEST ---");
|
|
@@ -29,7 +29,7 @@ async function runTest() {
|
|
|
29
29
|
// TEST CASE A: Requesting RAG without Ads (Should FAIL due to Payment Requirement)
|
|
30
30
|
console.log("\n[TEST A] Requesting RAG (No Ads)...");
|
|
31
31
|
const reqA = await agent.createAccessRequest('/doc/1', AccessPurpose.RAG_RETRIEVAL, { adsDisplayed: false });
|
|
32
|
-
|
|
32
|
+
|
|
33
33
|
const payloadA = JSON.stringify(reqA.header);
|
|
34
34
|
const headersA = {
|
|
35
35
|
[HEADERS.PAYLOAD]: btoa(payloadA),
|
|
@@ -45,7 +45,7 @@ async function runTest() {
|
|
|
45
45
|
// TEST CASE B: Requesting RAG WITH Ads (Should SUCCEED via Exemption)
|
|
46
46
|
console.log("\n[TEST B] Requesting RAG (With Ads)...");
|
|
47
47
|
const reqB = await agent.createAccessRequest('/doc/1', AccessPurpose.RAG_RETRIEVAL, { adsDisplayed: true });
|
|
48
|
-
|
|
48
|
+
|
|
49
49
|
const payloadB = JSON.stringify(reqB.header);
|
|
50
50
|
const headersB = {
|
|
51
51
|
[HEADERS.PAYLOAD]: btoa(payloadB),
|
package/tsconfig.json
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
3
|
"target": "ES2020",
|
|
4
|
-
"module": "
|
|
5
|
-
"
|
|
4
|
+
"module": "NodeNext",
|
|
5
|
+
"moduleResolution": "NodeNext",
|
|
6
|
+
"lib": [
|
|
7
|
+
"ES2020",
|
|
8
|
+
"DOM"
|
|
9
|
+
],
|
|
6
10
|
"declaration": true,
|
|
7
11
|
"outDir": "./dist",
|
|
8
12
|
"rootDir": "./src",
|
|
@@ -11,5 +15,7 @@
|
|
|
11
15
|
"skipLibCheck": true,
|
|
12
16
|
"forceConsistentCasingInFileNames": true
|
|
13
17
|
},
|
|
14
|
-
"include": [
|
|
18
|
+
"include": [
|
|
19
|
+
"src/**/*"
|
|
20
|
+
]
|
|
15
21
|
}
|