@bobfrankston/mailx-imap 0.1.62 → 0.1.64
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/index.js +17 -5
- 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";
|
|
@@ -113,8 +113,20 @@ async function extractPreview(source) {
|
|
|
113
113
|
const parsed = await parseSerial(fixCharsetDeclString(source), "background");
|
|
114
114
|
const bodyText = parsed.text || "";
|
|
115
115
|
const bodyHtml = parsed.html || "";
|
|
116
|
-
//
|
|
117
|
-
|
|
116
|
+
// Prefer HTML so we can replace <img> with [image] before tag-strip;
|
|
117
|
+
// fall back to text if no HTML part. Either source then gets any
|
|
118
|
+
// remaining base64 data: URIs (rare: text/plain copies generated
|
|
119
|
+
// from a Quill compose pasted-image HTML) collapsed to [image] too.
|
|
120
|
+
let raw;
|
|
121
|
+
if (bodyHtml) {
|
|
122
|
+
raw = bodyHtml
|
|
123
|
+
.replace(/<img\b[^>]*>/gi, " [image] ")
|
|
124
|
+
.replace(/<[^>]+>/g, " ");
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
raw = bodyText;
|
|
128
|
+
}
|
|
129
|
+
raw = raw.replace(/data:image\/[a-z0-9.+-]+;base64,[A-Za-z0-9+/=\s]+/gi, "[image]");
|
|
118
130
|
const preview = decodeEntities(raw).replace(/\s+/g, " ").trim().slice(0, 200);
|
|
119
131
|
const hasAttachments = (parsed.attachments?.length || 0) > 0;
|
|
120
132
|
return { bodyHtml, bodyText, preview, hasAttachments };
|
|
@@ -284,7 +296,7 @@ export class ImapManager extends EventEmitter {
|
|
|
284
296
|
this.watchers.delete(accountId);
|
|
285
297
|
}
|
|
286
298
|
// Delete only the IMAP token (not contacts — separate scope, separate consent)
|
|
287
|
-
const accountDir = account.imap.user
|
|
299
|
+
const accountDir = tokenDirName(account.imap.user);
|
|
288
300
|
const tokenDir = path.join(getConfigDir(), "tokens", accountDir);
|
|
289
301
|
const tokenPath = path.join(tokenDir, "token.json");
|
|
290
302
|
if (fs.existsSync(tokenPath)) {
|
|
@@ -728,7 +740,7 @@ export class ImapManager extends EventEmitter {
|
|
|
728
740
|
}
|
|
729
741
|
catch { /* iflow-direct not resolvable */ }
|
|
730
742
|
}
|
|
731
|
-
const tokenDir = path.join(getConfigDir(), "tokens", account.imap.user
|
|
743
|
+
const tokenDir = path.join(getConfigDir(), "tokens", tokenDirName(account.imap.user));
|
|
732
744
|
tokenProvider = async () => {
|
|
733
745
|
// Wall-clock timeout on OAuth. Use a longer timeout when no
|
|
734
746
|
// cached token exists (first auth needs user to click through
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bobfrankston/mailx-imap",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.64",
|
|
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.
|
|
13
|
+
"@bobfrankston/mailx-settings": "^0.1.24",
|
|
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.
|
|
41
|
+
"@bobfrankston/mailx-settings": "^0.1.24",
|
|
42
42
|
"@bobfrankston/mailx-store": "^0.1.37",
|
|
43
43
|
"@bobfrankston/iflow-direct": "^0.1.50",
|
|
44
44
|
"@bobfrankston/tcp-transport": "^0.1.6",
|