@bobfrankston/mailx 1.0.304 → 1.0.305

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/bin/mailx.js CHANGED
@@ -906,15 +906,18 @@ async function main() {
906
906
  if (req._action === "performUpdate") {
907
907
  handle.send({ _cbid: req._cbid, ok: true, status: "updating" });
908
908
  try {
909
- const { execSync } = await import("child_process");
909
+ const { execSync, spawn: spawnChild } = await import("child_process");
910
910
  console.log(" [update] Installing latest version...");
911
911
  execSync("npm install -g @bobfrankston/mailx", { encoding: "utf-8", timeout: 120_000, stdio: "inherit" });
912
- console.log(" [update] Install complete — restarting");
912
+ console.log(" [update] Install complete — relaunching");
913
+ // Spawn the new version detached so it outlives this process
914
+ const child = spawnChild("mailx", [], { detached: true, stdio: "ignore", shell: true });
915
+ child.unref();
913
916
  }
914
917
  catch (e) {
915
918
  console.error(` [update] Install failed: ${e.message}`);
916
919
  }
917
- gracefulShutdown("Update complete — restarting");
920
+ gracefulShutdown("Update applied");
918
921
  return;
919
922
  }
920
923
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bobfrankston/mailx",
3
- "version": "1.0.304",
3
+ "version": "1.0.305",
4
4
  "description": "Local-first email client with IMAP sync and standalone native app",
5
5
  "type": "module",
6
6
  "main": "bin/mailx.js",
@@ -24,7 +24,7 @@
24
24
  "@bobfrankston/iflow-node": "^0.1.7",
25
25
  "@bobfrankston/miscinfo": "^1.0.8",
26
26
  "@bobfrankston/oauthsupport": "^1.0.24",
27
- "@bobfrankston/msger": "^0.1.326",
27
+ "@bobfrankston/msger": "^0.1.327",
28
28
  "@capacitor/android": "^8.3.0",
29
29
  "@capacitor/cli": "^8.3.0",
30
30
  "@capacitor/core": "^8.3.0",
@@ -86,7 +86,7 @@
86
86
  "@bobfrankston/iflow-node": "^0.1.7",
87
87
  "@bobfrankston/miscinfo": "^1.0.8",
88
88
  "@bobfrankston/oauthsupport": "^1.0.24",
89
- "@bobfrankston/msger": "^0.1.326",
89
+ "@bobfrankston/msger": "^0.1.327",
90
90
  "@capacitor/android": "^8.3.0",
91
91
  "@capacitor/cli": "^8.3.0",
92
92
  "@capacitor/core": "^8.3.0",
@@ -464,9 +464,11 @@ export class ImapManager extends EventEmitter {
464
464
  }
465
465
  const tokenDir = path.join(getConfigDir(), "tokens", account.imap.user.replace(/[@.]/g, "_"));
466
466
  tokenProvider = async () => {
467
- // Wrap authenticateOAuth with a 30s wall-clock timeout. Without this,
468
- // a hung OAuth server could block the entire sync thread indefinitely.
469
- const TOKEN_FETCH_TIMEOUT_MS = 30000;
467
+ // Wall-clock timeout on OAuth. Use a longer timeout when no
468
+ // cached token exists (first auth needs user to click through
469
+ // the browser consent screen — 30s is too tight).
470
+ const hasToken = fs.existsSync(path.join(tokenDir, "oauth-token.json"));
471
+ const TOKEN_FETCH_TIMEOUT_MS = hasToken ? 30_000 : 120_000;
470
472
  const authPromise = authenticateOAuth(credPath, {
471
473
  scope: "https://mail.google.com/ https://www.googleapis.com/auth/contacts.readonly https://www.googleapis.com/auth/calendar https://www.googleapis.com/auth/drive",
472
474
  tokenDirectory: tokenDir,