UNPKG

@cafecafe/afip.ts

Version:
78 lines (77 loc) 2.27 kB
import { AccessTicket } from "./access-ticket"; import { ServiceNamesEnum } from "../soap/service-names.enum"; import { Context, WSAuthParam } from "../types"; export declare class AfipAuth { private readonly context; resolvedFolderPath: string; constructor(context: Context); private getAuthClient; /** * Tokent request authorization * * @param serviceName * @returns */ private getTRA; /** * Sign tokent request authorization * * @param serviceName * @param cert * @param key */ private signTRA; /** * Get login cms from new request to afip * * @param serviceName ServiceNamesEnum * @returns ILoginCmsReturn */ private requestLogin; /** * Creates the format of the authentication headers requested by the afip endpoints * * @param ticket AccessTicket * @returns WSAuthParam */ getWSAuthForRequest(ticket: AccessTicket): Promise<WSAuthParam>; /** * Create the file name with a standard format * * @param serviceName name from Afip WS * @returns */ createFileName(serviceName: ServiceNamesEnum): string; /** * Get path to the ticket file * * @param serviceName ServiceNamesEnum * @returns */ private getTicketFilePathByService; /** * Get token authorization * * @param serviceName ServiceNamesEnum * @returns AccessTicket */ login(serviceName: ServiceNamesEnum): Promise<AccessTicket>; /** * Save the access ticket locally using file system * * @param ticket accessmticket header and credentials * @param serviceName name from Afip WS * @returns void */ saveLocalAccessTicket(ticket: AccessTicket, serviceName: ServiceNamesEnum): Promise<void>; /** * Get the access ticket locally using file system. * If the file is not found, the catch take the error and return undefined. * * ** Check if the folder has the correct access permission. ** * * @param serviceName name from Afip WS * @returns access ticket or undefined if it is not there */ getLocalAccessTicket(serviceName: ServiceNamesEnum): Promise<AccessTicket | undefined>; }