daemonServerAuthHeaders (shared/daemon-server-auth.ts)

imcodes · shared/daemon-server-auth.ts · typescript · MIT
auth, tag:embed-classified

Utility to build auth headers for daemon‑to‑server REST calls.

// Source: https://github.com/im4codes/imcodes | License: MIT | Copyright 2026 IM.codes
// Provided via justclaw.it.com; keep this notice with the code.
import { AUTHORIZATION_HEADER, SERVER_ID_HEADER } from './http-header-names.js';

/**
 * The credential a daemon presents to the server's REST API: `Authorization: Bearer <server token>` plus `X-Server-Id`.
 * The server checks the bearer against that server's stored token hash (revoked tokens and controlled nodes are refused),
 * so the pair is the only way for a daemon to be authenticated. One builder for every daemon -> server HTTP call: a call
 * that sends a serverId alone authenticates nothing.
 */
export function daemonServerAuthHeaders(credentials: { serverId: string; token: string }): Record<string, string> {
  return {
    [AUTHO

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key