@bobfrankston/iflow 1.0.49 → 1.0.51
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/imaplib/imap-compat.d.ts +6 -0
- package/imaplib/imap-compat.js +16 -0
- package/imaplib/imap-native.d.ts +2 -0
- package/imaplib/imap-native.js +16 -26
- package/package.json +1 -1
package/imaplib/imap-compat.d.ts
CHANGED
|
@@ -49,8 +49,14 @@ export declare class CompatImapClient {
|
|
|
49
49
|
getMessagesCount(mailbox: string): Promise<number>;
|
|
50
50
|
/** Get all UIDs in a mailbox */
|
|
51
51
|
getUids(mailbox: string): Promise<number[]>;
|
|
52
|
+
/** Fetch messages by UID range string (e.g. "100,200,300" or "100:200") */
|
|
53
|
+
fetchMessages(mailbox: string, uidRange: string, options?: {
|
|
54
|
+
source?: boolean;
|
|
55
|
+
}): Promise<any[]>;
|
|
52
56
|
/** Search messages in a mailbox */
|
|
53
57
|
searchMessages(mailbox: string, criteria: any): Promise<number[]>;
|
|
58
|
+
/** Search by header value — returns matching UIDs */
|
|
59
|
+
searchByHeader(mailbox: string, headerName: string, headerValue: string): Promise<number[]>;
|
|
54
60
|
/** Delete a message by UID */
|
|
55
61
|
deleteMessageByUid(mailbox: string, uid: number): Promise<void>;
|
|
56
62
|
/** Move a message between mailboxes (same server) */
|
package/imaplib/imap-compat.js
CHANGED
|
@@ -131,6 +131,14 @@ export class CompatImapClient {
|
|
|
131
131
|
await this.native.closeMailbox();
|
|
132
132
|
return uids;
|
|
133
133
|
}
|
|
134
|
+
/** Fetch messages by UID range string (e.g. "100,200,300" or "100:200") */
|
|
135
|
+
async fetchMessages(mailbox, uidRange, options) {
|
|
136
|
+
await this.ensureConnected();
|
|
137
|
+
await this.native.select(mailbox);
|
|
138
|
+
const msgs = await this.native.fetchMessages(uidRange, options);
|
|
139
|
+
await this.native.closeMailbox();
|
|
140
|
+
return msgs.map(toCompatMessage);
|
|
141
|
+
}
|
|
134
142
|
/** Search messages in a mailbox */
|
|
135
143
|
async searchMessages(mailbox, criteria) {
|
|
136
144
|
await this.ensureConnected();
|
|
@@ -154,6 +162,14 @@ export class CompatImapClient {
|
|
|
154
162
|
await this.native.closeMailbox();
|
|
155
163
|
return uids;
|
|
156
164
|
}
|
|
165
|
+
/** Search by header value — returns matching UIDs */
|
|
166
|
+
async searchByHeader(mailbox, headerName, headerValue) {
|
|
167
|
+
await this.ensureConnected();
|
|
168
|
+
await this.native.select(mailbox);
|
|
169
|
+
const uids = await this.native.search(`HEADER ${headerName} "${headerValue}"`);
|
|
170
|
+
await this.native.closeMailbox();
|
|
171
|
+
return uids;
|
|
172
|
+
}
|
|
157
173
|
/** Delete a message by UID */
|
|
158
174
|
async deleteMessageByUid(mailbox, uid) {
|
|
159
175
|
await this.ensureConnected();
|
package/imaplib/imap-native.d.ts
CHANGED
|
@@ -58,6 +58,8 @@ export declare class NativeImapClient {
|
|
|
58
58
|
private selectedMailbox;
|
|
59
59
|
private mailboxInfo;
|
|
60
60
|
private greetingResolve;
|
|
61
|
+
/** Callback for waitForContinuation — set when waiting for "+" response */
|
|
62
|
+
private continuationResolve;
|
|
61
63
|
constructor(config: ImapClientConfig, transportFactory: TransportFactory);
|
|
62
64
|
get connected(): boolean;
|
|
63
65
|
connect(): Promise<void>;
|
package/imaplib/imap-native.js
CHANGED
|
@@ -21,6 +21,8 @@ export class NativeImapClient {
|
|
|
21
21
|
selectedMailbox = null;
|
|
22
22
|
mailboxInfo = { exists: 0, recent: 0, uidNext: 0, uidValidity: 0, flags: [], permanentFlags: [] };
|
|
23
23
|
greetingResolve = null;
|
|
24
|
+
/** Callback for waitForContinuation — set when waiting for "+" response */
|
|
25
|
+
continuationResolve = null;
|
|
24
26
|
constructor(config, transportFactory) {
|
|
25
27
|
this.config = config;
|
|
26
28
|
this.transportFactory = transportFactory;
|
|
@@ -445,30 +447,15 @@ export class NativeImapClient {
|
|
|
445
447
|
}
|
|
446
448
|
waitForContinuation(tag) {
|
|
447
449
|
return new Promise((resolve) => {
|
|
448
|
-
const timeout = setTimeout(() =>
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
clearTimeout(timeout);
|
|
457
|
-
resolve(resp);
|
|
458
|
-
return;
|
|
459
|
-
}
|
|
460
|
-
// Not continuation — process and keep waiting
|
|
461
|
-
this.buffer = this.buffer.substring(lineEnd + 2);
|
|
462
|
-
this.handleUntaggedResponse(resp);
|
|
463
|
-
}
|
|
464
|
-
if (this.transport.connected)
|
|
465
|
-
setTimeout(check, 5);
|
|
466
|
-
else {
|
|
467
|
-
clearTimeout(timeout);
|
|
468
|
-
resolve(null);
|
|
469
|
-
}
|
|
450
|
+
const timeout = setTimeout(() => {
|
|
451
|
+
this.continuationResolve = null;
|
|
452
|
+
resolve(null);
|
|
453
|
+
}, 30000);
|
|
454
|
+
this.continuationResolve = (resp) => {
|
|
455
|
+
clearTimeout(timeout);
|
|
456
|
+
this.continuationResolve = null;
|
|
457
|
+
resolve(resp);
|
|
470
458
|
};
|
|
471
|
-
check();
|
|
472
459
|
});
|
|
473
460
|
}
|
|
474
461
|
waitForTagged(tag) {
|
|
@@ -583,9 +570,12 @@ export class NativeImapClient {
|
|
|
583
570
|
}
|
|
584
571
|
// Continuation response
|
|
585
572
|
if (resp.tag === "+") {
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
573
|
+
if (this.continuationResolve) {
|
|
574
|
+
// APPEND or other command waiting for continuation
|
|
575
|
+
this.continuationResolve(resp);
|
|
576
|
+
}
|
|
577
|
+
else if (!this.idleTag && this.pendingCommand) {
|
|
578
|
+
// Unexpected continuation (e.g. AUTHENTICATE challenge) — cancel
|
|
589
579
|
this.transport.write("\r\n").catch(() => { });
|
|
590
580
|
}
|
|
591
581
|
continue;
|