Auto-commit 2026-04-29 16:31
This commit is contained in:
71
apps/api/src/services/spamshield/spamshield.config.ts
Normal file
71
apps/api/src/services/spamshield/spamshield.config.ts
Normal file
@@ -0,0 +1,71 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
// Environment variables for SpamShield
|
||||
const envSchema = z.object({
|
||||
HIYA_API_KEY: z.string(),
|
||||
HIYA_API_URL: z.string().default('https://api.hiya.com/v1'),
|
||||
TRUECALLER_API_KEY: z.string().optional(),
|
||||
BERT_MODEL_PATH: z.string().default('./models/spam-classifier'),
|
||||
SPAM_THRESHOLD_AUTO_BLOCK: z.string().transform(Number).default(0.85),
|
||||
SPAM_THRESHOLD_FLAG: z.string().transform(Number).default(0.6),
|
||||
CALL_ANALYSIS_TIMEOUT_MS: z.string().transform(Number).default(200),
|
||||
});
|
||||
|
||||
export const spamShieldEnv = envSchema.parse({
|
||||
HIYA_API_KEY: process.env.HIYA_API_KEY,
|
||||
HIYA_API_URL: process.env.HIYA_API_URL,
|
||||
TRUECALLER_API_KEY: process.env.TRUECALLER_API_KEY,
|
||||
BERT_MODEL_PATH: process.env.BERT_MODEL_PATH,
|
||||
SPAM_THRESHOLD_AUTO_BLOCK: process.env.SPAM_THRESHOLD_AUTO_BLOCK,
|
||||
SPAM_THRESHOLD_FLAG: process.env.SPAM_THRESHOLD_FLAG,
|
||||
CALL_ANALYSIS_TIMEOUT_MS: process.env.CALL_ANALYSIS_TIMEOUT_MS,
|
||||
});
|
||||
|
||||
// Spam detection layers
|
||||
export enum SpamLayer {
|
||||
NUMBER_REPUTATION = 'number_reputation',
|
||||
CONTENT_CLASSIFICATION = 'content_classification',
|
||||
BEHAVIORAL_ANALYSIS = 'behavioral_analysis',
|
||||
COMMUNITY_INTELLIGENCE = 'community_intelligence',
|
||||
}
|
||||
|
||||
// Spam decision types
|
||||
export enum SpamDecision {
|
||||
ALLOW = 'allow',
|
||||
FLAG = 'flag',
|
||||
BLOCK = 'block',
|
||||
CHALLENGE = 'challenge',
|
||||
}
|
||||
|
||||
// Confidence levels
|
||||
export enum ConfidenceLevel {
|
||||
LOW = 'low',
|
||||
MEDIUM = 'medium',
|
||||
HIGH = 'high',
|
||||
VERY_HIGH = 'very_high',
|
||||
}
|
||||
|
||||
// Feature flags for spam detection
|
||||
export const spamFeatureFlags = {
|
||||
enableNumberReputation: true,
|
||||
enableContentClassification: true,
|
||||
enableBehavioralAnalysis: true,
|
||||
enableCommunityIntelligence: true,
|
||||
enableRealTimeBlocking: true,
|
||||
};
|
||||
|
||||
// Rate limits for spam analysis
|
||||
export const spamRateLimits = {
|
||||
basic: {
|
||||
analysesPerMinute: 10,
|
||||
analysesPerDay: 100,
|
||||
},
|
||||
plus: {
|
||||
analysesPerMinute: 50,
|
||||
analysesPerDay: 1000,
|
||||
},
|
||||
premium: {
|
||||
analysesPerMinute: 200,
|
||||
analysesPerDay: 10000,
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user