(request: Request)
| 113 | }; |
| 114 | |
| 115 | const 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 | |
| 141 | const handleAuthorize = (request: Request) => { |
| 142 | const url = new URL(request.url); |
no test coverage detected