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

Function handleRegister

packages/core/test-servers/src/worker.ts:115–139  ·  view source on GitHub ↗
(request: Request)

Source from the content-addressed store, hash-verified

113};
114
115const handleRegister = async (request: Request) => {
116 const body = (await request.json()) as {
117 readonly redirect_uris?: readonly string[];
118 readonly token_endpoint_auth_method?: string;
119 };
120 const clientId = `client_${crypto.randomUUID()}`;
121 const authMethod = body.token_endpoint_auth_method ?? "none";
122 const clientSecret = authMethod === "none" ? null : `secret_${crypto.randomUUID()}`;
123 clients.set(clientId, {
124 clientSecret,
125 redirectUris: new Set(body.redirect_uris ?? []),
126 });
127 return json(
128 {
129 client_id: clientId,
130 ...(clientSecret ? { client_secret: clientSecret } : {}),
131 token_endpoint_auth_method: authMethod,
132 redirect_uris: body.redirect_uris ?? [],
133 grant_types: ["authorization_code"],
134 response_types: ["code"],
135 scope: "read write",
136 },
137 { status: 201, headers: { "cache-control": "no-store" } },
138 );
139};
140
141const handleAuthorize = (request: Request) => {
142 const url = new URL(request.url);

Callers 1

handleRequestFunction · 0.85

Calls 3

setMethod · 0.80
jsonFunction · 0.70
jsonMethod · 0.65

Tested by

no test coverage detected