emailengine-app 2.61.1 → 2.61.2

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 (136) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/data/google-crawlers.json +1 -1
  3. package/lib/account/account-state.js +248 -0
  4. package/lib/account.js +17 -178
  5. package/lib/api-routes/account-routes.js +1006 -0
  6. package/lib/api-routes/message-routes.js +1377 -0
  7. package/lib/consts.js +12 -2
  8. package/lib/email-client/base-client.js +282 -771
  9. package/lib/email-client/gmail/gmail-api.js +243 -0
  10. package/lib/email-client/gmail-client.js +145 -53
  11. package/lib/email-client/imap/mailbox.js +24 -698
  12. package/lib/email-client/imap/sync-operations.js +812 -0
  13. package/lib/email-client/imap-client.js +1 -1
  14. package/lib/email-client/message-builder.js +566 -0
  15. package/lib/email-client/notification-handler.js +314 -0
  16. package/lib/email-client/outlook/graph-api.js +326 -0
  17. package/lib/email-client/outlook-client.js +159 -113
  18. package/lib/email-client/smtp-pool-manager.js +196 -0
  19. package/lib/imapproxy/imap-server.js +3 -12
  20. package/lib/oauth/gmail.js +4 -4
  21. package/lib/oauth/mail-ru.js +30 -5
  22. package/lib/oauth/outlook.js +57 -3
  23. package/lib/oauth/pubsub/google.js +30 -11
  24. package/lib/oauth/scope-checker.js +202 -0
  25. package/lib/oauth2-apps.js +8 -4
  26. package/lib/redis-operations.js +484 -0
  27. package/lib/routes-ui.js +283 -2582
  28. package/lib/tools.js +4 -196
  29. package/lib/ui-routes/account-routes.js +1931 -0
  30. package/lib/ui-routes/admin-config-routes.js +1233 -0
  31. package/lib/ui-routes/admin-entities-routes.js +2367 -0
  32. package/lib/ui-routes/oauth-routes.js +992 -0
  33. package/lib/utils/network.js +237 -0
  34. package/package.json +9 -9
  35. package/sbom.json +1 -1
  36. package/static/js/app.js +5 -5
  37. package/static/licenses.html +78 -18
  38. package/translations/de.mo +0 -0
  39. package/translations/de.po +85 -82
  40. package/translations/en.mo +0 -0
  41. package/translations/en.po +63 -71
  42. package/translations/et.mo +0 -0
  43. package/translations/et.po +84 -82
  44. package/translations/fr.mo +0 -0
  45. package/translations/fr.po +85 -82
  46. package/translations/ja.mo +0 -0
  47. package/translations/ja.po +84 -82
  48. package/translations/messages.pot +74 -87
  49. package/translations/nl.mo +0 -0
  50. package/translations/nl.po +86 -82
  51. package/translations/pl.mo +0 -0
  52. package/translations/pl.po +84 -82
  53. package/views/account/security.hbs +4 -4
  54. package/views/accounts/account.hbs +13 -13
  55. package/views/accounts/register/imap-server.hbs +12 -12
  56. package/views/config/document-store/pre-processing/index.hbs +4 -2
  57. package/views/config/oauth/app.hbs +6 -7
  58. package/views/config/oauth/index.hbs +2 -2
  59. package/views/config/service.hbs +3 -4
  60. package/views/dashboard.hbs +5 -7
  61. package/views/error.hbs +22 -7
  62. package/views/gateways/gateway.hbs +2 -2
  63. package/views/partials/add_account_modal.hbs +7 -10
  64. package/views/partials/document_store_header.hbs +1 -1
  65. package/views/partials/editor_scope_info.hbs +0 -1
  66. package/views/partials/oauth_config_header.hbs +1 -1
  67. package/views/partials/side_menu.hbs +3 -3
  68. package/views/partials/webhook_form.hbs +2 -2
  69. package/views/templates/index.hbs +1 -1
  70. package/views/templates/template.hbs +8 -8
  71. package/views/tokens/index.hbs +6 -6
  72. package/views/tokens/new.hbs +1 -1
  73. package/views/webhooks/index.hbs +4 -4
  74. package/views/webhooks/webhook.hbs +7 -7
  75. package/workers/api.js +148 -2436
  76. package/workers/smtp.js +2 -1
  77. package/lib/imapproxy/imap-core/test/client.js +0 -46
  78. package/lib/imapproxy/imap-core/test/fixtures/append.eml +0 -1196
  79. package/lib/imapproxy/imap-core/test/fixtures/chunks.js +0 -44
  80. package/lib/imapproxy/imap-core/test/fixtures/fix1.eml +0 -6
  81. package/lib/imapproxy/imap-core/test/fixtures/fix2.eml +0 -599
  82. package/lib/imapproxy/imap-core/test/fixtures/fix3.eml +0 -32
  83. package/lib/imapproxy/imap-core/test/fixtures/fix4.eml +0 -6
  84. package/lib/imapproxy/imap-core/test/fixtures/mimetorture.eml +0 -599
  85. package/lib/imapproxy/imap-core/test/fixtures/mimetorture.js +0 -2740
  86. package/lib/imapproxy/imap-core/test/fixtures/mimetorture.json +0 -1411
  87. package/lib/imapproxy/imap-core/test/fixtures/mimetree.js +0 -85
  88. package/lib/imapproxy/imap-core/test/fixtures/nodemailer.eml +0 -582
  89. package/lib/imapproxy/imap-core/test/fixtures/ryan_finnie_mime_torture.eml +0 -599
  90. package/lib/imapproxy/imap-core/test/fixtures/simple.eml +0 -42
  91. package/lib/imapproxy/imap-core/test/fixtures/simple.json +0 -164
  92. package/lib/imapproxy/imap-core/test/imap-compile-stream-test.js +0 -671
  93. package/lib/imapproxy/imap-core/test/imap-compiler-test.js +0 -272
  94. package/lib/imapproxy/imap-core/test/imap-indexer-test.js +0 -236
  95. package/lib/imapproxy/imap-core/test/imap-parser-test.js +0 -922
  96. package/lib/imapproxy/imap-core/test/memory-notifier.js +0 -129
  97. package/lib/imapproxy/imap-core/test/prepare.sh +0 -74
  98. package/lib/imapproxy/imap-core/test/protocol-test.js +0 -1756
  99. package/lib/imapproxy/imap-core/test/search-test.js +0 -1356
  100. package/lib/imapproxy/imap-core/test/test-client.js +0 -152
  101. package/lib/imapproxy/imap-core/test/test-server.js +0 -623
  102. package/lib/imapproxy/imap-core/test/tools-test.js +0 -22
  103. package/test/api-test.js +0 -899
  104. package/test/autoreply-test.js +0 -327
  105. package/test/bounce-test.js +0 -151
  106. package/test/complaint-test.js +0 -256
  107. package/test/fixtures/autoreply/LICENSE +0 -27
  108. package/test/fixtures/autoreply/rfc3834-01.eml +0 -23
  109. package/test/fixtures/autoreply/rfc3834-02.eml +0 -24
  110. package/test/fixtures/autoreply/rfc3834-03.eml +0 -26
  111. package/test/fixtures/autoreply/rfc3834-04.eml +0 -48
  112. package/test/fixtures/autoreply/rfc3834-05.eml +0 -19
  113. package/test/fixtures/autoreply/rfc3834-06.eml +0 -59
  114. package/test/fixtures/bounces/163.eml +0 -2521
  115. package/test/fixtures/bounces/fastmail.eml +0 -242
  116. package/test/fixtures/bounces/gmail.eml +0 -252
  117. package/test/fixtures/bounces/hotmail.eml +0 -655
  118. package/test/fixtures/bounces/mailru.eml +0 -121
  119. package/test/fixtures/bounces/outlook.eml +0 -1107
  120. package/test/fixtures/bounces/postfix.eml +0 -101
  121. package/test/fixtures/bounces/rambler.eml +0 -116
  122. package/test/fixtures/bounces/workmail.eml +0 -142
  123. package/test/fixtures/bounces/yahoo.eml +0 -139
  124. package/test/fixtures/bounces/zoho.eml +0 -83
  125. package/test/fixtures/bounces/zonemta.eml +0 -100
  126. package/test/fixtures/complaints/LICENSE +0 -27
  127. package/test/fixtures/complaints/amazonses.eml +0 -72
  128. package/test/fixtures/complaints/dmarc.eml +0 -59
  129. package/test/fixtures/complaints/hotmail.eml +0 -49
  130. package/test/fixtures/complaints/optout.eml +0 -40
  131. package/test/fixtures/complaints/standard-arf.eml +0 -68
  132. package/test/fixtures/complaints/yahoo.eml +0 -68
  133. package/test/oauth2-apps-test.js +0 -301
  134. package/test/sendonly-test.js +0 -160
  135. package/test/test-config.js +0 -34
  136. package/test/webhooks-server.js +0 -39
