Skip to content

Commit

Permalink
Include default generated passphrase when none is specified.
Browse files Browse the repository at this point in the history
  • Loading branch information
wparad committed Apr 4, 2024
1 parent fe02ebb commit b859572
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/components/vanishingKeys.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,13 @@ async function handleClick(event) {
}

const secret = this.shadowRoot.getElementById('secret').value;
const passphrase = this.shadowRoot.getElementById('passphrase').value;
const includePassphrase = this.shadowRoot.getElementById('includePassphrase').checked || !passphrase;
const specifiedPassphrase = this.shadowRoot.getElementById('passphrase').value;
const includePassphrase = this.shadowRoot.getElementById('includePassphrase').checked || !specifiedPassphrase;

// This is not base32 but instead base32hex: https://datatracker.ietf.org/doc/html/rfc4648#section-7
const base32hexMap = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ23456789';
const fallbackPassphrase = [...(window.crypto || window.msCrypto).getRandomValues(new Uint8Array(24))].map(val => base32hexMap[val % 32]).join('');
const passphrase = specifiedPassphrase || fallbackPassphrase;

const result = await encryptionManager.generateLink(secret, passphrase, includePassphrase, lifetime);
if (!result) {
Expand Down

0 comments on commit b859572

Please sign in to comment.