UNPKG

@sebak/recaptcha-v3

Version:

![npm](https://img.shields.io/npm/v/recaptcha-v3.svg) ![npm type definitions](https://img.shields.io/npm/types/recaptcha-v3.svg)

35 lines (34 loc) 1.3 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var ReCaptchaInstance = (function () { function ReCaptchaInstance(siteKey, recaptcha) { this.siteKey = siteKey; this.recaptcha = recaptcha; } ReCaptchaInstance.prototype.execute = function (action) { var _this = this; return new Promise(function (resolve, reject) { _this.recaptcha.execute(_this.siteKey, { action: action }).then(resolve, reject); }); }; ReCaptchaInstance.prototype.hideBadge = function () { var badges = this.findBadges(); badges.forEach(function (badge) { badge.style.display = 'none'; }); }; ReCaptchaInstance.prototype.showBadge = function () { var badges = this.findBadges(); badges.forEach(function (badge) { badge.style.display = 'block'; }); }; ReCaptchaInstance.prototype.findBadges = function () { var foundElements = Array.from(document.getElementsByClassName('grecaptcha-badge')); return foundElements.filter(function (value) { return value instanceof HTMLElement; }).map(function (value) { return value; }); }; return ReCaptchaInstance; }()); exports.ReCaptchaInstance = ReCaptchaInstance;