Skip to content

Commit cf24357

Browse files
authored
Merge branch 'master' into issue-5667-added-message-decryption-on-thunderbird
2 parents 0dddb00 + a84810e commit cf24357

File tree

11 files changed

+254
-205
lines changed

11 files changed

+254
-205
lines changed

extension/chrome/settings/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ View.run(
509509
const fpHtml = `fingerprint:&nbsp;<span class="good">${Str.spaced(Xss.escape(ki.fingerprints[0]))}</span>`;
510510
const space = `&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`;
511511
html += `<div class="row key-content-row">`;
512-
html += ` <div class="col-12">${escapedLink} from ${Xss.escape(date)}${space}${fpHtml}${space}${removeKeyBtn}</div>`;
512+
html += ` <div class="col-12">${escapedLink} from ${Xss.escape(date)}${space}${fpHtml}${space}${KeyUtil.statusHtml(ki.id, prv)}${space}${removeKeyBtn}</div>`;
513513
html += `</div>`;
514514
}
515515
Xss.sanitizeAppend('.key_list', html);

extension/chrome/settings/modules/contacts.ts

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -143,25 +143,13 @@ View.run(
143143
for (const pubkey of contact.sortedPubkeys) {
144144
const keyid = Xss.escape(pubkey.pubkey.id);
145145
const type = Xss.escape(pubkey.pubkey.family);
146-
let keyStatus: { state: string; statusIndicator: string };
147-
if (pubkey.revoked) {
148-
keyStatus = { state: 'revoked', statusIndicator: 'light-gray' };
149-
} else if (pubkey.pubkey?.usableForEncryption) {
150-
keyStatus = { state: 'active', statusIndicator: 'green' };
151-
} else if (pubkey.pubkey?.usableForEncryptionButExpired) {
152-
keyStatus = { state: 'expired', statusIndicator: 'orange' };
153-
} else if (pubkey.pubkey?.usableForSigning) {
154-
keyStatus = { state: 'sign only', statusIndicator: 'yellow' };
155-
} else {
156-
keyStatus = { state: 'unusable', statusIndicator: 'red' };
157-
}
158146
const change = `<a href="#" title="Change" class="action_change" data-test="action-change-pubkey-${keyid}-${type}"></a>`;
159147
const remove = `<a href="#" title="Remove" class="action_remove" data-test="action-remove-pubkey-${keyid}-${type}"></a>`;
160148
const show = `<a href="#" title="Show" class="action_show" data-test="action-show-pubkey-${keyid}-${type}">${Str.spaced(keyid)}</a>`;
161149
tableContents += `<div class="contacts-pubkey" email="${e}" keyid="${keyid}" type="${type}">
162150
<div class="contacts-pubkey-info">
163151
<span class="fc-badge fc-badge-gray" data-test="container-contact-key-type-${keyid}">${type}</span>&nbsp;
164-
<span class="fc-badge fc-badge-${keyStatus.statusIndicator}" data-test="container-key-status-${keyid}">${keyStatus.state}</span>
152+
${KeyUtil.statusHtml(keyid, pubkey.pubkey)}
165153
${show}
166154
</div>
167155
<div class="contacts-pubkey-actions">${change}${remove}</div></div>`;

extension/chrome/settings/modules/my_key.htm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<title>FlowCrypt</title>
88
<link rel="stylesheet" href="/css/cryptup.css" />
99
<link rel="stylesheet" href="/css/sweetalert2.css" />
10+
<link rel="stylesheet" href="/css/settings.css" />
1011
<link rel="stylesheet" href="/css/open-sans.css" />
1112
<link rel="stylesheet" href="/css/animate.css" />
1213
<link rel="stylesheet" href="/css/mobile-menu-styling.css" />
@@ -32,6 +33,8 @@
3233
<a href="#" class="action_download_pubkey">Save public key to a file</a>
3334
</div>
3435
<div class="line show_when_showing_public pubkey_link_container" style="display: none">Share your public key: <a href="" target="_blank"></a></div>
36+
<div class="line key_status_contatiner"></div>
37+
<div class="line">Key creation: <span class="key_creation" data-test="content-key-creation"></span></div>
3538
<div class="line">Key expiration: <span class="key_expiration" data-test="content-key-expiration"></span></div>
3639
<div class="line-separator"></div>
3740
<div class="line">

extension/chrome/settings/modules/my_key.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ View.run(
5555
$('.fingerprint').text(Str.spaced(this.keyInfo.fingerprints[0]));
5656
Xss.sanitizeRender('.email', this.pubKey.emails.map(email => `<span>${Xss.escape(email)}</span>`).join(', '));
5757
const expiration = this.pubKey.expiration;
58+
const creation = Str.datetimeToDate(Str.fromDate(new Date(this.pubKey.created)));
59+
Xss.sanitizeRender('.key_status_contatiner', KeyUtil.statusHtml(this.keyInfo.longid, this.pubKey));
60+
$('.key_creation').text(creation);
5861
$('.key_expiration').text(expiration && expiration !== Infinity ? Str.datetimeToDate(Str.fromDate(new Date(expiration))) : 'Does not expire');
5962
this.renderPrivateKeyLink();
6063
await this.renderPubkeyShareableLink();

extension/js/common/core/crypto/key.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ import { EmailParts, Str } from '../common.js';
2020
* all dates are expressed as number of milliseconds since Unix Epoch.
2121
* This is what `Date.now()` returns and `new Date(x)` accepts.
2222
*/
23+
24+
type KeyStatus = {
25+
state: 'active' | 'revoked' | 'expired' | 'sign only' | 'unusable';
26+
statusIndicator: 'light-gray' | 'green' | 'orange' | 'yellow' | 'red';
27+
};
28+
2329
export interface Key extends KeyIdentity {
2430
allIds: string[]; // a list of fingerprints, including those for subkeys
2531
created: number;
@@ -307,6 +313,30 @@ export class KeyUtil {
307313
return Date.now() > exp;
308314
}
309315

316+
public static status(key: Key | undefined): KeyStatus {
317+
if (!key) {
318+
return { state: 'unusable', statusIndicator: 'red' };
319+
}
320+
let keyStatus: KeyStatus;
321+
if (key.revoked) {
322+
keyStatus = { state: 'revoked', statusIndicator: 'light-gray' };
323+
} else if (key.usableForEncryption) {
324+
keyStatus = { state: 'active', statusIndicator: 'green' };
325+
} else if (key.usableForEncryptionButExpired) {
326+
keyStatus = { state: 'expired', statusIndicator: 'orange' };
327+
} else if (key.usableForSigning) {
328+
keyStatus = { state: 'sign only', statusIndicator: 'yellow' };
329+
} else {
330+
keyStatus = { state: 'unusable', statusIndicator: 'red' };
331+
}
332+
return keyStatus;
333+
}
334+
335+
public static statusHtml(keyid: string, key: Key | undefined): string {
336+
const keyStatus = KeyUtil.status(key);
337+
return `<span class="fc-badge fc-badge-${keyStatus.statusIndicator}" data-test="container-key-status-${keyid}">${keyStatus.state}</span>`;
338+
}
339+
310340
public static dateBeforeExpirationIfAlreadyExpired(key: Key): Date | undefined {
311341
const expiration = key.expiration;
312342
return expiration && KeyUtil.expired(key) ? new Date(expiration - 1000) : undefined;

0 commit comments

Comments
 (0)