@paydock/client-sdk
Version:
Paydock client sdk
76 lines • 2.78 kB
TypeScript
/**
* Regular expression pattern for detecting PAN (Primary Account Number) sequences
* Matches groups of 13 or more digits with spaces or dashes in between
*/
export declare const PAN_PATTERN_REGEX: RegExp;
/**
* Detects if a given string contains a PAN (Primary Account Number) that should be masked
*
* PAN detection requirements:
* - The system should disregard any number of dashes and spaces and combine the digits into one number.
* - If there is a number ≥ 13 and ≤ 19 digits, excluding dashes (-) and spaces ( ), the system will take this number and check it for PAN exposure using the Luhn algorithm.
* - If there is a number with > 19 digits, excluding dashes (-) and spaces ( ), the system will take the first 19 digits and will check it for PAN exposure using the Luhn algorithm.
*
* @param value - The string to check for PAN exposure
* @returns true if a PAN is detected, false otherwise
*/
export declare function detectPan(value: string): boolean;
/**
* Validates a number using the Luhn algorithm (modulo 10)
* @param value - The numeric string to validate
* @returns true if the number passes Luhn validation, false otherwise
*/
export declare function validateLuhn(value: string): boolean;
export declare const CARD_CODE: {
CVV: string;
CID: string;
CVC: string;
CVN: string;
};
export declare const CARD_TYPE: {
AUSBC: string;
VISA_WHITE: string;
VISA: string;
MASTERCARD: string;
DINERS: string;
JAPCB: string;
LASER: string;
SOLO: string;
DISCOVER: string;
AMEX: string;
UNIONPAY: string;
MAESTRO: string;
EFTPOS: string;
EFTPOS_WHITE: string;
};
export interface IScheme {
type: string | null;
label: string;
prefixPattern: RegExp | null;
exactPattern: RegExp | null;
gaps: number[];
lengths: number[];
code: {
name: string;
size: number;
};
}
export declare class CardScheme {
static readonly cardHolderNamePattern: RegExp;
static readonly cardHolderNameNoDigitPattern: RegExp;
protected scheme: IScheme;
static byType(type: string | null): CardScheme;
static byNumber(cardNumber: string | number): CardScheme;
static getTypeByNumber(cardNumber: string | number): string | null;
static getNumberLast4(cardNumber: string): string | null;
static isCorrectLength(cardNumber: string): boolean;
static getNumberLength(cardNumber: string): number;
static isValidCardHolderName(name: string): boolean;
static hasSequentialDigitsMoreThan(text: string, max: number): boolean;
protected constructor(scheme: IScheme);
get type(): string;
get label(): string;
get minNumberLength(): number;
get maxNumberLength(): number;
}
//# sourceMappingURL=card-scheme.d.ts.map