@bobfrankston/iflow 1.0.51 → 1.0.52
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
|
|
3
|
-
*
|
|
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
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
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
|
|
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
|
|
3
|
-
*
|
|
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
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
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
|
|
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
|
|
22
|
+
this.streamId = await msgapi.tcp.connect(host, port, tls);
|
|
23
23
|
this._connected = true;
|
|
24
|
-
|
|
24
|
+
msgapi.tcp.onData(this.streamId, (data) => {
|
|
25
25
|
if (this.dataHandler)
|
|
26
26
|
this.dataHandler(data);
|
|
27
27
|
});
|
|
28
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
55
|
+
msgapi.tcp.close(this.streamId);
|
|
56
56
|
this.streamId = null;
|
|
57
57
|
}
|
|
58
58
|
}
|