UNPKG

@mcaptcha/core-glue

Version:

internal library containig shared glue code

2 lines 2.01 kB
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.mcaptchaGlue=e():t.mcaptchaGlue=e()}(this,(()=>(()=>{"use strict";var t={};return{607:function(t,e){var n,i=this&&this.__extends||(n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},n(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function i(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)});Object.defineProperty(e,"__esModule",{value:!0}),e.ConfigurationError=void 0;var o=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.message="Provide either widget link or site key to display mCaptcha widget",e}return i(e,t),e}(Error);e.ConfigurationError=o;var r=function(){function t(t,e){var n=this;if(this.handle=function(t){console.log("message received from ".concat(t.origin," with data: ").concat(t.data.token)),new URL(t.origin).host==n.widgetLink.host?n.updateState(t.data.token):console.error("expected message from ".concat(n.widgetLink.host," but received message from ").concat(t.origin,". Aborting."))},this.updateState=e,t.widgetLink&&t.siteKey)throw new o;if(t.widgetLink)this.widgetLink=t.widgetLink;else{if(!t.siteKey)throw new o;t.siteKey.instanceUrl?(this.widgetLink=t.siteKey.instanceUrl,this.widgetLink.pathname="/widget/",this.widgetLink.search="?sitekey=".concat(t.siteKey.key)):this.widgetLink=new URL("https://demo.mcaptcha.org/widget/?sitekey=".concat(t.siteKey.key))}}return t.prototype.listen=function(){window.addEventListener("message",this.handle)},t.prototype.destroy=function(){window.removeEventListener("message",this.handle)},t}();e.default=r}}[607](0,t),t})())); //# sourceMappingURL=index.js.map