"use strict";function_typeof(a){"@babel/helpers - typeof";return_typeof="function"==typeofSymbol&&"symbol"==typeofSymbol.iterator?function(a){returntypeofa}:function(a){returna&&"function"==typeofSymbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeofa},_typeof(a)}var_fs=_interopRequireDefault(require("fs")),_async=_interopRequireDefault(require("async")),_bcryptjs=_interopRequireDefault(require("bcryptjs")),passportSaml=_interopRequireWildcard(require("passport-saml")),_dbconn=require("../config/dbconn"),_dbController=require("../controller/dbController"),_gitlabController=require("../controller/gitlabController"),_const=require("../config/const"),_mailer=require("../config/mailer"),_user=require("../classes/user"),_website=require("../classes/website"),_repo=require("../classes/repo");function_getRequireWildcardCache(a){if("function"!=typeofWeakMap)returnnull;varb=newWeakMap,c=newWeakMap;return(_getRequireWildcardCache=function(a){returna?c:b})(a)}function_interopRequireWildcard(a,b){if(!b&&a&&a.__esModule)returna;if(null===a||"object"!==_typeof(a)&&"function"!=typeofa)return{default:a};varc=_getRequireWildcardCache(b);if(c&&c.has(a))returnc.get(a);vard={},e=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(varfina)if("default"!=f&&Object.prototype.hasOwnProperty.call(a,f)){varg=e?Object.getOwnPropertyDescriptor(a,f):null;g&&(g.get||g.set)?Object.defineProperty(d,f,g):d[f]=a[f]}returnd["default"]=a,c&&c.set(a,d),d}function_interopRequireDefault(a){returna&&a.__esModule?a:{default:a}}function_regeneratorRuntime(){"use strict";/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */functiona(a,b,c){returnObject.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}),a[b]}functionb(a,b,e,f){varg=b&&b.prototypeinstanceofd?b:d,h=Object.create(g.prototype),j=newl(f||[]);returnh._invoke=function(a,b,d){vare="suspendedStart";returnfunction(f,g){if("executing"===e)thrownewError("Generator is already running");if("completed"===e){if("throw"===f)throwg;returnn()}for(d.method=f,d.arg=g;;){varh=d.delegate;if(h){varj=i(h,d);if(j){if(j===v)continue;returnj}}if("next"===d.method)d.sent=d._sent=d.arg;elseif("throw"===d.method){if("suspendedStart"===e)throwe="completed",d.arg;d.dispatchException(d.arg)}else"return"===d.method&&d.abrupt("return",d.arg);e="executing";vark=c(a,b,d);if("normal"===k.type){if(e=d.done?"completed":"suspendedYield",k.arg===v)continue;return{value:k.arg,done:d.done}}"throw"===k.type&&(e="completed",d.method="throw",d.arg=k.arg)}}}(a,e,j),h}functionc(a,b,c){try{return{type:"normal",arg:a.call(b,c)}}catch(a){return{type:"throw",arg:a}}}functiond(){}functione(){}functionf(){}functiong(b){["next","throw","return"].forEach(function(c){a(b,c,function(a){returnthis._invoke(c,a)})})}functionh(a,b){functiond(e,f,g,h){vari=c(a[e],a,f);if("throw"!==i.type){varj=i.arg,k=j.value;returnk&&"object"==_typeof(k)&&q.call(k,"__await")?b.resolve(k.__await).then(function(a){d("next",a,g,h)},function(a){d("throw",a,g,h)}):b.resolve(k).then(function(a){j.value=a,g(j)},function(a){returnd("throw",a,g,h)})}h(i.arg)}vare;this._invoke=function(a,c){functionf(){returnnewb(function(b,e){d(a,c,b,e)})}returne=e?e.then(f,f):f()}}functioni(a,b){vard=a.iterator[b.method];if(void0===d){if(b.delegate=null,"throw"===b.method){if(a.iterator["return"]&&(b.method="return",b.arg=void0,i(a,b),"throw"===b.method))returnv;b.method="throw",b.arg=newTypeError("The iterator does not provide a 'throw' method")}returnv}vare=c(d,a.iterator,b.arg);if("throw"===e.type)returnb.method="throw",b.arg=e.arg,b.delegate=null,v;varf=e.arg;returnf?f.done?(b[a.resultName]=f.value,b.next=a.nextLoc,"return"!==b.method&&(b.method="next",b.arg=void0),b.delegate=null,v):f:(b.method="throw",b.arg=newTypeError("iterator result is not an object"),b.delegate=null,v)}functionj(a){varb={tryLoc:a[0]};1ina&&(b.catchLoc=a[1]),2ina&&(b.finallyLoc=a[2],b.afterLoc=a[3]),this.tryEntries.push(b)}functionk(a){varb=a.completion||{};b.type="normal",deleteb.arg,a.completion=b}functionl(a){this.tryEntries=[{tryLoc:"root"}],a.forEach(j,this),this.reset(!0)}functionm(a){if(a){varb=a[s];if(b)returnb.call(a);if("function"==typeofa.next)returna;if(!isNaN(a.length)){varc=-1,d=functionb(){for(;++c<a.length;)if(q.call(a,c))returnb.value=a[c],b.done=!1,b;returnb.value=void0,b.done=!0,b};returnd.next=d}}return{next:n}}functionn(){return{value:void0,done:!0}}_regeneratorRuntime=function(){returno};varo={},p=Object.prototype,q=p.hasOwnProperty,r="function"==typeofSymbol?Symbol:{},s=r.iterator||"@@iterator",t=r.asyncIterator||"@@asyncIterator",u=r.toStringTag||"@@toStringTag";try{a({},"")}catch(b){a=function(a,b,c){returna[b]=c}}o.wrap=b;varv={},w={};a(w,s,function(){returnthis});varx=Object.getPrototypeOf,y=x&&x(x(m([])));y&&y!==p&&q.call(y,s)&&(w=y);varz=f.prototype=d.prototype=Object.create(w);returne.prototype=f,a(z,"constructor",f),a(f,"constructor",e),e.displayName=a(f,u,"GeneratorFunction"),o.isGeneratorFunction=function(a){varb="function"==typeofa&&a.constructor;return!!b&&(b===e||"GeneratorFunction"===(b.displayName||b.name))},o.mark=function(b){returnObject.setPrototypeOf?Object.setPrototypeOf(b,f):(b.__proto__=f,a(b,u,"GeneratorFunction")),b.prototype=Object.create(z),b},o.awrap=function(a){return{__await:a}},g(h.prototype),a(h.prototype,t,function(){returnthis}),o.AsyncIterator=h,o.async=function(a,c,d,e,f){void0===f&&(f=Promise);varg=newh(b(a,c,d,e),f);returno.isGeneratorFunction(c)?g:g.next().then(function(a){returna.done?a.value:g.next()})},g(z),a(z,u,"Generator"),a(z,s,function(){returnthis}),a(z,"toString",function(){return"[object Generator]"}),o.keys=function(a){varb=[];for(varcina)b.push(c);returnb.reverse(),functionc(){for(;b.length;){vard=b.pop();if(dina)returnc.value=d,c.done=!1,c}returnc.done=!0,c}},o.values=m,l.prototype={constructor:l,reset:functionreset(a){if(this.prev=0,this.next=0,this.sent=this._sent=void0,this.done=!1,this.delegate=null,this.method="next",this.arg=void0,this.tryEntries.forEach(k),!a)for(varbinthis)"t"===b.charAt(0)&&q.call(this,b)&&!isNaN(+b.slice(1))&&(this[b]=void0)},stop:functionstop(){this.done=!0;vara=this.tryEntries[0].completion;if("throw"===a.type)throwa.arg;returnthis.rval},dispatchException:functiondispatchException(a){functionb(b,d){returnf.type="throw",f.arg=a,c.next=b,d&&(c.method="next",c.arg=void0),!!d}if(this.done)throwa;for(varc=this,d=this.tryEntries.length-1;0<=d;--d){vare=this.tryEntries[d],f=e.completion;if("root"===e.tryLoc)returnb("end");if(e.tryLoc<=this.prev){varg=q.call(e,"catchLoc"),h=q.call(e,"finallyLoc");if(g&&h){if(this.prev<e.catchLoc)returnb(e.catchLoc,!0);if(this.prev<e.finallyLoc)returnb(e.finallyLoc)}elseif(!g){if(!h)thrownewError("try statement without catch or finally");if(this.prev<e.finallyLoc)returnb(e.finallyLoc)}elseif(this.prev<e.catchLoc)returnb(e.catchLoc,!0)}}},abrupt:functionabrupt(a,b){for(varc,d=this.tryEntries.length-1;0<=d;--d)if(c=this.tryEntries[d],c.tryLoc<=this.prev&&q.call(c,"finallyLoc")&&this.prev<c.finallyLoc){vare=c;break}e&&("break"===a||"continue"===a)&&e.tryLoc<=b&&b<=e.finallyLoc&&(e=null);varf=e?e.completion:{};returnf.type=a,f.arg=b,e?(this.method="next",this.next=e.finallyLoc,v):this.complete(f)},complete:functioncomplete(a,b){if("throw"===a.type)throwa.arg;return"break"===a.type||"continue"===a.type?this.next=a.arg:"return"===a.type?(this.rval=this.arg=a.arg,this.method="return",this.next="end"):"normal"===a.type&&b&&(this.next=b),v},finish:functionfinish(a){for(varb,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.finallyLoc===a)returnthis.complete(b.completion,b.afterLoc),k(b),v},catch:function_catch(a){for(varb,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.tryLoc===a){vard=b.completion;if("throw"===d.type){vare=d.arg;k(b)}returne}thrownewError("illegal catch attempt")},delegateYield:functiondelegateYield(a,b,c){returnthis.delegate={iterator:m(a),resultName:b,nextLoc:c},"next"===this.method&&(this.arg=void0),v}},o}functionasyncGeneratorStep(a,b,c,d,e,f,g){try{varh=a[f](g),i=h.value}catch(a){returnvoidc(a)}h.done?b(i):Promise.resolve(i).then(d,e)}function_asyncToGenerator(a){returnfunction(){varb=this,c=arguments;returnnewPromise(function(d,e){functionf(a){asyncGeneratorStep(h,d,e,f,g,"next",a)}functiong(a){asyncGeneratorStep(h,d,e,f,g,"throw",a)}varh=a.apply(b,c);f(void0)})}}varSamlStrategy=passportSaml.Strategy,saltRounds=10,salt=64,logoDir="public/upload/",defaultLogo="public/default/logo.png";module.exports=function(a,b,c,d){// ======== APP ROUTES - ACCOUNT ====================
"use strict";function_typeof(a){"@babel/helpers - typeof";return_typeof="function"==typeofSymbol&&"symbol"==typeofSymbol.iterator?function(a){returntypeofa}:function(a){returna&&"function"==typeofSymbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeofa},_typeof(a)}var_fs=_interopRequireDefault(require("fs")),_async=_interopRequireDefault(require("async")),_bcryptjs=_interopRequireDefault(require("bcryptjs")),passportSaml=_interopRequireWildcard(require("passport-saml")),_dbconn=require("../config/dbconn"),_dbController=require("../controller/dbController"),_gitlabController=require("../controller/gitlabController"),_const=require("../config/const"),_mailer=require("../config/mailer"),_user=require("../classes/user"),_website=require("../classes/website"),_repo=require("../classes/repo");function_getRequireWildcardCache(a){if("function"!=typeofWeakMap)returnnull;varb=newWeakMap,c=newWeakMap;return(_getRequireWildcardCache=function(a){returna?c:b})(a)}function_interopRequireWildcard(a,b){if(!b&&a&&a.__esModule)returna;if(null===a||"object"!==_typeof(a)&&"function"!=typeofa)return{default:a};varc=_getRequireWildcardCache(b);if(c&&c.has(a))returnc.get(a);vard={},e=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(varfina)if("default"!=f&&Object.prototype.hasOwnProperty.call(a,f)){varg=e?Object.getOwnPropertyDescriptor(a,f):null;g&&(g.get||g.set)?Object.defineProperty(d,f,g):d[f]=a[f]}returnd["default"]=a,c&&c.set(a,d),d}function_interopRequireDefault(a){returna&&a.__esModule?a:{default:a}}function_regeneratorRuntime(){"use strict";/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */functiona(a,b,c){returnObject.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}),a[b]}functionb(a,b,e,f){varg=b&&b.prototypeinstanceofd?b:d,h=Object.create(g.prototype),j=newl(f||[]);returnh._invoke=function(a,b,d){vare="suspendedStart";returnfunction(f,g){if("executing"===e)thrownewError("Generator is already running");if("completed"===e){if("throw"===f)throwg;returnn()}for(d.method=f,d.arg=g;;){varh=d.delegate;if(h){varj=i(h,d);if(j){if(j===v)continue;returnj}}if("next"===d.method)d.sent=d._sent=d.arg;elseif("throw"===d.method){if("suspendedStart"===e)throwe="completed",d.arg;d.dispatchException(d.arg)}else"return"===d.method&&d.abrupt("return",d.arg);e="executing";vark=c(a,b,d);if("normal"===k.type){if(e=d.done?"completed":"suspendedYield",k.arg===v)continue;return{value:k.arg,done:d.done}}"throw"===k.type&&(e="completed",d.method="throw",d.arg=k.arg)}}}(a,e,j),h}functionc(a,b,c){try{return{type:"normal",arg:a.call(b,c)}}catch(a){return{type:"throw",arg:a}}}functiond(){}functione(){}functionf(){}functiong(b){["next","throw","return"].forEach(function(c){a(b,c,function(a){returnthis._invoke(c,a)})})}functionh(a,b){functiond(e,f,g,h){vari=c(a[e],a,f);if("throw"!==i.type){varj=i.arg,k=j.value;returnk&&"object"==_typeof(k)&&q.call(k,"__await")?b.resolve(k.__await).then(function(a){d("next",a,g,h)},function(a){d("throw",a,g,h)}):b.resolve(k).then(function(a){j.value=a,g(j)},function(a){returnd("throw",a,g,h)})}h(i.arg)}vare;this._invoke=function(a,c){functionf(){returnnewb(function(b,e){d(a,c,b,e)})}returne=e?e.then(f,f):f()}}functioni(a,b){vard=a.iterator[b.method];if(void0===d){if(b.delegate=null,"throw"===b.method){if(a.iterator["return"]&&(b.method="return",b.arg=void0,i(a,b),"throw"===b.method))returnv;b.method="throw",b.arg=newTypeError("The iterator does not provide a 'throw' method")}returnv}vare=c(d,a.iterator,b.arg);if("throw"===e.type)returnb.method="throw",b.arg=e.arg,b.delegate=null,v;varf=e.arg;returnf?f.done?(b[a.resultName]=f.value,b.next=a.nextLoc,"return"!==b.method&&(b.method="next",b.arg=void0),b.delegate=null,v):f:(b.method="throw",b.arg=newTypeError("iterator result is not an object"),b.delegate=null,v)}functionj(a){varb={tryLoc:a[0]};1ina&&(b.catchLoc=a[1]),2ina&&(b.finallyLoc=a[2],b.afterLoc=a[3]),this.tryEntries.push(b)}functionk(a){varb=a.completion||{};b.type="normal",deleteb.arg,a.completion=b}functionl(a){this.tryEntries=[{tryLoc:"root"}],a.forEach(j,this),this.reset(!0)}functionm(a){if(a){varb=a[s];if(b)returnb.call(a);if("function"==typeofa.next)returna;if(!isNaN(a.length)){varc=-1,d=functionb(){for(;++c<a.length;)if(q.call(a,c))returnb.value=a[c],b.done=!1,b;returnb.value=void0,b.done=!0,b};returnd.next=d}}return{next:n}}functionn(){return{value:void0,done:!0}}_regeneratorRuntime=function(){returno};varo={},p=Object.prototype,q=p.hasOwnProperty,r="function"==typeofSymbol?Symbol:{},s=r.iterator||"@@iterator",t=r.asyncIterator||"@@asyncIterator",u=r.toStringTag||"@@toStringTag";try{a({},"")}catch(b){a=function(a,b,c){returna[b]=c}}o.wrap=b;varv={},w={};a(w,s,function(){returnthis});varx=Object.getPrototypeOf,y=x&&x(x(m([])));y&&y!==p&&q.call(y,s)&&(w=y);varz=f.prototype=d.prototype=Object.create(w);returne.prototype=f,a(z,"constructor",f),a(f,"constructor",e),e.displayName=a(f,u,"GeneratorFunction"),o.isGeneratorFunction=function(a){varb="function"==typeofa&&a.constructor;return!!b&&(b===e||"GeneratorFunction"===(b.displayName||b.name))},o.mark=function(b){returnObject.setPrototypeOf?Object.setPrototypeOf(b,f):(b.__proto__=f,a(b,u,"GeneratorFunction")),b.prototype=Object.create(z),b},o.awrap=function(a){return{__await:a}},g(h.prototype),a(h.prototype,t,function(){returnthis}),o.AsyncIterator=h,o.async=function(a,c,d,e,f){void0===f&&(f=Promise);varg=newh(b(a,c,d,e),f);returno.isGeneratorFunction(c)?g:g.next().then(function(a){returna.done?a.value:g.next()})},g(z),a(z,u,"Generator"),a(z,s,function(){returnthis}),a(z,"toString",function(){return"[object Generator]"}),o.keys=function(a){varb=[];for(varcina)b.push(c);returnb.reverse(),functionc(){for(;b.length;){vard=b.pop();if(dina)returnc.value=d,c.done=!1,c}returnc.done=!0,c}},o.values=m,l.prototype={constructor:l,reset:functionreset(a){if(this.prev=0,this.next=0,this.sent=this._sent=void0,this.done=!1,this.delegate=null,this.method="next",this.arg=void0,this.tryEntries.forEach(k),!a)for(varbinthis)"t"===b.charAt(0)&&q.call(this,b)&&!isNaN(+b.slice(1))&&(this[b]=void0)},stop:functionstop(){this.done=!0;vara=this.tryEntries[0].completion;if("throw"===a.type)throwa.arg;returnthis.rval},dispatchException:functiondispatchException(a){functionb(b,d){returnf.type="throw",f.arg=a,c.next=b,d&&(c.method="next",c.arg=void0),!!d}if(this.done)throwa;for(varc=this,d=this.tryEntries.length-1;0<=d;--d){vare=this.tryEntries[d],f=e.completion;if("root"===e.tryLoc)returnb("end");if(e.tryLoc<=this.prev){varg=q.call(e,"catchLoc"),h=q.call(e,"finallyLoc");if(g&&h){if(this.prev<e.catchLoc)returnb(e.catchLoc,!0);if(this.prev<e.finallyLoc)returnb(e.finallyLoc)}elseif(!g){if(!h)thrownewError("try statement without catch or finally");if(this.prev<e.finallyLoc)returnb(e.finallyLoc)}elseif(this.prev<e.catchLoc)returnb(e.catchLoc,!0)}}},abrupt:functionabrupt(a,b){for(varc,d=this.tryEntries.length-1;0<=d;--d)if(c=this.tryEntries[d],c.tryLoc<=this.prev&&q.call(c,"finallyLoc")&&this.prev<c.finallyLoc){vare=c;break}e&&("break"===a||"continue"===a)&&e.tryLoc<=b&&b<=e.finallyLoc&&(e=null);varf=e?e.completion:{};returnf.type=a,f.arg=b,e?(this.method="next",this.next=e.finallyLoc,v):this.complete(f)},complete:functioncomplete(a,b){if("throw"===a.type)throwa.arg;return"break"===a.type||"continue"===a.type?this.next=a.arg:"return"===a.type?(this.rval=this.arg=a.arg,this.method="return",this.next="end"):"normal"===a.type&&b&&(this.next=b),v},finish:functionfinish(a){for(varb,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.finallyLoc===a)returnthis.complete(b.completion,b.afterLoc),k(b),v},catch:function_catch(a){for(varb,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.tryLoc===a){vard=b.completion;if("throw"===d.type){vare=d.arg;k(b)}returne}thrownewError("illegal catch attempt")},delegateYield:functiondelegateYield(a,b,c){returnthis.delegate={iterator:m(a),resultName:b,nextLoc:c},"next"===this.method&&(this.arg=void0),v}},o}functionasyncGeneratorStep(a,b,c,d,e,f,g){try{varh=a[f](g),i=h.value}catch(a){returnvoidc(a)}h.done?b(i):Promise.resolve(i).then(d,e)}function_asyncToGenerator(a){returnfunction(){varb=this,c=arguments;returnnewPromise(function(d,e){functionf(a){asyncGeneratorStep(h,d,e,f,g,"next",a)}functiong(a){asyncGeneratorStep(h,d,e,f,g,"throw",a)}varh=a.apply(b,c);f(void0)})}}varSamlStrategy=passportSaml.Strategy,saltRounds=10,salt=64,logoDir="built/public/upload/",defaultLogo="built/public/default/logo.png";module.exports=function(a,b,c,d){// ======== APP ROUTES - ACCOUNT ====================
functione(){returnf.apply(this,arguments)}functionf(){returnf=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(functionb(a){varc,d,e;return_regeneratorRuntime().wrap(functionf(b){for(;1;)switch(b.prev=b.next){case0:returnb.next=2,_dbController.dbController.getUserByEmail(a);case2:if(c=b.sent,c){b.next=8;break}returnconsole.log("no user found"),b.abrupt("return",null);case8:returnd=new_user.User(c.id,a,c.salutation,c.title,c.firstname,c.lastname,c.industry,c.organisation,c.speciality,c.m4lab_idp,c.verificationStatus),b.next=11,_dbController.dbController.getGitlabId(d.id);case11:returne=b.sent,e&&d.setGitlabUserId(e),b.abrupt("return",d);case14:case"end":returnb.stop();}},b)})),f.apply(this,arguments)}c.serializeUser(function(a,b){b(null,a)}),c.deserializeUser(function(a,b){b(null,a)});varg=newSamlStrategy({// URL that goes from the Identity Provider -> Service Provider
callbackUrl:b.passport.saml.path,// Base address to call logout requests
logoutUrl:b.passport.saml.logoutUrl,entryPoint:b.passport.saml.entryPoint,issuer:b.passport.saml.issuer,identifierFormat:void0,// Service Provider private key