agentpay-mcp 4.1.10 → 4.1.16

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.
Files changed (59) hide show
  1. package/README.md +13 -1
  2. package/dist/index.js +2 -2
  3. package/dist/utils/authorized-cybersecurity-scan-profile.d.ts +216 -0
  4. package/dist/utils/authorized-cybersecurity-scan-profile.d.ts.map +1 -0
  5. package/dist/utils/authorized-cybersecurity-scan-profile.js +130 -0
  6. package/dist/utils/authorized-cybersecurity-scan-profile.js.map +1 -0
  7. package/dist/utils/paid-provider-health-proof.d.ts +4 -4
  8. package/dist/utils/paid-tool-quality-threshold.d.ts +261 -0
  9. package/dist/utils/paid-tool-quality-threshold.d.ts.map +1 -0
  10. package/dist/utils/paid-tool-quality-threshold.js +155 -0
  11. package/dist/utils/paid-tool-quality-threshold.js.map +1 -0
  12. package/dist/utils/post-quantum-spend-envelope-compatibility.d.ts +22 -0
  13. package/dist/utils/post-quantum-spend-envelope-compatibility.d.ts.map +1 -0
  14. package/dist/utils/post-quantum-spend-envelope-compatibility.js +61 -0
  15. package/dist/utils/post-quantum-spend-envelope-compatibility.js.map +1 -0
  16. package/dist/utils/wallet-action-preflight-profile.d.ts +70 -0
  17. package/dist/utils/wallet-action-preflight-profile.d.ts.map +1 -0
  18. package/dist/utils/wallet-action-preflight-profile.js +151 -0
  19. package/dist/utils/wallet-action-preflight-profile.js.map +1 -0
  20. package/dist/utils/x402-chain-neutral-gateway-profile.d.ts +66 -0
  21. package/dist/utils/x402-chain-neutral-gateway-profile.d.ts.map +1 -0
  22. package/dist/utils/x402-chain-neutral-gateway-profile.js +145 -0
  23. package/dist/utils/x402-chain-neutral-gateway-profile.js.map +1 -0
  24. package/dist/utils/x402-dynamic-paid-mcp-manifest-drift.d.ts +82 -0
  25. package/dist/utils/x402-dynamic-paid-mcp-manifest-drift.d.ts.map +1 -0
  26. package/dist/utils/x402-dynamic-paid-mcp-manifest-drift.js +158 -0
  27. package/dist/utils/x402-dynamic-paid-mcp-manifest-drift.js.map +1 -0
  28. package/dist/utils/x402-multi-ledger-receipt.d.ts +64 -0
  29. package/dist/utils/x402-multi-ledger-receipt.d.ts.map +1 -0
  30. package/dist/utils/x402-multi-ledger-receipt.js +150 -0
  31. package/dist/utils/x402-multi-ledger-receipt.js.map +1 -0
  32. package/docs/agentpay-escrow-reputation-boundary.md +64 -0
  33. package/docs/agentpay-five-tool-parity-proof.json +56 -0
  34. package/docs/agentpay-five-tool-parity-proof.md +64 -0
  35. package/docs/agentpay-machine-payment-directory-listing-pack.md +101 -0
  36. package/docs/agentpay-machine-payment-directory-listing.json +41 -0
  37. package/docs/agentpay-paid-proxy-discovery-listing.json +42 -0
  38. package/docs/authorized-cybersecurity-scan-profile.md +56 -0
  39. package/docs/fixtures/authorized-cybersecurity-scan-profile-agentaegis-2026-05-04.json +43 -0
  40. package/docs/fixtures/chain-neutral-gateway-profile-rugmunch-2026-05-03.json +43 -0
  41. package/docs/fixtures/dynamic-paid-mcp-manifest-rugmunch-2026-05-04-baseline.json +67 -0
  42. package/docs/fixtures/dynamic-paid-mcp-manifest-rugmunch-2026-05-04.json +67 -0
  43. package/docs/fixtures/multi-ledger-receipt-xrpl-utilities-2026-05-04.json +35 -0
  44. package/docs/fixtures/paid-tool-quality-threshold-strale-2026-05-04.json +53 -0
  45. package/docs/fixtures/wallet-action-preflight-merx-2026-05-04.json +54 -0
  46. package/docs/paid-mcp-proxy-discovery-readiness.md +70 -0
  47. package/docs/paid-tool-quality-thresholds.md +47 -0
  48. package/docs/post-quantum-spend-envelope-compatibility.md +37 -0
  49. package/docs/smithery-paid-mcp-installation.md +180 -0
  50. package/docs/wallet-action-preflight-profile.md +57 -0
  51. package/docs/x402-chain-neutral-gateway-profile.md +65 -0
  52. package/docs/x402-chain-neutral-gateway-profile.schema.json +75 -0
  53. package/docs/x402-dynamic-paid-mcp-manifest-drift.md +41 -0
  54. package/docs/x402-dynamic-paid-mcp-manifest-drift.schema.json +193 -0
  55. package/docs/x402-multi-ledger-receipt-normalization.md +57 -0
  56. package/docs/x402-multi-ledger-receipt-normalization.schema.json +67 -0
  57. package/examples/smithery-paid-mcp-installation/README.md +63 -0
  58. package/llms.txt +4 -0
  59. package/package.json +2 -1
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  [![npm version](https://img.shields.io/npm/v/agentpay-mcp.svg)](https://www.npmjs.com/package/agentpay-mcp)
4
4
  [![Glama MCP Server](https://img.shields.io/badge/glama.ai-MCP%20server-1ee495?logo=githubsponsors&logoColor=1ee495&labelColor=0a0a0a)](https://glama.ai/mcp/servers/up2itnow0822/claw-pay-mcp)
5
5
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
6
- [![Tests](https://img.shields.io/badge/tests-222%20passing-brightgreen.svg)](tests/)
6
+ [![Tests](https://img.shields.io/badge/tests-273%20passing-brightgreen.svg)](tests/)
7
7
  [![Patent Pending](https://img.shields.io/badge/patent-pending-orange.svg)](https://uspto.gov)
8
8
 
9
9
  **Compatible with x402 V1/V2 + Stripe MPP — protocol-agnostic spend controls.**
@@ -96,12 +96,24 @@ AgentPay MCP is built for enterprise MCP deployments where supply chain security
96
96
  - **Directory introspection readiness.** For Glama, Smithery, and other MCP catalogs, use the [directory introspection readiness note](docs/directory-introspection-readiness.md) for verified `npx`, Docker, MCP name, and non-custodial metadata paths.
97
97
  - **x402 v2.11 paid MCP compatibility.** Use the [compatibility proof](docs/x402-v211-paid-mcp-compatibility.md) for `Payment-Signature`, `payment-response`, `mcp-session-id`, CORS exposed headers, Streamable HTTP initialize order, receipt links, and Base Sepolia to Base mainnet cutover.
98
98
  - **Directory-grade metadata proof.** Use the [registry/listing proof](docs/mcp-registry-listing-proof.md), `docs/mcp-registry-listing.json`, `glama.json`, `smithery.yaml`, and `llms.txt` for catalog crawlers and buyer agents.
99
+ - **Chain-neutral x402 gateway profile.** Use the [chain-neutral gateway profile proof](docs/x402-chain-neutral-gateway-profile.md), schema, and fixture to document supported networks, facilitator/settlement metadata, trial/refund policies, and directory manifests without leaking Base-only assumptions into non-EVM discovery.
100
+ - **Multi-ledger x402 receipt normalization.** Use the [multi-ledger receipt normalization proof](docs/x402-multi-ledger-receipt-normalization.md), schema, and XRPL fixture to normalize ledger labels, assets, settlement targets, `Payment-Signature`, `payment-response`, verification status, non-custodial boundaries, and unsupported-ledger refusals before signing.
101
+ - **Wallet-action preflight profile.** Use the [wallet-action preflight profile](docs/wallet-action-preflight-profile.md) and TRON fixture to require simulation, chain/resource caps, allowlists, recipient and amount confirmation, nonce guidance, and approval copy before irreversible sends, swaps, or resource purchases.
102
+ - **Machine-payment directory listing pack.** Use the [directory listing pack](docs/agentpay-machine-payment-directory-listing-pack.md) and [listing JSON](docs/agentpay-machine-payment-directory-listing.json) for MPP and paid-MCP directories without claiming unsupported non-EVM signing.
103
+ - **Five-tool x402 parity proof.** Use the [five-tool parity proof](docs/agentpay-five-tool-parity-proof.md) and [machine-readable map](docs/agentpay-five-tool-parity-proof.json) to map search, check, fetch, wallet, and pay flows to AgentPay's local-signer, approval-gated controls.
104
+ - **Escrow and reputation boundary.** Use the [escrow/reputation boundary proof](docs/agentpay-escrow-reputation-boundary.md) to keep x402 payment authorization separate from task escrow, identity, reputation, and work proof.
105
+ - **Paid MCP proxy and discovery readiness.** Use the [paid-proxy and discovery readiness pack](docs/paid-mcp-proxy-discovery-readiness.md) plus [listing JSON](docs/agentpay-paid-proxy-discovery-listing.json) for Toolstem/Cinderwright-style proxy and directory submissions.
106
+ - **Dynamic paid MCP manifest drift.** Use the [dynamic manifest drift proof](docs/x402-dynamic-paid-mcp-manifest-drift.md), schema, and Rug Munch fixtures to validate fresh `.well-known/x402` snapshots, stale-metadata warnings, no-trial/pricing clarity, supported networks, and directory endpoint freshness before buyer agents sign.
107
+ - **Smithery paid MCP installation.** Use the [Smithery install proof](docs/smithery-paid-mcp-installation.md) and [`examples/smithery-paid-mcp-installation`](examples/smithery-paid-mcp-installation/) for Smithery CLI, Vercel AI SDK MCP, `@smithery/api`, approval gates, spend-limit defaults, and fresh x402 manifest checks. Do not claim live Smithery verification until the listing is verified.
99
108
  - **x402-native vs Stripe-proxy MCP.** For builders comparing AgentPay MCP with emerging Stripe-proxy MCP repos, use the [x402-native vs Stripe-proxy note](docs/x402-native-vs-stripe-proxy.md) to keep approval gates, spend caps, audit rows, and non-custodial signing separate from proxy billing claims.
100
109
  - **Hosted x402 proxy verification.** Before an agent pays a hosted x402 MCP gateway, use the [hosted x402 proxy buyer checklist](docs/hosted-x402-proxy-verification.md) to verify `payment-required` headers, non-zero `payTo`, network and asset allowlists, approval state, spend cap, audit correlation, and pooled-token lock-in.
101
110
  - **Paid MCP discovery and budget response.** For SettleGrid-style discovery, metering, and budget-platform comparisons, use the [paid MCP discovery and budget response](docs/settlegrid-paid-mcp-discovery-response.md) to separate directory discovery from x402 buyer authorization.
102
111
  - **Buyer-flow parity for one-command x402 tools.** For AgentScore Pay-style buyer CLI comparisons, use the [AgentPay buyer-flow parity checklist](docs/agentpay-buyer-flow-parity.md) to prove discover, check, dry-run, pay, spend caps, typed payment errors, quota envelopes, no-charge failures, idempotency, MCP exposure, and audit before signing.
103
112
  - **Paid MCP gateway hardening.** For create-mcpay-style Worker scaffolds, use the [paid MCP gateway hardening checklist](docs/paid-mcp-gateway-hardening.md) to test signup, challenge parsing, key minting, atomic billing, scope defaults, no-charge validation failures, and buyer audit rows.
104
113
  - **Paid-provider health proof.** For Voidly-style public provider health feeds, use the [paid-provider health proof checklist](docs/paid-provider-health-proof.md) to verify provider success rate, stale streaks, receipt state, x402 network, asset, payTo, and fail-closed routing before signing.
114
+ - **Paid-tool quality thresholds.** For Strale-style scored catalogs, use the [paid-tool quality thresholds proof](docs/paid-tool-quality-thresholds.md) to verify fresh score fields, stale-score warnings, provider-health snapshots, minimum-quality rejection, and approval gates before x402 signing.
115
+ - **Authorized cybersecurity scans.** For AgentAegis-style paid security tools, use the [authorized cybersecurity-scan payment profile](docs/authorized-cybersecurity-scan-profile.md) to require target authorization, allowed-domain binding, per-target spend caps, scan-rate policy, approval prompts, and audit receipt language.
116
+ - **Post-quantum spend-envelope compatibility.** For PQSafe-style buyer questions, use the [post-quantum spend-envelope assessment](docs/post-quantum-spend-envelope-compatibility.md) to map spend limits, allowlists, x402 receipts, approval gates, and audit metadata without claiming ML-DSA implementation.
105
117
  - **Payment-critical dependency pins.** For x402 verifier and signing paths, AgentPay pins `viem` exactly at `2.48.7`, enforces the same root override, and runs a clean-install smoke check before release. See the [dependency pin policy](docs/dependency-pin-policy.md).
106
118
  - **WhatsApp and SMB agent controls.** For channel-native paid agents, use the [WhatsApp and SMB paid-agent controls recipe](docs/whatsapp-smb-agent-controls.md).
107
119
  - **Channel-agent affiliate payout controls.** For Axon-style affiliate and referral revenue shares, use the [channel-agent affiliate controls spec](docs/channel-agent-affiliate-controls.md) to keep payout caps, per-contact approval, audit rows, and optional x402 settlement separate from paid tool spend approval.
package/dist/index.js CHANGED
@@ -42,7 +42,7 @@ const otel_budget_js_1 = require("./tools/otel-budget.js");
42
42
  // ─── Server configuration ──────────────────────────────────────────────────
43
43
  const SERVER_INFO = {
44
44
  name: 'agentpay-mcp',
45
- version: '4.1.10',
45
+ version: '4.1.15',
46
46
  };
47
47
  const SERVER_CAPABILITIES = {
48
48
  tools: {},
@@ -261,7 +261,7 @@ async function main() {
261
261
  });
262
262
  await server.connect(transport);
263
263
  // Log to stderr (not stdout — stdout is reserved for MCP protocol)
264
- process.stderr.write(`AgentPay MCP v4.1.10 started. ` +
264
+ process.stderr.write(`AgentPay MCP v4.1.15 started. ` +
265
265
  `Wallet: ${process.env['AGENT_WALLET_ADDRESS'] ?? '(not configured)'} | ` +
266
266
  `Chain: ${process.env['CHAIN_ID'] ?? '8453 (Base Mainnet)'} | ` +
267
267
  `Session TTL: ${process.env['SESSION_TTL_SECONDS'] ?? '3600'}s\n`);
@@ -0,0 +1,216 @@
1
+ /**
2
+ * Authorized cybersecurity-scan payment profile helpers.
3
+ *
4
+ * Paid security tools need tighter guards than general data APIs. These helpers
5
+ * require target authorization, allowed-domain binding, per-target spend caps,
6
+ * scan-rate policy, human approval, and audit receipt language before x402
7
+ * signing can proceed.
8
+ */
9
+ import { z } from 'zod';
10
+ export declare const AuthorizedCyberScanProfileSchema: z.ZodObject<{
11
+ schema: z.ZodLiteral<"agentpay-authorized-cybersecurity-scan-profile/v1">;
12
+ generated_at: z.ZodEffects<z.ZodString, string, string>;
13
+ scan: z.ZodObject<{
14
+ tool_id: z.ZodString;
15
+ category: z.ZodEnum<["vulnerability_scan", "compliance_check", "threat_intel_lookup", "security_audit"]>;
16
+ target: z.ZodString;
17
+ target_domain: z.ZodString;
18
+ requested_by_agent: z.ZodString;
19
+ }, "strip", z.ZodTypeAny, {
20
+ target: string;
21
+ tool_id: string;
22
+ category: "vulnerability_scan" | "compliance_check" | "threat_intel_lookup" | "security_audit";
23
+ target_domain: string;
24
+ requested_by_agent: string;
25
+ }, {
26
+ target: string;
27
+ tool_id: string;
28
+ category: "vulnerability_scan" | "compliance_check" | "threat_intel_lookup" | "security_audit";
29
+ target_domain: string;
30
+ requested_by_agent: string;
31
+ }>;
32
+ authorization: z.ZodObject<{
33
+ attestation_id: z.ZodString;
34
+ granted_by: z.ZodString;
35
+ granted_at: z.ZodEffects<z.ZodString, string, string>;
36
+ expires_at: z.ZodEffects<z.ZodString, string, string>;
37
+ allowed_domains: z.ZodArray<z.ZodString, "many">;
38
+ allowed_scan_categories: z.ZodArray<z.ZodEnum<["vulnerability_scan", "compliance_check", "threat_intel_lookup", "security_audit"]>, "many">;
39
+ proof_uri: z.ZodOptional<z.ZodString>;
40
+ }, "strip", z.ZodTypeAny, {
41
+ attestation_id: string;
42
+ granted_by: string;
43
+ granted_at: string;
44
+ expires_at: string;
45
+ allowed_domains: string[];
46
+ allowed_scan_categories: ("vulnerability_scan" | "compliance_check" | "threat_intel_lookup" | "security_audit")[];
47
+ proof_uri?: string | undefined;
48
+ }, {
49
+ attestation_id: string;
50
+ granted_by: string;
51
+ granted_at: string;
52
+ expires_at: string;
53
+ allowed_domains: string[];
54
+ allowed_scan_categories: ("vulnerability_scan" | "compliance_check" | "threat_intel_lookup" | "security_audit")[];
55
+ proof_uri?: string | undefined;
56
+ }>;
57
+ spend_policy: z.ZodObject<{
58
+ currency: z.ZodLiteral<"USD">;
59
+ per_target_cap_usd: z.ZodNumber;
60
+ spent_for_target_usd: z.ZodNumber;
61
+ requested_cost_usd: z.ZodNumber;
62
+ x402_max_amount_required: z.ZodEffects<z.ZodString, string, string>;
63
+ }, "strip", z.ZodTypeAny, {
64
+ currency: "USD";
65
+ per_target_cap_usd: number;
66
+ spent_for_target_usd: number;
67
+ requested_cost_usd: number;
68
+ x402_max_amount_required: string;
69
+ }, {
70
+ currency: "USD";
71
+ per_target_cap_usd: number;
72
+ spent_for_target_usd: number;
73
+ requested_cost_usd: number;
74
+ x402_max_amount_required: string;
75
+ }>;
76
+ rate_limit: z.ZodObject<{
77
+ window_seconds: z.ZodNumber;
78
+ max_scans_per_window: z.ZodNumber;
79
+ scans_used_in_window: z.ZodNumber;
80
+ }, "strip", z.ZodTypeAny, {
81
+ window_seconds: number;
82
+ max_scans_per_window: number;
83
+ scans_used_in_window: number;
84
+ }, {
85
+ window_seconds: number;
86
+ max_scans_per_window: number;
87
+ scans_used_in_window: number;
88
+ }>;
89
+ approval_gate: z.ZodObject<{
90
+ fail_closed: z.ZodLiteral<true>;
91
+ requires_human_approval: z.ZodLiteral<true>;
92
+ approved: z.ZodBoolean;
93
+ prompt: z.ZodString;
94
+ }, "strip", z.ZodTypeAny, {
95
+ approved: boolean;
96
+ fail_closed: true;
97
+ requires_human_approval: true;
98
+ prompt: string;
99
+ }, {
100
+ approved: boolean;
101
+ fail_closed: true;
102
+ requires_human_approval: true;
103
+ prompt: string;
104
+ }>;
105
+ audit_receipt: z.ZodObject<{
106
+ receipt_id: z.ZodString;
107
+ retention_days: z.ZodNumber;
108
+ language: z.ZodString;
109
+ }, "strip", z.ZodTypeAny, {
110
+ receipt_id: string;
111
+ retention_days: number;
112
+ language: string;
113
+ }, {
114
+ receipt_id: string;
115
+ retention_days: number;
116
+ language: string;
117
+ }>;
118
+ }, "strip", z.ZodTypeAny, {
119
+ authorization: {
120
+ attestation_id: string;
121
+ granted_by: string;
122
+ granted_at: string;
123
+ expires_at: string;
124
+ allowed_domains: string[];
125
+ allowed_scan_categories: ("vulnerability_scan" | "compliance_check" | "threat_intel_lookup" | "security_audit")[];
126
+ proof_uri?: string | undefined;
127
+ };
128
+ schema: "agentpay-authorized-cybersecurity-scan-profile/v1";
129
+ generated_at: string;
130
+ scan: {
131
+ target: string;
132
+ tool_id: string;
133
+ category: "vulnerability_scan" | "compliance_check" | "threat_intel_lookup" | "security_audit";
134
+ target_domain: string;
135
+ requested_by_agent: string;
136
+ };
137
+ spend_policy: {
138
+ currency: "USD";
139
+ per_target_cap_usd: number;
140
+ spent_for_target_usd: number;
141
+ requested_cost_usd: number;
142
+ x402_max_amount_required: string;
143
+ };
144
+ rate_limit: {
145
+ window_seconds: number;
146
+ max_scans_per_window: number;
147
+ scans_used_in_window: number;
148
+ };
149
+ approval_gate: {
150
+ approved: boolean;
151
+ fail_closed: true;
152
+ requires_human_approval: true;
153
+ prompt: string;
154
+ };
155
+ audit_receipt: {
156
+ receipt_id: string;
157
+ retention_days: number;
158
+ language: string;
159
+ };
160
+ }, {
161
+ authorization: {
162
+ attestation_id: string;
163
+ granted_by: string;
164
+ granted_at: string;
165
+ expires_at: string;
166
+ allowed_domains: string[];
167
+ allowed_scan_categories: ("vulnerability_scan" | "compliance_check" | "threat_intel_lookup" | "security_audit")[];
168
+ proof_uri?: string | undefined;
169
+ };
170
+ schema: "agentpay-authorized-cybersecurity-scan-profile/v1";
171
+ generated_at: string;
172
+ scan: {
173
+ target: string;
174
+ tool_id: string;
175
+ category: "vulnerability_scan" | "compliance_check" | "threat_intel_lookup" | "security_audit";
176
+ target_domain: string;
177
+ requested_by_agent: string;
178
+ };
179
+ spend_policy: {
180
+ currency: "USD";
181
+ per_target_cap_usd: number;
182
+ spent_for_target_usd: number;
183
+ requested_cost_usd: number;
184
+ x402_max_amount_required: string;
185
+ };
186
+ rate_limit: {
187
+ window_seconds: number;
188
+ max_scans_per_window: number;
189
+ scans_used_in_window: number;
190
+ };
191
+ approval_gate: {
192
+ approved: boolean;
193
+ fail_closed: true;
194
+ requires_human_approval: true;
195
+ prompt: string;
196
+ };
197
+ audit_receipt: {
198
+ receipt_id: string;
199
+ retention_days: number;
200
+ language: string;
201
+ };
202
+ }>;
203
+ export type AuthorizedCyberScanProfile = z.infer<typeof AuthorizedCyberScanProfileSchema>;
204
+ export type AuthorizedCyberScanPolicy = {
205
+ now?: Date;
206
+ allowedDomains: string[];
207
+ maxRequestedCostUsd: number;
208
+ minReceiptRetentionDays: number;
209
+ };
210
+ export type AuthorizedCyberScanDecision = {
211
+ ok: boolean;
212
+ failures: string[];
213
+ warnings: string[];
214
+ };
215
+ export declare function evaluateAuthorizedCyberScanProfile(profileInput: unknown, policy: AuthorizedCyberScanPolicy): AuthorizedCyberScanDecision;
216
+ //# sourceMappingURL=authorized-cybersecurity-scan-profile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authorized-cybersecurity-scan-profile.d.ts","sourceRoot":"","sources":["../../src/utils/authorized-cybersecurity-scan-profile.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAWxB,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0C3C,CAAC;AAEH,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gCAAgC,CAAC,CAAC;AAE1F,MAAM,MAAM,yBAAyB,GAAG;IACtC,GAAG,CAAC,EAAE,IAAI,CAAC;IACX,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,uBAAuB,EAAE,MAAM,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG;IACxC,EAAE,EAAE,OAAO,CAAC;IACZ,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB,CAAC;AAUF,wBAAgB,kCAAkC,CAChD,YAAY,EAAE,OAAO,EACrB,MAAM,EAAE,yBAAyB,GAChC,2BAA2B,CA0E7B"}
@@ -0,0 +1,130 @@
1
+ "use strict";
2
+ /**
3
+ * Authorized cybersecurity-scan payment profile helpers.
4
+ *
5
+ * Paid security tools need tighter guards than general data APIs. These helpers
6
+ * require target authorization, allowed-domain binding, per-target spend caps,
7
+ * scan-rate policy, human approval, and audit receipt language before x402
8
+ * signing can proceed.
9
+ */
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.AuthorizedCyberScanProfileSchema = void 0;
12
+ exports.evaluateAuthorizedCyberScanProfile = evaluateAuthorizedCyberScanProfile;
13
+ const zod_1 = require("zod");
14
+ const isoDateString = zod_1.z.string().refine((value) => !Number.isNaN(Date.parse(value)), {
15
+ message: 'must be an ISO-8601 timestamp',
16
+ });
17
+ const positiveIntegerString = zod_1.z
18
+ .string()
19
+ .regex(/^\d+$/)
20
+ .refine((value) => BigInt(value) > 0n, { message: 'amount must be greater than zero' });
21
+ exports.AuthorizedCyberScanProfileSchema = zod_1.z.object({
22
+ schema: zod_1.z.literal('agentpay-authorized-cybersecurity-scan-profile/v1'),
23
+ generated_at: isoDateString,
24
+ scan: zod_1.z.object({
25
+ tool_id: zod_1.z.string().min(1),
26
+ category: zod_1.z.enum(['vulnerability_scan', 'compliance_check', 'threat_intel_lookup', 'security_audit']),
27
+ target: zod_1.z.string().min(1),
28
+ target_domain: zod_1.z.string().min(1),
29
+ requested_by_agent: zod_1.z.string().min(1),
30
+ }),
31
+ authorization: zod_1.z.object({
32
+ attestation_id: zod_1.z.string().min(1),
33
+ granted_by: zod_1.z.string().min(1),
34
+ granted_at: isoDateString,
35
+ expires_at: isoDateString,
36
+ allowed_domains: zod_1.z.array(zod_1.z.string().min(1)).min(1),
37
+ allowed_scan_categories: zod_1.z.array(zod_1.z.enum(['vulnerability_scan', 'compliance_check', 'threat_intel_lookup', 'security_audit'])).min(1),
38
+ proof_uri: zod_1.z.string().url().optional(),
39
+ }),
40
+ spend_policy: zod_1.z.object({
41
+ currency: zod_1.z.literal('USD'),
42
+ per_target_cap_usd: zod_1.z.number().positive(),
43
+ spent_for_target_usd: zod_1.z.number().nonnegative(),
44
+ requested_cost_usd: zod_1.z.number().positive(),
45
+ x402_max_amount_required: positiveIntegerString,
46
+ }),
47
+ rate_limit: zod_1.z.object({
48
+ window_seconds: zod_1.z.number().int().positive(),
49
+ max_scans_per_window: zod_1.z.number().int().positive(),
50
+ scans_used_in_window: zod_1.z.number().int().nonnegative(),
51
+ }),
52
+ approval_gate: zod_1.z.object({
53
+ fail_closed: zod_1.z.literal(true),
54
+ requires_human_approval: zod_1.z.literal(true),
55
+ approved: zod_1.z.boolean(),
56
+ prompt: zod_1.z.string().min(1),
57
+ }),
58
+ audit_receipt: zod_1.z.object({
59
+ receipt_id: zod_1.z.string().min(1),
60
+ retention_days: zod_1.z.number().int().positive(),
61
+ language: zod_1.z.string().min(40),
62
+ }),
63
+ });
64
+ function sameDomain(left, right) {
65
+ return left.toLowerCase() === right.toLowerCase();
66
+ }
67
+ function includesDomain(domains, targetDomain) {
68
+ return domains.some((domain) => sameDomain(domain, targetDomain));
69
+ }
70
+ function evaluateAuthorizedCyberScanProfile(profileInput, policy) {
71
+ const parsed = exports.AuthorizedCyberScanProfileSchema.safeParse(profileInput);
72
+ const failures = [];
73
+ const warnings = [];
74
+ if (!parsed.success) {
75
+ return {
76
+ ok: false,
77
+ failures: parsed.error.issues.map((issue) => `${issue.path.join('.')}: ${issue.message}`),
78
+ warnings,
79
+ };
80
+ }
81
+ const profile = parsed.data;
82
+ const now = policy.now ?? new Date();
83
+ const expiresAt = new Date(profile.authorization.expires_at);
84
+ const grantedAt = new Date(profile.authorization.granted_at);
85
+ if (grantedAt.getTime() > now.getTime()) {
86
+ failures.push('Target authorization is not active yet.');
87
+ }
88
+ if (expiresAt.getTime() <= now.getTime()) {
89
+ failures.push('Target authorization is expired.');
90
+ }
91
+ if (!includesDomain(profile.authorization.allowed_domains, profile.scan.target_domain)) {
92
+ failures.push(`Target domain ${profile.scan.target_domain} is not listed in the authorization attestation.`);
93
+ }
94
+ if (!includesDomain(policy.allowedDomains, profile.scan.target_domain)) {
95
+ failures.push(`Target domain ${profile.scan.target_domain} is not allowed by buyer policy.`);
96
+ }
97
+ if (!profile.authorization.allowed_scan_categories.includes(profile.scan.category)) {
98
+ failures.push(`Scan category ${profile.scan.category} is not authorized for target ${profile.scan.target_domain}.`);
99
+ }
100
+ if (profile.spend_policy.requested_cost_usd > policy.maxRequestedCostUsd) {
101
+ failures.push(`Requested scan cost ${profile.spend_policy.requested_cost_usd} exceeds buyer max ${policy.maxRequestedCostUsd}.`);
102
+ }
103
+ if (profile.spend_policy.spent_for_target_usd + profile.spend_policy.requested_cost_usd > profile.spend_policy.per_target_cap_usd) {
104
+ failures.push('Requested scan would exceed the per-target spend cap.');
105
+ }
106
+ if (profile.rate_limit.scans_used_in_window >= profile.rate_limit.max_scans_per_window) {
107
+ failures.push('Scan rate limit is exhausted for this target window.');
108
+ }
109
+ if (!profile.approval_gate.approved) {
110
+ failures.push('Human approval has not been granted for this paid cybersecurity scan.');
111
+ }
112
+ if (!profile.approval_gate.prompt.includes(profile.scan.target_domain)) {
113
+ warnings.push('Approval prompt does not name the target domain.');
114
+ }
115
+ if (profile.audit_receipt.retention_days < policy.minReceiptRetentionDays) {
116
+ failures.push(`Audit receipt retention ${profile.audit_receipt.retention_days} days is below required ${policy.minReceiptRetentionDays}.`);
117
+ }
118
+ const language = profile.audit_receipt.language.toLowerCase();
119
+ for (const requiredPhrase of ['authorized target', 'spend cap', 'x402 receipt']) {
120
+ if (!language.includes(requiredPhrase)) {
121
+ failures.push(`Audit receipt language must include "${requiredPhrase}".`);
122
+ }
123
+ }
124
+ return {
125
+ ok: failures.length === 0,
126
+ failures,
127
+ warnings,
128
+ };
129
+ }
130
+ //# sourceMappingURL=authorized-cybersecurity-scan-profile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authorized-cybersecurity-scan-profile.js","sourceRoot":"","sources":["../../src/utils/authorized-cybersecurity-scan-profile.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAgFH,gFA6EC;AA3JD,6BAAwB;AAExB,MAAM,aAAa,GAAG,OAAC,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE;IACnF,OAAO,EAAE,+BAA+B;CACzC,CAAC,CAAC;AAEH,MAAM,qBAAqB,GAAG,OAAC;KAC5B,MAAM,EAAE;KACR,KAAK,CAAC,OAAO,CAAC;KACd,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE,EAAE,OAAO,EAAE,kCAAkC,EAAE,CAAC,CAAC;AAE7E,QAAA,gCAAgC,GAAG,OAAC,CAAC,MAAM,CAAC;IACvD,MAAM,EAAE,OAAC,CAAC,OAAO,CAAC,mDAAmD,CAAC;IACtE,YAAY,EAAE,aAAa;IAC3B,IAAI,EAAE,OAAC,CAAC,MAAM,CAAC;QACb,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;QAC1B,QAAQ,EAAE,OAAC,CAAC,IAAI,CAA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AM,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC;QACvE,QAAQ,CAAC,IAAI,CAAC,kDAAkD,CAAC,CAAC;IACpE,CAAC;IAED,IAAI,OAAO,CAAC,aAAa,CAAC,cAAc,GAAG,MAAM,CAAC,uBAAuB,EAAE,CAAC;QAC1E,QAAQ,CAAC,IAAI,CAAC,2BAA2B,OAAO,CAAC,aAAa,CAAC,cAAc,2BAA2B,MAAM,CAAC,uBAAuB,GAAG,CAAC,CAAC;IAC7I,CAAC;IAED,MAAM,QAAQ,GAAG,OAAO,CAAC,aAAa,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC;IAC9D,KAAK,MAAM,cAAc,IAAI,CAAC,mBAAmB,EAAE,WAAW,EAAE,cAAc,CAAC,EAAE,CAAC;QAChF,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC;YACvC,QAAQ,CAAC,IAAI,CAAC,wCAAwC,cAAc,IAAI,CAAC,CAAC;QAC5E,CAAC;IACH,CAAC;IAED,OAAO;QACL,EAAE,EAAE,QAAQ,CAAC,MAAM,KAAK,CAAC;QACzB,QAAQ;QACR,QAAQ;KACT,CAAC;AACJ,CAAC"}
@@ -128,10 +128,10 @@ export declare const PaidProviderHealthProofSchema: z.ZodObject<{
128
128
  receipt_state: "verified" | "pending_acceptance_verified" | "missing" | "invalid" | "unverified";
129
129
  verified: boolean;
130
130
  error?: string | undefined;
131
+ receipt_id?: string | undefined;
131
132
  latency_ms?: number | undefined;
132
133
  capability?: string | undefined;
133
134
  capability_id?: string | undefined;
134
- receipt_id?: string | undefined;
135
135
  x402_payment?: {
136
136
  scheme: "exact";
137
137
  network: string;
@@ -149,10 +149,10 @@ export declare const PaidProviderHealthProofSchema: z.ZodObject<{
149
149
  receipt_state: "verified" | "pending_acceptance_verified" | "missing" | "invalid" | "unverified";
150
150
  verified: boolean;
151
151
  error?: string | undefined;
152
+ receipt_id?: string | undefined;
152
153
  latency_ms?: number | undefined;
153
154
  capability?: string | undefined;
154
155
  capability_id?: string | undefined;
155
- receipt_id?: string | undefined;
156
156
  x402_payment?: {
157
157
  network: string;
158
158
  asset: string;
@@ -204,10 +204,10 @@ export declare const PaidProviderHealthProofSchema: z.ZodObject<{
204
204
  receipt_state: "verified" | "pending_acceptance_verified" | "missing" | "invalid" | "unverified";
205
205
  verified: boolean;
206
206
  error?: string | undefined;
207
+ receipt_id?: string | undefined;
207
208
  latency_ms?: number | undefined;
208
209
  capability?: string | undefined;
209
210
  capability_id?: string | undefined;
210
- receipt_id?: string | undefined;
211
211
  x402_payment?: {
212
212
  scheme: "exact";
213
213
  network: string;
@@ -251,10 +251,10 @@ export declare const PaidProviderHealthProofSchema: z.ZodObject<{
251
251
  receipt_state: "verified" | "pending_acceptance_verified" | "missing" | "invalid" | "unverified";
252
252
  verified: boolean;
253
253
  error?: string | undefined;
254
+ receipt_id?: string | undefined;
254
255
  latency_ms?: number | undefined;
255
256
  capability?: string | undefined;
256
257
  capability_id?: string | undefined;
257
- receipt_id?: string | undefined;
258
258
  x402_payment?: {
259
259
  network: string;
260
260
  asset: string;