Files
evig/cms-api/node_modules/validator/lib/isCreditCard.js
T
Your Name 53caf6c3aa feat: implement complete admin interface for Reboot Content
- Add Next.js admin routes (/admin, /admin/login, /admin/pages, /admin/pages/new, /admin/pages/[id])
- Create admin layout with navigation and authentication
- Build login page with email/password form
- Implement pages list with search and create functionality
- Add WYSIWYG editor for content creation/editing
- Create API routes for admin authentication and content management
- Add middleware for route protection
- Include sample data population script
- Add comprehensive admin interface documentation for non-technical users
- Create test page for validating admin functionality
- Update environment configuration for JWT secret

Admin interface is now super easy and intuitive for non-technical team members to:
- Login with email/password
- View all pages with search
- Create new pages
- Edit existing pages with rich text editor
- Save as draft or publish immediately
- Preview content before publishing

All code follows best practices with proper error handling, security, and accessibility.
2025-09-08 13:18:07 +02:00

52 lines
1.8 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = isCreditCard;
var _assertString = _interopRequireDefault(require("./util/assertString"));
var _isLuhnNumber = _interopRequireDefault(require("./isLuhnNumber"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var cards = {
amex: /^3[47][0-9]{13}$/,
dinersclub: /^3(?:0[0-5]|[68][0-9])[0-9]{11}$/,
discover: /^6(?:011|5[0-9][0-9])[0-9]{12,15}$/,
jcb: /^(?:2131|1800|35\d{3})\d{11}$/,
mastercard: /^5[1-5][0-9]{2}|(222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}$/,
// /^[25][1-7][0-9]{14}$/;
unionpay: /^(6[27][0-9]{14}|^(81[0-9]{14,17}))$/,
visa: /^(?:4[0-9]{12})(?:[0-9]{3,6})?$/
};
var allCards = function () {
var tmpCardsArray = [];
for (var cardProvider in cards) {
// istanbul ignore else
if (cards.hasOwnProperty(cardProvider)) {
tmpCardsArray.push(cards[cardProvider]);
}
}
return tmpCardsArray;
}();
function isCreditCard(card) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
(0, _assertString.default)(card);
var provider = options.provider;
var sanitized = card.replace(/[- ]+/g, '');
if (provider && provider.toLowerCase() in cards) {
// specific provider in the list
if (!cards[provider.toLowerCase()].test(sanitized)) {
return false;
}
} else if (provider && !(provider.toLowerCase() in cards)) {
/* specific provider not in the list */
throw new Error("".concat(provider, " is not a valid credit card provider."));
} else if (!allCards.some(function (cardProvider) {
return cardProvider.test(sanitized);
})) {
// no specific provider
return false;
}
return (0, _isLuhnNumber.default)(card);
}
module.exports = exports.default;
module.exports.default = exports.default;