@sockethub/platform-email 0.0.0-stage → 1.0.0-beta.3
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/LICENSE +165 -0
- package/README.md +237 -2
- package/dist/index.d.ts +263 -0
- package/dist/index.js +134944 -0
- package/dist/index.js.map +550 -0
- package/dist/net.d.ts +1 -0
- package/dist/schema.d.ts +218 -0
- package/dist/types.d.ts +51 -0
- package/package.json +58 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
GNU LESSER GENERAL PUBLIC LICENSE
|
|
2
|
+
Version 3, 29 June 2007
|
|
3
|
+
|
|
4
|
+
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
|
5
|
+
Everyone is permitted to copy and distribute verbatim copies
|
|
6
|
+
of this license document, but changing it is not allowed.
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
This version of the GNU Lesser General Public License incorporates
|
|
10
|
+
the terms and conditions of version 3 of the GNU General Public
|
|
11
|
+
License, supplemented by the additional permissions listed below.
|
|
12
|
+
|
|
13
|
+
0. Additional Definitions.
|
|
14
|
+
|
|
15
|
+
As used herein, "this License" refers to version 3 of the GNU Lesser
|
|
16
|
+
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
|
17
|
+
General Public License.
|
|
18
|
+
|
|
19
|
+
"The Library" refers to a covered work governed by this License,
|
|
20
|
+
other than an Application or a Combined Work as defined below.
|
|
21
|
+
|
|
22
|
+
An "Application" is any work that makes use of an interface provided
|
|
23
|
+
by the Library, but which is not otherwise based on the Library.
|
|
24
|
+
Defining a subclass of a class defined by the Library is deemed a mode
|
|
25
|
+
of using an interface provided by the Library.
|
|
26
|
+
|
|
27
|
+
A "Combined Work" is a work produced by combining or linking an
|
|
28
|
+
Application with the Library. The particular version of the Library
|
|
29
|
+
with which the Combined Work was made is also called the "Linked
|
|
30
|
+
Version".
|
|
31
|
+
|
|
32
|
+
The "Minimal Corresponding Source" for a Combined Work means the
|
|
33
|
+
Corresponding Source for the Combined Work, excluding any source code
|
|
34
|
+
for portions of the Combined Work that, considered in isolation, are
|
|
35
|
+
based on the Application, and not on the Linked Version.
|
|
36
|
+
|
|
37
|
+
The "Corresponding Application Code" for a Combined Work means the
|
|
38
|
+
object code and/or source code for the Application, including any data
|
|
39
|
+
and utility programs needed for reproducing the Combined Work from the
|
|
40
|
+
Application, but excluding the System Libraries of the Combined Work.
|
|
41
|
+
|
|
42
|
+
1. Exception to Section 3 of the GNU GPL.
|
|
43
|
+
|
|
44
|
+
You may convey a covered work under sections 3 and 4 of this License
|
|
45
|
+
without being bound by section 3 of the GNU GPL.
|
|
46
|
+
|
|
47
|
+
2. Conveying Modified Versions.
|
|
48
|
+
|
|
49
|
+
If you modify a copy of the Library, and, in your modifications, a
|
|
50
|
+
facility refers to a function or data to be supplied by an Application
|
|
51
|
+
that uses the facility (other than as an argument passed when the
|
|
52
|
+
facility is invoked), then you may convey a copy of the modified
|
|
53
|
+
version:
|
|
54
|
+
|
|
55
|
+
a) under this License, provided that you make a good faith effort to
|
|
56
|
+
ensure that, in the event an Application does not supply the
|
|
57
|
+
function or data, the facility still operates, and performs
|
|
58
|
+
whatever part of its purpose remains meaningful, or
|
|
59
|
+
|
|
60
|
+
b) under the GNU GPL, with none of the additional permissions of
|
|
61
|
+
this License applicable to that copy.
|
|
62
|
+
|
|
63
|
+
3. Object Code Incorporating Material from Library Header Files.
|
|
64
|
+
|
|
65
|
+
The object code form of an Application may incorporate material from
|
|
66
|
+
a header file that is part of the Library. You may convey such object
|
|
67
|
+
code under terms of your choice, provided that, if the incorporated
|
|
68
|
+
material is not limited to numerical parameters, data structure
|
|
69
|
+
layouts and accessors, or small macros, inline functions and templates
|
|
70
|
+
(ten or fewer lines in length), you do both of the following:
|
|
71
|
+
|
|
72
|
+
a) Give prominent notice with each copy of the object code that the
|
|
73
|
+
Library is used in it and that the Library and its use are
|
|
74
|
+
covered by this License.
|
|
75
|
+
|
|
76
|
+
b) Accompany the object code with a copy of the GNU GPL and this license
|
|
77
|
+
document.
|
|
78
|
+
|
|
79
|
+
4. Combined Works.
|
|
80
|
+
|
|
81
|
+
You may convey a Combined Work under terms of your choice that,
|
|
82
|
+
taken together, effectively do not restrict modification of the
|
|
83
|
+
portions of the Library contained in the Combined Work and reverse
|
|
84
|
+
engineering for debugging such modifications, if you also do each of
|
|
85
|
+
the following:
|
|
86
|
+
|
|
87
|
+
a) Give prominent notice with each copy of the Combined Work that
|
|
88
|
+
the Library is used in it and that the Library and its use are
|
|
89
|
+
covered by this License.
|
|
90
|
+
|
|
91
|
+
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
|
92
|
+
document.
|
|
93
|
+
|
|
94
|
+
c) For a Combined Work that displays copyright notices during
|
|
95
|
+
execution, include the copyright notice for the Library among
|
|
96
|
+
these notices, as well as a reference directing the user to the
|
|
97
|
+
copies of the GNU GPL and this license document.
|
|
98
|
+
|
|
99
|
+
d) Do one of the following:
|
|
100
|
+
|
|
101
|
+
0) Convey the Minimal Corresponding Source under the terms of this
|
|
102
|
+
License, and the Corresponding Application Code in a form
|
|
103
|
+
suitable for, and under terms that permit, the user to
|
|
104
|
+
recombine or relink the Application with a modified version of
|
|
105
|
+
the Linked Version to produce a modified Combined Work, in the
|
|
106
|
+
manner specified by section 6 of the GNU GPL for conveying
|
|
107
|
+
Corresponding Source.
|
|
108
|
+
|
|
109
|
+
1) Use a suitable shared library mechanism for linking with the
|
|
110
|
+
Library. A suitable mechanism is one that (a) uses at run time
|
|
111
|
+
a copy of the Library already present on the user's computer
|
|
112
|
+
system, and (b) will operate properly with a modified version
|
|
113
|
+
of the Library that is interface-compatible with the Linked
|
|
114
|
+
Version.
|
|
115
|
+
|
|
116
|
+
e) Provide Installation Information, but only if you would otherwise
|
|
117
|
+
be required to provide such information under section 6 of the
|
|
118
|
+
GNU GPL, and only to the extent that such information is
|
|
119
|
+
necessary to install and execute a modified version of the
|
|
120
|
+
Combined Work produced by recombining or relinking the
|
|
121
|
+
Application with a modified version of the Linked Version. (If
|
|
122
|
+
you use option 4d0, the Installation Information must accompany
|
|
123
|
+
the Minimal Corresponding Source and Corresponding Application
|
|
124
|
+
Code. If you use option 4d1, you must provide the Installation
|
|
125
|
+
Information in the manner specified by section 6 of the GNU GPL
|
|
126
|
+
for conveying Corresponding Source.)
|
|
127
|
+
|
|
128
|
+
5. Combined Libraries.
|
|
129
|
+
|
|
130
|
+
You may place library facilities that are a work based on the
|
|
131
|
+
Library side by side in a single library together with other library
|
|
132
|
+
facilities that are not Applications and are not covered by this
|
|
133
|
+
License, and convey such a combined library under terms of your
|
|
134
|
+
choice, if you do both of the following:
|
|
135
|
+
|
|
136
|
+
a) Accompany the combined library with a copy of the same work based
|
|
137
|
+
on the Library, uncombined with any other library facilities,
|
|
138
|
+
conveyed under the terms of this License.
|
|
139
|
+
|
|
140
|
+
b) Give prominent notice with the combined library that part of it
|
|
141
|
+
is a work based on the Library, and explaining where to find the
|
|
142
|
+
accompanying uncombined form of the same work.
|
|
143
|
+
|
|
144
|
+
6. Revised Versions of the GNU Lesser General Public License.
|
|
145
|
+
|
|
146
|
+
The Free Software Foundation may publish revised and/or new versions
|
|
147
|
+
of the GNU Lesser General Public License from time to time. Such new
|
|
148
|
+
versions will be similar in spirit to the present version, but may
|
|
149
|
+
differ in detail to address new problems or concerns.
|
|
150
|
+
|
|
151
|
+
Each version is given a distinguishing version number. If the
|
|
152
|
+
Library as you received it specifies that a certain numbered version
|
|
153
|
+
of the GNU Lesser General Public License "or any later version"
|
|
154
|
+
applies to it, you have the option of following the terms and
|
|
155
|
+
conditions either of that published version or of any later version
|
|
156
|
+
published by the Free Software Foundation. If the Library as you
|
|
157
|
+
received it does not specify a version number of the GNU Lesser
|
|
158
|
+
General Public License, you may choose any version of the GNU Lesser
|
|
159
|
+
General Public License ever published by the Free Software Foundation.
|
|
160
|
+
|
|
161
|
+
If the Library as you received it specifies that a proxy can decide
|
|
162
|
+
whether future versions of the GNU Lesser General Public License shall
|
|
163
|
+
apply, that proxy's public statement of acceptance of any version is
|
|
164
|
+
permanent authorization for you to choose that version for the
|
|
165
|
+
Library.
|
package/README.md
CHANGED
|
@@ -1,3 +1,238 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Email platform
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`@sockethub/platform-email` receives mail through IMAP and submits outgoing mail
|
|
4
|
+
through SMTP. The mail server remains the message store. Sockethub keeps no
|
|
5
|
+
mailbox database and does not change read flags, move messages, or delete mail.
|
|
6
|
+
|
|
7
|
+
Requires Node.js >=20.19 and Redis through the Sockethub server.
|
|
8
|
+
|
|
9
|
+
Supported actions: `connect`, `disconnect`, `fetch`, `watch`, `unwatch`, `send`.
|
|
10
|
+
Each client session has its own worker and IMAP connection, so clients using the
|
|
11
|
+
same account can choose different folders and filters independently.
|
|
12
|
+
|
|
13
|
+
## Connect
|
|
14
|
+
|
|
15
|
+
Enable `@sockethub/platform-email` in the server's `platforms` list if you use an
|
|
16
|
+
explicit configuration. The bundled default configuration includes it.
|
|
17
|
+
|
|
18
|
+
```javascript
|
|
19
|
+
await sc.ready();
|
|
20
|
+
const actor = { id: 'me@example.com', type: 'person', name: 'Example Sender' };
|
|
21
|
+
const context = sc.contextFor('email');
|
|
22
|
+
|
|
23
|
+
function emit(event, activity) {
|
|
24
|
+
return new Promise((resolve, reject) => {
|
|
25
|
+
sc.socket.emit(event, activity, (result) => {
|
|
26
|
+
if (result?.error) reject(new Error(result.error));
|
|
27
|
+
else resolve(result);
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
await emit('credentials', {
|
|
33
|
+
'@context': context,
|
|
34
|
+
type: 'credentials',
|
|
35
|
+
actor,
|
|
36
|
+
object: {
|
|
37
|
+
type: 'credentials',
|
|
38
|
+
from: 'me@example.com',
|
|
39
|
+
imap: {
|
|
40
|
+
host: 'imap.example.com',
|
|
41
|
+
port: 993,
|
|
42
|
+
secure: true,
|
|
43
|
+
username: 'me@example.com',
|
|
44
|
+
password: '<runtime app password>'
|
|
45
|
+
},
|
|
46
|
+
smtp: {
|
|
47
|
+
host: 'smtp.example.com',
|
|
48
|
+
port: 587,
|
|
49
|
+
secure: false,
|
|
50
|
+
username: 'me@example.com',
|
|
51
|
+
token: '<runtime OAuth access token>'
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
await emit('message', { '@context': context, type: 'connect', actor });
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Configure IMAP, SMTP, or both. Every server needs its own username and exactly one
|
|
59
|
+
of `password` or `token`. Access tokens are supplied by your application; this
|
|
60
|
+
platform does not run authorization flows or refresh tokens. `from` is the sender
|
|
61
|
+
address used for outgoing mail, which the SMTP provider must authorize.
|
|
62
|
+
|
|
63
|
+
`secure: true` uses TLS immediately. `secure: false` requires STARTTLS; plaintext
|
|
64
|
+
credentials and invalid certificates are never accepted. IMAP defaults to TLS on
|
|
65
|
+
993, SMTP to STARTTLS on 587. SMTP port 465 implies immediate TLS unless overridden.
|
|
66
|
+
|
|
67
|
+
Private, loopback, and metadata server addresses are blocked by default. An
|
|
68
|
+
operator can allow a trusted private mail server with:
|
|
69
|
+
|
|
70
|
+
```json
|
|
71
|
+
{
|
|
72
|
+
"packageConfig": {
|
|
73
|
+
"@sockethub/platform-email": {
|
|
74
|
+
"allowPrivateAddresses": true
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
The examples app includes an `/email` page for configuring an account, fetching,
|
|
81
|
+
watching, and sending. Credentials are entered at runtime.
|
|
82
|
+
|
|
83
|
+
## Fetch
|
|
84
|
+
|
|
85
|
+
```javascript
|
|
86
|
+
const page = await emit('message', {
|
|
87
|
+
'@context': context,
|
|
88
|
+
type: 'fetch',
|
|
89
|
+
actor,
|
|
90
|
+
object: {
|
|
91
|
+
folders: ['INBOX', 'Orders'],
|
|
92
|
+
from: ['friend@example.com'],
|
|
93
|
+
to: ['me@example.com'],
|
|
94
|
+
match: 'any',
|
|
95
|
+
limit: 20
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
// Repeat with the same folders and filters to fetch the next page.
|
|
100
|
+
const next = await emit('message', {
|
|
101
|
+
'@context': context,
|
|
102
|
+
type: 'fetch',
|
|
103
|
+
actor,
|
|
104
|
+
object: {
|
|
105
|
+
folders: ['INBOX', 'Orders'],
|
|
106
|
+
from: ['friend@example.com'],
|
|
107
|
+
to: ['me@example.com'],
|
|
108
|
+
match: 'any',
|
|
109
|
+
limit: 20,
|
|
110
|
+
cursors: page.cursors
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Responses are `collection` objects with `items`, per-folder `cursors`, and
|
|
116
|
+
`hasMore`. Merge returned cursors into the previous cursor map before requesting
|
|
117
|
+
another page: folders not visited in a page have no replacement cursor. Results
|
|
118
|
+
are ordered by increasing UID within each requested folder, visiting folders in
|
|
119
|
+
request order. There is no cross-folder date sort. Omit cursors to start from the
|
|
120
|
+
oldest messages; the default folder is `INBOX` and the default limit is 20 (max 50).
|
|
121
|
+
|
|
122
|
+
Address arrays match any listed address. `match: "any"` (default) means From OR To;
|
|
123
|
+
`match: "all"` means From AND To when both filters are present. Sockethub checks
|
|
124
|
+
parsed addresses case-insensitively after IMAP search, avoiding substring matches.
|
|
125
|
+
To refers to the visible To header, not BCC or the actual delivery envelope. A
|
|
126
|
+
matching From header does not establish sender authenticity.
|
|
127
|
+
|
|
128
|
+
Every item is a `post` activity: its actor is the sender, target is your account,
|
|
129
|
+
and object is a `message` containing `id`, `folder`, `uidValidity`, `uid`, `from`,
|
|
130
|
+
`to`, `cc`, `subject`, `messageId`, `inReplyTo`, `references` (an array of message
|
|
131
|
+
IDs), `published`, `content` (plain text), and optional `html`. Sender display
|
|
132
|
+
names are retained in `from` and the activity's `actor.name`. Treat returned HTML
|
|
133
|
+
as untrusted when rendering it.
|
|
134
|
+
|
|
135
|
+
`attachments` lists MIME part metadata as `{ filename?, contentType }`, including
|
|
136
|
+
named inline parts and nested attachments. An attachment without a filename is
|
|
137
|
+
still listed with its media type. Filenames and References are fetched separately
|
|
138
|
+
from the body, so they remain available when `bodyOmitted` is true. Attachment
|
|
139
|
+
contents are never returned.
|
|
140
|
+
|
|
141
|
+
A request examines up to 500 UID positions per folder and transfers up to 512 KiB
|
|
142
|
+
of source message data across the batch. A page can therefore be empty while
|
|
143
|
+
`hasMore` remains true; continue using its cursors. Messages larger than 256 KiB
|
|
144
|
+
are returned as metadata with `bodyOmitted: true`. Attachment contents are not returned.
|
|
145
|
+
|
|
146
|
+
The cursor combines UIDVALIDITY and the last scanned UID. Keep it tied to the
|
|
147
|
+
same mail server, account, and folder: UIDVALIDITY values can overlap across
|
|
148
|
+
accounts. The examples page resets pagination on connection changes.
|
|
149
|
+
If the server resets UIDVALIDITY, Sockethub rejects the cursor;
|
|
150
|
+
discard that folder's cursor and fetch again. The application owns any durable
|
|
151
|
+
cursor storage and duplicate handling. Reset cursors when changing filters.
|
|
152
|
+
|
|
153
|
+
## Watch
|
|
154
|
+
|
|
155
|
+
```javascript
|
|
156
|
+
sc.socket.on('message', (activity) => {
|
|
157
|
+
// Check the email context before processing messages from a multi-platform client.
|
|
158
|
+
if (activity['@context']?.some(value => value.includes('/platform/email/'))) {
|
|
159
|
+
if (activity.error) console.error(activity.error);
|
|
160
|
+
else if (activity.type === 'post') console.log(activity.object);
|
|
161
|
+
else if (activity.type === 'watch') console.log(activity.object.cursor);
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
await emit('message', {
|
|
166
|
+
'@context': context,
|
|
167
|
+
type: 'watch',
|
|
168
|
+
actor,
|
|
169
|
+
object: { folder: 'INBOX', to: ['me@example.com'] }
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
await emit('message', { '@context': context, type: 'unwatch', actor });
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
Watch observes one folder per client session, using IMAP IDLE with the library's
|
|
176
|
+
polling fallback. A new watch replaces the previous watch. It starts at the
|
|
177
|
+
current end of the folder unless `object.cursor` supplies a prior cursor for
|
|
178
|
+
catch-up. Filters have the same meaning as fetch. Progress arrives as `watch`
|
|
179
|
+
activities containing `{ type: "subscription", folder, cursor }`, including when
|
|
180
|
+
new messages do not match the filters. Fetching other folders temporarily pauses
|
|
181
|
+
the watch and then resumes it, catching up by UID.
|
|
182
|
+
|
|
183
|
+
Watching stops on connection loss and reports a `disconnect` activity with an
|
|
184
|
+
error. Explicitly reconnect and supply your saved cursor to fetch or watch again.
|
|
185
|
+
There is no background collection or exactly-once delivery guarantee. Mail moved
|
|
186
|
+
out of the watched folder before it can be fetched may not be observed.
|
|
187
|
+
|
|
188
|
+
## Send
|
|
189
|
+
|
|
190
|
+
```javascript
|
|
191
|
+
const submission = await emit('message', {
|
|
192
|
+
'@context': context,
|
|
193
|
+
type: 'send',
|
|
194
|
+
actor,
|
|
195
|
+
object: {
|
|
196
|
+
to: ['friend@example.com'],
|
|
197
|
+
subject: 'Hello',
|
|
198
|
+
content: 'Hello from Sockethub!',
|
|
199
|
+
inReplyTo: '<original-message@example.com>'
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
console.log(submission.object.accepted, submission.object.rejected);
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
Send accepts `to`, optional `cc` and `bcc` arrays, `subject`, `content` (plain text),
|
|
206
|
+
`html`, `inReplyTo`, and a `references` array. The outgoing sender display name
|
|
207
|
+
comes from `actor.name` when provided. At least one body representation and
|
|
208
|
+
one To recipient are required. It returns a `send` activity with a `submission`
|
|
209
|
+
object containing `messageId`, `accepted`, `rejected`, and
|
|
210
|
+
`status: "accepted-by-server"`. Acceptance does not guarantee delivery; some
|
|
211
|
+
recipients can be rejected while others are accepted.
|
|
212
|
+
|
|
213
|
+
A failed submission can have an uncertain outcome if the connection drops after
|
|
214
|
+
the server accepts it. Do not automatically resend an uncertain submission. The
|
|
215
|
+
platform makes one submission attempt per action and disables stalled-job replay
|
|
216
|
+
after worker crashes, so uncertain sends are left for the application to resolve.
|
|
217
|
+
It does not save a Sent-folder copy.
|
|
218
|
+
|
|
219
|
+
On logout, disconnect and clear the client's replayed credentials:
|
|
220
|
+
|
|
221
|
+
```javascript
|
|
222
|
+
await emit('message', { '@context': context, type: 'disconnect', actor });
|
|
223
|
+
sc.clearCredentials({ platform: 'email', actorId: actor.id });
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
POP, folder mutations, flags, drafts, attachment transfers, provider OAuth
|
|
227
|
+
onboarding, and durable mailbox synchronization are outside this platform's scope.
|
|
228
|
+
|
|
229
|
+
## Development checks
|
|
230
|
+
|
|
231
|
+
After `bun install`, run `bun run --filter='@sockethub/platform-email' test` for
|
|
232
|
+
unit tests, including on a clean checkout. This runs the repository's shared
|
|
233
|
+
`build:foundations` preparation first; it does not build the whole monorepo.
|
|
234
|
+
Direct `bun test` assumes those dependencies have already been built.
|
|
235
|
+
|
|
236
|
+
After `bun run build`, run `bun run integration:email` for real IMAP fetch/watch
|
|
237
|
+
and SMTP send against local TLS test servers. That check requires `openssl` and
|
|
238
|
+
no external mail account.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
import type { ActivityStream, PersistentPlatformConfig, PersistentPlatformInterface, PlatformCallback, PlatformSession } from "@sockethub/schemas";
|
|
2
|
+
import { ImapFlow, type ImapFlowOptions, type MessageEnvelopeObject, type MessageStructureObject } from "imapflow";
|
|
3
|
+
import { type Transporter } from "nodemailer";
|
|
4
|
+
import type SMTPTransport from "nodemailer/lib/smtp-transport/index.js";
|
|
5
|
+
import type { EmailAttachment, EmailCredentials, EmailJob, FetchOptions, Filter, SendOptions, WatchOptions } from "./types.js";
|
|
6
|
+
export type { Cursor, EmailAttachment, EmailCredentials, FetchOptions, Filter, SendOptions, WatchOptions, } from "./types.js";
|
|
7
|
+
interface Dependencies {
|
|
8
|
+
imap(options: ImapFlowOptions): ImapFlow;
|
|
9
|
+
smtp(options: SMTPTransport.Options): Transporter<SMTPTransport.SentMessageInfo>;
|
|
10
|
+
}
|
|
11
|
+
export declare function matchesAddresses(envelope: MessageEnvelopeObject, filter: Filter): boolean;
|
|
12
|
+
/** List attachment metadata without fetching attachment body parts. */
|
|
13
|
+
export declare function attachmentMetadata(structure?: MessageStructureObject): EmailAttachment[];
|
|
14
|
+
export default class Email implements PersistentPlatformInterface {
|
|
15
|
+
private readonly dependencies;
|
|
16
|
+
credentialsHash: string | undefined;
|
|
17
|
+
config: PersistentPlatformConfig;
|
|
18
|
+
private readonly log;
|
|
19
|
+
private readonly sendToClient;
|
|
20
|
+
private client?;
|
|
21
|
+
private initialized;
|
|
22
|
+
private connecting?;
|
|
23
|
+
private chain;
|
|
24
|
+
private watching?;
|
|
25
|
+
private draining;
|
|
26
|
+
private drainAgain;
|
|
27
|
+
private closed;
|
|
28
|
+
private disposed;
|
|
29
|
+
constructor(session: PlatformSession, dependencies?: Dependencies);
|
|
30
|
+
get schema(): {
|
|
31
|
+
name: string;
|
|
32
|
+
version: string;
|
|
33
|
+
contextUrl: string;
|
|
34
|
+
contextVersion: string;
|
|
35
|
+
schemaVersion: string;
|
|
36
|
+
credentials: {
|
|
37
|
+
required: string[];
|
|
38
|
+
properties: {
|
|
39
|
+
object: {
|
|
40
|
+
type: string;
|
|
41
|
+
additionalProperties: boolean;
|
|
42
|
+
required: string[];
|
|
43
|
+
properties: {
|
|
44
|
+
type: {
|
|
45
|
+
const: string;
|
|
46
|
+
};
|
|
47
|
+
from: {
|
|
48
|
+
type: string;
|
|
49
|
+
format: string;
|
|
50
|
+
maxLength: number;
|
|
51
|
+
};
|
|
52
|
+
imap: {
|
|
53
|
+
type: string;
|
|
54
|
+
additionalProperties: boolean;
|
|
55
|
+
required: string[];
|
|
56
|
+
properties: {
|
|
57
|
+
host: {
|
|
58
|
+
type: string;
|
|
59
|
+
minLength: number;
|
|
60
|
+
maxLength: number;
|
|
61
|
+
pattern: string;
|
|
62
|
+
};
|
|
63
|
+
port: {
|
|
64
|
+
type: string;
|
|
65
|
+
minimum: number;
|
|
66
|
+
maximum: number;
|
|
67
|
+
};
|
|
68
|
+
secure: {
|
|
69
|
+
type: string;
|
|
70
|
+
};
|
|
71
|
+
username: {
|
|
72
|
+
type: string;
|
|
73
|
+
minLength: number;
|
|
74
|
+
maxLength: number;
|
|
75
|
+
};
|
|
76
|
+
password: {
|
|
77
|
+
type: string;
|
|
78
|
+
minLength: number;
|
|
79
|
+
maxLength: number;
|
|
80
|
+
};
|
|
81
|
+
token: {
|
|
82
|
+
type: string;
|
|
83
|
+
minLength: number;
|
|
84
|
+
maxLength: number;
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
oneOf: {
|
|
88
|
+
required: string[];
|
|
89
|
+
}[];
|
|
90
|
+
};
|
|
91
|
+
smtp: {
|
|
92
|
+
type: string;
|
|
93
|
+
additionalProperties: boolean;
|
|
94
|
+
required: string[];
|
|
95
|
+
properties: {
|
|
96
|
+
host: {
|
|
97
|
+
type: string;
|
|
98
|
+
minLength: number;
|
|
99
|
+
maxLength: number;
|
|
100
|
+
pattern: string;
|
|
101
|
+
};
|
|
102
|
+
port: {
|
|
103
|
+
type: string;
|
|
104
|
+
minimum: number;
|
|
105
|
+
maximum: number;
|
|
106
|
+
};
|
|
107
|
+
secure: {
|
|
108
|
+
type: string;
|
|
109
|
+
};
|
|
110
|
+
username: {
|
|
111
|
+
type: string;
|
|
112
|
+
minLength: number;
|
|
113
|
+
maxLength: number;
|
|
114
|
+
};
|
|
115
|
+
password: {
|
|
116
|
+
type: string;
|
|
117
|
+
minLength: number;
|
|
118
|
+
maxLength: number;
|
|
119
|
+
};
|
|
120
|
+
token: {
|
|
121
|
+
type: string;
|
|
122
|
+
minLength: number;
|
|
123
|
+
maxLength: number;
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
oneOf: {
|
|
127
|
+
required: string[];
|
|
128
|
+
}[];
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
anyOf: {
|
|
132
|
+
required: string[];
|
|
133
|
+
}[];
|
|
134
|
+
};
|
|
135
|
+
};
|
|
136
|
+
};
|
|
137
|
+
messages: {
|
|
138
|
+
required: string[];
|
|
139
|
+
properties: {
|
|
140
|
+
type: {
|
|
141
|
+
enum: string[];
|
|
142
|
+
};
|
|
143
|
+
object: {
|
|
144
|
+
type: string;
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
allOf: ({
|
|
148
|
+
if: {
|
|
149
|
+
properties: {
|
|
150
|
+
type: {
|
|
151
|
+
const: string;
|
|
152
|
+
};
|
|
153
|
+
};
|
|
154
|
+
};
|
|
155
|
+
then: {
|
|
156
|
+
properties: {
|
|
157
|
+
object: {
|
|
158
|
+
type: string;
|
|
159
|
+
additionalProperties: boolean;
|
|
160
|
+
properties: {
|
|
161
|
+
type: {
|
|
162
|
+
const: string;
|
|
163
|
+
};
|
|
164
|
+
};
|
|
165
|
+
};
|
|
166
|
+
};
|
|
167
|
+
required?: undefined;
|
|
168
|
+
};
|
|
169
|
+
} | {
|
|
170
|
+
if: {
|
|
171
|
+
properties: {
|
|
172
|
+
type: {
|
|
173
|
+
const: string;
|
|
174
|
+
};
|
|
175
|
+
};
|
|
176
|
+
};
|
|
177
|
+
then: {
|
|
178
|
+
required: string[];
|
|
179
|
+
properties: {
|
|
180
|
+
object: {
|
|
181
|
+
required: string[];
|
|
182
|
+
anyOf: {
|
|
183
|
+
required: string[];
|
|
184
|
+
}[];
|
|
185
|
+
type: string;
|
|
186
|
+
additionalProperties: boolean;
|
|
187
|
+
properties: {
|
|
188
|
+
type: {
|
|
189
|
+
const: string;
|
|
190
|
+
};
|
|
191
|
+
};
|
|
192
|
+
};
|
|
193
|
+
};
|
|
194
|
+
};
|
|
195
|
+
})[];
|
|
196
|
+
};
|
|
197
|
+
responses: {
|
|
198
|
+
type: string;
|
|
199
|
+
required: string[];
|
|
200
|
+
properties: {
|
|
201
|
+
type: {
|
|
202
|
+
enum: string[];
|
|
203
|
+
};
|
|
204
|
+
actor: {
|
|
205
|
+
type: string;
|
|
206
|
+
required: string[];
|
|
207
|
+
};
|
|
208
|
+
object: {
|
|
209
|
+
type: string;
|
|
210
|
+
};
|
|
211
|
+
items: {
|
|
212
|
+
type: string;
|
|
213
|
+
maxItems: number;
|
|
214
|
+
items: {
|
|
215
|
+
type: string;
|
|
216
|
+
required: string[];
|
|
217
|
+
};
|
|
218
|
+
};
|
|
219
|
+
cursors: {
|
|
220
|
+
type: string;
|
|
221
|
+
additionalProperties: {
|
|
222
|
+
type: string;
|
|
223
|
+
additionalProperties: boolean;
|
|
224
|
+
required: string[];
|
|
225
|
+
properties: {
|
|
226
|
+
uidValidity: {
|
|
227
|
+
type: string;
|
|
228
|
+
pattern: string;
|
|
229
|
+
maxLength: number;
|
|
230
|
+
};
|
|
231
|
+
uid: {
|
|
232
|
+
type: string;
|
|
233
|
+
minimum: number;
|
|
234
|
+
maximum: number;
|
|
235
|
+
};
|
|
236
|
+
};
|
|
237
|
+
};
|
|
238
|
+
};
|
|
239
|
+
hasMore: {
|
|
240
|
+
type: string;
|
|
241
|
+
};
|
|
242
|
+
error: {
|
|
243
|
+
type: string;
|
|
244
|
+
};
|
|
245
|
+
};
|
|
246
|
+
};
|
|
247
|
+
};
|
|
248
|
+
isInitialized(): boolean;
|
|
249
|
+
private failure;
|
|
250
|
+
private run;
|
|
251
|
+
connect(job: ActivityStream, credentials: EmailCredentials, done: PlatformCallback): void;
|
|
252
|
+
private open;
|
|
253
|
+
fetch(job: EmailJob<FetchOptions>, done: PlatformCallback): void;
|
|
254
|
+
private imap;
|
|
255
|
+
private batch;
|
|
256
|
+
watch(job: EmailJob<WatchOptions>, done: PlatformCallback): void;
|
|
257
|
+
private drain;
|
|
258
|
+
unwatch(job: ActivityStream, done: PlatformCallback): void;
|
|
259
|
+
send(job: EmailJob<SendOptions>, credentials: EmailCredentials, done: PlatformCallback): void;
|
|
260
|
+
disconnect(job: ActivityStream, done: PlatformCallback): void;
|
|
261
|
+
private close;
|
|
262
|
+
cleanup(done: PlatformCallback): void;
|
|
263
|
+
}
|