spamscanner 6.0.0 → 6.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.
@@ -0,0 +1,236 @@
1
+ /**
2
+ * Enhanced IDN Detector options
3
+ */
4
+ export type EnhancedIdnDetectorOptions = {
5
+ /** Enable strict mode */
6
+ strictMode?: boolean;
7
+ /** Enable domain whitelist */
8
+ enableWhitelist?: boolean;
9
+ /** Enable brand protection */
10
+ enableBrandProtection?: boolean;
11
+ /** Enable context analysis */
12
+ enableContextAnalysis?: boolean;
13
+ /** Maximum similarity threshold (0-1) */
14
+ maxSimilarityThreshold?: number;
15
+ /** Minimum domain age in days */
16
+ minDomainAge?: number;
17
+ };
18
+
19
+ /**
20
+ * Context for IDN analysis
21
+ */
22
+ export type IdnAnalysisContext = {
23
+ /** Email content */
24
+ emailContent?: string;
25
+ /** Display text (if different from domain) */
26
+ displayText?: string | undefined;
27
+ /** Sender reputation (0-1) */
28
+ senderReputation?: number;
29
+ /** Email headers */
30
+ emailHeaders?: Map<string, unknown> | Record<string, unknown>;
31
+ };
32
+
33
+ /**
34
+ * IDN analysis result
35
+ */
36
+ export type IdnAnalysisResult = {
37
+ /** The domain analyzed */
38
+ domain: string;
39
+ /** Whether the domain is an IDN */
40
+ isIdn: boolean;
41
+ /** Risk score (0-1) */
42
+ riskScore: number;
43
+ /** Risk factors identified */
44
+ riskFactors: string[];
45
+ /** Recommendations */
46
+ recommendations: string[];
47
+ /** Confidence level (0-1) */
48
+ confidence: number;
49
+ };
50
+
51
+ /**
52
+ * Confusable character analysis result
53
+ */
54
+ export type ConfusableAnalysis = {
55
+ /** Risk score contribution */
56
+ score: number;
57
+ /** Risk factors identified */
58
+ factors: string[];
59
+ };
60
+
61
+ /**
62
+ * Brand similarity analysis result
63
+ */
64
+ export type BrandAnalysis = {
65
+ /** Risk score contribution */
66
+ score: number;
67
+ /** Risk factors identified */
68
+ factors: string[];
69
+ };
70
+
71
+ /**
72
+ * Script mixing analysis result
73
+ */
74
+ export type ScriptAnalysis = {
75
+ /** Risk score contribution */
76
+ score: number;
77
+ /** Risk factors identified */
78
+ factors: string[];
79
+ };
80
+
81
+ /**
82
+ * Context analysis result
83
+ */
84
+ export type ContextAnalysis = {
85
+ /** Risk score contribution */
86
+ score: number;
87
+ /** Risk factors identified */
88
+ factors: string[];
89
+ };
90
+
91
+ /**
92
+ * Punycode analysis result
93
+ */
94
+ export type PunycodeAnalysis = {
95
+ /** Risk score contribution */
96
+ score: number;
97
+ /** Risk factors identified */
98
+ factors: string[];
99
+ };
100
+
101
+ /**
102
+ * Enhanced IDN Homograph Attack Detector
103
+ */
104
+ declare class EnhancedIdnDetector {
105
+ /** Detector options */
106
+ options: EnhancedIdnDetectorOptions & {
107
+ strictMode: boolean;
108
+ enableWhitelist: boolean;
109
+ enableBrandProtection: boolean;
110
+ enableContextAnalysis: boolean;
111
+ maxSimilarityThreshold: number;
112
+ minDomainAge: number;
113
+ };
114
+
115
+ /** Analysis cache */
116
+ cache: Map<string, IdnAnalysisResult>;
117
+
118
+ /**
119
+ * Create a new EnhancedIdnDetector instance
120
+ * @param options - Configuration options
121
+ */
122
+ constructor(options?: EnhancedIdnDetectorOptions);
123
+
124
+ /**
125
+ * Detect homograph attack in a domain
126
+ * @param domain - Domain to analyze
127
+ * @param context - Analysis context
128
+ * @returns Analysis result
129
+ */
130
+ detectHomographAttack(domain: string, context?: IdnAnalysisContext): IdnAnalysisResult;
131
+
132
+ /**
133
+ * Comprehensive analysis of a domain
134
+ * @param domain - Domain to analyze
135
+ * @param context - Analysis context
136
+ * @returns Analysis result
137
+ */
138
+ analyzeComprehensive(domain: string, context: IdnAnalysisContext): IdnAnalysisResult;
139
+
140
+ /**
141
+ * Check if domain contains IDN characters
142
+ * @param domain - Domain to check
143
+ * @returns Whether the domain is an IDN
144
+ */
145
+ isIdnDomain(domain: string): boolean;
146
+
147
+ /**
148
+ * Check if domain is whitelisted
149
+ * @param domain - Domain to check
150
+ * @returns Whether the domain is whitelisted
151
+ */
152
+ isWhitelisted(domain: string): boolean;
153
+
154
+ /**
155
+ * Analyze confusable characters in domain
156
+ * @param domain - Domain to analyze
157
+ * @returns Confusable analysis result
158
+ */
159
+ analyzeConfusableCharacters(domain: string): ConfusableAnalysis;
160
+
161
+ /**
162
+ * Analyze brand similarity
163
+ * @param domain - Domain to analyze
164
+ * @returns Brand analysis result
165
+ */
166
+ analyzeBrandSimilarity(domain: string): BrandAnalysis;
167
+
168
+ /**
169
+ * Analyze script mixing patterns
170
+ * @param domain - Domain to analyze
171
+ * @returns Script analysis result
172
+ */
173
+ analyzeScriptMixing(domain: string): ScriptAnalysis;
174
+
175
+ /**
176
+ * Analyze context for additional risk factors
177
+ * @param domain - Domain to analyze
178
+ * @param context - Analysis context
179
+ * @returns Context analysis result
180
+ */
181
+ analyzeContext(domain: string, context: IdnAnalysisContext): ContextAnalysis;
182
+
183
+ /**
184
+ * Analyze punycode domain
185
+ * @param domain - Domain to analyze
186
+ * @returns Punycode analysis result
187
+ */
188
+ analyzePunycode(domain: string): PunycodeAnalysis;
189
+
190
+ /**
191
+ * Normalize domain for comparison
192
+ * @param domain - Domain to normalize
193
+ * @returns Normalized domain
194
+ */
195
+ normalizeDomain(domain: string): string;
196
+
197
+ /**
198
+ * Calculate string similarity using Levenshtein distance
199
+ * @param string1 - First string
200
+ * @param string2 - Second string
201
+ * @returns Similarity score (0-1)
202
+ */
203
+ calculateSimilarity(string1: string, string2: string): number;
204
+
205
+ /**
206
+ * Detect scripts used in domain
207
+ * @param domain - Domain to analyze
208
+ * @returns Set of detected scripts
209
+ */
210
+ detectScripts(domain: string): Set<string>;
211
+
212
+ /**
213
+ * Decode punycode domain
214
+ * @param domain - Domain to decode
215
+ * @returns Decoded domain
216
+ */
217
+ decodePunycode(domain: string): string;
218
+
219
+ /**
220
+ * Generate recommendations based on analysis
221
+ * @param analysis - Analysis result
222
+ * @returns Array of recommendations
223
+ */
224
+ generateRecommendations(analysis: IdnAnalysisResult): string[];
225
+
226
+ /**
227
+ * Get cache key for analysis
228
+ * @param domain - Domain
229
+ * @param context - Analysis context
230
+ * @returns Cache key
231
+ */
232
+ getCacheKey(domain: string, context: IdnAnalysisContext): string;
233
+ }
234
+
235
+ export default EnhancedIdnDetector;
236
+ export {EnhancedIdnDetector};