window.addEventListener("load",function(){var e=document.getElementById("register");e&&e.addEventListener("click",function(){navigator.registerProtocolHandler("openpgp4fpr","https://metacode.biz/openpgp/resolve/%s","Search for key on the keyserver")});var r=document.getElementById("search");r&&r.addEventListener("submit",function(t){t.preventDefault(),t.disabled=!0;var o=t.target.querySelector("ul");o.textContent="Checking OpenPGP key using Web Key Directory...";var e=t.target.querySelector("input").value;fetch("./wkd-checker",{method:"POST",body:JSON.stringify({email:e})}).then(function(e){return e.json()}).then(function(e){var r=[];r.push({category:"info",value:"Key address",url:e.key.url}),200!==e.key.code?r.push({category:"error",value:"Key not found"}):(r.push({category:"ok",value:"Key file found"}),e.key.response.startsWith("9")?r.push({category:"ok",value:"Key format correct"}):r.push({category:"error",value:"Key format error: key should be in binary form, not ASCII-armored"}),e.key.cors?(r.push({category:"ok",value:"Key is accessible from all sites"}),e["fake-key"].cors?r.push({category:"ok",value:"Not found keys also generate CORS headers"}):r.push({category:"warn",value:"Not found keys do not have CORS headers"})):r.push({category:"warn",value:"Key is not accessible, add 'Access-Control-Allow-Origin: *' header"})),200!==e.policy.code?r.push({category:"error",value:"Policy not found. Policy file can be empty",url:e.policy.url}):r.push({category:"ok",value:"Policy file found"}),o.innerHTML="",r.map(function(e){var r=document.createElement("LI");if(r.textContent=e.value,r.className=e.category,e.url){var t=document.createElement("A");t.href=e.url,t.textContent=e.url,t.target="_blank",t.setAttribute("rel","nofollow noopener"),r.textContent+=": ",r.appendChild(t)}return r}).forEach(o.appendChild.bind(o)),console.log(r),t.disabled=!1})})});
