MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / bearerChallenge

Function bearerChallenge

apps/cloud/src/mcp/responses.ts:15–28  ·  view source on GitHub ↗
(auth: UnauthorizedAuth, protectedResourceMetadataUrl: string)

Source from the content-addressed store, hash-verified

13 `"${value.replaceAll("\\", "\\\\").replaceAll('"', '\\"')}"`;
14
15export const bearerChallenge = (auth: UnauthorizedAuth, protectedResourceMetadataUrl: string) => {
16 const params =
17 auth.reason === "missing_bearer"
18 ? [`resource_metadata=${quoteAuthParam(protectedResourceMetadataUrl)}`]
19 : [
20 'error="invalid_token"',
21 `error_description=${quoteAuthParam(
22 auth.description ?? "The access token is invalid or expired",
23 )}`,
24 `resource_metadata=${quoteAuthParam(protectedResourceMetadataUrl)}`,
25 ];
26
27 return `Bearer ${params.join(", ")}`;
28};
29
30/**
31 * The cloud edge's JSON-RPC error `Response` (CORS-on — it crosses the browser

Callers 2

bearerChallengeForFunction · 0.90
unauthorizedFunction · 0.85

Calls 1

quoteAuthParamFunction · 0.85

Tested by

no test coverage detected