@cap.js/widget 0.1.23 → 0.1.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- (()=>{const t=(e,o,n,i)=>{o.onclick=null;const s=parseInt(o.getAttribute("data-cap-floating-offset"))||8,a=o.getAttribute("data-cap-floating-position")||"top",l=o.getBoundingClientRect();Object.assign(n.style,{display:"block",position:"absolute",zIndex:"99999"});const c=l.left+(l.width-n.offsetWidth)/2,r=Math.min(c,window.innerWidth-n.offsetWidth);n.style.top="top"===a?`${Math.max(window.scrollY,l.top-n.offsetHeight-s+window.scrollY)}px`:`${Math.min(l.bottom+s+window.scrollY,window.innerHeight-n.offsetHeight+window.scrollY)}px`,n.style.left=`${Math.max(r,2)}px`,n.solve(),n.addEventListener("solve",({detail:s})=>{o.setAttribute("data-cap-token",s.token),o.setAttribute("data-cap-progress","done"),setTimeout(()=>{i.forEach(t=>{o.addEventListener("click",t),t.call(o,e)}),setTimeout(()=>{o.onclick=null,i.forEach(t=>o.removeEventListener("click",t)),o.onclick=e=>t(e,o,n,i)},50)},500),setTimeout(()=>{n.style.display="none"},700)})},e=e=>{const o=e.getAttribute("data-cap-floating");if(!o)return;const n=document.querySelector(o);if(!document.contains(n)&&!n.solve)throw new Error(`[cap floating] "${o}" doesn't exist or isn't a Cap widget`);n.style.display="none";const i=[e.onclick].filter(Boolean);"function"==typeof getEventListeners&&i.push(...(getEventListeners(e).click||[]).map(t=>t.listener)),i.length&&(e.onclick=null,i.forEach(t=>e.removeEventListener("click",t))),e.addEventListener("click",o=>{o.stopImmediatePropagation(),o.preventDefault(),t(o,e,n,i)})},o=t=>{e(t),t.querySelectorAll("[data-cap-floating]").forEach(e)};o(document.body),new MutationObserver(t=>t.forEach(t=>t.addedNodes.forEach(t=>{t.nodeType===Node.ELEMENT_NODE&&o(t)}))).observe(document.body,{childList:!0,subtree:!0})})();
1
+ (()=>{const t=(e,o,n,i)=>{o.onclick=null;const s=parseInt(o.getAttribute("data-cap-floating-offset"))||8,a=o.getAttribute("data-cap-floating-position")||"top",l=o.getBoundingClientRect();Object.assign(n.style,{display:"block",position:"absolute",zIndex:"99999",opacity:"0",transform:"scale(0.98)",marginTop:"-4px",boxShadow:"rgba(0, 0, 0, 0.05) 0px 6px 24px 0px",borderRadius:"14px",transition:"opacity 0.15s, margin-top 0.2s, transform 0.2s"}),setTimeout(()=>{n.style.transform="scale(1)",n.style.opacity="1",n.style.marginTop="0"},5);const r=l.left+(l.width-n.offsetWidth)/2,c=Math.min(r,window.innerWidth-n.offsetWidth);n.style.top="top"===a?`${Math.max(window.scrollY,l.top-n.offsetHeight-s+window.scrollY)}px`:`${Math.min(l.bottom+s+window.scrollY,window.innerHeight-n.offsetHeight+window.scrollY)}px`,n.style.left=`${Math.max(c,2)}px`,n.solve(),n.addEventListener("solve",({detail:s})=>{o.setAttribute("data-cap-token",s.token),o.setAttribute("data-cap-progress","done"),setTimeout(()=>{i.forEach(t=>{o.addEventListener("click",t),t.call(o,e)}),setTimeout(()=>{o.onclick=null,i.forEach(t=>o.removeEventListener("click",t)),o.onclick=e=>t(e,o,n,i)},50)},500),setTimeout(()=>{n.style.transform="scale(0.98)",n.style.opacity="0",n.style.marginTop="-4px"},500),setTimeout(()=>{n.style.display="none"},700)})},e=e=>{const o=e.getAttribute("data-cap-floating");if(!o)return;const n=document.querySelector(o);if(!document.contains(n)&&!n.solve)throw new Error(`[cap floating] "${o}" doesn't exist or isn't a Cap widget`);n.style.display="none";const i=[e.onclick].filter(Boolean);"function"==typeof getEventListeners&&i.push(...(getEventListeners(e).click||[]).map(t=>t.listener)),i.length&&(e.onclick=null,i.forEach(t=>e.removeEventListener("click",t))),e.addEventListener("click",o=>{o.stopImmediatePropagation(),o.preventDefault(),t(o,e,n,i)})},o=t=>{e(t),t.querySelectorAll("[data-cap-floating]").forEach(e)};o(document.body),new MutationObserver(t=>t.forEach(t=>t.addedNodes.forEach(t=>{t.nodeType===Node.ELEMENT_NODE&&o(t)}))).observe(document.body,{childList:!0,subtree:!0})})();
package/cap.min.js CHANGED
@@ -1 +1 @@
1
- !function(){const e="0.0.6",t=function(){return window?.CAP_CUSTOM_FETCH?window.CAP_CUSTOM_FETCH(...arguments):fetch(...arguments)};window.CAP_CUSTOM_WASM_URL||[`https://cdn.jsdelivr.net/npm/@cap.js/wasm@${e}/browser/cap_wasm.min.js`,`https://cdn.jsdelivr.net/npm/@cap.js/wasm@${e}/browser/cap_wasm_bg.wasm`].forEach(e=>{const t=document.createElement("link");t.rel="prefetch",t.href=e,t.as=e.endsWith(".wasm")?"fetch":"script",document.head.appendChild(t)});class r extends HTMLElement{#e="";#t=null;#r=navigator.hardwareConcurrency||8;token=null;#s;#i;#a;#n=!1;#o;getI18nText(e,t){return this.getAttribute(`data-cap-i18n-${e}`)||t}static get observedAttributes(){return["onsolve","onprogress","onreset","onerror","data-cap-worker-count","data-cap-i18n-initial-state","[cap]"]}constructor(){super(),this.#o&&this.#o.forEach((e,t)=>{this.removeEventListener(t.slice(2),e)}),this.#o=new Map,this.boundHandleProgress=this.handleProgress.bind(this),this.boundHandleSolve=this.handleSolve.bind(this),this.boundHandleError=this.handleError.bind(this),this.boundHandleReset=this.handleReset.bind(this)}initialize(){this.#e=URL.createObjectURL(new Blob(['(()=>{if("object"!=typeof WebAssembly||"function"!=typeof WebAssembly?.instantiate)return self.onmessage=async({data:{salt:e,target:r}})=>{let o=0;let t=0;const s=new TextEncoder,n=new Uint8Array(r.length/2);for(let e=0;e<n.length;e++)n[e]=parseInt(r.substring(2*e,2*e+2),16);const a=n.length;for(;;)try{for(let r=0;r<5e4;r++){const r=e+o,t=s.encode(r),l=await crypto.subtle.digest("SHA-256",t),c=new Uint8Array(l,0,a);let f=!0;for(let e=0;e<a;e++)if(c[e]!==n[e]){f=!1;break}if(f)return void self.postMessage({nonce:o,found:!0});o++}t+=5e4}catch(e){return console.error("[cap worker] fallback worker error",e),void self.postMessage({found:!1,error:e.message})}},console.warn("[cap worker] wasm not supported, falling back to alternative solver. this will be significantly slower.");let e,r;self.onmessage=async({data:{salt:o,target:t,wasmUrl:s}})=>{e!==s&&(e=s,await import(s).then(e=>e.default().then(o=>{r=(o&&o.exports?o.exports:e).solve_pow})).catch(e=>{console.error("[cap worker] using fallback solver due to error:",e)}));try{const e=performance.now(),s=r(o,t),n=performance.now();self.postMessage({nonce:Number(s),found:!0,durationMs:(n-e).toFixed(2)})}catch(e){console.error("[cap worker]",e),self.postMessage({found:!1,error:e.message||String(e)})}},self.onerror=e=>{self.postMessage({found:!1,error:e})}})();'],{type:"application/javascript"}))}attributeChangedCallback(e,t,r){if(e.startsWith("on")){const t=e.slice(2),s=this.#o.get(e);if(s&&this.removeEventListener(t,s),r){const r=t=>{const r=this.getAttribute(e);"function"==typeof window[r]&&window[r].call(this,t)};this.#o.set(e,r),this.addEventListener(t,r)}}"data-cap-worker-count"===e&&this.setWorkersCount(parseInt(r)),"data-cap-i18n-initial-state"===e&&this.#i&&this.#i?.querySelector("p")?.innerText&&(this.#i.querySelector("p").innerText=this.getI18nText("initial-state","I'm a human"))}async connectedCallback(){this.#a=this,this.#s=this.attachShadow({mode:"open"}),this.#i=document.createElement("div"),this.createUI(),this.addEventListeners(),await this.initialize(),this.#i.removeAttribute("disabled");const e=this.getAttribute("data-cap-worker-count"),t=e?parseInt(e,10):null;this.setWorkersCount(t||navigator.hardwareConcurrency||8);const r=this.getAttribute("data-cap-hidden-field-name")||"cap-token";this.#a.innerHTML=`<input type="hidden" name="${r}">`}async solve(){if(!this.#n)try{this.#n=!0,this.updateUI("verifying",this.getI18nText("verifying-label","Verifying..."),!0),this.#i.setAttribute("aria-label",this.getI18nText("verifying-aria-label","Verifying you're a human, please wait")),this.dispatchEvent("progress",{progress:0});try{const e=this.getAttribute("data-cap-api-endpoint");if(!e)throw new Error("Missing API endpoint");const{challenge:r,token:s}=await(await t(`${e}challenge`,{method:"POST"})).json(),i=await this.solveChallenges(r),a=await(await t(`${e}redeem`,{method:"POST",body:JSON.stringify({token:s,solutions:i}),headers:{"Content-Type":"application/json"}})).json();if(this.dispatchEvent("progress",{progress:100}),!a.success)throw new Error("Invalid solution");const n=this.getAttribute("data-cap-hidden-field-name")||"cap-token";this.querySelector(`input[name='${n}']`)&&(this.querySelector(`input[name='${n}']`).value=a.token),this.dispatchEvent("solve",{token:a.token}),this.token=a.token,this.#t&&clearTimeout(this.#t);const o=new Date(a.expires).getTime()-Date.now();return o>0&&o<864e5?this.#t=setTimeout(()=>this.reset(),o):this.error("Invalid expiration time"),this.#i.setAttribute("aria-label",this.getI18nText("verified-aria-label","We have verified you're a human, you may now continue")),{success:!0,token:this.token}}catch(e){throw this.#i.setAttribute("aria-label",this.getI18nText("error-aria-label","An error occurred, please try again")),this.error(e.message),e}}finally{this.#n=!1}}async solveChallenges(t){const r=t.length;let s=0;const i=Array(this.#r).fill(null).map(()=>{try{return new Worker(this.#e)}catch(e){throw console.error("[cap] Failed to create worker:",e),new Error("Worker creation failed")}}),a=([t,a],n)=>new Promise((o,c)=>{const d=i[n];if(!d)return void c(new Error("Worker not available"));const l=setTimeout(()=>{try{d.terminate(),i[n]=new Worker(this.#e)}catch(e){console.error("[cap] error terminating/recreating worker:",e)}c(new Error("Worker timeout"))},3e4);d.onmessage=({data:e})=>{e.found&&(clearTimeout(l),s++,this.dispatchEvent("progress",{progress:Math.round(s/r*100)}),o([t,a,e.nonce]))},d.onerror=e=>{clearTimeout(l),this.error(`Error in worker: ${e.message||e}`),c(e)},d.postMessage({salt:t,target:a,wasmUrl:window.CAP_CUSTOM_WASM_URL||`https://cdn.jsdelivr.net/npm/@cap.js/wasm@${e}/browser/cap_wasm.min.js`})}),n=[];try{for(let e=0;e<t.length;e+=this.#r){const r=t.slice(e,Math.min(e+this.#r,t.length)),s=await Promise.all(r.map((e,t)=>a(e,t)));n.push(...s)}}finally{i.forEach(e=>{if(e)try{e.terminate()}catch(e){console.error("[cap] error terminating worker:",e)}})}return n}setWorkersCount(e){const t=parseInt(e,10),r=Math.min(navigator.hardwareConcurrency||8,16);this.#r=!isNaN(t)&&t>0&&t<=r?t:navigator.hardwareConcurrency||8}createUI(){this.#i.classList.add("captcha"),this.#i.setAttribute("role","button"),this.#i.setAttribute("tabindex","0"),this.#i.setAttribute("aria-label",this.getI18nText("verify-aria-label","Click to verify you're a human")),this.#i.setAttribute("aria-live","polite"),this.#i.setAttribute("disabled","true"),this.#i.innerHTML=`<div class="checkbox" part="checkbox"></div><p part="label">${this.getI18nText("initial-state","I'm a human")}</p><a part="attribution" aria-label="Secured by Cap" href="https://capjs.js.org/" class="credits" target="_blank" rel="follow noopener"><span>Secured by&nbsp;</span>Cap</a>`,this.#s.innerHTML='<style>.captcha,.captcha * {box-sizing:border-box;}.captcha{background-color:var(--cap-background,#fdfdfd);border:1px solid var(--cap-border-color,#dddddd8f);border-radius:var(--cap-border-radius,14px);\nuser-select:none;height:var(--cap-widget-height, 30px);width:var(--cap-widget-width, 230px);display:flex;align-items:center;padding:var(--cap-widget-padding,14px);gap:var(--cap-gap,15px);cursor:pointer;transition:filter .2s,transform .2s;position:relative;-webkit-tap-highlight-color:rgba(255,255,255,0);overflow:hidden;color:var(--cap-color,#212121)}.captcha:hover{filter:brightness(98%)}.checkbox{width:var(--cap-checkbox-size,25px);height:var(--cap-checkbox-size,25px);border:var(--cap-checkbox-border,1px solid #aaaaaad1);border-radius:var(--cap-checkbox-border-radius,6px);background-color:var(--cap-checkbox-background,#fafafa91);transition:opacity .2s;margin-top:var(--cap-checkbox-margin,2px);margin-bottom:var(--cap-checkbox-margin,2px)}.captcha *{font-family:var(--cap-font,system,-apple-system,"BlinkMacSystemFont",".SFNSText-Regular","San Francisco","Roboto","Segoe UI","Helvetica Neue","Lucida Grande","Ubuntu","arial",sans-serif)}.captcha p{margin:0;font-weight:500;font-size:15px;user-select:none;transition:opacity .2s}.captcha[data-state=verifying]\n.checkbox{background: none;display:flex;align-items:center;justify-content:center;transform: scale(1.1);border: none;border-radius: 50%;background: conic-gradient(var(--cap-spinner-color,#000) 0%, var(--cap-spinner-color,#000) var(--progress, 0%), var(--cap-spinner-background-color,#eee) var(--progress, 0%), var(--cap-spinner-background-color,#eee) 100%);position: relative;}.captcha[data-state=verifying] .checkbox::after {content: "";background-color: var(--cap-background,#fdfdfd);width: calc(100% - var(--cap-spinner-thickness,5px));height: calc(100% - var(--cap-spinner-thickness,5px));border-radius: 50%;margin:calc(var(--cap-spinner-thickness,5px) / 2)}.captcha[data-state=done] .checkbox{border:1px solid transparent;background-image:var(--cap-checkmark,url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2224%22%20height%3D%2224%22%20viewBox%3D%220%200%2024%2024%22%3E%3Cstyle%3E%40keyframes%20anim%7B0%25%7Bstroke-dashoffset%3A23.21320343017578px%7Dto%7Bstroke-dashoffset%3A0%7D%7D%3C%2Fstyle%3E%3Cpath%20fill%3D%22none%22%20stroke%3D%22%2300a67d%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%20stroke-width%3D%222%22%20d%3D%22m5%2012%205%205L20%207%22%20style%3D%22stroke-dashoffset%3A0%3Bstroke-dasharray%3A23.21320343017578px%3Banimation%3Aanim%20.5s%20ease%22%2F%3E%3C%2Fsvg%3E"));background-size:cover}.captcha[data-state=error] .checkbox{border:1px solid transparent;background-image:var(--cap-error-cross,url("data:image/svg+xml,%3Csvg xmlns=\'http://www.w3.org/2000/svg\' width=\'96\' height=\'96\' viewBox=\'0 0 24 24\'%3E%3Cpath fill=\'%23f55b50\' d=\'M11 15h2v2h-2zm0-8h2v6h-2zm1-5C6.47 2 2 6.5 2 12a10 10 0 0 0 10 10a10 10 0 0 0 10-10A10 10 0 0 0 12 2m0 18a8 8 0 0 1-8-8a8 8 0 0 1 8-8a8 8 0 0 1 8 8a8 8 0 0 1-8 8\'/%3E%3C/svg%3E"));background-size:cover}.captcha[disabled]{cursor:not-allowed}.captcha[disabled][data-state=verifying]{cursor:progress}.captcha[disabled][data-state=done]{cursor:default}.captcha .credits{position:absolute;bottom:10px;right:10px;font-size:var(--cap-credits-font-size,12px);color:var(--cap-color,#212121);opacity:var(--cap-opacity-hover,0.8)}.captcha .credits span{display:none;text-decoration:underline}.captcha .credits:hover span{display:inline-block}</style>',this.#s.appendChild(this.#i)}addEventListeners(){this.#i&&(this.#i.querySelector("a").addEventListener("click",e=>{e.stopPropagation(),e.preventDefault(),window.open("https://capjs.js.org","_blank")}),this.#i.addEventListener("click",()=>{this.#i.hasAttribute("disabled")||this.solve()}),this.#i.addEventListener("keydown",e=>{"Enter"!==e.key&&" "!==e.key||this.#i.hasAttribute("disabled")||(e.preventDefault(),e.stopPropagation(),this.solve())}),this.addEventListener("progress",this.boundHandleProgress),this.addEventListener("solve",this.boundHandleSolve),this.addEventListener("error",this.boundHandleError),this.addEventListener("reset",this.boundHandleReset))}updateUI(e,t,r=!1){this.#i&&(this.#i.setAttribute("data-state",e),this.#i.querySelector("p").innerText=t,r?this.#i.setAttribute("disabled","true"):this.#i.removeAttribute("disabled"))}handleProgress(e){if(!this.#i)return;const t=this.#i.querySelector("p"),r=this.#i.querySelector(".checkbox");t&&r&&(r.style.setProperty("--progress",`${e.detail.progress}%`),t.innerText=`${this.getI18nText("verifying-label","Verifying...")} ${e.detail.progress}%`),this.executeAttributeCode("onprogress",e)}handleSolve(e){this.updateUI("done",this.getI18nText("solved-label","You're a human"),!0),this.executeAttributeCode("onsolve",e)}handleError(e){this.updateUI("error",this.getI18nText("error-label","Error. Try again.")),this.executeAttributeCode("onerror",e)}handleReset(e){this.updateUI("",this.getI18nText("initial-state","I'm a human")),this.executeAttributeCode("onreset",e)}executeAttributeCode(e,t){const r=this.getAttribute(e);r&&new Function("event",r).call(this,t)}error(e="Unknown error"){console.error("[cap]",e),this.dispatchEvent("error",{isCap:!0,message:e})}dispatchEvent(e,t={}){const r=new CustomEvent(e,{bubbles:!0,composed:!0,detail:t});super.dispatchEvent(r)}reset(){this.#t&&(clearTimeout(this.#t),this.#t=null),this.dispatchEvent("reset"),this.token=null;const e=this.getAttribute("data-cap-hidden-field-name")||"cap-token";this.querySelector(`input[name='${e}']`)&&(this.querySelector(`input[name='${e}']`).value="")}get tokenValue(){return this.token}disconnectedCallback(){this.removeEventListener("progress",this.boundHandleProgress),this.removeEventListener("solve",this.boundHandleSolve),this.removeEventListener("error",this.boundHandleError),this.removeEventListener("reset",this.boundHandleReset),this.#o.forEach((e,t)=>{this.removeEventListener(t.slice(2),e)}),this.#o.clear(),this.#s&&(this.#s.innerHTML=""),this.reset(),this.cleanup()}cleanup(){this.#t&&(clearTimeout(this.#t),this.#t=null),this.#e&&(URL.revokeObjectURL(this.#e),this.#e="")}}class s{constructor(e={},t){let r=t||document.createElement("cap-widget");if(Object.entries(e).forEach(([e,t])=>{r.setAttribute(e,t)}),!e.apiEndpoint)throw r.remove(),new Error("Missing API endpoint");r.setAttribute("data-cap-api-endpoint",e.apiEndpoint),this.widget=r,this.solve=this.widget.solve.bind(this.widget),this.reset=this.widget.reset.bind(this.widget),this.addEventListener=this.widget.addEventListener.bind(this.widget),Object.defineProperty(this,"token",{get:()=>r.token,configurable:!0,enumerable:!0}),t||(r.style.display="none",document.documentElement.appendChild(r))}}window.Cap=s,customElements.get("cap-widget")||window?.CAP_DONT_SKIP_REDEFINE?console.warn("[cap] the cap-widget element has already been defined, skipping re-defining it.\nto prevent this, set window.CAP_DONT_SKIP_REDEFINE to true"):customElements.define("cap-widget",r),"object"==typeof exports&&"undefined"!=typeof module?module.exports=s:"function"==typeof define&&define.amd&&define([],function(){return s}),"undefined"!=typeof exports&&(exports.default=s)}();
1
+ !function(){const e="0.0.6",t=function(){return window?.CAP_CUSTOM_FETCH?window.CAP_CUSTOM_FETCH(...arguments):fetch(...arguments)};window.CAP_CUSTOM_WASM_URL||[`https://cdn.jsdelivr.net/npm/@cap.js/wasm@${e}/browser/cap_wasm.min.js`,`https://cdn.jsdelivr.net/npm/@cap.js/wasm@${e}/browser/cap_wasm_bg.wasm`].forEach(e=>{const t=document.createElement("link");t.rel="prefetch",t.href=e,t.as=e.endsWith(".wasm")?"fetch":"script",document.head.appendChild(t)});class r extends HTMLElement{#e="";#t=null;#r=navigator.hardwareConcurrency||8;token=null;#s;#i;#a;#n=!1;#o;getI18nText(e,t){return this.getAttribute(`data-cap-i18n-${e}`)||t}static get observedAttributes(){return["onsolve","onprogress","onreset","onerror","data-cap-worker-count","data-cap-i18n-initial-state","[cap]"]}constructor(){super(),this.#o&&this.#o.forEach((e,t)=>{this.removeEventListener(t.slice(2),e)}),this.#o=new Map,this.boundHandleProgress=this.handleProgress.bind(this),this.boundHandleSolve=this.handleSolve.bind(this),this.boundHandleError=this.handleError.bind(this),this.boundHandleReset=this.handleReset.bind(this)}initialize(){this.#e=URL.createObjectURL(new Blob(['(()=>{if("object"!=typeof WebAssembly||"function"!=typeof WebAssembly?.instantiate)return self.onmessage=async({data:{salt:e,target:r}})=>{let o=0;let t=0;const s=new TextEncoder,n=new Uint8Array(r.length/2);for(let e=0;e<n.length;e++)n[e]=parseInt(r.substring(2*e,2*e+2),16);const a=n.length;for(;;)try{for(let r=0;r<5e4;r++){const r=e+o,t=s.encode(r),l=await crypto.subtle.digest("SHA-256",t),c=new Uint8Array(l,0,a);let f=!0;for(let e=0;e<a;e++)if(c[e]!==n[e]){f=!1;break}if(f)return void self.postMessage({nonce:o,found:!0});o++}t+=5e4}catch(e){return console.error("[cap worker]",e),void self.postMessage({found:!1,error:e.message})}},console.warn("[cap worker] wasm not supported, falling back to alternative solver. this will be significantly slower.");let e,r;self.onmessage=async({data:{salt:o,target:t,wasmUrl:s}})=>{e!==s&&(e=s,await import(s).then(e=>e.default().then(o=>{r=(o&&o.exports?o.exports:e).solve_pow})).catch(e=>{console.error("[cap worker] using fallback solver due to error:",e)}));try{const e=performance.now(),s=r(o,t),n=performance.now();self.postMessage({nonce:Number(s),found:!0,durationMs:(n-e).toFixed(2)})}catch(e){console.error("[cap worker]",e),self.postMessage({found:!1,error:e.message||String(e)})}},self.onerror=e=>{self.postMessage({found:!1,error:e})}})();'],{type:"application/javascript"}))}attributeChangedCallback(e,t,r){if(e.startsWith("on")){const t=e.slice(2),s=this.#o.get(e);if(s&&this.removeEventListener(t,s),r){const r=t=>{const r=this.getAttribute(e);"function"==typeof window[r]&&window[r].call(this,t)};this.#o.set(e,r),this.addEventListener(t,r)}}"data-cap-worker-count"===e&&this.setWorkersCount(parseInt(r)),"data-cap-i18n-initial-state"===e&&this.#i&&this.#i?.querySelector("p")?.innerText&&(this.#i.querySelector("p").innerText=this.getI18nText("initial-state","I'm a human"))}async connectedCallback(){this.#a=this,this.#s=this.attachShadow({mode:"open"}),this.#i=document.createElement("div"),this.createUI(),this.addEventListeners(),await this.initialize(),this.#i.removeAttribute("disabled");const e=this.getAttribute("data-cap-worker-count"),t=e?parseInt(e,10):null;this.setWorkersCount(t||navigator.hardwareConcurrency||8);const r=this.getAttribute("data-cap-hidden-field-name")||"cap-token";this.#a.innerHTML=`<input type="hidden" name="${r}">`}async solve(){if(!this.#n)try{this.#n=!0,this.updateUI("verifying",this.getI18nText("verifying-label","Verifying..."),!0),this.#i.setAttribute("aria-label",this.getI18nText("verifying-aria-label","Verifying you're a human, please wait")),this.dispatchEvent("progress",{progress:0});try{const e=this.getAttribute("data-cap-api-endpoint");if(!e)throw new Error("Missing API endpoint");const{challenge:r,token:s}=await(await t(`${e}challenge`,{method:"POST"})).json();let i=r;if(!Array.isArray(i)){function d(e,t){let r=function(e){let t=2166136261;for(let r=0;r<e.length;r++)t^=e.charCodeAt(r),t+=(t<<1)+(t<<4)+(t<<7)+(t<<8)+(t<<24);return t>>>0}(e),s="";function i(){return r^=r<<13,r^=r>>>17,r^=r<<5,r>>>0}for(;s.length<t;){s+=i().toString(16).padStart(8,"0")}return s.substring(0,t)}let l=0;i=Array.from({length:r.c},()=>(l+=1,[d(`${s}${l}`,r.s),d(`${s}${l}d`,r.d)]))}const a=await this.solveChallenges(i),n=await(await t(`${e}redeem`,{method:"POST",body:JSON.stringify({token:s,solutions:a}),headers:{"Content-Type":"application/json"}})).json();if(this.dispatchEvent("progress",{progress:100}),!n.success)throw new Error("Invalid solution");const o=this.getAttribute("data-cap-hidden-field-name")||"cap-token";this.querySelector(`input[name='${o}']`)&&(this.querySelector(`input[name='${o}']`).value=n.token),this.dispatchEvent("solve",{token:n.token}),this.token=n.token,this.#t&&clearTimeout(this.#t);const c=new Date(n.expires).getTime()-Date.now();return c>0&&c<864e5?this.#t=setTimeout(()=>this.reset(),c):this.error("Invalid expiration time"),this.#i.setAttribute("aria-label",this.getI18nText("verified-aria-label","We have verified you're a human, you may now continue")),{success:!0,token:this.token}}catch(h){throw this.#i.setAttribute("aria-label",this.getI18nText("error-aria-label","An error occurred, please try again")),this.error(h.message),h}}finally{this.#n=!1}}async solveChallenges(t){const r=t.length;let s=0;const i=Array(this.#r).fill(null).map(()=>{try{return new Worker(this.#e)}catch(e){throw console.error("[cap] Failed to create worker:",e),new Error("Worker creation failed")}}),a=([t,a],n)=>new Promise((o,c)=>{const d=i[n];if(!d)return void c(new Error("Worker not available"));const l=setTimeout(()=>{try{d.terminate(),i[n]=new Worker(this.#e)}catch(e){console.error("[cap] error terminating/recreating worker:",e)}c(new Error("Worker timeout"))},3e4);d.onmessage=({data:e})=>{e.found&&(clearTimeout(l),s++,this.dispatchEvent("progress",{progress:Math.round(s/r*100)}),o(e.nonce))},d.onerror=e=>{clearTimeout(l),this.error(`Error in worker: ${e.message||e}`),c(e)},d.postMessage({salt:t,target:a,wasmUrl:window.CAP_CUSTOM_WASM_URL||`https://cdn.jsdelivr.net/npm/@cap.js/wasm@${e}/browser/cap_wasm.min.js`})}),n=[];try{for(let e=0;e<t.length;e+=this.#r){const r=t.slice(e,Math.min(e+this.#r,t.length)),s=await Promise.all(r.map((e,t)=>a(e,t)));n.push(...s)}}finally{i.forEach(e=>{if(e)try{e.terminate()}catch(e){console.error("[cap] error terminating worker:",e)}})}return n}setWorkersCount(e){const t=parseInt(e,10),r=Math.min(navigator.hardwareConcurrency||8,16);this.#r=!isNaN(t)&&t>0&&t<=r?t:navigator.hardwareConcurrency||8}createUI(){this.#i.classList.add("captcha"),this.#i.setAttribute("role","button"),this.#i.setAttribute("tabindex","0"),this.#i.setAttribute("aria-label",this.getI18nText("verify-aria-label","Click to verify you're a human")),this.#i.setAttribute("aria-live","polite"),this.#i.setAttribute("disabled","true"),this.#i.innerHTML=`<div class="checkbox" part="checkbox"></div><p part="label">${this.getI18nText("initial-state","I'm a human")}</p><a part="attribution" aria-label="Secured by Cap" href="https://capjs.js.org/" class="credits" target="_blank" rel="follow noopener">Cap</a>`,this.#s.innerHTML='<style>.captcha,.captcha * {box-sizing:border-box;}.captcha{background-color:var(--cap-background,#fdfdfd);border:1px solid var(--cap-border-color,#dddddd8f);border-radius:var(--cap-border-radius,14px);user-select:none;height:var(--cap-widget-height, 58px);width:var(--cap-widget-width, 230px);display:flex;align-items:center;padding:var(--cap-widget-padding,14px);gap:var(--cap-gap,15px);cursor:pointer;transition:filter .2s,transform .2s;position:relative;-webkit-tap-highlight-color:rgba(255,255,255,0);overflow:hidden;color:var(--cap-color,#212121)}.captcha:hover{filter:brightness(98%)}.checkbox{width:var(--cap-checkbox-size,25px);height:var(--cap-checkbox-size,25px);border:var(--cap-checkbox-border,1px solid #aaaaaad1);border-radius:var(--cap-checkbox-border-radius,6px);background-color:var(--cap-checkbox-background,#fafafa91);transition:opacity .2s;margin-top:var(--cap-checkbox-margin,2px);margin-bottom:var(--cap-checkbox-margin,2px)}.captcha *{font-family:var(--cap-font,system,-apple-system,"BlinkMacSystemFont",".SFNSText-Regular","San Francisco","Roboto","Segoe UI","Helvetica Neue","Lucida Grande","Ubuntu","arial",sans-serif)}.captcha p{margin:0;font-weight:500;font-size:15px;user-select:none;transition:opacity .2s}.captcha[data-state=verifying]\n.checkbox{background: none;display:flex;align-items:center;justify-content:center;transform: scale(1.1);border: none;border-radius: 50%;background: conic-gradient(var(--cap-spinner-color,#000) 0%, var(--cap-spinner-color,#000) var(--progress, 0%), var(--cap-spinner-background-color,#eee) var(--progress, 0%), var(--cap-spinner-background-color,#eee) 100%);position: relative;}.captcha[data-state=verifying] .checkbox::after {content: "";background-color: var(--cap-background,#fdfdfd);width: calc(100% - var(--cap-spinner-thickness,5px));height: calc(100% - var(--cap-spinner-thickness,5px));border-radius: 50%;margin:calc(var(--cap-spinner-thickness,5px) / 2)}.captcha[data-state=done] .checkbox{border:1px solid transparent;background-image:var(--cap-checkmark,url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2224%22%20height%3D%2224%22%20viewBox%3D%220%200%2024%2024%22%3E%3Cstyle%3E%40keyframes%20anim%7B0%25%7Bstroke-dashoffset%3A23.21320343017578px%7Dto%7Bstroke-dashoffset%3A0%7D%7D%3C%2Fstyle%3E%3Cpath%20fill%3D%22none%22%20stroke%3D%22%2300a67d%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%20stroke-width%3D%222%22%20d%3D%22m5%2012%205%205L20%207%22%20style%3D%22stroke-dashoffset%3A0%3Bstroke-dasharray%3A23.21320343017578px%3Banimation%3Aanim%20.5s%20ease%22%2F%3E%3C%2Fsvg%3E"));background-size:cover}.captcha[data-state=error] .checkbox{border:1px solid transparent;background-image:var(--cap-error-cross,url("data:image/svg+xml,%3Csvg xmlns=\'http://www.w3.org/2000/svg\' width=\'96\' height=\'96\' viewBox=\'0 0 24 24\'%3E%3Cpath fill=\'%23f55b50\' d=\'M11 15h2v2h-2zm0-8h2v6h-2zm1-5C6.47 2 2 6.5 2 12a10 10 0 0 0 10 10a10 10 0 0 0 10-10A10 10 0 0 0 12 2m0 18a8 8 0 0 1-8-8a8 8 0 0 1 8-8a8 8 0 0 1 8 8a8 8 0 0 1-8 8\'/%3E%3C/svg%3E"));background-size:cover}.captcha[disabled]{cursor:not-allowed}.captcha[disabled][data-state=verifying]{cursor:progress}.captcha[disabled][data-state=done]{cursor:default}.captcha .credits{position:absolute;bottom:10px;right:10px;font-size:var(--cap-credits-font-size,12px);color:var(--cap-color,#212121);opacity:var(--cap-opacity-hover,0.8);text-underline-offset: 1.5px;}</style>',this.#s.appendChild(this.#i)}addEventListeners(){this.#i&&(this.#i.querySelector("a").addEventListener("click",e=>{e.stopPropagation(),e.preventDefault(),window.open("https://capjs.js.org","_blank")}),this.#i.addEventListener("click",()=>{this.#i.hasAttribute("disabled")||this.solve()}),this.#i.addEventListener("keydown",e=>{"Enter"!==e.key&&" "!==e.key||this.#i.hasAttribute("disabled")||(e.preventDefault(),e.stopPropagation(),this.solve())}),this.addEventListener("progress",this.boundHandleProgress),this.addEventListener("solve",this.boundHandleSolve),this.addEventListener("error",this.boundHandleError),this.addEventListener("reset",this.boundHandleReset))}updateUI(e,t,r=!1){this.#i&&(this.#i.setAttribute("data-state",e),this.#i.querySelector("p").innerText=t,r?this.#i.setAttribute("disabled","true"):this.#i.removeAttribute("disabled"))}handleProgress(e){if(!this.#i)return;const t=this.#i.querySelector("p"),r=this.#i.querySelector(".checkbox");t&&r&&(r.style.setProperty("--progress",`${e.detail.progress}%`),t.innerText=`${this.getI18nText("verifying-label","Verifying...")} ${e.detail.progress}%`),this.executeAttributeCode("onprogress",e)}handleSolve(e){this.updateUI("done",this.getI18nText("solved-label","You're a human"),!0),this.executeAttributeCode("onsolve",e)}handleError(e){this.updateUI("error",this.getI18nText("error-label","Error. Try again.")),this.executeAttributeCode("onerror",e)}handleReset(e){this.updateUI("",this.getI18nText("initial-state","I'm a human")),this.executeAttributeCode("onreset",e)}executeAttributeCode(e,t){const r=this.getAttribute(e);r&&new Function("event",r).call(this,t)}error(e="Unknown error"){console.error("[cap]",e),this.dispatchEvent("error",{isCap:!0,message:e})}dispatchEvent(e,t={}){const r=new CustomEvent(e,{bubbles:!0,composed:!0,detail:t});super.dispatchEvent(r)}reset(){this.#t&&(clearTimeout(this.#t),this.#t=null),this.dispatchEvent("reset"),this.token=null;const e=this.getAttribute("data-cap-hidden-field-name")||"cap-token";this.querySelector(`input[name='${e}']`)&&(this.querySelector(`input[name='${e}']`).value="")}get tokenValue(){return this.token}disconnectedCallback(){this.removeEventListener("progress",this.boundHandleProgress),this.removeEventListener("solve",this.boundHandleSolve),this.removeEventListener("error",this.boundHandleError),this.removeEventListener("reset",this.boundHandleReset),this.#o.forEach((e,t)=>{this.removeEventListener(t.slice(2),e)}),this.#o.clear(),this.#s&&(this.#s.innerHTML=""),this.reset(),this.cleanup()}cleanup(){this.#t&&(clearTimeout(this.#t),this.#t=null),this.#e&&(URL.revokeObjectURL(this.#e),this.#e="")}}class s{constructor(e={},t){let r=t||document.createElement("cap-widget");if(Object.entries(e).forEach(([e,t])=>{r.setAttribute(e,t)}),!e.apiEndpoint)throw r.remove(),new Error("Missing API endpoint");r.setAttribute("data-cap-api-endpoint",e.apiEndpoint),this.widget=r,this.solve=this.widget.solve.bind(this.widget),this.reset=this.widget.reset.bind(this.widget),this.addEventListener=this.widget.addEventListener.bind(this.widget),Object.defineProperty(this,"token",{get:()=>r.token,configurable:!0,enumerable:!0}),t||(r.style.display="none",document.documentElement.appendChild(r))}}window.Cap=s,customElements.get("cap-widget")||window?.CAP_DONT_SKIP_REDEFINE?console.warn("[cap] the cap-widget element has already been defined, skipping re-defining it.\nto prevent this, set window.CAP_DONT_SKIP_REDEFINE to true"):customElements.define("cap-widget",r),"object"==typeof exports&&"undefined"!=typeof module?module.exports=s:"function"==typeof define&&define.amd&&define([],function(){return s}),"undefined"!=typeof exports&&(exports.default=s)}();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cap.js/widget",
3
- "version": "0.1.23",
3
+ "version": "0.1.25",
4
4
  "description": "Client-side widget for Cap, a lightweight, modern open-source CAPTCHA alternative designed using SHA-256 PoW.",
5
5
  "keywords": [
6
6
  "security",
@@ -15,7 +15,8 @@
15
15
 
16
16
  element.onclick = null;
17
17
 
18
- const offset = parseInt(element.getAttribute("data-cap-floating-offset")) || 8;
18
+ const offset =
19
+ parseInt(element.getAttribute("data-cap-floating-offset")) || 8;
19
20
  const position =
20
21
  element.getAttribute("data-cap-floating-position") || "top";
21
22
  const rect = element.getBoundingClientRect();
@@ -23,9 +24,21 @@
23
24
  Object.assign(capWidget.style, {
24
25
  display: "block",
25
26
  position: "absolute",
26
- zIndex: "99999"
27
+ zIndex: "99999",
28
+ opacity: "0",
29
+ transform: "scale(0.98)",
30
+ marginTop: "-4px",
31
+ boxShadow: "rgba(0, 0, 0, 0.05) 0px 6px 24px 0px",
32
+ borderRadius: "14px",
33
+ transition: "opacity 0.15s, margin-top 0.2s, transform 0.2s",
27
34
  });
28
35
 
36
+ setTimeout(() => {
37
+ capWidget.style.transform = "scale(1)";
38
+ capWidget.style.opacity = "1";
39
+ capWidget.style.marginTop = "0";
40
+ }, 5);
41
+
29
42
  const centerX = rect.left + (rect.width - capWidget.offsetWidth) / 2;
30
43
  const safeX = Math.min(centerX, window.innerWidth - capWidget.offsetWidth);
31
44
 
@@ -51,6 +64,12 @@
51
64
  trigger();
52
65
  }, 500);
53
66
 
67
+ setTimeout(() => {
68
+ capWidget.style.transform = "scale(0.98)";
69
+ capWidget.style.opacity = "0";
70
+ capWidget.style.marginTop = "-4px";
71
+ }, 500);
72
+
54
73
  setTimeout(() => {
55
74
  capWidget.style.display = "none";
56
75
  }, 700);
@@ -63,7 +82,9 @@
63
82
 
64
83
  const capWidget = document.querySelector(capWidgetSelector);
65
84
  if (!document.contains(capWidget) && !capWidget.solve) {
66
- throw new Error(`[cap floating] "${capWidgetSelector}" doesn't exist or isn't a Cap widget`);
85
+ throw new Error(
86
+ `[cap floating] "${capWidgetSelector}" doesn't exist or isn't a Cap widget`
87
+ );
67
88
  }
68
89
 
69
90
  capWidget.style.display = "none";
package/src/cap.js CHANGED
@@ -143,7 +143,10 @@
143
143
 
144
144
  this.#div.setAttribute(
145
145
  "aria-label",
146
- this.getI18nText("verifying-aria-label", "Verifying you're a human, please wait")
146
+ this.getI18nText(
147
+ "verifying-aria-label",
148
+ "Verifying you're a human, please wait"
149
+ )
147
150
  );
148
151
 
149
152
  this.dispatchEvent("progress", { progress: 0 });
@@ -157,7 +160,56 @@
157
160
  method: "POST",
158
161
  })
159
162
  ).json();
160
- const solutions = await this.solveChallenges(challenge);
163
+
164
+ let challenges = challenge;
165
+
166
+ if (!Array.isArray(challenges)) {
167
+ function prng(seed, length) {
168
+ function fnv1a(str) {
169
+ let hash = 2166136261;
170
+ for (let i = 0; i < str.length; i++) {
171
+ hash ^= str.charCodeAt(i);
172
+ hash +=
173
+ (hash << 1) +
174
+ (hash << 4) +
175
+ (hash << 7) +
176
+ (hash << 8) +
177
+ (hash << 24);
178
+ }
179
+ return hash >>> 0;
180
+ }
181
+
182
+ let state = fnv1a(seed);
183
+ let result = "";
184
+
185
+ function next() {
186
+ state ^= state << 13;
187
+ state ^= state >>> 17;
188
+ state ^= state << 5;
189
+ return state >>> 0;
190
+ }
191
+
192
+ while (result.length < length) {
193
+ const rnd = next();
194
+ result += rnd.toString(16).padStart(8, "0");
195
+ }
196
+
197
+ return result.substring(0, length);
198
+ }
199
+
200
+ let i = 0;
201
+
202
+ challenges = Array.from({ length: challenge.c }, () => {
203
+ i = i + 1;
204
+
205
+ return [
206
+ prng(`${token}${i}`, challenge.s),
207
+ prng(`${token}${i}d`, challenge.d),
208
+ ];
209
+ });
210
+ }
211
+
212
+ const solutions = await this.solveChallenges(challenges);
161
213
 
