6 Commits

Author SHA1 Message Date
4fb99d27f7 docs(near-x402): record real NEAR Testnet end-to-end verification + fix stale test counts
Revived cred402 for the NEAR Hackathon per owner override (2026-10-28 retirement
does not apply to this product in this session). Audited the existing NEAR x402
implementation (lib/x402/near_*.ts, api/near_x402_routes.ts) and found it already
complete and correctly wired into api/server.ts — no code bugs found.

Verified live against a running server and the real NEAR Testnet RPC, no protocol
mocking: unpaid request returns a real 402 + PAYMENT-REQUIRED; a tampered proof is
rejected at decode time; a well-formed proof over a never-broadcast tx hash returns
502 indeterminate (intentional fail-safe, documented); a real signed NEAR Transfer
(tx C1LNxQFEaR2AQj79U9WzToiB1eY86jwzmxoHKvr9W7jk) settles for real with finality
confirmations and a verified receipt; replay returns the cached result; a real
underpaid Transfer (G33RhcX5zSMarmkY358ANHcCVpeGGasrNmjgiiruYQdn) is cleanly
rejected on-chain-amount, not just signature-claimed amount. Two disposable NEAR
Testnet accounts were created+funded via the public non-captcha helper API to run
this without any owner credential.

Corrected stale/inaccurate test-count claims in HACKATHON.md, SUBMISSION-CHECKLIST.md,
and README.md: real full suite is 447/450 (3 pre-existing failures in the unrelated
test/mcp_sdk.test.ts stdio handshake, not the x402/NEAR path), not 450/450 or 346.
docs/near_x402.md gets a new Verification section with the real evidence and a
Known Gaps entry explaining the 502-vs-402 design choice for ambiguous RPC timeouts.
2026-11-03 01:44:12 +03:00
c80dda9e91 feat(near): add NEAR Hackathon x402 credit-score integration
Adds a third chain-priced rail (alongside the existing Algorand and QIE
integrations, both untouched) for the NEAR Hackathon (Nov 1-14, 2026,
Agent Economy track): GET /v1/x402/near/credit-score/:agentId, settled
in native NEAR on NEAR Testnet.

No @x402/near scheme package exists, so lib/x402/near_gateway.ts is a
from-scratch x402 v2 "exact" scheme built on @x402/core's chain-agnostic
header codecs and types. It needs no third-party facilitator: Cred402
verifies settlement itself directly against the configured NEAR RPC
(lib/x402/near_finality.ts), the same role the Algorand Indexer check and
QIE RPC check play for their chains.

- lib/x402/near_networks.ts, near_rpc.ts, near_finality.ts,
  near_payment_attempt_store.ts, near_gateway.ts: resource server,
  self-verifying settlement, durable exact-once replay protection.
- api/near_x402_routes.ts, api/near_receipt_anchor.ts: HTTP routes
  (status, usage, payment attempts, paid credit score) and Casper-rooted
  receipt anchoring, wired into api/server.ts and api/state.ts.
- examples/near-paid-score/typescript.ts (+ README): a real buyer that
  signs and submits a NEAR Testnet transaction via near-api-js.
- test/near_x402.test.ts: 14 new tests (TDD), full suite 450/450 green,
  typecheck clean.
- docs/near_x402.md, HACKATHON.md, SUBMISSION-CHECKLIST.md: protocol
  writeup (incl. Chain Signatures / NEAR Intents extension points),
  submission guide, and an explicit owner-only checklist (team info,
  payout account, demo video/post, form submission).
2026-10-21 03:11:37 +03:00
1ff795f53f fix: put the challenge tag where the facilitator actually reads it
The GoPlausible facilitator writes Global x402 Challenge attribution at
settlement time from accepts[].extra.tag, and never backfills it. It does
not persist the x402 resource.tags array into its Bazaar record: of 200
live Bazaar resources, 176 carry the tag via extra.tag and zero have a
tags field at all.

Cred402 advertised the tag only in resource.tags, so a real Mainnet
payment would have settled, catalogued into the Bazaar, and then been
filed under src=direct -- never reaching the challenge leaderboard.

- move the tag into the accepted option's extra, from a shared
  challenge_tag module so server and client cannot drift
- declare the x402-merchant extension so the leaderboard row carries a
  name and logo instead of a bare hostname
- reject a challenge missing extra.tag in inspectAlgorandChallenge, which
  fails both the preflight and the release gate
- assert it in the gateway test and in both buyer examples
- add x402:algorand:challenge-check, a read-only gate over the status
  probe, the Bazaar catalogue and the challenge leaderboard

Attribution is not retroactive, so this has to ship before the first real
payment.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-16 15:35:55 +03:00
388d482cfc chore: add Apache-2.0 LICENSE (unblocks open-core) + extract http_utils from server god-file 2026-08-25 03:09:55 +03:00
afed64e4bd feat(p2): x402 Gateway middleware — any API becomes x402-payable + receipt-generating
Roadmap p2 shipped. The adoption wedge: drop one middleware in front of any route
and it issues 402 challenges, verifies EIP-712/ed25519 payments (replay-protected),
emits a receipt commitment to a sink, and proceeds — feeding the Cred402 credit moat.

- lib/x402/gateway.ts: framework-agnostic X402Gateway + Express and Web (Fetch)
  adapters, pluggable nonce store (replay guard), per-route analytics, receipt sink.
- Works for ANY p1 service category (inference/data/compute/…), not just RWA.
- Fix: eip712 uint256 now padded to 32 bytes (odd-length amounts no longer break signing).
- test/x402_gateway.test.ts (5 cases, real buyer→gateway round-trips), examples/paid-api-x402.ts,
  npm run demo:gateway, docs/roadmap (p2 ✅). 181 tests green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-17 17:20:46 +03:00
2d43618725 feat: real integrations (Casper Testnet, x402/EIP-712, MCP, RealFi, cross-chain), wallet sign-in, branding
Replace the design-note docs (p1–p7) with the implemented "make it real" phase
docs (p8–p10) and wire production-grade, env-gated real integrations:

- p8 Casper Testnet: byte-exact deploys + WASM install via casper-js-sdk; live
  node reads (node.testnet.casper.network); CRED402_CHAIN=sim|testnet transport.
- p9 x402 + data + MCP: real EIP-712 typed-data digests (@casper-ecosystem/
  casper-eip-712); casper-x402 facilitator client (x402 V2); live Open-Meteo GHI;
  official @modelcontextprotocol/sdk server; casper-sidecar SSE event feed.
- p10 RealFi + cross-chain: real Stripe test-mode webhooks (HMAC-verified) and
  Plaid sandbox → privacy-preserving on-chain envelopes; Base Sepolia EVM deploy
  (Foundry); reachable via /api/realfi/* and /api/x402/facilitator routes.
- Sign-in with Casper Wallet: real extension provider + challenge/ed25519/session
  flow (/v1/auth/wallet/*), console connect + sign-in button.
- Branding: Cred402 logo mark, favicon, OG image; Vercel config for the console.

All env-gated with sim/free-API fallbacks; full suite green, all toolchains
(TS/Rust/Go/Solidity) build.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-17 00:37:36 +03:00