presidio-anonymizer-nestjs
Version:
NestJS service & module for Presidio-based anonymization/de-anonymization
53 lines (52 loc) • 1.52 kB
TypeScript
import { HttpService } from '@nestjs/axios';
import { ConfigService } from '@nestjs/config';
export interface SensitiveEntity {
original: string;
anonymized: string;
entityType: string;
start: number;
end: number;
}
export declare class AnonymizerService {
private readonly http;
private readonly configService;
private readonly logger;
private entityMap;
constructor(http: HttpService, configService: ConfigService);
/**
* Analyzes text for sensitive information, anonymizes it, and maintains a mapping
* for later deanonymization
*/
anonymizeText(text: string): Promise<{
anonymizedText: string;
entitiesFound: boolean;
}>;
/**
* Deanonymizes text by replacing anonymized values with original values
*/
deanonymizeText(anonymizedText: string): string;
/**
* Returns all sensitive entities found in the last anonymization
*/
getSensitiveEntities(): SensitiveEntity[];
/**
* Clear the entity mapping
*/
clearEntityMapping(): void;
/**
* Analyzes text to identify sensitive information
*/
private analyzeText;
/**
* Builds configuration for the anonymizer based on entity types
*/
private buildAnonymizersConfig;
/**
* Builds a mapping between original and anonymized entities
*/
private buildEntityMapping;
/**
* Finds the best match for a given entity type from all detected entities
*/
private findBestMatch;
}