@mikkelscheike/email-provider-links 1.0.0 โ†’ 1.2.0

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/README.md CHANGED
@@ -1,14 +1,20 @@
1
1
  # Email Provider Links
2
2
 
3
- A TypeScript package that provides direct links to email providers based on email addresses to streamline login and password reset flows.
3
+ ๐Ÿ”’ **Enterprise-grade secure email provider detection for login and password reset flows**
4
4
 
5
- ## Features
5
+ A TypeScript package that provides direct links to email providers based on email addresses, with comprehensive security features to prevent malicious redirects and supply chain attacks.
6
+
7
+ ## โœจ Features
6
8
 
7
9
  - ๐Ÿš€ **Fast & Lightweight**: Zero dependencies, minimal footprint
8
- - ๐Ÿ“ง **55+ Email Providers**: Gmail, Outlook, Yahoo, ProtonMail, and more
9
- - ๐Ÿข **Business Domain Detection**: DNS-based detection for custom domains
10
- - ๐Ÿ”’ **Type Safe**: Full TypeScript support
10
+ - ๐Ÿ“ง **64+ Email Providers**: Gmail, Outlook, Yahoo, ProtonMail, iCloud, and more
11
+ - ๐Ÿข **Business Domain Detection**: DNS-based detection for custom domains (Google Workspace, Microsoft 365, etc.)
12
+ - ๐Ÿ”’ **Enterprise Security**: Multi-layer protection against malicious URLs and supply chain attacks
13
+ - ๐Ÿ›ก๏ธ **URL Validation**: HTTPS-only enforcement with domain allowlisting
14
+ - ๐Ÿ” **Integrity Verification**: Cryptographic hash verification for data integrity
15
+ - ๐Ÿ“ **Type Safe**: Full TypeScript support with comprehensive interfaces
11
16
  - โšก **Performance Optimized**: Smart DNS fallback with configurable timeouts
17
+ - ๐Ÿงช **Thoroughly Tested**: 83+ tests including comprehensive security coverage
12
18
 
13
19
  ## Installation
14
20
 
@@ -36,7 +42,7 @@ console.log(business.provider?.companyProvider); // "Google Workspace" (if detec
36
42
  Gmail, Outlook, Yahoo Mail, iCloud, ProtonMail, Zoho, AOL, GMX, Web.de, Mail.ru, QQ Mail, NetEase, Yandex, and more.
37
43
 
38
44
  **Business Email (via DNS detection):**
39
- Microsoft 365, Google Workspace, ProtonMail Business, FastMail, Tutanota, Zoho Workplace, and others.
45
+ Microsoft 365, Google Workspace, ProtonMail Business, Hostinger, FastMail, GoDaddy, Tutanota, Zoho Workplace, and others.
40
46
 
41
47
  ## API
42
48
 
@@ -93,13 +99,61 @@ interface EmailProviderResult {
93
99
  }
