芝麻web文件管理V1.00
编辑当前文件:/home2/sdektunc/chocholayucatan.gob.mx/media/plg_system_webauthn/js/login-es5.min.js
!function(){"use strict";window.Joomla=window.Joomla||{},function(e,n){var r=function e(n,r){void 0===r&&(r="");var t="";return Object.keys(n).forEach((function(a){if("object"!=typeof n[a])return t.length>0&&(t+="&"),void(t+=""===r?encodeURIComponent(a)+"="+encodeURIComponent(n[a]):encodeURIComponent(r)+"["+encodeURIComponent(a)+"]="+encodeURIComponent(n[a]));t+=""+e(n[a],a)})),t},t=function(e,n){var r=e.querySelectorAll(n);return r.length?r[0]:null},a=function(e,n){var r=null;if(!e)return r;var a=e.parentElement;if("FORM"===a.nodeName)return r=t(a,n);var o=a.querySelectorAll("form");if(o.length)for(var i=0;i<o.length;i+=1)if(null!==(r=t(o[i],n)))return r;return null},o=function(n){e.renderMessages({error:[n]})};e.plgSystemWebauthnLogin=function(t,i){var u=n.getElementById(t),l=a(u,"input[name=username]"),c=a(u,"input[name=return]");if(null===l)return e.renderMessages({error:[e.Text._("PLG_SYSTEM_WEBAUTHN_ERR_CANNOT_FIND_USERNAME")]}),!1;var s=l.value,d=c?c.value:null;if(""===s)return e.renderMessages({error:[e.Text._("PLG_SYSTEM_WEBAUTHN_ERR_EMPTY_USERNAME")]}),!1;var g={option:"com_ajax",group:"system",plugin:"webauthn",format:"raw",akaction:"challenge",encoding:"raw",username:s,returnUrl:d};return e.request({url:i,method:"POST",data:r(g),onSuccess:function(n){var r={};try{r=JSON.parse(n)}catch(e){}!function(n,r){var t=function(e){return btoa(String.fromCharCode.apply(String,e))},a=function(e){var n=e.replace(/-/g,"+").replace(/_/g,"/"),r=n.length%4;if(r){if(1===r)throw new Error("InvalidLengthError: Input base64url string is the wrong length to determine padding");n+=new Array(5-r).join("=")}return n};n.challenge?(n.challenge=Uint8Array.from(window.atob(a(n.challenge)),(function(e){return e.charCodeAt(0)})),n.allowCredentials&&(n.allowCredentials=n.allowCredentials.map((function(e){return e.id=Uint8Array.from(window.atob(a(e.id)),(function(e){return e.charCodeAt(0)})),e}))),navigator.credentials.get({publicKey:n}).then((function(e){var n={id:e.id,type:e.type,rawId:t(new Uint8Array(e.rawId)),response:{authenticatorData:t(new Uint8Array(e.response.authenticatorData)),clientDataJSON:t(new Uint8Array(e.response.clientDataJSON)),signature:t(new Uint8Array(e.response.signature)),userHandle:e.response.userHandle?t(new Uint8Array(e.response.userHandle)):null}};window.location=r+"&option=com_ajax&group=system&plugin=webauthn&format=raw&akaction=login&encoding=redirect&data="+btoa(JSON.stringify(n))})).catch((function(e){o(e)}))):o(e.Text._("PLG_SYSTEM_WEBAUTHN_ERR_INVALID_USERNAME"))}(r,i)},onError:function(e){o(e.status+" "+e.statusText)}}),!1};var i=[].slice.call(n.querySelectorAll(".plg_system_webauthn_login_button"));i.length&&i.forEach((function(n){n.addEventListener("click",(function(n){var r=n.currentTarget;e.plgSystemWebauthnLogin(r.getAttribute("data-webauthn-form"),r.getAttribute("data-webauthn-url"))}))}))}(Joomla,document)}();