@bobfrankston/iflow-direct 0.1.56 → 0.1.58
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/README.md +28 -5
- package/imap-native.js +11 -2
- package/package.json +2 -10
package/README.md
CHANGED
|
@@ -11,19 +11,25 @@ and the desktop/browser architecture diagram.
|
|
|
11
11
|
|
|
12
12
|
```bash
|
|
13
13
|
npm install @bobfrankston/iflow-direct
|
|
14
|
-
# desktop TCP transport:
|
|
15
|
-
npm install @bobfrankston/tcp-transport
|
|
14
|
+
# desktop (Node) TCP transport implementation:
|
|
15
|
+
npm install @bobfrankston/node-tcp-transport
|
|
16
16
|
```
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
`@bobfrankston/tcp-transport` is the *interface* package (`TcpTransport` is a
|
|
19
|
+
type, plus the browser/Android `BridgeTcpTransport`); the class you instantiate
|
|
20
|
+
in Node is `NodeTcpTransport` from `@bobfrankston/node-tcp-transport`
|
|
21
|
+
(node:net/tls). `@bobfrankston/iflow-node` is a back-compat shim re-exporting
|
|
22
|
+
it as `NodeTransport` — new code should not use it.
|
|
23
|
+
|
|
24
|
+
## Quick start (Node)
|
|
19
25
|
|
|
20
26
|
```typescript
|
|
21
27
|
import { NativeImapClient } from "@bobfrankston/iflow-direct";
|
|
22
|
-
import {
|
|
28
|
+
import { NodeTcpTransport } from "@bobfrankston/node-tcp-transport";
|
|
23
29
|
|
|
24
30
|
const client = new NativeImapClient(
|
|
25
31
|
{ server: "imap.example.com", port: 993, username: "me", password: "..." },
|
|
26
|
-
() => new
|
|
32
|
+
() => new NodeTcpTransport(),
|
|
27
33
|
);
|
|
28
34
|
await client.connect();
|
|
29
35
|
await client.select("INBOX");
|
|
@@ -31,6 +37,23 @@ const msgs = await client.fetchMessages("1:50", { source: false });
|
|
|
31
37
|
await client.logout();
|
|
32
38
|
```
|
|
33
39
|
|
|
40
|
+
For OAuth (Gmail, Office 365), omit `password` and supply a `tokenProvider` —
|
|
41
|
+
an async function returning a current access token; the client calls it at
|
|
42
|
+
authentication time, so refresh logic lives in the provider:
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
const client = new NativeImapClient(
|
|
46
|
+
{
|
|
47
|
+
server: "imap.gmail.com", port: 993, username: "me@gmail.com",
|
|
48
|
+
tokenProvider: async () => myOauth.getFreshAccessToken(),
|
|
49
|
+
},
|
|
50
|
+
() => new NodeTcpTransport(),
|
|
51
|
+
);
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
(mailx pairs this with `@bobfrankston/oauthsupport`, but any source of a valid
|
|
55
|
+
token works.)
|
|
56
|
+
|
|
34
57
|
For the legacy API shape (`getFolderList`, etc.) use `CompatImapClient` from the
|
|
35
58
|
same package.
|
|
36
59
|
|
package/imap-native.js
CHANGED
|
@@ -588,13 +588,19 @@ export class NativeImapClient {
|
|
|
588
588
|
}
|
|
589
589
|
const allMessages = [];
|
|
590
590
|
let chunkSize = this.fetchChunkSize;
|
|
591
|
-
|
|
591
|
+
// Advance by the chunk ACTUALLY fetched, then grow. The old
|
|
592
|
+
// `i += chunkSize` used the post-growth size, so after chunk 1
|
|
593
|
+
// (say 25 UIDs) the index jumped 100 — UIDs 25..99 were silently
|
|
594
|
+
// skipped on every multi-chunk fetch (imail "skips some letters",
|
|
595
|
+
// Bob 2026-07-17; mailx relied on set-diff sweeps to mop up).
|
|
596
|
+
for (let i = 0; i < uids.length;) {
|
|
592
597
|
const chunk = uids.slice(i, i + chunkSize);
|
|
593
598
|
const msgs = await this.fetchMessages(chunk.join(","), options);
|
|
594
599
|
allMessages.push(...msgs);
|
|
595
600
|
// console.log(` [fetch] ${allMessages.length}/${uids.length} (chunk of ${chunk.length})`);
|
|
596
601
|
if (onChunk)
|
|
597
602
|
onChunk(msgs);
|
|
603
|
+
i += chunk.length;
|
|
598
604
|
if (chunkSize < this.fetchChunkSizeMax)
|
|
599
605
|
chunkSize = Math.min(chunkSize * 4, this.fetchChunkSizeMax);
|
|
600
606
|
}
|
|
@@ -622,7 +628,9 @@ export class NativeImapClient {
|
|
|
622
628
|
const allMessages = [];
|
|
623
629
|
let chunkSize = this.fetchChunkSize;
|
|
624
630
|
let chunkIndex = 0;
|
|
625
|
-
|
|
631
|
+
// Advance by the chunk ACTUALLY fetched, then grow — same skipped-
|
|
632
|
+
// UIDs bug as fetchSinceUid (see comment there).
|
|
633
|
+
for (let i = 0; i < uids.length;) {
|
|
626
634
|
const chunk = uids.slice(i, i + chunkSize);
|
|
627
635
|
const msgs = await this.fetchMessages(chunk.join(","), options);
|
|
628
636
|
allMessages.push(...msgs);
|
|
@@ -635,6 +643,7 @@ export class NativeImapClient {
|
|
|
635
643
|
}
|
|
636
644
|
if (onChunk)
|
|
637
645
|
onChunk(msgs);
|
|
646
|
+
i += chunk.length;
|
|
638
647
|
if (chunkSize < this.fetchChunkSizeMax)
|
|
639
648
|
chunkSize = Math.min(chunkSize * 4, this.fetchChunkSizeMax);
|
|
640
649
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bobfrankston/iflow-direct",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.58",
|
|
4
4
|
"description": "Direct IMAP client — transport-agnostic, no Node.js dependencies, browser-ready",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.ts",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"author": "Bob Frankston",
|
|
20
20
|
"license": "ISC",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@bobfrankston/tcp-transport": "
|
|
22
|
+
"@bobfrankston/tcp-transport": "file:../tcp-transport"
|
|
23
23
|
},
|
|
24
24
|
"exports": {
|
|
25
25
|
".": {
|
|
@@ -44,13 +44,5 @@
|
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@types/node": "^25.6.0"
|
|
47
|
-
},
|
|
48
|
-
".dependencies": {
|
|
49
|
-
"@bobfrankston/tcp-transport": "file:../tcp-transport"
|
|
50
|
-
},
|
|
51
|
-
".transformedSnapshot": {
|
|
52
|
-
"dependencies": {
|
|
53
|
-
"@bobfrankston/tcp-transport": "^0.1.7"
|
|
54
|
-
}
|
|
55
47
|
}
|
|
56
48
|
}
|