(res: ServerResponse, route: string, rpcId: unknown)
| 393 | } |
| 394 | |
| 395 | function sendUnauthorized(res: ServerResponse, route: string, rpcId: unknown): void { |
| 396 | res.statusCode = 401; |
| 397 | res.setHeader('content-type', 'application/json'); |
| 398 | if (route === '/rpc') { |
| 399 | res.end( |
| 400 | JSON.stringify({ |
| 401 | jsonrpc: '2.0', |
| 402 | id: rpcId, |
| 403 | error: { |
| 404 | code: -32001, |
| 405 | message: 'Invalid proxy token', |
| 406 | data: normalizeError(new AppError('UNAUTHORIZED', 'Invalid proxy token')), |
| 407 | }, |
| 408 | }), |
| 409 | ); |
| 410 | return; |
| 411 | } |
| 412 | res.end( |
| 413 | JSON.stringify({ |
| 414 | ok: false, |
| 415 | error: 'Invalid proxy token', |
| 416 | code: 'UNAUTHORIZED', |
| 417 | }), |
| 418 | ); |
| 419 | } |
| 420 | |
| 421 | function sendProxyError(res: ServerResponse, error: unknown): void { |
| 422 | if (res.headersSent) { |
no test coverage detected