lemonldap-ng/lemonldap-ng-manager/site/htdocs/static/js/2ndfa.min.js
2020-11-13 06:17:45 +01:00

1 line
4.7 KiB
JavaScript

(function(){var r={_whatToTrace:[function(e,t){return"groupBy=substr("+e+",1)"},function(e,t){return e+"="+t+"*"}]},d={_whatToTrace:function(e,t,n,a){return console.log("overSchema => level",n,"over",a),1===n&&t.length>a?e+"="+t+"*&groupBy=substr("+e+","+(n+a+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(_,t,e,n,h){var p,a,f;return _.links=links,_.menulinks=menulinks,_.staticPrefix=staticPrefix,_.scriptname=scriptname,_.formPrefix=formPrefix,_.availableLanguages=availableLanguages,_.waiting=!0,_.showM=!1,_.showT=!0,_.data=[],_.currentScope=null,_.currentSession=null,_.menu=i,_.searchString="",_.U2FCheck="1",_.TOTPCheck="1",_.UBKCheck="1",_.translateP=t.translateP,_.translate=t.translate,_.translateTitle=function(e){return t.translateField(e,"title")},f="persistent",_.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(_.currentNode,_),_[e.action]();break;case"string":_[e.action]();break;default:console.log(typeof e.action)}return _.showM=!1},_.search2FA=function(e){return e&&(_.searchString=""),_.currentSession=null,_.data=[],_.updateTree2("",_.data,0,0)},_.delete2FA=function(e,t){for(var n=document.querySelectorAll(".data-"+t),a=0,r=n.length;a<r;a++)n[a].remove();return _.waiting=!0,h.delete(scriptname+"sfa/"+f+"/"+_.currentSession.id+"?type="+e+"&epoch="+t).then(function(e){return _.waiting=!1},function(e){return _.waiting=!1}),_.showT=!1},_.stoggle=function(e){var t=e.$modelValue;return 0===t.nodes.length&&_.updateTree(t.value,t.nodes,t.level,t.over,t.query,t.count),e.toggle()},_.displaySession=function(e){var t=function(e){var t,n,a,r,i,o,u,s,l,c,h,p,f,d,g,m,T,w=e._utime,y=e._session_id;for(s in e)(T=e[s])?("string"==typeof e&&T.match(/; /)&&(e[s]=T.split("; ")),"object"!=typeof e[s]&&("_password".match(new RegExp("\b"+s+"\b"))?e[s]="********":s.match(/^(_utime|_lastAuthnUTime|_lastSeen|notification)$/)?e[s]=_.localeDate(T):s.match(/^(_startTime|_updateTime)$/)&&(p=/^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})$/,p=T.match(p),e[s]=p[3]+"/"+p[2]+"/"+p[1]+" à "+p[4]+":"+p[5]+":"+p[6]))):delete e[s];for(r in f=[],v){for(g=[],o=0,l=(a=v[r]).length;o<l;o++)if(n=a[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(s in d=t[u])T=d[s],"type"===s&&(m=T),"name"===s&&(h=T),"epoch"===s&&(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:"__"+r+"__",nodes:g})}return{_utime:w,id:y,nodes:f}},e=(_.currentScope=e).$modelValue.session;return h.get(scriptname+"sfa/"+f+"/"+e).then(function(e){return _.currentSession=t(e.data)}),_.showT=!1},_.localeDate=function(e){return new Date(1e3*e).toLocaleString()},_.getLanguage=function(e){return _.lang=e,_.form="white",_.init(),_.showM=!1},a=function(e,t,n){t=t.match(/#!?\/(\w+)/);return null!==t&&!t[1].match(/^(persistent)$/)||(_.type="_session_uid"),_.init()},_.$on("$locationChangeSuccess",a),p=0,_.updateTree=function(i,o,u,s,e,t){var l,c,n;return _.waiting=!0,c=r[_.type]||r._whatToTrace,l=c[u](_.type,i,e),25<t&&d[_.type]&&(n=d[_.type](_.type,i,u,s,e))?(s++,l=n,--u):s=0,h.get(scriptname+"sfa/"+f+"?"+l+"&U2FCheck="+_.U2FCheck+"&TOTPCheck="+_.TOTPCheck+"&UBKCheck="+_.UBKCheck).then(function(e){var t,n,a,r,e=e.data;if(e.result){for(t=0,n=(r=e.values).length;t<n;t++)a=r[t],p++,a.id="node"+p,u<c.length-1&&(a.nodes=[],a.level=u+1,a.query=l,a.over=s),o.push(a);""===i&&(_.total=e.total)}return _.waiting=!1},function(e){return _.waiting=!1})},_.updateTree2=function(i,o,u,s,e,t){var l,c,n;return _.waiting=!0,c=r[_.type]||("_updateTime"===_.type?r._startTime:r._whatToTrace),l=c[u](_.type,i,e),25<t&&d[_.type]&&(n=d[_.type](_.type,i,u,s,e))?(s++,l=n,--u):s=0,h.get(scriptname+"sfa/"+f+"?_session_uid="+_.searchString+"*&groupBy=substr(_session_uid,"+_.searchString.length+")&U2FCheck="+_.U2FCheck+"&TOTPCheck="+_.TOTPCheck+"&UBKCheck="+_.UBKCheck).then(function(e){var t,n,a,r,e=e.data;if(e.result){for(t=0,n=(r=e.values).length;t<n;t++)a=r[t],p++,a.id="node"+p,u<c.length-1&&(a.nodes=[],a.level=u+1,a.query=l,a.over=s),o.push(a);""===i&&(_.total=e.total)}return _.waiting=!1},function(e){return _.waiting=!1})},_.init=function(){return _.waiting=!0,_.data=[],n.all([t.init(_.lang),_.updateTree("",_.data,0,0)]).then(function(){return _.waiting=!1},function(e){return _.waiting=!1}),_.activeModule="2ndFA",_.myStyle={color:"#ffb84d"}},e=e.path().match(/^\/(\w+)/),_.type=e?e[1]:"_whatToTrace"}])}).call(this);