From da7dfa12c081b4d2ce70e456bdf378bf2bbad8f6 Mon Sep 17 00:00:00 2001 From: John Rallis Date: Tue, 5 Mar 2024 15:10:50 +0200 Subject: [PATCH] add optional expiry via headers --- dist/altcha.iife.js | 2 +- dist/altcha.js | 796 +++++++++++++++++++-------------------- dist/altcha.umd.cjs | 2 +- package-lock.json | 900 +------------------------------------------- src/Altcha.svelte | 35 +- src/types.ts | 2 + 6 files changed, 430 insertions(+), 1307 deletions(-) diff --git a/dist/altcha.iife.js b/dist/altcha.iife.js index 06bbd28..32e53ba 100644 --- a/dist/altcha.iife.js +++ b/dist/altcha.iife.js @@ -1 +1 @@ -var altcha=function(S){"use strict";var _t=Object.defineProperty;var wt=(S,p,V)=>p in S?_t(S,p,{enumerable:!0,configurable:!0,writable:!0,value:V}):S[p]=V;var R=(S,p,V)=>(wt(S,typeof p!="symbol"?p+"":p,V),V);function p(){}function V(t){return t()}function re(){return Object.create(null)}function W(t){t.forEach(V)}function ie(t){return typeof t=="function"}function Ee(t,e){return t!=t?e==e:t!==e||t&&typeof t=="object"||typeof t=="function"}function Ce(t){return Object.keys(t).length===0}function g(t,e){t.appendChild(e)}function xe(t,e,n){const i=Le(t);if(!i.getElementById(e)){const o=$("style");o.id=e,o.textContent=n,Ie(i,o)}}function Le(t){if(!t)return document;const e=t.getRootNode?t.getRootNode():t.ownerDocument;return e&&e.host?e:t.ownerDocument}function Ie(t,e){return g(t.head||t,e),e.sheet}function N(t,e,n){t.insertBefore(e,n||null)}function L(t){t.parentNode&&t.parentNode.removeChild(t)}function $(t){return document.createElement(t)}function M(t){return document.createElementNS("http://www.w3.org/2000/svg",t)}function Re(t){return document.createTextNode(t)}function F(){return Re(" ")}function K(t,e,n,i){return t.addEventListener(e,n,i),()=>t.removeEventListener(e,n,i)}function c(t,e,n){n==null?t.removeAttribute(e):t.getAttribute(e)!==n&&t.setAttribute(e,n)}function Ne(t){return Array.from(t.childNodes)}function le(t,e,n){t.classList.toggle(e,!!n)}function je(t,e,{bubbles:n=!1,cancelable:i=!1}={}){return new CustomEvent(t,{detail:e,bubbles:n,cancelable:i})}function Ae(t){const e={};return t.childNodes.forEach(n=>{e[n.slot||"default"]=!0}),e}let P;function T(t){P=t}function z(){if(!P)throw new Error("Function called outside component initialization");return P}function Ge(t){z().$$.on_mount.push(t)}function Se(t){z().$$.on_destroy.push(t)}function Me(){const t=z();return(e,n,{cancelable:i=!1}={})=>{const o=t.$$.callbacks[e];if(o){const r=je(e,n,{cancelable:i});return o.slice().forEach(s=>{s.call(t,r)}),!r.defaultPrevented}return!0}}const Z=[],J=[];let B=[];const oe=[],se=Promise.resolve();let Q=!1;function ce(){Q||(Q=!0,se.then(E))}function Ue(){return ce(),se}function q(t){B.push(t)}const ee=new Set;let H=0;function E(){if(H!==0)return;const t=P;do{try{for(;Ht.indexOf(i)===-1?e.push(i):n.push(i)),n.forEach(i=>i()),B=e}const Fe=new Set;function Ye(t,e){t&&t.i&&(Fe.delete(t),t.i(e))}function Ze(t,e,n){const{fragment:i,after_update:o}=t.$$;i&&i.m(e,n),q(()=>{const r=t.$$.on_mount.map(V).filter(ie);t.$$.on_destroy?t.$$.on_destroy.push(...r):W(r),t.$$.on_mount=[]}),o.forEach(q)}function Be(t,e){const n=t.$$;n.fragment!==null&&(Oe(n.after_update),W(n.on_destroy),n.fragment&&n.fragment.d(e),n.on_destroy=n.fragment=null,n.ctx=[])}function He(t,e){t.$$.dirty[0]===-1&&(Z.push(t),ce(),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<{const G=I.length?I[0]:A;return a.ctx&&o(a.ctx[k],a.ctx[k]=G)&&(!a.skip_bound&&a.bound[k]&&a.bound[k](G),j&&He(t,k)),A}):[],a.update(),j=!0,W(a.before_update),a.fragment=i?i(a.ctx):!1,e.target){if(e.hydrate){const k=Ne(e.target);a.fragment&&a.fragment.l(k),k.forEach(L)}else a.fragment&&a.fragment.c();e.intro&&Ye(t.$$.fragment),Ze(t,e.target,e.anchor),E()}T(f)}let ue;typeof HTMLElement=="function"&&(ue=class extends HTMLElement{constructor(e,n,i){super();R(this,"$$ctor");R(this,"$$s");R(this,"$$c");R(this,"$$cn",!1);R(this,"$$d",{});R(this,"$$r",!1);R(this,"$$p_d",{});R(this,"$$l",{});R(this,"$$l_u",new Map);this.$$ctor=e,this.$$s=n,i&&this.attachShadow({mode:"open"})}addEventListener(e,n,i){if(this.$$l[e]=this.$$l[e]||[],this.$$l[e].push(n),this.$$c){const o=this.$$c.$on(e,n);this.$$l_u.set(n,o)}super.addEventListener(e,n,i)}removeEventListener(e,n,i){if(super.removeEventListener(e,n,i),this.$$c){const o=this.$$l_u.get(n);o&&(o(),this.$$l_u.delete(n))}}async connectedCallback(){if(this.$$cn=!0,!this.$$c){let e=function(r){return()=>{let s;return{c:function(){s=$("slot"),r!=="default"&&c(s,"name",r)},m:function(a,j){N(a,s,j)},d:function(a){a&&L(s)}}}};if(await Promise.resolve(),!this.$$cn||this.$$c)return;const n={},i=Ae(this);for(const r of this.$$s)r in i&&(n[r]=[e(r)]);for(const r of this.attributes){const s=this.$$g_p(r.name);s in this.$$d||(this.$$d[s]=D(s,r.value,this.$$p_d,"toProp"))}for(const r in this.$$p_d)!(r in this.$$d)&&this[r]!==void 0&&(this.$$d[r]=this[r],delete this[r]);this.$$c=new this.$$ctor({target:this.shadowRoot||this,props:{...this.$$d,$$slots:n,$$scope:{ctx:[]}}});const o=()=>{this.$$r=!0;for(const r in this.$$p_d)if(this.$$d[r]=this.$$c.$$.ctx[this.$$c.$$.props[r]],this.$$p_d[r].reflect){const s=D(r,this.$$d[r],this.$$p_d,"toAttribute");s==null?this.removeAttribute(this.$$p_d[r].attribute||r):this.setAttribute(this.$$p_d[r].attribute||r,s)}this.$$r=!1};this.$$c.$$.after_update.push(o),o();for(const r in this.$$l)for(const s of this.$$l[r]){const u=this.$$c.$on(r,s);this.$$l_u.set(s,u)}this.$$l={}}}attributeChangedCallback(e,n,i){var o;this.$$r||(e=this.$$g_p(e),this.$$d[e]=D(e,i,this.$$p_d,"toProp"),(o=this.$$c)==null||o.$set({[e]:this.$$d[e]}))}disconnectedCallback(){this.$$cn=!1,Promise.resolve().then(()=>{this.$$cn||(this.$$c.$destroy(),this.$$c=void 0)})}$$g_p(e){return Object.keys(this.$$p_d).find(n=>this.$$p_d[n].attribute===e||!this.$$p_d[n].attribute&&n.toLowerCase()===e)||e}});function D(t,e,n,i){var r;const o=(r=n[t])==null?void 0:r.type;if(e=o==="Boolean"&&typeof e!="boolean"?e!=null:e,!i||!n[t])return e;if(i==="toAttribute")switch(o){case"Object":case"Array":return e==null?null:JSON.stringify(e);case"Boolean":return e?"":null;case"Number":return e??null;default:return e}else switch(o){case"Object":case"Array":return e&&JSON.parse(e);case"Boolean":return e;case"Number":return e!=null?+e:e;default:return e}}function Pe(t,e,n,i,o,r){let s=class extends ue{constructor(){super(t,n,o),this.$$p_d=e}static get observedAttributes(){return Object.keys(e).map(u=>(e[u].attribute||u).toLowerCase())}};return Object.keys(e).forEach(u=>{Object.defineProperty(s.prototype,u,{get(){return this.$$c&&u in this.$$c?this.$$c[u]:this.$$d[u]},set(f){var a;f=D(u,f,e),this.$$d[u]=f,(a=this.$$c)==null||a.$set({[u]:f})}})}),i.forEach(u=>{Object.defineProperty(s.prototype,u,{get(){var f;return(f=this.$$c)==null?void 0:f[u]}})}),r&&(s=r(s)),t.element=s,s}class Te{constructor(){R(this,"$$");R(this,"$$set")}$destroy(){Be(this,1),this.$destroy=p}$on(e,n){if(!ie(n))return p;const i=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return i.push(n),()=>{const o=i.indexOf(n);o!==-1&&i.splice(o,1)}}$set(e){this.$$set&&!Ce(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const Xe="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(Xe);const ae="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0IHI9bmV3IFRleHRFbmNvZGVyO2Z1bmN0aW9uIGMoZSl7cmV0dXJuWy4uLm5ldyBVaW50OEFycmF5KGUpXS5tYXAobj0+bi50b1N0cmluZygxNikucGFkU3RhcnQoMiwiMCIpKS5qb2luKCIiKX1hc3luYyBmdW5jdGlvbiBsKGUsbixhKXtyZXR1cm4gYyhhd2FpdCBjcnlwdG8uc3VidGxlLmRpZ2VzdChhLnRvVXBwZXJDYXNlKCksci5lbmNvZGUoZStuKSkpfWFzeW5jIGZ1bmN0aW9uIGkoZSxuLGE9IlNIQS0yNTYiLG89MWU3KXtjb25zdCBzPURhdGUubm93KCk7Zm9yKGxldCB0PTA7dDw9bzt0KyspaWYoYXdhaXQgbChuLHQsYSk9PT1lKXJldHVybntudW1iZXI6dCx0b29rOkRhdGUubm93KCktc307cmV0dXJuIG51bGx9b25tZXNzYWdlPWFzeW5jIGU9Pntjb25zdHthbGc6bixjaGFsbGVuZ2U6YSxtYXg6byxzYWx0OnN9PWUuZGF0YXx8e307aWYoYSYmcyl7Y29uc3QgdD1hd2FpdCBpKGEscyxuLG8pO3NlbGYucG9zdE1lc3NhZ2UodCYmey4uLnQsd29ya2VyOiEwfSl9ZWxzZSBzZWxmLnBvc3RNZXNzYWdlKG51bGwpfX0pKCk7Cg==",De=t=>Uint8Array.from(atob(t),e=>e.charCodeAt(0)),fe=typeof window<"u"&&window.Blob&&new Blob([De(ae)],{type:"text/javascript;charset=utf-8"});function Ke(t){let e;try{if(e=fe&&(window.URL||window.webkitURL).createObjectURL(fe),!e)throw"";const n=new Worker(e,{name:t==null?void 0:t.name});return n.addEventListener("error",()=>{(window.URL||window.webkitURL).revokeObjectURL(e)}),n}catch{return new Worker("data:text/javascript;base64,"+ae,{name:t==null?void 0:t.name})}finally{e&&(window.URL||window.webkitURL).revokeObjectURL(e)}}const ze=1e7,Je=new TextEncoder;function Qe(t){return[...new Uint8Array(t)].map(e=>e.toString(16).padStart(2,"0")).join("")}async function qe(t=1e5,e="SHA-256"){const n=Date.now().toString(16),i=Math.round(Math.random()*t),o=await he(n,i,e);return{algorithm:e,challenge:o,salt:n,signature:""}}async function he(t,e,n){return Qe(await crypto.subtle.digest(n.toUpperCase(),Je.encode(t+e)))}async function et(t,e,n="SHA-256",i=ze){const o=Date.now();for(let r=0;r<=i;r++)if(await he(e,r,n)===t)return{number:r,took:Date.now()-o};return null}var y=(t=>(t.ERROR="error",t.VERIFIED="verified",t.VERIFYING="verifying",t.UNVERIFIED="unverified",t))(y||{});function tt(t){xe(t,"svelte-vuofbg",".altcha.svelte-vuofbg.svelte-vuofbg{background:var(--altcha-color-base, transparent);border:var(--altcha-border-width, 1px) solid var(--altcha-color-border, #a0a0a0);border-radius:var(--altcha-border-radius, 3px);color:var(--altcha-color-text, currentColor);display:flex;flex-direction:column;max-width:var(--altcha-max-width, 260px);overflow:hidden;position:relative;text-align:left}.altcha.svelte-vuofbg.svelte-vuofbg:focus-within{border-color:var(--altcha-color-border-focus, currentColor)}.altcha-main.svelte-vuofbg.svelte-vuofbg{align-items:center;display:flex;gap:0.4rem;padding:0.7rem}.altcha-label.svelte-vuofbg.svelte-vuofbg{flex-grow:1}.altcha-label.svelte-vuofbg label.svelte-vuofbg{cursor:pointer}.altcha-logo.svelte-vuofbg.svelte-vuofbg{color:currentColor;opacity:0.3}.altcha-logo.svelte-vuofbg.svelte-vuofbg:hover{opacity:1}.altcha-error.svelte-vuofbg.svelte-vuofbg{color:var(--altcha-color-error-text, #f23939);display:flex;font-size:0.85rem;gap:0.3rem;padding:0 0.7rem 0.7rem}.altcha-footer.svelte-vuofbg.svelte-vuofbg{align-items:center;background-color:var(--altcha-color-footer-bg, transparent);display:flex;font-size:0.75rem;opacity:0.4;padding:0.2rem 0.7rem;text-align:right}.altcha-footer.svelte-vuofbg.svelte-vuofbg:hover{opacity:1}.altcha-footer.svelte-vuofbg>.svelte-vuofbg:first-child{flex-grow:1}.altcha-footer.svelte-vuofbg a{color:currentColor}.altcha-checkbox.svelte-vuofbg.svelte-vuofbg{display:flex;align-items:center;height:24px;width:24px}.altcha-checkbox.svelte-vuofbg input.svelte-vuofbg{width:18px;height:18px;margin:0}.altcha-hidden.svelte-vuofbg.svelte-vuofbg{display:none}.altcha-spinner.svelte-vuofbg.svelte-vuofbg{animation:svelte-vuofbg-altcha-spinner 0.75s infinite linear;transform-origin:center}@keyframes svelte-vuofbg-altcha-spinner{100%{transform:rotate(360deg)}}")}function de(t){let e,n,i;return{c(){e=M("svg"),n=M("path"),i=M("path"),c(n,"d","M12,1A11,11,0,1,0,23,12,11,11,0,0,0,12,1Zm0,19a8,8,0,1,1,8-8A8,8,0,0,1,12,20Z"),c(n,"fill","currentColor"),c(n,"opacity",".25"),c(i,"d","M12,4a8,8,0,0,1,7.89,6.7A1.53,1.53,0,0,0,21.38,12h0a1.5,1.5,0,0,0,1.48-1.75,11,11,0,0,0-21.72,0A1.5,1.5,0,0,0,2.62,12h0a1.53,1.53,0,0,0,1.49-1.3A8,8,0,0,1,12,4Z"),c(i,"fill","currentColor"),c(i,"class","altcha-spinner svelte-vuofbg"),c(e,"width","24"),c(e,"height","24"),c(e,"viewBox","0 0 24 24"),c(e,"xmlns","http://www.w3.org/2000/svg")},m(o,r){N(o,e,r),g(e,n),g(e,i)},d(o){o&&L(e)}}}function nt(t){let e,n=t[9].label+"",i;return{c(){e=$("label"),c(e,"for",i=t[3]+"_checkbox"),c(e,"class","svelte-vuofbg")},m(o,r){N(o,e,r),e.innerHTML=n},p(o,r){r[0]&512&&n!==(n=o[9].label+"")&&(e.innerHTML=n),r[0]&8&&i!==(i=o[3]+"_checkbox")&&c(e,"for",i)},d(o){o&&L(e)}}}function rt(t){let e,n=t[9].verifying+"";return{c(){e=$("span")},m(i,o){N(i,e,o),e.innerHTML=n},p(i,o){o[0]&512&&n!==(n=i[9].verifying+"")&&(e.innerHTML=n)},d(i){i&&L(e)}}}function it(t){let e,n=t[9].verified+"",i,o;return{c(){e=$("span"),i=F(),o=$("input"),c(o,"type","hidden"),c(o,"name",t[3]),o.value=t[4]},m(r,s){N(r,e,s),e.innerHTML=n,N(r,i,s),N(r,o,s)},p(r,s){s[0]&512&&n!==(n=r[9].verified+"")&&(e.innerHTML=n),s[0]&8&&c(o,"name",r[3]),s[0]&16&&(o.value=r[4])},d(r){r&&(L(e),L(i),L(o))}}}function ge(t){let e,n,i,o,r,s;return{c(){e=$("div"),n=$("a"),i=M("svg"),o=M("path"),r=M("path"),s=M("path"),c(o,"d","M2.33955 16.4279C5.88954 20.6586 12.1971 21.2105 16.4279 17.6604C18.4699 15.947 19.6548 13.5911 19.9352 11.1365L17.9886 10.4279C17.8738 12.5624 16.909 14.6459 15.1423 16.1284C11.7577 18.9684 6.71167 18.5269 3.87164 15.1423C1.03163 11.7577 1.4731 6.71166 4.8577 3.87164C8.24231 1.03162 13.2883 1.4731 16.1284 4.8577C16.9767 5.86872 17.5322 7.02798 17.804 8.2324L19.9522 9.01429C19.7622 7.07737 19.0059 5.17558 17.6604 3.57212C14.1104 -0.658624 7.80283 -1.21043 3.57212 2.33956C-0.658625 5.88958 -1.21046 12.1971 2.33955 16.4279Z"),c(o,"fill","currentColor"),c(r,"d","M3.57212 2.33956C1.65755 3.94607 0.496389 6.11731 0.12782 8.40523L2.04639 9.13961C2.26047 7.15832 3.21057 5.25375 4.8577 3.87164C8.24231 1.03162 13.2883 1.4731 16.1284 4.8577L13.8302 6.78606L19.9633 9.13364C19.7929 7.15555 19.0335 5.20847 17.6604 3.57212C14.1104 -0.658624 7.80283 -1.21043 3.57212 2.33956Z"),c(r,"fill","currentColor"),c(s,"d","M7 10H5C5 12.7614 7.23858 15 10 15C12.7614 15 15 12.7614 15 10H13C13 11.6569 11.6569 13 10 13C8.3431 13 7 11.6569 7 10Z"),c(s,"fill","currentColor"),c(i,"width","22"),c(i,"height","22"),c(i,"viewBox","0 0 20 20"),c(i,"fill","none"),c(i,"xmlns","http://www.w3.org/2000/svg"),c(n,"href",ve),c(n,"target","_blank"),c(n,"class","altcha-logo svelte-vuofbg")},m(u,f){N(u,e,f),g(e,n),g(n,i),g(i,o),g(i,r),g(i,s)},p,d(u){u&&L(e)}}}function be(t){let e,n,i,o,r,s=t[9].error+"";return{c(){e=$("div"),n=M("svg"),i=M("path"),o=F(),r=$("div"),c(i,"stroke-linecap","round"),c(i,"stroke-linejoin","round"),c(i,"d","M6 18L18 6M6 6l12 12"),c(n,"width","14"),c(n,"height","14"),c(n,"xmlns","http://www.w3.org/2000/svg"),c(n,"fill","none"),c(n,"viewBox","0 0 24 24"),c(n,"stroke-width","1.5"),c(n,"stroke","currentColor"),c(r,"title",t[8]),c(e,"class","altcha-error svelte-vuofbg")},m(u,f){N(u,e,f),g(e,n),g(n,i),g(e,o),g(e,r),r.innerHTML=s},p(u,f){f[0]&512&&s!==(s=u[9].error+"")&&(r.innerHTML=s),f[0]&256&&c(r,"title",u[8])},d(u){u&&L(e)}}}function me(t){let e,n,i=t[9].footer+"";return{c(){e=$("div"),n=$("div"),c(n,"class","svelte-vuofbg"),c(e,"class","altcha-footer svelte-vuofbg")},m(o,r){N(o,e,r),g(e,n),n.innerHTML=i},p(o,r){r[0]&512&&i!==(i=o[9].footer+"")&&(n.innerHTML=i)},d(o){o&&L(e)}}}function lt(t){let e,n,i,o,r,s,u,f,a,j,k,A,I,G,_=t[5]===y.VERIFYING&&de();function U(h,v){return h[5]===y.VERIFIED?it:h[5]===y.VERIFYING?rt:nt}let Y=U(t),C=Y(t),b=t[2]!==!0&&ge(),m=t[8]&&be(t),d=t[9].footer&&t[1]!==!0&&me(t);return{c(){e=$("div"),n=$("div"),_&&_.c(),i=F(),o=$("div"),r=$("input"),f=F(),a=$("div"),C.c(),j=F(),b&&b.c(),k=F(),m&&m.c(),A=F(),d&&d.c(),c(r,"type","checkbox"),c(r,"id",s=t[3]+"_checkbox"),r.required=u=t[0]!=="onsubmit",c(r,"class","svelte-vuofbg"),c(o,"class","altcha-checkbox svelte-vuofbg"),le(o,"altcha-hidden",t[5]===y.VERIFYING),c(a,"class","altcha-label svelte-vuofbg"),c(n,"class","altcha-main svelte-vuofbg"),c(e,"class","altcha svelte-vuofbg"),c(e,"data-state",t[5])},m(h,v){N(h,e,v),g(e,n),_&&_.m(n,null),g(n,i),g(n,o),g(o,r),r.checked=t[6],g(n,f),g(n,a),C.m(a,null),g(n,j),b&&b.m(n,null),g(e,k),m&&m.m(e,null),g(e,A),d&&d.m(e,null),t[24](e),I||(G=[K(r,"change",t[23]),K(r,"change",t[10]),K(r,"invalid",t[11])],I=!0)},p(h,v){h[5]===y.VERIFYING?_||(_=de(),_.c(),_.m(n,i)):_&&(_.d(1),_=null),v[0]&8&&s!==(s=h[3]+"_checkbox")&&c(r,"id",s),v[0]&1&&u!==(u=h[0]!=="onsubmit")&&(r.required=u),v[0]&64&&(r.checked=h[6]),v[0]&32&&le(o,"altcha-hidden",h[5]===y.VERIFYING),Y===(Y=U(h))&&C?C.p(h,v):(C.d(1),C=Y(h),C&&(C.c(),C.m(a,null))),h[2]!==!0?b?b.p(h,v):(b=ge(),b.c(),b.m(n,null)):b&&(b.d(1),b=null),h[8]?m?m.p(h,v):(m=be(h),m.c(),m.m(e,A)):m&&(m.d(1),m=null),h[9].footer&&h[1]!==!0?d?d.p(h,v):(d=me(h),d.c(),d.m(e,null)):d&&(d.d(1),d=null),v[0]&32&&c(e,"data-state",h[5])},i:p,o:p,d(h){h&&L(e),_&&_.d(),C.d(),b&&b.d(),m&&m.d(),d&&d.d(),t[24](null),I=!1,W(G)}}}const ve="https://altcha.org/";function _e(t){return JSON.parse(t)}function ot(t,e,n){let i,o,r,{auto:s=void 0}=e,{challengeurl:u=void 0}=e,{challengejson:f=void 0}=e,{debug:a=!1}=e,{hidefooter:j=!1}=e,{hidelogo:k=!1}=e,{name:A="altcha"}=e,{maxnumber:I=void 0}=e,{mockerror:G=!1}=e,{strings:_=void 0}=e,{test:U=!1}=e;const Y=Me(),C=["SHA-256","SHA-384","SHA-512"];let b=!1,m,d=null,h=null,v=null,O=y.UNVERIFIED;Se(()=>{d&&(d.removeEventListener("submit",$e),d.removeEventListener("reset",ye),d=null)}),Ge(()=>{x("mounted","0.1.9"),U&&x("using test mode"),s!==void 0&&x("auto",s),d=m.closest("form"),d&&(d.addEventListener("submit",$e),d.addEventListener("reset",ye)),s==="onload"&&X()});function x(...l){(a||l.some(w=>w instanceof Error))&&console[l[0]instanceof Error?"error":"log"]("ALTCHA",...l)}function $e(l){d&&s==="onsubmit"&&O===y.UNVERIFIED&&(l.preventDefault(),l.stopPropagation(),X().then(()=>{d==null||d.requestSubmit()}))}function ye(){te()}function st(l,w){return btoa(JSON.stringify({algorithm:l.algorithm,challenge:l.challenge,number:w.number,salt:l.salt,signature:l.signature,test:U?!0:void 0,took:w.took}))}function ke(l){if(!l.algorithm)throw new Error("Invalid challenge. Property algorithm is missing.");if(l.signature===void 0)throw new Error("Invalid challenge. Property signature is missing.");if(!C.includes(l.algorithm.toUpperCase()))throw new Error(`Unknown algorithm value. Allowed values: ${C.join(", ")}`);if(!l.challenge||l.challenge.length<40)throw new Error("Challenge is too short. Min. 40 chars.");if(!l.salt||l.salt.length<10)throw new Error("Salt is too short. Min. 10 chars.")}async function ct(){if(G)throw x("mocking error"),new Error("Mocked error.");if(i)return x("using provided json data"),i;if(U)return x("generating test challenge"),qe();{if(!u)throw new Error("Attribute challengeurl not set.");x("fetching challenge from",u);const l=await fetch(u);if(l.status!==200)throw new Error(`Server responded with ${l.status}.`);return l.json()}}async function ut(l){let w=null;if("Worker"in window){try{w=await at(l.challenge,l.salt,l.algorithm)}catch(ne){x(ne)}if((w==null?void 0:w.number)!==void 0)return{data:l,solution:w}}return{data:l,solution:await et(l.challenge,l.salt,l.algorithm,I)}}async function at(l,w,ne){const pe=new Ke;return new Promise(mt=>{pe.addEventListener("message",vt=>{mt(vt.data)}),pe.postMessage({alg:ne,challenge:l,max:I,salt:w})})}function ft(){[y.UNVERIFIED,y.ERROR].includes(O)?X():n(6,b=!0)}function ht(){O===y.VERIFYING&&alert(r.waitAlert)}function dt(l){l.auto!==void 0&&(n(0,s=l.auto),s==="onload"&&X()),l.challenge&&(ke(l.challenge),i=l.challenge),l.debug!==void 0&&n(12,a=!!l.debug),l.hidefooter!==void 0&&n(1,j=!!l.hidefooter),l.hidelogo!==void 0&&n(2,k=!!l.hidelogo),l.maxnumber!==void 0&&n(13,I=+l.maxnumber),l.mockerror!==void 0&&n(14,G=!!l.mockerror),l.name!==void 0&&n(3,A=l.name),l.test!==void 0&&n(15,U=!!l.test),l.strings&&n(22,o=l.strings)}function te(l=y.UNVERIFIED){n(6,b=!1),n(8,h=null),n(4,v=null),n(5,O=l)}async function X(){return te(y.VERIFYING),ct().then(l=>(ke(l),x("challenge",l),ut(l))).then(({data:l,solution:w})=>{if(x("solution",w),(w==null?void 0:w.number)!==void 0)x("verified"),n(5,O=y.VERIFIED),n(6,b=!0),n(4,v=st(l,w)),x("payload",v),Ue().then(()=>{Y("verified",{payload:v})});else throw new Error("Unexpected result returned.")}).catch(l=>{x(l),n(5,O=y.ERROR),n(6,b=!1),n(8,h=l)})}function gt(){b=this.checked,n(6,b)}function bt(l){J[l?"unshift":"push"](()=>{m=l,n(7,m)})}return t.$$set=l=>{"auto"in l&&n(0,s=l.auto),"challengeurl"in l&&n(16,u=l.challengeurl),"challengejson"in l&&n(17,f=l.challengejson),"debug"in l&&n(12,a=l.debug),"hidefooter"in l&&n(1,j=l.hidefooter),"hidelogo"in l&&n(2,k=l.hidelogo),"name"in l&&n(3,A=l.name),"maxnumber"in l&&n(13,I=l.maxnumber),"mockerror"in l&&n(14,G=l.mockerror),"strings"in l&&n(18,_=l.strings),"test"in l&&n(15,U=l.test)},t.$$.update=()=>{t.$$.dirty[0]&131072&&(i=f?_e(f):void 0),t.$$.dirty[0]&262144&&n(22,o=_?_e(_):{}),t.$$.dirty[0]&4194304&&n(9,r={error:"Verification failed. Try again later.",footer:`Protected by ALTCHA`,label:"I'm not a robot",verified:"Verified",verifying:"Verifying...",waitAlert:"Verifying... please wait.",...o}),t.$$.dirty[0]&48&&Y("statechange",{payload:v,state:O})},[s,j,k,A,v,O,b,m,h,r,ft,ht,a,I,G,U,u,f,_,dt,te,X,o,gt,bt]}class we extends Te{constructor(e){super(),We(this,e,ot,lt,Ee,{auto:0,challengeurl:16,challengejson:17,debug:12,hidefooter:1,hidelogo:2,name:3,maxnumber:13,mockerror:14,strings:18,test:15,configure:19,reset:20,verify:21},tt,[-1,-1])}get auto(){return this.$$.ctx[0]}set auto(e){this.$$set({auto:e}),E()}get challengeurl(){return this.$$.ctx[16]}set challengeurl(e){this.$$set({challengeurl:e}),E()}get challengejson(){return this.$$.ctx[17]}set challengejson(e){this.$$set({challengejson:e}),E()}get debug(){return this.$$.ctx[12]}set debug(e){this.$$set({debug:e}),E()}get hidefooter(){return this.$$.ctx[1]}set hidefooter(e){this.$$set({hidefooter:e}),E()}get hidelogo(){return this.$$.ctx[2]}set hidelogo(e){this.$$set({hidelogo:e}),E()}get name(){return this.$$.ctx[3]}set name(e){this.$$set({name:e}),E()}get maxnumber(){return this.$$.ctx[13]}set maxnumber(e){this.$$set({maxnumber:e}),E()}get mockerror(){return this.$$.ctx[14]}set mockerror(e){this.$$set({mockerror:e}),E()}get strings(){return this.$$.ctx[18]}set strings(e){this.$$set({strings:e}),E()}get test(){return this.$$.ctx[15]}set test(e){this.$$set({test:e}),E()}get configure(){return this.$$.ctx[19]}get reset(){return this.$$.ctx[20]}get verify(){return this.$$.ctx[21]}}return customElements.define("altcha-widget",Pe(we,{auto:{},challengeurl:{},challengejson:{},debug:{type:"Boolean"},hidefooter:{type:"Boolean"},hidelogo:{type:"Boolean"},name:{},maxnumber:{},mockerror:{type:"Boolean"},strings:{},test:{type:"Boolean"}},[],["configure","reset","verify"],!1)),S.Altcha=we,Object.defineProperty(S,Symbol.toStringTag,{value:"Module"}),S}({}); +var altcha=function(S){"use strict";var yt=Object.defineProperty;var pt=(S,k,U)=>k in S?yt(S,k,{enumerable:!0,configurable:!0,writable:!0,value:U}):S[k]=U;var R=(S,k,U)=>(pt(S,typeof k!="symbol"?k+"":k,U),U);function k(){}function U(t){return t()}function ie(){return Object.create(null)}function T(t){t.forEach(U)}function oe(t){return typeof t=="function"}function Ie(t,e){return t!=t?e==e:t!==e||t&&typeof t=="object"||typeof t=="function"}function Le(t){return Object.keys(t).length===0}function g(t,e){t.appendChild(e)}function Re(t,e,n){const i=Ne(t);if(!i.getElementById(e)){const l=$("style");l.id=e,l.textContent=n,je(i,l)}}function Ne(t){if(!t)return document;const e=t.getRootNode?t.getRootNode():t.ownerDocument;return e&&e.host?e:t.ownerDocument}function je(t,e){return g(t.head||t,e),e.sheet}function N(t,e,n){t.insertBefore(e,n||null)}function I(t){t.parentNode&&t.parentNode.removeChild(t)}function $(t){return document.createElement(t)}function V(t){return document.createElementNS("http://www.w3.org/2000/svg",t)}function Ae(t){return document.createTextNode(t)}function F(){return Ae(" ")}function Q(t,e,n,i){return t.addEventListener(e,n,i),()=>t.removeEventListener(e,n,i)}function c(t,e,n){n==null?t.removeAttribute(e):t.getAttribute(e)!==n&&t.setAttribute(e,n)}function Ge(t){return Array.from(t.childNodes)}function le(t,e,n){t.classList.toggle(e,!!n)}function Se(t,e,{bubbles:n=!1,cancelable:i=!1}={}){return new CustomEvent(t,{detail:e,bubbles:n,cancelable:i})}function Ve(t){const e={};return t.childNodes.forEach(n=>{e[n.slot||"default"]=!0}),e}let D;function X(t){D=t}function q(){if(!D)throw new Error("Function called outside component initialization");return D}function Me(t){q().$$.on_mount.push(t)}function Ue(t){q().$$.on_destroy.push(t)}function Oe(){const t=q();return(e,n,{cancelable:i=!1}={})=>{const l=t.$$.callbacks[e];if(l){const r=Se(e,n,{cancelable:i});return l.slice().forEach(s=>{s.call(t,r)}),!r.defaultPrevented}return!0}}const Z=[],ee=[];let B=[];const se=[],ce=Promise.resolve();let te=!1;function ue(){te||(te=!0,ce.then(E))}function Fe(){return ue(),ce}function ne(t){B.push(t)}const re=new Set;let H=0;function E(){if(H!==0)return;const t=D;do{try{for(;Ht.indexOf(i)===-1?e.push(i):n.push(i)),n.forEach(i=>i()),B=e}const Be=new Set;function He(t,e){t&&t.i&&(Be.delete(t),t.i(e))}function We(t,e,n){const{fragment:i,after_update:l}=t.$$;i&&i.m(e,n),ne(()=>{const r=t.$$.on_mount.map(U).filter(oe);t.$$.on_destroy?t.$$.on_destroy.push(...r):T(r),t.$$.on_mount=[]}),l.forEach(ne)}function Pe(t,e){const n=t.$$;n.fragment!==null&&(Ze(n.after_update),T(n.on_destroy),n.fragment&&n.fragment.d(e),n.on_destroy=n.fragment=null,n.ctx=[])}function Te(t,e){t.$$.dirty[0]===-1&&(Z.push(t),ue(),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<{const G=L.length?L[0]:A;return f.ctx&&l(f.ctx[p],f.ctx[p]=G)&&(!f.skip_bound&&f.bound[p]&&f.bound[p](G),j&&Te(t,p)),A}):[],f.update(),j=!0,T(f.before_update),f.fragment=i?i(f.ctx):!1,e.target){if(e.hydrate){const p=Ge(e.target);f.fragment&&f.fragment.l(p),p.forEach(I)}else f.fragment&&f.fragment.c();e.intro&&He(t.$$.fragment),We(t,e.target,e.anchor),E()}X(h)}let ae;typeof HTMLElement=="function"&&(ae=class extends HTMLElement{constructor(e,n,i){super();R(this,"$$ctor");R(this,"$$s");R(this,"$$c");R(this,"$$cn",!1);R(this,"$$d",{});R(this,"$$r",!1);R(this,"$$p_d",{});R(this,"$$l",{});R(this,"$$l_u",new Map);this.$$ctor=e,this.$$s=n,i&&this.attachShadow({mode:"open"})}addEventListener(e,n,i){if(this.$$l[e]=this.$$l[e]||[],this.$$l[e].push(n),this.$$c){const l=this.$$c.$on(e,n);this.$$l_u.set(n,l)}super.addEventListener(e,n,i)}removeEventListener(e,n,i){if(super.removeEventListener(e,n,i),this.$$c){const l=this.$$l_u.get(n);l&&(l(),this.$$l_u.delete(n))}}async connectedCallback(){if(this.$$cn=!0,!this.$$c){let e=function(r){return()=>{let s;return{c:function(){s=$("slot"),r!=="default"&&c(s,"name",r)},m:function(f,j){N(f,s,j)},d:function(f){f&&I(s)}}}};if(await Promise.resolve(),!this.$$cn||this.$$c)return;const n={},i=Ve(this);for(const r of this.$$s)r in i&&(n[r]=[e(r)]);for(const r of this.attributes){const s=this.$$g_p(r.name);s in this.$$d||(this.$$d[s]=z(s,r.value,this.$$p_d,"toProp"))}for(const r in this.$$p_d)!(r in this.$$d)&&this[r]!==void 0&&(this.$$d[r]=this[r],delete this[r]);this.$$c=new this.$$ctor({target:this.shadowRoot||this,props:{...this.$$d,$$slots:n,$$scope:{ctx:[]}}});const l=()=>{this.$$r=!0;for(const r in this.$$p_d)if(this.$$d[r]=this.$$c.$$.ctx[this.$$c.$$.props[r]],this.$$p_d[r].reflect){const s=z(r,this.$$d[r],this.$$p_d,"toAttribute");s==null?this.removeAttribute(this.$$p_d[r].attribute||r):this.setAttribute(this.$$p_d[r].attribute||r,s)}this.$$r=!1};this.$$c.$$.after_update.push(l),l();for(const r in this.$$l)for(const s of this.$$l[r]){const a=this.$$c.$on(r,s);this.$$l_u.set(s,a)}this.$$l={}}}attributeChangedCallback(e,n,i){var l;this.$$r||(e=this.$$g_p(e),this.$$d[e]=z(e,i,this.$$p_d,"toProp"),(l=this.$$c)==null||l.$set({[e]:this.$$d[e]}))}disconnectedCallback(){this.$$cn=!1,Promise.resolve().then(()=>{this.$$cn||(this.$$c.$destroy(),this.$$c=void 0)})}$$g_p(e){return Object.keys(this.$$p_d).find(n=>this.$$p_d[n].attribute===e||!this.$$p_d[n].attribute&&n.toLowerCase()===e)||e}});function z(t,e,n,i){var r;const l=(r=n[t])==null?void 0:r.type;if(e=l==="Boolean"&&typeof e!="boolean"?e!=null:e,!i||!n[t])return e;if(i==="toAttribute")switch(l){case"Object":case"Array":return e==null?null:JSON.stringify(e);case"Boolean":return e?"":null;case"Number":return e??null;default:return e}else switch(l){case"Object":case"Array":return e&&JSON.parse(e);case"Boolean":return e;case"Number":return e!=null?+e:e;default:return e}}function Xe(t,e,n,i,l,r){let s=class extends ae{constructor(){super(t,n,l),this.$$p_d=e}static get observedAttributes(){return Object.keys(e).map(a=>(e[a].attribute||a).toLowerCase())}};return Object.keys(e).forEach(a=>{Object.defineProperty(s.prototype,a,{get(){return this.$$c&&a in this.$$c?this.$$c[a]:this.$$d[a]},set(h){var f;h=z(a,h,e),this.$$d[a]=h,(f=this.$$c)==null||f.$set({[a]:h})}})}),i.forEach(a=>{Object.defineProperty(s.prototype,a,{get(){var h;return(h=this.$$c)==null?void 0:h[a]}})}),r&&(s=r(s)),t.element=s,s}class Ke{constructor(){R(this,"$$");R(this,"$$set")}$destroy(){Pe(this,1),this.$destroy=k}$on(e,n){if(!oe(n))return k;const i=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return i.push(n),()=>{const l=i.indexOf(n);l!==-1&&i.splice(l,1)}}$set(e){this.$$set&&!Le(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const ze="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(ze);const fe="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0IHI9bmV3IFRleHRFbmNvZGVyO2Z1bmN0aW9uIGMoZSl7cmV0dXJuWy4uLm5ldyBVaW50OEFycmF5KGUpXS5tYXAobj0+bi50b1N0cmluZygxNikucGFkU3RhcnQoMiwiMCIpKS5qb2luKCIiKX1hc3luYyBmdW5jdGlvbiBsKGUsbixhKXtyZXR1cm4gYyhhd2FpdCBjcnlwdG8uc3VidGxlLmRpZ2VzdChhLnRvVXBwZXJDYXNlKCksci5lbmNvZGUoZStuKSkpfWFzeW5jIGZ1bmN0aW9uIGkoZSxuLGE9IlNIQS0yNTYiLG89MWU3KXtjb25zdCBzPURhdGUubm93KCk7Zm9yKGxldCB0PTA7dDw9bzt0KyspaWYoYXdhaXQgbChuLHQsYSk9PT1lKXJldHVybntudW1iZXI6dCx0b29rOkRhdGUubm93KCktc307cmV0dXJuIG51bGx9b25tZXNzYWdlPWFzeW5jIGU9Pntjb25zdHthbGc6bixjaGFsbGVuZ2U6YSxtYXg6byxzYWx0OnN9PWUuZGF0YXx8e307aWYoYSYmcyl7Y29uc3QgdD1hd2FpdCBpKGEscyxuLG8pO3NlbGYucG9zdE1lc3NhZ2UodCYmey4uLnQsd29ya2VyOiEwfSl9ZWxzZSBzZWxmLnBvc3RNZXNzYWdlKG51bGwpfX0pKCk7Cg==",Je=t=>Uint8Array.from(atob(t),e=>e.charCodeAt(0)),he=typeof window<"u"&&window.Blob&&new Blob([Je(fe)],{type:"text/javascript;charset=utf-8"});function Qe(t){let e;try{if(e=he&&(window.URL||window.webkitURL).createObjectURL(he),!e)throw"";const n=new Worker(e,{name:t==null?void 0:t.name});return n.addEventListener("error",()=>{(window.URL||window.webkitURL).revokeObjectURL(e)}),n}catch{return new Worker("data:text/javascript;base64,"+fe,{name:t==null?void 0:t.name})}finally{e&&(window.URL||window.webkitURL).revokeObjectURL(e)}}const qe=1e7,et=new TextEncoder;function tt(t){return[...new Uint8Array(t)].map(e=>e.toString(16).padStart(2,"0")).join("")}async function nt(t=1e5,e="SHA-256"){const n=Date.now().toString(16),i=Math.round(Math.random()*t),l=await de(n,i,e);return{algorithm:e,challenge:l,salt:n,signature:""}}async function de(t,e,n){return tt(await crypto.subtle.digest(n.toUpperCase(),et.encode(t+e)))}async function rt(t,e,n="SHA-256",i=qe){const l=Date.now();for(let r=0;r<=i;r++)if(await de(e,r,n)===t)return{number:r,took:Date.now()-l};return null}var v=(t=>(t.ERROR="error",t.VERIFIED="verified",t.VERIFYING="verifying",t.UNVERIFIED="unverified",t.EXPIRED="expired",t))(v||{});function it(t){Re(t,"svelte-vuofbg",".altcha.svelte-vuofbg.svelte-vuofbg{background:var(--altcha-color-base, transparent);border:var(--altcha-border-width, 1px) solid var(--altcha-color-border, #a0a0a0);border-radius:var(--altcha-border-radius, 3px);color:var(--altcha-color-text, currentColor);display:flex;flex-direction:column;max-width:var(--altcha-max-width, 260px);overflow:hidden;position:relative;text-align:left}.altcha.svelte-vuofbg.svelte-vuofbg:focus-within{border-color:var(--altcha-color-border-focus, currentColor)}.altcha-main.svelte-vuofbg.svelte-vuofbg{align-items:center;display:flex;gap:0.4rem;padding:0.7rem}.altcha-label.svelte-vuofbg.svelte-vuofbg{flex-grow:1}.altcha-label.svelte-vuofbg label.svelte-vuofbg{cursor:pointer}.altcha-logo.svelte-vuofbg.svelte-vuofbg{color:currentColor;opacity:0.3}.altcha-logo.svelte-vuofbg.svelte-vuofbg:hover{opacity:1}.altcha-error.svelte-vuofbg.svelte-vuofbg{color:var(--altcha-color-error-text, #f23939);display:flex;font-size:0.85rem;gap:0.3rem;padding:0 0.7rem 0.7rem}.altcha-footer.svelte-vuofbg.svelte-vuofbg{align-items:center;background-color:var(--altcha-color-footer-bg, transparent);display:flex;font-size:0.75rem;opacity:0.4;padding:0.2rem 0.7rem;text-align:right}.altcha-footer.svelte-vuofbg.svelte-vuofbg:hover{opacity:1}.altcha-footer.svelte-vuofbg>.svelte-vuofbg:first-child{flex-grow:1}.altcha-footer.svelte-vuofbg a{color:currentColor}.altcha-checkbox.svelte-vuofbg.svelte-vuofbg{display:flex;align-items:center;height:24px;width:24px}.altcha-checkbox.svelte-vuofbg input.svelte-vuofbg{width:18px;height:18px;margin:0}.altcha-hidden.svelte-vuofbg.svelte-vuofbg{display:none}.altcha-spinner.svelte-vuofbg.svelte-vuofbg{animation:svelte-vuofbg-altcha-spinner 0.75s infinite linear;transform-origin:center}@keyframes svelte-vuofbg-altcha-spinner{100%{transform:rotate(360deg)}}")}function ge(t){let e,n,i;return{c(){e=V("svg"),n=V("path"),i=V("path"),c(n,"d","M12,1A11,11,0,1,0,23,12,11,11,0,0,0,12,1Zm0,19a8,8,0,1,1,8-8A8,8,0,0,1,12,20Z"),c(n,"fill","currentColor"),c(n,"opacity",".25"),c(i,"d","M12,4a8,8,0,0,1,7.89,6.7A1.53,1.53,0,0,0,21.38,12h0a1.5,1.5,0,0,0,1.48-1.75,11,11,0,0,0-21.72,0A1.5,1.5,0,0,0,2.62,12h0a1.53,1.53,0,0,0,1.49-1.3A8,8,0,0,1,12,4Z"),c(i,"fill","currentColor"),c(i,"class","altcha-spinner svelte-vuofbg"),c(e,"width","24"),c(e,"height","24"),c(e,"viewBox","0 0 24 24"),c(e,"xmlns","http://www.w3.org/2000/svg")},m(l,r){N(l,e,r),g(e,n),g(e,i)},d(l){l&&I(e)}}}function ot(t){let e,n=t[9].label+"",i;return{c(){e=$("label"),c(e,"for",i=t[3]+"_checkbox"),c(e,"class","svelte-vuofbg")},m(l,r){N(l,e,r),e.innerHTML=n},p(l,r){r[0]&512&&n!==(n=l[9].label+"")&&(e.innerHTML=n),r[0]&8&&i!==(i=l[3]+"_checkbox")&&c(e,"for",i)},d(l){l&&I(e)}}}function lt(t){let e,n=t[9].verifying+"";return{c(){e=$("span")},m(i,l){N(i,e,l),e.innerHTML=n},p(i,l){l[0]&512&&n!==(n=i[9].verifying+"")&&(e.innerHTML=n)},d(i){i&&I(e)}}}function st(t){let e,n=t[9].verified+"",i,l;return{c(){e=$("span"),i=F(),l=$("input"),c(l,"type","hidden"),c(l,"name",t[3]),l.value=t[4]},m(r,s){N(r,e,s),e.innerHTML=n,N(r,i,s),N(r,l,s)},p(r,s){s[0]&512&&n!==(n=r[9].verified+"")&&(e.innerHTML=n),s[0]&8&&c(l,"name",r[3]),s[0]&16&&(l.value=r[4])},d(r){r&&(I(e),I(i),I(l))}}}function be(t){let e,n,i,l,r,s;return{c(){e=$("div"),n=$("a"),i=V("svg"),l=V("path"),r=V("path"),s=V("path"),c(l,"d","M2.33955 16.4279C5.88954 20.6586 12.1971 21.2105 16.4279 17.6604C18.4699 15.947 19.6548 13.5911 19.9352 11.1365L17.9886 10.4279C17.8738 12.5624 16.909 14.6459 15.1423 16.1284C11.7577 18.9684 6.71167 18.5269 3.87164 15.1423C1.03163 11.7577 1.4731 6.71166 4.8577 3.87164C8.24231 1.03162 13.2883 1.4731 16.1284 4.8577C16.9767 5.86872 17.5322 7.02798 17.804 8.2324L19.9522 9.01429C19.7622 7.07737 19.0059 5.17558 17.6604 3.57212C14.1104 -0.658624 7.80283 -1.21043 3.57212 2.33956C-0.658625 5.88958 -1.21046 12.1971 2.33955 16.4279Z"),c(l,"fill","currentColor"),c(r,"d","M3.57212 2.33956C1.65755 3.94607 0.496389 6.11731 0.12782 8.40523L2.04639 9.13961C2.26047 7.15832 3.21057 5.25375 4.8577 3.87164C8.24231 1.03162 13.2883 1.4731 16.1284 4.8577L13.8302 6.78606L19.9633 9.13364C19.7929 7.15555 19.0335 5.20847 17.6604 3.57212C14.1104 -0.658624 7.80283 -1.21043 3.57212 2.33956Z"),c(r,"fill","currentColor"),c(s,"d","M7 10H5C5 12.7614 7.23858 15 10 15C12.7614 15 15 12.7614 15 10H13C13 11.6569 11.6569 13 10 13C8.3431 13 7 11.6569 7 10Z"),c(s,"fill","currentColor"),c(i,"width","22"),c(i,"height","22"),c(i,"viewBox","0 0 20 20"),c(i,"fill","none"),c(i,"xmlns","http://www.w3.org/2000/svg"),c(n,"href",_e),c(n,"target","_blank"),c(n,"class","altcha-logo svelte-vuofbg")},m(a,h){N(a,e,h),g(e,n),g(n,i),g(i,l),g(i,r),g(i,s)},p:k,d(a){a&&I(e)}}}function me(t){let e,n,i,l,r;return{c(){e=$("div"),n=V("svg"),i=V("path"),l=F(),r=$("div"),c(i,"stroke-linecap","round"),c(i,"stroke-linejoin","round"),c(i,"d","M6 18L18 6M6 6l12 12"),c(n,"width","14"),c(n,"height","14"),c(n,"xmlns","http://www.w3.org/2000/svg"),c(n,"fill","none"),c(n,"viewBox","0 0 24 24"),c(n,"stroke-width","1.5"),c(n,"stroke","currentColor"),c(e,"class","altcha-error svelte-vuofbg")},m(s,a){N(s,e,a),g(e,n),g(n,i),g(e,l),g(e,r),r.innerHTML=t[8]},p(s,a){a[0]&256&&(r.innerHTML=s[8])},d(s){s&&I(e)}}}function ve(t){let e,n,i=t[9].footer+"";return{c(){e=$("div"),n=$("div"),c(n,"class","svelte-vuofbg"),c(e,"class","altcha-footer svelte-vuofbg")},m(l,r){N(l,e,r),g(e,n),n.innerHTML=i},p(l,r){r[0]&512&&i!==(i=l[9].footer+"")&&(n.innerHTML=i)},d(l){l&&I(e)}}}function ct(t){let e,n,i,l,r,s,a,h,f,j,p,A,L,G,_=t[5]===v.VERIFYING&&ge();function M(u,y){return u[5]===v.VERIFIED?st:u[5]===v.VERIFYING?lt:ot}let Y=M(t),C=Y(t),w=t[2]!==!0&&be(),b=t[8]&&me(t),m=t[9].footer&&t[1]!==!0&&ve(t);return{c(){e=$("div"),n=$("div"),_&&_.c(),i=F(),l=$("div"),r=$("input"),h=F(),f=$("div"),C.c(),j=F(),w&&w.c(),p=F(),b&&b.c(),A=F(),m&&m.c(),c(r,"type","checkbox"),c(r,"id",s=t[3]+"_checkbox"),r.required=a=t[0]!=="onsubmit",c(r,"class","svelte-vuofbg"),c(l,"class","altcha-checkbox svelte-vuofbg"),le(l,"altcha-hidden",t[5]===v.VERIFYING),c(f,"class","altcha-label svelte-vuofbg"),c(n,"class","altcha-main svelte-vuofbg"),c(e,"class","altcha svelte-vuofbg"),c(e,"data-state",t[5])},m(u,y){N(u,e,y),g(e,n),_&&_.m(n,null),g(n,i),g(n,l),g(l,r),r.checked=t[6],g(n,h),g(n,f),C.m(f,null),g(n,j),w&&w.m(n,null),g(e,p),b&&b.m(e,null),g(e,A),m&&m.m(e,null),t[24](e),L||(G=[Q(r,"change",t[23]),Q(r,"change",t[10]),Q(r,"invalid",t[11])],L=!0)},p(u,y){u[5]===v.VERIFYING?_||(_=ge(),_.c(),_.m(n,i)):_&&(_.d(1),_=null),y[0]&8&&s!==(s=u[3]+"_checkbox")&&c(r,"id",s),y[0]&1&&a!==(a=u[0]!=="onsubmit")&&(r.required=a),y[0]&64&&(r.checked=u[6]),y[0]&32&&le(l,"altcha-hidden",u[5]===v.VERIFYING),Y===(Y=M(u))&&C?C.p(u,y):(C.d(1),C=Y(u),C&&(C.c(),C.m(f,null))),u[2]!==!0?w?w.p(u,y):(w=be(),w.c(),w.m(n,null)):w&&(w.d(1),w=null),u[8]?b?b.p(u,y):(b=me(u),b.c(),b.m(e,A)):b&&(b.d(1),b=null),u[9].footer&&u[1]!==!0?m?m.p(u,y):(m=ve(u),m.c(),m.m(e,null)):m&&(m.d(1),m=null),y[0]&32&&c(e,"data-state",u[5])},i:k,o:k,d(u){u&&I(e),_&&_.d(),C.d(),w&&w.d(),b&&b.d(),m&&m.d(),t[24](null),L=!1,T(G)}}}const _e="https://altcha.org/";function we(t){return JSON.parse(t)}function ut(t,e,n){let i,l,r,{auto:s=void 0}=e,{challengeurl:a=void 0}=e,{challengejson:h=void 0}=e,{debug:f=!1}=e,{hidefooter:j=!1}=e,{hidelogo:p=!1}=e,{name:A="altcha"}=e,{maxnumber:L=void 0}=e,{mockerror:G=!1}=e,{strings:_=void 0}=e,{test:M=!1}=e;const Y=Oe(),C=["SHA-256","SHA-384","SHA-512"],w=[];let b=!1,m,u=null,y=null,W=null,O=v.UNVERIFIED,ye;Ue(()=>{u&&(u.removeEventListener("submit",pe),u.removeEventListener("reset",ke),u=null)}),Me(()=>{x("mounted","0.1.9"),M&&x("using test mode"),s!==void 0&&x("auto",s),u=m.closest("form"),u&&(u.addEventListener("submit",pe),u.addEventListener("reset",ke)),s==="onload"&&K()});function x(...o){(f||o.some(d=>d instanceof Error))&&console[o[0]instanceof Error?"error":"log"]("ALTCHA",...o)}function pe(o){u&&s==="onsubmit"&&O===v.UNVERIFIED&&(o.preventDefault(),o.stopPropagation(),K().then(()=>{u==null||u.requestSubmit()}))}function ke(){J()}function at(o,d){return btoa(JSON.stringify({algorithm:o.algorithm,challenge:o.challenge,number:d.number,salt:o.salt,signature:o.signature,test:M?!0:void 0,took:d.took}))}function Ee(o){if(!o.algorithm)throw new Error("Invalid challenge. Property algorithm is missing.");if(o.signature===void 0)throw new Error("Invalid challenge. Property signature is missing.");if(!C.includes(o.algorithm.toUpperCase()))throw new Error(`Unknown algorithm value. Allowed values: ${C.join(", ")}`);if(!o.challenge||o.challenge.length<40)throw new Error("Challenge is too short. Min. 40 chars.");if(!o.salt||o.salt.length<10)throw new Error("Salt is too short. Min. 10 chars.")}async function ft(){if(G)throw x("mocking error"),new Error("Mocked error.");if(i)return x("using provided json data"),i;if(M)return x("generating test challenge"),nt();{if(!a)throw new Error("Attribute challengeurl not set.");x("fetching challenge from",a);const o=await fetch(a);if(o.status!==200)throw new Error(`Server responded with ${o.status}.`);const d=o.headers.get("Expires");if(d.length){const P=Date.parse(d)-Date.now();P<1?Ce():ye=setTimeout(Ce,P)}return o.json()}}function Ce(){J(v.EXPIRED,r.expired)}async function ht(o){let d=null;if("Worker"in window){try{d=await dt(o.challenge,o.salt,o.algorithm)}catch(P){x(P)}if((d==null?void 0:d.number)!==void 0)return{data:o,solution:d}}return{data:o,solution:await rt(o.challenge,o.salt,o.algorithm,L)}}async function dt(o,d,P){const xe=w.push(new Qe);return new Promise(wt=>{w[xe-1].addEventListener("message",$t=>{wt($t.data)}),w[xe-1].postMessage({alg:P,challenge:o,max:L,salt:d})})}function gt(){[v.UNVERIFIED,v.ERROR,v.EXPIRED].includes(O)?K():n(6,b=!0)}function bt(){O===v.VERIFYING&&alert(r.waitAlert)}function mt(o){o.auto!==void 0&&(n(0,s=o.auto),s==="onload"&&K()),o.challenge&&(Ee(o.challenge),i=o.challenge),o.debug!==void 0&&n(12,f=!!o.debug),o.hidefooter!==void 0&&n(1,j=!!o.hidefooter),o.hidelogo!==void 0&&n(2,p=!!o.hidelogo),o.maxnumber!==void 0&&n(13,L=+o.maxnumber),o.mockerror!==void 0&&n(14,G=!!o.mockerror),o.name!==void 0&&n(3,A=o.name),o.test!==void 0&&n(15,M=!!o.test),o.strings&&n(22,l=o.strings)}function J(o=v.UNVERIFIED,d=null){clearTimeout(ye),n(6,b=!1),n(8,y=d),n(4,W=null),n(5,O=o)}async function K(){return J(v.VERIFYING),ft().then(o=>(Ee(o),x("challenge",o),ht(o))).then(({data:o,solution:d})=>{if(x("solution",d),(d==null?void 0:d.number)!==void 0)x("verified"),n(5,O=v.VERIFIED),n(6,b=!0),n(4,W=at(o,d)),x("payload",W),Fe().then(()=>{Y("verified",{payload:W})});else throw new Error("Unexpected result returned.")}).catch(o=>{x(o),n(5,O=v.ERROR),n(6,b=!1),n(8,y=o.message)})}function vt(){b=this.checked,n(6,b)}function _t(o){ee[o?"unshift":"push"](()=>{m=o,n(7,m)})}return t.$$set=o=>{"auto"in o&&n(0,s=o.auto),"challengeurl"in o&&n(16,a=o.challengeurl),"challengejson"in o&&n(17,h=o.challengejson),"debug"in o&&n(12,f=o.debug),"hidefooter"in o&&n(1,j=o.hidefooter),"hidelogo"in o&&n(2,p=o.hidelogo),"name"in o&&n(3,A=o.name),"maxnumber"in o&&n(13,L=o.maxnumber),"mockerror"in o&&n(14,G=o.mockerror),"strings"in o&&n(18,_=o.strings),"test"in o&&n(15,M=o.test)},t.$$.update=()=>{t.$$.dirty[0]&131072&&(i=h?we(h):void 0),t.$$.dirty[0]&262144&&n(22,l=_?we(_):{}),t.$$.dirty[0]&4194304&&n(9,r={error:"Verification failed. Try again later.",expired:"Verification expired. Try again.",footer:`Protected by ALTCHA`,label:"I'm not a robot",verified:"Verified",verifying:"Verifying...",waitAlert:"Verifying... please wait.",...l}),t.$$.dirty[0]&48&&Y("statechange",{payload:W,state:O})},[s,j,p,A,W,O,b,m,y,r,gt,bt,f,L,G,M,a,h,_,mt,J,K,l,vt,_t]}class $e extends Ke{constructor(e){super(),De(this,e,ut,ct,Ie,{auto:0,challengeurl:16,challengejson:17,debug:12,hidefooter:1,hidelogo:2,name:3,maxnumber:13,mockerror:14,strings:18,test:15,configure:19,reset:20,verify:21},it,[-1,-1])}get auto(){return this.$$.ctx[0]}set auto(e){this.$$set({auto:e}),E()}get challengeurl(){return this.$$.ctx[16]}set challengeurl(e){this.$$set({challengeurl:e}),E()}get challengejson(){return this.$$.ctx[17]}set challengejson(e){this.$$set({challengejson:e}),E()}get debug(){return this.$$.ctx[12]}set debug(e){this.$$set({debug:e}),E()}get hidefooter(){return this.$$.ctx[1]}set hidefooter(e){this.$$set({hidefooter:e}),E()}get hidelogo(){return this.$$.ctx[2]}set hidelogo(e){this.$$set({hidelogo:e}),E()}get name(){return this.$$.ctx[3]}set name(e){this.$$set({name:e}),E()}get maxnumber(){return this.$$.ctx[13]}set maxnumber(e){this.$$set({maxnumber:e}),E()}get mockerror(){return this.$$.ctx[14]}set mockerror(e){this.$$set({mockerror:e}),E()}get strings(){return this.$$.ctx[18]}set strings(e){this.$$set({strings:e}),E()}get test(){return this.$$.ctx[15]}set test(e){this.$$set({test:e}),E()}get configure(){return this.$$.ctx[19]}get reset(){return this.$$.ctx[20]}get verify(){return this.$$.ctx[21]}}return customElements.define("altcha-widget",Xe($e,{auto:{},challengeurl:{},challengejson:{},debug:{type:"Boolean"},hidefooter:{type:"Boolean"},hidelogo:{type:"Boolean"},name:{},maxnumber:{},mockerror:{type:"Boolean"},strings:{},test:{type:"Boolean"}},[],["configure","reset","verify"],!1)),S.Altcha=$e,Object.defineProperty(S,Symbol.toStringTag,{value:"Module"}),S}({}); diff --git a/dist/altcha.js b/dist/altcha.js index 0b0e49c..b686224 100644 --- a/dist/altcha.js +++ b/dist/altcha.js @@ -1,37 +1,37 @@ -var Ge = Object.defineProperty; -var Se = (t, e, n) => e in t ? Ge(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n; -var L = (t, e, n) => (Se(t, typeof e != "symbol" ? e + "" : e, n), n); -function Z() { +var Ue = Object.defineProperty; +var Me = (t, e, n) => e in t ? Ue(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n; +var I = (t, e, n) => (Me(t, typeof e != "symbol" ? e + "" : e, n), n); +function H() { } -function ge(t) { +function ve(t) { return t(); } -function ie() { +function ce() { return /* @__PURE__ */ Object.create(null); } -function P(t) { - t.forEach(ge); +function T(t) { + t.forEach(ve); } -function be(t) { +function _e(t) { return typeof t == "function"; } -function Ue(t, e) { +function Fe(t, e) { return t != t ? e == e : t !== e || t && typeof t == "object" || typeof t == "function"; } -function Ve(t) { +function Oe(t) { return Object.keys(t).length === 0; } function b(t, e) { t.appendChild(e); } -function Me(t, e, n) { - const o = Fe(t); - if (!o.getElementById(e)) { +function Ye(t, e, n) { + const i = Ze(t); + if (!i.getElementById(e)) { const l = $("style"); - l.id = e, l.textContent = n, Oe(o, l); + l.id = e, l.textContent = n, Be(i, l); } } -function Fe(t) { +function Ze(t) { if (!t) return document; const e = t.getRootNode ? t.getRootNode() : t.ownerDocument; @@ -41,7 +41,7 @@ function Fe(t) { e ) : t.ownerDocument; } -function Oe(t, e) { +function Be(t, e) { return b( /** @type {Document} */ t.head || t, @@ -51,37 +51,37 @@ function Oe(t, e) { function N(t, e, n) { t.insertBefore(e, n || null); } -function I(t) { +function L(t) { t.parentNode && t.parentNode.removeChild(t); } function $(t) { return document.createElement(t); } -function S(t) { +function V(t) { return document.createElementNS("http://www.w3.org/2000/svg", t); } -function Ye(t) { +function He(t) { return document.createTextNode(t); } function M() { - return Ye(" "); + return He(" "); } -function K(t, e, n, o) { - return t.addEventListener(e, n, o), () => t.removeEventListener(e, n, o); +function z(t, e, n, i) { + return t.addEventListener(e, n, i), () => t.removeEventListener(e, n, i); } function c(t, e, n) { n == null ? t.removeAttribute(e) : t.getAttribute(e) !== n && t.setAttribute(e, n); } -function Ze(t) { +function We(t) { return Array.from(t.childNodes); } -function le(t, e, n) { +function ue(t, e, n) { t.classList.toggle(e, !!n); } -function Be(t, e, { bubbles: n = !1, cancelable: o = !1 } = {}) { - return new CustomEvent(t, { detail: e, bubbles: n, cancelable: o }); +function De(t, e, { bubbles: n = !1, cancelable: i = !1 } = {}) { + return new CustomEvent(t, { detail: e, bubbles: n, cancelable: i }); } -function He(t) { +function Pe(t) { const e = {}; return t.childNodes.forEach( /** @param {Element} node */ @@ -90,31 +90,31 @@ function He(t) { } ), e; } -let W; -function H(t) { - W = t; +let P; +function D(t) { + P = t; } -function ee() { - if (!W) +function te() { + if (!P) throw new Error("Function called outside component initialization"); - return W; + return P; } -function We(t) { - ee().$$.on_mount.push(t); +function Te(t) { + te().$$.on_mount.push(t); } -function Pe(t) { - ee().$$.on_destroy.push(t); +function Xe(t) { + te().$$.on_destroy.push(t); } -function Te() { - const t = ee(); - return (e, n, { cancelable: o = !1 } = {}) => { +function Ke() { + const t = te(); + return (e, n, { cancelable: i = !1 } = {}) => { const l = t.$$.callbacks[e]; if (l) { - const r = Be( + const r = De( /** @type {string} */ e, n, - { cancelable: o } + { cancelable: i } ); return l.slice().forEach((s) => { s.call(t, r); @@ -123,147 +123,147 @@ function Te() { return !0; }; } -const O = [], J = []; -let Y = []; -const se = [], me = /* @__PURE__ */ Promise.resolve(); -let Q = !1; -function ve() { - Q || (Q = !0, me.then(C)); +const Z = [], Q = []; +let B = []; +const ae = [], we = /* @__PURE__ */ Promise.resolve(); +let q = !1; +function $e() { + q || (q = !0, we.then(x)); } -function Xe() { - return ve(), me; +function ze() { + return $e(), we; } -function q(t) { - Y.push(t); +function ee(t) { + B.push(t); } -const z = /* @__PURE__ */ new Set(); -let F = 0; -function C() { - if (F !== 0) +const J = /* @__PURE__ */ new Set(); +let Y = 0; +function x() { + if (Y !== 0) return; - const t = W; + const t = P; do { try { - for (; F < O.length; ) { - const e = O[F]; - F++, H(e), De(e.$$); + for (; Y < Z.length; ) { + const e = Z[Y]; + Y++, D(e), Je(e.$$); } } catch (e) { - throw O.length = 0, F = 0, e; + throw Z.length = 0, Y = 0, e; } - for (H(null), O.length = 0, F = 0; J.length; ) - J.pop()(); - for (let e = 0; e < Y.length; e += 1) { - const n = Y[e]; - z.has(n) || (z.add(n), n()); + for (D(null), Z.length = 0, Y = 0; Q.length; ) + Q.pop()(); + for (let e = 0; e < B.length; e += 1) { + const n = B[e]; + J.has(n) || (J.add(n), n()); } - Y.length = 0; - } while (O.length); - for (; se.length; ) - se.pop()(); - Q = !1, z.clear(), H(t); + B.length = 0; + } while (Z.length); + for (; ae.length; ) + ae.pop()(); + q = !1, J.clear(), D(t); } -function De(t) { +function Je(t) { if (t.fragment !== null) { - t.update(), P(t.before_update); + t.update(), T(t.before_update); const e = t.dirty; - t.dirty = [-1], t.fragment && t.fragment.p(t.ctx, e), t.after_update.forEach(q); + t.dirty = [-1], t.fragment && t.fragment.p(t.ctx, e), t.after_update.forEach(ee); } } -function Ke(t) { +function Qe(t) { const e = [], n = []; - Y.forEach((o) => t.indexOf(o) === -1 ? e.push(o) : n.push(o)), n.forEach((o) => o()), Y = e; + B.forEach((i) => t.indexOf(i) === -1 ? e.push(i) : n.push(i)), n.forEach((i) => i()), B = e; } -const ze = /* @__PURE__ */ new Set(); -function Je(t, e) { - t && t.i && (ze.delete(t), t.i(e)); +const qe = /* @__PURE__ */ new Set(); +function et(t, e) { + t && t.i && (qe.delete(t), t.i(e)); } -function Qe(t, e, n) { - const { fragment: o, after_update: l } = t.$$; - o && o.m(e, n), q(() => { - const r = t.$$.on_mount.map(ge).filter(be); - t.$$.on_destroy ? t.$$.on_destroy.push(...r) : P(r), t.$$.on_mount = []; - }), l.forEach(q); +function tt(t, e, n) { + const { fragment: i, after_update: l } = t.$$; + i && i.m(e, n), ee(() => { + const r = t.$$.on_mount.map(ve).filter(_e); + t.$$.on_destroy ? t.$$.on_destroy.push(...r) : T(r), t.$$.on_mount = []; + }), l.forEach(ee); } -function qe(t, e) { +function nt(t, e) { const n = t.$$; - n.fragment !== null && (Ke(n.after_update), P(n.on_destroy), n.fragment && n.fragment.d(e), n.on_destroy = n.fragment = null, n.ctx = []); + n.fragment !== null && (Qe(n.after_update), T(n.on_destroy), n.fragment && n.fragment.d(e), n.on_destroy = n.fragment = null, n.ctx = []); } -function et(t, e) { - t.$$.dirty[0] === -1 && (O.push(t), ve(), t.$$.dirty.fill(0)), t.$$.dirty[e / 31 | 0] |= 1 << e % 31; +function rt(t, e) { + t.$$.dirty[0] === -1 && (Z.push(t), $e(), t.$$.dirty.fill(0)), t.$$.dirty[e / 31 | 0] |= 1 << e % 31; } -function tt(t, e, n, o, l, r, s = null, u = [-1]) { - const f = W; - H(t); - const a = t.$$ = { +function it(t, e, n, i, l, r, s = null, a = [-1]) { + const h = P; + D(t); + const f = t.$$ = { fragment: null, ctx: [], // state props: r, - update: Z, + update: H, not_equal: l, - bound: ie(), + bound: ce(), // lifecycle on_mount: [], on_destroy: [], on_disconnect: [], before_update: [], after_update: [], - context: new Map(e.context || (f ? f.$$.context : [])), + context: new Map(e.context || (h ? h.$$.context : [])), // everything else - callbacks: ie(), - dirty: u, + callbacks: ce(), + dirty: a, skip_bound: !1, - root: e.target || f.$$.root + root: e.target || h.$$.root }; - s && s(a.root); + s && s(f.root); let R = !1; - if (a.ctx = n ? n(t, e.props || {}, (p, j, ...x) => { - const A = x.length ? x[0] : j; - return a.ctx && l(a.ctx[p], a.ctx[p] = A) && (!a.skip_bound && a.bound[p] && a.bound[p](A), R && et(t, p)), j; - }) : [], a.update(), R = !0, P(a.before_update), a.fragment = o ? o(a.ctx) : !1, e.target) { + if (f.ctx = n ? n(t, e.props || {}, (p, j, ...C) => { + const A = C.length ? C[0] : j; + return f.ctx && l(f.ctx[p], f.ctx[p] = A) && (!f.skip_bound && f.bound[p] && f.bound[p](A), R && rt(t, p)), j; + }) : [], f.update(), R = !0, T(f.before_update), f.fragment = i ? i(f.ctx) : !1, e.target) { if (e.hydrate) { - const p = Ze(e.target); - a.fragment && a.fragment.l(p), p.forEach(I); + const p = We(e.target); + f.fragment && f.fragment.l(p), p.forEach(L); } else - a.fragment && a.fragment.c(); - e.intro && Je(t.$$.fragment), Qe(t, e.target, e.anchor), C(); + f.fragment && f.fragment.c(); + e.intro && et(t.$$.fragment), tt(t, e.target, e.anchor), x(); } - H(f); + D(h); } -let _e; -typeof HTMLElement == "function" && (_e = class extends HTMLElement { - constructor(e, n, o) { +let ye; +typeof HTMLElement == "function" && (ye = class extends HTMLElement { + constructor(e, n, i) { super(); /** The Svelte component constructor */ - L(this, "$$ctor"); + I(this, "$$ctor"); /** Slots */ - L(this, "$$s"); + I(this, "$$s"); /** The Svelte component instance */ - L(this, "$$c"); + I(this, "$$c"); /** Whether or not the custom element is connected */ - L(this, "$$cn", !1); + I(this, "$$cn", !1); /** Component props data */ - L(this, "$$d", {}); + I(this, "$$d", {}); /** `true` if currently in the process of reflecting component props back to attributes */ - L(this, "$$r", !1); + I(this, "$$r", !1); /** @type {Record} Props definition (name, reflected, type etc) */ - L(this, "$$p_d", {}); + I(this, "$$p_d", {}); /** @type {Record} Event listeners */ - L(this, "$$l", {}); + I(this, "$$l", {}); /** @type {Map} Event listener unsubscribe functions */ - L(this, "$$l_u", /* @__PURE__ */ new Map()); - this.$$ctor = e, this.$$s = n, o && this.attachShadow({ mode: "open" }); + I(this, "$$l_u", /* @__PURE__ */ new Map()); + this.$$ctor = e, this.$$s = n, i && this.attachShadow({ mode: "open" }); } - addEventListener(e, n, o) { + addEventListener(e, n, i) { if (this.$$l[e] = this.$$l[e] || [], this.$$l[e].push(n), this.$$c) { const l = this.$$c.$on(e, n); this.$$l_u.set(n, l); } - super.addEventListener(e, n, o); + super.addEventListener(e, n, i); } - removeEventListener(e, n, o) { - if (super.removeEventListener(e, n, o), this.$$c) { + removeEventListener(e, n, i) { + if (super.removeEventListener(e, n, i), this.$$c) { const l = this.$$l_u.get(n); l && (l(), this.$$l_u.delete(n)); } @@ -281,23 +281,23 @@ typeof HTMLElement == "function" && (_e = class extends HTMLElement { * @param {HTMLElement} target * @param {HTMLElement} [anchor] */ - m: function(a, R) { - N(a, s, R); + m: function(f, R) { + N(f, s, R); }, - d: function(a) { - a && I(s); + d: function(f) { + f && L(s); } }; }; }; if (await Promise.resolve(), !this.$$cn || this.$$c) return; - const n = {}, o = He(this); + const n = {}, i = Pe(this); for (const r of this.$$s) - r in o && (n[r] = [e(r)]); + r in i && (n[r] = [e(r)]); for (const r of this.attributes) { const s = this.$$g_p(r.name); - s in this.$$d || (this.$$d[s] = T(s, r.value, this.$$p_d, "toProp")); + s in this.$$d || (this.$$d[s] = K(s, r.value, this.$$p_d, "toProp")); } for (const r in this.$$p_d) !(r in this.$$d) && this[r] !== void 0 && (this.$$d[r] = this[r], delete this[r]); @@ -315,7 +315,7 @@ typeof HTMLElement == "function" && (_e = class extends HTMLElement { this.$$r = !0; for (const r in this.$$p_d) if (this.$$d[r] = this.$$c.$$.ctx[this.$$c.$$.props[r]], this.$$p_d[r].reflect) { - const s = T( + const s = K( r, this.$$d[r], this.$$p_d, @@ -328,17 +328,17 @@ typeof HTMLElement == "function" && (_e = class extends HTMLElement { this.$$c.$$.after_update.push(l), l(); for (const r in this.$$l) for (const s of this.$$l[r]) { - const u = this.$$c.$on(r, s); - this.$$l_u.set(s, u); + const a = this.$$c.$on(r, s); + this.$$l_u.set(s, a); } this.$$l = {}; } } // We don't need this when working within Svelte code, but for compatibility of people using this outside of Svelte // and setting attributes through setAttribute etc, this is helpful - attributeChangedCallback(e, n, o) { + attributeChangedCallback(e, n, i) { var l; - this.$$r || (e = this.$$g_p(e), this.$$d[e] = T(e, o, this.$$p_d, "toProp"), (l = this.$$c) == null || l.$set({ [e]: this.$$d[e] })); + this.$$r || (e = this.$$g_p(e), this.$$d[e] = K(e, i, this.$$p_d, "toProp"), (l = this.$$c) == null || l.$set({ [e]: this.$$d[e] })); } disconnectedCallback() { this.$$cn = !1, Promise.resolve().then(() => { @@ -351,12 +351,12 @@ typeof HTMLElement == "function" && (_e = class extends HTMLElement { ) || e; } }); -function T(t, e, n, o) { +function K(t, e, n, i) { var r; const l = (r = n[t]) == null ? void 0 : r.type; - if (e = l === "Boolean" && typeof e != "boolean" ? e != null : e, !o || !n[t]) + if (e = l === "Boolean" && typeof e != "boolean" ? e != null : e, !i || !n[t]) return e; - if (o === "toAttribute") + if (i === "toAttribute") switch (l) { case "Object": case "Array": @@ -381,38 +381,38 @@ function T(t, e, n, o) { return e; } } -function nt(t, e, n, o, l, r) { - let s = class extends _e { +function ot(t, e, n, i, l, r) { + let s = class extends ye { constructor() { super(t, n, l), this.$$p_d = e; } static get observedAttributes() { return Object.keys(e).map( - (u) => (e[u].attribute || u).toLowerCase() + (a) => (e[a].attribute || a).toLowerCase() ); } }; - return Object.keys(e).forEach((u) => { - Object.defineProperty(s.prototype, u, { + return Object.keys(e).forEach((a) => { + Object.defineProperty(s.prototype, a, { get() { - return this.$$c && u in this.$$c ? this.$$c[u] : this.$$d[u]; + return this.$$c && a in this.$$c ? this.$$c[a] : this.$$d[a]; }, - set(f) { - var a; - f = T(u, f, e), this.$$d[u] = f, (a = this.$$c) == null || a.$set({ [u]: f }); + set(h) { + var f; + h = K(a, h, e), this.$$d[a] = h, (f = this.$$c) == null || f.$set({ [a]: h }); } }); - }), o.forEach((u) => { - Object.defineProperty(s.prototype, u, { + }), i.forEach((a) => { + Object.defineProperty(s.prototype, a, { get() { - var f; - return (f = this.$$c) == null ? void 0 : f[u]; + var h; + return (h = this.$$c) == null ? void 0 : h[a]; } }); }), r && (s = r(s)), t.element = /** @type {any} */ s, s; } -class rt { +class lt { constructor() { /** * ### PRIVATE API @@ -421,7 +421,7 @@ class rt { * * @type {any} */ - L(this, "$$"); + I(this, "$$"); /** * ### PRIVATE API * @@ -429,11 +429,11 @@ class rt { * * @type {any} */ - L(this, "$$set"); + I(this, "$$set"); } /** @returns {void} */ $destroy() { - qe(this, 1), this.$destroy = Z; + nt(this, 1), this.$destroy = H; } /** * @template {Extract} K @@ -442,12 +442,12 @@ class rt { * @returns {() => void} */ $on(e, n) { - if (!be(n)) - return Z; - const o = this.$$.callbacks[e] || (this.$$.callbacks[e] = []); - return o.push(n), () => { - const l = o.indexOf(n); - l !== -1 && o.splice(l, 1); + if (!_e(n)) + return H; + const i = this.$$.callbacks[e] || (this.$$.callbacks[e] = []); + return i.push(n), () => { + const l = i.indexOf(n); + l !== -1 && i.splice(l, 1); }; } /** @@ -455,16 +455,16 @@ class rt { * @returns {void} */ $set(e) { - this.$$set && !Ve(e) && (this.$$.skip_bound = !0, this.$$set(e), this.$$.skip_bound = !1); + this.$$set && !Oe(e) && (this.$$.skip_bound = !0, this.$$set(e), this.$$.skip_bound = !1); } } -const ot = "4"; -typeof window < "u" && (window.__svelte || (window.__svelte = { v: /* @__PURE__ */ new Set() })).v.add(ot); -const we = "KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0IHI9bmV3IFRleHRFbmNvZGVyO2Z1bmN0aW9uIGMoZSl7cmV0dXJuWy4uLm5ldyBVaW50OEFycmF5KGUpXS5tYXAobj0+bi50b1N0cmluZygxNikucGFkU3RhcnQoMiwiMCIpKS5qb2luKCIiKX1hc3luYyBmdW5jdGlvbiBsKGUsbixhKXtyZXR1cm4gYyhhd2FpdCBjcnlwdG8uc3VidGxlLmRpZ2VzdChhLnRvVXBwZXJDYXNlKCksci5lbmNvZGUoZStuKSkpfWFzeW5jIGZ1bmN0aW9uIGkoZSxuLGE9IlNIQS0yNTYiLG89MWU3KXtjb25zdCBzPURhdGUubm93KCk7Zm9yKGxldCB0PTA7dDw9bzt0KyspaWYoYXdhaXQgbChuLHQsYSk9PT1lKXJldHVybntudW1iZXI6dCx0b29rOkRhdGUubm93KCktc307cmV0dXJuIG51bGx9b25tZXNzYWdlPWFzeW5jIGU9Pntjb25zdHthbGc6bixjaGFsbGVuZ2U6YSxtYXg6byxzYWx0OnN9PWUuZGF0YXx8e307aWYoYSYmcyl7Y29uc3QgdD1hd2FpdCBpKGEscyxuLG8pO3NlbGYucG9zdE1lc3NhZ2UodCYmey4uLnQsd29ya2VyOiEwfSl9ZWxzZSBzZWxmLnBvc3RNZXNzYWdlKG51bGwpfX0pKCk7Cg==", it = (t) => Uint8Array.from(atob(t), (e) => e.charCodeAt(0)), ce = typeof window < "u" && window.Blob && new Blob([it(we)], { type: "text/javascript;charset=utf-8" }); -function lt(t) { +const st = "4"; +typeof window < "u" && (window.__svelte || (window.__svelte = { v: /* @__PURE__ */ new Set() })).v.add(st); +const pe = "KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0IHI9bmV3IFRleHRFbmNvZGVyO2Z1bmN0aW9uIGMoZSl7cmV0dXJuWy4uLm5ldyBVaW50OEFycmF5KGUpXS5tYXAobj0+bi50b1N0cmluZygxNikucGFkU3RhcnQoMiwiMCIpKS5qb2luKCIiKX1hc3luYyBmdW5jdGlvbiBsKGUsbixhKXtyZXR1cm4gYyhhd2FpdCBjcnlwdG8uc3VidGxlLmRpZ2VzdChhLnRvVXBwZXJDYXNlKCksci5lbmNvZGUoZStuKSkpfWFzeW5jIGZ1bmN0aW9uIGkoZSxuLGE9IlNIQS0yNTYiLG89MWU3KXtjb25zdCBzPURhdGUubm93KCk7Zm9yKGxldCB0PTA7dDw9bzt0KyspaWYoYXdhaXQgbChuLHQsYSk9PT1lKXJldHVybntudW1iZXI6dCx0b29rOkRhdGUubm93KCktc307cmV0dXJuIG51bGx9b25tZXNzYWdlPWFzeW5jIGU9Pntjb25zdHthbGc6bixjaGFsbGVuZ2U6YSxtYXg6byxzYWx0OnN9PWUuZGF0YXx8e307aWYoYSYmcyl7Y29uc3QgdD1hd2FpdCBpKGEscyxuLG8pO3NlbGYucG9zdE1lc3NhZ2UodCYmey4uLnQsd29ya2VyOiEwfSl9ZWxzZSBzZWxmLnBvc3RNZXNzYWdlKG51bGwpfX0pKCk7Cg==", ct = (t) => Uint8Array.from(atob(t), (e) => e.charCodeAt(0)), fe = typeof window < "u" && window.Blob && new Blob([ct(pe)], { type: "text/javascript;charset=utf-8" }); +function ut(t) { let e; try { - if (e = ce && (window.URL || window.webkitURL).createObjectURL(ce), !e) + if (e = fe && (window.URL || window.webkitURL).createObjectURL(fe), !e) throw ""; const n = new Worker(e, { name: t == null ? void 0 : t.name @@ -474,7 +474,7 @@ function lt(t) { }), n; } catch { return new Worker( - "data:text/javascript;base64," + we, + "data:text/javascript;base64," + pe, { name: t == null ? void 0 : t.name } @@ -483,12 +483,12 @@ function lt(t) { e && (window.URL || window.webkitURL).revokeObjectURL(e); } } -const st = 1e7, ct = new TextEncoder(); -function ut(t) { +const at = 1e7, ft = new TextEncoder(); +function ht(t) { return [...new Uint8Array(t)].map((e) => e.toString(16).padStart(2, "0")).join(""); } -async function at(t = 1e5, e = "SHA-256") { - const n = Date.now().toString(16), o = Math.round(Math.random() * t), l = await $e(n, o, e); +async function dt(t = 1e5, e = "SHA-256") { + const n = Date.now().toString(16), i = Math.round(Math.random() * t), l = await ke(n, i, e); return { algorithm: e, challenge: l, @@ -496,45 +496,45 @@ async function at(t = 1e5, e = "SHA-256") { signature: "" }; } -async function $e(t, e, n) { - return ut(await crypto.subtle.digest(n.toUpperCase(), ct.encode(t + e))); +async function ke(t, e, n) { + return ht(await crypto.subtle.digest(n.toUpperCase(), ft.encode(t + e))); } -async function ft(t, e, n = "SHA-256", o = st) { +async function gt(t, e, n = "SHA-256", i = at) { const l = Date.now(); - for (let r = 0; r <= o; r++) - if (await $e(e, r, n) === t) + for (let r = 0; r <= i; r++) + if (await ke(e, r, n) === t) return { number: r, took: Date.now() - l }; return null; } -var y = /* @__PURE__ */ ((t) => (t.ERROR = "error", t.VERIFIED = "verified", t.VERIFYING = "verifying", t.UNVERIFIED = "unverified", t))(y || {}); -function ht(t) { - Me(t, "svelte-vuofbg", ".altcha.svelte-vuofbg.svelte-vuofbg{background:var(--altcha-color-base, transparent);border:var(--altcha-border-width, 1px) solid var(--altcha-color-border, #a0a0a0);border-radius:var(--altcha-border-radius, 3px);color:var(--altcha-color-text, currentColor);display:flex;flex-direction:column;max-width:var(--altcha-max-width, 260px);overflow:hidden;position:relative;text-align:left}.altcha.svelte-vuofbg.svelte-vuofbg:focus-within{border-color:var(--altcha-color-border-focus, currentColor)}.altcha-main.svelte-vuofbg.svelte-vuofbg{align-items:center;display:flex;gap:0.4rem;padding:0.7rem}.altcha-label.svelte-vuofbg.svelte-vuofbg{flex-grow:1}.altcha-label.svelte-vuofbg label.svelte-vuofbg{cursor:pointer}.altcha-logo.svelte-vuofbg.svelte-vuofbg{color:currentColor;opacity:0.3}.altcha-logo.svelte-vuofbg.svelte-vuofbg:hover{opacity:1}.altcha-error.svelte-vuofbg.svelte-vuofbg{color:var(--altcha-color-error-text, #f23939);display:flex;font-size:0.85rem;gap:0.3rem;padding:0 0.7rem 0.7rem}.altcha-footer.svelte-vuofbg.svelte-vuofbg{align-items:center;background-color:var(--altcha-color-footer-bg, transparent);display:flex;font-size:0.75rem;opacity:0.4;padding:0.2rem 0.7rem;text-align:right}.altcha-footer.svelte-vuofbg.svelte-vuofbg:hover{opacity:1}.altcha-footer.svelte-vuofbg>.svelte-vuofbg:first-child{flex-grow:1}.altcha-footer.svelte-vuofbg a{color:currentColor}.altcha-checkbox.svelte-vuofbg.svelte-vuofbg{display:flex;align-items:center;height:24px;width:24px}.altcha-checkbox.svelte-vuofbg input.svelte-vuofbg{width:18px;height:18px;margin:0}.altcha-hidden.svelte-vuofbg.svelte-vuofbg{display:none}.altcha-spinner.svelte-vuofbg.svelte-vuofbg{animation:svelte-vuofbg-altcha-spinner 0.75s infinite linear;transform-origin:center}@keyframes svelte-vuofbg-altcha-spinner{100%{transform:rotate(360deg)}}"); +var w = /* @__PURE__ */ ((t) => (t.ERROR = "error", t.VERIFIED = "verified", t.VERIFYING = "verifying", t.UNVERIFIED = "unverified", t.EXPIRED = "expired", t))(w || {}); +function bt(t) { + Ye(t, "svelte-vuofbg", ".altcha.svelte-vuofbg.svelte-vuofbg{background:var(--altcha-color-base, transparent);border:var(--altcha-border-width, 1px) solid var(--altcha-color-border, #a0a0a0);border-radius:var(--altcha-border-radius, 3px);color:var(--altcha-color-text, currentColor);display:flex;flex-direction:column;max-width:var(--altcha-max-width, 260px);overflow:hidden;position:relative;text-align:left}.altcha.svelte-vuofbg.svelte-vuofbg:focus-within{border-color:var(--altcha-color-border-focus, currentColor)}.altcha-main.svelte-vuofbg.svelte-vuofbg{align-items:center;display:flex;gap:0.4rem;padding:0.7rem}.altcha-label.svelte-vuofbg.svelte-vuofbg{flex-grow:1}.altcha-label.svelte-vuofbg label.svelte-vuofbg{cursor:pointer}.altcha-logo.svelte-vuofbg.svelte-vuofbg{color:currentColor;opacity:0.3}.altcha-logo.svelte-vuofbg.svelte-vuofbg:hover{opacity:1}.altcha-error.svelte-vuofbg.svelte-vuofbg{color:var(--altcha-color-error-text, #f23939);display:flex;font-size:0.85rem;gap:0.3rem;padding:0 0.7rem 0.7rem}.altcha-footer.svelte-vuofbg.svelte-vuofbg{align-items:center;background-color:var(--altcha-color-footer-bg, transparent);display:flex;font-size:0.75rem;opacity:0.4;padding:0.2rem 0.7rem;text-align:right}.altcha-footer.svelte-vuofbg.svelte-vuofbg:hover{opacity:1}.altcha-footer.svelte-vuofbg>.svelte-vuofbg:first-child{flex-grow:1}.altcha-footer.svelte-vuofbg a{color:currentColor}.altcha-checkbox.svelte-vuofbg.svelte-vuofbg{display:flex;align-items:center;height:24px;width:24px}.altcha-checkbox.svelte-vuofbg input.svelte-vuofbg{width:18px;height:18px;margin:0}.altcha-hidden.svelte-vuofbg.svelte-vuofbg{display:none}.altcha-spinner.svelte-vuofbg.svelte-vuofbg{animation:svelte-vuofbg-altcha-spinner 0.75s infinite linear;transform-origin:center}@keyframes svelte-vuofbg-altcha-spinner{100%{transform:rotate(360deg)}}"); } -function ue(t) { - let e, n, o; +function he(t) { + let e, n, i; return { c() { - e = S("svg"), n = S("path"), o = S("path"), c(n, "d", "M12,1A11,11,0,1,0,23,12,11,11,0,0,0,12,1Zm0,19a8,8,0,1,1,8-8A8,8,0,0,1,12,20Z"), c(n, "fill", "currentColor"), c(n, "opacity", ".25"), c(o, "d", "M12,4a8,8,0,0,1,7.89,6.7A1.53,1.53,0,0,0,21.38,12h0a1.5,1.5,0,0,0,1.48-1.75,11,11,0,0,0-21.72,0A1.5,1.5,0,0,0,2.62,12h0a1.53,1.53,0,0,0,1.49-1.3A8,8,0,0,1,12,4Z"), c(o, "fill", "currentColor"), c(o, "class", "altcha-spinner svelte-vuofbg"), c(e, "width", "24"), c(e, "height", "24"), c(e, "viewBox", "0 0 24 24"), c(e, "xmlns", "http://www.w3.org/2000/svg"); + e = V("svg"), n = V("path"), i = V("path"), c(n, "d", "M12,1A11,11,0,1,0,23,12,11,11,0,0,0,12,1Zm0,19a8,8,0,1,1,8-8A8,8,0,0,1,12,20Z"), c(n, "fill", "currentColor"), c(n, "opacity", ".25"), c(i, "d", "M12,4a8,8,0,0,1,7.89,6.7A1.53,1.53,0,0,0,21.38,12h0a1.5,1.5,0,0,0,1.48-1.75,11,11,0,0,0-21.72,0A1.5,1.5,0,0,0,2.62,12h0a1.53,1.53,0,0,0,1.49-1.3A8,8,0,0,1,12,4Z"), c(i, "fill", "currentColor"), c(i, "class", "altcha-spinner svelte-vuofbg"), c(e, "width", "24"), c(e, "height", "24"), c(e, "viewBox", "0 0 24 24"), c(e, "xmlns", "http://www.w3.org/2000/svg"); }, m(l, r) { - N(l, e, r), b(e, n), b(e, o); + N(l, e, r), b(e, n), b(e, i); }, d(l) { - l && I(e); + l && L(e); } }; } -function dt(t) { +function mt(t) { let e, n = ( /*_strings*/ t[9].label + "" - ), o; + ), i; return { c() { - e = $("label"), c(e, "for", o = /*name*/ + e = $("label"), c(e, "for", i = /*name*/ t[3] + "_checkbox"), c(e, "class", "svelte-vuofbg"); }, m(l, r) { @@ -544,15 +544,15 @@ function dt(t) { r[0] & /*_strings*/ 512 && n !== (n = /*_strings*/ l[9].label + "") && (e.innerHTML = n), r[0] & /*name*/ - 8 && o !== (o = /*name*/ - l[3] + "_checkbox") && c(e, "for", o); + 8 && i !== (i = /*name*/ + l[3] + "_checkbox") && c(e, "for", i); }, d(l) { - l && I(e); + l && L(e); } }; } -function gt(t) { +function vt(t) { let e, n = ( /*_strings*/ t[9].verifying + "" @@ -561,27 +561,27 @@ function gt(t) { c() { e = $("span"); }, - m(o, l) { - N(o, e, l), e.innerHTML = n; + m(i, l) { + N(i, e, l), e.innerHTML = n; }, - p(o, l) { + p(i, l) { l[0] & /*_strings*/ 512 && n !== (n = /*_strings*/ - o[9].verifying + "") && (e.innerHTML = n); + i[9].verifying + "") && (e.innerHTML = n); }, - d(o) { - o && I(e); + d(i) { + i && L(e); } }; } -function bt(t) { +function _t(t) { let e, n = ( /*_strings*/ t[9].verified + "" - ), o, l; + ), i, l; return { c() { - e = $("span"), o = M(), l = $("input"), c(l, "type", "hidden"), c( + e = $("span"), i = M(), l = $("input"), c(l, "type", "hidden"), c( l, "name", /*name*/ @@ -590,7 +590,7 @@ function bt(t) { t[4]; }, m(r, s) { - N(r, e, s), e.innerHTML = n, N(r, o, s), N(r, l, s); + N(r, e, s), e.innerHTML = n, N(r, i, s), N(r, l, s); }, p(r, s) { s[0] & /*_strings*/ @@ -606,60 +606,47 @@ function bt(t) { r[4]); }, d(r) { - r && (I(e), I(o), I(l)); + r && (L(e), L(i), L(l)); } }; } -function ae(t) { - let e, n, o, l, r, s; +function de(t) { + let e, n, i, l, r, s; return { c() { - e = $("div"), n = $("a"), o = S("svg"), l = S("path"), r = S("path"), s = S("path"), c(l, "d", "M2.33955 16.4279C5.88954 20.6586 12.1971 21.2105 16.4279 17.6604C18.4699 15.947 19.6548 13.5911 19.9352 11.1365L17.9886 10.4279C17.8738 12.5624 16.909 14.6459 15.1423 16.1284C11.7577 18.9684 6.71167 18.5269 3.87164 15.1423C1.03163 11.7577 1.4731 6.71166 4.8577 3.87164C8.24231 1.03162 13.2883 1.4731 16.1284 4.8577C16.9767 5.86872 17.5322 7.02798 17.804 8.2324L19.9522 9.01429C19.7622 7.07737 19.0059 5.17558 17.6604 3.57212C14.1104 -0.658624 7.80283 -1.21043 3.57212 2.33956C-0.658625 5.88958 -1.21046 12.1971 2.33955 16.4279Z"), c(l, "fill", "currentColor"), c(r, "d", "M3.57212 2.33956C1.65755 3.94607 0.496389 6.11731 0.12782 8.40523L2.04639 9.13961C2.26047 7.15832 3.21057 5.25375 4.8577 3.87164C8.24231 1.03162 13.2883 1.4731 16.1284 4.8577L13.8302 6.78606L19.9633 9.13364C19.7929 7.15555 19.0335 5.20847 17.6604 3.57212C14.1104 -0.658624 7.80283 -1.21043 3.57212 2.33956Z"), c(r, "fill", "currentColor"), c(s, "d", "M7 10H5C5 12.7614 7.23858 15 10 15C12.7614 15 15 12.7614 15 10H13C13 11.6569 11.6569 13 10 13C8.3431 13 7 11.6569 7 10Z"), c(s, "fill", "currentColor"), c(o, "width", "22"), c(o, "height", "22"), c(o, "viewBox", "0 0 20 20"), c(o, "fill", "none"), c(o, "xmlns", "http://www.w3.org/2000/svg"), c(n, "href", ye), c(n, "target", "_blank"), c(n, "class", "altcha-logo svelte-vuofbg"); + e = $("div"), n = $("a"), i = V("svg"), l = V("path"), r = V("path"), s = V("path"), c(l, "d", "M2.33955 16.4279C5.88954 20.6586 12.1971 21.2105 16.4279 17.6604C18.4699 15.947 19.6548 13.5911 19.9352 11.1365L17.9886 10.4279C17.8738 12.5624 16.909 14.6459 15.1423 16.1284C11.7577 18.9684 6.71167 18.5269 3.87164 15.1423C1.03163 11.7577 1.4731 6.71166 4.8577 3.87164C8.24231 1.03162 13.2883 1.4731 16.1284 4.8577C16.9767 5.86872 17.5322 7.02798 17.804 8.2324L19.9522 9.01429C19.7622 7.07737 19.0059 5.17558 17.6604 3.57212C14.1104 -0.658624 7.80283 -1.21043 3.57212 2.33956C-0.658625 5.88958 -1.21046 12.1971 2.33955 16.4279Z"), c(l, "fill", "currentColor"), c(r, "d", "M3.57212 2.33956C1.65755 3.94607 0.496389 6.11731 0.12782 8.40523L2.04639 9.13961C2.26047 7.15832 3.21057 5.25375 4.8577 3.87164C8.24231 1.03162 13.2883 1.4731 16.1284 4.8577L13.8302 6.78606L19.9633 9.13364C19.7929 7.15555 19.0335 5.20847 17.6604 3.57212C14.1104 -0.658624 7.80283 -1.21043 3.57212 2.33956Z"), c(r, "fill", "currentColor"), c(s, "d", "M7 10H5C5 12.7614 7.23858 15 10 15C12.7614 15 15 12.7614 15 10H13C13 11.6569 11.6569 13 10 13C8.3431 13 7 11.6569 7 10Z"), c(s, "fill", "currentColor"), c(i, "width", "22"), c(i, "height", "22"), c(i, "viewBox", "0 0 20 20"), c(i, "fill", "none"), c(i, "xmlns", "http://www.w3.org/2000/svg"), c(n, "href", Ee), c(n, "target", "_blank"), c(n, "class", "altcha-logo svelte-vuofbg"); }, - m(u, f) { - N(u, e, f), b(e, n), b(n, o), b(o, l), b(o, r), b(o, s); + m(a, h) { + N(a, e, h), b(e, n), b(n, i), b(i, l), b(i, r), b(i, s); }, - p: Z, - d(u) { - u && I(e); + p: H, + d(a) { + a && L(e); } }; } -function fe(t) { - let e, n, o, l, r, s = ( - /*_strings*/ - t[9].error + "" - ); +function ge(t) { + let e, n, i, l, r; return { c() { - e = $("div"), n = S("svg"), o = S("path"), l = M(), r = $("div"), c(o, "stroke-linecap", "round"), c(o, "stroke-linejoin", "round"), c(o, "d", "M6 18L18 6M6 6l12 12"), c(n, "width", "14"), c(n, "height", "14"), c(n, "xmlns", "http://www.w3.org/2000/svg"), c(n, "fill", "none"), c(n, "viewBox", "0 0 24 24"), c(n, "stroke-width", "1.5"), c(n, "stroke", "currentColor"), c( - r, - "title", - /*error*/ - t[8] - ), c(e, "class", "altcha-error svelte-vuofbg"); + e = $("div"), n = V("svg"), i = V("path"), l = M(), r = $("div"), c(i, "stroke-linecap", "round"), c(i, "stroke-linejoin", "round"), c(i, "d", "M6 18L18 6M6 6l12 12"), c(n, "width", "14"), c(n, "height", "14"), c(n, "xmlns", "http://www.w3.org/2000/svg"), c(n, "fill", "none"), c(n, "viewBox", "0 0 24 24"), c(n, "stroke-width", "1.5"), c(n, "stroke", "currentColor"), c(e, "class", "altcha-error svelte-vuofbg"); }, - m(u, f) { - N(u, e, f), b(e, n), b(n, o), b(e, l), b(e, r), r.innerHTML = s; + m(s, a) { + N(s, e, a), b(e, n), b(n, i), b(e, l), b(e, r), r.innerHTML = /*error*/ + t[8]; }, - p(u, f) { - f[0] & /*_strings*/ - 512 && s !== (s = /*_strings*/ - u[9].error + "") && (r.innerHTML = s), f[0] & /*error*/ - 256 && c( - r, - "title", - /*error*/ - u[8] - ); + p(s, a) { + a[0] & /*error*/ + 256 && (r.innerHTML = /*error*/ + s[8]); }, - d(u) { - u && I(e); + d(s) { + s && L(e); } }; } -function he(t) { - let e, n, o = ( +function be(t) { + let e, n, i = ( /*_strings*/ t[9].footer + "" ); @@ -668,287 +655,296 @@ function he(t) { e = $("div"), n = $("div"), c(n, "class", "svelte-vuofbg"), c(e, "class", "altcha-footer svelte-vuofbg"); }, m(l, r) { - N(l, e, r), b(e, n), n.innerHTML = o; + N(l, e, r), b(e, n), n.innerHTML = i; }, p(l, r) { r[0] & /*_strings*/ - 512 && o !== (o = /*_strings*/ - l[9].footer + "") && (n.innerHTML = o); + 512 && i !== (i = /*_strings*/ + l[9].footer + "") && (n.innerHTML = i); }, d(l) { - l && I(e); + l && L(e); } }; } -function mt(t) { - let e, n, o, l, r, s, u, f, a, R, p, j, x, A, _ = ( +function wt(t) { + let e, n, i, l, r, s, a, h, f, R, p, j, C, A, v = ( /*state*/ - t[5] === y.VERIFYING && ue() + t[5] === w.VERIFYING && he() ); - function G(h, v) { + function G(u, y) { return ( /*state*/ - h[5] === y.VERIFIED ? bt : ( + u[5] === w.VERIFIED ? _t : ( /*state*/ - h[5] === y.VERIFYING ? gt : dt + u[5] === w.VERIFYING ? vt : mt ) ); } - let V = G(t), k = V(t), g = ( + let U = G(t), k = U(t), _ = ( /*hidelogo*/ - t[2] !== !0 && ae() - ), m = ( + t[2] !== !0 && de() + ), g = ( /*error*/ - t[8] && fe(t) - ), d = ( + t[8] && ge(t) + ), m = ( /*_strings*/ t[9].footer && /*hidefooter*/ - t[1] !== !0 && he(t) + t[1] !== !0 && be(t) ); return { c() { - e = $("div"), n = $("div"), _ && _.c(), o = M(), l = $("div"), r = $("input"), f = M(), a = $("div"), k.c(), R = M(), g && g.c(), p = M(), m && m.c(), j = M(), d && d.c(), c(r, "type", "checkbox"), c(r, "id", s = /*name*/ - t[3] + "_checkbox"), r.required = u = /*auto*/ - t[0] !== "onsubmit", c(r, "class", "svelte-vuofbg"), c(l, "class", "altcha-checkbox svelte-vuofbg"), le( + e = $("div"), n = $("div"), v && v.c(), i = M(), l = $("div"), r = $("input"), h = M(), f = $("div"), k.c(), R = M(), _ && _.c(), p = M(), g && g.c(), j = M(), m && m.c(), c(r, "type", "checkbox"), c(r, "id", s = /*name*/ + t[3] + "_checkbox"), r.required = a = /*auto*/ + t[0] !== "onsubmit", c(r, "class", "svelte-vuofbg"), c(l, "class", "altcha-checkbox svelte-vuofbg"), ue( l, "altcha-hidden", /*state*/ - t[5] === y.VERIFYING - ), c(a, "class", "altcha-label svelte-vuofbg"), c(n, "class", "altcha-main svelte-vuofbg"), c(e, "class", "altcha svelte-vuofbg"), c( + t[5] === w.VERIFYING + ), c(f, "class", "altcha-label svelte-vuofbg"), c(n, "class", "altcha-main svelte-vuofbg"), c(e, "class", "altcha svelte-vuofbg"), c( e, "data-state", /*state*/ t[5] ); }, - m(h, v) { - N(h, e, v), b(e, n), _ && _.m(n, null), b(n, o), b(n, l), b(l, r), r.checked = /*checked*/ - t[6], b(n, f), b(n, a), k.m(a, null), b(n, R), g && g.m(n, null), b(e, p), m && m.m(e, null), b(e, j), d && d.m(e, null), t[24](e), x || (A = [ - K( + m(u, y) { + N(u, e, y), b(e, n), v && v.m(n, null), b(n, i), b(n, l), b(l, r), r.checked = /*checked*/ + t[6], b(n, h), b(n, f), k.m(f, null), b(n, R), _ && _.m(n, null), b(e, p), g && g.m(e, null), b(e, j), m && m.m(e, null), t[24](e), C || (A = [ + z( r, "change", /*input_change_handler*/ t[23] ), - K( + z( r, "change", /*onCheckedChange*/ t[10] ), - K( + z( r, "invalid", /*onInvalid*/ t[11] ) - ], x = !0); + ], C = !0); }, - p(h, v) { + p(u, y) { /*state*/ - h[5] === y.VERIFYING ? _ || (_ = ue(), _.c(), _.m(n, o)) : _ && (_.d(1), _ = null), v[0] & /*name*/ + u[5] === w.VERIFYING ? v || (v = he(), v.c(), v.m(n, i)) : v && (v.d(1), v = null), y[0] & /*name*/ 8 && s !== (s = /*name*/ - h[3] + "_checkbox") && c(r, "id", s), v[0] & /*auto*/ - 1 && u !== (u = /*auto*/ - h[0] !== "onsubmit") && (r.required = u), v[0] & /*checked*/ + u[3] + "_checkbox") && c(r, "id", s), y[0] & /*auto*/ + 1 && a !== (a = /*auto*/ + u[0] !== "onsubmit") && (r.required = a), y[0] & /*checked*/ 64 && (r.checked = /*checked*/ - h[6]), v[0] & /*state*/ - 32 && le( + u[6]), y[0] & /*state*/ + 32 && ue( l, "altcha-hidden", /*state*/ - h[5] === y.VERIFYING - ), V === (V = G(h)) && k ? k.p(h, v) : (k.d(1), k = V(h), k && (k.c(), k.m(a, null))), /*hidelogo*/ - h[2] !== !0 ? g ? g.p(h, v) : (g = ae(), g.c(), g.m(n, null)) : g && (g.d(1), g = null), /*error*/ - h[8] ? m ? m.p(h, v) : (m = fe(h), m.c(), m.m(e, j)) : m && (m.d(1), m = null), /*_strings*/ - h[9].footer && /*hidefooter*/ - h[1] !== !0 ? d ? d.p(h, v) : (d = he(h), d.c(), d.m(e, null)) : d && (d.d(1), d = null), v[0] & /*state*/ + u[5] === w.VERIFYING + ), U === (U = G(u)) && k ? k.p(u, y) : (k.d(1), k = U(u), k && (k.c(), k.m(f, null))), /*hidelogo*/ + u[2] !== !0 ? _ ? _.p(u, y) : (_ = de(), _.c(), _.m(n, null)) : _ && (_.d(1), _ = null), /*error*/ + u[8] ? g ? g.p(u, y) : (g = ge(u), g.c(), g.m(e, j)) : g && (g.d(1), g = null), /*_strings*/ + u[9].footer && /*hidefooter*/ + u[1] !== !0 ? m ? m.p(u, y) : (m = be(u), m.c(), m.m(e, null)) : m && (m.d(1), m = null), y[0] & /*state*/ 32 && c( e, "data-state", /*state*/ - h[5] + u[5] ); }, - i: Z, - o: Z, - d(h) { - h && I(e), _ && _.d(), k.d(), g && g.d(), m && m.d(), d && d.d(), t[24](null), x = !1, P(A); + i: H, + o: H, + d(u) { + u && L(e), v && v.d(), k.d(), _ && _.d(), g && g.d(), m && m.d(), t[24](null), C = !1, T(A); } }; } -const ye = "https://altcha.org/"; -function de(t) { +const Ee = "https://altcha.org/"; +function me(t) { return JSON.parse(t); } -function vt(t, e, n) { - let o, l, r, { auto: s = void 0 } = e, { challengeurl: u = void 0 } = e, { challengejson: f = void 0 } = e, { debug: a = !1 } = e, { hidefooter: R = !1 } = e, { hidelogo: p = !1 } = e, { name: j = "altcha" } = e, { maxnumber: x = void 0 } = e, { mockerror: A = !1 } = e, { strings: _ = void 0 } = e, { test: G = !1 } = e; - const V = Te(), k = ["SHA-256", "SHA-384", "SHA-512"]; - let g = !1, m, d = null, h = null, v = null, U = y.UNVERIFIED; - Pe(() => { - d && (d.removeEventListener("submit", te), d.removeEventListener("reset", ne), d = null); - }), We(() => { - E("mounted", "0.1.9"), G && E("using test mode"), s !== void 0 && E("auto", s), d = m.closest("form"), d && (d.addEventListener("submit", te), d.addEventListener("reset", ne)), s === "onload" && B(); +function $t(t, e, n) { + let i, l, r, { auto: s = void 0 } = e, { challengeurl: a = void 0 } = e, { challengejson: h = void 0 } = e, { debug: f = !1 } = e, { hidefooter: R = !1 } = e, { hidelogo: p = !1 } = e, { name: j = "altcha" } = e, { maxnumber: C = void 0 } = e, { mockerror: A = !1 } = e, { strings: v = void 0 } = e, { test: G = !1 } = e; + const U = Ke(), k = ["SHA-256", "SHA-384", "SHA-512"], _ = []; + let g = !1, m, u = null, y = null, F = null, S = w.UNVERIFIED, ne; + Xe(() => { + u && (u.removeEventListener("submit", re), u.removeEventListener("reset", ie), u = null); + }), Te(() => { + E("mounted", "0.1.9"), G && E("using test mode"), s !== void 0 && E("auto", s), u = m.closest("form"), u && (u.addEventListener("submit", re), u.addEventListener("reset", ie)), s === "onload" && W(); }); - function E(...i) { - (a || i.some((w) => w instanceof Error)) && console[i[0] instanceof Error ? "error" : "log"]("ALTCHA", ...i); + function E(...o) { + (f || o.some((d) => d instanceof Error)) && console[o[0] instanceof Error ? "error" : "log"]("ALTCHA", ...o); } - function te(i) { - d && s === "onsubmit" && U === y.UNVERIFIED && (i.preventDefault(), i.stopPropagation(), B().then(() => { - d == null || d.requestSubmit(); + function re(o) { + u && s === "onsubmit" && S === w.UNVERIFIED && (o.preventDefault(), o.stopPropagation(), W().then(() => { + u == null || u.requestSubmit(); })); } - function ne() { + function ie() { X(); } - function pe(i, w) { + function xe(o, d) { return btoa(JSON.stringify({ - algorithm: i.algorithm, - challenge: i.challenge, - number: w.number, - salt: i.salt, - signature: i.signature, + algorithm: o.algorithm, + challenge: o.challenge, + number: d.number, + salt: o.salt, + signature: o.signature, test: G ? !0 : void 0, - took: w.took + took: d.took })); } - function re(i) { - if (!i.algorithm) + function oe(o) { + if (!o.algorithm) throw new Error("Invalid challenge. Property algorithm is missing."); - if (i.signature === void 0) + if (o.signature === void 0) throw new Error("Invalid challenge. Property signature is missing."); - if (!k.includes(i.algorithm.toUpperCase())) + if (!k.includes(o.algorithm.toUpperCase())) throw new Error(`Unknown algorithm value. Allowed values: ${k.join(", ")}`); - if (!i.challenge || i.challenge.length < 40) + if (!o.challenge || o.challenge.length < 40) throw new Error("Challenge is too short. Min. 40 chars."); - if (!i.salt || i.salt.length < 10) + if (!o.salt || o.salt.length < 10) throw new Error("Salt is too short. Min. 10 chars."); } - async function ke() { + async function Ce() { if (A) throw E("mocking error"), new Error("Mocked error."); - if (o) - return E("using provided json data"), o; + if (i) + return E("using provided json data"), i; if (G) - return E("generating test challenge"), at(); + return E("generating test challenge"), dt(); { - if (!u) + if (!a) throw new Error("Attribute challengeurl not set."); - E("fetching challenge from", u); - const i = await fetch(u); - if (i.status !== 200) - throw new Error(`Server responded with ${i.status}.`); - return i.json(); + E("fetching challenge from", a); + const o = await fetch(a); + if (o.status !== 200) + throw new Error(`Server responded with ${o.status}.`); + const d = o.headers.get("Expires"); + if (d.length) { + const O = Date.parse(d) - Date.now(); + O < 1 ? le() : ne = setTimeout(le, O); + } + return o.json(); } } - async function Ee(i) { - let w = null; + function le() { + X(w.EXPIRED, r.expired); + } + async function Ie(o) { + let d = null; if ("Worker" in window) { try { - w = await Ce(i.challenge, i.salt, i.algorithm); - } catch (D) { - E(D); + d = await Le(o.challenge, o.salt, o.algorithm); + } catch (O) { + E(O); } - if ((w == null ? void 0 : w.number) !== void 0) - return { data: i, solution: w }; + if ((d == null ? void 0 : d.number) !== void 0) + return { data: o, solution: d }; } return { - data: i, - solution: await ft(i.challenge, i.salt, i.algorithm, x) + data: o, + solution: await gt(o.challenge, o.salt, o.algorithm, C) }; } - async function Ce(i, w, D) { - const oe = new lt(); - return new Promise((je) => { - oe.addEventListener("message", (Ae) => { - je(Ae.data); - }), oe.postMessage({ alg: D, challenge: i, max: x, salt: w }); + async function Le(o, d, O) { + const se = _.push(new ut()); + return new Promise((Ve) => { + _[se - 1].addEventListener("message", (Se) => { + Ve(Se.data); + }), _[se - 1].postMessage({ alg: O, challenge: o, max: C, salt: d }); }); } - function xe() { - [y.UNVERIFIED, y.ERROR].includes(U) ? B() : n(6, g = !0); + function Re() { + [w.UNVERIFIED, w.ERROR, w.EXPIRED].includes(S) ? W() : n(6, g = !0); } - function Le() { - U === y.VERIFYING && alert(r.waitAlert); + function Ne() { + S === w.VERIFYING && alert(r.waitAlert); } - function Ie(i) { - i.auto !== void 0 && (n(0, s = i.auto), s === "onload" && B()), i.challenge && (re(i.challenge), o = i.challenge), i.debug !== void 0 && n(12, a = !!i.debug), i.hidefooter !== void 0 && n(1, R = !!i.hidefooter), i.hidelogo !== void 0 && n(2, p = !!i.hidelogo), i.maxnumber !== void 0 && n(13, x = +i.maxnumber), i.mockerror !== void 0 && n(14, A = !!i.mockerror), i.name !== void 0 && n(3, j = i.name), i.test !== void 0 && n(15, G = !!i.test), i.strings && n(22, l = i.strings); + function je(o) { + o.auto !== void 0 && (n(0, s = o.auto), s === "onload" && W()), o.challenge && (oe(o.challenge), i = o.challenge), o.debug !== void 0 && n(12, f = !!o.debug), o.hidefooter !== void 0 && n(1, R = !!o.hidefooter), o.hidelogo !== void 0 && n(2, p = !!o.hidelogo), o.maxnumber !== void 0 && n(13, C = +o.maxnumber), o.mockerror !== void 0 && n(14, A = !!o.mockerror), o.name !== void 0 && n(3, j = o.name), o.test !== void 0 && n(15, G = !!o.test), o.strings && n(22, l = o.strings); } - function X(i = y.UNVERIFIED) { - n(6, g = !1), n(8, h = null), n(4, v = null), n(5, U = i); + function X(o = w.UNVERIFIED, d = null) { + clearTimeout(ne), n(6, g = !1), n(8, y = d), n(4, F = null), n(5, S = o); } - async function B() { - return X(y.VERIFYING), ke().then((i) => (re(i), E("challenge", i), Ee(i))).then(({ data: i, solution: w }) => { - if (E("solution", w), (w == null ? void 0 : w.number) !== void 0) - E("verified"), n(5, U = y.VERIFIED), n(6, g = !0), n(4, v = pe(i, w)), E("payload", v), Xe().then(() => { - V("verified", { payload: v }); + async function W() { + return X(w.VERIFYING), Ce().then((o) => (oe(o), E("challenge", o), Ie(o))).then(({ data: o, solution: d }) => { + if (E("solution", d), (d == null ? void 0 : d.number) !== void 0) + E("verified"), n(5, S = w.VERIFIED), n(6, g = !0), n(4, F = xe(o, d)), E("payload", F), ze().then(() => { + U("verified", { payload: F }); }); else throw new Error("Unexpected result returned."); - }).catch((i) => { - E(i), n(5, U = y.ERROR), n(6, g = !1), n(8, h = i); + }).catch((o) => { + E(o), n(5, S = w.ERROR), n(6, g = !1), n(8, y = o.message); }); } - function Re() { + function Ae() { g = this.checked, n(6, g); } - function Ne(i) { - J[i ? "unshift" : "push"](() => { - m = i, n(7, m); + function Ge(o) { + Q[o ? "unshift" : "push"](() => { + m = o, n(7, m); }); } - return t.$$set = (i) => { - "auto" in i && n(0, s = i.auto), "challengeurl" in i && n(16, u = i.challengeurl), "challengejson" in i && n(17, f = i.challengejson), "debug" in i && n(12, a = i.debug), "hidefooter" in i && n(1, R = i.hidefooter), "hidelogo" in i && n(2, p = i.hidelogo), "name" in i && n(3, j = i.name), "maxnumber" in i && n(13, x = i.maxnumber), "mockerror" in i && n(14, A = i.mockerror), "strings" in i && n(18, _ = i.strings), "test" in i && n(15, G = i.test); + return t.$$set = (o) => { + "auto" in o && n(0, s = o.auto), "challengeurl" in o && n(16, a = o.challengeurl), "challengejson" in o && n(17, h = o.challengejson), "debug" in o && n(12, f = o.debug), "hidefooter" in o && n(1, R = o.hidefooter), "hidelogo" in o && n(2, p = o.hidelogo), "name" in o && n(3, j = o.name), "maxnumber" in o && n(13, C = o.maxnumber), "mockerror" in o && n(14, A = o.mockerror), "strings" in o && n(18, v = o.strings), "test" in o && n(15, G = o.test); }, t.$$.update = () => { t.$$.dirty[0] & /*challengejson*/ - 131072 && (o = f ? de(f) : void 0), t.$$.dirty[0] & /*strings*/ - 262144 && n(22, l = _ ? de(_) : {}), t.$$.dirty[0] & /*parsedStrings*/ + 131072 && (i = h ? me(h) : void 0), t.$$.dirty[0] & /*strings*/ + 262144 && n(22, l = v ? me(v) : {}), t.$$.dirty[0] & /*parsedStrings*/ 4194304 && n(9, r = { error: "Verification failed. Try again later.", - footer: `Protected by ALTCHA`, + expired: "Verification expired. Try again.", + footer: `Protected by ALTCHA`, label: "I'm not a robot", verified: "Verified", verifying: "Verifying...", waitAlert: "Verifying... please wait.", ...l }), t.$$.dirty[0] & /*payload, state*/ - 48 && V("statechange", { payload: v, state: U }); + 48 && U("statechange", { payload: F, state: S }); }, [ s, R, p, j, - v, - U, + F, + S, g, m, - h, + y, r, - xe, - Le, - a, - x, + Re, + Ne, + f, + C, A, G, - u, - f, - _, - Ie, + a, + h, + v, + je, X, - B, + W, l, - Re, - Ne + Ae, + Ge ]; } -class _t extends rt { +class yt extends lt { constructor(e) { - super(), tt( + super(), it( this, e, - vt, - mt, - Ue, + $t, + wt, + Fe, { auto: 0, challengeurl: 16, @@ -965,7 +961,7 @@ class _t extends rt { reset: 20, verify: 21 }, - ht, + bt, [-1, -1] ); } @@ -973,67 +969,67 @@ class _t extends rt { return this.$$.ctx[0]; } set auto(e) { - this.$$set({ auto: e }), C(); + this.$$set({ auto: e }), x(); } get challengeurl() { return this.$$.ctx[16]; } set challengeurl(e) { - this.$$set({ challengeurl: e }), C(); + this.$$set({ challengeurl: e }), x(); } get challengejson() { return this.$$.ctx[17]; } set challengejson(e) { - this.$$set({ challengejson: e }), C(); + this.$$set({ challengejson: e }), x(); } get debug() { return this.$$.ctx[12]; } set debug(e) { - this.$$set({ debug: e }), C(); + this.$$set({ debug: e }), x(); } get hidefooter() { return this.$$.ctx[1]; } set hidefooter(e) { - this.$$set({ hidefooter: e }), C(); + this.$$set({ hidefooter: e }), x(); } get hidelogo() { return this.$$.ctx[2]; } set hidelogo(e) { - this.$$set({ hidelogo: e }), C(); + this.$$set({ hidelogo: e }), x(); } get name() { return this.$$.ctx[3]; } set name(e) { - this.$$set({ name: e }), C(); + this.$$set({ name: e }), x(); } get maxnumber() { return this.$$.ctx[13]; } set maxnumber(e) { - this.$$set({ maxnumber: e }), C(); + this.$$set({ maxnumber: e }), x(); } get mockerror() { return this.$$.ctx[14]; } set mockerror(e) { - this.$$set({ mockerror: e }), C(); + this.$$set({ mockerror: e }), x(); } get strings() { return this.$$.ctx[18]; } set strings(e) { - this.$$set({ strings: e }), C(); + this.$$set({ strings: e }), x(); } get test() { return this.$$.ctx[15]; } set test(e) { - this.$$set({ test: e }), C(); + this.$$set({ test: e }), x(); } get configure() { return this.$$.ctx[19]; @@ -1045,7 +1041,7 @@ class _t extends rt { return this.$$.ctx[21]; } } -customElements.define("altcha-widget", nt(_t, { auto: {}, challengeurl: {}, challengejson: {}, debug: { type: "Boolean" }, hidefooter: { type: "Boolean" }, hidelogo: { type: "Boolean" }, name: {}, maxnumber: {}, mockerror: { type: "Boolean" }, strings: {}, test: { type: "Boolean" } }, [], ["configure", "reset", "verify"], !1)); +customElements.define("altcha-widget", ot(yt, { auto: {}, challengeurl: {}, challengejson: {}, debug: { type: "Boolean" }, hidefooter: { type: "Boolean" }, hidelogo: { type: "Boolean" }, name: {}, maxnumber: {}, mockerror: { type: "Boolean" }, strings: {}, test: { type: "Boolean" } }, [], ["configure", "reset", "verify"], !1)); export { - _t as Altcha + yt as Altcha }; diff --git a/dist/altcha.umd.cjs b/dist/altcha.umd.cjs index 7e0ef28..346f94f 100644 --- a/dist/altcha.umd.cjs +++ b/dist/altcha.umd.cjs @@ -1 +1 @@ -(function(L,_){typeof exports=="object"&&typeof module<"u"?_(exports):typeof define=="function"&&define.amd?define(["exports"],_):(L=typeof globalThis<"u"?globalThis:L||self,_(L.altcha={}))})(this,function(L){"use strict";var _t=Object.defineProperty;var wt=(L,_,V)=>_ in L?_t(L,_,{enumerable:!0,configurable:!0,writable:!0,value:V}):L[_]=V;var N=(L,_,V)=>(wt(L,typeof _!="symbol"?_+"":_,V),V);function _(){}function V(t){return t()}function re(){return Object.create(null)}function W(t){t.forEach(V)}function ie(t){return typeof t=="function"}function Ee(t,e){return t!=t?e==e:t!==e||t&&typeof t=="object"||typeof t=="function"}function Ce(t){return Object.keys(t).length===0}function g(t,e){t.appendChild(e)}function xe(t,e,n){const i=Le(t);if(!i.getElementById(e)){const l=y("style");l.id=e,l.textContent=n,Ie(i,l)}}function Le(t){if(!t)return document;const e=t.getRootNode?t.getRootNode():t.ownerDocument;return e&&e.host?e:t.ownerDocument}function Ie(t,e){return g(t.head||t,e),e.sheet}function j(t,e,n){t.insertBefore(e,n||null)}function I(t){t.parentNode&&t.parentNode.removeChild(t)}function y(t){return document.createElement(t)}function M(t){return document.createElementNS("http://www.w3.org/2000/svg",t)}function Re(t){return document.createTextNode(t)}function F(){return Re(" ")}function K(t,e,n,i){return t.addEventListener(e,n,i),()=>t.removeEventListener(e,n,i)}function c(t,e,n){n==null?t.removeAttribute(e):t.getAttribute(e)!==n&&t.setAttribute(e,n)}function Ne(t){return Array.from(t.childNodes)}function oe(t,e,n){t.classList.toggle(e,!!n)}function je(t,e,{bubbles:n=!1,cancelable:i=!1}={}){return new CustomEvent(t,{detail:e,bubbles:n,cancelable:i})}function Ae(t){const e={};return t.childNodes.forEach(n=>{e[n.slot||"default"]=!0}),e}let T;function P(t){T=t}function z(){if(!T)throw new Error("Function called outside component initialization");return T}function Ge(t){z().$$.on_mount.push(t)}function Se(t){z().$$.on_destroy.push(t)}function Me(){const t=z();return(e,n,{cancelable:i=!1}={})=>{const l=t.$$.callbacks[e];if(l){const r=je(e,n,{cancelable:i});return l.slice().forEach(s=>{s.call(t,r)}),!r.defaultPrevented}return!0}}const Z=[],J=[];let B=[];const le=[],se=Promise.resolve();let Q=!1;function ce(){Q||(Q=!0,se.then(E))}function Ue(){return ce(),se}function q(t){B.push(t)}const ee=new Set;let H=0;function E(){if(H!==0)return;const t=T;do{try{for(;Ht.indexOf(i)===-1?e.push(i):n.push(i)),n.forEach(i=>i()),B=e}const Fe=new Set;function Ye(t,e){t&&t.i&&(Fe.delete(t),t.i(e))}function Ze(t,e,n){const{fragment:i,after_update:l}=t.$$;i&&i.m(e,n),q(()=>{const r=t.$$.on_mount.map(V).filter(ie);t.$$.on_destroy?t.$$.on_destroy.push(...r):W(r),t.$$.on_mount=[]}),l.forEach(q)}function Be(t,e){const n=t.$$;n.fragment!==null&&(Oe(n.after_update),W(n.on_destroy),n.fragment&&n.fragment.d(e),n.on_destroy=n.fragment=null,n.ctx=[])}function He(t,e){t.$$.dirty[0]===-1&&(Z.push(t),ce(),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<{const S=R.length?R[0]:G;return a.ctx&&l(a.ctx[k],a.ctx[k]=S)&&(!a.skip_bound&&a.bound[k]&&a.bound[k](S),A&&He(t,k)),G}):[],a.update(),A=!0,W(a.before_update),a.fragment=i?i(a.ctx):!1,e.target){if(e.hydrate){const k=Ne(e.target);a.fragment&&a.fragment.l(k),k.forEach(I)}else a.fragment&&a.fragment.c();e.intro&&Ye(t.$$.fragment),Ze(t,e.target,e.anchor),E()}P(f)}let ue;typeof HTMLElement=="function"&&(ue=class extends HTMLElement{constructor(e,n,i){super();N(this,"$$ctor");N(this,"$$s");N(this,"$$c");N(this,"$$cn",!1);N(this,"$$d",{});N(this,"$$r",!1);N(this,"$$p_d",{});N(this,"$$l",{});N(this,"$$l_u",new Map);this.$$ctor=e,this.$$s=n,i&&this.attachShadow({mode:"open"})}addEventListener(e,n,i){if(this.$$l[e]=this.$$l[e]||[],this.$$l[e].push(n),this.$$c){const l=this.$$c.$on(e,n);this.$$l_u.set(n,l)}super.addEventListener(e,n,i)}removeEventListener(e,n,i){if(super.removeEventListener(e,n,i),this.$$c){const l=this.$$l_u.get(n);l&&(l(),this.$$l_u.delete(n))}}async connectedCallback(){if(this.$$cn=!0,!this.$$c){let e=function(r){return()=>{let s;return{c:function(){s=y("slot"),r!=="default"&&c(s,"name",r)},m:function(a,A){j(a,s,A)},d:function(a){a&&I(s)}}}};if(await Promise.resolve(),!this.$$cn||this.$$c)return;const n={},i=Ae(this);for(const r of this.$$s)r in i&&(n[r]=[e(r)]);for(const r of this.attributes){const s=this.$$g_p(r.name);s in this.$$d||(this.$$d[s]=D(s,r.value,this.$$p_d,"toProp"))}for(const r in this.$$p_d)!(r in this.$$d)&&this[r]!==void 0&&(this.$$d[r]=this[r],delete this[r]);this.$$c=new this.$$ctor({target:this.shadowRoot||this,props:{...this.$$d,$$slots:n,$$scope:{ctx:[]}}});const l=()=>{this.$$r=!0;for(const r in this.$$p_d)if(this.$$d[r]=this.$$c.$$.ctx[this.$$c.$$.props[r]],this.$$p_d[r].reflect){const s=D(r,this.$$d[r],this.$$p_d,"toAttribute");s==null?this.removeAttribute(this.$$p_d[r].attribute||r):this.setAttribute(this.$$p_d[r].attribute||r,s)}this.$$r=!1};this.$$c.$$.after_update.push(l),l();for(const r in this.$$l)for(const s of this.$$l[r]){const u=this.$$c.$on(r,s);this.$$l_u.set(s,u)}this.$$l={}}}attributeChangedCallback(e,n,i){var l;this.$$r||(e=this.$$g_p(e),this.$$d[e]=D(e,i,this.$$p_d,"toProp"),(l=this.$$c)==null||l.$set({[e]:this.$$d[e]}))}disconnectedCallback(){this.$$cn=!1,Promise.resolve().then(()=>{this.$$cn||(this.$$c.$destroy(),this.$$c=void 0)})}$$g_p(e){return Object.keys(this.$$p_d).find(n=>this.$$p_d[n].attribute===e||!this.$$p_d[n].attribute&&n.toLowerCase()===e)||e}});function D(t,e,n,i){var r;const l=(r=n[t])==null?void 0:r.type;if(e=l==="Boolean"&&typeof e!="boolean"?e!=null:e,!i||!n[t])return e;if(i==="toAttribute")switch(l){case"Object":case"Array":return e==null?null:JSON.stringify(e);case"Boolean":return e?"":null;case"Number":return e??null;default:return e}else switch(l){case"Object":case"Array":return e&&JSON.parse(e);case"Boolean":return e;case"Number":return e!=null?+e:e;default:return e}}function Te(t,e,n,i,l,r){let s=class extends ue{constructor(){super(t,n,l),this.$$p_d=e}static get observedAttributes(){return Object.keys(e).map(u=>(e[u].attribute||u).toLowerCase())}};return Object.keys(e).forEach(u=>{Object.defineProperty(s.prototype,u,{get(){return this.$$c&&u in this.$$c?this.$$c[u]:this.$$d[u]},set(f){var a;f=D(u,f,e),this.$$d[u]=f,(a=this.$$c)==null||a.$set({[u]:f})}})}),i.forEach(u=>{Object.defineProperty(s.prototype,u,{get(){var f;return(f=this.$$c)==null?void 0:f[u]}})}),r&&(s=r(s)),t.element=s,s}class Pe{constructor(){N(this,"$$");N(this,"$$set")}$destroy(){Be(this,1),this.$destroy=_}$on(e,n){if(!ie(n))return _;const i=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return i.push(n),()=>{const l=i.indexOf(n);l!==-1&&i.splice(l,1)}}$set(e){this.$$set&&!Ce(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const Xe="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(Xe);const ae="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0IHI9bmV3IFRleHRFbmNvZGVyO2Z1bmN0aW9uIGMoZSl7cmV0dXJuWy4uLm5ldyBVaW50OEFycmF5KGUpXS5tYXAobj0+bi50b1N0cmluZygxNikucGFkU3RhcnQoMiwiMCIpKS5qb2luKCIiKX1hc3luYyBmdW5jdGlvbiBsKGUsbixhKXtyZXR1cm4gYyhhd2FpdCBjcnlwdG8uc3VidGxlLmRpZ2VzdChhLnRvVXBwZXJDYXNlKCksci5lbmNvZGUoZStuKSkpfWFzeW5jIGZ1bmN0aW9uIGkoZSxuLGE9IlNIQS0yNTYiLG89MWU3KXtjb25zdCBzPURhdGUubm93KCk7Zm9yKGxldCB0PTA7dDw9bzt0KyspaWYoYXdhaXQgbChuLHQsYSk9PT1lKXJldHVybntudW1iZXI6dCx0b29rOkRhdGUubm93KCktc307cmV0dXJuIG51bGx9b25tZXNzYWdlPWFzeW5jIGU9Pntjb25zdHthbGc6bixjaGFsbGVuZ2U6YSxtYXg6byxzYWx0OnN9PWUuZGF0YXx8e307aWYoYSYmcyl7Y29uc3QgdD1hd2FpdCBpKGEscyxuLG8pO3NlbGYucG9zdE1lc3NhZ2UodCYmey4uLnQsd29ya2VyOiEwfSl9ZWxzZSBzZWxmLnBvc3RNZXNzYWdlKG51bGwpfX0pKCk7Cg==",De=t=>Uint8Array.from(atob(t),e=>e.charCodeAt(0)),fe=typeof window<"u"&&window.Blob&&new Blob([De(ae)],{type:"text/javascript;charset=utf-8"});function Ke(t){let e;try{if(e=fe&&(window.URL||window.webkitURL).createObjectURL(fe),!e)throw"";const n=new Worker(e,{name:t==null?void 0:t.name});return n.addEventListener("error",()=>{(window.URL||window.webkitURL).revokeObjectURL(e)}),n}catch{return new Worker("data:text/javascript;base64,"+ae,{name:t==null?void 0:t.name})}finally{e&&(window.URL||window.webkitURL).revokeObjectURL(e)}}const ze=1e7,Je=new TextEncoder;function Qe(t){return[...new Uint8Array(t)].map(e=>e.toString(16).padStart(2,"0")).join("")}async function qe(t=1e5,e="SHA-256"){const n=Date.now().toString(16),i=Math.round(Math.random()*t),l=await he(n,i,e);return{algorithm:e,challenge:l,salt:n,signature:""}}async function he(t,e,n){return Qe(await crypto.subtle.digest(n.toUpperCase(),Je.encode(t+e)))}async function et(t,e,n="SHA-256",i=ze){const l=Date.now();for(let r=0;r<=i;r++)if(await he(e,r,n)===t)return{number:r,took:Date.now()-l};return null}var p=(t=>(t.ERROR="error",t.VERIFIED="verified",t.VERIFYING="verifying",t.UNVERIFIED="unverified",t))(p||{});function tt(t){xe(t,"svelte-vuofbg",".altcha.svelte-vuofbg.svelte-vuofbg{background:var(--altcha-color-base, transparent);border:var(--altcha-border-width, 1px) solid var(--altcha-color-border, #a0a0a0);border-radius:var(--altcha-border-radius, 3px);color:var(--altcha-color-text, currentColor);display:flex;flex-direction:column;max-width:var(--altcha-max-width, 260px);overflow:hidden;position:relative;text-align:left}.altcha.svelte-vuofbg.svelte-vuofbg:focus-within{border-color:var(--altcha-color-border-focus, currentColor)}.altcha-main.svelte-vuofbg.svelte-vuofbg{align-items:center;display:flex;gap:0.4rem;padding:0.7rem}.altcha-label.svelte-vuofbg.svelte-vuofbg{flex-grow:1}.altcha-label.svelte-vuofbg label.svelte-vuofbg{cursor:pointer}.altcha-logo.svelte-vuofbg.svelte-vuofbg{color:currentColor;opacity:0.3}.altcha-logo.svelte-vuofbg.svelte-vuofbg:hover{opacity:1}.altcha-error.svelte-vuofbg.svelte-vuofbg{color:var(--altcha-color-error-text, #f23939);display:flex;font-size:0.85rem;gap:0.3rem;padding:0 0.7rem 0.7rem}.altcha-footer.svelte-vuofbg.svelte-vuofbg{align-items:center;background-color:var(--altcha-color-footer-bg, transparent);display:flex;font-size:0.75rem;opacity:0.4;padding:0.2rem 0.7rem;text-align:right}.altcha-footer.svelte-vuofbg.svelte-vuofbg:hover{opacity:1}.altcha-footer.svelte-vuofbg>.svelte-vuofbg:first-child{flex-grow:1}.altcha-footer.svelte-vuofbg a{color:currentColor}.altcha-checkbox.svelte-vuofbg.svelte-vuofbg{display:flex;align-items:center;height:24px;width:24px}.altcha-checkbox.svelte-vuofbg input.svelte-vuofbg{width:18px;height:18px;margin:0}.altcha-hidden.svelte-vuofbg.svelte-vuofbg{display:none}.altcha-spinner.svelte-vuofbg.svelte-vuofbg{animation:svelte-vuofbg-altcha-spinner 0.75s infinite linear;transform-origin:center}@keyframes svelte-vuofbg-altcha-spinner{100%{transform:rotate(360deg)}}")}function de(t){let e,n,i;return{c(){e=M("svg"),n=M("path"),i=M("path"),c(n,"d","M12,1A11,11,0,1,0,23,12,11,11,0,0,0,12,1Zm0,19a8,8,0,1,1,8-8A8,8,0,0,1,12,20Z"),c(n,"fill","currentColor"),c(n,"opacity",".25"),c(i,"d","M12,4a8,8,0,0,1,7.89,6.7A1.53,1.53,0,0,0,21.38,12h0a1.5,1.5,0,0,0,1.48-1.75,11,11,0,0,0-21.72,0A1.5,1.5,0,0,0,2.62,12h0a1.53,1.53,0,0,0,1.49-1.3A8,8,0,0,1,12,4Z"),c(i,"fill","currentColor"),c(i,"class","altcha-spinner svelte-vuofbg"),c(e,"width","24"),c(e,"height","24"),c(e,"viewBox","0 0 24 24"),c(e,"xmlns","http://www.w3.org/2000/svg")},m(l,r){j(l,e,r),g(e,n),g(e,i)},d(l){l&&I(e)}}}function nt(t){let e,n=t[9].label+"",i;return{c(){e=y("label"),c(e,"for",i=t[3]+"_checkbox"),c(e,"class","svelte-vuofbg")},m(l,r){j(l,e,r),e.innerHTML=n},p(l,r){r[0]&512&&n!==(n=l[9].label+"")&&(e.innerHTML=n),r[0]&8&&i!==(i=l[3]+"_checkbox")&&c(e,"for",i)},d(l){l&&I(e)}}}function rt(t){let e,n=t[9].verifying+"";return{c(){e=y("span")},m(i,l){j(i,e,l),e.innerHTML=n},p(i,l){l[0]&512&&n!==(n=i[9].verifying+"")&&(e.innerHTML=n)},d(i){i&&I(e)}}}function it(t){let e,n=t[9].verified+"",i,l;return{c(){e=y("span"),i=F(),l=y("input"),c(l,"type","hidden"),c(l,"name",t[3]),l.value=t[4]},m(r,s){j(r,e,s),e.innerHTML=n,j(r,i,s),j(r,l,s)},p(r,s){s[0]&512&&n!==(n=r[9].verified+"")&&(e.innerHTML=n),s[0]&8&&c(l,"name",r[3]),s[0]&16&&(l.value=r[4])},d(r){r&&(I(e),I(i),I(l))}}}function ge(t){let e,n,i,l,r,s;return{c(){e=y("div"),n=y("a"),i=M("svg"),l=M("path"),r=M("path"),s=M("path"),c(l,"d","M2.33955 16.4279C5.88954 20.6586 12.1971 21.2105 16.4279 17.6604C18.4699 15.947 19.6548 13.5911 19.9352 11.1365L17.9886 10.4279C17.8738 12.5624 16.909 14.6459 15.1423 16.1284C11.7577 18.9684 6.71167 18.5269 3.87164 15.1423C1.03163 11.7577 1.4731 6.71166 4.8577 3.87164C8.24231 1.03162 13.2883 1.4731 16.1284 4.8577C16.9767 5.86872 17.5322 7.02798 17.804 8.2324L19.9522 9.01429C19.7622 7.07737 19.0059 5.17558 17.6604 3.57212C14.1104 -0.658624 7.80283 -1.21043 3.57212 2.33956C-0.658625 5.88958 -1.21046 12.1971 2.33955 16.4279Z"),c(l,"fill","currentColor"),c(r,"d","M3.57212 2.33956C1.65755 3.94607 0.496389 6.11731 0.12782 8.40523L2.04639 9.13961C2.26047 7.15832 3.21057 5.25375 4.8577 3.87164C8.24231 1.03162 13.2883 1.4731 16.1284 4.8577L13.8302 6.78606L19.9633 9.13364C19.7929 7.15555 19.0335 5.20847 17.6604 3.57212C14.1104 -0.658624 7.80283 -1.21043 3.57212 2.33956Z"),c(r,"fill","currentColor"),c(s,"d","M7 10H5C5 12.7614 7.23858 15 10 15C12.7614 15 15 12.7614 15 10H13C13 11.6569 11.6569 13 10 13C8.3431 13 7 11.6569 7 10Z"),c(s,"fill","currentColor"),c(i,"width","22"),c(i,"height","22"),c(i,"viewBox","0 0 20 20"),c(i,"fill","none"),c(i,"xmlns","http://www.w3.org/2000/svg"),c(n,"href",ve),c(n,"target","_blank"),c(n,"class","altcha-logo svelte-vuofbg")},m(u,f){j(u,e,f),g(e,n),g(n,i),g(i,l),g(i,r),g(i,s)},p:_,d(u){u&&I(e)}}}function be(t){let e,n,i,l,r,s=t[9].error+"";return{c(){e=y("div"),n=M("svg"),i=M("path"),l=F(),r=y("div"),c(i,"stroke-linecap","round"),c(i,"stroke-linejoin","round"),c(i,"d","M6 18L18 6M6 6l12 12"),c(n,"width","14"),c(n,"height","14"),c(n,"xmlns","http://www.w3.org/2000/svg"),c(n,"fill","none"),c(n,"viewBox","0 0 24 24"),c(n,"stroke-width","1.5"),c(n,"stroke","currentColor"),c(r,"title",t[8]),c(e,"class","altcha-error svelte-vuofbg")},m(u,f){j(u,e,f),g(e,n),g(n,i),g(e,l),g(e,r),r.innerHTML=s},p(u,f){f[0]&512&&s!==(s=u[9].error+"")&&(r.innerHTML=s),f[0]&256&&c(r,"title",u[8])},d(u){u&&I(e)}}}function me(t){let e,n,i=t[9].footer+"";return{c(){e=y("div"),n=y("div"),c(n,"class","svelte-vuofbg"),c(e,"class","altcha-footer svelte-vuofbg")},m(l,r){j(l,e,r),g(e,n),n.innerHTML=i},p(l,r){r[0]&512&&i!==(i=l[9].footer+"")&&(n.innerHTML=i)},d(l){l&&I(e)}}}function ot(t){let e,n,i,l,r,s,u,f,a,A,k,G,R,S,w=t[5]===p.VERIFYING&&de();function U(h,v){return h[5]===p.VERIFIED?it:h[5]===p.VERIFYING?rt:nt}let Y=U(t),C=Y(t),b=t[2]!==!0&&ge(),m=t[8]&&be(t),d=t[9].footer&&t[1]!==!0&&me(t);return{c(){e=y("div"),n=y("div"),w&&w.c(),i=F(),l=y("div"),r=y("input"),f=F(),a=y("div"),C.c(),A=F(),b&&b.c(),k=F(),m&&m.c(),G=F(),d&&d.c(),c(r,"type","checkbox"),c(r,"id",s=t[3]+"_checkbox"),r.required=u=t[0]!=="onsubmit",c(r,"class","svelte-vuofbg"),c(l,"class","altcha-checkbox svelte-vuofbg"),oe(l,"altcha-hidden",t[5]===p.VERIFYING),c(a,"class","altcha-label svelte-vuofbg"),c(n,"class","altcha-main svelte-vuofbg"),c(e,"class","altcha svelte-vuofbg"),c(e,"data-state",t[5])},m(h,v){j(h,e,v),g(e,n),w&&w.m(n,null),g(n,i),g(n,l),g(l,r),r.checked=t[6],g(n,f),g(n,a),C.m(a,null),g(n,A),b&&b.m(n,null),g(e,k),m&&m.m(e,null),g(e,G),d&&d.m(e,null),t[24](e),R||(S=[K(r,"change",t[23]),K(r,"change",t[10]),K(r,"invalid",t[11])],R=!0)},p(h,v){h[5]===p.VERIFYING?w||(w=de(),w.c(),w.m(n,i)):w&&(w.d(1),w=null),v[0]&8&&s!==(s=h[3]+"_checkbox")&&c(r,"id",s),v[0]&1&&u!==(u=h[0]!=="onsubmit")&&(r.required=u),v[0]&64&&(r.checked=h[6]),v[0]&32&&oe(l,"altcha-hidden",h[5]===p.VERIFYING),Y===(Y=U(h))&&C?C.p(h,v):(C.d(1),C=Y(h),C&&(C.c(),C.m(a,null))),h[2]!==!0?b?b.p(h,v):(b=ge(),b.c(),b.m(n,null)):b&&(b.d(1),b=null),h[8]?m?m.p(h,v):(m=be(h),m.c(),m.m(e,G)):m&&(m.d(1),m=null),h[9].footer&&h[1]!==!0?d?d.p(h,v):(d=me(h),d.c(),d.m(e,null)):d&&(d.d(1),d=null),v[0]&32&&c(e,"data-state",h[5])},i:_,o:_,d(h){h&&I(e),w&&w.d(),C.d(),b&&b.d(),m&&m.d(),d&&d.d(),t[24](null),R=!1,W(S)}}}const ve="https://altcha.org/";function _e(t){return JSON.parse(t)}function lt(t,e,n){let i,l,r,{auto:s=void 0}=e,{challengeurl:u=void 0}=e,{challengejson:f=void 0}=e,{debug:a=!1}=e,{hidefooter:A=!1}=e,{hidelogo:k=!1}=e,{name:G="altcha"}=e,{maxnumber:R=void 0}=e,{mockerror:S=!1}=e,{strings:w=void 0}=e,{test:U=!1}=e;const Y=Me(),C=["SHA-256","SHA-384","SHA-512"];let b=!1,m,d=null,h=null,v=null,O=p.UNVERIFIED;Se(()=>{d&&(d.removeEventListener("submit",$e),d.removeEventListener("reset",ye),d=null)}),Ge(()=>{x("mounted","0.1.9"),U&&x("using test mode"),s!==void 0&&x("auto",s),d=m.closest("form"),d&&(d.addEventListener("submit",$e),d.addEventListener("reset",ye)),s==="onload"&&X()});function x(...o){(a||o.some($=>$ instanceof Error))&&console[o[0]instanceof Error?"error":"log"]("ALTCHA",...o)}function $e(o){d&&s==="onsubmit"&&O===p.UNVERIFIED&&(o.preventDefault(),o.stopPropagation(),X().then(()=>{d==null||d.requestSubmit()}))}function ye(){te()}function st(o,$){return btoa(JSON.stringify({algorithm:o.algorithm,challenge:o.challenge,number:$.number,salt:o.salt,signature:o.signature,test:U?!0:void 0,took:$.took}))}function pe(o){if(!o.algorithm)throw new Error("Invalid challenge. Property algorithm is missing.");if(o.signature===void 0)throw new Error("Invalid challenge. Property signature is missing.");if(!C.includes(o.algorithm.toUpperCase()))throw new Error(`Unknown algorithm value. Allowed values: ${C.join(", ")}`);if(!o.challenge||o.challenge.length<40)throw new Error("Challenge is too short. Min. 40 chars.");if(!o.salt||o.salt.length<10)throw new Error("Salt is too short. Min. 10 chars.")}async function ct(){if(S)throw x("mocking error"),new Error("Mocked error.");if(i)return x("using provided json data"),i;if(U)return x("generating test challenge"),qe();{if(!u)throw new Error("Attribute challengeurl not set.");x("fetching challenge from",u);const o=await fetch(u);if(o.status!==200)throw new Error(`Server responded with ${o.status}.`);return o.json()}}async function ut(o){let $=null;if("Worker"in window){try{$=await at(o.challenge,o.salt,o.algorithm)}catch(ne){x(ne)}if(($==null?void 0:$.number)!==void 0)return{data:o,solution:$}}return{data:o,solution:await et(o.challenge,o.salt,o.algorithm,R)}}async function at(o,$,ne){const ke=new Ke;return new Promise(mt=>{ke.addEventListener("message",vt=>{mt(vt.data)}),ke.postMessage({alg:ne,challenge:o,max:R,salt:$})})}function ft(){[p.UNVERIFIED,p.ERROR].includes(O)?X():n(6,b=!0)}function ht(){O===p.VERIFYING&&alert(r.waitAlert)}function dt(o){o.auto!==void 0&&(n(0,s=o.auto),s==="onload"&&X()),o.challenge&&(pe(o.challenge),i=o.challenge),o.debug!==void 0&&n(12,a=!!o.debug),o.hidefooter!==void 0&&n(1,A=!!o.hidefooter),o.hidelogo!==void 0&&n(2,k=!!o.hidelogo),o.maxnumber!==void 0&&n(13,R=+o.maxnumber),o.mockerror!==void 0&&n(14,S=!!o.mockerror),o.name!==void 0&&n(3,G=o.name),o.test!==void 0&&n(15,U=!!o.test),o.strings&&n(22,l=o.strings)}function te(o=p.UNVERIFIED){n(6,b=!1),n(8,h=null),n(4,v=null),n(5,O=o)}async function X(){return te(p.VERIFYING),ct().then(o=>(pe(o),x("challenge",o),ut(o))).then(({data:o,solution:$})=>{if(x("solution",$),($==null?void 0:$.number)!==void 0)x("verified"),n(5,O=p.VERIFIED),n(6,b=!0),n(4,v=st(o,$)),x("payload",v),Ue().then(()=>{Y("verified",{payload:v})});else throw new Error("Unexpected result returned.")}).catch(o=>{x(o),n(5,O=p.ERROR),n(6,b=!1),n(8,h=o)})}function gt(){b=this.checked,n(6,b)}function bt(o){J[o?"unshift":"push"](()=>{m=o,n(7,m)})}return t.$$set=o=>{"auto"in o&&n(0,s=o.auto),"challengeurl"in o&&n(16,u=o.challengeurl),"challengejson"in o&&n(17,f=o.challengejson),"debug"in o&&n(12,a=o.debug),"hidefooter"in o&&n(1,A=o.hidefooter),"hidelogo"in o&&n(2,k=o.hidelogo),"name"in o&&n(3,G=o.name),"maxnumber"in o&&n(13,R=o.maxnumber),"mockerror"in o&&n(14,S=o.mockerror),"strings"in o&&n(18,w=o.strings),"test"in o&&n(15,U=o.test)},t.$$.update=()=>{t.$$.dirty[0]&131072&&(i=f?_e(f):void 0),t.$$.dirty[0]&262144&&n(22,l=w?_e(w):{}),t.$$.dirty[0]&4194304&&n(9,r={error:"Verification failed. Try again later.",footer:`Protected by ALTCHA`,label:"I'm not a robot",verified:"Verified",verifying:"Verifying...",waitAlert:"Verifying... please wait.",...l}),t.$$.dirty[0]&48&&Y("statechange",{payload:v,state:O})},[s,A,k,G,v,O,b,m,h,r,ft,ht,a,R,S,U,u,f,w,dt,te,X,l,gt,bt]}class we extends Pe{constructor(e){super(),We(this,e,lt,ot,Ee,{auto:0,challengeurl:16,challengejson:17,debug:12,hidefooter:1,hidelogo:2,name:3,maxnumber:13,mockerror:14,strings:18,test:15,configure:19,reset:20,verify:21},tt,[-1,-1])}get auto(){return this.$$.ctx[0]}set auto(e){this.$$set({auto:e}),E()}get challengeurl(){return this.$$.ctx[16]}set challengeurl(e){this.$$set({challengeurl:e}),E()}get challengejson(){return this.$$.ctx[17]}set challengejson(e){this.$$set({challengejson:e}),E()}get debug(){return this.$$.ctx[12]}set debug(e){this.$$set({debug:e}),E()}get hidefooter(){return this.$$.ctx[1]}set hidefooter(e){this.$$set({hidefooter:e}),E()}get hidelogo(){return this.$$.ctx[2]}set hidelogo(e){this.$$set({hidelogo:e}),E()}get name(){return this.$$.ctx[3]}set name(e){this.$$set({name:e}),E()}get maxnumber(){return this.$$.ctx[13]}set maxnumber(e){this.$$set({maxnumber:e}),E()}get mockerror(){return this.$$.ctx[14]}set mockerror(e){this.$$set({mockerror:e}),E()}get strings(){return this.$$.ctx[18]}set strings(e){this.$$set({strings:e}),E()}get test(){return this.$$.ctx[15]}set test(e){this.$$set({test:e}),E()}get configure(){return this.$$.ctx[19]}get reset(){return this.$$.ctx[20]}get verify(){return this.$$.ctx[21]}}customElements.define("altcha-widget",Te(we,{auto:{},challengeurl:{},challengejson:{},debug:{type:"Boolean"},hidefooter:{type:"Boolean"},hidelogo:{type:"Boolean"},name:{},maxnumber:{},mockerror:{type:"Boolean"},strings:{},test:{type:"Boolean"}},[],["configure","reset","verify"],!1)),L.Altcha=we,Object.defineProperty(L,Symbol.toStringTag,{value:"Module"})}); +(function(I,v){typeof exports=="object"&&typeof module<"u"?v(exports):typeof define=="function"&&define.amd?define(["exports"],v):(I=typeof globalThis<"u"?globalThis:I||self,v(I.altcha={}))})(this,function(I){"use strict";var yt=Object.defineProperty;var pt=(I,v,U)=>v in I?yt(I,v,{enumerable:!0,configurable:!0,writable:!0,value:U}):I[v]=U;var N=(I,v,U)=>(pt(I,typeof v!="symbol"?v+"":v,U),U);function v(){}function U(t){return t()}function ie(){return Object.create(null)}function P(t){t.forEach(U)}function oe(t){return typeof t=="function"}function Ie(t,e){return t!=t?e==e:t!==e||t&&typeof t=="object"||typeof t=="function"}function Le(t){return Object.keys(t).length===0}function g(t,e){t.appendChild(e)}function Re(t,e,n){const i=Ne(t);if(!i.getElementById(e)){const l=y("style");l.id=e,l.textContent=n,je(i,l)}}function Ne(t){if(!t)return document;const e=t.getRootNode?t.getRootNode():t.ownerDocument;return e&&e.host?e:t.ownerDocument}function je(t,e){return g(t.head||t,e),e.sheet}function j(t,e,n){t.insertBefore(e,n||null)}function L(t){t.parentNode&&t.parentNode.removeChild(t)}function y(t){return document.createElement(t)}function V(t){return document.createElementNS("http://www.w3.org/2000/svg",t)}function Ae(t){return document.createTextNode(t)}function F(){return Ae(" ")}function Q(t,e,n,i){return t.addEventListener(e,n,i),()=>t.removeEventListener(e,n,i)}function c(t,e,n){n==null?t.removeAttribute(e):t.getAttribute(e)!==n&&t.setAttribute(e,n)}function Ge(t){return Array.from(t.childNodes)}function le(t,e,n){t.classList.toggle(e,!!n)}function Se(t,e,{bubbles:n=!1,cancelable:i=!1}={}){return new CustomEvent(t,{detail:e,bubbles:n,cancelable:i})}function Ve(t){const e={};return t.childNodes.forEach(n=>{e[n.slot||"default"]=!0}),e}let D;function X(t){D=t}function q(){if(!D)throw new Error("Function called outside component initialization");return D}function Me(t){q().$$.on_mount.push(t)}function Ue(t){q().$$.on_destroy.push(t)}function Oe(){const t=q();return(e,n,{cancelable:i=!1}={})=>{const l=t.$$.callbacks[e];if(l){const r=Se(e,n,{cancelable:i});return l.slice().forEach(s=>{s.call(t,r)}),!r.defaultPrevented}return!0}}const Z=[],ee=[];let B=[];const se=[],ce=Promise.resolve();let te=!1;function ue(){te||(te=!0,ce.then(E))}function Fe(){return ue(),ce}function ne(t){B.push(t)}const re=new Set;let H=0;function E(){if(H!==0)return;const t=D;do{try{for(;Ht.indexOf(i)===-1?e.push(i):n.push(i)),n.forEach(i=>i()),B=e}const Be=new Set;function He(t,e){t&&t.i&&(Be.delete(t),t.i(e))}function Te(t,e,n){const{fragment:i,after_update:l}=t.$$;i&&i.m(e,n),ne(()=>{const r=t.$$.on_mount.map(U).filter(oe);t.$$.on_destroy?t.$$.on_destroy.push(...r):P(r),t.$$.on_mount=[]}),l.forEach(ne)}function We(t,e){const n=t.$$;n.fragment!==null&&(Ze(n.after_update),P(n.on_destroy),n.fragment&&n.fragment.d(e),n.on_destroy=n.fragment=null,n.ctx=[])}function Pe(t,e){t.$$.dirty[0]===-1&&(Z.push(t),ue(),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<{const S=R.length?R[0]:G;return f.ctx&&l(f.ctx[k],f.ctx[k]=S)&&(!f.skip_bound&&f.bound[k]&&f.bound[k](S),A&&Pe(t,k)),G}):[],f.update(),A=!0,P(f.before_update),f.fragment=i?i(f.ctx):!1,e.target){if(e.hydrate){const k=Ge(e.target);f.fragment&&f.fragment.l(k),k.forEach(L)}else f.fragment&&f.fragment.c();e.intro&&He(t.$$.fragment),Te(t,e.target,e.anchor),E()}X(h)}let ae;typeof HTMLElement=="function"&&(ae=class extends HTMLElement{constructor(e,n,i){super();N(this,"$$ctor");N(this,"$$s");N(this,"$$c");N(this,"$$cn",!1);N(this,"$$d",{});N(this,"$$r",!1);N(this,"$$p_d",{});N(this,"$$l",{});N(this,"$$l_u",new Map);this.$$ctor=e,this.$$s=n,i&&this.attachShadow({mode:"open"})}addEventListener(e,n,i){if(this.$$l[e]=this.$$l[e]||[],this.$$l[e].push(n),this.$$c){const l=this.$$c.$on(e,n);this.$$l_u.set(n,l)}super.addEventListener(e,n,i)}removeEventListener(e,n,i){if(super.removeEventListener(e,n,i),this.$$c){const l=this.$$l_u.get(n);l&&(l(),this.$$l_u.delete(n))}}async connectedCallback(){if(this.$$cn=!0,!this.$$c){let e=function(r){return()=>{let s;return{c:function(){s=y("slot"),r!=="default"&&c(s,"name",r)},m:function(f,A){j(f,s,A)},d:function(f){f&&L(s)}}}};if(await Promise.resolve(),!this.$$cn||this.$$c)return;const n={},i=Ve(this);for(const r of this.$$s)r in i&&(n[r]=[e(r)]);for(const r of this.attributes){const s=this.$$g_p(r.name);s in this.$$d||(this.$$d[s]=z(s,r.value,this.$$p_d,"toProp"))}for(const r in this.$$p_d)!(r in this.$$d)&&this[r]!==void 0&&(this.$$d[r]=this[r],delete this[r]);this.$$c=new this.$$ctor({target:this.shadowRoot||this,props:{...this.$$d,$$slots:n,$$scope:{ctx:[]}}});const l=()=>{this.$$r=!0;for(const r in this.$$p_d)if(this.$$d[r]=this.$$c.$$.ctx[this.$$c.$$.props[r]],this.$$p_d[r].reflect){const s=z(r,this.$$d[r],this.$$p_d,"toAttribute");s==null?this.removeAttribute(this.$$p_d[r].attribute||r):this.setAttribute(this.$$p_d[r].attribute||r,s)}this.$$r=!1};this.$$c.$$.after_update.push(l),l();for(const r in this.$$l)for(const s of this.$$l[r]){const a=this.$$c.$on(r,s);this.$$l_u.set(s,a)}this.$$l={}}}attributeChangedCallback(e,n,i){var l;this.$$r||(e=this.$$g_p(e),this.$$d[e]=z(e,i,this.$$p_d,"toProp"),(l=this.$$c)==null||l.$set({[e]:this.$$d[e]}))}disconnectedCallback(){this.$$cn=!1,Promise.resolve().then(()=>{this.$$cn||(this.$$c.$destroy(),this.$$c=void 0)})}$$g_p(e){return Object.keys(this.$$p_d).find(n=>this.$$p_d[n].attribute===e||!this.$$p_d[n].attribute&&n.toLowerCase()===e)||e}});function z(t,e,n,i){var r;const l=(r=n[t])==null?void 0:r.type;if(e=l==="Boolean"&&typeof e!="boolean"?e!=null:e,!i||!n[t])return e;if(i==="toAttribute")switch(l){case"Object":case"Array":return e==null?null:JSON.stringify(e);case"Boolean":return e?"":null;case"Number":return e??null;default:return e}else switch(l){case"Object":case"Array":return e&&JSON.parse(e);case"Boolean":return e;case"Number":return e!=null?+e:e;default:return e}}function Xe(t,e,n,i,l,r){let s=class extends ae{constructor(){super(t,n,l),this.$$p_d=e}static get observedAttributes(){return Object.keys(e).map(a=>(e[a].attribute||a).toLowerCase())}};return Object.keys(e).forEach(a=>{Object.defineProperty(s.prototype,a,{get(){return this.$$c&&a in this.$$c?this.$$c[a]:this.$$d[a]},set(h){var f;h=z(a,h,e),this.$$d[a]=h,(f=this.$$c)==null||f.$set({[a]:h})}})}),i.forEach(a=>{Object.defineProperty(s.prototype,a,{get(){var h;return(h=this.$$c)==null?void 0:h[a]}})}),r&&(s=r(s)),t.element=s,s}class Ke{constructor(){N(this,"$$");N(this,"$$set")}$destroy(){We(this,1),this.$destroy=v}$on(e,n){if(!oe(n))return v;const i=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return i.push(n),()=>{const l=i.indexOf(n);l!==-1&&i.splice(l,1)}}$set(e){this.$$set&&!Le(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const ze="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(ze);const fe="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0IHI9bmV3IFRleHRFbmNvZGVyO2Z1bmN0aW9uIGMoZSl7cmV0dXJuWy4uLm5ldyBVaW50OEFycmF5KGUpXS5tYXAobj0+bi50b1N0cmluZygxNikucGFkU3RhcnQoMiwiMCIpKS5qb2luKCIiKX1hc3luYyBmdW5jdGlvbiBsKGUsbixhKXtyZXR1cm4gYyhhd2FpdCBjcnlwdG8uc3VidGxlLmRpZ2VzdChhLnRvVXBwZXJDYXNlKCksci5lbmNvZGUoZStuKSkpfWFzeW5jIGZ1bmN0aW9uIGkoZSxuLGE9IlNIQS0yNTYiLG89MWU3KXtjb25zdCBzPURhdGUubm93KCk7Zm9yKGxldCB0PTA7dDw9bzt0KyspaWYoYXdhaXQgbChuLHQsYSk9PT1lKXJldHVybntudW1iZXI6dCx0b29rOkRhdGUubm93KCktc307cmV0dXJuIG51bGx9b25tZXNzYWdlPWFzeW5jIGU9Pntjb25zdHthbGc6bixjaGFsbGVuZ2U6YSxtYXg6byxzYWx0OnN9PWUuZGF0YXx8e307aWYoYSYmcyl7Y29uc3QgdD1hd2FpdCBpKGEscyxuLG8pO3NlbGYucG9zdE1lc3NhZ2UodCYmey4uLnQsd29ya2VyOiEwfSl9ZWxzZSBzZWxmLnBvc3RNZXNzYWdlKG51bGwpfX0pKCk7Cg==",Je=t=>Uint8Array.from(atob(t),e=>e.charCodeAt(0)),he=typeof window<"u"&&window.Blob&&new Blob([Je(fe)],{type:"text/javascript;charset=utf-8"});function Qe(t){let e;try{if(e=he&&(window.URL||window.webkitURL).createObjectURL(he),!e)throw"";const n=new Worker(e,{name:t==null?void 0:t.name});return n.addEventListener("error",()=>{(window.URL||window.webkitURL).revokeObjectURL(e)}),n}catch{return new Worker("data:text/javascript;base64,"+fe,{name:t==null?void 0:t.name})}finally{e&&(window.URL||window.webkitURL).revokeObjectURL(e)}}const qe=1e7,et=new TextEncoder;function tt(t){return[...new Uint8Array(t)].map(e=>e.toString(16).padStart(2,"0")).join("")}async function nt(t=1e5,e="SHA-256"){const n=Date.now().toString(16),i=Math.round(Math.random()*t),l=await de(n,i,e);return{algorithm:e,challenge:l,salt:n,signature:""}}async function de(t,e,n){return tt(await crypto.subtle.digest(n.toUpperCase(),et.encode(t+e)))}async function rt(t,e,n="SHA-256",i=qe){const l=Date.now();for(let r=0;r<=i;r++)if(await de(e,r,n)===t)return{number:r,took:Date.now()-l};return null}var _=(t=>(t.ERROR="error",t.VERIFIED="verified",t.VERIFYING="verifying",t.UNVERIFIED="unverified",t.EXPIRED="expired",t))(_||{});function it(t){Re(t,"svelte-vuofbg",".altcha.svelte-vuofbg.svelte-vuofbg{background:var(--altcha-color-base, transparent);border:var(--altcha-border-width, 1px) solid var(--altcha-color-border, #a0a0a0);border-radius:var(--altcha-border-radius, 3px);color:var(--altcha-color-text, currentColor);display:flex;flex-direction:column;max-width:var(--altcha-max-width, 260px);overflow:hidden;position:relative;text-align:left}.altcha.svelte-vuofbg.svelte-vuofbg:focus-within{border-color:var(--altcha-color-border-focus, currentColor)}.altcha-main.svelte-vuofbg.svelte-vuofbg{align-items:center;display:flex;gap:0.4rem;padding:0.7rem}.altcha-label.svelte-vuofbg.svelte-vuofbg{flex-grow:1}.altcha-label.svelte-vuofbg label.svelte-vuofbg{cursor:pointer}.altcha-logo.svelte-vuofbg.svelte-vuofbg{color:currentColor;opacity:0.3}.altcha-logo.svelte-vuofbg.svelte-vuofbg:hover{opacity:1}.altcha-error.svelte-vuofbg.svelte-vuofbg{color:var(--altcha-color-error-text, #f23939);display:flex;font-size:0.85rem;gap:0.3rem;padding:0 0.7rem 0.7rem}.altcha-footer.svelte-vuofbg.svelte-vuofbg{align-items:center;background-color:var(--altcha-color-footer-bg, transparent);display:flex;font-size:0.75rem;opacity:0.4;padding:0.2rem 0.7rem;text-align:right}.altcha-footer.svelte-vuofbg.svelte-vuofbg:hover{opacity:1}.altcha-footer.svelte-vuofbg>.svelte-vuofbg:first-child{flex-grow:1}.altcha-footer.svelte-vuofbg a{color:currentColor}.altcha-checkbox.svelte-vuofbg.svelte-vuofbg{display:flex;align-items:center;height:24px;width:24px}.altcha-checkbox.svelte-vuofbg input.svelte-vuofbg{width:18px;height:18px;margin:0}.altcha-hidden.svelte-vuofbg.svelte-vuofbg{display:none}.altcha-spinner.svelte-vuofbg.svelte-vuofbg{animation:svelte-vuofbg-altcha-spinner 0.75s infinite linear;transform-origin:center}@keyframes svelte-vuofbg-altcha-spinner{100%{transform:rotate(360deg)}}")}function ge(t){let e,n,i;return{c(){e=V("svg"),n=V("path"),i=V("path"),c(n,"d","M12,1A11,11,0,1,0,23,12,11,11,0,0,0,12,1Zm0,19a8,8,0,1,1,8-8A8,8,0,0,1,12,20Z"),c(n,"fill","currentColor"),c(n,"opacity",".25"),c(i,"d","M12,4a8,8,0,0,1,7.89,6.7A1.53,1.53,0,0,0,21.38,12h0a1.5,1.5,0,0,0,1.48-1.75,11,11,0,0,0-21.72,0A1.5,1.5,0,0,0,2.62,12h0a1.53,1.53,0,0,0,1.49-1.3A8,8,0,0,1,12,4Z"),c(i,"fill","currentColor"),c(i,"class","altcha-spinner svelte-vuofbg"),c(e,"width","24"),c(e,"height","24"),c(e,"viewBox","0 0 24 24"),c(e,"xmlns","http://www.w3.org/2000/svg")},m(l,r){j(l,e,r),g(e,n),g(e,i)},d(l){l&&L(e)}}}function ot(t){let e,n=t[9].label+"",i;return{c(){e=y("label"),c(e,"for",i=t[3]+"_checkbox"),c(e,"class","svelte-vuofbg")},m(l,r){j(l,e,r),e.innerHTML=n},p(l,r){r[0]&512&&n!==(n=l[9].label+"")&&(e.innerHTML=n),r[0]&8&&i!==(i=l[3]+"_checkbox")&&c(e,"for",i)},d(l){l&&L(e)}}}function lt(t){let e,n=t[9].verifying+"";return{c(){e=y("span")},m(i,l){j(i,e,l),e.innerHTML=n},p(i,l){l[0]&512&&n!==(n=i[9].verifying+"")&&(e.innerHTML=n)},d(i){i&&L(e)}}}function st(t){let e,n=t[9].verified+"",i,l;return{c(){e=y("span"),i=F(),l=y("input"),c(l,"type","hidden"),c(l,"name",t[3]),l.value=t[4]},m(r,s){j(r,e,s),e.innerHTML=n,j(r,i,s),j(r,l,s)},p(r,s){s[0]&512&&n!==(n=r[9].verified+"")&&(e.innerHTML=n),s[0]&8&&c(l,"name",r[3]),s[0]&16&&(l.value=r[4])},d(r){r&&(L(e),L(i),L(l))}}}function be(t){let e,n,i,l,r,s;return{c(){e=y("div"),n=y("a"),i=V("svg"),l=V("path"),r=V("path"),s=V("path"),c(l,"d","M2.33955 16.4279C5.88954 20.6586 12.1971 21.2105 16.4279 17.6604C18.4699 15.947 19.6548 13.5911 19.9352 11.1365L17.9886 10.4279C17.8738 12.5624 16.909 14.6459 15.1423 16.1284C11.7577 18.9684 6.71167 18.5269 3.87164 15.1423C1.03163 11.7577 1.4731 6.71166 4.8577 3.87164C8.24231 1.03162 13.2883 1.4731 16.1284 4.8577C16.9767 5.86872 17.5322 7.02798 17.804 8.2324L19.9522 9.01429C19.7622 7.07737 19.0059 5.17558 17.6604 3.57212C14.1104 -0.658624 7.80283 -1.21043 3.57212 2.33956C-0.658625 5.88958 -1.21046 12.1971 2.33955 16.4279Z"),c(l,"fill","currentColor"),c(r,"d","M3.57212 2.33956C1.65755 3.94607 0.496389 6.11731 0.12782 8.40523L2.04639 9.13961C2.26047 7.15832 3.21057 5.25375 4.8577 3.87164C8.24231 1.03162 13.2883 1.4731 16.1284 4.8577L13.8302 6.78606L19.9633 9.13364C19.7929 7.15555 19.0335 5.20847 17.6604 3.57212C14.1104 -0.658624 7.80283 -1.21043 3.57212 2.33956Z"),c(r,"fill","currentColor"),c(s,"d","M7 10H5C5 12.7614 7.23858 15 10 15C12.7614 15 15 12.7614 15 10H13C13 11.6569 11.6569 13 10 13C8.3431 13 7 11.6569 7 10Z"),c(s,"fill","currentColor"),c(i,"width","22"),c(i,"height","22"),c(i,"viewBox","0 0 20 20"),c(i,"fill","none"),c(i,"xmlns","http://www.w3.org/2000/svg"),c(n,"href",_e),c(n,"target","_blank"),c(n,"class","altcha-logo svelte-vuofbg")},m(a,h){j(a,e,h),g(e,n),g(n,i),g(i,l),g(i,r),g(i,s)},p:v,d(a){a&&L(e)}}}function me(t){let e,n,i,l,r;return{c(){e=y("div"),n=V("svg"),i=V("path"),l=F(),r=y("div"),c(i,"stroke-linecap","round"),c(i,"stroke-linejoin","round"),c(i,"d","M6 18L18 6M6 6l12 12"),c(n,"width","14"),c(n,"height","14"),c(n,"xmlns","http://www.w3.org/2000/svg"),c(n,"fill","none"),c(n,"viewBox","0 0 24 24"),c(n,"stroke-width","1.5"),c(n,"stroke","currentColor"),c(e,"class","altcha-error svelte-vuofbg")},m(s,a){j(s,e,a),g(e,n),g(n,i),g(e,l),g(e,r),r.innerHTML=t[8]},p(s,a){a[0]&256&&(r.innerHTML=s[8])},d(s){s&&L(e)}}}function ve(t){let e,n,i=t[9].footer+"";return{c(){e=y("div"),n=y("div"),c(n,"class","svelte-vuofbg"),c(e,"class","altcha-footer svelte-vuofbg")},m(l,r){j(l,e,r),g(e,n),n.innerHTML=i},p(l,r){r[0]&512&&i!==(i=l[9].footer+"")&&(n.innerHTML=i)},d(l){l&&L(e)}}}function ct(t){let e,n,i,l,r,s,a,h,f,A,k,G,R,S,w=t[5]===_.VERIFYING&&ge();function M(u,p){return u[5]===_.VERIFIED?st:u[5]===_.VERIFYING?lt:ot}let Y=M(t),x=Y(t),$=t[2]!==!0&&be(),b=t[8]&&me(t),m=t[9].footer&&t[1]!==!0&&ve(t);return{c(){e=y("div"),n=y("div"),w&&w.c(),i=F(),l=y("div"),r=y("input"),h=F(),f=y("div"),x.c(),A=F(),$&&$.c(),k=F(),b&&b.c(),G=F(),m&&m.c(),c(r,"type","checkbox"),c(r,"id",s=t[3]+"_checkbox"),r.required=a=t[0]!=="onsubmit",c(r,"class","svelte-vuofbg"),c(l,"class","altcha-checkbox svelte-vuofbg"),le(l,"altcha-hidden",t[5]===_.VERIFYING),c(f,"class","altcha-label svelte-vuofbg"),c(n,"class","altcha-main svelte-vuofbg"),c(e,"class","altcha svelte-vuofbg"),c(e,"data-state",t[5])},m(u,p){j(u,e,p),g(e,n),w&&w.m(n,null),g(n,i),g(n,l),g(l,r),r.checked=t[6],g(n,h),g(n,f),x.m(f,null),g(n,A),$&&$.m(n,null),g(e,k),b&&b.m(e,null),g(e,G),m&&m.m(e,null),t[24](e),R||(S=[Q(r,"change",t[23]),Q(r,"change",t[10]),Q(r,"invalid",t[11])],R=!0)},p(u,p){u[5]===_.VERIFYING?w||(w=ge(),w.c(),w.m(n,i)):w&&(w.d(1),w=null),p[0]&8&&s!==(s=u[3]+"_checkbox")&&c(r,"id",s),p[0]&1&&a!==(a=u[0]!=="onsubmit")&&(r.required=a),p[0]&64&&(r.checked=u[6]),p[0]&32&&le(l,"altcha-hidden",u[5]===_.VERIFYING),Y===(Y=M(u))&&x?x.p(u,p):(x.d(1),x=Y(u),x&&(x.c(),x.m(f,null))),u[2]!==!0?$?$.p(u,p):($=be(),$.c(),$.m(n,null)):$&&($.d(1),$=null),u[8]?b?b.p(u,p):(b=me(u),b.c(),b.m(e,G)):b&&(b.d(1),b=null),u[9].footer&&u[1]!==!0?m?m.p(u,p):(m=ve(u),m.c(),m.m(e,null)):m&&(m.d(1),m=null),p[0]&32&&c(e,"data-state",u[5])},i:v,o:v,d(u){u&&L(e),w&&w.d(),x.d(),$&&$.d(),b&&b.d(),m&&m.d(),t[24](null),R=!1,P(S)}}}const _e="https://altcha.org/";function we(t){return JSON.parse(t)}function ut(t,e,n){let i,l,r,{auto:s=void 0}=e,{challengeurl:a=void 0}=e,{challengejson:h=void 0}=e,{debug:f=!1}=e,{hidefooter:A=!1}=e,{hidelogo:k=!1}=e,{name:G="altcha"}=e,{maxnumber:R=void 0}=e,{mockerror:S=!1}=e,{strings:w=void 0}=e,{test:M=!1}=e;const Y=Oe(),x=["SHA-256","SHA-384","SHA-512"],$=[];let b=!1,m,u=null,p=null,T=null,O=_.UNVERIFIED,ye;Ue(()=>{u&&(u.removeEventListener("submit",pe),u.removeEventListener("reset",ke),u=null)}),Me(()=>{C("mounted","0.1.9"),M&&C("using test mode"),s!==void 0&&C("auto",s),u=m.closest("form"),u&&(u.addEventListener("submit",pe),u.addEventListener("reset",ke)),s==="onload"&&K()});function C(...o){(f||o.some(d=>d instanceof Error))&&console[o[0]instanceof Error?"error":"log"]("ALTCHA",...o)}function pe(o){u&&s==="onsubmit"&&O===_.UNVERIFIED&&(o.preventDefault(),o.stopPropagation(),K().then(()=>{u==null||u.requestSubmit()}))}function ke(){J()}function at(o,d){return btoa(JSON.stringify({algorithm:o.algorithm,challenge:o.challenge,number:d.number,salt:o.salt,signature:o.signature,test:M?!0:void 0,took:d.took}))}function Ee(o){if(!o.algorithm)throw new Error("Invalid challenge. Property algorithm is missing.");if(o.signature===void 0)throw new Error("Invalid challenge. Property signature is missing.");if(!x.includes(o.algorithm.toUpperCase()))throw new Error(`Unknown algorithm value. Allowed values: ${x.join(", ")}`);if(!o.challenge||o.challenge.length<40)throw new Error("Challenge is too short. Min. 40 chars.");if(!o.salt||o.salt.length<10)throw new Error("Salt is too short. Min. 10 chars.")}async function ft(){if(S)throw C("mocking error"),new Error("Mocked error.");if(i)return C("using provided json data"),i;if(M)return C("generating test challenge"),nt();{if(!a)throw new Error("Attribute challengeurl not set.");C("fetching challenge from",a);const o=await fetch(a);if(o.status!==200)throw new Error(`Server responded with ${o.status}.`);const d=o.headers.get("Expires");if(d.length){const W=Date.parse(d)-Date.now();W<1?xe():ye=setTimeout(xe,W)}return o.json()}}function xe(){J(_.EXPIRED,r.expired)}async function ht(o){let d=null;if("Worker"in window){try{d=await dt(o.challenge,o.salt,o.algorithm)}catch(W){C(W)}if((d==null?void 0:d.number)!==void 0)return{data:o,solution:d}}return{data:o,solution:await rt(o.challenge,o.salt,o.algorithm,R)}}async function dt(o,d,W){const Ce=$.push(new Qe);return new Promise(wt=>{$[Ce-1].addEventListener("message",$t=>{wt($t.data)}),$[Ce-1].postMessage({alg:W,challenge:o,max:R,salt:d})})}function gt(){[_.UNVERIFIED,_.ERROR,_.EXPIRED].includes(O)?K():n(6,b=!0)}function bt(){O===_.VERIFYING&&alert(r.waitAlert)}function mt(o){o.auto!==void 0&&(n(0,s=o.auto),s==="onload"&&K()),o.challenge&&(Ee(o.challenge),i=o.challenge),o.debug!==void 0&&n(12,f=!!o.debug),o.hidefooter!==void 0&&n(1,A=!!o.hidefooter),o.hidelogo!==void 0&&n(2,k=!!o.hidelogo),o.maxnumber!==void 0&&n(13,R=+o.maxnumber),o.mockerror!==void 0&&n(14,S=!!o.mockerror),o.name!==void 0&&n(3,G=o.name),o.test!==void 0&&n(15,M=!!o.test),o.strings&&n(22,l=o.strings)}function J(o=_.UNVERIFIED,d=null){clearTimeout(ye),n(6,b=!1),n(8,p=d),n(4,T=null),n(5,O=o)}async function K(){return J(_.VERIFYING),ft().then(o=>(Ee(o),C("challenge",o),ht(o))).then(({data:o,solution:d})=>{if(C("solution",d),(d==null?void 0:d.number)!==void 0)C("verified"),n(5,O=_.VERIFIED),n(6,b=!0),n(4,T=at(o,d)),C("payload",T),Fe().then(()=>{Y("verified",{payload:T})});else throw new Error("Unexpected result returned.")}).catch(o=>{C(o),n(5,O=_.ERROR),n(6,b=!1),n(8,p=o.message)})}function vt(){b=this.checked,n(6,b)}function _t(o){ee[o?"unshift":"push"](()=>{m=o,n(7,m)})}return t.$$set=o=>{"auto"in o&&n(0,s=o.auto),"challengeurl"in o&&n(16,a=o.challengeurl),"challengejson"in o&&n(17,h=o.challengejson),"debug"in o&&n(12,f=o.debug),"hidefooter"in o&&n(1,A=o.hidefooter),"hidelogo"in o&&n(2,k=o.hidelogo),"name"in o&&n(3,G=o.name),"maxnumber"in o&&n(13,R=o.maxnumber),"mockerror"in o&&n(14,S=o.mockerror),"strings"in o&&n(18,w=o.strings),"test"in o&&n(15,M=o.test)},t.$$.update=()=>{t.$$.dirty[0]&131072&&(i=h?we(h):void 0),t.$$.dirty[0]&262144&&n(22,l=w?we(w):{}),t.$$.dirty[0]&4194304&&n(9,r={error:"Verification failed. Try again later.",expired:"Verification expired. Try again.",footer:`Protected by ALTCHA`,label:"I'm not a robot",verified:"Verified",verifying:"Verifying...",waitAlert:"Verifying... please wait.",...l}),t.$$.dirty[0]&48&&Y("statechange",{payload:T,state:O})},[s,A,k,G,T,O,b,m,p,r,gt,bt,f,R,S,M,a,h,w,mt,J,K,l,vt,_t]}class $e extends Ke{constructor(e){super(),De(this,e,ut,ct,Ie,{auto:0,challengeurl:16,challengejson:17,debug:12,hidefooter:1,hidelogo:2,name:3,maxnumber:13,mockerror:14,strings:18,test:15,configure:19,reset:20,verify:21},it,[-1,-1])}get auto(){return this.$$.ctx[0]}set auto(e){this.$$set({auto:e}),E()}get challengeurl(){return this.$$.ctx[16]}set challengeurl(e){this.$$set({challengeurl:e}),E()}get challengejson(){return this.$$.ctx[17]}set challengejson(e){this.$$set({challengejson:e}),E()}get debug(){return this.$$.ctx[12]}set debug(e){this.$$set({debug:e}),E()}get hidefooter(){return this.$$.ctx[1]}set hidefooter(e){this.$$set({hidefooter:e}),E()}get hidelogo(){return this.$$.ctx[2]}set hidelogo(e){this.$$set({hidelogo:e}),E()}get name(){return this.$$.ctx[3]}set name(e){this.$$set({name:e}),E()}get maxnumber(){return this.$$.ctx[13]}set maxnumber(e){this.$$set({maxnumber:e}),E()}get mockerror(){return this.$$.ctx[14]}set mockerror(e){this.$$set({mockerror:e}),E()}get strings(){return this.$$.ctx[18]}set strings(e){this.$$set({strings:e}),E()}get test(){return this.$$.ctx[15]}set test(e){this.$$set({test:e}),E()}get configure(){return this.$$.ctx[19]}get reset(){return this.$$.ctx[20]}get verify(){return this.$$.ctx[21]}}customElements.define("altcha-widget",Xe($e,{auto:{},challengeurl:{},challengejson:{},debug:{type:"Boolean"},hidefooter:{type:"Boolean"},hidelogo:{type:"Boolean"},name:{},maxnumber:{},mockerror:{type:"Boolean"},strings:{},test:{type:"Boolean"}},[],["configure","reset","verify"],!1)),I.Altcha=$e,Object.defineProperty(I,Symbol.toStringTag,{value:"Module"})}); diff --git a/package-lock.json b/package-lock.json index 6e98b9b..6cac995 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "altcha", - "version": "0.1.6", + "version": "0.1.9", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "altcha", - "version": "0.1.6", + "version": "0.1.9", "license": "MIT", "devDependencies": { "@playwright/test": "^1.41.2", @@ -17,7 +17,6 @@ "cors": "^2.8.5", "express": "^4.18.2", "sass": "^1.71.1", - "serve": "^14.2.1", "svelte": "^4.2.11", "svelte-check": "^3.4.6", "tslib": "^2.6.0", @@ -841,12 +840,6 @@ "url": "https://opencollective.com/vitest" } }, - "node_modules/@zeit/schemas": { - "version": "2.29.0", - "resolved": "https://registry.npmjs.org/@zeit/schemas/-/schemas-2.29.0.tgz", - "integrity": "sha512-g5QiLIfbg3pLuYUJPlisNKY+epQJTcMDsOnVNkscrDP1oi7vmJnzOANYJI/1pZcVJ6umUkBv3aFtlg1UvUHGzA==", - "dev": true - }, "node_modules/accepts": { "version": "1.3.8", "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", @@ -881,84 +874,6 @@ "node": ">=0.4.0" } }, - "node_modules/ajv": { - "version": "8.11.0", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.11.0.tgz", - "integrity": "sha512-wGgprdCvMalC0BztXvitD2hC04YffAvtsUn93JbGXYLAtCUO4xd17mCCZQxUOItiBwZvJScWo8NIvQMQ71rdpg==", - "dev": true, - "dependencies": { - "fast-deep-equal": "^3.1.1", - "json-schema-traverse": "^1.0.0", - "require-from-string": "^2.0.2", - "uri-js": "^4.2.2" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/epoberezkin" - } - }, - "node_modules/ansi-align": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/ansi-align/-/ansi-align-3.0.1.tgz", - "integrity": "sha512-IOfwwBF5iczOjp/WeY4YxyjqAFMQoZufdQWDd19SEExbVLNXqvpzSJ/M7Za4/sCPmQ0+GRquoA7bGcINcxew6w==", - "dev": true, - "dependencies": { - "string-width": "^4.1.0" - } - }, - "node_modules/ansi-align/node_modules/ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/ansi-align/node_modules/emoji-regex": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "dev": true - }, - "node_modules/ansi-align/node_modules/string-width": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dev": true, - "dependencies": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/ansi-align/node_modules/strip-ansi": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dev": true, - "dependencies": { - "ansi-regex": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/ansi-regex": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz", - "integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==", - "dev": true, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/ansi-regex?sponsor=1" - } - }, "node_modules/ansi-styles": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz", @@ -984,32 +899,6 @@ "node": ">= 8" } }, - "node_modules/arch": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/arch/-/arch-2.2.0.tgz", - "integrity": "sha512-Of/R0wqp83cgHozfIYLbBMnej79U/SVGOOyuB3VVFv1NRM/PSFMK12x9KVtiYzJqmnU5WR2qp0Z5rHb7sWGnFQ==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ] - }, - "node_modules/arg": { - "version": "5.0.2", - "resolved": "https://registry.npmjs.org/arg/-/arg-5.0.2.tgz", - "integrity": "sha512-PYjyFOLKQ9y57JvQ6QLo8dAgNqswh8M1RMJYdQduT6xbWSgK36P/Z/v+p888pM69jMMfS8Xd8F6I1kQ/I9HUGg==", - "dev": true - }, "node_modules/aria-query": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.3.0.tgz", @@ -1097,28 +986,6 @@ "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", "dev": true }, - "node_modules/boxen": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/boxen/-/boxen-7.0.0.tgz", - "integrity": "sha512-j//dBVuyacJbvW+tvZ9HuH03fZ46QcaKvvhZickZqtB271DxJ7SNRSNxrV/dZX0085m7hISRZWbzWlJvx/rHSg==", - "dev": true, - "dependencies": { - "ansi-align": "^3.0.1", - "camelcase": "^7.0.0", - "chalk": "^5.0.1", - "cli-boxes": "^3.0.0", - "string-width": "^5.1.2", - "type-fest": "^2.13.0", - "widest-line": "^4.0.1", - "wrap-ansi": "^8.0.1" - }, - "engines": { - "node": ">=14.16" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", @@ -1196,18 +1063,6 @@ "node": ">=6" } }, - "node_modules/camelcase": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-7.0.1.tgz", - "integrity": "sha512-xlx1yCK2Oc1APsPXDL2LdlNP6+uu8OCDdhOBSVT279M/S+y75O30C2VuD8T2ogdePBBl7PfPF4504tnLgX3zfw==", - "dev": true, - "engines": { - "node": ">=14.16" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/chai": { "version": "4.4.1", "resolved": "https://registry.npmjs.org/chai/-/chai-4.4.1.tgz", @@ -1226,64 +1081,6 @@ "node": ">=4" } }, - "node_modules/chalk": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.0.1.tgz", - "integrity": "sha512-Fo07WOYGqMfCWHOzSXOt2CxDbC6skS/jO9ynEcmpANMoPrD+W1r1K6Vx7iNm+AQmETU1Xr2t+n8nzkV9t6xh3w==", - "dev": true, - "engines": { - "node": "^12.17.0 || ^14.13 || >=16.0.0" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "node_modules/chalk-template": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/chalk-template/-/chalk-template-0.4.0.tgz", - "integrity": "sha512-/ghrgmhfY8RaSdeo43hNXxpoHAtxdbskUHjPpfqUWGttFgycUhYPGx3YZBCnUCvOa7Doivn1IZec3DEGFoMgLg==", - "dev": true, - "dependencies": { - "chalk": "^4.1.2" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/chalk-template?sponsor=1" - } - }, - "node_modules/chalk-template/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/chalk-template/node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dev": true, - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, "node_modules/check-error": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.3.tgz", @@ -1320,35 +1117,6 @@ "fsevents": "~2.3.2" } }, - "node_modules/cli-boxes": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/cli-boxes/-/cli-boxes-3.0.0.tgz", - "integrity": "sha512-/lzGpEWL/8PfI0BmBOPRwp0c/wFNX1RdUML3jK/RcSBA9T8mZDdQpqYBKtCFTOfQbwPqWEOpjqW+Fnayc0969g==", - "dev": true, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/clipboardy": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/clipboardy/-/clipboardy-3.0.0.tgz", - "integrity": "sha512-Su+uU5sr1jkUy1sGRpLKjKrvEOVXgSgiSInwa/qeID6aJ07yh+5NWc3h2QfjHjBnfX4LhtFcuAWKUsJ3r+fjbg==", - "dev": true, - "dependencies": { - "arch": "^2.2.0", - "execa": "^5.1.1", - "is-wsl": "^2.2.0" - }, - "engines": { - "node": "^12.20.0 || ^14.13.1 || >=16.0.0" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/code-red": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/code-red/-/code-red-1.0.4.tgz", @@ -1362,84 +1130,6 @@ "periscopic": "^3.1.0" } }, - "node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "node_modules/compressible": { - "version": "2.0.18", - "resolved": "https://registry.npmjs.org/compressible/-/compressible-2.0.18.tgz", - "integrity": "sha512-AF3r7P5dWxL8MxyITRMlORQNaOA2IkAFaTr4k7BUumjPtRpGDTZpl0Pb1XCO6JeDCBdp126Cgs9sMxqSjgYyRg==", - "dev": true, - "dependencies": { - "mime-db": ">= 1.43.0 < 2" - }, - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/compression": { - "version": "1.7.4", - "resolved": "https://registry.npmjs.org/compression/-/compression-1.7.4.tgz", - "integrity": "sha512-jaSIDzP9pZVS4ZfQ+TzvtiWhdpFhE2RDHz8QJkpX9SIpLq88VueF5jJw6t+6CUQcAoA6t+x89MLrWAqpfDE8iQ==", - "dev": true, - "dependencies": { - "accepts": "~1.3.5", - "bytes": "3.0.0", - "compressible": "~2.0.16", - "debug": "2.6.9", - "on-headers": "~1.0.2", - "safe-buffer": "5.1.2", - "vary": "~1.1.2" - }, - "engines": { - "node": ">= 0.8.0" - } - }, - "node_modules/compression/node_modules/bytes": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz", - "integrity": "sha512-pMhOfFDPiv9t5jjIXkHosWmkSyQbvsgEVNkz0ERHbuLh2T/7j4Mqqpz523Fe8MVY89KC6Sh/QfS2sM+SjgFDcw==", - "dev": true, - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/compression/node_modules/debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dev": true, - "dependencies": { - "ms": "2.0.0" - } - }, - "node_modules/compression/node_modules/ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", - "dev": true - }, - "node_modules/compression/node_modules/safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", - "dev": true - }, "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", @@ -1495,20 +1185,6 @@ "node": ">= 0.10" } }, - "node_modules/cross-spawn": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", - "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", - "dev": true, - "dependencies": { - "path-key": "^3.1.0", - "shebang-command": "^2.0.0", - "which": "^2.0.1" - }, - "engines": { - "node": ">= 8" - } - }, "node_modules/css-tree": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/css-tree/-/css-tree-2.3.1.tgz", @@ -1551,15 +1227,6 @@ "node": ">=6" } }, - "node_modules/deep-extend": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz", - "integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==", - "dev": true, - "engines": { - "node": ">=4.0.0" - } - }, "node_modules/deepmerge": { "version": "4.3.1", "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.1.tgz", @@ -1632,24 +1299,12 @@ "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, - "node_modules/eastasianwidth": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", - "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==", - "dev": true - }, "node_modules/ee-first": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==", "dev": true }, - "node_modules/emoji-regex": { - "version": "9.2.2", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", - "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==", - "dev": true - }, "node_modules/encodeurl": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", @@ -1748,29 +1403,6 @@ "node": ">= 0.6" } }, - "node_modules/execa": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/execa/-/execa-5.1.1.tgz", - "integrity": "sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==", - "dev": true, - "dependencies": { - "cross-spawn": "^7.0.3", - "get-stream": "^6.0.0", - "human-signals": "^2.1.0", - "is-stream": "^2.0.0", - "merge-stream": "^2.0.0", - "npm-run-path": "^4.0.1", - "onetime": "^5.1.2", - "signal-exit": "^3.0.3", - "strip-final-newline": "^2.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sindresorhus/execa?sponsor=1" - } - }, "node_modules/express": { "version": "4.18.2", "resolved": "https://registry.npmjs.org/express/-/express-4.18.2.tgz", @@ -1867,12 +1499,6 @@ "node": ">= 0.8" } }, - "node_modules/fast-deep-equal": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", - "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", - "dev": true - }, "node_modules/fast-glob": { "version": "3.3.2", "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.2.tgz", @@ -1889,15 +1515,6 @@ "node": ">=8.6.0" } }, - "node_modules/fast-url-parser": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/fast-url-parser/-/fast-url-parser-1.1.3.tgz", - "integrity": "sha512-5jOCVXADYNuRkKFzNJ0dCCewsZiYo0dz8QNYljkOpFC6r2U4OBmKtvm/Tsuh4w1YYdDqDb31a8TVhBJ2OJKdqQ==", - "dev": true, - "dependencies": { - "punycode": "^1.3.2" - } - }, "node_modules/fastq": { "version": "1.17.1", "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.17.1.tgz", @@ -2027,18 +1644,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/get-stream": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-6.0.1.tgz", - "integrity": "sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==", - "dev": true, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/glob": { "version": "7.2.3", "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", @@ -2089,15 +1694,6 @@ "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", "dev": true }, - "node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true, - "engines": { - "node": ">=8" - } - }, "node_modules/has-property-descriptors": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz", @@ -2162,15 +1758,6 @@ "node": ">= 0.8" } }, - "node_modules/human-signals": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-2.1.0.tgz", - "integrity": "sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==", - "dev": true, - "engines": { - "node": ">=10.17.0" - } - }, "node_modules/iconv-lite": { "version": "0.4.24", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", @@ -2221,12 +1808,6 @@ "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", "dev": true }, - "node_modules/ini": { - "version": "1.3.8", - "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz", - "integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==", - "dev": true - }, "node_modules/ipaddr.js": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", @@ -2248,21 +1829,6 @@ "node": ">=8" } }, - "node_modules/is-docker": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-2.2.1.tgz", - "integrity": "sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ==", - "dev": true, - "bin": { - "is-docker": "cli.js" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/is-extglob": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", @@ -2272,15 +1838,6 @@ "node": ">=0.10.0" } }, - "node_modules/is-fullwidth-code-point": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", - "dev": true, - "engines": { - "node": ">=8" - } - }, "node_modules/is-glob": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", @@ -2298,20 +1855,8 @@ "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", "dev": true, - "engines": { - "node": ">=0.12.0" - } - }, - "node_modules/is-port-reachable": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/is-port-reachable/-/is-port-reachable-4.0.0.tgz", - "integrity": "sha512-9UoipoxYmSk6Xy7QFgRv2HDyaysmgSG75TFQs6S+3pDM7ZhKTF/bskZV+0UlABHzKjNVhPjYCLfeZUEg1wXxig==", - "dev": true, - "engines": { - "node": "^12.20.0 || ^14.13.1 || >=16.0.0" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" + "engines": { + "node": ">=0.12.0" } }, "node_modules/is-reference": { @@ -2323,42 +1868,6 @@ "@types/estree": "*" } }, - "node_modules/is-stream": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", - "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==", - "dev": true, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/is-wsl": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz", - "integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==", - "dev": true, - "dependencies": { - "is-docker": "^2.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/isexe": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", - "dev": true - }, - "node_modules/json-schema-traverse": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", - "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", - "dev": true - }, "node_modules/jsonc-parser": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.2.1.tgz", @@ -2434,12 +1943,6 @@ "integrity": "sha512-cCi6g3/Zr1iqQi6ySbseM1Xvooa98N0w31jzUYrXPX2xqObmFGHJ0tQ5u74H3mVh7wLouTseZyYIq39g8cNp1w==", "dev": true }, - "node_modules/merge-stream": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", - "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==", - "dev": true - }, "node_modules/merge2": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", @@ -2504,15 +2007,6 @@ "node": ">= 0.6" } }, - "node_modules/mimic-fn": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", - "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", - "dev": true, - "engines": { - "node": ">=6" - } - }, "node_modules/min-indent": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/min-indent/-/min-indent-1.0.1.tgz", @@ -2618,18 +2112,6 @@ "node": ">=0.10.0" } }, - "node_modules/npm-run-path": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-4.0.1.tgz", - "integrity": "sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==", - "dev": true, - "dependencies": { - "path-key": "^3.0.0" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/object-assign": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", @@ -2660,15 +2142,6 @@ "node": ">= 0.8" } }, - "node_modules/on-headers": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/on-headers/-/on-headers-1.0.2.tgz", - "integrity": "sha512-pZAE+FJLoyITytdqK0U5s+FIpjN0JP3OzFi/u8Rx+EV5/W+JTWGXG8xFzevE7AjBfDqHv/8vL8qQsIhHnqRkrA==", - "dev": true, - "engines": { - "node": ">= 0.8" - } - }, "node_modules/once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", @@ -2678,21 +2151,6 @@ "wrappy": "1" } }, - "node_modules/onetime": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz", - "integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==", - "dev": true, - "dependencies": { - "mimic-fn": "^2.1.0" - }, - "engines": { - "node": ">=6" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/p-limit": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-4.0.0.tgz", @@ -2738,21 +2196,6 @@ "node": ">=0.10.0" } }, - "node_modules/path-is-inside": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/path-is-inside/-/path-is-inside-1.0.2.tgz", - "integrity": "sha512-DUWJr3+ULp4zXmol/SZkFf3JGsS9/SIv+Y3Rt93/UjPpDpklB5f1er4O3POIbUuUJ3FXgqte2Q7SrU6zAqwk8w==", - "dev": true - }, - "node_modules/path-key": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", - "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", - "dev": true, - "engines": { - "node": ">=8" - } - }, "node_modules/path-to-regexp": { "version": "0.1.7", "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", @@ -2913,12 +2356,6 @@ "node": ">= 0.10" } }, - "node_modules/punycode": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", - "integrity": "sha512-jmYNElW7yvO7TV33CjSmvSiE2yco3bV2czu/OzDKdMNVZQWfxCblURLhf+47syQRBntjfLdd/H0egrzIG+oaFQ==", - "dev": true - }, "node_modules/qs": { "version": "6.11.0", "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", @@ -2978,21 +2415,6 @@ "node": ">= 0.8" } }, - "node_modules/rc": { - "version": "1.2.8", - "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz", - "integrity": "sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==", - "dev": true, - "dependencies": { - "deep-extend": "^0.6.0", - "ini": "~1.3.0", - "minimist": "^1.2.0", - "strip-json-comments": "~2.0.1" - }, - "bin": { - "rc": "cli.js" - } - }, "node_modules/react-is": { "version": "18.2.0", "resolved": "https://registry.npmjs.org/react-is/-/react-is-18.2.0.tgz", @@ -3011,37 +2433,6 @@ "node": ">=8.10.0" } }, - "node_modules/registry-auth-token": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/registry-auth-token/-/registry-auth-token-3.3.2.tgz", - "integrity": "sha512-JL39c60XlzCVgNrO+qq68FoNb56w/m7JYvGR2jT5iR1xBrUA3Mfx5Twk5rqTThPmQKMWydGmq8oFtDlxfrmxnQ==", - "dev": true, - "dependencies": { - "rc": "^1.1.6", - "safe-buffer": "^5.0.1" - } - }, - "node_modules/registry-url": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/registry-url/-/registry-url-3.1.0.tgz", - "integrity": "sha512-ZbgR5aZEdf4UKZVBPYIgaglBmSF2Hi94s2PcIHhRGFjKYu+chjJdYfHn4rt3hB6eCKLJ8giVIIfgMa1ehDfZKA==", - "dev": true, - "dependencies": { - "rc": "^1.0.1" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/require-from-string": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", - "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/resolve-from": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", @@ -3240,101 +2631,6 @@ "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", "dev": true }, - "node_modules/serve": { - "version": "14.2.1", - "resolved": "https://registry.npmjs.org/serve/-/serve-14.2.1.tgz", - "integrity": "sha512-48er5fzHh7GCShLnNyPBRPEjs2I6QBozeGr02gaacROiyS/8ARADlj595j39iZXAqBbJHH/ivJJyPRWY9sQWZA==", - "dev": true, - "dependencies": { - "@zeit/schemas": "2.29.0", - "ajv": "8.11.0", - "arg": "5.0.2", - "boxen": "7.0.0", - "chalk": "5.0.1", - "chalk-template": "0.4.0", - "clipboardy": "3.0.0", - "compression": "1.7.4", - "is-port-reachable": "4.0.0", - "serve-handler": "6.1.5", - "update-check": "1.5.4" - }, - "bin": { - "serve": "build/main.js" - }, - "engines": { - "node": ">= 14" - } - }, - "node_modules/serve-handler": { - "version": "6.1.5", - "resolved": "https://registry.npmjs.org/serve-handler/-/serve-handler-6.1.5.tgz", - "integrity": "sha512-ijPFle6Hwe8zfmBxJdE+5fta53fdIY0lHISJvuikXB3VYFafRjMRpOffSPvCYsbKyBA7pvy9oYr/BT1O3EArlg==", - "dev": true, - "dependencies": { - "bytes": "3.0.0", - "content-disposition": "0.5.2", - "fast-url-parser": "1.1.3", - "mime-types": "2.1.18", - "minimatch": "3.1.2", - "path-is-inside": "1.0.2", - "path-to-regexp": "2.2.1", - "range-parser": "1.2.0" - } - }, - "node_modules/serve-handler/node_modules/bytes": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz", - "integrity": "sha512-pMhOfFDPiv9t5jjIXkHosWmkSyQbvsgEVNkz0ERHbuLh2T/7j4Mqqpz523Fe8MVY89KC6Sh/QfS2sM+SjgFDcw==", - "dev": true, - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/serve-handler/node_modules/content-disposition": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.2.tgz", - "integrity": "sha512-kRGRZw3bLlFISDBgwTSA1TMBFN6J6GWDeubmDE3AF+3+yXL8hTWv8r5rkLbqYXY4RjPk/EzHnClI3zQf1cFmHA==", - "dev": true, - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/serve-handler/node_modules/mime-db": { - "version": "1.33.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.33.0.tgz", - "integrity": "sha512-BHJ/EKruNIqJf/QahvxwQZXKygOQ256myeN/Ew+THcAa5q+PjyTTMMeNQC4DZw5AwfvelsUrA6B67NKMqXDbzQ==", - "dev": true, - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/serve-handler/node_modules/mime-types": { - "version": "2.1.18", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.18.tgz", - "integrity": "sha512-lc/aahn+t4/SWV/qcmumYjymLsWfN3ELhpmVuUFjgsORruuZPVSwAQryq+HHGvO/SI2KVX26bx+En+zhM8g8hQ==", - "dev": true, - "dependencies": { - "mime-db": "~1.33.0" - }, - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/serve-handler/node_modules/path-to-regexp": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-2.2.1.tgz", - "integrity": "sha512-gu9bD6Ta5bwGrrU8muHzVOBFFREpp2iRkVfhBJahwJ6p6Xw20SjT0MxLnwkjOibQmGSYhiUnf2FLe7k+jcFmGQ==", - "dev": true - }, - "node_modules/serve-handler/node_modules/range-parser": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.0.tgz", - "integrity": "sha512-kA5WQoNVo4t9lNx2kQNFCxKeBl5IbbSNBl1M/tLkw9WCn+hxNBAW5Qh8gdhs63CJnhjJ2zQWFoqPJP2sK1AV5A==", - "dev": true, - "engines": { - "node": ">= 0.6" - } - }, "node_modules/serve-static": { "version": "1.15.0", "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.15.0.tgz", @@ -3373,27 +2669,6 @@ "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==", "dev": true }, - "node_modules/shebang-command": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", - "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", - "dev": true, - "dependencies": { - "shebang-regex": "^3.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/shebang-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", - "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", - "dev": true, - "engines": { - "node": ">=8" - } - }, "node_modules/side-channel": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.5.tgz", @@ -3418,12 +2693,6 @@ "integrity": "sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==", "dev": true }, - "node_modules/signal-exit": { - "version": "3.0.7", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", - "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", - "dev": true - }, "node_modules/sorcery": { "version": "0.11.0", "resolved": "https://registry.npmjs.org/sorcery/-/sorcery-0.11.0.tgz", @@ -3469,47 +2738,6 @@ "integrity": "sha512-JPbdCEQLj1w5GilpiHAx3qJvFndqybBysA3qUOnznweH4QbNYUsW/ea8QzSrnh0vNsezMMw5bcVool8lM0gwzg==", "dev": true }, - "node_modules/string-width": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz", - "integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==", - "dev": true, - "dependencies": { - "eastasianwidth": "^0.2.0", - "emoji-regex": "^9.2.2", - "strip-ansi": "^7.0.1" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/strip-ansi": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", - "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", - "dev": true, - "dependencies": { - "ansi-regex": "^6.0.1" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/strip-ansi?sponsor=1" - } - }, - "node_modules/strip-final-newline": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-2.0.0.tgz", - "integrity": "sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==", - "dev": true, - "engines": { - "node": ">=6" - } - }, "node_modules/strip-indent": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/strip-indent/-/strip-indent-3.0.0.tgz", @@ -3522,15 +2750,6 @@ "node": ">=8" } }, - "node_modules/strip-json-comments": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", - "integrity": "sha512-4gB8na07fecVVkOI6Rs4e7T6NOTki5EmL7TUduTs6bu3EdnSycntVJ4re8kgZA+wx9IueI2Y11bfbgwtzuE0KQ==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/strip-literal": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/strip-literal/-/strip-literal-1.3.0.tgz", @@ -3543,18 +2762,6 @@ "url": "https://github.com/sponsors/antfu" } }, - "node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/svelte": { "version": "4.2.11", "resolved": "https://registry.npmjs.org/svelte/-/svelte-4.2.11.tgz", @@ -3737,18 +2944,6 @@ "node": ">=4" } }, - "node_modules/type-fest": { - "version": "2.19.0", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-2.19.0.tgz", - "integrity": "sha512-RAH822pAdBgcNMAfWnCBU3CFZcfZ/i1eZjwFU/dsLKumyuuP3niueg2UAukXYF0E2AAoc82ZSSf9J0WQBinzHA==", - "dev": true, - "engines": { - "node": ">=12.20" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/type-is": { "version": "1.6.18", "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", @@ -3796,34 +2991,6 @@ "node": ">= 0.8" } }, - "node_modules/update-check": { - "version": "1.5.4", - "resolved": "https://registry.npmjs.org/update-check/-/update-check-1.5.4.tgz", - "integrity": "sha512-5YHsflzHP4t1G+8WGPlvKbJEbAJGCgw+Em+dGR1KmBUbr1J36SJBqlHLjR7oob7sco5hWHGQVcr9B2poIVDDTQ==", - "dev": true, - "dependencies": { - "registry-auth-token": "3.3.2", - "registry-url": "3.1.0" - } - }, - "node_modules/uri-js": { - "version": "4.4.1", - "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", - "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", - "dev": true, - "dependencies": { - "punycode": "^2.1.0" - } - }, - "node_modules/uri-js/node_modules/punycode": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", - "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", - "dev": true, - "engines": { - "node": ">=6" - } - }, "node_modules/utils-merge": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", @@ -4011,21 +3178,6 @@ } } }, - "node_modules/which": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", - "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", - "dev": true, - "dependencies": { - "isexe": "^2.0.0" - }, - "bin": { - "node-which": "bin/node-which" - }, - "engines": { - "node": ">= 8" - } - }, "node_modules/why-is-node-running": { "version": "2.2.2", "resolved": "https://registry.npmjs.org/why-is-node-running/-/why-is-node-running-2.2.2.tgz", @@ -4042,50 +3194,6 @@ "node": ">=8" } }, - "node_modules/widest-line": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/widest-line/-/widest-line-4.0.1.tgz", - "integrity": "sha512-o0cyEG0e8GPzT4iGHphIOh0cJOV8fivsXxddQasHPHfoZf1ZexrfeA21w2NaEN1RHE+fXlfISmOE8R9N3u3Qig==", - "dev": true, - "dependencies": { - "string-width": "^5.0.1" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/wrap-ansi": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz", - "integrity": "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==", - "dev": true, - "dependencies": { - "ansi-styles": "^6.1.0", - "string-width": "^5.0.1", - "strip-ansi": "^7.0.1" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/wrap-ansi?sponsor=1" - } - }, - "node_modules/wrap-ansi/node_modules/ansi-styles": { - "version": "6.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.1.tgz", - "integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==", - "dev": true, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, "node_modules/wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", diff --git a/src/Altcha.svelte b/src/Altcha.svelte index c2ab102..3e9c706 100644 --- a/src/Altcha.svelte +++ b/src/Altcha.svelte @@ -25,18 +25,21 @@ const dispatch = createEventDispatcher(); const allowedAlgs = ['SHA-256', 'SHA-384', 'SHA-512']; const website = 'https://altcha.org/'; + const workers = []; let checked: boolean = false; let el: HTMLElement; let elForm: HTMLFormElement | null = null; - let error: any = null; + let error: string | null = null; let payload: string | null = null; let state: State = State.UNVERIFIED; + let expiry: ReturnType; $: parsedChallenge = challengejson ? parseJsonAttribute(challengejson) : undefined; $: parsedStrings = strings ? parseJsonAttribute(strings) : {}; $: _strings = { error: 'Verification failed. Try again later.', + expired: 'Verification expired. Try again.', footer: `Protected by ALTCHA`, label: 'I\'m not a robot', verified: 'Verified', @@ -148,10 +151,23 @@ if (resp.status !== 200) { throw new Error(`Server responded with ${resp.status}.`); } + const expHeader = resp.headers.get('Expires'); + if(expHeader.length) { + const diff = Date.parse(expHeader) - Date.now(); + if(diff < 1) { + expire() + } else { + expiry = setTimeout(expire, diff); + } + } return resp.json(); } } + function expire() { + reset(State.EXPIRED, _strings.expired) + } + async function run(data: Challenge): Promise<{ data: Challenge, solution: Solution | null }> { let solution: Solution | null = null; if ('Worker' in window) { @@ -174,12 +190,12 @@ } async function runWorker(challenge: string, salt: string, alg?: string): Promise { - const worker = new InlineWorker(); + const totalWorkers = workers.push(new InlineWorker()); return new Promise((resolve) => { - worker.addEventListener('message', (message: MessageEvent) => { + workers[totalWorkers - 1].addEventListener('message', (message: MessageEvent) => { resolve(message.data); }); - worker.postMessage({ + workers[totalWorkers - 1].postMessage({ alg, challenge, max: maxnumber, @@ -189,7 +205,7 @@ } function onCheckedChange() { - if ([State.UNVERIFIED, State.ERROR].includes(state)) { + if ([State.UNVERIFIED, State.ERROR, State.EXPIRED].includes(state)) { verify(); } else { checked = true; @@ -239,9 +255,10 @@ } } - export function reset(newState: State = State.UNVERIFIED) { + export function reset(newState: State = State.UNVERIFIED, err: string | null = null) { + clearTimeout(expiry); checked = false; - error = null; + error = err; payload = null; state = newState; } @@ -273,7 +290,7 @@ log(err); state = State.ERROR; checked = false; - error = err; + error = err.message; }); } @@ -338,7 +355,7 @@ -
{@html _strings.error}
+
{@html error}
{/if} diff --git a/src/types.ts b/src/types.ts index fdc2e9e..393b08a 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,5 +1,6 @@ export interface Strings { error: string; + expired: string; footer: string; label: string; verified: string; @@ -48,4 +49,5 @@ export enum State { VERIFIED = 'verified', VERIFYING = 'verifying', UNVERIFIED = 'unverified', + EXPIRED = 'expired', };