import { join } from 'node:path';
import { getOwnerHomeDir } from '@@/data-path';

const getVncDir = (email: string): string => join(getOwnerHomeDir(email), '.vnc');

export async function getVncPassword(email: string): Promise<string | null> {
  const file = Bun.file(join(getVncDir(email), 'password'));
  if (!(await file.exists())) return null;
  return (await file.text()).trim();
}
