verifyMessage

import { verifyMessage } from "jsr:@ende/http/unstable-message-signatures";

function ยท experimental

async function verifyMessage(message: Request | Response, keyLookup: (keyId: string, algorithm?: SignatureAlgorithm) => Promise<CryptoKey | null> | CryptoKey | null, options?: VerifyOptions): Promise<VerifyResult[]>

Verify one or more signatures on an HTTP message per RFC 9421.

message: Request | Response

The HTTP request or response to verify.

keyLookup: (keyId: string, algorithm?: SignatureAlgorithm) => Promise<CryptoKey | null> | CryptoKey | null

Resolves a key identifier to a CryptoKey, or null if the key is not found. When the signature has no keyid parameter, the empty string "" is passed.

options?: VerifyOptions

Optional verification constraints.

Returns

Array of verified signature results.

Example: Usage

import { verifyMessage } from "@ende/http/unstable-message-signatures";

const results = await verifyMessage(
  signedRequest,
  async (keyId) => lookupPublicKey(keyId),
  { requiredComponents: ["@method", "@authority"] },
);

Source