Skip to content

Commit 3c0d0a5

Browse files
authored
#5999 Add fingerprint when rendering private backups (#6004)
* feat: add fingerprint on private key backup render * feat: escape fingerprint * test: fix failing test * test: fix failing test * test: fix failing test
1 parent 609a8b2 commit 3c0d0a5

File tree

2 files changed

+32
-6
lines changed

2 files changed

+32
-6
lines changed

extension/chrome/elements/backup.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { Url, Str } from '../../js/common/core/common.js';
1111
import { View } from '../../js/common/view.js';
1212
import { initPassphraseToggle } from '../../js/common/ui/passphrase-ui.js';
1313
import { KeyStore } from '../../js/common/platform/store/key-store.js';
14+
import { Xss } from '../../js/common/platform/xss.js';
1415

1516
View.run(
1617
class BackupView extends View {
@@ -48,10 +49,15 @@ View.run(
4849
}
4950
[this.storedPrvWithMatchingLongid] = await KeyStore.get(this.acctEmail, [fingerprint]);
5051
if (this.storedPrvWithMatchingLongid) {
51-
$('.line .private_key_status').text('This Private Key is already imported.');
52+
$('.line .private_key_status').html(
53+
`This private key with fingerprint <span class="green">${Xss.escape(Str.spaced(fingerprint))}</span> has already been imported.`
54+
);
5255
} else {
5356
$('.line .private_key_status')
54-
.text('This private key was not imported yet. We suggest to import all backups so that you can read all incoming encrypted emails.')
57+
.html(
58+
`The private key <span class="green">${Xss.escape(Str.spaced(fingerprint))}</span> has not been imported yet. \n` +
59+
`We recommend importing all backups to ensure you can read all incoming encrypted emails.`
60+
)
5561
.after('<div class="line"><button class="button green" id="action_import_key">Import Missing Private Key</button></div>'); // xss-direct
5662
}
5763
this.sendResizeMsg();

test/source/tests/decrypt.ts

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,21 @@ export const defineDecryptTests = (testVariant: TestVariant, testWithBrowser: Te
7272
const { acctEmail, authHdr } = await BrowserRecipe.setupCommonAcctWithAttester(t, browser, 'compatibility');
7373
const inboxPage = await browser.newExtensionPage(t, `chrome/settings/inbox/inbox.htm?acctEmail=${acctEmail}&threadId=${threadId}`);
7474
await inboxPage.waitForSelTestState('ready');
75-
await (await inboxPage.getFrame(['backup.htm'])).waitForContent('@private-key-status', 'This Private Key is already imported.');
75+
await (
76+
await inboxPage.getFrame(['backup.htm'])
77+
).waitForContent(
78+
'@private-key-status',
79+
'This private key with fingerprint 5520 CACE 2CB6 1EA7 13E5 B005 7FDE 6855 48AE A788 has already been imported.'
80+
);
7681
await inboxPage.close();
7782
const gmailPage = await browser.newPage(t, `${t.context.urls?.mockGmailUrl()}/${threadId}`, undefined, authHdr);
7883
await gmailPage.waitAll('iframe');
79-
await (await gmailPage.getFrame(['backup.htm'])).waitForContent('@private-key-status', 'This Private Key is already imported.');
84+
await (
85+
await gmailPage.getFrame(['backup.htm'])
86+
).waitForContent(
87+
'@private-key-status',
88+
'This private key with fingerprint 5520 CACE 2CB6 1EA7 13E5 B005 7FDE 6855 48AE A788 has already been imported.'
89+
);
8090
await gmailPage.close();
8191
})
8292
);
@@ -88,11 +98,21 @@ export const defineDecryptTests = (testVariant: TestVariant, testWithBrowser: Te
8898
const { acctEmail, authHdr } = await BrowserRecipe.setupCommonAcctWithAttester(t, browser, 'compatibility');
8999
const inboxPage = await browser.newExtensionPage(t, `chrome/settings/inbox/inbox.htm?acctEmail=${acctEmail}&threadId=${threadId}`);
90100
await inboxPage.waitForSelTestState('ready');
91-
await (await inboxPage.getFrame(['backup.htm'])).waitForContent('@private-key-status', 'This Private Key is already imported.');
101+
await (
102+
await inboxPage.getFrame(['backup.htm'])
103+
).waitForContent(
104+
'@private-key-status',
105+
'This private key with fingerprint E8F0 517B A6D7 DAB6 081C 96E4 ADAC 279C 9509 3207 has already been imported.'
106+
);
92107
await inboxPage.close();
93108
const gmailPage = await browser.newPage(t, `${t.context.urls?.mockGmailUrl()}/${threadId}`, undefined, authHdr);
94109
await gmailPage.waitAll('iframe');
95-
await (await gmailPage.getFrame(['backup.htm'])).waitForContent('@private-key-status', 'This Private Key is already imported.');
110+
await (
111+
await gmailPage.getFrame(['backup.htm'])
112+
).waitForContent(
113+
'@private-key-status',
114+
'This private key with fingerprint E8F0 517B A6D7 DAB6 081C 96E4 ADAC 279C 9509 3207 has already been imported.'
115+
);
96116
await gmailPage.close();
97117
})
98118
);

0 commit comments

Comments
 (0)