94
100
  ```
95
101
 
102
+ ## ๐Ÿ›ก๏ธ Security Features
103
+
104
+ This package implements **enterprise-grade security** to protect against malicious redirects and supply chain attacks:
105
+
106
+ ### โœ… Multi-Layer Protection
107
+
108
+ - **HTTPS-Only Enforcement**: All provider URLs must use HTTPS protocol
109
+ - **Domain Allowlisting**: Only pre-approved domains are allowed (64+ verified providers)
110
+ - **Malicious Pattern Detection**: Blocks IP addresses, URL shorteners, suspicious TLDs
111
+ - **Path Traversal Prevention**: Detects and blocks `../` and encoded variants
112
+ - **JavaScript Injection Protection**: Prevents `javascript:`, `data:`, and script injections
113
+ - **File Integrity Verification**: SHA-256 hash verification for provider database
114
+
115
+ ### ๐Ÿ”’ Attack Prevention
116
+
117
+ Protects against common attack vectors:
118
+ - โŒ **URL Injection**: Blocked by strict allowlisting
119
+ - โŒ **Typosquatting**: Blocked by domain validation
120
+ - โŒ **URL Shorteners**: Blocked by pattern detection
121
+ - โŒ **Protocol Downgrade**: Blocked by HTTPS enforcement
122
+ - โŒ **Path Traversal**: Blocked by path validation
123
+ - โŒ **Script Injection**: Blocked by content validation
124
+ - โŒ **Supply Chain Attacks**: Blocked by integrity verification
125
+
126
+ ### ๐Ÿงช Security Testing
127
+
128
+ - **29 dedicated security tests** covering all attack vectors
129
+ - **94% security code coverage** with edge case testing
130
+ - **Automated security validation** in CI/CD pipeline
131
+ - **Regular security audits** of provider database
132
+
133
+ ### ๐Ÿ” For Security Teams
134
+
135
+ Security validation can be integrated into your workflow:
136
+
137
+ ```typescript
138
+ import { secureLoadProviders } from '@mikkelscheike/email-provider-links/security';
139
+
140
+ // Secure loading with integrity verification
141
+ const result = secureLoadProviders();
142
+ if (result.securityReport.securityLevel === 'CRITICAL') {
143
+ // Handle security incident
144
+ console.error('Security validation failed:', result.securityReport.issues);
145
+ }
146
+ ```
147
+
96
148
  ## Contributing
97
149
 
98
150
  We welcome contributions! See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines on adding new email providers.
99
151
 
152
+ **Security Note**: All new providers undergo security validation and must pass our allowlist verification.
153
+
100
154
  ## Security
101
155
 
102
- For security concerns, see our [Security Policy](SECURITY.md).
156
+ For security concerns or to report vulnerabilities, see our [Security Policy](SECURITY.md).
103
157
 
104
158
  ## License
105
159
 
@@ -0,0 +1,94 @@
1
+ /**
2
+ * Hash Verification System
3
+ *
4
+ * Provides cryptographic integrity verification for the email providers database
5
+ * to detect tampering or unauthorized modifications.
6
+ */
7
+ export interface HashVerificationResult {
8
+ isValid: boolean;
9
+ expectedHash?: string;
10
+ actualHash: string;
11
+ reason?: string;
12
+ file: string;
13
+ }
14
+ /**
15
+ * Calculates SHA-256 hash of a file or string content
16
+ *
17
+ * @param content - File content as string or Buffer
18
+ * @returns SHA-256 hash as hex string
19
+ */
20
+ export declare function calculateHash(content: string | Buffer): string;
21
+ /**
22
+ * Calculates SHA-256 hash of a file
23
+ *
24
+ * @param filePath - Path to the file
25
+ * @returns SHA-256 hash as hex string
26
+ */
27
+ export declare function calculateFileHash(filePath: string): string;
28
+ /**
29
+ * Verifies the integrity of the email providers JSON file
30
+ *
31
+ * @param filePath - Path to the providers JSON file
32
+ * @param expectedHash - Optional expected hash (if not provided, uses KNOWN_GOOD_HASHES)
33
+ * @returns Verification result
34
+ */
35
+ export declare function verifyProvidersIntegrity(filePath: string, expectedHash?: string): HashVerificationResult;
36
+ /**
37
+ * Verifies the integrity of providers data from JSON object
38
+ *
39
+ * @param providersData - The providers data object
40
+ * @param expectedHash - Expected hash of the JSON string
41
+ * @returns Verification result
42
+ */
43
+ export declare function verifyProvidersDataIntegrity(providersData: any, expectedHash?: string): HashVerificationResult;
44
+ /**
45
+ * Generates security hashes for critical files - use this during development
46
+ *
47
+ * @param basePath - Base path of the project
48
+ * @returns Object with calculated hashes
49
+ */
50
+ export declare function generateSecurityHashes(basePath?: string): Record<string, string>;
51
+ /**
52
+ * Easy-to-use function to recalculate and display current hashes
53
+ * for updating KNOWN_GOOD_HASHES when making legitimate changes
54
+ *
55
+ * @param basePath - Base path of the project
56
+ * @returns Formatted hash configuration for copy-paste
57
+ */
58
+ export declare function recalculateHashes(basePath?: string): string;
59
+ /**
60
+ * Enhanced security warning system for hash mismatches
61
+ *
62
+ * @param result - Hash verification result
63
+ * @param options - Warning options
64
+ */
65
+ export declare function handleHashMismatch(result: HashVerificationResult, options?: {
66
+ throwOnMismatch?: boolean;
67
+ logLevel?: 'error' | 'warn' | 'silent';
68
+ onMismatch?: (result: HashVerificationResult) => void;
69
+ }): void;
70
+ /**
71
+ * Comprehensive security audit including hash verification
72
+ *
73
+ * @param providersFilePath - Path to providers JSON file
74
+ * @returns Complete security audit result
75
+ */
76
+ export declare function performSecurityAudit(providersFilePath?: string): {
77
+ hashVerification: HashVerificationResult;
78
+ recommendations: string[];
79
+ securityLevel: 'HIGH' | 'MEDIUM' | 'LOW' | 'CRITICAL';
80
+ };
81
+ /**
82
+ * Creates a signed manifest of all provider URLs with their hashes
83
+ * This can be used to detect any URL modifications
84
+ *
85
+ * @param providers - Array of email providers
86
+ * @returns Signed manifest with URL hashes
87
+ */
88
+ export declare function createProviderManifest(providers: any[]): {
89
+ timestamp: string;
90
+ providerCount: number;
91
+ urlHashes: Record<string, string>;
92
+ manifestHash: string;
93
+ };
94
+ //# sourceMappingURL=hash-verifier.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hash-verifier.d.ts","sourceRoot":"","sources":["../../src/security/hash-verifier.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAqBH,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,OAAO,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;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AG,EAAE,GAAG;IACxD,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,YAAY,EAAE,MAAM,CAAC;CACtB,CAsBA"}
@@ -0,0 +1,284 @@
1
+ "use strict";
2
+ /**
3
+ * Hash Verification System
4
+ *
5
+ * Provides cryptographic integrity verification for the email providers database
6
+ * to detect tampering or unauthorized modifications.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.calculateHash = calculateHash;
10
+ exports.calculateFileHash = calculateFileHash;
11
+ exports.verifyProvidersIntegrity = verifyProvidersIntegrity;
12
+ exports.verifyProvidersDataIntegrity = verifyProvidersDataIntegrity;
13
+ exports.generateSecurityHashes = generateSecurityHashes;
14
+ exports.recalculateHashes = recalculateHashes;
15
+ exports.handleHashMismatch = handleHashMismatch;
16
+ exports.performSecurityAudit = performSecurityAudit;
17
+ exports.createProviderManifest = createProviderManifest;
18
+ const crypto_1 = require("crypto");
19
+ const fs_1 = require("fs");
20
+ const path_1 = require("path");
21
+ /**
22
+ * Known good hashes for the providers database.
23
+ * These should be updated whenever the legitimate data changes.
24
+ *
25
+ * IMPORTANT: These hashes should be stored in a separate, more secure location
26
+ * in production (e.g., environment variables, secure CI/CD secrets)
27
+ */
28
+ const KNOWN_GOOD_HASHES = {
29
+ // SHA-256 hash of the legitimate emailproviders.json
30
+ 'emailproviders.json': 'da7a856fe04b11e326230d195fcc3d44f078e481b8929cf4fb5040276e05ffd0',
31
+ // You can add hashes for other critical files
32
+ 'package.json': 'ac34bf4e9e39757c3952070ff423dd46896bf32d48e2360d0e64d80c12387e53'
33
+ };
34
+ /**
35
+ * Calculates SHA-256 hash of a file or string content
36
+ *
37
+ * @param content - File content as string or Buffer
38
+ * @returns SHA-256 hash as hex string
39
+ */
40
+ function calculateHash(content) {
41
+ return (0, crypto_1.createHash)('sha256').update(content).digest('hex');
42
+ }
43
+ /**
44
+ * Calculates SHA-256 hash of a file
45
+ *
46
+ * @param filePath - Path to the file
47
+ * @returns SHA-256 hash as hex string
48
+ */
49
+ function calculateFileHash(filePath) {
50
+ const content = (0, fs_1.readFileSync)(filePath);
51
+ return calculateHash(content);
52
+ }
53
+ /**
54
+ * Verifies the integrity of the email providers JSON file
55
+ *
56
+ * @param filePath - Path to the providers JSON file
57
+ * @param expectedHash - Optional expected hash (if not provided, uses KNOWN_GOOD_HASHES)
58
+ * @returns Verification result
59
+ */
60
+ function verifyProvidersIntegrity(filePath, expectedHash) {
61
+ try {
62
+ const actualHash = calculateFileHash(filePath);
63
+ const expectedHashToUse = expectedHash || KNOWN_GOOD_HASHES['emailproviders.json'];
64
+ if (expectedHashToUse === 'TO_BE_CALCULATED') {
65
+ return {
66
+ isValid: false,
67
+ actualHash,
68
+ reason: 'Expected hash not configured. Run generateSecurityHashes() first.',
69
+ file: filePath
70
+ };
71
+ }
72
+ const isValid = actualHash === expectedHashToUse;
73
+ return {
74
+ isValid,
75
+ expectedHash: expectedHashToUse,
76
+ actualHash,
77
+ reason: isValid ? undefined : 'File hash does not match expected value - potential tampering detected',
78
+ file: filePath
79
+ };
80
+ }
81
+ catch (error) {
82
+ return {
83
+ isValid: false,
84
+ actualHash: '',
85
+ reason: `Failed to verify file: ${error instanceof Error ? error.message : 'Unknown error'}`,
86
+ file: filePath
87
+ };
88
+ }
89
+ }
90
+ /**
91
+ * Verifies the integrity of providers data from JSON object
92
+ *
93
+ * @param providersData - The providers data object
94
+ * @param expectedHash - Expected hash of the JSON string
95
+ * @returns Verification result
96
+ */
97
+ function verifyProvidersDataIntegrity(providersData, expectedHash) {
98
+ try {
99
+ // Create deterministic JSON string (sorted keys)
100
+ const jsonString = JSON.stringify(providersData, Object.keys(providersData).sort(), 2);
101
+ const actualHash = calculateHash(jsonString);
102
+ const expectedHashToUse = expectedHash || KNOWN_GOOD_HASHES['emailproviders.json'];
103
+ if (expectedHashToUse === 'TO_BE_CALCULATED') {
104
+ return {
105
+ isValid: false,
106
+ actualHash,
107
+ reason: 'Expected hash not configured',
108
+ file: 'providersData'
109
+ };
110
+ }
111
+ const isValid = actualHash === expectedHashToUse;
112
+ return {
113
+ isValid,
114
+ expectedHash: expectedHashToUse,
115
+ actualHash,
116
+ reason: isValid ? undefined : 'Data hash does not match expected value',
117
+ file: 'providersData'
118
+ };
119
+ }
120
+ catch (error) {
121
+ return {
122
+ isValid: false,
123
+ actualHash: '',
124
+ reason: `Failed to verify data: ${error instanceof Error ? error.message : 'Unknown error'}`,
125
+ file: 'providersData'
126
+ };
127
+ }
128
+ }
129
+ /**
130
+ * Generates security hashes for critical files - use this during development
131
+ *
132
+ * @param basePath - Base path of the project
133
+ * @returns Object with calculated hashes
134
+ */
135
+ function generateSecurityHashes(basePath = __dirname) {
136
+ const files = [
137
+ 'providers/emailproviders.json',
138
+ 'package.json'
139
+ ];
140
+ const hashes = {};
141
+ for (const file of files) {
142
+ try {
143
+ const fullPath = (0, path_1.join)(basePath, '..', '..', file);
144
+ const hash = calculateFileHash(fullPath);
145
+ hashes[file.split('/').pop() || file] = hash;
146
+ console.log(`โœ… ${file}: ${hash}`);
147
+ }
148
+ catch (error) {
149
+ console.error(`โŒ Failed to hash ${file}:`, error);
150
+ }
151
+ }
152
+ return hashes;
153
+ }
154
+ /**
155
+ * Easy-to-use function to recalculate and display current hashes
156
+ * for updating KNOWN_GOOD_HASHES when making legitimate changes
157
+ *
158
+ * @param basePath - Base path of the project
159
+ * @returns Formatted hash configuration for copy-paste
160
+ */
161
+ function recalculateHashes(basePath) {
162
+ console.log('๐Ÿ”„ RECALCULATING SECURITY HASHES');
163
+ console.log('='.repeat(50));
164
+ const hashes = generateSecurityHashes(basePath);
165
+ const configCode = `
166
+ // Updated KNOWN_GOOD_HASHES configuration:
167
+ const KNOWN_GOOD_HASHES = {
168
+ 'emailproviders.json': '${hashes['emailproviders.json']}',
169
+ 'package.json': '${hashes['package.json']}'
170
+ };
171
+ `;
172
+ console.log('\n๐Ÿ“‹ Copy this configuration to hash-verifier.ts:');
173
+ console.log(configCode);
174
+ console.log('\nโš ๏ธ SECURITY REMINDER:');
175
+ console.log('- Only update hashes after verifying changes are legitimate');
176
+ console.log('- Review git diff before updating hash values');
177
+ console.log('- Consider requiring code review for hash updates');
178
+ return configCode;
179
+ }
180
+ /**
181
+ * Enhanced security warning system for hash mismatches
182
+ *
183
+ * @param result - Hash verification result
184
+ * @param options - Warning options
185
+ */
186
+ function handleHashMismatch(result, options = {}) {
187
+ if (result.isValid)
188
+ return;
189
+ const { throwOnMismatch = false, logLevel = 'error', onMismatch } = options;
190
+ const securityAlert = [
191
+ '๐Ÿšจ๐Ÿšจ๐Ÿšจ CRITICAL SECURITY ALERT ๐Ÿšจ๐Ÿšจ๐Ÿšจ',
192
+ `File: ${result.file}`,
193
+ `Reason: ${result.reason}`,
194
+ `Expected Hash: ${result.expectedHash}`,
195
+ `Actual Hash: ${result.actualHash}`,
196
+ '',
197
+ 'โš ๏ธ POTENTIAL SECURITY BREACH DETECTED:',
198
+ '- File may have been tampered with',
199
+ '- Unauthorized modifications detected',
200
+ '- Supply chain attack possible',
201
+ '',
202
+ '๐Ÿ” IMMEDIATE ACTIONS REQUIRED:',
203
+ '1. Stop using this package immediately',
204
+ '2. Investigate the source of file changes',
205
+ '3. Check git history for unauthorized commits',
206
+ '4. Verify file integrity from trusted source',
207
+ '5. Report security incident if confirmed',
208
+ '',
209
+ '๐Ÿ“ง Consider reporting to: security@[your-domain].com'
210
+ ].join('\n');
211
+ if (logLevel === 'error') {
212
+ console.error(securityAlert);
213
+ }
214
+ else if (logLevel === 'warn') {
215
+ console.warn(securityAlert);
216
+ }
217
+ // Call custom handler if provided
218
+ if (onMismatch) {
219
+ onMismatch(result);
220
+ }
221
+ // Throw error if requested (for production environments)
222
+ if (throwOnMismatch) {
223
+ throw new Error(`SECURITY BREACH: Hash verification failed for ${result.file}. ` +
224
+ `Expected: ${result.expectedHash}, Got: ${result.actualHash}`);
225
+ }
226
+ }
227
+ /**
228
+ * Comprehensive security audit including hash verification
229
+ *
230
+ * @param providersFilePath - Path to providers JSON file
231
+ * @returns Complete security audit result
232
+ */
233
+ function performSecurityAudit(providersFilePath) {
234
+ const filePath = providersFilePath || (0, path_1.join)(__dirname, '..', '..', 'providers', 'emailproviders.json');
235
+ const hashResult = verifyProvidersIntegrity(filePath);
236
+ const recommendations = [];
237
+ let securityLevel = 'HIGH';
238
+ if (!hashResult.isValid) {
239
+ securityLevel = 'CRITICAL';
240
+ recommendations.push('๐Ÿšจ CRITICAL: File integrity check failed - investigate immediately');
241
+ recommendations.push('๐Ÿ”’ Verify the source of the providers file');
242
+ recommendations.push('๐Ÿ“‹ Check git history for unauthorized changes');
243
+ }
244
+ if (KNOWN_GOOD_HASHES['emailproviders.json'] === 'TO_BE_CALCULATED') {
245
+ securityLevel = securityLevel === 'HIGH' ? 'MEDIUM' : securityLevel;
246
+ recommendations.push('โš™๏ธ Configure expected hash values in production');
247
+ recommendations.push('๐Ÿ” Store hashes in secure environment variables');
248
+ }
249
+ recommendations.push('๐Ÿ”„ Regularly update hash values when making legitimate changes');
250
+ recommendations.push('๐Ÿ“Š Monitor for unexpected hash changes in CI/CD');
251
+ recommendations.push('๐Ÿ›ก๏ธ Consider implementing digital signatures for additional security');
252
+ return {
253
+ hashVerification: hashResult,
254
+ recommendations,
255
+ securityLevel
256
+ };
257
+ }
258
+ /**
259
+ * Creates a signed manifest of all provider URLs with their hashes
260
+ * This can be used to detect any URL modifications
261
+ *
262
+ * @param providers - Array of email providers
263
+ * @returns Signed manifest with URL hashes
264
+ */
265
+ function createProviderManifest(providers) {
266
+ const urlHashes = {};
267
+ for (const provider of providers) {
268
+ if (provider.loginUrl) {
269
+ const key = `${provider.companyProvider}::${provider.loginUrl}`;
270
+ urlHashes[key] = calculateHash(provider.loginUrl);
271
+ }
272
+ }
273
+ const manifestData = {
274
+ timestamp: new Date().toISOString(),
275
+ providerCount: providers.length,
276
+ urlHashes
277
+ };
278
+ const manifestHash = calculateHash(JSON.stringify(manifestData, null, 2));
279
+ return {
280
+ ...manifestData,
281
+ manifestHash
282
+ };
283
+ }
284
+ //# sourceMappingURL=hash-verifier.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hash-verifier.js","sourceRoot":"","sources":["../../src/security/hash-verifier.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAmCH,sCAEC;AAQD,8CAGC;AASD,4DAmCC;AASD,oEAsCC;AAQD,wDAoBC;AASD,8CAuBC;AAQD,gDAoDC;AAQD,oDAiCC;AASD,wDA2BC;AA9UD,mCAAoC;AACpC,2BAAkC;AAClC,+BAA4B;AAE5B;;;;;;GAMG;AACH,MAAM,iBAAiB,GAAG;IACxB,qDAAqD;IACrD,qBAAqB,EAAE,kEAAkE;IAEzF,8CAA8C;IAC9C,cAAc,EAAE,kEAAkE;CACnF,CAAC;AAUF;;;;;GAKG;AACH,SAAgB,aAAa,CAAC,OAAwB;IACpD,OAAO,IAAA,mBAAU,EAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC5D,CAAC;AAED;;;;;GAKG;AACH,SAAgB,iBAAiB,CAAC,QAAgB;IAChD,MAAM,OAAO,GAAG,IAAA,iBAAY,EAAC,QAAQ,CAAC,CAAC;IACvC,OAAO,aAAa,CAAC,OAAO,CAAC,CAAC;AAChC,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,wBAAwB,CACtC,QAAgB,EAChB,YAAqB;IAErB,IAAI,CAAC;QACH,MAAM,UAAU,GAAG,iBAAiB,CAAC,QAAQ,CAAC,CAAC;QAC/C,MAAM,iBAAiB,GAAG,YAAY,IAAI,iBAAiB,CAAC,qBAAqB,CAAC,CAAC;QAEnF,IAAI,iBAAiB,KAAK,kBAAkB,EAAE,CAAC;YAC7C,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,UAAU;gBACV,MAAM,EAAE,mEAAmE;gBAC3E,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AC;IAC1E,CAAC;IAED,eAAe,CAAC,IAAI,CAAC,gEAAgE,CAAC,CAAC;IACvF,eAAe,CAAC,IAAI,CAAC,iDAAiD,CAAC,CAAC;IACxE,eAAe,CAAC,IAAI,CAAC,uEAAuE,CAAC,CAAC;IAE9F,OAAO;QACL,gBAAgB,EAAE,UAAU;QAC5B,eAAe;QACf,aAAa;KACd,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,sBAAsB,CAAC,SAAgB;IAMrD,MAAM,SAAS,GAA2B,EAAE,CAAC;IAE7C,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;QACjC,IAAI,QAAQ,CAAC,QAAQ,EAAE,CAAC;YACtB,MAAM,GAAG,GAAG,GAAG,QAAQ,CAAC,eAAe,KAAK,QAAQ,CAAC,QAAQ,EAAE,CAAC;YAChE,SAAS,CAAC,GAAG,CAAC,GAAG,aAAa,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACpD,CAAC;IACH,CAAC;IAED,MAAM,YAAY,GAAG;QACnB,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACnC,aAAa,EAAE,SAAS,CAAC,MAAM;QAC/B,SAAS;KACV,CAAC;IAEF,MAAM,YAAY,GAAG,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAE1E,OAAO;QACL,GAAG,YAAY;QACf,YAAY;KACb,CAAC;AACJ,CAAC"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Secure Loader for Email Providers
3
+ *
4
+ * Integrates URL validation and hash verification to create a secure
5
+ * loading system for email provider data.
6
+ */
7
+ import type { EmailProvider } from '../index';
8
+ export interface SecureLoadResult {
9
+ success: boolean;
10
+ providers: EmailProvider[];
11
+ securityReport: {
12
+ hashVerification: boolean;
13
+ urlValidation: boolean;
14
+ totalProviders: number;
15
+ validUrls: number;
16
+ invalidUrls: number;
17
+ securityLevel: 'SECURE' | 'WARNING' | 'CRITICAL';
18
+ issues: string[];
19
+ };
20
+ }
21
+ /**
22
+ * Securely loads and validates email provider data
23
+ *
24
+ * @param providersPath - Path to the providers JSON file
25
+ * @param expectedHash - Optional expected hash for verification
26
+ * @returns Secure load result with validation details
27
+ */
28
+ export declare function secureLoadProviders(providersPath?: string, expectedHash?: string): SecureLoadResult;
29
+ /**
30
+ * Development utility to generate and display current hashes
31
+ */
32
+ export declare function initializeSecurity(): Record<string, string>;
33
+ /**
34
+ * Express middleware for secure provider loading (if using in web apps)
35
+ */
36
+ export declare function createSecurityMiddleware(options?: {
37
+ expectedHash?: string;
38
+ allowInvalidUrls?: boolean;
39
+ onSecurityIssue?: (report: SecureLoadResult['securityReport']) => void;
40
+ }): (req: any, res: any, next: any) => any;
41
+ declare const _default: {
42
+ secureLoadProviders: typeof secureLoadProviders;
43
+ initializeSecurity: typeof initializeSecurity;
44
+ createSecurityMiddleware: typeof createSecurityMiddleware;
45
+ };
46
+ export default _default;
47
+ //# sourceMappingURL=secure-loader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secure-loader.d.ts","sourceRoot":"","sources":["../../src/security/secure-loader.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,aAAa,EAAE,CAAC;IAC3B,cAAc,EAAE;QACd,gBAAgB,EAAE,OAAO,CAAC;QAC1B,aAAa,EAAE,OAAO,CAAC;QACvB,cAAc,EAAE,MAAM,CAAC;QACvB,SAAS,EAAE,MAAM,CAAC;QAClB,WAAW,EAAE,MAAM,CAAC;QACpB,aAAa,EAAE,QAAQ,GAAG,SAAS,GAAG,UAAU,CAAC;QACjD,MAAM,EAAE,MAAM,EAAE,CAAC;KAClB,CAAC;CACH;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,aAAa,CAAC,EAAE,MAAM,EACtB,YAAY,CAAC,EAAE,MAAM,GACpB,gBAAgB,CAoFlB;AAED;;GAEG;AACH,wBAAgB,kBAAkB,2BAWjC;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,GAAE;IAChD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,eAAe,CAAC,EAAE,CAAC,MAAM,EAAE,gBAAgB,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;CACnE,IACI,KAAK,GAAG,EAAE,KAAK,GAAG,EAAE,MAAM,GAAG,SAmBtC;;;;;;AAED,wBAIE"}