Security: POST /v1/payments/:id/confirm only verified Arc payments; any other network confirmed with an arbitrary txHash and granted entitlements. The API now keeps a per-network verifier registry (ctx.verifiers: arc via the existing Arc client, base via the generic EVM client + BASE_RPC_URL + Base USDC, solana via @settlekit/solana) and confirm/observe reject any network without one. - a transaction hash settles at most one payment (409 on reuse, also on record); EVM hashes are normalized to lowercase - checkout sessions accept network solana, require a base58 payTo and get a fresh Solana Pay paymentReference the tx must include - observe validates hash/address formats per network (base58 vs 0x) - compliance screening maps solana to Circle's SOL chain - env: SOLANA_CLUSTER, SOLANA_RPC_URL, SOLANA_USDC_MINT, BASE_RPC_URL, BASE_MIN_CONFIRMATIONS Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
40 lines
1.4 KiB
TypeScript
40 lines
1.4 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { loadConfig } from "../src/config/env.js";
|
|
import { buildIntegrations } from "../src/config/integrations.js";
|
|
|
|
describe("buildIntegrations verifier registry", () => {
|
|
it("registers no verifiers when no chain is configured (everything fails closed)", () => {
|
|
expect(buildIntegrations(loadConfig({})).verifiers).toEqual({});
|
|
});
|
|
|
|
it("registers one verifier per configured network", () => {
|
|
const integrations = buildIntegrations(
|
|
loadConfig({
|
|
ARC_CHAIN_ID: "5042002",
|
|
BASE_RPC_URL: "https://mainnet.base.org",
|
|
SOLANA_CLUSTER: "devnet",
|
|
}),
|
|
);
|
|
expect(Object.keys(integrations.verifiers).sort()).toEqual(["arc", "base", "solana"]);
|
|
expect(integrations.verifiers.arc).toBe(integrations.arcVerifier);
|
|
});
|
|
|
|
it("the base verifier rejects proofs for other networks without touching the chain", async () => {
|
|
const { verifiers } = buildIntegrations(loadConfig({ BASE_RPC_URL: "http://127.0.0.1:9" }));
|
|
const result = await verifiers.base!(
|
|
{ txHash: `0x${"ab".repeat(32)}`, from: "", amount: "1", network: "arc", nonce: "" },
|
|
{
|
|
scheme: "x402",
|
|
amount: "1",
|
|
asset: "USDC",
|
|
network: "arc",
|
|
payTo: "0x1111111111111111111111111111111111111111",
|
|
productId: "",
|
|
resource: "r",
|
|
nonce: "",
|
|
},
|
|
);
|
|
expect(result).toEqual({ ok: false, reason: "Unsupported network: arc" });
|
|
});
|
|
});
|