162
214
  const resp = await (
163
215
  await capFetch(`${apiEndpoint}redeem`, {
@@ -189,14 +241,20 @@
189
241
 
190
242
  this.#div.setAttribute(
191
243
  "aria-label",
192
- this.getI18nText("verified-aria-label", "We have verified you're a human, you may now continue")
244
+ this.getI18nText(
245
+ "verified-aria-label",
246
+ "We have verified you're a human, you may now continue"
247
+ )
193
248
  );
194
249
 
195
250
  return { success: true, token: this.token };
196
251
  } catch (err) {
197
252
  this.#div.setAttribute(
198
253
  "aria-label",
199
- this.getI18nText("error-aria-label", "An error occurred, please try again")
254
+ this.getI18nText(
255
+ "error-aria-label",
256
+ "An error occurred, please try again"
257
+ )
200
258
  );
201
259
  this.error(err.message);
202
260
  throw err;
@@ -249,7 +307,8 @@
249
307
  this.dispatchEvent("progress", {
250
308
  progress: Math.round((completed / total) * 100),
251
309
  });
252
- resolve([salt, target, data.nonce]);
310
+
311
+ resolve(data.nonce);
253
312
  };
254
313
 
255
314
  worker.onerror = (err) => {
@@ -309,17 +368,19 @@
309
368
  this.#div.classList.add("captcha");
310
369
  this.#div.setAttribute("role", "button");
311
370
  this.#div.setAttribute("tabindex", "0");
312
- this.#div.setAttribute("aria-label", this.getI18nText("verify-aria-label", "Click to verify you're a human"));
371
+ this.#div.setAttribute(
372
+ "aria-label",
373
+ this.getI18nText("verify-aria-label", "Click to verify you're a human")
374
+ );
313
375
  this.#div.setAttribute("aria-live", "polite");
