Current File : /home/pacjaorg/.trash/media.1/plg_system_webauthn/js/management.min.js
/**
 * @package     Joomla.Plugin
 * @subpackage  System.webauthn
 *
 * @copyright   (C) 2020 Open Source Matters, Inc. <https://www.joomla.org>
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */window.Joomla=window.Joomla||{},((t,d)=>{const _=(n,r="")=>{let e="";return Object.keys(n).forEach(a=>{if(typeof n[a]!="object"){e.length>0&&(e+="&"),r===""?e+=`${encodeURIComponent(a)}=${encodeURIComponent(n[a])}`:e+=`${encodeURIComponent(r)}[${encodeURIComponent(a)}]=${encodeURIComponent(n[a])}`;return}e+=`${_(n[a],a)}`}),e},g=n=>{t.renderMessages({error:[n]})};t.plgSystemWebauthnInitCreateCredentials=()=>{if(!("credentials"in navigator)){t.renderMessages({error:[t.Text._("PLG_SYSTEM_WEBAUTHN_ERR_NO_BROWSER_SUPPORT")]});return}const n=t.getOptions("system.paths"),r=`${n?`${n.base}/index.php`:window.location.pathname}`,e={option:"com_ajax",group:"system",plugin:"webauthn",format:"json",akaction:"initcreate",encoding:"json"};e[t.getOptions("csrf.token")]=1,t.request({url:r,method:"POST",data:_(e),onSuccess(a){try{const i=JSON.parse(a);t.plgSystemWebauthnCreateCredentials(i)}catch{g(t.Text._("PLG_SYSTEM_WEBAUTHN_ERR_XHR_INITCREATE"))}},onError:a=>{g(`${a.status} ${a.statusText}`)}})},t.plgSystemWebauthnCreateCredentials=n=>{const r=t.getOptions("system.paths"),e=`${r?`${r.base}/index.php`:window.location.pathname}`,a=s=>btoa(String.fromCharCode(...s)),i=s=>{let l=s.replace(/-/g,"+").replace(/_/g,"/");const c=l.length%4;if(c){if(c===1)throw new Error("InvalidLengthError: Input base64url string is the wrong length to determine padding");l+=new Array(5-c).join("=")}return l};n.challenge=Uint8Array.from(window.atob(i(n.challenge)),s=>s.charCodeAt(0)),n.user.id=Uint8Array.from(window.atob(n.user.id),s=>s.charCodeAt(0)),n.excludeCredentials&&(n.excludeCredentials=n.excludeCredentials.map(s=>(s.id=Uint8Array.from(window.atob(i(s.id)),l=>l.charCodeAt(0)),s))),navigator.credentials.create({publicKey:n}).then(s=>{const l={id:s.id,type:s.type,rawId:a(new Uint8Array(s.rawId)),response:{clientDataJSON:a(new Uint8Array(s.response.clientDataJSON)),attestationObject:a(new Uint8Array(s.response.attestationObject))}},c={option:"com_ajax",group:"system",plugin:"webauthn",format:"raw",akaction:"create",encoding:"raw",data:btoa(JSON.stringify(l))};c[t.getOptions("csrf.token")]=1,t.request({url:e,method:"POST",data:_(c),onSuccess(o){const u=d.querySelectorAll("#plg_system_webauthn-management-interface");if(!u)return;const h=u[0];h.outerHTML=o,t.plgSystemWebauthnInitialize(),t.plgSystemWebauthnReactivateTooltips()},onError:o=>{g(`${o.status} ${o.statusText}`)}})}).catch(s=>{g(s)})},t.plgSystemWebauthnEditLabel=n=>{const r=t.getOptions("system.paths"),e=`${r?`${r.base}/index.php`:window.location.pathname}`,a=n.parentElement.parentElement,i=a.dataset.credential_id,s=a.querySelectorAll(".webauthnManagementCell"),l=s[0],o=s[1].querySelectorAll("button"),u=o[0],h=o[1],E=l.innerText,p=d.createElement("div");p.className="webauthnManagementEditorRow d-flex gap-2";const b=d.createElement("input");b.type="text",b.name="label",b.defaultValue=E,b.className="form-control";const T=d.createElement("button");T.className="btn btn-success btn-sm",T.innerText=t.Text._("PLG_SYSTEM_WEBAUTHN_MANAGE_BTN_SAVE_LABEL"),T.addEventListener("click",()=>{const m=b.value;if(m!==""){const w={option:"com_ajax",group:"system",plugin:"webauthn",format:"json",encoding:"json",akaction:"savelabel",credential_id:i,new_label:m};w[t.getOptions("csrf.token")]=1,t.request({url:e,method:"POST",data:_(w),onSuccess(f){let y=!1;try{y=JSON.parse(f)}catch{y=f==="true"}y!==!0&&g(t.Text._("PLG_SYSTEM_WEBAUTHN_ERR_LABEL_NOT_SAVED"))},onError:f=>{g(`${t.Text._("PLG_SYSTEM_WEBAUTHN_ERR_LABEL_NOT_SAVED")} -- ${f.status} ${f.statusText}`)}})}return l.innerText=m,u.disabled=!1,h.disabled=!1,!1},!1);const S=d.createElement("button");return S.className="btn btn-danger btn-sm",S.innerText=t.Text._("PLG_SYSTEM_WEBAUTHN_MANAGE_BTN_CANCEL_LABEL"),S.addEventListener("click",()=>(l.innerText=E,u.disabled=!1,h.disabled=!1,!1),!1),l.innerHTML="",p.appendChild(b),p.appendChild(T),p.appendChild(S),l.appendChild(p),u.disabled=!0,h.disabled=!0,!1},t.plgSystemWebauthnDelete=n=>{if(!window.confirm(t.Text._("JGLOBAL_CONFIRM_DELETE")))return!1;const r=t.getOptions("system.paths"),e=`${r?`${r.base}/index.php`:window.location.pathname}`,a=n.parentElement.parentElement,i=a.dataset.credential_id,c=a.querySelectorAll(".webauthnManagementCell")[1].querySelectorAll("button"),o=c[0],u=c[1];o.disabled=!0,u.disabled=!0;const h={option:"com_ajax",group:"system",plugin:"webauthn",format:"json",encoding:"json",akaction:"delete",credential_id:i};return h[t.getOptions("csrf.token")]=1,t.request({url:e,method:"POST",data:_(h),onSuccess(E){let p=!1;try{p=JSON.parse(E)}catch{p=E==="true"}if(p!==!0){g(t.Text._("PLG_SYSTEM_WEBAUTHN_ERR_NOT_DELETED"));return}a.parentElement.removeChild(a)},onError:E=>{o.disabled=!1,u.disabled=!1,g(`${t.Text._("PLG_SYSTEM_WEBAUTHN_ERR_NOT_DELETED")} -- ${E.status} ${E.statusText}`)}}),!1},t.plgSystemWebauthnReactivateTooltips=()=>{const n=t.getOptions("bootstrap.tooltip");typeof n=="object"&&n!==null&&Object.keys(n).forEach(r=>{const e=n[r],a={animation:e.animation?e.animation:!0,container:e.container?e.container:!1,delay:e.delay?e.delay:0,html:e.html?e.html:!1,selector:e.selector?e.selector:!1,trigger:e.trigger?e.trigger:"hover focus",fallbackPlacement:e.fallbackPlacement?e.fallbackPlacement:null,boundary:e.boundary?e.boundary:"clippingParents",title:e.title?e.title:"",customClass:e.customClass?e.customClass:"",sanitize:e.sanitize?e.sanitize:!0,sanitizeFn:e.sanitizeFn?e.sanitizeFn:null,popperConfig:e.popperConfig?e.popperConfig:null};e.placement&&(a.placement=e.placement),e.template&&(a.template=e.template),e.allowList&&(a.allowList=e.allowList);const i=Array.from(d.querySelectorAll(r));i.length&&i.map(s=>new window.bootstrap.Tooltip(s,a))})},t.plgSystemWebauthnAddOnClick=n=>(n.preventDefault(),t.plgSystemWebauthnInitCreateCredentials(),!1),t.plgSystemWebauthnEditOnClick=n=>(n.preventDefault(),t.plgSystemWebauthnEditLabel(n.currentTarget),!1),t.plgSystemWebauthnDeleteOnClick=n=>(n.preventDefault(),t.plgSystemWebauthnDelete(n.currentTarget),!1),t.plgSystemWebauthnInitialize=()=>{const n=d.getElementById("plg_system_webauthn-manage-add");n&&n.addEventListener("click",t.plgSystemWebauthnAddOnClick),d.querySelectorAll(".plg_system_webauthn-manage-edit").forEach(r=>r.addEventListener("click",t.plgSystemWebauthnEditOnClick)),d.querySelectorAll(".plg_system_webauthn-manage-delete").forEach(r=>r.addEventListener("click",t.plgSystemWebauthnDeleteOnClick))},t.plgSystemWebauthnInitialize()})(Joomla,document);
Site is undergoing maintenance

PACJA Events

Maintenance mode is on

Site will be available soon. Thank you for your patience!