updated encryption to only encrypt when password is set.
This commit is contained in:
parent
4fdcc9694d
commit
1de6270f79
@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<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">
|
||||
<meta content="width=device-width, initial-scale=1, height=device-height" name="viewport">
|
||||
<link href="/styles.css" rel="stylesheet">
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "immersive",
|
||||
"private": true,
|
||||
"version": "0.0.8-13",
|
||||
"version": "0.0.8-15",
|
||||
"type": "module",
|
||||
"engines": {
|
||||
"node": ">=18.0.0"
|
||||
|
||||
@ -17,6 +17,13 @@ import {Presence} from "./presence";
|
||||
type PasswordEvent = {
|
||||
detail: string;
|
||||
|
||||
}
|
||||
type PasswordEvent2 = {
|
||||
|
||||
password: string;
|
||||
id: string;
|
||||
encrypted: boolean;
|
||||
|
||||
}
|
||||
export class PouchdbPersistenceManager {
|
||||
private _logger: Logger = log.getLogger('PouchdbPersistenceManager');
|
||||
@ -41,6 +48,24 @@ export class PouchdbPersistenceManager {
|
||||
}
|
||||
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) {
|
||||
@ -200,6 +225,7 @@ export class PouchdbPersistenceManager {
|
||||
if (doc && doc.friendly) {
|
||||
this._logger.info("Storing Document friendly name in local storage");
|
||||
localStorage.setItem(current, doc.friendly);
|
||||
this._encKey = null;
|
||||
}
|
||||
if (doc && doc.camera) {
|
||||
|
||||
@ -240,7 +266,7 @@ export class PouchdbPersistenceManager {
|
||||
current = 'localdb';
|
||||
}
|
||||
this.db = new PouchDB(current, {auto_compaction: true});
|
||||
//await this.db.compact();
|
||||
//await this.db.compact();
|
||||
if (sync) {
|
||||
if (await this.setupMetadata(current)) {
|
||||
await this.beginSync(current);
|
||||
|
||||
@ -59,13 +59,19 @@ function CreateMenu({display, toggleCreateMenu}) {
|
||||
const onCreateClick = (evt) => {
|
||||
evt.preventDefault();
|
||||
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;
|
||||
if (password !== password2) {
|
||||
window.alert('Passwords do not match');
|
||||
return;
|
||||
}
|
||||
|
||||
const id = window.crypto.randomUUID().replace(/-/g, '_');
|
||||
if (password.length == 0) {
|
||||
password = id;
|
||||
}
|
||||
const encrypted = (password != id);
|
||||
|
||||
localStorage.setItem(id, name);
|
||||
if (name && name.length > 4) {
|
||||
axios.post(import.meta.env.VITE_CREATE_ENDPOINT,
|
||||
@ -78,7 +84,16 @@ function CreateMenu({display, toggleCreateMenu}) {
|
||||
}
|
||||
).then(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 => {
|
||||
console.error(error);
|
||||
});
|
||||
|
||||
@ -18,7 +18,8 @@ export class CustomPhysics {
|
||||
const havok = await HavokPhysics();
|
||||
const havokPlugin = new HavokPlugin(true, havok);
|
||||
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.onAfterPhysicsObservable.add(() => {
|
||||
scene.meshes.forEach((mesh) => {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user