mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-10-17 19:15:59 +08:00
logging ua
This commit is contained in:
parent
d446fd5b66
commit
9a5ea07ca0
3 changed files with 18 additions and 4 deletions
7
backend/package-lock.json
generated
7
backend/package-lock.json
generated
|
@ -10219,6 +10219,8 @@
|
|||
},
|
||||
"node_modules/ua-parser-js": {
|
||||
"version": "0.7.28",
|
||||
"resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-0.7.28.tgz",
|
||||
"integrity": "sha512-6Gurc1n//gjp9eQNXjD9O3M/sMwVtN5S8Lv9bvOYBfKfDNiIIhqiyi01vMBO45u4zkDE420w/e0se7Vs+sIg+g==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "opencollective",
|
||||
|
@ -10229,7 +10231,6 @@
|
|||
"url": "https://paypal.me/faisalman"
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": "*"
|
||||
}
|
||||
|
@ -17944,7 +17945,9 @@
|
|||
"peer": true
|
||||
},
|
||||
"ua-parser-js": {
|
||||
"version": "0.7.28"
|
||||
"version": "0.7.28",
|
||||
"resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-0.7.28.tgz",
|
||||
"integrity": "sha512-6Gurc1n//gjp9eQNXjD9O3M/sMwVtN5S8Lv9bvOYBfKfDNiIIhqiyi01vMBO45u4zkDE420w/e0se7Vs+sIg+g=="
|
||||
},
|
||||
"uc.micro": {
|
||||
"version": "1.0.6",
|
||||
|
|
|
@ -2,7 +2,11 @@ export function implemented(): boolean {
|
|||
return false;
|
||||
}
|
||||
|
||||
export function validateResult(_result: object, _version: string): boolean {
|
||||
export function validateResult(
|
||||
_result: object,
|
||||
_version: string,
|
||||
_uaStringifiedObject: string
|
||||
): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@ import { buildMonkeyMail } from "../../utils/monkey-mail";
|
|||
import FunboxesMetadata from "../../constants/funbox";
|
||||
import _ from "lodash";
|
||||
import * as WeeklyXpLeaderboard from "../../services/weekly-xp-leaderboard";
|
||||
import { UAParser } from "ua-parser-js";
|
||||
|
||||
try {
|
||||
if (anticheatImplemented() === false) throw new Error("undefined");
|
||||
|
@ -197,7 +198,13 @@ export async function addResult(
|
|||
}
|
||||
|
||||
if (anticheatImplemented()) {
|
||||
if (!validateResult(result, req.headers["client-version"] as string)) {
|
||||
if (
|
||||
!validateResult(
|
||||
result,
|
||||
req.headers["client-version"] as string,
|
||||
JSON.stringify(new UAParser(req.headers["user-agent"]).getResult())
|
||||
)
|
||||
) {
|
||||
const status = MonkeyStatusCodes.RESULT_DATA_INVALID;
|
||||
throw new MonkeyError(status.code, "Result data doesn't make sense");
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue