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

Function loadHttpAuthHook

src/daemon/server/http-server.ts:489–511  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

487}
488
489async function loadHttpAuthHook(): Promise<HttpAuthHook | null> {
490 const hookPath = process.env.AGENT_DEVICE_HTTP_AUTH_HOOK;
491 if (!hookPath) return null;
492 const exportName = process.env.AGENT_DEVICE_HTTP_AUTH_EXPORT || 'default';
493 const resolvedPath = path.isAbsolute(hookPath) ? hookPath : path.resolve(hookPath);
494 let imported: Record<string, unknown>;
495 try {
496 imported = (await import(pathToFileURL(resolvedPath).href)) as Record<string, unknown>;
497 } catch (error) {
498 throw new AppError('COMMAND_FAILED', 'Failed to load AGENT_DEVICE_HTTP_AUTH_HOOK module', {
499 hookPath: resolvedPath,
500 error: error instanceof Error ? error.message : String(error),
501 });
502 }
503 const maybeHook = imported[exportName];
504 if (typeof maybeHook !== 'function') {
505 throw new AppError('INVALID_ARGS', `Auth hook export ${exportName} is not a function`, {
506 hookPath: resolvedPath,
507 exportName,
508 });
509 }
510 return maybeHook as HttpAuthHook;
511}
512
513export async function createDaemonHttpServer(options: {
514 handleRequest: DaemonInvokeFn;

Callers 1

createDaemonHttpServerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected