Compare commits
6
Commits
acba5d641e
...
V0.4.4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e5391dbb62 | ||
|
|
115e29640e | ||
|
|
2a23f4d40e | ||
|
|
959658c400 | ||
|
|
2068e3f32b | ||
|
|
5cd8d545e9 |
@@ -1,3 +1,4 @@
|
|||||||
node_modules/
|
node_modules/
|
||||||
release/
|
release/
|
||||||
dist/
|
dist/
|
||||||
|
android/local.properties
|
||||||
|
|||||||
+8
-7
@@ -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.
|
- 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
|
||||||
@@ -17,7 +17,7 @@ The browser UI is rendered from the web assets in the root and `www/` folders:
|
|||||||
|
|
||||||
- `index.html` and the shared shell files define the layout and global state.
|
- `index.html` and the shared shell files define the layout and global state.
|
||||||
- `app.js`, `mail-ui.js`, `account-ui.js`, `dav-ui.js`, `pgp-ui.js`, and `pgp-mail-ui.js` handle page flow, compose/read views, account setup, and encryption UX.
|
- `app.js`, `mail-ui.js`, `account-ui.js`, `dav-ui.js`, `pgp-ui.js`, and `pgp-mail-ui.js` handle page flow, compose/read views, account setup, and encryption UX.
|
||||||
- The renderer is intentionally thin: it requests actions and displays data, but the actual cryptographic and network work stays in the main process.
|
- The renderer is intentionally thin: it requests actions and displays data, while mail-protocol and cryptographic network work stays in the main process. The reader makes direct HTTPS image requests only after explicit per-message approval.
|
||||||
|
|
||||||
### Android client
|
### Android client
|
||||||
|
|
||||||
@@ -54,11 +54,11 @@ A generation counter invalidates stale sync jobs when accounts are edited or rem
|
|||||||
|
|
||||||
The send flow is also centralized in the main process:
|
The send flow is also centralized in the main process:
|
||||||
|
|
||||||
- the renderer calls `mail:send`
|
- the renderer calls the desktop `mail:send` IPC or the Android `EpMail.send` plugin with message fields and selected attachment bytes
|
||||||
- the main process resolves the account, checks the sender settings, and applies OpenPGP encryption/signing before sending
|
- the native send path resolves the account, checks sender settings, builds multipart MIME, and on desktop applies OpenPGP encryption/signing to the body and attachments before sending
|
||||||
- the message is either transmitted immediately or queued as an offline send when connectivity is unavailable
|
- the message is either transmitted immediately or queued as an offline send when connectivity is unavailable; local draft attachments are persisted with draft content
|
||||||
|
|
||||||
This prevents the renderer from silently bypassing critical security checks or storing plaintext in outbox data.
|
The renderer sends file bytes rather than local paths. OpenPGP messages are encrypted before offline queueing so the outbox contains ciphertext instead of plaintext message or attachment content.
|
||||||
|
|
||||||
## 3. Security boundary
|
## 3. Security boundary
|
||||||
|
|
||||||
@@ -73,6 +73,7 @@ This boundary is important for encryption and safety checks:
|
|||||||
- Key-server lookup results never elevate trust; only the public key is sent during a separately confirmed publication.
|
- Key-server lookup results never elevate trust; only the public key is sent during a separately confirmed publication.
|
||||||
- Send-time downgrade checks happen in the main process rather than only in UI logic.
|
- Send-time downgrade checks happen in the main process rather than only in UI logic.
|
||||||
- External links open only after a native confirmation dialog.
|
- External links open only after a native confirmation dialog.
|
||||||
|
- Incoming HTML is sanitized in the renderer before insertion. HTTPS image URLs are kept in inert data attributes; only a per-message user action assigns image sources, and reopening the message resets that approval. HTTP images are rejected to preserve Android's cleartext-traffic protection. The CSP allows HTTPS images; scripts, frames, forms, and remote connections remain blocked.
|
||||||
- Credentials and private keys are stored with the OS keyring, not in plain JSON files.
|
- Credentials and private keys are stored with the OS keyring, not in plain JSON files.
|
||||||
|
|
||||||
## 4. OpenPGP subsystem
|
## 4. OpenPGP subsystem
|
||||||
@@ -91,7 +92,7 @@ Key-server enablement is persisted in encrypted OpenPGP settings; all servers de
|
|||||||
## 5. Data flow patterns
|
## 5. Data flow patterns
|
||||||
|
|
||||||
- Account setup and edits flow from the UI into IPC, then into the encrypted main-process storage.
|
- Account setup and edits flow from the UI into IPC, then into the encrypted main-process storage.
|
||||||
- Mail content is fetched by the main process and served to the renderer in a sanitized, parsed form.
|
- Mail content is fetched by the native mail service and passed to the renderer as plain text, bounded HTML alternatives, links, and attachment metadata. HTML is allowlist-sanitized before display; HTTPS image requests remain inert until explicitly enabled for the current message view.
|
||||||
- Attachments, decrypted bodies, and external links are all checked before user-visible actions are allowed.
|
- Attachments, decrypted bodies, and external links are all checked before user-visible actions are allowed.
|
||||||
- Search, folder listing, and draft operations reuse the same account model across both desktop and Android versions.
|
- Search, folder listing, and draft operations reuse the same account model across both desktop and Android versions.
|
||||||
|
|
||||||
|
|||||||
@@ -72,6 +72,8 @@ Decision: OpenPGP only for v1; S/MIME may follow later.
|
|||||||
- [desktop/pgp-keystore.cjs](./desktop/pgp-keystore.cjs): also stores contact public keys with trust levels (`unknown`, `trusted`, `verified`) and the passphrase-memory setting.
|
- [desktop/pgp-keystore.cjs](./desktop/pgp-keystore.cjs): also stores contact public keys with trust levels (`unknown`, `trusted`, `verified`) and the passphrase-memory setting.
|
||||||
- Encrypted messages appear in the list as "Encrypted message"; they are decrypted on demand (`pgp:decrypt-message`) and the plaintext is never cached on disk. Attachments are read from the decrypted payload.
|
- Encrypted messages appear in the list as "Encrypted message"; they are decrypted on demand (`pgp:decrypt-message`) and the plaintext is never cached on disk. Attachments are read from the decrypted payload.
|
||||||
- Compose shows Encrypt and Sign options. Encrypt turns on by default when every recipient has a key; if a key is missing the app asks before sending unencrypted. Encryption happens before the message is sent or queued offline, so passphrases and plaintext never enter the outbox. The Sent copy is also encrypted to the sender's own key.
|
- Compose shows Encrypt and Sign options. Encrypt turns on by default when every recipient has a key; if a key is missing the app asks before sending unencrypted. Encryption happens before the message is sent or queued offline, so passphrases and plaintext never enter the outbox. The Sent copy is also encrypted to the sender's own key.
|
||||||
|
- Multiple outgoing attachments are included in the OpenPGP MIME payload and encrypted/signed together with the body. Android does not yet implement OpenPGP.
|
||||||
|
- Attachment selection has no app-enforced aggregate size cap; local storage capacity and mail-provider limits still apply.
|
||||||
- A signature from a key that differs from the one on file for the sender is flagged as a changed key.
|
- A signature from a key that differs from the one on file for the sender is flagged as a changed key.
|
||||||
- Interop: [tests/pgp-gnupg-interop.test.cjs](./tests/pgp-gnupg-interop.test.cjs) runs against a real GnuPG (skipped when it is not installed).
|
- Interop: [tests/pgp-gnupg-interop.test.cjs](./tests/pgp-gnupg-interop.test.cjs) runs against a real GnuPG (skipped when it is not installed).
|
||||||
- Tests: [tests/pgp-mail.test.cjs](./tests/pgp-mail.test.cjs) (round trips, several recipients, tampering, key changes, large attachments, inline PGP).
|
- Tests: [tests/pgp-mail.test.cjs](./tests/pgp-mail.test.cjs) (round trips, several recipients, tampering, key changes, large attachments, inline PGP).
|
||||||
|
|||||||
@@ -4,10 +4,12 @@ An Eternity Project mail client with **Eternity Daylight**, **Wasteland**, and E
|
|||||||
|
|
||||||
## Desktop app
|
## Desktop app
|
||||||
|
|
||||||
The Electron app runs in its own window. With Node.js installed, run `npm install` and then `npm start`. Open **Mail account settings** to connect an IMAP/SMTP account. Each account can have its own outgoing signature, new-mail notification toggle, periodic sync interval (2–60 minutes; IDLE remains event-driven), and mail rules. Rules match incoming Inbox messages by sender and/or subject; the first matching rule archives, moves to Inbox/Archive/Trash, applies a label, or flags the message. Sender/domain and extracted message-link checks highlight selected phishing warning signs. Message links are shown separately from the body and require explicit confirmation before opening in a browser; the app never renders remote message HTML. Settings, cached recent messages, offline drafts, and queued mail operations are stored with the encrypted account credentials. Search supports text, sender, subject, date range, attachment, and folder filters; a filtered online search scans up to the newest 5,000 messages in the selected folder. When offline, the app can read cached messages, save drafts, and queue supported message actions and sends for retry on the next successful sync. The app uses required STARTTLS for IMAP port 143 and SMTP port 587. Before preparing a new release, bump the version once with `npm run bump:build`; then build all platform targets for that same version. To package it on Windows, run `npm run dist:win`; the installer and portable `.exe` are written to `release/`. To package on Linux, run `npm install` and `npm run dist:linux` on a Linux machine; this produces AppImage and Debian packages in `release/`.
|
The Electron app runs in its own window. On Windows, ep-mail also shows its icon in the notification area beside the clock; click it to open the app, or right-click for Open and Quit. With Node.js installed, run `npm install` and then `npm start`. Open **Mail account settings** to connect an IMAP/SMTP account. Each account can have its own outgoing signature, new-mail notification toggle, periodic sync interval (2–60 minutes; IDLE remains event-driven), and mail rules. Rules match incoming Inbox messages by sender and/or subject; the first matching rule archives, moves to Inbox/Archive/Trash, applies a label, or flags the message. Sender/domain and extracted message-link checks highlight selected phishing warning signs. Message links are shown separately from the body and require explicit confirmation before opening in a browser. On desktop and Android, incoming HTML is sanitized before display; external HTTPS images stay blocked until you explicitly load them for that message. Loading remote images can disclose your network address and message-open timing to their hosts. Settings, cached recent messages, offline drafts, and queued mail operations are stored with the encrypted account credentials. Search supports text, sender, subject, date range, attachment, and folder filters; a filtered online search scans up to the newest 5,000 messages in the selected folder. When offline, the app can read cached messages, save drafts, and queue supported message actions and sends for retry on the next successful sync. The app uses required STARTTLS for IMAP port 143 and SMTP port 587. Before preparing a new release, bump the version once with `npm run bump:build`; then build all platform targets for that same version. To package it on Windows, run `npm run dist:win`; the installer and portable `.exe` are written to `release/`. Windows builds use the app icon for the executable, window, and shortcuts. If Windows continues showing an old icon for an existing taskbar pin, unpin ep-mail, install or launch the updated build, then pin it again from the updated shortcut. To package on Linux, run `npm install` and `npm run dist:linux` on a Linux machine; this produces AppImage and Debian packages in `release/`.
|
||||||
|
|
||||||
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
|
||||||
@@ -33,4 +35,4 @@ On Windows, `py -m http.server 8000` is also available on many Python installati
|
|||||||
|
|
||||||
## Current scope
|
## Current scope
|
||||||
|
|
||||||
Mail supports multiple IMAP/SMTP accounts, switching between them, and saving message attachments. CalDAV and CardDAV servers can be added from the Calendar and Contacts views; credentials are kept in the OS-encrypted credential store, and events and contacts can sync and be edited on the server. Local contacts and events remain available without a DAV connection. Your display name is saved locally and appears in the greeting. Use the **+** beside **Folders** in the sidebar to create IMAP folders on the server; your custom folders appear in the sidebar and can be opened like any other folder. Keyboard shortcuts for compose, search, refresh, archive, delete, star, reply, forward, and message navigation can be changed in **Settings**. Attachments can be previewed (images and text) in the reader, and the **Attachments** view in the sidebar lists, searches, filters by type, previews and downloads attachments across Inbox, Sent, Archive and Trash. On desktop, **Settings → Encryption keys** creates, imports and exports passphrase-protected OpenPGP keys stored encrypted by the operating system; you can import contact keys, enable selected key servers (all are disabled initially), search all enabled servers, and publish a key to one explicitly selected server after a native confirmation names the destination. Discovered keys remain unverified until you compare fingerprints independently. Desktop can read encrypted or signed OpenPGP mail and encrypt or sign outgoing messages (see [ENCRYPTION_PLAN.md](./ENCRYPTION_PLAN.md)); Android OpenPGP support is not available yet. Run the tests with `npm test`.
|
Mail supports multiple IMAP/SMTP accounts, switching between them, and saving message attachments. Compose can attach multiple files of any type; attachments are retained in local drafts and sent with the message. There is no app-enforced total-size cap, though local storage and mail providers may impose limits. Desktop encrypts and signs attachments together with the body when OpenPGP is selected. CalDAV and CardDAV servers can be added from the Calendar and Contacts views; credentials are kept in the OS-encrypted credential store, and events and contacts can sync and be edited on the server. Local contacts and events remain available without a DAV connection. Your display name is saved locally and appears in the greeting. Use the **+** beside **Folders** in the sidebar to create IMAP folders on the server; your custom folders appear in the sidebar and can be opened like any other folder. Keyboard shortcuts for compose, search, refresh, archive, delete, star, reply, forward, and message navigation can be changed in **Settings**. Attachments can be previewed (images and text) in the reader, and the **Attachments** view in the sidebar lists, searches, filters by type, previews and downloads attachments across Inbox, Sent, Archive and Trash. On desktop, **Settings → Encryption keys** creates, imports and exports passphrase-protected OpenPGP keys stored encrypted by the operating system; you can import contact keys, enable selected key servers (all are disabled initially), search all enabled servers, and publish a key to one explicitly selected server after a native confirmation names the destination. Discovered keys remain unverified until you compare fingerprints independently. Desktop can read encrypted or signed OpenPGP mail and encrypt or sign outgoing messages (see [ENCRYPTION_PLAN.md](./ENCRYPTION_PLAN.md)); Android OpenPGP support is not available yet. Run the tests with `npm test`.
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
- [x] Rename the program to **ep-mail** across the app UI, package metadata, desktop builds, and documentation.
|
- [x] Rename the program to **ep-mail** across the app UI, package metadata, desktop builds, and documentation.
|
||||||
- [x] Replace the temporary sun/asterisk app mark with the Git and webmail logo, using the EP Daylight and EP Wasteland color variants.
|
- [x] Replace the temporary sun/asterisk app mark with the Git and webmail logo, using the EP Daylight and EP Wasteland color variants.
|
||||||
|
- [x] Fix the ep-mail logo not appearing in the Windows taskbar.
|
||||||
- [x] Add Android support for the mail app.
|
- [x] Add Android support for the mail app.
|
||||||
- [ ] Add macOS support: configure macOS release targets and build the app on a Mac or hosted macOS runner; sign and notarize releases for distribution.
|
- [ ] Add macOS support: configure macOS release targets and build the app on a Mac or hosted macOS runner; sign and notarize releases for distribution.
|
||||||
- [x] Show the app version after **ep-mail** in the window title.
|
- [x] Show the app version after **ep-mail** in the window title.
|
||||||
@@ -21,7 +22,7 @@
|
|||||||
- [x] Add per-account rules to sort, archive, label, or flag new incoming messages by sender and/or subject.
|
- [x] Add per-account rules to sort, archive, label, or flag new incoming messages by sender and/or subject.
|
||||||
- [x] Add per-account signatures, notification preferences, and sync settings.
|
- [x] Add per-account signatures, notification preferences, and sync settings.
|
||||||
- [x] Add the ability to create IMAP folders from the app.
|
- [x] Add the ability to create IMAP folders from the app.
|
||||||
- [ ] Block remote images by default and let users load them per message.
|
- [x] Block remote images by default and let users load them per message on desktop and Android/Web.
|
||||||
|
|
||||||
## Mail security
|
## Mail security
|
||||||
|
|
||||||
@@ -68,6 +69,6 @@
|
|||||||
- [x] Fix draft mail deletion to work like the Inbox: select multiple drafts and delete the selected drafts at once.
|
- [x] Fix draft mail deletion to work like the Inbox: select multiple drafts and delete the selected drafts at once.
|
||||||
- [x] Show created IMAP folders in the same list as Inbox and the other folders, and move the folder list and the add-folder button to the top row above Inbox. Add scrolling to the IMAP folders area.
|
- [x] Show created IMAP folders in the same list as Inbox and the other folders, and move the folder list and the add-folder button to the top row above Inbox. Add scrolling to the IMAP folders area.
|
||||||
- [x] Add desktop public key server support for finding and publishing OpenPGP keys: keys.openpgp.org (VKS), keys.mailvelope.com (HKP over HTTPS), and user-defined HTTPS HKP/VKS servers. Servers are disabled until selected; lookup checks all enabled servers, and publishing requires one explicitly selected destination. Discovered keys remain unverified until fingerprint verification.
|
- [x] Add desktop public key server support for finding and publishing OpenPGP keys: keys.openpgp.org (VKS), keys.mailvelope.com (HKP over HTTPS), and user-defined HTTPS HKP/VKS servers. Servers are disabled until selected; lookup checks all enabled servers, and publishing requires one explicitly selected destination. Discovered keys remain unverified until fingerprint verification.
|
||||||
- [ ] Add the ability to attach files to outgoing mails.
|
- [x] Add the ability to attach multiple files to outgoing mails on desktop and Android/Web, persist them in local drafts, and include them within desktop OpenPGP protection.
|
||||||
- [x] Fix security review findings: confirm key replacement in the main process, enforce the plaintext-send check in the main process, and handle the Linux safeStorage basic_text backend. See SECURITY_REVIEW.md.
|
- [x] Fix security review findings: confirm key replacement in the main process, enforce the plaintext-send check in the main process, and handle the Linux safeStorage basic_text backend. See SECURITY_REVIEW.md.
|
||||||
- [x] Add the ability to change the passphrase of an encryption key on desktop.
|
- [x] Add the ability to change the passphrase of an encryption key on desktop.
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ import java.util.Date
|
|||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
import java.util.Properties
|
import java.util.Properties
|
||||||
import java.util.UUID
|
import java.util.UUID
|
||||||
|
import android.util.Base64
|
||||||
|
import javax.activation.DataHandler
|
||||||
import javax.mail.Address
|
import javax.mail.Address
|
||||||
import javax.mail.Authenticator
|
import javax.mail.Authenticator
|
||||||
import javax.mail.Flags
|
import javax.mail.Flags
|
||||||
@@ -28,6 +30,7 @@ import javax.mail.PasswordAuthentication
|
|||||||
import javax.mail.Session
|
import javax.mail.Session
|
||||||
import javax.mail.Store
|
import javax.mail.Store
|
||||||
import javax.mail.Transport
|
import javax.mail.Transport
|
||||||
|
import javax.mail.util.ByteArrayDataSource
|
||||||
import javax.mail.UIDFolder
|
import javax.mail.UIDFolder
|
||||||
import javax.mail.internet.InternetAddress
|
import javax.mail.internet.InternetAddress
|
||||||
import javax.mail.internet.MimeBodyPart
|
import javax.mail.internet.MimeBodyPart
|
||||||
@@ -272,10 +275,37 @@ internal object AndroidMailService {
|
|||||||
message.subject = input.optString("subject", "(no subject)")
|
message.subject = input.optString("subject", "(no subject)")
|
||||||
val body = input.optString("text")
|
val body = input.optString("text")
|
||||||
val signature = account.optString("signature").take(5000)
|
val signature = account.optString("signature").take(5000)
|
||||||
message.setText(
|
val fullBody = if (signature.isBlank()) body else "$body${if (body.isBlank()) "" else "\n\n"}$signature"
|
||||||
if (signature.isBlank()) body else "$body${if (body.isBlank()) "" else "\n\n"}$signature",
|
val attachments = input.optJSONArray("attachments") ?: JSONArray()
|
||||||
"UTF-8"
|
if (attachments.length() == 0) {
|
||||||
)
|
message.setText(fullBody, "UTF-8")
|
||||||
|
} else {
|
||||||
|
val multipart = MimeMultipart("mixed")
|
||||||
|
multipart.addBodyPart(MimeBodyPart().apply { setText(fullBody, "UTF-8") })
|
||||||
|
for (index in 0 until attachments.length()) {
|
||||||
|
val file = attachments.optJSONObject(index)
|
||||||
|
?: throw IllegalArgumentException("An attachment could not be read.")
|
||||||
|
val encoded = file.optString("contentBase64")
|
||||||
|
require(encoded.length % 4 == 0 && encoded.matches(Regex("^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$"))) {
|
||||||
|
"The contents of an attachment are invalid."
|
||||||
|
}
|
||||||
|
val filename = file.optString("filename", "attachment")
|
||||||
|
.replace(Regex("[\\\\/\\r\\n\\u0000]"), "")
|
||||||
|
.take(255)
|
||||||
|
.ifBlank { "attachment" }
|
||||||
|
val contentType = file.optString("contentType", "application/octet-stream")
|
||||||
|
.lowercase(Locale.ROOT)
|
||||||
|
require(contentType.matches(Regex("^[a-z0-9!#$&^_.+-]+/[a-z0-9!#$&^_.+-]+$"))) {
|
||||||
|
"The content type for $filename is invalid."
|
||||||
|
}
|
||||||
|
val part = MimeBodyPart()
|
||||||
|
part.dataHandler = DataHandler(ByteArrayDataSource(Base64.decode(encoded, Base64.DEFAULT), contentType))
|
||||||
|
part.fileName = MimeUtility.encodeText(filename, "UTF-8", null)
|
||||||
|
part.disposition = javax.mail.Part.ATTACHMENT
|
||||||
|
multipart.addBodyPart(part)
|
||||||
|
}
|
||||||
|
message.setContent(multipart)
|
||||||
|
}
|
||||||
message.sentDate = Date()
|
message.sentDate = Date()
|
||||||
message.saveChanges()
|
message.saveChanges()
|
||||||
input.optString("messageId").takeIf(String::isNotBlank)?.let { message.setHeader("Message-ID", it) }
|
input.optString("messageId").takeIf(String::isNotBlank)?.let { message.setHeader("Message-ID", it) }
|
||||||
@@ -561,9 +591,10 @@ internal object AndroidMailService {
|
|||||||
val senderEmail = sender?.address ?: ""
|
val senderEmail = sender?.address ?: ""
|
||||||
val subject = decode(message.subject).ifBlank { "(no subject)" }
|
val subject = decode(message.subject).ifBlank { "(no subject)" }
|
||||||
val body = ArrayList<String>()
|
val body = ArrayList<String>()
|
||||||
|
val htmlBodies = ArrayList<String>()
|
||||||
val attachments = JSONArray()
|
val attachments = JSONArray()
|
||||||
val links = linkedSetOf<String>()
|
val links = linkedSetOf<String>()
|
||||||
collectParts(message, body, attachments, links)
|
collectParts(message, body, htmlBodies, attachments, links)
|
||||||
val bodyText = body.joinToString("\n\n").trim().take(8000)
|
val bodyText = body.joinToString("\n\n").trim().take(8000)
|
||||||
val snippet = (bodyText.ifBlank { subject }).replace(Regex("\\s+"), " ").take(180)
|
val snippet = (bodyText.ifBlank { subject }).replace(Regex("\\s+"), " ").take(180)
|
||||||
val date = message.receivedDate ?: message.sentDate ?: Date()
|
val date = message.receivedDate ?: message.sentDate ?: Date()
|
||||||
@@ -598,6 +629,7 @@ internal object AndroidMailService {
|
|||||||
.put("archived", requestedFolder == "Archive")
|
.put("archived", requestedFolder == "Archive")
|
||||||
.put("deleted", requestedFolder == "Trash")
|
.put("deleted", requestedFolder == "Trash")
|
||||||
.put("sourceFolder", labelFolder)
|
.put("sourceFolder", labelFolder)
|
||||||
|
.put("html", htmlBodies.firstOrNull()?.take(100000) ?: "")
|
||||||
.put("body", JSONArray().apply {
|
.put("body", JSONArray().apply {
|
||||||
val paragraphs = bodyText.split(Regex("\\n\\s*\\n")).map(String::trim).filter(String::isNotEmpty).take(40)
|
val paragraphs = bodyText.split(Regex("\\n\\s*\\n")).map(String::trim).filter(String::isNotEmpty).take(40)
|
||||||
if (paragraphs.isEmpty()) put("This message has no plain-text body.") else paragraphs.forEach(::put)
|
if (paragraphs.isEmpty()) put("This message has no plain-text body.") else paragraphs.forEach(::put)
|
||||||
@@ -611,7 +643,13 @@ internal object AndroidMailService {
|
|||||||
private fun attachmentList(attachments: JSONArray): List<JSONObject> =
|
private fun attachmentList(attachments: JSONArray): List<JSONObject> =
|
||||||
(0 until attachments.length()).map { attachments.getJSONObject(it) }
|
(0 until attachments.length()).map { attachments.getJSONObject(it) }
|
||||||
|
|
||||||
private fun collectParts(part: javax.mail.Part, body: MutableList<String>, attachments: JSONArray, links: MutableSet<String>) {
|
private fun collectParts(
|
||||||
|
part: javax.mail.Part,
|
||||||
|
body: MutableList<String>,
|
||||||
|
htmlBodies: MutableList<String>,
|
||||||
|
attachments: JSONArray,
|
||||||
|
links: MutableSet<String>
|
||||||
|
) {
|
||||||
val filename = decode(part.fileName)
|
val filename = decode(part.fileName)
|
||||||
if (filename.isNotBlank() || part.disposition.equals(javax.mail.Part.ATTACHMENT, true)) {
|
if (filename.isNotBlank() || part.disposition.equals(javax.mail.Part.ATTACHMENT, true)) {
|
||||||
val name = filename.ifBlank { "attachment" }
|
val name = filename.ifBlank { "attachment" }
|
||||||
@@ -624,6 +662,7 @@ internal object AndroidMailService {
|
|||||||
is String -> if (part.isMimeType("text/plain")) {
|
is String -> if (part.isMimeType("text/plain")) {
|
||||||
body.add(content.replace("\r", "").trim())
|
body.add(content.replace("\r", "").trim())
|
||||||
} else if (part.isMimeType("text/html")) {
|
} else if (part.isMimeType("text/html")) {
|
||||||
|
if (htmlBodies.isEmpty()) htmlBodies.add(content.take(100000))
|
||||||
Regex("""<a\b[^>]*\bhref\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))""", RegexOption.IGNORE_CASE)
|
Regex("""<a\b[^>]*\bhref\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))""", RegexOption.IGNORE_CASE)
|
||||||
.findAll(content)
|
.findAll(content)
|
||||||
.mapNotNull { match -> (match.groups[1]?.value ?: match.groups[2]?.value ?: match.groups[3]?.value)?.replace("&", "&") }
|
.mapNotNull { match -> (match.groups[1]?.value ?: match.groups[2]?.value ?: match.groups[3]?.value)?.replace("&", "&") }
|
||||||
@@ -632,9 +671,9 @@ internal object AndroidMailService {
|
|||||||
if (body.isEmpty()) body.add(Html.fromHtml(content, Html.FROM_HTML_MODE_LEGACY).toString().trim())
|
if (body.isEmpty()) body.add(Html.fromHtml(content, Html.FROM_HTML_MODE_LEGACY).toString().trim())
|
||||||
}
|
}
|
||||||
is Multipart -> for (index in 0 until content.count) {
|
is Multipart -> for (index in 0 until content.count) {
|
||||||
collectParts(content.getBodyPart(index), body, attachments, links)
|
collectParts(content.getBodyPart(index), body, htmlBodies, attachments, links)
|
||||||
}
|
}
|
||||||
is javax.mail.BodyPart -> collectParts(content, body, attachments, links)
|
is javax.mail.BodyPart -> collectParts(content, body, htmlBodies, attachments, links)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -331,6 +331,7 @@ class EpMailPlugin : Plugin() {
|
|||||||
.put("cc", input.optString("cc").take(4000))
|
.put("cc", input.optString("cc").take(4000))
|
||||||
.put("subject", input.optString("subject").take(998))
|
.put("subject", input.optString("subject").take(998))
|
||||||
.put("text", input.optString("text").take(500000))
|
.put("text", input.optString("text").take(500000))
|
||||||
|
.put("attachments", input.optJSONArray("attachments") ?: JSONArray())
|
||||||
.put("updatedAt", System.currentTimeMillis())
|
.put("updatedAt", System.currentTimeMillis())
|
||||||
AndroidAccountVault.saveDraft(account.optString("id"), draft)
|
AndroidAccountVault.saveDraft(account.optString("id"), draft)
|
||||||
call.resolve(draft.toJSObject())
|
call.resolve(draft.toJSObject())
|
||||||
|
|||||||
@@ -4,8 +4,75 @@ const contacts=[];
|
|||||||
let activeMessage=1,activeFolder='Inbox',activeView='mail',query='',toastTimer,selectedIds=new Set();
|
let activeMessage=1,activeFolder='Inbox',activeView='mail',query='',toastTimer,selectedIds=new Set();
|
||||||
const $=s=>document.querySelector(s), $$=s=>[...document.querySelectorAll(s)];
|
const $=s=>document.querySelector(s), $$=s=>[...document.querySelectorAll(s)];
|
||||||
function esc(x){return String(x).replace(/[&<>"']/g,c=>({'&':'&','<':'<','>':'>','"':'"',"'":'''}[c]))}
|
function esc(x){return String(x).replace(/[&<>"']/g,c=>({'&':'&','<':'<','>':'>','"':'"',"'":'''}[c]))}
|
||||||
|
function safeRemoteImageUrl(value){if(typeof value!=='string'||value.length>2048)return null;try{const url=new URL(value);return url.protocol==='https:'&&url.hostname&&!url.username&&!url.password?url.href:null}catch{return null}}
|
||||||
|
function sanitizeMailHtml(value){
|
||||||
|
const html=String(value||'').slice(0,100000);
|
||||||
|
const inertImages=html
|
||||||
|
.replace(/<(script|style|iframe|frame|object|embed|svg|math|form|noscript|template|video|audio|source|picture|track)\b[\s\S]*?<\/\1\s*>/gi,'')
|
||||||
|
.replace(/<(?:script|style|iframe|frame|object|embed|svg|math|form|noscript|template|video|audio|source|picture|track|link|base|meta)\b[^>]*>/gi,'')
|
||||||
|
.replace(/<!--[\s\S]*?-->/g,'')
|
||||||
|
.replace(/<img\b[^>]*>/gi,tag=>{
|
||||||
|
const source=tag.match(/\bsrc\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s/>]+))/i);
|
||||||
|
const alt=tag.match(/\balt\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s/>]+))/i);
|
||||||
|
const remote=source&&(source[1]||source[2]||source[3]||'').trim();
|
||||||
|
const alternative=alt&&(alt[1]||alt[2]||alt[3]||'');
|
||||||
|
return `<img${remote?` data-remote-src="${esc(remote)}"`:''}${alternative?` alt="${esc(alternative)}"`:''}>`;
|
||||||
|
})
|
||||||
|
.replace(/\s(?:src|srcset|background|poster|action|formaction|href|xlink:href|srcdoc|dynsrc|lowsrc|style)\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/gi,'');
|
||||||
|
const document=new DOMParser().parseFromString(inertImages,'text/html');
|
||||||
|
const allowed=new Set(['a','p','div','span','br','hr','h1','h2','h3','h4','h5','h6','b','strong','i','em','u','s','del','blockquote','pre','code','ul','ol','li','table','thead','tbody','tfoot','tr','th','td','img']);
|
||||||
|
const discard=new Set(['script','style','iframe','frame','object','embed','svg','math','form','input','button','textarea','select','option','link','base','meta','video','audio','source','picture','track']);
|
||||||
|
let remoteImageCount=0;
|
||||||
|
const clean=parent=>{
|
||||||
|
for(const node of [...parent.childNodes]){
|
||||||
|
if(node.nodeType!==Node.ELEMENT_NODE){if(node.nodeType!==Node.TEXT_NODE)node.remove();continue}
|
||||||
|
const name=node.localName.toLowerCase();
|
||||||
|
if(discard.has(name)){node.remove();continue}
|
||||||
|
if(!allowed.has(name)){node.replaceWith(...node.childNodes);continue}
|
||||||
|
for(const attribute of [...node.attributes]){
|
||||||
|
const key=attribute.name.toLowerCase();
|
||||||
|
const keep=(name==='img'&&(key==='alt'||key==='data-remote-src'))||
|
||||||
|
(name==='td'||name==='th')&&['colspan','rowspan'].includes(key)&&/^\d{1,2}$/.test(attribute.value);
|
||||||
|
if(!keep)node.removeAttribute(attribute.name);
|
||||||
|
}
|
||||||
|
if(name==='img'){
|
||||||
|
const url=safeRemoteImageUrl(node.getAttribute('data-remote-src'));
|
||||||
|
if(url){node.setAttribute('data-remote-src',url);remoteImageCount+=1}
|
||||||
|
else node.removeAttribute('data-remote-src');
|
||||||
|
}
|
||||||
|
clean(node);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
clean(document.body);
|
||||||
|
return {html:document.body.innerHTML,remoteImageCount};
|
||||||
|
}
|
||||||
function renderList(){let rows=messages.filter(m=>{if(activeFolder==='Starred'&&!m.star)return false;if(activeFolder==='Inbox'&&m.archived)return false;if(activeFolder==='Archive'&&!m.archived)return false;if(activeFolder==='Trash'&&!m.deleted)return false;if(activeFolder==='Sent'&&!m.sent)return false;if(activeFolder==='Drafts')return false;if(activeFolder==='Snoozed')return false;if(m.deleted&&activeFolder!=='Trash')return false;return !query||`${m.sender} ${m.email} ${m.subject} ${m.snippet}`.toLowerCase().includes(query.toLowerCase())});$('#message-list').innerHTML=rows.length?rows.map(m=>`<div class="message ${m.unread?'unread':''} ${m.id===activeMessage?'selected':''}" data-id="${m.id}"><input class="row-check" type="checkbox" aria-label="Select message" ${selectedIds.has(m.id)?'checked':''}><div class="contact-avatar" style="background:${m.color}">${m.initials}</div><div class="message-body"><div class="sender">${esc(m.sender)}</div><div class="subject">${esc(m.subject)}</div><div class="snippet">${esc(m.snippet)}</div></div><div class="message-meta"><span class="time">${esc(m.time)}</span><button class="star ${m.star?'on':''}" aria-label="${m.star?'Unstar':'Star'}">${m.star?'★':'☆'}</button></div></div>`).join(''):`<div class="reader-empty"><div><div class="empty-icon">⌕</div><h3>No messages here</h3><p>Try another folder or search.</p></div></div>`;$$('.message').forEach(row=>{row.addEventListener('click',e=>{if(e.target.closest('.row-check')){const id=+row.dataset.id;selectedIds.has(id)?selectedIds.delete(id):selectedIds.add(id);return}if(e.target.closest('.star')){const m=messages.find(x=>x.id===+row.dataset.id);m.star=!m.star;renderList();return}openMessage(+row.dataset.id)});});if(!rows.length)$('#reader-pane').innerHTML=emptyReader()}
|
function renderList(){let rows=messages.filter(m=>{if(activeFolder==='Starred'&&!m.star)return false;if(activeFolder==='Inbox'&&m.archived)return false;if(activeFolder==='Archive'&&!m.archived)return false;if(activeFolder==='Trash'&&!m.deleted)return false;if(activeFolder==='Sent'&&!m.sent)return false;if(activeFolder==='Drafts')return false;if(activeFolder==='Snoozed')return false;if(m.deleted&&activeFolder!=='Trash')return false;return !query||`${m.sender} ${m.email} ${m.subject} ${m.snippet}`.toLowerCase().includes(query.toLowerCase())});$('#message-list').innerHTML=rows.length?rows.map(m=>`<div class="message ${m.unread?'unread':''} ${m.id===activeMessage?'selected':''}" data-id="${m.id}"><input class="row-check" type="checkbox" aria-label="Select message" ${selectedIds.has(m.id)?'checked':''}><div class="contact-avatar" style="background:${m.color}">${m.initials}</div><div class="message-body"><div class="sender">${esc(m.sender)}</div><div class="subject">${esc(m.subject)}</div><div class="snippet">${esc(m.snippet)}</div></div><div class="message-meta"><span class="time">${esc(m.time)}</span><button class="star ${m.star?'on':''}" aria-label="${m.star?'Unstar':'Star'}">${m.star?'★':'☆'}</button></div></div>`).join(''):`<div class="reader-empty"><div><div class="empty-icon">⌕</div><h3>No messages here</h3><p>Try another folder or search.</p></div></div>`;$$('.message').forEach(row=>{row.addEventListener('click',e=>{if(e.target.closest('.row-check')){const id=+row.dataset.id;selectedIds.has(id)?selectedIds.delete(id):selectedIds.add(id);return}if(e.target.closest('.star')){const m=messages.find(x=>x.id===+row.dataset.id);m.star=!m.star;renderList();return}openMessage(+row.dataset.id)});});if(!rows.length)$('#reader-pane').innerHTML=emptyReader()}
|
||||||
function openMessage(id){activeMessage=id;const m=messages.find(x=>x.id===id);if(!m)return;m.unread=false;renderList();$('#reader-pane').innerHTML=`<div class="reader-header"><div class="reader-topline"><div class="reader-tags">${m.tags.map((t,i)=>`<span class="tag ${i?'green':''}">${esc(t)}</span>`).join('')}</div><div class="reader-tools"><button class="icon-button" id="reader-archive" title="Archive">▱</button><button class="icon-button" id="reader-delete" title="Delete">⌫</button><button class="icon-button" title="More">···</button></div></div><h2 class="reader-subject">${esc(m.subject)}</h2><div class="sender-row"><div class="contact-avatar" style="background:${m.color}">${m.initials}</div><div class="sender-details"><strong>${esc(m.sender)}</strong><span>${esc(m.email)} · to me</span></div><span class="message-date">${esc(m.date)}</span><button class="icon-button" title="Star" id="reader-star">${m.star?'★':'☆'}</button></div></div><div class="reader-body">${m.body.map(p=>`<p>${esc(p)}</p>`).join('')}<p class="signoff">${esc(m.signature||m.sender)}</p>${(m.attachments?.length ? m.attachments : m.attachment ? [{filename:m.attachment,size:m.size}] : []).map(file=>`<div class="attachment"><div class="file-icon">${file.filename.toLowerCase().endsWith('.pdf')?'▤':'▧'}</div><div class="attachment-info"><strong title="${esc(file.filename)}">${esc(file.filename)}</strong><small>${file.size ? (typeof file.size==='string' ? esc(file.size) : `${(file.size/1048576).toFixed(1)} MB`) : 'Attachment'}</small></div><button class="download" data-filename="${esc(file.filename)}" title="Download ${esc(file.filename)}">↓</button></div>`).join('')}</div><div class="reply-bar"><button class="reply-button primary" id="reply">↶ Reply</button><button class="reply-button" id="forward">↗ Forward</button></div>`;$('#reader-archive').onclick=()=>{m.archived=true;toast('Moved to Archive');renderList();$('#reader-pane').innerHTML=emptyReader()};$('#reader-delete').onclick=()=>{m.deleted=true;toast('Moved to Trash');renderList();$('#reader-pane').innerHTML=emptyReader()};$('#reader-star').onclick=()=>{m.star=!m.star;renderList();openMessage(id)};$('#reply').onclick=()=>showCompose(m);$('#forward').onclick=()=>showCompose(m,true)}
|
function openMessage(id){
|
||||||
|
activeMessage=id;
|
||||||
|
const m=messages.find(x=>x.id===id);
|
||||||
|
if(!m)return;
|
||||||
|
m.unread=false;
|
||||||
|
renderList();
|
||||||
|
let safeHtml={html:'',remoteImageCount:0};
|
||||||
|
if(m.html)try{safeHtml=sanitizeMailHtml(m.html)}catch(error){console.error('Could not sanitize message HTML; showing plain text instead.',error)}
|
||||||
|
const body=safeHtml.html?safeHtml.html:`${m.body.map(p=>`<p>${esc(p)}</p>`).join('')}<p class="signoff">${esc(m.signature||m.sender)}</p>`;
|
||||||
|
const imageNotice=safeHtml.remoteImageCount?`<section class="remote-image-notice" role="status"><p>This message contains ${safeHtml.remoteImageCount} remote image${safeHtml.remoteImageCount===1?'':'s'}. Loading them can reveal your network address and that you opened this message to the image host.</p><button type="button" class="reply-button" id="load-remote-images">Load images for this message</button></section>`:'';
|
||||||
|
const attachments=(m.attachments?.length?m.attachments:m.attachment?[{filename:m.attachment,size:m.size}]:[]).map(file=>`<div class="attachment"><div class="file-icon">${file.filename.toLowerCase().endsWith('.pdf')?'▤':'▧'}</div><div class="attachment-info"><strong title="${esc(file.filename)}">${esc(file.filename)}</strong><small>${file.size?(typeof file.size==='string'?esc(file.size):`${(file.size/1048576).toFixed(1)} MB`):'Attachment'}</small></div><button class="download" data-filename="${esc(file.filename)}" title="Download ${esc(file.filename)}">↓</button></div>`).join('');
|
||||||
|
$('#reader-pane').innerHTML=`<div class="reader-header"><div class="reader-topline"><div class="reader-tags">${m.tags.map((t,i)=>`<span class="tag ${i?'green':''}">${esc(t)}</span>`).join('')}</div><div class="reader-tools"><button class="icon-button" id="reader-archive" title="Archive">▱</button><button class="icon-button" id="reader-delete" title="Delete">⌫</button><button class="icon-button" title="More">···</button></div></div><h2 class="reader-subject">${esc(m.subject)}</h2><div class="sender-row"><div class="contact-avatar" style="background:${m.color}">${m.initials}</div><div class="sender-details"><strong>${esc(m.sender)}</strong><span>${esc(m.email)} · to me</span></div><span class="message-date">${esc(m.date)}</span><button class="icon-button" title="Star" id="reader-star">${m.star?'★':'☆'}</button></div></div>${imageNotice}<div class="reader-body">${body}${attachments}</div><div class="reply-bar"><button class="reply-button primary" id="reply">↶ Reply</button><button class="reply-button" id="forward">↗ Forward</button></div>`;
|
||||||
|
$('#load-remote-images')?.addEventListener('click',()=>{
|
||||||
|
$('#reader-pane').querySelectorAll('.reader-body img[data-remote-src]').forEach(image=>{
|
||||||
|
const url=safeRemoteImageUrl(image.getAttribute('data-remote-src'));
|
||||||
|
image.removeAttribute('data-remote-src');
|
||||||
|
if(url)image.src=url;
|
||||||
|
});
|
||||||
|
$('.remote-image-notice')?.remove();
|
||||||
|
});
|
||||||
|
$('#reader-archive').onclick=()=>{m.archived=true;toast('Moved to Archive');renderList();$('#reader-pane').innerHTML=emptyReader()};
|
||||||
|
$('#reader-delete').onclick=()=>{m.deleted=true;toast('Moved to Trash');renderList();$('#reader-pane').innerHTML=emptyReader()};
|
||||||
|
$('#reader-star').onclick=()=>{m.star=!m.star;renderList();openMessage(id)};
|
||||||
|
$('#reply').onclick=()=>showCompose(m);
|
||||||
|
$('#forward').onclick=()=>showCompose(m,true);
|
||||||
|
}
|
||||||
function emptyReader(){return `<div class="reader-empty"><div><div class="empty-icon">✉</div><h3>Your inbox, at your pace</h3><p>Select a message to read it here.</p></div></div>`}
|
function emptyReader(){return `<div class="reader-empty"><div><div class="empty-icon">✉</div><h3>Your inbox, at your pace</h3><p>Select a message to read it here.</p></div></div>`}
|
||||||
function toast(s){const el=$('#toast');el.textContent=s;el.classList.add('visible');clearTimeout(toastTimer);toastTimer=setTimeout(()=>el.classList.remove('visible'),2300)}
|
function toast(s){const el=$('#toast');el.textContent=s;el.classList.add('visible');clearTimeout(toastTimer);toastTimer=setTimeout(()=>el.classList.remove('visible'),2300)}
|
||||||
function showCompose(reply,forward=false){const root=$('#modal-root');root.innerHTML=`<div class="modal-overlay"><div class="compose-modal"><div class="modal-head"><span>${reply?(forward?'Forward message':'Reply to message'):'New message'}</span><button class="modal-close" aria-label="Close">×</button></div><div class="compose-fields"><label class="compose-line"><span>To</span><input id="compose-to" placeholder="name@example.com" value="${reply?esc(forward?'':reply.email):''}"></label><label class="compose-line"><span>Cc</span><input id="compose-cc" placeholder="Add Cc"></label><input id="compose-subject" class="compose-subject" placeholder="Subject" value="${reply?esc((forward?'Fwd: ':'Re: ')+reply.subject):''}"></div><textarea class="compose-body" id="compose-body" placeholder="Write something thoughtful…">${reply&&!forward?'\n\nOn '+reply.date+', '+reply.sender+' wrote:\n> '+reply.snippet:''}</textarea><div class="compose-footer"><button class="discard" id="discard">Discard</button><button class="send-button" id="send">Send ↗</button></div></div></div>`;const close=()=>root.innerHTML='';$('.modal-close').onclick=close;$('#discard').onclick=close;$('.modal-overlay').addEventListener('click',e=>{if(e.target.classList.contains('modal-overlay'))close()});$('#send').onclick=()=>{const to=$('#compose-to').value.trim();if(!to){$('#compose-to').focus();toast('Add a recipient to send your message');return}const subject=$('#compose-subject').value.trim()||'(no subject)';const body=$('#compose-body').value;messages.unshift({id:Date.now(),initials:(profileSettings.name||connectedMailAccount?.email?.split('@')[0]||'Me').split(/\\s+/).map(x=>x[0]).join('').slice(0,2).toUpperCase(),color:'#dce9dd',sender:(profileSettings.name||connectedMailAccount?.email?.split('@')[0]||'Me'),email:(connectedMailAccount?.email||''),subject,snippet:body||'No message text',time:'Just now',date:'Today',unread:false,star:false,sent:true,tags:['Sent'],body:body.split('\n').filter(Boolean)});close();toast('Message sent');renderList()};$('#compose-to').focus()}
|
function showCompose(reply,forward=false){const root=$('#modal-root');root.innerHTML=`<div class="modal-overlay"><div class="compose-modal"><div class="modal-head"><span>${reply?(forward?'Forward message':'Reply to message'):'New message'}</span><button class="modal-close" aria-label="Close">×</button></div><div class="compose-fields"><label class="compose-line"><span>To</span><input id="compose-to" placeholder="name@example.com" value="${reply?esc(forward?'':reply.email):''}"></label><label class="compose-line"><span>Cc</span><input id="compose-cc" placeholder="Add Cc"></label><input id="compose-subject" class="compose-subject" placeholder="Subject" value="${reply?esc((forward?'Fwd: ':'Re: ')+reply.subject):''}"></div><textarea class="compose-body" id="compose-body" placeholder="Write something thoughtful…">${reply&&!forward?'\n\nOn '+reply.date+', '+reply.sender+' wrote:\n> '+reply.snippet:''}</textarea><div class="compose-footer"><button class="discard" id="discard">Discard</button><button class="send-button" id="send">Send ↗</button></div></div></div>`;const close=()=>root.innerHTML='';$('.modal-close').onclick=close;$('#discard').onclick=close;$('.modal-overlay').addEventListener('click',e=>{if(e.target.classList.contains('modal-overlay'))close()});$('#send').onclick=()=>{const to=$('#compose-to').value.trim();if(!to){$('#compose-to').focus();toast('Add a recipient to send your message');return}const subject=$('#compose-subject').value.trim()||'(no subject)';const body=$('#compose-body').value;messages.unshift({id:Date.now(),initials:(profileSettings.name||connectedMailAccount?.email?.split('@')[0]||'Me').split(/\\s+/).map(x=>x[0]).join('').slice(0,2).toUpperCase(),color:'#dce9dd',sender:(profileSettings.name||connectedMailAccount?.email?.split('@')[0]||'Me'),email:(connectedMailAccount?.email||''),subject,snippet:body||'No message text',time:'Just now',date:'Today',unread:false,star:false,sent:true,tags:['Sent'],body:body.split('\n').filter(Boolean)});close();toast('Message sent');renderList()};$('#compose-to').focus()}
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
const path = require('node:path');
|
||||||
|
|
||||||
|
function normalizeOutgoingAttachments(value) {
|
||||||
|
if (value === undefined) return [];
|
||||||
|
if (!Array.isArray(value)) throw new Error('The attachment list is invalid.');
|
||||||
|
return value.map(file => {
|
||||||
|
if (!file || typeof file !== 'object' || typeof file.contentBase64 !== 'string') {
|
||||||
|
throw new Error('An attachment could not be read.');
|
||||||
|
}
|
||||||
|
const filename = path.basename(String(file.filename || 'attachment').replace(/\\/g, '/'))
|
||||||
|
.replace(/[\r\n\0]/g, '')
|
||||||
|
.slice(0, 255) || 'attachment';
|
||||||
|
const contentType = String(file.contentType || 'application/octet-stream').trim().toLowerCase();
|
||||||
|
if (!/^[a-z0-9!#$&^_.+-]+\/[a-z0-9!#$&^_.+-]+$/.test(contentType)) {
|
||||||
|
throw new Error(`The content type for ${filename} is invalid.`);
|
||||||
|
}
|
||||||
|
const encoded = file.contentBase64;
|
||||||
|
if (encoded.length % 4 !== 0 || !/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(encoded)) {
|
||||||
|
throw new Error(`The contents of ${filename} are invalid.`);
|
||||||
|
}
|
||||||
|
const content = Buffer.from(encoded, 'base64');
|
||||||
|
return { filename, contentType, contentBase64: encoded, size: content.length, content };
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function serializeOutgoingAttachments(attachments) {
|
||||||
|
return attachments.map(({ content, ...file }) => file);
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = { normalizeOutgoingAttachments, serializeOutgoingAttachments };
|
||||||
+92
-5
@@ -1,4 +1,5 @@
|
|||||||
const { app, BrowserWindow, shell, ipcMain, safeStorage, dialog, Notification, powerMonitor } = 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');
|
||||||
@@ -9,6 +10,7 @@ const { createDAVClient } = require('tsdav');
|
|||||||
const ICAL = require('ical.js');
|
const ICAL = require('ical.js');
|
||||||
const openpgp = require('openpgp');
|
const openpgp = require('openpgp');
|
||||||
const { createKeyServerService, listServers, MAX_CUSTOM_SERVERS, normalizeCustomServer } = require('./pgp-keyservers.cjs');
|
const { createKeyServerService, listServers, MAX_CUSTOM_SERVERS, normalizeCustomServer } = require('./pgp-keyservers.cjs');
|
||||||
|
const { normalizeOutgoingAttachments, serializeOutgoingAttachments } = require('./mail-attachments.cjs');
|
||||||
|
|
||||||
const credentialsPath = () => path.join(app.getPath('userData'), 'mail-account.enc');
|
const credentialsPath = () => path.join(app.getPath('userData'), 'mail-account.enc');
|
||||||
const davCredentialsPath = () => path.join(app.getPath('userData'), 'dav-accounts.enc');
|
const davCredentialsPath = () => path.join(app.getPath('userData'), 'dav-accounts.enc');
|
||||||
@@ -17,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;
|
||||||
@@ -26,6 +29,8 @@ const backgroundSyncFailures = new Map();
|
|||||||
const flagSnapshots = new Map();
|
const flagSnapshots = new Map();
|
||||||
const idleWatchers = new Map();
|
const idleWatchers = new Map();
|
||||||
const lastBackgroundSyncAt = new Map();
|
const lastBackgroundSyncAt = new Map();
|
||||||
|
let windowsAppIcon = null;
|
||||||
|
let tray = null;
|
||||||
|
|
||||||
function updateAccountStore(update) {
|
function updateAccountStore(update) {
|
||||||
const operation = accountStoreQueue.then(async () => {
|
const operation = accountStoreQueue.then(async () => {
|
||||||
@@ -610,6 +615,7 @@ async function toUiMessage(item, folder) {
|
|||||||
deleted: folder === 'Trash',
|
deleted: folder === 'Trash',
|
||||||
sourceFolder: folder,
|
sourceFolder: folder,
|
||||||
body,
|
body,
|
||||||
|
html: content.html,
|
||||||
links,
|
links,
|
||||||
uid: Number(item.uid),
|
uid: Number(item.uid),
|
||||||
attachments: content.attachments,
|
attachments: content.attachments,
|
||||||
@@ -630,6 +636,7 @@ function mailContent(parsed) {
|
|||||||
return {
|
return {
|
||||||
bodyText,
|
bodyText,
|
||||||
body,
|
body,
|
||||||
|
html: html.slice(0, 100000),
|
||||||
links,
|
links,
|
||||||
attachments: files.map(file => ({ filename: file.filename || 'attachment', size: file.size || 0 })),
|
attachments: files.map(file => ({ filename: file.filename || 'attachment', size: file.size || 0 })),
|
||||||
attachment: files[0]?.filename || null,
|
attachment: files[0]?.filename || null,
|
||||||
@@ -1027,6 +1034,7 @@ ipcMain.handle('mail:save-draft', async (_event, input) => {
|
|||||||
cc: String(input?.cc || '').slice(0, 4000),
|
cc: String(input?.cc || '').slice(0, 4000),
|
||||||
subject: String(input?.subject || '').slice(0, 998),
|
subject: String(input?.subject || '').slice(0, 998),
|
||||||
text: String(input?.text || '').slice(0, 500000),
|
text: String(input?.text || '').slice(0, 500000),
|
||||||
|
attachments: serializeOutgoingAttachments(normalizeOutgoingAttachments(input?.attachments)),
|
||||||
updatedAt: Date.now()
|
updatedAt: Date.now()
|
||||||
};
|
};
|
||||||
await updateAccountStore(store => {
|
await updateAccountStore(store => {
|
||||||
@@ -1376,6 +1384,7 @@ ipcMain.handle('pgp:decrypt-message', async (_event, input) => {
|
|||||||
return {
|
return {
|
||||||
ok: true,
|
ok: true,
|
||||||
body: content.body,
|
body: content.body,
|
||||||
|
html: content.html,
|
||||||
links: content.links,
|
links: content.links,
|
||||||
attachments: content.attachments,
|
attachments: content.attachments,
|
||||||
attachment: content.attachment,
|
attachment: content.attachment,
|
||||||
@@ -1594,6 +1603,7 @@ ipcMain.handle('mail:sync-inbox', async () => {
|
|||||||
async function sendMailNow(account, message) {
|
async function sendMailNow(account, message) {
|
||||||
const to = String(message?.to || '').trim();
|
const to = String(message?.to || '').trim();
|
||||||
if (!to) throw new Error('Add at least one recipient.');
|
if (!to) throw new Error('Add at least one recipient.');
|
||||||
|
const attachments = normalizeOutgoingAttachments(message?.attachments);
|
||||||
const transport = smtpTransport(account);
|
const transport = smtpTransport(account);
|
||||||
const sentMessageId = String(message.messageId || `<${require('node:crypto').randomUUID()}@ep-mail.local>`);
|
const sentMessageId = String(message.messageId || `<${require('node:crypto').randomUUID()}@ep-mail.local>`);
|
||||||
const fromName = String(account.displayName || message.displayName || account.email).replace(/[\r\n]+/g, ' ').trim().slice(0, 80) || account.email;
|
const fromName = String(account.displayName || message.displayName || account.email).replace(/[\r\n]+/g, ' ').trim().slice(0, 80) || account.email;
|
||||||
@@ -1605,7 +1615,12 @@ async function sendMailNow(account, message) {
|
|||||||
cc: String(message.cc || '').trim() || undefined,
|
cc: String(message.cc || '').trim() || undefined,
|
||||||
subject: String(message.subject || '(no subject)').slice(0, 998),
|
subject: String(message.subject || '(no subject)').slice(0, 998),
|
||||||
text: signature ? `${body}${body.trim() ? '\n\n' : ''}${signature}`.slice(0, 505000) : body,
|
text: signature ? `${body}${body.trim() ? '\n\n' : ''}${signature}`.slice(0, 505000) : body,
|
||||||
messageId: sentMessageId
|
messageId: sentMessageId,
|
||||||
|
attachments: attachments.map(file => ({
|
||||||
|
filename: file.filename,
|
||||||
|
contentType: file.contentType,
|
||||||
|
content: file.content
|
||||||
|
}))
|
||||||
};
|
};
|
||||||
const rawMessage = message.rawBase64 ? Buffer.from(String(message.rawBase64), 'base64') : null;
|
const rawMessage = message.rawBase64 ? Buffer.from(String(message.rawBase64), 'base64') : null;
|
||||||
try {
|
try {
|
||||||
@@ -1644,6 +1659,8 @@ ipcMain.handle('mail:send', async (event, message) => {
|
|||||||
if (!account) throw new Error('Add a mail account before sending.');
|
if (!account) throw new Error('Add a mail account before sending.');
|
||||||
const pgpOptions = message?.pgp && (message.pgp.encrypt || message.pgp.sign) ? message.pgp : null;
|
const pgpOptions = message?.pgp && (message.pgp.encrypt || message.pgp.sign) ? message.pgp : null;
|
||||||
const queuedMessage = { ...message, messageId: message?.messageId || `<${randomUUID()}@ep-mail.local>` };
|
const queuedMessage = { ...message, messageId: message?.messageId || `<${randomUUID()}@ep-mail.local>` };
|
||||||
|
const attachments = normalizeOutgoingAttachments(message?.attachments);
|
||||||
|
queuedMessage.attachments = serializeOutgoingAttachments(attachments);
|
||||||
delete queuedMessage.pgp;
|
delete queuedMessage.pgp;
|
||||||
if (!pgpOptions?.encrypt) {
|
if (!pgpOptions?.encrypt) {
|
||||||
const recipients = [queuedMessage.to, queuedMessage.cc].filter(Boolean);
|
const recipients = [queuedMessage.to, queuedMessage.cc].filter(Boolean);
|
||||||
@@ -1677,11 +1694,13 @@ ipcMain.handle('mail:send', async (event, message) => {
|
|||||||
messageId: queuedMessage.messageId,
|
messageId: queuedMessage.messageId,
|
||||||
encrypt: Boolean(pgpOptions.encrypt),
|
encrypt: Boolean(pgpOptions.encrypt),
|
||||||
sign: Boolean(pgpOptions.sign),
|
sign: Boolean(pgpOptions.sign),
|
||||||
passphrase: typeof pgpOptions.passphrase === 'string' && pgpOptions.passphrase ? pgpOptions.passphrase : null
|
passphrase: typeof pgpOptions.passphrase === 'string' && pgpOptions.passphrase ? pgpOptions.passphrase : null,
|
||||||
|
attachments: attachments.map(({ filename, contentType, content }) => ({ filename, contentType, content }))
|
||||||
});
|
});
|
||||||
queuedMessage.rawBase64 = built.raw.toString('base64');
|
queuedMessage.rawBase64 = built.raw.toString('base64');
|
||||||
queuedMessage.envelope = built.envelope;
|
queuedMessage.envelope = built.envelope;
|
||||||
queuedMessage.text = '';
|
queuedMessage.text = '';
|
||||||
|
queuedMessage.attachments = [];
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error instanceof PgpError) return pgpFailure(error);
|
if (error instanceof PgpError) return pgpFailure(error);
|
||||||
throw error;
|
throw error;
|
||||||
@@ -1878,7 +1897,7 @@ function createWindow() {
|
|||||||
backgroundColor: '#f4f5f1',
|
backgroundColor: '#f4f5f1',
|
||||||
show: false,
|
show: false,
|
||||||
autoHideMenuBar: true,
|
autoHideMenuBar: true,
|
||||||
icon: path.join(__dirname, '..', 'icon.svg'),
|
icon: windowsAppIcon || path.join(__dirname, '..', 'icon.svg'),
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
preload: path.join(__dirname, 'preload.cjs'),
|
preload: path.join(__dirname, 'preload.cjs'),
|
||||||
contextIsolation: true,
|
contextIsolation: true,
|
||||||
@@ -1896,10 +1915,78 @@ function createWindow() {
|
|||||||
window.webContents.on('will-navigate', (event, url) => {
|
window.webContents.on('will-navigate', (event, url) => {
|
||||||
if (!url.startsWith('file:')) event.preventDefault();
|
if (!url.startsWith('file:')) event.preventDefault();
|
||||||
});
|
});
|
||||||
|
return window;
|
||||||
|
}
|
||||||
|
|
||||||
|
function showMainWindow() {
|
||||||
|
let window = BrowserWindow.getAllWindows().find(item => !item.isDestroyed());
|
||||||
|
if (!window) {
|
||||||
|
window = createWindow();
|
||||||
|
} else {
|
||||||
|
if (window.isMinimized()) window.restore();
|
||||||
|
window.show();
|
||||||
|
window.focus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function createWindowsTray() {
|
||||||
|
tray = new Tray(windowsAppIcon.resize({ width: 16, height: 16 }));
|
||||||
|
tray.setToolTip('ep-mail');
|
||||||
|
tray.setContextMenu(Menu.buildFromTemplate([
|
||||||
|
{ label: 'Open ep-mail', click: showMainWindow },
|
||||||
|
{ type: 'separator' },
|
||||||
|
{ label: 'Quit ep-mail', click: () => app.quit() }
|
||||||
|
]));
|
||||||
|
tray.on('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') {
|
||||||
|
windowsAppIcon = nativeImage.createFromPath(path.join(__dirname, '..', 'icon.ico'));
|
||||||
|
if (windowsAppIcon.isEmpty()) throw new Error('Could not load the Windows application icon.');
|
||||||
|
repairWindowsStartMenuShortcut();
|
||||||
|
createWindowsTray();
|
||||||
|
}
|
||||||
createWindow();
|
createWindow();
|
||||||
const syncTimer = setInterval(() => {
|
const syncTimer = setInterval(() => {
|
||||||
void runBackgroundSync(true).catch(error => console.error('Periodic mail sync failed:', error));
|
void runBackgroundSync(true).catch(error => console.error('Periodic mail sync failed:', error));
|
||||||
|
|||||||
+18
-3
@@ -1,6 +1,7 @@
|
|||||||
const openpgp = require('openpgp');
|
const openpgp = require('openpgp');
|
||||||
const { simpleParser } = require('mailparser');
|
const { simpleParser } = require('mailparser');
|
||||||
const addressParser = require('nodemailer/lib/addressparser');
|
const addressParser = require('nodemailer/lib/addressparser');
|
||||||
|
const MailComposer = require('nodemailer/lib/mail-composer');
|
||||||
const { randomBytes } = require('node:crypto');
|
const { randomBytes } = require('node:crypto');
|
||||||
|
|
||||||
const ARMORED_MESSAGE = /-----BEGIN PGP MESSAGE-----[\s\S]+?-----END PGP MESSAGE-----/;
|
const ARMORED_MESSAGE = /-----BEGIN PGP MESSAGE-----[\s\S]+?-----END PGP MESSAGE-----/;
|
||||||
@@ -131,7 +132,21 @@ function parseAddresses(value) {
|
|||||||
return addressParser(String(value || '')).filter(entry => entry.address || entry.name);
|
return addressParser(String(value || '')).filter(entry => entry.address || entry.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
function innerEntity(text) {
|
async function innerEntity(text, attachments) {
|
||||||
|
if (attachments.length) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
new MailComposer({
|
||||||
|
text: String(text || ''),
|
||||||
|
attachments: attachments.map(file => ({
|
||||||
|
filename: file.filename,
|
||||||
|
contentType: file.contentType,
|
||||||
|
content: file.content
|
||||||
|
}))
|
||||||
|
}).compile().build((error, message) => error
|
||||||
|
? reject(error)
|
||||||
|
: resolve(Buffer.from(message.toString('latin1').replace(/\r?\n/g, '\r\n'), 'latin1')));
|
||||||
|
});
|
||||||
|
}
|
||||||
const body = Buffer.from(String(text || ''), 'utf8');
|
const body = Buffer.from(String(text || ''), 'utf8');
|
||||||
return Buffer.from(`Content-Type: text/plain; charset=utf-8\r\nContent-Transfer-Encoding: base64\r\n\r\n${chunkBase64(body)}\r\n`, 'latin1');
|
return Buffer.from(`Content-Type: text/plain; charset=utf-8\r\nContent-Transfer-Encoding: base64\r\n\r\n${chunkBase64(body)}\r\n`, 'latin1');
|
||||||
}
|
}
|
||||||
@@ -252,7 +267,7 @@ function createPgpMail({ keyStore, cache }) {
|
|||||||
},
|
},
|
||||||
|
|
||||||
// Builds a complete RFC 3156 message. Returns { raw, envelope }.
|
// Builds a complete RFC 3156 message. Returns { raw, envelope }.
|
||||||
async build({ from, to, cc, subject, text, messageId, date = new Date(), encrypt, sign, passphrase, signerFingerprint }) {
|
async build({ from, to, cc, subject, text, messageId, date = new Date(), encrypt, sign, passphrase, signerFingerprint, attachments = [] }) {
|
||||||
const toList = parseAddresses(to);
|
const toList = parseAddresses(to);
|
||||||
const ccList = parseAddresses(cc);
|
const ccList = parseAddresses(cc);
|
||||||
if (!toList.length) throw new Error('Add at least one recipient.');
|
if (!toList.length) throw new Error('Add at least one recipient.');
|
||||||
@@ -284,7 +299,7 @@ function createPgpMail({ keyStore, cache }) {
|
|||||||
`Message-ID: ${String(messageId).replace(/[\r\n<>\s]/g, '').replace(/^/, '<').replace(/$/, '>')}`,
|
`Message-ID: ${String(messageId).replace(/[\r\n<>\s]/g, '').replace(/^/, '<').replace(/$/, '>')}`,
|
||||||
'MIME-Version: 1.0'
|
'MIME-Version: 1.0'
|
||||||
];
|
];
|
||||||
const inner = innerEntity(text);
|
const inner = await innerEntity(text, attachments);
|
||||||
const mark = boundary();
|
const mark = boundary();
|
||||||
let body;
|
let body;
|
||||||
let contentType;
|
let contentType;
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<meta name="theme-color" content="#f4f5f1">
|
<meta name="theme-color" content="#f4f5f1">
|
||||||
<meta name="description" content="ep-mail: Eternity Project mail, calendar, and contacts for Windows and Linux.">
|
<meta name="description" content="ep-mail: Eternity Project mail, calendar, and contacts for Windows and Linux.">
|
||||||
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self'; connect-src 'none'">
|
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; font-src 'self'; connect-src 'none'; frame-src 'none'; object-src 'none'; base-uri 'none'; form-action 'none'">
|
||||||
<title>ep-mail</title>
|
<title>ep-mail</title>
|
||||||
<link rel="manifest" href="manifest.webmanifest">
|
<link rel="manifest" href="manifest.webmanifest">
|
||||||
<link rel="stylesheet" href="styles.css">
|
<link rel="stylesheet" href="styles.css">
|
||||||
|
|||||||
+81
-2
@@ -398,6 +398,83 @@ function setupDraftComposer() {
|
|||||||
const modal = root.querySelector('.compose-modal');
|
const modal = root.querySelector('.compose-modal');
|
||||||
if (!modal) return;
|
if (!modal) return;
|
||||||
modal.dataset.draftId = draft?.id || '';
|
modal.dataset.draftId = draft?.id || '';
|
||||||
|
let attachments = Array.isArray(draft?.attachments) ? draft.attachments : [];
|
||||||
|
modal._composeAttachments = attachments;
|
||||||
|
const fields = modal.querySelector('.compose-fields');
|
||||||
|
const attachmentRow = document.createElement('div');
|
||||||
|
attachmentRow.className = 'compose-line';
|
||||||
|
const attachmentLabel = document.createElement('span');
|
||||||
|
attachmentLabel.textContent = 'Attachments';
|
||||||
|
const attachmentControls = document.createElement('div');
|
||||||
|
attachmentControls.className = 'compose-attachments';
|
||||||
|
const attachmentInput = document.createElement('input');
|
||||||
|
attachmentInput.type = 'file';
|
||||||
|
attachmentInput.multiple = true;
|
||||||
|
attachmentInput.accept = '*/*';
|
||||||
|
attachmentInput.hidden = true;
|
||||||
|
attachmentInput.setAttribute('aria-label', 'Choose files to attach');
|
||||||
|
const attachButton = document.createElement('button');
|
||||||
|
attachButton.type = 'button';
|
||||||
|
attachButton.className = 'discard';
|
||||||
|
attachButton.textContent = 'Attach files…';
|
||||||
|
const attachmentList = document.createElement('div');
|
||||||
|
attachmentList.className = 'attachment-list';
|
||||||
|
attachmentList.setAttribute('aria-live', 'polite');
|
||||||
|
attachmentControls.append(attachButton, attachmentInput);
|
||||||
|
attachmentRow.append(attachmentLabel, attachmentControls);
|
||||||
|
fields.append(attachmentRow, attachmentList);
|
||||||
|
attachButton.onclick = () => attachmentInput.click();
|
||||||
|
const renderAttachments = () => {
|
||||||
|
attachmentList.replaceChildren();
|
||||||
|
attachments.forEach((file, index) => {
|
||||||
|
const row = document.createElement('div');
|
||||||
|
row.className = 'attachment-row';
|
||||||
|
const name = document.createElement('strong');
|
||||||
|
name.textContent = file.filename;
|
||||||
|
const size = document.createElement('small');
|
||||||
|
size.textContent = `${((file.size || 0) / 1048576).toFixed(2)} MB`;
|
||||||
|
const remove = document.createElement('button');
|
||||||
|
remove.type = 'button';
|
||||||
|
remove.className = 'discard';
|
||||||
|
remove.textContent = 'Remove';
|
||||||
|
remove.setAttribute('aria-label', `Remove ${file.filename}`);
|
||||||
|
remove.onclick = () => {
|
||||||
|
attachments.splice(index, 1);
|
||||||
|
renderAttachments();
|
||||||
|
void persist().catch(error => toast(error.message || 'Could not save the draft'));
|
||||||
|
};
|
||||||
|
row.append(name, size, remove);
|
||||||
|
attachmentList.append(row);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
attachmentInput.onchange = async () => {
|
||||||
|
attachButton.disabled = true;
|
||||||
|
try {
|
||||||
|
const selected = [];
|
||||||
|
for (const file of attachmentInput.files) {
|
||||||
|
const bytes = new Uint8Array(await file.arrayBuffer());
|
||||||
|
let binary = '';
|
||||||
|
for (let offset = 0; offset < bytes.length; offset += 0x8000) {
|
||||||
|
binary += String.fromCharCode(...bytes.subarray(offset, offset + 0x8000));
|
||||||
|
}
|
||||||
|
selected.push({
|
||||||
|
filename: file.name,
|
||||||
|
contentType: file.type || 'application/octet-stream',
|
||||||
|
size: file.size,
|
||||||
|
contentBase64: btoa(binary)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
attachments.push(...selected);
|
||||||
|
renderAttachments();
|
||||||
|
await persist();
|
||||||
|
} catch (error) {
|
||||||
|
toast(error.message || 'Could not add the selected files');
|
||||||
|
} finally {
|
||||||
|
attachmentInput.value = '';
|
||||||
|
attachButton.disabled = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
renderAttachments();
|
||||||
if (draft) {
|
if (draft) {
|
||||||
$('#compose-to').value = draft.to || '';
|
$('#compose-to').value = draft.to || '';
|
||||||
$('#compose-cc').value = draft.cc || '';
|
$('#compose-cc').value = draft.cc || '';
|
||||||
@@ -420,9 +497,10 @@ function setupDraftComposer() {
|
|||||||
to: $('#compose-to').value,
|
to: $('#compose-to').value,
|
||||||
cc: $('#compose-cc').value,
|
cc: $('#compose-cc').value,
|
||||||
subject: $('#compose-subject').value,
|
subject: $('#compose-subject').value,
|
||||||
text: $('#compose-body').value
|
text: $('#compose-body').value,
|
||||||
|
attachments
|
||||||
};
|
};
|
||||||
if (!Object.values(values).some(value => typeof value === 'string' && value.trim())) return;
|
if (!Object.values(values).some(value => typeof value === 'string' && value.trim()) && !attachments.length) return;
|
||||||
modal.dataset.draftId = values.id;
|
modal.dataset.draftId = values.id;
|
||||||
const result = await window.daybreakMail.saveDraft(values);
|
const result = await window.daybreakMail.saveDraft(values);
|
||||||
modal.dataset.draftId = result.id;
|
modal.dataset.draftId = result.id;
|
||||||
@@ -668,6 +746,7 @@ if (window.daybreakMail) {
|
|||||||
cc: $('#compose-cc').value,
|
cc: $('#compose-cc').value,
|
||||||
subject: $('#compose-subject').value.trim(),
|
subject: $('#compose-subject').value.trim(),
|
||||||
text: $('#compose-body').value,
|
text: $('#compose-body').value,
|
||||||
|
attachments: $('#modal-root .compose-modal')?._composeAttachments || [],
|
||||||
displayName: connectedMailAccount.displayName || profileSettings.name,
|
displayName: connectedMailAccount.displayName || profileSettings.name,
|
||||||
...(pgp ? { pgp } : {})
|
...(pgp ? { pgp } : {})
|
||||||
});
|
});
|
||||||
|
|||||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "ep-mail",
|
"name": "ep-mail",
|
||||||
"version": "0.3.6",
|
"version": "0.4.4",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "ep-mail",
|
"name": "ep-mail",
|
||||||
"version": "0.3.6",
|
"version": "0.4.4",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@capacitor/android": "^8.5.2",
|
"@capacitor/android": "^8.5.2",
|
||||||
"@capacitor/core": "^8.5.2",
|
"@capacitor/core": "^8.5.2",
|
||||||
|
|||||||
+9
-2
@@ -1,9 +1,13 @@
|
|||||||
{
|
{
|
||||||
"name": "ep-mail",
|
"name": "ep-mail",
|
||||||
"version": "0.3.6",
|
"version": "0.4.4",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "Eternity Project mail client",
|
"description": "Eternity Project mail client",
|
||||||
"author": "Eternity Project",
|
"homepage": "https://git.eternityproject.fi/thuttu/ep-mail-client",
|
||||||
|
"author": {
|
||||||
|
"name": "Eternity Project",
|
||||||
|
"email": "tero.huttunen@eternityproject.fi"
|
||||||
|
},
|
||||||
"desktopName": "ep-mail",
|
"desktopName": "ep-mail",
|
||||||
"main": "desktop/main.cjs",
|
"main": "desktop/main.cjs",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@@ -48,6 +52,7 @@
|
|||||||
"pgp-ui.js",
|
"pgp-ui.js",
|
||||||
"pgp-mail-ui.js",
|
"pgp-mail-ui.js",
|
||||||
"icon.svg",
|
"icon.svg",
|
||||||
|
"icon.ico",
|
||||||
"logo-ep-daylight.svg",
|
"logo-ep-daylight.svg",
|
||||||
"logo-ep-wasteland.svg",
|
"logo-ep-wasteland.svg",
|
||||||
"manifest.webmanifest",
|
"manifest.webmanifest",
|
||||||
@@ -59,6 +64,7 @@
|
|||||||
"output": "release"
|
"output": "release"
|
||||||
},
|
},
|
||||||
"win": {
|
"win": {
|
||||||
|
"icon": "icon.ico",
|
||||||
"target": [
|
"target": [
|
||||||
"nsis",
|
"nsis",
|
||||||
"portable"
|
"portable"
|
||||||
@@ -77,6 +83,7 @@
|
|||||||
"AppImage",
|
"AppImage",
|
||||||
"deb"
|
"deb"
|
||||||
],
|
],
|
||||||
|
"maintainer": "Tero Huttunen <tero.huttunen@eternityproject.fi>",
|
||||||
"synopsis": "A calmer place for mail, people, and plans"
|
"synopsis": "A calmer place for mail, people, and plans"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
+1
-1
@@ -92,7 +92,7 @@ async function pgpUnlockMessage(message, interactive) {
|
|||||||
}
|
}
|
||||||
if (result.ok) {
|
if (result.ok) {
|
||||||
Object.assign(message, {
|
Object.assign(message, {
|
||||||
body: result.body, links: result.links, attachments: result.attachments, attachment: result.attachment, size: result.size,
|
body: result.body, html: result.html, links: result.links, attachments: result.attachments, attachment: result.attachment, size: result.size,
|
||||||
snippet: 'Encrypted message', pgpDecrypted: true, pgpResult: { signatures: result.signatures, attachedKeys: result.attachedKeys }
|
snippet: 'Encrypted message', pgpDecrypted: true, pgpResult: { signatures: result.signatures, attachedKeys: result.attachedKeys }
|
||||||
});
|
});
|
||||||
if (activeMessage === message.id) openMessage(message.id);
|
if (activeMessage === message.id) openMessage(message.id);
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
const CACHE='ep-mail-v7';
|
const CACHE='ep-mail-v8';
|
||||||
const FILES=['./','./index.html','./styles.css','./branding.css','./app.js','./platform-bridge.js','./mail-ui.js','./productivity.js','./snooze-ui.js','./account-ui.js','./dav-ui.js','./shortcuts.js','./attachments.js','./pgp-ui.js','./pgp-mail-ui.js','./manifest.webmanifest','./icon.svg','./logo-ep-daylight.svg','./logo-ep-wasteland.svg'];
|
const FILES=['./','./index.html','./styles.css','./branding.css','./app.js','./platform-bridge.js','./mail-ui.js','./productivity.js','./snooze-ui.js','./account-ui.js','./dav-ui.js','./shortcuts.js','./attachments.js','./pgp-ui.js','./pgp-mail-ui.js','./manifest.webmanifest','./icon.svg','./logo-ep-daylight.svg','./logo-ep-wasteland.svg'];
|
||||||
self.addEventListener('install',event=>event.waitUntil(caches.open(CACHE).then(cache=>cache.addAll(FILES))));
|
self.addEventListener('install',event=>event.waitUntil(caches.open(CACHE).then(cache=>cache.addAll(FILES))));
|
||||||
self.addEventListener('activate',event=>event.waitUntil(caches.keys().then(keys=>Promise.all(keys.filter(k=>k!==CACHE).map(k=>caches.delete(k))))));
|
self.addEventListener('activate',event=>event.waitUntil(caches.keys().then(keys=>Promise.all(keys.filter(k=>k!==CACHE).map(k=>caches.delete(k))))));
|
||||||
|
|||||||
@@ -138,5 +138,6 @@ body.ep-daylight .row-check:checked{accent-color:#526a2c}
|
|||||||
.pgp-trust{margin-left:8px}
|
.pgp-trust{margin-left:8px}
|
||||||
|
|
||||||
.draft-delete{margin-top:4px;font-size:15px;opacity:.55}.draft-delete:hover{opacity:1;color:#b3261e}.pgp-prompt-box{width:min(380px,92vw)}
|
.draft-delete{margin-top:4px;font-size:15px;opacity:.55}.draft-delete:hover{opacity:1;color:#b3261e}.pgp-prompt-box{width:min(380px,92vw)}
|
||||||
|
.reader-body img{display:block;max-width:100%;height:auto;margin:12px 0;border-radius:6px}.reader-body table{max-width:100%;border-collapse:collapse}.reader-body th,.reader-body td{border:1px solid var(--line);padding:5px}.remote-image-notice{margin:14px 0 0;padding:12px;border:1px solid #d7a85c;border-radius:8px;background:#fff8e9;color:#664a23;font-size:10px;line-height:1.5}.remote-image-notice p{margin:0 0 8px}.remote-image-notice .reply-button{background:transparent;color:inherit;border-color:#d7a85c}body.ep-wasteland .remote-image-notice{background:#3a3022;color:#e6d1a8;border-color:#806b44}body.ep-daylight .remote-image-notice{background:#fff8e9;color:#664a23;border-color:#d7a85c}
|
||||||
|
|
||||||
.sidebar{overflow-y:auto}#mail-nav{overflow-y:auto;min-height:150px;flex:0 1 auto;scrollbar-width:thin;align-content:start}#custom-folders{display:contents}.folders-head{flex:none}.sidebar>:not(#mail-nav){flex-shrink:0}.folders-head+.folder-nav{margin-top:0}
|
.sidebar{overflow-y:auto}#mail-nav{overflow-y:auto;min-height:150px;flex:0 1 auto;scrollbar-width:thin;align-content:start}#custom-folders{display:contents}.folders-head{flex:none}.sidebar>:not(#mail-nav){flex-shrink:0}.folders-head+.folder-nav{margin-top:0}
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
const test = require('node:test');
|
||||||
|
const assert = require('node:assert/strict');
|
||||||
|
const { normalizeOutgoingAttachments, serializeOutgoingAttachments } = require('../desktop/mail-attachments.cjs');
|
||||||
|
|
||||||
|
test('normalizes attachment metadata and round-trips bytes through serialized drafts and sends', () => {
|
||||||
|
const bytes = Buffer.from([0, 1, 2, 127, 128, 255]);
|
||||||
|
const [file] = normalizeOutgoingAttachments([{
|
||||||
|
filename: 'folder\\report.bin',
|
||||||
|
contentType: 'APPLICATION/OCTET-STREAM',
|
||||||
|
size: 999,
|
||||||
|
contentBase64: bytes.toString('base64')
|
||||||
|
}]);
|
||||||
|
|
||||||
|
assert.equal(file.filename, 'report.bin');
|
||||||
|
assert.equal(file.contentType, 'application/octet-stream');
|
||||||
|
assert.equal(file.size, bytes.length);
|
||||||
|
assert.deepEqual(file.content, bytes);
|
||||||
|
const [serialized] = serializeOutgoingAttachments([file]);
|
||||||
|
assert.equal(serialized.contentBase64, bytes.toString('base64'));
|
||||||
|
assert.equal('content' in serialized, false);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('rejects malformed attachment data and unsafe content types', () => {
|
||||||
|
assert.throws(() => normalizeOutgoingAttachments({}), /attachment list is invalid/);
|
||||||
|
assert.throws(() => normalizeOutgoingAttachments([{ filename: 'x', contentBase64: '***=' }]), /contents.*invalid/);
|
||||||
|
assert.throws(() => normalizeOutgoingAttachments([{
|
||||||
|
filename: 'x',
|
||||||
|
contentType: 'text/plain\r\nBcc: bad@example.com',
|
||||||
|
contentBase64: ''
|
||||||
|
}]), /content type.*invalid/);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('uses fallback names and MIME types for empty metadata', () => {
|
||||||
|
const [file] = normalizeOutgoingAttachments([{ contentBase64: '' }]);
|
||||||
|
assert.equal(file.filename, 'attachment');
|
||||||
|
assert.equal(file.contentType, 'application/octet-stream');
|
||||||
|
assert.equal(file.size, 0);
|
||||||
|
});
|
||||||
+30
-1
@@ -75,6 +75,29 @@ test('encrypts to several recipients and each can decrypt', async () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('encrypts and signs outgoing attachments with the message body', async () => {
|
||||||
|
const alice = await actor('Alice', 'alice@example.com');
|
||||||
|
const bob = await actor('Bob', 'bob@example.com');
|
||||||
|
await exchange(alice, bob);
|
||||||
|
const contents = Buffer.from([0, 1, 2, 127, 128, 255]);
|
||||||
|
const { raw } = await alice.mail.build(sendOptions(alice, 'bob@example.com', {
|
||||||
|
encrypt: true,
|
||||||
|
sign: true,
|
||||||
|
passphrase: alice.passphrase,
|
||||||
|
attachments: [{ filename: 'binary-data.bin', contentType: 'application/octet-stream', content: contents }]
|
||||||
|
}));
|
||||||
|
assert.ok(!raw.toString('latin1').includes(contents.toString('latin1')));
|
||||||
|
|
||||||
|
const parsed = await simpleParser(raw);
|
||||||
|
const decrypted = await bob.mail.decrypt(parsed, { passphrase: bob.passphrase });
|
||||||
|
assert.equal(decrypted.parsed.text.trim(), 'Top secret ✓\nline two');
|
||||||
|
assert.equal(decrypted.parsed.attachments.length, 1);
|
||||||
|
assert.equal(decrypted.parsed.attachments[0].filename, 'binary-data.bin');
|
||||||
|
assert.equal(decrypted.parsed.attachments[0].contentType, 'application/octet-stream');
|
||||||
|
assert.deepEqual(decrypted.parsed.attachments[0].content, contents);
|
||||||
|
assert.equal(decrypted.signatures[0].status, 'valid');
|
||||||
|
});
|
||||||
|
|
||||||
test('detects tampered and corrupted encrypted messages', async () => {
|
test('detects tampered and corrupted encrypted messages', async () => {
|
||||||
const alice = await actor('Alice', 'alice@example.com');
|
const alice = await actor('Alice', 'alice@example.com');
|
||||||
const bob = await actor('Bob', 'bob@example.com');
|
const bob = await actor('Bob', 'bob@example.com');
|
||||||
@@ -112,10 +135,16 @@ test('signs without encrypting and verifies PGP/MIME signatures', async () => {
|
|||||||
const alice = await actor('Alice', 'alice@example.com');
|
const alice = await actor('Alice', 'alice@example.com');
|
||||||
const bob = await actor('Bob', 'bob@example.com');
|
const bob = await actor('Bob', 'bob@example.com');
|
||||||
await bob.keyStore.addContact({ armoredKey: await alice.keyStore.exportPublic(alice.key.fingerprint) });
|
await bob.keyStore.addContact({ armoredKey: await alice.keyStore.exportPublic(alice.key.fingerprint) });
|
||||||
const { raw } = await alice.mail.build(sendOptions(alice, 'bob@example.com', { sign: true, passphrase: alice.passphrase }));
|
const attachment = Buffer.from('signed attachment data');
|
||||||
|
const { raw } = await alice.mail.build(sendOptions(alice, 'bob@example.com', {
|
||||||
|
sign: true,
|
||||||
|
passphrase: alice.passphrase,
|
||||||
|
attachments: [{ filename: 'signed.txt', contentType: 'text/plain', content: attachment }]
|
||||||
|
}));
|
||||||
const parsed = await simpleParser(raw);
|
const parsed = await simpleParser(raw);
|
||||||
assert.equal(detect(parsed), 'signed-mime');
|
assert.equal(detect(parsed), 'signed-mime');
|
||||||
assert.match(parsed.text, /Top secret/);
|
assert.match(parsed.text, /Top secret/);
|
||||||
|
assert.deepEqual(parsed.attachments[0].content, attachment);
|
||||||
const [signature] = await bob.mail.verifySigned(parsed, raw);
|
const [signature] = await bob.mail.verifySigned(parsed, raw);
|
||||||
assert.equal(signature.status, 'valid');
|
assert.equal(signature.status, 'valid');
|
||||||
const altered = Buffer.from(raw.toString('latin1').replace('Content-Type: text/plain', 'Content-Type: text/plain'), 'latin1');
|
const altered = Buffer.from(raw.toString('latin1').replace('Content-Type: text/plain', 'Content-Type: text/plain'), 'latin1');
|
||||||
|
|||||||
+68
-1
@@ -4,8 +4,75 @@ const contacts=[];
|
|||||||
let activeMessage=1,activeFolder='Inbox',activeView='mail',query='',toastTimer,selectedIds=new Set();
|
let activeMessage=1,activeFolder='Inbox',activeView='mail',query='',toastTimer,selectedIds=new Set();
|
||||||
const $=s=>document.querySelector(s), $$=s=>[...document.querySelectorAll(s)];
|
const $=s=>document.querySelector(s), $$=s=>[...document.querySelectorAll(s)];
|
||||||
function esc(x){return String(x).replace(/[&<>"']/g,c=>({'&':'&','<':'<','>':'>','"':'"',"'":'''}[c]))}
|
function esc(x){return String(x).replace(/[&<>"']/g,c=>({'&':'&','<':'<','>':'>','"':'"',"'":'''}[c]))}
|
||||||
|
function safeRemoteImageUrl(value){if(typeof value!=='string'||value.length>2048)return null;try{const url=new URL(value);return url.protocol==='https:'&&url.hostname&&!url.username&&!url.password?url.href:null}catch{return null}}
|
||||||
|
function sanitizeMailHtml(value){
|
||||||
|
const html=String(value||'').slice(0,100000);
|
||||||
|
const inertImages=html
|
||||||
|
.replace(/<(script|style|iframe|frame|object|embed|svg|math|form|noscript|template|video|audio|source|picture|track)\b[\s\S]*?<\/\1\s*>/gi,'')
|
||||||
|
.replace(/<(?:script|style|iframe|frame|object|embed|svg|math|form|noscript|template|video|audio|source|picture|track|link|base|meta)\b[^>]*>/gi,'')
|
||||||
|
.replace(/<!--[\s\S]*?-->/g,'')
|
||||||
|
.replace(/<img\b[^>]*>/gi,tag=>{
|
||||||
|
const source=tag.match(/\bsrc\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s/>]+))/i);
|
||||||
|
const alt=tag.match(/\balt\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s/>]+))/i);
|
||||||
|
const remote=source&&(source[1]||source[2]||source[3]||'').trim();
|
||||||
|
const alternative=alt&&(alt[1]||alt[2]||alt[3]||'');
|
||||||
|
return `<img${remote?` data-remote-src="${esc(remote)}"`:''}${alternative?` alt="${esc(alternative)}"`:''}>`;
|
||||||
|
})
|
||||||
|
.replace(/\s(?:src|srcset|background|poster|action|formaction|href|xlink:href|srcdoc|dynsrc|lowsrc|style)\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/gi,'');
|
||||||
|
const document=new DOMParser().parseFromString(inertImages,'text/html');
|
||||||
|
const allowed=new Set(['a','p','div','span','br','hr','h1','h2','h3','h4','h5','h6','b','strong','i','em','u','s','del','blockquote','pre','code','ul','ol','li','table','thead','tbody','tfoot','tr','th','td','img']);
|
||||||
|
const discard=new Set(['script','style','iframe','frame','object','embed','svg','math','form','input','button','textarea','select','option','link','base','meta','video','audio','source','picture','track']);
|
||||||
|
let remoteImageCount=0;
|
||||||
|
const clean=parent=>{
|
||||||
|
for(const node of [...parent.childNodes]){
|
||||||
|
if(node.nodeType!==Node.ELEMENT_NODE){if(node.nodeType!==Node.TEXT_NODE)node.remove();continue}
|
||||||
|
const name=node.localName.toLowerCase();
|
||||||
|
if(discard.has(name)){node.remove();continue}
|
||||||
|
if(!allowed.has(name)){node.replaceWith(...node.childNodes);continue}
|
||||||
|
for(const attribute of [...node.attributes]){
|
||||||
|
const key=attribute.name.toLowerCase();
|
||||||
|
const keep=(name==='img'&&(key==='alt'||key==='data-remote-src'))||
|
||||||
|
(name==='td'||name==='th')&&['colspan','rowspan'].includes(key)&&/^\d{1,2}$/.test(attribute.value);
|
||||||
|
if(!keep)node.removeAttribute(attribute.name);
|
||||||
|
}
|
||||||
|
if(name==='img'){
|
||||||
|
const url=safeRemoteImageUrl(node.getAttribute('data-remote-src'));
|
||||||
|
if(url){node.setAttribute('data-remote-src',url);remoteImageCount+=1}
|
||||||
|
else node.removeAttribute('data-remote-src');
|
||||||
|
}
|
||||||
|
clean(node);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
clean(document.body);
|
||||||
|
return {html:document.body.innerHTML,remoteImageCount};
|
||||||
|
}
|
||||||
function renderList(){let rows=messages.filter(m=>{if(activeFolder==='Starred'&&!m.star)return false;if(activeFolder==='Inbox'&&m.archived)return false;if(activeFolder==='Archive'&&!m.archived)return false;if(activeFolder==='Trash'&&!m.deleted)return false;if(activeFolder==='Sent'&&!m.sent)return false;if(activeFolder==='Drafts')return false;if(activeFolder==='Snoozed')return false;if(m.deleted&&activeFolder!=='Trash')return false;return !query||`${m.sender} ${m.email} ${m.subject} ${m.snippet}`.toLowerCase().includes(query.toLowerCase())});$('#message-list').innerHTML=rows.length?rows.map(m=>`<div class="message ${m.unread?'unread':''} ${m.id===activeMessage?'selected':''}" data-id="${m.id}"><input class="row-check" type="checkbox" aria-label="Select message" ${selectedIds.has(m.id)?'checked':''}><div class="contact-avatar" style="background:${m.color}">${m.initials}</div><div class="message-body"><div class="sender">${esc(m.sender)}</div><div class="subject">${esc(m.subject)}</div><div class="snippet">${esc(m.snippet)}</div></div><div class="message-meta"><span class="time">${esc(m.time)}</span><button class="star ${m.star?'on':''}" aria-label="${m.star?'Unstar':'Star'}">${m.star?'★':'☆'}</button></div></div>`).join(''):`<div class="reader-empty"><div><div class="empty-icon">⌕</div><h3>No messages here</h3><p>Try another folder or search.</p></div></div>`;$$('.message').forEach(row=>{row.addEventListener('click',e=>{if(e.target.closest('.row-check')){const id=+row.dataset.id;selectedIds.has(id)?selectedIds.delete(id):selectedIds.add(id);return}if(e.target.closest('.star')){const m=messages.find(x=>x.id===+row.dataset.id);m.star=!m.star;renderList();return}openMessage(+row.dataset.id)});});if(!rows.length)$('#reader-pane').innerHTML=emptyReader()}
|
function renderList(){let rows=messages.filter(m=>{if(activeFolder==='Starred'&&!m.star)return false;if(activeFolder==='Inbox'&&m.archived)return false;if(activeFolder==='Archive'&&!m.archived)return false;if(activeFolder==='Trash'&&!m.deleted)return false;if(activeFolder==='Sent'&&!m.sent)return false;if(activeFolder==='Drafts')return false;if(activeFolder==='Snoozed')return false;if(m.deleted&&activeFolder!=='Trash')return false;return !query||`${m.sender} ${m.email} ${m.subject} ${m.snippet}`.toLowerCase().includes(query.toLowerCase())});$('#message-list').innerHTML=rows.length?rows.map(m=>`<div class="message ${m.unread?'unread':''} ${m.id===activeMessage?'selected':''}" data-id="${m.id}"><input class="row-check" type="checkbox" aria-label="Select message" ${selectedIds.has(m.id)?'checked':''}><div class="contact-avatar" style="background:${m.color}">${m.initials}</div><div class="message-body"><div class="sender">${esc(m.sender)}</div><div class="subject">${esc(m.subject)}</div><div class="snippet">${esc(m.snippet)}</div></div><div class="message-meta"><span class="time">${esc(m.time)}</span><button class="star ${m.star?'on':''}" aria-label="${m.star?'Unstar':'Star'}">${m.star?'★':'☆'}</button></div></div>`).join(''):`<div class="reader-empty"><div><div class="empty-icon">⌕</div><h3>No messages here</h3><p>Try another folder or search.</p></div></div>`;$$('.message').forEach(row=>{row.addEventListener('click',e=>{if(e.target.closest('.row-check')){const id=+row.dataset.id;selectedIds.has(id)?selectedIds.delete(id):selectedIds.add(id);return}if(e.target.closest('.star')){const m=messages.find(x=>x.id===+row.dataset.id);m.star=!m.star;renderList();return}openMessage(+row.dataset.id)});});if(!rows.length)$('#reader-pane').innerHTML=emptyReader()}
|
||||||
function openMessage(id){activeMessage=id;const m=messages.find(x=>x.id===id);if(!m)return;m.unread=false;renderList();$('#reader-pane').innerHTML=`<div class="reader-header"><div class="reader-topline"><div class="reader-tags">${m.tags.map((t,i)=>`<span class="tag ${i?'green':''}">${esc(t)}</span>`).join('')}</div><div class="reader-tools"><button class="icon-button" id="reader-archive" title="Archive">▱</button><button class="icon-button" id="reader-delete" title="Delete">⌫</button><button class="icon-button" title="More">···</button></div></div><h2 class="reader-subject">${esc(m.subject)}</h2><div class="sender-row"><div class="contact-avatar" style="background:${m.color}">${m.initials}</div><div class="sender-details"><strong>${esc(m.sender)}</strong><span>${esc(m.email)} · to me</span></div><span class="message-date">${esc(m.date)}</span><button class="icon-button" title="Star" id="reader-star">${m.star?'★':'☆'}</button></div></div><div class="reader-body">${m.body.map(p=>`<p>${esc(p)}</p>`).join('')}<p class="signoff">${esc(m.signature||m.sender)}</p>${(m.attachments?.length ? m.attachments : m.attachment ? [{filename:m.attachment,size:m.size}] : []).map(file=>`<div class="attachment"><div class="file-icon">${file.filename.toLowerCase().endsWith('.pdf')?'▤':'▧'}</div><div class="attachment-info"><strong title="${esc(file.filename)}">${esc(file.filename)}</strong><small>${file.size ? (typeof file.size==='string' ? esc(file.size) : `${(file.size/1048576).toFixed(1)} MB`) : 'Attachment'}</small></div><button class="download" data-filename="${esc(file.filename)}" title="Download ${esc(file.filename)}">↓</button></div>`).join('')}</div><div class="reply-bar"><button class="reply-button primary" id="reply">↶ Reply</button><button class="reply-button" id="forward">↗ Forward</button></div>`;$('#reader-archive').onclick=()=>{m.archived=true;toast('Moved to Archive');renderList();$('#reader-pane').innerHTML=emptyReader()};$('#reader-delete').onclick=()=>{m.deleted=true;toast('Moved to Trash');renderList();$('#reader-pane').innerHTML=emptyReader()};$('#reader-star').onclick=()=>{m.star=!m.star;renderList();openMessage(id)};$('#reply').onclick=()=>showCompose(m);$('#forward').onclick=()=>showCompose(m,true)}
|
function openMessage(id){
|
||||||
|
activeMessage=id;
|
||||||
|
const m=messages.find(x=>x.id===id);
|
||||||
|
if(!m)return;
|
||||||
|
m.unread=false;
|
||||||
|
renderList();
|
||||||
|
let safeHtml={html:'',remoteImageCount:0};
|
||||||
|
if(m.html)try{safeHtml=sanitizeMailHtml(m.html)}catch(error){console.error('Could not sanitize message HTML; showing plain text instead.',error)}
|
||||||
|
const body=safeHtml.html?safeHtml.html:`${m.body.map(p=>`<p>${esc(p)}</p>`).join('')}<p class="signoff">${esc(m.signature||m.sender)}</p>`;
|
||||||
|
const imageNotice=safeHtml.remoteImageCount?`<section class="remote-image-notice" role="status"><p>This message contains ${safeHtml.remoteImageCount} remote image${safeHtml.remoteImageCount===1?'':'s'}. Loading them can reveal your network address and that you opened this message to the image host.</p><button type="button" class="reply-button" id="load-remote-images">Load images for this message</button></section>`:'';
|
||||||
|
const attachments=(m.attachments?.length?m.attachments:m.attachment?[{filename:m.attachment,size:m.size}]:[]).map(file=>`<div class="attachment"><div class="file-icon">${file.filename.toLowerCase().endsWith('.pdf')?'▤':'▧'}</div><div class="attachment-info"><strong title="${esc(file.filename)}">${esc(file.filename)}</strong><small>${file.size?(typeof file.size==='string'?esc(file.size):`${(file.size/1048576).toFixed(1)} MB`):'Attachment'}</small></div><button class="download" data-filename="${esc(file.filename)}" title="Download ${esc(file.filename)}">↓</button></div>`).join('');
|
||||||
|
$('#reader-pane').innerHTML=`<div class="reader-header"><div class="reader-topline"><div class="reader-tags">${m.tags.map((t,i)=>`<span class="tag ${i?'green':''}">${esc(t)}</span>`).join('')}</div><div class="reader-tools"><button class="icon-button" id="reader-archive" title="Archive">▱</button><button class="icon-button" id="reader-delete" title="Delete">⌫</button><button class="icon-button" title="More">···</button></div></div><h2 class="reader-subject">${esc(m.subject)}</h2><div class="sender-row"><div class="contact-avatar" style="background:${m.color}">${m.initials}</div><div class="sender-details"><strong>${esc(m.sender)}</strong><span>${esc(m.email)} · to me</span></div><span class="message-date">${esc(m.date)}</span><button class="icon-button" title="Star" id="reader-star">${m.star?'★':'☆'}</button></div></div>${imageNotice}<div class="reader-body">${body}${attachments}</div><div class="reply-bar"><button class="reply-button primary" id="reply">↶ Reply</button><button class="reply-button" id="forward">↗ Forward</button></div>`;
|
||||||
|
$('#load-remote-images')?.addEventListener('click',()=>{
|
||||||
|
$('#reader-pane').querySelectorAll('.reader-body img[data-remote-src]').forEach(image=>{
|
||||||
|
const url=safeRemoteImageUrl(image.getAttribute('data-remote-src'));
|
||||||
|
image.removeAttribute('data-remote-src');
|
||||||
|
if(url)image.src=url;
|
||||||
|
});
|
||||||
|
$('.remote-image-notice')?.remove();
|
||||||
|
});
|
||||||
|
$('#reader-archive').onclick=()=>{m.archived=true;toast('Moved to Archive');renderList();$('#reader-pane').innerHTML=emptyReader()};
|
||||||
|
$('#reader-delete').onclick=()=>{m.deleted=true;toast('Moved to Trash');renderList();$('#reader-pane').innerHTML=emptyReader()};
|
||||||
|
$('#reader-star').onclick=()=>{m.star=!m.star;renderList();openMessage(id)};
|
||||||
|
$('#reply').onclick=()=>showCompose(m);
|
||||||
|
$('#forward').onclick=()=>showCompose(m,true);
|
||||||
|
}
|
||||||
function emptyReader(){return `<div class="reader-empty"><div><div class="empty-icon">✉</div><h3>Your inbox, at your pace</h3><p>Select a message to read it here.</p></div></div>`}
|
function emptyReader(){return `<div class="reader-empty"><div><div class="empty-icon">✉</div><h3>Your inbox, at your pace</h3><p>Select a message to read it here.</p></div></div>`}
|
||||||
function toast(s){const el=$('#toast');el.textContent=s;el.classList.add('visible');clearTimeout(toastTimer);toastTimer=setTimeout(()=>el.classList.remove('visible'),2300)}
|
function toast(s){const el=$('#toast');el.textContent=s;el.classList.add('visible');clearTimeout(toastTimer);toastTimer=setTimeout(()=>el.classList.remove('visible'),2300)}
|
||||||
function showCompose(reply,forward=false){const root=$('#modal-root');root.innerHTML=`<div class="modal-overlay"><div class="compose-modal"><div class="modal-head"><span>${reply?(forward?'Forward message':'Reply to message'):'New message'}</span><button class="modal-close" aria-label="Close">×</button></div><div class="compose-fields"><label class="compose-line"><span>To</span><input id="compose-to" placeholder="name@example.com" value="${reply?esc(forward?'':reply.email):''}"></label><label class="compose-line"><span>Cc</span><input id="compose-cc" placeholder="Add Cc"></label><input id="compose-subject" class="compose-subject" placeholder="Subject" value="${reply?esc((forward?'Fwd: ':'Re: ')+reply.subject):''}"></div><textarea class="compose-body" id="compose-body" placeholder="Write something thoughtful…">${reply&&!forward?'\n\nOn '+reply.date+', '+reply.sender+' wrote:\n> '+reply.snippet:''}</textarea><div class="compose-footer"><button class="discard" id="discard">Discard</button><button class="send-button" id="send">Send ↗</button></div></div></div>`;const close=()=>root.innerHTML='';$('.modal-close').onclick=close;$('#discard').onclick=close;$('.modal-overlay').addEventListener('click',e=>{if(e.target.classList.contains('modal-overlay'))close()});$('#send').onclick=()=>{const to=$('#compose-to').value.trim();if(!to){$('#compose-to').focus();toast('Add a recipient to send your message');return}const subject=$('#compose-subject').value.trim()||'(no subject)';const body=$('#compose-body').value;messages.unshift({id:Date.now(),initials:(profileSettings.name||connectedMailAccount?.email?.split('@')[0]||'Me').split(/\\s+/).map(x=>x[0]).join('').slice(0,2).toUpperCase(),color:'#dce9dd',sender:(profileSettings.name||connectedMailAccount?.email?.split('@')[0]||'Me'),email:(connectedMailAccount?.email||''),subject,snippet:body||'No message text',time:'Just now',date:'Today',unread:false,star:false,sent:true,tags:['Sent'],body:body.split('\n').filter(Boolean)});close();toast('Message sent');renderList()};$('#compose-to').focus()}
|
function showCompose(reply,forward=false){const root=$('#modal-root');root.innerHTML=`<div class="modal-overlay"><div class="compose-modal"><div class="modal-head"><span>${reply?(forward?'Forward message':'Reply to message'):'New message'}</span><button class="modal-close" aria-label="Close">×</button></div><div class="compose-fields"><label class="compose-line"><span>To</span><input id="compose-to" placeholder="name@example.com" value="${reply?esc(forward?'':reply.email):''}"></label><label class="compose-line"><span>Cc</span><input id="compose-cc" placeholder="Add Cc"></label><input id="compose-subject" class="compose-subject" placeholder="Subject" value="${reply?esc((forward?'Fwd: ':'Re: ')+reply.subject):''}"></div><textarea class="compose-body" id="compose-body" placeholder="Write something thoughtful…">${reply&&!forward?'\n\nOn '+reply.date+', '+reply.sender+' wrote:\n> '+reply.snippet:''}</textarea><div class="compose-footer"><button class="discard" id="discard">Discard</button><button class="send-button" id="send">Send ↗</button></div></div></div>`;const close=()=>root.innerHTML='';$('.modal-close').onclick=close;$('#discard').onclick=close;$('.modal-overlay').addEventListener('click',e=>{if(e.target.classList.contains('modal-overlay'))close()});$('#send').onclick=()=>{const to=$('#compose-to').value.trim();if(!to){$('#compose-to').focus();toast('Add a recipient to send your message');return}const subject=$('#compose-subject').value.trim()||'(no subject)';const body=$('#compose-body').value;messages.unshift({id:Date.now(),initials:(profileSettings.name||connectedMailAccount?.email?.split('@')[0]||'Me').split(/\\s+/).map(x=>x[0]).join('').slice(0,2).toUpperCase(),color:'#dce9dd',sender:(profileSettings.name||connectedMailAccount?.email?.split('@')[0]||'Me'),email:(connectedMailAccount?.email||''),subject,snippet:body||'No message text',time:'Just now',date:'Today',unread:false,star:false,sent:true,tags:['Sent'],body:body.split('\n').filter(Boolean)});close();toast('Message sent');renderList()};$('#compose-to').focus()}
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<meta name="theme-color" content="#f4f5f1">
|
<meta name="theme-color" content="#f4f5f1">
|
||||||
<meta name="description" content="ep-mail: Eternity Project mail, calendar, and contacts for Windows and Linux.">
|
<meta name="description" content="ep-mail: Eternity Project mail, calendar, and contacts for Windows and Linux.">
|
||||||
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self'; connect-src 'none'">
|
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; font-src 'self'; connect-src 'none'; frame-src 'none'; object-src 'none'; base-uri 'none'; form-action 'none'">
|
||||||
<title>ep-mail</title>
|
<title>ep-mail</title>
|
||||||
<link rel="manifest" href="manifest.webmanifest">
|
<link rel="manifest" href="manifest.webmanifest">
|
||||||
<link rel="stylesheet" href="styles.css">
|
<link rel="stylesheet" href="styles.css">
|
||||||
|
|||||||
+81
-2
@@ -398,6 +398,83 @@ function setupDraftComposer() {
|
|||||||
const modal = root.querySelector('.compose-modal');
|
const modal = root.querySelector('.compose-modal');
|
||||||
if (!modal) return;
|
if (!modal) return;
|
||||||
modal.dataset.draftId = draft?.id || '';
|
modal.dataset.draftId = draft?.id || '';
|
||||||
|
let attachments = Array.isArray(draft?.attachments) ? draft.attachments : [];
|
||||||
|
modal._composeAttachments = attachments;
|
||||||
|
const fields = modal.querySelector('.compose-fields');
|
||||||
|
const attachmentRow = document.createElement('div');
|
||||||
|
attachmentRow.className = 'compose-line';
|
||||||
|
const attachmentLabel = document.createElement('span');
|
||||||
|
attachmentLabel.textContent = 'Attachments';
|
||||||
|
const attachmentControls = document.createElement('div');
|
||||||
|
attachmentControls.className = 'compose-attachments';
|
||||||
|
const attachmentInput = document.createElement('input');
|
||||||
|
attachmentInput.type = 'file';
|
||||||
|
attachmentInput.multiple = true;
|
||||||
|
attachmentInput.accept = '*/*';
|
||||||
|
attachmentInput.hidden = true;
|
||||||
|
attachmentInput.setAttribute('aria-label', 'Choose files to attach');
|
||||||
|
const attachButton = document.createElement('button');
|
||||||
|
attachButton.type = 'button';
|
||||||
|
attachButton.className = 'discard';
|
||||||
|
attachButton.textContent = 'Attach files…';
|
||||||
|
const attachmentList = document.createElement('div');
|
||||||
|
attachmentList.className = 'attachment-list';
|
||||||
|
attachmentList.setAttribute('aria-live', 'polite');
|
||||||
|
attachmentControls.append(attachButton, attachmentInput);
|
||||||
|
attachmentRow.append(attachmentLabel, attachmentControls);
|
||||||
|
fields.append(attachmentRow, attachmentList);
|
||||||
|
attachButton.onclick = () => attachmentInput.click();
|
||||||
|
const renderAttachments = () => {
|
||||||
|
attachmentList.replaceChildren();
|
||||||
|
attachments.forEach((file, index) => {
|
||||||
|
const row = document.createElement('div');
|
||||||
|
row.className = 'attachment-row';
|
||||||
|
const name = document.createElement('strong');
|
||||||
|
name.textContent = file.filename;
|
||||||
|
const size = document.createElement('small');
|
||||||
|
size.textContent = `${((file.size || 0) / 1048576).toFixed(2)} MB`;
|
||||||
|
const remove = document.createElement('button');
|
||||||
|
remove.type = 'button';
|
||||||
|
remove.className = 'discard';
|
||||||
|
remove.textContent = 'Remove';
|
||||||
|
remove.setAttribute('aria-label', `Remove ${file.filename}`);
|
||||||
|
remove.onclick = () => {
|
||||||
|
attachments.splice(index, 1);
|
||||||
|
renderAttachments();
|
||||||
|
void persist().catch(error => toast(error.message || 'Could not save the draft'));
|
||||||
|
};
|
||||||
|
row.append(name, size, remove);
|
||||||
|
attachmentList.append(row);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
attachmentInput.onchange = async () => {
|
||||||
|
attachButton.disabled = true;
|
||||||
|
try {
|
||||||
|
const selected = [];
|
||||||
|
for (const file of attachmentInput.files) {
|
||||||
|
const bytes = new Uint8Array(await file.arrayBuffer());
|
||||||
|
let binary = '';
|
||||||
|
for (let offset = 0; offset < bytes.length; offset += 0x8000) {
|
||||||
|
binary += String.fromCharCode(...bytes.subarray(offset, offset + 0x8000));
|
||||||
|
}
|
||||||
|
selected.push({
|
||||||
|
filename: file.name,
|
||||||
|
contentType: file.type || 'application/octet-stream',
|
||||||
|
size: file.size,
|
||||||
|
contentBase64: btoa(binary)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
attachments.push(...selected);
|
||||||
|
renderAttachments();
|
||||||
|
await persist();
|
||||||
|
} catch (error) {
|
||||||
|
toast(error.message || 'Could not add the selected files');
|
||||||
|
} finally {
|
||||||
|
attachmentInput.value = '';
|
||||||
|
attachButton.disabled = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
renderAttachments();
|
||||||
if (draft) {
|
if (draft) {
|
||||||
$('#compose-to').value = draft.to || '';
|
$('#compose-to').value = draft.to || '';
|
||||||
$('#compose-cc').value = draft.cc || '';
|
$('#compose-cc').value = draft.cc || '';
|
||||||
@@ -420,9 +497,10 @@ function setupDraftComposer() {
|
|||||||
to: $('#compose-to').value,
|
to: $('#compose-to').value,
|
||||||
cc: $('#compose-cc').value,
|
cc: $('#compose-cc').value,
|
||||||
subject: $('#compose-subject').value,
|
subject: $('#compose-subject').value,
|
||||||
text: $('#compose-body').value
|
text: $('#compose-body').value,
|
||||||
|
attachments
|
||||||
};
|
};
|
||||||
if (!Object.values(values).some(value => typeof value === 'string' && value.trim())) return;
|
if (!Object.values(values).some(value => typeof value === 'string' && value.trim()) && !attachments.length) return;
|
||||||
modal.dataset.draftId = values.id;
|
modal.dataset.draftId = values.id;
|
||||||
const result = await window.daybreakMail.saveDraft(values);
|
const result = await window.daybreakMail.saveDraft(values);
|
||||||
modal.dataset.draftId = result.id;
|
modal.dataset.draftId = result.id;
|
||||||
@@ -668,6 +746,7 @@ if (window.daybreakMail) {
|
|||||||
cc: $('#compose-cc').value,
|
cc: $('#compose-cc').value,
|
||||||
subject: $('#compose-subject').value.trim(),
|
subject: $('#compose-subject').value.trim(),
|
||||||
text: $('#compose-body').value,
|
text: $('#compose-body').value,
|
||||||
|
attachments: $('#modal-root .compose-modal')?._composeAttachments || [],
|
||||||
displayName: connectedMailAccount.displayName || profileSettings.name,
|
displayName: connectedMailAccount.displayName || profileSettings.name,
|
||||||
...(pgp ? { pgp } : {})
|
...(pgp ? { pgp } : {})
|
||||||
});
|
});
|
||||||
|
|||||||
+1
-1
@@ -92,7 +92,7 @@ async function pgpUnlockMessage(message, interactive) {
|
|||||||
}
|
}
|
||||||
if (result.ok) {
|
if (result.ok) {
|
||||||
Object.assign(message, {
|
Object.assign(message, {
|
||||||
body: result.body, links: result.links, attachments: result.attachments, attachment: result.attachment, size: result.size,
|
body: result.body, html: result.html, links: result.links, attachments: result.attachments, attachment: result.attachment, size: result.size,
|
||||||
snippet: 'Encrypted message', pgpDecrypted: true, pgpResult: { signatures: result.signatures, attachedKeys: result.attachedKeys }
|
snippet: 'Encrypted message', pgpDecrypted: true, pgpResult: { signatures: result.signatures, attachedKeys: result.attachedKeys }
|
||||||
});
|
});
|
||||||
if (activeMessage === message.id) openMessage(message.id);
|
if (activeMessage === message.id) openMessage(message.id);
|
||||||
|
|||||||
+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();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const CACHE='ep-mail-v7';
|
const CACHE='ep-mail-v8';
|
||||||
const FILES=['./','./index.html','./styles.css','./branding.css','./app.js','./platform-bridge.js','./mail-ui.js','./productivity.js','./snooze-ui.js','./account-ui.js','./dav-ui.js','./shortcuts.js','./attachments.js','./pgp-ui.js','./pgp-mail-ui.js','./manifest.webmanifest','./icon.svg','./logo-ep-daylight.svg','./logo-ep-wasteland.svg'];
|
const FILES=['./','./index.html','./styles.css','./branding.css','./app.js','./platform-bridge.js','./mail-ui.js','./productivity.js','./snooze-ui.js','./account-ui.js','./dav-ui.js','./shortcuts.js','./attachments.js','./pgp-ui.js','./pgp-mail-ui.js','./manifest.webmanifest','./icon.svg','./logo-ep-daylight.svg','./logo-ep-wasteland.svg'];
|
||||||
self.addEventListener('install',event=>event.waitUntil(caches.open(CACHE).then(cache=>cache.addAll(FILES))));
|
self.addEventListener('install',event=>event.waitUntil(caches.open(CACHE).then(cache=>cache.addAll(FILES))));
|
||||||
self.addEventListener('activate',event=>event.waitUntil(caches.keys().then(keys=>Promise.all(keys.filter(k=>k!==CACHE).map(k=>caches.delete(k))))));
|
self.addEventListener('activate',event=>event.waitUntil(caches.keys().then(keys=>Promise.all(keys.filter(k=>k!==CACHE).map(k=>caches.delete(k))))));
|
||||||
|
|||||||
@@ -138,5 +138,6 @@ body.ep-daylight .row-check:checked{accent-color:#526a2c}
|
|||||||
.pgp-trust{margin-left:8px}
|
.pgp-trust{margin-left:8px}
|
||||||
|
|
||||||
.draft-delete{margin-top:4px;font-size:15px;opacity:.55}.draft-delete:hover{opacity:1;color:#b3261e}.pgp-prompt-box{width:min(380px,92vw)}
|
.draft-delete{margin-top:4px;font-size:15px;opacity:.55}.draft-delete:hover{opacity:1;color:#b3261e}.pgp-prompt-box{width:min(380px,92vw)}
|
||||||
|
.reader-body img{display:block;max-width:100%;height:auto;margin:12px 0;border-radius:6px}.reader-body table{max-width:100%;border-collapse:collapse}.reader-body th,.reader-body td{border:1px solid var(--line);padding:5px}.remote-image-notice{margin:14px 0 0;padding:12px;border:1px solid #d7a85c;border-radius:8px;background:#fff8e9;color:#664a23;font-size:10px;line-height:1.5}.remote-image-notice p{margin:0 0 8px}.remote-image-notice .reply-button{background:transparent;color:inherit;border-color:#d7a85c}body.ep-wasteland .remote-image-notice{background:#3a3022;color:#e6d1a8;border-color:#806b44}body.ep-daylight .remote-image-notice{background:#fff8e9;color:#664a23;border-color:#d7a85c}
|
||||||
|
|
||||||
.sidebar{overflow-y:auto}#mail-nav{overflow-y:auto;min-height:150px;flex:0 1 auto;scrollbar-width:thin;align-content:start}#custom-folders{display:contents}.folders-head{flex:none}.sidebar>:not(#mail-nav){flex-shrink:0}.folders-head+.folder-nav{margin-top:0}
|
.sidebar{overflow-y:auto}#mail-nav{overflow-y:auto;min-height:150px;flex:0 1 auto;scrollbar-width:thin;align-content:start}#custom-folders{display:contents}.folders-head{flex:none}.sidebar>:not(#mail-nav){flex-shrink:0}.folders-head+.folder-nav{margin-top:0}
|
||||||
|
|||||||
Reference in New Issue
Block a user