6 Commits

Author SHA1 Message Date
d7f37afc30 1.2.1
Some checks failed
CI / Type Check & Lint (push) Failing after 34s
CI / Build Test (Current Platform) (push) Failing after 38s
Publish to npm / npm-publish (push) Failing after 59s
CI / Build All Platforms (push) Successful in 2m2s
Release / build-and-release (push) Successful in 2m4s
2025-10-24 10:00:25 +00:00
27b6bb779e fix(mail/delivery): Centralize runtime/plugin imports and switch modules to use plugins exports; unify EventEmitter usage; update Deno dependencies and small path/server refactors 2025-10-24 10:00:25 +00:00
d4778d15fc 1.2.0
Some checks failed
CI / Build All Platforms (push) Failing after 11s
CI / Build Test (Current Platform) (push) Failing after 13s
CI / Type Check & Lint (push) Failing after 18s
Publish to npm / npm-publish (push) Failing after 12s
Release / build-and-release (push) Failing after 12s
2025-10-24 08:19:56 +00:00
269bafc1bf feat(plugins): Add smartmail, mailauth and uuid to Deno dependencies and export them from plugins; include local dev permissions file 2025-10-24 08:19:56 +00:00
d6a1cf5bf4 1.1.0
Some checks failed
CI / Type Check & Lint (push) Failing after 4s
CI / Build Test (Current Platform) (push) Failing after 3s
CI / Build All Platforms (push) Failing after 3s
Publish to npm / npm-publish (push) Failing after 5s
Release / build-and-release (push) Failing after 3s
2025-10-24 08:13:59 +00:00
e49becec95 feat(ci): Add CI, release and npm-publish automation; introduce release template and local settings 2025-10-24 08:13:59 +00:00
23 changed files with 626 additions and 56 deletions

View File

@@ -0,0 +1,26 @@
## MAILER {{VERSION}}
Pre-compiled binaries for multiple platforms.
### Installation
#### Option 1: Via npm (recommended)
```bash
npm install -g @serve.zone/mailer
```
#### Option 2: Direct binary download
Download the appropriate binary for your platform from the assets below and make it executable.
### Supported Platforms
- Linux x86_64 (x64)
- Linux ARM64 (aarch64)
- macOS x86_64 (Intel)
- macOS ARM64 (Apple Silicon)
- Windows x86_64
### Checksums
SHA256 checksums are provided in `SHA256SUMS.txt` for binary verification.
### npm Package
The npm package includes automatic binary detection and installation for your platform.

84
.gitea/workflows/ci.yml Normal file
View File

@@ -0,0 +1,84 @@
name: CI
on:
push:
branches:
- main
- 'migration/**'
pull_request:
branches:
- main
jobs:
check:
name: Type Check & Lint
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Deno
uses: denoland/setup-deno@v1
with:
deno-version: v2.x
- name: Check TypeScript types
run: deno check mod.ts
- name: Lint code
run: deno lint
continue-on-error: true
- name: Format check
run: deno fmt --check
continue-on-error: true
build:
name: Build Test (Current Platform)
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Deno
uses: denoland/setup-deno@v1
with:
deno-version: v2.x
- name: Compile for current platform
run: |
echo "Testing compilation for Linux x86_64..."
deno compile --allow-all --no-check \
--output mailer-test \
--target x86_64-unknown-linux-gnu mod.ts
- name: Test binary execution
run: |
chmod +x mailer-test
./mailer-test --version
./mailer-test help
build-all:
name: Build All Platforms
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Deno
uses: denoland/setup-deno@v1
with:
deno-version: v2.x
- name: Compile all platform binaries
run: bash scripts/compile-all.sh
- name: Upload all binaries as artifact
uses: actions/upload-artifact@v3
with:
name: mailer-binaries.zip
path: dist/binaries/*
retention-days: 30

View File

@@ -0,0 +1,129 @@
name: Publish to npm
on:
push:
tags:
- 'v*'
jobs:
npm-publish:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Deno
uses: denoland/setup-deno@v1
with:
deno-version: v2.x
- name: Setup Node.js for npm publishing
uses: actions/setup-node@v4
with:
node-version: '18.x'
registry-url: 'https://registry.npmjs.org/'
- name: Get version from tag
id: version
run: |
VERSION=${GITHUB_REF#refs/tags/}
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "version_number=${VERSION#v}" >> $GITHUB_OUTPUT
echo "Publishing version: $VERSION"
- name: Verify deno.json version matches tag
run: |
DENO_VERSION=$(grep -o '"version": "[^"]*"' deno.json | cut -d'"' -f4)
TAG_VERSION="${{ steps.version.outputs.version_number }}"
echo "deno.json version: $DENO_VERSION"
echo "Tag version: $TAG_VERSION"
if [ "$DENO_VERSION" != "$TAG_VERSION" ]; then
echo "ERROR: Version mismatch!"
echo "deno.json has version $DENO_VERSION but tag is $TAG_VERSION"
exit 1
fi
- name: Compile binaries for npm package
run: |
echo "Compiling binaries for npm package..."
deno task compile
echo ""
echo "Binary sizes:"
ls -lh dist/binaries/
- name: Generate SHA256 checksums
run: |
cd dist/binaries
sha256sum * > SHA256SUMS
cat SHA256SUMS
cd ../..
- name: Sync package.json version
run: |
VERSION="${{ steps.version.outputs.version_number }}"
echo "Syncing package.json to version ${VERSION}..."
npm version ${VERSION} --no-git-tag-version --allow-same-version
echo "package.json version: $(grep '"version"' package.json | head -1)"
- name: Create npm package
run: |
echo "Creating npm package..."
npm pack
echo ""
echo "Package created:"
ls -lh *.tgz
- name: Test local installation
run: |
echo "Testing local package installation..."
PACKAGE_FILE=$(ls *.tgz)
npm install -g ${PACKAGE_FILE}
echo ""
echo "Testing mailer command:"
mailer --version || echo "Note: Binary execution may fail in CI environment"
echo ""
echo "Checking installed files:"
npm ls -g @serve.zone/mailer || true
- name: Publish to npm
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
echo "Publishing to npm registry..."
npm publish --access public
echo ""
echo "✅ Successfully published @serve.zone/mailer to npm!"
echo ""
echo "Package info:"
npm view @serve.zone/mailer
- name: Verify npm package
run: |
echo "Waiting for npm propagation..."
sleep 30
echo ""
echo "Verifying published package..."
npm view @serve.zone/mailer
echo ""
echo "Testing installation from npm:"
npm install -g @serve.zone/mailer
echo ""
echo "Package installed successfully!"
which mailer || echo "Binary location check skipped"
- name: Publish Summary
run: |
echo "================================================"
echo " npm Publish Complete!"
echo "================================================"
echo ""
echo "✅ Package: @serve.zone/mailer"
echo "✅ Version: ${{ steps.version.outputs.version }}"
echo ""
echo "Installation:"
echo " npm install -g @serve.zone/mailer"
echo ""
echo "Registry:"
echo " https://www.npmjs.com/package/@serve.zone/mailer"
echo ""

View File

@@ -0,0 +1,249 @@
name: Release
on:
push:
tags:
- 'v*'
jobs:
build-and-release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Deno
uses: denoland/setup-deno@v1
with:
deno-version: v2.x
- name: Get version from tag
id: version
run: |
VERSION=${GITHUB_REF#refs/tags/}
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "version_number=${VERSION#v}" >> $GITHUB_OUTPUT
echo "Building version: $VERSION"
- name: Verify deno.json version matches tag
run: |
DENO_VERSION=$(grep -o '"version": "[^"]*"' deno.json | cut -d'"' -f4)
TAG_VERSION="${{ steps.version.outputs.version_number }}"
echo "deno.json version: $DENO_VERSION"
echo "Tag version: $TAG_VERSION"
if [ "$DENO_VERSION" != "$TAG_VERSION" ]; then
echo "ERROR: Version mismatch!"
echo "deno.json has version $DENO_VERSION but tag is $TAG_VERSION"
exit 1
fi
- name: Compile binaries for all platforms
run: |
echo "================================================"
echo " MAILER Release Compilation"
echo " Version: ${{ steps.version.outputs.version }}"
echo "================================================"
echo ""
# Clean up old binaries and create fresh directory
rm -rf dist/binaries
mkdir -p dist/binaries
echo "→ Cleaned old binaries from dist/binaries"
echo ""
# Linux x86_64
echo "→ Compiling for Linux x86_64..."
deno compile --allow-all --no-check \
--output dist/binaries/mailer-linux-x64 \
--target x86_64-unknown-linux-gnu mod.ts
echo " ✓ Linux x86_64 complete"
# Linux ARM64
echo "→ Compiling for Linux ARM64..."
deno compile --allow-all --no-check \
--output dist/binaries/mailer-linux-arm64 \
--target aarch64-unknown-linux-gnu mod.ts
echo " ✓ Linux ARM64 complete"
# macOS x86_64
echo "→ Compiling for macOS x86_64..."
deno compile --allow-all --no-check \
--output dist/binaries/mailer-macos-x64 \
--target x86_64-apple-darwin mod.ts
echo " ✓ macOS x86_64 complete"
# macOS ARM64
echo "→ Compiling for macOS ARM64..."
deno compile --allow-all --no-check \
--output dist/binaries/mailer-macos-arm64 \
--target aarch64-apple-darwin mod.ts
echo " ✓ macOS ARM64 complete"
# Windows x86_64
echo "→ Compiling for Windows x86_64..."
deno compile --allow-all --no-check \
--output dist/binaries/mailer-windows-x64.exe \
--target x86_64-pc-windows-msvc mod.ts
echo " ✓ Windows x86_64 complete"
echo ""
echo "All binaries compiled successfully!"
ls -lh dist/binaries/
- name: Generate SHA256 checksums
run: |
cd dist/binaries
sha256sum * > SHA256SUMS.txt
cat SHA256SUMS.txt
cd ../..
- name: Extract changelog for this version
id: changelog
run: |
VERSION="${{ steps.version.outputs.version }}"
# Check if CHANGELOG.md exists
if [ ! -f CHANGELOG.md ]; then
echo "No CHANGELOG.md found, using default release notes"
cat > /tmp/release_notes.md << EOF
## MAILER $VERSION
Pre-compiled binaries for multiple platforms.
### Installation
Use the installation script:
\`\`\`bash
curl -sSL https://code.foss.global/serve.zone/mailer/raw/branch/main/install.sh | sudo bash
\`\`\`
Or download the binary for your platform and make it executable.
### Supported Platforms
- Linux x86_64 (x64)
- Linux ARM64 (aarch64)
- macOS x86_64 (Intel)
- macOS ARM64 (Apple Silicon)
- Windows x86_64
### Checksums
SHA256 checksums are provided in SHA256SUMS.txt
EOF
else
# Try to extract section for this version from CHANGELOG.md
# This is a simple extraction - adjust based on your CHANGELOG format
awk "/## \[$VERSION\]/,/## \[/" CHANGELOG.md | sed '$d' > /tmp/release_notes.md || cat > /tmp/release_notes.md << EOF
## MAILER $VERSION
See CHANGELOG.md for full details.
### Installation
Use the installation script:
\`\`\`bash
curl -sSL https://code.foss.global/serve.zone/mailer/raw/branch/main/install.sh | sudo bash
\`\`\`
EOF
fi
echo "Release notes:"
cat /tmp/release_notes.md
- name: Delete existing release if it exists
run: |
VERSION="${{ steps.version.outputs.version }}"
echo "Checking for existing release $VERSION..."
# Try to get existing release by tag
EXISTING_RELEASE_ID=$(curl -s \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://code.foss.global/api/v1/repos/serve.zone/mailer/releases/tags/$VERSION" \
| jq -r '.id // empty')
if [ -n "$EXISTING_RELEASE_ID" ]; then
echo "Found existing release (ID: $EXISTING_RELEASE_ID), deleting..."
curl -X DELETE -s \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://code.foss.global/api/v1/repos/serve.zone/mailer/releases/$EXISTING_RELEASE_ID"
echo "Existing release deleted"
sleep 2
else
echo "No existing release found, proceeding with creation"
fi
- name: Create Gitea Release
run: |
VERSION="${{ steps.version.outputs.version }}"
RELEASE_NOTES=$(cat /tmp/release_notes.md)
# Create the release
echo "Creating release for $VERSION..."
RELEASE_ID=$(curl -X POST -s \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: application/json" \
"https://code.foss.global/api/v1/repos/serve.zone/mailer/releases" \
-d "{
\"tag_name\": \"$VERSION\",
\"name\": \"MAILER $VERSION\",
\"body\": $(jq -Rs . /tmp/release_notes.md),
\"draft\": false,
\"prerelease\": false
}" | jq -r '.id')
echo "Release created with ID: $RELEASE_ID"
# Upload binaries as release assets
for binary in dist/binaries/*; do
filename=$(basename "$binary")
echo "Uploading $filename..."
curl -X POST -s \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: application/octet-stream" \
--data-binary "@$binary" \
"https://code.foss.global/api/v1/repos/serve.zone/mailer/releases/$RELEASE_ID/assets?name=$filename"
done
echo "All assets uploaded successfully"
- name: Clean up old releases
run: |
echo "Cleaning up old releases (keeping only last 3)..."
# Fetch all releases sorted by creation date
RELEASES=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://code.foss.global/api/v1/repos/serve.zone/mailer/releases" | \
jq -r 'sort_by(.created_at) | reverse | .[3:] | .[].id')
# Delete old releases
if [ -n "$RELEASES" ]; then
echo "Found releases to delete:"
for release_id in $RELEASES; do
echo " Deleting release ID: $release_id"
curl -X DELETE -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://code.foss.global/api/v1/repos/serve.zone/mailer/releases/$release_id"
done
echo "Old releases deleted successfully"
else
echo "No old releases to delete (less than 4 releases total)"
fi
echo ""
- name: Release Summary
run: |
echo "================================================"
echo " Release ${{ steps.version.outputs.version }} Complete!"
echo "================================================"
echo ""
echo "Binaries published:"
ls -lh dist/binaries/
echo ""
echo "Release URL:"
echo "https://code.foss.global/serve.zone/mailer/releases/tag/${{ steps.version.outputs.version }}"
echo ""
echo "Installation command:"
echo "curl -sSL https://code.foss.global/serve.zone/mailer/raw/branch/main/install.sh | sudo bash"
echo ""

View File

@@ -1,5 +1,33 @@
# Changelog
## 2025-10-24 - 1.2.1 - fix(mail/delivery)
Centralize runtime/plugin imports and switch modules to use plugins exports; unify EventEmitter usage; update Deno dependencies and small path/server refactors
- Centralized Node and third-party imports in ts/plugins.ts and re-exported commonly used utilities (net, tls, dns, fs, smartfile, smartdns, smartmail, mailauth, uuid, ip, LRUCache, etc).
- Replaced direct EventEmitter / Node built-in imports with plugins.EventEmitter across delivery, smtpclient, routing and the unified email server to standardize runtime integration.
- Updated deno.json dependency map: added @push.rocks/smartfile, @push.rocks/smartdns, @tsclass/tsclass and ip; reordered lru-cache entry.
- Stopped exporting ./dns/index.ts from ts/index.ts (DNS is available via mail/routing) to avoid duplicate exports.
- Added keysDir alias and dnsRecordsDir in ts/paths.ts and small path-related fixes.
- Added a placeholder SmtpServer and other minor delivery/smtpserver refactors and sanitizations.
- Added a local .claude/settings.local.json for development permissions (local-only configuration).
## 2025-10-24 - 1.2.0 - feat(plugins)
Add smartmail, mailauth and uuid to Deno dependencies and export them from plugins; include local dev permissions file
- Add @push.rocks/smartmail, mailauth and uuid to deno.json dependencies so email parsing, DKIM and UUID utilities are available.
- Export smartmail, mailauth and uuid from ts/plugins.ts for centralized access across the codebase.
- Add .claude/settings.local.json to define local development permissions (tooling/dev environment configuration).
## 2025-10-24 - 1.1.0 - feat(ci)
Add CI, release and npm-publish automation; introduce release template and local settings
- Add CI workflow (.gitea/workflows/ci.yml) to run TypeScript checks, linting, formatting and platform compilation tests
- Add release workflow (.gitea/workflows/release.yml) to compile binaries for multiple platforms, generate checksums, create/update Gitea releases and upload assets
- Add npm publish workflow (.gitea/workflows/npm-publish.yml) to build package from a tag and publish precompiled binaries to npm (tag-triggered)
- Add a Gitea release template (.gitea/release-template.md) describing platforms, checksums and installation options
- Add local tool permission settings (.claude/settings.local.json) used by local tooling
- No API or runtime source changes — this commit is focused on CI/CD, release automation and packaging
## 2025-10-24 - 1.0.1 - fix(dev)
Add local development settings file to grant tooling permissions

View File

@@ -1,6 +1,6 @@
{
"name": "@serve.zone/mailer",
"version": "1.0.1",
"version": "1.2.1",
"exports": "./mod.ts",
"nodeModulesDir": "auto",
"tasks": {
@@ -41,7 +41,13 @@
"@std/crypto": "jsr:@std/crypto@^1.0.0",
"@std/assert": "jsr:@std/assert@^1.0.0",
"@apiclient.xyz/cloudflare": "npm:@apiclient.xyz/cloudflare@latest",
"@push.rocks/smartfile": "npm:@push.rocks/smartfile@latest",
"@push.rocks/smartdns": "npm:@push.rocks/smartdns@latest",
"@push.rocks/smartmail": "npm:@push.rocks/smartmail@^2.0.0",
"@tsclass/tsclass": "npm:@tsclass/tsclass@latest",
"lru-cache": "npm:lru-cache@^11.0.0",
"mailaddress-validator": "npm:mailaddress-validator@^1.0.11"
"mailauth": "npm:mailauth@^4.0.0",
"uuid": "npm:uuid@^9.0.0",
"ip": "npm:ip@^2.0.0"
}
}

View File

@@ -1,6 +1,6 @@
{
"name": "@serve.zone/mailer",
"version": "1.0.1",
"version": "1.2.1",
"description": "Enterprise mail server with SMTP, HTTP API, and DNS management - built for serve.zone infrastructure",
"keywords": [
"mailer",

View File

@@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@serve.zone/mailer',
version: '1.0.1',
version: '1.2.1',
description: 'Enterprise mail server with SMTP, HTTP API, and DNS management - built for serve.zone infrastructure'
}

View File

@@ -8,5 +8,6 @@ export * from './mail/core/index.ts';
export * from './mail/delivery/index.ts';
export * from './mail/routing/index.ts';
export * from './api/index.ts';
export * from './dns/index.ts';
export * from './config/index.ts';
// DNS exports are included in mail/routing, so we skip './dns/index.ts' to avoid duplication

View File

@@ -1,7 +1,4 @@
import * as plugins from '../../plugins.ts';
import { EventEmitter } from 'node:events';
import * as fs from 'node:fs';
import * as path from 'node:path';
import { logger } from '../../logger.ts';
import { type EmailProcessingMode } from '../routing/classes.email.config.ts';
import type { IEmailRoute } from '../routing/interfaces.ts';
@@ -74,7 +71,7 @@ export interface IQueueStats {
/**
* A unified queue for all email modes
*/
export class UnifiedDeliveryQueue extends EventEmitter {
export class UnifiedDeliveryQueue extends plugins.EventEmitter {
private options: Required<IQueueOptions>;
private queue: Map<string, IQueueItem> = new Map();
private checkTimer?: NodeJS.Timeout;

View File

@@ -1,7 +1,4 @@
import * as plugins from '../../plugins.ts';
import { EventEmitter } from 'node:events';
import * as net from 'node:net';
import * as tls from 'node:tls';
import { logger } from '../../logger.ts';
import {
SecurityLogger,
@@ -100,7 +97,7 @@ export interface IDeliveryStats {
/**
* Handles delivery for all email processing modes
*/
export class MultiModeDeliverySystem extends EventEmitter {
export class MultiModeDeliverySystem extends plugins.EventEmitter {
private queue: UnifiedDeliveryQueue;
private options: Required<IMultiModeDeliveryOptions>;
private stats: IDeliveryStats;

View File

@@ -1,5 +1,4 @@
import * as plugins from '../../plugins.ts';
import { EventEmitter } from 'node:events';
import { logger } from '../../logger.ts';
import { SecurityLogger, SecurityLogLevel, SecurityEventType } from '../../security/index.ts';
@@ -84,7 +83,7 @@ export interface IRateLimitResult {
/**
* Unified rate limiter for all email processing modes
*/
export class UnifiedRateLimiter extends EventEmitter {
export class UnifiedRateLimiter extends plugins.EventEmitter {
private config: IHierarchicalRateLimits;
private counters: Map<string, ILimitCounter> = new Map();
private patternCounters: Map<string, ILimitCounter> = new Map();

View File

@@ -0,0 +1,14 @@
/**
* Placeholder delivery implementation
* This will be replaced with actual delivery logic
*/
export class DeliveryPlaceholder {
// Placeholder for delivery functionality
}
export class SmtpServer {
// Placeholder SMTP server
async start() {}
async stop() {}
}

View File

@@ -3,7 +3,7 @@
* SMTP command sending and response parsing
*/
import { EventEmitter } from 'node:events';
import * as plugins from '../../../plugins.ts';
import { SMTP_COMMANDS, SMTP_CODES, LINE_ENDINGS } from './constants.ts';
import type {
ISmtpConnection,
@@ -19,7 +19,7 @@ import {
} from './utils/helpers.ts';
import { logCommand, logDebug } from './utils/logging.ts';
export class CommandHandler extends EventEmitter {
export class CommandHandler extends plugins.EventEmitter {
private options: ISmtpClientOptions;
private responseBuffer: string = '';
private pendingCommand: { resolve: Function; reject: Function; command: string } | null = null;

View File

@@ -3,20 +3,18 @@
* Connection pooling and lifecycle management
*/
import * as net from 'node:net';
import * as tls from 'node:tls';
import { EventEmitter } from 'node:events';
import * as plugins from '../../../plugins.ts';
import { DEFAULTS, CONNECTION_STATES } from './constants.ts';
import type {
ISmtpClientOptions,
ISmtpConnection,
import type {
ISmtpClientOptions,
ISmtpConnection,
IConnectionPoolStatus,
ConnectionState
ConnectionState
} from './interfaces.ts';
import { logConnection, logDebug } from './utils/logging.ts';
import { generateConnectionId } from './utils/helpers.ts';
export class ConnectionManager extends EventEmitter {
export class ConnectionManager extends plugins.EventEmitter {
private options: ISmtpClientOptions;
private connections: Map<string, ISmtpConnection> = new Map();
private pendingConnections: Set<string> = new Set();

View File

@@ -3,7 +3,7 @@
* Main client class with delegation to handlers
*/
import { EventEmitter } from 'node:events';
import * as plugins from '../../../plugins.ts';
import type { Email } from '../../core/classes.email.ts';
import type {
ISmtpClientOptions,
@@ -30,7 +30,7 @@ interface ISmtpClientDependencies {
errorHandler: SmtpErrorHandler;
}
export class SmtpClient extends EventEmitter {
export class SmtpClient extends plugins.EventEmitter {
private options: ISmtpClientOptions;
private connectionManager: ConnectionManager;
private commandHandler: CommandHandler;

View File

@@ -3,17 +3,16 @@
* Provides utilities for managing TLS certificates
*/
import * as fs from 'fs';
import * as tls from 'tls';
import * as plugins from '../../../plugins.ts';
import { SmtpLogger } from './utils/logging.ts';
/**
* Certificate data
*/
export interface ICertificateData {
key: Buffer;
cert: Buffer;
ca?: Buffer;
key: plugins.Buffer;
cert: plugins.Buffer;
ca?: plugins.Buffer;
}
/**
@@ -155,7 +154,7 @@ export function loadCertificatesFromString(options: {
const caBuffer = caStr ? Buffer.from(caStr, 'utf8') : undefined;
// Test the certificates first
const secureContext = tls.createSecureContext({
const secureContext = plugins.tls.createSecureContext({
key: keyBuffer,
cert: certBuffer,
ca: caBuffer
@@ -206,7 +205,7 @@ export function loadCertificatesFromString(options: {
// Validate the certificates by attempting to create a secure context
try {
const secureContext = tls.createSecureContext({
const secureContext = plugins.tls.createSecureContext({
key: keyBuffer,
cert: certBuffer,
ca: caBuffer
@@ -253,9 +252,9 @@ export function loadCertificatesFromFiles(options: {
}): ICertificateData {
try {
// Read files directly as Buffers
const key = fs.readFileSync(options.keyPath);
const cert = fs.readFileSync(options.certPath);
const ca = options.caPath ? fs.readFileSync(options.caPath) : undefined;
const key = plugins.fs.readFileSync(options.keyPath);
const cert = plugins.fs.readFileSync(options.certPath);
const ca = options.caPath ? plugins.fs.readFileSync(options.caPath) : undefined;
// Log for debugging
SmtpLogger.debug('Certificate file properties', {
@@ -266,7 +265,7 @@ export function loadCertificatesFromFiles(options: {
// Validate the certificates by attempting to create a secure context
try {
const secureContext = tls.createSecureContext({
const secureContext = plugins.tls.createSecureContext({
key,
cert,
ca
@@ -364,8 +363,8 @@ ORWZbz+8rBL0JIeA7eFxEA==
export function createTlsOptions(
certificates: ICertificateData,
isServer: boolean = true
): tls.TlsOptions {
const options: tls.TlsOptions = {
): plugins.tls.TlsOptions {
const options: plugins.tls.TlsOptions = {
key: certificates.key,
cert: certificates.cert,
ca: certificates.ca,

View File

@@ -4,8 +4,6 @@
*/
import * as plugins from '../../../plugins.ts';
import * as fs from 'fs';
import * as path from 'path';
import { SmtpState } from './interfaces.ts';
import type { ISmtpSession, ISmtpTransactionResult } from './interfaces.ts';
import type { IDataHandler, ISmtpServer } from './interfaces.ts';

View File

@@ -1,12 +1,11 @@
import * as plugins from '../../plugins.ts';
import { EventEmitter } from 'node:events';
import type { IEmailRoute, IEmailMatch, IEmailAction, IEmailContext } from './interfaces.ts';
import type { Email } from '../core/classes.email.ts';
/**
* Email router that evaluates routes and determines actions
*/
export class EmailRouter extends EventEmitter {
export class EmailRouter extends plugins.EventEmitter {
private routes: IEmailRoute[];
private patternCache: Map<string, boolean> = new Map();
private storageManager?: any; // StorageManager instance

View File

@@ -1,6 +1,5 @@
import * as plugins from '../../plugins.ts';
import * as paths from '../../paths.ts';
import { EventEmitter } from 'events';
import { logger } from '../../logger.ts';
import {
SecurityLogger,
@@ -154,7 +153,7 @@ export interface IServerStats {
/**
* Unified email server that handles all email traffic with pattern-based routing
*/
export class UnifiedEmailServer extends EventEmitter {
export class UnifiedEmailServer extends plugins.EventEmitter {
private dcRouter: DcRouter;
private options: IUnifiedEmailServerOptions;
private emailRouter: EmailRouter;

View File

@@ -19,3 +19,9 @@ export const logsDir = plugins.path.join(configDir, 'logs');
// DKIM keys directory
export const dkimKeysDir = plugins.path.join(configDir, 'dkim-keys');
// Keys directory (alias for compatibility)
export const keysDir = dkimKeysDir;
// DNS records directory
export const dnsRecordsDir = plugins.path.join(configDir, 'dns-records');

View File

@@ -10,12 +10,7 @@ export * as cli from '@std/cli';
export { serveDir } from '@std/http/file-server';
export * as crypto from '@std/crypto';
// Cloudflare API client
import * as cloudflareImport from '@apiclient.xyz/cloudflare';
export const cloudflare = cloudflareImport;
// Node.js compatibility - needed for SMTP and email processing
// We import these as npm: specifiers for Node.js modules that don't have Deno equivalents
// Node.js built-in modules (needed for SMTP and email processing)
import { EventEmitter } from 'node:events';
import * as net from 'node:net';
import * as tls from 'node:tls';
@@ -24,9 +19,32 @@ import * as fs from 'node:fs';
import * as os from 'node:os';
import * as process from 'node:process';
import * as buffer from 'node:buffer';
import * as util from 'node:util';
export { EventEmitter };
export { net, tls, dns, fs, os, process, buffer };
// Re-export Buffer for convenience
export { EventEmitter, net, tls, dns, fs, os, process, buffer, util };
export const Buffer = buffer.Buffer;
// Cloudflare API client
import * as cloudflareImport from '@apiclient.xyz/cloudflare';
export const cloudflare = cloudflareImport;
// @push.rocks packages
import * as smartfile from '@push.rocks/smartfile';
import * as smartdns from '@push.rocks/smartdns';
import * as smartmail from '@push.rocks/smartmail';
export { smartfile, smartdns, smartmail };
// @tsclass packages
import * as tsclass from '@tsclass/tsclass';
export { tsclass };
// Third-party libraries
import * as mailauth from 'mailauth';
import { dkimSign } from 'mailauth/lib/dkim/sign.js';
import * as uuid from 'uuid';
import * as ip from 'ip';
import { LRUCache } from 'lru-cache';
export { mailauth, dkimSign, uuid, ip, LRUCache };

View File

@@ -0,0 +1,23 @@
/**
* IP Reputation Checker
* Checks IP addresses against reputation databases
*/
export interface IIpReputationResult {
ip: string;
score: number;
isBlacklisted: boolean;
sources: string[];
}
export class IpReputationChecker {
public async checkReputation(ip: string): Promise<IIpReputationResult> {
// Placeholder implementation
return {
ip,
score: 100,
isBlacklisted: false,
sources: [],
};
}
}