feat(accounts): implement local login

Route login and character requests by their original host names on one
loopback port. Add local accounts, saves, and credential redaction.
This commit is contained in:
N0VAN0M4LY committed 2026-11-24 05:01:26 +08:00
1 parent c3914ec0d6
commit 7f482ae530
55 files changed
+1559 -58

No files matched your search

@@ -0,0 +1,19 @@
/**
* Write a file so that a crash leaves either the old or the new content, never a mix:
* write a temporary file next to it, flush it to disk, then rename it over the target.
*/
import { closeSync, fsyncSync, mkdirSync, openSync, renameSync, writeSync } from 'node:fs';
import { dirname } from 'node:path';
export function writeFileAtomic(path: string, content: Uint8Array | string): void {
mkdirSync(dirname(path), { recursive: true });
const temporary = `${path}.${process.pid}.tmp`;
const fd = openSync(temporary, 'w');
try {
writeSync(fd, typeof content === 'string' ? Buffer.from(content, 'utf8') : content);
fsyncSync(fd);
} finally {
closeSync(fd);
}
renameSync(temporary, path);
}