@adcp/sdk API Reference - v7.9.0
    Preparing search index...

    Function parseWWWAuthenticate

    • Parse a WWW-Authenticate header into its auth-scheme and parameters.

      Handles the single-challenge case used by MCP servers in practice: one scheme (typically Bearer) followed by comma-separated key=value or key="value" auth-params. Returns null for an empty or malformed header.

      Quoted-string values may contain escaped quotes (\") and backslashes (\\), per RFC 9110 §5.6.4; these are unescaped on the way out.

      Parameters

      • header: string | null | undefined

      Returns WWWAuthenticateChallenge | null

      const c = parseWWWAuthenticate(
      'Bearer realm="api", error="invalid_token", resource_metadata="https://api.example.com/.well-known/oauth-protected-resource"'
      );
      // c.scheme === 'bearer'
      // c.error === 'invalid_token'
      // c.resource_metadata === 'https://api.example.com/.well-known/oauth-protected-resource'