Skip to content

Commit 8a0de27

Browse files
authored
QR scan encryption fix (#398)
QR scan encryption fix
2 parents 0109cb5 + 975a668 commit 8a0de27

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/background.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,13 @@ async function getTotp(text: string) {
204204
if (period) {
205205
entryData[hash].period = period;
206206
}
207+
if (
208+
(await EntryStorage.hasEncryptedEntry()) !==
209+
encryption.getEncryptionStatus()
210+
) {
211+
chrome.tabs.sendMessage(id, { action: "errorenc" });
212+
return;
213+
}
207214
await EntryStorage.import(encryption, entryData);
208215
chrome.tabs.sendMessage(id, { action: "added", account });
209216
}
@@ -410,6 +417,10 @@ function setAutolock() {
410417
document.cookie = `passphrase="${getCachedPassphrase()}${getCookieExpiry()}"`;
411418
autolockTimeout = setTimeout(() => {
412419
cachedPassphrase = "";
420+
const id = contentTab.id;
421+
if (id) {
422+
chrome.tabs.sendMessage(id, { action: "stopCapture" });
423+
}
413424
}, Number(localStorage.autolock) * 60000);
414425
}
415426
}

src/content.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ if (!document.getElementById("__ga_grayLayout__")) {
1414
case "errorqr":
1515
alert(chrome.i18n.getMessage("errorqr"));
1616
break;
17+
case "errorenc":
18+
alert(chrome.i18n.getMessage("phrase_incorrect"));
19+
break;
1720
case "added":
1821
alert(message.account + chrome.i18n.getMessage("added"));
1922
break;
@@ -23,6 +26,17 @@ if (!document.getElementById("__ga_grayLayout__")) {
2326
case "pastecode":
2427
pasteCode(message.code);
2528
break;
29+
case "stopCapture":
30+
const captureBox = document.getElementById("__ga_captureBox__");
31+
if (captureBox) {
32+
captureBox.style.display = "none";
33+
}
34+
35+
const grayLayout = document.getElementById("__ga_grayLayout__");
36+
if (grayLayout) {
37+
grayLayout.style.display = "none";
38+
}
39+
break;
2640
default:
2741
// invalid command, ignore it
2842
break;

0 commit comments

Comments
 (0)