proton-mail-bridge-client 2.9.1 → 2.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -3642,8 +3642,9 @@ function validatePortEnv(name) {
3642
3642
  throw new Error(`${name} must be an integer between 1 and 65535, got: ${raw}`);
3643
3643
  }
3644
3644
  }
3645
- // One switch for the safety flags. A mode only sets the starting point: any of the individual variables that is set
3646
- // explicitly still wins, so a mode never takes a setting away that someone chose on purpose.
3645
+ // One switch for the safety flags. A mode is a floor: the individual variables can make things stricter, never
3646
+ // looser. The Claude Desktop bundle always sends read-only and allow-sending explicitly, so a mode that an explicit
3647
+ // value could loosen would be ignored for exactly the people who pick it there.
3647
3648
  const SAFETY_MODES = {
3648
3649
  // Browse and search only: nothing is written, nothing is sent.
3649
3650
  "read-only": { readOnly: true },
@@ -3655,7 +3656,8 @@ const SAFETY_MODES = {
3655
3656
  };
3656
3657
  function parseSafetyModeEnv(name) {
3657
3658
  const raw = process.env[name]?.trim().toLowerCase();
3658
- if (!raw) {
3659
+ // An unfilled "${user_config.mode}" from a host that did not substitute it is "not set", not a typo to fail on.
3660
+ if (!raw || raw.startsWith("${")) {
3659
3661
  return undefined;
3660
3662
  }
3661
3663
  if (Object.hasOwn(SAFETY_MODES, raw)) {
@@ -3663,10 +3665,10 @@ function parseSafetyModeEnv(name) {
3663
3665
  }
3664
3666
  throw new Error(`${name} must be one of: ${Object.keys(SAFETY_MODES).join(", ")} (got "${raw}").`);
3665
3667
  }
3666
- function parseAllowedActionsEnv(name, fallback = ALL_EMAIL_ACTIONS) {
3668
+ function parseAllowedActionsEnv(name) {
3667
3669
  const configured = parseListValues(process.env[name]);
3668
3670
  if (configured.length === 0) {
3669
- return [...fallback];
3671
+ return [...ALL_EMAIL_ACTIONS];
3670
3672
  }
3671
3673
  const allowed = configured.filter((value) => ALL_EMAIL_ACTIONS.includes(value));
3672
3674
  if (allowed.length === 0) {
@@ -3780,14 +3782,14 @@ export function buildConfigFromEnv() {
3780
3782
  const debug = parseBooleanEnv("DEBUG", false);
3781
3783
  const mode = parseSafetyModeEnv("PROTONMAIL_MODE");
3782
3784
  const preset = mode ? SAFETY_MODES[mode] : {};
3783
- const readOnly = parseBooleanEnv("PROTONMAIL_READ_ONLY", preset.readOnly ?? false);
3784
- const allowSend = parseBooleanEnv("PROTONMAIL_ALLOW_SEND", preset.allowSend ?? !readOnly);
3785
+ const readOnly = (preset.readOnly ?? false) || parseBooleanEnv("PROTONMAIL_READ_ONLY", false);
3786
+ const allowSend = (preset.allowSend ?? true) && parseBooleanEnv("PROTONMAIL_ALLOW_SEND", !readOnly);
3785
3787
  const allowRemoteDraftSync = parseBooleanEnv("PROTONMAIL_ALLOW_REMOTE_DRAFT_SYNC", !readOnly);
3786
3788
  const autoSync = parseBooleanEnv("PROTONMAIL_AUTO_SYNC", true);
3787
3789
  const syncInterval = parseIntegerEnv("PROTONMAIL_SYNC_INTERVAL_MINUTES", 5, 1, 24 * 60);
3788
3790
  const idleWatchEnabled = parseBooleanEnv("PROTONMAIL_IDLE_WATCH", autoSync);
3789
3791
  const idleMaxSeconds = parseIntegerEnv("PROTONMAIL_IDLE_MAX_SECONDS", 30, 5, 300);
3790
- const confirmDestructive = parseBooleanEnv("PROTONMAIL_CONFIRM_DESTRUCTIVE", preset.confirmDestructive ?? false);
3792
+ const confirmDestructive = (preset.confirmDestructive ?? false) || parseBooleanEnv("PROTONMAIL_CONFIRM_DESTRUCTIVE", false);
3791
3793
  const allowEmptyFolder = parseBooleanEnv("PROTONMAIL_ALLOW_EMPTY_FOLDER", false);
3792
3794
  const restrictOutboundToSelf = parseBooleanEnv("PROTONMAIL_RESTRICT_OUTBOUND_TO_SELF", false);
3793
3795
  const allowFileDownloadDir = process.env.PROTONMAIL_ALLOW_FILE_DOWNLOAD_DIR?.trim() || undefined;
@@ -3836,7 +3838,7 @@ export function buildConfigFromEnv() {
3836
3838
  readOnly,
3837
3839
  allowSend,
3838
3840
  allowRemoteDraftSync,
3839
- allowedActions: parseAllowedActionsEnv("PROTONMAIL_ALLOWED_ACTIONS", preset.allowedActions),
3841
+ allowedActions: parseAllowedActionsEnv("PROTONMAIL_ALLOWED_ACTIONS").filter((action) => !preset.allowedActions || preset.allowedActions.includes(action)),
3840
3842
  startupSync: parseBooleanEnv("PROTONMAIL_STARTUP_SYNC", autoSync),
3841
3843
  // Comma-separated; Sent is included by default so pendingOn/digest/follow-up
3842
3844
  // candidates don't misreport threads that were already answered — IDLE still