@bobfrankston/mailx-imap 0.1.61 → 0.1.63

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.
Files changed (2) hide show
  1. package/index.js +17 -3
  2. package/package.json +3 -3
package/index.js CHANGED
@@ -6,7 +6,7 @@
6
6
  import { createAutoImapConfig, CompatImapClient } from "@bobfrankston/iflow-direct";
7
7
  import { authenticateOAuth } from "@bobfrankston/oauthsupport";
8
8
  import { parseSerial, fixCharsetDeclString, storeBus } from "@bobfrankston/mailx-store";
9
- import { loadSettings, getConfigDir, getHistoryDays, getPrefetch } from "@bobfrankston/mailx-settings";
9
+ import { loadSettings, getConfigDir, getHistoryDays, getPrefetch, tokenDirName } from "@bobfrankston/mailx-settings";
10
10
  import { EventEmitter } from "node:events";
11
11
  import * as fs from "node:fs";
12
12
  import * as path from "node:path";
@@ -284,7 +284,7 @@ export class ImapManager extends EventEmitter {
284
284
  this.watchers.delete(accountId);
285
285
  }
286
286
  // Delete only the IMAP token (not contacts — separate scope, separate consent)
287
- const accountDir = account.imap.user.replace(/[@.]/g, "_");
287
+ const accountDir = tokenDirName(account.imap.user);
288
288
  const tokenDir = path.join(getConfigDir(), "tokens", accountDir);
289
289
  const tokenPath = path.join(tokenDir, "token.json");
290
290
  if (fs.existsSync(tokenPath)) {
@@ -728,7 +728,7 @@ export class ImapManager extends EventEmitter {
728
728
  }
729
729
  catch { /* iflow-direct not resolvable */ }
730
730
  }
731
- const tokenDir = path.join(getConfigDir(), "tokens", account.imap.user.replace(/[@.]/g, "_"));
731
+ const tokenDir = path.join(getConfigDir(), "tokens", tokenDirName(account.imap.user));
732
732
  tokenProvider = async () => {
733
733
  // Wall-clock timeout on OAuth. Use a longer timeout when no
734
734
  // cached token exists (first auth needs user to click through
@@ -744,6 +744,20 @@ export class ImapManager extends EventEmitter {
744
744
  tokenDirectory: tokenDir,
745
745
  credentialsKey: "installed",
746
746
  loginHint: account.imap.user,
747
+ // Route info/error to the daemon log. oauthsupport's
748
+ // default logFn drops info silently — that masked "full
749
+ // reauth keeps firing" with no log trail (Bob 2026-05-25
750
+ // "the log should be showing the auth request"). With
751
+ // this, "Forcing consent prompt", "No valid token found,
752
+ // starting OAuth authentication", "Token refresh failed"
753
+ // all land in rmfmail-*.log under [oauth] prefix.
754
+ logFn: (type, message) => {
755
+ const prefix = ` [oauth ${account.id}]`;
756
+ if (type === "error")
757
+ console.error(`${prefix} ${message}`);
758
+ else
759
+ console.log(`${prefix} ${message}`);
760
+ },
747
761
  });
748
762
  const timeoutPromise = new Promise((_, reject) => setTimeout(() => reject(new Error(`OAuth token fetch timeout (${TOKEN_FETCH_TIMEOUT_MS / 1000}s)`)), TOKEN_FETCH_TIMEOUT_MS));
749
763
  const result = await Promise.race([authPromise, timeoutPromise]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bobfrankston/mailx-imap",
3
- "version": "0.1.61",
3
+ "version": "0.1.63",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -10,7 +10,7 @@
10
10
  "license": "ISC",
11
11
  "dependencies": {
12
12
  "@bobfrankston/mailx-types": "^0.1.18",
13
- "@bobfrankston/mailx-settings": "^0.1.22",
13
+ "@bobfrankston/mailx-settings": "^0.1.23",
14
14
  "@bobfrankston/mailx-store": "^0.1.37",
15
15
  "@bobfrankston/iflow-direct": "^0.1.50",
16
16
  "@bobfrankston/tcp-transport": "^0.1.6",
@@ -38,7 +38,7 @@
38
38
  ".transformedSnapshot": {
39
39
  "dependencies": {
40
40
  "@bobfrankston/mailx-types": "^0.1.18",
41
- "@bobfrankston/mailx-settings": "^0.1.22",
41
+ "@bobfrankston/mailx-settings": "^0.1.23",
42
42
  "@bobfrankston/mailx-store": "^0.1.37",
43
43
  "@bobfrankston/iflow-direct": "^0.1.50",
44
44
  "@bobfrankston/tcp-transport": "^0.1.6",