UNPKG

vue-programmatic-invisible-google-recaptcha

Version:

A simple invisible Google reCAPTCHA component focused solely on programmatic invocation.

1 lines 8.63 kB
!function(t){function e(e){for(var i,s,c=e[0],o=e[1],l=e[2],p=0,h=[];p<c.length;p++)s=c[p],n[s]&&h.push(n[s][0]),n[s]=0;for(i in o)Object.prototype.hasOwnProperty.call(o,i)&&(t[i]=o[i]);for(u&&u(e);h.length;)h.shift()();return r.push.apply(r,l||[]),a()}function a(){for(var t,e=0;e<r.length;e++){for(var a=r[e],i=!0,c=1;c<a.length;c++){var o=a[c];0!==n[o]&&(i=!1)}i&&(r.splice(e--,1),t=s(s.s=a[0]))}return t}var i={},n={0:0},r=[];function s(e){if(i[e])return i[e].exports;var a=i[e]={i:e,l:!1,exports:{}};return t[e].call(a.exports,a,a.exports,s),a.l=!0,a.exports}s.m=t,s.c=i,s.d=function(t,e,a){s.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:a})},s.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},s.t=function(t,e){if(1&e&&(t=s(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var a=Object.create(null);if(s.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)s.d(a,i,function(e){return t[e]}.bind(null,i));return a},s.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return s.d(e,"a",e),e},s.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},s.p="./";var c=window.webpackJsonp=window.webpackJsonp||[],o=c.push.bind(c);c.push=e,c=c.slice();for(var l=0;l<c.length;l++)e(c[l]);var u=o;r.push([7,1]),a()}([,function(t,e,a){},function(t,e,a){},,,function(t,e,a){"use strict";var i={name:"vue-programmatic-invisible-google-recaptcha",props:{sitekey:{type:String,required:!0},elementId:{type:String,required:!0},showBadgeMobile:{type:Boolean,default:!0},showBadgeDesktop:{type:Boolean,default:!0},badgePosition:{type:String}},data:function(){return{gAssignedId:null,captchaReady:!1,checkInterval:null,checkIntervalRunCount:0}},computed:{styleClassObject:function(){return{"g-recaptcha--left":"left"===this.badgePosition,"g-recaptcha--mobile-hidden":!this.showBadgeMobile,"g-recaptcha--desktop-hidden":!this.showBadgeDesktop}}},methods:{execute:function(){window.grecaptcha.execute(this.gAssignedId)},reset:function(){window.grecaptcha.reset(this.gAssignedId)},callback:function(t){this.$emit("recaptcha-callback",t),this.reset()},render:function(){var t=this;this.gAssignedId=window.grecaptcha.render(this.elementId,{sitekey:this.sitekey,size:"invisible",callback:function(e){t.callback(e)},"expired-callback":function(){t.reset()}})},init:function(){var t=this;this.checkInterval=setInterval(function(){t.checkIntervalRunCount++,window.grecaptcha&&window.grecaptcha.hasOwnProperty("render")&&(t.captchaReady=!0)},1e3)}},watch:{captchaReady:function(t){t&&(clearInterval(this.checkInterval),this.render())}},mounted:function(){this.init()}},n=(a(9),a(3)),r=Object(n.a)(i,function(){var t=this.$createElement;return(this._self._c||t)("div",{staticClass:"g-recaptcha",class:this.styleClassObject,attrs:{id:this.elementId,"data-sitekey":this.sitekey}})},[],!1,null,null,null);e.a=r.exports},function(t,e,a){"use strict";(function(t){var i=a(5);var n={install:function t(e){t.installed||(t.installed=!0,e.component("VueProgrammaticInvisibleGoogleRecaptcha",i.a))}},r=null;"undefined"!=typeof window?r=window.Vue:void 0!==t&&(r=t.Vue),r&&r.use(n),e.a=i.a}).call(this,a(0))},function(t,e,a){t.exports=a(13)},function(t,e,a){"use strict";var i=a(1);a.n(i).a},function(t,e,a){"use strict";var i=a(2);a.n(i).a},,,,function(t,e,a){"use strict";a.r(e);var i=a(4),n={name:"app",data:function(){return{recaptchaToken:null}},methods:{submitButtonClicked:function(){this.$refs.invisibleRecaptcha1.execute()},recaptchaCallback:function(t){console.log(t),this.recaptchaToken=t},removeToken:function(){this.recaptchaToken=null}}},r=(a(8),a(3)),s=Object(r.a)(n,function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("div",{attrs:{id:"app"}},[a("a",{staticClass:"github-corner",attrs:{href:"https://github.com/promosis/vue-programmatic-invisible-google-recaptcha",target:"_blank","aria-label":"View source on Github"}},[a("svg",{staticStyle:{fill:"#F46428",color:"#fff",position:"absolute",top:"0",border:"0",right:"0"},attrs:{width:"80",height:"80",viewBox:"0 0 250 250","aria-hidden":"true"}},[a("path",{attrs:{d:"M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"}}),a("path",{staticClass:"octo-arm",staticStyle:{"transform-origin":"130px 106px"},attrs:{d:"M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2",fill:"currentColor"}}),a("path",{staticClass:"octo-body",attrs:{d:"M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z",fill:"currentColor"}})])]),t._v(" "),t._m(0),t._v(" "),t._m(1),t._v(" "),t._m(2),t._v(" "),a("div",{staticClass:"container"},[a("div",{staticClass:"row"},[a("div",{staticClass:"col-lg-6"},[a("div",{staticClass:"col-lg-12"},[a("button",{staticClass:"btn btn-primary mx-auto d-block mb-4",on:{click:t.submitButtonClicked}},[t._v("Submit Button")]),t._v(" "),a("p",[t._v("Click the submit button to trigger the reCAPTCHA and get a token. You can attach this to any action you like. Multiple reCAPTCHAs per page is supported.")])]),t._v(" "),a("div",{staticClass:"col-lg-12"},[a("p",[a("a",{attrs:{href:"javascript:void(0)"},on:{click:function(e){return e.preventDefault(),t.$refs.invisibleRecaptcha1.reset()}}},[t._v("Click here")]),t._v(" to refresh the recaptcha if you're having trouble. If you continue having trouble, please reload the page and try again.")]),t._v(" "),a("p",[a("a",{attrs:{href:"javascript:void(0)"},on:{click:function(e){return e.preventDefault(),t.removeToken(e)}}},[t._v("Click here")]),t._v(" to remove the recieved token from this parent component.")])])]),t._v(" "),a("div",{staticClass:"col-lg-6"},[a("div",{staticClass:"col-lg-12"},[a("p",[t._v("Sometimes, Google will give you a few challenges before they give you a token. Each time the token is recieved it'll be printed here: ")]),t._v(" "),a("div",{staticClass:"alert alert-primary tokenDisplay",attrs:{role:"alert"}},[a("span",[t._v(t._s(t.recaptchaToken?t.recaptchaToken:"Nothing yet..."))])])])])])]),t._v(" "),a("vue-programmatic-invisible-google-recaptcha",{ref:"invisibleRecaptcha1",attrs:{sitekey:"6Lez6G4UAAAAAIWdTdyt__nFHp2q9aMci9Q3B1aq",elementId:"invisibleRecaptcha1",badgePosition:"left",showBadgeMobile:!1,showBadgeDesktop:!0},on:{"recaptcha-callback":t.recaptchaCallback}})],1)},[function(){var t=this.$createElement,e=this._self._c||t;return e("div",{staticClass:"container py-4"},[e("div",{staticClass:"row justify-content-center"},[e("div",{staticClass:"col-lg-12 text-center"},[e("h3",[this._v("vue-programmatic-invisible-google-recaptcha")])])])])},function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("div",{staticClass:"container pt-3 pb-4"},[a("div",{staticClass:"row justify-content-center"},[a("div",{staticClass:"col-lg-6"},[a("span",{staticClass:"badge badge-primary mb-1"},[t._v("install")]),t._v(" "),a("div",{staticClass:"install-text"},[t._v("npm i vue-programmatic-invisible-google-recaptcha")])]),t._v(" "),a("div",{staticClass:"col-lg-4"},[a("div",{staticClass:"list-group"},[a("a",{staticClass:"list-group-item list-group-item-action",attrs:{href:"https://github.com/promosis/vue-programmatic-invisible-google-recaptcha",target:"_blank"}},[t._v("View on GitHub")]),t._v(" "),a("a",{staticClass:"list-group-item list-group-item-action",attrs:{href:"https://www.npmjs.com/package/vue-programmatic-invisible-google-recaptcha",target:"_blank"}},[t._v("View on NPM")]),t._v(" "),a("a",{staticClass:"list-group-item list-group-item-action list-group-item-success",attrs:{href:"https://promosis.com",target:"_blank"}},[t._v("Visit Promosis.com")])])])])])},function(){var t=this.$createElement,e=this._self._c||t;return e("div",{staticClass:"container py-3"},[e("div",{staticClass:"row justify-content-center"},[e("div",{staticClass:"col-lg-10"},[e("hr")])])])}],!1,null,null,null).exports,c=a(6);i.a.component("vue-programmatic-invisible-google-recaptcha",c.a),new i.a({el:"#app",render:function(t){return t(s)}})}]);