From 6cdf207dcd41270ff4c6084fbb24bd261cc1762a Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Wed, 8 Nov 2023 01:58:02 +0000 Subject: [PATCH] Encrypt draft wiki blobs. git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4619 ed5197a5-7fde-0310-b194-c3ffbd925b24 --- apps/wiki.json | 2 +- apps/wiki/tf-wiki-doc.js | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/apps/wiki.json b/apps/wiki.json index e9a1ab5a..cd04a522 100644 --- a/apps/wiki.json +++ b/apps/wiki.json @@ -1,5 +1,5 @@ { "type": "tildefriends-app", "emoji": "📝", - "previous": "&rj3P1MdTitVRBCznRAN+lmMz8dxPwil2PjQ31KdkPi4=.sha256" + "previous": "&N1wA9DJ6RacaPG52I+ZEhWbbVvf3U1Dcvouh0UkfkG0=.sha256" } \ No newline at end of file diff --git a/apps/wiki/tf-wiki-doc.js b/apps/wiki/tf-wiki-doc.js index a8cc75fc..7e8e6564 100644 --- a/apps/wiki/tf-wiki-doc.js +++ b/apps/wiki/tf-wiki-doc.js @@ -25,8 +25,15 @@ class TfWikiDocElement extends LitElement { } async load_blob() { - this.blob = await tfrpc.rpc.get_blob(this.value?.blob); - this.blob_original = this.blob; + let blob = await tfrpc.rpc.get_blob(this.value?.blob); + if (blob.endsWith('.box')) { + let d = await tfrpc.rpc.try_decrypt(this.whoami, blob); + if (d) { + blob = d; + } + } + this.blob = blob; + this.blob_original = blob; } on_edit(event) { @@ -39,7 +46,11 @@ class TfWikiDocElement extends LitElement { } async append_message(draft) { - let id = await tfrpc.rpc.store_blob(this.blob); + let blob = this.blob; + if (draft) { + blob = await tfrpc.rpc.encrypt(this.whoami, this.value.editors, blob); + } + let id = await tfrpc.rpc.store_blob(blob); let message = { type: 'wiki-doc', key: this.value.id,