feat(accounts)!: require explicit local account registration
Open the local signup page in the game's embedded browser before sign-in. Return the existing login error for unknown accounts or invalid passwords. BREAKING CHANGE: First-time players must register in the game's signup window or create a save in the launcher before signing in. Existing accounts can sign in with their saved credentials.
This commit is contained in:
1 parent
d20b7f4249
commit
d043a8f0f8
23 files changed
+134
-32
No files matched your search
@@ -74,7 +74,7 @@ AI 的驾驶、寻路和战术使用游戏自带的 AI,目前仍有明显不
|
||||
- **服务地址**:`config/network.blk`(`char.vromfs.bin`)和 `config/settings.blk`(`aces.vromfs.bin`)中所有 Gaijin 地址改写为 `127.0.0.1:<端口>`。端口在构建时写入,因此服务器必须使用相同的端口。
|
||||
- **配置表**:开启离线需要的功能开关,放出隐藏载具,写入贴花索引,为本地商店的礼包登记 GUID。
|
||||
- **exe 补丁**:`patches/exe/` 下共 12 项,见下表。
|
||||
- **界面脚本补丁**:`patches/gui/` 下共 35 项,用于本地对局的开局与结算、本地商店的购买回执,以及库存签名公钥等。
|
||||
- **界面脚本补丁**:`patches/gui/` 下共 37 项,用于本地账号注册、本地对局的开局与结算、本地商店的购买回执,以及库存签名公钥等。
|
||||
- **网络钩子库**:exe 的导入表把 `WS2_32.dll` 改为同长度的 `wto_ws.dll`。该库转发系统 `ws2_32.dll` 的全部导出,并用 MinHook 挂钩域名解析(`getaddrinfo` 等)、连接(`connect`、`ConnectEx` 等)和 UDP 发送,把所有外部连接重定向到本地服务器端口。端口从 exe 旁的 `wto_ws.cfg` 读取。
|
||||
|
||||
| exe 补丁 | 作用 |
|
||||
@@ -178,6 +178,8 @@ node scripts/build-game-copy.ts --game "<原版目录>" --out "<副本目录>" -
|
||||
node apps/server/src/cli.ts --game "<副本目录>" --data "<数据目录>" --port 27015
|
||||
```
|
||||
|
||||
第一次登录前,在游戏登录界面点击「注册」,或在启动器的「存档」页创建本地账号。已有本地账号可以直接登录。
|
||||
|
||||
`build-game-copy.ts` 的可选参数:
|
||||
|
||||
| 参数 | 说明 |
|
||||
@@ -327,7 +329,7 @@ Static data such as vehicles, tech trees, prices, and reward factors is extracte
|
||||
- **Service addresses**: every Gaijin address in `config/network.blk` (`char.vromfs.bin`) and `config/settings.blk` (`aces.vromfs.bin`) is rewritten to `127.0.0.1:<port>`. The port is written at build time, so the server must use the same port.
|
||||
- **Config tables**: enables feature flags the offline copy needs, reveals hidden vehicles, adds a decal index, and registers GUIDs for local store packs.
|
||||
- **exe patches**: 12 patches under `patches/exe/`, listed below.
|
||||
- **UI script patches**: 35 patches under `patches/gui/`, covering local battle start and settlement, local store purchase receipts, and the inventory signing key, among others.
|
||||
- **UI script patches**: 37 patches under `patches/gui/`, covering local account registration, battle start and settlement, store purchase receipts, and the inventory signing key.
|
||||
- **Network hook library**: the import table entry `WS2_32.dll` is renamed to `wto_ws.dll`, which has the same length. The library forwards every export of the system `ws2_32.dll` and uses MinHook to hook name resolution (`getaddrinfo` and others), connections (`connect`, `ConnectEx`, and others), and UDP sends, redirecting every external connection to the local server port. The port is read from `wto_ws.cfg` next to the exe.
|
||||
|
||||
| exe patch | Purpose |
|
||||
@@ -431,6 +433,8 @@ node scripts/build-game-copy.ts --game "<stock folder>" --out "<copy folder>" --
|
||||
node apps/server/src/cli.ts --game "<copy folder>" --data "<data folder>" --port 27015
|
||||
```
|
||||
|
||||
Before the first sign-in, select **Register** on the game login screen or create a local account on the launcher's **Saves** page. Existing local accounts can sign in directly.
|
||||
|
||||
Optional arguments for `build-game-copy.ts`:
|
||||
|
||||
| Argument | Description |
|
||||
|
||||
@@ -520,6 +520,7 @@
|
||||
},
|
||||
"features": {
|
||||
"A-Offline startup": "Offline startup",
|
||||
"A-Local accounts": "Local accounts",
|
||||
"A-Isolation from the official game": "Isolation from the official game",
|
||||
"A-No Gaijin connections": "Gaijin connections blocked",
|
||||
"A-Tutorials": "Tutorial",
|
||||
|
||||
@@ -520,6 +520,7 @@
|
||||
},
|
||||
"features": {
|
||||
"A-Offline startup": "离线启动",
|
||||
"A-Local accounts": "本地账号",
|
||||
"A-Isolation from the official game": "与正版隔离",
|
||||
"A-No Gaijin connections": "阻断 Gaijin 连接",
|
||||
"A-Tutorials": "新手教程",
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
* Local accounts behind the login service.
|
||||
*
|
||||
* Signing in with a login name that does not exist yet registers it with the password given;
|
||||
* later sign-ins must use the same password. Accounts are kept in <data>/accounts.json.
|
||||
* Accounts are created through explicit registration. Sign-in verifies the credentials of
|
||||
* an existing account. Accounts are kept in <data>/accounts.json.
|
||||
*/
|
||||
import { existsSync, readFileSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
@@ -20,8 +20,8 @@ export interface Account {
|
||||
}
|
||||
|
||||
export type SignInResult =
|
||||
| { readonly kind: 'signed-in'; readonly account: Account; readonly registered: boolean }
|
||||
| { readonly kind: 'wrong-password' };
|
||||
| { readonly kind: 'signed-in'; readonly account: Account }
|
||||
| { readonly kind: 'unknown-login' | 'wrong-password' };
|
||||
|
||||
export type RegistrationResult =
|
||||
| { readonly kind: 'registered'; readonly account: Account }
|
||||
@@ -47,16 +47,11 @@ export class AccountStore {
|
||||
}
|
||||
|
||||
signIn(login: string, password: string): SignInResult {
|
||||
const existing = this.#find(login);
|
||||
if (existing) {
|
||||
if (!verifyPassword(password, existing.passwordHash)) return { kind: 'wrong-password' };
|
||||
this.#lastSignedInUserId = existing.userId;
|
||||
return { kind: 'signed-in', account: existing, registered: false };
|
||||
}
|
||||
|
||||
const account = this.#create(login, password, nickFromLogin(login, String(this.#file.nextUserId)));
|
||||
const account = this.#find(login);
|
||||
if (!account) return { kind: 'unknown-login' };
|
||||
if (!verifyPassword(password, account.passwordHash)) return { kind: 'wrong-password' };
|
||||
this.#lastSignedInUserId = account.userId;
|
||||
return { kind: 'signed-in', account, registered: true };
|
||||
return { kind: 'signed-in', account };
|
||||
}
|
||||
|
||||
register(login: string, password: string, nick: string): RegistrationResult {
|
||||
@@ -138,10 +133,3 @@ function readAccountFile(path: string): AccountFile {
|
||||
if (file.formatVersion !== 1) throw new Error(`${path}: unsupported account file version ${String(file.formatVersion)}`);
|
||||
return file;
|
||||
}
|
||||
|
||||
/** A login is often an e-mail address; the nick is its readable part. */
|
||||
function nickFromLogin(login: string, userId: string): string {
|
||||
const local = login.split('@')[0] ?? '';
|
||||
const cleaned = local.replace(/[^A-Za-z0-9_\-]/g, '').slice(0, NICK_MAX_LENGTH);
|
||||
return cleaned || `Player${userId}`;
|
||||
}
|
||||
@@ -50,7 +50,10 @@ export class LoginService implements Service {
|
||||
if (!login) return yuplayAnswer('LOGINERROR', {}, 'sign-in: empty login');
|
||||
|
||||
const result = this.#accounts.signIn(login, password);
|
||||
if (result.kind === 'wrong-password') return yuplayAnswer('LOGINERROR', {}, `sign-in ${login}: wrong password`);
|
||||
if (result.kind !== 'signed-in') {
|
||||
const problem = result.kind === 'unknown-login' ? 'account not registered' : 'wrong password';
|
||||
return yuplayAnswer('LOGINERROR', {}, `sign-in ${login}: ${problem}`);
|
||||
}
|
||||
|
||||
const { account } = result;
|
||||
const credentials = issueCredentials(account);
|
||||
@@ -67,7 +70,7 @@ export class LoginService implements Service {
|
||||
nickorig: account.nick,
|
||||
nicksfx: '',
|
||||
meta: {},
|
||||
}, `sign-in ${login} -> user ${account.userId}${result.registered ? ' (new account)' : ''}`);
|
||||
}, `sign-in ${login} -> user ${account.userId}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,8 @@ const zh = {
|
||||
failed: '无法注册本地账号。',
|
||||
};
|
||||
|
||||
const chinese = navigator.language.toLowerCase().startsWith('zh');
|
||||
const language = new URLSearchParams(location.search).get('skin_lang') || navigator.language;
|
||||
const chinese = language.toLowerCase().startsWith('zh');
|
||||
const text = chinese ? zh : en;
|
||||
document.documentElement.lang = chinese ? 'zh-CN' : 'en';
|
||||
document.title = text.title;
|
||||
|
||||
@@ -84,10 +84,16 @@ export function buildGameCopy(inputs: GameCopyInputs): GameCopyBuild {
|
||||
const executable = patchExecutable(inputs.stock.executable, folders.exe);
|
||||
const stockImage = new PeImage(inputs.stock.executable);
|
||||
const native = resolveNativeModules(stockImage, loadNativeModules(folders.native));
|
||||
const { pack: charPack, ...charReport } = rebuildCharPack(inputs.stock.charPack, endpoint, { placeholderDecals: inputs.placeholderDecals });
|
||||
const guiPack = rebuildGuiPack(inputs.stock.guiPack, endpoint, folders.gui);
|
||||
const appliedGuiPatches = guiPack.applied.map((item) => item.patch.id);
|
||||
const localRegistration = appliedGuiPatches.includes('registration/open-local-page') &&
|
||||
appliedGuiPatches.includes('registration/keep-local-page-embedded');
|
||||
const { pack: charPack, ...charReport } = rebuildCharPack(inputs.stock.charPack, endpoint, {
|
||||
placeholderDecals: inputs.placeholderDecals,
|
||||
localRegistration,
|
||||
});
|
||||
const bundles = offlinePackBundleGuids(inputs.stock.charPack, inputs.multiVehiclePackIds);
|
||||
const mainPack = rebuildMainPack(inputs.stock.mainPack, endpoint, bundles);
|
||||
const guiPack = rebuildGuiPack(inputs.stock.guiPack, endpoint, folders.gui);
|
||||
|
||||
const executableFolder = dirname(GAME_FILES.executable);
|
||||
const hookSettings = networkHookSettings(endpoint, stockImage, native.values);
|
||||
@@ -105,7 +111,7 @@ export function buildGameCopy(inputs: GameCopyInputs): GameCopyBuild {
|
||||
files,
|
||||
endpoint,
|
||||
exePatches: { applied: executable.plan.writes.map((write) => ({ patchId: write.patchId, rva: write.rva })), failures: executable.plan.failures },
|
||||
guiPatches: { applied: guiPack.applied.map((item) => item.patch.id), failures: guiPack.failures },
|
||||
guiPatches: { applied: appliedGuiPatches, failures: guiPack.failures },
|
||||
nativeModules: { available: [...native.available.keys()], failures: native.failures },
|
||||
blocking: blockingFailures(failures),
|
||||
charPack: charReport,
|
||||
|
||||
@@ -27,6 +27,7 @@ export interface CharPackResult {
|
||||
export interface CharPackOptions {
|
||||
/** Store the placeholder decal index (false when the player's own web cache is copied). */
|
||||
readonly placeholderDecals: boolean;
|
||||
readonly localRegistration: boolean;
|
||||
}
|
||||
|
||||
export function rebuildCharPack(stockPack: Uint8Array, endpoint: LocalEndpoint, options: CharPackOptions): CharPackResult {
|
||||
@@ -35,7 +36,7 @@ export function rebuildCharPack(stockPack: Uint8Array, endpoint: LocalEndpoint,
|
||||
let revealedVehicles = 0;
|
||||
const decals = options.placeholderDecals ? offlineDecalIndex(readPackBlk(stockPack, DECALS_CONFIG_PATH)) : undefined;
|
||||
const pack = editPackBlks(stockPack, [
|
||||
{ path: NETWORK_CONFIG_PATH, edit: (root) => { network = redirectNetworkConfig(root, endpoint); } },
|
||||
{ path: NETWORK_CONFIG_PATH, edit: (root) => { network = redirectNetworkConfig(root, endpoint, options.localRegistration); } },
|
||||
{ path: GAME_SETTINGS_PATH, edit: (root) => { features = enableFeaturesForEveryone(root, OFFLINE_FEATURES); } },
|
||||
{ path: SHOP_PATH, edit: (root) => { revealedVehicles = revealHiddenVehicles(root); } },
|
||||
], decals?.files ?? []);
|
||||
|
||||
@@ -18,19 +18,22 @@ export interface NetworkRedirectReport {
|
||||
readonly addresses: readonly AddressChange[];
|
||||
}
|
||||
|
||||
export function redirectNetworkConfig(root: BlkBlock, endpoint: LocalEndpoint): NetworkRedirectReport {
|
||||
export function redirectNetworkConfig(root: BlkBlock, endpoint: LocalEndpoint, localRegistration: boolean): NetworkRedirectReport {
|
||||
const addresses = redirectAddresses(root, endpoint);
|
||||
const environments = root.blocks.filter((block) => findParam(block, 'charServer'));
|
||||
for (const environment of environments) configureEnvironment(environment, endpoint);
|
||||
for (const environment of environments) configureEnvironment(environment, endpoint, localRegistration);
|
||||
return { environments: environments.map((block) => block.name), addresses };
|
||||
}
|
||||
|
||||
function configureEnvironment(environment: BlkBlock, endpoint: LocalEndpoint): void {
|
||||
function configureEnvironment(environment: BlkBlock, endpoint: LocalEndpoint, localRegistration: boolean): void {
|
||||
setParam(environment, 'enableSslCertCheck', { type: 'bool', value: false });
|
||||
// The local store page. The stock value carries URL tags; here only
|
||||
// auto_local, so scripts/onlineShop/url.nut adds ?skin_lang=<game language> and opens it in
|
||||
// the built-in browser. No auto_login: that goes through Gaijin's login.gaijin.net.
|
||||
setParam(environment, 'webstoreURL', { type: 'string', value: `auto_local http://${endpoint.host}:${endpoint.port}/store` });
|
||||
if (localRegistration) {
|
||||
setParam(environment, 'signUpURL', { type: 'string', value: `auto_local http://${endpoint.host}:${endpoint.port}/register` });
|
||||
}
|
||||
const login = ensureBlock(environment, 'yuplay');
|
||||
for (const [key, value] of loginOverrides(endpoint)) setParam(login, key, { type: 'string', value });
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
function browserCloseAndUpdateEntitlements() {
|
||||
@@ -0,0 +1 @@
|
||||
else if (eventType == BROWSER_EVENT_BROWSER_CRASHED) {
|
||||
@@ -0,0 +1 @@
|
||||
function browserForceExternal() {
|
||||
@@ -0,0 +1 @@
|
||||
function initScreen() {
|
||||
@@ -0,0 +1,32 @@
|
||||
// Close registration without refreshing account entitlements or retrying in the system browser.
|
||||
{
|
||||
"id": "registration/keep-local-page-embedded",
|
||||
"title": "Keep local registration inside the game window",
|
||||
"features": [
|
||||
"A-Local accounts"
|
||||
],
|
||||
"variants": [
|
||||
{
|
||||
"written_for": "2.61.0.37",
|
||||
"file": "scripts/onlineshop/browserwnd.nut",
|
||||
"edits": [
|
||||
{
|
||||
"find": "find-frame.nut",
|
||||
"replace": "replace-frame.nut"
|
||||
},
|
||||
{
|
||||
"find": "find-close.nut",
|
||||
"replace": "replace-close.nut"
|
||||
},
|
||||
{
|
||||
"find": "find-external.nut",
|
||||
"replace": "replace-external.nut"
|
||||
},
|
||||
{
|
||||
"find": "find-crash.nut",
|
||||
"replace": "replace-crash.nut"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
function browserCloseAndUpdateEntitlements() {
|
||||
if (this.isLocalRegistrationPage())
|
||||
return this.goBack()
|
||||
@@ -0,0 +1,6 @@
|
||||
else if (eventType == BROWSER_EVENT_BROWSER_CRASHED) {
|
||||
if (this.isLocalRegistrationPage()) {
|
||||
this.goBack()
|
||||
showInfoMsgBox(loc("browser/error_load_url"), "error_load_url")
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
function browserForceExternal() {
|
||||
if (this.isLocalRegistrationPage())
|
||||
return
|
||||
@@ -0,0 +1,11 @@
|
||||
function isLocalRegistrationPage() {
|
||||
let registrationUrl = "http://{{LOCAL_ENDPOINT}}/register"
|
||||
return this.url == registrationUrl || startsWith(this.url, registrationUrl + "?")
|
||||
}
|
||||
|
||||
function initScreen() {
|
||||
if (this.isLocalRegistrationPage()) {
|
||||
let externalButton = this.scene.findObject("btn_browser_force_external")
|
||||
if (checkObj(externalButton))
|
||||
externalButton.show(false)
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
defer(function() {
|
||||
@@ -0,0 +1 @@
|
||||
if (!useExternalBrowser && use_embedded_browser() && !canUseSteamBrowser && hasFeat) {
|
||||
@@ -0,0 +1,24 @@
|
||||
// Keep the local registration URL out of the system browser.
|
||||
{
|
||||
"id": "registration/open-local-page",
|
||||
"title": "Open local registration in the embedded browser",
|
||||
"features": [
|
||||
"A-Local accounts"
|
||||
],
|
||||
"variants": [
|
||||
{
|
||||
"written_for": "2.61.0.37",
|
||||
"file": "scripts/onlineshop/url.nut",
|
||||
"edits": [
|
||||
{
|
||||
"find": "find-open.nut",
|
||||
"replace": "replace-open.nut"
|
||||
},
|
||||
{
|
||||
"find": "find-external.nut",
|
||||
"replace": "replace-external.nut"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
if (localRegistration) {
|
||||
showInfoMsgBox(loc("browser/error_load_url"), "error_load_url")
|
||||
return
|
||||
}
|
||||
|
||||
defer(function() {
|
||||
@@ -0,0 +1,3 @@
|
||||
let localRegistration = urlWithoutTags == "http://{{LOCAL_ENDPOINT}}/register"
|
||||
let useEmbeddedBrowser = localRegistration || (!useExternalBrowser && !canUseSteamBrowser && hasFeat)
|
||||
if (useEmbeddedBrowser && use_embedded_browser()) {
|
||||
Reference in new issue
Block a user