(
status: number,
code: number,
message: string,
opts?: { readonly cors?: boolean; readonly challenge?: string },
)
| 84 | * local — the four hand-rolled copies are deleted in favor of this. |
| 85 | */ |
| 86 | export const jsonRpcErrorBody = ( |
| 87 | status: number, |
| 88 | code: number, |
| 89 | message: string, |
| 90 | opts?: { readonly cors?: boolean; readonly challenge?: string }, |
| 91 | ): Response => { |
| 92 | const cors = opts?.cors ?? true; |
| 93 | const challenge = opts?.challenge; |
| 94 | return new Response(JSON.stringify({ jsonrpc: "2.0", error: { code, message }, id: null }), { |
| 95 | status, |
| 96 | headers: { |
| 97 | "content-type": "application/json", |
| 98 | ...(cors ? { "access-control-allow-origin": "*" } : {}), |
| 99 | ...(challenge |
| 100 | ? { |
| 101 | "www-authenticate": challenge, |
| 102 | "access-control-expose-headers": "WWW-Authenticate", |
| 103 | } |
| 104 | : {}), |
| 105 | }, |
| 106 | }); |
| 107 | }; |
| 108 | |
| 109 | /** The envelope's own CORS-on JSON-RPC error `Response`, optionally carrying a challenge. */ |
| 110 | const jsonRpcResponse = ( |
no outgoing calls
no test coverage detected