updated encryption to only encrypt when password is set.

This commit is contained in:
Michael Mainguy 2024-07-17 15:29:57 -05:00
parent 4fdcc9694d
commit 1de6270f79
5 changed files with 48 additions and 6 deletions

View File

@ -3,7 +3,7 @@
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta content="width=device-width, initial-scale=1" name="viewport"/> <meta content="width=device-width, initial-scale=1" name="viewport"/>
<meta content="An immersive vr diagramming experience based using webxr version @@VERSION (@@DATE) @@GIT" <meta content="An immersive vr diagramming experience based using webxr version 0.0.8-14 (2024-07-03T13:09:05.707Z) 4fdcc9694d3614be538e425110d1ab50cd20b302"
name="description"> name="description">
<meta content="width=device-width, initial-scale=1, height=device-height" name="viewport"> <meta content="width=device-width, initial-scale=1, height=device-height" name="viewport">
<link href="/styles.css" rel="stylesheet"> <link href="/styles.css" rel="stylesheet">

View File

@ -1,7 +1,7 @@
{ {
"name": "immersive", "name": "immersive",
"private": true, "private": true,
"version": "0.0.8-13", "version": "0.0.8-15",
"type": "module", "type": "module",
"engines": { "engines": {
"node": ">=18.0.0" "node": ">=18.0.0"

View File

@ -17,6 +17,13 @@ import {Presence} from "./presence";
type PasswordEvent = { type PasswordEvent = {
detail: string; detail: string;
}
type PasswordEvent2 = {
password: string;
id: string;
encrypted: boolean;
} }
export class PouchdbPersistenceManager { export class PouchdbPersistenceManager {
private _logger: Logger = log.getLogger('PouchdbPersistenceManager'); private _logger: Logger = log.getLogger('PouchdbPersistenceManager');
@ -41,6 +48,24 @@ export class PouchdbPersistenceManager {
} }
this._logger.debug(evt); this._logger.debug(evt);
}); });
document.addEventListener('dbcreated', (evt) => {
const detail = ((evt as unknown) as PasswordEvent2);
const password = detail.password;
const id = detail.id;
if (detail.encrypted) {
this._encKey = password;
} else {
this._encKey = null;
}
//this._encKey = password;
this.db = new PouchDB(detail.id, {auto_compaction: true});
this.setupMetadata(id).then(() => {
document.location.href = '/db/' + id;
}).catch((err) => {
console.log(err);
})
});
} }
public setDiagramManager(diagramManager: DiagramManager) { public setDiagramManager(diagramManager: DiagramManager) {
@ -200,6 +225,7 @@ export class PouchdbPersistenceManager {
if (doc && doc.friendly) { if (doc && doc.friendly) {
this._logger.info("Storing Document friendly name in local storage"); this._logger.info("Storing Document friendly name in local storage");
localStorage.setItem(current, doc.friendly); localStorage.setItem(current, doc.friendly);
this._encKey = null;
} }
if (doc && doc.camera) { if (doc && doc.camera) {

View File

@ -59,13 +59,19 @@ function CreateMenu({display, toggleCreateMenu}) {
const onCreateClick = (evt) => { const onCreateClick = (evt) => {
evt.preventDefault(); evt.preventDefault();
const name = (document.querySelector('#createName') as HTMLInputElement).value; const name = (document.querySelector('#createName') as HTMLInputElement).value;
const password = (document.querySelector('#createPassword') as HTMLInputElement).value; let password = (document.querySelector('#createPassword') as HTMLInputElement).value;
const password2 = (document.querySelector('#createPassword2') as HTMLInputElement).value; const password2 = (document.querySelector('#createPassword2') as HTMLInputElement).value;
if (password !== password2) { if (password !== password2) {
window.alert('Passwords do not match'); window.alert('Passwords do not match');
return; return;
} }
const id = window.crypto.randomUUID().replace(/-/g, '_'); const id = window.crypto.randomUUID().replace(/-/g, '_');
if (password.length == 0) {
password = id;
}
const encrypted = (password != id);
localStorage.setItem(id, name); localStorage.setItem(id, name);
if (name && name.length > 4) { if (name && name.length > 4) {
axios.post(import.meta.env.VITE_CREATE_ENDPOINT, axios.post(import.meta.env.VITE_CREATE_ENDPOINT,
@ -78,7 +84,16 @@ function CreateMenu({display, toggleCreateMenu}) {
} }
).then(response => { ).then(response => {
console.log(response); console.log(response);
document.location.href = '/db/' + id; const evt = new CustomEvent('dbcreated', {
detail: {
id: id,
name: name,
password: password,
encrypted: encrypted
}
});
document.dispatchEvent(evt);
}).catch(error => { }).catch(error => {
console.error(error); console.error(error);
}); });

View File

@ -18,7 +18,8 @@ export class CustomPhysics {
const havok = await HavokPhysics(); const havok = await HavokPhysics();
const havokPlugin = new HavokPlugin(true, havok); const havokPlugin = new HavokPlugin(true, havok);
const scene = this.scene; const scene = this.scene;
scene.enablePhysics(new Vector3(0, -9.8, 0), havokPlugin); const physicsEnable = scene.enablePhysics(new Vector3(0, -9.8, 0), havokPlugin);
scene.collisionsEnabled = true; scene.collisionsEnabled = true;
scene.onAfterPhysicsObservable.add(() => { scene.onAfterPhysicsObservable.add(() => {
scene.meshes.forEach((mesh) => { scene.meshes.forEach((mesh) => {