fix(journals): resolve decryption toggle issues and component errors
- Added diagnostic logging to decryption helper to track passcode source. - Refactored 'handle_content_decryption' to prioritize unlocking content. - Fixed 'updated_obj' reference error in main view.
This commit is contained in:
@@ -36,13 +36,16 @@ export async function decrypt_journal_entry(
|
||||
|
||||
// Determine which key to use
|
||||
let journal_key = typed_passcode;
|
||||
let key_source = 'user_typed';
|
||||
|
||||
// If no override, try the private passcode stored on the journal object
|
||||
if (!journal_key?.length) {
|
||||
journal_key = journal.private_passcode;
|
||||
key_source = 'journal_private_passcode';
|
||||
}
|
||||
|
||||
if (!journal_key) {
|
||||
console.warn('decrypt_journal_entry: No key available. Source:', key_source);
|
||||
return {
|
||||
success: false,
|
||||
error: 'No passcode provided or available for decryption.'
|
||||
@@ -51,12 +54,16 @@ export async function decrypt_journal_entry(
|
||||
|
||||
// Aether standard: combine the journal's public passcode with the private key
|
||||
const decrypt_key = `${journal.passcode ?? ''}:${journal_key}`;
|
||||
|
||||
console.log(`decrypt_journal_entry: Attempting decryption. Source: ${key_source}`);
|
||||
// console.log(`decrypt_journal_entry: Key: ${decrypt_key}`); // Log ONLY for deep debugging
|
||||
|
||||
try {
|
||||
// Decrypt Primary Content
|
||||
const result = await ae_util.decrypt_wrapper(entry.content_encrypted, decrypt_key);
|
||||
|
||||
if (result === false) {
|
||||
console.error('decrypt_journal_entry: Decryption wrapper returned false.');
|
||||
return {
|
||||
success: false,
|
||||
error: 'Decryption failed. Incorrect passcode or corrupted data.'
|
||||
@@ -74,6 +81,7 @@ export async function decrypt_journal_entry(
|
||||
}
|
||||
}
|
||||
|
||||
console.log('decrypt_journal_entry: SUCCESS');
|
||||
return {
|
||||
success: true,
|
||||
content: decrypted_text,
|
||||
|
||||
Reference in New Issue
Block a user