You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2 lines
4.4 KiB
2 lines
4.4 KiB
(()=>{"use strict";function e(){const e=window.location.hostname||"";return[".bitwarden.com",".bitwarden.eu",".bitwarden.pw"].some(t=>e.endsWith(t))}function t(e){const t=window.location.href;e=e.replace(/[\[\]]/g,"\\$&");const n=new RegExp("[?&]"+e+"(=([^&#]*)|&|#|$)").exec(t);return n?n[2]?decodeURIComponent(n[2].replace(/\+/g," ")):"":null}function n(e,t=!1){return t&&(e=e.replace(/ /g,"+")),decodeURIComponent(Array.prototype.map.call(atob(e),e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)).join(""))}function r(e){document.location.replace(e)}function o(e){const n=`${e}-callback`;return"https"===(t("deeplinkScheme")||"").toLowerCase()?`https://${function(){const e=window.location.hostname||"";return e.endsWith("bitwarden.eu")?"bitwarden.eu":e.endsWith("bitwarden.pw")?"bitwarden.pw":"bitwarden.com"}()}/${n}`:`bitwarden://${n}`}function a(e){if(Array.isArray(e)&&(e=Uint8Array.from(e)),e instanceof ArrayBuffer&&(e=new Uint8Array(e)),e instanceof Uint8Array){let t="";const n=e.byteLength;for(let r=0;r<n;r++)t+=String.fromCharCode(e[r]);e=window.btoa(t)}if("string"!=typeof e)throw new Error("could not coerce to string");return e=e.replace(/\+/g,"-").replace(/\//g,"_").replace(/=*$/g,"")}let i,c=!1,d=null,s=null,l=null,u=null,w=null,f=null,p=null,g=null,h=!1,b=!1,m=!1,y=null;const v=["tw-bg-secondary-300","tw-border-secondary-300","!tw-text-muted","!tw-cursor-not-allowed","hover:tw-bg-secondary-300","hover:tw-border-secondary-300","hover:!tw-text-muted","hover:tw-no-underline"],x=["tw-bg-primary-600","tw-border-primary-600","!tw-text-contrast","hover:tw-bg-primary-700","hover:tw-border-primary-700","hover:!tw-text-contrast","hover:tw-no-underline"];function U(){if(!s)return;const e=document.getElementById("webauthn-button");e.onclick=I,e.innerText=decodeURI(s),e.classList.remove(...v),e.classList.add(...x)}function A(){if(c)return;w=t("parent"),w&&(w=decodeURIComponent(w),f=new URL(w).origin),p=function(t){if(t)try{if("file:"===new URL(t).protocol)return t}catch(n){}return e()?window.location.origin:t}(w);"1"===t("v")?function(){const e=t("data");if(!e)return void R("No data.");i=n(e),d=t("headerText"),s=t("btnText"),l=t("btnAwaitingInteractionText"),u=t("btnReturnText")}():function(){let e=null;try{e=JSON.parse(n(t("data")))}catch(r){return void R("Cannot parse data.")}g=function(e,t,n){return e?n():!0===t.mobile||null!=t.callbackUri?"bitwarden://webauthn-callback":null}(t("deeplinkScheme"),e,()=>o("webauthn")),h=null!=g,i=e.data,d=e.headerText,s=e.btnText,u=e.btnReturnText}(),w||g?c=!0:R("No return target provided.")}function C(){if(m=!1,"credentials"in navigator){if(A(),d){document.getElementById("webauthn-header").innerText=decodeURI(d)}if(U(),i){try{y=function(e){const t=JSON.parse(e),n=t.challenge.replace(/-/g,"+").replace(/_/g,"/");return t.challenge=Uint8Array.from(atob(n),e=>e.charCodeAt(0)),t.allowCredentials.forEach(e=>{const t=e.id.replace(/\_/g,"/").replace(/\-/g,"+");e.id=Uint8Array.from(atob(t),e=>e.charCodeAt(0))}),t}(i)}catch(e){return void R("Cannot parse webauthn data.")}b=!1,h||-1!==navigator.userAgent.indexOf(" Safari/")&&-1===navigator.userAgent.indexOf("Chrome")||I()}else R("No data.")}else R("WebAuthn is not supported in this browser.")}function I(){b?U():(!function(){if(!l)return;const e=document.getElementById("webauthn-button");e.innerText=decodeURI(l),e.onclick=null,e.classList.remove(...x),e.classList.add(...v)}(),navigator.credentials.get({publicKey:y}).then(L).catch(R))}function R(e){if(g){const t=g+"?error="+encodeURIComponent(e);r(t),T(t)}else w&&(parent.postMessage("error|"+e,p),U())}function L(e){if(m)return;const t=function(e){const t=e.response,n=new Uint8Array(t.authenticatorData),r=new Uint8Array(t.clientDataJSON),o=new Uint8Array(e.rawId),i=new Uint8Array(t.signature),c={id:e.id,rawId:a(o),type:e.type,extensions:e.getClientExtensionResults(),response:{authenticatorData:a(n),clientDataJson:a(r),signature:a(i)}};return JSON.stringify(c)}(e);if(g){const e=g+"?data="+encodeURIComponent(t);r(e),T(e)}else w&&(parent.postMessage("success|"+t,p),m=!0)}function T(e){const t=document.getElementById("webauthn-button");t.innerText=decodeURI(u),t.onclick=()=>{r(e)}}document.addEventListener("DOMContentLoaded",()=>{var t;C(),window.addEventListener("message",t=>{const n=w&&w.startsWith("file:")||!e()?f:window.location.origin;(!n||t.origin&&""!==t.origin&&t.origin===n)&&("stop"===t.data?(U(),b=!0):"start"===t.data&&b&&C())},!1),t="ready",!h&&w&&parent.postMessage("info|"+t,p)})})();
|
|
//# sourceMappingURL=webauthn.ead2ec284156bb3fc911.js.map
|