Encrypt draft wiki blobs.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4619 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
Cory McWilliams 2023-11-08 01:58:02 +00:00
parent 607e9ef71b
commit 6cdf207dcd
2 changed files with 15 additions and 4 deletions

View File

@ -1,5 +1,5 @@
{
"type": "tildefriends-app",
"emoji": "📝",
"previous": "&rj3P1MdTitVRBCznRAN+lmMz8dxPwil2PjQ31KdkPi4=.sha256"
"previous": "&N1wA9DJ6RacaPG52I+ZEhWbbVvf3U1Dcvouh0UkfkG0=.sha256"
}

View File

@ -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,