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,856 @@
1
+ import type {ParsedMail, Attachment} from 'mailparser';
2
+
3
+ /**
4
+ * ClamScan configuration options
5
+ */
6
+ export type ClamScanConfig = {
7
+ /** Remove infected files automatically */
8
+ removeInfected?: boolean;
9
+ /** Quarantine infected files */
10
+ quarantineInfected?: boolean;
11
+ /** Path to scan log file */
12
+ scanLog?: string | undefined;
13
+ /** Enable debug mode for ClamScan */
14
+ debugMode?: boolean;
15
+ /** File list to scan */
16
+ fileList?: string | undefined;
17
+ /** Scan directories recursively */
18
+ scanRecursively?: boolean;
19
+ /** Path to clamscan binary */
20
+ clamscanPath?: string;
21
+ /** Path to clamdscan binary */
22
+ clamdscanPath?: string;
23
+ /** Preferred scanner to use */
24
+ preference?: 'clamscan' | 'clamdscan';
25
+ };
26
+
27
+ /**
28
+ * SpamScanner configuration options
29
+ */
30
+ export type SpamScannerConfig = {
31
+ /** Enable macro detection in documents */
32
+ enableMacroDetection?: boolean;
33
+ /** Enable performance metrics collection */
34
+ enablePerformanceMetrics?: boolean;
35
+ /** Timeout for operations in milliseconds */
36
+ timeout?: number;
37
+ /** List of supported languages for detection */
38
+ supportedLanguages?: string[];
39
+ /** Enable mixed language detection */
40
+ enableMixedLanguageDetection?: boolean;
41
+ /** Enable advanced pattern recognition */
42
+ enableAdvancedPatternRecognition?: boolean;
43
+ /** Enable debug mode */
44
+ debug?: boolean;
45
+ /** Logger instance */
46
+ logger?: Console | {
47
+ log: (...args: unknown[]) => void;
48
+ error: (...args: unknown[]) => void;
49
+ warn: (...args: unknown[]) => void;
50
+ info: (...args: unknown[]) => void;
51
+ debug: (...args: unknown[]) => void;
52
+ };
53
+ /** ClamScan configuration */
54
+ clamscan?: ClamScanConfig;
55
+ /** Pre-trained classifier data */
56
+ classifier?: Record<string, unknown> | undefined;
57
+ /** Replacement word mappings */
58
+ replacements?: Map<string, string> | Record<string, string> | undefined;
59
+ /** Enable NSFW detection */
60
+ enableNsfwDetection?: boolean;
61
+ /** Enable toxicity detection */
62
+ enableToxicityDetection?: boolean;
63
+ /** Toxicity detection threshold (0-1) */
64
+ toxicityThreshold?: number;
65
+ /** NSFW detection threshold (0-1) */
66
+ nsfwThreshold?: number;
67
+ /** Enable strict IDN detection */
68
+ strictIdnDetection?: boolean;
69
+ /** Enable token hashing */
70
+ hashTokens?: boolean;
71
+ };
72
+
73
+ /**
74
+ * Classification result
75
+ */
76
+ export type ClassificationResult = {
77
+ /** Classification category */
78
+ category: 'spam' | 'ham';
79
+ /** Classification probability */
80
+ probability: number;
81
+ };
82
+
83
+ /**
84
+ * Phishing detection result
85
+ */
86
+ export type PhishingResult = {
87
+ /** Type of detection */
88
+ type: 'phishing' | 'suspicious';
89
+ /** The URL that was flagged */
90
+ url: string;
91
+ /** Description of the issue */
92
+ description: string;
93
+ /** Additional details */
94
+ details?: {
95
+ riskFactors?: string[];
96
+ recommendations?: string[];
97
+ confidence?: number;
98
+ };
99
+ };
100
+
101
+ /**
102
+ * Executable detection result
103
+ */
104
+ export type ExecutableResult = {
105
+ /** Type of detection */
106
+ type: 'executable' | 'archive';
107
+ /** Filename of the attachment */
108
+ filename: string;
109
+ /** File extension */
110
+ extension?: string;
111
+ /** Detected file type */
112
+ detectedType?: string;
113
+ /** Description of the issue */
114
+ description: string;
115
+ /** Risk level */
116
+ risk?: 'low' | 'medium' | 'high';
117
+ /** Warning message */
118
+ warning?: string;
119
+ };
120
+
121
+ /**
122
+ * Macro detection result
123
+ */
124
+ export type MacroResult = {
125
+ /** Type of detection */
126
+ type: 'macro';
127
+ /** Subtype of macro */
128
+ subtype: 'vba' | 'powershell' | 'javascript' | 'batch' | 'script' | 'office_document' | 'legacy_office' | 'pdf_javascript';
129
+ /** Filename if from attachment */
130
+ filename?: string;
131
+ /** Description of the issue */
132
+ description: string;
133
+ /** Risk level */
134
+ risk?: 'low' | 'medium' | 'high';
135
+ };
136
+
137
+ /**
138
+ * Arbitrary detection result (e.g., GTUBE)
139
+ */
140
+ export type ArbitraryResult = {
141
+ /** Type of detection */
142
+ type: 'arbitrary';
143
+ /** Description of the issue */
144
+ description: string;
145
+ };
146
+
147
+ /**
148
+ * Virus detection result
149
+ */
150
+ export type VirusResult = {
151
+ /** Filename of the infected attachment */
152
+ filename: string;
153
+ /** Detected virus names */
154
+ virus: string[];
155
+ /** Type of detection */
156
+ type: 'virus';
157
+ };
158
+
159
+ /**
160
+ * Pattern detection result
161
+ */
162
+ export type PatternResult = {
163
+ /** Type of detection */
164
+ type: 'pattern' | 'file_path';
165
+ /** Subtype of pattern */
166
+ subtype?: string;
167
+ /** Count of matches */
168
+ count?: number;
169
+ /** Detected path */
170
+ path?: string;
171
+ /** Description of the issue */
172
+ description: string;
173
+ };
174
+
175
+ /**
176
+ * IDN Homograph attack detection result
177
+ */
178
+ export type IdnHomographResult = {
179
+ /** Whether an attack was detected */
180
+ detected: boolean;
181
+ /** List of suspicious domains */
182
+ domains: IdnDomainAnalysis[];
183
+ /** Overall risk score (0-1) */
184
+ riskScore: number;
185
+ /** Additional details */
186
+ details: string[];
187
+ };
188
+
189
+ /**
190
+ * IDN domain analysis
191
+ */
192
+ export type IdnDomainAnalysis = {
193
+ /** The domain analyzed */
194
+ domain: string;
195
+ /** Original URL */
196
+ originalUrl: string;
197
+ /** Normalized URL */
198
+ normalizedUrl: string;
199
+ /** Risk score (0-1) */
200
+ riskScore: number;
201
+ /** Risk factors identified */
202
+ riskFactors: string[];
203
+ /** Recommendations */
204
+ recommendations: string[];
205
+ /** Confidence level */
206
+ confidence: number;
207
+ };
208
+
209
+ /**
210
+ * Toxicity detection result
211
+ */
212
+ export type ToxicityResult = {
213
+ /** Type of detection */
214
+ type: 'toxicity';
215
+ /** Toxicity category */
216
+ category: string;
217
+ /** Probability of toxicity */
218
+ probability: number;
219
+ /** Description of the issue */
220
+ description: string;
221
+ };
222
+
223
+ /**
224
+ * NSFW detection result
225
+ */
226
+ export type NsfwResult = {
227
+ /** Type of detection */
228
+ type: 'nsfw';
229
+ /** Filename of the image */
230
+ filename: string;
231
+ /** NSFW category */
232
+ category: 'Porn' | 'Hentai' | 'Sexy' | 'Drawing' | 'Neutral';
233
+ /** Probability of NSFW content */
234
+ probability: number;
235
+ /** Description of the issue */
236
+ description: string;
237
+ };
238
+
239
+ /**
240
+ * All scan results
241
+ */
242
+ export type ScanResults = {
243
+ /** Classification result */
244
+ classification: ClassificationResult;
245
+ /** Phishing detection results */
246
+ phishing: PhishingResult[];
247
+ /** Executable detection results */
248
+ executables: ExecutableResult[];
249
+ /** Macro detection results */
250
+ macros: MacroResult[];
251
+ /** Arbitrary pattern results */
252
+ arbitrary: ArbitraryResult[];
253
+ /** Virus detection results */
254
+ viruses: VirusResult[];
255
+ /** Pattern detection results */
256
+ patterns: PatternResult[];
257
+ /** IDN homograph attack results */
258
+ idnHomographAttack: IdnHomographResult;
259
+ /** Toxicity detection results */
260
+ toxicity: ToxicityResult[];
261
+ /** NSFW detection results */
262
+ nsfw: NsfwResult[];
263
+ };
264
+
265
+ /**
266
+ * Performance metrics
267
+ */
268
+ export type PerformanceMetrics = {
269
+ /** Total processing time in ms */
270
+ totalTime: number;
271
+ /** Classification time in ms */
272
+ classificationTime: number;
273
+ /** Phishing detection time in ms */
274
+ phishingTime: number;
275
+ /** Executable detection time in ms */
276
+ executableTime: number;
277
+ /** Macro detection time in ms */
278
+ macroTime: number;
279
+ /** Virus scan time in ms */
280
+ virusTime: number;
281
+ /** Pattern detection time in ms */
282
+ patternTime: number;
283
+ /** IDN detection time in ms */
284
+ idnTime: number;
285
+ /** Memory usage statistics */
286
+ memoryUsage: NodeJS.MemoryUsage;
287
+ };
288
+
289
+ /**
290
+ * Scanner metrics
291
+ */
292
+ export type ScannerMetrics = {
293
+ /** Total number of scans performed */
294
+ totalScans: number;
295
+ /** Average scan time in ms */
296
+ averageTime: number;
297
+ /** Last scan time in ms */
298
+ lastScanTime: number;
299
+ };
300
+
301
+ /**
302
+ * Scan result
303
+ */
304
+ export type ScanResult = {
305
+ /** Whether the email is spam */
306
+ isSpam: boolean;
307
+ /** Human-readable message */
308
+ message: string;
309
+ /** Detailed results from all detectors */
310
+ results: ScanResults;
311
+ /** Extracted URLs from the email */
312
+ links: string[];
313
+ /** Extracted tokens from the email */
314
+ tokens: string[];
315
+ /** Parsed mail object */
316
+ mail: ParsedMail;
317
+ /** Performance metrics (if enabled) */
318
+ metrics?: PerformanceMetrics;
319
+ };
320
+
321
+ /**
322
+ * Tokens and mail result from source parsing
323
+ */
324
+ export type TokensAndMailResult = {
325
+ /** Extracted tokens */
326
+ tokens: string[];
327
+ /** Parsed mail object */
328
+ mail: ParsedMail;
329
+ };
330
+
331
+ /**
332
+ * Parsed URL result using tldts
333
+ */
334
+ export type ParsedUrl = {
335
+ /** Full domain */
336
+ domain: string | undefined;
337
+ /** Domain without suffix */
338
+ domainWithoutSuffix: string | undefined;
339
+ /** Full hostname */
340
+ hostname: string | undefined;
341
+ /** Public suffix */
342
+ publicSuffix: string | undefined;
343
+ /** Subdomain */
344
+ subdomain: string | undefined;
345
+ /** Whether the hostname is an IP address */
346
+ isIp: boolean;
347
+ /** Whether the domain is ICANN registered */
348
+ isIcann: boolean;
349
+ /** Whether the domain is private */
350
+ isPrivate: boolean;
351
+ };
352
+
353
+ /**
354
+ * Mail object for internal processing
355
+ */
356
+ export type MailObject = {
357
+ /** Plain text content */
358
+ text?: string;
359
+ /** HTML content */
360
+ html?: string;
361
+ /** Email subject */
362
+ subject?: string;
363
+ /** From address */
364
+ from?: Record<string, unknown>;
365
+ /** To addresses */
366
+ to?: unknown[];
367
+ /** Attachments */
368
+ attachments?: Attachment[];
369
+ /** Header lines */
370
+ headerLines?: Array<{line?: string}>;
371
+ /** Headers map */
372
+ headers?: Map<string, unknown> | Record<string, unknown>;
373
+ };
374
+
375
+ /**
376
+ * Source input type for scanning
377
+ */
378
+ export type ScanSource = string | Uint8Array;
379
+
380
+ /**
381
+ * SpamScanner class for email spam detection
382
+ */
383
+ declare class SpamScanner {
384
+ /** Scanner configuration */
385
+ config: SpamScannerConfig & {
386
+ enableMacroDetection: boolean;
387
+ enablePerformanceMetrics: boolean;
388
+ timeout: number;
389
+ supportedLanguages: string[];
390
+ enableMixedLanguageDetection: boolean;
391
+ enableAdvancedPatternRecognition: boolean;
392
+ debug: boolean;
393
+ logger: Console;
394
+ clamscan: ClamScanConfig;
395
+ classifier: Record<string, unknown> | undefined;
396
+ replacements: Map<string, string> | Record<string, string> | undefined;
397
+ };
398
+
399
+ /** Naive Bayes classifier instance */
400
+ classifier: unknown | undefined;
401
+
402
+ /** ClamScan instance */
403
+ clamscan: unknown | undefined;
404
+
405
+ /** Whether the scanner is initialized */
406
+ isInitialized: boolean;
407
+
408
+ /** Replacement word mappings */
409
+ replacements: Map<string, string>;
410
+
411
+ /** Scanner metrics */
412
+ metrics: ScannerMetrics;
413
+
414
+ /**
415
+ * Create a new SpamScanner instance
416
+ * @param options - Configuration options
417
+ */
418
+ constructor(options?: SpamScannerConfig);
419
+
420
+ /**
421
+ * Initialize the classifier
422
+ */
423
+ initializeClassifier(): Promise<void>;
424
+
425
+ /**
426
+ * Initialize replacements
427
+ */
428
+ initializeReplacements(): Promise<void>;
429
+
430
+ /**
431
+ * Initialize regex helpers
432
+ */
433
+ initializeRegex(): void;
434
+
435
+ /**
436
+ * Scan an email for spam
437
+ * @param source - Email source (string, Uint8Array, or file path)
438
+ * @returns Scan result
439
+ */
440
+ scan(source: ScanSource): Promise<ScanResult>;
441
+
442
+ /**
443
+ * Get tokens and parsed mail from source
444
+ * @param source - Email source
445
+ * @returns Tokens and mail object
446
+ */
447
+ getTokensAndMailFromSource(source: ScanSource): Promise<TokensAndMailResult>;
448
+
449
+ /**
450
+ * Get classification result for tokens
451
+ * @param tokens - Array of tokens
452
+ * @returns Classification result
453
+ */
454
+ getClassification(tokens: string[]): Promise<ClassificationResult>;
455
+
456
+ /**
457
+ * Get phishing detection results
458
+ * @param mail - Parsed mail object
459
+ * @returns Array of phishing results
460
+ */
461
+ getPhishingResults(mail: MailObject): Promise<PhishingResult[]>;
462
+
463
+ /**
464
+ * Get executable detection results
465
+ * @param mail - Parsed mail object
466
+ * @returns Array of executable results
467
+ */
468
+ getExecutableResults(mail: MailObject): Promise<ExecutableResult[]>;
469
+
470
+ /**
471
+ * Get macro detection results
472
+ * @param mail - Parsed mail object
473
+ * @returns Array of macro results
474
+ */
475
+ getMacroResults(mail: MailObject): Promise<MacroResult[]>;
476
+
477
+ /**
478
+ * Get arbitrary pattern results (e.g., GTUBE)
479
+ * @param mail - Parsed mail object
480
+ * @returns Array of arbitrary results
481
+ */
482
+ getArbitraryResults(mail: MailObject): Promise<ArbitraryResult[]>;
483
+
484
+ /**
485
+ * Get virus scan results
486
+ * @param mail - Parsed mail object
487
+ * @returns Array of virus results
488
+ */
489
+ getVirusResults(mail: MailObject): Promise<VirusResult[]>;
490
+
491
+ /**
492
+ * Get pattern detection results
493
+ * @param mail - Parsed mail object
494
+ * @returns Array of pattern results
495
+ */
496
+ getPatternResults(mail: MailObject): Promise<PatternResult[]>;
497
+
498
+ /**
499
+ * Get file path detection results
500
+ * @param mail - Parsed mail object
501
+ * @returns Array of pattern results
502
+ */
503
+ getFilePathResults(mail: MailObject): Promise<PatternResult[]>;
504
+
505
+ /**
506
+ * Get IDN homograph attack results
507
+ * @param mail - Parsed mail object
508
+ * @returns IDN homograph result
509
+ */
510
+ getIdnHomographResults(mail: MailObject): Promise<IdnHomographResult>;
511
+
512
+ /**
513
+ * Get toxicity detection results
514
+ * @param mail - Parsed mail object
515
+ * @returns Array of toxicity results
516
+ */
517
+ getToxicityResults(mail: MailObject): Promise<ToxicityResult[]>;
518
+
519
+ /**
520
+ * Get NSFW detection results
521
+ * @param mail - Parsed mail object
522
+ * @returns Array of NSFW results
523
+ */
524
+ getNsfwResults(mail: MailObject): Promise<NsfwResult[]>;
525
+
526
+ /**
527
+ * Get tokens from text
528
+ * @param text - Text to tokenize
529
+ * @param locale - Locale code (default: 'en')
530
+ * @param isHtml - Whether the text is HTML
531
+ * @returns Array of tokens
532
+ */
533
+ getTokens(text: string, locale?: string, isHtml?: boolean): Promise<string[]>;
534
+
535
+ /**
536
+ * Preprocess text for analysis
537
+ * @param text - Text to preprocess
538
+ * @returns Preprocessed text
539
+ */
540
+ preprocessText(text: string): Promise<string>;
541
+
542
+ /**
543
+ * Extract URLs from text
544
+ * @param text - Text to extract URLs from
545
+ * @returns Array of URLs
546
+ */
547
+ getUrls(text: string): string[];
548
+
549
+ /**
550
+ * Extract all URLs from mail and source
551
+ * @param mail - Parsed mail object
552
+ * @param originalSource - Original email source
553
+ * @returns Array of URLs
554
+ */
555
+ extractAllUrls(mail: MailObject, originalSource: ScanSource): string[];
556
+
557
+ /**
558
+ * Optimize URL parsing with timeout protection
559
+ * @param url - URL to parse
560
+ * @returns Normalized URL
561
+ */
562
+ optimizeUrlParsing(url: string): Promise<string>;
563
+
564
+ /**
565
+ * Parse URL using tldts
566
+ * @param url - URL to parse
567
+ * @returns Parsed URL result or null
568
+ */
569
+ parseUrlWithTldts(url: string): ParsedUrl | undefined;
570
+
571
+ /**
572
+ * Check if a domain is blocked by Cloudflare
573
+ * @param hostname - Hostname to check
574
+ * @returns Whether the domain is blocked
575
+ */
576
+ isCloudflareBlocked(hostname: string): Promise<boolean>;
577
+
578
+ /**
579
+ * Detect language using hybrid approach
580
+ * @param text - Text to analyze
581
+ * @returns Detected language code
582
+ */
583
+ detectLanguageHybrid(text: string): Promise<string>;
584
+
585
+ /**
586
+ * Parse and normalize locale code
587
+ * @param locale - Locale code to parse
588
+ * @returns Normalized locale code
589
+ */
590
+ parseLocale(locale: string): string;
591
+
592
+ /**
593
+ * Normalize language code from 3-letter to 2-letter format
594
+ * @param code - Language code to normalize
595
+ * @returns Normalized 2-letter language code
596
+ */
597
+ normalizeLanguageCode(code: string): string;
598
+
599
+ /**
600
+ * Validate short text language detection
601
+ * @param text - Text that was analyzed
602
+ * @param detectedLang - Detected language code
603
+ * @returns Whether the detection is valid
604
+ */
605
+ isValidShortTextDetection(text: string, detectedLang: string): boolean;
606
+
607
+ /**
608
+ * Check if a path is a valid file path
609
+ * @param path - Path to validate
610
+ * @returns Whether the path is valid
611
+ */
612
+ isValidFilePath(path: string): boolean;
613
+
614
+ /**
615
+ * Get IDN detector instance
616
+ * @returns IDN detector or null
617
+ */
618
+ getIdnDetector(): Promise<EnhancedIdnDetector | undefined>;
619
+ }
620
+
621
+ /**
622
+ * Enhanced IDN Detector options
623
+ */
624
+ export type EnhancedIdnDetectorOptions = {
625
+ /** Enable strict mode */
626
+ strictMode?: boolean;
627
+ /** Enable domain whitelist */
628
+ enableWhitelist?: boolean;
629
+ /** Enable brand protection */
630
+ enableBrandProtection?: boolean;
631
+ /** Enable context analysis */
632
+ enableContextAnalysis?: boolean;
633
+ /** Maximum similarity threshold (0-1) */
634
+ maxSimilarityThreshold?: number;
635
+ /** Minimum domain age in days */
636
+ minDomainAge?: number;
637
+ };
638
+
639
+ /**
640
+ * Context for IDN analysis
641
+ */
642
+ export type IdnAnalysisContext = {
643
+ /** Email content */
644
+ emailContent?: string;
645
+ /** Display text (if different from domain) */
646
+ displayText?: string | undefined;
647
+ /** Sender reputation (0-1) */
648
+ senderReputation?: number;
649
+ /** Email headers */
650
+ emailHeaders?: Map<string, unknown> | Record<string, unknown>;
651
+ };
652
+
653
+ /**
654
+ * IDN analysis result
655
+ */
656
+ export type IdnAnalysisResult = {
657
+ /** The domain analyzed */
658
+ domain: string;
659
+ /** Whether the domain is an IDN */
660
+ isIdn: boolean;
661
+ /** Risk score (0-1) */
662
+ riskScore: number;
663
+ /** Risk factors identified */
664
+ riskFactors: string[];
665
+ /** Recommendations */
666
+ recommendations: string[];
667
+ /** Confidence level (0-1) */
668
+ confidence: number;
669
+ };
670
+
671
+ /**
672
+ * Confusable character analysis result
673
+ */
674
+ export type ConfusableAnalysis = {
675
+ /** Risk score contribution */
676
+ score: number;
677
+ /** Risk factors identified */
678
+ factors: string[];
679
+ };
680
+
681
+ /**
682
+ * Brand similarity analysis result
683
+ */
684
+ export type BrandAnalysis = {
685
+ /** Risk score contribution */
686
+ score: number;
687
+ /** Risk factors identified */
688
+ factors: string[];
689
+ };
690
+
691
+ /**
692
+ * Script mixing analysis result
693
+ */
694
+ export type ScriptAnalysis = {
695
+ /** Risk score contribution */
696
+ score: number;
697
+ /** Risk factors identified */
698
+ factors: string[];
699
+ };
700
+
701
+ /**
702
+ * Context analysis result
703
+ */
704
+ export type ContextAnalysis = {
705
+ /** Risk score contribution */
706
+ score: number;
707
+ /** Risk factors identified */
708
+ factors: string[];
709
+ };
710
+
711
+ /**
712
+ * Punycode analysis result
713
+ */
714
+ export type PunycodeAnalysis = {
715
+ /** Risk score contribution */
716
+ score: number;
717
+ /** Risk factors identified */
718
+ factors: string[];
719
+ };
720
+
721
+ /**
722
+ * Enhanced IDN Homograph Attack Detector
723
+ */
724
+ declare class EnhancedIdnDetector {
725
+ /** Detector options */
726
+ options: EnhancedIdnDetectorOptions & {
727
+ strictMode: boolean;
728
+ enableWhitelist: boolean;
729
+ enableBrandProtection: boolean;
730
+ enableContextAnalysis: boolean;
731
+ maxSimilarityThreshold: number;
732
+ minDomainAge: number;
733
+ };
734
+
735
+ /** Analysis cache */
736
+ cache: Map<string, IdnAnalysisResult>;
737
+
738
+ /**
739
+ * Create a new EnhancedIdnDetector instance
740
+ * @param options - Configuration options
741
+ */
742
+ constructor(options?: EnhancedIdnDetectorOptions);
743
+
744
+ /**
745
+ * Detect homograph attack in a domain
746
+ * @param domain - Domain to analyze
747
+ * @param context - Analysis context
748
+ * @returns Analysis result
749
+ */
750
+ detectHomographAttack(domain: string, context?: IdnAnalysisContext): IdnAnalysisResult;
751
+
752
+ /**
753
+ * Comprehensive analysis of a domain
754
+ * @param domain - Domain to analyze
755
+ * @param context - Analysis context
756
+ * @returns Analysis result
757
+ */
758
+ analyzeComprehensive(domain: string, context: IdnAnalysisContext): IdnAnalysisResult;
759
+
760
+ /**
761
+ * Check if domain contains IDN characters
762
+ * @param domain - Domain to check
763
+ * @returns Whether the domain is an IDN
764
+ */
765
+ isIdnDomain(domain: string): boolean;
766
+
767
+ /**
768
+ * Check if domain is whitelisted
769
+ * @param domain - Domain to check
770
+ * @returns Whether the domain is whitelisted
771
+ */
772
+ isWhitelisted(domain: string): boolean;
773
+
774
+ /**
775
+ * Analyze confusable characters in domain
776
+ * @param domain - Domain to analyze
777
+ * @returns Confusable analysis result
778
+ */
779
+ analyzeConfusableCharacters(domain: string): ConfusableAnalysis;
780
+
781
+ /**
782
+ * Analyze brand similarity
783
+ * @param domain - Domain to analyze
784
+ * @returns Brand analysis result
785
+ */
786
+ analyzeBrandSimilarity(domain: string): BrandAnalysis;
787
+
788
+ /**
789
+ * Analyze script mixing patterns
790
+ * @param domain - Domain to analyze
791
+ * @returns Script analysis result
792
+ */
793
+ analyzeScriptMixing(domain: string): ScriptAnalysis;
794
+
795
+ /**
796
+ * Analyze context for additional risk factors
797
+ * @param domain - Domain to analyze
798
+ * @param context - Analysis context
799
+ * @returns Context analysis result
800
+ */
801
+ analyzeContext(domain: string, context: IdnAnalysisContext): ContextAnalysis;
802
+
803
+ /**
804
+ * Analyze punycode domain
805
+ * @param domain - Domain to analyze
806
+ * @returns Punycode analysis result
807
+ */
808
+ analyzePunycode(domain: string): PunycodeAnalysis;
809
+
810
+ /**
811
+ * Normalize domain for comparison
812
+ * @param domain - Domain to normalize
813
+ * @returns Normalized domain
814
+ */
815
+ normalizeDomain(domain: string): string;
816
+
817
+ /**
818
+ * Calculate string similarity using Levenshtein distance
819
+ * @param string1 - First string
820
+ * @param string2 - Second string
821
+ * @returns Similarity score (0-1)
822
+ */
823
+ calculateSimilarity(string1: string, string2: string): number;
824
+
825
+ /**
826
+ * Detect scripts used in domain
827
+ * @param domain - Domain to analyze
828
+ * @returns Set of detected scripts
829
+ */
830
+ detectScripts(domain: string): Set<string>;
831
+
832
+ /**
833
+ * Decode punycode domain
834
+ * @param domain - Domain to decode
835
+ * @returns Decoded domain
836
+ */
837
+ decodePunycode(domain: string): string;
838
+
839
+ /**
840
+ * Generate recommendations based on analysis
841
+ * @param analysis - Analysis result
842
+ * @returns Array of recommendations
843
+ */
844
+ generateRecommendations(analysis: IdnAnalysisResult): string[];
845
+
846
+ /**
847
+ * Get cache key for analysis
848
+ * @param domain - Domain
849
+ * @param context - Analysis context
850
+ * @returns Cache key
851
+ */
852
+ getCacheKey(domain: string, context: IdnAnalysisContext): string;
853
+ }
854
+
855
+ export default SpamScanner;
856
+ export {SpamScanner, EnhancedIdnDetector};