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

1 line
4.8 KiB
JavaScript

!function(){var a={_whatToTrace:[function(e,t){return"groupBy=substr("+e+",1)"},function(e,t){return e+"="+t+"*"}]},d={_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,r,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 t,n,r,a,i,o,u,c,l,s,h,p,f,d,g,m,T,w=e._utime;for(c in e)(T=e[c])?("string"==typeof e&&T.match(/; /)&&(e[c]=T.split("; ")),"object"!=typeof e[c]&&("_password".match(new RegExp("\b"+c+"\b"))?e[c]="********":c.match(/^(_utime|_lastAuthnUTime|_lastSeen|notification)$/)?e[c]=y.localeDate(T):c.match(/^(_startTime|_updateTime)$/)&&(p=/^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})$/,p=T.match(p),e[c]=p[3]+"/"+p[2]+"/"+p[1]+" à "+p[4]+":"+p[5]+":"+p[6]))):delete e[c];for(a in f=[],v){for(g=[],o=0,l=(r=v[a]).length;o<l;o++)if(n=r[o],e[n])if(e[n].toString().match(/"type":\s*"(?:TOTP|U2F|UBK|WebAuthn)"/)){for(g.push({title:"type",value:"name",epoch:"date"}),u=0,s=(t=JSON.parse(e[n])).length;u<s;u++){for(c in d=t[u])T=d[c],"type"===c&&(m=T),"name"===c&&(h=T),"epoch"===c&&(i=T);g.push({title:m,value:h,epoch:i})}delete e[n]}else e[n].toString().match(/\w+/)&&g.push({title:n,value:e[n]}),delete e[n];else delete e[n];0<g.length&&f.push({title:"__"+a+"__",nodes:g})}return{_utime:w,nodes:f}};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},r=function(e,t,n){t=t.match(/#!?\/(\w+)/);return null!==t&&!t[1].match(/^(persistent)$/)||(y.type="_session_uid"),y.init()},y.$on("$locationChangeSuccess",r),p=0,y.updateTree=function(i,o,u,c,e,t){var l,s,n;return y.waiting=!0,s=a[y.type]||a._whatToTrace,l=s[u](y.type,i,e),25<t&&d[y.type]&&(n=d[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=a[y.type]||("_updateTime"===y.type?a._startTime:a._whatToTrace),l=s[u](y.type,i,e),25<t&&d[y.type]&&(n=d[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"}},e=e.path().match(/^\/(\w+)/),y.type=e?e[1]:"_whatToTrace"}])}.call(this);