lemonldap-ng/lemonldap-ng-manager/site/htdocs/static/js/2ndfa.min.js

1 line
4.9 KiB
JavaScript

!function(){var r={_whatToTrace:[function(e,t){return"groupBy=substr("+e+",1)"},function(e,t){return e+"="+t+"*"}]},a={_whatToTrace:function(e,t,n,r){return console.log("overSchema => level",n,"over",r),1===n&&t.length>r?e+"="+t+"*&groupBy=substr("+e+","+(n+r+1)+")":null}},v={dateTitle:["_utime","_startTime","_updateTime"],sfaTitle:["_2fDevices"]},i={home:[]};angular.module("llngSessionsExplorer",["ui.tree","ui.bootstrap","llApp"]).controller("SessionsExplorerCtrl",["$scope","$translator","$location","$q","$http",function(y,t,e,n,h){var p,f;return y.links=links,y.menulinks=menulinks,y.staticPrefix=staticPrefix,y.scriptname=scriptname,y.formPrefix=formPrefix,y.availableLanguages=availableLanguages,y.waiting=!0,y.showM=!1,y.showT=!0,y.data=[],y.currentScope=null,y.currentSession=null,y.menu=i,y.searchString="",y.U2FCheck="1",y.TOTPCheck="1",y.UBKCheck="1",y.WebAuthnCheck="1",y.translateP=t.translateP,y.translate=t.translate,y.translateTitle=function(e){return t.translateField(e,"title")},f="persistent",y.menuClick=function(e){if(e.popup)window.open(e.popup);else switch(e.action||(e.action=e.title),typeof e.action){case"function":e.action(y.currentNode,y),y[e.action]();break;case"string":y[e.action]();break;default:console.log(typeof e.action)}return y.showM=!1},y.search2FA=function(e){return e&&(y.searchString=""),y.currentSession=null,y.data=[],y.updateTree2("",y.data,0,0)},y.delete2FA=function(e,t){for(var n=document.querySelectorAll(".data-"+t),r=0,a=n.length;r<a;r++)n[r].remove();return y.waiting=!0,h.delete(scriptname+"sfa/"+f+"/"+y.currentSession.id+"?type="+e+"&epoch="+t).then(function(e){return y.waiting=!1},function(e){return y.waiting=!1}),y.showT=!1},y.stoggle=function(e){var t=e.$modelValue;return 0===t.nodes.length&&y.updateTree(t.value,t.nodes,t.level,t.over,t.query,t.count),e.toggle()},y.displaySession=function(e){var t,n=function(e){var s,t,n,h,r,p,a,i,o,f,d,g,u,m,c,T,l,w=e._utime;for(o in e)(l=e[o])?("string"==typeof e&&l.match(/; /)&&(e[o]=l.split("; ")),"object"!=typeof e[o]&&("_password".match(new RegExp("\b"+o+"\b"))?e[o]="********":o.match(/^(_utime|_lastAuthnUTime|_lastSeen|notification)$/)?e[o]=y.localeDate(l):o.match(/^(_startTime|_updateTime)$/)&&(t=l.match(/^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})$/),e[o]=t[3]+"/"+t[2]+"/"+t[1]+" à "+t[4]+":"+t[5]+":"+t[6]))):delete e[o];for(r in u=[],v){for(c=[],a=0,f=(h=v[r]).length;a<f;a++)if(n=h[a],e[n])if(e[n].toString().match(/"type":\s*"(?:TOTP|U2F|UBK|WebAuthn)"/)){for(c.push({title:"type",value:"name",epoch:"date"}),i=0,d=(s=JSON.parse(e[n])).length;i<d;i++){for(o in m=s[i])l=m[o],"type"===o&&(T=l),"name"===o&&(g=l),"epoch"===o&&(p=l);c.push({title:T,value:g,epoch:p})}delete e[n]}else e[n].toString().match(/\w+/)&&c.push({title:n,value:e[n]}),delete e[n];else delete e[n];0<c.length&&u.push({title:"__"+r+"__",nodes:c})}return{_utime:w,nodes:u}};return y.currentScope=e,t=e.$modelValue.session,h.get(scriptname+"sfa/"+f+"/"+t).then(function(e){return y.currentSession=n(e.data),y.currentSession.id=t}),y.showT=!1},y.localeDate=function(e){return new Date(1e3*e).toLocaleString()},y.getLanguage=function(e){return y.lang=e,y.form="white",y.init(),y.showM=!1},y.$on("$locationChangeSuccess",function(e,t,n){t=t.match(/#!?\/(\w+)/);return null!==t&&!t[1].match(/^(persistent)$/)||(y.type="_session_uid"),y.init()}),p=0,y.updateTree=function(i,o,u,c,e,t){var l,s,n;return y.waiting=!0,s=r[y.type]||r._whatToTrace,l=s[u](y.type,i,e),25<t&&a[y.type]&&(n=a[y.type](y.type,i,u,c,e))?(c++,l=n,u-=1):c=0,h.get(scriptname+"sfa/"+f+"?"+l+"&U2FCheck="+y.U2FCheck+"&TOTPCheck="+y.TOTPCheck+"&UBKCheck="+y.UBKCheck+"&WebAuthnCheck="+y.WebAuthnCheck).then(function(e){var t,n,r,a,e=e.data;if(e.result){for(t=0,n=(a=e.values).length;t<n;t++)r=a[t],p++,r.id="node"+p,u<s.length-1&&(r.nodes=[],r.level=u+1,r.query=l,r.over=c),o.push(r);""===i&&(y.total=e.total)}return y.waiting=!1},function(e){return y.waiting=!1})},y.updateTree2=function(i,o,u,c,e,t){var l,s,n;return y.waiting=!0,s=r[y.type]||("_updateTime"===y.type?r._startTime:r._whatToTrace),l=s[u](y.type,i,e),25<t&&a[y.type]&&(n=a[y.type](y.type,i,u,c,e))?(c++,l=n,u-=1):c=0,h.get(scriptname+"sfa/"+f+"?_session_uid="+y.searchString+"*&groupBy=substr(_session_uid,"+y.searchString.length+")&U2FCheck="+y.U2FCheck+"&TOTPCheck="+y.TOTPCheck+"&UBKCheck="+y.UBKCheck+"&WebAuthnCheck="+y.WebAuthnCheck).then(function(e){var t,n,r,a,e=e.data;if(e.result){for(t=0,n=(a=e.values).length;t<n;t++)r=a[t],p++,r.id="node"+p,u<s.length-1&&(r.nodes=[],r.level=u+1,r.query=l,r.over=c),o.push(r);""===i&&(y.total=e.total)}return y.waiting=!1},function(e){return y.waiting=!1})},y.init=function(){return y.waiting=!0,y.data=[],n.all([t.init(y.lang),y.updateTree("",y.data,0,0)]).then(function(){return y.waiting=!1},function(e){return y.waiting=!1}),y.activeModule="2ndFA",y.myStyle={color:"#ffb84d"},y.bannerStyle={"background-color":""+window.bannerColor}},e=e.path().match(/^\/(\w+)/),y.type=e?e[1]:"_whatToTrace"}])}.call(this);