Fixed and improved encryption handling. Also wrapping up for the day.

This commit is contained in:
Scott Idem
2025-05-16 17:29:33 -04:00
parent 8b68b0d2bb
commit f88e6cef89
5 changed files with 154 additions and 96 deletions

View File

@@ -740,7 +740,7 @@ export async function db_save_ae_obj_li__journal(
// tmp_sort_1: `${obj.original_datetime}_${obj.group}_${obj.priority}_${obj.sort}`,
// tmp_sort_2: `${obj.group}_${obj.original_datetime}_${obj.priority}_${obj.sort}`,
combined_passcode: `${obj.passcode}:${obj.private_passcode}`, // Combined Journal passcode and Journal private passcode to encrypt and decrypt Entries
combined_passcode: `${obj.passcode}:${obj.private_passcode ?? ''}`, // Combined Journal passcode and Journal private passcode to encrypt and decrypt Entries
// From SQL view
journal_entry_count: obj.journal_entry_count,

View File

@@ -101,7 +101,7 @@ export let decrypt_wrapper = async function decrypt_wrapper(
) {
if (!combined) {
console.error('No combined string provided. Returning empty string.');
return '';
return false;
}
const { iv, base64 } = split_iv_and_base64(combined);
let decrypted;
@@ -114,7 +114,7 @@ export let decrypt_wrapper = async function decrypt_wrapper(
}
} catch (error) {
console.error('Decryption failed:', error);
return '';
return false;
}
return decrypted;
}

View File

