mirror of
https://gitlab.com/lecarore/breakout71.git
synced 2025-04-22 04:56:15 -04:00
Added save file tempering "protection"
This commit is contained in:
parent
659d79bcd0
commit
efa634cd8f
2 changed files with 3773 additions and 3 deletions
3763
dist/index.html
vendored
3763
dist/index.html
vendored
File diff suppressed because one or more lines are too long
13
src/game.ts
13
src/game.ts
|
@ -51,6 +51,7 @@ import {
|
||||||
closeModal,
|
closeModal,
|
||||||
} from "./asyncAlert";
|
} from "./asyncAlert";
|
||||||
import { isOptionOn, options, toggleOption } from "./options";
|
import { isOptionOn, options, toggleOption } from "./options";
|
||||||
|
import {hashCode} from "./getLevelBackground";
|
||||||
|
|
||||||
export function play() {
|
export function play() {
|
||||||
if (gameState.running) return;
|
if (gameState.running) return;
|
||||||
|
@ -662,6 +663,7 @@ async function openSettingsPanel() {
|
||||||
localStorageContent[key] = value;
|
localStorageContent[key] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const signedPayload=JSON.stringify(localStorageContent)
|
||||||
const dlLink = document.createElement("a");
|
const dlLink = document.createElement("a");
|
||||||
|
|
||||||
dlLink.setAttribute(
|
dlLink.setAttribute(
|
||||||
|
@ -671,7 +673,8 @@ async function openSettingsPanel() {
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
fileType: "B71-save-file",
|
fileType: "B71-save-file",
|
||||||
appVersion,
|
appVersion,
|
||||||
localStorageContent,
|
signedPayload,
|
||||||
|
key: hashCode('Security by obscurity, but really the game is oss so eh'+signedPayload)
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -722,7 +725,7 @@ async function openSettingsPanel() {
|
||||||
const {
|
const {
|
||||||
fileType,
|
fileType,
|
||||||
appVersion: fileVersion,
|
appVersion: fileVersion,
|
||||||
localStorageContent,
|
signedPayload,key
|
||||||
} = JSON.parse(content);
|
} = JSON.parse(content);
|
||||||
if (fileType !== "B71-save-file")
|
if (fileType !== "B71-save-file")
|
||||||
throw new Error("Not a B71 save file");
|
throw new Error("Not a B71 save file");
|
||||||
|
@ -732,6 +735,12 @@ async function openSettingsPanel() {
|
||||||
fileVersion +
|
fileVersion +
|
||||||
" or newer.",
|
" or newer.",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if(key!== hashCode('Security by obscurity, but really the game is oss so eh'+signedPayload)){
|
||||||
|
throw new Error("Key does not match content.")
|
||||||
|
}
|
||||||
|
|
||||||
|
const localStorageContent=JSON.parse(signedPayload)
|
||||||
localStorage.clear();
|
localStorage.clear();
|
||||||
for (let key in localStorageContent) {
|
for (let key in localStorageContent) {
|
||||||
localStorage.setItem(key, localStorageContent[key]);
|
localStorage.setItem(key, localStorageContent[key]);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue