MCPcopy Index your code
hub / github.com/callstack/agent-device / sendUnauthorized

Function sendUnauthorized

src/remote/daemon-proxy.ts:395–419  ·  view source on GitHub ↗
(res: ServerResponse, route: string, rpcId: unknown)

Source from the content-addressed store, hash-verified

393}
394
395function 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
421function sendProxyError(res: ServerResponse, error: unknown): void {
422 if (res.headersSent) {

Callers 1

handleProxyRequestFunction · 0.85

Calls 1

normalizeErrorFunction · 0.90

Tested by

no test coverage detected