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
8.6 KiB

(()=>{"use strict";function e(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 t(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 n(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 a=0;a<n;a++)t+=String.fromCharCode(e[a]);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,"")}var a=function(e,t,n,a){return new(n||(n=Promise))(function(s,o){function i(e){try{l(a.next(e))}catch(t){o(t)}}function r(e){try{l(a.throw(e))}catch(t){o(t)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(i,r)}l((a=a.apply(e,t||[])).next())})};class s{constructor(e,t,n){this.systemLanguage=e,this.localesDirectory=t,this.getLocalesJson=n,this.supportedTranslationLocales=["en"],this.defaultLocale="en",this.localeNames=new Map([["af","Afrikaans"],["ar","العربية الفصحى"],["az","Azərbaycanca"],["be","Беларуская"],["bg","български"],["bn","বাংলা"],["bs","bosanski jezik"],["ca","català"],["cs","čeština"],["cy","Cymraeg, y Gymraeg"],["da","dansk"],["de","Deutsch"],["el","Ελληνικά"],["en","English"],["en-GB","English (British)"],["en-IN","English (India)"],["eo","Esperanto"],["es","español"],["et","eesti"],["eu","euskara"],["fa","فارسی"],["fi","suomi"],["fil","Wikang Filipino"],["fr","français"],["gl","galego"],["he","עברית"],["hi","हिन्दी"],["hr","hrvatski"],["hu","magyar"],["id","Bahasa Indonesia"],["it","italiano"],["ja","日本語"],["ka","ქართული"],["km","ខ្មែរ, ខេមរភាសា, ភាសាខ្មែរ"],["kn","ಕನ್ನಡ"],["ko","한국어"],["lt","lietuvių kalba"],["lv","Latvietis"],["me","црногорски"],["ml","മലയാളം"],["mr","मराठी"],["my","ဗမာစကား"],["nb","norsk (bokmål)"],["ne","नेपाली"],["nl","Nederlands"],["nn","Norsk Nynorsk"],["or","ଓଡ଼ିଆ"],["pl","polski"],["pt-BR","português do Brasil"],["pt-PT","português"],["ro","română"],["ru","русский"],["si","සිංහල"],["sk","slovenčina"],["sl","Slovenski jezik, Slovenščina"],["sr","Српски"],["sv","svenska"],["ta","தமிழ்"],["te","తెలుగు"],["th","ไทย"],["tr","Türkçe"],["uk","українська"],["vi","Tiếng Việt"],["zh-CN","中文(中国大陆)"],["zh-TW","中文(台灣)"]]),this.defaultMessages={},this.localeMessages={},this.systemLanguage=e.replace("_","-")}init(e){return a(this,void 0,void 0,function*(){if(this.inited)throw new Error("i18n already initialized.");if(null==this.supportedTranslationLocales||0===this.supportedTranslationLocales.length)throw new Error("supportedTranslationLocales not set.");this.inited=!0,this.translationLocale=null!=e?e:this.systemLanguage;try{this.collator=new Intl.Collator(this.translationLocale,{numeric:!0,sensitivity:"base"})}catch(t){this.collator=null}-1===this.supportedTranslationLocales.indexOf(this.translationLocale)&&(this.translationLocale=this.translationLocale.slice(0,2),-1===this.supportedTranslationLocales.indexOf(this.translationLocale)&&(this.translationLocale=this.defaultLocale)),null!=this.localesDirectory&&(yield this.loadMessages(this.translationLocale,this.localeMessages),this.translationLocale!==this.defaultLocale&&(yield this.loadMessages(this.defaultLocale,this.defaultMessages)))})}t(e,t,n,a){return this.translate(e,t,n,a)}translate(e,t,n,a){let s;return s=this.localeMessages.hasOwnProperty(e)&&this.localeMessages[e]?this.localeMessages[e]:this.defaultMessages.hasOwnProperty(e)&&this.defaultMessages[e]?this.defaultMessages[e]:"",""!==s&&(null!=t&&(s=s.split("__$1__").join(t.toString())),null!=n&&(s=s.split("__$2__").join(n.toString())),null!=a&&(s=s.split("__$3__").join(a.toString()))),s}loadMessages(e,t){return a(this,void 0,void 0,function*(){const n=e.replace("-","_"),a=yield this.getLocalesJson(n);for(const e in a)if(a.hasOwnProperty(e)&&(t[e]=a[e].message,a[e].placeholders))for(const n in a[e].placeholders){if(!a[e].placeholders.hasOwnProperty(n)||!a[e].placeholders[n].content)continue;const s="\\$"+n.toUpperCase()+"\\$";let o=a[e].placeholders[n].content;"$1"!==o&&"$2"!==o&&"$3"!==o||(o="__$"+o+"__"),t[e]=t[e].replace(new RegExp(s,"g"),o)}})}}const o=["en","af","ar","az","be","bg","bn","bs","ca","cs","cy","da","de","el","en-GB","en-IN","eo","es","et","eu","fa","fi","fil","fr","gl","he","hi","hr","hu","id","it","ja","ka","km","kn","ko","lv","ml","mr","my","nb","ne","nl","nn","or","pl","pt-PT","pt-BR","ro","ru","si","sk","sl","sr","sv","ta","te","th","tr","uk","vi","zh-CN","zh-TW"];var i=function(e,t,n,a){return new(n||(n=Promise))(function(s,o){function i(e){try{l(a.next(e))}catch(t){o(t)}}function r(e){try{l(a.throw(e))}catch(t){o(t)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(i,r)}l((a=a.apply(e,t||[])).next())})};class r extends s{constructor(e,t){super(e||"en-US",t,e=>i(this,void 0,void 0,function*(){const t=this.localesDirectory+"/"+e+"/messages.json?cache=r5ktz",n=yield fetch(t);return yield n.json()})),this.supportedTranslationLocales=o}get translationLocale(){return this._translationLocale}set translationLocale(e){this._translationLocale=e}}var l=function(e,t,n,a){return new(n||(n=Promise))(function(s,o){function i(e){try{l(a.next(e))}catch(t){o(t)}}function r(e){try{l(a.throw(e))}catch(t){o(t)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(i,r)}l((a=a.apply(e,t||[])).next())})};let c,d=!1,u=null,h=!1,f=null,g=null;function p(){var n;if(d)return;if(u=e("parent"),!u)return void m("No parent.");u=decodeURIComponent(u),f=null!==(n=e("locale"))&&void 0!==n?n:"en";"1"===e("v")?function(){const n=e("data");if(!n)return void m("No data.");c=t(n)}():function(){let n=null;try{n=JSON.parse(t(e("data")))}catch(a){return void m("Cannot parse data.")}c=n.data}(),d=!0}function y(){if(h)return;if(!("credentials"in navigator))return void m(g.t("webAuthnNotSupported"));if(p(),!c)return void m("No data.");let e;try{e=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}(c)}catch(t){return void m("Cannot parse data.")}!function(e){l(this,void 0,void 0,function*(){try{const t=yield navigator.credentials.get({publicKey:e});if(h)return;const a=function(e){const t=e.response,a=new Uint8Array(t.authenticatorData),s=new Uint8Array(t.clientDataJSON),o=new Uint8Array(e.rawId),i=new Uint8Array(t.signature),r={id:e.id,rawId:n(o),type:e.type,extensions:e.getClientExtensionResults(),response:{authenticatorData:n(a),clientDataJson:n(s),signature:n(i)}};return JSON.stringify(r)}(t),s=document.getElementById("remember").checked;window.postMessage({command:"webAuthnResult",data:a,remember:s},"*"),h=!0,function(e){document.getElementById("webauthn-button").disabled=!0,document.getElementById("remember").disabled=!0;const t=document.getElementById("msg");v(t),t.textContent=e,t.classList.add("alert"),t.classList.add("alert-success"),t.classList.remove("tw-hidden")}(g.t("webAuthnSuccess"))}catch(t){m(t)}})}(e)}function m(e){const t=document.getElementById("msg");v(t),t.textContent=e,t.classList.add("alert"),t.classList.add("alert-danger"),t.classList.remove("tw-hidden")}function v(e){e.classList.remove("alert"),e.classList.remove("alert-danger"),e.classList.remove("alert-success"),e.classList.add("tw-hidden")}document.addEventListener("DOMContentLoaded",()=>l(void 0,void 0,void 0,function*(){p();try{g=new r(f,"locales")}catch(a){m("Failed to load the provided locale "+f),g=new r("en","locales")}yield g.init(),document.getElementById("remember-label").innerText=g.t("dontAskAgainOnThisDeviceFor30Days");const e=document.getElementById("webauthn-button");e.innerText=g.t("readSecurityKey"),e.onclick=y;const t=document.getElementById("title-smaller-screens"),n=document.getElementById("title-larger-screens");t.innerText=g.t("verifyYourIdentity"),n.innerText=g.t("verifyYourIdentity");document.getElementById("subtitle").innerText=g.t("followTheStepsBelowToFinishLoggingInWithSecurityKey")}))})();
//# sourceMappingURL=webauthn-fallback.a4e27e1529cc9c0658a1.js.map