Saving now works over insecure networks.

This commit is contained in:
2025-03-17 21:57:57 -05:00
parent aa42df4a0e
commit da34ccfa0c
4 changed files with 43 additions and 8 deletions

View File

@ -51,6 +51,12 @@ class HomeplayEmulator {
window.EJS_onLoadState = this.onEJSLoadState;
window.onmessage = this.onMessage;
// Now check if we have the libs we NEED.
if(!window.JSZip || !window.CryptoJS) {
this.send({ message: 'error', error: 'Missing required libraries' });
return;
}
// Begin the init interval
this.initInterval = setInterval(() => {
this.send({ message: 'iframe_loaded' });
@ -66,7 +72,7 @@ class HomeplayEmulator {
await this.save();
}
} catch(e) {
console.error('Error checking for save updates', e);
this.send({ message: 'error', error: e.message });
} finally {
this.saveLock = false;
}
@ -147,16 +153,22 @@ class HomeplayEmulator {
break;
default:
console.error('Website sent invalid message', data);
this.send({ message: 'error', error: 'Unknown message' });
break;
}
}
getFileMD5 = async path => {
const buffer = window.EJS_emulator.gameManager.FS.readFile(path);
const hash = await crypto.subtle.digest('SHA-256', buffer);
const hashArray = Array.from(new Uint8Array(hash));
const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join('');
return hashHex;
// Convert buffer to string, likely going to need to change later.
const bufferArray = Array.from(new Uint8Array(buffer));
const bufferString = bufferArray.map(b => String.fromCharCode(b)).join('');
// Hash string
const hash = window.CryptoJS.MD5(bufferString);
const hashString = hash.toString(CryptoJS.enc.Base64);
return hashString;
}
getRetroArchCfg = (gameManager) => {