removing custom text from the hash

This commit is contained in:
Miodec 2022-03-16 22:41:21 +01:00
parent de636ffc21
commit 3b01cd4f19
2 changed files with 5 additions and 2 deletions

View file

@ -75,6 +75,7 @@ class ResultController {
const resulthash = result.hash;
delete result.hash;
delete result.strigified;
delete result.customText;
if (
req.ctx.configuration.resultObjectHashCheck.enabled &&
resulthash.length === 64

View file

@ -1071,7 +1071,7 @@ export async function addWord(): Promise<void> {
interface CompletedEvent extends MonkeyTypes.Result<MonkeyTypes.Mode> {
keySpacing: number[] | "toolong";
keyDuration: number[] | "toolong";
customText: MonkeyTypes.CustomText;
customText?: MonkeyTypes.CustomText;
smoothConsistency: number;
wpmConsistency: number;
lang: string;
@ -1500,7 +1500,9 @@ export async function finish(difficultyFailed = false): Promise<void> {
AccountButton.loading(true);
completedEvent.challenge = ChallengeContoller.verify(completedEvent);
if (completedEvent.challenge === null) delete completedEvent?.challenge;
completedEvent.hash = objecthash(completedEvent);
const toHash = Object.assign({}, completedEvent);
delete toHash.customText;
completedEvent.hash = objecthash(toHash);
const response = await Ape.results.save(completedEvent);