lemonldap-ng/lemonldap-ng-manager/site/htdocs/static/js/2ndfa.min.js
2021-04-02 16:09:50 +02:00

1 line
4.7 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.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,l,s,c,h,p,f,d,g,m,T,w=e._utime;for(l in e)(T=e[l])?("string"==typeof e&&T.match(/; /)&&(e[l]=T.split("; ")),"object"!=typeof e[l]&&("_password".match(new RegExp("\b"+l+"\b"))?e[l]="********":l.match(/^(_utime|_lastAuthnUTime|_lastSeen|notification)$/)?e[l]=y.localeDate(T):l.match(/^(_startTime|_updateTime)$/)&&(p=/^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})$/,p=T.match(p),e[l]=p[3]+"/"+p[2]+"/"+p[1]+" à "+p[4]+":"+p[5]+":"+p[6]))):delete e[l];for(a in f=[],v){for(g=[],o=0,s=(r=v[a]).length;o<s;o++)if(n=r[o],e[n])if(e[n].toString().match(/"type":\s*"(?:TOTP|U2F|UBK)"/)){for(g.push({title:"type",value:"name",epoch:"date"}),u=0,c=(t=JSON.parse(e[n])).length;u<c;u++){for(l in d=t[u])T=d[l],"type"===l&&(m=T),"name"===l&&(h=T),"epoch"===l&&(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,l,e,t){var s,c,n;return y.waiting=!0,c=a[y.type]||a._whatToTrace,s=c[u](y.type,i,e),25<t&&d[y.type]&&(n=d[y.type](y.type,i,u,l,e))?(l++,s=n,u-=1):l=0,h.get(scriptname+"sfa/"+f+"?"+s+"&U2FCheck="+y.U2FCheck+"&TOTPCheck="+y.TOTPCheck+"&UBKCheck="+y.UBKCheck).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<c.length-1&&(r.nodes=[],r.level=u+1,r.query=s,r.over=l),o.push(r);""===i&&(y.total=e.total)}return y.waiting=!1},function(e){return y.waiting=!1})},y.updateTree2=function(i,o,u,l,e,t){var s,c,n;return y.waiting=!0,c=a[y.type]||("_updateTime"===y.type?a._startTime:a._whatToTrace),s=c[u](y.type,i,e),25<t&&d[y.type]&&(n=d[y.type](y.type,i,u,l,e))?(l++,s=n,u-=1):l=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).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<c.length-1&&(r.nodes=[],r.level=u+1,r.query=s,r.over=l),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);