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,15 @@
/** Char action names mapped to their handlers (full list of names: research-data/char_actions_37.json). */
import type { PlayerProfiles } from '../../profile/player-profiles.ts';
import type { CharActionHandler } from '../char-action.ts';
import { initialMeta, legacyUserData } from './online-init-actions.ts';
export interface ActionDependencies {
readonly profiles: PlayerProfiles;
}
export function actionTable(deps: ActionDependencies): ReadonlyMap<string, CharActionHandler> {
return new Map<string, CharActionHandler>([
['cln_get_initial_meta', initialMeta()],
['cln_legacy_get_userdata', legacyUserData(deps.profiles)],
]);
}
@@ -0,0 +1,31 @@
/**
* Char actions of the online initialisation after sign-in, up to the profile
*.
*/
import { emptyBlock } from '@wto/blk';
import type { PlayerProfiles } from '../../profile/player-profiles.ts';
import type { CharAnswer } from '../char-answers.ts';
import type { CharActionContext, CharActionHandler } from '../char-action.ts';
/**
* cln_get_initial_meta: server-side metadata the client reads in GameSaveData's initial-meta
* handling (aces.exe 0xeb5f60). binaryDataMetainfo lists server-side binary files the client
* must fetch and compare by hash; the local service has none, so the list is empty and no
* downloads follow.
*/
export function initialMeta(): CharActionHandler {
return () => {
const meta = emptyBlock();
meta.blocks.push(emptyBlock('binaryDataMetainfo'), emptyBlock('generalBlkMeta'));
return { kind: 'data', blk: meta };
};
}
/** cln_legacy_get_userdata: the whole profile (ClientEconomicState::loadOnline, aces.exe 0x2a23b0). */
export function legacyUserData(profiles: PlayerProfiles): CharActionHandler {
return (context) => withUser(context, (userId) => ({ kind: 'data', blk: profiles.profileOf(userId) }));
}
function withUser(context: CharActionContext, run: (userId: string) => CharAnswer): CharAnswer {
return context.userId ? run(context.userId) : { kind: 'error', code: 'AUTH_REQ_ERROR' };
}