UNPKG

ci-validation

Version:

🇺🇾 Complete TypeScript/JavaScript library for validating Uruguayan CI (Cédula de Identidad) with official algorithm and government service integration

92 lines • 2.59 kB
/** * Interface for Sisi API response */ export interface SisiResponse { success: boolean; hasUser: boolean; error?: string; userInfo?: { ci: string; country: string; status: "exists" | "not_found" | "error"; message: string; executionTime: number; }; } /** * Interface for Sisi request parameters */ export interface SisiRequest { ci: string; pais?: string; } /** * Sisi Service Class * Handles verification of users in the Sisi system (sisi.com.uy) * * This service checks if a user exists in the Sisi loyalty program * by making requests to their sisipuntos-consulta endpoint. */ export declare class SisiService { private readonly baseUrl; private readonly endpoint; private readonly timeout; /** * Default headers for Sisi requests * Based on the original curl request */ private getDefaultHeaders; /** * Creates form data for the Sisi API request * @param ci - Cédula de identidad (without dots or dashes) * @param pais - Country code (default: "001" for Uruguay) * @returns FormData object */ private createFormData; /** * Validates CI format before making the request * @param ci - Cédula de identidad * @returns boolean */ private validateCI; /** * Normalizes CI by removing any formatting * @param ci - Cédula de identidad * @returns Normalized CI string */ private normalizeCI; /** * Parses the Sisi API response to determine user existence * @param response - Axios response * @returns Parsed SisiResponse */ private parseResponse; /** * Determines if user exists based on response message * @param data - Response data * @returns boolean indicating if user exists */ private determineUserExistence; /** * Extracts user-friendly message from response * @param data - Response data * @param hasUser - Whether user exists * @returns User-friendly message */ private extractMessage; /** * Checks if a user exists in the Sisi system * @param request - Sisi request parameters * @returns Promise<SisiResponse> */ checkUser(request: SisiRequest): Promise<SisiResponse>; /** * Convenience method to check if a user exists by CI only * @param ci - Cédula de identidad * @returns Promise<boolean> */ hasUser(ci: string): Promise<boolean>; } declare const _default: SisiService; export default _default; //# sourceMappingURL=Sisi.d.ts.map