(
auth: McpAuthProvider["Service"],
request: Request,
outcome: Exclude<AuthOutcome, { readonly _tag: "Authenticated" }>,
)
| 286 | * session, 404 means the session id is dead and the client must reconnect. |
| 287 | */ |
| 288 | const renderAuthError = ( |
| 289 | auth: McpAuthProvider["Service"], |
| 290 | request: Request, |
| 291 | outcome: Exclude<AuthOutcome, { readonly _tag: "Authenticated" }>, |
| 292 | ): Response => |
| 293 | Match.value(outcome).pipe( |
| 294 | Match.tag("Unauthorized", (u) => |
| 295 | jsonRpcResponse( |
| 296 | 401, |
| 297 | -32001, |
| 298 | "Unauthorized", |
| 299 | u.challenge ?? `Bearer resource_metadata="${auth.resourceMetadataUrl(request)}"`, |
| 300 | ), |
| 301 | ), |
| 302 | Match.tag("Forbidden", (f) => jsonRpcResponse(403, f.code ?? -32001, f.message)), |
| 303 | Match.tag("Unavailable", (u) => |
| 304 | jsonRpcErrorBody(503, -32001, u.message, { |
| 305 | retryAfterSeconds: UNAVAILABLE_RETRY_AFTER_SECONDS, |
| 306 | }), |
| 307 | ), |
| 308 | Match.exhaustive, |
| 309 | ); |
| 310 | |
| 311 | /** |
| 312 | * Render a non-`Response` {@link McpDispatchResult} discriminant. A dead |
no test coverage detected