86 lines
1.4 KiB
JavaScript
86 lines
1.4 KiB
JavaScript
/**
|
|
* Card Generator Configuration
|
|
* 卡类型配置
|
|
*/
|
|
|
|
const CARD_TYPES = {
|
|
unionpay: {
|
|
name: '中国银联 (UnionPay)',
|
|
prefix: '622836754',
|
|
length: 16,
|
|
cvvLength: 3,
|
|
useLuhn: true // 使用Luhn算法校验
|
|
},
|
|
visa: {
|
|
name: 'Visa',
|
|
prefix: '4',
|
|
length: 16,
|
|
cvvLength: 3,
|
|
useLuhn: true
|
|
},
|
|
mastercard: {
|
|
name: 'MasterCard',
|
|
prefix: '5',
|
|
length: 16,
|
|
cvvLength: 3,
|
|
useLuhn: true
|
|
},
|
|
amex: {
|
|
name: 'American Express',
|
|
prefix: '34',
|
|
length: 15,
|
|
cvvLength: 4,
|
|
useLuhn: true
|
|
},
|
|
discover: {
|
|
name: 'Discover',
|
|
prefix: '6011',
|
|
length: 16,
|
|
cvvLength: 3,
|
|
useLuhn: true
|
|
}
|
|
};
|
|
|
|
/**
|
|
* 有效期配置
|
|
*/
|
|
const EXPIRY_CONFIG = {
|
|
minYear: 26, // 2026
|
|
maxYear: 30, // 2030
|
|
minMonth: 1,
|
|
maxMonth: 12
|
|
};
|
|
|
|
/**
|
|
* 输出格式配置
|
|
*/
|
|
const OUTPUT_FORMATS = {
|
|
pipe: {
|
|
name: 'Pipe分隔 (|)',
|
|
formatter: (card) => `${card.number}|${card.month}|${card.year}|${card.cvv}`
|
|
},
|
|
json: {
|
|
name: 'JSON格式',
|
|
formatter: (card) => JSON.stringify(card, null, 2)
|
|
},
|
|
csv: {
|
|
name: 'CSV格式',
|
|
formatter: (card) => `${card.number},${card.month},${card.year},${card.cvv}`
|
|
},
|
|
pretty: {
|
|
name: '美化格式',
|
|
formatter: (card) => `
|
|
Card Number: ${card.number}
|
|
Expiry Date: ${card.month}/${card.year}
|
|
CVV: ${card.cvv}
|
|
Type: ${card.type}
|
|
`.trim()
|
|
}
|
|
};
|
|
|
|
module.exports = {
|
|
CARD_TYPES,
|
|
EXPIRY_CONFIG,
|
|
OUTPUT_FORMATS
|
|
};
|