diff --git a/Classes/Configuration.php b/Classes/Configuration.php index 34bd68a..939064f 100644 --- a/Classes/Configuration.php +++ b/Classes/Configuration.php @@ -11,7 +11,7 @@ class Configuration { - public const DEFAULT_JS_PATH = 'EXT:friendlycaptcha_official/Resources/Public/JavaScript/lib/sdk@0.1.8-site.compat.min.js'; + public const DEFAULT_JS_PATH = 'EXT:friendlycaptcha_official/Resources/Public/JavaScript/lib/sdk@0.1.26-site.compat.min.js'; protected string $siteKey = ''; protected string $siteSecretKey = ''; diff --git a/Documentation/Index.rst b/Documentation/Index.rst index b5cd16f..d086e08 100644 --- a/Documentation/Index.rst +++ b/Documentation/Index.rst @@ -46,6 +46,7 @@ TYPO3 Extension friendlycaptcha_official Configuration/Index Using/Index V2_Migration/Index + v2.1.0_Update/Index .. Meta Menu diff --git a/Documentation/V2_Migration/Index.rst b/Documentation/V2_Migration/Index.rst index 0150621..eff49c4 100644 --- a/Documentation/V2_Migration/Index.rst +++ b/Documentation/V2_Migration/Index.rst @@ -13,4 +13,4 @@ If you’re currently using an earlier version of the plugin with **Friendly Cap * In TYPO3 backend, go to the *Site Management*/*Sites* module and switch to the **FriendlyCaptcha** tab. You need to change the URLs **Puzzle Endpoint** - check it if you want to use the EU Endpoint **Verify URL** - `https://global.frcapi.com/api/v2/captcha/siteverify` or `https://eu.frcapi.com/api/v2/captcha/siteverify` if you prefer to use EU endpoint -**JavaScript Path** - `EXT:friendlycaptcha_official/Resources/Public/JavaScript/lib/sdk@0.1.8-site.compat.min.js` \ No newline at end of file +**JavaScript Path** - `EXT:friendlycaptcha_official/Resources/Public/JavaScript/lib/sdk@0.1.26-site.compat.min.js` diff --git a/Documentation/v2.1.0_Update/Index.rst b/Documentation/v2.1.0_Update/Index.rst new file mode 100644 index 0000000..45c6b9b --- /dev/null +++ b/Documentation/v2.1.0_Update/Index.rst @@ -0,0 +1,18 @@ +.. include:: /Includes.rst.txt + + +**JavaScript Path**. _v2.1.0_update: + + +============ +Migration to FriendlyCaptcha v2.1.0 +============ + +If you’re currently using an earlier v2 version of the plugin and want to switch to **Friendly Captcha v2.1.0**: + +* After install the newest version, you need to change the **JavaScript Path** in TYPO3 backend - *Site Management*/*Sites* module +Change `EXT:friendlycaptcha_official/Resources/Public/JavaScript/lib/sdk@0.1.8-site.compat.min.js` to `EXT:friendlycaptcha_official/Resources/Public/JavaScript/lib/sdk@0.1.26-site.compat.min.js` + +Why to switch? +================= +Version 2.1.0 of the plugin uses the latest 0.1.26 version of the Friendly Captcha widget library, which includes improvements to accessibility. diff --git a/Resources/Public/JavaScript/lib/sdk@0.1.26-site.compat.min.js b/Resources/Public/JavaScript/lib/sdk@0.1.26-site.compat.min.js new file mode 100644 index 0000000..655c45c --- /dev/null +++ b/Resources/Public/JavaScript/lib/sdk@0.1.26-site.compat.min.js @@ -0,0 +1,7 @@ +function _typeof(e){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof(e)}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n-1},clear:function(){this.k.length=this.v.length=this.size=0},forEach:function(e,t){t&&(e=e.bind(t));for(var n=-1,r=this.size;++n!==r;)e(this.v[n],this.k[n],this)},entries:function(){var e=0,t=this;return{next:function(){return e!==t.size?{value:[t.k[e++],t.v[e]],done:!1}:{done:!0}}}},keys:function(){var e=0,t=this;return{next:function(){return e!==t.size?{value:t.k[e++],done:!1}:{done:!0}}}},values:function(){var e=0,t=this;return{next:function(){return e!==t.size?{value:t.v[e++],done:!1}:{done:!0}}}},toString:function(){return"[object Map]"}};WeakMap=Map=function(t){if(i=this.k=[],o=this.v=[],r=0,null!=t){if(a=Object(t),(n=+a.length)!=n)throw new TypeError("("+(t.toString||a.toString)()+") is not iterable");for(;n--;){if(!(a[n]instanceof Object))throw new TypeError("Iterator value "+a[n]+" is not an entry object");~e(i,a[n][0])||(i[r]=a[n][0],o[r++]=a[n][1])}i.reverse(),o.reverse()}this.size=r},Map.prototype=s,WeakSet=Set=function(t){if(i=this.k=this.v=[],r=0,null!=t){if(a=Object(t),(n=+a.length)!=n)throw new TypeError("("+(t.toString||a.toString)()+") is not iterable");for(;n--;)~e(i,a[n])||(i[r++]=a[n]);i.reverse()}this.size=r},Set.prototype={delete:function(n){return!!~(t=e(this.k,n))&&(this.k.splice(t,1),--this.size,!0)},add:function(n){return~(t=e(this.k,n))||(t=this.size++),this.k[t]=n,this},has:s.has,clear:s.clear,forEach:s.forEach,entries:s.entries,keys:s.keys,values:s.keys,toString:function(){return"[object Set]"}}}(),function(){function e(){return document.querySelectorAll(".frc-captcha")}function t(e,t,n){""===e.style[t]&&(e.style[t]=n)}function n(e){"loading"!==document.readyState?e():document.addEventListener("DOMContentLoaded",e)}function r(e){var t,n,r=new Promise((function(e,r){t=e,n=r}));return e&&e(t,n),{promise:r,resolve:t,reject:n}}function i(e,t){return 0===e.lastIndexOf(t,0)}function o(e){for(var t=[],n=Object.keys(e),r=encodeURIComponent,i=0;i1&&void 0!==arguments[1]?arguments[1]:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",n="",r=0;re[6]&&(e[6]=t))}}}function k(){return/Android/i.test(navigator.userAgent)}function _(e,t){var r,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=arguments.length>3?arguments[3]:void 0,a=b(),s=!1;return n((function(){(o=o||document.body)[V](e,(function(e){s&&!i||(r=e.timeStamp,s=!0)})),o[V](t,(function(e){s&&(a.add(e.timeStamp-r),s=!1)}))})),a.s}function S(e){for(var t=[],n=function(n){t.push(0),document[V](e[n],(function(){return t[n]++}))},r=0;r180?-360:n<-180?360:0)}function A(e){var t=e;return t?Z[t]&&(t=Z[t]):t=Z.global,a(t)}function M(){var e=document.querySelector('meta[name="frc-api-endpoint"]');if(e)return e.content;var t=document.currentScript;if(t){var n=t.dataset.frcApiEndpoint;if(n)return n}var r=document.querySelector(".frc-captcha[data-api-endpoint]");if(r){var i=r.dataset.apiEndpoint;if(i)return i}}var x,T,P,F=/^((?:\w+:)?\/\/([^\/]+))/,O=function(){function e(t){_classCallCheck(this,e),this.ready=!1,this.buffer=[],this.id=t.id,this.type=t.type,this.element=t.element,this.onReady=t.onReady,this.origin=a(t.element.src)}return _createClass(e,[{key:"send",value:function(e){this.ready?this.element.contentWindow.postMessage(e,this.origin):this.buffer.push(e)}},{key:"setReady",value:function(e){this.onReady(),this.ready=e,this.ready&&this.flush()}},{key:"flush",value:function(){for(var e=0;e1&&void 0!==arguments[1]?arguments[1]:d())("readonly",(function(t){return c(t.get(e))}))}(i,n.idb):n.mem.get(e);try{var o=sessionStorage.getItem(i);return null===o?void 0:o}catch(a){}return n.mem.get(e)}))}},{key:"set",value:function(e,t,n){var r=this;return this.setup().then((function(i){var o=r.storePrefix+"__"+e;if(n.p){if(i)return function(e,t){return(arguments.length>2&&void 0!==arguments[2]?arguments[2]:d())("readwrite",(function(n){return n.put(t,e),c(n.transaction)}))}(o,t,r.idb);void 0===t?r.mem.delete(e):r.mem.set(e,t)}else try{void 0===t?(r.mem.delete(e),sessionStorage.removeItem(o)):(r.mem.set(e,t),sessionStorage.setItem(o,t))}catch(a){}}))}},{key:"hasSA",value:function(){return this._hasSA}}]),e}(),X="undefined"!=typeof navigator&&void 0!==navigator.userAgentData,Y="FrcFrameId",q="frc-i-agent",H={cs:"Ověření proti botům",da:"Anti-robot verificering",nl:"Anti-robotverificatie",en:"Anti-Robot verification",fr:"Vérification Anti-Robot",de:"Anti-Roboter-Verifizierung",hu:"Anti-Robot ellenőrzés",it:"Verifica anti-robot",pl:"Weryfikacja antybotowa",pt:"Verificação Anti-Robô",ru:"Проверка на Анти-Робота",es:"Verificación anti-robot",sv:"Anti-Robot Verifiering",tr:"Anti-Robot doğrulaması"},U=["ar","he","fa","ur","ps","sd","yi"],B=function(){function e(t){var n=this;_classCallCheck(this,e),this.state="init",this.response=".UNINITIALIZED",this.focusEventPending=!1,this.isDestroyed=!1,this.id=t.id;var r=t.createOpts;if(this.e=r.element,this.ready=t.registered,!this.e)throw new Error("No element provided to mount widget under.");if(this.e.frcWidget=this,this.formFieldName=void 0===r.formFieldName?"frc-captcha-response":r.formFieldName,this.sitekey=r.sitekey,this._reset=t.callbacks.onReset,this._destroy=t.callbacks.onDestroy,this._trigger=t.callbacks.onTrigger,this.startMode=t.createOpts.startMode||"focus",null!==this.formFieldName){var i=document.createElement("input");i.type="hidden",i.style.display="none",i.name=this.formFieldName,this.hiddenFormEl=i,this.e.appendChild(i)}this.setState({response:".UNCONNECTED",state:"init"}),this.ready.then((function(){n.handleStartMode()}))}return _createClass(e,[{key:"handleStartMode",value:function(){var e,t=this;if("focus"!==this.startMode||this.focusEventPending||this.isDestroyed)"auto"===this.startMode&&this.trigger("auto");else{var n=function(e){for(;"FORM"!==e.tagName;)if(!(e=e.parentElement))return null;return e}(this.e);n&&(this.focusEventPending=!0,e=function(e){t.trigger("focus",{ev:e}),t.focusEventPending=!1},n.addEventListener("focusin",e,{once:!0,passive:!0}))}}},{key:"reset",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{trigger:"root"};if(this.isDestroyed)throw new Error("Can not reset destroyed widget.");this.setState({response:".RESET",state:"reset",resetTrigger:e.trigger}),this._reset(e),this.handleStartMode()}},{key:"destroy",value:function(){this.isDestroyed=!0,this.hiddenFormEl&&this.hiddenFormEl.remove(),this.hiddenFormEl=void 0,this.setState({response:".DESTROYED",state:"destroyed"}),this._destroy()}},{key:"trigger",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.isDestroyed)throw new Error("Can not start destroyed widget.");var n=function(e,t,n,r){var i=y(),o=n.getBoundingClientRect(),a={v:1,tt:e,pnow:i,sm:t,el:{bcr:[o.left,o.top,o.width,o.height],con:document.body.contains(n)},stack:(new Error).stack||"",we:!!window.event,weit:!!window.event&&!!window.event.isTrusted};return r&&(a.ev={ts:r.timeStamp,rt:!!r.relatedTarget,eot:!!r.explicitOriginalTarget,it:r.isTrusted}),a}(e,this.startMode,this.e,t.ev);this._trigger({trigger:n})}},{key:"start",value:function(){this.trigger("programmatic")}},{key:"setState",value:function(e){var t=this.state!==e.state;this.response=e.response,this.state=e.state,this.hiddenFormEl&&!1!==this.e.isConnected&&(this.hiddenFormEl.value=e.response),t&&this.dispatchWidgetEvent({name:"frc:widget.statechange",error:e.error}),"expired"===this.state?this.dispatchWidgetEvent({name:"frc:widget.expire"}):"completed"===this.state?this.dispatchWidgetEvent({name:"frc:widget.complete"}):"error"===this.state?this.dispatchWidgetEvent({name:"frc:widget.error",error:e.error}):"reset"===this.state&&this.dispatchWidgetEvent({name:"frc:widget.reset",trigger:e.resetTrigger})}},{key:"dispatchWidgetEvent",value:function(e){var t={response:this.response,state:this.state,id:this.id};w(t,e),function(e,t){var n;"function"==typeof window.CustomEvent?n=new CustomEvent(t.name,{bubbles:!0,detail:t}):(n=document.createEvent("CustomEvent")).initCustomEvent(t.name,!0,!1,t),e.dispatchEvent(n)}(this.e,t)}},{key:"addEventListener",value:function(e,t,n){this.e.addEventListener(e,t,n)}},{key:"removeEventListener",value:function(e,t,n){this.e.removeEventListener(e,t,n)}},{key:"getState",value:function(){return this.state}},{key:"getResponse",value:function(){return this.response}},{key:"getElement",value:function(){return this.e}}]),e}(),V="addEventListener",G=Math,K=function(){function e(t){_classCallCheck(this,e),this.rn=0,this.i=0,this.smel={n:0,ts:0,d:0};var r,i,o="mouse",a=this.smel,s=function(e){a.n||(a.fts=e.timeStamp,a.fxy=[e.clientX,e.clientY,e.screenX,e.screenY]),a.n++,e.type===o+"leave"&&(a.d+=e.timeStamp-a.ts),a.ts=e.timeStamp,a.xy=[e.clientX,e.clientY]},c=document;n((function(){var e=c.body;e[V](o+"enter",s),e[V](o+"leave",s)})),this.bh={onoff:{kdu:_("keydown","keyup"),cse:_("compositionstart","compositionend"),mdu:_(o+"down",o+"up"),mle:_(o+"leave",o+"enter"),med:_(o+"enter",o+"down",!0),semd:_("scrollend",o+"down",!0,c),se:_("scroll","scrollend",!1,c),pdc:_("pointerdown","pointercancel",!0),mmc:_(o+"move","click",!0),tse:_("touchstart","touchend"),fikd:_("focusin","keydown",!0)},nev:S([o+"out","pointercancel","focus","focusin","blur","visibilitychange","copy","paste","cut","contextmenu","click","auxclick","wheel","resize"]),nk:(r=[0,0,0,0,0,0,0,0],i={8:1,46:1,9:2,45:3,17:4,13:5,37:6,38:6,39:6,40:6,33:7,34:7},document[V]("keydown",(function(e){var t=e.keyCode;i[t]?r[i[t]]++:t>=112&&t<=123&&r[0]++})),r),mov:this.setupMovementMetrics(),dm:this.setupMotionMetrics(),do:this.setupOrientationMetrics()},this.dep=t.disableEvalPatching||!1,this.takeTraceRecords=function(e){var t=[],n=new Map,r=window,i=function(){try{var e=document.createElement("iframe");e.style.display="none",(document.body||document.head).appendChild(e);var t=e?e.contentWindow:0;return e.remove(),t||r}catch(n){return r}}(),o=Function.prototype.toString,a=function(){for(var e="function"==typeof this&&n.get(this),t=this===a?o:e||this,r=arguments.length,i=new Array(r),s=0;s=1e3&&(h=0,f=e),h<50){var n={d:e,pnow:y(),n:s,st:(i.Error||r.Error)("FriendlyCaptcha_DummyTrace").stack||""};t.length>2e4&&t.splice(0,1e3),t.push(n),h++}for(var o=arguments.length,a=new Array(o),c=0;c=200||n&&(n[0]&&e.tm.timeStamp===n[1]||!n[0]&&e.mm.timeStamp===n[1])){if(clearInterval(t),t=void 0,1===r.length)return s.ns++,void(r=[]);var c=r[0];i.add(n[1]-c[1]),o.add(E(n[2],c[2],n[3],c[3]));for(var u=1;ue.tm.timeStamp?0:1:e.mm||(g=1),g){var m=e.tm.touches[0];m&&r.push([1,e.tm.timeStamp,m.screenX,m.screenY])}else r.push([0,e.mm.timeStamp,e.mm.screenX,e.mm.screenY])}},u=-1;return n((function(){var n=document.body;n[V]("mousemove",(function(n){e.mm=n,void 0===t&&(c(),t=setInterval(c,50))})),n[V]("touchmove",(function(n){e.tm=n;var r=n.touches[0];if(r){var i=r.radiusX+1.234*r.radiusY;i!==u&&(u=i,e.rn++)}void 0===t&&(c(),t=setInterval(c,50))}))})),s}},{key:"setupMotionMetrics",value:function(){var e=b(),t=b(),n={n:0,ts:0,ac:e.s,rr:t.s,i:0,g:!1};return k()?(window[V]("devicemotion",(function(r){n.ts=r.timeStamp,n.i=r.interval,n.g=!r.acceleration;var i=r.acceleration||r.accelerationIncludingGravity;i&&e.add(C(i.x,i.y,i.z));var o=r.rotationRate;o&&t.add(C(o.alpha,o.beta,o.gamma))})),n):n}},{key:"setupOrientationMetrics",value:function(){var e,t=b(),n=b(),r={fts:0,ts:0,gd:t.s,bd:n.s};return k()?(window[V]("deviceorientation",(function(i){null!=i.gamma&&null!=i.beta&&null!=i.alpha&&(r.ts=i.timeStamp,r.a=i.alpha,r.b=i.beta,r.g=i.gamma,e?(t.add(R(i.gamma,r.g)),n.add(R(r.b,i.beta))):(r.fts=r.ts,e=!0))})),r):r}},{key:"gmm",value:function(){var e=this.mm;return e&&{xy:[e.clientX,e.clientY,e.screenX,e.screenY,e.offsetX,e.offsetY,e.pageX,e.pageY,e.movementX,e.movementY],ts:e.timeStamp}}},{key:"gtm",value:function(){var e=this.tm,t=e&&e.touches,n=t&&t[0];return e&&n&&{id:n.identifier,xy:[n.clientX,n.clientY,n.screenX,n.screenY,n.pageX,n.pageY],r:[n.radiusX,n.radiusX,n.rotationAngle,n.force],n:t.length,ts:e.timeStamp,rn:this.rn}}},{key:"get",value:function(e){var t=document.body,n=window,r=n.performance;return{v:1,i:++this.i,hl:history.length,fe:!!window.frameElement,dep:this.dep,wid:e,sc:parseInt(l(!1)),sid:f(),conv:0,t:{pnow:y(),pto:r&&r.timeOrigin||0,ts:Date.now()},dims:{d:[n.innerWidth,n.innerHeight,n.outerWidth,n.outerHeight,n.screenX,n.screenY,n.pageXOffset,n.pageYOffset,t.clientWidth,t.clientHeight],dpr:n.devicePixelRatio},mel:this.smel,mm:this.gmm(),tm:this.gtm(),bh:this.bh,stack:(new Error).stack||"",trc:this.takeTraceRecords()}}}]),e}(),Z={eu:"https://eu.frcapi.com",global:"https://global.frcapi.com"},J="FrcFrameId",Q=0,$=function(){function n(){var e,t=this,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(_classCallCheck(this,n),this.agents=new Map,this.agentState=new Map,this.widgets=new Map,this._attached=r(),this.attached=this._attached.promise,this.apiEndpoint=i.apiEndpoint,(P=P||new I).listen((function(e){return t.onReceiveMessage(e)})),this.bus=P,++Q>1&&console.warn("Multiple Friendly Captcha SDKs created, this is not recommended. Please use a single SDK instance."),this.signals=function(e){return T||(T=new K(e))}({disableEvalPatching:i.disableEvalPatching||(e=document.querySelector('meta[name="frc-disable-eval-patching"]'),!!e&&!!e.content)}),i.startAgent){var o=A(this.apiEndpoint||M());this.ensureAgentIFrame(o)}this.setupPeriodicRefresh()}return _createClass(n,[{key:"onReceiveMessage",value:function(e){if("root_set_response"===e.type){var t=this.widgets.get(e.widget_id);if(!t)return void(1===Q&&console.warn("Received set response message for widget ".concat(e.widget_id," that doesn't exist")));t.setState(e)}else if(i(e.type,"root_store"))this.handleStoreMessage(e);else if("root_signals_get"===e.type)this.handleSignalsGetMessage(e);else if("widget_language_change"===e.type)this.handleWidgetLanguageChange(e);else if("widget_reset"===e.type){var n=this.widgets.get(e.from_id);if(!n)return void(1===Q&&console.warn("Received reset message for widget ".concat(e.from_id," that doesn't exist")));n.reset({trigger:"widget"})}}},{key:"handleWidgetLanguageChange",value:function(e){var t=this.widgets.get(e.from_id);if(t){var n=t.getElement(),r=n.querySelector("iframe");r&&(r.title=g(e.language));var i=n.querySelector(".frc-banner");if(i){var o=i.style;m(e.language)?(o.left="6px",o.right="auto"):(o.left="auto",o.right="6px")}}else 1===Q&&console.warn("Received language change message for widget ".concat(e.from_id," that doesn't exist"))}},{key:"handleSignalsGetMessage",value:function(e){var t=this.signals.get(e.widget_id);this.bus.send({type:"root_signals_get_reply",from_id:"",to_id:e.from_id,_frc:1,rid:e.rid,value:t})}},{key:"handleStoreMessage",value:function(e){var t=this,n=e.from_id,r=this.agentState.get(n);r?"root_store_get"===e.type?r.store.get(e.key,{p:e.p}).then((function(i){t.bus.send({type:"root_store_get_reply",from_id:"",to_id:n,_frc:1,rid:e.rid,value:i,sa:r.store.hasSA()})})):"root_store_set"===e.type&&r.store.set(e.key,e.value,{p:e.p}).then((function(){t.bus.send({type:"root_store_set_reply",from_id:"",to_id:n,_frc:1,rid:e.rid,sa:r.store.hasSA()})})):console.error("Store not found ".concat(n))}},{key:"ensureAgentIFrame",value:function(e){for(var t=this,n=e+"/api/v2/captcha/agent",r=document.getElementsByClassName(q),i=0;i4)return console.error("[Friendly Captcha] Failed to load agent iframe after 4 retries."),d.remove(),void t.agents.delete(e);console.warn("[Friendly Captcha] Retrying agent iframe load."),d.src+="&retry="+h++,n()}}))}(),u}},{key:"setupPeriodicRefresh",value:function(){var e=this,t=1;setInterval((function(){var n="&expire="+t++;e.agents.forEach((function(e){e.src+=n})),e.widgets.forEach((function(e){e.getElement().querySelector("iframe").src+=n}))}),1296e5)}},{key:"getRetryTimeout",value:function(e){return 1e3*Math.pow(e,2)+4e3}},{key:"attach",value:function(t){void 0===t&&(t=e()),Array.isArray(t)||t instanceof NodeList||(t=[t]);for(var n=[],r=0;r4)return console.error("[Friendly Captcha] Failed to load widget iframe after 4 retries."),b.setState({state:"error",response:".ERROR",error:{code:"network_error",detail:"Widget load timeout, stopped retrying"}}),C.borderColor="#f00",C.fontSize="12px",void(E.textContent="Anti-Robot check failed to connect to page or ".concat(a(S.src),"\nCheck your connection and try again."));C.backgroundColor="#fee",C.color="#222",E.textContent="Anti-Robot check took too long to connect.\n\nRetrying... (".concat(R,")"),console.warn("[Friendly Captcha] Retrying widget ".concat(u," iframe load.")),b.setState({state:"error",response:".ERROR",error:{code:"network_error",detail:"Widget load timeout, will retry."}}),S.src+="&retry="+R++,t()}else"registered"===n&&(e.element.removeChild(E),S.style.display="")}))}(),y.resolve(),b}},{key:"getAllWidgets",value:function(){var e=[];return this.widgets.forEach((function(t){e.push(t)})),e}},{key:"getWidgetById",value:function(e){return this.widgets.get(e)}},{key:"clear",value:function(){this.widgets.forEach((function(e){e.destroy()})),this.agents.forEach((function(e){e.remove()})),this.agents.clear()}}]),n}();window.frcaptcha=new $,n((function(){var t=e();window.frcaptcha.attach(t)}))}(); +/*! + * Copyright (c) Friendly Captcha GmbH 2023. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + */ \ No newline at end of file diff --git a/Resources/Public/JavaScript/lib/sdk@0.1.8-site.compat.min.js b/Resources/Public/JavaScript/lib/sdk@0.1.8-site.compat.min.js deleted file mode 100644 index 5e639b8..0000000 --- a/Resources/Public/JavaScript/lib/sdk@0.1.8-site.compat.min.js +++ /dev/null @@ -1,7 +0,0 @@ -function ownKeys(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function _objectSpread(e){for(var t=1;te.length)&&(t=e.length);for(var n=0,r=new Array(t);n-1},clear:function(){this.k.length=this.v.length=this.size=0},forEach:function(e,t){t&&(e=e.bind(t));for(var n=-1,r=this.size;++n!==r;)e(this.v[n],this.k[n],this)},entries:function(){var e=0,t=this;return{next:function(){return e!==t.size?{value:[t.k[e++],t.v[e]],done:!1}:{done:!0}}}},keys:function(){var e=0,t=this;return{next:function(){return e!==t.size?{value:t.k[e++],done:!1}:{done:!0}}}},values:function(){var e=0,t=this;return{next:function(){return e!==t.size?{value:t.v[e++],done:!1}:{done:!0}}}},toString:function(){return"[object Map]"}};WeakMap=Map=function(t){if(i=this.k=[],o=this.v=[],r=0,null!=t){if(s=Object(t),(n=+s.length)!=n)throw new TypeError("("+(t.toString||s.toString)()+") is not iterable");for(;n--;){if(!(s[n]instanceof Object))throw new TypeError("Iterator value "+s[n]+" is not an entry object");~e(i,s[n][0])||(i[r]=s[n][0],o[r++]=s[n][1])}i.reverse(),o.reverse()}this.size=r},Map.prototype=a,WeakSet=Set=function(t){if(i=this.k=this.v=[],r=0,null!=t){if(s=Object(t),(n=+s.length)!=n)throw new TypeError("("+(t.toString||s.toString)()+") is not iterable");for(;n--;)~e(i,s[n])||(i[r++]=s[n]);i.reverse()}this.size=r},Set.prototype={delete:function(n){return!!~(t=e(this.k,n))&&(this.k.splice(t,1),--this.size,!0)},add:function(n){return~(t=e(this.k,n))||(t=this.size++),this.k[t]=n,this},has:a.has,clear:a.clear,forEach:a.forEach,entries:a.entries,keys:a.keys,values:a.keys,toString:function(){return"[object Set]"}}}(),function(){function e(){return document.querySelectorAll(".frc-captcha")}function t(e,t,n){""===e.style[t]&&(e.style[t]=n)}function n(e){var t,n,r=new Promise((function(e,r){t=e,n=r}));return e&&e(t,n),{promise:r,resolve:t,reject:n}}function r(e,t){return 0===e.lastIndexOf(t,0)}function i(e){for(var t=[],n=Object.keys(e),r=encodeURIComponent,i=0;i1&&void 0!==arguments[1]?arguments[1]:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",n="",r=0;re[6]&&(e[6]=t))}}}function p(e,t){var n,r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:document.body,o=m(),s=!1;return i[Y](e,(function(e){s&&!r||(n=e.timeStamp,s=!0)})),i[Y](t,(function(e){s&&(o.add(e.timeStamp-n),s=!1)})),o.s}function v(e){for(var t=[],n=function(n){t.push(0),document[Y](e[n],(function(){return t[n]++}))},r=0;r180?-360:n<-180?360:0)}function _(e){return e?K[e]||e:K.global}var k,S,E,C,P=/^((?:\w+:)?\/\/([^\/]+))/,R=function(){function e(t){_classCallCheck(this,e),this.ready=!1,this.buffer=[],this.id=t.id,this.type=t.type,this.element=t.element,this.onReady=t.onReady,this.origin=o(t.element.src)}return _createClass(e,[{key:"send",value:function(e){this.ready?this.element.contentWindow.postMessage(e,this.origin):this.buffer.push(e)}},{key:"setReady",value:function(e){this.onReady(),this.ready=e,this.ready&&this.flush()}},{key:"flush",value:function(){for(var e=0;e1&&void 0!==arguments[1]?arguments[1]:u())("readonly",(function(t){return a(t.get(e))}))}(i,n.idb):n.mem.get(e);try{var o=sessionStorage.getItem(i);return null===o?void 0:o}catch(s){}return n.mem.get(e)}))}},{key:"set",value:function(e,t,n){var r=this;return this.setup().then((function(i){var o=r.storePrefix+"__"+e;if(n.p){if(i)return function(e,t){return(arguments.length>2&&void 0!==arguments[2]?arguments[2]:u())("readwrite",(function(n){return n.put(t,e),a(n.transaction)}))}(o,t,r.idb);void 0===t?r.mem.delete(e):r.mem.set(e,t)}else try{void 0===t?(r.mem.delete(e),sessionStorage.removeItem(o)):(r.mem.set(e,t),sessionStorage.setItem(o,t))}catch(s){}}))}},{key:"hasSA",value:function(){return this._hasSA}}]),e}(),I="undefined"!=typeof navigator&&void 0!==navigator.userAgentData,D="FrcFrameId",W="frc-i-agent",N=function(){function e(t){var n=this;_classCallCheck(this,e),this.state="init",this.response=".UNINITIALIZED",this.focusEventPending=!1,this.isDestroyed=!1,this.id=t.id;var r=t.createOpts;if(this.e=r.element,this.ready=t.registered,!this.e)throw new Error("No element provided to mount widget under.");if(this.e.frcWidget=this,this.formFieldName=void 0===r.formFieldName?"frc-captcha-response":r.formFieldName,this.sitekey=r.sitekey,this._reset=t.callbacks.onReset,this._destroy=t.callbacks.onDestroy,this._trigger=t.callbacks.onTrigger,this.startMode=t.createOpts.startMode||"focus",null!==this.formFieldName){var i=document.createElement("input");i.type="hidden",i.style.display="none",i.name=this.formFieldName,this.hiddenFormEl=i,this.e.appendChild(i)}this.setState({response:".UNCONNECTED",state:"init"}),this.ready.then((function(){n.handleStartMode()}))}return _createClass(e,[{key:"handleStartMode",value:function(){var e,t=this;if("focus"!==this.startMode||this.focusEventPending||this.isDestroyed)"auto"===this.startMode&&this.trigger("auto");else{var n=function(e){for(;"FORM"!==e.tagName;)if(!(e=e.parentElement))return null;return e}(this.e);n&&(this.focusEventPending=!0,e=function(e){t.trigger("focus",{ev:e}),t.focusEventPending=!1},n.addEventListener("focusin",e,{once:!0,passive:!0}))}}},{key:"reset",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{trigger:"root"};if(this.isDestroyed)throw new Error("Can not reset destroyed widget.");this.setState({response:".RESET",state:"reset",resetTrigger:e.trigger}),this._reset(e),this.handleStartMode()}},{key:"destroy",value:function(){var e;this.isDestroyed=!0,null===(e=this.hiddenFormEl)||void 0===e||e.remove(),this.hiddenFormEl=void 0,this.setState({response:".DESTROYED",state:"destroyed"}),this._destroy()}},{key:"trigger",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.isDestroyed)throw new Error("Can not start destroyed widget.");var n=function(e,t,n,r){var i=h(),o=n.getBoundingClientRect(),s={v:1,tt:e,pnow:i,sm:t,el:{bcr:[o.left,o.top,o.width,o.height],con:document.body.contains(n)},stack:(new Error).stack||"",we:!!window.event,weit:!!window.event&&!!window.event.isTrusted};return r&&(s.ev={ts:r.timeStamp,rt:!!r.relatedTarget,eot:!!r.explicitOriginalTarget,it:r.isTrusted}),s}(e,this.startMode,this.e,t.ev);this._trigger({trigger:n})}},{key:"start",value:function(){this.trigger("programmatic")}},{key:"setState",value:function(e){var t=this.state!==e.state;this.response=e.response,this.state=e.state,this.hiddenFormEl&&!1!==this.e.isConnected&&(this.hiddenFormEl.value=e.response),t&&this.dispatchWidgetEvent({name:"frc:widget.statechange",error:e.error}),"expired"===this.state?this.dispatchWidgetEvent({name:"frc:widget.expire"}):"completed"===this.state?this.dispatchWidgetEvent({name:"frc:widget.complete"}):"error"===this.state?this.dispatchWidgetEvent({name:"frc:widget.error",error:e.error}):"reset"===this.state&&this.dispatchWidgetEvent({name:"frc:widget.reset",trigger:e.resetTrigger})}},{key:"dispatchWidgetEvent",value:function(e){var t={response:this.response,state:this.state,id:this.id};g(t,e),function(e,t){var n;"function"==typeof window.CustomEvent?n=new CustomEvent(t.name,{bubbles:!0,detail:t}):(n=document.createEvent("CustomEvent")).initCustomEvent(t.name,!0,!1,t),e.dispatchEvent(n)}(this.e,t)}},{key:"addEventListener",value:function(e,t,n){this.e.addEventListener(e,t,n)}},{key:"removeEventListener",value:function(e,t,n){this.e.removeEventListener(e,t,n)}},{key:"getState",value:function(){return this.state}},{key:"getResponse",value:function(){return this.response}},{key:"getElement",value:function(){return this.e}}]),e}(),L=function(e){return"function"==typeof e},X=function(){var e=[],t=new Map,n=window,r=function(){try{var e=document.createElement("iframe");e.style.display="none",(document.body||document.head).appendChild(e);var t=e?e.contentWindow:0;return e.remove(),t||n}catch(r){return n}}(),i=Function.prototype.toString,o=function(){if(!L(this)){for(var e=!!L(this)&&t.get(this),n=this===o?i:e||this,r=arguments.length,s=new Array(r),a=0;a=112&&r<=123&&t[0]++})),t),mov:this.setupMovementMetrics(),dm:this.setupMotionMetrics(),do:this.setupOrientationMetrics()}}return _createClass(e,[{key:"setupMovementMetrics",value:function(){var e=this,t=void 0,n=[],r=m(),i=m(),o=m(),s={t:r.s,v:o.s,d:i.s,ns:0},a=document.body,c=function(){var a=n[n.length-1];if(n.length>=200||a&&(a[0]&&e.tm.timeStamp===a[1]||!a[0]&&e.mm.timeStamp===a[1])){if(clearInterval(t),t=void 0,1===n.length)return s.ns++,void(n=[]);var c=n[0];r.add(a[1]-c[1]),i.add(y(a[2],c[2],a[3],c[3]));for(var u=1;ue.tm.timeStamp?0:1:e.mm||(g=1),g){var m=e.tm.touches[0];m&&n.push([1,e.tm.timeStamp,m.screenX,m.screenY])}else n.push([0,e.mm.timeStamp,e.mm.screenX,e.mm.screenY])}};a[Y]("mousemove",(function(n){e.mm=n,void 0===t&&(c(),t=setInterval(c,50))}));var u=-1;return a[Y]("touchmove",(function(n){e.tm=n;var r=n.touches[0];if(r){var i=r.radiusX+1.234*r.radiusY;i!==u&&(u=i,e.rn++)}void 0===t&&(c(),t=setInterval(c,50))})),s}},{key:"setupMotionMetrics",value:function(){var e=m(),t=m(),n={n:0,ts:0,ac:e.s,rr:t.s,i:0,g:!1};return window[Y]("devicemotion",(function(r){n.ts=r.timeStamp,n.i=r.interval,n.g=!r.acceleration;var i=r.acceleration||r.accelerationIncludingGravity;i&&e.add(w(i.x,i.y,i.z));var o=r.rotationRate;o&&t.add(w(o.alpha,o.beta,o.gamma))})),n}},{key:"setupOrientationMetrics",value:function(){var e,t=m(),n=m(),r={fts:0,ts:0,gd:t.s,bd:n.s};return window[Y]("deviceorientation",(function(i){null!=i.gamma&&null!=i.beta&&null!=i.alpha&&(r.ts=i.timeStamp,r.a=i.alpha,r.b=i.beta,r.g=i.gamma,e?(t.add(b(i.gamma,r.g)),n.add(b(r.b,i.beta))):(r.fts=r.ts,e=!0))})),r}},{key:"gmm",value:function(){var e=this.mm;return e&&{xy:[e.clientX,e.clientY,e.screenX,e.screenY,e.offsetX,e.offsetY,e.pageX,e.pageY,e.movementX,e.movementY],ts:e.timeStamp}}},{key:"gtm",value:function(){var e=this.tm,t=e&&e.touches,n=t&&t[0];return e&&n&&{id:n.identifier,xy:[n.clientX,n.clientY,n.screenX,n.screenY,n.pageX,n.pageY],r:[n.radiusX,n.radiusX,n.rotationAngle,n.force],n:t.length,ts:e.timeStamp,rn:this.rn}}},{key:"get",value:function(e){var t=document.body,n=window,r=n.performance;return{v:1,i:++this.i,hl:history.length,fe:!!window.frameElement,wid:e,sc:parseInt(d(!1)),sid:l(),conv:0,t:{pnow:h(),pto:r&&r.timeOrigin||0,ts:Date.now()},dims:{d:[n.innerWidth,n.innerHeight,n.outerWidth,n.outerHeight,n.screenX,n.screenY,n.pageXOffset,n.pageYOffset,t.clientWidth,t.clientHeight],dpr:n.devicePixelRatio},mel:this.smel,mm:this.gmm(),tm:this.gtm(),bh:this.bh,stack:(new Error).stack||"",trc:X()}}}]),e}(),K={eu:"https://eu.frcapi.com/api/v2/captcha",global:"https://global.frcapi.com/api/v2/captcha"},q="FrcFrameId",H=0,B=function(){function a(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};_classCallCheck(this,a),this.agents=new Map,this.agentState=new Map,this.widgets=new Map,this._attached=n(),this.attached=this._attached.promise,this.signals=S||(S=new U),this.baseURL=_(t.apiEndpoint||function(){var e=document.querySelector('meta[name="frc-api-endpoint"]');if(e)return e.content;var t=document.currentScript;if(t){var n=t.dataset.frcApiEndpoint;if(n)return n}var r=document.querySelector(".frc-captcha[data-api-endpoint]");if(r){var i=r.dataset.apiEndpoint;if(i)return i}}()),(E=E||new M).addOrigin(o(this.baseURL)),E.listen((function(t){return e.onReceiveMessage(t)})),this.bus=E,++H>1&&console.warn("Multiple Friendly Captcha SDKs created, this is not recommended. Please use a single SDK instance."),!1!==t.startAgent&&this.ensureAgentIFrame(),this.setupPeriodicRefresh()}return _createClass(a,[{key:"onReceiveMessage",value:function(e){if("root_set_response"===e.type){var t=this.widgets.get(e.widget_id);if(!t)return void(1===H&&console.warn("Received set response message for widget ".concat(e.widget_id," that doesn't exist")));t.setState(e)}else if(r(e.type,"root_store"))this.handleStoreMessage(e);else if("root_signals_get"===e.type)this.handleSignalsGetMessage(e);else if("widget_reset"===e.type){var n=this.widgets.get(e.from_id);if(!n)return void(1===H&&console.warn("Received reset message for widget ".concat(e.from_id," that doesn't exist")));n.reset({trigger:"widget"})}}},{key:"handleSignalsGetMessage",value:function(e){var t=this.signals.get(e.widget_id);this.bus.send({type:"root_signals_get_reply",from_id:"",to_id:e.from_id,_frc:1,rid:e.rid,value:t})}},{key:"handleStoreMessage",value:function(e){var t=this,n=e.from_id,r=this.agentState.get(n);r?"root_store_get"===e.type?r.store.get(e.key,{p:e.p}).then((function(i){t.bus.send({type:"root_store_get_reply",from_id:"",to_id:n,_frc:1,rid:e.rid,value:i,sa:r.store.hasSA()})})):"root_store_set"===e.type&&r.store.set(e.key,e.value,{p:e.p}).then((function(){t.bus.send({type:"root_store_set_reply",from_id:"",to_id:n,_frc:1,rid:e.rid,sa:r.store.hasSA()})})):console.error("Store not found ".concat(n))}},{key:"getAPIUrls",value:function(e){if(e&&"string"!=typeof e)return{agent:e.agent,widget:e.widget};var t=e||this.baseURL;return{agent:t+"/agent",widget:t+"/widget"}}},{key:"ensureAgentIFrame",value:function(e){for(var t=this,n=this.getAPIUrls(e).agent,r=o(n),a=document.getElementsByClassName(W),c=0;c15)return console.error("[Friendly Captcha] Failed to load agent iframe after 15 retries."),h.remove(),void t.agents.delete(r);console.warn("[Friendly Captcha] Retrying agent iframe load."),h.src+="&retry="+g++,e()}}))}(),f}},{key:"setupPeriodicRefresh",value:function(){var e=this,t=1;setInterval((function(){var n="&expire="+t++;e.agents.forEach((function(e){e.src+=n})),e.widgets.forEach((function(e){e.getElement().querySelector("iframe").src+=n}))}),1296e5)}},{key:"attach",value:function(t){void 0===t&&(t=e()),Array.isArray(t)||t instanceof NodeList||(t=[t]);for(var n=[],r=0;r4)return console.error("[Friendly Captcha] Failed to load widget iframe after 4 retries."),v.setState({state:"error",response:".ERROR",error:{code:"network_error",detail:"Widget load timeout, stopped retrying"}}),E.borderColor="#f00",E.fontSize="12px",void(S.textContent="Anti-Robot check failed to connect to page or ".concat(o(k.src),"\nCheck your connection and try again."));E.backgroundColor="#fee",E.color="#222",S.textContent="Anti-Robot check took too long to connect.\n\nRetrying... (".concat(C,")"),console.warn("[Friendly Captcha] Retrying widget ".concat(u," iframe load.")),v.setState({state:"error",response:".ERROR",error:{code:"network_error",detail:"Widget load timeout, will retry."}}),k.src+="&retry="+C++,t()}else"registered"===n&&(e.element.removeChild(S),k.style.display="")}))}(),p.resolve(),v}},{key:"getAllWidgets",value:function(){var e=[];return this.widgets.forEach((function(t){e.push(t)})),e}},{key:"getWidgetById",value:function(e){return this.widgets.get(e)}},{key:"clear",value:function(){this.widgets.forEach((function(e){e.destroy()})),this.agents.forEach((function(e){e.remove()})),this.agents.clear()}}]),a}();window.frcaptcha=new B,C=function(){var t=e();window.frcaptcha.attach(t)},"loading"!==document.readyState?C():document.addEventListener("DOMContentLoaded",C)}(); -/*! - * Copyright (c) Friendly Captcha GmbH 2023. - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ \ No newline at end of file diff --git a/Tests/Unit/ViewHelpers/ConfigurationViewHelperTest.php b/Tests/Unit/ViewHelpers/ConfigurationViewHelperTest.php index c2f9951..2977b18 100644 --- a/Tests/Unit/ViewHelpers/ConfigurationViewHelperTest.php +++ b/Tests/Unit/ViewHelpers/ConfigurationViewHelperTest.php @@ -24,7 +24,7 @@ public function viewHelperReturnsProperConfiguration(): void 'siteKey' => '1234', 'verifyUrl' => 'https://verify,https://verify2', 'useEuPuzzleEndpoint' => false, - 'jsPath' => 'EXT:friendlycaptcha_official/Resources/Public/JavaScript/lib/sdk@0.1.8-site.compat.min.js', + 'jsPath' => 'EXT:friendlycaptcha_official/Resources/Public/JavaScript/lib/sdk@0.1.26-site.compat.min.js', 'enabled' => true, ], $configurationViewHelper->render()); } diff --git a/ext_emconf.php b/ext_emconf.php index e61f115..223e033 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -17,5 +17,5 @@ ], ], 'state' => 'stable', - 'version' => '1.0.1', -]; \ No newline at end of file + 'version' => '2.1.0', +];