UNPKG

paytools-3ds

Version:

3D secure implementation with a single line of code

301 lines (298 loc) 6.54 kB
// Generated by dts-bundle-generator v9.5.1 /** * Card types */ export type CardTypes = "AMEX" | "BC" | "CartaSi" | "Dankort" | "Delta" | "DinersClub" | "Discover" | "Electron" | "Elo" | "enRoute" | "Hipercard" | "JCB" | "Maestro" | "MasterCard" | "MC_Alaska" | "MC_Canada" | "Switch" | "Troy" | "UATP" | "UnionPay" | "Visa"; /** * Card details required for 3DS */ export declare class CardData { /** * Card Brand */ cardType: CardTypes; /** * PAN */ cardNumber: string; /** * Expiration Year */ expirationYear: number; /** * Expiration month (1..12) */ expirationMonth: number; /** * Name on card */ cardHolderName: string; /** * security Code */ securityCode: string; /** * Issue Number */ issueNumber: string; /** * ownerId */ ownerId: string; /** * Cardholder email address * To be removed once old 3ds is deprecated * */ customerEmail: string | undefined; /** * Cardholder phone number (incl. country code, no '+' sign, digits only) * To be removed once old 3ds is deprecated * */ customerPhone: string | undefined; } /** * Message sent to client */ export declare class ClientMessage { /** * Message type */ messageType: MessageType; /** * Provider Name */ providerName: ProviderName; } /** * Authenticated message */ export declare class ClientAuthenticatedMessage extends ClientMessage { /** * Authentication data */ threeDS: ThreeDS; } /** * FingerPrint Required message */ export declare class ClientFingerPrintRequiredMessage extends ClientMessage { /** * Uri of the Device fingerprint flow src */ fingerPrintUri: string; /** * Additional data used for Device fingerprint flow */ fingerPrintData: string; } /** * Challenge Required message */ export declare class ClientChallengeRequiredMessage extends ClientMessage { /** * Url to use for the client challenge flow */ ascUri: string; /** * JWT to provider */ accessToken: string; } /** * Technical problem message */ export declare class ClientTechnicalProblemDetectedMessage extends ClientMessage { /** * Reason for technical problem */ reason: string; /** * MPI Reference */ reference: string; } declare class ThreeDS { /** * Authentication Value */ authenticationValue: string; /** * ECI */ eci: string; /** * Transaction Id */ xid: string; /** * 3DS version */ version: string; /** * (masterCard) Service level Indication */ sli: string; } /** * Provider names */ export type ProviderName = "Unknown" | "Shift4" | "CyberSource"; /** * Client message type enumeration */ export type MessageType = /** * The initial state */ "NeverUsed" | /** * Authenticated */ "Authenticated" | /** * Attempt Without Authentication */ "AttemptWithoutAuthentication" | /** * Rejected */ "Rejected" | /** * Device FingerPrint Required */ "FingerPrintRequired" | /** * Device FingerPrint Required */ "FingerPrintCompleted" | /** * Challenge required */ "ChallengeRequired" | /** * A technical problem */ "TechnicalProblem" | /** * Card is not enrolled for 3DS */ "CardNotEnrolled" | /** * No response has been received from MPI */ "NoResponse"; declare class CreateSessionResponse { /** Was the request successful? */ success: boolean; /** * Error message */ message: string; /** * Token to be used as Bearer authentication in next iteration with the host */ token: string; /** * The actual payload */ clientMessage: ClientMessage; } declare class Options { /** * if set, indicates a required postmessage with the target host */ postMessageTarget: string; /** * If true, the challenge form within the hosting page */ displayChallengeFormWithinPage: boolean; } export declare class Engine { /** * Base url for Api */ private _oldModelStyle; /** * Urls for varios operations */ private createSessionUrl; private getChallengeResultsUrl; private getFingerpringResultsUrl; /** * The session token as generated by ePayTools */ private sessionToken; /** * iFrame for challenge/fingerprint */ private iFrame; /** * Provider object */ private _provider; /** * Options */ private _options; /** * Resolver of entry point */ private resolver; private _supportedCardBrands; /** * Constructor * @param apiBaseUrl The url of the server. Leave the default for production */ constructor(apiBaseUrl?: string, options?: Options | undefined); /** * Main function to perform a 3d secure authentication session * * @param {string} sessionToken - token obtained from the Orchestra service * @param {string} iFrameElementSelector - Selector of element in which a challenge iFrame is to be created * @param {CardData|undefined} cardData - The card details * @param {string|undefined} cardToken An optional token with which a host-stored card details can be recovered */ perform3ds(sessionToken: string, iFrameElementSelector: string, cardData: CardData | undefined, cardToken?: string | undefined): Promise<ClientMessage>; /** * An event that is trigerred when a user interaction starts/ends. * It can be used by the caller in order to start/stop displaying a 'please wait' message */ onPresentingGui: (isOn: boolean) => {}; /** * Parse the session token and detect if it has a url field; In this case, it will override the baseUrl and path */ parseSessionToken(token: string): boolean; /** * init 3DS Authentication Session * @param {CardData} cardData containing card info * @param cardToken An optional token with which a host-stored card details can be recovered */ init3DSecAuthSession(cardData: CardData | undefined, cardToken: string | undefined): void; /** * Handle response for init session * * @param {CreateSessionResponse} createSessionResponse - message received from server */ handleInitSessionResponse(createSessionResponse: CreateSessionResponse): void; /** * Fingerprint results handler * @param clientMessage results of fingerprint */ handleFingerPrintResults(clientMessage: ClientMessage): void; /** * Perform challenge. Can be called either after session initiation or after a fingerprint test * @param {string} ascUri - the URI to use for iFrame src tag. */ performChallenge(ascUri: string, acessToken: string | undefined): void; /** * Scroll smoothly to element */ scrollToElement(element: HTMLElement): void; /** * Error reporting * @param {string} reason * @param {string} ref */ handleError(reason: string, ref: string): void; } export {};