Fix Windows taskbar shortcut icon
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
+1
-1
@@ -8,7 +8,7 @@ This project has a layered architecture: a desktop Electron shell, a browser-ren
|
|||||||
|
|
||||||
- `desktop/main.cjs` is the privileged process.
|
- `desktop/main.cjs` is the privileged process.
|
||||||
- It owns account storage, mail sync, IMAP/SMTP connectivity, DAV sync, and OpenPGP key handling.
|
- It owns account storage, mail sync, IMAP/SMTP connectivity, DAV sync, and OpenPGP key handling.
|
||||||
- It can show native dialogs, notifications, and system prompts. On Windows, its notification-area tray icon uses the packaged multi-resolution application icon and provides Open and Quit actions.
|
- It can show native dialogs, notifications, and system prompts. On Windows, its notification-area tray icon uses the packaged multi-resolution application icon and provides Open and Quit actions. Packaged startup repairs an existing per-user Start Menu shortcut to target the launched app and use its icon, keeping taskbar pins associated with the matching AppUserModelID.
|
||||||
- `desktop/preload.cjs` exposes a minimal API to the renderer through `window.daybreakMail` and `window.pgpPrepareSend`.
|
- `desktop/preload.cjs` exposes a minimal API to the renderer through `window.daybreakMail` and `window.pgpPrepareSend`.
|
||||||
|
|
||||||
### Renderer UI
|
### Renderer UI
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ The Electron app runs in its own window. On Windows, ep-mail also shows its icon
|
|||||||
|
|
||||||
The `.github/workflows/desktop-build.yml` workflow builds both Windows and Linux artifacts on their native GitHub-hosted runners when manually started from the Actions tab. Snoozed messages return to their original mailbox with a reminder; desktop reminders are checked while the app is running, and Android uses its periodic background worker.
|
The `.github/workflows/desktop-build.yml` workflow builds both Windows and Linux artifacts on their native GitHub-hosted runners when manually started from the Actions tab. Snoozed messages return to their original mailbox with a reminder; desktop reminders are checked while the app is running, and Android uses its periodic background worker.
|
||||||
|
|
||||||
|
On packaged Windows builds, startup repairs an existing per-user Start Menu shortcut to point to the launched installed or portable executable and use its icon and AppUserModelID. Windows may keep a cached icon for an existing taskbar pin; if so, unpin and pin ep-mail again after launching the updated build.
|
||||||
|
|
||||||
See the project architecture overview in [ARCHITECTURE.md](./ARCHITECTURE.md).
|
See the project architecture overview in [ARCHITECTURE.md](./ARCHITECTURE.md).
|
||||||
|
|
||||||
## Android app
|
## Android app
|
||||||
|
|||||||
+42
-1
@@ -1,4 +1,5 @@
|
|||||||
const { app, BrowserWindow, shell, ipcMain, safeStorage, dialog, Notification, powerMonitor, Menu, Tray, nativeImage } = require('electron');
|
const { app, BrowserWindow, shell, ipcMain, safeStorage, dialog, Notification, powerMonitor, Menu, Tray, nativeImage } = require('electron');
|
||||||
|
const fsSync = require('node:fs');
|
||||||
const path = require('node:path');
|
const path = require('node:path');
|
||||||
const fs = require('node:fs/promises');
|
const fs = require('node:fs/promises');
|
||||||
const { ImapFlow } = require('imapflow');
|
const { ImapFlow } = require('imapflow');
|
||||||
@@ -18,6 +19,7 @@ const backgroundRetryIntervalMs = 2 * 60 * 1000;
|
|||||||
const backgroundSyncConcurrency = 2;
|
const backgroundSyncConcurrency = 2;
|
||||||
const backgroundIdleConcurrency = 2;
|
const backgroundIdleConcurrency = 2;
|
||||||
const snoozeCheckIntervalMs = 30 * 1000;
|
const snoozeCheckIntervalMs = 30 * 1000;
|
||||||
|
const windowsAppUserModelId = 'studio.daybreak.mail';
|
||||||
let accountStoreQueue = Promise.resolve();
|
let accountStoreQueue = Promise.resolve();
|
||||||
let backgroundSyncInProgress = false;
|
let backgroundSyncInProgress = false;
|
||||||
let backgroundSyncRequested = false;
|
let backgroundSyncRequested = false;
|
||||||
@@ -1939,11 +1941,50 @@ function createWindowsTray() {
|
|||||||
tray.on('double-click', showMainWindow);
|
tray.on('double-click', showMainWindow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function repairWindowsStartMenuShortcut() {
|
||||||
|
if (!app.isPackaged) return;
|
||||||
|
|
||||||
|
const shortcutPath = path.join(
|
||||||
|
app.getPath('appData'),
|
||||||
|
'Microsoft',
|
||||||
|
'Windows',
|
||||||
|
'Start Menu',
|
||||||
|
'Programs',
|
||||||
|
'ep-mail.lnk'
|
||||||
|
);
|
||||||
|
if (!fsSync.existsSync(shortcutPath)) return;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const shortcut = shell.readShortcutLink(shortcutPath);
|
||||||
|
const isEpMailShortcut = path.basename(shortcut.target).toLowerCase() === 'ep-mail.exe'
|
||||||
|
|| shortcut.appUserModelId === windowsAppUserModelId;
|
||||||
|
if (!isEpMailShortcut) return;
|
||||||
|
if (shortcut.appUserModelId && shortcut.appUserModelId !== windowsAppUserModelId) return;
|
||||||
|
|
||||||
|
const portableExecutable = process.env.PORTABLE_EXECUTABLE_FILE;
|
||||||
|
const executable = portableExecutable && fsSync.existsSync(portableExecutable)
|
||||||
|
? portableExecutable
|
||||||
|
: process.execPath;
|
||||||
|
const updated = shell.writeShortcutLink(shortcutPath, 'update', {
|
||||||
|
...shortcut,
|
||||||
|
target: executable,
|
||||||
|
cwd: path.dirname(executable),
|
||||||
|
icon: executable,
|
||||||
|
iconIndex: 0,
|
||||||
|
appUserModelId: windowsAppUserModelId
|
||||||
|
});
|
||||||
|
if (!updated) throw new Error('Windows did not update the shortcut.');
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Could not repair the ep-mail Start Menu shortcut:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
app.whenReady().then(() => {
|
app.whenReady().then(() => {
|
||||||
app.setAppUserModelId('studio.daybreak.mail');
|
app.setAppUserModelId(windowsAppUserModelId);
|
||||||
if (process.platform === 'win32') {
|
if (process.platform === 'win32') {
|
||||||
windowsAppIcon = nativeImage.createFromPath(path.join(__dirname, '..', 'icon.ico'));
|
windowsAppIcon = nativeImage.createFromPath(path.join(__dirname, '..', 'icon.ico'));
|
||||||
if (windowsAppIcon.isEmpty()) throw new Error('Could not load the Windows application icon.');
|
if (windowsAppIcon.isEmpty()) throw new Error('Could not load the Windows application icon.');
|
||||||
|
repairWindowsStartMenuShortcut();
|
||||||
createWindowsTray();
|
createWindowsTray();
|
||||||
}
|
}
|
||||||
createWindow();
|
createWindow();
|
||||||
|
|||||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "ep-mail",
|
"name": "ep-mail",
|
||||||
"version": "0.3.6",
|
"version": "0.4.3",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "ep-mail",
|
"name": "ep-mail",
|
||||||
"version": "0.3.6",
|
"version": "0.4.3",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@capacitor/android": "^8.5.2",
|
"@capacitor/android": "^8.5.2",
|
||||||
"@capacitor/core": "^8.5.2",
|
"@capacitor/core": "^8.5.2",
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ep-mail",
|
"name": "ep-mail",
|
||||||
"version": "0.3.6",
|
"version": "0.4.3",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "Eternity Project mail client",
|
"description": "Eternity Project mail client",
|
||||||
"author": "Eternity Project",
|
"author": "Eternity Project",
|
||||||
|
|||||||
+226
@@ -7,9 +7,27 @@ function openEncryptionKeys() {
|
|||||||
root.innerHTML = `<div class="modal-overlay"><div class="compose-modal attachments-modal"><div class="modal-head"><span>Encryption keys</span><button class="modal-close" aria-label="Close">×</button></div><div class="compose-fields">
|
root.innerHTML = `<div class="modal-overlay"><div class="compose-modal attachments-modal"><div class="modal-head"><span>Encryption keys</span><button class="modal-close" aria-label="Close">×</button></div><div class="compose-fields">
|
||||||
<p class="account-note">OpenPGP keys are protected by a passphrase and stored encrypted by your operating system. Back up your private key and revocation certificate: without them, encrypted mail cannot be recovered. Contact keys below are used to encrypt mail to your correspondents and to check signatures.</p>
|
<p class="account-note">OpenPGP keys are protected by a passphrase and stored encrypted by your operating system. Back up your private key and revocation certificate: without them, encrypted mail cannot be recovered. Contact keys below are used to encrypt mail to your correspondents and to check signatures.</p>
|
||||||
<div id="pgp-key-list" class="attachment-list">Loading keys…</div>
|
<div id="pgp-key-list" class="attachment-list">Loading keys…</div>
|
||||||
|
<h3 class="pgp-heading">Change a key passphrase</h3>
|
||||||
|
<label class="compose-line"><span>Current passphrase</span><input id="pgp-change-current-passphrase" type="password" autocomplete="current-password"></label>
|
||||||
|
<label class="compose-line"><span>New passphrase</span><input id="pgp-new-passphrase" type="password" autocomplete="new-password" placeholder="At least 8 characters"></label>
|
||||||
|
<label class="compose-line"><span>Confirm new passphrase</span><input id="pgp-confirm-passphrase" type="password" autocomplete="new-password" placeholder="Enter the new passphrase again"></label>
|
||||||
|
<p class="account-note">Select Change passphrase on a key below. Its public key and revocation certificate will not change.</p>
|
||||||
<h3 class="pgp-heading">Contact public keys</h3>
|
<h3 class="pgp-heading">Contact public keys</h3>
|
||||||
<div id="pgp-contact-list" class="attachment-list">Loading contacts…</div>
|
<div id="pgp-contact-list" class="attachment-list">Loading contacts…</div>
|
||||||
<div class="pgp-actions"><button class="discard" id="pgp-add-contact">Import public key…</button></div>
|
<div class="pgp-actions"><button class="discard" id="pgp-add-contact">Import public key…</button></div>
|
||||||
|
<h3 class="pgp-heading">Public key servers</h3>
|
||||||
|
<p class="account-note">Servers are disabled by default. Enable the servers you want to use; searching checks every enabled server, which can learn which email address you searched for. Discovered keys remain unverified until you check their fingerprints independently.</p>
|
||||||
|
<div id="pgp-server-list" class="attachment-list">Loading key servers…</div>
|
||||||
|
<label class="compose-line"><span>Email address</span><input id="pgp-search-email" type="email" value="${esc(account.email || '')}"></label>
|
||||||
|
<div class="pgp-actions"><button class="discard" id="pgp-find-key">Search all enabled servers</button></div>
|
||||||
|
<div id="pgp-found-keys" class="attachment-list"></div>
|
||||||
|
<label class="compose-line"><span>Publish to one server</span><select id="pgp-publish-server"></select></label>
|
||||||
|
<p class="account-note">Publishing targets only the selected enabled server. ep-mail names the destination and asks for native confirmation before uploading.</p>
|
||||||
|
<h4 class="pgp-heading">Add a custom HTTPS server</h4>
|
||||||
|
<label class="compose-line"><span>Name</span><input id="pgp-server-name" maxlength="60" placeholder="My key server"></label>
|
||||||
|
<label class="compose-line"><span>HTTPS base URL</span><input id="pgp-server-url" type="url" placeholder="https://keys.example.org"></label>
|
||||||
|
<label class="compose-line"><span>Protocol</span><select id="pgp-server-protocol"><option value="hkp">HKP</option><option value="vks">VKS</option></select></label>
|
||||||
|
<div class="pgp-actions"><button class="discard" id="pgp-add-server">Add custom server…</button></div>
|
||||||
<h3 class="pgp-heading">Passphrase memory</h3>
|
<h3 class="pgp-heading">Passphrase memory</h3>
|
||||||
<label class="compose-line"><span>Minutes</span><input id="pgp-cache-minutes" type="number" min="0" max="1440" step="1"></label>
|
<label class="compose-line"><span>Minutes</span><input id="pgp-cache-minutes" type="number" min="0" max="1440" step="1"></label>
|
||||||
<div class="pgp-actions"><button class="discard" id="pgp-save-cache">Save</button><button class="discard" id="pgp-forget">Forget passphrases now</button></div>
|
<div class="pgp-actions"><button class="discard" id="pgp-save-cache">Save</button><button class="discard" id="pgp-forget">Forget passphrases now</button></div>
|
||||||
@@ -26,6 +44,15 @@ function openEncryptionKeys() {
|
|||||||
root.querySelector('.modal-overlay').onclick = event => { if (event.target.classList.contains('modal-overlay')) close(); };
|
root.querySelector('.modal-overlay').onclick = event => { if (event.target.classList.contains('modal-overlay')) close(); };
|
||||||
const status = message => { $('#pgp-status').textContent = message; };
|
const status = message => { $('#pgp-status').textContent = message; };
|
||||||
const passphraseField = () => $('#pgp-passphrase');
|
const passphraseField = () => $('#pgp-passphrase');
|
||||||
|
let keyServers = [];
|
||||||
|
const selectedPublishServer = () => keyServers.find(server => server.id === $('#pgp-publish-server').value && server.enabled);
|
||||||
|
const updatePublishButtons = () => {
|
||||||
|
const server = selectedPublishServer();
|
||||||
|
$$('.pgp-publish').forEach(button => {
|
||||||
|
button.disabled = !server;
|
||||||
|
button.textContent = server ? `Publish to ${server.name}…` : 'Enable a server to publish…';
|
||||||
|
});
|
||||||
|
};
|
||||||
const needPassphrase = () => {
|
const needPassphrase = () => {
|
||||||
const value = passphraseField().value;
|
const value = passphraseField().value;
|
||||||
if (!value) { status('Enter the key passphrase in the Passphrase field first.'); passphraseField().focus(); }
|
if (!value) { status('Enter the key passphrase in the Passphrase field first.'); passphraseField().focus(); }
|
||||||
@@ -55,6 +82,44 @@ function openEncryptionKeys() {
|
|||||||
['Export public', () => window.daybreakMail.pgp.exportPublic(key.fingerprint), false],
|
['Export public', () => window.daybreakMail.pgp.exportPublic(key.fingerprint), false],
|
||||||
['Export private', () => window.daybreakMail.pgp.exportPrivate(key.fingerprint, needPassphrase()), true]
|
['Export private', () => window.daybreakMail.pgp.exportPrivate(key.fingerprint, needPassphrase()), true]
|
||||||
];
|
];
|
||||||
|
const changePassphrase = document.createElement('button');
|
||||||
|
changePassphrase.className = 'discard';
|
||||||
|
changePassphrase.textContent = 'Change passphrase…';
|
||||||
|
changePassphrase.onclick = async () => {
|
||||||
|
const currentPassphrase = $('#pgp-change-current-passphrase').value;
|
||||||
|
if (!currentPassphrase) {
|
||||||
|
status('Enter the current passphrase for this key.');
|
||||||
|
$('#pgp-change-current-passphrase').focus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const newPassphrase = $('#pgp-new-passphrase').value;
|
||||||
|
if (newPassphrase.length < 8) {
|
||||||
|
status('Use a new passphrase of at least 8 characters.');
|
||||||
|
$('#pgp-new-passphrase').focus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (newPassphrase !== $('#pgp-confirm-passphrase').value) {
|
||||||
|
status('The new passphrases do not match.');
|
||||||
|
$('#pgp-confirm-passphrase').focus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
changePassphrase.disabled = true;
|
||||||
|
try {
|
||||||
|
await window.daybreakMail.pgp.changePassphrase({
|
||||||
|
fingerprint: key.fingerprint,
|
||||||
|
currentPassphrase,
|
||||||
|
newPassphrase
|
||||||
|
});
|
||||||
|
$('#pgp-change-current-passphrase').value = '';
|
||||||
|
status(`Passphrase changed for ${key.email || key.fingerprint}.`);
|
||||||
|
} catch (error) { status(error.message || 'Could not change the key passphrase.'); }
|
||||||
|
finally {
|
||||||
|
$('#pgp-new-passphrase').value = '';
|
||||||
|
$('#pgp-confirm-passphrase').value = '';
|
||||||
|
changePassphrase.disabled = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
row.append(changePassphrase);
|
||||||
if (key.hasRevocationCertificate) actions.push(['Revocation cert.', () => window.daybreakMail.pgp.exportRevocation(key.fingerprint, needPassphrase()), true]);
|
if (key.hasRevocationCertificate) actions.push(['Revocation cert.', () => window.daybreakMail.pgp.exportRevocation(key.fingerprint, needPassphrase()), true]);
|
||||||
actions.push(['Delete', async () => {
|
actions.push(['Delete', async () => {
|
||||||
if (!confirm('Delete this key? Encrypted mail that needs it can no longer be read unless you have a backup.')) return { canceled: true };
|
if (!confirm('Delete this key? Encrypted mail that needs it can no longer be read unless you have a backup.')) return { canceled: true };
|
||||||
@@ -75,8 +140,28 @@ function openEncryptionKeys() {
|
|||||||
};
|
};
|
||||||
row.append(button);
|
row.append(button);
|
||||||
});
|
});
|
||||||
|
const publish = document.createElement('button');
|
||||||
|
publish.className = 'discard pgp-publish';
|
||||||
|
publish.onclick = async () => {
|
||||||
|
const server = selectedPublishServer();
|
||||||
|
if (!server) { status('Enable a key server and select it as the publication target first.'); return; }
|
||||||
|
publish.disabled = true;
|
||||||
|
try {
|
||||||
|
const result = await window.daybreakMail.pgp.publishKey({ fingerprint: key.fingerprint, serverId: server.id });
|
||||||
|
if (result.canceled) return;
|
||||||
|
if (result.warning) status(result.warning);
|
||||||
|
else if (result.verification === 'pending' || result.verification === 'requested') status(`Uploaded to ${server.name}. Check ${key.email || 'your email'} for a verification message before the key becomes searchable.`);
|
||||||
|
else if (result.verification === 'published') status(`The key is already published and searchable on ${server.name}.`);
|
||||||
|
else if (result.verification === 'request-failed') status('The key was uploaded, but the server could not request email verification.');
|
||||||
|
else if (result.verification === 'check-email') status(`${server.name} accepted the key. Check ${key.email || 'your email'} for its verification message. ${result.message || ''}`.trim());
|
||||||
|
else status(`${server.name} accepted the key. ${result.message || ''}`.trim());
|
||||||
|
} catch (error) { status(error.message || 'Could not publish the public key.'); }
|
||||||
|
finally { updatePublishButtons(); }
|
||||||
|
};
|
||||||
|
row.append(publish);
|
||||||
list.append(row);
|
list.append(row);
|
||||||
});
|
});
|
||||||
|
updatePublishButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#pgp-generate').onclick = async () => {
|
$('#pgp-generate').onclick = async () => {
|
||||||
@@ -166,12 +251,153 @@ function openEncryptionKeys() {
|
|||||||
await renderContacts();
|
await renderContacts();
|
||||||
} catch (error) { status(error.message || 'Could not import the key.'); }
|
} catch (error) { status(error.message || 'Could not import the key.'); }
|
||||||
};
|
};
|
||||||
|
async function renderKeyServers() {
|
||||||
|
const list = $('#pgp-server-list');
|
||||||
|
const selector = $('#pgp-publish-server');
|
||||||
|
const selectedId = selector.value;
|
||||||
|
try { keyServers = await window.daybreakMail.pgp.keyServers(); }
|
||||||
|
catch (error) { list.textContent = error.message || 'Could not load key servers.'; return; }
|
||||||
|
selector.replaceChildren();
|
||||||
|
const enabledServers = keyServers.filter(server => server.enabled);
|
||||||
|
if (!enabledServers.length) {
|
||||||
|
const option = document.createElement('option');
|
||||||
|
option.value = '';
|
||||||
|
option.textContent = 'No enabled servers';
|
||||||
|
selector.append(option);
|
||||||
|
} else enabledServers.forEach(server => {
|
||||||
|
const option = document.createElement('option');
|
||||||
|
option.value = server.id;
|
||||||
|
option.textContent = `${server.name} (${server.protocol.toUpperCase()})`;
|
||||||
|
option.selected = server.id === selectedId;
|
||||||
|
selector.append(option);
|
||||||
|
});
|
||||||
|
if (selectedId && !enabledServers.some(server => server.id === selectedId)) selector.selectedIndex = 0;
|
||||||
|
selector.onchange = updatePublishButtons;
|
||||||
|
list.replaceChildren();
|
||||||
|
keyServers.forEach(server => {
|
||||||
|
const row = document.createElement('div');
|
||||||
|
row.className = 'attachment-row';
|
||||||
|
const info = document.createElement('div');
|
||||||
|
info.className = 'attachment-row-info';
|
||||||
|
const title = document.createElement('strong');
|
||||||
|
title.textContent = server.name;
|
||||||
|
const details = document.createElement('small');
|
||||||
|
details.textContent = `${server.protocol.toUpperCase()} · ${server.url}${server.builtin ? ' · built in' : ' · custom'}`;
|
||||||
|
info.append(title, details);
|
||||||
|
const enabledLabel = document.createElement('label');
|
||||||
|
enabledLabel.className = 'compose-line';
|
||||||
|
const enabledText = document.createElement('span');
|
||||||
|
enabledText.textContent = 'Use for lookup and publishing';
|
||||||
|
const enabled = document.createElement('input');
|
||||||
|
enabled.type = 'checkbox';
|
||||||
|
enabled.checked = server.enabled;
|
||||||
|
enabled.setAttribute('aria-label', `${server.name} enabled`);
|
||||||
|
enabled.onchange = async () => {
|
||||||
|
enabled.disabled = true;
|
||||||
|
try {
|
||||||
|
await window.daybreakMail.pgp.setKeyServerEnabled(server.id, enabled.checked);
|
||||||
|
await renderKeyServers();
|
||||||
|
status(`${server.name} ${enabled.checked ? 'enabled' : 'disabled'}.`);
|
||||||
|
} catch (error) {
|
||||||
|
enabled.checked = server.enabled;
|
||||||
|
status(error.message || `Could not update ${server.name}.`);
|
||||||
|
} finally { enabled.disabled = false; }
|
||||||
|
};
|
||||||
|
enabledLabel.append(enabledText, enabled);
|
||||||
|
row.append(info, enabledLabel);
|
||||||
|
if (!server.builtin) {
|
||||||
|
const remove = document.createElement('button');
|
||||||
|
remove.className = 'discard';
|
||||||
|
remove.textContent = 'Remove';
|
||||||
|
remove.onclick = async () => {
|
||||||
|
try {
|
||||||
|
await window.daybreakMail.pgp.removeKeyServer(server.id);
|
||||||
|
await renderKeyServers();
|
||||||
|
status('Custom key server removed.');
|
||||||
|
} catch (error) { status(error.message || 'Could not remove the key server.'); }
|
||||||
|
};
|
||||||
|
row.append(remove);
|
||||||
|
}
|
||||||
|
list.append(row);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
$('#pgp-find-key').onclick = async () => {
|
||||||
|
const button = $('#pgp-find-key');
|
||||||
|
const results = $('#pgp-found-keys');
|
||||||
|
button.disabled = true;
|
||||||
|
results.textContent = 'Searching…';
|
||||||
|
try {
|
||||||
|
const found = await window.daybreakMail.pgp.findKey({
|
||||||
|
email: $('#pgp-search-email').value
|
||||||
|
});
|
||||||
|
results.replaceChildren();
|
||||||
|
found.keys.forEach(key => {
|
||||||
|
const row = document.createElement('div');
|
||||||
|
row.className = 'attachment-row';
|
||||||
|
const info = document.createElement('div');
|
||||||
|
info.className = 'attachment-row-info';
|
||||||
|
const title = document.createElement('strong');
|
||||||
|
title.textContent = key.emails.join(', ') || key.name || 'Public key';
|
||||||
|
const meta = document.createElement('small');
|
||||||
|
meta.textContent = `Found on ${key.sources.join(', ')} · not verified`;
|
||||||
|
const fingerprint = document.createElement('small');
|
||||||
|
fingerprint.textContent = `Fingerprint: ${key.fingerprint.match(/.{1,4}/g).join(' ')}`;
|
||||||
|
info.append(title, meta, fingerprint);
|
||||||
|
const add = document.createElement('button');
|
||||||
|
add.className = 'discard';
|
||||||
|
add.textContent = 'Add to contacts…';
|
||||||
|
add.onclick = async () => {
|
||||||
|
add.disabled = true;
|
||||||
|
try {
|
||||||
|
const result = await window.daybreakMail.pgp.addContact({ armoredKey: key.armoredKey, source: 'keyserver' });
|
||||||
|
if (result.canceled) return;
|
||||||
|
status(result.keyChangedFrom?.length ? 'Key added. You already had another key for this address; compare fingerprints before trusting either key.' : 'Key added as unverified. Compare its fingerprint with the owner before trusting it.');
|
||||||
|
await renderContacts();
|
||||||
|
row.remove();
|
||||||
|
} catch (error) { status(error.message || 'Could not add the public key.'); }
|
||||||
|
finally { add.disabled = false; }
|
||||||
|
};
|
||||||
|
row.append(info, add);
|
||||||
|
results.append(row);
|
||||||
|
});
|
||||||
|
found.errors.forEach(error => {
|
||||||
|
const warning = document.createElement('small');
|
||||||
|
warning.textContent = `${error.name}: ${error.message}`;
|
||||||
|
results.append(warning);
|
||||||
|
});
|
||||||
|
if (!found.keys.length && !found.errors.length) results.textContent = 'No matching public key was found on the enabled servers.';
|
||||||
|
if (found.keys.length) status(`Found ${found.keys.length} public key(s) on ${found.searchedServers.map(server => server.name).join(', ')}. They remain unverified until you check their fingerprints independently.${found.errors.length ? ` ${found.errors.length} server(s) could not be searched; see details above.` : ''}`);
|
||||||
|
else if (found.errors.length) status(`No key results; ${found.errors.length} enabled server(s) could not be searched. See details above.`);
|
||||||
|
else status(`No matching key found across ${found.searchedServers.length} enabled server(s).`);
|
||||||
|
} catch (error) {
|
||||||
|
results.textContent = '';
|
||||||
|
status(error.message || 'Could not search the key server.');
|
||||||
|
} finally { button.disabled = false; }
|
||||||
|
};
|
||||||
|
$('#pgp-add-server').onclick = async () => {
|
||||||
|
const button = $('#pgp-add-server');
|
||||||
|
button.disabled = true;
|
||||||
|
try {
|
||||||
|
const result = await window.daybreakMail.pgp.addKeyServer({
|
||||||
|
name: $('#pgp-server-name').value,
|
||||||
|
url: $('#pgp-server-url').value,
|
||||||
|
protocol: $('#pgp-server-protocol').value
|
||||||
|
});
|
||||||
|
if (result.canceled) return;
|
||||||
|
$('#pgp-server-name').value = '';
|
||||||
|
$('#pgp-server-url').value = '';
|
||||||
|
await renderKeyServers();
|
||||||
|
status('Custom key server added.');
|
||||||
|
} catch (error) { status(error.message || 'Could not add the key server.'); }
|
||||||
|
finally { button.disabled = false; }
|
||||||
|
};
|
||||||
window.daybreakMail.pgp.getSettings().then(settings => { $('#pgp-cache-minutes').value = settings.cacheMinutes; }).catch(() => {});
|
window.daybreakMail.pgp.getSettings().then(settings => { $('#pgp-cache-minutes').value = settings.cacheMinutes; }).catch(() => {});
|
||||||
$('#pgp-save-cache').onclick = async () => {
|
$('#pgp-save-cache').onclick = async () => {
|
||||||
try { const settings = await window.daybreakMail.pgp.setSettings({ cacheMinutes: Number($('#pgp-cache-minutes').value) }); status(`Passphrases are remembered for ${settings.cacheMinutes} minute(s).`); }
|
try { const settings = await window.daybreakMail.pgp.setSettings({ cacheMinutes: Number($('#pgp-cache-minutes').value) }); status(`Passphrases are remembered for ${settings.cacheMinutes} minute(s).`); }
|
||||||
catch (error) { status(error.message || 'Could not save the setting.'); }
|
catch (error) { status(error.message || 'Could not save the setting.'); }
|
||||||
};
|
};
|
||||||
$('#pgp-forget').onclick = async () => { await window.daybreakMail.pgp.forgetPassphrases(); status('Remembered passphrases were cleared.'); };
|
$('#pgp-forget').onclick = async () => { await window.daybreakMail.pgp.forgetPassphrases(); status('Remembered passphrases were cleared.'); };
|
||||||
|
void renderKeyServers();
|
||||||
void renderContacts();
|
void renderContacts();
|
||||||
void render();
|
void render();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user