/** * Navidrome MCP Server - Web remote principal resolver * Copyright (C) 2025 * SPDX-License-Identifier: AGPL-3.0-or-later */ import type { IncomingMessage } from 'node:http'; import type { WebuiAdminAccess, WebuiAuthMode } from '../../constants/defaults.js'; import type { AuthService } from './auth-service.js'; import type { AdminSession, GuestSession } from './auth-store.js'; import { type Permission } from './roles.js'; /** * `open` is mode `none`. `anonymous` holds no valid session in a mode with a login. `outside-level` * presents a valid admin session from a source the admin access level does not admit. A guest * session answers to the jukebox code, never to the admin access level. `isLocal` gates the * local-only permissions, which no guest role holds. */ export type Principal = { kind: 'open'; isLocal: boolean; } | { kind: 'anonymous'; } | { kind: 'outside-level'; level: WebuiAdminAccess; session: AdminSession; } | { kind: 'admin'; session: AdminSession; isLocal: boolean; } | { kind: 'guest'; session: GuestSession; }; type Authorization = { ok: true; } | { ok: false; status: number; body: { error: string; code?: string; }; }; export declare function sourcePassesLevel(req: IncomingMessage, level: WebuiAdminAccess): boolean; /** * The player's computer is the root of trust, so it logs in with no password when the owner turned the * ask off or no password is saved. Every admin access level admits a local request. The login also needs * the launch key, which `handleLogin` checks, since only the login body carries it. */ export declare function isPasswordlessHere(req: IncomingMessage, auth: AuthService): boolean; export declare function resolvePrincipal(req: IncomingMessage, auth: AuthService): Principal; /** * A route the mode lacks answers 404 to every principal, and so does a local-only route that a * non-local open principal or admin session asks for, so the route stays hidden. */ export declare function authorize(mode: WebuiAuthMode, principal: Principal, permission: Permission): Authorization; /** Only the owner holds an admin session, so this refusal may name the settings page. */ export declare function outsideLevelMessage(level: WebuiAdminAccess): string; /** The role the session route reports, so the page can pick the login view, the guest page or the player. */ export declare function principalRole(principal: Principal): 'open' | 'admin' | 'guest' | 'anonymous'; export {}; //# sourceMappingURL=principal.d.ts.map