[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

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

   1  window.Joomla=window.Joomla||{},((e,t)=>{const n=(e,t="")=>{let a="";return Object.keys(e).forEach((l=>{if("object"!=typeof e[l])return a.length>0&&(a+="&"),void(a+=""===t?`$encodeURIComponent(l)}=$encodeURIComponent(e[l])}`:`$encodeURIComponent(t)}[$encodeURIComponent(l)}]=$encodeURIComponent(e[l])}`);a+=`$n(e[l],l)}`})),a},a=t=>{e.renderMessages({error:[t]})};e.plgSystemWebauthnInitCreateCredentials=()=>{if(!("credentials"in navigator))return void e.renderMessages({error:[e.Text._("PLG_SYSTEM_WEBAUTHN_ERR_NO_BROWSER_SUPPORT")]});const t=e.getOptions("system.paths"),l=`$t?`$t.base}/index.php`:window.location.pathname}`,o={option:"com_ajax",group:"system",plugin:"webauthn",format:"json",akaction:"initcreate",encoding:"json"};o[e.getOptions("csrf.token")]=1,e.request({url:l,method:"POST",data:n(o),onSuccess(t){try{const n=JSON.parse(t);e.plgSystemWebauthnCreateCredentials(n)}catch(t){a(e.Text._("PLG_SYSTEM_WEBAUTHN_ERR_XHR_INITCREATE"))}},onError:e=>{a(`$e.status} $e.statusText}`)}})},e.plgSystemWebauthnCreateCredentials=l=>{const o=e.getOptions("system.paths"),r=`$o?`$o.base}/index.php`:window.location.pathname}`,s=e=>btoa(String.fromCharCode(...e)),i=e=>{let t=e.replace(/-/g,"+").replace(/_/g,"/");const 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};l.challenge=Uint8Array.from(window.atob(i(l.challenge)),(e=>e.charCodeAt(0))),l.user.id=Uint8Array.from(window.atob(l.user.id),(e=>e.charCodeAt(0))),l.excludeCredentials&&(l.excludeCredentials=l.excludeCredentials.map((e=>(e.id=Uint8Array.from(window.atob(i(e.id)),(e=>e.charCodeAt(0))),e)))),navigator.credentials.create({publicKey:l}).then((l=>{const o={id:l.id,type:l.type,rawId:s(new Uint8Array(l.rawId)),response:{clientDataJSON:s(new Uint8Array(l.response.clientDataJSON)),attestationObject:s(new Uint8Array(l.response.attestationObject))}},i={option:"com_ajax",group:"system",plugin:"webauthn",format:"raw",akaction:"create",encoding:"raw",data:btoa(JSON.stringify(o))};i[e.getOptions("csrf.token")]=1,e.request({url:r,method:"POST",data:n(i),onSuccess(n){const a=t.querySelectorAll("#plg_system_webauthn-management-interface");if(!a)return;a[0].outerHTML=n,e.plgSystemWebauthnInitialize(),e.plgSystemWebauthnReactivateTooltips()},onError:e=>{a(`$e.status} $e.statusText}`)}})})).catch((e=>{a(e)}))},e.plgSystemWebauthnEditLabel=l=>{const o=e.getOptions("system.paths"),r=`$o?`$o.base}/index.php`:window.location.pathname}`,s=l.parentElement.parentElement,i=s.dataset.credential_id,c=s.querySelectorAll(".webauthnManagementCell"),d=c[0],p=c[1].querySelectorAll("button"),u=p[0],m=p[1],g=d.innerText,b=t.createElement("div");b.className="webauthnManagementEditorRow d-flex gap-2";const h=t.createElement("input");h.type="text",h.name="label",h.defaultValue=g,h.className="form-control";const E=t.createElement("button");E.className="btn btn-success btn-sm",E.innerText=e.Text._("PLG_SYSTEM_WEBAUTHN_MANAGE_BTN_SAVE_LABEL"),E.addEventListener("click",(()=>{const t=h.value;if(""!==t){const l={option:"com_ajax",group:"system",plugin:"webauthn",format:"json",encoding:"json",akaction:"savelabel",credential_id:i,new_label:t};l[e.getOptions("csrf.token")]=1,e.request({url:r,method:"POST",data:n(l),onSuccess(t){let 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:t=>{a(`$e.Text._("PLG_SYSTEM_WEBAUTHN_ERR_LABEL_NOT_SAVED")} -- $t.status} $t.statusText}`)}})}return d.innerText=t,u.disabled=!1,m.disabled=!1,!1}),!1);const _=t.createElement("button");return _.className="btn btn-danger btn-sm",_.innerText=e.Text._("PLG_SYSTEM_WEBAUTHN_MANAGE_BTN_CANCEL_LABEL"),_.addEventListener("click",(()=>(d.innerText=g,u.disabled=!1,m.disabled=!1,!1)),!1),d.innerHTML="",b.appendChild(h),b.appendChild(E),b.appendChild(_),d.appendChild(b),u.disabled=!0,m.disabled=!0,!1},e.plgSystemWebauthnDelete=t=>{if(!window.confirm(e.Text._("JGLOBAL_CONFIRM_DELETE")))return!1;const l=e.getOptions("system.paths"),o=`$l?`$l.base}/index.php`:window.location.pathname}`,r=t.parentElement.parentElement,s=r.dataset.credential_id,i=r.querySelectorAll(".webauthnManagementCell")[1].querySelectorAll("button"),c=i[0],d=i[1];c.disabled=!0,d.disabled=!0;const p={option:"com_ajax",group:"system",plugin:"webauthn",format:"json",encoding:"json",akaction:"delete",credential_id:s};return p[e.getOptions("csrf.token")]=1,e.request({url:o,method:"POST",data:n(p),onSuccess(t){let n=!1;try{n=JSON.parse(t)}catch(e){n="true"===t}!0===n?r.parentElement.removeChild(r):a(e.Text._("PLG_SYSTEM_WEBAUTHN_ERR_NOT_DELETED"))},onError:t=>{c.disabled=!1,d.disabled=!1,a(`$e.Text._("PLG_SYSTEM_WEBAUTHN_ERR_NOT_DELETED")} -- $t.status} $t.statusText}`)}}),!1},e.plgSystemWebauthnReactivateTooltips=()=>{const n=e.getOptions("bootstrap.tooltip");"object"==typeof n&&null!==n&&Object.keys(n).forEach((e=>{const a=n[e],l={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&&(l.placement=a.placement),a.template&&(l.template=a.template),a.allowList&&(l.allowList=a.allowList);const o=Array.from(t.querySelectorAll(e));o.length&&o.map((e=>new window.bootstrap.Tooltip(e,l)))}))},e.plgSystemWebauthnAddOnClick=t=>(t.preventDefault(),e.plgSystemWebauthnInitCreateCredentials(),!1),e.plgSystemWebauthnEditOnClick=t=>(t.preventDefault(),e.plgSystemWebauthnEditLabel(t.currentTarget),!1),e.plgSystemWebauthnDeleteOnClick=t=>(t.preventDefault(),e.plgSystemWebauthnDelete(t.currentTarget),!1),e.plgSystemWebauthnInitialize=()=>{const n=t.getElementById("plg_system_webauthn-manage-add");n&&n.addEventListener("click",e.plgSystemWebauthnAddOnClick);const a=[].slice.call(t.querySelectorAll(".plg_system_webauthn-manage-edit"));a.length&&a.forEach((t=>{t.addEventListener("click",e.plgSystemWebauthnEditOnClick)}));const l=[].slice.call(t.querySelectorAll(".plg_system_webauthn-manage-delete"));l.length&&l.forEach((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