[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/media/plg_system_webauthn/js/ -> management-es5.min.js (source)

   1  !function(){"use strict";window.Joomla=window.Joomla||{},function(e,t){var n=function e(t,n){void 0===n&&(n="");var a="";return Object.keys(t).forEach((function(r){if("object"!=typeof t[r])return a.length>0&&(a+="&"),void(a+=""===n?encodeURIComponent(r)+"="+encodeURIComponent(t[r]):encodeURIComponent(n)+"["+encodeURIComponent(r)+"]="+encodeURIComponent(t[r]));a+=""+e(t[r],r)})),a},a=function(t){e.renderMessages({error:[t]})};e.plgSystemWebauthnInitCreateCredentials=function(){if("credentials"in navigator){var t=e.getOptions("system.paths"),r=""+(t?t.base+"/index.php":window.location.pathname),i={option:"com_ajax",group:"system",plugin:"webauthn",format:"json",akaction:"initcreate",encoding:"json"};i[e.getOptions("csrf.token")]=1,e.request({url:r,method:"POST",data:n(i),onSuccess:function(t){try{var n=JSON.parse(t);e.plgSystemWebauthnCreateCredentials(n)}catch(t){a(e.Text._("PLG_SYSTEM_WEBAUTHN_ERR_XHR_INITCREATE"))}},onError:function(e){a(e.status+" "+e.statusText)}})}else e.renderMessages({error:[e.Text._("PLG_SYSTEM_WEBAUTHN_ERR_NO_BROWSER_SUPPORT")]})},e.plgSystemWebauthnCreateCredentials=function(r){var i=e.getOptions("system.paths"),o=""+(i?i.base+"/index.php":window.location.pathname),l=function(e){return btoa(String.fromCharCode.apply(String,e))},s=function(e){var t=e.replace(/-/g,"+").replace(/_/g,"/"),n=t.length%4;if(n){if(1===n)throw new Error("InvalidLengthError: Input base64url string is the wrong length to determine padding");t+=new Array(5-n).join("=")}return t};r.challenge=Uint8Array.from(window.atob(s(r.challenge)),(function(e){return e.charCodeAt(0)})),r.user.id=Uint8Array.from(window.atob(r.user.id),(function(e){return e.charCodeAt(0)})),r.excludeCredentials&&(r.excludeCredentials=r.excludeCredentials.map((function(e){return e.id=Uint8Array.from(window.atob(s(e.id)),(function(e){return e.charCodeAt(0)})),e}))),navigator.credentials.create({publicKey:r}).then((function(r){var i={id:r.id,type:r.type,rawId:l(new Uint8Array(r.rawId)),response:{clientDataJSON:l(new Uint8Array(r.response.clientDataJSON)),attestationObject:l(new Uint8Array(r.response.attestationObject))}},s={option:"com_ajax",group:"system",plugin:"webauthn",format:"raw",akaction:"create",encoding:"raw",data:btoa(JSON.stringify(i))};s[e.getOptions("csrf.token")]=1,e.request({url:o,method:"POST",data:n(s),onSuccess:function(n){var a=t.querySelectorAll("#plg_system_webauthn-management-interface");a&&(a[0].outerHTML=n,e.plgSystemWebauthnInitialize(),e.plgSystemWebauthnReactivateTooltips())},onError:function(e){a(e.status+" "+e.statusText)}})})).catch((function(e){a(e)}))},e.plgSystemWebauthnEditLabel=function(r){var i=e.getOptions("system.paths"),o=""+(i?i.base+"/index.php":window.location.pathname),l=r.parentElement.parentElement,s=l.dataset.credential_id,c=l.querySelectorAll(".webauthnManagementCell"),u=c[0],d=c[1].querySelectorAll("button"),p=d[0],m=d[1],g=u.innerText,b=t.createElement("div");b.className="webauthnManagementEditorRow d-flex gap-2";var h=t.createElement("input");h.type="text",h.name="label",h.defaultValue=g,h.className="form-control";var f=t.createElement("button");f.className="btn btn-success btn-sm",f.innerText=e.Text._("PLG_SYSTEM_WEBAUTHN_MANAGE_BTN_SAVE_LABEL"),f.addEventListener("click",(function(){var t=h.value;if(""!==t){var r={option:"com_ajax",group:"system",plugin:"webauthn",format:"json",encoding:"json",akaction:"savelabel",credential_id:s,new_label:t};r[e.getOptions("csrf.token")]=1,e.request({url:o,method:"POST",data:n(r),onSuccess:function(t){var n=!1;try{n=JSON.parse(t)}catch(e){n="true"===t}!0!==n&&a(e.Text._("PLG_SYSTEM_WEBAUTHN_ERR_LABEL_NOT_SAVED"))},onError:function(t){a(e.Text._("PLG_SYSTEM_WEBAUTHN_ERR_LABEL_NOT_SAVED")+" -- "+t.status+" "+t.statusText)}})}return u.innerText=t,p.disabled=!1,m.disabled=!1,!1}),!1);var E=t.createElement("button");return E.className="btn btn-danger btn-sm",E.innerText=e.Text._("PLG_SYSTEM_WEBAUTHN_MANAGE_BTN_CANCEL_LABEL"),E.addEventListener("click",(function(){return u.innerText=g,p.disabled=!1,m.disabled=!1,!1}),!1),u.innerHTML="",b.appendChild(h),b.appendChild(f),b.appendChild(E),u.appendChild(b),p.disabled=!0,m.disabled=!0,!1},e.plgSystemWebauthnDelete=function(t){if(!window.confirm(e.Text._("JGLOBAL_CONFIRM_DELETE")))return!1;var r=e.getOptions("system.paths"),i=""+(r?r.base+"/index.php":window.location.pathname),o=t.parentElement.parentElement,l=o.dataset.credential_id,s=o.querySelectorAll(".webauthnManagementCell")[1].querySelectorAll("button"),c=s[0],u=s[1];c.disabled=!0,u.disabled=!0;var d={option:"com_ajax",group:"system",plugin:"webauthn",format:"json",encoding:"json",akaction:"delete",credential_id:l};return d[e.getOptions("csrf.token")]=1,e.request({url:i,method:"POST",data:n(d),onSuccess:function(t){var n=!1;try{n=JSON.parse(t)}catch(e){n="true"===t}!0===n?o.parentElement.removeChild(o):a(e.Text._("PLG_SYSTEM_WEBAUTHN_ERR_NOT_DELETED"))},onError:function(t){c.disabled=!1,u.disabled=!1,a(e.Text._("PLG_SYSTEM_WEBAUTHN_ERR_NOT_DELETED")+" -- "+t.status+" "+t.statusText)}}),!1},e.plgSystemWebauthnReactivateTooltips=function(){var n=e.getOptions("bootstrap.tooltip");"object"==typeof n&&null!==n&&Object.keys(n).forEach((function(e){var a=n[e],r={animation:!a.animation||a.animation,container:!!a.container&&a.container,delay:a.delay?a.delay:0,html:!!a.html&&a.html,selector:!!a.selector&&a.selector,trigger:a.trigger?a.trigger:"hover focus",fallbackPlacement:a.fallbackPlacement?a.fallbackPlacement:null,boundary:a.boundary?a.boundary:"clippingParents",title:a.title?a.title:"",customClass:a.customClass?a.customClass:"",sanitize:!a.sanitize||a.sanitize,sanitizeFn:a.sanitizeFn?a.sanitizeFn:null,popperConfig:a.popperConfig?a.popperConfig:null};a.placement&&(r.placement=a.placement),a.template&&(r.template=a.template),a.allowList&&(r.allowList=a.allowList);var i=Array.from(t.querySelectorAll(e));i.length&&i.map((function(e){return new window.bootstrap.Tooltip(e,r)}))}))},e.plgSystemWebauthnAddOnClick=function(t){return t.preventDefault(),e.plgSystemWebauthnInitCreateCredentials(),!1},e.plgSystemWebauthnEditOnClick=function(t){return t.preventDefault(),e.plgSystemWebauthnEditLabel(t.currentTarget),!1},e.plgSystemWebauthnDeleteOnClick=function(t){return t.preventDefault(),e.plgSystemWebauthnDelete(t.currentTarget),!1},e.plgSystemWebauthnInitialize=function(){var n=t.getElementById("plg_system_webauthn-manage-add");n&&n.addEventListener("click",e.plgSystemWebauthnAddOnClick);var a=[].slice.call(t.querySelectorAll(".plg_system_webauthn-manage-edit"));a.length&&a.forEach((function(t){t.addEventListener("click",e.plgSystemWebauthnEditOnClick)}));var r=[].slice.call(t.querySelectorAll(".plg_system_webauthn-manage-delete"));r.length&&r.forEach((function(t){t.addEventListener("click",e.plgSystemWebauthnDeleteOnClick)}))},e.plgSystemWebauthnInitialize()}(Joomla,document)}();


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer