@bernierllc/email-mitm-masking 1.6.9 → 1.6.10

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bernierllc/email-mitm-masking",
3
- "version": "1.6.9",
3
+ "version": "1.6.10",
4
4
  "description": "Email masking and man-in-the-middle routing service for privacy-focused email communication",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -22,11 +22,11 @@
22
22
  "license": "SEE LICENSE IN LICENSE",
23
23
  "dependencies": {
24
24
  "pg": "^8.11.0",
25
+ "@bernierllc/crypto-utils": "^1.4.0",
25
26
  "@bernierllc/email-sender": "^5.13.0",
26
27
  "@bernierllc/email-parser": "^0.7.0",
27
- "@bernierllc/logger": "^1.7.1",
28
- "@bernierllc/neverhub-adapter": "^0.4.1",
29
- "@bernierllc/crypto-utils": "^1.4.0"
28
+ "@bernierllc/logger": "^2.0.0",
29
+ "@bernierllc/neverhub-adapter": "^0.4.1"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@types/jest": "^29.0.0",
@@ -1,90 +0,0 @@
1
- import type { EmailMaskingConfig, ProxyAddress, RoutingResult, CreateProxyOptions } from './types.js';
2
- /**
3
- * Email masking and man-in-the-middle routing service
4
- */
5
- export declare class EmailMaskingService {
6
- private config;
7
- private db;
8
- private cleanupInterval?;
9
- constructor(config: EmailMaskingConfig);
10
- /**
11
- * Initialize the masking service
12
- */
13
- initialize(): Promise<void>;
14
- /**
15
- * Cleanup resources
16
- */
17
- shutdown(): Promise<void>;
18
- /**
19
- * Create a new proxy email address
20
- */
21
- createProxy(userId: string, realEmail: string, options?: CreateProxyOptions): Promise<ProxyAddress>;
22
- /**
23
- * Route inbound email (external → real address)
24
- */
25
- routeInbound(from: string, to: string, _subject: string, _text?: string, _html?: string): Promise<RoutingResult>;
26
- /**
27
- * Route outbound email (real address → external via proxy)
28
- */
29
- routeOutbound(userId: string, realEmail: string, externalEmail: string, _emailContent: {
30
- subject: string;
31
- text?: string;
32
- html?: string;
33
- }): Promise<RoutingResult>;
34
- /**
35
- * Deactivate a proxy address
36
- */
37
- deactivateProxy(proxyId: string): Promise<void>;
38
- /**
39
- * Revoke a proxy address permanently
40
- */
41
- revokeProxy(proxyId: string): Promise<void>;
42
- /**
43
- * Get proxy by ID
44
- */
45
- getProxyById(proxyId: string): Promise<ProxyAddress | null>;
46
- /**
47
- * Get proxy by email address
48
- */
49
- private getProxyByEmail;
50
- /**
51
- * Get proxy for specific user-contact pair
52
- */
53
- private getProxyForContact;
54
- /**
55
- * Update proxy usage statistics
56
- */
57
- private updateProxyUsage;
58
- /**
59
- * Audit a routing decision
60
- */
61
- private auditRouting;
62
- /**
63
- * Map database row to ProxyAddress
64
- */
65
- private mapProxyRow;
66
- /**
67
- * Get user's proxy count
68
- */
69
- private getUserProxyCount;
70
- /**
71
- * Expire a proxy
72
- */
73
- private expireProxy;
74
- /**
75
- * Start cleanup job for expired proxies
76
- */
77
- private startCleanupJob;
78
- /**
79
- * Cleanup expired proxies
80
- */
81
- private cleanupExpiredProxies;
82
- /**
83
- * Extract proxy address from To field
84
- */
85
- private extractProxyAddress;
86
- /**
87
- * Generate secure proxy token
88
- */
89
- private generateProxyToken;
90
- }
@@ -1,319 +0,0 @@
1
- "use strict";
2
- /*
3
- Copyright (c) 2025 Bernier LLC
4
-
5
- This file is licensed to the client under a limited-use license.
6
- The client may use and modify this code *only within the scope of the project it was delivered for*.
7
- Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.EmailMaskingService = void 0;
11
- const pg_1 = require("pg");
12
- const database_js_1 = require("./database.js");
13
- /**
14
- * Email masking and man-in-the-middle routing service
15
- */
16
- class EmailMaskingService {
17
- config;
18
- db;
19
- cleanupInterval;
20
- constructor(config) {
21
- this.config = config;
22
- this.db = new pg_1.Pool({
23
- host: config.database.host,
24
- port: config.database.port,
25
- database: config.database.database,
26
- user: config.database.user,
27
- password: config.database.password,
28
- });
29
- }
30
- /**
31
- * Initialize the masking service
32
- */
33
- async initialize() {
34
- // Initialize database schema
35
- await (0, database_js_1.initializeDatabase)(this.db);
36
- // Start cleanup job for expired proxies
37
- this.startCleanupJob();
38
- }
39
- /**
40
- * Cleanup resources
41
- */
42
- async shutdown() {
43
- if (this.cleanupInterval) {
44
- clearInterval(this.cleanupInterval);
45
- }
46
- await this.db.end();
47
- }
48
- /**
49
- * Create a new proxy email address
50
- */
51
- async createProxy(userId, realEmail, options) {
52
- // Validate user's proxy quota
53
- const userProxies = await this.getUserProxyCount(userId);
54
- const maxProxies = this.config.maxProxiesPerUser || 0;
55
- if (maxProxies > 0 && userProxies >= maxProxies) {
56
- throw new Error(`User ${userId} has reached maximum proxy limit (${maxProxies})`);
57
- }
58
- // Generate secure proxy token
59
- const proxyToken = this.generateProxyToken();
60
- const proxyEmail = `${userId}-${proxyToken}@${this.config.proxyDomain}`;
61
- // Calculate expiration
62
- const ttl = options?.ttlDays !== undefined ? options.ttlDays : (this.config.defaultTTL || 0);
63
- const expiresAt = ttl !== 0
64
- ? new Date(Date.now() + ttl * 24 * 60 * 60 * 1000)
65
- : null;
66
- // Insert proxy record
67
- const result = await this.db.query(`INSERT INTO proxy_addresses
68
- (proxy_email, real_email, user_id, external_email, conversation_id, status, expires_at, metadata)
69
- VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
70
- RETURNING *`, [
71
- proxyEmail,
72
- realEmail,
73
- userId,
74
- options?.externalEmail || null,
75
- options?.conversationId || null,
76
- 'active',
77
- expiresAt,
78
- JSON.stringify(options?.metadata || {})
79
- ]);
80
- return this.mapProxyRow(result.rows[0]);
81
- }
82
- /**
83
- * Route inbound email (external → real address)
84
- */
85
- async routeInbound(from, to, _subject, _text, _html) {
86
- const toAddress = this.extractProxyAddress(to);
87
- if (!toAddress) {
88
- return {
89
- success: false,
90
- direction: 'inbound',
91
- error: 'No proxy address found in To field'
92
- };
93
- }
94
- // Look up proxy
95
- const proxy = await this.getProxyByEmail(toAddress);
96
- if (!proxy) {
97
- return {
98
- success: false,
99
- direction: 'inbound',
100
- error: `Proxy address not found: ${toAddress}`
101
- };
102
- }
103
- // Validate proxy status
104
- if (proxy.status !== 'active') {
105
- return {
106
- success: false,
107
- direction: 'inbound',
108
- error: `Proxy is ${proxy.status}: ${toAddress}`
109
- };
110
- }
111
- // Check expiration
112
- if (proxy.expiresAt && proxy.expiresAt < new Date()) {
113
- await this.expireProxy(proxy.id);
114
- return {
115
- success: false,
116
- direction: 'inbound',
117
- error: `Proxy expired: ${toAddress}`
118
- };
119
- }
120
- // Update proxy usage
121
- await this.updateProxyUsage(proxy.id);
122
- // Audit the routing
123
- const auditId = await this.auditRouting({
124
- proxyId: proxy.id,
125
- direction: 'inbound',
126
- fromAddress: from,
127
- toAddress: proxy.realEmail,
128
- success: true
129
- });
130
- return {
131
- success: true,
132
- routedTo: proxy.realEmail,
133
- proxyUsed: toAddress,
134
- direction: 'inbound',
135
- auditId
136
- };
137
- }
138
- /**
139
- * Route outbound email (real address → external via proxy)
140
- */
141
- async routeOutbound(userId, realEmail, externalEmail, _emailContent) {
142
- // Find or create proxy for this user-external pair
143
- let proxy = await this.getProxyForContact(userId, realEmail, externalEmail);
144
- if (!proxy) {
145
- // Auto-create proxy for outbound routing
146
- proxy = await this.createProxy(userId, realEmail, {
147
- externalEmail,
148
- metadata: { autoCreated: true, direction: 'outbound' }
149
- });
150
- }
151
- // Validate proxy status
152
- if (proxy.status !== 'active') {
153
- return {
154
- success: false,
155
- direction: 'outbound',
156
- error: `Proxy is ${proxy.status}`
157
- };
158
- }
159
- // Update proxy usage
160
- await this.updateProxyUsage(proxy.id);
161
- // Audit the routing
162
- const auditId = await this.auditRouting({
163
- proxyId: proxy.id,
164
- direction: 'outbound',
165
- fromAddress: realEmail,
166
- toAddress: externalEmail,
167
- success: true
168
- });
169
- return {
170
- success: true,
171
- routedTo: externalEmail,
172
- proxyUsed: proxy.proxyEmail,
173
- direction: 'outbound',
174
- auditId
175
- };
176
- }
177
- /**
178
- * Deactivate a proxy address
179
- */
180
- async deactivateProxy(proxyId) {
181
- await this.db.query('UPDATE proxy_addresses SET status = $1 WHERE id = $2', ['inactive', proxyId]);
182
- }
183
- /**
184
- * Revoke a proxy address permanently
185
- */
186
- async revokeProxy(proxyId) {
187
- await this.db.query('UPDATE proxy_addresses SET status = $1 WHERE id = $2', ['revoked', proxyId]);
188
- }
189
- /**
190
- * Get proxy by ID
191
- */
192
- async getProxyById(proxyId) {
193
- const result = await this.db.query('SELECT * FROM proxy_addresses WHERE id = $1', [proxyId]);
194
- return result.rows.length > 0 ? this.mapProxyRow(result.rows[0]) : null;
195
- }
196
- /**
197
- * Get proxy by email address
198
- */
199
- async getProxyByEmail(proxyEmail) {
200
- const result = await this.db.query('SELECT * FROM proxy_addresses WHERE proxy_email = $1', [proxyEmail]);
201
- return result.rows.length > 0 ? this.mapProxyRow(result.rows[0]) : null;
202
- }
203
- /**
204
- * Get proxy for specific user-contact pair
205
- */
206
- async getProxyForContact(userId, realEmail, externalEmail) {
207
- const result = await this.db.query(`SELECT * FROM proxy_addresses
208
- WHERE user_id = $1
209
- AND real_email = $2
210
- AND external_email = $3
211
- ORDER BY created_at DESC
212
- LIMIT 1`, [userId, realEmail, externalEmail]);
213
- return result.rows.length > 0 ? this.mapProxyRow(result.rows[0]) : null;
214
- }
215
- /**
216
- * Update proxy usage statistics
217
- */
218
- async updateProxyUsage(proxyId) {
219
- await this.db.query(`UPDATE proxy_addresses
220
- SET routing_count = routing_count + 1, last_used_at = NOW()
221
- WHERE id = $1`, [proxyId]);
222
- }
223
- /**
224
- * Audit a routing decision
225
- */
226
- async auditRouting(audit) {
227
- if (!this.config.auditEnabled) {
228
- return '';
229
- }
230
- const result = await this.db.query(`INSERT INTO routing_audit
231
- (proxy_id, direction, from_address, to_address, success, error, metadata)
232
- VALUES ($1, $2, $3, $4, $5, $6, $7)
233
- RETURNING id`, [
234
- audit.proxyId,
235
- audit.direction,
236
- audit.fromAddress,
237
- audit.toAddress,
238
- audit.success,
239
- audit.error || null,
240
- JSON.stringify(audit.metadata || {})
241
- ]);
242
- return result.rows[0].id;
243
- }
244
- /**
245
- * Map database row to ProxyAddress
246
- */
247
- mapProxyRow(row) {
248
- return {
249
- id: row.id,
250
- proxyEmail: row.proxy_email,
251
- realEmail: row.real_email,
252
- userId: row.user_id,
253
- externalEmail: row.external_email || undefined,
254
- conversationId: row.conversation_id || undefined,
255
- status: row.status,
256
- createdAt: new Date(row.created_at),
257
- activatedAt: row.activated_at ? new Date(row.activated_at) : undefined,
258
- expiresAt: row.expires_at ? new Date(row.expires_at) : undefined,
259
- lastUsedAt: row.last_used_at ? new Date(row.last_used_at) : undefined,
260
- routingCount: parseInt(row.routing_count) || 0,
261
- metadata: row.metadata ? JSON.parse(row.metadata) : {}
262
- };
263
- }
264
- /**
265
- * Get user's proxy count
266
- */
267
- async getUserProxyCount(userId) {
268
- const result = await this.db.query(`SELECT COUNT(*) as count FROM proxy_addresses
269
- WHERE user_id = $1 AND status = 'active'`, [userId]);
270
- return parseInt(result.rows[0].count) || 0;
271
- }
272
- /**
273
- * Expire a proxy
274
- */
275
- async expireProxy(proxyId) {
276
- await this.db.query('UPDATE proxy_addresses SET status = $1 WHERE id = $2', ['expired', proxyId]);
277
- }
278
- /**
279
- * Start cleanup job for expired proxies
280
- */
281
- startCleanupJob() {
282
- // Run every hour
283
- this.cleanupInterval = setInterval(() => {
284
- void this.cleanupExpiredProxies();
285
- }, 60 * 60 * 1000); // 1 hour
286
- }
287
- /**
288
- * Cleanup expired proxies
289
- */
290
- async cleanupExpiredProxies() {
291
- await this.db.query(`UPDATE proxy_addresses
292
- SET status = 'expired'
293
- WHERE expires_at < NOW() AND status = 'active'`);
294
- }
295
- /**
296
- * Extract proxy address from To field
297
- */
298
- extractProxyAddress(to) {
299
- const proxyDomain = this.config.proxyDomain;
300
- if (to.includes(`@${proxyDomain}`)) {
301
- // Extract email from "Name <email>" format
302
- const match = to.match(/<(.+?)>/) || [null, to];
303
- return match[1];
304
- }
305
- return null;
306
- }
307
- /**
308
- * Generate secure proxy token
309
- */
310
- generateProxyToken() {
311
- const chars = 'abcdefghijklmnopqrstuvwxyz0123456789';
312
- let token = '';
313
- for (let i = 0; i < 16; i++) {
314
- token += chars.charAt(Math.floor(Math.random() * chars.length));
315
- }
316
- return token;
317
- }
318
- }
319
- exports.EmailMaskingService = EmailMaskingService;
@@ -1,5 +0,0 @@
1
- import { Pool } from 'pg';
2
- /**
3
- * Initialize database schema for email masking
4
- */
5
- export declare function initializeDatabase(pool: Pool): Promise<void>;
package/dist/database.js DELETED
@@ -1,69 +0,0 @@
1
- "use strict";
2
- /*
3
- Copyright (c) 2025 Bernier LLC
4
-
5
- This file is licensed to the client under a limited-use license.
6
- The client may use and modify this code *only within the scope of the project it was delivered for*.
7
- Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.initializeDatabase = initializeDatabase;
11
- /**
12
- * Initialize database schema for email masking
13
- */
14
- async function initializeDatabase(pool) {
15
- await pool.query(`
16
- CREATE TABLE IF NOT EXISTS proxy_addresses (
17
- id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
18
- proxy_email TEXT UNIQUE NOT NULL,
19
- real_email TEXT NOT NULL,
20
- user_id TEXT NOT NULL,
21
- external_email TEXT,
22
- conversation_id TEXT,
23
- status TEXT NOT NULL DEFAULT 'active',
24
- created_at TIMESTAMP NOT NULL DEFAULT NOW(),
25
- activated_at TIMESTAMP,
26
- expires_at TIMESTAMP,
27
- last_used_at TIMESTAMP,
28
- routing_count INTEGER NOT NULL DEFAULT 0,
29
- metadata JSONB
30
- );
31
-
32
- CREATE INDEX IF NOT EXISTS idx_proxy_email ON proxy_addresses(proxy_email);
33
- CREATE INDEX IF NOT EXISTS idx_user_id ON proxy_addresses(user_id);
34
- CREATE INDEX IF NOT EXISTS idx_real_email ON proxy_addresses(real_email);
35
- CREATE INDEX IF NOT EXISTS idx_status ON proxy_addresses(status);
36
- CREATE INDEX IF NOT EXISTS idx_expires_at ON proxy_addresses(expires_at) WHERE status = 'active';
37
-
38
- CREATE TABLE IF NOT EXISTS routing_audit (
39
- id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
40
- proxy_id UUID NOT NULL,
41
- direction TEXT NOT NULL,
42
- from_address TEXT NOT NULL,
43
- to_address TEXT NOT NULL,
44
- routed_at TIMESTAMP NOT NULL DEFAULT NOW(),
45
- success BOOLEAN NOT NULL,
46
- error TEXT,
47
- metadata JSONB
48
- );
49
-
50
- CREATE INDEX IF NOT EXISTS idx_audit_proxy_id ON routing_audit(proxy_id);
51
- CREATE INDEX IF NOT EXISTS idx_routed_at ON routing_audit(routed_at);
52
- CREATE INDEX IF NOT EXISTS idx_direction ON routing_audit(direction);
53
-
54
- CREATE TABLE IF NOT EXISTS masking_rules (
55
- id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
56
- user_id TEXT NOT NULL,
57
- type TEXT NOT NULL,
58
- criteria TEXT NOT NULL,
59
- action TEXT NOT NULL,
60
- priority INTEGER NOT NULL DEFAULT 0,
61
- enabled BOOLEAN NOT NULL DEFAULT true,
62
- created_at TIMESTAMP NOT NULL DEFAULT NOW()
63
- );
64
-
65
- CREATE INDEX IF NOT EXISTS idx_rules_user_id ON masking_rules(user_id);
66
- CREATE INDEX IF NOT EXISTS idx_priority ON masking_rules(priority);
67
- CREATE INDEX IF NOT EXISTS idx_enabled ON masking_rules(enabled);
68
- `);
69
- }
package/dist/errors.d.ts DELETED
@@ -1,11 +0,0 @@
1
- export type EmailMitmMaskingErrorCode = 'EMAIL_MITM_MASKING_ERROR' | 'INVALID_INPUT' | 'OPERATION_FAILED';
2
- export interface EmailMitmMaskingErrorOptions {
3
- cause?: Error;
4
- code?: EmailMitmMaskingErrorCode;
5
- context?: Record<string, unknown>;
6
- }
7
- export declare class EmailMitmMaskingError extends Error {
8
- readonly code: EmailMitmMaskingErrorCode;
9
- readonly context?: Record<string, unknown>;
10
- constructor(message: string, options?: EmailMitmMaskingErrorOptions);
11
- }
package/dist/errors.js DELETED
@@ -1,24 +0,0 @@
1
- "use strict";
2
- /*
3
- Copyright (c) 2025 Bernier LLC
4
-
5
- This file is licensed to the client under a limited-use license.
6
- The client may use and modify this code *only within the scope of the project it was delivered for*.
7
- Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.EmailMitmMaskingError = void 0;
11
- class EmailMitmMaskingError extends Error {
12
- code;
13
- context;
14
- constructor(message, options) {
15
- super(message, options?.cause ? { cause: options.cause } : undefined);
16
- this.name = 'EmailMitmMaskingError';
17
- this.code = options?.code ?? 'EMAIL_MITM_MASKING_ERROR';
18
- if (options?.context !== undefined) {
19
- this.context = options.context;
20
- }
21
- Error.captureStackTrace?.(this, this.constructor);
22
- }
23
- }
24
- exports.EmailMitmMaskingError = EmailMitmMaskingError;
package/dist/index.d.ts DELETED
@@ -1,3 +0,0 @@
1
- export { EmailMaskingService } from './EmailMaskingService.js';
2
- export { EmailMitmMaskingError, type EmailMitmMaskingErrorCode, type EmailMitmMaskingErrorOptions } from './errors.js';
3
- export type { EmailMaskingConfig, DatabaseConfig, ProxyAddress, MaskingRule, RoutingResult, RoutingAudit, MaskingResult, CreateProxyOptions, EmailContent } from './types.js';
package/dist/index.js DELETED
@@ -1,14 +0,0 @@
1
- "use strict";
2
- /*
3
- Copyright (c) 2025 Bernier LLC
4
-
5
- This file is licensed to the client under a limited-use license.
6
- The client may use and modify this code *only within the scope of the project it was delivered for*.
7
- Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.EmailMitmMaskingError = exports.EmailMaskingService = void 0;
11
- var EmailMaskingService_js_1 = require("./EmailMaskingService.js");
12
- Object.defineProperty(exports, "EmailMaskingService", { enumerable: true, get: function () { return EmailMaskingService_js_1.EmailMaskingService; } });
13
- var errors_js_1 = require("./errors.js");
14
- Object.defineProperty(exports, "EmailMitmMaskingError", { enumerable: true, get: function () { return errors_js_1.EmailMitmMaskingError; } });
package/dist/types.d.ts DELETED
@@ -1,159 +0,0 @@
1
- /**
2
- * Configuration for email masking service
3
- */
4
- export interface EmailMaskingConfig {
5
- /** Proxy domain for masked addresses (e.g., proxy.example.com) */
6
- proxyDomain: string;
7
- /** Database connection for proxy storage */
8
- database: DatabaseConfig;
9
- /** Default TTL for proxy addresses (in days, 0 = unlimited) */
10
- defaultTTL?: number;
11
- /** Maximum proxies per user (0 = unlimited) */
12
- maxProxiesPerUser?: number;
13
- /** Enable audit logging */
14
- auditEnabled?: boolean;
15
- /** Masking strategy */
16
- strategy?: 'per-user' | 'per-contact' | 'per-conversation';
17
- }
18
- /**
19
- * Database configuration
20
- */
21
- export interface DatabaseConfig {
22
- host: string;
23
- port: number;
24
- database: string;
25
- user: string;
26
- password: string;
27
- }
28
- /**
29
- * Proxy email address record
30
- */
31
- export interface ProxyAddress {
32
- /** Unique proxy identifier */
33
- id: string;
34
- /** Proxy email address (e.g., user-abc123@proxy.domain.com) */
35
- proxyEmail: string;
36
- /** Real user email address */
37
- realEmail: string;
38
- /** User identifier */
39
- userId: string;
40
- /** Optional external contact email (for per-contact masking) */
41
- externalEmail?: string;
42
- /** Optional conversation identifier (for per-conversation masking) */
43
- conversationId?: string;
44
- /** Proxy status */
45
- status: 'active' | 'inactive' | 'expired' | 'revoked';
46
- /** Creation timestamp */
47
- createdAt: Date;
48
- /** Activation timestamp */
49
- activatedAt?: Date;
50
- /** Expiration timestamp (null = no expiration) */
51
- expiresAt?: Date;
52
- /** Last used timestamp */
53
- lastUsedAt?: Date;
54
- /** Routing count */
55
- routingCount: number;
56
- /** Metadata */
57
- metadata?: Record<string, unknown>;
58
- }
59
- /**
60
- * Masking rule configuration
61
- */
62
- export interface MaskingRule {
63
- /** Rule identifier */
64
- id: string;
65
- /** User identifier */
66
- userId: string;
67
- /** Rule type */
68
- type: 'domain' | 'address' | 'pattern';
69
- /** Match criteria */
70
- criteria: string;
71
- /** Action (mask or allow) */
72
- action: 'mask' | 'allow';
73
- /** Priority (higher = evaluated first) */
74
- priority: number;
75
- /** Enabled flag */
76
- enabled: boolean;
77
- }
78
- /**
79
- * Routing result
80
- */
81
- export interface RoutingResult {
82
- success: boolean;
83
- routedTo?: string;
84
- proxyUsed?: string;
85
- direction: 'inbound' | 'outbound';
86
- error?: string;
87
- auditId?: string;
88
- }
89
- /**
90
- * Audit entry
91
- */
92
- export interface RoutingAudit {
93
- id: string;
94
- proxyId: string;
95
- direction: 'inbound' | 'outbound';
96
- fromAddress: string;
97
- toAddress: string;
98
- routedAt: Date;
99
- success: boolean;
100
- error?: string;
101
- metadata?: Record<string, unknown>;
102
- }
103
- /**
104
- * Result wrapper for masking operations
105
- */
106
- export interface MaskingResult<T = unknown> {
107
- success: boolean;
108
- data?: T;
109
- error?: string;
110
- }
111
- /**
112
- * Options for creating a proxy
113
- */
114
- export interface CreateProxyOptions {
115
- externalEmail?: string;
116
- conversationId?: string;
117
- ttlDays?: number;
118
- metadata?: Record<string, unknown>;
119
- }
120
- /**
121
- * Email content for outbound routing
122
- */
123
- export interface EmailContent {
124
- subject: string;
125
- text?: string;
126
- html?: string;
127
- }
128
- /**
129
- * Database row type for proxy addresses
130
- */
131
- export interface ProxyAddressRow {
132
- id: string;
133
- proxy_email: string;
134
- real_email: string;
135
- user_id: string;
136
- external_email: string | null;
137
- conversation_id: string | null;
138
- status: string;
139
- created_at: string;
140
- activated_at: string | null;
141
- expires_at: string | null;
142
- last_used_at: string | null;
143
- routing_count: string;
144
- metadata: string | null;
145
- }
146
- /**
147
- * Database row type for routing audit
148
- */
149
- export interface RoutingAuditRow {
150
- id: string;
151
- proxy_id: string;
152
- direction: string;
153
- from_address: string;
154
- to_address: string;
155
- routed_at: string;
156
- success: boolean;
157
- error: string | null;
158
- metadata: string | null;
159
- }
package/dist/types.js DELETED
@@ -1,9 +0,0 @@
1
- "use strict";
2
- /*
3
- Copyright (c) 2025 Bernier LLC
4
-
5
- This file is licensed to the client under a limited-use license.
6
- The client may use and modify this code *only within the scope of the project it was delivered for*.
7
- Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });