@resolveio/server-lib 20.7.132 → 20.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/http/auth.js +8 -8
- package/http/auth.js.map +1 -1
- package/http/home.js +2 -1
- package/http/home.js.map +1 -1
- package/managers/mongo.manager.d.ts +4 -0
- package/managers/mongo.manager.js +74 -32
- package/managers/mongo.manager.js.map +1 -1
- package/managers/subscription.manager.d.ts +1 -0
- package/managers/subscription.manager.js +16 -5
- package/managers/subscription.manager.js.map +1 -1
- package/package.json +1 -1
- package/server-app.js +1 -4
- package/server-app.js.map +1 -1
- package/util/common.d.ts +2 -0
- package/util/common.js +35 -1
- package/util/common.js.map +1 -1
package/http/auth.js
CHANGED
|
@@ -52,7 +52,7 @@ function setupAuthRoutes(mainServer, app, serverConfig) {
|
|
|
52
52
|
return __generator(this, function (_a) {
|
|
53
53
|
switch (_a.label) {
|
|
54
54
|
case 0:
|
|
55
|
-
if (
|
|
55
|
+
if (!!(0, common_1.isAllowedOrigin)(request.headers.origin, serverConfig)) return [3 /*break*/, 1];
|
|
56
56
|
response.send(JSON.stringify({
|
|
57
57
|
error: true,
|
|
58
58
|
result: 'Invalid header'
|
|
@@ -179,7 +179,7 @@ function setupAuthRoutes(mainServer, app, serverConfig) {
|
|
|
179
179
|
return __generator(this, function (_a) {
|
|
180
180
|
switch (_a.label) {
|
|
181
181
|
case 0:
|
|
182
|
-
if (
|
|
182
|
+
if (!!(0, common_1.isAllowedOrigin)(request.headers.origin, serverConfig)) return [3 /*break*/, 1];
|
|
183
183
|
response.send(JSON.stringify({
|
|
184
184
|
error: true,
|
|
185
185
|
result: 'Invalid header'
|
|
@@ -317,7 +317,7 @@ function setupAuthRoutes(mainServer, app, serverConfig) {
|
|
|
317
317
|
return __generator(this, function (_a) {
|
|
318
318
|
switch (_a.label) {
|
|
319
319
|
case 0:
|
|
320
|
-
if (
|
|
320
|
+
if (!!(0, common_1.isAllowedOrigin)(request.headers.origin, serverConfig)) return [3 /*break*/, 1];
|
|
321
321
|
response.send(JSON.stringify({
|
|
322
322
|
error: true,
|
|
323
323
|
result: 'Invalid header'
|
|
@@ -413,7 +413,7 @@ function setupAuthRoutes(mainServer, app, serverConfig) {
|
|
|
413
413
|
return __generator(this, function (_a) {
|
|
414
414
|
switch (_a.label) {
|
|
415
415
|
case 0:
|
|
416
|
-
if (
|
|
416
|
+
if (!!(0, common_1.isAllowedOrigin)(request.headers.origin, serverConfig)) return [3 /*break*/, 1];
|
|
417
417
|
response.send(JSON.stringify({
|
|
418
418
|
error: true,
|
|
419
419
|
result: 'Invalid header'
|
|
@@ -511,7 +511,7 @@ function setupAuthRoutes(mainServer, app, serverConfig) {
|
|
|
511
511
|
return __generator(this, function (_a) {
|
|
512
512
|
switch (_a.label) {
|
|
513
513
|
case 0:
|
|
514
|
-
if (
|
|
514
|
+
if (!!(0, common_1.isAllowedOrigin)(request.headers.origin, serverConfig)) return [3 /*break*/, 1];
|
|
515
515
|
response.send(JSON.stringify({
|
|
516
516
|
error: true,
|
|
517
517
|
result: 'Invalid header'
|
|
@@ -613,7 +613,7 @@ function setupAuthRoutes(mainServer, app, serverConfig) {
|
|
|
613
613
|
return __generator(this, function (_a) {
|
|
614
614
|
switch (_a.label) {
|
|
615
615
|
case 0:
|
|
616
|
-
if (
|
|
616
|
+
if (!!(0, common_1.isAllowedOrigin)(request.headers.origin, serverConfig)) return [3 /*break*/, 1];
|
|
617
617
|
response.send(JSON.stringify({
|
|
618
618
|
error: true,
|
|
619
619
|
result: 'Invalid header'
|
|
@@ -711,7 +711,7 @@ function setupAuthRoutes(mainServer, app, serverConfig) {
|
|
|
711
711
|
return __generator(this, function (_a) {
|
|
712
712
|
switch (_a.label) {
|
|
713
713
|
case 0:
|
|
714
|
-
if (
|
|
714
|
+
if (!!(0, common_1.isAllowedOrigin)(request.headers.origin, serverConfig)) return [3 /*break*/, 1];
|
|
715
715
|
response.send(JSON.stringify({
|
|
716
716
|
error: true,
|
|
717
717
|
result: 'Invalid header'
|
|
@@ -812,7 +812,7 @@ function setupAuthRoutes(mainServer, app, serverConfig) {
|
|
|
812
812
|
return __generator(this, function (_a) {
|
|
813
813
|
switch (_a.label) {
|
|
814
814
|
case 0:
|
|
815
|
-
if (
|
|
815
|
+
if (!!(0, common_1.isAllowedOrigin)(request.headers.origin, serverConfig)) return [3 /*break*/, 1];
|
|
816
816
|
response.send(JSON.stringify({
|
|
817
817
|
error: true,
|
|
818
818
|
result: 'Invalid header'
|
package/http/auth.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/http/auth.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wCAA0C;AAC1C,uCAAyC;AACzC,kCAAoC;AACpC,yCAAoC;AACpC,6CAAwC;AACxC,kEAAuD;AACvD,gEAA0D;AAE1D,yCAAmD;AAEnD,SAAgB,eAAe,CAAC,UAA+B,EAAE,GAAG,EAAE,YAAY;IAAlF,iBAytBC;IAxtBA,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC,IAAI,EAAE,EAAE,UAAO,OAAO,EAAE,QAAQ;;;;;yBAC5D,CAAA,OAAO,CAAC,OAAO,CAAC,MAAM,KAAK,YAAY,CAAC,UAAU,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,MAAM,KAAK,YAAY,CAAC,cAAc,CAAC,CAAA,EAA9G,wBAA8G;oBACjH,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC;wBAC5B,KAAK,EAAE,IAAI;wBACX,MAAM,EAAE,gBAAgB;qBACxB,CAAC,CAAC,CAAC;;;oBAGA,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;oBAEpB,MAAM,GAAG,IAAI,sBAAY,CAAC;wBAC7B,QAAQ,EAAE;4BACT,IAAI,EAAE,MAAM;yBACZ;qBACD,CAAC,CAAC;;;;oBAGF,MAAM,CAAC,QAAQ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AoB;qBAC5B,CAAC,CAAC,CAAC;oBAEJ,sBAAO;;wBAIE,qBAAM,uBAAK,CAAC,OAAO,CAAC,EAAC,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAC,CAAC,EAAA;;oBAAnE,IAAI,GAAG,SAA4D;yBAEnE,CAAC,IAAI,EAAL,wBAAK;oBACD,qBAAM,uBAAK,CAAC,OAAO,CAAC,EAAC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,QAAQ,EAAC,CAAC,EAAA;;oBAAhE,IAAI,GAAG,SAAyD,CAAC;;;oBAGlE,IAAI,IAAI,EAAE;wBACT,UAAU,CAAC,gBAAgB,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,gBAAgB,EAAE,EAAE,mBAAmB,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;qBAC5G;oBAED,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC;wBAC5B,KAAK,EAAE,KAAK;wBACZ,MAAM,EAAE,EAAE;qBACV,CAAC,CAAC,CAAC;;;;;SAEL,CAAC,CAAC;AACJ,CAAC;AAztBD,0CAytBC","file":"auth.js","sourcesContent":["import * as bodyParser from 'body-parser';\nimport * as handlebars from 'handlebars';\nimport * as jwt from 'jsonwebtoken';\nimport jwt_decode from 'jwt-decode';\nimport SimpleSchema from 'simpl-schema';\nimport { Users } from '../collections/user.collection';\nimport { ResolveIOServer } from '../resolveio-server-app';\nimport { ResolveIOMainServer } from '../server-app';\nimport { objectIdHexString } from '../util/common';\n\nexport function setupAuthRoutes(mainServer: ResolveIOMainServer, app, serverConfig) {\n\tapp.post('/login365', bodyParser.json(), async (request, response) => {\n\t\tif (request.headers.origin !== serverConfig['ROOT_URL'] && request.headers.origin !== serverConfig['SEC_ROOT_URL']) {\n\t\t\tresponse.send(JSON.stringify({\n\t\t\t\terror: true,\n\t\t\t\tresult: 'Invalid header'\n\t\t\t}));\n\t\t}\n\t\telse {\n\t\t\tlet body = request.body;\n\n\t\t\tlet schema = new SimpleSchema({\n\t\t\t\tid_token: {\n\t\t\t\t\ttype: String\n\t\t\t\t}\n\t\t\t});\n\t\n\t\t\ttry {\n\t\t\t\tschema.validate(body);\n\t\t\t}\n\t\t\tcatch (errors) {\n\t\t\t\tif (errors) {\n\t\t\t\t\tconsole.error(new Date(), 'Error in HTTP Check (/login)', errors);\n\t\n\t\t\t\t\tawait ResolveIOServer.getMainServer().getMethodManager().sendEmail('dev@resolveio.com', ResolveIOServer.getClientName() + 'HTTP - Error Detected', 'Match Error On HTTP ' + '/login365' + '\\n\\nData Being Checked\\n' + JSON.stringify(body, null, 2) + '\\n\\nErrors\\n' + JSON.stringify(errors, null, 2));\n\t\n\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\terror: true,\n\t\t\t\t\t\tresult: 'Invalid Parameters'\n\t\t\t\t\t}));\n\t\t\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlet tokenData = body.id_token.split('&');\n\t\t\tlet token = tokenData[0].split('=')[1];\n\t\t\tlet decodedJWT = jwt_decode(token);\n\n\t\t\tif (decodedJWT && decodedJWT['name'] && decodedJWT['preferred_username'] && decodedJWT['oid']) {\n\t\t\t\tlet user = await Users.findOne({'other.ms_oid': decodedJWT['oid']});\n\n\t\t\t\tif (!user) {\n\t\t\t\t\tuser = await Users.findOne({email: decodedJWT['preferred_username'].toLowerCase()});\n\n\t\t\t\t\tif (user) {\n\t\t\t\t\t\tawait Users.updateOne({_id: user._id}, {$set: {'other.ms_oid': decodedJWT['oid']}});\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (!user) {\n\t\t\t\t\tuser = {\n\t\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t\t__v: 0,\n\t\t\t\t\t\troles: {\n\t\t\t\t\t\t\tsuper_admin: false,\n\t\t\t\t\t\t\tapprovals: [],\n\t\t\t\t\t\t\tgroups: [],\n\t\t\t\t\t\t\tnotifications: [],\n\t\t\t\t\t\t\tmiscs: []\n\t\t\t\t\t\t},\n\t\t\t\t\t\tusername: decodedJWT['preferred_username'].toLowerCase(),\n\t\t\t\t\t\temail: decodedJWT['preferred_username'].toLowerCase(),\n\t\t\t\t\t\tfullname: decodedJWT['name'],\n\t\t\t\t\t\tactive: true,\n\t\t\t\t\t\tphonenumber: '',\n\t\t\t\t\t\treadonly: false,\n\t\t\t\t\t\tother: {\n\t\t\t\t\t\t\tms_oid: decodedJWT['oid']\n\t\t\t\t\t\t},\n\t\t\t\t\t\tattempts: 0,\n\t\t\t\t\t\tsalt: jwt.sign({now: (Date.now() - 1000).toString()}, serverConfig['JWT_SECRET'], {\n\t\t\t\t\t\t\texpiresIn : 90 * 24 * 60 * 60 * 1000 // 90 days\n\t\t\t\t\t\t}),\n\t\t\t\t\t\thash: jwt.sign({now: (Date.now() + 1000).toString()}, serverConfig['JWT_SECRET'], {\n\t\t\t\t\t\t\texpiresIn : 90 * 24 * 60 * 60 * 1000 // 90 days\n\t\t\t\t\t\t}),\n\t\t\t\t\t\tlast: new Date(),\n\t\t\t\t\t\tsettings: null,\n\t\t\t\t\t\tservices: null,\n\t\t\t\t\t\tis_customer: false\n\t\t\t\t\t};\n\t\t\t\t\t\n\t\t\t\t\tawait Users.create(user);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tlet update = false;\n\n\t\t\t\t\tif (user.email !== decodedJWT['preferred_username'].toLowerCase()) {\n\t\t\t\t\t\tuser.email = decodedJWT['preferred_username'].toLowerCase();\n\t\t\t\t\t\tupdate = true;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (user.fullname !== decodedJWT['name']) {\n\t\t\t\t\t\tuser.fullname = decodedJWT['name'];\n\t\t\t\t\t\tupdate = true;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (update) {\n\t\t\t\t\t\tawait Users.updateOne({_id: user._id}, {$set: {email: user.email, fullname: user.fullname}});\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\terror: false,\n\t\t\t\t\tresult: {\n\t\t\t\t\t\ttoken: jwt.sign({id_user: user._id}, serverConfig['JWT_SECRET'], {\n\t\t\t\t\t\t\texpiresIn : 90 * 24 * 60 * 60 * 1000 // 90 days\n\t\t\t\t\t\t})\n\t\t\t\t\t}\n\t\t\t\t}));\n\t\t\t}\n\t\t\telse {\n\t\t\t\tconsole.log('ERROR - 1', tokenData, token, decodedJWT);\n\n\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\terror: true,\n\t\t\t\t\tresult: 'Invalid Azure Token'\n\t\t\t\t}));\n\t\t\t}\n\t\t}\n\t});\n\n\t// Login via HTTP, return refresh token if authenticated\n\tapp.post('/login', bodyParser.json(), async (request, response) => {\n\t\tif (request.headers.origin !== serverConfig['ROOT_URL'] && request.headers.origin !== serverConfig['SEC_ROOT_URL']) {\n\t\t\tresponse.send(JSON.stringify({\n\t\t\t\terror: true,\n\t\t\t\tresult: 'Invalid header'\n\t\t\t}));\n\t\t}\n\t\telse {\n\n\t\t\tlet body = request.body;\n\n\t\t\tlet schema = new SimpleSchema({\n\t\t\t\tusername: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tpassword: {\n\t\t\t\t\ttype: String\n\t\t\t\t}\n\t\t\t});\n\t\n\t\t\ttry {\n\t\t\t\tschema.validate(body);\n\t\t\t}\n\t\t\tcatch (errors) {\n\t\t\t\tif (errors) {\n\t\t\t\t\tconsole.error(new Date(), 'Error in HTTP Check (/login)', errors);\n\t\n\t\t\t\t\tawait ResolveIOServer.getMainServer().getMethodManager().sendEmail('dev@resolveio.com', ResolveIOServer.getClientName() + 'HTTP - Error Detected', 'Match Error On HTTP ' + '/login' + '\\n\\nData Being Checked\\n' + JSON.stringify(body, null, 2) + '\\n\\nErrors\\n' + JSON.stringify(errors, null, 2));\n\t\n\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\terror: true,\n\t\t\t\t\t\tresult: 'Invalid Parameters'\n\t\t\t\t\t}));\n\t\t\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlet user = await Users.findOne({active: true, username: body.username});\n\n\t\t\tif (!user) {\n\t\t\t\tuser = await Users.findOne({active: true, email: body.username});\n\t\t\t}\n\t\t\t\n\t\t\tif (!user) {\n\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\terror: true,\n\t\t\t\t\tresult: 'Invalid Username And Password'\n\t\t\t\t}));\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tlet resAuth = await Users.authenticate(user, body.password);\n\n\t\t\tif (resAuth['error']) {\n\t\t\t\tif (resAuth['error'] === 'Too Many Attempts') {\n\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\terror: true,\n\t\t\t\t\t\tresult: resAuth['error'] + '. A password reset link has been sent to your email, please reset your password.'\n\t\t\t\t\t}));\n\n\t\t\t\t\tif (!user.services) {\n\t\t\t\t\t\tuser.services = {};\n\t\t\t\t\t}\n\n\t\t\t\t\tuser.services['forgot_password'] = jwt.sign({id_user: user._id}, serverConfig['JWT_SECRET']);\n\n\t\t\t\t\tlet emailData = {\n\t\t\t\t\t\tuserToChangePassword: user.fullname,\n\t\t\t\t\t\tuserWhoResetPassword: ResolveIOServer.getClientName() + ' System',\n\t\t\t\t\t\turl: (serverConfig['ROOT_URL'] + '/forgot-password?' + encodeURIComponent(serverConfig['SERVER_URL']) + '&' + user.services['forgot_password'])\n\t\t\t\t\t};\n\n\t\t\t\t\tawait Users.updateOne({_id: user._id}, {$set: {services: user.services}});\n\t\t\t\t\tlet html = mainServer.getMethodManager().readFile('email-templates/forgot-password.html');\n\t\t\t\t\tlet template = handlebars.compile(html);\n\t\t\t\t\thandlebars.registerHelper('equals', (a, b) => {\n\t\t\t\t\t\treturn a === b;\n\t\t\t\t\t});\n\t\n\t\t\t\t\tawait mainServer.getMethodManager().sendEmail(user.email, 'ResolveIO (' + ResolveIOServer.getClientName() + ') - Forgot Password', '', template(emailData), null, null, '');\n\t\t\t\t}\n\t\t\t\telse if (resAuth['error'] === 'No Salt Value Stored') {\n\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\terror: true,\n\t\t\t\t\t\tresult: 'A password reset link has been sent to your email, please reset your password.'\n\t\t\t\t\t}));\n\n\t\t\t\t\tif (!user.services) {\n\t\t\t\t\t\tuser.services = {};\n\t\t\t\t\t}\n\n\t\t\t\t\tuser.services['forgot_password'] = jwt.sign({id_user: user._id}, serverConfig['JWT_SECRET']);\n\n\t\t\t\t\tlet emailData = {\n\t\t\t\t\t\tuserToChangePassword: user.fullname,\n\t\t\t\t\t\tuserWhoResetPassword: ResolveIOServer.getClientName() + ' System',\n\t\t\t\t\t\turl: (serverConfig['ROOT_URL'] + '/forgot-password?' + encodeURIComponent(serverConfig['SERVER_URL']) + '&' + user.services['forgot_password'])\n\t\t\t\t\t};\n\n\t\t\t\t\tawait Users.updateOne({_id: user._id}, {$set: {services: user.services}});\n\t\t\t\t\tlet html = mainServer.getMethodManager().readFile('email-templates/forgot-password.html');\n\t\t\t\t\tlet template = handlebars.compile(html);\n\t\t\t\t\thandlebars.registerHelper('equals', (a, b) => {\n\t\t\t\t\t\treturn a === b;\n\t\t\t\t\t});\n\n\t\t\t\t\tawait mainServer.getMethodManager().sendEmail(user.email, 'ResolveIO (' + ResolveIOServer.getClientName() + ') - Forgot Password', '', template(emailData), null, null, '');\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\terror: true,\n\t\t\t\t\t\tresult: resAuth['error']\n\t\t\t\t\t}));\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (resAuth && resAuth['data'] && resAuth['data'].active) {\n\t\t\t\t\tawait Users.resetAttempts(resAuth['data']);\n\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\terror: false,\n\t\t\t\t\t\tresult: {\n\t\t\t\t\t\t\ttoken: jwt.sign({id_user: resAuth['data']._id}, serverConfig['JWT_SECRET'], {\n\t\t\t\t\t\t\t\texpiresIn : 90 * 24 * 60 * 60 * 1000 // 90 days\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t} \n\t\t\t\t\t}));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t});\n\n\tapp.post('/accessToken', bodyParser.json(), async (request, response) => {\n\t\tif (request.headers.origin !== serverConfig['ROOT_URL'] && request.headers.origin !== serverConfig['SEC_ROOT_URL'] && request.headers.origin !== serverConfig['RESOLVEIO_URL'] && request.headers.origin !== serverConfig['RESOLVEIO_SECONDARY_URL']) {\n\t\t\tresponse.send(JSON.stringify({\n\t\t\t\terror: true,\n\t\t\t\tresult: 'Invalid header'\n\t\t\t}));\n\t\t}\n\t\telse {\n\t\t\tlet body = request.body;\n\n\t\t\tlet schema = new SimpleSchema({\n\t\t\t\trefreshToken: {\n\t\t\t\t\ttype: String\n\t\t\t\t}\n\t\t\t});\n\t\n\t\t\ttry {\n\t\t\t\tschema.validate(body);\n\t\t\t}\n\t\t\tcatch (errors) {\n\t\t\t\tif (errors) {\n\t\t\t\t\tconsole.error(new Date(), 'Error in HTTP Check (/accessToken)', errors);\n\t\n\t\t\t\t\tawait ResolveIOServer.getMainServer().getMethodManager().sendEmail('dev@resolveio.com', ResolveIOServer.getClientName() + 'HTTP - Error Detected', 'Match Error On HTTP ' + '/accessToken' + '\\n\\nData Being Checked\\n' + JSON.stringify(body, null, 2) + '\\n\\nErrors\\n' + JSON.stringify(errors, null, 2));\n\t\n\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\terror: true,\n\t\t\t\t\t\tresult: 'Invalid Parameters'\n\t\t\t\t\t}));\n\t\t\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tjwt.verify(body.refreshToken, serverConfig['JWT_SECRET'], async (err, decoded) => {\n\t\t\t\tif (err) {\n\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\terror: true,\n\t\t\t\t\t\tresult: 'Invalid Token'\n\t\t\t\t\t}));\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tlet user = await Users.findById(decoded['id_user']);\n\t\t\t\t\t\tif (user) {\n\t\t\t\t\t\t\tif (user.active) {\n\t\t\t\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\t\t\t\terror: false,\n\t\t\t\t\t\t\t\t\tresult: {\n\t\t\t\t\t\t\t\t\t\ttoken: jwt.sign({id_user: user._id}, serverConfig['JWT_SECRET'], {\n\t\t\t\t\t\t\t\t\t\t\texpiresIn : 3 * 24 * 60 * 60 * 1000 // 3 days\n\t\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\t\tuser: user\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\t\t\t\terror: true,\n\t\t\t\t\t\t\t\t\tresult: 'Account is Disabled'\n\t\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\t\t\terror: true,\n\t\t\t\t\t\t\t\tresult: 'Invalid User'\n\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tcatch {\n\t\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\t\terror: true,\n\t\t\t\t\t\t\tresult: 'Invalid Mongo Get User'\n\t\t\t\t\t\t}));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t});\n\n\tapp.post('/userWithEnrollmentToken', bodyParser.json(), async (request, response) => {\n\t\tif (request.headers.origin !== serverConfig['ROOT_URL'] && request.headers.origin !== serverConfig['SEC_ROOT_URL'] && request.headers.origin !== serverConfig['RESOLVEIO_URL'] && request.headers.origin !== serverConfig['RESOLVEIO_SECONDARY_URL']) {\n\t\t\tresponse.send(JSON.stringify({\n\t\t\t\terror: true,\n\t\t\t\tresult: 'Invalid header'\n\t\t\t}));\n\t\t}\n\t\telse {\n\t\t\tlet body = request.body;\n\n\t\t\tlet schema = new SimpleSchema({\n\t\t\t\tenrollmentToken: {\n\t\t\t\t\ttype: String\n\t\t\t\t}\n\t\t\t});\n\t\n\t\t\ttry {\n\t\t\t\tschema.validate(body);\n\t\t\t}\n\t\t\tcatch (errors) {\n\t\t\t\tif (errors) {\n\t\t\t\t\tconsole.error(new Date(), 'Error in HTTP Check (/userWithEnrollmentToken)', errors);\n\t\n\t\t\t\t\tawait ResolveIOServer.getMainServer().getMethodManager().sendEmail('dev@resolveio.com', ResolveIOServer.getClientName() + 'HTTP - Error Detected', 'Match Error On HTTP ' + '/userWithEnrollmentToken' + '\\n\\nData Being Checked\\n' + JSON.stringify(body, null, 2) + '\\n\\nErrors\\n' + JSON.stringify(errors, null, 2));\n\t\n\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\terror: true,\n\t\t\t\t\t\tresult: 'Invalid Parameters'\n\t\t\t\t\t}));\n\t\t\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tjwt.verify(body.enrollmentToken, serverConfig['JWT_SECRET'], async (err, decoded) => {\n\t\t\t\tif (err) {\n\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\terror: true,\n\t\t\t\t\t\tresult: 'Invalid Token'\n\t\t\t\t\t}));\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tlet user = await Users.findOne({\n\t\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t\t{_id: decoded['id_user']},\n\t\t\t\t\t\t\t\t{'services.enrollment': body.enrollmentToken}\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t}, {projection: {_id: 1, __v: 1, username: 1, active: 1}});\n\t\t\t\t\t\tif (user) {\n\t\t\t\t\t\t\tif (user.active) {\n\n\t\t\t\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\t\t\t\terror: false,\n\t\t\t\t\t\t\t\t\tresult: {\n\t\t\t\t\t\t\t\t\t\tuser: user\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\t\t\t\terror: true,\n\t\t\t\t\t\t\t\t\tresult: 'Account is Disabled'\n\t\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\t\t\terror: true,\n\t\t\t\t\t\t\t\tresult: 'Invalid User'\n\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tcatch {\n\t\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\t\terror: true,\n\t\t\t\t\t\t\tresult: 'Invalid Mongo Get User'\n\t\t\t\t\t\t}));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t});\n\n\tapp.post('/setUserWithEnrollmentToken', bodyParser.json(), async (request, response) => {\n\t\tif (request.headers.origin !== serverConfig['ROOT_URL'] && request.headers.origin !== serverConfig['SEC_ROOT_URL'] && request.headers.origin !== serverConfig['RESOLVEIO_URL'] && request.headers.origin !== serverConfig['RESOLVEIO_SECONDARY_URL']) {\n\t\t\tresponse.send(JSON.stringify({\n\t\t\t\terror: true,\n\t\t\t\tresult: 'Invalid header'\n\t\t\t}));\n\t\t}\n\t\telse {\n\t\t\tlet body = request.body;\n\n\t\t\tlet schema = new SimpleSchema({\n\t\t\t\tenrollmentToken: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tpassword: {\n\t\t\t\t\ttype: String\n\t\t\t\t}\n\t\t\t});\n\t\n\t\t\ttry {\n\t\t\t\tschema.validate(body);\n\t\t\t}\n\t\t\tcatch (errors) {\n\t\t\t\tif (errors) {\n\t\t\t\t\tconsole.error(new Date(), 'Error in HTTP Check (/setUserWithEnrollmentToken)', errors);\n\t\n\t\t\t\t\tawait ResolveIOServer.getMainServer().getMethodManager().sendEmail('dev@resolveio.com', ResolveIOServer.getClientName() + 'HTTP - Error Detected', 'Match Error On HTTP ' + '/setUserWithEnrollmentToken' + '\\n\\nData Being Checked\\n' + JSON.stringify(body, null, 2) + '\\n\\nErrors\\n' + JSON.stringify(errors, null, 2));\n\t\n\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\terror: true,\n\t\t\t\t\t\tresult: 'Invalid Parameters'\n\t\t\t\t\t}));\n\t\t\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tjwt.verify(body.enrollmentToken, serverConfig['JWT_SECRET'], async (err, decoded) => {\n\t\t\t\tif (err) {\n\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\terror: true,\n\t\t\t\t\t\tresult: 'Invalid Token'\n\t\t\t\t\t}));\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tlet user = await Users.findOne({\n\t\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t\t{_id: decoded['id_user']},\n\t\t\t\t\t\t\t\t{'services.enrollment': body.enrollmentToken}\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t});\n\t\t\t\t\t\tif (user) {\n\t\t\t\t\t\t\tif (user.active) {\n\t\t\t\t\t\t\t\tawait Users.setPassword(user, body.password);\n\n\t\t\t\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\t\t\t\terror: false,\n\t\t\t\t\t\t\t\t\tresult: true\n\t\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\t\t\t\terror: true,\n\t\t\t\t\t\t\t\t\tresult: 'Account is Disabled'\n\t\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\t\t\terror: true,\n\t\t\t\t\t\t\t\tresult: 'Invalid User'\n\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tcatch {\n\t\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\t\terror: true,\n\t\t\t\t\t\t\tresult: 'Invalid Mongo Get User'\n\t\t\t\t\t\t}));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t});\n\n\tapp.post('/userWithForgotPasswordToken', bodyParser.json(), async (request, response) => {\n\t\tif (request.headers.origin !== serverConfig['ROOT_URL'] && request.headers.origin !== serverConfig['SEC_ROOT_URL'] && request.headers.origin !== serverConfig['RESOLVEIO_URL'] && request.headers.origin !== serverConfig['RESOLVEIO_SECONDARY_URL']) {\n\t\t\tresponse.send(JSON.stringify({\n\t\t\t\terror: true,\n\t\t\t\tresult: 'Invalid header'\n\t\t\t}));\n\t\t}\n\t\telse {\n\t\t\tlet body = request.body;\n\n\t\t\tlet schema = new SimpleSchema({\n\t\t\t\tforgotPasswordToken: {\n\t\t\t\t\ttype: String\n\t\t\t\t}\n\t\t\t});\n\t\n\t\t\ttry {\n\t\t\t\tschema.validate(body);\n\t\t\t}\n\t\t\tcatch (errors) {\n\t\t\t\tif (errors) {\n\t\t\t\t\tconsole.error(new Date(), 'Error in HTTP Check (/userWithForgotPasswordToken)', errors);\n\t\n\t\t\t\t\tawait ResolveIOServer.getMainServer().getMethodManager().sendEmail('dev@resolveio.com', ResolveIOServer.getClientName() + 'HTTP - Error Detected', 'Match Error On HTTP ' + '/userWithForgotPasswordToken' + '\\n\\nData Being Checked\\n' + JSON.stringify(body, null, 2) + '\\n\\nErrors\\n' + JSON.stringify(errors, null, 2));\n\t\n\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\terror: true,\n\t\t\t\t\t\tresult: 'Invalid Parameters'\n\t\t\t\t\t}));\n\t\t\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tjwt.verify(body.forgotPasswordToken, serverConfig['JWT_SECRET'], async (err, decoded) => {\n\t\t\t\tif (err) {\n\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\terror: true,\n\t\t\t\t\t\tresult: 'Invalid Token'\n\t\t\t\t\t}));\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tlet user = await Users.findOne({\n\t\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t\t{_id: decoded['id_user']},\n\t\t\t\t\t\t\t\t{'services.forgot_password': body.forgotPasswordToken}\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t}, {projection: {_id: 1, __v: 1, username: 1, active: 1}});\n\t\t\t\t\t\t\t\n\t\t\t\t\t\tif (user) {\n\t\t\t\t\t\t\tif (user.active) {\n\t\t\t\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\t\t\t\terror: false,\n\t\t\t\t\t\t\t\t\tresult: {\n\t\t\t\t\t\t\t\t\t\tuser: user\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\t\t\t\terror: true,\n\t\t\t\t\t\t\t\t\tresult: 'Account is Disabled'\n\t\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\t\t\terror: true,\n\t\t\t\t\t\t\t\tresult: 'Invalid Token'\n\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tcatch {\n\t\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\t\terror: true,\n\t\t\t\t\t\t\tresult: 'Invalid Mongo Get User'\n\t\t\t\t\t\t}));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t});\n\n\tapp.post('/setUserWithForgotPasswordToken', bodyParser.json(), async (request, response) => {\n\t\tif (request.headers.origin !== serverConfig['ROOT_URL'] && request.headers.origin !== serverConfig['SEC_ROOT_URL'] && request.headers.origin !== serverConfig['RESOLVEIO_URL'] && request.headers.origin !== serverConfig['RESOLVEIO_SECONDARY_URL']) {\n\t\t\tresponse.send(JSON.stringify({\n\t\t\t\terror: true,\n\t\t\t\tresult: 'Invalid header'\n\t\t\t}));\n\t\t}\n\t\telse {\n\t\t\tlet body = request.body;\n\n\t\t\tlet schema = new SimpleSchema({\n\t\t\t\tforgotPasswordToken: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tpassword: {\n\t\t\t\t\ttype: String\n\t\t\t\t}\n\t\t\t});\n\t\n\t\t\ttry {\n\t\t\t\tschema.validate(body);\n\t\t\t}\n\t\t\tcatch (errors) {\n\t\t\t\tif (errors) {\n\t\t\t\t\tconsole.error(new Date(), 'Error in HTTP Check (/setUserWithForgotPasswordToken)', errors);\n\t\n\t\t\t\t\tawait ResolveIOServer.getMainServer().getMethodManager().sendEmail('dev@resolveio.com', ResolveIOServer.getClientName() + 'HTTP - Error Detected', 'Match Error On HTTP ' + '/setUserWithForgotPasswordToken' + '\\n\\nData Being Checked\\n' + JSON.stringify(body, null, 2) + '\\n\\nErrors\\n' + JSON.stringify(errors, null, 2));\n\t\n\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\terror: true,\n\t\t\t\t\t\tresult: 'Invalid Parameters'\n\t\t\t\t\t}));\n\t\t\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tjwt.verify(body.forgotPasswordToken, serverConfig['JWT_SECRET'], async (err, decoded) => {\n\t\t\t\tif (err) {\n\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\terror: true,\n\t\t\t\t\t\tresult: 'Invalid Token'\n\t\t\t\t\t}));\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tlet user = await Users.findOne({\n\t\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t\t{_id: decoded['id_user']},\n\t\t\t\t\t\t\t\t{'services.forgot_password': body.forgotPasswordToken}\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\n\t\t\t\t\t\tif (user) {\n\t\t\t\t\t\t\tif (user.active) {\n\t\t\t\t\t\t\t\tawait Users.setPassword(user, body.password);\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\t\t\t\terror: false,\n\t\t\t\t\t\t\t\t\tresult: true\n\t\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\t\t\t\terror: true,\n\t\t\t\t\t\t\t\t\tresult: 'Account is Disabled'\n\t\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\t\t\terror: true,\n\t\t\t\t\t\t\t\tresult: 'Invalid User'\n\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tcatch {\n\t\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\t\terror: true,\n\t\t\t\t\t\t\tresult: 'Invalid Mongo Get User'\n\t\t\t\t\t\t}));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t});\n\n\tapp.post('/resetPassword', bodyParser.json(), async (request, response) => {\n\t\tif (request.headers.origin !== serverConfig['ROOT_URL'] && request.headers.origin !== serverConfig['SEC_ROOT_URL']) {\n\t\t\tresponse.send(JSON.stringify({\n\t\t\t\terror: true,\n\t\t\t\tresult: 'Invalid header'\n\t\t\t}));\n\t\t}\n\t\telse {\n\t\t\tlet body = request.body;\n\n\t\t\tlet schema = new SimpleSchema({\n\t\t\t\tusername: {\n\t\t\t\t\ttype: String\n\t\t\t\t}\n\t\t\t});\n\t\n\t\t\ttry {\n\t\t\t\tschema.validate(body);\n\t\t\t}\n\t\t\tcatch (errors) {\n\t\t\t\tif (errors) {\n\t\t\t\t\tconsole.error(new Date(), 'Error in HTTP Check (/resetPassword)', errors);\n\t\n\t\t\t\t\tawait ResolveIOServer.getMainServer().getMethodManager().sendEmail('dev@resolveio.com', ResolveIOServer.getClientName() + 'HTTP - Error Detected', 'Match Error On HTTP ' + '/resetPassword' + '\\n\\nData Being Checked\\n' + JSON.stringify(body, null, 2) + '\\n\\nErrors\\n' + JSON.stringify(errors, null, 2));\n\t\n\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\terror: true,\n\t\t\t\t\t\tresult: 'Invalid Parameters'\n\t\t\t\t\t}));\n\t\t\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlet user = await Users.findOne({active: true, username: body.username});\n\n\t\t\tif (!user) {\n\t\t\t\tuser = await Users.findOne({active: true, email: body.username});\n\t\t\t}\n\t\t\t\n\t\t\tif (user) {\n\t\t\t\tmainServer.getMethodManager().callMethod.call(mainServer.getMethodManager(), 'resetUserPassword', user._id);\n\t\t\t}\n\n\t\t\tresponse.send(JSON.stringify({\n\t\t\t\terror: false,\n\t\t\t\tresult: ''\n\t\t\t}));\n\t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,KAAK,EAAE,IAAI,CAAC,QAAQ,EAAC,CAAC,EAAA;;oBAAhE,IAAI,GAAG,SAAyD,CAAC;;;oBAGlE,IAAI,IAAI,EAAE;wBACT,UAAU,CAAC,gBAAgB,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,gBAAgB,EAAE,EAAE,mBAAmB,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;qBAC5G;oBAED,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC;wBAC5B,KAAK,EAAE,KAAK;wBACZ,MAAM,EAAE,EAAE;qBACV,CAAC,CAAC,CAAC;;;;;SAEL,CAAC,CAAC;AACJ,CAAC;AAztBD,0CAytBC","file":"auth.js","sourcesContent":["import * as bodyParser from 'body-parser';\nimport * as handlebars from 'handlebars';\nimport * as jwt from 'jsonwebtoken';\nimport jwt_decode from 'jwt-decode';\nimport SimpleSchema from 'simpl-schema';\nimport { Users } from '../collections/user.collection';\nimport { ResolveIOServer } from '../resolveio-server-app';\nimport { ResolveIOMainServer } from '../server-app';\nimport { isAllowedOrigin, objectIdHexString } from '../util/common';\n\nexport function setupAuthRoutes(mainServer: ResolveIOMainServer, app, serverConfig) {\n\tapp.post('/login365', bodyParser.json(), async (request, response) => {\n\t\tif (!isAllowedOrigin(request.headers.origin, serverConfig)) {\n\t\t\tresponse.send(JSON.stringify({\n\t\t\t\terror: true,\n\t\t\t\tresult: 'Invalid header'\n\t\t\t}));\n\t\t}\n\t\telse {\n\t\t\tlet body = request.body;\n\n\t\t\tlet schema = new SimpleSchema({\n\t\t\t\tid_token: {\n\t\t\t\t\ttype: String\n\t\t\t\t}\n\t\t\t});\n\t\n\t\t\ttry {\n\t\t\t\tschema.validate(body);\n\t\t\t}\n\t\t\tcatch (errors) {\n\t\t\t\tif (errors) {\n\t\t\t\t\tconsole.error(new Date(), 'Error in HTTP Check (/login)', errors);\n\t\n\t\t\t\t\tawait ResolveIOServer.getMainServer().getMethodManager().sendEmail('dev@resolveio.com', ResolveIOServer.getClientName() + 'HTTP - Error Detected', 'Match Error On HTTP ' + '/login365' + '\\n\\nData Being Checked\\n' + JSON.stringify(body, null, 2) + '\\n\\nErrors\\n' + JSON.stringify(errors, null, 2));\n\t\n\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\terror: true,\n\t\t\t\t\t\tresult: 'Invalid Parameters'\n\t\t\t\t\t}));\n\t\t\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlet tokenData = body.id_token.split('&');\n\t\t\tlet token = tokenData[0].split('=')[1];\n\t\t\tlet decodedJWT = jwt_decode(token);\n\n\t\t\tif (decodedJWT && decodedJWT['name'] && decodedJWT['preferred_username'] && decodedJWT['oid']) {\n\t\t\t\tlet user = await Users.findOne({'other.ms_oid': decodedJWT['oid']});\n\n\t\t\t\tif (!user) {\n\t\t\t\t\tuser = await Users.findOne({email: decodedJWT['preferred_username'].toLowerCase()});\n\n\t\t\t\t\tif (user) {\n\t\t\t\t\t\tawait Users.updateOne({_id: user._id}, {$set: {'other.ms_oid': decodedJWT['oid']}});\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (!user) {\n\t\t\t\t\tuser = {\n\t\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t\t__v: 0,\n\t\t\t\t\t\troles: {\n\t\t\t\t\t\t\tsuper_admin: false,\n\t\t\t\t\t\t\tapprovals: [],\n\t\t\t\t\t\t\tgroups: [],\n\t\t\t\t\t\t\tnotifications: [],\n\t\t\t\t\t\t\tmiscs: []\n\t\t\t\t\t\t},\n\t\t\t\t\t\tusername: decodedJWT['preferred_username'].toLowerCase(),\n\t\t\t\t\t\temail: decodedJWT['preferred_username'].toLowerCase(),\n\t\t\t\t\t\tfullname: decodedJWT['name'],\n\t\t\t\t\t\tactive: true,\n\t\t\t\t\t\tphonenumber: '',\n\t\t\t\t\t\treadonly: false,\n\t\t\t\t\t\tother: {\n\t\t\t\t\t\t\tms_oid: decodedJWT['oid']\n\t\t\t\t\t\t},\n\t\t\t\t\t\tattempts: 0,\n\t\t\t\t\t\tsalt: jwt.sign({now: (Date.now() - 1000).toString()}, serverConfig['JWT_SECRET'], {\n\t\t\t\t\t\t\texpiresIn : 90 * 24 * 60 * 60 * 1000 // 90 days\n\t\t\t\t\t\t}),\n\t\t\t\t\t\thash: jwt.sign({now: (Date.now() + 1000).toString()}, serverConfig['JWT_SECRET'], {\n\t\t\t\t\t\t\texpiresIn : 90 * 24 * 60 * 60 * 1000 // 90 days\n\t\t\t\t\t\t}),\n\t\t\t\t\t\tlast: new Date(),\n\t\t\t\t\t\tsettings: null,\n\t\t\t\t\t\tservices: null,\n\t\t\t\t\t\tis_customer: false\n\t\t\t\t\t};\n\t\t\t\t\t\n\t\t\t\t\tawait Users.create(user);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tlet update = false;\n\n\t\t\t\t\tif (user.email !== decodedJWT['preferred_username'].toLowerCase()) {\n\t\t\t\t\t\tuser.email = decodedJWT['preferred_username'].toLowerCase();\n\t\t\t\t\t\tupdate = true;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (user.fullname !== decodedJWT['name']) {\n\t\t\t\t\t\tuser.fullname = decodedJWT['name'];\n\t\t\t\t\t\tupdate = true;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (update) {\n\t\t\t\t\t\tawait Users.updateOne({_id: user._id}, {$set: {email: user.email, fullname: user.fullname}});\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\terror: false,\n\t\t\t\t\tresult: {\n\t\t\t\t\t\ttoken: jwt.sign({id_user: user._id}, serverConfig['JWT_SECRET'], {\n\t\t\t\t\t\t\texpiresIn : 90 * 24 * 60 * 60 * 1000 // 90 days\n\t\t\t\t\t\t})\n\t\t\t\t\t}\n\t\t\t\t}));\n\t\t\t}\n\t\t\telse {\n\t\t\t\tconsole.log('ERROR - 1', tokenData, token, decodedJWT);\n\n\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\terror: true,\n\t\t\t\t\tresult: 'Invalid Azure Token'\n\t\t\t\t}));\n\t\t\t}\n\t\t}\n\t});\n\n\t// Login via HTTP, return refresh token if authenticated\n\tapp.post('/login', bodyParser.json(), async (request, response) => {\n\t\tif (!isAllowedOrigin(request.headers.origin, serverConfig)) {\n\t\t\tresponse.send(JSON.stringify({\n\t\t\t\terror: true,\n\t\t\t\tresult: 'Invalid header'\n\t\t\t}));\n\t\t}\n\t\telse {\n\n\t\t\tlet body = request.body;\n\n\t\t\tlet schema = new SimpleSchema({\n\t\t\t\tusername: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tpassword: {\n\t\t\t\t\ttype: String\n\t\t\t\t}\n\t\t\t});\n\t\n\t\t\ttry {\n\t\t\t\tschema.validate(body);\n\t\t\t}\n\t\t\tcatch (errors) {\n\t\t\t\tif (errors) {\n\t\t\t\t\tconsole.error(new Date(), 'Error in HTTP Check (/login)', errors);\n\t\n\t\t\t\t\tawait ResolveIOServer.getMainServer().getMethodManager().sendEmail('dev@resolveio.com', ResolveIOServer.getClientName() + 'HTTP - Error Detected', 'Match Error On HTTP ' + '/login' + '\\n\\nData Being Checked\\n' + JSON.stringify(body, null, 2) + '\\n\\nErrors\\n' + JSON.stringify(errors, null, 2));\n\t\n\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\terror: true,\n\t\t\t\t\t\tresult: 'Invalid Parameters'\n\t\t\t\t\t}));\n\t\t\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlet user = await Users.findOne({active: true, username: body.username});\n\n\t\t\tif (!user) {\n\t\t\t\tuser = await Users.findOne({active: true, email: body.username});\n\t\t\t}\n\t\t\t\n\t\t\tif (!user) {\n\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\terror: true,\n\t\t\t\t\tresult: 'Invalid Username And Password'\n\t\t\t\t}));\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tlet resAuth = await Users.authenticate(user, body.password);\n\n\t\t\tif (resAuth['error']) {\n\t\t\t\tif (resAuth['error'] === 'Too Many Attempts') {\n\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\terror: true,\n\t\t\t\t\t\tresult: resAuth['error'] + '. A password reset link has been sent to your email, please reset your password.'\n\t\t\t\t\t}));\n\n\t\t\t\t\tif (!user.services) {\n\t\t\t\t\t\tuser.services = {};\n\t\t\t\t\t}\n\n\t\t\t\t\tuser.services['forgot_password'] = jwt.sign({id_user: user._id}, serverConfig['JWT_SECRET']);\n\n\t\t\t\t\tlet emailData = {\n\t\t\t\t\t\tuserToChangePassword: user.fullname,\n\t\t\t\t\t\tuserWhoResetPassword: ResolveIOServer.getClientName() + ' System',\n\t\t\t\t\t\turl: (serverConfig['ROOT_URL'] + '/forgot-password?' + encodeURIComponent(serverConfig['SERVER_URL']) + '&' + user.services['forgot_password'])\n\t\t\t\t\t};\n\n\t\t\t\t\tawait Users.updateOne({_id: user._id}, {$set: {services: user.services}});\n\t\t\t\t\tlet html = mainServer.getMethodManager().readFile('email-templates/forgot-password.html');\n\t\t\t\t\tlet template = handlebars.compile(html);\n\t\t\t\t\thandlebars.registerHelper('equals', (a, b) => {\n\t\t\t\t\t\treturn a === b;\n\t\t\t\t\t});\n\t\n\t\t\t\t\tawait mainServer.getMethodManager().sendEmail(user.email, 'ResolveIO (' + ResolveIOServer.getClientName() + ') - Forgot Password', '', template(emailData), null, null, '');\n\t\t\t\t}\n\t\t\t\telse if (resAuth['error'] === 'No Salt Value Stored') {\n\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\terror: true,\n\t\t\t\t\t\tresult: 'A password reset link has been sent to your email, please reset your password.'\n\t\t\t\t\t}));\n\n\t\t\t\t\tif (!user.services) {\n\t\t\t\t\t\tuser.services = {};\n\t\t\t\t\t}\n\n\t\t\t\t\tuser.services['forgot_password'] = jwt.sign({id_user: user._id}, serverConfig['JWT_SECRET']);\n\n\t\t\t\t\tlet emailData = {\n\t\t\t\t\t\tuserToChangePassword: user.fullname,\n\t\t\t\t\t\tuserWhoResetPassword: ResolveIOServer.getClientName() + ' System',\n\t\t\t\t\t\turl: (serverConfig['ROOT_URL'] + '/forgot-password?' + encodeURIComponent(serverConfig['SERVER_URL']) + '&' + user.services['forgot_password'])\n\t\t\t\t\t};\n\n\t\t\t\t\tawait Users.updateOne({_id: user._id}, {$set: {services: user.services}});\n\t\t\t\t\tlet html = mainServer.getMethodManager().readFile('email-templates/forgot-password.html');\n\t\t\t\t\tlet template = handlebars.compile(html);\n\t\t\t\t\thandlebars.registerHelper('equals', (a, b) => {\n\t\t\t\t\t\treturn a === b;\n\t\t\t\t\t});\n\n\t\t\t\t\tawait mainServer.getMethodManager().sendEmail(user.email, 'ResolveIO (' + ResolveIOServer.getClientName() + ') - Forgot Password', '', template(emailData), null, null, '');\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\terror: true,\n\t\t\t\t\t\tresult: resAuth['error']\n\t\t\t\t\t}));\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (resAuth && resAuth['data'] && resAuth['data'].active) {\n\t\t\t\t\tawait Users.resetAttempts(resAuth['data']);\n\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\terror: false,\n\t\t\t\t\t\tresult: {\n\t\t\t\t\t\t\ttoken: jwt.sign({id_user: resAuth['data']._id}, serverConfig['JWT_SECRET'], {\n\t\t\t\t\t\t\t\texpiresIn : 90 * 24 * 60 * 60 * 1000 // 90 days\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t} \n\t\t\t\t\t}));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t});\n\n\tapp.post('/accessToken', bodyParser.json(), async (request, response) => {\n\t\tif (!isAllowedOrigin(request.headers.origin, serverConfig)) {\n\t\t\tresponse.send(JSON.stringify({\n\t\t\t\terror: true,\n\t\t\t\tresult: 'Invalid header'\n\t\t\t}));\n\t\t}\n\t\telse {\n\t\t\tlet body = request.body;\n\n\t\t\tlet schema = new SimpleSchema({\n\t\t\t\trefreshToken: {\n\t\t\t\t\ttype: String\n\t\t\t\t}\n\t\t\t});\n\t\n\t\t\ttry {\n\t\t\t\tschema.validate(body);\n\t\t\t}\n\t\t\tcatch (errors) {\n\t\t\t\tif (errors) {\n\t\t\t\t\tconsole.error(new Date(), 'Error in HTTP Check (/accessToken)', errors);\n\t\n\t\t\t\t\tawait ResolveIOServer.getMainServer().getMethodManager().sendEmail('dev@resolveio.com', ResolveIOServer.getClientName() + 'HTTP - Error Detected', 'Match Error On HTTP ' + '/accessToken' + '\\n\\nData Being Checked\\n' + JSON.stringify(body, null, 2) + '\\n\\nErrors\\n' + JSON.stringify(errors, null, 2));\n\t\n\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\terror: true,\n\t\t\t\t\t\tresult: 'Invalid Parameters'\n\t\t\t\t\t}));\n\t\t\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tjwt.verify(body.refreshToken, serverConfig['JWT_SECRET'], async (err, decoded) => {\n\t\t\t\tif (err) {\n\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\terror: true,\n\t\t\t\t\t\tresult: 'Invalid Token'\n\t\t\t\t\t}));\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tlet user = await Users.findById(decoded['id_user']);\n\t\t\t\t\t\tif (user) {\n\t\t\t\t\t\t\tif (user.active) {\n\t\t\t\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\t\t\t\terror: false,\n\t\t\t\t\t\t\t\t\tresult: {\n\t\t\t\t\t\t\t\t\t\ttoken: jwt.sign({id_user: user._id}, serverConfig['JWT_SECRET'], {\n\t\t\t\t\t\t\t\t\t\t\texpiresIn : 3 * 24 * 60 * 60 * 1000 // 3 days\n\t\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\t\tuser: user\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\t\t\t\terror: true,\n\t\t\t\t\t\t\t\t\tresult: 'Account is Disabled'\n\t\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\t\t\terror: true,\n\t\t\t\t\t\t\t\tresult: 'Invalid User'\n\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tcatch {\n\t\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\t\terror: true,\n\t\t\t\t\t\t\tresult: 'Invalid Mongo Get User'\n\t\t\t\t\t\t}));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t});\n\n\tapp.post('/userWithEnrollmentToken', bodyParser.json(), async (request, response) => {\n\t\tif (!isAllowedOrigin(request.headers.origin, serverConfig)) {\n\t\t\tresponse.send(JSON.stringify({\n\t\t\t\terror: true,\n\t\t\t\tresult: 'Invalid header'\n\t\t\t}));\n\t\t}\n\t\telse {\n\t\t\tlet body = request.body;\n\n\t\t\tlet schema = new SimpleSchema({\n\t\t\t\tenrollmentToken: {\n\t\t\t\t\ttype: String\n\t\t\t\t}\n\t\t\t});\n\t\n\t\t\ttry {\n\t\t\t\tschema.validate(body);\n\t\t\t}\n\t\t\tcatch (errors) {\n\t\t\t\tif (errors) {\n\t\t\t\t\tconsole.error(new Date(), 'Error in HTTP Check (/userWithEnrollmentToken)', errors);\n\t\n\t\t\t\t\tawait ResolveIOServer.getMainServer().getMethodManager().sendEmail('dev@resolveio.com', ResolveIOServer.getClientName() + 'HTTP - Error Detected', 'Match Error On HTTP ' + '/userWithEnrollmentToken' + '\\n\\nData Being Checked\\n' + JSON.stringify(body, null, 2) + '\\n\\nErrors\\n' + JSON.stringify(errors, null, 2));\n\t\n\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\terror: true,\n\t\t\t\t\t\tresult: 'Invalid Parameters'\n\t\t\t\t\t}));\n\t\t\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tjwt.verify(body.enrollmentToken, serverConfig['JWT_SECRET'], async (err, decoded) => {\n\t\t\t\tif (err) {\n\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\terror: true,\n\t\t\t\t\t\tresult: 'Invalid Token'\n\t\t\t\t\t}));\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tlet user = await Users.findOne({\n\t\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t\t{_id: decoded['id_user']},\n\t\t\t\t\t\t\t\t{'services.enrollment': body.enrollmentToken}\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t}, {projection: {_id: 1, __v: 1, username: 1, active: 1}});\n\t\t\t\t\t\tif (user) {\n\t\t\t\t\t\t\tif (user.active) {\n\n\t\t\t\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\t\t\t\terror: false,\n\t\t\t\t\t\t\t\t\tresult: {\n\t\t\t\t\t\t\t\t\t\tuser: user\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\t\t\t\terror: true,\n\t\t\t\t\t\t\t\t\tresult: 'Account is Disabled'\n\t\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\t\t\terror: true,\n\t\t\t\t\t\t\t\tresult: 'Invalid User'\n\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tcatch {\n\t\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\t\terror: true,\n\t\t\t\t\t\t\tresult: 'Invalid Mongo Get User'\n\t\t\t\t\t\t}));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t});\n\n\tapp.post('/setUserWithEnrollmentToken', bodyParser.json(), async (request, response) => {\n\t\tif (!isAllowedOrigin(request.headers.origin, serverConfig)) {\n\t\t\tresponse.send(JSON.stringify({\n\t\t\t\terror: true,\n\t\t\t\tresult: 'Invalid header'\n\t\t\t}));\n\t\t}\n\t\telse {\n\t\t\tlet body = request.body;\n\n\t\t\tlet schema = new SimpleSchema({\n\t\t\t\tenrollmentToken: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tpassword: {\n\t\t\t\t\ttype: String\n\t\t\t\t}\n\t\t\t});\n\t\n\t\t\ttry {\n\t\t\t\tschema.validate(body);\n\t\t\t}\n\t\t\tcatch (errors) {\n\t\t\t\tif (errors) {\n\t\t\t\t\tconsole.error(new Date(), 'Error in HTTP Check (/setUserWithEnrollmentToken)', errors);\n\t\n\t\t\t\t\tawait ResolveIOServer.getMainServer().getMethodManager().sendEmail('dev@resolveio.com', ResolveIOServer.getClientName() + 'HTTP - Error Detected', 'Match Error On HTTP ' + '/setUserWithEnrollmentToken' + '\\n\\nData Being Checked\\n' + JSON.stringify(body, null, 2) + '\\n\\nErrors\\n' + JSON.stringify(errors, null, 2));\n\t\n\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\terror: true,\n\t\t\t\t\t\tresult: 'Invalid Parameters'\n\t\t\t\t\t}));\n\t\t\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tjwt.verify(body.enrollmentToken, serverConfig['JWT_SECRET'], async (err, decoded) => {\n\t\t\t\tif (err) {\n\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\terror: true,\n\t\t\t\t\t\tresult: 'Invalid Token'\n\t\t\t\t\t}));\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tlet user = await Users.findOne({\n\t\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t\t{_id: decoded['id_user']},\n\t\t\t\t\t\t\t\t{'services.enrollment': body.enrollmentToken}\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t});\n\t\t\t\t\t\tif (user) {\n\t\t\t\t\t\t\tif (user.active) {\n\t\t\t\t\t\t\t\tawait Users.setPassword(user, body.password);\n\n\t\t\t\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\t\t\t\terror: false,\n\t\t\t\t\t\t\t\t\tresult: true\n\t\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\t\t\t\terror: true,\n\t\t\t\t\t\t\t\t\tresult: 'Account is Disabled'\n\t\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\t\t\terror: true,\n\t\t\t\t\t\t\t\tresult: 'Invalid User'\n\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tcatch {\n\t\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\t\terror: true,\n\t\t\t\t\t\t\tresult: 'Invalid Mongo Get User'\n\t\t\t\t\t\t}));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t});\n\n\tapp.post('/userWithForgotPasswordToken', bodyParser.json(), async (request, response) => {\n\t\tif (!isAllowedOrigin(request.headers.origin, serverConfig)) {\n\t\t\tresponse.send(JSON.stringify({\n\t\t\t\terror: true,\n\t\t\t\tresult: 'Invalid header'\n\t\t\t}));\n\t\t}\n\t\telse {\n\t\t\tlet body = request.body;\n\n\t\t\tlet schema = new SimpleSchema({\n\t\t\t\tforgotPasswordToken: {\n\t\t\t\t\ttype: String\n\t\t\t\t}\n\t\t\t});\n\t\n\t\t\ttry {\n\t\t\t\tschema.validate(body);\n\t\t\t}\n\t\t\tcatch (errors) {\n\t\t\t\tif (errors) {\n\t\t\t\t\tconsole.error(new Date(), 'Error in HTTP Check (/userWithForgotPasswordToken)', errors);\n\t\n\t\t\t\t\tawait ResolveIOServer.getMainServer().getMethodManager().sendEmail('dev@resolveio.com', ResolveIOServer.getClientName() + 'HTTP - Error Detected', 'Match Error On HTTP ' + '/userWithForgotPasswordToken' + '\\n\\nData Being Checked\\n' + JSON.stringify(body, null, 2) + '\\n\\nErrors\\n' + JSON.stringify(errors, null, 2));\n\t\n\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\terror: true,\n\t\t\t\t\t\tresult: 'Invalid Parameters'\n\t\t\t\t\t}));\n\t\t\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tjwt.verify(body.forgotPasswordToken, serverConfig['JWT_SECRET'], async (err, decoded) => {\n\t\t\t\tif (err) {\n\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\terror: true,\n\t\t\t\t\t\tresult: 'Invalid Token'\n\t\t\t\t\t}));\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tlet user = await Users.findOne({\n\t\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t\t{_id: decoded['id_user']},\n\t\t\t\t\t\t\t\t{'services.forgot_password': body.forgotPasswordToken}\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t}, {projection: {_id: 1, __v: 1, username: 1, active: 1}});\n\t\t\t\t\t\t\t\n\t\t\t\t\t\tif (user) {\n\t\t\t\t\t\t\tif (user.active) {\n\t\t\t\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\t\t\t\terror: false,\n\t\t\t\t\t\t\t\t\tresult: {\n\t\t\t\t\t\t\t\t\t\tuser: user\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\t\t\t\terror: true,\n\t\t\t\t\t\t\t\t\tresult: 'Account is Disabled'\n\t\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\t\t\terror: true,\n\t\t\t\t\t\t\t\tresult: 'Invalid Token'\n\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tcatch {\n\t\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\t\terror: true,\n\t\t\t\t\t\t\tresult: 'Invalid Mongo Get User'\n\t\t\t\t\t\t}));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t});\n\n\tapp.post('/setUserWithForgotPasswordToken', bodyParser.json(), async (request, response) => {\n\t\tif (!isAllowedOrigin(request.headers.origin, serverConfig)) {\n\t\t\tresponse.send(JSON.stringify({\n\t\t\t\terror: true,\n\t\t\t\tresult: 'Invalid header'\n\t\t\t}));\n\t\t}\n\t\telse {\n\t\t\tlet body = request.body;\n\n\t\t\tlet schema = new SimpleSchema({\n\t\t\t\tforgotPasswordToken: {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\tpassword: {\n\t\t\t\t\ttype: String\n\t\t\t\t}\n\t\t\t});\n\t\n\t\t\ttry {\n\t\t\t\tschema.validate(body);\n\t\t\t}\n\t\t\tcatch (errors) {\n\t\t\t\tif (errors) {\n\t\t\t\t\tconsole.error(new Date(), 'Error in HTTP Check (/setUserWithForgotPasswordToken)', errors);\n\t\n\t\t\t\t\tawait ResolveIOServer.getMainServer().getMethodManager().sendEmail('dev@resolveio.com', ResolveIOServer.getClientName() + 'HTTP - Error Detected', 'Match Error On HTTP ' + '/setUserWithForgotPasswordToken' + '\\n\\nData Being Checked\\n' + JSON.stringify(body, null, 2) + '\\n\\nErrors\\n' + JSON.stringify(errors, null, 2));\n\t\n\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\terror: true,\n\t\t\t\t\t\tresult: 'Invalid Parameters'\n\t\t\t\t\t}));\n\t\t\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tjwt.verify(body.forgotPasswordToken, serverConfig['JWT_SECRET'], async (err, decoded) => {\n\t\t\t\tif (err) {\n\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\terror: true,\n\t\t\t\t\t\tresult: 'Invalid Token'\n\t\t\t\t\t}));\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tlet user = await Users.findOne({\n\t\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t\t{_id: decoded['id_user']},\n\t\t\t\t\t\t\t\t{'services.forgot_password': body.forgotPasswordToken}\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\n\t\t\t\t\t\tif (user) {\n\t\t\t\t\t\t\tif (user.active) {\n\t\t\t\t\t\t\t\tawait Users.setPassword(user, body.password);\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\t\t\t\terror: false,\n\t\t\t\t\t\t\t\t\tresult: true\n\t\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\t\t\t\terror: true,\n\t\t\t\t\t\t\t\t\tresult: 'Account is Disabled'\n\t\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\t\t\terror: true,\n\t\t\t\t\t\t\t\tresult: 'Invalid User'\n\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tcatch {\n\t\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\t\terror: true,\n\t\t\t\t\t\t\tresult: 'Invalid Mongo Get User'\n\t\t\t\t\t\t}));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t});\n\n\tapp.post('/resetPassword', bodyParser.json(), async (request, response) => {\n\t\tif (!isAllowedOrigin(request.headers.origin, serverConfig)) {\n\t\t\tresponse.send(JSON.stringify({\n\t\t\t\terror: true,\n\t\t\t\tresult: 'Invalid header'\n\t\t\t}));\n\t\t}\n\t\telse {\n\t\t\tlet body = request.body;\n\n\t\t\tlet schema = new SimpleSchema({\n\t\t\t\tusername: {\n\t\t\t\t\ttype: String\n\t\t\t\t}\n\t\t\t});\n\t\n\t\t\ttry {\n\t\t\t\tschema.validate(body);\n\t\t\t}\n\t\t\tcatch (errors) {\n\t\t\t\tif (errors) {\n\t\t\t\t\tconsole.error(new Date(), 'Error in HTTP Check (/resetPassword)', errors);\n\t\n\t\t\t\t\tawait ResolveIOServer.getMainServer().getMethodManager().sendEmail('dev@resolveio.com', ResolveIOServer.getClientName() + 'HTTP - Error Detected', 'Match Error On HTTP ' + '/resetPassword' + '\\n\\nData Being Checked\\n' + JSON.stringify(body, null, 2) + '\\n\\nErrors\\n' + JSON.stringify(errors, null, 2));\n\t\n\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\terror: true,\n\t\t\t\t\t\tresult: 'Invalid Parameters'\n\t\t\t\t\t}));\n\t\t\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlet user = await Users.findOne({active: true, username: body.username});\n\n\t\t\tif (!user) {\n\t\t\t\tuser = await Users.findOne({active: true, email: body.username});\n\t\t\t}\n\t\t\t\n\t\t\tif (user) {\n\t\t\t\tmainServer.getMethodManager().callMethod.call(mainServer.getMethodManager(), 'resetUserPassword', user._id);\n\t\t\t}\n\n\t\t\tresponse.send(JSON.stringify({\n\t\t\t\terror: false,\n\t\t\t\tresult: ''\n\t\t\t}));\n\t\t}\n\t});\n}\n"]}
|
package/http/home.js
CHANGED
|
@@ -40,6 +40,7 @@ exports.setupHomeRoutes = void 0;
|
|
|
40
40
|
var bodyParser = require("body-parser");
|
|
41
41
|
var simpl_schema_1 = require("simpl-schema");
|
|
42
42
|
var resolveio_server_app_1 = require("../resolveio-server-app");
|
|
43
|
+
var common_1 = require("../util/common");
|
|
43
44
|
function setupHomeRoutes(mainServer, app, serverConfig) {
|
|
44
45
|
var _this = this;
|
|
45
46
|
app.post('/resolveioContactUs', bodyParser.json(), function (request, response) { return __awaiter(_this, void 0, void 0, function () {
|
|
@@ -47,7 +48,7 @@ function setupHomeRoutes(mainServer, app, serverConfig) {
|
|
|
47
48
|
return __generator(this, function (_a) {
|
|
48
49
|
switch (_a.label) {
|
|
49
50
|
case 0:
|
|
50
|
-
if (
|
|
51
|
+
if (!!(0, common_1.isAllowedOrigin)(request.headers.origin, serverConfig)) return [3 /*break*/, 1];
|
|
51
52
|
response.send(JSON.stringify({
|
|
52
53
|
error: true,
|
|
53
54
|
result: 'Invalid header'
|
package/http/home.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/http/home.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wCAA0C;AAC1C,6CAAwC;AACxC,gEAA0D;
|
|
1
|
+
{"version":3,"sources":["../../src/http/home.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;A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CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,cAAc,GAAG,IAAI,CAAC,SAAS,CAAC,QAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAA;;oBAAlT,SAAkT,CAAC;oBAEnT,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC;wBAC5B,KAAK,EAAE,IAAI;wBACX,MAAM,EAAE,oBAAoB;qBAC5B,CAAC,CAAC,CAAC;oBAEJ,sBAAO;;;oBAII,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC;oBAE7B,UAAU,CAAC,gBAAgB,EAAE,CAAC,SAAS,CAAC,sBAAsB,EAAE,wBAAwB,EAAE,EAAE,EAC5F,QAAQ,GAAG,IAAI,CAAC,IAAI,GAAG,MAAM;wBAC7B,SAAS,GAAG,IAAI,CAAC,KAAK,GAAG,MAAM;wBAC/B,SAAS,GAAG,IAAI,CAAC,KAAK,GAAG,MAAM;wBAC/B,WAAW,GAAG,IAAI,CAAC,OAAO,GAAG,MAAM;wBACnC,WAAW,GAAG,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,CAAC;oBAErC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC;wBACrC,KAAK,EAAE,KAAK;wBACZ,MAAM,EAAE,IAAI;qBACZ,CAAC,CAAC,CAAC;;;;;SAEL,CAAC,CAAC;AACJ,CAAC;AAjED,0CAiEC","file":"home.js","sourcesContent":["import * as bodyParser from 'body-parser';\nimport SimpleSchema from 'simpl-schema';\nimport { ResolveIOServer } from '../resolveio-server-app';\nimport { isAllowedOrigin } from '../util/common';\n\nexport function setupHomeRoutes(mainServer, app, serverConfig) {\n\tapp.post('/resolveioContactUs', bodyParser.json(), async (request, response) => {\n\t\tif (!isAllowedOrigin(request.headers.origin, serverConfig)) {\n\t\t\tresponse.send(JSON.stringify({\n\t\t\t\terror: true,\n\t\t\t\tresult: 'Invalid header'\n\t\t\t}));\n\t\t}\n\t\telse {\n\t\t\tlet body = request.body;\n\n\t\t\tlet schema = new SimpleSchema({\n\t\t\t\tform: {\n\t\t\t\t\ttype: Object\n\t\t\t\t},\n\t\t\t\t'form.name': {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\t'form.email': {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\t'form.phone': {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\t'form.subject': {\n\t\t\t\t\ttype: String\n\t\t\t\t},\n\t\t\t\t'form.message': {\n\t\t\t\t\ttype: String\n\t\t\t\t}\n\t\t\t});\n\t\n\t\t\ttry {\n\t\t\t\tschema.validate(body);\n\t\t\t}\n\t\t\tcatch (errors) {\n\t\t\t\tif (errors) {\n\t\t\t\t\tconsole.error(new Date(), 'Error in HTTP Check (/resolveioContactUs)', errors);\n\t\n\t\t\t\t\tawait ResolveIOServer.getMainServer().getMethodManager().sendEmail('dev@resolveio.com', ResolveIOServer.getClientName() + 'HTTP - Error Detected', 'Match Error On HTTP ' + '/resolveioContactUs' + '\\n\\nData Being Checked\\n' + JSON.stringify(body, null, 2) + '\\n\\nErrors\\n' + JSON.stringify(errors, null, 2));\n\t\n\t\t\t\t\tresponse.send(JSON.stringify({\n\t\t\t\t\t\terror: true,\n\t\t\t\t\t\tresult: 'Invalid Parameters'\n\t\t\t\t\t}));\n\t\t\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n let form = request.body.form;\n \n mainServer.getMethodManager().sendEmail('dustin@resolveio.com', 'ResolveIO - Contact Us', '', \n 'Name: ' + form.name + '<br>' + \n 'Email: ' + form.email + '<br>' + \n 'Phone: ' + form.phone + '<br>' + \n 'Subject: ' + form.subject + '<br>' + \n 'Message: ' + form.message + '<br>');\n\n response.send(JSON.stringify({\n\t\t\t\terror: false,\n\t\t\t\tresult: null\n\t\t\t}));\n\t\t}\n\t});\n}\n"]}
|
|
@@ -85,9 +85,13 @@ export declare class MongoManager {
|
|
|
85
85
|
private _serverCollections;
|
|
86
86
|
private _isWorkersEnabled;
|
|
87
87
|
private _isWorkerInstance;
|
|
88
|
+
private _watchedDatabases;
|
|
89
|
+
private _mainDatabaseName;
|
|
88
90
|
constructor();
|
|
89
91
|
static create(): Promise<MongoManager>;
|
|
90
92
|
private initialize;
|
|
93
|
+
private resolveWatchedDatabases;
|
|
94
|
+
getWatchedDatabases(): string[];
|
|
91
95
|
oneTimeTransaction<T>(fn: () => Promise<T>): Promise<T>;
|
|
92
96
|
getSession(): any;
|
|
93
97
|
private setCacheLimit;
|
|
@@ -72,6 +72,17 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
72
72
|
}
|
|
73
73
|
return t;
|
|
74
74
|
};
|
|
75
|
+
var __values = (this && this.__values) || function(o) {
|
|
76
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
77
|
+
if (m) return m.call(o);
|
|
78
|
+
if (o && typeof o.length === "number") return {
|
|
79
|
+
next: function () {
|
|
80
|
+
if (o && i >= o.length) o = void 0;
|
|
81
|
+
return { value: o && o[i++], done: !o };
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
85
|
+
};
|
|
75
86
|
var __read = (this && this.__read) || function (o, n) {
|
|
76
87
|
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
77
88
|
if (!m) return o;
|
|
@@ -97,17 +108,6 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
97
108
|
}
|
|
98
109
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
99
110
|
};
|
|
100
|
-
var __values = (this && this.__values) || function(o) {
|
|
101
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
102
|
-
if (m) return m.call(o);
|
|
103
|
-
if (o && typeof o.length === "number") return {
|
|
104
|
-
next: function () {
|
|
105
|
-
if (o && i >= o.length) o = void 0;
|
|
106
|
-
return { value: o && o[i++], done: !o };
|
|
107
|
-
}
|
|
108
|
-
};
|
|
109
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
110
|
-
};
|
|
111
111
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
112
112
|
exports.MongoManagerUserCollection = exports.MongoManagerCollection = exports.MongoManagerModel = exports.MongoManager = void 0;
|
|
113
113
|
var NodeCache = require("node-cache");
|
|
@@ -132,6 +132,8 @@ var MongoManager = /** @class */ (function () {
|
|
|
132
132
|
this._serverCollections = [];
|
|
133
133
|
this._isWorkersEnabled = false;
|
|
134
134
|
this._isWorkerInstance = false;
|
|
135
|
+
this._watchedDatabases = [];
|
|
136
|
+
this._mainDatabaseName = '';
|
|
135
137
|
}
|
|
136
138
|
MongoManager.create = function () {
|
|
137
139
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -157,6 +159,8 @@ var MongoManager = /** @class */ (function () {
|
|
|
157
159
|
this._nodeCache = new NodeCache({ stdTTL: 0, checkperiod: 0 });
|
|
158
160
|
this._isWorkersEnabled = process.env.IS_WORKERS_ENABLED === 'true';
|
|
159
161
|
this._isWorkerInstance = process.env.IS_WORKER_INSTANCE === 'true';
|
|
162
|
+
this._mainDatabaseName = resolveio_server_app_1.ResolveIOServer.getServerConfig() ? resolveio_server_app_1.ResolveIOServer.getServerConfig()['DATABASE'] : '';
|
|
163
|
+
this._watchedDatabases = this.resolveWatchedDatabases();
|
|
160
164
|
this.setCacheLimit();
|
|
161
165
|
if (this._isWorkersEnabled && this._isWorkerInstance) {
|
|
162
166
|
this.setupChangeStream();
|
|
@@ -170,6 +174,43 @@ var MongoManager = /** @class */ (function () {
|
|
|
170
174
|
});
|
|
171
175
|
});
|
|
172
176
|
};
|
|
177
|
+
MongoManager.prototype.resolveWatchedDatabases = function () {
|
|
178
|
+
var e_1, _a;
|
|
179
|
+
var config = resolveio_server_app_1.ResolveIOServer.getServerConfig ? resolveio_server_app_1.ResolveIOServer.getServerConfig() : null;
|
|
180
|
+
var watchSet = new Set();
|
|
181
|
+
if (this._mainDatabaseName) {
|
|
182
|
+
watchSet.add(this._mainDatabaseName);
|
|
183
|
+
}
|
|
184
|
+
var configValue = config ? config['WATCH_DATABASES'] : null;
|
|
185
|
+
if (Array.isArray(configValue)) {
|
|
186
|
+
try {
|
|
187
|
+
for (var configValue_1 = __values(configValue), configValue_1_1 = configValue_1.next(); !configValue_1_1.done; configValue_1_1 = configValue_1.next()) {
|
|
188
|
+
var value = configValue_1_1.value;
|
|
189
|
+
if (typeof value === 'string' && value.trim()) {
|
|
190
|
+
watchSet.add(value.trim());
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
195
|
+
finally {
|
|
196
|
+
try {
|
|
197
|
+
if (configValue_1_1 && !configValue_1_1.done && (_a = configValue_1.return)) _a.call(configValue_1);
|
|
198
|
+
}
|
|
199
|
+
finally { if (e_1) throw e_1.error; }
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
else if (typeof configValue === 'string' && configValue.trim()) {
|
|
203
|
+
configValue.split(',').map(function (a) { return a.trim(); }).filter(function (a) { return a.length; }).forEach(function (a) { return watchSet.add(a); });
|
|
204
|
+
}
|
|
205
|
+
var envValue = process.env.MONGO_WATCH_DATABASES;
|
|
206
|
+
if (envValue) {
|
|
207
|
+
envValue.split(',').map(function (a) { return a.trim(); }).filter(function (a) { return a.length; }).forEach(function (a) { return watchSet.add(a); });
|
|
208
|
+
}
|
|
209
|
+
return Array.from(watchSet.values());
|
|
210
|
+
};
|
|
211
|
+
MongoManager.prototype.getWatchedDatabases = function () {
|
|
212
|
+
return this._watchedDatabases;
|
|
213
|
+
};
|
|
173
214
|
MongoManager.prototype.oneTimeTransaction = function (fn) {
|
|
174
215
|
var _this = this;
|
|
175
216
|
return asyncLocalStorage.run({}, function () { return __awaiter(_this, void 0, void 0, function () {
|
|
@@ -615,7 +656,7 @@ var MongoManager = /** @class */ (function () {
|
|
|
615
656
|
return undefined;
|
|
616
657
|
};
|
|
617
658
|
MongoManager.prototype.addToCache = function (collections, cacheKey, data) {
|
|
618
|
-
var
|
|
659
|
+
var e_2, _a;
|
|
619
660
|
if ((0, common_1.getBinarySize)(JSON.stringify(data)) < 1000000 &&
|
|
620
661
|
!collections.includes('logs') &&
|
|
621
662
|
!collections.find(function (a) { return a.endsWith('.versions'); }) &&
|
|
@@ -635,12 +676,12 @@ var MongoManager = /** @class */ (function () {
|
|
|
635
676
|
}
|
|
636
677
|
}
|
|
637
678
|
}
|
|
638
|
-
catch (
|
|
679
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
639
680
|
finally {
|
|
640
681
|
try {
|
|
641
682
|
if (keys_1_1 && !keys_1_1.done && (_a = keys_1.return)) _a.call(keys_1);
|
|
642
683
|
}
|
|
643
|
-
finally { if (
|
|
684
|
+
finally { if (e_2) throw e_2.error; }
|
|
644
685
|
}
|
|
645
686
|
console.log('Query Cache: ' + 'Too Big, - Deleted: ' + deleteCount + ' - ' + nodeCacheSize);
|
|
646
687
|
}
|
|
@@ -649,7 +690,7 @@ var MongoManager = /** @class */ (function () {
|
|
|
649
690
|
}
|
|
650
691
|
};
|
|
651
692
|
MongoManager.prototype.invalidateQueryCache = function (collection) {
|
|
652
|
-
var
|
|
693
|
+
var e_3, _a, e_4, _b;
|
|
653
694
|
var collectionCacheMap = this._cacheMap.filter(function (a) { return a.collections.includes(collection); });
|
|
654
695
|
if (resolveio_server_app_1.ResolveIOServer.getMainServer().getSubscriptionManager() && resolveio_server_app_1.ResolveIOServer.getMainServer().getSubscriptionManager().getEnableDebug()) {
|
|
655
696
|
console.log(new Date(), 'Mongo Invalidate Cache', collection);
|
|
@@ -666,12 +707,12 @@ var MongoManager = /** @class */ (function () {
|
|
|
666
707
|
}
|
|
667
708
|
}
|
|
668
709
|
}
|
|
669
|
-
catch (
|
|
710
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
670
711
|
finally {
|
|
671
712
|
try {
|
|
672
713
|
if (collectionCacheMap_1_1 && !collectionCacheMap_1_1.done && (_a = collectionCacheMap_1.return)) _a.call(collectionCacheMap_1);
|
|
673
714
|
}
|
|
674
|
-
finally { if (
|
|
715
|
+
finally { if (e_3) throw e_3.error; }
|
|
675
716
|
}
|
|
676
717
|
try {
|
|
677
718
|
// eslint-disable-next-line no-unused-vars
|
|
@@ -685,22 +726,23 @@ var MongoManager = /** @class */ (function () {
|
|
|
685
726
|
}
|
|
686
727
|
}
|
|
687
728
|
}
|
|
688
|
-
catch (
|
|
729
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
689
730
|
finally {
|
|
690
731
|
try {
|
|
691
732
|
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
692
733
|
}
|
|
693
|
-
finally { if (
|
|
734
|
+
finally { if (e_4) throw e_4.error; }
|
|
694
735
|
}
|
|
695
736
|
this._cacheMap = this._cacheMap.filter(function (a) { return !a.collections.includes(collection); });
|
|
696
737
|
};
|
|
697
738
|
MongoManager.prototype.setupChangeStream = function () {
|
|
698
739
|
var _this = this;
|
|
699
|
-
var
|
|
740
|
+
var client = resolveio_server_app_1.ResolveIOServer.getMongoConnection();
|
|
741
|
+
var watchDatabases = this._watchedDatabases.length ? this._watchedDatabases : (this._mainDatabaseName ? [this._mainDatabaseName] : []);
|
|
700
742
|
var pipeline = [
|
|
701
743
|
{
|
|
702
744
|
$match: {
|
|
703
|
-
$and: [
|
|
745
|
+
$and: __spreadArray(__spreadArray([], __read((watchDatabases.length ? [{ 'ns.db': { $in: watchDatabases } }] : [])), false), [
|
|
704
746
|
{ 'ns.coll': { $nin: [
|
|
705
747
|
'log-method-latencies',
|
|
706
748
|
'log-subscriptions',
|
|
@@ -715,11 +757,11 @@ var MongoManager = /** @class */ (function () {
|
|
|
715
757
|
] } },
|
|
716
758
|
{ 'ns.coll': { $not: /.*\.versions$/ } },
|
|
717
759
|
{ 'ns.coll': { $not: /^monitor-/ } },
|
|
718
|
-
]
|
|
760
|
+
], false)
|
|
719
761
|
},
|
|
720
762
|
},
|
|
721
763
|
];
|
|
722
|
-
var changeStream =
|
|
764
|
+
var changeStream = client.watch(pipeline, { fullDocument: 'updateLookup' });
|
|
723
765
|
changeStream.on('change', function (change) {
|
|
724
766
|
if (change['ns'] && change['ns'].coll) {
|
|
725
767
|
var collectionName = change['ns'].coll;
|
|
@@ -1031,7 +1073,7 @@ var MongoManagerCollection = /** @class */ (function () {
|
|
|
1031
1073
|
if (bypassSession === void 0) { bypassSession = false; }
|
|
1032
1074
|
return __awaiter(this, void 0, void 0, function () {
|
|
1033
1075
|
var BATCH_SIZE, opIndex, mongoSession, _a, session, safeOptions, batchOps, logs, versionOps, batchOps_1, batchOps_1_1, op, opType, doc, validationContext, isValid, affectedDocs, versionFilters, versionInserts, _b, _c, monitor, err_7, bwOptions, affectedDocIds, pipeline, oldVersions, _d;
|
|
1034
|
-
var
|
|
1076
|
+
var e_5, _e;
|
|
1035
1077
|
return __generator(this, function (_f) {
|
|
1036
1078
|
switch (_f.label) {
|
|
1037
1079
|
case 0:
|
|
@@ -1057,7 +1099,7 @@ var MongoManagerCollection = /** @class */ (function () {
|
|
|
1057
1099
|
logs = [];
|
|
1058
1100
|
versionOps = [];
|
|
1059
1101
|
try {
|
|
1060
|
-
for (batchOps_1 = (
|
|
1102
|
+
for (batchOps_1 = (e_5 = void 0, __values(batchOps)), batchOps_1_1 = batchOps_1.next(); !batchOps_1_1.done; batchOps_1_1 = batchOps_1.next()) {
|
|
1061
1103
|
op = batchOps_1_1.value;
|
|
1062
1104
|
opType = Object.keys(op)[0];
|
|
1063
1105
|
doc = op[opType];
|
|
@@ -1227,12 +1269,12 @@ var MongoManagerCollection = /** @class */ (function () {
|
|
|
1227
1269
|
}
|
|
1228
1270
|
}
|
|
1229
1271
|
}
|
|
1230
|
-
catch (
|
|
1272
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
1231
1273
|
finally {
|
|
1232
1274
|
try {
|
|
1233
1275
|
if (batchOps_1_1 && !batchOps_1_1.done && (_e = batchOps_1.return)) _e.call(batchOps_1);
|
|
1234
1276
|
}
|
|
1235
|
-
finally { if (
|
|
1277
|
+
finally { if (e_5) throw e_5.error; }
|
|
1236
1278
|
}
|
|
1237
1279
|
affectedDocs = [];
|
|
1238
1280
|
if (!(!bypassVersions && this.useVersions && versionOps.length > 0)) return [3 /*break*/, 10];
|
|
@@ -2630,8 +2672,8 @@ var MongoManagerCollection = /** @class */ (function () {
|
|
|
2630
2672
|
if (bypassMonitor === void 0) { bypassMonitor = false; }
|
|
2631
2673
|
if (bypassSession === void 0) { bypassSession = false; }
|
|
2632
2674
|
return __awaiter(this, void 0, void 0, function () {
|
|
2633
|
-
var validationResults, docs_1, docs_1_1, doc, validation, isValid,
|
|
2634
|
-
var
|
|
2675
|
+
var validationResults, docs_1, docs_1_1, doc, validation, isValid, e_6_1, validDocs, mongoSession, _a, session, safeOptions, i, doc, date, monitor, err_25;
|
|
2676
|
+
var e_6, _b;
|
|
2635
2677
|
return __generator(this, function (_c) {
|
|
2636
2678
|
switch (_c.label) {
|
|
2637
2679
|
case 0:
|
|
@@ -2665,14 +2707,14 @@ var MongoManagerCollection = /** @class */ (function () {
|
|
|
2665
2707
|
return [3 /*break*/, 2];
|
|
2666
2708
|
case 6: return [3 /*break*/, 9];
|
|
2667
2709
|
case 7:
|
|
2668
|
-
|
|
2669
|
-
|
|
2710
|
+
e_6_1 = _c.sent();
|
|
2711
|
+
e_6 = { error: e_6_1 };
|
|
2670
2712
|
return [3 /*break*/, 9];
|
|
2671
2713
|
case 8:
|
|
2672
2714
|
try {
|
|
2673
2715
|
if (docs_1_1 && !docs_1_1.done && (_b = docs_1.return)) _b.call(docs_1);
|
|
2674
2716
|
}
|
|
2675
|
-
finally { if (
|
|
2717
|
+
finally { if (e_6) throw e_6.error; }
|
|
2676
2718
|
return [7 /*endfinally*/];
|
|
2677
2719
|
case 9:
|
|
2678
2720
|
validDocs = this.checkSchema ? docs.filter(function (a, idx) { return validationResults[idx]; }) : docs;
|