Skip to main content

Overview

The tool.verify() method verifies RFC 9421 signed HTTP requests with additional security checks. It validates that the request signature is valid and that the signing agent’s domain is trusted.
tool.verify() is a wrapper around primitives.verify() that adds FQDN (Fully Qualified Domain Name) trust validation. Use this method when building tools that need to verify requests from trusted agents only.

Signature

Parameters

HttpMethod
required
The HTTP method of the request being verified.Valid values: 'GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS', 'HEAD', or any custom string.
string
required
The full URI of the request being verified (e.g., https://tool.example.com/api/action).
HeaderBag
default:"{}"
The HTTP headers from the incoming request. Must include Signature, Signature-Input, and Signature-Agent headers.

Return Value

Returns a Promise that resolves to a VerifyResult object:
string
The unique identifier of the agent that signed the request.
string
The key ID (thumbprint) of the public key used to sign the request.
PublicJwk
The public JWK that was used to verify the signature.
string
The well-known URL where the public key was discovered (if applicable).

Trust Validation

The tool.verify() method validates that the signing agent’s domain matches one of these trusted patterns:
  1. Vestauth API: *.api.vestauth.com
  2. Server Hostname: Matches the configured server hostname (if using Vestauth server)
  3. Custom Pattern: Matches the TOOL_FQDN_REGEX environment variable (if set)
If the agent’s domain doesn’t match any trusted pattern, the method throws an untrustedSignatureAgent error.

Example

Example with Next.js API Route

Example Output

Custom Trust Pattern

You can configure custom trusted domains using the TOOL_FQDN_REGEX environment variable:

Error Handling

Common Errors

  • Missing HTTP Method: httpMethod parameter is required
  • Missing URI: uri parameter is required
  • Missing Signature-Agent: The Signature-Agent header is not present in the request
  • Invalid Signature-Agent: The Signature-Agent header is malformed
  • Untrusted Signature-Agent: The agent’s domain is not in the trusted list
  • Invalid Signature: The signature verification failed (wrong key or tampered request)
  • Expired Signature: The signature has expired (based on the expires parameter)

Verification Flow

  1. Validate Headers: Ensures Signature-Agent header is present and valid
  2. Extract FQDN: Parses the agent’s domain from the Signature-Agent header
  3. Trust Check: Validates the domain against trusted patterns
  4. Signature Verification: Calls primitives.verify() to verify the cryptographic signature
  5. Return Result: Returns the verified agent information