UNPKG

@nestlab/google-recaptcha

Version:
26 lines (25 loc) 878 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AbstractGoogleRecaptchaValidator = void 0; class AbstractGoogleRecaptchaValidator { constructor(options) { this.options = options; } isValidAction(action, options) { if (options.action) { return options.action === action; } return this.options.valueOf.actions ? this.options.valueOf.actions.includes(action) : true; } isValidScore(score, validator) { const finalValidator = validator || this.options.valueOf.score; if (finalValidator) { if (typeof finalValidator === 'function') { return finalValidator(score); } return score >= finalValidator; } return true; } } exports.AbstractGoogleRecaptchaValidator = AbstractGoogleRecaptchaValidator;