Files
WT-Offline/packages/local-service/src/matching/matching-requests.ts
T
N0VAN0M4LY 6233a64835 fix(matching): return clusters in the stock response envelope
Return recognizable regions from fetch_clusters_list and place matching
results in data.data. Document the handshake, heartbeat, and EULA
requirements. The offline client remains logged in after the cluster reply.
2026-11-24 08:44:44 +08:00

42 lines
2.0 KiB
TypeScript

/**
* What the local matching server answers, by request name.
*
* mlogin.login: the client's sign-in to the matching server (built at aces.exe 2.61.0.37
* 0x44e8160: auth_jwt_enc, login (sealed session key, session-crypto/session-key.ts),
* user_id, name, protocol, caps, version, platform). Its result handler (0x44f1850) treats
* error 0 as success, marks the client signed in and passes "data" to the online layer.
* Nothing local checks the credentials (single-player machine); the session key is needed
* because the client encrypts everything after this request.
*/
import { fetchClustersList } from './cluster-list.ts';
import type { MatchingRequest } from './matching-message.ts';
import { jwtDecryptsWith, unwrapSessionKey } from './session-crypto/session-key.ts';
/** What a request handler may do to its connection besides answering. */
export interface MatchingSessionControl {
/** Encrypt this connection from the answer to the current request on. */
useSessionKey(key: Buffer): void;
/** Add a line to the traffic log entry of the current request. */
note(text: string): void;
}
export type MatchingRequestHandler = (request: MatchingRequest, session: MatchingSessionControl) => Record<string, unknown>;
export const MATCHING_REQUESTS: ReadonlyMap<string, MatchingRequestHandler> = new Map([
['mlogin.login', signIn],
['wtmm_static.fetch_clusters_list', fetchClustersList],
]);
function signIn(request: MatchingRequest, session: MatchingSessionControl): Record<string, unknown> {
const { login, auth_jwt_enc: authJwtEnc } = request.params;
if (typeof login === 'string') {
const { sessionKey, fields } = unwrapSessionKey(login);
const verified = typeof authJwtEnc === 'string' && jwtDecryptsWith(sessionKey, authJwtEnc);
session.note(`session key unwrapped (sealed fields: ${fields.join(', ')}); auth_jwt_enc ${verified ? 'decrypts with it' : 'does NOT decrypt with it'}`);
session.useSessionKey(sessionKey);
} else {
session.note('no sealed login field: the connection stays unencrypted');
}
return {};
}