314
376
  this.#div.setAttribute("disabled", "true");
315
377
  this.#div.innerHTML = `<div class="checkbox" part="checkbox"></div><p part="label">${this.getI18nText(
316
378
  "initial-state",
317
379
  "I'm a human"
318
- )}</p><a part="attribution" aria-label="Secured by Cap" href="https://capjs.js.org/" class="credits" target="_blank" rel="follow noopener"><span>Secured by&nbsp;</span>Cap</a>`;
380
+ )}</p><a part="attribution" aria-label="Secured by Cap" href="https://capjs.js.org/" class="credits" target="_blank" rel="follow noopener">Cap</a>`;
319
381
 
320
- this.#shadow.innerHTML = `<style>.captcha,.captcha * {box-sizing:border-box;}.captcha{background-color:var(--cap-background,#fdfdfd);border:1px solid var(--cap-border-color,#dddddd8f);border-radius:var(--cap-border-radius,14px);
321
- user-select:none;height:var(--cap-widget-height, 30px);width:var(--cap-widget-width, 230px);display:flex;align-items:center;padding:var(--cap-widget-padding,14px);gap:var(--cap-gap,15px);cursor:pointer;transition:filter .2s,transform .2s;position:relative;-webkit-tap-highlight-color:rgba(255,255,255,0);overflow:hidden;color:var(--cap-color,#212121)}.captcha:hover{filter:brightness(98%)}.checkbox{width:var(--cap-checkbox-size,25px);height:var(--cap-checkbox-size,25px);border:var(--cap-checkbox-border,1px solid #aaaaaad1);border-radius:var(--cap-checkbox-border-radius,6px);background-color:var(--cap-checkbox-background,#fafafa91);transition:opacity .2s;margin-top:var(--cap-checkbox-margin,2px);margin-bottom:var(--cap-checkbox-margin,2px)}.captcha *{font-family:var(--cap-font,system,-apple-system,"BlinkMacSystemFont",".SFNSText-Regular","San Francisco","Roboto","Segoe UI","Helvetica Neue","Lucida Grande","Ubuntu","arial",sans-serif)}.captcha p{margin:0;font-weight:500;font-size:15px;user-select:none;transition:opacity .2s}.captcha[data-state=verifying]
322
- .checkbox{background: none;display:flex;align-items:center;justify-content:center;transform: scale(1.1);border: none;border-radius: 50%;background: conic-gradient(var(--cap-spinner-color,#000) 0%, var(--cap-spinner-color,#000) var(--progress, 0%), var(--cap-spinner-background-color,#eee) var(--progress, 0%), var(--cap-spinner-background-color,#eee) 100%);position: relative;}.captcha[data-state=verifying] .checkbox::after {content: "";background-color: var(--cap-background,#fdfdfd);width: calc(100% - var(--cap-spinner-thickness,5px));height: calc(100% - var(--cap-spinner-thickness,5px));border-radius: 50%;margin:calc(var(--cap-spinner-thickness,5px) / 2)}.captcha[data-state=done] .checkbox{border:1px solid transparent;background-image:var(--cap-checkmark,url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2224%22%20height%3D%2224%22%20viewBox%3D%220%200%2024%2024%22%3E%3Cstyle%3E%40keyframes%20anim%7B0%25%7Bstroke-dashoffset%3A23.21320343017578px%7Dto%7Bstroke-dashoffset%3A0%7D%7D%3C%2Fstyle%3E%3Cpath%20fill%3D%22none%22%20stroke%3D%22%2300a67d%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%20stroke-width%3D%222%22%20d%3D%22m5%2012%205%205L20%207%22%20style%3D%22stroke-dashoffset%3A0%3Bstroke-dasharray%3A23.21320343017578px%3Banimation%3Aanim%20.5s%20ease%22%2F%3E%3C%2Fsvg%3E"));background-size:cover}.captcha[data-state=error] .checkbox{border:1px solid transparent;background-image:var(--cap-error-cross,url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='96' height='96' viewBox='0 0 24 24'%3E%3Cpath fill='%23f55b50' d='M11 15h2v2h-2zm0-8h2v6h-2zm1-5C6.47 2 2 6.5 2 12a10 10 0 0 0 10 10a10 10 0 0 0 10-10A10 10 0 0 0 12 2m0 18a8 8 0 0 1-8-8a8 8 0 0 1 8-8a8 8 0 0 1 8 8a8 8 0 0 1-8 8'/%3E%3C/svg%3E"));background-size:cover}.captcha[disabled]{cursor:not-allowed}.captcha[disabled][data-state=verifying]{cursor:progress}.captcha[disabled][data-state=done]{cursor:default}.captcha .credits{position:absolute;bottom:10px;right:10px;font-size:var(--cap-credits-font-size,12px);color:var(--cap-color,#212121);opacity:var(--cap-opacity-hover,0.8)}.captcha .credits span{display:none;text-decoration:underline}.captcha .credits:hover span{display:inline-block}</style>`;
382
+ this.#shadow.innerHTML = `<style>.captcha,.captcha * {box-sizing:border-box;}.captcha{background-color:var(--cap-background,#fdfdfd);border:1px solid var(--cap-border-color,#dddddd8f);border-radius:var(--cap-border-radius,14px);user-select:none;height:var(--cap-widget-height, 58px);width:var(--cap-widget-width, 230px);display:flex;align-items:center;padding:var(--cap-widget-padding,14px);gap:var(--cap-gap,15px);cursor:pointer;transition:filter .2s,transform .2s;position:relative;-webkit-tap-highlight-color:rgba(255,255,255,0);overflow:hidden;color:var(--cap-color,#212121)}.captcha:hover{filter:brightness(98%)}.checkbox{width:var(--cap-checkbox-size,25px);height:var(--cap-checkbox-size,25px);border:var(--cap-checkbox-border,1px solid #aaaaaad1);border-radius:var(--cap-checkbox-border-radius,6px);background-color:var(--cap-checkbox-background,#fafafa91);transition:opacity .2s;margin-top:var(--cap-checkbox-margin,2px);margin-bottom:var(--cap-checkbox-margin,2px)}.captcha *{font-family:var(--cap-font,system,-apple-system,"BlinkMacSystemFont",".SFNSText-Regular","San Francisco","Roboto","Segoe UI","Helvetica Neue","Lucida Grande","Ubuntu","arial",sans-serif)}.captcha p{margin:0;font-weight:500;font-size:15px;user-select:none;transition:opacity .2s}.captcha[data-state=verifying]
383
+ .checkbox{background: none;display:flex;align-items:center;justify-content:center;transform: scale(1.1);border: none;border-radius: 50%;background: conic-gradient(var(--cap-spinner-color,#000) 0%, var(--cap-spinner-color,#000) var(--progress, 0%), var(--cap-spinner-background-color,#eee) var(--progress, 0%), var(--cap-spinner-background-color,#eee) 100%);position: relative;}.captcha[data-state=verifying] .checkbox::after {content: "";background-color: var(--cap-background,#fdfdfd);width: calc(100% - var(--cap-spinner-thickness,5px));height: calc(100% - var(--cap-spinner-thickness,5px));border-radius: 50%;margin:calc(var(--cap-spinner-thickness,5px) / 2)}.captcha[data-state=done] .checkbox{border:1px solid transparent;background-image:var(--cap-checkmark,url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2224%22%20height%3D%2224%22%20viewBox%3D%220%200%2024%2024%22%3E%3Cstyle%3E%40keyframes%20anim%7B0%25%7Bstroke-dashoffset%3A23.21320343017578px%7Dto%7Bstroke-dashoffset%3A0%7D%7D%3C%2Fstyle%3E%3Cpath%20fill%3D%22none%22%20stroke%3D%22%2300a67d%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%20stroke-width%3D%222%22%20d%3D%22m5%2012%205%205L20%207%22%20style%3D%22stroke-dashoffset%3A0%3Bstroke-dasharray%3A23.21320343017578px%3Banimation%3Aanim%20.5s%20ease%22%2F%3E%3C%2Fsvg%3E"));background-size:cover}.captcha[data-state=error] .checkbox{border:1px solid transparent;background-image:var(--cap-error-cross,url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='96' height='96' viewBox='0 0 24 24'%3E%3Cpath fill='%23f55b50' d='M11 15h2v2h-2zm0-8h2v6h-2zm1-5C6.47 2 2 6.5 2 12a10 10 0 0 0 10 10a10 10 0 0 0 10-10A10 10 0 0 0 12 2m0 18a8 8 0 0 1-8-8a8 8 0 0 1 8-8a8 8 0 0 1 8 8a8 8 0 0 1-8 8'/%3E%3C/svg%3E"));background-size:cover}.captcha[disabled]{cursor:not-allowed}.captcha[disabled][data-state=verifying]{cursor:progress}.captcha[disabled][data-state=done]{cursor:default}.captcha .credits{position:absolute;bottom:10px;right:10px;font-size:var(--cap-credits-font-size,12px);color:var(--cap-color,#212121);opacity:var(--cap-opacity-hover,0.8);text-underline-offset: 1.5px;}</style>`;
323
384
 
324
385
  this.#shadow.appendChild(this.#div);
325
386
  }
package/src/worker.js CHANGED
@@ -3,9 +3,10 @@
3
3
  typeof WebAssembly !== "object" ||
4
4
  typeof WebAssembly?.instantiate !== "function"
5
5
  ) {
6
- self.onmessage = async ({ data: { salt, target } }) => {
7
- // Fallback solver in case WASM is not available
6
+ // fallback worker for environments without wasm
7
+ // this is much slower than the wasm version
8
8
 
9
+ self.onmessage = async ({ data: { salt, target } }) => {
9
10
  let nonce = 0;
10
11
  const batchSize = 50000;
11
12
  let processed = 0;
@@ -48,7 +49,7 @@
48
49
 
49
50
  processed += batchSize;
50
51
  } catch (error) {
51
- console.error("[cap worker] fallback worker error", error);
52
+ console.error("[cap worker]", error);
52
53
  self.postMessage({
53
54
  found: false,
54
55
  error: error.message,
@@ -1 +1,35 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).hashwasm=e.hashwasm||{})}(void 0,(function(e){function t(e,t,n,A){return new(n||(n=Promise))((function(i,o){function r(e){try{a(A.next(e))}catch(e){o(e)}}function E(e){try{a(A.throw(e))}catch(e){o(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(r,E)}a((A=A.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class n{constructor(){this.mutex=Promise.resolve()}lock(){let e=()=>{};return this.mutex=this.mutex.then((()=>new Promise(e))),new Promise((t=>{e=t}))}dispatch(e){return t(this,void 0,void 0,(function*(){const t=yield this.lock();try{return yield Promise.resolve(e())}finally{t()}}))}}var A;const i="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,o=null!==(A=i.Buffer)&&void 0!==A?A:null,r=i.TextEncoder?new i.TextEncoder:null;function E(e,t){return(15&e)+(e>>6|e>>3&8)<<4|(15&t)+(t>>6|t>>3&8)}const a="a".charCodeAt(0)-10,g="0".charCodeAt(0);function s(e,t,n){let A=0;for(let i=0;i<n;i++){let n=t[i]>>>4;e[A++]=n>9?n+a:n+g,n=15&t[i],e[A++]=n>9?n+a:n+g}return String.fromCharCode.apply(null,e)}const C=null!==o?e=>{if("string"==typeof e){const t=o.from(e,"utf8");return new Uint8Array(t.buffer,t.byteOffset,t.length)}if(o.isBuffer(e))return new Uint8Array(e.buffer,e.byteOffset,e.length);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Invalid data type!")}:e=>{if("string"==typeof e)return r.encode(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Invalid data type!")},B="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",c=new Uint8Array(256);for(let e=0;e<64;e++)c[B.charCodeAt(e)]=e;function l(e){const t=function(e){let t=Math.floor(.75*e.length);const n=e.length;return"="===e[n-1]&&(t-=1,"="===e[n-2]&&(t-=1)),t}(e),n=e.length,A=new Uint8Array(t);let i=0;for(let t=0;t<n;t+=4){const n=c[e.charCodeAt(t)],o=c[e.charCodeAt(t+1)],r=c[e.charCodeAt(t+2)],E=c[e.charCodeAt(t+3)];A[i]=n<<2|o>>4,i+=1,A[i]=(15&o)<<4|r>>2,i+=1,A[i]=(3&r)<<6|63&E,i+=1}return A}const h=16384,f=new n,d=new Map;function u(e,n){return t(this,void 0,void 0,(function*(){let A=null,i=null,o=!1;if("undefined"==typeof WebAssembly)throw new Error("WebAssembly is not supported in this environment!");const r=()=>new DataView(A.exports.memory.buffer).getUint32(A.exports.STATE_SIZE,!0),a=f.dispatch((()=>t(this,void 0,void 0,(function*(){if(!d.has(e.name)){const t=l(e.data),n=WebAssembly.compile(t);d.set(e.name,n)}const t=yield d.get(e.name);A=yield WebAssembly.instantiate(t,{})})))),g=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;o=!0,A.exports.Hash_Init(e)},B=e=>{if(!o)throw new Error("update() called before init()");(e=>{let t=0;for(;t<e.length;){const n=e.subarray(t,t+h);t+=n.length,i.set(n),A.exports.Hash_Update(n.length)}})(C(e))},c=new Uint8Array(2*n),u=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(!o)throw new Error("digest() called before init()");return o=!1,A.exports.Hash_Final(t),"binary"===e?i.slice(0,n):s(c,i,n)},v=e=>"string"==typeof e?e.length<4096:e.byteLength<h;let N=v;switch(e.name){case"argon2":case"scrypt":N=()=>!0;break;case"blake2b":case"blake2s":N=(e,t)=>t<=512&&v(e);break;case"blake3":N=(e,t)=>0===t&&v(e);break;case"xxhash64":case"xxhash3":case"xxhash128":N=()=>!1}return yield(()=>t(this,void 0,void 0,(function*(){A||(yield a);const e=A.exports.Hash_GetBuffer(),t=A.exports.memory.buffer;i=new Uint8Array(t,e,h)})))(),{getMemory:()=>i,writeMemory:function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;i.set(e,t)},getExports:()=>A.exports,setMemorySize:e=>{A.exports.Hash_SetMemorySize(e);const t=A.exports.Hash_GetBuffer(),n=A.exports.memory.buffer;i=new Uint8Array(n,t,e)},init:g,update:B,digest:u,save:()=>{if(!o)throw new Error("save() can only be called after init() and before digest()");const t=A.exports.Hash_GetState(),n=r(),i=A.exports.memory.buffer,a=new Uint8Array(i,t,n),g=new Uint8Array(4+n);return function(e,t){const n=t.length>>1;for(let A=0;A<n;A++){const n=A<<1;e[A]=E(t.charCodeAt(n),t.charCodeAt(n+1))}}(g,e.hash),g.set(a,4),g},load:t=>{if(!(t instanceof Uint8Array))throw new Error("load() expects an Uint8Array generated by save()");const n=A.exports.Hash_GetState(),i=r(),a=4+i,g=A.exports.memory.buffer;if(t.length!==a)throw new Error("Bad state length (expected ".concat(a," bytes, got ").concat(t.length,")"));if(!function(e,t){if(e.length!==2*t.length)return!1;for(let n=0;n<t.length;n++){const A=n<<1;if(t[n]!==E(e.charCodeAt(A),e.charCodeAt(A+1)))return!1}return!0}(e.hash,t.subarray(0,4)))throw new Error("This state was written by an incompatible hash implementation");const s=t.subarray(4);new Uint8Array(g,n,i).set(s),o=!0},calculate:function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;if(!N(e,t))return g(t),B(e),u("hex",o);const r=C(e);return i.set(r),A.exports.Hash_Calculate(r.length,t,o),s(c,i,n)},hashLength:n}}))}let v="AGFzbQE||BEAF/YAF/AG|AGACf38|wgH|EBAQAw$AQECAgYOAn8BQfCJBQt/AEGACAsHcAgGbWVtb3J5AÔHZXRCdWZmZX|lº0luaXQ|Qtº1VwZGF0ZQACCkhhc2hfRmluYWwABA1º0dldFN0YXRl|UÔDYWxjdWxhdGUABgpTVEFURV9TSVpFAwEKoEoHBQBBkLnQEABCADcDwÈBHEEgBB4AFGIbNgL#QFBAEKnn+anxvST/b5/Qquzj/yRo7Pw2wABs3A+C“QrGWgP6fooWs6ABC/6S5iMWR2oKbfy|GzcD2ÈCl7rDg5Onlod3QvLmu+Ojp/2npX8Bs3A9C“Qti9loj8oLW+NkLnzKfQ1tDrs7t/AbNwPI¥L7wICAX4Gf0EAApA8CJASCtfDcDw`AkACQAJAGnQT9xIgINAEGACSEDDAELAkBBw|msiBC|QEkbIgNFDQA0EDcSEFJBg`aiEGAhAgJANBBEkNACADQfwAcSEHAhAgNAYm#AyACQYA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G#DG#BCAÖEªE(EJMgEnNxJ³‚IglËgCU¡AJ‰gC$§ƒ#C,TJœSC$aJ(J„#E,JNœTŅcXM$eBÑBӆc3Eg‡ÎDˆBGHZyc‰h2QYD+A3EŠ`akNwFB‹Nqd%B0EVB0Œgk¾©Û#Ei߯Žz\vP¦99CIDÏN?0±NҐ13‘EAKAL’cXMgBkEeGÑGӓJA$A”BE3dz•l3–BACgC—2og˜ai0|Do|CA™EZšYÕgBiAN›ÐhEgC,T†E3~œzc,iQFBAžBCndzŸgEÇ qAoA¡<h0ci¢mog£EO¤QYD+A3FBCHRy¥iQE¦p3§YdnJyIg¨gB3Ùd©Nql%C$VCUªEa«Kd3Nq¬BDXdz­BCnZz®BHnc¯gNh°#AW#E±EIdk<²BCHZBgP4Dc,³z\vJ¦ll´z\vS¦JJµAKAI¶CgC·AoA¸•IC¹53ºIYXNoX»GA¥QA¼gDCAG½gZgcgDyA¾gEyAS†En¿lqLQ|OAÀWot|A6|AÁgEXNxFz\vÂhGE=GE\bhÃDEªM(MÄFEªU(UÅE$aR(RÆEkªS(SÇWogÈ`BÉ$NÊEAIQËBGHQÌDdnMÍgE¢ÎiABÏh0ÐgFÑN3҈iIÓp3ÔOSGFzaF9ÕgDXMgDHEÖH9œPB×^aiBCNØhc‡ZDÙNxÚFzÛ#AmÜk™Ý•ÞBAnRBg`ßARlœJàhkaC";const N="àßÞÝÜÛÚÙØ×ÖÕÔÓÒÑÐÏÎÍÌËÊÉÈÇÆÅÄÃÂÁÀ¿¾½¼»º¹¸·¶µ´³²±°¯®­¬«ª©¨§¦¥¤£¢¡ Ÿžœ›š™˜—–•”“’‘ŽŒ‹Š‰ˆ‡†…„ƒ‚€~}|{`_^][@?>=<;:.-,*)(&%$#! \f\v\t\b";let D;for(D in N){const e=v.split(N[D]);v=e.join(e.pop())}var G={name:"sha256",data:v,hash:"64f06674"};const y=new n;let J=null;e.createSHA256=function(){return u(G,32).then((e=>{e.init(256);const t={init:()=>(e.init(256),t),update:n=>(e.update(n),t),digest:t=>e.digest(t),save:()=>e.save(),load:n=>(e.load(n),t),blockSize:64,digestSize:32};return t}))},e.sha256=function(e){if(null===J)return function(e,n){return t(this,void 0,void 0,(function*(){const t=yield e.lock(),A=yield u(n,32);return t(),A}))}(y,G).then((t=>(J=t,J.calculate(e,256))));try{const t=J.calculate(e,256);return Promise.resolve(t)}catch(e){return Promise.reject(e)}}}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).hashwasm=e.hashwasm||{})}(void 0,(function(e){function t(e,t,n,A){return new(n||(n=Promise))((function(i,o){function r(e){try{a(A.next(e))}catch(e){o(e)}}function E(e){try{a(A.throw(e))}catch(e){o(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(r,E)}a((A=A.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class n{constructor(){this.mutex=Promise.resolve()}lock(){let e=()=>{};return this.mutex=this.mutex.then((()=>new Promise(e))),new Promise((t=>{e=t}))}dispatch(e){return t(this,void 0,void 0,(function*(){const t=yield this.lock();try{return yield Promise.resolve(e())}finally{t()}}))}}var A;const i="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,o=null!==(A=i.Buffer)&&void 0!==A?A:null,r=i.TextEncoder?new i.TextEncoder:null;function E(e,t){return(15&e)+(e>>6|e>>3&8)<<4|(15&t)+(t>>6|t>>3&8)}const a="a".charCodeAt(0)-10,g="0".charCodeAt(0);function s(e,t,n){let A=0;for(let i=0;i<n;i++){let n=t[i]>>>4;e[A++]=n>9?n+a:n+g,n=15&t[i],e[A++]=n>9?n+a:n+g}return String.fromCharCode.apply(null,e)}const C=null!==o?e=>{if("string"==typeof e){const t=o.from(e,"utf8");return new Uint8Array(t.buffer,t.byteOffset,t.length)}if(o.isBuffer(e))return new Uint8Array(e.buffer,e.byteOffset,e.length);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Invalid data type!")}:e=>{if("string"==typeof e)return r.encode(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Invalid data type!")},B="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",c=new Uint8Array(256);for(let e=0;e<64;e++)c[B.charCodeAt(e)]=e;function l(e){const t=function(e){let t=Math.floor(.75*e.length);const n=e.length;return"="===e[n-1]&&(t-=1,"="===e[n-2]&&(t-=1)),t}(e),n=e.length,A=new Uint8Array(t);let i=0;for(let t=0;t<n;t+=4){const n=c[e.charCodeAt(t)],o=c[e.charCodeAt(t+1)],r=c[e.charCodeAt(t+2)],E=c[e.charCodeAt(t+3)];A[i]=n<<2|o>>4,i+=1,A[i]=(15&o)<<4|r>>2,i+=1,A[i]=(3&r)<<6|63&E,i+=1}return A}const h=16384,f=new n,d=new Map;function u(e,n){return t(this,void 0,void 0,(function*(){let A=null,i=null,o=!1;if("undefined"==typeof WebAssembly)throw new Error("WebAssembly is not supported in this environment!");const r=()=>new DataView(A.exports.memory.buffer).getUint32(A.exports.STATE_SIZE,!0),a=f.dispatch((()=>t(this,void 0,void 0,(function*(){if(!d.has(e.name)){const t=l(e.data),n=WebAssembly.compile(t);d.set(e.name,n)}const t=yield d.get(e.name);A=yield WebAssembly.instantiate(t,{})})))),g=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;o=!0,A.exports.Hash_Init(e)},B=e=>{if(!o)throw new Error("update() called before init()");(e=>{let t=0;for(;t<e.length;){const n=e.subarray(t,t+h);t+=n.length,i.set(n),A.exports.Hash_Update(n.length)}})(C(e))},c=new Uint8Array(2*n),u=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(!o)throw new Error("digest() called before init()");return o=!1,A.exports.Hash_Final(t),"binary"===e?i.slice(0,n):s(c,i,n)},v=e=>"string"==typeof e?e.length<4096:e.byteLength<h;let N=v;switch(e.name){case"argon2":case"scrypt":N=()=>!0;break;case"blake2b":case"blake2s":N=(e,t)=>t<=512&&v(e);break;case"blake3":N=(e,t)=>0===t&&v(e);break;case"xxhash64":case"xxhash3":case"xxhash128":N=()=>!1}return yield(()=>t(this,void 0,void 0,(function*(){A||(yield a);const e=A.exports.Hash_GetBuffer(),t=A.exports.memory.buffer;i=new Uint8Array(t,e,h)})))(),{getMemory:()=>i,writeMemory:function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;i.set(e,t)},getExports:()=>A.exports,setMemorySize:e=>{A.exports.Hash_SetMemorySize(e);const t=A.exports.Hash_GetBuffer(),n=A.exports.memory.buffer;i=new Uint8Array(n,t,e)},init:g,update:B,digest:u,save:()=>{if(!o)throw new Error("save() can only be called after init() and before digest()");const t=A.exports.Hash_GetState(),n=r(),i=A.exports.memory.buffer,a=new Uint8Array(i,t,n),g=new Uint8Array(4+n);return function(e,t){const n=t.length>>1;for(let A=0;A<n;A++){const n=A<<1;e[A]=E(t.charCodeAt(n),t.charCodeAt(n+1))}}(g,e.hash),g.set(a,4),g},load:t=>{if(!(t instanceof Uint8Array))throw new Error("load() expects an Uint8Array generated by save()");const n=A.exports.Hash_GetState(),i=r(),a=4+i,g=A.exports.memory.buffer;if(t.length!==a)throw new Error("Bad state length (expected ".concat(a," bytes, got ").concat(t.length,")"));if(!function(e,t){if(e.length!==2*t.length)return!1;for(let n=0;n<t.length;n++){const A=n<<1;if(t[n]!==E(e.charCodeAt(A),e.charCodeAt(A+1)))return!1}return!0}(e.hash,t.subarray(0,4)))throw new Error("This state was written by an incompatible hash implementation");const s=t.subarray(4);new Uint8Array(g,n,i).set(s),o=!0},calculate:function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;if(!N(e,t))return g(t),B(e),u("hex",o);const r=C(e);return i.set(r),A.ex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Wot|A6|AÁgEXNxFz\vÂhGE=GE\bhÃDEªM(MÄFEªU(UÅE$aR(RÆEkªS(SÇWogÈ`BÉ$NÊEAIQËBGHQÌDdnMÍgE¢ÎiABÏh0ÐgFÑN3҈iIÓp3ÔOSGFzaF9ÕgDXMgDHEÖH9œPB×^aiBCNØhc‡ZDÙNxÚFzÛ#AmÜk™Ý•ÞBAnRBg`ßARlœJàhkaC";const N="àßÞÝÜÛÚÙØ×ÖÕÔÓÒÑÐÏÎÍÌËÊÉÈÇÆÅÄÃÂÁÀ¿¾½¼»º¹¸·¶µ´³²±°¯®­¬«ª©¨§¦¥¤£¢¡ Ÿžœ›š™˜—–•”“’‘ŽŒ‹Š‰ˆ‡†…„ƒ‚€~}|{`_^][@?>=<;:.-,*)(&%$#! \f\v\t\b";let D;for(D in N){const e=v.split(N[D]);v=e.join(e.pop())}var G={name:"sha256",data:v,hash:"64f06674"};const y=new n;let J=null;e.createSHA256=function(){return u(G,32).then((e=>{e.init(256);const t={init:()=>(e.init(256),t),update:n=>(e.update(n),t),digest:t=>e.digest(t),save:()=>e.save(),load:n=>(e.load(n),t),blockSize:64,digestSize:32};return t}))},e.sha256=function(e){if(null===J)return function(e,n){return t(this,void 0,void 0,(function*(){const t=yield e.lock(),A=yield u(n,32);return t(),A}))}(y,G).then((t=>(J=t,J.calculate(e,256))));try{const t=J.calculate(e,256);return Promise.resolve(t)}catch(e){return Promise.reject(e)}}}));
2
+
3
+ // ====================================================
4
+
5
+ // this is a now unused library which an old version of
6
+ // cap depended on. to avoid breaking things as much as
7
+ // possible, we've kept it here.
8
+
9
+ try {
10
+ // lets us know how many people are actually using this
11
+ // so we can know when it's safe to deprecate.
12
+
13
+ // server source code:
14
+ // https://gist.github.com/tiagorangel1/ffb39489f5af91e6e45f94f1bfa14ab2
15
+ fetch(
16
+ `https://api.tiagorangel.com/cap-legacy-widget?h=${self.location?.hostname || 'unknown'}`, {
17
+ mode: 'no-cors'
18
+ }
19
+ ).catch(() => {});
20
+ } catch {}
21
+
22
+ console.warn(
23
+ `[cap]
24
+ %cYou're using a deprecated version of Cap's widget that still relies on this file.
25
+
26
+ It may continue to work for now, but could break at any time since this dependency was removed several versions ago.
27
+
28
+ Please update Cap to fix this.`,
29
+ "font-size:15px;background-image:url('https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fpreview.colorkit.co%2Fcolor%2FEEEEEE.png%3Ftype%3Darticle-preview-logo%26size%3Dsocial%26colorname%3DSuper%2520Silver&f=1&nofb=1&ipt=49845e9195461b7c779182793c2ebf7834102eaf5561c15fa2cbb55494b77a9b');background-size:10px"
30
+ );
31
+
32
+ console.log(
33
+ `%cTo help us understand how many people are using this legacy version and when it's safe to deprecate it, we've sent a small, privacy-friendly beacon to our servers. All related code, including the telemetry server, is open source.\n\nYou might have gotten a CSP error before this, it should be safe to ignore. Server source code: https://gist.github.com/tiagorangel1/ffb39489f5af91e6e45f94f1bfa14ab2`,
34
+ "font-size:11px;color:#b7b7b7"
35
+ );