@agentsbloom/sdk 0.2.0 → 0.4.0
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/LICENSE +21 -21
- package/README.md +184 -254
- package/SECURITY.md +24 -19
- package/index.d.ts +95 -2
- package/index.js +1994 -1111
- package/lib/ap2.js +153 -38
- package/lib/outcomes.js +108 -0
- package/lib/shared-store.js +172 -0
- package/package.json +85 -81
- package/telemetry.js +24 -17
- package/assets/logo-mark.svg +0 -25
package/index.d.ts
CHANGED
|
@@ -16,19 +16,62 @@ export interface AgentAction {
|
|
|
16
16
|
export interface AgentsBloomConfig {
|
|
17
17
|
apiKey?: string | null;
|
|
18
18
|
agentSecret?: string | null;
|
|
19
|
+
/**
|
|
20
|
+
* Previous shared secret, kept verify-live during AGENTSBLOOM_SECRET
|
|
21
|
+
* rotation so in-flight signed requests survive the window. Falls back
|
|
22
|
+
* to the AGENTSBLOOM_SECRET_PREVIOUS environment variable.
|
|
23
|
+
*/
|
|
24
|
+
agentSecretPrevious?: string | null;
|
|
19
25
|
name?: string;
|
|
20
26
|
description?: string;
|
|
21
27
|
actions?: Record<string, AgentAction>;
|
|
22
28
|
llmsDoc?: string;
|
|
23
29
|
baseUrl?: string;
|
|
24
|
-
|
|
30
|
+
/**
|
|
31
|
+
* v4: when set, only requests whose Host header matches one of these
|
|
32
|
+
* values get Host-derived discovery URLs; any other Host falls back to
|
|
33
|
+
* `baseUrl`. Prevents Host-header poisoning of discovery documents.
|
|
34
|
+
*/
|
|
35
|
+
allowedHosts?: string[];
|
|
36
|
+
/**
|
|
37
|
+
* v4 medium pass: string behaves as before; an ARRAY is an exact-match
|
|
38
|
+
* allow-list - matching Origins are reflected (Vary: Origin), everything
|
|
39
|
+
* else receives no Access-Control-Allow-Origin at all.
|
|
40
|
+
*/
|
|
41
|
+
corsOrigin?: string | string[];
|
|
42
|
+
/** v4 medium pass (V10): body-size cap in bytes, enforced against the
|
|
43
|
+
* received bytes as well as Content-Length (default 1 MiB). */
|
|
44
|
+
maxBodyBytes?: number;
|
|
45
|
+
/**
|
|
46
|
+
* v4 medium pass (V11): per-agent legacy-HMAC secrets keyed by
|
|
47
|
+
* X-Agent-Identifier. Checked before the shared `agentSecret` fallback.
|
|
48
|
+
*/
|
|
49
|
+
agentKeys?: Record<string, string>;
|
|
50
|
+
/** v4 medium pass (V11): identifiers rejected outright before verification. */
|
|
51
|
+
revokedIdentifiers?: string[];
|
|
52
|
+
/**
|
|
53
|
+
* v4 medium pass (V12): per-action authorization. 'authenticated'
|
|
54
|
+
* requires a verified RFC/legacy signature identity even for reads.
|
|
55
|
+
*/
|
|
56
|
+
actionAccess?: Record<string, 'anonymous' | 'authenticated'>;
|
|
57
|
+
/**
|
|
58
|
+
* v4 medium pass (V12): per-action identity allow-lists. Entries match
|
|
59
|
+
* exactly (`rfc:key-1`) or by prefix when ending with ':' (`legacy:`).
|
|
60
|
+
*/
|
|
61
|
+
actionIdentities?: Record<string, string[]>;
|
|
25
62
|
merchantJwks?: Record<string, unknown>;
|
|
63
|
+
/**
|
|
64
|
+
* v4: RFC 9421 verification now FAILS CLOSED - one of `agentJwks` or
|
|
65
|
+
* `agentJwksUrl` must be configured for Signature-header writes to verify.
|
|
66
|
+
*/
|
|
26
67
|
agentJwks?: {
|
|
27
68
|
keys: Array<Record<string, unknown>>;
|
|
28
69
|
};
|
|
29
70
|
agentJwksUrl?: string;
|
|
30
71
|
signature?: {
|
|
31
72
|
maxAgeMs?: number;
|
|
73
|
+
/** v4 medium pass (V14): require the @authority covered component. */
|
|
74
|
+
requireAuthority?: boolean;
|
|
32
75
|
};
|
|
33
76
|
ap2PublicKey?: unknown;
|
|
34
77
|
ap2?: {
|
|
@@ -36,13 +79,27 @@ export interface AgentsBloomConfig {
|
|
|
36
79
|
maxMandateLifetimeSec?: number;
|
|
37
80
|
requireJti?: boolean;
|
|
38
81
|
requestedCategories?: string[];
|
|
82
|
+
/**
|
|
83
|
+
* v4: reject self-certifying did:key mandates (anyone can mint those
|
|
84
|
+
* with an arbitrary maxBudget) and accept only mandates signed by the
|
|
85
|
+
* merchant-configured trusted key.
|
|
86
|
+
*/
|
|
87
|
+
trustedIssuersOnly?: boolean;
|
|
88
|
+
/** v4 medium pass (V17): pin the currency budgets are denominated in. */
|
|
89
|
+
expectedCurrency?: string;
|
|
39
90
|
};
|
|
40
91
|
rateLimit?: {
|
|
41
92
|
max?: number;
|
|
42
93
|
windowMs?: number;
|
|
43
94
|
};
|
|
95
|
+
mcp?: {
|
|
96
|
+
/** v4: cap on concurrent MCP SSE sessions (default 100). */
|
|
97
|
+
maxSessions?: number;
|
|
98
|
+
};
|
|
44
99
|
idempotency?: {
|
|
45
100
|
ttlMs?: number;
|
|
101
|
+
/** v4 medium pass (V18): bound on cached entries (default 10,000). */
|
|
102
|
+
maxEntries?: number;
|
|
46
103
|
};
|
|
47
104
|
demoMode?: boolean;
|
|
48
105
|
disableSignatureAuth?: boolean;
|
|
@@ -70,6 +127,12 @@ export interface TelemetryConfig {
|
|
|
70
127
|
|
|
71
128
|
export interface Ap2VerificationResult {
|
|
72
129
|
valid: boolean;
|
|
130
|
+
/**
|
|
131
|
+
* True only when a presented mandate cryptographically verified. When a
|
|
132
|
+
* shared replay store (UPSTASH_REDIS_REST_URL/TOKEN) is configured,
|
|
133
|
+
* verification may resolve asynchronously - the return type becomes
|
|
134
|
+
* Promise<Ap2VerificationResult>; callers should await it either way.
|
|
135
|
+
*/
|
|
73
136
|
verified?: boolean;
|
|
74
137
|
protocol: 'AP2';
|
|
75
138
|
reason?: string;
|
|
@@ -84,6 +147,8 @@ export interface Ap2VerifyOptions {
|
|
|
84
147
|
maxMandateLifetimeSec?: number;
|
|
85
148
|
requireJti?: boolean;
|
|
86
149
|
requestedCategories?: string[];
|
|
150
|
+
/** v4: when false, self-certifying did:key issuers are rejected. */
|
|
151
|
+
allowSelfCertifying?: boolean;
|
|
87
152
|
}
|
|
88
153
|
|
|
89
154
|
export interface CreateAp2MandateOptions {
|
|
@@ -117,8 +182,36 @@ export function verifyAP2Mandates(
|
|
|
117
182
|
headers?: Record<string, string | undefined>,
|
|
118
183
|
body?: Record<string, unknown>,
|
|
119
184
|
publicKeyOrOptions?: unknown | Ap2VerifyOptions
|
|
120
|
-
): Ap2VerificationResult
|
|
185
|
+
): Ap2VerificationResult | Promise<Ap2VerificationResult>;
|
|
121
186
|
export function createAp2Mandate(options: CreateAp2MandateOptions): Ap2Mandate;
|
|
122
187
|
export function didKeyFromEd25519PublicKey(publicKey: unknown): string;
|
|
123
188
|
export function ed25519PublicKeyFromDidKey(didKey: string): unknown | null;
|
|
124
189
|
export function resetAp2ReplayCache(): void;
|
|
190
|
+
/**
|
|
191
|
+
* Normalizes an audience/merchantScope value (URL-parsed: lowercased host,
|
|
192
|
+
* trailing slashes stripped) so mandates built via new URL().href compare
|
|
193
|
+
* equal to slash-free configured audiences.
|
|
194
|
+
*/
|
|
195
|
+
export function normalizeAudience(value: string): string;
|
|
196
|
+
|
|
197
|
+
export interface OutcomeReport {
|
|
198
|
+
orderRef: string;
|
|
199
|
+
status: 'paid' | 'declined' | 'refunded' | 'chargeback' | 'disputed' | 'canceled';
|
|
200
|
+
gateway?: 'stripe' | 'razorpay' | 'paddle' | 'other';
|
|
201
|
+
reason?: string | null;
|
|
202
|
+
amount?: number | null;
|
|
203
|
+
currency?: string | null;
|
|
204
|
+
identityKey?: string | null;
|
|
205
|
+
occurredAt?: string;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export interface OutcomeReporter {
|
|
209
|
+
report(body: OutcomeReport): Promise<{ ok: boolean; recorded: string; orderRef: string }>;
|
|
210
|
+
captureStripeOutcome(event: unknown): Promise<{ skipped: boolean } | { ok: boolean }>;
|
|
211
|
+
}
|
|
212
|
+
export function stripeEventToOutcome(event: unknown): OutcomeReport | null;
|
|
213
|
+
export function createOutcomeReporter(options: {
|
|
214
|
+
apiKey: string;
|
|
215
|
+
collectorUrl?: string;
|
|
216
|
+
fetchImpl?: (url: string, init: object) => Promise<Response>;
|
|
217
|
+
}): OutcomeReporter;
|