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

+4 -23
View File
@@ -1,13 +1,7 @@
/**
* Rebuild char.vromfs.bin with config/network.blk pointed at the local service. Every other
* file of the pack is kept byte for byte. The rewritten network.blk is stored self-contained
* (it no longer depends on the pack's shared name map), which the game accepts in every
* loading mode.
*/
import { decodeBlk, encodeBlk, parseSharedNameMap } from '@wto/blk';
import { getFile, NAME_MAP_PATH, putFile, readArchive, writeArchive, type Archive } from '@wto/vromfs';
/** Rebuild char.vromfs.bin with config/network.blk pointed at the local service. */
import type { LocalEndpoint } from './network/local-endpoint.ts';
import { redirectNetworkConfig, type NetworkRedirectReport } from './network/redirect-network-config.ts';
import { editPackBlk } from './pack-edit.ts';
export const NETWORK_CONFIG_PATH = 'config/network.blk';
@@ -17,19 +11,6 @@ export interface CharPackResult {
}
export function rebuildCharPack(stockPack: Uint8Array, endpoint: LocalEndpoint): CharPackResult {
const archive = readArchive(stockPack);
const dictionary = findDictionary(archive);
const shared = parseSharedNameMap(getFile(archive, NAME_MAP_PATH), dictionary);
const networkConfig = decodeBlk(getFile(archive, NETWORK_CONFIG_PATH), { names: shared.names, dictionary });
const network = redirectNetworkConfig(networkConfig, endpoint);
putFile(archive, NETWORK_CONFIG_PATH, encodeBlk(networkConfig));
return { pack: writeArchive(archive), network };
}
/** The pack's zstd dictionary, if it has one (char.vromfs.bin in 2.61.0.37 has none). */
function findDictionary(archive: Archive): Uint8Array | undefined {
const dictionaries = [...archive.files.keys()].filter((path) => path.endsWith('.dict'));
if (dictionaries.length > 1) throw new Error(`the data pack has several zstd dictionaries: ${dictionaries.join(', ')}`);
return dictionaries.length ? archive.files.get(dictionaries[0]!) : undefined;
const { pack, report } = editPackBlk(stockPack, NETWORK_CONFIG_PATH, (root) => redirectNetworkConfig(root, endpoint));
return { pack, network: report };
}