@bobfrankston/iflow 1.0.51 → 1.0.53

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.
@@ -1,15 +1,15 @@
1
1
  /**
2
- * Bridge transport for IMAP — uses mailxapi.tcp from the native shell.
3
- * For Android (MAUI) and potentially desktop WebView.
2
+ * Bridge transport for IMAP — uses msgapi.tcp from the native shell.
3
+ * Works in any msgapi host: msga (MAUI), msger (Rust/wry), msgview (Electron).
4
4
  *
5
5
  * The native shell provides:
6
- * mailxapi.tcp.connect(host, port, tls) → streamId
7
- * mailxapi.tcp.write(streamId, data)
8
- * mailxapi.tcp.onData(streamId, callback)
9
- * mailxapi.tcp.upgradeTLS(streamId, servername)
10
- * mailxapi.tcp.close(streamId)
6
+ * msgapi.tcp.connect(host, port, tls) → streamId
7
+ * msgapi.tcp.write(streamId, data)
8
+ * msgapi.tcp.onData(streamId, callback)
9
+ * msgapi.tcp.upgradeTLS(streamId, servername)
10
+ * msgapi.tcp.close(streamId)
11
11
  *
12
- * TLS is handled natively (C# SslStream) — JS never sees raw TLS handshake.
12
+ * TLS is handled natively — JS never sees raw TLS handshake.
13
13
  */
14
14
  import type { ImapTransport } from "./transport.js";
15
15
  export declare class BridgeTransport implements ImapTransport {
@@ -1,15 +1,15 @@
1
1
  /**
2
- * Bridge transport for IMAP — uses mailxapi.tcp from the native shell.
3
- * For Android (MAUI) and potentially desktop WebView.
2
+ * Bridge transport for IMAP — uses msgapi.tcp from the native shell.
3
+ * Works in any msgapi host: msga (MAUI), msger (Rust/wry), msgview (Electron).
4
4
  *
5
5
  * The native shell provides:
6
- * mailxapi.tcp.connect(host, port, tls) → streamId
7
- * mailxapi.tcp.write(streamId, data)
8
- * mailxapi.tcp.onData(streamId, callback)
9
- * mailxapi.tcp.upgradeTLS(streamId, servername)
10
- * mailxapi.tcp.close(streamId)
6
+ * msgapi.tcp.connect(host, port, tls) → streamId
7
+ * msgapi.tcp.write(streamId, data)
8
+ * msgapi.tcp.onData(streamId, callback)
9
+ * msgapi.tcp.upgradeTLS(streamId, servername)
10
+ * msgapi.tcp.close(streamId)
11
11
  *
12
- * TLS is handled natively (C# SslStream) — JS never sees raw TLS handshake.
12
+ * TLS is handled natively — JS never sees raw TLS handshake.
13
13
  */
14
14
  export class BridgeTransport {
15
15
  streamId = null;
@@ -19,18 +19,18 @@ export class BridgeTransport {
19
19
  _connected = false;
20
20
  get connected() { return this._connected; }
21
21
  async connect(host, port, tls, _servername) {
22
- this.streamId = await mailxapi.tcp.connect(host, port, tls);
22
+ this.streamId = await msgapi.tcp.connect(host, port, tls);
23
23
  this._connected = true;
24
- mailxapi.tcp.onData(this.streamId, (data) => {
24
+ msgapi.tcp.onData(this.streamId, (data) => {
25
25
  if (this.dataHandler)
26
26
  this.dataHandler(data);
27
27
  });
28
- mailxapi.tcp.onClose(this.streamId, (hadError) => {
28
+ msgapi.tcp.onClose(this.streamId, (hadError) => {
29
29
  this._connected = false;
30
30
  if (this.closeHandler)
31
31
  this.closeHandler(hadError);
32
32
  });
33
- mailxapi.tcp.onError(this.streamId, (message) => {
33
+ msgapi.tcp.onError(this.streamId, (message) => {
34
34
  if (this.errorHandler)
35
35
  this.errorHandler(new Error(message));
36
36
  });
@@ -38,13 +38,13 @@ export class BridgeTransport {
38
38
  async upgradeTLS(servername) {
39
39
  if (this.streamId == null)
40
40
  throw new Error("Not connected");
41
- await mailxapi.tcp.upgradeTLS(this.streamId, servername || "");
41
+ await msgapi.tcp.upgradeTLS(this.streamId, servername || "");
42
42
  }
43
43
  async write(data) {
44
44
  if (this.streamId == null)
45
45
  throw new Error("Not connected");
46
46
  const str = typeof data === "string" ? data : new TextDecoder().decode(data);
47
- await mailxapi.tcp.write(this.streamId, str);
47
+ await msgapi.tcp.write(this.streamId, str);
48
48
  }
49
49
  onData(handler) { this.dataHandler = handler; }
50
50
  onClose(handler) { this.closeHandler = handler; }
@@ -52,7 +52,7 @@ export class BridgeTransport {
52
52
  close() {
53
53
  this._connected = false;
54
54
  if (this.streamId != null) {
55
- mailxapi.tcp.close(this.streamId);
55
+ msgapi.tcp.close(this.streamId);
56
56
  this.streamId = null;
57
57
  }
58
58
  }
@@ -5,6 +5,7 @@
5
5
  import type { ImapTransport } from "./transport.js";
6
6
  export declare class NodeTransport implements ImapTransport {
7
7
  private socket;
8
+ private decoder;
8
9
  private dataHandler;
9
10
  private closeHandler;
10
11
  private errorHandler;
@@ -4,8 +4,10 @@
4
4
  */
5
5
  import * as net from "node:net";
6
6
  import * as tls from "node:tls";
7
+ import { StringDecoder } from "node:string_decoder";
7
8
  export class NodeTransport {
8
9
  socket = null;
10
+ decoder = new StringDecoder("utf-8");
9
11
  dataHandler = null;
10
12
  closeHandler = null;
11
13
  errorHandler = null;
@@ -40,7 +42,7 @@ export class NodeTransport {
40
42
  // Wire up persistent handlers after connect
41
43
  this.socket.on("data", (chunk) => {
42
44
  if (this.dataHandler)
43
- this.dataHandler(chunk.toString("utf-8"));
45
+ this.dataHandler(this.decoder.write(chunk));
44
46
  });
45
47
  this.socket.on("close", (hadError) => {
46
48
  this._connected = false;
@@ -64,10 +66,11 @@ export class NodeTransport {
64
66
  rejectUnauthorized: this.rejectUnauthorized,
65
67
  }, () => {
66
68
  this.socket = tlsSocket;
69
+ this.decoder = new StringDecoder("utf-8");
67
70
  // Re-wire data handler to new socket
68
71
  tlsSocket.on("data", (chunk) => {
69
72
  if (this.dataHandler)
70
- this.dataHandler(chunk.toString("utf-8"));
73
+ this.dataHandler(this.decoder.write(chunk));
71
74
  });
72
75
  tlsSocket.on("close", (hadError) => {
73
76
  this._connected = false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bobfrankston/iflow",
3
- "version": "1.0.51",
3
+ "version": "1.0.53",
4
4
  "description": "IMAP client wrapper library",
5
5
  "main": "index.js",
6
6
  "types": "index.ts",