Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions extension/js/common/core/crypto/key.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,8 @@ export class KeyUtil {
const opgpresult = await OpenPGPKey.diagnose(key, passphrase);
result = new Map<string, string>([...result, ...opgpresult]);
}
result.set(`expiration`, KeyUtil.formatResult(key.expiration));
const expirationIso = key.expiration ? new Date(key.expiration).toISOString() : undefined;
result.set(`expiration`, KeyUtil.formatResult(expirationIso));
result.set(`internal dateBeforeExpiration`, await KeyUtil.formatResultAsync(async () => KeyUtil.dateBeforeExpirationIfAlreadyExpired(key)));
result.set(`internal usableForEncryption`, KeyUtil.formatResult(key.usableForEncryption));
result.set(`internal usableForSigning`, KeyUtil.formatResult(key.usableForSigning));
Expand All @@ -292,8 +293,9 @@ export class KeyUtil {
}
}

public static formatResult(value: unknown): string {
return `[-] ${String(value)}`;
public static formatResult(value: unknown | undefined): string {
const formattedOutput = value !== undefined ? (value as string) : '-';
return `[-] ${formattedOutput}`;
}

public static async asPublicKey(key: Key): Promise<Key> {
Expand Down
20 changes: 10 additions & 10 deletions test/source/tests/unit-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1638,8 +1638,8 @@ ZAvn6PBX7vsaReOVa2zsnuY5g70xCxvzHIwR94POu5cENwRtCkrppFnISALpQ1kA
expect(result.get('SK 0 > SIG 0 > Sig creation time')).to.equal('[-] 1606140328 or 2020-11-23T14:05:28.000Z');
expect(result.get('SK 0 > SIG 0 > Sig expiration time')).to.equal('[-] -');
expect(result.get('SK 0 > SIG 0 > Verify')).to.equal('[-] valid');
expect(result.get('expiration')).to.equal('[-] undefined');
expect(result.get('internal dateBeforeExpiration')).to.equal('[-] undefined');
expect(result.get('expiration')).to.equal('[-] -');
expect(result.get('internal dateBeforeExpiration')).to.equal('[-] -');
expect(result.get('internal usableForEncryptionButExpired')).to.equal('[-] false');
expect(result.get('internal usableForSigningButExpired')).to.equal('[-] false');
t.pass();
Expand Down Expand Up @@ -1676,8 +1676,8 @@ ZAvn6PBX7vsaReOVa2zsnuY5g70xCxvzHIwR94POu5cENwRtCkrppFnISALpQ1kA
expect(result.get('SK 0 > SIG 0 > Sig creation time')).to.equal('[-] 1606140328 or 2020-11-23T14:05:28.000Z');
expect(result.get('SK 0 > SIG 0 > Sig expiration time')).to.equal('[-] -');
expect(result.get('SK 0 > SIG 0 > Verify')).to.equal('[-] valid');
expect(result.get('expiration')).to.equal('[-] undefined');
expect(result.get('internal dateBeforeExpiration')).to.equal('[-] undefined');
expect(result.get('expiration')).to.equal('[-] -');
expect(result.get('internal dateBeforeExpiration')).to.equal('[-] -');
expect(result.get('internal usableForEncryptionButExpired')).to.equal('[-] false');
expect(result.get('internal usableForSigningButExpired')).to.equal('[-] false');
t.pass();
Expand Down Expand Up @@ -1983,8 +1983,8 @@ jA==
expect(result.get('SK 0 > SIG 0 > Sig creation time')).to.equal('[-] 1606140328 or 2020-11-23T14:05:28.000Z');
expect(result.get('SK 0 > SIG 0 > Sig expiration time')).to.equal('[-] -');
expect(result.get('SK 0 > SIG 0 > Verify')).to.equal('[-] valid');
expect(result.get('expiration')).to.equal('[-] undefined');
expect(result.get('internal dateBeforeExpiration')).to.equal('[-] undefined');
expect(result.get('expiration')).to.equal('[-] -');
expect(result.get('internal dateBeforeExpiration')).to.equal('[-] -');
expect(result.get('internal usableForEncryptionButExpired')).to.equal('[-] false');
expect(result.get('internal usableForSigningButExpired')).to.equal('[-] false');
t.pass();
Expand Down Expand Up @@ -2022,8 +2022,8 @@ jA==
expect(result.get('SK 0 > SIG 0 > Sig creation time')).to.equal('[-] 1611140947 or 2021-01-20T11:09:07.000Z');
expect(result.get('SK 0 > SIG 0 > Sig expiration time')).to.equal('[-] -');
expect(result.get('SK 0 > SIG 0 > Verify')).to.equal('[-] valid');
expect(result.get('expiration')).to.equal('[-] undefined');
expect(result.get('internal dateBeforeExpiration')).to.equal('[-] undefined');
expect(result.get('expiration')).to.equal('[-] -');
expect(result.get('internal dateBeforeExpiration')).to.equal('[-] -');
expect(result.get('internal usableForEncryptionButExpired')).to.equal('[-] false');
expect(result.get('internal usableForSigningButExpired')).to.equal('[-] false');
t.pass();
Expand Down Expand Up @@ -2059,8 +2059,8 @@ jA==
expect(result.get('SK 0 > SIG 0 > Sig creation time')).to.equal('[-] 1611500699 or 2021-01-24T15:04:59.000Z');
expect(result.get('SK 0 > SIG 0 > Sig expiration time')).to.equal('[-] -');
expect(result.get('SK 0 > SIG 0 > Verify')).to.equal('[-] valid');
expect(result.get('expiration')).to.equal('[-] undefined');
expect(result.get('internal dateBeforeExpiration')).to.equal('[-] undefined');
expect(result.get('expiration')).to.equal('[-] -');
expect(result.get('internal dateBeforeExpiration')).to.equal('[-] -');
expect(result.get('internal usableForEncryptionButExpired')).to.equal('[-] false');
expect(result.get('internal usableForSigningButExpired')).to.equal('[-] false');
t.pass();
Expand Down