@bobfrankston/iflow 1.0.40 → 1.0.42

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.
@@ -57,6 +57,7 @@ export declare class NativeImapClient {
57
57
  private verbose;
58
58
  private selectedMailbox;
59
59
  private mailboxInfo;
60
+ private greetingResolve;
60
61
  constructor(config: ImapClientConfig, transportFactory: TransportFactory);
61
62
  get connected(): boolean;
62
63
  connect(): Promise<void>;
@@ -20,6 +20,7 @@ export class NativeImapClient {
20
20
  verbose;
21
21
  selectedMailbox = null;
22
22
  mailboxInfo = { exists: 0, recent: 0, uidNext: 0, uidValidity: 0, flags: [], permanentFlags: [] };
23
+ greetingResolve = null;
23
24
  constructor(config, transportFactory) {
24
25
  this.config = config;
25
26
  this.transportFactory = transportFactory;
@@ -71,19 +72,15 @@ export class NativeImapClient {
71
72
  await this.authenticate();
72
73
  }
73
74
  async readGreeting() {
74
- return new Promise((resolve) => {
75
- const check = () => {
76
- const lineEnd = this.buffer.indexOf("\r\n");
77
- if (lineEnd >= 0) {
78
- const line = this.buffer.substring(0, lineEnd + 2);
79
- this.buffer = this.buffer.substring(lineEnd + 2);
80
- resolve(proto.parseResponseLine(line));
81
- }
82
- else {
83
- setTimeout(check, 10);
84
- }
75
+ return new Promise((resolve, reject) => {
76
+ const timeout = setTimeout(() => {
77
+ this.greetingResolve = null;
78
+ reject(new Error("Greeting timeout (10s)"));
79
+ }, 10000);
80
+ this.greetingResolve = (resp) => {
81
+ clearTimeout(timeout);
82
+ resolve(resp);
85
83
  };
86
- check();
87
84
  });
88
85
  }
89
86
  async authenticate() {
@@ -511,6 +508,13 @@ export class NativeImapClient {
511
508
  if (this.verbose && resp.raw.length < 200) {
512
509
  console.log(` [imap] < ${resp.raw}`);
513
510
  }
511
+ // Server greeting — resolve readGreeting() promise
512
+ if (this.greetingResolve && resp.tag === "*" && (resp.type === "OK" || resp.type === "PREAUTH")) {
513
+ const resolve = this.greetingResolve;
514
+ this.greetingResolve = null;
515
+ resolve(resp);
516
+ continue;
517
+ }
514
518
  // During IDLE, handle EXISTS notifications
515
519
  if (this.idleTag && resp.tag === "*" && resp.type === "EXISTS") {
516
520
  const count = parseInt(resp.text);
@@ -526,9 +530,13 @@ export class NativeImapClient {
526
530
  this.pendingCommand.responses.push(resp);
527
531
  continue;
528
532
  }
529
- // Continuation — resolve if waiting
533
+ // Continuation response
530
534
  if (resp.tag === "+") {
531
- // Handled by waitForContinuation
535
+ // If not in IDLE and no one is waiting for continuation (APPEND),
536
+ // this is likely an AUTHENTICATE challenge — send empty line to cancel
537
+ if (!this.idleTag && this.pendingCommand) {
538
+ this.transport.write("\r\n").catch(() => { });
539
+ }
532
540
  continue;
533
541
  }
534
542
  // Tagged response — command complete
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bobfrankston/iflow",
3
- "version": "1.0.40",
3
+ "version": "1.0.42",
4
4
  "description": "IMAP client wrapper library",
5
5
  "main": "index.js",
6
6
  "types": "index.ts",