(response: Response)
| 467 | // its claims against the AS metadata and rejects mismatches we don't care |
| 468 | // about. Strip the field before delegation. |
| 469 | const stripIdToken = async (response: Response): Promise<Response> => { |
| 470 | const body = await response |
| 471 | .clone() |
| 472 | .json() |
| 473 | .then( |
| 474 | (value: unknown) => value, |
| 475 | () => null, |
| 476 | ); |
| 477 | if (!body || typeof body !== "object" || !("id_token" in (body as Record<string, unknown>))) { |
| 478 | return response; |
| 479 | } |
| 480 | const { id_token: _ignored, ...rest } = body as Record<string, unknown>; |
| 481 | return new Response(JSON.stringify(rest), { |
| 482 | status: response.status, |
| 483 | statusText: response.statusText, |
| 484 | headers: response.headers, |
| 485 | }); |
| 486 | }; |
| 487 | |
| 488 | const processTokenEndpointResponse = async ( |
| 489 | as: oauth.AuthorizationServer, |
no test coverage detected