diff --git a/docs/facilitator-readiness.md b/docs/facilitator-readiness.md new file mode 100644 index 0000000..0e34306 --- /dev/null +++ b/docs/facilitator-readiness.md @@ -0,0 +1,27 @@ +# Mainnet facilitator compatibility + +Checked **1 October 2026** with public documentation and unauthenticated `GET /supported` and `GET /pricing` requests only. No payment was signed, verified, submitted or settled. Nothing here selects a provider, enables either payment rail, or installs a trusted sponsor. + +## Public exact-payment option: PayAI + +The [official Solana mainnet guide](https://docs.payai.network/x402/solana-mainnet-express) documents `https://facilitator.payai.network` for x402 v2 exact native-USDC payments. Its current tested example uses `@x402/*` 2.27.0; Allowance pins 2.25.0. Their request envelopes match the installed SDK and Allowance's bounded adapter, but discovery compatibility does not establish funded interoperability. + +At 06:20 UTC, [public discovery](https://facilitator.payai.network/supported) returned HTTP 200 with v2 `exact` for `solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp`, and `extra.feePayer` was `CjNFTjvBhbJJd2B5ePPMHRLx1ELZpa8dwQgGL727eKww`. This is dated observation, **not a permanent configuration value**. Obtain the response again through the same authentication lane used for settlement, review the sponsor, and explicitly configure `TRUSTED_FEE_PAYER`. A changed sponsor must fail closed until reviewed. + +The response also included legacy v1 names such as `base-sepolia` and `solana`. Allowance now validates these separately and removes all v1 capabilities before exposing discovery to its v2 client. Malformed v2 identifiers still reject the entire response, and actual spending still requires the configured network, exact scheme and pinned sponsor. + +The [authentication guide](https://docs.payai.network/x402/facilitators/authentication) permits ordinary exact payments without credentials within the public allowance. Authenticated service uses a short-lived Ed25519 JWT generated from a merchant key ID and secret; a raw API secret is not a bearer token. Authenticated discovery can return an account-specific sponsor. Allowance's current static `FACILITATOR_TOKEN` does not refresh these JWTs: sustained authenticated PayAI service needs an auth adapter or compatible gateway. Do not paste a private key into that setting. + +The [pricing guide](https://docs.payai.network/x402/facilitators/pricing) gives new receiving wallets **1,000 lifetime free credits**, not a monthly allowance. Shared host/IP pools can exhaust access earlier. Beyond that allowance, credits cost $0.001 each and settlements are priced at measured network gas plus 30%. The [live rate table](https://facilitator.payai.network/pricing), read at 06:20 UTC, listed mainnet exact transfers at 1.62 credits ($0.00162) each, effective 27 September 2026. Rates can change. This service charge is separate from an API's USDC price. + +The [capacity guide](https://docs.payai.network/x402/facilitators/capacity-and-limits) warns that a timeout or `settlement_pending` can leave the transaction unresolved, including an empty Solana transaction field. Allowance retains its original authorization and conservative hold; a read of `/supported` cannot validate that recovery against a real provider. Token-account initialization also requires separate funding; sponsorship of the purchase does not create the required merchant USDC account. + +## Authenticated alternative: Coinbase CDP + +The [CDP facilitator documentation](https://docs.cdp.coinbase.com/x402/seller/facilitator) lists v2 exact Solana mainnet and requires a CDP API key ID and secret. It advertises 1,000 free onchain transactions each month and $0.001 per additional transaction. The [production guide](https://docs.cdp.coinbase.com/x402/seller/production-configuration) uses `createCdpFacilitatorClient` for authentication; direct REST requests require signed bearer JWTs. Allowance needs a compatible authentication adapter or gateway before this is a durable alternative. The documented endpoint is `https://api.cdp.coinbase.com/platform/v2/x402`; no authenticated request was made. + +The default public test endpoint, `https://x402.org/facilitator/supported`, returned HTTP 200 but **no v2 exact Solana mainnet capability** at this check. Its successful response is not evidence that it can settle mainnet purchases. + +## Still required for a real payment + +Provision the persistent backend and operator access, an explicit mainnet RPC, dedicated payer key, initialized and funded payer USDC account, separate initialized merchant USDC account, reviewed sponsor, and bounded spending authorization. Select a provider whose account or public allowance is available from the deployed host. Then run the documented preflight and one intended funded scenario, preserving uncertain outcomes and independently checking chain evidence. The absence of a facilitator API key alone is not necessarily a blocker for PayAI's public exact lane; absent payer funds, signing authority and merchant configuration remain blockers. diff --git a/docs/launch-film.md b/docs/launch-film.md new file mode 100644 index 0000000..08a64e0 --- /dev/null +++ b/docs/launch-film.md @@ -0,0 +1,29 @@ +# Allowance launch film + +The landing page includes the supplied 30-second brand film under **Watch launch film**. It sits after the interactive allowance story and links separately to the recorded app walkthrough at `/demo#product-tour`. + +The film uses the approved curved A mark and shows a policy plan: a 0.040000 USDC allowance, 0.030000 in planned tool costs, and an additional request blocked before signing. Its receipt is explicitly labeled **Policy outcome** and **Policy plan · No funds moved**. This is brand storytelling; actual settlement evidence remains in connected workspace receipts. + +## Supplied delivery and published copies + +The delivery project is `allowance-showreel/out/deliver`. Its master, web delivery, and cover were kept unchanged. The site uses the supplied web delivery byte for byte, including its original music and sound effects. No voice or other audio was generated or substituted. + +| Supplied file | Published file | SHA-256 | +| ------------------------------- | ----------------------------------------------- | ------------------------------------------------------------------ | +| `allowance-showreel-master.mp4` | Not copied into the site | `7c2e83519a5a7439562432ec215e56b8f12d1e04c005e77abf0ef8cdec931ef6` | +| `allowance-showreel-web.mp4` | `public/media/allowance-launch-film.mp4` | `ed934c2d40235a40abfe2135d532081ce73d1a0173b0c74bd16217d83ac9ef64` | +| `allowance-showreel-cover.jpg` | `public/media/allowance-launch-film-poster.jpg` | `8a61fab658fe876c5c92b2aea88c35428cc96d85da6bd73c96035305e65c1814` | + +Web delivery: 9,384,026 bytes; 30.000 seconds; H.264, 1920 × 1080, 60 frames per second; stereo AAC at 48 kHz. Its MP4 metadata precedes the media payload, so playback supports progressive loading. The 18,099,480-byte master remains in the supplied delivery folder. + +The delivery project's README credits Tatamusic's **Stylish Fashion Show Music** from Pixabay and describes a music/SFX soundtrack. This attribution comes from the supplied project documentation. The integration does not add narration or claim that the footage verifies a payment. + +## Playback and access + +- The film waits for an explicit Play action, with `preload="none"` and native playback controls. It does not autoplay or change the existing decorative film preferences. +- The supplied cover stays visible before playback. The layout reserves its dimensions to prevent a page jump. +- **Read the visual story** provides an accurate text alternative for the on-screen scenes. There was no speech transcript or caption file in the delivery folder; no speech captions were invented. +- A readable failure message, the text alternative, and the actual app walkthrough remain available if media cannot load. +- **Save film** downloads the original web delivery. + +Browser coverage is in `tests/browser/launch-film.spec.ts`: no initial MP4 fetch, user-initiated playback and metadata, exact download hash, phone layout, and failure recovery. The supplied footage was inspected using a contact sheet and full-resolution policy-outcome frames; this review found no claimed verified transaction or transaction signature. diff --git a/docs/live-setup.md b/docs/live-setup.md index 5af363e..3b4ca52 100644 --- a/docs/live-setup.md +++ b/docs/live-setup.md @@ -23,6 +23,8 @@ Keep `LIVE_PAYMENTS_ENABLED=false` and `DIRECT_PAYMENTS_ENABLED=false` during in Canonical network values are fixed in `shared/domain.ts`: mainnet `solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp`, native USDC `EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v`, six decimals. These match the [official x402 exact SVM specification](https://github.com/x402-foundation/x402/blob/main/specs/schemes/exact/scheme_exact_svm.md) and [Circle USDC contract addresses](https://developers.circle.com/stablecoins/usdc-contract-addresses), checked 19 September 2026. A supported response is compatibility evidence, not payment proof. +See the [dated facilitator compatibility check](facilitator-readiness.md) for PayAI's public exact-payment allowance, current discovery evidence, and authentication limitations of this client. + ## Mainnet direct-payment configuration Direct transfers use the same dedicated payer, payment network/RPC and shared daily ceiling, with their own mandate limits. Explicitly set `PAYMENT_NETWORK=mainnet`, `PAYMENT_RPC_URL`, `MAINNET_PAYMENTS_ACKNOWLEDGED=true` and, only after reviewing the intended capability, `DIRECT_PAYMENTS_ENABLED=true`. This rail does not require `LIVE_PAYMENTS_ENABLED`, a merchant recipient, facilitator or sponsor. The network default remains mainnet; the [direct-payment guide](direct-payments.md) deliberately uses explicit devnet settings for its funded verification procedure. diff --git a/playwright.hosted.config.ts b/playwright.hosted.config.ts index 44c3854..3dfcae0 100644 --- a/playwright.hosted.config.ts +++ b/playwright.hosted.config.ts @@ -11,6 +11,7 @@ export default defineConfig({ 'pwa.spec.ts', 'navigation.spec.ts', 'product-tour.spec.ts', + 'launch-film.spec.ts', ], timeout: 60000, expect: { timeout: 15000 }, diff --git a/public/media/allowance-launch-film-poster.jpg b/public/media/allowance-launch-film-poster.jpg new file mode 100644 index 0000000..8b351d1 Binary files /dev/null and b/public/media/allowance-launch-film-poster.jpg differ diff --git a/public/media/allowance-launch-film.mp4 b/public/media/allowance-launch-film.mp4 new file mode 100644 index 0000000..31f8410 Binary files /dev/null and b/public/media/allowance-launch-film.mp4 differ diff --git a/server/payments/facilitator.ts b/server/payments/facilitator.ts index 047f07b..e5a5747 100644 --- a/server/payments/facilitator.ts +++ b/server/payments/facilitator.ts @@ -54,14 +54,24 @@ const verificationSchema = z.object({ const supportedSchema = z.object({ kinds: z .array( - z.object({ - x402Version: z.number().int().min(1).max(2), - scheme: z.string().max(64), - network, - extra, - }) + z.discriminatedUnion('x402Version', [ + z.object({ + x402Version: z.literal(1), + scheme: z.string().max(64), + network: z.union([network, z.string().regex(/^[a-z0-9][a-z0-9-]{0,127}$/)]), + extra, + }), + z.object({ + x402Version: z.literal(2), + scheme: z.string().max(64), + network, + extra, + }), + ]) ) - .max(128), + .max(128) + // Providers advertise legacy names alongside CAIP-2 kinds; this client only uses v2. + .transform((kinds) => kinds.filter((kind) => kind.x402Version === 2)), extensions: z.array(z.string().max(128)).max(64).default([]), signers: z.record(z.string(), z.array(z.string().max(128)).max(64)).default({}), }); diff --git a/src/App.tsx b/src/App.tsx index a7a4d5d..8676cdd 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -76,6 +76,7 @@ import LandingStory from './LandingStory'; import PolicyLab from './PolicyLab'; import WorkspaceShell, { getWorkspaceView } from './WorkspaceNav'; import ProductTour from './ProductTour'; +import LaunchFilm from './LaunchFilm'; function Logo({ compact = false }: { compact?: boolean }) { return ( @@ -475,9 +476,9 @@ function Landing() { Open walkthrough - - See how it works - + + Watch launch film +
@@ -542,6 +543,7 @@ function Landing() { /> +
Enough freedom to be useful. diff --git a/src/LaunchFilm.tsx b/src/LaunchFilm.tsx new file mode 100644 index 0000000..9a506c8 --- /dev/null +++ b/src/LaunchFilm.tsx @@ -0,0 +1,129 @@ +import { useRef, useState } from 'react'; +import { ArrowDownToLine, ArrowRight, Film, Play } from 'lucide-react'; +import { Link } from 'react-router-dom'; +import './launch-film.css'; + +export default function LaunchFilm() { + const video = useRef(null); + const unavailable = useRef(false); + const [started, setStarted] = useState(false); + const [failed, setFailed] = useState(false); + const [message, setMessage] = useState(''); + function playbackFailed() { + unavailable.current = true; + setFailed(true); + setMessage( + 'The launch film could not load. Read the visual story below or open the app walkthrough.' + ); + } + async function play() { + const player = video.current; + if (!player || failed) return; + setMessage(''); + try { + await player.play(); + } catch { + if (!unavailable.current && !player.error) + setMessage('Press play in the video controls to start the film.'); + } + } + return ( +
+
+
+
+
+

+ A little independence. +
+ A clear limit. +

+
+

+ A short brand story about useful agents and the boundaries you set. Planning scenes. No + funds moved. +

+
+
+ + {!started && !failed && ( + + )} +
+

+ {message} +

+
+
+ Behind the idea. + Budgets, useful work, and the decisions in between. +
+ + + + Open the app walkthrough
+
+ Read the visual story +

This description follows the on-screen scenes in the supplied launch film.

+
    +
  1. + A little independence. The red Allowance A takes shape, followed by “Give your + agent a budget.” +
  2. +
  3. + You decide what’s enough. A policy card sets a 0.040000 USDC allowance, a + 0.020000 per-request cap, daily capacity, and permitted tools. +
  4. +
  5. + Small purchases. A fuller picture. A wallet snapshot and a transaction + explanation bring planned tool costs to 0.030000 USDC, leaving 0.010000. +
  6. +
  7. + Blocked before signing. Another 0.020000 request exceeds the remaining allowance. + The policy outcome keeps the permitted requests and the blocked decision together, + marked “No funds moved.” +
  8. +
  9. + Find the right amount of freedom. A sculptural red A stands above the water. The + film closes with the Allowance identity and an invitation to explore the policy lab. +
  10. +
+
+
+ ); +} diff --git a/src/launch-film.css b/src/launch-film.css new file mode 100644 index 0000000..e0eb1f2 --- /dev/null +++ b/src/launch-film.css @@ -0,0 +1,217 @@ +.launch-film { + scroll-margin-top: 110px; + padding-block: 72px 88px; +} +.launch-film-heading { + display: flex; + align-items: end; + justify-content: space-between; + gap: 36px; + margin-bottom: 30px; +} +.launch-film-heading .eyebrow { + display: flex; + align-items: center; + gap: 8px; + margin-bottom: 18px; + color: #af203b; +} +.launch-film-heading h2 { + margin: 0; + font-size: clamp(32px, 4.25vw, 58px); + font-weight: 600; + letter-spacing: -0.052em; + line-height: 1.06; +} +.launch-film-heading h2 span { + color: #ba203f; +} +.launch-film-heading > p { + max-width: 292px; + color: #756960; + font-size: 13px; + line-height: 1.75; + margin: 0 0 3px; +} +.launch-film-screen { + position: relative; + overflow: hidden; + border: 1px solid #d8d2cc; + border-radius: 14px; + aspect-ratio: 16 / 9; + background: #e7e1da; + box-shadow: 0 20px 60px #49372913; +} +.launch-film-screen video { + display: block; + width: 100%; + height: 100%; + object-fit: contain; +} +.launch-film-play { + position: absolute; + right: 32px; + bottom: 65px; + display: flex; + align-items: center; + gap: 12px; + min-height: 58px; + padding: 9px 22px 9px 10px; + background: #fffaf5; + color: #632237; + border: 1px solid #ffffffc2; + border-radius: 40px; + box-shadow: 0 8px 30px #3415222b; + font-size: 13px; + font-weight: 650; + transition: + transform 0.18s ease, + background 0.18s ease; +} +.launch-film-play > span { + display: grid; + place-items: center; + width: 39px; + height: 39px; + border-radius: 50%; + background: #bf2343; + color: white; +} +.launch-film-play:hover { + background: white; + transform: translateY(-2px); +} +.launch-film-status { + min-height: 1em; + font-size: 12px; + color: #ad273e; + line-height: 1.7; + margin: 10px 0; +} +.launch-film-footer { + display: flex; + align-items: center; + gap: 24px; + padding: 0 0 26px; + border-bottom: 1px solid #ded7d0; +} +.launch-film-footer > div { + flex: 1; + display: grid; + gap: 6px; +} +.launch-film-footer b { + font-size: 13px; + font-weight: 600; +} +.launch-film-footer span { + font-size: 11px; + color: #817368; + line-height: 1.65; +} +.launch-film-footer > a { + display: flex; + align-items: center; + gap: 8px; + min-height: 44px; + font-size: 12px; + white-space: nowrap; +} +.launch-film-footer > a:last-child { + color: #ae203b; +} +.launch-film-story { + padding-block: 18px; + border-bottom: 1px solid #ded7d0; +} +.launch-film-story summary { + width: fit-content; + cursor: pointer; + font-size: 12px; + min-height: 28px; + color: #746258; +} +.launch-film-story p, +.launch-film-story li { + font-size: 12px; + line-height: 1.85; + color: #786a60; +} +.launch-film-story p { + margin: 12px 0; +} +.launch-film-story ol { + display: grid; + gap: 12px; + margin: 0; + padding-left: 22px; + max-width: 800px; +} +.launch-film-story li::marker { + color: #a32d42; +} +.launch-film-story b { + color: #42322c; +} +@media (max-width: 760px) { + .launch-film { + padding-block: 48px 56px; + } + .launch-film-heading { + flex-direction: column; + align-items: flex-start; + gap: 20px; + margin-bottom: 23px; + } + .launch-film-heading > p { + max-width: 440px; + } + .launch-film-heading h2 { + font-size: clamp(32px, 7vw, 44px); + } + .launch-film-screen { + border-radius: 9px; + } + .launch-film-play { + right: 12px; + top: 12px; + bottom: auto; + min-height: 44px; + padding: 5px 13px 5px 5px; + gap: 8px; + font-size: 10px; + } + .launch-film-play > span { + width: 32px; + height: 32px; + } + .launch-film-play svg { + width: 14px; + height: 14px; + } + .launch-film-footer { + flex-wrap: wrap; + gap: 6px 20px; + } + .launch-film-footer > div { + flex: 0 0 100%; + margin-bottom: 5px; + } + .launch-film-footer > a { + font-size: 11px; + } +} +@media (prefers-reduced-motion: reduce) { + .launch-film-play { + transition: none; + } +} +@media print { + .launch-film { + display: none !important; + } +} + +html[data-motion='reduced'] .launch-film-play { + transition: none; +} diff --git a/tests/browser/launch-film.spec.ts b/tests/browser/launch-film.spec.ts new file mode 100644 index 0000000..ce58a25 --- /dev/null +++ b/tests/browser/launch-film.spec.ts @@ -0,0 +1,87 @@ +import { expect, test } from '@playwright/test'; +import fs from 'node:fs/promises'; +import { createHash } from 'node:crypto'; +import { evidencePath } from './evidence'; + +test('the supplied launch film waits for play and downloads the original web delivery', async ({ + page, +}) => { + const filmRequests: string[] = []; + page.on('request', (request) => { + if (new URL(request.url()).pathname === '/media/allowance-launch-film.mp4') + filmRequests.push(request.url()); + }); + await page.goto('/'); + const film = page.getByRole('region', { name: 'A little independence. A clear limit.' }); + const video = page.getByLabel('Allowance launch film', { exact: true }); + await page.getByRole('link', { name: 'Watch launch film', exact: true }).click(); + await expect(page).toHaveURL(/#launch-film$/); + await expect(film).toBeInViewport(); + await expect(video).toHaveAttribute('preload', 'none'); + await expect(video).toHaveJSProperty('paused', true); + expect(filmRequests).toEqual([]); + await expect(film).toContainText('Planning scenes. No funds moved.'); + await film.screenshot({ path: evidencePath('launch-film-desktop-poster.png') }); + await page.getByRole('button', { name: 'Play launch film', exact: true }).click(); + await expect + .poll(() => video.evaluate((element: HTMLVideoElement) => element.currentTime)) + .toBeGreaterThan(0.1); + const metadata = await video.evaluate((element: HTMLVideoElement) => ({ + width: element.videoWidth, + height: element.videoHeight, + duration: element.duration, + controls: element.controls, + autoplay: element.autoplay, + playsInline: element.playsInline, + muted: element.muted, + })); + expect(metadata).toMatchObject({ + width: 1920, + height: 1080, + controls: true, + autoplay: false, + playsInline: true, + muted: false, + }); + expect(metadata.duration).toBeCloseTo(30, 1); + await expect(page.getByRole('button', { name: 'Play launch film', exact: true })).toHaveCount(0); + await video.evaluate((element: HTMLVideoElement) => element.pause()); + const downloaded = page.waitForEvent('download'); + await film.getByRole('link', { name: 'Save film', exact: true }).click(); + const download = await downloaded; + expect(download.suggestedFilename()).toBe('allowance-launch-film.mp4'); + expect(await download.failure()).toBeNull(); + const bytes = await fs.readFile((await download.path())!); + expect(createHash('sha256').update(bytes).digest('hex')).toBe( + 'ed934c2d40235a40abfe2135d532081ce73d1a0173b0c74bd16217d83ac9ef64' + ); + await film.screenshot({ path: evidencePath('launch-film-desktop.png') }); +}); + +test('a failed launch film keeps the visual story and actual app walkthrough reachable on a phone', async ({ + page, +}) => { + await page.setViewportSize({ width: 320, height: 740 }); + await page.emulateMedia({ reducedMotion: 'reduce' }); + await page.route('**/media/allowance-launch-film.mp4', (route) => route.abort('failed')); + await page.goto('/#launch-film'); + const film = page.getByRole('region', { name: 'A little independence. A clear limit.' }); + await film.screenshot({ path: evidencePath('launch-film-phone-poster.png') }); + await film.getByRole('button', { name: 'Play launch film', exact: true }).click(); + await expect(film.getByRole('status')).toContainText('The launch film could not load.'); + await film.getByText('Read the visual story', { exact: true }).click(); + await expect( + film.getByText('This description follows the on-screen scenes in the supplied launch film.') + ).toBeVisible(); + await expect(film.getByRole('list')).toContainText('Blocked before signing.'); + await expect(film.getByRole('list')).toContainText('No funds moved.'); + expect(await page.evaluate(() => document.documentElement.scrollWidth <= window.innerWidth)).toBe( + true + ); + await film.screenshot({ path: evidencePath('launch-film-phone-fallback.png') }); + await film.getByRole('link', { name: 'Open the app walkthrough', exact: true }).click(); + await expect(page).toHaveURL(/\/demo#product-tour$/); + await expect( + page.getByRole('region', { name: 'A budget. A boundary. A clear record.' }) + ).toBeVisible(); +}); diff --git a/tests/facilitator.test.ts b/tests/facilitator.test.ts index bd8f621..084c1eb 100644 --- a/tests/facilitator.test.ts +++ b/tests/facilitator.test.ts @@ -43,6 +43,83 @@ it('uses the installed v2 request shape with fixed endpoints, no redirects, a ti }); }); +it('accepts mixed provider discovery but exposes only strictly validated v2 capabilities', async () => { + // Shape from PayAI's public /supported response; no provider is contacted by this test. + const feePayer = 'CjNFTjvBhbJJd2B5ePPMHRLx1ELZpa8dwQgGL727eKww'; + const mainnet = { + x402Version: 2, + scheme: 'exact', + network: PAYMENT_CHAINS.mainnet.network, + extra: { feePayer, recentBlockhash: '11111111111111111111111111111111' }, + }; + const fetcher = vi.fn().mockResolvedValue( + Response.json({ + kinds: [ + { x402Version: 1, scheme: 'exact', network: 'base-sepolia' }, + { x402Version: 1, scheme: 'exact', network: 'solana', extra: { feePayer } }, + { x402Version: 1, scheme: 'exact', network: PAYMENT_CHAINS.mainnet.network }, + mainnet, + ], + extensions: ['bazaar'], + signers: { 'solana:*': [feePayer] }, + }) + ); + const client = createBoundedFacilitatorClient({ + url: 'https://facilitator.example', + fetch: fetcher, + }); + await expect(client.getSupported()).resolves.toEqual({ + kinds: [mainnet], + extensions: ['bazaar'], + signers: { 'solana:*': [feePayer] }, + }); + expect(fetcher).toHaveBeenCalledExactlyOnceWith( + 'https://facilitator.example/supported', + expect.objectContaining({ method: 'GET', redirect: 'error' }) + ); +}); + +it.each([ + { x402Version: 2, scheme: 'exact', network: 'solana' }, + { x402Version: 2, scheme: 'exact', network: 'solana:' }, + { x402Version: 2, scheme: 'exact', network: PAYMENT_CHAINS.mainnet.network, extra: 'bad' }, + { x402Version: 1, scheme: 'exact', network: 'https://unapproved.example' }, + { x402Version: 3, scheme: 'exact', network: PAYMENT_CHAINS.mainnet.network }, +])( + 'rejects malformed discovery kinds instead of filtering away invalid v2 terms (%o)', + async (kind) => { + const fetcher = vi.fn().mockResolvedValue( + Response.json({ + kinds: [{ x402Version: 1, scheme: 'exact', network: 'solana' }, kind], + }) + ); + const client = createBoundedFacilitatorClient({ + url: 'https://facilitator.example', + fetch: fetcher, + }); + await expect(client.getSupported()).rejects.toThrow( + 'Facilitator supported failed or returned an invalid bounded response.' + ); + expect(fetcher).toHaveBeenCalledTimes(1); + } +); + +it('does not promote a legacy-only facilitator to v2 support', async () => { + const fetcher = vi.fn().mockResolvedValue( + Response.json({ + kinds: [ + { x402Version: 1, scheme: 'exact', network: 'solana' }, + { x402Version: 1, scheme: 'exact', network: PAYMENT_CHAINS.mainnet.network }, + ], + }) + ); + const client = createBoundedFacilitatorClient({ + url: 'https://facilitator.example', + fetch: fetcher, + }); + await expect(client.getSupported()).resolves.toMatchObject({ kinds: [] }); +}); + it.each([ new Response('private-provider-body', { status: 302, diff --git a/tests/payment-http.test.ts b/tests/payment-http.test.ts index ce9a1b0..78a13a6 100644 --- a/tests/payment-http.test.ts +++ b/tests/payment-http.test.ts @@ -775,6 +775,29 @@ describe('mainnet exact payment boundaries with controlled adapters', () => { expect(s.settle).not.toHaveBeenCalled(); } ); + it('rejects a mainnet capability whose fee payer differs from the reviewed sponsor before signing', async () => { + const s = await setup({ network: 'mainnet' }); + vi.spyOn(s.adapters.facilitator!, 'getSupported').mockResolvedValue({ + kinds: [ + { + x402Version: 2, + scheme: 'exact', + network: PAYMENT_CHAINS.mainnet.network, + extra: { feePayer: s.recipient }, + }, + ], + extensions: [], + signers: { 'solana:*': [s.recipient] }, + }); + expect((await s.service.readiness()).ready).toBe(false); + await expect( + s.service.runPaidTool(s.run.id, 'wrong_sponsor_001', 'wallet_snapshot', { + address: s.payer, + }) + ).rejects.toThrow(/unavailable/); + expect(s.sign).not.toHaveBeenCalled(); + expect(s.settle).not.toHaveBeenCalled(); + }); it('rejects RPC cluster changes after preflight, before the payer signature', async () => { const s = await setup({ network: 'mainnet' }); expect((await s.service.readiness()).ready).toBe(true);