Files
WoW-Hybrid-gateway/ops/octo_browser_routes.py
2026-11-23 03:28:32 +02:00

80 lines
2.7 KiB
Python

#!/usr/bin/env python3
"""Derive two selected 70334 Glue scripts with explicit Octo browser actions.
This is an isolated content transformation. It does not change client code,
install a CASC package, or claim that native login or browser routing works.
Usage: python ops/octo_browser_routes.py CHARACTERSELECT GLUEPARENT OUTPUT_DIR
"""
import argparse
import hashlib
from pathlib import Path
CHARACTER_SELECT_SHA256 = "92be7d3f84c35a9a37c54d80d4313e698f4196769bfd117687de03aaf4474daf"
GLUE_PARENT_SHA256 = "e0c1b6128fee3a6645cebc2cabb4852233e3afe0351117e9abfcc51976126385"
OCTO_HOME = "https://octowow.st/"
OCTO_BUG_TRACKER = "https://octowow.st/bug-tracker"
def _selected(source: bytes, expected_hash: str, label: str) -> bytes:
if hashlib.sha256(source).hexdigest() != expected_hash:
raise ValueError(f"Selected {label} differs from pinned 0874ff37 content")
return source
def _replace_one(source: bytes, old: bytes, new: bytes, label: str) -> bytes:
if source.count(old) != 1:
raise ValueError(f"Selected {label} anchor differs")
return source.replace(old, new, 1)
def transform_character_select(source: bytes) -> bytes:
"""Route the two explicit character-selection browser buttons to Octo."""
result = _selected(source, CHARACTER_SELECT_SHA256, "CharacterSelect")
result = _replace_one(
result,
b"\tLaunchURL(TECH_SUPPORT_URL);",
b'\tLaunchURL("https://octowow.st/bug-tracker");',
"Tech Support URL",
)
result = _replace_one(
result,
b"\tLaunchURL(AUTH_NO_TIME_URL);",
b'\tLaunchURL("https://octowow.st/");',
"Manage Account URL",
)
return result
def transform_glue_parent(source: bytes) -> bytes:
"""Route the legacy new-account fallback, retaining store/trial branches."""
result = _selected(source, GLUE_PARENT_SHA256, "GlueParent")
return _replace_one(
result,
b"\t\t\tLoadURLIndex(2);",
b'\t\t\tLaunchURL("https://octowow.st/");',
"Upgrade Account fallback URL",
)
def main() -> int:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("character_select", type=Path)
parser.add_argument("glue_parent", type=Path)
parser.add_argument("output", type=Path)
args = parser.parse_args()
files = {
"characterselect.lua": transform_character_select(args.character_select.read_bytes()),
"glueparent.lua": transform_glue_parent(args.glue_parent.read_bytes()),
}
args.output.mkdir(parents=True, exist_ok=True)
for name, data in files.items():
(args.output / name).write_bytes(data)
print(name, hashlib.sha256(data).hexdigest())
return 0
if __name__ == "__main__":
raise SystemExit(main())