@trustcomponent/trustcaptcha-frontend
Version:
TrustCaptcha – Privacy-first CAPTCHA solution. GDPR-compliant, bot protection made in Europe.
1 lines • 2.43 kB
JavaScript
var __awaiter=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(a,o){function i(t){try{u(r.next(t))}catch(t){o(t)}}function c(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?a(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(i,c)}u((r=r.apply(t,e||[])).next())}))},__generator=this&&this.__generator||function(t,e){var n,r,a,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(u){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(o=0)),o;)try{if(n=1,r&&(a=2&c[0]?r.return:c[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,c[1])).done)return a;switch(r=0,a&&(c=[2&c[0],a.value]),c[0]){case 0:case 1:a=c;break;case 4:return o.label++,{value:c[1],done:!1};case 5:o.label++,r=c[1],c=[0];continue;case 7:c=o.ops.pop(),o.trys.pop();continue;default:if(!(a=o.trys,(a=a.length>0&&a[a.length-1])||6!==c[0]&&2!==c[0])){o=0;continue}if(3===c[0]&&(!a||c[1]>a[0]&&c[1]<a[3])){o.label=c[1];break}if(6===c[0]&&o.label<a[1]){o.label=a[1],a=c;break}if(a&&o.label<a[2]){o.label=a[2],o.ops.push(c);break}a[2]&&o.ops.pop(),o.trys.pop();continue}c=e.call(t,o)}catch(t){c=[6,t],r=0}finally{n=a=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,u])}}},_this=this;self.addEventListener("message",(function(t){return __awaiter(_this,void 0,void 0,(function(){var e,n,r,a;return __generator(this,(function(o){switch(o.label){case 0:return e=t.data,n=e.task,r=e.difficulty,a=postMessage,[4,function(t,e){return __awaiter(this,void 0,void 0,(function(){var n,r,a,o,i,c,u,l,s,f;return __generator(this,(function(h){switch(h.label){case 0:n=Uint8Array.from(atob(t.input),(function(t){return t.charCodeAt(0)})),r=0,h.label=1;case 1:return a="tcn".concat(r),o=(new TextEncoder).encode(a),(i=new Uint8Array(n.length+o.length)).set(n),i.set(o,n.length),u=Uint8Array.bind,[4,crypto.subtle.digest("SHA-256",i)];case 2:for(c=new(u.apply(Uint8Array,[void 0,h.sent()])),l=0,s=0;s<c.length;s++){if(0!==(f=c[s])){l+=Math.clz32(f)-24;break}l+=8}return l===e?[2,{number:t.number,nonce:a}]:(r++,[3,1]);case 3:return[2]}}))}))}(n,r)];case 1:return a.apply(void 0,[o.sent()]),[2]}}))}))}));