ci-validation
Version:
🇺🇾 Complete TypeScript/JavaScript library for validating Uruguayan CI (Cédula de Identidad) with official algorithm and government service integration
133 lines • 4.31 kB
TypeScript
export interface SmiRequest {
ci: string;
}
export interface SmiMember {
ci: string;
userData?: ExtractedUserData;
status: "registered" | "not_registered";
executionTime: number;
}
export interface SmiResponse {
success: boolean;
hasUser: boolean;
member?: SmiMember;
error?: string;
}
export interface ExtractedUserData {
perID?: string;
perCI?: string;
perMail?: string;
domicTel?: string;
tipoCodigoRecuperacion?: string;
metodos?: Array<{
tipo: string;
descripcion: string;
}>;
mensaje?: string;
isValidUser: boolean;
}
export declare class SmiService {
private readonly loginUrl;
private readonly baseUrl;
private sessionData;
private readonly headers;
/**
* Create axios instance with proxy configuration if available
* @returns Configured axios instance
*/
private createAxiosInstance;
/**
* Initialize session by making a GET request to the login page
* @returns Promise with session initialization result
*/
initializeSession(): Promise<boolean>;
/**
* Extract security tokens from HTML content
* @param html - The HTML content from the login page
*/
private extractTokensFromHTML;
/**
* Generate recovery page hash based on GeneXus session and security patterns
* @returns MD5 hash for the recovery page URL
*/
private generateRecoveryPageHash;
/**
* Generate login page hash for forgot password requests
* @returns MD5 hash for the login page URL
*/
private generateLoginPageHash;
/**
* Execute forgot password action on login page
* @returns Promise with success status
*/
executeForgotPassword(): Promise<boolean>;
/**
* Initialize recovery page by making a GET request
* @returns Promise with initialization result
*/
initializeRecoveryPage(): Promise<boolean>;
/**
* Perform final validation request to validate account
* @param finalUrl - The complete URL for the validation request
* @returns Promise with validation result
*/
performFinalValidation(finalUrl: string): Promise<any>;
/**
* Check if user is registered in SMI system
* @param request - Object containing the CI
* @returns Promise with SMI response data
*/
checkUser(request: SmiRequest): Promise<SmiResponse>;
/**
* Check user via external proxy (when SMI_PROXY is set)
* @param request - Object containing the CI
* @param startTime - Start time for execution timing
* @returns Promise with SMI response data
*/
private checkUserViaProxy;
/**
* Direct SMI check (original implementation)
* @param request - Object containing the CI
* @param startTime - Start time for execution timing
* @returns Promise with SMI response data
*/
private checkUserDirect;
/**
* Build cookie header from session data
* @returns Cookie header string
*/
private buildCookieHeader;
/**
* Extract user data from the final HTML response
* @param htmlContent - The HTML content from the final validation response
* @returns Extracted user data
*/
private extractUserDataFromHTML;
/**
* Parse the raw API response into our standardized format
* @param apiResponse - Raw response from SMI API
* @param ci - The CI number that was queried
* @param executionTime - Time taken for the request
* @returns Parsed SmiResponse
*/
private parseResponse;
/**
* Check if user exists in the SMI system
* @param request - Object containing the CI
* @returns Promise with boolean indicating if user exists
*/
hasUser(request: SmiRequest): Promise<boolean>;
/**
* Get member information
* @param request - Object containing the CI
* @returns Promise with member data or null if not found
*/
getMember(request: SmiRequest): Promise<SmiMember | null>;
/**
* Extract detailed user data from HTML response
* @param htmlContent - HTML content from SMI response
* @returns Extracted user data with detailed information
*/
extractUserData(htmlContent: string): ExtractedUserData;
}
//# sourceMappingURL=Smi.d.ts.map