mikromail 0.0.1

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/lib/index.mjs ADDED
@@ -0,0 +1,10 @@
1
+ import {
2
+ MikroMail
3
+ } from "./chunk-XNGASLEZ.mjs";
4
+ import "./chunk-V2NYOKWA.mjs";
5
+ import "./chunk-TCYL3UFZ.mjs";
6
+ import "./chunk-47VXJTWV.mjs";
7
+ import "./chunk-UDLJWUFN.mjs";
8
+ export {
9
+ MikroMail
10
+ };
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Configuration options for SMTP client.
3
+ */
4
+ interface SMTPConfiguration {
5
+ user: string;
6
+ password: string;
7
+ host: string;
8
+ port?: number;
9
+ secure?: boolean;
10
+ timeout?: number;
11
+ debug?: boolean;
12
+ clientName?: string;
13
+ maxRetries?: number;
14
+ retryDelay?: number;
15
+ skipAuthentication?: boolean;
16
+ }
17
+ /**
18
+ * Email sending options.
19
+ */
20
+ interface EmailOptions {
21
+ from?: string;
22
+ to: string;
23
+ cc?: string | string[];
24
+ bcc?: string | string[];
25
+ replyTo?: string;
26
+ subject: string;
27
+ text?: string;
28
+ html?: string;
29
+ attachments?: Attachment[];
30
+ headers?: Record<string, string>;
31
+ }
32
+ /**
33
+ * Email attachment definition.
34
+ */
35
+ interface Attachment {
36
+ filename: string;
37
+ content: string | Buffer;
38
+ contentType?: string;
39
+ encoding?: 'base64' | 'hex' | 'binary';
40
+ }
41
+ /**
42
+ * Result of email sending operation.
43
+ */
44
+ interface SendResult {
45
+ success: boolean;
46
+ messageId?: string;
47
+ message?: string;
48
+ error?: string;
49
+ }
50
+ /**
51
+ * Supported authentication methods.
52
+ */
53
+ type AuthMethod = 'PLAIN' | 'LOGIN' | 'CRAM-MD5';
54
+ type ConfigurationOptions = {
55
+ config?: SMTPConfiguration;
56
+ configFilePath?: string;
57
+ args?: string[];
58
+ };
59
+
60
+ export type { Attachment, AuthMethod, ConfigurationOptions, EmailOptions, SMTPConfiguration, SendResult };
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Configuration options for SMTP client.
3
+ */
4
+ interface SMTPConfiguration {
5
+ user: string;
6
+ password: string;
7
+ host: string;
8
+ port?: number;
9
+ secure?: boolean;
10
+ timeout?: number;
11
+ debug?: boolean;
12
+ clientName?: string;
13
+ maxRetries?: number;
14
+ retryDelay?: number;
15
+ skipAuthentication?: boolean;
16
+ }
17
+ /**
18
+ * Email sending options.
19
+ */
20
+ interface EmailOptions {
21
+ from?: string;
22
+ to: string;
23
+ cc?: string | string[];
24
+ bcc?: string | string[];
25
+ replyTo?: string;
26
+ subject: string;
27
+ text?: string;
28
+ html?: string;
29
+ attachments?: Attachment[];
30
+ headers?: Record<string, string>;
31
+ }
32
+ /**
33
+ * Email attachment definition.
34
+ */
35
+ interface Attachment {
36
+ filename: string;
37
+ content: string | Buffer;
38
+ contentType?: string;
39
+ encoding?: 'base64' | 'hex' | 'binary';
40
+ }
41
+ /**
42
+ * Result of email sending operation.
43
+ */
44
+ interface SendResult {
45
+ success: boolean;
46
+ messageId?: string;
47
+ message?: string;
48
+ error?: string;
49
+ }
50
+ /**
51
+ * Supported authentication methods.
52
+ */
53
+ type AuthMethod = 'PLAIN' | 'LOGIN' | 'CRAM-MD5';
54
+ type ConfigurationOptions = {
55
+ config?: SMTPConfiguration;
56
+ configFilePath?: string;
57
+ args?: string[];
58
+ };
59
+
60
+ export type { Attachment, AuthMethod, ConfigurationOptions, EmailOptions, SMTPConfiguration, SendResult };
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+
16
+ // src/interfaces/index.ts
17
+ var interfaces_exports = {};
18
+ module.exports = __toCommonJS(interfaces_exports);
File without changes
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Encode text using quoted-printable encoding
3
+ * Follows RFC 2045 specification for MIME encoding
4
+ */
5
+ declare function encodeQuotedPrintable(text: string): string;
6
+ /**
7
+ * Validates an email address using stricter rules
8
+ */
9
+ declare function validateEmail(email: string): boolean;
10
+ /**
11
+ * Helper function to verify SMTP server MX records
12
+ */
13
+ declare function verifyMXRecords(domain: string): Promise<boolean>;
14
+ /**
15
+ * Helper function to verify email domain has proper MX records
16
+ */
17
+ declare function verifyEmailDomain(email: string): Promise<boolean>;
18
+
19
+ export { encodeQuotedPrintable, validateEmail, verifyEmailDomain, verifyMXRecords };
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Encode text using quoted-printable encoding
3
+ * Follows RFC 2045 specification for MIME encoding
4
+ */
5
+ declare function encodeQuotedPrintable(text: string): string;
6
+ /**
7
+ * Validates an email address using stricter rules
8
+ */
9
+ declare function validateEmail(email: string): boolean;
10
+ /**
11
+ * Helper function to verify SMTP server MX records
12
+ */
13
+ declare function verifyMXRecords(domain: string): Promise<boolean>;
14
+ /**
15
+ * Helper function to verify email domain has proper MX records
16
+ */
17
+ declare function verifyEmailDomain(email: string): Promise<boolean>;
18
+
19
+ export { encodeQuotedPrintable, validateEmail, verifyEmailDomain, verifyMXRecords };
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/utils/index.ts
21
+ var utils_exports = {};
22
+ __export(utils_exports, {
23
+ encodeQuotedPrintable: () => encodeQuotedPrintable,
24
+ validateEmail: () => validateEmail,
25
+ verifyEmailDomain: () => verifyEmailDomain,
26
+ verifyMXRecords: () => verifyMXRecords
27
+ });
28
+ module.exports = __toCommonJS(utils_exports);
29
+ var import_node_dns = require("dns");
30
+ function encodeQuotedPrintable(text) {
31
+ let result = text.replace(/\r?\n/g, "\r\n");
32
+ result = result.replace(/=/g, "=3D");
33
+ const utf8Bytes = new TextEncoder().encode(result);
34
+ let encoded = "";
35
+ let lineLength = 0;
36
+ for (let i = 0; i < utf8Bytes.length; i++) {
37
+ const byte = utf8Bytes[i];
38
+ let chunk = "";
39
+ if (byte >= 33 && byte <= 126 && byte !== 61 || byte === 32) {
40
+ chunk = String.fromCharCode(byte);
41
+ } else if (byte === 13 || byte === 10) {
42
+ chunk = String.fromCharCode(byte);
43
+ if (byte === 10) {
44
+ lineLength = 0;
45
+ }
46
+ } else {
47
+ const hex = byte.toString(16).toUpperCase();
48
+ chunk = `=${hex.length < 2 ? `0${hex}` : hex}`;
49
+ }
50
+ if (lineLength + chunk.length > 75 && !(byte === 13 || byte === 10)) {
51
+ encoded += "=\r\n";
52
+ lineLength = 0;
53
+ }
54
+ encoded += chunk;
55
+ lineLength += chunk.length;
56
+ }
57
+ return encoded;
58
+ }
59
+ function validateEmail(email) {
60
+ try {
61
+ const [localPart, domain] = email.split("@");
62
+ if (!localPart || localPart.length > 64) return false;
63
+ if (localPart.startsWith(".") || localPart.endsWith(".") || localPart.includes(".."))
64
+ return false;
65
+ if (!/^[a-zA-Z0-9!#$%&'*+\-/=?^_`{|}~.]+$/.test(localPart)) return false;
66
+ if (!domain || domain.length > 255) return false;
67
+ if (domain.startsWith("[") && domain.endsWith("]")) {
68
+ const ipContent = domain.slice(1, -1);
69
+ if (ipContent.startsWith("IPv6:")) return true;
70
+ const ipv4Regex = /^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/;
71
+ return ipv4Regex.test(ipContent);
72
+ }
73
+ if (domain.startsWith(".") || domain.endsWith(".") || domain.includes(".."))
74
+ return false;
75
+ const domainParts = domain.split(".");
76
+ if (domainParts.length < 2 || domainParts[domainParts.length - 1].length < 2)
77
+ return false;
78
+ for (const part of domainParts) {
79
+ if (!part || part.length > 63) return false;
80
+ if (!/^[a-zA-Z0-9]([a-zA-Z0-9\-]*[a-zA-Z0-9])?$/.test(part)) return false;
81
+ }
82
+ return true;
83
+ } catch (_error) {
84
+ return false;
85
+ }
86
+ }
87
+ async function verifyMXRecords(domain) {
88
+ try {
89
+ const records = await import_node_dns.promises.resolveMx(domain);
90
+ return !!records && records.length > 0;
91
+ } catch (_error) {
92
+ return false;
93
+ }
94
+ }
95
+ async function verifyEmailDomain(email) {
96
+ try {
97
+ const domain = email.split("@")[1];
98
+ if (!domain) return false;
99
+ return await verifyMXRecords(domain);
100
+ } catch (_error) {
101
+ return false;
102
+ }
103
+ }
104
+ // Annotate the CommonJS export names for ESM import in node:
105
+ 0 && (module.exports = {
106
+ encodeQuotedPrintable,
107
+ validateEmail,
108
+ verifyEmailDomain,
109
+ verifyMXRecords
110
+ });
@@ -0,0 +1,12 @@
1
+ import {
2
+ encodeQuotedPrintable,
3
+ validateEmail,
4
+ verifyEmailDomain,
5
+ verifyMXRecords
6
+ } from "../chunk-UDLJWUFN.mjs";
7
+ export {
8
+ encodeQuotedPrintable,
9
+ validateEmail,
10
+ verifyEmailDomain,
11
+ verifyMXRecords
12
+ };
package/package.json ADDED
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "mikromail",
3
+ "description": "Lightweight replacement for Nodemailer, supporting HTML, international symbols, and more.",
4
+ "version": "0.0.1",
5
+ "author": "Mikael Vesavuori",
6
+ "license": "MIT",
7
+ "keywords": [],
8
+ "main": "lib/index.js",
9
+ "module": "lib/index.mjs",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/mikaelvesavuori/mikromail"
13
+ },
14
+ "bugs": {
15
+ "url": "https://github.com/mikaelvesavuori/mikromail/issues"
16
+ },
17
+ "homepage": "https://github.com/mikaelvesavuori/mikromail",
18
+ "exports": {
19
+ ".": {
20
+ "require": "./lib/index.js",
21
+ "import": "./lib/index.mjs"
22
+ }
23
+ },
24
+ "files": [
25
+ "/lib",
26
+ "!/lib/**/*.map",
27
+ "!/tests"
28
+ ],
29
+ "scripts": {
30
+ "test": "npm run test:licenses && npm run test:types && npm run lint && npm run test:unit",
31
+ "test:data": "rm -rf test-db && npx tsx random-data.ts",
32
+ "test:types": "npx type-coverage --at-least 95 --strict --ignore-files \"tests/**/*.ts\" --ignore-files \"*.ts\" --ignore-files \"src/errors/*.ts\" --ignore-files \"testdata/*.ts\"",
33
+ "test:licenses": "npx license-compliance --direct --allow 'MIT;ISC;0BSD;BSD-2-Clause;BSD-3-Clause;Apache-2.0;Unlicense;CC0-1.0'",
34
+ "test:unit": "npx vitest run --coverage",
35
+ "test:watch": "npx vitest --watch",
36
+ "build": "npm run clean && npm run build:tsup",
37
+ "build:tsup": "npm run clean && tsup src --format esm,cjs --dts && mv dist lib",
38
+ "clean": "rm -rf lib && rm -rf dist",
39
+ "lint": "npx @biomejs/biome check --write ./src ./tests",
40
+ "package": "npm pack",
41
+ "prepublishOnly": "npm run build"
42
+ },
43
+ "devDependencies": {
44
+ "@biomejs/biome": "1",
45
+ "@types/node": "latest",
46
+ "@vitest/coverage-v8": "2",
47
+ "husky": "9",
48
+ "license-compliance": "latest",
49
+ "tslib": "latest",
50
+ "tsup": "8",
51
+ "tsx": "latest",
52
+ "type-coverage": "2",
53
+ "typescript": "5",
54
+ "vitest": "2"
55
+ }
56
+ }