@@ -1,272 +0,0 @@
1
- /*eslint no-unused-expressions: 0, prefer-arrow-callback: 0 */
2
-
3
- 'use strict';
4
-
5
- const chai = require('chai');
6
- const imapHandler = require('../lib/handler/imap-handler');
7
- const expect = chai.expect;
8
- chai.config.includeStack = true;
9
-
10
- describe('IMAP Command Compiler', function () {
11
- describe('#compile', function () {
12
- it('should compile correctly', function () {
13
- let command =
14
- '* FETCH (ENVELOPE ("Mon, 2 Sep 2013 05:30:13 -0700 (PDT)" NIL ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "tr.ee")) NIL NIL NIL "<-4730417346358914070@unknownmsgid>") BODYSTRUCTURE (("MESSAGE" "RFC822" NIL NIL NIL "7BIT" 105 (NIL NIL ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "pangalink.net")) NIL NIL "<test1>" NIL) ("TEXT" "PLAIN" NIL NIL NIL "7BIT" 12 0 NIL NIL NIL) 5 NIL NIL NIL)("MESSAGE" "RFC822" NIL NIL NIL "7BIT" 83 (NIL NIL ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "kreata.ee")) ((NIL NIL "andris" "pangalink.net")) NIL NIL "NIL" NIL) ("TEXT" "PLAIN" NIL NIL NIL "7BIT" 12 0 NIL NIL NIL) 4 NIL NIL NIL)("TEXT" "HTML" ("CHARSET" "utf-8") NIL NIL "QUOTED-PRINTABLE" 19 0 NIL NIL NIL) "MIXED" ("BOUNDARY" "----mailcomposer-?=_1-1328088797399") NIL NIL))',
15
- parsed = imapHandler.parser(command, {
16
- allowUntagged: true
17
- }),
18
- compiled = imapHandler.compiler(parsed);
19
-
20
- expect(compiled).to.equal(command);
21
- });
22
- });
23
-
24
- describe('Types', function () {
25
- let parsed;
26
-
27
- beforeEach(function () {
28
- parsed = {
29
- tag: '*',
30
- command: 'CMD'
31
- };
32
- });
33
-
34
- describe('No attributes', function () {
35
- it('should compile correctly', function () {
36
- expect(imapHandler.compiler(parsed)).to.equal('* CMD');
37
- });
38
- });
39
-
40
- describe('TEXT', function () {
41
- it('should compile correctly', function () {
42
- parsed.attributes = [
43
- {
44
- type: 'TEXT',
45
- value: 'Tere tere!'
46
- }
47
- ];
48
- expect(imapHandler.compiler(parsed)).to.equal('* CMD Tere tere!');
49
- });
50
- });
51
-
52
- describe('SECTION', function () {
53
- it('should compile correctly', function () {
54
- parsed.attributes = [
55
- {
56
- type: 'SECTION',
57
- section: [
58
- {
59
- type: 'ATOM',
60
- value: 'ALERT'
61
- }
62
- ]
63
- }
64
- ];
65
- expect(imapHandler.compiler(parsed)).to.equal('* CMD [ALERT]');
66
- });
67
- });
68
-
69
- describe('ATOM', function () {
70
- it('should compile correctly', function () {
71
- parsed.attributes = [
72
- //
73
- {
74
- type: 'ATOM',
75
- value: 'ALERT'
76
- },
77
- {
78
- type: 'ATOM',
79
- value: '\\ALERT'
80
- },
81
- {
82
- type: 'ATOM',
83
- value: 'NO ALERT'
84
- }
85
- ];
86
- expect(imapHandler.compiler(parsed)).to.equal('* CMD ALERT \\ALERT "NO ALERT"');
87
- });
88
- });
89
-
90
- describe('SEQUENCE', function () {
91
- it('should compile correctly', function () {
92
- parsed.attributes = [
93
- {
94
- type: 'SEQUENCE',
95
- value: '*:4,5,6'
96
- }
97
- ];
98
- expect(imapHandler.compiler(parsed)).to.equal('* CMD *:4,5,6');
99
- });
100
- });
101
-
102
- describe('NIL', function () {
103
- it('should compile correctly', function () {
104
- parsed.attributes = [null, null];
105
-
106
- expect(imapHandler.compiler(parsed)).to.equal('* CMD NIL NIL');
107
- });
108
- });
109
-
110
- describe('TEXT', function () {
111
- it('should compile correctly', function () {
112
- parsed.attributes = [
113
- // keep indentation
114
- {
115
- type: 'String',
116
- value: 'Tere tere!',
117
- sensitive: true
118
- },
119
- 'Vana kere'
120
- ];
121
-
122
- expect(imapHandler.compiler(parsed)).to.equal('* CMD "Tere tere!" "Vana kere"');
123
- });
124
-
125
- it('should keep short strings', function () {
126
- parsed.attributes = [
127
- // keep indentation
128
- {
129
- type: 'String',
130
- value: 'Tere tere!'
131
- },
132
- 'Vana kere'
133
- ];
134
-
135
- expect(imapHandler.compiler(parsed, false, true)).to.equal('* CMD "Tere tere!" "Vana kere"');
136
- });
137
-
138
- it('should hide strings', function () {
139
- parsed.attributes = [
140
- // keep indentation
141
- {
142
- type: 'String',
143
- value: 'Tere tere!',
144
- sensitive: true
145
- },
146
- 'Vana kere'
147
- ];
148
-
149
- expect(imapHandler.compiler(parsed, false, true)).to.equal('* CMD "(* value hidden *)" "Vana kere"');
150
- });
151
-
152
- it('should hide long strings', function () {
153
- parsed.attributes = [
154
- // keep indentation
155
- {
156
- type: 'String',
157
- value: 'Tere tere! Tere tere! Tere tere! Tere tere! Tere tere!'
158
- },
159
- 'Vana kere'
160
- ];
161
-
162
- expect(imapHandler.compiler(parsed, false, true)).to.equal('* CMD "(* 54B string *)" "Vana kere"');
163
- });
164
- });
165
-
166
- describe('No Command', function () {
167
- it('should compile correctly', function () {
168
- parsed = {
169
- tag: '*',
170
- attributes: [
171
- 1,
172
- {
173
- type: 'ATOM',
174
- value: 'EXPUNGE'
175
- }
176
- ]
177
- };
178
-
179
- expect(imapHandler.compiler(parsed)).to.equal('* 1 EXPUNGE');
180
- });
181
- });
182
- describe('Literal', function () {
183
- it('should return as text', function () {
184
- let parsed = {
185
- tag: '*',
186
- command: 'CMD',
187
- attributes: [
188
- // keep indentation
189
- {
190
- type: 'LITERAL',
191
- value: 'Tere tere!'
192
- },
193
- 'Vana kere'
194
- ]
195
- };
196
-
197
- expect(imapHandler.compiler(parsed)).to.equal('* CMD {10}\r\nTere tere! "Vana kere"');
198
- });
199
-
200
- it('should return as an array text 1', function () {
201
- let parsed = {
202
- tag: '*',
203
- command: 'CMD',
204
- attributes: [
205
- {
206
- type: 'LITERAL',
207
- value: 'Tere tere!'
208
- },
209
- {
210
- type: 'LITERAL',
211
- value: 'Vana kere'
212
- }
213
- ]
214
- };
215
- expect(imapHandler.compiler(parsed, true)).to.deep.equal(['* CMD {10}\r\n', 'Tere tere! {9}\r\n', 'Vana kere']);
216
- });
217
-
218
- it('should return as an array text 2', function () {
219
- let parsed = {
220
- tag: '*',
221
- command: 'CMD',
222
- attributes: [
223
- // keep indentation
224
- {
225
- type: 'LITERAL',
226
- value: 'Tere tere!'
227
- },
228
- {
229
- type: 'LITERAL',
230
- value: 'Vana kere'
231
- },
232
- 'zzz'
233
- ]
234
- };
235
- expect(imapHandler.compiler(parsed, true)).to.deep.equal(['* CMD {10}\r\n', 'Tere tere! {9}\r\n', 'Vana kere "zzz"']);
236
- });
237
-
238
- it('should compile correctly without tag and command', function () {
239
- let parsed = {
240
- attributes: [
241
- {
242
- type: 'LITERAL',
243
- value: 'Tere tere!'
244
- },
245
- {
246
- type: 'LITERAL',
247
- value: 'Vana kere'
248
- }
249
- ]
250
- };
251
- expect(imapHandler.compiler(parsed, true)).to.deep.equal(['{10}\r\n', 'Tere tere! {9}\r\n', 'Vana kere']);
252
- });
253
-
254
- it('should return byte length', function () {
255
- let parsed = {
256
- tag: '*',
257
- command: 'CMD',
258
- attributes: [
259
- // keep indentation
260
- {
261
- type: 'LITERAL',
262
- value: 'Tere tere!'
263
- },
264
- 'Vana kere'
265
- ]
266
- };
267
-
268
- expect(imapHandler.compiler(parsed, false, true)).to.equal('* CMD "(* 10B literal *)" "Vana kere"');
269
- });
270
- });
271
- });
272
- });
@@ -1,236 +0,0 @@
1
-
2
- /* eslint no-unused-expressions: 0, prefer-arrow-callback: 0 */
3
-
4
- 'use strict';
5
-
6
- const chai = require('chai');
7
- const expect = chai.expect;
8
-
9
- //let http = require('http');
10
- const fs = require('fs');
11
- const Indexer = require('../lib/indexer/indexer');
12
- const indexer = new Indexer();
13
-
14
- chai.config.includeStack = true;
15
-
16
- //const HTTP_PORT = 9998;
17
-
18
- const fixtures = {
19
- simple: {
20
- eml: fs.readFileSync(__dirname + '/fixtures/simple.eml'),
21
- tree: require('./fixtures/simple.json')
22
- },
23
- mimetorture: {
24
- eml: fs.readFileSync(__dirname + '/fixtures/mimetorture.eml'),
25
- tree: require('./fixtures/mimetorture.json')
26
- }
27
- };
28
-
29
- describe('#parseMimeTree', function() {
30
- it('should parse mime message', function(done) {
31
- let parsed = indexer.parseMimeTree(fixtures.simple.eml);
32
-
33
- //expect(parsed).to.deep.equal(fixtures.simple.tree);
34
-
35
- parsed = indexer.parseMimeTree(fixtures.mimetorture.eml);
36
-
37
- //expect(parsed).to.deep.equal(fixtures.mimetorture.tree);
38
-
39
- indexer.bodyQuery(parsed, '', (err, data) => {
40
- expect(err).to.not.exist;
41
-
42
- expect(data.toString('binary').replace(/\r?\n/g, '\n')).to.equal(fixtures.mimetorture.eml.toString('binary').replace(/\r?\n/g, '\n'));
43
- done();
44
- });
45
- });
46
- });
47
-
48
- /*
49
- describe('#rebuild', function () {
50
- let httpServer;
51
-
52
- beforeEach(function (done) {
53
- httpServer = http.createServer(function (req, res) {
54
- res.writeHead(200, {
55
- 'Content-Type': 'text/plain'
56
- });
57
- if (req.url === '/qp') {
58
- res.end('<p>Krediitkaardiga on tehtud kulutusi, mida oleks saanud v=C3=B5i pidanud =\r\ntegema muul viisil kui kaardiga. Krediitkaardiga tehtud kulude kohta ei ole=\r\n t=C3=A4htaegselt esitatud aruandlust, kuludokumentidel ei kajastu =\r\npiisavaid selgitusi, mist=C3=B5ttu esineb olulisi piiranguid kulude =\r\nsihip=C3=A4rasuse ja otstarbekuse hindamisel ning kulude p=C3=B5hjendatuse =\r\nkontrollimine on raskendatud.</p>');
59
- } else {
60
- res.end('Hello World! '.repeat(20) + 'Bye!');
61
- }
62
-
63
- });
64
-
65
- httpServer.listen(HTTP_PORT, done);
66
- });
67
-
68
- afterEach(function (done) {
69
- httpServer.close(done);
70
- });
71
-
72
-
73
- it('should rebuild using stream', function (done) {
74
- let message = `Content-Type: multipart/mixed;
75
- boundary="foo"
76
-
77
- --foo
78
- Content-Type: text/plain
79
- Content-Transfer-Encoding: base64
80
- X-Attachment-Stream-Size: 264
81
- X-Attachment-Stream-Url: <http://localhost:${HTTP_PORT}/>
82
-
83
- --foo--
84
- `;
85
- let parsed = indexer.parseMimeTree(message);
86
- indexer.bodyQuery(parsed, '', (err, data) => {
87
- expect(err).to.not.exist;
88
- expect(data.length).to.equal(492);
89
- done();
90
- });
91
- });
92
-
93
- it('should rebuild stream part', function (done) {
94
- let message = `Content-Type: multipart/mixed;
95
- boundary="foo"
96
-
97
- --foo
98
- Content-Type: text/plain
99
- Content-Transfer-Encoding: base64
100
- X-Attachment-Stream-Size: 264
101
- X-Attachment-Stream-Url: <http://localhost:${HTTP_PORT}/>
102
-
103
- --foo--
104
- `;
105
- let parsed = indexer.parseMimeTree(message);
106
- indexer.bodyQuery(parsed, {
107
- path: '1',
108
- type: ''
109
- }, (err, data) => {
110
- expect(err).to.not.exist;
111
- expect(data.length).to.equal(360);
112
- done();
113
- });
114
- });
115
-
116
- it('should rebuild using stream', function (done) {
117
- let message = `Content-Type: text/plain
118
- Content-Transfer-Encoding: base64
119
- X-Attachment-Stream-Size: 264
120
- X-Attachment-Stream-Url: <http://localhost:${HTTP_PORT}/>
121
-
122
- `;
123
- let parsed = indexer.parseMimeTree(message);
124
- indexer.bodyQuery(parsed, '', (err, data) => {
125
- expect(err).to.not.exist;
126
- expect(data.length).to.equal(423);
127
- indexer.bodyQuery(parsed, {
128
- path: '1',
129
- type: ''
130
- }, (err, data) => {
131
- expect(err).to.not.exist;
132
- expect(data.length).to.equal(360);
133
- done();
134
- });
135
- });
136
- });
137
-
138
- it('should rebuild using stream with truncated content', function (done) {
139
- let message = `Content-Type: text/plain
140
- Content-Transfer-Encoding: base64
141
- X-Attachment-Stream-Size: 150
142
- X-Attachment-Stream-Url: <http://localhost:${HTTP_PORT}/>
143
-
144
- `;
145
- let parsed = indexer.parseMimeTree(message);
146
- indexer.bodyQuery(parsed, '', (err, data) => {
147
- expect(err).to.not.exist;
148
- expect(data.length).to.equal(267);
149
- indexer.bodyQuery(parsed, {
150
- path: '1',
151
- type: ''
152
- }, (err, data) => {
153
- expect(err).to.not.exist;
154
- expect(data.length).to.equal(204);
155
- done();
156
- });
157
- });
158
- });
159
-
160
- it('should rebuild using stream with padded content', function (done) {
161
- let message = `Content-Type: text/plain
162
- Content-Transfer-Encoding: base64
163
- X-Attachment-Stream-Size: 280
164
- X-Attachment-Stream-Url: <http://localhost:${HTTP_PORT}/>
165
-
166
- `;
167
- let parsed = indexer.parseMimeTree(message);
168
- indexer.bodyQuery(parsed, '', (err, data) => {
169
- expect(err).to.not.exist;
170
- expect(data.length).to.equal(447);
171
- indexer.bodyQuery(parsed, {
172
- path: '1',
173
- type: ''
174
- }, (err, data) => {
175
- expect(err).to.not.exist;
176
- expect(data.length).to.equal(384);
177
- done();
178
- });
179
- });
180
- });
181
-
182
- it('should return correct attachment size in bodystructure', function () {
183
- let message = `Content-Type: multipart/mixed;
184
- boundary="foo"
185
-
186
- --foo
187
- Content-Type: text/plain
188
- Content-Transfer-Encoding: 7bit
189
-
190
- Hello world!
191
- --foo
192
- Content-Type: application/octet-stream
193
- Content-Disposition: attachment; filename=normal.bin
194
- Content-Transfer-Encoding: 7bit
195
-
196
- 12345678901234567890
197
- --foo
198
- Content-Type: application/octet-stream
199
- Content-Disposition: attachment; filename=stream.bin
200
- Content-Transfer-Encoding: base64
201
- X-Attachment-Stream-Size: 264
202
- X-Attachment-Stream-Url: <http://localhost:${HTTP_PORT}/>
203
-
204
- --foo--
205
- `;
206
- let parsed = indexer.parseMimeTree(message);
207
- let bodystruct = indexer.getBodyStructure(parsed);
208
- expect(bodystruct[1][6]).to.equal(20);
209
- expect(bodystruct[2][6]).to.equal(360);
210
- });
211
-
212
- it('should rebuild using encoded stream', function (done) {
213
- let message = `Content-Type: text/html; charset=utf-8
214
- Content-Transfer-Encoding: quoted-printable
215
- X-Attachment-Stream-Size: 407
216
- X-Attachment-Stream-Url: <http://localhost:${HTTP_PORT}/qp>
217
- X-Attachment-Stream-Lines: 6
218
- X-Attachment-Stream-Encoded: Yes
219
-
220
- `;
221
- let parsed = indexer.parseMimeTree(message);
222
- indexer.bodyQuery(parsed, '', (err, data) => {
223
- expect(err).to.not.exist;
224
- expect(data.length).to.equal(494);
225
- indexer.bodyQuery(parsed, {
226
- path: '1',
227
- type: ''
228
- }, (err, data) => {
229
- expect(err).to.not.exist;
230
- expect(data.length).to.equal(407);
231
- done();
232
- });
233
- });
234
- });
235
- });
236
- */