+
{#if data.paste}
+ >
+ {decryptStatus || 'Loading...'}
+
diff --git a/SharpbinV3.Client/src/routes/[id]/+page.svelte b/SharpbinV3.Client/src/routes/[id]/+page.svelte index 1bbf751..bf2be71 100644 --- a/SharpbinV3.Client/src/routes/[id]/+page.svelte +++ b/SharpbinV3.Client/src/routes/[id]/+page.svelte @@ -52,6 +52,7 @@ let pasteContent = ''; let decryptedContent: string | null = null; let decryptError = ''; + let decryptStatus = ''; let contentRendered = false; let downloadedPaste = false; let copiedPaste = false; @@ -132,6 +133,7 @@ isBinary = isBinaryData(buffer); if (isBinary) { contentRendered = true; + decryptStatus = ''; return; } @@ -159,6 +161,7 @@ const wrapped = `
${highlighted}`;
pasteContent = addLineNumbers(wrapped);
contentRendered = true;
+ decryptStatus = '';
}
async function updatePaste(content: string | null, metadata: Paste | null) {
@@ -278,39 +281,53 @@
try {
if (data?.paste && data.paste.visibility === 2) {
contentRendered = false;
+ decryptStatus = 'Preparing decryption...';
const urlHash = window.location.hash.slice(1);
if (urlHash) {
const passwordFromUrl = atob(urlHash);
+ decryptStatus = 'Deriving key...';
decryptedContent = await decryptAES(data.content, passwordFromUrl);
if (decryptedContent === null) {
+ decryptStatus = 'Waiting for password...';
const password = await promptUser('decrypt');
if (password) {
+ decryptStatus = 'Deriving key...';
decryptedContent = await decryptAES(data.content, password);
if (decryptedContent === null) {
decryptError = 'Incorrect password. Please try again.';
+ decryptStatus = 'Decryption failed.';
} else {
renderCode();
history.replaceState(null, '', window.location.pathname + window.location.search);
}
+ } else {
+ decryptStatus = 'Decryption canceled.';
}
} else {
renderCode();
}
return;
}
+ decryptStatus = 'Waiting for password...';
const password = await promptUser('decrypt');
if (password) {
+ decryptStatus = 'Deriving key...';
decryptedContent = await decryptAES(data.content, password);
if (decryptedContent === null) {
decryptError = 'Incorrect password. Please try again.';
+ decryptStatus = 'Decryption failed.';
} else {
renderCode();
}
+ } else {
+ decryptStatus = 'Decryption canceled.';
}
} else {
+ decryptStatus = 'Rendering content...';
renderCode();
}
} catch {
+ decryptStatus = 'Rendering content...';
renderCode();
}
});
@@ -359,9 +376,9 @@