Compare commits
5
Commits
8a798fec6b
...
V0.6.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bb34eedb44 | ||
|
|
93ff651e9d | ||
|
|
96c7b6966b | ||
|
|
d0e2ce26bc | ||
|
|
4ec578b072 |
@@ -0,0 +1 @@
|
|||||||
|
scripts/build-linux-wsl.sh text eol=lf
|
||||||
Vendored
+3
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"java.configuration.updateBuildConfiguration": "interactive"
|
||||||
|
}
|
||||||
@@ -6,6 +6,12 @@ An Eternity Project mail client with **Eternity Daylight**, **Wasteland**, and E
|
|||||||
|
|
||||||
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 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/`.
|
||||||
|
|
||||||
|
On Windows, `npm run build` runs `scripts\build.ps1`, building the Android debug APK and Windows portable executable. For all targets, run `npm run build:all`: it also builds the Windows installer and uses the default WSL distribution to build the Linux AppImage and Debian package. To select a distribution, run `powershell -NoProfile -ExecutionPolicy Bypass -File scripts\build-all.ps1 -WslDistribution Ubuntu`. WSL needs Linux Node.js, npm and tar, plus the usual Electron packaging prerequisites and network access to install the locked dependencies. Linux builds use a temporary Linux filesystem workspace, then copy both packages into `release\`. Both build scripts preserve the legacy `ep-mail <version>.apk` copy of the debug APK; it is **not a signed release APK** and will overwrite a same-named signed APK. Use `npm run android:release-apk` afterwards when a signed release is needed.
|
||||||
|
|
||||||
|
See [SIGNING.md](./SIGNING.md) for private Android and Windows signing, verification, key backups, and the Android debug-to-release transition.
|
||||||
|
|
||||||
|
The message list groups related messages using Message-ID, References, and In-Reply-To headers. Expand or collapse each conversation to access its individual messages; collapsing deselects hidden messages, and bulk selection applies to visible rows. Grouping covers only the messages currently loaded in the selected folder or search results, not other folders or unloaded pages. Older offline cache entries gain threading information when refreshed.
|
||||||
|
|
||||||
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.
|
||||||
|
|
||||||
### Google and Microsoft OAuth2
|
### Google and Microsoft OAuth2
|
||||||
@@ -27,6 +33,8 @@ npm run android:apk
|
|||||||
|
|
||||||
The debug APK is written to `android/app/build/outputs/apk/debug/app-debug.apk` and copied to `release/ep-mail <version>-debug.apk`; install it on a connected test device with `adb install -r android/app/build/outputs/apk/debug/app-debug.apk`. For a signed release, configure `EP_MAIL_ANDROID_STORE_FILE` (an absolute path), `EP_MAIL_ANDROID_STORE_PASSWORD`, `EP_MAIL_ANDROID_KEY_ALIAS`, and `EP_MAIL_ANDROID_KEY_PASSWORD` in the build environment, then run `npm run android:release-apk`. The signed artifact is copied to `release/ep-mail <version>.apk`; keep keystores and passwords out of the repository and logs. The first account enables a visible, ongoing foreground-service notification while IMAP IDLE checks for new mail; Android also runs a network-constrained periodic reconciliation. Notification sender/subject details are hidden by default; enabling them in Settings still keeps lock-screen previews redacted. Android may delay or stop background activity after force-stop, prolonged device restrictions, or vendor battery management.
|
The debug APK is written to `android/app/build/outputs/apk/debug/app-debug.apk` and copied to `release/ep-mail <version>-debug.apk`; install it on a connected test device with `adb install -r android/app/build/outputs/apk/debug/app-debug.apk`. For a signed release, configure `EP_MAIL_ANDROID_STORE_FILE` (an absolute path), `EP_MAIL_ANDROID_STORE_PASSWORD`, `EP_MAIL_ANDROID_KEY_ALIAS`, and `EP_MAIL_ANDROID_KEY_PASSWORD` in the build environment, then run `npm run android:release-apk`. The signed artifact is copied to `release/ep-mail <version>.apk`; keep keystores and passwords out of the repository and logs. The first account enables a visible, ongoing foreground-service notification while IMAP IDLE checks for new mail; Android also runs a network-constrained periodic reconciliation. Notification sender/subject details are hidden by default; enabling them in Settings still keeps lock-screen previews redacted. Android may delay or stop background activity after force-stop, prolonged device restrictions, or vendor battery management.
|
||||||
|
|
||||||
|
For Android OpenPGP testing, transfer a passphrase-protected, ASCII-armored private key (`.asc`) securely to the device. In **Settings → Encryption keys**, enter its passphrase, select **Import private key from file…**, and choose the file (maximum 200,000 bytes). The file picker is unavailable while app lock is enabled because leaving the app can reset the import; paste the key instead, or temporarily disable app lock and re-enable it after importing. Compare the imported fingerprint with the original, then remove the transferred file and clear the clipboard if used. Keep a separate secure backup of the key and its revocation certificate.
|
||||||
|
|
||||||
Android builds use the Gradle wrapper and Android Gradle Plugin 9.4.0. Capacitor's generated modules are aligned to that plugin version during the build; the legacy Android DSL and external Kotlin plugin remain enabled for compatibility and must be migrated before upgrading to AGP 10.
|
Android builds use the Gradle wrapper and Android Gradle Plugin 9.4.0. Capacitor's generated modules are aligned to that plugin version during the build; the legacy Android DSL and external Kotlin plugin remain enabled for compatibility and must be migrated before upgrading to AGP 10.
|
||||||
|
|
||||||
On Android, previously cached folder messages appear while the mailbox refreshes; a folder without cached messages still needs to load from the server. Folder discovery and message actions run separately from cached-folder loading. The app stays in the message list until you select a message; returning to the list does not automatically reopen the newest message.
|
On Android, previously cached folder messages appear while the mailbox refreshes; a folder without cached messages still needs to load from the server. Folder discovery and message actions run separately from cached-folder loading. The app stays in the message list until you select a message; returning to the list does not automatically reopen the newest message.
|
||||||
|
|||||||
+143
@@ -0,0 +1,143 @@
|
|||||||
|
# Signing ep-mail builds
|
||||||
|
|
||||||
|
This guide covers privately distributed Android APKs and Windows executables built on Windows. Neither Google Play nor the Microsoft Store is required. Signing identifies the key used to produce an artifact and detects subsequent changes; it does not by itself prove the application is safe.
|
||||||
|
|
||||||
|
Android OpenPGP remains experimental and is not independently security reviewed. Signing the application does not change that status.
|
||||||
|
|
||||||
|
## Keep signing keys safe
|
||||||
|
|
||||||
|
- Keep private keys, keystores, PFX files, and passwords outside the repository and release artifacts. Never commit them or paste passwords into chat, issues, logs, or scripts.
|
||||||
|
- Restrict access to the files and store passwords separately in a password manager. Keep a secure backup of each private key and its password.
|
||||||
|
- Exchange and verify public certificate fingerprints through a separate trusted channel before trusting a certificate or installing an artifact.
|
||||||
|
- Run the PowerShell commands below from the repository root unless stated otherwise. Environment variables set here last only for the current PowerShell session, but are available to child processes during the build.
|
||||||
|
|
||||||
|
## Android: create a release signing key
|
||||||
|
|
||||||
|
Android accepts a self-signed app certificate; a paid certificate and Google Play account are unnecessary. Install the Android SDK and JDK 21 as described in the [README](./README.md).
|
||||||
|
|
||||||
|
Choose a secure directory outside the repository. Create it with appropriate access restrictions before proceeding. The following example uses Android Studio's JDK and prompts for the keystore password and certificate details:
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
$env:JAVA_HOME = "C:\Program Files\Android\Android Studio\jbr"
|
||||||
|
$env:ANDROID_HOME = Join-Path $env:LOCALAPPDATA "Android\Sdk"
|
||||||
|
|
||||||
|
& "$env:JAVA_HOME\bin\keytool.exe" -genkeypair -v `
|
||||||
|
-keystore "C:\secure\ep-mail-android.p12" -storetype PKCS12 `
|
||||||
|
-alias ep-mail -keyalg RSA -keysize 3072 -validity 10000
|
||||||
|
```
|
||||||
|
|
||||||
|
Replace `C:\secure` with your secured directory. Do not overwrite or recreate an existing production keystore. With PKCS12, use the same password for the keystore and key entry. Back up the keystore and password securely; losing the key prevents ordinary in-place updates of apps signed with it. Record the alias and public certificate SHA-256 fingerprint:
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
& "$env:JAVA_HOME\bin\keytool.exe" -list -v `
|
||||||
|
-keystore "C:\secure\ep-mail-android.p12" -storetype PKCS12 -alias ep-mail
|
||||||
|
```
|
||||||
|
|
||||||
|
### Build and verify
|
||||||
|
|
||||||
|
In the same PowerShell session, configure the existing release build. The password prompt avoids entering the password as a command-line argument, although the environment variables contain plaintext for the duration of the build session.
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
$env:EP_MAIL_ANDROID_STORE_FILE = "C:\secure\ep-mail-android.p12"
|
||||||
|
$env:EP_MAIL_ANDROID_KEY_ALIAS = "ep-mail"
|
||||||
|
$env:EP_MAIL_ANDROID_STORE_PASSWORD = Read-Host "Keystore password" -AsSecureString |
|
||||||
|
ForEach-Object { [System.Net.NetworkCredential]::new("", $_).Password }
|
||||||
|
$env:EP_MAIL_ANDROID_KEY_PASSWORD = $env:EP_MAIL_ANDROID_STORE_PASSWORD
|
||||||
|
|
||||||
|
npm run android:release-apk
|
||||||
|
```
|
||||||
|
|
||||||
|
The output is `release\ep-mail <version>.apk`. Confirm the build succeeded before using it. Verify the signature and certificate fingerprint using the Android SDK build-tools version installed on your machine, replacing the example version if necessary:
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
$version = (Get-Content package.json -Raw | ConvertFrom-Json).version
|
||||||
|
$apksigner = Join-Path $env:ANDROID_HOME "build-tools\36.0.0\apksigner.bat"
|
||||||
|
& $apksigner verify --verbose --print-certs "release\ep-mail $version.apk"
|
||||||
|
```
|
||||||
|
|
||||||
|
Compare the displayed signer SHA-256 fingerprint with the fingerprint recorded from the keystore. Afterwards, remove the password variables from the session:
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
Remove-Item Env:\EP_MAIL_ANDROID_STORE_PASSWORD, Env:\EP_MAIL_ANDROID_KEY_PASSWORD
|
||||||
|
```
|
||||||
|
|
||||||
|
**Build order matters:** `npm run build` and `npm run build:all` build a debug APK and overwrite `release\ep-mail <version>.apk` with a debug-signed copy. Run `npm run android:release-apk` **after** those commands, then verify the resulting APK. The `-debug.apk` remains a debug build.
|
||||||
|
|
||||||
|
### Moving from the existing debug app
|
||||||
|
|
||||||
|
Android normally requires the installed app and its update to have the same signing certificate. A new release key will not match the currently installed debug key, so `adb install -r` will fail rather than replace it.
|
||||||
|
|
||||||
|
Before uninstalling, securely back up any private OpenPGP keys and revocation certificates, local-only drafts and other local data you need; ensure account settings can be recreated. Uninstalling removes the app's local data. After verifying your backups, uninstall the debug app using Android's app settings and install the verified release APK:
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
& "$env:ANDROID_HOME\platform-tools\adb.exe" install "release\ep-mail $version.apk"
|
||||||
|
```
|
||||||
|
|
||||||
|
Future builds signed with the same release key can normally be installed with `adb install -r`. Keep the same package ID and use an appropriate version code for upgrades; do not assume that a different signing key will update the app.
|
||||||
|
|
||||||
|
## Windows: self-signed certificate for internal use
|
||||||
|
|
||||||
|
For private machines you control, a self-signed code-signing certificate is an option without buying a certificate. This does **not** make the publisher publicly trusted and does not guarantee that Microsoft Defender SmartScreen will stop warning. An unsigned build is also an option if these trust changes are not wanted.
|
||||||
|
|
||||||
|
The example below creates an exportable certificate in the current user's personal certificate store and exports a password-protected private-key PFX plus a public-only CER. Use a securely permissioned directory outside the repository and a name appropriate for your project. Do not replace an existing key without a plan for distributing and trusting the new public certificate.
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
$cert = New-SelfSignedCertificate -Type CodeSigningCert `
|
||||||
|
-Subject "CN=ep-mail Internal" -CertStoreLocation "Cert:\CurrentUser\My" `
|
||||||
|
-KeyAlgorithm RSA -KeyLength 3072 -HashAlgorithm SHA256 `
|
||||||
|
-KeyExportPolicy Exportable -NotAfter (Get-Date).AddYears(5)
|
||||||
|
|
||||||
|
$pfxPassword = Read-Host "Choose a PFX password" -AsSecureString
|
||||||
|
Export-PfxCertificate -Cert $cert -FilePath "C:\secure\ep-mail-windows.pfx" -Password $pfxPassword
|
||||||
|
Export-Certificate -Cert $cert -FilePath "C:\secure\ep-mail-windows.cer"
|
||||||
|
$cert | Format-List Subject, Thumbprint, NotBefore, NotAfter
|
||||||
|
```
|
||||||
|
|
||||||
|
Back up the PFX and password securely. The CER is the public certificate: share it only with people who need to verify your builds, and verify its fingerprint independently. Renew or replace the certificate before expiry; use a trusted timestamp when signing so signature validity can be evaluated after expiry. Timestamping requires network access.
|
||||||
|
|
||||||
|
### Build and verify
|
||||||
|
|
||||||
|
Electron-builder accepts a PFX and password from the environment:
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
$env:WIN_CSC_LINK = "C:\secure\ep-mail-windows.pfx"
|
||||||
|
$env:WIN_CSC_KEY_PASSWORD = Read-Host "PFX password" -AsSecureString |
|
||||||
|
ForEach-Object { [System.Net.NetworkCredential]::new("", $_).Password }
|
||||||
|
npm run dist:win
|
||||||
|
```
|
||||||
|
|
||||||
|
This builds the portable executable and installer in `release\`. `npm run build:all` also builds both Windows targets and uses these signing variables when supplied. Check the build output for signing errors; a build without credentials can otherwise produce unsigned artifacts. Verify **both** outputs:
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
$version = (Get-Content package.json -Raw | ConvertFrom-Json).version
|
||||||
|
Get-AuthenticodeSignature "release\ep-mail $version.exe" |
|
||||||
|
Format-List Status, StatusMessage, SignerCertificate, TimeStamperCertificate
|
||||||
|
Get-AuthenticodeSignature "release\ep-mail Setup $version.exe" |
|
||||||
|
Format-List Status, StatusMessage, SignerCertificate, TimeStamperCertificate
|
||||||
|
Remove-Item Env:\WIN_CSC_KEY_PASSWORD
|
||||||
|
```
|
||||||
|
|
||||||
|
Compare each signer certificate fingerprint with the independently verified certificate. `Status` may indicate an untrusted chain until the public certificate is trusted on the verifying machine; a missing signer, invalid signature, or unexpected fingerprint must not be treated as success. A timestamp is distinct from the signer certificate; inspect its presence and validity as well.
|
||||||
|
|
||||||
|
### Trust the public certificate on a private machine
|
||||||
|
|
||||||
|
Only do this on machines you control, after independently verifying the CER fingerprint. Importing a root certificate changes trust for the current user, not just for ep-mail: software signed by a trusted key may also be trusted. Protect and distribute the key accordingly. Never import the PFX on machines that only need to verify builds.
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
$publicCert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2("C:\secure\ep-mail-windows.cer")
|
||||||
|
$publicCert | Format-List Subject, Thumbprint, NotBefore, NotAfter
|
||||||
|
# Proceed only after checking the thumbprint through a separate trusted channel.
|
||||||
|
Import-Certificate -FilePath "C:\secure\ep-mail-windows.cer" -CertStoreLocation "Cert:\CurrentUser\Root"
|
||||||
|
Import-Certificate -FilePath "C:\secure\ep-mail-windows.cer" -CertStoreLocation "Cert:\CurrentUser\TrustedPublisher"
|
||||||
|
```
|
||||||
|
|
||||||
|
Re-run `Get-AuthenticodeSignature` on each artifact and confirm a `Valid` status, the expected signer and the timestamp. Trust is per user with these commands; other users or machines require their own trust configuration. If the certificate is compromised or no longer needed, remove its entries from those stores and stop trusting or distributing builds signed by the compromised key.
|
||||||
|
|
||||||
|
For distribution to machines where manually installing trust is impractical, use a certificate from a publicly trusted code-signing provider instead. Such certificates have costs and provider-specific requirements; a valid signature does not guarantee SmartScreen reputation.
|
||||||
|
|
||||||
|
## References
|
||||||
|
|
||||||
|
- [Android app signing](https://developer.android.com/studio/publish/app-signing)
|
||||||
|
- [Android apksigner](https://developer.android.com/tools/apksigner)
|
||||||
|
- [electron-builder Windows code signing](https://www.electron.build/docs/features/code-signing/code-signing-win/)
|
||||||
|
- [Microsoft: New-SelfSignedCertificate](https://learn.microsoft.com/en-us/powershell/module/pki/new-selfsignedcertificate)
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
- [ ] Add a configurable Undo Send delay and scheduled sending.
|
- [ ] Add a configurable Undo Send delay and scheduled sending.
|
||||||
- [x] Improve mail search with sender, subject, date, folder, and attachment filters.
|
- [x] Improve mail search with sender, subject, date, folder, and attachment filters.
|
||||||
- [x] Cache recent messages and save drafts offline; queue supported sends and message actions for retry when connectivity returns.
|
- [x] Cache recent messages and save drafts offline; queue supported sends and message actions for retry when connectivity returns.
|
||||||
- [ ] Group related messages into conversations, with controls to expand or collapse threads.
|
- [x] Group related messages into conversations, with controls to expand or collapse threads.
|
||||||
- [x] Add attachment previews and a dedicated view to find and manage attachments across mailboxes.
|
- [x] Add attachment previews and a dedicated view to find and manage attachments across mailboxes.
|
||||||
- [x] Add configurable keyboard shortcuts for common actions such as compose, archive, reply, and search.
|
- [x] Add configurable keyboard shortcuts for common actions such as compose, archive, reply, and search.
|
||||||
- [x] Warn about suspicious sender addresses and links; require confirmation before opening external links.
|
- [x] Warn about suspicious sender addresses and links; require confirmation before opening external links.
|
||||||
|
|||||||
@@ -166,6 +166,9 @@ internal object AndroidMailService {
|
|||||||
add(FetchProfile.Item.FLAGS)
|
add(FetchProfile.Item.FLAGS)
|
||||||
add(FetchProfile.Item.CONTENT_INFO)
|
add(FetchProfile.Item.CONTENT_INFO)
|
||||||
add(UIDFolder.FetchProfileItem.UID)
|
add(UIDFolder.FetchProfileItem.UID)
|
||||||
|
add("Message-ID")
|
||||||
|
add("In-Reply-To")
|
||||||
|
add("References")
|
||||||
}
|
}
|
||||||
folder.fetch(batch.toTypedArray(), profile)
|
folder.fetch(batch.toTypedArray(), profile)
|
||||||
val snoozed = account.optJSONArray("snoozedMessages") ?: JSONArray()
|
val snoozed = account.optJSONArray("snoozedMessages") ?: JSONArray()
|
||||||
@@ -380,6 +383,11 @@ internal object AndroidMailService {
|
|||||||
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) }
|
||||||
|
val idPattern = Regex("<[\\x21-\\x3b\\x3d\\x3f-\\x7e]+@[\\x21-\\x3b\\x3d\\x3f-\\x7e]+>")
|
||||||
|
val parent = idPattern.find(input.optString("inReplyTo").take(254))?.value
|
||||||
|
val references = idPattern.findAll(input.optString("references").take(900)).map { it.value }.toList()
|
||||||
|
if (parent != null) message.setHeader("In-Reply-To", parent)
|
||||||
|
if (references.isNotEmpty()) message.setHeader("References", references.joinToString(" "))
|
||||||
}
|
}
|
||||||
|
|
||||||
val transport = session.getTransport("smtp")
|
val transport = session.getTransport("smtp")
|
||||||
@@ -426,7 +434,7 @@ internal object AndroidMailService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun validateOpenPgpMime(message: MimeMessage) {
|
internal fun validateOpenPgpMime(message: MimeMessage) {
|
||||||
val contentType = message.contentType.lowercase(Locale.ROOT)
|
val contentType = message.contentType.lowercase(Locale.ROOT)
|
||||||
val multipart = message.content as? Multipart
|
val multipart = message.content as? Multipart
|
||||||
?: throw IllegalArgumentException("The OpenPGP MIME message is malformed.")
|
?: throw IllegalArgumentException("The OpenPGP MIME message is malformed.")
|
||||||
@@ -434,8 +442,8 @@ internal object AndroidMailService {
|
|||||||
if (contentType.startsWith("multipart/encrypted")) {
|
if (contentType.startsWith("multipart/encrypted")) {
|
||||||
val versionPart = multipart.getBodyPart(0)
|
val versionPart = multipart.getBodyPart(0)
|
||||||
val encryptedPart = multipart.getBodyPart(1)
|
val encryptedPart = multipart.getBodyPart(1)
|
||||||
val version = runCatching { versionPart.content.toString().trim() }.getOrDefault("")
|
val version = versionPart.inputStream.bufferedReader(Charsets.US_ASCII).use { it.readText().trim() }
|
||||||
val armor = runCatching { String(encryptedPart.inputStream.readBytes(), Charsets.US_ASCII) }.getOrDefault("")
|
val armor = encryptedPart.inputStream.bufferedReader(Charsets.US_ASCII).use { it.readText() }
|
||||||
require(versionPart.isMimeType("application/pgp-encrypted") && version == "Version: 1" &&
|
require(versionPart.isMimeType("application/pgp-encrypted") && version == "Version: 1" &&
|
||||||
encryptedPart.isMimeType("application/octet-stream") &&
|
encryptedPart.isMimeType("application/octet-stream") &&
|
||||||
armor.contains("-----BEGIN PGP MESSAGE-----") && armor.contains("-----END PGP MESSAGE-----")) {
|
armor.contains("-----BEGIN PGP MESSAGE-----") && armor.contains("-----END PGP MESSAGE-----")) {
|
||||||
@@ -443,7 +451,7 @@ internal object AndroidMailService {
|
|||||||
}
|
}
|
||||||
} else if (contentType.startsWith("multipart/signed")) {
|
} else if (contentType.startsWith("multipart/signed")) {
|
||||||
val signaturePart = multipart.getBodyPart(1)
|
val signaturePart = multipart.getBodyPart(1)
|
||||||
val armor = runCatching { String(signaturePart.inputStream.readBytes(), Charsets.US_ASCII) }.getOrDefault("")
|
val armor = signaturePart.inputStream.bufferedReader(Charsets.US_ASCII).use { it.readText() }
|
||||||
require(signaturePart.isMimeType("application/pgp-signature") &&
|
require(signaturePart.isMimeType("application/pgp-signature") &&
|
||||||
armor.contains("-----BEGIN PGP SIGNATURE-----") && armor.contains("-----END PGP SIGNATURE-----")) {
|
armor.contains("-----BEGIN PGP SIGNATURE-----") && armor.contains("-----END PGP SIGNATURE-----")) {
|
||||||
"The OpenPGP signature is missing or malformed."
|
"The OpenPGP signature is missing or malformed."
|
||||||
@@ -750,6 +758,9 @@ internal object AndroidMailService {
|
|||||||
.put("sender", senderName)
|
.put("sender", senderName)
|
||||||
.put("email", senderEmail)
|
.put("email", senderEmail)
|
||||||
.put("subject", subject)
|
.put("subject", subject)
|
||||||
|
.put("messageId", message.getHeader("Message-ID")?.joinToString(" ") ?: "")
|
||||||
|
.put("inReplyTo", message.getHeader("In-Reply-To")?.joinToString(" ") ?: "")
|
||||||
|
.put("references", message.getHeader("References")?.joinToString(" ") ?: "")
|
||||||
.put("snippet", snippet)
|
.put("snippet", snippet)
|
||||||
.put("encrypted", encrypted)
|
.put("encrypted", encrypted)
|
||||||
.put("signed", signed)
|
.put("signed", signed)
|
||||||
|
|||||||
@@ -6,12 +6,15 @@ import android.content.Intent
|
|||||||
import android.content.IntentFilter
|
import android.content.IntentFilter
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
|
import android.app.Activity
|
||||||
import android.app.AlertDialog
|
import android.app.AlertDialog
|
||||||
|
import androidx.activity.result.ActivityResult
|
||||||
import androidx.biometric.BiometricPrompt
|
import androidx.biometric.BiometricPrompt
|
||||||
import com.getcapacitor.JSObject
|
import com.getcapacitor.JSObject
|
||||||
import com.getcapacitor.Plugin
|
import com.getcapacitor.Plugin
|
||||||
import com.getcapacitor.PluginCall
|
import com.getcapacitor.PluginCall
|
||||||
import com.getcapacitor.PluginMethod
|
import com.getcapacitor.PluginMethod
|
||||||
|
import com.getcapacitor.annotation.ActivityCallback
|
||||||
import com.getcapacitor.annotation.CapacitorPlugin
|
import com.getcapacitor.annotation.CapacitorPlugin
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
import java.util.UUID
|
import java.util.UUID
|
||||||
@@ -78,6 +81,55 @@ class EpMailPlugin : Plugin() {
|
|||||||
call.resolve(JSObject().put("version", BuildConfig.VERSION_NAME))
|
call.resolve(JSObject().put("version", BuildConfig.VERSION_NAME))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PluginMethod
|
||||||
|
fun pickPgpPrivateKey(call: PluginCall) {
|
||||||
|
try {
|
||||||
|
if (AndroidAccountVault.appLockEnabled()) {
|
||||||
|
call.reject("File import is unavailable while app lock is enabled. Paste the key instead, or temporarily disable app lock and re-enable it after importing.")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
} catch (error: Exception) {
|
||||||
|
call.reject(error.message ?: "Could not check the app lock setting.")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
val intent = Intent(Intent.ACTION_OPEN_DOCUMENT).apply {
|
||||||
|
addCategory(Intent.CATEGORY_OPENABLE)
|
||||||
|
type = "*/*"
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
startActivityForResult(call, intent, "pgpPrivateKeyPicked")
|
||||||
|
} catch (_: android.content.ActivityNotFoundException) {
|
||||||
|
call.reject("No file picker is available on this device.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ActivityCallback
|
||||||
|
private fun pgpPrivateKeyPicked(call: PluginCall?, result: ActivityResult) {
|
||||||
|
if (call == null) return
|
||||||
|
if (result.resultCode != Activity.RESULT_OK) {
|
||||||
|
call.resolve(JSObject().put("canceled", true))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
val uri = result.data?.data
|
||||||
|
if (uri == null || uri.scheme != "content") {
|
||||||
|
call.reject("Could not access the selected key file.")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
mailboxExecutor.execute {
|
||||||
|
try {
|
||||||
|
val bytes = context.contentResolver.openInputStream(uri)?.use {
|
||||||
|
BoundedInputReader.read(it, 200001)
|
||||||
|
} ?: throw IllegalArgumentException("Could not open the selected key file.")
|
||||||
|
if (bytes.isEmpty() || bytes.size > 200000) {
|
||||||
|
throw IllegalArgumentException("That key file is empty or too large (maximum 200 KB).")
|
||||||
|
}
|
||||||
|
call.resolve(JSObject().put("armoredKey", String(bytes, Charsets.UTF_8)))
|
||||||
|
} catch (error: Exception) {
|
||||||
|
call.reject(error.message ?: "Could not read the selected key file.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@PluginMethod
|
@PluginMethod
|
||||||
fun getNotificationPrivacy(call: PluginCall) {
|
fun getNotificationPrivacy(call: PluginCall) {
|
||||||
try {
|
try {
|
||||||
@@ -352,7 +404,7 @@ class EpMailPlugin : Plugin() {
|
|||||||
val account = AndroidAccountVault.account()
|
val account = AndroidAccountVault.account()
|
||||||
?: throw IllegalStateException("Add a mail account before opening messages.")
|
?: throw IllegalStateException("Add a mail account before opening messages.")
|
||||||
val folder = call.getString("folder") ?: "Inbox"
|
val folder = call.getString("folder") ?: "Inbox"
|
||||||
val uid = call.getLong("uid") ?: 0L
|
val uid = PgpMessageUid.requireValid(call.data.opt("uid"))
|
||||||
call.resolve(AndroidMailService.pgpMessageSource(account, folder, uid).toJSObject())
|
call.resolve(AndroidMailService.pgpMessageSource(account, folder, uid).toJSObject())
|
||||||
} catch (error: Exception) {
|
} catch (error: Exception) {
|
||||||
call.reject(error.message ?: "Could not load the encrypted message.")
|
call.reject(error.message ?: "Could not load the encrypted message.")
|
||||||
@@ -778,6 +830,8 @@ 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("inReplyTo", input.optString("inReplyTo").take(254))
|
||||||
|
.put("references", input.optString("references").take(900))
|
||||||
.put("attachments", input.optJSONArray("attachments") ?: JSONArray())
|
.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)
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package studio.daybreak.mail
|
||||||
|
|
||||||
|
internal object PgpMessageUid {
|
||||||
|
fun requireValid(value: Any?): Long {
|
||||||
|
require(value is Number) { "That message could not be identified." }
|
||||||
|
val number = value.toDouble()
|
||||||
|
require(number.isFinite() && number >= 1 && number <= 4294967295.0 && number == kotlin.math.floor(number)) {
|
||||||
|
"That message could not be identified."
|
||||||
|
}
|
||||||
|
return number.toLong()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
package studio.daybreak.mail
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream
|
||||||
|
import java.io.File
|
||||||
|
import java.util.Properties
|
||||||
|
import javax.mail.Session
|
||||||
|
import javax.mail.internet.MimeMessage
|
||||||
|
import org.junit.Assert.assertThrows
|
||||||
|
import org.junit.Assume.assumeTrue
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
|
class AndroidPgpMimeValidationTest {
|
||||||
|
private fun message(contentType: String, parts: String): MimeMessage {
|
||||||
|
val source = "MIME-Version: 1.0\r\nContent-Type: $contentType; boundary=\"test\"\r\n\r\n$parts"
|
||||||
|
return MimeMessage(Session.getInstance(Properties()), ByteArrayInputStream(source.toByteArray(Charsets.UTF_8)))
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun encrypted(version: String = "Version: 1", partType: String = "application/octet-stream", armor: String = "-----BEGIN PGP MESSAGE-----\r\nabc\r\n-----END PGP MESSAGE-----"): MimeMessage =
|
||||||
|
message("multipart/encrypted; protocol=\"application/pgp-encrypted\"",
|
||||||
|
"--test\r\nContent-Type: application/pgp-encrypted\r\n\r\n$version\r\n" +
|
||||||
|
"--test\r\nContent-Type: $partType\r\n\r\n$armor\r\n--test--\r\n")
|
||||||
|
|
||||||
|
private fun signed(armor: String = "-----BEGIN PGP SIGNATURE-----\r\nabc\r\n-----END PGP SIGNATURE-----"): MimeMessage =
|
||||||
|
message("multipart/signed; protocol=\"application/pgp-signature\"",
|
||||||
|
"--test\r\nContent-Type: text/plain\r\n\r\nhello\r\n" +
|
||||||
|
"--test\r\nContent-Type: application/pgp-signature\r\n\r\n$armor\r\n--test--\r\n")
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun acceptsValidEncryptedAndSignedMime() {
|
||||||
|
AndroidMailService.validateOpenPgpMime(encrypted())
|
||||||
|
AndroidMailService.validateOpenPgpMime(signed())
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun rejectsMalformedEncryptedAndSignedMime() {
|
||||||
|
assertThrows(IllegalArgumentException::class.java) { AndroidMailService.validateOpenPgpMime(encrypted(version = "Version: 2")) }
|
||||||
|
assertThrows(IllegalArgumentException::class.java) { AndroidMailService.validateOpenPgpMime(encrypted(partType = "text/plain")) }
|
||||||
|
assertThrows(IllegalArgumentException::class.java) { AndroidMailService.validateOpenPgpMime(encrypted(armor = "missing armor")) }
|
||||||
|
assertThrows(IllegalArgumentException::class.java) { AndroidMailService.validateOpenPgpMime(signed(armor = "missing signature")) }
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun acceptsMimeGeneratedByAndroidOpenPgpBuilder() {
|
||||||
|
val directory = System.getenv("EP_MAIL_PGP_MIME_FIXTURE_DIR")
|
||||||
|
assumeTrue("Set EP_MAIL_PGP_MIME_FIXTURE_DIR to run the JavaScript-to-JavaMail integration test.", !directory.isNullOrBlank())
|
||||||
|
for (name in listOf("encrypted", "signed", "encrypted-signed")) {
|
||||||
|
val file = File(directory, "$name.eml")
|
||||||
|
val parsed = file.inputStream().use { MimeMessage(Session.getInstance(Properties()), it) }
|
||||||
|
AndroidMailService.validateOpenPgpMime(parsed)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package studio.daybreak.mail
|
||||||
|
|
||||||
|
import org.junit.Assert.assertEquals
|
||||||
|
import org.junit.Assert.assertThrows
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
|
class PgpMessageUidTest {
|
||||||
|
@Test
|
||||||
|
fun acceptsJsonIntegerAndLongUids() {
|
||||||
|
assertEquals(42L, PgpMessageUid.requireValid(42))
|
||||||
|
assertEquals(42L, PgpMessageUid.requireValid(42L))
|
||||||
|
assertEquals(4294967295L, PgpMessageUid.requireValid(4294967295L))
|
||||||
|
assertEquals(42L, PgpMessageUid.requireValid(42.0))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun rejectsMissingAndInvalidUids() {
|
||||||
|
for (value in listOf(null, "42", 0, -1, 1.5, Double.NaN, Double.POSITIVE_INFINITY, 4294967296L)) {
|
||||||
|
assertThrows(IllegalArgumentException::class.java) { PgpMessageUid.requireValid(value) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,7 +18,54 @@ function returnToMessageList() {
|
|||||||
if (readerListPosition?.folder === state.activeFolder) $('#message-list').scrollTop = readerListPosition.scrollTop;
|
if (readerListPosition?.folder === state.activeFolder) $('#message-list').scrollTop = readerListPosition.scrollTop;
|
||||||
readerListPosition = null;
|
readerListPosition = null;
|
||||||
}
|
}
|
||||||
function renderList(){let rows=state.messages.filter(m=>{if(state.activeFolder==='Starred'&&!m.star)return false;if(state.activeFolder==='Inbox'&&m.archived)return false;if(state.activeFolder==='Archive'&&!m.archived)return false;if(state.activeFolder==='Trash'&&!m.deleted)return false;if(state.activeFolder==='Sent'&&!m.sent)return false;if(state.activeFolder==='Drafts')return false;if(state.activeFolder==='Snoozed')return false;if(m.deleted&&state.activeFolder!=='Trash')return false;return !state.query||`${m.sender} ${m.email} ${m.subject} ${m.snippet}`.toLowerCase().includes(state.query.toLowerCase())});$('#message-list').innerHTML=rows.length?rows.map(m=>`<div class="message ${m.unread?'unread':''} ${m.id===state.activeMessage?'selected':''}" data-id="${m.id}"><input class="row-check" type="checkbox" aria-label="Select message" ${state.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;state.selectedIds.has(id)?state.selectedIds.delete(id):state.selectedIds.add(id);return}if(e.target.closest('.star')){const m=state.messages.find(x=>x.id===+row.dataset.id);m.star=!m.star;renderList();return}openMessage(+row.dataset.id)});});if(!rows.length){document.body.classList.remove('reader-open');$('#reader-pane').innerHTML=emptyReader()}}
|
const collapsedThreads = new Set();
|
||||||
|
function renderList() {
|
||||||
|
const rows = state.messages.filter(m => {
|
||||||
|
if (state.activeFolder === 'Starred' && !m.star) return false;
|
||||||
|
if (state.activeFolder === 'Inbox' && m.archived) return false;
|
||||||
|
if (state.activeFolder === 'Archive' && !m.archived) return false;
|
||||||
|
if (state.activeFolder === 'Trash' && !m.deleted) return false;
|
||||||
|
if (state.activeFolder === 'Sent' && !m.sent) return false;
|
||||||
|
if (state.activeFolder === 'Drafts' || state.activeFolder === 'Snoozed') return false;
|
||||||
|
if (m.deleted && state.activeFolder !== 'Trash') return false;
|
||||||
|
return !state.query || `${m.sender} ${m.email} ${m.subject} ${m.snippet}`.toLowerCase().includes(state.query.toLowerCase());
|
||||||
|
});
|
||||||
|
const groups = window.epMailConversationThreads.groupMessages(rows);
|
||||||
|
const scope = `${window.epMailFeatures?.mail?.connectedAccount?.id || ''}:${state.activeFolder}:`;
|
||||||
|
const keyFor = message => scope + (window.epMailConversationThreads.messageIds(message.messageId)[0] || `uid:${message.sourceFolder || ''}:${message.id}`);
|
||||||
|
const rowHtml = m => `<div class="message ${m.unread?'unread':''} ${m.id===state.activeMessage?'selected':''}" data-id="${esc(m.id)}"><input class="row-check" type="checkbox" aria-label="Select message" ${state.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>`;
|
||||||
|
$('#message-list').innerHTML = rows.length ? groups.map((group, index) => {
|
||||||
|
if (group.length === 1) return rowHtml(group[0]);
|
||||||
|
const collapsed = group.some(message => collapsedThreads.has(keyFor(message)));
|
||||||
|
if (collapsed) group.slice(1).forEach(message => state.selectedIds.delete(message.id));
|
||||||
|
const unread = group.filter(message => message.unread).length;
|
||||||
|
return `<section class="conversation"><button type="button" class="conversation-toggle" data-thread="${index}" aria-expanded="${!collapsed}" aria-label="${collapsed ? 'Expand' : 'Collapse'} conversation: ${esc(group[0].subject)}">${collapsed ? '▸' : '▾'} Conversation · ${group.length} messages${unread ? ` · ${unread} unread` : ''}</button>${rowHtml(group[0])}<div class="conversation-replies"${collapsed ? ' hidden' : ''}>${group.slice(1).map(rowHtml).join('')}</div></section>`;
|
||||||
|
}).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>`;
|
||||||
|
$$('.conversation-toggle').forEach(button => button.addEventListener('click', () => {
|
||||||
|
const group = groups[Number(button.dataset.thread)];
|
||||||
|
const collapsing = button.getAttribute('aria-expanded') === 'true';
|
||||||
|
group.forEach(message => collapsing ? collapsedThreads.add(keyFor(message)) : collapsedThreads.delete(keyFor(message)));
|
||||||
|
if (collapsing) group.slice(1).forEach(message => state.selectedIds.delete(message.id));
|
||||||
|
const scrollTop = $('#message-list').scrollTop;
|
||||||
|
renderList();
|
||||||
|
$('#message-list').scrollTop = scrollTop;
|
||||||
|
}));
|
||||||
|
$$('.message').forEach(row => row.addEventListener('click', e => {
|
||||||
|
if (e.target.closest('.row-check')) {
|
||||||
|
const id = +row.dataset.id;
|
||||||
|
state.selectedIds.has(id) ? state.selectedIds.delete(id) : state.selectedIds.add(id);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (e.target.closest('.star')) {
|
||||||
|
const m = state.messages.find(x => x.id === +row.dataset.id);
|
||||||
|
m.star = !m.star;
|
||||||
|
renderList();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
openMessage(+row.dataset.id);
|
||||||
|
}));
|
||||||
|
if (!rows.length) { document.body.classList.remove('reader-open'); $('#reader-pane').innerHTML = emptyReader(); }
|
||||||
|
}
|
||||||
function openMessage(id){
|
function openMessage(id){
|
||||||
state.activeMessage=id;
|
state.activeMessage=id;
|
||||||
const m=state.messages.find(x=>x.id===id);
|
const m=state.messages.find(x=>x.id===id);
|
||||||
|
|||||||
@@ -0,0 +1,47 @@
|
|||||||
|
(function installConversationThreads(root, factory) {
|
||||||
|
const api = factory();
|
||||||
|
if (typeof module === 'object' && module.exports) module.exports = api;
|
||||||
|
else root.epMailConversationThreads = api;
|
||||||
|
})(typeof window === 'undefined' ? globalThis : window, function () {
|
||||||
|
function messageIds(value) {
|
||||||
|
const text = Array.isArray(value) ? value.join(' ') : String(value || '');
|
||||||
|
return [...new Set((text.match(/<[\x21-\x3b\x3d\x3f-\x7e]+@[\x21-\x3b\x3d\x3f-\x7e]+>/g) || [])
|
||||||
|
.filter(id => id.length <= 254))];
|
||||||
|
}
|
||||||
|
|
||||||
|
function replyHeaders(message) {
|
||||||
|
const inReplyTo = messageIds(message?.messageId)[0] || '';
|
||||||
|
if (!inReplyTo) return { inReplyTo: '', references: '' };
|
||||||
|
const ids = [...new Set([...messageIds(message.references), inReplyTo])];
|
||||||
|
while (ids.join(' ').length > 900 && ids.length > 1) ids.splice(1, 1);
|
||||||
|
return { inReplyTo, references: ids.join(' ') };
|
||||||
|
}
|
||||||
|
|
||||||
|
function groupMessages(messages) {
|
||||||
|
const parents = messages.map((_, index) => index);
|
||||||
|
const find = index => {
|
||||||
|
while (parents[index] !== index) {
|
||||||
|
parents[index] = parents[parents[index]];
|
||||||
|
index = parents[index];
|
||||||
|
}
|
||||||
|
return index;
|
||||||
|
};
|
||||||
|
const owners = new Map();
|
||||||
|
messages.forEach((message, index) => {
|
||||||
|
const ids = [...messageIds(message.messageId), ...messageIds(message.inReplyTo), ...messageIds(message.references)];
|
||||||
|
for (const id of new Set(ids)) {
|
||||||
|
if (owners.has(id)) parents[find(index)] = find(owners.get(id));
|
||||||
|
else owners.set(id, index);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const groups = new Map();
|
||||||
|
messages.forEach((message, index) => {
|
||||||
|
const root = find(index);
|
||||||
|
if (!groups.has(root)) groups.set(root, []);
|
||||||
|
groups.get(root).push(message);
|
||||||
|
});
|
||||||
|
return [...groups.values()];
|
||||||
|
}
|
||||||
|
|
||||||
|
return { messageIds, replyHeaders, groupMessages };
|
||||||
|
});
|
||||||
@@ -202,6 +202,8 @@ registerIpcHandler('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),
|
||||||
|
inReplyTo: String(input?.inReplyTo || '').slice(0, 254),
|
||||||
|
references: String(input?.references || '').slice(0, 900),
|
||||||
attachments: serializeOutgoingAttachments(normalizeOutgoingAttachments(input?.attachments)),
|
attachments: serializeOutgoingAttachments(normalizeOutgoingAttachments(input?.attachments)),
|
||||||
updatedAt: Date.now()
|
updatedAt: Date.now()
|
||||||
};
|
};
|
||||||
@@ -341,6 +343,8 @@ registerIpcHandler('mail:send', async (event, message) => {
|
|||||||
text: message.text,
|
text: message.text,
|
||||||
displayName: message.displayName,
|
displayName: message.displayName,
|
||||||
messageId: message.messageId || `<${randomUUID()}@ep-mail.local>`,
|
messageId: message.messageId || `<${randomUUID()}@ep-mail.local>`,
|
||||||
|
inReplyTo: message.inReplyTo,
|
||||||
|
references: message.references,
|
||||||
attachments: message.attachments
|
attachments: message.attachments
|
||||||
};
|
};
|
||||||
const attachments = normalizeOutgoingAttachments(message?.attachments);
|
const attachments = normalizeOutgoingAttachments(message?.attachments);
|
||||||
@@ -376,6 +380,8 @@ registerIpcHandler('mail:send', async (event, message) => {
|
|||||||
subject: String(queuedMessage.subject || '(no subject)').slice(0, 998),
|
subject: String(queuedMessage.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: queuedMessage.messageId,
|
messageId: queuedMessage.messageId,
|
||||||
|
inReplyTo: queuedMessage.inReplyTo,
|
||||||
|
references: queuedMessage.references,
|
||||||
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,
|
||||||
|
|||||||
+12
-7
@@ -1,3 +1,5 @@
|
|||||||
|
const { BUILTIN_SERVER_IDS } = require('../pgp-keyservers.cjs');
|
||||||
|
|
||||||
function pgpFailure(error) {
|
function pgpFailure(error) {
|
||||||
return {
|
return {
|
||||||
failed: true,
|
failed: true,
|
||||||
@@ -207,12 +209,12 @@ function registerPgpIpcHandlers({
|
|||||||
});
|
});
|
||||||
registerIpcHandler('pgp:key-servers', async () => {
|
registerIpcHandler('pgp:key-servers', async () => {
|
||||||
const settings = await pgpKeys.getSettings();
|
const settings = await pgpKeys.getSettings();
|
||||||
return listServers(settings.customKeyServers, settings.enabledKeyServers);
|
return listServers(settings.customKeyServers, settings.enabledKeyServers, settings.removedBuiltinKeyServers);
|
||||||
});
|
});
|
||||||
registerIpcHandler('pgp:set-key-server-enabled', async (_event, input) => {
|
registerIpcHandler('pgp:set-key-server-enabled', async (_event, input) => {
|
||||||
if (typeof input?.enabled !== 'boolean') throw new Error('Choose whether to enable or disable this key server.');
|
if (typeof input?.enabled !== 'boolean') throw new Error('Choose whether to enable or disable this key server.');
|
||||||
const settings = await pgpKeys.getSettings();
|
const settings = await pgpKeys.getSettings();
|
||||||
const servers = listServers(settings.customKeyServers, settings.enabledKeyServers);
|
const servers = listServers(settings.customKeyServers, settings.enabledKeyServers, settings.removedBuiltinKeyServers);
|
||||||
const serverId = String(input?.serverId || '');
|
const serverId = String(input?.serverId || '');
|
||||||
if (!servers.some(server => server.id === serverId)) throw new Error('That key server was not found.');
|
if (!servers.some(server => server.id === serverId)) throw new Error('That key server was not found.');
|
||||||
const enabled = new Set(settings.enabledKeyServers);
|
const enabled = new Set(settings.enabledKeyServers);
|
||||||
@@ -221,7 +223,8 @@ function registerPgpIpcHandlers({
|
|||||||
await pgpKeys.setSettings({
|
await pgpKeys.setSettings({
|
||||||
cacheMinutes: settings.cacheMinutes,
|
cacheMinutes: settings.cacheMinutes,
|
||||||
customKeyServers: settings.customKeyServers,
|
customKeyServers: settings.customKeyServers,
|
||||||
enabledKeyServers: [...enabled]
|
enabledKeyServers: [...enabled],
|
||||||
|
removedBuiltinKeyServers: settings.removedBuiltinKeyServers
|
||||||
});
|
});
|
||||||
return { serverId, enabled: input.enabled };
|
return { serverId, enabled: input.enabled };
|
||||||
});
|
});
|
||||||
@@ -256,23 +259,25 @@ function registerPgpIpcHandlers({
|
|||||||
const id = String(serverId || '');
|
const id = String(serverId || '');
|
||||||
const settings = await pgpKeys.getSettings();
|
const settings = await pgpKeys.getSettings();
|
||||||
const customServers = settings.customKeyServers.filter(server => server.id !== id);
|
const customServers = settings.customKeyServers.filter(server => server.id !== id);
|
||||||
if (customServers.length === settings.customKeyServers.length) throw new Error('That custom key server was not found.');
|
const removesBuiltin = BUILTIN_SERVER_IDS.includes(id) && !settings.removedBuiltinKeyServers.includes(id);
|
||||||
|
if (customServers.length === settings.customKeyServers.length && !removesBuiltin) throw new Error('That key server was not found.');
|
||||||
await pgpKeys.setSettings({
|
await pgpKeys.setSettings({
|
||||||
cacheMinutes: settings.cacheMinutes,
|
cacheMinutes: settings.cacheMinutes,
|
||||||
customKeyServers,
|
customKeyServers: customServers,
|
||||||
|
removedBuiltinKeyServers: removesBuiltin ? [...settings.removedBuiltinKeyServers, id] : settings.removedBuiltinKeyServers,
|
||||||
enabledKeyServers: settings.enabledKeyServers.filter(enabledId => enabledId !== id)
|
enabledKeyServers: settings.enabledKeyServers.filter(enabledId => enabledId !== id)
|
||||||
});
|
});
|
||||||
return { removed: true };
|
return { removed: true };
|
||||||
});
|
});
|
||||||
registerIpcHandler('pgp:find-key', async (_event, input) => {
|
registerIpcHandler('pgp:find-key', async (_event, input) => {
|
||||||
const settings = await pgpKeys.getSettings();
|
const settings = await pgpKeys.getSettings();
|
||||||
const servers = listServers(settings.customKeyServers, settings.enabledKeyServers);
|
const servers = listServers(settings.customKeyServers, settings.enabledKeyServers, settings.removedBuiltinKeyServers);
|
||||||
return pgpKeyServers.lookupEnabled(servers, input?.email);
|
return pgpKeyServers.lookupEnabled(servers, input?.email);
|
||||||
});
|
});
|
||||||
registerIpcHandler('pgp:publish-key', async (event, input) => {
|
registerIpcHandler('pgp:publish-key', async (event, input) => {
|
||||||
const fingerprint = pgpFingerprint(input?.fingerprint);
|
const fingerprint = pgpFingerprint(input?.fingerprint);
|
||||||
const settings = await pgpKeys.getSettings();
|
const settings = await pgpKeys.getSettings();
|
||||||
const server = listServers(settings.customKeyServers, settings.enabledKeyServers).find(item => item.id === String(input?.serverId || ''));
|
const server = listServers(settings.customKeyServers, settings.enabledKeyServers, settings.removedBuiltinKeyServers).find(item => item.id === String(input?.serverId || ''));
|
||||||
if (!server) throw new Error('Choose a configured key server.');
|
if (!server) throw new Error('Choose a configured key server.');
|
||||||
if (!server.enabled) throw new Error('Enable the selected key server before publishing to it.');
|
if (!server.enabled) throw new Error('Enable the selected key server before publishing to it.');
|
||||||
const entry = (await pgpKeys.list()).find(key => key.fingerprint === fingerprint);
|
const entry = (await pgpKeys.list()).find(key => key.fingerprint === fingerprint);
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
const { randomUUID } = require('node:crypto');
|
const { randomUUID } = require('node:crypto');
|
||||||
const nodemailer = require('nodemailer');
|
const nodemailer = require('nodemailer');
|
||||||
const { normalizeOutgoingAttachments } = require('../mail-attachments.cjs');
|
const { normalizeOutgoingAttachments } = require('../mail-attachments.cjs');
|
||||||
|
const { messageIds } = require('../../conversation-threads.js');
|
||||||
|
|
||||||
function createMailSender({ smtpTransport, imapClient, findSentMailbox, createTransport = nodemailer.createTransport }) {
|
function createMailSender({ smtpTransport, imapClient, findSentMailbox, createTransport = nodemailer.createTransport }) {
|
||||||
async function sendMailNow(account, message) {
|
async function sendMailNow(account, message) {
|
||||||
@@ -19,6 +20,8 @@ function createMailSender({ smtpTransport, imapClient, findSentMailbox, createTr
|
|||||||
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,
|
||||||
|
inReplyTo: messageIds(message.inReplyTo)[0] || undefined,
|
||||||
|
references: messageIds(message.references),
|
||||||
attachments: attachments.map(file => ({
|
attachments: attachments.map(file => ({
|
||||||
filename: file.filename,
|
filename: file.filename,
|
||||||
contentType: file.contentType,
|
contentType: file.contentType,
|
||||||
|
|||||||
@@ -344,6 +344,9 @@ async function toUiMessage(item, folder) {
|
|||||||
sender: sender?.name || sender?.address || 'Unknown sender',
|
sender: sender?.name || sender?.address || 'Unknown sender',
|
||||||
email: sender?.address || '',
|
email: sender?.address || '',
|
||||||
subject: parsed.subject || '(no subject)',
|
subject: parsed.subject || '(no subject)',
|
||||||
|
messageId: parsed.messageId || '',
|
||||||
|
inReplyTo: parsed.inReplyTo || '',
|
||||||
|
references: parsed.references || [],
|
||||||
snippet: encrypted ? 'Encrypted message' : (bodyText || parsed.subject || '').replace(/\s+/g, ' ').slice(0, 180),
|
snippet: encrypted ? 'Encrypted message' : (bodyText || parsed.subject || '').replace(/\s+/g, ' ').slice(0, 180),
|
||||||
encrypted,
|
encrypted,
|
||||||
pgpSignatures,
|
pgpSignatures,
|
||||||
|
|||||||
@@ -7,8 +7,10 @@ const MAX_CUSTOM_SERVERS = 10;
|
|||||||
|
|
||||||
const BUILTIN_SERVERS = [
|
const BUILTIN_SERVERS = [
|
||||||
{ id: 'openpgp-vks', name: 'keys.openpgp.org', url: 'https://keys.openpgp.org', protocol: 'vks', builtin: true },
|
{ id: 'openpgp-vks', name: 'keys.openpgp.org', url: 'https://keys.openpgp.org', protocol: 'vks', builtin: true },
|
||||||
{ id: 'mailvelope-hkp', name: 'keys.mailvelope.com', url: 'https://keys.mailvelope.com', protocol: 'hkp', builtin: true }
|
{ id: 'mailvelope-hkp', name: 'keys.mailvelope.com', url: 'https://keys.mailvelope.com', protocol: 'hkp', builtin: true },
|
||||||
|
{ id: 'eternity-vks', name: 'keys.eternityproject.fi', url: 'https://keys.eternityproject.fi', protocol: 'vks', builtin: true }
|
||||||
];
|
];
|
||||||
|
const BUILTIN_SERVER_IDS = BUILTIN_SERVERS.map(server => server.id);
|
||||||
|
|
||||||
function normalizeBaseUrl(value) {
|
function normalizeBaseUrl(value) {
|
||||||
const raw = String(value || '').trim();
|
const raw = String(value || '').trim();
|
||||||
@@ -40,10 +42,11 @@ function normalizeCustomServer(input) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function listServers(customServers = [], enabledServerIds = []) {
|
function listServers(customServers = [], enabledServerIds = [], removedBuiltinIds = []) {
|
||||||
const enabled = new Set(enabledServerIds);
|
const enabled = new Set(enabledServerIds);
|
||||||
|
const removed = new Set(removedBuiltinIds);
|
||||||
return [
|
return [
|
||||||
...BUILTIN_SERVERS.map(server => ({ ...server, enabled: enabled.has(server.id) })),
|
...BUILTIN_SERVERS.filter(server => !removed.has(server.id)).map(server => ({ ...server, enabled: enabled.has(server.id) })),
|
||||||
...customServers.map(server => {
|
...customServers.map(server => {
|
||||||
const normalized = normalizeCustomServer(server);
|
const normalized = normalizeCustomServer(server);
|
||||||
return { ...normalized, enabled: enabled.has(normalized.id) };
|
return { ...normalized, enabled: enabled.has(normalized.id) };
|
||||||
@@ -72,14 +75,17 @@ async function readResponseText(response) {
|
|||||||
const chunks = [];
|
const chunks = [];
|
||||||
let length = 0;
|
let length = 0;
|
||||||
for await (const chunk of response.body) {
|
for await (const chunk of response.body) {
|
||||||
const bytes = Buffer.from(chunk);
|
const bytes = typeof chunk === 'string' ? new TextEncoder().encode(chunk) : chunk;
|
||||||
length += bytes.length;
|
length += bytes.length;
|
||||||
if (length > MAX_RESPONSE_BYTES) {
|
if (length > MAX_RESPONSE_BYTES) {
|
||||||
throw new Error('The key server response is too large.');
|
throw new Error('The key server response is too large.');
|
||||||
}
|
}
|
||||||
chunks.push(bytes);
|
chunks.push(bytes);
|
||||||
}
|
}
|
||||||
return Buffer.concat(chunks, length).toString('utf8');
|
const joined = new Uint8Array(length);
|
||||||
|
let offset = 0;
|
||||||
|
for (const bytes of chunks) { joined.set(bytes, offset); offset += bytes.length; }
|
||||||
|
return new TextDecoder().decode(joined);
|
||||||
}
|
}
|
||||||
|
|
||||||
function createKeyServerService({ fetchImpl = globalThis.fetch } = {}) {
|
function createKeyServerService({ fetchImpl = globalThis.fetch } = {}) {
|
||||||
@@ -269,6 +275,7 @@ function createKeyServerService({ fetchImpl = globalThis.fetch } = {}) {
|
|||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
BUILTIN_SERVERS,
|
BUILTIN_SERVERS,
|
||||||
|
BUILTIN_SERVER_IDS,
|
||||||
MAX_CUSTOM_SERVERS,
|
MAX_CUSTOM_SERVERS,
|
||||||
createKeyServerService,
|
createKeyServerService,
|
||||||
listServers,
|
listServers,
|
||||||
|
|||||||
@@ -198,11 +198,14 @@ function createKeyStore(storage) {
|
|||||||
customKeyServers: Array.isArray(settings.customKeyServers) ? settings.customKeyServers : [],
|
customKeyServers: Array.isArray(settings.customKeyServers) ? settings.customKeyServers : [],
|
||||||
enabledKeyServers: Array.isArray(settings.enabledKeyServers)
|
enabledKeyServers: Array.isArray(settings.enabledKeyServers)
|
||||||
? [...new Set(settings.enabledKeyServers.filter(id => typeof id === 'string'))]
|
? [...new Set(settings.enabledKeyServers.filter(id => typeof id === 'string'))]
|
||||||
|
: [],
|
||||||
|
removedBuiltinKeyServers: Array.isArray(settings.removedBuiltinKeyServers)
|
||||||
|
? [...new Set(settings.removedBuiltinKeyServers.filter(id => typeof id === 'string'))]
|
||||||
: []
|
: []
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
async setSettings({ cacheMinutes, customKeyServers, enabledKeyServers }) {
|
async setSettings({ cacheMinutes, customKeyServers, enabledKeyServers, removedBuiltinKeyServers }) {
|
||||||
const minutes = Number(cacheMinutes);
|
const minutes = Number(cacheMinutes);
|
||||||
if (!Number.isFinite(minutes) || minutes < 0 || minutes > 1440) throw new Error('Choose between 0 and 1440 minutes.');
|
if (!Number.isFinite(minutes) || minutes < 0 || minutes > 1440) throw new Error('Choose between 0 and 1440 minutes.');
|
||||||
const data = await read();
|
const data = await read();
|
||||||
@@ -224,11 +227,18 @@ function createKeyStore(storage) {
|
|||||||
}
|
}
|
||||||
data.settings.enabledKeyServers = [...new Set(enabledKeyServers)];
|
data.settings.enabledKeyServers = [...new Set(enabledKeyServers)];
|
||||||
}
|
}
|
||||||
|
if (removedBuiltinKeyServers !== undefined) {
|
||||||
|
if (!Array.isArray(removedBuiltinKeyServers) || removedBuiltinKeyServers.length > 12 || removedBuiltinKeyServers.some(id => typeof id !== 'string' || !id.trim())) {
|
||||||
|
throw new Error('Choose no more than 12 valid built-in key servers to remove.');
|
||||||
|
}
|
||||||
|
data.settings.removedBuiltinKeyServers = [...new Set(removedBuiltinKeyServers)];
|
||||||
|
}
|
||||||
await storage.save(data);
|
await storage.save(data);
|
||||||
return {
|
return {
|
||||||
cacheMinutes: data.settings.cacheMinutes,
|
cacheMinutes: data.settings.cacheMinutes,
|
||||||
customKeyServers: Array.isArray(data.settings.customKeyServers) ? data.settings.customKeyServers : [],
|
customKeyServers: Array.isArray(data.settings.customKeyServers) ? data.settings.customKeyServers : [],
|
||||||
enabledKeyServers: Array.isArray(data.settings.enabledKeyServers) ? [...data.settings.enabledKeyServers] : []
|
enabledKeyServers: Array.isArray(data.settings.enabledKeyServers) ? [...data.settings.enabledKeyServers] : [],
|
||||||
|
removedBuiltinKeyServers: Array.isArray(data.settings.removedBuiltinKeyServers) ? [...data.settings.removedBuiltinKeyServers] : []
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -267,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, attachments = [] }) {
|
async build({ from, to, cc, subject, text, messageId, inReplyTo, references, 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.');
|
||||||
@@ -290,6 +290,9 @@ function createPgpMail({ keyStore, cache }) {
|
|||||||
}
|
}
|
||||||
await cache.remember(signerEntry.fingerprint, secret);
|
await cache.remember(signerEntry.fingerprint, secret);
|
||||||
}
|
}
|
||||||
|
const { messageIds } = require('../conversation-threads.js');
|
||||||
|
const parentIds = messageIds(inReplyTo).slice(0, 1);
|
||||||
|
const referenceIds = messageIds(references);
|
||||||
const headers = [
|
const headers = [
|
||||||
`From: ${formatAddress(from)}`,
|
`From: ${formatAddress(from)}`,
|
||||||
`To: ${toList.map(formatAddress).join(', ')}`,
|
`To: ${toList.map(formatAddress).join(', ')}`,
|
||||||
@@ -297,6 +300,8 @@ function createPgpMail({ keyStore, cache }) {
|
|||||||
`Subject: ${encodeHeader(subject || '(no subject)')}`,
|
`Subject: ${encodeHeader(subject || '(no subject)')}`,
|
||||||
`Date: ${date.toUTCString().replace('GMT', '+0000')}`,
|
`Date: ${date.toUTCString().replace('GMT', '+0000')}`,
|
||||||
`Message-ID: ${String(messageId).replace(/[\r\n<>\s]/g, '').replace(/^/, '<').replace(/$/, '>')}`,
|
`Message-ID: ${String(messageId).replace(/[\r\n<>\s]/g, '').replace(/^/, '<').replace(/$/, '>')}`,
|
||||||
|
...parentIds.map(id => `In-Reply-To: ${id}`),
|
||||||
|
...(referenceIds.length ? [`References: ${referenceIds.join(' ')}`] : []),
|
||||||
'MIME-Version: 1.0'
|
'MIME-Version: 1.0'
|
||||||
];
|
];
|
||||||
const inner = await innerEntity(text, attachments);
|
const inner = await innerEntity(text, attachments);
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ const objectFieldSchemas = {
|
|||||||
'mail:create-folder': [{ name: str(100) }],
|
'mail:create-folder': [{ name: str(100) }],
|
||||||
'mail:save-draft': [{
|
'mail:save-draft': [{
|
||||||
id: str(256), to: str(4000), cc: str(4000), subject: str(998), text: str(500_000),
|
id: str(256), to: str(4000), cc: str(4000), subject: str(998), text: str(500_000),
|
||||||
|
inReplyTo: str(254), references: str(900),
|
||||||
attachments: array(record(attachmentFields))
|
attachments: array(record(attachmentFields))
|
||||||
}],
|
}],
|
||||||
'mail:set-snooze': [{
|
'mail:set-snooze': [{
|
||||||
@@ -67,7 +68,7 @@ const objectFieldSchemas = {
|
|||||||
'mail:preview-attachment': [{ uid: num({ integer: true, min: 1 }), folder: str(256), filename: str(1000) }],
|
'mail:preview-attachment': [{ uid: num({ integer: true, min: 1 }), folder: str(256), filename: str(1000) }],
|
||||||
'mail:send': [{
|
'mail:send': [{
|
||||||
to: str(4000), cc: str(4000), subject: str(998), text: str(500_000), displayName: str(80),
|
to: str(4000), cc: str(4000), subject: str(998), text: str(500_000), displayName: str(80),
|
||||||
messageId: str(998), attachments: array(record(attachmentFields)),
|
messageId: str(998), inReplyTo: str(254), references: str(900), attachments: array(record(attachmentFields)),
|
||||||
pgp: record({ encrypt: bool(), sign: bool(), passphrase: str(4096, { nullable: true }) }, { nullable: true })
|
pgp: record({ encrypt: bool(), sign: bool(), passphrase: str(4096, { nullable: true }) }, { nullable: true })
|
||||||
}],
|
}],
|
||||||
'pgp:generate': [{ name: str(200), email: str(320), passphrase: str(4096), accountId: str(256, { nullable: true }) }],
|
'pgp:generate': [{ name: str(200), email: str(320), passphrase: str(4096), accountId: str(256, { nullable: true }) }],
|
||||||
@@ -115,7 +116,7 @@ const positionalFieldSchemas = {
|
|||||||
'pgp:remove-key-server': { 0: str(256) }
|
'pgp:remove-key-server': { 0: str(256) }
|
||||||
};
|
};
|
||||||
|
|
||||||
const sendMessageFields = new Set(['to', 'cc', 'subject', 'text', 'displayName', 'messageId', 'attachments', 'pgp']);
|
const sendMessageFields = new Set(['to', 'cc', 'subject', 'text', 'displayName', 'messageId', 'inReplyTo', 'references', 'attachments', 'pgp']);
|
||||||
|
|
||||||
const schemas = {
|
const schemas = {
|
||||||
'app:get-version': [],
|
'app:get-version': [],
|
||||||
|
|||||||
@@ -65,6 +65,7 @@
|
|||||||
<div id="modal-root"></div>
|
<div id="modal-root"></div>
|
||||||
<div id="toast" class="toast" role="status" aria-live="polite"></div>
|
<div id="toast" class="toast" role="status" aria-live="polite"></div>
|
||||||
<script src="renderer-state.js"></script>
|
<script src="renderer-state.js"></script>
|
||||||
|
<script src="conversation-threads.js"></script>
|
||||||
<script src="mail-content-security.js"></script>
|
<script src="mail-content-security.js"></script>
|
||||||
<script src="app.js"></script>
|
<script src="app.js"></script>
|
||||||
<script src="platform-bridge-loader.js"></script>
|
<script src="platform-bridge-loader.js"></script>
|
||||||
|
|||||||
+48
-34
@@ -529,6 +529,9 @@ 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 || '';
|
||||||
|
modal._replyHeaders = draft
|
||||||
|
? { inReplyTo: draft.inReplyTo || '', references: draft.references || '' }
|
||||||
|
: reply && !forward ? window.epMailConversationThreads.replyHeaders(reply) : { inReplyTo: '', references: '' };
|
||||||
let attachments = Array.isArray(draft?.attachments) ? draft.attachments : [];
|
let attachments = Array.isArray(draft?.attachments) ? draft.attachments : [];
|
||||||
modal._composeAttachments = attachments;
|
modal._composeAttachments = attachments;
|
||||||
const fields = modal.querySelector('.compose-fields');
|
const fields = modal.querySelector('.compose-fields');
|
||||||
@@ -595,6 +598,7 @@ function setupDraftComposer() {
|
|||||||
contentBase64: btoa(binary)
|
contentBase64: btoa(binary)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if (closed) return;
|
||||||
attachments.push(...selected);
|
attachments.push(...selected);
|
||||||
renderAttachments();
|
renderAttachments();
|
||||||
await persist();
|
await persist();
|
||||||
@@ -621,58 +625,67 @@ function setupDraftComposer() {
|
|||||||
modal.querySelector('.compose-footer').insertBefore(save, selectMailUi('#send'));
|
modal.querySelector('.compose-footer').insertBefore(save, selectMailUi('#send'));
|
||||||
let saveTimer;
|
let saveTimer;
|
||||||
let closed = false;
|
let closed = false;
|
||||||
const persist = async () => {
|
let pendingSave = Promise.resolve();
|
||||||
if (closed || !selectMailUi('#compose-to')) return;
|
const persist = () => {
|
||||||
|
if (closed || !modal.isConnected) return Promise.resolve(false);
|
||||||
const values = {
|
const values = {
|
||||||
id: modal.dataset.draftId || window.crypto.randomUUID(),
|
to: modal.querySelector('#compose-to').value,
|
||||||
to: selectMailUi('#compose-to').value,
|
cc: modal.querySelector('#compose-cc').value,
|
||||||
cc: selectMailUi('#compose-cc').value,
|
subject: modal.querySelector('#compose-subject').value,
|
||||||
subject: selectMailUi('#compose-subject').value,
|
text: modal.querySelector('#compose-body').value,
|
||||||
text: selectMailUi('#compose-body').value,
|
attachments: [...attachments],
|
||||||
attachments
|
...modal._replyHeaders
|
||||||
};
|
};
|
||||||
if (!Object.values(values).some(value => typeof value === 'string' && value.trim()) && !attachments.length) return;
|
if (!modal.dataset.draftId && ![values.to, values.cc, values.subject, values.text].some(value => value.trim()) && !values.attachments.length) return Promise.resolve(false);
|
||||||
|
values.id = modal.dataset.draftId || window.crypto.randomUUID();
|
||||||
modal.dataset.draftId = values.id;
|
modal.dataset.draftId = values.id;
|
||||||
const result = await window.daybreakMail.saveDraft(values);
|
const operation = pendingSave.then(async () => {
|
||||||
modal.dataset.draftId = result.id;
|
await window.daybreakMail.saveDraft(values);
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
pendingSave = operation.then(() => {}, () => {});
|
||||||
|
return operation;
|
||||||
};
|
};
|
||||||
save.onclick = async () => {
|
save.onclick = async () => {
|
||||||
try {
|
try {
|
||||||
await persist();
|
const saved = await persist();
|
||||||
toastMailUi('Draft saved on this device');
|
toastMailUi(saved ? 'Draft saved on this device' : 'Nothing to save in this draft');
|
||||||
if (rendererState.activeFolder === 'Drafts') void syncMailbox(false);
|
if (saved && rendererState.activeFolder === 'Drafts') void syncMailbox(false);
|
||||||
} catch (error) { toastMailUi(error.message || 'Could not save draft'); }
|
} catch (error) { toastMailUi(error.message || 'Could not save draft'); }
|
||||||
};
|
};
|
||||||
modal.addEventListener('input', () => {
|
modal.addEventListener('input', () => {
|
||||||
clearTimeout(saveTimer);
|
clearTimeout(saveTimer);
|
||||||
saveTimer = setTimeout(() => persist().catch(error => toastMailUi(error.message || 'Could not save draft')), 700);
|
saveTimer = setTimeout(() => persist().catch(error => toastMailUi(error.message || 'Could not save draft')), 700);
|
||||||
});
|
});
|
||||||
modal.querySelector('.modal-overlay')?.addEventListener('click', event => {
|
const saveAndClose = () => {
|
||||||
|
if (closed) return;
|
||||||
|
clearTimeout(saveTimer);
|
||||||
|
persist().then(saved => { if (saved && rendererState.activeFolder === 'Drafts') void syncMailbox(false); })
|
||||||
|
.catch(error => toastMailUi(error.message || 'Could not save draft'));
|
||||||
|
closed = true;
|
||||||
|
};
|
||||||
|
root.querySelector('.modal-overlay')?.addEventListener('click', event => {
|
||||||
if (!event.target.classList.contains('modal-overlay')) return;
|
if (!event.target.classList.contains('modal-overlay')) return;
|
||||||
clearTimeout(saveTimer);
|
saveAndClose();
|
||||||
persist().then(() => { if (rendererState.activeFolder === 'Drafts') void syncMailbox(false); })
|
|
||||||
.catch(error => toastMailUi(error.message || 'Could not save draft'));
|
|
||||||
closed = true;
|
|
||||||
}, true);
|
}, true);
|
||||||
root.querySelector('.modal-close')?.addEventListener('click', () => {
|
root.querySelector('.modal-close')?.addEventListener('click', saveAndClose, true);
|
||||||
|
modal.addEventListener('keydown', event => {
|
||||||
|
if (event.key === 'Escape') saveAndClose();
|
||||||
|
});
|
||||||
|
const deleteSavedDraft = async () => {
|
||||||
clearTimeout(saveTimer);
|
clearTimeout(saveTimer);
|
||||||
persist().then(() => { if (rendererState.activeFolder === 'Drafts') void syncMailbox(false); })
|
|
||||||
.catch(error => toastMailUi(error.message || 'Could not save draft'));
|
|
||||||
closed = true;
|
closed = true;
|
||||||
}, true);
|
await pendingSave;
|
||||||
|
if (modal.dataset.draftId) await window.daybreakMail.deleteDraft(modal.dataset.draftId);
|
||||||
|
};
|
||||||
|
modal._deleteSavedDraft = deleteSavedDraft;
|
||||||
selectMailUi('#discard').onclick = async () => {
|
selectMailUi('#discard').onclick = async () => {
|
||||||
clearTimeout(saveTimer);
|
|
||||||
closed = true;
|
|
||||||
try {
|
try {
|
||||||
if (modal.dataset.draftId) await window.daybreakMail.deleteDraft(modal.dataset.draftId);
|
await deleteSavedDraft();
|
||||||
root.innerHTML = '';
|
root.innerHTML = '';
|
||||||
if (rendererState.activeFolder === 'Drafts') void syncMailbox(false);
|
if (rendererState.activeFolder === 'Drafts') void syncMailbox(false);
|
||||||
} catch (error) { toastMailUi(error.message || 'Could not delete draft'); }
|
} catch (error) { toastMailUi(error.message || 'Could not delete draft'); }
|
||||||
};
|
};
|
||||||
selectMailUi('#send').addEventListener('click', () => {
|
|
||||||
clearTimeout(saveTimer);
|
|
||||||
closed = true;
|
|
||||||
}, true);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1044,6 +1057,7 @@ if (window.daybreakMail) {
|
|||||||
text: selectMailUi('#compose-body').value,
|
text: selectMailUi('#compose-body').value,
|
||||||
attachments: selectMailUi('#modal-root .compose-modal')?._composeAttachments || [],
|
attachments: selectMailUi('#modal-root .compose-modal')?._composeAttachments || [],
|
||||||
displayName: mailFeatureState.connectedAccount.displayName || window.epMailFeatures.productivity?.profileName || '',
|
displayName: mailFeatureState.connectedAccount.displayName || window.epMailFeatures.productivity?.profileName || '',
|
||||||
|
...(selectMailUi('#modal-root .compose-modal')?._replyHeaders || {}),
|
||||||
...(pgp ? { pgp } : {})
|
...(pgp ? { pgp } : {})
|
||||||
});
|
});
|
||||||
if (result.failed) {
|
if (result.failed) {
|
||||||
@@ -1053,15 +1067,15 @@ if (window.daybreakMail) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (result.queued) {
|
if (result.queued) {
|
||||||
const draftId = selectMailUi('#modal-root .compose-modal')?.dataset.draftId;
|
const modal = selectMailUi('#modal-root .compose-modal');
|
||||||
if (draftId) await window.daybreakMail.deleteDraft(draftId);
|
if (modal?._deleteSavedDraft) await modal._deleteSavedDraft();
|
||||||
selectMailUi('#modal-root').innerHTML = '';
|
selectMailUi('#modal-root').innerHTML = '';
|
||||||
toastMailUi('Offline: message queued and will send when connected');
|
toastMailUi('Offline: message queued and will send when connected');
|
||||||
if (rendererState.activeFolder === 'Drafts') void syncMailbox(false);
|
if (rendererState.activeFolder === 'Drafts') void syncMailbox(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const draftId = selectMailUi('#modal-root .compose-modal')?.dataset.draftId;
|
const modal = selectMailUi('#modal-root .compose-modal');
|
||||||
if (draftId) await window.daybreakMail.deleteDraft(draftId);
|
if (modal?._deleteSavedDraft) await modal._deleteSavedDraft();
|
||||||
selectMailUi('#modal-root').innerHTML = '';
|
selectMailUi('#modal-root').innerHTML = '';
|
||||||
toastMailUi(result.savedToSent ? 'Message sent and saved in Sent' : 'Message sent, but its Sent copy could not be saved');
|
toastMailUi(result.savedToSent ? 'Message sent and saved in Sent' : 'Message sent, but its Sent copy could not be saved');
|
||||||
if (rendererState.activeFolder === 'Sent') syncMailbox(false, { offset: 0 });
|
if (rendererState.activeFolder === 'Sent') syncMailbox(false, { offset: 0 });
|
||||||
|
|||||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "ep-mail",
|
"name": "ep-mail",
|
||||||
"version": "0.5.20",
|
"version": "0.6.0",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "ep-mail",
|
"name": "ep-mail",
|
||||||
"version": "0.5.20",
|
"version": "0.6.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@capacitor/android": "^8.5.2",
|
"@capacitor/android": "^8.5.2",
|
||||||
"@capacitor/core": "^8.5.2",
|
"@capacitor/core": "^8.5.2",
|
||||||
|
|||||||
+3
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ep-mail",
|
"name": "ep-mail",
|
||||||
"version": "0.5.20",
|
"version": "0.6.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "Eternity Project mail client",
|
"description": "Eternity Project mail client",
|
||||||
"homepage": "https://git.eternityproject.fi/thuttu/ep-mail-client",
|
"homepage": "https://git.eternityproject.fi/thuttu/ep-mail-client",
|
||||||
@@ -26,6 +26,7 @@
|
|||||||
"android:open": "npm run android:sync && cap open android",
|
"android:open": "npm run android:sync && cap open android",
|
||||||
"android:apk": "npm run android:sync && node scripts/build-android-apk.cjs",
|
"android:apk": "npm run android:sync && node scripts/build-android-apk.cjs",
|
||||||
"android:release-apk": "npm run android:sync && node scripts/build-android-release-apk.cjs",
|
"android:release-apk": "npm run android:sync && node scripts/build-android-release-apk.cjs",
|
||||||
|
"build": "powershell -NoProfile -ExecutionPolicy Bypass -File scripts/build.ps1",
|
||||||
"build:all": "powershell -NoProfile -ExecutionPolicy Bypass -File scripts/build-all.ps1"
|
"build:all": "powershell -NoProfile -ExecutionPolicy Bypass -File scripts/build-all.ps1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@@ -45,6 +46,7 @@
|
|||||||
"styles.css",
|
"styles.css",
|
||||||
"branding.css",
|
"branding.css",
|
||||||
"renderer-state.js",
|
"renderer-state.js",
|
||||||
|
"conversation-threads.js",
|
||||||
"mail-content-security.js",
|
"mail-content-security.js",
|
||||||
"renderer-mail-api.js",
|
"renderer-mail-api.js",
|
||||||
"app.js",
|
"app.js",
|
||||||
|
|||||||
+2
-2
@@ -158,8 +158,8 @@ pgpMailUi.wrapOpenMessage(baseOpenMessage => function (id) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Compose: encrypt/sign options.
|
// Compose: encrypt/sign options.
|
||||||
pgpMailUi.wrapShowCompose(baseShowCompose => function (reply, forward = false) {
|
pgpMailUi.wrapShowCompose(baseShowCompose => function (reply, forward = false, draft = null) {
|
||||||
baseShowCompose(reply, forward);
|
baseShowCompose(reply, forward, draft);
|
||||||
const footer = selectPgpMailUi('#modal-root .compose-footer');
|
const footer = selectPgpMailUi('#modal-root .compose-footer');
|
||||||
if (!footer || !pgpApi()) return;
|
if (!footer || !pgpApi()) return;
|
||||||
const box = document.createElement('div');
|
const box = document.createElement('div');
|
||||||
|
|||||||
@@ -19,9 +19,7 @@ function openEncryptionKeys() {
|
|||||||
const root = selectPgpKeyUi('#modal-root');
|
const root = selectPgpKeyUi('#modal-root');
|
||||||
const account = window.epMailFeatures.mail.connectedAccount || {};
|
const account = window.epMailFeatures.mail.connectedAccount || {};
|
||||||
const androidPgp = window.daybreakMail?.pgp?.platform === 'android';
|
const androidPgp = window.daybreakMail?.pgp?.platform === 'android';
|
||||||
const serverSettings = androidPgp
|
const serverSettings = `<h3 class="pgp-heading">Public key servers</h3>
|
||||||
? '<h3 class="pgp-heading">Public key servers</h3><p class="account-note">Key-server lookup and publication are disabled in Android testing. Import a public key directly and compare its fingerprint with the owner.</p><div hidden><div id="pgp-server-list"></div><input id="pgp-search-email"><button id="pgp-find-key"></button><div id="pgp-found-keys"></div><select id="pgp-publish-server"></select><input id="pgp-server-name"><input id="pgp-server-url"><select id="pgp-server-protocol"></select><button id="pgp-add-server"></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>
|
<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>
|
<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="${escapePgpKeyUi(account.email || '')}"></label>
|
<label class="compose-line"><span>Email address</span><input id="pgp-search-email" type="email" value="${escapePgpKeyUi(account.email || '')}"></label>
|
||||||
@@ -34,7 +32,7 @@ function openEncryptionKeys() {
|
|||||||
<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>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>
|
<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>`;
|
<div class="pgp-actions"><button class="discard" id="pgp-add-server">Add custom server…</button></div>`;
|
||||||
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 pgp-keys-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">${androidPgp ? 'EXPERIMENTAL ANDROID TESTING — not independently security reviewed. Private keys remain passphrase-protected inside the encrypted Android vault. Optional biometric unlock stores the passphrase in a Keystore key requiring user authentication. Back up your private key and revocation certificate: without them, encrypted mail cannot be recovered.' : '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">${androidPgp ? 'EXPERIMENTAL ANDROID TESTING — not independently security reviewed. Private keys remain passphrase-protected inside the encrypted Android vault. Optional biometric unlock stores the passphrase in a Keystore key requiring user authentication. Back up your private key and revocation certificate: without them, encrypted mail cannot be recovered.' : '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>
|
<h3 class="pgp-heading">Change a key passphrase</h3>
|
||||||
@@ -54,7 +52,7 @@ function openEncryptionKeys() {
|
|||||||
<label class="compose-line"><span>Name</span><input id="pgp-name" maxlength="100" value="${escapePgpKeyUi(account.displayName || '')}"></label>
|
<label class="compose-line"><span>Name</span><input id="pgp-name" maxlength="100" value="${escapePgpKeyUi(account.displayName || '')}"></label>
|
||||||
<label class="compose-line"><span>Email</span><input id="pgp-email" type="email" value="${escapePgpKeyUi(account.email || '')}"></label>
|
<label class="compose-line"><span>Email</span><input id="pgp-email" type="email" value="${escapePgpKeyUi(account.email || '')}"></label>
|
||||||
<label class="compose-line"><span>Passphrase</span><input id="pgp-passphrase" type="password" autocomplete="new-password" placeholder="At least 8 characters"></label>
|
<label class="compose-line"><span>Passphrase</span><input id="pgp-passphrase" type="password" autocomplete="new-password" placeholder="At least 8 characters"></label>
|
||||||
<div class="pgp-actions"><button class="send-button" id="pgp-generate">Create key</button><button class="discard" id="pgp-import">Import private key…</button></div>
|
<div class="pgp-actions"><button class="send-button" id="pgp-generate">Create key</button><button class="discard" id="pgp-import">${androidPgp ? 'Import private key from file…' : 'Import private key…'}</button>${androidPgp ? '<button class="discard" id="pgp-import-paste">Paste private key…</button>' : ''}</div>
|
||||||
<p class="account-note" id="pgp-status" role="status"></p>
|
<p class="account-note" id="pgp-status" role="status"></p>
|
||||||
</div></div></div>`;
|
</div></div></div>`;
|
||||||
const close = () => { root.innerHTML = ''; };
|
const close = () => { root.innerHTML = ''; };
|
||||||
@@ -231,15 +229,17 @@ function openEncryptionKeys() {
|
|||||||
} catch (error) { status(error.message || 'Could not create the key.'); }
|
} catch (error) { status(error.message || 'Could not create the key.'); }
|
||||||
button.disabled = false;
|
button.disabled = false;
|
||||||
};
|
};
|
||||||
selectPgpKeyUi('#pgp-import').onclick = async () => {
|
const importPrivateKey = async source => {
|
||||||
const passphrase = needPassphrase();
|
const passphrase = needPassphrase();
|
||||||
if (!passphrase) return;
|
if (!passphrase) return;
|
||||||
try {
|
try {
|
||||||
const result = await window.daybreakMail.pgp.importKey({ passphrase, accountId: account.id || null });
|
const result = await window.daybreakMail.pgp.importKey({ passphrase, accountId: account.id || null, ...(androidPgp ? { source } : {}) });
|
||||||
status(result.canceled ? '' : result.keyChangedFrom?.length ? 'Key imported. You already have a different key for this address; compare fingerprints before trusting either key.' : 'Key imported.');
|
status(result.canceled ? '' : result.keyChangedFrom?.length ? 'Key imported. You already have a different key for this address; compare fingerprints before trusting either key.' : 'Key imported.');
|
||||||
await render();
|
if (!result.canceled) await render();
|
||||||
} catch (error) { status(error.message || 'Could not import the key.'); }
|
} catch (error) { status(error.message || 'Could not import the key.'); }
|
||||||
};
|
};
|
||||||
|
selectPgpKeyUi('#pgp-import').onclick = () => importPrivateKey(androidPgp ? 'file' : undefined);
|
||||||
|
if (androidPgp) selectPgpKeyUi('#pgp-import-paste').onclick = () => importPrivateKey('paste');
|
||||||
async function renderContacts() {
|
async function renderContacts() {
|
||||||
const list = selectPgpKeyUi('#pgp-contact-list');
|
const list = selectPgpKeyUi('#pgp-contact-list');
|
||||||
let contacts = [];
|
let contacts = [];
|
||||||
@@ -359,19 +359,17 @@ function openEncryptionKeys() {
|
|||||||
};
|
};
|
||||||
enabledLabel.append(enabledText, enabled);
|
enabledLabel.append(enabledText, enabled);
|
||||||
row.append(info, enabledLabel);
|
row.append(info, enabledLabel);
|
||||||
if (!server.builtin) {
|
const remove = document.createElement('button');
|
||||||
const remove = document.createElement('button');
|
remove.className = 'discard';
|
||||||
remove.className = 'discard';
|
remove.textContent = 'Remove';
|
||||||
remove.textContent = 'Remove';
|
remove.onclick = async () => {
|
||||||
remove.onclick = async () => {
|
try {
|
||||||
try {
|
await window.daybreakMail.pgp.removeKeyServer(server.id);
|
||||||
await window.daybreakMail.pgp.removeKeyServer(server.id);
|
await renderKeyServers();
|
||||||
await renderKeyServers();
|
status(`${server.name} removed.`);
|
||||||
status('Custom key server removed.');
|
} catch (error) { status(error.message || 'Could not remove the key server.'); }
|
||||||
} catch (error) { status(error.message || 'Could not remove the key server.'); }
|
};
|
||||||
};
|
row.append(remove);
|
||||||
row.append(remove);
|
|
||||||
}
|
|
||||||
list.append(row);
|
list.append(row);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -451,13 +449,13 @@ function openEncryptionKeys() {
|
|||||||
catch (error) { status(error.message || 'Could not save the setting.'); }
|
catch (error) { status(error.message || 'Could not save the setting.'); }
|
||||||
};
|
};
|
||||||
selectPgpKeyUi('#pgp-forget').onclick = async () => { await window.daybreakMail.pgp.forgetPassphrases(); status('Remembered passphrases were cleared.'); };
|
selectPgpKeyUi('#pgp-forget').onclick = async () => { await window.daybreakMail.pgp.forgetPassphrases(); status('Remembered passphrases were cleared.'); };
|
||||||
if (!androidPgp) void renderKeyServers();
|
void renderKeyServers();
|
||||||
void renderContacts();
|
void renderContacts();
|
||||||
void render();
|
void render();
|
||||||
}
|
}
|
||||||
|
|
||||||
window.epMailFeatures.productivity.wrapOpenPreferences(baseOpenPreferences => function () {
|
window.epMailFeatures.productivity.wrapOpenPreferences(baseOpenPreferences => async function () {
|
||||||
baseOpenPreferences();
|
await baseOpenPreferences();
|
||||||
const fields = selectPgpKeyUi('#modal-root .compose-fields');
|
const fields = selectPgpKeyUi('#modal-root .compose-fields');
|
||||||
if (!fields || !pgpAvailable()) return;
|
if (!fields || !pgpAvailable()) return;
|
||||||
const button = document.createElement('button');
|
const button = document.createElement('button');
|
||||||
|
|||||||
+5725
-5094
File diff suppressed because one or more lines are too long
+1
-1
@@ -59,7 +59,7 @@ function renderLabels(){const box=selectProductivityUi('#custom-labels');if(!box
|
|||||||
function addCustomLabel(){const label=prompt('Name this label');if(!label?.trim())return;const clean=label.trim();if(customLabels.some(x=>x.toLowerCase()===clean.toLowerCase())){toastProductivityUi('That label already exists');return}customLabels.push(clean);productWrite(productKeys.labels,customLabels);renderLabels();toastProductivityUi('Label added')}
|
function addCustomLabel(){const label=prompt('Name this label');if(!label?.trim())return;const clean=label.trim();if(customLabels.some(x=>x.toLowerCase()===clean.toLowerCase())){toastProductivityUi('That label already exists');return}customLabels.push(clean);productWrite(productKeys.labels,customLabels);renderLabels();toastProductivityUi('Label added')}
|
||||||
function messageAction(message,action){if(productivityMailUi.connectedAccount&&window.daybreakMail&&message.uid){return window.daybreakMail.updateMessage({uid:message.uid,folder:message.sourceFolder||productivityMailUi.state.activeFolder,action,enabled:action==='star'?!message.star:true}).then(result=>{if(result?.queued)toastProductivityUi('Offline: action queued and will sync when connected');return result})}return Promise.resolve()}
|
function messageAction(message,action){if(productivityMailUi.connectedAccount&&window.daybreakMail&&message.uid){return window.daybreakMail.updateMessage({uid:message.uid,folder:message.sourceFolder||productivityMailUi.state.activeFolder,action,enabled:action==='star'?!message.star:true}).then(result=>{if(result?.queued)toastProductivityUi('Offline: action queued and will sync when connected');return result})}return Promise.resolve()}
|
||||||
async function actOnSelected(action){const selected=productivityMailUi.state.messages.filter(m=>productivityMailUi.state.selectedIds.has(m.id));if(!selected.length){toastProductivityUi('Select one or more messages first');return}try{for(const m of selected)await messageAction(m,action);if(action==='archive'||action==='delete')selected.forEach(m=>{m[action==='archive'?'archived':'deleted']=true});if(action==='unread')selected.forEach(m=>m.unread=true);productivityMailUi.state.selectedIds.clear();productivityMailUi.renderList();if(action==='archive'||action==='delete')selectProductivityUi('#reader-pane').innerHTML=productivityMailUi.emptyReader();toastProductivityUi(action==='archive'?'Messages archived':action==='delete'?'Messages moved to Trash':'Messages marked unread')}catch(e){toastProductivityUi(e.message||'Could not update messages')}}
|
async function actOnSelected(action){const selected=productivityMailUi.state.messages.filter(m=>productivityMailUi.state.selectedIds.has(m.id));if(!selected.length){toastProductivityUi('Select one or more messages first');return}try{for(const m of selected)await messageAction(m,action);if(action==='archive'||action==='delete')selected.forEach(m=>{m[action==='archive'?'archived':'deleted']=true});if(action==='unread')selected.forEach(m=>m.unread=true);productivityMailUi.state.selectedIds.clear();productivityMailUi.renderList();if(action==='archive'||action==='delete')selectProductivityUi('#reader-pane').innerHTML=productivityMailUi.emptyReader();toastProductivityUi(action==='archive'?'Messages archived':action==='delete'?'Messages moved to Trash':'Messages marked unread')}catch(e){toastProductivityUi(e.message||'Could not update messages')}}
|
||||||
document.addEventListener('DOMContentLoaded',()=>{setProfileName(profileSettings.name);renderLabels();selectAllProductivityUi('.profile-button').forEach(b=>b.onclick=openAccountSettings);selectProductivityUi('#settings-button').onclick=openPreferences;selectProductivityUi('#add-label').onclick=addCustomLabel;selectProductivityUi('#sidebar-menu').onclick=()=>{const choice=prompt('Mailbox options: enter “refresh†to sync, or “account†to manage your mailbox.');if(choice?.toLowerCase()==='account')productivityMailUi.openMailAccount();else if(choice?.toLowerCase()==='refresh')productivityMailUi.syncMailbox(true)};selectProductivityUi('.help-button').onclick=()=>{const root=selectProductivityUi('#modal-root');root.innerHTML='<div class="modal-overlay"><div class="compose-modal"><div class="modal-head"><span>ep-mail help</span><button class="modal-close">×</button></div><div class="compose-fields"><p>Use the left rail to switch between Mail, Calendar, and Contacts. Select mail with the checkboxes for bulk actions. Calendar events and contacts are saved on this device.</p></div><div class="compose-footer"><span></span><button class="send-button modal-close">Got it</button></div></div></div>';selectAllProductivityUi('.modal-close').forEach(b=>b.onclick=()=>root.innerHTML='')};selectProductivityUi('#select-all').onclick=()=>{const rows=selectAllProductivityUi('.message');const ids=rows.map(r=>Number(r.dataset.id));const all=ids.length&&ids.every(id=>productivityMailUi.state.selectedIds.has(id));ids.forEach(id=>all?productivityMailUi.state.selectedIds.delete(id):productivityMailUi.state.selectedIds.add(id));productivityMailUi.renderList()};selectProductivityUi('#archive-selected').onclick=()=>actOnSelected('archive');selectProductivityUi('#delete-selected').onclick=()=>actOnSelected('delete');selectProductivityUi('#mark-unread').onclick=()=>actOnSelected('unread');document.addEventListener('click',e=>{const more=e.target.closest('.reader-tools button[title="More"]');if(more){const m=productivityMailUi.state.messages.find(x=>x.id===productivityMailUi.state.activeMessage);if(!m)return;const choice=prompt('Message actions: unread, snooze, label, inbox');if(choice==='unread')messageAction(m,'unread').then(()=>{m.unread=true;productivityMailUi.renderList();toastProductivityUi('Marked unread')});else if(choice==='snooze'){snoozedIds=[...new Set([...snoozedIds,m.id])];productWrite(productKeys.snoozed,snoozedIds);toastProductivityUi('Message snoozed')}else if(choice==='label')addMessageLabel(m);else if(choice==='inbox'){m.archived=false;productivityMailUi.renderList();toastProductivityUi('Moved to Inbox')}e.stopImmediatePropagation();return}const readerAction=e.target.closest('#reader-archive,#reader-delete,#reader-star');if(readerAction){const m=productivityMailUi.state.messages.find(x=>x.id===productivityMailUi.state.activeMessage);if(!m)return;e.stopImmediatePropagation();const action=readerAction.id==='reader-archive'?'archive':readerAction.id==='reader-delete'?'delete':'star';messageAction(m,action).then(()=>{if(action==='star')m.star=!m.star;else m[action==='archive'?'archived':'deleted']=true;if(action==='star'){productivityMailUi.renderList();openMessage(m.id)}else{productivityMailUi.renderList();selectProductivityUi('#reader-pane').innerHTML=productivityMailUi.emptyReader();toastProductivityUi(action==='archive'?'Moved to Archive':'Moved to Trash')}}).catch(x=>toastProductivityUi(x.message));return}const star=e.target.closest('.star');if(star){const m=productivityMailUi.state.messages.find(x=>x.id===Number(star.closest('.message').dataset.id));if(m){e.stopImmediatePropagation();messageAction(m,'star').then(()=>{m.star=!m.star;productivityMailUi.renderList()}).catch(x=>toastProductivityUi(x.message))}}const row=e.target.closest('.message');if(row&&!e.target.closest('button,input')){const m=productivityMailUi.state.messages.find(x=>x.id===Number(row.dataset.id));if(m&&productivityMailUi.connectedAccount&&m.uid)window.daybreakMail.updateMessage({uid:m.uid,folder:productivityMailUi.state.activeFolder,action:'unread',enabled:false}).catch(()=>{})}},{capture:true});selectProductivityUi('#load-more').textContent='Load more ↓';});
|
document.addEventListener('DOMContentLoaded',()=>{setProfileName(profileSettings.name);renderLabels();selectAllProductivityUi('.profile-button').forEach(b=>b.onclick=openAccountSettings);selectProductivityUi('#settings-button').onclick=openPreferences;selectProductivityUi('#add-label').onclick=addCustomLabel;selectProductivityUi('#sidebar-menu').onclick=()=>{const choice=prompt('Mailbox options: enter “refresh†to sync, or “account†to manage your mailbox.');if(choice?.toLowerCase()==='account')productivityMailUi.openMailAccount();else if(choice?.toLowerCase()==='refresh')productivityMailUi.syncMailbox(true)};selectProductivityUi('.help-button').onclick=()=>{const root=selectProductivityUi('#modal-root');root.innerHTML='<div class="modal-overlay"><div class="compose-modal"><div class="modal-head"><span>ep-mail help</span><button class="modal-close">×</button></div><div class="compose-fields"><p>Use the left rail to switch between Mail, Calendar, and Contacts. Select mail with the checkboxes for bulk actions. Calendar events and contacts are saved on this device.</p></div><div class="compose-footer"><span></span><button class="send-button modal-close">Got it</button></div></div></div>';selectAllProductivityUi('.modal-close').forEach(b=>b.onclick=()=>root.innerHTML='')};selectProductivityUi('#select-all').onclick=()=>{const rows=selectAllProductivityUi('.message').filter(row=>!row.closest('[hidden]'));const ids=rows.map(r=>Number(r.dataset.id));const all=ids.length&&ids.every(id=>productivityMailUi.state.selectedIds.has(id));ids.forEach(id=>all?productivityMailUi.state.selectedIds.delete(id):productivityMailUi.state.selectedIds.add(id));productivityMailUi.renderList()};selectProductivityUi('#archive-selected').onclick=()=>actOnSelected('archive');selectProductivityUi('#delete-selected').onclick=()=>actOnSelected('delete');selectProductivityUi('#mark-unread').onclick=()=>actOnSelected('unread');document.addEventListener('click',e=>{const more=e.target.closest('.reader-tools button[title="More"]');if(more){const m=productivityMailUi.state.messages.find(x=>x.id===productivityMailUi.state.activeMessage);if(!m)return;const choice=prompt('Message actions: unread, snooze, label, inbox');if(choice==='unread')messageAction(m,'unread').then(()=>{m.unread=true;productivityMailUi.renderList();toastProductivityUi('Marked unread')});else if(choice==='snooze'){snoozedIds=[...new Set([...snoozedIds,m.id])];productWrite(productKeys.snoozed,snoozedIds);toastProductivityUi('Message snoozed')}else if(choice==='label')addMessageLabel(m);else if(choice==='inbox'){m.archived=false;productivityMailUi.renderList();toastProductivityUi('Moved to Inbox')}e.stopImmediatePropagation();return}const readerAction=e.target.closest('#reader-archive,#reader-delete,#reader-star');if(readerAction){const m=productivityMailUi.state.messages.find(x=>x.id===productivityMailUi.state.activeMessage);if(!m)return;e.stopImmediatePropagation();const action=readerAction.id==='reader-archive'?'archive':readerAction.id==='reader-delete'?'delete':'star';messageAction(m,action).then(()=>{if(action==='star')m.star=!m.star;else m[action==='archive'?'archived':'deleted']=true;if(action==='star'){productivityMailUi.renderList();openMessage(m.id)}else{productivityMailUi.renderList();selectProductivityUi('#reader-pane').innerHTML=productivityMailUi.emptyReader();toastProductivityUi(action==='archive'?'Moved to Archive':'Moved to Trash')}}).catch(x=>toastProductivityUi(x.message));return}const star=e.target.closest('.star');if(star){const m=productivityMailUi.state.messages.find(x=>x.id===Number(star.closest('.message').dataset.id));if(m){e.stopImmediatePropagation();messageAction(m,'star').then(()=>{m.star=!m.star;productivityMailUi.renderList()}).catch(x=>toastProductivityUi(x.message))}}const row=e.target.closest('.message');if(row&&!e.target.closest('button,input')){const m=productivityMailUi.state.messages.find(x=>x.id===Number(row.dataset.id));if(m&&productivityMailUi.connectedAccount&&m.uid)window.daybreakMail.updateMessage({uid:m.uid,folder:productivityMailUi.state.activeFolder,action:'unread',enabled:false}).catch(()=>{})}},{capture:true});selectProductivityUi('#load-more').textContent='Load more ↓';});
|
||||||
function addMessageLabel(m){const options=['Design','Travel','Personal',...customLabels];const label=prompt(`Add a label (${options.join(', ')})`);if(!label)return;m.tags=[...new Set([...(m.tags||[]),label])];productWrite(`daybreak-message-labels-${m.id}`,m.tags);toastProductivityUi(`Labeled ${label}`);productivityMailUi.renderList()}
|
function addMessageLabel(m){const options=['Design','Travel','Personal',...customLabels];const label=prompt(`Add a label (${options.join(', ')})`);if(!label)return;m.tags=[...new Set([...(m.tags||[]),label])];productWrite(`daybreak-message-labels-${m.id}`,m.tags);toastProductivityUi(`Labeled ${label}`);productivityMailUi.renderList()}
|
||||||
productivityMailUi.wrapRenderList(baseMessageRenderer => function () {
|
productivityMailUi.wrapRenderList(baseMessageRenderer => function () {
|
||||||
const state = productivityMailUi.state;
|
const state = productivityMailUi.state;
|
||||||
|
|||||||
@@ -1,8 +1,23 @@
|
|||||||
import { Capacitor, registerPlugin } from '@capacitor/core';
|
import { Capacitor, CapacitorHttp, registerPlugin } from '@capacitor/core';
|
||||||
import { createAndroidPgp } from './android-pgp.js';
|
import { createAndroidPgp } from './android-pgp.js';
|
||||||
|
|
||||||
const EpMail = registerPlugin('EpMail');
|
const EpMail = registerPlugin('EpMail');
|
||||||
|
|
||||||
|
// Native HTTP avoids WebView CORS limits; redirects are refused like on desktop.
|
||||||
|
async function nativeFetch(url, options = {}) {
|
||||||
|
const headers = options.headers || {};
|
||||||
|
const contentType = String(headers['content-type'] || '');
|
||||||
|
let data = options.body;
|
||||||
|
if (typeof data === 'string' && contentType.includes('json')) data = JSON.parse(data);
|
||||||
|
else if (typeof data === 'string' && contentType.includes('x-www-form-urlencoded')) data = Object.fromEntries(new URLSearchParams(data));
|
||||||
|
const response = await CapacitorHttp.request({ url: String(url), method: options.method || 'GET', headers, data,
|
||||||
|
responseType: 'text', disableRedirects: true, connectTimeout: 15000, readTimeout: 15000 });
|
||||||
|
const text = typeof response.data === 'string' ? response.data : JSON.stringify(response.data ?? '');
|
||||||
|
const lowered = Object.fromEntries(Object.entries(response.headers || {}).map(([name, value]) => [name.toLowerCase(), value]));
|
||||||
|
return { status: response.status, ok: response.status >= 200 && response.status < 300,
|
||||||
|
headers: { get: name => lowered[String(name).toLowerCase()] ?? null }, body: [new TextEncoder().encode(text)] };
|
||||||
|
}
|
||||||
|
|
||||||
if (Capacitor.isNativePlatform() && Capacitor.getPlatform() === 'android') {
|
if (Capacitor.isNativePlatform() && Capacitor.getPlatform() === 'android') {
|
||||||
const daybreakMail = {
|
const daybreakMail = {
|
||||||
platform: 'android',
|
platform: 'android',
|
||||||
@@ -63,6 +78,6 @@ if (Capacitor.isNativePlatform() && Capacitor.getPlatform() === 'android') {
|
|||||||
davSaveContact: contact => EpMail.davSaveContact(contact),
|
davSaveContact: contact => EpMail.davSaveContact(contact),
|
||||||
davDeleteContact: remote => EpMail.davDeleteContact(remote)
|
davDeleteContact: remote => EpMail.davDeleteContact(remote)
|
||||||
};
|
};
|
||||||
daybreakMail.pgp = createAndroidPgp({ EpMail, getAccount: () => EpMail.getAccount() });
|
daybreakMail.pgp = createAndroidPgp({ EpMail, getAccount: () => EpMail.getAccount(), fetchImpl: nativeFetch });
|
||||||
window.daybreakMail = daybreakMail;
|
window.daybreakMail = daybreakMail;
|
||||||
}
|
}
|
||||||
|
|||||||
+81
-10
@@ -1,4 +1,7 @@
|
|||||||
import * as openpgp from 'openpgp';
|
import * as openpgp from 'openpgp';
|
||||||
|
import keyServers from '../desktop/pgp-keyservers.cjs';
|
||||||
|
|
||||||
|
const { BUILTIN_SERVER_IDS, MAX_CUSTOM_SERVERS, createKeyServerService, listServers, normalizeCustomServer } = keyServers;
|
||||||
|
|
||||||
const MAX_KEY_LENGTH = 200000;
|
const MAX_KEY_LENGTH = 200000;
|
||||||
const MAX_MESSAGE_BYTES = 25 * 1024 * 1024;
|
const MAX_MESSAGE_BYTES = 25 * 1024 * 1024;
|
||||||
@@ -255,8 +258,19 @@ async function signatureStatuses(signatures, verification, sender) {
|
|||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createAndroidPgp({ EpMail, getAccount, confirm = globalThis.confirm }) {
|
export function createAndroidPgp({ EpMail, getAccount, confirm = globalThis.confirm, fetchImpl }) {
|
||||||
|
const keyServerService = createKeyServerService({ fetchImpl });
|
||||||
let storePromise;
|
let storePromise;
|
||||||
|
function serverSettings(data) {
|
||||||
|
const settings = data.settings || {};
|
||||||
|
const ids = value => Array.isArray(value) ? [...new Set(value.filter(id => typeof id === 'string'))] : [];
|
||||||
|
return { ...settings, customKeyServers: Array.isArray(settings.customKeyServers) ? settings.customKeyServers : [],
|
||||||
|
enabledKeyServers: ids(settings.enabledKeyServers), removedBuiltinKeyServers: ids(settings.removedBuiltinKeyServers) };
|
||||||
|
}
|
||||||
|
function currentServers(data) {
|
||||||
|
const settings = serverSettings(data);
|
||||||
|
return listServers(settings.customKeyServers, settings.enabledKeyServers, settings.removedBuiltinKeyServers);
|
||||||
|
}
|
||||||
const passphrases = new Map();
|
const passphrases = new Map();
|
||||||
let cacheMinutes = 10;
|
let cacheMinutes = 10;
|
||||||
|
|
||||||
@@ -310,7 +324,7 @@ export function createAndroidPgp({ EpMail, getAccount, confirm = globalThis.conf
|
|||||||
}
|
}
|
||||||
const user = await key.getPrimaryUser();
|
const user = await key.getPrimaryUser();
|
||||||
data.contacts.push({ fingerprint, name: user.user.userID?.name || '', emails, trust: 'unknown',
|
data.contacts.push({ fingerprint, name: user.user.userID?.name || '', emails, trust: 'unknown',
|
||||||
source: ['import', 'message', 'paste'].includes(source) ? source : 'import', addedAt: Date.now(), publicKey: key.armor() });
|
source: ['import', 'message', 'paste', 'keyserver'].includes(source) ? source : 'import', addedAt: Date.now(), publicKey: key.armor() });
|
||||||
await persist(data);
|
await persist(data);
|
||||||
return { contact: { fingerprint, name: user.user.userID?.name || '', emails, trust: 'unknown', source, addedAt: Date.now() }, keyChangedFrom };
|
return { contact: { fingerprint, name: user.user.userID?.name || '', emails, trust: 'unknown', source, addedAt: Date.now() }, keyChangedFrom };
|
||||||
}
|
}
|
||||||
@@ -391,6 +405,8 @@ export function createAndroidPgp({ EpMail, getAccount, confirm = globalThis.conf
|
|||||||
`Subject: ${encodeHeader(message.subject || '(no subject)')}`,
|
`Subject: ${encodeHeader(message.subject || '(no subject)')}`,
|
||||||
`Date: ${new Date().toUTCString().replace('GMT', '+0000')}`,
|
`Date: ${new Date().toUTCString().replace('GMT', '+0000')}`,
|
||||||
`Message-ID: ${safeHeader(message.messageId || `<${crypto.randomUUID()}@ep-mail.local>`, 200)}`,
|
`Message-ID: ${safeHeader(message.messageId || `<${crypto.randomUUID()}@ep-mail.local>`, 200)}`,
|
||||||
|
...(message.inReplyTo ? [`In-Reply-To: ${safeHeader(message.inReplyTo, 254)}`] : []),
|
||||||
|
...(message.references ? [`References: ${safeHeader(message.references, 900)}`] : []),
|
||||||
'MIME-Version: 1.0'
|
'MIME-Version: 1.0'
|
||||||
];
|
];
|
||||||
let contentType;
|
let contentType;
|
||||||
@@ -523,8 +539,15 @@ export function createAndroidPgp({ EpMail, getAccount, confirm = globalThis.conf
|
|||||||
await persist(data);
|
await persist(data);
|
||||||
return { key: publicInfo(entry), revocationCertificate: generated.revocationCertificate };
|
return { key: publicInfo(entry), revocationCertificate: generated.revocationCertificate };
|
||||||
},
|
},
|
||||||
async importKey({ armoredKey, passphrase, accountId = null }) {
|
async importKey({ armoredKey, passphrase, accountId = null, source = 'paste' }) {
|
||||||
if (!armoredKey) armoredKey = prompt('Paste an ASCII-armored OpenPGP private key (up to 200 KB):') || '';
|
if (!armoredKey && source === 'file') {
|
||||||
|
const selected = await EpMail.pickPgpPrivateKey();
|
||||||
|
if (selected.canceled) return { canceled: true };
|
||||||
|
armoredKey = selected.armoredKey;
|
||||||
|
if (typeof armoredKey !== 'string' || !armoredKey.trim()) throw new Error('That key file is empty.');
|
||||||
|
} else if (!armoredKey) {
|
||||||
|
armoredKey = prompt('Paste an ASCII-armored OpenPGP private key (up to 200 KB):') || '';
|
||||||
|
}
|
||||||
const armored = String(armoredKey).trim();
|
const armored = String(armoredKey).trim();
|
||||||
if (!armored || armored.length > MAX_KEY_LENGTH) throw new Error('That key file is empty or too large.');
|
if (!armored || armored.length > MAX_KEY_LENGTH) throw new Error('That key file is empty or too large.');
|
||||||
if (typeof passphrase !== 'string' || passphrase.length < 8) throw new Error('Use a passphrase of at least 8 characters.');
|
if (typeof passphrase !== 'string' || passphrase.length < 8) throw new Error('Use a passphrase of at least 8 characters.');
|
||||||
@@ -607,12 +630,60 @@ export function createAndroidPgp({ EpMail, getAccount, confirm = globalThis.conf
|
|||||||
return { cacheMinutes };
|
return { cacheMinutes };
|
||||||
},
|
},
|
||||||
async forgetPassphrases() { clear(); return { cleared: true }; },
|
async forgetPassphrases() { clear(); return { cleared: true }; },
|
||||||
async keyServers() { return []; },
|
async keyServers() { return currentServers(await store()); },
|
||||||
async findKey() { throw new Error('Key-server lookup is not included in Android testing. Import a public key directly.'); },
|
async findKey({ email } = {}) { return keyServerService.lookupEnabled(currentServers(await store()), email); },
|
||||||
async addKeyServer() { throw new Error('Key-server support is not included in Android testing.'); },
|
async addKeyServer(input) {
|
||||||
async removeKeyServer() { throw new Error('Key-server support is not included in Android testing.'); },
|
const candidate = normalizeCustomServer(input);
|
||||||
async setKeyServerEnabled() { throw new Error('Key-server support is not included in Android testing.'); },
|
const data = await store();
|
||||||
async publishKey() { throw new Error('Key-server support is not included in Android testing.'); },
|
const settings = serverSettings(data);
|
||||||
|
const custom = settings.customKeyServers.map(normalizeCustomServer);
|
||||||
|
if (custom.length >= MAX_CUSTOM_SERVERS) throw new Error(`You can configure up to ${MAX_CUSTOM_SERVERS} custom key servers.`);
|
||||||
|
if (currentServers(data).some(server => server.url === candidate.url && server.protocol === candidate.protocol)) throw new Error('That key server is already configured.');
|
||||||
|
const host = new URL(candidate.url).host;
|
||||||
|
if (!confirm(`Allow ep-mail to contact ${host} for OpenPGP keys?\n\nProtocol: ${candidate.protocol.toUpperCase()}\nThe server may learn which email addresses you search for. Only add a server you trust.`)) return { canceled: true };
|
||||||
|
candidate.id = crypto.randomUUID();
|
||||||
|
data.settings = { ...serverSettings(data), customKeyServers: [...custom, candidate] };
|
||||||
|
await persist(data);
|
||||||
|
return { server: candidate };
|
||||||
|
},
|
||||||
|
async removeKeyServer(serverId) {
|
||||||
|
const id = String(serverId || '');
|
||||||
|
const data = await store();
|
||||||
|
const settings = serverSettings(data);
|
||||||
|
const custom = settings.customKeyServers.filter(server => server.id !== id);
|
||||||
|
const removesBuiltin = BUILTIN_SERVER_IDS.includes(id) && !settings.removedBuiltinKeyServers.includes(id);
|
||||||
|
if (custom.length === settings.customKeyServers.length && !removesBuiltin) throw new Error('That key server was not found.');
|
||||||
|
data.settings = { ...settings, customKeyServers: custom,
|
||||||
|
enabledKeyServers: settings.enabledKeyServers.filter(enabledId => enabledId !== id),
|
||||||
|
removedBuiltinKeyServers: removesBuiltin ? [...settings.removedBuiltinKeyServers, id] : settings.removedBuiltinKeyServers };
|
||||||
|
await persist(data);
|
||||||
|
return { removed: true };
|
||||||
|
},
|
||||||
|
async setKeyServerEnabled(serverId, enabled) {
|
||||||
|
if (typeof enabled !== 'boolean') throw new Error('Choose whether to enable or disable this key server.');
|
||||||
|
const id = String(serverId || '');
|
||||||
|
const data = await store();
|
||||||
|
if (!currentServers(data).some(server => server.id === id)) throw new Error('That key server was not found.');
|
||||||
|
const settings = serverSettings(data);
|
||||||
|
const next = new Set(settings.enabledKeyServers);
|
||||||
|
if (enabled) next.add(id); else next.delete(id);
|
||||||
|
data.settings = { ...settings, enabledKeyServers: [...next] };
|
||||||
|
await persist(data);
|
||||||
|
return { serverId: id, enabled };
|
||||||
|
},
|
||||||
|
async publishKey({ fingerprint, serverId } = {}) {
|
||||||
|
const data = await store();
|
||||||
|
const server = currentServers(data).find(item => item.id === String(serverId || ''));
|
||||||
|
if (!server) throw new Error('Choose a configured key server.');
|
||||||
|
if (!server.enabled) throw new Error('Enable the selected key server before publishing to it.');
|
||||||
|
const entry = data.keys.find(item => item.fingerprint === fingerprint);
|
||||||
|
if (!entry) throw new Error('That key was not found.');
|
||||||
|
if (!entry.email) throw new Error('This key has no email address to publish.');
|
||||||
|
const publicKey = await openpgp.readKey({ armoredKey: entry.publicKey });
|
||||||
|
if (!emailsOf(publicKey).includes(String(entry.email).toLowerCase())) throw new Error('The selected key no longer matches its stored email address.');
|
||||||
|
if (!confirm(`Publish the public key for ${entry.email} to ${server.name}?\n\nFingerprint:\n${fingerprint.match(/.{1,4}/g).join(' ')}\n\nOnly the public key will be sent. This exposes the email address in the key to the server, which may retain it. The server may send a verification email before the key becomes searchable.`)) return { canceled: true };
|
||||||
|
return keyServerService.publish(server, entry.email, entry.publicKey, fingerprint);
|
||||||
|
},
|
||||||
clearPassphrases: clear,
|
clearPassphrases: clear,
|
||||||
buildOutgoing
|
buildOutgoing
|
||||||
};
|
};
|
||||||
|
|||||||
+16
-13
@@ -1,19 +1,22 @@
|
|||||||
# Builds the Android APK and the Windows portable exe into .\release
|
param(
|
||||||
|
[string]$WslDistribution
|
||||||
|
)
|
||||||
|
|
||||||
$ErrorActionPreference = 'Stop'
|
$ErrorActionPreference = 'Stop'
|
||||||
Set-Location $PSScriptRoot\..
|
Set-Location $PSScriptRoot\..
|
||||||
$version = (Get-Content package.json -Raw | ConvertFrom-Json).version
|
$version = (Get-Content package.json -Raw | ConvertFrom-Json).version
|
||||||
if (-not $env:JAVA_HOME) { $env:JAVA_HOME = 'C:\Program Files\Android\Android Studio\jbr' }
|
|
||||||
if (-not $env:ANDROID_HOME) { $env:ANDROID_HOME = Join-Path $env:LOCALAPPDATA 'Android\Sdk' }
|
|
||||||
New-Item -ItemType Directory -Force release | Out-Null
|
|
||||||
|
|
||||||
Write-Host "== Building APK $version =="
|
& "$PSScriptRoot\build.ps1"
|
||||||
npm run android:apk
|
|
||||||
if ($LASTEXITCODE) { throw 'APK build failed' }
|
|
||||||
Copy-Item android\app\build\outputs\apk\debug\app-debug.apk "release\ep-mail $version.apk" -Force
|
|
||||||
|
|
||||||
Write-Host "== Building portable exe $version =="
|
Write-Host "`n== Building Windows installer $version =="
|
||||||
npm run dist:win:portable
|
npm run dist:win:installer
|
||||||
if ($LASTEXITCODE) { throw 'Portable build failed' }
|
if ($LASTEXITCODE) { throw 'Windows installer build failed' }
|
||||||
|
|
||||||
Write-Host "`nDone:"
|
Write-Host "`n== Building Linux AppImage and deb $version in WSL =="
|
||||||
Get-ChildItem release | Where-Object { $_.Name -like "ep-mail $version.*" } | ForEach-Object { " $($_.FullName)" }
|
$wslArguments = @()
|
||||||
|
if ($WslDistribution) { $wslArguments += @('--distribution', $WslDistribution) }
|
||||||
|
$wslArguments += @('--exec', 'bash', './scripts/build-linux-wsl.sh')
|
||||||
|
& wsl.exe @wslArguments
|
||||||
|
if ($LASTEXITCODE) { throw 'WSL Linux build failed' }
|
||||||
|
|
||||||
|
Write-Host "`nAll platform builds completed for $version. Artifacts are in release\."
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
source_dir="$(pwd -P)"
|
||||||
|
if [[ ! -f "$source_dir/package.json" || ! -f "$source_dir/package-lock.json" ]]; then
|
||||||
|
echo "Run this script from the project root." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
work_dir="$(mktemp -d "${TMPDIR:-/tmp}/ep-mail-linux-build.XXXXXXXX")"
|
||||||
|
trap 'rm -rf -- "$work_dir"' EXIT
|
||||||
|
|
||||||
|
echo "Copying sources to an isolated Linux workspace..."
|
||||||
|
tar -C "$source_dir" --exclude='./.git' --exclude='./node_modules' \
|
||||||
|
--exclude='./release' --exclude='./dist' --exclude='./android' --exclude='./www' \
|
||||||
|
-cf - . | tar -C "$work_dir" -xf -
|
||||||
|
cd "$work_dir"
|
||||||
|
|
||||||
|
echo "Installing Linux dependencies from package-lock.json..."
|
||||||
|
npm ci
|
||||||
|
version="$(node -p "require('./package.json').version")"
|
||||||
|
echo "Building Linux packages for $version..."
|
||||||
|
npm run dist:linux
|
||||||
|
|
||||||
|
shopt -s nullglob
|
||||||
|
appimages=(release/ep-mail-"$version"*.AppImage)
|
||||||
|
debs=(release/ep-mail_"$version"_*.deb)
|
||||||
|
if (( ${#appimages[@]} != 1 || ${#debs[@]} != 1 )); then
|
||||||
|
echo "Expected exactly one AppImage and one deb for version $version." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
mkdir -p "$source_dir/release"
|
||||||
|
cp -- "${appimages[0]}" "${debs[0]}" "$source_dir/release/"
|
||||||
|
printf 'Linux artifacts copied to release/:\n %s\n %s\n' "${appimages[0]##*/}" "${debs[0]##*/}"
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
# Builds the Android debug APK and the Windows portable exe into .\release
|
||||||
|
$ErrorActionPreference = 'Stop'
|
||||||
|
Set-Location $PSScriptRoot\..
|
||||||
|
$version = (Get-Content package.json -Raw | ConvertFrom-Json).version
|
||||||
|
if (-not $env:JAVA_HOME) { $env:JAVA_HOME = 'C:\Program Files\Android\Android Studio\jbr' }
|
||||||
|
if (-not $env:ANDROID_HOME) { $env:ANDROID_HOME = Join-Path $env:LOCALAPPDATA 'Android\Sdk' }
|
||||||
|
New-Item -ItemType Directory -Force release | Out-Null
|
||||||
|
|
||||||
|
Write-Host "== Building APK $version =="
|
||||||
|
npm run android:apk
|
||||||
|
if ($LASTEXITCODE) { throw 'APK build failed' }
|
||||||
|
Write-Warning "The legacy ep-mail $version.apk copy is a debug APK and overwrites any existing file with that name."
|
||||||
|
Copy-Item android\app\build\outputs\apk\debug\app-debug.apk "release\ep-mail $version.apk" -Force
|
||||||
|
|
||||||
|
Write-Host "== Building portable exe $version =="
|
||||||
|
npm run dist:win:portable
|
||||||
|
if ($LASTEXITCODE) { throw 'Portable build failed' }
|
||||||
|
|
||||||
|
Write-Host "`nDone:"
|
||||||
|
Get-ChildItem release | Where-Object { $_.Name -like "ep-mail $version.*" } | ForEach-Object { " $($_.FullName)" }
|
||||||
@@ -10,6 +10,7 @@ const assets = [
|
|||||||
'branding.css',
|
'branding.css',
|
||||||
'platform-bridge-loader.js',
|
'platform-bridge-loader.js',
|
||||||
'renderer-state.js',
|
'renderer-state.js',
|
||||||
|
'conversation-threads.js',
|
||||||
'mail-content-security.js',
|
'mail-content-security.js',
|
||||||
'renderer-mail-api.js',
|
'renderer-mail-api.js',
|
||||||
'app.js',
|
'app.js',
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
const CACHE='ep-mail-v22';
|
const CACHE='ep-mail-v23';
|
||||||
const FILES=['./','./index.html','./styles.css','./branding.css','./renderer-state.js','./mail-content-security.js','./renderer-mail-api.js','./app.js','./platform-bridge-loader.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','./renderer-state.js','./conversation-threads.js','./mail-content-security.js','./renderer-mail-api.js','./app.js','./platform-bridge-loader.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)).then(()=>self.skipWaiting())));
|
self.addEventListener('install',event=>event.waitUntil(caches.open(CACHE).then(cache=>cache.addAll(FILES)).then(()=>self.skipWaiting())));
|
||||||
self.addEventListener('activate',event=>event.waitUntil(caches.keys().then(keys=>Promise.all(keys.filter(k=>k!==CACHE).map(k=>caches.delete(k)))).then(()=>self.clients.claim())));
|
self.addEventListener('activate',event=>event.waitUntil(caches.keys().then(keys=>Promise.all(keys.filter(k=>k!==CACHE).map(k=>caches.delete(k)))).then(()=>self.clients.claim())));
|
||||||
self.addEventListener('fetch', event => {
|
self.addEventListener('fetch', event => {
|
||||||
|
|||||||
+49
-39
@@ -65,43 +65,53 @@ document.addEventListener('keydown', event => {
|
|||||||
action.run();
|
action.run();
|
||||||
});
|
});
|
||||||
|
|
||||||
shortcutProductivityUi.wrapOpenPreferences(baseOpenPreferences => function () {
|
function openShortcutSettings() {
|
||||||
baseOpenPreferences();
|
const root = selectShortcutUi('#modal-root');
|
||||||
const fields = selectShortcutUi('#modal-root .compose-fields');
|
const shortcuts = loadShortcuts();
|
||||||
const save = selectShortcutUi('#save-appearance');
|
root.innerHTML = `<div class="modal-overlay"><div class="compose-modal"><div class="modal-head"><span>Keyboard shortcuts</span><button class="modal-close" aria-label="Close">×</button></div><div class="compose-fields"><p class="account-note">Type a key or combination such as <code>c</code>, <code>Ctrl+Enter</code> or <code>Alt+n</code>. Leave blank to disable. Shortcuts are inactive while typing or in dialogs.</p>${shortcutActions.map(action =>
|
||||||
if (!fields || !save) return;
|
`<label class="compose-line"><span>${action.label}</span><input class="shortcut-input" data-action="${action.id}" maxlength="24" value="${escapeShortcutUi(shortcuts[action.id])}" placeholder="None"></label>`).join('')}<button type="button" class="discard" id="reset-shortcuts">Reset to defaults</button></div><div class="compose-footer"><button class="discard modal-close">Cancel</button><button class="send-button" id="save-shortcuts">Save shortcuts</button></div></div></div>`;
|
||||||
const shortcuts = loadShortcuts();
|
const close = () => { root.innerHTML = ''; };
|
||||||
const section = document.createElement('div');
|
root.querySelectorAll('.modal-close').forEach(button => { button.onclick = close; });
|
||||||
section.className = 'shortcut-settings';
|
selectShortcutUi('.modal-overlay').onclick = event => { if (event.target.classList.contains('modal-overlay')) close(); };
|
||||||
section.innerHTML = `<h3>Keyboard shortcuts</h3><p class="account-note">Type a key or combination such as <code>c</code>, <code>Ctrl+Enter</code> or <code>Alt+n</code>. Leave blank to disable. Shortcuts are inactive while typing or in dialogs.</p>${shortcutActions.map(action =>
|
const fields = selectShortcutUi('#modal-root .compose-fields');
|
||||||
`<label class="compose-line"><span>${action.label}</span><input class="shortcut-input" data-action="${action.id}" maxlength="24" value="${escapeShortcutUi(shortcuts[action.id])}" placeholder="None"></label>`).join('')}<button type="button" class="discard" id="reset-shortcuts">Reset to defaults</button>`;
|
fields.addEventListener('keydown', event => {
|
||||||
fields.append(section);
|
const input = event.target.closest('.shortcut-input');
|
||||||
section.addEventListener('keydown', event => {
|
if (!input || ['Tab', 'Escape'].includes(event.key)) return;
|
||||||
const input = event.target.closest('.shortcut-input');
|
event.preventDefault();
|
||||||
if (!input || ['Tab', 'Escape'].includes(event.key)) return;
|
if (['Backspace', 'Delete'].includes(event.key)) { input.value = ''; return; }
|
||||||
event.preventDefault();
|
const combo = eventShortcut(event);
|
||||||
if (['Backspace', 'Delete'].includes(event.key)) { input.value = ''; return; }
|
if (combo) input.value = combo;
|
||||||
const combo = eventShortcut(event);
|
|
||||||
if (combo) input.value = combo;
|
|
||||||
});
|
|
||||||
selectShortcutUi('#reset-shortcuts').onclick = () => {
|
|
||||||
section.querySelectorAll('.shortcut-input').forEach(input => {
|
|
||||||
input.value = shortcutActions.find(action => action.id === input.dataset.action).fallback;
|
|
||||||
});
|
|
||||||
};
|
|
||||||
const baseSave = save.onclick;
|
|
||||||
save.onclick = event => {
|
|
||||||
const values = {};
|
|
||||||
const used = new Map();
|
|
||||||
for (const input of section.querySelectorAll('.shortcut-input')) {
|
|
||||||
const value = normalizeShortcut(input.value);
|
|
||||||
const label = shortcutActions.find(action => action.id === input.dataset.action).label;
|
|
||||||
if (value && used.has(value)) { toastShortcutUi(`“${value}” is used by both ${used.get(value)} and ${label}`); return; }
|
|
||||||
if (value) used.set(value, label);
|
|
||||||
values[input.dataset.action] = value;
|
|
||||||
}
|
|
||||||
localStorage.setItem(shortcutStorageKey, JSON.stringify(values));
|
|
||||||
baseSave?.call(save, event);
|
|
||||||
};
|
|
||||||
});
|
});
|
||||||
})();
|
selectShortcutUi('#reset-shortcuts').onclick = () => {
|
||||||
|
fields.querySelectorAll('.shortcut-input').forEach(input => {
|
||||||
|
input.value = shortcutActions.find(action => action.id === input.dataset.action).fallback;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
selectShortcutUi('#save-shortcuts').onclick = () => {
|
||||||
|
const values = {};
|
||||||
|
const used = new Map();
|
||||||
|
for (const input of fields.querySelectorAll('.shortcut-input')) {
|
||||||
|
const value = normalizeShortcut(input.value);
|
||||||
|
const label = shortcutActions.find(action => action.id === input.dataset.action).label;
|
||||||
|
if (value && used.has(value)) { toastShortcutUi(`“${value}” is used by both ${used.get(value)} and ${label}`); return; }
|
||||||
|
if (value) used.set(value, label);
|
||||||
|
values[input.dataset.action] = value;
|
||||||
|
}
|
||||||
|
localStorage.setItem(shortcutStorageKey, JSON.stringify(values));
|
||||||
|
close();
|
||||||
|
toastShortcutUi('Keyboard shortcuts saved');
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
shortcutProductivityUi.wrapOpenPreferences(baseOpenPreferences => async function () {
|
||||||
|
await baseOpenPreferences();
|
||||||
|
const fields = selectShortcutUi('#modal-root .compose-fields');
|
||||||
|
if (!fields || !selectShortcutUi('#save-appearance')) return;
|
||||||
|
const button = document.createElement('button');
|
||||||
|
button.type = 'button';
|
||||||
|
button.className = 'discard';
|
||||||
|
button.id = 'open-keyboard-shortcuts';
|
||||||
|
button.textContent = 'Keyboard shortcuts…';
|
||||||
|
button.onclick = openShortcutSettings;
|
||||||
|
fields.append(button);
|
||||||
|
});})();
|
||||||
|
|||||||
+10
-4
@@ -114,7 +114,7 @@ body.ep-daylight .compose-line input::placeholder,body.ep-daylight .compose-body
|
|||||||
body.ep-daylight .modal-close,body.ep-daylight .discard{color:#59706b}
|
body.ep-daylight .modal-close,body.ep-daylight .discard{color:#59706b}
|
||||||
body.ep-daylight .toast{background:#11212b;color:#f1f1e9}
|
body.ep-daylight .toast{background:#11212b;color:#f1f1e9}
|
||||||
body.ep-daylight .row-check:checked{accent-color:#526a2c}
|
body.ep-daylight .row-check:checked{accent-color:#526a2c}
|
||||||
.compose-modal{max-height:90vh;display:flex;flex-direction:column}.compose-fields{min-height:0;flex:1 1 auto;overflow-y:auto}
|
.compose-modal{max-height:90vh;display:flex;flex-direction:column}.compose-modal>.modal-head,.compose-modal>.compose-footer{flex:none}.compose-fields{min-height:0;flex:0 1 auto;overflow-y:auto}.compose-modal>.compose-body{flex:1 1 120px;min-height:90px;height:auto}
|
||||||
.snooze-options .outline-button{width:100%;text-align:left}
|
.snooze-options .outline-button{width:100%;text-align:left}
|
||||||
.mail-rules{padding:10px 0;border-bottom:1px solid var(--line)}.mail-rule-row{display:grid;grid-template-columns:1fr 1fr 120px 1fr auto;gap:6px;align-items:center;padding:5px 0}.mail-rule-row input,.mail-rule-row select{box-sizing:border-box;min-width:0;width:100%;padding:7px;border:1px solid var(--line);border-radius:5px;background:var(--panel);color:var(--text);font-size:10px}.mail-rule-row input:disabled{opacity:.55}.mail-rule-row .discard{white-space:nowrap}
|
.mail-rules{padding:10px 0;border-bottom:1px solid var(--line)}.mail-rule-row{display:grid;grid-template-columns:1fr 1fr 120px 1fr auto;gap:6px;align-items:center;padding:5px 0}.mail-rule-row input,.mail-rule-row select{box-sizing:border-box;min-width:0;width:100%;padding:7px;border:1px solid var(--line);border-radius:5px;background:var(--panel);color:var(--text);font-size:10px}.mail-rule-row input:disabled{opacity:.55}.mail-rule-row .discard{white-space:nowrap}
|
||||||
@media(max-width:650px){.mail-rule-row{grid-template-columns:1fr 1fr}.mail-rule-row .mail-rule-action,.mail-rule-row .mail-rule-value{grid-column:auto}}
|
@media(max-width:650px){.mail-rule-row{grid-template-columns:1fr 1fr}.mail-rule-row .mail-rule-action,.mail-rule-row .mail-rule-value{grid-column:auto}}
|
||||||
@@ -126,9 +126,10 @@ body.ep-daylight .row-check:checked{accent-color:#526a2c}
|
|||||||
body.ep-daylight .mail-safety-warning{background:#fff6df;color:#5b3c17}body.ep-daylight .mail-link-risky{background:#fff8ea;border-color:#d69b43}
|
body.ep-daylight .mail-safety-warning{background:#fff6df;color:#5b3c17}body.ep-daylight .mail-link-risky{background:#fff8ea;border-color:#d69b43}
|
||||||
|
|
||||||
.folder-add{border:0;background:transparent;color:#929990;font-size:18px;cursor:pointer}.folder-add:hover{color:#487354}.section-label+.folder-nav:empty{display:none}.custom-folder span:last-child{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
.folder-add{border:0;background:transparent;color:#929990;font-size:18px;cursor:pointer}.folder-add:hover{color:#487354}.section-label+.folder-nav:empty{display:none}.custom-folder span:last-child{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
||||||
.shortcut-settings h3{margin:16px 0 4px;font-size:13px}.shortcut-settings code{font-family:monospace}.shortcut-input{text-transform:none}.shortcut-settings #reset-shortcuts{margin-top:8px}
|
.compose-fields code{font-family:monospace}.shortcut-input{text-transform:none}#reset-shortcuts{margin-top:8px}
|
||||||
.attachments-modal{width:min(720px,94vw)}.attachment-toolbar{display:flex;gap:8px;margin-bottom:10px}.attachment-toolbar input{flex:1}.attachment-list{max-height:60vh;overflow:auto;display:grid;gap:8px}.attachment-row{display:flex;flex-wrap:wrap;gap:8px;align-items:center;padding:8px;border:1px solid var(--line);border-radius:8px}.attachment-row-info{flex:1;min-width:0;display:flex;flex-direction:column;gap:2px}.attachment-row-info strong,.attachment-row-info small{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.attachment-preview{flex-basis:100%;max-height:320px;overflow:auto;padding:8px;font-size:12px}.attachment-preview-image{max-width:100%;max-height:300px;display:block}.attachment-preview-text{margin:0;white-space:pre-wrap;word-break:break-word}.preview-attachment{font-size:14px}
|
.attachments-modal{width:min(720px,94vw)}.attachment-toolbar{display:flex;gap:8px;margin-bottom:10px}.attachment-toolbar input{flex:1}.attachment-list{max-height:60vh;overflow:auto;display:grid;gap:8px}.attachment-row{display:flex;flex-wrap:wrap;gap:8px;align-items:center;padding:8px;border:1px solid var(--line);border-radius:8px}.attachment-row-info{flex:1;min-width:0;display:flex;flex-direction:column;gap:2px}.attachment-row-info strong,.attachment-row-info small{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.attachment-preview{flex-basis:100%;max-height:320px;overflow:auto;padding:8px;font-size:12px}.attachment-preview-image{max-width:100%;max-height:300px;display:block}.attachment-preview-text{margin:0;white-space:pre-wrap;word-break:break-word}.preview-attachment{font-size:14px}
|
||||||
.pgp-heading{margin:16px 0 4px;font-size:13px}.pgp-actions{display:flex;gap:8px;margin-top:8px}#open-encryption-keys{margin-top:12px}
|
.pgp-heading{margin:16px 0 4px;font-size:13px}.pgp-actions{display:flex;gap:8px;margin-top:8px}#open-encryption-keys{margin-top:12px}
|
||||||
|
.pgp-keys-modal .attachment-list{grid-template-columns:minmax(0,1fr)}.pgp-keys-modal .attachment-row{min-width:0}.pgp-keys-modal .attachment-row-info{flex:1 0 100%}.pgp-keys-modal .attachment-row-info strong,.pgp-keys-modal .attachment-row-info small{overflow:visible;text-overflow:clip;white-space:normal;overflow-wrap:anywhere}.pgp-keys-modal .attachment-row>button{max-width:100%;padding:8px;font-size:12px}.pgp-keys-modal .attachment-row>.compose-line{flex:1 1 180px;min-width:0}.pgp-keys-modal .pgp-trust{margin-left:0;max-width:100%}.pgp-keys-modal .pgp-actions{flex-wrap:wrap}
|
||||||
|
|
||||||
.pgp-prompt{z-index:2000}.pgp-prompt-box{max-width:420px}
|
.pgp-prompt{z-index:2000}.pgp-prompt-box{max-width:420px}
|
||||||
.pgp-status,.pgp-banner{display:flex;flex-direction:column;gap:2px;margin:10px 0;padding:10px 12px;border-radius:8px;border:1px solid var(--line,#c9d1c8);font-size:13px}
|
.pgp-status,.pgp-banner{display:flex;flex-direction:column;gap:2px;margin:10px 0;padding:10px 12px;border-radius:8px;border:1px solid var(--line,#c9d1c8);font-size:13px}
|
||||||
@@ -199,8 +200,10 @@ body.ep-daylight .row-check:checked{accent-color:#526a2c}
|
|||||||
.compose-line input[type=checkbox]{flex:0 0 auto;width:20px;height:20px}
|
.compose-line input[type=checkbox]{flex:0 0 auto;width:20px;height:20px}
|
||||||
.compose-line span{flex:0 1 54%;line-height:1.25}
|
.compose-line span{flex:0 1 54%;line-height:1.25}
|
||||||
.compose-line input:not([type=checkbox]){flex:1;max-width:100%;min-width:0}
|
.compose-line input:not([type=checkbox]){flex:1;max-width:100%;min-width:0}
|
||||||
.compose-footer{gap:8px;padding:10px 12px}
|
.compose-footer{gap:8px;padding:10px 12px;flex-wrap:wrap;justify-content:flex-end}
|
||||||
.compose-body{height:30vh;padding:12px}
|
.compose-footer .pgp-compose{flex:1 0 100%;flex-wrap:wrap;margin-right:0;gap:4px 12px}
|
||||||
|
.compose-footer .send-button{order:99;padding:10px 18px;font-size:12px}
|
||||||
|
.compose-body{padding:12px}
|
||||||
.account-note,.account-status{font-size:12px}
|
.account-note,.account-status{font-size:12px}
|
||||||
.mail-rule-row{grid-template-columns:1fr;gap:6px}
|
.mail-rule-row{grid-template-columns:1fr;gap:6px}
|
||||||
.mail-rule-row>*{grid-column:1}
|
.mail-rule-row>*{grid-column:1}
|
||||||
@@ -232,3 +235,6 @@ body.ep-daylight .row-check:checked{accent-color:#526a2c}
|
|||||||
.reader-pane{padding-bottom:10px}
|
.reader-pane{padding-bottom:10px}
|
||||||
}
|
}
|
||||||
@media(max-width:1000px),(max-height:500px) and (orientation:landscape) and (max-width:1200px){.sidebar{overflow:hidden}#mail-nav{display:flex;flex-direction:row;align-items:center;height:42px;min-height:0;max-height:42px;flex:none;overflow-x:auto;overflow-y:hidden;align-content:normal}#mail-nav .folder{height:34px;align-self:center}}
|
@media(max-width:1000px),(max-height:500px) and (orientation:landscape) and (max-width:1200px){.sidebar{overflow:hidden}#mail-nav{display:flex;flex-direction:row;align-items:center;height:42px;min-height:0;max-height:42px;flex:none;overflow-x:auto;overflow-y:hidden;align-content:normal}#mail-nav .folder{height:34px;align-self:center}}
|
||||||
|
.conversation-toggle{display:block;width:100%;padding:8px 12px;border:0;border-bottom:1px solid var(--border,#ddd);background:transparent;color:inherit;text-align:left;font:inherit;font-size:.8rem;font-weight:600;cursor:pointer}
|
||||||
|
.conversation-toggle:focus-visible{outline:2px solid currentColor;outline-offset:-2px}
|
||||||
|
.conversation-replies .message{padding-left:22px}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
const test = require('node:test');
|
const test = require('node:test');
|
||||||
const assert = require('node:assert/strict');
|
const assert = require('node:assert/strict');
|
||||||
const path = require('node:path');
|
const path = require('node:path');
|
||||||
|
const fs = require('node:fs');
|
||||||
const vm = require('node:vm');
|
const vm = require('node:vm');
|
||||||
const esbuild = require('esbuild');
|
const esbuild = require('esbuild');
|
||||||
const { webcrypto } = require('node:crypto');
|
const { webcrypto } = require('node:crypto');
|
||||||
@@ -20,6 +21,12 @@ const bundled = esbuild.buildSync({
|
|||||||
vm.runInThisContext(bundled);
|
vm.runInThisContext(bundled);
|
||||||
const { createAndroidPgp } = global.AndroidPgpBundle;
|
const { createAndroidPgp } = global.AndroidPgpBundle;
|
||||||
|
|
||||||
|
function saveMimeFixture(name, rawBase64) {
|
||||||
|
if (process.env.EP_MAIL_PGP_MIME_FIXTURE_DIR) {
|
||||||
|
fs.writeFileSync(path.join(process.env.EP_MAIL_PGP_MIME_FIXTURE_DIR, `${name}.eml`), Buffer.from(rawBase64, 'base64'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function makeEndpoint(account, { confirm = () => true } = {}) {
|
function makeEndpoint(account, { confirm = () => true } = {}) {
|
||||||
const vault = { keys: [], contacts: [], settings: {} };
|
const vault = { keys: [], contacts: [], settings: {} };
|
||||||
let messageSource = null;
|
let messageSource = null;
|
||||||
@@ -36,6 +43,39 @@ function makeEndpoint(account, { confirm = () => true } = {}) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test('Android imports an armored private key selected from a file', async () => {
|
||||||
|
const source = makeEndpoint({ email: 'alice@example.test' });
|
||||||
|
const target = makeEndpoint({ email: 'alice@example.test' });
|
||||||
|
const passphrase = 'alice test passphrase';
|
||||||
|
const generated = await source.api.generate({ name: 'Alice', email: 'alice@example.test', passphrase });
|
||||||
|
const armoredKey = await source.api.exportPrivate(generated.key.fingerprint, passphrase);
|
||||||
|
target.EpMail.pickPgpPrivateKey = async () => ({ armoredKey });
|
||||||
|
|
||||||
|
await assert.rejects(target.api.importKey({ source: 'file', passphrase: 'incorrect passphrase' }), /passphrase is incorrect/);
|
||||||
|
assert.equal(target.vault.keys.length, 0);
|
||||||
|
const result = await target.api.importKey({ source: 'file', passphrase, accountId: 'account-1' });
|
||||||
|
assert.equal(result.key.fingerprint, generated.key.fingerprint);
|
||||||
|
assert.equal(target.vault.keys[0].accountId, 'account-1');
|
||||||
|
assert.equal((await openpgp.readPrivateKey({ armoredKey: target.vault.keys[0].privateKey })).isDecrypted(), false);
|
||||||
|
await assert.rejects(target.api.importKey({ source: 'file', passphrase }), /already in your keyring/);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Android file import handles cancellation, picker errors and invalid content', async () => {
|
||||||
|
const target = makeEndpoint({ email: 'alice@example.test' });
|
||||||
|
const options = { source: 'file', passphrase: 'test passphrase' };
|
||||||
|
target.EpMail.pickPgpPrivateKey = async () => ({ canceled: true });
|
||||||
|
assert.deepEqual(await target.api.importKey(options), { canceled: true });
|
||||||
|
target.EpMail.pickPgpPrivateKey = async () => { throw new Error('Picker failed'); };
|
||||||
|
await assert.rejects(target.api.importKey(options), /Picker failed/);
|
||||||
|
target.EpMail.pickPgpPrivateKey = async () => ({ armoredKey: '' });
|
||||||
|
await assert.rejects(target.api.importKey(options), /empty/);
|
||||||
|
target.EpMail.pickPgpPrivateKey = async () => ({ armoredKey: 'not a private key' });
|
||||||
|
await assert.rejects(target.api.importKey(options), /not a valid OpenPGP private key/);
|
||||||
|
target.EpMail.pickPgpPrivateKey = async () => ({ armoredKey: 'x'.repeat(200001) });
|
||||||
|
await assert.rejects(target.api.importKey(options), /too large/);
|
||||||
|
assert.equal(target.vault.keys.length, 0);
|
||||||
|
});
|
||||||
|
|
||||||
test('Android OpenPGP encrypts MIME attachments and decrypts with a recipient key', async () => {
|
test('Android OpenPGP encrypts MIME attachments and decrypts with a recipient key', async () => {
|
||||||
const sender = makeEndpoint({ email: 'alice@example.test', displayName: 'Alice', signature: '' });
|
const sender = makeEndpoint({ email: 'alice@example.test', displayName: 'Alice', signature: '' });
|
||||||
const recipient = makeEndpoint({ email: 'bob@example.test', displayName: 'Bob', signature: '' });
|
const recipient = makeEndpoint({ email: 'bob@example.test', displayName: 'Bob', signature: '' });
|
||||||
@@ -48,14 +88,19 @@ test('Android OpenPGP encrypts MIME attachments and decrypts with a recipient ke
|
|||||||
|
|
||||||
const built = await sender.api.buildOutgoing({
|
const built = await sender.api.buildOutgoing({
|
||||||
to: 'Bob <bob@example.test>', cc: '', subject: 'Secret note', text: 'hello from Android',
|
to: 'Bob <bob@example.test>', cc: '', subject: 'Secret note', text: 'hello from Android',
|
||||||
messageId: '<test-message@example.test>', pgp: { encrypt: true, sign: true, passphrase: 'alice test passphrase' },
|
messageId: '<test-message@example.test>', inReplyTo: '<parent@example.test>',
|
||||||
|
references: '<root@example.test> <parent@example.test>',
|
||||||
|
pgp: { encrypt: true, sign: true, passphrase: 'alice test passphrase' },
|
||||||
attachments: [
|
attachments: [
|
||||||
{ filename: 'note.txt', contentType: 'text/plain', contentBase64: Buffer.from('private attachment').toString('base64') },
|
{ filename: 'note.txt', contentType: 'text/plain', contentBase64: Buffer.from('private attachment').toString('base64') },
|
||||||
{ filename: 'charlie.asc', contentType: 'application/pgp-keys', contentBase64: Buffer.from(await thirdParty.api.exportPublic(charlie.key.fingerprint)).toString('base64') }
|
{ filename: 'charlie.asc', contentType: 'application/pgp-keys', contentBase64: Buffer.from(await thirdParty.api.exportPublic(charlie.key.fingerprint)).toString('base64') }
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
assert.ok(built.rawBase64);
|
assert.ok(built.rawBase64);
|
||||||
|
saveMimeFixture('encrypted-signed', built.rawBase64);
|
||||||
const raw = Buffer.from(built.rawBase64, 'base64').toString('utf8');
|
const raw = Buffer.from(built.rawBase64, 'base64').toString('utf8');
|
||||||
|
assert.match(raw, /\r\nIn-Reply-To: <parent@example\.test>\r\n/);
|
||||||
|
assert.match(raw, /\r\nReferences: <root@example\.test> <parent@example\.test>\r\n/);
|
||||||
assert.match(raw, /multipart\/encrypted; protocol="application\/pgp-encrypted"/i);
|
assert.match(raw, /multipart\/encrypted; protocol="application\/pgp-encrypted"/i);
|
||||||
assert.doesNotMatch(raw, /hello from Android|private attachment/);
|
assert.doesNotMatch(raw, /hello from Android|private attachment/);
|
||||||
recipient.setMessage({ rawBase64: built.rawBase64 });
|
recipient.setMessage({ rawBase64: built.rawBase64 });
|
||||||
@@ -114,6 +159,7 @@ test('Android verifies PGP/MIME signed-only and clear-signed mail', async () =>
|
|||||||
to: 'Bob <bob@example.test>', cc: '', subject: 'Signed note', text: 'signed MIME body',
|
to: 'Bob <bob@example.test>', cc: '', subject: 'Signed note', text: 'signed MIME body',
|
||||||
pgp: { encrypt: false, sign: true, passphrase: 'alice test passphrase' }, attachments: []
|
pgp: { encrypt: false, sign: true, passphrase: 'alice test passphrase' }, attachments: []
|
||||||
});
|
});
|
||||||
|
saveMimeFixture('signed', signedMime.rawBase64);
|
||||||
recipient.setMessage({ rawBase64: signedMime.rawBase64 });
|
recipient.setMessage({ rawBase64: signedMime.rawBase64 });
|
||||||
const mimeResult = await recipient.api.verifyMessage({ folder: 'Inbox', uid: 8 });
|
const mimeResult = await recipient.api.verifyMessage({ folder: 'Inbox', uid: 8 });
|
||||||
assert.equal(mimeResult.signatures[0].status, 'valid');
|
assert.equal(mimeResult.signatures[0].status, 'valid');
|
||||||
@@ -169,6 +215,7 @@ test('Android rejects tampered, malformed, and oversized encrypted input', async
|
|||||||
to: 'bob@example.test', subject: 'Encrypted test', text: 'tamper test',
|
to: 'bob@example.test', subject: 'Encrypted test', text: 'tamper test',
|
||||||
pgp: { encrypt: true }, attachments: []
|
pgp: { encrypt: true }, attachments: []
|
||||||
});
|
});
|
||||||
|
saveMimeFixture('encrypted', built.rawBase64);
|
||||||
const raw = Buffer.from(built.rawBase64, 'base64').toString('utf8');
|
const raw = Buffer.from(built.rawBase64, 'base64').toString('utf8');
|
||||||
const armor = /-----BEGIN PGP MESSAGE-----[\s\S]+?-----END PGP MESSAGE-----/.exec(raw)?.[0];
|
const armor = /-----BEGIN PGP MESSAGE-----[\s\S]+?-----END PGP MESSAGE-----/.exec(raw)?.[0];
|
||||||
assert.ok(armor);
|
assert.ok(armor);
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ const androidPgpConfirmationGate = fs.readFileSync(path.join(root, 'android', 'a
|
|||||||
const productivity = fs.readFileSync(path.join(root, 'productivity.js'), 'utf8');
|
const productivity = fs.readFileSync(path.join(root, 'productivity.js'), 'utf8');
|
||||||
const androidBridge = fs.readFileSync(path.join(root, 'scripts', 'android-bridge.js'), 'utf8');
|
const androidBridge = fs.readFileSync(path.join(root, 'scripts', 'android-bridge.js'), 'utf8');
|
||||||
const androidPgp = fs.readFileSync(path.join(root, 'scripts', 'android-pgp.js'), 'utf8');
|
const androidPgp = fs.readFileSync(path.join(root, 'scripts', 'android-pgp.js'), 'utf8');
|
||||||
|
const pgpUi = fs.readFileSync(path.join(root, 'pgp-ui.js'), 'utf8');
|
||||||
const pgpMailUi = fs.readFileSync(path.join(root, 'pgp-mail-ui.js'), 'utf8');
|
const pgpMailUi = fs.readFileSync(path.join(root, 'pgp-mail-ui.js'), 'utf8');
|
||||||
const packageJson = JSON.parse(fs.readFileSync(path.join(root, 'package.json'), 'utf8'));
|
const packageJson = JSON.parse(fs.readFileSync(path.join(root, 'package.json'), 'utf8'));
|
||||||
const packageLock = JSON.parse(fs.readFileSync(path.join(root, 'package-lock.json'), 'utf8'));
|
const packageLock = JSON.parse(fs.readFileSync(path.join(root, 'package-lock.json'), 'utf8'));
|
||||||
@@ -39,6 +40,14 @@ test('mobile layout removes desktop minimum width and provides a compact reader
|
|||||||
assert.match(app, /if\(!m\)\{state\.activeMessage=null;document\.body\.classList\.remove\('reader-open'\);return;\}/);
|
assert.match(app, /if\(!m\)\{state\.activeMessage=null;document\.body\.classList\.remove\('reader-open'\);return;\}/);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('key settings cards keep key details readable and actions wrapped', () => {
|
||||||
|
assert.match(pgpUi, /compose-modal attachments-modal pgp-keys-modal/);
|
||||||
|
assert.match(styles, /\.pgp-keys-modal \.attachment-list\{grid-template-columns:minmax\(0,1fr\)\}/);
|
||||||
|
assert.match(styles, /\.pgp-keys-modal \.attachment-row-info\{flex:1 0 100%\}/);
|
||||||
|
assert.match(styles, /\.pgp-keys-modal \.attachment-row-info small\{[^}]*white-space:normal;overflow-wrap:anywhere/);
|
||||||
|
assert.match(styles, /\.pgp-keys-modal \.pgp-actions\{flex-wrap:wrap\}/);
|
||||||
|
});
|
||||||
|
|
||||||
test('mailbox setup exposes ports and TLS modes and submits them to Android', () => {
|
test('mailbox setup exposes ports and TLS modes and submits them to Android', () => {
|
||||||
for (const id of ['mail-account-imap-port', 'mail-account-imap-secure', 'mail-account-smtp-port', 'mail-account-smtp-secure']) {
|
for (const id of ['mail-account-imap-port', 'mail-account-imap-secure', 'mail-account-smtp-port', 'mail-account-smtp-secure']) {
|
||||||
assert.ok(mailUi.includes(`id="${id}"`), `missing account field ${id}`);
|
assert.ok(mailUi.includes(`id="${id}"`), `missing account field ${id}`);
|
||||||
@@ -91,6 +100,15 @@ test('Android app lock is native-enforced and requires a secure device credentia
|
|||||||
assert.match(mainActivity, /FLAG_SECURE/);
|
assert.match(mainActivity, /FLAG_SECURE/);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('Android private-key picker preserves WebView restrictions and checks app lock', () => {
|
||||||
|
assert.match(plugin, /fun pickPgpPrivateKey\(call: PluginCall\)/);
|
||||||
|
assert.match(plugin, /AndroidAccountVault\.appLockEnabled\(\)/);
|
||||||
|
assert.match(plugin, /Intent\.ACTION_OPEN_DOCUMENT/);
|
||||||
|
assert.match(plugin, /uri\.scheme != "content"/);
|
||||||
|
assert.match(plugin, /BoundedInputReader\.read\(it, 200001\)/);
|
||||||
|
assert.match(plugin, /bytes\.isEmpty\(\) \|\| bytes\.size > 200000/);
|
||||||
|
});
|
||||||
|
|
||||||
test('Android biometric PGP unlock keeps secrets behind an authentication-bound Keystore key', () => {
|
test('Android biometric PGP unlock keeps secrets behind an authentication-bound Keystore key', () => {
|
||||||
assert.match(plugin, /fun setPgpBiometricUnlock/);
|
assert.match(plugin, /fun setPgpBiometricUnlock/);
|
||||||
assert.match(plugin, /fun getPgpBiometricPassphrase/);
|
assert.match(plugin, /fun getPgpBiometricPassphrase/);
|
||||||
@@ -170,9 +188,10 @@ test('Android OpenPGP uses the encrypted vault and queues only built MIME data',
|
|||||||
assert.match(androidPgp, /readSignature/);
|
assert.match(androidPgp, /readSignature/);
|
||||||
assert.match(pgpMailUi, /message\.signed/);
|
assert.match(pgpMailUi, /message\.signed/);
|
||||||
assert.match(androidBridge, /buildOutgoing\(message\)/);
|
assert.match(androidBridge, /buildOutgoing\(message\)/);
|
||||||
|
assert.match(plugin, /PgpMessageUid\.requireValid\(call\.data\.opt\("uid"\)\)/);
|
||||||
assert.match(androidBridge, /rawBase64, envelope: \{ from, to \}, text: '', attachments: \[\]/);
|
assert.match(androidBridge, /rawBase64, envelope: \{ from, to \}, text: '', attachments: \[\]/);
|
||||||
assert.match(androidMailService, /validateOpenPgpMime\(message\)/);
|
assert.match(androidMailService, /validateOpenPgpMime\(message\)/);
|
||||||
assert.match(androidMailService, /private fun validateOpenPgpMime/);
|
assert.match(androidMailService, /internal fun validateOpenPgpMime/);
|
||||||
assert.match(androidMailService, /"send" -> send\(account, data\)/);
|
assert.match(androidMailService, /"send" -> send\(account, data\)/);
|
||||||
assert.match(androidMailService, /private fun isEncryptedMessage/);
|
assert.match(androidMailService, /private fun isEncryptedMessage/);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ const packageJson = JSON.parse(fs.readFileSync(path.join(root, 'package.json'),
|
|||||||
const packageLock = JSON.parse(fs.readFileSync(path.join(root, 'package-lock.json'), 'utf8'));
|
const packageLock = JSON.parse(fs.readFileSync(path.join(root, 'package-lock.json'), 'utf8'));
|
||||||
const androidBuild = fs.readFileSync(path.join(root, 'android', 'app', 'build.gradle'), 'utf8');
|
const androidBuild = fs.readFileSync(path.join(root, 'android', 'app', 'build.gradle'), 'utf8');
|
||||||
const buildAll = fs.readFileSync(path.join(root, 'scripts', 'build-all.ps1'), 'utf8');
|
const buildAll = fs.readFileSync(path.join(root, 'scripts', 'build-all.ps1'), 'utf8');
|
||||||
|
const build = fs.readFileSync(path.join(root, 'scripts', 'build.ps1'), 'utf8');
|
||||||
|
const linuxBuild = fs.readFileSync(path.join(root, 'scripts', 'build-linux-wsl.sh'), 'utf8');
|
||||||
const androidDebugScript = fs.readFileSync(path.join(root, 'scripts', 'build-android-apk.cjs'), 'utf8');
|
const androidDebugScript = fs.readFileSync(path.join(root, 'scripts', 'build-android-apk.cjs'), 'utf8');
|
||||||
const androidReleaseScript = fs.readFileSync(path.join(root, 'scripts', 'build-android-release-apk.cjs'), 'utf8');
|
const androidReleaseScript = fs.readFileSync(path.join(root, 'scripts', 'build-android-release-apk.cjs'), 'utf8');
|
||||||
const desktopWorkflow = fs.readFileSync(path.join(root, '.github', 'workflows', 'desktop-build.yml'), 'utf8');
|
const desktopWorkflow = fs.readFileSync(path.join(root, '.github', 'workflows', 'desktop-build.yml'), 'utf8');
|
||||||
@@ -34,10 +36,27 @@ test('Android version name and code derive from the canonical package version',
|
|||||||
|
|
||||||
test('release scripts and desktop artifact labels use package.json version', () => {
|
test('release scripts and desktop artifact labels use package.json version', () => {
|
||||||
assert.match(buildAll, /package\.json/);
|
assert.match(buildAll, /package\.json/);
|
||||||
|
assert.match(build, /package\.json/);
|
||||||
assert.match(desktopWorkflow, /require\('\.\/package\.json'\)\.version/);
|
assert.match(desktopWorkflow, /require\('\.\/package\.json'\)\.version/);
|
||||||
assert.match(desktopWorkflow, /-v\$\{\{ steps\.app-version\.outputs\.version \}\}/);
|
assert.match(desktopWorkflow, /-v\$\{\{ steps\.app-version\.outputs\.version \}\}/);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('build scripts retain the basic targets and add the Windows installer and isolated WSL builds', () => {
|
||||||
|
assert.match(build, /npm run android:apk/);
|
||||||
|
assert.match(build, /npm run dist:win:portable/);
|
||||||
|
assert.match(buildAll, /build\.ps1/);
|
||||||
|
assert.match(buildAll, /npm run dist:win:installer/);
|
||||||
|
assert.match(buildAll, /--distribution/);
|
||||||
|
assert.match(buildAll, /build-linux-wsl\.sh/);
|
||||||
|
assert.match(linuxBuild, /mktemp -d/);
|
||||||
|
assert.match(linuxBuild, /--exclude='\.\/node_modules'/);
|
||||||
|
assert.match(linuxBuild, /npm ci/);
|
||||||
|
assert.match(linuxBuild, /npm run dist:linux/);
|
||||||
|
assert.match(linuxBuild, /appimages=/);
|
||||||
|
assert.match(linuxBuild, /debs=/);
|
||||||
|
assert.doesNotMatch(linuxBuild, /\r/);
|
||||||
|
});
|
||||||
|
|
||||||
test('Android debug APK is labeled as debug and release APK requires signing credentials', () => {
|
test('Android debug APK is labeled as debug and release APK requires signing credentials', () => {
|
||||||
assert.match(androidDebugScript, /assembleDebug/);
|
assert.match(androidDebugScript, /assembleDebug/);
|
||||||
assert.match(androidDebugScript, /ep-mail \$\{version\}-debug\.apk/);
|
assert.match(androidDebugScript, /ep-mail \$\{version\}-debug\.apk/);
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
const test = require('node:test');
|
||||||
|
const assert = require('node:assert/strict');
|
||||||
|
const { groupMessages, messageIds, replyHeaders } = require('../conversation-threads.js');
|
||||||
|
|
||||||
|
test('groups linked messages transitively in the original order, including absent ancestors', () => {
|
||||||
|
const messages = [
|
||||||
|
{ id: 1, messageId: '<one@example>', references: '<root@example>' },
|
||||||
|
{ id: 2, messageId: '<other@example>', subject: 'Same subject' },
|
||||||
|
{ id: 3, messageId: '<three@example>', inReplyTo: '<one@example>' },
|
||||||
|
{ id: 4, messageId: '<four@example>', references: ['<root@example>', '<missing@example>'] }
|
||||||
|
];
|
||||||
|
assert.deepEqual(groupMessages(messages).map(group => group.map(message => message.id)), [[1, 3, 4], [2]]);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('messages without reference headers do not group by subject or invalid IDs', () => {
|
||||||
|
const messages = [
|
||||||
|
{ id: 1, subject: 'Hello', messageId: 'not-an-id' },
|
||||||
|
{ id: 2, subject: 'Re: Hello', inReplyTo: 'not-an-id' }
|
||||||
|
];
|
||||||
|
assert.deepEqual(groupMessages(messages).map(group => group.length), [1, 1]);
|
||||||
|
assert.deepEqual(messageIds('<a@example>\r\nBcc: <b@example>'), ['<a@example>', '<b@example>']);
|
||||||
|
assert.deepEqual(messageIds(`<${'a'.repeat(255)}@example>`), []);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('reply headers retain the parent and bounded ancestry', () => {
|
||||||
|
assert.deepEqual(replyHeaders({ messageId: '<parent@example>', references: ['<root@example>', '<parent@example>'] }), {
|
||||||
|
inReplyTo: '<parent@example>', references: '<root@example> <parent@example>'
|
||||||
|
});
|
||||||
|
assert.deepEqual(replyHeaders({ references: '<root@example>' }), { inReplyTo: '', references: '' });
|
||||||
|
const result = replyHeaders({
|
||||||
|
messageId: '<parent@example>',
|
||||||
|
references: Array.from({ length: 100 }, (_, i) => `<${i}@example.test>`)
|
||||||
|
});
|
||||||
|
assert.ok(result.references.length <= 900);
|
||||||
|
assert.ok(result.references.startsWith('<0@example.test>'));
|
||||||
|
assert.ok(result.references.endsWith('<parent@example>'));
|
||||||
|
});
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
const test = require('node:test');
|
||||||
|
const assert = require('node:assert/strict');
|
||||||
|
const fs = require('node:fs');
|
||||||
|
const vm = require('node:vm');
|
||||||
|
const path = require('node:path');
|
||||||
|
const threads = require('../conversation-threads.js');
|
||||||
|
|
||||||
|
test('conversation toggle hides older messages, clears their selection and preserves scroll', () => {
|
||||||
|
const source = fs.readFileSync(path.join(__dirname, '..', 'app.js'), 'utf8');
|
||||||
|
const code = source.slice(source.indexOf('const collapsedThreads = new Set();'), source.indexOf('function openMessage(id)'));
|
||||||
|
const list = { innerHTML: '', scrollTop: 42 };
|
||||||
|
const state = {
|
||||||
|
activeFolder: 'Inbox', query: '', activeMessage: null, selectedIds: new Set([1, 2]),
|
||||||
|
messages: [
|
||||||
|
{ id: 1, messageId: '<one@test>', inReplyTo: '<root@test>', subject: 'Re: Topic', unread: true },
|
||||||
|
{ id: 2, messageId: '<root@test>', subject: 'Topic' }
|
||||||
|
]
|
||||||
|
};
|
||||||
|
let handler;
|
||||||
|
const context = {
|
||||||
|
state, window: { epMailConversationThreads: threads },
|
||||||
|
document: { body: { classList: { remove() {} } } },
|
||||||
|
esc: value => String(value).replace(/&/g, '&').replace(/</g, '<').replace(/"/g, '"'),
|
||||||
|
$: selector => selector === '#message-list' ? list : {},
|
||||||
|
$$: selector => selector === '.conversation-toggle' ? [{
|
||||||
|
dataset: { thread: '0' },
|
||||||
|
getAttribute: () => list.innerHTML.includes('aria-expanded="true"') ? 'true' : 'false',
|
||||||
|
addEventListener(_type, callback) { handler = callback; }
|
||||||
|
}] : [],
|
||||||
|
emptyReader: () => '', openMessage() {}
|
||||||
|
};
|
||||||
|
vm.runInNewContext(`${code}\nrenderList();`, context);
|
||||||
|
assert.match(list.innerHTML, /aria-expanded="true"/);
|
||||||
|
assert.match(list.innerHTML, /2 messages · 1 unread/);
|
||||||
|
handler();
|
||||||
|
assert.match(list.innerHTML, /aria-expanded="false"/);
|
||||||
|
assert.match(list.innerHTML, /class="conversation-replies" hidden/);
|
||||||
|
assert.deepEqual([...state.selectedIds], [1]);
|
||||||
|
assert.equal(list.scrollTop, 42);
|
||||||
|
handler();
|
||||||
|
assert.match(list.innerHTML, /aria-expanded="true"/);
|
||||||
|
assert.doesNotMatch(list.innerHTML, /class="conversation-replies" hidden/);
|
||||||
|
});
|
||||||
@@ -0,0 +1,191 @@
|
|||||||
|
const test = require('node:test');
|
||||||
|
const assert = require('node:assert/strict');
|
||||||
|
const fs = require('node:fs');
|
||||||
|
const path = require('node:path');
|
||||||
|
const vm = require('node:vm');
|
||||||
|
|
||||||
|
const root = path.resolve(__dirname, '..');
|
||||||
|
const mailSource = fs.readFileSync(path.join(root, 'mail-ui.js'), 'utf8');
|
||||||
|
const pgpSource = fs.readFileSync(path.join(root, 'pgp-mail-ui.js'), 'utf8');
|
||||||
|
const setupSource = mailSource.slice(mailSource.indexOf('function setupDraftComposer()'), mailSource.indexOf('\nasync function syncMailbox('));
|
||||||
|
|
||||||
|
function harness(initialDraft = null, reply = null, forward = false) {
|
||||||
|
const saved = [];
|
||||||
|
const deleted = [];
|
||||||
|
const toasts = [];
|
||||||
|
const elements = new Map();
|
||||||
|
const timers = new Map();
|
||||||
|
let nextTimer = 0;
|
||||||
|
let wrapped;
|
||||||
|
let saveDraft = async values => { saved.push(structuredClone(values)); return { id: values.id }; };
|
||||||
|
function node() {
|
||||||
|
const listeners = {};
|
||||||
|
return {
|
||||||
|
value: '', dataset: {}, isConnected: true, files: [], children: [],
|
||||||
|
classList: { contains: () => false },
|
||||||
|
append(...items) { this.children.push(...items); },
|
||||||
|
replaceChildren() { this.children = []; },
|
||||||
|
insertBefore(item) { this.children.push(item); },
|
||||||
|
setAttribute() {},
|
||||||
|
addEventListener(type, handler) { (listeners[type] ||= []).push(handler); },
|
||||||
|
dispatch(type, event = {}) { for (const handler of listeners[type] || []) handler(event); },
|
||||||
|
querySelector(selector) { return elements.get(selector); }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
for (const name of ['#compose-to', '#compose-cc', '#compose-subject', '#compose-body', '#send', '#discard', '.modal-head span', '.compose-fields', '.compose-footer', '.modal-close', '.modal-overlay']) elements.set(name, node());
|
||||||
|
const modal = node();
|
||||||
|
const modalRoot = node();
|
||||||
|
modalRoot.querySelector = selector => selector === '.compose-modal' ? modal : elements.get(selector);
|
||||||
|
const context = {
|
||||||
|
appShell: { wrapShowCompose(fn) { wrapped = fn(() => {}); } },
|
||||||
|
selectMailUi: selector => selector === '#modal-root' ? modalRoot : elements.get(selector),
|
||||||
|
document: { createElement: node },
|
||||||
|
window: { epMailConversationThreads: require('../conversation-threads.js'), crypto: { randomUUID: () => 'new-id' }, daybreakMail: {
|
||||||
|
saveDraft: values => saveDraft(values),
|
||||||
|
async deleteDraft(id) { deleted.push(id); }
|
||||||
|
} },
|
||||||
|
rendererState: { activeFolder: 'Inbox' },
|
||||||
|
syncMailbox() {},
|
||||||
|
toastMailUi: message => toasts.push(message),
|
||||||
|
setTimeout(fn) { const id = ++nextTimer; timers.set(id, fn); return id; },
|
||||||
|
clearTimeout(id) { timers.delete(id); },
|
||||||
|
btoa: value => Buffer.from(value, 'binary').toString('base64')
|
||||||
|
};
|
||||||
|
vm.runInNewContext(`${setupSource}\nsetupDraftComposer();`, context);
|
||||||
|
wrapped(reply, forward, initialDraft);
|
||||||
|
return {
|
||||||
|
modal, modalRoot, elements, saved, deleted, toasts,
|
||||||
|
setSave(fn) { saveDraft = fn; },
|
||||||
|
async runTimers() { for (const fn of [...timers.values()]) fn(); timers.clear(); await new Promise(resolve => setImmediate(resolve)); },
|
||||||
|
async settle() { await new Promise(resolve => setImmediate(resolve)); }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
test('PGP composer forwards the complete draft to the wrapped composer', () => {
|
||||||
|
const start = pgpSource.indexOf('pgpMailUi.wrapShowCompose(');
|
||||||
|
const end = pgpSource.indexOf('\n// Called by the send handler', start);
|
||||||
|
let args;
|
||||||
|
const context = {
|
||||||
|
pgpMailUi: { wrapShowCompose(decorator) { decorator((...values) => { args = values; })(null, false, { id: 'existing', text: 'saved text' }); } },
|
||||||
|
selectPgpMailUi: () => null
|
||||||
|
};
|
||||||
|
vm.runInNewContext(pgpSource.slice(start, end), context);
|
||||||
|
assert.equal(args[2].id, 'existing');
|
||||||
|
assert.equal(args[2].text, 'saved text');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('reopening a draft restores fields, attachments, and its identity', () => {
|
||||||
|
const draft = { id: 'existing', to: 'a@example.test', cc: 'b@example.test', subject: 'Subject', text: 'Message', attachments: [{ filename: 'note.txt' }] };
|
||||||
|
const h = harness(draft);
|
||||||
|
assert.equal(h.modal.dataset.draftId, draft.id);
|
||||||
|
for (const [field, value] of [['to', draft.to], ['cc', draft.cc], ['subject', draft.subject], ['body', draft.text]]) {
|
||||||
|
assert.equal(h.elements.get(`#compose-${field}`).value, value);
|
||||||
|
}
|
||||||
|
assert.equal(h.modal._composeAttachments[0].filename, 'note.txt');
|
||||||
|
assert.equal(h.elements.get('.modal-head span').textContent, 'Edit draft');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('reply draft preserves thread headers when saved and restored; forwards do not inherit them', async () => {
|
||||||
|
const h = harness(null, { messageId: '<parent@example.test>', references: '<root@example.test>' });
|
||||||
|
h.elements.get('#compose-body').value = 'Reply';
|
||||||
|
h.modal.dispatch('input');
|
||||||
|
await h.runTimers();
|
||||||
|
assert.equal(h.saved[0].inReplyTo, '<parent@example.test>');
|
||||||
|
assert.equal(h.saved[0].references, '<root@example.test> <parent@example.test>');
|
||||||
|
const restored = harness(h.saved[0]);
|
||||||
|
assert.equal(restored.modal._replyHeaders.inReplyTo, '<parent@example.test>');
|
||||||
|
const forward = harness(null, { messageId: '<parent@example.test>' }, true);
|
||||||
|
assert.equal(forward.modal._replyHeaders.inReplyTo, '');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('blank and whitespace-only new messages are not saved on close or manual save', async () => {
|
||||||
|
const h = harness();
|
||||||
|
h.elements.get('#compose-body').value = ' \n ';
|
||||||
|
h.modal.dispatch('input');
|
||||||
|
await h.runTimers();
|
||||||
|
const save = h.elements.get('.compose-footer').children.find(item => item.id === 'save-draft');
|
||||||
|
await save.onclick();
|
||||||
|
assert.equal(h.toasts.at(-1), 'Nothing to save in this draft');
|
||||||
|
h.elements.get('.modal-close').dispatch('click');
|
||||||
|
await h.settle();
|
||||||
|
assert.equal(h.saved.length, 0);
|
||||||
|
assert.equal(h.modal.dataset.draftId, '');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('closing via overlay or Escape saves meaningful unsaved text', async () => {
|
||||||
|
for (const method of ['overlay', 'escape']) {
|
||||||
|
const h = harness();
|
||||||
|
h.elements.get('#compose-subject').value = 'Saved subject';
|
||||||
|
if (method === 'overlay') h.elements.get('.modal-overlay').dispatch('click', { target: { classList: { contains: () => true } } });
|
||||||
|
else h.modal.dispatch('keydown', { key: 'Escape' });
|
||||||
|
await h.settle();
|
||||||
|
assert.equal(h.saved.length, 1);
|
||||||
|
assert.equal(h.saved[0].subject, 'Saved subject');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
test('attachment-only drafts are saved and picker cancellation creates nothing', async () => {
|
||||||
|
const h = harness();
|
||||||
|
const attachmentRow = h.elements.get('.compose-fields').children[0];
|
||||||
|
const input = attachmentRow.children[1].children[1];
|
||||||
|
await input.onchange();
|
||||||
|
assert.equal(h.saved.length, 0);
|
||||||
|
input.files = [{ name: 'note.txt', type: 'text/plain', size: 3, async arrayBuffer() { return Uint8Array.from([97, 98, 99]).buffer; } }];
|
||||||
|
await input.onchange();
|
||||||
|
assert.equal(h.saved.length, 1);
|
||||||
|
assert.equal(h.saved[0].attachments[0].contentBase64, 'YWJj');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('pending saves are serialized and discard waits before deleting', async () => {
|
||||||
|
const h = harness();
|
||||||
|
let finishFirst;
|
||||||
|
const calls = [];
|
||||||
|
h.setSave(values => {
|
||||||
|
calls.push(values.text);
|
||||||
|
if (calls.length === 1) return new Promise(resolve => { finishFirst = resolve; });
|
||||||
|
return Promise.resolve({ id: values.id });
|
||||||
|
});
|
||||||
|
h.elements.get('#compose-body').value = 'first';
|
||||||
|
h.modal.dispatch('input');
|
||||||
|
await h.runTimers();
|
||||||
|
h.elements.get('#compose-body').value = 'second';
|
||||||
|
h.modal.dispatch('input');
|
||||||
|
await h.runTimers();
|
||||||
|
const discard = h.elements.get('#discard').onclick();
|
||||||
|
assert.deepEqual(calls, ['first']);
|
||||||
|
assert.deepEqual(h.deleted, []);
|
||||||
|
finishFirst({ id: 'new-id' });
|
||||||
|
await discard;
|
||||||
|
assert.deepEqual(calls, ['first', 'second']);
|
||||||
|
assert.deepEqual(h.deleted, ['new-id']);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('sent draft cleanup cancels unsaved timers and waits for in-flight saves', async () => {
|
||||||
|
const h = harness();
|
||||||
|
let finishSave;
|
||||||
|
h.setSave(() => new Promise(resolve => { finishSave = resolve; }));
|
||||||
|
h.elements.get('#compose-body').value = 'sent message';
|
||||||
|
h.modal.dispatch('input');
|
||||||
|
await h.runTimers();
|
||||||
|
h.elements.get('#compose-body').value = 'newer edit';
|
||||||
|
h.modal.dispatch('input');
|
||||||
|
const cleanup = h.modal._deleteSavedDraft();
|
||||||
|
await h.runTimers();
|
||||||
|
assert.deepEqual(h.deleted, []);
|
||||||
|
finishSave({ id: 'new-id' });
|
||||||
|
await cleanup;
|
||||||
|
assert.deepEqual(h.deleted, ['new-id']);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('a failed save reports an error and a later save can retry', async () => {
|
||||||
|
const h = harness();
|
||||||
|
h.elements.get('#compose-body').value = 'message';
|
||||||
|
h.setSave(async () => { throw new Error('Storage unavailable'); });
|
||||||
|
const save = h.elements.get('.compose-footer').children.find(item => item.id === 'save-draft');
|
||||||
|
await save.onclick();
|
||||||
|
assert.equal(h.toasts.at(-1), 'Storage unavailable');
|
||||||
|
h.setSave(async values => { h.saved.push(values); return { id: values.id }; });
|
||||||
|
await save.onclick();
|
||||||
|
assert.equal(h.saved.length, 1);
|
||||||
|
assert.equal(h.toasts.at(-1), 'Draft saved on this device');
|
||||||
|
});
|
||||||
@@ -71,6 +71,7 @@ test('validates channel-specific field shapes, limits, and enums', () => {
|
|||||||
test('prevents renderer-supplied raw SMTP messages while accepting standard compose fields', () => {
|
test('prevents renderer-supplied raw SMTP messages while accepting standard compose fields', () => {
|
||||||
assert.doesNotThrow(() => validateIpcArguments('mail:send', [{
|
assert.doesNotThrow(() => validateIpcArguments('mail:send', [{
|
||||||
to: 'friend@example.test', cc: '', subject: 'Hello', text: 'Body',
|
to: 'friend@example.test', cc: '', subject: 'Hello', text: 'Body',
|
||||||
|
inReplyTo: '<parent@example.test>', references: '<root@example.test> <parent@example.test>',
|
||||||
attachments: [{ filename: 'note.txt', contentBase64: 'aGVsbG8=' }],
|
attachments: [{ filename: 'note.txt', contentBase64: 'aGVsbG8=' }],
|
||||||
pgp: { encrypt: true, sign: false, passphrase: null }
|
pgp: { encrypt: true, sign: false, passphrase: null }
|
||||||
}]));
|
}]));
|
||||||
|
|||||||
@@ -82,6 +82,20 @@ test('reports Sent-copy failures without retrying a message accepted by SMTP', a
|
|||||||
assert.equal(calls.appended.length, 0);
|
assert.equal(calls.appended.length, 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('preserves reply headers in the SMTP message and Sent copy', async () => {
|
||||||
|
const { sendMailNow, calls } = makeSender();
|
||||||
|
await sendMailNow({ email: 'sender@example.com' }, {
|
||||||
|
to: 'recipient@example.com',
|
||||||
|
inReplyTo: '<parent@example.test>',
|
||||||
|
references: '<root@example.test> <parent@example.test>'
|
||||||
|
});
|
||||||
|
assert.equal(calls.smtp[0].inReplyTo, '<parent@example.test>');
|
||||||
|
assert.deepEqual(calls.smtp[0].references, ['<root@example.test>', '<parent@example.test>']);
|
||||||
|
const saved = JSON.parse(calls.appended[0].content.toString());
|
||||||
|
assert.equal(saved.inReplyTo, calls.smtp[0].inReplyTo);
|
||||||
|
assert.deepEqual(saved.references, calls.smtp[0].references);
|
||||||
|
});
|
||||||
|
|
||||||
test('closes SMTP transport and reports send failures', async () => {
|
test('closes SMTP transport and reports send failures', async () => {
|
||||||
const { sendMailNow, calls } = makeSender({ smtpFails: true });
|
const { sendMailNow, calls } = makeSender({ smtpFails: true });
|
||||||
await assert.rejects(
|
await assert.rejects(
|
||||||
|
|||||||
@@ -52,8 +52,11 @@ test('all built-in and custom key servers start disabled', () => {
|
|||||||
url: 'https://keys.example.org',
|
url: 'https://keys.example.org',
|
||||||
protocol: 'hkp'
|
protocol: 'hkp'
|
||||||
}]);
|
}]);
|
||||||
assert.equal(servers.length, 3);
|
assert.equal(servers.length, 4);
|
||||||
|
assert.ok(servers.some(server => server.id === 'eternity-vks' && server.url === 'https://keys.eternityproject.fi' && server.protocol === 'vks'));
|
||||||
assert.ok(servers.every(server => server.enabled === false));
|
assert.ok(servers.every(server => server.enabled === false));
|
||||||
|
const trimmed = listServers([], [], ['openpgp-vks', 'mailvelope-hkp']);
|
||||||
|
assert.deepEqual(trimmed.map(server => server.id), ['eternity-vks']);
|
||||||
const enabled = listServers([], ['openpgp-vks']);
|
const enabled = listServers([], ['openpgp-vks']);
|
||||||
assert.equal(enabled.find(server => server.id === 'openpgp-vks').enabled, true);
|
assert.equal(enabled.find(server => server.id === 'openpgp-vks').enabled, true);
|
||||||
assert.equal(enabled.find(server => server.id === 'mailvelope-hkp').enabled, false);
|
assert.equal(enabled.find(server => server.id === 'mailvelope-hkp').enabled, false);
|
||||||
|
|||||||
@@ -32,11 +32,16 @@ test('encrypts and signs for a recipient and the sender can read the copy', asyn
|
|||||||
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 exchange(alice, bob);
|
await exchange(alice, bob);
|
||||||
const { raw, envelope } = await alice.mail.build(sendOptions(alice, 'Bob <bob@example.com>', { encrypt: true, sign: true, passphrase: alice.passphrase }));
|
const { raw, envelope } = await alice.mail.build(sendOptions(alice, 'Bob <bob@example.com>', {
|
||||||
|
encrypt: true, sign: true, passphrase: alice.passphrase,
|
||||||
|
inReplyTo: '<parent@example.test>', references: '<root@example.test> <parent@example.test>'
|
||||||
|
}));
|
||||||
assert.deepEqual(envelope.to, ['bob@example.com']);
|
assert.deepEqual(envelope.to, ['bob@example.com']);
|
||||||
assert.ok(!raw.toString('latin1').includes('Top secret'));
|
assert.ok(!raw.toString('latin1').includes('Top secret'));
|
||||||
const parsed = await simpleParser(raw);
|
const parsed = await simpleParser(raw);
|
||||||
assert.equal(parsed.subject, 'Héllo secrèt');
|
assert.equal(parsed.subject, 'Héllo secrèt');
|
||||||
|
assert.equal(parsed.inReplyTo, '<parent@example.test>');
|
||||||
|
assert.deepEqual(parsed.references, ['<root@example.test>', '<parent@example.test>']);
|
||||||
assert.equal(detect(parsed), 'encrypted-mime');
|
assert.equal(detect(parsed), 'encrypted-mime');
|
||||||
await assert.rejects(() => bob.mail.decrypt(parsed), error => error.code === 'PASSPHRASE_REQUIRED');
|
await assert.rejects(() => bob.mail.decrypt(parsed), error => error.code === 'PASSPHRASE_REQUIRED');
|
||||||
await assert.rejects(() => bob.mail.decrypt(parsed, { passphrase: 'wrong wrong' }), error => error.code === 'BAD_PASSPHRASE');
|
await assert.rejects(() => bob.mail.decrypt(parsed, { passphrase: 'wrong wrong' }), error => error.code === 'BAD_PASSPHRASE');
|
||||||
@@ -195,7 +200,7 @@ test('keyring: contacts, trust levels, expired passphrase cache and settings', a
|
|||||||
await assert.rejects(async () => alice.keyStore.addContact({ armoredKey: await bob.keyStore.exportPublic(bob.key.fingerprint) }), /already/);
|
await assert.rejects(async () => alice.keyStore.addContact({ armoredKey: await bob.keyStore.exportPublic(bob.key.fingerprint) }), /already/);
|
||||||
await assert.rejects(async () => alice.keyStore.addContact({ armoredKey: await bob.keyStore.exportPrivate(bob.key.fingerprint, bob.passphrase) }), /private key/);
|
await assert.rejects(async () => alice.keyStore.addContact({ armoredKey: await bob.keyStore.exportPrivate(bob.key.fingerprint, bob.passphrase) }), /private key/);
|
||||||
await assert.rejects(() => alice.keyStore.addContact({ armoredKey: 'junk' }), /valid OpenPGP/);
|
await assert.rejects(() => alice.keyStore.addContact({ armoredKey: 'junk' }), /valid OpenPGP/);
|
||||||
assert.deepEqual(await alice.keyStore.getSettings(), { cacheMinutes: 10, customKeyServers: [], enabledKeyServers: [] });
|
assert.deepEqual(await alice.keyStore.getSettings(), { cacheMinutes: 10, customKeyServers: [], enabledKeyServers: [], removedBuiltinKeyServers: [] });
|
||||||
const customServer = { id: 'custom', name: 'Example', url: 'https://keys.example.org/', protocol: 'hkp' };
|
const customServer = { id: 'custom', name: 'Example', url: 'https://keys.example.org/', protocol: 'hkp' };
|
||||||
await alice.keyStore.setSettings({ cacheMinutes: 0, customKeyServers: [customServer], enabledKeyServers: ['custom', 'openpgp-vks'] });
|
await alice.keyStore.setSettings({ cacheMinutes: 0, customKeyServers: [customServer], enabledKeyServers: ['custom', 'openpgp-vks'] });
|
||||||
assert.equal((await alice.keyStore.getSettings()).cacheMinutes, 0);
|
assert.equal((await alice.keyStore.getSettings()).cacheMinutes, 0);
|
||||||
|
|||||||
@@ -0,0 +1,70 @@
|
|||||||
|
const test = require('node:test');
|
||||||
|
const assert = require('node:assert/strict');
|
||||||
|
const fs = require('node:fs');
|
||||||
|
const path = require('node:path');
|
||||||
|
const vm = require('node:vm');
|
||||||
|
|
||||||
|
const source = fs.readFileSync(path.join(__dirname, '..', 'pgp-ui.js'), 'utf8');
|
||||||
|
|
||||||
|
async function openKeySettings(platform) {
|
||||||
|
const elements = new Map();
|
||||||
|
function element(selector) {
|
||||||
|
if (!elements.has(selector)) elements.set(selector, {
|
||||||
|
value: '', textContent: '', innerHTML: '',
|
||||||
|
append() {}, replaceChildren() {}, focus() { this.focused = true; },
|
||||||
|
querySelector: element
|
||||||
|
});
|
||||||
|
return elements.get(selector);
|
||||||
|
}
|
||||||
|
const calls = [];
|
||||||
|
const pgp = {
|
||||||
|
platform,
|
||||||
|
async list() { return []; },
|
||||||
|
async contacts() { return []; },
|
||||||
|
async keyServers() { return []; },
|
||||||
|
async getSettings() { return { cacheMinutes: 0 }; },
|
||||||
|
async importKey(input) { calls.push(input); return { canceled: false }; }
|
||||||
|
};
|
||||||
|
let wrap;
|
||||||
|
const window = {
|
||||||
|
daybreakMail: { pgp },
|
||||||
|
epMailFeatures: {
|
||||||
|
mail: { select: element, selectAll: () => [], escapeHtml: value => value, toast() {}, connectedAccount: { id: 'account-1' } },
|
||||||
|
productivity: { wrapOpenPreferences(fn) { wrap = fn; } }
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let openButton;
|
||||||
|
const document = { createElement() { openButton = {}; return openButton; } };
|
||||||
|
element('#modal-root .compose-fields').append = button => { openButton = button; };
|
||||||
|
vm.runInNewContext(source, { window, document });
|
||||||
|
await wrap(async () => {})();
|
||||||
|
openButton.onclick();
|
||||||
|
return { element, calls, pgp };
|
||||||
|
}
|
||||||
|
|
||||||
|
test('Android private-key controls route file and paste imports with the account and passphrase', async () => {
|
||||||
|
const { element, calls, pgp } = await openKeySettings('android');
|
||||||
|
assert.match(element('#modal-root').innerHTML, /Import private key from file/);
|
||||||
|
await element('#pgp-import').onclick();
|
||||||
|
assert.equal(calls.length, 0);
|
||||||
|
assert.equal(element('#pgp-passphrase').focused, true);
|
||||||
|
element('#pgp-passphrase').value = 'test passphrase';
|
||||||
|
await element('#pgp-import').onclick();
|
||||||
|
await element('#pgp-import-paste').onclick();
|
||||||
|
assert.equal(calls[0].source, 'file');
|
||||||
|
assert.equal(calls[1].source, 'paste');
|
||||||
|
assert.equal(calls[0].passphrase, 'test passphrase');
|
||||||
|
assert.equal(calls[0].accountId, 'account-1');
|
||||||
|
pgp.importKey = async () => { throw new Error('File read failed'); };
|
||||||
|
await element('#pgp-import').onclick();
|
||||||
|
assert.equal(element('#pgp-status').textContent, 'File read failed');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('desktop private-key import retains its existing file-picker API', async () => {
|
||||||
|
const { element, calls } = await openKeySettings('desktop');
|
||||||
|
assert.doesNotMatch(element('#modal-root').innerHTML, /pgp-import-paste/);
|
||||||
|
element('#pgp-passphrase').value = 'test passphrase';
|
||||||
|
await element('#pgp-import').onclick();
|
||||||
|
assert.equal(calls.length, 1);
|
||||||
|
assert.equal(Object.hasOwn(calls[0], 'source'), false);
|
||||||
|
});
|
||||||
@@ -55,7 +55,7 @@ test('desktop, Android web generation, and offline cache include renderer suppor
|
|||||||
const buildFiles = require(path.join(root, 'package.json')).build.files;
|
const buildFiles = require(path.join(root, 'package.json')).build.files;
|
||||||
const androidAssets = read('scripts/prepare-android-web.cjs');
|
const androidAssets = read('scripts/prepare-android-web.cjs');
|
||||||
const worker = read('service-worker.js');
|
const worker = read('service-worker.js');
|
||||||
for (const file of ['renderer-state.js', 'mail-content-security.js', 'renderer-mail-api.js', 'platform-bridge-loader.js']) {
|
for (const file of ['renderer-state.js', 'conversation-threads.js', 'mail-content-security.js', 'renderer-mail-api.js', 'platform-bridge-loader.js']) {
|
||||||
assert.ok(buildFiles.includes(file), `Electron package is missing ${file}`);
|
assert.ok(buildFiles.includes(file), `Electron package is missing ${file}`);
|
||||||
assert.ok(androidAssets.includes(`'${file}'`), `Android web generator is missing ${file}`);
|
assert.ok(androidAssets.includes(`'${file}'`), `Android web generator is missing ${file}`);
|
||||||
assert.ok(worker.includes(`'./${file}'`), `service worker is missing ${file}`);
|
assert.ok(worker.includes(`'./${file}'`), `service worker is missing ${file}`);
|
||||||
|
|||||||
+48
-1
@@ -18,7 +18,54 @@ function returnToMessageList() {
|
|||||||
if (readerListPosition?.folder === state.activeFolder) $('#message-list').scrollTop = readerListPosition.scrollTop;
|
if (readerListPosition?.folder === state.activeFolder) $('#message-list').scrollTop = readerListPosition.scrollTop;
|
||||||
readerListPosition = null;
|
readerListPosition = null;
|
||||||
}
|
}
|
||||||
function renderList(){let rows=state.messages.filter(m=>{if(state.activeFolder==='Starred'&&!m.star)return false;if(state.activeFolder==='Inbox'&&m.archived)return false;if(state.activeFolder==='Archive'&&!m.archived)return false;if(state.activeFolder==='Trash'&&!m.deleted)return false;if(state.activeFolder==='Sent'&&!m.sent)return false;if(state.activeFolder==='Drafts')return false;if(state.activeFolder==='Snoozed')return false;if(m.deleted&&state.activeFolder!=='Trash')return false;return !state.query||`${m.sender} ${m.email} ${m.subject} ${m.snippet}`.toLowerCase().includes(state.query.toLowerCase())});$('#message-list').innerHTML=rows.length?rows.map(m=>`<div class="message ${m.unread?'unread':''} ${m.id===state.activeMessage?'selected':''}" data-id="${m.id}"><input class="row-check" type="checkbox" aria-label="Select message" ${state.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;state.selectedIds.has(id)?state.selectedIds.delete(id):state.selectedIds.add(id);return}if(e.target.closest('.star')){const m=state.messages.find(x=>x.id===+row.dataset.id);m.star=!m.star;renderList();return}openMessage(+row.dataset.id)});});if(!rows.length){document.body.classList.remove('reader-open');$('#reader-pane').innerHTML=emptyReader()}}
|
const collapsedThreads = new Set();
|
||||||
|
function renderList() {
|
||||||
|
const rows = state.messages.filter(m => {
|
||||||
|
if (state.activeFolder === 'Starred' && !m.star) return false;
|
||||||
|
if (state.activeFolder === 'Inbox' && m.archived) return false;
|
||||||
|
if (state.activeFolder === 'Archive' && !m.archived) return false;
|
||||||
|
if (state.activeFolder === 'Trash' && !m.deleted) return false;
|
||||||
|
if (state.activeFolder === 'Sent' && !m.sent) return false;
|
||||||
|
if (state.activeFolder === 'Drafts' || state.activeFolder === 'Snoozed') return false;
|
||||||
|
if (m.deleted && state.activeFolder !== 'Trash') return false;
|
||||||
|
return !state.query || `${m.sender} ${m.email} ${m.subject} ${m.snippet}`.toLowerCase().includes(state.query.toLowerCase());
|
||||||
|
});
|
||||||
|
const groups = window.epMailConversationThreads.groupMessages(rows);
|
||||||
|
const scope = `${window.epMailFeatures?.mail?.connectedAccount?.id || ''}:${state.activeFolder}:`;
|
||||||
|
const keyFor = message => scope + (window.epMailConversationThreads.messageIds(message.messageId)[0] || `uid:${message.sourceFolder || ''}:${message.id}`);
|
||||||
|
const rowHtml = m => `<div class="message ${m.unread?'unread':''} ${m.id===state.activeMessage?'selected':''}" data-id="${esc(m.id)}"><input class="row-check" type="checkbox" aria-label="Select message" ${state.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>`;
|
||||||
|
$('#message-list').innerHTML = rows.length ? groups.map((group, index) => {
|
||||||
|
if (group.length === 1) return rowHtml(group[0]);
|
||||||
|
const collapsed = group.some(message => collapsedThreads.has(keyFor(message)));
|
||||||
|
if (collapsed) group.slice(1).forEach(message => state.selectedIds.delete(message.id));
|
||||||
|
const unread = group.filter(message => message.unread).length;
|
||||||
|
return `<section class="conversation"><button type="button" class="conversation-toggle" data-thread="${index}" aria-expanded="${!collapsed}" aria-label="${collapsed ? 'Expand' : 'Collapse'} conversation: ${esc(group[0].subject)}">${collapsed ? '▸' : '▾'} Conversation · ${group.length} messages${unread ? ` · ${unread} unread` : ''}</button>${rowHtml(group[0])}<div class="conversation-replies"${collapsed ? ' hidden' : ''}>${group.slice(1).map(rowHtml).join('')}</div></section>`;
|
||||||
|
}).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>`;
|
||||||
|
$$('.conversation-toggle').forEach(button => button.addEventListener('click', () => {
|
||||||
|
const group = groups[Number(button.dataset.thread)];
|
||||||
|
const collapsing = button.getAttribute('aria-expanded') === 'true';
|
||||||
|
group.forEach(message => collapsing ? collapsedThreads.add(keyFor(message)) : collapsedThreads.delete(keyFor(message)));
|
||||||
|
if (collapsing) group.slice(1).forEach(message => state.selectedIds.delete(message.id));
|
||||||
|
const scrollTop = $('#message-list').scrollTop;
|
||||||
|
renderList();
|
||||||
|
$('#message-list').scrollTop = scrollTop;
|
||||||
|
}));
|
||||||
|
$$('.message').forEach(row => row.addEventListener('click', e => {
|
||||||
|
if (e.target.closest('.row-check')) {
|
||||||
|
const id = +row.dataset.id;
|
||||||
|
state.selectedIds.has(id) ? state.selectedIds.delete(id) : state.selectedIds.add(id);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (e.target.closest('.star')) {
|
||||||
|
const m = state.messages.find(x => x.id === +row.dataset.id);
|
||||||
|
m.star = !m.star;
|
||||||
|
renderList();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
openMessage(+row.dataset.id);
|
||||||
|
}));
|
||||||
|
if (!rows.length) { document.body.classList.remove('reader-open'); $('#reader-pane').innerHTML = emptyReader(); }
|
||||||
|
}
|
||||||
function openMessage(id){
|
function openMessage(id){
|
||||||
state.activeMessage=id;
|
state.activeMessage=id;
|
||||||
const m=state.messages.find(x=>x.id===id);
|
const m=state.messages.find(x=>x.id===id);
|
||||||
|
|||||||
@@ -0,0 +1,47 @@
|
|||||||
|
(function installConversationThreads(root, factory) {
|
||||||
|
const api = factory();
|
||||||
|
if (typeof module === 'object' && module.exports) module.exports = api;
|
||||||
|
else root.epMailConversationThreads = api;
|
||||||
|
})(typeof window === 'undefined' ? globalThis : window, function () {
|
||||||
|
function messageIds(value) {
|
||||||
|
const text = Array.isArray(value) ? value.join(' ') : String(value || '');
|
||||||
|
return [...new Set((text.match(/<[\x21-\x3b\x3d\x3f-\x7e]+@[\x21-\x3b\x3d\x3f-\x7e]+>/g) || [])
|
||||||
|
.filter(id => id.length <= 254))];
|
||||||
|
}
|
||||||
|
|
||||||
|
function replyHeaders(message) {
|
||||||
|
const inReplyTo = messageIds(message?.messageId)[0] || '';
|
||||||
|
if (!inReplyTo) return { inReplyTo: '', references: '' };
|
||||||
|
const ids = [...new Set([...messageIds(message.references), inReplyTo])];
|
||||||
|
while (ids.join(' ').length > 900 && ids.length > 1) ids.splice(1, 1);
|
||||||
|
return { inReplyTo, references: ids.join(' ') };
|
||||||
|
}
|
||||||
|
|
||||||
|
function groupMessages(messages) {
|
||||||
|
const parents = messages.map((_, index) => index);
|
||||||
|
const find = index => {
|
||||||
|
while (parents[index] !== index) {
|
||||||
|
parents[index] = parents[parents[index]];
|
||||||
|
index = parents[index];
|
||||||
|
}
|
||||||
|
return index;
|
||||||
|
};
|
||||||
|
const owners = new Map();
|
||||||
|
messages.forEach((message, index) => {
|
||||||
|
const ids = [...messageIds(message.messageId), ...messageIds(message.inReplyTo), ...messageIds(message.references)];
|
||||||
|
for (const id of new Set(ids)) {
|
||||||
|
if (owners.has(id)) parents[find(index)] = find(owners.get(id));
|
||||||
|
else owners.set(id, index);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const groups = new Map();
|
||||||
|
messages.forEach((message, index) => {
|
||||||
|
const root = find(index);
|
||||||
|
if (!groups.has(root)) groups.set(root, []);
|
||||||
|
groups.get(root).push(message);
|
||||||
|
});
|
||||||
|
return [...groups.values()];
|
||||||
|
}
|
||||||
|
|
||||||
|
return { messageIds, replyHeaders, groupMessages };
|
||||||
|
});
|
||||||
@@ -65,6 +65,7 @@
|
|||||||
<div id="modal-root"></div>
|
<div id="modal-root"></div>
|
||||||
<div id="toast" class="toast" role="status" aria-live="polite"></div>
|
<div id="toast" class="toast" role="status" aria-live="polite"></div>
|
||||||
<script src="renderer-state.js"></script>
|
<script src="renderer-state.js"></script>
|
||||||
|
<script src="conversation-threads.js"></script>
|
||||||
<script src="mail-content-security.js"></script>
|
<script src="mail-content-security.js"></script>
|
||||||
<script src="app.js"></script>
|
<script src="app.js"></script>
|
||||||
<script src="platform-bridge-loader.js"></script>
|
<script src="platform-bridge-loader.js"></script>
|
||||||
|
|||||||
+48
-34
@@ -529,6 +529,9 @@ 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 || '';
|
||||||
|
modal._replyHeaders = draft
|
||||||
|
? { inReplyTo: draft.inReplyTo || '', references: draft.references || '' }
|
||||||
|
: reply && !forward ? window.epMailConversationThreads.replyHeaders(reply) : { inReplyTo: '', references: '' };
|
||||||
let attachments = Array.isArray(draft?.attachments) ? draft.attachments : [];
|
let attachments = Array.isArray(draft?.attachments) ? draft.attachments : [];
|
||||||
modal._composeAttachments = attachments;
|
modal._composeAttachments = attachments;
|
||||||
const fields = modal.querySelector('.compose-fields');
|
const fields = modal.querySelector('.compose-fields');
|
||||||
@@ -595,6 +598,7 @@ function setupDraftComposer() {
|
|||||||
contentBase64: btoa(binary)
|
contentBase64: btoa(binary)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if (closed) return;
|
||||||
attachments.push(...selected);
|
attachments.push(...selected);
|
||||||
renderAttachments();
|
renderAttachments();
|
||||||
await persist();
|
await persist();
|
||||||
@@ -621,58 +625,67 @@ function setupDraftComposer() {
|
|||||||
modal.querySelector('.compose-footer').insertBefore(save, selectMailUi('#send'));
|
modal.querySelector('.compose-footer').insertBefore(save, selectMailUi('#send'));
|
||||||
let saveTimer;
|
let saveTimer;
|
||||||
let closed = false;
|
let closed = false;
|
||||||
const persist = async () => {
|
let pendingSave = Promise.resolve();
|
||||||
if (closed || !selectMailUi('#compose-to')) return;
|
const persist = () => {
|
||||||
|
if (closed || !modal.isConnected) return Promise.resolve(false);
|
||||||
const values = {
|
const values = {
|
||||||
id: modal.dataset.draftId || window.crypto.randomUUID(),
|
to: modal.querySelector('#compose-to').value,
|
||||||
to: selectMailUi('#compose-to').value,
|
cc: modal.querySelector('#compose-cc').value,
|
||||||
cc: selectMailUi('#compose-cc').value,
|
subject: modal.querySelector('#compose-subject').value,
|
||||||
subject: selectMailUi('#compose-subject').value,
|
text: modal.querySelector('#compose-body').value,
|
||||||
text: selectMailUi('#compose-body').value,
|
attachments: [...attachments],
|
||||||
attachments
|
...modal._replyHeaders
|
||||||
};
|
};
|
||||||
if (!Object.values(values).some(value => typeof value === 'string' && value.trim()) && !attachments.length) return;
|
if (!modal.dataset.draftId && ![values.to, values.cc, values.subject, values.text].some(value => value.trim()) && !values.attachments.length) return Promise.resolve(false);
|
||||||
|
values.id = modal.dataset.draftId || window.crypto.randomUUID();
|
||||||
modal.dataset.draftId = values.id;
|
modal.dataset.draftId = values.id;
|
||||||
const result = await window.daybreakMail.saveDraft(values);
|
const operation = pendingSave.then(async () => {
|
||||||
modal.dataset.draftId = result.id;
|
await window.daybreakMail.saveDraft(values);
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
pendingSave = operation.then(() => {}, () => {});
|
||||||
|
return operation;
|
||||||
};
|
};
|
||||||
save.onclick = async () => {
|
save.onclick = async () => {
|
||||||
try {
|
try {
|
||||||
await persist();
|
const saved = await persist();
|
||||||
toastMailUi('Draft saved on this device');
|
toastMailUi(saved ? 'Draft saved on this device' : 'Nothing to save in this draft');
|
||||||
if (rendererState.activeFolder === 'Drafts') void syncMailbox(false);
|
if (saved && rendererState.activeFolder === 'Drafts') void syncMailbox(false);
|
||||||
} catch (error) { toastMailUi(error.message || 'Could not save draft'); }
|
} catch (error) { toastMailUi(error.message || 'Could not save draft'); }
|
||||||
};
|
};
|
||||||
modal.addEventListener('input', () => {
|
modal.addEventListener('input', () => {
|
||||||
clearTimeout(saveTimer);
|
clearTimeout(saveTimer);
|
||||||
saveTimer = setTimeout(() => persist().catch(error => toastMailUi(error.message || 'Could not save draft')), 700);
|
saveTimer = setTimeout(() => persist().catch(error => toastMailUi(error.message || 'Could not save draft')), 700);
|
||||||
});
|
});
|
||||||
modal.querySelector('.modal-overlay')?.addEventListener('click', event => {
|
const saveAndClose = () => {
|
||||||
|
if (closed) return;
|
||||||
|
clearTimeout(saveTimer);
|
||||||
|
persist().then(saved => { if (saved && rendererState.activeFolder === 'Drafts') void syncMailbox(false); })
|
||||||
|
.catch(error => toastMailUi(error.message || 'Could not save draft'));
|
||||||
|
closed = true;
|
||||||
|
};
|
||||||
|
root.querySelector('.modal-overlay')?.addEventListener('click', event => {
|
||||||
if (!event.target.classList.contains('modal-overlay')) return;
|
if (!event.target.classList.contains('modal-overlay')) return;
|
||||||
clearTimeout(saveTimer);
|
saveAndClose();
|
||||||
persist().then(() => { if (rendererState.activeFolder === 'Drafts') void syncMailbox(false); })
|
|
||||||
.catch(error => toastMailUi(error.message || 'Could not save draft'));
|
|
||||||
closed = true;
|
|
||||||
}, true);
|
}, true);
|
||||||
root.querySelector('.modal-close')?.addEventListener('click', () => {
|
root.querySelector('.modal-close')?.addEventListener('click', saveAndClose, true);
|
||||||
|
modal.addEventListener('keydown', event => {
|
||||||
|
if (event.key === 'Escape') saveAndClose();
|
||||||
|
});
|
||||||
|
const deleteSavedDraft = async () => {
|
||||||
clearTimeout(saveTimer);
|
clearTimeout(saveTimer);
|
||||||
persist().then(() => { if (rendererState.activeFolder === 'Drafts') void syncMailbox(false); })
|
|
||||||
.catch(error => toastMailUi(error.message || 'Could not save draft'));
|
|
||||||
closed = true;
|
closed = true;
|
||||||
}, true);
|
await pendingSave;
|
||||||
|
if (modal.dataset.draftId) await window.daybreakMail.deleteDraft(modal.dataset.draftId);
|
||||||
|
};
|
||||||
|
modal._deleteSavedDraft = deleteSavedDraft;
|
||||||
selectMailUi('#discard').onclick = async () => {
|
selectMailUi('#discard').onclick = async () => {
|
||||||
clearTimeout(saveTimer);
|
|
||||||
closed = true;
|
|
||||||
try {
|
try {
|
||||||
if (modal.dataset.draftId) await window.daybreakMail.deleteDraft(modal.dataset.draftId);
|
await deleteSavedDraft();
|
||||||
root.innerHTML = '';
|
root.innerHTML = '';
|
||||||
if (rendererState.activeFolder === 'Drafts') void syncMailbox(false);
|
if (rendererState.activeFolder === 'Drafts') void syncMailbox(false);
|
||||||
} catch (error) { toastMailUi(error.message || 'Could not delete draft'); }
|
} catch (error) { toastMailUi(error.message || 'Could not delete draft'); }
|
||||||
};
|
};
|
||||||
selectMailUi('#send').addEventListener('click', () => {
|
|
||||||
clearTimeout(saveTimer);
|
|
||||||
closed = true;
|
|
||||||
}, true);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1044,6 +1057,7 @@ if (window.daybreakMail) {
|
|||||||
text: selectMailUi('#compose-body').value,
|
text: selectMailUi('#compose-body').value,
|
||||||
attachments: selectMailUi('#modal-root .compose-modal')?._composeAttachments || [],
|
attachments: selectMailUi('#modal-root .compose-modal')?._composeAttachments || [],
|
||||||
displayName: mailFeatureState.connectedAccount.displayName || window.epMailFeatures.productivity?.profileName || '',
|
displayName: mailFeatureState.connectedAccount.displayName || window.epMailFeatures.productivity?.profileName || '',
|
||||||
|
...(selectMailUi('#modal-root .compose-modal')?._replyHeaders || {}),
|
||||||
...(pgp ? { pgp } : {})
|
...(pgp ? { pgp } : {})
|
||||||
});
|
});
|
||||||
if (result.failed) {
|
if (result.failed) {
|
||||||
@@ -1053,15 +1067,15 @@ if (window.daybreakMail) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (result.queued) {
|
if (result.queued) {
|
||||||
const draftId = selectMailUi('#modal-root .compose-modal')?.dataset.draftId;
|
const modal = selectMailUi('#modal-root .compose-modal');
|
||||||
if (draftId) await window.daybreakMail.deleteDraft(draftId);
|
if (modal?._deleteSavedDraft) await modal._deleteSavedDraft();
|
||||||
selectMailUi('#modal-root').innerHTML = '';
|
selectMailUi('#modal-root').innerHTML = '';
|
||||||
toastMailUi('Offline: message queued and will send when connected');
|
toastMailUi('Offline: message queued and will send when connected');
|
||||||
if (rendererState.activeFolder === 'Drafts') void syncMailbox(false);
|
if (rendererState.activeFolder === 'Drafts') void syncMailbox(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const draftId = selectMailUi('#modal-root .compose-modal')?.dataset.draftId;
|
const modal = selectMailUi('#modal-root .compose-modal');
|
||||||
if (draftId) await window.daybreakMail.deleteDraft(draftId);
|
if (modal?._deleteSavedDraft) await modal._deleteSavedDraft();
|
||||||
selectMailUi('#modal-root').innerHTML = '';
|
selectMailUi('#modal-root').innerHTML = '';
|
||||||
toastMailUi(result.savedToSent ? 'Message sent and saved in Sent' : 'Message sent, but its Sent copy could not be saved');
|
toastMailUi(result.savedToSent ? 'Message sent and saved in Sent' : 'Message sent, but its Sent copy could not be saved');
|
||||||
if (rendererState.activeFolder === 'Sent') syncMailbox(false, { offset: 0 });
|
if (rendererState.activeFolder === 'Sent') syncMailbox(false, { offset: 0 });
|
||||||
|
|||||||
+2
-2
@@ -158,8 +158,8 @@ pgpMailUi.wrapOpenMessage(baseOpenMessage => function (id) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Compose: encrypt/sign options.
|
// Compose: encrypt/sign options.
|
||||||
pgpMailUi.wrapShowCompose(baseShowCompose => function (reply, forward = false) {
|
pgpMailUi.wrapShowCompose(baseShowCompose => function (reply, forward = false, draft = null) {
|
||||||
baseShowCompose(reply, forward);
|
baseShowCompose(reply, forward, draft);
|
||||||
const footer = selectPgpMailUi('#modal-root .compose-footer');
|
const footer = selectPgpMailUi('#modal-root .compose-footer');
|
||||||
if (!footer || !pgpApi()) return;
|
if (!footer || !pgpApi()) return;
|
||||||
const box = document.createElement('div');
|
const box = document.createElement('div');
|
||||||
|
|||||||
+22
-24
@@ -19,9 +19,7 @@ function openEncryptionKeys() {
|
|||||||
const root = selectPgpKeyUi('#modal-root');
|
const root = selectPgpKeyUi('#modal-root');
|
||||||
const account = window.epMailFeatures.mail.connectedAccount || {};
|
const account = window.epMailFeatures.mail.connectedAccount || {};
|
||||||
const androidPgp = window.daybreakMail?.pgp?.platform === 'android';
|
const androidPgp = window.daybreakMail?.pgp?.platform === 'android';
|
||||||
const serverSettings = androidPgp
|
const serverSettings = `<h3 class="pgp-heading">Public key servers</h3>
|
||||||
? '<h3 class="pgp-heading">Public key servers</h3><p class="account-note">Key-server lookup and publication are disabled in Android testing. Import a public key directly and compare its fingerprint with the owner.</p><div hidden><div id="pgp-server-list"></div><input id="pgp-search-email"><button id="pgp-find-key"></button><div id="pgp-found-keys"></div><select id="pgp-publish-server"></select><input id="pgp-server-name"><input id="pgp-server-url"><select id="pgp-server-protocol"></select><button id="pgp-add-server"></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>
|
<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>
|
<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="${escapePgpKeyUi(account.email || '')}"></label>
|
<label class="compose-line"><span>Email address</span><input id="pgp-search-email" type="email" value="${escapePgpKeyUi(account.email || '')}"></label>
|
||||||
@@ -34,7 +32,7 @@ function openEncryptionKeys() {
|
|||||||
<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>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>
|
<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>`;
|
<div class="pgp-actions"><button class="discard" id="pgp-add-server">Add custom server…</button></div>`;
|
||||||
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 pgp-keys-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">${androidPgp ? 'EXPERIMENTAL ANDROID TESTING — not independently security reviewed. Private keys remain passphrase-protected inside the encrypted Android vault. Optional biometric unlock stores the passphrase in a Keystore key requiring user authentication. Back up your private key and revocation certificate: without them, encrypted mail cannot be recovered.' : '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">${androidPgp ? 'EXPERIMENTAL ANDROID TESTING — not independently security reviewed. Private keys remain passphrase-protected inside the encrypted Android vault. Optional biometric unlock stores the passphrase in a Keystore key requiring user authentication. Back up your private key and revocation certificate: without them, encrypted mail cannot be recovered.' : '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>
|
<h3 class="pgp-heading">Change a key passphrase</h3>
|
||||||
@@ -54,7 +52,7 @@ function openEncryptionKeys() {
|
|||||||
<label class="compose-line"><span>Name</span><input id="pgp-name" maxlength="100" value="${escapePgpKeyUi(account.displayName || '')}"></label>
|
<label class="compose-line"><span>Name</span><input id="pgp-name" maxlength="100" value="${escapePgpKeyUi(account.displayName || '')}"></label>
|
||||||
<label class="compose-line"><span>Email</span><input id="pgp-email" type="email" value="${escapePgpKeyUi(account.email || '')}"></label>
|
<label class="compose-line"><span>Email</span><input id="pgp-email" type="email" value="${escapePgpKeyUi(account.email || '')}"></label>
|
||||||
<label class="compose-line"><span>Passphrase</span><input id="pgp-passphrase" type="password" autocomplete="new-password" placeholder="At least 8 characters"></label>
|
<label class="compose-line"><span>Passphrase</span><input id="pgp-passphrase" type="password" autocomplete="new-password" placeholder="At least 8 characters"></label>
|
||||||
<div class="pgp-actions"><button class="send-button" id="pgp-generate">Create key</button><button class="discard" id="pgp-import">Import private key…</button></div>
|
<div class="pgp-actions"><button class="send-button" id="pgp-generate">Create key</button><button class="discard" id="pgp-import">${androidPgp ? 'Import private key from file…' : 'Import private key…'}</button>${androidPgp ? '<button class="discard" id="pgp-import-paste">Paste private key…</button>' : ''}</div>
|
||||||
<p class="account-note" id="pgp-status" role="status"></p>
|
<p class="account-note" id="pgp-status" role="status"></p>
|
||||||
</div></div></div>`;
|
</div></div></div>`;
|
||||||
const close = () => { root.innerHTML = ''; };
|
const close = () => { root.innerHTML = ''; };
|
||||||
@@ -231,15 +229,17 @@ function openEncryptionKeys() {
|
|||||||
} catch (error) { status(error.message || 'Could not create the key.'); }
|
} catch (error) { status(error.message || 'Could not create the key.'); }
|
||||||
button.disabled = false;
|
button.disabled = false;
|
||||||
};
|
};
|
||||||
selectPgpKeyUi('#pgp-import').onclick = async () => {
|
const importPrivateKey = async source => {
|
||||||
const passphrase = needPassphrase();
|
const passphrase = needPassphrase();
|
||||||
if (!passphrase) return;
|
if (!passphrase) return;
|
||||||
try {
|
try {
|
||||||
const result = await window.daybreakMail.pgp.importKey({ passphrase, accountId: account.id || null });
|
const result = await window.daybreakMail.pgp.importKey({ passphrase, accountId: account.id || null, ...(androidPgp ? { source } : {}) });
|
||||||
status(result.canceled ? '' : result.keyChangedFrom?.length ? 'Key imported. You already have a different key for this address; compare fingerprints before trusting either key.' : 'Key imported.');
|
status(result.canceled ? '' : result.keyChangedFrom?.length ? 'Key imported. You already have a different key for this address; compare fingerprints before trusting either key.' : 'Key imported.');
|
||||||
await render();
|
if (!result.canceled) await render();
|
||||||
} catch (error) { status(error.message || 'Could not import the key.'); }
|
} catch (error) { status(error.message || 'Could not import the key.'); }
|
||||||
};
|
};
|
||||||
|
selectPgpKeyUi('#pgp-import').onclick = () => importPrivateKey(androidPgp ? 'file' : undefined);
|
||||||
|
if (androidPgp) selectPgpKeyUi('#pgp-import-paste').onclick = () => importPrivateKey('paste');
|
||||||
async function renderContacts() {
|
async function renderContacts() {
|
||||||
const list = selectPgpKeyUi('#pgp-contact-list');
|
const list = selectPgpKeyUi('#pgp-contact-list');
|
||||||
let contacts = [];
|
let contacts = [];
|
||||||
@@ -359,19 +359,17 @@ function openEncryptionKeys() {
|
|||||||
};
|
};
|
||||||
enabledLabel.append(enabledText, enabled);
|
enabledLabel.append(enabledText, enabled);
|
||||||
row.append(info, enabledLabel);
|
row.append(info, enabledLabel);
|
||||||
if (!server.builtin) {
|
const remove = document.createElement('button');
|
||||||
const remove = document.createElement('button');
|
remove.className = 'discard';
|
||||||
remove.className = 'discard';
|
remove.textContent = 'Remove';
|
||||||
remove.textContent = 'Remove';
|
remove.onclick = async () => {
|
||||||
remove.onclick = async () => {
|
try {
|
||||||
try {
|
await window.daybreakMail.pgp.removeKeyServer(server.id);
|
||||||
await window.daybreakMail.pgp.removeKeyServer(server.id);
|
await renderKeyServers();
|
||||||
await renderKeyServers();
|
status(`${server.name} removed.`);
|
||||||
status('Custom key server removed.');
|
} catch (error) { status(error.message || 'Could not remove the key server.'); }
|
||||||
} catch (error) { status(error.message || 'Could not remove the key server.'); }
|
};
|
||||||
};
|
row.append(remove);
|
||||||
row.append(remove);
|
|
||||||
}
|
|
||||||
list.append(row);
|
list.append(row);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -451,13 +449,13 @@ function openEncryptionKeys() {
|
|||||||
catch (error) { status(error.message || 'Could not save the setting.'); }
|
catch (error) { status(error.message || 'Could not save the setting.'); }
|
||||||
};
|
};
|
||||||
selectPgpKeyUi('#pgp-forget').onclick = async () => { await window.daybreakMail.pgp.forgetPassphrases(); status('Remembered passphrases were cleared.'); };
|
selectPgpKeyUi('#pgp-forget').onclick = async () => { await window.daybreakMail.pgp.forgetPassphrases(); status('Remembered passphrases were cleared.'); };
|
||||||
if (!androidPgp) void renderKeyServers();
|
void renderKeyServers();
|
||||||
void renderContacts();
|
void renderContacts();
|
||||||
void render();
|
void render();
|
||||||
}
|
}
|
||||||
|
|
||||||
window.epMailFeatures.productivity.wrapOpenPreferences(baseOpenPreferences => function () {
|
window.epMailFeatures.productivity.wrapOpenPreferences(baseOpenPreferences => async function () {
|
||||||
baseOpenPreferences();
|
await baseOpenPreferences();
|
||||||
const fields = selectPgpKeyUi('#modal-root .compose-fields');
|
const fields = selectPgpKeyUi('#modal-root .compose-fields');
|
||||||
if (!fields || !pgpAvailable()) return;
|
if (!fields || !pgpAvailable()) return;
|
||||||
const button = document.createElement('button');
|
const button = document.createElement('button');
|
||||||
|
|||||||
+5725
-5094
File diff suppressed because one or more lines are too long
+1
-1
@@ -59,7 +59,7 @@ function renderLabels(){const box=selectProductivityUi('#custom-labels');if(!box
|
|||||||
function addCustomLabel(){const label=prompt('Name this label');if(!label?.trim())return;const clean=label.trim();if(customLabels.some(x=>x.toLowerCase()===clean.toLowerCase())){toastProductivityUi('That label already exists');return}customLabels.push(clean);productWrite(productKeys.labels,customLabels);renderLabels();toastProductivityUi('Label added')}
|
function addCustomLabel(){const label=prompt('Name this label');if(!label?.trim())return;const clean=label.trim();if(customLabels.some(x=>x.toLowerCase()===clean.toLowerCase())){toastProductivityUi('That label already exists');return}customLabels.push(clean);productWrite(productKeys.labels,customLabels);renderLabels();toastProductivityUi('Label added')}
|
||||||
function messageAction(message,action){if(productivityMailUi.connectedAccount&&window.daybreakMail&&message.uid){return window.daybreakMail.updateMessage({uid:message.uid,folder:message.sourceFolder||productivityMailUi.state.activeFolder,action,enabled:action==='star'?!message.star:true}).then(result=>{if(result?.queued)toastProductivityUi('Offline: action queued and will sync when connected');return result})}return Promise.resolve()}
|
function messageAction(message,action){if(productivityMailUi.connectedAccount&&window.daybreakMail&&message.uid){return window.daybreakMail.updateMessage({uid:message.uid,folder:message.sourceFolder||productivityMailUi.state.activeFolder,action,enabled:action==='star'?!message.star:true}).then(result=>{if(result?.queued)toastProductivityUi('Offline: action queued and will sync when connected');return result})}return Promise.resolve()}
|
||||||
async function actOnSelected(action){const selected=productivityMailUi.state.messages.filter(m=>productivityMailUi.state.selectedIds.has(m.id));if(!selected.length){toastProductivityUi('Select one or more messages first');return}try{for(const m of selected)await messageAction(m,action);if(action==='archive'||action==='delete')selected.forEach(m=>{m[action==='archive'?'archived':'deleted']=true});if(action==='unread')selected.forEach(m=>m.unread=true);productivityMailUi.state.selectedIds.clear();productivityMailUi.renderList();if(action==='archive'||action==='delete')selectProductivityUi('#reader-pane').innerHTML=productivityMailUi.emptyReader();toastProductivityUi(action==='archive'?'Messages archived':action==='delete'?'Messages moved to Trash':'Messages marked unread')}catch(e){toastProductivityUi(e.message||'Could not update messages')}}
|
async function actOnSelected(action){const selected=productivityMailUi.state.messages.filter(m=>productivityMailUi.state.selectedIds.has(m.id));if(!selected.length){toastProductivityUi('Select one or more messages first');return}try{for(const m of selected)await messageAction(m,action);if(action==='archive'||action==='delete')selected.forEach(m=>{m[action==='archive'?'archived':'deleted']=true});if(action==='unread')selected.forEach(m=>m.unread=true);productivityMailUi.state.selectedIds.clear();productivityMailUi.renderList();if(action==='archive'||action==='delete')selectProductivityUi('#reader-pane').innerHTML=productivityMailUi.emptyReader();toastProductivityUi(action==='archive'?'Messages archived':action==='delete'?'Messages moved to Trash':'Messages marked unread')}catch(e){toastProductivityUi(e.message||'Could not update messages')}}
|
||||||
document.addEventListener('DOMContentLoaded',()=>{setProfileName(profileSettings.name);renderLabels();selectAllProductivityUi('.profile-button').forEach(b=>b.onclick=openAccountSettings);selectProductivityUi('#settings-button').onclick=openPreferences;selectProductivityUi('#add-label').onclick=addCustomLabel;selectProductivityUi('#sidebar-menu').onclick=()=>{const choice=prompt('Mailbox options: enter “refresh†to sync, or “account†to manage your mailbox.');if(choice?.toLowerCase()==='account')productivityMailUi.openMailAccount();else if(choice?.toLowerCase()==='refresh')productivityMailUi.syncMailbox(true)};selectProductivityUi('.help-button').onclick=()=>{const root=selectProductivityUi('#modal-root');root.innerHTML='<div class="modal-overlay"><div class="compose-modal"><div class="modal-head"><span>ep-mail help</span><button class="modal-close">×</button></div><div class="compose-fields"><p>Use the left rail to switch between Mail, Calendar, and Contacts. Select mail with the checkboxes for bulk actions. Calendar events and contacts are saved on this device.</p></div><div class="compose-footer"><span></span><button class="send-button modal-close">Got it</button></div></div></div>';selectAllProductivityUi('.modal-close').forEach(b=>b.onclick=()=>root.innerHTML='')};selectProductivityUi('#select-all').onclick=()=>{const rows=selectAllProductivityUi('.message');const ids=rows.map(r=>Number(r.dataset.id));const all=ids.length&&ids.every(id=>productivityMailUi.state.selectedIds.has(id));ids.forEach(id=>all?productivityMailUi.state.selectedIds.delete(id):productivityMailUi.state.selectedIds.add(id));productivityMailUi.renderList()};selectProductivityUi('#archive-selected').onclick=()=>actOnSelected('archive');selectProductivityUi('#delete-selected').onclick=()=>actOnSelected('delete');selectProductivityUi('#mark-unread').onclick=()=>actOnSelected('unread');document.addEventListener('click',e=>{const more=e.target.closest('.reader-tools button[title="More"]');if(more){const m=productivityMailUi.state.messages.find(x=>x.id===productivityMailUi.state.activeMessage);if(!m)return;const choice=prompt('Message actions: unread, snooze, label, inbox');if(choice==='unread')messageAction(m,'unread').then(()=>{m.unread=true;productivityMailUi.renderList();toastProductivityUi('Marked unread')});else if(choice==='snooze'){snoozedIds=[...new Set([...snoozedIds,m.id])];productWrite(productKeys.snoozed,snoozedIds);toastProductivityUi('Message snoozed')}else if(choice==='label')addMessageLabel(m);else if(choice==='inbox'){m.archived=false;productivityMailUi.renderList();toastProductivityUi('Moved to Inbox')}e.stopImmediatePropagation();return}const readerAction=e.target.closest('#reader-archive,#reader-delete,#reader-star');if(readerAction){const m=productivityMailUi.state.messages.find(x=>x.id===productivityMailUi.state.activeMessage);if(!m)return;e.stopImmediatePropagation();const action=readerAction.id==='reader-archive'?'archive':readerAction.id==='reader-delete'?'delete':'star';messageAction(m,action).then(()=>{if(action==='star')m.star=!m.star;else m[action==='archive'?'archived':'deleted']=true;if(action==='star'){productivityMailUi.renderList();openMessage(m.id)}else{productivityMailUi.renderList();selectProductivityUi('#reader-pane').innerHTML=productivityMailUi.emptyReader();toastProductivityUi(action==='archive'?'Moved to Archive':'Moved to Trash')}}).catch(x=>toastProductivityUi(x.message));return}const star=e.target.closest('.star');if(star){const m=productivityMailUi.state.messages.find(x=>x.id===Number(star.closest('.message').dataset.id));if(m){e.stopImmediatePropagation();messageAction(m,'star').then(()=>{m.star=!m.star;productivityMailUi.renderList()}).catch(x=>toastProductivityUi(x.message))}}const row=e.target.closest('.message');if(row&&!e.target.closest('button,input')){const m=productivityMailUi.state.messages.find(x=>x.id===Number(row.dataset.id));if(m&&productivityMailUi.connectedAccount&&m.uid)window.daybreakMail.updateMessage({uid:m.uid,folder:productivityMailUi.state.activeFolder,action:'unread',enabled:false}).catch(()=>{})}},{capture:true});selectProductivityUi('#load-more').textContent='Load more ↓';});
|
document.addEventListener('DOMContentLoaded',()=>{setProfileName(profileSettings.name);renderLabels();selectAllProductivityUi('.profile-button').forEach(b=>b.onclick=openAccountSettings);selectProductivityUi('#settings-button').onclick=openPreferences;selectProductivityUi('#add-label').onclick=addCustomLabel;selectProductivityUi('#sidebar-menu').onclick=()=>{const choice=prompt('Mailbox options: enter “refresh†to sync, or “account†to manage your mailbox.');if(choice?.toLowerCase()==='account')productivityMailUi.openMailAccount();else if(choice?.toLowerCase()==='refresh')productivityMailUi.syncMailbox(true)};selectProductivityUi('.help-button').onclick=()=>{const root=selectProductivityUi('#modal-root');root.innerHTML='<div class="modal-overlay"><div class="compose-modal"><div class="modal-head"><span>ep-mail help</span><button class="modal-close">×</button></div><div class="compose-fields"><p>Use the left rail to switch between Mail, Calendar, and Contacts. Select mail with the checkboxes for bulk actions. Calendar events and contacts are saved on this device.</p></div><div class="compose-footer"><span></span><button class="send-button modal-close">Got it</button></div></div></div>';selectAllProductivityUi('.modal-close').forEach(b=>b.onclick=()=>root.innerHTML='')};selectProductivityUi('#select-all').onclick=()=>{const rows=selectAllProductivityUi('.message').filter(row=>!row.closest('[hidden]'));const ids=rows.map(r=>Number(r.dataset.id));const all=ids.length&&ids.every(id=>productivityMailUi.state.selectedIds.has(id));ids.forEach(id=>all?productivityMailUi.state.selectedIds.delete(id):productivityMailUi.state.selectedIds.add(id));productivityMailUi.renderList()};selectProductivityUi('#archive-selected').onclick=()=>actOnSelected('archive');selectProductivityUi('#delete-selected').onclick=()=>actOnSelected('delete');selectProductivityUi('#mark-unread').onclick=()=>actOnSelected('unread');document.addEventListener('click',e=>{const more=e.target.closest('.reader-tools button[title="More"]');if(more){const m=productivityMailUi.state.messages.find(x=>x.id===productivityMailUi.state.activeMessage);if(!m)return;const choice=prompt('Message actions: unread, snooze, label, inbox');if(choice==='unread')messageAction(m,'unread').then(()=>{m.unread=true;productivityMailUi.renderList();toastProductivityUi('Marked unread')});else if(choice==='snooze'){snoozedIds=[...new Set([...snoozedIds,m.id])];productWrite(productKeys.snoozed,snoozedIds);toastProductivityUi('Message snoozed')}else if(choice==='label')addMessageLabel(m);else if(choice==='inbox'){m.archived=false;productivityMailUi.renderList();toastProductivityUi('Moved to Inbox')}e.stopImmediatePropagation();return}const readerAction=e.target.closest('#reader-archive,#reader-delete,#reader-star');if(readerAction){const m=productivityMailUi.state.messages.find(x=>x.id===productivityMailUi.state.activeMessage);if(!m)return;e.stopImmediatePropagation();const action=readerAction.id==='reader-archive'?'archive':readerAction.id==='reader-delete'?'delete':'star';messageAction(m,action).then(()=>{if(action==='star')m.star=!m.star;else m[action==='archive'?'archived':'deleted']=true;if(action==='star'){productivityMailUi.renderList();openMessage(m.id)}else{productivityMailUi.renderList();selectProductivityUi('#reader-pane').innerHTML=productivityMailUi.emptyReader();toastProductivityUi(action==='archive'?'Moved to Archive':'Moved to Trash')}}).catch(x=>toastProductivityUi(x.message));return}const star=e.target.closest('.star');if(star){const m=productivityMailUi.state.messages.find(x=>x.id===Number(star.closest('.message').dataset.id));if(m){e.stopImmediatePropagation();messageAction(m,'star').then(()=>{m.star=!m.star;productivityMailUi.renderList()}).catch(x=>toastProductivityUi(x.message))}}const row=e.target.closest('.message');if(row&&!e.target.closest('button,input')){const m=productivityMailUi.state.messages.find(x=>x.id===Number(row.dataset.id));if(m&&productivityMailUi.connectedAccount&&m.uid)window.daybreakMail.updateMessage({uid:m.uid,folder:productivityMailUi.state.activeFolder,action:'unread',enabled:false}).catch(()=>{})}},{capture:true});selectProductivityUi('#load-more').textContent='Load more ↓';});
|
||||||
function addMessageLabel(m){const options=['Design','Travel','Personal',...customLabels];const label=prompt(`Add a label (${options.join(', ')})`);if(!label)return;m.tags=[...new Set([...(m.tags||[]),label])];productWrite(`daybreak-message-labels-${m.id}`,m.tags);toastProductivityUi(`Labeled ${label}`);productivityMailUi.renderList()}
|
function addMessageLabel(m){const options=['Design','Travel','Personal',...customLabels];const label=prompt(`Add a label (${options.join(', ')})`);if(!label)return;m.tags=[...new Set([...(m.tags||[]),label])];productWrite(`daybreak-message-labels-${m.id}`,m.tags);toastProductivityUi(`Labeled ${label}`);productivityMailUi.renderList()}
|
||||||
productivityMailUi.wrapRenderList(baseMessageRenderer => function () {
|
productivityMailUi.wrapRenderList(baseMessageRenderer => function () {
|
||||||
const state = productivityMailUi.state;
|
const state = productivityMailUi.state;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
const CACHE='ep-mail-v22';
|
const CACHE='ep-mail-v23';
|
||||||
const FILES=['./','./index.html','./styles.css','./branding.css','./renderer-state.js','./mail-content-security.js','./renderer-mail-api.js','./app.js','./platform-bridge-loader.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','./renderer-state.js','./conversation-threads.js','./mail-content-security.js','./renderer-mail-api.js','./app.js','./platform-bridge-loader.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)).then(()=>self.skipWaiting())));
|
self.addEventListener('install',event=>event.waitUntil(caches.open(CACHE).then(cache=>cache.addAll(FILES)).then(()=>self.skipWaiting())));
|
||||||
self.addEventListener('activate',event=>event.waitUntil(caches.keys().then(keys=>Promise.all(keys.filter(k=>k!==CACHE).map(k=>caches.delete(k)))).then(()=>self.clients.claim())));
|
self.addEventListener('activate',event=>event.waitUntil(caches.keys().then(keys=>Promise.all(keys.filter(k=>k!==CACHE).map(k=>caches.delete(k)))).then(()=>self.clients.claim())));
|
||||||
self.addEventListener('fetch', event => {
|
self.addEventListener('fetch', event => {
|
||||||
|
|||||||
+49
-39
@@ -65,43 +65,53 @@ document.addEventListener('keydown', event => {
|
|||||||
action.run();
|
action.run();
|
||||||
});
|
});
|
||||||
|
|
||||||
shortcutProductivityUi.wrapOpenPreferences(baseOpenPreferences => function () {
|
function openShortcutSettings() {
|
||||||
baseOpenPreferences();
|
const root = selectShortcutUi('#modal-root');
|
||||||
const fields = selectShortcutUi('#modal-root .compose-fields');
|
const shortcuts = loadShortcuts();
|
||||||
const save = selectShortcutUi('#save-appearance');
|
root.innerHTML = `<div class="modal-overlay"><div class="compose-modal"><div class="modal-head"><span>Keyboard shortcuts</span><button class="modal-close" aria-label="Close">×</button></div><div class="compose-fields"><p class="account-note">Type a key or combination such as <code>c</code>, <code>Ctrl+Enter</code> or <code>Alt+n</code>. Leave blank to disable. Shortcuts are inactive while typing or in dialogs.</p>${shortcutActions.map(action =>
|
||||||
if (!fields || !save) return;
|
`<label class="compose-line"><span>${action.label}</span><input class="shortcut-input" data-action="${action.id}" maxlength="24" value="${escapeShortcutUi(shortcuts[action.id])}" placeholder="None"></label>`).join('')}<button type="button" class="discard" id="reset-shortcuts">Reset to defaults</button></div><div class="compose-footer"><button class="discard modal-close">Cancel</button><button class="send-button" id="save-shortcuts">Save shortcuts</button></div></div></div>`;
|
||||||
const shortcuts = loadShortcuts();
|
const close = () => { root.innerHTML = ''; };
|
||||||
const section = document.createElement('div');
|
root.querySelectorAll('.modal-close').forEach(button => { button.onclick = close; });
|
||||||
section.className = 'shortcut-settings';
|
selectShortcutUi('.modal-overlay').onclick = event => { if (event.target.classList.contains('modal-overlay')) close(); };
|
||||||
section.innerHTML = `<h3>Keyboard shortcuts</h3><p class="account-note">Type a key or combination such as <code>c</code>, <code>Ctrl+Enter</code> or <code>Alt+n</code>. Leave blank to disable. Shortcuts are inactive while typing or in dialogs.</p>${shortcutActions.map(action =>
|
const fields = selectShortcutUi('#modal-root .compose-fields');
|
||||||
`<label class="compose-line"><span>${action.label}</span><input class="shortcut-input" data-action="${action.id}" maxlength="24" value="${escapeShortcutUi(shortcuts[action.id])}" placeholder="None"></label>`).join('')}<button type="button" class="discard" id="reset-shortcuts">Reset to defaults</button>`;
|
fields.addEventListener('keydown', event => {
|
||||||
fields.append(section);
|
const input = event.target.closest('.shortcut-input');
|
||||||
section.addEventListener('keydown', event => {
|
if (!input || ['Tab', 'Escape'].includes(event.key)) return;
|
||||||
const input = event.target.closest('.shortcut-input');
|
event.preventDefault();
|
||||||
if (!input || ['Tab', 'Escape'].includes(event.key)) return;
|
if (['Backspace', 'Delete'].includes(event.key)) { input.value = ''; return; }
|
||||||
event.preventDefault();
|
const combo = eventShortcut(event);
|
||||||
if (['Backspace', 'Delete'].includes(event.key)) { input.value = ''; return; }
|
if (combo) input.value = combo;
|
||||||
const combo = eventShortcut(event);
|
|
||||||
if (combo) input.value = combo;
|
|
||||||
});
|
|
||||||
selectShortcutUi('#reset-shortcuts').onclick = () => {
|
|
||||||
section.querySelectorAll('.shortcut-input').forEach(input => {
|
|
||||||
input.value = shortcutActions.find(action => action.id === input.dataset.action).fallback;
|
|
||||||
});
|
|
||||||
};
|
|
||||||
const baseSave = save.onclick;
|
|
||||||
save.onclick = event => {
|
|
||||||
const values = {};
|
|
||||||
const used = new Map();
|
|
||||||
for (const input of section.querySelectorAll('.shortcut-input')) {
|
|
||||||
const value = normalizeShortcut(input.value);
|
|
||||||
const label = shortcutActions.find(action => action.id === input.dataset.action).label;
|
|
||||||
if (value && used.has(value)) { toastShortcutUi(`“${value}” is used by both ${used.get(value)} and ${label}`); return; }
|
|
||||||
if (value) used.set(value, label);
|
|
||||||
values[input.dataset.action] = value;
|
|
||||||
}
|
|
||||||
localStorage.setItem(shortcutStorageKey, JSON.stringify(values));
|
|
||||||
baseSave?.call(save, event);
|
|
||||||
};
|
|
||||||
});
|
});
|
||||||
})();
|
selectShortcutUi('#reset-shortcuts').onclick = () => {
|
||||||
|
fields.querySelectorAll('.shortcut-input').forEach(input => {
|
||||||
|
input.value = shortcutActions.find(action => action.id === input.dataset.action).fallback;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
selectShortcutUi('#save-shortcuts').onclick = () => {
|
||||||
|
const values = {};
|
||||||
|
const used = new Map();
|
||||||
|
for (const input of fields.querySelectorAll('.shortcut-input')) {
|
||||||
|
const value = normalizeShortcut(input.value);
|
||||||
|
const label = shortcutActions.find(action => action.id === input.dataset.action).label;
|
||||||
|
if (value && used.has(value)) { toastShortcutUi(`“${value}” is used by both ${used.get(value)} and ${label}`); return; }
|
||||||
|
if (value) used.set(value, label);
|
||||||
|
values[input.dataset.action] = value;
|
||||||
|
}
|
||||||
|
localStorage.setItem(shortcutStorageKey, JSON.stringify(values));
|
||||||
|
close();
|
||||||
|
toastShortcutUi('Keyboard shortcuts saved');
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
shortcutProductivityUi.wrapOpenPreferences(baseOpenPreferences => async function () {
|
||||||
|
await baseOpenPreferences();
|
||||||
|
const fields = selectShortcutUi('#modal-root .compose-fields');
|
||||||
|
if (!fields || !selectShortcutUi('#save-appearance')) return;
|
||||||
|
const button = document.createElement('button');
|
||||||
|
button.type = 'button';
|
||||||
|
button.className = 'discard';
|
||||||
|
button.id = 'open-keyboard-shortcuts';
|
||||||
|
button.textContent = 'Keyboard shortcuts…';
|
||||||
|
button.onclick = openShortcutSettings;
|
||||||
|
fields.append(button);
|
||||||
|
});})();
|
||||||
|
|||||||
+10
-4
@@ -114,7 +114,7 @@ body.ep-daylight .compose-line input::placeholder,body.ep-daylight .compose-body
|
|||||||
body.ep-daylight .modal-close,body.ep-daylight .discard{color:#59706b}
|
body.ep-daylight .modal-close,body.ep-daylight .discard{color:#59706b}
|
||||||
body.ep-daylight .toast{background:#11212b;color:#f1f1e9}
|
body.ep-daylight .toast{background:#11212b;color:#f1f1e9}
|
||||||
body.ep-daylight .row-check:checked{accent-color:#526a2c}
|
body.ep-daylight .row-check:checked{accent-color:#526a2c}
|
||||||
.compose-modal{max-height:90vh;display:flex;flex-direction:column}.compose-fields{min-height:0;flex:1 1 auto;overflow-y:auto}
|
.compose-modal{max-height:90vh;display:flex;flex-direction:column}.compose-modal>.modal-head,.compose-modal>.compose-footer{flex:none}.compose-fields{min-height:0;flex:0 1 auto;overflow-y:auto}.compose-modal>.compose-body{flex:1 1 120px;min-height:90px;height:auto}
|
||||||
.snooze-options .outline-button{width:100%;text-align:left}
|
.snooze-options .outline-button{width:100%;text-align:left}
|
||||||
.mail-rules{padding:10px 0;border-bottom:1px solid var(--line)}.mail-rule-row{display:grid;grid-template-columns:1fr 1fr 120px 1fr auto;gap:6px;align-items:center;padding:5px 0}.mail-rule-row input,.mail-rule-row select{box-sizing:border-box;min-width:0;width:100%;padding:7px;border:1px solid var(--line);border-radius:5px;background:var(--panel);color:var(--text);font-size:10px}.mail-rule-row input:disabled{opacity:.55}.mail-rule-row .discard{white-space:nowrap}
|
.mail-rules{padding:10px 0;border-bottom:1px solid var(--line)}.mail-rule-row{display:grid;grid-template-columns:1fr 1fr 120px 1fr auto;gap:6px;align-items:center;padding:5px 0}.mail-rule-row input,.mail-rule-row select{box-sizing:border-box;min-width:0;width:100%;padding:7px;border:1px solid var(--line);border-radius:5px;background:var(--panel);color:var(--text);font-size:10px}.mail-rule-row input:disabled{opacity:.55}.mail-rule-row .discard{white-space:nowrap}
|
||||||
@media(max-width:650px){.mail-rule-row{grid-template-columns:1fr 1fr}.mail-rule-row .mail-rule-action,.mail-rule-row .mail-rule-value{grid-column:auto}}
|
@media(max-width:650px){.mail-rule-row{grid-template-columns:1fr 1fr}.mail-rule-row .mail-rule-action,.mail-rule-row .mail-rule-value{grid-column:auto}}
|
||||||
@@ -126,9 +126,10 @@ body.ep-daylight .row-check:checked{accent-color:#526a2c}
|
|||||||
body.ep-daylight .mail-safety-warning{background:#fff6df;color:#5b3c17}body.ep-daylight .mail-link-risky{background:#fff8ea;border-color:#d69b43}
|
body.ep-daylight .mail-safety-warning{background:#fff6df;color:#5b3c17}body.ep-daylight .mail-link-risky{background:#fff8ea;border-color:#d69b43}
|
||||||
|
|
||||||
.folder-add{border:0;background:transparent;color:#929990;font-size:18px;cursor:pointer}.folder-add:hover{color:#487354}.section-label+.folder-nav:empty{display:none}.custom-folder span:last-child{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
.folder-add{border:0;background:transparent;color:#929990;font-size:18px;cursor:pointer}.folder-add:hover{color:#487354}.section-label+.folder-nav:empty{display:none}.custom-folder span:last-child{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
||||||
.shortcut-settings h3{margin:16px 0 4px;font-size:13px}.shortcut-settings code{font-family:monospace}.shortcut-input{text-transform:none}.shortcut-settings #reset-shortcuts{margin-top:8px}
|
.compose-fields code{font-family:monospace}.shortcut-input{text-transform:none}#reset-shortcuts{margin-top:8px}
|
||||||
.attachments-modal{width:min(720px,94vw)}.attachment-toolbar{display:flex;gap:8px;margin-bottom:10px}.attachment-toolbar input{flex:1}.attachment-list{max-height:60vh;overflow:auto;display:grid;gap:8px}.attachment-row{display:flex;flex-wrap:wrap;gap:8px;align-items:center;padding:8px;border:1px solid var(--line);border-radius:8px}.attachment-row-info{flex:1;min-width:0;display:flex;flex-direction:column;gap:2px}.attachment-row-info strong,.attachment-row-info small{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.attachment-preview{flex-basis:100%;max-height:320px;overflow:auto;padding:8px;font-size:12px}.attachment-preview-image{max-width:100%;max-height:300px;display:block}.attachment-preview-text{margin:0;white-space:pre-wrap;word-break:break-word}.preview-attachment{font-size:14px}
|
.attachments-modal{width:min(720px,94vw)}.attachment-toolbar{display:flex;gap:8px;margin-bottom:10px}.attachment-toolbar input{flex:1}.attachment-list{max-height:60vh;overflow:auto;display:grid;gap:8px}.attachment-row{display:flex;flex-wrap:wrap;gap:8px;align-items:center;padding:8px;border:1px solid var(--line);border-radius:8px}.attachment-row-info{flex:1;min-width:0;display:flex;flex-direction:column;gap:2px}.attachment-row-info strong,.attachment-row-info small{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.attachment-preview{flex-basis:100%;max-height:320px;overflow:auto;padding:8px;font-size:12px}.attachment-preview-image{max-width:100%;max-height:300px;display:block}.attachment-preview-text{margin:0;white-space:pre-wrap;word-break:break-word}.preview-attachment{font-size:14px}
|
||||||
.pgp-heading{margin:16px 0 4px;font-size:13px}.pgp-actions{display:flex;gap:8px;margin-top:8px}#open-encryption-keys{margin-top:12px}
|
.pgp-heading{margin:16px 0 4px;font-size:13px}.pgp-actions{display:flex;gap:8px;margin-top:8px}#open-encryption-keys{margin-top:12px}
|
||||||
|
.pgp-keys-modal .attachment-list{grid-template-columns:minmax(0,1fr)}.pgp-keys-modal .attachment-row{min-width:0}.pgp-keys-modal .attachment-row-info{flex:1 0 100%}.pgp-keys-modal .attachment-row-info strong,.pgp-keys-modal .attachment-row-info small{overflow:visible;text-overflow:clip;white-space:normal;overflow-wrap:anywhere}.pgp-keys-modal .attachment-row>button{max-width:100%;padding:8px;font-size:12px}.pgp-keys-modal .attachment-row>.compose-line{flex:1 1 180px;min-width:0}.pgp-keys-modal .pgp-trust{margin-left:0;max-width:100%}.pgp-keys-modal .pgp-actions{flex-wrap:wrap}
|
||||||
|
|
||||||
.pgp-prompt{z-index:2000}.pgp-prompt-box{max-width:420px}
|
.pgp-prompt{z-index:2000}.pgp-prompt-box{max-width:420px}
|
||||||
.pgp-status,.pgp-banner{display:flex;flex-direction:column;gap:2px;margin:10px 0;padding:10px 12px;border-radius:8px;border:1px solid var(--line,#c9d1c8);font-size:13px}
|
.pgp-status,.pgp-banner{display:flex;flex-direction:column;gap:2px;margin:10px 0;padding:10px 12px;border-radius:8px;border:1px solid var(--line,#c9d1c8);font-size:13px}
|
||||||
@@ -199,8 +200,10 @@ body.ep-daylight .row-check:checked{accent-color:#526a2c}
|
|||||||
.compose-line input[type=checkbox]{flex:0 0 auto;width:20px;height:20px}
|
.compose-line input[type=checkbox]{flex:0 0 auto;width:20px;height:20px}
|
||||||
.compose-line span{flex:0 1 54%;line-height:1.25}
|
.compose-line span{flex:0 1 54%;line-height:1.25}
|
||||||
.compose-line input:not([type=checkbox]){flex:1;max-width:100%;min-width:0}
|
.compose-line input:not([type=checkbox]){flex:1;max-width:100%;min-width:0}
|
||||||
.compose-footer{gap:8px;padding:10px 12px}
|
.compose-footer{gap:8px;padding:10px 12px;flex-wrap:wrap;justify-content:flex-end}
|
||||||
.compose-body{height:30vh;padding:12px}
|
.compose-footer .pgp-compose{flex:1 0 100%;flex-wrap:wrap;margin-right:0;gap:4px 12px}
|
||||||
|
.compose-footer .send-button{order:99;padding:10px 18px;font-size:12px}
|
||||||
|
.compose-body{padding:12px}
|
||||||
.account-note,.account-status{font-size:12px}
|
.account-note,.account-status{font-size:12px}
|
||||||
.mail-rule-row{grid-template-columns:1fr;gap:6px}
|
.mail-rule-row{grid-template-columns:1fr;gap:6px}
|
||||||
.mail-rule-row>*{grid-column:1}
|
.mail-rule-row>*{grid-column:1}
|
||||||
@@ -232,3 +235,6 @@ body.ep-daylight .row-check:checked{accent-color:#526a2c}
|
|||||||
.reader-pane{padding-bottom:10px}
|
.reader-pane{padding-bottom:10px}
|
||||||
}
|
}
|
||||||
@media(max-width:1000px),(max-height:500px) and (orientation:landscape) and (max-width:1200px){.sidebar{overflow:hidden}#mail-nav{display:flex;flex-direction:row;align-items:center;height:42px;min-height:0;max-height:42px;flex:none;overflow-x:auto;overflow-y:hidden;align-content:normal}#mail-nav .folder{height:34px;align-self:center}}
|
@media(max-width:1000px),(max-height:500px) and (orientation:landscape) and (max-width:1200px){.sidebar{overflow:hidden}#mail-nav{display:flex;flex-direction:row;align-items:center;height:42px;min-height:0;max-height:42px;flex:none;overflow-x:auto;overflow-y:hidden;align-content:normal}#mail-nav .folder{height:34px;align-self:center}}
|
||||||
|
.conversation-toggle{display:block;width:100%;padding:8px 12px;border:0;border-bottom:1px solid var(--border,#ddd);background:transparent;color:inherit;text-align:left;font:inherit;font-size:.8rem;font-weight:600;cursor:pointer}
|
||||||
|
.conversation-toggle:focus-visible{outline:2px solid currentColor;outline-offset:-2px}
|
||||||
|
.conversation-replies .message{padding-left:22px}
|
||||||
|
|||||||
Reference in New Issue
Block a user