@bobfrankston/iflow-direct 0.1.53 → 0.1.54

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/imap-native.js +17 -0
  2. package/package.json +3 -3
package/imap-native.js CHANGED
@@ -1244,6 +1244,23 @@ export class NativeImapClient {
1244
1244
  // decode happens once per literal, not once per chunk that
1245
1245
  // arrives during the literal's transit.
1246
1246
  let literal = this.utf8Decoder.decode(literalBytes);
1247
+ // DESYNC CAPTURE (Bob 2026-06-16, overnight debug). A BODY[]
1248
+ // literal whose content is itself an IMAP command tag means the
1249
+ // byte-buffer parser misaligned: the declared {N} didn't match
1250
+ // reality and we swallowed a later command's bytes. Dump the
1251
+ // declared size + the misaligned content + the raw bytes that
1252
+ // PRECEDED the literal, so the mechanism (how the {N} boundary
1253
+ // slipped) is finally visible. Cheap; only fires on the desync.
1254
+ if (this.pendingCommand.currentLiteralKey?.startsWith("BODY")
1255
+ && /^[A-Za-z]+\d+\s+(SELECT|FETCH|UID|LOGIN|STATUS|EXAMINE|LIST|IDLE|NOOP|STORE|SEARCH|CAPABILITY|CLOSE|LOGOUT|APPEND|COPY|MOVE|EXPUNGE|CREATE|DELETE|RENAME|SUBSCRIBE|ENABLE|STARTTLS)\b/i.test(literal.slice(0, 80).replace(/^[\s*]+/, ""))) {
1256
+ const litStart = this.bufferOffset - neededBytes;
1257
+ const ctxStart = Math.max(0, litStart - 256);
1258
+ const ctx = this.buffer.subarray(ctxStart, litStart);
1259
+ const ascii = Array.from(ctx).map(b => (b >= 32 && b < 127) ? String.fromCharCode(b) : (b === 13 ? "\\r" : b === 10 ? "\\n" : ".")).join("");
1260
+ console.error(` [imap] DESYNC CAPTURE key=${this.pendingCommand.currentLiteralKey} declaredLiteral=${neededBytes}B bufferOffset=${this.bufferOffset} bufferLength=${this.bufferLength} litStart=${litStart}`);
1261
+ console.error(` [imap] DESYNC literal[0..200]=${JSON.stringify(literal.slice(0, 200))}`);
1262
+ console.error(` [imap] DESYNC preceding[${ctx.length}B]=${JSON.stringify(ascii)}`);
1263
+ }
1247
1264
  // For non-BODY literals (e.g. display names in ENVELOPE), wrap in quotes
1248
1265
  // so tokenizeParenList treats them as a single token
1249
1266
  if (!this.pendingCommand.currentLiteralKey) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bobfrankston/iflow-direct",
3
- "version": "0.1.53",
3
+ "version": "0.1.54",
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": "^0.1.6"
22
+ "@bobfrankston/tcp-transport": "^0.1.7"
23
23
  },
24
24
  "exports": {
25
25
  ".": {
@@ -50,7 +50,7 @@
50
50
  },
51
51
  ".transformedSnapshot": {
52
52
  "dependencies": {
53
- "@bobfrankston/tcp-transport": "^0.1.6"
53
+ "@bobfrankston/tcp-transport": "^0.1.7"
54
54
  }
55
55
  }
56
56
  }