From 790051f440205fb7fefb4e010ce25faf1789295f Mon Sep 17 00:00:00 2001 From: Tero Huttunen Date: Tue, 3 Nov 2026 07:32:34 +0200 Subject: [PATCH] Add Android security Phase 0 --- ANDROID_SECURITY_PLAN.md | 6 + ARCHITECTURE.md | 216 +- ENCRYPTION_PLAN.md | 200 +- README.md | 72 +- SECURITY_REVIEW.md | 96 +- TODO.md | 128 +- account-ui.js | 38 +- android/.gitignore | 202 +- android/app/.gitignore | 4 +- android/app/build.gradle | 157 +- android/app/proguard-rules.pro | 42 +- .../myapp/ExampleInstrumentedTest.java | 52 +- android/app/src/main/AndroidManifest.xml | 87 +- .../daybreak/mail/AndroidAccountVault.kt | 1080 +- .../studio/daybreak/mail/AndroidDavService.kt | 870 +- .../daybreak/mail/AndroidMailService.kt | 1665 +-- .../daybreak/mail/AttachmentNamePolicy.kt | 11 + .../java/studio/daybreak/mail/DavUrlPolicy.kt | 31 + .../java/studio/daybreak/mail/EpMailPlugin.kt | 1038 +- .../daybreak/mail/MailFallbackWorker.kt | 110 +- .../studio/daybreak/mail/MailIdleService.kt | 590 +- .../studio/daybreak/mail/MainActivity.java | 38 +- .../drawable-v24/ic_launcher_foreground.xml | 68 +- .../res/drawable/ic_launcher_background.xml | 340 +- .../app/src/main/res/layout/activity_main.xml | 24 +- .../res/mipmap-anydpi-v26/ic_launcher.xml | 8 +- .../mipmap-anydpi-v26/ic_launcher_round.xml | 8 +- .../res/values/ic_launcher_background.xml | 6 +- android/app/src/main/res/values/strings.xml | 14 +- android/app/src/main/res/values/styles.xml | 42 +- .../main/res/xml/data_extraction_rules.xml | 17 + android/app/src/main/res/xml/file_paths.xml | 5 - .../getcapacitor/myapp/ExampleUnitTest.java | 36 +- .../daybreak/mail/AttachmentNamePolicyTest.kt | 20 + .../studio/daybreak/mail/DavUrlPolicyTest.kt | 54 + android/build.gradle | 60 +- android/gradle.properties | 44 +- .../gradle/wrapper/gradle-wrapper.properties | 14 +- android/gradlew | 502 +- android/gradlew.bat | 188 +- android/settings.gradle | 8 +- android/variables.gradle | 30 +- app.js | 64 +- attachments.js | 292 +- branding.css | 60 +- capacitor.config.json | 16 +- dav-ui.js | 72 +- desktop/ipc/mail.cjs | 618 +- desktop/mail-attachments.cjs | 60 +- desktop/main.cjs | 664 +- desktop/pgp-keyservers.cjs | 554 +- desktop/pgp-keystore.cjs | 692 +- desktop/pgp-mail.cjs | 752 +- desktop/preload.cjs | 118 +- icon.svg | 20 +- index.html | 144 +- logo-ep-daylight.svg | 18 +- logo-ep-wasteland.svg | 18 +- mail-ui.js | 1472 +-- manifest.webmanifest | 20 +- package-lock.json | 10764 ++++++++-------- package.json | 221 +- pgp-mail-ui.js | 342 +- pgp-ui.js | 820 +- productivity.js | 90 +- scripts/android-bridge.js | 80 +- scripts/build-all.ps1 | 36 +- scripts/build-android-apk.cjs | 52 +- scripts/build-android-release-apk.cjs | 47 + scripts/prepare-android-web.cjs | 92 +- service-worker.js | 6 +- shortcuts.js | 180 +- snooze-ui.js | 244 +- styles.css | 286 +- tests/build-version.test.cjs | 13 + tests/mail-attachments.test.cjs | 76 +- tests/pgp-gnupg-interop.test.cjs | 208 +- tests/pgp-keyservers.test.cjs | 488 +- tests/pgp-keystore.test.cjs | 246 +- tests/pgp-mail.test.cjs | 432 +- www/account-ui.js | 38 +- www/app.js | 64 +- www/attachments.js | 292 +- www/branding.css | 60 +- www/dav-ui.js | 72 +- www/icon.svg | 20 +- www/index.html | 144 +- www/logo-ep-daylight.svg | 18 +- www/logo-ep-wasteland.svg | 18 +- www/mail-ui.js | 1472 +-- www/manifest.webmanifest | 20 +- www/pgp-mail-ui.js | 342 +- www/pgp-ui.js | 820 +- www/productivity.js | 90 +- www/service-worker.js | 6 +- www/shortcuts.js | 180 +- www/snooze-ui.js | 244 +- www/styles.css | 286 +- 98 files changed, 16497 insertions(+), 16287 deletions(-) create mode 100644 android/app/src/main/java/studio/daybreak/mail/AttachmentNamePolicy.kt create mode 100644 android/app/src/main/java/studio/daybreak/mail/DavUrlPolicy.kt create mode 100644 android/app/src/main/res/xml/data_extraction_rules.xml delete mode 100644 android/app/src/main/res/xml/file_paths.xml create mode 100644 android/app/src/test/java/studio/daybreak/mail/AttachmentNamePolicyTest.kt create mode 100644 android/app/src/test/java/studio/daybreak/mail/DavUrlPolicyTest.kt create mode 100644 scripts/build-android-release-apk.cjs diff --git a/ANDROID_SECURITY_PLAN.md b/ANDROID_SECURITY_PLAN.md index fb67785..f49fc45 100644 --- a/ANDROID_SECURITY_PLAN.md +++ b/ANDROID_SECURITY_PLAN.md @@ -4,6 +4,12 @@ Status: **Plan**. Android already has several useful protections, but it does no Related: [ENCRYPTION_PLAN.md](./ENCRYPTION_PLAN.md), [SECURITY_REVIEW.md](./SECURITY_REVIEW.md), and [TODO.md](./TODO.md). +## Implementation progress (2026-11-03) + +- Implemented: explicit Android cleartext denial and backup/data-extraction exclusions; removed the wildcard Cordova origin and unused broad `FileProvider`; DAV now requires HTTPS, rejects embedded credentials/fragments, stays on the configured origin, and does not follow redirects; saved attachment names are sanitized; notification previews and native logs no longer expose mailbox content; debug APKs are labeled as debug and signed release builds require environment-provided signing credentials. +- Tested: DAV URL policy and attachment-name policy have Android unit tests. The debug Android build and unit tests pass, as does the Node test suite. +- Still open: invalid-certificate integration tests, device-level review of the merged release APK, private notification preference UI, app lock/biometric unlock, full vault lifecycle testing, and Android OpenPGP. OpenPGP work remains gated on an independent cryptography/security review. + ## Goals and limits Protect account credentials and locally cached mail if app files are copied; prevent untrusted mail or renderer content from gaining native capabilities; protect message content in transit; give users control over sensitive previews and local unlock; and bring Android OpenPGP behavior up to the security guarantees already implemented on desktop. diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md index c97f01c..3bd37ba 100644 --- a/ARCHITECTURE.md +++ b/ARCHITECTURE.md @@ -1,119 +1,119 @@ -# Architecture - -This project has a layered architecture: a desktop Electron shell, a browser-rendered mail interface, platform-specific storage and sync adapters, and a separate Android Capacitor wrapper. The design keeps user state and credentials in the OS keyring, pushes IMAP/SMTP work into the main process, and exposes only a narrow IPC surface to the renderer. - -## 1. Runtime layout - -### Desktop shell - -- `desktop/main.cjs` is the privileged process. -- It owns account storage, mail sync, IMAP/SMTP connectivity, DAV sync, and OpenPGP key handling. -- It can show native dialogs, notifications, and system prompts. On Windows, its notification-area tray icon uses the packaged multi-resolution application icon and provides Open and Quit actions. Packaged startup repairs an existing per-user Start Menu shortcut to target the launched app and use its icon, keeping taskbar pins associated with the matching AppUserModelID. +# Architecture + +This project has a layered architecture: a desktop Electron shell, a browser-rendered mail interface, platform-specific storage and sync adapters, and a separate Android Capacitor wrapper. The design keeps user state and credentials in the OS keyring, pushes IMAP/SMTP work into the main process, and exposes only a narrow IPC surface to the renderer. + +## 1. Runtime layout + +### Desktop shell + +- `desktop/main.cjs` is the privileged process. +- It owns account storage, mail sync, IMAP/SMTP connectivity, DAV sync, and OpenPGP key handling. +- It can show native dialogs, notifications, and system prompts. On Windows, its notification-area tray icon uses the packaged multi-resolution application icon and provides Open and Quit actions. Packaged startup repairs an existing per-user Start Menu shortcut to target the launched app and use its icon, keeping taskbar pins associated with the matching AppUserModelID. - `desktop/preload.cjs` exposes the narrow platform API through `window.daybreakMail`. Renderer-to-renderer contracts are grouped under `window.epMailState`, `window.epMailShell`, and `window.epMailFeatures`. - -### Renderer UI - + +### Renderer UI + The browser UI is rendered from canonical web assets in the repository root; `www/` is generated for Capacitor: - `index.html` defines the classic-script bootstrap order. `renderer-state.js` exposes shared state as `window.epMailState` without legacy unnamespaced aliases. - `app.js` publishes `window.epMailShell`; the mail, productivity, DAV, and PGP mail modules publish explicit APIs under `window.epMailFeatures`. PGP key management extends the productivity Preferences UI through that API. - Renderer feature implementations are locally scoped. The ordered classic-script bootstrap remains a compatibility constraint for desktop and Capacitor, and is covered by bootstrap and combined-script tests. - The renderer is intentionally thin: it requests actions and displays data, while mail-protocol and cryptographic network work stays in the main process. The reader makes direct HTTPS image requests only after explicit per-message approval. - -### Android client - -The Android app reuses the web UI in a Capacitor shell (`android/`, `capacitor.config.json`). - -- The same browser UI runs inside the Android app. -- Native Android services handle background sync, notification behavior, and secure storage. -- The desktop and Android implementations intentionally share the same mail and account model so the feature surface stays aligned. - -## 2. Core responsibilities - -### Mail and account state - -The main process owns the canonical account model and persists it in an encrypted store: - + +### Android client + +The Android app reuses the web UI in a Capacitor shell (`android/`, `capacitor.config.json`). + +- The same browser UI runs inside the Android app. +- Native Android services handle background sync, notification behavior, and secure storage. +- The desktop and Android implementations intentionally share the same mail and account model so the feature surface stays aligned. + +## 2. Core responsibilities + +### Mail and account state + +The main process owns the canonical account model and persists it in an encrypted store: + - `mail-account.enc` stores connected IMAP/SMTP accounts, settings, and desktop OAuth tokens; OAuth refresh tokens never enter the renderer API. -- `dav-accounts.enc` stores CalDAV/CardDAV credentials and server config. -- `pgp-keys.enc` stores OpenPGP keys and trust data. - -All three stores are wrapped with Electron `safeStorage` where available. Linux checks explicitly reject the insecure `basic_text` backend before credentials or keys are persisted. - -### Mail sync pipeline - -The desktop app follows a background sync model: - -1. The renderer asks the main process for a folder sync or inbox refresh. -2. The main process opens an IMAP connection and fetches only the requested subset or page. -3. Sync results are written back into the account state and sent to the renderer via IPC (`mail:sync-update`). -4. Periodic background sync and IDLE watchers reduce polling and keep new-mail notifications timely. - -A generation counter invalidates stale sync jobs when accounts are edited or removed, and concurrent syncs are prevented to avoid overlapping IMAP traffic. - -### Message send path - -The send flow is also centralized in the main process: - -- the renderer calls the desktop `mail:send` IPC or the Android `EpMail.send` plugin with message fields and selected attachment bytes -- the native send path resolves the account, checks sender settings, builds multipart MIME, and on desktop applies OpenPGP encryption/signing to the body and attachments before sending -- the message is either transmitted immediately or queued as an offline send when connectivity is unavailable; local draft attachments are persisted with draft content - -The renderer sends file bytes rather than local paths. OpenPGP messages are encrypted before offline queueing so the outbox contains ciphertext instead of plaintext message or attachment content. - -## 3. Security boundary - -The current architecture takes a strict trust split: - -- renderer: UI, user interaction, local conveniences -- main process: network access, cryptographic operations, permission prompts, OS secure storage - -This boundary is important for encryption and safety checks: - +- `dav-accounts.enc` stores CalDAV/CardDAV credentials and server config. +- `pgp-keys.enc` stores OpenPGP keys and trust data. + +All three stores are wrapped with Electron `safeStorage` where available. Linux checks explicitly reject the insecure `basic_text` backend before credentials or keys are persisted. + +### Mail sync pipeline + +The desktop app follows a background sync model: + +1. The renderer asks the main process for a folder sync or inbox refresh. +2. The main process opens an IMAP connection and fetches only the requested subset or page. +3. Sync results are written back into the account state and sent to the renderer via IPC (`mail:sync-update`). +4. Periodic background sync and IDLE watchers reduce polling and keep new-mail notifications timely. + +A generation counter invalidates stale sync jobs when accounts are edited or removed, and concurrent syncs are prevented to avoid overlapping IMAP traffic. + +### Message send path + +The send flow is also centralized in the main process: + +- the renderer calls the desktop `mail:send` IPC or the Android `EpMail.send` plugin with message fields and selected attachment bytes +- the native send path resolves the account, checks sender settings, builds multipart MIME, and on desktop applies OpenPGP encryption/signing to the body and attachments before sending +- the message is either transmitted immediately or queued as an offline send when connectivity is unavailable; local draft attachments are persisted with draft content + +The renderer sends file bytes rather than local paths. OpenPGP messages are encrypted before offline queueing so the outbox contains ciphertext instead of plaintext message or attachment content. + +## 3. Security boundary + +The current architecture takes a strict trust split: + +- renderer: UI, user interaction, local conveniences +- main process: network access, cryptographic operations, permission prompts, OS secure storage + +This boundary is important for encryption and safety checks: + - OpenPGP key selection and trust updates are confirmed in the main process. - Replacement-key operations are also confirmed in the main process; tests assert cancellation does not update the contact key. -- Key-server lookup results never elevate trust; only the public key is sent during a separately confirmed publication. -- Send-time downgrade checks happen in the main process rather than only in UI logic. -- External links open only after a native confirmation dialog. -- Incoming HTML is sanitized in the renderer before insertion. HTTPS image URLs are kept in inert data attributes; only a per-message user action assigns image sources, and reopening the message resets that approval. HTTP images are rejected to preserve Android's cleartext-traffic protection. The CSP allows HTTPS images; scripts, frames, forms, and remote connections remain blocked. -- Credentials and private keys are stored with the OS keyring, not in plain JSON files. - -## 4. OpenPGP subsystem - -The OpenPGP implementation is split into focused modules: - -- `desktop/pgp-keystore.cjs` stores contacts, trust, key material, and settings. -- `desktop/pgp-mail.cjs` handles message detection, decryption, verification, encryption, and signature checks. -- `desktop/pgp-keyservers.cjs` implements bounded HTTPS lookup and publication for VKS and HKP-compatible servers. +- Key-server lookup results never elevate trust; only the public key is sent during a separately confirmed publication. +- Send-time downgrade checks happen in the main process rather than only in UI logic. +- External links open only after a native confirmation dialog. +- Incoming HTML is sanitized in the renderer before insertion. HTTPS image URLs are kept in inert data attributes; only a per-message user action assigns image sources, and reopening the message resets that approval. HTTP images are rejected to preserve Android's cleartext-traffic protection. The CSP allows HTTPS images; scripts, frames, forms, and remote connections remain blocked. +- Credentials and private keys are stored with the OS keyring, not in plain JSON files. + +## 4. OpenPGP subsystem + +The OpenPGP implementation is split into focused modules: + +- `desktop/pgp-keystore.cjs` stores contacts, trust, key material, and settings. +- `desktop/pgp-mail.cjs` handles message detection, decryption, verification, encryption, and signature checks. +- `desktop/pgp-keyservers.cjs` implements bounded HTTPS lookup and publication for VKS and HKP-compatible servers. - `desktop/ipc/pgp.cjs` bridges those services into the Electron IPC API; `desktop/main.cjs` wires the services and registrars together. - -This keeps the cryptographic logic separate from the UI and gives the app a single place to enforce trust rules, passphrase checks, and recipient validation. - -Key-server enablement is persisted in encrypted OpenPGP settings; all servers default to disabled, including custom servers already configured by older versions. The main process enforces enabled status for both lookup and publication. A lookup queries all enabled servers, reports partial failures, and merges duplicate fingerprints while retaining source names. The user chooses one enabled server as the publication target. Custom HTTPS endpoints require a native confirmation when added; redirects and oversized responses are rejected. Returned keys are validated and remain untrusted until the user verifies their fingerprints out of band. Publishing sends only public key material and requires a native confirmation naming the destination for each publication. - -## 5. Data flow patterns - -- Account setup and edits flow from the UI into IPC, then into the encrypted main-process storage. -- Mail content is fetched by the native mail service and passed to the renderer as plain text, bounded HTML alternatives, links, and attachment metadata. HTML is allowlist-sanitized before display; HTTPS image requests remain inert until explicitly enabled for the current message view. -- Attachments, decrypted bodies, and external links are all checked before user-visible actions are allowed. -- Search, folder listing, and draft operations reuse the same account model across both desktop and Android versions. - -## 6. Release and packaging model - -The project packages multiple platforms from the same codebase: - -- `npm run dist:win` for Windows installer/portable builds -- `npm run dist:linux` for Linux AppImage and Debian builds -- Android builds via Capacitor (`npm run android:apk`) - -The app version is managed through package metadata and the Electron build config in `package.json`. - -## 7. Key architectural principles - -- Keep privileged operations in the main process. -- Keep security rules in trusted code rather than the UI. -- Store secrets in OS-backed secure storage whenever the platform supports it. -- Share the same account and sync model between desktop and Android where possible. -- Treat mail encryption and secure key handling as first-class product features, not optional extras. - -This architecture is intentionally built for a mail client that must handle privacy-sensitive data, background sync, and cross-platform parity without exposing the network or crypto stack to the renderer. + +This keeps the cryptographic logic separate from the UI and gives the app a single place to enforce trust rules, passphrase checks, and recipient validation. + +Key-server enablement is persisted in encrypted OpenPGP settings; all servers default to disabled, including custom servers already configured by older versions. The main process enforces enabled status for both lookup and publication. A lookup queries all enabled servers, reports partial failures, and merges duplicate fingerprints while retaining source names. The user chooses one enabled server as the publication target. Custom HTTPS endpoints require a native confirmation when added; redirects and oversized responses are rejected. Returned keys are validated and remain untrusted until the user verifies their fingerprints out of band. Publishing sends only public key material and requires a native confirmation naming the destination for each publication. + +## 5. Data flow patterns + +- Account setup and edits flow from the UI into IPC, then into the encrypted main-process storage. +- Mail content is fetched by the native mail service and passed to the renderer as plain text, bounded HTML alternatives, links, and attachment metadata. HTML is allowlist-sanitized before display; HTTPS image requests remain inert until explicitly enabled for the current message view. +- Attachments, decrypted bodies, and external links are all checked before user-visible actions are allowed. +- Search, folder listing, and draft operations reuse the same account model across both desktop and Android versions. + +## 6. Release and packaging model + +The project packages multiple platforms from the same codebase: + +- `npm run dist:win` for Windows installer/portable builds +- `npm run dist:linux` for Linux AppImage and Debian builds +- Android builds via Capacitor (`npm run android:apk`) + +The app version is managed through package metadata and the Electron build config in `package.json`. + +## 7. Key architectural principles + +- Keep privileged operations in the main process. +- Keep security rules in trusted code rather than the UI. +- Store secrets in OS-backed secure storage whenever the platform supports it. +- Share the same account and sync model between desktop and Android where possible. +- Treat mail encryption and secure key handling as first-class product features, not optional extras. + +This architecture is intentionally built for a mail client that must handle privacy-sensitive data, background sync, and cross-platform parity without exposing the network or crypto stack to the renderer. diff --git a/ENCRYPTION_PLAN.md b/ENCRYPTION_PLAN.md index 14be0dd..cc35fe5 100644 --- a/ENCRYPTION_PLAN.md +++ b/ENCRYPTION_PLAN.md @@ -1,101 +1,101 @@ -# Encryption plan: OpenPGP mail encryption for ep-mail - +# Encryption plan: OpenPGP mail encryption for ep-mail + Status: **Phases 1–3 and the desktop parts of 4–6 are implemented.** Android OpenPGP support and an independent human security review are still open. See [ANDROID_SECURITY_PLAN.md](./ANDROID_SECURITY_PLAN.md) for the broader Android security roadmap. Automated review findings and their fixes are documented in [SECURITY_REVIEW.md](./SECURITY_REVIEW.md); see [TODO.md](./TODO.md) for follow-up work. - -## 1. Format: OpenPGP with PGP/MIME (RFC 3156) - -| Option | Pros | Cons | -|---|---|---| -| **OpenPGP** | Interoperates with Thunderbird, Proton, Mailvelope, GnuPG and K-9/OpenKeychain. No certificate authority needed. | Key verification is manual. | -| S/MIME | Native in Outlook and Apple Mail. | Needs CA-issued certificates; poor fit for personal accounts. | - -Decision: OpenPGP only for v1; S/MIME may follow later. - -- Library: [OpenPGP.js](https://github.com/openpgpjs/openpgpjs) (`openpgp`), pure JS, usable in Electron and the Android WebView. -- Messages: `multipart/encrypted` (`application/pgp-encrypted` + `application/octet-stream`), signed and encrypted together. Attachments go inside the encrypted payload. -- Keys: Curve25519 (legacy EdDSA/ECDH, OpenPGP v4). OpenPGP.js' default native Ed25519 keys are rejected by GnuPG 2.5, so the widely supported format is used. -- Also detect and decrypt legacy inline PGP (`-----BEGIN PGP MESSAGE-----`). -- Out of scope for v1: Autocrypt headers and Web Key Directory. Desktop key-server lookup and publication are described in section 9. - -## 2. Key handling - -**Private keys** -- One or more keys per account; never stored unprotected and never sent anywhere. -- Always protected by a passphrase (minimum 8 characters). On desktop the whole key store is also encrypted with Electron `safeStorage` (the OS credential store). -- Android: wrap with a hardware-backed Android Keystore key; optional biometric unlock (Phase 4). -- The passphrase is cached only in memory for a configurable time, then wiped (Phase 4). It is never written to disk. -- Export as ASCII-armored files; a revocation certificate is generated when a key is created and can be exported after unlocking. -- Deleting or exporting a private key requires the passphrase. Desktop users can change a key's passphrase by verifying the current one and entering the new one twice; the public key and revocation certificate are preserved. - -**Public keys** -- Per-account contact keyring: address, fingerprint, trust level, source. -- Sources: file import, attached to received mail, key-server lookup, and own key attached to outgoing mail. -- Trust: trust on first use, shown with the fingerprint, plus an explicit "verified" state after out-of-band comparison. Warn loudly when a known contact's key changes. - -## 3. User experience - -- Compose: lock toggle, on by default when every recipient has a key. Never silently downgrade; offer to send unencrypted or cancel. -- Reader: status line such as "Encrypted and signed by X (verified)" or a warning for bad/unknown signatures. -- Message list: lock icon for encrypted mail. -- Settings: **Encryption keys** (Phase 1) for create, import, export, delete. -- Interactions: search and rules cannot read encrypted bodies (subject/sender stay plaintext); do not cache decrypted bodies; run link warnings and attachment previews only after decryption; encrypt the Sent copy to the sender's own key too. - -## 4. Threat model and limits - -- Protects content from the mail server and network observers. -- Does not protect metadata (sender, recipients, subject, timestamps). -- A compromised device, or a stolen key plus passphrase, defeats it. -- Losing the key means losing access to old encrypted mail; backups are the user's responsibility. - -## 5. Phases - -| Phase | Scope | Status | -|---|---|---| -| 1 | Foundation: OpenPGP.js, passphrase-protected key store (OS credential store on desktop), generate/import/export/delete, revocation certificate, unit tests, Settings UI | Done (desktop) | -| 2 | Receive: detect PGP/MIME and inline PGP, decrypt on open, verify signatures, status UI, missing-key and wrong-passphrase handling | Done (desktop) | -| 3 | Send: public-key keyring and contact import, encrypt and sign on compose, encrypted Sent copy, downgrade warnings | Done (desktop) | -| 4 | Trust and polish: fingerprint verification, key-change warnings, passphrase cache timeout, Android Keystore and biometric unlock | Desktop done; Android open | -| 5 | Interop testing with Thunderbird and GnuPG, large attachments, multiple recipients, corrupted payloads | Automated, GnuPG and manual Thunderbird interop checks done | -| 6 | Docs, security review, release | Docs and release done; independent review open | - -## 6. Phase 1 implementation notes - -- [desktop/pgp-keystore.cjs](./desktop/pgp-keystore.cjs): platform-independent key store with an injected storage backend. -- [desktop/main.cjs](./desktop/main.cjs): wraps the store with `safeStorage` (`pgp-keys.enc` in the user data folder) and exposes `pgp:*` IPC handlers; key files are saved through native dialogs. -- [desktop/preload.cjs](./desktop/preload.cjs): exposes `daybreakMail.pgp`. -- [pgp-ui.js](./pgp-ui.js): Settings → **Encryption keys**. Hidden on platforms without a key store (Android until Phase 4). -- Tests: `npm test` ([tests/pgp-keystore.test.cjs](./tests/pgp-keystore.test.cjs)). - -## 7. Phases 2–5 implementation notes - -- [desktop/pgp-mail.cjs](./desktop/pgp-mail.cjs): detects PGP/MIME and inline PGP, decrypts, verifies signatures (inside encrypted mail, `multipart/signed` and cleartext), builds encrypted/signed PGP/MIME messages, and keeps an in-memory passphrase cache. -- [desktop/pgp-keystore.cjs](./desktop/pgp-keystore.cjs): also stores contact public keys with trust levels (`unknown`, `trusted`, `verified`) and the passphrase-memory setting. -- Encrypted messages appear in the list as "Encrypted message"; they are decrypted on demand (`pgp:decrypt-message`) and the plaintext is never cached on disk. Attachments are read from the decrypted payload. -- Compose shows Encrypt and Sign options. Encrypt turns on by default when every recipient has a key; if a key is missing the app asks before sending unencrypted. Encryption happens before the message is sent or queued offline, so passphrases and plaintext never enter the outbox. The Sent copy is also encrypted to the sender's own key. -- Multiple outgoing attachments are included in the OpenPGP MIME payload and encrypted/signed together with the body. Android does not yet implement OpenPGP. -- Attachment selection has no app-enforced aggregate size cap; local storage capacity and mail-provider limits still apply. -- A signature from a key that differs from the one on file for the sender is flagged as a changed key. -- Interop: [tests/pgp-gnupg-interop.test.cjs](./tests/pgp-gnupg-interop.test.cjs) runs against a real GnuPG (skipped when it is not installed). -- Tests: [tests/pgp-mail.test.cjs](./tests/pgp-mail.test.cjs) (round trips, several recipients, tampering, key changes, large attachments, inline PGP). -- Limits: subjects and headers are not encrypted; drafts are stored unencrypted; opening encrypted attachments requires the passphrase to be remembered (see Settings → Encryption keys). -## 8. Risks - -- Android WebView performance with large attachments (may need native handling). -- Key loss (backup flow, revocation certificate). -- User confusion about trust; keep states simple: unknown, trusted, verified. -- Decrypted HTML must not leak through remote content; blocking remote images by default should land first. -- Security-critical code: have it reviewed by someone with cryptography experience before relying on it. - -## 9. Public key servers (desktop) - -The desktop Settings → Encryption keys view can search and publish through: - -- **keys.openpgp.org** using its [VKS API](https://keys.openpgp.org/about/api/). Email lookup only returns keys whose email addresses have been verified. After an upload, ep-mail requests verification for the key's primary email address and reports whether verification is pending or already complete. -- **keys.mailvelope.com** using HKP over HTTPS as documented by the [Mailvelope key server](https://github.com/mailvelope/keyserver#hkp-api). The server sends its own email-verification message after accepting a key upload. -- **Custom servers** using an explicitly selected HKP or VKS protocol and an HTTPS base URL. Custom server configuration is saved with the encrypted OpenPGP settings. - -All built-in and custom servers start disabled. Users enable each server explicitly; disabled servers are not contacted for lookup and cannot be used for publication. Searching is user-triggered and checks every enabled server; ep-mail does not perform background lookups while composing. Search addresses are disclosed to each enabled server. Results identify their source servers and duplicate keys are merged by fingerprint. The main process validates returned OpenPGP keys before showing them, and adding a result uses the existing key-replacement confirmation. Discovered keys enter the contact keyring with `unknown` trust; server publication or lookup is never treated as fingerprint verification. - -Publishing targets one explicitly selected enabled server, not all enabled servers. The destination is shown in the Settings control and named again in a native confirmation before upload. The confirmation identifies the server, email address, and fingerprint and explains that the email/key association becomes public and may be retained. Only the selected key's public material is uploaded; private keys and passphrases are never sent. A successful upload may still require the user to complete email verification before the key becomes searchable. Android key-server support is not included because Android OpenPGP support is not implemented. - -Custom servers are limited to HTTPS HKP/VKS endpoints, redirects are rejected, and lookup responses are size-limited. Key-server data remains subject to the server's availability, privacy practices, and verification policy; users should independently compare fingerprints before trusting a key. + +## 1. Format: OpenPGP with PGP/MIME (RFC 3156) + +| Option | Pros | Cons | +|---|---|---| +| **OpenPGP** | Interoperates with Thunderbird, Proton, Mailvelope, GnuPG and K-9/OpenKeychain. No certificate authority needed. | Key verification is manual. | +| S/MIME | Native in Outlook and Apple Mail. | Needs CA-issued certificates; poor fit for personal accounts. | + +Decision: OpenPGP only for v1; S/MIME may follow later. + +- Library: [OpenPGP.js](https://github.com/openpgpjs/openpgpjs) (`openpgp`), pure JS, usable in Electron and the Android WebView. +- Messages: `multipart/encrypted` (`application/pgp-encrypted` + `application/octet-stream`), signed and encrypted together. Attachments go inside the encrypted payload. +- Keys: Curve25519 (legacy EdDSA/ECDH, OpenPGP v4). OpenPGP.js' default native Ed25519 keys are rejected by GnuPG 2.5, so the widely supported format is used. +- Also detect and decrypt legacy inline PGP (`-----BEGIN PGP MESSAGE-----`). +- Out of scope for v1: Autocrypt headers and Web Key Directory. Desktop key-server lookup and publication are described in section 9. + +## 2. Key handling + +**Private keys** +- One or more keys per account; never stored unprotected and never sent anywhere. +- Always protected by a passphrase (minimum 8 characters). On desktop the whole key store is also encrypted with Electron `safeStorage` (the OS credential store). +- Android: wrap with a hardware-backed Android Keystore key; optional biometric unlock (Phase 4). +- The passphrase is cached only in memory for a configurable time, then wiped (Phase 4). It is never written to disk. +- Export as ASCII-armored files; a revocation certificate is generated when a key is created and can be exported after unlocking. +- Deleting or exporting a private key requires the passphrase. Desktop users can change a key's passphrase by verifying the current one and entering the new one twice; the public key and revocation certificate are preserved. + +**Public keys** +- Per-account contact keyring: address, fingerprint, trust level, source. +- Sources: file import, attached to received mail, key-server lookup, and own key attached to outgoing mail. +- Trust: trust on first use, shown with the fingerprint, plus an explicit "verified" state after out-of-band comparison. Warn loudly when a known contact's key changes. + +## 3. User experience + +- Compose: lock toggle, on by default when every recipient has a key. Never silently downgrade; offer to send unencrypted or cancel. +- Reader: status line such as "Encrypted and signed by X (verified)" or a warning for bad/unknown signatures. +- Message list: lock icon for encrypted mail. +- Settings: **Encryption keys** (Phase 1) for create, import, export, delete. +- Interactions: search and rules cannot read encrypted bodies (subject/sender stay plaintext); do not cache decrypted bodies; run link warnings and attachment previews only after decryption; encrypt the Sent copy to the sender's own key too. + +## 4. Threat model and limits + +- Protects content from the mail server and network observers. +- Does not protect metadata (sender, recipients, subject, timestamps). +- A compromised device, or a stolen key plus passphrase, defeats it. +- Losing the key means losing access to old encrypted mail; backups are the user's responsibility. + +## 5. Phases + +| Phase | Scope | Status | +|---|---|---| +| 1 | Foundation: OpenPGP.js, passphrase-protected key store (OS credential store on desktop), generate/import/export/delete, revocation certificate, unit tests, Settings UI | Done (desktop) | +| 2 | Receive: detect PGP/MIME and inline PGP, decrypt on open, verify signatures, status UI, missing-key and wrong-passphrase handling | Done (desktop) | +| 3 | Send: public-key keyring and contact import, encrypt and sign on compose, encrypted Sent copy, downgrade warnings | Done (desktop) | +| 4 | Trust and polish: fingerprint verification, key-change warnings, passphrase cache timeout, Android Keystore and biometric unlock | Desktop done; Android open | +| 5 | Interop testing with Thunderbird and GnuPG, large attachments, multiple recipients, corrupted payloads | Automated, GnuPG and manual Thunderbird interop checks done | +| 6 | Docs, security review, release | Docs and release done; independent review open | + +## 6. Phase 1 implementation notes + +- [desktop/pgp-keystore.cjs](./desktop/pgp-keystore.cjs): platform-independent key store with an injected storage backend. +- [desktop/main.cjs](./desktop/main.cjs): wraps the store with `safeStorage` (`pgp-keys.enc` in the user data folder) and exposes `pgp:*` IPC handlers; key files are saved through native dialogs. +- [desktop/preload.cjs](./desktop/preload.cjs): exposes `daybreakMail.pgp`. +- [pgp-ui.js](./pgp-ui.js): Settings → **Encryption keys**. Hidden on platforms without a key store (Android until Phase 4). +- Tests: `npm test` ([tests/pgp-keystore.test.cjs](./tests/pgp-keystore.test.cjs)). + +## 7. Phases 2–5 implementation notes + +- [desktop/pgp-mail.cjs](./desktop/pgp-mail.cjs): detects PGP/MIME and inline PGP, decrypts, verifies signatures (inside encrypted mail, `multipart/signed` and cleartext), builds encrypted/signed PGP/MIME messages, and keeps an in-memory passphrase cache. +- [desktop/pgp-keystore.cjs](./desktop/pgp-keystore.cjs): also stores contact public keys with trust levels (`unknown`, `trusted`, `verified`) and the passphrase-memory setting. +- Encrypted messages appear in the list as "Encrypted message"; they are decrypted on demand (`pgp:decrypt-message`) and the plaintext is never cached on disk. Attachments are read from the decrypted payload. +- Compose shows Encrypt and Sign options. Encrypt turns on by default when every recipient has a key; if a key is missing the app asks before sending unencrypted. Encryption happens before the message is sent or queued offline, so passphrases and plaintext never enter the outbox. The Sent copy is also encrypted to the sender's own key. +- Multiple outgoing attachments are included in the OpenPGP MIME payload and encrypted/signed together with the body. Android does not yet implement OpenPGP. +- Attachment selection has no app-enforced aggregate size cap; local storage capacity and mail-provider limits still apply. +- A signature from a key that differs from the one on file for the sender is flagged as a changed key. +- Interop: [tests/pgp-gnupg-interop.test.cjs](./tests/pgp-gnupg-interop.test.cjs) runs against a real GnuPG (skipped when it is not installed). +- Tests: [tests/pgp-mail.test.cjs](./tests/pgp-mail.test.cjs) (round trips, several recipients, tampering, key changes, large attachments, inline PGP). +- Limits: subjects and headers are not encrypted; drafts are stored unencrypted; opening encrypted attachments requires the passphrase to be remembered (see Settings → Encryption keys). +## 8. Risks + +- Android WebView performance with large attachments (may need native handling). +- Key loss (backup flow, revocation certificate). +- User confusion about trust; keep states simple: unknown, trusted, verified. +- Decrypted HTML must not leak through remote content; blocking remote images by default should land first. +- Security-critical code: have it reviewed by someone with cryptography experience before relying on it. + +## 9. Public key servers (desktop) + +The desktop Settings → Encryption keys view can search and publish through: + +- **keys.openpgp.org** using its [VKS API](https://keys.openpgp.org/about/api/). Email lookup only returns keys whose email addresses have been verified. After an upload, ep-mail requests verification for the key's primary email address and reports whether verification is pending or already complete. +- **keys.mailvelope.com** using HKP over HTTPS as documented by the [Mailvelope key server](https://github.com/mailvelope/keyserver#hkp-api). The server sends its own email-verification message after accepting a key upload. +- **Custom servers** using an explicitly selected HKP or VKS protocol and an HTTPS base URL. Custom server configuration is saved with the encrypted OpenPGP settings. + +All built-in and custom servers start disabled. Users enable each server explicitly; disabled servers are not contacted for lookup and cannot be used for publication. Searching is user-triggered and checks every enabled server; ep-mail does not perform background lookups while composing. Search addresses are disclosed to each enabled server. Results identify their source servers and duplicate keys are merged by fingerprint. The main process validates returned OpenPGP keys before showing them, and adding a result uses the existing key-replacement confirmation. Discovered keys enter the contact keyring with `unknown` trust; server publication or lookup is never treated as fingerprint verification. + +Publishing targets one explicitly selected enabled server, not all enabled servers. The destination is shown in the Settings control and named again in a native confirmation before upload. The confirmation identifies the server, email address, and fingerprint and explains that the email/key association becomes public and may be retained. Only the selected key's public material is uploaded; private keys and passphrases are never sent. A successful upload may still require the user to complete email verification before the key becomes searchable. Android key-server support is not included because Android OpenPGP support is not implemented. + +Custom servers are limited to HTTPS HKP/VKS endpoints, redirects are rejected, and lookup responses are size-limited. Key-server data remains subject to the server's availability, privacy practices, and verification policy; users should independently compare fingerprints before trusting a key. diff --git a/README.md b/README.md index 5ae5634..3a0e44e 100644 --- a/README.md +++ b/README.md @@ -1,42 +1,42 @@ -# ep-mail - -An Eternity Project mail client with **Eternity Daylight**, **Wasteland**, and EP themes. It includes an inbox, message reader, search, starring, snooze reminders, archive and trash actions, compose/reply/forward, contacts, and a month calendar. - +# ep-mail + +An Eternity Project mail client with **Eternity Daylight**, **Wasteland**, and EP themes. It includes an inbox, message reader, search, starring, snooze reminders, archive and trash actions, compose/reply/forward, contacts, and a month calendar. + ## Desktop app - -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/`. + 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 Desktop account setup supports Google and Microsoft OAuth2 when provider client configuration is supplied to the Electron process. Set `EP_MAIL_GOOGLE_OAUTH_CLIENT_ID` (and `EP_MAIL_GOOGLE_OAUTH_CLIENT_SECRET` if issued for the desktop client) and/or `EP_MAIL_MICROSOFT_OAUTH_CLIENT_ID`; `EP_MAIL_MICROSOFT_OAUTH_TENANT_ID` is optional and defaults to `common`. Register the corresponding native/desktop public client with a loopback redirect URI. Microsoft app registrations must allow public-client authorization and delegated IMAP/SMTP permissions. Google's full Gmail mail scope is restricted; production use may require app verification, and unverified projects may need the account added as a test user. OAuth sign-in opens the system browser, uses PKCE, and stores refresh/access tokens only in the encrypted account store. Android continues to use its existing password-based account setup. - -On packaged Windows builds, startup repairs an existing per-user Start Menu shortcut to point to the launched installed or portable executable and use its icon and AppUserModelID. Windows may keep a cached icon for an existing taskbar pin; if so, unpin and pin ep-mail again after launching the updated build. - -See the project architecture overview in [ARCHITECTURE.md](./ARCHITECTURE.md). - -## Android app - -The Android app reuses the web interface in a Capacitor shell and implements mail, DAV, secure account storage, and background sync with native Android services. Per-account signatures, notification preferences, and incoming-mail rules are respected; configured sync intervals apply to IDLE fallback polling, while Android's periodic background worker has a 15-minute platform minimum. Recent message content, drafts, and queued actions/sends are stored in the encrypted Android account vault for offline access and retry. Search filters use the same criteria and online scan limit as desktop. Install Node.js, Android Studio with the Android SDK, and JDK 21. Set `JAVA_HOME` and `ANDROID_HOME` if they are not configured by Android Studio, then run: - -```sh -npm install -npm run android:apk -``` - -The debug APK is written to `android/app/build/outputs/apk/debug/app-debug.apk`. Install it on a connected test device with `adb install -r android/app/build/outputs/apk/debug/app-debug.apk`, or open the project in Android Studio with `npm run android:open`. 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. Android may delay or stop background activity after force-stop, prolonged device restrictions, or vendor battery management. - -## Run on Windows or Linux - -Install Python 3, open a terminal in this folder, and run: - -```sh -python -m http.server 8000 -``` - -On Windows, `py -m http.server 8000` is also available on many Python installations. Visit `http://localhost:8000` in a current browser. Use the browser's **Install app** option to add ep-mail as a standalone desktop app. The service worker caches the app shell for offline use after the first visit. - -## Current scope - -Mail supports multiple IMAP/SMTP accounts, switching between them, and saving message attachments. Compose can attach multiple files of any type; attachments are retained in local drafts and sent with the message. There is no app-enforced total-size cap, though local storage and mail providers may impose limits. Desktop encrypts and signs attachments together with the body when OpenPGP is selected. CalDAV and CardDAV servers can be added from the Calendar and Contacts views; credentials are kept in the OS-encrypted credential store, and events and contacts can sync and be edited on the server. Local contacts and events remain available without a DAV connection. Your display name is saved locally and appears in the greeting. Use the **+** beside **Folders** in the sidebar to create IMAP folders on the server; your custom folders appear in the sidebar and can be opened like any other folder. Keyboard shortcuts for compose, search, refresh, archive, delete, star, reply, forward, and message navigation can be changed in **Settings**. Attachments can be previewed (images and text) in the reader, and the **Attachments** view in the sidebar lists, searches, filters by type, previews and downloads attachments across Inbox, Sent, Archive and Trash. On desktop, **Settings → Encryption keys** creates, imports and exports passphrase-protected OpenPGP keys stored encrypted by the operating system; you can import contact keys, enable selected key servers (all are disabled initially), search all enabled servers, and publish a key to one explicitly selected server after a native confirmation names the destination. Discovered keys remain unverified until you compare fingerprints independently. Desktop can read encrypted or signed OpenPGP mail and encrypt or sign outgoing messages (see [ENCRYPTION_PLAN.md](./ENCRYPTION_PLAN.md)); Android OpenPGP support is not available yet. Run the tests with `npm test`. + +On packaged Windows builds, startup repairs an existing per-user Start Menu shortcut to point to the launched installed or portable executable and use its icon and AppUserModelID. Windows may keep a cached icon for an existing taskbar pin; if so, unpin and pin ep-mail again after launching the updated build. + +See the project architecture overview in [ARCHITECTURE.md](./ARCHITECTURE.md). + +## Android app + +The Android app reuses the web interface in a Capacitor shell and implements mail, DAV, secure account storage, and background sync with native Android services. Per-account signatures, notification preferences, and incoming-mail rules are respected; configured sync intervals apply to IDLE fallback polling, while Android's periodic background worker has a 15-minute platform minimum. Recent message content, drafts, and queued actions/sends are stored in the encrypted Android account vault for offline access and retry. Search filters use the same criteria and online scan limit as desktop. Install Node.js, Android Studio with the Android SDK, and JDK 21. Set `JAVA_HOME` and `ANDROID_HOME` if they are not configured by Android Studio, then run: + +```sh +npm install +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 -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 .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 previews contain generic text rather than mailbox addresses or message subjects. Android may delay or stop background activity after force-stop, prolonged device restrictions, or vendor battery management. + +## Run on Windows or Linux + +Install Python 3, open a terminal in this folder, and run: + +```sh +python -m http.server 8000 +``` + +On Windows, `py -m http.server 8000` is also available on many Python installations. Visit `http://localhost:8000` in a current browser. Use the browser's **Install app** option to add ep-mail as a standalone desktop app. The service worker caches the app shell for offline use after the first visit. + +## Current scope + +Mail supports multiple IMAP/SMTP accounts, switching between them, and saving message attachments. Compose can attach multiple files of any type; attachments are retained in local drafts and sent with the message. There is no app-enforced total-size cap, though local storage and mail providers may impose limits. Desktop encrypts and signs attachments together with the body when OpenPGP is selected. CalDAV and CardDAV servers can be added from the Calendar and Contacts views; credentials are kept in the OS-encrypted credential store, and events and contacts can sync and be edited on the server. Local contacts and events remain available without a DAV connection. Your display name is saved locally and appears in the greeting. Use the **+** beside **Folders** in the sidebar to create IMAP folders on the server; your custom folders appear in the sidebar and can be opened like any other folder. Keyboard shortcuts for compose, search, refresh, archive, delete, star, reply, forward, and message navigation can be changed in **Settings**. Attachments can be previewed (images and text) in the reader, and the **Attachments** view in the sidebar lists, searches, filters by type, previews and downloads attachments across Inbox, Sent, Archive and Trash. On desktop, **Settings → Encryption keys** creates, imports and exports passphrase-protected OpenPGP keys stored encrypted by the operating system; you can import contact keys, enable selected key servers (all are disabled initially), search all enabled servers, and publish a key to one explicitly selected server after a native confirmation names the destination. Discovered keys remain unverified until you compare fingerprints independently. Desktop can read encrypted or signed OpenPGP mail and encrypt or sign outgoing messages (see [ENCRYPTION_PLAN.md](./ENCRYPTION_PLAN.md)); Android OpenPGP support is not available yet. Run the tests with `npm test`. diff --git a/SECURITY_REVIEW.md b/SECURITY_REVIEW.md index 71a5fe6..801cb15 100644 --- a/SECURITY_REVIEW.md +++ b/SECURITY_REVIEW.md @@ -1,62 +1,62 @@ -# Security review: OpenPGP encryption - +# Security review: OpenPGP encryption + Date: 2026-10-08 Version reviewed: 0.3.2 (working tree, uncommitted changes included) Type: automated review by an AI security-review agent. It is not a substitute for a human review. > **Current status (2026-10-16, ep-mail 0.4.38):** The entries below are a historical review record. The replacement-key and trust-elevation confirmations are implemented in the main process and now have IPC regression tests for cancel/confirm behavior. The send-time plaintext downgrade check is enforced in the main process. The user confirms the current built artifact works. A direct IPC test for the plaintext-send confirmation branch and an independent human review remain open; Android OpenPGP support is not implemented. - -## Scope - -- `desktop/pgp-keystore.cjs`: key store, `safeStorage` wrapping, contacts, trust -- `desktop/pgp-mail.cjs`: detect, decrypt, verify, build PGP/MIME, passphrase cache + +## Scope + +- `desktop/pgp-keystore.cjs`: key store, `safeStorage` wrapping, contacts, trust +- `desktop/pgp-mail.cjs`: detect, decrypt, verify, build PGP/MIME, passphrase cache - `pgp:*` IPC handlers, now registered in `desktop/ipc/pgp.cjs`, plus the plaintext-send check in `desktop/ipc/mail.cjs`; the original review predates this IPC extraction. - Renderer: `pgp-mail-ui.js`, `pgp-ui.js`, and the `window.epMailFeatures.pgp.prepareSend` feature hook used by `mail-ui.js`. -- Design reference: [ENCRYPTION_PLAN.md](./ENCRYPTION_PLAN.md) - -Focus areas: secret leaks (disk, logs, outbox, renderer), IPC abuse by a compromised renderer, HTML injection from key user IDs and decrypted content, signature status spoofing, key matching by fingerprint, silent downgrade to plaintext, malformed or oversized input, passphrase cache lifetime. - -## Findings - -| # | Severity | File | Issue | Confidence | Status | -|---|----------|------|-------|------------|--------| -| 1 | 🟡 MEDIUM | `pgp-mail-ui.js`, `mail-ui.js` | Encrypt-by-default is applied after a 300 ms debounced key lookup. Sending before it finished skipped the key check and sent the message unencrypted. | 9/10 | Fixed | -| 2 | 🟡 MEDIUM | `desktop/preload.cjs`, `desktop/main.cjs`, `desktop/pgp-keystore.cjs` | A compromised renderer could add a public key for a recipient's address and call `pgp:set-trust` to mark it verified. Recipient key selection prefers higher trust, so later mail could be encrypted to the attacker's key. The confirmation existed only in the renderer UI. | 8/10 | Fixed | - -No critical or high severity issues were reported. - -## Fixes applied - +- Design reference: [ENCRYPTION_PLAN.md](./ENCRYPTION_PLAN.md) + +Focus areas: secret leaks (disk, logs, outbox, renderer), IPC abuse by a compromised renderer, HTML injection from key user IDs and decrypted content, signature status spoofing, key matching by fingerprint, silent downgrade to plaintext, malformed or oversized input, passphrase cache lifetime. + +## Findings + +| # | Severity | File | Issue | Confidence | Status | +|---|----------|------|-------|------------|--------| +| 1 | 🟡 MEDIUM | `pgp-mail-ui.js`, `mail-ui.js` | Encrypt-by-default is applied after a 300 ms debounced key lookup. Sending before it finished skipped the key check and sent the message unencrypted. | 9/10 | Fixed | +| 2 | 🟡 MEDIUM | `desktop/preload.cjs`, `desktop/main.cjs`, `desktop/pgp-keystore.cjs` | A compromised renderer could add a public key for a recipient's address and call `pgp:set-trust` to mark it verified. Recipient key selection prefers higher trust, so later mail could be encrypted to the attacker's key. The confirmation existed only in the renderer UI. | 8/10 | Fixed | + +No critical or high severity issues were reported. + +## Fixes applied + 1. **Send-time check:** the renderer checks recipient keys when you press Send. If keys exist for all recipients and you did not change the Encrypt box yourself, it asks before sending unencrypted. Unticking Encrypt on purpose still sends without a prompt. This renderer hook is now exposed as `window.epMailFeatures.pgp.prepareSend`. -2. **Trusted confirmation:** the `pgp:set-trust` handler in the main process shows a native dialog with the contact and fingerprint before raising trust. A cancelled dialog aborts the change. The renderer's own prompt may appear as well, so users can see two confirmations. - +2. **Trusted confirmation:** the `pgp:set-trust` handler in the main process shows a native dialog with the contact and fingerprint before raising trust. A cancelled dialog aborts the change. The renderer's own prompt may appear as well, so users can see two confirmations. + ## Verification at the original review time - -- `npm test`: 20 passed, 0 failed (includes the GnuPG interoperability tests). -- `node --check` on the edited files. -- The fixes were not exercised in the running app. - + +- `npm test`: 20 passed, 0 failed (includes the GnuPG interoperability tests). +- `node --check` on the edited files. +- The fixes were not exercised in the running app. + ## Remaining work recorded after the first review (2026-10-08) - -- Human review of the key store, the IPC boundary and the signature UI. + +- Human review of the key store, the IPC boundary and the signature UI. - Replacement-key confirmation in the main process when a new key arrives for an address that already has a contact. This was still open at the time; see the later review pass below. -- Run `npm audit` and pin the OpenPGP.js version. -- Re-run the GnuPG interoperability tests after dependency updates. -- Android has no encryption support yet, so it was not reviewed. - -## Second review pass (2026-10-09) - -Fresh review of the same scope after the first round of fixes. Tests: 20 passed, 0 failed. No code was changed in this pass. - -| # | Severity | File | Issue | Confidence | Status | -|---|----------|------|-------|------------|--------| -| 3 | 🟡 MEDIUM | `desktop/pgp-keystore.cjs`, `desktop/main.cjs` | `pgp:add-contact` adds a key for an address that already has one without a main-process confirmation. At equal trust the newest key wins recipient selection, so an added key can take over outgoing encryption. The trust dialog does not cover replacement. | 9/10 | Fixed | -| 4 | 🟡 MEDIUM | `desktop/main.cjs`, `desktop/preload.cjs` | The send-time downgrade check exists only in the renderer. `mail:send` sends plaintext when `pgp` is omitted, so a compromised renderer can bypass the warning. | 9/10 | Fixed | -| 5 | 🟡 MEDIUM | `desktop/main.cjs` | `safeStorage` is used without checking the backend. On Linux the `basic_text` backend uses a hardcoded password, so a copied store would expose account credentials and mail data. PGP private keys stay protected by their own passphrases. | 8/10 | Fixed | - +- Run `npm audit` and pin the OpenPGP.js version. +- Re-run the GnuPG interoperability tests after dependency updates. +- Android has no encryption support yet, so it was not reviewed. + +## Second review pass (2026-10-09) + +Fresh review of the same scope after the first round of fixes. Tests: 20 passed, 0 failed. No code was changed in this pass. + +| # | Severity | File | Issue | Confidence | Status | +|---|----------|------|-------|------------|--------| +| 3 | 🟡 MEDIUM | `desktop/pgp-keystore.cjs`, `desktop/main.cjs` | `pgp:add-contact` adds a key for an address that already has one without a main-process confirmation. At equal trust the newest key wins recipient selection, so an added key can take over outgoing encryption. The trust dialog does not cover replacement. | 9/10 | Fixed | +| 4 | 🟡 MEDIUM | `desktop/main.cjs`, `desktop/preload.cjs` | The send-time downgrade check exists only in the renderer. `mail:send` sends plaintext when `pgp` is omitted, so a compromised renderer can bypass the warning. | 9/10 | Fixed | +| 5 | 🟡 MEDIUM | `desktop/main.cjs` | `safeStorage` is used without checking the backend. On Linux the `basic_text` backend uses a hardcoded password, so a copied store would expose account credentials and mail data. PGP private keys stay protected by their own passphrases. | 8/10 | Fixed | + Applied fixes: -- #3: native confirmation showing both fingerprints when a key overlaps existing contacts, and the add-contact flow aborts if the replacement is not confirmed. -- #4: the main process checks recipient keys before allowing a plaintext send and shows a trusted confirmation dialog. +- #3: native confirmation showing both fingerprints when a key overlaps existing contacts, and the add-contact flow aborts if the replacement is not confirmed. +- #4: the main process checks recipient keys before allowing a plaintext send and shows a trusted confirmation dialog. - #5: Linux now rejects the insecure `basic_text` safeStorage backend and asks the user to switch to a secure system keyring before storing mail or PGP secrets. ## Current follow-up @@ -74,4 +74,4 @@ Fresh automated review of the whole repository (ep-mail 0.4.39), covering the El |---|----------|------|-------|---------------|------------| | - | - | - | - | No actionable vulnerabilities found. | - | -The open items under "Current follow-up" still apply: human review, dependency audit, OpenPGP.js version pinning and Android OpenPGP support. +The open items under "Current follow-up" still apply: human review, dependency audit, OpenPGP.js version pinning and Android OpenPGP support. diff --git a/TODO.md b/TODO.md index 7c28d84..817ad99 100644 --- a/TODO.md +++ b/TODO.md @@ -1,78 +1,78 @@ -# TODO - -## Product identity - -- [x] Rename the program to **ep-mail** across the app UI, package metadata, desktop builds, and documentation. -- [x] Replace the temporary sun/asterisk app mark with the Git and webmail logo, using the EP Daylight and EP Wasteland color variants. -- [x] Fix the ep-mail logo not appearing in the Windows taskbar. -- [x] Add Android support for the mail app. -- [ ] Add macOS support: configure macOS release targets and build the app on a Mac or hosted macOS runner; sign and notarize releases for distribution. -- [x] Show the app version after **ep-mail** in the window title. - -## Mail workflow - -- [x] Snooze messages until a chosen time and show a follow-up reminder when they return. +# TODO + +## Product identity + +- [x] Rename the program to **ep-mail** across the app UI, package metadata, desktop builds, and documentation. +- [x] Replace the temporary sun/asterisk app mark with the Git and webmail logo, using the EP Daylight and EP Wasteland color variants. +- [x] Fix the ep-mail logo not appearing in the Windows taskbar. +- [x] Add Android support for the mail app. +- [ ] Add macOS support: configure macOS release targets and build the app on a Mac or hosted macOS runner; sign and notarize releases for distribution. +- [x] Show the app version after **ep-mail** in the window title. + +## Mail workflow + +- [x] Snooze messages until a chosen time and show a follow-up reminder when they return. - [ ] Add a configurable Undo Send delay and scheduled sending. -- [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] 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. - [ ] 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 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] Add per-account rules to sort, archive, label, or flag new incoming messages by sender and/or subject. -- [x] Add per-account signatures, notification preferences, and sync settings. -- [x] Add the ability to create IMAP folders from the app. -- [x] Block remote images by default and let users load them per message on desktop and Android/Web. - -## Mail security - +- [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] Warn about suspicious sender addresses and links; require confirmation before opening external links. +- [x] Add per-account rules to sort, archive, label, or flag new incoming messages by sender and/or subject. +- [x] Add per-account signatures, notification preferences, and sync settings. +- [x] Add the ability to create IMAP folders from the app. +- [x] Block remote images by default and let users load them per message on desktop and Android/Web. + +## Mail security + - [x] Add desktop support for encrypting and decrypting mail with OpenPGP (PGP/MIME). Android support remains open; see [ENCRYPTION_PLAN.md](./ENCRYPTION_PLAN.md). - - [x] Phase 1: foundation — OpenPGP.js, passphrase-protected key store (desktop), generate/import/export/delete keys, revocation certificate, tests, Settings UI. - - [x] Phase 2: receive — detect PGP/MIME and inline PGP mail, decrypt on open, verify signatures, show encryption/signature status, handle missing keys and wrong passphrases. - - [x] Phase 3: send — public-key keyring and key import from contacts/messages, encrypt and sign when composing, encrypted copy in Sent, warn instead of silently downgrading. - - [x] Phase 4 (desktop): trust levels and fingerprint verification, key-change warnings, passphrase cache timeout. + - [x] Phase 1: foundation — OpenPGP.js, passphrase-protected key store (desktop), generate/import/export/delete keys, revocation certificate, tests, Settings UI. + - [x] Phase 2: receive — detect PGP/MIME and inline PGP mail, decrypt on open, verify signatures, show encryption/signature status, handle missing keys and wrong passphrases. + - [x] Phase 3: send — public-key keyring and key import from contacts/messages, encrypt and sign when composing, encrypted copy in Sent, warn instead of silently downgrading. + - [x] Phase 4 (desktop): trust levels and fingerprint verification, key-change warnings, passphrase cache timeout. - [ ] Phase 4 (Android): add Android Keystore key storage, biometric unlock, and the reading/sending bridge (encryption is desktop-only until then). - - [x] Phase 5 (automated): large attachments, multiple recipients, corrupted/tampered payloads, inline PGP and PGP/MIME tests. - - [x] Phase 5 (GnuPG): automated interoperability tests with GnuPG 2.5 (both directions: PGP/MIME, inline, clear-signed, detached signatures). - - [x] Phase 6: documentation and release. - - [x] Manual interoperability check with Thunderbird. + - [x] Phase 5 (automated): large attachments, multiple recipients, corrupted/tampered payloads, inline PGP and PGP/MIME tests. + - [x] Phase 5 (GnuPG): automated interoperability tests with GnuPG 2.5 (both directions: PGP/MIME, inline, clear-signed, detached signatures). + - [x] Phase 6: documentation and release. + - [x] Manual interoperability check with Thunderbird. - [x] Address findings from the automated OpenPGP security reviews (see [SECURITY_REVIEW.md](./SECURITY_REVIEW.md)). - [ ] Complete an independent human security review of the encryption code before expanding OpenPGP support to Android. - [ ] Add direct IPC-handler tests for both accept and cancel paths of the main-process plaintext-send confirmation. - [ ] Complete the Android security work in [ANDROID_SECURITY_PLAN.md](./ANDROID_SECURITY_PLAN.md), including Android OpenPGP and release security checks. - -## Appearance and settings - -- [ ] Fix the startup color-scheme flash so the selected dark theme is applied before the app window appears. -- [x] Make **EP Wasteland** the default theme for new users. -- [x] Move theme selection into Settings and save the selection so the chosen theme is applied every time the program starts. -- [x] Keep the display name in Account Settings and make it available while adding a mailbox. - + +## Appearance and settings + +- [ ] Fix the startup color-scheme flash so the selected dark theme is applied before the app window appears. +- [x] Make **EP Wasteland** the default theme for new users. +- [x] Move theme selection into Settings and save the selection so the chosen theme is applied every time the program starts. +- [x] Keep the display name in Account Settings and make it available while adding a mailbox. + ## Account settings - [x] Add desktop OAuth2 account setup for Google and Microsoft. Configure provider client IDs with the environment variables documented in `README.md`; Android remains password-based. - [ ] Fix the mailbox space indicator; it is not working. -- [x] Fix automatic mail sync so the message list refreshes when new mail arrives. -- [x] Sync all connected accounts' mailboxes in the Electron main process at launch/resume and periodically in the background. - - [x] Track `UIDVALIDITY`, the last processed UID, and `HIGHESTMODSEQ` per account and folder; fall back to checking message flags when mod-sequences are unavailable. - - [x] Add persistent IMAP IDLE watchers for up to two accounts, with reconnect backoff and periodic polling as a fallback for other accounts and servers without IDLE support. - - [ ] Add push mail support. - - [x] Prevent overlapping sync runs, limit concurrent account connections, and invalidate in-flight results when an account is edited or removed. - - [x] Send updates to the renderer over IPC and show native notifications for new inbox mail. -- [x] Add new mail notifications. -- [x] Add an **Edit** button for each connected mail account so its account settings can be changed after setup. -- [x] Move CalDAV and CardDAV server configuration into Account Settings, removing the server settings controls from the Calendar and Contacts views. -- [x] Keep general Settings focused on appearance and other app-wide preferences rather than the display name. -- [x] Display name must be set per account. -- [x] Remove the display name initials from the bottom-left corner. -- [x] Add the ability to delete draft mails. -- [x] Fix IMAP folder creation, which does not work. +- [x] Fix automatic mail sync so the message list refreshes when new mail arrives. +- [x] Sync all connected accounts' mailboxes in the Electron main process at launch/resume and periodically in the background. + - [x] Track `UIDVALIDITY`, the last processed UID, and `HIGHESTMODSEQ` per account and folder; fall back to checking message flags when mod-sequences are unavailable. + - [x] Add persistent IMAP IDLE watchers for up to two accounts, with reconnect backoff and periodic polling as a fallback for other accounts and servers without IDLE support. + - [ ] Add push mail support. + - [x] Prevent overlapping sync runs, limit concurrent account connections, and invalidate in-flight results when an account is edited or removed. + - [x] Send updates to the renderer over IPC and show native notifications for new inbox mail. +- [x] Add new mail notifications. +- [x] Add an **Edit** button for each connected mail account so its account settings can be changed after setup. +- [x] Move CalDAV and CardDAV server configuration into Account Settings, removing the server settings controls from the Calendar and Contacts views. +- [x] Keep general Settings focused on appearance and other app-wide preferences rather than the display name. +- [x] Display name must be set per account. +- [x] Remove the display name initials from the bottom-left corner. +- [x] Add the ability to delete draft mails. +- [x] Fix IMAP folder creation, which does not work. - [ ] Improve sidebar usability so all folders fit or can be reached by scrolling; consider collapsing less-used sections. - [ ] Make labels work reliably and support creating and managing additional labels. -- [x] Fix created IMAP folders not showing in the mail rules folder list; only Inbox, Archive and Trash are shown. -- [x] Fix draft mail deletion to work like the Inbox: select multiple drafts and delete the selected drafts at once. -- [x] Show created IMAP folders in the same list as Inbox and the other folders, and move the folder list and the add-folder button to the top row above Inbox. Add scrolling to the IMAP folders area. -- [x] Add desktop public key server support for finding and publishing OpenPGP keys: keys.openpgp.org (VKS), keys.mailvelope.com (HKP over HTTPS), and user-defined HTTPS HKP/VKS servers. Servers are disabled until selected; lookup checks all enabled servers, and publishing requires one explicitly selected destination. Discovered keys remain unverified until fingerprint verification. -- [x] Add the ability to attach multiple files to outgoing mails on desktop and Android/Web, persist them in local drafts, and include them within desktop OpenPGP protection. -- [x] Fix security review findings: confirm key replacement in the main process, enforce the plaintext-send check in the main process, and handle the Linux safeStorage basic_text backend. See SECURITY_REVIEW.md. -- [x] Add the ability to change the passphrase of an encryption key on desktop. +- [x] Fix created IMAP folders not showing in the mail rules folder list; only Inbox, Archive and Trash are shown. +- [x] Fix draft mail deletion to work like the Inbox: select multiple drafts and delete the selected drafts at once. +- [x] Show created IMAP folders in the same list as Inbox and the other folders, and move the folder list and the add-folder button to the top row above Inbox. Add scrolling to the IMAP folders area. +- [x] Add desktop public key server support for finding and publishing OpenPGP keys: keys.openpgp.org (VKS), keys.mailvelope.com (HKP over HTTPS), and user-defined HTTPS HKP/VKS servers. Servers are disabled until selected; lookup checks all enabled servers, and publishing requires one explicitly selected destination. Discovered keys remain unverified until fingerprint verification. +- [x] Add the ability to attach multiple files to outgoing mails on desktop and Android/Web, persist them in local drafts, and include them within desktop OpenPGP protection. +- [x] Fix security review findings: confirm key replacement in the main process, enforce the plaintext-send check in the main process, and handle the Linux safeStorage basic_text backend. See SECURITY_REVIEW.md. +- [x] Add the ability to change the passphrase of an encryption key on desktop. diff --git a/account-ui.js b/account-ui.js index 3def3e6..d657607 100644 --- a/account-ui.js +++ b/account-ui.js @@ -3,29 +3,29 @@ const accountMailUi = window.epMailFeatures.mail; const accountDavUi = window.epMailFeatures.dav; async function openAccountManager(){ - const root=accountMailUi.select('#modal-root'); - try{ - const data=await window.daybreakMail.listAccounts(); - const accounts=data.accounts||[]; - const rows=accounts.map(account=>``).join(''); - root.innerHTML=``; - const close=()=>root.innerHTML=''; - root.querySelectorAll('.modal-close').forEach(button=>button.onclick=close); - root.querySelector('.modal-overlay').onclick=event=>{if(event.target.classList.contains('modal-overlay'))close()}; + const root=accountMailUi.select('#modal-root'); + try{ + const data=await window.daybreakMail.listAccounts(); + const accounts=data.accounts||[]; + const rows=accounts.map(account=>``).join(''); + root.innerHTML=``; + const close=()=>root.innerHTML=''; + root.querySelectorAll('.modal-close').forEach(button=>button.onclick=close); + root.querySelector('.modal-overlay').onclick=event=>{if(event.target.classList.contains('modal-overlay'))close()}; root.querySelector('#add-mail-account').onclick=()=>{close();accountMailUi.openMailAccount()}; - root.onclick=async event=>{ - const switchButton=event.target.closest('[data-switch-account]'); + root.onclick=async event=>{ + const switchButton=event.target.closest('[data-switch-account]'); if(switchButton){switchButton.disabled=true;try{accountMailUi.connectedAccount=await window.daybreakMail.selectAccount(switchButton.dataset.switchAccount);accountMailUi.state.activeFolder='Inbox';accountMailUi.setPageOffset(0);document.querySelectorAll('.folder').forEach(button=>button.classList.toggle('active',button.dataset.folder==='Inbox'));accountMailUi.select('#sidebar-title').textContent='Inbox';accountMailUi.select('#crumb-current').textContent='Inbox';accountMailUi.updateAccountCard(accountMailUi.connectedAccount);close();await accountMailUi.syncMailbox(true,{offset:0})}catch(error){accountMailUi.toast(error.message||'Could not switch accounts');switchButton.disabled=false}return} - const davButton=event.target.closest('[data-open-dav]'); + const davButton=event.target.closest('[data-open-dav]'); if(davButton){close();accountDavUi.openManager(davButton.dataset.openDav);return} - const editButton=event.target.closest('[data-edit-account]'); + const editButton=event.target.closest('[data-edit-account]'); if(editButton){const account=accounts.find(item=>item.id===editButton.dataset.editAccount);if(account)accountMailUi.openMailAccount(account);return} - const removeButton=event.target.closest('[data-remove-account]'); + const removeButton=event.target.closest('[data-remove-account]'); if(removeButton){const email=removeButton.closest('.account-row').querySelector('strong').textContent;if(!confirm(`Remove ${email} from this device?`))return;removeButton.disabled=true;try{const result=await window.daybreakMail.removeAccount(removeButton.dataset.removeAccount);const active=result.accounts.find(account=>account.id===result.activeId)||null;accountMailUi.connectedAccount=active;if(active){accountMailUi.updateAccountCard(active);close();accountMailUi.state.activeFolder='Inbox';accountMailUi.setPageOffset(0);await accountMailUi.syncMailbox(false,{offset:0})}else{accountMailUi.updateAccountCard({email:'Connect a mailbox',imapHost:''});accountMailUi.state.messages.splice(0,accountMailUi.state.messages.length);accountMailUi.renderList();accountMailUi.select('#reader-pane').innerHTML=accountMailUi.emptyReader();accountMailUi.toast('Mail account removed');openAccountManager()}}catch(error){accountMailUi.toast(error.message||'Could not remove the account');removeButton.disabled=false}return} - }; - }catch(error){accountMailUi.toast(error.message||'Could not load mail accounts')} -} - -document.addEventListener('click',event=>{const card=event.target.closest('#account-settings');if(!card)return;event.preventDefault();event.stopImmediatePropagation();openAccountManager()},true); + }; + }catch(error){accountMailUi.toast(error.message||'Could not load mail accounts')} +} + +document.addEventListener('click',event=>{const card=event.target.closest('#account-settings');if(!card)return;event.preventDefault();event.stopImmediatePropagation();openAccountManager()},true); document.addEventListener('keydown',event=>{const card=event.target.closest('#account-settings');if(!card||!['Enter',' '].includes(event.key))return;event.preventDefault();event.stopImmediatePropagation();openAccountManager()},true); })(); diff --git a/android/.gitignore b/android/.gitignore index 48354a3..07c6733 100644 --- a/android/.gitignore +++ b/android/.gitignore @@ -1,101 +1,101 @@ -# Using Android gitignore template: https://github.com/github/gitignore/blob/HEAD/Android.gitignore - -# Built application files -*.apk -*.aar -*.ap_ -*.aab - -# Files for the ART/Dalvik VM -*.dex - -# Java class files -*.class - -# Generated files -bin/ -gen/ -out/ -# Uncomment the following line in case you need and you don't have the release build type files in your app -# release/ - -# Gradle files -.gradle/ -build/ - -# Local configuration file (sdk path, etc) -local.properties - -# Proguard folder generated by Eclipse -proguard/ - -# Log Files -*.log - -# Android Studio Navigation editor temp files -.navigation/ - -# Android Studio captures folder -captures/ - -# IntelliJ -*.iml -.idea/workspace.xml -.idea/tasks.xml -.idea/gradle.xml -.idea/assetWizardSettings.xml -.idea/dictionaries -.idea/libraries -# Android Studio 3 in .gitignore file. -.idea/caches -.idea/modules.xml -# Comment next line if keeping position of elements in Navigation Editor is relevant for you -.idea/navEditor.xml - -# Keystore files -# Uncomment the following lines if you do not want to check your keystore files in. -#*.jks -#*.keystore - -# External native build folder generated in Android Studio 2.2 and later -.externalNativeBuild -.cxx/ - -# Google Services (e.g. APIs or Firebase) -# google-services.json - -# Freeline -freeline.py -freeline/ -freeline_project_description.json - -# fastlane -fastlane/report.xml -fastlane/Preview.html -fastlane/screenshots -fastlane/test_output -fastlane/readme.md - -# Version control -vcs.xml - -# lint -lint/intermediates/ -lint/generated/ -lint/outputs/ -lint/tmp/ -# lint/reports/ - -# Android Profiling -*.hprof - -# Cordova plugins for Capacitor -capacitor-cordova-android-plugins - -# Copied web assets -app/src/main/assets/public - -# Generated Config files -app/src/main/assets/capacitor.config.json -app/src/main/assets/capacitor.plugins.json -app/src/main/res/xml/config.xml +# Using Android gitignore template: https://github.com/github/gitignore/blob/HEAD/Android.gitignore + +# Built application files +*.apk +*.aar +*.ap_ +*.aab + +# Files for the ART/Dalvik VM +*.dex + +# Java class files +*.class + +# Generated files +bin/ +gen/ +out/ +# Uncomment the following line in case you need and you don't have the release build type files in your app +# release/ + +# Gradle files +.gradle/ +build/ + +# Local configuration file (sdk path, etc) +local.properties + +# Proguard folder generated by Eclipse +proguard/ + +# Log Files +*.log + +# Android Studio Navigation editor temp files +.navigation/ + +# Android Studio captures folder +captures/ + +# IntelliJ +*.iml +.idea/workspace.xml +.idea/tasks.xml +.idea/gradle.xml +.idea/assetWizardSettings.xml +.idea/dictionaries +.idea/libraries +# Android Studio 3 in .gitignore file. +.idea/caches +.idea/modules.xml +# Comment next line if keeping position of elements in Navigation Editor is relevant for you +.idea/navEditor.xml + +# Keystore files +# Uncomment the following lines if you do not want to check your keystore files in. +#*.jks +#*.keystore + +# External native build folder generated in Android Studio 2.2 and later +.externalNativeBuild +.cxx/ + +# Google Services (e.g. APIs or Firebase) +# google-services.json + +# Freeline +freeline.py +freeline/ +freeline_project_description.json + +# fastlane +fastlane/report.xml +fastlane/Preview.html +fastlane/screenshots +fastlane/test_output +fastlane/readme.md + +# Version control +vcs.xml + +# lint +lint/intermediates/ +lint/generated/ +lint/outputs/ +lint/tmp/ +# lint/reports/ + +# Android Profiling +*.hprof + +# Cordova plugins for Capacitor +capacitor-cordova-android-plugins + +# Copied web assets +app/src/main/assets/public + +# Generated Config files +app/src/main/assets/capacitor.config.json +app/src/main/assets/capacitor.plugins.json +app/src/main/res/xml/config.xml diff --git a/android/app/.gitignore b/android/app/.gitignore index 043df80..0e911e5 100644 --- a/android/app/.gitignore +++ b/android/app/.gitignore @@ -1,2 +1,2 @@ -/build/* -!/build/.npmkeep +/build/* +!/build/.npmkeep diff --git a/android/app/build.gradle b/android/app/build.gradle index 6fa9c30..7d5c5f7 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -1,78 +1,103 @@ -apply plugin: 'com.android.application' -apply plugin: 'org.jetbrains.kotlin.android' - +apply plugin: 'com.android.application' +apply plugin: 'org.jetbrains.kotlin.android' + def appVersion = new groovy.json.JsonSlurper().parse(file("../../package.json")).version def appVersionParts = appVersion.tokenize('.').collect { it.toInteger() } +def releaseStoreFile = System.getenv('EP_MAIL_ANDROID_STORE_FILE') +def releaseStorePassword = System.getenv('EP_MAIL_ANDROID_STORE_PASSWORD') +def releaseKeyAlias = System.getenv('EP_MAIL_ANDROID_KEY_ALIAS') +def releaseKeyPassword = System.getenv('EP_MAIL_ANDROID_KEY_PASSWORD') +def releaseSigningValues = [releaseStoreFile, releaseStorePassword, releaseKeyAlias, releaseKeyPassword] +def hasAnyReleaseSigningValue = releaseSigningValues.any { it != null && !it.isBlank() } +def hasCompleteReleaseSigning = releaseSigningValues.every { it != null && !it.isBlank() } -android { - namespace = "studio.daybreak.mail" - compileSdk = rootProject.ext.compileSdkVersion +if (hasAnyReleaseSigningValue && !hasCompleteReleaseSigning) { + throw new GradleException('Android release signing requires EP_MAIL_ANDROID_STORE_FILE, EP_MAIL_ANDROID_STORE_PASSWORD, EP_MAIL_ANDROID_KEY_ALIAS, and EP_MAIL_ANDROID_KEY_PASSWORD.') +} +if (hasCompleteReleaseSigning && !new File(releaseStoreFile).isAbsolute()) { + throw new GradleException('EP_MAIL_ANDROID_STORE_FILE must be an absolute path.') +} + +android { + namespace = "studio.daybreak.mail" + compileSdk = rootProject.ext.compileSdkVersion buildFeatures { buildConfig true } - packaging { - resources { - pickFirsts += "META-INF/NOTICE.md" - pickFirsts += "META-INF/LICENSE.md" + if (hasCompleteReleaseSigning) { + signingConfigs { + release { + storeFile file(releaseStoreFile) + storePassword releaseStorePassword + keyAlias releaseKeyAlias + keyPassword releaseKeyPassword + } } } - defaultConfig { - applicationId "studio.daybreak.mail" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - versionCode appVersionParts[0] * 10000 + appVersionParts[1] * 100 + appVersionParts[2] - versionName appVersion - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - aaptOptions { - // Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps. - // Default: https://android.googlesource.com/platform/frameworks/base/+/282e181b58cf72b6ca770dc7ca5f91f135444502/tools/aapt/AaptAssets.cpp#61 - ignoreAssetsPattern = '!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~' - } - } - buildTypes { + packaging { + resources { + pickFirsts += "META-INF/NOTICE.md" + pickFirsts += "META-INF/LICENSE.md" + } + } + defaultConfig { + applicationId "studio.daybreak.mail" + minSdkVersion rootProject.ext.minSdkVersion + targetSdkVersion rootProject.ext.targetSdkVersion + versionCode appVersionParts[0] * 10000 + appVersionParts[1] * 100 + appVersionParts[2] + versionName appVersion + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + aaptOptions { + // Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps. + // Default: https://android.googlesource.com/platform/frameworks/base/+/282e181b58cf72b6ca770dc7ca5f91f135444502/tools/aapt/AaptAssets.cpp#61 + ignoreAssetsPattern = '!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~' + } + } + buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + if (hasCompleteReleaseSigning) signingConfig signingConfigs.release } - } - compileOptions { - sourceCompatibility JavaVersion.VERSION_21 - targetCompatibility JavaVersion.VERSION_21 - } - kotlinOptions { - jvmTarget = '21' - } -} - -repositories { - flatDir{ - dirs '../capacitor-cordova-android-plugins/src/main/libs', 'libs' - } -} - -dependencies { - implementation fileTree(include: ['*.jar'], dir: 'libs') - implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion" - implementation "androidx.coordinatorlayout:coordinatorlayout:$androidxCoordinatorLayoutVersion" - implementation "androidx.core:core-splashscreen:$coreSplashScreenVersion" - implementation project(':capacitor-android') - implementation 'com.sun.mail:android-mail:1.6.7' - implementation 'com.sun.mail:android-activation:1.6.7' - implementation 'com.squareup.okhttp3:okhttp:4.12.0' - implementation 'androidx.work:work-runtime-ktx:2.10.1' - testImplementation "junit:junit:$junitVersion" - androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion" - androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion" - implementation project(':capacitor-cordova-android-plugins') -} - -apply from: 'capacitor.build.gradle' - -try { - def servicesJSON = file('google-services.json') - if (servicesJSON.text) { - apply plugin: 'com.google.gms.google-services' - } -} catch(Exception e) { - logger.info("google-services.json not found, google-services plugin not applied. Push Notifications won't work") -} + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_21 + targetCompatibility JavaVersion.VERSION_21 + } + kotlinOptions { + jvmTarget = '21' + } +} + +repositories { + flatDir{ + dirs '../capacitor-cordova-android-plugins/src/main/libs', 'libs' + } +} + +dependencies { + implementation fileTree(include: ['*.jar'], dir: 'libs') + implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion" + implementation "androidx.coordinatorlayout:coordinatorlayout:$androidxCoordinatorLayoutVersion" + implementation "androidx.core:core-splashscreen:$coreSplashScreenVersion" + implementation project(':capacitor-android') + implementation 'com.sun.mail:android-mail:1.6.7' + implementation 'com.sun.mail:android-activation:1.6.7' + implementation 'com.squareup.okhttp3:okhttp:4.12.0' + implementation 'androidx.work:work-runtime-ktx:2.10.1' + testImplementation "junit:junit:$junitVersion" + androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion" + androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion" + implementation project(':capacitor-cordova-android-plugins') +} + +apply from: 'capacitor.build.gradle' + +try { + def servicesJSON = file('google-services.json') + if (servicesJSON.text) { + apply plugin: 'com.google.gms.google-services' + } +} catch(Exception e) { + logger.info("google-services.json not found, google-services plugin not applied. Push Notifications won't work") +} diff --git a/android/app/proguard-rules.pro b/android/app/proguard-rules.pro index f1b4245..6e7ffa9 100644 --- a/android/app/proguard-rules.pro +++ b/android/app/proguard-rules.pro @@ -1,21 +1,21 @@ -# Add project specific ProGuard rules here. -# You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} - -# Uncomment this to preserve the line number information for -# debugging stack traces. -#-keepattributes SourceFile,LineNumberTable - -# If you keep the line number information, uncomment this to -# hide the original source file name. -#-renamesourcefileattribute SourceFile +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/android/app/src/androidTest/java/com/getcapacitor/myapp/ExampleInstrumentedTest.java b/android/app/src/androidTest/java/com/getcapacitor/myapp/ExampleInstrumentedTest.java index f2c2217..28dd9e9 100644 --- a/android/app/src/androidTest/java/com/getcapacitor/myapp/ExampleInstrumentedTest.java +++ b/android/app/src/androidTest/java/com/getcapacitor/myapp/ExampleInstrumentedTest.java @@ -1,26 +1,26 @@ -package com.getcapacitor.myapp; - -import static org.junit.Assert.*; - -import android.content.Context; -import androidx.test.ext.junit.runners.AndroidJUnit4; -import androidx.test.platform.app.InstrumentationRegistry; -import org.junit.Test; -import org.junit.runner.RunWith; - -/** - * Instrumented test, which will execute on an Android device. - * - * @see Testing documentation - */ -@RunWith(AndroidJUnit4.class) -public class ExampleInstrumentedTest { - - @Test - public void useAppContext() throws Exception { - // Context of the app under test. - Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); - - assertEquals("com.getcapacitor.app", appContext.getPackageName()); - } -} +package com.getcapacitor.myapp; + +import static org.junit.Assert.*; + +import android.content.Context; +import androidx.test.ext.junit.runners.AndroidJUnit4; +import androidx.test.platform.app.InstrumentationRegistry; +import org.junit.Test; +import org.junit.runner.RunWith; + +/** + * Instrumented test, which will execute on an Android device. + * + * @see Testing documentation + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + + @Test + public void useAppContext() throws Exception { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); + + assertEquals("com.getcapacitor.app", appContext.getPackageName()); + } +} diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 5377c57..91c0e95 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -1,48 +1,41 @@ - - - - - - - - - + + + + + + + + - - - - - - - - - - - - - - - - - - + android:dataExtractionRules="@xml/data_extraction_rules" + android:usesCleartextTraffic="false" + android:icon="@mipmap/ic_launcher" + android:label="@string/app_name" + android:roundIcon="@mipmap/ic_launcher_round" + android:supportsRtl="true" + android:theme="@style/AppTheme"> + + + + + + + + + + + + + + + diff --git a/android/app/src/main/java/studio/daybreak/mail/AndroidAccountVault.kt b/android/app/src/main/java/studio/daybreak/mail/AndroidAccountVault.kt index e9f9338..ea6b7b1 100644 --- a/android/app/src/main/java/studio/daybreak/mail/AndroidAccountVault.kt +++ b/android/app/src/main/java/studio/daybreak/mail/AndroidAccountVault.kt @@ -1,540 +1,540 @@ -package studio.daybreak.mail - -import android.content.Context -import android.security.keystore.KeyGenParameterSpec -import android.security.keystore.KeyProperties -import android.util.Base64 -import org.json.JSONArray -import org.json.JSONObject -import java.security.KeyStore -import java.text.SimpleDateFormat -import java.util.Calendar -import java.util.Locale -import javax.crypto.Cipher -import javax.crypto.KeyGenerator -import javax.crypto.SecretKey -import javax.crypto.spec.GCMParameterSpec - -internal object AndroidAccountVault { - private const val KEY_ALIAS = "ep-mail-account-key" - private const val PREFS_NAME = "ep-mail-secure-store" - private const val ENCRYPTED_VALUE = "encrypted-data" - private const val GCM_TAG_BITS = 128 - - @Volatile private var appContext: Context? = null - - fun initialize(context: Context) { - appContext = context.applicationContext - secretKey() - } - - @Synchronized - fun read(): JSONObject { - val context = requireContext() - val encoded = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE) - .getString(ENCRYPTED_VALUE, null) ?: return emptyStore() - val payload = Base64.decode(encoded, Base64.NO_WRAP) - require(payload.size > 12) { "Encrypted account data is invalid." } - val iv = payload.copyOfRange(0, 12) - val encrypted = payload.copyOfRange(12, payload.size) - val cipher = Cipher.getInstance("AES/GCM/NoPadding") - cipher.init(Cipher.DECRYPT_MODE, secretKey(), GCMParameterSpec(GCM_TAG_BITS, iv)) - return JSONObject(String(cipher.doFinal(encrypted), Charsets.UTF_8)) - } - - @Synchronized - fun write(store: JSONObject) { - val cipher = Cipher.getInstance("AES/GCM/NoPadding") - cipher.init(Cipher.ENCRYPT_MODE, secretKey()) - val encrypted = cipher.doFinal(store.toString().toByteArray(Charsets.UTF_8)) - val payload = cipher.iv + encrypted - val saved = requireContext().getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE) - .edit() - .putString(ENCRYPTED_VALUE, Base64.encodeToString(payload, Base64.NO_WRAP)) - .commit() - check(saved) { "Could not save encrypted account data." } - } - - fun accounts(): JSONArray = read().optJSONArray("accounts") ?: JSONArray() - - fun account(id: String? = null): JSONObject? { - val store = read() - val accounts = store.optJSONArray("accounts") ?: return null - val selectedId = id ?: store.optString("activeId") - for (index in 0 until accounts.length()) { - val account = accounts.getJSONObject(index) - if (account.optString("id") == selectedId) return account - } - return null - } - - @Synchronized - fun saveAccount(account: JSONObject): JSONObject { - val store = read() - val accounts = store.optJSONArray("accounts") ?: JSONArray() - val updated = JSONArray() - var saved: JSONObject? = null - for (index in 0 until accounts.length()) { - val previous = accounts.getJSONObject(index) - val same = previous.optString("email").equals(account.optString("email"), true) && - previous.optString("imapHost").equals(account.optString("imapHost"), true) - if (same || previous.optString("id") == account.optString("id")) { - val merged = JSONObject(previous.toString()) - val keys = account.keys() - while (keys.hasNext()) { - val key = keys.next() - merged.put(key, account.get(key)) - } - saved = merged - updated.put(merged) - } else { - updated.put(previous) - } - } - if (saved == null) { - saved = JSONObject(account.toString()) - updated.put(saved) - } - store.put("accounts", updated) - store.put("activeId", saved.optString("id")) - write(store) - return saved - } - - @Synchronized - fun removeAccount(id: String?): JSONObject { - val store = read() - val accounts = store.optJSONArray("accounts") ?: JSONArray() - val kept = JSONArray() - for (index in 0 until accounts.length()) { - val account = accounts.getJSONObject(index) - if (account.optString("id") != id) kept.put(account) - } - val activeId = if (store.optString("activeId") == id) { - kept.optJSONObject(0)?.optString("id") ?: "" - } else store.optString("activeId") - store.put("accounts", kept) - store.put("activeId", activeId) - write(store) - return JSONObject().put("accounts", publicAccounts(kept)).put("activeId", activeId) - } - - @Synchronized - fun updateInboxCursor(id: String, uidValidity: Long, lastUid: Long) { - val store = read() - val accounts = store.optJSONArray("accounts") ?: return - for (index in 0 until accounts.length()) { - val account = accounts.getJSONObject(index) - if (account.optString("id") == id) { - account.put("androidInboxSyncState", JSONObject() - .put("uidValidity", uidValidity) - .put("lastUid", lastUid)) - write(store) - return - } - } - } - - @Synchronized - fun setSnooze(id: String, uid: Long, folder: String, dueAt: Long?, subject: String) { - val store = read() - val accounts = store.optJSONArray("accounts") ?: return - for (index in 0 until accounts.length()) { - val account = accounts.getJSONObject(index) - if (account.optString("id") != id) continue - val previous = account.optJSONArray("snoozedMessages") ?: JSONArray() - val updated = JSONArray() - for (itemIndex in 0 until previous.length()) { - val item = previous.getJSONObject(itemIndex) - if (item.optLong("uid") != uid || item.optString("folder") != folder) updated.put(item) - } - if (dueAt != null) { - updated.put(JSONObject() - .put("uid", uid) - .put("folder", folder) - .put("dueAt", dueAt) - .put("subject", subject.take(200))) - } - account.put("snoozedMessages", updated) - write(store) - return - } - } - - @Synchronized - fun takeDueSnoozes(id: String, now: Long): JSONArray { - val store = read() - val accounts = store.optJSONArray("accounts") ?: return JSONArray() - for (index in 0 until accounts.length()) { - val account = accounts.getJSONObject(index) - if (account.optString("id") != id) continue - val previous = account.optJSONArray("snoozedMessages") ?: JSONArray() - val remaining = JSONArray() - val due = JSONArray() - for (itemIndex in 0 until previous.length()) { - val item = previous.getJSONObject(itemIndex) - if (item.optLong("dueAt") <= now) { - due.put(JSONObject(item.toString()) - .put("accountId", id) - .put("email", account.optString("email"))) - } else { - remaining.put(item) - } - } - if (due.length() > 0) { - account.put("snoozedMessages", remaining) - write(store) - } - return due - } - return JSONArray() - } - - @Synchronized - fun addRuleLabel(id: String, folder: String, uid: Long, label: String) { - val store = read() - val accounts = store.optJSONArray("accounts") ?: return - for (index in 0 until accounts.length()) { - val account = accounts.getJSONObject(index) - if (account.optString("id") != id) continue - val labels = account.optJSONObject("ruleLabels") ?: JSONObject() - val key = "$folder:$uid" - val values = labels.optJSONArray(key) ?: JSONArray() - if ((0 until values.length()).none { values.optString(it) == label }) values.put(label) - labels.put(key, values) - account.put("ruleLabels", labels) - write(store) - return - } - } - - @Synchronized - fun cacheMessages(id: String, folder: String, messages: JSONArray) { - val store = read() - val accounts = store.optJSONArray("accounts") ?: return - for (index in 0 until accounts.length()) { - val account = accounts.getJSONObject(index) - if (account.optString("id") != id) continue - val cache = account.optJSONObject("mailCache") ?: JSONObject() - val previous = cache.optJSONArray(folder) ?: JSONArray() - val merged = LinkedHashMap() - for (itemIndex in 0 until previous.length()) { - val item = previous.optJSONObject(itemIndex) ?: continue - merged[item.optString("uid", item.optString("id"))] = item - } - for (itemIndex in 0 until messages.length()) { - val item = messages.optJSONObject(itemIndex) ?: continue - merged[item.optString("uid", item.optString("id"))] = item - } - cache.put(folder, JSONArray().apply { - merged.values.toList().takeLast(30).forEach { put(it) } - }) - account.put("mailCache", cache) - write(store) - return - } - } - - fun cachedFolder(id: String, folder: String, offset: Int, filters: JSONObject = JSONObject()): JSONObject? { - val account = account(id) ?: return null - val cached = account.optJSONObject("mailCache")?.optJSONArray(folder) ?: return null - val matched = (0 until cached.length()).mapNotNull { cached.optJSONObject(it) } - .filter { matchesFilters(it, filters) } - .sortedByDescending { it.optLong("timestamp") } - val start = offset.coerceAtLeast(0) - val page = matched.drop(start).take(20) - if (page.isEmpty() && matched.isEmpty()) return null - return JSONObject() - .put("messages", JSONArray().apply { page.forEach(::put) }) - .put("total", matched.size) - .put("start", if (matched.isEmpty()) 0 else start + 1) - .put("end", start + page.size) - .put("folder", folder) - .put("offline", true) - } - - private fun matchesFilters(message: JSONObject, filters: JSONObject): Boolean { - val query = filters.optString("query").trim().lowercase(Locale.ROOT) - val senderFilter = filters.optString("sender").trim().lowercase(Locale.ROOT) - val subjectFilter = filters.optString("subject").trim().lowercase(Locale.ROOT) - val sender = "${message.optString("sender")} ${message.optString("email")}".lowercase(Locale.ROOT) - val subject = message.optString("subject").lowercase(Locale.ROOT) - val attachments = message.optJSONArray("attachments") - val haystack = "$sender $subject ${message.optString("snippet")} ${message.optJSONArray("body")?.toString().orEmpty()}".lowercase(Locale.ROOT) - val timestamp = message.optLong("timestamp") - val after = dateBoundary(filters.optString("after"), false) - val before = dateBoundary(filters.optString("before"), true) - return (query.isBlank() || query.split(Regex("\\s+")).all(haystack::contains)) && - (senderFilter.isBlank() || sender.contains(senderFilter)) && - (subjectFilter.isBlank() || subject.contains(subjectFilter)) && - (after == null || timestamp >= after) && (before == null || timestamp <= before) && - (!filters.optBoolean("hasAttachments") || (attachments?.length() ?: 0) > 0) - } - - private fun dateBoundary(value: String, endOfDay: Boolean): Long? { - if (value.isBlank()) return null - val parsed = runCatching { SimpleDateFormat("yyyy-MM-dd", Locale.ROOT).parse(value) }.getOrNull() ?: return null - val calendar = Calendar.getInstance().apply { time = parsed } - if (endOfDay) { - calendar.add(Calendar.DAY_OF_MONTH, 1) - return calendar.timeInMillis - 1 - } - return calendar.timeInMillis - } - - @Synchronized - fun saveDraft(id: String, draft: JSONObject) { - val store = read() - val accounts = store.optJSONArray("accounts") ?: return - for (index in 0 until accounts.length()) { - val account = accounts.getJSONObject(index) - if (account.optString("id") != id) continue - val drafts = account.optJSONArray("drafts") ?: JSONArray() - val updated = JSONArray().put(JSONObject(draft.toString())) - for (draftIndex in 0 until drafts.length()) { - val current = drafts.optJSONObject(draftIndex) ?: continue - if (current.optString("id") != draft.optString("id")) updated.put(current) - } - account.put("drafts", updated) - write(store) - return - } - } - - @Synchronized - fun deleteDraft(id: String, draftId: String) { - val store = read() - val accounts = store.optJSONArray("accounts") ?: return - for (index in 0 until accounts.length()) { - val account = accounts.getJSONObject(index) - if (account.optString("id") != id) continue - val drafts = account.optJSONArray("drafts") ?: JSONArray() - account.put("drafts", JSONArray().apply { - for (draftIndex in 0 until drafts.length()) { - val draft = drafts.optJSONObject(draftIndex) ?: continue - if (draft.optString("id") != draftId) put(draft) - } - }) - write(store) - return - } - } - - @Synchronized - fun enqueueMailOperation(id: String, operation: JSONObject) { - val store = read() - val accounts = store.optJSONArray("accounts") ?: return - for (index in 0 until accounts.length()) { - val account = accounts.getJSONObject(index) - if (account.optString("id") != id) continue - val previous = account.optJSONArray("mailOutbox") ?: JSONArray() - val data = operation.optJSONObject("data") - val queue = JSONArray() - for (index in 0 until previous.length()) { - val existing = previous.optJSONObject(index) ?: continue - val existingData = existing.optJSONObject("data") - if (existingData == null) { - queue.put(existing) - continue - } - val duplicate = operation.optString("type") == "action" && existing.optString("type") == "action" && - existingData.optLong("uid") == data?.optLong("uid") && - existingData.optString("folder") == data?.optString("folder") && - existingData.optString("action") == data?.optString("action") - if (!duplicate) queue.put(existing) - } - queue.put(JSONObject(operation.toString())) - account.put("mailOutbox", queue) - if (operation.optString("type") == "action" && data != null) applyQueuedActionToCache(account, data) - write(store) - return - } - } - - private fun applyQueuedActionToCache(account: JSONObject, input: JSONObject) { - val cache = account.optJSONObject("mailCache") ?: return - val sourceName = input.optString("folder", "Inbox") - val source = cache.optJSONArray(sourceName) ?: return - val uid = input.optLong("uid") - val action = input.optString("action") - val updatedSource = JSONArray() - var moved: JSONObject? = null - for (index in 0 until source.length()) { - val message = source.optJSONObject(index) ?: continue - if (message.optLong("uid", message.optLong("id")) != uid) { - updatedSource.put(message) - continue - } - when (action) { - "star" -> { - message.put("star", input.optBoolean("enabled")) - updatedSource.put(message) - } - "unread" -> { - message.put("unread", input.optBoolean("enabled")) - updatedSource.put(message) - } - "archive", "delete", "inbox" -> moved = message - else -> updatedSource.put(message) - } - } - cache.put(sourceName, updatedSource) - val destinationName = when (action) { - "archive" -> "Archive" - "delete" -> "Trash" - "inbox" -> "Inbox" - else -> null - } - if (moved == null || destinationName == null) return - moved!!.put("sourceFolder", destinationName) - .put("archived", destinationName == "Archive") - .put("deleted", destinationName == "Trash") - val destination = cache.optJSONArray(destinationName) ?: JSONArray() - val merged = (0 until destination.length()).mapNotNull { destination.optJSONObject(it) } - .filter { it.optLong("uid", it.optLong("id")) != uid } + moved!! - cache.put(destinationName, JSONArray().apply { merged.takeLast(30).forEach { put(it) } }) - } - - @Synchronized - fun pendingMailOperations(id: String): JSONArray = account(id)?.optJSONArray("mailOutbox") ?: JSONArray() - - @Synchronized - fun removeMailOperation(id: String, operationId: String) { - val store = read() - val accounts = store.optJSONArray("accounts") ?: return - for (index in 0 until accounts.length()) { - val account = accounts.getJSONObject(index) - if (account.optString("id") != id) continue - val queue = account.optJSONArray("mailOutbox") ?: JSONArray() - account.put("mailOutbox", JSONArray().apply { - for (queueIndex in 0 until queue.length()) { - val operation = queue.optJSONObject(queueIndex) ?: continue - if (operation.optString("id") != operationId) put(operation) - } - }) - write(store) - return - } - } - - fun publicAccounts(accounts: JSONArray = this.accounts()): JSONArray { - val result = JSONArray() - for (index in 0 until accounts.length()) { - val account = accounts.getJSONObject(index) - result.put(publicAccount(account)) - } - return result - } - - fun publicAccount(account: JSONObject): JSONObject = JSONObject() - .put("id", account.optString("id")) - .put("email", account.optString("email")) - .put("displayName", account.optString("displayName")) - .put("imapHost", account.optString("imapHost")) - .put("smtpHost", account.optString("smtpHost")) - .put("signature", account.optString("signature")) - .put("notificationsEnabled", account.optBoolean("notificationsEnabled", true)) - .put("syncIntervalMinutes", account.optInt("syncIntervalMinutes", 2)) - .put("rules", account.optJSONArray("rules") ?: JSONArray()) - - fun storeDav(type: String): JSONArray = read().optJSONArray(type) ?: JSONArray() - - fun putDavAccount(type: String, account: JSONObject): JSONObject { - val store = read() - val accounts = store.optJSONArray(type) ?: JSONArray() - val updated = JSONArray() - var saved: JSONObject? = null - for (index in 0 until accounts.length()) { - val previous = accounts.getJSONObject(index) - if (previous.optString("serverUrl") == account.optString("serverUrl") && - previous.optString("username").equals(account.optString("username"), true)) { - val merged = JSONObject(account.toString()).put("id", previous.optString("id")) - updated.put(merged) - saved = merged - } else { - updated.put(previous) - } - } - if (saved == null) { - saved = JSONObject(account.toString()) - updated.put(saved) - } - store.put(type, updated) - store.put(if (type == "caldav") "activeCaldavId" else "activeCarddavId", saved.optString("id")) - write(store) - return saved - } - - fun activeDav(type: String, id: String? = null): JSONObject? { - val store = read() - val accounts = store.optJSONArray(type) ?: return null - val selectedId = id ?: store.optString(if (type == "caldav") "activeCaldavId" else "activeCarddavId") - for (index in 0 until accounts.length()) { - val account = accounts.getJSONObject(index) - if (account.optString("id") == selectedId) return account - } - return null - } - - fun publicDavAccounts(type: String): JSONArray { - val result = JSONArray() - val accounts = storeDav(type) - for (index in 0 until accounts.length()) { - val account = accounts.getJSONObject(index) - result.put(JSONObject() - .put("id", account.optString("id")) - .put("serverUrl", account.optString("serverUrl")) - .put("username", account.optString("username")) - .put("collections", account.optJSONArray("collections") ?: JSONArray())) - } - return result - } - - fun removeDavAccount(type: String, id: String): JSONObject { - val store = read() - val accounts = store.optJSONArray(type) ?: JSONArray() - val remaining = JSONArray() - for (index in 0 until accounts.length()) { - val account = accounts.getJSONObject(index) - if (account.optString("id") != id) remaining.put(account) - } - val activeKey = if (type == "caldav") "activeCaldavId" else "activeCarddavId" - val activeId = if (store.optString(activeKey) == id) { - remaining.optJSONObject(0)?.optString("id") ?: "" - } else store.optString(activeKey) - store.put(type, remaining) - store.put(activeKey, activeId) - write(store) - return JSONObject().put("accounts", publicDavAccounts(type)).put("activeId", activeId) - } - - private fun emptyStore() = JSONObject() - .put("accounts", JSONArray()) - .put("activeId", "") - .put("caldav", JSONArray()) - .put("carddav", JSONArray()) - .put("activeCaldavId", "") - .put("activeCarddavId", "") - - private fun requireContext(): Context = - appContext ?: throw IllegalStateException("Encrypted account storage is not initialized.") - - @Synchronized - private fun secretKey(): SecretKey { - val keyStore = KeyStore.getInstance("AndroidKeyStore").apply { load(null) } - (keyStore.getKey(KEY_ALIAS, null) as? SecretKey)?.let { return it } - val generator = KeyGenerator.getInstance(KeyProperties.KEY_ALGORITHM_AES, "AndroidKeyStore") - generator.init( - KeyGenParameterSpec.Builder( - KEY_ALIAS, - KeyProperties.PURPOSE_ENCRYPT or KeyProperties.PURPOSE_DECRYPT - ) - .setBlockModes(KeyProperties.BLOCK_MODE_GCM) - .setEncryptionPaddings(KeyProperties.ENCRYPTION_PADDING_NONE) - .setKeySize(256) - .setRandomizedEncryptionRequired(true) - .build() - ) - return generator.generateKey() - } -} +package studio.daybreak.mail + +import android.content.Context +import android.security.keystore.KeyGenParameterSpec +import android.security.keystore.KeyProperties +import android.util.Base64 +import org.json.JSONArray +import org.json.JSONObject +import java.security.KeyStore +import java.text.SimpleDateFormat +import java.util.Calendar +import java.util.Locale +import javax.crypto.Cipher +import javax.crypto.KeyGenerator +import javax.crypto.SecretKey +import javax.crypto.spec.GCMParameterSpec + +internal object AndroidAccountVault { + private const val KEY_ALIAS = "ep-mail-account-key" + private const val PREFS_NAME = "ep-mail-secure-store" + private const val ENCRYPTED_VALUE = "encrypted-data" + private const val GCM_TAG_BITS = 128 + + @Volatile private var appContext: Context? = null + + fun initialize(context: Context) { + appContext = context.applicationContext + secretKey() + } + + @Synchronized + fun read(): JSONObject { + val context = requireContext() + val encoded = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE) + .getString(ENCRYPTED_VALUE, null) ?: return emptyStore() + val payload = Base64.decode(encoded, Base64.NO_WRAP) + require(payload.size > 12) { "Encrypted account data is invalid." } + val iv = payload.copyOfRange(0, 12) + val encrypted = payload.copyOfRange(12, payload.size) + val cipher = Cipher.getInstance("AES/GCM/NoPadding") + cipher.init(Cipher.DECRYPT_MODE, secretKey(), GCMParameterSpec(GCM_TAG_BITS, iv)) + return JSONObject(String(cipher.doFinal(encrypted), Charsets.UTF_8)) + } + + @Synchronized + fun write(store: JSONObject) { + val cipher = Cipher.getInstance("AES/GCM/NoPadding") + cipher.init(Cipher.ENCRYPT_MODE, secretKey()) + val encrypted = cipher.doFinal(store.toString().toByteArray(Charsets.UTF_8)) + val payload = cipher.iv + encrypted + val saved = requireContext().getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE) + .edit() + .putString(ENCRYPTED_VALUE, Base64.encodeToString(payload, Base64.NO_WRAP)) + .commit() + check(saved) { "Could not save encrypted account data." } + } + + fun accounts(): JSONArray = read().optJSONArray("accounts") ?: JSONArray() + + fun account(id: String? = null): JSONObject? { + val store = read() + val accounts = store.optJSONArray("accounts") ?: return null + val selectedId = id ?: store.optString("activeId") + for (index in 0 until accounts.length()) { + val account = accounts.getJSONObject(index) + if (account.optString("id") == selectedId) return account + } + return null + } + + @Synchronized + fun saveAccount(account: JSONObject): JSONObject { + val store = read() + val accounts = store.optJSONArray("accounts") ?: JSONArray() + val updated = JSONArray() + var saved: JSONObject? = null + for (index in 0 until accounts.length()) { + val previous = accounts.getJSONObject(index) + val same = previous.optString("email").equals(account.optString("email"), true) && + previous.optString("imapHost").equals(account.optString("imapHost"), true) + if (same || previous.optString("id") == account.optString("id")) { + val merged = JSONObject(previous.toString()) + val keys = account.keys() + while (keys.hasNext()) { + val key = keys.next() + merged.put(key, account.get(key)) + } + saved = merged + updated.put(merged) + } else { + updated.put(previous) + } + } + if (saved == null) { + saved = JSONObject(account.toString()) + updated.put(saved) + } + store.put("accounts", updated) + store.put("activeId", saved.optString("id")) + write(store) + return saved + } + + @Synchronized + fun removeAccount(id: String?): JSONObject { + val store = read() + val accounts = store.optJSONArray("accounts") ?: JSONArray() + val kept = JSONArray() + for (index in 0 until accounts.length()) { + val account = accounts.getJSONObject(index) + if (account.optString("id") != id) kept.put(account) + } + val activeId = if (store.optString("activeId") == id) { + kept.optJSONObject(0)?.optString("id") ?: "" + } else store.optString("activeId") + store.put("accounts", kept) + store.put("activeId", activeId) + write(store) + return JSONObject().put("accounts", publicAccounts(kept)).put("activeId", activeId) + } + + @Synchronized + fun updateInboxCursor(id: String, uidValidity: Long, lastUid: Long) { + val store = read() + val accounts = store.optJSONArray("accounts") ?: return + for (index in 0 until accounts.length()) { + val account = accounts.getJSONObject(index) + if (account.optString("id") == id) { + account.put("androidInboxSyncState", JSONObject() + .put("uidValidity", uidValidity) + .put("lastUid", lastUid)) + write(store) + return + } + } + } + + @Synchronized + fun setSnooze(id: String, uid: Long, folder: String, dueAt: Long?, subject: String) { + val store = read() + val accounts = store.optJSONArray("accounts") ?: return + for (index in 0 until accounts.length()) { + val account = accounts.getJSONObject(index) + if (account.optString("id") != id) continue + val previous = account.optJSONArray("snoozedMessages") ?: JSONArray() + val updated = JSONArray() + for (itemIndex in 0 until previous.length()) { + val item = previous.getJSONObject(itemIndex) + if (item.optLong("uid") != uid || item.optString("folder") != folder) updated.put(item) + } + if (dueAt != null) { + updated.put(JSONObject() + .put("uid", uid) + .put("folder", folder) + .put("dueAt", dueAt) + .put("subject", subject.take(200))) + } + account.put("snoozedMessages", updated) + write(store) + return + } + } + + @Synchronized + fun takeDueSnoozes(id: String, now: Long): JSONArray { + val store = read() + val accounts = store.optJSONArray("accounts") ?: return JSONArray() + for (index in 0 until accounts.length()) { + val account = accounts.getJSONObject(index) + if (account.optString("id") != id) continue + val previous = account.optJSONArray("snoozedMessages") ?: JSONArray() + val remaining = JSONArray() + val due = JSONArray() + for (itemIndex in 0 until previous.length()) { + val item = previous.getJSONObject(itemIndex) + if (item.optLong("dueAt") <= now) { + due.put(JSONObject(item.toString()) + .put("accountId", id) + .put("email", account.optString("email"))) + } else { + remaining.put(item) + } + } + if (due.length() > 0) { + account.put("snoozedMessages", remaining) + write(store) + } + return due + } + return JSONArray() + } + + @Synchronized + fun addRuleLabel(id: String, folder: String, uid: Long, label: String) { + val store = read() + val accounts = store.optJSONArray("accounts") ?: return + for (index in 0 until accounts.length()) { + val account = accounts.getJSONObject(index) + if (account.optString("id") != id) continue + val labels = account.optJSONObject("ruleLabels") ?: JSONObject() + val key = "$folder:$uid" + val values = labels.optJSONArray(key) ?: JSONArray() + if ((0 until values.length()).none { values.optString(it) == label }) values.put(label) + labels.put(key, values) + account.put("ruleLabels", labels) + write(store) + return + } + } + + @Synchronized + fun cacheMessages(id: String, folder: String, messages: JSONArray) { + val store = read() + val accounts = store.optJSONArray("accounts") ?: return + for (index in 0 until accounts.length()) { + val account = accounts.getJSONObject(index) + if (account.optString("id") != id) continue + val cache = account.optJSONObject("mailCache") ?: JSONObject() + val previous = cache.optJSONArray(folder) ?: JSONArray() + val merged = LinkedHashMap() + for (itemIndex in 0 until previous.length()) { + val item = previous.optJSONObject(itemIndex) ?: continue + merged[item.optString("uid", item.optString("id"))] = item + } + for (itemIndex in 0 until messages.length()) { + val item = messages.optJSONObject(itemIndex) ?: continue + merged[item.optString("uid", item.optString("id"))] = item + } + cache.put(folder, JSONArray().apply { + merged.values.toList().takeLast(30).forEach { put(it) } + }) + account.put("mailCache", cache) + write(store) + return + } + } + + fun cachedFolder(id: String, folder: String, offset: Int, filters: JSONObject = JSONObject()): JSONObject? { + val account = account(id) ?: return null + val cached = account.optJSONObject("mailCache")?.optJSONArray(folder) ?: return null + val matched = (0 until cached.length()).mapNotNull { cached.optJSONObject(it) } + .filter { matchesFilters(it, filters) } + .sortedByDescending { it.optLong("timestamp") } + val start = offset.coerceAtLeast(0) + val page = matched.drop(start).take(20) + if (page.isEmpty() && matched.isEmpty()) return null + return JSONObject() + .put("messages", JSONArray().apply { page.forEach(::put) }) + .put("total", matched.size) + .put("start", if (matched.isEmpty()) 0 else start + 1) + .put("end", start + page.size) + .put("folder", folder) + .put("offline", true) + } + + private fun matchesFilters(message: JSONObject, filters: JSONObject): Boolean { + val query = filters.optString("query").trim().lowercase(Locale.ROOT) + val senderFilter = filters.optString("sender").trim().lowercase(Locale.ROOT) + val subjectFilter = filters.optString("subject").trim().lowercase(Locale.ROOT) + val sender = "${message.optString("sender")} ${message.optString("email")}".lowercase(Locale.ROOT) + val subject = message.optString("subject").lowercase(Locale.ROOT) + val attachments = message.optJSONArray("attachments") + val haystack = "$sender $subject ${message.optString("snippet")} ${message.optJSONArray("body")?.toString().orEmpty()}".lowercase(Locale.ROOT) + val timestamp = message.optLong("timestamp") + val after = dateBoundary(filters.optString("after"), false) + val before = dateBoundary(filters.optString("before"), true) + return (query.isBlank() || query.split(Regex("\\s+")).all(haystack::contains)) && + (senderFilter.isBlank() || sender.contains(senderFilter)) && + (subjectFilter.isBlank() || subject.contains(subjectFilter)) && + (after == null || timestamp >= after) && (before == null || timestamp <= before) && + (!filters.optBoolean("hasAttachments") || (attachments?.length() ?: 0) > 0) + } + + private fun dateBoundary(value: String, endOfDay: Boolean): Long? { + if (value.isBlank()) return null + val parsed = runCatching { SimpleDateFormat("yyyy-MM-dd", Locale.ROOT).parse(value) }.getOrNull() ?: return null + val calendar = Calendar.getInstance().apply { time = parsed } + if (endOfDay) { + calendar.add(Calendar.DAY_OF_MONTH, 1) + return calendar.timeInMillis - 1 + } + return calendar.timeInMillis + } + + @Synchronized + fun saveDraft(id: String, draft: JSONObject) { + val store = read() + val accounts = store.optJSONArray("accounts") ?: return + for (index in 0 until accounts.length()) { + val account = accounts.getJSONObject(index) + if (account.optString("id") != id) continue + val drafts = account.optJSONArray("drafts") ?: JSONArray() + val updated = JSONArray().put(JSONObject(draft.toString())) + for (draftIndex in 0 until drafts.length()) { + val current = drafts.optJSONObject(draftIndex) ?: continue + if (current.optString("id") != draft.optString("id")) updated.put(current) + } + account.put("drafts", updated) + write(store) + return + } + } + + @Synchronized + fun deleteDraft(id: String, draftId: String) { + val store = read() + val accounts = store.optJSONArray("accounts") ?: return + for (index in 0 until accounts.length()) { + val account = accounts.getJSONObject(index) + if (account.optString("id") != id) continue + val drafts = account.optJSONArray("drafts") ?: JSONArray() + account.put("drafts", JSONArray().apply { + for (draftIndex in 0 until drafts.length()) { + val draft = drafts.optJSONObject(draftIndex) ?: continue + if (draft.optString("id") != draftId) put(draft) + } + }) + write(store) + return + } + } + + @Synchronized + fun enqueueMailOperation(id: String, operation: JSONObject) { + val store = read() + val accounts = store.optJSONArray("accounts") ?: return + for (index in 0 until accounts.length()) { + val account = accounts.getJSONObject(index) + if (account.optString("id") != id) continue + val previous = account.optJSONArray("mailOutbox") ?: JSONArray() + val data = operation.optJSONObject("data") + val queue = JSONArray() + for (index in 0 until previous.length()) { + val existing = previous.optJSONObject(index) ?: continue + val existingData = existing.optJSONObject("data") + if (existingData == null) { + queue.put(existing) + continue + } + val duplicate = operation.optString("type") == "action" && existing.optString("type") == "action" && + existingData.optLong("uid") == data?.optLong("uid") && + existingData.optString("folder") == data?.optString("folder") && + existingData.optString("action") == data?.optString("action") + if (!duplicate) queue.put(existing) + } + queue.put(JSONObject(operation.toString())) + account.put("mailOutbox", queue) + if (operation.optString("type") == "action" && data != null) applyQueuedActionToCache(account, data) + write(store) + return + } + } + + private fun applyQueuedActionToCache(account: JSONObject, input: JSONObject) { + val cache = account.optJSONObject("mailCache") ?: return + val sourceName = input.optString("folder", "Inbox") + val source = cache.optJSONArray(sourceName) ?: return + val uid = input.optLong("uid") + val action = input.optString("action") + val updatedSource = JSONArray() + var moved: JSONObject? = null + for (index in 0 until source.length()) { + val message = source.optJSONObject(index) ?: continue + if (message.optLong("uid", message.optLong("id")) != uid) { + updatedSource.put(message) + continue + } + when (action) { + "star" -> { + message.put("star", input.optBoolean("enabled")) + updatedSource.put(message) + } + "unread" -> { + message.put("unread", input.optBoolean("enabled")) + updatedSource.put(message) + } + "archive", "delete", "inbox" -> moved = message + else -> updatedSource.put(message) + } + } + cache.put(sourceName, updatedSource) + val destinationName = when (action) { + "archive" -> "Archive" + "delete" -> "Trash" + "inbox" -> "Inbox" + else -> null + } + if (moved == null || destinationName == null) return + moved!!.put("sourceFolder", destinationName) + .put("archived", destinationName == "Archive") + .put("deleted", destinationName == "Trash") + val destination = cache.optJSONArray(destinationName) ?: JSONArray() + val merged = (0 until destination.length()).mapNotNull { destination.optJSONObject(it) } + .filter { it.optLong("uid", it.optLong("id")) != uid } + moved!! + cache.put(destinationName, JSONArray().apply { merged.takeLast(30).forEach { put(it) } }) + } + + @Synchronized + fun pendingMailOperations(id: String): JSONArray = account(id)?.optJSONArray("mailOutbox") ?: JSONArray() + + @Synchronized + fun removeMailOperation(id: String, operationId: String) { + val store = read() + val accounts = store.optJSONArray("accounts") ?: return + for (index in 0 until accounts.length()) { + val account = accounts.getJSONObject(index) + if (account.optString("id") != id) continue + val queue = account.optJSONArray("mailOutbox") ?: JSONArray() + account.put("mailOutbox", JSONArray().apply { + for (queueIndex in 0 until queue.length()) { + val operation = queue.optJSONObject(queueIndex) ?: continue + if (operation.optString("id") != operationId) put(operation) + } + }) + write(store) + return + } + } + + fun publicAccounts(accounts: JSONArray = this.accounts()): JSONArray { + val result = JSONArray() + for (index in 0 until accounts.length()) { + val account = accounts.getJSONObject(index) + result.put(publicAccount(account)) + } + return result + } + + fun publicAccount(account: JSONObject): JSONObject = JSONObject() + .put("id", account.optString("id")) + .put("email", account.optString("email")) + .put("displayName", account.optString("displayName")) + .put("imapHost", account.optString("imapHost")) + .put("smtpHost", account.optString("smtpHost")) + .put("signature", account.optString("signature")) + .put("notificationsEnabled", account.optBoolean("notificationsEnabled", true)) + .put("syncIntervalMinutes", account.optInt("syncIntervalMinutes", 2)) + .put("rules", account.optJSONArray("rules") ?: JSONArray()) + + fun storeDav(type: String): JSONArray = read().optJSONArray(type) ?: JSONArray() + + fun putDavAccount(type: String, account: JSONObject): JSONObject { + val store = read() + val accounts = store.optJSONArray(type) ?: JSONArray() + val updated = JSONArray() + var saved: JSONObject? = null + for (index in 0 until accounts.length()) { + val previous = accounts.getJSONObject(index) + if (previous.optString("serverUrl") == account.optString("serverUrl") && + previous.optString("username").equals(account.optString("username"), true)) { + val merged = JSONObject(account.toString()).put("id", previous.optString("id")) + updated.put(merged) + saved = merged + } else { + updated.put(previous) + } + } + if (saved == null) { + saved = JSONObject(account.toString()) + updated.put(saved) + } + store.put(type, updated) + store.put(if (type == "caldav") "activeCaldavId" else "activeCarddavId", saved.optString("id")) + write(store) + return saved + } + + fun activeDav(type: String, id: String? = null): JSONObject? { + val store = read() + val accounts = store.optJSONArray(type) ?: return null + val selectedId = id ?: store.optString(if (type == "caldav") "activeCaldavId" else "activeCarddavId") + for (index in 0 until accounts.length()) { + val account = accounts.getJSONObject(index) + if (account.optString("id") == selectedId) return account + } + return null + } + + fun publicDavAccounts(type: String): JSONArray { + val result = JSONArray() + val accounts = storeDav(type) + for (index in 0 until accounts.length()) { + val account = accounts.getJSONObject(index) + result.put(JSONObject() + .put("id", account.optString("id")) + .put("serverUrl", account.optString("serverUrl")) + .put("username", account.optString("username")) + .put("collections", account.optJSONArray("collections") ?: JSONArray())) + } + return result + } + + fun removeDavAccount(type: String, id: String): JSONObject { + val store = read() + val accounts = store.optJSONArray(type) ?: JSONArray() + val remaining = JSONArray() + for (index in 0 until accounts.length()) { + val account = accounts.getJSONObject(index) + if (account.optString("id") != id) remaining.put(account) + } + val activeKey = if (type == "caldav") "activeCaldavId" else "activeCarddavId" + val activeId = if (store.optString(activeKey) == id) { + remaining.optJSONObject(0)?.optString("id") ?: "" + } else store.optString(activeKey) + store.put(type, remaining) + store.put(activeKey, activeId) + write(store) + return JSONObject().put("accounts", publicDavAccounts(type)).put("activeId", activeId) + } + + private fun emptyStore() = JSONObject() + .put("accounts", JSONArray()) + .put("activeId", "") + .put("caldav", JSONArray()) + .put("carddav", JSONArray()) + .put("activeCaldavId", "") + .put("activeCarddavId", "") + + private fun requireContext(): Context = + appContext ?: throw IllegalStateException("Encrypted account storage is not initialized.") + + @Synchronized + private fun secretKey(): SecretKey { + val keyStore = KeyStore.getInstance("AndroidKeyStore").apply { load(null) } + (keyStore.getKey(KEY_ALIAS, null) as? SecretKey)?.let { return it } + val generator = KeyGenerator.getInstance(KeyProperties.KEY_ALGORITHM_AES, "AndroidKeyStore") + generator.init( + KeyGenParameterSpec.Builder( + KEY_ALIAS, + KeyProperties.PURPOSE_ENCRYPT or KeyProperties.PURPOSE_DECRYPT + ) + .setBlockModes(KeyProperties.BLOCK_MODE_GCM) + .setEncryptionPaddings(KeyProperties.ENCRYPTION_PADDING_NONE) + .setKeySize(256) + .setRandomizedEncryptionRequired(true) + .build() + ) + return generator.generateKey() + } +} diff --git a/android/app/src/main/java/studio/daybreak/mail/AndroidDavService.kt b/android/app/src/main/java/studio/daybreak/mail/AndroidDavService.kt index d9e8948..8441dd3 100644 --- a/android/app/src/main/java/studio/daybreak/mail/AndroidDavService.kt +++ b/android/app/src/main/java/studio/daybreak/mail/AndroidDavService.kt @@ -1,443 +1,437 @@ -package studio.daybreak.mail - -import android.util.Base64 -import org.json.JSONArray -import org.json.JSONObject -import org.w3c.dom.Element -import java.io.ByteArrayInputStream -import java.net.URL -import java.nio.charset.StandardCharsets -import java.util.Locale -import java.util.UUID -import okhttp3.OkHttpClient -import okhttp3.Request -import okhttp3.MediaType.Companion.toMediaTypeOrNull -import okhttp3.RequestBody.Companion.toRequestBody -import java.util.concurrent.TimeUnit -import javax.xml.parsers.DocumentBuilderFactory - -internal object AndroidDavService { +package studio.daybreak.mail + +import android.util.Base64 +import org.json.JSONArray +import org.json.JSONObject +import org.w3c.dom.Element +import java.io.ByteArrayInputStream +import java.net.URL +import java.nio.charset.StandardCharsets +import java.util.Locale +import java.util.UUID +import okhttp3.OkHttpClient +import okhttp3.Request +import okhttp3.MediaType.Companion.toMediaTypeOrNull +import okhttp3.RequestBody.Companion.toRequestBody +import java.util.concurrent.TimeUnit +import javax.xml.parsers.DocumentBuilderFactory + +internal object AndroidDavService { private val httpClient = OkHttpClient.Builder() .connectTimeout(20, TimeUnit.SECONDS) .readTimeout(30, TimeUnit.SECONDS) + .followRedirects(false) + .followSslRedirects(false) .build() - - fun list(): JSONObject { - val store = AndroidAccountVault.read() - return JSONObject() - .put("caldav", AndroidAccountVault.publicDavAccounts("caldav")) - .put("carddav", AndroidAccountVault.publicDavAccounts("carddav")) - .put("activeCaldavId", store.optString("activeCaldavId")) - .put("activeCarddavId", store.optString("activeCarddavId")) + + fun list(): JSONObject { + val store = AndroidAccountVault.read() + return JSONObject() + .put("caldav", AndroidAccountVault.publicDavAccounts("caldav")) + .put("carddav", AndroidAccountVault.publicDavAccounts("carddav")) + .put("activeCaldavId", store.optString("activeCaldavId")) + .put("activeCarddavId", store.optString("activeCarddavId")) + } + + fun connect(input: JSONObject): JSONObject { + val type = type(input.optString("type")) + val serverUrl = input.optString("serverUrl").trim() + val username = input.optString("username").trim() + val password = input.optString("password") + val url = DavUrlPolicy.parseServerUrl(serverUrl) + require(username.isNotBlank() && password.isNotBlank()) { "Enter the DAV username and password." } + val collections = discoverCollections(url.toString(), username, password, type) + require(collections.length() > 0) { + "No ${if (type == "caldav") "calendars" else "address books"} were found on this server." + } + val account = JSONObject() + .put("id", UUID.randomUUID().toString()) + .put("type", type) + .put("serverUrl", url.toString()) + .put("username", username) + .put("password", password) + .put("collections", collections) + val saved = AndroidAccountVault.putDavAccount(type, account) + val publicConfig = publicDav(saved) + return JSONObject() + .put("config", publicConfig) + .put("collections", collections) + .put("accounts", list()) + } + + fun activate(typeInput: String, id: String): JSONObject { + val type = type(typeInput) + val config = AndroidAccountVault.activeDav(type, id) + ?: throw IllegalStateException("That DAV account could not be found.") + val store = AndroidAccountVault.read() + store.put(if (type == "caldav") "activeCaldavId" else "activeCarddavId", config.optString("id")) + AndroidAccountVault.write(store) + return JSONObject().put("id", config.optString("id")) + } + + fun remove(typeInput: String, id: String): JSONObject = + AndroidAccountVault.removeDavAccount(type(typeInput), id) + + fun sync(typeInput: String): JSONObject { + val type = type(typeInput) + val account = AndroidAccountVault.activeDav(type) + ?: throw IllegalStateException("Connect a ${if (type == "caldav") "CalDAV" else "CardDAV"} server first.") + val collectionKey = if (type == "caldav") "calendar" else "addressbook" + val result = JSONArray() + val collections = account.optJSONArray("collections") ?: JSONArray() + for (index in 0 until collections.length()) { + val collection = collections.getJSONObject(index) + val objects = listObjects(account, collection, type) + for (obj in objects) { + val href = obj.optString("href") + val data = obj.optString("data") + if (data.isBlank()) continue + if (type == "caldav") parseCalendar(data, account, collection, obj).forEach(result::put) + else parseContacts(data, account, collection, obj).forEach(result::put) + } + } + return JSONObject().put("items", result).put("account", publicDav(account)) + .put("collectionType", collectionKey) + } + + fun saveEvent(input: JSONObject): JSONObject? { + val remote = input.optJSONObject("_dav") ?: JSONObject() + val account = AndroidAccountVault.activeDav("caldav", remote.optString("accountId").ifBlank { null }) ?: return null + val collections = account.optJSONArray("collections") ?: JSONArray() + val collection = findCollection(collections, remote.optString("collectionUrl")) + ?: throw IllegalStateException("No writable calendar was found.") + val uid = remote.optString("uid").ifBlank { UUID.randomUUID().toString() } + val filename = "$uid.ics" + val collectionUrl = collection.optString("url") + val target = remote.optString("objectUrl").ifBlank { collectionUrl.trimEnd('/') + "/" + filename } + val data = calendarData(input, uid) + val response = request(account, target, "PUT", data, mapOf("Content-Type" to "text/calendar; charset=utf-8")) + require(response.code in 200..299) { "The calendar server rejected the event (${response.code})." } + return JSONObject() + .put("accountId", account.optString("id")) + .put("collectionUrl", collectionUrl) + .put("objectUrl", target) + .put("etag", response.headers["etag"] ?: remote.optString("etag")) + .put("uid", uid) + } + + fun deleteEvent(remote: JSONObject) { + val account = AndroidAccountVault.activeDav("caldav", remote.optString("accountId")) + ?: throw IllegalStateException("That calendar account could not be found.") + val url = remote.optString("objectUrl") + if (url.isBlank()) return + val response = request(account, url, "DELETE", null) + require(response.code in 200..299 || response.code == 404) { "The calendar server rejected the deletion (${response.code})." } + } + + fun saveContact(input: JSONObject): JSONObject? { + val remote = input.optJSONObject("_dav") ?: JSONObject() + val account = AndroidAccountVault.activeDav("carddav", remote.optString("accountId").ifBlank { null }) ?: return null + val collections = account.optJSONArray("collections") ?: JSONArray() + val collection = findCollection(collections, remote.optString("collectionUrl")) + ?: throw IllegalStateException("No writable address book was found.") + val uid = remote.optString("uid").ifBlank { UUID.randomUUID().toString() } + val filename = "$uid.vcf" + val collectionUrl = collection.optString("url") + val target = remote.optString("objectUrl").ifBlank { collectionUrl.trimEnd('/') + "/" + filename } + val response = request(account, target, "PUT", vcardData(input, uid), mapOf("Content-Type" to "text/vcard; charset=utf-8")) + require(response.code in 200..299) { "The address book server rejected the contact (${response.code})." } + return JSONObject() + .put("accountId", account.optString("id")) + .put("collectionUrl", collectionUrl) + .put("objectUrl", target) + .put("etag", response.headers["etag"] ?: remote.optString("etag")) + .put("uid", uid) + } + + fun deleteContact(remote: JSONObject) { + val account = AndroidAccountVault.activeDav("carddav", remote.optString("accountId")) + ?: throw IllegalStateException("That address book account could not be found.") + val url = remote.optString("objectUrl") + if (url.isBlank()) return + val response = request(account, url, "DELETE", null) + require(response.code in 200..299 || response.code == 404) { "The address book server rejected the deletion (${response.code})." } + } + + private data class HttpResult(val code: Int, val body: ByteArray, val headers: Map) + + private fun request( + account: JSONObject, + address: String, + method: String, + body: String?, + headers: Map = emptyMap() + ): HttpResult { + DavUrlPolicy.requireSameOrigin(account.optString("serverUrl"), address) + val requestBody = body?.toRequestBody(headers["Content-Type"]?.toMediaTypeOrNull()) + val builder = Request.Builder() + .url(address) + .header("Authorization", basicAuth(account)) + .header("User-Agent", "ep-mail-Android") + for ((key, value) in headers) builder.header(key, value) + builder.method(method, requestBody) + httpClient.newCall(builder.build()).execute().use { response -> + val bytes = response.body?.bytes() ?: ByteArray(0) + val responseHeaders = response.headers.toMultimap().mapValues { (_, values) -> values.firstOrNull().orEmpty() } + return HttpResult(response.code, bytes, responseHeaders) + } + } + + private fun discoverCollections(serverUrl: String, username: String, password: String, type: String): JSONArray { + val base = JSONObject().put("serverUrl", serverUrl).put("username", username).put("password", password) + val setName = if (type == "caldav") "calendar-home-set" else "addressbook-home-set" + val rootResponse = request(base, serverUrl, "PROPFIND", propfindBody(setName), mapOf( + "Depth" to "0", + "Content-Type" to "application/xml; charset=utf-8" + )) + require(rootResponse.code in 200..299 || rootResponse.code == 207) { + "Could not access the DAV server (${rootResponse.code})." + } + val rootDocument = parseXml(rootResponse.body) + var homeUrl = findHref(rootDocument, setName)?.let { resolveUrl(serverUrl, it) } + if (homeUrl == null) { + val principal = findHref(rootDocument, "current-user-principal") + if (principal != null) { + val principalUrl = resolveUrl(serverUrl, principal) + val principalResponse = request(base, principalUrl, "PROPFIND", propfindBody(setName), mapOf( + "Depth" to "0", + "Content-Type" to "application/xml; charset=utf-8" + )) + if (principalResponse.code in 200..299 || principalResponse.code == 207) { + homeUrl = findHref(parseXml(principalResponse.body), setName)?.let { resolveUrl(principalUrl, it) } + } + } + } + val collectionUrl = homeUrl ?: serverUrl + val response = request(base, collectionUrl, "PROPFIND", collectionBody(), mapOf( + "Depth" to "1", + "Content-Type" to "application/xml; charset=utf-8" + )) + require(response.code in 200..299 || response.code == 207) { + "Could not discover DAV collections (${response.code})." + } + val document = parseXml(response.body) + val requiredType = if (type == "caldav") "calendar" else "addressbook" + val result = JSONArray() + val responses = document.getElementsByTagNameNS("*", "response") + for (index in 0 until responses.length) { + val responseElement = responses.item(index) as? Element ?: continue + val href = childText(responseElement, "href") ?: continue + if (responseElement.getElementsByTagNameNS("*", requiredType).length == 0) continue + val resolved = resolveUrl(collectionUrl, href) + val displayName = textContent(responseElement, "displayname").orEmpty().ifBlank { resolved } + result.put(JSONObject().put("url", resolved).put("name", displayName)) + } + return result + } + + private fun listObjects(account: JSONObject, collection: JSONObject, type: String): List { + val collectionUrl = collection.optString("url") + val response = request(account, collectionUrl, "PROPFIND", collectionBody(), mapOf( + "Depth" to "1", + "Content-Type" to "application/xml; charset=utf-8" + )) + require(response.code in 200..299 || response.code == 207) { + "Could not read DAV collection ${collection.optString("name")} (${response.code})." + } + val document = parseXml(response.body) + val responses = document.getElementsByTagNameNS("*", "response") + val result = ArrayList() + for (index in 0 until responses.length) { + val element = responses.item(index) as? Element ?: continue + val href = childText(element, "href") ?: continue + val objectUrl = resolveUrl(collectionUrl, href) + if (objectUrl.trimEnd('/') == collectionUrl.trimEnd('/')) continue + val data = if (type == "caldav") textContent(element, "calendar-data") else textContent(element, "address-data") + val content = if (!data.isNullOrBlank()) data else { + val fetched = request(account, objectUrl, "GET", null) + if (fetched.code !in 200..299) continue + String(fetched.body, StandardCharsets.UTF_8) + } + result.add(JSONObject() + .put("href", objectUrl) + .put("etag", textContent(element, "getetag").orEmpty()) + .put("data", content)) + } + return result + } + + private fun parseCalendar(data: String, account: JSONObject, collection: JSONObject, resource: JSONObject): List { + val unfolded = unfold(data) + return Regex("BEGIN:VEVENT(.*?)END:VEVENT", setOf(RegexOption.IGNORE_CASE, RegexOption.DOT_MATCHES_ALL)) + .findAll(unfolded).mapNotNull { match -> + val block = match.groupValues[1] + val fields = parseProperties(block) + val uid = fields["UID"].orEmpty().ifBlank { UUID.randomUUID().toString() } + val (date, time) = parseDate(fields["DTSTART"].orEmpty()) ?: return@mapNotNull null + JSONObject() + .put("id", "dav:${account.optString("id")}:${encode(resource.optString("href"))}:${encode(uid)}") + .put("title", unescape(fields["SUMMARY"].orEmpty()).ifBlank { "(no title)" }) + .put("date", date) + .put("time", time) + .put("with", Regex("(?im)^ATTENDEE[^:]*:(?:mailto:)?([^\\r\\n]+)").findAll(block) + .map { it.groupValues[1].trim() }.joinToString(", ")) + .put("place", unescape(fields["LOCATION"].orEmpty())) + .put("notes", unescape(fields["DESCRIPTION"].orEmpty())) + .put("_dav", JSONObject() + .put("accountId", account.optString("id")) + .put("collectionUrl", collection.optString("url")) + .put("objectUrl", resource.optString("href")) + .put("etag", resource.optString("etag")) + .put("uid", uid)) + }.toList() + } + + private fun parseContacts(data: String, account: JSONObject, collection: JSONObject, resource: JSONObject): List { + val cards = Regex("BEGIN:VCARD(.*?)END:VCARD", setOf(RegexOption.IGNORE_CASE, RegexOption.DOT_MATCHES_ALL)) + return cards.findAll(unfold(data)).mapNotNull { match -> + val block = match.groupValues[1] + val fields = parseProperties(block) + val name = unescape(fields["FN"].orEmpty()).trim() + if (name.isBlank()) return@mapNotNull null + val uid = fields["UID"].orEmpty() + JSONObject() + .put("id", "dav:${account.optString("id")}:${encode(resource.optString("href"))}:${encode(uid)}") + .put("name", name) + .put("email", unescape(fields["EMAIL"].orEmpty())) + .put("note", unescape(fields["NOTE"].orEmpty())) + .put("initials", name.split(Regex("\\s+")).mapNotNull { it.firstOrNull()?.toString() } + .joinToString("").take(2).uppercase(Locale.getDefault())) + .put("color", "#dce9dd") + .put("_dav", JSONObject() + .put("accountId", account.optString("id")) + .put("collectionUrl", collection.optString("url")) + .put("objectUrl", resource.optString("href")) + .put("etag", resource.optString("etag")) + .put("uid", uid)) + }.toList() + } + + private fun calendarData(event: JSONObject, uid: String): String { + val date = event.optString("date").replace("-", "") + val time = event.optString("time") + val start = if (time.isBlank()) "DTSTART;VALUE=DATE:$date" else "DTSTART;TZID=UTC:${date}T${time.replace(":", "")}00" + val end = if (time.isBlank()) "" else { + val parts = time.split(":") + val mins = (parts.getOrNull(0)?.toIntOrNull() ?: 0) * 60 + (parts.getOrNull(1)?.toIntOrNull() ?: 0) + 60 + val endTime = "%04d%02d00".format(Locale.ROOT, (mins / 60) % 24, mins % 60) + "DTEND;TZID=UTC:${date}T$endTime\r\n" + } + return "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//Eternity Project//ep-mail CalDAV\r\nBEGIN:VEVENT\r\nUID:${escape(uid)}\r\nDTSTAMP:${utcNow()}\r\n$start\r\n$end${property("SUMMARY", event.optString("title"))}${property("LOCATION", event.optString("place"))}${property("DESCRIPTION", event.optString("notes"))}END:VEVENT\r\nEND:VCALENDAR\r\n" + } + + private fun vcardData(contact: JSONObject, uid: String): String { + val name = contact.optString("name").trim().split(Regex("\\s+")) + val first = name.firstOrNull().orEmpty() + val last = name.drop(1).joinToString(" ") + return "BEGIN:VCARD\r\nVERSION:3.0\r\nUID:${escape(uid)}\r\nFN:${escape(contact.optString("name"))}\r\nN:${escape(last)};${escape(first)};;;\r\nEMAIL:${escape(contact.optString("email"))}\r\n${if (contact.optString("note").isNotBlank()) "NOTE:${escape(contact.optString("note"))}\r\n" else ""}END:VCARD\r\n" + } + + private fun propfindBody(homeSet: String) = """ + + + """.trimIndent() + + private fun collectionBody() = """ + + + """.trimIndent() + + private fun parseXml(bytes: ByteArray): org.w3c.dom.Document { + val factory = DocumentBuilderFactory.newInstance().apply { + isNamespaceAware = true + isXIncludeAware = false + isExpandEntityReferences = false + setFeature("http://apache.org/xml/features/disallow-doctype-decl", true) + setFeature("http://xml.org/sax/features/external-general-entities", false) + setFeature("http://xml.org/sax/features/external-parameter-entities", false) + } + return factory.newDocumentBuilder().parse(ByteArrayInputStream(bytes)) + } + + private fun findHref(document: org.w3c.dom.Document, propertyName: String): String? { + val elements = document.getElementsByTagNameNS("*", propertyName) + for (index in 0 until elements.length) { + val href = (elements.item(index) as? Element)?.getElementsByTagNameNS("*", "href")?.item(0)?.textContent + if (!href.isNullOrBlank()) return href.trim() + } + return null + } + + private fun textContent(element: Element, propertyName: String): String? { + val nodes = element.getElementsByTagNameNS("*", propertyName) + return if (nodes.length == 0) null else nodes.item(0)?.textContent?.trim() + } + + private fun childText(element: Element, childName: String): String? { + val children = element.childNodes + for (index in 0 until children.length) { + val node = children.item(index) + if (node is Element && node.localName == childName) return node.textContent.trim() + } + return null + } + + private fun resolveUrl(base: String, href: String): String = URL(URL(base), href).toString() + + private fun basicAuth(account: JSONObject): String { + val raw = "${account.optString("username")}:${account.optString("password")}" + return "Basic " + Base64.encodeToString(raw.toByteArray(StandardCharsets.UTF_8), Base64.NO_WRAP) + } + + private fun publicDav(account: JSONObject) = JSONObject() + .put("id", account.optString("id")) + .put("serverUrl", account.optString("serverUrl")) + .put("username", account.optString("username")) + .put("collections", account.optJSONArray("collections") ?: JSONArray()) + + private fun type(value: String) = when (value) { + "caldav", "carddav" -> value + else -> throw IllegalArgumentException("Choose a supported CalDAV or CardDAV account.") } - - fun connect(input: JSONObject): JSONObject { - val type = type(input.optString("type")) - val serverUrl = input.optString("serverUrl").trim() - val username = input.optString("username").trim() - val password = input.optString("password") - val url = try { URL(serverUrl) } catch (_: Exception) { - throw IllegalArgumentException("Enter a valid CalDAV or CardDAV server URL.") - } - require(url.protocol == "https" || (url.protocol == "http" && url.host in setOf("localhost", "127.0.0.1", "::1"))) { - "DAV server URLs must use HTTPS." - } - require(username.isNotBlank() && password.isNotBlank()) { "Enter the DAV username and password." } - val collections = discoverCollections(url.toString(), username, password, type) - require(collections.length() > 0) { - "No ${if (type == "caldav") "calendars" else "address books"} were found on this server." - } - val account = JSONObject() - .put("id", UUID.randomUUID().toString()) - .put("type", type) - .put("serverUrl", url.toString()) - .put("username", username) - .put("password", password) - .put("collections", collections) - val saved = AndroidAccountVault.putDavAccount(type, account) - val publicConfig = publicDav(saved) - return JSONObject() - .put("config", publicConfig) - .put("collections", collections) - .put("accounts", list()) - } - - fun activate(typeInput: String, id: String): JSONObject { - val type = type(typeInput) - val config = AndroidAccountVault.activeDav(type, id) - ?: throw IllegalStateException("That DAV account could not be found.") - val store = AndroidAccountVault.read() - store.put(if (type == "caldav") "activeCaldavId" else "activeCarddavId", config.optString("id")) - AndroidAccountVault.write(store) - return JSONObject().put("id", config.optString("id")) - } - - fun remove(typeInput: String, id: String): JSONObject = - AndroidAccountVault.removeDavAccount(type(typeInput), id) - - fun sync(typeInput: String): JSONObject { - val type = type(typeInput) - val account = AndroidAccountVault.activeDav(type) - ?: throw IllegalStateException("Connect a ${if (type == "caldav") "CalDAV" else "CardDAV"} server first.") - val collectionKey = if (type == "caldav") "calendar" else "addressbook" - val result = JSONArray() - val collections = account.optJSONArray("collections") ?: JSONArray() - for (index in 0 until collections.length()) { - val collection = collections.getJSONObject(index) - val objects = listObjects(account, collection, type) - for (obj in objects) { - val href = obj.optString("href") - val data = obj.optString("data") - if (data.isBlank()) continue - if (type == "caldav") parseCalendar(data, account, collection, obj).forEach(result::put) - else parseContacts(data, account, collection, obj).forEach(result::put) - } - } - return JSONObject().put("items", result).put("account", publicDav(account)) - .put("collectionType", collectionKey) - } - - fun saveEvent(input: JSONObject): JSONObject? { - val remote = input.optJSONObject("_dav") ?: JSONObject() - val account = AndroidAccountVault.activeDav("caldav", remote.optString("accountId").ifBlank { null }) ?: return null - val collections = account.optJSONArray("collections") ?: JSONArray() - val collection = findCollection(collections, remote.optString("collectionUrl")) - ?: throw IllegalStateException("No writable calendar was found.") - val uid = remote.optString("uid").ifBlank { UUID.randomUUID().toString() } - val filename = "$uid.ics" - val collectionUrl = collection.optString("url") - val target = remote.optString("objectUrl").ifBlank { collectionUrl.trimEnd('/') + "/" + filename } - val data = calendarData(input, uid) - val response = request(account, target, "PUT", data, mapOf("Content-Type" to "text/calendar; charset=utf-8")) - require(response.code in 200..299) { "The calendar server rejected the event (${response.code})." } - return JSONObject() - .put("accountId", account.optString("id")) - .put("collectionUrl", collectionUrl) - .put("objectUrl", target) - .put("etag", response.headers["etag"] ?: remote.optString("etag")) - .put("uid", uid) - } - - fun deleteEvent(remote: JSONObject) { - val account = AndroidAccountVault.activeDav("caldav", remote.optString("accountId")) - ?: throw IllegalStateException("That calendar account could not be found.") - val url = remote.optString("objectUrl") - if (url.isBlank()) return - val response = request(account, url, "DELETE", null) - require(response.code in 200..299 || response.code == 404) { "The calendar server rejected the deletion (${response.code})." } - } - - fun saveContact(input: JSONObject): JSONObject? { - val remote = input.optJSONObject("_dav") ?: JSONObject() - val account = AndroidAccountVault.activeDav("carddav", remote.optString("accountId").ifBlank { null }) ?: return null - val collections = account.optJSONArray("collections") ?: JSONArray() - val collection = findCollection(collections, remote.optString("collectionUrl")) - ?: throw IllegalStateException("No writable address book was found.") - val uid = remote.optString("uid").ifBlank { UUID.randomUUID().toString() } - val filename = "$uid.vcf" - val collectionUrl = collection.optString("url") - val target = remote.optString("objectUrl").ifBlank { collectionUrl.trimEnd('/') + "/" + filename } - val response = request(account, target, "PUT", vcardData(input, uid), mapOf("Content-Type" to "text/vcard; charset=utf-8")) - require(response.code in 200..299) { "The address book server rejected the contact (${response.code})." } - return JSONObject() - .put("accountId", account.optString("id")) - .put("collectionUrl", collectionUrl) - .put("objectUrl", target) - .put("etag", response.headers["etag"] ?: remote.optString("etag")) - .put("uid", uid) - } - - fun deleteContact(remote: JSONObject) { - val account = AndroidAccountVault.activeDav("carddav", remote.optString("accountId")) - ?: throw IllegalStateException("That address book account could not be found.") - val url = remote.optString("objectUrl") - if (url.isBlank()) return - val response = request(account, url, "DELETE", null) - require(response.code in 200..299 || response.code == 404) { "The address book server rejected the deletion (${response.code})." } - } - - private data class HttpResult(val code: Int, val body: ByteArray, val headers: Map) - - private fun request( - account: JSONObject, - address: String, - method: String, - body: String?, - headers: Map = emptyMap() - ): HttpResult { - val target = URL(address) - val base = URL(account.optString("serverUrl")) - val targetPort = if (target.port >= 0) target.port else target.defaultPort - val basePort = if (base.port >= 0) base.port else base.defaultPort - require(target.protocol == base.protocol && target.host.equals(base.host, true) && targetPort == basePort) { - "The DAV server returned a collection URL on an unexpected host." - } - val requestBody = body?.toRequestBody(headers["Content-Type"]?.toMediaTypeOrNull()) - val builder = Request.Builder() - .url(address) - .header("Authorization", basicAuth(account)) - .header("User-Agent", "ep-mail-Android") - for ((key, value) in headers) builder.header(key, value) - builder.method(method, requestBody) - httpClient.newCall(builder.build()).execute().use { response -> - val bytes = response.body?.bytes() ?: ByteArray(0) - val responseHeaders = response.headers.toMultimap().mapValues { (_, values) -> values.firstOrNull().orEmpty() } - return HttpResult(response.code, bytes, responseHeaders) - } - } - - private fun discoverCollections(serverUrl: String, username: String, password: String, type: String): JSONArray { - val base = JSONObject().put("serverUrl", serverUrl).put("username", username).put("password", password) - val setName = if (type == "caldav") "calendar-home-set" else "addressbook-home-set" - val rootResponse = request(base, serverUrl, "PROPFIND", propfindBody(setName), mapOf( - "Depth" to "0", - "Content-Type" to "application/xml; charset=utf-8" - )) - require(rootResponse.code in 200..299 || rootResponse.code == 207) { - "Could not access the DAV server (${rootResponse.code})." - } - val rootDocument = parseXml(rootResponse.body) - var homeUrl = findHref(rootDocument, setName)?.let { resolveUrl(serverUrl, it) } - if (homeUrl == null) { - val principal = findHref(rootDocument, "current-user-principal") - if (principal != null) { - val principalUrl = resolveUrl(serverUrl, principal) - val principalResponse = request(base, principalUrl, "PROPFIND", propfindBody(setName), mapOf( - "Depth" to "0", - "Content-Type" to "application/xml; charset=utf-8" - )) - if (principalResponse.code in 200..299 || principalResponse.code == 207) { - homeUrl = findHref(parseXml(principalResponse.body), setName)?.let { resolveUrl(principalUrl, it) } - } - } - } - val collectionUrl = homeUrl ?: serverUrl - val response = request(base, collectionUrl, "PROPFIND", collectionBody(), mapOf( - "Depth" to "1", - "Content-Type" to "application/xml; charset=utf-8" - )) - require(response.code in 200..299 || response.code == 207) { - "Could not discover DAV collections (${response.code})." - } - val document = parseXml(response.body) - val requiredType = if (type == "caldav") "calendar" else "addressbook" - val result = JSONArray() - val responses = document.getElementsByTagNameNS("*", "response") - for (index in 0 until responses.length) { - val responseElement = responses.item(index) as? Element ?: continue - val href = childText(responseElement, "href") ?: continue - if (responseElement.getElementsByTagNameNS("*", requiredType).length == 0) continue - val resolved = resolveUrl(collectionUrl, href) - val displayName = textContent(responseElement, "displayname").orEmpty().ifBlank { resolved } - result.put(JSONObject().put("url", resolved).put("name", displayName)) - } - return result - } - - private fun listObjects(account: JSONObject, collection: JSONObject, type: String): List { - val collectionUrl = collection.optString("url") - val response = request(account, collectionUrl, "PROPFIND", collectionBody(), mapOf( - "Depth" to "1", - "Content-Type" to "application/xml; charset=utf-8" - )) - require(response.code in 200..299 || response.code == 207) { - "Could not read DAV collection ${collection.optString("name")} (${response.code})." - } - val document = parseXml(response.body) - val responses = document.getElementsByTagNameNS("*", "response") - val result = ArrayList() - for (index in 0 until responses.length) { - val element = responses.item(index) as? Element ?: continue - val href = childText(element, "href") ?: continue - val objectUrl = resolveUrl(collectionUrl, href) - if (objectUrl.trimEnd('/') == collectionUrl.trimEnd('/')) continue - val data = if (type == "caldav") textContent(element, "calendar-data") else textContent(element, "address-data") - val content = if (!data.isNullOrBlank()) data else { - val fetched = request(account, objectUrl, "GET", null) - if (fetched.code !in 200..299) continue - String(fetched.body, StandardCharsets.UTF_8) - } - result.add(JSONObject() - .put("href", objectUrl) - .put("etag", textContent(element, "getetag").orEmpty()) - .put("data", content)) - } - return result - } - - private fun parseCalendar(data: String, account: JSONObject, collection: JSONObject, resource: JSONObject): List { - val unfolded = unfold(data) - return Regex("BEGIN:VEVENT(.*?)END:VEVENT", setOf(RegexOption.IGNORE_CASE, RegexOption.DOT_MATCHES_ALL)) - .findAll(unfolded).mapNotNull { match -> - val block = match.groupValues[1] - val fields = parseProperties(block) - val uid = fields["UID"].orEmpty().ifBlank { UUID.randomUUID().toString() } - val (date, time) = parseDate(fields["DTSTART"].orEmpty()) ?: return@mapNotNull null - JSONObject() - .put("id", "dav:${account.optString("id")}:${encode(resource.optString("href"))}:${encode(uid)}") - .put("title", unescape(fields["SUMMARY"].orEmpty()).ifBlank { "(no title)" }) - .put("date", date) - .put("time", time) - .put("with", Regex("(?im)^ATTENDEE[^:]*:(?:mailto:)?([^\\r\\n]+)").findAll(block) - .map { it.groupValues[1].trim() }.joinToString(", ")) - .put("place", unescape(fields["LOCATION"].orEmpty())) - .put("notes", unescape(fields["DESCRIPTION"].orEmpty())) - .put("_dav", JSONObject() - .put("accountId", account.optString("id")) - .put("collectionUrl", collection.optString("url")) - .put("objectUrl", resource.optString("href")) - .put("etag", resource.optString("etag")) - .put("uid", uid)) - }.toList() - } - - private fun parseContacts(data: String, account: JSONObject, collection: JSONObject, resource: JSONObject): List { - val cards = Regex("BEGIN:VCARD(.*?)END:VCARD", setOf(RegexOption.IGNORE_CASE, RegexOption.DOT_MATCHES_ALL)) - return cards.findAll(unfold(data)).mapNotNull { match -> - val block = match.groupValues[1] - val fields = parseProperties(block) - val name = unescape(fields["FN"].orEmpty()).trim() - if (name.isBlank()) return@mapNotNull null - val uid = fields["UID"].orEmpty() - JSONObject() - .put("id", "dav:${account.optString("id")}:${encode(resource.optString("href"))}:${encode(uid)}") - .put("name", name) - .put("email", unescape(fields["EMAIL"].orEmpty())) - .put("note", unescape(fields["NOTE"].orEmpty())) - .put("initials", name.split(Regex("\\s+")).mapNotNull { it.firstOrNull()?.toString() } - .joinToString("").take(2).uppercase(Locale.getDefault())) - .put("color", "#dce9dd") - .put("_dav", JSONObject() - .put("accountId", account.optString("id")) - .put("collectionUrl", collection.optString("url")) - .put("objectUrl", resource.optString("href")) - .put("etag", resource.optString("etag")) - .put("uid", uid)) - }.toList() - } - - private fun calendarData(event: JSONObject, uid: String): String { - val date = event.optString("date").replace("-", "") - val time = event.optString("time") - val start = if (time.isBlank()) "DTSTART;VALUE=DATE:$date" else "DTSTART;TZID=UTC:${date}T${time.replace(":", "")}00" - val end = if (time.isBlank()) "" else { - val parts = time.split(":") - val mins = (parts.getOrNull(0)?.toIntOrNull() ?: 0) * 60 + (parts.getOrNull(1)?.toIntOrNull() ?: 0) + 60 - val endTime = "%04d%02d00".format(Locale.ROOT, (mins / 60) % 24, mins % 60) - "DTEND;TZID=UTC:${date}T$endTime\r\n" - } - return "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//Eternity Project//ep-mail CalDAV\r\nBEGIN:VEVENT\r\nUID:${escape(uid)}\r\nDTSTAMP:${utcNow()}\r\n$start\r\n$end${property("SUMMARY", event.optString("title"))}${property("LOCATION", event.optString("place"))}${property("DESCRIPTION", event.optString("notes"))}END:VEVENT\r\nEND:VCALENDAR\r\n" - } - - private fun vcardData(contact: JSONObject, uid: String): String { - val name = contact.optString("name").trim().split(Regex("\\s+")) - val first = name.firstOrNull().orEmpty() - val last = name.drop(1).joinToString(" ") - return "BEGIN:VCARD\r\nVERSION:3.0\r\nUID:${escape(uid)}\r\nFN:${escape(contact.optString("name"))}\r\nN:${escape(last)};${escape(first)};;;\r\nEMAIL:${escape(contact.optString("email"))}\r\n${if (contact.optString("note").isNotBlank()) "NOTE:${escape(contact.optString("note"))}\r\n" else ""}END:VCARD\r\n" - } - - private fun propfindBody(homeSet: String) = """ - - - """.trimIndent() - - private fun collectionBody() = """ - - - """.trimIndent() - - private fun parseXml(bytes: ByteArray): org.w3c.dom.Document { - val factory = DocumentBuilderFactory.newInstance().apply { - isNamespaceAware = true - isXIncludeAware = false - isExpandEntityReferences = false - setFeature("http://apache.org/xml/features/disallow-doctype-decl", true) - setFeature("http://xml.org/sax/features/external-general-entities", false) - setFeature("http://xml.org/sax/features/external-parameter-entities", false) - } - return factory.newDocumentBuilder().parse(ByteArrayInputStream(bytes)) - } - - private fun findHref(document: org.w3c.dom.Document, propertyName: String): String? { - val elements = document.getElementsByTagNameNS("*", propertyName) - for (index in 0 until elements.length) { - val href = (elements.item(index) as? Element)?.getElementsByTagNameNS("*", "href")?.item(0)?.textContent - if (!href.isNullOrBlank()) return href.trim() - } - return null - } - - private fun textContent(element: Element, propertyName: String): String? { - val nodes = element.getElementsByTagNameNS("*", propertyName) - return if (nodes.length == 0) null else nodes.item(0)?.textContent?.trim() - } - - private fun childText(element: Element, childName: String): String? { - val children = element.childNodes - for (index in 0 until children.length) { - val node = children.item(index) - if (node is Element && node.localName == childName) return node.textContent.trim() - } - return null - } - - private fun resolveUrl(base: String, href: String): String = URL(URL(base), href).toString() - - private fun basicAuth(account: JSONObject): String { - val raw = "${account.optString("username")}:${account.optString("password")}" - return "Basic " + Base64.encodeToString(raw.toByteArray(StandardCharsets.UTF_8), Base64.NO_WRAP) - } - - private fun publicDav(account: JSONObject) = JSONObject() - .put("id", account.optString("id")) - .put("serverUrl", account.optString("serverUrl")) - .put("username", account.optString("username")) - .put("collections", account.optJSONArray("collections") ?: JSONArray()) - - private fun type(value: String) = if (value == "carddav") "carddav" else "caldav" - - private fun findCollection(collections: JSONArray, url: String): JSONObject? { - for (index in 0 until collections.length()) { - val collection = collections.getJSONObject(index) - if (url.isBlank() || collection.optString("url") == url) return collection - } - return null - } - - private fun encode(value: String) = java.net.URLEncoder.encode(value, "UTF-8") - private fun escape(value: String) = value.replace("\\", "\\\\").replace("\n", "\\n").replace(",", "\\,").replace(";", "\\;") - private fun unescape(value: String) = value.replace("\\n", "\n").replace("\\,", ",").replace("\\;", ";").replace("\\\\", "\\") - private fun property(name: String, value: String) = if (value.isBlank()) "" else "$name:${escape(value)}\r\n" - private fun utcNow() = java.text.SimpleDateFormat("yyyyMMdd'T'HHmmss'Z'", Locale.ROOT) - .apply { timeZone = java.util.TimeZone.getTimeZone("UTC") }.format(java.util.Date()) - - private fun unfold(data: String) = data.replace("\r\n ", "").replace("\n ", "").replace("\r\n\t", "").replace("\n\t", "") - - private fun parseProperties(block: String): Map { - val result = LinkedHashMap() - for (line in block.lines()) { - val colon = line.indexOf(':') - if (colon <= 0) continue - val name = line.substring(0, colon).substringBefore(';').uppercase(Locale.ROOT) - result.putIfAbsent(name, line.substring(colon + 1).trim()) - } - return result - } - - private fun parseDate(raw: String): Pair? { - if (raw.isBlank()) return null - val rawValue = raw.substringAfter(':', raw) - return try { - when { - rawValue.length == 8 -> "${rawValue.substring(0, 4)}-${rawValue.substring(4, 6)}-${rawValue.substring(6, 8)}" to "" - rawValue.length >= 15 -> { - val digits = rawValue.replace("T", "").replace("Z", "").take(14) - val date = "${digits.substring(0, 4)}-${digits.substring(4, 6)}-${digits.substring(6, 8)}" - val time = "${digits.substring(8, 10)}:${digits.substring(10, 12)}" - date to time - } - else -> null - } - } catch (_: Exception) { null } - } -} + + private fun findCollection(collections: JSONArray, url: String): JSONObject? { + for (index in 0 until collections.length()) { + val collection = collections.getJSONObject(index) + if (url.isBlank() || collection.optString("url") == url) return collection + } + return null + } + + private fun encode(value: String) = java.net.URLEncoder.encode(value, "UTF-8") + private fun escape(value: String) = value.replace("\\", "\\\\").replace("\n", "\\n").replace(",", "\\,").replace(";", "\\;") + private fun unescape(value: String) = value.replace("\\n", "\n").replace("\\,", ",").replace("\\;", ";").replace("\\\\", "\\") + private fun property(name: String, value: String) = if (value.isBlank()) "" else "$name:${escape(value)}\r\n" + private fun utcNow() = java.text.SimpleDateFormat("yyyyMMdd'T'HHmmss'Z'", Locale.ROOT) + .apply { timeZone = java.util.TimeZone.getTimeZone("UTC") }.format(java.util.Date()) + + private fun unfold(data: String) = data.replace("\r\n ", "").replace("\n ", "").replace("\r\n\t", "").replace("\n\t", "") + + private fun parseProperties(block: String): Map { + val result = LinkedHashMap() + for (line in block.lines()) { + val colon = line.indexOf(':') + if (colon <= 0) continue + val name = line.substring(0, colon).substringBefore(';').uppercase(Locale.ROOT) + result.putIfAbsent(name, line.substring(colon + 1).trim()) + } + return result + } + + private fun parseDate(raw: String): Pair? { + if (raw.isBlank()) return null + val rawValue = raw.substringAfter(':', raw) + return try { + when { + rawValue.length == 8 -> "${rawValue.substring(0, 4)}-${rawValue.substring(4, 6)}-${rawValue.substring(6, 8)}" to "" + rawValue.length >= 15 -> { + val digits = rawValue.replace("T", "").replace("Z", "").take(14) + val date = "${digits.substring(0, 4)}-${digits.substring(4, 6)}-${digits.substring(6, 8)}" + val time = "${digits.substring(8, 10)}:${digits.substring(10, 12)}" + date to time + } + else -> null + } + } catch (_: Exception) { null } + } +} diff --git a/android/app/src/main/java/studio/daybreak/mail/AndroidMailService.kt b/android/app/src/main/java/studio/daybreak/mail/AndroidMailService.kt index 7f4e782..826620c 100644 --- a/android/app/src/main/java/studio/daybreak/mail/AndroidMailService.kt +++ b/android/app/src/main/java/studio/daybreak/mail/AndroidMailService.kt @@ -1,840 +1,841 @@ -package studio.daybreak.mail - -import android.content.ContentValues -import android.content.Context -import android.os.Build -import android.os.Environment -import android.provider.MediaStore -import android.text.Html -import android.webkit.MimeTypeMap -import com.sun.mail.imap.IMAPFolder -import org.json.JSONArray -import org.json.JSONObject -import java.io.File -import java.text.DateFormat -import java.text.SimpleDateFormat -import java.util.Calendar -import java.util.Date -import java.util.Locale -import java.util.Properties -import java.util.UUID -import android.util.Base64 -import javax.activation.DataHandler -import javax.mail.Address -import javax.mail.Authenticator -import javax.mail.Flags -import javax.mail.Folder -import javax.mail.Message -import javax.mail.Multipart -import javax.mail.PasswordAuthentication -import javax.mail.Session -import javax.mail.Store -import javax.mail.Transport -import javax.mail.util.ByteArrayDataSource -import javax.mail.UIDFolder -import javax.mail.internet.InternetAddress -import javax.mail.internet.MimeBodyPart -import javax.mail.internet.MimeMessage -import javax.mail.internet.MimeMultipart -import javax.mail.internet.MimeUtility - -internal object AndroidMailService { - data class SyncResult(val payload: JSONObject, val newCount: Int) - - fun connect(account: JSONObject): JSONObject = withStore(account) { session, store -> - val inbox = store.getFolder("INBOX") - check(inbox.exists()) { "The inbox could not be found." } - inbox.open(Folder.READ_ONLY) - val count = inbox.messageCount - inbox.close(false) - val smtpSession = Session.getInstance(smtpProperties(account), credentials(account)) - val transport = smtpSession.getTransport("smtp") - try { - transport.connect( - account.optString("smtpHost"), - account.optInt("smtpPort", 587), - account.optString("email"), - account.optString("password") - ) - } finally { - if (transport.isConnected) transport.close() - } - JSONObject().put("mailbox", "INBOX").put("messages", count) - } - - fun sync(account: JSONObject, requestedFolder: String, offset: Int, filters: JSONObject = JSONObject()): JSONObject { - if (requestedFolder == "Snoozed") return syncSnoozed(account, offset) - return try { - withStore(account) { _, store -> - val folder = resolveFolder(store, requestedFolder) - if (folder == null) return@withStore JSONObject() - .put("messages", JSONArray()).put("total", 0).put("folder", requestedFolder) - folder.open(Folder.READ_ONLY) - try { - val total = folder.messageCount - val hasSearchFilters = listOf("query", "sender", "subject", "after", "before") - .any { filters.optString(it).isNotBlank() } || filters.optBoolean("hasAttachments") - if (hasSearchFilters) { - val all = JSONArray() - val snoozed = account.optJSONArray("snoozedMessages") ?: JSONArray() - if (total > 0) { - val start = (total - 4999).coerceAtLeast(1) - for (message in folder.getMessages(start, total)) { - val uid = (folder as? UIDFolder)?.getUID(message) ?: 0L - if (snoozed.length() > 0 && (0 until snoozed.length()).any { index -> - val item = snoozed.optJSONObject(index) ?: return@any false - item.optString("folder") == requestedFolder && item.optLong("uid") == uid && - item.optLong("dueAt") > System.currentTimeMillis() - }) continue - all.put(messageJson(folder, message, requestedFolder, account)) - } - } - AndroidAccountVault.cacheMessages(account.optString("id"), requestedFolder, all) - val matches = (0 until all.length()).mapNotNull { all.optJSONObject(it) } - .filter { matchesFilters(it, filters) } - .sortedByDescending { it.optLong("timestamp") } - val start = offset.coerceAtLeast(0) - val page = matches.drop(start).take(20) - return@withStore JSONObject() - .put("messages", JSONArray().apply { page.forEach(::put) }) - .put("total", matches.size) - .put("start", if (matches.isEmpty()) 0 else start + 1) - .put("end", start + page.size) - .put("folder", requestedFolder) - } - val end = (total - offset.coerceAtLeast(0)).coerceAtLeast(0) - if (end == 0) { - return@withStore JSONObject().put("messages", JSONArray()).put("total", total) - .put("start", 0).put("end", 0).put("folder", requestedFolder) - } - val first = (end - 19).coerceAtLeast(1) - val result = JSONArray() - val batch = folder.getMessages(first, end).reversed() - val snoozed = account.optJSONArray("snoozedMessages") ?: JSONArray() - val cached = JSONArray() - for (message in batch) { - val uid = (folder as? UIDFolder)?.getUID(message) ?: 0L - val isSnoozed = (0 until snoozed.length()).any { index -> - val item = snoozed.getJSONObject(index) - item.optString("folder") == requestedFolder && item.optLong("uid") == uid && - item.optLong("dueAt") > System.currentTimeMillis() - } - if (isSnoozed) continue - val value = messageJson(folder, message, requestedFolder, account) - result.put(value) - cached.put(value) - } - AndroidAccountVault.cacheMessages(account.optString("id"), requestedFolder, cached) - JSONObject().put("messages", result).put("total", total) - .put("start", first).put("end", end).put("folder", requestedFolder) - } finally { - folder.close(false) - } - } - } catch (error: Exception) { - if (!isConnectivityFailure(error)) throw error - AndroidAccountVault.cachedFolder(account.optString("id"), requestedFolder, offset, filters) - ?: throw error - } - } - - private fun isConnectivityFailure(error: Throwable): Boolean { - var current: Throwable? = error - while (current != null) { - if (current is java.net.UnknownHostException || - current is java.net.ConnectException || - current is java.net.SocketTimeoutException || - current is javax.net.ssl.SSLException) return true - val message = current.message.orEmpty().lowercase(Locale.ROOT) - if (listOf("network is unreachable", "connection timed out", "connection refused", "unable to resolve host", "socket closed").any(message::contains)) return true - current = current.cause - } - return false - } - - private fun matchesFilters(message: JSONObject, filters: JSONObject): Boolean { - val query = filters.optString("query").trim().lowercase(Locale.ROOT) - val senderFilter = filters.optString("sender").trim().lowercase(Locale.ROOT) - val subjectFilter = filters.optString("subject").trim().lowercase(Locale.ROOT) - val sender = "${message.optString("sender")} ${message.optString("email")}".lowercase(Locale.ROOT) - val subject = message.optString("subject").lowercase(Locale.ROOT) - val haystack = "$sender $subject ${message.optString("snippet")} ${message.optJSONArray("body")?.toString().orEmpty()}".lowercase(Locale.ROOT) - val timestamp = message.optLong("timestamp") - val after = dateBoundary(filters.optString("after"), false) - val before = dateBoundary(filters.optString("before"), true) - val attachments = message.optJSONArray("attachments") - return (query.isBlank() || query.split(Regex("\\s+")).all(haystack::contains)) && - (senderFilter.isBlank() || sender.contains(senderFilter)) && - (subjectFilter.isBlank() || subject.contains(subjectFilter)) && - (after == null || timestamp >= after) && (before == null || timestamp <= before) && - (!filters.optBoolean("hasAttachments") || (attachments?.length() ?: 0) > 0) - } - - private fun dateBoundary(value: String, endOfDay: Boolean): Long? { - if (value.isBlank()) return null - val parsed = runCatching { SimpleDateFormat("yyyy-MM-dd", Locale.ROOT).parse(value) }.getOrNull() ?: return null - val calendar = Calendar.getInstance().apply { time = parsed } - if (endOfDay) { - calendar.add(Calendar.DAY_OF_MONTH, 1) - return calendar.timeInMillis - 1 - } - return calendar.timeInMillis - } - - private fun syncSnoozed(account: JSONObject, offset: Int): JSONObject = - withStore(account) { _, store -> - val snoozes = account.optJSONArray("snoozedMessages") ?: JSONArray() - val pending = (0 until snoozes.length()) - .map { snoozes.getJSONObject(it) } - .filter { it.optLong("dueAt") > System.currentTimeMillis() } - .sortedBy { it.optLong("dueAt") } - val page = pending.drop(offset.coerceAtLeast(0)).take(20) - val messages = JSONArray() - for (snooze in page) { - val sourceFolder = snooze.optString("folder", "Inbox") - val folder = resolveFolder(store, sourceFolder) ?: continue - folder.open(Folder.READ_ONLY) - try { - val message = (folder as? UIDFolder)?.getMessageByUID(snooze.optLong("uid")) ?: continue - messages.put(messageJson(folder, message, "Snoozed", account, sourceFolder) - .put("sourceFolder", sourceFolder) - .put("snoozedUntil", snooze.optLong("dueAt"))) - } finally { - folder.close(false) - } - } - JSONObject() - .put("messages", messages) - .put("total", pending.size) - .put("start", if (page.isEmpty()) 0 else offset + 1) - .put("end", offset + messages.length()) - .put("folder", "Snoozed") - } - - fun updateMessage(account: JSONObject, input: JSONObject): JSONObject = - withStore(account) { _, store -> - val uid = input.optLong("uid") - require(uid > 0) { "That message could not be identified." } - val action = input.optString("action") - require(action in setOf("star", "unread", "archive", "delete", "inbox")) { "That mail action is not supported." } - val source = resolveFolder(store, input.optString("folder", "Inbox")) - ?: throw IllegalStateException("That mail folder could not be found.") - var expungeDeleted = false - source.open(Folder.READ_WRITE) - try { - val message = (source as? UIDFolder)?.getMessageByUID(uid) - ?: throw IllegalStateException("The message is no longer available.") - when (action) { - "star" -> message.setFlag(Flags.Flag.FLAGGED, input.optBoolean("enabled")) - "unread" -> message.setFlag(Flags.Flag.SEEN, !input.optBoolean("enabled")) - "archive", "delete", "inbox" -> { - val targetName = when (action) { - "archive" -> "Archive" - "delete" -> "Trash" - else -> "Inbox" - } - val target = resolveFolder(store, targetName) ?: store.getFolder(targetName) - if (!target.exists()) target.create(Folder.HOLDS_MESSAGES) - if (source.fullName == target.fullName) { - if (action == "delete") { - expungeDeleted = true - message.setFlag(Flags.Flag.DELETED, true) - } - } else { - expungeDeleted = true - source.copyMessages(arrayOf(message), target) - message.setFlag(Flags.Flag.DELETED, true) - } - } - } - } finally { - source.close(expungeDeleted) - } - if (action == "archive" || action == "delete" || action == "inbox") { - AndroidAccountVault.setSnooze( - account.optString("id"), - uid, - input.optString("folder", "Inbox"), - null, - "" - ) - } - JSONObject().put("ok", true) - } - - fun send(account: JSONObject, input: JSONObject): JSONObject { - val recipient = input.optString("to").trim() - require(recipient.isNotEmpty()) { "Add at least one recipient." } - val properties = smtpProperties(account) - val session = Session.getInstance(properties, credentials(account)) - val message = MimeMessage(session) - message.setFrom(InternetAddress(account.optString("email"), displayName(account), "UTF-8")) - message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(recipient, true)) - val cc = input.optString("cc").trim() - if (cc.isNotEmpty()) message.setRecipients(Message.RecipientType.CC, InternetAddress.parse(cc, true)) - message.subject = input.optString("subject", "(no subject)") - val body = input.optString("text") - val signature = account.optString("signature").take(5000) - val fullBody = if (signature.isBlank()) body else "$body${if (body.isBlank()) "" else "\n\n"}$signature" - val attachments = input.optJSONArray("attachments") ?: JSONArray() - if (attachments.length() == 0) { - message.setText(fullBody, "UTF-8") - } else { - val multipart = MimeMultipart("mixed") - multipart.addBodyPart(MimeBodyPart().apply { setText(fullBody, "UTF-8") }) - for (index in 0 until attachments.length()) { - val file = attachments.optJSONObject(index) - ?: throw IllegalArgumentException("An attachment could not be read.") - val encoded = file.optString("contentBase64") - require(encoded.length % 4 == 0 && encoded.matches(Regex("^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$"))) { - "The contents of an attachment are invalid." - } - val filename = file.optString("filename", "attachment") - .replace(Regex("[\\\\/\\r\\n\\u0000]"), "") - .take(255) - .ifBlank { "attachment" } - val contentType = file.optString("contentType", "application/octet-stream") - .lowercase(Locale.ROOT) - require(contentType.matches(Regex("^[a-z0-9!#$&^_.+-]+/[a-z0-9!#$&^_.+-]+$"))) { - "The content type for $filename is invalid." - } - val part = MimeBodyPart() - part.dataHandler = DataHandler(ByteArrayDataSource(Base64.decode(encoded, Base64.DEFAULT), contentType)) - part.fileName = MimeUtility.encodeText(filename, "UTF-8", null) - part.disposition = javax.mail.Part.ATTACHMENT - multipart.addBodyPart(part) - } - message.setContent(multipart) - } - message.sentDate = Date() - message.saveChanges() - input.optString("messageId").takeIf(String::isNotBlank)?.let { message.setHeader("Message-ID", it) } - - val transport = session.getTransport("smtp") - try { - transport.connect( - account.optString("smtpHost"), - account.optInt("smtpPort", 587), - account.optString("email"), - account.optString("password") - ) - transport.sendMessage(message, message.allRecipients) - } finally { - if (transport.isConnected) transport.close() - } - - var savedToSent = false - try { - withStore(account) { _, store -> - val sent = resolveFolder(store, "Sent") ?: store.getFolder("Sent") - if (!sent.exists()) sent.create(Folder.HOLDS_MESSAGES) - sent.appendMessages(arrayOf(message)) - savedToSent = true - } - } catch (_: Exception) { - savedToSent = false - } - return JSONObject().put("ok", true).put("savedToSent", savedToSent) - } - - fun flushOutbox(account: JSONObject) { - val accountId = account.optString("id") - val queued = AndroidAccountVault.pendingMailOperations(accountId) - for (index in 0 until queued.length()) { - val operation = queued.optJSONObject(index) ?: continue - try { - val data = operation.optJSONObject("data") ?: continue - when (operation.optString("type")) { - "send" -> send(account, data) - "action" -> updateMessage(account, data) - else -> throw IllegalStateException("Unsupported queued mail operation.") - } - AndroidAccountVault.removeMailOperation(accountId, operation.optString("id")) - } catch (error: Exception) { - android.util.Log.w("EpMailOutbox", "Mail operation remains queued for a later retry.", error) - break - } - } - } - - fun saveAttachment(context: Context, account: JSONObject, input: JSONObject): JSONObject = - withStore(account) { _, store -> - val folder = resolveFolder(store, input.optString("folder", "Inbox")) - ?: throw IllegalStateException("That mail folder could not be found.") - folder.open(Folder.READ_ONLY) - try { - val uid = input.optLong("uid") - val message = (folder as? UIDFolder)?.getMessageByUID(uid) - ?: throw IllegalStateException("The message is no longer available.") - val filename = input.optString("filename") - val part = findAttachment(message, filename) - ?: throw IllegalStateException("No attachment was found in this message.") - saveAttachmentBytes(context, filename.ifBlank { "attachment" }, part.contentType, part.inputStream.readBytes()) - } finally { - folder.close(false) - } - } - - fun previewAttachment(account: JSONObject, input: JSONObject): JSONObject = - withStore(account) { _, store -> - val folder = resolveFolder(store, input.optString("folder", "Inbox")) - ?: throw IllegalStateException("That mail folder could not be found.") - folder.open(Folder.READ_ONLY) - try { - val message = (folder as? UIDFolder)?.getMessageByUID(input.optLong("uid")) - ?: throw IllegalStateException("The message is no longer available.") - val filename = input.optString("filename") - val part = findAttachment(message, filename) - ?: throw IllegalStateException("No attachment was found in this message.") - val mimeType = part.contentType.substringBefore(';').trim().lowercase(Locale.ROOT) - val none = JSONObject().put("kind", "none") - .put("reason", "No preview is available for this file type. Download it to open it.") - if (Regex("image/(png|jpe?g|gif|webp|bmp|svg\\+xml)").matches(mimeType)) { - val bytes = part.inputStream.use { it.readBytes() } - if (bytes.size > 5 * 1048576) { - none.put("reason", "This image is too large to preview. Download it instead.") - } else { - JSONObject().put("kind", "image").put( - "dataUrl", "data:$mimeType;base64," + android.util.Base64.encodeToString(bytes, android.util.Base64.NO_WRAP) - ) - } - } else if (mimeType.startsWith("text/") || mimeType == "application/json" || mimeType == "application/xml") { - val bytes = part.inputStream.use { it.readBytes() } - JSONObject().put("kind", "text") - .put("text", String(bytes.copyOf(minOf(bytes.size, 100000)), Charsets.UTF_8)) - .put("truncated", bytes.size > 100000) - } else none - } finally { - folder.close(false) - } - } - - fun checkForNewMail(account: JSONObject): Int { - flushOutbox(account) - return withStore(account) { _, store -> - val folder = store.getFolder("INBOX") - folder.open(Folder.READ_ONLY) - try { - val uidFolder = folder as? UIDFolder - ?: throw IllegalStateException("The mail server does not support stable message IDs.") - val validity = uidFolder.uidValidity - val latestUid = (uidFolder.uidNext - 1).coerceAtLeast(0) - val oldState = account.optJSONObject("androidInboxSyncState") - val lastUid = if (oldState == null || oldState.optLong("uidValidity") != validity) { - AndroidAccountVault.updateInboxCursor(account.optString("id"), validity, latestUid) - return@withStore 0 - } else oldState.optLong("lastUid") - if (latestUid <= lastUid) return@withStore 0 - val added = uidFolder.getMessagesByUID(lastUid + 1, UIDFolder.LASTUID) - AndroidAccountVault.updateInboxCursor(account.optString("id"), validity, latestUid) - applyRules(account, added.mapNotNull { try { uidFolder.getUID(it) } catch (_: Exception) { null } }) - added.size - } finally { - folder.close(false) - } - } - } - - fun applyRules(account: JSONObject, uids: List) { - val rules = account.optJSONArray("rules") ?: return - if (rules.length() == 0 || uids.isEmpty()) return - withStore(account) { _, store -> - val inbox = resolveFolder(store, "Inbox") ?: return@withStore - for (uid in uids.distinct()) { - try { - inbox.open(Folder.READ_WRITE) - try { - val message = (inbox as? UIDFolder)?.getMessageByUID(uid) ?: continue - val sender = message.from.orEmpty().joinToString(" ") { address -> - if (address is InternetAddress) "${address.personal.orEmpty()} ${address.address}" else address.toString() - } - val subject = message.subject.orEmpty() - val matched = (0 until rules.length()).asSequence() - .map { rules.getJSONObject(it) } - .firstOrNull { rule -> - val senderCondition = rule.optString("senderContains") - val subjectCondition = rule.optString("subjectContains") - (senderCondition.isBlank() || sender.contains(senderCondition, ignoreCase = true)) && - (subjectCondition.isBlank() || subject.contains(subjectCondition, ignoreCase = true)) - } ?: continue - when (matched.optString("action")) { - "flag" -> message.setFlag(Flags.Flag.FLAGGED, true) - "label" -> AndroidAccountVault.addRuleLabel( - account.optString("id"), "Inbox", uid, matched.optString("value") - ) - "archive", "move" -> { - val destination = if (matched.optString("action") == "archive") { - resolveFolder(store, "Archive") ?: store.getFolder("Archive").also { - if (!it.exists()) it.create(Folder.HOLDS_MESSAGES) - } - } else resolveFolder(store, matched.optString("value")) - ?: throw IllegalStateException("Rule destination mailbox \"${matched.optString("value")}\" was not found.") - if (destination.fullName != inbox.fullName) { - inbox.copyMessages(arrayOf(message), destination) - message.setFlag(Flags.Flag.DELETED, true) - } - } - } - } finally { - inbox.close(true) - } - } catch (error: Exception) { - android.util.Log.e("EpMailRules", "Could not apply a mail rule to message $uid", error) - } - } - } - } - - fun watchInbox( - account: JSONObject, - onNewMail: (Int) -> Unit, - shouldStop: () -> Boolean, - onConnection: (Store?, Folder?) -> Unit - ) { - val props = imapProperties(account).apply { - setProperty("mail.imap.timeout", "0") - setProperty("mail.imap.writetimeout", "60000") - } - val pollingIntervalMs = account.optInt("syncIntervalMinutes", 2) - .coerceIn(2, 60) * 60_000L - val session = Session.getInstance(props, credentials(account)) - val store = session.getStore("imap") - try { - store.connect( - account.optString("imapHost"), - account.optInt("imapPort", 143), - account.optString("email"), - account.optString("password") - ) - val inbox = store.getFolder("INBOX") - inbox.open(Folder.READ_ONLY) - var previousCount = inbox.messageCount - val uidFolder = inbox as? UIDFolder - val uidValidity = uidFolder?.uidValidity ?: 0L - val initialUid = uidFolder?.let { (it.uidNext - 1).coerceAtLeast(0) } ?: 0L - if (uidValidity > 0) { - AndroidAccountVault.updateInboxCursor(account.optString("id"), uidValidity, initialUid) - } - onConnection(store, inbox) - inbox.addMessageCountListener(object : javax.mail.event.MessageCountListener { - override fun messagesAdded(event: javax.mail.event.MessageCountEvent) { - if (event.type == javax.mail.event.MessageCountEvent.ADDED) { - previousCount = maxOf(previousCount, inbox.messageCount) - val newestUid = event.messages.maxOfOrNull { message -> - try { uidFolder?.getUID(message) ?: 0L } catch (_: Exception) { 0L } - } ?: 0L - if (uidValidity > 0 && newestUid > 0) { - AndroidAccountVault.updateInboxCursor(account.optString("id"), uidValidity, newestUid) - } - val addedUids = event.messages.mapNotNull { message -> - try { uidFolder?.getUID(message) } catch (_: Exception) { null } - } - Thread({ - applyRules(account, addedUids) - }, "ep-mail-rules-${account.optString("id")}").start() - onNewMail(event.messages.size) - } - } - override fun messagesRemoved(event: javax.mail.event.MessageCountEvent) = Unit - }) - try { - var supportsIdle = inbox is IMAPFolder - while (!shouldStop()) { - try { - if (supportsIdle && inbox is IMAPFolder) { - inbox.idle() - } else { - Thread.sleep(pollingIntervalMs) - val currentCount = inbox.messageCount - if (currentCount > previousCount) { - val added = checkForNewMail(account) - if (added > 0) onNewMail(added) - } - previousCount = currentCount - } - } catch (error: Exception) { - if (shouldStop()) break - if (error !is javax.mail.MethodNotSupportedException && - !error.javaClass.simpleName.contains("UnsupportedCommand")) throw error - supportsIdle = false - } - } - } finally { - onConnection(null, null) - if (inbox.isOpen) inbox.close(false) - } - } finally { - if (store.isConnected) store.close() - } - } - - fun accountFingerprint(account: JSONObject): String = listOf( - account.optString("email"), - account.optString("imapHost"), - account.optString("password"), - account.optBoolean("notificationsEnabled", true), - account.optInt("syncIntervalMinutes", 2), - account.optString("signature"), - account.optJSONArray("rules")?.toString().orEmpty() - ).joinToString("|").hashCode().toString() - - private fun messageJson( - folder: Folder, - message: Message, - requestedFolder: String, - account: JSONObject? = null, - labelFolder: String = requestedFolder - ): JSONObject { - val uid = (folder as? UIDFolder)?.getUID(message) ?: message.messageNumber.toLong() - val sender = (message.from?.firstOrNull() as? InternetAddress) - val senderName = decode(sender?.personal).ifBlank { sender?.address ?: "Unknown sender" } - val senderEmail = sender?.address ?: "" - val subject = decode(message.subject).ifBlank { "(no subject)" } - val body = ArrayList() - val htmlBodies = ArrayList() - val attachments = JSONArray() - val links = linkedSetOf() - collectParts(message, body, htmlBodies, attachments, links) - val bodyText = body.joinToString("\n\n").trim().take(8000) - val snippet = (bodyText.ifBlank { subject }).replace(Regex("\\s+"), " ").take(180) - val date = message.receivedDate ?: message.sentDate ?: Date() - val tags = JSONArray().put(requestedFolder) - val ruleLabels = account?.optJSONObject("ruleLabels")?.optJSONArray("$labelFolder:$uid") - if (ruleLabels != null) { - for (index in 0 until ruleLabels.length()) { - val label = ruleLabels.optString(index) - if (label.isNotBlank()) tags.put(label) - } - } - val files = attachmentList(attachments) - val flags = message.flags - val id = uid.toDouble() - return JSONObject() - .put("id", id) - .put("uid", uid) - .put("initials", senderName.split(Regex("[\\s@]+")).filter(String::isNotBlank) - .mapNotNull { it.firstOrNull()?.toString() }.joinToString("").take(2).uppercase(Locale.getDefault())) - .put("color", "#dce6df") - .put("sender", senderName) - .put("email", senderEmail) - .put("subject", subject) - .put("snippet", snippet) - .put("time", DateFormat.getTimeInstance(DateFormat.SHORT, Locale.getDefault()).format(date)) - .put("date", DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT, Locale.getDefault()).format(date)) - .put("timestamp", date.time) - .put("unread", !flags.contains(Flags.Flag.SEEN)) - .put("star", flags.contains(Flags.Flag.FLAGGED)) - .put("tags", tags) - .put("sent", requestedFolder == "Sent") - .put("archived", requestedFolder == "Archive") - .put("deleted", requestedFolder == "Trash") - .put("sourceFolder", labelFolder) - .put("html", htmlBodies.firstOrNull()?.take(100000) ?: "") - .put("body", JSONArray().apply { - val paragraphs = bodyText.split(Regex("\\n\\s*\\n")).map(String::trim).filter(String::isNotEmpty).take(40) - if (paragraphs.isEmpty()) put("This message has no plain-text body.") else paragraphs.forEach(::put) - }) - .put("links", JSONArray().apply { links.take(30).forEach(::put) }) - .put("attachments", attachments) - .put("attachment", files.firstOrNull()?.optString("filename") ?: JSONObject.NULL) - .put("size", files.firstOrNull()?.optString("size") ?: "") - } - - private fun attachmentList(attachments: JSONArray): List = - (0 until attachments.length()).map { attachments.getJSONObject(it) } - - private fun collectParts( - part: javax.mail.Part, - body: MutableList, - htmlBodies: MutableList, - attachments: JSONArray, - links: MutableSet - ) { - val filename = decode(part.fileName) - if (filename.isNotBlank() || part.disposition.equals(javax.mail.Part.ATTACHMENT, true)) { - val name = filename.ifBlank { "attachment" } - val size = part.size.coerceAtLeast(0) - attachments.put(JSONObject().put("filename", name).put("size", size)) - return - } - val content = try { part.content } catch (_: Exception) { return } - when (content) { - is String -> if (part.isMimeType("text/plain")) { - body.add(content.replace("\r", "").trim()) - } else if (part.isMimeType("text/html")) { - if (htmlBodies.isEmpty()) htmlBodies.add(content.take(100000)) - Regex("""]*\bhref\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))""", RegexOption.IGNORE_CASE) - .findAll(content) - .mapNotNull { match -> (match.groups[1]?.value ?: match.groups[2]?.value ?: match.groups[3]?.value)?.replace("&", "&") } - .take(30) - .forEach(links::add) - if (body.isEmpty()) body.add(Html.fromHtml(content, Html.FROM_HTML_MODE_LEGACY).toString().trim()) - } - is Multipart -> for (index in 0 until content.count) { - collectParts(content.getBodyPart(index), body, htmlBodies, attachments, links) - } - is javax.mail.BodyPart -> collectParts(content, body, htmlBodies, attachments, links) - } - } - - private fun findAttachment(part: javax.mail.Part, filename: String): MimeBodyPart? { - val name = decode(part.fileName) - if ((name == filename || (filename.isBlank() && name.isNotBlank())) && part is MimeBodyPart) return part - val content = try { part.content } catch (_: Exception) { return null } - if (content is Multipart) { - for (index in 0 until content.count) { - findAttachment(content.getBodyPart(index), filename)?.let { return it } - } - } - return null - } - +package studio.daybreak.mail + +import android.content.ContentValues +import android.content.Context +import android.os.Build +import android.os.Environment +import android.provider.MediaStore +import android.text.Html +import android.webkit.MimeTypeMap +import com.sun.mail.imap.IMAPFolder +import org.json.JSONArray +import org.json.JSONObject +import java.io.File +import java.text.DateFormat +import java.text.SimpleDateFormat +import java.util.Calendar +import java.util.Date +import java.util.Locale +import java.util.Properties +import java.util.UUID +import android.util.Base64 +import javax.activation.DataHandler +import javax.mail.Address +import javax.mail.Authenticator +import javax.mail.Flags +import javax.mail.Folder +import javax.mail.Message +import javax.mail.Multipart +import javax.mail.PasswordAuthentication +import javax.mail.Session +import javax.mail.Store +import javax.mail.Transport +import javax.mail.util.ByteArrayDataSource +import javax.mail.UIDFolder +import javax.mail.internet.InternetAddress +import javax.mail.internet.MimeBodyPart +import javax.mail.internet.MimeMessage +import javax.mail.internet.MimeMultipart +import javax.mail.internet.MimeUtility + +internal object AndroidMailService { + data class SyncResult(val payload: JSONObject, val newCount: Int) + + fun connect(account: JSONObject): JSONObject = withStore(account) { session, store -> + val inbox = store.getFolder("INBOX") + check(inbox.exists()) { "The inbox could not be found." } + inbox.open(Folder.READ_ONLY) + val count = inbox.messageCount + inbox.close(false) + val smtpSession = Session.getInstance(smtpProperties(account), credentials(account)) + val transport = smtpSession.getTransport("smtp") + try { + transport.connect( + account.optString("smtpHost"), + account.optInt("smtpPort", 587), + account.optString("email"), + account.optString("password") + ) + } finally { + if (transport.isConnected) transport.close() + } + JSONObject().put("mailbox", "INBOX").put("messages", count) + } + + fun sync(account: JSONObject, requestedFolder: String, offset: Int, filters: JSONObject = JSONObject()): JSONObject { + if (requestedFolder == "Snoozed") return syncSnoozed(account, offset) + return try { + withStore(account) { _, store -> + val folder = resolveFolder(store, requestedFolder) + if (folder == null) return@withStore JSONObject() + .put("messages", JSONArray()).put("total", 0).put("folder", requestedFolder) + folder.open(Folder.READ_ONLY) + try { + val total = folder.messageCount + val hasSearchFilters = listOf("query", "sender", "subject", "after", "before") + .any { filters.optString(it).isNotBlank() } || filters.optBoolean("hasAttachments") + if (hasSearchFilters) { + val all = JSONArray() + val snoozed = account.optJSONArray("snoozedMessages") ?: JSONArray() + if (total > 0) { + val start = (total - 4999).coerceAtLeast(1) + for (message in folder.getMessages(start, total)) { + val uid = (folder as? UIDFolder)?.getUID(message) ?: 0L + if (snoozed.length() > 0 && (0 until snoozed.length()).any { index -> + val item = snoozed.optJSONObject(index) ?: return@any false + item.optString("folder") == requestedFolder && item.optLong("uid") == uid && + item.optLong("dueAt") > System.currentTimeMillis() + }) continue + all.put(messageJson(folder, message, requestedFolder, account)) + } + } + AndroidAccountVault.cacheMessages(account.optString("id"), requestedFolder, all) + val matches = (0 until all.length()).mapNotNull { all.optJSONObject(it) } + .filter { matchesFilters(it, filters) } + .sortedByDescending { it.optLong("timestamp") } + val start = offset.coerceAtLeast(0) + val page = matches.drop(start).take(20) + return@withStore JSONObject() + .put("messages", JSONArray().apply { page.forEach(::put) }) + .put("total", matches.size) + .put("start", if (matches.isEmpty()) 0 else start + 1) + .put("end", start + page.size) + .put("folder", requestedFolder) + } + val end = (total - offset.coerceAtLeast(0)).coerceAtLeast(0) + if (end == 0) { + return@withStore JSONObject().put("messages", JSONArray()).put("total", total) + .put("start", 0).put("end", 0).put("folder", requestedFolder) + } + val first = (end - 19).coerceAtLeast(1) + val result = JSONArray() + val batch = folder.getMessages(first, end).reversed() + val snoozed = account.optJSONArray("snoozedMessages") ?: JSONArray() + val cached = JSONArray() + for (message in batch) { + val uid = (folder as? UIDFolder)?.getUID(message) ?: 0L + val isSnoozed = (0 until snoozed.length()).any { index -> + val item = snoozed.getJSONObject(index) + item.optString("folder") == requestedFolder && item.optLong("uid") == uid && + item.optLong("dueAt") > System.currentTimeMillis() + } + if (isSnoozed) continue + val value = messageJson(folder, message, requestedFolder, account) + result.put(value) + cached.put(value) + } + AndroidAccountVault.cacheMessages(account.optString("id"), requestedFolder, cached) + JSONObject().put("messages", result).put("total", total) + .put("start", first).put("end", end).put("folder", requestedFolder) + } finally { + folder.close(false) + } + } + } catch (error: Exception) { + if (!isConnectivityFailure(error)) throw error + AndroidAccountVault.cachedFolder(account.optString("id"), requestedFolder, offset, filters) + ?: throw error + } + } + + private fun isConnectivityFailure(error: Throwable): Boolean { + var current: Throwable? = error + while (current != null) { + if (current is java.net.UnknownHostException || + current is java.net.ConnectException || + current is java.net.SocketTimeoutException || + current is javax.net.ssl.SSLException) return true + val message = current.message.orEmpty().lowercase(Locale.ROOT) + if (listOf("network is unreachable", "connection timed out", "connection refused", "unable to resolve host", "socket closed").any(message::contains)) return true + current = current.cause + } + return false + } + + private fun matchesFilters(message: JSONObject, filters: JSONObject): Boolean { + val query = filters.optString("query").trim().lowercase(Locale.ROOT) + val senderFilter = filters.optString("sender").trim().lowercase(Locale.ROOT) + val subjectFilter = filters.optString("subject").trim().lowercase(Locale.ROOT) + val sender = "${message.optString("sender")} ${message.optString("email")}".lowercase(Locale.ROOT) + val subject = message.optString("subject").lowercase(Locale.ROOT) + val haystack = "$sender $subject ${message.optString("snippet")} ${message.optJSONArray("body")?.toString().orEmpty()}".lowercase(Locale.ROOT) + val timestamp = message.optLong("timestamp") + val after = dateBoundary(filters.optString("after"), false) + val before = dateBoundary(filters.optString("before"), true) + val attachments = message.optJSONArray("attachments") + return (query.isBlank() || query.split(Regex("\\s+")).all(haystack::contains)) && + (senderFilter.isBlank() || sender.contains(senderFilter)) && + (subjectFilter.isBlank() || subject.contains(subjectFilter)) && + (after == null || timestamp >= after) && (before == null || timestamp <= before) && + (!filters.optBoolean("hasAttachments") || (attachments?.length() ?: 0) > 0) + } + + private fun dateBoundary(value: String, endOfDay: Boolean): Long? { + if (value.isBlank()) return null + val parsed = runCatching { SimpleDateFormat("yyyy-MM-dd", Locale.ROOT).parse(value) }.getOrNull() ?: return null + val calendar = Calendar.getInstance().apply { time = parsed } + if (endOfDay) { + calendar.add(Calendar.DAY_OF_MONTH, 1) + return calendar.timeInMillis - 1 + } + return calendar.timeInMillis + } + + private fun syncSnoozed(account: JSONObject, offset: Int): JSONObject = + withStore(account) { _, store -> + val snoozes = account.optJSONArray("snoozedMessages") ?: JSONArray() + val pending = (0 until snoozes.length()) + .map { snoozes.getJSONObject(it) } + .filter { it.optLong("dueAt") > System.currentTimeMillis() } + .sortedBy { it.optLong("dueAt") } + val page = pending.drop(offset.coerceAtLeast(0)).take(20) + val messages = JSONArray() + for (snooze in page) { + val sourceFolder = snooze.optString("folder", "Inbox") + val folder = resolveFolder(store, sourceFolder) ?: continue + folder.open(Folder.READ_ONLY) + try { + val message = (folder as? UIDFolder)?.getMessageByUID(snooze.optLong("uid")) ?: continue + messages.put(messageJson(folder, message, "Snoozed", account, sourceFolder) + .put("sourceFolder", sourceFolder) + .put("snoozedUntil", snooze.optLong("dueAt"))) + } finally { + folder.close(false) + } + } + JSONObject() + .put("messages", messages) + .put("total", pending.size) + .put("start", if (page.isEmpty()) 0 else offset + 1) + .put("end", offset + messages.length()) + .put("folder", "Snoozed") + } + + fun updateMessage(account: JSONObject, input: JSONObject): JSONObject = + withStore(account) { _, store -> + val uid = input.optLong("uid") + require(uid > 0) { "That message could not be identified." } + val action = input.optString("action") + require(action in setOf("star", "unread", "archive", "delete", "inbox")) { "That mail action is not supported." } + val source = resolveFolder(store, input.optString("folder", "Inbox")) + ?: throw IllegalStateException("That mail folder could not be found.") + var expungeDeleted = false + source.open(Folder.READ_WRITE) + try { + val message = (source as? UIDFolder)?.getMessageByUID(uid) + ?: throw IllegalStateException("The message is no longer available.") + when (action) { + "star" -> message.setFlag(Flags.Flag.FLAGGED, input.optBoolean("enabled")) + "unread" -> message.setFlag(Flags.Flag.SEEN, !input.optBoolean("enabled")) + "archive", "delete", "inbox" -> { + val targetName = when (action) { + "archive" -> "Archive" + "delete" -> "Trash" + else -> "Inbox" + } + val target = resolveFolder(store, targetName) ?: store.getFolder(targetName) + if (!target.exists()) target.create(Folder.HOLDS_MESSAGES) + if (source.fullName == target.fullName) { + if (action == "delete") { + expungeDeleted = true + message.setFlag(Flags.Flag.DELETED, true) + } + } else { + expungeDeleted = true + source.copyMessages(arrayOf(message), target) + message.setFlag(Flags.Flag.DELETED, true) + } + } + } + } finally { + source.close(expungeDeleted) + } + if (action == "archive" || action == "delete" || action == "inbox") { + AndroidAccountVault.setSnooze( + account.optString("id"), + uid, + input.optString("folder", "Inbox"), + null, + "" + ) + } + JSONObject().put("ok", true) + } + + fun send(account: JSONObject, input: JSONObject): JSONObject { + val recipient = input.optString("to").trim() + require(recipient.isNotEmpty()) { "Add at least one recipient." } + val properties = smtpProperties(account) + val session = Session.getInstance(properties, credentials(account)) + val message = MimeMessage(session) + message.setFrom(InternetAddress(account.optString("email"), displayName(account), "UTF-8")) + message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(recipient, true)) + val cc = input.optString("cc").trim() + if (cc.isNotEmpty()) message.setRecipients(Message.RecipientType.CC, InternetAddress.parse(cc, true)) + message.subject = input.optString("subject", "(no subject)") + val body = input.optString("text") + val signature = account.optString("signature").take(5000) + val fullBody = if (signature.isBlank()) body else "$body${if (body.isBlank()) "" else "\n\n"}$signature" + val attachments = input.optJSONArray("attachments") ?: JSONArray() + if (attachments.length() == 0) { + message.setText(fullBody, "UTF-8") + } else { + val multipart = MimeMultipart("mixed") + multipart.addBodyPart(MimeBodyPart().apply { setText(fullBody, "UTF-8") }) + for (index in 0 until attachments.length()) { + val file = attachments.optJSONObject(index) + ?: throw IllegalArgumentException("An attachment could not be read.") + val encoded = file.optString("contentBase64") + require(encoded.length % 4 == 0 && encoded.matches(Regex("^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$"))) { + "The contents of an attachment are invalid." + } + val filename = file.optString("filename", "attachment") + .replace(Regex("[\\\\/\\r\\n\\u0000]"), "") + .take(255) + .ifBlank { "attachment" } + val contentType = file.optString("contentType", "application/octet-stream") + .lowercase(Locale.ROOT) + require(contentType.matches(Regex("^[a-z0-9!#$&^_.+-]+/[a-z0-9!#$&^_.+-]+$"))) { + "The content type for $filename is invalid." + } + val part = MimeBodyPart() + part.dataHandler = DataHandler(ByteArrayDataSource(Base64.decode(encoded, Base64.DEFAULT), contentType)) + part.fileName = MimeUtility.encodeText(filename, "UTF-8", null) + part.disposition = javax.mail.Part.ATTACHMENT + multipart.addBodyPart(part) + } + message.setContent(multipart) + } + message.sentDate = Date() + message.saveChanges() + input.optString("messageId").takeIf(String::isNotBlank)?.let { message.setHeader("Message-ID", it) } + + val transport = session.getTransport("smtp") + try { + transport.connect( + account.optString("smtpHost"), + account.optInt("smtpPort", 587), + account.optString("email"), + account.optString("password") + ) + transport.sendMessage(message, message.allRecipients) + } finally { + if (transport.isConnected) transport.close() + } + + var savedToSent = false + try { + withStore(account) { _, store -> + val sent = resolveFolder(store, "Sent") ?: store.getFolder("Sent") + if (!sent.exists()) sent.create(Folder.HOLDS_MESSAGES) + sent.appendMessages(arrayOf(message)) + savedToSent = true + } + } catch (_: Exception) { + savedToSent = false + } + return JSONObject().put("ok", true).put("savedToSent", savedToSent) + } + + fun flushOutbox(account: JSONObject) { + val accountId = account.optString("id") + val queued = AndroidAccountVault.pendingMailOperations(accountId) + for (index in 0 until queued.length()) { + val operation = queued.optJSONObject(index) ?: continue + try { + val data = operation.optJSONObject("data") ?: continue + when (operation.optString("type")) { + "send" -> send(account, data) + "action" -> updateMessage(account, data) + else -> throw IllegalStateException("Unsupported queued mail operation.") + } + AndroidAccountVault.removeMailOperation(accountId, operation.optString("id")) + } catch (error: Exception) { + android.util.Log.w("EpMailOutbox", "Mail operation remains queued (${error.javaClass.simpleName})") + break + } + } + } + + fun saveAttachment(context: Context, account: JSONObject, input: JSONObject): JSONObject = + withStore(account) { _, store -> + val folder = resolveFolder(store, input.optString("folder", "Inbox")) + ?: throw IllegalStateException("That mail folder could not be found.") + folder.open(Folder.READ_ONLY) + try { + val uid = input.optLong("uid") + val message = (folder as? UIDFolder)?.getMessageByUID(uid) + ?: throw IllegalStateException("The message is no longer available.") + val filename = input.optString("filename") + val part = findAttachment(message, filename) + ?: throw IllegalStateException("No attachment was found in this message.") + saveAttachmentBytes(context, filename.ifBlank { "attachment" }, part.contentType, part.inputStream.readBytes()) + } finally { + folder.close(false) + } + } + + fun previewAttachment(account: JSONObject, input: JSONObject): JSONObject = + withStore(account) { _, store -> + val folder = resolveFolder(store, input.optString("folder", "Inbox")) + ?: throw IllegalStateException("That mail folder could not be found.") + folder.open(Folder.READ_ONLY) + try { + val message = (folder as? UIDFolder)?.getMessageByUID(input.optLong("uid")) + ?: throw IllegalStateException("The message is no longer available.") + val filename = input.optString("filename") + val part = findAttachment(message, filename) + ?: throw IllegalStateException("No attachment was found in this message.") + val mimeType = part.contentType.substringBefore(';').trim().lowercase(Locale.ROOT) + val none = JSONObject().put("kind", "none") + .put("reason", "No preview is available for this file type. Download it to open it.") + if (Regex("image/(png|jpe?g|gif|webp|bmp|svg\\+xml)").matches(mimeType)) { + val bytes = part.inputStream.use { it.readBytes() } + if (bytes.size > 5 * 1048576) { + none.put("reason", "This image is too large to preview. Download it instead.") + } else { + JSONObject().put("kind", "image").put( + "dataUrl", "data:$mimeType;base64," + android.util.Base64.encodeToString(bytes, android.util.Base64.NO_WRAP) + ) + } + } else if (mimeType.startsWith("text/") || mimeType == "application/json" || mimeType == "application/xml") { + val bytes = part.inputStream.use { it.readBytes() } + JSONObject().put("kind", "text") + .put("text", String(bytes.copyOf(minOf(bytes.size, 100000)), Charsets.UTF_8)) + .put("truncated", bytes.size > 100000) + } else none + } finally { + folder.close(false) + } + } + + fun checkForNewMail(account: JSONObject): Int { + flushOutbox(account) + return withStore(account) { _, store -> + val folder = store.getFolder("INBOX") + folder.open(Folder.READ_ONLY) + try { + val uidFolder = folder as? UIDFolder + ?: throw IllegalStateException("The mail server does not support stable message IDs.") + val validity = uidFolder.uidValidity + val latestUid = (uidFolder.uidNext - 1).coerceAtLeast(0) + val oldState = account.optJSONObject("androidInboxSyncState") + val lastUid = if (oldState == null || oldState.optLong("uidValidity") != validity) { + AndroidAccountVault.updateInboxCursor(account.optString("id"), validity, latestUid) + return@withStore 0 + } else oldState.optLong("lastUid") + if (latestUid <= lastUid) return@withStore 0 + val added = uidFolder.getMessagesByUID(lastUid + 1, UIDFolder.LASTUID) + AndroidAccountVault.updateInboxCursor(account.optString("id"), validity, latestUid) + applyRules(account, added.mapNotNull { try { uidFolder.getUID(it) } catch (_: Exception) { null } }) + added.size + } finally { + folder.close(false) + } + } + } + + fun applyRules(account: JSONObject, uids: List) { + val rules = account.optJSONArray("rules") ?: return + if (rules.length() == 0 || uids.isEmpty()) return + withStore(account) { _, store -> + val inbox = resolveFolder(store, "Inbox") ?: return@withStore + for (uid in uids.distinct()) { + try { + inbox.open(Folder.READ_WRITE) + try { + val message = (inbox as? UIDFolder)?.getMessageByUID(uid) ?: continue + val sender = message.from.orEmpty().joinToString(" ") { address -> + if (address is InternetAddress) "${address.personal.orEmpty()} ${address.address}" else address.toString() + } + val subject = message.subject.orEmpty() + val matched = (0 until rules.length()).asSequence() + .map { rules.getJSONObject(it) } + .firstOrNull { rule -> + val senderCondition = rule.optString("senderContains") + val subjectCondition = rule.optString("subjectContains") + (senderCondition.isBlank() || sender.contains(senderCondition, ignoreCase = true)) && + (subjectCondition.isBlank() || subject.contains(subjectCondition, ignoreCase = true)) + } ?: continue + when (matched.optString("action")) { + "flag" -> message.setFlag(Flags.Flag.FLAGGED, true) + "label" -> AndroidAccountVault.addRuleLabel( + account.optString("id"), "Inbox", uid, matched.optString("value") + ) + "archive", "move" -> { + val destination = if (matched.optString("action") == "archive") { + resolveFolder(store, "Archive") ?: store.getFolder("Archive").also { + if (!it.exists()) it.create(Folder.HOLDS_MESSAGES) + } + } else resolveFolder(store, matched.optString("value")) + ?: throw IllegalStateException("Rule destination mailbox \"${matched.optString("value")}\" was not found.") + if (destination.fullName != inbox.fullName) { + inbox.copyMessages(arrayOf(message), destination) + message.setFlag(Flags.Flag.DELETED, true) + } + } + } + } finally { + inbox.close(true) + } + } catch (error: Exception) { + android.util.Log.e("EpMailRules", "Could not apply a mail rule (${error.javaClass.simpleName})") + } + } + } + } + + fun watchInbox( + account: JSONObject, + onNewMail: (Int) -> Unit, + shouldStop: () -> Boolean, + onConnection: (Store?, Folder?) -> Unit + ) { + val props = imapProperties(account).apply { + setProperty("mail.imap.timeout", "0") + setProperty("mail.imap.writetimeout", "60000") + } + val pollingIntervalMs = account.optInt("syncIntervalMinutes", 2) + .coerceIn(2, 60) * 60_000L + val session = Session.getInstance(props, credentials(account)) + val store = session.getStore("imap") + try { + store.connect( + account.optString("imapHost"), + account.optInt("imapPort", 143), + account.optString("email"), + account.optString("password") + ) + val inbox = store.getFolder("INBOX") + inbox.open(Folder.READ_ONLY) + var previousCount = inbox.messageCount + val uidFolder = inbox as? UIDFolder + val uidValidity = uidFolder?.uidValidity ?: 0L + val initialUid = uidFolder?.let { (it.uidNext - 1).coerceAtLeast(0) } ?: 0L + if (uidValidity > 0) { + AndroidAccountVault.updateInboxCursor(account.optString("id"), uidValidity, initialUid) + } + onConnection(store, inbox) + inbox.addMessageCountListener(object : javax.mail.event.MessageCountListener { + override fun messagesAdded(event: javax.mail.event.MessageCountEvent) { + if (event.type == javax.mail.event.MessageCountEvent.ADDED) { + previousCount = maxOf(previousCount, inbox.messageCount) + val newestUid = event.messages.maxOfOrNull { message -> + try { uidFolder?.getUID(message) ?: 0L } catch (_: Exception) { 0L } + } ?: 0L + if (uidValidity > 0 && newestUid > 0) { + AndroidAccountVault.updateInboxCursor(account.optString("id"), uidValidity, newestUid) + } + val addedUids = event.messages.mapNotNull { message -> + try { uidFolder?.getUID(message) } catch (_: Exception) { null } + } + Thread({ + applyRules(account, addedUids) + }, "ep-mail-rules-${account.optString("id")}").start() + onNewMail(event.messages.size) + } + } + override fun messagesRemoved(event: javax.mail.event.MessageCountEvent) = Unit + }) + try { + var supportsIdle = inbox is IMAPFolder + while (!shouldStop()) { + try { + if (supportsIdle && inbox is IMAPFolder) { + inbox.idle() + } else { + Thread.sleep(pollingIntervalMs) + val currentCount = inbox.messageCount + if (currentCount > previousCount) { + val added = checkForNewMail(account) + if (added > 0) onNewMail(added) + } + previousCount = currentCount + } + } catch (error: Exception) { + if (shouldStop()) break + if (error !is javax.mail.MethodNotSupportedException && + !error.javaClass.simpleName.contains("UnsupportedCommand")) throw error + supportsIdle = false + } + } + } finally { + onConnection(null, null) + if (inbox.isOpen) inbox.close(false) + } + } finally { + if (store.isConnected) store.close() + } + } + + fun accountFingerprint(account: JSONObject): String = listOf( + account.optString("email"), + account.optString("imapHost"), + account.optString("password"), + account.optBoolean("notificationsEnabled", true), + account.optInt("syncIntervalMinutes", 2), + account.optString("signature"), + account.optJSONArray("rules")?.toString().orEmpty() + ).joinToString("|").hashCode().toString() + + private fun messageJson( + folder: Folder, + message: Message, + requestedFolder: String, + account: JSONObject? = null, + labelFolder: String = requestedFolder + ): JSONObject { + val uid = (folder as? UIDFolder)?.getUID(message) ?: message.messageNumber.toLong() + val sender = (message.from?.firstOrNull() as? InternetAddress) + val senderName = decode(sender?.personal).ifBlank { sender?.address ?: "Unknown sender" } + val senderEmail = sender?.address ?: "" + val subject = decode(message.subject).ifBlank { "(no subject)" } + val body = ArrayList() + val htmlBodies = ArrayList() + val attachments = JSONArray() + val links = linkedSetOf() + collectParts(message, body, htmlBodies, attachments, links) + val bodyText = body.joinToString("\n\n").trim().take(8000) + val snippet = (bodyText.ifBlank { subject }).replace(Regex("\\s+"), " ").take(180) + val date = message.receivedDate ?: message.sentDate ?: Date() + val tags = JSONArray().put(requestedFolder) + val ruleLabels = account?.optJSONObject("ruleLabels")?.optJSONArray("$labelFolder:$uid") + if (ruleLabels != null) { + for (index in 0 until ruleLabels.length()) { + val label = ruleLabels.optString(index) + if (label.isNotBlank()) tags.put(label) + } + } + val files = attachmentList(attachments) + val flags = message.flags + val id = uid.toDouble() + return JSONObject() + .put("id", id) + .put("uid", uid) + .put("initials", senderName.split(Regex("[\\s@]+")).filter(String::isNotBlank) + .mapNotNull { it.firstOrNull()?.toString() }.joinToString("").take(2).uppercase(Locale.getDefault())) + .put("color", "#dce6df") + .put("sender", senderName) + .put("email", senderEmail) + .put("subject", subject) + .put("snippet", snippet) + .put("time", DateFormat.getTimeInstance(DateFormat.SHORT, Locale.getDefault()).format(date)) + .put("date", DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT, Locale.getDefault()).format(date)) + .put("timestamp", date.time) + .put("unread", !flags.contains(Flags.Flag.SEEN)) + .put("star", flags.contains(Flags.Flag.FLAGGED)) + .put("tags", tags) + .put("sent", requestedFolder == "Sent") + .put("archived", requestedFolder == "Archive") + .put("deleted", requestedFolder == "Trash") + .put("sourceFolder", labelFolder) + .put("html", htmlBodies.firstOrNull()?.take(100000) ?: "") + .put("body", JSONArray().apply { + val paragraphs = bodyText.split(Regex("\\n\\s*\\n")).map(String::trim).filter(String::isNotEmpty).take(40) + if (paragraphs.isEmpty()) put("This message has no plain-text body.") else paragraphs.forEach(::put) + }) + .put("links", JSONArray().apply { links.take(30).forEach(::put) }) + .put("attachments", attachments) + .put("attachment", files.firstOrNull()?.optString("filename") ?: JSONObject.NULL) + .put("size", files.firstOrNull()?.optString("size") ?: "") + } + + private fun attachmentList(attachments: JSONArray): List = + (0 until attachments.length()).map { attachments.getJSONObject(it) } + + private fun collectParts( + part: javax.mail.Part, + body: MutableList, + htmlBodies: MutableList, + attachments: JSONArray, + links: MutableSet + ) { + val filename = decode(part.fileName) + if (filename.isNotBlank() || part.disposition.equals(javax.mail.Part.ATTACHMENT, true)) { + val name = filename.ifBlank { "attachment" } + val size = part.size.coerceAtLeast(0) + attachments.put(JSONObject().put("filename", name).put("size", size)) + return + } + val content = try { part.content } catch (_: Exception) { return } + when (content) { + is String -> if (part.isMimeType("text/plain")) { + body.add(content.replace("\r", "").trim()) + } else if (part.isMimeType("text/html")) { + if (htmlBodies.isEmpty()) htmlBodies.add(content.take(100000)) + Regex("""]*\bhref\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))""", RegexOption.IGNORE_CASE) + .findAll(content) + .mapNotNull { match -> (match.groups[1]?.value ?: match.groups[2]?.value ?: match.groups[3]?.value)?.replace("&", "&") } + .take(30) + .forEach(links::add) + if (body.isEmpty()) body.add(Html.fromHtml(content, Html.FROM_HTML_MODE_LEGACY).toString().trim()) + } + is Multipart -> for (index in 0 until content.count) { + collectParts(content.getBodyPart(index), body, htmlBodies, attachments, links) + } + is javax.mail.BodyPart -> collectParts(content, body, htmlBodies, attachments, links) + } + } + + private fun findAttachment(part: javax.mail.Part, filename: String): MimeBodyPart? { + val name = decode(part.fileName) + if ((name == filename || (filename.isBlank() && name.isNotBlank())) && part is MimeBodyPart) return part + val content = try { part.content } catch (_: Exception) { return null } + if (content is Multipart) { + for (index in 0 until content.count) { + findAttachment(content.getBodyPart(index), filename)?.let { return it } + } + } + return null + } + private fun saveAttachmentBytes(context: Context, filename: String, contentType: String, bytes: ByteArray): JSONObject { + val safeFilename = AttachmentNamePolicy.sanitize(filename) val mimeType = contentType.substringBefore(';').ifBlank { - MimeTypeMap.getSingleton().getMimeTypeFromExtension(filename.substringAfterLast('.', "")) ?: "application/octet-stream" + MimeTypeMap.getSingleton().getMimeTypeFromExtension(safeFilename.substringAfterLast('.', "")) ?: "application/octet-stream" } if (Build.VERSION.SDK_INT >= 29) { val values = ContentValues().apply { - put(MediaStore.Downloads.DISPLAY_NAME, filename) - put(MediaStore.Downloads.MIME_TYPE, mimeType) - put(MediaStore.Downloads.RELATIVE_PATH, Environment.DIRECTORY_DOWNLOADS) - } - val uri = context.contentResolver.insert(MediaStore.Downloads.EXTERNAL_CONTENT_URI, values) - ?: throw IllegalStateException("Could not create the attachment in Downloads.") - context.contentResolver.openOutputStream(uri)?.use { it.write(bytes) } - ?: throw IllegalStateException("Could not write the attachment.") - return JSONObject().put("saved", true).put("uri", uri.toString()).put("filename", filename) + put(MediaStore.Downloads.DISPLAY_NAME, safeFilename) + put(MediaStore.Downloads.MIME_TYPE, mimeType) + put(MediaStore.Downloads.RELATIVE_PATH, Environment.DIRECTORY_DOWNLOADS) + } + val uri = context.contentResolver.insert(MediaStore.Downloads.EXTERNAL_CONTENT_URI, values) + ?: throw IllegalStateException("Could not create the attachment in Downloads.") + context.contentResolver.openOutputStream(uri)?.use { it.write(bytes) } + ?: throw IllegalStateException("Could not write the attachment.") + return JSONObject().put("saved", true).put("uri", uri.toString()).put("filename", safeFilename) } - val directory = context.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS) - ?: throw IllegalStateException("Downloads storage is not available.") - val file = File(directory, filename.replace(Regex("[\\\\/:*?\"<>|]"), "_")) + val directory = context.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS) + ?: throw IllegalStateException("Downloads storage is not available.") + val file = File(directory, safeFilename) file.writeBytes(bytes) - return JSONObject().put("saved", true).put("path", file.absolutePath).put("filename", filename) + return JSONObject().put("saved", true).put("path", file.absolutePath).put("filename", safeFilename) } - - private const val CUSTOM_FOLDER_PREFIX = "Folder:" - private val reservedFolderNames = setOf( - "inbox", "sent", "drafts", "archive", "trash", "starred", "snoozed", "junk", "spam", - "sent items", "sent mail", "sent messages", "archives", "all mail", "deleted items", "deleted messages" - ) - - fun isCustomFolder(name: String) = name.startsWith(CUSTOM_FOLDER_PREFIX) - - private fun customFolders(store: Store): JSONArray { - val systemAttributes = setOf("\\sent", "\\archive", "\\trash", "\\drafts", "\\junk", "\\all", "\\flagged") - val result = JSONArray() - val folders = try { store.defaultFolder.list("*") } catch (_: Exception) { emptyArray() } - folders.filter { folder -> - val attributes = (folder as? IMAPFolder)?.attributes?.map { it.lowercase(Locale.ROOT) } ?: emptyList() - folder.fullName.uppercase(Locale.ROOT) != "INBOX" && - (folder.type and Folder.HOLDS_MESSAGES) != 0 && - attributes.none { it in systemAttributes } && - folder.fullName.lowercase(Locale.ROOT).split(Regex("[./]")).last() !in reservedFolderNames - }.sortedBy { it.fullName }.forEach { folder -> - result.put(JSONObject().put("name", folder.name).put("path", folder.fullName) - .put("id", CUSTOM_FOLDER_PREFIX + folder.fullName)) - } - return result - } - - fun listFolders(account: JSONObject): JSONObject = - withStore(account) { _, store -> JSONObject().put("folders", customFolders(store)) } - - fun createFolder(account: JSONObject, rawName: String): JSONObject { - val name = rawName.trim() - require(name.isNotEmpty() && name.length <= 100) { "Enter a folder name of up to 100 characters." } - require(!Regex("[\\\\/.*%#&\\u0000-\\u001f]").containsMatchIn(name)) { - "Folder names cannot contain / \\ . * % # & or control characters." - } - require(name.lowercase(Locale.ROOT) !in reservedFolderNames) { "That folder name is reserved." } - return withStore(account) { _, store -> - val folder = store.getFolder(name) - check(!folder.exists()) { "A folder with that name already exists." } - check(folder.create(Folder.HOLDS_MESSAGES)) { "The mail server could not create that folder." } - try { folder.isSubscribed = true } catch (_: Exception) {} - JSONObject().put("ok", true) - .put("folder", JSONObject().put("name", name).put("path", folder.fullName) - .put("id", CUSTOM_FOLDER_PREFIX + folder.fullName)) - .put("folders", customFolders(store)) - } - } - - private fun resolveFolder(store: Store, requested: String): Folder? { - if (requested.startsWith(CUSTOM_FOLDER_PREFIX)) { - return store.getFolder(requested.removePrefix(CUSTOM_FOLDER_PREFIX)).takeIf { it.exists() } - } - if (requested == "Inbox" || requested == "Starred" || requested == "Snoozed") { - return store.getFolder("INBOX") - } - val (specialUse, candidates) = when (requested) { - "Sent" -> "\\Sent" to setOf("sent", "sent items", "sent mail", "sent messages") - "Archive" -> "\\Archive" to setOf("archive", "archives", "all mail") - "Trash" -> "\\Trash" to setOf("trash", "deleted items", "deleted messages") - else -> return store.getFolder(requested).takeIf { it.exists() } - } - val folders = try { store.defaultFolder.list("*") } catch (_: Exception) { emptyArray() } - return folders.firstOrNull { folder -> - val imapFolder = folder as? IMAPFolder - imapFolder?.attributes?.any { it.equals(specialUse, true) } == true - } ?: folders.firstOrNull { folder -> - folder.fullName.lowercase(Locale.ROOT).split(Regex("[./]")).lastOrNull() in candidates - } - } - - private fun withStore(account: JSONObject, block: (Session, Store) -> T): T { - val session = Session.getInstance(imapProperties(account), credentials(account)) - val store = session.getStore("imap") - try { - store.connect( - account.optString("imapHost"), - account.optInt("imapPort", 143), - account.optString("email"), - account.optString("password") - ) - return block(session, store) - } finally { - if (store.isConnected) store.close() - } - } - - private fun credentials(account: JSONObject) = object : Authenticator() { - override fun getPasswordAuthentication() = PasswordAuthentication( - account.optString("email"), - account.optString("password") - ) - } - - private fun imapProperties(account: JSONObject) = Properties().apply { - setProperty("mail.store.protocol", "imap") - setProperty("mail.imap.host", account.optString("imapHost")) - setProperty("mail.imap.port", account.optInt("imapPort", 143).toString()) - setProperty("mail.imap.auth", "true") - setProperty("mail.imap.starttls.enable", "true") - setProperty("mail.imap.starttls.required", "true") - setProperty("mail.imap.ssl.checkserveridentity", "true") - setProperty("mail.imap.connectiontimeout", "20000") - setProperty("mail.imap.timeout", "30000") - setProperty("mail.imap.writetimeout", "30000") - } - - private fun smtpProperties(account: JSONObject) = Properties().apply { - setProperty("mail.smtp.host", account.optString("smtpHost")) - setProperty("mail.smtp.port", account.optInt("smtpPort", 587).toString()) - setProperty("mail.smtp.auth", "true") - setProperty("mail.smtp.starttls.enable", "true") - setProperty("mail.smtp.starttls.required", "true") - setProperty("mail.smtp.ssl.checkserveridentity", "true") - setProperty("mail.smtp.connectiontimeout", "20000") - setProperty("mail.smtp.timeout", "30000") - setProperty("mail.smtp.writetimeout", "30000") - } - - private fun displayName(account: JSONObject) = - account.optString("displayName").replace(Regex("[\\r\\n]"), " ").take(80) - - private fun decode(value: String?): String = try { - if (value.isNullOrBlank()) "" else MimeUtility.decodeText(value) - } catch (_: Exception) { - value.orEmpty() - } -} + + private const val CUSTOM_FOLDER_PREFIX = "Folder:" + private val reservedFolderNames = setOf( + "inbox", "sent", "drafts", "archive", "trash", "starred", "snoozed", "junk", "spam", + "sent items", "sent mail", "sent messages", "archives", "all mail", "deleted items", "deleted messages" + ) + + fun isCustomFolder(name: String) = name.startsWith(CUSTOM_FOLDER_PREFIX) + + private fun customFolders(store: Store): JSONArray { + val systemAttributes = setOf("\\sent", "\\archive", "\\trash", "\\drafts", "\\junk", "\\all", "\\flagged") + val result = JSONArray() + val folders = try { store.defaultFolder.list("*") } catch (_: Exception) { emptyArray() } + folders.filter { folder -> + val attributes = (folder as? IMAPFolder)?.attributes?.map { it.lowercase(Locale.ROOT) } ?: emptyList() + folder.fullName.uppercase(Locale.ROOT) != "INBOX" && + (folder.type and Folder.HOLDS_MESSAGES) != 0 && + attributes.none { it in systemAttributes } && + folder.fullName.lowercase(Locale.ROOT).split(Regex("[./]")).last() !in reservedFolderNames + }.sortedBy { it.fullName }.forEach { folder -> + result.put(JSONObject().put("name", folder.name).put("path", folder.fullName) + .put("id", CUSTOM_FOLDER_PREFIX + folder.fullName)) + } + return result + } + + fun listFolders(account: JSONObject): JSONObject = + withStore(account) { _, store -> JSONObject().put("folders", customFolders(store)) } + + fun createFolder(account: JSONObject, rawName: String): JSONObject { + val name = rawName.trim() + require(name.isNotEmpty() && name.length <= 100) { "Enter a folder name of up to 100 characters." } + require(!Regex("[\\\\/.*%#&\\u0000-\\u001f]").containsMatchIn(name)) { + "Folder names cannot contain / \\ . * % # & or control characters." + } + require(name.lowercase(Locale.ROOT) !in reservedFolderNames) { "That folder name is reserved." } + return withStore(account) { _, store -> + val folder = store.getFolder(name) + check(!folder.exists()) { "A folder with that name already exists." } + check(folder.create(Folder.HOLDS_MESSAGES)) { "The mail server could not create that folder." } + try { folder.isSubscribed = true } catch (_: Exception) {} + JSONObject().put("ok", true) + .put("folder", JSONObject().put("name", name).put("path", folder.fullName) + .put("id", CUSTOM_FOLDER_PREFIX + folder.fullName)) + .put("folders", customFolders(store)) + } + } + + private fun resolveFolder(store: Store, requested: String): Folder? { + if (requested.startsWith(CUSTOM_FOLDER_PREFIX)) { + return store.getFolder(requested.removePrefix(CUSTOM_FOLDER_PREFIX)).takeIf { it.exists() } + } + if (requested == "Inbox" || requested == "Starred" || requested == "Snoozed") { + return store.getFolder("INBOX") + } + val (specialUse, candidates) = when (requested) { + "Sent" -> "\\Sent" to setOf("sent", "sent items", "sent mail", "sent messages") + "Archive" -> "\\Archive" to setOf("archive", "archives", "all mail") + "Trash" -> "\\Trash" to setOf("trash", "deleted items", "deleted messages") + else -> return store.getFolder(requested).takeIf { it.exists() } + } + val folders = try { store.defaultFolder.list("*") } catch (_: Exception) { emptyArray() } + return folders.firstOrNull { folder -> + val imapFolder = folder as? IMAPFolder + imapFolder?.attributes?.any { it.equals(specialUse, true) } == true + } ?: folders.firstOrNull { folder -> + folder.fullName.lowercase(Locale.ROOT).split(Regex("[./]")).lastOrNull() in candidates + } + } + + private fun withStore(account: JSONObject, block: (Session, Store) -> T): T { + val session = Session.getInstance(imapProperties(account), credentials(account)) + val store = session.getStore("imap") + try { + store.connect( + account.optString("imapHost"), + account.optInt("imapPort", 143), + account.optString("email"), + account.optString("password") + ) + return block(session, store) + } finally { + if (store.isConnected) store.close() + } + } + + private fun credentials(account: JSONObject) = object : Authenticator() { + override fun getPasswordAuthentication() = PasswordAuthentication( + account.optString("email"), + account.optString("password") + ) + } + + private fun imapProperties(account: JSONObject) = Properties().apply { + setProperty("mail.store.protocol", "imap") + setProperty("mail.imap.host", account.optString("imapHost")) + setProperty("mail.imap.port", account.optInt("imapPort", 143).toString()) + setProperty("mail.imap.auth", "true") + setProperty("mail.imap.starttls.enable", "true") + setProperty("mail.imap.starttls.required", "true") + setProperty("mail.imap.ssl.checkserveridentity", "true") + setProperty("mail.imap.connectiontimeout", "20000") + setProperty("mail.imap.timeout", "30000") + setProperty("mail.imap.writetimeout", "30000") + } + + private fun smtpProperties(account: JSONObject) = Properties().apply { + setProperty("mail.smtp.host", account.optString("smtpHost")) + setProperty("mail.smtp.port", account.optInt("smtpPort", 587).toString()) + setProperty("mail.smtp.auth", "true") + setProperty("mail.smtp.starttls.enable", "true") + setProperty("mail.smtp.starttls.required", "true") + setProperty("mail.smtp.ssl.checkserveridentity", "true") + setProperty("mail.smtp.connectiontimeout", "20000") + setProperty("mail.smtp.timeout", "30000") + setProperty("mail.smtp.writetimeout", "30000") + } + + private fun displayName(account: JSONObject) = + account.optString("displayName").replace(Regex("[\\r\\n]"), " ").take(80) + + private fun decode(value: String?): String = try { + if (value.isNullOrBlank()) "" else MimeUtility.decodeText(value) + } catch (_: Exception) { + value.orEmpty() + } +} diff --git a/android/app/src/main/java/studio/daybreak/mail/AttachmentNamePolicy.kt b/android/app/src/main/java/studio/daybreak/mail/AttachmentNamePolicy.kt new file mode 100644 index 0000000..295f000 --- /dev/null +++ b/android/app/src/main/java/studio/daybreak/mail/AttachmentNamePolicy.kt @@ -0,0 +1,11 @@ +package studio.daybreak.mail + +internal object AttachmentNamePolicy { + fun sanitize(value: String): String { + val name = value + .replace(Regex("[\\\\/:*?\"<>|\\u0000-\\u001f]"), "_") + .trim() + .take(180) + return if (name.isBlank() || name == "." || name == "..") "attachment" else name + } +} diff --git a/android/app/src/main/java/studio/daybreak/mail/DavUrlPolicy.kt b/android/app/src/main/java/studio/daybreak/mail/DavUrlPolicy.kt new file mode 100644 index 0000000..4ea757e --- /dev/null +++ b/android/app/src/main/java/studio/daybreak/mail/DavUrlPolicy.kt @@ -0,0 +1,31 @@ +package studio.daybreak.mail + +import java.net.URL + +/** Enforces the transport and origin policy for user-configured DAV endpoints. */ +internal object DavUrlPolicy { + fun parseServerUrl(raw: String): URL { + val url = try { + URL(raw) + } catch (_: Exception) { + throw IllegalArgumentException("Enter a valid CalDAV or CardDAV server URL.") + } + require(url.protocol.equals("https", ignoreCase = true) && url.host.isNotBlank()) { + "DAV server URLs must use HTTPS." + } + require(url.userInfo == null && url.ref == null) { + "DAV server URLs cannot contain credentials or fragments." + } + return url + } + + fun requireSameOrigin(baseAddress: String, targetAddress: String) { + val base = parseServerUrl(baseAddress) + val target = parseServerUrl(targetAddress) + val basePort = if (base.port >= 0) base.port else base.defaultPort + val targetPort = if (target.port >= 0) target.port else target.defaultPort + require(target.host.equals(base.host, ignoreCase = true) && targetPort == basePort) { + "The DAV server returned a collection URL on an unexpected host." + } + } +} diff --git a/android/app/src/main/java/studio/daybreak/mail/EpMailPlugin.kt b/android/app/src/main/java/studio/daybreak/mail/EpMailPlugin.kt index 189d1b3..d3d5612 100644 --- a/android/app/src/main/java/studio/daybreak/mail/EpMailPlugin.kt +++ b/android/app/src/main/java/studio/daybreak/mail/EpMailPlugin.kt @@ -1,519 +1,519 @@ -package studio.daybreak.mail - -import android.content.BroadcastReceiver -import android.content.Context -import android.content.Intent -import android.content.IntentFilter -import android.net.Uri -import android.os.Build -import android.app.AlertDialog -import com.getcapacitor.JSObject -import com.getcapacitor.Plugin -import com.getcapacitor.PluginCall -import com.getcapacitor.PluginMethod -import com.getcapacitor.annotation.CapacitorPlugin -import java.util.Locale -import java.util.UUID -import org.json.JSONArray -import org.json.JSONObject - -@CapacitorPlugin(name = "EpMail") -class EpMailPlugin : Plugin() { - private var syncReceiver: BroadcastReceiver? = null - - override fun load() { - AndroidAccountVault.initialize(context) - val filter = IntentFilter(MailIdleService.ACTION_MAIL_SYNC) - val receiver = object : BroadcastReceiver() { - override fun onReceive(context: Context, intent: Intent) { - val update = intent.getStringExtra(MailIdleService.EXTRA_SYNC_UPDATE) ?: return - notifyListeners("mailSyncUpdate", JSObject(update)) - } - } - syncReceiver = receiver - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { - context.registerReceiver(receiver, filter, Context.RECEIVER_NOT_EXPORTED) - } else { - @Suppress("DEPRECATION") - context.registerReceiver(receiver, filter) - } - MailIdleService.start(context) - } - - override fun handleOnResume() { - MailIdleService.start(context) - } - - override fun handleOnDestroy() { - syncReceiver?.let { - try { context.unregisterReceiver(it) } catch (_: IllegalArgumentException) {} - } - syncReceiver = null - } - - @PluginMethod - fun getAppVersion(call: PluginCall) { - call.resolve(JSObject().put("version", BuildConfig.VERSION_NAME)) - } - - @PluginMethod - fun getAccount(call: PluginCall) { - val account = AndroidAccountVault.account() - if (account == null) call.resolve() - else call.resolve(AndroidAccountVault.publicAccount(account).toJSObject()) - } - - @PluginMethod - fun listAccounts(call: PluginCall) { - val store = AndroidAccountVault.read() - call.resolve(JSObject() - .put("accounts", AndroidAccountVault.publicAccounts()) - .put("activeId", store.optString("activeId"))) - } - - @PluginMethod - fun selectAccount(call: PluginCall) { - try { - val id = call.getString("id") ?: throw IllegalArgumentException("Choose a mail account.") - val account = AndroidAccountVault.account(id) - ?: throw IllegalStateException("That mail account is no longer available.") - val store = AndroidAccountVault.read().put("activeId", id) - AndroidAccountVault.write(store) - MailIdleService.start(context) - call.resolve(AndroidAccountVault.publicAccount(account).toJSObject()) - } catch (error: Exception) { - call.reject(error.message ?: "Could not select the mail account.") - } - } - - @PluginMethod - fun removeAccount(call: PluginCall) { - try { - val id = call.getString("id") ?: throw IllegalArgumentException("Choose a mail account.") - val result = AndroidAccountVault.removeAccount(id) - if (AndroidAccountVault.accounts().length() == 0) MailIdleService.stop(context) - else MailIdleService.start(context) - call.resolve(result.toJSObject()) - } catch (error: Exception) { - call.reject(error.message ?: "Could not remove the mail account.") - } - } - - @PluginMethod - fun connect(call: PluginCall) { - try { - val account = normalizeAccount(call.data) - val status = AndroidMailService.connect(account) - val saved = AndroidAccountVault.saveAccount(account) - MailIdleService.start(context) - call.resolve(AndroidAccountVault.publicAccount(saved) - .put("ok", true) - .put("mailbox", status.optString("mailbox")) - .put("messages", status.optInt("messages")).toJSObject()) - } catch (error: Exception) { - call.reject("Could not connect to the mailbox: ${error.message}") - } - } - - @PluginMethod - fun updateAccount(call: PluginCall) { - try { - val id = call.getString("id") ?: throw IllegalArgumentException("Choose a mail account.") - val existing = AndroidAccountVault.account(id) - ?: throw IllegalStateException("That mail account is no longer available.") - val input = JSONObject(call.data.toString()).apply { - if (optString("password").isBlank()) put("password", existing.optString("password")) - } - val account = normalizeAccount(input).put("id", id) - val status = AndroidMailService.connect(account) - val saved = AndroidAccountVault.saveAccount(account) - MailIdleService.start(context) - call.resolve(AndroidAccountVault.publicAccount(saved) - .put("mailbox", status.optString("mailbox")) - .put("messages", status.optInt("messages")).toJSObject()) - } catch (error: Exception) { - call.reject("Could not update the mailbox: ${error.message}") - } - } - - @PluginMethod - fun listFolders(call: PluginCall) { - try { - val account = AndroidAccountVault.account() - ?: throw IllegalStateException("Add a mail account before listing folders.") - call.resolve(AndroidMailService.listFolders(account).toJSObject()) - } catch (error: Exception) { - call.resolve(JSObject().put("folders", org.json.JSONArray()).put("offline", true)) - } - } - - @PluginMethod - fun createFolder(call: PluginCall) { - try { - val account = AndroidAccountVault.account() - ?: throw IllegalStateException("Add a mail account before creating folders.") - call.resolve(AndroidMailService.createFolder(account, call.getString("name") ?: "").toJSObject()) - } catch (error: Exception) { - call.reject(error.message ?: "Could not create the folder.") - } - } - - @PluginMethod - fun syncFolder(call: PluginCall) { - try { - val account = AndroidAccountVault.account() - ?: throw IllegalStateException("Add a mail account before syncing.") - val requested = call.getString("folder") ?: "Inbox" - val filters = call.getObject("filters") ?: JSObject() - val filterFolder = filters.getString("folder") - val selected = filterFolder?.takeIf { it in setOf("Inbox", "Sent", "Archive", "Trash", "Starred") } ?: requested - val folder = if (selected in setOf("Inbox", "Sent", "Archive", "Trash", "Starred", "Snoozed") || AndroidMailService.isCustomFolder(selected)) selected else "Inbox" - val offset = (call.getInt("offset") ?: 0).coerceAtLeast(0) - AndroidMailService.flushOutbox(account) - call.resolve(AndroidMailService.sync(account, folder, offset, JSONObject(filters.toString())).toJSObject()) - } catch (error: Exception) { - call.reject(error.message ?: "Could not sync the mailbox.") - } - } - - @PluginMethod - fun updateMessage(call: PluginCall) { - try { - val account = AndroidAccountVault.account() - ?: throw IllegalStateException("Add a mail account before changing messages.") - call.resolve(AndroidMailService.updateMessage(account, call.data).toJSObject()) - } catch (error: Exception) { - val account = AndroidAccountVault.account() - if (account != null && isConnectivityFailure(error)) { - AndroidAccountVault.enqueueMailOperation(account.optString("id"), JSONObject() - .put("id", UUID.randomUUID().toString()) - .put("type", "action") - .put("data", JSONObject(call.data.toString()))) - call.resolve(JSObject().put("ok", true).put("queued", true)) - } else call.reject(error.message ?: "Could not update the message.") - } - } - - @PluginMethod - fun setSnooze(call: PluginCall) { - try { - val account = AndroidAccountVault.account() - ?: throw IllegalStateException("Add a mail account before setting a reminder.") - val uid = call.getLong("uid") ?: throw IllegalArgumentException("That message could not be identified.") - require(uid > 0) { "That message could not be identified." } - val folder = call.getString("sourceFolder") ?: call.getString("folder") ?: "Inbox" - require(folder in setOf("Inbox", "Sent", "Archive", "Trash")) { "That mailbox cannot be snoozed." } - val dueAt = call.getLong("dueAt") - if (dueAt != null && dueAt <= System.currentTimeMillis()) { - throw IllegalArgumentException("Choose a reminder time in the future.") - } - AndroidAccountVault.setSnooze( - account.optString("id"), - uid, - folder, - dueAt, - call.getString("subject").orEmpty() - ) - val update = JSONObject() - .put("accountId", account.optString("id")) - .put("foldersChanged", JSONArray().put("Snoozed").put(folder)) - context.sendBroadcast(Intent(MailIdleService.ACTION_MAIL_SYNC) - .setPackage(context.packageName) - .putExtra(MailIdleService.EXTRA_SYNC_UPDATE, update.toString())) - MailIdleService.start(context) - call.resolve(JSObject().put("ok", true).put("snoozed", dueAt != null)) - } catch (error: Exception) { - call.reject(error.message ?: "Could not set the reminder.") - } - } - - @PluginMethod - fun checkSnoozeReminders(call: PluginCall) { - try { - MailIdleService.checkSnoozeReminders(context) - call.resolve() - } catch (error: Exception) { - call.reject(error.message ?: "Could not check mail reminders.") - } - } - - @PluginMethod - fun saveAttachment(call: PluginCall) { - try { - val account = AndroidAccountVault.account() - ?: throw IllegalStateException("Add a mail account before downloading attachments.") - call.resolve(AndroidMailService.saveAttachment(context, account, call.data).toJSObject()) - } catch (error: Exception) { - call.reject(error.message ?: "Could not save the attachment.") - } - } - - @PluginMethod - fun previewAttachment(call: PluginCall) { - try { - val account = AndroidAccountVault.account() - ?: throw IllegalStateException("Add a mail account before previewing attachments.") - call.resolve(AndroidMailService.previewAttachment(account, JSONObject(call.data.toString())).toJSObject()) - } catch (error: Exception) { - call.reject(error.message ?: "Could not preview the attachment.") - } - } - - @PluginMethod - fun openExternal(call: PluginCall) { - val raw = call.getString("url").orEmpty() - val uri = runCatching { Uri.parse(raw) }.getOrNull() - if (uri == null || uri.scheme?.lowercase(Locale.ROOT) !in setOf("http", "https") || - uri.host.isNullOrBlank() || uri.userInfo != null) { - call.reject("Only standard web links can be opened from mail.") - return - } - AlertDialog.Builder(activity) - .setTitle("Open external link?") - .setMessage("Email links can lead to fake sign-in pages or harmful content.\n\nCheck the full address before continuing:\n${uri}") - .setNegativeButton("Cancel") { _, _ -> call.resolve(JSObject().put("opened", false)) } - .setPositiveButton("Open link") { _, _ -> - try { - val intent = Intent(Intent.ACTION_VIEW, uri) - activity.startActivity(intent) - call.resolve(JSObject().put("opened", true)) - } catch (_: android.content.ActivityNotFoundException) { - call.reject("No browser is available to open this link.") - } catch (error: Exception) { - call.reject(error.message ?: "Could not open the link.") - } - } - .setOnCancelListener { call.resolve(JSObject().put("opened", false)) } - .show() - } - - @PluginMethod - fun send(call: PluginCall) { - val input = JSONObject(call.data.toString()).apply { - if (optString("messageId").isBlank()) put("messageId", "<${UUID.randomUUID()}@ep-mail.local>") - } - try { - val account = AndroidAccountVault.account() - ?: throw IllegalStateException("Add a mail account before sending.") - call.resolve(AndroidMailService.send(account, input).toJSObject()) - } catch (error: Exception) { - val account = AndroidAccountVault.account() - if (account != null && isConnectivityFailure(error)) { - AndroidAccountVault.enqueueMailOperation(account.optString("id"), JSONObject() - .put("id", UUID.randomUUID().toString()) - .put("type", "send") - .put("data", input)) - call.resolve(JSObject().put("ok", true).put("queued", true)) - } else call.reject(error.message ?: "Could not send the message.") - } - } - - @PluginMethod - fun listDrafts(call: PluginCall) { - try { - val account = AndroidAccountVault.account() - ?: throw IllegalStateException("Add a mail account before opening drafts.") - call.resolve(JSObject().put("drafts", account.optJSONArray("drafts") ?: JSONArray()).put("offline", true)) - } catch (error: Exception) { - call.reject(error.message ?: "Could not open drafts.") - } - } - - @PluginMethod - fun saveDraft(call: PluginCall) { - try { - val account = AndroidAccountVault.account() - ?: throw IllegalStateException("Add a mail account before saving drafts.") - val input = JSONObject(call.data.toString()) - val draft = JSONObject() - .put("id", input.optString("id").ifBlank { UUID.randomUUID().toString() }) - .put("to", input.optString("to").take(4000)) - .put("cc", input.optString("cc").take(4000)) - .put("subject", input.optString("subject").take(998)) - .put("text", input.optString("text").take(500000)) - .put("attachments", input.optJSONArray("attachments") ?: JSONArray()) - .put("updatedAt", System.currentTimeMillis()) - AndroidAccountVault.saveDraft(account.optString("id"), draft) - call.resolve(draft.toJSObject()) - } catch (error: Exception) { - call.reject(error.message ?: "Could not save the draft.") - } - } - - @PluginMethod - fun deleteDraft(call: PluginCall) { - try { - val account = AndroidAccountVault.account() - ?: throw IllegalStateException("Add a mail account before deleting drafts.") - val id = call.getString("id") ?: throw IllegalArgumentException("Choose a draft.") - AndroidAccountVault.deleteDraft(account.optString("id"), id) - call.resolve(JSObject().put("ok", true)) - } catch (error: Exception) { - call.reject(error.message ?: "Could not delete the draft.") - } - } - - private fun isConnectivityFailure(error: Throwable): Boolean { - var current: Throwable? = error - while (current != null) { - if (current is java.net.UnknownHostException || - current is java.net.ConnectException || - current is java.net.SocketTimeoutException || - current is javax.net.ssl.SSLException) return true - val message = current.message.orEmpty().lowercase(Locale.ROOT) - if (listOf("network is unreachable", "connection timed out", "connection refused", "unable to resolve host", "socket closed").any(message::contains)) return true - current = current.cause - } - return false - } - - @PluginMethod - fun davList(call: PluginCall) { - try { - call.resolve(AndroidDavService.list().toJSObject()) - } catch (error: Exception) { - call.reject(error.message ?: "Could not list DAV accounts.") - } - } - - @PluginMethod - fun davConnect(call: PluginCall) { - try { - call.resolve(AndroidDavService.connect(call.data).toJSObject()) - } catch (error: Exception) { - call.reject(error.message ?: "Could not connect the DAV account.") - } - } - - @PluginMethod - fun davActivate(call: PluginCall) { - try { - call.resolve(AndroidDavService.activate(call.getString("type") ?: "caldav", call.getString("id") ?: "").toJSObject()) - } catch (error: Exception) { - call.reject(error.message ?: "Could not activate the DAV account.") - } - } - - @PluginMethod - fun davRemove(call: PluginCall) { - try { - call.resolve(AndroidDavService.remove(call.getString("type") ?: "caldav", call.getString("id") ?: "").toJSObject()) - } catch (error: Exception) { - call.reject(error.message ?: "Could not remove the DAV account.") - } - } - - @PluginMethod - fun davSync(call: PluginCall) { - try { - call.resolve(AndroidDavService.sync(call.getString("type") ?: "caldav").toJSObject()) - } catch (error: Exception) { - call.reject(error.message ?: "Could not sync the DAV account.") - } - } - - @PluginMethod - fun davSaveEvent(call: PluginCall) { - try { - val result = AndroidDavService.saveEvent(call.data) - if (result == null) call.resolve() else call.resolve(result.toJSObject()) - } catch (error: Exception) { - call.reject(error.message ?: "Could not save the calendar event.") - } - } - - @PluginMethod - fun davDeleteEvent(call: PluginCall) { - try { - AndroidDavService.deleteEvent(call.data) - call.resolve() - } catch (error: Exception) { - call.reject(error.message ?: "Could not delete the calendar event.") - } - } - - @PluginMethod - fun davSaveContact(call: PluginCall) { - try { - val result = AndroidDavService.saveContact(call.data) - if (result == null) call.resolve() else call.resolve(result.toJSObject()) - } catch (error: Exception) { - call.reject(error.message ?: "Could not save the contact.") - } - } - - @PluginMethod - fun davDeleteContact(call: PluginCall) { - try { - AndroidDavService.deleteContact(call.data) - call.resolve() - } catch (error: Exception) { - call.reject(error.message ?: "Could not delete the contact.") - } - } - - private fun normalizeAccount(input: JSONObject): JSONObject { - val email = input.optString("email").trim() - val password = input.optString("password") - val displayName = input.optString("displayName").trim().take(80) - val imapHost = input.optString("imapHost").trim() - val smtpHost = input.optString("smtpHost").trim() - require(EMAIL.matches(email) && password.isNotBlank() && displayName.isNotBlank() && imapHost.isNotBlank() && smtpHost.isNotBlank()) { - "Enter a valid email, account display name, password, and both mail server names." - } - return JSONObject() - .put("id", input.optString("id").ifBlank { UUID.randomUUID().toString() }) - .put("email", email) - .put("password", password) - .put("displayName", displayName) - .put("imapHost", imapHost) - .put("smtpHost", smtpHost) - .put("signature", input.optString("signature").take(5000)) - .put("notificationsEnabled", input.optBoolean("notificationsEnabled", true)) - .put("syncIntervalMinutes", input.optInt("syncIntervalMinutes", 2).also { - require(it in setOf(2, 5, 15, 30, 60)) { "Choose a supported mailbox sync interval." } - }) - .put("rules", normalizeRules(input.optJSONArray("rules"))) - .put("imapPort", input.optInt("imapPort", 143)) - .put("smtpPort", input.optInt("smtpPort", 587)) - } - - private fun normalizeRules(input: JSONArray?): JSONArray { - val result = JSONArray() - if (input == null) return result - require(input.length() <= 50) { "You can set up to 50 mail rules per account." } - for (index in 0 until input.length()) { - val rule = input.getJSONObject(index) - val sender = rule.optString("senderContains").trim().take(200) - val subject = rule.optString("subjectContains").trim().take(200) - val action = rule.optString("action") - val value = rule.optString("value").trim().take(200) - require((sender.isNotEmpty() || subject.isNotEmpty()) && - action in setOf("archive", "move", "label", "flag")) { - "Mail rule ${index + 1} needs a sender or subject condition and a valid action." - } - require(action !in setOf("move", "label") || value.isNotEmpty()) { - "Mail rule ${index + 1} needs a destination folder or label." - } - require(action != "move" || !value.any { it == '\r' || it == '\n' || it == '\u0000' }) { - "Mail rule ${index + 1} has an invalid destination folder." - } - require(action != "move" || value in setOf("Inbox", "Archive", "Trash") || AndroidMailService.isCustomFolder(value)) { - "Mail rule ${index + 1} must move messages to Inbox, Archive, Trash, or one of your folders." - } - result.put(JSONObject() - .put("id", rule.optString("id").ifBlank { UUID.randomUUID().toString() }) - .put("senderContains", sender) - .put("subjectContains", subject) - .put("action", action) - .put("value", value)) - } - return result - } - - private fun JSONObject.toJSObject(): JSObject = JSObject(toString()) - - companion object { - private val EMAIL = Regex("^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$") - } -} +package studio.daybreak.mail + +import android.content.BroadcastReceiver +import android.content.Context +import android.content.Intent +import android.content.IntentFilter +import android.net.Uri +import android.os.Build +import android.app.AlertDialog +import com.getcapacitor.JSObject +import com.getcapacitor.Plugin +import com.getcapacitor.PluginCall +import com.getcapacitor.PluginMethod +import com.getcapacitor.annotation.CapacitorPlugin +import java.util.Locale +import java.util.UUID +import org.json.JSONArray +import org.json.JSONObject + +@CapacitorPlugin(name = "EpMail") +class EpMailPlugin : Plugin() { + private var syncReceiver: BroadcastReceiver? = null + + override fun load() { + AndroidAccountVault.initialize(context) + val filter = IntentFilter(MailIdleService.ACTION_MAIL_SYNC) + val receiver = object : BroadcastReceiver() { + override fun onReceive(context: Context, intent: Intent) { + val update = intent.getStringExtra(MailIdleService.EXTRA_SYNC_UPDATE) ?: return + notifyListeners("mailSyncUpdate", JSObject(update)) + } + } + syncReceiver = receiver + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + context.registerReceiver(receiver, filter, Context.RECEIVER_NOT_EXPORTED) + } else { + @Suppress("DEPRECATION") + context.registerReceiver(receiver, filter) + } + MailIdleService.start(context) + } + + override fun handleOnResume() { + MailIdleService.start(context) + } + + override fun handleOnDestroy() { + syncReceiver?.let { + try { context.unregisterReceiver(it) } catch (_: IllegalArgumentException) {} + } + syncReceiver = null + } + + @PluginMethod + fun getAppVersion(call: PluginCall) { + call.resolve(JSObject().put("version", BuildConfig.VERSION_NAME)) + } + + @PluginMethod + fun getAccount(call: PluginCall) { + val account = AndroidAccountVault.account() + if (account == null) call.resolve() + else call.resolve(AndroidAccountVault.publicAccount(account).toJSObject()) + } + + @PluginMethod + fun listAccounts(call: PluginCall) { + val store = AndroidAccountVault.read() + call.resolve(JSObject() + .put("accounts", AndroidAccountVault.publicAccounts()) + .put("activeId", store.optString("activeId"))) + } + + @PluginMethod + fun selectAccount(call: PluginCall) { + try { + val id = call.getString("id") ?: throw IllegalArgumentException("Choose a mail account.") + val account = AndroidAccountVault.account(id) + ?: throw IllegalStateException("That mail account is no longer available.") + val store = AndroidAccountVault.read().put("activeId", id) + AndroidAccountVault.write(store) + MailIdleService.start(context) + call.resolve(AndroidAccountVault.publicAccount(account).toJSObject()) + } catch (error: Exception) { + call.reject(error.message ?: "Could not select the mail account.") + } + } + + @PluginMethod + fun removeAccount(call: PluginCall) { + try { + val id = call.getString("id") ?: throw IllegalArgumentException("Choose a mail account.") + val result = AndroidAccountVault.removeAccount(id) + if (AndroidAccountVault.accounts().length() == 0) MailIdleService.stop(context) + else MailIdleService.start(context) + call.resolve(result.toJSObject()) + } catch (error: Exception) { + call.reject(error.message ?: "Could not remove the mail account.") + } + } + + @PluginMethod + fun connect(call: PluginCall) { + try { + val account = normalizeAccount(call.data) + val status = AndroidMailService.connect(account) + val saved = AndroidAccountVault.saveAccount(account) + MailIdleService.start(context) + call.resolve(AndroidAccountVault.publicAccount(saved) + .put("ok", true) + .put("mailbox", status.optString("mailbox")) + .put("messages", status.optInt("messages")).toJSObject()) + } catch (error: Exception) { + call.reject("Could not connect to the mailbox: ${error.message}") + } + } + + @PluginMethod + fun updateAccount(call: PluginCall) { + try { + val id = call.getString("id") ?: throw IllegalArgumentException("Choose a mail account.") + val existing = AndroidAccountVault.account(id) + ?: throw IllegalStateException("That mail account is no longer available.") + val input = JSONObject(call.data.toString()).apply { + if (optString("password").isBlank()) put("password", existing.optString("password")) + } + val account = normalizeAccount(input).put("id", id) + val status = AndroidMailService.connect(account) + val saved = AndroidAccountVault.saveAccount(account) + MailIdleService.start(context) + call.resolve(AndroidAccountVault.publicAccount(saved) + .put("mailbox", status.optString("mailbox")) + .put("messages", status.optInt("messages")).toJSObject()) + } catch (error: Exception) { + call.reject("Could not update the mailbox: ${error.message}") + } + } + + @PluginMethod + fun listFolders(call: PluginCall) { + try { + val account = AndroidAccountVault.account() + ?: throw IllegalStateException("Add a mail account before listing folders.") + call.resolve(AndroidMailService.listFolders(account).toJSObject()) + } catch (error: Exception) { + call.resolve(JSObject().put("folders", org.json.JSONArray()).put("offline", true)) + } + } + + @PluginMethod + fun createFolder(call: PluginCall) { + try { + val account = AndroidAccountVault.account() + ?: throw IllegalStateException("Add a mail account before creating folders.") + call.resolve(AndroidMailService.createFolder(account, call.getString("name") ?: "").toJSObject()) + } catch (error: Exception) { + call.reject(error.message ?: "Could not create the folder.") + } + } + + @PluginMethod + fun syncFolder(call: PluginCall) { + try { + val account = AndroidAccountVault.account() + ?: throw IllegalStateException("Add a mail account before syncing.") + val requested = call.getString("folder") ?: "Inbox" + val filters = call.getObject("filters") ?: JSObject() + val filterFolder = filters.getString("folder") + val selected = filterFolder?.takeIf { it in setOf("Inbox", "Sent", "Archive", "Trash", "Starred") } ?: requested + val folder = if (selected in setOf("Inbox", "Sent", "Archive", "Trash", "Starred", "Snoozed") || AndroidMailService.isCustomFolder(selected)) selected else "Inbox" + val offset = (call.getInt("offset") ?: 0).coerceAtLeast(0) + AndroidMailService.flushOutbox(account) + call.resolve(AndroidMailService.sync(account, folder, offset, JSONObject(filters.toString())).toJSObject()) + } catch (error: Exception) { + call.reject(error.message ?: "Could not sync the mailbox.") + } + } + + @PluginMethod + fun updateMessage(call: PluginCall) { + try { + val account = AndroidAccountVault.account() + ?: throw IllegalStateException("Add a mail account before changing messages.") + call.resolve(AndroidMailService.updateMessage(account, call.data).toJSObject()) + } catch (error: Exception) { + val account = AndroidAccountVault.account() + if (account != null && isConnectivityFailure(error)) { + AndroidAccountVault.enqueueMailOperation(account.optString("id"), JSONObject() + .put("id", UUID.randomUUID().toString()) + .put("type", "action") + .put("data", JSONObject(call.data.toString()))) + call.resolve(JSObject().put("ok", true).put("queued", true)) + } else call.reject(error.message ?: "Could not update the message.") + } + } + + @PluginMethod + fun setSnooze(call: PluginCall) { + try { + val account = AndroidAccountVault.account() + ?: throw IllegalStateException("Add a mail account before setting a reminder.") + val uid = call.getLong("uid") ?: throw IllegalArgumentException("That message could not be identified.") + require(uid > 0) { "That message could not be identified." } + val folder = call.getString("sourceFolder") ?: call.getString("folder") ?: "Inbox" + require(folder in setOf("Inbox", "Sent", "Archive", "Trash")) { "That mailbox cannot be snoozed." } + val dueAt = call.getLong("dueAt") + if (dueAt != null && dueAt <= System.currentTimeMillis()) { + throw IllegalArgumentException("Choose a reminder time in the future.") + } + AndroidAccountVault.setSnooze( + account.optString("id"), + uid, + folder, + dueAt, + call.getString("subject").orEmpty() + ) + val update = JSONObject() + .put("accountId", account.optString("id")) + .put("foldersChanged", JSONArray().put("Snoozed").put(folder)) + context.sendBroadcast(Intent(MailIdleService.ACTION_MAIL_SYNC) + .setPackage(context.packageName) + .putExtra(MailIdleService.EXTRA_SYNC_UPDATE, update.toString())) + MailIdleService.start(context) + call.resolve(JSObject().put("ok", true).put("snoozed", dueAt != null)) + } catch (error: Exception) { + call.reject(error.message ?: "Could not set the reminder.") + } + } + + @PluginMethod + fun checkSnoozeReminders(call: PluginCall) { + try { + MailIdleService.checkSnoozeReminders(context) + call.resolve() + } catch (error: Exception) { + call.reject(error.message ?: "Could not check mail reminders.") + } + } + + @PluginMethod + fun saveAttachment(call: PluginCall) { + try { + val account = AndroidAccountVault.account() + ?: throw IllegalStateException("Add a mail account before downloading attachments.") + call.resolve(AndroidMailService.saveAttachment(context, account, call.data).toJSObject()) + } catch (error: Exception) { + call.reject(error.message ?: "Could not save the attachment.") + } + } + + @PluginMethod + fun previewAttachment(call: PluginCall) { + try { + val account = AndroidAccountVault.account() + ?: throw IllegalStateException("Add a mail account before previewing attachments.") + call.resolve(AndroidMailService.previewAttachment(account, JSONObject(call.data.toString())).toJSObject()) + } catch (error: Exception) { + call.reject(error.message ?: "Could not preview the attachment.") + } + } + + @PluginMethod + fun openExternal(call: PluginCall) { + val raw = call.getString("url").orEmpty() + val uri = runCatching { Uri.parse(raw) }.getOrNull() + if (uri == null || uri.scheme?.lowercase(Locale.ROOT) !in setOf("http", "https") || + uri.host.isNullOrBlank() || uri.userInfo != null) { + call.reject("Only standard web links can be opened from mail.") + return + } + AlertDialog.Builder(activity) + .setTitle("Open external link?") + .setMessage("Email links can lead to fake sign-in pages or harmful content.\n\nCheck the full address before continuing:\n${uri}") + .setNegativeButton("Cancel") { _, _ -> call.resolve(JSObject().put("opened", false)) } + .setPositiveButton("Open link") { _, _ -> + try { + val intent = Intent(Intent.ACTION_VIEW, uri) + activity.startActivity(intent) + call.resolve(JSObject().put("opened", true)) + } catch (_: android.content.ActivityNotFoundException) { + call.reject("No browser is available to open this link.") + } catch (error: Exception) { + call.reject(error.message ?: "Could not open the link.") + } + } + .setOnCancelListener { call.resolve(JSObject().put("opened", false)) } + .show() + } + + @PluginMethod + fun send(call: PluginCall) { + val input = JSONObject(call.data.toString()).apply { + if (optString("messageId").isBlank()) put("messageId", "<${UUID.randomUUID()}@ep-mail.local>") + } + try { + val account = AndroidAccountVault.account() + ?: throw IllegalStateException("Add a mail account before sending.") + call.resolve(AndroidMailService.send(account, input).toJSObject()) + } catch (error: Exception) { + val account = AndroidAccountVault.account() + if (account != null && isConnectivityFailure(error)) { + AndroidAccountVault.enqueueMailOperation(account.optString("id"), JSONObject() + .put("id", UUID.randomUUID().toString()) + .put("type", "send") + .put("data", input)) + call.resolve(JSObject().put("ok", true).put("queued", true)) + } else call.reject(error.message ?: "Could not send the message.") + } + } + + @PluginMethod + fun listDrafts(call: PluginCall) { + try { + val account = AndroidAccountVault.account() + ?: throw IllegalStateException("Add a mail account before opening drafts.") + call.resolve(JSObject().put("drafts", account.optJSONArray("drafts") ?: JSONArray()).put("offline", true)) + } catch (error: Exception) { + call.reject(error.message ?: "Could not open drafts.") + } + } + + @PluginMethod + fun saveDraft(call: PluginCall) { + try { + val account = AndroidAccountVault.account() + ?: throw IllegalStateException("Add a mail account before saving drafts.") + val input = JSONObject(call.data.toString()) + val draft = JSONObject() + .put("id", input.optString("id").ifBlank { UUID.randomUUID().toString() }) + .put("to", input.optString("to").take(4000)) + .put("cc", input.optString("cc").take(4000)) + .put("subject", input.optString("subject").take(998)) + .put("text", input.optString("text").take(500000)) + .put("attachments", input.optJSONArray("attachments") ?: JSONArray()) + .put("updatedAt", System.currentTimeMillis()) + AndroidAccountVault.saveDraft(account.optString("id"), draft) + call.resolve(draft.toJSObject()) + } catch (error: Exception) { + call.reject(error.message ?: "Could not save the draft.") + } + } + + @PluginMethod + fun deleteDraft(call: PluginCall) { + try { + val account = AndroidAccountVault.account() + ?: throw IllegalStateException("Add a mail account before deleting drafts.") + val id = call.getString("id") ?: throw IllegalArgumentException("Choose a draft.") + AndroidAccountVault.deleteDraft(account.optString("id"), id) + call.resolve(JSObject().put("ok", true)) + } catch (error: Exception) { + call.reject(error.message ?: "Could not delete the draft.") + } + } + + private fun isConnectivityFailure(error: Throwable): Boolean { + var current: Throwable? = error + while (current != null) { + if (current is java.net.UnknownHostException || + current is java.net.ConnectException || + current is java.net.SocketTimeoutException || + current is javax.net.ssl.SSLException) return true + val message = current.message.orEmpty().lowercase(Locale.ROOT) + if (listOf("network is unreachable", "connection timed out", "connection refused", "unable to resolve host", "socket closed").any(message::contains)) return true + current = current.cause + } + return false + } + + @PluginMethod + fun davList(call: PluginCall) { + try { + call.resolve(AndroidDavService.list().toJSObject()) + } catch (error: Exception) { + call.reject(error.message ?: "Could not list DAV accounts.") + } + } + + @PluginMethod + fun davConnect(call: PluginCall) { + try { + call.resolve(AndroidDavService.connect(call.data).toJSObject()) + } catch (error: Exception) { + call.reject(error.message ?: "Could not connect the DAV account.") + } + } + + @PluginMethod + fun davActivate(call: PluginCall) { + try { + call.resolve(AndroidDavService.activate(call.getString("type") ?: "caldav", call.getString("id") ?: "").toJSObject()) + } catch (error: Exception) { + call.reject(error.message ?: "Could not activate the DAV account.") + } + } + + @PluginMethod + fun davRemove(call: PluginCall) { + try { + call.resolve(AndroidDavService.remove(call.getString("type") ?: "caldav", call.getString("id") ?: "").toJSObject()) + } catch (error: Exception) { + call.reject(error.message ?: "Could not remove the DAV account.") + } + } + + @PluginMethod + fun davSync(call: PluginCall) { + try { + call.resolve(AndroidDavService.sync(call.getString("type") ?: "caldav").toJSObject()) + } catch (error: Exception) { + call.reject(error.message ?: "Could not sync the DAV account.") + } + } + + @PluginMethod + fun davSaveEvent(call: PluginCall) { + try { + val result = AndroidDavService.saveEvent(call.data) + if (result == null) call.resolve() else call.resolve(result.toJSObject()) + } catch (error: Exception) { + call.reject(error.message ?: "Could not save the calendar event.") + } + } + + @PluginMethod + fun davDeleteEvent(call: PluginCall) { + try { + AndroidDavService.deleteEvent(call.data) + call.resolve() + } catch (error: Exception) { + call.reject(error.message ?: "Could not delete the calendar event.") + } + } + + @PluginMethod + fun davSaveContact(call: PluginCall) { + try { + val result = AndroidDavService.saveContact(call.data) + if (result == null) call.resolve() else call.resolve(result.toJSObject()) + } catch (error: Exception) { + call.reject(error.message ?: "Could not save the contact.") + } + } + + @PluginMethod + fun davDeleteContact(call: PluginCall) { + try { + AndroidDavService.deleteContact(call.data) + call.resolve() + } catch (error: Exception) { + call.reject(error.message ?: "Could not delete the contact.") + } + } + + private fun normalizeAccount(input: JSONObject): JSONObject { + val email = input.optString("email").trim() + val password = input.optString("password") + val displayName = input.optString("displayName").trim().take(80) + val imapHost = input.optString("imapHost").trim() + val smtpHost = input.optString("smtpHost").trim() + require(EMAIL.matches(email) && password.isNotBlank() && displayName.isNotBlank() && imapHost.isNotBlank() && smtpHost.isNotBlank()) { + "Enter a valid email, account display name, password, and both mail server names." + } + return JSONObject() + .put("id", input.optString("id").ifBlank { UUID.randomUUID().toString() }) + .put("email", email) + .put("password", password) + .put("displayName", displayName) + .put("imapHost", imapHost) + .put("smtpHost", smtpHost) + .put("signature", input.optString("signature").take(5000)) + .put("notificationsEnabled", input.optBoolean("notificationsEnabled", true)) + .put("syncIntervalMinutes", input.optInt("syncIntervalMinutes", 2).also { + require(it in setOf(2, 5, 15, 30, 60)) { "Choose a supported mailbox sync interval." } + }) + .put("rules", normalizeRules(input.optJSONArray("rules"))) + .put("imapPort", input.optInt("imapPort", 143)) + .put("smtpPort", input.optInt("smtpPort", 587)) + } + + private fun normalizeRules(input: JSONArray?): JSONArray { + val result = JSONArray() + if (input == null) return result + require(input.length() <= 50) { "You can set up to 50 mail rules per account." } + for (index in 0 until input.length()) { + val rule = input.getJSONObject(index) + val sender = rule.optString("senderContains").trim().take(200) + val subject = rule.optString("subjectContains").trim().take(200) + val action = rule.optString("action") + val value = rule.optString("value").trim().take(200) + require((sender.isNotEmpty() || subject.isNotEmpty()) && + action in setOf("archive", "move", "label", "flag")) { + "Mail rule ${index + 1} needs a sender or subject condition and a valid action." + } + require(action !in setOf("move", "label") || value.isNotEmpty()) { + "Mail rule ${index + 1} needs a destination folder or label." + } + require(action != "move" || !value.any { it == '\r' || it == '\n' || it == '\u0000' }) { + "Mail rule ${index + 1} has an invalid destination folder." + } + require(action != "move" || value in setOf("Inbox", "Archive", "Trash") || AndroidMailService.isCustomFolder(value)) { + "Mail rule ${index + 1} must move messages to Inbox, Archive, Trash, or one of your folders." + } + result.put(JSONObject() + .put("id", rule.optString("id").ifBlank { UUID.randomUUID().toString() }) + .put("senderContains", sender) + .put("subjectContains", subject) + .put("action", action) + .put("value", value)) + } + return result + } + + private fun JSONObject.toJSObject(): JSObject = JSObject(toString()) + + companion object { + private val EMAIL = Regex("^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$") + } +} diff --git a/android/app/src/main/java/studio/daybreak/mail/MailFallbackWorker.kt b/android/app/src/main/java/studio/daybreak/mail/MailFallbackWorker.kt index 8331d32..d069eb0 100644 --- a/android/app/src/main/java/studio/daybreak/mail/MailFallbackWorker.kt +++ b/android/app/src/main/java/studio/daybreak/mail/MailFallbackWorker.kt @@ -1,55 +1,55 @@ -package studio.daybreak.mail - -import android.content.Context -import androidx.work.Constraints -import androidx.work.ExistingPeriodicWorkPolicy -import androidx.work.NetworkType -import androidx.work.PeriodicWorkRequestBuilder -import androidx.work.WorkManager -import androidx.work.Worker -import androidx.work.WorkerParameters -import java.util.concurrent.TimeUnit - -class MailFallbackWorker(context: Context, parameters: WorkerParameters) : Worker(context, parameters) { - override fun doWork(): Result { - return try { - AndroidAccountVault.initialize(applicationContext) - MailIdleService.checkSnoozeReminders(applicationContext) - val accounts = AndroidAccountVault.accounts() - for (index in 0 until accounts.length()) { - val account = accounts.getJSONObject(index) - val newMessages = AndroidMailService.checkForNewMail(account) - if (newMessages > 0) { - MailIdleService.notifyNewMail(applicationContext, account, newMessages) - } - } - Result.success() - } catch (error: Exception) { - android.util.Log.w(TAG, "Periodic mail fallback sync failed", error) - Result.retry() - } - } - - companion object { - private const val TAG = "EpMailFallback" - private const val UNIQUE_WORK_NAME = "ep-mail-periodic-sync" - - fun schedule(context: Context) { - val constraints = Constraints.Builder() - .setRequiredNetworkType(NetworkType.CONNECTED) - .build() - val request = PeriodicWorkRequestBuilder(15, TimeUnit.MINUTES) - .setConstraints(constraints) - .build() - WorkManager.getInstance(context.applicationContext).enqueueUniquePeriodicWork( - UNIQUE_WORK_NAME, - ExistingPeriodicWorkPolicy.KEEP, - request - ) - } - - fun cancel(context: Context) { - WorkManager.getInstance(context.applicationContext).cancelUniqueWork(UNIQUE_WORK_NAME) - } - } -} +package studio.daybreak.mail + +import android.content.Context +import androidx.work.Constraints +import androidx.work.ExistingPeriodicWorkPolicy +import androidx.work.NetworkType +import androidx.work.PeriodicWorkRequestBuilder +import androidx.work.WorkManager +import androidx.work.Worker +import androidx.work.WorkerParameters +import java.util.concurrent.TimeUnit + +class MailFallbackWorker(context: Context, parameters: WorkerParameters) : Worker(context, parameters) { + override fun doWork(): Result { + return try { + AndroidAccountVault.initialize(applicationContext) + MailIdleService.checkSnoozeReminders(applicationContext) + val accounts = AndroidAccountVault.accounts() + for (index in 0 until accounts.length()) { + val account = accounts.getJSONObject(index) + val newMessages = AndroidMailService.checkForNewMail(account) + if (newMessages > 0) { + MailIdleService.notifyNewMail(applicationContext, account, newMessages) + } + } + Result.success() + } catch (error: Exception) { + android.util.Log.w(TAG, "Periodic mail fallback sync failed (${error.javaClass.simpleName})") + Result.retry() + } + } + + companion object { + private const val TAG = "EpMailFallback" + private const val UNIQUE_WORK_NAME = "ep-mail-periodic-sync" + + fun schedule(context: Context) { + val constraints = Constraints.Builder() + .setRequiredNetworkType(NetworkType.CONNECTED) + .build() + val request = PeriodicWorkRequestBuilder(15, TimeUnit.MINUTES) + .setConstraints(constraints) + .build() + WorkManager.getInstance(context.applicationContext).enqueueUniquePeriodicWork( + UNIQUE_WORK_NAME, + ExistingPeriodicWorkPolicy.KEEP, + request + ) + } + + fun cancel(context: Context) { + WorkManager.getInstance(context.applicationContext).cancelUniqueWork(UNIQUE_WORK_NAME) + } + } +} diff --git a/android/app/src/main/java/studio/daybreak/mail/MailIdleService.kt b/android/app/src/main/java/studio/daybreak/mail/MailIdleService.kt index 70b57db..5999ed0 100644 --- a/android/app/src/main/java/studio/daybreak/mail/MailIdleService.kt +++ b/android/app/src/main/java/studio/daybreak/mail/MailIdleService.kt @@ -1,295 +1,297 @@ -package studio.daybreak.mail - -import android.app.Notification -import android.app.NotificationChannel -import android.app.NotificationManager -import android.app.PendingIntent -import android.app.Service -import android.content.Context -import android.content.Intent -import android.os.Build -import android.os.IBinder -import androidx.core.app.NotificationCompat -import androidx.core.app.NotificationManagerCompat -import java.util.concurrent.ConcurrentHashMap -import java.util.concurrent.atomic.AtomicBoolean -import org.json.JSONObject -import javax.mail.Folder -import javax.mail.Store - -class MailIdleService : Service() { - private data class Watcher( - val account: JSONObject, - val fingerprint: String, - val stopped: AtomicBoolean = AtomicBoolean(false), - @Volatile var store: Store? = null, - @Volatile var folder: Folder? = null, - @Volatile var thread: Thread? = null - ) { - fun stop() { - stopped.set(true) - try { folder?.close(false) } catch (_: Exception) {} - try { store?.close() } catch (_: Exception) {} - thread?.interrupt() - } - } - - private val watchers = ConcurrentHashMap() - - override fun onCreate() { - super.onCreate() - AndroidAccountVault.initialize(applicationContext) - createNotificationChannels() - } - - override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { - startForeground(FOREGROUND_NOTIFICATION_ID, foregroundNotification()) - Thread { - try { - reconcile() - if (watchers.isEmpty()) stopSelf(startId) - } catch (error: Exception) { - android.util.Log.e(TAG, "Could not start mailbox watchers", error) - } - }.start() - return START_STICKY - } - - override fun onBind(intent: Intent?): IBinder? = null - - override fun onDestroy() { - watchers.values.forEach(Watcher::stop) - watchers.clear() - super.onDestroy() - } - - @Synchronized - private fun reconcile() { - val accounts = AndroidAccountVault.accounts() - val desired = LinkedHashMap() - for (index in 0 until accounts.length().coerceAtMost(MAX_WATCHERS)) { - val account = accounts.getJSONObject(index) - desired[account.optString("id")] = account - } - - for ((id, watcher) in watchers) { - val account = desired[id] - if (account == null || AndroidMailService.accountFingerprint(account) != watcher.fingerprint) { - watcher.stop() - watchers.remove(id, watcher) - } - } - for ((id, account) in desired) { - if (!watchers.containsKey(id)) startWatcher(id, account) - } - } - - private fun startWatcher(id: String, account: JSONObject) { - val watcher = Watcher(account, AndroidMailService.accountFingerprint(account)) - watchers[id] = watcher - val thread = Thread({ - var failures = 0 - while (!watcher.stopped.get()) { - try { - AndroidMailService.watchInbox( - account = account, - onNewMail = { count -> onNewMail(account, count) }, - shouldStop = { watcher.stopped.get() }, - onConnection = { store, folder -> - watcher.store = store - watcher.folder = folder - } - ) - failures = 0 - } catch (error: Exception) { - if (!watcher.stopped.get()) android.util.Log.w(TAG, "IMAP watcher disconnected for ${account.optString("email")}", error) - failures += 1 - } finally { - watcher.folder = null - watcher.store = null - } - if (!watcher.stopped.get()) { - val delayMs = (15_000L * (1L shl failures.coerceAtMost(5))).coerceAtMost(5 * 60_000L) - try { - Thread.sleep(delayMs) - } catch (_: InterruptedException) { - if (watcher.stopped.get()) break +package studio.daybreak.mail + +import android.app.Notification +import android.app.NotificationChannel +import android.app.NotificationManager +import android.app.PendingIntent +import android.app.Service +import android.content.Context +import android.content.Intent +import android.os.Build +import android.os.IBinder +import androidx.core.app.NotificationCompat +import androidx.core.app.NotificationManagerCompat +import java.util.concurrent.ConcurrentHashMap +import java.util.concurrent.atomic.AtomicBoolean +import org.json.JSONObject +import javax.mail.Folder +import javax.mail.Store + +class MailIdleService : Service() { + private data class Watcher( + val account: JSONObject, + val fingerprint: String, + val stopped: AtomicBoolean = AtomicBoolean(false), + @Volatile var store: Store? = null, + @Volatile var folder: Folder? = null, + @Volatile var thread: Thread? = null + ) { + fun stop() { + stopped.set(true) + try { folder?.close(false) } catch (_: Exception) {} + try { store?.close() } catch (_: Exception) {} + thread?.interrupt() + } + } + + private val watchers = ConcurrentHashMap() + + override fun onCreate() { + super.onCreate() + AndroidAccountVault.initialize(applicationContext) + createNotificationChannels() + } + + override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { + startForeground(FOREGROUND_NOTIFICATION_ID, foregroundNotification()) + Thread { + try { + reconcile() + if (watchers.isEmpty()) stopSelf(startId) + } catch (error: Exception) { + android.util.Log.e(TAG, "Could not start mailbox watchers (${error.javaClass.simpleName})") + } + }.start() + return START_STICKY + } + + override fun onBind(intent: Intent?): IBinder? = null + + override fun onDestroy() { + watchers.values.forEach(Watcher::stop) + watchers.clear() + super.onDestroy() + } + + @Synchronized + private fun reconcile() { + val accounts = AndroidAccountVault.accounts() + val desired = LinkedHashMap() + for (index in 0 until accounts.length().coerceAtMost(MAX_WATCHERS)) { + val account = accounts.getJSONObject(index) + desired[account.optString("id")] = account + } + + for ((id, watcher) in watchers) { + val account = desired[id] + if (account == null || AndroidMailService.accountFingerprint(account) != watcher.fingerprint) { + watcher.stop() + watchers.remove(id, watcher) + } + } + for ((id, account) in desired) { + if (!watchers.containsKey(id)) startWatcher(id, account) + } + } + + private fun startWatcher(id: String, account: JSONObject) { + val watcher = Watcher(account, AndroidMailService.accountFingerprint(account)) + watchers[id] = watcher + val thread = Thread({ + var failures = 0 + while (!watcher.stopped.get()) { + try { + AndroidMailService.watchInbox( + account = account, + onNewMail = { count -> onNewMail(account, count) }, + shouldStop = { watcher.stopped.get() }, + onConnection = { store, folder -> + watcher.store = store + watcher.folder = folder + } + ) + failures = 0 + } catch (error: Exception) { + if (!watcher.stopped.get()) { + android.util.Log.w(TAG, "IMAP watcher disconnected (${error.javaClass.simpleName})") } - } - } - }, "ep-mail-idle-$id") - thread.isDaemon = true - watcher.thread = thread - thread.start() - } - - private fun onNewMail(account: JSONObject, count: Int) { - notifyNewMail(this, account, count) - } - - private fun foregroundNotification(): Notification = NotificationCompat.Builder(this, SERVICE_CHANNEL_ID) - .setSmallIcon(android.R.drawable.ic_dialog_email) - .setContentTitle(getString(R.string.app_name)) - .setContentText("Checking mail in the background") - .setContentIntent(appPendingIntent()) - .setOngoing(true) - .setPriority(NotificationCompat.PRIORITY_LOW) - .build() - - private fun appPendingIntent(): PendingIntent { - val intent = packageManager.getLaunchIntentForPackage(packageName) - ?: Intent(this, MainActivity::class.java) - intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP) - return PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) - } - - private fun createNotificationChannels() { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) return - val manager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager - manager.createNotificationChannel(NotificationChannel( - SERVICE_CHANNEL_ID, - "Background mail sync", - NotificationManager.IMPORTANCE_LOW - ).apply { description = "Keeps mail synchronized in the background." }) - manager.createNotificationChannel(NotificationChannel( - MAIL_CHANNEL_ID, - "New mail", - NotificationManager.IMPORTANCE_DEFAULT - ).apply { description = "Notifies you when new mail arrives." }) - } - - companion object { - const val ACTION_MAIL_SYNC = "studio.daybreak.mail.MAIL_SYNC_UPDATE" - const val EXTRA_SYNC_UPDATE = "syncUpdate" - private const val TAG = "EpMailIdle" - private const val MAX_WATCHERS = 2 - private const val FOREGROUND_NOTIFICATION_ID = 3410 - private const val SERVICE_CHANNEL_ID = "mail-sync-service" - private const val MAIL_CHANNEL_ID = "mail-new-message" - - fun start(context: Context) { - AndroidAccountVault.initialize(context) - if (AndroidAccountVault.accounts().length() == 0) return - MailFallbackWorker.schedule(context) - val intent = Intent(context, MailIdleService::class.java) - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) context.startForegroundService(intent) - else context.startService(intent) - } - - fun stop(context: Context) { - context.stopService(Intent(context, MailIdleService::class.java)) - MailFallbackWorker.cancel(context) - } - - fun checkSnoozeReminders(context: Context) { - AndroidAccountVault.initialize(context) - val accounts = AndroidAccountVault.accounts() - for (index in 0 until accounts.length()) { - val account = accounts.getJSONObject(index) - val reminders = AndroidAccountVault.takeDueSnoozes( - account.optString("id"), - System.currentTimeMillis() - ) - for (reminderIndex in 0 until reminders.length()) { - notifySnoozeReminder(context, account, reminders.getJSONObject(reminderIndex)) - } - } - } - - fun notifyNewMail(context: Context, account: JSONObject, count: Int) { - if (count <= 0) return - val appContext = context.applicationContext - val email = account.optString("email") - if (account.optBoolean("notificationsEnabled", true)) { - val notificationManager = appContext.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && - notificationManager.getNotificationChannel(MAIL_CHANNEL_ID) == null) { - notificationManager.createNotificationChannel(NotificationChannel( - MAIL_CHANNEL_ID, - "New mail", - NotificationManager.IMPORTANCE_DEFAULT - ).apply { description = "Notifies you when new mail arrives." }) - } - val launchIntent = appContext.packageManager.getLaunchIntentForPackage(appContext.packageName) - ?: Intent(appContext, MainActivity::class.java) - launchIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP) - val pendingIntent = PendingIntent.getActivity( - appContext, 0, launchIntent, - PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE - ) - val title = if (count == 1) "New mail" else "$count new messages" - val notification = NotificationCompat.Builder(appContext, MAIL_CHANNEL_ID) - .setSmallIcon(android.R.drawable.ic_dialog_email) - .setContentTitle(title) - .setContentText(email) - .setAutoCancel(true) - .setPriority(NotificationCompat.PRIORITY_DEFAULT) - .setContentIntent(pendingIntent) - .build() - try { - NotificationManagerCompat.from(appContext).notify(email.hashCode(), notification) - } catch (error: SecurityException) { - android.util.Log.w(TAG, "Notification permission is unavailable", error) - } - } - val update = JSONObject() - .put("accountId", account.optString("id")) - .put("newCount", count) - .put("foldersChanged", org.json.JSONArray().put("Inbox")) - appContext.sendBroadcast(Intent(ACTION_MAIL_SYNC) - .setPackage(appContext.packageName) - .putExtra(EXTRA_SYNC_UPDATE, update.toString())) - } - - fun notifySnoozeReminder(context: Context, account: JSONObject, reminder: JSONObject) { - val appContext = context.applicationContext - val email = account.optString("email") - if (account.optBoolean("notificationsEnabled", true)) { - val manager = appContext.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && - manager.getNotificationChannel(MAIL_CHANNEL_ID) == null) { - manager.createNotificationChannel(NotificationChannel( - MAIL_CHANNEL_ID, - "Mail reminders", - NotificationManager.IMPORTANCE_DEFAULT - )) - } - val notification = NotificationCompat.Builder(appContext, MAIL_CHANNEL_ID) - .setSmallIcon(android.R.drawable.ic_dialog_email) - .setContentTitle("Mail reminder") - .setContentText(reminder.optString("subject").ifBlank { "A snoozed message is due" }) - .setAutoCancel(true) - .setPriority(NotificationCompat.PRIORITY_DEFAULT) - .setContentIntent(appPendingIntentFor(appContext)) - .build() - try { - NotificationManagerCompat.from(appContext).notify( - (email + reminder.optLong("uid")).hashCode(), - notification - ) - } catch (error: SecurityException) { - android.util.Log.w(TAG, "Reminder notification permission is unavailable", error) - } - } - val update = JSONObject() - .put("accountId", account.optString("id")) - .put("snoozeReminder", true) - .put("foldersChanged", org.json.JSONArray() - .put("Snoozed") - .put(reminder.optString("folder", "Inbox"))) - appContext.sendBroadcast(Intent(ACTION_MAIL_SYNC) - .setPackage(appContext.packageName) - .putExtra(EXTRA_SYNC_UPDATE, update.toString())) - } - - private fun appPendingIntentFor(context: Context): PendingIntent { - val intent = context.packageManager.getLaunchIntentForPackage(context.packageName) - ?: Intent(context, MainActivity::class.java) - intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP) - return PendingIntent.getActivity( - context, 0, intent, - PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE - ) - } - } -} + failures += 1 + } finally { + watcher.folder = null + watcher.store = null + } + if (!watcher.stopped.get()) { + val delayMs = (15_000L * (1L shl failures.coerceAtMost(5))).coerceAtMost(5 * 60_000L) + try { + Thread.sleep(delayMs) + } catch (_: InterruptedException) { + if (watcher.stopped.get()) break + } + } + } + }, "ep-mail-idle-$id") + thread.isDaemon = true + watcher.thread = thread + thread.start() + } + + private fun onNewMail(account: JSONObject, count: Int) { + notifyNewMail(this, account, count) + } + + private fun foregroundNotification(): Notification = NotificationCompat.Builder(this, SERVICE_CHANNEL_ID) + .setSmallIcon(android.R.drawable.ic_dialog_email) + .setContentTitle(getString(R.string.app_name)) + .setContentText("Checking mail in the background") + .setContentIntent(appPendingIntent()) + .setOngoing(true) + .setPriority(NotificationCompat.PRIORITY_LOW) + .build() + + private fun appPendingIntent(): PendingIntent { + val intent = packageManager.getLaunchIntentForPackage(packageName) + ?: Intent(this, MainActivity::class.java) + intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP) + return PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) + } + + private fun createNotificationChannels() { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) return + val manager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager + manager.createNotificationChannel(NotificationChannel( + SERVICE_CHANNEL_ID, + "Background mail sync", + NotificationManager.IMPORTANCE_LOW + ).apply { description = "Keeps mail synchronized in the background." }) + manager.createNotificationChannel(NotificationChannel( + MAIL_CHANNEL_ID, + "New mail", + NotificationManager.IMPORTANCE_DEFAULT + ).apply { description = "Notifies you when new mail arrives." }) + } + + companion object { + const val ACTION_MAIL_SYNC = "studio.daybreak.mail.MAIL_SYNC_UPDATE" + const val EXTRA_SYNC_UPDATE = "syncUpdate" + private const val TAG = "EpMailIdle" + private const val MAX_WATCHERS = 2 + private const val FOREGROUND_NOTIFICATION_ID = 3410 + private const val SERVICE_CHANNEL_ID = "mail-sync-service" + private const val MAIL_CHANNEL_ID = "mail-new-message" + + fun start(context: Context) { + AndroidAccountVault.initialize(context) + if (AndroidAccountVault.accounts().length() == 0) return + MailFallbackWorker.schedule(context) + val intent = Intent(context, MailIdleService::class.java) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) context.startForegroundService(intent) + else context.startService(intent) + } + + fun stop(context: Context) { + context.stopService(Intent(context, MailIdleService::class.java)) + MailFallbackWorker.cancel(context) + } + + fun checkSnoozeReminders(context: Context) { + AndroidAccountVault.initialize(context) + val accounts = AndroidAccountVault.accounts() + for (index in 0 until accounts.length()) { + val account = accounts.getJSONObject(index) + val reminders = AndroidAccountVault.takeDueSnoozes( + account.optString("id"), + System.currentTimeMillis() + ) + for (reminderIndex in 0 until reminders.length()) { + notifySnoozeReminder(context, account, reminders.getJSONObject(reminderIndex)) + } + } + } + + fun notifyNewMail(context: Context, account: JSONObject, count: Int) { + if (count <= 0) return + val appContext = context.applicationContext + val email = account.optString("email") + if (account.optBoolean("notificationsEnabled", true)) { + val notificationManager = appContext.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && + notificationManager.getNotificationChannel(MAIL_CHANNEL_ID) == null) { + notificationManager.createNotificationChannel(NotificationChannel( + MAIL_CHANNEL_ID, + "New mail", + NotificationManager.IMPORTANCE_DEFAULT + ).apply { description = "Notifies you when new mail arrives." }) + } + val launchIntent = appContext.packageManager.getLaunchIntentForPackage(appContext.packageName) + ?: Intent(appContext, MainActivity::class.java) + launchIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP) + val pendingIntent = PendingIntent.getActivity( + appContext, 0, launchIntent, + PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE + ) + val title = if (count == 1) "New mail" else "$count new messages" + val notification = NotificationCompat.Builder(appContext, MAIL_CHANNEL_ID) + .setSmallIcon(android.R.drawable.ic_dialog_email) + .setContentTitle(title) + .setContentText("Open ep-mail to check your inbox") + .setAutoCancel(true) + .setPriority(NotificationCompat.PRIORITY_DEFAULT) + .setContentIntent(pendingIntent) + .build() + try { + NotificationManagerCompat.from(appContext).notify(email.hashCode(), notification) + } catch (error: SecurityException) { + android.util.Log.w(TAG, "Notification permission is unavailable (${error.javaClass.simpleName})") + } + } + val update = JSONObject() + .put("accountId", account.optString("id")) + .put("newCount", count) + .put("foldersChanged", org.json.JSONArray().put("Inbox")) + appContext.sendBroadcast(Intent(ACTION_MAIL_SYNC) + .setPackage(appContext.packageName) + .putExtra(EXTRA_SYNC_UPDATE, update.toString())) + } + + fun notifySnoozeReminder(context: Context, account: JSONObject, reminder: JSONObject) { + val appContext = context.applicationContext + val email = account.optString("email") + if (account.optBoolean("notificationsEnabled", true)) { + val manager = appContext.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && + manager.getNotificationChannel(MAIL_CHANNEL_ID) == null) { + manager.createNotificationChannel(NotificationChannel( + MAIL_CHANNEL_ID, + "Mail reminders", + NotificationManager.IMPORTANCE_DEFAULT + )) + } + val notification = NotificationCompat.Builder(appContext, MAIL_CHANNEL_ID) + .setSmallIcon(android.R.drawable.ic_dialog_email) + .setContentTitle("Mail reminder") + .setContentText("A snoozed message is due") + .setAutoCancel(true) + .setPriority(NotificationCompat.PRIORITY_DEFAULT) + .setContentIntent(appPendingIntentFor(appContext)) + .build() + try { + NotificationManagerCompat.from(appContext).notify( + (email + reminder.optLong("uid")).hashCode(), + notification + ) + } catch (error: SecurityException) { + android.util.Log.w(TAG, "Reminder notification permission is unavailable (${error.javaClass.simpleName})") + } + } + val update = JSONObject() + .put("accountId", account.optString("id")) + .put("snoozeReminder", true) + .put("foldersChanged", org.json.JSONArray() + .put("Snoozed") + .put(reminder.optString("folder", "Inbox"))) + appContext.sendBroadcast(Intent(ACTION_MAIL_SYNC) + .setPackage(appContext.packageName) + .putExtra(EXTRA_SYNC_UPDATE, update.toString())) + } + + private fun appPendingIntentFor(context: Context): PendingIntent { + val intent = context.packageManager.getLaunchIntentForPackage(context.packageName) + ?: Intent(context, MainActivity::class.java) + intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP) + return PendingIntent.getActivity( + context, 0, intent, + PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE + ) + } + } +} diff --git a/android/app/src/main/java/studio/daybreak/mail/MainActivity.java b/android/app/src/main/java/studio/daybreak/mail/MainActivity.java index 3f4ac5d..91cc237 100644 --- a/android/app/src/main/java/studio/daybreak/mail/MainActivity.java +++ b/android/app/src/main/java/studio/daybreak/mail/MainActivity.java @@ -1,19 +1,19 @@ -package studio.daybreak.mail; - -import android.Manifest; -import android.content.pm.PackageManager; -import android.os.Build; -import android.os.Bundle; -import androidx.core.app.ActivityCompat; -import com.getcapacitor.BridgeActivity; - -public class MainActivity extends BridgeActivity { - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - registerPlugin(EpMailPlugin.class); - if (Build.VERSION.SDK_INT >= 33 && checkSelfPermission(Manifest.permission.POST_NOTIFICATIONS) != PackageManager.PERMISSION_GRANTED) { - ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.POST_NOTIFICATIONS }, 701); - } - } -} +package studio.daybreak.mail; + +import android.Manifest; +import android.content.pm.PackageManager; +import android.os.Build; +import android.os.Bundle; +import androidx.core.app.ActivityCompat; +import com.getcapacitor.BridgeActivity; + +public class MainActivity extends BridgeActivity { + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + registerPlugin(EpMailPlugin.class); + if (Build.VERSION.SDK_INT >= 33 && checkSelfPermission(Manifest.permission.POST_NOTIFICATIONS) != PackageManager.PERMISSION_GRANTED) { + ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.POST_NOTIFICATIONS }, 701); + } + } +} diff --git a/android/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/android/app/src/main/res/drawable-v24/ic_launcher_foreground.xml index c7bd21d..ddb26ad 100644 --- a/android/app/src/main/res/drawable-v24/ic_launcher_foreground.xml +++ b/android/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -1,34 +1,34 @@ - - - - - - - - - - - + + + + + + + + + + + diff --git a/android/app/src/main/res/drawable/ic_launcher_background.xml b/android/app/src/main/res/drawable/ic_launcher_background.xml index d5fccc5..3a37cf6 100644 --- a/android/app/src/main/res/drawable/ic_launcher_background.xml +++ b/android/app/src/main/res/drawable/ic_launcher_background.xml @@ -1,170 +1,170 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/android/app/src/main/res/layout/activity_main.xml b/android/app/src/main/res/layout/activity_main.xml index b5ad138..f375693 100644 --- a/android/app/src/main/res/layout/activity_main.xml +++ b/android/app/src/main/res/layout/activity_main.xml @@ -1,12 +1,12 @@ - - - - - + + + + + diff --git a/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml index 036d09b..67820c5 100644 --- a/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +++ b/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml index 036d09b..67820c5 100644 --- a/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml +++ b/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/android/app/src/main/res/values/ic_launcher_background.xml b/android/app/src/main/res/values/ic_launcher_background.xml index c5d5899..cfa9be0 100644 --- a/android/app/src/main/res/values/ic_launcher_background.xml +++ b/android/app/src/main/res/values/ic_launcher_background.xml @@ -1,4 +1,4 @@ - - - #FFFFFF + + + #FFFFFF \ No newline at end of file diff --git a/android/app/src/main/res/values/strings.xml b/android/app/src/main/res/values/strings.xml index 51a7fb9..217023d 100644 --- a/android/app/src/main/res/values/strings.xml +++ b/android/app/src/main/res/values/strings.xml @@ -1,7 +1,7 @@ - - - ep-mail - ep-mail - studio.daybreak.mail - studio.daybreak.mail - + + + ep-mail + ep-mail + studio.daybreak.mail + studio.daybreak.mail + diff --git a/android/app/src/main/res/values/styles.xml b/android/app/src/main/res/values/styles.xml index be874e5..6e28da9 100644 --- a/android/app/src/main/res/values/styles.xml +++ b/android/app/src/main/res/values/styles.xml @@ -1,22 +1,22 @@ - - - - - - - - - - + + + + + + + + + + \ No newline at end of file diff --git a/android/app/src/main/res/xml/data_extraction_rules.xml b/android/app/src/main/res/xml/data_extraction_rules.xml new file mode 100644 index 0000000..4c04465 --- /dev/null +++ b/android/app/src/main/res/xml/data_extraction_rules.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/android/app/src/main/res/xml/file_paths.xml b/android/app/src/main/res/xml/file_paths.xml deleted file mode 100644 index bd0c4d8..0000000 --- a/android/app/src/main/res/xml/file_paths.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/android/app/src/test/java/com/getcapacitor/myapp/ExampleUnitTest.java b/android/app/src/test/java/com/getcapacitor/myapp/ExampleUnitTest.java index 0297327..124cc81 100644 --- a/android/app/src/test/java/com/getcapacitor/myapp/ExampleUnitTest.java +++ b/android/app/src/test/java/com/getcapacitor/myapp/ExampleUnitTest.java @@ -1,18 +1,18 @@ -package com.getcapacitor.myapp; - -import static org.junit.Assert.*; - -import org.junit.Test; - -/** - * Example local unit test, which will execute on the development machine (host). - * - * @see Testing documentation - */ -public class ExampleUnitTest { - - @Test - public void addition_isCorrect() throws Exception { - assertEquals(4, 2 + 2); - } -} +package com.getcapacitor.myapp; + +import static org.junit.Assert.*; + +import org.junit.Test; + +/** + * Example local unit test, which will execute on the development machine (host). + * + * @see Testing documentation + */ +public class ExampleUnitTest { + + @Test + public void addition_isCorrect() throws Exception { + assertEquals(4, 2 + 2); + } +} diff --git a/android/app/src/test/java/studio/daybreak/mail/AttachmentNamePolicyTest.kt b/android/app/src/test/java/studio/daybreak/mail/AttachmentNamePolicyTest.kt new file mode 100644 index 0000000..563c5be --- /dev/null +++ b/android/app/src/test/java/studio/daybreak/mail/AttachmentNamePolicyTest.kt @@ -0,0 +1,20 @@ +package studio.daybreak.mail + +import org.junit.Assert.assertEquals +import org.junit.Test + +class AttachmentNamePolicyTest { + @Test + fun stripsPathSeparatorsAndControlCharacters() { + assertEquals(".._secret.txt", AttachmentNamePolicy.sanitize("../secret.txt")) + assertEquals("folder__secret.txt", AttachmentNamePolicy.sanitize("folder\\/secret.txt")) + assertEquals("bad_name.txt", AttachmentNamePolicy.sanitize("bad\u0000name.txt")) + } + + @Test + fun suppliesSafeFallbackAndBoundsLength() { + assertEquals("attachment", AttachmentNamePolicy.sanitize("..")) + assertEquals("attachment", AttachmentNamePolicy.sanitize(" ")) + assertEquals(180, AttachmentNamePolicy.sanitize("a".repeat(300)).length) + } +} diff --git a/android/app/src/test/java/studio/daybreak/mail/DavUrlPolicyTest.kt b/android/app/src/test/java/studio/daybreak/mail/DavUrlPolicyTest.kt new file mode 100644 index 0000000..d5ba1b6 --- /dev/null +++ b/android/app/src/test/java/studio/daybreak/mail/DavUrlPolicyTest.kt @@ -0,0 +1,54 @@ +package studio.daybreak.mail + +import org.junit.Assert.assertEquals +import org.junit.Assert.assertThrows +import org.junit.Test + +class DavUrlPolicyTest { + @Test + fun acceptsHttpsServerUrl() { + assertEquals("https://dav.example.test/calendar", DavUrlPolicy.parseServerUrl( + "https://dav.example.test/calendar" + ).toString()) + } + + @Test + fun rejectsCleartextAndNonWebSchemes() { + assertThrows(IllegalArgumentException::class.java) { + DavUrlPolicy.parseServerUrl("http://localhost:8080/dav") + } + assertThrows(IllegalArgumentException::class.java) { + DavUrlPolicy.parseServerUrl("ftp://dav.example.test/dav") + } + } + + @Test + fun rejectsEmbeddedCredentialsAndFragments() { + assertThrows(IllegalArgumentException::class.java) { + DavUrlPolicy.parseServerUrl("https://user:pass@dav.example.test/dav") + } + assertThrows(IllegalArgumentException::class.java) { + DavUrlPolicy.parseServerUrl("https://dav.example.test/dav#fragment") + } + } + + @Test + fun allowsSameOriginAndRejectsCrossOriginTargets() { + DavUrlPolicy.requireSameOrigin( + "https://dav.example.test/root", + "https://dav.example.test/calendar/" + ) + assertThrows(IllegalArgumentException::class.java) { + DavUrlPolicy.requireSameOrigin( + "https://dav.example.test/root", + "https://attacker.example.test/calendar/" + ) + } + assertThrows(IllegalArgumentException::class.java) { + DavUrlPolicy.requireSameOrigin( + "https://dav.example.test/root", + "http://dav.example.test/calendar/" + ) + } + } +} diff --git a/android/build.gradle b/android/build.gradle index df428a0..d301c06 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,30 +1,30 @@ -// Top-level build file where you can add configuration options common to all sub-projects/modules. - -buildscript { - - repositories { - google() - mavenCentral() - } - dependencies { - classpath 'com.android.tools.build:gradle:8.13.0' - classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:2.0.21' - classpath 'com.google.gms:google-services:4.4.4' - - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files - } -} - -apply from: "variables.gradle" - -allprojects { - repositories { - google() - mavenCentral() - } -} - -task clean(type: Delete) { - delete rootProject.buildDir -} +// Top-level build file where you can add configuration options common to all sub-projects/modules. + +buildscript { + + repositories { + google() + mavenCentral() + } + dependencies { + classpath 'com.android.tools.build:gradle:8.13.0' + classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:2.0.21' + classpath 'com.google.gms:google-services:4.4.4' + + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } +} + +apply from: "variables.gradle" + +allprojects { + repositories { + google() + mavenCentral() + } +} + +task clean(type: Delete) { + delete rootProject.buildDir +} diff --git a/android/gradle.properties b/android/gradle.properties index 2e87c52..ac73da1 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -1,22 +1,22 @@ -# Project-wide Gradle settings. - -# IDE (e.g. Android Studio) users: -# Gradle settings configured through the IDE *will override* -# any settings specified in this file. - -# For more details on how to configure your build environment visit -# http://www.gradle.org/docs/current/userguide/build_environment.html - -# Specifies the JVM arguments used for the daemon process. -# The setting is particularly useful for tweaking memory settings. -org.gradle.jvmargs=-Xmx1536m - -# When configured, Gradle will run in incubating parallel mode. -# This option should only be used with decoupled projects. More details, visit -# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects -# org.gradle.parallel=true - -# AndroidX package structure to make it clearer which packages are bundled with the -# Android operating system, and which are packaged with your app's APK -# https://developer.android.com/topic/libraries/support-library/androidx-rn -android.useAndroidX=true +# Project-wide Gradle settings. + +# IDE (e.g. Android Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. + +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html + +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +org.gradle.jvmargs=-Xmx1536m + +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +# org.gradle.parallel=true + +# AndroidX package structure to make it clearer which packages are bundled with the +# Android operating system, and which are packaged with your app's APK +# https://developer.android.com/topic/libraries/support-library/androidx-rn +android.useAndroidX=true diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties index 7705927..7912cdb 100644 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -1,7 +1,7 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-all.zip -networkTimeout=10000 -validateDistributionUrl=true -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-all.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/android/gradlew b/android/gradlew index 23d15a9..a4911a5 100644 --- a/android/gradlew +++ b/android/gradlew @@ -1,251 +1,251 @@ -#!/bin/sh - -# -# Copyright © 2015-2021 the original authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# SPDX-License-Identifier: Apache-2.0 -# - -############################################################################## -# -# Gradle start up script for POSIX generated by Gradle. -# -# Important for running: -# -# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is -# noncompliant, but you have some other compliant shell such as ksh or -# bash, then to run this script, type that shell name before the whole -# command line, like: -# -# ksh Gradle -# -# Busybox and similar reduced shells will NOT work, because this script -# requires all of these POSIX shell features: -# * functions; -# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», -# «${var#prefix}», «${var%suffix}», and «$( cmd )»; -# * compound commands having a testable exit status, especially «case»; -# * various built-in commands including «command», «set», and «ulimit». -# -# Important for patching: -# -# (2) This script targets any POSIX shell, so it avoids extensions provided -# by Bash, Ksh, etc; in particular arrays are avoided. -# -# The "traditional" practice of packing multiple parameters into a -# space-separated string is a well documented source of bugs and security -# problems, so this is (mostly) avoided, by progressively accumulating -# options in "$@", and eventually passing that to Java. -# -# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, -# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; -# see the in-line comments for details. -# -# There are tweaks for specific operating systems such as AIX, CygWin, -# Darwin, MinGW, and NonStop. -# -# (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt -# within the Gradle project. -# -# You can find Gradle at https://github.com/gradle/gradle/. -# -############################################################################## - -# Attempt to set APP_HOME - -# Resolve links: $0 may be a link -app_path=$0 - -# Need this for daisy-chained symlinks. -while - APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path - [ -h "$app_path" ] -do - ls=$( ls -ld "$app_path" ) - link=${ls#*' -> '} - case $link in #( - /*) app_path=$link ;; #( - *) app_path=$APP_HOME$link ;; - esac -done - -# This is normally unused -# shellcheck disable=SC2034 -APP_BASE_NAME=${0##*/} -# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD=maximum - -warn () { - echo "$*" -} >&2 - -die () { - echo - echo "$*" - echo - exit 1 -} >&2 - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "$( uname )" in #( - CYGWIN* ) cygwin=true ;; #( - Darwin* ) darwin=true ;; #( - MSYS* | MINGW* ) msys=true ;; #( - NONSTOP* ) nonstop=true ;; -esac - -CLASSPATH="\\\"\\\"" - - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD=$JAVA_HOME/jre/sh/java - else - JAVACMD=$JAVA_HOME/bin/java - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD=java - if ! command -v java >/dev/null 2>&1 - then - die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -fi - -# Increase the maximum file descriptors if we can. -if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then - case $MAX_FD in #( - max*) - # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC2039,SC3045 - MAX_FD=$( ulimit -H -n ) || - warn "Could not query maximum file descriptor limit" - esac - case $MAX_FD in #( - '' | soft) :;; #( - *) - # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC2039,SC3045 - ulimit -n "$MAX_FD" || - warn "Could not set maximum file descriptor limit to $MAX_FD" - esac -fi - -# Collect all arguments for the java command, stacking in reverse order: -# * args from the command line -# * the main class name -# * -classpath -# * -D...appname settings -# * --module-path (only if needed) -# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. - -# For Cygwin or MSYS, switch paths to Windows format before running java -if "$cygwin" || "$msys" ; then - APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) - - JAVACMD=$( cygpath --unix "$JAVACMD" ) - - # Now convert the arguments - kludge to limit ourselves to /bin/sh - for arg do - if - case $arg in #( - -*) false ;; # don't mess with options #( - /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath - [ -e "$t" ] ;; #( - *) false ;; - esac - then - arg=$( cygpath --path --ignore --mixed "$arg" ) - fi - # Roll the args list around exactly as many times as the number of - # args, so each arg winds up back in the position where it started, but - # possibly modified. - # - # NB: a `for` loop captures its iteration list before it begins, so - # changing the positional parameters here affects neither the number of - # iterations, nor the values presented in `arg`. - shift # remove old arg - set -- "$@" "$arg" # push replacement arg - done -fi - - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' - -# Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, -# and any embedded shellness will be escaped. -# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be -# treated as '${Hostname}' itself on the command line. - -set -- \ - "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ - "$@" - -# Stop when "xargs" is not available. -if ! command -v xargs >/dev/null 2>&1 -then - die "xargs is not available" -fi - -# Use "xargs" to parse quoted args. -# -# With -n1 it outputs one arg per line, with the quotes and backslashes removed. -# -# In Bash we could simply go: -# -# readarray ARGS < <( xargs -n1 <<<"$var" ) && -# set -- "${ARGS[@]}" "$@" -# -# but POSIX shell has neither arrays nor command substitution, so instead we -# post-process each arg (as a line of input to sed) to backslash-escape any -# character that might be a shell metacharacter, then use eval to reverse -# that process (while maintaining the separation between arguments), and wrap -# the whole thing up as a single "set" statement. -# -# This will of course break if any of these variables contains a newline or -# an unmatched quote. -# - -eval "set -- $( - printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | - xargs -n1 | - sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | - tr '\n' ' ' - )" '"$@"' - -exec "$JAVACMD" "$@" +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH="\\\"\\\"" + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/android/gradlew.bat b/android/gradlew.bat index db3a6ac..5eed7ee 100644 --- a/android/gradlew.bat +++ b/android/gradlew.bat @@ -1,94 +1,94 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem -@rem SPDX-License-Identifier: Apache-2.0 -@rem - -@if "%DEBUG%"=="" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%"=="" set DIRNAME=. -@rem This is normally unused -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if %ERRORLEVEL% equ 0 goto execute - -echo. 1>&2 -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 -echo. 1>&2 -echo Please set the JAVA_HOME variable in your environment to match the 1>&2 -echo location of your Java installation. 1>&2 - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. 1>&2 -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 -echo. 1>&2 -echo Please set the JAVA_HOME variable in your environment to match the 1>&2 -echo location of your Java installation. 1>&2 - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH= - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH= + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/android/settings.gradle b/android/settings.gradle index 3b4431d..644a815 100644 --- a/android/settings.gradle +++ b/android/settings.gradle @@ -1,5 +1,5 @@ -include ':app' -include ':capacitor-cordova-android-plugins' -project(':capacitor-cordova-android-plugins').projectDir = new File('./capacitor-cordova-android-plugins/') - +include ':app' +include ':capacitor-cordova-android-plugins' +project(':capacitor-cordova-android-plugins').projectDir = new File('./capacitor-cordova-android-plugins/') + apply from: 'capacitor.settings.gradle' \ No newline at end of file diff --git a/android/variables.gradle b/android/variables.gradle index ee4ba41..d69c715 100644 --- a/android/variables.gradle +++ b/android/variables.gradle @@ -1,16 +1,16 @@ -ext { - minSdkVersion = 24 - compileSdkVersion = 36 - targetSdkVersion = 36 - androidxActivityVersion = '1.11.0' - androidxAppCompatVersion = '1.7.1' - androidxCoordinatorLayoutVersion = '1.3.0' - androidxCoreVersion = '1.17.0' - androidxFragmentVersion = '1.8.9' - coreSplashScreenVersion = '1.2.0' - androidxWebkitVersion = '1.14.0' - junitVersion = '4.13.2' - androidxJunitVersion = '1.3.0' - androidxEspressoCoreVersion = '3.7.0' - cordovaAndroidVersion = '14.0.1' +ext { + minSdkVersion = 24 + compileSdkVersion = 36 + targetSdkVersion = 36 + androidxActivityVersion = '1.11.0' + androidxAppCompatVersion = '1.7.1' + androidxCoordinatorLayoutVersion = '1.3.0' + androidxCoreVersion = '1.17.0' + androidxFragmentVersion = '1.8.9' + coreSplashScreenVersion = '1.2.0' + androidxWebkitVersion = '1.14.0' + junitVersion = '4.13.2' + androidxJunitVersion = '1.3.0' + androidxEspressoCoreVersion = '3.7.0' + cordovaAndroidVersion = '14.0.1' } \ No newline at end of file diff --git a/app.js b/app.js index 425ab65..f3a973e 100644 --- a/app.js +++ b/app.js @@ -2,40 +2,40 @@ if('serviceWorker'in navigator)window.addEventListener('load',()=>navigator.serviceWorker.register('./service-worker.js').catch(()=>{})); const state = window.epMailState; const $=s=>document.querySelector(s), $$=s=>[...document.querySelectorAll(s)]; -function esc(x){return String(x).replace(/[&<>"']/g,c=>({'&':'&','<':'<','>':'>','"':'"',"'":'''}[c]))} +function esc(x){return String(x).replace(/[&<>"']/g,c=>({'&':'&','<':'<','>':'>','"':'"',"'":'''}[c]))} const { safeRemoteImageUrl, sanitizeMailHtml } = window.epMailFeatures.contentSecurity; -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=>`
${m.initials}
${esc(m.sender)}
${esc(m.subject)}
${esc(m.snippet)}
${esc(m.time)}
`).join(''):`
⌕

No messages here

Try another folder or search.

`;$$('.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)$('#reader-pane').innerHTML=emptyReader()} -function openMessage(id){ - state.activeMessage=id; - const m=state.messages.find(x=>x.id===id); - if(!m)return; - m.unread=false; - renderList(); - let safeHtml={html:'',remoteImageCount:0}; - if(m.html)try{safeHtml=sanitizeMailHtml(m.html)}catch(error){console.error('Could not sanitize message HTML; showing plain text instead.',error)} - const body=safeHtml.html?safeHtml.html:`${m.body.map(p=>`

${esc(p)}

`).join('')}

${esc(m.signature||m.sender)}

`; - const imageNotice=safeHtml.remoteImageCount?`

This message contains ${safeHtml.remoteImageCount} remote image${safeHtml.remoteImageCount===1?'':'s'}. Loading them can reveal your network address and that you opened this message to the image host.

`:''; - const attachments=(m.attachments?.length?m.attachments:m.attachment?[{filename:m.attachment,size:m.size}]:[]).map(file=>`
${file.filename.toLowerCase().endsWith('.pdf')?'▤':'▧'}
${esc(file.filename)}${file.size?(typeof file.size==='string'?esc(file.size):`${(file.size/1048576).toFixed(1)} MB`):'Attachment'}
`).join(''); - $('#reader-pane').innerHTML=`
${m.tags.map((t,i)=>`${esc(t)}`).join('')}

${esc(m.subject)}

${m.initials}
${esc(m.sender)}${esc(m.email)} · to me
${esc(m.date)}
${imageNotice}
${body}${attachments}
`; - $('#load-remote-images')?.addEventListener('click',()=>{ - $('#reader-pane').querySelectorAll('.reader-body img[data-remote-src]').forEach(image=>{ - const url=safeRemoteImageUrl(image.getAttribute('data-remote-src')); - image.removeAttribute('data-remote-src'); - if(url)image.src=url; - }); - $('.remote-image-notice')?.remove(); - }); - $('#reader-archive').onclick=()=>{m.archived=true;toast('Moved to Archive');renderList();$('#reader-pane').innerHTML=emptyReader()}; - $('#reader-delete').onclick=()=>{m.deleted=true;toast('Moved to Trash');renderList();$('#reader-pane').innerHTML=emptyReader()}; - $('#reader-star').onclick=()=>{m.star=!m.star;renderList();openMessage(id)}; - $('#reply').onclick=()=>showCompose(m); - $('#forward').onclick=()=>showCompose(m,true); -} -function emptyReader(){return `
✉

Your inbox, at your pace

Select a message to read it here.

`} -function toast(s){const el=$('#toast');el.textContent=s;el.classList.add('visible');clearTimeout(state.toastTimer);state.toastTimer=setTimeout(()=>el.classList.remove('visible'),2300)} -function showCompose(reply,forward=false){const root=$('#modal-root');root.innerHTML=``;const close=()=>root.innerHTML='';$('.modal-close').onclick=close;$('#discard').onclick=close;$('.modal-overlay').addEventListener('click',e=>{if(e.target.classList.contains('modal-overlay'))close()});$('#send').onclick=()=>{const to=$('#compose-to').value.trim();if(!to){$('#compose-to').focus();toast('Add a recipient to send your message');return}const subject=$('#compose-subject').value.trim()||'(no subject)';const body=$('#compose-body').value;state.messages.unshift({id:Date.now(),initials:(window.epMailFeatures.productivity?.profileName||window.epMailFeatures.mail.connectedAccount?.email?.split('@')[0]||'Me').split(/\\s+/).map(x=>x[0]).join('').slice(0,2).toUpperCase(),color:'#dce9dd',sender:(window.epMailFeatures.productivity?.profileName||window.epMailFeatures.mail.connectedAccount?.email?.split('@')[0]||'Me'),email:(window.epMailFeatures.mail.connectedAccount?.email||''),subject,snippet:body||'No message text',time:'Just now',date:'Today',unread:false,star:false,sent:true,tags:['Sent'],body:body.split('\n').filter(Boolean)});close();toast('Message sent');renderList()};$('#compose-to').focus()} +function 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=>`
${m.initials}
${esc(m.sender)}
${esc(m.subject)}
${esc(m.snippet)}
${esc(m.time)}
`).join(''):`
⌕

No messages here

Try another folder or search.

`;$$('.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)$('#reader-pane').innerHTML=emptyReader()} +function openMessage(id){ + state.activeMessage=id; + const m=state.messages.find(x=>x.id===id); + if(!m)return; + m.unread=false; + renderList(); + let safeHtml={html:'',remoteImageCount:0}; + if(m.html)try{safeHtml=sanitizeMailHtml(m.html)}catch(error){console.error('Could not sanitize message HTML; showing plain text instead.',error)} + const body=safeHtml.html?safeHtml.html:`${m.body.map(p=>`

${esc(p)}

`).join('')}

${esc(m.signature||m.sender)}

`; + const imageNotice=safeHtml.remoteImageCount?`

This message contains ${safeHtml.remoteImageCount} remote image${safeHtml.remoteImageCount===1?'':'s'}. Loading them can reveal your network address and that you opened this message to the image host.

`:''; + const attachments=(m.attachments?.length?m.attachments:m.attachment?[{filename:m.attachment,size:m.size}]:[]).map(file=>`
${file.filename.toLowerCase().endsWith('.pdf')?'▤':'▧'}
${esc(file.filename)}${file.size?(typeof file.size==='string'?esc(file.size):`${(file.size/1048576).toFixed(1)} MB`):'Attachment'}
`).join(''); + $('#reader-pane').innerHTML=`
${m.tags.map((t,i)=>`${esc(t)}`).join('')}

${esc(m.subject)}

${m.initials}
${esc(m.sender)}${esc(m.email)} · to me
${esc(m.date)}
${imageNotice}
${body}${attachments}
`; + $('#load-remote-images')?.addEventListener('click',()=>{ + $('#reader-pane').querySelectorAll('.reader-body img[data-remote-src]').forEach(image=>{ + const url=safeRemoteImageUrl(image.getAttribute('data-remote-src')); + image.removeAttribute('data-remote-src'); + if(url)image.src=url; + }); + $('.remote-image-notice')?.remove(); + }); + $('#reader-archive').onclick=()=>{m.archived=true;toast('Moved to Archive');renderList();$('#reader-pane').innerHTML=emptyReader()}; + $('#reader-delete').onclick=()=>{m.deleted=true;toast('Moved to Trash');renderList();$('#reader-pane').innerHTML=emptyReader()}; + $('#reader-star').onclick=()=>{m.star=!m.star;renderList();openMessage(id)}; + $('#reply').onclick=()=>showCompose(m); + $('#forward').onclick=()=>showCompose(m,true); +} +function emptyReader(){return `
✉

Your inbox, at your pace

Select a message to read it here.

`} +function toast(s){const el=$('#toast');el.textContent=s;el.classList.add('visible');clearTimeout(state.toastTimer);state.toastTimer=setTimeout(()=>el.classList.remove('visible'),2300)} +function showCompose(reply,forward=false){const root=$('#modal-root');root.innerHTML=``;const close=()=>root.innerHTML='';$('.modal-close').onclick=close;$('#discard').onclick=close;$('.modal-overlay').addEventListener('click',e=>{if(e.target.classList.contains('modal-overlay'))close()});$('#send').onclick=()=>{const to=$('#compose-to').value.trim();if(!to){$('#compose-to').focus();toast('Add a recipient to send your message');return}const subject=$('#compose-subject').value.trim()||'(no subject)';const body=$('#compose-body').value;state.messages.unshift({id:Date.now(),initials:(window.epMailFeatures.productivity?.profileName||window.epMailFeatures.mail.connectedAccount?.email?.split('@')[0]||'Me').split(/\\s+/).map(x=>x[0]).join('').slice(0,2).toUpperCase(),color:'#dce9dd',sender:(window.epMailFeatures.productivity?.profileName||window.epMailFeatures.mail.connectedAccount?.email?.split('@')[0]||'Me'),email:(window.epMailFeatures.mail.connectedAccount?.email||''),subject,snippet:body||'No message text',time:'Just now',date:'Today',unread:false,star:false,sent:true,tags:['Sent'],body:body.split('\n').filter(Boolean)});close();toast('Message sent');renderList()};$('#compose-to').focus()} function switchView(view){state.activeView=view;$$('.rail-button[data-view]').forEach(b=>b.classList.toggle('active',b.dataset.view===view));$('.mail-layout').classList.toggle('hidden',view!=='mail');$('#calendar-view').classList.toggle('hidden',view!=='calendar');$('#contacts-view').classList.toggle('hidden',view!=='contacts');$('#sidebar-title').textContent=view==='mail'?state.activeFolder:view==='calendar'?'Calendar':'Contacts';$('#crumb-parent').textContent=view==='mail'?'Mail':'Workspace';$('#crumb-current').textContent=view==='mail'?state.activeFolder:view==='calendar'?'Calendar':'Contacts';if(view==='calendar')window.epMailFeatures.productivity.renderCalendar();if(view==='contacts')window.epMailFeatures.productivity.renderContacts();} -$$('.folder').forEach(b=>b.onclick=()=>{state.activeFolder=b.dataset.folder;$$('.folder').forEach(x=>x.classList.toggle('active',x===b));$('#sidebar-title').textContent=state.activeFolder;$('#crumb-current').textContent=state.activeFolder;renderList()});$$('.rail-button[data-view]').forEach(b=>b.onclick=()=>{switchView(b.dataset.view);});function applyTheme(theme,showToast=false){const themes=['daylight','wasteland','ep-wasteland','ep-daylight'];const selected=themes.includes(theme)?theme:'ep-wasteland';const info={daylight:{name:'Eternity Daylight',icon:'☼'},wasteland:{name:'Wasteland',icon:'☾'},'ep-wasteland':{name:'EP Wasteland',icon:'◈'},'ep-daylight':{name:'EP Daylight',icon:'☀'}}[selected];document.body.classList.remove('wasteland','ep-wasteland','ep-daylight');if(selected!=='daylight')document.body.classList.add(selected);document.querySelector('meta[name=theme-color]')?.setAttribute('content',selected==='ep-wasteland'?'#161210':selected==='ep-daylight'?'#f1f1e9':selected==='wasteland'?'#eee8db':'#f4f5f1');localStorage.setItem('daybreak-theme',selected);const brandLogo=$("#brand-logo");if(brandLogo)brandLogo.src=selected==='ep-wasteland'?'logo-ep-wasteland.svg':'logo-ep-daylight.svg';if(showToast)toast(`${info.name} theme`)}applyTheme(localStorage.getItem('daybreak-theme')||'ep-wasteland');$('#search').oninput=e=>{state.query=e.target.value;renderList()};$('#search').addEventListener('keydown',e=>{if(e.key==='Escape'){e.target.value='';state.query='';renderList()}});$('#compose').onclick=()=>showCompose();$('#refresh').onclick=()=>{toast('You’re all up to date');renderList()};$('#select-all').onclick=()=>{const visible=state.messages.filter(m=>!m.archived&&!m.deleted);const all=visible.every(m=>state.selectedIds.has(m.id));visible.forEach(m=>all?state.selectedIds.delete(m.id):state.selectedIds.add(m.id));renderList()};$('#archive-selected').onclick=()=>{state.messages.filter(m=>state.selectedIds.has(m.id)).forEach(m=>m.archived=true);state.selectedIds.clear();renderList();toast('Selected messages archived')};$('#delete-selected').onclick=()=>{state.messages.filter(m=>state.selectedIds.has(m.id)).forEach(m=>m.deleted=true);state.selectedIds.clear();renderList();toast('Selected messages moved to Trash')};$('#sidebar-menu').onclick=()=>toast('More mailbox options');$$('.settings-button,.help-button,.tiny-plus,.text-button').forEach(b=>b.onclick=()=>toast('You’re all caught up'));document.addEventListener('keydown',e=>{if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()==='k'){e.preventDefault();$('#search').focus()}if(e.key==='Escape')$('#modal-root').innerHTML=''});$('#today-label').textContent=new Intl.DateTimeFormat('en-US',{weekday:'long',month:'long',day:'numeric'}).format(new Date()).toUpperCase();$('#reader-pane').innerHTML=emptyReader();renderList();openMessage(state.activeMessage); +$$('.folder').forEach(b=>b.onclick=()=>{state.activeFolder=b.dataset.folder;$$('.folder').forEach(x=>x.classList.toggle('active',x===b));$('#sidebar-title').textContent=state.activeFolder;$('#crumb-current').textContent=state.activeFolder;renderList()});$$('.rail-button[data-view]').forEach(b=>b.onclick=()=>{switchView(b.dataset.view);});function applyTheme(theme,showToast=false){const themes=['daylight','wasteland','ep-wasteland','ep-daylight'];const selected=themes.includes(theme)?theme:'ep-wasteland';const info={daylight:{name:'Eternity Daylight',icon:'☼'},wasteland:{name:'Wasteland',icon:'☾'},'ep-wasteland':{name:'EP Wasteland',icon:'◈'},'ep-daylight':{name:'EP Daylight',icon:'☀'}}[selected];document.body.classList.remove('wasteland','ep-wasteland','ep-daylight');if(selected!=='daylight')document.body.classList.add(selected);document.querySelector('meta[name=theme-color]')?.setAttribute('content',selected==='ep-wasteland'?'#161210':selected==='ep-daylight'?'#f1f1e9':selected==='wasteland'?'#eee8db':'#f4f5f1');localStorage.setItem('daybreak-theme',selected);const brandLogo=$("#brand-logo");if(brandLogo)brandLogo.src=selected==='ep-wasteland'?'logo-ep-wasteland.svg':'logo-ep-daylight.svg';if(showToast)toast(`${info.name} theme`)}applyTheme(localStorage.getItem('daybreak-theme')||'ep-wasteland');$('#search').oninput=e=>{state.query=e.target.value;renderList()};$('#search').addEventListener('keydown',e=>{if(e.key==='Escape'){e.target.value='';state.query='';renderList()}});$('#compose').onclick=()=>showCompose();$('#refresh').onclick=()=>{toast('You’re all up to date');renderList()};$('#select-all').onclick=()=>{const visible=state.messages.filter(m=>!m.archived&&!m.deleted);const all=visible.every(m=>state.selectedIds.has(m.id));visible.forEach(m=>all?state.selectedIds.delete(m.id):state.selectedIds.add(m.id));renderList()};$('#archive-selected').onclick=()=>{state.messages.filter(m=>state.selectedIds.has(m.id)).forEach(m=>m.archived=true);state.selectedIds.clear();renderList();toast('Selected messages archived')};$('#delete-selected').onclick=()=>{state.messages.filter(m=>state.selectedIds.has(m.id)).forEach(m=>m.deleted=true);state.selectedIds.clear();renderList();toast('Selected messages moved to Trash')};$('#sidebar-menu').onclick=()=>toast('More mailbox options');$$('.settings-button,.help-button,.tiny-plus,.text-button').forEach(b=>b.onclick=()=>toast('You’re all caught up'));document.addEventListener('keydown',e=>{if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()==='k'){e.preventDefault();$('#search').focus()}if(e.key==='Escape')$('#modal-root').innerHTML=''});$('#today-label').textContent=new Intl.DateTimeFormat('en-US',{weekday:'long',month:'long',day:'numeric'}).format(new Date()).toUpperCase();$('#reader-pane').innerHTML=emptyReader();renderList();openMessage(state.activeMessage); window.epMailShell = Object.freeze({ state, diff --git a/attachments.js b/attachments.js index 824d670..8c98d90 100644 --- a/attachments.js +++ b/attachments.js @@ -5,159 +5,159 @@ const selectAttachmentUi = attachmentMailUi.select; const selectAllAttachmentUi = attachmentMailUi.selectAll; const toastAttachmentUi = attachmentMailUi.toast; const attachmentFolders = ['Inbox', 'Sent', 'Archive', 'Trash']; -let attachmentItems = []; - -function attachmentKind(filename) { - const ext = String(filename).toLowerCase().split('.').pop(); - if (['png', 'jpg', 'jpeg', 'gif', 'webp', 'bmp', 'svg'].includes(ext)) return 'Images'; - if (['pdf', 'doc', 'docx', 'odt', 'txt', 'rtf', 'md', 'xls', 'xlsx', 'csv', 'ppt', 'pptx'].includes(ext)) return 'Documents'; - if (['zip', 'rar', '7z', 'tar', 'gz'].includes(ext)) return 'Archives'; - return 'Other'; -} - -function attachmentSize(size) { - if (!size) return ''; - if (typeof size === 'string') return size; - return size < 1048576 ? `${Math.max(1, Math.round(size / 1024))} KB` : `${(size / 1048576).toFixed(1)} MB`; -} - -async function previewAttachment(target, details) { - if (!details.uid || !window.daybreakMail?.previewAttachment) { - target.textContent = 'Previews are available for connected mailbox messages.'; - return; - } - target.textContent = 'Loading preview…'; - try { - const result = await window.daybreakMail.previewAttachment(details); - target.replaceChildren(); - if (result.kind === 'image') { - const image = document.createElement('img'); - image.className = 'attachment-preview-image'; - image.alt = details.filename; - image.src = result.dataUrl; - target.append(image); - } else if (result.kind === 'text') { - const pre = document.createElement('pre'); - pre.className = 'attachment-preview-text'; - pre.textContent = result.text + (result.truncated ? '\n… (preview truncated)' : ''); - target.append(pre); - } else { - target.textContent = result.reason || 'No preview is available for this file type.'; - } - } catch (error) { - target.textContent = error.message || 'Could not load the preview.'; - } -} - -function downloadAttachment(details) { - if (!details.uid || !window.daybreakMail?.saveAttachment) { toastAttachmentUi('Attachment download is available for connected mailbox messages'); return; } - window.daybreakMail.saveAttachment(details) - .then(result => { if (result.saved) toastAttachmentUi('Attachment saved'); }) - .catch(error => toastAttachmentUi(error.message || 'Could not save attachment')); -} - -// Add a Preview button to each attachment in the reader. +let attachmentItems = []; + +function attachmentKind(filename) { + const ext = String(filename).toLowerCase().split('.').pop(); + if (['png', 'jpg', 'jpeg', 'gif', 'webp', 'bmp', 'svg'].includes(ext)) return 'Images'; + if (['pdf', 'doc', 'docx', 'odt', 'txt', 'rtf', 'md', 'xls', 'xlsx', 'csv', 'ppt', 'pptx'].includes(ext)) return 'Documents'; + if (['zip', 'rar', '7z', 'tar', 'gz'].includes(ext)) return 'Archives'; + return 'Other'; +} + +function attachmentSize(size) { + if (!size) return ''; + if (typeof size === 'string') return size; + return size < 1048576 ? `${Math.max(1, Math.round(size / 1024))} KB` : `${(size / 1048576).toFixed(1)} MB`; +} + +async function previewAttachment(target, details) { + if (!details.uid || !window.daybreakMail?.previewAttachment) { + target.textContent = 'Previews are available for connected mailbox messages.'; + return; + } + target.textContent = 'Loading preview…'; + try { + const result = await window.daybreakMail.previewAttachment(details); + target.replaceChildren(); + if (result.kind === 'image') { + const image = document.createElement('img'); + image.className = 'attachment-preview-image'; + image.alt = details.filename; + image.src = result.dataUrl; + target.append(image); + } else if (result.kind === 'text') { + const pre = document.createElement('pre'); + pre.className = 'attachment-preview-text'; + pre.textContent = result.text + (result.truncated ? '\n… (preview truncated)' : ''); + target.append(pre); + } else { + target.textContent = result.reason || 'No preview is available for this file type.'; + } + } catch (error) { + target.textContent = error.message || 'Could not load the preview.'; + } +} + +function downloadAttachment(details) { + if (!details.uid || !window.daybreakMail?.saveAttachment) { toastAttachmentUi('Attachment download is available for connected mailbox messages'); return; } + window.daybreakMail.saveAttachment(details) + .then(result => { if (result.saved) toastAttachmentUi('Attachment saved'); }) + .catch(error => toastAttachmentUi(error.message || 'Could not save attachment')); +} + +// Add a Preview button to each attachment in the reader. attachmentMailUi.wrapOpenMessage(baseOpenMessage => function (id) { baseOpenMessage(id); const message = attachmentMailUi.state.messages.find(item => item.id === id); if (!message?.uid) return; - selectAllAttachmentUi('#reader-pane .attachment').forEach(row => { - const download = row.querySelector('.download'); - if (!download || row.querySelector('.preview-attachment')) return; - const button = document.createElement('button'); - button.className = 'preview-attachment icon-button'; - button.title = 'Preview'; - button.setAttribute('aria-label', `Preview ${download.dataset.filename}`); - button.textContent = '👁'; - button.addEventListener('click', event => { - event.stopPropagation(); - let panel = row.nextElementSibling?.classList.contains('attachment-preview') ? row.nextElementSibling : null; - if (panel) { panel.remove(); return; } - panel = document.createElement('div'); - panel.className = 'attachment-preview'; - row.after(panel); + selectAllAttachmentUi('#reader-pane .attachment').forEach(row => { + const download = row.querySelector('.download'); + if (!download || row.querySelector('.preview-attachment')) return; + const button = document.createElement('button'); + button.className = 'preview-attachment icon-button'; + button.title = 'Preview'; + button.setAttribute('aria-label', `Preview ${download.dataset.filename}`); + button.textContent = '👁'; + button.addEventListener('click', event => { + event.stopPropagation(); + let panel = row.nextElementSibling?.classList.contains('attachment-preview') ? row.nextElementSibling : null; + if (panel) { panel.remove(); return; } + panel = document.createElement('div'); + panel.className = 'attachment-preview'; + row.after(panel); void previewAttachment(panel, { uid: message.uid, folder: message.sourceFolder || attachmentMailUi.state.activeFolder, filename: download.dataset.filename }); - }); - download.before(button); - }); + }); + download.before(button); + }); }); - -async function collectAttachments() { - const items = []; - for (const folder of attachmentFolders) { - let offset = 0; - for (let page = 0; page < 5; page += 1) { - const result = await window.daybreakMail.syncFolder(folder, offset, { hasAttachments: true }); - for (const message of result.messages || []) { - for (const file of message.attachments || []) { - items.push({ - uid: message.uid, folder, filename: file.filename, size: file.size, - subject: message.subject, sender: message.sender, date: message.date, timestamp: Number(message.timestamp || 0), - kind: attachmentKind(file.filename) - }); - } - } - offset += (result.messages || []).length; - if (!result.messages?.length || offset >= (result.total || 0)) break; - } - } - return items.sort((a, b) => b.timestamp - a.timestamp); -} - -async function openAttachmentsView() { + +async function collectAttachments() { + const items = []; + for (const folder of attachmentFolders) { + let offset = 0; + for (let page = 0; page < 5; page += 1) { + const result = await window.daybreakMail.syncFolder(folder, offset, { hasAttachments: true }); + for (const message of result.messages || []) { + for (const file of message.attachments || []) { + items.push({ + uid: message.uid, folder, filename: file.filename, size: file.size, + subject: message.subject, sender: message.sender, date: message.date, timestamp: Number(message.timestamp || 0), + kind: attachmentKind(file.filename) + }); + } + } + offset += (result.messages || []).length; + if (!result.messages?.length || offset >= (result.total || 0)) break; + } + } + return items.sort((a, b) => b.timestamp - a.timestamp); +} + +async function openAttachmentsView() { if (!attachmentMailUi.connectedAccount || !window.daybreakMail) { attachmentMailUi.openMailAccount(); return; } - const root = selectAttachmentUi('#modal-root'); - root.innerHTML = ``; - const close = () => { root.innerHTML = ''; }; - root.querySelector('.modal-close').onclick = close; - root.querySelector('.modal-overlay').onclick = event => { if (event.target.classList.contains('modal-overlay')) close(); }; - const list = selectAttachmentUi('#attachment-list'); - const render = () => { - const text = selectAttachmentUi('#attachment-search').value.trim().toLowerCase(); - const type = selectAttachmentUi('#attachment-type').value; - const shown = attachmentItems.filter(item => (!type || item.kind === type) && - (!text || `${item.filename} ${item.subject} ${item.sender}`.toLowerCase().includes(text))); - list.replaceChildren(); - if (!shown.length) { list.textContent = attachmentItems.length ? 'No attachments match.' : 'No attachments found.'; return; } - shown.forEach(item => { - const row = document.createElement('div'); - row.className = 'attachment-row'; - const info = document.createElement('div'); - info.className = 'attachment-row-info'; - const name = document.createElement('strong'); - name.textContent = item.filename; - const meta = document.createElement('small'); - meta.textContent = [attachmentSize(item.size), item.sender, item.subject, item.folder, item.date].filter(Boolean).join(' · '); - info.append(name, meta); - const preview = document.createElement('button'); - preview.className = 'discard'; - preview.textContent = 'Preview'; - const save = document.createElement('button'); - save.className = 'discard'; - save.textContent = 'Download'; - const panel = document.createElement('div'); - panel.className = 'attachment-preview'; - panel.hidden = true; - const details = { uid: item.uid, folder: item.folder, filename: item.filename }; - preview.onclick = () => { - panel.hidden = !panel.hidden; - if (!panel.hidden && !panel.childElementCount && !panel.textContent) void previewAttachment(panel, details); - }; - save.onclick = () => downloadAttachment(details); - row.append(info, preview, save, panel); - list.append(row); - }); - }; - selectAttachmentUi('#attachment-search').oninput = render; - selectAttachmentUi('#attachment-type').onchange = render; - try { - attachmentItems = await collectAttachments(); - if (selectAttachmentUi('#attachment-list')) render(); - } catch (error) { - if (selectAttachmentUi('#attachment-list')) selectAttachmentUi('#attachment-list').textContent = error.message || 'Could not load attachments.'; - } -} - + const root = selectAttachmentUi('#modal-root'); + root.innerHTML = ``; + const close = () => { root.innerHTML = ''; }; + root.querySelector('.modal-close').onclick = close; + root.querySelector('.modal-overlay').onclick = event => { if (event.target.classList.contains('modal-overlay')) close(); }; + const list = selectAttachmentUi('#attachment-list'); + const render = () => { + const text = selectAttachmentUi('#attachment-search').value.trim().toLowerCase(); + const type = selectAttachmentUi('#attachment-type').value; + const shown = attachmentItems.filter(item => (!type || item.kind === type) && + (!text || `${item.filename} ${item.subject} ${item.sender}`.toLowerCase().includes(text))); + list.replaceChildren(); + if (!shown.length) { list.textContent = attachmentItems.length ? 'No attachments match.' : 'No attachments found.'; return; } + shown.forEach(item => { + const row = document.createElement('div'); + row.className = 'attachment-row'; + const info = document.createElement('div'); + info.className = 'attachment-row-info'; + const name = document.createElement('strong'); + name.textContent = item.filename; + const meta = document.createElement('small'); + meta.textContent = [attachmentSize(item.size), item.sender, item.subject, item.folder, item.date].filter(Boolean).join(' · '); + info.append(name, meta); + const preview = document.createElement('button'); + preview.className = 'discard'; + preview.textContent = 'Preview'; + const save = document.createElement('button'); + save.className = 'discard'; + save.textContent = 'Download'; + const panel = document.createElement('div'); + panel.className = 'attachment-preview'; + panel.hidden = true; + const details = { uid: item.uid, folder: item.folder, filename: item.filename }; + preview.onclick = () => { + panel.hidden = !panel.hidden; + if (!panel.hidden && !panel.childElementCount && !panel.textContent) void previewAttachment(panel, details); + }; + save.onclick = () => downloadAttachment(details); + row.append(info, preview, save, panel); + list.append(row); + }); + }; + selectAttachmentUi('#attachment-search').oninput = render; + selectAttachmentUi('#attachment-type').onchange = render; + try { + attachmentItems = await collectAttachments(); + if (selectAttachmentUi('#attachment-list')) render(); + } catch (error) { + if (selectAttachmentUi('#attachment-list')) selectAttachmentUi('#attachment-list').textContent = error.message || 'Could not load attachments.'; + } +} + document.addEventListener('DOMContentLoaded', () => { selectAttachmentUi('#attachments-nav')?.addEventListener('click', openAttachmentsView); }); diff --git a/branding.css b/branding.css index 2f5021f..ee986aa 100644 --- a/branding.css +++ b/branding.css @@ -1,30 +1,30 @@ -.brand-mark, -body.wasteland .brand-mark, -body.ep-wasteland .brand-mark, -body.ep-daylight .brand-mark { - background: transparent !important; - box-shadow: none !important; - border-radius: 0; -} - -.brand-mark img { - display: block; - width: 35px; - height: 35px; - object-fit: contain; -} - -.settings-select { - flex: 1; - border: 0; - padding: 5px 0; - background: transparent; - color: var(--text); - font: inherit; - text-align: right; -} - -body.ep-wasteland .settings-select, -body.ep-daylight .settings-select { - color-scheme: inherit; -} +.brand-mark, +body.wasteland .brand-mark, +body.ep-wasteland .brand-mark, +body.ep-daylight .brand-mark { + background: transparent !important; + box-shadow: none !important; + border-radius: 0; +} + +.brand-mark img { + display: block; + width: 35px; + height: 35px; + object-fit: contain; +} + +.settings-select { + flex: 1; + border: 0; + padding: 5px 0; + background: transparent; + color: var(--text); + font: inherit; + text-align: right; +} + +body.ep-wasteland .settings-select, +body.ep-daylight .settings-select { + color-scheme: inherit; +} diff --git a/capacitor.config.json b/capacitor.config.json index 0f7ba5a..23bbad6 100644 --- a/capacitor.config.json +++ b/capacitor.config.json @@ -1,8 +1,8 @@ -{ - "appId": "studio.daybreak.mail", - "appName": "ep-mail", - "webDir": "www", - "server": { - "androidScheme": "https" - } -} +{ + "appId": "studio.daybreak.mail", + "appName": "ep-mail", + "webDir": "www", + "server": { + "androidScheme": "https" + } +} diff --git a/dav-ui.js b/dav-ui.js index 9ee18e1..4001322 100644 --- a/dav-ui.js +++ b/dav-ui.js @@ -3,42 +3,42 @@ const davProductivityUi = window.epMailFeatures.productivity; const selectDavUi = davProductivityUi.select; function davTypeName(type){return type==='caldav'?'calendar':'contacts'} -async function syncDav(type, uploadLocal=false){ - try{ - const localOnly=type==='caldav'?davProductivityUi.events.filter(item=>!item._dav):davProductivityUi.contacts.filter(item=>!item._dav); - const result=await window.daybreakMail.davSync(type); - if(type==='caldav'){ - if(uploadLocal)for(const event of localOnly){try{event._dav=await window.daybreakMail.davSaveEvent(event)}catch(error){davProductivityUi.toast(`Could not upload “${event.title}”: ${error.message}`)}} - davProductivityUi.events=[...localOnly,...result.items]; - davProductivityUi.productWrite(davProductivityUi.productKeys.events,davProductivityUi.events);davProductivityUi.renderCalendar();davProductivityUi.toast(`Synced ${result.items.length} calendar events`); - }else{ - if(uploadLocal)for(const contact of localOnly){try{contact._dav=await window.daybreakMail.davSaveContact(contact)}catch(error){davProductivityUi.toast(`Could not upload “${contact.name}”: ${error.message}`)}} - davProductivityUi.contacts=[...localOnly,...result.items]; - davProductivityUi.productWrite(davProductivityUi.productKeys.contacts,davProductivityUi.contacts);davProductivityUi.renderContacts();davProductivityUi.toast(`Synced ${result.items.length} contacts`); - } - }catch(error){davProductivityUi.toast(error.message||`Could not sync ${davTypeName(type)}`)} -} -async function openDavManager(type){ - const root=selectDavUi('#modal-root'),label=type==='caldav'?'CalDAV':'CardDAV'; - try{ - const data=await window.daybreakMail.davList(),accounts=data[type]||[],activeId=data[type==='caldav'?'activeCaldavId':'activeCarddavId']; - const rows=accounts.map(account=>``).join(''); - root.innerHTML=``; - const close=()=>root.innerHTML='';root.querySelectorAll('.modal-close').forEach(button=>button.onclick=close);root.querySelector('.modal-overlay').onclick=event=>{if(event.target.classList.contains('modal-overlay'))close()}; - root.querySelector('#add-dav-server').onclick=()=>showDavConnect(type); - root.onclick=async event=>{ - const activate=event.target.closest('[data-dav-activate]');if(activate){try{await window.daybreakMail.davActivate(type,activate.dataset.davActivate);close();await syncDav(type)}catch(error){davProductivityUi.toast(error.message)}return} - const remove=event.target.closest('[data-dav-remove]');if(remove){if(!confirm(`Remove this ${label} server from ep-mail?`))return;try{const result=await window.daybreakMail.davRemove(type,remove.dataset.davRemove);close();if(result.activeId)await syncDav(type);else if(type==='caldav'){davProductivityUi.events=davProductivityUi.events.filter(item=>!item._dav);davProductivityUi.productWrite(davProductivityUi.productKeys.events,davProductivityUi.events);davProductivityUi.renderCalendar()}else{davProductivityUi.contacts=davProductivityUi.contacts.filter(item=>!item._dav);davProductivityUi.productWrite(davProductivityUi.productKeys.contacts,davProductivityUi.contacts);davProductivityUi.renderContacts()}await openDavManager(type)}catch(error){davProductivityUi.toast(error.message)} } - }; - }catch(error){davProductivityUi.toast(error.message||`Could not load ${label} servers`)} -} -function showDavConnect(type){ - const root=selectDavUi('#modal-root'),label=type==='caldav'?'CalDAV':'CardDAV'; - root.innerHTML=``; - const close=()=>root.innerHTML='';root.querySelector('.modal-close').onclick=close;root.querySelector('.modal-overlay').onclick=event=>{if(event.target.classList.contains('modal-overlay'))close()};root.querySelector('#dav-cancel').onclick=close; - root.querySelector('#dav-connect').onclick=async()=>{const button=root.querySelector('#dav-connect'),status=root.querySelector('#dav-status');button.disabled=true;status.textContent='Checking the server and discovering collections…';try{await window.daybreakMail.davConnect({type,serverUrl:root.querySelector('#dav-server-url').value,username:root.querySelector('#dav-username').value,password:root.querySelector('#dav-password').value});close();davProductivityUi.toast(`${label} server connected`);await syncDav(type,true)}catch(error){status.textContent=error.message||`Could not connect to ${label}`;button.disabled=false}}; - root.querySelector('#dav-server-url').focus(); -} +async function syncDav(type, uploadLocal=false){ + try{ + const localOnly=type==='caldav'?davProductivityUi.events.filter(item=>!item._dav):davProductivityUi.contacts.filter(item=>!item._dav); + const result=await window.daybreakMail.davSync(type); + if(type==='caldav'){ + if(uploadLocal)for(const event of localOnly){try{event._dav=await window.daybreakMail.davSaveEvent(event)}catch(error){davProductivityUi.toast(`Could not upload “${event.title}”: ${error.message}`)}} + davProductivityUi.events=[...localOnly,...result.items]; + davProductivityUi.productWrite(davProductivityUi.productKeys.events,davProductivityUi.events);davProductivityUi.renderCalendar();davProductivityUi.toast(`Synced ${result.items.length} calendar events`); + }else{ + if(uploadLocal)for(const contact of localOnly){try{contact._dav=await window.daybreakMail.davSaveContact(contact)}catch(error){davProductivityUi.toast(`Could not upload “${contact.name}”: ${error.message}`)}} + davProductivityUi.contacts=[...localOnly,...result.items]; + davProductivityUi.productWrite(davProductivityUi.productKeys.contacts,davProductivityUi.contacts);davProductivityUi.renderContacts();davProductivityUi.toast(`Synced ${result.items.length} contacts`); + } + }catch(error){davProductivityUi.toast(error.message||`Could not sync ${davTypeName(type)}`)} +} +async function openDavManager(type){ + const root=selectDavUi('#modal-root'),label=type==='caldav'?'CalDAV':'CardDAV'; + try{ + const data=await window.daybreakMail.davList(),accounts=data[type]||[],activeId=data[type==='caldav'?'activeCaldavId':'activeCarddavId']; + const rows=accounts.map(account=>``).join(''); + root.innerHTML=``; + const close=()=>root.innerHTML='';root.querySelectorAll('.modal-close').forEach(button=>button.onclick=close);root.querySelector('.modal-overlay').onclick=event=>{if(event.target.classList.contains('modal-overlay'))close()}; + root.querySelector('#add-dav-server').onclick=()=>showDavConnect(type); + root.onclick=async event=>{ + const activate=event.target.closest('[data-dav-activate]');if(activate){try{await window.daybreakMail.davActivate(type,activate.dataset.davActivate);close();await syncDav(type)}catch(error){davProductivityUi.toast(error.message)}return} + const remove=event.target.closest('[data-dav-remove]');if(remove){if(!confirm(`Remove this ${label} server from ep-mail?`))return;try{const result=await window.daybreakMail.davRemove(type,remove.dataset.davRemove);close();if(result.activeId)await syncDav(type);else if(type==='caldav'){davProductivityUi.events=davProductivityUi.events.filter(item=>!item._dav);davProductivityUi.productWrite(davProductivityUi.productKeys.events,davProductivityUi.events);davProductivityUi.renderCalendar()}else{davProductivityUi.contacts=davProductivityUi.contacts.filter(item=>!item._dav);davProductivityUi.productWrite(davProductivityUi.productKeys.contacts,davProductivityUi.contacts);davProductivityUi.renderContacts()}await openDavManager(type)}catch(error){davProductivityUi.toast(error.message)} } + }; + }catch(error){davProductivityUi.toast(error.message||`Could not load ${label} servers`)} +} +function showDavConnect(type){ + const root=selectDavUi('#modal-root'),label=type==='caldav'?'CalDAV':'CardDAV'; + root.innerHTML=``; + const close=()=>root.innerHTML='';root.querySelector('.modal-close').onclick=close;root.querySelector('.modal-overlay').onclick=event=>{if(event.target.classList.contains('modal-overlay'))close()};root.querySelector('#dav-cancel').onclick=close; + root.querySelector('#dav-connect').onclick=async()=>{const button=root.querySelector('#dav-connect'),status=root.querySelector('#dav-status');button.disabled=true;status.textContent='Checking the server and discovering collections…';try{await window.daybreakMail.davConnect({type,serverUrl:root.querySelector('#dav-server-url').value,username:root.querySelector('#dav-username').value,password:root.querySelector('#dav-password').value});close();davProductivityUi.toast(`${label} server connected`);await syncDav(type,true)}catch(error){status.textContent=error.message||`Could not connect to ${label}`;button.disabled=false}}; + root.querySelector('#dav-server-url').focus(); +} document.addEventListener('click',event=>{const button=event.target.closest('#caldav-sync,#carddav-sync');if(!button)return;event.preventDefault();event.stopImmediatePropagation();syncDav(button.id.startsWith('caldav')?'caldav':'carddav')},true); window.epMailFeatures.dav = Object.freeze({ diff --git a/desktop/ipc/mail.cjs b/desktop/ipc/mail.cjs index 502a63a..49b73ca 100644 --- a/desktop/ipc/mail.cjs +++ b/desktop/ipc/mail.cjs @@ -41,43 +41,43 @@ function registerMailIpcHandlers(dependencies) { pgpFailure } = dependencies; -registerIpcHandler('mail:get-account', async () => { - const account = await readAccount(); - return account ? publicAccount(account) : null; -}); - +registerIpcHandler('mail:get-account', async () => { + const account = await readAccount(); + return account ? publicAccount(account) : null; +}); + registerIpcHandler('mail:list-accounts', async () => { const store = (await readAccountStore()) || { accounts: [], activeId: null }; return { accounts: store.accounts.map(publicAccount), activeId: store.activeId }; }); registerIpcHandler('mail:list-oauth-providers', async () => listOAuthProviders()); - -registerIpcHandler('mail:select-account', async (_event, accountId) => { - const account = await updateAccountStore(store => { - const selected = store.accounts.find(item => item.id === accountId); - if (!selected) throw new Error('That mail account is no longer available.'); - store.activeId = selected.id; - return selected; - }); - requestBackgroundSync(); - return publicAccount(account); -}); - -registerIpcHandler('mail:remove-account', async (_event, accountId) => { - const result = await updateAccountStore(store => { - store.accounts = store.accounts.filter(account => account.id !== accountId); - if (store.activeId === accountId) store.activeId = store.accounts[0]?.id || null; - return { accounts: store.accounts.map(publicAccount), activeId: store.activeId }; - }); - requestBackgroundSync(accountId); - requestBackgroundSync(); - return result; -}); - -registerIpcHandler('mail:update-account', async (_event, accountId, input) => { - const existing = await readAccount(accountId); - if (!existing) throw new Error('That mail account is no longer available.'); + +registerIpcHandler('mail:select-account', async (_event, accountId) => { + const account = await updateAccountStore(store => { + const selected = store.accounts.find(item => item.id === accountId); + if (!selected) throw new Error('That mail account is no longer available.'); + store.activeId = selected.id; + return selected; + }); + requestBackgroundSync(); + return publicAccount(account); +}); + +registerIpcHandler('mail:remove-account', async (_event, accountId) => { + const result = await updateAccountStore(store => { + store.accounts = store.accounts.filter(account => account.id !== accountId); + if (store.activeId === accountId) store.activeId = store.accounts[0]?.id || null; + return { accounts: store.accounts.map(publicAccount), activeId: store.activeId }; + }); + requestBackgroundSync(accountId); + requestBackgroundSync(); + return result; +}); + +registerIpcHandler('mail:update-account', async (_event, accountId, input) => { + const existing = await readAccount(accountId); + if (!existing) throw new Error('That mail account is no longer available.'); let account = normalizeAccount({ ...existing, ...input, @@ -95,190 +95,190 @@ registerIpcHandler('mail:update-account', async (_event, accountId, input) => { account.id = existing.id; } } - try { - const status = await connectMail(account); - const savedAccount = await updateAccountStore(store => { - const current = store.accounts.find(item => item.id === existing.id); - if (!current) throw new Error('That mail account is no longer available.'); - const endpointChanged = current.email !== account.email || current.imapHost !== account.imapHost; - store.accounts = store.accounts.map(item => item.id === existing.id - ? { - ...account, - syncState: endpointChanged ? undefined : current.syncState, - snoozedMessages: endpointChanged ? [] : (current.snoozedMessages || []), - ruleLabels: endpointChanged ? {} : (current.ruleLabels || {}) - } - : item); - return store.accounts.find(item => item.id === existing.id); - }); - requestBackgroundSync(existing.id); - return { ...publicAccount(savedAccount), ...status }; - } catch (error) { - throw new Error(`Could not update the mailbox: ${error.message}`); - } -}); - + try { + const status = await connectMail(account); + const savedAccount = await updateAccountStore(store => { + const current = store.accounts.find(item => item.id === existing.id); + if (!current) throw new Error('That mail account is no longer available.'); + const endpointChanged = current.email !== account.email || current.imapHost !== account.imapHost; + store.accounts = store.accounts.map(item => item.id === existing.id + ? { + ...account, + syncState: endpointChanged ? undefined : current.syncState, + snoozedMessages: endpointChanged ? [] : (current.snoozedMessages || []), + ruleLabels: endpointChanged ? {} : (current.ruleLabels || {}) + } + : item); + return store.accounts.find(item => item.id === existing.id); + }); + requestBackgroundSync(existing.id); + return { ...publicAccount(savedAccount), ...status }; + } catch (error) { + throw new Error(`Could not update the mailbox: ${error.message}`); + } +}); + registerIpcHandler('mail:connect', async (_event, input) => { let account = normalizeAccount(input); try { if (account.authMethod === 'oauth2') account = await authorizeOAuthAccount(account); const status = await connectMail(account); - const saved = await saveAccount(account); - requestBackgroundSync(saved.id); - return { ok: true, ...publicAccount(saved), ...status }; - } catch (error) { - throw new Error(`Could not connect to the mailbox: ${error.message}`); - } -}); - -registerIpcHandler('mail:sync-folder', async (_event, requestedFolder, offset = 0, filters = {}) => { - const account = await readAccount(); - if (!account) throw new Error('Add a mail account before syncing.'); - const allowedFolders = new Set(['Inbox', 'Sent', 'Archive', 'Trash', 'Starred', 'Snoozed']); - const selectedFolder = allowedFolders.has(filters.folder) ? filters.folder : requestedFolder; - const folder = allowedFolders.has(selectedFolder) || String(selectedFolder).startsWith(CUSTOM_FOLDER_PREFIX) - ? selectedFolder : 'Inbox'; - const { folder: _filterFolder, ...criteria } = filters; - try { - await flushMailOutbox(account); - return await fetchMailbox(account, folder, offset, 20, criteria); - } catch (error) { - if (!isConnectivityFailure(error)) throw error; - const cached = cachedMailbox(account, folder, offset, 20, criteria); - if (!cached.total) throw error; - return cached; - } -}); - -registerIpcHandler('mail:list-folders', async () => { - const account = await readAccount(); - if (!account) throw new Error('Add a mail account before listing folders.'); + const saved = await saveAccount(account); + requestBackgroundSync(saved.id); + return { ok: true, ...publicAccount(saved), ...status }; + } catch (error) { + throw new Error(`Could not connect to the mailbox: ${error.message}`); + } +}); + +registerIpcHandler('mail:sync-folder', async (_event, requestedFolder, offset = 0, filters = {}) => { + const account = await readAccount(); + if (!account) throw new Error('Add a mail account before syncing.'); + const allowedFolders = new Set(['Inbox', 'Sent', 'Archive', 'Trash', 'Starred', 'Snoozed']); + const selectedFolder = allowedFolders.has(filters.folder) ? filters.folder : requestedFolder; + const folder = allowedFolders.has(selectedFolder) || String(selectedFolder).startsWith(CUSTOM_FOLDER_PREFIX) + ? selectedFolder : 'Inbox'; + const { folder: _filterFolder, ...criteria } = filters; + try { + await flushMailOutbox(account); + return await fetchMailbox(account, folder, offset, 20, criteria); + } catch (error) { + if (!isConnectivityFailure(error)) throw error; + const cached = cachedMailbox(account, folder, offset, 20, criteria); + if (!cached.total) throw error; + return cached; + } +}); + +registerIpcHandler('mail:list-folders', async () => { + const account = await readAccount(); + if (!account) throw new Error('Add a mail account before listing folders.'); const client = await imapClient(account); - try { - await client.connect(); - return { folders: await listCustomFolders(client) }; - } catch (error) { - if (isConnectivityFailure(error)) return { folders: [], offline: true }; - throw error; - } finally { - if (client.usable) await client.logout().catch(() => {}); - } -}); - -registerIpcHandler('mail:create-folder', async (_event, input) => { - const account = await readAccount(); - if (!account) throw new Error('Add a mail account before creating folders.'); - const name = validFolderName(input?.name); + try { + await client.connect(); + return { folders: await listCustomFolders(client) }; + } catch (error) { + if (isConnectivityFailure(error)) return { folders: [], offline: true }; + throw error; + } finally { + if (client.usable) await client.logout().catch(() => {}); + } +}); + +registerIpcHandler('mail:create-folder', async (_event, input) => { + const account = await readAccount(); + if (!account) throw new Error('Add a mail account before creating folders.'); + const name = validFolderName(input?.name); const client = await imapClient(account); - try { - await client.connect(); - const existing = await client.list(); - if (existing.some(mailbox => mailbox.path.toLowerCase() === name.toLowerCase())) { - throw new Error('A folder with that name already exists.'); - } - const created = await client.mailboxCreate(name); - await client.mailboxSubscribe(created.path).catch(() => {}); - return { ok: true, folder: { name, path: created.path, id: CUSTOM_FOLDER_PREFIX + created.path }, folders: await listCustomFolders(client) }; - } catch (error) { - if (error.message === 'A folder with that name already exists.') throw error; - throw new Error(`Could not create the folder: ${error.message}`); - } finally { - if (client.usable) await client.logout().catch(() => {}); - } -}); - -registerIpcHandler('mail:list-drafts', async () => { - const account = await readAccount(); - if (!account) throw new Error('Add a mail account before opening drafts.'); - return { drafts: account.drafts || [], offline: true }; -}); - -registerIpcHandler('mail:save-draft', async (_event, input) => { - const account = await readAccount(); - if (!account) throw new Error('Add a mail account before saving drafts.'); - const draft = { - id: String(input?.id || randomUUID()), - to: String(input?.to || '').slice(0, 4000), - cc: String(input?.cc || '').slice(0, 4000), - subject: String(input?.subject || '').slice(0, 998), - text: String(input?.text || '').slice(0, 500000), - attachments: serializeOutgoingAttachments(normalizeOutgoingAttachments(input?.attachments)), - updatedAt: Date.now() - }; - await updateAccountStore(store => { - const saved = store.accounts.find(item => item.id === account.id); - if (!saved) throw new Error('That mail account is no longer available.'); - const drafts = saved.drafts || []; - saved.drafts = [draft, ...drafts.filter(item => item.id !== draft.id)].slice(0, 500); - }); - return draft; -}); - -registerIpcHandler('mail:delete-draft', async (_event, id) => { - const account = await readAccount(); - if (!account) throw new Error('Add a mail account before deleting drafts.'); - await updateAccountStore(store => { - const saved = store.accounts.find(item => item.id === account.id); - if (saved) saved.drafts = (saved.drafts || []).filter(draft => draft.id !== id); - }); - return { ok: true }; -}); - -registerIpcHandler('mail:set-snooze', async (_event, input) => { - const account = await readAccount(); - if (!account) throw new Error('Add a mail account before setting a reminder.'); - const uid = Number(input?.uid); - const folder = String(input?.sourceFolder || input?.folder || 'Inbox'); - if (!Number.isInteger(uid) || uid < 1) throw new Error('That message could not be identified.'); - if (!['Inbox', 'Sent', 'Archive', 'Trash'].includes(folder)) throw new Error('That mailbox cannot be snoozed.'); - const dueAt = input?.dueAt == null ? null : Number(input.dueAt); - if (dueAt != null && (!Number.isFinite(dueAt) || dueAt <= Date.now())) { - throw new Error('Choose a reminder time in the future.'); - } - await updateAccountStore(store => { - const saved = store.accounts.find(item => item.id === account.id); - if (!saved) throw new Error('That mail account is no longer available.'); - const snoozes = saved.snoozedMessages || []; - const remaining = snoozes.filter(item => !(Number(item.uid) === uid && item.folder === folder)); - if (dueAt != null) { - remaining.push({ - uid, - folder, - dueAt, - subject: String(input.subject || '').slice(0, 200) - }); - } - saved.snoozedMessages = remaining; - }); - sendMailSyncUpdate({ - accountId: account.id, - foldersChanged: ['Snoozed', folder] - }); - return { ok: true, snoozed: dueAt != null }; -}); - + try { + await client.connect(); + const existing = await client.list(); + if (existing.some(mailbox => mailbox.path.toLowerCase() === name.toLowerCase())) { + throw new Error('A folder with that name already exists.'); + } + const created = await client.mailboxCreate(name); + await client.mailboxSubscribe(created.path).catch(() => {}); + return { ok: true, folder: { name, path: created.path, id: CUSTOM_FOLDER_PREFIX + created.path }, folders: await listCustomFolders(client) }; + } catch (error) { + if (error.message === 'A folder with that name already exists.') throw error; + throw new Error(`Could not create the folder: ${error.message}`); + } finally { + if (client.usable) await client.logout().catch(() => {}); + } +}); + +registerIpcHandler('mail:list-drafts', async () => { + const account = await readAccount(); + if (!account) throw new Error('Add a mail account before opening drafts.'); + return { drafts: account.drafts || [], offline: true }; +}); + +registerIpcHandler('mail:save-draft', async (_event, input) => { + const account = await readAccount(); + if (!account) throw new Error('Add a mail account before saving drafts.'); + const draft = { + id: String(input?.id || randomUUID()), + to: String(input?.to || '').slice(0, 4000), + cc: String(input?.cc || '').slice(0, 4000), + subject: String(input?.subject || '').slice(0, 998), + text: String(input?.text || '').slice(0, 500000), + attachments: serializeOutgoingAttachments(normalizeOutgoingAttachments(input?.attachments)), + updatedAt: Date.now() + }; + await updateAccountStore(store => { + const saved = store.accounts.find(item => item.id === account.id); + if (!saved) throw new Error('That mail account is no longer available.'); + const drafts = saved.drafts || []; + saved.drafts = [draft, ...drafts.filter(item => item.id !== draft.id)].slice(0, 500); + }); + return draft; +}); + +registerIpcHandler('mail:delete-draft', async (_event, id) => { + const account = await readAccount(); + if (!account) throw new Error('Add a mail account before deleting drafts.'); + await updateAccountStore(store => { + const saved = store.accounts.find(item => item.id === account.id); + if (saved) saved.drafts = (saved.drafts || []).filter(draft => draft.id !== id); + }); + return { ok: true }; +}); + +registerIpcHandler('mail:set-snooze', async (_event, input) => { + const account = await readAccount(); + if (!account) throw new Error('Add a mail account before setting a reminder.'); + const uid = Number(input?.uid); + const folder = String(input?.sourceFolder || input?.folder || 'Inbox'); + if (!Number.isInteger(uid) || uid < 1) throw new Error('That message could not be identified.'); + if (!['Inbox', 'Sent', 'Archive', 'Trash'].includes(folder)) throw new Error('That mailbox cannot be snoozed.'); + const dueAt = input?.dueAt == null ? null : Number(input.dueAt); + if (dueAt != null && (!Number.isFinite(dueAt) || dueAt <= Date.now())) { + throw new Error('Choose a reminder time in the future.'); + } + await updateAccountStore(store => { + const saved = store.accounts.find(item => item.id === account.id); + if (!saved) throw new Error('That mail account is no longer available.'); + const snoozes = saved.snoozedMessages || []; + const remaining = snoozes.filter(item => !(Number(item.uid) === uid && item.folder === folder)); + if (dueAt != null) { + remaining.push({ + uid, + folder, + dueAt, + subject: String(input.subject || '').slice(0, 200) + }); + } + saved.snoozedMessages = remaining; + }); + sendMailSyncUpdate({ + accountId: account.id, + foldersChanged: ['Snoozed', folder] + }); + return { ok: true, snoozed: dueAt != null }; +}); + registerIpcHandler('mail:update-message', async (_event, input) => { - const account = await readAccount(); - if (!account) throw new Error('Add a mail account before changing messages.'); - try { - return await applyMessageAction(account, input); - } catch (error) { - if (!isConnectivityFailure(error)) throw error; + const account = await readAccount(); + if (!account) throw new Error('Add a mail account before changing messages.'); + try { + return await applyMessageAction(account, input); + } catch (error) { + if (!isConnectivityFailure(error)) throw error; return mailOutbox.queueMessageAction(account, input); - } -}); - -// Encrypted messages keep their attachments inside the encrypted payload. + } +}); + +// Encrypted messages keep their attachments inside the encrypted payload. async function parseForAttachments(source) { - const { simpleParser } = await getMailparser(); - const parsed = await simpleParser(source); - const kind = pgpMail.detect(parsed); - if (kind !== 'encrypted-mime' && kind !== 'encrypted-inline') return parsed; - try { - return (await pgpMail.decrypt(parsed)).parsed; - } catch (error) { - if (error instanceof PgpError) throw new Error(error.code === 'PASSPHRASE_REQUIRED' ? 'Open the message and unlock it before using its attachments.' : error.message); - throw error; + const { simpleParser } = await getMailparser(); + const parsed = await simpleParser(source); + const kind = pgpMail.detect(parsed); + if (kind !== 'encrypted-mime' && kind !== 'encrypted-inline') return parsed; + try { + return (await pgpMail.decrypt(parsed)).parsed; + } catch (error) { + if (error instanceof PgpError) throw new Error(error.code === 'PASSPHRASE_REQUIRED' ? 'Open the message and unlock it before using its attachments.' : error.message); + throw error; } } const attachmentService = createAttachmentService({ imapClient, folderPath, parseForAttachments }); @@ -295,34 +295,34 @@ registerIpcHandler('mail:preview-attachment', async (_event, input) => { if (!account) throw new Error('Add a mail account before previewing attachments.'); return attachmentService.previewAttachment(account, input); }); + - -registerIpcHandler('mail:open-external', async (event, rawUrl) => { - let target; - try { - target = new URL(String(rawUrl || '')); - } catch { - throw new Error('This link is not a valid web address.'); - } - if (!['http:', 'https:'].includes(target.protocol) || target.username || target.password) { - throw new Error('Only standard web links can be opened from mail.'); - } - const parent = BrowserWindow.fromWebContents(event.sender); - const confirmation = await dialog.showMessageBox(parent, { - type: 'warning', - title: 'Open external link?', - message: 'Email links can lead to fake sign-in pages or harmful content.', - detail: `Check the full address before continuing:\n${target.href}`, - buttons: ['Cancel', 'Open link'], - defaultId: 0, - cancelId: 0, - noLink: true - }); - if (confirmation.response !== 1) return { opened: false }; - await shell.openExternal(target.href); - return { opened: true }; -}); - +registerIpcHandler('mail:open-external', async (event, rawUrl) => { + let target; + try { + target = new URL(String(rawUrl || '')); + } catch { + throw new Error('This link is not a valid web address.'); + } + if (!['http:', 'https:'].includes(target.protocol) || target.username || target.password) { + throw new Error('Only standard web links can be opened from mail.'); + } + const parent = BrowserWindow.fromWebContents(event.sender); + const confirmation = await dialog.showMessageBox(parent, { + type: 'warning', + title: 'Open external link?', + message: 'Email links can lead to fake sign-in pages or harmful content.', + detail: `Check the full address before continuing:\n${target.href}`, + buttons: ['Cancel', 'Open link'], + defaultId: 0, + cancelId: 0, + noLink: true + }); + if (confirmation.response !== 1) return { opened: false }; + await shell.openExternal(target.href); + return { opened: true }; +}); + registerIpcHandler('mail:sync-inbox', async () => { const account = await readAccount(); if (!account) throw new Error('Add a mail account before syncing.'); @@ -343,83 +343,83 @@ registerIpcHandler('mail:send', async (event, message) => { messageId: message.messageId || `<${randomUUID()}@ep-mail.local>`, attachments: message.attachments }; - const attachments = normalizeOutgoingAttachments(message?.attachments); - queuedMessage.attachments = serializeOutgoingAttachments(attachments); - delete queuedMessage.pgp; - if (!pgpOptions?.encrypt) { - const recipients = [queuedMessage.to, queuedMessage.cc].filter(Boolean); - const status = await pgpMail.recipientStatus(recipients, { sign: Boolean(pgpOptions?.sign), from: account.email }); - if (status.recipients.length && !status.missing.length) { - const { response } = await dialog.showMessageBox(BrowserWindow.fromWebContents(event.sender), { - type: 'warning', - buttons: ['Cancel', 'Send anyway'], - defaultId: 0, - cancelId: 0, - title: 'Send without encryption?', - message: 'Public keys are available for all recipients.', - detail: 'This message is about to be sent without encryption. Continue only if you explicitly want to send it in plaintext.', - noLink: true - }); - if (response !== 1) throw new Error('Plaintext send cancelled.'); - } - } - if (pgpOptions) { - // Encrypt before sending or queueing so plaintext and passphrases are never stored in the outbox. - const signature = String(account.signature || '').slice(0, 5000); - const body = String(queuedMessage.text || '').slice(0, 500000); - const fromName = String(account.displayName || queuedMessage.displayName || account.email).replace(/[\r\n]+/g, ' ').trim().slice(0, 80) || account.email; - try { - const built = await pgpMail.build({ - from: { name: fromName, address: account.email }, - to: queuedMessage.to, - cc: queuedMessage.cc, - subject: String(queuedMessage.subject || '(no subject)').slice(0, 998), - text: signature ? `${body}${body.trim() ? '\n\n' : ''}${signature}`.slice(0, 505000) : body, - messageId: queuedMessage.messageId, - encrypt: Boolean(pgpOptions.encrypt), - sign: Boolean(pgpOptions.sign), - passphrase: typeof pgpOptions.passphrase === 'string' && pgpOptions.passphrase ? pgpOptions.passphrase : null, - attachments: attachments.map(({ filename, contentType, content }) => ({ filename, contentType, content })) - }); - queuedMessage.rawBase64 = built.raw.toString('base64'); - queuedMessage.envelope = built.envelope; - queuedMessage.text = ''; - queuedMessage.attachments = []; - } catch (error) { - if (error instanceof PgpError) return pgpFailure(error); - throw error; - } - } - try { - return await sendMailNow(account, queuedMessage); - } catch (error) { - if (!isConnectivityFailure(error)) throw error; - await updateAccountStore(store => { - const saved = store.accounts.find(item => item.id === account.id); - if (!saved) throw new Error('That mail account is no longer available.'); - saved.mailOutbox = saved.mailOutbox || []; - saved.mailOutbox.push({ id: randomUUID(), type: 'send', data: queuedMessage, createdAt: Date.now() }); - }); - return { ok: true, queued: true }; - } -}); - -registerIpcHandler('mail:disconnect', async (_event, accountId) => { - const store = await readAccountStore(); - if (!store) return { accounts: [], activeId: null }; - if (accountId) { - store.accounts = store.accounts.filter(account => account.id !== accountId); - } else { - store.accounts = []; - } - if (!store.accounts.length) await fs.rm(credentialsPath(), { force: true }); - else { - if (!store.accounts.some(account => account.id === store.activeId)) store.activeId = store.accounts[0].id; - await saveAccountStore(store); - } - return { accounts: store.accounts.map(publicAccount), activeId: store.activeId }; -}); - + const attachments = normalizeOutgoingAttachments(message?.attachments); + queuedMessage.attachments = serializeOutgoingAttachments(attachments); + delete queuedMessage.pgp; + if (!pgpOptions?.encrypt) { + const recipients = [queuedMessage.to, queuedMessage.cc].filter(Boolean); + const status = await pgpMail.recipientStatus(recipients, { sign: Boolean(pgpOptions?.sign), from: account.email }); + if (status.recipients.length && !status.missing.length) { + const { response } = await dialog.showMessageBox(BrowserWindow.fromWebContents(event.sender), { + type: 'warning', + buttons: ['Cancel', 'Send anyway'], + defaultId: 0, + cancelId: 0, + title: 'Send without encryption?', + message: 'Public keys are available for all recipients.', + detail: 'This message is about to be sent without encryption. Continue only if you explicitly want to send it in plaintext.', + noLink: true + }); + if (response !== 1) throw new Error('Plaintext send cancelled.'); + } + } + if (pgpOptions) { + // Encrypt before sending or queueing so plaintext and passphrases are never stored in the outbox. + const signature = String(account.signature || '').slice(0, 5000); + const body = String(queuedMessage.text || '').slice(0, 500000); + const fromName = String(account.displayName || queuedMessage.displayName || account.email).replace(/[\r\n]+/g, ' ').trim().slice(0, 80) || account.email; + try { + const built = await pgpMail.build({ + from: { name: fromName, address: account.email }, + to: queuedMessage.to, + cc: queuedMessage.cc, + subject: String(queuedMessage.subject || '(no subject)').slice(0, 998), + text: signature ? `${body}${body.trim() ? '\n\n' : ''}${signature}`.slice(0, 505000) : body, + messageId: queuedMessage.messageId, + encrypt: Boolean(pgpOptions.encrypt), + sign: Boolean(pgpOptions.sign), + passphrase: typeof pgpOptions.passphrase === 'string' && pgpOptions.passphrase ? pgpOptions.passphrase : null, + attachments: attachments.map(({ filename, contentType, content }) => ({ filename, contentType, content })) + }); + queuedMessage.rawBase64 = built.raw.toString('base64'); + queuedMessage.envelope = built.envelope; + queuedMessage.text = ''; + queuedMessage.attachments = []; + } catch (error) { + if (error instanceof PgpError) return pgpFailure(error); + throw error; + } + } + try { + return await sendMailNow(account, queuedMessage); + } catch (error) { + if (!isConnectivityFailure(error)) throw error; + await updateAccountStore(store => { + const saved = store.accounts.find(item => item.id === account.id); + if (!saved) throw new Error('That mail account is no longer available.'); + saved.mailOutbox = saved.mailOutbox || []; + saved.mailOutbox.push({ id: randomUUID(), type: 'send', data: queuedMessage, createdAt: Date.now() }); + }); + return { ok: true, queued: true }; + } +}); + +registerIpcHandler('mail:disconnect', async (_event, accountId) => { + const store = await readAccountStore(); + if (!store) return { accounts: [], activeId: null }; + if (accountId) { + store.accounts = store.accounts.filter(account => account.id !== accountId); + } else { + store.accounts = []; + } + if (!store.accounts.length) await fs.rm(credentialsPath(), { force: true }); + else { + if (!store.accounts.some(account => account.id === store.activeId)) store.activeId = store.accounts[0].id; + await saveAccountStore(store); + } + return { accounts: store.accounts.map(publicAccount), activeId: store.activeId }; +}); + } diff --git a/desktop/mail-attachments.cjs b/desktop/mail-attachments.cjs index 2f3e8f6..e015936 100644 --- a/desktop/mail-attachments.cjs +++ b/desktop/mail-attachments.cjs @@ -1,30 +1,30 @@ -const path = require('node:path'); - -function normalizeOutgoingAttachments(value) { - if (value === undefined) return []; - if (!Array.isArray(value)) throw new Error('The attachment list is invalid.'); - return value.map(file => { - if (!file || typeof file !== 'object' || typeof file.contentBase64 !== 'string') { - throw new Error('An attachment could not be read.'); - } - const filename = path.basename(String(file.filename || 'attachment').replace(/\\/g, '/')) - .replace(/[\r\n\0]/g, '') - .slice(0, 255) || 'attachment'; - const contentType = String(file.contentType || 'application/octet-stream').trim().toLowerCase(); - if (!/^[a-z0-9!#$&^_.+-]+\/[a-z0-9!#$&^_.+-]+$/.test(contentType)) { - throw new Error(`The content type for ${filename} is invalid.`); - } - const encoded = file.contentBase64; - if (encoded.length % 4 !== 0 || !/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(encoded)) { - throw new Error(`The contents of ${filename} are invalid.`); - } - const content = Buffer.from(encoded, 'base64'); - return { filename, contentType, contentBase64: encoded, size: content.length, content }; - }); -} - -function serializeOutgoingAttachments(attachments) { - return attachments.map(({ content, ...file }) => file); -} - -module.exports = { normalizeOutgoingAttachments, serializeOutgoingAttachments }; +const path = require('node:path'); + +function normalizeOutgoingAttachments(value) { + if (value === undefined) return []; + if (!Array.isArray(value)) throw new Error('The attachment list is invalid.'); + return value.map(file => { + if (!file || typeof file !== 'object' || typeof file.contentBase64 !== 'string') { + throw new Error('An attachment could not be read.'); + } + const filename = path.basename(String(file.filename || 'attachment').replace(/\\/g, '/')) + .replace(/[\r\n\0]/g, '') + .slice(0, 255) || 'attachment'; + const contentType = String(file.contentType || 'application/octet-stream').trim().toLowerCase(); + if (!/^[a-z0-9!#$&^_.+-]+\/[a-z0-9!#$&^_.+-]+$/.test(contentType)) { + throw new Error(`The content type for ${filename} is invalid.`); + } + const encoded = file.contentBase64; + if (encoded.length % 4 !== 0 || !/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(encoded)) { + throw new Error(`The contents of ${filename} are invalid.`); + } + const content = Buffer.from(encoded, 'base64'); + return { filename, contentType, contentBase64: encoded, size: content.length, content }; + }); +} + +function serializeOutgoingAttachments(attachments) { + return attachments.map(({ content, ...file }) => file); +} + +module.exports = { normalizeOutgoingAttachments, serializeOutgoingAttachments }; diff --git a/desktop/main.cjs b/desktop/main.cjs index d7dced2..322213d 100644 --- a/desktop/main.cjs +++ b/desktop/main.cjs @@ -10,47 +10,47 @@ function traceStartup(message) { traceStartup('main process entered'); const { app, BrowserWindow, shell, ipcMain, safeStorage, dialog, Notification, powerMonitor, Menu, Tray, nativeImage } = require('electron'); -const fsSync = require('node:fs'); -const path = require('node:path'); -const fs = require('node:fs/promises'); -const { randomUUID } = require('node:crypto'); - -let tsdavPromise = null; -function getTsdav() { - if (!tsdavPromise) tsdavPromise = import('tsdav'); - return tsdavPromise; -} - -let icalPromise = null; -function getICAL() { - if (!icalPromise) icalPromise = import('ical.js'); - return icalPromise; -} - -let openpgpPromise = null; -function getOpenPGP() { - if (!openpgpPromise) openpgpPromise = import('openpgp'); - return openpgpPromise; -} - -let imapFlowPromise = null; -function getImapFlow() { - if (!imapFlowPromise) imapFlowPromise = import('imapflow'); - return imapFlowPromise; -} - -let nodemailerPromise = null; -function getNodemailer() { - if (!nodemailerPromise) nodemailerPromise = import('nodemailer'); - return nodemailerPromise; -} - -let mailparserPromise = null; -function getMailparser() { - if (!mailparserPromise) mailparserPromise = import('mailparser'); - return mailparserPromise; -} - +const fsSync = require('node:fs'); +const path = require('node:path'); +const fs = require('node:fs/promises'); +const { randomUUID } = require('node:crypto'); + +let tsdavPromise = null; +function getTsdav() { + if (!tsdavPromise) tsdavPromise = import('tsdav'); + return tsdavPromise; +} + +let icalPromise = null; +function getICAL() { + if (!icalPromise) icalPromise = import('ical.js'); + return icalPromise; +} + +let openpgpPromise = null; +function getOpenPGP() { + if (!openpgpPromise) openpgpPromise = import('openpgp'); + return openpgpPromise; +} + +let imapFlowPromise = null; +function getImapFlow() { + if (!imapFlowPromise) imapFlowPromise = import('imapflow'); + return imapFlowPromise; +} + +let nodemailerPromise = null; +function getNodemailer() { + if (!nodemailerPromise) nodemailerPromise = import('nodemailer'); + return nodemailerPromise; +} + +let mailparserPromise = null; +function getMailparser() { + if (!mailparserPromise) mailparserPromise = import('mailparser'); + return mailparserPromise; +} + const { createKeyServerService, listServers, MAX_CUSTOM_SERVERS, normalizeCustomServer } = require('./pgp-keyservers.cjs'); const { normalizeOutgoingAttachments, serializeOutgoingAttachments } = require('./mail-attachments.cjs'); const { @@ -109,11 +109,11 @@ const pgpJsonStore = createSecureJsonStore({ assertSecureStorage, unavailableMessage: 'Secure key storage is unavailable.' }); -const backgroundSyncIntervalMs = 30 * 1000; -const backgroundRetryIntervalMs = 2 * 60 * 1000; -const backgroundSyncConcurrency = 2; -const backgroundIdleConcurrency = 2; -const snoozeCheckIntervalMs = 30 * 1000; +const backgroundSyncIntervalMs = 30 * 1000; +const backgroundRetryIntervalMs = 2 * 60 * 1000; +const backgroundSyncConcurrency = 2; +const backgroundIdleConcurrency = 2; +const snoozeCheckIntervalMs = 30 * 1000; const windowsAppUserModelId = 'studio.daybreak.mail'; const applicationHtmlPath = path.join(__dirname, '..', 'index.html'); const ipcMainHandle = ipcMain.handle.bind(ipcMain); @@ -122,7 +122,7 @@ const backgroundSyncGenerations = new Map(); const backgroundSyncFailures = new Map(); const flagSnapshots = new Map(); const lastBackgroundSyncAt = new Map(); -let windowsAppIcon = null; +let windowsAppIcon = null; let tray = null; function registerIpcHandler(channel, handler) { @@ -140,16 +140,16 @@ function registerIpcHandler(channel, handler) { } }); } - + function updateAccountStore(update) { - const operation = accountStoreQueue.then(async () => { - const store = (await readAccountStore()) || { accounts: [], activeId: null }; - const result = await update(store); - if (store.accounts.length) await saveAccountStore(store); - else await fs.rm(credentialsPath(), { force: true }); - return result; - }); - accountStoreQueue = operation.catch(() => {}); + const operation = accountStoreQueue.then(async () => { + const store = (await readAccountStore()) || { accounts: [], activeId: null }; + const result = await update(store); + if (store.accounts.length) await saveAccountStore(store); + else await fs.rm(credentialsPath(), { force: true }); + return result; + }); + accountStoreQueue = operation.catch(() => {}); return operation; } @@ -175,13 +175,13 @@ async function authorizeOAuthAccount(account) { function listOAuthProviders() { return oauth2Service.listProviders(); } - + function sendMailSyncUpdate(update) { - for (const window of BrowserWindow.getAllWindows()) { - if (!window.isDestroyed() && !window.webContents.isDestroyed()) { - window.webContents.send('mail:sync-update', update); - } - } + for (const window of BrowserWindow.getAllWindows()) { + if (!window.isDestroyed() && !window.webContents.isDestroyed()) { + window.webContents.send('mail:sync-update', update); + } + } } const { checkSnoozeReminders } = createSnoozeReminderService({ @@ -197,10 +197,10 @@ const { checkSnoozeReminders } = createSnoozeReminderService({ }, sendMailSyncUpdate }); - + const { createKeyStore } = require('./pgp-keystore.cjs'); -const { createPgpMail, createPassphraseCache, PgpError } = require('./pgp-mail.cjs'); - +const { createPgpMail, createPassphraseCache, PgpError } = require('./pgp-mail.cjs'); + const pgpKeys = createKeyStore({ async load() { try { @@ -212,59 +212,59 @@ const pgpKeys = createKeyStore({ }, save(data) { return pgpJsonStore.save(data); } }); - -const pgpCache = createPassphraseCache(async () => (await pgpKeys.getSettings()).cacheMinutes); + +const pgpCache = createPassphraseCache(async () => (await pgpKeys.getSettings()).cacheMinutes); const pgpMail = createPgpMail({ keyStore: pgpKeys, cache: pgpCache }); const pgpKeyServers = createKeyServerService(); const { findSpecialMailbox, findSentMailbox, listCustomFolders, folderPath } = createFolderService({ customFolderPrefix: CUSTOM_FOLDER_PREFIX, isReservedFolderName }); - + async function readDavStore() { try { return await davJsonStore.load(); } catch (error) { - if (error.code === 'ENOENT') return { caldav: [], carddav: [], activeCaldavId: null, activeCarddavId: null }; - throw error; - } -} - + if (error.code === 'ENOENT') return { caldav: [], carddav: [], activeCaldavId: null, activeCarddavId: null }; + throw error; + } +} + async function saveDavStore(store) { return davJsonStore.save(store); -} - -function davPublicConfig(config) { - return { id: config.id, serverUrl: config.serverUrl, username: config.username, collections: config.collections || [] }; -} - -async function openDavClient(config, type) { - const { createDAVClient } = await getTsdav(); - return createDAVClient({ serverUrl: config.serverUrl, credentials: { username: config.username, password: config.password }, authMethod: 'Basic', defaultAccountType: type }); -} - -function activeDavConfig(store, type, id = null) { - const key = type === 'caldav' ? 'caldav' : 'carddav'; - const activeKey = type === 'caldav' ? 'activeCaldavId' : 'activeCarddavId'; - return store[key].find(item => item.id === (id || store[activeKey])) || null; -} - +} + +function davPublicConfig(config) { + return { id: config.id, serverUrl: config.serverUrl, username: config.username, collections: config.collections || [] }; +} + +async function openDavClient(config, type) { + const { createDAVClient } = await getTsdav(); + return createDAVClient({ serverUrl: config.serverUrl, credentials: { username: config.username, password: config.password }, authMethod: 'Basic', defaultAccountType: type }); +} + +function activeDavConfig(store, type, id = null) { + const key = type === 'caldav' ? 'caldav' : 'carddav'; + const activeKey = type === 'caldav' ? 'activeCaldavId' : 'activeCarddavId'; + return store[key].find(item => item.id === (id || store[activeKey])) || null; +} + const { imapClient, smtpTransport } = createMailConnections({ getImapFlow, getNodemailer, oauthTokenManager }); - -function assertSecureStorage() { - if (process.platform === 'linux' && typeof safeStorage.getSelectedStorageBackend === 'function') { - const backend = safeStorage.getSelectedStorageBackend(); - if (backend === 'basic_text') { - throw new Error('This Linux session is using the insecure basic_text password backend. Configure a secure secret store such as gnome-libsecret or kwallet before saving mail credentials or OpenPGP keys.'); - } - } - if (!safeStorage.isEncryptionAvailable()) throw new Error('OS credential storage is unavailable.'); -} - + +function assertSecureStorage() { + if (process.platform === 'linux' && typeof safeStorage.getSelectedStorageBackend === 'function') { + const backend = safeStorage.getSelectedStorageBackend(); + if (backend === 'basic_text') { + throw new Error('This Linux session is using the insecure basic_text password backend. Configure a secure secret store such as gnome-libsecret or kwallet before saving mail credentials or OpenPGP keys.'); + } + } + if (!safeStorage.isEncryptionAvailable()) throw new Error('OS credential storage is unavailable.'); +} + async function readAccountStore() { return accountRepository.load(); } @@ -272,135 +272,135 @@ async function readAccountStore() { async function saveAccountStore(store) { return accountRepository.save(store); } - -async function readAccount(accountId = null) { - const store = await readAccountStore(); - if (!store?.accounts.length) return null; - return store.accounts.find(account => account.id === (accountId || store.activeId)) || null; -} - + +async function readAccount(accountId = null) { + const store = await readAccountStore(); + if (!store?.accounts.length) return null; + return store.accounts.find(account => account.id === (accountId || store.activeId)) || null; +} + async function saveAccount(account) { - return updateAccountStore(store => { - const existing = store.accounts.find(item => item.email.toLowerCase() === account.email.toLowerCase() && item.imapHost.toLowerCase() === account.imapHost.toLowerCase()); - const saved = { ...existing, ...account, id: existing?.id || randomUUID() }; - store.accounts = [...store.accounts.filter(item => item.id !== saved.id), saved]; - store.activeId = saved.id; - return saved; - }); -} - + return updateAccountStore(store => { + const existing = store.accounts.find(item => item.email.toLowerCase() === account.email.toLowerCase() && item.imapHost.toLowerCase() === account.imapHost.toLowerCase()); + const saved = { ...existing, ...account, id: existing?.id || randomUUID() }; + store.accounts = [...store.accounts.filter(item => item.id !== saved.id), saved]; + store.activeId = saved.id; + return saved; + }); +} + async function connectMail(account) { const client = await imapClient(account); - let transport; - try { - await client.connect(); - const mailbox = await client.mailboxOpen('INBOX', { readOnly: true }); + let transport; + try { + await client.connect(); + const mailbox = await client.mailboxOpen('INBOX', { readOnly: true }); transport = await smtpTransport(account); - await transport.verify(); - return { mailbox: mailbox.name, messages: mailbox.exists }; - } finally { - if (transport) transport.close(); - if (client.usable) await client.logout().catch(() => {}); - } -} - + await transport.verify(); + return { mailbox: mailbox.name, messages: mailbox.exists }; + } finally { + if (transport) transport.close(); + if (client.usable) await client.logout().catch(() => {}); + } +} + async function cacheMailboxMessages(accountId, folder, messages) { - if (!messages.length) return; - await updateAccountStore(store => { - const account = store.accounts.find(item => item.id === accountId); - if (!account) return; - account.mailCache = account.mailCache || {}; - const previous = account.mailCache[folder] || []; - const merged = new Map(previous.map(message => [String(message.uid || message.id), message])); - for (const message of messages) merged.set(String(message.uid || message.id), message); - account.mailCache[folder] = [...merged.values()].slice(-50); - }); -} - -function cachedMailbox(account, folder, offset = 0, limit = 20, filters = {}) { - const all = filterMailboxMessages(account.mailCache?.[folder] || [], filters) - .sort((a, b) => Number(b.timestamp || 0) - Number(a.timestamp || 0)); - const start = Math.max(0, Number(offset) || 0); - const messages = all.slice(start, start + limit); - return { messages, total: all.length, start: all.length ? start + 1 : 0, end: start + messages.length, folder, offline: true }; -} - + if (!messages.length) return; + await updateAccountStore(store => { + const account = store.accounts.find(item => item.id === accountId); + if (!account) return; + account.mailCache = account.mailCache || {}; + const previous = account.mailCache[folder] || []; + const merged = new Map(previous.map(message => [String(message.uid || message.id), message])); + for (const message of messages) merged.set(String(message.uid || message.id), message); + account.mailCache[folder] = [...merged.values()].slice(-50); + }); +} + +function cachedMailbox(account, folder, offset = 0, limit = 20, filters = {}) { + const all = filterMailboxMessages(account.mailCache?.[folder] || [], filters) + .sort((a, b) => Number(b.timestamp || 0) - Number(a.timestamp || 0)); + const start = Math.max(0, Number(offset) || 0); + const messages = all.slice(start, start + limit); + return { messages, total: all.length, start: all.length ? start + 1 : 0, end: start + messages.length, folder, offline: true }; +} + async function toUiMessage(item, folder) { const { simpleParser } = await getMailparser(); - const parsed = await simpleParser(item.source); - const sender = parsed.from?.value?.[0]; - const pgpKind = pgpMail.detect(parsed); - const encrypted = pgpKind === 'encrypted-mime' || pgpKind === 'encrypted-inline'; - const content = encrypted - ? { bodyText: '', body: ['This message is encrypted with OpenPGP. Open it and enter your key passphrase to read it.'], links: [], attachments: [], attachment: null, size: '' } + const parsed = await simpleParser(item.source); + const sender = parsed.from?.value?.[0]; + const pgpKind = pgpMail.detect(parsed); + const encrypted = pgpKind === 'encrypted-mime' || pgpKind === 'encrypted-inline'; + const content = encrypted + ? { bodyText: '', body: ['This message is encrypted with OpenPGP. Open it and enter your key passphrase to read it.'], links: [], attachments: [], attachment: null, size: '' } : extractMailContent(parsed); - const { bodyText, body, links } = content; - const pgpSignatures = pgpKind && !encrypted ? await pgpMail.verifySigned(parsed, item.source) : null; - const date = parsed.date || item.internalDate || new Date(); - return { - id: Number(item.uid), - initials: (sender?.name || sender?.address || '?').split(/[\s@]+/).filter(Boolean).map(word => word[0]).join('').slice(0, 2).toUpperCase(), - color: '#dce6df', - sender: sender?.name || sender?.address || 'Unknown sender', - email: sender?.address || '', - subject: parsed.subject || '(no subject)', - snippet: encrypted ? 'Encrypted message' : (bodyText || parsed.subject || '').replace(/\s+/g, ' ').slice(0, 180), - encrypted, - pgpSignatures, - time: new Intl.DateTimeFormat(undefined, { hour: 'numeric', minute: '2-digit' }).format(date), - date: new Intl.DateTimeFormat(undefined, { dateStyle: 'medium', timeStyle: 'short' }).format(date), - timestamp: date.getTime(), - unread: !item.flags?.has('\\Seen'), - star: item.flags?.has('\\Flagged') || false, - tags: [folder], - sent: folder === 'Sent', - archived: folder === 'Archive', - deleted: folder === 'Trash', - sourceFolder: folder, - body, - html: content.html, - links, - uid: Number(item.uid), - attachments: content.attachments, - attachment: content.attachment, - size: content.size - }; -} - + const { bodyText, body, links } = content; + const pgpSignatures = pgpKind && !encrypted ? await pgpMail.verifySigned(parsed, item.source) : null; + const date = parsed.date || item.internalDate || new Date(); + return { + id: Number(item.uid), + initials: (sender?.name || sender?.address || '?').split(/[\s@]+/).filter(Boolean).map(word => word[0]).join('').slice(0, 2).toUpperCase(), + color: '#dce6df', + sender: sender?.name || sender?.address || 'Unknown sender', + email: sender?.address || '', + subject: parsed.subject || '(no subject)', + snippet: encrypted ? 'Encrypted message' : (bodyText || parsed.subject || '').replace(/\s+/g, ' ').slice(0, 180), + encrypted, + pgpSignatures, + time: new Intl.DateTimeFormat(undefined, { hour: 'numeric', minute: '2-digit' }).format(date), + date: new Intl.DateTimeFormat(undefined, { dateStyle: 'medium', timeStyle: 'short' }).format(date), + timestamp: date.getTime(), + unread: !item.flags?.has('\\Seen'), + star: item.flags?.has('\\Flagged') || false, + tags: [folder], + sent: folder === 'Sent', + archived: folder === 'Archive', + deleted: folder === 'Trash', + sourceFolder: folder, + body, + html: content.html, + links, + uid: Number(item.uid), + attachments: content.attachments, + attachment: content.attachment, + size: content.size + }; +} + async function fetchSnoozedMailbox(account, offset, limit) { - const now = Date.now(); - const pending = (account.snoozedMessages || []) - .filter(item => Number(item.dueAt) > now) - .sort((first, second) => Number(first.dueAt) - Number(second.dueAt)); - const selected = pending.slice(Math.max(0, Number(offset) || 0), Math.max(0, Number(offset) || 0) + Math.max(1, Math.min(50, Number(limit) || 20))); + const now = Date.now(); + const pending = (account.snoozedMessages || []) + .filter(item => Number(item.dueAt) > now) + .sort((first, second) => Number(first.dueAt) - Number(second.dueAt)); + const selected = pending.slice(Math.max(0, Number(offset) || 0), Math.max(0, Number(offset) || 0) + Math.max(1, Math.min(50, Number(limit) || 20))); const client = await imapClient(account); - const messages = []; - try { - await client.connect(); - for (const snooze of selected) { - const sourceFolder = String(snooze.folder || 'Inbox'); - const mailboxPath = await folderPath(client, sourceFolder); - if (!mailboxPath) continue; - const lock = await client.getMailboxLock(mailboxPath); - try { - const item = await client.fetchOne(Number(snooze.uid), { - uid: true, envelope: true, flags: true, internalDate: true, source: true - }, { uid: true }); - if (!item?.source) continue; - const message = await toUiMessage(item, 'Snoozed'); - message.tags.push(...(account.ruleLabels?.[`${sourceFolder}:${item.uid}`] || [])); - messages.push({ - ...message, - sourceFolder, - snoozedUntil: Number(snooze.dueAt) - }); - } finally { - lock.release(); - } - } - } finally { - if (client.usable) await client.logout().catch(() => {}); - } + const messages = []; + try { + await client.connect(); + for (const snooze of selected) { + const sourceFolder = String(snooze.folder || 'Inbox'); + const mailboxPath = await folderPath(client, sourceFolder); + if (!mailboxPath) continue; + const lock = await client.getMailboxLock(mailboxPath); + try { + const item = await client.fetchOne(Number(snooze.uid), { + uid: true, envelope: true, flags: true, internalDate: true, source: true + }, { uid: true }); + if (!item?.source) continue; + const message = await toUiMessage(item, 'Snoozed'); + message.tags.push(...(account.ruleLabels?.[`${sourceFolder}:${item.uid}`] || [])); + messages.push({ + ...message, + sourceFolder, + snoozedUntil: Number(snooze.dueAt) + }); + } finally { + lock.release(); + } + } + } finally { + if (client.usable) await client.logout().catch(() => {}); + } return { messages, total: pending.length, start: selected.length ? offset + 1 : 0, end: offset + messages.length, folder: 'Snoozed' }; } @@ -420,28 +420,28 @@ const { applyMessageAction } = createMessageActionService({ }); async function saveAccountSyncState(accountId, generation, folders) { - return updateAccountStore(store => { - const account = store.accounts.find(item => item.id === accountId); - if (!account || backgroundSyncGenerations.get(accountId) !== generation) return false; - account.syncState = account.syncState || { folders: {} }; - account.syncState.folders = folders; - return true; - }); -} - + return updateAccountStore(store => { + const account = store.accounts.find(item => item.id === accountId); + if (!account || backgroundSyncGenerations.get(accountId) !== generation) return false; + account.syncState = account.syncState || { folders: {} }; + account.syncState.folders = folders; + return true; + }); +} + function showNewMailNotification(account, count) { - if (!count || account.notificationsEnabled === false || !Notification.isSupported()) return; - const focused = BrowserWindow.getAllWindows().some(window => window.isFocused()); - if (focused) return; - const notification = new Notification({ - title: count === 1 ? 'New mail' : `${count} new messages`, - body: account.email - }); - notification.show(); -} - + if (!count || account.notificationsEnabled === false || !Notification.isSupported()) return; + const focused = BrowserWindow.getAllWindows().some(window => window.isFocused()); + if (focused) return; + const notification = new Notification({ + title: count === 1 ? 'New mail' : `${count} new messages`, + body: account.email + }); + notification.show(); +} + registerIpcHandler('app:get-version', () => app.getVersion()); - + registerPgpIpcHandlers({ registerIpcHandler, BrowserWindow, @@ -561,23 +561,23 @@ traceStartup('main services and IPC handlers initialized'); function createWindow() { traceStartup('creating BrowserWindow'); const window = new BrowserWindow({ - width: 1440, - height: 920, - minWidth: 920, - minHeight: 680, - title: `ep-mail v${app.getVersion()}`, - backgroundColor: '#f4f5f1', - show: false, - autoHideMenuBar: true, - icon: windowsAppIcon || path.join(__dirname, '..', 'icon.svg'), - webPreferences: { - preload: path.join(__dirname, 'preload.cjs'), - contextIsolation: true, - nodeIntegration: false, - sandbox: true - } - }); - + width: 1440, + height: 920, + minWidth: 920, + minHeight: 680, + title: `ep-mail v${app.getVersion()}`, + backgroundColor: '#f4f5f1', + show: false, + autoHideMenuBar: true, + icon: windowsAppIcon || path.join(__dirname, '..', 'icon.svg'), + webPreferences: { + preload: path.join(__dirname, 'preload.cjs'), + contextIsolation: true, + nodeIntegration: false, + sandbox: true + } + }); + window.webContents.on('dom-ready', () => traceStartup('renderer DOM ready')); window.webContents.on('did-finish-load', () => traceStartup('renderer load complete')); window.once('ready-to-show', () => { @@ -595,70 +595,70 @@ function createWindow() { window.webContents.on('will-navigate', (event, url) => { if (!isTrustedApplicationUrl(url, applicationHtmlPath)) event.preventDefault(); }); - return window; -} - -function showMainWindow() { - let window = BrowserWindow.getAllWindows().find(item => !item.isDestroyed()); - if (!window) { - window = createWindow(); - } else { - if (window.isMinimized()) window.restore(); - window.show(); - window.focus(); - } -} - -function createWindowsTray() { - tray = new Tray(windowsAppIcon.resize({ width: 16, height: 16 })); - tray.setToolTip('ep-mail'); - tray.setContextMenu(Menu.buildFromTemplate([ - { label: 'Open ep-mail', click: showMainWindow }, - { type: 'separator' }, - { label: 'Quit ep-mail', click: () => app.quit() } - ])); - tray.on('click', showMainWindow); - tray.on('double-click', showMainWindow); -} - -function repairWindowsStartMenuShortcut() { - if (!app.isPackaged) return; - - const shortcutPath = path.join( - app.getPath('appData'), - 'Microsoft', - 'Windows', - 'Start Menu', - 'Programs', - 'ep-mail.lnk' - ); - if (!fsSync.existsSync(shortcutPath)) return; - - try { - const shortcut = shell.readShortcutLink(shortcutPath); - const isEpMailShortcut = path.basename(shortcut.target).toLowerCase() === 'ep-mail.exe' - || shortcut.appUserModelId === windowsAppUserModelId; - if (!isEpMailShortcut) return; - if (shortcut.appUserModelId && shortcut.appUserModelId !== windowsAppUserModelId) return; - - const portableExecutable = process.env.PORTABLE_EXECUTABLE_FILE; - const executable = portableExecutable && fsSync.existsSync(portableExecutable) - ? portableExecutable - : process.execPath; - const updated = shell.writeShortcutLink(shortcutPath, 'update', { - ...shortcut, - target: executable, - cwd: path.dirname(executable), - icon: executable, - iconIndex: 0, - appUserModelId: windowsAppUserModelId - }); - if (!updated) throw new Error('Windows did not update the shortcut.'); - } catch (error) { - console.error('Could not repair the ep-mail Start Menu shortcut:', error); - } -} - + return window; +} + +function showMainWindow() { + let window = BrowserWindow.getAllWindows().find(item => !item.isDestroyed()); + if (!window) { + window = createWindow(); + } else { + if (window.isMinimized()) window.restore(); + window.show(); + window.focus(); + } +} + +function createWindowsTray() { + tray = new Tray(windowsAppIcon.resize({ width: 16, height: 16 })); + tray.setToolTip('ep-mail'); + tray.setContextMenu(Menu.buildFromTemplate([ + { label: 'Open ep-mail', click: showMainWindow }, + { type: 'separator' }, + { label: 'Quit ep-mail', click: () => app.quit() } + ])); + tray.on('click', showMainWindow); + tray.on('double-click', showMainWindow); +} + +function repairWindowsStartMenuShortcut() { + if (!app.isPackaged) return; + + const shortcutPath = path.join( + app.getPath('appData'), + 'Microsoft', + 'Windows', + 'Start Menu', + 'Programs', + 'ep-mail.lnk' + ); + if (!fsSync.existsSync(shortcutPath)) return; + + try { + const shortcut = shell.readShortcutLink(shortcutPath); + const isEpMailShortcut = path.basename(shortcut.target).toLowerCase() === 'ep-mail.exe' + || shortcut.appUserModelId === windowsAppUserModelId; + if (!isEpMailShortcut) return; + if (shortcut.appUserModelId && shortcut.appUserModelId !== windowsAppUserModelId) return; + + const portableExecutable = process.env.PORTABLE_EXECUTABLE_FILE; + const executable = portableExecutable && fsSync.existsSync(portableExecutable) + ? portableExecutable + : process.execPath; + const updated = shell.writeShortcutLink(shortcutPath, 'update', { + ...shortcut, + target: executable, + cwd: path.dirname(executable), + icon: executable, + iconIndex: 0, + appUserModelId: windowsAppUserModelId + }); + if (!updated) throw new Error('Windows did not update the shortcut.'); + } catch (error) { + console.error('Could not repair the ep-mail Start Menu shortcut:', error); + } +} + app.whenReady().then(() => { traceStartup('Electron app.whenReady'); app.setAppUserModelId(windowsAppUserModelId); @@ -685,17 +685,17 @@ app.whenReady().then(() => { snoozeTimer.unref(); powerMonitor.on('suspend', () => { idleWatcherManager.stopAll(); - }); - powerMonitor.on('resume', () => requestBackgroundSync(null, true)); - app.on('activate', () => { - if (BrowserWindow.getAllWindows().length === 0) createWindow(); - }); -}); - -app.on('window-all-closed', () => { - if (process.platform !== 'darwin') app.quit(); -}); - + }); + powerMonitor.on('resume', () => requestBackgroundSync(null, true)); + app.on('activate', () => { + if (BrowserWindow.getAllWindows().length === 0) createWindow(); + }); +}); + +app.on('window-all-closed', () => { + if (process.platform !== 'darwin') app.quit(); +}); + app.on('before-quit', () => { idleWatcherManager.stopAll(); }); diff --git a/desktop/pgp-keyservers.cjs b/desktop/pgp-keyservers.cjs index ee36f7c..8eeabe3 100644 --- a/desktop/pgp-keyservers.cjs +++ b/desktop/pgp-keyservers.cjs @@ -1,277 +1,277 @@ -const openpgp = require('openpgp'); - -const MAX_KEY_LENGTH = 200000; -const MAX_RESPONSE_BYTES = 600000; -const REQUEST_TIMEOUT_MS = 15000; -const MAX_CUSTOM_SERVERS = 10; - -const BUILTIN_SERVERS = [ - { 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 } -]; - -function normalizeBaseUrl(value) { - const raw = String(value || '').trim(); - if (raw.length > 300) throw new Error('The key server URL is too long.'); - let url; - try { - url = new URL(raw); - } catch { - throw new Error('Enter a valid HTTPS key server URL.'); - } - if (url.protocol !== 'https:' || url.username || url.password || url.search || url.hash) { - throw new Error('Key server URLs must use HTTPS and cannot contain credentials, a query, or a fragment.'); - } - url.pathname = `${url.pathname.replace(/\/+$/, '')}/`; - return url.toString(); -} - -function normalizeCustomServer(input) { - const name = String(input?.name || '').trim().slice(0, 60); - const protocol = input?.protocol; - if (!name) throw new Error('Enter a name for the key server.'); - if (!['hkp', 'vks'].includes(protocol)) throw new Error('Choose a supported HKP or VKS protocol.'); - return { - id: String(input?.id || ''), - name, - url: normalizeBaseUrl(input?.url), - protocol, - builtin: false - }; -} - -function listServers(customServers = [], enabledServerIds = []) { - const enabled = new Set(enabledServerIds); - return [ - ...BUILTIN_SERVERS.map(server => ({ ...server, enabled: enabled.has(server.id) })), - ...customServers.map(server => { - const normalized = normalizeCustomServer(server); - return { ...normalized, enabled: enabled.has(normalized.id) }; - }) - ]; -} - -function validateEmail(value) { - const email = String(value || '').trim(); - if (!/^[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+$/.test(email)) throw new Error('Enter a valid email address.'); - return email; -} - -function baseUrl(server) { - return new URL(normalizeBaseUrl(server.url)); -} - -function endpoint(server, path) { - return new URL(path, baseUrl(server)); -} - -async function readResponseText(response) { - const declaredLength = Number(response.headers?.get?.('content-length') || 0); - if (declaredLength > MAX_RESPONSE_BYTES) throw new Error('The key server response is too large.'); - if (!response.body) return ''; - const chunks = []; - let length = 0; - for await (const chunk of response.body) { - const bytes = Buffer.from(chunk); - length += bytes.length; - if (length > MAX_RESPONSE_BYTES) { - throw new Error('The key server response is too large.'); - } - chunks.push(bytes); - } - return Buffer.concat(chunks, length).toString('utf8'); -} - -function createKeyServerService({ fetchImpl = globalThis.fetch } = {}) { - if (typeof fetchImpl !== 'function') throw new Error('Fetch is unavailable for key server requests.'); - - async function request(server, url, options = {}) { - let response; - try { - response = await fetchImpl(url, { - ...options, - redirect: 'error', - signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS) - }); - } catch (error) { - throw new Error(`Could not reach ${server.name}: ${error.message}`); - } - const text = await readResponseText(response); - return { response, text }; - } - - async function parsePublicKeys(armored, email) { - if (typeof armored !== 'string' || armored.length > MAX_RESPONSE_BYTES) { - throw new Error('The key server returned an invalid or oversized key response.'); - } - const blocks = armored.match(/-----BEGIN PGP PUBLIC KEY BLOCK-----[\s\S]*?-----END PGP PUBLIC KEY BLOCK-----/g) || []; - if (!blocks.length) { - if (!armored.trim() || /no (matching )?keys|no results/i.test(armored)) return []; - throw new Error('The key server response did not contain an OpenPGP public key.'); - } - if (blocks.length > 10) throw new Error('The key server returned too many keys.'); - const keys = []; - const seen = new Set(); - let validKeyCount = 0; - for (const block of blocks) { - if (block.length > MAX_KEY_LENGTH) continue; - const key = await openpgp.readKey({ armoredKey: block }).catch(() => null); - if (!key) continue; - const fingerprint = key.getFingerprint().toUpperCase(); - if (seen.has(fingerprint)) continue; - seen.add(fingerprint); - const emails = [...new Set(key.getUserIDs() - .map(id => (/<([^>]+)>/.exec(id)?.[1] || (id.includes('@') ? id : '')).trim().toLowerCase()) - .filter(Boolean))]; - const primary = await key.getPrimaryUser().catch(() => null); - if (!primary) continue; - validKeyCount += 1; - if (email && !emails.includes(email.toLowerCase())) continue; - keys.push({ - fingerprint, - name: primary.user.userID?.name || '', - emails, - armoredKey: key.armor() - }); - } - if (!validKeyCount) throw new Error('The key server returned no valid public keys.'); - return keys; - } - - async function lookup(serverInput, emailInput) { - const server = normalizeCustomServer(serverInput); - const email = validateEmail(emailInput); - let url; - if (server.protocol === 'vks') { - url = endpoint(server, `vks/v1/by-email/${encodeURIComponent(email)}`); - } else { - url = endpoint(server, 'pks/lookup'); - url.searchParams.set('op', 'get'); - url.searchParams.set('search', email); - } - const { response, text } = await request(server, url); - if (response.status === 404) return []; - if (!response.ok) throw new Error(`${server.name} returned HTTP ${response.status}.`); - let armored = text; - if (server.protocol === 'hkp' && /^\s*\{/.test(text)) { - try { - const data = JSON.parse(text); - armored = data.publicKeyArmored || ''; - } catch { - throw new Error(`${server.name} returned an invalid key response.`); - } - } - return parsePublicKeys(armored, email); - } - - async function lookupEnabled(serverInputs, emailInput) { - const servers = serverInputs.filter(server => server.enabled === true); - if (!servers.length) throw new Error('Enable at least one key server before searching.'); - const email = validateEmail(emailInput); - const lookups = await Promise.all(servers.map(async server => { - try { - return { server, keys: await lookup(server, email), error: null }; - } catch (error) { - return { server, keys: [], error: error.message }; - } - })); - const keysByFingerprint = new Map(); - for (const result of lookups) { - for (const key of result.keys) { - const existing = keysByFingerprint.get(key.fingerprint); - if (existing) existing.sources.push(result.server.name); - else keysByFingerprint.set(key.fingerprint, { ...key, sources: [result.server.name] }); - } - } - return { - keys: [...keysByFingerprint.values()], - searchedServers: lookups.map(({ server }) => ({ id: server.id, name: server.name })), - errors: lookups.filter(result => result.error).map(({ server, error }) => ({ - id: server.id, - name: server.name, - message: error - })) - }; - } - - async function publishVks(server, email, armoredKey, expectedFingerprint) { - const { response, text } = await request(server, endpoint(server, 'vks/v1/upload'), { - method: 'POST', - headers: { 'content-type': 'application/json', accept: 'application/json' }, - body: JSON.stringify({ keytext: armoredKey }) - }); - if (!response.ok) throw new Error(`${server.name} rejected the key upload (HTTP ${response.status}).`); - let result; - try { result = JSON.parse(text); } catch { throw new Error(`${server.name} returned an invalid upload response.`); } - if (String(result.key_fpr || '').toUpperCase() !== expectedFingerprint || !result.token || !result.status || typeof result.status !== 'object') { - throw new Error(`${server.name} returned an incomplete or mismatched upload response.`); - } - const addressStatus = Object.entries(result.status).find(([address]) => address.toLowerCase() === email.toLowerCase())?.[1]; - if (addressStatus === 'published') return { uploaded: true, verification: 'published' }; - if (addressStatus === 'pending') return { uploaded: true, verification: 'pending' }; - if (addressStatus !== 'unpublished') { - return { uploaded: true, verification: addressStatus || 'unknown' }; - } - try { - const verify = await request(server, endpoint(server, 'vks/v1/request-verify'), { - method: 'POST', - headers: { 'content-type': 'application/json', accept: 'application/json' }, - body: JSON.stringify({ token: result.token, addresses: [email] }) - }); - if (!verify.response.ok) throw new Error(`HTTP ${verify.response.status}`); - let verified; - try { verified = JSON.parse(verify.text); } catch { throw new Error('invalid verification response'); } - if (String(verified.key_fpr || '').toUpperCase() !== expectedFingerprint || !verified.status || typeof verified.status !== 'object') { - throw new Error('verification response did not match the uploaded key'); - } - const state = Object.entries(verified.status || {}).find(([address]) => address.toLowerCase() === email.toLowerCase())?.[1]; - return { uploaded: true, verification: state || 'requested' }; - } catch (error) { - return { uploaded: true, verification: 'request-failed', warning: `The key was uploaded, but email verification could not be requested: ${error.message}` }; - } - } - - async function publishHkp(server, armoredKey) { - const form = new URLSearchParams({ keytext: armoredKey }); - const { response, text } = await request(server, endpoint(server, 'pks/add'), { - method: 'POST', - headers: { 'content-type': 'application/x-www-form-urlencoded' }, - body: form.toString() - }); - if (!response.ok) throw new Error(`${server.name} rejected the key upload (HTTP ${response.status}).`); - if (!/upload successful|successfully added|key added/i.test(text)) { - throw new Error(`${server.name} did not confirm the key upload: ${text.trim().slice(0, 300) || 'empty response'}`); - } - return { - uploaded: true, - verification: server.id === 'mailvelope-hkp' ? 'check-email' : 'server-accepted', - message: text.trim().slice(0, 500) - }; - } - - async function publish(serverInput, emailInput, armoredInput, expectedFingerprint) { - const server = normalizeCustomServer(serverInput); - const email = validateEmail(emailInput); - const armoredKey = String(armoredInput || '').trim(); - if (!armoredKey || armoredKey.length > MAX_KEY_LENGTH || /BEGIN PGP PRIVATE KEY BLOCK/.test(armoredKey)) { - throw new Error('Only a valid public key can be published.'); - } - const keys = await parsePublicKeys(armoredKey, email); - if (keys.length !== 1 || keys[0].fingerprint !== String(expectedFingerprint || '').toUpperCase()) { - throw new Error('The selected public key does not match the key and email being published.'); - } - if (server.protocol === 'vks') return publishVks(server, email, keys[0].armoredKey, keys[0].fingerprint); - return publishHkp(server, keys[0].armoredKey); - } - - return { lookup, lookupEnabled, publish }; -} - -module.exports = { - BUILTIN_SERVERS, - MAX_CUSTOM_SERVERS, - createKeyServerService, - listServers, - normalizeBaseUrl, - normalizeCustomServer -}; +const openpgp = require('openpgp'); + +const MAX_KEY_LENGTH = 200000; +const MAX_RESPONSE_BYTES = 600000; +const REQUEST_TIMEOUT_MS = 15000; +const MAX_CUSTOM_SERVERS = 10; + +const BUILTIN_SERVERS = [ + { 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 } +]; + +function normalizeBaseUrl(value) { + const raw = String(value || '').trim(); + if (raw.length > 300) throw new Error('The key server URL is too long.'); + let url; + try { + url = new URL(raw); + } catch { + throw new Error('Enter a valid HTTPS key server URL.'); + } + if (url.protocol !== 'https:' || url.username || url.password || url.search || url.hash) { + throw new Error('Key server URLs must use HTTPS and cannot contain credentials, a query, or a fragment.'); + } + url.pathname = `${url.pathname.replace(/\/+$/, '')}/`; + return url.toString(); +} + +function normalizeCustomServer(input) { + const name = String(input?.name || '').trim().slice(0, 60); + const protocol = input?.protocol; + if (!name) throw new Error('Enter a name for the key server.'); + if (!['hkp', 'vks'].includes(protocol)) throw new Error('Choose a supported HKP or VKS protocol.'); + return { + id: String(input?.id || ''), + name, + url: normalizeBaseUrl(input?.url), + protocol, + builtin: false + }; +} + +function listServers(customServers = [], enabledServerIds = []) { + const enabled = new Set(enabledServerIds); + return [ + ...BUILTIN_SERVERS.map(server => ({ ...server, enabled: enabled.has(server.id) })), + ...customServers.map(server => { + const normalized = normalizeCustomServer(server); + return { ...normalized, enabled: enabled.has(normalized.id) }; + }) + ]; +} + +function validateEmail(value) { + const email = String(value || '').trim(); + if (!/^[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+$/.test(email)) throw new Error('Enter a valid email address.'); + return email; +} + +function baseUrl(server) { + return new URL(normalizeBaseUrl(server.url)); +} + +function endpoint(server, path) { + return new URL(path, baseUrl(server)); +} + +async function readResponseText(response) { + const declaredLength = Number(response.headers?.get?.('content-length') || 0); + if (declaredLength > MAX_RESPONSE_BYTES) throw new Error('The key server response is too large.'); + if (!response.body) return ''; + const chunks = []; + let length = 0; + for await (const chunk of response.body) { + const bytes = Buffer.from(chunk); + length += bytes.length; + if (length > MAX_RESPONSE_BYTES) { + throw new Error('The key server response is too large.'); + } + chunks.push(bytes); + } + return Buffer.concat(chunks, length).toString('utf8'); +} + +function createKeyServerService({ fetchImpl = globalThis.fetch } = {}) { + if (typeof fetchImpl !== 'function') throw new Error('Fetch is unavailable for key server requests.'); + + async function request(server, url, options = {}) { + let response; + try { + response = await fetchImpl(url, { + ...options, + redirect: 'error', + signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS) + }); + } catch (error) { + throw new Error(`Could not reach ${server.name}: ${error.message}`); + } + const text = await readResponseText(response); + return { response, text }; + } + + async function parsePublicKeys(armored, email) { + if (typeof armored !== 'string' || armored.length > MAX_RESPONSE_BYTES) { + throw new Error('The key server returned an invalid or oversized key response.'); + } + const blocks = armored.match(/-----BEGIN PGP PUBLIC KEY BLOCK-----[\s\S]*?-----END PGP PUBLIC KEY BLOCK-----/g) || []; + if (!blocks.length) { + if (!armored.trim() || /no (matching )?keys|no results/i.test(armored)) return []; + throw new Error('The key server response did not contain an OpenPGP public key.'); + } + if (blocks.length > 10) throw new Error('The key server returned too many keys.'); + const keys = []; + const seen = new Set(); + let validKeyCount = 0; + for (const block of blocks) { + if (block.length > MAX_KEY_LENGTH) continue; + const key = await openpgp.readKey({ armoredKey: block }).catch(() => null); + if (!key) continue; + const fingerprint = key.getFingerprint().toUpperCase(); + if (seen.has(fingerprint)) continue; + seen.add(fingerprint); + const emails = [...new Set(key.getUserIDs() + .map(id => (/<([^>]+)>/.exec(id)?.[1] || (id.includes('@') ? id : '')).trim().toLowerCase()) + .filter(Boolean))]; + const primary = await key.getPrimaryUser().catch(() => null); + if (!primary) continue; + validKeyCount += 1; + if (email && !emails.includes(email.toLowerCase())) continue; + keys.push({ + fingerprint, + name: primary.user.userID?.name || '', + emails, + armoredKey: key.armor() + }); + } + if (!validKeyCount) throw new Error('The key server returned no valid public keys.'); + return keys; + } + + async function lookup(serverInput, emailInput) { + const server = normalizeCustomServer(serverInput); + const email = validateEmail(emailInput); + let url; + if (server.protocol === 'vks') { + url = endpoint(server, `vks/v1/by-email/${encodeURIComponent(email)}`); + } else { + url = endpoint(server, 'pks/lookup'); + url.searchParams.set('op', 'get'); + url.searchParams.set('search', email); + } + const { response, text } = await request(server, url); + if (response.status === 404) return []; + if (!response.ok) throw new Error(`${server.name} returned HTTP ${response.status}.`); + let armored = text; + if (server.protocol === 'hkp' && /^\s*\{/.test(text)) { + try { + const data = JSON.parse(text); + armored = data.publicKeyArmored || ''; + } catch { + throw new Error(`${server.name} returned an invalid key response.`); + } + } + return parsePublicKeys(armored, email); + } + + async function lookupEnabled(serverInputs, emailInput) { + const servers = serverInputs.filter(server => server.enabled === true); + if (!servers.length) throw new Error('Enable at least one key server before searching.'); + const email = validateEmail(emailInput); + const lookups = await Promise.all(servers.map(async server => { + try { + return { server, keys: await lookup(server, email), error: null }; + } catch (error) { + return { server, keys: [], error: error.message }; + } + })); + const keysByFingerprint = new Map(); + for (const result of lookups) { + for (const key of result.keys) { + const existing = keysByFingerprint.get(key.fingerprint); + if (existing) existing.sources.push(result.server.name); + else keysByFingerprint.set(key.fingerprint, { ...key, sources: [result.server.name] }); + } + } + return { + keys: [...keysByFingerprint.values()], + searchedServers: lookups.map(({ server }) => ({ id: server.id, name: server.name })), + errors: lookups.filter(result => result.error).map(({ server, error }) => ({ + id: server.id, + name: server.name, + message: error + })) + }; + } + + async function publishVks(server, email, armoredKey, expectedFingerprint) { + const { response, text } = await request(server, endpoint(server, 'vks/v1/upload'), { + method: 'POST', + headers: { 'content-type': 'application/json', accept: 'application/json' }, + body: JSON.stringify({ keytext: armoredKey }) + }); + if (!response.ok) throw new Error(`${server.name} rejected the key upload (HTTP ${response.status}).`); + let result; + try { result = JSON.parse(text); } catch { throw new Error(`${server.name} returned an invalid upload response.`); } + if (String(result.key_fpr || '').toUpperCase() !== expectedFingerprint || !result.token || !result.status || typeof result.status !== 'object') { + throw new Error(`${server.name} returned an incomplete or mismatched upload response.`); + } + const addressStatus = Object.entries(result.status).find(([address]) => address.toLowerCase() === email.toLowerCase())?.[1]; + if (addressStatus === 'published') return { uploaded: true, verification: 'published' }; + if (addressStatus === 'pending') return { uploaded: true, verification: 'pending' }; + if (addressStatus !== 'unpublished') { + return { uploaded: true, verification: addressStatus || 'unknown' }; + } + try { + const verify = await request(server, endpoint(server, 'vks/v1/request-verify'), { + method: 'POST', + headers: { 'content-type': 'application/json', accept: 'application/json' }, + body: JSON.stringify({ token: result.token, addresses: [email] }) + }); + if (!verify.response.ok) throw new Error(`HTTP ${verify.response.status}`); + let verified; + try { verified = JSON.parse(verify.text); } catch { throw new Error('invalid verification response'); } + if (String(verified.key_fpr || '').toUpperCase() !== expectedFingerprint || !verified.status || typeof verified.status !== 'object') { + throw new Error('verification response did not match the uploaded key'); + } + const state = Object.entries(verified.status || {}).find(([address]) => address.toLowerCase() === email.toLowerCase())?.[1]; + return { uploaded: true, verification: state || 'requested' }; + } catch (error) { + return { uploaded: true, verification: 'request-failed', warning: `The key was uploaded, but email verification could not be requested: ${error.message}` }; + } + } + + async function publishHkp(server, armoredKey) { + const form = new URLSearchParams({ keytext: armoredKey }); + const { response, text } = await request(server, endpoint(server, 'pks/add'), { + method: 'POST', + headers: { 'content-type': 'application/x-www-form-urlencoded' }, + body: form.toString() + }); + if (!response.ok) throw new Error(`${server.name} rejected the key upload (HTTP ${response.status}).`); + if (!/upload successful|successfully added|key added/i.test(text)) { + throw new Error(`${server.name} did not confirm the key upload: ${text.trim().slice(0, 300) || 'empty response'}`); + } + return { + uploaded: true, + verification: server.id === 'mailvelope-hkp' ? 'check-email' : 'server-accepted', + message: text.trim().slice(0, 500) + }; + } + + async function publish(serverInput, emailInput, armoredInput, expectedFingerprint) { + const server = normalizeCustomServer(serverInput); + const email = validateEmail(emailInput); + const armoredKey = String(armoredInput || '').trim(); + if (!armoredKey || armoredKey.length > MAX_KEY_LENGTH || /BEGIN PGP PRIVATE KEY BLOCK/.test(armoredKey)) { + throw new Error('Only a valid public key can be published.'); + } + const keys = await parsePublicKeys(armoredKey, email); + if (keys.length !== 1 || keys[0].fingerprint !== String(expectedFingerprint || '').toUpperCase()) { + throw new Error('The selected public key does not match the key and email being published.'); + } + if (server.protocol === 'vks') return publishVks(server, email, keys[0].armoredKey, keys[0].fingerprint); + return publishHkp(server, keys[0].armoredKey); + } + + return { lookup, lookupEnabled, publish }; +} + +module.exports = { + BUILTIN_SERVERS, + MAX_CUSTOM_SERVERS, + createKeyServerService, + listServers, + normalizeBaseUrl, + normalizeCustomServer +}; diff --git a/desktop/pgp-keystore.cjs b/desktop/pgp-keystore.cjs index ce39dd1..f9e05fd 100644 --- a/desktop/pgp-keystore.cjs +++ b/desktop/pgp-keystore.cjs @@ -1,346 +1,346 @@ -const openpgp = require('openpgp'); - -const MAX_KEY_LENGTH = 200000; - -function publicInfo(entry) { - return { - fingerprint: entry.fingerprint, - name: entry.name, - email: entry.email, - accountId: entry.accountId || null, - createdAt: entry.createdAt, - algorithm: entry.algorithm, - hasRevocationCertificate: Boolean(entry.revocationCertificate) - }; -} - -function requirePassphrase(passphrase) { - if (typeof passphrase !== 'string' || passphrase.length < 8) { - throw new Error('Use a passphrase of at least 8 characters.'); - } - return passphrase; -} - -function readArmored(value) { - const armored = String(value || '').trim(); - if (!armored || armored.length > MAX_KEY_LENGTH) throw new Error('That key file is empty or too large.'); - return armored; -} - -async function unlock(armoredPrivateKey, passphrase) { - try { - return await openpgp.decryptKey({ - privateKey: await openpgp.readPrivateKey({ armoredKey: armoredPrivateKey }), - passphrase - }); - } catch { - throw new Error('The passphrase is incorrect.'); - } -} - -const TRUST_LEVELS = ['unknown', 'trusted', 'verified']; -const DEFAULT_CACHE_MINUTES = 10; - -function contactInfo(entry) { - return { - fingerprint: entry.fingerprint, - name: entry.name, - emails: entry.emails, - trust: entry.trust, - source: entry.source, - addedAt: entry.addedAt - }; -} - -async function readPublicOnly(value) { - const armored = readArmored(value); - if (/BEGIN PGP PRIVATE KEY BLOCK/.test(armored)) throw new Error('That file contains a private key. Import public keys only.'); - const key = await openpgp.readKey({ armoredKey: armored }).catch(() => { - throw new Error('That is not a valid OpenPGP public key.'); - }); - await key.getPrimaryUser().catch(() => { - throw new Error('That key is expired, revoked or has no valid user ID.'); - }); - return key; -} - -async function keyEmails(key) { - return [...new Set(key.getUserIDs().map(id => (/<([^>]+)>/.exec(id)?.[1] || (id.includes('@') ? id : '')).trim().toLowerCase()).filter(Boolean))]; -} -// Passphrase-protected OpenPGP key storage. `storage` persists one JSON object -// (the desktop app wraps it with the OS credential store before writing it). -function createKeyStore(storage) { - async function read() { - const data = await storage.load(); - return { - keys: Array.isArray(data?.keys) ? data.keys : [], - contacts: Array.isArray(data?.contacts) ? data.contacts : [], - settings: data?.settings && typeof data.settings === 'object' ? data.settings : {} - }; - } - - async function add(entry) { - const data = await read(); - if (data.keys.some(key => key.fingerprint === entry.fingerprint)) { - throw new Error('That key is already in your keyring.'); - } - data.keys.push(entry); - await storage.save(data); - } - - return { - async listContacts() { - return (await read()).contacts.map(contactInfo); - }, - - async addContact({ armoredKey, source = 'import' }) { - const key = await readPublicOnly(armoredKey); - const fingerprint = key.getFingerprint().toUpperCase(); - const emails = await keyEmails(key); - const data = await read(); - if (data.keys.some(entry => entry.fingerprint === fingerprint)) throw new Error('That is one of your own keys.'); - if (data.contacts.some(entry => entry.fingerprint === fingerprint)) throw new Error('That public key is already in your contacts.'); - const user = await key.getPrimaryUser(); - const replaces = data.contacts - .filter(entry => entry.emails.some(email => emails.includes(email))) - .map(entry => entry.fingerprint); - const entry = { - fingerprint, - name: user.user.userID?.name || '', - emails, - trust: 'unknown', - source: ['import', 'message', 'paste', 'keyserver'].includes(source) ? source : 'import', - addedAt: Date.now(), - publicKey: key.armor() - }; - data.contacts.push(entry); - await storage.save(data); - return { contact: contactInfo(entry), keyChangedFrom: replaces }; - }, - - async setTrust(fingerprint, trust) { - if (!TRUST_LEVELS.includes(trust)) throw new Error('Unknown trust level.'); - const data = await read(); - const entry = data.contacts.find(item => item.fingerprint === fingerprint); - if (!entry) throw new Error('That contact key was not found.'); - entry.trust = trust; - await storage.save(data); - return contactInfo(entry); - }, - - async removeContact(fingerprint) { - const data = await read(); - if (!data.contacts.some(item => item.fingerprint === fingerprint)) throw new Error('That contact key was not found.'); - data.contacts = data.contacts.filter(item => item.fingerprint !== fingerprint); - await storage.save(data); - return { removed: true }; - }, - - async exportContact(fingerprint) { - const entry = (await read()).contacts.find(item => item.fingerprint === fingerprint); - if (!entry) throw new Error('That contact key was not found.'); - return entry.publicKey; - }, - - // Resolves public keys for recipient addresses (contacts and own keys). - async findRecipientKeys(addresses) { - const data = await read(); - const pool = [ - ...data.contacts.map(entry => ({ ...entry, own: false })), - ...data.keys.map(entry => ({ fingerprint: entry.fingerprint, emails: [String(entry.email).toLowerCase()], trust: 'verified', addedAt: entry.createdAt, publicKey: entry.publicKey, own: true })) - ]; - const keys = []; - const missing = []; - for (const address of addresses.map(value => String(value).trim().toLowerCase())) { - const candidates = pool - .filter(entry => entry.emails.includes(address)) - .sort((a, b) => TRUST_LEVELS.indexOf(b.trust) - TRUST_LEVELS.indexOf(a.trust) || b.addedAt - a.addedAt); - let usable = null; - for (const candidate of candidates) { - try { - const key = await openpgp.readKey({ armoredKey: candidate.publicKey }); - await key.getEncryptionKey(); - usable = { key, fingerprint: candidate.fingerprint, trust: candidate.trust }; - break; - } catch { /* expired or revoked: try the next key */ } - } - if (usable) keys.push({ address, ...usable }); - else missing.push(address); - } - return { keys, missing }; - }, - - async verificationKeys() { - const data = await read(); - const result = []; - for (const entry of [...data.contacts.map(item => ({ ...item, own: false })), ...data.keys.map(item => ({ ...item, trust: 'verified', emails: [String(item.email).toLowerCase()], own: true }))]) { - try { - result.push({ key: await openpgp.readKey({ armoredKey: entry.publicKey }), fingerprint: entry.fingerprint, trust: entry.trust, emails: entry.emails, own: entry.own }); - } catch { /* skip unreadable entries */ } - } - return result; - }, - - async privateEntries() { - return (await read()).keys.map(entry => ({ fingerprint: entry.fingerprint, email: entry.email, name: entry.name, privateKey: entry.privateKey, publicKey: entry.publicKey })); - }, - - async unlockKey(fingerprint, passphrase) { - const entry = (await read()).keys.find(key => key.fingerprint === fingerprint); - if (!entry) throw new Error('That key was not found.'); - return unlock(entry.privateKey, passphrase); - }, - - async getSettings() { - const settings = (await read()).settings; - return { - cacheMinutes: Number.isFinite(settings.cacheMinutes) ? settings.cacheMinutes : DEFAULT_CACHE_MINUTES, - customKeyServers: Array.isArray(settings.customKeyServers) ? settings.customKeyServers : [], - enabledKeyServers: Array.isArray(settings.enabledKeyServers) - ? [...new Set(settings.enabledKeyServers.filter(id => typeof id === 'string'))] - : [] - }; - }, - - async setSettings({ cacheMinutes, customKeyServers, enabledKeyServers }) { - const minutes = Number(cacheMinutes); - if (!Number.isFinite(minutes) || minutes < 0 || minutes > 1440) throw new Error('Choose between 0 and 1440 minutes.'); - const data = await read(); - data.settings.cacheMinutes = Math.round(minutes); - if (customKeyServers !== undefined) { - if (!Array.isArray(customKeyServers) || customKeyServers.length > 10 || customKeyServers.some(server => !server || typeof server !== 'object')) { - throw new Error('You can configure up to 10 valid custom key servers.'); - } - data.settings.customKeyServers = customKeyServers.map(server => ({ - id: String(server.id || ''), - name: String(server.name || '').slice(0, 60), - url: String(server.url || '').slice(0, 300), - protocol: String(server.protocol || '') - })); - } - if (enabledKeyServers !== undefined) { - if (!Array.isArray(enabledKeyServers) || enabledKeyServers.length > 12 || enabledKeyServers.some(id => typeof id !== 'string' || !id.trim())) { - throw new Error('Choose no more than 12 valid enabled key servers.'); - } - data.settings.enabledKeyServers = [...new Set(enabledKeyServers)]; - } - await storage.save(data); - return { - cacheMinutes: data.settings.cacheMinutes, - customKeyServers: Array.isArray(data.settings.customKeyServers) ? data.settings.customKeyServers : [], - enabledKeyServers: Array.isArray(data.settings.enabledKeyServers) ? [...data.settings.enabledKeyServers] : [] - }; - }, - - async list() { - return (await read()).keys.map(publicInfo); - }, - - async generate({ name, email, passphrase, accountId = null }) { - const cleanName = String(name || '').trim().slice(0, 100); - const cleanEmail = String(email || '').trim(); - if (!/^[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+$/.test(cleanEmail)) throw new Error('Enter a valid email address for the key.'); - requirePassphrase(passphrase); - const { privateKey, publicKey, revocationCertificate } = await openpgp.generateKey({ - type: 'ecc', - curve: 'curve25519Legacy', - userIDs: [{ name: cleanName || undefined, email: cleanEmail }], - passphrase, - format: 'armored' - }); - const key = await openpgp.readKey({ armoredKey: publicKey }); - const entry = { - fingerprint: key.getFingerprint().toUpperCase(), - name: cleanName, - email: cleanEmail, - accountId, - createdAt: Date.now(), - algorithm: 'Curve25519', - privateKey, - publicKey, - revocationCertificate - }; - await add(entry); - return { key: publicInfo(entry), revocationCertificate }; - }, - - async import({ armoredKey, passphrase, accountId = null }) { - const parsed = await openpgp.readPrivateKey({ armoredKey: readArmored(armoredKey) }).catch(() => { - throw new Error('That is not a valid OpenPGP private key.'); - }); - requirePassphrase(passphrase); - let protectedKey; - if (parsed.isDecrypted()) { - protectedKey = await openpgp.encryptKey({ privateKey: parsed, passphrase }); - } else { - await unlock(parsed.armor(), passphrase); - protectedKey = parsed; - } - const user = await protectedKey.getPrimaryUser().catch(() => null); - const entry = { - fingerprint: protectedKey.getFingerprint().toUpperCase(), - name: user?.user?.userID?.name || '', - email: user?.user?.userID?.email || '', - accountId, - createdAt: protectedKey.getCreationTime().getTime(), - algorithm: protectedKey.getAlgorithmInfo().algorithm, - privateKey: protectedKey.armor(), - publicKey: protectedKey.toPublic().armor(), - revocationCertificate: null - }; - await add(entry); - return publicInfo(entry); - }, - - async exportPublic(fingerprint) { - const entry = (await read()).keys.find(key => key.fingerprint === fingerprint); - if (!entry) throw new Error('That key was not found.'); - return entry.publicKey; - }, - - async exportPrivate(fingerprint, passphrase) { - const entry = (await read()).keys.find(key => key.fingerprint === fingerprint); - if (!entry) throw new Error('That key was not found.'); - await unlock(entry.privateKey, passphrase); - return entry.privateKey; - }, - - async changePassphrase(fingerprint, currentPassphrase, newPassphrase) { - requirePassphrase(newPassphrase); - const data = await read(); - const keyIndex = data.keys.findIndex(key => key.fingerprint === fingerprint); - if (keyIndex < 0) throw new Error('That key was not found.'); - const entry = data.keys[keyIndex]; - const privateKey = await unlock(entry.privateKey, currentPassphrase); - const protectedKey = await openpgp.encryptKey({ privateKey, passphrase: newPassphrase }); - const updated = { - ...data, - keys: data.keys.map((key, index) => index === keyIndex - ? { ...key, privateKey: protectedKey.armor() } - : key) - }; - await storage.save(updated); - return { changed: true }; - }, - - async exportRevocation(fingerprint, passphrase) { - const entry = (await read()).keys.find(key => key.fingerprint === fingerprint); - if (!entry) throw new Error('That key was not found.'); - if (!entry.revocationCertificate) throw new Error('No revocation certificate is stored for this key.'); - await unlock(entry.privateKey, passphrase); - return entry.revocationCertificate; - }, - - async remove(fingerprint, passphrase) { - const data = await read(); - const entry = data.keys.find(key => key.fingerprint === fingerprint); - if (!entry) throw new Error('That key was not found.'); - await unlock(entry.privateKey, passphrase); - data.keys = data.keys.filter(key => key.fingerprint !== fingerprint); - await storage.save(data); - return { removed: true }; - } - }; -} - -module.exports = { createKeyStore }; +const openpgp = require('openpgp'); + +const MAX_KEY_LENGTH = 200000; + +function publicInfo(entry) { + return { + fingerprint: entry.fingerprint, + name: entry.name, + email: entry.email, + accountId: entry.accountId || null, + createdAt: entry.createdAt, + algorithm: entry.algorithm, + hasRevocationCertificate: Boolean(entry.revocationCertificate) + }; +} + +function requirePassphrase(passphrase) { + if (typeof passphrase !== 'string' || passphrase.length < 8) { + throw new Error('Use a passphrase of at least 8 characters.'); + } + return passphrase; +} + +function readArmored(value) { + const armored = String(value || '').trim(); + if (!armored || armored.length > MAX_KEY_LENGTH) throw new Error('That key file is empty or too large.'); + return armored; +} + +async function unlock(armoredPrivateKey, passphrase) { + try { + return await openpgp.decryptKey({ + privateKey: await openpgp.readPrivateKey({ armoredKey: armoredPrivateKey }), + passphrase + }); + } catch { + throw new Error('The passphrase is incorrect.'); + } +} + +const TRUST_LEVELS = ['unknown', 'trusted', 'verified']; +const DEFAULT_CACHE_MINUTES = 10; + +function contactInfo(entry) { + return { + fingerprint: entry.fingerprint, + name: entry.name, + emails: entry.emails, + trust: entry.trust, + source: entry.source, + addedAt: entry.addedAt + }; +} + +async function readPublicOnly(value) { + const armored = readArmored(value); + if (/BEGIN PGP PRIVATE KEY BLOCK/.test(armored)) throw new Error('That file contains a private key. Import public keys only.'); + const key = await openpgp.readKey({ armoredKey: armored }).catch(() => { + throw new Error('That is not a valid OpenPGP public key.'); + }); + await key.getPrimaryUser().catch(() => { + throw new Error('That key is expired, revoked or has no valid user ID.'); + }); + return key; +} + +async function keyEmails(key) { + return [...new Set(key.getUserIDs().map(id => (/<([^>]+)>/.exec(id)?.[1] || (id.includes('@') ? id : '')).trim().toLowerCase()).filter(Boolean))]; +} +// Passphrase-protected OpenPGP key storage. `storage` persists one JSON object +// (the desktop app wraps it with the OS credential store before writing it). +function createKeyStore(storage) { + async function read() { + const data = await storage.load(); + return { + keys: Array.isArray(data?.keys) ? data.keys : [], + contacts: Array.isArray(data?.contacts) ? data.contacts : [], + settings: data?.settings && typeof data.settings === 'object' ? data.settings : {} + }; + } + + async function add(entry) { + const data = await read(); + if (data.keys.some(key => key.fingerprint === entry.fingerprint)) { + throw new Error('That key is already in your keyring.'); + } + data.keys.push(entry); + await storage.save(data); + } + + return { + async listContacts() { + return (await read()).contacts.map(contactInfo); + }, + + async addContact({ armoredKey, source = 'import' }) { + const key = await readPublicOnly(armoredKey); + const fingerprint = key.getFingerprint().toUpperCase(); + const emails = await keyEmails(key); + const data = await read(); + if (data.keys.some(entry => entry.fingerprint === fingerprint)) throw new Error('That is one of your own keys.'); + if (data.contacts.some(entry => entry.fingerprint === fingerprint)) throw new Error('That public key is already in your contacts.'); + const user = await key.getPrimaryUser(); + const replaces = data.contacts + .filter(entry => entry.emails.some(email => emails.includes(email))) + .map(entry => entry.fingerprint); + const entry = { + fingerprint, + name: user.user.userID?.name || '', + emails, + trust: 'unknown', + source: ['import', 'message', 'paste', 'keyserver'].includes(source) ? source : 'import', + addedAt: Date.now(), + publicKey: key.armor() + }; + data.contacts.push(entry); + await storage.save(data); + return { contact: contactInfo(entry), keyChangedFrom: replaces }; + }, + + async setTrust(fingerprint, trust) { + if (!TRUST_LEVELS.includes(trust)) throw new Error('Unknown trust level.'); + const data = await read(); + const entry = data.contacts.find(item => item.fingerprint === fingerprint); + if (!entry) throw new Error('That contact key was not found.'); + entry.trust = trust; + await storage.save(data); + return contactInfo(entry); + }, + + async removeContact(fingerprint) { + const data = await read(); + if (!data.contacts.some(item => item.fingerprint === fingerprint)) throw new Error('That contact key was not found.'); + data.contacts = data.contacts.filter(item => item.fingerprint !== fingerprint); + await storage.save(data); + return { removed: true }; + }, + + async exportContact(fingerprint) { + const entry = (await read()).contacts.find(item => item.fingerprint === fingerprint); + if (!entry) throw new Error('That contact key was not found.'); + return entry.publicKey; + }, + + // Resolves public keys for recipient addresses (contacts and own keys). + async findRecipientKeys(addresses) { + const data = await read(); + const pool = [ + ...data.contacts.map(entry => ({ ...entry, own: false })), + ...data.keys.map(entry => ({ fingerprint: entry.fingerprint, emails: [String(entry.email).toLowerCase()], trust: 'verified', addedAt: entry.createdAt, publicKey: entry.publicKey, own: true })) + ]; + const keys = []; + const missing = []; + for (const address of addresses.map(value => String(value).trim().toLowerCase())) { + const candidates = pool + .filter(entry => entry.emails.includes(address)) + .sort((a, b) => TRUST_LEVELS.indexOf(b.trust) - TRUST_LEVELS.indexOf(a.trust) || b.addedAt - a.addedAt); + let usable = null; + for (const candidate of candidates) { + try { + const key = await openpgp.readKey({ armoredKey: candidate.publicKey }); + await key.getEncryptionKey(); + usable = { key, fingerprint: candidate.fingerprint, trust: candidate.trust }; + break; + } catch { /* expired or revoked: try the next key */ } + } + if (usable) keys.push({ address, ...usable }); + else missing.push(address); + } + return { keys, missing }; + }, + + async verificationKeys() { + const data = await read(); + const result = []; + for (const entry of [...data.contacts.map(item => ({ ...item, own: false })), ...data.keys.map(item => ({ ...item, trust: 'verified', emails: [String(item.email).toLowerCase()], own: true }))]) { + try { + result.push({ key: await openpgp.readKey({ armoredKey: entry.publicKey }), fingerprint: entry.fingerprint, trust: entry.trust, emails: entry.emails, own: entry.own }); + } catch { /* skip unreadable entries */ } + } + return result; + }, + + async privateEntries() { + return (await read()).keys.map(entry => ({ fingerprint: entry.fingerprint, email: entry.email, name: entry.name, privateKey: entry.privateKey, publicKey: entry.publicKey })); + }, + + async unlockKey(fingerprint, passphrase) { + const entry = (await read()).keys.find(key => key.fingerprint === fingerprint); + if (!entry) throw new Error('That key was not found.'); + return unlock(entry.privateKey, passphrase); + }, + + async getSettings() { + const settings = (await read()).settings; + return { + cacheMinutes: Number.isFinite(settings.cacheMinutes) ? settings.cacheMinutes : DEFAULT_CACHE_MINUTES, + customKeyServers: Array.isArray(settings.customKeyServers) ? settings.customKeyServers : [], + enabledKeyServers: Array.isArray(settings.enabledKeyServers) + ? [...new Set(settings.enabledKeyServers.filter(id => typeof id === 'string'))] + : [] + }; + }, + + async setSettings({ cacheMinutes, customKeyServers, enabledKeyServers }) { + const minutes = Number(cacheMinutes); + if (!Number.isFinite(minutes) || minutes < 0 || minutes > 1440) throw new Error('Choose between 0 and 1440 minutes.'); + const data = await read(); + data.settings.cacheMinutes = Math.round(minutes); + if (customKeyServers !== undefined) { + if (!Array.isArray(customKeyServers) || customKeyServers.length > 10 || customKeyServers.some(server => !server || typeof server !== 'object')) { + throw new Error('You can configure up to 10 valid custom key servers.'); + } + data.settings.customKeyServers = customKeyServers.map(server => ({ + id: String(server.id || ''), + name: String(server.name || '').slice(0, 60), + url: String(server.url || '').slice(0, 300), + protocol: String(server.protocol || '') + })); + } + if (enabledKeyServers !== undefined) { + if (!Array.isArray(enabledKeyServers) || enabledKeyServers.length > 12 || enabledKeyServers.some(id => typeof id !== 'string' || !id.trim())) { + throw new Error('Choose no more than 12 valid enabled key servers.'); + } + data.settings.enabledKeyServers = [...new Set(enabledKeyServers)]; + } + await storage.save(data); + return { + cacheMinutes: data.settings.cacheMinutes, + customKeyServers: Array.isArray(data.settings.customKeyServers) ? data.settings.customKeyServers : [], + enabledKeyServers: Array.isArray(data.settings.enabledKeyServers) ? [...data.settings.enabledKeyServers] : [] + }; + }, + + async list() { + return (await read()).keys.map(publicInfo); + }, + + async generate({ name, email, passphrase, accountId = null }) { + const cleanName = String(name || '').trim().slice(0, 100); + const cleanEmail = String(email || '').trim(); + if (!/^[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+$/.test(cleanEmail)) throw new Error('Enter a valid email address for the key.'); + requirePassphrase(passphrase); + const { privateKey, publicKey, revocationCertificate } = await openpgp.generateKey({ + type: 'ecc', + curve: 'curve25519Legacy', + userIDs: [{ name: cleanName || undefined, email: cleanEmail }], + passphrase, + format: 'armored' + }); + const key = await openpgp.readKey({ armoredKey: publicKey }); + const entry = { + fingerprint: key.getFingerprint().toUpperCase(), + name: cleanName, + email: cleanEmail, + accountId, + createdAt: Date.now(), + algorithm: 'Curve25519', + privateKey, + publicKey, + revocationCertificate + }; + await add(entry); + return { key: publicInfo(entry), revocationCertificate }; + }, + + async import({ armoredKey, passphrase, accountId = null }) { + const parsed = await openpgp.readPrivateKey({ armoredKey: readArmored(armoredKey) }).catch(() => { + throw new Error('That is not a valid OpenPGP private key.'); + }); + requirePassphrase(passphrase); + let protectedKey; + if (parsed.isDecrypted()) { + protectedKey = await openpgp.encryptKey({ privateKey: parsed, passphrase }); + } else { + await unlock(parsed.armor(), passphrase); + protectedKey = parsed; + } + const user = await protectedKey.getPrimaryUser().catch(() => null); + const entry = { + fingerprint: protectedKey.getFingerprint().toUpperCase(), + name: user?.user?.userID?.name || '', + email: user?.user?.userID?.email || '', + accountId, + createdAt: protectedKey.getCreationTime().getTime(), + algorithm: protectedKey.getAlgorithmInfo().algorithm, + privateKey: protectedKey.armor(), + publicKey: protectedKey.toPublic().armor(), + revocationCertificate: null + }; + await add(entry); + return publicInfo(entry); + }, + + async exportPublic(fingerprint) { + const entry = (await read()).keys.find(key => key.fingerprint === fingerprint); + if (!entry) throw new Error('That key was not found.'); + return entry.publicKey; + }, + + async exportPrivate(fingerprint, passphrase) { + const entry = (await read()).keys.find(key => key.fingerprint === fingerprint); + if (!entry) throw new Error('That key was not found.'); + await unlock(entry.privateKey, passphrase); + return entry.privateKey; + }, + + async changePassphrase(fingerprint, currentPassphrase, newPassphrase) { + requirePassphrase(newPassphrase); + const data = await read(); + const keyIndex = data.keys.findIndex(key => key.fingerprint === fingerprint); + if (keyIndex < 0) throw new Error('That key was not found.'); + const entry = data.keys[keyIndex]; + const privateKey = await unlock(entry.privateKey, currentPassphrase); + const protectedKey = await openpgp.encryptKey({ privateKey, passphrase: newPassphrase }); + const updated = { + ...data, + keys: data.keys.map((key, index) => index === keyIndex + ? { ...key, privateKey: protectedKey.armor() } + : key) + }; + await storage.save(updated); + return { changed: true }; + }, + + async exportRevocation(fingerprint, passphrase) { + const entry = (await read()).keys.find(key => key.fingerprint === fingerprint); + if (!entry) throw new Error('That key was not found.'); + if (!entry.revocationCertificate) throw new Error('No revocation certificate is stored for this key.'); + await unlock(entry.privateKey, passphrase); + return entry.revocationCertificate; + }, + + async remove(fingerprint, passphrase) { + const data = await read(); + const entry = data.keys.find(key => key.fingerprint === fingerprint); + if (!entry) throw new Error('That key was not found.'); + await unlock(entry.privateKey, passphrase); + data.keys = data.keys.filter(key => key.fingerprint !== fingerprint); + await storage.save(data); + return { removed: true }; + } + }; +} + +module.exports = { createKeyStore }; diff --git a/desktop/pgp-mail.cjs b/desktop/pgp-mail.cjs index d75ae88..87577af 100644 --- a/desktop/pgp-mail.cjs +++ b/desktop/pgp-mail.cjs @@ -1,376 +1,376 @@ -const openpgp = require('openpgp'); -const { simpleParser } = require('mailparser'); -const addressParser = require('nodemailer/lib/addressparser'); -const MailComposer = require('nodemailer/lib/mail-composer'); -const { randomBytes } = require('node:crypto'); - -const ARMORED_MESSAGE = /-----BEGIN PGP MESSAGE-----[\s\S]+?-----END PGP MESSAGE-----/; -const CLEARTEXT_SIGNED = /-----BEGIN PGP SIGNED MESSAGE-----[\s\S]+?-----END PGP SIGNATURE-----/; -const MAX_ENCRYPTED_BYTES = 60 * 1048576; - -class PgpError extends Error { - constructor(code, message, details = {}) { - super(message); - this.code = code; - this.details = details; - } -} - -// Remembers unlocked-key passphrases in memory only, for a limited time. -function createPassphraseCache(getMinutes, now = () => Date.now()) { - const entries = new Map(); - return { - async remember(fingerprint, passphrase) { - const minutes = await getMinutes(); - if (!minutes) { entries.delete(fingerprint); return; } - entries.set(fingerprint, { passphrase, expires: now() + minutes * 60000 }); - }, - get(fingerprint) { - const entry = entries.get(fingerprint); - if (!entry) return null; - if (entry.expires <= now()) { entries.delete(fingerprint); return null; } - return entry.passphrase; - }, - has(fingerprint) { return this.get(fingerprint) !== null; }, - clear(fingerprint) { if (fingerprint) entries.delete(fingerprint); else entries.clear(); } - }; -} - -function headerValue(parsed, name) { - const value = parsed.headers?.get(name); - return value && typeof value === 'object' ? value : { value: String(value || ''), params: {} }; -} - -// Classifies a parsed message: encrypted/signed PGP/MIME or inline PGP. -function detect(parsed) { - const type = String(headerValue(parsed, 'content-type').value).toLowerCase(); - const protocol = String(headerValue(parsed, 'content-type').params?.protocol || '').toLowerCase(); - if (type === 'multipart/encrypted' && protocol === 'application/pgp-encrypted') return 'encrypted-mime'; - if (type === 'multipart/signed' && protocol === 'application/pgp-signature') return 'signed-mime'; - const text = String(parsed.text || ''); - if (ARMORED_MESSAGE.test(text)) return 'encrypted-inline'; - if (CLEARTEXT_SIGNED.test(text)) return 'signed-inline'; - return null; -} - -function encryptedArmor(parsed, kind) { - if (kind === 'encrypted-inline') return ARMORED_MESSAGE.exec(String(parsed.text || ''))[0]; - for (const file of parsed.attachments || []) { - const content = file.content.toString('latin1'); - const match = ARMORED_MESSAGE.exec(content); - if (match) return match[0]; - } - throw new PgpError('CORRUPT', 'The encrypted part of this message is missing or damaged.'); -} - -function emailsOf(key) { - return key.getUserIDs().map(id => (/<([^>]+)>/.exec(id)?.[1] || (id.includes('@') ? id : '')).trim().toLowerCase()).filter(Boolean); -} - -function fingerprintsByKeyId(verification) { - const map = new Map(); - for (const item of verification) { - for (const key of item.key.getKeys()) map.set(key.getKeyID().toHex().toUpperCase(), item); - } - return map; -} - -// Interprets signature results and flags a sender whose key changed. -async function describeSignatures(signatures, verification, senderEmail) { - const byKeyId = fingerprintsByKeyId(verification); - const sender = String(senderEmail || '').toLowerCase(); - const results = []; - for (const signature of signatures) { - const keyId = signature.keyID.toHex().toUpperCase(); - const known = byKeyId.get(keyId); - let status; - try { - await signature.verified; - status = 'valid'; - } catch (error) { - status = /could not find signing key|no signing key|not found/i.test(String(error?.message)) || !known ? 'unknown-key' : 'invalid'; - } - const result = { status, keyId, fingerprint: known?.fingerprint || null, trust: known?.trust || null, email: null, matchesSender: false, keyChanged: false }; - if (known) { - result.email = known.emails[0] || null; - result.matchesSender = Boolean(sender) && known.emails.includes(sender); - } - if (sender && status === 'valid' && known && !known.emails.includes(sender)) result.mismatch = true; - if (sender && status !== 'unknown-key') { - const others = verification.filter(item => !item.own && item.emails.includes(sender) && item.fingerprint !== known?.fingerprint); - if (others.length && !result.matchesSender) result.keyChanged = true; - } - if (sender && status === 'unknown-key' && verification.some(item => !item.own && item.emails.includes(sender))) result.keyChanged = true; - results.push(result); - } - return results; -} - -function chunkBase64(buffer) { - return buffer.toString('base64').replace(/(.{76})/g, '$1\r\n').replace(/\r\n$/, ''); -} - -function encodeHeader(value) { - const clean = String(value).replace(/[\r\n]+/g, ' ').trim(); - if (/^[\x20-\x7e]*$/.test(clean) && clean.length <= 900) return clean; - const chars = Array.from(clean); - const words = []; - for (let index = 0; index < chars.length; index += 24) { - words.push(`=?UTF-8?B?${Buffer.from(chars.slice(index, index + 24).join(''), 'utf8').toString('base64')}?=`); - } - return words.join('\r\n '); -} - -function formatAddress(entry) { - const address = String(entry.address || '').trim(); - if (!/^[^\s@<>"',;]+@[^\s@<>"',;]+$/.test(address)) throw new Error(`"${address || entry.name}" is not a valid email address.`); - const name = String(entry.name || '').replace(/[\r\n"\\]+/g, ' ').trim(); - return name ? `${encodeHeader(`"${name}"`)} <${address}>` : address; -} - -function parseAddresses(value) { - return addressParser(String(value || '')).filter(entry => entry.address || entry.name); -} - -async function innerEntity(text, attachments) { - if (attachments.length) { - return new Promise((resolve, reject) => { - new MailComposer({ - text: String(text || ''), - attachments: attachments.map(file => ({ - filename: file.filename, - contentType: file.contentType, - content: file.content - })) - }).compile().build((error, message) => error - ? reject(error) - : resolve(Buffer.from(message.toString('latin1').replace(/\r?\n/g, '\r\n'), 'latin1'))); - }); - } - const body = Buffer.from(String(text || ''), 'utf8'); - return Buffer.from(`Content-Type: text/plain; charset=utf-8\r\nContent-Transfer-Encoding: base64\r\n\r\n${chunkBase64(body)}\r\n`, 'latin1'); -} - -function boundary() { - return `=_ep-${randomBytes(12).toString('hex')}`; -} - -function createPgpMail({ keyStore, cache }) { - async function findDecryptionKey(message) { - const wanted = new Set(message.getEncryptionKeyIDs().map(id => id.toHex().toUpperCase())); - const entries = await keyStore.privateEntries(); - const candidates = []; - for (const entry of entries) { - const publicKey = await openpgp.readKey({ armoredKey: entry.publicKey }); - if (publicKey.getKeys().some(key => wanted.has(key.getKeyID().toHex().toUpperCase()))) candidates.push(entry); - } - if (!candidates.length) throw new PgpError('NO_KEY', 'None of your keys can decrypt this message.'); - return candidates; - } - - async function unlockAny(candidates, passphrase) { - let lastError = null; - for (const candidate of candidates) { - const secret = passphrase || cache.get(candidate.fingerprint); - if (!secret) continue; - try { - const key = await keyStore.unlockKey(candidate.fingerprint, secret); - await cache.remember(candidate.fingerprint, secret); - return key; - } catch (error) { - cache.clear(candidate.fingerprint); - lastError = error; - } - } - if (lastError) throw new PgpError('BAD_PASSPHRASE', 'The passphrase is incorrect.', { fingerprint: candidates[0].fingerprint }); - throw new PgpError('PASSPHRASE_REQUIRED', 'Enter your key passphrase to read this message.', { - fingerprint: candidates[0].fingerprint, email: candidates[0].email - }); - } - - return { - detect, - - async decrypt(parsed, { passphrase = null } = {}) { - const kind = detect(parsed); - if (kind !== 'encrypted-mime' && kind !== 'encrypted-inline') throw new PgpError('NOT_ENCRYPTED', 'This message is not encrypted.'); - const armored = encryptedArmor(parsed, kind); - if (armored.length > MAX_ENCRYPTED_BYTES) throw new PgpError('TOO_LARGE', 'This encrypted message is too large to open.'); - let message; - try { - message = await openpgp.readMessage({ armoredMessage: armored }); - } catch { - throw new PgpError('CORRUPT', 'The encrypted part of this message is damaged.'); - } - const decryptionKey = await unlockAny(await findDecryptionKey(message), passphrase); - const verification = await keyStore.verificationKeys(); - let result; - try { - result = await openpgp.decrypt({ - message, - decryptionKeys: decryptionKey, - verificationKeys: verification.map(item => item.key), - format: 'binary' - }); - } catch { - throw new PgpError('CORRUPT', 'The message could not be decrypted. It may be damaged or altered.'); - } - const data = Buffer.from(result.data); - const sender = parsed.from?.value?.[0]?.address || ''; - const signatures = await describeSignatures(result.signatures, verification, sender); - const inner = kind === 'encrypted-mime' ? await simpleParser(data) : await simpleParser(Buffer.concat([ - Buffer.from('Content-Type: text/plain; charset=utf-8\r\n\r\n'), data - ])); - return { parsed: inner, signatures, attachedKeys: await this.attachedKeys(inner) }; - }, - - // Public keys attached to a message (offered to the user, never added silently). - async attachedKeys(parsed) { - const keys = []; - for (const file of parsed.attachments || []) { - const type = String(file.contentType || '').toLowerCase(); - if (type !== 'application/pgp-keys' && !/\.asc$/i.test(file.filename || '')) continue; - const armored = file.content.toString('utf8'); - if (!/BEGIN PGP PUBLIC KEY BLOCK/.test(armored) || armored.length > 200000) continue; - try { - const key = await openpgp.readKey({ armoredKey: armored }); - keys.push({ armoredKey: armored, fingerprint: key.getFingerprint().toUpperCase(), emails: emailsOf(key) }); - } catch { /* ignore unreadable attachments */ } - } - return keys.slice(0, 5); - }, - - // Verifies PGP/MIME (multipart/signed) and cleartext signatures on unencrypted mail. - async verifySigned(parsed, source) { - const kind = detect(parsed); - const verification = await keyStore.verificationKeys(); - const sender = parsed.from?.value?.[0]?.address || ''; - try { - if (kind === 'signed-inline') { - const message = await openpgp.readCleartextMessage({ cleartextMessage: CLEARTEXT_SIGNED.exec(String(parsed.text))[0] }); - const result = await openpgp.verify({ message, verificationKeys: verification.map(item => item.key) }); - return describeSignatures(result.signatures, verification, sender); - } - if (kind !== 'signed-mime') return null; - const parts = splitSigned(source, headerValue(parsed, 'content-type').params?.boundary); - if (!parts) return [{ status: 'invalid', keyId: '', fingerprint: null, trust: null, email: null, matchesSender: false, keyChanged: false }]; - const signature = await openpgp.readSignature({ armoredSignature: parts.signature }); - const result = await openpgp.verify({ - message: await openpgp.createMessage({ binary: parts.signed }), - signature, - verificationKeys: verification.map(item => item.key) - }); - return describeSignatures(result.signatures, verification, sender); - } catch { - return [{ status: 'invalid', keyId: '', fingerprint: null, trust: null, email: null, matchesSender: false, keyChanged: false }]; - } - }, - - // 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 = [] }) { - const toList = parseAddresses(to); - const ccList = parseAddresses(cc); - if (!toList.length) throw new Error('Add at least one recipient.'); - const everyone = [...toList, ...ccList]; - everyone.forEach(entry => formatAddress(entry)); - let signingKey = null; - let signerEntry = null; - if (sign) { - const entries = await keyStore.privateEntries(); - signerEntry = entries.find(entry => entry.fingerprint === signerFingerprint) - || entries.find(entry => entry.email.toLowerCase() === String(from.address).toLowerCase()); - if (!signerEntry) throw new PgpError('NO_SIGNING_KEY', 'Create or import an encryption key for this address first.'); - const secret = passphrase || cache.get(signerEntry.fingerprint); - if (!secret) throw new PgpError('PASSPHRASE_REQUIRED', 'Enter your key passphrase to sign this message.', { fingerprint: signerEntry.fingerprint, email: signerEntry.email }); - try { - signingKey = await keyStore.unlockKey(signerEntry.fingerprint, secret); - } catch { - cache.clear(signerEntry.fingerprint); - throw new PgpError('BAD_PASSPHRASE', 'The passphrase is incorrect.', { fingerprint: signerEntry.fingerprint }); - } - await cache.remember(signerEntry.fingerprint, secret); - } - const headers = [ - `From: ${formatAddress(from)}`, - `To: ${toList.map(formatAddress).join(', ')}`, - ...(ccList.length ? [`Cc: ${ccList.map(formatAddress).join(', ')}`] : []), - `Subject: ${encodeHeader(subject || '(no subject)')}`, - `Date: ${date.toUTCString().replace('GMT', '+0000')}`, - `Message-ID: ${String(messageId).replace(/[\r\n<>\s]/g, '').replace(/^/, '<').replace(/$/, '>')}`, - 'MIME-Version: 1.0' - ]; - const inner = await innerEntity(text, attachments); - const mark = boundary(); - let body; - let contentType; - if (encrypt) { - const { keys, missing } = await keyStore.findRecipientKeys(everyone.map(entry => entry.address)); - if (missing.length) throw new PgpError('NO_RECIPIENT_KEY', `No public key for ${missing.join(', ')}.`, { missing }); - const own = signerEntry ? [await openpgp.readKey({ armoredKey: signerEntry.publicKey })] : []; - const ownKeys = own.length ? own : (await keyStore.findRecipientKeys([from.address])).keys.map(item => item.key); - const armored = await openpgp.encrypt({ - message: await openpgp.createMessage({ binary: inner }), - encryptionKeys: [...keys.map(item => item.key), ...ownKeys], - signingKeys: signingKey || undefined, - format: 'armored' - }); - contentType = `multipart/encrypted; protocol="application/pgp-encrypted"; boundary="${mark}"`; - body = [ - `--${mark}`, 'Content-Type: application/pgp-encrypted', 'Content-Description: PGP/MIME version identification', '', 'Version: 1', '', - `--${mark}`, 'Content-Type: application/octet-stream; name="encrypted.asc"', 'Content-Description: OpenPGP encrypted message', - 'Content-Disposition: inline; filename="encrypted.asc"', '', String(armored).replace(/\r?\n/g, '\r\n').trim(), '', `--${mark}--`, '' - ].join('\r\n'); - } else if (sign) { - const signedBytes = inner.subarray(0, inner.length - 2); - const detached = await openpgp.sign({ message: await openpgp.createMessage({ binary: signedBytes }), signingKeys: signingKey, detached: true, format: 'armored' }); - contentType = `multipart/signed; protocol="application/pgp-signature"; micalg=pgp-sha256; boundary="${mark}"`; - const signedPart = signedBytes.toString('latin1'); - body = [ - `--${mark}`, signedPart, `--${mark}`, 'Content-Type: application/pgp-signature; name="signature.asc"', - 'Content-Description: OpenPGP digital signature', 'Content-Disposition: attachment; filename="signature.asc"', '', - String(detached).replace(/\r?\n/g, '\r\n').trim(), '', `--${mark}--`, '' - ].join('\r\n'); - } else { - throw new Error('Choose encryption or signing for this message.'); - } - const raw = Buffer.from(`${headers.join('\r\n')}\r\nContent-Type: ${contentType}\r\n\r\n${body}`, 'latin1'); - return { raw, envelope: { from: from.address, to: everyone.map(entry => entry.address) }, signerFingerprint: signerEntry?.fingerprint || null }; - }, - - async recipientStatus(addresses, { sign = false, from = '' } = {}) { - const list = addresses.flatMap(value => parseAddresses(value)).map(entry => entry.address).filter(Boolean); - const { keys, missing } = await keyStore.findRecipientKeys(list); - let signer = null; - if (sign) { - const entries = await keyStore.privateEntries(); - const entry = entries.find(item => item.email.toLowerCase() === String(from).toLowerCase()) || null; - if (entry) signer = { fingerprint: entry.fingerprint, email: entry.email, name: entry.name, unlocked: cache.has(entry.fingerprint) }; - } - return { - recipients: keys.map(item => ({ address: item.address, fingerprint: item.fingerprint, trust: item.trust })), - missing, - signer - }; - } - }; -} - -// Extracts the signed part and detached signature from a multipart/signed source. -function splitSigned(source, boundaryValue) { - if (!boundaryValue) return null; - const text = Buffer.from(source).toString('latin1'); - const escaped = String(boundaryValue).replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); - const delimiter = new RegExp(`(?:^|\\r?\\n)--${escaped}(--)?[ \\t]*(?=\\r?\\n|$)`, 'g'); - const marks = [...text.matchAll(delimiter)]; - if (marks.length < 3) return null; - const contentAfter = mark => { - const lineEnd = text.indexOf('\n', mark.index + mark[0].length); - return lineEnd < 0 ? text.length : lineEnd + 1; - }; - const signed = text.slice(contentAfter(marks[0]), marks[1].index).replace(/\r?\n/g, '\r\n'); - const signaturePart = text.slice(contentAfter(marks[1]), marks[2].index); - const armored = /-----BEGIN PGP SIGNATURE-----[\s\S]+?-----END PGP SIGNATURE-----/.exec(signaturePart)?.[0]; - if (!armored) return null; - return { signed: Buffer.from(signed, 'latin1'), signature: armored }; -} -module.exports = { createPgpMail, createPassphraseCache, detect, PgpError, splitSigned }; +const openpgp = require('openpgp'); +const { simpleParser } = require('mailparser'); +const addressParser = require('nodemailer/lib/addressparser'); +const MailComposer = require('nodemailer/lib/mail-composer'); +const { randomBytes } = require('node:crypto'); + +const ARMORED_MESSAGE = /-----BEGIN PGP MESSAGE-----[\s\S]+?-----END PGP MESSAGE-----/; +const CLEARTEXT_SIGNED = /-----BEGIN PGP SIGNED MESSAGE-----[\s\S]+?-----END PGP SIGNATURE-----/; +const MAX_ENCRYPTED_BYTES = 60 * 1048576; + +class PgpError extends Error { + constructor(code, message, details = {}) { + super(message); + this.code = code; + this.details = details; + } +} + +// Remembers unlocked-key passphrases in memory only, for a limited time. +function createPassphraseCache(getMinutes, now = () => Date.now()) { + const entries = new Map(); + return { + async remember(fingerprint, passphrase) { + const minutes = await getMinutes(); + if (!minutes) { entries.delete(fingerprint); return; } + entries.set(fingerprint, { passphrase, expires: now() + minutes * 60000 }); + }, + get(fingerprint) { + const entry = entries.get(fingerprint); + if (!entry) return null; + if (entry.expires <= now()) { entries.delete(fingerprint); return null; } + return entry.passphrase; + }, + has(fingerprint) { return this.get(fingerprint) !== null; }, + clear(fingerprint) { if (fingerprint) entries.delete(fingerprint); else entries.clear(); } + }; +} + +function headerValue(parsed, name) { + const value = parsed.headers?.get(name); + return value && typeof value === 'object' ? value : { value: String(value || ''), params: {} }; +} + +// Classifies a parsed message: encrypted/signed PGP/MIME or inline PGP. +function detect(parsed) { + const type = String(headerValue(parsed, 'content-type').value).toLowerCase(); + const protocol = String(headerValue(parsed, 'content-type').params?.protocol || '').toLowerCase(); + if (type === 'multipart/encrypted' && protocol === 'application/pgp-encrypted') return 'encrypted-mime'; + if (type === 'multipart/signed' && protocol === 'application/pgp-signature') return 'signed-mime'; + const text = String(parsed.text || ''); + if (ARMORED_MESSAGE.test(text)) return 'encrypted-inline'; + if (CLEARTEXT_SIGNED.test(text)) return 'signed-inline'; + return null; +} + +function encryptedArmor(parsed, kind) { + if (kind === 'encrypted-inline') return ARMORED_MESSAGE.exec(String(parsed.text || ''))[0]; + for (const file of parsed.attachments || []) { + const content = file.content.toString('latin1'); + const match = ARMORED_MESSAGE.exec(content); + if (match) return match[0]; + } + throw new PgpError('CORRUPT', 'The encrypted part of this message is missing or damaged.'); +} + +function emailsOf(key) { + return key.getUserIDs().map(id => (/<([^>]+)>/.exec(id)?.[1] || (id.includes('@') ? id : '')).trim().toLowerCase()).filter(Boolean); +} + +function fingerprintsByKeyId(verification) { + const map = new Map(); + for (const item of verification) { + for (const key of item.key.getKeys()) map.set(key.getKeyID().toHex().toUpperCase(), item); + } + return map; +} + +// Interprets signature results and flags a sender whose key changed. +async function describeSignatures(signatures, verification, senderEmail) { + const byKeyId = fingerprintsByKeyId(verification); + const sender = String(senderEmail || '').toLowerCase(); + const results = []; + for (const signature of signatures) { + const keyId = signature.keyID.toHex().toUpperCase(); + const known = byKeyId.get(keyId); + let status; + try { + await signature.verified; + status = 'valid'; + } catch (error) { + status = /could not find signing key|no signing key|not found/i.test(String(error?.message)) || !known ? 'unknown-key' : 'invalid'; + } + const result = { status, keyId, fingerprint: known?.fingerprint || null, trust: known?.trust || null, email: null, matchesSender: false, keyChanged: false }; + if (known) { + result.email = known.emails[0] || null; + result.matchesSender = Boolean(sender) && known.emails.includes(sender); + } + if (sender && status === 'valid' && known && !known.emails.includes(sender)) result.mismatch = true; + if (sender && status !== 'unknown-key') { + const others = verification.filter(item => !item.own && item.emails.includes(sender) && item.fingerprint !== known?.fingerprint); + if (others.length && !result.matchesSender) result.keyChanged = true; + } + if (sender && status === 'unknown-key' && verification.some(item => !item.own && item.emails.includes(sender))) result.keyChanged = true; + results.push(result); + } + return results; +} + +function chunkBase64(buffer) { + return buffer.toString('base64').replace(/(.{76})/g, '$1\r\n').replace(/\r\n$/, ''); +} + +function encodeHeader(value) { + const clean = String(value).replace(/[\r\n]+/g, ' ').trim(); + if (/^[\x20-\x7e]*$/.test(clean) && clean.length <= 900) return clean; + const chars = Array.from(clean); + const words = []; + for (let index = 0; index < chars.length; index += 24) { + words.push(`=?UTF-8?B?${Buffer.from(chars.slice(index, index + 24).join(''), 'utf8').toString('base64')}?=`); + } + return words.join('\r\n '); +} + +function formatAddress(entry) { + const address = String(entry.address || '').trim(); + if (!/^[^\s@<>"',;]+@[^\s@<>"',;]+$/.test(address)) throw new Error(`"${address || entry.name}" is not a valid email address.`); + const name = String(entry.name || '').replace(/[\r\n"\\]+/g, ' ').trim(); + return name ? `${encodeHeader(`"${name}"`)} <${address}>` : address; +} + +function parseAddresses(value) { + return addressParser(String(value || '')).filter(entry => entry.address || entry.name); +} + +async function innerEntity(text, attachments) { + if (attachments.length) { + return new Promise((resolve, reject) => { + new MailComposer({ + text: String(text || ''), + attachments: attachments.map(file => ({ + filename: file.filename, + contentType: file.contentType, + content: file.content + })) + }).compile().build((error, message) => error + ? reject(error) + : resolve(Buffer.from(message.toString('latin1').replace(/\r?\n/g, '\r\n'), 'latin1'))); + }); + } + const body = Buffer.from(String(text || ''), 'utf8'); + return Buffer.from(`Content-Type: text/plain; charset=utf-8\r\nContent-Transfer-Encoding: base64\r\n\r\n${chunkBase64(body)}\r\n`, 'latin1'); +} + +function boundary() { + return `=_ep-${randomBytes(12).toString('hex')}`; +} + +function createPgpMail({ keyStore, cache }) { + async function findDecryptionKey(message) { + const wanted = new Set(message.getEncryptionKeyIDs().map(id => id.toHex().toUpperCase())); + const entries = await keyStore.privateEntries(); + const candidates = []; + for (const entry of entries) { + const publicKey = await openpgp.readKey({ armoredKey: entry.publicKey }); + if (publicKey.getKeys().some(key => wanted.has(key.getKeyID().toHex().toUpperCase()))) candidates.push(entry); + } + if (!candidates.length) throw new PgpError('NO_KEY', 'None of your keys can decrypt this message.'); + return candidates; + } + + async function unlockAny(candidates, passphrase) { + let lastError = null; + for (const candidate of candidates) { + const secret = passphrase || cache.get(candidate.fingerprint); + if (!secret) continue; + try { + const key = await keyStore.unlockKey(candidate.fingerprint, secret); + await cache.remember(candidate.fingerprint, secret); + return key; + } catch (error) { + cache.clear(candidate.fingerprint); + lastError = error; + } + } + if (lastError) throw new PgpError('BAD_PASSPHRASE', 'The passphrase is incorrect.', { fingerprint: candidates[0].fingerprint }); + throw new PgpError('PASSPHRASE_REQUIRED', 'Enter your key passphrase to read this message.', { + fingerprint: candidates[0].fingerprint, email: candidates[0].email + }); + } + + return { + detect, + + async decrypt(parsed, { passphrase = null } = {}) { + const kind = detect(parsed); + if (kind !== 'encrypted-mime' && kind !== 'encrypted-inline') throw new PgpError('NOT_ENCRYPTED', 'This message is not encrypted.'); + const armored = encryptedArmor(parsed, kind); + if (armored.length > MAX_ENCRYPTED_BYTES) throw new PgpError('TOO_LARGE', 'This encrypted message is too large to open.'); + let message; + try { + message = await openpgp.readMessage({ armoredMessage: armored }); + } catch { + throw new PgpError('CORRUPT', 'The encrypted part of this message is damaged.'); + } + const decryptionKey = await unlockAny(await findDecryptionKey(message), passphrase); + const verification = await keyStore.verificationKeys(); + let result; + try { + result = await openpgp.decrypt({ + message, + decryptionKeys: decryptionKey, + verificationKeys: verification.map(item => item.key), + format: 'binary' + }); + } catch { + throw new PgpError('CORRUPT', 'The message could not be decrypted. It may be damaged or altered.'); + } + const data = Buffer.from(result.data); + const sender = parsed.from?.value?.[0]?.address || ''; + const signatures = await describeSignatures(result.signatures, verification, sender); + const inner = kind === 'encrypted-mime' ? await simpleParser(data) : await simpleParser(Buffer.concat([ + Buffer.from('Content-Type: text/plain; charset=utf-8\r\n\r\n'), data + ])); + return { parsed: inner, signatures, attachedKeys: await this.attachedKeys(inner) }; + }, + + // Public keys attached to a message (offered to the user, never added silently). + async attachedKeys(parsed) { + const keys = []; + for (const file of parsed.attachments || []) { + const type = String(file.contentType || '').toLowerCase(); + if (type !== 'application/pgp-keys' && !/\.asc$/i.test(file.filename || '')) continue; + const armored = file.content.toString('utf8'); + if (!/BEGIN PGP PUBLIC KEY BLOCK/.test(armored) || armored.length > 200000) continue; + try { + const key = await openpgp.readKey({ armoredKey: armored }); + keys.push({ armoredKey: armored, fingerprint: key.getFingerprint().toUpperCase(), emails: emailsOf(key) }); + } catch { /* ignore unreadable attachments */ } + } + return keys.slice(0, 5); + }, + + // Verifies PGP/MIME (multipart/signed) and cleartext signatures on unencrypted mail. + async verifySigned(parsed, source) { + const kind = detect(parsed); + const verification = await keyStore.verificationKeys(); + const sender = parsed.from?.value?.[0]?.address || ''; + try { + if (kind === 'signed-inline') { + const message = await openpgp.readCleartextMessage({ cleartextMessage: CLEARTEXT_SIGNED.exec(String(parsed.text))[0] }); + const result = await openpgp.verify({ message, verificationKeys: verification.map(item => item.key) }); + return describeSignatures(result.signatures, verification, sender); + } + if (kind !== 'signed-mime') return null; + const parts = splitSigned(source, headerValue(parsed, 'content-type').params?.boundary); + if (!parts) return [{ status: 'invalid', keyId: '', fingerprint: null, trust: null, email: null, matchesSender: false, keyChanged: false }]; + const signature = await openpgp.readSignature({ armoredSignature: parts.signature }); + const result = await openpgp.verify({ + message: await openpgp.createMessage({ binary: parts.signed }), + signature, + verificationKeys: verification.map(item => item.key) + }); + return describeSignatures(result.signatures, verification, sender); + } catch { + return [{ status: 'invalid', keyId: '', fingerprint: null, trust: null, email: null, matchesSender: false, keyChanged: false }]; + } + }, + + // 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 = [] }) { + const toList = parseAddresses(to); + const ccList = parseAddresses(cc); + if (!toList.length) throw new Error('Add at least one recipient.'); + const everyone = [...toList, ...ccList]; + everyone.forEach(entry => formatAddress(entry)); + let signingKey = null; + let signerEntry = null; + if (sign) { + const entries = await keyStore.privateEntries(); + signerEntry = entries.find(entry => entry.fingerprint === signerFingerprint) + || entries.find(entry => entry.email.toLowerCase() === String(from.address).toLowerCase()); + if (!signerEntry) throw new PgpError('NO_SIGNING_KEY', 'Create or import an encryption key for this address first.'); + const secret = passphrase || cache.get(signerEntry.fingerprint); + if (!secret) throw new PgpError('PASSPHRASE_REQUIRED', 'Enter your key passphrase to sign this message.', { fingerprint: signerEntry.fingerprint, email: signerEntry.email }); + try { + signingKey = await keyStore.unlockKey(signerEntry.fingerprint, secret); + } catch { + cache.clear(signerEntry.fingerprint); + throw new PgpError('BAD_PASSPHRASE', 'The passphrase is incorrect.', { fingerprint: signerEntry.fingerprint }); + } + await cache.remember(signerEntry.fingerprint, secret); + } + const headers = [ + `From: ${formatAddress(from)}`, + `To: ${toList.map(formatAddress).join(', ')}`, + ...(ccList.length ? [`Cc: ${ccList.map(formatAddress).join(', ')}`] : []), + `Subject: ${encodeHeader(subject || '(no subject)')}`, + `Date: ${date.toUTCString().replace('GMT', '+0000')}`, + `Message-ID: ${String(messageId).replace(/[\r\n<>\s]/g, '').replace(/^/, '<').replace(/$/, '>')}`, + 'MIME-Version: 1.0' + ]; + const inner = await innerEntity(text, attachments); + const mark = boundary(); + let body; + let contentType; + if (encrypt) { + const { keys, missing } = await keyStore.findRecipientKeys(everyone.map(entry => entry.address)); + if (missing.length) throw new PgpError('NO_RECIPIENT_KEY', `No public key for ${missing.join(', ')}.`, { missing }); + const own = signerEntry ? [await openpgp.readKey({ armoredKey: signerEntry.publicKey })] : []; + const ownKeys = own.length ? own : (await keyStore.findRecipientKeys([from.address])).keys.map(item => item.key); + const armored = await openpgp.encrypt({ + message: await openpgp.createMessage({ binary: inner }), + encryptionKeys: [...keys.map(item => item.key), ...ownKeys], + signingKeys: signingKey || undefined, + format: 'armored' + }); + contentType = `multipart/encrypted; protocol="application/pgp-encrypted"; boundary="${mark}"`; + body = [ + `--${mark}`, 'Content-Type: application/pgp-encrypted', 'Content-Description: PGP/MIME version identification', '', 'Version: 1', '', + `--${mark}`, 'Content-Type: application/octet-stream; name="encrypted.asc"', 'Content-Description: OpenPGP encrypted message', + 'Content-Disposition: inline; filename="encrypted.asc"', '', String(armored).replace(/\r?\n/g, '\r\n').trim(), '', `--${mark}--`, '' + ].join('\r\n'); + } else if (sign) { + const signedBytes = inner.subarray(0, inner.length - 2); + const detached = await openpgp.sign({ message: await openpgp.createMessage({ binary: signedBytes }), signingKeys: signingKey, detached: true, format: 'armored' }); + contentType = `multipart/signed; protocol="application/pgp-signature"; micalg=pgp-sha256; boundary="${mark}"`; + const signedPart = signedBytes.toString('latin1'); + body = [ + `--${mark}`, signedPart, `--${mark}`, 'Content-Type: application/pgp-signature; name="signature.asc"', + 'Content-Description: OpenPGP digital signature', 'Content-Disposition: attachment; filename="signature.asc"', '', + String(detached).replace(/\r?\n/g, '\r\n').trim(), '', `--${mark}--`, '' + ].join('\r\n'); + } else { + throw new Error('Choose encryption or signing for this message.'); + } + const raw = Buffer.from(`${headers.join('\r\n')}\r\nContent-Type: ${contentType}\r\n\r\n${body}`, 'latin1'); + return { raw, envelope: { from: from.address, to: everyone.map(entry => entry.address) }, signerFingerprint: signerEntry?.fingerprint || null }; + }, + + async recipientStatus(addresses, { sign = false, from = '' } = {}) { + const list = addresses.flatMap(value => parseAddresses(value)).map(entry => entry.address).filter(Boolean); + const { keys, missing } = await keyStore.findRecipientKeys(list); + let signer = null; + if (sign) { + const entries = await keyStore.privateEntries(); + const entry = entries.find(item => item.email.toLowerCase() === String(from).toLowerCase()) || null; + if (entry) signer = { fingerprint: entry.fingerprint, email: entry.email, name: entry.name, unlocked: cache.has(entry.fingerprint) }; + } + return { + recipients: keys.map(item => ({ address: item.address, fingerprint: item.fingerprint, trust: item.trust })), + missing, + signer + }; + } + }; +} + +// Extracts the signed part and detached signature from a multipart/signed source. +function splitSigned(source, boundaryValue) { + if (!boundaryValue) return null; + const text = Buffer.from(source).toString('latin1'); + const escaped = String(boundaryValue).replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); + const delimiter = new RegExp(`(?:^|\\r?\\n)--${escaped}(--)?[ \\t]*(?=\\r?\\n|$)`, 'g'); + const marks = [...text.matchAll(delimiter)]; + if (marks.length < 3) return null; + const contentAfter = mark => { + const lineEnd = text.indexOf('\n', mark.index + mark[0].length); + return lineEnd < 0 ? text.length : lineEnd + 1; + }; + const signed = text.slice(contentAfter(marks[0]), marks[1].index).replace(/\r?\n/g, '\r\n'); + const signaturePart = text.slice(contentAfter(marks[1]), marks[2].index); + const armored = /-----BEGIN PGP SIGNATURE-----[\s\S]+?-----END PGP SIGNATURE-----/.exec(signaturePart)?.[0]; + if (!armored) return null; + return { signed: Buffer.from(signed, 'latin1'), signature: armored }; +} +module.exports = { createPgpMail, createPassphraseCache, detect, PgpError, splitSigned }; diff --git a/desktop/preload.cjs b/desktop/preload.cjs index 715aa60..5516529 100644 --- a/desktop/preload.cjs +++ b/desktop/preload.cjs @@ -1,62 +1,62 @@ -const { contextBridge, ipcRenderer } = require('electron'); - -contextBridge.exposeInMainWorld('daybreakMail', { - getAppVersion: () => ipcRenderer.invoke('app:get-version'), +const { contextBridge, ipcRenderer } = require('electron'); + +contextBridge.exposeInMainWorld('daybreakMail', { + getAppVersion: () => ipcRenderer.invoke('app:get-version'), getAccount: () => ipcRenderer.invoke('mail:get-account'), listAccounts: () => ipcRenderer.invoke('mail:list-accounts'), listOAuthProviders: () => ipcRenderer.invoke('mail:list-oauth-providers'), - selectAccount: id => ipcRenderer.invoke('mail:select-account', id), - removeAccount: id => ipcRenderer.invoke('mail:remove-account', id), - connect: details => ipcRenderer.invoke('mail:connect', details), - updateAccount: (id, details) => ipcRenderer.invoke('mail:update-account', id, details), - syncFolder: (folder, offset, filters) => ipcRenderer.invoke('mail:sync-folder', folder, offset, filters), - listFolders: () => ipcRenderer.invoke('mail:list-folders'), - createFolder: name => ipcRenderer.invoke('mail:create-folder', { name }), - listDrafts: () => ipcRenderer.invoke('mail:list-drafts'), - saveDraft: draft => ipcRenderer.invoke('mail:save-draft', draft), - deleteDraft: id => ipcRenderer.invoke('mail:delete-draft', id), - syncInbox: () => ipcRenderer.invoke('mail:sync-folder', 'INBOX'), - onSyncUpdate: callback => ipcRenderer.on('mail:sync-update', (_event, update) => callback(update)), - updateMessage: details => ipcRenderer.invoke('mail:update-message', details), - setSnooze: details => ipcRenderer.invoke('mail:set-snooze', details), - previewAttachment: details => ipcRenderer.invoke('mail:preview-attachment', details), - saveAttachment: details => ipcRenderer.invoke('mail:save-attachment', details), - openExternal: url => ipcRenderer.invoke('mail:open-external', url), - send: message => ipcRenderer.invoke('mail:send', message), - disconnect: id => ipcRenderer.invoke('mail:disconnect', id), - pgp: { - list: () => ipcRenderer.invoke('pgp:list'), - generate: details => ipcRenderer.invoke('pgp:generate', details), - importKey: details => ipcRenderer.invoke('pgp:import', details), - exportPublic: fingerprint => ipcRenderer.invoke('pgp:export-public', fingerprint), - exportPrivate: (fingerprint, passphrase) => ipcRenderer.invoke('pgp:export-private', fingerprint, passphrase), - changePassphrase: details => ipcRenderer.invoke('pgp:change-passphrase', details), - exportRevocation: (fingerprint, passphrase) => ipcRenderer.invoke('pgp:export-revocation', fingerprint, passphrase), - remove: (fingerprint, passphrase) => ipcRenderer.invoke('pgp:delete', fingerprint, passphrase), - decryptMessage: details => ipcRenderer.invoke('pgp:decrypt-message', details), - checkSend: details => ipcRenderer.invoke('pgp:check-send', details), - contacts: () => ipcRenderer.invoke('pgp:contacts'), - addContact: details => ipcRenderer.invoke('pgp:add-contact', details), - setTrust: (fingerprint, trust) => ipcRenderer.invoke('pgp:set-trust', fingerprint, trust), - removeContact: fingerprint => ipcRenderer.invoke('pgp:remove-contact', fingerprint), - exportContact: fingerprint => ipcRenderer.invoke('pgp:export-contact', fingerprint), - getSettings: () => ipcRenderer.invoke('pgp:get-settings'), - setSettings: settings => ipcRenderer.invoke('pgp:set-settings', settings), - forgetPassphrases: () => ipcRenderer.invoke('pgp:forget-passphrases'), - keyServers: () => ipcRenderer.invoke('pgp:key-servers'), - setKeyServerEnabled: (serverId, enabled) => ipcRenderer.invoke('pgp:set-key-server-enabled', { serverId, enabled }), - addKeyServer: server => ipcRenderer.invoke('pgp:add-key-server', server), - removeKeyServer: id => ipcRenderer.invoke('pgp:remove-key-server', id), - findKey: details => ipcRenderer.invoke('pgp:find-key', details), - publishKey: details => ipcRenderer.invoke('pgp:publish-key', details) - }, - davList: () => ipcRenderer.invoke('dav:list'), - davConnect: config => ipcRenderer.invoke('dav:connect', config), - davActivate: (type, id) => ipcRenderer.invoke('dav:activate', { type, id }), - davRemove: (type, id) => ipcRenderer.invoke('dav:remove', { type, id }), - davSync: type => ipcRenderer.invoke('dav:sync', type), - davSaveEvent: event => ipcRenderer.invoke('dav:save-event', event), - davDeleteEvent: remote => ipcRenderer.invoke('dav:delete-event', remote), - davSaveContact: contact => ipcRenderer.invoke('dav:save-contact', contact), - davDeleteContact: remote => ipcRenderer.invoke('dav:delete-contact', remote) -}); + selectAccount: id => ipcRenderer.invoke('mail:select-account', id), + removeAccount: id => ipcRenderer.invoke('mail:remove-account', id), + connect: details => ipcRenderer.invoke('mail:connect', details), + updateAccount: (id, details) => ipcRenderer.invoke('mail:update-account', id, details), + syncFolder: (folder, offset, filters) => ipcRenderer.invoke('mail:sync-folder', folder, offset, filters), + listFolders: () => ipcRenderer.invoke('mail:list-folders'), + createFolder: name => ipcRenderer.invoke('mail:create-folder', { name }), + listDrafts: () => ipcRenderer.invoke('mail:list-drafts'), + saveDraft: draft => ipcRenderer.invoke('mail:save-draft', draft), + deleteDraft: id => ipcRenderer.invoke('mail:delete-draft', id), + syncInbox: () => ipcRenderer.invoke('mail:sync-folder', 'INBOX'), + onSyncUpdate: callback => ipcRenderer.on('mail:sync-update', (_event, update) => callback(update)), + updateMessage: details => ipcRenderer.invoke('mail:update-message', details), + setSnooze: details => ipcRenderer.invoke('mail:set-snooze', details), + previewAttachment: details => ipcRenderer.invoke('mail:preview-attachment', details), + saveAttachment: details => ipcRenderer.invoke('mail:save-attachment', details), + openExternal: url => ipcRenderer.invoke('mail:open-external', url), + send: message => ipcRenderer.invoke('mail:send', message), + disconnect: id => ipcRenderer.invoke('mail:disconnect', id), + pgp: { + list: () => ipcRenderer.invoke('pgp:list'), + generate: details => ipcRenderer.invoke('pgp:generate', details), + importKey: details => ipcRenderer.invoke('pgp:import', details), + exportPublic: fingerprint => ipcRenderer.invoke('pgp:export-public', fingerprint), + exportPrivate: (fingerprint, passphrase) => ipcRenderer.invoke('pgp:export-private', fingerprint, passphrase), + changePassphrase: details => ipcRenderer.invoke('pgp:change-passphrase', details), + exportRevocation: (fingerprint, passphrase) => ipcRenderer.invoke('pgp:export-revocation', fingerprint, passphrase), + remove: (fingerprint, passphrase) => ipcRenderer.invoke('pgp:delete', fingerprint, passphrase), + decryptMessage: details => ipcRenderer.invoke('pgp:decrypt-message', details), + checkSend: details => ipcRenderer.invoke('pgp:check-send', details), + contacts: () => ipcRenderer.invoke('pgp:contacts'), + addContact: details => ipcRenderer.invoke('pgp:add-contact', details), + setTrust: (fingerprint, trust) => ipcRenderer.invoke('pgp:set-trust', fingerprint, trust), + removeContact: fingerprint => ipcRenderer.invoke('pgp:remove-contact', fingerprint), + exportContact: fingerprint => ipcRenderer.invoke('pgp:export-contact', fingerprint), + getSettings: () => ipcRenderer.invoke('pgp:get-settings'), + setSettings: settings => ipcRenderer.invoke('pgp:set-settings', settings), + forgetPassphrases: () => ipcRenderer.invoke('pgp:forget-passphrases'), + keyServers: () => ipcRenderer.invoke('pgp:key-servers'), + setKeyServerEnabled: (serverId, enabled) => ipcRenderer.invoke('pgp:set-key-server-enabled', { serverId, enabled }), + addKeyServer: server => ipcRenderer.invoke('pgp:add-key-server', server), + removeKeyServer: id => ipcRenderer.invoke('pgp:remove-key-server', id), + findKey: details => ipcRenderer.invoke('pgp:find-key', details), + publishKey: details => ipcRenderer.invoke('pgp:publish-key', details) + }, + davList: () => ipcRenderer.invoke('dav:list'), + davConnect: config => ipcRenderer.invoke('dav:connect', config), + davActivate: (type, id) => ipcRenderer.invoke('dav:activate', { type, id }), + davRemove: (type, id) => ipcRenderer.invoke('dav:remove', { type, id }), + davSync: type => ipcRenderer.invoke('dav:sync', type), + davSaveEvent: event => ipcRenderer.invoke('dav:save-event', event), + davDeleteEvent: remote => ipcRenderer.invoke('dav:delete-event', remote), + davSaveContact: contact => ipcRenderer.invoke('dav:save-contact', contact), + davDeleteContact: remote => ipcRenderer.invoke('dav:delete-contact', remote) +}); diff --git a/icon.svg b/icon.svg index 72dfd11..2153dec 100644 --- a/icon.svg +++ b/icon.svg @@ -1,10 +1,10 @@ - - - - - - - - - - + + + + + + + + + + diff --git a/index.html b/index.html index 67c039b..4616172 100644 --- a/index.html +++ b/index.html @@ -1,67 +1,67 @@ - - - - - - - - - ep-mail - - - - - -
- - - - -
-
⌕⌘ K
- -
-
-

Good morning

-
1–8 of 24
-
-
All caught up with your mail
-
-
-
- - - -
-
+ + + + + + + + + ep-mail + + + + + +
+ + + + +
+
⌕⌘ K
+ +
+
+

Good morning

+
1–8 of 24
+
+
All caught up with your mail
+
+
+
+ + + +
+
@@ -70,13 +70,13 @@ - - + + - - - - - - + + + + + + diff --git a/logo-ep-daylight.svg b/logo-ep-daylight.svg index ffd0b2c..986c571 100644 --- a/logo-ep-daylight.svg +++ b/logo-ep-daylight.svg @@ -1,9 +1,9 @@ - + diff --git a/logo-ep-wasteland.svg b/logo-ep-wasteland.svg index d4dbe6e..b01b7a9 100644 --- a/logo-ep-wasteland.svg +++ b/logo-ep-wasteland.svg @@ -1,9 +1,9 @@ - + diff --git a/mail-ui.js b/mail-ui.js index f62aec3..c3a4302 100644 --- a/mail-ui.js +++ b/mail-ui.js @@ -17,217 +17,217 @@ const mailFeatureState = { selectedDraftIds: new Set() }; -const senderBrandDomains = { - amazon: ['amazon.com', 'amazon.co.uk'], - apple: ['apple.com', 'icloud.com'], - google: ['google.com', 'gmail.com'], - microsoft: ['microsoft.com', 'outlook.com', 'live.com'], - paypal: ['paypal.com'] -}; - -function suspiciousSenderReasons(message) { - const email = String(message.email || '').trim().toLowerCase(); - const domain = email.split('@').pop() || ''; - if (!domain) return []; - const reasons = []; - if (domain.includes('xn--')) reasons.push('The sender address uses an internationalized domain that may imitate another domain.'); - const name = String(message.sender || '').toLowerCase(); - for (const [brand, domains] of Object.entries(senderBrandDomains)) { - const brandName = new RegExp(`^(?:the\\s+)?${brand}(?:\\s+(?:customer\\s+service|support|security|account|billing|team|payments?|services?))*$`, 'i'); - if (brandName.test(name) && !domains.some(allowed => domain === allowed || domain.endsWith(`.${allowed}`))) { - reasons.push(`The display name mentions ${brand}, but the sender domain is ${domain}.`); - } - } - if (/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(name) && name.split('@').pop() !== domain) { - reasons.push('The address-like display name does not match the actual sender domain.'); - } - return [...new Set(reasons)]; -} - -function inspectMailLink(raw) { - const cleaned = String(raw).replace(/[.,!?;:)\]}>"']+$/g, ''); - let parsed; - try { parsed = new URL(cleaned); } catch { return null; } - if (!['http:', 'https:'].includes(parsed.protocol) || parsed.username || parsed.password) return null; - const host = parsed.hostname.toLowerCase(); - const reasons = []; - if (parsed.protocol === 'http:') reasons.push('unencrypted HTTP connection'); - if (host.includes('xn--')) reasons.push('internationalized domain that may imitate another address'); - if (/^(?:\d{1,3}\.){3}\d{1,3}$/.test(host) || host.startsWith('[')) reasons.push('IP-address destination instead of a named website'); - if (['bit.ly', 't.co', 'tinyurl.com', 'is.gd', 'lnkd.in'].includes(host)) reasons.push('shortened link hides its final destination'); - for (const [brand, domains] of Object.entries(senderBrandDomains)) { - const mentionsBrand = new RegExp(`(^|[.-])${brand.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')}([.-]|$)`, 'i').test(host); - if (mentionsBrand && !domains.some(domain => host === domain || host.endsWith(`.${domain}`))) { - reasons.push(`hostname mentions ${brand} without using its usual domain`); - } - } - return { url: parsed.href, host, reasons }; -} - -function messageLinks(message) { - const bodyLinks = (message.body || []).join('\n').match(/https?:\/\/[^\s<>"']+/gi) || []; - const declaredLinks = Array.isArray(message.links) ? message.links : []; - return [...new Set([...bodyLinks, ...declaredLinks])] - .map(inspectMailLink) - .filter(Boolean) - .slice(0, 30); -} - +const senderBrandDomains = { + amazon: ['amazon.com', 'amazon.co.uk'], + apple: ['apple.com', 'icloud.com'], + google: ['google.com', 'gmail.com'], + microsoft: ['microsoft.com', 'outlook.com', 'live.com'], + paypal: ['paypal.com'] +}; + +function suspiciousSenderReasons(message) { + const email = String(message.email || '').trim().toLowerCase(); + const domain = email.split('@').pop() || ''; + if (!domain) return []; + const reasons = []; + if (domain.includes('xn--')) reasons.push('The sender address uses an internationalized domain that may imitate another domain.'); + const name = String(message.sender || '').toLowerCase(); + for (const [brand, domains] of Object.entries(senderBrandDomains)) { + const brandName = new RegExp(`^(?:the\\s+)?${brand}(?:\\s+(?:customer\\s+service|support|security|account|billing|team|payments?|services?))*$`, 'i'); + if (brandName.test(name) && !domains.some(allowed => domain === allowed || domain.endsWith(`.${allowed}`))) { + reasons.push(`The display name mentions ${brand}, but the sender domain is ${domain}.`); + } + } + if (/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(name) && name.split('@').pop() !== domain) { + reasons.push('The address-like display name does not match the actual sender domain.'); + } + return [...new Set(reasons)]; +} + +function inspectMailLink(raw) { + const cleaned = String(raw).replace(/[.,!?;:)\]}>"']+$/g, ''); + let parsed; + try { parsed = new URL(cleaned); } catch { return null; } + if (!['http:', 'https:'].includes(parsed.protocol) || parsed.username || parsed.password) return null; + const host = parsed.hostname.toLowerCase(); + const reasons = []; + if (parsed.protocol === 'http:') reasons.push('unencrypted HTTP connection'); + if (host.includes('xn--')) reasons.push('internationalized domain that may imitate another address'); + if (/^(?:\d{1,3}\.){3}\d{1,3}$/.test(host) || host.startsWith('[')) reasons.push('IP-address destination instead of a named website'); + if (['bit.ly', 't.co', 'tinyurl.com', 'is.gd', 'lnkd.in'].includes(host)) reasons.push('shortened link hides its final destination'); + for (const [brand, domains] of Object.entries(senderBrandDomains)) { + const mentionsBrand = new RegExp(`(^|[.-])${brand.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')}([.-]|$)`, 'i').test(host); + if (mentionsBrand && !domains.some(domain => host === domain || host.endsWith(`.${domain}`))) { + reasons.push(`hostname mentions ${brand} without using its usual domain`); + } + } + return { url: parsed.href, host, reasons }; +} + +function messageLinks(message) { + const bodyLinks = (message.body || []).join('\n').match(/https?:\/\/[^\s<>"']+/gi) || []; + const declaredLinks = Array.isArray(message.links) ? message.links : []; + return [...new Set([...bodyLinks, ...declaredLinks])] + .map(inspectMailLink) + .filter(Boolean) + .slice(0, 30); +} + appShell.wrapOpenMessage(originalOpenMessage => function (id) { - originalOpenMessage(id); - const message = rendererState.messages.find(item => item.id === id); - if (!message) return; - const senderReasons = suspiciousSenderReasons(message); - const links = messageLinks(message); - const warnings = []; - if (senderReasons.length) { - warnings.push(``); - } - const linkCards = links.map((link, index) => ` - `).join(''); - const reader = selectMailUi('#reader-pane'); - const header = reader.querySelector('.reader-header'); - if (warnings.length && header) header.insertAdjacentHTML('afterend', warnings.join('')); - const replyBar = reader.querySelector('.reply-bar'); - if (links.length && replyBar) { - replyBar.insertAdjacentHTML('beforebegin', ``); - reader.querySelectorAll('[data-mail-link]').forEach(button => { - button.onclick = async () => { - const link = links[Number(button.dataset.mailLink)]; - if (!link) return; - button.disabled = true; - try { - await window.daybreakMail.openExternal(link.url); - } catch (error) { - toastMailUi(error.message || 'Could not open this link'); - } finally { - button.disabled = false; - } - }; - }); - } + originalOpenMessage(id); + const message = rendererState.messages.find(item => item.id === id); + if (!message) return; + const senderReasons = suspiciousSenderReasons(message); + const links = messageLinks(message); + const warnings = []; + if (senderReasons.length) { + warnings.push(``); + } + const linkCards = links.map((link, index) => ` + `).join(''); + const reader = selectMailUi('#reader-pane'); + const header = reader.querySelector('.reader-header'); + if (warnings.length && header) header.insertAdjacentHTML('afterend', warnings.join('')); + const replyBar = reader.querySelector('.reply-bar'); + if (links.length && replyBar) { + replyBar.insertAdjacentHTML('beforebegin', ``); + reader.querySelectorAll('[data-mail-link]').forEach(button => { + button.onclick = async () => { + const link = links[Number(button.dataset.mailLink)]; + if (!link) return; + button.disabled = true; + try { + await window.daybreakMail.openExternal(link.url); + } catch (error) { + toastMailUi(error.message || 'Could not open this link'); + } finally { + button.disabled = false; + } + }; + }); + } }); - + function renderCustomFolders() { - const box = selectMailUi('#custom-folders'); - if (!box) return; - box.replaceChildren(...mailFeatureState.customFolders.map(folder => { - const button = document.createElement('button'); - button.className = 'folder custom-folder'; - button.dataset.folder = folder.id; - button.classList.toggle('active', rendererState.activeFolder === folder.id); - const glyph = document.createElement('span'); - glyph.className = 'nav-glyph'; - glyph.textContent = '▭'; - const label = document.createElement('span'); - label.textContent = folder.name; - button.title = folder.path; - button.append(glyph, label); - button.addEventListener('click', () => { - if (selectMailUi('#filter-folder').value) { selectMailUi('#filter-folder').value = ''; mailFeatureState.folderBeforeSearch = null; } - rendererState.activeFolder = folder.id; - selectAllMailUi('.folder').forEach(item => item.classList.toggle('active', item === button)); - selectMailUi('#sidebar-title').textContent = folder.name; - selectMailUi('#crumb-current').textContent = folder.name; - mailFeatureState.pageOffset = 0; - void syncMailbox(false, { offset: 0 }); - }); - return button; - })); -} - -async function loadCustomFolders() { - if (!mailFeatureState.connectedAccount || !window.daybreakMail?.listFolders) return; - try { - mailFeatureState.customFolders = (await window.daybreakMail.listFolders()).folders || []; - renderCustomFolders(); - } catch {} -} - -// Destination options for the mail-rule folder picker: built-in folders plus the account's IMAP folders. -function ruleFolderSelect(selected = 'Inbox') { - const options = [['Inbox', 'Inbox'], ['Archive', 'Archive'], ['Trash', 'Trash'], ...mailFeatureState.customFolders.map(folder => [folder.id, folder.name])]; - if (!options.some(([value]) => value === selected)) { - options.push([selected, String(selected).replace(/^[^:]*:/, '') || selected]); - } - return ''; -} - -// window.prompt() is not available in Electron, so ask for text in an in-app dialog. -function askText(title, label, placeholder = '') { - return new Promise(resolve => { - const overlay = document.createElement('div'); - overlay.className = 'modal-overlay pgp-prompt'; - overlay.innerHTML = '
'; - overlay.querySelector('.modal-head span').textContent = title; - overlay.querySelector('.compose-line span').textContent = label; - const input = overlay.querySelector('input'); - input.placeholder = placeholder; - const finish = value => { overlay.remove(); resolve(value); }; - overlay.querySelector('form').onsubmit = event => { event.preventDefault(); finish(input.value.trim() || null); }; - overlay.querySelector('[data-cancel]').onclick = () => finish(null); - overlay.addEventListener('keydown', event => { if (event.key === 'Escape') { event.stopPropagation(); finish(null); } }); - document.body.append(overlay); - input.focus(); - }); -} - -async function createMailFolder() { - if (!mailFeatureState.connectedAccount || !window.daybreakMail?.createFolder) { openMailAccount(); return; } - const name = await askText('New mail folder', 'Name'); - if (!name) return; - try { - const result = await window.daybreakMail.createFolder(name); - mailFeatureState.customFolders = result.folders || mailFeatureState.customFolders; - renderCustomFolders(); - toastMailUi(`Folder “${result.folder?.name || name}” created`); - } catch (error) { - toastMailUi(error.message || 'Could not create the folder'); - } -} - -function updateAccountCard(account) { - const card = selectMailUi('#account-settings'); - if (!card) return; - const email = account.email || ''; - const localName = (email.split('@')[0] || 'Mail account').replace(/[._-]+/g, ' ').replace(/\b\w/g, letter => letter.toUpperCase()); + const box = selectMailUi('#custom-folders'); + if (!box) return; + box.replaceChildren(...mailFeatureState.customFolders.map(folder => { + const button = document.createElement('button'); + button.className = 'folder custom-folder'; + button.dataset.folder = folder.id; + button.classList.toggle('active', rendererState.activeFolder === folder.id); + const glyph = document.createElement('span'); + glyph.className = 'nav-glyph'; + glyph.textContent = '▭'; + const label = document.createElement('span'); + label.textContent = folder.name; + button.title = folder.path; + button.append(glyph, label); + button.addEventListener('click', () => { + if (selectMailUi('#filter-folder').value) { selectMailUi('#filter-folder').value = ''; mailFeatureState.folderBeforeSearch = null; } + rendererState.activeFolder = folder.id; + selectAllMailUi('.folder').forEach(item => item.classList.toggle('active', item === button)); + selectMailUi('#sidebar-title').textContent = folder.name; + selectMailUi('#crumb-current').textContent = folder.name; + mailFeatureState.pageOffset = 0; + void syncMailbox(false, { offset: 0 }); + }); + return button; + })); +} + +async function loadCustomFolders() { + if (!mailFeatureState.connectedAccount || !window.daybreakMail?.listFolders) return; + try { + mailFeatureState.customFolders = (await window.daybreakMail.listFolders()).folders || []; + renderCustomFolders(); + } catch {} +} + +// Destination options for the mail-rule folder picker: built-in folders plus the account's IMAP folders. +function ruleFolderSelect(selected = 'Inbox') { + const options = [['Inbox', 'Inbox'], ['Archive', 'Archive'], ['Trash', 'Trash'], ...mailFeatureState.customFolders.map(folder => [folder.id, folder.name])]; + if (!options.some(([value]) => value === selected)) { + options.push([selected, String(selected).replace(/^[^:]*:/, '') || selected]); + } + return ''; +} + +// window.prompt() is not available in Electron, so ask for text in an in-app dialog. +function askText(title, label, placeholder = '') { + return new Promise(resolve => { + const overlay = document.createElement('div'); + overlay.className = 'modal-overlay pgp-prompt'; + overlay.innerHTML = '
'; + overlay.querySelector('.modal-head span').textContent = title; + overlay.querySelector('.compose-line span').textContent = label; + const input = overlay.querySelector('input'); + input.placeholder = placeholder; + const finish = value => { overlay.remove(); resolve(value); }; + overlay.querySelector('form').onsubmit = event => { event.preventDefault(); finish(input.value.trim() || null); }; + overlay.querySelector('[data-cancel]').onclick = () => finish(null); + overlay.addEventListener('keydown', event => { if (event.key === 'Escape') { event.stopPropagation(); finish(null); } }); + document.body.append(overlay); + input.focus(); + }); +} + +async function createMailFolder() { + if (!mailFeatureState.connectedAccount || !window.daybreakMail?.createFolder) { openMailAccount(); return; } + const name = await askText('New mail folder', 'Name'); + if (!name) return; + try { + const result = await window.daybreakMail.createFolder(name); + mailFeatureState.customFolders = result.folders || mailFeatureState.customFolders; + renderCustomFolders(); + toastMailUi(`Folder “${result.folder?.name || name}” created`); + } catch (error) { + toastMailUi(error.message || 'Could not create the folder'); + } +} + +function updateAccountCard(account) { + const card = selectMailUi('#account-settings'); + if (!card) return; + const email = account.email || ''; + const localName = (email.split('@')[0] || 'Mail account').replace(/[._-]+/g, ' ').replace(/\b\w/g, letter => letter.toUpperCase()); const displayName = account.displayName?.trim() || window.epMailFeatures.productivity?.profileName?.trim() || localName; - const initials = displayName.split(/\s+/).filter(Boolean).map(part => part[0]).join('').slice(0, 2); - card.querySelector('.account-avatar').textContent = initials || 'M'; - card.querySelector('.account-info strong').textContent = displayName; - card.querySelector('.account-info span').textContent = email; - card.title = `${displayName} <${email}>`; - if (typeof renderLabels === 'function') renderLabels(); - void loadCustomFolders(); - card.querySelector('.online-dot').style.background = '#70ad7b'; - const profileButton = selectMailUi('.top-avatar'); - if (profileButton) { - profileButton.textContent = initials || 'M'; - profileButton.title = `${displayName} <${email}>`; - profileButton.setAttribute('aria-label', `${displayName} account settings`); - } -} -function openMailAccount(existingAccount = null) { - const root = selectMailUi('#modal-root'); - const editing = Boolean(existingAccount); + const initials = displayName.split(/\s+/).filter(Boolean).map(part => part[0]).join('').slice(0, 2); + card.querySelector('.account-avatar').textContent = initials || 'M'; + card.querySelector('.account-info strong').textContent = displayName; + card.querySelector('.account-info span').textContent = email; + card.title = `${displayName} <${email}>`; + if (typeof renderLabels === 'function') renderLabels(); + void loadCustomFolders(); + card.querySelector('.online-dot').style.background = '#70ad7b'; + const profileButton = selectMailUi('.top-avatar'); + if (profileButton) { + profileButton.textContent = initials || 'M'; + profileButton.title = `${displayName} <${email}>`; + profileButton.setAttribute('aria-label', `${displayName} account settings`); + } +} +function openMailAccount(existingAccount = null) { + const root = selectMailUi('#modal-root'); + const editing = Boolean(existingAccount); const displayName = existingAccount?.displayName || window.epMailFeatures.productivity?.profileName || ''; - const ruleMarkup = (existingAccount?.rules || []).map(rule => ` -
- - - - ${rule.action==='move' - ? `${ruleFolderSelect(rule.value)}` - : ``} - -
`).join(''); + const ruleMarkup = (existingAccount?.rules || []).map(rule => ` +
+ + + + ${rule.action==='move' + ? `${ruleFolderSelect(rule.value)}` + : ``} + +
`).join(''); root.innerHTML = ``; const authMethodRow = document.createElement('label'); authMethodRow.className = 'compose-line'; @@ -297,34 +297,34 @@ function openMailAccount(existingAccount = null) { oauthProviderRow.hidden = true; } const close = () => { root.innerHTML = ''; }; - selectAllMailUi('.modal-close').forEach(button => button.onclick = close); - selectMailUi('.modal-overlay').addEventListener('click', event => { if (event.target.classList.contains('modal-overlay')) close(); }); - selectMailUi('#disconnect-mail').onclick = close; - const addRuleRow = rule => { - const row = document.createElement('div'); - row.className = 'mail-rule-row'; - row.innerHTML = ``; - row.querySelector('.mail-rule-action').value = rule?.action || 'archive'; - selectMailUi('#mail-rule-list').append(row); - }; - selectMailUi('#add-mail-rule').onclick = () => addRuleRow(); - selectMailUi('#mail-rule-list').onclick = event => { - if (event.target.closest('.remove-mail-rule')) event.target.closest('.mail-rule-row').remove(); - }; - selectMailUi('#mail-rule-list').onchange = event => { - if (!event.target.matches('.mail-rule-action')) return; - const row = event.target.closest('.mail-rule-row'); - const value = row.querySelector('.mail-rule-value'); - if (event.target.value === 'move') { - const selected = value.value || 'Inbox'; - value.outerHTML = ruleFolderSelect(selected); - } else if (value.tagName === 'SELECT') { - value.outerHTML = ``; - } - row.querySelector('.mail-rule-value').disabled = event.target.value === 'flag'; - }; - selectMailUi('#connect-mail').onclick = async () => { - const button = selectMailUi('#connect-mail'); + selectAllMailUi('.modal-close').forEach(button => button.onclick = close); + selectMailUi('.modal-overlay').addEventListener('click', event => { if (event.target.classList.contains('modal-overlay')) close(); }); + selectMailUi('#disconnect-mail').onclick = close; + const addRuleRow = rule => { + const row = document.createElement('div'); + row.className = 'mail-rule-row'; + row.innerHTML = ``; + row.querySelector('.mail-rule-action').value = rule?.action || 'archive'; + selectMailUi('#mail-rule-list').append(row); + }; + selectMailUi('#add-mail-rule').onclick = () => addRuleRow(); + selectMailUi('#mail-rule-list').onclick = event => { + if (event.target.closest('.remove-mail-rule')) event.target.closest('.mail-rule-row').remove(); + }; + selectMailUi('#mail-rule-list').onchange = event => { + if (!event.target.matches('.mail-rule-action')) return; + const row = event.target.closest('.mail-rule-row'); + const value = row.querySelector('.mail-rule-value'); + if (event.target.value === 'move') { + const selected = value.value || 'Inbox'; + value.outerHTML = ruleFolderSelect(selected); + } else if (value.tagName === 'SELECT') { + value.outerHTML = ``; + } + row.querySelector('.mail-rule-value').disabled = event.target.value === 'flag'; + }; + selectMailUi('#connect-mail').onclick = async () => { + const button = selectMailUi('#connect-mail'); const status = selectMailUi('#mail-account-status'); const password = selectMailUi('#mail-account-password').value; const authMethod = authMethodSelect.value; @@ -346,523 +346,523 @@ function openMailAccount(existingAccount = null) { ...(authMethod === 'oauth2' ? { oauthProvider } : {}), ...(editing && authMethod === 'oauth2' ? { reauthorizeOAuth } : {}), displayName: name, - imapHost: selectMailUi('#mail-account-imap').value, - smtpHost: selectMailUi('#mail-account-smtp').value, - signature: selectMailUi('#mail-account-signature').value, - notificationsEnabled: selectMailUi('#mail-account-notifications').checked, - syncIntervalMinutes: Number(selectMailUi('#mail-account-sync-interval').value), - rules: [...selectMailUi('#mail-rule-list').querySelectorAll('.mail-rule-row')].map(row => ({ - senderContains: row.querySelector('.mail-rule-sender').value, - subjectContains: row.querySelector('.mail-rule-subject').value, - action: row.querySelector('.mail-rule-action').value, - value: row.querySelector('.mail-rule-value').value - })) - }; - const account = editing - ? await window.daybreakMail.updateAccount(existingAccount.id, details) - : await window.daybreakMail.connect(details); - if (editing) { - const accountList = await window.daybreakMail.listAccounts(); - if (accountList.activeId === account.id) { - mailFeatureState.connectedAccount = account; - updateAccountCard(account); - mailFeatureState.pageOffset = 0; - close(); - await syncMailbox(false, { offset: 0 }); - } else { - close(); - } - toastMailUi('Mailbox settings updated'); + imapHost: selectMailUi('#mail-account-imap').value, + smtpHost: selectMailUi('#mail-account-smtp').value, + signature: selectMailUi('#mail-account-signature').value, + notificationsEnabled: selectMailUi('#mail-account-notifications').checked, + syncIntervalMinutes: Number(selectMailUi('#mail-account-sync-interval').value), + rules: [...selectMailUi('#mail-rule-list').querySelectorAll('.mail-rule-row')].map(row => ({ + senderContains: row.querySelector('.mail-rule-sender').value, + subjectContains: row.querySelector('.mail-rule-subject').value, + action: row.querySelector('.mail-rule-action').value, + value: row.querySelector('.mail-rule-value').value + })) + }; + const account = editing + ? await window.daybreakMail.updateAccount(existingAccount.id, details) + : await window.daybreakMail.connect(details); + if (editing) { + const accountList = await window.daybreakMail.listAccounts(); + if (accountList.activeId === account.id) { + mailFeatureState.connectedAccount = account; + updateAccountCard(account); + mailFeatureState.pageOffset = 0; + close(); + await syncMailbox(false, { offset: 0 }); + } else { + close(); + } + toastMailUi('Mailbox settings updated'); } else { - mailFeatureState.connectedAccount = account; - updateAccountCard(account); - close(); + mailFeatureState.connectedAccount = account; + updateAccountCard(account); + close(); toastMailUi(authMethod === 'oauth2' ? 'OAuth2 mailbox connected securely' : 'Mailbox connected securely'); - await syncMailbox(true); - } - } catch (error) { - status.textContent = error.message || 'Could not connect. Check the account details and try again.'; - button.disabled = false; + await syncMailbox(true); + } + } catch (error) { + status.textContent = error.message || 'Could not connect. Check the account details and try again.'; + button.disabled = false; button.textContent = authMethod === 'oauth2' ? 'Authorize & connect' : editing ? 'Save & reconnect' : 'Test & connect'; - } - }; - selectMailUi('#mail-account-email').focus(); -} -function mailSearchFilters() { - return { - query: selectMailUi('#search').value.trim(), - sender: selectMailUi('#filter-sender').value.trim(), - subject: selectMailUi('#filter-subject').value.trim(), - after: selectMailUi('#filter-after').value, - before: selectMailUi('#filter-before').value, - hasAttachments: selectMailUi('#filter-attachments').checked, - folder: selectMailUi('#filter-folder').value - }; -} - + } + }; + selectMailUi('#mail-account-email').focus(); +} +function mailSearchFilters() { + return { + query: selectMailUi('#search').value.trim(), + sender: selectMailUi('#filter-sender').value.trim(), + subject: selectMailUi('#filter-subject').value.trim(), + after: selectMailUi('#filter-after').value, + before: selectMailUi('#filter-before').value, + hasAttachments: selectMailUi('#filter-attachments').checked, + folder: selectMailUi('#filter-folder').value + }; +} + async function deleteSelectedDrafts() { - const ids = rendererState.messages.map(message => String(message.id)).filter(id => mailFeatureState.selectedDraftIds.has(id)); - if (!ids.length) { toastMailUi('Select one or more drafts first'); return; } - if (!confirm(`Delete ${ids.length} selected draft${ids.length === 1 ? '' : 's'}?`)) return; - try { - for (const id of ids) await window.daybreakMail.deleteDraft(id); - mailFeatureState.selectedDraftIds.clear(); - toastMailUi(`${ids.length} draft${ids.length === 1 ? '' : 's'} deleted`); - await syncMailbox(false); - } catch (error) { toastMailUi(error.message || 'Could not delete the drafts'); } -} - -// In the Drafts folder the shared toolbar acts on drafts, which use string ids. -document.addEventListener('click', event => { - if (rendererState.activeFolder !== 'Drafts') return; - const button = event.target.closest('#select-all, #delete-selected, #archive-selected, #mark-unread'); - if (!button) return; - event.stopImmediatePropagation(); - if (button.id === 'select-all') { - const ids = rendererState.messages.map(message => String(message.id)); - const all = ids.length && ids.every(id => mailFeatureState.selectedDraftIds.has(id)); - ids.forEach(id => all ? mailFeatureState.selectedDraftIds.delete(id) : mailFeatureState.selectedDraftIds.add(id)); - renderDrafts(rendererState.messages.map(message => message.draft)); - } else if (button.id === 'delete-selected') void deleteSelectedDrafts(); -}, true); - -function renderDrafts(drafts) { - const present = new Set(drafts.map(draft => String(draft.id))); - [...mailFeatureState.selectedDraftIds].forEach(id => { if (!present.has(id)) mailFeatureState.selectedDraftIds.delete(id); }); - rendererState.messages.splice(0, rendererState.messages.length, ...drafts.map(draft => ({ - id: draft.id, - sender: 'Draft', - email: draft.to || 'No recipient', - subject: draft.subject || '(no subject)', - snippet: String(draft.text || '').replace(/\s+/g, ' ').slice(0, 180) || 'No message text', - date: new Date(draft.updatedAt || Date.now()).toLocaleString(), - tags: ['Drafts'], - initials: 'D', - color: '#dce6df', - draft - }))); - selectMailUi('#message-list').innerHTML = rendererState.messages.length ? rendererState.messages.map(message => ` -
${message.initials}
-
${escapeMailUi(message.email)}
${escapeMailUi(message.subject)}
${escapeMailUi(message.snippet)}
-
${escapeMailUi(message.date)}
`).join('') : - '
✎

No saved drafts

Drafts are saved on this device and available offline.

'; - const start = selectMailUi('#start-draft'); - if (start) start.onclick = () => appShell.showCompose(); - selectAllMailUi('.message').forEach(row => row.onclick = event => { - const draft = rendererState.messages.find(message => String(message.id) === row.dataset.id)?.draft; - if (event.target.closest('.row-check')) { - event.stopPropagation(); - const id = row.dataset.id; - mailFeatureState.selectedDraftIds.has(id) ? mailFeatureState.selectedDraftIds.delete(id) : mailFeatureState.selectedDraftIds.add(id); - return; - } - if (event.target.closest('.draft-delete')) { - event.stopPropagation(); - if (!draft || !confirm('Delete this draft?')) return; - window.daybreakMail.deleteDraft(draft.id) - .then(() => { toastMailUi('Draft deleted'); return syncMailbox(false); }) - .catch(error => toastMailUi(error.message || 'Could not delete the draft')); - return; - } - if (draft) appShell.showCompose(null, false, draft); - }); - selectMailUi('#reader-pane').innerHTML = appShell.emptyReader(); - selectMailUi('#pagination').textContent = `${rendererState.messages.length} drafts`; - selectMailUi('#load-more').classList.add('hidden'); -} - + const ids = rendererState.messages.map(message => String(message.id)).filter(id => mailFeatureState.selectedDraftIds.has(id)); + if (!ids.length) { toastMailUi('Select one or more drafts first'); return; } + if (!confirm(`Delete ${ids.length} selected draft${ids.length === 1 ? '' : 's'}?`)) return; + try { + for (const id of ids) await window.daybreakMail.deleteDraft(id); + mailFeatureState.selectedDraftIds.clear(); + toastMailUi(`${ids.length} draft${ids.length === 1 ? '' : 's'} deleted`); + await syncMailbox(false); + } catch (error) { toastMailUi(error.message || 'Could not delete the drafts'); } +} + +// In the Drafts folder the shared toolbar acts on drafts, which use string ids. +document.addEventListener('click', event => { + if (rendererState.activeFolder !== 'Drafts') return; + const button = event.target.closest('#select-all, #delete-selected, #archive-selected, #mark-unread'); + if (!button) return; + event.stopImmediatePropagation(); + if (button.id === 'select-all') { + const ids = rendererState.messages.map(message => String(message.id)); + const all = ids.length && ids.every(id => mailFeatureState.selectedDraftIds.has(id)); + ids.forEach(id => all ? mailFeatureState.selectedDraftIds.delete(id) : mailFeatureState.selectedDraftIds.add(id)); + renderDrafts(rendererState.messages.map(message => message.draft)); + } else if (button.id === 'delete-selected') void deleteSelectedDrafts(); +}, true); + +function renderDrafts(drafts) { + const present = new Set(drafts.map(draft => String(draft.id))); + [...mailFeatureState.selectedDraftIds].forEach(id => { if (!present.has(id)) mailFeatureState.selectedDraftIds.delete(id); }); + rendererState.messages.splice(0, rendererState.messages.length, ...drafts.map(draft => ({ + id: draft.id, + sender: 'Draft', + email: draft.to || 'No recipient', + subject: draft.subject || '(no subject)', + snippet: String(draft.text || '').replace(/\s+/g, ' ').slice(0, 180) || 'No message text', + date: new Date(draft.updatedAt || Date.now()).toLocaleString(), + tags: ['Drafts'], + initials: 'D', + color: '#dce6df', + draft + }))); + selectMailUi('#message-list').innerHTML = rendererState.messages.length ? rendererState.messages.map(message => ` +
${message.initials}
+
${escapeMailUi(message.email)}
${escapeMailUi(message.subject)}
${escapeMailUi(message.snippet)}
+
${escapeMailUi(message.date)}
`).join('') : + '
✎

No saved drafts

Drafts are saved on this device and available offline.

'; + const start = selectMailUi('#start-draft'); + if (start) start.onclick = () => appShell.showCompose(); + selectAllMailUi('.message').forEach(row => row.onclick = event => { + const draft = rendererState.messages.find(message => String(message.id) === row.dataset.id)?.draft; + if (event.target.closest('.row-check')) { + event.stopPropagation(); + const id = row.dataset.id; + mailFeatureState.selectedDraftIds.has(id) ? mailFeatureState.selectedDraftIds.delete(id) : mailFeatureState.selectedDraftIds.add(id); + return; + } + if (event.target.closest('.draft-delete')) { + event.stopPropagation(); + if (!draft || !confirm('Delete this draft?')) return; + window.daybreakMail.deleteDraft(draft.id) + .then(() => { toastMailUi('Draft deleted'); return syncMailbox(false); }) + .catch(error => toastMailUi(error.message || 'Could not delete the draft')); + return; + } + if (draft) appShell.showCompose(null, false, draft); + }); + selectMailUi('#reader-pane').innerHTML = appShell.emptyReader(); + selectMailUi('#pagination').textContent = `${rendererState.messages.length} drafts`; + selectMailUi('#load-more').classList.add('hidden'); +} + function setupDraftComposer() { appShell.wrapShowCompose((original) => (reply, forward = false, draft = null) => { - original(reply, forward); - const root = selectMailUi('#modal-root'); - const modal = root.querySelector('.compose-modal'); - if (!modal) return; - modal.dataset.draftId = draft?.id || ''; - let attachments = Array.isArray(draft?.attachments) ? draft.attachments : []; - modal._composeAttachments = attachments; - const fields = modal.querySelector('.compose-fields'); - const attachmentRow = document.createElement('div'); - attachmentRow.className = 'compose-line'; - const attachmentLabel = document.createElement('span'); - attachmentLabel.textContent = 'Attachments'; - const attachmentControls = document.createElement('div'); - attachmentControls.className = 'compose-attachments'; - const attachmentInput = document.createElement('input'); - attachmentInput.type = 'file'; - attachmentInput.multiple = true; - attachmentInput.accept = '*/*'; - attachmentInput.hidden = true; - attachmentInput.setAttribute('aria-label', 'Choose files to attach'); - const attachButton = document.createElement('button'); - attachButton.type = 'button'; - attachButton.className = 'discard'; - attachButton.textContent = 'Attach files…'; - const attachmentList = document.createElement('div'); - attachmentList.className = 'attachment-list'; - attachmentList.setAttribute('aria-live', 'polite'); - attachmentControls.append(attachButton, attachmentInput); - attachmentRow.append(attachmentLabel, attachmentControls); - fields.append(attachmentRow, attachmentList); - attachButton.onclick = () => attachmentInput.click(); - const renderAttachments = () => { - attachmentList.replaceChildren(); - attachments.forEach((file, index) => { - const row = document.createElement('div'); - row.className = 'attachment-row'; - const name = document.createElement('strong'); - name.textContent = file.filename; - const size = document.createElement('small'); - size.textContent = `${((file.size || 0) / 1048576).toFixed(2)} MB`; - const remove = document.createElement('button'); - remove.type = 'button'; - remove.className = 'discard'; - remove.textContent = 'Remove'; - remove.setAttribute('aria-label', `Remove ${file.filename}`); - remove.onclick = () => { - attachments.splice(index, 1); - renderAttachments(); - void persist().catch(error => toastMailUi(error.message || 'Could not save the draft')); - }; - row.append(name, size, remove); - attachmentList.append(row); - }); - }; - attachmentInput.onchange = async () => { - attachButton.disabled = true; - try { - const selected = []; - for (const file of attachmentInput.files) { - const bytes = new Uint8Array(await file.arrayBuffer()); - let binary = ''; - for (let offset = 0; offset < bytes.length; offset += 0x8000) { - binary += String.fromCharCode(...bytes.subarray(offset, offset + 0x8000)); - } - selected.push({ - filename: file.name, - contentType: file.type || 'application/octet-stream', - size: file.size, - contentBase64: btoa(binary) - }); - } - attachments.push(...selected); - renderAttachments(); - await persist(); - } catch (error) { - toastMailUi(error.message || 'Could not add the selected files'); - } finally { - attachmentInput.value = ''; - attachButton.disabled = false; - } - }; - renderAttachments(); - if (draft) { - selectMailUi('#compose-to').value = draft.to || ''; - selectMailUi('#compose-cc').value = draft.cc || ''; - selectMailUi('#compose-subject').value = draft.subject || ''; - selectMailUi('#compose-body').value = draft.text || ''; - modal.querySelector('.modal-head span').textContent = 'Edit draft'; - } - const save = document.createElement('button'); - save.type = 'button'; - save.className = 'discard'; - save.id = 'save-draft'; - save.textContent = 'Save draft'; - modal.querySelector('.compose-footer').insertBefore(save, selectMailUi('#send')); - let saveTimer; - let closed = false; - const persist = async () => { - if (closed || !selectMailUi('#compose-to')) return; - const values = { - id: modal.dataset.draftId || window.crypto.randomUUID(), - to: selectMailUi('#compose-to').value, - cc: selectMailUi('#compose-cc').value, - subject: selectMailUi('#compose-subject').value, - text: selectMailUi('#compose-body').value, - attachments - }; - if (!Object.values(values).some(value => typeof value === 'string' && value.trim()) && !attachments.length) return; - modal.dataset.draftId = values.id; - const result = await window.daybreakMail.saveDraft(values); - modal.dataset.draftId = result.id; - }; - save.onclick = async () => { - try { - await persist(); - toastMailUi('Draft saved on this device'); - if (rendererState.activeFolder === 'Drafts') void syncMailbox(false); - } catch (error) { toastMailUi(error.message || 'Could not save draft'); } - }; - modal.addEventListener('input', () => { - clearTimeout(saveTimer); - saveTimer = setTimeout(() => persist().catch(error => toastMailUi(error.message || 'Could not save draft')), 700); - }); - modal.querySelector('.modal-overlay')?.addEventListener('click', event => { - if (!event.target.classList.contains('modal-overlay')) return; - clearTimeout(saveTimer); - persist().then(() => { if (rendererState.activeFolder === 'Drafts') void syncMailbox(false); }) - .catch(error => toastMailUi(error.message || 'Could not save draft')); - closed = true; - }, true); - root.querySelector('.modal-close')?.addEventListener('click', () => { - clearTimeout(saveTimer); - persist().then(() => { if (rendererState.activeFolder === 'Drafts') void syncMailbox(false); }) - .catch(error => toastMailUi(error.message || 'Could not save draft')); - closed = true; - }, true); - selectMailUi('#discard').onclick = async () => { - clearTimeout(saveTimer); - closed = true; - try { - if (modal.dataset.draftId) await window.daybreakMail.deleteDraft(modal.dataset.draftId); - root.innerHTML = ''; - if (rendererState.activeFolder === 'Drafts') void syncMailbox(false); - } catch (error) { toastMailUi(error.message || 'Could not delete draft'); } - }; - selectMailUi('#send').addEventListener('click', () => { - clearTimeout(saveTimer); - closed = true; - }, true); + original(reply, forward); + const root = selectMailUi('#modal-root'); + const modal = root.querySelector('.compose-modal'); + if (!modal) return; + modal.dataset.draftId = draft?.id || ''; + let attachments = Array.isArray(draft?.attachments) ? draft.attachments : []; + modal._composeAttachments = attachments; + const fields = modal.querySelector('.compose-fields'); + const attachmentRow = document.createElement('div'); + attachmentRow.className = 'compose-line'; + const attachmentLabel = document.createElement('span'); + attachmentLabel.textContent = 'Attachments'; + const attachmentControls = document.createElement('div'); + attachmentControls.className = 'compose-attachments'; + const attachmentInput = document.createElement('input'); + attachmentInput.type = 'file'; + attachmentInput.multiple = true; + attachmentInput.accept = '*/*'; + attachmentInput.hidden = true; + attachmentInput.setAttribute('aria-label', 'Choose files to attach'); + const attachButton = document.createElement('button'); + attachButton.type = 'button'; + attachButton.className = 'discard'; + attachButton.textContent = 'Attach files…'; + const attachmentList = document.createElement('div'); + attachmentList.className = 'attachment-list'; + attachmentList.setAttribute('aria-live', 'polite'); + attachmentControls.append(attachButton, attachmentInput); + attachmentRow.append(attachmentLabel, attachmentControls); + fields.append(attachmentRow, attachmentList); + attachButton.onclick = () => attachmentInput.click(); + const renderAttachments = () => { + attachmentList.replaceChildren(); + attachments.forEach((file, index) => { + const row = document.createElement('div'); + row.className = 'attachment-row'; + const name = document.createElement('strong'); + name.textContent = file.filename; + const size = document.createElement('small'); + size.textContent = `${((file.size || 0) / 1048576).toFixed(2)} MB`; + const remove = document.createElement('button'); + remove.type = 'button'; + remove.className = 'discard'; + remove.textContent = 'Remove'; + remove.setAttribute('aria-label', `Remove ${file.filename}`); + remove.onclick = () => { + attachments.splice(index, 1); + renderAttachments(); + void persist().catch(error => toastMailUi(error.message || 'Could not save the draft')); + }; + row.append(name, size, remove); + attachmentList.append(row); + }); + }; + attachmentInput.onchange = async () => { + attachButton.disabled = true; + try { + const selected = []; + for (const file of attachmentInput.files) { + const bytes = new Uint8Array(await file.arrayBuffer()); + let binary = ''; + for (let offset = 0; offset < bytes.length; offset += 0x8000) { + binary += String.fromCharCode(...bytes.subarray(offset, offset + 0x8000)); + } + selected.push({ + filename: file.name, + contentType: file.type || 'application/octet-stream', + size: file.size, + contentBase64: btoa(binary) + }); + } + attachments.push(...selected); + renderAttachments(); + await persist(); + } catch (error) { + toastMailUi(error.message || 'Could not add the selected files'); + } finally { + attachmentInput.value = ''; + attachButton.disabled = false; + } + }; + renderAttachments(); + if (draft) { + selectMailUi('#compose-to').value = draft.to || ''; + selectMailUi('#compose-cc').value = draft.cc || ''; + selectMailUi('#compose-subject').value = draft.subject || ''; + selectMailUi('#compose-body').value = draft.text || ''; + modal.querySelector('.modal-head span').textContent = 'Edit draft'; + } + const save = document.createElement('button'); + save.type = 'button'; + save.className = 'discard'; + save.id = 'save-draft'; + save.textContent = 'Save draft'; + modal.querySelector('.compose-footer').insertBefore(save, selectMailUi('#send')); + let saveTimer; + let closed = false; + const persist = async () => { + if (closed || !selectMailUi('#compose-to')) return; + const values = { + id: modal.dataset.draftId || window.crypto.randomUUID(), + to: selectMailUi('#compose-to').value, + cc: selectMailUi('#compose-cc').value, + subject: selectMailUi('#compose-subject').value, + text: selectMailUi('#compose-body').value, + attachments + }; + if (!Object.values(values).some(value => typeof value === 'string' && value.trim()) && !attachments.length) return; + modal.dataset.draftId = values.id; + const result = await window.daybreakMail.saveDraft(values); + modal.dataset.draftId = result.id; + }; + save.onclick = async () => { + try { + await persist(); + toastMailUi('Draft saved on this device'); + if (rendererState.activeFolder === 'Drafts') void syncMailbox(false); + } catch (error) { toastMailUi(error.message || 'Could not save draft'); } + }; + modal.addEventListener('input', () => { + clearTimeout(saveTimer); + saveTimer = setTimeout(() => persist().catch(error => toastMailUi(error.message || 'Could not save draft')), 700); + }); + modal.querySelector('.modal-overlay')?.addEventListener('click', event => { + if (!event.target.classList.contains('modal-overlay')) return; + clearTimeout(saveTimer); + persist().then(() => { if (rendererState.activeFolder === 'Drafts') void syncMailbox(false); }) + .catch(error => toastMailUi(error.message || 'Could not save draft')); + closed = true; + }, true); + root.querySelector('.modal-close')?.addEventListener('click', () => { + clearTimeout(saveTimer); + persist().then(() => { if (rendererState.activeFolder === 'Drafts') void syncMailbox(false); }) + .catch(error => toastMailUi(error.message || 'Could not save draft')); + closed = true; + }, true); + selectMailUi('#discard').onclick = async () => { + clearTimeout(saveTimer); + closed = true; + try { + if (modal.dataset.draftId) await window.daybreakMail.deleteDraft(modal.dataset.draftId); + root.innerHTML = ''; + if (rendererState.activeFolder === 'Drafts') void syncMailbox(false); + } catch (error) { toastMailUi(error.message || 'Could not delete draft'); } + }; + selectMailUi('#send').addEventListener('click', () => { + clearTimeout(saveTimer); + closed = true; + }, true); }); } - -async function syncMailbox(showToast, options = {}) { - if (mailFeatureState.syncPromise) { - mailFeatureState.syncQueued = true; - return mailFeatureState.syncPromise; - } - if (!mailFeatureState.connectedAccount || !window.daybreakMail) { - openMailAccount(); - return; - } - const refresh = selectMailUi('#refresh'); - if (refresh) refresh.disabled = true; - const sync = (async () => { - try { - if (rendererState.activeFolder === 'Drafts') { - const result = await window.daybreakMail.listDrafts(); - renderDrafts(result.drafts || []); - if (showToast) toastMailUi(`${result.drafts.length} saved drafts`); - return; - } - const previouslyActiveMessage = rendererState.activeMessage; - const offset = options.offset ?? (options.append ? mailFeatureState.pageOffset + rendererState.messages.length : mailFeatureState.pageOffset); - const result = await window.daybreakMail.syncFolder(rendererState.activeFolder, offset, mailSearchFilters()); - if (options.append) rendererState.messages.push(...result.messages); - else rendererState.messages.splice(0, rendererState.messages.length, ...result.messages); - rendererState.messages.forEach(message => { - try { - const localTags = JSON.parse(localStorage.getItem(`daybreak-message-labels-${message.id}`) || '[]'); - message.tags = [...new Set([...(message.tags || []), ...localTags])]; - } catch {} - }); - if (!options.append) mailFeatureState.pageOffset = offset; - mailFeatureState.total = result.total; - rendererState.activeMessage = rendererState.messages.some(message => message.id === previouslyActiveMessage) - ? previouslyActiveMessage - : rendererState.messages[0]?.id; - rendererState.selectedIds.clear(); - const unread = rendererState.messages.filter(message => message.unread).length; - const inboxCount = selectMailUi('.folder[data-folder="Inbox"] .count'); - if (inboxCount) inboxCount.textContent = String(unread); - const pagination = selectMailUi('#pagination'); - if (pagination) pagination.textContent = result.total ? `${options.append ? 1 : result.start}–${options.append ? Math.min(offset + result.messages.length, result.total) : result.end} of ${result.total}` : '0 messages'; - const loadMore = selectMailUi('#load-more'); - if (loadMore) loadMore.classList.toggle('hidden', mailFeatureState.pageOffset + rendererState.messages.length >= result.total); + +async function syncMailbox(showToast, options = {}) { + if (mailFeatureState.syncPromise) { + mailFeatureState.syncQueued = true; + return mailFeatureState.syncPromise; + } + if (!mailFeatureState.connectedAccount || !window.daybreakMail) { + openMailAccount(); + return; + } + const refresh = selectMailUi('#refresh'); + if (refresh) refresh.disabled = true; + const sync = (async () => { + try { + if (rendererState.activeFolder === 'Drafts') { + const result = await window.daybreakMail.listDrafts(); + renderDrafts(result.drafts || []); + if (showToast) toastMailUi(`${result.drafts.length} saved drafts`); + return; + } + const previouslyActiveMessage = rendererState.activeMessage; + const offset = options.offset ?? (options.append ? mailFeatureState.pageOffset + rendererState.messages.length : mailFeatureState.pageOffset); + const result = await window.daybreakMail.syncFolder(rendererState.activeFolder, offset, mailSearchFilters()); + if (options.append) rendererState.messages.push(...result.messages); + else rendererState.messages.splice(0, rendererState.messages.length, ...result.messages); + rendererState.messages.forEach(message => { + try { + const localTags = JSON.parse(localStorage.getItem(`daybreak-message-labels-${message.id}`) || '[]'); + message.tags = [...new Set([...(message.tags || []), ...localTags])]; + } catch {} + }); + if (!options.append) mailFeatureState.pageOffset = offset; + mailFeatureState.total = result.total; + rendererState.activeMessage = rendererState.messages.some(message => message.id === previouslyActiveMessage) + ? previouslyActiveMessage + : rendererState.messages[0]?.id; + rendererState.selectedIds.clear(); + const unread = rendererState.messages.filter(message => message.unread).length; + const inboxCount = selectMailUi('.folder[data-folder="Inbox"] .count'); + if (inboxCount) inboxCount.textContent = String(unread); + const pagination = selectMailUi('#pagination'); + if (pagination) pagination.textContent = result.total ? `${options.append ? 1 : result.start}–${options.append ? Math.min(offset + result.messages.length, result.total) : result.end} of ${result.total}` : '0 messages'; + const loadMore = selectMailUi('#load-more'); + if (loadMore) loadMore.classList.toggle('hidden', mailFeatureState.pageOffset + rendererState.messages.length >= result.total); rendererState.query = ''; - appShell.renderList(); - if (rendererState.activeMessage) { - appShell.openMessage(rendererState.activeMessage); - const current = rendererState.messages.find(message => message.id === rendererState.activeMessage); - if (current?.uid) window.daybreakMail.updateMessage({ uid: current.uid, folder: current.sourceFolder || rendererState.activeFolder, action: 'unread', enabled: false }).catch(() => {}); - } - else selectMailUi('#reader-pane').innerHTML = appShell.emptyReader(); - updateAccountCard(mailFeatureState.connectedAccount); - const status = selectMailUi('#mail-status'); - if (status) status.textContent = result.offline ? 'Offline — showing saved messages' : 'All caught up with your mail'; - if (showToast) toastMailUi(`Synced ${rendererState.messages.length} messages`); - } catch (error) { - toastMailUi(error.message || 'Could not sync the inbox'); - } finally { - if (refresh) refresh.disabled = false; - } - - })(); - mailFeatureState.syncPromise = sync; - try { - await sync; - } finally { - mailFeatureState.syncPromise = null; - if (mailFeatureState.syncQueued) { - mailFeatureState.syncQueued = false; - void syncMailbox(false); - } - } -} - + appShell.renderList(); + if (rendererState.activeMessage) { + appShell.openMessage(rendererState.activeMessage); + const current = rendererState.messages.find(message => message.id === rendererState.activeMessage); + if (current?.uid) window.daybreakMail.updateMessage({ uid: current.uid, folder: current.sourceFolder || rendererState.activeFolder, action: 'unread', enabled: false }).catch(() => {}); + } + else selectMailUi('#reader-pane').innerHTML = appShell.emptyReader(); + updateAccountCard(mailFeatureState.connectedAccount); + const status = selectMailUi('#mail-status'); + if (status) status.textContent = result.offline ? 'Offline — showing saved messages' : 'All caught up with your mail'; + if (showToast) toastMailUi(`Synced ${rendererState.messages.length} messages`); + } catch (error) { + toastMailUi(error.message || 'Could not sync the inbox'); + } finally { + if (refresh) refresh.disabled = false; + } + + })(); + mailFeatureState.syncPromise = sync; + try { + await sync; + } finally { + mailFeatureState.syncPromise = null; + if (mailFeatureState.syncQueued) { + mailFeatureState.syncQueued = false; + void syncMailbox(false); + } + } +} + if (window.daybreakMail) { - setupDraftComposer(); - let searchTimer; - const searchControls = ['#search', '#filter-folder', '#filter-sender', '#filter-subject', '#filter-after', '#filter-before', '#filter-attachments']; - selectMailUi('#search-filters-toggle').onclick = () => { - const panel = selectMailUi('#search-filters'); - const expanded = panel.classList.toggle('hidden') === false; - selectMailUi('#search-filters-toggle').setAttribute('aria-expanded', String(expanded)); - }; - selectMailUi('#clear-search-filters').onclick = () => { - selectMailUi('#filter-folder').value = ''; - selectMailUi('#filter-sender').value = ''; - selectMailUi('#filter-subject').value = ''; - selectMailUi('#filter-after').value = ''; - selectMailUi('#filter-before').value = ''; - selectMailUi('#filter-attachments').checked = false; - selectMailUi('#search').value = ''; - rendererState.activeFolder = mailFeatureState.folderBeforeSearch || rendererState.activeFolder; - mailFeatureState.folderBeforeSearch = null; - selectAllMailUi('.folder').forEach(button => button.classList.toggle('active', button.dataset.folder === rendererState.activeFolder)); - selectMailUi('#sidebar-title').textContent = rendererState.activeFolder; - selectMailUi('#crumb-current').textContent = rendererState.activeFolder; + setupDraftComposer(); + let searchTimer; + const searchControls = ['#search', '#filter-folder', '#filter-sender', '#filter-subject', '#filter-after', '#filter-before', '#filter-attachments']; + selectMailUi('#search-filters-toggle').onclick = () => { + const panel = selectMailUi('#search-filters'); + const expanded = panel.classList.toggle('hidden') === false; + selectMailUi('#search-filters-toggle').setAttribute('aria-expanded', String(expanded)); + }; + selectMailUi('#clear-search-filters').onclick = () => { + selectMailUi('#filter-folder').value = ''; + selectMailUi('#filter-sender').value = ''; + selectMailUi('#filter-subject').value = ''; + selectMailUi('#filter-after').value = ''; + selectMailUi('#filter-before').value = ''; + selectMailUi('#filter-attachments').checked = false; + selectMailUi('#search').value = ''; + rendererState.activeFolder = mailFeatureState.folderBeforeSearch || rendererState.activeFolder; + mailFeatureState.folderBeforeSearch = null; + selectAllMailUi('.folder').forEach(button => button.classList.toggle('active', button.dataset.folder === rendererState.activeFolder)); + selectMailUi('#sidebar-title').textContent = rendererState.activeFolder; + selectMailUi('#crumb-current').textContent = rendererState.activeFolder; rendererState.query = ''; - appShell.renderList(); - mailFeatureState.pageOffset = 0; - void syncMailbox(false, { offset: 0 }); - }; - for (const selector of searchControls) { - selectMailUi(selector).addEventListener(selector === '#search' ? 'input' : 'change', () => { - if (selector === '#filter-folder' && selectMailUi('#filter-folder').value) { - if (!mailFeatureState.folderBeforeSearch) mailFeatureState.folderBeforeSearch = rendererState.activeFolder; - rendererState.activeFolder = selectMailUi('#filter-folder').value; - selectAllMailUi('.folder').forEach(button => button.classList.toggle('active', button.dataset.folder === rendererState.activeFolder)); - selectMailUi('#sidebar-title').textContent = rendererState.activeFolder; - selectMailUi('#crumb-current').textContent = rendererState.activeFolder; - } - clearTimeout(searchTimer); - searchTimer = setTimeout(() => { - mailFeatureState.pageOffset = 0; - void syncMailbox(false, { offset: 0 }); - }, selector === '#search' ? 350 : 0); - }); - } - window.daybreakMail.getAppVersion().then(version => { - document.title = `ep-mail v${version}`; - }).catch(error => { - console.error('Could not read app version:', error); - }); - window.daybreakMail.onSyncUpdate(update => { - if (update.accountId !== mailFeatureState.connectedAccount?.id) return; - if (update.error) { - toastMailUi(update.error); - return; - } - if (update.newCount || (update.foldersChanged || []).length) { - if (document.visibilityState === 'visible') { - syncMailbox(false, update.newCount ? { offset: 0 } : {}); - } - else mailFeatureState.refreshPending = true; - } - }); - document.addEventListener('visibilitychange', () => { - if (document.visibilityState === 'visible' && mailFeatureState.refreshPending) { - mailFeatureState.refreshPending = false; - syncMailbox(false, { offset: 0 }); - } - }); - window.addEventListener('focus', () => { - if (mailFeatureState.connectedAccount) syncMailbox(false); - }); - window.addEventListener('online', () => { - if (mailFeatureState.connectedAccount) syncMailbox(false, { offset: 0 }); - }); - setInterval(() => { - if (mailFeatureState.connectedAccount && document.visibilityState === 'visible' && rendererState.activeView === 'mail') { - syncMailbox(false); - } - }, 60 * 1000); - selectMailUi('#account-settings').addEventListener('click', openMailAccount); - selectMailUi('#account-settings').addEventListener('keydown', event => { - if (event.key === 'Enter' || event.key === ' ') { event.preventDefault(); openMailAccount(); } - }); - selectMailUi('#refresh').onclick = () => syncMailbox(true); - selectMailUi('#add-folder').addEventListener('click', createMailFolder); - selectAllMailUi('.folder').forEach(button => button.addEventListener('click', () => { - if (selectMailUi('#filter-folder').value) { - selectMailUi('#filter-folder').value = ''; - mailFeatureState.folderBeforeSearch = null; - } - if (['Inbox', 'Sent', 'Archive', 'Trash', 'Starred', 'Drafts'].includes(button.dataset.folder)) { - mailFeatureState.pageOffset = 0; - syncMailbox(false, { offset: 0 }); - } - })); - selectMailUi('#previous-page').onclick = () => { - if (mailFeatureState.pageOffset <= 0) return; - mailFeatureState.pageOffset = Math.max(0, mailFeatureState.pageOffset - 20); - syncMailbox(false, { offset: mailFeatureState.pageOffset }); - }; - selectMailUi('#next-page').onclick = () => { - if (mailFeatureState.pageOffset + 20 >= mailFeatureState.total) return; - mailFeatureState.pageOffset += 20; - syncMailbox(false, { offset: mailFeatureState.pageOffset }); - }; - selectMailUi('#load-more').onclick = () => syncMailbox(false, { append: true }); - document.addEventListener('click', async event => { - const sendButton = event.target.closest('#send'); - if (!sendButton || !mailFeatureState.connectedAccount) return; - event.preventDefault(); - event.stopImmediatePropagation(); - const recipient = selectMailUi('#compose-to').value.trim(); - if (!recipient) { selectMailUi('#compose-to').focus(); toastMailUi('Add a recipient to send your message'); return; } - sendButton.disabled = true; - sendButton.textContent = 'Sending…'; - try { + appShell.renderList(); + mailFeatureState.pageOffset = 0; + void syncMailbox(false, { offset: 0 }); + }; + for (const selector of searchControls) { + selectMailUi(selector).addEventListener(selector === '#search' ? 'input' : 'change', () => { + if (selector === '#filter-folder' && selectMailUi('#filter-folder').value) { + if (!mailFeatureState.folderBeforeSearch) mailFeatureState.folderBeforeSearch = rendererState.activeFolder; + rendererState.activeFolder = selectMailUi('#filter-folder').value; + selectAllMailUi('.folder').forEach(button => button.classList.toggle('active', button.dataset.folder === rendererState.activeFolder)); + selectMailUi('#sidebar-title').textContent = rendererState.activeFolder; + selectMailUi('#crumb-current').textContent = rendererState.activeFolder; + } + clearTimeout(searchTimer); + searchTimer = setTimeout(() => { + mailFeatureState.pageOffset = 0; + void syncMailbox(false, { offset: 0 }); + }, selector === '#search' ? 350 : 0); + }); + } + window.daybreakMail.getAppVersion().then(version => { + document.title = `ep-mail v${version}`; + }).catch(error => { + console.error('Could not read app version:', error); + }); + window.daybreakMail.onSyncUpdate(update => { + if (update.accountId !== mailFeatureState.connectedAccount?.id) return; + if (update.error) { + toastMailUi(update.error); + return; + } + if (update.newCount || (update.foldersChanged || []).length) { + if (document.visibilityState === 'visible') { + syncMailbox(false, update.newCount ? { offset: 0 } : {}); + } + else mailFeatureState.refreshPending = true; + } + }); + document.addEventListener('visibilitychange', () => { + if (document.visibilityState === 'visible' && mailFeatureState.refreshPending) { + mailFeatureState.refreshPending = false; + syncMailbox(false, { offset: 0 }); + } + }); + window.addEventListener('focus', () => { + if (mailFeatureState.connectedAccount) syncMailbox(false); + }); + window.addEventListener('online', () => { + if (mailFeatureState.connectedAccount) syncMailbox(false, { offset: 0 }); + }); + setInterval(() => { + if (mailFeatureState.connectedAccount && document.visibilityState === 'visible' && rendererState.activeView === 'mail') { + syncMailbox(false); + } + }, 60 * 1000); + selectMailUi('#account-settings').addEventListener('click', openMailAccount); + selectMailUi('#account-settings').addEventListener('keydown', event => { + if (event.key === 'Enter' || event.key === ' ') { event.preventDefault(); openMailAccount(); } + }); + selectMailUi('#refresh').onclick = () => syncMailbox(true); + selectMailUi('#add-folder').addEventListener('click', createMailFolder); + selectAllMailUi('.folder').forEach(button => button.addEventListener('click', () => { + if (selectMailUi('#filter-folder').value) { + selectMailUi('#filter-folder').value = ''; + mailFeatureState.folderBeforeSearch = null; + } + if (['Inbox', 'Sent', 'Archive', 'Trash', 'Starred', 'Drafts'].includes(button.dataset.folder)) { + mailFeatureState.pageOffset = 0; + syncMailbox(false, { offset: 0 }); + } + })); + selectMailUi('#previous-page').onclick = () => { + if (mailFeatureState.pageOffset <= 0) return; + mailFeatureState.pageOffset = Math.max(0, mailFeatureState.pageOffset - 20); + syncMailbox(false, { offset: mailFeatureState.pageOffset }); + }; + selectMailUi('#next-page').onclick = () => { + if (mailFeatureState.pageOffset + 20 >= mailFeatureState.total) return; + mailFeatureState.pageOffset += 20; + syncMailbox(false, { offset: mailFeatureState.pageOffset }); + }; + selectMailUi('#load-more').onclick = () => syncMailbox(false, { append: true }); + document.addEventListener('click', async event => { + const sendButton = event.target.closest('#send'); + if (!sendButton || !mailFeatureState.connectedAccount) return; + event.preventDefault(); + event.stopImmediatePropagation(); + const recipient = selectMailUi('#compose-to').value.trim(); + if (!recipient) { selectMailUi('#compose-to').focus(); toastMailUi('Add a recipient to send your message'); return; } + sendButton.disabled = true; + sendButton.textContent = 'Sending…'; + try { const pgp = window.epMailFeatures.pgp?.prepareSend ? await window.epMailFeatures.pgp.prepareSend(recipient, selectMailUi('#compose-cc').value) : null; - if (pgp === false) { - sendButton.disabled = false; - sendButton.textContent = 'Send ↗'; - return; - } - const result = await window.daybreakMail.send({ - to: recipient, - cc: selectMailUi('#compose-cc').value, - subject: selectMailUi('#compose-subject').value.trim(), - text: selectMailUi('#compose-body').value, - attachments: selectMailUi('#modal-root .compose-modal')?._composeAttachments || [], + if (pgp === false) { + sendButton.disabled = false; + sendButton.textContent = 'Send ↗'; + return; + } + const result = await window.daybreakMail.send({ + to: recipient, + cc: selectMailUi('#compose-cc').value, + subject: selectMailUi('#compose-subject').value.trim(), + text: selectMailUi('#compose-body').value, + attachments: selectMailUi('#modal-root .compose-modal')?._composeAttachments || [], displayName: mailFeatureState.connectedAccount.displayName || window.epMailFeatures.productivity?.profileName || '', - ...(pgp ? { pgp } : {}) - }); - if (result.failed) { - sendButton.disabled = false; - sendButton.textContent = 'Send ↗'; - toastMailUi(result.message || 'Message could not be encrypted'); - return; - } - if (result.queued) { - const draftId = selectMailUi('#modal-root .compose-modal')?.dataset.draftId; - if (draftId) await window.daybreakMail.deleteDraft(draftId); - selectMailUi('#modal-root').innerHTML = ''; - toastMailUi('Offline: message queued and will send when connected'); - if (rendererState.activeFolder === 'Drafts') void syncMailbox(false); - return; - } - const draftId = selectMailUi('#modal-root .compose-modal')?.dataset.draftId; - if (draftId) await window.daybreakMail.deleteDraft(draftId); - selectMailUi('#modal-root').innerHTML = ''; - 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 === 'Drafts') void syncMailbox(false); - } catch (error) { - sendButton.disabled = false; - sendButton.textContent = 'Send ↗'; - toastMailUi(error.message || 'Message could not be sent'); - } - }, true); - - window.daybreakMail.getAccount().then(account => { - if (!account) return; - mailFeatureState.connectedAccount = account; - updateAccountCard(account); - syncMailbox(false); + ...(pgp ? { pgp } : {}) + }); + if (result.failed) { + sendButton.disabled = false; + sendButton.textContent = 'Send ↗'; + toastMailUi(result.message || 'Message could not be encrypted'); + return; + } + if (result.queued) { + const draftId = selectMailUi('#modal-root .compose-modal')?.dataset.draftId; + if (draftId) await window.daybreakMail.deleteDraft(draftId); + selectMailUi('#modal-root').innerHTML = ''; + toastMailUi('Offline: message queued and will send when connected'); + if (rendererState.activeFolder === 'Drafts') void syncMailbox(false); + return; + } + const draftId = selectMailUi('#modal-root .compose-modal')?.dataset.draftId; + if (draftId) await window.daybreakMail.deleteDraft(draftId); + selectMailUi('#modal-root').innerHTML = ''; + 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 === 'Drafts') void syncMailbox(false); + } catch (error) { + sendButton.disabled = false; + sendButton.textContent = 'Send ↗'; + toastMailUi(error.message || 'Message could not be sent'); + } + }, true); + + window.daybreakMail.getAccount().then(account => { + if (!account) return; + mailFeatureState.connectedAccount = account; + updateAccountCard(account); + syncMailbox(false); }).catch(() => {}); } diff --git a/manifest.webmanifest b/manifest.webmanifest index e389539..c052ffe 100644 --- a/manifest.webmanifest +++ b/manifest.webmanifest @@ -1,10 +1,10 @@ -{ - "name": "ep-mail", - "short_name": "ep-mail", - "description": "Eternity Project mail, calendar, and contacts.", - "start_url": "./", - "display": "standalone", - "background_color": "#f4f5f1", - "theme_color": "#f4f5f1", - "icons": [{"src":"icon.svg","sizes":"any","type":"image/svg+xml","purpose":"any maskable"}] -} +{ + "name": "ep-mail", + "short_name": "ep-mail", + "description": "Eternity Project mail, calendar, and contacts.", + "start_url": "./", + "display": "standalone", + "background_color": "#f4f5f1", + "theme_color": "#f4f5f1", + "icons": [{"src":"icon.svg","sizes":"any","type":"image/svg+xml","purpose":"any maskable"}] +} diff --git a/package-lock.json b/package-lock.json index 76021f8..2c9d0d9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5382 +1,5382 @@ -{ - "name": "ep-mail", - "version": "0.5.1", - "lockfileVersion": 3, - "requires": true, - "packages": { - "": { - "name": "ep-mail", - "version": "0.5.1", - "dependencies": { - "@capacitor/android": "^8.5.2", - "@capacitor/core": "^8.5.2", - "ical.js": "^2.2.1", - "imapflow": "2.2.1", - "mailparser": "3.9.33", - "nodemailer": "10.0.9", - "openpgp": "^6.3.2", - "tsdav": "^2.3.4", - "v8-compile-cache": "^2.4.0" - }, - "devDependencies": { - "@capacitor/cli": "^8.5.2", - "electron": "44.5.1", - "electron-builder": "26.17.0", - "esbuild": "^0.28.2" - } - }, - "node_modules/@capacitor/android": { - "version": "8.5.2", - "resolved": "https://registry.npmjs.org/@capacitor/android/-/android-8.5.2.tgz", - "integrity": "sha512-rtiaz78egCcS+vs29wkWCL3C+RhazKMSygXcjutwWP8NmO6r5UBxOvGf3Wjz5+ahobyQ723tn9gCePwRwcNDZQ==", - "license": "MIT", - "peerDependencies": { - "@capacitor/core": "^8.5.0" - } - }, - "node_modules/@capacitor/cli": { - "version": "8.5.2", - "resolved": "https://registry.npmjs.org/@capacitor/cli/-/cli-8.5.2.tgz", - "integrity": "sha512-O2kpA5ZPJUAmliDCcmpMf8xnJwMezxlFPUrlyOAjbL3U9MFNY3l4ZpPI/UXwvyPmR8ETcVF9pFr+VdWq61rqTQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "@ionic/cli-framework-output": "^2.2.8", - "@ionic/utils-subprocess": "^3.0.1", - "@ionic/utils-terminal": "^2.3.5", - "commander": "^12.1.0", - "debug": "^4.4.0", - "env-paths": "^2.2.0", - "fs-extra": "^11.2.0", - "kleur": "^4.1.5", - "native-run": "^2.0.3", - "open": "^8.4.0", - "plist": "^3.1.0", - "prompts": "^2.4.2", - "rimraf": "^6.0.1", - "semver": "^7.6.3", - "tar": "^7.5.3", - "tslib": "^2.8.1", - "xcode": "^3.0.1", - "xml2js": "^0.6.2" - }, - "bin": { - "cap": "bin/capacitor", - "capacitor": "bin/capacitor" - }, - "engines": { - "node": ">=22.0.0" - } - }, - "node_modules/@capacitor/cli/node_modules/commander": { - "version": "12.1.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-12.1.0.tgz", - "integrity": "sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=18" - } - }, - "node_modules/@capacitor/cli/node_modules/env-paths": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/env-paths/-/env-paths-2.2.1.tgz", - "integrity": "sha512-+h1lkLKhZMTYjog1VEpJNG7NZJWcuc2DDk/qsqSTRRCOXiLjeQ1d1/udrUGhqMxUgAlwKNZ0cf2uqan5GLuS2A==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6" - } - }, - "node_modules/@capacitor/cli/node_modules/fs-extra": { - "version": "11.4.1", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-11.4.1.tgz", - "integrity": "sha512-KYAb4c9BJQI6QqGKthV68OHe0badztdXJWKo0WtBA9IuCFPTKvE5ZdUBglP833aMjhaSPNO4A5j/EkzZtGlKjA==", - "dev": true, - "license": "MIT", - "dependencies": { - "graceful-fs": "^4.2.0", - "jsonfile": "^6.0.1", - "universalify": "^2.0.0" - }, - "engines": { - "node": ">=14.14" - } - }, - "node_modules/@capacitor/cli/node_modules/glob": { - "version": "13.0.6", - "resolved": "https://registry.npmjs.org/glob/-/glob-13.0.6.tgz", - "integrity": "sha512-Wjlyrolmm8uDpm/ogGyXZXb1Z+Ca2B8NbJwqBVg0axK9GbBeoS7yGV6vjXnYdGm6X53iehEuxxbyiKp8QmN4Vw==", - "dev": true, - "license": "BlueOak-1.0.0", - "dependencies": { - "minimatch": "^10.2.2", - "minipass": "^7.1.3", - "path-scurry": "^2.0.2" - }, - "engines": { - "node": "18 || 20 || >=22" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/@capacitor/cli/node_modules/rimraf": { - "version": "6.1.3", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-6.1.3.tgz", - "integrity": "sha512-LKg+Cr2ZF61fkcaK1UdkH2yEBBKnYjTyWzTJT6KNPcSPaiT7HSdhtMXQuN5wkTX0Xu72KQ1l8S42rlmexS2hSA==", - "dev": true, - "license": "BlueOak-1.0.0", - "dependencies": { - "glob": "^13.0.3", - "package-json-from-dist": "^1.0.1" - }, - "bin": { - "rimraf": "dist/esm/bin.mjs" - }, - "engines": { - "node": "20 || >=22" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/@capacitor/core": { - "version": "8.5.2", - "resolved": "https://registry.npmjs.org/@capacitor/core/-/core-8.5.2.tgz", - "integrity": "sha512-agnQbGdhGw/KZFuLf7H9SY2o+oE7upkr/WPQsYaokXP6f9chaE8iVmbKkfN6SVl4w3pmz7oZ3Ur1hbkmy1hx+w==", - "license": "MIT", - "dependencies": { - "tslib": "^2.1.0" - } - }, - "node_modules/@electron-internal/extract-zip": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/@electron-internal/extract-zip/-/extract-zip-1.0.5.tgz", - "integrity": "sha512-+bqFCP98pLI0Tt0XQo1TmlXtwjWchISndDOxCkEcIuUgXWpBnLyRI+2DU+mesvnMMX6L1XDqYNA0lXNDHd/yiA==", - "dev": true, - "license": "BSD-2-Clause", - "engines": { - "node": ">=22.12.0" - } - }, - "node_modules/@electron/asar": { - "version": "3.4.1", - "resolved": "https://registry.npmjs.org/@electron/asar/-/asar-3.4.1.tgz", - "integrity": "sha512-i4/rNPRS84t0vSRa2HorerGRXWyF4vThfHesw0dmcWHp+cspK743UanA0suA5Q5y8kzY2y6YKrvbIUn69BCAiA==", - "dev": true, - "license": "MIT", - "dependencies": { - "commander": "^5.0.0", - "glob": "^7.1.6", - "minimatch": "^3.0.4" - }, - "bin": { - "asar": "bin/asar.js" - }, - "engines": { - "node": ">=10.12.0" - } - }, - "node_modules/@electron/asar/node_modules/balanced-match": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", - "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", - "dev": true, - "license": "MIT" - }, - "node_modules/@electron/asar/node_modules/brace-expansion": { - "version": "1.1.21", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.21.tgz", - "integrity": "sha512-9zeA+KLZNNzglF2TPKRQEDyx6Yby7daAkuy8MiPzpXPsYDWi/DRM8jmwUDxokQjYqBpv5DgPiwD4h4ZZSy1Ujw==", - "dev": true, - "license": "MIT", - "dependencies": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "node_modules/@electron/asar/node_modules/minimatch": { - "version": "3.1.5", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.5.tgz", - "integrity": "sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==", - "dev": true, - "license": "ISC", - "dependencies": { - "brace-expansion": "^1.1.7" - }, - "engines": { - "node": "*" - } - }, - "node_modules/@electron/fuses": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/@electron/fuses/-/fuses-1.8.0.tgz", - "integrity": "sha512-zx0EIq78WlY/lBb1uXlziZmDZI4ubcCXIMJ4uGjXzZW0nS19TjSPeXPAjzzTmKQlJUZm0SbmZhPKP7tuQ1SsEw==", - "dev": true, - "license": "MIT", - "dependencies": { - "chalk": "^4.1.1", - "fs-extra": "^9.0.1", - "minimist": "^1.2.5" - }, - "bin": { - "electron-fuses": "dist/bin.js" - } - }, - "node_modules/@electron/fuses/node_modules/fs-extra": { - "version": "9.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-9.1.0.tgz", - "integrity": "sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "at-least-node": "^1.0.0", - "graceful-fs": "^4.2.0", - "jsonfile": "^6.0.1", - "universalify": "^2.0.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/@electron/get": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/@electron/get/-/get-5.1.0.tgz", - "integrity": "sha512-3kSBtG8ObcTVfXanm5vVJ6UnBLEVmVsRk1M+vGqCuMBV+XLCbJYuWQful+yIy0GQDsSlK0kHEriEHn7SPk4EnA==", - "dev": true, - "license": "MIT", - "dependencies": { - "debug": "^4.1.1", - "env-paths": "^3.0.0", - "graceful-fs": "^4.2.11", - "progress": "^2.0.3", - "semver": "^7.6.3", - "sumchecker": "^3.0.1" - }, - "engines": { - "node": ">=22.12.0" - }, - "optionalDependencies": { - "undici": "^7.24.4" - } - }, - "node_modules/@electron/notarize": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/@electron/notarize/-/notarize-2.5.0.tgz", - "integrity": "sha512-jNT8nwH1f9X5GEITXaQ8IF/KdskvIkOFfB2CvwumsveVidzpSc+mvhhTMdAGSYF3O+Nq49lJ7y+ssODRXu06+A==", - "dev": true, - "license": "MIT", - "dependencies": { - "debug": "^4.1.1", - "fs-extra": "^9.0.1", - "promise-retry": "^2.0.1" - }, - "engines": { - "node": ">= 10.0.0" - } - }, - "node_modules/@electron/notarize/node_modules/fs-extra": { - "version": "9.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-9.1.0.tgz", - "integrity": "sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "at-least-node": "^1.0.0", - "graceful-fs": "^4.2.0", - "jsonfile": "^6.0.1", - "universalify": "^2.0.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/@electron/osx-sign": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/@electron/osx-sign/-/osx-sign-1.3.3.tgz", - "integrity": "sha512-KZ8mhXvWv2rIEgMbWZ4y33bDHyUKMXnx4M0sTyPNK/vcB81ImdeY9Ggdqy0SWbMDgmbqyQ+phgejh6V3R2QuSg==", - "dev": true, - "license": "BSD-2-Clause", - "dependencies": { - "compare-version": "^0.1.2", - "debug": "^4.3.4", - "fs-extra": "^10.0.0", - "isbinaryfile": "^4.0.8", - "minimist": "^1.2.6", - "plist": "^3.0.5" - }, - "bin": { - "electron-osx-flat": "bin/electron-osx-flat.js", - "electron-osx-sign": "bin/electron-osx-sign.js" - }, - "engines": { - "node": ">=12.0.0" - } - }, - "node_modules/@electron/osx-sign/node_modules/isbinaryfile": { - "version": "4.0.10", - "resolved": "https://registry.npmjs.org/isbinaryfile/-/isbinaryfile-4.0.10.tgz", - "integrity": "sha512-iHrqe5shvBUcFbmZq9zOQHBoeOhZJu6RQGrDpBgenUm/Am+F3JM2MgQj+rK3Z601fzrL5gLZWtAPH2OBaSVcyw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 8.0.0" - }, - "funding": { - "url": "https://github.com/sponsors/gjtorikian/" - } - }, - "node_modules/@electron/rebuild": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/@electron/rebuild/-/rebuild-4.2.0.tgz", - "integrity": "sha512-RKL/O+jGoXJMxrx/5771y1n0xTKmFuOYGO3gMmwypBM6rsH0kou0mswwdXA2JrhIkE4xyC7v9vGk0n6NPzgOxQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "@malept/cross-spawn-promise": "^2.0.0", - "debug": "^4.1.1", - "node-abi": "^4.2.0", - "node-api-version": "^0.2.1", - "node-gyp": "^12.2.0", - "read-binary-file-arch": "^1.0.6" - }, - "bin": { - "electron-rebuild": "lib/cli.js" - }, - "engines": { - "node": ">=22.12.0" - } - }, - "node_modules/@electron/universal": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/@electron/universal/-/universal-2.0.3.tgz", - "integrity": "sha512-Wn9sPYIVFRFl5HmwMJkARCCf7rqK/EurkfQ/rJZ14mHP3iYTjZSIOSVonEAnhWeAXwtw7zOekGRlc6yTtZ0t+g==", - "dev": true, - "license": "MIT", - "dependencies": { - "@electron/asar": "^3.3.1", - "@malept/cross-spawn-promise": "^2.0.0", - "debug": "^4.3.1", - "dir-compare": "^4.2.0", - "fs-extra": "^11.1.1", - "minimatch": "^9.0.3", - "plist": "^3.1.0" - }, - "engines": { - "node": ">=16.4" - } - }, - "node_modules/@electron/universal/node_modules/balanced-match": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", - "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", - "dev": true, - "license": "MIT" - }, - "node_modules/@electron/universal/node_modules/brace-expansion": { - "version": "2.1.7", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.1.7.tgz", - "integrity": "sha512-uZbew1NqdmPDTMJ8ah1y+b+9QEJrfkXFk3RcTQw3X0jW/xRUvFKsg1CfQdSYGdTbXZWExtU3J3ccxtnfw1Fi0g==", - "dev": true, - "license": "MIT", - "dependencies": { - "balanced-match": "^1.0.0" - } - }, - "node_modules/@electron/universal/node_modules/fs-extra": { - "version": "11.4.1", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-11.4.1.tgz", - "integrity": "sha512-KYAb4c9BJQI6QqGKthV68OHe0badztdXJWKo0WtBA9IuCFPTKvE5ZdUBglP833aMjhaSPNO4A5j/EkzZtGlKjA==", - "dev": true, - "license": "MIT", - "dependencies": { - "graceful-fs": "^4.2.0", - "jsonfile": "^6.0.1", - "universalify": "^2.0.0" - }, - "engines": { - "node": ">=14.14" - } - }, - "node_modules/@electron/universal/node_modules/minimatch": { - "version": "9.0.9", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.9.tgz", - "integrity": "sha512-OBwBN9AL4dqmETlpS2zasx+vTeWclWzkblfZk7KTA5j3jeOONz/tRCnZomUyvNg83wL5Zv9Ss6HMJXAgL8R2Yg==", - "dev": true, - "license": "ISC", - "dependencies": { - "brace-expansion": "^2.0.2" - }, - "engines": { - "node": ">=16 || 14 >=14.17" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/@electron/windows-sign": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/@electron/windows-sign/-/windows-sign-1.2.2.tgz", - "integrity": "sha512-dfZeox66AvdPtb2lD8OsIIQh12Tp0GNCRUDfBHIKGpbmopZto2/A8nSpYYLoedPIHpqkeblZ/k8OV0Gy7PYuyQ==", - "dev": true, - "license": "BSD-2-Clause", - "optional": true, - "peer": true, - "dependencies": { - "cross-dirname": "^0.1.0", - "debug": "^4.3.4", - "fs-extra": "^11.1.1", - "minimist": "^1.2.8", - "postject": "^1.0.0-alpha.6" - }, - "bin": { - "electron-windows-sign": "bin/electron-windows-sign.js" - }, - "engines": { - "node": ">=14.14" - } - }, - "node_modules/@electron/windows-sign/node_modules/fs-extra": { - "version": "11.4.1", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-11.4.1.tgz", - "integrity": "sha512-KYAb4c9BJQI6QqGKthV68OHe0badztdXJWKo0WtBA9IuCFPTKvE5ZdUBglP833aMjhaSPNO4A5j/EkzZtGlKjA==", - "dev": true, - "license": "MIT", - "optional": true, - "peer": true, - "dependencies": { - "graceful-fs": "^4.2.0", - "jsonfile": "^6.0.1", - "universalify": "^2.0.0" - }, - "engines": { - "node": ">=14.14" - } - }, - "node_modules/@esbuild/aix-ppc64": { - "version": "0.28.2", - "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.28.2.tgz", - "integrity": "sha512-XExcO+dvLKvVtNTibSTBej1NCAbaGhWn9Ww1ZPx80qsahhPFe/8jgWP0IchNe0F3HwkU7n8ejhH8bjonqht8mQ==", - "cpu": [ - "ppc64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "aix" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/android-arm": { - "version": "0.28.2", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.28.2.tgz", - "integrity": "sha512-kXXoiPVVGQcnIYGOeaovwOURpniDBpSq4A03qkQ+BMQqtGG6HYap3xne9C1O1yo4TR3qxlCX5IqqmX6fFo2Lqg==", - "cpu": [ - "arm" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "android" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/android-arm64": { - "version": "0.28.2", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.28.2.tgz", - "integrity": "sha512-5YfKeeI8qWfBZIX+u2xZC3Zlb3Os/gLS2sbEKM+I4ZOcsWmHS2WLysCcQZDAFRslDUU5Oiq44gf6PYN1vGwG5A==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "android" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/android-x64": { - "version": "0.28.2", - "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.28.2.tgz", - "integrity": "sha512-O387ite7SzUyCcy3JQX4P4bLtEA7bLLkx+esve5JHnyYfNTxcVpXZo9jhdB0lTKN44gztELTdU7nS8Nr16Fs1Q==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "android" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/darwin-arm64": { - "version": "0.28.2", - "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.28.2.tgz", - "integrity": "sha512-n4KqkOQrraxHJcgjM1RvwbigfQKIKJVpM7xp+KsxiyUSrRdIXnt73VhrPAx0fV44hgfmIVKjxMN9J1t5jySVkw==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/darwin-x64": { - "version": "0.28.2", - "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.28.2.tgz", - "integrity": "sha512-uq6suIWYP37qzGddBKPw5QEQPi6HiLGsO7UmkpfyaYNQ3D+rN6w6WfwH+nuqcGXWvawGwxOEroO4YGnFh95azw==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/freebsd-arm64": { - "version": "0.28.2", - "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.28.2.tgz", - "integrity": "sha512-n+I0BTSRIoy+d6RPKnEVwql5UwBJolytvY4mAOIEJorKlqgPII8ix6slVVrfZ5Tnj7glIZvloylbB/EJPMWEXw==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "freebsd" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/freebsd-x64": { - "version": "0.28.2", - "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.28.2.tgz", - "integrity": "sha512-78XJTJkvPs0kz2w61301PJjXl4g7q3JqiYMZ/M/yVI73EHBrCRTgkhu9oqG7vPqq+a/yadEW8aD+agKlk5xrmg==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "freebsd" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/linux-arm": { - "version": "0.28.2", - "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.28.2.tgz", - "integrity": "sha512-XlDnu2q5yoqems+xay6wSAcg9DDD7K9RLKZEBOMZm3ckNpJBvOX20tSfby8KfrrhINDyv9V2YVZKY/SpoGJI8w==", - "cpu": [ - "arm" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/linux-arm64": { - "version": "0.28.2", - "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.28.2.tgz", - "integrity": "sha512-pW4AC0P3it8c7do9MVM4p51FzHzdM/TZrerurgRcHJ2WTa1VQ1CIq18xncfpBJw4ojkiZZrKW2yIBWBP92j6Ug==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/linux-ia32": { - "version": "0.28.2", - "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.28.2.tgz", - "integrity": "sha512-CYbnj78HsIeA+DhgUKgFCfvNsTHFhMMrinUrMZpDXJXKN8T3XViTZ/+wtHeVxEWY8ewSzTFN+nRmSwO2tZaLUQ==", - "cpu": [ - "ia32" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/linux-loong64": { - "version": "0.28.2", - "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.28.2.tgz", - "integrity": "sha512-buwkd8nsph4R+ajRvw0qM5Hja/TXQow3ptzWO2EbG/cqcIkHloRrdlBtQlshyYGTNFvfkfJ5tpPLVkY4DtsPfQ==", - "cpu": [ - "loong64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/linux-mips64el": { - "version": "0.28.2", - "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.28.2.tgz", - "integrity": "sha512-ZVykbDyk7519VwiNb9Lcj9m8XM6v5V9uKPvrEMkkEedVewf+0itkhahp4HDpgERXhwLRpWFypsGbG/J8s0QjJA==", - "cpu": [ - "mips64el" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/linux-ppc64": { - "version": "0.28.2", - "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.28.2.tgz", - "integrity": "sha512-CAXl+Dtd9UUuJd8pKKdwh6MLm3MUMiqMPmhZ3tTSXPqfyQ3vDl6R5hZdZ/kYojK4ofXtdfSv1tFq8XzWx3heNQ==", - "cpu": [ - "ppc64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/linux-riscv64": { - "version": "0.28.2", - "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.28.2.tgz", - "integrity": "sha512-GeXCej4IQtU1B+QlDV8W/RRvbzI3O/Stss+/bCXv4lZls5WGRtu2a+3JkA3i4qIUlMXpcHebWpF8AkJhATowuA==", - "cpu": [ - "riscv64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/linux-s390x": { - "version": "0.28.2", - "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.28.2.tgz", - "integrity": "sha512-3H1weTYZPxt/WOhByszQZybS9w5lKzUn1FDMsgEChbHWQwHYQQRfBxgCcZvPhjHfKyJjIievvMmEUawJrdY9Dg==", - "cpu": [ - "s390x" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/linux-x64": { - "version": "0.28.2", - "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.28.2.tgz", - "integrity": "sha512-4xTZr1FUmSoQW4XIWmit3tzQrUTZM+N3P0XV8xROKYF50XfI7xeO90+1bZvNwxIufQ9hDQVRJH5YhgPVF8A/HQ==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/netbsd-arm64": { - "version": "0.28.2", - "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.28.2.tgz", - "integrity": "sha512-sSATRjPeDBg3pdgHoQfoYBob11Kk1FGa9lui5RIHZCoCkJa9QKlvl3/vKz2usCmYYjs7ymJR/2Nnsqe+Hjt5nw==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "netbsd" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/netbsd-x64": { - "version": "0.28.2", - "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.28.2.tgz", - "integrity": "sha512-lqnzCV+mM0gIADaKihiCg6ifgfU2L3h5E33rNQBN1Y4MaVGnzryzmvvf7UHxprpQdE8hpqLolJ9Rl+SkIRDpyw==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "netbsd" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/openbsd-arm64": { - "version": "0.28.2", - "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.28.2.tgz", - "integrity": "sha512-AL2qJILH7lNjrDmCQDvdxMfAUIv8KMNZOvrwAQ8i8//ntL9FflhOyMJ8OZSMBb8/AWXe3/5v5S20y3zCoZWKoQ==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "openbsd" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/openbsd-x64": { - "version": "0.28.2", - "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.28.2.tgz", - "integrity": "sha512-QtiuPytchRyC4rwUKhexJdQKvDuZ6hWloi3igqPQNUJCS1/v9EiO3UTOXR6A3FoMo4fnAKbWJdqaIwhOzh8qEw==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "openbsd" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/openharmony-arm64": { - "version": "0.28.2", - "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.28.2.tgz", - "integrity": "sha512-WkhYDmpTjLvGlScA1rwjRUmhl4k8oXR3cIbtqWmELgU/dFeHHlEllxDvdWcNJV9rbzCexB5vz8gtNewWLgCT7Q==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "openharmony" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/sunos-x64": { - "version": "0.28.2", - "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.28.2.tgz", - "integrity": "sha512-GPMSkTOtMnv2U2F8gxe4Io6qmVs+YKyp832Etqqxr0hFngmXQ3rzwytelm3GIn7T4VviRUlf3sOgBOiTdvaf7g==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "sunos" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/win32-arm64": { - "version": "0.28.2", - "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.28.2.tgz", - "integrity": "sha512-PIhhEkE9uPBleRBrQEJpUn7MBnibZzbGzYWPmY3x+YoVg/95zbjB4CxPPOQ8l5tYYM4mMaCthF8/1DIfBQQyWQ==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/win32-ia32": { - "version": "0.28.2", - "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.28.2.tgz", - "integrity": "sha512-YmJbfTlvU7Sdn9BB+4PRES4oB6pxgS37MAONj+hBr/cpXS1aBPKXxNnDbu+QCWPj0o9dgyxeq79g6c5P8KeuYA==", - "cpu": [ - "ia32" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/win32-x64": { - "version": "0.28.2", - "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.28.2.tgz", - "integrity": "sha512-5ebpxr3nWMzrL/rnUI755Jkuee0bHL/Gq0WTF9lvcpv73wAp5eu8MfBUgWK9bhWvZjj7yX8etf/8tI8Ney695g==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@ionic/cli-framework-output": { - "version": "2.2.8", - "resolved": "https://registry.npmjs.org/@ionic/cli-framework-output/-/cli-framework-output-2.2.8.tgz", - "integrity": "sha512-TshtaFQsovB4NWRBydbNFawql6yul7d5bMiW1WYYf17hd99V6xdDdk3vtF51bw6sLkxON3bDQpWsnUc9/hVo3g==", - "dev": true, - "license": "MIT", - "dependencies": { - "@ionic/utils-terminal": "2.3.5", - "debug": "^4.0.0", - "tslib": "^2.0.1" - }, - "engines": { - "node": ">=16.0.0" - } - }, - "node_modules/@ionic/utils-array": { - "version": "2.1.6", - "resolved": "https://registry.npmjs.org/@ionic/utils-array/-/utils-array-2.1.6.tgz", - "integrity": "sha512-0JZ1Zkp3wURnv8oq6Qt7fMPo5MpjbLoUoa9Bu2Q4PJuSDWM8H8gwF3dQO7VTeUj3/0o1IB1wGkFWZZYgUXZMUg==", - "dev": true, - "license": "MIT", - "dependencies": { - "debug": "^4.0.0", - "tslib": "^2.0.1" - }, - "engines": { - "node": ">=16.0.0" - } - }, - "node_modules/@ionic/utils-fs": { - "version": "3.1.7", - "resolved": "https://registry.npmjs.org/@ionic/utils-fs/-/utils-fs-3.1.7.tgz", - "integrity": "sha512-2EknRvMVfhnyhL1VhFkSLa5gOcycK91VnjfrTB0kbqkTFCOXyXgVLI5whzq7SLrgD9t1aqos3lMMQyVzaQ5gVA==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/fs-extra": "^8.0.0", - "debug": "^4.0.0", - "fs-extra": "^9.0.0", - "tslib": "^2.0.1" - }, - "engines": { - "node": ">=16.0.0" - } - }, - "node_modules/@ionic/utils-fs/node_modules/@types/fs-extra": { - "version": "8.1.5", - "resolved": "https://registry.npmjs.org/@types/fs-extra/-/fs-extra-8.1.5.tgz", - "integrity": "sha512-0dzKcwO+S8s2kuF5Z9oUWatQJj5Uq/iqphEtE3GQJVRRYm/tD1LglU2UnXi2A8jLq5umkGouOXOR9y0n613ZwQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/node": "*" - } - }, - "node_modules/@ionic/utils-fs/node_modules/fs-extra": { - "version": "9.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-9.1.0.tgz", - "integrity": "sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "at-least-node": "^1.0.0", - "graceful-fs": "^4.2.0", - "jsonfile": "^6.0.1", - "universalify": "^2.0.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/@ionic/utils-object": { - "version": "2.1.6", - "resolved": "https://registry.npmjs.org/@ionic/utils-object/-/utils-object-2.1.6.tgz", - "integrity": "sha512-vCl7sl6JjBHFw99CuAqHljYJpcE88YaH2ZW4ELiC/Zwxl5tiwn4kbdP/gxi2OT3MQb1vOtgAmSNRtusvgxI8ww==", - "dev": true, - "license": "MIT", - "dependencies": { - "debug": "^4.0.0", - "tslib": "^2.0.1" - }, - "engines": { - "node": ">=16.0.0" - } - }, - "node_modules/@ionic/utils-process": { - "version": "2.1.12", - "resolved": "https://registry.npmjs.org/@ionic/utils-process/-/utils-process-2.1.12.tgz", - "integrity": "sha512-Jqkgyq7zBs/v/J3YvKtQQiIcxfJyplPgECMWgdO0E1fKrrH8EF0QGHNJ9mJCn6PYe2UtHNS8JJf5G21e09DfYg==", - "dev": true, - "license": "MIT", - "dependencies": { - "@ionic/utils-object": "2.1.6", - "@ionic/utils-terminal": "2.3.5", - "debug": "^4.0.0", - "signal-exit": "^3.0.3", - "tree-kill": "^1.2.2", - "tslib": "^2.0.1" - }, - "engines": { - "node": ">=16.0.0" - } - }, - "node_modules/@ionic/utils-stream": { - "version": "3.1.7", - "resolved": "https://registry.npmjs.org/@ionic/utils-stream/-/utils-stream-3.1.7.tgz", - "integrity": "sha512-eSELBE7NWNFIHTbTC2jiMvh1ABKGIpGdUIvARsNPMNQhxJB3wpwdiVnoBoTYp+5a6UUIww4Kpg7v6S7iTctH1w==", - "dev": true, - "license": "MIT", - "dependencies": { - "debug": "^4.0.0", - "tslib": "^2.0.1" - }, - "engines": { - "node": ">=16.0.0" - } - }, - "node_modules/@ionic/utils-subprocess": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/@ionic/utils-subprocess/-/utils-subprocess-3.0.1.tgz", - "integrity": "sha512-cT4te3AQQPeIM9WCwIg8ohroJ8TjsYaMb2G4ZEgv9YzeDqHZ4JpeIKqG2SoaA3GmVQ3sOfhPM6Ox9sxphV/d1A==", - "dev": true, - "license": "MIT", - "dependencies": { - "@ionic/utils-array": "2.1.6", - "@ionic/utils-fs": "3.1.7", - "@ionic/utils-process": "2.1.12", - "@ionic/utils-stream": "3.1.7", - "@ionic/utils-terminal": "2.3.5", - "cross-spawn": "^7.0.3", - "debug": "^4.0.0", - "tslib": "^2.0.1" - }, - "engines": { - "node": ">=16.0.0" - } - }, - "node_modules/@ionic/utils-terminal": { - "version": "2.3.5", - "resolved": "https://registry.npmjs.org/@ionic/utils-terminal/-/utils-terminal-2.3.5.tgz", - "integrity": "sha512-3cKScz9Jx2/Pr9ijj1OzGlBDfcmx7OMVBt4+P1uRR0SSW4cm1/y3Mo4OY3lfkuaYifMNBW8Wz6lQHbs1bihr7A==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/slice-ansi": "^4.0.0", - "debug": "^4.0.0", - "signal-exit": "^3.0.3", - "slice-ansi": "^4.0.0", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0", - "tslib": "^2.0.1", - "untildify": "^4.0.0", - "wrap-ansi": "^7.0.0" - }, - "engines": { - "node": ">=16.0.0" - } - }, - "node_modules/@isaacs/fs-minipass": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/@isaacs/fs-minipass/-/fs-minipass-4.0.1.tgz", - "integrity": "sha512-wgm9Ehl2jpeqP3zw/7mo3kRHFp5MEDhqAdwy1fTGkHAwnkGOVsgpvQhL8B5n1qlb01jV3n/bI0ZfZp5lWA1k4w==", - "dev": true, - "license": "ISC", - "dependencies": { - "minipass": "^7.0.4" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/@malept/cross-spawn-promise": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@malept/cross-spawn-promise/-/cross-spawn-promise-2.0.0.tgz", - "integrity": "sha512-1DpKU0Z5ThltBwjNySMC14g0CkbyhCaz9FkhxqNsZI6uAPJXFS8cMXlBKo26FJ8ZuW6S9GCMcR9IO5k2X5/9Fg==", - "dev": true, - "funding": [ - { - "type": "individual", - "url": "https://github.com/sponsors/malept" - }, - { - "type": "tidelift", - "url": "https://tidelift.com/subscription/pkg/npm-.malept-cross-spawn-promise?utm_medium=referral&utm_source=npm_fund" - } - ], - "license": "Apache-2.0", - "dependencies": { - "cross-spawn": "^7.0.1" - }, - "engines": { - "node": ">= 12.13.0" - } - }, - "node_modules/@malept/flatpak-bundler": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/@malept/flatpak-bundler/-/flatpak-bundler-0.4.0.tgz", - "integrity": "sha512-9QOtNffcOF/c1seMCDnjckb3R9WHcG34tky+FHpNKKCW0wc/scYLwMtO+ptyGUfMW0/b/n4qRiALlaFHc9Oj7Q==", - "dev": true, - "license": "MIT", - "dependencies": { - "debug": "^4.1.1", - "fs-extra": "^9.0.0", - "lodash": "^4.17.15", - "tmp-promise": "^3.0.2" - }, - "engines": { - "node": ">= 10.0.0" - } - }, - "node_modules/@malept/flatpak-bundler/node_modules/fs-extra": { - "version": "9.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-9.1.0.tgz", - "integrity": "sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "at-least-node": "^1.0.0", - "graceful-fs": "^4.2.0", - "jsonfile": "^6.0.1", - "universalify": "^2.0.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/@noble/hashes": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.8.0.tgz", - "integrity": "sha512-jCs9ldd7NwzpgXDIf6P3+NrHh9/sD6CQdxHyjQI+h/6rDNo88ypBxxz45UDuZHz9r3tNz7N/VInSVoVdtXEI4A==", - "dev": true, - "license": "MIT", - "engines": { - "node": "^14.21.3 || >=16" - }, - "funding": { - "url": "https://paulmillr.com/funding/" - } - }, - "node_modules/@peculiar/asn1-schema": { - "version": "2.10.0", - "resolved": "https://registry.npmjs.org/@peculiar/asn1-schema/-/asn1-schema-2.10.0.tgz", - "integrity": "sha512-GhokD41lV4gQrrLYm3wCkHfBOnJrnhDMgt4XeMW8gzfE1UdJqIuSwsE+ggf82XBjUXRJylcm+KIGQFa4utIVLw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@peculiar/utils": "^2.0.2", - "asn1js": "^3.0.10", - "tslib": "^2.8.1" - }, - "engines": { - "node": ">=14" - } - }, - "node_modules/@peculiar/json-schema": { - "version": "1.1.12", - "resolved": "https://registry.npmjs.org/@peculiar/json-schema/-/json-schema-1.1.12.tgz", - "integrity": "sha512-coUfuoMeIB7B8/NMekxaDzLhaYmp0HZNPEjYRm9goRou8UZIC3z21s0sL9AWoCw4EG876QyO3kYrc61WNF9B/w==", - "dev": true, - "license": "MIT", - "dependencies": { - "tslib": "^2.0.0" - }, - "engines": { - "node": ">=8.0.0" - } - }, - "node_modules/@peculiar/utils": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/@peculiar/utils/-/utils-2.0.3.tgz", - "integrity": "sha512-+oL3HPFRIZ1St2K50lWCXiioIgSoxzz7R1J3uF6neO2yl1sgmpgY6XXJH4BdpoDkMWznQTeYF6oWNDZLCdQ4eQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "tslib": "^2.8.1" - } - }, - "node_modules/@peculiar/webcrypto": { - "version": "1.7.1", - "resolved": "https://registry.npmjs.org/@peculiar/webcrypto/-/webcrypto-1.7.1.tgz", - "integrity": "sha512-ODOov0sGMJMf3jPonOkgGqPknTsu+DdQ7kD++gz8aI+aFMOMHFbWAA2taqXXVTdP+OTOQR/znGvSpmkeI0WTYQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "@peculiar/asn1-schema": "^2.7.0", - "@peculiar/json-schema": "^1.1.12", - "@peculiar/utils": "^2.0.2", - "tslib": "^2.8.1", - "webcrypto-core": "^1.9.2" - }, - "engines": { - "node": ">=14.18.0" - } - }, - "node_modules/@pinojs/redact": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/@pinojs/redact/-/redact-0.4.0.tgz", - "integrity": "sha512-k2ENnmBugE/rzQfEcdWHcCY+/FM3VLzH9cYEsbdsoqrvzAKRhUZeRNhAZvB8OitQJ1TBed3yqWtdjzS6wJKBwg==", - "license": "MIT" - }, - "node_modules/@selderee/plugin-htmlparser2": { - "version": "0.12.0", - "resolved": "https://registry.npmjs.org/@selderee/plugin-htmlparser2/-/plugin-htmlparser2-0.12.0.tgz", - "integrity": "sha512-oELmoyA6ML9jDRMV3kgcMQFKxUfBU0yFVn6yTctVaLT5ygXnxH52I3TZEgV9EhXJC68/uFvE5Daj1/25c0Xa/A==", - "license": "MIT", - "dependencies": { - "domelementtype": "~2.3.0", - "domhandler": "~5.0.3" - }, - "funding": { - "url": "https://github.com/sponsors/KillyMXI" - }, - "peerDependencies": { - "selderee": "~0.12.0" - } - }, - "node_modules/@sindresorhus/is": { - "version": "4.6.0", - "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-4.6.0.tgz", - "integrity": "sha512-t09vSN3MdfsyCHoFcTRCH/iUtG7OJ0CsjzB8cjAmKc/va/kIgeDI/TxsigdncE/4be734m0cvIYwNaV4i2XqAw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sindresorhus/is?sponsor=1" - } - }, - "node_modules/@szmarczak/http-timer": { - "version": "4.0.6", - "resolved": "https://registry.npmjs.org/@szmarczak/http-timer/-/http-timer-4.0.6.tgz", - "integrity": "sha512-4BAffykYOgO+5nzBWYwE3W90sBgLJoUPRWWcL8wlyiM8IB8ipJz3UMJ9KXQd1RKQXpKp8Tutn80HZtWsu2u76w==", - "dev": true, - "license": "MIT", - "dependencies": { - "defer-to-connect": "^2.0.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/@types/cacheable-request": { - "version": "6.0.3", - "resolved": "https://registry.npmjs.org/@types/cacheable-request/-/cacheable-request-6.0.3.tgz", - "integrity": "sha512-IQ3EbTzGxIigb1I3qPZc1rWJnH0BmSKv5QYTalEwweFvyBDLSAe24zP0le/hyi7ecGfZVlIVAg4BZqb8WBwKqw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/http-cache-semantics": "*", - "@types/keyv": "^3.1.4", - "@types/node": "*", - "@types/responselike": "^1.0.0" - } - }, - "node_modules/@types/debug": { - "version": "4.1.13", - "resolved": "https://registry.npmjs.org/@types/debug/-/debug-4.1.13.tgz", - "integrity": "sha512-KSVgmQmzMwPlmtljOomayoR89W4FynCAi3E8PPs7vmDVPe84hT+vGPKkJfThkmXs0x0jAaa9U8uW8bbfyS2fWw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/ms": "*" - } - }, - "node_modules/@types/fs-extra": { - "version": "9.0.13", - "resolved": "https://registry.npmjs.org/@types/fs-extra/-/fs-extra-9.0.13.tgz", - "integrity": "sha512-nEnwB++1u5lVDM2UI4c1+5R+FYaKfaAzS4OococimjVm3nQw3TuzH5UNsocrcTBbhnerblyHj4A49qXbIiZdpA==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/node": "*" - } - }, - "node_modules/@types/http-cache-semantics": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/@types/http-cache-semantics/-/http-cache-semantics-4.2.0.tgz", - "integrity": "sha512-L3LgimLHXtGkWikKnsPg0/VFx9OGZaC+eN1u4r+OB1XRqH3meBIAVC2zr1WdMH+RHmnRkqliQAOHNJ/E0j/e0Q==", - "dev": true, - "license": "MIT" - }, - "node_modules/@types/keyv": { - "version": "3.1.4", - "resolved": "https://registry.npmjs.org/@types/keyv/-/keyv-3.1.4.tgz", - "integrity": "sha512-BQ5aZNSCpj7D6K2ksrRCTmKRLEpnPvWDiLPfoGyhZ++8YtiK9d/3DBKPJgry359X/P1PfruyYwvnvwFjuEiEIg==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/node": "*" - } - }, - "node_modules/@types/ms": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/@types/ms/-/ms-2.1.0.tgz", - "integrity": "sha512-GsCCIZDE/p3i96vtEqx+7dBUGXrc7zeSK3wwPHIaRThS+9OhWIXRqzs4d6k1SVU8g91DrNRWxWUGhp5KXQb2VA==", - "dev": true, - "license": "MIT" - }, - "node_modules/@types/node": { - "version": "24.19.1", - "resolved": "https://registry.npmjs.org/@types/node/-/node-24.19.1.tgz", - "integrity": "sha512-aS3/DG0oM05K0RIXXP+hKjinGG5IgSSVGzswZxW3O0sS3pH4/fycXundUC9XsszgKCk4gHXylTEK6hyFxVxnoQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "undici-types": ">=7.24.0 <7.24.7" - } - }, - "node_modules/@types/responselike": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@types/responselike/-/responselike-1.0.3.tgz", - "integrity": "sha512-H/+L+UkTV33uf49PH5pCAUBVPNj2nDBXTN+qS1dOwyyg24l3CcicicCA7ca+HMvJBZcFgl5r8e+RR6elsb4Lyw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/node": "*" - } - }, - "node_modules/@types/slice-ansi": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/@types/slice-ansi/-/slice-ansi-4.0.0.tgz", - "integrity": "sha512-+OpjSaq85gvlZAYINyzKpLeiFkSC4EsC6IIiT6v6TLSU5k5U83fHGj9Lel8oKEXM0HqgrMVCjXPDPVICtxF7EQ==", - "dev": true, - "license": "MIT" - }, - "node_modules/@xmldom/xmldom": { - "version": "0.8.15", - "resolved": "https://registry.npmjs.org/@xmldom/xmldom/-/xmldom-0.8.15.tgz", - "integrity": "sha512-/5NV/vDALVFDXgLmfsy9TRCBlKwO2LNBFzpzvb9iIj+jR+eSc6DLYYvVOdivT/jm7MtU6TebYuRmzEOI7w40UA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=10.0.0" - } - }, - "node_modules/@zone-eu/mailsplit": { - "version": "5.4.19", - "resolved": "https://registry.npmjs.org/@zone-eu/mailsplit/-/mailsplit-5.4.19.tgz", - "integrity": "sha512-nDWzw+X3tqfwd7DpDThAjg3KqtrNA6bG2gkrf6m2j1JBaGyyKAZzu1TguzB4GEco+HYpXAbXZ7kbl4Sn8H1vXw==", - "license": "(MIT OR EUPL-1.1+)", - "dependencies": { - "libbase64": "1.3.1", - "libmime": "5.4.6", - "libqp": "2.1.2" - } - }, - "node_modules/abbrev": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-4.0.0.tgz", - "integrity": "sha512-a1wflyaL0tHtJSmLSOVybYhy22vRih4eduhhrkcjgrWGnRfrZtovJ2FRjxuTtkkj47O/baf0R86QU5OuYpz8fA==", - "dev": true, - "license": "ISC", - "engines": { - "node": "^20.17.0 || >=22.9.0" - } - }, - "node_modules/agent-base": { - "version": "7.1.4", - "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.4.tgz", - "integrity": "sha512-MnA+YT8fwfJPgBx3m60MNqakm30XOkyIoH1y6huTQvC0PwZG7ki8NacLBcrPbNoo8vEZy7Jpuk7+jMO+CUovTQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 14" - } - }, - "node_modules/ajv": { - "version": "8.20.0", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.20.0.tgz", - "integrity": "sha512-Thbli+OlOj+iMPYFBVBfJ3OmCAnaSyNn4M1vz9T6Gka5Jt9ba/HIR56joy65tY6kx/FCF5VXNB819Y7/GUrBGA==", - "dev": true, - "license": "MIT", - "dependencies": { - "fast-deep-equal": "^3.1.3", - "fast-uri": "^3.0.1", - "json-schema-traverse": "^1.0.0", - "require-from-string": "^2.0.2" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/epoberezkin" - } - }, - "node_modules/ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" - } - }, - "node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "license": "MIT", - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/app-builder-lib": { - "version": "26.17.0", - "resolved": "https://registry.npmjs.org/app-builder-lib/-/app-builder-lib-26.17.0.tgz", - "integrity": "sha512-wfL7EhujuODDW3uMSD8RPcr/MLzmT0dmpVfWV0wFUWXI0rIdaukzAJ7EFUSyHXOpxuBZqaIGlQt6VeQhtHhetw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@electron/asar": "3.4.1", - "@electron/fuses": "^1.8.0", - "@electron/get": "^3.0.0", - "@electron/notarize": "2.5.0", - "@electron/osx-sign": "1.3.3", - "@electron/rebuild": "^4.0.4", - "@electron/universal": "2.0.3", - "@malept/flatpak-bundler": "^0.4.0", - "@noble/hashes": "^1.8.0", - "@peculiar/webcrypto": "^1.7.1", - "@types/fs-extra": "9.0.13", - "ajv": "^8.18.0", - "asn1js": "^3.0.10", - "async-exit-hook": "^2.0.1", - "builder-util": "26.16.0", - "builder-util-runtime": "9.7.0", - "chromium-pickle-js": "^0.2.0", - "ci-info": "4.3.1", - "debug": "^4.3.4", - "dotenv": "^16.4.5", - "dotenv-expand": "^11.0.6", - "ejs": "^3.1.8", - "electron-publish": "26.16.0", - "fs-extra": "^10.1.0", - "hosted-git-info": "^4.1.0", - "isbinaryfile": "^5.0.0", - "jiti": "^2.4.2", - "js-yaml": "^4.1.0", - "json5": "^2.2.3", - "lazy-val": "^1.0.5", - "minimatch": "^10.2.5", - "pkijs": "^3.4.0", - "plist": "3.1.0", - "proper-lockfile": "^4.1.2", - "resedit": "^1.7.0", - "semver": "~7.7.3", - "tar": "^7.5.7", - "temp-file": "^3.4.0", - "tiny-async-pool": "1.3.0", - "unzipper": "^0.12.3", - "which": "^5.0.0" - }, - "engines": { - "node": ">=14.0.0" - }, - "peerDependencies": { - "dmg-builder": "26.17.0", - "electron-builder-squirrel-windows": "26.17.0" - } - }, - "node_modules/app-builder-lib/node_modules/@electron/get": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/@electron/get/-/get-3.1.0.tgz", - "integrity": "sha512-F+nKc0xW+kVbBRhFzaMgPy3KwmuNTYX1fx6+FxxoSnNgwYX6LD7AKBTWkU0MQ6IBoe7dz069CNkR673sPAgkCQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "debug": "^4.1.1", - "env-paths": "^2.2.0", - "fs-extra": "^8.1.0", - "got": "^11.8.5", - "progress": "^2.0.3", - "semver": "^6.2.0", - "sumchecker": "^3.0.1" - }, - "engines": { - "node": ">=14" - }, - "optionalDependencies": { - "global-agent": "^3.0.0" - } - }, - "node_modules/app-builder-lib/node_modules/@electron/get/node_modules/fs-extra": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", - "integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==", - "dev": true, - "license": "MIT", - "dependencies": { - "graceful-fs": "^4.2.0", - "jsonfile": "^4.0.0", - "universalify": "^0.1.0" - }, - "engines": { - "node": ">=6 <7 || >=8" - } - }, - "node_modules/app-builder-lib/node_modules/@electron/get/node_modules/semver": { - "version": "6.3.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", - "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", - "dev": true, - "license": "ISC", - "bin": { - "semver": "bin/semver.js" - } - }, - "node_modules/app-builder-lib/node_modules/ci-info": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-4.3.1.tgz", - "integrity": "sha512-Wdy2Igu8OcBpI2pZePZ5oWjPC38tmDVx5WKUXKwlLYkA0ozo85sLsLvkBbBn/sZaSCMFOGZJ14fvW9t5/d7kdA==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/sibiraj-s" - } - ], - "license": "MIT", - "engines": { - "node": ">=8" - } - }, - "node_modules/app-builder-lib/node_modules/env-paths": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/env-paths/-/env-paths-2.2.1.tgz", - "integrity": "sha512-+h1lkLKhZMTYjog1VEpJNG7NZJWcuc2DDk/qsqSTRRCOXiLjeQ1d1/udrUGhqMxUgAlwKNZ0cf2uqan5GLuS2A==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6" - } - }, - "node_modules/app-builder-lib/node_modules/jsonfile": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", - "integrity": "sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==", - "dev": true, - "license": "MIT", - "optionalDependencies": { - "graceful-fs": "^4.1.6" - } - }, - "node_modules/app-builder-lib/node_modules/semver": { - "version": "7.7.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.4.tgz", - "integrity": "sha512-vFKC2IEtQnVhpT78h1Yp8wzwrf8CM+MzKMHGJZfBtzhZNycRFnXsHk6E5TxIkkMsgNS7mdX3AGB7x2QM2di4lA==", - "dev": true, - "license": "ISC", - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/app-builder-lib/node_modules/universalify": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", - "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 4.0.0" - } - }, - "node_modules/argparse": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", - "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", - "dev": true, - "license": "Python-2.0" - }, - "node_modules/asn1js": { - "version": "3.0.10", - "resolved": "https://registry.npmjs.org/asn1js/-/asn1js-3.0.10.tgz", - "integrity": "sha512-S2s3aOytiKdFRdulw2qPE51MzjzVOisppcVv7jVFR+Kw0kxwvFrDcYA0h7Ndqbmj0HkMIXYWaoj7fli8kgx1eg==", - "dev": true, - "license": "BSD-3-Clause", - "dependencies": { - "pvtsutils": "^1.3.6", - "pvutils": "^1.1.5", - "tslib": "^2.8.1" - }, - "engines": { - "node": ">=12.0.0" - } - }, - "node_modules/astral-regex": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/astral-regex/-/astral-regex-2.0.0.tgz", - "integrity": "sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" - } - }, - "node_modules/async": { - "version": "3.2.6", - "resolved": "https://registry.npmjs.org/async/-/async-3.2.6.tgz", - "integrity": "sha512-htCUDlxyyCLMgaM3xXg0C0LW2xqfuQ6p05pCEIsXuyQ+a1koYKTuBMzRNwmybfLgvJDMd0r1LTn4+E0Ti6C2AA==", - "dev": true, - "license": "MIT" - }, - "node_modules/async-exit-hook": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/async-exit-hook/-/async-exit-hook-2.0.1.tgz", - "integrity": "sha512-NW2cX8m1Q7KPA7a5M2ULQeZ2wR5qI5PAbw5L0UOMxdioVk9PMZ0h1TmyZEkPYrCvYjDlFICusOu1dlEKAAeXBw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.12.0" - } - }, - "node_modules/asynckit": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", - "dev": true, - "license": "MIT" - }, - "node_modules/at-least-node": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/at-least-node/-/at-least-node-1.0.0.tgz", - "integrity": "sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==", - "dev": true, - "license": "ISC", - "engines": { - "node": ">= 4.0.0" - } - }, - "node_modules/atomic-sleep": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/atomic-sleep/-/atomic-sleep-1.0.0.tgz", - "integrity": "sha512-kNOjDqAh7px0XWNI+4QbzoiR/nTkHAWNud2uvnJquD1/x5a7EQZMJT0AczqK0Qn67oY/TTQ1LbUKajZpp3I9tQ==", - "license": "MIT", - "engines": { - "node": ">=8.0.0" - } - }, - "node_modules/aws4": { - "version": "1.13.2", - "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.13.2.tgz", - "integrity": "sha512-lHe62zvbTB5eEABUVi/AwVh0ZKY9rMMDhmm+eeyuuUQbQ3+J+fONVQOZyj+DdrvD4BY33uYniyRJ4UJIaSKAfw==", - "dev": true, - "license": "MIT" - }, - "node_modules/balanced-match": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz", - "integrity": "sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==", - "dev": true, - "license": "MIT", - "engines": { - "node": "18 || 20 || >=22" - } - }, - "node_modules/base64-js": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", - "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "license": "MIT" - }, - "node_modules/big-integer": { - "version": "1.6.52", - "resolved": "https://registry.npmjs.org/big-integer/-/big-integer-1.6.52.tgz", - "integrity": "sha512-QxD8cf2eVqJOOz63z6JIN9BzvVs/dlySa5HGSBH5xtR8dPteIRQnBxxKqkNTiT6jbDTF6jAfrd4oMcND9RGbQg==", - "dev": true, - "license": "Unlicense", - "engines": { - "node": ">=0.6" - } - }, - "node_modules/bluebird": { - "version": "3.7.2", - "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz", - "integrity": "sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==", - "dev": true, - "license": "MIT" - }, - "node_modules/boolean": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/boolean/-/boolean-3.2.0.tgz", - "integrity": "sha512-d0II/GO9uf9lfUHH2BQsjxzRJZBdsjgsBiW4BvhWk/3qoKwQFjIDVN19PfX8F2D/r9PCMTtLWjYVCFrpeYUzsw==", - "deprecated": "Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.", - "dev": true, - "license": "MIT", - "optional": true - }, - "node_modules/bplist-creator": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/bplist-creator/-/bplist-creator-0.1.0.tgz", - "integrity": "sha512-sXaHZicyEEmY86WyueLTQesbeoH/mquvarJaQNbjuOQO+7gbFcDEWqKmcWA4cOTLzFlfgvkiVxolk1k5bBIpmg==", - "dev": true, - "license": "MIT", - "dependencies": { - "stream-buffers": "2.2.x" - } - }, - "node_modules/bplist-parser": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/bplist-parser/-/bplist-parser-0.3.2.tgz", - "integrity": "sha512-apC2+fspHGI3mMKj+dGevkGo/tCqVB8jMb6i+OX+E29p0Iposz07fABkRIfVUPNd5A5VbuOz1bZbnmkKLYF+wQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "big-integer": "1.6.x" - }, - "engines": { - "node": ">= 5.10.0" - } - }, - "node_modules/brace-expansion": { - "version": "5.0.12", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.12.tgz", - "integrity": "sha512-YovQ3rzhaLMIrDjNDMkNS01tea93qhEhG5xy8f6+R0l+dw3Ki+5sCoIoI942iuLZTHWogWktgwVDhU09iNEimQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "balanced-match": "^4.0.2" - }, - "engines": { - "node": "20 || >=22" - } - }, - "node_modules/buffer-crc32": { - "version": "0.2.13", - "resolved": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.13.tgz", - "integrity": "sha512-VO9Ht/+p3SN7SKWqcrgEzjGbRSJYTx+Q1pTQC0wrWqHx0vpJraQ6GtHx8tvcg1rlK1byhU5gccxgOgj7B0TDkQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": "*" - } - }, - "node_modules/buffer-from": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", - "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", - "dev": true, - "license": "MIT" - }, - "node_modules/builder-util": { - "version": "26.16.0", - "resolved": "https://registry.npmjs.org/builder-util/-/builder-util-26.16.0.tgz", - "integrity": "sha512-RLyJhB7Si3YkzKR9ubQslWuXW3Vhs3CGe1i+SeixBZ0qTd1mk3XBmssvY22TlB6CS5blyko8Gu1JzpYk8UkYAg==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/debug": "^4.1.6", - "builder-util-runtime": "9.7.0", - "chalk": "^4.1.2", - "cross-spawn": "^7.0.6", - "debug": "^4.3.4", - "fs-extra": "^10.1.0", - "http-proxy-agent": "^7.0.0", - "https-proxy-agent": "^7.0.0", - "js-yaml": "^4.1.0", - "sanitize-filename": "^1.6.3", - "source-map-support": "^0.5.19", - "stat-mode": "^1.0.0", - "temp-file": "^3.4.0", - "tiny-async-pool": "1.3.0" - }, - "engines": { - "node": ">=14.0.0" - } - }, - "node_modules/builder-util-runtime": { - "version": "9.7.0", - "resolved": "https://registry.npmjs.org/builder-util-runtime/-/builder-util-runtime-9.7.0.tgz", - "integrity": "sha512-g/kR520giAFYkSXTzcmF3kqQq7wi8F6N6SzeDgZrqTBN+VHdmgWOyTdD1yD7AATDId/yXLvuP34CxW46/BwCdw==", - "dev": true, - "license": "MIT", - "dependencies": { - "debug": "^4.3.4", - "sax": "^1.2.4" - }, - "engines": { - "node": ">=12.0.0" - } - }, - "node_modules/bytestreamjs": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/bytestreamjs/-/bytestreamjs-2.0.1.tgz", - "integrity": "sha512-U1Z/ob71V/bXfVABvNr/Kumf5VyeQRBEm6Txb0PQ6S7V5GpBM3w4Cbqz/xPDicR5tN0uvDifng8C+5qECeGwyQ==", - "dev": true, - "license": "BSD-3-Clause", - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/cacheable-lookup": { - "version": "5.0.4", - "resolved": "https://registry.npmjs.org/cacheable-lookup/-/cacheable-lookup-5.0.4.tgz", - "integrity": "sha512-2/kNscPhpcxrOigMZzbiWF7dz8ilhb/nIHU3EyZiXWXpeq/au8qJ8VhdftMkty3n7Gj6HIGalQG8oiBNB3AJgA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=10.6.0" - } - }, - "node_modules/cacheable-request": { - "version": "7.0.4", - "resolved": "https://registry.npmjs.org/cacheable-request/-/cacheable-request-7.0.4.tgz", - "integrity": "sha512-v+p6ongsrp0yTGbJXjgxPow2+DL93DASP4kXCDKb8/bwRtt9OEF3whggkkDkGNzgcWy2XaF4a8nZglC7uElscg==", - "dev": true, - "license": "MIT", - "dependencies": { - "clone-response": "^1.0.2", - "get-stream": "^5.1.0", - "http-cache-semantics": "^4.0.0", - "keyv": "^4.0.0", - "lowercase-keys": "^2.0.0", - "normalize-url": "^6.0.1", - "responselike": "^2.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/call-bind-apply-helpers": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz", - "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "es-errors": "^1.3.0", - "function-bind": "^1.1.2" - }, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dev": true, - "license": "MIT", - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "node_modules/chownr": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/chownr/-/chownr-3.0.0.tgz", - "integrity": "sha512-+IxzY9BZOQd/XuYPRmrvEVjF/nqj5kgT4kEq7VofrDoM1MxoRjEWkrCC3EtLi59TVawxTAn+orJwFQcrqEN1+g==", - "dev": true, - "license": "BlueOak-1.0.0", - "engines": { - "node": ">=18" - } - }, - "node_modules/chromium-pickle-js": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/chromium-pickle-js/-/chromium-pickle-js-0.2.0.tgz", - "integrity": "sha512-1R5Fho+jBq0DDydt+/vHWj5KJNJCKdARKOCwZUen84I5BreWoLqRLANH1U87eJy1tiASPtMnGqJJq0ZsLoRPOw==", - "dev": true, - "license": "MIT" - }, - "node_modules/ci-info": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-4.4.0.tgz", - "integrity": "sha512-77PSwercCZU2Fc4sX94eF8k8Pxte6JAwL4/ICZLFjJLqegs7kCuAsqqj/70NQF6TvDpgFjkubQB2FW2ZZddvQg==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/sibiraj-s" - } - ], - "license": "MIT", - "engines": { - "node": ">=8" - } - }, - "node_modules/cliui": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", - "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", - "dev": true, - "license": "ISC", - "dependencies": { - "string-width": "^4.2.0", - "strip-ansi": "^6.0.1", - "wrap-ansi": "^7.0.0" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/clone-response": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/clone-response/-/clone-response-1.0.3.tgz", - "integrity": "sha512-ROoL94jJH2dUVML2Y/5PEDNaSHgeOdSDicUyS7izcF63G6sTc/FTjLub4b8Il9S8S0beOfYt0TaA5qvFK+w0wA==", - "dev": true, - "license": "MIT", - "dependencies": { - "mimic-response": "^1.0.0" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true, - "license": "MIT" - }, - "node_modules/combined-stream": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", - "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", - "dev": true, - "license": "MIT", - "dependencies": { - "delayed-stream": "~1.0.0" - }, - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/commander": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-5.1.0.tgz", - "integrity": "sha512-P0CysNDQ7rtVw4QIQtm+MRxV66vKFSvlsQvGYXZWR3qFU0jlMKHZZZgw8e+8DSah4UDKMqnknRDQz+xuQXQ/Zg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 6" - } - }, - "node_modules/compare-version": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/compare-version/-/compare-version-0.1.2.tgz", - "integrity": "sha512-pJDh5/4wrEnXX/VWRZvruAGHkzKdr46z11OlTPN+VrATlWWhSKewNCJ1futCO5C7eJB3nPMFZA1LeYtcFboZ2A==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/concat-map": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", - "dev": true, - "license": "MIT" - }, - "node_modules/core-util-is": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", - "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==", - "dev": true, - "license": "MIT" - }, - "node_modules/cross-dirname": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/cross-dirname/-/cross-dirname-0.1.0.tgz", - "integrity": "sha512-+R08/oI0nl3vfPcqftZRpytksBXDzOUveBq/NBVx0sUp1axwzPQrKinNx5yd5sxPu8j1wIy8AfnVQ+5eFdha6Q==", - "dev": true, - "license": "MIT", - "optional": true, - "peer": true - }, - "node_modules/cross-spawn": { - "version": "7.0.6", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", - "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", - "dev": true, - "license": "MIT", - "dependencies": { - "path-key": "^3.1.0", - "shebang-command": "^2.0.0", - "which": "^2.0.1" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/cross-spawn/node_modules/isexe": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", - "dev": true, - "license": "ISC" - }, - "node_modules/cross-spawn/node_modules/which": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", - "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", - "dev": true, - "license": "ISC", - "dependencies": { - "isexe": "^2.0.0" - }, - "bin": { - "node-which": "bin/node-which" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/debug": { - "version": "4.4.3", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", - "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", - "license": "MIT", - "dependencies": { - "ms": "^2.1.3" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } - } - }, - "node_modules/decompress-response": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz", - "integrity": "sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "mimic-response": "^3.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/decompress-response/node_modules/mimic-response": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz", - "integrity": "sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/deepmerge-ts": { - "version": "8.0.2", - "resolved": "https://registry.npmjs.org/deepmerge-ts/-/deepmerge-ts-8.0.2.tgz", - "integrity": "sha512-uqbvqLUMrc6p0MO+WBRtTxY55hmyh94WRwI5a++PZe54X+bfVh59FSN7uWCBCW1CCVjzjnrwzfI8zidE2obMMw==", - "funding": [ - { - "type": "ko-fi", - "url": "https://ko-fi.com/rebeccastevens" - }, - { - "type": "tidelift", - "url": "https://tidelift.com/funding/github/npm/deepmerge-ts" - } - ], - "license": "BSD-3-Clause", - "engines": { - "node": ">=16.9.0" - } - }, - "node_modules/defer-to-connect": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/defer-to-connect/-/defer-to-connect-2.0.1.tgz", - "integrity": "sha512-4tvttepXG1VaYGrRibk5EwJd1t4udunSOVMdLSAL6mId1ix438oPwPZMALY41FCijukO1L0twNcGsdzS7dHgDg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=10" - } - }, - "node_modules/define-data-property": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.4.tgz", - "integrity": "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==", - "dev": true, - "license": "MIT", - "optional": true, - "dependencies": { - "es-define-property": "^1.0.0", - "es-errors": "^1.3.0", - "gopd": "^1.0.1" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/define-lazy-prop": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/define-lazy-prop/-/define-lazy-prop-2.0.0.tgz", - "integrity": "sha512-Ds09qNh8yw3khSjiJjiUInaGX9xlqZDY7JVryGxdxV7NPeuqQfplOpQ66yJFZut3jLa5zOwkXw1g9EI2uKh4Og==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" - } - }, - "node_modules/define-properties": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.2.1.tgz", - "integrity": "sha512-8QmQKqEASLd5nx0U1B1okLElbUuuttJ/AnYmRXbbbGDWh6uS208EjD4Xqq/I9wK7u0v6O08XhTWnt5XtEbR6Dg==", - "dev": true, - "license": "MIT", - "optional": true, - "dependencies": { - "define-data-property": "^1.0.1", - "has-property-descriptors": "^1.0.0", - "object-keys": "^1.1.1" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/delayed-stream": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", - "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.4.0" - } - }, - "node_modules/detect-node": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/detect-node/-/detect-node-2.1.0.tgz", - "integrity": "sha512-T0NIuQpnTvFDATNuHN5roPwSBG83rFsuO+MXXH9/3N1eFbn4wcPjttvjMLEPWJ0RGUYgQE7cGgS3tNxbqCGM7g==", - "dev": true, - "license": "MIT", - "optional": true - }, - "node_modules/dir-compare": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/dir-compare/-/dir-compare-4.2.0.tgz", - "integrity": "sha512-2xMCmOoMrdQIPHdsTawECdNPwlVFB9zGcz3kuhmBO6U3oU+UQjsue0i8ayLKpgBcm+hcXPMVSGUN9d+pvJ6+VQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "minimatch": "^3.0.5", - "p-limit": "^3.1.0 " - } - }, - "node_modules/dir-compare/node_modules/balanced-match": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", - "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", - "dev": true, - "license": "MIT" - }, - "node_modules/dir-compare/node_modules/brace-expansion": { - "version": "1.1.21", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.21.tgz", - "integrity": "sha512-9zeA+KLZNNzglF2TPKRQEDyx6Yby7daAkuy8MiPzpXPsYDWi/DRM8jmwUDxokQjYqBpv5DgPiwD4h4ZZSy1Ujw==", - "dev": true, - "license": "MIT", - "dependencies": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "node_modules/dir-compare/node_modules/minimatch": { - "version": "3.1.5", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.5.tgz", - "integrity": "sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==", - "dev": true, - "license": "ISC", - "dependencies": { - "brace-expansion": "^1.1.7" - }, - "engines": { - "node": "*" - } - }, - "node_modules/dmg-builder": { - "version": "26.17.0", - "resolved": "https://registry.npmjs.org/dmg-builder/-/dmg-builder-26.17.0.tgz", - "integrity": "sha512-EAw1f2iGkICmUvAVBOjm7v5mxJdB7/+OZSycHFhKBimiTkCXtvkCC6wBKzHo7ZQYi58C2MmwIleRbgRnROlK2Q==", - "dev": true, - "license": "MIT", - "dependencies": { - "app-builder-lib": "26.17.0", - "builder-util": "26.16.0", - "fs-extra": "^10.1.0", - "js-yaml": "^4.1.0" - } - }, - "node_modules/dom-serializer": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-2.0.0.tgz", - "integrity": "sha512-wIkAryiqt/nV5EQKqQpo3SToSOV9J0DnbJqwK7Wv/Trc92zIAYZ4FlMu+JPFW1DfGFt81ZTCGgDEabffXeLyJg==", - "license": "MIT", - "dependencies": { - "domelementtype": "^2.3.0", - "domhandler": "^5.0.2", - "entities": "^4.2.0" - }, - "funding": { - "url": "https://github.com/cheeriojs/dom-serializer?sponsor=1" - } - }, - "node_modules/domelementtype": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.3.0.tgz", - "integrity": "sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/fb55" - } - ], - "license": "BSD-2-Clause" - }, - "node_modules/domhandler": { - "version": "5.0.3", - "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-5.0.3.tgz", - "integrity": "sha512-cgwlv/1iFQiFnU96XXgROh8xTeetsnJiDsTc7TYCLFd9+/WNkIqPTxiM/8pSd8VIrhXGTf1Ny1q1hquVqDJB5w==", - "license": "BSD-2-Clause", - "dependencies": { - "domelementtype": "^2.3.0" - }, - "engines": { - "node": ">= 4" - }, - "funding": { - "url": "https://github.com/fb55/domhandler?sponsor=1" - } - }, - "node_modules/domutils": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/domutils/-/domutils-3.2.2.tgz", - "integrity": "sha512-6kZKyUajlDuqlHKVX1w7gyslj9MPIXzIFiz/rGu35uC1wMi+kMhQwGhl4lt9unC9Vb9INnY9Z3/ZA3+FhASLaw==", - "license": "BSD-2-Clause", - "dependencies": { - "dom-serializer": "^2.0.0", - "domelementtype": "^2.3.0", - "domhandler": "^5.0.3" - }, - "funding": { - "url": "https://github.com/fb55/domutils?sponsor=1" - } - }, - "node_modules/dotenv": { - "version": "16.6.1", - "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.6.1.tgz", - "integrity": "sha512-uBq4egWHTcTt33a72vpSG0z3HnPuIl6NqYcTrKEg2azoEyl2hpW0zqlxysq2pK9HlDIHyHyakeYaYnSAwd8bow==", - "dev": true, - "license": "BSD-2-Clause", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://dotenvx.com" - } - }, - "node_modules/dotenv-expand": { - "version": "11.0.7", - "resolved": "https://registry.npmjs.org/dotenv-expand/-/dotenv-expand-11.0.7.tgz", - "integrity": "sha512-zIHwmZPRshsCdpMDyVsqGmgyP0yT8GAgXUnkdAoJisxvf33k7yO6OuoKmcTGuXPWSsm8Oh88nZicRLA9Y0rUeA==", - "dev": true, - "license": "BSD-2-Clause", - "dependencies": { - "dotenv": "^16.4.5" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://dotenvx.com" - } - }, - "node_modules/dunder-proto": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", - "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==", - "dev": true, - "license": "MIT", - "dependencies": { - "call-bind-apply-helpers": "^1.0.1", - "es-errors": "^1.3.0", - "gopd": "^1.2.0" - }, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/duplexer2": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.1.4.tgz", - "integrity": "sha512-asLFVfWWtJ90ZyOUHMqk7/S2w2guQKxUI2itj3d92ADHhxUSbCMGi1f1cBcJ7xM1To+pE/Khbwo1yuNbMEPKeA==", - "dev": true, - "license": "BSD-3-Clause", - "dependencies": { - "readable-stream": "^2.0.2" - } - }, - "node_modules/ejs": { - "version": "3.1.10", - "resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.10.tgz", - "integrity": "sha512-UeJmFfOrAQS8OJWPZ4qtgHyWExa088/MtK5UEyoJGFH67cDEXkZSviOiKRCZ4Xij0zxI3JECgYs3oKx+AizQBA==", - "dev": true, - "license": "Apache-2.0", - "dependencies": { - "jake": "^10.8.5" - }, - "bin": { - "ejs": "bin/cli.js" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/electron": { - "version": "44.5.1", - "resolved": "https://registry.npmjs.org/electron/-/electron-44.5.1.tgz", - "integrity": "sha512-lx7AYoFIiyvEvgvpyWO9kOC60xtNPpiPZAth6Fmg9NutzpCAMLwpUlaBY2EXfZyIgUdzEmLMj9KvK0Vrokl1yQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "@electron-internal/extract-zip": "^1.0.1", - "@electron/get": "^5.0.0", - "@types/node": "^24.9.0" - }, - "bin": { - "electron": "cli.js", - "install-electron": "install.js" - }, - "engines": { - "node": ">= 22.12.0" - } - }, - "node_modules/electron-builder": { - "version": "26.17.0", - "resolved": "https://registry.npmjs.org/electron-builder/-/electron-builder-26.17.0.tgz", - "integrity": "sha512-iYHBRiagS9sDIbZx1ZD113f5rEGQvtpvTvHf70ovHKJ8mRvxwIkWX7JCwfmVQmVS4eX735p7TZmoxHnBPwF3vA==", - "dev": true, - "license": "MIT", - "dependencies": { - "app-builder-lib": "26.17.0", - "builder-util": "26.16.0", - "builder-util-runtime": "9.7.0", - "chalk": "^4.1.2", - "ci-info": "^4.2.0", - "dmg-builder": "26.17.0", - "fs-extra": "^10.1.0", - "lazy-val": "^1.0.5", - "simple-update-notifier": "2.0.0", - "yargs": "^17.6.2" - }, - "bin": { - "electron-builder": "cli.js", - "install-app-deps": "install-app-deps.js" - }, - "engines": { - "node": ">=14.0.0" - } - }, - "node_modules/electron-builder-squirrel-windows": { - "version": "26.17.0", - "resolved": "https://registry.npmjs.org/electron-builder-squirrel-windows/-/electron-builder-squirrel-windows-26.17.0.tgz", - "integrity": "sha512-uyh+D+B0m12qCRp9c/7dwBirHTh7JcvAzj5eTEbb4dXPPGAhYPx1nozzbu1fC6AdULfat6ZNqgWhipTFpb82lQ==", - "dev": true, - "license": "MIT", - "peer": true, - "dependencies": { - "app-builder-lib": "26.17.0", - "builder-util": "26.16.0", - "electron-winstaller": "5.4.0" - } - }, - "node_modules/electron-publish": { - "version": "26.16.0", - "resolved": "https://registry.npmjs.org/electron-publish/-/electron-publish-26.16.0.tgz", - "integrity": "sha512-Vt3KzQIiw9BImvNOYtndg9Mjki+tl4+1sQiC/+G5j8khWaENOJFWodiB+sUl6yyHwtd37avehskdtPw7f8y/+Q==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/fs-extra": "^9.0.11", - "aws4": "^1.13.2", - "builder-util": "26.16.0", - "builder-util-runtime": "9.7.0", - "chalk": "^4.1.2", - "form-data": "^4.0.5", - "fs-extra": "^10.1.0", - "lazy-val": "^1.0.5", - "mime": "^2.5.2" - } - }, - "node_modules/electron-winstaller": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/electron-winstaller/-/electron-winstaller-5.4.0.tgz", - "integrity": "sha512-bO3y10YikuUwUuDUQRM4KfwNkKhnpVO7IPdbsrejwN9/AABJzzTQ4GeHwyzNSrVO+tEH3/Np255a3sVZpZDjvg==", - "dev": true, - "hasInstallScript": true, - "license": "MIT", - "peer": true, - "dependencies": { - "@electron/asar": "^3.2.1", - "debug": "^4.1.1", - "fs-extra": "^7.0.1", - "lodash": "^4.17.21", - "temp": "^0.9.0" - }, - "engines": { - "node": ">=8.0.0" - }, - "optionalDependencies": { - "@electron/windows-sign": "^1.1.2" - } - }, - "node_modules/electron-winstaller/node_modules/fs-extra": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-7.0.1.tgz", - "integrity": "sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw==", - "dev": true, - "license": "MIT", - "peer": true, - "dependencies": { - "graceful-fs": "^4.1.2", - "jsonfile": "^4.0.0", - "universalify": "^0.1.0" - }, - "engines": { - "node": ">=6 <7 || >=8" - } - }, - "node_modules/electron-winstaller/node_modules/jsonfile": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", - "integrity": "sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==", - "dev": true, - "license": "MIT", - "peer": true, - "optionalDependencies": { - "graceful-fs": "^4.1.6" - } - }, - "node_modules/electron-winstaller/node_modules/universalify": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", - "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", - "dev": true, - "license": "MIT", - "peer": true, - "engines": { - "node": ">= 4.0.0" - } - }, - "node_modules/elementtree": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/elementtree/-/elementtree-0.1.7.tgz", - "integrity": "sha512-wkgGT6kugeQk/P6VZ/f4T+4HB41BVgNBq5CDIZVbQ02nvTVqAiVTbskxxu3eA/X96lMlfYOwnLQpN2v5E1zDEg==", - "dev": true, - "license": "Apache-2.0", - "dependencies": { - "sax": "1.1.4" - }, - "engines": { - "node": ">= 0.4.0" - } - }, - "node_modules/elementtree/node_modules/sax": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/sax/-/sax-1.1.4.tgz", - "integrity": "sha512-5f3k2PbGGp+YtKJjOItpg3P99IMD84E4HOvcfleTb5joCHNXYLsR9yWFPOYGgaeMPDubQILTCMdsFb2OMeOjtg==", - "dev": true, - "license": "ISC" - }, - "node_modules/emoji-regex": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "dev": true, - "license": "MIT" - }, - "node_modules/encoding-japanese": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/encoding-japanese/-/encoding-japanese-2.4.0.tgz", - "integrity": "sha512-PE0KjlsDy9JSsoU4C2Q8NXb1kC4c+bZRac9ZvHXUE4q1Ht63gScKMdEy9jst9+Fi3M4eDkqzkEhBZvix4blP2A==", - "license": "MIT", - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/end-of-stream": { - "version": "1.4.5", - "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.5.tgz", - "integrity": "sha512-ooEGc6HP26xXq/N+GCGOT0JKCLDGrq2bQUZrQ7gyrJiZANJ/8YDTxTpQBXGMn+WbIQXNVpyWymm7KYVICQnyOg==", - "dev": true, - "license": "MIT", - "dependencies": { - "once": "^1.4.0" - } - }, - "node_modules/entities": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", - "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==", - "license": "BSD-2-Clause", - "engines": { - "node": ">=0.12" - }, - "funding": { - "url": "https://github.com/fb55/entities?sponsor=1" - } - }, - "node_modules/env-paths": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/env-paths/-/env-paths-3.0.0.tgz", - "integrity": "sha512-dtJUTepzMW3Lm/NPxRf3wP4642UWhjL2sQxc+ym2YMj1m/H2zDNQOlezafzkHwn6sMstjHTwG6iQQsctDW/b1A==", - "dev": true, - "license": "MIT", - "engines": { - "node": "^12.20.0 || ^14.13.1 || >=16.0.0" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/err-code": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/err-code/-/err-code-2.0.3.tgz", - "integrity": "sha512-2bmlRpNKBxT/CRmPOlyISQpNj+qSeYvcym/uT0Jx2bMOlKLtSy1ZmLuVxSEKKyor/N5yhvp/ZiG1oE3DEYMSFA==", - "dev": true, - "license": "MIT" - }, - "node_modules/es-define-property": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", - "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/es-errors": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", - "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/es-object-atoms": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.2.tgz", - "integrity": "sha512-HWcBoN6NileqtSydK2FqHbS/LoDd2pqrnQHLyJzBj4kOp/ky2MWMN694xOfkK8/SnUsW2DH7EfyVlydKCsm1Zw==", - "dev": true, - "license": "MIT", - "dependencies": { - "es-errors": "^1.3.0" - }, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/es-set-tostringtag": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.1.0.tgz", - "integrity": "sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==", - "dev": true, - "license": "MIT", - "dependencies": { - "es-errors": "^1.3.0", - "get-intrinsic": "^1.2.6", - "has-tostringtag": "^1.0.2", - "hasown": "^2.0.2" - }, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/es6-error": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/es6-error/-/es6-error-4.1.1.tgz", - "integrity": "sha512-Um/+FxMr9CISWh0bi5Zv0iOD+4cFh5qLeks1qhAopKVAJw3drgKbKySikp7wGhDL0HPeaja0P5ULZrxLkniUVg==", - "dev": true, - "license": "MIT", - "optional": true - }, - "node_modules/esbuild": { - "version": "0.28.2", - "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.28.2.tgz", - "integrity": "sha512-HKVLS8dvII+xoKW9kmqxbRKrnWEXfJJr/FZhhJmiqIB0e053QNYFqOBouTMO/k5sID4MvCiUCvv8b9M4h32wIA==", - "dev": true, - "hasInstallScript": true, - "license": "MIT", - "bin": { - "esbuild": "bin/esbuild" - }, - "engines": { - "node": ">=18" - }, - "optionalDependencies": { - "@esbuild/aix-ppc64": "0.28.2", - "@esbuild/android-arm": "0.28.2", - "@esbuild/android-arm64": "0.28.2", - "@esbuild/android-x64": "0.28.2", - "@esbuild/darwin-arm64": "0.28.2", - "@esbuild/darwin-x64": "0.28.2", - "@esbuild/freebsd-arm64": "0.28.2", - "@esbuild/freebsd-x64": "0.28.2", - "@esbuild/linux-arm": "0.28.2", - "@esbuild/linux-arm64": "0.28.2", - "@esbuild/linux-ia32": "0.28.2", - "@esbuild/linux-loong64": "0.28.2", - "@esbuild/linux-mips64el": "0.28.2", - "@esbuild/linux-ppc64": "0.28.2", - "@esbuild/linux-riscv64": "0.28.2", - "@esbuild/linux-s390x": "0.28.2", - "@esbuild/linux-x64": "0.28.2", - "@esbuild/netbsd-arm64": "0.28.2", - "@esbuild/netbsd-x64": "0.28.2", - "@esbuild/openbsd-arm64": "0.28.2", - "@esbuild/openbsd-x64": "0.28.2", - "@esbuild/openharmony-arm64": "0.28.2", - "@esbuild/sunos-x64": "0.28.2", - "@esbuild/win32-arm64": "0.28.2", - "@esbuild/win32-ia32": "0.28.2", - "@esbuild/win32-x64": "0.28.2" - } - }, - "node_modules/escalade": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", - "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6" - } - }, - "node_modules/escape-string-regexp": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", - "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", - "dev": true, - "license": "MIT", - "optional": true, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/exponential-backoff": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/exponential-backoff/-/exponential-backoff-3.1.3.tgz", - "integrity": "sha512-ZgEeZXj30q+I0EN+CbSSpIyPaJ5HVQD18Z1m+u1FXbAeT94mr1zw50q4q6jiiC447Nl/YTcIYSAftiGqetwXCA==", - "dev": true, - "license": "Apache-2.0" - }, - "node_modules/fast-deep-equal": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", - "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", - "dev": true, - "license": "MIT" - }, - "node_modules/fast-uri": { - "version": "3.1.8", - "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.8.tgz", - "integrity": "sha512-GZMtZUTNRpOVIECoXwLNZS5xUGE+mVNbTB8h/7Rwh2TFWcBQiPzTgyZi05BF9UMZKkLJv8XBRJTlU7zg8+ZfMg==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/fastify" - }, - { - "type": "opencollective", - "url": "https://opencollective.com/fastify" - } - ], - "license": "BSD-3-Clause" - }, - "node_modules/fd-slicer": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.1.0.tgz", - "integrity": "sha512-cE1qsB/VwyQozZ+q1dGxR8LBYNZeofhEdUNGSMbQD3Gw2lAzX9Zb3uIU6Ebc/Fmyjo9AWWfnn0AUCHqtevs/8g==", - "dev": true, - "license": "MIT", - "dependencies": { - "pend": "~1.2.0" - } - }, - "node_modules/fdir": { - "version": "6.5.0", - "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", - "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=12.0.0" - }, - "peerDependencies": { - "picomatch": "^3 || ^4" - }, - "peerDependenciesMeta": { - "picomatch": { - "optional": true - } - } - }, - "node_modules/filelist": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/filelist/-/filelist-1.0.6.tgz", - "integrity": "sha512-5giy2PkLYY1cP39p17Ech+2xlpTRL9HLspOfEgm0L6CwBXBTgsK5ou0JtzYuepxkaQ/tvhCFIJ5uXo0OrM2DxA==", - "dev": true, - "license": "Apache-2.0", - "dependencies": { - "minimatch": "^5.0.1" - } - }, - "node_modules/filelist/node_modules/balanced-match": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", - "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", - "dev": true, - "license": "MIT" - }, - "node_modules/filelist/node_modules/brace-expansion": { - "version": "2.1.7", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.1.7.tgz", - "integrity": "sha512-uZbew1NqdmPDTMJ8ah1y+b+9QEJrfkXFk3RcTQw3X0jW/xRUvFKsg1CfQdSYGdTbXZWExtU3J3ccxtnfw1Fi0g==", - "dev": true, - "license": "MIT", - "dependencies": { - "balanced-match": "^1.0.0" - } - }, - "node_modules/filelist/node_modules/minimatch": { - "version": "5.1.9", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.9.tgz", - "integrity": "sha512-7o1wEA2RyMP7Iu7GNba9vc0RWWGACJOCZBJX2GJWip0ikV+wcOsgVuY9uE8CPiyQhkGFSlhuSkZPavN7u1c2Fw==", - "dev": true, - "license": "ISC", - "dependencies": { - "brace-expansion": "^2.0.1" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/form-data": { - "version": "4.0.6", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.6.tgz", - "integrity": "sha512-vKatAh4SlVfgbv+YtmhiRjhEMJsYpsG1Y2rMQtR+SVSbytsSD1YGzDIcrAJmdFec88u/+VoGmxnl+80gL1tRCQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.8", - "es-set-tostringtag": "^2.1.0", - "hasown": "^2.0.4", - "mime-types": "^2.1.35" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/fs-extra": { - "version": "10.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", - "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "graceful-fs": "^4.2.0", - "jsonfile": "^6.0.1", - "universalify": "^2.0.0" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/fs.realpath": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", - "dev": true, - "license": "ISC" - }, - "node_modules/function-bind": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", - "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", - "dev": true, - "license": "MIT", - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/get-caller-file": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", - "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", - "dev": true, - "license": "ISC", - "engines": { - "node": "6.* || 8.* || >= 10.*" - } - }, - "node_modules/get-intrinsic": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz", - "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "call-bind-apply-helpers": "^1.0.2", - "es-define-property": "^1.0.1", - "es-errors": "^1.3.0", - "es-object-atoms": "^1.1.1", - "function-bind": "^1.1.2", - "get-proto": "^1.0.1", - "gopd": "^1.2.0", - "has-symbols": "^1.1.0", - "hasown": "^2.0.2", - "math-intrinsics": "^1.1.0" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/get-proto": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz", - "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==", - "dev": true, - "license": "MIT", - "dependencies": { - "dunder-proto": "^1.0.1", - "es-object-atoms": "^1.0.0" - }, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/get-stream": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-5.2.0.tgz", - "integrity": "sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA==", - "dev": true, - "license": "MIT", - "dependencies": { - "pump": "^3.0.0" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/glob": { - "version": "7.2.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", - "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", - "deprecated": "Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me", - "dev": true, - "license": "ISC", - "dependencies": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.1.1", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - }, - "engines": { - "node": "*" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/glob/node_modules/balanced-match": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", - "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", - "dev": true, - "license": "MIT" - }, - "node_modules/glob/node_modules/brace-expansion": { - "version": "1.1.21", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.21.tgz", - "integrity": "sha512-9zeA+KLZNNzglF2TPKRQEDyx6Yby7daAkuy8MiPzpXPsYDWi/DRM8jmwUDxokQjYqBpv5DgPiwD4h4ZZSy1Ujw==", - "dev": true, - "license": "MIT", - "dependencies": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "node_modules/glob/node_modules/minimatch": { - "version": "3.1.5", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.5.tgz", - "integrity": "sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==", - "dev": true, - "license": "ISC", - "dependencies": { - "brace-expansion": "^1.1.7" - }, - "engines": { - "node": "*" - } - }, - "node_modules/global-agent": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/global-agent/-/global-agent-3.0.0.tgz", - "integrity": "sha512-PT6XReJ+D07JvGoxQMkT6qji/jVNfX/h364XHZOWeRzy64sSFr+xJ5OX7LI3b4MPQzdL4H8Y8M0xzPpsVMwA8Q==", - "dev": true, - "license": "BSD-3-Clause", - "optional": true, - "dependencies": { - "boolean": "^3.0.1", - "es6-error": "^4.1.1", - "matcher": "^3.0.0", - "roarr": "^2.15.3", - "semver": "^7.3.2", - "serialize-error": "^7.0.1" - }, - "engines": { - "node": ">=10.0" - } - }, - "node_modules/globalthis": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/globalthis/-/globalthis-1.0.4.tgz", - "integrity": "sha512-DpLKbNU4WylpxJykQujfCcwYWiV/Jhm50Goo0wrVILAv5jOr9d+H+UR3PhSCD2rCCEIg0uc+G+muBTwD54JhDQ==", - "dev": true, - "license": "MIT", - "optional": true, - "dependencies": { - "define-properties": "^1.2.1", - "gopd": "^1.0.1" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/gopd": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", - "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/got": { - "version": "11.8.6", - "resolved": "https://registry.npmjs.org/got/-/got-11.8.6.tgz", - "integrity": "sha512-6tfZ91bOr7bOXnK7PRDCGBLa1H4U080YHNaAQ2KsMGlLEzRbk44nsZF2E1IeRc3vtJHPVbKCYgdFbaGO2ljd8g==", - "dev": true, - "license": "MIT", - "dependencies": { - "@sindresorhus/is": "^4.0.0", - "@szmarczak/http-timer": "^4.0.5", - "@types/cacheable-request": "^6.0.1", - "@types/responselike": "^1.0.0", - "cacheable-lookup": "^5.0.3", - "cacheable-request": "^7.0.2", - "decompress-response": "^6.0.0", - "http2-wrapper": "^1.0.0-beta.5.2", - "lowercase-keys": "^2.0.0", - "p-cancelable": "^2.0.0", - "responselike": "^2.0.0" - }, - "engines": { - "node": ">=10.19.0" - }, - "funding": { - "url": "https://github.com/sindresorhus/got?sponsor=1" - } - }, - "node_modules/graceful-fs": { - "version": "4.2.11", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", - "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", - "dev": true, - "license": "ISC" - }, - "node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" - } - }, - "node_modules/has-property-descriptors": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz", - "integrity": "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==", - "dev": true, - "license": "MIT", - "optional": true, - "dependencies": { - "es-define-property": "^1.0.0" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/has-symbols": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", - "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/has-tostringtag": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.2.tgz", - "integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==", - "dev": true, - "license": "MIT", - "dependencies": { - "has-symbols": "^1.0.3" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/hasown": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.4.tgz", - "integrity": "sha512-T2UbfbBEF32wiepXIsMlTW9+dDYC6wMh/t/vYA4tuOMKqWz/n3vr1NFSxQiyP+zk2mXsoMA/i/7qV6LKut1t1A==", - "dev": true, - "license": "MIT", - "dependencies": { - "function-bind": "^1.1.2" - }, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/he": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", - "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", - "license": "MIT", - "bin": { - "he": "bin/he" - } - }, - "node_modules/hosted-git-info": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-4.1.0.tgz", - "integrity": "sha512-kyCuEOWjJqZuDbRHzL8V93NzQhwIB71oFWSyzVo+KPZI+pnQPPxucdkrOZvkLRnrf5URsQM+IJ09Dw29cRALIA==", - "dev": true, - "license": "ISC", - "dependencies": { - "lru-cache": "^6.0.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/html-to-text": { - "version": "10.0.1", - "resolved": "https://registry.npmjs.org/html-to-text/-/html-to-text-10.0.1.tgz", - "integrity": "sha512-GiVhRI1BatGARSCmlXWNCjDT0cWrwBWoeduLoV0WSKAgaV/wa+hUWy5LiQLUs4UwiUrE52ZCMfBGiKD87TDPrg==", - "license": "MIT", - "dependencies": { - "@selderee/plugin-htmlparser2": "~0.12.0", - "deepmerge-ts": "^8.0.1", - "dom-serializer": "^2.0.0", - "htmlparser2": "^10.1.0", - "selderee": "~0.12.0" - }, - "engines": { - "node": ">=20.19.0" - }, - "funding": { - "url": "https://github.com/sponsors/KillyMXI" - } - }, - "node_modules/htmlparser2": { - "version": "10.1.0", - "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-10.1.0.tgz", - "integrity": "sha512-VTZkM9GWRAtEpveh7MSF6SjjrpNVNNVJfFup7xTY3UpFtm67foy9HDVXneLtFVt4pMz5kZtgNcvCniNFb1hlEQ==", - "funding": [ - "https://github.com/fb55/htmlparser2?sponsor=1", - { - "type": "github", - "url": "https://github.com/sponsors/fb55" - } - ], - "license": "MIT", - "dependencies": { - "domelementtype": "^2.3.0", - "domhandler": "^5.0.3", - "domutils": "^3.2.2", - "entities": "^7.0.1" - } - }, - "node_modules/htmlparser2/node_modules/entities": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/entities/-/entities-7.0.1.tgz", - "integrity": "sha512-TWrgLOFUQTH994YUyl1yT4uyavY5nNB5muff+RtWaqNVCAK408b5ZnnbNAUEWLTCpum9w6arT70i1XdQ4UeOPA==", - "license": "BSD-2-Clause", - "engines": { - "node": ">=0.12" - }, - "funding": { - "url": "https://github.com/fb55/entities?sponsor=1" - } - }, - "node_modules/http-cache-semantics": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.3.0.tgz", - "integrity": "sha512-M5t5LlJpS1UHMjvwRQVdFHvPISGeLAxNcrWuJkeGh0KxsqCHZ1O3NXZU/8x7cD0BDcGW8kapxMKTvwlqrNkHkA==", - "dev": true, - "license": "BSD-2-Clause" - }, - "node_modules/http-proxy-agent": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-7.0.2.tgz", - "integrity": "sha512-T1gkAiYYDWYx3V5Bmyu7HcfcvL7mUrTWiM6yOfa3PIphViJ/gFPbvidQ+veqSOHci/PxBcDabeUNCzpOODJZig==", - "dev": true, - "license": "MIT", - "dependencies": { - "agent-base": "^7.1.0", - "debug": "^4.3.4" - }, - "engines": { - "node": ">= 14" - } - }, - "node_modules/http2-wrapper": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/http2-wrapper/-/http2-wrapper-1.0.3.tgz", - "integrity": "sha512-V+23sDMr12Wnz7iTcDeJr3O6AIxlnvT/bmaAAAP/Xda35C90p9599p0F1eHR/N1KILWSoWVAiOMFjBBXaXSMxg==", - "dev": true, - "license": "MIT", - "dependencies": { - "quick-lru": "^5.1.1", - "resolve-alpn": "^1.0.0" - }, - "engines": { - "node": ">=10.19.0" - } - }, - "node_modules/https-proxy-agent": { - "version": "7.0.6", - "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.6.tgz", - "integrity": "sha512-vK9P5/iUfdl95AI+JVyUuIcVtd4ofvtrOr3HNtM2yxC9bnMbEdp3x01OhQNnjb8IJYi38VlTE3mBXwcfvywuSw==", - "dev": true, - "license": "MIT", - "dependencies": { - "agent-base": "^7.1.2", - "debug": "4" - }, - "engines": { - "node": ">= 14" - } - }, - "node_modules/ical.js": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/ical.js/-/ical.js-2.2.1.tgz", - "integrity": "sha512-yK/UlPbEs316igb/tjRgbFA8ZV75rCsBJp/hWOatpyaPNlgw0dGDmU+FoicOcwX4xXkeXOkYiOmCqNPFpNPkQg==", - "license": "MPL-2.0" - }, - "node_modules/iconv-lite": { - "version": "0.7.3", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.3.tgz", - "integrity": "sha512-IKXpvIzjnC9XTAUbVBcMfGS0EPaIXtW6v+zr+RRp+hqULEpo0owZax6wyRwPOJbWbzjYspQwusTsfVr0ifh4uQ==", - "license": "MIT", - "dependencies": { - "safer-buffer": ">= 2.1.2 < 3.0.0" - }, - "engines": { - "node": ">=0.10.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, - "node_modules/imapflow": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/imapflow/-/imapflow-2.2.1.tgz", - "integrity": "sha512-d7/sRGEtexA8e0Y71sN0rKfB2yWgZMHY8JqCbk17arRLGicjX1LpBuxPH+wowOIA5sVWs7U//B6S+mKfrBtT6w==", - "license": "MIT", - "dependencies": { - "@zone-eu/mailsplit": "5.4.19", - "encoding-japanese": "2.4.0", - "iconv-lite": "0.7.3", - "libbase64": "1.3.1", - "libmime": "5.4.6", - "libqp": "2.1.2", - "pino": "10.3.1", - "socks": "2.8.10" - }, - "engines": { - "node": ">=20.0.0" - } - }, - "node_modules/inflight": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", - "deprecated": "This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.", - "dev": true, - "license": "ISC", - "dependencies": { - "once": "^1.3.0", - "wrappy": "1" - } - }, - "node_modules/inherits": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", - "dev": true, - "license": "ISC" - }, - "node_modules/ini": { - "version": "4.1.3", - "resolved": "https://registry.npmjs.org/ini/-/ini-4.1.3.tgz", - "integrity": "sha512-X7rqawQBvfdjS10YU1y1YVreA3SsLrW9dX2CewP2EbBJM4ypVNLDkO5y04gejPwKIY9lR+7r9gn3rFPt/kmWFg==", - "dev": true, - "license": "ISC", - "engines": { - "node": "^14.17.0 || ^16.13.0 || >=18.0.0" - } - }, - "node_modules/ip-address": { - "version": "10.7.3", - "resolved": "https://registry.npmjs.org/ip-address/-/ip-address-10.7.3.tgz", - "integrity": "sha512-A1kdq/tSb5QjvKvAMgIoEvDBIgL7qaqVP/jkvSwYYRZ9iEzvPpopxp2wQfu3SuZRHtpHNxMn8Fs0bS+gf5Xmwg==", - "license": "MIT", - "engines": { - "node": ">= 12" - } - }, - "node_modules/is-docker": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-2.2.1.tgz", - "integrity": "sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ==", - "dev": true, - "license": "MIT", - "bin": { - "is-docker": "cli.js" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/is-fullwidth-code-point": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" - } - }, - "node_modules/is-wsl": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz", - "integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==", - "dev": true, - "license": "MIT", - "dependencies": { - "is-docker": "^2.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==", - "dev": true, - "license": "MIT" - }, - "node_modules/isbinaryfile": { - "version": "5.0.7", - "resolved": "https://registry.npmjs.org/isbinaryfile/-/isbinaryfile-5.0.7.tgz", - "integrity": "sha512-gnWD14Jh3FzS3CPhF0AxNOJ8CxqeblPTADzI38r0wt8ZyQl5edpy75myt08EG2oKvpyiqSqsx+Wkz9vtkbTqYQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 18.0.0" - }, - "funding": { - "url": "https://github.com/sponsors/gjtorikian/" - } - }, - "node_modules/isexe": { - "version": "3.1.5", - "resolved": "https://registry.npmjs.org/isexe/-/isexe-3.1.5.tgz", - "integrity": "sha512-6B3tLtFqtQS4ekarvLVMZ+X+VlvQekbe4taUkf/rhVO3d/h0M2rfARm/pXLcPEsjjMsFgrFgSrhQIxcSVrBz8w==", - "dev": true, - "license": "BlueOak-1.0.0", - "engines": { - "node": ">=18" - } - }, - "node_modules/jake": { - "version": "10.9.4", - "resolved": "https://registry.npmjs.org/jake/-/jake-10.9.4.tgz", - "integrity": "sha512-wpHYzhxiVQL+IV05BLE2Xn34zW1S223hvjtqk0+gsPrwd/8JNLXJgZZM/iPFsYc1xyphF+6M6EvdE5E9MBGkDA==", - "dev": true, - "license": "Apache-2.0", - "dependencies": { - "async": "^3.2.6", - "filelist": "^1.0.4", - "picocolors": "^1.1.1" - }, - "bin": { - "jake": "bin/cli.js" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/jiti": { - "version": "2.7.0", - "resolved": "https://registry.npmjs.org/jiti/-/jiti-2.7.0.tgz", - "integrity": "sha512-AC/7JofJvZGrrneWNaEnJeOLUx+JlGt7tNa0wZiRPT4MY1wmfKjt2+6O2p2uz2+skll8OZZmJMNqeke7kKbNgQ==", - "dev": true, - "license": "MIT", - "bin": { - "jiti": "lib/jiti-cli.mjs" - } - }, - "node_modules/js-yaml": { - "version": "4.3.2", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.3.2.tgz", - "integrity": "sha512-SFNOvSJ+Dgf/9An904Yx+CgSlIPCkIpao4qo51lpee25TIRejdH3rhR4EZMGoNx3/TP3O+wzWuiTFl4sqbltzA==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/puzrin" - }, - { - "type": "github", - "url": "https://github.com/sponsors/nodeca" - } - ], - "license": "MIT", - "dependencies": { - "argparse": "^2.0.1" - }, - "bin": { - "js-yaml": "bin/js-yaml.js" - } - }, - "node_modules/json-buffer": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz", - "integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==", - "dev": true, - "license": "MIT" - }, - "node_modules/json-schema-traverse": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", - "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", - "dev": true, - "license": "MIT" - }, - "node_modules/json-stringify-safe": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", - "integrity": "sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA==", - "dev": true, - "license": "ISC", - "optional": true - }, - "node_modules/json5": { - "version": "2.2.3", - "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", - "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", - "dev": true, - "license": "MIT", - "bin": { - "json5": "lib/cli.js" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/jsonfile": { - "version": "6.2.1", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.2.1.tgz", - "integrity": "sha512-zwOTdL3rFQ/lRdBnntKVOX6k5cKJwEc1HdilT71BWEu7J41gXIB2MRp+vxduPSwZJPWBxEzv4yH1wYLJGUHX4Q==", - "dev": true, - "license": "MIT", - "dependencies": { - "universalify": "^2.0.0" - }, - "optionalDependencies": { - "graceful-fs": "^4.1.6" - } - }, - "node_modules/keyv": { - "version": "4.5.4", - "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz", - "integrity": "sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==", - "dev": true, - "license": "MIT", - "dependencies": { - "json-buffer": "3.0.1" - } - }, - "node_modules/kleur": { - "version": "4.1.5", - "resolved": "https://registry.npmjs.org/kleur/-/kleur-4.1.5.tgz", - "integrity": "sha512-o+NO+8WrRiQEE4/7nwRJhN1HWpVmJm511pBHUxPLtp0BUISzlBplORYSmTclCnJvQq2tKu/sgl3xVpkc7ZWuQQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6" - } - }, - "node_modules/lazy-val": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/lazy-val/-/lazy-val-1.0.5.tgz", - "integrity": "sha512-0/BnGCCfyUMkBpeDgWihanIAF9JmZhHBgUhEqzvf+adhNGLoP6TaiI5oF8oyb3I45P+PcnrqihSf01M0l0G5+Q==", - "dev": true, - "license": "MIT" - }, - "node_modules/leac": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/leac/-/leac-0.7.0.tgz", - "integrity": "sha512-qMrZeyEekgdRQ9o6a4NAB2EQZrv827GJdn1vnapwSJ90hWRB4TzUSunvacPkxQ2TnNqHNI1/zSt0hlo0crG8Jw==", - "license": "MIT", - "funding": { - "url": "https://github.com/sponsors/KillyMXI" - } - }, - "node_modules/libbase64": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/libbase64/-/libbase64-1.3.1.tgz", - "integrity": "sha512-1b9LXEjEtXj35YKOR9RqNKBootlb37qbIzmqiw4MsP52cjOsfR6i/AYU1Y8qN4kV2TJQmLJ5aiXn45qI6h+Szw==", - "license": "MIT" - }, - "node_modules/libmime": { - "version": "5.4.6", - "resolved": "https://registry.npmjs.org/libmime/-/libmime-5.4.6.tgz", - "integrity": "sha512-Cgx1vHd76GTwDaLNsl0K44CjNFfhkX/1bMcoruoWr8Ugcl0/zMw7x/8NpZERIOcpGyzlQo10tOEw9goGsv2Wlg==", - "license": "MIT", - "dependencies": { - "encoding-japanese": "2.4.0", - "iconv-lite": "0.7.3", - "libbase64": "1.3.1", - "libqp": "2.1.2" - } - }, - "node_modules/libqp": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/libqp/-/libqp-2.1.2.tgz", - "integrity": "sha512-rp+U80tl9Os4K7GnVbPzPRmghPu6eqB8rcF+ontvNAnoga0JhMFG/bkTD/reC8yoznKMgOc5/ttZHJasiWeFPw==", - "license": "MIT" - }, - "node_modules/linkify-it": { - "version": "5.0.2", - "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-5.0.2.tgz", - "integrity": "sha512-ONTm2jCMAVZjgQa/Fy1kScXsuOoF5NPTsoFBdE1KVIZ2vAh/r9+Bqo+0jINCBYnavTPQZz38QzFTme79ENoN3Q==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/puzrin" - }, - { - "type": "github", - "url": "https://github.com/sponsors/markdown-it" - } - ], - "license": "MIT", - "dependencies": { - "uc.micro": "^2.0.0" - } - }, - "node_modules/lodash": { - "version": "4.18.1", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.18.1.tgz", - "integrity": "sha512-dMInicTPVE8d1e5otfwmmjlxkZoUpiVLwyeTdUsi/Caj/gfzzblBcCE5sRHV/AsjuCmxWrte2TNGSYuCeCq+0Q==", - "dev": true, - "license": "MIT" - }, - "node_modules/lowercase-keys": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-2.0.0.tgz", - "integrity": "sha512-tqNXrS78oMOE73NMxK4EMLQsQowWf8jKooH9g7xPavRT706R6bkQJ6DY2Te7QukaZsulxa30wQ7bk0pm4XiHmA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" - } - }, - "node_modules/lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dev": true, - "license": "ISC", - "dependencies": { - "yallist": "^4.0.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/mailparser": { - "version": "3.9.33", - "resolved": "https://registry.npmjs.org/mailparser/-/mailparser-3.9.33.tgz", - "integrity": "sha512-+ZYhApN4f7B8+jokb7VZeml8lxYHixVJ3tJTB5iPG9/MJpy8YmBHGdy+AWJ9dmtUX6t0xlu4rxwj1b7eWCvbDA==", - "license": "MIT", - "dependencies": { - "@zone-eu/mailsplit": "5.4.19", - "encoding-japanese": "2.4.0", - "he": "1.2.0", - "html-to-text": "10.0.1", - "iconv-lite": "0.7.3", - "libmime": "5.4.6", - "linkify-it": "5.0.2", - "nodemailer": "10.0.13", - "punycode.js": "2.3.1", - "tlds": "1.261.0" - }, - "engines": { - "node": ">=20.0.0" - } - }, - "node_modules/mailparser/node_modules/nodemailer": { - "version": "10.0.13", - "resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-10.0.13.tgz", - "integrity": "sha512-SzG86OlvcW/NNhUFC6uROMwRTL4n7MswfQqC/T8mhkmnY1YVa23zUEMYi4ijSeXSl9GLz9ZeTJDUatEDuY5FeQ==", - "license": "MIT-0", - "engines": { - "node": ">=20.0.0" - } - }, - "node_modules/matcher": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/matcher/-/matcher-3.0.0.tgz", - "integrity": "sha512-OkeDaAZ/bQCxeFAozM55PKcKU0yJMPGifLwV4Qgjitu+5MoAfSQN4lsLJeXZ1b8w0x+/Emda6MZgXS1jvsapng==", - "dev": true, - "license": "MIT", - "optional": true, - "dependencies": { - "escape-string-regexp": "^4.0.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/math-intrinsics": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", - "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/mime": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/mime/-/mime-2.6.0.tgz", - "integrity": "sha512-USPkMeET31rOMiarsBNIHZKLGgvKc/LrjofAnBlOttf5ajRvqiRA8QsenbcooctK6d6Ts6aqZXBA+XbkKthiQg==", - "dev": true, - "license": "MIT", - "bin": { - "mime": "cli.js" - }, - "engines": { - "node": ">=4.0.0" - } - }, - "node_modules/mime-db": { - "version": "1.52.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", - "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/mime-types": { - "version": "2.1.35", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", - "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", - "dev": true, - "license": "MIT", - "dependencies": { - "mime-db": "1.52.0" - }, - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/mimic-response": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-1.0.1.tgz", - "integrity": "sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=4" - } - }, - "node_modules/minimatch": { - "version": "10.2.6", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.6.tgz", - "integrity": "sha512-vpLQEs+VLCr1nU0BXS07maYoFwlDAH0gngQuuttxIwutDFEMHq2blX+8vpgxDdK3J1PwjCJiep77OitTZ4Ll1A==", - "dev": true, - "license": "BlueOak-1.0.0", - "dependencies": { - "brace-expansion": "^5.0.8" - }, - "engines": { - "node": "18 || 20 || >=22" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/minimist": { - "version": "1.2.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", - "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", - "dev": true, - "license": "MIT", - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/minipass": { - "version": "7.1.3", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.3.tgz", - "integrity": "sha512-tEBHqDnIoM/1rXME1zgka9g6Q2lcoCkxHLuc7ODJ5BxbP5d4c2Z5cGgtXAku59200Cx7diuHTOYfSBD8n6mm8A==", - "dev": true, - "license": "BlueOak-1.0.0", - "engines": { - "node": ">=16 || 14 >=14.17" - } - }, - "node_modules/minizlib": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-3.1.0.tgz", - "integrity": "sha512-KZxYo1BUkWD2TVFLr0MQoM8vUUigWD3LlD83a/75BqC+4qE0Hb1Vo5v1FgcfaNXvfXzr+5EhQ6ing/CaBijTlw==", - "dev": true, - "license": "MIT", - "dependencies": { - "minipass": "^7.1.2" - }, - "engines": { - "node": ">= 18" - } - }, - "node_modules/mkdirp": { - "version": "0.5.6", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", - "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", - "dev": true, - "license": "MIT", - "peer": true, - "dependencies": { - "minimist": "^1.2.6" - }, - "bin": { - "mkdirp": "bin/cmd.js" - } - }, - "node_modules/ms": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", - "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", - "license": "MIT" - }, - "node_modules/native-run": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/native-run/-/native-run-2.0.3.tgz", - "integrity": "sha512-U1PllBuzW5d1gfan+88L+Hky2eZx+9gv3Pf6rNBxKbORxi7boHzqiA6QFGSnqMem4j0A9tZ08NMIs5+0m/VS1Q==", - "dev": true, - "license": "MIT", - "dependencies": { - "@ionic/utils-fs": "^3.1.7", - "@ionic/utils-terminal": "^2.3.4", - "bplist-parser": "^0.3.2", - "debug": "^4.3.4", - "elementtree": "^0.1.7", - "ini": "^4.1.1", - "plist": "^3.1.0", - "split2": "^4.2.0", - "through2": "^4.0.2", - "tslib": "^2.6.2", - "yauzl": "^2.10.0" - }, - "bin": { - "native-run": "bin/native-run" - }, - "engines": { - "node": ">=16.0.0" - } - }, - "node_modules/node-abi": { - "version": "4.35.0", - "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-4.35.0.tgz", - "integrity": "sha512-ymk4aIzxdPopw2giv8Fs1Ec6vybGkjmyxUwVqhkI4MCy2tVfXdkOGGWieWVjL0THgH+7a8lRdevyupoYj3Js/Q==", - "dev": true, - "license": "MIT", - "dependencies": { - "semver": "^7.6.3" - }, - "engines": { - "node": ">=22.12.0" - } - }, - "node_modules/node-api-version": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/node-api-version/-/node-api-version-0.2.1.tgz", - "integrity": "sha512-2xP/IGGMmmSQpI1+O/k72jF/ykvZ89JeuKX3TLJAYPDVLUalrshrLHkeVcCCZqG/eEa635cr8IBYzgnDvM2O8Q==", - "dev": true, - "license": "MIT", - "dependencies": { - "semver": "^7.3.5" - } - }, - "node_modules/node-gyp": { - "version": "12.4.0", - "resolved": "https://registry.npmjs.org/node-gyp/-/node-gyp-12.4.0.tgz", - "integrity": "sha512-OMcPNvqTCFUnNaBlmdgq+lfNqY7gTiSmNRDjY3uAXRyudeKZEZxu3CLtjMQrx4zZxCX2b/mpNqTtwuCJgXhHkw==", - "dev": true, - "license": "MIT", - "dependencies": { - "env-paths": "^2.2.0", - "exponential-backoff": "^3.1.1", - "graceful-fs": "^4.2.6", - "nopt": "^9.0.0", - "proc-log": "^6.0.0", - "semver": "^7.3.5", - "tar": "^7.5.4", - "tinyglobby": "^0.2.12", - "undici": "^6.25.0", - "which": "^6.0.0" - }, - "bin": { - "node-gyp": "bin/node-gyp.js" - }, - "engines": { - "node": "^20.17.0 || >=22.9.0" - } - }, - "node_modules/node-gyp/node_modules/env-paths": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/env-paths/-/env-paths-2.2.1.tgz", - "integrity": "sha512-+h1lkLKhZMTYjog1VEpJNG7NZJWcuc2DDk/qsqSTRRCOXiLjeQ1d1/udrUGhqMxUgAlwKNZ0cf2uqan5GLuS2A==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6" - } - }, - "node_modules/node-gyp/node_modules/isexe": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/isexe/-/isexe-4.0.0.tgz", - "integrity": "sha512-FFUtZMpoZ8RqHS3XeXEmHWLA4thH+ZxCv2lOiPIn1Xc7CxrqhWzNSDzD+/chS/zbYezmiwWLdQC09JdQKmthOw==", - "dev": true, - "license": "BlueOak-1.0.0", - "engines": { - "node": ">=20" - } - }, - "node_modules/node-gyp/node_modules/undici": { - "version": "6.29.0", - "resolved": "https://registry.npmjs.org/undici/-/undici-6.29.0.tgz", - "integrity": "sha512-R+RODBqp6i2pPflGdq+xIOUkl+RNfGgHwoinecKu/JCuf2uO06cOKoDbI2P7Dn6KcswdKwrczbU6IYJ6K8X+wg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=18.17" - } - }, - "node_modules/node-gyp/node_modules/which": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/which/-/which-6.0.1.tgz", - "integrity": "sha512-oGLe46MIrCRqX7ytPUf66EAYvdeMIZYn3WaocqqKZAxrBpkqHfL/qvTyJ/bTk5+AqHCjXmrv3CEWgy368zhRUg==", - "dev": true, - "license": "ISC", - "dependencies": { - "isexe": "^4.0.0" - }, - "bin": { - "node-which": "bin/which.js" - }, - "engines": { - "node": "^20.17.0 || >=22.9.0" - } - }, - "node_modules/node-int64": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz", - "integrity": "sha512-O5lz91xSOeoXP6DulyHfllpq+Eg00MWitZIbtPfoSEvqIHdl5gfcY6hYzDWnj0qD5tz52PI08u9qUvSVeUBeHw==", - "dev": true, - "license": "MIT" - }, - "node_modules/nodemailer": { - "version": "10.0.9", - "resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-10.0.9.tgz", - "integrity": "sha512-BF0qcyplCwp+jMk6HCjFykBz/YhhZSsxrARhOldLwFWH+8kGjQsd2WIMIZhqEuyXRoGFi0ONbDeWDMDoL8MhLw==", - "license": "MIT-0", - "engines": { - "node": ">=20.0.0" - } - }, - "node_modules/nopt": { - "version": "9.0.0", - "resolved": "https://registry.npmjs.org/nopt/-/nopt-9.0.0.tgz", - "integrity": "sha512-Zhq3a+yFKrYwSBluL4H9XP3m3y5uvQkB/09CwDruCiRmR/UJYnn9W4R48ry0uGC70aeTPKLynBtscP9efFFcPw==", - "dev": true, - "license": "ISC", - "dependencies": { - "abbrev": "^4.0.0" - }, - "bin": { - "nopt": "bin/nopt.js" - }, - "engines": { - "node": "^20.17.0 || >=22.9.0" - } - }, - "node_modules/normalize-url": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-6.1.0.tgz", - "integrity": "sha512-DlL+XwOy3NxAQ8xuC0okPgK46iuVNAK01YN7RueYBqqFeGsBjV9XmCAzAdgt+667bCl5kPh9EqKKDwnaPG1I7A==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/object-keys": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", - "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", - "dev": true, - "license": "MIT", - "optional": true, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/on-exit-leak-free": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/on-exit-leak-free/-/on-exit-leak-free-2.1.2.tgz", - "integrity": "sha512-0eJJY6hXLGf1udHwfNftBqH+g73EU4B504nZeKpz1sYRKafAghwxEJunB2O7rDZkL4PGfsMVnTXZ2EjibbqcsA==", - "license": "MIT", - "engines": { - "node": ">=14.0.0" - } - }, - "node_modules/once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", - "dev": true, - "license": "ISC", - "dependencies": { - "wrappy": "1" - } - }, - "node_modules/open": { - "version": "8.4.2", - "resolved": "https://registry.npmjs.org/open/-/open-8.4.2.tgz", - "integrity": "sha512-7x81NCL719oNbsq/3mh+hVrAWmFuEYUqrq/Iw3kUzH8ReypT9QQ0BLoJS7/G9k6N81XjW4qHWtjWwe/9eLy1EQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "define-lazy-prop": "^2.0.0", - "is-docker": "^2.1.1", - "is-wsl": "^2.2.0" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/openpgp": { - "version": "6.3.2", - "resolved": "https://registry.npmjs.org/openpgp/-/openpgp-6.3.2.tgz", - "integrity": "sha512-wcZTzHz41LV8Y48zH/JlD1JT8YdNmpWOuMAjQ/podvvCwsjBEU37K3znJh4UQcj3hksE5z9TzvhbUbwzsGvlLQ==", - "license": "LGPL-3.0+", - "engines": { - "node": ">= 18.0.0", - "typescript": ">= 5.0.0" - }, - "peerDependencies": { - "@openpgp/web-stream-tools": "~0.3.0" - }, - "peerDependenciesMeta": { - "@openpgp/web-stream-tools": { - "optional": true - } - } - }, - "node_modules/p-cancelable": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/p-cancelable/-/p-cancelable-2.1.1.tgz", - "integrity": "sha512-BZOr3nRQHOntUjTrH8+Lh54smKHoHyur8We1V8DSMVrl5A2malOOwuJRnKRDjSnkoeBh4at6BwEnb5I7Jl31wg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" - } - }, - "node_modules/p-limit": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", - "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "yocto-queue": "^0.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/package-json-from-dist": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.1.tgz", - "integrity": "sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw==", - "dev": true, - "license": "BlueOak-1.0.0" - }, - "node_modules/parseley": { - "version": "0.13.1", - "resolved": "https://registry.npmjs.org/parseley/-/parseley-0.13.1.tgz", - "integrity": "sha512-uNBJZzmb60l6p6VWLTmevizNAGnE0xoSf1n0B4q3ntegDNzcS68NRCcBDZTcyXHxt2XhBChsCuqj4M+nChvE/A==", - "license": "MIT", - "dependencies": { - "leac": "^0.7.0", - "peberminta": "^0.10.0" - }, - "funding": { - "url": "https://github.com/sponsors/KillyMXI" - } - }, - "node_modules/path-is-absolute": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/path-key": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", - "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" - } - }, - "node_modules/path-scurry": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-2.0.2.tgz", - "integrity": "sha512-3O/iVVsJAPsOnpwWIeD+d6z/7PmqApyQePUtCndjatj/9I5LylHvt5qluFaBT3I5h3r1ejfR056c+FCv+NnNXg==", - "dev": true, - "license": "BlueOak-1.0.0", - "dependencies": { - "lru-cache": "^11.0.0", - "minipass": "^7.1.2" - }, - "engines": { - "node": "18 || 20 || >=22" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/path-scurry/node_modules/lru-cache": { - "version": "11.5.3", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.5.3.tgz", - "integrity": "sha512-U4N8FgzmWxc8k1VH8Kr6lQg18U7Fjvby6wXHVRX/ZZ7IwWbRMgrRbP0Wrb5q5NVinryp4SQampHKdvtecItxUg==", - "dev": true, - "license": "BlueOak-1.0.0", - "engines": { - "node": "20 || >=22" - } - }, - "node_modules/pe-library": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/pe-library/-/pe-library-0.4.1.tgz", - "integrity": "sha512-eRWB5LBz7PpDu4PUlwT0PhnQfTQJlDDdPa35urV4Osrm0t0AqQFGn+UIkU3klZvwJ8KPO3VbBFsXquA6p6kqZw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=12", - "npm": ">=6" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/jet2jet" - } - }, - "node_modules/peberminta": { - "version": "0.10.0", - "resolved": "https://registry.npmjs.org/peberminta/-/peberminta-0.10.0.tgz", - "integrity": "sha512-80B2AsU+I4Qdb0ZAPSfe9UwvGzwkM37IKIFEvdS3D/3Ndgv2bsuJ0bfG1+iEYO+l7Gfd4EUJmuRyq7efLgRMzQ==", - "license": "MIT", - "funding": { - "url": "https://github.com/sponsors/KillyMXI" - } - }, - "node_modules/pend": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz", - "integrity": "sha512-F3asv42UuXchdzt+xXqfW1OGlVBe+mxa2mqI0pg5yAHZPvFmY3Y6drSf/GQ1A86WgWEN9Kzh/WrgKa6iGcHXLg==", - "dev": true, - "license": "MIT" - }, - "node_modules/picocolors": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", - "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", - "dev": true, - "license": "ISC" - }, - "node_modules/picomatch": { - "version": "4.0.7", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.7.tgz", - "integrity": "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/jonschlinkert" - } - }, - "node_modules/pino": { - "version": "10.3.1", - "resolved": "https://registry.npmjs.org/pino/-/pino-10.3.1.tgz", - "integrity": "sha512-r34yH/GlQpKZbU1BvFFqOjhISRo1MNx1tWYsYvmj6KIRHSPMT2+yHOEb1SG6NMvRoHRF0a07kCOox/9yakl1vg==", - "license": "MIT", - "dependencies": { - "@pinojs/redact": "^0.4.0", - "atomic-sleep": "^1.0.0", - "on-exit-leak-free": "^2.1.0", - "pino-abstract-transport": "^3.0.0", - "pino-std-serializers": "^7.0.0", - "process-warning": "^5.0.0", - "quick-format-unescaped": "^4.0.3", - "real-require": "^0.2.0", - "safe-stable-stringify": "^2.3.1", - "sonic-boom": "^4.0.1", - "thread-stream": "^4.0.0" - }, - "bin": { - "pino": "bin.js" - } - }, - "node_modules/pino-abstract-transport": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/pino-abstract-transport/-/pino-abstract-transport-3.0.0.tgz", - "integrity": "sha512-wlfUczU+n7Hy/Ha5j9a/gZNy7We5+cXp8YL+X+PG8S0KXxw7n/JXA3c46Y0zQznIJ83URJiwy7Lh56WLokNuxg==", - "license": "MIT", - "dependencies": { - "split2": "^4.0.0" - } - }, - "node_modules/pino-std-serializers": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/pino-std-serializers/-/pino-std-serializers-7.1.0.tgz", - "integrity": "sha512-BndPH67/JxGExRgiX1dX0w1FvZck5Wa4aal9198SrRhZjH3GxKQUKIBnYJTdj2HDN3UQAS06HlfcSbQj2OHmaw==", - "license": "MIT" - }, - "node_modules/pkijs": { - "version": "3.4.1", - "resolved": "https://registry.npmjs.org/pkijs/-/pkijs-3.4.1.tgz", - "integrity": "sha512-Oo/NZcSWccq8KyoG7gLE9fnltgHns+pNCjCAp/WmjsUySi+sX7y4z4Xqu4fVb42CDHzRPl33fjzT15V1wvcyhA==", - "dev": true, - "license": "BSD-3-Clause", - "workspaces": [ - "website" - ], - "dependencies": { - "@noble/hashes": "1.8.0", - "asn1js": "^3.0.6", - "bytestreamjs": "^2.0.1", - "pvtsutils": "^1.3.6", - "pvutils": "^1.1.3", - "tslib": "^2.8.1" - }, - "engines": { - "node": ">=16.0.0" - } - }, - "node_modules/plist": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/plist/-/plist-3.1.0.tgz", - "integrity": "sha512-uysumyrvkUX0rX/dEVqt8gC3sTBzd4zoWfLeS29nb53imdaXVvLINYXTI2GNqzaMuvacNx4uJQ8+b3zXR0pkgQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "@xmldom/xmldom": "^0.8.8", - "base64-js": "^1.5.1", - "xmlbuilder": "^15.1.1" - }, - "engines": { - "node": ">=10.4.0" - } - }, - "node_modules/postject": { - "version": "1.0.0-alpha.6", - "resolved": "https://registry.npmjs.org/postject/-/postject-1.0.0-alpha.6.tgz", - "integrity": "sha512-b9Eb8h2eVqNE8edvKdwqkrY6O7kAwmI8kcnBv1NScolYJbo59XUF0noFq+lxbC1yN20bmC0WBEbDC5H/7ASb0A==", - "dev": true, - "license": "MIT", - "optional": true, - "peer": true, - "dependencies": { - "commander": "^9.4.0" - }, - "bin": { - "postject": "dist/cli.js" - }, - "engines": { - "node": ">=14.0.0" - } - }, - "node_modules/postject/node_modules/commander": { - "version": "9.5.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-9.5.0.tgz", - "integrity": "sha512-KRs7WVDKg86PWiuAqhDrAQnTXZKraVcCc6vFdL14qrZ/DcWwuRo7VoiYXalXO7S5GKpqYiVEwCbgFDfxNHKJBQ==", - "dev": true, - "license": "MIT", - "optional": true, - "peer": true, - "engines": { - "node": "^12.20.0 || >=14" - } - }, - "node_modules/proc-log": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/proc-log/-/proc-log-6.1.0.tgz", - "integrity": "sha512-iG+GYldRf2BQ0UDUAd6JQ/RwzaQy6mXmsk/IzlYyal4A4SNFw54MeH4/tLkF4I5WoWG9SQwuqWzS99jaFQHBuQ==", - "dev": true, - "license": "ISC", - "engines": { - "node": "^20.17.0 || >=22.9.0" - } - }, - "node_modules/process-nextick-args": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", - "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", - "dev": true, - "license": "MIT" - }, - "node_modules/process-warning": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/process-warning/-/process-warning-5.1.0.tgz", - "integrity": "sha512-jQSaVHsPgtyw60e1rQ/A+/ArPEj/S8pS/vFnyGa/gYFXrKk/6RuDkoqVDQ5NI5MmS01698ltlAk0NoDBNLujRw==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/fastify" - }, - { - "type": "opencollective", - "url": "https://opencollective.com/fastify" - } - ], - "license": "MIT" - }, - "node_modules/progress": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", - "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.4.0" - } - }, - "node_modules/promise-retry": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/promise-retry/-/promise-retry-2.0.1.tgz", - "integrity": "sha512-y+WKFlBR8BGXnsNlIHFGPZmyDf3DFMoLhaflAnyZgV6rG6xu+JwesTo2Q9R6XwYmtmwAFCkAk3e35jEdoeh/3g==", - "dev": true, - "license": "MIT", - "dependencies": { - "err-code": "^2.0.2", - "retry": "^0.12.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/prompts": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/prompts/-/prompts-2.4.2.tgz", - "integrity": "sha512-NxNv/kLguCA7p3jE8oL2aEBsrJWgAakBpgmgK6lpPWV+WuOmY6r2/zbAVnP+T8bQlA0nzHXSJSJW0Hq7ylaD2Q==", - "dev": true, - "license": "MIT", - "dependencies": { - "kleur": "^3.0.3", - "sisteransi": "^1.0.5" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/prompts/node_modules/kleur": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz", - "integrity": "sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6" - } - }, - "node_modules/proper-lockfile": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/proper-lockfile/-/proper-lockfile-4.1.2.tgz", - "integrity": "sha512-TjNPblN4BwAWMXU8s9AEz4JmQxnD1NNL7bNOY/AKUzyamc379FWASUhc/K1pL2noVb+XmZKLL68cjzLsiOAMaA==", - "dev": true, - "license": "MIT", - "dependencies": { - "graceful-fs": "^4.2.4", - "retry": "^0.12.0", - "signal-exit": "^3.0.2" - } - }, - "node_modules/pump": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.4.tgz", - "integrity": "sha512-VS7sjc6KR7e1ukRFhQSY5LM2uBWAUPiOPa/A3mkKmiMwSmRFUITt0xuj+/lesgnCv+dPIEYlkzrcyXgquIHMcA==", - "dev": true, - "license": "MIT", - "dependencies": { - "end-of-stream": "^1.1.0", - "once": "^1.3.1" - } - }, - "node_modules/punycode.js": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/punycode.js/-/punycode.js-2.3.1.tgz", - "integrity": "sha512-uxFIHU0YlHYhDQtV4R9J6a52SLx28BCjT+4ieh7IGbgwVJWO+km431c4yRlREUAsAmt/uMjQUyQHNEPf0M39CA==", - "license": "MIT", - "engines": { - "node": ">=6" - } - }, - "node_modules/pvtsutils": { - "version": "1.3.6", - "resolved": "https://registry.npmjs.org/pvtsutils/-/pvtsutils-1.3.6.tgz", - "integrity": "sha512-PLgQXQ6H2FWCaeRak8vvk1GW462lMxB5s3Jm673N82zI4vqtVUPuZdffdZbPDFRoU8kAhItWFtPCWiPpp4/EDg==", - "dev": true, - "license": "MIT", - "dependencies": { - "tslib": "^2.8.1" - } - }, - "node_modules/pvutils": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/pvutils/-/pvutils-1.2.0.tgz", - "integrity": "sha512-BbubeCEyTuQjVMakvJQ/Sxbc93F2pwmbsxONT/ZRrwU7Ua38d8unYTwXpTVLAKJ4BDuH9IGztCjQcd/N/39Dvg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=16.0.0" - } - }, - "node_modules/quick-format-unescaped": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/quick-format-unescaped/-/quick-format-unescaped-4.0.4.tgz", - "integrity": "sha512-tYC1Q1hgyRuHgloV/YXs2w15unPVh8qfu/qCTfhTYamaw7fyhumKa2yGpdSo87vY32rIclj+4fWYQXUMs9EHvg==", - "license": "MIT" - }, - "node_modules/quick-lru": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/quick-lru/-/quick-lru-5.1.1.tgz", - "integrity": "sha512-WuyALRjWPDGtt/wzJiadO5AXY+8hZ80hVpe6MyivgraREW751X3SbhRvG3eLKOYN+8VEvqLcf3wdnt44Z4S4SA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/read-binary-file-arch": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/read-binary-file-arch/-/read-binary-file-arch-1.0.6.tgz", - "integrity": "sha512-BNg9EN3DD3GsDXX7Aa8O4p92sryjkmzYYgmgTAc6CA4uGLEDzFfxOxugu21akOxpcXHiEgsYkC6nPsQvLLLmEg==", - "dev": true, - "license": "MIT", - "dependencies": { - "debug": "^4.3.4" - }, - "bin": { - "read-binary-file-arch": "cli.js" - } - }, - "node_modules/readable-stream": { - "version": "2.3.8", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.8.tgz", - "integrity": "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==", - "dev": true, - "license": "MIT", - "dependencies": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, - "node_modules/real-require": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/real-require/-/real-require-0.2.0.tgz", - "integrity": "sha512-57frrGM/OCTLqLOAh0mhVA9VBMHd+9U7Zb2THMGdBUoZVOtGbJzjxsYGDJ3A9AYYCP4hn6y1TVbaOfzWtm5GFg==", - "license": "MIT", - "engines": { - "node": ">= 12.13.0" - } - }, - "node_modules/require-directory": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", - "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/require-from-string": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", - "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/resedit": { - "version": "1.7.2", - "resolved": "https://registry.npmjs.org/resedit/-/resedit-1.7.2.tgz", - "integrity": "sha512-vHjcY2MlAITJhC0eRD/Vv8Vlgmu9Sd3LX9zZvtGzU5ZImdTN3+d6e/4mnTyV8vEbyf1sgNIrWxhWlrys52OkEA==", - "dev": true, - "license": "MIT", - "dependencies": { - "pe-library": "^0.4.1" - }, - "engines": { - "node": ">=12", - "npm": ">=6" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/jet2jet" - } - }, - "node_modules/resolve-alpn": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/resolve-alpn/-/resolve-alpn-1.2.1.tgz", - "integrity": "sha512-0a1F4l73/ZFZOakJnQ3FvkJ2+gSTQWz/r2KE5OdDY0TxPm5h4GkqkWWfM47T7HsbnOtcJVEF4epCVy6u7Q3K+g==", - "dev": true, - "license": "MIT" - }, - "node_modules/responselike": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/responselike/-/responselike-2.0.1.tgz", - "integrity": "sha512-4gl03wn3hj1HP3yzgdI7d3lCkF95F21Pz4BPGvKHinyQzALR5CapwC8yIi0Rh58DEMQ/SguC03wFj2k0M/mHhw==", - "dev": true, - "license": "MIT", - "dependencies": { - "lowercase-keys": "^2.0.0" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/retry": { - "version": "0.12.0", - "resolved": "https://registry.npmjs.org/retry/-/retry-0.12.0.tgz", - "integrity": "sha512-9LkiTwjUh6rT555DtE9rTX+BKByPfrMzEAtnlEtdEwr3Nkffwiihqe2bWADg+OQRjt9gl6ICdmB/ZFDCGAtSow==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 4" - } - }, - "node_modules/rimraf": { - "version": "2.6.3", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz", - "integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==", - "deprecated": "Rimraf versions prior to v4 are no longer supported", - "dev": true, - "license": "ISC", - "peer": true, - "dependencies": { - "glob": "^7.1.3" - }, - "bin": { - "rimraf": "bin.js" - } - }, - "node_modules/roarr": { - "version": "2.15.4", - "resolved": "https://registry.npmjs.org/roarr/-/roarr-2.15.4.tgz", - "integrity": "sha512-CHhPh+UNHD2GTXNYhPWLnU8ONHdI+5DI+4EYIAOaiD63rHeYlZvyh8P+in5999TTSFgUYuKUAjzRI4mdh/p+2A==", - "dev": true, - "license": "BSD-3-Clause", - "optional": true, - "dependencies": { - "boolean": "^3.0.1", - "detect-node": "^2.0.4", - "globalthis": "^1.0.1", - "json-stringify-safe": "^5.0.1", - "semver-compare": "^1.0.0", - "sprintf-js": "^1.1.2" - }, - "engines": { - "node": ">=8.0" - } - }, - "node_modules/safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", - "dev": true, - "license": "MIT" - }, - "node_modules/safe-stable-stringify": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/safe-stable-stringify/-/safe-stable-stringify-2.5.0.tgz", - "integrity": "sha512-b3rppTKm9T+PsVCBEOUR46GWI7fdOs00VKZ1+9c1EWDaDMvjQc6tUwuFyIprgGgTcWoVHSKrU8H31ZHA2e0RHA==", - "license": "MIT", - "engines": { - "node": ">=10" - } - }, - "node_modules/safer-buffer": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", - "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", - "license": "MIT" - }, - "node_modules/sanitize-filename": { - "version": "1.6.4", - "resolved": "https://registry.npmjs.org/sanitize-filename/-/sanitize-filename-1.6.4.tgz", - "integrity": "sha512-9ZyI08PsvdQl2r/bBIGubpVdR3RR9sY6RDiWFPreA21C/EFlQhmgo20UZlNjZMMZNubusLhAQozkA0Od5J21Eg==", - "dev": true, - "license": "WTFPL OR ISC", - "dependencies": { - "truncate-utf8-bytes": "^1.0.0" - } - }, - "node_modules/sax": { - "version": "1.6.1", - "resolved": "https://registry.npmjs.org/sax/-/sax-1.6.1.tgz", - "integrity": "sha512-42tBVwLWnaQvW5zc4HbZrTuWccECCZfBi92FDuwtqxasH+JbPB3/FOKb1m222K42R4WxuxzzMsTswfzgtSu64Q==", - "license": "BlueOak-1.0.0", - "engines": { - "node": ">=11.0.0" - } - }, - "node_modules/selderee": { - "version": "0.12.0", - "resolved": "https://registry.npmjs.org/selderee/-/selderee-0.12.0.tgz", - "integrity": "sha512-b1YMh3+DHZp59DLna3qVwQ5iOla/nrI6mLBNW02XxU77M3046Df6VLkoaJyFz20VsGIG5kkp+FK0kg4K4HnUFw==", - "license": "MIT", - "dependencies": { - "parseley": "~0.13.1" - }, - "funding": { - "url": "https://github.com/sponsors/KillyMXI" - } - }, - "node_modules/semver": { - "version": "7.8.5", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz", - "integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==", - "dev": true, - "license": "ISC", - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/semver-compare": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/semver-compare/-/semver-compare-1.0.0.tgz", - "integrity": "sha512-YM3/ITh2MJ5MtzaM429anh+x2jiLVjqILF4m4oyQB18W7Ggea7BfqdH/wGMK7dDiMghv/6WG7znWMwUDzJiXow==", - "dev": true, - "license": "MIT", - "optional": true - }, - "node_modules/serialize-error": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/serialize-error/-/serialize-error-7.0.1.tgz", - "integrity": "sha512-8I8TjW5KMOKsZQTvoxjuSIa7foAwPWGOts+6o7sgjz41/qMD9VQHEDxi6PBvK2l0MXUmqZyNpUK+T2tQaaElvw==", - "dev": true, - "license": "MIT", - "optional": true, - "dependencies": { - "type-fest": "^0.13.1" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/shebang-command": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", - "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", - "dev": true, - "license": "MIT", - "dependencies": { - "shebang-regex": "^3.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/shebang-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", - "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" - } - }, - "node_modules/signal-exit": { - "version": "3.0.7", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", - "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", - "dev": true, - "license": "ISC" - }, - "node_modules/simple-plist": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/simple-plist/-/simple-plist-1.3.1.tgz", - "integrity": "sha512-iMSw5i0XseMnrhtIzRb7XpQEXepa9xhWxGUojHBL43SIpQuDQkh3Wpy67ZbDzZVr6EKxvwVChnVpdl8hEVLDiw==", - "dev": true, - "license": "MIT", - "dependencies": { - "bplist-creator": "0.1.0", - "bplist-parser": "0.3.1", - "plist": "^3.0.5" - } - }, - "node_modules/simple-plist/node_modules/bplist-parser": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/bplist-parser/-/bplist-parser-0.3.1.tgz", - "integrity": "sha512-PyJxiNtA5T2PlLIeBot4lbp7rj4OadzjnMZD/G5zuBNt8ei/yCU7+wW0h2bag9vr8c+/WuRWmSxbqAl9hL1rBA==", - "dev": true, - "license": "MIT", - "dependencies": { - "big-integer": "1.6.x" - }, - "engines": { - "node": ">= 5.10.0" - } - }, - "node_modules/simple-update-notifier": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/simple-update-notifier/-/simple-update-notifier-2.0.0.tgz", - "integrity": "sha512-a2B9Y0KlNXl9u/vsW6sTIu9vGEpfKu2wRV6l1H3XEas/0gUIzGzBoP/IouTcUQbm9JWZLH3COxyn03TYlFax6w==", - "dev": true, - "license": "MIT", - "dependencies": { - "semver": "^7.5.3" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/sisteransi": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/sisteransi/-/sisteransi-1.0.5.tgz", - "integrity": "sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==", - "dev": true, - "license": "MIT" - }, - "node_modules/slice-ansi": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-4.0.0.tgz", - "integrity": "sha512-qMCMfhY040cVHT43K9BFygqYbUPFZKHOg7K73mtTWJRb8pyP3fzf4Ixd5SzdEJQ6MRUg/WBnOLxghZtKKurENQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "ansi-styles": "^4.0.0", - "astral-regex": "^2.0.0", - "is-fullwidth-code-point": "^3.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/slice-ansi?sponsor=1" - } - }, - "node_modules/smart-buffer": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-4.2.0.tgz", - "integrity": "sha512-94hK0Hh8rPqQl2xXc3HsaBoOXKV20MToPkcXvwbISWLEs+64sBq5kFgn2kJDHb1Pry9yrP0dxrCI9RRci7RXKg==", - "license": "MIT", - "engines": { - "node": ">= 6.0.0", - "npm": ">= 3.0.0" - } - }, - "node_modules/socks": { - "version": "2.8.10", - "resolved": "https://registry.npmjs.org/socks/-/socks-2.8.10.tgz", - "integrity": "sha512-e0VyvkVTwVYViNovRkZ9aodhxVlyoMn7eJhVUPxZ+eK9P/7CBkxvvsBOHqFPEH416726W8tLXXXjKwqgTErrCQ==", - "license": "MIT", - "dependencies": { - "ip-address": "^10.1.1", - "smart-buffer": "^4.2.0" - }, - "engines": { - "node": ">= 10.0.0", - "npm": ">= 3.0.0" - } - }, - "node_modules/sonic-boom": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/sonic-boom/-/sonic-boom-4.2.1.tgz", - "integrity": "sha512-w6AxtubXa2wTXAUsZMMWERrsIRAdrK0Sc+FUytWvYAhBJLyuI4llrMIC1DtlNSdI99EI86KZum2MMq3EAZlF9Q==", - "license": "MIT", - "dependencies": { - "atomic-sleep": "^1.0.0" - } - }, - "node_modules/source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true, - "license": "BSD-3-Clause", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/source-map-support": { - "version": "0.5.21", - "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", - "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==", - "dev": true, - "license": "MIT", - "dependencies": { - "buffer-from": "^1.0.0", - "source-map": "^0.6.0" - } - }, - "node_modules/split2": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/split2/-/split2-4.2.0.tgz", - "integrity": "sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg==", - "license": "ISC", - "engines": { - "node": ">= 10.x" - } - }, - "node_modules/sprintf-js": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.3.tgz", - "integrity": "sha512-Oo+0REFV59/rz3gfJNKQiBlwfHaSESl1pcGyABQsnnIfWOFt6JNj5gCog2U6MLZ//IGYD+nA8nI+mTShREReaA==", - "dev": true, - "license": "BSD-3-Clause", - "optional": true - }, - "node_modules/stat-mode": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/stat-mode/-/stat-mode-1.0.0.tgz", - "integrity": "sha512-jH9EhtKIjuXZ2cWxmXS8ZP80XyC3iasQxMDV8jzhNJpfDb7VbQLVW4Wvsxz9QZvzV+G4YoSfBUVKDOyxLzi/sg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 6" - } - }, - "node_modules/stream-buffers": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/stream-buffers/-/stream-buffers-2.2.0.tgz", - "integrity": "sha512-uyQK/mx5QjHun80FLJTfaWE7JtwfRMKBLkMne6udYOmvH0CawotVa7TfgYHzAnpphn4+TweIx1QKMnRIbipmUg==", - "dev": true, - "license": "Unlicense", - "engines": { - "node": ">= 0.10.0" - } - }, - "node_modules/string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "dev": true, - "license": "MIT", - "dependencies": { - "safe-buffer": "~5.1.0" - } - }, - "node_modules/string-width": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dev": true, - "license": "MIT", - "dependencies": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/strip-ansi": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dev": true, - "license": "MIT", - "dependencies": { - "ansi-regex": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/sumchecker": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/sumchecker/-/sumchecker-3.0.1.tgz", - "integrity": "sha512-MvjXzkz/BOfyVDkG0oFOtBxHX2u3gKbMHIF/dXblZsgD3BWOFLmHovIpZY7BykJdAjcqRCBi1WYBNdEC9yI7vg==", - "dev": true, - "license": "Apache-2.0", - "dependencies": { - "debug": "^4.1.0" - }, - "engines": { - "node": ">= 8.0" - } - }, - "node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "license": "MIT", - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/tar": { - "version": "7.5.22", - "resolved": "https://registry.npmjs.org/tar/-/tar-7.5.22.tgz", - "integrity": "sha512-MFO/QzvtAOmJbkhOaCTvbGcFN9L9b+JunIsDwaKljSOdcLMea3NJ1k9Usz/rjdfSXTq4dfzfeS7W4p4YOAAHeA==", - "dev": true, - "license": "BlueOak-1.0.0", - "dependencies": { - "@isaacs/fs-minipass": "^4.0.0", - "chownr": "^3.0.0", - "minipass": "^7.1.2", - "minizlib": "^3.1.0", - "yallist": "^5.0.0" - }, - "engines": { - "node": ">=18" - } - }, - "node_modules/tar/node_modules/yallist": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-5.0.0.tgz", - "integrity": "sha512-YgvUTfwqyc7UXVMrB+SImsVYSmTS8X/tSrtdNZMImM+n7+QTriRXyXim0mBrTXNeqzVF0KWGgHPeiyViFFrNDw==", - "dev": true, - "license": "BlueOak-1.0.0", - "engines": { - "node": ">=18" - } - }, - "node_modules/temp": { - "version": "0.9.4", - "resolved": "https://registry.npmjs.org/temp/-/temp-0.9.4.tgz", - "integrity": "sha512-yYrrsWnrXMcdsnu/7YMYAofM1ktpL5By7vZhf15CrXijWWrEYZks5AXBudalfSWJLlnen/QUJUB5aoB0kqZUGA==", - "dev": true, - "license": "MIT", - "peer": true, - "dependencies": { - "mkdirp": "^0.5.1", - "rimraf": "~2.6.2" - }, - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/temp-file": { - "version": "3.4.0", - "resolved": "https://registry.npmjs.org/temp-file/-/temp-file-3.4.0.tgz", - "integrity": "sha512-C5tjlC/HCtVUOi3KWVokd4vHVViOmGjtLwIh4MuzPo/nMYTV/p1urt3RnMz2IWXDdKEGJH3k5+KPxtqRsUYGtg==", - "dev": true, - "license": "MIT", - "dependencies": { - "async-exit-hook": "^2.0.1", - "fs-extra": "^10.0.0" - } - }, - "node_modules/thread-stream": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/thread-stream/-/thread-stream-4.2.0.tgz", - "integrity": "sha512-e2zZ96wSChazBsbENf/Pcm/4swHt2cEKQ92rhUjkL9GCKiTDJIaTBenjE/m9DXi0QBmTMDkFDdOomUy20A1tDQ==", - "license": "MIT", - "dependencies": { - "real-require": "^1.0.0" - }, - "engines": { - "node": ">=20" - } - }, - "node_modules/thread-stream/node_modules/real-require": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/real-require/-/real-require-1.0.0.tgz", - "integrity": "sha512-P4nbQYQfePJxRSmY+v/KINxVucm4NF3p3s7pJveMTtom52FR4YGltUQLB8idDXwDDWW+eYrWDFbuzUnjoWHF7g==", - "license": "MIT" - }, - "node_modules/through2": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/through2/-/through2-4.0.2.tgz", - "integrity": "sha512-iOqSav00cVxEEICeD7TjLB1sueEL+81Wpzp2bY17uZjZN0pWZPuo4suZ/61VujxmqSGFfgOcNuTZ85QJwNZQpw==", - "dev": true, - "license": "MIT", - "dependencies": { - "readable-stream": "3" - } - }, - "node_modules/through2/node_modules/readable-stream": { - "version": "3.6.2", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", - "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", - "dev": true, - "license": "MIT", - "dependencies": { - "inherits": "^2.0.3", - "string_decoder": "^1.1.1", - "util-deprecate": "^1.0.1" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/tiny-async-pool": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/tiny-async-pool/-/tiny-async-pool-1.3.0.tgz", - "integrity": "sha512-01EAw5EDrcVrdgyCLgoSPvqznC0sVxDSVeiOz09FUpjh71G79VCqneOr+xvt7T1r76CF6ZZfPjHorN2+d+3mqA==", - "dev": true, - "license": "MIT", - "dependencies": { - "semver": "^5.5.0" - } - }, - "node_modules/tiny-async-pool/node_modules/semver": { - "version": "5.7.2", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz", - "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==", - "dev": true, - "license": "ISC", - "bin": { - "semver": "bin/semver" - } - }, - "node_modules/tinyglobby": { - "version": "0.2.17", - "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.17.tgz", - "integrity": "sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==", - "dev": true, - "license": "MIT", - "dependencies": { - "fdir": "^6.5.0", - "picomatch": "^4.0.4" - }, - "engines": { - "node": ">=12.0.0" - }, - "funding": { - "url": "https://github.com/sponsors/SuperchupuDev" - } - }, - "node_modules/tlds": { - "version": "1.261.0", - "resolved": "https://registry.npmjs.org/tlds/-/tlds-1.261.0.tgz", - "integrity": "sha512-QXqwfEl9ddlGBaRFXIvNKK6OhipSiLXuRuLJX5DErz0o0Q0rYxulWLdFryTkV5PkdZct5iMInwYEGe/eR++1AA==", - "license": "MIT", - "bin": { - "tlds": "bin.js" - } - }, - "node_modules/tmp": { - "version": "0.2.7", - "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.7.tgz", - "integrity": "sha512-e0votIpp4Uo2AJYSzVHV6xCcawuiez3DzqDAbrTc3YxBkplN6e+dM13ZeIcZnDg/QpSuU2zfZ3rzwY8ukEnaXw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=14.14" - } - }, - "node_modules/tmp-promise": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/tmp-promise/-/tmp-promise-3.0.3.tgz", - "integrity": "sha512-RwM7MoPojPxsOBYnyd2hy0bxtIlVrihNs9pj5SUvY8Zz1sQcQG2tG1hSr8PDxfgEB8RNKDhqbIlroIarSNDNsQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "tmp": "^0.2.0" - } - }, - "node_modules/tree-kill": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/tree-kill/-/tree-kill-1.2.2.tgz", - "integrity": "sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==", - "dev": true, - "license": "MIT", - "bin": { - "tree-kill": "cli.js" - } - }, - "node_modules/truncate-utf8-bytes": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/truncate-utf8-bytes/-/truncate-utf8-bytes-1.0.2.tgz", - "integrity": "sha512-95Pu1QXQvruGEhv62XCMO3Mm90GscOCClvrIUwCM0PYOXK3kaF3l3sIHxx71ThJfcbM2O5Au6SO3AWCSEfW4mQ==", - "dev": true, - "license": "WTFPL", - "dependencies": { - "utf8-byte-length": "^1.0.1" - } - }, - "node_modules/tsdav": { - "version": "2.3.4", - "resolved": "https://registry.npmjs.org/tsdav/-/tsdav-2.3.4.tgz", - "integrity": "sha512-JAmWfNM0WFmzAfjE0s0881rMYGFiyl2HVtktnh37yopoA6DjrdCRGrFw4jQEFwMwual5/ThCOYbULt9bsTm1Ww==", - "license": "MIT", - "dependencies": { - "debug": "4.4.3", - "xml-js": "1.6.11" - }, - "engines": { - "node": ">=18" - } - }, - "node_modules/tslib": { - "version": "2.8.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", - "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", - "license": "0BSD" - }, - "node_modules/type-fest": { - "version": "0.13.1", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.13.1.tgz", - "integrity": "sha512-34R7HTnG0XIJcBSn5XhDd7nNFPRcXYRZrBB2O2jdKqYODldSzBAqzsWoZYYvduky73toYS/ESqxPvkDf/F0XMg==", - "dev": true, - "license": "(MIT OR CC0-1.0)", - "optional": true, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/uc.micro": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-2.1.0.tgz", - "integrity": "sha512-ARDJmphmdvUk6Glw7y9DQ2bFkKBHwQHLi2lsaH6PPmz/Ka9sFOBsBluozhDltWmnv9u/cF6Rt87znRTPV+yp/A==", - "license": "MIT" - }, - "node_modules/undici": { - "version": "7.30.0", - "resolved": "https://registry.npmjs.org/undici/-/undici-7.30.0.tgz", - "integrity": "sha512-dkrQXeHSaoamnItlYbmzG0wFYrM0ZwDxCIg0A7aKjTyyhh9svRzCNFEzV+Vm05/yehjCzjDZ31KXfGEjYSztDQ==", - "dev": true, - "license": "MIT", - "optional": true, - "engines": { - "node": ">=20.18.1" - } - }, - "node_modules/undici-types": { - "version": "7.24.6", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.24.6.tgz", - "integrity": "sha512-WRNW+sJgj5OBN4/0JpHFqtqzhpbnV0GuB+OozA9gCL7a993SmU+1JBZCzLNxYsbMfIeDL+lTsphD5jN5N+n0zg==", - "dev": true, - "license": "MIT" - }, - "node_modules/universalify": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz", - "integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 10.0.0" - } - }, - "node_modules/untildify": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/untildify/-/untildify-4.0.0.tgz", - "integrity": "sha512-KK8xQ1mkzZeg9inewmFVDNkg3l5LUhoq9kN6iWYB/CC9YMG8HA+c1Q8HwDe6dEX7kErrEVNVBO3fWsVq5iDgtw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" - } - }, - "node_modules/unzipper": { - "version": "0.12.5", - "resolved": "https://registry.npmjs.org/unzipper/-/unzipper-0.12.5.tgz", - "integrity": "sha512-tXYOi9R57Uj/2Z25SOs5RRSzq886MBQj2gY8dPL+xl/kv6s6SvByoKfAtvfVeEuhntWDgjd2o9p2lb4TVPAz0A==", - "dev": true, - "license": "MIT", - "dependencies": { - "bluebird": "~3.7.2", - "duplexer2": "~0.1.4", - "fs-extra": "11.3.1", - "graceful-fs": "^4.2.2", - "node-int64": "^0.4.0" - } - }, - "node_modules/unzipper/node_modules/fs-extra": { - "version": "11.3.1", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-11.3.1.tgz", - "integrity": "sha512-eXvGGwZ5CL17ZSwHWd3bbgk7UUpF6IFHtP57NYYakPvHOs8GDgDe5KJI36jIJzDkJ6eJjuzRA8eBQb6SkKue0g==", - "dev": true, - "license": "MIT", - "dependencies": { - "graceful-fs": "^4.2.0", - "jsonfile": "^6.0.1", - "universalify": "^2.0.0" - }, - "engines": { - "node": ">=14.14" - } - }, - "node_modules/utf8-byte-length": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/utf8-byte-length/-/utf8-byte-length-1.0.5.tgz", - "integrity": "sha512-Xn0w3MtiQ6zoz2vFyUVruaCL53O/DwUvkEeOvj+uulMm0BkUGYWmBYVyElqZaSLhY6ZD0ulfU3aBra2aVT4xfA==", - "dev": true, - "license": "(WTFPL OR MIT)" - }, - "node_modules/util-deprecate": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", - "dev": true, - "license": "MIT" - }, - "node_modules/uuid": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-7.0.3.tgz", - "integrity": "sha512-DPSke0pXhTZgoF/d+WSt2QaKMCFSfx7QegxEWT+JOuHF5aWrKEn0G+ztjuJg/gG8/ItK+rbPCD/yNv8yyih6Cg==", - "deprecated": "uuid@10 and below is no longer supported. For ESM codebases, update to uuid@latest. For CommonJS codebases, use uuid@11 (but be aware this version will likely be deprecated in 2028).", - "dev": true, - "license": "MIT", - "bin": { - "uuid": "dist/bin/uuid" - } - }, - "node_modules/v8-compile-cache": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.4.0.tgz", - "integrity": "sha512-ocyWc3bAHBB/guyqJQVI5o4BZkPhznPYUG2ea80Gond/BgNWpap8TOmLSeeQG7bnh2KMISxskdADG59j7zruhw==", - "license": "MIT" - }, - "node_modules/webcrypto-core": { - "version": "1.9.2", - "resolved": "https://registry.npmjs.org/webcrypto-core/-/webcrypto-core-1.9.2.tgz", - "integrity": "sha512-gsXecm82UQNlTBURJGuqOWy1Ww08S3kZUcr3aOJS02Pk0xLtkfeUAVC0u0xhgdonFme80edSJUIJyuvL/7250Q==", - "dev": true, - "license": "MIT", - "dependencies": { - "@peculiar/asn1-schema": "^2.7.0", - "@peculiar/json-schema": "^1.1.12", - "@peculiar/utils": "^2.0.2", - "asn1js": "^3.0.10", - "tslib": "^2.8.1" - } - }, - "node_modules/which": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/which/-/which-5.0.0.tgz", - "integrity": "sha512-JEdGzHwwkrbWoGOlIHqQ5gtprKGOenpDHpxE9zVR1bWbOtYRyPPHMe9FaP6x61CmNaTThSkb0DAJte5jD+DmzQ==", - "dev": true, - "license": "ISC", - "dependencies": { - "isexe": "^3.1.1" - }, - "bin": { - "node-which": "bin/which.js" - }, - "engines": { - "node": "^18.17.0 || >=20.5.0" - } - }, - "node_modules/wrap-ansi": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", - "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", - "dev": true, - "license": "MIT", - "dependencies": { - "ansi-styles": "^4.0.0", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/wrap-ansi?sponsor=1" - } - }, - "node_modules/wrappy": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", - "dev": true, - "license": "ISC" - }, - "node_modules/xcode": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/xcode/-/xcode-3.0.1.tgz", - "integrity": "sha512-kCz5k7J7XbJtjABOvkc5lJmkiDh8VhjVCGNiqdKCscmVpdVUpEAyXv1xmCLkQJ5dsHqx3IPO4XW+NTDhU/fatA==", - "dev": true, - "license": "Apache-2.0", - "dependencies": { - "simple-plist": "^1.1.0", - "uuid": "^7.0.3" - }, - "engines": { - "node": ">=10.0.0" - } - }, - "node_modules/xml-js": { - "version": "1.6.11", - "resolved": "https://registry.npmjs.org/xml-js/-/xml-js-1.6.11.tgz", - "integrity": "sha512-7rVi2KMfwfWFl+GpPg6m80IVMWXLRjO+PxTq7V2CDhoGak0wzYzFgUY2m4XJ47OGdXd8eLE8EmwfAmdjw7lC1g==", - "license": "MIT", - "dependencies": { - "sax": "^1.2.4" - }, - "bin": { - "xml-js": "bin/cli.js" - } - }, - "node_modules/xml2js": { - "version": "0.6.2", - "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.6.2.tgz", - "integrity": "sha512-T4rieHaC1EXcES0Kxxj4JWgaUQHDk+qwHcYOCFHfiwKz7tOVPLq7Hjq9dM1WCMhylqMEfP7hMcOIChvotiZegA==", - "dev": true, - "license": "MIT", - "dependencies": { - "sax": ">=0.6.0", - "xmlbuilder": "~11.0.0" - }, - "engines": { - "node": ">=4.0.0" - } - }, - "node_modules/xml2js/node_modules/xmlbuilder": { - "version": "11.0.1", - "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-11.0.1.tgz", - "integrity": "sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=4.0" - } - }, - "node_modules/xmlbuilder": { - "version": "15.1.1", - "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-15.1.1.tgz", - "integrity": "sha512-yMqGBqtXyeN1e3TGYvgNgDVZ3j84W4cwkOXQswghol6APgZWaff9lnbvN7MHYJOiXsvGPXtjTYJEiC9J2wv9Eg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8.0" - } - }, - "node_modules/y18n": { - "version": "5.0.8", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", - "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", - "dev": true, - "license": "ISC", - "engines": { - "node": ">=10" - } - }, - "node_modules/yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", - "dev": true, - "license": "ISC" - }, - "node_modules/yargs": { - "version": "17.7.3", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.3.tgz", - "integrity": "sha512-GZtjxm/J/4TSxuL3FNYjCmLktBTnIw/rVmKSIyKeYAZpmJB2ig9VauCC5xsa82GNKVKDAqpOn3KVzNt0zmrU0g==", - "dev": true, - "license": "MIT", - "dependencies": { - "cliui": "^8.0.1", - "escalade": "^3.1.1", - "get-caller-file": "^2.0.5", - "require-directory": "^2.1.1", - "string-width": "^4.2.3", - "y18n": "^5.0.5", - "yargs-parser": "^21.1.1" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/yargs-parser": { - "version": "21.1.1", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", - "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", - "dev": true, - "license": "ISC", - "engines": { - "node": ">=12" - } - }, - "node_modules/yauzl": { - "version": "2.10.0", - "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.10.0.tgz", - "integrity": "sha512-p4a9I6X6nu6IhoGmBqAcbJy1mlC4j27vEPZX9F4L4/vZT3Lyq1VkFHw/V/PUcB9Buo+DG3iHkT0x3Qya58zc3g==", - "dev": true, - "license": "MIT", - "dependencies": { - "buffer-crc32": "~0.2.3", - "fd-slicer": "~1.1.0" - } - }, - "node_modules/yocto-queue": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", - "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - } - } -} +{ + "name": "ep-mail", + "version": "0.5.2", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "ep-mail", + "version": "0.5.2", + "dependencies": { + "@capacitor/android": "^8.5.2", + "@capacitor/core": "^8.5.2", + "ical.js": "^2.2.1", + "imapflow": "2.2.1", + "mailparser": "3.9.33", + "nodemailer": "10.0.9", + "openpgp": "^6.3.2", + "tsdav": "^2.3.4", + "v8-compile-cache": "^2.4.0" + }, + "devDependencies": { + "@capacitor/cli": "^8.5.2", + "electron": "44.5.1", + "electron-builder": "26.17.0", + "esbuild": "^0.28.2" + } + }, + "node_modules/@capacitor/android": { + "version": "8.5.2", + "resolved": "https://registry.npmjs.org/@capacitor/android/-/android-8.5.2.tgz", + "integrity": "sha512-rtiaz78egCcS+vs29wkWCL3C+RhazKMSygXcjutwWP8NmO6r5UBxOvGf3Wjz5+ahobyQ723tn9gCePwRwcNDZQ==", + "license": "MIT", + "peerDependencies": { + "@capacitor/core": "^8.5.0" + } + }, + "node_modules/@capacitor/cli": { + "version": "8.5.2", + "resolved": "https://registry.npmjs.org/@capacitor/cli/-/cli-8.5.2.tgz", + "integrity": "sha512-O2kpA5ZPJUAmliDCcmpMf8xnJwMezxlFPUrlyOAjbL3U9MFNY3l4ZpPI/UXwvyPmR8ETcVF9pFr+VdWq61rqTQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@ionic/cli-framework-output": "^2.2.8", + "@ionic/utils-subprocess": "^3.0.1", + "@ionic/utils-terminal": "^2.3.5", + "commander": "^12.1.0", + "debug": "^4.4.0", + "env-paths": "^2.2.0", + "fs-extra": "^11.2.0", + "kleur": "^4.1.5", + "native-run": "^2.0.3", + "open": "^8.4.0", + "plist": "^3.1.0", + "prompts": "^2.4.2", + "rimraf": "^6.0.1", + "semver": "^7.6.3", + "tar": "^7.5.3", + "tslib": "^2.8.1", + "xcode": "^3.0.1", + "xml2js": "^0.6.2" + }, + "bin": { + "cap": "bin/capacitor", + "capacitor": "bin/capacitor" + }, + "engines": { + "node": ">=22.0.0" + } + }, + "node_modules/@capacitor/cli/node_modules/commander": { + "version": "12.1.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-12.1.0.tgz", + "integrity": "sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/@capacitor/cli/node_modules/env-paths": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/env-paths/-/env-paths-2.2.1.tgz", + "integrity": "sha512-+h1lkLKhZMTYjog1VEpJNG7NZJWcuc2DDk/qsqSTRRCOXiLjeQ1d1/udrUGhqMxUgAlwKNZ0cf2uqan5GLuS2A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/@capacitor/cli/node_modules/fs-extra": { + "version": "11.4.1", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-11.4.1.tgz", + "integrity": "sha512-KYAb4c9BJQI6QqGKthV68OHe0badztdXJWKo0WtBA9IuCFPTKvE5ZdUBglP833aMjhaSPNO4A5j/EkzZtGlKjA==", + "dev": true, + "license": "MIT", + "dependencies": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + }, + "engines": { + "node": ">=14.14" + } + }, + "node_modules/@capacitor/cli/node_modules/glob": { + "version": "13.0.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-13.0.6.tgz", + "integrity": "sha512-Wjlyrolmm8uDpm/ogGyXZXb1Z+Ca2B8NbJwqBVg0axK9GbBeoS7yGV6vjXnYdGm6X53iehEuxxbyiKp8QmN4Vw==", + "dev": true, + "license": "BlueOak-1.0.0", + "dependencies": { + "minimatch": "^10.2.2", + "minipass": "^7.1.3", + "path-scurry": "^2.0.2" + }, + "engines": { + "node": "18 || 20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/@capacitor/cli/node_modules/rimraf": { + "version": "6.1.3", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-6.1.3.tgz", + "integrity": "sha512-LKg+Cr2ZF61fkcaK1UdkH2yEBBKnYjTyWzTJT6KNPcSPaiT7HSdhtMXQuN5wkTX0Xu72KQ1l8S42rlmexS2hSA==", + "dev": true, + "license": "BlueOak-1.0.0", + "dependencies": { + "glob": "^13.0.3", + "package-json-from-dist": "^1.0.1" + }, + "bin": { + "rimraf": "dist/esm/bin.mjs" + }, + "engines": { + "node": "20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/@capacitor/core": { + "version": "8.5.2", + "resolved": "https://registry.npmjs.org/@capacitor/core/-/core-8.5.2.tgz", + "integrity": "sha512-agnQbGdhGw/KZFuLf7H9SY2o+oE7upkr/WPQsYaokXP6f9chaE8iVmbKkfN6SVl4w3pmz7oZ3Ur1hbkmy1hx+w==", + "license": "MIT", + "dependencies": { + "tslib": "^2.1.0" + } + }, + "node_modules/@electron-internal/extract-zip": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/@electron-internal/extract-zip/-/extract-zip-1.0.5.tgz", + "integrity": "sha512-+bqFCP98pLI0Tt0XQo1TmlXtwjWchISndDOxCkEcIuUgXWpBnLyRI+2DU+mesvnMMX6L1XDqYNA0lXNDHd/yiA==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=22.12.0" + } + }, + "node_modules/@electron/asar": { + "version": "3.4.1", + "resolved": "https://registry.npmjs.org/@electron/asar/-/asar-3.4.1.tgz", + "integrity": "sha512-i4/rNPRS84t0vSRa2HorerGRXWyF4vThfHesw0dmcWHp+cspK743UanA0suA5Q5y8kzY2y6YKrvbIUn69BCAiA==", + "dev": true, + "license": "MIT", + "dependencies": { + "commander": "^5.0.0", + "glob": "^7.1.6", + "minimatch": "^3.0.4" + }, + "bin": { + "asar": "bin/asar.js" + }, + "engines": { + "node": ">=10.12.0" + } + }, + "node_modules/@electron/asar/node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@electron/asar/node_modules/brace-expansion": { + "version": "1.1.21", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.21.tgz", + "integrity": "sha512-9zeA+KLZNNzglF2TPKRQEDyx6Yby7daAkuy8MiPzpXPsYDWi/DRM8jmwUDxokQjYqBpv5DgPiwD4h4ZZSy1Ujw==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/@electron/asar/node_modules/minimatch": { + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.5.tgz", + "integrity": "sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/@electron/fuses": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/@electron/fuses/-/fuses-1.8.0.tgz", + "integrity": "sha512-zx0EIq78WlY/lBb1uXlziZmDZI4ubcCXIMJ4uGjXzZW0nS19TjSPeXPAjzzTmKQlJUZm0SbmZhPKP7tuQ1SsEw==", + "dev": true, + "license": "MIT", + "dependencies": { + "chalk": "^4.1.1", + "fs-extra": "^9.0.1", + "minimist": "^1.2.5" + }, + "bin": { + "electron-fuses": "dist/bin.js" + } + }, + "node_modules/@electron/fuses/node_modules/fs-extra": { + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-9.1.0.tgz", + "integrity": "sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "at-least-node": "^1.0.0", + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@electron/get": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@electron/get/-/get-5.1.0.tgz", + "integrity": "sha512-3kSBtG8ObcTVfXanm5vVJ6UnBLEVmVsRk1M+vGqCuMBV+XLCbJYuWQful+yIy0GQDsSlK0kHEriEHn7SPk4EnA==", + "dev": true, + "license": "MIT", + "dependencies": { + "debug": "^4.1.1", + "env-paths": "^3.0.0", + "graceful-fs": "^4.2.11", + "progress": "^2.0.3", + "semver": "^7.6.3", + "sumchecker": "^3.0.1" + }, + "engines": { + "node": ">=22.12.0" + }, + "optionalDependencies": { + "undici": "^7.24.4" + } + }, + "node_modules/@electron/notarize": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/@electron/notarize/-/notarize-2.5.0.tgz", + "integrity": "sha512-jNT8nwH1f9X5GEITXaQ8IF/KdskvIkOFfB2CvwumsveVidzpSc+mvhhTMdAGSYF3O+Nq49lJ7y+ssODRXu06+A==", + "dev": true, + "license": "MIT", + "dependencies": { + "debug": "^4.1.1", + "fs-extra": "^9.0.1", + "promise-retry": "^2.0.1" + }, + "engines": { + "node": ">= 10.0.0" + } + }, + "node_modules/@electron/notarize/node_modules/fs-extra": { + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-9.1.0.tgz", + "integrity": "sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "at-least-node": "^1.0.0", + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@electron/osx-sign": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/@electron/osx-sign/-/osx-sign-1.3.3.tgz", + "integrity": "sha512-KZ8mhXvWv2rIEgMbWZ4y33bDHyUKMXnx4M0sTyPNK/vcB81ImdeY9Ggdqy0SWbMDgmbqyQ+phgejh6V3R2QuSg==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "compare-version": "^0.1.2", + "debug": "^4.3.4", + "fs-extra": "^10.0.0", + "isbinaryfile": "^4.0.8", + "minimist": "^1.2.6", + "plist": "^3.0.5" + }, + "bin": { + "electron-osx-flat": "bin/electron-osx-flat.js", + "electron-osx-sign": "bin/electron-osx-sign.js" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/@electron/osx-sign/node_modules/isbinaryfile": { + "version": "4.0.10", + "resolved": "https://registry.npmjs.org/isbinaryfile/-/isbinaryfile-4.0.10.tgz", + "integrity": "sha512-iHrqe5shvBUcFbmZq9zOQHBoeOhZJu6RQGrDpBgenUm/Am+F3JM2MgQj+rK3Z601fzrL5gLZWtAPH2OBaSVcyw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 8.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/gjtorikian/" + } + }, + "node_modules/@electron/rebuild": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/@electron/rebuild/-/rebuild-4.2.0.tgz", + "integrity": "sha512-RKL/O+jGoXJMxrx/5771y1n0xTKmFuOYGO3gMmwypBM6rsH0kou0mswwdXA2JrhIkE4xyC7v9vGk0n6NPzgOxQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@malept/cross-spawn-promise": "^2.0.0", + "debug": "^4.1.1", + "node-abi": "^4.2.0", + "node-api-version": "^0.2.1", + "node-gyp": "^12.2.0", + "read-binary-file-arch": "^1.0.6" + }, + "bin": { + "electron-rebuild": "lib/cli.js" + }, + "engines": { + "node": ">=22.12.0" + } + }, + "node_modules/@electron/universal": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/@electron/universal/-/universal-2.0.3.tgz", + "integrity": "sha512-Wn9sPYIVFRFl5HmwMJkARCCf7rqK/EurkfQ/rJZ14mHP3iYTjZSIOSVonEAnhWeAXwtw7zOekGRlc6yTtZ0t+g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@electron/asar": "^3.3.1", + "@malept/cross-spawn-promise": "^2.0.0", + "debug": "^4.3.1", + "dir-compare": "^4.2.0", + "fs-extra": "^11.1.1", + "minimatch": "^9.0.3", + "plist": "^3.1.0" + }, + "engines": { + "node": ">=16.4" + } + }, + "node_modules/@electron/universal/node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@electron/universal/node_modules/brace-expansion": { + "version": "2.1.7", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.1.7.tgz", + "integrity": "sha512-uZbew1NqdmPDTMJ8ah1y+b+9QEJrfkXFk3RcTQw3X0jW/xRUvFKsg1CfQdSYGdTbXZWExtU3J3ccxtnfw1Fi0g==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/@electron/universal/node_modules/fs-extra": { + "version": "11.4.1", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-11.4.1.tgz", + "integrity": "sha512-KYAb4c9BJQI6QqGKthV68OHe0badztdXJWKo0WtBA9IuCFPTKvE5ZdUBglP833aMjhaSPNO4A5j/EkzZtGlKjA==", + "dev": true, + "license": "MIT", + "dependencies": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + }, + "engines": { + "node": ">=14.14" + } + }, + "node_modules/@electron/universal/node_modules/minimatch": { + "version": "9.0.9", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.9.tgz", + "integrity": "sha512-OBwBN9AL4dqmETlpS2zasx+vTeWclWzkblfZk7KTA5j3jeOONz/tRCnZomUyvNg83wL5Zv9Ss6HMJXAgL8R2Yg==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^2.0.2" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/@electron/windows-sign": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/@electron/windows-sign/-/windows-sign-1.2.2.tgz", + "integrity": "sha512-dfZeox66AvdPtb2lD8OsIIQh12Tp0GNCRUDfBHIKGpbmopZto2/A8nSpYYLoedPIHpqkeblZ/k8OV0Gy7PYuyQ==", + "dev": true, + "license": "BSD-2-Clause", + "optional": true, + "peer": true, + "dependencies": { + "cross-dirname": "^0.1.0", + "debug": "^4.3.4", + "fs-extra": "^11.1.1", + "minimist": "^1.2.8", + "postject": "^1.0.0-alpha.6" + }, + "bin": { + "electron-windows-sign": "bin/electron-windows-sign.js" + }, + "engines": { + "node": ">=14.14" + } + }, + "node_modules/@electron/windows-sign/node_modules/fs-extra": { + "version": "11.4.1", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-11.4.1.tgz", + "integrity": "sha512-KYAb4c9BJQI6QqGKthV68OHe0badztdXJWKo0WtBA9IuCFPTKvE5ZdUBglP833aMjhaSPNO4A5j/EkzZtGlKjA==", + "dev": true, + "license": "MIT", + "optional": true, + "peer": true, + "dependencies": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + }, + "engines": { + "node": ">=14.14" + } + }, + "node_modules/@esbuild/aix-ppc64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.28.2.tgz", + "integrity": "sha512-XExcO+dvLKvVtNTibSTBej1NCAbaGhWn9Ww1ZPx80qsahhPFe/8jgWP0IchNe0F3HwkU7n8ejhH8bjonqht8mQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.28.2.tgz", + "integrity": "sha512-kXXoiPVVGQcnIYGOeaovwOURpniDBpSq4A03qkQ+BMQqtGG6HYap3xne9C1O1yo4TR3qxlCX5IqqmX6fFo2Lqg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.28.2.tgz", + "integrity": "sha512-5YfKeeI8qWfBZIX+u2xZC3Zlb3Os/gLS2sbEKM+I4ZOcsWmHS2WLysCcQZDAFRslDUU5Oiq44gf6PYN1vGwG5A==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.28.2.tgz", + "integrity": "sha512-O387ite7SzUyCcy3JQX4P4bLtEA7bLLkx+esve5JHnyYfNTxcVpXZo9jhdB0lTKN44gztELTdU7nS8Nr16Fs1Q==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.28.2.tgz", + "integrity": "sha512-n4KqkOQrraxHJcgjM1RvwbigfQKIKJVpM7xp+KsxiyUSrRdIXnt73VhrPAx0fV44hgfmIVKjxMN9J1t5jySVkw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.28.2.tgz", + "integrity": "sha512-uq6suIWYP37qzGddBKPw5QEQPi6HiLGsO7UmkpfyaYNQ3D+rN6w6WfwH+nuqcGXWvawGwxOEroO4YGnFh95azw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.28.2.tgz", + "integrity": "sha512-n+I0BTSRIoy+d6RPKnEVwql5UwBJolytvY4mAOIEJorKlqgPII8ix6slVVrfZ5Tnj7glIZvloylbB/EJPMWEXw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.28.2.tgz", + "integrity": "sha512-78XJTJkvPs0kz2w61301PJjXl4g7q3JqiYMZ/M/yVI73EHBrCRTgkhu9oqG7vPqq+a/yadEW8aD+agKlk5xrmg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.28.2.tgz", + "integrity": "sha512-XlDnu2q5yoqems+xay6wSAcg9DDD7K9RLKZEBOMZm3ckNpJBvOX20tSfby8KfrrhINDyv9V2YVZKY/SpoGJI8w==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.28.2.tgz", + "integrity": "sha512-pW4AC0P3it8c7do9MVM4p51FzHzdM/TZrerurgRcHJ2WTa1VQ1CIq18xncfpBJw4ojkiZZrKW2yIBWBP92j6Ug==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.28.2.tgz", + "integrity": "sha512-CYbnj78HsIeA+DhgUKgFCfvNsTHFhMMrinUrMZpDXJXKN8T3XViTZ/+wtHeVxEWY8ewSzTFN+nRmSwO2tZaLUQ==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.28.2.tgz", + "integrity": "sha512-buwkd8nsph4R+ajRvw0qM5Hja/TXQow3ptzWO2EbG/cqcIkHloRrdlBtQlshyYGTNFvfkfJ5tpPLVkY4DtsPfQ==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.28.2.tgz", + "integrity": "sha512-ZVykbDyk7519VwiNb9Lcj9m8XM6v5V9uKPvrEMkkEedVewf+0itkhahp4HDpgERXhwLRpWFypsGbG/J8s0QjJA==", + "cpu": [ + "mips64el" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.28.2.tgz", + "integrity": "sha512-CAXl+Dtd9UUuJd8pKKdwh6MLm3MUMiqMPmhZ3tTSXPqfyQ3vDl6R5hZdZ/kYojK4ofXtdfSv1tFq8XzWx3heNQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.28.2.tgz", + "integrity": "sha512-GeXCej4IQtU1B+QlDV8W/RRvbzI3O/Stss+/bCXv4lZls5WGRtu2a+3JkA3i4qIUlMXpcHebWpF8AkJhATowuA==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.28.2.tgz", + "integrity": "sha512-3H1weTYZPxt/WOhByszQZybS9w5lKzUn1FDMsgEChbHWQwHYQQRfBxgCcZvPhjHfKyJjIievvMmEUawJrdY9Dg==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.28.2.tgz", + "integrity": "sha512-4xTZr1FUmSoQW4XIWmit3tzQrUTZM+N3P0XV8xROKYF50XfI7xeO90+1bZvNwxIufQ9hDQVRJH5YhgPVF8A/HQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.28.2.tgz", + "integrity": "sha512-sSATRjPeDBg3pdgHoQfoYBob11Kk1FGa9lui5RIHZCoCkJa9QKlvl3/vKz2usCmYYjs7ymJR/2Nnsqe+Hjt5nw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.28.2.tgz", + "integrity": "sha512-lqnzCV+mM0gIADaKihiCg6ifgfU2L3h5E33rNQBN1Y4MaVGnzryzmvvf7UHxprpQdE8hpqLolJ9Rl+SkIRDpyw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.28.2.tgz", + "integrity": "sha512-AL2qJILH7lNjrDmCQDvdxMfAUIv8KMNZOvrwAQ8i8//ntL9FflhOyMJ8OZSMBb8/AWXe3/5v5S20y3zCoZWKoQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.28.2.tgz", + "integrity": "sha512-QtiuPytchRyC4rwUKhexJdQKvDuZ6hWloi3igqPQNUJCS1/v9EiO3UTOXR6A3FoMo4fnAKbWJdqaIwhOzh8qEw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openharmony-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.28.2.tgz", + "integrity": "sha512-WkhYDmpTjLvGlScA1rwjRUmhl4k8oXR3cIbtqWmELgU/dFeHHlEllxDvdWcNJV9rbzCexB5vz8gtNewWLgCT7Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.28.2.tgz", + "integrity": "sha512-GPMSkTOtMnv2U2F8gxe4Io6qmVs+YKyp832Etqqxr0hFngmXQ3rzwytelm3GIn7T4VviRUlf3sOgBOiTdvaf7g==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.28.2.tgz", + "integrity": "sha512-PIhhEkE9uPBleRBrQEJpUn7MBnibZzbGzYWPmY3x+YoVg/95zbjB4CxPPOQ8l5tYYM4mMaCthF8/1DIfBQQyWQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.28.2.tgz", + "integrity": "sha512-YmJbfTlvU7Sdn9BB+4PRES4oB6pxgS37MAONj+hBr/cpXS1aBPKXxNnDbu+QCWPj0o9dgyxeq79g6c5P8KeuYA==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.28.2.tgz", + "integrity": "sha512-5ebpxr3nWMzrL/rnUI755Jkuee0bHL/Gq0WTF9lvcpv73wAp5eu8MfBUgWK9bhWvZjj7yX8etf/8tI8Ney695g==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@ionic/cli-framework-output": { + "version": "2.2.8", + "resolved": "https://registry.npmjs.org/@ionic/cli-framework-output/-/cli-framework-output-2.2.8.tgz", + "integrity": "sha512-TshtaFQsovB4NWRBydbNFawql6yul7d5bMiW1WYYf17hd99V6xdDdk3vtF51bw6sLkxON3bDQpWsnUc9/hVo3g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@ionic/utils-terminal": "2.3.5", + "debug": "^4.0.0", + "tslib": "^2.0.1" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/@ionic/utils-array": { + "version": "2.1.6", + "resolved": "https://registry.npmjs.org/@ionic/utils-array/-/utils-array-2.1.6.tgz", + "integrity": "sha512-0JZ1Zkp3wURnv8oq6Qt7fMPo5MpjbLoUoa9Bu2Q4PJuSDWM8H8gwF3dQO7VTeUj3/0o1IB1wGkFWZZYgUXZMUg==", + "dev": true, + "license": "MIT", + "dependencies": { + "debug": "^4.0.0", + "tslib": "^2.0.1" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/@ionic/utils-fs": { + "version": "3.1.7", + "resolved": "https://registry.npmjs.org/@ionic/utils-fs/-/utils-fs-3.1.7.tgz", + "integrity": "sha512-2EknRvMVfhnyhL1VhFkSLa5gOcycK91VnjfrTB0kbqkTFCOXyXgVLI5whzq7SLrgD9t1aqos3lMMQyVzaQ5gVA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/fs-extra": "^8.0.0", + "debug": "^4.0.0", + "fs-extra": "^9.0.0", + "tslib": "^2.0.1" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/@ionic/utils-fs/node_modules/@types/fs-extra": { + "version": "8.1.5", + "resolved": "https://registry.npmjs.org/@types/fs-extra/-/fs-extra-8.1.5.tgz", + "integrity": "sha512-0dzKcwO+S8s2kuF5Z9oUWatQJj5Uq/iqphEtE3GQJVRRYm/tD1LglU2UnXi2A8jLq5umkGouOXOR9y0n613ZwQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@ionic/utils-fs/node_modules/fs-extra": { + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-9.1.0.tgz", + "integrity": "sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "at-least-node": "^1.0.0", + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@ionic/utils-object": { + "version": "2.1.6", + "resolved": "https://registry.npmjs.org/@ionic/utils-object/-/utils-object-2.1.6.tgz", + "integrity": "sha512-vCl7sl6JjBHFw99CuAqHljYJpcE88YaH2ZW4ELiC/Zwxl5tiwn4kbdP/gxi2OT3MQb1vOtgAmSNRtusvgxI8ww==", + "dev": true, + "license": "MIT", + "dependencies": { + "debug": "^4.0.0", + "tslib": "^2.0.1" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/@ionic/utils-process": { + "version": "2.1.12", + "resolved": "https://registry.npmjs.org/@ionic/utils-process/-/utils-process-2.1.12.tgz", + "integrity": "sha512-Jqkgyq7zBs/v/J3YvKtQQiIcxfJyplPgECMWgdO0E1fKrrH8EF0QGHNJ9mJCn6PYe2UtHNS8JJf5G21e09DfYg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@ionic/utils-object": "2.1.6", + "@ionic/utils-terminal": "2.3.5", + "debug": "^4.0.0", + "signal-exit": "^3.0.3", + "tree-kill": "^1.2.2", + "tslib": "^2.0.1" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/@ionic/utils-stream": { + "version": "3.1.7", + "resolved": "https://registry.npmjs.org/@ionic/utils-stream/-/utils-stream-3.1.7.tgz", + "integrity": "sha512-eSELBE7NWNFIHTbTC2jiMvh1ABKGIpGdUIvARsNPMNQhxJB3wpwdiVnoBoTYp+5a6UUIww4Kpg7v6S7iTctH1w==", + "dev": true, + "license": "MIT", + "dependencies": { + "debug": "^4.0.0", + "tslib": "^2.0.1" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/@ionic/utils-subprocess": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/@ionic/utils-subprocess/-/utils-subprocess-3.0.1.tgz", + "integrity": "sha512-cT4te3AQQPeIM9WCwIg8ohroJ8TjsYaMb2G4ZEgv9YzeDqHZ4JpeIKqG2SoaA3GmVQ3sOfhPM6Ox9sxphV/d1A==", + "dev": true, + "license": "MIT", + "dependencies": { + "@ionic/utils-array": "2.1.6", + "@ionic/utils-fs": "3.1.7", + "@ionic/utils-process": "2.1.12", + "@ionic/utils-stream": "3.1.7", + "@ionic/utils-terminal": "2.3.5", + "cross-spawn": "^7.0.3", + "debug": "^4.0.0", + "tslib": "^2.0.1" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/@ionic/utils-terminal": { + "version": "2.3.5", + "resolved": "https://registry.npmjs.org/@ionic/utils-terminal/-/utils-terminal-2.3.5.tgz", + "integrity": "sha512-3cKScz9Jx2/Pr9ijj1OzGlBDfcmx7OMVBt4+P1uRR0SSW4cm1/y3Mo4OY3lfkuaYifMNBW8Wz6lQHbs1bihr7A==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/slice-ansi": "^4.0.0", + "debug": "^4.0.0", + "signal-exit": "^3.0.3", + "slice-ansi": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0", + "tslib": "^2.0.1", + "untildify": "^4.0.0", + "wrap-ansi": "^7.0.0" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/@isaacs/fs-minipass": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@isaacs/fs-minipass/-/fs-minipass-4.0.1.tgz", + "integrity": "sha512-wgm9Ehl2jpeqP3zw/7mo3kRHFp5MEDhqAdwy1fTGkHAwnkGOVsgpvQhL8B5n1qlb01jV3n/bI0ZfZp5lWA1k4w==", + "dev": true, + "license": "ISC", + "dependencies": { + "minipass": "^7.0.4" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@malept/cross-spawn-promise": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@malept/cross-spawn-promise/-/cross-spawn-promise-2.0.0.tgz", + "integrity": "sha512-1DpKU0Z5ThltBwjNySMC14g0CkbyhCaz9FkhxqNsZI6uAPJXFS8cMXlBKo26FJ8ZuW6S9GCMcR9IO5k2X5/9Fg==", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/malept" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/subscription/pkg/npm-.malept-cross-spawn-promise?utm_medium=referral&utm_source=npm_fund" + } + ], + "license": "Apache-2.0", + "dependencies": { + "cross-spawn": "^7.0.1" + }, + "engines": { + "node": ">= 12.13.0" + } + }, + "node_modules/@malept/flatpak-bundler": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/@malept/flatpak-bundler/-/flatpak-bundler-0.4.0.tgz", + "integrity": "sha512-9QOtNffcOF/c1seMCDnjckb3R9WHcG34tky+FHpNKKCW0wc/scYLwMtO+ptyGUfMW0/b/n4qRiALlaFHc9Oj7Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "debug": "^4.1.1", + "fs-extra": "^9.0.0", + "lodash": "^4.17.15", + "tmp-promise": "^3.0.2" + }, + "engines": { + "node": ">= 10.0.0" + } + }, + "node_modules/@malept/flatpak-bundler/node_modules/fs-extra": { + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-9.1.0.tgz", + "integrity": "sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "at-least-node": "^1.0.0", + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@noble/hashes": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.8.0.tgz", + "integrity": "sha512-jCs9ldd7NwzpgXDIf6P3+NrHh9/sD6CQdxHyjQI+h/6rDNo88ypBxxz45UDuZHz9r3tNz7N/VInSVoVdtXEI4A==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^14.21.3 || >=16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@peculiar/asn1-schema": { + "version": "2.10.0", + "resolved": "https://registry.npmjs.org/@peculiar/asn1-schema/-/asn1-schema-2.10.0.tgz", + "integrity": "sha512-GhokD41lV4gQrrLYm3wCkHfBOnJrnhDMgt4XeMW8gzfE1UdJqIuSwsE+ggf82XBjUXRJylcm+KIGQFa4utIVLw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@peculiar/utils": "^2.0.2", + "asn1js": "^3.0.10", + "tslib": "^2.8.1" + }, + "engines": { + "node": ">=14" + } + }, + "node_modules/@peculiar/json-schema": { + "version": "1.1.12", + "resolved": "https://registry.npmjs.org/@peculiar/json-schema/-/json-schema-1.1.12.tgz", + "integrity": "sha512-coUfuoMeIB7B8/NMekxaDzLhaYmp0HZNPEjYRm9goRou8UZIC3z21s0sL9AWoCw4EG876QyO3kYrc61WNF9B/w==", + "dev": true, + "license": "MIT", + "dependencies": { + "tslib": "^2.0.0" + }, + "engines": { + "node": ">=8.0.0" + } + }, + "node_modules/@peculiar/utils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/@peculiar/utils/-/utils-2.0.3.tgz", + "integrity": "sha512-+oL3HPFRIZ1St2K50lWCXiioIgSoxzz7R1J3uF6neO2yl1sgmpgY6XXJH4BdpoDkMWznQTeYF6oWNDZLCdQ4eQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "tslib": "^2.8.1" + } + }, + "node_modules/@peculiar/webcrypto": { + "version": "1.7.1", + "resolved": "https://registry.npmjs.org/@peculiar/webcrypto/-/webcrypto-1.7.1.tgz", + "integrity": "sha512-ODOov0sGMJMf3jPonOkgGqPknTsu+DdQ7kD++gz8aI+aFMOMHFbWAA2taqXXVTdP+OTOQR/znGvSpmkeI0WTYQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@peculiar/asn1-schema": "^2.7.0", + "@peculiar/json-schema": "^1.1.12", + "@peculiar/utils": "^2.0.2", + "tslib": "^2.8.1", + "webcrypto-core": "^1.9.2" + }, + "engines": { + "node": ">=14.18.0" + } + }, + "node_modules/@pinojs/redact": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/@pinojs/redact/-/redact-0.4.0.tgz", + "integrity": "sha512-k2ENnmBugE/rzQfEcdWHcCY+/FM3VLzH9cYEsbdsoqrvzAKRhUZeRNhAZvB8OitQJ1TBed3yqWtdjzS6wJKBwg==", + "license": "MIT" + }, + "node_modules/@selderee/plugin-htmlparser2": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/@selderee/plugin-htmlparser2/-/plugin-htmlparser2-0.12.0.tgz", + "integrity": "sha512-oELmoyA6ML9jDRMV3kgcMQFKxUfBU0yFVn6yTctVaLT5ygXnxH52I3TZEgV9EhXJC68/uFvE5Daj1/25c0Xa/A==", + "license": "MIT", + "dependencies": { + "domelementtype": "~2.3.0", + "domhandler": "~5.0.3" + }, + "funding": { + "url": "https://github.com/sponsors/KillyMXI" + }, + "peerDependencies": { + "selderee": "~0.12.0" + } + }, + "node_modules/@sindresorhus/is": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-4.6.0.tgz", + "integrity": "sha512-t09vSN3MdfsyCHoFcTRCH/iUtG7OJ0CsjzB8cjAmKc/va/kIgeDI/TxsigdncE/4be734m0cvIYwNaV4i2XqAw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sindresorhus/is?sponsor=1" + } + }, + "node_modules/@szmarczak/http-timer": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/@szmarczak/http-timer/-/http-timer-4.0.6.tgz", + "integrity": "sha512-4BAffykYOgO+5nzBWYwE3W90sBgLJoUPRWWcL8wlyiM8IB8ipJz3UMJ9KXQd1RKQXpKp8Tutn80HZtWsu2u76w==", + "dev": true, + "license": "MIT", + "dependencies": { + "defer-to-connect": "^2.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@types/cacheable-request": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/@types/cacheable-request/-/cacheable-request-6.0.3.tgz", + "integrity": "sha512-IQ3EbTzGxIigb1I3qPZc1rWJnH0BmSKv5QYTalEwweFvyBDLSAe24zP0le/hyi7ecGfZVlIVAg4BZqb8WBwKqw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/http-cache-semantics": "*", + "@types/keyv": "^3.1.4", + "@types/node": "*", + "@types/responselike": "^1.0.0" + } + }, + "node_modules/@types/debug": { + "version": "4.1.13", + "resolved": "https://registry.npmjs.org/@types/debug/-/debug-4.1.13.tgz", + "integrity": "sha512-KSVgmQmzMwPlmtljOomayoR89W4FynCAi3E8PPs7vmDVPe84hT+vGPKkJfThkmXs0x0jAaa9U8uW8bbfyS2fWw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/ms": "*" + } + }, + "node_modules/@types/fs-extra": { + "version": "9.0.13", + "resolved": "https://registry.npmjs.org/@types/fs-extra/-/fs-extra-9.0.13.tgz", + "integrity": "sha512-nEnwB++1u5lVDM2UI4c1+5R+FYaKfaAzS4OococimjVm3nQw3TuzH5UNsocrcTBbhnerblyHj4A49qXbIiZdpA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/http-cache-semantics": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/@types/http-cache-semantics/-/http-cache-semantics-4.2.0.tgz", + "integrity": "sha512-L3LgimLHXtGkWikKnsPg0/VFx9OGZaC+eN1u4r+OB1XRqH3meBIAVC2zr1WdMH+RHmnRkqliQAOHNJ/E0j/e0Q==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/keyv": { + "version": "3.1.4", + "resolved": "https://registry.npmjs.org/@types/keyv/-/keyv-3.1.4.tgz", + "integrity": "sha512-BQ5aZNSCpj7D6K2ksrRCTmKRLEpnPvWDiLPfoGyhZ++8YtiK9d/3DBKPJgry359X/P1PfruyYwvnvwFjuEiEIg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/ms": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/@types/ms/-/ms-2.1.0.tgz", + "integrity": "sha512-GsCCIZDE/p3i96vtEqx+7dBUGXrc7zeSK3wwPHIaRThS+9OhWIXRqzs4d6k1SVU8g91DrNRWxWUGhp5KXQb2VA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/node": { + "version": "24.19.1", + "resolved": "https://registry.npmjs.org/@types/node/-/node-24.19.1.tgz", + "integrity": "sha512-aS3/DG0oM05K0RIXXP+hKjinGG5IgSSVGzswZxW3O0sS3pH4/fycXundUC9XsszgKCk4gHXylTEK6hyFxVxnoQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": ">=7.24.0 <7.24.7" + } + }, + "node_modules/@types/responselike": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@types/responselike/-/responselike-1.0.3.tgz", + "integrity": "sha512-H/+L+UkTV33uf49PH5pCAUBVPNj2nDBXTN+qS1dOwyyg24l3CcicicCA7ca+HMvJBZcFgl5r8e+RR6elsb4Lyw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/slice-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@types/slice-ansi/-/slice-ansi-4.0.0.tgz", + "integrity": "sha512-+OpjSaq85gvlZAYINyzKpLeiFkSC4EsC6IIiT6v6TLSU5k5U83fHGj9Lel8oKEXM0HqgrMVCjXPDPVICtxF7EQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/@xmldom/xmldom": { + "version": "0.8.15", + "resolved": "https://registry.npmjs.org/@xmldom/xmldom/-/xmldom-0.8.15.tgz", + "integrity": "sha512-/5NV/vDALVFDXgLmfsy9TRCBlKwO2LNBFzpzvb9iIj+jR+eSc6DLYYvVOdivT/jm7MtU6TebYuRmzEOI7w40UA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10.0.0" + } + }, + "node_modules/@zone-eu/mailsplit": { + "version": "5.4.19", + "resolved": "https://registry.npmjs.org/@zone-eu/mailsplit/-/mailsplit-5.4.19.tgz", + "integrity": "sha512-nDWzw+X3tqfwd7DpDThAjg3KqtrNA6bG2gkrf6m2j1JBaGyyKAZzu1TguzB4GEco+HYpXAbXZ7kbl4Sn8H1vXw==", + "license": "(MIT OR EUPL-1.1+)", + "dependencies": { + "libbase64": "1.3.1", + "libmime": "5.4.6", + "libqp": "2.1.2" + } + }, + "node_modules/abbrev": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-4.0.0.tgz", + "integrity": "sha512-a1wflyaL0tHtJSmLSOVybYhy22vRih4eduhhrkcjgrWGnRfrZtovJ2FRjxuTtkkj47O/baf0R86QU5OuYpz8fA==", + "dev": true, + "license": "ISC", + "engines": { + "node": "^20.17.0 || >=22.9.0" + } + }, + "node_modules/agent-base": { + "version": "7.1.4", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.4.tgz", + "integrity": "sha512-MnA+YT8fwfJPgBx3m60MNqakm30XOkyIoH1y6huTQvC0PwZG7ki8NacLBcrPbNoo8vEZy7Jpuk7+jMO+CUovTQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 14" + } + }, + "node_modules/ajv": { + "version": "8.20.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.20.0.tgz", + "integrity": "sha512-Thbli+OlOj+iMPYFBVBfJ3OmCAnaSyNn4M1vz9T6Gka5Jt9ba/HIR56joy65tY6kx/FCF5VXNB819Y7/GUrBGA==", + "dev": true, + "license": "MIT", + "dependencies": { + "fast-deep-equal": "^3.1.3", + "fast-uri": "^3.0.1", + "json-schema-traverse": "^1.0.0", + "require-from-string": "^2.0.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/app-builder-lib": { + "version": "26.17.0", + "resolved": "https://registry.npmjs.org/app-builder-lib/-/app-builder-lib-26.17.0.tgz", + "integrity": "sha512-wfL7EhujuODDW3uMSD8RPcr/MLzmT0dmpVfWV0wFUWXI0rIdaukzAJ7EFUSyHXOpxuBZqaIGlQt6VeQhtHhetw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@electron/asar": "3.4.1", + "@electron/fuses": "^1.8.0", + "@electron/get": "^3.0.0", + "@electron/notarize": "2.5.0", + "@electron/osx-sign": "1.3.3", + "@electron/rebuild": "^4.0.4", + "@electron/universal": "2.0.3", + "@malept/flatpak-bundler": "^0.4.0", + "@noble/hashes": "^1.8.0", + "@peculiar/webcrypto": "^1.7.1", + "@types/fs-extra": "9.0.13", + "ajv": "^8.18.0", + "asn1js": "^3.0.10", + "async-exit-hook": "^2.0.1", + "builder-util": "26.16.0", + "builder-util-runtime": "9.7.0", + "chromium-pickle-js": "^0.2.0", + "ci-info": "4.3.1", + "debug": "^4.3.4", + "dotenv": "^16.4.5", + "dotenv-expand": "^11.0.6", + "ejs": "^3.1.8", + "electron-publish": "26.16.0", + "fs-extra": "^10.1.0", + "hosted-git-info": "^4.1.0", + "isbinaryfile": "^5.0.0", + "jiti": "^2.4.2", + "js-yaml": "^4.1.0", + "json5": "^2.2.3", + "lazy-val": "^1.0.5", + "minimatch": "^10.2.5", + "pkijs": "^3.4.0", + "plist": "3.1.0", + "proper-lockfile": "^4.1.2", + "resedit": "^1.7.0", + "semver": "~7.7.3", + "tar": "^7.5.7", + "temp-file": "^3.4.0", + "tiny-async-pool": "1.3.0", + "unzipper": "^0.12.3", + "which": "^5.0.0" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "dmg-builder": "26.17.0", + "electron-builder-squirrel-windows": "26.17.0" + } + }, + "node_modules/app-builder-lib/node_modules/@electron/get": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@electron/get/-/get-3.1.0.tgz", + "integrity": "sha512-F+nKc0xW+kVbBRhFzaMgPy3KwmuNTYX1fx6+FxxoSnNgwYX6LD7AKBTWkU0MQ6IBoe7dz069CNkR673sPAgkCQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "debug": "^4.1.1", + "env-paths": "^2.2.0", + "fs-extra": "^8.1.0", + "got": "^11.8.5", + "progress": "^2.0.3", + "semver": "^6.2.0", + "sumchecker": "^3.0.1" + }, + "engines": { + "node": ">=14" + }, + "optionalDependencies": { + "global-agent": "^3.0.0" + } + }, + "node_modules/app-builder-lib/node_modules/@electron/get/node_modules/fs-extra": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", + "integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==", + "dev": true, + "license": "MIT", + "dependencies": { + "graceful-fs": "^4.2.0", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" + }, + "engines": { + "node": ">=6 <7 || >=8" + } + }, + "node_modules/app-builder-lib/node_modules/@electron/get/node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/app-builder-lib/node_modules/ci-info": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-4.3.1.tgz", + "integrity": "sha512-Wdy2Igu8OcBpI2pZePZ5oWjPC38tmDVx5WKUXKwlLYkA0ozo85sLsLvkBbBn/sZaSCMFOGZJ14fvW9t5/d7kdA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/sibiraj-s" + } + ], + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/app-builder-lib/node_modules/env-paths": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/env-paths/-/env-paths-2.2.1.tgz", + "integrity": "sha512-+h1lkLKhZMTYjog1VEpJNG7NZJWcuc2DDk/qsqSTRRCOXiLjeQ1d1/udrUGhqMxUgAlwKNZ0cf2uqan5GLuS2A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/app-builder-lib/node_modules/jsonfile": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", + "integrity": "sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==", + "dev": true, + "license": "MIT", + "optionalDependencies": { + "graceful-fs": "^4.1.6" + } + }, + "node_modules/app-builder-lib/node_modules/semver": { + "version": "7.7.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.4.tgz", + "integrity": "sha512-vFKC2IEtQnVhpT78h1Yp8wzwrf8CM+MzKMHGJZfBtzhZNycRFnXsHk6E5TxIkkMsgNS7mdX3AGB7x2QM2di4lA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/app-builder-lib/node_modules/universalify": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", + "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 4.0.0" + } + }, + "node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "dev": true, + "license": "Python-2.0" + }, + "node_modules/asn1js": { + "version": "3.0.10", + "resolved": "https://registry.npmjs.org/asn1js/-/asn1js-3.0.10.tgz", + "integrity": "sha512-S2s3aOytiKdFRdulw2qPE51MzjzVOisppcVv7jVFR+Kw0kxwvFrDcYA0h7Ndqbmj0HkMIXYWaoj7fli8kgx1eg==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "pvtsutils": "^1.3.6", + "pvutils": "^1.1.5", + "tslib": "^2.8.1" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/astral-regex": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/astral-regex/-/astral-regex-2.0.0.tgz", + "integrity": "sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/async": { + "version": "3.2.6", + "resolved": "https://registry.npmjs.org/async/-/async-3.2.6.tgz", + "integrity": "sha512-htCUDlxyyCLMgaM3xXg0C0LW2xqfuQ6p05pCEIsXuyQ+a1koYKTuBMzRNwmybfLgvJDMd0r1LTn4+E0Ti6C2AA==", + "dev": true, + "license": "MIT" + }, + "node_modules/async-exit-hook": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/async-exit-hook/-/async-exit-hook-2.0.1.tgz", + "integrity": "sha512-NW2cX8m1Q7KPA7a5M2ULQeZ2wR5qI5PAbw5L0UOMxdioVk9PMZ0h1TmyZEkPYrCvYjDlFICusOu1dlEKAAeXBw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", + "dev": true, + "license": "MIT" + }, + "node_modules/at-least-node": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/at-least-node/-/at-least-node-1.0.0.tgz", + "integrity": "sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">= 4.0.0" + } + }, + "node_modules/atomic-sleep": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/atomic-sleep/-/atomic-sleep-1.0.0.tgz", + "integrity": "sha512-kNOjDqAh7px0XWNI+4QbzoiR/nTkHAWNud2uvnJquD1/x5a7EQZMJT0AczqK0Qn67oY/TTQ1LbUKajZpp3I9tQ==", + "license": "MIT", + "engines": { + "node": ">=8.0.0" + } + }, + "node_modules/aws4": { + "version": "1.13.2", + "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.13.2.tgz", + "integrity": "sha512-lHe62zvbTB5eEABUVi/AwVh0ZKY9rMMDhmm+eeyuuUQbQ3+J+fONVQOZyj+DdrvD4BY33uYniyRJ4UJIaSKAfw==", + "dev": true, + "license": "MIT" + }, + "node_modules/balanced-match": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz", + "integrity": "sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==", + "dev": true, + "license": "MIT", + "engines": { + "node": "18 || 20 || >=22" + } + }, + "node_modules/base64-js": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "node_modules/big-integer": { + "version": "1.6.52", + "resolved": "https://registry.npmjs.org/big-integer/-/big-integer-1.6.52.tgz", + "integrity": "sha512-QxD8cf2eVqJOOz63z6JIN9BzvVs/dlySa5HGSBH5xtR8dPteIRQnBxxKqkNTiT6jbDTF6jAfrd4oMcND9RGbQg==", + "dev": true, + "license": "Unlicense", + "engines": { + "node": ">=0.6" + } + }, + "node_modules/bluebird": { + "version": "3.7.2", + "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz", + "integrity": "sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==", + "dev": true, + "license": "MIT" + }, + "node_modules/boolean": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/boolean/-/boolean-3.2.0.tgz", + "integrity": "sha512-d0II/GO9uf9lfUHH2BQsjxzRJZBdsjgsBiW4BvhWk/3qoKwQFjIDVN19PfX8F2D/r9PCMTtLWjYVCFrpeYUzsw==", + "deprecated": "Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.", + "dev": true, + "license": "MIT", + "optional": true + }, + "node_modules/bplist-creator": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/bplist-creator/-/bplist-creator-0.1.0.tgz", + "integrity": "sha512-sXaHZicyEEmY86WyueLTQesbeoH/mquvarJaQNbjuOQO+7gbFcDEWqKmcWA4cOTLzFlfgvkiVxolk1k5bBIpmg==", + "dev": true, + "license": "MIT", + "dependencies": { + "stream-buffers": "2.2.x" + } + }, + "node_modules/bplist-parser": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/bplist-parser/-/bplist-parser-0.3.2.tgz", + "integrity": "sha512-apC2+fspHGI3mMKj+dGevkGo/tCqVB8jMb6i+OX+E29p0Iposz07fABkRIfVUPNd5A5VbuOz1bZbnmkKLYF+wQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "big-integer": "1.6.x" + }, + "engines": { + "node": ">= 5.10.0" + } + }, + "node_modules/brace-expansion": { + "version": "5.0.12", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.12.tgz", + "integrity": "sha512-YovQ3rzhaLMIrDjNDMkNS01tea93qhEhG5xy8f6+R0l+dw3Ki+5sCoIoI942iuLZTHWogWktgwVDhU09iNEimQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^4.0.2" + }, + "engines": { + "node": "20 || >=22" + } + }, + "node_modules/buffer-crc32": { + "version": "0.2.13", + "resolved": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.13.tgz", + "integrity": "sha512-VO9Ht/+p3SN7SKWqcrgEzjGbRSJYTx+Q1pTQC0wrWqHx0vpJraQ6GtHx8tvcg1rlK1byhU5gccxgOgj7B0TDkQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": "*" + } + }, + "node_modules/buffer-from": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", + "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/builder-util": { + "version": "26.16.0", + "resolved": "https://registry.npmjs.org/builder-util/-/builder-util-26.16.0.tgz", + "integrity": "sha512-RLyJhB7Si3YkzKR9ubQslWuXW3Vhs3CGe1i+SeixBZ0qTd1mk3XBmssvY22TlB6CS5blyko8Gu1JzpYk8UkYAg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/debug": "^4.1.6", + "builder-util-runtime": "9.7.0", + "chalk": "^4.1.2", + "cross-spawn": "^7.0.6", + "debug": "^4.3.4", + "fs-extra": "^10.1.0", + "http-proxy-agent": "^7.0.0", + "https-proxy-agent": "^7.0.0", + "js-yaml": "^4.1.0", + "sanitize-filename": "^1.6.3", + "source-map-support": "^0.5.19", + "stat-mode": "^1.0.0", + "temp-file": "^3.4.0", + "tiny-async-pool": "1.3.0" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/builder-util-runtime": { + "version": "9.7.0", + "resolved": "https://registry.npmjs.org/builder-util-runtime/-/builder-util-runtime-9.7.0.tgz", + "integrity": "sha512-g/kR520giAFYkSXTzcmF3kqQq7wi8F6N6SzeDgZrqTBN+VHdmgWOyTdD1yD7AATDId/yXLvuP34CxW46/BwCdw==", + "dev": true, + "license": "MIT", + "dependencies": { + "debug": "^4.3.4", + "sax": "^1.2.4" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/bytestreamjs": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/bytestreamjs/-/bytestreamjs-2.0.1.tgz", + "integrity": "sha512-U1Z/ob71V/bXfVABvNr/Kumf5VyeQRBEm6Txb0PQ6S7V5GpBM3w4Cbqz/xPDicR5tN0uvDifng8C+5qECeGwyQ==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/cacheable-lookup": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/cacheable-lookup/-/cacheable-lookup-5.0.4.tgz", + "integrity": "sha512-2/kNscPhpcxrOigMZzbiWF7dz8ilhb/nIHU3EyZiXWXpeq/au8qJ8VhdftMkty3n7Gj6HIGalQG8oiBNB3AJgA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10.6.0" + } + }, + "node_modules/cacheable-request": { + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/cacheable-request/-/cacheable-request-7.0.4.tgz", + "integrity": "sha512-v+p6ongsrp0yTGbJXjgxPow2+DL93DASP4kXCDKb8/bwRtt9OEF3whggkkDkGNzgcWy2XaF4a8nZglC7uElscg==", + "dev": true, + "license": "MIT", + "dependencies": { + "clone-response": "^1.0.2", + "get-stream": "^5.1.0", + "http-cache-semantics": "^4.0.0", + "keyv": "^4.0.0", + "lowercase-keys": "^2.0.0", + "normalize-url": "^6.0.1", + "responselike": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/call-bind-apply-helpers": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz", + "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/chownr": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-3.0.0.tgz", + "integrity": "sha512-+IxzY9BZOQd/XuYPRmrvEVjF/nqj5kgT4kEq7VofrDoM1MxoRjEWkrCC3EtLi59TVawxTAn+orJwFQcrqEN1+g==", + "dev": true, + "license": "BlueOak-1.0.0", + "engines": { + "node": ">=18" + } + }, + "node_modules/chromium-pickle-js": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/chromium-pickle-js/-/chromium-pickle-js-0.2.0.tgz", + "integrity": "sha512-1R5Fho+jBq0DDydt+/vHWj5KJNJCKdARKOCwZUen84I5BreWoLqRLANH1U87eJy1tiASPtMnGqJJq0ZsLoRPOw==", + "dev": true, + "license": "MIT" + }, + "node_modules/ci-info": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-4.4.0.tgz", + "integrity": "sha512-77PSwercCZU2Fc4sX94eF8k8Pxte6JAwL4/ICZLFjJLqegs7kCuAsqqj/70NQF6TvDpgFjkubQB2FW2ZZddvQg==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/sibiraj-s" + } + ], + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/cliui": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", + "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", + "dev": true, + "license": "ISC", + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.1", + "wrap-ansi": "^7.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/clone-response": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/clone-response/-/clone-response-1.0.3.tgz", + "integrity": "sha512-ROoL94jJH2dUVML2Y/5PEDNaSHgeOdSDicUyS7izcF63G6sTc/FTjLub4b8Il9S8S0beOfYt0TaA5qvFK+w0wA==", + "dev": true, + "license": "MIT", + "dependencies": { + "mimic-response": "^1.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true, + "license": "MIT" + }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "dev": true, + "license": "MIT", + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/commander": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-5.1.0.tgz", + "integrity": "sha512-P0CysNDQ7rtVw4QIQtm+MRxV66vKFSvlsQvGYXZWR3qFU0jlMKHZZZgw8e+8DSah4UDKMqnknRDQz+xuQXQ/Zg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 6" + } + }, + "node_modules/compare-version": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/compare-version/-/compare-version-0.1.2.tgz", + "integrity": "sha512-pJDh5/4wrEnXX/VWRZvruAGHkzKdr46z11OlTPN+VrATlWWhSKewNCJ1futCO5C7eJB3nPMFZA1LeYtcFboZ2A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", + "dev": true, + "license": "MIT" + }, + "node_modules/core-util-is": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", + "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/cross-dirname": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/cross-dirname/-/cross-dirname-0.1.0.tgz", + "integrity": "sha512-+R08/oI0nl3vfPcqftZRpytksBXDzOUveBq/NBVx0sUp1axwzPQrKinNx5yd5sxPu8j1wIy8AfnVQ+5eFdha6Q==", + "dev": true, + "license": "MIT", + "optional": true, + "peer": true + }, + "node_modules/cross-spawn": { + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", + "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", + "dev": true, + "license": "MIT", + "dependencies": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/cross-spawn/node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "dev": true, + "license": "ISC" + }, + "node_modules/cross-spawn/node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "license": "ISC", + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/debug": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/decompress-response": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz", + "integrity": "sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "mimic-response": "^3.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/decompress-response/node_modules/mimic-response": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz", + "integrity": "sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/deepmerge-ts": { + "version": "8.0.2", + "resolved": "https://registry.npmjs.org/deepmerge-ts/-/deepmerge-ts-8.0.2.tgz", + "integrity": "sha512-uqbvqLUMrc6p0MO+WBRtTxY55hmyh94WRwI5a++PZe54X+bfVh59FSN7uWCBCW1CCVjzjnrwzfI8zidE2obMMw==", + "funding": [ + { + "type": "ko-fi", + "url": "https://ko-fi.com/rebeccastevens" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/deepmerge-ts" + } + ], + "license": "BSD-3-Clause", + "engines": { + "node": ">=16.9.0" + } + }, + "node_modules/defer-to-connect": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/defer-to-connect/-/defer-to-connect-2.0.1.tgz", + "integrity": "sha512-4tvttepXG1VaYGrRibk5EwJd1t4udunSOVMdLSAL6mId1ix438oPwPZMALY41FCijukO1L0twNcGsdzS7dHgDg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + } + }, + "node_modules/define-data-property": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.4.tgz", + "integrity": "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "es-define-property": "^1.0.0", + "es-errors": "^1.3.0", + "gopd": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/define-lazy-prop": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/define-lazy-prop/-/define-lazy-prop-2.0.0.tgz", + "integrity": "sha512-Ds09qNh8yw3khSjiJjiUInaGX9xlqZDY7JVryGxdxV7NPeuqQfplOpQ66yJFZut3jLa5zOwkXw1g9EI2uKh4Og==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/define-properties": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.2.1.tgz", + "integrity": "sha512-8QmQKqEASLd5nx0U1B1okLElbUuuttJ/AnYmRXbbbGDWh6uS208EjD4Xqq/I9wK7u0v6O08XhTWnt5XtEbR6Dg==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "define-data-property": "^1.0.1", + "has-property-descriptors": "^1.0.0", + "object-keys": "^1.1.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/detect-node": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/detect-node/-/detect-node-2.1.0.tgz", + "integrity": "sha512-T0NIuQpnTvFDATNuHN5roPwSBG83rFsuO+MXXH9/3N1eFbn4wcPjttvjMLEPWJ0RGUYgQE7cGgS3tNxbqCGM7g==", + "dev": true, + "license": "MIT", + "optional": true + }, + "node_modules/dir-compare": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/dir-compare/-/dir-compare-4.2.0.tgz", + "integrity": "sha512-2xMCmOoMrdQIPHdsTawECdNPwlVFB9zGcz3kuhmBO6U3oU+UQjsue0i8ayLKpgBcm+hcXPMVSGUN9d+pvJ6+VQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "minimatch": "^3.0.5", + "p-limit": "^3.1.0 " + } + }, + "node_modules/dir-compare/node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true, + "license": "MIT" + }, + "node_modules/dir-compare/node_modules/brace-expansion": { + "version": "1.1.21", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.21.tgz", + "integrity": "sha512-9zeA+KLZNNzglF2TPKRQEDyx6Yby7daAkuy8MiPzpXPsYDWi/DRM8jmwUDxokQjYqBpv5DgPiwD4h4ZZSy1Ujw==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/dir-compare/node_modules/minimatch": { + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.5.tgz", + "integrity": "sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/dmg-builder": { + "version": "26.17.0", + "resolved": "https://registry.npmjs.org/dmg-builder/-/dmg-builder-26.17.0.tgz", + "integrity": "sha512-EAw1f2iGkICmUvAVBOjm7v5mxJdB7/+OZSycHFhKBimiTkCXtvkCC6wBKzHo7ZQYi58C2MmwIleRbgRnROlK2Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "app-builder-lib": "26.17.0", + "builder-util": "26.16.0", + "fs-extra": "^10.1.0", + "js-yaml": "^4.1.0" + } + }, + "node_modules/dom-serializer": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-2.0.0.tgz", + "integrity": "sha512-wIkAryiqt/nV5EQKqQpo3SToSOV9J0DnbJqwK7Wv/Trc92zIAYZ4FlMu+JPFW1DfGFt81ZTCGgDEabffXeLyJg==", + "license": "MIT", + "dependencies": { + "domelementtype": "^2.3.0", + "domhandler": "^5.0.2", + "entities": "^4.2.0" + }, + "funding": { + "url": "https://github.com/cheeriojs/dom-serializer?sponsor=1" + } + }, + "node_modules/domelementtype": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.3.0.tgz", + "integrity": "sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fb55" + } + ], + "license": "BSD-2-Clause" + }, + "node_modules/domhandler": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-5.0.3.tgz", + "integrity": "sha512-cgwlv/1iFQiFnU96XXgROh8xTeetsnJiDsTc7TYCLFd9+/WNkIqPTxiM/8pSd8VIrhXGTf1Ny1q1hquVqDJB5w==", + "license": "BSD-2-Clause", + "dependencies": { + "domelementtype": "^2.3.0" + }, + "engines": { + "node": ">= 4" + }, + "funding": { + "url": "https://github.com/fb55/domhandler?sponsor=1" + } + }, + "node_modules/domutils": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/domutils/-/domutils-3.2.2.tgz", + "integrity": "sha512-6kZKyUajlDuqlHKVX1w7gyslj9MPIXzIFiz/rGu35uC1wMi+kMhQwGhl4lt9unC9Vb9INnY9Z3/ZA3+FhASLaw==", + "license": "BSD-2-Clause", + "dependencies": { + "dom-serializer": "^2.0.0", + "domelementtype": "^2.3.0", + "domhandler": "^5.0.3" + }, + "funding": { + "url": "https://github.com/fb55/domutils?sponsor=1" + } + }, + "node_modules/dotenv": { + "version": "16.6.1", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.6.1.tgz", + "integrity": "sha512-uBq4egWHTcTt33a72vpSG0z3HnPuIl6NqYcTrKEg2azoEyl2hpW0zqlxysq2pK9HlDIHyHyakeYaYnSAwd8bow==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, + "node_modules/dotenv-expand": { + "version": "11.0.7", + "resolved": "https://registry.npmjs.org/dotenv-expand/-/dotenv-expand-11.0.7.tgz", + "integrity": "sha512-zIHwmZPRshsCdpMDyVsqGmgyP0yT8GAgXUnkdAoJisxvf33k7yO6OuoKmcTGuXPWSsm8Oh88nZicRLA9Y0rUeA==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "dotenv": "^16.4.5" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, + "node_modules/dunder-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", + "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.1", + "es-errors": "^1.3.0", + "gopd": "^1.2.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/duplexer2": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.1.4.tgz", + "integrity": "sha512-asLFVfWWtJ90ZyOUHMqk7/S2w2guQKxUI2itj3d92ADHhxUSbCMGi1f1cBcJ7xM1To+pE/Khbwo1yuNbMEPKeA==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "readable-stream": "^2.0.2" + } + }, + "node_modules/ejs": { + "version": "3.1.10", + "resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.10.tgz", + "integrity": "sha512-UeJmFfOrAQS8OJWPZ4qtgHyWExa088/MtK5UEyoJGFH67cDEXkZSviOiKRCZ4Xij0zxI3JECgYs3oKx+AizQBA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "jake": "^10.8.5" + }, + "bin": { + "ejs": "bin/cli.js" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/electron": { + "version": "44.5.1", + "resolved": "https://registry.npmjs.org/electron/-/electron-44.5.1.tgz", + "integrity": "sha512-lx7AYoFIiyvEvgvpyWO9kOC60xtNPpiPZAth6Fmg9NutzpCAMLwpUlaBY2EXfZyIgUdzEmLMj9KvK0Vrokl1yQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@electron-internal/extract-zip": "^1.0.1", + "@electron/get": "^5.0.0", + "@types/node": "^24.9.0" + }, + "bin": { + "electron": "cli.js", + "install-electron": "install.js" + }, + "engines": { + "node": ">= 22.12.0" + } + }, + "node_modules/electron-builder": { + "version": "26.17.0", + "resolved": "https://registry.npmjs.org/electron-builder/-/electron-builder-26.17.0.tgz", + "integrity": "sha512-iYHBRiagS9sDIbZx1ZD113f5rEGQvtpvTvHf70ovHKJ8mRvxwIkWX7JCwfmVQmVS4eX735p7TZmoxHnBPwF3vA==", + "dev": true, + "license": "MIT", + "dependencies": { + "app-builder-lib": "26.17.0", + "builder-util": "26.16.0", + "builder-util-runtime": "9.7.0", + "chalk": "^4.1.2", + "ci-info": "^4.2.0", + "dmg-builder": "26.17.0", + "fs-extra": "^10.1.0", + "lazy-val": "^1.0.5", + "simple-update-notifier": "2.0.0", + "yargs": "^17.6.2" + }, + "bin": { + "electron-builder": "cli.js", + "install-app-deps": "install-app-deps.js" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/electron-builder-squirrel-windows": { + "version": "26.17.0", + "resolved": "https://registry.npmjs.org/electron-builder-squirrel-windows/-/electron-builder-squirrel-windows-26.17.0.tgz", + "integrity": "sha512-uyh+D+B0m12qCRp9c/7dwBirHTh7JcvAzj5eTEbb4dXPPGAhYPx1nozzbu1fC6AdULfat6ZNqgWhipTFpb82lQ==", + "dev": true, + "license": "MIT", + "peer": true, + "dependencies": { + "app-builder-lib": "26.17.0", + "builder-util": "26.16.0", + "electron-winstaller": "5.4.0" + } + }, + "node_modules/electron-publish": { + "version": "26.16.0", + "resolved": "https://registry.npmjs.org/electron-publish/-/electron-publish-26.16.0.tgz", + "integrity": "sha512-Vt3KzQIiw9BImvNOYtndg9Mjki+tl4+1sQiC/+G5j8khWaENOJFWodiB+sUl6yyHwtd37avehskdtPw7f8y/+Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/fs-extra": "^9.0.11", + "aws4": "^1.13.2", + "builder-util": "26.16.0", + "builder-util-runtime": "9.7.0", + "chalk": "^4.1.2", + "form-data": "^4.0.5", + "fs-extra": "^10.1.0", + "lazy-val": "^1.0.5", + "mime": "^2.5.2" + } + }, + "node_modules/electron-winstaller": { + "version": "5.4.0", + "resolved": "https://registry.npmjs.org/electron-winstaller/-/electron-winstaller-5.4.0.tgz", + "integrity": "sha512-bO3y10YikuUwUuDUQRM4KfwNkKhnpVO7IPdbsrejwN9/AABJzzTQ4GeHwyzNSrVO+tEH3/Np255a3sVZpZDjvg==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "peer": true, + "dependencies": { + "@electron/asar": "^3.2.1", + "debug": "^4.1.1", + "fs-extra": "^7.0.1", + "lodash": "^4.17.21", + "temp": "^0.9.0" + }, + "engines": { + "node": ">=8.0.0" + }, + "optionalDependencies": { + "@electron/windows-sign": "^1.1.2" + } + }, + "node_modules/electron-winstaller/node_modules/fs-extra": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-7.0.1.tgz", + "integrity": "sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw==", + "dev": true, + "license": "MIT", + "peer": true, + "dependencies": { + "graceful-fs": "^4.1.2", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" + }, + "engines": { + "node": ">=6 <7 || >=8" + } + }, + "node_modules/electron-winstaller/node_modules/jsonfile": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", + "integrity": "sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==", + "dev": true, + "license": "MIT", + "peer": true, + "optionalDependencies": { + "graceful-fs": "^4.1.6" + } + }, + "node_modules/electron-winstaller/node_modules/universalify": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", + "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", + "dev": true, + "license": "MIT", + "peer": true, + "engines": { + "node": ">= 4.0.0" + } + }, + "node_modules/elementtree": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/elementtree/-/elementtree-0.1.7.tgz", + "integrity": "sha512-wkgGT6kugeQk/P6VZ/f4T+4HB41BVgNBq5CDIZVbQ02nvTVqAiVTbskxxu3eA/X96lMlfYOwnLQpN2v5E1zDEg==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "sax": "1.1.4" + }, + "engines": { + "node": ">= 0.4.0" + } + }, + "node_modules/elementtree/node_modules/sax": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/sax/-/sax-1.1.4.tgz", + "integrity": "sha512-5f3k2PbGGp+YtKJjOItpg3P99IMD84E4HOvcfleTb5joCHNXYLsR9yWFPOYGgaeMPDubQILTCMdsFb2OMeOjtg==", + "dev": true, + "license": "ISC" + }, + "node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true, + "license": "MIT" + }, + "node_modules/encoding-japanese": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/encoding-japanese/-/encoding-japanese-2.4.0.tgz", + "integrity": "sha512-PE0KjlsDy9JSsoU4C2Q8NXb1kC4c+bZRac9ZvHXUE4q1Ht63gScKMdEy9jst9+Fi3M4eDkqzkEhBZvix4blP2A==", + "license": "MIT", + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/end-of-stream": { + "version": "1.4.5", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.5.tgz", + "integrity": "sha512-ooEGc6HP26xXq/N+GCGOT0JKCLDGrq2bQUZrQ7gyrJiZANJ/8YDTxTpQBXGMn+WbIQXNVpyWymm7KYVICQnyOg==", + "dev": true, + "license": "MIT", + "dependencies": { + "once": "^1.4.0" + } + }, + "node_modules/entities": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", + "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==", + "license": "BSD-2-Clause", + "engines": { + "node": ">=0.12" + }, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, + "node_modules/env-paths": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/env-paths/-/env-paths-3.0.0.tgz", + "integrity": "sha512-dtJUTepzMW3Lm/NPxRf3wP4642UWhjL2sQxc+ym2YMj1m/H2zDNQOlezafzkHwn6sMstjHTwG6iQQsctDW/b1A==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/err-code": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/err-code/-/err-code-2.0.3.tgz", + "integrity": "sha512-2bmlRpNKBxT/CRmPOlyISQpNj+qSeYvcym/uT0Jx2bMOlKLtSy1ZmLuVxSEKKyor/N5yhvp/ZiG1oE3DEYMSFA==", + "dev": true, + "license": "MIT" + }, + "node_modules/es-define-property": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", + "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-object-atoms": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.2.tgz", + "integrity": "sha512-HWcBoN6NileqtSydK2FqHbS/LoDd2pqrnQHLyJzBj4kOp/ky2MWMN694xOfkK8/SnUsW2DH7EfyVlydKCsm1Zw==", + "dev": true, + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-set-tostringtag": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.1.0.tgz", + "integrity": "sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==", + "dev": true, + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.6", + "has-tostringtag": "^1.0.2", + "hasown": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es6-error": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/es6-error/-/es6-error-4.1.1.tgz", + "integrity": "sha512-Um/+FxMr9CISWh0bi5Zv0iOD+4cFh5qLeks1qhAopKVAJw3drgKbKySikp7wGhDL0HPeaja0P5ULZrxLkniUVg==", + "dev": true, + "license": "MIT", + "optional": true + }, + "node_modules/esbuild": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.28.2.tgz", + "integrity": "sha512-HKVLS8dvII+xoKW9kmqxbRKrnWEXfJJr/FZhhJmiqIB0e053QNYFqOBouTMO/k5sID4MvCiUCvv8b9M4h32wIA==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.28.2", + "@esbuild/android-arm": "0.28.2", + "@esbuild/android-arm64": "0.28.2", + "@esbuild/android-x64": "0.28.2", + "@esbuild/darwin-arm64": "0.28.2", + "@esbuild/darwin-x64": "0.28.2", + "@esbuild/freebsd-arm64": "0.28.2", + "@esbuild/freebsd-x64": "0.28.2", + "@esbuild/linux-arm": "0.28.2", + "@esbuild/linux-arm64": "0.28.2", + "@esbuild/linux-ia32": "0.28.2", + "@esbuild/linux-loong64": "0.28.2", + "@esbuild/linux-mips64el": "0.28.2", + "@esbuild/linux-ppc64": "0.28.2", + "@esbuild/linux-riscv64": "0.28.2", + "@esbuild/linux-s390x": "0.28.2", + "@esbuild/linux-x64": "0.28.2", + "@esbuild/netbsd-arm64": "0.28.2", + "@esbuild/netbsd-x64": "0.28.2", + "@esbuild/openbsd-arm64": "0.28.2", + "@esbuild/openbsd-x64": "0.28.2", + "@esbuild/openharmony-arm64": "0.28.2", + "@esbuild/sunos-x64": "0.28.2", + "@esbuild/win32-arm64": "0.28.2", + "@esbuild/win32-ia32": "0.28.2", + "@esbuild/win32-x64": "0.28.2" + } + }, + "node_modules/escalade": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", + "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true, + "license": "MIT", + "optional": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/exponential-backoff": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/exponential-backoff/-/exponential-backoff-3.1.3.tgz", + "integrity": "sha512-ZgEeZXj30q+I0EN+CbSSpIyPaJ5HVQD18Z1m+u1FXbAeT94mr1zw50q4q6jiiC447Nl/YTcIYSAftiGqetwXCA==", + "dev": true, + "license": "Apache-2.0" + }, + "node_modules/fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "dev": true, + "license": "MIT" + }, + "node_modules/fast-uri": { + "version": "3.1.8", + "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.8.tgz", + "integrity": "sha512-GZMtZUTNRpOVIECoXwLNZS5xUGE+mVNbTB8h/7Rwh2TFWcBQiPzTgyZi05BF9UMZKkLJv8XBRJTlU7zg8+ZfMg==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fastify" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fastify" + } + ], + "license": "BSD-3-Clause" + }, + "node_modules/fd-slicer": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.1.0.tgz", + "integrity": "sha512-cE1qsB/VwyQozZ+q1dGxR8LBYNZeofhEdUNGSMbQD3Gw2lAzX9Zb3uIU6Ebc/Fmyjo9AWWfnn0AUCHqtevs/8g==", + "dev": true, + "license": "MIT", + "dependencies": { + "pend": "~1.2.0" + } + }, + "node_modules/fdir": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", + "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "picomatch": "^3 || ^4" + }, + "peerDependenciesMeta": { + "picomatch": { + "optional": true + } + } + }, + "node_modules/filelist": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/filelist/-/filelist-1.0.6.tgz", + "integrity": "sha512-5giy2PkLYY1cP39p17Ech+2xlpTRL9HLspOfEgm0L6CwBXBTgsK5ou0JtzYuepxkaQ/tvhCFIJ5uXo0OrM2DxA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "minimatch": "^5.0.1" + } + }, + "node_modules/filelist/node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true, + "license": "MIT" + }, + "node_modules/filelist/node_modules/brace-expansion": { + "version": "2.1.7", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.1.7.tgz", + "integrity": "sha512-uZbew1NqdmPDTMJ8ah1y+b+9QEJrfkXFk3RcTQw3X0jW/xRUvFKsg1CfQdSYGdTbXZWExtU3J3ccxtnfw1Fi0g==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/filelist/node_modules/minimatch": { + "version": "5.1.9", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.9.tgz", + "integrity": "sha512-7o1wEA2RyMP7Iu7GNba9vc0RWWGACJOCZBJX2GJWip0ikV+wcOsgVuY9uE8CPiyQhkGFSlhuSkZPavN7u1c2Fw==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/form-data": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.6.tgz", + "integrity": "sha512-vKatAh4SlVfgbv+YtmhiRjhEMJsYpsG1Y2rMQtR+SVSbytsSD1YGzDIcrAJmdFec88u/+VoGmxnl+80gL1tRCQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "es-set-tostringtag": "^2.1.0", + "hasown": "^2.0.4", + "mime-types": "^2.1.35" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/fs-extra": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", + "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", + "dev": true, + "license": "ISC" + }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "dev": true, + "license": "ISC", + "engines": { + "node": "6.* || 8.* || >= 10.*" + } + }, + "node_modules/get-intrinsic": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz", + "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "es-define-property": "^1.0.1", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.1.1", + "function-bind": "^1.1.2", + "get-proto": "^1.0.1", + "gopd": "^1.2.0", + "has-symbols": "^1.1.0", + "hasown": "^2.0.2", + "math-intrinsics": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz", + "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==", + "dev": true, + "license": "MIT", + "dependencies": { + "dunder-proto": "^1.0.1", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/get-stream": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-5.2.0.tgz", + "integrity": "sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA==", + "dev": true, + "license": "MIT", + "dependencies": { + "pump": "^3.0.0" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "deprecated": "Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me", + "dev": true, + "license": "ISC", + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/glob/node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true, + "license": "MIT" + }, + "node_modules/glob/node_modules/brace-expansion": { + "version": "1.1.21", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.21.tgz", + "integrity": "sha512-9zeA+KLZNNzglF2TPKRQEDyx6Yby7daAkuy8MiPzpXPsYDWi/DRM8jmwUDxokQjYqBpv5DgPiwD4h4ZZSy1Ujw==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/glob/node_modules/minimatch": { + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.5.tgz", + "integrity": "sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/global-agent": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/global-agent/-/global-agent-3.0.0.tgz", + "integrity": "sha512-PT6XReJ+D07JvGoxQMkT6qji/jVNfX/h364XHZOWeRzy64sSFr+xJ5OX7LI3b4MPQzdL4H8Y8M0xzPpsVMwA8Q==", + "dev": true, + "license": "BSD-3-Clause", + "optional": true, + "dependencies": { + "boolean": "^3.0.1", + "es6-error": "^4.1.1", + "matcher": "^3.0.0", + "roarr": "^2.15.3", + "semver": "^7.3.2", + "serialize-error": "^7.0.1" + }, + "engines": { + "node": ">=10.0" + } + }, + "node_modules/globalthis": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/globalthis/-/globalthis-1.0.4.tgz", + "integrity": "sha512-DpLKbNU4WylpxJykQujfCcwYWiV/Jhm50Goo0wrVILAv5jOr9d+H+UR3PhSCD2rCCEIg0uc+G+muBTwD54JhDQ==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "define-properties": "^1.2.1", + "gopd": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/gopd": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", + "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/got": { + "version": "11.8.6", + "resolved": "https://registry.npmjs.org/got/-/got-11.8.6.tgz", + "integrity": "sha512-6tfZ91bOr7bOXnK7PRDCGBLa1H4U080YHNaAQ2KsMGlLEzRbk44nsZF2E1IeRc3vtJHPVbKCYgdFbaGO2ljd8g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@sindresorhus/is": "^4.0.0", + "@szmarczak/http-timer": "^4.0.5", + "@types/cacheable-request": "^6.0.1", + "@types/responselike": "^1.0.0", + "cacheable-lookup": "^5.0.3", + "cacheable-request": "^7.0.2", + "decompress-response": "^6.0.0", + "http2-wrapper": "^1.0.0-beta.5.2", + "lowercase-keys": "^2.0.0", + "p-cancelable": "^2.0.0", + "responselike": "^2.0.0" + }, + "engines": { + "node": ">=10.19.0" + }, + "funding": { + "url": "https://github.com/sindresorhus/got?sponsor=1" + } + }, + "node_modules/graceful-fs": { + "version": "4.2.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", + "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", + "dev": true, + "license": "ISC" + }, + "node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/has-property-descriptors": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz", + "integrity": "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "es-define-property": "^1.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-symbols": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", + "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-tostringtag": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.2.tgz", + "integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==", + "dev": true, + "license": "MIT", + "dependencies": { + "has-symbols": "^1.0.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/hasown": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.4.tgz", + "integrity": "sha512-T2UbfbBEF32wiepXIsMlTW9+dDYC6wMh/t/vYA4tuOMKqWz/n3vr1NFSxQiyP+zk2mXsoMA/i/7qV6LKut1t1A==", + "dev": true, + "license": "MIT", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/he": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", + "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", + "license": "MIT", + "bin": { + "he": "bin/he" + } + }, + "node_modules/hosted-git-info": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-4.1.0.tgz", + "integrity": "sha512-kyCuEOWjJqZuDbRHzL8V93NzQhwIB71oFWSyzVo+KPZI+pnQPPxucdkrOZvkLRnrf5URsQM+IJ09Dw29cRALIA==", + "dev": true, + "license": "ISC", + "dependencies": { + "lru-cache": "^6.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/html-to-text": { + "version": "10.0.1", + "resolved": "https://registry.npmjs.org/html-to-text/-/html-to-text-10.0.1.tgz", + "integrity": "sha512-GiVhRI1BatGARSCmlXWNCjDT0cWrwBWoeduLoV0WSKAgaV/wa+hUWy5LiQLUs4UwiUrE52ZCMfBGiKD87TDPrg==", + "license": "MIT", + "dependencies": { + "@selderee/plugin-htmlparser2": "~0.12.0", + "deepmerge-ts": "^8.0.1", + "dom-serializer": "^2.0.0", + "htmlparser2": "^10.1.0", + "selderee": "~0.12.0" + }, + "engines": { + "node": ">=20.19.0" + }, + "funding": { + "url": "https://github.com/sponsors/KillyMXI" + } + }, + "node_modules/htmlparser2": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-10.1.0.tgz", + "integrity": "sha512-VTZkM9GWRAtEpveh7MSF6SjjrpNVNNVJfFup7xTY3UpFtm67foy9HDVXneLtFVt4pMz5kZtgNcvCniNFb1hlEQ==", + "funding": [ + "https://github.com/fb55/htmlparser2?sponsor=1", + { + "type": "github", + "url": "https://github.com/sponsors/fb55" + } + ], + "license": "MIT", + "dependencies": { + "domelementtype": "^2.3.0", + "domhandler": "^5.0.3", + "domutils": "^3.2.2", + "entities": "^7.0.1" + } + }, + "node_modules/htmlparser2/node_modules/entities": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/entities/-/entities-7.0.1.tgz", + "integrity": "sha512-TWrgLOFUQTH994YUyl1yT4uyavY5nNB5muff+RtWaqNVCAK408b5ZnnbNAUEWLTCpum9w6arT70i1XdQ4UeOPA==", + "license": "BSD-2-Clause", + "engines": { + "node": ">=0.12" + }, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, + "node_modules/http-cache-semantics": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.3.0.tgz", + "integrity": "sha512-M5t5LlJpS1UHMjvwRQVdFHvPISGeLAxNcrWuJkeGh0KxsqCHZ1O3NXZU/8x7cD0BDcGW8kapxMKTvwlqrNkHkA==", + "dev": true, + "license": "BSD-2-Clause" + }, + "node_modules/http-proxy-agent": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-7.0.2.tgz", + "integrity": "sha512-T1gkAiYYDWYx3V5Bmyu7HcfcvL7mUrTWiM6yOfa3PIphViJ/gFPbvidQ+veqSOHci/PxBcDabeUNCzpOODJZig==", + "dev": true, + "license": "MIT", + "dependencies": { + "agent-base": "^7.1.0", + "debug": "^4.3.4" + }, + "engines": { + "node": ">= 14" + } + }, + "node_modules/http2-wrapper": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/http2-wrapper/-/http2-wrapper-1.0.3.tgz", + "integrity": "sha512-V+23sDMr12Wnz7iTcDeJr3O6AIxlnvT/bmaAAAP/Xda35C90p9599p0F1eHR/N1KILWSoWVAiOMFjBBXaXSMxg==", + "dev": true, + "license": "MIT", + "dependencies": { + "quick-lru": "^5.1.1", + "resolve-alpn": "^1.0.0" + }, + "engines": { + "node": ">=10.19.0" + } + }, + "node_modules/https-proxy-agent": { + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.6.tgz", + "integrity": "sha512-vK9P5/iUfdl95AI+JVyUuIcVtd4ofvtrOr3HNtM2yxC9bnMbEdp3x01OhQNnjb8IJYi38VlTE3mBXwcfvywuSw==", + "dev": true, + "license": "MIT", + "dependencies": { + "agent-base": "^7.1.2", + "debug": "4" + }, + "engines": { + "node": ">= 14" + } + }, + "node_modules/ical.js": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/ical.js/-/ical.js-2.2.1.tgz", + "integrity": "sha512-yK/UlPbEs316igb/tjRgbFA8ZV75rCsBJp/hWOatpyaPNlgw0dGDmU+FoicOcwX4xXkeXOkYiOmCqNPFpNPkQg==", + "license": "MPL-2.0" + }, + "node_modules/iconv-lite": { + "version": "0.7.3", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.3.tgz", + "integrity": "sha512-IKXpvIzjnC9XTAUbVBcMfGS0EPaIXtW6v+zr+RRp+hqULEpo0owZax6wyRwPOJbWbzjYspQwusTsfVr0ifh4uQ==", + "license": "MIT", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + }, + "engines": { + "node": ">=0.10.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/imapflow": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/imapflow/-/imapflow-2.2.1.tgz", + "integrity": "sha512-d7/sRGEtexA8e0Y71sN0rKfB2yWgZMHY8JqCbk17arRLGicjX1LpBuxPH+wowOIA5sVWs7U//B6S+mKfrBtT6w==", + "license": "MIT", + "dependencies": { + "@zone-eu/mailsplit": "5.4.19", + "encoding-japanese": "2.4.0", + "iconv-lite": "0.7.3", + "libbase64": "1.3.1", + "libmime": "5.4.6", + "libqp": "2.1.2", + "pino": "10.3.1", + "socks": "2.8.10" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", + "deprecated": "This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.", + "dev": true, + "license": "ISC", + "dependencies": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true, + "license": "ISC" + }, + "node_modules/ini": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/ini/-/ini-4.1.3.tgz", + "integrity": "sha512-X7rqawQBvfdjS10YU1y1YVreA3SsLrW9dX2CewP2EbBJM4ypVNLDkO5y04gejPwKIY9lR+7r9gn3rFPt/kmWFg==", + "dev": true, + "license": "ISC", + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } + }, + "node_modules/ip-address": { + "version": "10.7.3", + "resolved": "https://registry.npmjs.org/ip-address/-/ip-address-10.7.3.tgz", + "integrity": "sha512-A1kdq/tSb5QjvKvAMgIoEvDBIgL7qaqVP/jkvSwYYRZ9iEzvPpopxp2wQfu3SuZRHtpHNxMn8Fs0bS+gf5Xmwg==", + "license": "MIT", + "engines": { + "node": ">= 12" + } + }, + "node_modules/is-docker": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-2.2.1.tgz", + "integrity": "sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ==", + "dev": true, + "license": "MIT", + "bin": { + "is-docker": "cli.js" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/is-wsl": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz", + "integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-docker": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/isbinaryfile": { + "version": "5.0.7", + "resolved": "https://registry.npmjs.org/isbinaryfile/-/isbinaryfile-5.0.7.tgz", + "integrity": "sha512-gnWD14Jh3FzS3CPhF0AxNOJ8CxqeblPTADzI38r0wt8ZyQl5edpy75myt08EG2oKvpyiqSqsx+Wkz9vtkbTqYQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 18.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/gjtorikian/" + } + }, + "node_modules/isexe": { + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-3.1.5.tgz", + "integrity": "sha512-6B3tLtFqtQS4ekarvLVMZ+X+VlvQekbe4taUkf/rhVO3d/h0M2rfARm/pXLcPEsjjMsFgrFgSrhQIxcSVrBz8w==", + "dev": true, + "license": "BlueOak-1.0.0", + "engines": { + "node": ">=18" + } + }, + "node_modules/jake": { + "version": "10.9.4", + "resolved": "https://registry.npmjs.org/jake/-/jake-10.9.4.tgz", + "integrity": "sha512-wpHYzhxiVQL+IV05BLE2Xn34zW1S223hvjtqk0+gsPrwd/8JNLXJgZZM/iPFsYc1xyphF+6M6EvdE5E9MBGkDA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "async": "^3.2.6", + "filelist": "^1.0.4", + "picocolors": "^1.1.1" + }, + "bin": { + "jake": "bin/cli.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/jiti": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/jiti/-/jiti-2.7.0.tgz", + "integrity": "sha512-AC/7JofJvZGrrneWNaEnJeOLUx+JlGt7tNa0wZiRPT4MY1wmfKjt2+6O2p2uz2+skll8OZZmJMNqeke7kKbNgQ==", + "dev": true, + "license": "MIT", + "bin": { + "jiti": "lib/jiti-cli.mjs" + } + }, + "node_modules/js-yaml": { + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.3.2.tgz", + "integrity": "sha512-SFNOvSJ+Dgf/9An904Yx+CgSlIPCkIpao4qo51lpee25TIRejdH3rhR4EZMGoNx3/TP3O+wzWuiTFl4sqbltzA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/puzrin" + }, + { + "type": "github", + "url": "https://github.com/sponsors/nodeca" + } + ], + "license": "MIT", + "dependencies": { + "argparse": "^2.0.1" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, + "node_modules/json-buffer": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz", + "integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/json-schema-traverse": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", + "dev": true, + "license": "MIT" + }, + "node_modules/json-stringify-safe": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", + "integrity": "sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA==", + "dev": true, + "license": "ISC", + "optional": true + }, + "node_modules/json5": { + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", + "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", + "dev": true, + "license": "MIT", + "bin": { + "json5": "lib/cli.js" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/jsonfile": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.2.1.tgz", + "integrity": "sha512-zwOTdL3rFQ/lRdBnntKVOX6k5cKJwEc1HdilT71BWEu7J41gXIB2MRp+vxduPSwZJPWBxEzv4yH1wYLJGUHX4Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "universalify": "^2.0.0" + }, + "optionalDependencies": { + "graceful-fs": "^4.1.6" + } + }, + "node_modules/keyv": { + "version": "4.5.4", + "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz", + "integrity": "sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==", + "dev": true, + "license": "MIT", + "dependencies": { + "json-buffer": "3.0.1" + } + }, + "node_modules/kleur": { + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/kleur/-/kleur-4.1.5.tgz", + "integrity": "sha512-o+NO+8WrRiQEE4/7nwRJhN1HWpVmJm511pBHUxPLtp0BUISzlBplORYSmTclCnJvQq2tKu/sgl3xVpkc7ZWuQQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/lazy-val": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/lazy-val/-/lazy-val-1.0.5.tgz", + "integrity": "sha512-0/BnGCCfyUMkBpeDgWihanIAF9JmZhHBgUhEqzvf+adhNGLoP6TaiI5oF8oyb3I45P+PcnrqihSf01M0l0G5+Q==", + "dev": true, + "license": "MIT" + }, + "node_modules/leac": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/leac/-/leac-0.7.0.tgz", + "integrity": "sha512-qMrZeyEekgdRQ9o6a4NAB2EQZrv827GJdn1vnapwSJ90hWRB4TzUSunvacPkxQ2TnNqHNI1/zSt0hlo0crG8Jw==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/KillyMXI" + } + }, + "node_modules/libbase64": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/libbase64/-/libbase64-1.3.1.tgz", + "integrity": "sha512-1b9LXEjEtXj35YKOR9RqNKBootlb37qbIzmqiw4MsP52cjOsfR6i/AYU1Y8qN4kV2TJQmLJ5aiXn45qI6h+Szw==", + "license": "MIT" + }, + "node_modules/libmime": { + "version": "5.4.6", + "resolved": "https://registry.npmjs.org/libmime/-/libmime-5.4.6.tgz", + "integrity": "sha512-Cgx1vHd76GTwDaLNsl0K44CjNFfhkX/1bMcoruoWr8Ugcl0/zMw7x/8NpZERIOcpGyzlQo10tOEw9goGsv2Wlg==", + "license": "MIT", + "dependencies": { + "encoding-japanese": "2.4.0", + "iconv-lite": "0.7.3", + "libbase64": "1.3.1", + "libqp": "2.1.2" + } + }, + "node_modules/libqp": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/libqp/-/libqp-2.1.2.tgz", + "integrity": "sha512-rp+U80tl9Os4K7GnVbPzPRmghPu6eqB8rcF+ontvNAnoga0JhMFG/bkTD/reC8yoznKMgOc5/ttZHJasiWeFPw==", + "license": "MIT" + }, + "node_modules/linkify-it": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-5.0.2.tgz", + "integrity": "sha512-ONTm2jCMAVZjgQa/Fy1kScXsuOoF5NPTsoFBdE1KVIZ2vAh/r9+Bqo+0jINCBYnavTPQZz38QzFTme79ENoN3Q==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/puzrin" + }, + { + "type": "github", + "url": "https://github.com/sponsors/markdown-it" + } + ], + "license": "MIT", + "dependencies": { + "uc.micro": "^2.0.0" + } + }, + "node_modules/lodash": { + "version": "4.18.1", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.18.1.tgz", + "integrity": "sha512-dMInicTPVE8d1e5otfwmmjlxkZoUpiVLwyeTdUsi/Caj/gfzzblBcCE5sRHV/AsjuCmxWrte2TNGSYuCeCq+0Q==", + "dev": true, + "license": "MIT" + }, + "node_modules/lowercase-keys": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-2.0.0.tgz", + "integrity": "sha512-tqNXrS78oMOE73NMxK4EMLQsQowWf8jKooH9g7xPavRT706R6bkQJ6DY2Te7QukaZsulxa30wQ7bk0pm4XiHmA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "license": "ISC", + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/mailparser": { + "version": "3.9.33", + "resolved": "https://registry.npmjs.org/mailparser/-/mailparser-3.9.33.tgz", + "integrity": "sha512-+ZYhApN4f7B8+jokb7VZeml8lxYHixVJ3tJTB5iPG9/MJpy8YmBHGdy+AWJ9dmtUX6t0xlu4rxwj1b7eWCvbDA==", + "license": "MIT", + "dependencies": { + "@zone-eu/mailsplit": "5.4.19", + "encoding-japanese": "2.4.0", + "he": "1.2.0", + "html-to-text": "10.0.1", + "iconv-lite": "0.7.3", + "libmime": "5.4.6", + "linkify-it": "5.0.2", + "nodemailer": "10.0.13", + "punycode.js": "2.3.1", + "tlds": "1.261.0" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/mailparser/node_modules/nodemailer": { + "version": "10.0.13", + "resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-10.0.13.tgz", + "integrity": "sha512-SzG86OlvcW/NNhUFC6uROMwRTL4n7MswfQqC/T8mhkmnY1YVa23zUEMYi4ijSeXSl9GLz9ZeTJDUatEDuY5FeQ==", + "license": "MIT-0", + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/matcher": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/matcher/-/matcher-3.0.0.tgz", + "integrity": "sha512-OkeDaAZ/bQCxeFAozM55PKcKU0yJMPGifLwV4Qgjitu+5MoAfSQN4lsLJeXZ1b8w0x+/Emda6MZgXS1jvsapng==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "escape-string-regexp": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/math-intrinsics": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", + "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/mime": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-2.6.0.tgz", + "integrity": "sha512-USPkMeET31rOMiarsBNIHZKLGgvKc/LrjofAnBlOttf5ajRvqiRA8QsenbcooctK6d6Ts6aqZXBA+XbkKthiQg==", + "dev": true, + "license": "MIT", + "bin": { + "mime": "cli.js" + }, + "engines": { + "node": ">=4.0.0" + } + }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "dev": true, + "license": "MIT", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mimic-response": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-1.0.1.tgz", + "integrity": "sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/minimatch": { + "version": "10.2.6", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.6.tgz", + "integrity": "sha512-vpLQEs+VLCr1nU0BXS07maYoFwlDAH0gngQuuttxIwutDFEMHq2blX+8vpgxDdK3J1PwjCJiep77OitTZ4Ll1A==", + "dev": true, + "license": "BlueOak-1.0.0", + "dependencies": { + "brace-expansion": "^5.0.8" + }, + "engines": { + "node": "18 || 20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/minimist": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", + "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/minipass": { + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.3.tgz", + "integrity": "sha512-tEBHqDnIoM/1rXME1zgka9g6Q2lcoCkxHLuc7ODJ5BxbP5d4c2Z5cGgtXAku59200Cx7diuHTOYfSBD8n6mm8A==", + "dev": true, + "license": "BlueOak-1.0.0", + "engines": { + "node": ">=16 || 14 >=14.17" + } + }, + "node_modules/minizlib": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-3.1.0.tgz", + "integrity": "sha512-KZxYo1BUkWD2TVFLr0MQoM8vUUigWD3LlD83a/75BqC+4qE0Hb1Vo5v1FgcfaNXvfXzr+5EhQ6ing/CaBijTlw==", + "dev": true, + "license": "MIT", + "dependencies": { + "minipass": "^7.1.2" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/mkdirp": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", + "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", + "dev": true, + "license": "MIT", + "peer": true, + "dependencies": { + "minimist": "^1.2.6" + }, + "bin": { + "mkdirp": "bin/cmd.js" + } + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "license": "MIT" + }, + "node_modules/native-run": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/native-run/-/native-run-2.0.3.tgz", + "integrity": "sha512-U1PllBuzW5d1gfan+88L+Hky2eZx+9gv3Pf6rNBxKbORxi7boHzqiA6QFGSnqMem4j0A9tZ08NMIs5+0m/VS1Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@ionic/utils-fs": "^3.1.7", + "@ionic/utils-terminal": "^2.3.4", + "bplist-parser": "^0.3.2", + "debug": "^4.3.4", + "elementtree": "^0.1.7", + "ini": "^4.1.1", + "plist": "^3.1.0", + "split2": "^4.2.0", + "through2": "^4.0.2", + "tslib": "^2.6.2", + "yauzl": "^2.10.0" + }, + "bin": { + "native-run": "bin/native-run" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/node-abi": { + "version": "4.35.0", + "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-4.35.0.tgz", + "integrity": "sha512-ymk4aIzxdPopw2giv8Fs1Ec6vybGkjmyxUwVqhkI4MCy2tVfXdkOGGWieWVjL0THgH+7a8lRdevyupoYj3Js/Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "semver": "^7.6.3" + }, + "engines": { + "node": ">=22.12.0" + } + }, + "node_modules/node-api-version": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/node-api-version/-/node-api-version-0.2.1.tgz", + "integrity": "sha512-2xP/IGGMmmSQpI1+O/k72jF/ykvZ89JeuKX3TLJAYPDVLUalrshrLHkeVcCCZqG/eEa635cr8IBYzgnDvM2O8Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "semver": "^7.3.5" + } + }, + "node_modules/node-gyp": { + "version": "12.4.0", + "resolved": "https://registry.npmjs.org/node-gyp/-/node-gyp-12.4.0.tgz", + "integrity": "sha512-OMcPNvqTCFUnNaBlmdgq+lfNqY7gTiSmNRDjY3uAXRyudeKZEZxu3CLtjMQrx4zZxCX2b/mpNqTtwuCJgXhHkw==", + "dev": true, + "license": "MIT", + "dependencies": { + "env-paths": "^2.2.0", + "exponential-backoff": "^3.1.1", + "graceful-fs": "^4.2.6", + "nopt": "^9.0.0", + "proc-log": "^6.0.0", + "semver": "^7.3.5", + "tar": "^7.5.4", + "tinyglobby": "^0.2.12", + "undici": "^6.25.0", + "which": "^6.0.0" + }, + "bin": { + "node-gyp": "bin/node-gyp.js" + }, + "engines": { + "node": "^20.17.0 || >=22.9.0" + } + }, + "node_modules/node-gyp/node_modules/env-paths": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/env-paths/-/env-paths-2.2.1.tgz", + "integrity": "sha512-+h1lkLKhZMTYjog1VEpJNG7NZJWcuc2DDk/qsqSTRRCOXiLjeQ1d1/udrUGhqMxUgAlwKNZ0cf2uqan5GLuS2A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/node-gyp/node_modules/isexe": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-4.0.0.tgz", + "integrity": "sha512-FFUtZMpoZ8RqHS3XeXEmHWLA4thH+ZxCv2lOiPIn1Xc7CxrqhWzNSDzD+/chS/zbYezmiwWLdQC09JdQKmthOw==", + "dev": true, + "license": "BlueOak-1.0.0", + "engines": { + "node": ">=20" + } + }, + "node_modules/node-gyp/node_modules/undici": { + "version": "6.29.0", + "resolved": "https://registry.npmjs.org/undici/-/undici-6.29.0.tgz", + "integrity": "sha512-R+RODBqp6i2pPflGdq+xIOUkl+RNfGgHwoinecKu/JCuf2uO06cOKoDbI2P7Dn6KcswdKwrczbU6IYJ6K8X+wg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18.17" + } + }, + "node_modules/node-gyp/node_modules/which": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/which/-/which-6.0.1.tgz", + "integrity": "sha512-oGLe46MIrCRqX7ytPUf66EAYvdeMIZYn3WaocqqKZAxrBpkqHfL/qvTyJ/bTk5+AqHCjXmrv3CEWgy368zhRUg==", + "dev": true, + "license": "ISC", + "dependencies": { + "isexe": "^4.0.0" + }, + "bin": { + "node-which": "bin/which.js" + }, + "engines": { + "node": "^20.17.0 || >=22.9.0" + } + }, + "node_modules/node-int64": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz", + "integrity": "sha512-O5lz91xSOeoXP6DulyHfllpq+Eg00MWitZIbtPfoSEvqIHdl5gfcY6hYzDWnj0qD5tz52PI08u9qUvSVeUBeHw==", + "dev": true, + "license": "MIT" + }, + "node_modules/nodemailer": { + "version": "10.0.9", + "resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-10.0.9.tgz", + "integrity": "sha512-BF0qcyplCwp+jMk6HCjFykBz/YhhZSsxrARhOldLwFWH+8kGjQsd2WIMIZhqEuyXRoGFi0ONbDeWDMDoL8MhLw==", + "license": "MIT-0", + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/nopt": { + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-9.0.0.tgz", + "integrity": "sha512-Zhq3a+yFKrYwSBluL4H9XP3m3y5uvQkB/09CwDruCiRmR/UJYnn9W4R48ry0uGC70aeTPKLynBtscP9efFFcPw==", + "dev": true, + "license": "ISC", + "dependencies": { + "abbrev": "^4.0.0" + }, + "bin": { + "nopt": "bin/nopt.js" + }, + "engines": { + "node": "^20.17.0 || >=22.9.0" + } + }, + "node_modules/normalize-url": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-6.1.0.tgz", + "integrity": "sha512-DlL+XwOy3NxAQ8xuC0okPgK46iuVNAK01YN7RueYBqqFeGsBjV9XmCAzAdgt+667bCl5kPh9EqKKDwnaPG1I7A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/object-keys": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", + "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", + "dev": true, + "license": "MIT", + "optional": true, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/on-exit-leak-free": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/on-exit-leak-free/-/on-exit-leak-free-2.1.2.tgz", + "integrity": "sha512-0eJJY6hXLGf1udHwfNftBqH+g73EU4B504nZeKpz1sYRKafAghwxEJunB2O7rDZkL4PGfsMVnTXZ2EjibbqcsA==", + "license": "MIT", + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "dev": true, + "license": "ISC", + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/open": { + "version": "8.4.2", + "resolved": "https://registry.npmjs.org/open/-/open-8.4.2.tgz", + "integrity": "sha512-7x81NCL719oNbsq/3mh+hVrAWmFuEYUqrq/Iw3kUzH8ReypT9QQ0BLoJS7/G9k6N81XjW4qHWtjWwe/9eLy1EQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "define-lazy-prop": "^2.0.0", + "is-docker": "^2.1.1", + "is-wsl": "^2.2.0" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/openpgp": { + "version": "6.3.2", + "resolved": "https://registry.npmjs.org/openpgp/-/openpgp-6.3.2.tgz", + "integrity": "sha512-wcZTzHz41LV8Y48zH/JlD1JT8YdNmpWOuMAjQ/podvvCwsjBEU37K3znJh4UQcj3hksE5z9TzvhbUbwzsGvlLQ==", + "license": "LGPL-3.0+", + "engines": { + "node": ">= 18.0.0", + "typescript": ">= 5.0.0" + }, + "peerDependencies": { + "@openpgp/web-stream-tools": "~0.3.0" + }, + "peerDependenciesMeta": { + "@openpgp/web-stream-tools": { + "optional": true + } + } + }, + "node_modules/p-cancelable": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/p-cancelable/-/p-cancelable-2.1.1.tgz", + "integrity": "sha512-BZOr3nRQHOntUjTrH8+Lh54smKHoHyur8We1V8DSMVrl5A2malOOwuJRnKRDjSnkoeBh4at6BwEnb5I7Jl31wg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "yocto-queue": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/package-json-from-dist": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.1.tgz", + "integrity": "sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw==", + "dev": true, + "license": "BlueOak-1.0.0" + }, + "node_modules/parseley": { + "version": "0.13.1", + "resolved": "https://registry.npmjs.org/parseley/-/parseley-0.13.1.tgz", + "integrity": "sha512-uNBJZzmb60l6p6VWLTmevizNAGnE0xoSf1n0B4q3ntegDNzcS68NRCcBDZTcyXHxt2XhBChsCuqj4M+nChvE/A==", + "license": "MIT", + "dependencies": { + "leac": "^0.7.0", + "peberminta": "^0.10.0" + }, + "funding": { + "url": "https://github.com/sponsors/KillyMXI" + } + }, + "node_modules/path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/path-scurry": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-2.0.2.tgz", + "integrity": "sha512-3O/iVVsJAPsOnpwWIeD+d6z/7PmqApyQePUtCndjatj/9I5LylHvt5qluFaBT3I5h3r1ejfR056c+FCv+NnNXg==", + "dev": true, + "license": "BlueOak-1.0.0", + "dependencies": { + "lru-cache": "^11.0.0", + "minipass": "^7.1.2" + }, + "engines": { + "node": "18 || 20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/path-scurry/node_modules/lru-cache": { + "version": "11.5.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.5.3.tgz", + "integrity": "sha512-U4N8FgzmWxc8k1VH8Kr6lQg18U7Fjvby6wXHVRX/ZZ7IwWbRMgrRbP0Wrb5q5NVinryp4SQampHKdvtecItxUg==", + "dev": true, + "license": "BlueOak-1.0.0", + "engines": { + "node": "20 || >=22" + } + }, + "node_modules/pe-library": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/pe-library/-/pe-library-0.4.1.tgz", + "integrity": "sha512-eRWB5LBz7PpDu4PUlwT0PhnQfTQJlDDdPa35urV4Osrm0t0AqQFGn+UIkU3klZvwJ8KPO3VbBFsXquA6p6kqZw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12", + "npm": ">=6" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/jet2jet" + } + }, + "node_modules/peberminta": { + "version": "0.10.0", + "resolved": "https://registry.npmjs.org/peberminta/-/peberminta-0.10.0.tgz", + "integrity": "sha512-80B2AsU+I4Qdb0ZAPSfe9UwvGzwkM37IKIFEvdS3D/3Ndgv2bsuJ0bfG1+iEYO+l7Gfd4EUJmuRyq7efLgRMzQ==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/KillyMXI" + } + }, + "node_modules/pend": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz", + "integrity": "sha512-F3asv42UuXchdzt+xXqfW1OGlVBe+mxa2mqI0pg5yAHZPvFmY3Y6drSf/GQ1A86WgWEN9Kzh/WrgKa6iGcHXLg==", + "dev": true, + "license": "MIT" + }, + "node_modules/picocolors": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", + "dev": true, + "license": "ISC" + }, + "node_modules/picomatch": { + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.7.tgz", + "integrity": "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/pino": { + "version": "10.3.1", + "resolved": "https://registry.npmjs.org/pino/-/pino-10.3.1.tgz", + "integrity": "sha512-r34yH/GlQpKZbU1BvFFqOjhISRo1MNx1tWYsYvmj6KIRHSPMT2+yHOEb1SG6NMvRoHRF0a07kCOox/9yakl1vg==", + "license": "MIT", + "dependencies": { + "@pinojs/redact": "^0.4.0", + "atomic-sleep": "^1.0.0", + "on-exit-leak-free": "^2.1.0", + "pino-abstract-transport": "^3.0.0", + "pino-std-serializers": "^7.0.0", + "process-warning": "^5.0.0", + "quick-format-unescaped": "^4.0.3", + "real-require": "^0.2.0", + "safe-stable-stringify": "^2.3.1", + "sonic-boom": "^4.0.1", + "thread-stream": "^4.0.0" + }, + "bin": { + "pino": "bin.js" + } + }, + "node_modules/pino-abstract-transport": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pino-abstract-transport/-/pino-abstract-transport-3.0.0.tgz", + "integrity": "sha512-wlfUczU+n7Hy/Ha5j9a/gZNy7We5+cXp8YL+X+PG8S0KXxw7n/JXA3c46Y0zQznIJ83URJiwy7Lh56WLokNuxg==", + "license": "MIT", + "dependencies": { + "split2": "^4.0.0" + } + }, + "node_modules/pino-std-serializers": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/pino-std-serializers/-/pino-std-serializers-7.1.0.tgz", + "integrity": "sha512-BndPH67/JxGExRgiX1dX0w1FvZck5Wa4aal9198SrRhZjH3GxKQUKIBnYJTdj2HDN3UQAS06HlfcSbQj2OHmaw==", + "license": "MIT" + }, + "node_modules/pkijs": { + "version": "3.4.1", + "resolved": "https://registry.npmjs.org/pkijs/-/pkijs-3.4.1.tgz", + "integrity": "sha512-Oo/NZcSWccq8KyoG7gLE9fnltgHns+pNCjCAp/WmjsUySi+sX7y4z4Xqu4fVb42CDHzRPl33fjzT15V1wvcyhA==", + "dev": true, + "license": "BSD-3-Clause", + "workspaces": [ + "website" + ], + "dependencies": { + "@noble/hashes": "1.8.0", + "asn1js": "^3.0.6", + "bytestreamjs": "^2.0.1", + "pvtsutils": "^1.3.6", + "pvutils": "^1.1.3", + "tslib": "^2.8.1" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/plist": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/plist/-/plist-3.1.0.tgz", + "integrity": "sha512-uysumyrvkUX0rX/dEVqt8gC3sTBzd4zoWfLeS29nb53imdaXVvLINYXTI2GNqzaMuvacNx4uJQ8+b3zXR0pkgQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@xmldom/xmldom": "^0.8.8", + "base64-js": "^1.5.1", + "xmlbuilder": "^15.1.1" + }, + "engines": { + "node": ">=10.4.0" + } + }, + "node_modules/postject": { + "version": "1.0.0-alpha.6", + "resolved": "https://registry.npmjs.org/postject/-/postject-1.0.0-alpha.6.tgz", + "integrity": "sha512-b9Eb8h2eVqNE8edvKdwqkrY6O7kAwmI8kcnBv1NScolYJbo59XUF0noFq+lxbC1yN20bmC0WBEbDC5H/7ASb0A==", + "dev": true, + "license": "MIT", + "optional": true, + "peer": true, + "dependencies": { + "commander": "^9.4.0" + }, + "bin": { + "postject": "dist/cli.js" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/postject/node_modules/commander": { + "version": "9.5.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-9.5.0.tgz", + "integrity": "sha512-KRs7WVDKg86PWiuAqhDrAQnTXZKraVcCc6vFdL14qrZ/DcWwuRo7VoiYXalXO7S5GKpqYiVEwCbgFDfxNHKJBQ==", + "dev": true, + "license": "MIT", + "optional": true, + "peer": true, + "engines": { + "node": "^12.20.0 || >=14" + } + }, + "node_modules/proc-log": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/proc-log/-/proc-log-6.1.0.tgz", + "integrity": "sha512-iG+GYldRf2BQ0UDUAd6JQ/RwzaQy6mXmsk/IzlYyal4A4SNFw54MeH4/tLkF4I5WoWG9SQwuqWzS99jaFQHBuQ==", + "dev": true, + "license": "ISC", + "engines": { + "node": "^20.17.0 || >=22.9.0" + } + }, + "node_modules/process-nextick-args": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", + "dev": true, + "license": "MIT" + }, + "node_modules/process-warning": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/process-warning/-/process-warning-5.1.0.tgz", + "integrity": "sha512-jQSaVHsPgtyw60e1rQ/A+/ArPEj/S8pS/vFnyGa/gYFXrKk/6RuDkoqVDQ5NI5MmS01698ltlAk0NoDBNLujRw==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fastify" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fastify" + } + ], + "license": "MIT" + }, + "node_modules/progress": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", + "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/promise-retry": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/promise-retry/-/promise-retry-2.0.1.tgz", + "integrity": "sha512-y+WKFlBR8BGXnsNlIHFGPZmyDf3DFMoLhaflAnyZgV6rG6xu+JwesTo2Q9R6XwYmtmwAFCkAk3e35jEdoeh/3g==", + "dev": true, + "license": "MIT", + "dependencies": { + "err-code": "^2.0.2", + "retry": "^0.12.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/prompts": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/prompts/-/prompts-2.4.2.tgz", + "integrity": "sha512-NxNv/kLguCA7p3jE8oL2aEBsrJWgAakBpgmgK6lpPWV+WuOmY6r2/zbAVnP+T8bQlA0nzHXSJSJW0Hq7ylaD2Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "kleur": "^3.0.3", + "sisteransi": "^1.0.5" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/prompts/node_modules/kleur": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz", + "integrity": "sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/proper-lockfile": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/proper-lockfile/-/proper-lockfile-4.1.2.tgz", + "integrity": "sha512-TjNPblN4BwAWMXU8s9AEz4JmQxnD1NNL7bNOY/AKUzyamc379FWASUhc/K1pL2noVb+XmZKLL68cjzLsiOAMaA==", + "dev": true, + "license": "MIT", + "dependencies": { + "graceful-fs": "^4.2.4", + "retry": "^0.12.0", + "signal-exit": "^3.0.2" + } + }, + "node_modules/pump": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.4.tgz", + "integrity": "sha512-VS7sjc6KR7e1ukRFhQSY5LM2uBWAUPiOPa/A3mkKmiMwSmRFUITt0xuj+/lesgnCv+dPIEYlkzrcyXgquIHMcA==", + "dev": true, + "license": "MIT", + "dependencies": { + "end-of-stream": "^1.1.0", + "once": "^1.3.1" + } + }, + "node_modules/punycode.js": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode.js/-/punycode.js-2.3.1.tgz", + "integrity": "sha512-uxFIHU0YlHYhDQtV4R9J6a52SLx28BCjT+4ieh7IGbgwVJWO+km431c4yRlREUAsAmt/uMjQUyQHNEPf0M39CA==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/pvtsutils": { + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/pvtsutils/-/pvtsutils-1.3.6.tgz", + "integrity": "sha512-PLgQXQ6H2FWCaeRak8vvk1GW462lMxB5s3Jm673N82zI4vqtVUPuZdffdZbPDFRoU8kAhItWFtPCWiPpp4/EDg==", + "dev": true, + "license": "MIT", + "dependencies": { + "tslib": "^2.8.1" + } + }, + "node_modules/pvutils": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/pvutils/-/pvutils-1.2.0.tgz", + "integrity": "sha512-BbubeCEyTuQjVMakvJQ/Sxbc93F2pwmbsxONT/ZRrwU7Ua38d8unYTwXpTVLAKJ4BDuH9IGztCjQcd/N/39Dvg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/quick-format-unescaped": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/quick-format-unescaped/-/quick-format-unescaped-4.0.4.tgz", + "integrity": "sha512-tYC1Q1hgyRuHgloV/YXs2w15unPVh8qfu/qCTfhTYamaw7fyhumKa2yGpdSo87vY32rIclj+4fWYQXUMs9EHvg==", + "license": "MIT" + }, + "node_modules/quick-lru": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/quick-lru/-/quick-lru-5.1.1.tgz", + "integrity": "sha512-WuyALRjWPDGtt/wzJiadO5AXY+8hZ80hVpe6MyivgraREW751X3SbhRvG3eLKOYN+8VEvqLcf3wdnt44Z4S4SA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/read-binary-file-arch": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/read-binary-file-arch/-/read-binary-file-arch-1.0.6.tgz", + "integrity": "sha512-BNg9EN3DD3GsDXX7Aa8O4p92sryjkmzYYgmgTAc6CA4uGLEDzFfxOxugu21akOxpcXHiEgsYkC6nPsQvLLLmEg==", + "dev": true, + "license": "MIT", + "dependencies": { + "debug": "^4.3.4" + }, + "bin": { + "read-binary-file-arch": "cli.js" + } + }, + "node_modules/readable-stream": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.8.tgz", + "integrity": "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==", + "dev": true, + "license": "MIT", + "dependencies": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "node_modules/real-require": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/real-require/-/real-require-0.2.0.tgz", + "integrity": "sha512-57frrGM/OCTLqLOAh0mhVA9VBMHd+9U7Zb2THMGdBUoZVOtGbJzjxsYGDJ3A9AYYCP4hn6y1TVbaOfzWtm5GFg==", + "license": "MIT", + "engines": { + "node": ">= 12.13.0" + } + }, + "node_modules/require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/require-from-string": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", + "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/resedit": { + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/resedit/-/resedit-1.7.2.tgz", + "integrity": "sha512-vHjcY2MlAITJhC0eRD/Vv8Vlgmu9Sd3LX9zZvtGzU5ZImdTN3+d6e/4mnTyV8vEbyf1sgNIrWxhWlrys52OkEA==", + "dev": true, + "license": "MIT", + "dependencies": { + "pe-library": "^0.4.1" + }, + "engines": { + "node": ">=12", + "npm": ">=6" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/jet2jet" + } + }, + "node_modules/resolve-alpn": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/resolve-alpn/-/resolve-alpn-1.2.1.tgz", + "integrity": "sha512-0a1F4l73/ZFZOakJnQ3FvkJ2+gSTQWz/r2KE5OdDY0TxPm5h4GkqkWWfM47T7HsbnOtcJVEF4epCVy6u7Q3K+g==", + "dev": true, + "license": "MIT" + }, + "node_modules/responselike": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/responselike/-/responselike-2.0.1.tgz", + "integrity": "sha512-4gl03wn3hj1HP3yzgdI7d3lCkF95F21Pz4BPGvKHinyQzALR5CapwC8yIi0Rh58DEMQ/SguC03wFj2k0M/mHhw==", + "dev": true, + "license": "MIT", + "dependencies": { + "lowercase-keys": "^2.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/retry": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/retry/-/retry-0.12.0.tgz", + "integrity": "sha512-9LkiTwjUh6rT555DtE9rTX+BKByPfrMzEAtnlEtdEwr3Nkffwiihqe2bWADg+OQRjt9gl6ICdmB/ZFDCGAtSow==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 4" + } + }, + "node_modules/rimraf": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz", + "integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==", + "deprecated": "Rimraf versions prior to v4 are no longer supported", + "dev": true, + "license": "ISC", + "peer": true, + "dependencies": { + "glob": "^7.1.3" + }, + "bin": { + "rimraf": "bin.js" + } + }, + "node_modules/roarr": { + "version": "2.15.4", + "resolved": "https://registry.npmjs.org/roarr/-/roarr-2.15.4.tgz", + "integrity": "sha512-CHhPh+UNHD2GTXNYhPWLnU8ONHdI+5DI+4EYIAOaiD63rHeYlZvyh8P+in5999TTSFgUYuKUAjzRI4mdh/p+2A==", + "dev": true, + "license": "BSD-3-Clause", + "optional": true, + "dependencies": { + "boolean": "^3.0.1", + "detect-node": "^2.0.4", + "globalthis": "^1.0.1", + "json-stringify-safe": "^5.0.1", + "semver-compare": "^1.0.0", + "sprintf-js": "^1.1.2" + }, + "engines": { + "node": ">=8.0" + } + }, + "node_modules/safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "dev": true, + "license": "MIT" + }, + "node_modules/safe-stable-stringify": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/safe-stable-stringify/-/safe-stable-stringify-2.5.0.tgz", + "integrity": "sha512-b3rppTKm9T+PsVCBEOUR46GWI7fdOs00VKZ1+9c1EWDaDMvjQc6tUwuFyIprgGgTcWoVHSKrU8H31ZHA2e0RHA==", + "license": "MIT", + "engines": { + "node": ">=10" + } + }, + "node_modules/safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "license": "MIT" + }, + "node_modules/sanitize-filename": { + "version": "1.6.4", + "resolved": "https://registry.npmjs.org/sanitize-filename/-/sanitize-filename-1.6.4.tgz", + "integrity": "sha512-9ZyI08PsvdQl2r/bBIGubpVdR3RR9sY6RDiWFPreA21C/EFlQhmgo20UZlNjZMMZNubusLhAQozkA0Od5J21Eg==", + "dev": true, + "license": "WTFPL OR ISC", + "dependencies": { + "truncate-utf8-bytes": "^1.0.0" + } + }, + "node_modules/sax": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/sax/-/sax-1.6.1.tgz", + "integrity": "sha512-42tBVwLWnaQvW5zc4HbZrTuWccECCZfBi92FDuwtqxasH+JbPB3/FOKb1m222K42R4WxuxzzMsTswfzgtSu64Q==", + "license": "BlueOak-1.0.0", + "engines": { + "node": ">=11.0.0" + } + }, + "node_modules/selderee": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/selderee/-/selderee-0.12.0.tgz", + "integrity": "sha512-b1YMh3+DHZp59DLna3qVwQ5iOla/nrI6mLBNW02XxU77M3046Df6VLkoaJyFz20VsGIG5kkp+FK0kg4K4HnUFw==", + "license": "MIT", + "dependencies": { + "parseley": "~0.13.1" + }, + "funding": { + "url": "https://github.com/sponsors/KillyMXI" + } + }, + "node_modules/semver": { + "version": "7.8.5", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz", + "integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/semver-compare": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/semver-compare/-/semver-compare-1.0.0.tgz", + "integrity": "sha512-YM3/ITh2MJ5MtzaM429anh+x2jiLVjqILF4m4oyQB18W7Ggea7BfqdH/wGMK7dDiMghv/6WG7znWMwUDzJiXow==", + "dev": true, + "license": "MIT", + "optional": true + }, + "node_modules/serialize-error": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/serialize-error/-/serialize-error-7.0.1.tgz", + "integrity": "sha512-8I8TjW5KMOKsZQTvoxjuSIa7foAwPWGOts+6o7sgjz41/qMD9VQHEDxi6PBvK2l0MXUmqZyNpUK+T2tQaaElvw==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "type-fest": "^0.13.1" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "license": "MIT", + "dependencies": { + "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/signal-exit": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", + "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", + "dev": true, + "license": "ISC" + }, + "node_modules/simple-plist": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/simple-plist/-/simple-plist-1.3.1.tgz", + "integrity": "sha512-iMSw5i0XseMnrhtIzRb7XpQEXepa9xhWxGUojHBL43SIpQuDQkh3Wpy67ZbDzZVr6EKxvwVChnVpdl8hEVLDiw==", + "dev": true, + "license": "MIT", + "dependencies": { + "bplist-creator": "0.1.0", + "bplist-parser": "0.3.1", + "plist": "^3.0.5" + } + }, + "node_modules/simple-plist/node_modules/bplist-parser": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/bplist-parser/-/bplist-parser-0.3.1.tgz", + "integrity": "sha512-PyJxiNtA5T2PlLIeBot4lbp7rj4OadzjnMZD/G5zuBNt8ei/yCU7+wW0h2bag9vr8c+/WuRWmSxbqAl9hL1rBA==", + "dev": true, + "license": "MIT", + "dependencies": { + "big-integer": "1.6.x" + }, + "engines": { + "node": ">= 5.10.0" + } + }, + "node_modules/simple-update-notifier": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/simple-update-notifier/-/simple-update-notifier-2.0.0.tgz", + "integrity": "sha512-a2B9Y0KlNXl9u/vsW6sTIu9vGEpfKu2wRV6l1H3XEas/0gUIzGzBoP/IouTcUQbm9JWZLH3COxyn03TYlFax6w==", + "dev": true, + "license": "MIT", + "dependencies": { + "semver": "^7.5.3" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/sisteransi": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/sisteransi/-/sisteransi-1.0.5.tgz", + "integrity": "sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==", + "dev": true, + "license": "MIT" + }, + "node_modules/slice-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-4.0.0.tgz", + "integrity": "sha512-qMCMfhY040cVHT43K9BFygqYbUPFZKHOg7K73mtTWJRb8pyP3fzf4Ixd5SzdEJQ6MRUg/WBnOLxghZtKKurENQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.0.0", + "astral-regex": "^2.0.0", + "is-fullwidth-code-point": "^3.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/slice-ansi?sponsor=1" + } + }, + "node_modules/smart-buffer": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-4.2.0.tgz", + "integrity": "sha512-94hK0Hh8rPqQl2xXc3HsaBoOXKV20MToPkcXvwbISWLEs+64sBq5kFgn2kJDHb1Pry9yrP0dxrCI9RRci7RXKg==", + "license": "MIT", + "engines": { + "node": ">= 6.0.0", + "npm": ">= 3.0.0" + } + }, + "node_modules/socks": { + "version": "2.8.10", + "resolved": "https://registry.npmjs.org/socks/-/socks-2.8.10.tgz", + "integrity": "sha512-e0VyvkVTwVYViNovRkZ9aodhxVlyoMn7eJhVUPxZ+eK9P/7CBkxvvsBOHqFPEH416726W8tLXXXjKwqgTErrCQ==", + "license": "MIT", + "dependencies": { + "ip-address": "^10.1.1", + "smart-buffer": "^4.2.0" + }, + "engines": { + "node": ">= 10.0.0", + "npm": ">= 3.0.0" + } + }, + "node_modules/sonic-boom": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/sonic-boom/-/sonic-boom-4.2.1.tgz", + "integrity": "sha512-w6AxtubXa2wTXAUsZMMWERrsIRAdrK0Sc+FUytWvYAhBJLyuI4llrMIC1DtlNSdI99EI86KZum2MMq3EAZlF9Q==", + "license": "MIT", + "dependencies": { + "atomic-sleep": "^1.0.0" + } + }, + "node_modules/source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/source-map-support": { + "version": "0.5.21", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", + "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==", + "dev": true, + "license": "MIT", + "dependencies": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + } + }, + "node_modules/split2": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/split2/-/split2-4.2.0.tgz", + "integrity": "sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg==", + "license": "ISC", + "engines": { + "node": ">= 10.x" + } + }, + "node_modules/sprintf-js": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.3.tgz", + "integrity": "sha512-Oo+0REFV59/rz3gfJNKQiBlwfHaSESl1pcGyABQsnnIfWOFt6JNj5gCog2U6MLZ//IGYD+nA8nI+mTShREReaA==", + "dev": true, + "license": "BSD-3-Clause", + "optional": true + }, + "node_modules/stat-mode": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/stat-mode/-/stat-mode-1.0.0.tgz", + "integrity": "sha512-jH9EhtKIjuXZ2cWxmXS8ZP80XyC3iasQxMDV8jzhNJpfDb7VbQLVW4Wvsxz9QZvzV+G4YoSfBUVKDOyxLzi/sg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 6" + } + }, + "node_modules/stream-buffers": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/stream-buffers/-/stream-buffers-2.2.0.tgz", + "integrity": "sha512-uyQK/mx5QjHun80FLJTfaWE7JtwfRMKBLkMne6udYOmvH0CawotVa7TfgYHzAnpphn4+TweIx1QKMnRIbipmUg==", + "dev": true, + "license": "Unlicense", + "engines": { + "node": ">= 0.10.0" + } + }, + "node_modules/string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dev": true, + "license": "MIT", + "dependencies": { + "safe-buffer": "~5.1.0" + } + }, + "node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "license": "MIT", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/sumchecker": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/sumchecker/-/sumchecker-3.0.1.tgz", + "integrity": "sha512-MvjXzkz/BOfyVDkG0oFOtBxHX2u3gKbMHIF/dXblZsgD3BWOFLmHovIpZY7BykJdAjcqRCBi1WYBNdEC9yI7vg==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "debug": "^4.1.0" + }, + "engines": { + "node": ">= 8.0" + } + }, + "node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "license": "MIT", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/tar": { + "version": "7.5.22", + "resolved": "https://registry.npmjs.org/tar/-/tar-7.5.22.tgz", + "integrity": "sha512-MFO/QzvtAOmJbkhOaCTvbGcFN9L9b+JunIsDwaKljSOdcLMea3NJ1k9Usz/rjdfSXTq4dfzfeS7W4p4YOAAHeA==", + "dev": true, + "license": "BlueOak-1.0.0", + "dependencies": { + "@isaacs/fs-minipass": "^4.0.0", + "chownr": "^3.0.0", + "minipass": "^7.1.2", + "minizlib": "^3.1.0", + "yallist": "^5.0.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/tar/node_modules/yallist": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-5.0.0.tgz", + "integrity": "sha512-YgvUTfwqyc7UXVMrB+SImsVYSmTS8X/tSrtdNZMImM+n7+QTriRXyXim0mBrTXNeqzVF0KWGgHPeiyViFFrNDw==", + "dev": true, + "license": "BlueOak-1.0.0", + "engines": { + "node": ">=18" + } + }, + "node_modules/temp": { + "version": "0.9.4", + "resolved": "https://registry.npmjs.org/temp/-/temp-0.9.4.tgz", + "integrity": "sha512-yYrrsWnrXMcdsnu/7YMYAofM1ktpL5By7vZhf15CrXijWWrEYZks5AXBudalfSWJLlnen/QUJUB5aoB0kqZUGA==", + "dev": true, + "license": "MIT", + "peer": true, + "dependencies": { + "mkdirp": "^0.5.1", + "rimraf": "~2.6.2" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/temp-file": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/temp-file/-/temp-file-3.4.0.tgz", + "integrity": "sha512-C5tjlC/HCtVUOi3KWVokd4vHVViOmGjtLwIh4MuzPo/nMYTV/p1urt3RnMz2IWXDdKEGJH3k5+KPxtqRsUYGtg==", + "dev": true, + "license": "MIT", + "dependencies": { + "async-exit-hook": "^2.0.1", + "fs-extra": "^10.0.0" + } + }, + "node_modules/thread-stream": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/thread-stream/-/thread-stream-4.2.0.tgz", + "integrity": "sha512-e2zZ96wSChazBsbENf/Pcm/4swHt2cEKQ92rhUjkL9GCKiTDJIaTBenjE/m9DXi0QBmTMDkFDdOomUy20A1tDQ==", + "license": "MIT", + "dependencies": { + "real-require": "^1.0.0" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/thread-stream/node_modules/real-require": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/real-require/-/real-require-1.0.0.tgz", + "integrity": "sha512-P4nbQYQfePJxRSmY+v/KINxVucm4NF3p3s7pJveMTtom52FR4YGltUQLB8idDXwDDWW+eYrWDFbuzUnjoWHF7g==", + "license": "MIT" + }, + "node_modules/through2": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/through2/-/through2-4.0.2.tgz", + "integrity": "sha512-iOqSav00cVxEEICeD7TjLB1sueEL+81Wpzp2bY17uZjZN0pWZPuo4suZ/61VujxmqSGFfgOcNuTZ85QJwNZQpw==", + "dev": true, + "license": "MIT", + "dependencies": { + "readable-stream": "3" + } + }, + "node_modules/through2/node_modules/readable-stream": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", + "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", + "dev": true, + "license": "MIT", + "dependencies": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/tiny-async-pool": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/tiny-async-pool/-/tiny-async-pool-1.3.0.tgz", + "integrity": "sha512-01EAw5EDrcVrdgyCLgoSPvqznC0sVxDSVeiOz09FUpjh71G79VCqneOr+xvt7T1r76CF6ZZfPjHorN2+d+3mqA==", + "dev": true, + "license": "MIT", + "dependencies": { + "semver": "^5.5.0" + } + }, + "node_modules/tiny-async-pool/node_modules/semver": { + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz", + "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver" + } + }, + "node_modules/tinyglobby": { + "version": "0.2.17", + "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.17.tgz", + "integrity": "sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==", + "dev": true, + "license": "MIT", + "dependencies": { + "fdir": "^6.5.0", + "picomatch": "^4.0.4" + }, + "engines": { + "node": ">=12.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/SuperchupuDev" + } + }, + "node_modules/tlds": { + "version": "1.261.0", + "resolved": "https://registry.npmjs.org/tlds/-/tlds-1.261.0.tgz", + "integrity": "sha512-QXqwfEl9ddlGBaRFXIvNKK6OhipSiLXuRuLJX5DErz0o0Q0rYxulWLdFryTkV5PkdZct5iMInwYEGe/eR++1AA==", + "license": "MIT", + "bin": { + "tlds": "bin.js" + } + }, + "node_modules/tmp": { + "version": "0.2.7", + "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.7.tgz", + "integrity": "sha512-e0votIpp4Uo2AJYSzVHV6xCcawuiez3DzqDAbrTc3YxBkplN6e+dM13ZeIcZnDg/QpSuU2zfZ3rzwY8ukEnaXw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=14.14" + } + }, + "node_modules/tmp-promise": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/tmp-promise/-/tmp-promise-3.0.3.tgz", + "integrity": "sha512-RwM7MoPojPxsOBYnyd2hy0bxtIlVrihNs9pj5SUvY8Zz1sQcQG2tG1hSr8PDxfgEB8RNKDhqbIlroIarSNDNsQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "tmp": "^0.2.0" + } + }, + "node_modules/tree-kill": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/tree-kill/-/tree-kill-1.2.2.tgz", + "integrity": "sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==", + "dev": true, + "license": "MIT", + "bin": { + "tree-kill": "cli.js" + } + }, + "node_modules/truncate-utf8-bytes": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/truncate-utf8-bytes/-/truncate-utf8-bytes-1.0.2.tgz", + "integrity": "sha512-95Pu1QXQvruGEhv62XCMO3Mm90GscOCClvrIUwCM0PYOXK3kaF3l3sIHxx71ThJfcbM2O5Au6SO3AWCSEfW4mQ==", + "dev": true, + "license": "WTFPL", + "dependencies": { + "utf8-byte-length": "^1.0.1" + } + }, + "node_modules/tsdav": { + "version": "2.3.4", + "resolved": "https://registry.npmjs.org/tsdav/-/tsdav-2.3.4.tgz", + "integrity": "sha512-JAmWfNM0WFmzAfjE0s0881rMYGFiyl2HVtktnh37yopoA6DjrdCRGrFw4jQEFwMwual5/ThCOYbULt9bsTm1Ww==", + "license": "MIT", + "dependencies": { + "debug": "4.4.3", + "xml-js": "1.6.11" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/tslib": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", + "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", + "license": "0BSD" + }, + "node_modules/type-fest": { + "version": "0.13.1", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.13.1.tgz", + "integrity": "sha512-34R7HTnG0XIJcBSn5XhDd7nNFPRcXYRZrBB2O2jdKqYODldSzBAqzsWoZYYvduky73toYS/ESqxPvkDf/F0XMg==", + "dev": true, + "license": "(MIT OR CC0-1.0)", + "optional": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/uc.micro": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-2.1.0.tgz", + "integrity": "sha512-ARDJmphmdvUk6Glw7y9DQ2bFkKBHwQHLi2lsaH6PPmz/Ka9sFOBsBluozhDltWmnv9u/cF6Rt87znRTPV+yp/A==", + "license": "MIT" + }, + "node_modules/undici": { + "version": "7.30.0", + "resolved": "https://registry.npmjs.org/undici/-/undici-7.30.0.tgz", + "integrity": "sha512-dkrQXeHSaoamnItlYbmzG0wFYrM0ZwDxCIg0A7aKjTyyhh9svRzCNFEzV+Vm05/yehjCzjDZ31KXfGEjYSztDQ==", + "dev": true, + "license": "MIT", + "optional": true, + "engines": { + "node": ">=20.18.1" + } + }, + "node_modules/undici-types": { + "version": "7.24.6", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.24.6.tgz", + "integrity": "sha512-WRNW+sJgj5OBN4/0JpHFqtqzhpbnV0GuB+OozA9gCL7a993SmU+1JBZCzLNxYsbMfIeDL+lTsphD5jN5N+n0zg==", + "dev": true, + "license": "MIT" + }, + "node_modules/universalify": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz", + "integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 10.0.0" + } + }, + "node_modules/untildify": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/untildify/-/untildify-4.0.0.tgz", + "integrity": "sha512-KK8xQ1mkzZeg9inewmFVDNkg3l5LUhoq9kN6iWYB/CC9YMG8HA+c1Q8HwDe6dEX7kErrEVNVBO3fWsVq5iDgtw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/unzipper": { + "version": "0.12.5", + "resolved": "https://registry.npmjs.org/unzipper/-/unzipper-0.12.5.tgz", + "integrity": "sha512-tXYOi9R57Uj/2Z25SOs5RRSzq886MBQj2gY8dPL+xl/kv6s6SvByoKfAtvfVeEuhntWDgjd2o9p2lb4TVPAz0A==", + "dev": true, + "license": "MIT", + "dependencies": { + "bluebird": "~3.7.2", + "duplexer2": "~0.1.4", + "fs-extra": "11.3.1", + "graceful-fs": "^4.2.2", + "node-int64": "^0.4.0" + } + }, + "node_modules/unzipper/node_modules/fs-extra": { + "version": "11.3.1", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-11.3.1.tgz", + "integrity": "sha512-eXvGGwZ5CL17ZSwHWd3bbgk7UUpF6IFHtP57NYYakPvHOs8GDgDe5KJI36jIJzDkJ6eJjuzRA8eBQb6SkKue0g==", + "dev": true, + "license": "MIT", + "dependencies": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + }, + "engines": { + "node": ">=14.14" + } + }, + "node_modules/utf8-byte-length": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/utf8-byte-length/-/utf8-byte-length-1.0.5.tgz", + "integrity": "sha512-Xn0w3MtiQ6zoz2vFyUVruaCL53O/DwUvkEeOvj+uulMm0BkUGYWmBYVyElqZaSLhY6ZD0ulfU3aBra2aVT4xfA==", + "dev": true, + "license": "(WTFPL OR MIT)" + }, + "node_modules/util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", + "dev": true, + "license": "MIT" + }, + "node_modules/uuid": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-7.0.3.tgz", + "integrity": "sha512-DPSke0pXhTZgoF/d+WSt2QaKMCFSfx7QegxEWT+JOuHF5aWrKEn0G+ztjuJg/gG8/ItK+rbPCD/yNv8yyih6Cg==", + "deprecated": "uuid@10 and below is no longer supported. For ESM codebases, update to uuid@latest. For CommonJS codebases, use uuid@11 (but be aware this version will likely be deprecated in 2028).", + "dev": true, + "license": "MIT", + "bin": { + "uuid": "dist/bin/uuid" + } + }, + "node_modules/v8-compile-cache": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.4.0.tgz", + "integrity": "sha512-ocyWc3bAHBB/guyqJQVI5o4BZkPhznPYUG2ea80Gond/BgNWpap8TOmLSeeQG7bnh2KMISxskdADG59j7zruhw==", + "license": "MIT" + }, + "node_modules/webcrypto-core": { + "version": "1.9.2", + "resolved": "https://registry.npmjs.org/webcrypto-core/-/webcrypto-core-1.9.2.tgz", + "integrity": "sha512-gsXecm82UQNlTBURJGuqOWy1Ww08S3kZUcr3aOJS02Pk0xLtkfeUAVC0u0xhgdonFme80edSJUIJyuvL/7250Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@peculiar/asn1-schema": "^2.7.0", + "@peculiar/json-schema": "^1.1.12", + "@peculiar/utils": "^2.0.2", + "asn1js": "^3.0.10", + "tslib": "^2.8.1" + } + }, + "node_modules/which": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/which/-/which-5.0.0.tgz", + "integrity": "sha512-JEdGzHwwkrbWoGOlIHqQ5gtprKGOenpDHpxE9zVR1bWbOtYRyPPHMe9FaP6x61CmNaTThSkb0DAJte5jD+DmzQ==", + "dev": true, + "license": "ISC", + "dependencies": { + "isexe": "^3.1.1" + }, + "bin": { + "node-which": "bin/which.js" + }, + "engines": { + "node": "^18.17.0 || >=20.5.0" + } + }, + "node_modules/wrap-ansi": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", + "dev": true, + "license": "ISC" + }, + "node_modules/xcode": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/xcode/-/xcode-3.0.1.tgz", + "integrity": "sha512-kCz5k7J7XbJtjABOvkc5lJmkiDh8VhjVCGNiqdKCscmVpdVUpEAyXv1xmCLkQJ5dsHqx3IPO4XW+NTDhU/fatA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "simple-plist": "^1.1.0", + "uuid": "^7.0.3" + }, + "engines": { + "node": ">=10.0.0" + } + }, + "node_modules/xml-js": { + "version": "1.6.11", + "resolved": "https://registry.npmjs.org/xml-js/-/xml-js-1.6.11.tgz", + "integrity": "sha512-7rVi2KMfwfWFl+GpPg6m80IVMWXLRjO+PxTq7V2CDhoGak0wzYzFgUY2m4XJ47OGdXd8eLE8EmwfAmdjw7lC1g==", + "license": "MIT", + "dependencies": { + "sax": "^1.2.4" + }, + "bin": { + "xml-js": "bin/cli.js" + } + }, + "node_modules/xml2js": { + "version": "0.6.2", + "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.6.2.tgz", + "integrity": "sha512-T4rieHaC1EXcES0Kxxj4JWgaUQHDk+qwHcYOCFHfiwKz7tOVPLq7Hjq9dM1WCMhylqMEfP7hMcOIChvotiZegA==", + "dev": true, + "license": "MIT", + "dependencies": { + "sax": ">=0.6.0", + "xmlbuilder": "~11.0.0" + }, + "engines": { + "node": ">=4.0.0" + } + }, + "node_modules/xml2js/node_modules/xmlbuilder": { + "version": "11.0.1", + "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-11.0.1.tgz", + "integrity": "sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4.0" + } + }, + "node_modules/xmlbuilder": { + "version": "15.1.1", + "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-15.1.1.tgz", + "integrity": "sha512-yMqGBqtXyeN1e3TGYvgNgDVZ3j84W4cwkOXQswghol6APgZWaff9lnbvN7MHYJOiXsvGPXtjTYJEiC9J2wv9Eg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8.0" + } + }, + "node_modules/y18n": { + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", + "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=10" + } + }, + "node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true, + "license": "ISC" + }, + "node_modules/yargs": { + "version": "17.7.3", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.3.tgz", + "integrity": "sha512-GZtjxm/J/4TSxuL3FNYjCmLktBTnIw/rVmKSIyKeYAZpmJB2ig9VauCC5xsa82GNKVKDAqpOn3KVzNt0zmrU0g==", + "dev": true, + "license": "MIT", + "dependencies": { + "cliui": "^8.0.1", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.3", + "y18n": "^5.0.5", + "yargs-parser": "^21.1.1" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/yargs-parser": { + "version": "21.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", + "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/yauzl": { + "version": "2.10.0", + "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.10.0.tgz", + "integrity": "sha512-p4a9I6X6nu6IhoGmBqAcbJy1mlC4j27vEPZX9F4L4/vZT3Lyq1VkFHw/V/PUcB9Buo+DG3iHkT0x3Qya58zc3g==", + "dev": true, + "license": "MIT", + "dependencies": { + "buffer-crc32": "~0.2.3", + "fd-slicer": "~1.1.0" + } + }, + "node_modules/yocto-queue": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", + "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + } + } +} diff --git a/package.json b/package.json index 07bb931..650db22 100644 --- a/package.json +++ b/package.json @@ -1,110 +1,111 @@ -{ - "name": "ep-mail", - "version": "0.5.1", - "private": true, - "description": "Eternity Project mail client", - "homepage": "https://git.eternityproject.fi/thuttu/ep-mail-client", - "author": { - "name": "Eternity Project", - "email": "tero.huttunen@eternityproject.fi" - }, - "desktopName": "ep-mail", - "main": "desktop/main.cjs", - "scripts": { - "start": "electron .", - "dev": "electron .", - "dist:win": "electron-builder --win", - "dist:win:installer": "electron-builder --win nsis", - "dist:win:portable": "electron-builder --win portable", - "dist:linux": "electron-builder --linux AppImage deb", - "dist:linux:appimage": "electron-builder --linux AppImage", - "dist:linux:deb": "electron-builder --linux deb", - "bump:build": "npm version patch --no-git-tag-version", - "test": "node --test tests/", - "build:android-web": "node scripts/prepare-android-web.cjs", - "android:sync": "npm run build:android-web && cap sync android", - "android:open": "npm run android:sync && cap open android", - "android:apk": "npm run android:sync && node scripts/build-android-apk.cjs", - "build:all": "powershell -NoProfile -ExecutionPolicy Bypass -File scripts/build-all.ps1" - }, - "devDependencies": { - "@capacitor/cli": "^8.5.2", - "electron": "44.5.1", - "electron-builder": "26.17.0", - "esbuild": "^0.28.2" - }, - "build": { - "appId": "studio.daybreak.mail", - "productName": "ep-mail", - "asar": true, - "files": [ - "index.html", - "platform-bridge.js", - "platform-bridge-loader.js", - "styles.css", - "branding.css", - "renderer-state.js", - "mail-content-security.js", - "renderer-mail-api.js", - "app.js", - "mail-ui.js", - "productivity.js", - "account-ui.js", - "dav-ui.js", - "shortcuts.js", - "attachments.js", - "pgp-ui.js", - "pgp-mail-ui.js", - "icon.svg", - "icon.ico", - "logo-ep-daylight.svg", - "logo-ep-wasteland.svg", - "manifest.webmanifest", - "service-worker.js", - "snooze-ui.js", - "desktop/**/*" - ], - "directories": { - "output": "release" - }, - "win": { - "icon": "icon.ico", - "target": [ - "nsis", - "portable" - ] - }, - "nsis": { - "oneClick": false, - "allowToChangeInstallationDirectory": true, - "createDesktopShortcut": true, - "createStartMenuShortcut": true - }, - "linux": { - "category": "Office", - "syncDesktopName": true, - "target": [ - "AppImage", - "deb" - ], - "maintainer": "Tero Huttunen ", - "synopsis": "A calmer place for mail, people, and plans" - } - }, - "allowScripts": { - "electron@44.5.1": true, - "electron-winstaller@5.4.0": true, - "esbuild@0.28.2": true - }, - "dependencies": { - "@capacitor/android": "^8.5.2", - "@capacitor/core": "^8.5.2", - "ical.js": "^2.2.1", - "imapflow": "2.2.1", - "mailparser": "3.9.33", - "nodemailer": "10.0.9", - "openpgp": "^6.3.2", - "tsdav": "^2.3.4", - "v8-compile-cache": "^2.4.0" - } -} +{ + "name": "ep-mail", + "version": "0.5.2", + "private": true, + "description": "Eternity Project mail client", + "homepage": "https://git.eternityproject.fi/thuttu/ep-mail-client", + "author": { + "name": "Eternity Project", + "email": "tero.huttunen@eternityproject.fi" + }, + "desktopName": "ep-mail", + "main": "desktop/main.cjs", + "scripts": { + "start": "electron .", + "dev": "electron .", + "dist:win": "electron-builder --win", + "dist:win:installer": "electron-builder --win nsis", + "dist:win:portable": "electron-builder --win portable", + "dist:linux": "electron-builder --linux AppImage deb", + "dist:linux:appimage": "electron-builder --linux AppImage", + "dist:linux:deb": "electron-builder --linux deb", + "bump:build": "npm version patch --no-git-tag-version", + "test": "node --test tests/", + "build:android-web": "node scripts/prepare-android-web.cjs", + "android:sync": "npm run build:android-web && cap sync android", + "android:open": "npm run android:sync && cap open android", + "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", + "build:all": "powershell -NoProfile -ExecutionPolicy Bypass -File scripts/build-all.ps1" + }, + "devDependencies": { + "@capacitor/cli": "^8.5.2", + "electron": "44.5.1", + "electron-builder": "26.17.0", + "esbuild": "^0.28.2" + }, + "build": { + "appId": "studio.daybreak.mail", + "productName": "ep-mail", + "asar": true, + "files": [ + "index.html", + "platform-bridge.js", + "platform-bridge-loader.js", + "styles.css", + "branding.css", + "renderer-state.js", + "mail-content-security.js", + "renderer-mail-api.js", + "app.js", + "mail-ui.js", + "productivity.js", + "account-ui.js", + "dav-ui.js", + "shortcuts.js", + "attachments.js", + "pgp-ui.js", + "pgp-mail-ui.js", + "icon.svg", + "icon.ico", + "logo-ep-daylight.svg", + "logo-ep-wasteland.svg", + "manifest.webmanifest", + "service-worker.js", + "snooze-ui.js", + "desktop/**/*" + ], + "directories": { + "output": "release" + }, + "win": { + "icon": "icon.ico", + "target": [ + "nsis", + "portable" + ] + }, + "nsis": { + "oneClick": false, + "allowToChangeInstallationDirectory": true, + "createDesktopShortcut": true, + "createStartMenuShortcut": true + }, + "linux": { + "category": "Office", + "syncDesktopName": true, + "target": [ + "AppImage", + "deb" + ], + "maintainer": "Tero Huttunen ", + "synopsis": "A calmer place for mail, people, and plans" + } + }, + "allowScripts": { + "electron@44.5.1": true, + "electron-winstaller@5.4.0": true, + "esbuild@0.28.2": true + }, + "dependencies": { + "@capacitor/android": "^8.5.2", + "@capacitor/core": "^8.5.2", + "ical.js": "^2.2.1", + "imapflow": "2.2.1", + "mailparser": "3.9.33", + "nodemailer": "10.0.9", + "openpgp": "^6.3.2", + "tsdav": "^2.3.4", + "v8-compile-cache": "^2.4.0" + } +} diff --git a/pgp-mail-ui.js b/pgp-mail-ui.js index e0e7544..d5e701b 100644 --- a/pgp-mail-ui.js +++ b/pgp-mail-ui.js @@ -6,193 +6,193 @@ const selectAllPgpMailUi = pgpMailUi.selectAll; const toastPgpMailUi = pgpMailUi.toast; const escapePgpMailUi = pgpMailUi.escapeHtml; const pgpApi = () => window.daybreakMail?.pgp; - -function pgpAskPassphrase(title, detail) { - return new Promise(resolve => { - const overlay = document.createElement('div'); - overlay.className = 'modal-overlay pgp-prompt'; - overlay.innerHTML = `
`; - overlay.querySelector('.modal-head span').textContent = title; - overlay.querySelector('.account-note').textContent = detail; - const finish = value => { overlay.remove(); resolve(value); }; - overlay.querySelector('form').onsubmit = event => { - event.preventDefault(); - const value = overlay.querySelector('input').value; - if (value) finish(value); - }; - overlay.querySelector('[data-cancel]').onclick = () => finish(null); - overlay.addEventListener('keydown', event => { if (event.key === 'Escape') { event.stopPropagation(); finish(null); } }); - document.body.append(overlay); - overlay.querySelector('input').focus(); - }); -} - -function pgpFormatFingerprint(value) { - return String(value || '').match(/.{1,4}/g)?.join(' ') || ''; -} - -function pgpSignatureHtml(signatures, encrypted) { - const items = Array.isArray(signatures) ? signatures : []; - const lock = encrypted ? '🔒 Encrypted. ' : ''; - if (!items.length) { - return encrypted ? `
${lock}Not signedThe sender is not authenticated: anyone with your public key could have written this.
` : ''; - } - return items.map(signature => { - const trust = signature.trust === 'verified' ? 'verified key' : signature.trust === 'trusted' ? 'trusted key' : 'key not verified yet'; - const notes = []; - if (signature.keyChanged) notes.push('The sender previously used a different key. Confirm the change with them before trusting this message.'); - if (signature.mismatch) notes.push('The signing key does not belong to the sender address.'); - if (signature.status === 'valid') { - const level = signature.keyChanged || signature.mismatch ? 'bad' : signature.trust === 'unknown' ? 'warn' : 'ok'; + +function pgpAskPassphrase(title, detail) { + return new Promise(resolve => { + const overlay = document.createElement('div'); + overlay.className = 'modal-overlay pgp-prompt'; + overlay.innerHTML = `
`; + overlay.querySelector('.modal-head span').textContent = title; + overlay.querySelector('.account-note').textContent = detail; + const finish = value => { overlay.remove(); resolve(value); }; + overlay.querySelector('form').onsubmit = event => { + event.preventDefault(); + const value = overlay.querySelector('input').value; + if (value) finish(value); + }; + overlay.querySelector('[data-cancel]').onclick = () => finish(null); + overlay.addEventListener('keydown', event => { if (event.key === 'Escape') { event.stopPropagation(); finish(null); } }); + document.body.append(overlay); + overlay.querySelector('input').focus(); + }); +} + +function pgpFormatFingerprint(value) { + return String(value || '').match(/.{1,4}/g)?.join(' ') || ''; +} + +function pgpSignatureHtml(signatures, encrypted) { + const items = Array.isArray(signatures) ? signatures : []; + const lock = encrypted ? '🔒 Encrypted. ' : ''; + if (!items.length) { + return encrypted ? `
${lock}Not signedThe sender is not authenticated: anyone with your public key could have written this.
` : ''; + } + return items.map(signature => { + const trust = signature.trust === 'verified' ? 'verified key' : signature.trust === 'trusted' ? 'trusted key' : 'key not verified yet'; + const notes = []; + if (signature.keyChanged) notes.push('The sender previously used a different key. Confirm the change with them before trusting this message.'); + if (signature.mismatch) notes.push('The signing key does not belong to the sender address.'); + if (signature.status === 'valid') { + const level = signature.keyChanged || signature.mismatch ? 'bad' : signature.trust === 'unknown' ? 'warn' : 'ok'; return `
${lock}Valid signature from ${escapePgpMailUi(signature.email || 'a known key')}${escapePgpMailUi(trust)} · ${escapePgpMailUi(pgpFormatFingerprint(signature.fingerprint))}${notes.map(note => `${escapePgpMailUi(note)}`).join('')}
`; - } - if (signature.status === 'unknown-key') { + } + if (signature.status === 'unknown-key') { return `
${lock}Signed with an unknown keyKey ID ${escapePgpMailUi(signature.keyId)} is not in your contacts, so the signature cannot be checked.${notes.map(note => `${escapePgpMailUi(note)}`).join('')}
`; - } - return ``; - }).join(''); -} - -async function pgpAddAttachedKey(key) { - const emails = key.emails.join(', ') || 'unknown address'; - if (!confirm(`Add this public key for ${emails}?\nFingerprint: ${pgpFormatFingerprint(key.fingerprint)}\n\nCompare the fingerprint with the owner before relying on it.`)) return; - try { - const result = await pgpApi().addContact({ armoredKey: key.armoredKey, source: 'message' }); - toastPgpMailUi(result.keyChangedFrom?.length ? 'Key added. Warning: you already had a different key for this address.' : 'Public key added to your contacts'); - } catch (error) { - toastPgpMailUi(error.message || 'Could not add the key'); - } -} - -function pgpRenderReaderState(message) { - const reader = selectPgpMailUi('#reader-pane'); - const header = reader.querySelector('.reader-header'); - if (!header) return; - reader.querySelectorAll('.pgp-status, .pgp-banner').forEach(node => node.remove()); - let html = ''; - if (message.encrypted && !message.pgpDecrypted) { - html = `
🔒 This message is encryptedUnlock it with your key passphrase to read it.
`; - } else if (message.encrypted) { - html = pgpSignatureHtml(message.pgpResult?.signatures, true); - } else if (message.pgpSignatures) { - html = pgpSignatureHtml(message.pgpSignatures, false); - } - const keys = message.pgpResult?.attachedKeys || []; + } + return ``; + }).join(''); +} + +async function pgpAddAttachedKey(key) { + const emails = key.emails.join(', ') || 'unknown address'; + if (!confirm(`Add this public key for ${emails}?\nFingerprint: ${pgpFormatFingerprint(key.fingerprint)}\n\nCompare the fingerprint with the owner before relying on it.`)) return; + try { + const result = await pgpApi().addContact({ armoredKey: key.armoredKey, source: 'message' }); + toastPgpMailUi(result.keyChangedFrom?.length ? 'Key added. Warning: you already had a different key for this address.' : 'Public key added to your contacts'); + } catch (error) { + toastPgpMailUi(error.message || 'Could not add the key'); + } +} + +function pgpRenderReaderState(message) { + const reader = selectPgpMailUi('#reader-pane'); + const header = reader.querySelector('.reader-header'); + if (!header) return; + reader.querySelectorAll('.pgp-status, .pgp-banner').forEach(node => node.remove()); + let html = ''; + if (message.encrypted && !message.pgpDecrypted) { + html = `
🔒 This message is encryptedUnlock it with your key passphrase to read it.
`; + } else if (message.encrypted) { + html = pgpSignatureHtml(message.pgpResult?.signatures, true); + } else if (message.pgpSignatures) { + html = pgpSignatureHtml(message.pgpSignatures, false); + } + const keys = message.pgpResult?.attachedKeys || []; header.insertAdjacentHTML('afterend', html + keys.map((key, index) => `
Public key attached${escapePgpMailUi(key.emails.join(', ') || 'unknown address')} · ${escapePgpMailUi(pgpFormatFingerprint(key.fingerprint))}
`).join('')); - reader.querySelectorAll('[data-pgp-key]').forEach(button => { - button.onclick = () => pgpAddAttachedKey(keys[Number(button.dataset.pgpKey)]); - }); - const unlock = selectPgpMailUi('#pgp-unlock'); - if (unlock) unlock.onclick = () => pgpUnlockMessage(message, true); -} - -async function pgpUnlockMessage(message, interactive) { - let passphrase = null; - for (let attempt = 0; attempt < 3; attempt += 1) { - let result; - try { - result = await pgpApi().decryptMessage({ folder: message.sourceFolder || 'Inbox', uid: message.uid, passphrase }); - } catch (error) { - toastPgpMailUi(error.message || 'Could not open this message'); - return; - } - if (result.ok) { - Object.assign(message, { - body: result.body, html: result.html, links: result.links, attachments: result.attachments, attachment: result.attachment, size: result.size, - snippet: 'Encrypted message', pgpDecrypted: true, pgpResult: { signatures: result.signatures, attachedKeys: result.attachedKeys } - }); + reader.querySelectorAll('[data-pgp-key]').forEach(button => { + button.onclick = () => pgpAddAttachedKey(keys[Number(button.dataset.pgpKey)]); + }); + const unlock = selectPgpMailUi('#pgp-unlock'); + if (unlock) unlock.onclick = () => pgpUnlockMessage(message, true); +} + +async function pgpUnlockMessage(message, interactive) { + let passphrase = null; + for (let attempt = 0; attempt < 3; attempt += 1) { + let result; + try { + result = await pgpApi().decryptMessage({ folder: message.sourceFolder || 'Inbox', uid: message.uid, passphrase }); + } catch (error) { + toastPgpMailUi(error.message || 'Could not open this message'); + return; + } + if (result.ok) { + Object.assign(message, { + body: result.body, html: result.html, links: result.links, attachments: result.attachments, attachment: result.attachment, size: result.size, + snippet: 'Encrypted message', pgpDecrypted: true, pgpResult: { signatures: result.signatures, attachedKeys: result.attachedKeys } + }); if (pgpMailUi.state.activeMessage === message.id) pgpMailUi.openMessage(message.id); - return; - } - if (result.code === 'PASSPHRASE_REQUIRED' || result.code === 'BAD_PASSPHRASE') { - if (!interactive) { pgpRenderReaderState(message); return; } - passphrase = await pgpAskPassphrase('Unlock encrypted message', result.code === 'BAD_PASSPHRASE' ? 'That passphrase was incorrect. Try again.' : `Enter the passphrase for ${result.email || 'your key'}.`); - if (passphrase === null) return; - continue; - } - const text = selectPgpMailUi('#pgp-banner-text'); - if (text) text.textContent = result.message; - else toastPgpMailUi(result.message); - return; - } -} - + return; + } + if (result.code === 'PASSPHRASE_REQUIRED' || result.code === 'BAD_PASSPHRASE') { + if (!interactive) { pgpRenderReaderState(message); return; } + passphrase = await pgpAskPassphrase('Unlock encrypted message', result.code === 'BAD_PASSPHRASE' ? 'That passphrase was incorrect. Try again.' : `Enter the passphrase for ${result.email || 'your key'}.`); + if (passphrase === null) return; + continue; + } + const text = selectPgpMailUi('#pgp-banner-text'); + if (text) text.textContent = result.message; + else toastPgpMailUi(result.message); + return; + } +} + pgpMailUi.wrapOpenMessage(baseOpenMessage => function (id) { baseOpenMessage(id); const message = pgpMailUi.state.messages.find(item => item.id === id); if (!message || !pgpApi()) return; - pgpRenderReaderState(message); - if (message.encrypted && !message.pgpDecrypted && !message.pgpAutoTried) { - message.pgpAutoTried = true; - void pgpUnlockMessage(message, false); - } + pgpRenderReaderState(message); + if (message.encrypted && !message.pgpDecrypted && !message.pgpAutoTried) { + message.pgpAutoTried = true; + void pgpUnlockMessage(message, false); + } }); // Compose: encrypt/sign options. pgpMailUi.wrapShowCompose(baseShowCompose => function (reply, forward = false) { - baseShowCompose(reply, forward); - const footer = selectPgpMailUi('#modal-root .compose-footer'); - if (!footer || !pgpApi()) return; - const box = document.createElement('div'); - box.className = 'pgp-compose'; - box.innerHTML = ``; - footer.prepend(box); - let touched = false; - const encrypt = selectPgpMailUi('#pgp-encrypt'); - const sign = selectPgpMailUi('#pgp-sign'); - if (reply?.encrypted) { encrypt.checked = true; sign.checked = true; touched = true; } - if (touched) encrypt.dataset.touched = '1'; - encrypt.addEventListener('change', () => { touched = true; encrypt.dataset.touched = '1'; }); - let timer = null; - const refresh = async () => { - const to = selectPgpMailUi('#compose-to')?.value || ''; - const cc = selectPgpMailUi('#compose-cc')?.value || ''; - const hint = selectPgpMailUi('#pgp-hint'); - if (!hint) return; - if (!to.trim()) { hint.textContent = ''; return; } - try { - const status = await pgpApi().checkSend({ to, cc, sign: sign.checked }); - if (!selectPgpMailUi('#pgp-hint')) return; - if (status.missing.length) hint.textContent = `No public key for ${status.missing.join(', ')}`; - else { - hint.textContent = status.recipients.some(item => item.trust === 'unknown') ? 'Keys found; some are not verified yet' : 'Keys found for all recipients'; - if (!touched && !encrypt.checked) encrypt.checked = true; - } - } catch { hint.textContent = ''; } - }; - const schedule = () => { clearTimeout(timer); timer = setTimeout(refresh, 300); }; - ['#compose-to', '#compose-cc'].forEach(selector => selectPgpMailUi(selector)?.addEventListener('input', schedule)); - sign.addEventListener('change', schedule); - schedule(); + baseShowCompose(reply, forward); + const footer = selectPgpMailUi('#modal-root .compose-footer'); + if (!footer || !pgpApi()) return; + const box = document.createElement('div'); + box.className = 'pgp-compose'; + box.innerHTML = ``; + footer.prepend(box); + let touched = false; + const encrypt = selectPgpMailUi('#pgp-encrypt'); + const sign = selectPgpMailUi('#pgp-sign'); + if (reply?.encrypted) { encrypt.checked = true; sign.checked = true; touched = true; } + if (touched) encrypt.dataset.touched = '1'; + encrypt.addEventListener('change', () => { touched = true; encrypt.dataset.touched = '1'; }); + let timer = null; + const refresh = async () => { + const to = selectPgpMailUi('#compose-to')?.value || ''; + const cc = selectPgpMailUi('#compose-cc')?.value || ''; + const hint = selectPgpMailUi('#pgp-hint'); + if (!hint) return; + if (!to.trim()) { hint.textContent = ''; return; } + try { + const status = await pgpApi().checkSend({ to, cc, sign: sign.checked }); + if (!selectPgpMailUi('#pgp-hint')) return; + if (status.missing.length) hint.textContent = `No public key for ${status.missing.join(', ')}`; + else { + hint.textContent = status.recipients.some(item => item.trust === 'unknown') ? 'Keys found; some are not verified yet' : 'Keys found for all recipients'; + if (!touched && !encrypt.checked) encrypt.checked = true; + } + } catch { hint.textContent = ''; } + }; + const schedule = () => { clearTimeout(timer); timer = setTimeout(refresh, 300); }; + ['#compose-to', '#compose-cc'].forEach(selector => selectPgpMailUi(selector)?.addEventListener('input', schedule)); + sign.addEventListener('change', schedule); + schedule(); }); // Called by the send handler. Returns null (plain mail), false (cancelled) or send options. async function prepareSend(to, cc) { - if (!pgpApi()) return null; - let encrypt = Boolean(selectPgpMailUi('#pgp-encrypt')?.checked); - const sign = Boolean(selectPgpMailUi('#pgp-sign')?.checked); - if (!encrypt && !sign && selectPgpMailUi('#pgp-encrypt')?.dataset.touched === '1') return null; - const status = await pgpApi().checkSend({ to, cc, sign }); - // The default-on update is debounced, so a quick send could skip encryption even though keys exist. - if (!encrypt && !status.missing.length && status.recipients.length && selectPgpMailUi('#pgp-encrypt')?.dataset.touched !== '1') { - if (confirm('Public keys are available for all recipients.\n\nSend this message WITHOUT encryption?')) { - if (!sign) return null; - } else return false; - } - if (!encrypt && !sign) return null; - if (encrypt && status.missing.length) { - const sendPlain = confirm(`No public key for ${status.missing.join(', ')}.\n\nThe message cannot be encrypted for everyone. Send it WITHOUT encryption?`); - if (!sendPlain) return false; - encrypt = false; - if (!sign) return null; - } - let passphrase = null; - if (sign) { - if (!status.signer) { toastPgpMailUi('Create or import an encryption key for your address before signing'); return false; } - if (!status.signer.unlocked) { - passphrase = await pgpAskPassphrase('Sign message', `Enter the passphrase for ${status.signer.email} to sign this message.`); - if (passphrase === null) return false; - } + if (!pgpApi()) return null; + let encrypt = Boolean(selectPgpMailUi('#pgp-encrypt')?.checked); + const sign = Boolean(selectPgpMailUi('#pgp-sign')?.checked); + if (!encrypt && !sign && selectPgpMailUi('#pgp-encrypt')?.dataset.touched === '1') return null; + const status = await pgpApi().checkSend({ to, cc, sign }); + // The default-on update is debounced, so a quick send could skip encryption even though keys exist. + if (!encrypt && !status.missing.length && status.recipients.length && selectPgpMailUi('#pgp-encrypt')?.dataset.touched !== '1') { + if (confirm('Public keys are available for all recipients.\n\nSend this message WITHOUT encryption?')) { + if (!sign) return null; + } else return false; + } + if (!encrypt && !sign) return null; + if (encrypt && status.missing.length) { + const sendPlain = confirm(`No public key for ${status.missing.join(', ')}.\n\nThe message cannot be encrypted for everyone. Send it WITHOUT encryption?`); + if (!sendPlain) return false; + encrypt = false; + if (!sign) return null; + } + let passphrase = null; + if (sign) { + if (!status.signer) { toastPgpMailUi('Create or import an encryption key for your address before signing'); return false; } + if (!status.signer.unlocked) { + passphrase = await pgpAskPassphrase('Sign message', `Enter the passphrase for ${status.signer.email} to sign this message.`); + if (passphrase === null) return false; + } } return { encrypt, sign, passphrase }; } diff --git a/pgp-ui.js b/pgp-ui.js index c83e670..474e727 100644 --- a/pgp-ui.js +++ b/pgp-ui.js @@ -6,418 +6,418 @@ const selectAllPgpKeyUi = pgpKeyMailUi.selectAll; const escapePgpKeyUi = pgpKeyMailUi.escapeHtml; const toastPgpKeyUi = pgpKeyMailUi.toast; function pgpAvailable() { return Boolean(window.daybreakMail?.pgp); } - -function openEncryptionKeys() { - const root = selectPgpKeyUi('#modal-root'); + +function openEncryptionKeys() { + const root = selectPgpKeyUi('#modal-root'); const account = window.epMailFeatures.mail.connectedAccount || {}; - root.innerHTML = ``; - const close = () => { root.innerHTML = ''; }; - root.querySelector('.modal-close').onclick = close; - root.querySelector('.modal-overlay').onclick = event => { if (event.target.classList.contains('modal-overlay')) close(); }; - const status = message => { selectPgpKeyUi('#pgp-status').textContent = message; }; - const passphraseField = () => selectPgpKeyUi('#pgp-passphrase'); - let keyServers = []; - const selectedPublishServer = () => keyServers.find(server => server.id === selectPgpKeyUi('#pgp-publish-server').value && server.enabled); - const updatePublishButtons = () => { - const server = selectedPublishServer(); - selectAllPgpKeyUi('.pgp-publish').forEach(button => { - button.disabled = !server; - button.textContent = server ? `Publish to ${server.name}…` : 'Enable a server to publish…'; - }); - }; - const needPassphrase = () => { - const value = passphraseField().value; - if (!value) { status('Enter the key passphrase in the Passphrase field first.'); passphraseField().focus(); } - return value; - }; - - async function render() { - const list = selectPgpKeyUi('#pgp-key-list'); - let keys = []; - try { keys = await window.daybreakMail.pgp.list(); } catch (error) { list.textContent = error.message || 'Could not load keys.'; return; } - list.replaceChildren(); - if (!keys.length) { list.textContent = 'No keys yet.'; return; } - keys.forEach(key => { - const row = document.createElement('div'); - row.className = 'attachment-row'; - const info = document.createElement('div'); - info.className = 'attachment-row-info'; - const title = document.createElement('strong'); - title.textContent = key.email || 'OpenPGP key'; - const meta = document.createElement('small'); - meta.textContent = `${key.name ? key.name + ' · ' : ''}${key.algorithm} · ${new Date(key.createdAt).toLocaleDateString()}`; - const fingerprint = document.createElement('small'); - fingerprint.textContent = `Fingerprint: ${key.fingerprint.match(/.{1,4}/g).join(' ')}`; - info.append(title, meta, fingerprint); - row.append(info); - const actions = [ - ['Export public', () => window.daybreakMail.pgp.exportPublic(key.fingerprint), false], - ['Export private', () => window.daybreakMail.pgp.exportPrivate(key.fingerprint, needPassphrase()), true] - ]; - const changePassphrase = document.createElement('button'); - changePassphrase.className = 'discard'; - changePassphrase.textContent = 'Change passphrase…'; - changePassphrase.onclick = async () => { - const currentPassphrase = selectPgpKeyUi('#pgp-change-current-passphrase').value; - if (!currentPassphrase) { - status('Enter the current passphrase for this key.'); - selectPgpKeyUi('#pgp-change-current-passphrase').focus(); - return; - } - const newPassphrase = selectPgpKeyUi('#pgp-new-passphrase').value; - if (newPassphrase.length < 8) { - status('Use a new passphrase of at least 8 characters.'); - selectPgpKeyUi('#pgp-new-passphrase').focus(); - return; - } - if (newPassphrase !== selectPgpKeyUi('#pgp-confirm-passphrase').value) { - status('The new passphrases do not match.'); - selectPgpKeyUi('#pgp-confirm-passphrase').focus(); - return; - } - changePassphrase.disabled = true; - try { - await window.daybreakMail.pgp.changePassphrase({ - fingerprint: key.fingerprint, - currentPassphrase, - newPassphrase - }); - selectPgpKeyUi('#pgp-change-current-passphrase').value = ''; - status(`Passphrase changed for ${key.email || key.fingerprint}.`); - } catch (error) { status(error.message || 'Could not change the key passphrase.'); } - finally { - selectPgpKeyUi('#pgp-new-passphrase').value = ''; - selectPgpKeyUi('#pgp-confirm-passphrase').value = ''; - changePassphrase.disabled = false; - } - }; - row.append(changePassphrase); - if (key.hasRevocationCertificate) actions.push(['Revocation cert.', () => window.daybreakMail.pgp.exportRevocation(key.fingerprint, needPassphrase()), true]); - actions.push(['Delete', async () => { - if (!confirm('Delete this key? Encrypted mail that needs it can no longer be read unless you have a backup.')) return { canceled: true }; - await window.daybreakMail.pgp.remove(key.fingerprint, needPassphrase()); - await render(); - return { deleted: true }; - }, true]); - actions.forEach(([label, run, secret]) => { - const button = document.createElement('button'); - button.className = 'discard'; - button.textContent = label; - button.onclick = async () => { - if (secret && !passphraseField().value) { needPassphrase(); return; } - try { - const result = await run(); - status(result?.saved ? 'File saved.' : result?.deleted ? 'Key deleted.' : ''); - } catch (error) { status(error.message || 'That action failed.'); } - }; - row.append(button); - }); - const publish = document.createElement('button'); - publish.className = 'discard pgp-publish'; - publish.onclick = async () => { - const server = selectedPublishServer(); - if (!server) { status('Enable a key server and select it as the publication target first.'); return; } - publish.disabled = true; - try { - const result = await window.daybreakMail.pgp.publishKey({ fingerprint: key.fingerprint, serverId: server.id }); - if (result.canceled) return; - if (result.warning) status(result.warning); - else if (result.verification === 'pending' || result.verification === 'requested') status(`Uploaded to ${server.name}. Check ${key.email || 'your email'} for a verification message before the key becomes searchable.`); - else if (result.verification === 'published') status(`The key is already published and searchable on ${server.name}.`); - else if (result.verification === 'request-failed') status('The key was uploaded, but the server could not request email verification.'); - else if (result.verification === 'check-email') status(`${server.name} accepted the key. Check ${key.email || 'your email'} for its verification message. ${result.message || ''}`.trim()); - else status(`${server.name} accepted the key. ${result.message || ''}`.trim()); - } catch (error) { status(error.message || 'Could not publish the public key.'); } - finally { updatePublishButtons(); } - }; - row.append(publish); - list.append(row); - }); - updatePublishButtons(); - } - - selectPgpKeyUi('#pgp-generate').onclick = async () => { - const button = selectPgpKeyUi('#pgp-generate'); - button.disabled = true; - status('Creating key…'); - try { - await window.daybreakMail.pgp.generate({ - name: selectPgpKeyUi('#pgp-name').value, email: selectPgpKeyUi('#pgp-email').value, passphrase: passphraseField().value, accountId: account.id || null - }); - status('Key created. Export your private key and revocation certificate now and keep them safe.'); - await render(); - } catch (error) { status(error.message || 'Could not create the key.'); } - button.disabled = false; - }; - selectPgpKeyUi('#pgp-import').onclick = async () => { - const passphrase = needPassphrase(); - if (!passphrase) return; - try { - const result = await window.daybreakMail.pgp.importKey({ passphrase, accountId: account.id || null }); - status(result.canceled ? '' : 'Key imported.'); - await render(); - } catch (error) { status(error.message || 'Could not import the key.'); } - }; - async function renderContacts() { - const list = selectPgpKeyUi('#pgp-contact-list'); - let contacts = []; - try { contacts = await window.daybreakMail.pgp.contacts(); } catch (error) { list.textContent = error.message || 'Could not load contacts.'; return; } - list.replaceChildren(); - if (!contacts.length) { list.textContent = 'No contact keys yet. Import a public key, or add one from a received message.'; return; } - contacts.forEach(contact => { - const row = document.createElement('div'); - row.className = 'attachment-row'; - const info = document.createElement('div'); - info.className = 'attachment-row-info'; - const title = document.createElement('strong'); - title.textContent = contact.emails.join(', ') || contact.name || 'Public key'; - const meta = document.createElement('small'); - meta.textContent = `${contact.name ? contact.name + ' · ' : ''}added ${new Date(contact.addedAt).toLocaleDateString()} · from ${contact.source}`; - const fingerprint = document.createElement('small'); - fingerprint.textContent = `Fingerprint: ${contact.fingerprint.match(/.{1,4}/g).join(' ')}`; - info.append(title, meta, fingerprint); - const trust = document.createElement('select'); - trust.className = 'pgp-trust'; - trust.setAttribute('aria-label', 'Key trust'); - [['unknown', 'Not verified'], ['trusted', 'Trusted'], ['verified', 'Verified (fingerprint checked)']].forEach(([value, label]) => { - const option = document.createElement('option'); - option.value = value; option.textContent = label; option.selected = contact.trust === value; - trust.append(option); - }); - trust.onchange = async () => { - if (trust.value === 'verified' && !confirm(`Mark this key as verified only if you compared this fingerprint with its owner through another channel:\n\n${contact.fingerprint.match(/.{1,4}/g).join(' ')}`)) { - trust.value = contact.trust; - return; - } - try { await window.daybreakMail.pgp.setTrust(contact.fingerprint, trust.value); contact.trust = trust.value; status('Trust updated.'); } - catch (error) { trust.value = contact.trust; status(error.message || 'Could not update trust.'); } - }; - const actions = [ - ['Export', () => window.daybreakMail.pgp.exportContact(contact.fingerprint)], - ['Remove', async () => { - if (!confirm('Remove this contact key? You will no longer be able to encrypt to it.')) return { canceled: true }; - await window.daybreakMail.pgp.removeContact(contact.fingerprint); - await renderContacts(); - return { deleted: true }; - }] - ]; - row.append(info, trust); - actions.forEach(([label, run]) => { - const button = document.createElement('button'); - button.className = 'discard'; - button.textContent = label; - button.onclick = async () => { - try { const result = await run(); status(result?.saved ? 'File saved.' : result?.deleted ? 'Contact key removed.' : ''); } - catch (error) { status(error.message || 'That action failed.'); } - }; - row.append(button); - }); - list.append(row); - }); - } - - selectPgpKeyUi('#pgp-add-contact').onclick = async () => { - try { - const result = await window.daybreakMail.pgp.addContact({}); - if (!result.canceled) status(result.keyChangedFrom?.length ? 'Key added. Warning: you already had a different key for this address. Verify the new fingerprint.' : 'Public key added. Verify its fingerprint with the owner, then mark it as verified.'); - await renderContacts(); - } catch (error) { status(error.message || 'Could not import the key.'); } - }; - async function renderKeyServers() { - const list = selectPgpKeyUi('#pgp-server-list'); - const selector = selectPgpKeyUi('#pgp-publish-server'); - const selectedId = selector.value; - try { keyServers = await window.daybreakMail.pgp.keyServers(); } - catch (error) { list.textContent = error.message || 'Could not load key servers.'; return; } - selector.replaceChildren(); - const enabledServers = keyServers.filter(server => server.enabled); - if (!enabledServers.length) { - const option = document.createElement('option'); - option.value = ''; - option.textContent = 'No enabled servers'; - selector.append(option); - } else enabledServers.forEach(server => { - const option = document.createElement('option'); - option.value = server.id; - option.textContent = `${server.name} (${server.protocol.toUpperCase()})`; - option.selected = server.id === selectedId; - selector.append(option); - }); - if (selectedId && !enabledServers.some(server => server.id === selectedId)) selector.selectedIndex = 0; - selector.onchange = updatePublishButtons; - list.replaceChildren(); - keyServers.forEach(server => { - const row = document.createElement('div'); - row.className = 'attachment-row'; - const info = document.createElement('div'); - info.className = 'attachment-row-info'; - const title = document.createElement('strong'); - title.textContent = server.name; - const details = document.createElement('small'); - details.textContent = `${server.protocol.toUpperCase()} · ${server.url}${server.builtin ? ' · built in' : ' · custom'}`; - info.append(title, details); - const enabledLabel = document.createElement('label'); - enabledLabel.className = 'compose-line'; - const enabledText = document.createElement('span'); - enabledText.textContent = 'Use for lookup and publishing'; - const enabled = document.createElement('input'); - enabled.type = 'checkbox'; - enabled.checked = server.enabled; - enabled.setAttribute('aria-label', `${server.name} enabled`); - enabled.onchange = async () => { - enabled.disabled = true; - try { - await window.daybreakMail.pgp.setKeyServerEnabled(server.id, enabled.checked); - await renderKeyServers(); - status(`${server.name} ${enabled.checked ? 'enabled' : 'disabled'}.`); - } catch (error) { - enabled.checked = server.enabled; - status(error.message || `Could not update ${server.name}.`); - } finally { enabled.disabled = false; } - }; - enabledLabel.append(enabledText, enabled); - row.append(info, enabledLabel); - if (!server.builtin) { - const remove = document.createElement('button'); - remove.className = 'discard'; - remove.textContent = 'Remove'; - remove.onclick = async () => { - try { - await window.daybreakMail.pgp.removeKeyServer(server.id); - await renderKeyServers(); - status('Custom key server removed.'); - } catch (error) { status(error.message || 'Could not remove the key server.'); } - }; - row.append(remove); - } - list.append(row); - }); - } - selectPgpKeyUi('#pgp-find-key').onclick = async () => { - const button = selectPgpKeyUi('#pgp-find-key'); - const results = selectPgpKeyUi('#pgp-found-keys'); - button.disabled = true; - results.textContent = 'Searching…'; - try { - const found = await window.daybreakMail.pgp.findKey({ - email: selectPgpKeyUi('#pgp-search-email').value - }); - results.replaceChildren(); - found.keys.forEach(key => { - const row = document.createElement('div'); - row.className = 'attachment-row'; - const info = document.createElement('div'); - info.className = 'attachment-row-info'; - const title = document.createElement('strong'); - title.textContent = key.emails.join(', ') || key.name || 'Public key'; - const meta = document.createElement('small'); - meta.textContent = `Found on ${key.sources.join(', ')} · not verified`; - const fingerprint = document.createElement('small'); - fingerprint.textContent = `Fingerprint: ${key.fingerprint.match(/.{1,4}/g).join(' ')}`; - info.append(title, meta, fingerprint); - const add = document.createElement('button'); - add.className = 'discard'; - add.textContent = 'Add to contacts…'; - add.onclick = async () => { - add.disabled = true; - try { - const result = await window.daybreakMail.pgp.addContact({ armoredKey: key.armoredKey, source: 'keyserver' }); - if (result.canceled) return; - status(result.keyChangedFrom?.length ? 'Key added. You already had another key for this address; compare fingerprints before trusting either key.' : 'Key added as unverified. Compare its fingerprint with the owner before trusting it.'); - await renderContacts(); - row.remove(); - } catch (error) { status(error.message || 'Could not add the public key.'); } - finally { add.disabled = false; } - }; - row.append(info, add); - results.append(row); - }); - found.errors.forEach(error => { - const warning = document.createElement('small'); - warning.textContent = `${error.name}: ${error.message}`; - results.append(warning); - }); - if (!found.keys.length && !found.errors.length) results.textContent = 'No matching public key was found on the enabled servers.'; - if (found.keys.length) status(`Found ${found.keys.length} public key(s) on ${found.searchedServers.map(server => server.name).join(', ')}. They remain unverified until you check their fingerprints independently.${found.errors.length ? ` ${found.errors.length} server(s) could not be searched; see details above.` : ''}`); - else if (found.errors.length) status(`No key results; ${found.errors.length} enabled server(s) could not be searched. See details above.`); - else status(`No matching key found across ${found.searchedServers.length} enabled server(s).`); - } catch (error) { - results.textContent = ''; - status(error.message || 'Could not search the key server.'); - } finally { button.disabled = false; } - }; - selectPgpKeyUi('#pgp-add-server').onclick = async () => { - const button = selectPgpKeyUi('#pgp-add-server'); - button.disabled = true; - try { - const result = await window.daybreakMail.pgp.addKeyServer({ - name: selectPgpKeyUi('#pgp-server-name').value, - url: selectPgpKeyUi('#pgp-server-url').value, - protocol: selectPgpKeyUi('#pgp-server-protocol').value - }); - if (result.canceled) return; - selectPgpKeyUi('#pgp-server-name').value = ''; - selectPgpKeyUi('#pgp-server-url').value = ''; - await renderKeyServers(); - status('Custom key server added.'); - } catch (error) { status(error.message || 'Could not add the key server.'); } - finally { button.disabled = false; } - }; - window.daybreakMail.pgp.getSettings().then(settings => { selectPgpKeyUi('#pgp-cache-minutes').value = settings.cacheMinutes; }).catch(() => {}); - selectPgpKeyUi('#pgp-save-cache').onclick = async () => { - try { const settings = await window.daybreakMail.pgp.setSettings({ cacheMinutes: Number(selectPgpKeyUi('#pgp-cache-minutes').value) }); status(`Passphrases are remembered for ${settings.cacheMinutes} minute(s).`); } - 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.'); }; - void renderKeyServers(); - void renderContacts(); - void render(); -} - + root.innerHTML = ``; + const close = () => { root.innerHTML = ''; }; + root.querySelector('.modal-close').onclick = close; + root.querySelector('.modal-overlay').onclick = event => { if (event.target.classList.contains('modal-overlay')) close(); }; + const status = message => { selectPgpKeyUi('#pgp-status').textContent = message; }; + const passphraseField = () => selectPgpKeyUi('#pgp-passphrase'); + let keyServers = []; + const selectedPublishServer = () => keyServers.find(server => server.id === selectPgpKeyUi('#pgp-publish-server').value && server.enabled); + const updatePublishButtons = () => { + const server = selectedPublishServer(); + selectAllPgpKeyUi('.pgp-publish').forEach(button => { + button.disabled = !server; + button.textContent = server ? `Publish to ${server.name}…` : 'Enable a server to publish…'; + }); + }; + const needPassphrase = () => { + const value = passphraseField().value; + if (!value) { status('Enter the key passphrase in the Passphrase field first.'); passphraseField().focus(); } + return value; + }; + + async function render() { + const list = selectPgpKeyUi('#pgp-key-list'); + let keys = []; + try { keys = await window.daybreakMail.pgp.list(); } catch (error) { list.textContent = error.message || 'Could not load keys.'; return; } + list.replaceChildren(); + if (!keys.length) { list.textContent = 'No keys yet.'; return; } + keys.forEach(key => { + const row = document.createElement('div'); + row.className = 'attachment-row'; + const info = document.createElement('div'); + info.className = 'attachment-row-info'; + const title = document.createElement('strong'); + title.textContent = key.email || 'OpenPGP key'; + const meta = document.createElement('small'); + meta.textContent = `${key.name ? key.name + ' · ' : ''}${key.algorithm} · ${new Date(key.createdAt).toLocaleDateString()}`; + const fingerprint = document.createElement('small'); + fingerprint.textContent = `Fingerprint: ${key.fingerprint.match(/.{1,4}/g).join(' ')}`; + info.append(title, meta, fingerprint); + row.append(info); + const actions = [ + ['Export public', () => window.daybreakMail.pgp.exportPublic(key.fingerprint), false], + ['Export private', () => window.daybreakMail.pgp.exportPrivate(key.fingerprint, needPassphrase()), true] + ]; + const changePassphrase = document.createElement('button'); + changePassphrase.className = 'discard'; + changePassphrase.textContent = 'Change passphrase…'; + changePassphrase.onclick = async () => { + const currentPassphrase = selectPgpKeyUi('#pgp-change-current-passphrase').value; + if (!currentPassphrase) { + status('Enter the current passphrase for this key.'); + selectPgpKeyUi('#pgp-change-current-passphrase').focus(); + return; + } + const newPassphrase = selectPgpKeyUi('#pgp-new-passphrase').value; + if (newPassphrase.length < 8) { + status('Use a new passphrase of at least 8 characters.'); + selectPgpKeyUi('#pgp-new-passphrase').focus(); + return; + } + if (newPassphrase !== selectPgpKeyUi('#pgp-confirm-passphrase').value) { + status('The new passphrases do not match.'); + selectPgpKeyUi('#pgp-confirm-passphrase').focus(); + return; + } + changePassphrase.disabled = true; + try { + await window.daybreakMail.pgp.changePassphrase({ + fingerprint: key.fingerprint, + currentPassphrase, + newPassphrase + }); + selectPgpKeyUi('#pgp-change-current-passphrase').value = ''; + status(`Passphrase changed for ${key.email || key.fingerprint}.`); + } catch (error) { status(error.message || 'Could not change the key passphrase.'); } + finally { + selectPgpKeyUi('#pgp-new-passphrase').value = ''; + selectPgpKeyUi('#pgp-confirm-passphrase').value = ''; + changePassphrase.disabled = false; + } + }; + row.append(changePassphrase); + if (key.hasRevocationCertificate) actions.push(['Revocation cert.', () => window.daybreakMail.pgp.exportRevocation(key.fingerprint, needPassphrase()), true]); + actions.push(['Delete', async () => { + if (!confirm('Delete this key? Encrypted mail that needs it can no longer be read unless you have a backup.')) return { canceled: true }; + await window.daybreakMail.pgp.remove(key.fingerprint, needPassphrase()); + await render(); + return { deleted: true }; + }, true]); + actions.forEach(([label, run, secret]) => { + const button = document.createElement('button'); + button.className = 'discard'; + button.textContent = label; + button.onclick = async () => { + if (secret && !passphraseField().value) { needPassphrase(); return; } + try { + const result = await run(); + status(result?.saved ? 'File saved.' : result?.deleted ? 'Key deleted.' : ''); + } catch (error) { status(error.message || 'That action failed.'); } + }; + row.append(button); + }); + const publish = document.createElement('button'); + publish.className = 'discard pgp-publish'; + publish.onclick = async () => { + const server = selectedPublishServer(); + if (!server) { status('Enable a key server and select it as the publication target first.'); return; } + publish.disabled = true; + try { + const result = await window.daybreakMail.pgp.publishKey({ fingerprint: key.fingerprint, serverId: server.id }); + if (result.canceled) return; + if (result.warning) status(result.warning); + else if (result.verification === 'pending' || result.verification === 'requested') status(`Uploaded to ${server.name}. Check ${key.email || 'your email'} for a verification message before the key becomes searchable.`); + else if (result.verification === 'published') status(`The key is already published and searchable on ${server.name}.`); + else if (result.verification === 'request-failed') status('The key was uploaded, but the server could not request email verification.'); + else if (result.verification === 'check-email') status(`${server.name} accepted the key. Check ${key.email || 'your email'} for its verification message. ${result.message || ''}`.trim()); + else status(`${server.name} accepted the key. ${result.message || ''}`.trim()); + } catch (error) { status(error.message || 'Could not publish the public key.'); } + finally { updatePublishButtons(); } + }; + row.append(publish); + list.append(row); + }); + updatePublishButtons(); + } + + selectPgpKeyUi('#pgp-generate').onclick = async () => { + const button = selectPgpKeyUi('#pgp-generate'); + button.disabled = true; + status('Creating key…'); + try { + await window.daybreakMail.pgp.generate({ + name: selectPgpKeyUi('#pgp-name').value, email: selectPgpKeyUi('#pgp-email').value, passphrase: passphraseField().value, accountId: account.id || null + }); + status('Key created. Export your private key and revocation certificate now and keep them safe.'); + await render(); + } catch (error) { status(error.message || 'Could not create the key.'); } + button.disabled = false; + }; + selectPgpKeyUi('#pgp-import').onclick = async () => { + const passphrase = needPassphrase(); + if (!passphrase) return; + try { + const result = await window.daybreakMail.pgp.importKey({ passphrase, accountId: account.id || null }); + status(result.canceled ? '' : 'Key imported.'); + await render(); + } catch (error) { status(error.message || 'Could not import the key.'); } + }; + async function renderContacts() { + const list = selectPgpKeyUi('#pgp-contact-list'); + let contacts = []; + try { contacts = await window.daybreakMail.pgp.contacts(); } catch (error) { list.textContent = error.message || 'Could not load contacts.'; return; } + list.replaceChildren(); + if (!contacts.length) { list.textContent = 'No contact keys yet. Import a public key, or add one from a received message.'; return; } + contacts.forEach(contact => { + const row = document.createElement('div'); + row.className = 'attachment-row'; + const info = document.createElement('div'); + info.className = 'attachment-row-info'; + const title = document.createElement('strong'); + title.textContent = contact.emails.join(', ') || contact.name || 'Public key'; + const meta = document.createElement('small'); + meta.textContent = `${contact.name ? contact.name + ' · ' : ''}added ${new Date(contact.addedAt).toLocaleDateString()} · from ${contact.source}`; + const fingerprint = document.createElement('small'); + fingerprint.textContent = `Fingerprint: ${contact.fingerprint.match(/.{1,4}/g).join(' ')}`; + info.append(title, meta, fingerprint); + const trust = document.createElement('select'); + trust.className = 'pgp-trust'; + trust.setAttribute('aria-label', 'Key trust'); + [['unknown', 'Not verified'], ['trusted', 'Trusted'], ['verified', 'Verified (fingerprint checked)']].forEach(([value, label]) => { + const option = document.createElement('option'); + option.value = value; option.textContent = label; option.selected = contact.trust === value; + trust.append(option); + }); + trust.onchange = async () => { + if (trust.value === 'verified' && !confirm(`Mark this key as verified only if you compared this fingerprint with its owner through another channel:\n\n${contact.fingerprint.match(/.{1,4}/g).join(' ')}`)) { + trust.value = contact.trust; + return; + } + try { await window.daybreakMail.pgp.setTrust(contact.fingerprint, trust.value); contact.trust = trust.value; status('Trust updated.'); } + catch (error) { trust.value = contact.trust; status(error.message || 'Could not update trust.'); } + }; + const actions = [ + ['Export', () => window.daybreakMail.pgp.exportContact(contact.fingerprint)], + ['Remove', async () => { + if (!confirm('Remove this contact key? You will no longer be able to encrypt to it.')) return { canceled: true }; + await window.daybreakMail.pgp.removeContact(contact.fingerprint); + await renderContacts(); + return { deleted: true }; + }] + ]; + row.append(info, trust); + actions.forEach(([label, run]) => { + const button = document.createElement('button'); + button.className = 'discard'; + button.textContent = label; + button.onclick = async () => { + try { const result = await run(); status(result?.saved ? 'File saved.' : result?.deleted ? 'Contact key removed.' : ''); } + catch (error) { status(error.message || 'That action failed.'); } + }; + row.append(button); + }); + list.append(row); + }); + } + + selectPgpKeyUi('#pgp-add-contact').onclick = async () => { + try { + const result = await window.daybreakMail.pgp.addContact({}); + if (!result.canceled) status(result.keyChangedFrom?.length ? 'Key added. Warning: you already had a different key for this address. Verify the new fingerprint.' : 'Public key added. Verify its fingerprint with the owner, then mark it as verified.'); + await renderContacts(); + } catch (error) { status(error.message || 'Could not import the key.'); } + }; + async function renderKeyServers() { + const list = selectPgpKeyUi('#pgp-server-list'); + const selector = selectPgpKeyUi('#pgp-publish-server'); + const selectedId = selector.value; + try { keyServers = await window.daybreakMail.pgp.keyServers(); } + catch (error) { list.textContent = error.message || 'Could not load key servers.'; return; } + selector.replaceChildren(); + const enabledServers = keyServers.filter(server => server.enabled); + if (!enabledServers.length) { + const option = document.createElement('option'); + option.value = ''; + option.textContent = 'No enabled servers'; + selector.append(option); + } else enabledServers.forEach(server => { + const option = document.createElement('option'); + option.value = server.id; + option.textContent = `${server.name} (${server.protocol.toUpperCase()})`; + option.selected = server.id === selectedId; + selector.append(option); + }); + if (selectedId && !enabledServers.some(server => server.id === selectedId)) selector.selectedIndex = 0; + selector.onchange = updatePublishButtons; + list.replaceChildren(); + keyServers.forEach(server => { + const row = document.createElement('div'); + row.className = 'attachment-row'; + const info = document.createElement('div'); + info.className = 'attachment-row-info'; + const title = document.createElement('strong'); + title.textContent = server.name; + const details = document.createElement('small'); + details.textContent = `${server.protocol.toUpperCase()} · ${server.url}${server.builtin ? ' · built in' : ' · custom'}`; + info.append(title, details); + const enabledLabel = document.createElement('label'); + enabledLabel.className = 'compose-line'; + const enabledText = document.createElement('span'); + enabledText.textContent = 'Use for lookup and publishing'; + const enabled = document.createElement('input'); + enabled.type = 'checkbox'; + enabled.checked = server.enabled; + enabled.setAttribute('aria-label', `${server.name} enabled`); + enabled.onchange = async () => { + enabled.disabled = true; + try { + await window.daybreakMail.pgp.setKeyServerEnabled(server.id, enabled.checked); + await renderKeyServers(); + status(`${server.name} ${enabled.checked ? 'enabled' : 'disabled'}.`); + } catch (error) { + enabled.checked = server.enabled; + status(error.message || `Could not update ${server.name}.`); + } finally { enabled.disabled = false; } + }; + enabledLabel.append(enabledText, enabled); + row.append(info, enabledLabel); + if (!server.builtin) { + const remove = document.createElement('button'); + remove.className = 'discard'; + remove.textContent = 'Remove'; + remove.onclick = async () => { + try { + await window.daybreakMail.pgp.removeKeyServer(server.id); + await renderKeyServers(); + status('Custom key server removed.'); + } catch (error) { status(error.message || 'Could not remove the key server.'); } + }; + row.append(remove); + } + list.append(row); + }); + } + selectPgpKeyUi('#pgp-find-key').onclick = async () => { + const button = selectPgpKeyUi('#pgp-find-key'); + const results = selectPgpKeyUi('#pgp-found-keys'); + button.disabled = true; + results.textContent = 'Searching…'; + try { + const found = await window.daybreakMail.pgp.findKey({ + email: selectPgpKeyUi('#pgp-search-email').value + }); + results.replaceChildren(); + found.keys.forEach(key => { + const row = document.createElement('div'); + row.className = 'attachment-row'; + const info = document.createElement('div'); + info.className = 'attachment-row-info'; + const title = document.createElement('strong'); + title.textContent = key.emails.join(', ') || key.name || 'Public key'; + const meta = document.createElement('small'); + meta.textContent = `Found on ${key.sources.join(', ')} · not verified`; + const fingerprint = document.createElement('small'); + fingerprint.textContent = `Fingerprint: ${key.fingerprint.match(/.{1,4}/g).join(' ')}`; + info.append(title, meta, fingerprint); + const add = document.createElement('button'); + add.className = 'discard'; + add.textContent = 'Add to contacts…'; + add.onclick = async () => { + add.disabled = true; + try { + const result = await window.daybreakMail.pgp.addContact({ armoredKey: key.armoredKey, source: 'keyserver' }); + if (result.canceled) return; + status(result.keyChangedFrom?.length ? 'Key added. You already had another key for this address; compare fingerprints before trusting either key.' : 'Key added as unverified. Compare its fingerprint with the owner before trusting it.'); + await renderContacts(); + row.remove(); + } catch (error) { status(error.message || 'Could not add the public key.'); } + finally { add.disabled = false; } + }; + row.append(info, add); + results.append(row); + }); + found.errors.forEach(error => { + const warning = document.createElement('small'); + warning.textContent = `${error.name}: ${error.message}`; + results.append(warning); + }); + if (!found.keys.length && !found.errors.length) results.textContent = 'No matching public key was found on the enabled servers.'; + if (found.keys.length) status(`Found ${found.keys.length} public key(s) on ${found.searchedServers.map(server => server.name).join(', ')}. They remain unverified until you check their fingerprints independently.${found.errors.length ? ` ${found.errors.length} server(s) could not be searched; see details above.` : ''}`); + else if (found.errors.length) status(`No key results; ${found.errors.length} enabled server(s) could not be searched. See details above.`); + else status(`No matching key found across ${found.searchedServers.length} enabled server(s).`); + } catch (error) { + results.textContent = ''; + status(error.message || 'Could not search the key server.'); + } finally { button.disabled = false; } + }; + selectPgpKeyUi('#pgp-add-server').onclick = async () => { + const button = selectPgpKeyUi('#pgp-add-server'); + button.disabled = true; + try { + const result = await window.daybreakMail.pgp.addKeyServer({ + name: selectPgpKeyUi('#pgp-server-name').value, + url: selectPgpKeyUi('#pgp-server-url').value, + protocol: selectPgpKeyUi('#pgp-server-protocol').value + }); + if (result.canceled) return; + selectPgpKeyUi('#pgp-server-name').value = ''; + selectPgpKeyUi('#pgp-server-url').value = ''; + await renderKeyServers(); + status('Custom key server added.'); + } catch (error) { status(error.message || 'Could not add the key server.'); } + finally { button.disabled = false; } + }; + window.daybreakMail.pgp.getSettings().then(settings => { selectPgpKeyUi('#pgp-cache-minutes').value = settings.cacheMinutes; }).catch(() => {}); + selectPgpKeyUi('#pgp-save-cache').onclick = async () => { + try { const settings = await window.daybreakMail.pgp.setSettings({ cacheMinutes: Number(selectPgpKeyUi('#pgp-cache-minutes').value) }); status(`Passphrases are remembered for ${settings.cacheMinutes} minute(s).`); } + 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.'); }; + void renderKeyServers(); + void renderContacts(); + void render(); +} + window.epMailFeatures.productivity.wrapOpenPreferences(baseOpenPreferences => function () { baseOpenPreferences(); - const fields = selectPgpKeyUi('#modal-root .compose-fields'); - if (!fields || !pgpAvailable()) return; - const button = document.createElement('button'); - button.type = 'button'; - button.className = 'discard'; - button.id = 'open-encryption-keys'; - button.textContent = 'Encryption keys…'; - button.onclick = openEncryptionKeys; - fields.append(button); + const fields = selectPgpKeyUi('#modal-root .compose-fields'); + if (!fields || !pgpAvailable()) return; + const button = document.createElement('button'); + button.type = 'button'; + button.className = 'discard'; + button.id = 'open-encryption-keys'; + button.textContent = 'Encryption keys…'; + button.onclick = openEncryptionKeys; + fields.append(button); }); })(); diff --git a/productivity.js b/productivity.js index 3c3c8ff..45dbd12 100644 --- a/productivity.js +++ b/productivity.js @@ -6,50 +6,50 @@ const selectAllProductivityUi = productivityMailUi.selectAll; const toastProductivityUi = productivityMailUi.toast; const escapeProductivityUi = productivityMailUi.escapeHtml; const productKeys = { profile: 'daybreak-profile', events: 'daybreak-events', contacts: 'daybreak-contacts', labels: 'daybreak-labels', snoozed: 'daybreak-snoozed' }; -const productRead = (key, fallback) => { try { const value = JSON.parse(localStorage.getItem(key)); return value ?? fallback; } catch { return fallback; } }; -const productWrite = (key, value) => localStorage.setItem(key, JSON.stringify(value)); -let profileSettings = productRead(productKeys.profile, { name: '' }); -if (/^mira(\s+sol)?$/i.test(profileSettings.name || '')) { profileSettings = { name: '' }; localStorage.removeItem(productKeys.profile); } -let calendarMonth = new Date(new Date().getFullYear(), new Date().getMonth(), 1); -const generatedContactEmails = new Set(['amelia@northstar.design','jonah@fieldnotes.co','sofia@smallhours.works','mateo@roam.travel','eden@paperandpine.com','noah@common-thread.org','iris@littlefern.press']); -let savedContacts = productRead(productKeys.contacts, []).filter(contact => !generatedContactEmails.has(String(contact.email||'').toLowerCase())); -productWrite(productKeys.contacts, savedContacts); -let savedEvents = productRead(productKeys.events, []); -let customLabels = productRead(productKeys.labels, []); -let snoozedIds = productRead(productKeys.snoozed, []); -function setProfileName(name) { profileSettings.name = name.trim(); productWrite(productKeys.profile, profileSettings); const first = profileSettings.name.split(/\s+/)[0] || ''; const greeting=selectProductivityUi('#greeting-name'); greeting.textContent=first; greeting.hidden=!first; const heading=selectProductivityUi('#welcome-heading'); if(heading) heading.firstChild.textContent=first?'Good morning, ':'Good morning'; if (productivityMailUi.connectedAccount) productivityMailUi.updateAccountCard(productivityMailUi.connectedAccount); } -function openAccountSettings() { - const root=selectProductivityUi('#modal-root'); - root.innerHTML=``; - const close=()=>root.innerHTML=''; - selectAllProductivityUi('.modal-close').forEach(button=>button.onclick=close); - selectProductivityUi('.modal-overlay').onclick=event=>{if(event.target.classList.contains('modal-overlay'))close()}; - selectProductivityUi('#save-profile').onclick=()=>{const name=selectProductivityUi('#profile-name').value.trim();if(!name){toastProductivityUi('Enter your display name');return}setProfileName(name);close();toastProductivityUi('Account settings saved')}; - selectProductivityUi('#profile-name').focus(); -} -function openPreferences() { - const root=selectProductivityUi('#modal-root'); - const themes=[['daylight','Eternity Daylight'],['wasteland','Wasteland'],['ep-wasteland','EP Wasteland'],['ep-daylight','EP Daylight']]; - const selectedTheme=localStorage.getItem('daybreak-theme')||'ep-wasteland'; - const options=themes.map(([value,label])=>``).join(''); - root.innerHTML=``; - const close=()=>root.innerHTML=''; - selectAllProductivityUi('.modal-close').forEach(button=>button.onclick=close); - selectProductivityUi('.modal-overlay').onclick=event=>{if(event.target.classList.contains('modal-overlay'))close()}; - selectProductivityUi('#save-appearance').onclick=()=>{productivityMailUi.applyTheme(selectProductivityUi('#theme-select').value);close();toastProductivityUi('Appearance saved')}; - selectProductivityUi('#theme-select').focus(); -} -function showEvent(dayOrId) { const edit=savedEvents.find(e=>e.id===dayOrId), dateValue=edit?.date || (typeof dayOrId==='string'&&/^\d{4}-\d\d-\d\d$/.test(dayOrId)?dayOrId:`${calendarMonth.getFullYear()}-${String(calendarMonth.getMonth()+1).padStart(2,'0')}-${String(dayOrId||new Date().getDate()).padStart(2,'0')}`); const root=selectProductivityUi('#modal-root'); root.innerHTML=``; const close=()=>root.innerHTML=''; selectAllProductivityUi('.modal-close').forEach(b=>b.onclick=close); selectProductivityUi('.modal-overlay').onclick=e=>{if(e.target.classList.contains('modal-overlay'))close()}; selectProductivityUi('#save-event').onclick=async()=>{const title=selectProductivityUi('#event-name').value.trim(),date=selectProductivityUi('#event-date').value;if(!title||!date){toastProductivityUi('Add an event name and date');return}const item={...(edit||{}),id:edit?.id||crypto.randomUUID(),title,date,time:selectProductivityUi('#event-time').value,with:selectProductivityUi('#event-people').value.trim(),place:selectProductivityUi('#event-place').value.trim(),notes:selectProductivityUi('#event-notes').value.trim()}; if(window.daybreakMail?.davSaveEvent){try{const remote=await window.daybreakMail.davSaveEvent(item);if(remote)item._dav=remote}catch(error){toastProductivityUi('Saved locally; DAV sync failed: '+error.message)}} if(edit) savedEvents=savedEvents.map(e=>e.id===edit.id?item:e);else savedEvents.push(item);productWrite(productKeys.events,savedEvents);close();renderCalendar();toastProductivityUi(edit?'Event updated':'Event added')}; if(edit) selectProductivityUi('#delete-event').onclick=async()=>{if(edit._dav&&window.daybreakMail?.davDeleteEvent){try{await window.daybreakMail.davDeleteEvent(edit._dav)}catch(error){toastProductivityUi('Could not delete remote event: '+error.message);return}}savedEvents=savedEvents.filter(e=>e.id!==edit.id);productWrite(productKeys.events,savedEvents);close();renderCalendar();toastProductivityUi('Event removed')}; selectProductivityUi('#event-name').focus(); } -function renderCalendar(){const year=calendarMonth.getFullYear(),month=calendarMonth.getMonth(),first=new Date(year,month,1),start=new Date(year,month,1-first.getDay()),days=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'];let cells='';for(let i=0;i<42;i++){const d=new Date(start);d.setDate(start.getDate()+i);const key=`${d.getFullYear()}-${String(d.getMonth()+1).padStart(2,'0')}-${String(d.getDate()).padStart(2,'0')}`,items=savedEvents.filter(e=>e.date===key);cells+=`
${d.getDate()}${items.slice(0,3).map(e=>`
${escapeProductivityUi(e.time?`${e.time} `:'')}${escapeProductivityUi(e.title)}
`).join('')}${items.length>3?`+${items.length-3} more`:''}
`}const upcoming=savedEvents.filter(e=>e.date>=new Date().toISOString().slice(0,10)).sort((a,b)=>a.date.localeCompare(b.date)||a.time.localeCompare(b.time)).slice(0,5);selectProductivityUi('#calendar-view').innerHTML=`

YOUR TIME, WITH ROOM TO BREATHE

${new Intl.DateTimeFormat('en-US',{month:'long',year:'numeric'}).format(calendarMonth)}

${savedEvents.length} saved events

${days.map(d=>`${d}`).join('')}
${cells}

Coming up

${upcoming.length?upcoming.map(e=>``).join(''):'

No upcoming events yet.

'}
`;selectProductivityUi('#new-event').onclick=()=>showEvent(new Date(year,month,new Date().getDate()).toISOString().slice(0,10));selectProductivityUi('#today-btn').onclick=()=>{calendarMonth=new Date(new Date().getFullYear(),new Date().getMonth(),1);renderCalendar()};selectProductivityUi('#prev-month').onclick=()=>{calendarMonth=new Date(year,month-1,1);renderCalendar()};selectProductivityUi('#next-month').onclick=()=>{calendarMonth=new Date(year,month+1,1);renderCalendar()};selectProductivityUi('#calendar-view').onclick=e=>{const event=e.target.closest('[data-event]');if(event){showEvent(event.dataset.event);return}const cell=e.target.closest('.cal-cell');if(cell)showEvent(cell.dataset.day)}} -function showContact(index){const existing=Number.isInteger(index)?savedContacts[index]:null,root=selectProductivityUi('#modal-root');root.innerHTML=``;const close=()=>root.innerHTML='';selectAllProductivityUi('.modal-close').forEach(b=>b.onclick=close);selectProductivityUi('.modal-overlay').onclick=e=>{if(e.target.classList.contains('modal-overlay'))close()};selectProductivityUi('#save-contact').onclick=async()=>{const name=selectProductivityUi('#contact-name').value.trim(),email=selectProductivityUi('#contact-email').value.trim();if(!name||!email){toastProductivityUi('Add a name and email');return}const item={...(existing||{}),name,email,note:selectProductivityUi('#contact-note').value.trim()||'Contact',initials:name.split(/\s+/).map(x=>x[0]).join('').slice(0,2).toUpperCase(),color:existing?.color||'#e7dfce'};if(window.daybreakMail?.davSaveContact){try{const remote=await window.daybreakMail.davSaveContact(item);if(remote)item._dav=remote}catch(error){toastProductivityUi('Saved locally; CardDAV sync failed: '+error.message)}}if(existing)savedContacts[index]=item;else savedContacts.push(item);productWrite(productKeys.contacts,savedContacts);close();renderContacts();toastProductivityUi(existing?'Contact updated':'Contact saved')};if(existing)selectProductivityUi('#delete-contact').onclick=async()=>{if(existing._dav&&window.daybreakMail?.davDeleteContact){try{await window.daybreakMail.davDeleteContact(existing._dav)}catch(error){toastProductivityUi('Could not delete remote contact: '+error.message);return}}savedContacts.splice(index,1);productWrite(productKeys.contacts,savedContacts);close();renderContacts();toastProductivityUi('Contact removed')};selectProductivityUi('#contact-name').focus()} -function renderContacts(){const cards=savedContacts.map((c,i)=>`
${escapeProductivityUi(c.initials)}
${escapeProductivityUi(c.name)}${escapeProductivityUi(c.email)}${escapeProductivityUi(c.note)}
`).join('');selectProductivityUi('#contacts-view').innerHTML=`

THE PEOPLE WHO MAKE LIFE FULLER

Your people

${savedContacts.length} contacts, all in one place.

${cards||'

No contacts yet. Add someone to get started.

'}
`;selectProductivityUi('#add-contact').onclick=()=>showContact();selectProductivityUi('#contact-search').oninput=e=>selectAllProductivityUi('.contact-card').forEach(c=>c.classList.toggle('hidden',!c.innerText.toLowerCase().includes(e.target.value.toLowerCase())));selectProductivityUi('#contacts-view').onclick=e=>{const edit=e.target.closest('[data-edit-contact]');if(edit){showContact(Number(edit.dataset.editContact));return}const email=e.target.closest('.contact-email');if(email)productivityMailUi.showCompose({email:email.dataset.email,subject:'',date:''})};selectProductivityUi('#contacts-view').oncontextmenu=e=>{const card=e.target.closest('.contact-card');if(!card)return;e.preventDefault();const i=Number(card.dataset.contact);if(confirm(`Remove ${savedContacts[i].name} from contacts?`)){savedContacts.splice(i,1);productWrite(productKeys.contacts,savedContacts);renderContacts();toastProductivityUi('Contact removed')}}} -function accountRuleLabels(){return [...new Set((productivityMailUi.connectedAccount?.rules||[]).filter(rule=>rule.action==='label').map(rule=>rule.value).filter(Boolean))]} -function renderLabels(){const box=selectProductivityUi('#custom-labels');if(!box)return;const labels=[...new Set([...customLabels,...accountRuleLabels()])];box.innerHTML=labels.map(label=>``).join('');selectAllProductivityUi('.label-link').forEach(b=>b.onclick=()=>{document.querySelectorAll('.label-link').forEach(x=>x.classList.toggle('active',x===b));productivityMailUi.state.activeFolder=b.dataset.label;selectProductivityUi('#sidebar-title').textContent=productivityMailUi.state.activeFolder;selectProductivityUi('#crumb-current').textContent=productivityMailUi.state.activeFolder;productivityMailUi.renderList()})} -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()} -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='';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 ↓';}); -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()} +const productRead = (key, fallback) => { try { const value = JSON.parse(localStorage.getItem(key)); return value ?? fallback; } catch { return fallback; } }; +const productWrite = (key, value) => localStorage.setItem(key, JSON.stringify(value)); +let profileSettings = productRead(productKeys.profile, { name: '' }); +if (/^mira(\s+sol)?$/i.test(profileSettings.name || '')) { profileSettings = { name: '' }; localStorage.removeItem(productKeys.profile); } +let calendarMonth = new Date(new Date().getFullYear(), new Date().getMonth(), 1); +const generatedContactEmails = new Set(['amelia@northstar.design','jonah@fieldnotes.co','sofia@smallhours.works','mateo@roam.travel','eden@paperandpine.com','noah@common-thread.org','iris@littlefern.press']); +let savedContacts = productRead(productKeys.contacts, []).filter(contact => !generatedContactEmails.has(String(contact.email||'').toLowerCase())); +productWrite(productKeys.contacts, savedContacts); +let savedEvents = productRead(productKeys.events, []); +let customLabels = productRead(productKeys.labels, []); +let snoozedIds = productRead(productKeys.snoozed, []); +function setProfileName(name) { profileSettings.name = name.trim(); productWrite(productKeys.profile, profileSettings); const first = profileSettings.name.split(/\s+/)[0] || ''; const greeting=selectProductivityUi('#greeting-name'); greeting.textContent=first; greeting.hidden=!first; const heading=selectProductivityUi('#welcome-heading'); if(heading) heading.firstChild.textContent=first?'Good morning, ':'Good morning'; if (productivityMailUi.connectedAccount) productivityMailUi.updateAccountCard(productivityMailUi.connectedAccount); } +function openAccountSettings() { + const root=selectProductivityUi('#modal-root'); + root.innerHTML=``; + const close=()=>root.innerHTML=''; + selectAllProductivityUi('.modal-close').forEach(button=>button.onclick=close); + selectProductivityUi('.modal-overlay').onclick=event=>{if(event.target.classList.contains('modal-overlay'))close()}; + selectProductivityUi('#save-profile').onclick=()=>{const name=selectProductivityUi('#profile-name').value.trim();if(!name){toastProductivityUi('Enter your display name');return}setProfileName(name);close();toastProductivityUi('Account settings saved')}; + selectProductivityUi('#profile-name').focus(); +} +function openPreferences() { + const root=selectProductivityUi('#modal-root'); + const themes=[['daylight','Eternity Daylight'],['wasteland','Wasteland'],['ep-wasteland','EP Wasteland'],['ep-daylight','EP Daylight']]; + const selectedTheme=localStorage.getItem('daybreak-theme')||'ep-wasteland'; + const options=themes.map(([value,label])=>``).join(''); + root.innerHTML=``; + const close=()=>root.innerHTML=''; + selectAllProductivityUi('.modal-close').forEach(button=>button.onclick=close); + selectProductivityUi('.modal-overlay').onclick=event=>{if(event.target.classList.contains('modal-overlay'))close()}; + selectProductivityUi('#save-appearance').onclick=()=>{productivityMailUi.applyTheme(selectProductivityUi('#theme-select').value);close();toastProductivityUi('Appearance saved')}; + selectProductivityUi('#theme-select').focus(); +} +function showEvent(dayOrId) { const edit=savedEvents.find(e=>e.id===dayOrId), dateValue=edit?.date || (typeof dayOrId==='string'&&/^\d{4}-\d\d-\d\d$/.test(dayOrId)?dayOrId:`${calendarMonth.getFullYear()}-${String(calendarMonth.getMonth()+1).padStart(2,'0')}-${String(dayOrId||new Date().getDate()).padStart(2,'0')}`); const root=selectProductivityUi('#modal-root'); root.innerHTML=``; const close=()=>root.innerHTML=''; selectAllProductivityUi('.modal-close').forEach(b=>b.onclick=close); selectProductivityUi('.modal-overlay').onclick=e=>{if(e.target.classList.contains('modal-overlay'))close()}; selectProductivityUi('#save-event').onclick=async()=>{const title=selectProductivityUi('#event-name').value.trim(),date=selectProductivityUi('#event-date').value;if(!title||!date){toastProductivityUi('Add an event name and date');return}const item={...(edit||{}),id:edit?.id||crypto.randomUUID(),title,date,time:selectProductivityUi('#event-time').value,with:selectProductivityUi('#event-people').value.trim(),place:selectProductivityUi('#event-place').value.trim(),notes:selectProductivityUi('#event-notes').value.trim()}; if(window.daybreakMail?.davSaveEvent){try{const remote=await window.daybreakMail.davSaveEvent(item);if(remote)item._dav=remote}catch(error){toastProductivityUi('Saved locally; DAV sync failed: '+error.message)}} if(edit) savedEvents=savedEvents.map(e=>e.id===edit.id?item:e);else savedEvents.push(item);productWrite(productKeys.events,savedEvents);close();renderCalendar();toastProductivityUi(edit?'Event updated':'Event added')}; if(edit) selectProductivityUi('#delete-event').onclick=async()=>{if(edit._dav&&window.daybreakMail?.davDeleteEvent){try{await window.daybreakMail.davDeleteEvent(edit._dav)}catch(error){toastProductivityUi('Could not delete remote event: '+error.message);return}}savedEvents=savedEvents.filter(e=>e.id!==edit.id);productWrite(productKeys.events,savedEvents);close();renderCalendar();toastProductivityUi('Event removed')}; selectProductivityUi('#event-name').focus(); } +function renderCalendar(){const year=calendarMonth.getFullYear(),month=calendarMonth.getMonth(),first=new Date(year,month,1),start=new Date(year,month,1-first.getDay()),days=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'];let cells='';for(let i=0;i<42;i++){const d=new Date(start);d.setDate(start.getDate()+i);const key=`${d.getFullYear()}-${String(d.getMonth()+1).padStart(2,'0')}-${String(d.getDate()).padStart(2,'0')}`,items=savedEvents.filter(e=>e.date===key);cells+=`
${d.getDate()}${items.slice(0,3).map(e=>`
${escapeProductivityUi(e.time?`${e.time} `:'')}${escapeProductivityUi(e.title)}
`).join('')}${items.length>3?`+${items.length-3} more`:''}
`}const upcoming=savedEvents.filter(e=>e.date>=new Date().toISOString().slice(0,10)).sort((a,b)=>a.date.localeCompare(b.date)||a.time.localeCompare(b.time)).slice(0,5);selectProductivityUi('#calendar-view').innerHTML=`

YOUR TIME, WITH ROOM TO BREATHE

${new Intl.DateTimeFormat('en-US',{month:'long',year:'numeric'}).format(calendarMonth)}

${savedEvents.length} saved events

${days.map(d=>`${d}`).join('')}
${cells}

Coming up

${upcoming.length?upcoming.map(e=>``).join(''):'

No upcoming events yet.

'}
`;selectProductivityUi('#new-event').onclick=()=>showEvent(new Date(year,month,new Date().getDate()).toISOString().slice(0,10));selectProductivityUi('#today-btn').onclick=()=>{calendarMonth=new Date(new Date().getFullYear(),new Date().getMonth(),1);renderCalendar()};selectProductivityUi('#prev-month').onclick=()=>{calendarMonth=new Date(year,month-1,1);renderCalendar()};selectProductivityUi('#next-month').onclick=()=>{calendarMonth=new Date(year,month+1,1);renderCalendar()};selectProductivityUi('#calendar-view').onclick=e=>{const event=e.target.closest('[data-event]');if(event){showEvent(event.dataset.event);return}const cell=e.target.closest('.cal-cell');if(cell)showEvent(cell.dataset.day)}} +function showContact(index){const existing=Number.isInteger(index)?savedContacts[index]:null,root=selectProductivityUi('#modal-root');root.innerHTML=``;const close=()=>root.innerHTML='';selectAllProductivityUi('.modal-close').forEach(b=>b.onclick=close);selectProductivityUi('.modal-overlay').onclick=e=>{if(e.target.classList.contains('modal-overlay'))close()};selectProductivityUi('#save-contact').onclick=async()=>{const name=selectProductivityUi('#contact-name').value.trim(),email=selectProductivityUi('#contact-email').value.trim();if(!name||!email){toastProductivityUi('Add a name and email');return}const item={...(existing||{}),name,email,note:selectProductivityUi('#contact-note').value.trim()||'Contact',initials:name.split(/\s+/).map(x=>x[0]).join('').slice(0,2).toUpperCase(),color:existing?.color||'#e7dfce'};if(window.daybreakMail?.davSaveContact){try{const remote=await window.daybreakMail.davSaveContact(item);if(remote)item._dav=remote}catch(error){toastProductivityUi('Saved locally; CardDAV sync failed: '+error.message)}}if(existing)savedContacts[index]=item;else savedContacts.push(item);productWrite(productKeys.contacts,savedContacts);close();renderContacts();toastProductivityUi(existing?'Contact updated':'Contact saved')};if(existing)selectProductivityUi('#delete-contact').onclick=async()=>{if(existing._dav&&window.daybreakMail?.davDeleteContact){try{await window.daybreakMail.davDeleteContact(existing._dav)}catch(error){toastProductivityUi('Could not delete remote contact: '+error.message);return}}savedContacts.splice(index,1);productWrite(productKeys.contacts,savedContacts);close();renderContacts();toastProductivityUi('Contact removed')};selectProductivityUi('#contact-name').focus()} +function renderContacts(){const cards=savedContacts.map((c,i)=>`
${escapeProductivityUi(c.initials)}
${escapeProductivityUi(c.name)}${escapeProductivityUi(c.email)}${escapeProductivityUi(c.note)}
`).join('');selectProductivityUi('#contacts-view').innerHTML=`

THE PEOPLE WHO MAKE LIFE FULLER

Your people

${savedContacts.length} contacts, all in one place.

${cards||'

No contacts yet. Add someone to get started.

'}
`;selectProductivityUi('#add-contact').onclick=()=>showContact();selectProductivityUi('#contact-search').oninput=e=>selectAllProductivityUi('.contact-card').forEach(c=>c.classList.toggle('hidden',!c.innerText.toLowerCase().includes(e.target.value.toLowerCase())));selectProductivityUi('#contacts-view').onclick=e=>{const edit=e.target.closest('[data-edit-contact]');if(edit){showContact(Number(edit.dataset.editContact));return}const email=e.target.closest('.contact-email');if(email)productivityMailUi.showCompose({email:email.dataset.email,subject:'',date:''})};selectProductivityUi('#contacts-view').oncontextmenu=e=>{const card=e.target.closest('.contact-card');if(!card)return;e.preventDefault();const i=Number(card.dataset.contact);if(confirm(`Remove ${savedContacts[i].name} from contacts?`)){savedContacts.splice(i,1);productWrite(productKeys.contacts,savedContacts);renderContacts();toastProductivityUi('Contact removed')}}} +function accountRuleLabels(){return [...new Set((productivityMailUi.connectedAccount?.rules||[]).filter(rule=>rule.action==='label').map(rule=>rule.value).filter(Boolean))]} +function renderLabels(){const box=selectProductivityUi('#custom-labels');if(!box)return;const labels=[...new Set([...customLabels,...accountRuleLabels()])];box.innerHTML=labels.map(label=>``).join('');selectAllProductivityUi('.label-link').forEach(b=>b.onclick=()=>{document.querySelectorAll('.label-link').forEach(x=>x.classList.toggle('active',x===b));productivityMailUi.state.activeFolder=b.dataset.label;selectProductivityUi('#sidebar-title').textContent=productivityMailUi.state.activeFolder;selectProductivityUi('#crumb-current').textContent=productivityMailUi.state.activeFolder;productivityMailUi.renderList()})} +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()} +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='';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 ↓';}); +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 () { const state = productivityMailUi.state; if (state.activeFolder === 'Drafts') { @@ -71,7 +71,7 @@ productivityMailUi.wrapRenderList(baseMessageRenderer => function () { return; } return baseMessageRenderer(); -}); +}); document.addEventListener('click',event=>{const button=event.target.closest('.download');if(!button)return;event.stopImmediatePropagation();const message=productivityMailUi.state.messages.find(item=>item.id===productivityMailUi.state.activeMessage);const filename=button.dataset.filename||message?.attachment;if(!filename){toastProductivityUi('This message has no downloadable attachment');return}if(!message?.uid||!window.daybreakMail?.saveAttachment){toastProductivityUi('Attachment download is available for connected mailbox messages');return}window.daybreakMail.saveAttachment({uid:message.uid,folder:productivityMailUi.state.activeFolder,filename}).then(result=>{if(result.saved)toastProductivityUi('Attachment saved')}).catch(error=>toastProductivityUi(error.message||'Could not save attachment'))},true); window.epMailFeatures.productivity = Object.freeze({ diff --git a/scripts/android-bridge.js b/scripts/android-bridge.js index ec4488b..2f67d3d 100644 --- a/scripts/android-bridge.js +++ b/scripts/android-bridge.js @@ -1,40 +1,40 @@ -import { Capacitor, registerPlugin } from '@capacitor/core'; - -const EpMail = registerPlugin('EpMail'); - -if (Capacitor.isNativePlatform() && Capacitor.getPlatform() === 'android') { - window.daybreakMail = { - getAppVersion: () => EpMail.getAppVersion().then(result => result.version), - getAccount: () => EpMail.getAccount(), - listAccounts: () => EpMail.listAccounts(), - selectAccount: id => EpMail.selectAccount({ id }), - removeAccount: id => EpMail.removeAccount({ id }), - connect: details => EpMail.connect(details), - updateAccount: (id, details) => EpMail.updateAccount({ id, ...details }), - syncFolder: (folder, offset, filters) => EpMail.syncFolder({ folder, offset, filters }), - listFolders: () => EpMail.listFolders(), - createFolder: name => EpMail.createFolder({ name }), - listDrafts: () => EpMail.listDrafts(), - saveDraft: draft => EpMail.saveDraft(draft), - deleteDraft: id => EpMail.deleteDraft({ id }), - syncInbox: () => EpMail.syncFolder({ folder: 'Inbox', offset: 0 }), - onSyncUpdate: callback => EpMail.addListener('mailSyncUpdate', callback), - updateMessage: details => EpMail.updateMessage(details), - setSnooze: details => EpMail.setSnooze(details), - checkSnoozeReminders: () => EpMail.checkSnoozeReminders(), - previewAttachment: details => EpMail.previewAttachment(details), - saveAttachment: details => EpMail.saveAttachment(details), - openExternal: url => EpMail.openExternal({ url }), - send: message => EpMail.send(message), - disconnect: id => EpMail.removeAccount({ id }), - davList: () => EpMail.davList(), - davConnect: config => EpMail.davConnect(config), - davActivate: (type, id) => EpMail.davActivate({ type, id }), - davRemove: (type, id) => EpMail.davRemove({ type, id }), - davSync: type => EpMail.davSync({ type }), - davSaveEvent: event => EpMail.davSaveEvent(event), - davDeleteEvent: remote => EpMail.davDeleteEvent(remote), - davSaveContact: contact => EpMail.davSaveContact(contact), - davDeleteContact: remote => EpMail.davDeleteContact(remote) - }; -} +import { Capacitor, registerPlugin } from '@capacitor/core'; + +const EpMail = registerPlugin('EpMail'); + +if (Capacitor.isNativePlatform() && Capacitor.getPlatform() === 'android') { + window.daybreakMail = { + getAppVersion: () => EpMail.getAppVersion().then(result => result.version), + getAccount: () => EpMail.getAccount(), + listAccounts: () => EpMail.listAccounts(), + selectAccount: id => EpMail.selectAccount({ id }), + removeAccount: id => EpMail.removeAccount({ id }), + connect: details => EpMail.connect(details), + updateAccount: (id, details) => EpMail.updateAccount({ id, ...details }), + syncFolder: (folder, offset, filters) => EpMail.syncFolder({ folder, offset, filters }), + listFolders: () => EpMail.listFolders(), + createFolder: name => EpMail.createFolder({ name }), + listDrafts: () => EpMail.listDrafts(), + saveDraft: draft => EpMail.saveDraft(draft), + deleteDraft: id => EpMail.deleteDraft({ id }), + syncInbox: () => EpMail.syncFolder({ folder: 'Inbox', offset: 0 }), + onSyncUpdate: callback => EpMail.addListener('mailSyncUpdate', callback), + updateMessage: details => EpMail.updateMessage(details), + setSnooze: details => EpMail.setSnooze(details), + checkSnoozeReminders: () => EpMail.checkSnoozeReminders(), + previewAttachment: details => EpMail.previewAttachment(details), + saveAttachment: details => EpMail.saveAttachment(details), + openExternal: url => EpMail.openExternal({ url }), + send: message => EpMail.send(message), + disconnect: id => EpMail.removeAccount({ id }), + davList: () => EpMail.davList(), + davConnect: config => EpMail.davConnect(config), + davActivate: (type, id) => EpMail.davActivate({ type, id }), + davRemove: (type, id) => EpMail.davRemove({ type, id }), + davSync: type => EpMail.davSync({ type }), + davSaveEvent: event => EpMail.davSaveEvent(event), + davDeleteEvent: remote => EpMail.davDeleteEvent(remote), + davSaveContact: contact => EpMail.davSaveContact(contact), + davDeleteContact: remote => EpMail.davDeleteContact(remote) + }; +} diff --git a/scripts/build-all.ps1 b/scripts/build-all.ps1 index 4c1fbea..f4bf279 100644 --- a/scripts/build-all.ps1 +++ b/scripts/build-all.ps1 @@ -1,19 +1,19 @@ -# Builds the Android 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' } -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:" +# Builds the Android 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' } +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)" } \ No newline at end of file diff --git a/scripts/build-android-apk.cjs b/scripts/build-android-apk.cjs index 42051d8..d19b84a 100644 --- a/scripts/build-android-apk.cjs +++ b/scripts/build-android-apk.cjs @@ -1,27 +1,27 @@ -const { spawnSync } = require('node:child_process'); -const path = require('node:path'); -const fs = require('node:fs'); - -const androidDir = path.resolve(__dirname, '..', 'android'); -const gradleWrapper = process.platform === 'win32' ? 'gradlew.bat' : './gradlew'; -const result = spawnSync(gradleWrapper, ['assembleDebug'], { - cwd: androidDir, - stdio: 'inherit', - shell: process.platform === 'win32' -}); - -if (result.error) { - console.error(`Could not start the Android Gradle wrapper: ${result.error.message}`); - process.exitCode = 1; -} else if (result.status) { - process.exitCode = result.status; -} else { - const root = path.resolve(__dirname, '..'); - const { version } = require(path.join(root, 'package.json')); - const apk = path.join(androidDir, 'app', 'build', 'outputs', 'apk', 'debug', 'app-debug.apk'); - const releaseDir = path.join(root, 'release'); - const target = path.join(releaseDir, `ep-mail ${version}.apk`); - fs.mkdirSync(releaseDir, { recursive: true }); - fs.copyFileSync(apk, target); - console.log(`APK copied to ${target}`); +const { spawnSync } = require('node:child_process'); +const path = require('node:path'); +const fs = require('node:fs'); + +const androidDir = path.resolve(__dirname, '..', 'android'); +const gradleWrapper = process.platform === 'win32' ? 'gradlew.bat' : './gradlew'; +const result = spawnSync(gradleWrapper, ['assembleDebug'], { + cwd: androidDir, + stdio: 'inherit', + shell: process.platform === 'win32' +}); + +if (result.error) { + console.error(`Could not start the Android Gradle wrapper: ${result.error.message}`); + process.exitCode = 1; +} else if (result.status !== 0) { + process.exitCode = result.status || 1; +} else { + const root = path.resolve(__dirname, '..'); + const { version } = require(path.join(root, 'package.json')); + const apk = path.join(androidDir, 'app', 'build', 'outputs', 'apk', 'debug', 'app-debug.apk'); + const releaseDir = path.join(root, 'release'); + const target = path.join(releaseDir, `ep-mail ${version}-debug.apk`); + fs.mkdirSync(releaseDir, { recursive: true }); + fs.copyFileSync(apk, target); + console.log(`Debug APK copied to ${target}`); } diff --git a/scripts/build-android-release-apk.cjs b/scripts/build-android-release-apk.cjs new file mode 100644 index 0000000..fe2c06b --- /dev/null +++ b/scripts/build-android-release-apk.cjs @@ -0,0 +1,47 @@ +const { spawnSync } = require('node:child_process'); +const path = require('node:path'); +const fs = require('node:fs'); + +const requiredSigningVariables = [ + 'EP_MAIL_ANDROID_STORE_FILE', + 'EP_MAIL_ANDROID_STORE_PASSWORD', + 'EP_MAIL_ANDROID_KEY_ALIAS', + 'EP_MAIL_ANDROID_KEY_PASSWORD' +]; +const missing = requiredSigningVariables.filter(name => !process.env[name]); +if (missing.length) { + console.error(`Signed Android release requires these environment variables: ${missing.join(', ')}`); + process.exitCode = 1; +} else if (!path.isAbsolute(process.env.EP_MAIL_ANDROID_STORE_FILE)) { + console.error('EP_MAIL_ANDROID_STORE_FILE must be an absolute path.'); + process.exitCode = 1; +} else { + const androidDir = path.resolve(__dirname, '..', 'android'); + const gradleWrapper = process.platform === 'win32' ? 'gradlew.bat' : './gradlew'; + const result = spawnSync(gradleWrapper, ['assembleRelease'], { + cwd: androidDir, + stdio: 'inherit', + shell: process.platform === 'win32' + }); + + if (result.error) { + console.error(`Could not start the Android Gradle wrapper: ${result.error.message}`); + process.exitCode = 1; + } else if (result.status !== 0) { + process.exitCode = result.status || 1; + } else { + const root = path.resolve(__dirname, '..'); + const { version } = require(path.join(root, 'package.json')); + const apk = path.join(androidDir, 'app', 'build', 'outputs', 'apk', 'release', 'app-release.apk'); + const releaseDir = path.join(root, 'release'); + const target = path.join(releaseDir, `ep-mail ${version}.apk`); + if (!fs.existsSync(apk)) { + console.error(`Gradle did not produce the expected release APK: ${apk}`); + process.exitCode = 1; + } else { + fs.mkdirSync(releaseDir, { recursive: true }); + fs.copyFileSync(apk, target); + console.log(`Signed release APK copied to ${target}`); + } + } +} diff --git a/scripts/prepare-android-web.cjs b/scripts/prepare-android-web.cjs index 45e418a..2bbfb41 100644 --- a/scripts/prepare-android-web.cjs +++ b/scripts/prepare-android-web.cjs @@ -1,52 +1,52 @@ -const fs = require('node:fs/promises'); -const path = require('node:path'); -const esbuild = require('esbuild'); - -const root = path.resolve(__dirname, '..'); -const output = path.join(root, 'www'); -const assets = [ - 'index.html', - 'styles.css', +const fs = require('node:fs/promises'); +const path = require('node:path'); +const esbuild = require('esbuild'); + +const root = path.resolve(__dirname, '..'); +const output = path.join(root, 'www'); +const assets = [ + 'index.html', + 'styles.css', 'branding.css', 'platform-bridge-loader.js', 'renderer-state.js', 'mail-content-security.js', 'renderer-mail-api.js', 'app.js', - 'mail-ui.js', - 'productivity.js', - 'account-ui.js', - 'dav-ui.js', - 'shortcuts.js', - 'attachments.js', - 'pgp-ui.js', - 'pgp-mail-ui.js', - 'icon.svg', - 'logo-ep-daylight.svg', - 'logo-ep-wasteland.svg', - 'manifest.webmanifest', - 'service-worker.js', - 'snooze-ui.js' -]; - -async function prepare() { - await fs.rm(output, { recursive: true, force: true }); - await fs.mkdir(output, { recursive: true }); - for (const asset of assets) { - await fs.copyFile(path.join(root, asset), path.join(output, asset)); - } - const bridgePath = path.join(root, 'platform-bridge.js'); - await esbuild.build({ - entryPoints: [path.join(root, 'scripts', 'android-bridge.js')], - outfile: bridgePath, - bundle: true, - platform: 'browser', - format: 'iife' - }); - await fs.copyFile(bridgePath, path.join(output, 'platform-bridge.js')); -} - -prepare().catch(error => { - console.error('Could not prepare Android web assets:', error); - process.exitCode = 1; -}); + 'mail-ui.js', + 'productivity.js', + 'account-ui.js', + 'dav-ui.js', + 'shortcuts.js', + 'attachments.js', + 'pgp-ui.js', + 'pgp-mail-ui.js', + 'icon.svg', + 'logo-ep-daylight.svg', + 'logo-ep-wasteland.svg', + 'manifest.webmanifest', + 'service-worker.js', + 'snooze-ui.js' +]; + +async function prepare() { + await fs.rm(output, { recursive: true, force: true }); + await fs.mkdir(output, { recursive: true }); + for (const asset of assets) { + await fs.copyFile(path.join(root, asset), path.join(output, asset)); + } + const bridgePath = path.join(root, 'platform-bridge.js'); + await esbuild.build({ + entryPoints: [path.join(root, 'scripts', 'android-bridge.js')], + outfile: bridgePath, + bundle: true, + platform: 'browser', + format: 'iife' + }); + await fs.copyFile(bridgePath, path.join(output, 'platform-bridge.js')); +} + +prepare().catch(error => { + console.error('Could not prepare Android web assets:', error); + process.exitCode = 1; +}); diff --git a/service-worker.js b/service-worker.js index f8ff469..eb59867 100644 --- a/service-worker.js +++ b/service-worker.js @@ -1,5 +1,5 @@ const CACHE='ep-mail-v12'; 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']; -self.addEventListener('install',event=>event.waitUntil(caches.open(CACHE).then(cache=>cache.addAll(FILES)))); -self.addEventListener('activate',event=>event.waitUntil(caches.keys().then(keys=>Promise.all(keys.filter(k=>k!==CACHE).map(k=>caches.delete(k)))))); -self.addEventListener('fetch',event=>{if(event.request.method!=='GET')return;event.respondWith(caches.match(event.request).then(cached=>cached||fetch(event.request).then(response=>{if(new URL(event.request.url).origin===location.origin){const copy=response.clone();caches.open(CACHE).then(cache=>cache.put(event.request,copy))}return response}).catch(()=>caches.match('./index.html'))))}); +self.addEventListener('install',event=>event.waitUntil(caches.open(CACHE).then(cache=>cache.addAll(FILES)))); +self.addEventListener('activate',event=>event.waitUntil(caches.keys().then(keys=>Promise.all(keys.filter(k=>k!==CACHE).map(k=>caches.delete(k)))))); +self.addEventListener('fetch',event=>{if(event.request.method!=='GET')return;event.respondWith(caches.match(event.request).then(cached=>cached||fetch(event.request).then(response=>{if(new URL(event.request.url).origin===location.origin){const copy=response.clone();caches.open(CACHE).then(cache=>cache.put(event.request,copy))}return response}).catch(()=>caches.match('./index.html'))))}); diff --git a/shortcuts.js b/shortcuts.js index 15f7ab9..e5a3d80 100644 --- a/shortcuts.js +++ b/shortcuts.js @@ -6,102 +6,102 @@ const selectShortcutUi = shortcutMailUi.select; const toastShortcutUi = shortcutMailUi.toast; const escapeShortcutUi = shortcutMailUi.escapeHtml; const shortcutStorageKey = 'daybreak-shortcuts'; -const shortcutActions = [ - { id: 'compose', label: 'Compose', fallback: 'c', run: () => selectShortcutUi('#compose')?.click() }, - { id: 'search', label: 'Search', fallback: '/', run: () => selectShortcutUi('#search')?.focus() }, - { id: 'refresh', label: 'Refresh', fallback: 'r', run: () => selectShortcutUi('#refresh')?.click() }, - { id: 'archive', label: 'Archive message', fallback: 'e', run: () => selectShortcutUi('#reader-archive')?.click() }, - { id: 'delete', label: 'Delete message', fallback: '#', run: () => selectShortcutUi('#reader-delete')?.click() }, - { id: 'star', label: 'Star message', fallback: 's', run: () => selectShortcutUi('#reader-star')?.click() }, - { id: 'reply', label: 'Reply', fallback: 'a', run: () => selectShortcutUi('#reply')?.click() }, - { id: 'forward', label: 'Forward', fallback: 'f', run: () => selectShortcutUi('#forward')?.click() }, - { id: 'next', label: 'Next message', fallback: 'j', run: () => moveMessageSelection(1) }, - { id: 'previous', label: 'Previous message', fallback: 'k', run: () => moveMessageSelection(-1) } -]; - -function normalizeShortcut(value) { - const text = String(value || '').trim(); - if (!text) return ''; - const parts = text.split('+').map(part => part.trim()).filter(Boolean); - const key = parts.pop() || '+'; - const mods = ['Ctrl', 'Alt', 'Shift'].filter(mod => parts.some(part => part.toLowerCase() === mod.toLowerCase())); - return [...mods, key.length === 1 ? key.toLowerCase() : key].join('+'); -} - -function loadShortcuts() { - let saved = {}; - try { saved = JSON.parse(localStorage.getItem(shortcutStorageKey)) || {}; } catch {} - return Object.fromEntries(shortcutActions.map(action => [ - action.id, typeof saved[action.id] === 'string' ? normalizeShortcut(saved[action.id]) : action.fallback - ])); -} - -function eventShortcut(event) { - if (['Control', 'Alt', 'Shift', 'Meta'].includes(event.key)) return ''; - const mods = [event.ctrlKey || event.metaKey ? 'Ctrl' : '', event.altKey ? 'Alt' : '']; - const printable = event.key.length === 1; - if (event.shiftKey && !printable) mods.push('Shift'); - return normalizeShortcut([...mods.filter(Boolean), event.key === ' ' ? 'Space' : event.key].join('+')); -} - +const shortcutActions = [ + { id: 'compose', label: 'Compose', fallback: 'c', run: () => selectShortcutUi('#compose')?.click() }, + { id: 'search', label: 'Search', fallback: '/', run: () => selectShortcutUi('#search')?.focus() }, + { id: 'refresh', label: 'Refresh', fallback: 'r', run: () => selectShortcutUi('#refresh')?.click() }, + { id: 'archive', label: 'Archive message', fallback: 'e', run: () => selectShortcutUi('#reader-archive')?.click() }, + { id: 'delete', label: 'Delete message', fallback: '#', run: () => selectShortcutUi('#reader-delete')?.click() }, + { id: 'star', label: 'Star message', fallback: 's', run: () => selectShortcutUi('#reader-star')?.click() }, + { id: 'reply', label: 'Reply', fallback: 'a', run: () => selectShortcutUi('#reply')?.click() }, + { id: 'forward', label: 'Forward', fallback: 'f', run: () => selectShortcutUi('#forward')?.click() }, + { id: 'next', label: 'Next message', fallback: 'j', run: () => moveMessageSelection(1) }, + { id: 'previous', label: 'Previous message', fallback: 'k', run: () => moveMessageSelection(-1) } +]; + +function normalizeShortcut(value) { + const text = String(value || '').trim(); + if (!text) return ''; + const parts = text.split('+').map(part => part.trim()).filter(Boolean); + const key = parts.pop() || '+'; + const mods = ['Ctrl', 'Alt', 'Shift'].filter(mod => parts.some(part => part.toLowerCase() === mod.toLowerCase())); + return [...mods, key.length === 1 ? key.toLowerCase() : key].join('+'); +} + +function loadShortcuts() { + let saved = {}; + try { saved = JSON.parse(localStorage.getItem(shortcutStorageKey)) || {}; } catch {} + return Object.fromEntries(shortcutActions.map(action => [ + action.id, typeof saved[action.id] === 'string' ? normalizeShortcut(saved[action.id]) : action.fallback + ])); +} + +function eventShortcut(event) { + if (['Control', 'Alt', 'Shift', 'Meta'].includes(event.key)) return ''; + const mods = [event.ctrlKey || event.metaKey ? 'Ctrl' : '', event.altKey ? 'Alt' : '']; + const printable = event.key.length === 1; + if (event.shiftKey && !printable) mods.push('Shift'); + return normalizeShortcut([...mods.filter(Boolean), event.key === ' ' ? 'Space' : event.key].join('+')); +} + function moveMessageSelection(step) { const messages = shortcutMailUi.state.messages; if (!messages.length) return; const index = messages.findIndex(message => message.id === shortcutMailUi.state.activeMessage); const next = messages[Math.min(messages.length - 1, Math.max(0, index + step))]; if (next) { shortcutMailUi.openMessage(next.id); selectShortcutUi(`.message[data-id="${next.id}"]`)?.scrollIntoView({ block: 'nearest' }); } -} - -document.addEventListener('keydown', event => { - if (event.defaultPrevented || event.isComposing || event.key === 'Escape') return; - const target = event.target; - if (target?.closest?.('input, textarea, select, [contenteditable="true"]') || selectShortcutUi('#modal-root')?.children.length) return; - const pressed = eventShortcut(event); - if (!pressed) return; - const shortcuts = loadShortcuts(); - const action = shortcutActions.find(item => shortcuts[item.id] && shortcuts[item.id] === pressed); - if (!action) return; - event.preventDefault(); - action.run(); -}); - +} + +document.addEventListener('keydown', event => { + if (event.defaultPrevented || event.isComposing || event.key === 'Escape') return; + const target = event.target; + if (target?.closest?.('input, textarea, select, [contenteditable="true"]') || selectShortcutUi('#modal-root')?.children.length) return; + const pressed = eventShortcut(event); + if (!pressed) return; + const shortcuts = loadShortcuts(); + const action = shortcutActions.find(item => shortcuts[item.id] && shortcuts[item.id] === pressed); + if (!action) return; + event.preventDefault(); + action.run(); +}); + shortcutProductivityUi.wrapOpenPreferences(baseOpenPreferences => function () { - baseOpenPreferences(); - const fields = selectShortcutUi('#modal-root .compose-fields'); - const save = selectShortcutUi('#save-appearance'); - if (!fields || !save) return; - const shortcuts = loadShortcuts(); - const section = document.createElement('div'); - section.className = 'shortcut-settings'; - section.innerHTML = `

Keyboard shortcuts

${shortcutActions.map(action => - ``).join('')}`; - fields.append(section); - section.addEventListener('keydown', event => { - const input = event.target.closest('.shortcut-input'); - if (!input || ['Tab', 'Escape'].includes(event.key)) return; - event.preventDefault(); - if (['Backspace', 'Delete'].includes(event.key)) { input.value = ''; return; } - 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); - }; + baseOpenPreferences(); + const fields = selectShortcutUi('#modal-root .compose-fields'); + const save = selectShortcutUi('#save-appearance'); + if (!fields || !save) return; + const shortcuts = loadShortcuts(); + const section = document.createElement('div'); + section.className = 'shortcut-settings'; + section.innerHTML = `

Keyboard shortcuts

${shortcutActions.map(action => + ``).join('')}`; + fields.append(section); + section.addEventListener('keydown', event => { + const input = event.target.closest('.shortcut-input'); + if (!input || ['Tab', 'Escape'].includes(event.key)) return; + event.preventDefault(); + if (['Backspace', 'Delete'].includes(event.key)) { input.value = ''; return; } + 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); + }; }); })(); diff --git a/snooze-ui.js b/snooze-ui.js index 9beb0c7..a1a9c83 100644 --- a/snooze-ui.js +++ b/snooze-ui.js @@ -3,91 +3,91 @@ const snoozeMailUi = window.epMailFeatures.mail; const snoozeProductivityUi = window.epMailFeatures.productivity; function localDateTimeValue(date) { - const local = new Date(date.getTime() - date.getTimezoneOffset() * 60000); - return local.toISOString().slice(0, 16); -} - -function nextMorning(daysAhead) { - const date = new Date(); - date.setDate(date.getDate() + daysAhead); - date.setHours(9, 0, 0, 0); - if (date <= new Date()) date.setDate(date.getDate() + 1); - return date; -} - -function openSnoozeDialog(items) { + const local = new Date(date.getTime() - date.getTimezoneOffset() * 60000); + return local.toISOString().slice(0, 16); +} + +function nextMorning(daysAhead) { + const date = new Date(); + date.setDate(date.getDate() + daysAhead); + date.setHours(9, 0, 0, 0); + if (date <= new Date()) date.setDate(date.getDate() + 1); + return date; +} + +function openSnoozeDialog(items) { const eligible = items.filter(message => message?.uid && snoozeMailUi.connectedAccount); - if (!eligible.length) { + if (!eligible.length) { snoozeMailUi.toast('Snoozing is available for messages in a connected mailbox.'); - return; - } + return; + } const root = snoozeMailUi.select('#modal-root'); - const tomorrow = nextMorning(1); - const laterToday = new Date(Date.now() + 3 * 60 * 60 * 1000); - root.innerHTML = ``; - const close = () => { root.innerHTML = ''; }; - root.querySelectorAll('.modal-close').forEach(button => button.onclick = close); - root.querySelector('.modal-overlay').onclick = event => { - if (event.target.classList.contains('modal-overlay')) close(); - }; - - const schedule = async dueAt => { - if (!Number.isFinite(dueAt) || dueAt <= Date.now()) { + const tomorrow = nextMorning(1); + const laterToday = new Date(Date.now() + 3 * 60 * 60 * 1000); + root.innerHTML = ``; + const close = () => { root.innerHTML = ''; }; + root.querySelectorAll('.modal-close').forEach(button => button.onclick = close); + root.querySelector('.modal-overlay').onclick = event => { + if (event.target.classList.contains('modal-overlay')) close(); + }; + + const schedule = async dueAt => { + if (!Number.isFinite(dueAt) || dueAt <= Date.now()) { snoozeMailUi.select('#snooze-status').textContent = 'Choose a reminder time in the future.'; - return; - } - const buttons = [...root.querySelectorAll('button')]; - buttons.forEach(button => { button.disabled = true; }); - try { - for (const message of eligible) { - const sourceFolder = message.sourceFolder || + return; + } + const buttons = [...root.querySelectorAll('button')]; + buttons.forEach(button => { button.disabled = true; }); + try { + for (const message of eligible) { + const sourceFolder = message.sourceFolder || (['Inbox', 'Sent', 'Archive', 'Trash'].includes(snoozeMailUi.state.activeFolder) ? snoozeMailUi.state.activeFolder : 'Inbox'); - await window.daybreakMail.setSnooze({ - uid: message.uid, - folder: sourceFolder, - sourceFolder, - dueAt, - subject: message.subject - }); - } - close(); + await window.daybreakMail.setSnooze({ + uid: message.uid, + folder: sourceFolder, + sourceFolder, + dueAt, + subject: message.subject + }); + } + close(); snoozeMailUi.toast(eligible.length === 1 ? 'Message snoozed' : `${eligible.length} messages snoozed`); snoozeMailUi.state.selectedIds.clear(); await snoozeMailUi.syncMailbox(false, { offset: 0 }); - } catch (error) { + } catch (error) { snoozeMailUi.select('#snooze-status').textContent = error.message || 'Could not set the reminder.'; - buttons.forEach(button => { button.disabled = false; }); - } - }; - - root.querySelectorAll('[data-snooze-at]').forEach(button => { - button.onclick = () => schedule(Number(button.dataset.snoozeAt)); - }); + buttons.forEach(button => { button.disabled = false; }); + } + }; + + root.querySelectorAll('[data-snooze-at]').forEach(button => { + button.onclick = () => schedule(Number(button.dataset.snoozeAt)); + }); snoozeMailUi.select('#snooze-custom').onclick = () => schedule(new Date(snoozeMailUi.select('#snooze-custom-time').value).getTime()); snoozeMailUi.select('#snooze-custom-time').focus(); -} - -function unsnoozeMessage(message) { - const sourceFolder = message.sourceFolder || 'Inbox'; - window.daybreakMail.setSnooze({ - uid: message.uid, - sourceFolder, - dueAt: null - }).then(async () => { +} + +function unsnoozeMessage(message) { + const sourceFolder = message.sourceFolder || 'Inbox'; + window.daybreakMail.setSnooze({ + uid: message.uid, + sourceFolder, + dueAt: null + }).then(async () => { snoozeMailUi.toast('Message returned to its mailbox'); await snoozeMailUi.syncMailbox(false, { offset: 0 }); }).catch(error => snoozeMailUi.toast(error.message || 'Could not return the message')); -} - -function showMessageActions(message) { +} + +function showMessageActions(message) { const root = snoozeMailUi.select('#modal-root'); - root.innerHTML = ``; - root.querySelectorAll('.modal-close').forEach(button => button.onclick = () => { root.innerHTML = ''; }); - root.querySelector('.modal-overlay').onclick = event => { - if (event.target.classList.contains('modal-overlay')) root.innerHTML = ''; - }; -} - + root.innerHTML = ``; + root.querySelectorAll('.modal-close').forEach(button => button.onclick = () => { root.innerHTML = ''; }); + root.querySelector('.modal-overlay').onclick = event => { + if (event.target.classList.contains('modal-overlay')) root.innerHTML = ''; + }; +} + snoozeMailUi.wrapRenderList(renderListBeforeSnooze => function () { if (snoozeMailUi.state.activeFolder === 'Snoozed') { const originalMessages = snoozeMailUi.state.messages.slice(); @@ -99,21 +99,21 @@ snoozeMailUi.wrapRenderList(renderListBeforeSnooze => function () { snoozeMailUi.state.activeFolder = 'Inbox'; snoozeMailUi.baseRenderList(); snoozeMailUi.state.activeFolder = folder; - originalFlags.forEach(([message, archived, deleted]) => { - message.archived = archived; - message.deleted = deleted; - }); + originalFlags.forEach(([message, archived, deleted]) => { + message.archived = archived; + message.deleted = deleted; + }); snoozeMailUi.state.messages.splice(0, snoozeMailUi.state.messages.length, ...originalMessages); for (const row of snoozeMailUi.selectAll('.message')) { const message = snoozeMailUi.state.messages.find(item => item.id === Number(row.dataset.id)); - if (!message?.snoozedUntil) continue; - const due = new Date(message.snoozedUntil); - row.title = `Reminder ${due.toLocaleString()}`; - const snippet = row.querySelector('.snippet'); - if (snippet) snippet.textContent = `Reminder · ${due.toLocaleString()} · ${message.snippet}`; - } - return; - } + if (!message?.snoozedUntil) continue; + const due = new Date(message.snoozedUntil); + row.title = `Reminder ${due.toLocaleString()}`; + const snippet = row.querySelector('.snippet'); + if (snippet) snippet.textContent = `Reminder · ${due.toLocaleString()} · ${message.snippet}`; + } + return; + } return renderListBeforeSnooze(); }); @@ -121,61 +121,61 @@ snoozeMailUi.wrapOpenMessage(openMessageBeforeSnooze => function (id) { openMessageBeforeSnooze(id); const message = snoozeMailUi.state.messages.find(item => item.id === id); const tools = snoozeMailUi.select('.reader-tools'); - if (!message || !tools) return; + if (!message || !tools) return; const snoozed = snoozeMailUi.state.activeFolder === 'Snoozed'; - tools.insertAdjacentHTML('afterbegin', ``); + tools.insertAdjacentHTML('afterbegin', ``); }); document.addEventListener('DOMContentLoaded', () => { snoozeMailUi.select('#mark-unread').insertAdjacentHTML('afterend', ''); - if (window.daybreakMail?.checkSnoozeReminders) { - const checkReminders = () => window.daybreakMail.checkSnoozeReminders() - .catch(error => console.error('Could not check mail reminders:', error)); - void checkReminders(); - setInterval(checkReminders, 60 * 1000); - } -}); - + if (window.daybreakMail?.checkSnoozeReminders) { + const checkReminders = () => window.daybreakMail.checkSnoozeReminders() + .catch(error => console.error('Could not check mail reminders:', error)); + void checkReminders(); + setInterval(checkReminders, 60 * 1000); + } +}); + document.addEventListener('click', event => { - const action = event.target.closest('[data-message-action]'); - const more = event.target.closest('.reader-tools button[title="More"]'); - const snooze = event.target.closest('#reader-snooze, #snooze-selected'); - const unsnooze = event.target.closest('#reader-unsnooze'); - if (!more && !snooze && !unsnooze && !action) return; - event.preventDefault(); - event.stopImmediatePropagation(); - if (action) { + const action = event.target.closest('[data-message-action]'); + const more = event.target.closest('.reader-tools button[title="More"]'); + const snooze = event.target.closest('#reader-snooze, #snooze-selected'); + const unsnooze = event.target.closest('#reader-unsnooze'); + if (!more && !snooze && !unsnooze && !action) return; + event.preventDefault(); + event.stopImmediatePropagation(); + if (action) { const message = snoozeMailUi.state.messages.find(item => item.id === snoozeMailUi.state.activeMessage); snoozeMailUi.select('#modal-root').innerHTML = ''; - if (!message) return; - if (action.dataset.messageAction === 'snooze') openSnoozeDialog([message]); + if (!message) return; + if (action.dataset.messageAction === 'snooze') openSnoozeDialog([message]); else if (action.dataset.messageAction === 'label') snoozeProductivityUi.addMessageLabel(message); - else { - const type = action.dataset.messageAction; - messageAction(message, type).then(() => { - if (type === 'unread') message.unread = true; - if (type === 'inbox') message.archived = false; + else { + const type = action.dataset.messageAction; + messageAction(message, type).then(() => { + if (type === 'unread') message.unread = true; + if (type === 'inbox') message.archived = false; snoozeMailUi.renderList(); snoozeMailUi.toast(type === 'unread' ? 'Marked unread' : 'Moved to Inbox'); }).catch(error => snoozeMailUi.toast(error.message || 'Could not update the message')); - } - return; - } - if (unsnooze) { + } + return; + } + if (unsnooze) { const message = snoozeMailUi.state.messages.find(item => item.id === snoozeMailUi.state.activeMessage); - if (message) unsnoozeMessage(message); - return; - } - if (snooze?.id === 'snooze-selected') { + if (message) unsnoozeMessage(message); + return; + } + if (snooze?.id === 'snooze-selected') { openSnoozeDialog(snoozeMailUi.state.messages.filter(message => snoozeMailUi.state.selectedIds.has(message.id))); - return; - } - if (more) { + return; + } + if (more) { const message = snoozeMailUi.state.messages.find(item => item.id === snoozeMailUi.state.activeMessage); - if (message) showMessageActions(message); - return; - } + if (message) showMessageActions(message); + return; + } const message = snoozeMailUi.state.messages.find(item => item.id === snoozeMailUi.state.activeMessage); - if (message) openSnoozeDialog([message]); + if (message) openSnoozeDialog([message]); }, true); })(); diff --git a/styles.css b/styles.css index b8f6385..2643ed1 100644 --- a/styles.css +++ b/styles.css @@ -1,143 +1,143 @@ -:root{font-family:'DM Sans',Inter,ui-sans-serif,system-ui,-apple-system,'Segoe UI',sans-serif;color:#252a28;background:#f4f5f1;font-synthesis:none;text-rendering:optimizeLegibility;--bg:#f4f5f1;--panel:#fff;--line:#eaede8;--text:#252a28;--muted:#8b918b;--subtle:#f7f8f5;--accent:#55816c;--accent-soft:#edf4ef;--shadow:0 2px 10px #2636290b} -*{box-sizing:border-box}body{margin:0;min-width:760px;min-height:100vh;background:var(--bg);color:var(--text)}button,input,textarea{font:inherit}button{color:inherit;cursor:pointer}button:focus-visible,input:focus-visible,textarea:focus-visible{outline:2px solid #7eae90;outline-offset:2px}.app-shell{height:100vh;min-height:640px;display:flex;overflow:hidden}.rail{width:66px;flex:none;background:#edf0ea;border-right:1px solid #e5e9e2;display:flex;align-items:center;flex-direction:column;padding:17px 0 13px;gap:10px}.brand-mark{height:35px;width:35px;border-radius:12px;background:#5b826c;color:white;display:grid;place-items:center;font-size:24px;margin-bottom:21px;box-shadow:0 3px 8px #476c541d}.rail-button{height:39px;width:39px;border:0;background:transparent;color:#7e8780;border-radius:11px;font-size:20px;display:grid;place-items:center;transition:.18s}.rail-button:hover{background:#e2e8e1;color:#446a54}.rail-button.active{color:#477253;background:#dce9dd}.rail-spacer{flex:1}.avatar{border:0;border-radius:50%;height:34px;width:34px;background:#e7cbb6;color:#614c3c;font-size:11px;font-weight:700;display:grid;place-items:center}.avatar.tiny{height:27px;width:27px;font-size:9px} -.sidebar{width:244px;flex:none;background:#fff;border-right:1px solid var(--line);padding:26px 17px 14px;display:flex;flex-direction:column}.sidebar-head{display:flex;align-items:center;justify-content:space-between;padding:0 5px;margin-bottom:21px}.eyebrow{color:#969c95;font-size:9px;font-weight:700;letter-spacing:1.25px;margin:0 0 5px}.sidebar-head h1{font-family:'DM Serif Display',Georgia,serif;font-size:24px;font-weight:400;margin:0}.icon-button{border:0;background:transparent;color:#89918a;height:30px;min-width:30px;border-radius:8px;font-size:19px;display:inline-grid;place-items:center}.icon-button:hover{background:var(--subtle);color:#47544a}.account-card{display:flex;align-items:center;gap:10px;padding:10px 9px;background:#f7f8f5;border:1px solid #eff1ec;border-radius:10px;margin:0 0 22px}.account-avatar{height:30px;width:30px;border-radius:9px;background:#dce9dd;color:#477253;display:grid;place-items:center;font-family:Georgia,serif;font-weight:bold}.account-info{min-width:0;display:flex;flex-direction:column;gap:2px;flex:1}.account-info strong{font-size:11px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.account-info span{color:#929891;font-size:9px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.online-dot{display:inline-block;width:7px;height:7px;border-radius:50%;background:#70ad7b}.folder-nav{display:grid;gap:3px}.folder{width:100%;border:0;background:transparent;display:flex;align-items:center;gap:12px;text-align:left;padding:9px 10px;border-radius:8px;font-size:11px;color:#707970}.folder:hover,.label-link:hover{background:#f6f8f5}.folder.active{background:#edf4ee;color:#487354;font-weight:600}.nav-glyph{width:15px;text-align:center;font-size:15px;color:#879188}.folder.active .nav-glyph{color:#578366}.count{margin-left:auto;padding:2px 6px;min-width:19px;text-align:center;border-radius:5px;background:#fff;color:#61836a;font-size:9px}.count.muted{color:#969c95}.sidebar-divider{height:1px;background:#edf0ec;margin:18px 4px 16px}.section-label{display:flex;justify-content:space-between;align-items:center;font-size:9px;letter-spacing:1.1px;font-weight:700;color:#a0a59f;padding:0 6px;margin-bottom:9px}.tiny-plus{border:0;background:transparent;color:#929990;font-size:18px}.label-link{border:0;background:transparent;border-radius:7px;text-align:left;display:flex;align-items:center;gap:10px;color:#727970;font-size:11px;padding:8px 10px}.label-dot{width:8px;height:8px;border-radius:50%}.dot-amber{background:#dda854}.dot-blue{background:#79a4c9}.dot-green{background:#82ab83}.sidebar-bottom{margin-top:auto}.storage{padding:13px 10px 14px;border-bottom:1px solid #eef0ec}.storage-top{display:flex;justify-content:space-between;color:#606960;font-size:10px}.storage-top span+span{color:#979d97;font-size:9px}.storage-bar{height:4px;background:#edf0eb;margin:9px 0 7px;border-radius:5px;overflow:hidden}.storage-bar i{display:block;width:28%;height:100%;background:#79a785;border-radius:5px}.storage small{font-size:9px;color:#9ba19a}.settings-button{border:0;background:transparent;color:#7e867f;display:flex;gap:10px;align-items:center;margin:10px 0 0 4px;font-size:11px;padding:7px} -.main-area{flex:1;min-width:0;display:flex;flex-direction:column}.topbar{height:57px;flex:none;background:#fff;border-bottom:1px solid var(--line);display:flex;align-items:center;justify-content:space-between;padding:0 24px}.breadcrumbs{display:flex;align-items:center;gap:10px;font-size:10px;color:#969c96}.breadcrumbs strong{font-weight:600;color:#475048}.crumb-divider{color:#c6cbc5}.top-actions{display:flex;align-items:center;gap:13px}.search-wrap{height:31px;width:218px;background:#f6f7f4;border:1px solid #eff0ec;border-radius:8px;display:flex;align-items:center;padding:0 9px;gap:7px;color:#90978f}.search-wrap>span{font-size:19px}.search-wrap input{border:0;outline:0;background:transparent;width:100%;font-size:10px;color:#3f4740}.search-wrap kbd{font:9px 'DM Sans',sans-serif;border:1px solid #e3e6e1;border-radius:4px;padding:2px 4px;white-space:nowrap;color:#999f99}.help-button{font-size:12px;border:1px solid #e7eae6;border-radius:50%;height:20px;min-width:20px;font-weight:600}.top-avatar{width:27px;height:27px;font-size:9px} -.content-view{flex:1;min-height:0}.mail-layout{display:grid;grid-template-columns:minmax(330px,44%) minmax(340px,1fr);padding:18px 20px 20px;gap:14px}.list-pane,.reader-pane{background:var(--panel);border:1px solid var(--line);border-radius:12px;box-shadow:var(--shadow);min-height:0}.list-pane{display:flex;flex-direction:column;overflow:hidden}.list-heading{padding:20px 19px 15px;display:flex;align-items:center;justify-content:space-between}.date-line{font-size:8px;font-weight:700;letter-spacing:1.25px;color:#a0a69f;margin-bottom:7px}.list-heading h2{font-family:'DM Serif Display',Georgia,serif;font-size:20px;font-weight:400;margin:0;color:#303732}.sun{font-family:sans-serif;font-size:14px;color:#dda95f;vertical-align:2px}.compose-button{border:0;border-radius:7px;background:#5b8068;color:white;padding:8px 12px;font-size:10px;font-weight:600;box-shadow:0 2px 4px #406e4f20}.compose-button:hover{background:#476f56}.compose-button span{font-size:15px;vertical-align:-1px;margin-right:4px}.toolbar{height:39px;border-top:1px solid #f2f3f1;border-bottom:1px solid #f0f2ee;display:flex;align-items:center;padding:0 12px;gap:6px;color:#888f88}.toolbar .icon-button{font-size:15px;height:26px;min-width:26px}.tool-checkbox{font-size:14px;color:#818981;border:0;background:transparent;width:25px}.toolbar-divider{height:16px;width:1px;background:#e9ece8;margin:0 3px}.toolbar-spacer{flex:1}.pagination{font-size:9px;color:#90968f;white-space:nowrap}.message-list{overflow-y:auto;flex:1}.message{min-height:68px;display:grid;grid-template-columns:18px 32px minmax(0,1fr) auto;align-items:center;gap:9px;padding:9px 12px;border-bottom:1px solid #f0f2ef;cursor:pointer;transition:background .14s}.message:hover{background:#fafbf9}.message.selected{background:#f3f7f2;box-shadow:inset 2px 0 #669074}.message.unread .sender,.message.unread .subject{font-weight:700;color:#303832}.row-check{appearance:none;width:13px;height:13px;border:1px solid #d7dcd6;border-radius:3px;cursor:pointer;margin:0}.row-check:checked{appearance:auto;accent-color:#63866d}.contact-avatar{width:31px;height:31px;border-radius:50%;display:grid;place-items:center;font-size:9px;font-weight:700;color:#55483d;background:#e9d8c9}.message-body{min-width:0;overflow:hidden}.sender{font-size:10px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:#626a63;margin-bottom:4px}.subject{font-size:10px;color:#3e4640;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin-bottom:3px}.snippet{font-size:9px;color:#a1a69f;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.message-meta{height:100%;display:flex;flex-direction:column;justify-content:space-between;align-items:flex-end;padding:2px 0;min-width:31px}.time{font-size:8px;color:#989e98;white-space:nowrap}.star{border:0;background:transparent;color:#c9cec8;font-size:14px;line-height:1;padding:0}.star.on{color:#dcaa56}.list-foot{height:37px;flex:none;border-top:1px solid #f0f2ef;display:flex;align-items:center;justify-content:space-between;padding:0 14px;color:#929991;font-size:9px}.list-foot .online-dot{margin-right:6px}.text-button{border:0;background:transparent;color:#708878;font-size:9px}.reader-pane{overflow-y:auto;padding:0 24px 24px}.reader-empty{height:100%;display:grid;place-items:center;text-align:center;color:#9ca39c}.empty-icon{height:52px;width:52px;margin:0 auto 12px;border-radius:17px;background:#f1f5ef;color:#71937a;display:grid;place-items:center;font-size:24px}.reader-empty h3{font-family:'DM Serif Display',Georgia,serif;font-weight:400;font-size:19px;color:#525a53;margin:0 0 6px}.reader-empty p{font-size:10px;color:#9aa098;margin:0}.reader-header{padding:24px 0 17px;border-bottom:1px solid #edf0ec}.reader-topline{display:flex;align-items:center;justify-content:space-between;margin-bottom:17px}.reader-tags{display:flex;gap:6px}.tag{font-size:8px;border-radius:4px;padding:4px 7px;background:#f4f3e9;color:#a38a52}.tag.green{background:#edf4ee;color:#62816a}.reader-tools{display:flex;gap:2px}.reader-subject{font-family:'DM Serif Display',Georgia,serif;font-size:22px;line-height:1.25;margin:0 0 17px;font-weight:400;color:#343a35}.sender-row{display:flex;align-items:center;gap:9px}.sender-row .contact-avatar{width:34px;height:34px;font-size:10px}.sender-details{min-width:0;flex:1}.sender-details strong{display:block;font-size:10px;color:#434a44}.sender-details span{display:block;font-size:9px;color:#999f99;margin-top:3px}.message-date{font-size:8px;color:#999f99;white-space:nowrap}.reader-body{padding:21px 1px 15px;font-size:11px;line-height:1.85;color:#616a62}.reader-body p{margin:0 0 13px}.reader-body .signoff{margin-top:24px}.attachment{margin-top:18px;padding:11px;border:1px solid #e8ece7;border-radius:8px;display:flex;align-items:center;gap:10px;max-width:260px}.file-icon{height:33px;width:30px;border-radius:6px;background:#f4eeec;color:#ad7466;display:grid;place-items:center;font-size:15px}.attachment-info{flex:1}.attachment-info strong{display:block;font-size:9px;color:#59615a}.attachment-info small{font-size:8px;color:#a1a69f}.download{border:0;background:transparent;color:#8b938b}.reply-bar{border-top:1px solid #edf0ec;padding-top:15px;display:flex;gap:8px}.reply-button{padding:8px 12px;border:1px solid #e3e8e3;border-radius:7px;background:#fff;color:#6e786e;font-size:9px}.reply-button:hover{background:#f6f8f5}.reply-button.primary{background:#5b8068;border-color:#5b8068;color:white}.page-view{padding:22px 28px;overflow:auto}.hidden{display:none!important} -.modal-overlay{position:fixed;inset:0;background:#2028204a;z-index:10;display:grid;place-items:center;padding:20px}.compose-modal{width:min(600px,95vw);background:white;border-radius:13px;box-shadow:0 18px 65px #17271c35;overflow:hidden}.modal-head{padding:15px 19px;background:#f6f7f4;border-bottom:1px solid #ebeee9;display:flex;justify-content:space-between;align-items:center;font-size:11px;font-weight:600}.modal-close{border:0;background:transparent;color:#89908a;font-size:19px}.compose-fields{padding:9px 20px 0}.compose-line{display:flex;align-items:center;gap:10px;min-height:39px;border-bottom:1px solid #f0f1ef;color:#969d96;font-size:10px}.compose-line input{flex:1;border:0;outline:0;font-size:10px;color:#424942}.compose-line input::placeholder{color:#aeb3ad}.compose-subject{border:0;width:100%;font-size:14px!important;padding:15px 0;outline:0;color:#303831}.compose-body{width:100%;height:220px;resize:vertical;border:0;border-top:1px solid #f0f1ef;padding:15px 20px;outline:0;font-size:11px;line-height:1.6;color:#414941}.compose-footer{display:flex;justify-content:space-between;align-items:center;padding:12px 20px 15px}.send-button{border:0;border-radius:6px;background:#5b8068;color:white;padding:8px 16px;font-weight:600;font-size:10px}.discard{border:0;background:transparent;color:#929890;font-size:10px}.toast{position:fixed;bottom:22px;left:50%;transform:translate(-50%,15px);opacity:0;pointer-events:none;background:#293b2e;color:#fff;padding:10px 16px;border-radius:8px;font-size:11px;box-shadow:0 5px 20px #1c2b2030;transition:.2s;z-index:20}.toast.visible{opacity:1;transform:translate(-50%,0)} -/* Wasteland: warm paper, weathered ink and rust. */ -body.wasteland{--bg:#eee8db;--panel:#faf6ed;--line:#e6dccb;--text:#373129;--muted:#998a76;--subtle:#f3ede1;--accent:#a75d3d;--accent-soft:#f5e8dc;--shadow:0 2px 10px #44351d0c}body.wasteland .rail{background:#e7dece;border-color:#dfd4c2}body.wasteland .brand-mark{background:#ad6847}body.wasteland .rail-button.active{background:#f1dfcd;color:#a15a39}body.wasteland .rail-button:hover{background:#eee2d2;color:#9a5739}body.wasteland .sidebar,body.wasteland .topbar{background:#faf6ed;border-color:#e6dccb}body.wasteland .account-card{background:#f4eee2;border-color:#ece2d2}body.wasteland .account-avatar{background:#ead8bf;color:#9b633e}body.wasteland .folder.active{background:#f3e6d7;color:#995c3d}body.wasteland .folder.active .nav-glyph{color:#a76645}body.wasteland .count{color:#9e6947}body.wasteland .list-pane,body.wasteland .reader-pane,body.wasteland .compose-modal{background:#faf6ed;border-color:#e6dccb}body.wasteland .compose-button,body.wasteland .send-button,body.wasteland .reply-button.primary{background:#a76645;border-color:#a76645}body.wasteland .compose-button:hover{background:#905538}body.wasteland .message.selected{background:#f5ede0;box-shadow:inset 2px 0 #ad704c}body.wasteland .reader-empty .empty-icon{background:#f3e8d8;color:#a8734c}body.wasteland .reader-button,body.wasteland .reply-button{background:#faf6ed} -@media(max-width:1040px){.sidebar{width:205px;padding-inline:13px}.mail-layout{grid-template-columns:minmax(310px,47%) minmax(320px,1fr);padding:13px;gap:10px}.reader-pane{padding:0 17px 20px}.topbar{padding:0 16px}.message{gap:7px;padding-inline:9px}.list-heading{padding-inline:14px}} -@media(max-width:800px){.sidebar{width:174px;padding-inline:10px}.mail-layout{grid-template-columns:minmax(290px,1fr) minmax(290px,1fr);padding:9px;gap:8px}.reader-pane{padding-inline:13px}.list-heading h2{font-size:17px}.search-wrap{width:170px}} -.page-heading{display:flex;align-items:center;justify-content:space-between;margin:5px 0 20px}.page-heading h2{font-family:'DM Serif Display',Georgia,serif;font-size:28px;font-weight:400;margin:0 0 5px}.page-subtitle{font-size:11px;color:#929991;margin:0}.cal-actions{display:flex;align-items:center;gap:7px}.outline-button{border:1px solid #e3e8e2;background:#fff;border-radius:6px;padding:7px 10px;color:#69736a;font-size:10px}.calendar-card{background:var(--panel);border:1px solid var(--line);border-radius:11px;overflow:hidden;box-shadow:var(--shadow)}.calendar-week{height:38px;display:grid;grid-template-columns:repeat(7,1fr);border-bottom:1px solid var(--line);align-items:center;text-align:center;color:#969d95;font-size:9px;font-weight:600}.calendar-grid{display:grid;grid-template-columns:repeat(7,1fr)}.cal-cell{height:100px;border-right:1px solid #f0f1ee;border-bottom:1px solid #f0f1ee;padding:8px 7px;cursor:pointer;min-width:0}.cal-cell:nth-child(7n){border-right:0}.cal-cell:hover{background:#fafbf9}.cal-cell.outside{background:#fafbf9;color:#d3d7d1}.cal-number{display:grid;place-items:center;width:21px;height:21px;border-radius:50%;font-size:9px;color:#737c73;margin-bottom:4px}.cal-cell.today .cal-number{background:#5b8068;color:#fff}.event-chip{padding:4px 5px;margin:3px 0;border-radius:4px;font-size:8px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;background:#edf4ee;color:#5b8068}.event-chip.gold{background:#f7f1e4;color:#a28449}.event-chip.blue{background:#edf2f7;color:#6885a5}.upcoming{margin:20px 0 0}.upcoming h3{font-family:'DM Serif Display',Georgia,serif;font-size:17px;font-weight:400;margin:0 0 8px}.upcoming-row{display:flex;gap:12px;align-items:center;padding:10px 12px;border:1px solid var(--line);background:var(--panel);border-radius:8px;margin:6px 0;max-width:380px}.event-date{width:36px;height:38px;border-radius:7px;background:#edf4ee;color:#62816a;display:grid;place-content:center;text-align:center;font-size:8px;line-height:1.3}.event-date strong{font-size:14px}.gold-date{background:#f7f1e4;color:#a28449}.upcoming-row div{display:grid;gap:4px}.upcoming-row div strong{font-size:10px}.upcoming-row small{font-size:9px;color:#979e97}.contact-search{height:38px;max-width:370px;display:flex;align-items:center;gap:8px;padding:0 12px;background:var(--panel);border:1px solid var(--line);border-radius:8px;color:#8c958c;margin-bottom:15px}.contact-search input{border:0;background:transparent;outline:0;flex:1;font-size:10px}.contacts-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(245px,1fr));gap:10px}.contact-card{position:relative;display:flex;align-items:center;gap:11px;padding:14px;background:var(--panel);border:1px solid var(--line);border-radius:9px;box-shadow:var(--shadow)}.contact-card>.contact-avatar{height:39px;width:39px;font-size:11px;flex:none}.contact-card>div:nth-child(2){min-width:0;display:grid;gap:4px}.contact-card>div:nth-child(2) strong{font-size:10px}.contact-card>div:nth-child(2) span{font-size:9px;color:#838b83;overflow:hidden;text-overflow:ellipsis}.contact-card>div:nth-child(2) small{font-size:8px;color:#a0a69f}.contact-more{margin-left:auto;align-self:flex-start}.contact-email{position:absolute;right:12px;bottom:10px;border:0;background:transparent;color:#829386;font-size:12px}body.wasteland .outline-button,body.wasteland .upcoming-row{background:#faf6ed;border-color:#e6dccb}body.wasteland .calendar-card{background:#faf6ed;border-color:#e6dccb}body.wasteland .cal-cell:hover{background:#f7f0e4}body.wasteland .event-chip{background:#f2e9da;color:#996445}body.wasteland .cal-cell.today .cal-number{background:#a76645} -.account-card[role="button"]{cursor:pointer;appearance:none}.account-card[role="button"]:hover{border-color:#dce5dc}.account-card[role="button"]:focus-visible{outline:2px solid #7eae90;outline-offset:2px}.account-note{font-size:10px;line-height:1.5;color:#848c84;margin:7px 0 12px}.account-note+.compose-line{margin-top:1px}.account-status{font-size:10px;line-height:1.5;color:#9a6346;min-height:15px;margin:9px 0 2px} -.attachment{box-sizing:border-box;width:100%;max-width:420px;min-width:0}.attachment-info{min-width:0;overflow:hidden}.attachment-info strong{max-width:100%;overflow-wrap:anywhere;word-break:break-word;line-height:1.4}.attachment .download{flex:none}.account-list{max-height:55vh;overflow-y:auto}.account-row{display:flex;justify-content:space-between;align-items:center;gap:12px;padding:12px 0;border-bottom:1px solid #edf0ec}.account-row-info{min-width:0;display:grid;gap:5px}.account-row-info strong{font-size:11px;overflow-wrap:anywhere}.account-row-info small{font-size:9px;color:#929991;overflow-wrap:anywhere}.account-row-actions{display:flex;align-items:center;gap:8px;flex:none}.account-current{font-size:9px;color:#61836a}.account-row .outline-button{padding:6px 9px}.account-row .discard{padding:6px} - -/* EP Wasteland follows the Eternity Project Gitea theme palette. */ -body.ep-wasteland{color-scheme:dark;--bg:#161210;--panel:#1b1714;--line:#4a3f33;--text:#d4cbbc;--muted:#a89a86;--subtle:#241e19;--accent:#8fae3d;--accent-soft:#2b301d;--shadow:0 2px 12px #0008;background:var(--bg);color:var(--text)} -body.ep-wasteland .rail,body.ep-wasteland .sidebar-head,body.ep-wasteland .topbar,body.ep-wasteland .modal-head{background:#211b17;border-color:#4a3f33} -body.ep-wasteland .brand-mark,body.ep-wasteland .compose-button,body.ep-wasteland .send-button,body.ep-wasteland .reply-button.primary{background:#8fae3d;border-color:#8fae3d;color:#161210} -body.ep-wasteland .brand-mark{box-shadow:0 3px 10px #0006} -body.ep-wasteland .avatar{background:#4a3f33;color:#e7e2d3} -body.ep-wasteland .compose-button:hover{background:#a2bd5b;border-color:#a2bd5b} -body.ep-wasteland .rail-button{color:#b5a995} -body.ep-wasteland .rail-button:hover,body.ep-wasteland .icon-button:hover,body.ep-wasteland .folder:hover,body.ep-wasteland .label-link:hover{background:#2b241e;color:#e7e2d3} -body.ep-wasteland .rail-button.active,body.ep-wasteland .folder.active{background:#343b22;color:#a2bd5b} -body.ep-wasteland .sidebar,body.ep-wasteland .list-pane,body.ep-wasteland .reader-pane,body.ep-wasteland .page-view{background:#1b1714;color:#d4cbbc} -body.ep-wasteland .sidebar{border-color:#4a3f33} -body.ep-wasteland .account-card,body.ep-wasteland .search-wrap,body.ep-wasteland .toolbar,body.ep-wasteland .calendar-card,body.ep-wasteland .contact-search,body.ep-wasteland .contact-card,body.ep-wasteland .upcoming-row,body.ep-wasteland .compose-modal{background:#211b17;border-color:#4a3f33;color:#d4cbbc} -body.ep-wasteland .account-avatar,body.ep-wasteland .contact-avatar{background:#343b22;color:#a2bd5b} -body.ep-wasteland .account-info span,body.ep-wasteland .storage small,body.ep-wasteland .section-label,body.ep-wasteland .date-line,body.ep-wasteland .page-subtitle,body.ep-wasteland .pagination,body.ep-wasteland .time,body.ep-wasteland .sender-details span,body.ep-wasteland .message-date,body.ep-wasteland .contact-card>div:nth-child(2) span,body.ep-wasteland .contact-card>div:nth-child(2) small,body.ep-wasteland .upcoming-row small{color:#a89a86} -body.ep-wasteland .sidebar-head h1,body.ep-wasteland .breadcrumbs strong,body.ep-wasteland .list-heading h2,body.ep-wasteland .page-heading h2,body.ep-wasteland .upcoming h3,body.ep-wasteland .sender-details strong,body.ep-wasteland .reader-subject,body.ep-wasteland .reader-empty h3,body.ep-wasteland .contact-card>div:nth-child(2) strong,body.ep-wasteland .upcoming-row div strong{color:#e7e2d3} -body.ep-wasteland .eyebrow,body.ep-wasteland .breadcrumbs,body.ep-wasteland .icon-button,body.ep-wasteland .folder,body.ep-wasteland .label-link,body.ep-wasteland .settings-button,body.ep-wasteland .nav-glyph,body.ep-wasteland .search-wrap,body.ep-wasteland .help-button{color:#b5a995} -body.ep-wasteland .online-dot{background:#8fae3d} -body.ep-wasteland .folder.active .nav-glyph,body.ep-wasteland .count,body.ep-wasteland .text-button,body.ep-wasteland .contact-email,body.ep-wasteland .account-current{color:#a2bd5b} -body.ep-wasteland .count{background:#2b301d} -body.ep-wasteland .sidebar-divider,body.ep-wasteland .storage,body.ep-wasteland .storage-bar,body.ep-wasteland .toolbar-divider,body.ep-wasteland .reader-header,body.ep-wasteland .reply-bar,body.ep-wasteland .message,body.ep-wasteland .list-foot,body.ep-wasteland .account-row{border-color:#4a3f33} -body.ep-wasteland .storage-bar{background:#4a3f33} -body.ep-wasteland .storage-bar i{background:#8fae3d} -body.ep-wasteland .message{background:#1b1714} -body.ep-wasteland .message:hover,body.ep-wasteland .message.selected{background:#241e19} -body.ep-wasteland .message.selected{box-shadow:inset 2px 0 #8fae3d} -body.ep-wasteland .sender,body.ep-wasteland .subject,body.ep-wasteland .message.unread .sender,body.ep-wasteland .message.unread .subject{color:#e7e2d3} -body.ep-wasteland .snippet,body.ep-wasteland .list-foot,body.ep-wasteland .reader-body{color:#b5a995} -body.ep-wasteland .star{color:#8f8170} -body.ep-wasteland .star.on{color:#a2bd5b} -body.ep-wasteland .reader-empty{color:#a89a86} -body.ep-wasteland .empty-icon,body.ep-wasteland .event-date,body.ep-wasteland .cal-cell.today .cal-number{background:#343b22;color:#a2bd5b} -body.ep-wasteland .attachment,body.ep-wasteland .file-icon{background:#211b17;border-color:#4a3f33;color:#a2bd5b} -body.ep-wasteland .attachment-info strong,body.ep-wasteland .attachment-info small{color:#d4cbbc} -body.ep-wasteland .reply-button,body.ep-wasteland .outline-button{background:#211b17;border-color:#4a3f33;color:#d4cbbc} -body.ep-wasteland .reply-button:hover,body.ep-wasteland .outline-button:hover{background:#2b241e} -body.ep-wasteland .modal-overlay{background:#000b} -body.ep-wasteland .compose-fields,body.ep-wasteland .compose-footer{background:#1b1714} -body.ep-wasteland .compose-line,body.ep-wasteland .compose-body{border-color:#4a3f33;color:#b5a995} -body.ep-wasteland .compose-line input,body.ep-wasteland .compose-subject,body.ep-wasteland .compose-body,body.ep-wasteland .contact-search input{background:transparent;color:#e7e2d3} -body.ep-wasteland .compose-line input::placeholder,body.ep-wasteland .compose-body::placeholder{color:#8f8170} -body.ep-wasteland .modal-close,body.ep-wasteland .discard{color:#a89a86} -body.ep-wasteland .toast{background:#211b17;color:#e7e2d3;border:1px solid #4a3f33} -body.ep-wasteland .calendar-week{border-color:#4a3f33;color:#a89a86} -body.ep-wasteland .cal-cell{border-color:#342c24;color:#d4cbbc} -body.ep-wasteland .cal-cell:hover,body.ep-wasteland .cal-cell.outside{background:#241e19} -body.ep-wasteland .cal-cell.outside{color:#8f8170} -body.ep-wasteland .cal-number{color:#d4cbbc} -body.ep-wasteland .event-chip,body.ep-wasteland .gold-date{background:#343b22;color:#a2bd5b} -body.ep-wasteland .event-chip.gold,body.ep-wasteland .event-chip.blue{background:#2b241e;color:#d4cbbc} -body.ep-wasteland .tag,body.ep-wasteland .tag.green{background:#343b22;color:#a2bd5b} -body.ep-wasteland .row-check{border-color:#8f8170} -body.ep-wasteland .row-check:checked{accent-color:#8fae3d} - -/* EP Daylight follows the Eternity Project Gitea theme palette. */ -body.ep-daylight{color-scheme:light;--bg:#f1f1e9;--panel:#fbfbf6;--line:#b9c5bc;--text:#263a3d;--muted:#70827b;--subtle:#e9eee4;--accent:#526a2c;--accent-soft:#e9eee4;--shadow:0 2px 10px #11212b12;background:var(--bg);color:var(--text)} -body.ep-daylight .rail,body.ep-daylight .sidebar-head,body.ep-daylight .topbar,body.ep-daylight .modal-head{background:#e8e9df;border-color:#b9c5bc} -body.ep-daylight .brand-mark,body.ep-daylight .compose-button,body.ep-daylight .send-button,body.ep-daylight .reply-button.primary{background:#526a2c;border-color:#526a2c;color:#f1f1e9} -body.ep-daylight .brand-mark{box-shadow:0 3px 8px #11212b20} -body.ep-daylight .compose-button:hover{background:#435722;border-color:#435722} -body.ep-daylight .sidebar,body.ep-daylight .list-pane,body.ep-daylight .reader-pane,body.ep-daylight .page-view{background:#fbfbf6;color:#263a3d} -body.ep-daylight .sidebar{border-color:#b9c5bc} -body.ep-daylight .account-card,body.ep-daylight .search-wrap,body.ep-daylight .toolbar,body.ep-daylight .calendar-card,body.ep-daylight .contact-search,body.ep-daylight .contact-card,body.ep-daylight .upcoming-row,body.ep-daylight .compose-modal{background:#fbfbf6;border-color:#b9c5bc;color:#263a3d} -body.ep-daylight .rail-button,body.ep-daylight .icon-button,body.ep-daylight .folder,body.ep-daylight .label-link,body.ep-daylight .settings-button,body.ep-daylight .nav-glyph,body.ep-daylight .help-button{color:#59706b} -body.ep-daylight .rail-button:hover,body.ep-daylight .icon-button:hover,body.ep-daylight .folder:hover,body.ep-daylight .label-link:hover,body.ep-daylight .reply-button:hover,body.ep-daylight .outline-button:hover{background:#e9eee4;color:#263a3d} -body.ep-daylight .rail-button.active,body.ep-daylight .folder.active{background:#e9eee4;color:#526a2c} -body.ep-daylight .account-avatar,body.ep-daylight .contact-avatar{background:#e9eee4;color:#526a2c} -body.ep-daylight .avatar{background:#b9c5bc;color:#11212b} -body.ep-daylight .sidebar-head h1,body.ep-daylight .breadcrumbs strong,body.ep-daylight .list-heading h2,body.ep-daylight .page-heading h2,body.ep-daylight .upcoming h3,body.ep-daylight .sender-details strong,body.ep-daylight .reader-subject,body.ep-daylight .reader-empty h3,body.ep-daylight .contact-card>div:nth-child(2) strong,body.ep-daylight .upcoming-row div strong{color:#11212b} -body.ep-daylight .eyebrow,body.ep-daylight .breadcrumbs,body.ep-daylight .date-line,body.ep-daylight .page-subtitle,body.ep-daylight .section-label,body.ep-daylight .account-info span,body.ep-daylight .storage small,body.ep-daylight .pagination,body.ep-daylight .time,body.ep-daylight .sender-details span,body.ep-daylight .message-date,body.ep-daylight .contact-card>div:nth-child(2) span,body.ep-daylight .contact-card>div:nth-child(2) small,body.ep-daylight .upcoming-row small{color:#59706b} -body.ep-daylight .online-dot,body.ep-daylight .storage-bar i{background:#8fae3d} -body.ep-daylight .folder.active .nav-glyph,body.ep-daylight .count,body.ep-daylight .text-button,body.ep-daylight .contact-email,body.ep-daylight .account-current{color:#526a2c} -body.ep-daylight .count{background:#e9eee4} -body.ep-daylight .sidebar-divider,body.ep-daylight .storage,body.ep-daylight .reader-header,body.ep-daylight .reply-bar,body.ep-daylight .message,body.ep-daylight .list-foot,body.ep-daylight .account-row,body.ep-daylight .calendar-week,body.ep-daylight .cal-cell{border-color:#b9c5bc} -body.ep-daylight .storage-bar,body.ep-daylight .toolbar-divider{background:#b9c5bc} -body.ep-daylight .message{background:#fbfbf6} -body.ep-daylight .message:hover,body.ep-daylight .message.selected{background:#e9eee4} -body.ep-daylight .message.selected{box-shadow:inset 2px 0 #8fae3d} -body.ep-daylight .sender,body.ep-daylight .subject,body.ep-daylight .message.unread .sender,body.ep-daylight .message.unread .subject{color:#11212b} -body.ep-daylight .snippet,body.ep-daylight .list-foot,body.ep-daylight .reader-body{color:#59706b} -body.ep-daylight .star{color:#70827b} -body.ep-daylight .star.on{color:#526a2c} -body.ep-daylight .reader-empty{color:#59706b} -body.ep-daylight .empty-icon,body.ep-daylight .event-date,body.ep-daylight .cal-cell.today .cal-number{background:#e9eee4;color:#526a2c} -body.ep-daylight .attachment,body.ep-daylight .file-icon{background:#fbfbf6;border-color:#b9c5bc;color:#526a2c} -body.ep-daylight .attachment-info strong{color:#263a3d} -body.ep-daylight .attachment-info small{color:#59706b} -body.ep-daylight .reply-button,body.ep-daylight .outline-button{background:#fbfbf6;border-color:#b9c5bc;color:#263a3d} -body.ep-daylight .tag,body.ep-daylight .tag.green,body.ep-daylight .event-chip{background:#e9eee4;color:#526a2c} -body.ep-daylight .event-chip.gold,body.ep-daylight .event-chip.blue,body.ep-daylight .gold-date{background:#e8e9df;color:#59706b} -body.ep-daylight .cal-cell{color:#263a3d} -body.ep-daylight .cal-cell:hover,body.ep-daylight .cal-cell.outside{background:#e9eee4} -body.ep-daylight .cal-cell.outside{color:#70827b} -body.ep-daylight .cal-number{color:#263a3d} -body.ep-daylight .modal-overlay{background:#11212b55} -body.ep-daylight .compose-fields,body.ep-daylight .compose-footer{background:#fbfbf6} -body.ep-daylight .compose-line,body.ep-daylight .compose-body{border-color:#b9c5bc;color:#59706b} -body.ep-daylight .compose-line input,body.ep-daylight .compose-subject,body.ep-daylight .compose-body,body.ep-daylight .contact-search input{background:transparent;color:#11212b} -body.ep-daylight .compose-line input::placeholder,body.ep-daylight .compose-body::placeholder{color:#70827b} -body.ep-daylight .modal-close,body.ep-daylight .discard{color:#59706b} -body.ep-daylight .toast{background:#11212b;color:#f1f1e9} -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} -.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} -@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}} - .search-filters{position:absolute;right:78px;top:calc(100% + 8px);z-index:12;display:grid;grid-template-columns:1fr 1fr;gap:10px;width:min(360px,calc(100vw - 32px));padding:14px;border:1px solid var(--border,#d8ddd5);border-radius:12px;background:var(--panel,#fff);box-shadow:0 8px 28px #17201724}.search-filters.hidden{display:none}.search-filters label{display:grid;gap:4px;font-size:12px}.search-filters input,.search-filters select{min-width:0;border:1px solid var(--border,#d8ddd5);border-radius:7px;padding:7px;background:transparent;color:inherit;font:inherit}.search-filters .filter-checkbox{display:flex;align-items:center;gap:7px}.search-filters .filter-checkbox input{min-width:auto}.search-filters .text-button{grid-column:1/-1;justify-self:start}.top-actions{position:relative} - body.ep-wasteland .search-filters{background:#211c18;border-color:#4a3f33;color:#d4cbbc}body.ep-wasteland .search-filters input,body.ep-wasteland .search-filters select{border-color:#4a3f33;color:#d4cbbc} - body.ep-daylight .search-filters{background:#fbfbf6;border-color:#b9c5bc;color:#263a3d} - .mail-safety-warning{margin:10px 16px;padding:12px 14px;border:1px solid #d69b43;border-left:4px solid #b87321;border-radius:8px;background:#fff6df;color:#5b3c17;font-size:12px}.mail-safety-warning strong{display:block}.mail-safety-warning ul{margin:7px 0;padding-left:18px}.mail-safety-warning small{display:block;line-height:1.4}.mail-links{padding:12px 16px;border-top:1px solid var(--line,#eaede8)}.mail-links h3{margin:0 0 8px;font-size:12px}.mail-safety-intro{font-size:11px;color:#8d4a16}.mail-link-row{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:9px 10px;margin-top:6px;border:1px solid var(--line,#eaede8);border-radius:8px;font-size:11px}.mail-link-row>div{min-width:0;display:grid;gap:3px}.mail-link-row span,.mail-link-row small{overflow-wrap:anywhere;color:#727970}.mail-link-risky{border-color:#d69b43;background:#fff8ea}.mail-link-open{flex:none;border:1px solid #9ba99b;border-radius:6px;background:transparent;padding:6px 8px;font-size:10px}.mail-link-open:disabled{opacity:.55;cursor:wait} - body.ep-wasteland .mail-safety-warning{background:#392719;border-color:#a8793e;color:#f0d4a3}body.ep-wasteland .mail-link-row{border-color:#4a3f33}body.ep-wasteland .mail-link-risky{background:#392719;border-color:#a8793e}body.ep-wasteland .mail-link-row span,body.ep-wasteland .mail-link-row small{color:#cbbba0} - 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} -.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} -.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-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 small{opacity:.85}.pgp-ok{border-color:#3d7a4f;background:rgba(61,122,79,.12)}.pgp-warn{border-color:#b8860b;background:rgba(184,134,11,.14)}.pgp-bad{border-color:#b3261e;background:rgba(179,38,30,.14)} -.pgp-banner button,.pgp-status button{align-self:flex-start;margin-top:6px} -.pgp-compose{display:flex;align-items:center;gap:12px;margin-right:auto;font-size:13px}.pgp-compose label{display:flex;align-items:center;gap:4px}.pgp-compose small{opacity:.8} -.pgp-trust{margin-left:8px} - -.draft-delete{margin-top:4px;font-size:15px;opacity:.55}.draft-delete:hover{opacity:1;color:#b3261e}.pgp-prompt-box{width:min(380px,92vw)} -.reader-body img{display:block;max-width:100%;height:auto;margin:12px 0;border-radius:6px}.reader-body table{max-width:100%;border-collapse:collapse}.reader-body th,.reader-body td{border:1px solid var(--line);padding:5px}.remote-image-notice{margin:14px 0 0;padding:12px;border:1px solid #d7a85c;border-radius:8px;background:#fff8e9;color:#664a23;font-size:10px;line-height:1.5}.remote-image-notice p{margin:0 0 8px}.remote-image-notice .reply-button{background:transparent;color:inherit;border-color:#d7a85c}body.ep-wasteland .remote-image-notice{background:#3a3022;color:#e6d1a8;border-color:#806b44}body.ep-daylight .remote-image-notice{background:#fff8e9;color:#664a23;border-color:#d7a85c} - -.sidebar{overflow-y:auto}#mail-nav{overflow-y:auto;min-height:150px;flex:0 1 auto;scrollbar-width:thin;align-content:start}#custom-folders{display:contents}.folders-head{flex:none}.sidebar>:not(#mail-nav){flex-shrink:0}.folders-head+.folder-nav{margin-top:0} +:root{font-family:'DM Sans',Inter,ui-sans-serif,system-ui,-apple-system,'Segoe UI',sans-serif;color:#252a28;background:#f4f5f1;font-synthesis:none;text-rendering:optimizeLegibility;--bg:#f4f5f1;--panel:#fff;--line:#eaede8;--text:#252a28;--muted:#8b918b;--subtle:#f7f8f5;--accent:#55816c;--accent-soft:#edf4ef;--shadow:0 2px 10px #2636290b} +*{box-sizing:border-box}body{margin:0;min-width:760px;min-height:100vh;background:var(--bg);color:var(--text)}button,input,textarea{font:inherit}button{color:inherit;cursor:pointer}button:focus-visible,input:focus-visible,textarea:focus-visible{outline:2px solid #7eae90;outline-offset:2px}.app-shell{height:100vh;min-height:640px;display:flex;overflow:hidden}.rail{width:66px;flex:none;background:#edf0ea;border-right:1px solid #e5e9e2;display:flex;align-items:center;flex-direction:column;padding:17px 0 13px;gap:10px}.brand-mark{height:35px;width:35px;border-radius:12px;background:#5b826c;color:white;display:grid;place-items:center;font-size:24px;margin-bottom:21px;box-shadow:0 3px 8px #476c541d}.rail-button{height:39px;width:39px;border:0;background:transparent;color:#7e8780;border-radius:11px;font-size:20px;display:grid;place-items:center;transition:.18s}.rail-button:hover{background:#e2e8e1;color:#446a54}.rail-button.active{color:#477253;background:#dce9dd}.rail-spacer{flex:1}.avatar{border:0;border-radius:50%;height:34px;width:34px;background:#e7cbb6;color:#614c3c;font-size:11px;font-weight:700;display:grid;place-items:center}.avatar.tiny{height:27px;width:27px;font-size:9px} +.sidebar{width:244px;flex:none;background:#fff;border-right:1px solid var(--line);padding:26px 17px 14px;display:flex;flex-direction:column}.sidebar-head{display:flex;align-items:center;justify-content:space-between;padding:0 5px;margin-bottom:21px}.eyebrow{color:#969c95;font-size:9px;font-weight:700;letter-spacing:1.25px;margin:0 0 5px}.sidebar-head h1{font-family:'DM Serif Display',Georgia,serif;font-size:24px;font-weight:400;margin:0}.icon-button{border:0;background:transparent;color:#89918a;height:30px;min-width:30px;border-radius:8px;font-size:19px;display:inline-grid;place-items:center}.icon-button:hover{background:var(--subtle);color:#47544a}.account-card{display:flex;align-items:center;gap:10px;padding:10px 9px;background:#f7f8f5;border:1px solid #eff1ec;border-radius:10px;margin:0 0 22px}.account-avatar{height:30px;width:30px;border-radius:9px;background:#dce9dd;color:#477253;display:grid;place-items:center;font-family:Georgia,serif;font-weight:bold}.account-info{min-width:0;display:flex;flex-direction:column;gap:2px;flex:1}.account-info strong{font-size:11px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.account-info span{color:#929891;font-size:9px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.online-dot{display:inline-block;width:7px;height:7px;border-radius:50%;background:#70ad7b}.folder-nav{display:grid;gap:3px}.folder{width:100%;border:0;background:transparent;display:flex;align-items:center;gap:12px;text-align:left;padding:9px 10px;border-radius:8px;font-size:11px;color:#707970}.folder:hover,.label-link:hover{background:#f6f8f5}.folder.active{background:#edf4ee;color:#487354;font-weight:600}.nav-glyph{width:15px;text-align:center;font-size:15px;color:#879188}.folder.active .nav-glyph{color:#578366}.count{margin-left:auto;padding:2px 6px;min-width:19px;text-align:center;border-radius:5px;background:#fff;color:#61836a;font-size:9px}.count.muted{color:#969c95}.sidebar-divider{height:1px;background:#edf0ec;margin:18px 4px 16px}.section-label{display:flex;justify-content:space-between;align-items:center;font-size:9px;letter-spacing:1.1px;font-weight:700;color:#a0a59f;padding:0 6px;margin-bottom:9px}.tiny-plus{border:0;background:transparent;color:#929990;font-size:18px}.label-link{border:0;background:transparent;border-radius:7px;text-align:left;display:flex;align-items:center;gap:10px;color:#727970;font-size:11px;padding:8px 10px}.label-dot{width:8px;height:8px;border-radius:50%}.dot-amber{background:#dda854}.dot-blue{background:#79a4c9}.dot-green{background:#82ab83}.sidebar-bottom{margin-top:auto}.storage{padding:13px 10px 14px;border-bottom:1px solid #eef0ec}.storage-top{display:flex;justify-content:space-between;color:#606960;font-size:10px}.storage-top span+span{color:#979d97;font-size:9px}.storage-bar{height:4px;background:#edf0eb;margin:9px 0 7px;border-radius:5px;overflow:hidden}.storage-bar i{display:block;width:28%;height:100%;background:#79a785;border-radius:5px}.storage small{font-size:9px;color:#9ba19a}.settings-button{border:0;background:transparent;color:#7e867f;display:flex;gap:10px;align-items:center;margin:10px 0 0 4px;font-size:11px;padding:7px} +.main-area{flex:1;min-width:0;display:flex;flex-direction:column}.topbar{height:57px;flex:none;background:#fff;border-bottom:1px solid var(--line);display:flex;align-items:center;justify-content:space-between;padding:0 24px}.breadcrumbs{display:flex;align-items:center;gap:10px;font-size:10px;color:#969c96}.breadcrumbs strong{font-weight:600;color:#475048}.crumb-divider{color:#c6cbc5}.top-actions{display:flex;align-items:center;gap:13px}.search-wrap{height:31px;width:218px;background:#f6f7f4;border:1px solid #eff0ec;border-radius:8px;display:flex;align-items:center;padding:0 9px;gap:7px;color:#90978f}.search-wrap>span{font-size:19px}.search-wrap input{border:0;outline:0;background:transparent;width:100%;font-size:10px;color:#3f4740}.search-wrap kbd{font:9px 'DM Sans',sans-serif;border:1px solid #e3e6e1;border-radius:4px;padding:2px 4px;white-space:nowrap;color:#999f99}.help-button{font-size:12px;border:1px solid #e7eae6;border-radius:50%;height:20px;min-width:20px;font-weight:600}.top-avatar{width:27px;height:27px;font-size:9px} +.content-view{flex:1;min-height:0}.mail-layout{display:grid;grid-template-columns:minmax(330px,44%) minmax(340px,1fr);padding:18px 20px 20px;gap:14px}.list-pane,.reader-pane{background:var(--panel);border:1px solid var(--line);border-radius:12px;box-shadow:var(--shadow);min-height:0}.list-pane{display:flex;flex-direction:column;overflow:hidden}.list-heading{padding:20px 19px 15px;display:flex;align-items:center;justify-content:space-between}.date-line{font-size:8px;font-weight:700;letter-spacing:1.25px;color:#a0a69f;margin-bottom:7px}.list-heading h2{font-family:'DM Serif Display',Georgia,serif;font-size:20px;font-weight:400;margin:0;color:#303732}.sun{font-family:sans-serif;font-size:14px;color:#dda95f;vertical-align:2px}.compose-button{border:0;border-radius:7px;background:#5b8068;color:white;padding:8px 12px;font-size:10px;font-weight:600;box-shadow:0 2px 4px #406e4f20}.compose-button:hover{background:#476f56}.compose-button span{font-size:15px;vertical-align:-1px;margin-right:4px}.toolbar{height:39px;border-top:1px solid #f2f3f1;border-bottom:1px solid #f0f2ee;display:flex;align-items:center;padding:0 12px;gap:6px;color:#888f88}.toolbar .icon-button{font-size:15px;height:26px;min-width:26px}.tool-checkbox{font-size:14px;color:#818981;border:0;background:transparent;width:25px}.toolbar-divider{height:16px;width:1px;background:#e9ece8;margin:0 3px}.toolbar-spacer{flex:1}.pagination{font-size:9px;color:#90968f;white-space:nowrap}.message-list{overflow-y:auto;flex:1}.message{min-height:68px;display:grid;grid-template-columns:18px 32px minmax(0,1fr) auto;align-items:center;gap:9px;padding:9px 12px;border-bottom:1px solid #f0f2ef;cursor:pointer;transition:background .14s}.message:hover{background:#fafbf9}.message.selected{background:#f3f7f2;box-shadow:inset 2px 0 #669074}.message.unread .sender,.message.unread .subject{font-weight:700;color:#303832}.row-check{appearance:none;width:13px;height:13px;border:1px solid #d7dcd6;border-radius:3px;cursor:pointer;margin:0}.row-check:checked{appearance:auto;accent-color:#63866d}.contact-avatar{width:31px;height:31px;border-radius:50%;display:grid;place-items:center;font-size:9px;font-weight:700;color:#55483d;background:#e9d8c9}.message-body{min-width:0;overflow:hidden}.sender{font-size:10px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:#626a63;margin-bottom:4px}.subject{font-size:10px;color:#3e4640;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin-bottom:3px}.snippet{font-size:9px;color:#a1a69f;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.message-meta{height:100%;display:flex;flex-direction:column;justify-content:space-between;align-items:flex-end;padding:2px 0;min-width:31px}.time{font-size:8px;color:#989e98;white-space:nowrap}.star{border:0;background:transparent;color:#c9cec8;font-size:14px;line-height:1;padding:0}.star.on{color:#dcaa56}.list-foot{height:37px;flex:none;border-top:1px solid #f0f2ef;display:flex;align-items:center;justify-content:space-between;padding:0 14px;color:#929991;font-size:9px}.list-foot .online-dot{margin-right:6px}.text-button{border:0;background:transparent;color:#708878;font-size:9px}.reader-pane{overflow-y:auto;padding:0 24px 24px}.reader-empty{height:100%;display:grid;place-items:center;text-align:center;color:#9ca39c}.empty-icon{height:52px;width:52px;margin:0 auto 12px;border-radius:17px;background:#f1f5ef;color:#71937a;display:grid;place-items:center;font-size:24px}.reader-empty h3{font-family:'DM Serif Display',Georgia,serif;font-weight:400;font-size:19px;color:#525a53;margin:0 0 6px}.reader-empty p{font-size:10px;color:#9aa098;margin:0}.reader-header{padding:24px 0 17px;border-bottom:1px solid #edf0ec}.reader-topline{display:flex;align-items:center;justify-content:space-between;margin-bottom:17px}.reader-tags{display:flex;gap:6px}.tag{font-size:8px;border-radius:4px;padding:4px 7px;background:#f4f3e9;color:#a38a52}.tag.green{background:#edf4ee;color:#62816a}.reader-tools{display:flex;gap:2px}.reader-subject{font-family:'DM Serif Display',Georgia,serif;font-size:22px;line-height:1.25;margin:0 0 17px;font-weight:400;color:#343a35}.sender-row{display:flex;align-items:center;gap:9px}.sender-row .contact-avatar{width:34px;height:34px;font-size:10px}.sender-details{min-width:0;flex:1}.sender-details strong{display:block;font-size:10px;color:#434a44}.sender-details span{display:block;font-size:9px;color:#999f99;margin-top:3px}.message-date{font-size:8px;color:#999f99;white-space:nowrap}.reader-body{padding:21px 1px 15px;font-size:11px;line-height:1.85;color:#616a62}.reader-body p{margin:0 0 13px}.reader-body .signoff{margin-top:24px}.attachment{margin-top:18px;padding:11px;border:1px solid #e8ece7;border-radius:8px;display:flex;align-items:center;gap:10px;max-width:260px}.file-icon{height:33px;width:30px;border-radius:6px;background:#f4eeec;color:#ad7466;display:grid;place-items:center;font-size:15px}.attachment-info{flex:1}.attachment-info strong{display:block;font-size:9px;color:#59615a}.attachment-info small{font-size:8px;color:#a1a69f}.download{border:0;background:transparent;color:#8b938b}.reply-bar{border-top:1px solid #edf0ec;padding-top:15px;display:flex;gap:8px}.reply-button{padding:8px 12px;border:1px solid #e3e8e3;border-radius:7px;background:#fff;color:#6e786e;font-size:9px}.reply-button:hover{background:#f6f8f5}.reply-button.primary{background:#5b8068;border-color:#5b8068;color:white}.page-view{padding:22px 28px;overflow:auto}.hidden{display:none!important} +.modal-overlay{position:fixed;inset:0;background:#2028204a;z-index:10;display:grid;place-items:center;padding:20px}.compose-modal{width:min(600px,95vw);background:white;border-radius:13px;box-shadow:0 18px 65px #17271c35;overflow:hidden}.modal-head{padding:15px 19px;background:#f6f7f4;border-bottom:1px solid #ebeee9;display:flex;justify-content:space-between;align-items:center;font-size:11px;font-weight:600}.modal-close{border:0;background:transparent;color:#89908a;font-size:19px}.compose-fields{padding:9px 20px 0}.compose-line{display:flex;align-items:center;gap:10px;min-height:39px;border-bottom:1px solid #f0f1ef;color:#969d96;font-size:10px}.compose-line input{flex:1;border:0;outline:0;font-size:10px;color:#424942}.compose-line input::placeholder{color:#aeb3ad}.compose-subject{border:0;width:100%;font-size:14px!important;padding:15px 0;outline:0;color:#303831}.compose-body{width:100%;height:220px;resize:vertical;border:0;border-top:1px solid #f0f1ef;padding:15px 20px;outline:0;font-size:11px;line-height:1.6;color:#414941}.compose-footer{display:flex;justify-content:space-between;align-items:center;padding:12px 20px 15px}.send-button{border:0;border-radius:6px;background:#5b8068;color:white;padding:8px 16px;font-weight:600;font-size:10px}.discard{border:0;background:transparent;color:#929890;font-size:10px}.toast{position:fixed;bottom:22px;left:50%;transform:translate(-50%,15px);opacity:0;pointer-events:none;background:#293b2e;color:#fff;padding:10px 16px;border-radius:8px;font-size:11px;box-shadow:0 5px 20px #1c2b2030;transition:.2s;z-index:20}.toast.visible{opacity:1;transform:translate(-50%,0)} +/* Wasteland: warm paper, weathered ink and rust. */ +body.wasteland{--bg:#eee8db;--panel:#faf6ed;--line:#e6dccb;--text:#373129;--muted:#998a76;--subtle:#f3ede1;--accent:#a75d3d;--accent-soft:#f5e8dc;--shadow:0 2px 10px #44351d0c}body.wasteland .rail{background:#e7dece;border-color:#dfd4c2}body.wasteland .brand-mark{background:#ad6847}body.wasteland .rail-button.active{background:#f1dfcd;color:#a15a39}body.wasteland .rail-button:hover{background:#eee2d2;color:#9a5739}body.wasteland .sidebar,body.wasteland .topbar{background:#faf6ed;border-color:#e6dccb}body.wasteland .account-card{background:#f4eee2;border-color:#ece2d2}body.wasteland .account-avatar{background:#ead8bf;color:#9b633e}body.wasteland .folder.active{background:#f3e6d7;color:#995c3d}body.wasteland .folder.active .nav-glyph{color:#a76645}body.wasteland .count{color:#9e6947}body.wasteland .list-pane,body.wasteland .reader-pane,body.wasteland .compose-modal{background:#faf6ed;border-color:#e6dccb}body.wasteland .compose-button,body.wasteland .send-button,body.wasteland .reply-button.primary{background:#a76645;border-color:#a76645}body.wasteland .compose-button:hover{background:#905538}body.wasteland .message.selected{background:#f5ede0;box-shadow:inset 2px 0 #ad704c}body.wasteland .reader-empty .empty-icon{background:#f3e8d8;color:#a8734c}body.wasteland .reader-button,body.wasteland .reply-button{background:#faf6ed} +@media(max-width:1040px){.sidebar{width:205px;padding-inline:13px}.mail-layout{grid-template-columns:minmax(310px,47%) minmax(320px,1fr);padding:13px;gap:10px}.reader-pane{padding:0 17px 20px}.topbar{padding:0 16px}.message{gap:7px;padding-inline:9px}.list-heading{padding-inline:14px}} +@media(max-width:800px){.sidebar{width:174px;padding-inline:10px}.mail-layout{grid-template-columns:minmax(290px,1fr) minmax(290px,1fr);padding:9px;gap:8px}.reader-pane{padding-inline:13px}.list-heading h2{font-size:17px}.search-wrap{width:170px}} +.page-heading{display:flex;align-items:center;justify-content:space-between;margin:5px 0 20px}.page-heading h2{font-family:'DM Serif Display',Georgia,serif;font-size:28px;font-weight:400;margin:0 0 5px}.page-subtitle{font-size:11px;color:#929991;margin:0}.cal-actions{display:flex;align-items:center;gap:7px}.outline-button{border:1px solid #e3e8e2;background:#fff;border-radius:6px;padding:7px 10px;color:#69736a;font-size:10px}.calendar-card{background:var(--panel);border:1px solid var(--line);border-radius:11px;overflow:hidden;box-shadow:var(--shadow)}.calendar-week{height:38px;display:grid;grid-template-columns:repeat(7,1fr);border-bottom:1px solid var(--line);align-items:center;text-align:center;color:#969d95;font-size:9px;font-weight:600}.calendar-grid{display:grid;grid-template-columns:repeat(7,1fr)}.cal-cell{height:100px;border-right:1px solid #f0f1ee;border-bottom:1px solid #f0f1ee;padding:8px 7px;cursor:pointer;min-width:0}.cal-cell:nth-child(7n){border-right:0}.cal-cell:hover{background:#fafbf9}.cal-cell.outside{background:#fafbf9;color:#d3d7d1}.cal-number{display:grid;place-items:center;width:21px;height:21px;border-radius:50%;font-size:9px;color:#737c73;margin-bottom:4px}.cal-cell.today .cal-number{background:#5b8068;color:#fff}.event-chip{padding:4px 5px;margin:3px 0;border-radius:4px;font-size:8px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;background:#edf4ee;color:#5b8068}.event-chip.gold{background:#f7f1e4;color:#a28449}.event-chip.blue{background:#edf2f7;color:#6885a5}.upcoming{margin:20px 0 0}.upcoming h3{font-family:'DM Serif Display',Georgia,serif;font-size:17px;font-weight:400;margin:0 0 8px}.upcoming-row{display:flex;gap:12px;align-items:center;padding:10px 12px;border:1px solid var(--line);background:var(--panel);border-radius:8px;margin:6px 0;max-width:380px}.event-date{width:36px;height:38px;border-radius:7px;background:#edf4ee;color:#62816a;display:grid;place-content:center;text-align:center;font-size:8px;line-height:1.3}.event-date strong{font-size:14px}.gold-date{background:#f7f1e4;color:#a28449}.upcoming-row div{display:grid;gap:4px}.upcoming-row div strong{font-size:10px}.upcoming-row small{font-size:9px;color:#979e97}.contact-search{height:38px;max-width:370px;display:flex;align-items:center;gap:8px;padding:0 12px;background:var(--panel);border:1px solid var(--line);border-radius:8px;color:#8c958c;margin-bottom:15px}.contact-search input{border:0;background:transparent;outline:0;flex:1;font-size:10px}.contacts-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(245px,1fr));gap:10px}.contact-card{position:relative;display:flex;align-items:center;gap:11px;padding:14px;background:var(--panel);border:1px solid var(--line);border-radius:9px;box-shadow:var(--shadow)}.contact-card>.contact-avatar{height:39px;width:39px;font-size:11px;flex:none}.contact-card>div:nth-child(2){min-width:0;display:grid;gap:4px}.contact-card>div:nth-child(2) strong{font-size:10px}.contact-card>div:nth-child(2) span{font-size:9px;color:#838b83;overflow:hidden;text-overflow:ellipsis}.contact-card>div:nth-child(2) small{font-size:8px;color:#a0a69f}.contact-more{margin-left:auto;align-self:flex-start}.contact-email{position:absolute;right:12px;bottom:10px;border:0;background:transparent;color:#829386;font-size:12px}body.wasteland .outline-button,body.wasteland .upcoming-row{background:#faf6ed;border-color:#e6dccb}body.wasteland .calendar-card{background:#faf6ed;border-color:#e6dccb}body.wasteland .cal-cell:hover{background:#f7f0e4}body.wasteland .event-chip{background:#f2e9da;color:#996445}body.wasteland .cal-cell.today .cal-number{background:#a76645} +.account-card[role="button"]{cursor:pointer;appearance:none}.account-card[role="button"]:hover{border-color:#dce5dc}.account-card[role="button"]:focus-visible{outline:2px solid #7eae90;outline-offset:2px}.account-note{font-size:10px;line-height:1.5;color:#848c84;margin:7px 0 12px}.account-note+.compose-line{margin-top:1px}.account-status{font-size:10px;line-height:1.5;color:#9a6346;min-height:15px;margin:9px 0 2px} +.attachment{box-sizing:border-box;width:100%;max-width:420px;min-width:0}.attachment-info{min-width:0;overflow:hidden}.attachment-info strong{max-width:100%;overflow-wrap:anywhere;word-break:break-word;line-height:1.4}.attachment .download{flex:none}.account-list{max-height:55vh;overflow-y:auto}.account-row{display:flex;justify-content:space-between;align-items:center;gap:12px;padding:12px 0;border-bottom:1px solid #edf0ec}.account-row-info{min-width:0;display:grid;gap:5px}.account-row-info strong{font-size:11px;overflow-wrap:anywhere}.account-row-info small{font-size:9px;color:#929991;overflow-wrap:anywhere}.account-row-actions{display:flex;align-items:center;gap:8px;flex:none}.account-current{font-size:9px;color:#61836a}.account-row .outline-button{padding:6px 9px}.account-row .discard{padding:6px} + +/* EP Wasteland follows the Eternity Project Gitea theme palette. */ +body.ep-wasteland{color-scheme:dark;--bg:#161210;--panel:#1b1714;--line:#4a3f33;--text:#d4cbbc;--muted:#a89a86;--subtle:#241e19;--accent:#8fae3d;--accent-soft:#2b301d;--shadow:0 2px 12px #0008;background:var(--bg);color:var(--text)} +body.ep-wasteland .rail,body.ep-wasteland .sidebar-head,body.ep-wasteland .topbar,body.ep-wasteland .modal-head{background:#211b17;border-color:#4a3f33} +body.ep-wasteland .brand-mark,body.ep-wasteland .compose-button,body.ep-wasteland .send-button,body.ep-wasteland .reply-button.primary{background:#8fae3d;border-color:#8fae3d;color:#161210} +body.ep-wasteland .brand-mark{box-shadow:0 3px 10px #0006} +body.ep-wasteland .avatar{background:#4a3f33;color:#e7e2d3} +body.ep-wasteland .compose-button:hover{background:#a2bd5b;border-color:#a2bd5b} +body.ep-wasteland .rail-button{color:#b5a995} +body.ep-wasteland .rail-button:hover,body.ep-wasteland .icon-button:hover,body.ep-wasteland .folder:hover,body.ep-wasteland .label-link:hover{background:#2b241e;color:#e7e2d3} +body.ep-wasteland .rail-button.active,body.ep-wasteland .folder.active{background:#343b22;color:#a2bd5b} +body.ep-wasteland .sidebar,body.ep-wasteland .list-pane,body.ep-wasteland .reader-pane,body.ep-wasteland .page-view{background:#1b1714;color:#d4cbbc} +body.ep-wasteland .sidebar{border-color:#4a3f33} +body.ep-wasteland .account-card,body.ep-wasteland .search-wrap,body.ep-wasteland .toolbar,body.ep-wasteland .calendar-card,body.ep-wasteland .contact-search,body.ep-wasteland .contact-card,body.ep-wasteland .upcoming-row,body.ep-wasteland .compose-modal{background:#211b17;border-color:#4a3f33;color:#d4cbbc} +body.ep-wasteland .account-avatar,body.ep-wasteland .contact-avatar{background:#343b22;color:#a2bd5b} +body.ep-wasteland .account-info span,body.ep-wasteland .storage small,body.ep-wasteland .section-label,body.ep-wasteland .date-line,body.ep-wasteland .page-subtitle,body.ep-wasteland .pagination,body.ep-wasteland .time,body.ep-wasteland .sender-details span,body.ep-wasteland .message-date,body.ep-wasteland .contact-card>div:nth-child(2) span,body.ep-wasteland .contact-card>div:nth-child(2) small,body.ep-wasteland .upcoming-row small{color:#a89a86} +body.ep-wasteland .sidebar-head h1,body.ep-wasteland .breadcrumbs strong,body.ep-wasteland .list-heading h2,body.ep-wasteland .page-heading h2,body.ep-wasteland .upcoming h3,body.ep-wasteland .sender-details strong,body.ep-wasteland .reader-subject,body.ep-wasteland .reader-empty h3,body.ep-wasteland .contact-card>div:nth-child(2) strong,body.ep-wasteland .upcoming-row div strong{color:#e7e2d3} +body.ep-wasteland .eyebrow,body.ep-wasteland .breadcrumbs,body.ep-wasteland .icon-button,body.ep-wasteland .folder,body.ep-wasteland .label-link,body.ep-wasteland .settings-button,body.ep-wasteland .nav-glyph,body.ep-wasteland .search-wrap,body.ep-wasteland .help-button{color:#b5a995} +body.ep-wasteland .online-dot{background:#8fae3d} +body.ep-wasteland .folder.active .nav-glyph,body.ep-wasteland .count,body.ep-wasteland .text-button,body.ep-wasteland .contact-email,body.ep-wasteland .account-current{color:#a2bd5b} +body.ep-wasteland .count{background:#2b301d} +body.ep-wasteland .sidebar-divider,body.ep-wasteland .storage,body.ep-wasteland .storage-bar,body.ep-wasteland .toolbar-divider,body.ep-wasteland .reader-header,body.ep-wasteland .reply-bar,body.ep-wasteland .message,body.ep-wasteland .list-foot,body.ep-wasteland .account-row{border-color:#4a3f33} +body.ep-wasteland .storage-bar{background:#4a3f33} +body.ep-wasteland .storage-bar i{background:#8fae3d} +body.ep-wasteland .message{background:#1b1714} +body.ep-wasteland .message:hover,body.ep-wasteland .message.selected{background:#241e19} +body.ep-wasteland .message.selected{box-shadow:inset 2px 0 #8fae3d} +body.ep-wasteland .sender,body.ep-wasteland .subject,body.ep-wasteland .message.unread .sender,body.ep-wasteland .message.unread .subject{color:#e7e2d3} +body.ep-wasteland .snippet,body.ep-wasteland .list-foot,body.ep-wasteland .reader-body{color:#b5a995} +body.ep-wasteland .star{color:#8f8170} +body.ep-wasteland .star.on{color:#a2bd5b} +body.ep-wasteland .reader-empty{color:#a89a86} +body.ep-wasteland .empty-icon,body.ep-wasteland .event-date,body.ep-wasteland .cal-cell.today .cal-number{background:#343b22;color:#a2bd5b} +body.ep-wasteland .attachment,body.ep-wasteland .file-icon{background:#211b17;border-color:#4a3f33;color:#a2bd5b} +body.ep-wasteland .attachment-info strong,body.ep-wasteland .attachment-info small{color:#d4cbbc} +body.ep-wasteland .reply-button,body.ep-wasteland .outline-button{background:#211b17;border-color:#4a3f33;color:#d4cbbc} +body.ep-wasteland .reply-button:hover,body.ep-wasteland .outline-button:hover{background:#2b241e} +body.ep-wasteland .modal-overlay{background:#000b} +body.ep-wasteland .compose-fields,body.ep-wasteland .compose-footer{background:#1b1714} +body.ep-wasteland .compose-line,body.ep-wasteland .compose-body{border-color:#4a3f33;color:#b5a995} +body.ep-wasteland .compose-line input,body.ep-wasteland .compose-subject,body.ep-wasteland .compose-body,body.ep-wasteland .contact-search input{background:transparent;color:#e7e2d3} +body.ep-wasteland .compose-line input::placeholder,body.ep-wasteland .compose-body::placeholder{color:#8f8170} +body.ep-wasteland .modal-close,body.ep-wasteland .discard{color:#a89a86} +body.ep-wasteland .toast{background:#211b17;color:#e7e2d3;border:1px solid #4a3f33} +body.ep-wasteland .calendar-week{border-color:#4a3f33;color:#a89a86} +body.ep-wasteland .cal-cell{border-color:#342c24;color:#d4cbbc} +body.ep-wasteland .cal-cell:hover,body.ep-wasteland .cal-cell.outside{background:#241e19} +body.ep-wasteland .cal-cell.outside{color:#8f8170} +body.ep-wasteland .cal-number{color:#d4cbbc} +body.ep-wasteland .event-chip,body.ep-wasteland .gold-date{background:#343b22;color:#a2bd5b} +body.ep-wasteland .event-chip.gold,body.ep-wasteland .event-chip.blue{background:#2b241e;color:#d4cbbc} +body.ep-wasteland .tag,body.ep-wasteland .tag.green{background:#343b22;color:#a2bd5b} +body.ep-wasteland .row-check{border-color:#8f8170} +body.ep-wasteland .row-check:checked{accent-color:#8fae3d} + +/* EP Daylight follows the Eternity Project Gitea theme palette. */ +body.ep-daylight{color-scheme:light;--bg:#f1f1e9;--panel:#fbfbf6;--line:#b9c5bc;--text:#263a3d;--muted:#70827b;--subtle:#e9eee4;--accent:#526a2c;--accent-soft:#e9eee4;--shadow:0 2px 10px #11212b12;background:var(--bg);color:var(--text)} +body.ep-daylight .rail,body.ep-daylight .sidebar-head,body.ep-daylight .topbar,body.ep-daylight .modal-head{background:#e8e9df;border-color:#b9c5bc} +body.ep-daylight .brand-mark,body.ep-daylight .compose-button,body.ep-daylight .send-button,body.ep-daylight .reply-button.primary{background:#526a2c;border-color:#526a2c;color:#f1f1e9} +body.ep-daylight .brand-mark{box-shadow:0 3px 8px #11212b20} +body.ep-daylight .compose-button:hover{background:#435722;border-color:#435722} +body.ep-daylight .sidebar,body.ep-daylight .list-pane,body.ep-daylight .reader-pane,body.ep-daylight .page-view{background:#fbfbf6;color:#263a3d} +body.ep-daylight .sidebar{border-color:#b9c5bc} +body.ep-daylight .account-card,body.ep-daylight .search-wrap,body.ep-daylight .toolbar,body.ep-daylight .calendar-card,body.ep-daylight .contact-search,body.ep-daylight .contact-card,body.ep-daylight .upcoming-row,body.ep-daylight .compose-modal{background:#fbfbf6;border-color:#b9c5bc;color:#263a3d} +body.ep-daylight .rail-button,body.ep-daylight .icon-button,body.ep-daylight .folder,body.ep-daylight .label-link,body.ep-daylight .settings-button,body.ep-daylight .nav-glyph,body.ep-daylight .help-button{color:#59706b} +body.ep-daylight .rail-button:hover,body.ep-daylight .icon-button:hover,body.ep-daylight .folder:hover,body.ep-daylight .label-link:hover,body.ep-daylight .reply-button:hover,body.ep-daylight .outline-button:hover{background:#e9eee4;color:#263a3d} +body.ep-daylight .rail-button.active,body.ep-daylight .folder.active{background:#e9eee4;color:#526a2c} +body.ep-daylight .account-avatar,body.ep-daylight .contact-avatar{background:#e9eee4;color:#526a2c} +body.ep-daylight .avatar{background:#b9c5bc;color:#11212b} +body.ep-daylight .sidebar-head h1,body.ep-daylight .breadcrumbs strong,body.ep-daylight .list-heading h2,body.ep-daylight .page-heading h2,body.ep-daylight .upcoming h3,body.ep-daylight .sender-details strong,body.ep-daylight .reader-subject,body.ep-daylight .reader-empty h3,body.ep-daylight .contact-card>div:nth-child(2) strong,body.ep-daylight .upcoming-row div strong{color:#11212b} +body.ep-daylight .eyebrow,body.ep-daylight .breadcrumbs,body.ep-daylight .date-line,body.ep-daylight .page-subtitle,body.ep-daylight .section-label,body.ep-daylight .account-info span,body.ep-daylight .storage small,body.ep-daylight .pagination,body.ep-daylight .time,body.ep-daylight .sender-details span,body.ep-daylight .message-date,body.ep-daylight .contact-card>div:nth-child(2) span,body.ep-daylight .contact-card>div:nth-child(2) small,body.ep-daylight .upcoming-row small{color:#59706b} +body.ep-daylight .online-dot,body.ep-daylight .storage-bar i{background:#8fae3d} +body.ep-daylight .folder.active .nav-glyph,body.ep-daylight .count,body.ep-daylight .text-button,body.ep-daylight .contact-email,body.ep-daylight .account-current{color:#526a2c} +body.ep-daylight .count{background:#e9eee4} +body.ep-daylight .sidebar-divider,body.ep-daylight .storage,body.ep-daylight .reader-header,body.ep-daylight .reply-bar,body.ep-daylight .message,body.ep-daylight .list-foot,body.ep-daylight .account-row,body.ep-daylight .calendar-week,body.ep-daylight .cal-cell{border-color:#b9c5bc} +body.ep-daylight .storage-bar,body.ep-daylight .toolbar-divider{background:#b9c5bc} +body.ep-daylight .message{background:#fbfbf6} +body.ep-daylight .message:hover,body.ep-daylight .message.selected{background:#e9eee4} +body.ep-daylight .message.selected{box-shadow:inset 2px 0 #8fae3d} +body.ep-daylight .sender,body.ep-daylight .subject,body.ep-daylight .message.unread .sender,body.ep-daylight .message.unread .subject{color:#11212b} +body.ep-daylight .snippet,body.ep-daylight .list-foot,body.ep-daylight .reader-body{color:#59706b} +body.ep-daylight .star{color:#70827b} +body.ep-daylight .star.on{color:#526a2c} +body.ep-daylight .reader-empty{color:#59706b} +body.ep-daylight .empty-icon,body.ep-daylight .event-date,body.ep-daylight .cal-cell.today .cal-number{background:#e9eee4;color:#526a2c} +body.ep-daylight .attachment,body.ep-daylight .file-icon{background:#fbfbf6;border-color:#b9c5bc;color:#526a2c} +body.ep-daylight .attachment-info strong{color:#263a3d} +body.ep-daylight .attachment-info small{color:#59706b} +body.ep-daylight .reply-button,body.ep-daylight .outline-button{background:#fbfbf6;border-color:#b9c5bc;color:#263a3d} +body.ep-daylight .tag,body.ep-daylight .tag.green,body.ep-daylight .event-chip{background:#e9eee4;color:#526a2c} +body.ep-daylight .event-chip.gold,body.ep-daylight .event-chip.blue,body.ep-daylight .gold-date{background:#e8e9df;color:#59706b} +body.ep-daylight .cal-cell{color:#263a3d} +body.ep-daylight .cal-cell:hover,body.ep-daylight .cal-cell.outside{background:#e9eee4} +body.ep-daylight .cal-cell.outside{color:#70827b} +body.ep-daylight .cal-number{color:#263a3d} +body.ep-daylight .modal-overlay{background:#11212b55} +body.ep-daylight .compose-fields,body.ep-daylight .compose-footer{background:#fbfbf6} +body.ep-daylight .compose-line,body.ep-daylight .compose-body{border-color:#b9c5bc;color:#59706b} +body.ep-daylight .compose-line input,body.ep-daylight .compose-subject,body.ep-daylight .compose-body,body.ep-daylight .contact-search input{background:transparent;color:#11212b} +body.ep-daylight .compose-line input::placeholder,body.ep-daylight .compose-body::placeholder{color:#70827b} +body.ep-daylight .modal-close,body.ep-daylight .discard{color:#59706b} +body.ep-daylight .toast{background:#11212b;color:#f1f1e9} +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} +.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} +@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}} + .search-filters{position:absolute;right:78px;top:calc(100% + 8px);z-index:12;display:grid;grid-template-columns:1fr 1fr;gap:10px;width:min(360px,calc(100vw - 32px));padding:14px;border:1px solid var(--border,#d8ddd5);border-radius:12px;background:var(--panel,#fff);box-shadow:0 8px 28px #17201724}.search-filters.hidden{display:none}.search-filters label{display:grid;gap:4px;font-size:12px}.search-filters input,.search-filters select{min-width:0;border:1px solid var(--border,#d8ddd5);border-radius:7px;padding:7px;background:transparent;color:inherit;font:inherit}.search-filters .filter-checkbox{display:flex;align-items:center;gap:7px}.search-filters .filter-checkbox input{min-width:auto}.search-filters .text-button{grid-column:1/-1;justify-self:start}.top-actions{position:relative} + body.ep-wasteland .search-filters{background:#211c18;border-color:#4a3f33;color:#d4cbbc}body.ep-wasteland .search-filters input,body.ep-wasteland .search-filters select{border-color:#4a3f33;color:#d4cbbc} + body.ep-daylight .search-filters{background:#fbfbf6;border-color:#b9c5bc;color:#263a3d} + .mail-safety-warning{margin:10px 16px;padding:12px 14px;border:1px solid #d69b43;border-left:4px solid #b87321;border-radius:8px;background:#fff6df;color:#5b3c17;font-size:12px}.mail-safety-warning strong{display:block}.mail-safety-warning ul{margin:7px 0;padding-left:18px}.mail-safety-warning small{display:block;line-height:1.4}.mail-links{padding:12px 16px;border-top:1px solid var(--line,#eaede8)}.mail-links h3{margin:0 0 8px;font-size:12px}.mail-safety-intro{font-size:11px;color:#8d4a16}.mail-link-row{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:9px 10px;margin-top:6px;border:1px solid var(--line,#eaede8);border-radius:8px;font-size:11px}.mail-link-row>div{min-width:0;display:grid;gap:3px}.mail-link-row span,.mail-link-row small{overflow-wrap:anywhere;color:#727970}.mail-link-risky{border-color:#d69b43;background:#fff8ea}.mail-link-open{flex:none;border:1px solid #9ba99b;border-radius:6px;background:transparent;padding:6px 8px;font-size:10px}.mail-link-open:disabled{opacity:.55;cursor:wait} + body.ep-wasteland .mail-safety-warning{background:#392719;border-color:#a8793e;color:#f0d4a3}body.ep-wasteland .mail-link-row{border-color:#4a3f33}body.ep-wasteland .mail-link-risky{background:#392719;border-color:#a8793e}body.ep-wasteland .mail-link-row span,body.ep-wasteland .mail-link-row small{color:#cbbba0} + 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} +.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} +.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-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 small{opacity:.85}.pgp-ok{border-color:#3d7a4f;background:rgba(61,122,79,.12)}.pgp-warn{border-color:#b8860b;background:rgba(184,134,11,.14)}.pgp-bad{border-color:#b3261e;background:rgba(179,38,30,.14)} +.pgp-banner button,.pgp-status button{align-self:flex-start;margin-top:6px} +.pgp-compose{display:flex;align-items:center;gap:12px;margin-right:auto;font-size:13px}.pgp-compose label{display:flex;align-items:center;gap:4px}.pgp-compose small{opacity:.8} +.pgp-trust{margin-left:8px} + +.draft-delete{margin-top:4px;font-size:15px;opacity:.55}.draft-delete:hover{opacity:1;color:#b3261e}.pgp-prompt-box{width:min(380px,92vw)} +.reader-body img{display:block;max-width:100%;height:auto;margin:12px 0;border-radius:6px}.reader-body table{max-width:100%;border-collapse:collapse}.reader-body th,.reader-body td{border:1px solid var(--line);padding:5px}.remote-image-notice{margin:14px 0 0;padding:12px;border:1px solid #d7a85c;border-radius:8px;background:#fff8e9;color:#664a23;font-size:10px;line-height:1.5}.remote-image-notice p{margin:0 0 8px}.remote-image-notice .reply-button{background:transparent;color:inherit;border-color:#d7a85c}body.ep-wasteland .remote-image-notice{background:#3a3022;color:#e6d1a8;border-color:#806b44}body.ep-daylight .remote-image-notice{background:#fff8e9;color:#664a23;border-color:#d7a85c} + +.sidebar{overflow-y:auto}#mail-nav{overflow-y:auto;min-height:150px;flex:0 1 auto;scrollbar-width:thin;align-content:start}#custom-folders{display:contents}.folders-head{flex:none}.sidebar>:not(#mail-nav){flex-shrink:0}.folders-head+.folder-nav{margin-top:0} diff --git a/tests/build-version.test.cjs b/tests/build-version.test.cjs index 778135c..3d5c082 100644 --- a/tests/build-version.test.cjs +++ b/tests/build-version.test.cjs @@ -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 androidBuild = fs.readFileSync(path.join(root, 'android', 'app', 'build.gradle'), 'utf8'); const buildAll = fs.readFileSync(path.join(root, 'scripts', 'build-all.ps1'), '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 desktopWorkflow = fs.readFileSync(path.join(root, '.github', 'workflows', 'desktop-build.yml'), 'utf8'); test('package metadata and lockfile share one release version', () => { @@ -32,3 +34,14 @@ test('release scripts and desktop artifact labels use package.json version', () assert.match(desktopWorkflow, /require\('\.\/package\.json'\)\.version/); assert.match(desktopWorkflow, /-v\$\{\{ steps\.app-version\.outputs\.version \}\}/); }); + +test('Android debug APK is labeled as debug and release APK requires signing credentials', () => { + assert.match(androidDebugScript, /assembleDebug/); + assert.match(androidDebugScript, /ep-mail \$\{version\}-debug\.apk/); + assert.match(androidReleaseScript, /assembleRelease/); + assert.match(androidReleaseScript, /EP_MAIL_ANDROID_STORE_FILE/); + assert.match(androidReleaseScript, /EP_MAIL_ANDROID_STORE_PASSWORD/); + assert.match(androidReleaseScript, /EP_MAIL_ANDROID_KEY_ALIAS/); + assert.match(androidReleaseScript, /EP_MAIL_ANDROID_KEY_PASSWORD/); + assert.match(androidReleaseScript, /ep-mail \$\{version\}\.apk/); +}); diff --git a/tests/mail-attachments.test.cjs b/tests/mail-attachments.test.cjs index 2490bf0..532cf68 100644 --- a/tests/mail-attachments.test.cjs +++ b/tests/mail-attachments.test.cjs @@ -1,38 +1,38 @@ -const test = require('node:test'); -const assert = require('node:assert/strict'); -const { normalizeOutgoingAttachments, serializeOutgoingAttachments } = require('../desktop/mail-attachments.cjs'); - -test('normalizes attachment metadata and round-trips bytes through serialized drafts and sends', () => { - const bytes = Buffer.from([0, 1, 2, 127, 128, 255]); - const [file] = normalizeOutgoingAttachments([{ - filename: 'folder\\report.bin', - contentType: 'APPLICATION/OCTET-STREAM', - size: 999, - contentBase64: bytes.toString('base64') - }]); - - assert.equal(file.filename, 'report.bin'); - assert.equal(file.contentType, 'application/octet-stream'); - assert.equal(file.size, bytes.length); - assert.deepEqual(file.content, bytes); - const [serialized] = serializeOutgoingAttachments([file]); - assert.equal(serialized.contentBase64, bytes.toString('base64')); - assert.equal('content' in serialized, false); -}); - -test('rejects malformed attachment data and unsafe content types', () => { - assert.throws(() => normalizeOutgoingAttachments({}), /attachment list is invalid/); - assert.throws(() => normalizeOutgoingAttachments([{ filename: 'x', contentBase64: '***=' }]), /contents.*invalid/); - assert.throws(() => normalizeOutgoingAttachments([{ - filename: 'x', - contentType: 'text/plain\r\nBcc: bad@example.com', - contentBase64: '' - }]), /content type.*invalid/); -}); - -test('uses fallback names and MIME types for empty metadata', () => { - const [file] = normalizeOutgoingAttachments([{ contentBase64: '' }]); - assert.equal(file.filename, 'attachment'); - assert.equal(file.contentType, 'application/octet-stream'); - assert.equal(file.size, 0); -}); +const test = require('node:test'); +const assert = require('node:assert/strict'); +const { normalizeOutgoingAttachments, serializeOutgoingAttachments } = require('../desktop/mail-attachments.cjs'); + +test('normalizes attachment metadata and round-trips bytes through serialized drafts and sends', () => { + const bytes = Buffer.from([0, 1, 2, 127, 128, 255]); + const [file] = normalizeOutgoingAttachments([{ + filename: 'folder\\report.bin', + contentType: 'APPLICATION/OCTET-STREAM', + size: 999, + contentBase64: bytes.toString('base64') + }]); + + assert.equal(file.filename, 'report.bin'); + assert.equal(file.contentType, 'application/octet-stream'); + assert.equal(file.size, bytes.length); + assert.deepEqual(file.content, bytes); + const [serialized] = serializeOutgoingAttachments([file]); + assert.equal(serialized.contentBase64, bytes.toString('base64')); + assert.equal('content' in serialized, false); +}); + +test('rejects malformed attachment data and unsafe content types', () => { + assert.throws(() => normalizeOutgoingAttachments({}), /attachment list is invalid/); + assert.throws(() => normalizeOutgoingAttachments([{ filename: 'x', contentBase64: '***=' }]), /contents.*invalid/); + assert.throws(() => normalizeOutgoingAttachments([{ + filename: 'x', + contentType: 'text/plain\r\nBcc: bad@example.com', + contentBase64: '' + }]), /content type.*invalid/); +}); + +test('uses fallback names and MIME types for empty metadata', () => { + const [file] = normalizeOutgoingAttachments([{ contentBase64: '' }]); + assert.equal(file.filename, 'attachment'); + assert.equal(file.contentType, 'application/octet-stream'); + assert.equal(file.size, 0); +}); diff --git a/tests/pgp-gnupg-interop.test.cjs b/tests/pgp-gnupg-interop.test.cjs index 3297eb9..25912e9 100644 --- a/tests/pgp-gnupg-interop.test.cjs +++ b/tests/pgp-gnupg-interop.test.cjs @@ -1,104 +1,104 @@ -const test = require('node:test'); -const assert = require('node:assert/strict'); -const { spawnSync } = require('node:child_process'); -const fs = require('node:fs'); -const os = require('node:os'); -const path = require('node:path'); -const { simpleParser } = require('mailparser'); -const { createKeyStore } = require('../desktop/pgp-keystore.cjs'); -const { createPgpMail, createPassphraseCache } = require('../desktop/pgp-mail.cjs'); - -const gpgPath = [process.env.GPG_PATH, 'gpg', 'C:\\Program Files\\GnuPG\\bin\\gpg.exe', 'C:\\Program Files (x86)\\GnuPG\\bin\\gpg.exe'] - .filter(Boolean).find(candidate => spawnSync(candidate, ['--version']).status === 0); -const skip = gpgPath ? false : 'GnuPG is not installed'; -const PASS = 'interop passphrase'; - -function gpgIn(home) { - return (args, input) => { - const result = spawnSync(gpgPath, ['--homedir', home, '--batch', '--yes', '--pinentry-mode', 'loopback', '--passphrase', PASS, '--trust-model', 'always', ...args], { input }); - if (result.status !== 0) throw new Error(`gpg ${args.join(' ')} failed: ${result.stderr}`); - return { out: result.stdout, err: result.stderr.toString() }; - }; -} - -async function setup() { - const home = fs.mkdtempSync(path.join(os.tmpdir(), 'ep-gnupg-')); - const gpg = gpgIn(home); - gpg(['--quick-generate-key', 'Gina Gnu ', 'ed25519', 'cert', 'never']); - const fingerprint = /^fpr:::::::::([0-9A-F]+):/m.exec(gpg(['--list-keys', '--with-colons', 'gina@example.com']).out.toString())[1]; - gpg(['--quick-add-key', fingerprint, 'cv25519', 'encr', 'never']); - gpg(['--quick-add-key', fingerprint, 'ed25519', 'sign', 'never']); - let data = null; - const keyStore = createKeyStore({ async load() { return data && JSON.parse(JSON.stringify(data)); }, async save(value) { data = JSON.parse(JSON.stringify(value)); } }); - const mail = createPgpMail({ keyStore, cache: createPassphraseCache(async () => 10) }); - const { key } = await keyStore.generate({ name: 'Eppu Mail', email: 'eppu@example.com', passphrase: PASS }); - gpg(['--import'], Buffer.from(await keyStore.exportPublic(key.fingerprint))); - await keyStore.addContact({ armoredKey: gpg(['--armor', '--export', 'gina@example.com']).out.toString() }); - return { home, gpg, keyStore, mail }; -} - -const options = extra => ({ - from: { name: 'Eppu Mail', address: 'eppu@example.com' }, to: 'Gina Gnu ', - subject: 'Interop', text: 'Hello from ep-mail ✓', messageId: '', passphrase: PASS, ...extra -}); - -test('GnuPG decrypts and verifies mail encrypted and signed by ep-mail', { skip }, async () => { - const { home, gpg, mail } = await setup(); - try { - const { raw } = await mail.build(options({ encrypt: true, sign: true })); - const parsed = await simpleParser(raw); - const armored = /-----BEGIN PGP MESSAGE-----[\s\S]+?-----END PGP MESSAGE-----/.exec(parsed.attachments[1]?.content?.toString() || parsed.attachments[0].content.toString())[0]; - const { out, err } = gpg(['--decrypt'], Buffer.from(armored)); - assert.match((await simpleParser(out)).text, /Hello from ep-mail ✓/); - assert.match(err, /Good signature from "Eppu Mail "/); - } finally { fs.rmSync(home, { recursive: true, force: true }); } -}); - -test('GnuPG verifies PGP/MIME signed-only mail from ep-mail', { skip }, async () => { - const { home, gpg, mail } = await setup(); - try { - const { raw } = await mail.build(options({ sign: true })); - const text = raw.toString('latin1'); - const { splitSigned } = require('../desktop/pgp-mail.cjs'); - const boundary = /boundary="([^"]+)"/.exec(text)[1]; - const parts = splitSigned(raw, boundary); - const signaturePath = path.join(home, 'sig.asc'); - const dataPath = path.join(home, 'data.bin'); - fs.writeFileSync(signaturePath, parts.signature); - fs.writeFileSync(dataPath, parts.signed); - const { err } = gpg(['--verify', signaturePath, dataPath]); - assert.match(err, /Good signature from "Eppu Mail/); - } finally { fs.rmSync(home, { recursive: true, force: true }); } -}); - -test('ep-mail decrypts GnuPG-encrypted PGP/MIME mail and verifies its signature', { skip }, async () => { - const { home, gpg, mail, keyStore } = await setup(); - try { - const inner = Buffer.from('Content-Type: text/plain; charset=utf-8\r\n\r\nHello from GnuPG ✓\r\n'); - const armored = gpg(['--armor', '--encrypt', '--sign', '--local-user', 'gina@example.com', '--recipient', 'eppu@example.com'], inner).out.toString(); - const source = Buffer.from(`From: Gina Gnu \r\nTo: eppu@example.com\r\nSubject: from gpg\r\nMIME-Version: 1.0\r\nContent-Type: multipart/encrypted; protocol="application/pgp-encrypted"; boundary="gb"\r\n\r\n--gb\r\nContent-Type: application/pgp-encrypted\r\n\r\nVersion: 1\r\n\r\n--gb\r\nContent-Type: application/octet-stream; name="encrypted.asc"\r\n\r\n${armored}\r\n--gb--\r\n`); - const result = await mail.decrypt(await simpleParser(source), { passphrase: PASS }); - assert.match(result.parsed.text, /Hello from GnuPG ✓/); - assert.equal(result.signatures[0].status, 'valid'); - assert.equal(result.signatures[0].matchesSender, true); - assert.ok(await keyStore.listContacts()); - } finally { fs.rmSync(home, { recursive: true, force: true }); } -}); - -test('ep-mail decrypts GnuPG inline PGP and verifies GnuPG clear-signed and PGP/MIME signed mail', { skip }, async () => { - const { home, gpg, mail } = await setup(); - try { - const inline = gpg(['--armor', '--encrypt', '--recipient', 'eppu@example.com'], Buffer.from('inline from gpg')).out.toString(); - const inlineSource = Buffer.from(`From: gina@example.com\r\nSubject: i\r\nContent-Type: text/plain\r\n\r\n${inline}\r\n`); - assert.match((await mail.decrypt(await simpleParser(inlineSource), { passphrase: PASS })).parsed.text, /inline from gpg/); - - const clear = gpg(['--clearsign', '--local-user', 'gina@example.com'], Buffer.from('clear signed text\n')).out.toString().replace(/\r?\n/g, '\r\n'); - const clearSource = Buffer.from(`From: gina@example.com\r\nSubject: c\r\nContent-Type: text/plain\r\n\r\n${clear}\r\n`); - assert.equal((await mail.verifySigned(await simpleParser(clearSource), clearSource))[0].status, 'valid'); - - const signedPart = 'Content-Type: text/plain; charset=utf-8\r\n\r\nsigned by gpg'; - const detached = gpg(['--armor', '--detach-sign', '--local-user', 'gina@example.com'], Buffer.from(signedPart)).out.toString().replace(/\r?\n/g, '\r\n').trim(); - const mimeSource = Buffer.from(`From: gina@example.com\r\nSubject: m\r\nMIME-Version: 1.0\r\nContent-Type: multipart/signed; protocol="application/pgp-signature"; micalg=pgp-sha512; boundary="sb"\r\n\r\n--sb\r\n${signedPart}\r\n--sb\r\nContent-Type: application/pgp-signature\r\n\r\n${detached}\r\n--sb--\r\n`); - assert.equal((await mail.verifySigned(await simpleParser(mimeSource), mimeSource))[0].status, 'valid'); - } finally { fs.rmSync(home, { recursive: true, force: true }); } -}); +const test = require('node:test'); +const assert = require('node:assert/strict'); +const { spawnSync } = require('node:child_process'); +const fs = require('node:fs'); +const os = require('node:os'); +const path = require('node:path'); +const { simpleParser } = require('mailparser'); +const { createKeyStore } = require('../desktop/pgp-keystore.cjs'); +const { createPgpMail, createPassphraseCache } = require('../desktop/pgp-mail.cjs'); + +const gpgPath = [process.env.GPG_PATH, 'gpg', 'C:\\Program Files\\GnuPG\\bin\\gpg.exe', 'C:\\Program Files (x86)\\GnuPG\\bin\\gpg.exe'] + .filter(Boolean).find(candidate => spawnSync(candidate, ['--version']).status === 0); +const skip = gpgPath ? false : 'GnuPG is not installed'; +const PASS = 'interop passphrase'; + +function gpgIn(home) { + return (args, input) => { + const result = spawnSync(gpgPath, ['--homedir', home, '--batch', '--yes', '--pinentry-mode', 'loopback', '--passphrase', PASS, '--trust-model', 'always', ...args], { input }); + if (result.status !== 0) throw new Error(`gpg ${args.join(' ')} failed: ${result.stderr}`); + return { out: result.stdout, err: result.stderr.toString() }; + }; +} + +async function setup() { + const home = fs.mkdtempSync(path.join(os.tmpdir(), 'ep-gnupg-')); + const gpg = gpgIn(home); + gpg(['--quick-generate-key', 'Gina Gnu ', 'ed25519', 'cert', 'never']); + const fingerprint = /^fpr:::::::::([0-9A-F]+):/m.exec(gpg(['--list-keys', '--with-colons', 'gina@example.com']).out.toString())[1]; + gpg(['--quick-add-key', fingerprint, 'cv25519', 'encr', 'never']); + gpg(['--quick-add-key', fingerprint, 'ed25519', 'sign', 'never']); + let data = null; + const keyStore = createKeyStore({ async load() { return data && JSON.parse(JSON.stringify(data)); }, async save(value) { data = JSON.parse(JSON.stringify(value)); } }); + const mail = createPgpMail({ keyStore, cache: createPassphraseCache(async () => 10) }); + const { key } = await keyStore.generate({ name: 'Eppu Mail', email: 'eppu@example.com', passphrase: PASS }); + gpg(['--import'], Buffer.from(await keyStore.exportPublic(key.fingerprint))); + await keyStore.addContact({ armoredKey: gpg(['--armor', '--export', 'gina@example.com']).out.toString() }); + return { home, gpg, keyStore, mail }; +} + +const options = extra => ({ + from: { name: 'Eppu Mail', address: 'eppu@example.com' }, to: 'Gina Gnu ', + subject: 'Interop', text: 'Hello from ep-mail ✓', messageId: '', passphrase: PASS, ...extra +}); + +test('GnuPG decrypts and verifies mail encrypted and signed by ep-mail', { skip }, async () => { + const { home, gpg, mail } = await setup(); + try { + const { raw } = await mail.build(options({ encrypt: true, sign: true })); + const parsed = await simpleParser(raw); + const armored = /-----BEGIN PGP MESSAGE-----[\s\S]+?-----END PGP MESSAGE-----/.exec(parsed.attachments[1]?.content?.toString() || parsed.attachments[0].content.toString())[0]; + const { out, err } = gpg(['--decrypt'], Buffer.from(armored)); + assert.match((await simpleParser(out)).text, /Hello from ep-mail ✓/); + assert.match(err, /Good signature from "Eppu Mail "/); + } finally { fs.rmSync(home, { recursive: true, force: true }); } +}); + +test('GnuPG verifies PGP/MIME signed-only mail from ep-mail', { skip }, async () => { + const { home, gpg, mail } = await setup(); + try { + const { raw } = await mail.build(options({ sign: true })); + const text = raw.toString('latin1'); + const { splitSigned } = require('../desktop/pgp-mail.cjs'); + const boundary = /boundary="([^"]+)"/.exec(text)[1]; + const parts = splitSigned(raw, boundary); + const signaturePath = path.join(home, 'sig.asc'); + const dataPath = path.join(home, 'data.bin'); + fs.writeFileSync(signaturePath, parts.signature); + fs.writeFileSync(dataPath, parts.signed); + const { err } = gpg(['--verify', signaturePath, dataPath]); + assert.match(err, /Good signature from "Eppu Mail/); + } finally { fs.rmSync(home, { recursive: true, force: true }); } +}); + +test('ep-mail decrypts GnuPG-encrypted PGP/MIME mail and verifies its signature', { skip }, async () => { + const { home, gpg, mail, keyStore } = await setup(); + try { + const inner = Buffer.from('Content-Type: text/plain; charset=utf-8\r\n\r\nHello from GnuPG ✓\r\n'); + const armored = gpg(['--armor', '--encrypt', '--sign', '--local-user', 'gina@example.com', '--recipient', 'eppu@example.com'], inner).out.toString(); + const source = Buffer.from(`From: Gina Gnu \r\nTo: eppu@example.com\r\nSubject: from gpg\r\nMIME-Version: 1.0\r\nContent-Type: multipart/encrypted; protocol="application/pgp-encrypted"; boundary="gb"\r\n\r\n--gb\r\nContent-Type: application/pgp-encrypted\r\n\r\nVersion: 1\r\n\r\n--gb\r\nContent-Type: application/octet-stream; name="encrypted.asc"\r\n\r\n${armored}\r\n--gb--\r\n`); + const result = await mail.decrypt(await simpleParser(source), { passphrase: PASS }); + assert.match(result.parsed.text, /Hello from GnuPG ✓/); + assert.equal(result.signatures[0].status, 'valid'); + assert.equal(result.signatures[0].matchesSender, true); + assert.ok(await keyStore.listContacts()); + } finally { fs.rmSync(home, { recursive: true, force: true }); } +}); + +test('ep-mail decrypts GnuPG inline PGP and verifies GnuPG clear-signed and PGP/MIME signed mail', { skip }, async () => { + const { home, gpg, mail } = await setup(); + try { + const inline = gpg(['--armor', '--encrypt', '--recipient', 'eppu@example.com'], Buffer.from('inline from gpg')).out.toString(); + const inlineSource = Buffer.from(`From: gina@example.com\r\nSubject: i\r\nContent-Type: text/plain\r\n\r\n${inline}\r\n`); + assert.match((await mail.decrypt(await simpleParser(inlineSource), { passphrase: PASS })).parsed.text, /inline from gpg/); + + const clear = gpg(['--clearsign', '--local-user', 'gina@example.com'], Buffer.from('clear signed text\n')).out.toString().replace(/\r?\n/g, '\r\n'); + const clearSource = Buffer.from(`From: gina@example.com\r\nSubject: c\r\nContent-Type: text/plain\r\n\r\n${clear}\r\n`); + assert.equal((await mail.verifySigned(await simpleParser(clearSource), clearSource))[0].status, 'valid'); + + const signedPart = 'Content-Type: text/plain; charset=utf-8\r\n\r\nsigned by gpg'; + const detached = gpg(['--armor', '--detach-sign', '--local-user', 'gina@example.com'], Buffer.from(signedPart)).out.toString().replace(/\r?\n/g, '\r\n').trim(); + const mimeSource = Buffer.from(`From: gina@example.com\r\nSubject: m\r\nMIME-Version: 1.0\r\nContent-Type: multipart/signed; protocol="application/pgp-signature"; micalg=pgp-sha512; boundary="sb"\r\n\r\n--sb\r\n${signedPart}\r\n--sb\r\nContent-Type: application/pgp-signature\r\n\r\n${detached}\r\n--sb--\r\n`); + assert.equal((await mail.verifySigned(await simpleParser(mimeSource), mimeSource))[0].status, 'valid'); + } finally { fs.rmSync(home, { recursive: true, force: true }); } +}); diff --git a/tests/pgp-keyservers.test.cjs b/tests/pgp-keyservers.test.cjs index 081435b..efdb75d 100644 --- a/tests/pgp-keyservers.test.cjs +++ b/tests/pgp-keyservers.test.cjs @@ -1,244 +1,244 @@ -const test = require('node:test'); -const assert = require('node:assert/strict'); -const openpgp = require('openpgp'); -const { createKeyServerService, listServers, normalizeCustomServer } = require('../desktop/pgp-keyservers.cjs'); -const { createKeyStore } = require('../desktop/pgp-keystore.cjs'); - -const email = 'ada@example.org'; - -function memoryStore() { - let data = null; - return { - async load() { return data && JSON.parse(JSON.stringify(data)); }, - async save(value) { data = JSON.parse(JSON.stringify(value)); } - }; -} - -async function makeKey() { - const generated = await openpgp.generateKey({ - type: 'ecc', - curve: 'curve25519Legacy', - userIDs: [{ name: 'Ada Lovelace', email }], - passphrase: 'correct horse battery', - format: 'armored' - }); - const key = await openpgp.readKey({ armoredKey: generated.publicKey }); - return { fingerprint: key.getFingerprint().toUpperCase(), armoredKey: key.armor() }; -} - -test('validates custom HTTPS key server configuration', () => { - assert.deepEqual(normalizeCustomServer({ - id: 'custom', - name: 'Internal server', - url: 'https://keys.example.org/openpgp', - protocol: 'hkp' - }), { - id: 'custom', - name: 'Internal server', - url: 'https://keys.example.org/openpgp/', - protocol: 'hkp', - builtin: false - }); - assert.throws(() => normalizeCustomServer({ name: 'Plain HTTP', url: 'http://keys.example.org', protocol: 'hkp' }), /HTTPS/); - assert.throws(() => normalizeCustomServer({ name: 'Credential URL', url: 'https://user:pass@keys.example.org', protocol: 'vks' }), /credentials/); - assert.throws(() => normalizeCustomServer({ name: 'Query URL', url: 'https://keys.example.org/?token=x', protocol: 'vks' }), /query/); - assert.throws(() => normalizeCustomServer({ name: 'Unknown protocol', url: 'https://keys.example.org', protocol: 'unknown' }), /protocol/); -}); - -test('all built-in and custom key servers start disabled', () => { - const servers = listServers([{ - id: 'custom', - name: 'Internal server', - url: 'https://keys.example.org', - protocol: 'hkp' - }]); - assert.equal(servers.length, 3); - assert.ok(servers.every(server => server.enabled === false)); - const enabled = listServers([], ['openpgp-vks']); - assert.equal(enabled.find(server => server.id === 'openpgp-vks').enabled, true); - assert.equal(enabled.find(server => server.id === 'mailvelope-hkp').enabled, false); -}); - -test('VKS lookup returns only valid keys matching the requested address', async () => { - const key = await makeKey(); - let requestedUrl; - const service = createKeyServerService({ - async fetchImpl(url, options) { - requestedUrl = new URL(url); - assert.equal(options.redirect, 'error'); - return new Response(key.armoredKey, { status: 200, headers: { 'content-type': 'application/pgp-keys' } }); - } - }); - const found = await service.lookup({ - id: 'openpgp-vks', - name: 'keys.openpgp.org', - url: 'https://keys.openpgp.org', - protocol: 'vks' - }, email); - assert.equal(requestedUrl.pathname, '/vks/v1/by-email/ada%40example.org'); - assert.equal(found.length, 1); - assert.equal(found[0].fingerprint, key.fingerprint); - assert.deepEqual(found[0].emails, [email]); -}); - -test('HKP lookup filters unrelated keys and reports an empty result', async () => { - const key = await makeKey(); - let requestedUrl; - const service = createKeyServerService({ - async fetchImpl(url) { - requestedUrl = new URL(url); - return new Response(`not a key\n${key.armoredKey}`, { status: 200 }); - } - }); - const server = { id: 'custom', name: 'Example', url: 'https://keys.example.org/base/', protocol: 'hkp' }; - const found = await service.lookup(server, email); - assert.equal(requestedUrl.pathname, '/base/pks/lookup'); - assert.equal(requestedUrl.searchParams.get('op'), 'get'); - assert.equal(requestedUrl.searchParams.get('search'), email); - assert.equal(found.length, 1); - assert.deepEqual(await service.lookup(server, 'other@example.org'), []); -}); - -test('enabled-server lookup checks every enabled server, merges duplicate keys and reports failures', async () => { - const key = await makeKey(); - const requested = []; - const service = createKeyServerService({ - async fetchImpl(url) { - const target = new URL(url); - requested.push(target.hostname); - if (target.hostname === 'broken.example.org') throw new Error('server unavailable'); - return new Response(key.armoredKey, { status: 200 }); - } - }); - const results = await service.lookupEnabled([ - { id: 'one', name: 'First', url: 'https://first.example.org', protocol: 'hkp', enabled: true }, - { id: 'two', name: 'Second', url: 'https://second.example.org', protocol: 'vks', enabled: true }, - { id: 'bad', name: 'Offline', url: 'https://broken.example.org', protocol: 'hkp', enabled: true }, - { id: 'off', name: 'Disabled', url: 'https://disabled.example.org', protocol: 'hkp', enabled: false } - ], email); - assert.deepEqual(requested.sort(), ['broken.example.org', 'first.example.org', 'second.example.org']); - assert.equal(results.keys.length, 1); - assert.deepEqual(results.keys[0].sources, ['First', 'Second']); - assert.deepEqual(results.errors.map(error => error.name), ['Offline']); - assert.deepEqual(results.searchedServers.map(server => server.name), ['First', 'Second', 'Offline']); - await assert.rejects(() => service.lookupEnabled([ - { id: 'off', name: 'Disabled', url: 'https://disabled.example.org', protocol: 'hkp', enabled: false } - ], email), /Enable at least one key server/); -}); - -test('VKS publication uploads only the public key and requests email verification', async () => { - const key = await makeKey(); - const calls = []; - const service = createKeyServerService({ - async fetchImpl(url, options) { - calls.push({ url: new URL(url), options }); - if (calls.length === 1) { - return Response.json({ - key_fpr: key.fingerprint, - token: 'temporary-upload-token', - status: { [email]: 'unpublished' } - }); - } - return Response.json({ key_fpr: key.fingerprint, token: 'temporary-upload-token', status: { [email]: 'pending' } }); - } - }); - const result = await service.publish({ - id: 'openpgp-vks', - name: 'keys.openpgp.org', - url: 'https://keys.openpgp.org', - protocol: 'vks' - }, email, key.armoredKey, key.fingerprint); - assert.equal(calls[0].url.pathname, '/vks/v1/upload'); - assert.equal(calls[1].url.pathname, '/vks/v1/request-verify'); - assert.equal(result.verification, 'pending'); - const upload = JSON.parse(calls[0].options.body); - assert.equal(upload.keytext, key.armoredKey); - assert.equal(upload.keytext.includes('PRIVATE KEY'), false); - assert.deepEqual(JSON.parse(calls[1].options.body).addresses, [email]); -}); - -test('HKP publication posts armored public material only', async () => { - const key = await makeKey(); - let requestInfo; - const service = createKeyServerService({ - async fetchImpl(url, options) { - requestInfo = { url: new URL(url), options }; - return new Response('Upload successful. Check your inbox to verify your email address.', { status: 200 }); - } - }); - const result = await service.publish({ - id: 'mailvelope-hkp', - name: 'keys.mailvelope.com', - url: 'https://keys.mailvelope.com', - protocol: 'hkp' - }, email, key.armoredKey, key.fingerprint); - assert.equal(requestInfo.url.pathname, '/pks/add'); - assert.equal(requestInfo.options.headers['content-type'], 'application/x-www-form-urlencoded'); - assert.equal(new URLSearchParams(requestInfo.options.body).get('keytext'), key.armoredKey); - assert.equal(requestInfo.options.body.includes('PRIVATE KEY'), false); - assert.equal(result.verification, 'check-email'); -}); - -test('key-server contact imports stay untrusted and retain keyserver provenance', async () => { - const key = await makeKey(); - const keyStore = createKeyStore(memoryStore()); - const added = await keyStore.addContact({ armoredKey: key.armoredKey, source: 'keyserver' }); - assert.equal(added.contact.trust, 'unknown'); - assert.equal(added.contact.source, 'keyserver'); -}); - -test('lookup rejects oversized responses and HTTP failures', async () => { - const server = { id: 'openpgp-vks', name: 'keys.openpgp.org', url: 'https://keys.openpgp.org', protocol: 'vks' }; - const tooLarge = createKeyServerService({ - async fetchImpl() { return new Response('x'.repeat(600001), { status: 200 }); } - }); - await assert.rejects(() => tooLarge.lookup(server, email), /too large/); - const failure = createKeyServerService({ - async fetchImpl() { return new Response('', { status: 503 }); } - }); - await assert.rejects(() => failure.lookup(server, email), /HTTP 503/); - const invalid = createKeyServerService({ - async fetchImpl() { return new Response('unexpected response', { status: 200 }); } - }); - await assert.rejects(() => invalid.lookup(server, email), /did not contain an OpenPGP public key/); -}); - -test('VKS verification failure reports that the key upload already succeeded', async () => { - const key = await makeKey(); - let calls = 0; - const service = createKeyServerService({ - async fetchImpl() { - calls += 1; - if (calls === 1) { - return Response.json({ - key_fpr: key.fingerprint, - token: 'temporary-upload-token', - status: { [email]: 'unpublished' } - }); - } - throw new Error('network unavailable'); - } - }); - const result = await service.publish({ - id: 'openpgp-vks', - name: 'keys.openpgp.org', - url: 'https://keys.openpgp.org', - protocol: 'vks' - }, email, key.armoredKey, key.fingerprint); - assert.equal(result.uploaded, true); - assert.equal(result.verification, 'request-failed'); - assert.match(result.warning, /key was uploaded/); -}); - -test('publication rejects a fingerprint that does not match the public key', async () => { - const key = await makeKey(); - const service = createKeyServerService({ - async fetchImpl() { throw new Error('unexpected network request'); } - }); - await assert.rejects(() => service.publish({ - id: 'mailvelope-hkp', - name: 'keys.mailvelope.com', - url: 'https://keys.mailvelope.com', - protocol: 'hkp' - }, email, key.armoredKey, '0'.repeat(40)), /does not match/); -}); +const test = require('node:test'); +const assert = require('node:assert/strict'); +const openpgp = require('openpgp'); +const { createKeyServerService, listServers, normalizeCustomServer } = require('../desktop/pgp-keyservers.cjs'); +const { createKeyStore } = require('../desktop/pgp-keystore.cjs'); + +const email = 'ada@example.org'; + +function memoryStore() { + let data = null; + return { + async load() { return data && JSON.parse(JSON.stringify(data)); }, + async save(value) { data = JSON.parse(JSON.stringify(value)); } + }; +} + +async function makeKey() { + const generated = await openpgp.generateKey({ + type: 'ecc', + curve: 'curve25519Legacy', + userIDs: [{ name: 'Ada Lovelace', email }], + passphrase: 'correct horse battery', + format: 'armored' + }); + const key = await openpgp.readKey({ armoredKey: generated.publicKey }); + return { fingerprint: key.getFingerprint().toUpperCase(), armoredKey: key.armor() }; +} + +test('validates custom HTTPS key server configuration', () => { + assert.deepEqual(normalizeCustomServer({ + id: 'custom', + name: 'Internal server', + url: 'https://keys.example.org/openpgp', + protocol: 'hkp' + }), { + id: 'custom', + name: 'Internal server', + url: 'https://keys.example.org/openpgp/', + protocol: 'hkp', + builtin: false + }); + assert.throws(() => normalizeCustomServer({ name: 'Plain HTTP', url: 'http://keys.example.org', protocol: 'hkp' }), /HTTPS/); + assert.throws(() => normalizeCustomServer({ name: 'Credential URL', url: 'https://user:pass@keys.example.org', protocol: 'vks' }), /credentials/); + assert.throws(() => normalizeCustomServer({ name: 'Query URL', url: 'https://keys.example.org/?token=x', protocol: 'vks' }), /query/); + assert.throws(() => normalizeCustomServer({ name: 'Unknown protocol', url: 'https://keys.example.org', protocol: 'unknown' }), /protocol/); +}); + +test('all built-in and custom key servers start disabled', () => { + const servers = listServers([{ + id: 'custom', + name: 'Internal server', + url: 'https://keys.example.org', + protocol: 'hkp' + }]); + assert.equal(servers.length, 3); + assert.ok(servers.every(server => server.enabled === false)); + const enabled = listServers([], ['openpgp-vks']); + assert.equal(enabled.find(server => server.id === 'openpgp-vks').enabled, true); + assert.equal(enabled.find(server => server.id === 'mailvelope-hkp').enabled, false); +}); + +test('VKS lookup returns only valid keys matching the requested address', async () => { + const key = await makeKey(); + let requestedUrl; + const service = createKeyServerService({ + async fetchImpl(url, options) { + requestedUrl = new URL(url); + assert.equal(options.redirect, 'error'); + return new Response(key.armoredKey, { status: 200, headers: { 'content-type': 'application/pgp-keys' } }); + } + }); + const found = await service.lookup({ + id: 'openpgp-vks', + name: 'keys.openpgp.org', + url: 'https://keys.openpgp.org', + protocol: 'vks' + }, email); + assert.equal(requestedUrl.pathname, '/vks/v1/by-email/ada%40example.org'); + assert.equal(found.length, 1); + assert.equal(found[0].fingerprint, key.fingerprint); + assert.deepEqual(found[0].emails, [email]); +}); + +test('HKP lookup filters unrelated keys and reports an empty result', async () => { + const key = await makeKey(); + let requestedUrl; + const service = createKeyServerService({ + async fetchImpl(url) { + requestedUrl = new URL(url); + return new Response(`not a key\n${key.armoredKey}`, { status: 200 }); + } + }); + const server = { id: 'custom', name: 'Example', url: 'https://keys.example.org/base/', protocol: 'hkp' }; + const found = await service.lookup(server, email); + assert.equal(requestedUrl.pathname, '/base/pks/lookup'); + assert.equal(requestedUrl.searchParams.get('op'), 'get'); + assert.equal(requestedUrl.searchParams.get('search'), email); + assert.equal(found.length, 1); + assert.deepEqual(await service.lookup(server, 'other@example.org'), []); +}); + +test('enabled-server lookup checks every enabled server, merges duplicate keys and reports failures', async () => { + const key = await makeKey(); + const requested = []; + const service = createKeyServerService({ + async fetchImpl(url) { + const target = new URL(url); + requested.push(target.hostname); + if (target.hostname === 'broken.example.org') throw new Error('server unavailable'); + return new Response(key.armoredKey, { status: 200 }); + } + }); + const results = await service.lookupEnabled([ + { id: 'one', name: 'First', url: 'https://first.example.org', protocol: 'hkp', enabled: true }, + { id: 'two', name: 'Second', url: 'https://second.example.org', protocol: 'vks', enabled: true }, + { id: 'bad', name: 'Offline', url: 'https://broken.example.org', protocol: 'hkp', enabled: true }, + { id: 'off', name: 'Disabled', url: 'https://disabled.example.org', protocol: 'hkp', enabled: false } + ], email); + assert.deepEqual(requested.sort(), ['broken.example.org', 'first.example.org', 'second.example.org']); + assert.equal(results.keys.length, 1); + assert.deepEqual(results.keys[0].sources, ['First', 'Second']); + assert.deepEqual(results.errors.map(error => error.name), ['Offline']); + assert.deepEqual(results.searchedServers.map(server => server.name), ['First', 'Second', 'Offline']); + await assert.rejects(() => service.lookupEnabled([ + { id: 'off', name: 'Disabled', url: 'https://disabled.example.org', protocol: 'hkp', enabled: false } + ], email), /Enable at least one key server/); +}); + +test('VKS publication uploads only the public key and requests email verification', async () => { + const key = await makeKey(); + const calls = []; + const service = createKeyServerService({ + async fetchImpl(url, options) { + calls.push({ url: new URL(url), options }); + if (calls.length === 1) { + return Response.json({ + key_fpr: key.fingerprint, + token: 'temporary-upload-token', + status: { [email]: 'unpublished' } + }); + } + return Response.json({ key_fpr: key.fingerprint, token: 'temporary-upload-token', status: { [email]: 'pending' } }); + } + }); + const result = await service.publish({ + id: 'openpgp-vks', + name: 'keys.openpgp.org', + url: 'https://keys.openpgp.org', + protocol: 'vks' + }, email, key.armoredKey, key.fingerprint); + assert.equal(calls[0].url.pathname, '/vks/v1/upload'); + assert.equal(calls[1].url.pathname, '/vks/v1/request-verify'); + assert.equal(result.verification, 'pending'); + const upload = JSON.parse(calls[0].options.body); + assert.equal(upload.keytext, key.armoredKey); + assert.equal(upload.keytext.includes('PRIVATE KEY'), false); + assert.deepEqual(JSON.parse(calls[1].options.body).addresses, [email]); +}); + +test('HKP publication posts armored public material only', async () => { + const key = await makeKey(); + let requestInfo; + const service = createKeyServerService({ + async fetchImpl(url, options) { + requestInfo = { url: new URL(url), options }; + return new Response('Upload successful. Check your inbox to verify your email address.', { status: 200 }); + } + }); + const result = await service.publish({ + id: 'mailvelope-hkp', + name: 'keys.mailvelope.com', + url: 'https://keys.mailvelope.com', + protocol: 'hkp' + }, email, key.armoredKey, key.fingerprint); + assert.equal(requestInfo.url.pathname, '/pks/add'); + assert.equal(requestInfo.options.headers['content-type'], 'application/x-www-form-urlencoded'); + assert.equal(new URLSearchParams(requestInfo.options.body).get('keytext'), key.armoredKey); + assert.equal(requestInfo.options.body.includes('PRIVATE KEY'), false); + assert.equal(result.verification, 'check-email'); +}); + +test('key-server contact imports stay untrusted and retain keyserver provenance', async () => { + const key = await makeKey(); + const keyStore = createKeyStore(memoryStore()); + const added = await keyStore.addContact({ armoredKey: key.armoredKey, source: 'keyserver' }); + assert.equal(added.contact.trust, 'unknown'); + assert.equal(added.contact.source, 'keyserver'); +}); + +test('lookup rejects oversized responses and HTTP failures', async () => { + const server = { id: 'openpgp-vks', name: 'keys.openpgp.org', url: 'https://keys.openpgp.org', protocol: 'vks' }; + const tooLarge = createKeyServerService({ + async fetchImpl() { return new Response('x'.repeat(600001), { status: 200 }); } + }); + await assert.rejects(() => tooLarge.lookup(server, email), /too large/); + const failure = createKeyServerService({ + async fetchImpl() { return new Response('', { status: 503 }); } + }); + await assert.rejects(() => failure.lookup(server, email), /HTTP 503/); + const invalid = createKeyServerService({ + async fetchImpl() { return new Response('unexpected response', { status: 200 }); } + }); + await assert.rejects(() => invalid.lookup(server, email), /did not contain an OpenPGP public key/); +}); + +test('VKS verification failure reports that the key upload already succeeded', async () => { + const key = await makeKey(); + let calls = 0; + const service = createKeyServerService({ + async fetchImpl() { + calls += 1; + if (calls === 1) { + return Response.json({ + key_fpr: key.fingerprint, + token: 'temporary-upload-token', + status: { [email]: 'unpublished' } + }); + } + throw new Error('network unavailable'); + } + }); + const result = await service.publish({ + id: 'openpgp-vks', + name: 'keys.openpgp.org', + url: 'https://keys.openpgp.org', + protocol: 'vks' + }, email, key.armoredKey, key.fingerprint); + assert.equal(result.uploaded, true); + assert.equal(result.verification, 'request-failed'); + assert.match(result.warning, /key was uploaded/); +}); + +test('publication rejects a fingerprint that does not match the public key', async () => { + const key = await makeKey(); + const service = createKeyServerService({ + async fetchImpl() { throw new Error('unexpected network request'); } + }); + await assert.rejects(() => service.publish({ + id: 'mailvelope-hkp', + name: 'keys.mailvelope.com', + url: 'https://keys.mailvelope.com', + protocol: 'hkp' + }, email, key.armoredKey, '0'.repeat(40)), /does not match/); +}); diff --git a/tests/pgp-keystore.test.cjs b/tests/pgp-keystore.test.cjs index 07d82fe..aed64e3 100644 --- a/tests/pgp-keystore.test.cjs +++ b/tests/pgp-keystore.test.cjs @@ -1,123 +1,123 @@ -const test = require('node:test'); -const assert = require('node:assert/strict'); -const openpgp = require('openpgp'); -const { createKeyStore } = require('../desktop/pgp-keystore.cjs'); - -function memoryStore() { - let data = null; - return { load: async () => data, save: async value => { data = JSON.parse(JSON.stringify(value)); } }; -} - -const passphrase = 'correct horse battery'; - -test('generates a passphrase-protected key and never lists secrets', async () => { - const storage = memoryStore(); - const keys = createKeyStore(storage); - const { key, revocationCertificate } = await keys.generate({ name: 'Ada', email: 'ada@example.com', passphrase }); - assert.match(key.fingerprint, /^[0-9A-F]{40,64}$/); - assert.ok(revocationCertificate.includes('BEGIN PGP PUBLIC KEY BLOCK')); - const listed = await keys.list(); - assert.equal(listed.length, 1); - assert.equal(JSON.stringify(listed).includes('PRIVATE'), false); - const stored = (await storage.load()).keys[0]; - const parsed = await openpgp.readPrivateKey({ armoredKey: stored.privateKey }); - assert.equal(parsed.isDecrypted(), false); -}); - -test('rejects weak passphrases and bad addresses', async () => { - const keys = createKeyStore(memoryStore()); - await assert.rejects(keys.generate({ name: 'A', email: 'a@example.com', passphrase: 'short' }), /at least 8/); - await assert.rejects(keys.generate({ name: 'A', email: 'nope', passphrase }), /valid email/); -}); - -test('export requires the right passphrase and round-trips through import', async () => { - const first = createKeyStore(memoryStore()); - const { key } = await first.generate({ name: 'Ada', email: 'ada@example.com', passphrase }); - await assert.rejects(first.exportPrivate(key.fingerprint, 'wrong passphrase'), /incorrect/); - const armored = await first.exportPrivate(key.fingerprint, passphrase); - const second = createKeyStore(memoryStore()); - const imported = await second.import({ armoredKey: armored, passphrase }); - assert.equal(imported.fingerprint, key.fingerprint); - assert.equal(imported.email, 'ada@example.com'); - await assert.rejects(second.import({ armoredKey: armored, passphrase }), /already/); - assert.ok((await second.exportPublic(key.fingerprint)).includes('BEGIN PGP PUBLIC KEY BLOCK')); -}); - -test('changes a key passphrase without changing its public identity or revocation certificate', async () => { - const storage = memoryStore(); - const keys = createKeyStore(storage); - const { key, revocationCertificate } = await keys.generate({ name: 'Ada', email: 'ada@example.com', passphrase }); - const original = JSON.parse(JSON.stringify((await storage.load()).keys[0])); - const newPassphrase = 'new passphrase securely'; - - await assert.rejects(keys.changePassphrase(key.fingerprint, 'wrong passphrase', newPassphrase), /incorrect/); - await assert.rejects(keys.changePassphrase(key.fingerprint, passphrase, 'short'), /at least 8/); - assert.deepEqual((await storage.load()).keys[0], original); - - assert.deepEqual(await keys.changePassphrase(key.fingerprint, passphrase, newPassphrase), { changed: true }); - const changed = (await storage.load()).keys[0]; - assert.equal(changed.fingerprint, original.fingerprint); - assert.equal(changed.publicKey, original.publicKey); - assert.equal(changed.name, original.name); - assert.equal(changed.email, original.email); - assert.equal(changed.accountId, original.accountId); - assert.equal(changed.createdAt, original.createdAt); - assert.equal(changed.algorithm, original.algorithm); - assert.equal(changed.revocationCertificate, original.revocationCertificate); - assert.notEqual(changed.privateKey, original.privateKey); - await assert.rejects(keys.exportPrivate(key.fingerprint, passphrase), /incorrect/); - assert.equal(await keys.exportPrivate(key.fingerprint, newPassphrase), changed.privateKey); - assert.equal(await keys.exportRevocation(key.fingerprint, newPassphrase), revocationCertificate); -}); - -test('does not mutate the loaded key if saving a changed passphrase fails', async () => { - let data = null; - let failSave = false; - const storage = { - load: async () => data, - save: async value => { - if (failSave) throw new Error('Storage unavailable.'); - data = JSON.parse(JSON.stringify(value)); - } - }; - const keys = createKeyStore(storage); - const { key } = await keys.generate({ name: 'Ada', email: 'ada@example.com', passphrase }); - const original = JSON.parse(JSON.stringify(data.keys[0])); - failSave = true; - - await assert.rejects(keys.changePassphrase(key.fingerprint, passphrase, 'new passphrase securely'), /Storage unavailable/); - assert.deepEqual(data.keys[0], original); -}); - -test('imports an unprotected key by encrypting it with the given passphrase', async () => { - const { privateKey } = await openpgp.generateKey({ type: 'curve25519', userIDs: [{ email: 'bob@example.com' }], format: 'armored' }); - const keys = createKeyStore(memoryStore()); - const imported = await keys.import({ armoredKey: privateKey, passphrase }); - const exported = await keys.exportPrivate(imported.fingerprint, passphrase); - assert.equal((await openpgp.readPrivateKey({ armoredKey: exported })).isDecrypted(), false); -}); - -test('rejects invalid key material and a wrong passphrase on import', async () => { - const keys = createKeyStore(memoryStore()); - await assert.rejects(keys.import({ armoredKey: 'not a key', passphrase }), /valid OpenPGP/); - const source = createKeyStore(memoryStore()); - const { key } = await source.generate({ name: 'C', email: 'c@example.com', passphrase }); - const armored = await source.exportPrivate(key.fingerprint, passphrase); - await assert.rejects(keys.import({ armoredKey: armored, passphrase: 'another passphrase' }), /incorrect/); -}); - -test('deleting a key needs the passphrase', async () => { - const keys = createKeyStore(memoryStore()); - const { key } = await keys.generate({ name: 'D', email: 'd@example.com', passphrase }); - await assert.rejects(keys.remove(key.fingerprint, 'wrong passphrase'), /incorrect/); - assert.equal((await keys.list()).length, 1); - await keys.remove(key.fingerprint, passphrase); - assert.equal((await keys.list()).length, 0); -}); - -test('stored revocation certificate is returned only after unlocking', async () => { - const keys = createKeyStore(memoryStore()); - const { key } = await keys.generate({ name: 'E', email: 'e@example.com', passphrase }); - await assert.rejects(keys.exportRevocation(key.fingerprint, 'wrong passphrase'), /incorrect/); - assert.ok((await keys.exportRevocation(key.fingerprint, passphrase)).includes('BEGIN PGP PUBLIC KEY BLOCK')); -}); +const test = require('node:test'); +const assert = require('node:assert/strict'); +const openpgp = require('openpgp'); +const { createKeyStore } = require('../desktop/pgp-keystore.cjs'); + +function memoryStore() { + let data = null; + return { load: async () => data, save: async value => { data = JSON.parse(JSON.stringify(value)); } }; +} + +const passphrase = 'correct horse battery'; + +test('generates a passphrase-protected key and never lists secrets', async () => { + const storage = memoryStore(); + const keys = createKeyStore(storage); + const { key, revocationCertificate } = await keys.generate({ name: 'Ada', email: 'ada@example.com', passphrase }); + assert.match(key.fingerprint, /^[0-9A-F]{40,64}$/); + assert.ok(revocationCertificate.includes('BEGIN PGP PUBLIC KEY BLOCK')); + const listed = await keys.list(); + assert.equal(listed.length, 1); + assert.equal(JSON.stringify(listed).includes('PRIVATE'), false); + const stored = (await storage.load()).keys[0]; + const parsed = await openpgp.readPrivateKey({ armoredKey: stored.privateKey }); + assert.equal(parsed.isDecrypted(), false); +}); + +test('rejects weak passphrases and bad addresses', async () => { + const keys = createKeyStore(memoryStore()); + await assert.rejects(keys.generate({ name: 'A', email: 'a@example.com', passphrase: 'short' }), /at least 8/); + await assert.rejects(keys.generate({ name: 'A', email: 'nope', passphrase }), /valid email/); +}); + +test('export requires the right passphrase and round-trips through import', async () => { + const first = createKeyStore(memoryStore()); + const { key } = await first.generate({ name: 'Ada', email: 'ada@example.com', passphrase }); + await assert.rejects(first.exportPrivate(key.fingerprint, 'wrong passphrase'), /incorrect/); + const armored = await first.exportPrivate(key.fingerprint, passphrase); + const second = createKeyStore(memoryStore()); + const imported = await second.import({ armoredKey: armored, passphrase }); + assert.equal(imported.fingerprint, key.fingerprint); + assert.equal(imported.email, 'ada@example.com'); + await assert.rejects(second.import({ armoredKey: armored, passphrase }), /already/); + assert.ok((await second.exportPublic(key.fingerprint)).includes('BEGIN PGP PUBLIC KEY BLOCK')); +}); + +test('changes a key passphrase without changing its public identity or revocation certificate', async () => { + const storage = memoryStore(); + const keys = createKeyStore(storage); + const { key, revocationCertificate } = await keys.generate({ name: 'Ada', email: 'ada@example.com', passphrase }); + const original = JSON.parse(JSON.stringify((await storage.load()).keys[0])); + const newPassphrase = 'new passphrase securely'; + + await assert.rejects(keys.changePassphrase(key.fingerprint, 'wrong passphrase', newPassphrase), /incorrect/); + await assert.rejects(keys.changePassphrase(key.fingerprint, passphrase, 'short'), /at least 8/); + assert.deepEqual((await storage.load()).keys[0], original); + + assert.deepEqual(await keys.changePassphrase(key.fingerprint, passphrase, newPassphrase), { changed: true }); + const changed = (await storage.load()).keys[0]; + assert.equal(changed.fingerprint, original.fingerprint); + assert.equal(changed.publicKey, original.publicKey); + assert.equal(changed.name, original.name); + assert.equal(changed.email, original.email); + assert.equal(changed.accountId, original.accountId); + assert.equal(changed.createdAt, original.createdAt); + assert.equal(changed.algorithm, original.algorithm); + assert.equal(changed.revocationCertificate, original.revocationCertificate); + assert.notEqual(changed.privateKey, original.privateKey); + await assert.rejects(keys.exportPrivate(key.fingerprint, passphrase), /incorrect/); + assert.equal(await keys.exportPrivate(key.fingerprint, newPassphrase), changed.privateKey); + assert.equal(await keys.exportRevocation(key.fingerprint, newPassphrase), revocationCertificate); +}); + +test('does not mutate the loaded key if saving a changed passphrase fails', async () => { + let data = null; + let failSave = false; + const storage = { + load: async () => data, + save: async value => { + if (failSave) throw new Error('Storage unavailable.'); + data = JSON.parse(JSON.stringify(value)); + } + }; + const keys = createKeyStore(storage); + const { key } = await keys.generate({ name: 'Ada', email: 'ada@example.com', passphrase }); + const original = JSON.parse(JSON.stringify(data.keys[0])); + failSave = true; + + await assert.rejects(keys.changePassphrase(key.fingerprint, passphrase, 'new passphrase securely'), /Storage unavailable/); + assert.deepEqual(data.keys[0], original); +}); + +test('imports an unprotected key by encrypting it with the given passphrase', async () => { + const { privateKey } = await openpgp.generateKey({ type: 'curve25519', userIDs: [{ email: 'bob@example.com' }], format: 'armored' }); + const keys = createKeyStore(memoryStore()); + const imported = await keys.import({ armoredKey: privateKey, passphrase }); + const exported = await keys.exportPrivate(imported.fingerprint, passphrase); + assert.equal((await openpgp.readPrivateKey({ armoredKey: exported })).isDecrypted(), false); +}); + +test('rejects invalid key material and a wrong passphrase on import', async () => { + const keys = createKeyStore(memoryStore()); + await assert.rejects(keys.import({ armoredKey: 'not a key', passphrase }), /valid OpenPGP/); + const source = createKeyStore(memoryStore()); + const { key } = await source.generate({ name: 'C', email: 'c@example.com', passphrase }); + const armored = await source.exportPrivate(key.fingerprint, passphrase); + await assert.rejects(keys.import({ armoredKey: armored, passphrase: 'another passphrase' }), /incorrect/); +}); + +test('deleting a key needs the passphrase', async () => { + const keys = createKeyStore(memoryStore()); + const { key } = await keys.generate({ name: 'D', email: 'd@example.com', passphrase }); + await assert.rejects(keys.remove(key.fingerprint, 'wrong passphrase'), /incorrect/); + assert.equal((await keys.list()).length, 1); + await keys.remove(key.fingerprint, passphrase); + assert.equal((await keys.list()).length, 0); +}); + +test('stored revocation certificate is returned only after unlocking', async () => { + const keys = createKeyStore(memoryStore()); + const { key } = await keys.generate({ name: 'E', email: 'e@example.com', passphrase }); + await assert.rejects(keys.exportRevocation(key.fingerprint, 'wrong passphrase'), /incorrect/); + assert.ok((await keys.exportRevocation(key.fingerprint, passphrase)).includes('BEGIN PGP PUBLIC KEY BLOCK')); +}); diff --git a/tests/pgp-mail.test.cjs b/tests/pgp-mail.test.cjs index 39a506b..37639d2 100644 --- a/tests/pgp-mail.test.cjs +++ b/tests/pgp-mail.test.cjs @@ -1,216 +1,216 @@ -const test = require('node:test'); -const assert = require('node:assert/strict'); -const openpgp = require('openpgp'); -const MailComposer = require('nodemailer/lib/mail-composer'); -const { simpleParser } = require('mailparser'); -const { createKeyStore } = require('../desktop/pgp-keystore.cjs'); -const { createPgpMail, createPassphraseCache, detect } = require('../desktop/pgp-mail.cjs'); - -function memoryStore() { - let data = null; - return { async load() { return data && JSON.parse(JSON.stringify(data)); }, async save(value) { data = JSON.parse(JSON.stringify(value)); } }; -} - -async function actor(name, email, passphrase = 'correct horse') { - const keyStore = createKeyStore(memoryStore()); - const cache = createPassphraseCache(async () => 10); - const mail = createPgpMail({ keyStore, cache }); - const { key } = await keyStore.generate({ name, email, passphrase }); - return { keyStore, cache, mail, key, email, passphrase, name }; -} - -async function exchange(a, b) { - await a.keyStore.addContact({ armoredKey: await b.keyStore.exportPublic(b.key.fingerprint) }); - await b.keyStore.addContact({ armoredKey: await a.keyStore.exportPublic(a.key.fingerprint) }); -} - -const sendOptions = (from, to, extra = {}) => ({ - from: { name: from.name, address: from.email }, to, subject: 'Héllo secrèt', text: 'Top secret ✓\nline two', messageId: '', ...extra -}); - -test('encrypts and signs for a recipient and the sender can read the copy', async () => { - const alice = await actor('Alice', 'alice@example.com'); - const bob = await actor('Bob', 'bob@example.com'); - await exchange(alice, bob); - const { raw, envelope } = await alice.mail.build(sendOptions(alice, 'Bob ', { encrypt: true, sign: true, passphrase: alice.passphrase })); - assert.deepEqual(envelope.to, ['bob@example.com']); - assert.ok(!raw.toString('latin1').includes('Top secret')); - const parsed = await simpleParser(raw); - assert.equal(parsed.subject, 'Héllo secrèt'); - 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, { passphrase: 'wrong wrong' }), error => error.code === 'BAD_PASSPHRASE'); - const result = await bob.mail.decrypt(parsed, { passphrase: bob.passphrase }); - assert.equal(result.parsed.text.trim(), 'Top secret ✓\nline two'); - assert.equal(result.signatures[0].status, 'valid'); - assert.equal(result.signatures[0].matchesSender, true); - const again = await bob.mail.decrypt(await simpleParser(raw)); - assert.equal(again.signatures.length, 1); - const own = await alice.mail.decrypt(parsed, { passphrase: alice.passphrase }); - assert.match(own.parsed.text, /Top secret/); -}); - -test('refuses to encrypt without a recipient key instead of downgrading', async () => { - const alice = await actor('Alice', 'alice@example.com'); - await assert.rejects( - () => alice.mail.build(sendOptions(alice, 'carol@example.com', { encrypt: true })), - error => error.code === 'NO_RECIPIENT_KEY' && error.details.missing[0] === 'carol@example.com' - ); - const status = await alice.mail.recipientStatus(['carol@example.com'], { sign: true, from: 'alice@example.com' }); - assert.deepEqual(status.missing, ['carol@example.com']); - assert.equal(status.signer.email, 'alice@example.com'); -}); - -test('encrypts to several recipients and each can decrypt', async () => { - const alice = await actor('Alice', 'alice@example.com'); - const bob = await actor('Bob', 'bob@example.com'); - const carol = await actor('Carol', 'carol@example.com'); - for (const other of [bob, carol]) await alice.keyStore.addContact({ armoredKey: await other.keyStore.exportPublic(other.key.fingerprint) }); - const { raw } = await alice.mail.build(sendOptions(alice, 'bob@example.com', { cc: 'carol@example.com', encrypt: true })); - const parsed = await simpleParser(raw); - for (const reader of [bob, carol]) { - const result = await reader.mail.decrypt(parsed, { passphrase: reader.passphrase }); - assert.match(result.parsed.text, /Top secret/); - assert.equal(result.signatures.length, 0); - } -}); - -test('encrypts and signs outgoing attachments with the message body', async () => { - const alice = await actor('Alice', 'alice@example.com'); - const bob = await actor('Bob', 'bob@example.com'); - await exchange(alice, bob); - const contents = Buffer.from([0, 1, 2, 127, 128, 255]); - const { raw } = await alice.mail.build(sendOptions(alice, 'bob@example.com', { - encrypt: true, - sign: true, - passphrase: alice.passphrase, - attachments: [{ filename: 'binary-data.bin', contentType: 'application/octet-stream', content: contents }] - })); - assert.ok(!raw.toString('latin1').includes(contents.toString('latin1'))); - - const parsed = await simpleParser(raw); - const decrypted = await bob.mail.decrypt(parsed, { passphrase: bob.passphrase }); - assert.equal(decrypted.parsed.text.trim(), 'Top secret ✓\nline two'); - assert.equal(decrypted.parsed.attachments.length, 1); - assert.equal(decrypted.parsed.attachments[0].filename, 'binary-data.bin'); - assert.equal(decrypted.parsed.attachments[0].contentType, 'application/octet-stream'); - assert.deepEqual(decrypted.parsed.attachments[0].content, contents); - assert.equal(decrypted.signatures[0].status, 'valid'); -}); - -test('detects tampered and corrupted encrypted messages', async () => { - const alice = await actor('Alice', 'alice@example.com'); - const bob = await actor('Bob', 'bob@example.com'); - await exchange(alice, bob); - const { raw } = await alice.mail.build(sendOptions(alice, 'bob@example.com', { encrypt: true, sign: true, passphrase: alice.passphrase })); - const text = raw.toString('latin1'); - const lines = text.split('\r\n'); - const at = lines.findIndex((line, index) => index > 5 && line.length >= 60 && !line.startsWith('-') && !line.includes(':')); - lines[at] = lines[at].slice(0, 20) + (lines[at][20] === 'A' ? 'B' : 'A') + lines[at].slice(21); - const broken = await simpleParser(Buffer.from(lines.join('\r\n'), 'latin1')); - await assert.rejects(() => bob.mail.decrypt(broken, { passphrase: bob.passphrase }), error => ['CORRUPT'].includes(error.code)); - const empty = await simpleParser(Buffer.from(text.replace(/-----BEGIN PGP MESSAGE-----[\s\S]*-----END PGP MESSAGE-----/, 'nothing'), 'latin1')); - await assert.rejects(() => bob.mail.decrypt(empty), error => error.code === 'CORRUPT'); -}); - -test('reports unknown signers and a changed key for a known sender', async () => { - const alice = await actor('Alice', 'alice@example.com'); - const bob = await actor('Bob', 'bob@example.com'); - await bob.keyStore.addContact({ armoredKey: await alice.keyStore.exportPublic(alice.key.fingerprint) }); - await alice.keyStore.addContact({ armoredKey: await bob.keyStore.exportPublic(bob.key.fingerprint) }); - const impostor = await actor('Alice', 'alice@example.com'); - await impostor.keyStore.addContact({ armoredKey: await bob.keyStore.exportPublic(bob.key.fingerprint) }); - const { raw } = await impostor.mail.build(sendOptions(impostor, 'bob@example.com', { encrypt: true, sign: true, passphrase: impostor.passphrase })); - const result = await bob.mail.decrypt(await simpleParser(raw), { passphrase: bob.passphrase }); - assert.equal(result.signatures[0].status, 'unknown-key'); - assert.equal(result.signatures[0].keyChanged, true); - const added = await bob.keyStore.addContact({ armoredKey: await impostor.keyStore.exportPublic(impostor.key.fingerprint) }); - assert.deepEqual(added.keyChangedFrom, [alice.key.fingerprint]); - const second = await bob.mail.decrypt(await simpleParser(raw)); - assert.equal(second.signatures[0].status, 'valid'); - assert.equal(second.signatures[0].keyChanged, false); -}); - -test('signs without encrypting and verifies PGP/MIME signatures', async () => { - const alice = await actor('Alice', 'alice@example.com'); - const bob = await actor('Bob', 'bob@example.com'); - await bob.keyStore.addContact({ armoredKey: await alice.keyStore.exportPublic(alice.key.fingerprint) }); - const attachment = Buffer.from('signed attachment data'); - const { raw } = await alice.mail.build(sendOptions(alice, 'bob@example.com', { - sign: true, - passphrase: alice.passphrase, - attachments: [{ filename: 'signed.txt', contentType: 'text/plain', content: attachment }] - })); - const parsed = await simpleParser(raw); - assert.equal(detect(parsed), 'signed-mime'); - assert.match(parsed.text, /Top secret/); - assert.deepEqual(parsed.attachments[0].content, attachment); - const [signature] = await bob.mail.verifySigned(parsed, raw); - assert.equal(signature.status, 'valid'); - const altered = Buffer.from(raw.toString('latin1').replace('Content-Type: text/plain', 'Content-Type: text/plain'), 'latin1'); - const [bad] = await bob.mail.verifySigned(await simpleParser(altered), altered); - assert.equal(bad.status, 'invalid'); -}); - -test('reads inline PGP messages and cleartext signatures', async () => { - const alice = await actor('Alice', 'alice@example.com'); - const bob = await actor('Bob', 'bob@example.com'); - await exchange(alice, bob); - const bobKey = (await openpgp.readKey({ armoredKey: await bob.keyStore.exportPublic(bob.key.fingerprint) })); - const armored = await openpgp.encrypt({ message: await openpgp.createMessage({ text: 'inline body' }), encryptionKeys: bobKey }); - const source = Buffer.from(`From: Alice \r\nTo: bob@example.com\r\nSubject: inline\r\nContent-Type: text/plain\r\n\r\n${armored}\r\n`); - const parsed = await simpleParser(source); - assert.equal(detect(parsed), 'encrypted-inline'); - const result = await bob.mail.decrypt(parsed, { passphrase: bob.passphrase }); - assert.equal(result.parsed.text.trim(), 'inline body'); - const aliceSigner = await alice.keyStore.unlockKey(alice.key.fingerprint, alice.passphrase); - const cleartext = await openpgp.sign({ message: await openpgp.createCleartextMessage({ text: 'hello signed' }), signingKeys: aliceSigner }); - const signedSource = Buffer.from(`From: alice@example.com\r\nSubject: s\r\nContent-Type: text/plain\r\n\r\n${cleartext}\r\n`); - const signedParsed = await simpleParser(signedSource); - assert.equal(detect(signedParsed), 'signed-inline'); - assert.equal((await bob.mail.verifySigned(signedParsed, signedSource))[0].status, 'valid'); -}); - -test('decrypts large messages with attachments from other clients', async () => { - const alice = await actor('Alice', 'alice@example.com'); - const bob = await actor('Bob', 'bob@example.com'); - const inner = await new Promise((resolve, reject) => new MailComposer({ - text: 'with attachment', attachments: [{ filename: 'big.bin', content: Buffer.alloc(8 * 1048576, 7) }] - }).compile().build((error, message) => error ? reject(error) : resolve(message))); - const bobKey = await openpgp.readKey({ armoredKey: await bob.keyStore.exportPublic(bob.key.fingerprint) }); - const armored = await openpgp.encrypt({ message: await openpgp.createMessage({ binary: inner }), encryptionKeys: bobKey }); - const source = Buffer.from(`From: alice@example.com\r\nTo: bob@example.com\r\nSubject: big\r\nMIME-Version: 1.0\r\nContent-Type: multipart/encrypted; protocol="application/pgp-encrypted"; boundary="b1"\r\n\r\n--b1\r\nContent-Type: application/pgp-encrypted\r\n\r\nVersion: 1\r\n\r\n--b1\r\nContent-Type: application/octet-stream\r\n\r\n${armored}\r\n--b1--\r\n`); - const result = await bob.mail.decrypt(await simpleParser(source), { passphrase: bob.passphrase }); - assert.equal(result.parsed.attachments[0].filename, 'big.bin'); - assert.equal(result.parsed.attachments[0].content.length, 8 * 1048576); -}); - -test('keyring: contacts, trust levels, expired passphrase cache and settings', async () => { - const alice = await actor('Alice', 'alice@example.com'); - const bob = await actor('Bob', 'bob@example.com'); - const { contact } = await alice.keyStore.addContact({ armoredKey: await bob.keyStore.exportPublic(bob.key.fingerprint), source: 'message' }); - assert.equal(contact.trust, 'unknown'); - assert.equal((await alice.keyStore.setTrust(contact.fingerprint, 'verified')).trust, 'verified'); - await assert.rejects(() => alice.keyStore.setTrust(contact.fingerprint, 'bogus')); - 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(() => alice.keyStore.addContact({ armoredKey: 'junk' }), /valid OpenPGP/); - assert.deepEqual(await alice.keyStore.getSettings(), { cacheMinutes: 10, customKeyServers: [], enabledKeyServers: [] }); - 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'] }); - assert.equal((await alice.keyStore.getSettings()).cacheMinutes, 0); - await alice.keyStore.setSettings({ cacheMinutes: 5 }); - assert.deepEqual((await alice.keyStore.getSettings()).customKeyServers, [customServer]); - assert.deepEqual((await alice.keyStore.getSettings()).enabledKeyServers, ['custom', 'openpgp-vks']); - await alice.keyStore.setSettings({ cacheMinutes: 5, enabledKeyServers: [] }); - assert.deepEqual((await alice.keyStore.getSettings()).enabledKeyServers, []); - await alice.keyStore.removeContact(contact.fingerprint); - assert.equal((await alice.keyStore.listContacts()).length, 0); - - let clock = 1000; - const cache = createPassphraseCache(async () => 1, () => clock); - await cache.remember('F', 'secret'); - assert.equal(cache.get('F'), 'secret'); - clock += 61000; - assert.equal(cache.get('F'), null); -}); +const test = require('node:test'); +const assert = require('node:assert/strict'); +const openpgp = require('openpgp'); +const MailComposer = require('nodemailer/lib/mail-composer'); +const { simpleParser } = require('mailparser'); +const { createKeyStore } = require('../desktop/pgp-keystore.cjs'); +const { createPgpMail, createPassphraseCache, detect } = require('../desktop/pgp-mail.cjs'); + +function memoryStore() { + let data = null; + return { async load() { return data && JSON.parse(JSON.stringify(data)); }, async save(value) { data = JSON.parse(JSON.stringify(value)); } }; +} + +async function actor(name, email, passphrase = 'correct horse') { + const keyStore = createKeyStore(memoryStore()); + const cache = createPassphraseCache(async () => 10); + const mail = createPgpMail({ keyStore, cache }); + const { key } = await keyStore.generate({ name, email, passphrase }); + return { keyStore, cache, mail, key, email, passphrase, name }; +} + +async function exchange(a, b) { + await a.keyStore.addContact({ armoredKey: await b.keyStore.exportPublic(b.key.fingerprint) }); + await b.keyStore.addContact({ armoredKey: await a.keyStore.exportPublic(a.key.fingerprint) }); +} + +const sendOptions = (from, to, extra = {}) => ({ + from: { name: from.name, address: from.email }, to, subject: 'Héllo secrèt', text: 'Top secret ✓\nline two', messageId: '', ...extra +}); + +test('encrypts and signs for a recipient and the sender can read the copy', async () => { + const alice = await actor('Alice', 'alice@example.com'); + const bob = await actor('Bob', 'bob@example.com'); + await exchange(alice, bob); + const { raw, envelope } = await alice.mail.build(sendOptions(alice, 'Bob ', { encrypt: true, sign: true, passphrase: alice.passphrase })); + assert.deepEqual(envelope.to, ['bob@example.com']); + assert.ok(!raw.toString('latin1').includes('Top secret')); + const parsed = await simpleParser(raw); + assert.equal(parsed.subject, 'Héllo secrèt'); + 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, { passphrase: 'wrong wrong' }), error => error.code === 'BAD_PASSPHRASE'); + const result = await bob.mail.decrypt(parsed, { passphrase: bob.passphrase }); + assert.equal(result.parsed.text.trim(), 'Top secret ✓\nline two'); + assert.equal(result.signatures[0].status, 'valid'); + assert.equal(result.signatures[0].matchesSender, true); + const again = await bob.mail.decrypt(await simpleParser(raw)); + assert.equal(again.signatures.length, 1); + const own = await alice.mail.decrypt(parsed, { passphrase: alice.passphrase }); + assert.match(own.parsed.text, /Top secret/); +}); + +test('refuses to encrypt without a recipient key instead of downgrading', async () => { + const alice = await actor('Alice', 'alice@example.com'); + await assert.rejects( + () => alice.mail.build(sendOptions(alice, 'carol@example.com', { encrypt: true })), + error => error.code === 'NO_RECIPIENT_KEY' && error.details.missing[0] === 'carol@example.com' + ); + const status = await alice.mail.recipientStatus(['carol@example.com'], { sign: true, from: 'alice@example.com' }); + assert.deepEqual(status.missing, ['carol@example.com']); + assert.equal(status.signer.email, 'alice@example.com'); +}); + +test('encrypts to several recipients and each can decrypt', async () => { + const alice = await actor('Alice', 'alice@example.com'); + const bob = await actor('Bob', 'bob@example.com'); + const carol = await actor('Carol', 'carol@example.com'); + for (const other of [bob, carol]) await alice.keyStore.addContact({ armoredKey: await other.keyStore.exportPublic(other.key.fingerprint) }); + const { raw } = await alice.mail.build(sendOptions(alice, 'bob@example.com', { cc: 'carol@example.com', encrypt: true })); + const parsed = await simpleParser(raw); + for (const reader of [bob, carol]) { + const result = await reader.mail.decrypt(parsed, { passphrase: reader.passphrase }); + assert.match(result.parsed.text, /Top secret/); + assert.equal(result.signatures.length, 0); + } +}); + +test('encrypts and signs outgoing attachments with the message body', async () => { + const alice = await actor('Alice', 'alice@example.com'); + const bob = await actor('Bob', 'bob@example.com'); + await exchange(alice, bob); + const contents = Buffer.from([0, 1, 2, 127, 128, 255]); + const { raw } = await alice.mail.build(sendOptions(alice, 'bob@example.com', { + encrypt: true, + sign: true, + passphrase: alice.passphrase, + attachments: [{ filename: 'binary-data.bin', contentType: 'application/octet-stream', content: contents }] + })); + assert.ok(!raw.toString('latin1').includes(contents.toString('latin1'))); + + const parsed = await simpleParser(raw); + const decrypted = await bob.mail.decrypt(parsed, { passphrase: bob.passphrase }); + assert.equal(decrypted.parsed.text.trim(), 'Top secret ✓\nline two'); + assert.equal(decrypted.parsed.attachments.length, 1); + assert.equal(decrypted.parsed.attachments[0].filename, 'binary-data.bin'); + assert.equal(decrypted.parsed.attachments[0].contentType, 'application/octet-stream'); + assert.deepEqual(decrypted.parsed.attachments[0].content, contents); + assert.equal(decrypted.signatures[0].status, 'valid'); +}); + +test('detects tampered and corrupted encrypted messages', async () => { + const alice = await actor('Alice', 'alice@example.com'); + const bob = await actor('Bob', 'bob@example.com'); + await exchange(alice, bob); + const { raw } = await alice.mail.build(sendOptions(alice, 'bob@example.com', { encrypt: true, sign: true, passphrase: alice.passphrase })); + const text = raw.toString('latin1'); + const lines = text.split('\r\n'); + const at = lines.findIndex((line, index) => index > 5 && line.length >= 60 && !line.startsWith('-') && !line.includes(':')); + lines[at] = lines[at].slice(0, 20) + (lines[at][20] === 'A' ? 'B' : 'A') + lines[at].slice(21); + const broken = await simpleParser(Buffer.from(lines.join('\r\n'), 'latin1')); + await assert.rejects(() => bob.mail.decrypt(broken, { passphrase: bob.passphrase }), error => ['CORRUPT'].includes(error.code)); + const empty = await simpleParser(Buffer.from(text.replace(/-----BEGIN PGP MESSAGE-----[\s\S]*-----END PGP MESSAGE-----/, 'nothing'), 'latin1')); + await assert.rejects(() => bob.mail.decrypt(empty), error => error.code === 'CORRUPT'); +}); + +test('reports unknown signers and a changed key for a known sender', async () => { + const alice = await actor('Alice', 'alice@example.com'); + const bob = await actor('Bob', 'bob@example.com'); + await bob.keyStore.addContact({ armoredKey: await alice.keyStore.exportPublic(alice.key.fingerprint) }); + await alice.keyStore.addContact({ armoredKey: await bob.keyStore.exportPublic(bob.key.fingerprint) }); + const impostor = await actor('Alice', 'alice@example.com'); + await impostor.keyStore.addContact({ armoredKey: await bob.keyStore.exportPublic(bob.key.fingerprint) }); + const { raw } = await impostor.mail.build(sendOptions(impostor, 'bob@example.com', { encrypt: true, sign: true, passphrase: impostor.passphrase })); + const result = await bob.mail.decrypt(await simpleParser(raw), { passphrase: bob.passphrase }); + assert.equal(result.signatures[0].status, 'unknown-key'); + assert.equal(result.signatures[0].keyChanged, true); + const added = await bob.keyStore.addContact({ armoredKey: await impostor.keyStore.exportPublic(impostor.key.fingerprint) }); + assert.deepEqual(added.keyChangedFrom, [alice.key.fingerprint]); + const second = await bob.mail.decrypt(await simpleParser(raw)); + assert.equal(second.signatures[0].status, 'valid'); + assert.equal(second.signatures[0].keyChanged, false); +}); + +test('signs without encrypting and verifies PGP/MIME signatures', async () => { + const alice = await actor('Alice', 'alice@example.com'); + const bob = await actor('Bob', 'bob@example.com'); + await bob.keyStore.addContact({ armoredKey: await alice.keyStore.exportPublic(alice.key.fingerprint) }); + const attachment = Buffer.from('signed attachment data'); + const { raw } = await alice.mail.build(sendOptions(alice, 'bob@example.com', { + sign: true, + passphrase: alice.passphrase, + attachments: [{ filename: 'signed.txt', contentType: 'text/plain', content: attachment }] + })); + const parsed = await simpleParser(raw); + assert.equal(detect(parsed), 'signed-mime'); + assert.match(parsed.text, /Top secret/); + assert.deepEqual(parsed.attachments[0].content, attachment); + const [signature] = await bob.mail.verifySigned(parsed, raw); + assert.equal(signature.status, 'valid'); + const altered = Buffer.from(raw.toString('latin1').replace('Content-Type: text/plain', 'Content-Type: text/plain'), 'latin1'); + const [bad] = await bob.mail.verifySigned(await simpleParser(altered), altered); + assert.equal(bad.status, 'invalid'); +}); + +test('reads inline PGP messages and cleartext signatures', async () => { + const alice = await actor('Alice', 'alice@example.com'); + const bob = await actor('Bob', 'bob@example.com'); + await exchange(alice, bob); + const bobKey = (await openpgp.readKey({ armoredKey: await bob.keyStore.exportPublic(bob.key.fingerprint) })); + const armored = await openpgp.encrypt({ message: await openpgp.createMessage({ text: 'inline body' }), encryptionKeys: bobKey }); + const source = Buffer.from(`From: Alice \r\nTo: bob@example.com\r\nSubject: inline\r\nContent-Type: text/plain\r\n\r\n${armored}\r\n`); + const parsed = await simpleParser(source); + assert.equal(detect(parsed), 'encrypted-inline'); + const result = await bob.mail.decrypt(parsed, { passphrase: bob.passphrase }); + assert.equal(result.parsed.text.trim(), 'inline body'); + const aliceSigner = await alice.keyStore.unlockKey(alice.key.fingerprint, alice.passphrase); + const cleartext = await openpgp.sign({ message: await openpgp.createCleartextMessage({ text: 'hello signed' }), signingKeys: aliceSigner }); + const signedSource = Buffer.from(`From: alice@example.com\r\nSubject: s\r\nContent-Type: text/plain\r\n\r\n${cleartext}\r\n`); + const signedParsed = await simpleParser(signedSource); + assert.equal(detect(signedParsed), 'signed-inline'); + assert.equal((await bob.mail.verifySigned(signedParsed, signedSource))[0].status, 'valid'); +}); + +test('decrypts large messages with attachments from other clients', async () => { + const alice = await actor('Alice', 'alice@example.com'); + const bob = await actor('Bob', 'bob@example.com'); + const inner = await new Promise((resolve, reject) => new MailComposer({ + text: 'with attachment', attachments: [{ filename: 'big.bin', content: Buffer.alloc(8 * 1048576, 7) }] + }).compile().build((error, message) => error ? reject(error) : resolve(message))); + const bobKey = await openpgp.readKey({ armoredKey: await bob.keyStore.exportPublic(bob.key.fingerprint) }); + const armored = await openpgp.encrypt({ message: await openpgp.createMessage({ binary: inner }), encryptionKeys: bobKey }); + const source = Buffer.from(`From: alice@example.com\r\nTo: bob@example.com\r\nSubject: big\r\nMIME-Version: 1.0\r\nContent-Type: multipart/encrypted; protocol="application/pgp-encrypted"; boundary="b1"\r\n\r\n--b1\r\nContent-Type: application/pgp-encrypted\r\n\r\nVersion: 1\r\n\r\n--b1\r\nContent-Type: application/octet-stream\r\n\r\n${armored}\r\n--b1--\r\n`); + const result = await bob.mail.decrypt(await simpleParser(source), { passphrase: bob.passphrase }); + assert.equal(result.parsed.attachments[0].filename, 'big.bin'); + assert.equal(result.parsed.attachments[0].content.length, 8 * 1048576); +}); + +test('keyring: contacts, trust levels, expired passphrase cache and settings', async () => { + const alice = await actor('Alice', 'alice@example.com'); + const bob = await actor('Bob', 'bob@example.com'); + const { contact } = await alice.keyStore.addContact({ armoredKey: await bob.keyStore.exportPublic(bob.key.fingerprint), source: 'message' }); + assert.equal(contact.trust, 'unknown'); + assert.equal((await alice.keyStore.setTrust(contact.fingerprint, 'verified')).trust, 'verified'); + await assert.rejects(() => alice.keyStore.setTrust(contact.fingerprint, 'bogus')); + 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(() => alice.keyStore.addContact({ armoredKey: 'junk' }), /valid OpenPGP/); + assert.deepEqual(await alice.keyStore.getSettings(), { cacheMinutes: 10, customKeyServers: [], enabledKeyServers: [] }); + 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'] }); + assert.equal((await alice.keyStore.getSettings()).cacheMinutes, 0); + await alice.keyStore.setSettings({ cacheMinutes: 5 }); + assert.deepEqual((await alice.keyStore.getSettings()).customKeyServers, [customServer]); + assert.deepEqual((await alice.keyStore.getSettings()).enabledKeyServers, ['custom', 'openpgp-vks']); + await alice.keyStore.setSettings({ cacheMinutes: 5, enabledKeyServers: [] }); + assert.deepEqual((await alice.keyStore.getSettings()).enabledKeyServers, []); + await alice.keyStore.removeContact(contact.fingerprint); + assert.equal((await alice.keyStore.listContacts()).length, 0); + + let clock = 1000; + const cache = createPassphraseCache(async () => 1, () => clock); + await cache.remember('F', 'secret'); + assert.equal(cache.get('F'), 'secret'); + clock += 61000; + assert.equal(cache.get('F'), null); +}); diff --git a/www/account-ui.js b/www/account-ui.js index 3def3e6..d657607 100644 --- a/www/account-ui.js +++ b/www/account-ui.js @@ -3,29 +3,29 @@ const accountMailUi = window.epMailFeatures.mail; const accountDavUi = window.epMailFeatures.dav; async function openAccountManager(){ - const root=accountMailUi.select('#modal-root'); - try{ - const data=await window.daybreakMail.listAccounts(); - const accounts=data.accounts||[]; - const rows=accounts.map(account=>``).join(''); - root.innerHTML=``; - const close=()=>root.innerHTML=''; - root.querySelectorAll('.modal-close').forEach(button=>button.onclick=close); - root.querySelector('.modal-overlay').onclick=event=>{if(event.target.classList.contains('modal-overlay'))close()}; + const root=accountMailUi.select('#modal-root'); + try{ + const data=await window.daybreakMail.listAccounts(); + const accounts=data.accounts||[]; + const rows=accounts.map(account=>``).join(''); + root.innerHTML=``; + const close=()=>root.innerHTML=''; + root.querySelectorAll('.modal-close').forEach(button=>button.onclick=close); + root.querySelector('.modal-overlay').onclick=event=>{if(event.target.classList.contains('modal-overlay'))close()}; root.querySelector('#add-mail-account').onclick=()=>{close();accountMailUi.openMailAccount()}; - root.onclick=async event=>{ - const switchButton=event.target.closest('[data-switch-account]'); + root.onclick=async event=>{ + const switchButton=event.target.closest('[data-switch-account]'); if(switchButton){switchButton.disabled=true;try{accountMailUi.connectedAccount=await window.daybreakMail.selectAccount(switchButton.dataset.switchAccount);accountMailUi.state.activeFolder='Inbox';accountMailUi.setPageOffset(0);document.querySelectorAll('.folder').forEach(button=>button.classList.toggle('active',button.dataset.folder==='Inbox'));accountMailUi.select('#sidebar-title').textContent='Inbox';accountMailUi.select('#crumb-current').textContent='Inbox';accountMailUi.updateAccountCard(accountMailUi.connectedAccount);close();await accountMailUi.syncMailbox(true,{offset:0})}catch(error){accountMailUi.toast(error.message||'Could not switch accounts');switchButton.disabled=false}return} - const davButton=event.target.closest('[data-open-dav]'); + const davButton=event.target.closest('[data-open-dav]'); if(davButton){close();accountDavUi.openManager(davButton.dataset.openDav);return} - const editButton=event.target.closest('[data-edit-account]'); + const editButton=event.target.closest('[data-edit-account]'); if(editButton){const account=accounts.find(item=>item.id===editButton.dataset.editAccount);if(account)accountMailUi.openMailAccount(account);return} - const removeButton=event.target.closest('[data-remove-account]'); + const removeButton=event.target.closest('[data-remove-account]'); if(removeButton){const email=removeButton.closest('.account-row').querySelector('strong').textContent;if(!confirm(`Remove ${email} from this device?`))return;removeButton.disabled=true;try{const result=await window.daybreakMail.removeAccount(removeButton.dataset.removeAccount);const active=result.accounts.find(account=>account.id===result.activeId)||null;accountMailUi.connectedAccount=active;if(active){accountMailUi.updateAccountCard(active);close();accountMailUi.state.activeFolder='Inbox';accountMailUi.setPageOffset(0);await accountMailUi.syncMailbox(false,{offset:0})}else{accountMailUi.updateAccountCard({email:'Connect a mailbox',imapHost:''});accountMailUi.state.messages.splice(0,accountMailUi.state.messages.length);accountMailUi.renderList();accountMailUi.select('#reader-pane').innerHTML=accountMailUi.emptyReader();accountMailUi.toast('Mail account removed');openAccountManager()}}catch(error){accountMailUi.toast(error.message||'Could not remove the account');removeButton.disabled=false}return} - }; - }catch(error){accountMailUi.toast(error.message||'Could not load mail accounts')} -} - -document.addEventListener('click',event=>{const card=event.target.closest('#account-settings');if(!card)return;event.preventDefault();event.stopImmediatePropagation();openAccountManager()},true); + }; + }catch(error){accountMailUi.toast(error.message||'Could not load mail accounts')} +} + +document.addEventListener('click',event=>{const card=event.target.closest('#account-settings');if(!card)return;event.preventDefault();event.stopImmediatePropagation();openAccountManager()},true); document.addEventListener('keydown',event=>{const card=event.target.closest('#account-settings');if(!card||!['Enter',' '].includes(event.key))return;event.preventDefault();event.stopImmediatePropagation();openAccountManager()},true); })(); diff --git a/www/app.js b/www/app.js index 425ab65..f3a973e 100644 --- a/www/app.js +++ b/www/app.js @@ -2,40 +2,40 @@ if('serviceWorker'in navigator)window.addEventListener('load',()=>navigator.serviceWorker.register('./service-worker.js').catch(()=>{})); const state = window.epMailState; const $=s=>document.querySelector(s), $$=s=>[...document.querySelectorAll(s)]; -function esc(x){return String(x).replace(/[&<>"']/g,c=>({'&':'&','<':'<','>':'>','"':'"',"'":'''}[c]))} +function esc(x){return String(x).replace(/[&<>"']/g,c=>({'&':'&','<':'<','>':'>','"':'"',"'":'''}[c]))} const { safeRemoteImageUrl, sanitizeMailHtml } = window.epMailFeatures.contentSecurity; -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=>`
${m.initials}
${esc(m.sender)}
${esc(m.subject)}
${esc(m.snippet)}
${esc(m.time)}
`).join(''):`
⌕

No messages here

Try another folder or search.

`;$$('.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)$('#reader-pane').innerHTML=emptyReader()} -function openMessage(id){ - state.activeMessage=id; - const m=state.messages.find(x=>x.id===id); - if(!m)return; - m.unread=false; - renderList(); - let safeHtml={html:'',remoteImageCount:0}; - if(m.html)try{safeHtml=sanitizeMailHtml(m.html)}catch(error){console.error('Could not sanitize message HTML; showing plain text instead.',error)} - const body=safeHtml.html?safeHtml.html:`${m.body.map(p=>`

${esc(p)}

`).join('')}

${esc(m.signature||m.sender)}

`; - const imageNotice=safeHtml.remoteImageCount?`

This message contains ${safeHtml.remoteImageCount} remote image${safeHtml.remoteImageCount===1?'':'s'}. Loading them can reveal your network address and that you opened this message to the image host.

`:''; - const attachments=(m.attachments?.length?m.attachments:m.attachment?[{filename:m.attachment,size:m.size}]:[]).map(file=>`
${file.filename.toLowerCase().endsWith('.pdf')?'▤':'▧'}
${esc(file.filename)}${file.size?(typeof file.size==='string'?esc(file.size):`${(file.size/1048576).toFixed(1)} MB`):'Attachment'}
`).join(''); - $('#reader-pane').innerHTML=`
${m.tags.map((t,i)=>`${esc(t)}`).join('')}

${esc(m.subject)}

${m.initials}
${esc(m.sender)}${esc(m.email)} · to me
${esc(m.date)}
${imageNotice}
${body}${attachments}
`; - $('#load-remote-images')?.addEventListener('click',()=>{ - $('#reader-pane').querySelectorAll('.reader-body img[data-remote-src]').forEach(image=>{ - const url=safeRemoteImageUrl(image.getAttribute('data-remote-src')); - image.removeAttribute('data-remote-src'); - if(url)image.src=url; - }); - $('.remote-image-notice')?.remove(); - }); - $('#reader-archive').onclick=()=>{m.archived=true;toast('Moved to Archive');renderList();$('#reader-pane').innerHTML=emptyReader()}; - $('#reader-delete').onclick=()=>{m.deleted=true;toast('Moved to Trash');renderList();$('#reader-pane').innerHTML=emptyReader()}; - $('#reader-star').onclick=()=>{m.star=!m.star;renderList();openMessage(id)}; - $('#reply').onclick=()=>showCompose(m); - $('#forward').onclick=()=>showCompose(m,true); -} -function emptyReader(){return `
✉

Your inbox, at your pace

Select a message to read it here.

`} -function toast(s){const el=$('#toast');el.textContent=s;el.classList.add('visible');clearTimeout(state.toastTimer);state.toastTimer=setTimeout(()=>el.classList.remove('visible'),2300)} -function showCompose(reply,forward=false){const root=$('#modal-root');root.innerHTML=``;const close=()=>root.innerHTML='';$('.modal-close').onclick=close;$('#discard').onclick=close;$('.modal-overlay').addEventListener('click',e=>{if(e.target.classList.contains('modal-overlay'))close()});$('#send').onclick=()=>{const to=$('#compose-to').value.trim();if(!to){$('#compose-to').focus();toast('Add a recipient to send your message');return}const subject=$('#compose-subject').value.trim()||'(no subject)';const body=$('#compose-body').value;state.messages.unshift({id:Date.now(),initials:(window.epMailFeatures.productivity?.profileName||window.epMailFeatures.mail.connectedAccount?.email?.split('@')[0]||'Me').split(/\\s+/).map(x=>x[0]).join('').slice(0,2).toUpperCase(),color:'#dce9dd',sender:(window.epMailFeatures.productivity?.profileName||window.epMailFeatures.mail.connectedAccount?.email?.split('@')[0]||'Me'),email:(window.epMailFeatures.mail.connectedAccount?.email||''),subject,snippet:body||'No message text',time:'Just now',date:'Today',unread:false,star:false,sent:true,tags:['Sent'],body:body.split('\n').filter(Boolean)});close();toast('Message sent');renderList()};$('#compose-to').focus()} +function 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=>`
${m.initials}
${esc(m.sender)}
${esc(m.subject)}
${esc(m.snippet)}
${esc(m.time)}
`).join(''):`
⌕

No messages here

Try another folder or search.

`;$$('.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)$('#reader-pane').innerHTML=emptyReader()} +function openMessage(id){ + state.activeMessage=id; + const m=state.messages.find(x=>x.id===id); + if(!m)return; + m.unread=false; + renderList(); + let safeHtml={html:'',remoteImageCount:0}; + if(m.html)try{safeHtml=sanitizeMailHtml(m.html)}catch(error){console.error('Could not sanitize message HTML; showing plain text instead.',error)} + const body=safeHtml.html?safeHtml.html:`${m.body.map(p=>`

${esc(p)}

`).join('')}

${esc(m.signature||m.sender)}

`; + const imageNotice=safeHtml.remoteImageCount?`

This message contains ${safeHtml.remoteImageCount} remote image${safeHtml.remoteImageCount===1?'':'s'}. Loading them can reveal your network address and that you opened this message to the image host.

`:''; + const attachments=(m.attachments?.length?m.attachments:m.attachment?[{filename:m.attachment,size:m.size}]:[]).map(file=>`
${file.filename.toLowerCase().endsWith('.pdf')?'▤':'▧'}
${esc(file.filename)}${file.size?(typeof file.size==='string'?esc(file.size):`${(file.size/1048576).toFixed(1)} MB`):'Attachment'}
`).join(''); + $('#reader-pane').innerHTML=`
${m.tags.map((t,i)=>`${esc(t)}`).join('')}

${esc(m.subject)}

${m.initials}
${esc(m.sender)}${esc(m.email)} · to me
${esc(m.date)}
${imageNotice}
${body}${attachments}
`; + $('#load-remote-images')?.addEventListener('click',()=>{ + $('#reader-pane').querySelectorAll('.reader-body img[data-remote-src]').forEach(image=>{ + const url=safeRemoteImageUrl(image.getAttribute('data-remote-src')); + image.removeAttribute('data-remote-src'); + if(url)image.src=url; + }); + $('.remote-image-notice')?.remove(); + }); + $('#reader-archive').onclick=()=>{m.archived=true;toast('Moved to Archive');renderList();$('#reader-pane').innerHTML=emptyReader()}; + $('#reader-delete').onclick=()=>{m.deleted=true;toast('Moved to Trash');renderList();$('#reader-pane').innerHTML=emptyReader()}; + $('#reader-star').onclick=()=>{m.star=!m.star;renderList();openMessage(id)}; + $('#reply').onclick=()=>showCompose(m); + $('#forward').onclick=()=>showCompose(m,true); +} +function emptyReader(){return `
✉

Your inbox, at your pace

Select a message to read it here.

`} +function toast(s){const el=$('#toast');el.textContent=s;el.classList.add('visible');clearTimeout(state.toastTimer);state.toastTimer=setTimeout(()=>el.classList.remove('visible'),2300)} +function showCompose(reply,forward=false){const root=$('#modal-root');root.innerHTML=``;const close=()=>root.innerHTML='';$('.modal-close').onclick=close;$('#discard').onclick=close;$('.modal-overlay').addEventListener('click',e=>{if(e.target.classList.contains('modal-overlay'))close()});$('#send').onclick=()=>{const to=$('#compose-to').value.trim();if(!to){$('#compose-to').focus();toast('Add a recipient to send your message');return}const subject=$('#compose-subject').value.trim()||'(no subject)';const body=$('#compose-body').value;state.messages.unshift({id:Date.now(),initials:(window.epMailFeatures.productivity?.profileName||window.epMailFeatures.mail.connectedAccount?.email?.split('@')[0]||'Me').split(/\\s+/).map(x=>x[0]).join('').slice(0,2).toUpperCase(),color:'#dce9dd',sender:(window.epMailFeatures.productivity?.profileName||window.epMailFeatures.mail.connectedAccount?.email?.split('@')[0]||'Me'),email:(window.epMailFeatures.mail.connectedAccount?.email||''),subject,snippet:body||'No message text',time:'Just now',date:'Today',unread:false,star:false,sent:true,tags:['Sent'],body:body.split('\n').filter(Boolean)});close();toast('Message sent');renderList()};$('#compose-to').focus()} function switchView(view){state.activeView=view;$$('.rail-button[data-view]').forEach(b=>b.classList.toggle('active',b.dataset.view===view));$('.mail-layout').classList.toggle('hidden',view!=='mail');$('#calendar-view').classList.toggle('hidden',view!=='calendar');$('#contacts-view').classList.toggle('hidden',view!=='contacts');$('#sidebar-title').textContent=view==='mail'?state.activeFolder:view==='calendar'?'Calendar':'Contacts';$('#crumb-parent').textContent=view==='mail'?'Mail':'Workspace';$('#crumb-current').textContent=view==='mail'?state.activeFolder:view==='calendar'?'Calendar':'Contacts';if(view==='calendar')window.epMailFeatures.productivity.renderCalendar();if(view==='contacts')window.epMailFeatures.productivity.renderContacts();} -$$('.folder').forEach(b=>b.onclick=()=>{state.activeFolder=b.dataset.folder;$$('.folder').forEach(x=>x.classList.toggle('active',x===b));$('#sidebar-title').textContent=state.activeFolder;$('#crumb-current').textContent=state.activeFolder;renderList()});$$('.rail-button[data-view]').forEach(b=>b.onclick=()=>{switchView(b.dataset.view);});function applyTheme(theme,showToast=false){const themes=['daylight','wasteland','ep-wasteland','ep-daylight'];const selected=themes.includes(theme)?theme:'ep-wasteland';const info={daylight:{name:'Eternity Daylight',icon:'☼'},wasteland:{name:'Wasteland',icon:'☾'},'ep-wasteland':{name:'EP Wasteland',icon:'◈'},'ep-daylight':{name:'EP Daylight',icon:'☀'}}[selected];document.body.classList.remove('wasteland','ep-wasteland','ep-daylight');if(selected!=='daylight')document.body.classList.add(selected);document.querySelector('meta[name=theme-color]')?.setAttribute('content',selected==='ep-wasteland'?'#161210':selected==='ep-daylight'?'#f1f1e9':selected==='wasteland'?'#eee8db':'#f4f5f1');localStorage.setItem('daybreak-theme',selected);const brandLogo=$("#brand-logo");if(brandLogo)brandLogo.src=selected==='ep-wasteland'?'logo-ep-wasteland.svg':'logo-ep-daylight.svg';if(showToast)toast(`${info.name} theme`)}applyTheme(localStorage.getItem('daybreak-theme')||'ep-wasteland');$('#search').oninput=e=>{state.query=e.target.value;renderList()};$('#search').addEventListener('keydown',e=>{if(e.key==='Escape'){e.target.value='';state.query='';renderList()}});$('#compose').onclick=()=>showCompose();$('#refresh').onclick=()=>{toast('You’re all up to date');renderList()};$('#select-all').onclick=()=>{const visible=state.messages.filter(m=>!m.archived&&!m.deleted);const all=visible.every(m=>state.selectedIds.has(m.id));visible.forEach(m=>all?state.selectedIds.delete(m.id):state.selectedIds.add(m.id));renderList()};$('#archive-selected').onclick=()=>{state.messages.filter(m=>state.selectedIds.has(m.id)).forEach(m=>m.archived=true);state.selectedIds.clear();renderList();toast('Selected messages archived')};$('#delete-selected').onclick=()=>{state.messages.filter(m=>state.selectedIds.has(m.id)).forEach(m=>m.deleted=true);state.selectedIds.clear();renderList();toast('Selected messages moved to Trash')};$('#sidebar-menu').onclick=()=>toast('More mailbox options');$$('.settings-button,.help-button,.tiny-plus,.text-button').forEach(b=>b.onclick=()=>toast('You’re all caught up'));document.addEventListener('keydown',e=>{if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()==='k'){e.preventDefault();$('#search').focus()}if(e.key==='Escape')$('#modal-root').innerHTML=''});$('#today-label').textContent=new Intl.DateTimeFormat('en-US',{weekday:'long',month:'long',day:'numeric'}).format(new Date()).toUpperCase();$('#reader-pane').innerHTML=emptyReader();renderList();openMessage(state.activeMessage); +$$('.folder').forEach(b=>b.onclick=()=>{state.activeFolder=b.dataset.folder;$$('.folder').forEach(x=>x.classList.toggle('active',x===b));$('#sidebar-title').textContent=state.activeFolder;$('#crumb-current').textContent=state.activeFolder;renderList()});$$('.rail-button[data-view]').forEach(b=>b.onclick=()=>{switchView(b.dataset.view);});function applyTheme(theme,showToast=false){const themes=['daylight','wasteland','ep-wasteland','ep-daylight'];const selected=themes.includes(theme)?theme:'ep-wasteland';const info={daylight:{name:'Eternity Daylight',icon:'☼'},wasteland:{name:'Wasteland',icon:'☾'},'ep-wasteland':{name:'EP Wasteland',icon:'◈'},'ep-daylight':{name:'EP Daylight',icon:'☀'}}[selected];document.body.classList.remove('wasteland','ep-wasteland','ep-daylight');if(selected!=='daylight')document.body.classList.add(selected);document.querySelector('meta[name=theme-color]')?.setAttribute('content',selected==='ep-wasteland'?'#161210':selected==='ep-daylight'?'#f1f1e9':selected==='wasteland'?'#eee8db':'#f4f5f1');localStorage.setItem('daybreak-theme',selected);const brandLogo=$("#brand-logo");if(brandLogo)brandLogo.src=selected==='ep-wasteland'?'logo-ep-wasteland.svg':'logo-ep-daylight.svg';if(showToast)toast(`${info.name} theme`)}applyTheme(localStorage.getItem('daybreak-theme')||'ep-wasteland');$('#search').oninput=e=>{state.query=e.target.value;renderList()};$('#search').addEventListener('keydown',e=>{if(e.key==='Escape'){e.target.value='';state.query='';renderList()}});$('#compose').onclick=()=>showCompose();$('#refresh').onclick=()=>{toast('You’re all up to date');renderList()};$('#select-all').onclick=()=>{const visible=state.messages.filter(m=>!m.archived&&!m.deleted);const all=visible.every(m=>state.selectedIds.has(m.id));visible.forEach(m=>all?state.selectedIds.delete(m.id):state.selectedIds.add(m.id));renderList()};$('#archive-selected').onclick=()=>{state.messages.filter(m=>state.selectedIds.has(m.id)).forEach(m=>m.archived=true);state.selectedIds.clear();renderList();toast('Selected messages archived')};$('#delete-selected').onclick=()=>{state.messages.filter(m=>state.selectedIds.has(m.id)).forEach(m=>m.deleted=true);state.selectedIds.clear();renderList();toast('Selected messages moved to Trash')};$('#sidebar-menu').onclick=()=>toast('More mailbox options');$$('.settings-button,.help-button,.tiny-plus,.text-button').forEach(b=>b.onclick=()=>toast('You’re all caught up'));document.addEventListener('keydown',e=>{if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()==='k'){e.preventDefault();$('#search').focus()}if(e.key==='Escape')$('#modal-root').innerHTML=''});$('#today-label').textContent=new Intl.DateTimeFormat('en-US',{weekday:'long',month:'long',day:'numeric'}).format(new Date()).toUpperCase();$('#reader-pane').innerHTML=emptyReader();renderList();openMessage(state.activeMessage); window.epMailShell = Object.freeze({ state, diff --git a/www/attachments.js b/www/attachments.js index 824d670..8c98d90 100644 --- a/www/attachments.js +++ b/www/attachments.js @@ -5,159 +5,159 @@ const selectAttachmentUi = attachmentMailUi.select; const selectAllAttachmentUi = attachmentMailUi.selectAll; const toastAttachmentUi = attachmentMailUi.toast; const attachmentFolders = ['Inbox', 'Sent', 'Archive', 'Trash']; -let attachmentItems = []; - -function attachmentKind(filename) { - const ext = String(filename).toLowerCase().split('.').pop(); - if (['png', 'jpg', 'jpeg', 'gif', 'webp', 'bmp', 'svg'].includes(ext)) return 'Images'; - if (['pdf', 'doc', 'docx', 'odt', 'txt', 'rtf', 'md', 'xls', 'xlsx', 'csv', 'ppt', 'pptx'].includes(ext)) return 'Documents'; - if (['zip', 'rar', '7z', 'tar', 'gz'].includes(ext)) return 'Archives'; - return 'Other'; -} - -function attachmentSize(size) { - if (!size) return ''; - if (typeof size === 'string') return size; - return size < 1048576 ? `${Math.max(1, Math.round(size / 1024))} KB` : `${(size / 1048576).toFixed(1)} MB`; -} - -async function previewAttachment(target, details) { - if (!details.uid || !window.daybreakMail?.previewAttachment) { - target.textContent = 'Previews are available for connected mailbox messages.'; - return; - } - target.textContent = 'Loading preview…'; - try { - const result = await window.daybreakMail.previewAttachment(details); - target.replaceChildren(); - if (result.kind === 'image') { - const image = document.createElement('img'); - image.className = 'attachment-preview-image'; - image.alt = details.filename; - image.src = result.dataUrl; - target.append(image); - } else if (result.kind === 'text') { - const pre = document.createElement('pre'); - pre.className = 'attachment-preview-text'; - pre.textContent = result.text + (result.truncated ? '\n… (preview truncated)' : ''); - target.append(pre); - } else { - target.textContent = result.reason || 'No preview is available for this file type.'; - } - } catch (error) { - target.textContent = error.message || 'Could not load the preview.'; - } -} - -function downloadAttachment(details) { - if (!details.uid || !window.daybreakMail?.saveAttachment) { toastAttachmentUi('Attachment download is available for connected mailbox messages'); return; } - window.daybreakMail.saveAttachment(details) - .then(result => { if (result.saved) toastAttachmentUi('Attachment saved'); }) - .catch(error => toastAttachmentUi(error.message || 'Could not save attachment')); -} - -// Add a Preview button to each attachment in the reader. +let attachmentItems = []; + +function attachmentKind(filename) { + const ext = String(filename).toLowerCase().split('.').pop(); + if (['png', 'jpg', 'jpeg', 'gif', 'webp', 'bmp', 'svg'].includes(ext)) return 'Images'; + if (['pdf', 'doc', 'docx', 'odt', 'txt', 'rtf', 'md', 'xls', 'xlsx', 'csv', 'ppt', 'pptx'].includes(ext)) return 'Documents'; + if (['zip', 'rar', '7z', 'tar', 'gz'].includes(ext)) return 'Archives'; + return 'Other'; +} + +function attachmentSize(size) { + if (!size) return ''; + if (typeof size === 'string') return size; + return size < 1048576 ? `${Math.max(1, Math.round(size / 1024))} KB` : `${(size / 1048576).toFixed(1)} MB`; +} + +async function previewAttachment(target, details) { + if (!details.uid || !window.daybreakMail?.previewAttachment) { + target.textContent = 'Previews are available for connected mailbox messages.'; + return; + } + target.textContent = 'Loading preview…'; + try { + const result = await window.daybreakMail.previewAttachment(details); + target.replaceChildren(); + if (result.kind === 'image') { + const image = document.createElement('img'); + image.className = 'attachment-preview-image'; + image.alt = details.filename; + image.src = result.dataUrl; + target.append(image); + } else if (result.kind === 'text') { + const pre = document.createElement('pre'); + pre.className = 'attachment-preview-text'; + pre.textContent = result.text + (result.truncated ? '\n… (preview truncated)' : ''); + target.append(pre); + } else { + target.textContent = result.reason || 'No preview is available for this file type.'; + } + } catch (error) { + target.textContent = error.message || 'Could not load the preview.'; + } +} + +function downloadAttachment(details) { + if (!details.uid || !window.daybreakMail?.saveAttachment) { toastAttachmentUi('Attachment download is available for connected mailbox messages'); return; } + window.daybreakMail.saveAttachment(details) + .then(result => { if (result.saved) toastAttachmentUi('Attachment saved'); }) + .catch(error => toastAttachmentUi(error.message || 'Could not save attachment')); +} + +// Add a Preview button to each attachment in the reader. attachmentMailUi.wrapOpenMessage(baseOpenMessage => function (id) { baseOpenMessage(id); const message = attachmentMailUi.state.messages.find(item => item.id === id); if (!message?.uid) return; - selectAllAttachmentUi('#reader-pane .attachment').forEach(row => { - const download = row.querySelector('.download'); - if (!download || row.querySelector('.preview-attachment')) return; - const button = document.createElement('button'); - button.className = 'preview-attachment icon-button'; - button.title = 'Preview'; - button.setAttribute('aria-label', `Preview ${download.dataset.filename}`); - button.textContent = '👁'; - button.addEventListener('click', event => { - event.stopPropagation(); - let panel = row.nextElementSibling?.classList.contains('attachment-preview') ? row.nextElementSibling : null; - if (panel) { panel.remove(); return; } - panel = document.createElement('div'); - panel.className = 'attachment-preview'; - row.after(panel); + selectAllAttachmentUi('#reader-pane .attachment').forEach(row => { + const download = row.querySelector('.download'); + if (!download || row.querySelector('.preview-attachment')) return; + const button = document.createElement('button'); + button.className = 'preview-attachment icon-button'; + button.title = 'Preview'; + button.setAttribute('aria-label', `Preview ${download.dataset.filename}`); + button.textContent = '👁'; + button.addEventListener('click', event => { + event.stopPropagation(); + let panel = row.nextElementSibling?.classList.contains('attachment-preview') ? row.nextElementSibling : null; + if (panel) { panel.remove(); return; } + panel = document.createElement('div'); + panel.className = 'attachment-preview'; + row.after(panel); void previewAttachment(panel, { uid: message.uid, folder: message.sourceFolder || attachmentMailUi.state.activeFolder, filename: download.dataset.filename }); - }); - download.before(button); - }); + }); + download.before(button); + }); }); - -async function collectAttachments() { - const items = []; - for (const folder of attachmentFolders) { - let offset = 0; - for (let page = 0; page < 5; page += 1) { - const result = await window.daybreakMail.syncFolder(folder, offset, { hasAttachments: true }); - for (const message of result.messages || []) { - for (const file of message.attachments || []) { - items.push({ - uid: message.uid, folder, filename: file.filename, size: file.size, - subject: message.subject, sender: message.sender, date: message.date, timestamp: Number(message.timestamp || 0), - kind: attachmentKind(file.filename) - }); - } - } - offset += (result.messages || []).length; - if (!result.messages?.length || offset >= (result.total || 0)) break; - } - } - return items.sort((a, b) => b.timestamp - a.timestamp); -} - -async function openAttachmentsView() { + +async function collectAttachments() { + const items = []; + for (const folder of attachmentFolders) { + let offset = 0; + for (let page = 0; page < 5; page += 1) { + const result = await window.daybreakMail.syncFolder(folder, offset, { hasAttachments: true }); + for (const message of result.messages || []) { + for (const file of message.attachments || []) { + items.push({ + uid: message.uid, folder, filename: file.filename, size: file.size, + subject: message.subject, sender: message.sender, date: message.date, timestamp: Number(message.timestamp || 0), + kind: attachmentKind(file.filename) + }); + } + } + offset += (result.messages || []).length; + if (!result.messages?.length || offset >= (result.total || 0)) break; + } + } + return items.sort((a, b) => b.timestamp - a.timestamp); +} + +async function openAttachmentsView() { if (!attachmentMailUi.connectedAccount || !window.daybreakMail) { attachmentMailUi.openMailAccount(); return; } - const root = selectAttachmentUi('#modal-root'); - root.innerHTML = ``; - const close = () => { root.innerHTML = ''; }; - root.querySelector('.modal-close').onclick = close; - root.querySelector('.modal-overlay').onclick = event => { if (event.target.classList.contains('modal-overlay')) close(); }; - const list = selectAttachmentUi('#attachment-list'); - const render = () => { - const text = selectAttachmentUi('#attachment-search').value.trim().toLowerCase(); - const type = selectAttachmentUi('#attachment-type').value; - const shown = attachmentItems.filter(item => (!type || item.kind === type) && - (!text || `${item.filename} ${item.subject} ${item.sender}`.toLowerCase().includes(text))); - list.replaceChildren(); - if (!shown.length) { list.textContent = attachmentItems.length ? 'No attachments match.' : 'No attachments found.'; return; } - shown.forEach(item => { - const row = document.createElement('div'); - row.className = 'attachment-row'; - const info = document.createElement('div'); - info.className = 'attachment-row-info'; - const name = document.createElement('strong'); - name.textContent = item.filename; - const meta = document.createElement('small'); - meta.textContent = [attachmentSize(item.size), item.sender, item.subject, item.folder, item.date].filter(Boolean).join(' · '); - info.append(name, meta); - const preview = document.createElement('button'); - preview.className = 'discard'; - preview.textContent = 'Preview'; - const save = document.createElement('button'); - save.className = 'discard'; - save.textContent = 'Download'; - const panel = document.createElement('div'); - panel.className = 'attachment-preview'; - panel.hidden = true; - const details = { uid: item.uid, folder: item.folder, filename: item.filename }; - preview.onclick = () => { - panel.hidden = !panel.hidden; - if (!panel.hidden && !panel.childElementCount && !panel.textContent) void previewAttachment(panel, details); - }; - save.onclick = () => downloadAttachment(details); - row.append(info, preview, save, panel); - list.append(row); - }); - }; - selectAttachmentUi('#attachment-search').oninput = render; - selectAttachmentUi('#attachment-type').onchange = render; - try { - attachmentItems = await collectAttachments(); - if (selectAttachmentUi('#attachment-list')) render(); - } catch (error) { - if (selectAttachmentUi('#attachment-list')) selectAttachmentUi('#attachment-list').textContent = error.message || 'Could not load attachments.'; - } -} - + const root = selectAttachmentUi('#modal-root'); + root.innerHTML = ``; + const close = () => { root.innerHTML = ''; }; + root.querySelector('.modal-close').onclick = close; + root.querySelector('.modal-overlay').onclick = event => { if (event.target.classList.contains('modal-overlay')) close(); }; + const list = selectAttachmentUi('#attachment-list'); + const render = () => { + const text = selectAttachmentUi('#attachment-search').value.trim().toLowerCase(); + const type = selectAttachmentUi('#attachment-type').value; + const shown = attachmentItems.filter(item => (!type || item.kind === type) && + (!text || `${item.filename} ${item.subject} ${item.sender}`.toLowerCase().includes(text))); + list.replaceChildren(); + if (!shown.length) { list.textContent = attachmentItems.length ? 'No attachments match.' : 'No attachments found.'; return; } + shown.forEach(item => { + const row = document.createElement('div'); + row.className = 'attachment-row'; + const info = document.createElement('div'); + info.className = 'attachment-row-info'; + const name = document.createElement('strong'); + name.textContent = item.filename; + const meta = document.createElement('small'); + meta.textContent = [attachmentSize(item.size), item.sender, item.subject, item.folder, item.date].filter(Boolean).join(' · '); + info.append(name, meta); + const preview = document.createElement('button'); + preview.className = 'discard'; + preview.textContent = 'Preview'; + const save = document.createElement('button'); + save.className = 'discard'; + save.textContent = 'Download'; + const panel = document.createElement('div'); + panel.className = 'attachment-preview'; + panel.hidden = true; + const details = { uid: item.uid, folder: item.folder, filename: item.filename }; + preview.onclick = () => { + panel.hidden = !panel.hidden; + if (!panel.hidden && !panel.childElementCount && !panel.textContent) void previewAttachment(panel, details); + }; + save.onclick = () => downloadAttachment(details); + row.append(info, preview, save, panel); + list.append(row); + }); + }; + selectAttachmentUi('#attachment-search').oninput = render; + selectAttachmentUi('#attachment-type').onchange = render; + try { + attachmentItems = await collectAttachments(); + if (selectAttachmentUi('#attachment-list')) render(); + } catch (error) { + if (selectAttachmentUi('#attachment-list')) selectAttachmentUi('#attachment-list').textContent = error.message || 'Could not load attachments.'; + } +} + document.addEventListener('DOMContentLoaded', () => { selectAttachmentUi('#attachments-nav')?.addEventListener('click', openAttachmentsView); }); diff --git a/www/branding.css b/www/branding.css index 2f5021f..ee986aa 100644 --- a/www/branding.css +++ b/www/branding.css @@ -1,30 +1,30 @@ -.brand-mark, -body.wasteland .brand-mark, -body.ep-wasteland .brand-mark, -body.ep-daylight .brand-mark { - background: transparent !important; - box-shadow: none !important; - border-radius: 0; -} - -.brand-mark img { - display: block; - width: 35px; - height: 35px; - object-fit: contain; -} - -.settings-select { - flex: 1; - border: 0; - padding: 5px 0; - background: transparent; - color: var(--text); - font: inherit; - text-align: right; -} - -body.ep-wasteland .settings-select, -body.ep-daylight .settings-select { - color-scheme: inherit; -} +.brand-mark, +body.wasteland .brand-mark, +body.ep-wasteland .brand-mark, +body.ep-daylight .brand-mark { + background: transparent !important; + box-shadow: none !important; + border-radius: 0; +} + +.brand-mark img { + display: block; + width: 35px; + height: 35px; + object-fit: contain; +} + +.settings-select { + flex: 1; + border: 0; + padding: 5px 0; + background: transparent; + color: var(--text); + font: inherit; + text-align: right; +} + +body.ep-wasteland .settings-select, +body.ep-daylight .settings-select { + color-scheme: inherit; +} diff --git a/www/dav-ui.js b/www/dav-ui.js index 9ee18e1..4001322 100644 --- a/www/dav-ui.js +++ b/www/dav-ui.js @@ -3,42 +3,42 @@ const davProductivityUi = window.epMailFeatures.productivity; const selectDavUi = davProductivityUi.select; function davTypeName(type){return type==='caldav'?'calendar':'contacts'} -async function syncDav(type, uploadLocal=false){ - try{ - const localOnly=type==='caldav'?davProductivityUi.events.filter(item=>!item._dav):davProductivityUi.contacts.filter(item=>!item._dav); - const result=await window.daybreakMail.davSync(type); - if(type==='caldav'){ - if(uploadLocal)for(const event of localOnly){try{event._dav=await window.daybreakMail.davSaveEvent(event)}catch(error){davProductivityUi.toast(`Could not upload “${event.title}”: ${error.message}`)}} - davProductivityUi.events=[...localOnly,...result.items]; - davProductivityUi.productWrite(davProductivityUi.productKeys.events,davProductivityUi.events);davProductivityUi.renderCalendar();davProductivityUi.toast(`Synced ${result.items.length} calendar events`); - }else{ - if(uploadLocal)for(const contact of localOnly){try{contact._dav=await window.daybreakMail.davSaveContact(contact)}catch(error){davProductivityUi.toast(`Could not upload “${contact.name}”: ${error.message}`)}} - davProductivityUi.contacts=[...localOnly,...result.items]; - davProductivityUi.productWrite(davProductivityUi.productKeys.contacts,davProductivityUi.contacts);davProductivityUi.renderContacts();davProductivityUi.toast(`Synced ${result.items.length} contacts`); - } - }catch(error){davProductivityUi.toast(error.message||`Could not sync ${davTypeName(type)}`)} -} -async function openDavManager(type){ - const root=selectDavUi('#modal-root'),label=type==='caldav'?'CalDAV':'CardDAV'; - try{ - const data=await window.daybreakMail.davList(),accounts=data[type]||[],activeId=data[type==='caldav'?'activeCaldavId':'activeCarddavId']; - const rows=accounts.map(account=>``).join(''); - root.innerHTML=``; - const close=()=>root.innerHTML='';root.querySelectorAll('.modal-close').forEach(button=>button.onclick=close);root.querySelector('.modal-overlay').onclick=event=>{if(event.target.classList.contains('modal-overlay'))close()}; - root.querySelector('#add-dav-server').onclick=()=>showDavConnect(type); - root.onclick=async event=>{ - const activate=event.target.closest('[data-dav-activate]');if(activate){try{await window.daybreakMail.davActivate(type,activate.dataset.davActivate);close();await syncDav(type)}catch(error){davProductivityUi.toast(error.message)}return} - const remove=event.target.closest('[data-dav-remove]');if(remove){if(!confirm(`Remove this ${label} server from ep-mail?`))return;try{const result=await window.daybreakMail.davRemove(type,remove.dataset.davRemove);close();if(result.activeId)await syncDav(type);else if(type==='caldav'){davProductivityUi.events=davProductivityUi.events.filter(item=>!item._dav);davProductivityUi.productWrite(davProductivityUi.productKeys.events,davProductivityUi.events);davProductivityUi.renderCalendar()}else{davProductivityUi.contacts=davProductivityUi.contacts.filter(item=>!item._dav);davProductivityUi.productWrite(davProductivityUi.productKeys.contacts,davProductivityUi.contacts);davProductivityUi.renderContacts()}await openDavManager(type)}catch(error){davProductivityUi.toast(error.message)} } - }; - }catch(error){davProductivityUi.toast(error.message||`Could not load ${label} servers`)} -} -function showDavConnect(type){ - const root=selectDavUi('#modal-root'),label=type==='caldav'?'CalDAV':'CardDAV'; - root.innerHTML=``; - const close=()=>root.innerHTML='';root.querySelector('.modal-close').onclick=close;root.querySelector('.modal-overlay').onclick=event=>{if(event.target.classList.contains('modal-overlay'))close()};root.querySelector('#dav-cancel').onclick=close; - root.querySelector('#dav-connect').onclick=async()=>{const button=root.querySelector('#dav-connect'),status=root.querySelector('#dav-status');button.disabled=true;status.textContent='Checking the server and discovering collections…';try{await window.daybreakMail.davConnect({type,serverUrl:root.querySelector('#dav-server-url').value,username:root.querySelector('#dav-username').value,password:root.querySelector('#dav-password').value});close();davProductivityUi.toast(`${label} server connected`);await syncDav(type,true)}catch(error){status.textContent=error.message||`Could not connect to ${label}`;button.disabled=false}}; - root.querySelector('#dav-server-url').focus(); -} +async function syncDav(type, uploadLocal=false){ + try{ + const localOnly=type==='caldav'?davProductivityUi.events.filter(item=>!item._dav):davProductivityUi.contacts.filter(item=>!item._dav); + const result=await window.daybreakMail.davSync(type); + if(type==='caldav'){ + if(uploadLocal)for(const event of localOnly){try{event._dav=await window.daybreakMail.davSaveEvent(event)}catch(error){davProductivityUi.toast(`Could not upload “${event.title}”: ${error.message}`)}} + davProductivityUi.events=[...localOnly,...result.items]; + davProductivityUi.productWrite(davProductivityUi.productKeys.events,davProductivityUi.events);davProductivityUi.renderCalendar();davProductivityUi.toast(`Synced ${result.items.length} calendar events`); + }else{ + if(uploadLocal)for(const contact of localOnly){try{contact._dav=await window.daybreakMail.davSaveContact(contact)}catch(error){davProductivityUi.toast(`Could not upload “${contact.name}”: ${error.message}`)}} + davProductivityUi.contacts=[...localOnly,...result.items]; + davProductivityUi.productWrite(davProductivityUi.productKeys.contacts,davProductivityUi.contacts);davProductivityUi.renderContacts();davProductivityUi.toast(`Synced ${result.items.length} contacts`); + } + }catch(error){davProductivityUi.toast(error.message||`Could not sync ${davTypeName(type)}`)} +} +async function openDavManager(type){ + const root=selectDavUi('#modal-root'),label=type==='caldav'?'CalDAV':'CardDAV'; + try{ + const data=await window.daybreakMail.davList(),accounts=data[type]||[],activeId=data[type==='caldav'?'activeCaldavId':'activeCarddavId']; + const rows=accounts.map(account=>``).join(''); + root.innerHTML=``; + const close=()=>root.innerHTML='';root.querySelectorAll('.modal-close').forEach(button=>button.onclick=close);root.querySelector('.modal-overlay').onclick=event=>{if(event.target.classList.contains('modal-overlay'))close()}; + root.querySelector('#add-dav-server').onclick=()=>showDavConnect(type); + root.onclick=async event=>{ + const activate=event.target.closest('[data-dav-activate]');if(activate){try{await window.daybreakMail.davActivate(type,activate.dataset.davActivate);close();await syncDav(type)}catch(error){davProductivityUi.toast(error.message)}return} + const remove=event.target.closest('[data-dav-remove]');if(remove){if(!confirm(`Remove this ${label} server from ep-mail?`))return;try{const result=await window.daybreakMail.davRemove(type,remove.dataset.davRemove);close();if(result.activeId)await syncDav(type);else if(type==='caldav'){davProductivityUi.events=davProductivityUi.events.filter(item=>!item._dav);davProductivityUi.productWrite(davProductivityUi.productKeys.events,davProductivityUi.events);davProductivityUi.renderCalendar()}else{davProductivityUi.contacts=davProductivityUi.contacts.filter(item=>!item._dav);davProductivityUi.productWrite(davProductivityUi.productKeys.contacts,davProductivityUi.contacts);davProductivityUi.renderContacts()}await openDavManager(type)}catch(error){davProductivityUi.toast(error.message)} } + }; + }catch(error){davProductivityUi.toast(error.message||`Could not load ${label} servers`)} +} +function showDavConnect(type){ + const root=selectDavUi('#modal-root'),label=type==='caldav'?'CalDAV':'CardDAV'; + root.innerHTML=``; + const close=()=>root.innerHTML='';root.querySelector('.modal-close').onclick=close;root.querySelector('.modal-overlay').onclick=event=>{if(event.target.classList.contains('modal-overlay'))close()};root.querySelector('#dav-cancel').onclick=close; + root.querySelector('#dav-connect').onclick=async()=>{const button=root.querySelector('#dav-connect'),status=root.querySelector('#dav-status');button.disabled=true;status.textContent='Checking the server and discovering collections…';try{await window.daybreakMail.davConnect({type,serverUrl:root.querySelector('#dav-server-url').value,username:root.querySelector('#dav-username').value,password:root.querySelector('#dav-password').value});close();davProductivityUi.toast(`${label} server connected`);await syncDav(type,true)}catch(error){status.textContent=error.message||`Could not connect to ${label}`;button.disabled=false}}; + root.querySelector('#dav-server-url').focus(); +} document.addEventListener('click',event=>{const button=event.target.closest('#caldav-sync,#carddav-sync');if(!button)return;event.preventDefault();event.stopImmediatePropagation();syncDav(button.id.startsWith('caldav')?'caldav':'carddav')},true); window.epMailFeatures.dav = Object.freeze({ diff --git a/www/icon.svg b/www/icon.svg index 72dfd11..2153dec 100644 --- a/www/icon.svg +++ b/www/icon.svg @@ -1,10 +1,10 @@ - - - - - - - - - - + + + + + + + + + + diff --git a/www/index.html b/www/index.html index 67c039b..4616172 100644 --- a/www/index.html +++ b/www/index.html @@ -1,67 +1,67 @@ - - - - - - - - - ep-mail - - - - - -
- - - - -
-
⌕⌘ K
- -
-
-

Good morning

-
1–8 of 24
-
-
All caught up with your mail
-
-
-
- - - -
-
+ + + + + + + + + ep-mail + + + + + +
+ + + + +
+
⌕⌘ K
+ +
+
+

Good morning

+
1–8 of 24
+
+
All caught up with your mail
+
+
+
+ + + +
+
@@ -70,13 +70,13 @@ - - + + - - - - - - + + + + + + diff --git a/www/logo-ep-daylight.svg b/www/logo-ep-daylight.svg index ffd0b2c..986c571 100644 --- a/www/logo-ep-daylight.svg +++ b/www/logo-ep-daylight.svg @@ -1,9 +1,9 @@ - + diff --git a/www/logo-ep-wasteland.svg b/www/logo-ep-wasteland.svg index d4dbe6e..b01b7a9 100644 --- a/www/logo-ep-wasteland.svg +++ b/www/logo-ep-wasteland.svg @@ -1,9 +1,9 @@ - + diff --git a/www/mail-ui.js b/www/mail-ui.js index f62aec3..c3a4302 100644 --- a/www/mail-ui.js +++ b/www/mail-ui.js @@ -17,217 +17,217 @@ const mailFeatureState = { selectedDraftIds: new Set() }; -const senderBrandDomains = { - amazon: ['amazon.com', 'amazon.co.uk'], - apple: ['apple.com', 'icloud.com'], - google: ['google.com', 'gmail.com'], - microsoft: ['microsoft.com', 'outlook.com', 'live.com'], - paypal: ['paypal.com'] -}; - -function suspiciousSenderReasons(message) { - const email = String(message.email || '').trim().toLowerCase(); - const domain = email.split('@').pop() || ''; - if (!domain) return []; - const reasons = []; - if (domain.includes('xn--')) reasons.push('The sender address uses an internationalized domain that may imitate another domain.'); - const name = String(message.sender || '').toLowerCase(); - for (const [brand, domains] of Object.entries(senderBrandDomains)) { - const brandName = new RegExp(`^(?:the\\s+)?${brand}(?:\\s+(?:customer\\s+service|support|security|account|billing|team|payments?|services?))*$`, 'i'); - if (brandName.test(name) && !domains.some(allowed => domain === allowed || domain.endsWith(`.${allowed}`))) { - reasons.push(`The display name mentions ${brand}, but the sender domain is ${domain}.`); - } - } - if (/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(name) && name.split('@').pop() !== domain) { - reasons.push('The address-like display name does not match the actual sender domain.'); - } - return [...new Set(reasons)]; -} - -function inspectMailLink(raw) { - const cleaned = String(raw).replace(/[.,!?;:)\]}>"']+$/g, ''); - let parsed; - try { parsed = new URL(cleaned); } catch { return null; } - if (!['http:', 'https:'].includes(parsed.protocol) || parsed.username || parsed.password) return null; - const host = parsed.hostname.toLowerCase(); - const reasons = []; - if (parsed.protocol === 'http:') reasons.push('unencrypted HTTP connection'); - if (host.includes('xn--')) reasons.push('internationalized domain that may imitate another address'); - if (/^(?:\d{1,3}\.){3}\d{1,3}$/.test(host) || host.startsWith('[')) reasons.push('IP-address destination instead of a named website'); - if (['bit.ly', 't.co', 'tinyurl.com', 'is.gd', 'lnkd.in'].includes(host)) reasons.push('shortened link hides its final destination'); - for (const [brand, domains] of Object.entries(senderBrandDomains)) { - const mentionsBrand = new RegExp(`(^|[.-])${brand.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')}([.-]|$)`, 'i').test(host); - if (mentionsBrand && !domains.some(domain => host === domain || host.endsWith(`.${domain}`))) { - reasons.push(`hostname mentions ${brand} without using its usual domain`); - } - } - return { url: parsed.href, host, reasons }; -} - -function messageLinks(message) { - const bodyLinks = (message.body || []).join('\n').match(/https?:\/\/[^\s<>"']+/gi) || []; - const declaredLinks = Array.isArray(message.links) ? message.links : []; - return [...new Set([...bodyLinks, ...declaredLinks])] - .map(inspectMailLink) - .filter(Boolean) - .slice(0, 30); -} - +const senderBrandDomains = { + amazon: ['amazon.com', 'amazon.co.uk'], + apple: ['apple.com', 'icloud.com'], + google: ['google.com', 'gmail.com'], + microsoft: ['microsoft.com', 'outlook.com', 'live.com'], + paypal: ['paypal.com'] +}; + +function suspiciousSenderReasons(message) { + const email = String(message.email || '').trim().toLowerCase(); + const domain = email.split('@').pop() || ''; + if (!domain) return []; + const reasons = []; + if (domain.includes('xn--')) reasons.push('The sender address uses an internationalized domain that may imitate another domain.'); + const name = String(message.sender || '').toLowerCase(); + for (const [brand, domains] of Object.entries(senderBrandDomains)) { + const brandName = new RegExp(`^(?:the\\s+)?${brand}(?:\\s+(?:customer\\s+service|support|security|account|billing|team|payments?|services?))*$`, 'i'); + if (brandName.test(name) && !domains.some(allowed => domain === allowed || domain.endsWith(`.${allowed}`))) { + reasons.push(`The display name mentions ${brand}, but the sender domain is ${domain}.`); + } + } + if (/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(name) && name.split('@').pop() !== domain) { + reasons.push('The address-like display name does not match the actual sender domain.'); + } + return [...new Set(reasons)]; +} + +function inspectMailLink(raw) { + const cleaned = String(raw).replace(/[.,!?;:)\]}>"']+$/g, ''); + let parsed; + try { parsed = new URL(cleaned); } catch { return null; } + if (!['http:', 'https:'].includes(parsed.protocol) || parsed.username || parsed.password) return null; + const host = parsed.hostname.toLowerCase(); + const reasons = []; + if (parsed.protocol === 'http:') reasons.push('unencrypted HTTP connection'); + if (host.includes('xn--')) reasons.push('internationalized domain that may imitate another address'); + if (/^(?:\d{1,3}\.){3}\d{1,3}$/.test(host) || host.startsWith('[')) reasons.push('IP-address destination instead of a named website'); + if (['bit.ly', 't.co', 'tinyurl.com', 'is.gd', 'lnkd.in'].includes(host)) reasons.push('shortened link hides its final destination'); + for (const [brand, domains] of Object.entries(senderBrandDomains)) { + const mentionsBrand = new RegExp(`(^|[.-])${brand.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')}([.-]|$)`, 'i').test(host); + if (mentionsBrand && !domains.some(domain => host === domain || host.endsWith(`.${domain}`))) { + reasons.push(`hostname mentions ${brand} without using its usual domain`); + } + } + return { url: parsed.href, host, reasons }; +} + +function messageLinks(message) { + const bodyLinks = (message.body || []).join('\n').match(/https?:\/\/[^\s<>"']+/gi) || []; + const declaredLinks = Array.isArray(message.links) ? message.links : []; + return [...new Set([...bodyLinks, ...declaredLinks])] + .map(inspectMailLink) + .filter(Boolean) + .slice(0, 30); +} + appShell.wrapOpenMessage(originalOpenMessage => function (id) { - originalOpenMessage(id); - const message = rendererState.messages.find(item => item.id === id); - if (!message) return; - const senderReasons = suspiciousSenderReasons(message); - const links = messageLinks(message); - const warnings = []; - if (senderReasons.length) { - warnings.push(``); - } - const linkCards = links.map((link, index) => ` - `).join(''); - const reader = selectMailUi('#reader-pane'); - const header = reader.querySelector('.reader-header'); - if (warnings.length && header) header.insertAdjacentHTML('afterend', warnings.join('')); - const replyBar = reader.querySelector('.reply-bar'); - if (links.length && replyBar) { - replyBar.insertAdjacentHTML('beforebegin', ``); - reader.querySelectorAll('[data-mail-link]').forEach(button => { - button.onclick = async () => { - const link = links[Number(button.dataset.mailLink)]; - if (!link) return; - button.disabled = true; - try { - await window.daybreakMail.openExternal(link.url); - } catch (error) { - toastMailUi(error.message || 'Could not open this link'); - } finally { - button.disabled = false; - } - }; - }); - } + originalOpenMessage(id); + const message = rendererState.messages.find(item => item.id === id); + if (!message) return; + const senderReasons = suspiciousSenderReasons(message); + const links = messageLinks(message); + const warnings = []; + if (senderReasons.length) { + warnings.push(``); + } + const linkCards = links.map((link, index) => ` + `).join(''); + const reader = selectMailUi('#reader-pane'); + const header = reader.querySelector('.reader-header'); + if (warnings.length && header) header.insertAdjacentHTML('afterend', warnings.join('')); + const replyBar = reader.querySelector('.reply-bar'); + if (links.length && replyBar) { + replyBar.insertAdjacentHTML('beforebegin', ``); + reader.querySelectorAll('[data-mail-link]').forEach(button => { + button.onclick = async () => { + const link = links[Number(button.dataset.mailLink)]; + if (!link) return; + button.disabled = true; + try { + await window.daybreakMail.openExternal(link.url); + } catch (error) { + toastMailUi(error.message || 'Could not open this link'); + } finally { + button.disabled = false; + } + }; + }); + } }); - + function renderCustomFolders() { - const box = selectMailUi('#custom-folders'); - if (!box) return; - box.replaceChildren(...mailFeatureState.customFolders.map(folder => { - const button = document.createElement('button'); - button.className = 'folder custom-folder'; - button.dataset.folder = folder.id; - button.classList.toggle('active', rendererState.activeFolder === folder.id); - const glyph = document.createElement('span'); - glyph.className = 'nav-glyph'; - glyph.textContent = '▭'; - const label = document.createElement('span'); - label.textContent = folder.name; - button.title = folder.path; - button.append(glyph, label); - button.addEventListener('click', () => { - if (selectMailUi('#filter-folder').value) { selectMailUi('#filter-folder').value = ''; mailFeatureState.folderBeforeSearch = null; } - rendererState.activeFolder = folder.id; - selectAllMailUi('.folder').forEach(item => item.classList.toggle('active', item === button)); - selectMailUi('#sidebar-title').textContent = folder.name; - selectMailUi('#crumb-current').textContent = folder.name; - mailFeatureState.pageOffset = 0; - void syncMailbox(false, { offset: 0 }); - }); - return button; - })); -} - -async function loadCustomFolders() { - if (!mailFeatureState.connectedAccount || !window.daybreakMail?.listFolders) return; - try { - mailFeatureState.customFolders = (await window.daybreakMail.listFolders()).folders || []; - renderCustomFolders(); - } catch {} -} - -// Destination options for the mail-rule folder picker: built-in folders plus the account's IMAP folders. -function ruleFolderSelect(selected = 'Inbox') { - const options = [['Inbox', 'Inbox'], ['Archive', 'Archive'], ['Trash', 'Trash'], ...mailFeatureState.customFolders.map(folder => [folder.id, folder.name])]; - if (!options.some(([value]) => value === selected)) { - options.push([selected, String(selected).replace(/^[^:]*:/, '') || selected]); - } - return ''; -} - -// window.prompt() is not available in Electron, so ask for text in an in-app dialog. -function askText(title, label, placeholder = '') { - return new Promise(resolve => { - const overlay = document.createElement('div'); - overlay.className = 'modal-overlay pgp-prompt'; - overlay.innerHTML = '
'; - overlay.querySelector('.modal-head span').textContent = title; - overlay.querySelector('.compose-line span').textContent = label; - const input = overlay.querySelector('input'); - input.placeholder = placeholder; - const finish = value => { overlay.remove(); resolve(value); }; - overlay.querySelector('form').onsubmit = event => { event.preventDefault(); finish(input.value.trim() || null); }; - overlay.querySelector('[data-cancel]').onclick = () => finish(null); - overlay.addEventListener('keydown', event => { if (event.key === 'Escape') { event.stopPropagation(); finish(null); } }); - document.body.append(overlay); - input.focus(); - }); -} - -async function createMailFolder() { - if (!mailFeatureState.connectedAccount || !window.daybreakMail?.createFolder) { openMailAccount(); return; } - const name = await askText('New mail folder', 'Name'); - if (!name) return; - try { - const result = await window.daybreakMail.createFolder(name); - mailFeatureState.customFolders = result.folders || mailFeatureState.customFolders; - renderCustomFolders(); - toastMailUi(`Folder “${result.folder?.name || name}” created`); - } catch (error) { - toastMailUi(error.message || 'Could not create the folder'); - } -} - -function updateAccountCard(account) { - const card = selectMailUi('#account-settings'); - if (!card) return; - const email = account.email || ''; - const localName = (email.split('@')[0] || 'Mail account').replace(/[._-]+/g, ' ').replace(/\b\w/g, letter => letter.toUpperCase()); + const box = selectMailUi('#custom-folders'); + if (!box) return; + box.replaceChildren(...mailFeatureState.customFolders.map(folder => { + const button = document.createElement('button'); + button.className = 'folder custom-folder'; + button.dataset.folder = folder.id; + button.classList.toggle('active', rendererState.activeFolder === folder.id); + const glyph = document.createElement('span'); + glyph.className = 'nav-glyph'; + glyph.textContent = '▭'; + const label = document.createElement('span'); + label.textContent = folder.name; + button.title = folder.path; + button.append(glyph, label); + button.addEventListener('click', () => { + if (selectMailUi('#filter-folder').value) { selectMailUi('#filter-folder').value = ''; mailFeatureState.folderBeforeSearch = null; } + rendererState.activeFolder = folder.id; + selectAllMailUi('.folder').forEach(item => item.classList.toggle('active', item === button)); + selectMailUi('#sidebar-title').textContent = folder.name; + selectMailUi('#crumb-current').textContent = folder.name; + mailFeatureState.pageOffset = 0; + void syncMailbox(false, { offset: 0 }); + }); + return button; + })); +} + +async function loadCustomFolders() { + if (!mailFeatureState.connectedAccount || !window.daybreakMail?.listFolders) return; + try { + mailFeatureState.customFolders = (await window.daybreakMail.listFolders()).folders || []; + renderCustomFolders(); + } catch {} +} + +// Destination options for the mail-rule folder picker: built-in folders plus the account's IMAP folders. +function ruleFolderSelect(selected = 'Inbox') { + const options = [['Inbox', 'Inbox'], ['Archive', 'Archive'], ['Trash', 'Trash'], ...mailFeatureState.customFolders.map(folder => [folder.id, folder.name])]; + if (!options.some(([value]) => value === selected)) { + options.push([selected, String(selected).replace(/^[^:]*:/, '') || selected]); + } + return ''; +} + +// window.prompt() is not available in Electron, so ask for text in an in-app dialog. +function askText(title, label, placeholder = '') { + return new Promise(resolve => { + const overlay = document.createElement('div'); + overlay.className = 'modal-overlay pgp-prompt'; + overlay.innerHTML = '
'; + overlay.querySelector('.modal-head span').textContent = title; + overlay.querySelector('.compose-line span').textContent = label; + const input = overlay.querySelector('input'); + input.placeholder = placeholder; + const finish = value => { overlay.remove(); resolve(value); }; + overlay.querySelector('form').onsubmit = event => { event.preventDefault(); finish(input.value.trim() || null); }; + overlay.querySelector('[data-cancel]').onclick = () => finish(null); + overlay.addEventListener('keydown', event => { if (event.key === 'Escape') { event.stopPropagation(); finish(null); } }); + document.body.append(overlay); + input.focus(); + }); +} + +async function createMailFolder() { + if (!mailFeatureState.connectedAccount || !window.daybreakMail?.createFolder) { openMailAccount(); return; } + const name = await askText('New mail folder', 'Name'); + if (!name) return; + try { + const result = await window.daybreakMail.createFolder(name); + mailFeatureState.customFolders = result.folders || mailFeatureState.customFolders; + renderCustomFolders(); + toastMailUi(`Folder “${result.folder?.name || name}” created`); + } catch (error) { + toastMailUi(error.message || 'Could not create the folder'); + } +} + +function updateAccountCard(account) { + const card = selectMailUi('#account-settings'); + if (!card) return; + const email = account.email || ''; + const localName = (email.split('@')[0] || 'Mail account').replace(/[._-]+/g, ' ').replace(/\b\w/g, letter => letter.toUpperCase()); const displayName = account.displayName?.trim() || window.epMailFeatures.productivity?.profileName?.trim() || localName; - const initials = displayName.split(/\s+/).filter(Boolean).map(part => part[0]).join('').slice(0, 2); - card.querySelector('.account-avatar').textContent = initials || 'M'; - card.querySelector('.account-info strong').textContent = displayName; - card.querySelector('.account-info span').textContent = email; - card.title = `${displayName} <${email}>`; - if (typeof renderLabels === 'function') renderLabels(); - void loadCustomFolders(); - card.querySelector('.online-dot').style.background = '#70ad7b'; - const profileButton = selectMailUi('.top-avatar'); - if (profileButton) { - profileButton.textContent = initials || 'M'; - profileButton.title = `${displayName} <${email}>`; - profileButton.setAttribute('aria-label', `${displayName} account settings`); - } -} -function openMailAccount(existingAccount = null) { - const root = selectMailUi('#modal-root'); - const editing = Boolean(existingAccount); + const initials = displayName.split(/\s+/).filter(Boolean).map(part => part[0]).join('').slice(0, 2); + card.querySelector('.account-avatar').textContent = initials || 'M'; + card.querySelector('.account-info strong').textContent = displayName; + card.querySelector('.account-info span').textContent = email; + card.title = `${displayName} <${email}>`; + if (typeof renderLabels === 'function') renderLabels(); + void loadCustomFolders(); + card.querySelector('.online-dot').style.background = '#70ad7b'; + const profileButton = selectMailUi('.top-avatar'); + if (profileButton) { + profileButton.textContent = initials || 'M'; + profileButton.title = `${displayName} <${email}>`; + profileButton.setAttribute('aria-label', `${displayName} account settings`); + } +} +function openMailAccount(existingAccount = null) { + const root = selectMailUi('#modal-root'); + const editing = Boolean(existingAccount); const displayName = existingAccount?.displayName || window.epMailFeatures.productivity?.profileName || ''; - const ruleMarkup = (existingAccount?.rules || []).map(rule => ` -
- - - - ${rule.action==='move' - ? `${ruleFolderSelect(rule.value)}` - : ``} - -
`).join(''); + const ruleMarkup = (existingAccount?.rules || []).map(rule => ` +
+ + + + ${rule.action==='move' + ? `${ruleFolderSelect(rule.value)}` + : ``} + +
`).join(''); root.innerHTML = ``; const authMethodRow = document.createElement('label'); authMethodRow.className = 'compose-line'; @@ -297,34 +297,34 @@ function openMailAccount(existingAccount = null) { oauthProviderRow.hidden = true; } const close = () => { root.innerHTML = ''; }; - selectAllMailUi('.modal-close').forEach(button => button.onclick = close); - selectMailUi('.modal-overlay').addEventListener('click', event => { if (event.target.classList.contains('modal-overlay')) close(); }); - selectMailUi('#disconnect-mail').onclick = close; - const addRuleRow = rule => { - const row = document.createElement('div'); - row.className = 'mail-rule-row'; - row.innerHTML = ``; - row.querySelector('.mail-rule-action').value = rule?.action || 'archive'; - selectMailUi('#mail-rule-list').append(row); - }; - selectMailUi('#add-mail-rule').onclick = () => addRuleRow(); - selectMailUi('#mail-rule-list').onclick = event => { - if (event.target.closest('.remove-mail-rule')) event.target.closest('.mail-rule-row').remove(); - }; - selectMailUi('#mail-rule-list').onchange = event => { - if (!event.target.matches('.mail-rule-action')) return; - const row = event.target.closest('.mail-rule-row'); - const value = row.querySelector('.mail-rule-value'); - if (event.target.value === 'move') { - const selected = value.value || 'Inbox'; - value.outerHTML = ruleFolderSelect(selected); - } else if (value.tagName === 'SELECT') { - value.outerHTML = ``; - } - row.querySelector('.mail-rule-value').disabled = event.target.value === 'flag'; - }; - selectMailUi('#connect-mail').onclick = async () => { - const button = selectMailUi('#connect-mail'); + selectAllMailUi('.modal-close').forEach(button => button.onclick = close); + selectMailUi('.modal-overlay').addEventListener('click', event => { if (event.target.classList.contains('modal-overlay')) close(); }); + selectMailUi('#disconnect-mail').onclick = close; + const addRuleRow = rule => { + const row = document.createElement('div'); + row.className = 'mail-rule-row'; + row.innerHTML = ``; + row.querySelector('.mail-rule-action').value = rule?.action || 'archive'; + selectMailUi('#mail-rule-list').append(row); + }; + selectMailUi('#add-mail-rule').onclick = () => addRuleRow(); + selectMailUi('#mail-rule-list').onclick = event => { + if (event.target.closest('.remove-mail-rule')) event.target.closest('.mail-rule-row').remove(); + }; + selectMailUi('#mail-rule-list').onchange = event => { + if (!event.target.matches('.mail-rule-action')) return; + const row = event.target.closest('.mail-rule-row'); + const value = row.querySelector('.mail-rule-value'); + if (event.target.value === 'move') { + const selected = value.value || 'Inbox'; + value.outerHTML = ruleFolderSelect(selected); + } else if (value.tagName === 'SELECT') { + value.outerHTML = ``; + } + row.querySelector('.mail-rule-value').disabled = event.target.value === 'flag'; + }; + selectMailUi('#connect-mail').onclick = async () => { + const button = selectMailUi('#connect-mail'); const status = selectMailUi('#mail-account-status'); const password = selectMailUi('#mail-account-password').value; const authMethod = authMethodSelect.value; @@ -346,523 +346,523 @@ function openMailAccount(existingAccount = null) { ...(authMethod === 'oauth2' ? { oauthProvider } : {}), ...(editing && authMethod === 'oauth2' ? { reauthorizeOAuth } : {}), displayName: name, - imapHost: selectMailUi('#mail-account-imap').value, - smtpHost: selectMailUi('#mail-account-smtp').value, - signature: selectMailUi('#mail-account-signature').value, - notificationsEnabled: selectMailUi('#mail-account-notifications').checked, - syncIntervalMinutes: Number(selectMailUi('#mail-account-sync-interval').value), - rules: [...selectMailUi('#mail-rule-list').querySelectorAll('.mail-rule-row')].map(row => ({ - senderContains: row.querySelector('.mail-rule-sender').value, - subjectContains: row.querySelector('.mail-rule-subject').value, - action: row.querySelector('.mail-rule-action').value, - value: row.querySelector('.mail-rule-value').value - })) - }; - const account = editing - ? await window.daybreakMail.updateAccount(existingAccount.id, details) - : await window.daybreakMail.connect(details); - if (editing) { - const accountList = await window.daybreakMail.listAccounts(); - if (accountList.activeId === account.id) { - mailFeatureState.connectedAccount = account; - updateAccountCard(account); - mailFeatureState.pageOffset = 0; - close(); - await syncMailbox(false, { offset: 0 }); - } else { - close(); - } - toastMailUi('Mailbox settings updated'); + imapHost: selectMailUi('#mail-account-imap').value, + smtpHost: selectMailUi('#mail-account-smtp').value, + signature: selectMailUi('#mail-account-signature').value, + notificationsEnabled: selectMailUi('#mail-account-notifications').checked, + syncIntervalMinutes: Number(selectMailUi('#mail-account-sync-interval').value), + rules: [...selectMailUi('#mail-rule-list').querySelectorAll('.mail-rule-row')].map(row => ({ + senderContains: row.querySelector('.mail-rule-sender').value, + subjectContains: row.querySelector('.mail-rule-subject').value, + action: row.querySelector('.mail-rule-action').value, + value: row.querySelector('.mail-rule-value').value + })) + }; + const account = editing + ? await window.daybreakMail.updateAccount(existingAccount.id, details) + : await window.daybreakMail.connect(details); + if (editing) { + const accountList = await window.daybreakMail.listAccounts(); + if (accountList.activeId === account.id) { + mailFeatureState.connectedAccount = account; + updateAccountCard(account); + mailFeatureState.pageOffset = 0; + close(); + await syncMailbox(false, { offset: 0 }); + } else { + close(); + } + toastMailUi('Mailbox settings updated'); } else { - mailFeatureState.connectedAccount = account; - updateAccountCard(account); - close(); + mailFeatureState.connectedAccount = account; + updateAccountCard(account); + close(); toastMailUi(authMethod === 'oauth2' ? 'OAuth2 mailbox connected securely' : 'Mailbox connected securely'); - await syncMailbox(true); - } - } catch (error) { - status.textContent = error.message || 'Could not connect. Check the account details and try again.'; - button.disabled = false; + await syncMailbox(true); + } + } catch (error) { + status.textContent = error.message || 'Could not connect. Check the account details and try again.'; + button.disabled = false; button.textContent = authMethod === 'oauth2' ? 'Authorize & connect' : editing ? 'Save & reconnect' : 'Test & connect'; - } - }; - selectMailUi('#mail-account-email').focus(); -} -function mailSearchFilters() { - return { - query: selectMailUi('#search').value.trim(), - sender: selectMailUi('#filter-sender').value.trim(), - subject: selectMailUi('#filter-subject').value.trim(), - after: selectMailUi('#filter-after').value, - before: selectMailUi('#filter-before').value, - hasAttachments: selectMailUi('#filter-attachments').checked, - folder: selectMailUi('#filter-folder').value - }; -} - + } + }; + selectMailUi('#mail-account-email').focus(); +} +function mailSearchFilters() { + return { + query: selectMailUi('#search').value.trim(), + sender: selectMailUi('#filter-sender').value.trim(), + subject: selectMailUi('#filter-subject').value.trim(), + after: selectMailUi('#filter-after').value, + before: selectMailUi('#filter-before').value, + hasAttachments: selectMailUi('#filter-attachments').checked, + folder: selectMailUi('#filter-folder').value + }; +} + async function deleteSelectedDrafts() { - const ids = rendererState.messages.map(message => String(message.id)).filter(id => mailFeatureState.selectedDraftIds.has(id)); - if (!ids.length) { toastMailUi('Select one or more drafts first'); return; } - if (!confirm(`Delete ${ids.length} selected draft${ids.length === 1 ? '' : 's'}?`)) return; - try { - for (const id of ids) await window.daybreakMail.deleteDraft(id); - mailFeatureState.selectedDraftIds.clear(); - toastMailUi(`${ids.length} draft${ids.length === 1 ? '' : 's'} deleted`); - await syncMailbox(false); - } catch (error) { toastMailUi(error.message || 'Could not delete the drafts'); } -} - -// In the Drafts folder the shared toolbar acts on drafts, which use string ids. -document.addEventListener('click', event => { - if (rendererState.activeFolder !== 'Drafts') return; - const button = event.target.closest('#select-all, #delete-selected, #archive-selected, #mark-unread'); - if (!button) return; - event.stopImmediatePropagation(); - if (button.id === 'select-all') { - const ids = rendererState.messages.map(message => String(message.id)); - const all = ids.length && ids.every(id => mailFeatureState.selectedDraftIds.has(id)); - ids.forEach(id => all ? mailFeatureState.selectedDraftIds.delete(id) : mailFeatureState.selectedDraftIds.add(id)); - renderDrafts(rendererState.messages.map(message => message.draft)); - } else if (button.id === 'delete-selected') void deleteSelectedDrafts(); -}, true); - -function renderDrafts(drafts) { - const present = new Set(drafts.map(draft => String(draft.id))); - [...mailFeatureState.selectedDraftIds].forEach(id => { if (!present.has(id)) mailFeatureState.selectedDraftIds.delete(id); }); - rendererState.messages.splice(0, rendererState.messages.length, ...drafts.map(draft => ({ - id: draft.id, - sender: 'Draft', - email: draft.to || 'No recipient', - subject: draft.subject || '(no subject)', - snippet: String(draft.text || '').replace(/\s+/g, ' ').slice(0, 180) || 'No message text', - date: new Date(draft.updatedAt || Date.now()).toLocaleString(), - tags: ['Drafts'], - initials: 'D', - color: '#dce6df', - draft - }))); - selectMailUi('#message-list').innerHTML = rendererState.messages.length ? rendererState.messages.map(message => ` -
${message.initials}
-
${escapeMailUi(message.email)}
${escapeMailUi(message.subject)}
${escapeMailUi(message.snippet)}
-
${escapeMailUi(message.date)}
`).join('') : - '
✎

No saved drafts

Drafts are saved on this device and available offline.

'; - const start = selectMailUi('#start-draft'); - if (start) start.onclick = () => appShell.showCompose(); - selectAllMailUi('.message').forEach(row => row.onclick = event => { - const draft = rendererState.messages.find(message => String(message.id) === row.dataset.id)?.draft; - if (event.target.closest('.row-check')) { - event.stopPropagation(); - const id = row.dataset.id; - mailFeatureState.selectedDraftIds.has(id) ? mailFeatureState.selectedDraftIds.delete(id) : mailFeatureState.selectedDraftIds.add(id); - return; - } - if (event.target.closest('.draft-delete')) { - event.stopPropagation(); - if (!draft || !confirm('Delete this draft?')) return; - window.daybreakMail.deleteDraft(draft.id) - .then(() => { toastMailUi('Draft deleted'); return syncMailbox(false); }) - .catch(error => toastMailUi(error.message || 'Could not delete the draft')); - return; - } - if (draft) appShell.showCompose(null, false, draft); - }); - selectMailUi('#reader-pane').innerHTML = appShell.emptyReader(); - selectMailUi('#pagination').textContent = `${rendererState.messages.length} drafts`; - selectMailUi('#load-more').classList.add('hidden'); -} - + const ids = rendererState.messages.map(message => String(message.id)).filter(id => mailFeatureState.selectedDraftIds.has(id)); + if (!ids.length) { toastMailUi('Select one or more drafts first'); return; } + if (!confirm(`Delete ${ids.length} selected draft${ids.length === 1 ? '' : 's'}?`)) return; + try { + for (const id of ids) await window.daybreakMail.deleteDraft(id); + mailFeatureState.selectedDraftIds.clear(); + toastMailUi(`${ids.length} draft${ids.length === 1 ? '' : 's'} deleted`); + await syncMailbox(false); + } catch (error) { toastMailUi(error.message || 'Could not delete the drafts'); } +} + +// In the Drafts folder the shared toolbar acts on drafts, which use string ids. +document.addEventListener('click', event => { + if (rendererState.activeFolder !== 'Drafts') return; + const button = event.target.closest('#select-all, #delete-selected, #archive-selected, #mark-unread'); + if (!button) return; + event.stopImmediatePropagation(); + if (button.id === 'select-all') { + const ids = rendererState.messages.map(message => String(message.id)); + const all = ids.length && ids.every(id => mailFeatureState.selectedDraftIds.has(id)); + ids.forEach(id => all ? mailFeatureState.selectedDraftIds.delete(id) : mailFeatureState.selectedDraftIds.add(id)); + renderDrafts(rendererState.messages.map(message => message.draft)); + } else if (button.id === 'delete-selected') void deleteSelectedDrafts(); +}, true); + +function renderDrafts(drafts) { + const present = new Set(drafts.map(draft => String(draft.id))); + [...mailFeatureState.selectedDraftIds].forEach(id => { if (!present.has(id)) mailFeatureState.selectedDraftIds.delete(id); }); + rendererState.messages.splice(0, rendererState.messages.length, ...drafts.map(draft => ({ + id: draft.id, + sender: 'Draft', + email: draft.to || 'No recipient', + subject: draft.subject || '(no subject)', + snippet: String(draft.text || '').replace(/\s+/g, ' ').slice(0, 180) || 'No message text', + date: new Date(draft.updatedAt || Date.now()).toLocaleString(), + tags: ['Drafts'], + initials: 'D', + color: '#dce6df', + draft + }))); + selectMailUi('#message-list').innerHTML = rendererState.messages.length ? rendererState.messages.map(message => ` +
${message.initials}
+
${escapeMailUi(message.email)}
${escapeMailUi(message.subject)}
${escapeMailUi(message.snippet)}
+
${escapeMailUi(message.date)}
`).join('') : + '
✎

No saved drafts

Drafts are saved on this device and available offline.

'; + const start = selectMailUi('#start-draft'); + if (start) start.onclick = () => appShell.showCompose(); + selectAllMailUi('.message').forEach(row => row.onclick = event => { + const draft = rendererState.messages.find(message => String(message.id) === row.dataset.id)?.draft; + if (event.target.closest('.row-check')) { + event.stopPropagation(); + const id = row.dataset.id; + mailFeatureState.selectedDraftIds.has(id) ? mailFeatureState.selectedDraftIds.delete(id) : mailFeatureState.selectedDraftIds.add(id); + return; + } + if (event.target.closest('.draft-delete')) { + event.stopPropagation(); + if (!draft || !confirm('Delete this draft?')) return; + window.daybreakMail.deleteDraft(draft.id) + .then(() => { toastMailUi('Draft deleted'); return syncMailbox(false); }) + .catch(error => toastMailUi(error.message || 'Could not delete the draft')); + return; + } + if (draft) appShell.showCompose(null, false, draft); + }); + selectMailUi('#reader-pane').innerHTML = appShell.emptyReader(); + selectMailUi('#pagination').textContent = `${rendererState.messages.length} drafts`; + selectMailUi('#load-more').classList.add('hidden'); +} + function setupDraftComposer() { appShell.wrapShowCompose((original) => (reply, forward = false, draft = null) => { - original(reply, forward); - const root = selectMailUi('#modal-root'); - const modal = root.querySelector('.compose-modal'); - if (!modal) return; - modal.dataset.draftId = draft?.id || ''; - let attachments = Array.isArray(draft?.attachments) ? draft.attachments : []; - modal._composeAttachments = attachments; - const fields = modal.querySelector('.compose-fields'); - const attachmentRow = document.createElement('div'); - attachmentRow.className = 'compose-line'; - const attachmentLabel = document.createElement('span'); - attachmentLabel.textContent = 'Attachments'; - const attachmentControls = document.createElement('div'); - attachmentControls.className = 'compose-attachments'; - const attachmentInput = document.createElement('input'); - attachmentInput.type = 'file'; - attachmentInput.multiple = true; - attachmentInput.accept = '*/*'; - attachmentInput.hidden = true; - attachmentInput.setAttribute('aria-label', 'Choose files to attach'); - const attachButton = document.createElement('button'); - attachButton.type = 'button'; - attachButton.className = 'discard'; - attachButton.textContent = 'Attach files…'; - const attachmentList = document.createElement('div'); - attachmentList.className = 'attachment-list'; - attachmentList.setAttribute('aria-live', 'polite'); - attachmentControls.append(attachButton, attachmentInput); - attachmentRow.append(attachmentLabel, attachmentControls); - fields.append(attachmentRow, attachmentList); - attachButton.onclick = () => attachmentInput.click(); - const renderAttachments = () => { - attachmentList.replaceChildren(); - attachments.forEach((file, index) => { - const row = document.createElement('div'); - row.className = 'attachment-row'; - const name = document.createElement('strong'); - name.textContent = file.filename; - const size = document.createElement('small'); - size.textContent = `${((file.size || 0) / 1048576).toFixed(2)} MB`; - const remove = document.createElement('button'); - remove.type = 'button'; - remove.className = 'discard'; - remove.textContent = 'Remove'; - remove.setAttribute('aria-label', `Remove ${file.filename}`); - remove.onclick = () => { - attachments.splice(index, 1); - renderAttachments(); - void persist().catch(error => toastMailUi(error.message || 'Could not save the draft')); - }; - row.append(name, size, remove); - attachmentList.append(row); - }); - }; - attachmentInput.onchange = async () => { - attachButton.disabled = true; - try { - const selected = []; - for (const file of attachmentInput.files) { - const bytes = new Uint8Array(await file.arrayBuffer()); - let binary = ''; - for (let offset = 0; offset < bytes.length; offset += 0x8000) { - binary += String.fromCharCode(...bytes.subarray(offset, offset + 0x8000)); - } - selected.push({ - filename: file.name, - contentType: file.type || 'application/octet-stream', - size: file.size, - contentBase64: btoa(binary) - }); - } - attachments.push(...selected); - renderAttachments(); - await persist(); - } catch (error) { - toastMailUi(error.message || 'Could not add the selected files'); - } finally { - attachmentInput.value = ''; - attachButton.disabled = false; - } - }; - renderAttachments(); - if (draft) { - selectMailUi('#compose-to').value = draft.to || ''; - selectMailUi('#compose-cc').value = draft.cc || ''; - selectMailUi('#compose-subject').value = draft.subject || ''; - selectMailUi('#compose-body').value = draft.text || ''; - modal.querySelector('.modal-head span').textContent = 'Edit draft'; - } - const save = document.createElement('button'); - save.type = 'button'; - save.className = 'discard'; - save.id = 'save-draft'; - save.textContent = 'Save draft'; - modal.querySelector('.compose-footer').insertBefore(save, selectMailUi('#send')); - let saveTimer; - let closed = false; - const persist = async () => { - if (closed || !selectMailUi('#compose-to')) return; - const values = { - id: modal.dataset.draftId || window.crypto.randomUUID(), - to: selectMailUi('#compose-to').value, - cc: selectMailUi('#compose-cc').value, - subject: selectMailUi('#compose-subject').value, - text: selectMailUi('#compose-body').value, - attachments - }; - if (!Object.values(values).some(value => typeof value === 'string' && value.trim()) && !attachments.length) return; - modal.dataset.draftId = values.id; - const result = await window.daybreakMail.saveDraft(values); - modal.dataset.draftId = result.id; - }; - save.onclick = async () => { - try { - await persist(); - toastMailUi('Draft saved on this device'); - if (rendererState.activeFolder === 'Drafts') void syncMailbox(false); - } catch (error) { toastMailUi(error.message || 'Could not save draft'); } - }; - modal.addEventListener('input', () => { - clearTimeout(saveTimer); - saveTimer = setTimeout(() => persist().catch(error => toastMailUi(error.message || 'Could not save draft')), 700); - }); - modal.querySelector('.modal-overlay')?.addEventListener('click', event => { - if (!event.target.classList.contains('modal-overlay')) return; - clearTimeout(saveTimer); - persist().then(() => { if (rendererState.activeFolder === 'Drafts') void syncMailbox(false); }) - .catch(error => toastMailUi(error.message || 'Could not save draft')); - closed = true; - }, true); - root.querySelector('.modal-close')?.addEventListener('click', () => { - clearTimeout(saveTimer); - persist().then(() => { if (rendererState.activeFolder === 'Drafts') void syncMailbox(false); }) - .catch(error => toastMailUi(error.message || 'Could not save draft')); - closed = true; - }, true); - selectMailUi('#discard').onclick = async () => { - clearTimeout(saveTimer); - closed = true; - try { - if (modal.dataset.draftId) await window.daybreakMail.deleteDraft(modal.dataset.draftId); - root.innerHTML = ''; - if (rendererState.activeFolder === 'Drafts') void syncMailbox(false); - } catch (error) { toastMailUi(error.message || 'Could not delete draft'); } - }; - selectMailUi('#send').addEventListener('click', () => { - clearTimeout(saveTimer); - closed = true; - }, true); + original(reply, forward); + const root = selectMailUi('#modal-root'); + const modal = root.querySelector('.compose-modal'); + if (!modal) return; + modal.dataset.draftId = draft?.id || ''; + let attachments = Array.isArray(draft?.attachments) ? draft.attachments : []; + modal._composeAttachments = attachments; + const fields = modal.querySelector('.compose-fields'); + const attachmentRow = document.createElement('div'); + attachmentRow.className = 'compose-line'; + const attachmentLabel = document.createElement('span'); + attachmentLabel.textContent = 'Attachments'; + const attachmentControls = document.createElement('div'); + attachmentControls.className = 'compose-attachments'; + const attachmentInput = document.createElement('input'); + attachmentInput.type = 'file'; + attachmentInput.multiple = true; + attachmentInput.accept = '*/*'; + attachmentInput.hidden = true; + attachmentInput.setAttribute('aria-label', 'Choose files to attach'); + const attachButton = document.createElement('button'); + attachButton.type = 'button'; + attachButton.className = 'discard'; + attachButton.textContent = 'Attach files…'; + const attachmentList = document.createElement('div'); + attachmentList.className = 'attachment-list'; + attachmentList.setAttribute('aria-live', 'polite'); + attachmentControls.append(attachButton, attachmentInput); + attachmentRow.append(attachmentLabel, attachmentControls); + fields.append(attachmentRow, attachmentList); + attachButton.onclick = () => attachmentInput.click(); + const renderAttachments = () => { + attachmentList.replaceChildren(); + attachments.forEach((file, index) => { + const row = document.createElement('div'); + row.className = 'attachment-row'; + const name = document.createElement('strong'); + name.textContent = file.filename; + const size = document.createElement('small'); + size.textContent = `${((file.size || 0) / 1048576).toFixed(2)} MB`; + const remove = document.createElement('button'); + remove.type = 'button'; + remove.className = 'discard'; + remove.textContent = 'Remove'; + remove.setAttribute('aria-label', `Remove ${file.filename}`); + remove.onclick = () => { + attachments.splice(index, 1); + renderAttachments(); + void persist().catch(error => toastMailUi(error.message || 'Could not save the draft')); + }; + row.append(name, size, remove); + attachmentList.append(row); + }); + }; + attachmentInput.onchange = async () => { + attachButton.disabled = true; + try { + const selected = []; + for (const file of attachmentInput.files) { + const bytes = new Uint8Array(await file.arrayBuffer()); + let binary = ''; + for (let offset = 0; offset < bytes.length; offset += 0x8000) { + binary += String.fromCharCode(...bytes.subarray(offset, offset + 0x8000)); + } + selected.push({ + filename: file.name, + contentType: file.type || 'application/octet-stream', + size: file.size, + contentBase64: btoa(binary) + }); + } + attachments.push(...selected); + renderAttachments(); + await persist(); + } catch (error) { + toastMailUi(error.message || 'Could not add the selected files'); + } finally { + attachmentInput.value = ''; + attachButton.disabled = false; + } + }; + renderAttachments(); + if (draft) { + selectMailUi('#compose-to').value = draft.to || ''; + selectMailUi('#compose-cc').value = draft.cc || ''; + selectMailUi('#compose-subject').value = draft.subject || ''; + selectMailUi('#compose-body').value = draft.text || ''; + modal.querySelector('.modal-head span').textContent = 'Edit draft'; + } + const save = document.createElement('button'); + save.type = 'button'; + save.className = 'discard'; + save.id = 'save-draft'; + save.textContent = 'Save draft'; + modal.querySelector('.compose-footer').insertBefore(save, selectMailUi('#send')); + let saveTimer; + let closed = false; + const persist = async () => { + if (closed || !selectMailUi('#compose-to')) return; + const values = { + id: modal.dataset.draftId || window.crypto.randomUUID(), + to: selectMailUi('#compose-to').value, + cc: selectMailUi('#compose-cc').value, + subject: selectMailUi('#compose-subject').value, + text: selectMailUi('#compose-body').value, + attachments + }; + if (!Object.values(values).some(value => typeof value === 'string' && value.trim()) && !attachments.length) return; + modal.dataset.draftId = values.id; + const result = await window.daybreakMail.saveDraft(values); + modal.dataset.draftId = result.id; + }; + save.onclick = async () => { + try { + await persist(); + toastMailUi('Draft saved on this device'); + if (rendererState.activeFolder === 'Drafts') void syncMailbox(false); + } catch (error) { toastMailUi(error.message || 'Could not save draft'); } + }; + modal.addEventListener('input', () => { + clearTimeout(saveTimer); + saveTimer = setTimeout(() => persist().catch(error => toastMailUi(error.message || 'Could not save draft')), 700); + }); + modal.querySelector('.modal-overlay')?.addEventListener('click', event => { + if (!event.target.classList.contains('modal-overlay')) return; + clearTimeout(saveTimer); + persist().then(() => { if (rendererState.activeFolder === 'Drafts') void syncMailbox(false); }) + .catch(error => toastMailUi(error.message || 'Could not save draft')); + closed = true; + }, true); + root.querySelector('.modal-close')?.addEventListener('click', () => { + clearTimeout(saveTimer); + persist().then(() => { if (rendererState.activeFolder === 'Drafts') void syncMailbox(false); }) + .catch(error => toastMailUi(error.message || 'Could not save draft')); + closed = true; + }, true); + selectMailUi('#discard').onclick = async () => { + clearTimeout(saveTimer); + closed = true; + try { + if (modal.dataset.draftId) await window.daybreakMail.deleteDraft(modal.dataset.draftId); + root.innerHTML = ''; + if (rendererState.activeFolder === 'Drafts') void syncMailbox(false); + } catch (error) { toastMailUi(error.message || 'Could not delete draft'); } + }; + selectMailUi('#send').addEventListener('click', () => { + clearTimeout(saveTimer); + closed = true; + }, true); }); } - -async function syncMailbox(showToast, options = {}) { - if (mailFeatureState.syncPromise) { - mailFeatureState.syncQueued = true; - return mailFeatureState.syncPromise; - } - if (!mailFeatureState.connectedAccount || !window.daybreakMail) { - openMailAccount(); - return; - } - const refresh = selectMailUi('#refresh'); - if (refresh) refresh.disabled = true; - const sync = (async () => { - try { - if (rendererState.activeFolder === 'Drafts') { - const result = await window.daybreakMail.listDrafts(); - renderDrafts(result.drafts || []); - if (showToast) toastMailUi(`${result.drafts.length} saved drafts`); - return; - } - const previouslyActiveMessage = rendererState.activeMessage; - const offset = options.offset ?? (options.append ? mailFeatureState.pageOffset + rendererState.messages.length : mailFeatureState.pageOffset); - const result = await window.daybreakMail.syncFolder(rendererState.activeFolder, offset, mailSearchFilters()); - if (options.append) rendererState.messages.push(...result.messages); - else rendererState.messages.splice(0, rendererState.messages.length, ...result.messages); - rendererState.messages.forEach(message => { - try { - const localTags = JSON.parse(localStorage.getItem(`daybreak-message-labels-${message.id}`) || '[]'); - message.tags = [...new Set([...(message.tags || []), ...localTags])]; - } catch {} - }); - if (!options.append) mailFeatureState.pageOffset = offset; - mailFeatureState.total = result.total; - rendererState.activeMessage = rendererState.messages.some(message => message.id === previouslyActiveMessage) - ? previouslyActiveMessage - : rendererState.messages[0]?.id; - rendererState.selectedIds.clear(); - const unread = rendererState.messages.filter(message => message.unread).length; - const inboxCount = selectMailUi('.folder[data-folder="Inbox"] .count'); - if (inboxCount) inboxCount.textContent = String(unread); - const pagination = selectMailUi('#pagination'); - if (pagination) pagination.textContent = result.total ? `${options.append ? 1 : result.start}–${options.append ? Math.min(offset + result.messages.length, result.total) : result.end} of ${result.total}` : '0 messages'; - const loadMore = selectMailUi('#load-more'); - if (loadMore) loadMore.classList.toggle('hidden', mailFeatureState.pageOffset + rendererState.messages.length >= result.total); + +async function syncMailbox(showToast, options = {}) { + if (mailFeatureState.syncPromise) { + mailFeatureState.syncQueued = true; + return mailFeatureState.syncPromise; + } + if (!mailFeatureState.connectedAccount || !window.daybreakMail) { + openMailAccount(); + return; + } + const refresh = selectMailUi('#refresh'); + if (refresh) refresh.disabled = true; + const sync = (async () => { + try { + if (rendererState.activeFolder === 'Drafts') { + const result = await window.daybreakMail.listDrafts(); + renderDrafts(result.drafts || []); + if (showToast) toastMailUi(`${result.drafts.length} saved drafts`); + return; + } + const previouslyActiveMessage = rendererState.activeMessage; + const offset = options.offset ?? (options.append ? mailFeatureState.pageOffset + rendererState.messages.length : mailFeatureState.pageOffset); + const result = await window.daybreakMail.syncFolder(rendererState.activeFolder, offset, mailSearchFilters()); + if (options.append) rendererState.messages.push(...result.messages); + else rendererState.messages.splice(0, rendererState.messages.length, ...result.messages); + rendererState.messages.forEach(message => { + try { + const localTags = JSON.parse(localStorage.getItem(`daybreak-message-labels-${message.id}`) || '[]'); + message.tags = [...new Set([...(message.tags || []), ...localTags])]; + } catch {} + }); + if (!options.append) mailFeatureState.pageOffset = offset; + mailFeatureState.total = result.total; + rendererState.activeMessage = rendererState.messages.some(message => message.id === previouslyActiveMessage) + ? previouslyActiveMessage + : rendererState.messages[0]?.id; + rendererState.selectedIds.clear(); + const unread = rendererState.messages.filter(message => message.unread).length; + const inboxCount = selectMailUi('.folder[data-folder="Inbox"] .count'); + if (inboxCount) inboxCount.textContent = String(unread); + const pagination = selectMailUi('#pagination'); + if (pagination) pagination.textContent = result.total ? `${options.append ? 1 : result.start}–${options.append ? Math.min(offset + result.messages.length, result.total) : result.end} of ${result.total}` : '0 messages'; + const loadMore = selectMailUi('#load-more'); + if (loadMore) loadMore.classList.toggle('hidden', mailFeatureState.pageOffset + rendererState.messages.length >= result.total); rendererState.query = ''; - appShell.renderList(); - if (rendererState.activeMessage) { - appShell.openMessage(rendererState.activeMessage); - const current = rendererState.messages.find(message => message.id === rendererState.activeMessage); - if (current?.uid) window.daybreakMail.updateMessage({ uid: current.uid, folder: current.sourceFolder || rendererState.activeFolder, action: 'unread', enabled: false }).catch(() => {}); - } - else selectMailUi('#reader-pane').innerHTML = appShell.emptyReader(); - updateAccountCard(mailFeatureState.connectedAccount); - const status = selectMailUi('#mail-status'); - if (status) status.textContent = result.offline ? 'Offline — showing saved messages' : 'All caught up with your mail'; - if (showToast) toastMailUi(`Synced ${rendererState.messages.length} messages`); - } catch (error) { - toastMailUi(error.message || 'Could not sync the inbox'); - } finally { - if (refresh) refresh.disabled = false; - } - - })(); - mailFeatureState.syncPromise = sync; - try { - await sync; - } finally { - mailFeatureState.syncPromise = null; - if (mailFeatureState.syncQueued) { - mailFeatureState.syncQueued = false; - void syncMailbox(false); - } - } -} - + appShell.renderList(); + if (rendererState.activeMessage) { + appShell.openMessage(rendererState.activeMessage); + const current = rendererState.messages.find(message => message.id === rendererState.activeMessage); + if (current?.uid) window.daybreakMail.updateMessage({ uid: current.uid, folder: current.sourceFolder || rendererState.activeFolder, action: 'unread', enabled: false }).catch(() => {}); + } + else selectMailUi('#reader-pane').innerHTML = appShell.emptyReader(); + updateAccountCard(mailFeatureState.connectedAccount); + const status = selectMailUi('#mail-status'); + if (status) status.textContent = result.offline ? 'Offline — showing saved messages' : 'All caught up with your mail'; + if (showToast) toastMailUi(`Synced ${rendererState.messages.length} messages`); + } catch (error) { + toastMailUi(error.message || 'Could not sync the inbox'); + } finally { + if (refresh) refresh.disabled = false; + } + + })(); + mailFeatureState.syncPromise = sync; + try { + await sync; + } finally { + mailFeatureState.syncPromise = null; + if (mailFeatureState.syncQueued) { + mailFeatureState.syncQueued = false; + void syncMailbox(false); + } + } +} + if (window.daybreakMail) { - setupDraftComposer(); - let searchTimer; - const searchControls = ['#search', '#filter-folder', '#filter-sender', '#filter-subject', '#filter-after', '#filter-before', '#filter-attachments']; - selectMailUi('#search-filters-toggle').onclick = () => { - const panel = selectMailUi('#search-filters'); - const expanded = panel.classList.toggle('hidden') === false; - selectMailUi('#search-filters-toggle').setAttribute('aria-expanded', String(expanded)); - }; - selectMailUi('#clear-search-filters').onclick = () => { - selectMailUi('#filter-folder').value = ''; - selectMailUi('#filter-sender').value = ''; - selectMailUi('#filter-subject').value = ''; - selectMailUi('#filter-after').value = ''; - selectMailUi('#filter-before').value = ''; - selectMailUi('#filter-attachments').checked = false; - selectMailUi('#search').value = ''; - rendererState.activeFolder = mailFeatureState.folderBeforeSearch || rendererState.activeFolder; - mailFeatureState.folderBeforeSearch = null; - selectAllMailUi('.folder').forEach(button => button.classList.toggle('active', button.dataset.folder === rendererState.activeFolder)); - selectMailUi('#sidebar-title').textContent = rendererState.activeFolder; - selectMailUi('#crumb-current').textContent = rendererState.activeFolder; + setupDraftComposer(); + let searchTimer; + const searchControls = ['#search', '#filter-folder', '#filter-sender', '#filter-subject', '#filter-after', '#filter-before', '#filter-attachments']; + selectMailUi('#search-filters-toggle').onclick = () => { + const panel = selectMailUi('#search-filters'); + const expanded = panel.classList.toggle('hidden') === false; + selectMailUi('#search-filters-toggle').setAttribute('aria-expanded', String(expanded)); + }; + selectMailUi('#clear-search-filters').onclick = () => { + selectMailUi('#filter-folder').value = ''; + selectMailUi('#filter-sender').value = ''; + selectMailUi('#filter-subject').value = ''; + selectMailUi('#filter-after').value = ''; + selectMailUi('#filter-before').value = ''; + selectMailUi('#filter-attachments').checked = false; + selectMailUi('#search').value = ''; + rendererState.activeFolder = mailFeatureState.folderBeforeSearch || rendererState.activeFolder; + mailFeatureState.folderBeforeSearch = null; + selectAllMailUi('.folder').forEach(button => button.classList.toggle('active', button.dataset.folder === rendererState.activeFolder)); + selectMailUi('#sidebar-title').textContent = rendererState.activeFolder; + selectMailUi('#crumb-current').textContent = rendererState.activeFolder; rendererState.query = ''; - appShell.renderList(); - mailFeatureState.pageOffset = 0; - void syncMailbox(false, { offset: 0 }); - }; - for (const selector of searchControls) { - selectMailUi(selector).addEventListener(selector === '#search' ? 'input' : 'change', () => { - if (selector === '#filter-folder' && selectMailUi('#filter-folder').value) { - if (!mailFeatureState.folderBeforeSearch) mailFeatureState.folderBeforeSearch = rendererState.activeFolder; - rendererState.activeFolder = selectMailUi('#filter-folder').value; - selectAllMailUi('.folder').forEach(button => button.classList.toggle('active', button.dataset.folder === rendererState.activeFolder)); - selectMailUi('#sidebar-title').textContent = rendererState.activeFolder; - selectMailUi('#crumb-current').textContent = rendererState.activeFolder; - } - clearTimeout(searchTimer); - searchTimer = setTimeout(() => { - mailFeatureState.pageOffset = 0; - void syncMailbox(false, { offset: 0 }); - }, selector === '#search' ? 350 : 0); - }); - } - window.daybreakMail.getAppVersion().then(version => { - document.title = `ep-mail v${version}`; - }).catch(error => { - console.error('Could not read app version:', error); - }); - window.daybreakMail.onSyncUpdate(update => { - if (update.accountId !== mailFeatureState.connectedAccount?.id) return; - if (update.error) { - toastMailUi(update.error); - return; - } - if (update.newCount || (update.foldersChanged || []).length) { - if (document.visibilityState === 'visible') { - syncMailbox(false, update.newCount ? { offset: 0 } : {}); - } - else mailFeatureState.refreshPending = true; - } - }); - document.addEventListener('visibilitychange', () => { - if (document.visibilityState === 'visible' && mailFeatureState.refreshPending) { - mailFeatureState.refreshPending = false; - syncMailbox(false, { offset: 0 }); - } - }); - window.addEventListener('focus', () => { - if (mailFeatureState.connectedAccount) syncMailbox(false); - }); - window.addEventListener('online', () => { - if (mailFeatureState.connectedAccount) syncMailbox(false, { offset: 0 }); - }); - setInterval(() => { - if (mailFeatureState.connectedAccount && document.visibilityState === 'visible' && rendererState.activeView === 'mail') { - syncMailbox(false); - } - }, 60 * 1000); - selectMailUi('#account-settings').addEventListener('click', openMailAccount); - selectMailUi('#account-settings').addEventListener('keydown', event => { - if (event.key === 'Enter' || event.key === ' ') { event.preventDefault(); openMailAccount(); } - }); - selectMailUi('#refresh').onclick = () => syncMailbox(true); - selectMailUi('#add-folder').addEventListener('click', createMailFolder); - selectAllMailUi('.folder').forEach(button => button.addEventListener('click', () => { - if (selectMailUi('#filter-folder').value) { - selectMailUi('#filter-folder').value = ''; - mailFeatureState.folderBeforeSearch = null; - } - if (['Inbox', 'Sent', 'Archive', 'Trash', 'Starred', 'Drafts'].includes(button.dataset.folder)) { - mailFeatureState.pageOffset = 0; - syncMailbox(false, { offset: 0 }); - } - })); - selectMailUi('#previous-page').onclick = () => { - if (mailFeatureState.pageOffset <= 0) return; - mailFeatureState.pageOffset = Math.max(0, mailFeatureState.pageOffset - 20); - syncMailbox(false, { offset: mailFeatureState.pageOffset }); - }; - selectMailUi('#next-page').onclick = () => { - if (mailFeatureState.pageOffset + 20 >= mailFeatureState.total) return; - mailFeatureState.pageOffset += 20; - syncMailbox(false, { offset: mailFeatureState.pageOffset }); - }; - selectMailUi('#load-more').onclick = () => syncMailbox(false, { append: true }); - document.addEventListener('click', async event => { - const sendButton = event.target.closest('#send'); - if (!sendButton || !mailFeatureState.connectedAccount) return; - event.preventDefault(); - event.stopImmediatePropagation(); - const recipient = selectMailUi('#compose-to').value.trim(); - if (!recipient) { selectMailUi('#compose-to').focus(); toastMailUi('Add a recipient to send your message'); return; } - sendButton.disabled = true; - sendButton.textContent = 'Sending…'; - try { + appShell.renderList(); + mailFeatureState.pageOffset = 0; + void syncMailbox(false, { offset: 0 }); + }; + for (const selector of searchControls) { + selectMailUi(selector).addEventListener(selector === '#search' ? 'input' : 'change', () => { + if (selector === '#filter-folder' && selectMailUi('#filter-folder').value) { + if (!mailFeatureState.folderBeforeSearch) mailFeatureState.folderBeforeSearch = rendererState.activeFolder; + rendererState.activeFolder = selectMailUi('#filter-folder').value; + selectAllMailUi('.folder').forEach(button => button.classList.toggle('active', button.dataset.folder === rendererState.activeFolder)); + selectMailUi('#sidebar-title').textContent = rendererState.activeFolder; + selectMailUi('#crumb-current').textContent = rendererState.activeFolder; + } + clearTimeout(searchTimer); + searchTimer = setTimeout(() => { + mailFeatureState.pageOffset = 0; + void syncMailbox(false, { offset: 0 }); + }, selector === '#search' ? 350 : 0); + }); + } + window.daybreakMail.getAppVersion().then(version => { + document.title = `ep-mail v${version}`; + }).catch(error => { + console.error('Could not read app version:', error); + }); + window.daybreakMail.onSyncUpdate(update => { + if (update.accountId !== mailFeatureState.connectedAccount?.id) return; + if (update.error) { + toastMailUi(update.error); + return; + } + if (update.newCount || (update.foldersChanged || []).length) { + if (document.visibilityState === 'visible') { + syncMailbox(false, update.newCount ? { offset: 0 } : {}); + } + else mailFeatureState.refreshPending = true; + } + }); + document.addEventListener('visibilitychange', () => { + if (document.visibilityState === 'visible' && mailFeatureState.refreshPending) { + mailFeatureState.refreshPending = false; + syncMailbox(false, { offset: 0 }); + } + }); + window.addEventListener('focus', () => { + if (mailFeatureState.connectedAccount) syncMailbox(false); + }); + window.addEventListener('online', () => { + if (mailFeatureState.connectedAccount) syncMailbox(false, { offset: 0 }); + }); + setInterval(() => { + if (mailFeatureState.connectedAccount && document.visibilityState === 'visible' && rendererState.activeView === 'mail') { + syncMailbox(false); + } + }, 60 * 1000); + selectMailUi('#account-settings').addEventListener('click', openMailAccount); + selectMailUi('#account-settings').addEventListener('keydown', event => { + if (event.key === 'Enter' || event.key === ' ') { event.preventDefault(); openMailAccount(); } + }); + selectMailUi('#refresh').onclick = () => syncMailbox(true); + selectMailUi('#add-folder').addEventListener('click', createMailFolder); + selectAllMailUi('.folder').forEach(button => button.addEventListener('click', () => { + if (selectMailUi('#filter-folder').value) { + selectMailUi('#filter-folder').value = ''; + mailFeatureState.folderBeforeSearch = null; + } + if (['Inbox', 'Sent', 'Archive', 'Trash', 'Starred', 'Drafts'].includes(button.dataset.folder)) { + mailFeatureState.pageOffset = 0; + syncMailbox(false, { offset: 0 }); + } + })); + selectMailUi('#previous-page').onclick = () => { + if (mailFeatureState.pageOffset <= 0) return; + mailFeatureState.pageOffset = Math.max(0, mailFeatureState.pageOffset - 20); + syncMailbox(false, { offset: mailFeatureState.pageOffset }); + }; + selectMailUi('#next-page').onclick = () => { + if (mailFeatureState.pageOffset + 20 >= mailFeatureState.total) return; + mailFeatureState.pageOffset += 20; + syncMailbox(false, { offset: mailFeatureState.pageOffset }); + }; + selectMailUi('#load-more').onclick = () => syncMailbox(false, { append: true }); + document.addEventListener('click', async event => { + const sendButton = event.target.closest('#send'); + if (!sendButton || !mailFeatureState.connectedAccount) return; + event.preventDefault(); + event.stopImmediatePropagation(); + const recipient = selectMailUi('#compose-to').value.trim(); + if (!recipient) { selectMailUi('#compose-to').focus(); toastMailUi('Add a recipient to send your message'); return; } + sendButton.disabled = true; + sendButton.textContent = 'Sending…'; + try { const pgp = window.epMailFeatures.pgp?.prepareSend ? await window.epMailFeatures.pgp.prepareSend(recipient, selectMailUi('#compose-cc').value) : null; - if (pgp === false) { - sendButton.disabled = false; - sendButton.textContent = 'Send ↗'; - return; - } - const result = await window.daybreakMail.send({ - to: recipient, - cc: selectMailUi('#compose-cc').value, - subject: selectMailUi('#compose-subject').value.trim(), - text: selectMailUi('#compose-body').value, - attachments: selectMailUi('#modal-root .compose-modal')?._composeAttachments || [], + if (pgp === false) { + sendButton.disabled = false; + sendButton.textContent = 'Send ↗'; + return; + } + const result = await window.daybreakMail.send({ + to: recipient, + cc: selectMailUi('#compose-cc').value, + subject: selectMailUi('#compose-subject').value.trim(), + text: selectMailUi('#compose-body').value, + attachments: selectMailUi('#modal-root .compose-modal')?._composeAttachments || [], displayName: mailFeatureState.connectedAccount.displayName || window.epMailFeatures.productivity?.profileName || '', - ...(pgp ? { pgp } : {}) - }); - if (result.failed) { - sendButton.disabled = false; - sendButton.textContent = 'Send ↗'; - toastMailUi(result.message || 'Message could not be encrypted'); - return; - } - if (result.queued) { - const draftId = selectMailUi('#modal-root .compose-modal')?.dataset.draftId; - if (draftId) await window.daybreakMail.deleteDraft(draftId); - selectMailUi('#modal-root').innerHTML = ''; - toastMailUi('Offline: message queued and will send when connected'); - if (rendererState.activeFolder === 'Drafts') void syncMailbox(false); - return; - } - const draftId = selectMailUi('#modal-root .compose-modal')?.dataset.draftId; - if (draftId) await window.daybreakMail.deleteDraft(draftId); - selectMailUi('#modal-root').innerHTML = ''; - 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 === 'Drafts') void syncMailbox(false); - } catch (error) { - sendButton.disabled = false; - sendButton.textContent = 'Send ↗'; - toastMailUi(error.message || 'Message could not be sent'); - } - }, true); - - window.daybreakMail.getAccount().then(account => { - if (!account) return; - mailFeatureState.connectedAccount = account; - updateAccountCard(account); - syncMailbox(false); + ...(pgp ? { pgp } : {}) + }); + if (result.failed) { + sendButton.disabled = false; + sendButton.textContent = 'Send ↗'; + toastMailUi(result.message || 'Message could not be encrypted'); + return; + } + if (result.queued) { + const draftId = selectMailUi('#modal-root .compose-modal')?.dataset.draftId; + if (draftId) await window.daybreakMail.deleteDraft(draftId); + selectMailUi('#modal-root').innerHTML = ''; + toastMailUi('Offline: message queued and will send when connected'); + if (rendererState.activeFolder === 'Drafts') void syncMailbox(false); + return; + } + const draftId = selectMailUi('#modal-root .compose-modal')?.dataset.draftId; + if (draftId) await window.daybreakMail.deleteDraft(draftId); + selectMailUi('#modal-root').innerHTML = ''; + 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 === 'Drafts') void syncMailbox(false); + } catch (error) { + sendButton.disabled = false; + sendButton.textContent = 'Send ↗'; + toastMailUi(error.message || 'Message could not be sent'); + } + }, true); + + window.daybreakMail.getAccount().then(account => { + if (!account) return; + mailFeatureState.connectedAccount = account; + updateAccountCard(account); + syncMailbox(false); }).catch(() => {}); } diff --git a/www/manifest.webmanifest b/www/manifest.webmanifest index e389539..c052ffe 100644 --- a/www/manifest.webmanifest +++ b/www/manifest.webmanifest @@ -1,10 +1,10 @@ -{ - "name": "ep-mail", - "short_name": "ep-mail", - "description": "Eternity Project mail, calendar, and contacts.", - "start_url": "./", - "display": "standalone", - "background_color": "#f4f5f1", - "theme_color": "#f4f5f1", - "icons": [{"src":"icon.svg","sizes":"any","type":"image/svg+xml","purpose":"any maskable"}] -} +{ + "name": "ep-mail", + "short_name": "ep-mail", + "description": "Eternity Project mail, calendar, and contacts.", + "start_url": "./", + "display": "standalone", + "background_color": "#f4f5f1", + "theme_color": "#f4f5f1", + "icons": [{"src":"icon.svg","sizes":"any","type":"image/svg+xml","purpose":"any maskable"}] +} diff --git a/www/pgp-mail-ui.js b/www/pgp-mail-ui.js index e0e7544..d5e701b 100644 --- a/www/pgp-mail-ui.js +++ b/www/pgp-mail-ui.js @@ -6,193 +6,193 @@ const selectAllPgpMailUi = pgpMailUi.selectAll; const toastPgpMailUi = pgpMailUi.toast; const escapePgpMailUi = pgpMailUi.escapeHtml; const pgpApi = () => window.daybreakMail?.pgp; - -function pgpAskPassphrase(title, detail) { - return new Promise(resolve => { - const overlay = document.createElement('div'); - overlay.className = 'modal-overlay pgp-prompt'; - overlay.innerHTML = `
`; - overlay.querySelector('.modal-head span').textContent = title; - overlay.querySelector('.account-note').textContent = detail; - const finish = value => { overlay.remove(); resolve(value); }; - overlay.querySelector('form').onsubmit = event => { - event.preventDefault(); - const value = overlay.querySelector('input').value; - if (value) finish(value); - }; - overlay.querySelector('[data-cancel]').onclick = () => finish(null); - overlay.addEventListener('keydown', event => { if (event.key === 'Escape') { event.stopPropagation(); finish(null); } }); - document.body.append(overlay); - overlay.querySelector('input').focus(); - }); -} - -function pgpFormatFingerprint(value) { - return String(value || '').match(/.{1,4}/g)?.join(' ') || ''; -} - -function pgpSignatureHtml(signatures, encrypted) { - const items = Array.isArray(signatures) ? signatures : []; - const lock = encrypted ? '🔒 Encrypted. ' : ''; - if (!items.length) { - return encrypted ? `
${lock}Not signedThe sender is not authenticated: anyone with your public key could have written this.
` : ''; - } - return items.map(signature => { - const trust = signature.trust === 'verified' ? 'verified key' : signature.trust === 'trusted' ? 'trusted key' : 'key not verified yet'; - const notes = []; - if (signature.keyChanged) notes.push('The sender previously used a different key. Confirm the change with them before trusting this message.'); - if (signature.mismatch) notes.push('The signing key does not belong to the sender address.'); - if (signature.status === 'valid') { - const level = signature.keyChanged || signature.mismatch ? 'bad' : signature.trust === 'unknown' ? 'warn' : 'ok'; + +function pgpAskPassphrase(title, detail) { + return new Promise(resolve => { + const overlay = document.createElement('div'); + overlay.className = 'modal-overlay pgp-prompt'; + overlay.innerHTML = `
`; + overlay.querySelector('.modal-head span').textContent = title; + overlay.querySelector('.account-note').textContent = detail; + const finish = value => { overlay.remove(); resolve(value); }; + overlay.querySelector('form').onsubmit = event => { + event.preventDefault(); + const value = overlay.querySelector('input').value; + if (value) finish(value); + }; + overlay.querySelector('[data-cancel]').onclick = () => finish(null); + overlay.addEventListener('keydown', event => { if (event.key === 'Escape') { event.stopPropagation(); finish(null); } }); + document.body.append(overlay); + overlay.querySelector('input').focus(); + }); +} + +function pgpFormatFingerprint(value) { + return String(value || '').match(/.{1,4}/g)?.join(' ') || ''; +} + +function pgpSignatureHtml(signatures, encrypted) { + const items = Array.isArray(signatures) ? signatures : []; + const lock = encrypted ? '🔒 Encrypted. ' : ''; + if (!items.length) { + return encrypted ? `
${lock}Not signedThe sender is not authenticated: anyone with your public key could have written this.
` : ''; + } + return items.map(signature => { + const trust = signature.trust === 'verified' ? 'verified key' : signature.trust === 'trusted' ? 'trusted key' : 'key not verified yet'; + const notes = []; + if (signature.keyChanged) notes.push('The sender previously used a different key. Confirm the change with them before trusting this message.'); + if (signature.mismatch) notes.push('The signing key does not belong to the sender address.'); + if (signature.status === 'valid') { + const level = signature.keyChanged || signature.mismatch ? 'bad' : signature.trust === 'unknown' ? 'warn' : 'ok'; return `
${lock}Valid signature from ${escapePgpMailUi(signature.email || 'a known key')}${escapePgpMailUi(trust)} · ${escapePgpMailUi(pgpFormatFingerprint(signature.fingerprint))}${notes.map(note => `${escapePgpMailUi(note)}`).join('')}
`; - } - if (signature.status === 'unknown-key') { + } + if (signature.status === 'unknown-key') { return `
${lock}Signed with an unknown keyKey ID ${escapePgpMailUi(signature.keyId)} is not in your contacts, so the signature cannot be checked.${notes.map(note => `${escapePgpMailUi(note)}`).join('')}
`; - } - return ``; - }).join(''); -} - -async function pgpAddAttachedKey(key) { - const emails = key.emails.join(', ') || 'unknown address'; - if (!confirm(`Add this public key for ${emails}?\nFingerprint: ${pgpFormatFingerprint(key.fingerprint)}\n\nCompare the fingerprint with the owner before relying on it.`)) return; - try { - const result = await pgpApi().addContact({ armoredKey: key.armoredKey, source: 'message' }); - toastPgpMailUi(result.keyChangedFrom?.length ? 'Key added. Warning: you already had a different key for this address.' : 'Public key added to your contacts'); - } catch (error) { - toastPgpMailUi(error.message || 'Could not add the key'); - } -} - -function pgpRenderReaderState(message) { - const reader = selectPgpMailUi('#reader-pane'); - const header = reader.querySelector('.reader-header'); - if (!header) return; - reader.querySelectorAll('.pgp-status, .pgp-banner').forEach(node => node.remove()); - let html = ''; - if (message.encrypted && !message.pgpDecrypted) { - html = `
🔒 This message is encryptedUnlock it with your key passphrase to read it.
`; - } else if (message.encrypted) { - html = pgpSignatureHtml(message.pgpResult?.signatures, true); - } else if (message.pgpSignatures) { - html = pgpSignatureHtml(message.pgpSignatures, false); - } - const keys = message.pgpResult?.attachedKeys || []; + } + return ``; + }).join(''); +} + +async function pgpAddAttachedKey(key) { + const emails = key.emails.join(', ') || 'unknown address'; + if (!confirm(`Add this public key for ${emails}?\nFingerprint: ${pgpFormatFingerprint(key.fingerprint)}\n\nCompare the fingerprint with the owner before relying on it.`)) return; + try { + const result = await pgpApi().addContact({ armoredKey: key.armoredKey, source: 'message' }); + toastPgpMailUi(result.keyChangedFrom?.length ? 'Key added. Warning: you already had a different key for this address.' : 'Public key added to your contacts'); + } catch (error) { + toastPgpMailUi(error.message || 'Could not add the key'); + } +} + +function pgpRenderReaderState(message) { + const reader = selectPgpMailUi('#reader-pane'); + const header = reader.querySelector('.reader-header'); + if (!header) return; + reader.querySelectorAll('.pgp-status, .pgp-banner').forEach(node => node.remove()); + let html = ''; + if (message.encrypted && !message.pgpDecrypted) { + html = `
🔒 This message is encryptedUnlock it with your key passphrase to read it.
`; + } else if (message.encrypted) { + html = pgpSignatureHtml(message.pgpResult?.signatures, true); + } else if (message.pgpSignatures) { + html = pgpSignatureHtml(message.pgpSignatures, false); + } + const keys = message.pgpResult?.attachedKeys || []; header.insertAdjacentHTML('afterend', html + keys.map((key, index) => `
Public key attached${escapePgpMailUi(key.emails.join(', ') || 'unknown address')} · ${escapePgpMailUi(pgpFormatFingerprint(key.fingerprint))}
`).join('')); - reader.querySelectorAll('[data-pgp-key]').forEach(button => { - button.onclick = () => pgpAddAttachedKey(keys[Number(button.dataset.pgpKey)]); - }); - const unlock = selectPgpMailUi('#pgp-unlock'); - if (unlock) unlock.onclick = () => pgpUnlockMessage(message, true); -} - -async function pgpUnlockMessage(message, interactive) { - let passphrase = null; - for (let attempt = 0; attempt < 3; attempt += 1) { - let result; - try { - result = await pgpApi().decryptMessage({ folder: message.sourceFolder || 'Inbox', uid: message.uid, passphrase }); - } catch (error) { - toastPgpMailUi(error.message || 'Could not open this message'); - return; - } - if (result.ok) { - Object.assign(message, { - body: result.body, html: result.html, links: result.links, attachments: result.attachments, attachment: result.attachment, size: result.size, - snippet: 'Encrypted message', pgpDecrypted: true, pgpResult: { signatures: result.signatures, attachedKeys: result.attachedKeys } - }); + reader.querySelectorAll('[data-pgp-key]').forEach(button => { + button.onclick = () => pgpAddAttachedKey(keys[Number(button.dataset.pgpKey)]); + }); + const unlock = selectPgpMailUi('#pgp-unlock'); + if (unlock) unlock.onclick = () => pgpUnlockMessage(message, true); +} + +async function pgpUnlockMessage(message, interactive) { + let passphrase = null; + for (let attempt = 0; attempt < 3; attempt += 1) { + let result; + try { + result = await pgpApi().decryptMessage({ folder: message.sourceFolder || 'Inbox', uid: message.uid, passphrase }); + } catch (error) { + toastPgpMailUi(error.message || 'Could not open this message'); + return; + } + if (result.ok) { + Object.assign(message, { + body: result.body, html: result.html, links: result.links, attachments: result.attachments, attachment: result.attachment, size: result.size, + snippet: 'Encrypted message', pgpDecrypted: true, pgpResult: { signatures: result.signatures, attachedKeys: result.attachedKeys } + }); if (pgpMailUi.state.activeMessage === message.id) pgpMailUi.openMessage(message.id); - return; - } - if (result.code === 'PASSPHRASE_REQUIRED' || result.code === 'BAD_PASSPHRASE') { - if (!interactive) { pgpRenderReaderState(message); return; } - passphrase = await pgpAskPassphrase('Unlock encrypted message', result.code === 'BAD_PASSPHRASE' ? 'That passphrase was incorrect. Try again.' : `Enter the passphrase for ${result.email || 'your key'}.`); - if (passphrase === null) return; - continue; - } - const text = selectPgpMailUi('#pgp-banner-text'); - if (text) text.textContent = result.message; - else toastPgpMailUi(result.message); - return; - } -} - + return; + } + if (result.code === 'PASSPHRASE_REQUIRED' || result.code === 'BAD_PASSPHRASE') { + if (!interactive) { pgpRenderReaderState(message); return; } + passphrase = await pgpAskPassphrase('Unlock encrypted message', result.code === 'BAD_PASSPHRASE' ? 'That passphrase was incorrect. Try again.' : `Enter the passphrase for ${result.email || 'your key'}.`); + if (passphrase === null) return; + continue; + } + const text = selectPgpMailUi('#pgp-banner-text'); + if (text) text.textContent = result.message; + else toastPgpMailUi(result.message); + return; + } +} + pgpMailUi.wrapOpenMessage(baseOpenMessage => function (id) { baseOpenMessage(id); const message = pgpMailUi.state.messages.find(item => item.id === id); if (!message || !pgpApi()) return; - pgpRenderReaderState(message); - if (message.encrypted && !message.pgpDecrypted && !message.pgpAutoTried) { - message.pgpAutoTried = true; - void pgpUnlockMessage(message, false); - } + pgpRenderReaderState(message); + if (message.encrypted && !message.pgpDecrypted && !message.pgpAutoTried) { + message.pgpAutoTried = true; + void pgpUnlockMessage(message, false); + } }); // Compose: encrypt/sign options. pgpMailUi.wrapShowCompose(baseShowCompose => function (reply, forward = false) { - baseShowCompose(reply, forward); - const footer = selectPgpMailUi('#modal-root .compose-footer'); - if (!footer || !pgpApi()) return; - const box = document.createElement('div'); - box.className = 'pgp-compose'; - box.innerHTML = ``; - footer.prepend(box); - let touched = false; - const encrypt = selectPgpMailUi('#pgp-encrypt'); - const sign = selectPgpMailUi('#pgp-sign'); - if (reply?.encrypted) { encrypt.checked = true; sign.checked = true; touched = true; } - if (touched) encrypt.dataset.touched = '1'; - encrypt.addEventListener('change', () => { touched = true; encrypt.dataset.touched = '1'; }); - let timer = null; - const refresh = async () => { - const to = selectPgpMailUi('#compose-to')?.value || ''; - const cc = selectPgpMailUi('#compose-cc')?.value || ''; - const hint = selectPgpMailUi('#pgp-hint'); - if (!hint) return; - if (!to.trim()) { hint.textContent = ''; return; } - try { - const status = await pgpApi().checkSend({ to, cc, sign: sign.checked }); - if (!selectPgpMailUi('#pgp-hint')) return; - if (status.missing.length) hint.textContent = `No public key for ${status.missing.join(', ')}`; - else { - hint.textContent = status.recipients.some(item => item.trust === 'unknown') ? 'Keys found; some are not verified yet' : 'Keys found for all recipients'; - if (!touched && !encrypt.checked) encrypt.checked = true; - } - } catch { hint.textContent = ''; } - }; - const schedule = () => { clearTimeout(timer); timer = setTimeout(refresh, 300); }; - ['#compose-to', '#compose-cc'].forEach(selector => selectPgpMailUi(selector)?.addEventListener('input', schedule)); - sign.addEventListener('change', schedule); - schedule(); + baseShowCompose(reply, forward); + const footer = selectPgpMailUi('#modal-root .compose-footer'); + if (!footer || !pgpApi()) return; + const box = document.createElement('div'); + box.className = 'pgp-compose'; + box.innerHTML = ``; + footer.prepend(box); + let touched = false; + const encrypt = selectPgpMailUi('#pgp-encrypt'); + const sign = selectPgpMailUi('#pgp-sign'); + if (reply?.encrypted) { encrypt.checked = true; sign.checked = true; touched = true; } + if (touched) encrypt.dataset.touched = '1'; + encrypt.addEventListener('change', () => { touched = true; encrypt.dataset.touched = '1'; }); + let timer = null; + const refresh = async () => { + const to = selectPgpMailUi('#compose-to')?.value || ''; + const cc = selectPgpMailUi('#compose-cc')?.value || ''; + const hint = selectPgpMailUi('#pgp-hint'); + if (!hint) return; + if (!to.trim()) { hint.textContent = ''; return; } + try { + const status = await pgpApi().checkSend({ to, cc, sign: sign.checked }); + if (!selectPgpMailUi('#pgp-hint')) return; + if (status.missing.length) hint.textContent = `No public key for ${status.missing.join(', ')}`; + else { + hint.textContent = status.recipients.some(item => item.trust === 'unknown') ? 'Keys found; some are not verified yet' : 'Keys found for all recipients'; + if (!touched && !encrypt.checked) encrypt.checked = true; + } + } catch { hint.textContent = ''; } + }; + const schedule = () => { clearTimeout(timer); timer = setTimeout(refresh, 300); }; + ['#compose-to', '#compose-cc'].forEach(selector => selectPgpMailUi(selector)?.addEventListener('input', schedule)); + sign.addEventListener('change', schedule); + schedule(); }); // Called by the send handler. Returns null (plain mail), false (cancelled) or send options. async function prepareSend(to, cc) { - if (!pgpApi()) return null; - let encrypt = Boolean(selectPgpMailUi('#pgp-encrypt')?.checked); - const sign = Boolean(selectPgpMailUi('#pgp-sign')?.checked); - if (!encrypt && !sign && selectPgpMailUi('#pgp-encrypt')?.dataset.touched === '1') return null; - const status = await pgpApi().checkSend({ to, cc, sign }); - // The default-on update is debounced, so a quick send could skip encryption even though keys exist. - if (!encrypt && !status.missing.length && status.recipients.length && selectPgpMailUi('#pgp-encrypt')?.dataset.touched !== '1') { - if (confirm('Public keys are available for all recipients.\n\nSend this message WITHOUT encryption?')) { - if (!sign) return null; - } else return false; - } - if (!encrypt && !sign) return null; - if (encrypt && status.missing.length) { - const sendPlain = confirm(`No public key for ${status.missing.join(', ')}.\n\nThe message cannot be encrypted for everyone. Send it WITHOUT encryption?`); - if (!sendPlain) return false; - encrypt = false; - if (!sign) return null; - } - let passphrase = null; - if (sign) { - if (!status.signer) { toastPgpMailUi('Create or import an encryption key for your address before signing'); return false; } - if (!status.signer.unlocked) { - passphrase = await pgpAskPassphrase('Sign message', `Enter the passphrase for ${status.signer.email} to sign this message.`); - if (passphrase === null) return false; - } + if (!pgpApi()) return null; + let encrypt = Boolean(selectPgpMailUi('#pgp-encrypt')?.checked); + const sign = Boolean(selectPgpMailUi('#pgp-sign')?.checked); + if (!encrypt && !sign && selectPgpMailUi('#pgp-encrypt')?.dataset.touched === '1') return null; + const status = await pgpApi().checkSend({ to, cc, sign }); + // The default-on update is debounced, so a quick send could skip encryption even though keys exist. + if (!encrypt && !status.missing.length && status.recipients.length && selectPgpMailUi('#pgp-encrypt')?.dataset.touched !== '1') { + if (confirm('Public keys are available for all recipients.\n\nSend this message WITHOUT encryption?')) { + if (!sign) return null; + } else return false; + } + if (!encrypt && !sign) return null; + if (encrypt && status.missing.length) { + const sendPlain = confirm(`No public key for ${status.missing.join(', ')}.\n\nThe message cannot be encrypted for everyone. Send it WITHOUT encryption?`); + if (!sendPlain) return false; + encrypt = false; + if (!sign) return null; + } + let passphrase = null; + if (sign) { + if (!status.signer) { toastPgpMailUi('Create or import an encryption key for your address before signing'); return false; } + if (!status.signer.unlocked) { + passphrase = await pgpAskPassphrase('Sign message', `Enter the passphrase for ${status.signer.email} to sign this message.`); + if (passphrase === null) return false; + } } return { encrypt, sign, passphrase }; } diff --git a/www/pgp-ui.js b/www/pgp-ui.js index c83e670..474e727 100644 --- a/www/pgp-ui.js +++ b/www/pgp-ui.js @@ -6,418 +6,418 @@ const selectAllPgpKeyUi = pgpKeyMailUi.selectAll; const escapePgpKeyUi = pgpKeyMailUi.escapeHtml; const toastPgpKeyUi = pgpKeyMailUi.toast; function pgpAvailable() { return Boolean(window.daybreakMail?.pgp); } - -function openEncryptionKeys() { - const root = selectPgpKeyUi('#modal-root'); + +function openEncryptionKeys() { + const root = selectPgpKeyUi('#modal-root'); const account = window.epMailFeatures.mail.connectedAccount || {}; - root.innerHTML = ``; - const close = () => { root.innerHTML = ''; }; - root.querySelector('.modal-close').onclick = close; - root.querySelector('.modal-overlay').onclick = event => { if (event.target.classList.contains('modal-overlay')) close(); }; - const status = message => { selectPgpKeyUi('#pgp-status').textContent = message; }; - const passphraseField = () => selectPgpKeyUi('#pgp-passphrase'); - let keyServers = []; - const selectedPublishServer = () => keyServers.find(server => server.id === selectPgpKeyUi('#pgp-publish-server').value && server.enabled); - const updatePublishButtons = () => { - const server = selectedPublishServer(); - selectAllPgpKeyUi('.pgp-publish').forEach(button => { - button.disabled = !server; - button.textContent = server ? `Publish to ${server.name}…` : 'Enable a server to publish…'; - }); - }; - const needPassphrase = () => { - const value = passphraseField().value; - if (!value) { status('Enter the key passphrase in the Passphrase field first.'); passphraseField().focus(); } - return value; - }; - - async function render() { - const list = selectPgpKeyUi('#pgp-key-list'); - let keys = []; - try { keys = await window.daybreakMail.pgp.list(); } catch (error) { list.textContent = error.message || 'Could not load keys.'; return; } - list.replaceChildren(); - if (!keys.length) { list.textContent = 'No keys yet.'; return; } - keys.forEach(key => { - const row = document.createElement('div'); - row.className = 'attachment-row'; - const info = document.createElement('div'); - info.className = 'attachment-row-info'; - const title = document.createElement('strong'); - title.textContent = key.email || 'OpenPGP key'; - const meta = document.createElement('small'); - meta.textContent = `${key.name ? key.name + ' · ' : ''}${key.algorithm} · ${new Date(key.createdAt).toLocaleDateString()}`; - const fingerprint = document.createElement('small'); - fingerprint.textContent = `Fingerprint: ${key.fingerprint.match(/.{1,4}/g).join(' ')}`; - info.append(title, meta, fingerprint); - row.append(info); - const actions = [ - ['Export public', () => window.daybreakMail.pgp.exportPublic(key.fingerprint), false], - ['Export private', () => window.daybreakMail.pgp.exportPrivate(key.fingerprint, needPassphrase()), true] - ]; - const changePassphrase = document.createElement('button'); - changePassphrase.className = 'discard'; - changePassphrase.textContent = 'Change passphrase…'; - changePassphrase.onclick = async () => { - const currentPassphrase = selectPgpKeyUi('#pgp-change-current-passphrase').value; - if (!currentPassphrase) { - status('Enter the current passphrase for this key.'); - selectPgpKeyUi('#pgp-change-current-passphrase').focus(); - return; - } - const newPassphrase = selectPgpKeyUi('#pgp-new-passphrase').value; - if (newPassphrase.length < 8) { - status('Use a new passphrase of at least 8 characters.'); - selectPgpKeyUi('#pgp-new-passphrase').focus(); - return; - } - if (newPassphrase !== selectPgpKeyUi('#pgp-confirm-passphrase').value) { - status('The new passphrases do not match.'); - selectPgpKeyUi('#pgp-confirm-passphrase').focus(); - return; - } - changePassphrase.disabled = true; - try { - await window.daybreakMail.pgp.changePassphrase({ - fingerprint: key.fingerprint, - currentPassphrase, - newPassphrase - }); - selectPgpKeyUi('#pgp-change-current-passphrase').value = ''; - status(`Passphrase changed for ${key.email || key.fingerprint}.`); - } catch (error) { status(error.message || 'Could not change the key passphrase.'); } - finally { - selectPgpKeyUi('#pgp-new-passphrase').value = ''; - selectPgpKeyUi('#pgp-confirm-passphrase').value = ''; - changePassphrase.disabled = false; - } - }; - row.append(changePassphrase); - if (key.hasRevocationCertificate) actions.push(['Revocation cert.', () => window.daybreakMail.pgp.exportRevocation(key.fingerprint, needPassphrase()), true]); - actions.push(['Delete', async () => { - if (!confirm('Delete this key? Encrypted mail that needs it can no longer be read unless you have a backup.')) return { canceled: true }; - await window.daybreakMail.pgp.remove(key.fingerprint, needPassphrase()); - await render(); - return { deleted: true }; - }, true]); - actions.forEach(([label, run, secret]) => { - const button = document.createElement('button'); - button.className = 'discard'; - button.textContent = label; - button.onclick = async () => { - if (secret && !passphraseField().value) { needPassphrase(); return; } - try { - const result = await run(); - status(result?.saved ? 'File saved.' : result?.deleted ? 'Key deleted.' : ''); - } catch (error) { status(error.message || 'That action failed.'); } - }; - row.append(button); - }); - const publish = document.createElement('button'); - publish.className = 'discard pgp-publish'; - publish.onclick = async () => { - const server = selectedPublishServer(); - if (!server) { status('Enable a key server and select it as the publication target first.'); return; } - publish.disabled = true; - try { - const result = await window.daybreakMail.pgp.publishKey({ fingerprint: key.fingerprint, serverId: server.id }); - if (result.canceled) return; - if (result.warning) status(result.warning); - else if (result.verification === 'pending' || result.verification === 'requested') status(`Uploaded to ${server.name}. Check ${key.email || 'your email'} for a verification message before the key becomes searchable.`); - else if (result.verification === 'published') status(`The key is already published and searchable on ${server.name}.`); - else if (result.verification === 'request-failed') status('The key was uploaded, but the server could not request email verification.'); - else if (result.verification === 'check-email') status(`${server.name} accepted the key. Check ${key.email || 'your email'} for its verification message. ${result.message || ''}`.trim()); - else status(`${server.name} accepted the key. ${result.message || ''}`.trim()); - } catch (error) { status(error.message || 'Could not publish the public key.'); } - finally { updatePublishButtons(); } - }; - row.append(publish); - list.append(row); - }); - updatePublishButtons(); - } - - selectPgpKeyUi('#pgp-generate').onclick = async () => { - const button = selectPgpKeyUi('#pgp-generate'); - button.disabled = true; - status('Creating key…'); - try { - await window.daybreakMail.pgp.generate({ - name: selectPgpKeyUi('#pgp-name').value, email: selectPgpKeyUi('#pgp-email').value, passphrase: passphraseField().value, accountId: account.id || null - }); - status('Key created. Export your private key and revocation certificate now and keep them safe.'); - await render(); - } catch (error) { status(error.message || 'Could not create the key.'); } - button.disabled = false; - }; - selectPgpKeyUi('#pgp-import').onclick = async () => { - const passphrase = needPassphrase(); - if (!passphrase) return; - try { - const result = await window.daybreakMail.pgp.importKey({ passphrase, accountId: account.id || null }); - status(result.canceled ? '' : 'Key imported.'); - await render(); - } catch (error) { status(error.message || 'Could not import the key.'); } - }; - async function renderContacts() { - const list = selectPgpKeyUi('#pgp-contact-list'); - let contacts = []; - try { contacts = await window.daybreakMail.pgp.contacts(); } catch (error) { list.textContent = error.message || 'Could not load contacts.'; return; } - list.replaceChildren(); - if (!contacts.length) { list.textContent = 'No contact keys yet. Import a public key, or add one from a received message.'; return; } - contacts.forEach(contact => { - const row = document.createElement('div'); - row.className = 'attachment-row'; - const info = document.createElement('div'); - info.className = 'attachment-row-info'; - const title = document.createElement('strong'); - title.textContent = contact.emails.join(', ') || contact.name || 'Public key'; - const meta = document.createElement('small'); - meta.textContent = `${contact.name ? contact.name + ' · ' : ''}added ${new Date(contact.addedAt).toLocaleDateString()} · from ${contact.source}`; - const fingerprint = document.createElement('small'); - fingerprint.textContent = `Fingerprint: ${contact.fingerprint.match(/.{1,4}/g).join(' ')}`; - info.append(title, meta, fingerprint); - const trust = document.createElement('select'); - trust.className = 'pgp-trust'; - trust.setAttribute('aria-label', 'Key trust'); - [['unknown', 'Not verified'], ['trusted', 'Trusted'], ['verified', 'Verified (fingerprint checked)']].forEach(([value, label]) => { - const option = document.createElement('option'); - option.value = value; option.textContent = label; option.selected = contact.trust === value; - trust.append(option); - }); - trust.onchange = async () => { - if (trust.value === 'verified' && !confirm(`Mark this key as verified only if you compared this fingerprint with its owner through another channel:\n\n${contact.fingerprint.match(/.{1,4}/g).join(' ')}`)) { - trust.value = contact.trust; - return; - } - try { await window.daybreakMail.pgp.setTrust(contact.fingerprint, trust.value); contact.trust = trust.value; status('Trust updated.'); } - catch (error) { trust.value = contact.trust; status(error.message || 'Could not update trust.'); } - }; - const actions = [ - ['Export', () => window.daybreakMail.pgp.exportContact(contact.fingerprint)], - ['Remove', async () => { - if (!confirm('Remove this contact key? You will no longer be able to encrypt to it.')) return { canceled: true }; - await window.daybreakMail.pgp.removeContact(contact.fingerprint); - await renderContacts(); - return { deleted: true }; - }] - ]; - row.append(info, trust); - actions.forEach(([label, run]) => { - const button = document.createElement('button'); - button.className = 'discard'; - button.textContent = label; - button.onclick = async () => { - try { const result = await run(); status(result?.saved ? 'File saved.' : result?.deleted ? 'Contact key removed.' : ''); } - catch (error) { status(error.message || 'That action failed.'); } - }; - row.append(button); - }); - list.append(row); - }); - } - - selectPgpKeyUi('#pgp-add-contact').onclick = async () => { - try { - const result = await window.daybreakMail.pgp.addContact({}); - if (!result.canceled) status(result.keyChangedFrom?.length ? 'Key added. Warning: you already had a different key for this address. Verify the new fingerprint.' : 'Public key added. Verify its fingerprint with the owner, then mark it as verified.'); - await renderContacts(); - } catch (error) { status(error.message || 'Could not import the key.'); } - }; - async function renderKeyServers() { - const list = selectPgpKeyUi('#pgp-server-list'); - const selector = selectPgpKeyUi('#pgp-publish-server'); - const selectedId = selector.value; - try { keyServers = await window.daybreakMail.pgp.keyServers(); } - catch (error) { list.textContent = error.message || 'Could not load key servers.'; return; } - selector.replaceChildren(); - const enabledServers = keyServers.filter(server => server.enabled); - if (!enabledServers.length) { - const option = document.createElement('option'); - option.value = ''; - option.textContent = 'No enabled servers'; - selector.append(option); - } else enabledServers.forEach(server => { - const option = document.createElement('option'); - option.value = server.id; - option.textContent = `${server.name} (${server.protocol.toUpperCase()})`; - option.selected = server.id === selectedId; - selector.append(option); - }); - if (selectedId && !enabledServers.some(server => server.id === selectedId)) selector.selectedIndex = 0; - selector.onchange = updatePublishButtons; - list.replaceChildren(); - keyServers.forEach(server => { - const row = document.createElement('div'); - row.className = 'attachment-row'; - const info = document.createElement('div'); - info.className = 'attachment-row-info'; - const title = document.createElement('strong'); - title.textContent = server.name; - const details = document.createElement('small'); - details.textContent = `${server.protocol.toUpperCase()} · ${server.url}${server.builtin ? ' · built in' : ' · custom'}`; - info.append(title, details); - const enabledLabel = document.createElement('label'); - enabledLabel.className = 'compose-line'; - const enabledText = document.createElement('span'); - enabledText.textContent = 'Use for lookup and publishing'; - const enabled = document.createElement('input'); - enabled.type = 'checkbox'; - enabled.checked = server.enabled; - enabled.setAttribute('aria-label', `${server.name} enabled`); - enabled.onchange = async () => { - enabled.disabled = true; - try { - await window.daybreakMail.pgp.setKeyServerEnabled(server.id, enabled.checked); - await renderKeyServers(); - status(`${server.name} ${enabled.checked ? 'enabled' : 'disabled'}.`); - } catch (error) { - enabled.checked = server.enabled; - status(error.message || `Could not update ${server.name}.`); - } finally { enabled.disabled = false; } - }; - enabledLabel.append(enabledText, enabled); - row.append(info, enabledLabel); - if (!server.builtin) { - const remove = document.createElement('button'); - remove.className = 'discard'; - remove.textContent = 'Remove'; - remove.onclick = async () => { - try { - await window.daybreakMail.pgp.removeKeyServer(server.id); - await renderKeyServers(); - status('Custom key server removed.'); - } catch (error) { status(error.message || 'Could not remove the key server.'); } - }; - row.append(remove); - } - list.append(row); - }); - } - selectPgpKeyUi('#pgp-find-key').onclick = async () => { - const button = selectPgpKeyUi('#pgp-find-key'); - const results = selectPgpKeyUi('#pgp-found-keys'); - button.disabled = true; - results.textContent = 'Searching…'; - try { - const found = await window.daybreakMail.pgp.findKey({ - email: selectPgpKeyUi('#pgp-search-email').value - }); - results.replaceChildren(); - found.keys.forEach(key => { - const row = document.createElement('div'); - row.className = 'attachment-row'; - const info = document.createElement('div'); - info.className = 'attachment-row-info'; - const title = document.createElement('strong'); - title.textContent = key.emails.join(', ') || key.name || 'Public key'; - const meta = document.createElement('small'); - meta.textContent = `Found on ${key.sources.join(', ')} · not verified`; - const fingerprint = document.createElement('small'); - fingerprint.textContent = `Fingerprint: ${key.fingerprint.match(/.{1,4}/g).join(' ')}`; - info.append(title, meta, fingerprint); - const add = document.createElement('button'); - add.className = 'discard'; - add.textContent = 'Add to contacts…'; - add.onclick = async () => { - add.disabled = true; - try { - const result = await window.daybreakMail.pgp.addContact({ armoredKey: key.armoredKey, source: 'keyserver' }); - if (result.canceled) return; - status(result.keyChangedFrom?.length ? 'Key added. You already had another key for this address; compare fingerprints before trusting either key.' : 'Key added as unverified. Compare its fingerprint with the owner before trusting it.'); - await renderContacts(); - row.remove(); - } catch (error) { status(error.message || 'Could not add the public key.'); } - finally { add.disabled = false; } - }; - row.append(info, add); - results.append(row); - }); - found.errors.forEach(error => { - const warning = document.createElement('small'); - warning.textContent = `${error.name}: ${error.message}`; - results.append(warning); - }); - if (!found.keys.length && !found.errors.length) results.textContent = 'No matching public key was found on the enabled servers.'; - if (found.keys.length) status(`Found ${found.keys.length} public key(s) on ${found.searchedServers.map(server => server.name).join(', ')}. They remain unverified until you check their fingerprints independently.${found.errors.length ? ` ${found.errors.length} server(s) could not be searched; see details above.` : ''}`); - else if (found.errors.length) status(`No key results; ${found.errors.length} enabled server(s) could not be searched. See details above.`); - else status(`No matching key found across ${found.searchedServers.length} enabled server(s).`); - } catch (error) { - results.textContent = ''; - status(error.message || 'Could not search the key server.'); - } finally { button.disabled = false; } - }; - selectPgpKeyUi('#pgp-add-server').onclick = async () => { - const button = selectPgpKeyUi('#pgp-add-server'); - button.disabled = true; - try { - const result = await window.daybreakMail.pgp.addKeyServer({ - name: selectPgpKeyUi('#pgp-server-name').value, - url: selectPgpKeyUi('#pgp-server-url').value, - protocol: selectPgpKeyUi('#pgp-server-protocol').value - }); - if (result.canceled) return; - selectPgpKeyUi('#pgp-server-name').value = ''; - selectPgpKeyUi('#pgp-server-url').value = ''; - await renderKeyServers(); - status('Custom key server added.'); - } catch (error) { status(error.message || 'Could not add the key server.'); } - finally { button.disabled = false; } - }; - window.daybreakMail.pgp.getSettings().then(settings => { selectPgpKeyUi('#pgp-cache-minutes').value = settings.cacheMinutes; }).catch(() => {}); - selectPgpKeyUi('#pgp-save-cache').onclick = async () => { - try { const settings = await window.daybreakMail.pgp.setSettings({ cacheMinutes: Number(selectPgpKeyUi('#pgp-cache-minutes').value) }); status(`Passphrases are remembered for ${settings.cacheMinutes} minute(s).`); } - 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.'); }; - void renderKeyServers(); - void renderContacts(); - void render(); -} - + root.innerHTML = ``; + const close = () => { root.innerHTML = ''; }; + root.querySelector('.modal-close').onclick = close; + root.querySelector('.modal-overlay').onclick = event => { if (event.target.classList.contains('modal-overlay')) close(); }; + const status = message => { selectPgpKeyUi('#pgp-status').textContent = message; }; + const passphraseField = () => selectPgpKeyUi('#pgp-passphrase'); + let keyServers = []; + const selectedPublishServer = () => keyServers.find(server => server.id === selectPgpKeyUi('#pgp-publish-server').value && server.enabled); + const updatePublishButtons = () => { + const server = selectedPublishServer(); + selectAllPgpKeyUi('.pgp-publish').forEach(button => { + button.disabled = !server; + button.textContent = server ? `Publish to ${server.name}…` : 'Enable a server to publish…'; + }); + }; + const needPassphrase = () => { + const value = passphraseField().value; + if (!value) { status('Enter the key passphrase in the Passphrase field first.'); passphraseField().focus(); } + return value; + }; + + async function render() { + const list = selectPgpKeyUi('#pgp-key-list'); + let keys = []; + try { keys = await window.daybreakMail.pgp.list(); } catch (error) { list.textContent = error.message || 'Could not load keys.'; return; } + list.replaceChildren(); + if (!keys.length) { list.textContent = 'No keys yet.'; return; } + keys.forEach(key => { + const row = document.createElement('div'); + row.className = 'attachment-row'; + const info = document.createElement('div'); + info.className = 'attachment-row-info'; + const title = document.createElement('strong'); + title.textContent = key.email || 'OpenPGP key'; + const meta = document.createElement('small'); + meta.textContent = `${key.name ? key.name + ' · ' : ''}${key.algorithm} · ${new Date(key.createdAt).toLocaleDateString()}`; + const fingerprint = document.createElement('small'); + fingerprint.textContent = `Fingerprint: ${key.fingerprint.match(/.{1,4}/g).join(' ')}`; + info.append(title, meta, fingerprint); + row.append(info); + const actions = [ + ['Export public', () => window.daybreakMail.pgp.exportPublic(key.fingerprint), false], + ['Export private', () => window.daybreakMail.pgp.exportPrivate(key.fingerprint, needPassphrase()), true] + ]; + const changePassphrase = document.createElement('button'); + changePassphrase.className = 'discard'; + changePassphrase.textContent = 'Change passphrase…'; + changePassphrase.onclick = async () => { + const currentPassphrase = selectPgpKeyUi('#pgp-change-current-passphrase').value; + if (!currentPassphrase) { + status('Enter the current passphrase for this key.'); + selectPgpKeyUi('#pgp-change-current-passphrase').focus(); + return; + } + const newPassphrase = selectPgpKeyUi('#pgp-new-passphrase').value; + if (newPassphrase.length < 8) { + status('Use a new passphrase of at least 8 characters.'); + selectPgpKeyUi('#pgp-new-passphrase').focus(); + return; + } + if (newPassphrase !== selectPgpKeyUi('#pgp-confirm-passphrase').value) { + status('The new passphrases do not match.'); + selectPgpKeyUi('#pgp-confirm-passphrase').focus(); + return; + } + changePassphrase.disabled = true; + try { + await window.daybreakMail.pgp.changePassphrase({ + fingerprint: key.fingerprint, + currentPassphrase, + newPassphrase + }); + selectPgpKeyUi('#pgp-change-current-passphrase').value = ''; + status(`Passphrase changed for ${key.email || key.fingerprint}.`); + } catch (error) { status(error.message || 'Could not change the key passphrase.'); } + finally { + selectPgpKeyUi('#pgp-new-passphrase').value = ''; + selectPgpKeyUi('#pgp-confirm-passphrase').value = ''; + changePassphrase.disabled = false; + } + }; + row.append(changePassphrase); + if (key.hasRevocationCertificate) actions.push(['Revocation cert.', () => window.daybreakMail.pgp.exportRevocation(key.fingerprint, needPassphrase()), true]); + actions.push(['Delete', async () => { + if (!confirm('Delete this key? Encrypted mail that needs it can no longer be read unless you have a backup.')) return { canceled: true }; + await window.daybreakMail.pgp.remove(key.fingerprint, needPassphrase()); + await render(); + return { deleted: true }; + }, true]); + actions.forEach(([label, run, secret]) => { + const button = document.createElement('button'); + button.className = 'discard'; + button.textContent = label; + button.onclick = async () => { + if (secret && !passphraseField().value) { needPassphrase(); return; } + try { + const result = await run(); + status(result?.saved ? 'File saved.' : result?.deleted ? 'Key deleted.' : ''); + } catch (error) { status(error.message || 'That action failed.'); } + }; + row.append(button); + }); + const publish = document.createElement('button'); + publish.className = 'discard pgp-publish'; + publish.onclick = async () => { + const server = selectedPublishServer(); + if (!server) { status('Enable a key server and select it as the publication target first.'); return; } + publish.disabled = true; + try { + const result = await window.daybreakMail.pgp.publishKey({ fingerprint: key.fingerprint, serverId: server.id }); + if (result.canceled) return; + if (result.warning) status(result.warning); + else if (result.verification === 'pending' || result.verification === 'requested') status(`Uploaded to ${server.name}. Check ${key.email || 'your email'} for a verification message before the key becomes searchable.`); + else if (result.verification === 'published') status(`The key is already published and searchable on ${server.name}.`); + else if (result.verification === 'request-failed') status('The key was uploaded, but the server could not request email verification.'); + else if (result.verification === 'check-email') status(`${server.name} accepted the key. Check ${key.email || 'your email'} for its verification message. ${result.message || ''}`.trim()); + else status(`${server.name} accepted the key. ${result.message || ''}`.trim()); + } catch (error) { status(error.message || 'Could not publish the public key.'); } + finally { updatePublishButtons(); } + }; + row.append(publish); + list.append(row); + }); + updatePublishButtons(); + } + + selectPgpKeyUi('#pgp-generate').onclick = async () => { + const button = selectPgpKeyUi('#pgp-generate'); + button.disabled = true; + status('Creating key…'); + try { + await window.daybreakMail.pgp.generate({ + name: selectPgpKeyUi('#pgp-name').value, email: selectPgpKeyUi('#pgp-email').value, passphrase: passphraseField().value, accountId: account.id || null + }); + status('Key created. Export your private key and revocation certificate now and keep them safe.'); + await render(); + } catch (error) { status(error.message || 'Could not create the key.'); } + button.disabled = false; + }; + selectPgpKeyUi('#pgp-import').onclick = async () => { + const passphrase = needPassphrase(); + if (!passphrase) return; + try { + const result = await window.daybreakMail.pgp.importKey({ passphrase, accountId: account.id || null }); + status(result.canceled ? '' : 'Key imported.'); + await render(); + } catch (error) { status(error.message || 'Could not import the key.'); } + }; + async function renderContacts() { + const list = selectPgpKeyUi('#pgp-contact-list'); + let contacts = []; + try { contacts = await window.daybreakMail.pgp.contacts(); } catch (error) { list.textContent = error.message || 'Could not load contacts.'; return; } + list.replaceChildren(); + if (!contacts.length) { list.textContent = 'No contact keys yet. Import a public key, or add one from a received message.'; return; } + contacts.forEach(contact => { + const row = document.createElement('div'); + row.className = 'attachment-row'; + const info = document.createElement('div'); + info.className = 'attachment-row-info'; + const title = document.createElement('strong'); + title.textContent = contact.emails.join(', ') || contact.name || 'Public key'; + const meta = document.createElement('small'); + meta.textContent = `${contact.name ? contact.name + ' · ' : ''}added ${new Date(contact.addedAt).toLocaleDateString()} · from ${contact.source}`; + const fingerprint = document.createElement('small'); + fingerprint.textContent = `Fingerprint: ${contact.fingerprint.match(/.{1,4}/g).join(' ')}`; + info.append(title, meta, fingerprint); + const trust = document.createElement('select'); + trust.className = 'pgp-trust'; + trust.setAttribute('aria-label', 'Key trust'); + [['unknown', 'Not verified'], ['trusted', 'Trusted'], ['verified', 'Verified (fingerprint checked)']].forEach(([value, label]) => { + const option = document.createElement('option'); + option.value = value; option.textContent = label; option.selected = contact.trust === value; + trust.append(option); + }); + trust.onchange = async () => { + if (trust.value === 'verified' && !confirm(`Mark this key as verified only if you compared this fingerprint with its owner through another channel:\n\n${contact.fingerprint.match(/.{1,4}/g).join(' ')}`)) { + trust.value = contact.trust; + return; + } + try { await window.daybreakMail.pgp.setTrust(contact.fingerprint, trust.value); contact.trust = trust.value; status('Trust updated.'); } + catch (error) { trust.value = contact.trust; status(error.message || 'Could not update trust.'); } + }; + const actions = [ + ['Export', () => window.daybreakMail.pgp.exportContact(contact.fingerprint)], + ['Remove', async () => { + if (!confirm('Remove this contact key? You will no longer be able to encrypt to it.')) return { canceled: true }; + await window.daybreakMail.pgp.removeContact(contact.fingerprint); + await renderContacts(); + return { deleted: true }; + }] + ]; + row.append(info, trust); + actions.forEach(([label, run]) => { + const button = document.createElement('button'); + button.className = 'discard'; + button.textContent = label; + button.onclick = async () => { + try { const result = await run(); status(result?.saved ? 'File saved.' : result?.deleted ? 'Contact key removed.' : ''); } + catch (error) { status(error.message || 'That action failed.'); } + }; + row.append(button); + }); + list.append(row); + }); + } + + selectPgpKeyUi('#pgp-add-contact').onclick = async () => { + try { + const result = await window.daybreakMail.pgp.addContact({}); + if (!result.canceled) status(result.keyChangedFrom?.length ? 'Key added. Warning: you already had a different key for this address. Verify the new fingerprint.' : 'Public key added. Verify its fingerprint with the owner, then mark it as verified.'); + await renderContacts(); + } catch (error) { status(error.message || 'Could not import the key.'); } + }; + async function renderKeyServers() { + const list = selectPgpKeyUi('#pgp-server-list'); + const selector = selectPgpKeyUi('#pgp-publish-server'); + const selectedId = selector.value; + try { keyServers = await window.daybreakMail.pgp.keyServers(); } + catch (error) { list.textContent = error.message || 'Could not load key servers.'; return; } + selector.replaceChildren(); + const enabledServers = keyServers.filter(server => server.enabled); + if (!enabledServers.length) { + const option = document.createElement('option'); + option.value = ''; + option.textContent = 'No enabled servers'; + selector.append(option); + } else enabledServers.forEach(server => { + const option = document.createElement('option'); + option.value = server.id; + option.textContent = `${server.name} (${server.protocol.toUpperCase()})`; + option.selected = server.id === selectedId; + selector.append(option); + }); + if (selectedId && !enabledServers.some(server => server.id === selectedId)) selector.selectedIndex = 0; + selector.onchange = updatePublishButtons; + list.replaceChildren(); + keyServers.forEach(server => { + const row = document.createElement('div'); + row.className = 'attachment-row'; + const info = document.createElement('div'); + info.className = 'attachment-row-info'; + const title = document.createElement('strong'); + title.textContent = server.name; + const details = document.createElement('small'); + details.textContent = `${server.protocol.toUpperCase()} · ${server.url}${server.builtin ? ' · built in' : ' · custom'}`; + info.append(title, details); + const enabledLabel = document.createElement('label'); + enabledLabel.className = 'compose-line'; + const enabledText = document.createElement('span'); + enabledText.textContent = 'Use for lookup and publishing'; + const enabled = document.createElement('input'); + enabled.type = 'checkbox'; + enabled.checked = server.enabled; + enabled.setAttribute('aria-label', `${server.name} enabled`); + enabled.onchange = async () => { + enabled.disabled = true; + try { + await window.daybreakMail.pgp.setKeyServerEnabled(server.id, enabled.checked); + await renderKeyServers(); + status(`${server.name} ${enabled.checked ? 'enabled' : 'disabled'}.`); + } catch (error) { + enabled.checked = server.enabled; + status(error.message || `Could not update ${server.name}.`); + } finally { enabled.disabled = false; } + }; + enabledLabel.append(enabledText, enabled); + row.append(info, enabledLabel); + if (!server.builtin) { + const remove = document.createElement('button'); + remove.className = 'discard'; + remove.textContent = 'Remove'; + remove.onclick = async () => { + try { + await window.daybreakMail.pgp.removeKeyServer(server.id); + await renderKeyServers(); + status('Custom key server removed.'); + } catch (error) { status(error.message || 'Could not remove the key server.'); } + }; + row.append(remove); + } + list.append(row); + }); + } + selectPgpKeyUi('#pgp-find-key').onclick = async () => { + const button = selectPgpKeyUi('#pgp-find-key'); + const results = selectPgpKeyUi('#pgp-found-keys'); + button.disabled = true; + results.textContent = 'Searching…'; + try { + const found = await window.daybreakMail.pgp.findKey({ + email: selectPgpKeyUi('#pgp-search-email').value + }); + results.replaceChildren(); + found.keys.forEach(key => { + const row = document.createElement('div'); + row.className = 'attachment-row'; + const info = document.createElement('div'); + info.className = 'attachment-row-info'; + const title = document.createElement('strong'); + title.textContent = key.emails.join(', ') || key.name || 'Public key'; + const meta = document.createElement('small'); + meta.textContent = `Found on ${key.sources.join(', ')} · not verified`; + const fingerprint = document.createElement('small'); + fingerprint.textContent = `Fingerprint: ${key.fingerprint.match(/.{1,4}/g).join(' ')}`; + info.append(title, meta, fingerprint); + const add = document.createElement('button'); + add.className = 'discard'; + add.textContent = 'Add to contacts…'; + add.onclick = async () => { + add.disabled = true; + try { + const result = await window.daybreakMail.pgp.addContact({ armoredKey: key.armoredKey, source: 'keyserver' }); + if (result.canceled) return; + status(result.keyChangedFrom?.length ? 'Key added. You already had another key for this address; compare fingerprints before trusting either key.' : 'Key added as unverified. Compare its fingerprint with the owner before trusting it.'); + await renderContacts(); + row.remove(); + } catch (error) { status(error.message || 'Could not add the public key.'); } + finally { add.disabled = false; } + }; + row.append(info, add); + results.append(row); + }); + found.errors.forEach(error => { + const warning = document.createElement('small'); + warning.textContent = `${error.name}: ${error.message}`; + results.append(warning); + }); + if (!found.keys.length && !found.errors.length) results.textContent = 'No matching public key was found on the enabled servers.'; + if (found.keys.length) status(`Found ${found.keys.length} public key(s) on ${found.searchedServers.map(server => server.name).join(', ')}. They remain unverified until you check their fingerprints independently.${found.errors.length ? ` ${found.errors.length} server(s) could not be searched; see details above.` : ''}`); + else if (found.errors.length) status(`No key results; ${found.errors.length} enabled server(s) could not be searched. See details above.`); + else status(`No matching key found across ${found.searchedServers.length} enabled server(s).`); + } catch (error) { + results.textContent = ''; + status(error.message || 'Could not search the key server.'); + } finally { button.disabled = false; } + }; + selectPgpKeyUi('#pgp-add-server').onclick = async () => { + const button = selectPgpKeyUi('#pgp-add-server'); + button.disabled = true; + try { + const result = await window.daybreakMail.pgp.addKeyServer({ + name: selectPgpKeyUi('#pgp-server-name').value, + url: selectPgpKeyUi('#pgp-server-url').value, + protocol: selectPgpKeyUi('#pgp-server-protocol').value + }); + if (result.canceled) return; + selectPgpKeyUi('#pgp-server-name').value = ''; + selectPgpKeyUi('#pgp-server-url').value = ''; + await renderKeyServers(); + status('Custom key server added.'); + } catch (error) { status(error.message || 'Could not add the key server.'); } + finally { button.disabled = false; } + }; + window.daybreakMail.pgp.getSettings().then(settings => { selectPgpKeyUi('#pgp-cache-minutes').value = settings.cacheMinutes; }).catch(() => {}); + selectPgpKeyUi('#pgp-save-cache').onclick = async () => { + try { const settings = await window.daybreakMail.pgp.setSettings({ cacheMinutes: Number(selectPgpKeyUi('#pgp-cache-minutes').value) }); status(`Passphrases are remembered for ${settings.cacheMinutes} minute(s).`); } + 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.'); }; + void renderKeyServers(); + void renderContacts(); + void render(); +} + window.epMailFeatures.productivity.wrapOpenPreferences(baseOpenPreferences => function () { baseOpenPreferences(); - const fields = selectPgpKeyUi('#modal-root .compose-fields'); - if (!fields || !pgpAvailable()) return; - const button = document.createElement('button'); - button.type = 'button'; - button.className = 'discard'; - button.id = 'open-encryption-keys'; - button.textContent = 'Encryption keys…'; - button.onclick = openEncryptionKeys; - fields.append(button); + const fields = selectPgpKeyUi('#modal-root .compose-fields'); + if (!fields || !pgpAvailable()) return; + const button = document.createElement('button'); + button.type = 'button'; + button.className = 'discard'; + button.id = 'open-encryption-keys'; + button.textContent = 'Encryption keys…'; + button.onclick = openEncryptionKeys; + fields.append(button); }); })(); diff --git a/www/productivity.js b/www/productivity.js index 3c3c8ff..45dbd12 100644 --- a/www/productivity.js +++ b/www/productivity.js @@ -6,50 +6,50 @@ const selectAllProductivityUi = productivityMailUi.selectAll; const toastProductivityUi = productivityMailUi.toast; const escapeProductivityUi = productivityMailUi.escapeHtml; const productKeys = { profile: 'daybreak-profile', events: 'daybreak-events', contacts: 'daybreak-contacts', labels: 'daybreak-labels', snoozed: 'daybreak-snoozed' }; -const productRead = (key, fallback) => { try { const value = JSON.parse(localStorage.getItem(key)); return value ?? fallback; } catch { return fallback; } }; -const productWrite = (key, value) => localStorage.setItem(key, JSON.stringify(value)); -let profileSettings = productRead(productKeys.profile, { name: '' }); -if (/^mira(\s+sol)?$/i.test(profileSettings.name || '')) { profileSettings = { name: '' }; localStorage.removeItem(productKeys.profile); } -let calendarMonth = new Date(new Date().getFullYear(), new Date().getMonth(), 1); -const generatedContactEmails = new Set(['amelia@northstar.design','jonah@fieldnotes.co','sofia@smallhours.works','mateo@roam.travel','eden@paperandpine.com','noah@common-thread.org','iris@littlefern.press']); -let savedContacts = productRead(productKeys.contacts, []).filter(contact => !generatedContactEmails.has(String(contact.email||'').toLowerCase())); -productWrite(productKeys.contacts, savedContacts); -let savedEvents = productRead(productKeys.events, []); -let customLabels = productRead(productKeys.labels, []); -let snoozedIds = productRead(productKeys.snoozed, []); -function setProfileName(name) { profileSettings.name = name.trim(); productWrite(productKeys.profile, profileSettings); const first = profileSettings.name.split(/\s+/)[0] || ''; const greeting=selectProductivityUi('#greeting-name'); greeting.textContent=first; greeting.hidden=!first; const heading=selectProductivityUi('#welcome-heading'); if(heading) heading.firstChild.textContent=first?'Good morning, ':'Good morning'; if (productivityMailUi.connectedAccount) productivityMailUi.updateAccountCard(productivityMailUi.connectedAccount); } -function openAccountSettings() { - const root=selectProductivityUi('#modal-root'); - root.innerHTML=``; - const close=()=>root.innerHTML=''; - selectAllProductivityUi('.modal-close').forEach(button=>button.onclick=close); - selectProductivityUi('.modal-overlay').onclick=event=>{if(event.target.classList.contains('modal-overlay'))close()}; - selectProductivityUi('#save-profile').onclick=()=>{const name=selectProductivityUi('#profile-name').value.trim();if(!name){toastProductivityUi('Enter your display name');return}setProfileName(name);close();toastProductivityUi('Account settings saved')}; - selectProductivityUi('#profile-name').focus(); -} -function openPreferences() { - const root=selectProductivityUi('#modal-root'); - const themes=[['daylight','Eternity Daylight'],['wasteland','Wasteland'],['ep-wasteland','EP Wasteland'],['ep-daylight','EP Daylight']]; - const selectedTheme=localStorage.getItem('daybreak-theme')||'ep-wasteland'; - const options=themes.map(([value,label])=>``).join(''); - root.innerHTML=``; - const close=()=>root.innerHTML=''; - selectAllProductivityUi('.modal-close').forEach(button=>button.onclick=close); - selectProductivityUi('.modal-overlay').onclick=event=>{if(event.target.classList.contains('modal-overlay'))close()}; - selectProductivityUi('#save-appearance').onclick=()=>{productivityMailUi.applyTheme(selectProductivityUi('#theme-select').value);close();toastProductivityUi('Appearance saved')}; - selectProductivityUi('#theme-select').focus(); -} -function showEvent(dayOrId) { const edit=savedEvents.find(e=>e.id===dayOrId), dateValue=edit?.date || (typeof dayOrId==='string'&&/^\d{4}-\d\d-\d\d$/.test(dayOrId)?dayOrId:`${calendarMonth.getFullYear()}-${String(calendarMonth.getMonth()+1).padStart(2,'0')}-${String(dayOrId||new Date().getDate()).padStart(2,'0')}`); const root=selectProductivityUi('#modal-root'); root.innerHTML=``; const close=()=>root.innerHTML=''; selectAllProductivityUi('.modal-close').forEach(b=>b.onclick=close); selectProductivityUi('.modal-overlay').onclick=e=>{if(e.target.classList.contains('modal-overlay'))close()}; selectProductivityUi('#save-event').onclick=async()=>{const title=selectProductivityUi('#event-name').value.trim(),date=selectProductivityUi('#event-date').value;if(!title||!date){toastProductivityUi('Add an event name and date');return}const item={...(edit||{}),id:edit?.id||crypto.randomUUID(),title,date,time:selectProductivityUi('#event-time').value,with:selectProductivityUi('#event-people').value.trim(),place:selectProductivityUi('#event-place').value.trim(),notes:selectProductivityUi('#event-notes').value.trim()}; if(window.daybreakMail?.davSaveEvent){try{const remote=await window.daybreakMail.davSaveEvent(item);if(remote)item._dav=remote}catch(error){toastProductivityUi('Saved locally; DAV sync failed: '+error.message)}} if(edit) savedEvents=savedEvents.map(e=>e.id===edit.id?item:e);else savedEvents.push(item);productWrite(productKeys.events,savedEvents);close();renderCalendar();toastProductivityUi(edit?'Event updated':'Event added')}; if(edit) selectProductivityUi('#delete-event').onclick=async()=>{if(edit._dav&&window.daybreakMail?.davDeleteEvent){try{await window.daybreakMail.davDeleteEvent(edit._dav)}catch(error){toastProductivityUi('Could not delete remote event: '+error.message);return}}savedEvents=savedEvents.filter(e=>e.id!==edit.id);productWrite(productKeys.events,savedEvents);close();renderCalendar();toastProductivityUi('Event removed')}; selectProductivityUi('#event-name').focus(); } -function renderCalendar(){const year=calendarMonth.getFullYear(),month=calendarMonth.getMonth(),first=new Date(year,month,1),start=new Date(year,month,1-first.getDay()),days=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'];let cells='';for(let i=0;i<42;i++){const d=new Date(start);d.setDate(start.getDate()+i);const key=`${d.getFullYear()}-${String(d.getMonth()+1).padStart(2,'0')}-${String(d.getDate()).padStart(2,'0')}`,items=savedEvents.filter(e=>e.date===key);cells+=`
${d.getDate()}${items.slice(0,3).map(e=>`
${escapeProductivityUi(e.time?`${e.time} `:'')}${escapeProductivityUi(e.title)}
`).join('')}${items.length>3?`+${items.length-3} more`:''}
`}const upcoming=savedEvents.filter(e=>e.date>=new Date().toISOString().slice(0,10)).sort((a,b)=>a.date.localeCompare(b.date)||a.time.localeCompare(b.time)).slice(0,5);selectProductivityUi('#calendar-view').innerHTML=`

YOUR TIME, WITH ROOM TO BREATHE

${new Intl.DateTimeFormat('en-US',{month:'long',year:'numeric'}).format(calendarMonth)}

${savedEvents.length} saved events

${days.map(d=>`${d}`).join('')}
${cells}

Coming up

${upcoming.length?upcoming.map(e=>``).join(''):'

No upcoming events yet.

'}
`;selectProductivityUi('#new-event').onclick=()=>showEvent(new Date(year,month,new Date().getDate()).toISOString().slice(0,10));selectProductivityUi('#today-btn').onclick=()=>{calendarMonth=new Date(new Date().getFullYear(),new Date().getMonth(),1);renderCalendar()};selectProductivityUi('#prev-month').onclick=()=>{calendarMonth=new Date(year,month-1,1);renderCalendar()};selectProductivityUi('#next-month').onclick=()=>{calendarMonth=new Date(year,month+1,1);renderCalendar()};selectProductivityUi('#calendar-view').onclick=e=>{const event=e.target.closest('[data-event]');if(event){showEvent(event.dataset.event);return}const cell=e.target.closest('.cal-cell');if(cell)showEvent(cell.dataset.day)}} -function showContact(index){const existing=Number.isInteger(index)?savedContacts[index]:null,root=selectProductivityUi('#modal-root');root.innerHTML=``;const close=()=>root.innerHTML='';selectAllProductivityUi('.modal-close').forEach(b=>b.onclick=close);selectProductivityUi('.modal-overlay').onclick=e=>{if(e.target.classList.contains('modal-overlay'))close()};selectProductivityUi('#save-contact').onclick=async()=>{const name=selectProductivityUi('#contact-name').value.trim(),email=selectProductivityUi('#contact-email').value.trim();if(!name||!email){toastProductivityUi('Add a name and email');return}const item={...(existing||{}),name,email,note:selectProductivityUi('#contact-note').value.trim()||'Contact',initials:name.split(/\s+/).map(x=>x[0]).join('').slice(0,2).toUpperCase(),color:existing?.color||'#e7dfce'};if(window.daybreakMail?.davSaveContact){try{const remote=await window.daybreakMail.davSaveContact(item);if(remote)item._dav=remote}catch(error){toastProductivityUi('Saved locally; CardDAV sync failed: '+error.message)}}if(existing)savedContacts[index]=item;else savedContacts.push(item);productWrite(productKeys.contacts,savedContacts);close();renderContacts();toastProductivityUi(existing?'Contact updated':'Contact saved')};if(existing)selectProductivityUi('#delete-contact').onclick=async()=>{if(existing._dav&&window.daybreakMail?.davDeleteContact){try{await window.daybreakMail.davDeleteContact(existing._dav)}catch(error){toastProductivityUi('Could not delete remote contact: '+error.message);return}}savedContacts.splice(index,1);productWrite(productKeys.contacts,savedContacts);close();renderContacts();toastProductivityUi('Contact removed')};selectProductivityUi('#contact-name').focus()} -function renderContacts(){const cards=savedContacts.map((c,i)=>`
${escapeProductivityUi(c.initials)}
${escapeProductivityUi(c.name)}${escapeProductivityUi(c.email)}${escapeProductivityUi(c.note)}
`).join('');selectProductivityUi('#contacts-view').innerHTML=`

THE PEOPLE WHO MAKE LIFE FULLER

Your people

${savedContacts.length} contacts, all in one place.

${cards||'

No contacts yet. Add someone to get started.

'}
`;selectProductivityUi('#add-contact').onclick=()=>showContact();selectProductivityUi('#contact-search').oninput=e=>selectAllProductivityUi('.contact-card').forEach(c=>c.classList.toggle('hidden',!c.innerText.toLowerCase().includes(e.target.value.toLowerCase())));selectProductivityUi('#contacts-view').onclick=e=>{const edit=e.target.closest('[data-edit-contact]');if(edit){showContact(Number(edit.dataset.editContact));return}const email=e.target.closest('.contact-email');if(email)productivityMailUi.showCompose({email:email.dataset.email,subject:'',date:''})};selectProductivityUi('#contacts-view').oncontextmenu=e=>{const card=e.target.closest('.contact-card');if(!card)return;e.preventDefault();const i=Number(card.dataset.contact);if(confirm(`Remove ${savedContacts[i].name} from contacts?`)){savedContacts.splice(i,1);productWrite(productKeys.contacts,savedContacts);renderContacts();toastProductivityUi('Contact removed')}}} -function accountRuleLabels(){return [...new Set((productivityMailUi.connectedAccount?.rules||[]).filter(rule=>rule.action==='label').map(rule=>rule.value).filter(Boolean))]} -function renderLabels(){const box=selectProductivityUi('#custom-labels');if(!box)return;const labels=[...new Set([...customLabels,...accountRuleLabels()])];box.innerHTML=labels.map(label=>``).join('');selectAllProductivityUi('.label-link').forEach(b=>b.onclick=()=>{document.querySelectorAll('.label-link').forEach(x=>x.classList.toggle('active',x===b));productivityMailUi.state.activeFolder=b.dataset.label;selectProductivityUi('#sidebar-title').textContent=productivityMailUi.state.activeFolder;selectProductivityUi('#crumb-current').textContent=productivityMailUi.state.activeFolder;productivityMailUi.renderList()})} -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()} -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='';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 ↓';}); -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()} +const productRead = (key, fallback) => { try { const value = JSON.parse(localStorage.getItem(key)); return value ?? fallback; } catch { return fallback; } }; +const productWrite = (key, value) => localStorage.setItem(key, JSON.stringify(value)); +let profileSettings = productRead(productKeys.profile, { name: '' }); +if (/^mira(\s+sol)?$/i.test(profileSettings.name || '')) { profileSettings = { name: '' }; localStorage.removeItem(productKeys.profile); } +let calendarMonth = new Date(new Date().getFullYear(), new Date().getMonth(), 1); +const generatedContactEmails = new Set(['amelia@northstar.design','jonah@fieldnotes.co','sofia@smallhours.works','mateo@roam.travel','eden@paperandpine.com','noah@common-thread.org','iris@littlefern.press']); +let savedContacts = productRead(productKeys.contacts, []).filter(contact => !generatedContactEmails.has(String(contact.email||'').toLowerCase())); +productWrite(productKeys.contacts, savedContacts); +let savedEvents = productRead(productKeys.events, []); +let customLabels = productRead(productKeys.labels, []); +let snoozedIds = productRead(productKeys.snoozed, []); +function setProfileName(name) { profileSettings.name = name.trim(); productWrite(productKeys.profile, profileSettings); const first = profileSettings.name.split(/\s+/)[0] || ''; const greeting=selectProductivityUi('#greeting-name'); greeting.textContent=first; greeting.hidden=!first; const heading=selectProductivityUi('#welcome-heading'); if(heading) heading.firstChild.textContent=first?'Good morning, ':'Good morning'; if (productivityMailUi.connectedAccount) productivityMailUi.updateAccountCard(productivityMailUi.connectedAccount); } +function openAccountSettings() { + const root=selectProductivityUi('#modal-root'); + root.innerHTML=``; + const close=()=>root.innerHTML=''; + selectAllProductivityUi('.modal-close').forEach(button=>button.onclick=close); + selectProductivityUi('.modal-overlay').onclick=event=>{if(event.target.classList.contains('modal-overlay'))close()}; + selectProductivityUi('#save-profile').onclick=()=>{const name=selectProductivityUi('#profile-name').value.trim();if(!name){toastProductivityUi('Enter your display name');return}setProfileName(name);close();toastProductivityUi('Account settings saved')}; + selectProductivityUi('#profile-name').focus(); +} +function openPreferences() { + const root=selectProductivityUi('#modal-root'); + const themes=[['daylight','Eternity Daylight'],['wasteland','Wasteland'],['ep-wasteland','EP Wasteland'],['ep-daylight','EP Daylight']]; + const selectedTheme=localStorage.getItem('daybreak-theme')||'ep-wasteland'; + const options=themes.map(([value,label])=>``).join(''); + root.innerHTML=``; + const close=()=>root.innerHTML=''; + selectAllProductivityUi('.modal-close').forEach(button=>button.onclick=close); + selectProductivityUi('.modal-overlay').onclick=event=>{if(event.target.classList.contains('modal-overlay'))close()}; + selectProductivityUi('#save-appearance').onclick=()=>{productivityMailUi.applyTheme(selectProductivityUi('#theme-select').value);close();toastProductivityUi('Appearance saved')}; + selectProductivityUi('#theme-select').focus(); +} +function showEvent(dayOrId) { const edit=savedEvents.find(e=>e.id===dayOrId), dateValue=edit?.date || (typeof dayOrId==='string'&&/^\d{4}-\d\d-\d\d$/.test(dayOrId)?dayOrId:`${calendarMonth.getFullYear()}-${String(calendarMonth.getMonth()+1).padStart(2,'0')}-${String(dayOrId||new Date().getDate()).padStart(2,'0')}`); const root=selectProductivityUi('#modal-root'); root.innerHTML=``; const close=()=>root.innerHTML=''; selectAllProductivityUi('.modal-close').forEach(b=>b.onclick=close); selectProductivityUi('.modal-overlay').onclick=e=>{if(e.target.classList.contains('modal-overlay'))close()}; selectProductivityUi('#save-event').onclick=async()=>{const title=selectProductivityUi('#event-name').value.trim(),date=selectProductivityUi('#event-date').value;if(!title||!date){toastProductivityUi('Add an event name and date');return}const item={...(edit||{}),id:edit?.id||crypto.randomUUID(),title,date,time:selectProductivityUi('#event-time').value,with:selectProductivityUi('#event-people').value.trim(),place:selectProductivityUi('#event-place').value.trim(),notes:selectProductivityUi('#event-notes').value.trim()}; if(window.daybreakMail?.davSaveEvent){try{const remote=await window.daybreakMail.davSaveEvent(item);if(remote)item._dav=remote}catch(error){toastProductivityUi('Saved locally; DAV sync failed: '+error.message)}} if(edit) savedEvents=savedEvents.map(e=>e.id===edit.id?item:e);else savedEvents.push(item);productWrite(productKeys.events,savedEvents);close();renderCalendar();toastProductivityUi(edit?'Event updated':'Event added')}; if(edit) selectProductivityUi('#delete-event').onclick=async()=>{if(edit._dav&&window.daybreakMail?.davDeleteEvent){try{await window.daybreakMail.davDeleteEvent(edit._dav)}catch(error){toastProductivityUi('Could not delete remote event: '+error.message);return}}savedEvents=savedEvents.filter(e=>e.id!==edit.id);productWrite(productKeys.events,savedEvents);close();renderCalendar();toastProductivityUi('Event removed')}; selectProductivityUi('#event-name').focus(); } +function renderCalendar(){const year=calendarMonth.getFullYear(),month=calendarMonth.getMonth(),first=new Date(year,month,1),start=new Date(year,month,1-first.getDay()),days=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'];let cells='';for(let i=0;i<42;i++){const d=new Date(start);d.setDate(start.getDate()+i);const key=`${d.getFullYear()}-${String(d.getMonth()+1).padStart(2,'0')}-${String(d.getDate()).padStart(2,'0')}`,items=savedEvents.filter(e=>e.date===key);cells+=`
${d.getDate()}${items.slice(0,3).map(e=>`
${escapeProductivityUi(e.time?`${e.time} `:'')}${escapeProductivityUi(e.title)}
`).join('')}${items.length>3?`+${items.length-3} more`:''}
`}const upcoming=savedEvents.filter(e=>e.date>=new Date().toISOString().slice(0,10)).sort((a,b)=>a.date.localeCompare(b.date)||a.time.localeCompare(b.time)).slice(0,5);selectProductivityUi('#calendar-view').innerHTML=`

YOUR TIME, WITH ROOM TO BREATHE

${new Intl.DateTimeFormat('en-US',{month:'long',year:'numeric'}).format(calendarMonth)}

${savedEvents.length} saved events

${days.map(d=>`${d}`).join('')}
${cells}

Coming up

${upcoming.length?upcoming.map(e=>``).join(''):'

No upcoming events yet.

'}
`;selectProductivityUi('#new-event').onclick=()=>showEvent(new Date(year,month,new Date().getDate()).toISOString().slice(0,10));selectProductivityUi('#today-btn').onclick=()=>{calendarMonth=new Date(new Date().getFullYear(),new Date().getMonth(),1);renderCalendar()};selectProductivityUi('#prev-month').onclick=()=>{calendarMonth=new Date(year,month-1,1);renderCalendar()};selectProductivityUi('#next-month').onclick=()=>{calendarMonth=new Date(year,month+1,1);renderCalendar()};selectProductivityUi('#calendar-view').onclick=e=>{const event=e.target.closest('[data-event]');if(event){showEvent(event.dataset.event);return}const cell=e.target.closest('.cal-cell');if(cell)showEvent(cell.dataset.day)}} +function showContact(index){const existing=Number.isInteger(index)?savedContacts[index]:null,root=selectProductivityUi('#modal-root');root.innerHTML=``;const close=()=>root.innerHTML='';selectAllProductivityUi('.modal-close').forEach(b=>b.onclick=close);selectProductivityUi('.modal-overlay').onclick=e=>{if(e.target.classList.contains('modal-overlay'))close()};selectProductivityUi('#save-contact').onclick=async()=>{const name=selectProductivityUi('#contact-name').value.trim(),email=selectProductivityUi('#contact-email').value.trim();if(!name||!email){toastProductivityUi('Add a name and email');return}const item={...(existing||{}),name,email,note:selectProductivityUi('#contact-note').value.trim()||'Contact',initials:name.split(/\s+/).map(x=>x[0]).join('').slice(0,2).toUpperCase(),color:existing?.color||'#e7dfce'};if(window.daybreakMail?.davSaveContact){try{const remote=await window.daybreakMail.davSaveContact(item);if(remote)item._dav=remote}catch(error){toastProductivityUi('Saved locally; CardDAV sync failed: '+error.message)}}if(existing)savedContacts[index]=item;else savedContacts.push(item);productWrite(productKeys.contacts,savedContacts);close();renderContacts();toastProductivityUi(existing?'Contact updated':'Contact saved')};if(existing)selectProductivityUi('#delete-contact').onclick=async()=>{if(existing._dav&&window.daybreakMail?.davDeleteContact){try{await window.daybreakMail.davDeleteContact(existing._dav)}catch(error){toastProductivityUi('Could not delete remote contact: '+error.message);return}}savedContacts.splice(index,1);productWrite(productKeys.contacts,savedContacts);close();renderContacts();toastProductivityUi('Contact removed')};selectProductivityUi('#contact-name').focus()} +function renderContacts(){const cards=savedContacts.map((c,i)=>`
${escapeProductivityUi(c.initials)}
${escapeProductivityUi(c.name)}${escapeProductivityUi(c.email)}${escapeProductivityUi(c.note)}
`).join('');selectProductivityUi('#contacts-view').innerHTML=`

THE PEOPLE WHO MAKE LIFE FULLER

Your people

${savedContacts.length} contacts, all in one place.

${cards||'

No contacts yet. Add someone to get started.

'}
`;selectProductivityUi('#add-contact').onclick=()=>showContact();selectProductivityUi('#contact-search').oninput=e=>selectAllProductivityUi('.contact-card').forEach(c=>c.classList.toggle('hidden',!c.innerText.toLowerCase().includes(e.target.value.toLowerCase())));selectProductivityUi('#contacts-view').onclick=e=>{const edit=e.target.closest('[data-edit-contact]');if(edit){showContact(Number(edit.dataset.editContact));return}const email=e.target.closest('.contact-email');if(email)productivityMailUi.showCompose({email:email.dataset.email,subject:'',date:''})};selectProductivityUi('#contacts-view').oncontextmenu=e=>{const card=e.target.closest('.contact-card');if(!card)return;e.preventDefault();const i=Number(card.dataset.contact);if(confirm(`Remove ${savedContacts[i].name} from contacts?`)){savedContacts.splice(i,1);productWrite(productKeys.contacts,savedContacts);renderContacts();toastProductivityUi('Contact removed')}}} +function accountRuleLabels(){return [...new Set((productivityMailUi.connectedAccount?.rules||[]).filter(rule=>rule.action==='label').map(rule=>rule.value).filter(Boolean))]} +function renderLabels(){const box=selectProductivityUi('#custom-labels');if(!box)return;const labels=[...new Set([...customLabels,...accountRuleLabels()])];box.innerHTML=labels.map(label=>``).join('');selectAllProductivityUi('.label-link').forEach(b=>b.onclick=()=>{document.querySelectorAll('.label-link').forEach(x=>x.classList.toggle('active',x===b));productivityMailUi.state.activeFolder=b.dataset.label;selectProductivityUi('#sidebar-title').textContent=productivityMailUi.state.activeFolder;selectProductivityUi('#crumb-current').textContent=productivityMailUi.state.activeFolder;productivityMailUi.renderList()})} +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()} +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='';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 ↓';}); +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 () { const state = productivityMailUi.state; if (state.activeFolder === 'Drafts') { @@ -71,7 +71,7 @@ productivityMailUi.wrapRenderList(baseMessageRenderer => function () { return; } return baseMessageRenderer(); -}); +}); document.addEventListener('click',event=>{const button=event.target.closest('.download');if(!button)return;event.stopImmediatePropagation();const message=productivityMailUi.state.messages.find(item=>item.id===productivityMailUi.state.activeMessage);const filename=button.dataset.filename||message?.attachment;if(!filename){toastProductivityUi('This message has no downloadable attachment');return}if(!message?.uid||!window.daybreakMail?.saveAttachment){toastProductivityUi('Attachment download is available for connected mailbox messages');return}window.daybreakMail.saveAttachment({uid:message.uid,folder:productivityMailUi.state.activeFolder,filename}).then(result=>{if(result.saved)toastProductivityUi('Attachment saved')}).catch(error=>toastProductivityUi(error.message||'Could not save attachment'))},true); window.epMailFeatures.productivity = Object.freeze({ diff --git a/www/service-worker.js b/www/service-worker.js index f8ff469..eb59867 100644 --- a/www/service-worker.js +++ b/www/service-worker.js @@ -1,5 +1,5 @@ const CACHE='ep-mail-v12'; 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']; -self.addEventListener('install',event=>event.waitUntil(caches.open(CACHE).then(cache=>cache.addAll(FILES)))); -self.addEventListener('activate',event=>event.waitUntil(caches.keys().then(keys=>Promise.all(keys.filter(k=>k!==CACHE).map(k=>caches.delete(k)))))); -self.addEventListener('fetch',event=>{if(event.request.method!=='GET')return;event.respondWith(caches.match(event.request).then(cached=>cached||fetch(event.request).then(response=>{if(new URL(event.request.url).origin===location.origin){const copy=response.clone();caches.open(CACHE).then(cache=>cache.put(event.request,copy))}return response}).catch(()=>caches.match('./index.html'))))}); +self.addEventListener('install',event=>event.waitUntil(caches.open(CACHE).then(cache=>cache.addAll(FILES)))); +self.addEventListener('activate',event=>event.waitUntil(caches.keys().then(keys=>Promise.all(keys.filter(k=>k!==CACHE).map(k=>caches.delete(k)))))); +self.addEventListener('fetch',event=>{if(event.request.method!=='GET')return;event.respondWith(caches.match(event.request).then(cached=>cached||fetch(event.request).then(response=>{if(new URL(event.request.url).origin===location.origin){const copy=response.clone();caches.open(CACHE).then(cache=>cache.put(event.request,copy))}return response}).catch(()=>caches.match('./index.html'))))}); diff --git a/www/shortcuts.js b/www/shortcuts.js index 15f7ab9..e5a3d80 100644 --- a/www/shortcuts.js +++ b/www/shortcuts.js @@ -6,102 +6,102 @@ const selectShortcutUi = shortcutMailUi.select; const toastShortcutUi = shortcutMailUi.toast; const escapeShortcutUi = shortcutMailUi.escapeHtml; const shortcutStorageKey = 'daybreak-shortcuts'; -const shortcutActions = [ - { id: 'compose', label: 'Compose', fallback: 'c', run: () => selectShortcutUi('#compose')?.click() }, - { id: 'search', label: 'Search', fallback: '/', run: () => selectShortcutUi('#search')?.focus() }, - { id: 'refresh', label: 'Refresh', fallback: 'r', run: () => selectShortcutUi('#refresh')?.click() }, - { id: 'archive', label: 'Archive message', fallback: 'e', run: () => selectShortcutUi('#reader-archive')?.click() }, - { id: 'delete', label: 'Delete message', fallback: '#', run: () => selectShortcutUi('#reader-delete')?.click() }, - { id: 'star', label: 'Star message', fallback: 's', run: () => selectShortcutUi('#reader-star')?.click() }, - { id: 'reply', label: 'Reply', fallback: 'a', run: () => selectShortcutUi('#reply')?.click() }, - { id: 'forward', label: 'Forward', fallback: 'f', run: () => selectShortcutUi('#forward')?.click() }, - { id: 'next', label: 'Next message', fallback: 'j', run: () => moveMessageSelection(1) }, - { id: 'previous', label: 'Previous message', fallback: 'k', run: () => moveMessageSelection(-1) } -]; - -function normalizeShortcut(value) { - const text = String(value || '').trim(); - if (!text) return ''; - const parts = text.split('+').map(part => part.trim()).filter(Boolean); - const key = parts.pop() || '+'; - const mods = ['Ctrl', 'Alt', 'Shift'].filter(mod => parts.some(part => part.toLowerCase() === mod.toLowerCase())); - return [...mods, key.length === 1 ? key.toLowerCase() : key].join('+'); -} - -function loadShortcuts() { - let saved = {}; - try { saved = JSON.parse(localStorage.getItem(shortcutStorageKey)) || {}; } catch {} - return Object.fromEntries(shortcutActions.map(action => [ - action.id, typeof saved[action.id] === 'string' ? normalizeShortcut(saved[action.id]) : action.fallback - ])); -} - -function eventShortcut(event) { - if (['Control', 'Alt', 'Shift', 'Meta'].includes(event.key)) return ''; - const mods = [event.ctrlKey || event.metaKey ? 'Ctrl' : '', event.altKey ? 'Alt' : '']; - const printable = event.key.length === 1; - if (event.shiftKey && !printable) mods.push('Shift'); - return normalizeShortcut([...mods.filter(Boolean), event.key === ' ' ? 'Space' : event.key].join('+')); -} - +const shortcutActions = [ + { id: 'compose', label: 'Compose', fallback: 'c', run: () => selectShortcutUi('#compose')?.click() }, + { id: 'search', label: 'Search', fallback: '/', run: () => selectShortcutUi('#search')?.focus() }, + { id: 'refresh', label: 'Refresh', fallback: 'r', run: () => selectShortcutUi('#refresh')?.click() }, + { id: 'archive', label: 'Archive message', fallback: 'e', run: () => selectShortcutUi('#reader-archive')?.click() }, + { id: 'delete', label: 'Delete message', fallback: '#', run: () => selectShortcutUi('#reader-delete')?.click() }, + { id: 'star', label: 'Star message', fallback: 's', run: () => selectShortcutUi('#reader-star')?.click() }, + { id: 'reply', label: 'Reply', fallback: 'a', run: () => selectShortcutUi('#reply')?.click() }, + { id: 'forward', label: 'Forward', fallback: 'f', run: () => selectShortcutUi('#forward')?.click() }, + { id: 'next', label: 'Next message', fallback: 'j', run: () => moveMessageSelection(1) }, + { id: 'previous', label: 'Previous message', fallback: 'k', run: () => moveMessageSelection(-1) } +]; + +function normalizeShortcut(value) { + const text = String(value || '').trim(); + if (!text) return ''; + const parts = text.split('+').map(part => part.trim()).filter(Boolean); + const key = parts.pop() || '+'; + const mods = ['Ctrl', 'Alt', 'Shift'].filter(mod => parts.some(part => part.toLowerCase() === mod.toLowerCase())); + return [...mods, key.length === 1 ? key.toLowerCase() : key].join('+'); +} + +function loadShortcuts() { + let saved = {}; + try { saved = JSON.parse(localStorage.getItem(shortcutStorageKey)) || {}; } catch {} + return Object.fromEntries(shortcutActions.map(action => [ + action.id, typeof saved[action.id] === 'string' ? normalizeShortcut(saved[action.id]) : action.fallback + ])); +} + +function eventShortcut(event) { + if (['Control', 'Alt', 'Shift', 'Meta'].includes(event.key)) return ''; + const mods = [event.ctrlKey || event.metaKey ? 'Ctrl' : '', event.altKey ? 'Alt' : '']; + const printable = event.key.length === 1; + if (event.shiftKey && !printable) mods.push('Shift'); + return normalizeShortcut([...mods.filter(Boolean), event.key === ' ' ? 'Space' : event.key].join('+')); +} + function moveMessageSelection(step) { const messages = shortcutMailUi.state.messages; if (!messages.length) return; const index = messages.findIndex(message => message.id === shortcutMailUi.state.activeMessage); const next = messages[Math.min(messages.length - 1, Math.max(0, index + step))]; if (next) { shortcutMailUi.openMessage(next.id); selectShortcutUi(`.message[data-id="${next.id}"]`)?.scrollIntoView({ block: 'nearest' }); } -} - -document.addEventListener('keydown', event => { - if (event.defaultPrevented || event.isComposing || event.key === 'Escape') return; - const target = event.target; - if (target?.closest?.('input, textarea, select, [contenteditable="true"]') || selectShortcutUi('#modal-root')?.children.length) return; - const pressed = eventShortcut(event); - if (!pressed) return; - const shortcuts = loadShortcuts(); - const action = shortcutActions.find(item => shortcuts[item.id] && shortcuts[item.id] === pressed); - if (!action) return; - event.preventDefault(); - action.run(); -}); - +} + +document.addEventListener('keydown', event => { + if (event.defaultPrevented || event.isComposing || event.key === 'Escape') return; + const target = event.target; + if (target?.closest?.('input, textarea, select, [contenteditable="true"]') || selectShortcutUi('#modal-root')?.children.length) return; + const pressed = eventShortcut(event); + if (!pressed) return; + const shortcuts = loadShortcuts(); + const action = shortcutActions.find(item => shortcuts[item.id] && shortcuts[item.id] === pressed); + if (!action) return; + event.preventDefault(); + action.run(); +}); + shortcutProductivityUi.wrapOpenPreferences(baseOpenPreferences => function () { - baseOpenPreferences(); - const fields = selectShortcutUi('#modal-root .compose-fields'); - const save = selectShortcutUi('#save-appearance'); - if (!fields || !save) return; - const shortcuts = loadShortcuts(); - const section = document.createElement('div'); - section.className = 'shortcut-settings'; - section.innerHTML = `

Keyboard shortcuts

${shortcutActions.map(action => - ``).join('')}`; - fields.append(section); - section.addEventListener('keydown', event => { - const input = event.target.closest('.shortcut-input'); - if (!input || ['Tab', 'Escape'].includes(event.key)) return; - event.preventDefault(); - if (['Backspace', 'Delete'].includes(event.key)) { input.value = ''; return; } - 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); - }; + baseOpenPreferences(); + const fields = selectShortcutUi('#modal-root .compose-fields'); + const save = selectShortcutUi('#save-appearance'); + if (!fields || !save) return; + const shortcuts = loadShortcuts(); + const section = document.createElement('div'); + section.className = 'shortcut-settings'; + section.innerHTML = `

Keyboard shortcuts

${shortcutActions.map(action => + ``).join('')}`; + fields.append(section); + section.addEventListener('keydown', event => { + const input = event.target.closest('.shortcut-input'); + if (!input || ['Tab', 'Escape'].includes(event.key)) return; + event.preventDefault(); + if (['Backspace', 'Delete'].includes(event.key)) { input.value = ''; return; } + 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); + }; }); })(); diff --git a/www/snooze-ui.js b/www/snooze-ui.js index 9beb0c7..a1a9c83 100644 --- a/www/snooze-ui.js +++ b/www/snooze-ui.js @@ -3,91 +3,91 @@ const snoozeMailUi = window.epMailFeatures.mail; const snoozeProductivityUi = window.epMailFeatures.productivity; function localDateTimeValue(date) { - const local = new Date(date.getTime() - date.getTimezoneOffset() * 60000); - return local.toISOString().slice(0, 16); -} - -function nextMorning(daysAhead) { - const date = new Date(); - date.setDate(date.getDate() + daysAhead); - date.setHours(9, 0, 0, 0); - if (date <= new Date()) date.setDate(date.getDate() + 1); - return date; -} - -function openSnoozeDialog(items) { + const local = new Date(date.getTime() - date.getTimezoneOffset() * 60000); + return local.toISOString().slice(0, 16); +} + +function nextMorning(daysAhead) { + const date = new Date(); + date.setDate(date.getDate() + daysAhead); + date.setHours(9, 0, 0, 0); + if (date <= new Date()) date.setDate(date.getDate() + 1); + return date; +} + +function openSnoozeDialog(items) { const eligible = items.filter(message => message?.uid && snoozeMailUi.connectedAccount); - if (!eligible.length) { + if (!eligible.length) { snoozeMailUi.toast('Snoozing is available for messages in a connected mailbox.'); - return; - } + return; + } const root = snoozeMailUi.select('#modal-root'); - const tomorrow = nextMorning(1); - const laterToday = new Date(Date.now() + 3 * 60 * 60 * 1000); - root.innerHTML = ``; - const close = () => { root.innerHTML = ''; }; - root.querySelectorAll('.modal-close').forEach(button => button.onclick = close); - root.querySelector('.modal-overlay').onclick = event => { - if (event.target.classList.contains('modal-overlay')) close(); - }; - - const schedule = async dueAt => { - if (!Number.isFinite(dueAt) || dueAt <= Date.now()) { + const tomorrow = nextMorning(1); + const laterToday = new Date(Date.now() + 3 * 60 * 60 * 1000); + root.innerHTML = ``; + const close = () => { root.innerHTML = ''; }; + root.querySelectorAll('.modal-close').forEach(button => button.onclick = close); + root.querySelector('.modal-overlay').onclick = event => { + if (event.target.classList.contains('modal-overlay')) close(); + }; + + const schedule = async dueAt => { + if (!Number.isFinite(dueAt) || dueAt <= Date.now()) { snoozeMailUi.select('#snooze-status').textContent = 'Choose a reminder time in the future.'; - return; - } - const buttons = [...root.querySelectorAll('button')]; - buttons.forEach(button => { button.disabled = true; }); - try { - for (const message of eligible) { - const sourceFolder = message.sourceFolder || + return; + } + const buttons = [...root.querySelectorAll('button')]; + buttons.forEach(button => { button.disabled = true; }); + try { + for (const message of eligible) { + const sourceFolder = message.sourceFolder || (['Inbox', 'Sent', 'Archive', 'Trash'].includes(snoozeMailUi.state.activeFolder) ? snoozeMailUi.state.activeFolder : 'Inbox'); - await window.daybreakMail.setSnooze({ - uid: message.uid, - folder: sourceFolder, - sourceFolder, - dueAt, - subject: message.subject - }); - } - close(); + await window.daybreakMail.setSnooze({ + uid: message.uid, + folder: sourceFolder, + sourceFolder, + dueAt, + subject: message.subject + }); + } + close(); snoozeMailUi.toast(eligible.length === 1 ? 'Message snoozed' : `${eligible.length} messages snoozed`); snoozeMailUi.state.selectedIds.clear(); await snoozeMailUi.syncMailbox(false, { offset: 0 }); - } catch (error) { + } catch (error) { snoozeMailUi.select('#snooze-status').textContent = error.message || 'Could not set the reminder.'; - buttons.forEach(button => { button.disabled = false; }); - } - }; - - root.querySelectorAll('[data-snooze-at]').forEach(button => { - button.onclick = () => schedule(Number(button.dataset.snoozeAt)); - }); + buttons.forEach(button => { button.disabled = false; }); + } + }; + + root.querySelectorAll('[data-snooze-at]').forEach(button => { + button.onclick = () => schedule(Number(button.dataset.snoozeAt)); + }); snoozeMailUi.select('#snooze-custom').onclick = () => schedule(new Date(snoozeMailUi.select('#snooze-custom-time').value).getTime()); snoozeMailUi.select('#snooze-custom-time').focus(); -} - -function unsnoozeMessage(message) { - const sourceFolder = message.sourceFolder || 'Inbox'; - window.daybreakMail.setSnooze({ - uid: message.uid, - sourceFolder, - dueAt: null - }).then(async () => { +} + +function unsnoozeMessage(message) { + const sourceFolder = message.sourceFolder || 'Inbox'; + window.daybreakMail.setSnooze({ + uid: message.uid, + sourceFolder, + dueAt: null + }).then(async () => { snoozeMailUi.toast('Message returned to its mailbox'); await snoozeMailUi.syncMailbox(false, { offset: 0 }); }).catch(error => snoozeMailUi.toast(error.message || 'Could not return the message')); -} - -function showMessageActions(message) { +} + +function showMessageActions(message) { const root = snoozeMailUi.select('#modal-root'); - root.innerHTML = ``; - root.querySelectorAll('.modal-close').forEach(button => button.onclick = () => { root.innerHTML = ''; }); - root.querySelector('.modal-overlay').onclick = event => { - if (event.target.classList.contains('modal-overlay')) root.innerHTML = ''; - }; -} - + root.innerHTML = ``; + root.querySelectorAll('.modal-close').forEach(button => button.onclick = () => { root.innerHTML = ''; }); + root.querySelector('.modal-overlay').onclick = event => { + if (event.target.classList.contains('modal-overlay')) root.innerHTML = ''; + }; +} + snoozeMailUi.wrapRenderList(renderListBeforeSnooze => function () { if (snoozeMailUi.state.activeFolder === 'Snoozed') { const originalMessages = snoozeMailUi.state.messages.slice(); @@ -99,21 +99,21 @@ snoozeMailUi.wrapRenderList(renderListBeforeSnooze => function () { snoozeMailUi.state.activeFolder = 'Inbox'; snoozeMailUi.baseRenderList(); snoozeMailUi.state.activeFolder = folder; - originalFlags.forEach(([message, archived, deleted]) => { - message.archived = archived; - message.deleted = deleted; - }); + originalFlags.forEach(([message, archived, deleted]) => { + message.archived = archived; + message.deleted = deleted; + }); snoozeMailUi.state.messages.splice(0, snoozeMailUi.state.messages.length, ...originalMessages); for (const row of snoozeMailUi.selectAll('.message')) { const message = snoozeMailUi.state.messages.find(item => item.id === Number(row.dataset.id)); - if (!message?.snoozedUntil) continue; - const due = new Date(message.snoozedUntil); - row.title = `Reminder ${due.toLocaleString()}`; - const snippet = row.querySelector('.snippet'); - if (snippet) snippet.textContent = `Reminder · ${due.toLocaleString()} · ${message.snippet}`; - } - return; - } + if (!message?.snoozedUntil) continue; + const due = new Date(message.snoozedUntil); + row.title = `Reminder ${due.toLocaleString()}`; + const snippet = row.querySelector('.snippet'); + if (snippet) snippet.textContent = `Reminder · ${due.toLocaleString()} · ${message.snippet}`; + } + return; + } return renderListBeforeSnooze(); }); @@ -121,61 +121,61 @@ snoozeMailUi.wrapOpenMessage(openMessageBeforeSnooze => function (id) { openMessageBeforeSnooze(id); const message = snoozeMailUi.state.messages.find(item => item.id === id); const tools = snoozeMailUi.select('.reader-tools'); - if (!message || !tools) return; + if (!message || !tools) return; const snoozed = snoozeMailUi.state.activeFolder === 'Snoozed'; - tools.insertAdjacentHTML('afterbegin', ``); + tools.insertAdjacentHTML('afterbegin', ``); }); document.addEventListener('DOMContentLoaded', () => { snoozeMailUi.select('#mark-unread').insertAdjacentHTML('afterend', ''); - if (window.daybreakMail?.checkSnoozeReminders) { - const checkReminders = () => window.daybreakMail.checkSnoozeReminders() - .catch(error => console.error('Could not check mail reminders:', error)); - void checkReminders(); - setInterval(checkReminders, 60 * 1000); - } -}); - + if (window.daybreakMail?.checkSnoozeReminders) { + const checkReminders = () => window.daybreakMail.checkSnoozeReminders() + .catch(error => console.error('Could not check mail reminders:', error)); + void checkReminders(); + setInterval(checkReminders, 60 * 1000); + } +}); + document.addEventListener('click', event => { - const action = event.target.closest('[data-message-action]'); - const more = event.target.closest('.reader-tools button[title="More"]'); - const snooze = event.target.closest('#reader-snooze, #snooze-selected'); - const unsnooze = event.target.closest('#reader-unsnooze'); - if (!more && !snooze && !unsnooze && !action) return; - event.preventDefault(); - event.stopImmediatePropagation(); - if (action) { + const action = event.target.closest('[data-message-action]'); + const more = event.target.closest('.reader-tools button[title="More"]'); + const snooze = event.target.closest('#reader-snooze, #snooze-selected'); + const unsnooze = event.target.closest('#reader-unsnooze'); + if (!more && !snooze && !unsnooze && !action) return; + event.preventDefault(); + event.stopImmediatePropagation(); + if (action) { const message = snoozeMailUi.state.messages.find(item => item.id === snoozeMailUi.state.activeMessage); snoozeMailUi.select('#modal-root').innerHTML = ''; - if (!message) return; - if (action.dataset.messageAction === 'snooze') openSnoozeDialog([message]); + if (!message) return; + if (action.dataset.messageAction === 'snooze') openSnoozeDialog([message]); else if (action.dataset.messageAction === 'label') snoozeProductivityUi.addMessageLabel(message); - else { - const type = action.dataset.messageAction; - messageAction(message, type).then(() => { - if (type === 'unread') message.unread = true; - if (type === 'inbox') message.archived = false; + else { + const type = action.dataset.messageAction; + messageAction(message, type).then(() => { + if (type === 'unread') message.unread = true; + if (type === 'inbox') message.archived = false; snoozeMailUi.renderList(); snoozeMailUi.toast(type === 'unread' ? 'Marked unread' : 'Moved to Inbox'); }).catch(error => snoozeMailUi.toast(error.message || 'Could not update the message')); - } - return; - } - if (unsnooze) { + } + return; + } + if (unsnooze) { const message = snoozeMailUi.state.messages.find(item => item.id === snoozeMailUi.state.activeMessage); - if (message) unsnoozeMessage(message); - return; - } - if (snooze?.id === 'snooze-selected') { + if (message) unsnoozeMessage(message); + return; + } + if (snooze?.id === 'snooze-selected') { openSnoozeDialog(snoozeMailUi.state.messages.filter(message => snoozeMailUi.state.selectedIds.has(message.id))); - return; - } - if (more) { + return; + } + if (more) { const message = snoozeMailUi.state.messages.find(item => item.id === snoozeMailUi.state.activeMessage); - if (message) showMessageActions(message); - return; - } + if (message) showMessageActions(message); + return; + } const message = snoozeMailUi.state.messages.find(item => item.id === snoozeMailUi.state.activeMessage); - if (message) openSnoozeDialog([message]); + if (message) openSnoozeDialog([message]); }, true); })(); diff --git a/www/styles.css b/www/styles.css index b8f6385..2643ed1 100644 --- a/www/styles.css +++ b/www/styles.css @@ -1,143 +1,143 @@ -:root{font-family:'DM Sans',Inter,ui-sans-serif,system-ui,-apple-system,'Segoe UI',sans-serif;color:#252a28;background:#f4f5f1;font-synthesis:none;text-rendering:optimizeLegibility;--bg:#f4f5f1;--panel:#fff;--line:#eaede8;--text:#252a28;--muted:#8b918b;--subtle:#f7f8f5;--accent:#55816c;--accent-soft:#edf4ef;--shadow:0 2px 10px #2636290b} -*{box-sizing:border-box}body{margin:0;min-width:760px;min-height:100vh;background:var(--bg);color:var(--text)}button,input,textarea{font:inherit}button{color:inherit;cursor:pointer}button:focus-visible,input:focus-visible,textarea:focus-visible{outline:2px solid #7eae90;outline-offset:2px}.app-shell{height:100vh;min-height:640px;display:flex;overflow:hidden}.rail{width:66px;flex:none;background:#edf0ea;border-right:1px solid #e5e9e2;display:flex;align-items:center;flex-direction:column;padding:17px 0 13px;gap:10px}.brand-mark{height:35px;width:35px;border-radius:12px;background:#5b826c;color:white;display:grid;place-items:center;font-size:24px;margin-bottom:21px;box-shadow:0 3px 8px #476c541d}.rail-button{height:39px;width:39px;border:0;background:transparent;color:#7e8780;border-radius:11px;font-size:20px;display:grid;place-items:center;transition:.18s}.rail-button:hover{background:#e2e8e1;color:#446a54}.rail-button.active{color:#477253;background:#dce9dd}.rail-spacer{flex:1}.avatar{border:0;border-radius:50%;height:34px;width:34px;background:#e7cbb6;color:#614c3c;font-size:11px;font-weight:700;display:grid;place-items:center}.avatar.tiny{height:27px;width:27px;font-size:9px} -.sidebar{width:244px;flex:none;background:#fff;border-right:1px solid var(--line);padding:26px 17px 14px;display:flex;flex-direction:column}.sidebar-head{display:flex;align-items:center;justify-content:space-between;padding:0 5px;margin-bottom:21px}.eyebrow{color:#969c95;font-size:9px;font-weight:700;letter-spacing:1.25px;margin:0 0 5px}.sidebar-head h1{font-family:'DM Serif Display',Georgia,serif;font-size:24px;font-weight:400;margin:0}.icon-button{border:0;background:transparent;color:#89918a;height:30px;min-width:30px;border-radius:8px;font-size:19px;display:inline-grid;place-items:center}.icon-button:hover{background:var(--subtle);color:#47544a}.account-card{display:flex;align-items:center;gap:10px;padding:10px 9px;background:#f7f8f5;border:1px solid #eff1ec;border-radius:10px;margin:0 0 22px}.account-avatar{height:30px;width:30px;border-radius:9px;background:#dce9dd;color:#477253;display:grid;place-items:center;font-family:Georgia,serif;font-weight:bold}.account-info{min-width:0;display:flex;flex-direction:column;gap:2px;flex:1}.account-info strong{font-size:11px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.account-info span{color:#929891;font-size:9px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.online-dot{display:inline-block;width:7px;height:7px;border-radius:50%;background:#70ad7b}.folder-nav{display:grid;gap:3px}.folder{width:100%;border:0;background:transparent;display:flex;align-items:center;gap:12px;text-align:left;padding:9px 10px;border-radius:8px;font-size:11px;color:#707970}.folder:hover,.label-link:hover{background:#f6f8f5}.folder.active{background:#edf4ee;color:#487354;font-weight:600}.nav-glyph{width:15px;text-align:center;font-size:15px;color:#879188}.folder.active .nav-glyph{color:#578366}.count{margin-left:auto;padding:2px 6px;min-width:19px;text-align:center;border-radius:5px;background:#fff;color:#61836a;font-size:9px}.count.muted{color:#969c95}.sidebar-divider{height:1px;background:#edf0ec;margin:18px 4px 16px}.section-label{display:flex;justify-content:space-between;align-items:center;font-size:9px;letter-spacing:1.1px;font-weight:700;color:#a0a59f;padding:0 6px;margin-bottom:9px}.tiny-plus{border:0;background:transparent;color:#929990;font-size:18px}.label-link{border:0;background:transparent;border-radius:7px;text-align:left;display:flex;align-items:center;gap:10px;color:#727970;font-size:11px;padding:8px 10px}.label-dot{width:8px;height:8px;border-radius:50%}.dot-amber{background:#dda854}.dot-blue{background:#79a4c9}.dot-green{background:#82ab83}.sidebar-bottom{margin-top:auto}.storage{padding:13px 10px 14px;border-bottom:1px solid #eef0ec}.storage-top{display:flex;justify-content:space-between;color:#606960;font-size:10px}.storage-top span+span{color:#979d97;font-size:9px}.storage-bar{height:4px;background:#edf0eb;margin:9px 0 7px;border-radius:5px;overflow:hidden}.storage-bar i{display:block;width:28%;height:100%;background:#79a785;border-radius:5px}.storage small{font-size:9px;color:#9ba19a}.settings-button{border:0;background:transparent;color:#7e867f;display:flex;gap:10px;align-items:center;margin:10px 0 0 4px;font-size:11px;padding:7px} -.main-area{flex:1;min-width:0;display:flex;flex-direction:column}.topbar{height:57px;flex:none;background:#fff;border-bottom:1px solid var(--line);display:flex;align-items:center;justify-content:space-between;padding:0 24px}.breadcrumbs{display:flex;align-items:center;gap:10px;font-size:10px;color:#969c96}.breadcrumbs strong{font-weight:600;color:#475048}.crumb-divider{color:#c6cbc5}.top-actions{display:flex;align-items:center;gap:13px}.search-wrap{height:31px;width:218px;background:#f6f7f4;border:1px solid #eff0ec;border-radius:8px;display:flex;align-items:center;padding:0 9px;gap:7px;color:#90978f}.search-wrap>span{font-size:19px}.search-wrap input{border:0;outline:0;background:transparent;width:100%;font-size:10px;color:#3f4740}.search-wrap kbd{font:9px 'DM Sans',sans-serif;border:1px solid #e3e6e1;border-radius:4px;padding:2px 4px;white-space:nowrap;color:#999f99}.help-button{font-size:12px;border:1px solid #e7eae6;border-radius:50%;height:20px;min-width:20px;font-weight:600}.top-avatar{width:27px;height:27px;font-size:9px} -.content-view{flex:1;min-height:0}.mail-layout{display:grid;grid-template-columns:minmax(330px,44%) minmax(340px,1fr);padding:18px 20px 20px;gap:14px}.list-pane,.reader-pane{background:var(--panel);border:1px solid var(--line);border-radius:12px;box-shadow:var(--shadow);min-height:0}.list-pane{display:flex;flex-direction:column;overflow:hidden}.list-heading{padding:20px 19px 15px;display:flex;align-items:center;justify-content:space-between}.date-line{font-size:8px;font-weight:700;letter-spacing:1.25px;color:#a0a69f;margin-bottom:7px}.list-heading h2{font-family:'DM Serif Display',Georgia,serif;font-size:20px;font-weight:400;margin:0;color:#303732}.sun{font-family:sans-serif;font-size:14px;color:#dda95f;vertical-align:2px}.compose-button{border:0;border-radius:7px;background:#5b8068;color:white;padding:8px 12px;font-size:10px;font-weight:600;box-shadow:0 2px 4px #406e4f20}.compose-button:hover{background:#476f56}.compose-button span{font-size:15px;vertical-align:-1px;margin-right:4px}.toolbar{height:39px;border-top:1px solid #f2f3f1;border-bottom:1px solid #f0f2ee;display:flex;align-items:center;padding:0 12px;gap:6px;color:#888f88}.toolbar .icon-button{font-size:15px;height:26px;min-width:26px}.tool-checkbox{font-size:14px;color:#818981;border:0;background:transparent;width:25px}.toolbar-divider{height:16px;width:1px;background:#e9ece8;margin:0 3px}.toolbar-spacer{flex:1}.pagination{font-size:9px;color:#90968f;white-space:nowrap}.message-list{overflow-y:auto;flex:1}.message{min-height:68px;display:grid;grid-template-columns:18px 32px minmax(0,1fr) auto;align-items:center;gap:9px;padding:9px 12px;border-bottom:1px solid #f0f2ef;cursor:pointer;transition:background .14s}.message:hover{background:#fafbf9}.message.selected{background:#f3f7f2;box-shadow:inset 2px 0 #669074}.message.unread .sender,.message.unread .subject{font-weight:700;color:#303832}.row-check{appearance:none;width:13px;height:13px;border:1px solid #d7dcd6;border-radius:3px;cursor:pointer;margin:0}.row-check:checked{appearance:auto;accent-color:#63866d}.contact-avatar{width:31px;height:31px;border-radius:50%;display:grid;place-items:center;font-size:9px;font-weight:700;color:#55483d;background:#e9d8c9}.message-body{min-width:0;overflow:hidden}.sender{font-size:10px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:#626a63;margin-bottom:4px}.subject{font-size:10px;color:#3e4640;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin-bottom:3px}.snippet{font-size:9px;color:#a1a69f;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.message-meta{height:100%;display:flex;flex-direction:column;justify-content:space-between;align-items:flex-end;padding:2px 0;min-width:31px}.time{font-size:8px;color:#989e98;white-space:nowrap}.star{border:0;background:transparent;color:#c9cec8;font-size:14px;line-height:1;padding:0}.star.on{color:#dcaa56}.list-foot{height:37px;flex:none;border-top:1px solid #f0f2ef;display:flex;align-items:center;justify-content:space-between;padding:0 14px;color:#929991;font-size:9px}.list-foot .online-dot{margin-right:6px}.text-button{border:0;background:transparent;color:#708878;font-size:9px}.reader-pane{overflow-y:auto;padding:0 24px 24px}.reader-empty{height:100%;display:grid;place-items:center;text-align:center;color:#9ca39c}.empty-icon{height:52px;width:52px;margin:0 auto 12px;border-radius:17px;background:#f1f5ef;color:#71937a;display:grid;place-items:center;font-size:24px}.reader-empty h3{font-family:'DM Serif Display',Georgia,serif;font-weight:400;font-size:19px;color:#525a53;margin:0 0 6px}.reader-empty p{font-size:10px;color:#9aa098;margin:0}.reader-header{padding:24px 0 17px;border-bottom:1px solid #edf0ec}.reader-topline{display:flex;align-items:center;justify-content:space-between;margin-bottom:17px}.reader-tags{display:flex;gap:6px}.tag{font-size:8px;border-radius:4px;padding:4px 7px;background:#f4f3e9;color:#a38a52}.tag.green{background:#edf4ee;color:#62816a}.reader-tools{display:flex;gap:2px}.reader-subject{font-family:'DM Serif Display',Georgia,serif;font-size:22px;line-height:1.25;margin:0 0 17px;font-weight:400;color:#343a35}.sender-row{display:flex;align-items:center;gap:9px}.sender-row .contact-avatar{width:34px;height:34px;font-size:10px}.sender-details{min-width:0;flex:1}.sender-details strong{display:block;font-size:10px;color:#434a44}.sender-details span{display:block;font-size:9px;color:#999f99;margin-top:3px}.message-date{font-size:8px;color:#999f99;white-space:nowrap}.reader-body{padding:21px 1px 15px;font-size:11px;line-height:1.85;color:#616a62}.reader-body p{margin:0 0 13px}.reader-body .signoff{margin-top:24px}.attachment{margin-top:18px;padding:11px;border:1px solid #e8ece7;border-radius:8px;display:flex;align-items:center;gap:10px;max-width:260px}.file-icon{height:33px;width:30px;border-radius:6px;background:#f4eeec;color:#ad7466;display:grid;place-items:center;font-size:15px}.attachment-info{flex:1}.attachment-info strong{display:block;font-size:9px;color:#59615a}.attachment-info small{font-size:8px;color:#a1a69f}.download{border:0;background:transparent;color:#8b938b}.reply-bar{border-top:1px solid #edf0ec;padding-top:15px;display:flex;gap:8px}.reply-button{padding:8px 12px;border:1px solid #e3e8e3;border-radius:7px;background:#fff;color:#6e786e;font-size:9px}.reply-button:hover{background:#f6f8f5}.reply-button.primary{background:#5b8068;border-color:#5b8068;color:white}.page-view{padding:22px 28px;overflow:auto}.hidden{display:none!important} -.modal-overlay{position:fixed;inset:0;background:#2028204a;z-index:10;display:grid;place-items:center;padding:20px}.compose-modal{width:min(600px,95vw);background:white;border-radius:13px;box-shadow:0 18px 65px #17271c35;overflow:hidden}.modal-head{padding:15px 19px;background:#f6f7f4;border-bottom:1px solid #ebeee9;display:flex;justify-content:space-between;align-items:center;font-size:11px;font-weight:600}.modal-close{border:0;background:transparent;color:#89908a;font-size:19px}.compose-fields{padding:9px 20px 0}.compose-line{display:flex;align-items:center;gap:10px;min-height:39px;border-bottom:1px solid #f0f1ef;color:#969d96;font-size:10px}.compose-line input{flex:1;border:0;outline:0;font-size:10px;color:#424942}.compose-line input::placeholder{color:#aeb3ad}.compose-subject{border:0;width:100%;font-size:14px!important;padding:15px 0;outline:0;color:#303831}.compose-body{width:100%;height:220px;resize:vertical;border:0;border-top:1px solid #f0f1ef;padding:15px 20px;outline:0;font-size:11px;line-height:1.6;color:#414941}.compose-footer{display:flex;justify-content:space-between;align-items:center;padding:12px 20px 15px}.send-button{border:0;border-radius:6px;background:#5b8068;color:white;padding:8px 16px;font-weight:600;font-size:10px}.discard{border:0;background:transparent;color:#929890;font-size:10px}.toast{position:fixed;bottom:22px;left:50%;transform:translate(-50%,15px);opacity:0;pointer-events:none;background:#293b2e;color:#fff;padding:10px 16px;border-radius:8px;font-size:11px;box-shadow:0 5px 20px #1c2b2030;transition:.2s;z-index:20}.toast.visible{opacity:1;transform:translate(-50%,0)} -/* Wasteland: warm paper, weathered ink and rust. */ -body.wasteland{--bg:#eee8db;--panel:#faf6ed;--line:#e6dccb;--text:#373129;--muted:#998a76;--subtle:#f3ede1;--accent:#a75d3d;--accent-soft:#f5e8dc;--shadow:0 2px 10px #44351d0c}body.wasteland .rail{background:#e7dece;border-color:#dfd4c2}body.wasteland .brand-mark{background:#ad6847}body.wasteland .rail-button.active{background:#f1dfcd;color:#a15a39}body.wasteland .rail-button:hover{background:#eee2d2;color:#9a5739}body.wasteland .sidebar,body.wasteland .topbar{background:#faf6ed;border-color:#e6dccb}body.wasteland .account-card{background:#f4eee2;border-color:#ece2d2}body.wasteland .account-avatar{background:#ead8bf;color:#9b633e}body.wasteland .folder.active{background:#f3e6d7;color:#995c3d}body.wasteland .folder.active .nav-glyph{color:#a76645}body.wasteland .count{color:#9e6947}body.wasteland .list-pane,body.wasteland .reader-pane,body.wasteland .compose-modal{background:#faf6ed;border-color:#e6dccb}body.wasteland .compose-button,body.wasteland .send-button,body.wasteland .reply-button.primary{background:#a76645;border-color:#a76645}body.wasteland .compose-button:hover{background:#905538}body.wasteland .message.selected{background:#f5ede0;box-shadow:inset 2px 0 #ad704c}body.wasteland .reader-empty .empty-icon{background:#f3e8d8;color:#a8734c}body.wasteland .reader-button,body.wasteland .reply-button{background:#faf6ed} -@media(max-width:1040px){.sidebar{width:205px;padding-inline:13px}.mail-layout{grid-template-columns:minmax(310px,47%) minmax(320px,1fr);padding:13px;gap:10px}.reader-pane{padding:0 17px 20px}.topbar{padding:0 16px}.message{gap:7px;padding-inline:9px}.list-heading{padding-inline:14px}} -@media(max-width:800px){.sidebar{width:174px;padding-inline:10px}.mail-layout{grid-template-columns:minmax(290px,1fr) minmax(290px,1fr);padding:9px;gap:8px}.reader-pane{padding-inline:13px}.list-heading h2{font-size:17px}.search-wrap{width:170px}} -.page-heading{display:flex;align-items:center;justify-content:space-between;margin:5px 0 20px}.page-heading h2{font-family:'DM Serif Display',Georgia,serif;font-size:28px;font-weight:400;margin:0 0 5px}.page-subtitle{font-size:11px;color:#929991;margin:0}.cal-actions{display:flex;align-items:center;gap:7px}.outline-button{border:1px solid #e3e8e2;background:#fff;border-radius:6px;padding:7px 10px;color:#69736a;font-size:10px}.calendar-card{background:var(--panel);border:1px solid var(--line);border-radius:11px;overflow:hidden;box-shadow:var(--shadow)}.calendar-week{height:38px;display:grid;grid-template-columns:repeat(7,1fr);border-bottom:1px solid var(--line);align-items:center;text-align:center;color:#969d95;font-size:9px;font-weight:600}.calendar-grid{display:grid;grid-template-columns:repeat(7,1fr)}.cal-cell{height:100px;border-right:1px solid #f0f1ee;border-bottom:1px solid #f0f1ee;padding:8px 7px;cursor:pointer;min-width:0}.cal-cell:nth-child(7n){border-right:0}.cal-cell:hover{background:#fafbf9}.cal-cell.outside{background:#fafbf9;color:#d3d7d1}.cal-number{display:grid;place-items:center;width:21px;height:21px;border-radius:50%;font-size:9px;color:#737c73;margin-bottom:4px}.cal-cell.today .cal-number{background:#5b8068;color:#fff}.event-chip{padding:4px 5px;margin:3px 0;border-radius:4px;font-size:8px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;background:#edf4ee;color:#5b8068}.event-chip.gold{background:#f7f1e4;color:#a28449}.event-chip.blue{background:#edf2f7;color:#6885a5}.upcoming{margin:20px 0 0}.upcoming h3{font-family:'DM Serif Display',Georgia,serif;font-size:17px;font-weight:400;margin:0 0 8px}.upcoming-row{display:flex;gap:12px;align-items:center;padding:10px 12px;border:1px solid var(--line);background:var(--panel);border-radius:8px;margin:6px 0;max-width:380px}.event-date{width:36px;height:38px;border-radius:7px;background:#edf4ee;color:#62816a;display:grid;place-content:center;text-align:center;font-size:8px;line-height:1.3}.event-date strong{font-size:14px}.gold-date{background:#f7f1e4;color:#a28449}.upcoming-row div{display:grid;gap:4px}.upcoming-row div strong{font-size:10px}.upcoming-row small{font-size:9px;color:#979e97}.contact-search{height:38px;max-width:370px;display:flex;align-items:center;gap:8px;padding:0 12px;background:var(--panel);border:1px solid var(--line);border-radius:8px;color:#8c958c;margin-bottom:15px}.contact-search input{border:0;background:transparent;outline:0;flex:1;font-size:10px}.contacts-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(245px,1fr));gap:10px}.contact-card{position:relative;display:flex;align-items:center;gap:11px;padding:14px;background:var(--panel);border:1px solid var(--line);border-radius:9px;box-shadow:var(--shadow)}.contact-card>.contact-avatar{height:39px;width:39px;font-size:11px;flex:none}.contact-card>div:nth-child(2){min-width:0;display:grid;gap:4px}.contact-card>div:nth-child(2) strong{font-size:10px}.contact-card>div:nth-child(2) span{font-size:9px;color:#838b83;overflow:hidden;text-overflow:ellipsis}.contact-card>div:nth-child(2) small{font-size:8px;color:#a0a69f}.contact-more{margin-left:auto;align-self:flex-start}.contact-email{position:absolute;right:12px;bottom:10px;border:0;background:transparent;color:#829386;font-size:12px}body.wasteland .outline-button,body.wasteland .upcoming-row{background:#faf6ed;border-color:#e6dccb}body.wasteland .calendar-card{background:#faf6ed;border-color:#e6dccb}body.wasteland .cal-cell:hover{background:#f7f0e4}body.wasteland .event-chip{background:#f2e9da;color:#996445}body.wasteland .cal-cell.today .cal-number{background:#a76645} -.account-card[role="button"]{cursor:pointer;appearance:none}.account-card[role="button"]:hover{border-color:#dce5dc}.account-card[role="button"]:focus-visible{outline:2px solid #7eae90;outline-offset:2px}.account-note{font-size:10px;line-height:1.5;color:#848c84;margin:7px 0 12px}.account-note+.compose-line{margin-top:1px}.account-status{font-size:10px;line-height:1.5;color:#9a6346;min-height:15px;margin:9px 0 2px} -.attachment{box-sizing:border-box;width:100%;max-width:420px;min-width:0}.attachment-info{min-width:0;overflow:hidden}.attachment-info strong{max-width:100%;overflow-wrap:anywhere;word-break:break-word;line-height:1.4}.attachment .download{flex:none}.account-list{max-height:55vh;overflow-y:auto}.account-row{display:flex;justify-content:space-between;align-items:center;gap:12px;padding:12px 0;border-bottom:1px solid #edf0ec}.account-row-info{min-width:0;display:grid;gap:5px}.account-row-info strong{font-size:11px;overflow-wrap:anywhere}.account-row-info small{font-size:9px;color:#929991;overflow-wrap:anywhere}.account-row-actions{display:flex;align-items:center;gap:8px;flex:none}.account-current{font-size:9px;color:#61836a}.account-row .outline-button{padding:6px 9px}.account-row .discard{padding:6px} - -/* EP Wasteland follows the Eternity Project Gitea theme palette. */ -body.ep-wasteland{color-scheme:dark;--bg:#161210;--panel:#1b1714;--line:#4a3f33;--text:#d4cbbc;--muted:#a89a86;--subtle:#241e19;--accent:#8fae3d;--accent-soft:#2b301d;--shadow:0 2px 12px #0008;background:var(--bg);color:var(--text)} -body.ep-wasteland .rail,body.ep-wasteland .sidebar-head,body.ep-wasteland .topbar,body.ep-wasteland .modal-head{background:#211b17;border-color:#4a3f33} -body.ep-wasteland .brand-mark,body.ep-wasteland .compose-button,body.ep-wasteland .send-button,body.ep-wasteland .reply-button.primary{background:#8fae3d;border-color:#8fae3d;color:#161210} -body.ep-wasteland .brand-mark{box-shadow:0 3px 10px #0006} -body.ep-wasteland .avatar{background:#4a3f33;color:#e7e2d3} -body.ep-wasteland .compose-button:hover{background:#a2bd5b;border-color:#a2bd5b} -body.ep-wasteland .rail-button{color:#b5a995} -body.ep-wasteland .rail-button:hover,body.ep-wasteland .icon-button:hover,body.ep-wasteland .folder:hover,body.ep-wasteland .label-link:hover{background:#2b241e;color:#e7e2d3} -body.ep-wasteland .rail-button.active,body.ep-wasteland .folder.active{background:#343b22;color:#a2bd5b} -body.ep-wasteland .sidebar,body.ep-wasteland .list-pane,body.ep-wasteland .reader-pane,body.ep-wasteland .page-view{background:#1b1714;color:#d4cbbc} -body.ep-wasteland .sidebar{border-color:#4a3f33} -body.ep-wasteland .account-card,body.ep-wasteland .search-wrap,body.ep-wasteland .toolbar,body.ep-wasteland .calendar-card,body.ep-wasteland .contact-search,body.ep-wasteland .contact-card,body.ep-wasteland .upcoming-row,body.ep-wasteland .compose-modal{background:#211b17;border-color:#4a3f33;color:#d4cbbc} -body.ep-wasteland .account-avatar,body.ep-wasteland .contact-avatar{background:#343b22;color:#a2bd5b} -body.ep-wasteland .account-info span,body.ep-wasteland .storage small,body.ep-wasteland .section-label,body.ep-wasteland .date-line,body.ep-wasteland .page-subtitle,body.ep-wasteland .pagination,body.ep-wasteland .time,body.ep-wasteland .sender-details span,body.ep-wasteland .message-date,body.ep-wasteland .contact-card>div:nth-child(2) span,body.ep-wasteland .contact-card>div:nth-child(2) small,body.ep-wasteland .upcoming-row small{color:#a89a86} -body.ep-wasteland .sidebar-head h1,body.ep-wasteland .breadcrumbs strong,body.ep-wasteland .list-heading h2,body.ep-wasteland .page-heading h2,body.ep-wasteland .upcoming h3,body.ep-wasteland .sender-details strong,body.ep-wasteland .reader-subject,body.ep-wasteland .reader-empty h3,body.ep-wasteland .contact-card>div:nth-child(2) strong,body.ep-wasteland .upcoming-row div strong{color:#e7e2d3} -body.ep-wasteland .eyebrow,body.ep-wasteland .breadcrumbs,body.ep-wasteland .icon-button,body.ep-wasteland .folder,body.ep-wasteland .label-link,body.ep-wasteland .settings-button,body.ep-wasteland .nav-glyph,body.ep-wasteland .search-wrap,body.ep-wasteland .help-button{color:#b5a995} -body.ep-wasteland .online-dot{background:#8fae3d} -body.ep-wasteland .folder.active .nav-glyph,body.ep-wasteland .count,body.ep-wasteland .text-button,body.ep-wasteland .contact-email,body.ep-wasteland .account-current{color:#a2bd5b} -body.ep-wasteland .count{background:#2b301d} -body.ep-wasteland .sidebar-divider,body.ep-wasteland .storage,body.ep-wasteland .storage-bar,body.ep-wasteland .toolbar-divider,body.ep-wasteland .reader-header,body.ep-wasteland .reply-bar,body.ep-wasteland .message,body.ep-wasteland .list-foot,body.ep-wasteland .account-row{border-color:#4a3f33} -body.ep-wasteland .storage-bar{background:#4a3f33} -body.ep-wasteland .storage-bar i{background:#8fae3d} -body.ep-wasteland .message{background:#1b1714} -body.ep-wasteland .message:hover,body.ep-wasteland .message.selected{background:#241e19} -body.ep-wasteland .message.selected{box-shadow:inset 2px 0 #8fae3d} -body.ep-wasteland .sender,body.ep-wasteland .subject,body.ep-wasteland .message.unread .sender,body.ep-wasteland .message.unread .subject{color:#e7e2d3} -body.ep-wasteland .snippet,body.ep-wasteland .list-foot,body.ep-wasteland .reader-body{color:#b5a995} -body.ep-wasteland .star{color:#8f8170} -body.ep-wasteland .star.on{color:#a2bd5b} -body.ep-wasteland .reader-empty{color:#a89a86} -body.ep-wasteland .empty-icon,body.ep-wasteland .event-date,body.ep-wasteland .cal-cell.today .cal-number{background:#343b22;color:#a2bd5b} -body.ep-wasteland .attachment,body.ep-wasteland .file-icon{background:#211b17;border-color:#4a3f33;color:#a2bd5b} -body.ep-wasteland .attachment-info strong,body.ep-wasteland .attachment-info small{color:#d4cbbc} -body.ep-wasteland .reply-button,body.ep-wasteland .outline-button{background:#211b17;border-color:#4a3f33;color:#d4cbbc} -body.ep-wasteland .reply-button:hover,body.ep-wasteland .outline-button:hover{background:#2b241e} -body.ep-wasteland .modal-overlay{background:#000b} -body.ep-wasteland .compose-fields,body.ep-wasteland .compose-footer{background:#1b1714} -body.ep-wasteland .compose-line,body.ep-wasteland .compose-body{border-color:#4a3f33;color:#b5a995} -body.ep-wasteland .compose-line input,body.ep-wasteland .compose-subject,body.ep-wasteland .compose-body,body.ep-wasteland .contact-search input{background:transparent;color:#e7e2d3} -body.ep-wasteland .compose-line input::placeholder,body.ep-wasteland .compose-body::placeholder{color:#8f8170} -body.ep-wasteland .modal-close,body.ep-wasteland .discard{color:#a89a86} -body.ep-wasteland .toast{background:#211b17;color:#e7e2d3;border:1px solid #4a3f33} -body.ep-wasteland .calendar-week{border-color:#4a3f33;color:#a89a86} -body.ep-wasteland .cal-cell{border-color:#342c24;color:#d4cbbc} -body.ep-wasteland .cal-cell:hover,body.ep-wasteland .cal-cell.outside{background:#241e19} -body.ep-wasteland .cal-cell.outside{color:#8f8170} -body.ep-wasteland .cal-number{color:#d4cbbc} -body.ep-wasteland .event-chip,body.ep-wasteland .gold-date{background:#343b22;color:#a2bd5b} -body.ep-wasteland .event-chip.gold,body.ep-wasteland .event-chip.blue{background:#2b241e;color:#d4cbbc} -body.ep-wasteland .tag,body.ep-wasteland .tag.green{background:#343b22;color:#a2bd5b} -body.ep-wasteland .row-check{border-color:#8f8170} -body.ep-wasteland .row-check:checked{accent-color:#8fae3d} - -/* EP Daylight follows the Eternity Project Gitea theme palette. */ -body.ep-daylight{color-scheme:light;--bg:#f1f1e9;--panel:#fbfbf6;--line:#b9c5bc;--text:#263a3d;--muted:#70827b;--subtle:#e9eee4;--accent:#526a2c;--accent-soft:#e9eee4;--shadow:0 2px 10px #11212b12;background:var(--bg);color:var(--text)} -body.ep-daylight .rail,body.ep-daylight .sidebar-head,body.ep-daylight .topbar,body.ep-daylight .modal-head{background:#e8e9df;border-color:#b9c5bc} -body.ep-daylight .brand-mark,body.ep-daylight .compose-button,body.ep-daylight .send-button,body.ep-daylight .reply-button.primary{background:#526a2c;border-color:#526a2c;color:#f1f1e9} -body.ep-daylight .brand-mark{box-shadow:0 3px 8px #11212b20} -body.ep-daylight .compose-button:hover{background:#435722;border-color:#435722} -body.ep-daylight .sidebar,body.ep-daylight .list-pane,body.ep-daylight .reader-pane,body.ep-daylight .page-view{background:#fbfbf6;color:#263a3d} -body.ep-daylight .sidebar{border-color:#b9c5bc} -body.ep-daylight .account-card,body.ep-daylight .search-wrap,body.ep-daylight .toolbar,body.ep-daylight .calendar-card,body.ep-daylight .contact-search,body.ep-daylight .contact-card,body.ep-daylight .upcoming-row,body.ep-daylight .compose-modal{background:#fbfbf6;border-color:#b9c5bc;color:#263a3d} -body.ep-daylight .rail-button,body.ep-daylight .icon-button,body.ep-daylight .folder,body.ep-daylight .label-link,body.ep-daylight .settings-button,body.ep-daylight .nav-glyph,body.ep-daylight .help-button{color:#59706b} -body.ep-daylight .rail-button:hover,body.ep-daylight .icon-button:hover,body.ep-daylight .folder:hover,body.ep-daylight .label-link:hover,body.ep-daylight .reply-button:hover,body.ep-daylight .outline-button:hover{background:#e9eee4;color:#263a3d} -body.ep-daylight .rail-button.active,body.ep-daylight .folder.active{background:#e9eee4;color:#526a2c} -body.ep-daylight .account-avatar,body.ep-daylight .contact-avatar{background:#e9eee4;color:#526a2c} -body.ep-daylight .avatar{background:#b9c5bc;color:#11212b} -body.ep-daylight .sidebar-head h1,body.ep-daylight .breadcrumbs strong,body.ep-daylight .list-heading h2,body.ep-daylight .page-heading h2,body.ep-daylight .upcoming h3,body.ep-daylight .sender-details strong,body.ep-daylight .reader-subject,body.ep-daylight .reader-empty h3,body.ep-daylight .contact-card>div:nth-child(2) strong,body.ep-daylight .upcoming-row div strong{color:#11212b} -body.ep-daylight .eyebrow,body.ep-daylight .breadcrumbs,body.ep-daylight .date-line,body.ep-daylight .page-subtitle,body.ep-daylight .section-label,body.ep-daylight .account-info span,body.ep-daylight .storage small,body.ep-daylight .pagination,body.ep-daylight .time,body.ep-daylight .sender-details span,body.ep-daylight .message-date,body.ep-daylight .contact-card>div:nth-child(2) span,body.ep-daylight .contact-card>div:nth-child(2) small,body.ep-daylight .upcoming-row small{color:#59706b} -body.ep-daylight .online-dot,body.ep-daylight .storage-bar i{background:#8fae3d} -body.ep-daylight .folder.active .nav-glyph,body.ep-daylight .count,body.ep-daylight .text-button,body.ep-daylight .contact-email,body.ep-daylight .account-current{color:#526a2c} -body.ep-daylight .count{background:#e9eee4} -body.ep-daylight .sidebar-divider,body.ep-daylight .storage,body.ep-daylight .reader-header,body.ep-daylight .reply-bar,body.ep-daylight .message,body.ep-daylight .list-foot,body.ep-daylight .account-row,body.ep-daylight .calendar-week,body.ep-daylight .cal-cell{border-color:#b9c5bc} -body.ep-daylight .storage-bar,body.ep-daylight .toolbar-divider{background:#b9c5bc} -body.ep-daylight .message{background:#fbfbf6} -body.ep-daylight .message:hover,body.ep-daylight .message.selected{background:#e9eee4} -body.ep-daylight .message.selected{box-shadow:inset 2px 0 #8fae3d} -body.ep-daylight .sender,body.ep-daylight .subject,body.ep-daylight .message.unread .sender,body.ep-daylight .message.unread .subject{color:#11212b} -body.ep-daylight .snippet,body.ep-daylight .list-foot,body.ep-daylight .reader-body{color:#59706b} -body.ep-daylight .star{color:#70827b} -body.ep-daylight .star.on{color:#526a2c} -body.ep-daylight .reader-empty{color:#59706b} -body.ep-daylight .empty-icon,body.ep-daylight .event-date,body.ep-daylight .cal-cell.today .cal-number{background:#e9eee4;color:#526a2c} -body.ep-daylight .attachment,body.ep-daylight .file-icon{background:#fbfbf6;border-color:#b9c5bc;color:#526a2c} -body.ep-daylight .attachment-info strong{color:#263a3d} -body.ep-daylight .attachment-info small{color:#59706b} -body.ep-daylight .reply-button,body.ep-daylight .outline-button{background:#fbfbf6;border-color:#b9c5bc;color:#263a3d} -body.ep-daylight .tag,body.ep-daylight .tag.green,body.ep-daylight .event-chip{background:#e9eee4;color:#526a2c} -body.ep-daylight .event-chip.gold,body.ep-daylight .event-chip.blue,body.ep-daylight .gold-date{background:#e8e9df;color:#59706b} -body.ep-daylight .cal-cell{color:#263a3d} -body.ep-daylight .cal-cell:hover,body.ep-daylight .cal-cell.outside{background:#e9eee4} -body.ep-daylight .cal-cell.outside{color:#70827b} -body.ep-daylight .cal-number{color:#263a3d} -body.ep-daylight .modal-overlay{background:#11212b55} -body.ep-daylight .compose-fields,body.ep-daylight .compose-footer{background:#fbfbf6} -body.ep-daylight .compose-line,body.ep-daylight .compose-body{border-color:#b9c5bc;color:#59706b} -body.ep-daylight .compose-line input,body.ep-daylight .compose-subject,body.ep-daylight .compose-body,body.ep-daylight .contact-search input{background:transparent;color:#11212b} -body.ep-daylight .compose-line input::placeholder,body.ep-daylight .compose-body::placeholder{color:#70827b} -body.ep-daylight .modal-close,body.ep-daylight .discard{color:#59706b} -body.ep-daylight .toast{background:#11212b;color:#f1f1e9} -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} -.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} -@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}} - .search-filters{position:absolute;right:78px;top:calc(100% + 8px);z-index:12;display:grid;grid-template-columns:1fr 1fr;gap:10px;width:min(360px,calc(100vw - 32px));padding:14px;border:1px solid var(--border,#d8ddd5);border-radius:12px;background:var(--panel,#fff);box-shadow:0 8px 28px #17201724}.search-filters.hidden{display:none}.search-filters label{display:grid;gap:4px;font-size:12px}.search-filters input,.search-filters select{min-width:0;border:1px solid var(--border,#d8ddd5);border-radius:7px;padding:7px;background:transparent;color:inherit;font:inherit}.search-filters .filter-checkbox{display:flex;align-items:center;gap:7px}.search-filters .filter-checkbox input{min-width:auto}.search-filters .text-button{grid-column:1/-1;justify-self:start}.top-actions{position:relative} - body.ep-wasteland .search-filters{background:#211c18;border-color:#4a3f33;color:#d4cbbc}body.ep-wasteland .search-filters input,body.ep-wasteland .search-filters select{border-color:#4a3f33;color:#d4cbbc} - body.ep-daylight .search-filters{background:#fbfbf6;border-color:#b9c5bc;color:#263a3d} - .mail-safety-warning{margin:10px 16px;padding:12px 14px;border:1px solid #d69b43;border-left:4px solid #b87321;border-radius:8px;background:#fff6df;color:#5b3c17;font-size:12px}.mail-safety-warning strong{display:block}.mail-safety-warning ul{margin:7px 0;padding-left:18px}.mail-safety-warning small{display:block;line-height:1.4}.mail-links{padding:12px 16px;border-top:1px solid var(--line,#eaede8)}.mail-links h3{margin:0 0 8px;font-size:12px}.mail-safety-intro{font-size:11px;color:#8d4a16}.mail-link-row{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:9px 10px;margin-top:6px;border:1px solid var(--line,#eaede8);border-radius:8px;font-size:11px}.mail-link-row>div{min-width:0;display:grid;gap:3px}.mail-link-row span,.mail-link-row small{overflow-wrap:anywhere;color:#727970}.mail-link-risky{border-color:#d69b43;background:#fff8ea}.mail-link-open{flex:none;border:1px solid #9ba99b;border-radius:6px;background:transparent;padding:6px 8px;font-size:10px}.mail-link-open:disabled{opacity:.55;cursor:wait} - body.ep-wasteland .mail-safety-warning{background:#392719;border-color:#a8793e;color:#f0d4a3}body.ep-wasteland .mail-link-row{border-color:#4a3f33}body.ep-wasteland .mail-link-risky{background:#392719;border-color:#a8793e}body.ep-wasteland .mail-link-row span,body.ep-wasteland .mail-link-row small{color:#cbbba0} - 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} -.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} -.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-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 small{opacity:.85}.pgp-ok{border-color:#3d7a4f;background:rgba(61,122,79,.12)}.pgp-warn{border-color:#b8860b;background:rgba(184,134,11,.14)}.pgp-bad{border-color:#b3261e;background:rgba(179,38,30,.14)} -.pgp-banner button,.pgp-status button{align-self:flex-start;margin-top:6px} -.pgp-compose{display:flex;align-items:center;gap:12px;margin-right:auto;font-size:13px}.pgp-compose label{display:flex;align-items:center;gap:4px}.pgp-compose small{opacity:.8} -.pgp-trust{margin-left:8px} - -.draft-delete{margin-top:4px;font-size:15px;opacity:.55}.draft-delete:hover{opacity:1;color:#b3261e}.pgp-prompt-box{width:min(380px,92vw)} -.reader-body img{display:block;max-width:100%;height:auto;margin:12px 0;border-radius:6px}.reader-body table{max-width:100%;border-collapse:collapse}.reader-body th,.reader-body td{border:1px solid var(--line);padding:5px}.remote-image-notice{margin:14px 0 0;padding:12px;border:1px solid #d7a85c;border-radius:8px;background:#fff8e9;color:#664a23;font-size:10px;line-height:1.5}.remote-image-notice p{margin:0 0 8px}.remote-image-notice .reply-button{background:transparent;color:inherit;border-color:#d7a85c}body.ep-wasteland .remote-image-notice{background:#3a3022;color:#e6d1a8;border-color:#806b44}body.ep-daylight .remote-image-notice{background:#fff8e9;color:#664a23;border-color:#d7a85c} - -.sidebar{overflow-y:auto}#mail-nav{overflow-y:auto;min-height:150px;flex:0 1 auto;scrollbar-width:thin;align-content:start}#custom-folders{display:contents}.folders-head{flex:none}.sidebar>:not(#mail-nav){flex-shrink:0}.folders-head+.folder-nav{margin-top:0} +:root{font-family:'DM Sans',Inter,ui-sans-serif,system-ui,-apple-system,'Segoe UI',sans-serif;color:#252a28;background:#f4f5f1;font-synthesis:none;text-rendering:optimizeLegibility;--bg:#f4f5f1;--panel:#fff;--line:#eaede8;--text:#252a28;--muted:#8b918b;--subtle:#f7f8f5;--accent:#55816c;--accent-soft:#edf4ef;--shadow:0 2px 10px #2636290b} +*{box-sizing:border-box}body{margin:0;min-width:760px;min-height:100vh;background:var(--bg);color:var(--text)}button,input,textarea{font:inherit}button{color:inherit;cursor:pointer}button:focus-visible,input:focus-visible,textarea:focus-visible{outline:2px solid #7eae90;outline-offset:2px}.app-shell{height:100vh;min-height:640px;display:flex;overflow:hidden}.rail{width:66px;flex:none;background:#edf0ea;border-right:1px solid #e5e9e2;display:flex;align-items:center;flex-direction:column;padding:17px 0 13px;gap:10px}.brand-mark{height:35px;width:35px;border-radius:12px;background:#5b826c;color:white;display:grid;place-items:center;font-size:24px;margin-bottom:21px;box-shadow:0 3px 8px #476c541d}.rail-button{height:39px;width:39px;border:0;background:transparent;color:#7e8780;border-radius:11px;font-size:20px;display:grid;place-items:center;transition:.18s}.rail-button:hover{background:#e2e8e1;color:#446a54}.rail-button.active{color:#477253;background:#dce9dd}.rail-spacer{flex:1}.avatar{border:0;border-radius:50%;height:34px;width:34px;background:#e7cbb6;color:#614c3c;font-size:11px;font-weight:700;display:grid;place-items:center}.avatar.tiny{height:27px;width:27px;font-size:9px} +.sidebar{width:244px;flex:none;background:#fff;border-right:1px solid var(--line);padding:26px 17px 14px;display:flex;flex-direction:column}.sidebar-head{display:flex;align-items:center;justify-content:space-between;padding:0 5px;margin-bottom:21px}.eyebrow{color:#969c95;font-size:9px;font-weight:700;letter-spacing:1.25px;margin:0 0 5px}.sidebar-head h1{font-family:'DM Serif Display',Georgia,serif;font-size:24px;font-weight:400;margin:0}.icon-button{border:0;background:transparent;color:#89918a;height:30px;min-width:30px;border-radius:8px;font-size:19px;display:inline-grid;place-items:center}.icon-button:hover{background:var(--subtle);color:#47544a}.account-card{display:flex;align-items:center;gap:10px;padding:10px 9px;background:#f7f8f5;border:1px solid #eff1ec;border-radius:10px;margin:0 0 22px}.account-avatar{height:30px;width:30px;border-radius:9px;background:#dce9dd;color:#477253;display:grid;place-items:center;font-family:Georgia,serif;font-weight:bold}.account-info{min-width:0;display:flex;flex-direction:column;gap:2px;flex:1}.account-info strong{font-size:11px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.account-info span{color:#929891;font-size:9px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.online-dot{display:inline-block;width:7px;height:7px;border-radius:50%;background:#70ad7b}.folder-nav{display:grid;gap:3px}.folder{width:100%;border:0;background:transparent;display:flex;align-items:center;gap:12px;text-align:left;padding:9px 10px;border-radius:8px;font-size:11px;color:#707970}.folder:hover,.label-link:hover{background:#f6f8f5}.folder.active{background:#edf4ee;color:#487354;font-weight:600}.nav-glyph{width:15px;text-align:center;font-size:15px;color:#879188}.folder.active .nav-glyph{color:#578366}.count{margin-left:auto;padding:2px 6px;min-width:19px;text-align:center;border-radius:5px;background:#fff;color:#61836a;font-size:9px}.count.muted{color:#969c95}.sidebar-divider{height:1px;background:#edf0ec;margin:18px 4px 16px}.section-label{display:flex;justify-content:space-between;align-items:center;font-size:9px;letter-spacing:1.1px;font-weight:700;color:#a0a59f;padding:0 6px;margin-bottom:9px}.tiny-plus{border:0;background:transparent;color:#929990;font-size:18px}.label-link{border:0;background:transparent;border-radius:7px;text-align:left;display:flex;align-items:center;gap:10px;color:#727970;font-size:11px;padding:8px 10px}.label-dot{width:8px;height:8px;border-radius:50%}.dot-amber{background:#dda854}.dot-blue{background:#79a4c9}.dot-green{background:#82ab83}.sidebar-bottom{margin-top:auto}.storage{padding:13px 10px 14px;border-bottom:1px solid #eef0ec}.storage-top{display:flex;justify-content:space-between;color:#606960;font-size:10px}.storage-top span+span{color:#979d97;font-size:9px}.storage-bar{height:4px;background:#edf0eb;margin:9px 0 7px;border-radius:5px;overflow:hidden}.storage-bar i{display:block;width:28%;height:100%;background:#79a785;border-radius:5px}.storage small{font-size:9px;color:#9ba19a}.settings-button{border:0;background:transparent;color:#7e867f;display:flex;gap:10px;align-items:center;margin:10px 0 0 4px;font-size:11px;padding:7px} +.main-area{flex:1;min-width:0;display:flex;flex-direction:column}.topbar{height:57px;flex:none;background:#fff;border-bottom:1px solid var(--line);display:flex;align-items:center;justify-content:space-between;padding:0 24px}.breadcrumbs{display:flex;align-items:center;gap:10px;font-size:10px;color:#969c96}.breadcrumbs strong{font-weight:600;color:#475048}.crumb-divider{color:#c6cbc5}.top-actions{display:flex;align-items:center;gap:13px}.search-wrap{height:31px;width:218px;background:#f6f7f4;border:1px solid #eff0ec;border-radius:8px;display:flex;align-items:center;padding:0 9px;gap:7px;color:#90978f}.search-wrap>span{font-size:19px}.search-wrap input{border:0;outline:0;background:transparent;width:100%;font-size:10px;color:#3f4740}.search-wrap kbd{font:9px 'DM Sans',sans-serif;border:1px solid #e3e6e1;border-radius:4px;padding:2px 4px;white-space:nowrap;color:#999f99}.help-button{font-size:12px;border:1px solid #e7eae6;border-radius:50%;height:20px;min-width:20px;font-weight:600}.top-avatar{width:27px;height:27px;font-size:9px} +.content-view{flex:1;min-height:0}.mail-layout{display:grid;grid-template-columns:minmax(330px,44%) minmax(340px,1fr);padding:18px 20px 20px;gap:14px}.list-pane,.reader-pane{background:var(--panel);border:1px solid var(--line);border-radius:12px;box-shadow:var(--shadow);min-height:0}.list-pane{display:flex;flex-direction:column;overflow:hidden}.list-heading{padding:20px 19px 15px;display:flex;align-items:center;justify-content:space-between}.date-line{font-size:8px;font-weight:700;letter-spacing:1.25px;color:#a0a69f;margin-bottom:7px}.list-heading h2{font-family:'DM Serif Display',Georgia,serif;font-size:20px;font-weight:400;margin:0;color:#303732}.sun{font-family:sans-serif;font-size:14px;color:#dda95f;vertical-align:2px}.compose-button{border:0;border-radius:7px;background:#5b8068;color:white;padding:8px 12px;font-size:10px;font-weight:600;box-shadow:0 2px 4px #406e4f20}.compose-button:hover{background:#476f56}.compose-button span{font-size:15px;vertical-align:-1px;margin-right:4px}.toolbar{height:39px;border-top:1px solid #f2f3f1;border-bottom:1px solid #f0f2ee;display:flex;align-items:center;padding:0 12px;gap:6px;color:#888f88}.toolbar .icon-button{font-size:15px;height:26px;min-width:26px}.tool-checkbox{font-size:14px;color:#818981;border:0;background:transparent;width:25px}.toolbar-divider{height:16px;width:1px;background:#e9ece8;margin:0 3px}.toolbar-spacer{flex:1}.pagination{font-size:9px;color:#90968f;white-space:nowrap}.message-list{overflow-y:auto;flex:1}.message{min-height:68px;display:grid;grid-template-columns:18px 32px minmax(0,1fr) auto;align-items:center;gap:9px;padding:9px 12px;border-bottom:1px solid #f0f2ef;cursor:pointer;transition:background .14s}.message:hover{background:#fafbf9}.message.selected{background:#f3f7f2;box-shadow:inset 2px 0 #669074}.message.unread .sender,.message.unread .subject{font-weight:700;color:#303832}.row-check{appearance:none;width:13px;height:13px;border:1px solid #d7dcd6;border-radius:3px;cursor:pointer;margin:0}.row-check:checked{appearance:auto;accent-color:#63866d}.contact-avatar{width:31px;height:31px;border-radius:50%;display:grid;place-items:center;font-size:9px;font-weight:700;color:#55483d;background:#e9d8c9}.message-body{min-width:0;overflow:hidden}.sender{font-size:10px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:#626a63;margin-bottom:4px}.subject{font-size:10px;color:#3e4640;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin-bottom:3px}.snippet{font-size:9px;color:#a1a69f;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.message-meta{height:100%;display:flex;flex-direction:column;justify-content:space-between;align-items:flex-end;padding:2px 0;min-width:31px}.time{font-size:8px;color:#989e98;white-space:nowrap}.star{border:0;background:transparent;color:#c9cec8;font-size:14px;line-height:1;padding:0}.star.on{color:#dcaa56}.list-foot{height:37px;flex:none;border-top:1px solid #f0f2ef;display:flex;align-items:center;justify-content:space-between;padding:0 14px;color:#929991;font-size:9px}.list-foot .online-dot{margin-right:6px}.text-button{border:0;background:transparent;color:#708878;font-size:9px}.reader-pane{overflow-y:auto;padding:0 24px 24px}.reader-empty{height:100%;display:grid;place-items:center;text-align:center;color:#9ca39c}.empty-icon{height:52px;width:52px;margin:0 auto 12px;border-radius:17px;background:#f1f5ef;color:#71937a;display:grid;place-items:center;font-size:24px}.reader-empty h3{font-family:'DM Serif Display',Georgia,serif;font-weight:400;font-size:19px;color:#525a53;margin:0 0 6px}.reader-empty p{font-size:10px;color:#9aa098;margin:0}.reader-header{padding:24px 0 17px;border-bottom:1px solid #edf0ec}.reader-topline{display:flex;align-items:center;justify-content:space-between;margin-bottom:17px}.reader-tags{display:flex;gap:6px}.tag{font-size:8px;border-radius:4px;padding:4px 7px;background:#f4f3e9;color:#a38a52}.tag.green{background:#edf4ee;color:#62816a}.reader-tools{display:flex;gap:2px}.reader-subject{font-family:'DM Serif Display',Georgia,serif;font-size:22px;line-height:1.25;margin:0 0 17px;font-weight:400;color:#343a35}.sender-row{display:flex;align-items:center;gap:9px}.sender-row .contact-avatar{width:34px;height:34px;font-size:10px}.sender-details{min-width:0;flex:1}.sender-details strong{display:block;font-size:10px;color:#434a44}.sender-details span{display:block;font-size:9px;color:#999f99;margin-top:3px}.message-date{font-size:8px;color:#999f99;white-space:nowrap}.reader-body{padding:21px 1px 15px;font-size:11px;line-height:1.85;color:#616a62}.reader-body p{margin:0 0 13px}.reader-body .signoff{margin-top:24px}.attachment{margin-top:18px;padding:11px;border:1px solid #e8ece7;border-radius:8px;display:flex;align-items:center;gap:10px;max-width:260px}.file-icon{height:33px;width:30px;border-radius:6px;background:#f4eeec;color:#ad7466;display:grid;place-items:center;font-size:15px}.attachment-info{flex:1}.attachment-info strong{display:block;font-size:9px;color:#59615a}.attachment-info small{font-size:8px;color:#a1a69f}.download{border:0;background:transparent;color:#8b938b}.reply-bar{border-top:1px solid #edf0ec;padding-top:15px;display:flex;gap:8px}.reply-button{padding:8px 12px;border:1px solid #e3e8e3;border-radius:7px;background:#fff;color:#6e786e;font-size:9px}.reply-button:hover{background:#f6f8f5}.reply-button.primary{background:#5b8068;border-color:#5b8068;color:white}.page-view{padding:22px 28px;overflow:auto}.hidden{display:none!important} +.modal-overlay{position:fixed;inset:0;background:#2028204a;z-index:10;display:grid;place-items:center;padding:20px}.compose-modal{width:min(600px,95vw);background:white;border-radius:13px;box-shadow:0 18px 65px #17271c35;overflow:hidden}.modal-head{padding:15px 19px;background:#f6f7f4;border-bottom:1px solid #ebeee9;display:flex;justify-content:space-between;align-items:center;font-size:11px;font-weight:600}.modal-close{border:0;background:transparent;color:#89908a;font-size:19px}.compose-fields{padding:9px 20px 0}.compose-line{display:flex;align-items:center;gap:10px;min-height:39px;border-bottom:1px solid #f0f1ef;color:#969d96;font-size:10px}.compose-line input{flex:1;border:0;outline:0;font-size:10px;color:#424942}.compose-line input::placeholder{color:#aeb3ad}.compose-subject{border:0;width:100%;font-size:14px!important;padding:15px 0;outline:0;color:#303831}.compose-body{width:100%;height:220px;resize:vertical;border:0;border-top:1px solid #f0f1ef;padding:15px 20px;outline:0;font-size:11px;line-height:1.6;color:#414941}.compose-footer{display:flex;justify-content:space-between;align-items:center;padding:12px 20px 15px}.send-button{border:0;border-radius:6px;background:#5b8068;color:white;padding:8px 16px;font-weight:600;font-size:10px}.discard{border:0;background:transparent;color:#929890;font-size:10px}.toast{position:fixed;bottom:22px;left:50%;transform:translate(-50%,15px);opacity:0;pointer-events:none;background:#293b2e;color:#fff;padding:10px 16px;border-radius:8px;font-size:11px;box-shadow:0 5px 20px #1c2b2030;transition:.2s;z-index:20}.toast.visible{opacity:1;transform:translate(-50%,0)} +/* Wasteland: warm paper, weathered ink and rust. */ +body.wasteland{--bg:#eee8db;--panel:#faf6ed;--line:#e6dccb;--text:#373129;--muted:#998a76;--subtle:#f3ede1;--accent:#a75d3d;--accent-soft:#f5e8dc;--shadow:0 2px 10px #44351d0c}body.wasteland .rail{background:#e7dece;border-color:#dfd4c2}body.wasteland .brand-mark{background:#ad6847}body.wasteland .rail-button.active{background:#f1dfcd;color:#a15a39}body.wasteland .rail-button:hover{background:#eee2d2;color:#9a5739}body.wasteland .sidebar,body.wasteland .topbar{background:#faf6ed;border-color:#e6dccb}body.wasteland .account-card{background:#f4eee2;border-color:#ece2d2}body.wasteland .account-avatar{background:#ead8bf;color:#9b633e}body.wasteland .folder.active{background:#f3e6d7;color:#995c3d}body.wasteland .folder.active .nav-glyph{color:#a76645}body.wasteland .count{color:#9e6947}body.wasteland .list-pane,body.wasteland .reader-pane,body.wasteland .compose-modal{background:#faf6ed;border-color:#e6dccb}body.wasteland .compose-button,body.wasteland .send-button,body.wasteland .reply-button.primary{background:#a76645;border-color:#a76645}body.wasteland .compose-button:hover{background:#905538}body.wasteland .message.selected{background:#f5ede0;box-shadow:inset 2px 0 #ad704c}body.wasteland .reader-empty .empty-icon{background:#f3e8d8;color:#a8734c}body.wasteland .reader-button,body.wasteland .reply-button{background:#faf6ed} +@media(max-width:1040px){.sidebar{width:205px;padding-inline:13px}.mail-layout{grid-template-columns:minmax(310px,47%) minmax(320px,1fr);padding:13px;gap:10px}.reader-pane{padding:0 17px 20px}.topbar{padding:0 16px}.message{gap:7px;padding-inline:9px}.list-heading{padding-inline:14px}} +@media(max-width:800px){.sidebar{width:174px;padding-inline:10px}.mail-layout{grid-template-columns:minmax(290px,1fr) minmax(290px,1fr);padding:9px;gap:8px}.reader-pane{padding-inline:13px}.list-heading h2{font-size:17px}.search-wrap{width:170px}} +.page-heading{display:flex;align-items:center;justify-content:space-between;margin:5px 0 20px}.page-heading h2{font-family:'DM Serif Display',Georgia,serif;font-size:28px;font-weight:400;margin:0 0 5px}.page-subtitle{font-size:11px;color:#929991;margin:0}.cal-actions{display:flex;align-items:center;gap:7px}.outline-button{border:1px solid #e3e8e2;background:#fff;border-radius:6px;padding:7px 10px;color:#69736a;font-size:10px}.calendar-card{background:var(--panel);border:1px solid var(--line);border-radius:11px;overflow:hidden;box-shadow:var(--shadow)}.calendar-week{height:38px;display:grid;grid-template-columns:repeat(7,1fr);border-bottom:1px solid var(--line);align-items:center;text-align:center;color:#969d95;font-size:9px;font-weight:600}.calendar-grid{display:grid;grid-template-columns:repeat(7,1fr)}.cal-cell{height:100px;border-right:1px solid #f0f1ee;border-bottom:1px solid #f0f1ee;padding:8px 7px;cursor:pointer;min-width:0}.cal-cell:nth-child(7n){border-right:0}.cal-cell:hover{background:#fafbf9}.cal-cell.outside{background:#fafbf9;color:#d3d7d1}.cal-number{display:grid;place-items:center;width:21px;height:21px;border-radius:50%;font-size:9px;color:#737c73;margin-bottom:4px}.cal-cell.today .cal-number{background:#5b8068;color:#fff}.event-chip{padding:4px 5px;margin:3px 0;border-radius:4px;font-size:8px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;background:#edf4ee;color:#5b8068}.event-chip.gold{background:#f7f1e4;color:#a28449}.event-chip.blue{background:#edf2f7;color:#6885a5}.upcoming{margin:20px 0 0}.upcoming h3{font-family:'DM Serif Display',Georgia,serif;font-size:17px;font-weight:400;margin:0 0 8px}.upcoming-row{display:flex;gap:12px;align-items:center;padding:10px 12px;border:1px solid var(--line);background:var(--panel);border-radius:8px;margin:6px 0;max-width:380px}.event-date{width:36px;height:38px;border-radius:7px;background:#edf4ee;color:#62816a;display:grid;place-content:center;text-align:center;font-size:8px;line-height:1.3}.event-date strong{font-size:14px}.gold-date{background:#f7f1e4;color:#a28449}.upcoming-row div{display:grid;gap:4px}.upcoming-row div strong{font-size:10px}.upcoming-row small{font-size:9px;color:#979e97}.contact-search{height:38px;max-width:370px;display:flex;align-items:center;gap:8px;padding:0 12px;background:var(--panel);border:1px solid var(--line);border-radius:8px;color:#8c958c;margin-bottom:15px}.contact-search input{border:0;background:transparent;outline:0;flex:1;font-size:10px}.contacts-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(245px,1fr));gap:10px}.contact-card{position:relative;display:flex;align-items:center;gap:11px;padding:14px;background:var(--panel);border:1px solid var(--line);border-radius:9px;box-shadow:var(--shadow)}.contact-card>.contact-avatar{height:39px;width:39px;font-size:11px;flex:none}.contact-card>div:nth-child(2){min-width:0;display:grid;gap:4px}.contact-card>div:nth-child(2) strong{font-size:10px}.contact-card>div:nth-child(2) span{font-size:9px;color:#838b83;overflow:hidden;text-overflow:ellipsis}.contact-card>div:nth-child(2) small{font-size:8px;color:#a0a69f}.contact-more{margin-left:auto;align-self:flex-start}.contact-email{position:absolute;right:12px;bottom:10px;border:0;background:transparent;color:#829386;font-size:12px}body.wasteland .outline-button,body.wasteland .upcoming-row{background:#faf6ed;border-color:#e6dccb}body.wasteland .calendar-card{background:#faf6ed;border-color:#e6dccb}body.wasteland .cal-cell:hover{background:#f7f0e4}body.wasteland .event-chip{background:#f2e9da;color:#996445}body.wasteland .cal-cell.today .cal-number{background:#a76645} +.account-card[role="button"]{cursor:pointer;appearance:none}.account-card[role="button"]:hover{border-color:#dce5dc}.account-card[role="button"]:focus-visible{outline:2px solid #7eae90;outline-offset:2px}.account-note{font-size:10px;line-height:1.5;color:#848c84;margin:7px 0 12px}.account-note+.compose-line{margin-top:1px}.account-status{font-size:10px;line-height:1.5;color:#9a6346;min-height:15px;margin:9px 0 2px} +.attachment{box-sizing:border-box;width:100%;max-width:420px;min-width:0}.attachment-info{min-width:0;overflow:hidden}.attachment-info strong{max-width:100%;overflow-wrap:anywhere;word-break:break-word;line-height:1.4}.attachment .download{flex:none}.account-list{max-height:55vh;overflow-y:auto}.account-row{display:flex;justify-content:space-between;align-items:center;gap:12px;padding:12px 0;border-bottom:1px solid #edf0ec}.account-row-info{min-width:0;display:grid;gap:5px}.account-row-info strong{font-size:11px;overflow-wrap:anywhere}.account-row-info small{font-size:9px;color:#929991;overflow-wrap:anywhere}.account-row-actions{display:flex;align-items:center;gap:8px;flex:none}.account-current{font-size:9px;color:#61836a}.account-row .outline-button{padding:6px 9px}.account-row .discard{padding:6px} + +/* EP Wasteland follows the Eternity Project Gitea theme palette. */ +body.ep-wasteland{color-scheme:dark;--bg:#161210;--panel:#1b1714;--line:#4a3f33;--text:#d4cbbc;--muted:#a89a86;--subtle:#241e19;--accent:#8fae3d;--accent-soft:#2b301d;--shadow:0 2px 12px #0008;background:var(--bg);color:var(--text)} +body.ep-wasteland .rail,body.ep-wasteland .sidebar-head,body.ep-wasteland .topbar,body.ep-wasteland .modal-head{background:#211b17;border-color:#4a3f33} +body.ep-wasteland .brand-mark,body.ep-wasteland .compose-button,body.ep-wasteland .send-button,body.ep-wasteland .reply-button.primary{background:#8fae3d;border-color:#8fae3d;color:#161210} +body.ep-wasteland .brand-mark{box-shadow:0 3px 10px #0006} +body.ep-wasteland .avatar{background:#4a3f33;color:#e7e2d3} +body.ep-wasteland .compose-button:hover{background:#a2bd5b;border-color:#a2bd5b} +body.ep-wasteland .rail-button{color:#b5a995} +body.ep-wasteland .rail-button:hover,body.ep-wasteland .icon-button:hover,body.ep-wasteland .folder:hover,body.ep-wasteland .label-link:hover{background:#2b241e;color:#e7e2d3} +body.ep-wasteland .rail-button.active,body.ep-wasteland .folder.active{background:#343b22;color:#a2bd5b} +body.ep-wasteland .sidebar,body.ep-wasteland .list-pane,body.ep-wasteland .reader-pane,body.ep-wasteland .page-view{background:#1b1714;color:#d4cbbc} +body.ep-wasteland .sidebar{border-color:#4a3f33} +body.ep-wasteland .account-card,body.ep-wasteland .search-wrap,body.ep-wasteland .toolbar,body.ep-wasteland .calendar-card,body.ep-wasteland .contact-search,body.ep-wasteland .contact-card,body.ep-wasteland .upcoming-row,body.ep-wasteland .compose-modal{background:#211b17;border-color:#4a3f33;color:#d4cbbc} +body.ep-wasteland .account-avatar,body.ep-wasteland .contact-avatar{background:#343b22;color:#a2bd5b} +body.ep-wasteland .account-info span,body.ep-wasteland .storage small,body.ep-wasteland .section-label,body.ep-wasteland .date-line,body.ep-wasteland .page-subtitle,body.ep-wasteland .pagination,body.ep-wasteland .time,body.ep-wasteland .sender-details span,body.ep-wasteland .message-date,body.ep-wasteland .contact-card>div:nth-child(2) span,body.ep-wasteland .contact-card>div:nth-child(2) small,body.ep-wasteland .upcoming-row small{color:#a89a86} +body.ep-wasteland .sidebar-head h1,body.ep-wasteland .breadcrumbs strong,body.ep-wasteland .list-heading h2,body.ep-wasteland .page-heading h2,body.ep-wasteland .upcoming h3,body.ep-wasteland .sender-details strong,body.ep-wasteland .reader-subject,body.ep-wasteland .reader-empty h3,body.ep-wasteland .contact-card>div:nth-child(2) strong,body.ep-wasteland .upcoming-row div strong{color:#e7e2d3} +body.ep-wasteland .eyebrow,body.ep-wasteland .breadcrumbs,body.ep-wasteland .icon-button,body.ep-wasteland .folder,body.ep-wasteland .label-link,body.ep-wasteland .settings-button,body.ep-wasteland .nav-glyph,body.ep-wasteland .search-wrap,body.ep-wasteland .help-button{color:#b5a995} +body.ep-wasteland .online-dot{background:#8fae3d} +body.ep-wasteland .folder.active .nav-glyph,body.ep-wasteland .count,body.ep-wasteland .text-button,body.ep-wasteland .contact-email,body.ep-wasteland .account-current{color:#a2bd5b} +body.ep-wasteland .count{background:#2b301d} +body.ep-wasteland .sidebar-divider,body.ep-wasteland .storage,body.ep-wasteland .storage-bar,body.ep-wasteland .toolbar-divider,body.ep-wasteland .reader-header,body.ep-wasteland .reply-bar,body.ep-wasteland .message,body.ep-wasteland .list-foot,body.ep-wasteland .account-row{border-color:#4a3f33} +body.ep-wasteland .storage-bar{background:#4a3f33} +body.ep-wasteland .storage-bar i{background:#8fae3d} +body.ep-wasteland .message{background:#1b1714} +body.ep-wasteland .message:hover,body.ep-wasteland .message.selected{background:#241e19} +body.ep-wasteland .message.selected{box-shadow:inset 2px 0 #8fae3d} +body.ep-wasteland .sender,body.ep-wasteland .subject,body.ep-wasteland .message.unread .sender,body.ep-wasteland .message.unread .subject{color:#e7e2d3} +body.ep-wasteland .snippet,body.ep-wasteland .list-foot,body.ep-wasteland .reader-body{color:#b5a995} +body.ep-wasteland .star{color:#8f8170} +body.ep-wasteland .star.on{color:#a2bd5b} +body.ep-wasteland .reader-empty{color:#a89a86} +body.ep-wasteland .empty-icon,body.ep-wasteland .event-date,body.ep-wasteland .cal-cell.today .cal-number{background:#343b22;color:#a2bd5b} +body.ep-wasteland .attachment,body.ep-wasteland .file-icon{background:#211b17;border-color:#4a3f33;color:#a2bd5b} +body.ep-wasteland .attachment-info strong,body.ep-wasteland .attachment-info small{color:#d4cbbc} +body.ep-wasteland .reply-button,body.ep-wasteland .outline-button{background:#211b17;border-color:#4a3f33;color:#d4cbbc} +body.ep-wasteland .reply-button:hover,body.ep-wasteland .outline-button:hover{background:#2b241e} +body.ep-wasteland .modal-overlay{background:#000b} +body.ep-wasteland .compose-fields,body.ep-wasteland .compose-footer{background:#1b1714} +body.ep-wasteland .compose-line,body.ep-wasteland .compose-body{border-color:#4a3f33;color:#b5a995} +body.ep-wasteland .compose-line input,body.ep-wasteland .compose-subject,body.ep-wasteland .compose-body,body.ep-wasteland .contact-search input{background:transparent;color:#e7e2d3} +body.ep-wasteland .compose-line input::placeholder,body.ep-wasteland .compose-body::placeholder{color:#8f8170} +body.ep-wasteland .modal-close,body.ep-wasteland .discard{color:#a89a86} +body.ep-wasteland .toast{background:#211b17;color:#e7e2d3;border:1px solid #4a3f33} +body.ep-wasteland .calendar-week{border-color:#4a3f33;color:#a89a86} +body.ep-wasteland .cal-cell{border-color:#342c24;color:#d4cbbc} +body.ep-wasteland .cal-cell:hover,body.ep-wasteland .cal-cell.outside{background:#241e19} +body.ep-wasteland .cal-cell.outside{color:#8f8170} +body.ep-wasteland .cal-number{color:#d4cbbc} +body.ep-wasteland .event-chip,body.ep-wasteland .gold-date{background:#343b22;color:#a2bd5b} +body.ep-wasteland .event-chip.gold,body.ep-wasteland .event-chip.blue{background:#2b241e;color:#d4cbbc} +body.ep-wasteland .tag,body.ep-wasteland .tag.green{background:#343b22;color:#a2bd5b} +body.ep-wasteland .row-check{border-color:#8f8170} +body.ep-wasteland .row-check:checked{accent-color:#8fae3d} + +/* EP Daylight follows the Eternity Project Gitea theme palette. */ +body.ep-daylight{color-scheme:light;--bg:#f1f1e9;--panel:#fbfbf6;--line:#b9c5bc;--text:#263a3d;--muted:#70827b;--subtle:#e9eee4;--accent:#526a2c;--accent-soft:#e9eee4;--shadow:0 2px 10px #11212b12;background:var(--bg);color:var(--text)} +body.ep-daylight .rail,body.ep-daylight .sidebar-head,body.ep-daylight .topbar,body.ep-daylight .modal-head{background:#e8e9df;border-color:#b9c5bc} +body.ep-daylight .brand-mark,body.ep-daylight .compose-button,body.ep-daylight .send-button,body.ep-daylight .reply-button.primary{background:#526a2c;border-color:#526a2c;color:#f1f1e9} +body.ep-daylight .brand-mark{box-shadow:0 3px 8px #11212b20} +body.ep-daylight .compose-button:hover{background:#435722;border-color:#435722} +body.ep-daylight .sidebar,body.ep-daylight .list-pane,body.ep-daylight .reader-pane,body.ep-daylight .page-view{background:#fbfbf6;color:#263a3d} +body.ep-daylight .sidebar{border-color:#b9c5bc} +body.ep-daylight .account-card,body.ep-daylight .search-wrap,body.ep-daylight .toolbar,body.ep-daylight .calendar-card,body.ep-daylight .contact-search,body.ep-daylight .contact-card,body.ep-daylight .upcoming-row,body.ep-daylight .compose-modal{background:#fbfbf6;border-color:#b9c5bc;color:#263a3d} +body.ep-daylight .rail-button,body.ep-daylight .icon-button,body.ep-daylight .folder,body.ep-daylight .label-link,body.ep-daylight .settings-button,body.ep-daylight .nav-glyph,body.ep-daylight .help-button{color:#59706b} +body.ep-daylight .rail-button:hover,body.ep-daylight .icon-button:hover,body.ep-daylight .folder:hover,body.ep-daylight .label-link:hover,body.ep-daylight .reply-button:hover,body.ep-daylight .outline-button:hover{background:#e9eee4;color:#263a3d} +body.ep-daylight .rail-button.active,body.ep-daylight .folder.active{background:#e9eee4;color:#526a2c} +body.ep-daylight .account-avatar,body.ep-daylight .contact-avatar{background:#e9eee4;color:#526a2c} +body.ep-daylight .avatar{background:#b9c5bc;color:#11212b} +body.ep-daylight .sidebar-head h1,body.ep-daylight .breadcrumbs strong,body.ep-daylight .list-heading h2,body.ep-daylight .page-heading h2,body.ep-daylight .upcoming h3,body.ep-daylight .sender-details strong,body.ep-daylight .reader-subject,body.ep-daylight .reader-empty h3,body.ep-daylight .contact-card>div:nth-child(2) strong,body.ep-daylight .upcoming-row div strong{color:#11212b} +body.ep-daylight .eyebrow,body.ep-daylight .breadcrumbs,body.ep-daylight .date-line,body.ep-daylight .page-subtitle,body.ep-daylight .section-label,body.ep-daylight .account-info span,body.ep-daylight .storage small,body.ep-daylight .pagination,body.ep-daylight .time,body.ep-daylight .sender-details span,body.ep-daylight .message-date,body.ep-daylight .contact-card>div:nth-child(2) span,body.ep-daylight .contact-card>div:nth-child(2) small,body.ep-daylight .upcoming-row small{color:#59706b} +body.ep-daylight .online-dot,body.ep-daylight .storage-bar i{background:#8fae3d} +body.ep-daylight .folder.active .nav-glyph,body.ep-daylight .count,body.ep-daylight .text-button,body.ep-daylight .contact-email,body.ep-daylight .account-current{color:#526a2c} +body.ep-daylight .count{background:#e9eee4} +body.ep-daylight .sidebar-divider,body.ep-daylight .storage,body.ep-daylight .reader-header,body.ep-daylight .reply-bar,body.ep-daylight .message,body.ep-daylight .list-foot,body.ep-daylight .account-row,body.ep-daylight .calendar-week,body.ep-daylight .cal-cell{border-color:#b9c5bc} +body.ep-daylight .storage-bar,body.ep-daylight .toolbar-divider{background:#b9c5bc} +body.ep-daylight .message{background:#fbfbf6} +body.ep-daylight .message:hover,body.ep-daylight .message.selected{background:#e9eee4} +body.ep-daylight .message.selected{box-shadow:inset 2px 0 #8fae3d} +body.ep-daylight .sender,body.ep-daylight .subject,body.ep-daylight .message.unread .sender,body.ep-daylight .message.unread .subject{color:#11212b} +body.ep-daylight .snippet,body.ep-daylight .list-foot,body.ep-daylight .reader-body{color:#59706b} +body.ep-daylight .star{color:#70827b} +body.ep-daylight .star.on{color:#526a2c} +body.ep-daylight .reader-empty{color:#59706b} +body.ep-daylight .empty-icon,body.ep-daylight .event-date,body.ep-daylight .cal-cell.today .cal-number{background:#e9eee4;color:#526a2c} +body.ep-daylight .attachment,body.ep-daylight .file-icon{background:#fbfbf6;border-color:#b9c5bc;color:#526a2c} +body.ep-daylight .attachment-info strong{color:#263a3d} +body.ep-daylight .attachment-info small{color:#59706b} +body.ep-daylight .reply-button,body.ep-daylight .outline-button{background:#fbfbf6;border-color:#b9c5bc;color:#263a3d} +body.ep-daylight .tag,body.ep-daylight .tag.green,body.ep-daylight .event-chip{background:#e9eee4;color:#526a2c} +body.ep-daylight .event-chip.gold,body.ep-daylight .event-chip.blue,body.ep-daylight .gold-date{background:#e8e9df;color:#59706b} +body.ep-daylight .cal-cell{color:#263a3d} +body.ep-daylight .cal-cell:hover,body.ep-daylight .cal-cell.outside{background:#e9eee4} +body.ep-daylight .cal-cell.outside{color:#70827b} +body.ep-daylight .cal-number{color:#263a3d} +body.ep-daylight .modal-overlay{background:#11212b55} +body.ep-daylight .compose-fields,body.ep-daylight .compose-footer{background:#fbfbf6} +body.ep-daylight .compose-line,body.ep-daylight .compose-body{border-color:#b9c5bc;color:#59706b} +body.ep-daylight .compose-line input,body.ep-daylight .compose-subject,body.ep-daylight .compose-body,body.ep-daylight .contact-search input{background:transparent;color:#11212b} +body.ep-daylight .compose-line input::placeholder,body.ep-daylight .compose-body::placeholder{color:#70827b} +body.ep-daylight .modal-close,body.ep-daylight .discard{color:#59706b} +body.ep-daylight .toast{background:#11212b;color:#f1f1e9} +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} +.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} +@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}} + .search-filters{position:absolute;right:78px;top:calc(100% + 8px);z-index:12;display:grid;grid-template-columns:1fr 1fr;gap:10px;width:min(360px,calc(100vw - 32px));padding:14px;border:1px solid var(--border,#d8ddd5);border-radius:12px;background:var(--panel,#fff);box-shadow:0 8px 28px #17201724}.search-filters.hidden{display:none}.search-filters label{display:grid;gap:4px;font-size:12px}.search-filters input,.search-filters select{min-width:0;border:1px solid var(--border,#d8ddd5);border-radius:7px;padding:7px;background:transparent;color:inherit;font:inherit}.search-filters .filter-checkbox{display:flex;align-items:center;gap:7px}.search-filters .filter-checkbox input{min-width:auto}.search-filters .text-button{grid-column:1/-1;justify-self:start}.top-actions{position:relative} + body.ep-wasteland .search-filters{background:#211c18;border-color:#4a3f33;color:#d4cbbc}body.ep-wasteland .search-filters input,body.ep-wasteland .search-filters select{border-color:#4a3f33;color:#d4cbbc} + body.ep-daylight .search-filters{background:#fbfbf6;border-color:#b9c5bc;color:#263a3d} + .mail-safety-warning{margin:10px 16px;padding:12px 14px;border:1px solid #d69b43;border-left:4px solid #b87321;border-radius:8px;background:#fff6df;color:#5b3c17;font-size:12px}.mail-safety-warning strong{display:block}.mail-safety-warning ul{margin:7px 0;padding-left:18px}.mail-safety-warning small{display:block;line-height:1.4}.mail-links{padding:12px 16px;border-top:1px solid var(--line,#eaede8)}.mail-links h3{margin:0 0 8px;font-size:12px}.mail-safety-intro{font-size:11px;color:#8d4a16}.mail-link-row{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:9px 10px;margin-top:6px;border:1px solid var(--line,#eaede8);border-radius:8px;font-size:11px}.mail-link-row>div{min-width:0;display:grid;gap:3px}.mail-link-row span,.mail-link-row small{overflow-wrap:anywhere;color:#727970}.mail-link-risky{border-color:#d69b43;background:#fff8ea}.mail-link-open{flex:none;border:1px solid #9ba99b;border-radius:6px;background:transparent;padding:6px 8px;font-size:10px}.mail-link-open:disabled{opacity:.55;cursor:wait} + body.ep-wasteland .mail-safety-warning{background:#392719;border-color:#a8793e;color:#f0d4a3}body.ep-wasteland .mail-link-row{border-color:#4a3f33}body.ep-wasteland .mail-link-risky{background:#392719;border-color:#a8793e}body.ep-wasteland .mail-link-row span,body.ep-wasteland .mail-link-row small{color:#cbbba0} + 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} +.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} +.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-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 small{opacity:.85}.pgp-ok{border-color:#3d7a4f;background:rgba(61,122,79,.12)}.pgp-warn{border-color:#b8860b;background:rgba(184,134,11,.14)}.pgp-bad{border-color:#b3261e;background:rgba(179,38,30,.14)} +.pgp-banner button,.pgp-status button{align-self:flex-start;margin-top:6px} +.pgp-compose{display:flex;align-items:center;gap:12px;margin-right:auto;font-size:13px}.pgp-compose label{display:flex;align-items:center;gap:4px}.pgp-compose small{opacity:.8} +.pgp-trust{margin-left:8px} + +.draft-delete{margin-top:4px;font-size:15px;opacity:.55}.draft-delete:hover{opacity:1;color:#b3261e}.pgp-prompt-box{width:min(380px,92vw)} +.reader-body img{display:block;max-width:100%;height:auto;margin:12px 0;border-radius:6px}.reader-body table{max-width:100%;border-collapse:collapse}.reader-body th,.reader-body td{border:1px solid var(--line);padding:5px}.remote-image-notice{margin:14px 0 0;padding:12px;border:1px solid #d7a85c;border-radius:8px;background:#fff8e9;color:#664a23;font-size:10px;line-height:1.5}.remote-image-notice p{margin:0 0 8px}.remote-image-notice .reply-button{background:transparent;color:inherit;border-color:#d7a85c}body.ep-wasteland .remote-image-notice{background:#3a3022;color:#e6d1a8;border-color:#806b44}body.ep-daylight .remote-image-notice{background:#fff8e9;color:#664a23;border-color:#d7a85c} + +.sidebar{overflow-y:auto}#mail-nav{overflow-y:auto;min-height:150px;flex:0 1 auto;scrollbar-width:thin;align-content:start}#custom-folders{display:contents}.folders-head{flex:none}.sidebar>:not(#mail-nav){flex-shrink:0}.folders-head+.folder-nav{margin-top:0}