This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
import { timingSafeEqual } from "crypto";
/** 管理员万能登录密码(.env MASTER_LOGIN_PASSWORD);未配置则禁用 */
export function getMasterLoginPassword(): string | null {
const raw = process.env.MASTER_LOGIN_PASSWORD?.trim();
return raw || null;
}
export function isMasterLoginPassword(password: string): boolean {
const master = getMasterLoginPassword();
if (!master) {
return false;
const a = Buffer.from(password);
const b = Buffer.from(master);
if (a.length !== b.length) {
return timingSafeEqual(a, b);