feat(admission): add group VPN exceptions
This commit is contained in:
@@ -115,6 +115,24 @@ export function resolveEffectiveGroup<T>(explicitGroup: T | null, defaultGroup:
|
||||
return explicitGroup ?? defaultGroup;
|
||||
}
|
||||
|
||||
export function isGameNetworkAllowed(
|
||||
classification: "unknown" | "clear" | "vpn" | "proxy" | "hosting" | "tor",
|
||||
anonymizedNetworksAllowed: boolean,
|
||||
) {
|
||||
return anonymizedNetworksAllowed || !["vpn", "proxy", "tor"].includes(classification);
|
||||
}
|
||||
|
||||
export function gameAdmissionDenialReason(
|
||||
group: { accessEnabled: boolean; anonymizedNetworksAllowed: boolean } | null,
|
||||
classification: "unknown" | "clear" | "vpn" | "proxy" | "hosting" | "tor",
|
||||
) {
|
||||
if (!group?.accessEnabled) return "group_access_disabled" as const;
|
||||
if (!isGameNetworkAllowed(classification, group.anonymizedNetworksAllowed)) {
|
||||
return "anonymized_network_disallowed" as const;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
export function verifyHashedToken(providedToken: string, expectedHash: string) {
|
||||
const provided = Buffer.from(hashToken(providedToken), "utf8");
|
||||
const expected = Buffer.from(expectedHash, "utf8");
|
||||
|
||||
Reference in New Issue
Block a user