@@ -59,6 +59,7 @@ let lq__journal_obj = $derived(liveQuery(async () => {
.get($journals_slct?.journal_id ?? ''); // null or undefined does not reset things like '' does
$journals_slct.journal_obj = results;
tmp_journal_obj = { ...results };
if (log_lvl) {
console.log(`lq__journal_obj: results = `, results);
}
@@ -66,11 +67,12 @@ let lq__journal_obj = $derived(liveQuery(async () => {
return results;
}));
$effect(() => {
if ($lq__journal_obj) {
tmp_journal_obj = { ...$lq__journal_obj };
}
});
// $effect(() => {
// if ($lq__journal_obj) {
// tmp_journal_obj = { ...$lq__journal_obj };
// console.log('tmp_journal_obj:', tmp_journal_obj);
// }
// });
$effect(() => {
if (tmp_journal_obj) {
@@ -79,18 +81,19 @@ $effect(() => {
});
async function handle_update_journal() {
if ($journals_slct.tmp_journal_obj.name && $journals_slct.tmp_journal_obj.type_code) {
if (tmp_journal_obj.name && tmp_journal_obj.type_code) {
try {
let data_kv = {
// account: $slct.account_id,
name: $journals_slct.tmp_journal_obj.name,
description: $journals_slct.tmp_journal_obj.description ?? '', // Ensure description is at least an empty string
type_code: $journals_slct.tmp_journal_obj.type_code,
passcode: $journals_slct.tmp_journal_obj.passcode,
passcode_timeout: $journals_slct.tmp_journal_obj.passcode_timeout,
auth_key: $journals_slct.tmp_journal_obj.auth_key, // The Journal Entry encryption password
name: tmp_journal_obj.name,
description: tmp_journal_obj.description ?? '', // Ensure description is at least an empty string
type_code: tmp_journal_obj.type_code,
passcode: tmp_journal_obj.passcode,
private_passcode: tmp_journal_obj.private_passcode,
passcode_timeout: tmp_journal_obj.passcode_timeout,
auth_key: tmp_journal_obj.auth_key, // The Journal Entry encryption password
cfg_json: $journals_slct.tmp_journal_obj.cfg_json
cfg_json: tmp_journal_obj.cfg_json
};
journals_func.update_ae_obj__journal({
@@ -199,7 +202,7 @@ async function handle_update_journal() {
<!-- <button
type="button"
onclick={() => {
$journals_slct.tmp_journal_obj = {
tmp_journal_obj = {
name: $lq__journal_obj?.name,
description: $lq__journal_obj?.description,
type_code: $lq__journal_obj?.type_code,
@@ -390,7 +393,7 @@ async function handle_update_journal() {
<div class="space-y-2 py-2 mb-2">
<label class="text-sm text-gray-500 hidden sm:inline">
Journal Name:
<input type="text" placeholder="Journal Name" bind:value={$journals_slct.tmp_journal_obj.name} class="input input-bordered w-full mb-2" />
<input type="text" placeholder="Journal Name" bind:value={tmp_journal_obj.name} class="input input-bordered w-full mb-2" />
</label>
<!-- Journal Description (Markdown) -->
@@ -398,7 +401,7 @@ async function handle_update_journal() {
Journal Description:
<textarea
placeholder="Journal Description (Markdown format)"
bind:value={$journals_slct.tmp_journal_obj.description}
bind:value={tmp_journal_obj.description}
class="input input-bordered w-full mb-2 h-32 resize-none"
title="Description of the journal (supports Markdown)"
></textarea>
@@ -406,31 +409,47 @@ async function handle_update_journal() {
<div class="*:hover:inline">
<!-- input for passcode -->
<label
class="text-sm text-gray-500">
Passcode:
<input type="text" placeholder="Passcode" bind:value={$journals_slct.tmp_journal_obj.passcode} class="input input-bordered w-64 mb-2" />
</label>
<div class="text-xs text-gray-500 hidden md:inline">
<span class="text-red-500">*</span> This passcode is used to encrypt the Journal Entries.
<div class="*:hover:inline">
<label
class="text-sm text-gray-500">
Passcode:
<input type="text" placeholder="Passcode" bind:value={tmp_journal_obj.passcode} class="input input-bordered w-64 mb-2" />
</label>
<div class="text-xs text-gray-500 hidden md:inline">
<span class="text-red-500">*</span> This passcode is used to encrypt the Journal Entries.
</div>
</div>
<!-- input for private passcode -->
<div class="*:hover:inline">
<label
class="text-sm text-gray-500">
Private Passcode:
<input type="text" placeholder="Private Passcode" bind:value={tmp_journal_obj.private_passcode} class="input input-bordered w-64 mb-2" />
</label>
<div class="text-xs text-gray-500 hidden md:inline">
<span class="text-red-500">*</span> This passcode is combined with the regular passcode and used to encrypt the Journal Entries.
</div>
</div>
<!-- input for passcode timeout -->
<label class="text-sm text-gray-500">
Passcode Timeout:
<input type="number" placeholder="Passcode Timeout" bind:value={$journals_slct.tmp_journal_obj.passcode_timeout} class="input input-bordered w-32 mb-2" />
</label>
<div class="*:hover:inline">
<label class="text-sm text-gray-500">
Passcode Timeout:
<input type="number" placeholder="Passcode Timeout" bind:value={tmp_journal_obj.passcode_timeout} class="input input-bordered w-32 mb-2" />
</label>
</div>
</div>
<!-- input for auth_key -->
<label class="text-sm text-gray-500 sm:inline">
Auth Key:
<input type="text" placeholder="Auth Key" bind:value={$journals_slct.tmp_journal_obj.auth_key} class="input input-bordered w-64 mb-2" />
<input type="text" placeholder="Auth Key" bind:value={tmp_journal_obj.auth_key} class="input input-bordered w-64 mb-2" />
</label>
<label class="text-sm text-gray-500">
Journal Type:
<input type="text" placeholder="Journal Type" bind:value={$journals_slct.tmp_journal_obj.type_code} class="input input-bordered w-48 mb-2" />
<input type="text" placeholder="Journal Type" bind:value={tmp_journal_obj.type_code} class="input input-bordered w-48 mb-2" />
</label>
<!-- select option for journal type_code -->
@@ -445,11 +464,11 @@ async function handle_update_journal() {
transition
text-xs
"
bind:value={$journals_slct.tmp_journal_obj.type_code}
bind:value={tmp_journal_obj.type_code}
onchange={(event) => {
// Update the cfg_json with the selected journal type. Example cate
$journals_slct.tmp_journal_obj.type_code = event.target.value;
console.log('Selected journal type:', $journals_slct.tmp_journal_obj.type_code);
tmp_journal_obj.type_code = event.target.value;
console.log('Selected journal type:', tmp_journal_obj.type_code);
}}
title="Select a journal type"
>
@@ -460,23 +479,23 @@ async function handle_update_journal() {
</select>
</div>
<div class="flex flex-row gap-1 items-center justify-start">
<div class="flex flex-row flex-wrap gap-1 items-start justify-start">
<!-- inputs for customizable journal category list -->
<!-- each category has a code and name; need to be able to add and remove categories -->
<div class="text-sm text-gray-500 hidden sm:inline">
Journal Categories:
</div>
<div class="flex flex-col gap-1 p-4">
{#each $journals_slct.tmp_journal_obj.cfg_json.category_li as category, index}
{#each tmp_journal_obj?.cfg_json?.category_li as category, index}
<div class="flex flex-row items-center gap-1">
<input type="text" placeholder="Category Code" bind:value={$journals_slct.tmp_journal_obj.cfg_json.category_li[index].code} class="input input-bordered w-48" />
<input type="text" placeholder="Category Name" bind:value={$journals_slct.tmp_journal_obj.cfg_json.category_li[index].name} class="input input-bordered w-full" />
<input type="text" placeholder="Category Code" bind:value={tmp_journal_obj.cfg_json.category_li[index].code} class="input input-bordered w-48" />
<input type="text" placeholder="Category Name" bind:value={tmp_journal_obj.cfg_json.category_li[index].name} class="input input-bordered w-full" />
<button
type="button"
class="btn btn-sm variant-ghost-danger hover:variant-filled-danger transition"
onclick={() => {
$journals_slct.tmp_journal_obj.cfg_json.category_li.splice(index, 1);
$journals_slct.tmp_journal_obj.cfg_json.category_li = $journals_slct.tmp_journal_obj.cfg_json.category_li;
tmp_journal_obj.cfg_json.category_li.splice(index, 1);
tmp_journal_obj.cfg_json.category_li = tmp_journal_obj.cfg_json.category_li;
}}
>
<Minus />
@@ -487,8 +506,8 @@ async function handle_update_journal() {
<button
type="button"
onclick={() => {
$journals_slct.tmp_journal_obj.cfg_json.category_li.push({ code: '', name: '' });
$journals_slct.tmp_journal_obj.cfg_json.category_li = $journals_slct.tmp_journal_obj.cfg_json.category_li;
tmp_journal_obj.cfg_json.category_li.push({ code: '', name: '' });
tmp_journal_obj.cfg_json.category_li = tmp_journal_obj.cfg_json.category_li;
}}
class="btn btn-sm variant-ghost-secondary hover:variant-filled-secondary transition max-w-48 p-1"
>
@@ -504,10 +523,10 @@ async function handle_update_journal() {
Journal Entry List Max Height:
</span>
<select
bind:value={$journals_slct.tmp_journal_obj.cfg_json.entry_li_max_height}
bind:value={tmp_journal_obj.cfg_json.entry_li_max_height}
onchange={(event) => {
$journals_slct.tmp_journal_obj.cfg_json.entry_li_max_height = event.target.value;
console.log('Selected max height:', $journals_slct.tmp_journal_obj.cfg_json.entry_li_max_height);
tmp_journal_obj.cfg_json.entry_li_max_height = event.target.value;
console.log('Selected max height:', tmp_journal_obj.cfg_json.entry_li_max_height);
}}
class="btn btn-sm variant-ghost-surface hover:variant-filled-surface transition text-xs w-full mb-2 max-w-48"
title="Select maximum height for journal entries in the list"
@@ -529,10 +548,10 @@ async function handle_update_journal() {
Journal Entry List Hover Max Height:
</span>
<select
bind:value={$journals_slct.tmp_journal_obj.cfg_json.entry_li_hover_max_height}
bind:value={tmp_journal_obj.cfg_json.entry_li_hover_max_height}
onchange={(event) => {
$journals_slct.tmp_journal_obj.cfg_json.entry_li_hover_max_height = event.target.value;
console.log('Selected max height:', $journals_slct.tmp_journal_obj.cfg_json.entry_li_hover_max_height);
tmp_journal_obj.cfg_json.entry_li_hover_max_height = event.target.value;
console.log('Selected max height:', tmp_journal_obj.cfg_json.entry_li_hover_max_height);
}}
class="btn btn-sm variant-ghost-surface hover:variant-filled-surface transition text-xs w-full mb-2 max-w-48"
title="Select maximum height for journal entries in the list"
@@ -554,10 +573,10 @@ async function handle_update_journal() {
Journal Entry List Active (click/press) Max Height:
</span>
<select
bind:value={$journals_slct.tmp_journal_obj.cfg_json.entry_li_click_max_height}
bind:value={tmp_journal_obj.cfg_json.entry_li_click_max_height}
onchange={(event) => {
$journals_slct.tmp_journal_obj.cfg_json.entry_li_click_max_height = event.target.value;
console.log('Selected max height:', $journals_slct.tmp_journal_obj.cfg_json.entry_li_click_max_height);
tmp_journal_obj.cfg_json.entry_li_click_max_height = event.target.value;
console.log('Selected max height:', tmp_journal_obj.cfg_json.entry_li_click_max_height);
}}
class="btn btn-sm variant-ghost-surface hover:variant-filled-surface transition text-xs w-full mb-2 max-w-48"
title="Select maximum height for journal entries in the list"
@@ -584,16 +603,16 @@ async function handle_update_journal() {
<button
type="button"
onclick={() => {
if ($journals_slct.tmp_journal_obj.cfg_json.expand_li_content == 'hover') {
$journals_slct.tmp_journal_obj.cfg_json.expand_li_content = 'click';
if (tmp_journal_obj.cfg_json.expand_li_content == 'hover') {
tmp_journal_obj.cfg_json.expand_li_content = 'click';
} else {
$journals_slct.tmp_journal_obj.cfg_json.expand_li_content = 'hover';
tmp_journal_obj.cfg_json.expand_li_content = 'hover';
}
}}
class="btn btn-sm variant-ghost-secondary hover:variant-filled-secondary transition *:hover:inline"
title="Toggle visibility of Markdown copy button(s) on Journal Entry view page"
>
{#if $journals_slct.tmp_journal_obj.cfg_json.expand_li_content == 'hover'}
{#if tmp_journal_obj.cfg_json.expand_li_content == 'hover'}
<!-- <EyeOff strokeWidth="1" color="red" /> -->
<ToggleLeft strokeWidth="1" color="red" class="mx-1" />
@@ -627,16 +646,16 @@ async function handle_update_journal() {
<button
type="button"
onclick={() => {
if ($journals_slct.tmp_journal_obj.cfg_json.entry_add_text == 'append') {
$journals_slct.tmp_journal_obj.cfg_json.entry_add_text = 'prepend';
if (tmp_journal_obj.cfg_json.entry_add_text == 'append') {
tmp_journal_obj.cfg_json.entry_add_text = 'prepend';
} else {
$journals_slct.tmp_journal_obj.cfg_json.entry_add_text = 'append';
tmp_journal_obj.cfg_json.entry_add_text = 'append';
}
}}
class="btn btn-sm variant-ghost-secondary hover:variant-filled-secondary transition *:hover:inline"
title="Toggle visibility of Markdown copy button(s) on Journal Entry view page"
>
{#if $journals_slct.tmp_journal_obj.cfg_json.entry_add_text == 'append'}
{#if tmp_journal_obj.cfg_json.entry_add_text == 'append'}
<!-- <EyeOff strokeWidth="1" color="red" /> -->
<ToggleLeft strokeWidth="1" color="red" class="mx-1" />
@@ -669,10 +688,10 @@ async function handle_update_journal() {
Color Scheme:
</span>
<select
bind:value={$journals_slct.tmp_journal_obj.cfg_json.color_scheme}
bind:value={tmp_journal_obj.cfg_json.color_scheme}
onchange={(event) => {
$journals_slct.tmp_journal_obj.cfg_json.color_scheme = event.target.value;
console.log('Selected color scheme:', $journals_slct.tmp_journal_obj.cfg_json.color_scheme);
tmp_journal_obj.cfg_json.color_scheme = event.target.value;
console.log('Selected color scheme:', tmp_journal_obj.cfg_json.color_scheme);
}}
class="btn btn-sm variant-ghost-surface hover:variant-filled-surface transition text-xs w-full mb-2 max-w-48"
title="Select color scheme for journal entries"
@@ -693,10 +712,10 @@ async function handle_update_journal() {
Preferred Viewer:
</span>
<select
bind:value={$journals_slct.tmp_journal_obj.cfg_json.pref_viewer}
bind:value={tmp_journal_obj.cfg_json.pref_viewer}
onchange={(event) => {
$journals_slct.tmp_journal_obj.cfg_json.pref_viewer = event.target.value;
console.log('Selected viewer:', $journals_slct.tmp_journal_obj.cfg_json.pref_viewer);
tmp_journal_obj.cfg_json.pref_viewer = event.target.value;
console.log('Selected viewer:', tmp_journal_obj.cfg_json.pref_viewer);
}}
class="btn btn-sm variant-ghost-surface hover:variant-filled-surface transition text-xs w-full mb-2 max-w-48"
title="Select preferred viewer for journal entries"
@@ -714,10 +733,10 @@ async function handle_update_journal() {
Preferred Editor:
</span>
<select
bind:value={$journals_slct.tmp_journal_obj.cfg_json.pref_editor}
bind:value={tmp_journal_obj.cfg_json.pref_editor}
onchange={(event) => {
$journals_slct.tmp_journal_obj.cfg_json.pref_editor = event.target.value;
console.log('Selected editor:', $journals_slct.tmp_journal_obj.cfg_json.pref_editor);
tmp_journal_obj.cfg_json.pref_editor = event.target.value;
console.log('Selected editor:', tmp_journal_obj.cfg_json.pref_editor);
}}
class="btn btn-sm variant-ghost-surface hover:variant-filled-surface transition text-xs w-full mb-2 max-w-48"
title="Select preferred editor for journal entries"
@@ -739,12 +758,12 @@ async function handle_update_journal() {
<button
type="button"
onclick={() => {
$journals_slct.tmp_journal_obj.cfg_json.hide_copy_plain_md = !$journals_slct.tmp_journal_obj.cfg_json.hide_copy_plain_md;
tmp_journal_obj.cfg_json.hide_copy_plain_md = !tmp_journal_obj.cfg_json.hide_copy_plain_md;
}}
class="btn btn-sm variant-ghost-secondary hover:variant-filled-secondary transition *:hover:inline"
title="Toggle visibility of Markdown copy button(s) on Journal Entry view page"
>
{#if $journals_slct.tmp_journal_obj.cfg_json.hide_copy_plain_md}
{#if tmp_journal_obj.cfg_json.hide_copy_plain_md}
<!-- <EyeOff strokeWidth="1" color="red" /> -->
<ToggleLeft strokeWidth="1" color="red" class="mx-1" />
<EyeOff strokeWidth="1" color="gray" />
@@ -767,12 +786,12 @@ async function handle_update_journal() {
<button
type="button"
onclick={() => {
$journals_slct.tmp_journal_obj.cfg_json.hide_copy_html = !$journals_slct.tmp_journal_obj.cfg_json.hide_copy_html;
tmp_journal_obj.cfg_json.hide_copy_html = !tmp_journal_obj.cfg_json.hide_copy_html;
}}
class="btn btn-sm variant-ghost-secondary hover:variant-filled-secondary transition *:hover:inline"
title="Toggle visibility of HTML copy button(s) on Journal Entry view page"
>
{#if $journals_slct.tmp_journal_obj.cfg_json.hide_copy_html}
{#if tmp_journal_obj.cfg_json.hide_copy_html}
<!-- <EyeOff strokeWidth="1" color="red" /> -->
<ToggleLeft strokeWidth="1" color="red" class="mx-1" />
<EyeOff strokeWidth="1" color="gray" />
@@ -795,12 +814,12 @@ async function handle_update_journal() {
<button
type="button"
onclick={() => {
$journals_slct.tmp_journal_obj.cfg_json.hide_copy_rich = !$journals_slct.tmp_journal_obj.cfg_json.hide_copy_rich;
tmp_journal_obj.cfg_json.hide_copy_rich = !tmp_journal_obj.cfg_json.hide_copy_rich;
}}
class="btn btn-sm variant-ghost-secondary hover:variant-filled-secondary transition *:hover:inline"
title="Toggle visibility of rendered copy button(s) on Journal Entry view page"
>
{#if $journals_slct.tmp_journal_obj.cfg_json.hide_copy_rich}
{#if tmp_journal_obj.cfg_json.hide_copy_rich}
<!-- <EyeOff strokeWidth="1" color="red" /> -->
<ToggleLeft strokeWidth="1" color="red" class="mx-1" />
<EyeOff strokeWidth="1" color="gray" />
@@ -823,12 +842,12 @@ async function handle_update_journal() {
<button
type="button"
onclick={() => {
$journals_slct.tmp_journal_obj.cfg_json.hide_copy_encrypted = !$journals_slct.tmp_journal_obj.cfg_json.hide_copy_encrypted;
tmp_journal_obj.cfg_json.hide_copy_encrypted = !tmp_journal_obj.cfg_json.hide_copy_encrypted;
}}
class="btn btn-sm variant-ghost-secondary hover:variant-filled-secondary transition *:hover:inline"
title="Toggle visibility of encrypted copy button(s) on Journal Entry view page"
>
{#if $journals_slct.tmp_journal_obj.cfg_json.hide_copy_encrypted}
{#if tmp_journal_obj.cfg_json.hide_copy_encrypted}
<!-- <EyeOff strokeWidth="1" color="red" /> -->
<ToggleLeft strokeWidth="1" color="red" class="mx-1" />
<EyeOff strokeWidth="1" color="gray" />
@@ -851,12 +870,12 @@ async function handle_update_journal() {
<button
type="button"
onclick={() => {
$journals_slct.tmp_journal_obj.cfg_json.hide_clone = !$journals_slct.tmp_journal_obj.cfg_json.hide_clone;
tmp_journal_obj.cfg_json.hide_clone = !tmp_journal_obj.cfg_json.hide_clone;
}}
class="btn btn-sm variant-ghost-secondary hover:variant-filled-secondary transition *:hover:inline"
title="Toggle visibility of clone button(s) on Journal Entry view page"
>
{#if $journals_slct.tmp_journal_obj.cfg_json.hide_clone}
{#if tmp_journal_obj.cfg_json.hide_clone}
<!-- <EyeOff strokeWidth="1" color="red" /> -->
<ToggleLeft strokeWidth="1" color="red" class="mx-1" />
<Copy strokeWidth="1" color="gray" />
@@ -891,12 +910,12 @@ async function handle_update_journal() {
<button
type="button"
onclick={() => {
$journals_slct.tmp_journal_obj.cfg_json.hide_private = !$journals_slct.tmp_journal_obj.cfg_json.hide_private;
tmp_journal_obj.cfg_json.hide_private = !tmp_journal_obj.cfg_json.hide_private;
}}
class="btn btn-sm variant-ghost-secondary hover:variant-filled-secondary transition *:hover:inline"
title="Toggle visibility of private entries"
>
{#if $journals_slct.tmp_journal_obj.cfg_json.hide_private}
{#if tmp_journal_obj.cfg_json.hide_private}
<!-- <EyeOff strokeWidth="1" color="red" /> -->
<ToggleLeft strokeWidth="1" color="red" class="mx-1" />
<Fingerprint strokeWidth="1" color="gray" class="mx-1" />
@@ -919,12 +938,12 @@ async function handle_update_journal() {
<button
type="button"
onclick={() => {
$journals_slct.tmp_journal_obj.cfg_json.hide_personal = !$journals_slct.tmp_journal_obj.cfg_json.hide_personal;
tmp_journal_obj.cfg_json.hide_personal = !tmp_journal_obj.cfg_json.hide_personal;
}}
class="btn btn-sm variant-ghost-secondary hover:variant-filled-secondary transition *:hover:inline"
title="Toggle visibility of personal entries"
>
{#if $journals_slct.tmp_journal_obj.cfg_json.hide_personal}
{#if tmp_journal_obj.cfg_json.hide_personal}
<!-- <EyeOff strokeWidth="1" color="red" /> -->
<ToggleLeft strokeWidth="1" color="red" class="mx-1" />
<BookHeart strokeWidth="1" color="gray" />
@@ -947,12 +966,12 @@ async function handle_update_journal() {
<button
type="button"
onclick={() => {
$journals_slct.tmp_journal_obj.cfg_json.hide_professional = !$journals_slct.tmp_journal_obj.cfg_json.hide_professional;
tmp_journal_obj.cfg_json.hide_professional = !tmp_journal_obj.cfg_json.hide_professional;
}}
class="btn btn-sm variant-ghost-secondary hover:variant-filled-secondary transition *:hover:inline"
title="Toggle visibility of professional entries"
>
{#if $journals_slct.tmp_journal_obj.cfg_json.hide_professional}
{#if tmp_journal_obj.cfg_json.hide_professional}
<!-- <EyeOff strokeWidth="1" color="red" /> -->
<ToggleLeft strokeWidth="1" color="red" class="mx-1" />
<BriefcaseBusiness strokeWidth="1" color="gray" />
@@ -986,7 +1005,7 @@ async function handle_update_journal() {
<button
type="button"
onclick={() => {
$journals_slct.tmp_journal_obj.cfg_json.hide_btn_alert = !$journals_slct.tmp_journal_obj.cfg_json.hide_btn_alert;
tmp_journal_obj.cfg_json.hide_btn_alert = !tmp_journal_obj.cfg_json.hide_btn_alert;
}}
class="btn btn-sm variant-ghost-secondary hover:variant-filled-secondary transition *:hover:inline"
title="Toggle visibility of alert icon button(s) on Journal Entry view page"
@@ -1014,7 +1033,7 @@ async function handle_update_journal() {
<button
type="button"
onclick={() => {
$journals_slct.tmp_journal_obj.cfg_json.hide_btn_alert_msg = !$journals_slct.tmp_journal_obj.cfg_json.hide_btn_alert_msg;
tmp_journal_obj.cfg_json.hide_btn_alert_msg = !tmp_journal_obj.cfg_json.hide_btn_alert_msg;
}}
class="btn btn-sm variant-ghost-secondary hover:variant-filled-secondary transition *:hover:inline"
title="Toggle visibility of alert message icon button(s) on Journal Entry view page"
@@ -1042,7 +1061,7 @@ async function handle_update_journal() {
<button
type="button"
onclick={() => {
$journals_slct.tmp_journal_obj.cfg_json.hide_btn_private = !$journals_slct.tmp_journal_obj.cfg_json.hide_btn_private;
tmp_journal_obj.cfg_json.hide_btn_private = !tmp_journal_obj.cfg_json.hide_btn_private;
}}
class="btn btn-sm variant-ghost-secondary hover:variant-filled-secondary transition *:hover:inline"
title="Toggle visibility of private icon button(s) on Journal Entry view page"
@@ -1070,7 +1089,7 @@ async function handle_update_journal() {
<button
type="button"
onclick={() => {
$journals_slct.tmp_journal_obj.cfg_json.hide_btn_public = !$journals_slct.tmp_journal_obj.cfg_json.hide_btn_public;
tmp_journal_obj.cfg_json.hide_btn_public = !tmp_journal_obj.cfg_json.hide_btn_public;
}}
class="btn btn-sm variant-ghost-secondary hover:variant-filled-secondary transition *:hover:inline"
title="Toggle visibility of public icon button(s) on Journal Entry view page"
@@ -1098,7 +1117,7 @@ async function handle_update_journal() {
<button
type="button"
onclick={() => {
$journals_slct.tmp_journal_obj.cfg_json.hide_btn_personal = !$journals_slct.tmp_journal_obj.cfg_json.hide_btn_personal;
tmp_journal_obj.cfg_json.hide_btn_personal = !tmp_journal_obj.cfg_json.hide_btn_personal;
}}
class="btn btn-sm variant-ghost-secondary hover:variant-filled-secondary transition *:hover:inline"
title="Toggle visibility of personal icon button(s) on Journal Entry view page"
@@ -1126,7 +1145,7 @@ async function handle_update_journal() {
<button
type="button"
onclick={() => {
$journals_slct.tmp_journal_obj.cfg_json.hide_btn_professional = !$journals_slct.tmp_journal_obj.cfg_json.hide_btn_professional;
tmp_journal_obj.cfg_json.hide_btn_professional = !tmp_journal_obj.cfg_json.hide_btn_professional;
}}
class="btn btn-sm variant-ghost-secondary hover:variant-filled-secondary transition *:hover:inline"
title="Toggle visibility of professional icon button(s) on Journal Entry view page"
@@ -1154,7 +1173,7 @@ async function handle_update_journal() {
<button
type="button"
onclick={() => {
$journals_slct.tmp_journal_obj.cfg_json.hide_btn_template = !$journals_slct.tmp_journal_obj.cfg_json.hide_btn_template;
tmp_journal_obj.cfg_json.hide_btn_template = !tmp_journal_obj.cfg_json.hide_btn_template;
}}
class="btn btn-sm variant-ghost-secondary hover:variant-filled-secondary transition *:hover:inline"
title="Toggle visibility of template icon button(s) on Journal Entry view page"

View File

@@ -272,6 +272,21 @@ $effect(() => {
}
});
$effect(async () => {
if ($journals_sess?.journal_kv[$lq__journal_obj?.id]?.journal_passcode_verified && tmp_entry_obj?.content_encrypted && !tmp_entry_obj.content) {
console.log('TEST: Decrypting the content before displaying it...');
tmp_entry_obj.content = await ae_util.decrypt_wrapper(tmp_entry_obj?.content_encrypted, journal_key);
tmp_entry_obj.content_md_html = handle_marked(tmp_entry_obj?.content);
}
if ($journals_sess?.journal_kv[$lq__journal_obj?.id]?.journal_passcode_verified && tmp_entry_obj?.history_encrypted && !tmp_entry_obj.history) {
console.log('TEST: Decrypting the history before displaying it...');
tmp_entry_obj.history = await ae_util.decrypt_wrapper(tmp_entry_obj?.history_encrypted, journal_key);
tmp_entry_obj.history_md_html = handle_marked(tmp_entry_obj?.history);
}
});
// const test_html = marked.parse('# Marked in Node.js\n\nRendered by **marked**.');
async function update_journal_entry() {
@@ -2046,10 +2061,25 @@ tabindex={$ae_loc.edit_mode ? 0 : -1} -->
shadow-lg rounded-lg
border border-red-200 dark:border-red-700
hover:border-red-500 dark:hover:border-red-500
"
>
The entry must be decrypted before it can be edited.
<div>The entry must be decrypted before it can be edited.</div>
{#if tmp_entry_obj?.content === false && $journals_sess?.journal_kv[$lq__journal_obj?.id]?.journal_passcode_verified}
<div class="text-sm text-red-500">
<LockKeyhole strokeWidth="1.5" color="red" class="inline-block" />
Decryption failed. Check the passcode(s).
</div>
{:else if tmp_entry_obj?.content === false}
<div class="text-sm text-red-500">
<LockKeyhole strokeWidth="1.5" color="red" class="inline-block" />
Decryption failed. You may need to enter the Journal's private passcode.
</div>
{/if}
{#if tmp_entry_obj?.content === false && $lq__journal_obj?.id && $journals_sess?.journal_kv[$lq__journal_obj?.id]?.journal_passcode_verified}
<div class="text-sm text-red-500">
This might not be encoded with the private passcode or a passcode has changed?
</div>
{/if}
<!-- <span class="text-sm text-gray-500">
<Lock key={0} strokeWidth="2.5" color="red" />
<span class="hidden sm:inline">Encrypted</span>

View File

@@ -35,7 +35,13 @@ let passcode_timer: any = $state(null);
$effect(() => {
if (typed_journal_passcode?.length > 4) {
// log_lvl = 1;
if (!$journals_sess?.journal_kv) {
$journals_sess.journal_kv = {};
}
if (!$journals_sess.journal_kv[$lq__journal_obj?.id]) {
$journals_sess.journal_kv[$lq__journal_obj?.id] = {};
}
verify_journal_passcode();
}
@@ -53,6 +59,9 @@ $effect(() => {
console.log('Passcode timer expired');
}
typed_journal_passcode = '';
if (!$journals_sess?.journal_kv[$lq__journal_obj?.id]) {
$journals_sess.journal_kv[$lq__journal_obj?.id] = {};
}
$journals_sess.journal_kv[$lq__journal_obj?.id].journal_passcode_verified = false;
}, 1000 * 60 * 1); // 1 minutes
// }, 1000 * $lq__journal_obj?.passcode_timeout); // 5 minutes
@@ -227,7 +236,7 @@ function verify_journal_passcode() {
title="Enter private passcode of this journal"
/>
{#if $journals_sess.journal_kv[$lq__journal_obj?.id]?.journal_passcode_verified}
{#if $journals_sess?.journal_kv[$lq__journal_obj?.id]?.journal_passcode_verified}
<div class="text-sm text-gray-500">
<span class="fas fa-check-circle text-green-500"></span>
Journal passcode verified