Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4b694bd33a | |||
| 13ca27db86 |
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"@git.zone/cli": {
|
||||
"projectType": "npm",
|
||||
"module": {
|
||||
"githost": "code.foss.global",
|
||||
"gitscope": "push.rocks",
|
||||
"gitrepo": "smartimap",
|
||||
"shortDescription": "event-driven IMAP message parser",
|
||||
"description": "A Node.js library for event-driven streaming and parsing of IMAP email messages.",
|
||||
"npmPackagename": "@push.rocks/smartimap",
|
||||
"license": "MIT",
|
||||
"projectDomain": "push.rocks",
|
||||
"keywords": [
|
||||
"imap",
|
||||
"email",
|
||||
"streaming",
|
||||
"mailparser",
|
||||
"email-client",
|
||||
"nodejs",
|
||||
"event-driven",
|
||||
"automation",
|
||||
"message-stream",
|
||||
"filter",
|
||||
"inbox",
|
||||
"connection",
|
||||
"message processing"
|
||||
]
|
||||
},
|
||||
"release": {
|
||||
"registries": [
|
||||
"https://verdaccio.lossless.digital",
|
||||
"https://registry.npmjs.org"
|
||||
],
|
||||
"accessLevel": "public"
|
||||
}
|
||||
},
|
||||
"@ship.zone/szci": {
|
||||
"npmGlobalTools": [],
|
||||
"npmRegistryUrl": "registry.npmjs.org"
|
||||
},
|
||||
"@git.zone/tsdoc": {
|
||||
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,13 @@
|
||||
# Changelog
|
||||
|
||||
## 2026-05-01 - 1.2.1 - fix(imap client)
|
||||
harden IMAP client message processing and modernize test tooling
|
||||
|
||||
- Guard against empty search results and missing message sources before parsing fetched messages.
|
||||
- Handle non-Error exceptions safely in the IMAP server command response path.
|
||||
- Migrate tests to @git.zone/tstest with node-specific test files and make the IMAP integration test opt-in via environment flag.
|
||||
- Update package metadata, exports, TypeScript settings, and dependency versions to align with the current build setup.
|
||||
|
||||
## 2024-11-26 - 1.2.0 - feat(core)
|
||||
Introduce ImapClient and ImapServer classes for enhanced IMAP support
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
Copyright (c) 2026 Task Venture Capital GmbH <hello@task.vc>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
+12
-4
@@ -1,10 +1,11 @@
|
||||
{
|
||||
"gitzone": {
|
||||
"@git.zone/cli": {
|
||||
"projectType": "npm",
|
||||
"module": {
|
||||
"githost": "code.foss.global",
|
||||
"gitscope": "push.rocks",
|
||||
"gitrepo": "smartimap",
|
||||
"shortDescription": "event-driven IMAP message parser",
|
||||
"description": "A Node.js library for event-driven streaming and parsing of IMAP email messages.",
|
||||
"npmPackagename": "@push.rocks/smartimap",
|
||||
"license": "MIT",
|
||||
@@ -24,13 +25,20 @@
|
||||
"connection",
|
||||
"message processing"
|
||||
]
|
||||
},
|
||||
"release": {
|
||||
"registries": [
|
||||
"https://verdaccio.lossless.digital",
|
||||
"https://registry.npmjs.org"
|
||||
],
|
||||
"accessLevel": "public"
|
||||
}
|
||||
},
|
||||
"npmci": {
|
||||
"@ship.zone/szci": {
|
||||
"npmGlobalTools": [],
|
||||
"npmAccessLevel": "public"
|
||||
"npmRegistryUrl": "registry.npmjs.org"
|
||||
},
|
||||
"tsdoc": {
|
||||
"@git.zone/tsdoc": {
|
||||
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
|
||||
}
|
||||
}
|
||||
+17
-15
@@ -1,31 +1,31 @@
|
||||
{
|
||||
"name": "@push.rocks/smartimap",
|
||||
"version": "1.2.0",
|
||||
"version": "1.2.1",
|
||||
"private": false,
|
||||
"description": "A Node.js library for event-driven streaming and parsing of IMAP email messages.",
|
||||
"exports": {
|
||||
".": "./dist_ts/index.js"
|
||||
},
|
||||
"main": "dist_ts/index.js",
|
||||
"typings": "dist_ts/index.d.ts",
|
||||
"type": "module",
|
||||
"author": "Task Venture Capital GmbH",
|
||||
"author": "Task Venture Capital GmbH <hello@task.vc>",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"test": "(tstest test/ --web)",
|
||||
"build": "(tsbuild --web --allowimplicitany)",
|
||||
"buildDocs": "(tsdoc)"
|
||||
"test": "tstest test/",
|
||||
"build": "tsbuild --web",
|
||||
"buildDocs": "tsdoc"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@git.zone/tsbuild": "^2.2.0",
|
||||
"@git.zone/tsbundle": "^2.1.0",
|
||||
"@git.zone/tsrun": "^1.3.3",
|
||||
"@git.zone/tstest": "^1.0.44",
|
||||
"@push.rocks/tapbundle": "^5.5.3",
|
||||
"@types/node": "^22.10.0"
|
||||
"@git.zone/tsbuild": "^4.4.0",
|
||||
"@git.zone/tsrun": "^2.0.3",
|
||||
"@git.zone/tstest": "^3.6.3",
|
||||
"@types/node": "^25.6.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/imapflow": "^1.0.19",
|
||||
"@types/mailparser": "^3.4.5",
|
||||
"imapflow": "^1.0.169",
|
||||
"mailparser": "^3.7.1"
|
||||
"@types/mailparser": "^3.4.6",
|
||||
"imapflow": "^1.3.3",
|
||||
"mailparser": "^3.9.8"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -47,6 +47,8 @@
|
||||
"dist_ts_web/**/*",
|
||||
"assets/**/*",
|
||||
"cli.js",
|
||||
".smartconfig.json",
|
||||
"license",
|
||||
"npmextra.json",
|
||||
"readme.md"
|
||||
],
|
||||
|
||||
Generated
+4157
-6027
File diff suppressed because it is too large
Load Diff
@@ -1,10 +1,16 @@
|
||||
import { expect, expectAsync, tap } from '@push.rocks/tapbundle';
|
||||
import { tapNodeTools } from '@push.rocks/tapbundle/node';
|
||||
import { tap } from '@git.zone/tstest/tapbundle';
|
||||
import { TapNodeTools } from '@git.zone/tstest/tapbundle_serverside';
|
||||
import * as smartimap from '../ts/index.js';
|
||||
|
||||
let testSmartImap: smartimap.ImapClient;
|
||||
const tapNodeTools = new TapNodeTools(tap);
|
||||
|
||||
tap.test('smartimap', async () => {
|
||||
if (process.env.SMARTIMAP_RUN_INTEGRATION_TESTS !== 'true') {
|
||||
console.log('Skipping IMAP integration test. Set SMARTIMAP_RUN_INTEGRATION_TESTS=true to run it.');
|
||||
return;
|
||||
}
|
||||
|
||||
testSmartImap = new smartimap.ImapClient({
|
||||
host: await tapNodeTools.getEnvVarOnDemand('IMAP_URL'),
|
||||
port: 993,
|
||||
@@ -17,13 +23,11 @@ tap.test('smartimap', async () => {
|
||||
filter: { seen: true, to: await tapNodeTools.getEnvVarOnDemand('IMAP_USER'), },
|
||||
});
|
||||
|
||||
await testSmartImap.connect();
|
||||
|
||||
testSmartImap.on('message', (message: smartimap.SmartImapMessage) => {
|
||||
console.log(message.subject);
|
||||
});
|
||||
|
||||
testSmartImap.on('error', (error) => {
|
||||
testSmartImap.on('error', (error: Error) => {
|
||||
console.error(error);
|
||||
});
|
||||
|
||||
@@ -34,6 +38,9 @@ tap.test('smartimap', async () => {
|
||||
testSmartImap.on('disconnected', () => {
|
||||
console.log('Disconnected');
|
||||
});
|
||||
|
||||
await testSmartImap.connect();
|
||||
await testSmartImap.disconnect();
|
||||
});
|
||||
|
||||
tap.start();
|
||||
export default tap.start();
|
||||
@@ -1,5 +1,4 @@
|
||||
import { tap, expect, expectAsync } from '@push.rocks/tapbundle';
|
||||
import { jestExpect } from '@push.rocks/tapbundle/node';
|
||||
import { tap } from '@git.zone/tstest/tapbundle';
|
||||
|
||||
import { ImapServer } from '../ts/classes.imapserver.js';
|
||||
|
||||
@@ -26,4 +25,4 @@ tap.test('imapserver', async () => {
|
||||
// imapServer.start(143);
|
||||
});
|
||||
|
||||
tap.start();
|
||||
export default tap.start();
|
||||
@@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@push.rocks/smartimap',
|
||||
version: '1.2.0',
|
||||
version: '1.2.1',
|
||||
description: 'A Node.js library for event-driven streaming and parsing of IMAP email messages.'
|
||||
}
|
||||
|
||||
@@ -68,6 +68,9 @@ export class ImapClient extends plugins.events.EventEmitter {
|
||||
|
||||
try {
|
||||
const searchResult = await this.client.search(this.filter);
|
||||
if (!searchResult) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Convert searchResult to a regular array
|
||||
const searchResultArray = Array.from(searchResult);
|
||||
@@ -80,6 +83,9 @@ export class ImapClient extends plugins.events.EventEmitter {
|
||||
|
||||
// Fetch messages
|
||||
for await (const message of this.client.fetch(newUids, { envelope: true, source: true })) {
|
||||
if (!message.source) {
|
||||
continue;
|
||||
}
|
||||
const parsed = await plugins.mailparser.simpleParser(message.source);
|
||||
this.emit('message', parsed);
|
||||
this.seenUids.add(message.uid);
|
||||
|
||||
@@ -145,7 +145,8 @@ export class ImapServer {
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
response = `${tag} BAD Error: ${error.message}`;
|
||||
const errorMessage = error instanceof Error ? error.message : String(error);
|
||||
response = `${tag} BAD Error: ${errorMessage}`;
|
||||
}
|
||||
|
||||
socket.write(response + "\r\n");
|
||||
|
||||
+3
-1
@@ -5,8 +5,10 @@
|
||||
"target": "ES2022",
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"noImplicitAny": true,
|
||||
"esModuleInterop": true,
|
||||
"verbatimModuleSyntax": true
|
||||
"verbatimModuleSyntax": true,
|
||||
"types": ["node"]
|
||||
},
|
||||
"exclude": [
|
||||
"dist_*/**/*.d.ts"
|
||||
|
||||
Reference in New Issue
Block a user