Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial support for HITMAN 3 Windows/Xbox PC version #326

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified PeacockPatcher.exe
Binary file not shown.
9 changes: 9 additions & 0 deletions components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,13 @@ app.get(
"scpc-prod"
}

if (req.params.audience === "pcgdk-prod") {
// PC Xbox version is a special audience
config.Versions[0].Name = "pcgdk-prod"
config.Versions[0].SERVER_VER.GlobalAuthentication.RequestedAudience =
"pcgdk-prod_8"
}

config.Versions[0].ISSUER_ID = req.query.issuer || "*"

config.Versions[0].SERVER_VER.Metrics.MetricsServerHost = `${proto}://${serverhost}`
Expand Down Expand Up @@ -298,6 +305,7 @@ app.use(
break
case "fghi4567xQOCheZIin0pazB47qGUvZw4":
case STEAM_NAMESPACE_2021:
case "RETAIL":
req.serverVersion = "8-13"
break
default:
Expand Down Expand Up @@ -560,6 +568,7 @@ function startServer(options: { hmr: boolean; pluginDevHost: boolean }): void {
"contracts",
join("userdata", "epicids"),
join("userdata", "steamids"),
join("userdata", "xboxids"),
join("userdata", "users"),
join("userdata", "h1", "steamids"),
join("userdata", "h1", "epicids"),
Expand Down
44 changes: 34 additions & 10 deletions components/oauthToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ export async function handleOauthToken(
noTimestamp: true,
}

let external_platform: "steam" | "epic",
let external_platform: "steam" | "epic" | "live",
external_userid: string,
external_users_folder: "steamids" | "epicids",
external_users_folder: "steamids" | "epicids" | "xboxids",
external_appid: string

if (req.body.grant_type === "external_steam") {
Expand Down Expand Up @@ -102,6 +102,11 @@ export async function handleOauthToken(
external_platform = "epic"
external_userid = req.body.epic_userid
external_users_folder = "epicids"
} else if (req.body.grant_type === "external_xbox") {
external_appid = "RETAIL"
external_platform = "live"
external_userid = req.body.xbox_userid
external_users_folder = "xboxids"
} else if (req.body.grant_type === "refresh_token") {
// send back the token from the request (re-signed so the timestamps update)
extractToken(req) // init req.jwt
Expand Down Expand Up @@ -148,7 +153,8 @@ export async function handleOauthToken(

const isHitman3 =
external_appid === "fghi4567xQOCheZIin0pazB47qGUvZw4" ||
external_appid === STEAM_NAMESPACE_2021
external_appid === STEAM_NAMESPACE_2021 ||
external_appid === "RETAIL"

const gameVersion: GameVersion = isFrankenstein
? "scpc"
Expand Down Expand Up @@ -199,13 +205,20 @@ export async function handleOauthToken(
}

/*
Store user auth for all games except scpc
Store user auth for all games except scpc & h3 xbox
*/
if (!isFrankenstein) {
const authContainer = new OfficialServerAuth(
gameVersion,
req.body.access_token,
)
if (!isFrankenstein && external_platform !== "live") {
let gameAuthToken: string

if (external_platform === "epic") {
gameAuthToken = req.body.access_token
} else if (external_platform === "steam") {
gameAuthToken = req.body.steam_clienttoken
} else {
gameAuthToken = undefined
}

const authContainer = new OfficialServerAuth(gameVersion, gameAuthToken)

log(LogLevel.DEBUG, `Setting up container with ID ${req.body.pId}.`)

Expand All @@ -226,12 +239,20 @@ export async function handleOauthToken(
true,
) as UserProfile
userData.Id = req.body.pId
userData.LinkedAccounts[external_platform] = external_userid

// IOI uses "xboxone" here
if (external_platform === "live") {
userData.LinkedAccounts["xboxone"] = external_userid
RDIL marked this conversation as resolved.
Show resolved Hide resolved
} else {
userData.LinkedAccounts[external_platform] = external_userid
}

if (external_platform === "steam") {
userData.SteamId = req.body.steam_userid
} else if (external_platform === "epic") {
userData.EpicId = req.body.epic_userid
} else if (external_platform === "live") {
userData.XboxLiveId = req.body.xbox_userid
}

if (
Expand Down Expand Up @@ -276,6 +297,9 @@ export async function handleOauthToken(
gameVersion,
STEAM_NAMESPACE_2021,
).get(req.body.pId)
} else if (external_platform === "live") {
// TODO: fetch proper entitlements
return ["9P2JC6R9S37C"]
} else {
log(LogLevel.ERROR, "Unsupported platform.")
return []
Expand Down
5 changes: 3 additions & 2 deletions components/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export type GameAudience =
| "xboxone-prod"
| "scpc-prod"
| "playtest01-prod_8"
| "pcgdk-prod_8"

/**
* Data from the JSON Web Token (JWT) authentication scheme.
Expand All @@ -78,9 +79,9 @@ export interface JwtData {
*/
userid: string
/**
* Either "steam" or "epic" on PC.
* Either "steam", "epic" or "live" on PC.
*/
platform: "steam" | "epic"
platform: "steam" | "epic" | "live"
/**
* Client/account locale.
*/
Expand Down
4 changes: 3 additions & 1 deletion components/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ export function extractToken(
res?: Response,
next?: NextFunction,
): void {
const header = req.header("Authorization")
// Xbox version uses X-GPS-Authorization
const header =
req.header("X-GPS-Authorization") ?? req.header("Authorization")
const auth = header ? header.split(" ") : []

if (auth.length === 2 && auth[0].toLowerCase() === "bearer") {
Expand Down
Loading