Skip to content

contrib: x402 top-level JSON shape vectors and agent mint/revoke hardening (#668, #762, #763, #765) - #784

Merged
davedumto merged 1 commit into
Vellar-Wallet:devfrom
Abdulwasiu45:contrib/issues-668-762-763-765
Oct 23, 2026
Merged

davedumto merged 1 commit into
Vellar-Wallet:devfrom
Abdulwasiu45:contrib/issues-668-762-763-765

Conversation

@Abdulwasiu45

Copy link
Copy Markdown
Contributor

Summary

All changes are scoped to contrib/issues-668-762-763-765/ per CONTRIBUTING.md. This PR provides reference implementations, adversarial conformance vectors, unit tests, documentation, and a maintainer integration patch for issues #668, #762, #763, and #765.

1. #668 - x402 untrusted vectors for valid JSON of wrong top-level type

  • Catalogs adversarial vectors in x402-top-level-vectors.ts covering valid JSON of wrong top-level types (bare JSON array, bare string, bare number, bare boolean, null).
  • Implements assertPaymentRequiredShape in x402-top-level-guard.ts as a distinct structural fence that runs immediately after JSON parsing and before field-level validation.
  • Prevents property-access crashes (TypeError) and blocks malformed payloads before any field can reach model-facing output (renderUntrusted / sanitizeMetadata).
  • 20 unit tests in x402-top-level-guard.test.ts.

2. #762 - Mint rejecting grant with duplicate policy contract IDs

  • Validates in assertNoDuplicatePolicies that within a single grant, no policy contract ID appears twice.
  • Explicitly rejects duplicates with InvalidAgentInputError("grant for [token] has duplicate policy: [policy]") consistently with the existing empty-array rejection.
  • Regression test confirms the same policy contract ID across different token grants within the same mint call remains allowed.

3. #763 - Mint rejecting expiresAt in the past

  • Validates expiresAt (Date or unix seconds) client-side in validateExpiresAt.
  • Rejects timestamps at or before current time with InvalidAgentInputError("expiresAt must be in the future") before any passkey prompt or RPC call.

4. #765 - Revoke idempotency against an already-revoked key

  • Ensures revoke called twice in succession on the same publicKey against a mocked AgentKeyRuntime either succeeds as an idempotent no-op or reports a clear, named AgentKeyNotFoundError, never throwing an unhandled or misleading error.
  • Documents idempotency guarantee and cross-references caller retry logic (revokeWithRetry).

Core Integration

A unified patch contrib/issues-668-762-763-765/core-integration.patch is included and verified to apply cleanly against dev for maintainers to lift into src/.

Closes #668
Closes #762
Closes #763
Closes #765

…ening (Vellar-Wallet#668, Vellar-Wallet#762, Vellar-Wallet#763, Vellar-Wallet#765)

- Vellar-Wallet#668: Add untrusted vectors covering valid JSON of wrong top-level type (bare array, string, number, boolean, null) and structural guard before model-facing output
- Vellar-Wallet#762: Reject duplicate policy contract IDs in agent grants while allowing cross-grant reuse
- Vellar-Wallet#763: Reject past expiresAt (Date and unix seconds) client-side before passkey prompt or RPC call
- Vellar-Wallet#765: Ensure agents-facade revoke is idempotent against already-revoked keys without unhandled errors

Closes Vellar-Wallet#668
Closes Vellar-Wallet#762
Closes Vellar-Wallet#763
Closes Vellar-Wallet#765
@vercel

vercel Bot commented Oct 22, 2026

Copy link
Copy Markdown

@k-deejah is attempting to deploy a commit to the david's projects Team on Vercel.

A member of the Team first needs to authorize it.

@davedumto
davedumto merged commit d0488c5 into Vellar-Wallet:dev Oct 23, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment