1
mirror of https://github.com/thepeacockproject/Peacock synced 2025-02-16 16:34:28 +01:00

refactor: consistent naming for scpc

This commit is contained in:
Reece Dunham 2024-08-06 10:59:33 -04:00
parent 46e66c32c9
commit d511e1e91b
5 changed files with 25 additions and 28 deletions

View File

@ -21,7 +21,7 @@ import { log, LogLevel } from "./loggingInterop"
import { userAuths } from "./officialServerAuth" import { userAuths } from "./officialServerAuth"
import { import {
EPIC_NAMESPACE_2021, EPIC_NAMESPACE_2021,
FRANKENSTEIN_SNIPER_ENTITLEMENTS, SCPC_ENTITLEMENTS,
getEpicEntitlements, getEpicEntitlements,
H2_STEAM_ENTITLEMENTS, H2_STEAM_ENTITLEMENTS,
STEAM_NAMESPACE_2016, STEAM_NAMESPACE_2016,
@ -132,7 +132,7 @@ export class EpicH1Strategy extends EntitlementStrategy {
*/ */
export class SteamScpcStrategy extends EntitlementStrategy { export class SteamScpcStrategy extends EntitlementStrategy {
override get() { override get() {
return FRANKENSTEIN_SNIPER_ENTITLEMENTS return SCPC_ENTITLEMENTS
} }
} }

View File

@ -160,10 +160,8 @@ menuDataRouter.get("/Hub", (req: RequestWithJwt, res) => {
if (req.gameVersion === "h3" || req.gameVersion === "h2") { if (req.gameVersion === "h3" || req.gameVersion === "h2") {
template = null template = null
} else { } else {
template = // scpc hub will need to be contributed by a plugin
req.gameVersion === "scpc" template = getVersionedConfig("HubTemplate", req.gameVersion, false)
? getConfig("FrankensteinHubTemplate", false)
: getConfig("LegacyHubTemplate", false)
} }
res.json({ res.json({
@ -381,10 +379,12 @@ menuDataRouter.get(
let template: unknown | null = null let template: unknown | null = null
if (req.gameVersion === "h1") { if (req.gameVersion === "h1" || req.gameVersion === "scpc") {
template = getConfig("LegacyPlanningTemplate", false) template = getVersionedConfig(
} else if (req.gameVersion === "scpc") { "PlanningTemplate",
template = getConfig("FrankensteinPlanningTemplate", false) req.gameVersion,
false,
)
} }
res.json({ res.json({
@ -647,10 +647,7 @@ const missionEndRequest = async (
} }
res.json({ res.json({
template: template: null,
req.gameVersion === "scpc"
? getConfig("FrankensteinScoreOverviewTemplate", false)
: null,
data: missionEndOutput, data: missionEndOutput,
}) })
} }

View File

@ -79,13 +79,13 @@ export const error406: unique symbol = Symbol("http406")
export async function handleOAuthToken( export async function handleOAuthToken(
req: RequestWithJwt<never, OAuthTokenBody>, req: RequestWithJwt<never, OAuthTokenBody>,
): Promise<typeof error400 | typeof error406 | OAuthTokenResponse> { ): Promise<typeof error400 | typeof error406 | OAuthTokenResponse> {
const isFrankenstein = req.body.gs === "scpc-prod" const isScpc = req.body.gs === "scpc-prod"
const signOptions = { const signOptions = {
notBefore: -60000, notBefore: -60000,
expiresIn: 6000, expiresIn: 6000,
issuer: "auth.hitman.io", issuer: "auth.hitman.io",
audience: isFrankenstein ? "scpc-prod" : "pc_prod_8", audience: isScpc ? "scpc-prod" : "pc_prod_8",
noTimestamp: true, noTimestamp: true,
} }
@ -136,7 +136,7 @@ export async function handleOAuthToken(
// @ts-expect-error Non-optional, we're reassigning. // @ts-expect-error Non-optional, we're reassigning.
delete req.jwt.aud // audience delete req.jwt.aud // audience
if (!isFrankenstein) { if (!isScpc) {
if (userAuths.has(req.jwt.unique_name)) { if (userAuths.has(req.jwt.unique_name)) {
userAuths userAuths
.get(req.jwt.unique_name)! .get(req.jwt.unique_name)!
@ -169,7 +169,7 @@ export async function handleOAuthToken(
let gameVersion: GameVersion = "h1" let gameVersion: GameVersion = "h1"
if (isFrankenstein) { if (isScpc) {
gameVersion = "scpc" gameVersion = "scpc"
} else if (isHitman3) { } else if (isHitman3) {
gameVersion = "h3" gameVersion = "h3"
@ -221,7 +221,7 @@ export async function handleOAuthToken(
/* /*
Store user auth for all games except scpc Store user auth for all games except scpc
*/ */
if (!isFrankenstein) { if (!isScpc) {
const authContainer = new OfficialServerAuth( const authContainer = new OfficialServerAuth(
gameVersion, gameVersion,
req.body.access_token, req.body.access_token,
@ -261,7 +261,7 @@ export async function handleOAuthToken(
} }
async function getEntitlements(): Promise<string[]> { async function getEntitlements(): Promise<string[]> {
if (isFrankenstein) { if (isScpc) {
return new SteamScpcStrategy().get() return new SteamScpcStrategy().get()
} }

View File

@ -136,7 +136,7 @@ export const STEAM_NAMESPACE_2018 = "863550"
export const EPIC_NAMESPACE_2021 = "ed55aa5edc5941de92fd7f64de415793" export const EPIC_NAMESPACE_2021 = "ed55aa5edc5941de92fd7f64de415793"
export const STEAM_NAMESPACE_2021 = "1659040" export const STEAM_NAMESPACE_2021 = "1659040"
export const FRANKENSTEIN_SNIPER_ENTITLEMENTS = [STEAM_NAMESPACE_2016, "783781"] export const SCPC_ENTITLEMENTS = [STEAM_NAMESPACE_2016, "783781"]
export function getPlatformEntitlements( export function getPlatformEntitlements(
req: RequestWithJwt, req: RequestWithJwt,

View File

@ -664,13 +664,13 @@ export async function getMissionEndData(
} }
// Resolve all opportunities for the location // Resolve all opportunities for the location
const opportunities = contractData.Metadata.Opportunities const opportunities: string[] | null | undefined =
const opportunityCount = opportunities ? opportunities.length : 0 contractData.Metadata.Opportunities
const opportunityCompleted = opportunities const opportunityCount = opportunities?.length ?? 0
? opportunities.filter( const opportunityCompleted =
(ms) => ms in userData.Extensions.opportunityprogression, opportunities?.filter(
).length (ms: string) => ms in userData.Extensions.opportunityprogression,
: 0 ).length ?? 0
// Resolve all challenges for the location // Resolve all challenges for the location
const locationChallenges = const locationChallenges =