- Add services/anythingllm-devtools HTTP API (repos + AnythingLLM + RAG) - Rename gitea-issues to git-issues across smart_ide agents and docs - Add projects/builazoo, builazoo README, cron fragment, ssh-config.example - Add ensure-ia-dev-project-link.sh; wrapper delegates smart_ide id - Bump ia_dev submodule (git-issues rename, project symlinks) - Align 4nkaiignore templates; update API index and project docs
22 lines
627 B
TypeScript
22 lines
627 B
TypeScript
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
|
|
export const readExpectedToken = (): string => {
|
|
return process.env.ANYTHINGLLM_DEVTOOLS_TOKEN?.trim() ?? "";
|
|
};
|
|
|
|
export const requireBearer = (
|
|
req: IncomingMessage,
|
|
res: ServerResponse,
|
|
expected: string,
|
|
): boolean => {
|
|
const h = req.headers.authorization ?? "";
|
|
const match = /^Bearer\s+(.+)$/i.exec(h);
|
|
const got = match?.[1]?.trim() ?? "";
|
|
if (got !== expected) {
|
|
res.writeHead(401, { "Content-Type": "application/json; charset=utf-8" });
|
|
res.end(JSON.stringify({ error: "Unauthorized" }));
|
|
return false;
|
|
}
|
|
return true;
|
|
};
|