@resolveio/server-lib 20.5.13 → 20.5.15

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.
Files changed (51) hide show
  1. package/collections/log-method-latency.collection.js +1 -1
  2. package/collections/log-method-latency.collection.js.map +1 -1
  3. package/collections/log-subscription.collection.js +1 -1
  4. package/collections/log-subscription.collection.js.map +1 -1
  5. package/collections/log.collection.js +1 -1
  6. package/collections/log.collection.js.map +1 -1
  7. package/collections/monitor-function.collection.d.ts +3 -0
  8. package/collections/monitor-function.collection.js +2 -0
  9. package/collections/monitor-function.collection.js.map +1 -0
  10. package/http/auth.js +1 -1
  11. package/http/auth.js.map +1 -1
  12. package/managers/local-log.manager.d.ts +1 -1
  13. package/managers/local-log.manager.js.map +1 -1
  14. package/managers/method.manager.d.ts +2 -4
  15. package/managers/method.manager.js +1 -1
  16. package/managers/method.manager.js.map +1 -1
  17. package/managers/mongo.manager.js +1 -1
  18. package/managers/mongo.manager.js.map +1 -1
  19. package/managers/monitor.manager.d.ts +7 -6
  20. package/managers/monitor.manager.js +1 -1
  21. package/managers/monitor.manager.js.map +1 -1
  22. package/managers/subscription.manager.js +1 -1
  23. package/managers/subscription.manager.js.map +1 -1
  24. package/methods/aws.js +1 -1
  25. package/methods/aws.js.map +1 -1
  26. package/methods/cron-jobs.js +1 -1
  27. package/methods/cron-jobs.js.map +1 -1
  28. package/methods/logs.js +1 -1
  29. package/methods/logs.js.map +1 -1
  30. package/methods/pdf.js +1 -1
  31. package/methods/pdf.js.map +1 -1
  32. package/methods.ts +0 -3
  33. package/models/log.model.d.ts +1 -1
  34. package/models/monitor-function.model.d.ts +14 -0
  35. package/models/{worker-task-request.model.js → monitor-function.model.js} +1 -1
  36. package/models/monitor-function.model.js.map +1 -0
  37. package/package.json +1 -1
  38. package/server-app.d.ts +33 -2
  39. package/server-app.js +1 -1
  40. package/server-app.js.map +1 -1
  41. package/collections/worker-task-request.collection.d.ts +0 -3
  42. package/collections/worker-task-request.collection.js +0 -2
  43. package/collections/worker-task-request.collection.js.map +0 -1
  44. package/collections/worker-task-response.collection.d.ts +0 -3
  45. package/collections/worker-task-response.collection.js +0 -2
  46. package/collections/worker-task-response.collection.js.map +0 -1
  47. package/models/worker-task-request.model.d.ts +0 -10
  48. package/models/worker-task-request.model.js.map +0 -1
  49. package/models/worker-task-response.model.d.ts +0 -9
  50. package/models/worker-task-response.model.js +0 -2
  51. package/models/worker-task-response.model.js.map +0 -1
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.LogMethodLatencies=void 0;var resolveio_server_app_1=require("../resolveio-server-app"),mongo_manager_1=require("../managers/mongo.manager"),schema={_id:{type:String,optional:!0},__v:{type:Number,optional:!0},updatedAt:{type:Date,optional:!0},createdAt:{type:Date,optional:!0},date_start:{type:Date},date_end:{type:Date,optional:!0},latency_ms:{type:Number},method:{type:String},client:{type:String},instance:{type:String}};function initializeCollection(){var e;resolveio_server_app_1.ResolveIOServer&&resolveio_server_app_1.ResolveIOServer.getMainDB()?(e=new mongo_manager_1.MongoManagerModel({collectionName:"log-method-latencies",schema:schema,useVersionCollection:!1,useReportBuilder:!0,reportBuilderLookupTables:[],timestamps:!0,createLogs:!1,checkSchema:!0,collectionOptions:null}),exports.LogMethodLatencies=e.collection_main,exports.LogMethodLatencies.createIndex({createdAt:1},{expireAfterSeconds:2592e3}),exports.LogMethodLatencies.createIndex({latency_ms:1}),exports.LogMethodLatencies.createIndex({method:1})):setTimeout(function(){initializeCollection()},1)}exports.LogMethodLatencies=null,initializeCollection();
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.LogMethodLatencies=void 0;var resolveio_server_app_1=require("../resolveio-server-app"),mongo_manager_1=require("../managers/mongo.manager"),schema={_id:{type:String,optional:!0},__v:{type:Number,optional:!0},updatedAt:{type:Date,optional:!0},createdAt:{type:Date,optional:!0},date_start:{type:Date},date_end:{type:Date,optional:!0},latency_ms:{type:Number},method:{type:String},client:{type:String},instance:{type:String}};function initializeCollection(){var e;resolveio_server_app_1.ResolveIOServer&&resolveio_server_app_1.ResolveIOServer.getMainDB()?(e=new mongo_manager_1.MongoManagerModel({collectionName:"log-method-latencies",schema:schema,useVersionCollection:!1,useReportBuilder:!0,reportBuilderLookupTables:[],timestamps:!0,createLogs:!1,checkSchema:!0,collectionOptions:null}),exports.LogMethodLatencies=e.collection_main,exports.LogMethodLatencies.createIndex({createdAt:1},{expireAfterSeconds:2592e3}),exports.LogMethodLatencies.createIndex({createdAt:-1,client:1}),exports.LogMethodLatencies.createIndex({latency_ms:1}),exports.LogMethodLatencies.createIndex({method:1})):setTimeout(function(){initializeCollection()},1)}exports.LogMethodLatencies=null,initializeCollection();
2
2
  //# sourceMappingURL=log-method-latency.collection.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/collections/log-method-latency.collection.ts"],"names":["resolveio_server_app_1","require","mongo_manager_1","schema","_id","type","String","optional","__v","Number","updatedAt","Date","createdAt","date_start","date_end","latency_ms","method","client","instance","initializeCollection","model","ResolveIOServer","getMainDB","MongoManagerModel","collectionName","useVersionCollection","useReportBuilder","reportBuilderLookupTables","timestamps","createLogs","checkSchema","collectionOptions","exports","LogMethodLatencies","collection_main","createIndex","expireAfterSeconds","setTimeout"],"mappings":"sGAAA,IAAAA,uBAAAC,QAAA,yBAAA,EACAC,gBAAAD,QAAA,2BAAA,EAGIE,OAAc,CACjBC,IAAK,CACJC,KAAMC,OACNC,SAAU,CAAA,C,EAEXC,IAAK,CACJH,KAAMI,OACNF,SAAU,CAAA,C,EAEXG,UAAW,CACVL,KAAMM,KACNJ,SAAU,CAAA,C,EAEXK,UAAW,CACVP,KAAMM,KACNJ,SAAU,CAAA,C,EAEXM,WAAY,CACXR,KAAMM,I,EAEPG,SAAU,CACTT,KAAMM,KACNJ,SAAU,CAAA,C,EAEXQ,WAAY,CACXV,KAAMI,M,EAEPO,OAAQ,CACPX,KAAMC,M,EAEPW,OAAQ,CACPZ,KAAMC,M,EAEPY,SAAU,CACTb,KAAMC,M,GAQR,SAASa,uBACR,IACOC,EADHpB,uBAAAqB,iBAAmBrB,uBAAAqB,gBAAgBC,UAAS,GACzCF,EAAQ,IAAIlB,gBAAAqB,kBAAyC,CAC1DC,eAAgB,uBAChBrB,OAAQA,OACRsB,qBAAsB,CAAA,EACtBC,iBAAkB,CAAA,EAClBC,0BAA2B,GAC3BC,WAAY,CAAA,EACZC,WAAY,CAAA,EACZC,YAAa,CAAA,EACbC,kBAAmB,I,CACnB,EACDC,QAAAC,mBAAqBb,EAAMc,gBAC3BF,QAAAC,mBAAmBE,YAAY,CAACvB,UAAW,CAAC,EAAG,CAACwB,mBAAoB,MAAiB,CAAC,EACtFJ,QAAAC,mBAAmBE,YAAY,CAACpB,WAAY,CAAC,CAAC,EAC9CiB,QAAAC,mBAAmBE,YAAY,CAACnB,OAAQ,CAAC,CAAC,GAG1CqB,WAAW,WACVlB,qBAAoB,CACrB,EAAG,CAAC,CAEN,CA3BWa,QAAAC,mBAAoE,KAE/Ed,qBAAoB","file":"log-method-latency.collection.js","sourcesContent":["import { ResolveIOServer } from '../resolveio-server-app';\nimport { MongoManagerCollection, MongoManagerModel } from '../managers/mongo.manager';\nimport { LogMethodLatencyModel } from '../models/log-method-latency.model';\n\nlet schema: any = {\n\t_id: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\t__v: {\n\t\ttype: Number,\n\t\toptional: true\n\t},\n\tupdatedAt: {\n\t\ttype: Date,\n\t\toptional: true\n\t},\n\tcreatedAt: {\n\t\ttype: Date,\n\t\toptional: true\n\t},\n\tdate_start: {\n\t\ttype: Date\n\t},\n\tdate_end: {\n\t\ttype: Date,\n\t\toptional: true\n\t},\n\tlatency_ms: {\n\t\ttype: Number\n\t},\n\tmethod: {\n\t\ttype: String\n\t},\n\tclient: {\n\t\ttype: String\n\t},\n\tinstance: {\n\t\ttype: String\n\t}\n};\n\nexport let LogMethodLatencies: MongoManagerCollection<LogMethodLatencyModel> = null;\n\ninitializeCollection();\n\nfunction initializeCollection() {\n\tif (ResolveIOServer && ResolveIOServer.getMainDB()) {\n\t\tconst model = new MongoManagerModel<LogMethodLatencyModel>({\n\t\t\tcollectionName: 'log-method-latencies',\n\t\t\tschema: schema,\n\t\t\tuseVersionCollection: false,\n\t\t\tuseReportBuilder: true,\n\t\t\treportBuilderLookupTables: [],\n\t\t\ttimestamps: true,\n\t\t\tcreateLogs: false,\n\t\t\tcheckSchema: true,\n\t\t\tcollectionOptions: null\n\t\t});\n\t\tLogMethodLatencies = model.collection_main;\n\t\tLogMethodLatencies.createIndex({createdAt: 1}, {expireAfterSeconds: 60 * 60 * 24 * 30});\n\t\tLogMethodLatencies.createIndex({latency_ms: 1});\n\t\tLogMethodLatencies.createIndex({method: 1});\n\t}\n\telse {\n\t\tsetTimeout(() => {\n\t\t\tinitializeCollection();\n\t\t}, 1);\n\t}\n}"]}
1
+ {"version":3,"sources":["../../src/collections/log-method-latency.collection.ts"],"names":["resolveio_server_app_1","require","mongo_manager_1","schema","_id","type","String","optional","__v","Number","updatedAt","Date","createdAt","date_start","date_end","latency_ms","method","client","instance","initializeCollection","model","ResolveIOServer","getMainDB","MongoManagerModel","collectionName","useVersionCollection","useReportBuilder","reportBuilderLookupTables","timestamps","createLogs","checkSchema","collectionOptions","exports","LogMethodLatencies","collection_main","createIndex","expireAfterSeconds","setTimeout"],"mappings":"sGAAA,IAAAA,uBAAAC,QAAA,yBAAA,EACAC,gBAAAD,QAAA,2BAAA,EAGIE,OAAc,CACjBC,IAAK,CACJC,KAAMC,OACNC,SAAU,CAAA,C,EAEXC,IAAK,CACJH,KAAMI,OACNF,SAAU,CAAA,C,EAEXG,UAAW,CACVL,KAAMM,KACNJ,SAAU,CAAA,C,EAEXK,UAAW,CACVP,KAAMM,KACNJ,SAAU,CAAA,C,EAEXM,WAAY,CACXR,KAAMM,I,EAEPG,SAAU,CACTT,KAAMM,KACNJ,SAAU,CAAA,C,EAEXQ,WAAY,CACXV,KAAMI,M,EAEPO,OAAQ,CACPX,KAAMC,M,EAEPW,OAAQ,CACPZ,KAAMC,M,EAEPY,SAAU,CACTb,KAAMC,M,GAQR,SAASa,uBACR,IACOC,EADHpB,uBAAAqB,iBAAmBrB,uBAAAqB,gBAAgBC,UAAS,GACzCF,EAAQ,IAAIlB,gBAAAqB,kBAAyC,CAC1DC,eAAgB,uBAChBrB,OAAQA,OACRsB,qBAAsB,CAAA,EACtBC,iBAAkB,CAAA,EAClBC,0BAA2B,GAC3BC,WAAY,CAAA,EACZC,WAAY,CAAA,EACZC,YAAa,CAAA,EACbC,kBAAmB,I,CACnB,EACDC,QAAAC,mBAAqBb,EAAMc,gBAC3BF,QAAAC,mBAAmBE,YAAY,CAACvB,UAAW,CAAC,EAAG,CAACwB,mBAAoB,MAAiB,CAAC,EACtFJ,QAAAC,mBAAmBE,YAAY,CAACvB,UAAW,CAAC,EAAGK,OAAQ,CAAC,CAAC,EACzDe,QAAAC,mBAAmBE,YAAY,CAACpB,WAAY,CAAC,CAAC,EAC9CiB,QAAAC,mBAAmBE,YAAY,CAACnB,OAAQ,CAAC,CAAC,GAG1CqB,WAAW,WACVlB,qBAAoB,CACrB,EAAG,CAAC,CAEN,CA5BWa,QAAAC,mBAAoE,KAE/Ed,qBAAoB","file":"log-method-latency.collection.js","sourcesContent":["import { ResolveIOServer } from '../resolveio-server-app';\nimport { MongoManagerCollection, MongoManagerModel } from '../managers/mongo.manager';\nimport { LogMethodLatencyModel } from '../models/log-method-latency.model';\n\nlet schema: any = {\n\t_id: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\t__v: {\n\t\ttype: Number,\n\t\toptional: true\n\t},\n\tupdatedAt: {\n\t\ttype: Date,\n\t\toptional: true\n\t},\n\tcreatedAt: {\n\t\ttype: Date,\n\t\toptional: true\n\t},\n\tdate_start: {\n\t\ttype: Date\n\t},\n\tdate_end: {\n\t\ttype: Date,\n\t\toptional: true\n\t},\n\tlatency_ms: {\n\t\ttype: Number\n\t},\n\tmethod: {\n\t\ttype: String\n\t},\n\tclient: {\n\t\ttype: String\n\t},\n\tinstance: {\n\t\ttype: String\n\t}\n};\n\nexport let LogMethodLatencies: MongoManagerCollection<LogMethodLatencyModel> = null;\n\ninitializeCollection();\n\nfunction initializeCollection() {\n\tif (ResolveIOServer && ResolveIOServer.getMainDB()) {\n\t\tconst model = new MongoManagerModel<LogMethodLatencyModel>({\n\t\t\tcollectionName: 'log-method-latencies',\n\t\t\tschema: schema,\n\t\t\tuseVersionCollection: false,\n\t\t\tuseReportBuilder: true,\n\t\t\treportBuilderLookupTables: [],\n\t\t\ttimestamps: true,\n\t\t\tcreateLogs: false,\n\t\t\tcheckSchema: true,\n\t\t\tcollectionOptions: null\n\t\t});\n\t\tLogMethodLatencies = model.collection_main;\n\t\tLogMethodLatencies.createIndex({createdAt: 1}, {expireAfterSeconds: 60 * 60 * 24 * 30});\n\t\tLogMethodLatencies.createIndex({createdAt: -1, client: 1});\n\t\tLogMethodLatencies.createIndex({latency_ms: 1});\n\t\tLogMethodLatencies.createIndex({method: 1});\n\t}\n\telse {\n\t\tsetTimeout(() => {\n\t\t\tinitializeCollection();\n\t\t}, 1);\n\t}\n}"]}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.LogSubscriptions=void 0;var resolveio_server_app_1=require("../resolveio-server-app"),mongo_manager_1=require("../managers/mongo.manager"),schema={_id:{type:String,optional:!0},__v:{type:Number,optional:!0},updatedAt:{type:Date,optional:!0},createdAt:{type:Date,optional:!0},date:{type:Date},type:{type:String},subscription:{type:String},collection_name:{type:String},subData:{type:String},client:{type:String},instance:{type:String}};function initializeCollection(){var e;resolveio_server_app_1.ResolveIOServer&&resolveio_server_app_1.ResolveIOServer.getMainDB()?(e=new mongo_manager_1.MongoManagerModel({collectionName:"log-subscriptions",schema:schema,useVersionCollection:!1,useReportBuilder:!0,reportBuilderLookupTables:[],timestamps:!0,createLogs:!1,checkSchema:!0,collectionOptions:null}),exports.LogSubscriptions=e.collection_main,exports.LogSubscriptions.createIndex({date:1},{expireAfterSeconds:2592e3}),exports.LogSubscriptions.createIndex({type:1}),exports.LogSubscriptions.createIndex({collection_name:1}),exports.LogSubscriptions.createIndex({date:1,type:1}),exports.LogSubscriptions.createIndex({createdAt:1})):setTimeout(function(){initializeCollection()},1)}exports.LogSubscriptions=null,initializeCollection();
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.LogSubscriptions=void 0;var resolveio_server_app_1=require("../resolveio-server-app"),mongo_manager_1=require("../managers/mongo.manager"),schema={_id:{type:String,optional:!0},__v:{type:Number,optional:!0},updatedAt:{type:Date,optional:!0},createdAt:{type:Date,optional:!0},date:{type:Date},type:{type:String},subscription:{type:String},collection_name:{type:String},subData:{type:String},client:{type:String},instance:{type:String}};function initializeCollection(){var e;resolveio_server_app_1.ResolveIOServer&&resolveio_server_app_1.ResolveIOServer.getMainDB()?(e=new mongo_manager_1.MongoManagerModel({collectionName:"log-subscriptions",schema:schema,useVersionCollection:!1,useReportBuilder:!0,reportBuilderLookupTables:[],timestamps:!0,createLogs:!1,checkSchema:!0,collectionOptions:null}),exports.LogSubscriptions=e.collection_main,exports.LogSubscriptions.createIndex({date:1},{expireAfterSeconds:2592e3}),exports.LogSubscriptions.createIndex({type:1}),exports.LogSubscriptions.createIndex({collection_name:1}),exports.LogSubscriptions.createIndex({date:1,type:1}),exports.LogSubscriptions.createIndex({createdAt:-1,client:1})):setTimeout(function(){initializeCollection()},1)}exports.LogSubscriptions=null,initializeCollection();
2
2
  //# sourceMappingURL=log-subscription.collection.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/collections/log-subscription.collection.ts"],"names":["resolveio_server_app_1","require","mongo_manager_1","schema","_id","type","String","optional","__v","Number","updatedAt","Date","createdAt","date","subscription","collection_name","subData","client","instance","initializeCollection","model","ResolveIOServer","getMainDB","MongoManagerModel","collectionName","useVersionCollection","useReportBuilder","reportBuilderLookupTables","timestamps","createLogs","checkSchema","collectionOptions","exports","LogSubscriptions","collection_main","createIndex","expireAfterSeconds","setTimeout"],"mappings":"oGAAA,IAAAA,uBAAAC,QAAA,yBAAA,EACAC,gBAAAD,QAAA,2BAAA,EAGIE,OAAc,CACjBC,IAAK,CACJC,KAAMC,OACNC,SAAU,CAAA,C,EAEXC,IAAK,CACJH,KAAMI,OACNF,SAAU,CAAA,C,EAEXG,UAAW,CACVL,KAAMM,KACNJ,SAAU,CAAA,C,EAEXK,UAAW,CACVP,KAAMM,KACNJ,SAAU,CAAA,C,EAEXM,KAAM,CACLR,KAAMM,I,EAEPN,KAAM,CACLA,KAAMC,M,EAEPQ,aAAc,CACbT,KAAMC,M,EAEPS,gBAAiB,CAChBV,KAAMC,M,EAEPU,QAAS,CACRX,KAAMC,M,EAEPW,OAAQ,CACPZ,KAAMC,M,EAEPY,SAAU,CACTb,KAAMC,M,GAQR,SAASa,uBACR,IACOC,EADHpB,uBAAAqB,iBAAmBrB,uBAAAqB,gBAAgBC,UAAS,GACzCF,EAAQ,IAAIlB,gBAAAqB,kBAAwC,CACzDC,eAAgB,oBAChBrB,OAAQA,OACRsB,qBAAsB,CAAA,EACtBC,iBAAkB,CAAA,EAClBC,0BAA2B,GAC3BC,WAAY,CAAA,EACZC,WAAY,CAAA,EACZC,YAAa,CAAA,EACbC,kBAAmB,I,CACnB,EACDC,QAAAC,iBAAmBb,EAAMc,gBACzBF,QAAAC,iBAAiBE,YAAY,CAACtB,KAAM,CAAC,EAAG,CAACuB,mBAAoB,MAAiB,CAAC,EAC/EJ,QAAAC,iBAAiBE,YAAY,CAAC9B,KAAM,CAAC,CAAC,EACtC2B,QAAAC,iBAAiBE,YAAY,CAACpB,gBAAiB,CAAC,CAAC,EACjDiB,QAAAC,iBAAiBE,YAAY,CAACtB,KAAM,EAAGR,KAAM,CAAC,CAAC,EAC/C2B,QAAAC,iBAAiBE,YAAY,CAACvB,UAAW,CAAC,CAAC,GAG3CyB,WAAW,WACVlB,qBAAoB,CACrB,EAAG,CAAC,CAEN,CA7BWa,QAAAC,iBAAiE,KAE5Ed,qBAAoB","file":"log-subscription.collection.js","sourcesContent":["import { ResolveIOServer } from '../resolveio-server-app';\nimport { MongoManagerCollection, MongoManagerModel } from '../managers/mongo.manager';\nimport { LogSubscriptionModel } from '../models/log-subscription.model';\n\nlet schema: any = {\n\t_id: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\t__v: {\n\t\ttype: Number,\n\t\toptional: true\n\t},\n\tupdatedAt: {\n\t\ttype: Date,\n\t\toptional: true\n\t},\n\tcreatedAt: {\n\t\ttype: Date,\n\t\toptional: true\n\t},\n\tdate: {\n\t\ttype: Date\n\t},\n\ttype: {\n\t\ttype: String\n\t},\n\tsubscription: {\n\t\ttype: String\n\t},\n\tcollection_name: {\n\t\ttype: String\n\t},\n\tsubData: {\n\t\ttype: String\t\n\t},\n\tclient: {\n\t\ttype: String\n\t},\n\tinstance: {\n\t\ttype: String\n\t}\n};\n\nexport let LogSubscriptions: MongoManagerCollection<LogSubscriptionModel> = null;\n\ninitializeCollection();\n\nfunction initializeCollection() {\n\tif (ResolveIOServer && ResolveIOServer.getMainDB()) {\n\t\tconst model = new MongoManagerModel<LogSubscriptionModel>({\n\t\t\tcollectionName: 'log-subscriptions',\n\t\t\tschema: schema,\n\t\t\tuseVersionCollection: false,\n\t\t\tuseReportBuilder: true,\n\t\t\treportBuilderLookupTables: [],\n\t\t\ttimestamps: true,\n\t\t\tcreateLogs: false,\n\t\t\tcheckSchema: true,\n\t\t\tcollectionOptions: null\n\t\t});\n\t\tLogSubscriptions = model.collection_main;\n\t\tLogSubscriptions.createIndex({date: 1}, {expireAfterSeconds: 60 * 60 * 24 * 30});\n\t\tLogSubscriptions.createIndex({type: 1});\n\t\tLogSubscriptions.createIndex({collection_name: 1});\n\t\tLogSubscriptions.createIndex({date: 1, type: 1});\n\t\tLogSubscriptions.createIndex({createdAt: 1});\n\t}\n\telse {\n\t\tsetTimeout(() => {\n\t\t\tinitializeCollection();\n\t\t}, 1);\n\t}\n}"]}
1
+ {"version":3,"sources":["../../src/collections/log-subscription.collection.ts"],"names":["resolveio_server_app_1","require","mongo_manager_1","schema","_id","type","String","optional","__v","Number","updatedAt","Date","createdAt","date","subscription","collection_name","subData","client","instance","initializeCollection","model","ResolveIOServer","getMainDB","MongoManagerModel","collectionName","useVersionCollection","useReportBuilder","reportBuilderLookupTables","timestamps","createLogs","checkSchema","collectionOptions","exports","LogSubscriptions","collection_main","createIndex","expireAfterSeconds","setTimeout"],"mappings":"oGAAA,IAAAA,uBAAAC,QAAA,yBAAA,EACAC,gBAAAD,QAAA,2BAAA,EAGIE,OAAc,CACjBC,IAAK,CACJC,KAAMC,OACNC,SAAU,CAAA,C,EAEXC,IAAK,CACJH,KAAMI,OACNF,SAAU,CAAA,C,EAEXG,UAAW,CACVL,KAAMM,KACNJ,SAAU,CAAA,C,EAEXK,UAAW,CACVP,KAAMM,KACNJ,SAAU,CAAA,C,EAEXM,KAAM,CACLR,KAAMM,I,EAEPN,KAAM,CACLA,KAAMC,M,EAEPQ,aAAc,CACbT,KAAMC,M,EAEPS,gBAAiB,CAChBV,KAAMC,M,EAEPU,QAAS,CACRX,KAAMC,M,EAEPW,OAAQ,CACPZ,KAAMC,M,EAEPY,SAAU,CACTb,KAAMC,M,GAQR,SAASa,uBACR,IACOC,EADHpB,uBAAAqB,iBAAmBrB,uBAAAqB,gBAAgBC,UAAS,GACzCF,EAAQ,IAAIlB,gBAAAqB,kBAAwC,CACzDC,eAAgB,oBAChBrB,OAAQA,OACRsB,qBAAsB,CAAA,EACtBC,iBAAkB,CAAA,EAClBC,0BAA2B,GAC3BC,WAAY,CAAA,EACZC,WAAY,CAAA,EACZC,YAAa,CAAA,EACbC,kBAAmB,I,CACnB,EACDC,QAAAC,iBAAmBb,EAAMc,gBACzBF,QAAAC,iBAAiBE,YAAY,CAACtB,KAAM,CAAC,EAAG,CAACuB,mBAAoB,MAAiB,CAAC,EAC/EJ,QAAAC,iBAAiBE,YAAY,CAAC9B,KAAM,CAAC,CAAC,EACtC2B,QAAAC,iBAAiBE,YAAY,CAACpB,gBAAiB,CAAC,CAAC,EACjDiB,QAAAC,iBAAiBE,YAAY,CAACtB,KAAM,EAAGR,KAAM,CAAC,CAAC,EAC/C2B,QAAAC,iBAAiBE,YAAY,CAACvB,UAAW,CAAC,EAAGK,OAAQ,CAAC,CAAC,GAGvDoB,WAAW,WACVlB,qBAAoB,CACrB,EAAG,CAAC,CAEN,CA7BWa,QAAAC,iBAAiE,KAE5Ed,qBAAoB","file":"log-subscription.collection.js","sourcesContent":["import { ResolveIOServer } from '../resolveio-server-app';\nimport { MongoManagerCollection, MongoManagerModel } from '../managers/mongo.manager';\nimport { LogSubscriptionModel } from '../models/log-subscription.model';\n\nlet schema: any = {\n\t_id: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\t__v: {\n\t\ttype: Number,\n\t\toptional: true\n\t},\n\tupdatedAt: {\n\t\ttype: Date,\n\t\toptional: true\n\t},\n\tcreatedAt: {\n\t\ttype: Date,\n\t\toptional: true\n\t},\n\tdate: {\n\t\ttype: Date\n\t},\n\ttype: {\n\t\ttype: String\n\t},\n\tsubscription: {\n\t\ttype: String\n\t},\n\tcollection_name: {\n\t\ttype: String\n\t},\n\tsubData: {\n\t\ttype: String\t\n\t},\n\tclient: {\n\t\ttype: String\n\t},\n\tinstance: {\n\t\ttype: String\n\t}\n};\n\nexport let LogSubscriptions: MongoManagerCollection<LogSubscriptionModel> = null;\n\ninitializeCollection();\n\nfunction initializeCollection() {\n\tif (ResolveIOServer && ResolveIOServer.getMainDB()) {\n\t\tconst model = new MongoManagerModel<LogSubscriptionModel>({\n\t\t\tcollectionName: 'log-subscriptions',\n\t\t\tschema: schema,\n\t\t\tuseVersionCollection: false,\n\t\t\tuseReportBuilder: true,\n\t\t\treportBuilderLookupTables: [],\n\t\t\ttimestamps: true,\n\t\t\tcreateLogs: false,\n\t\t\tcheckSchema: true,\n\t\t\tcollectionOptions: null\n\t\t});\n\t\tLogSubscriptions = model.collection_main;\n\t\tLogSubscriptions.createIndex({date: 1}, {expireAfterSeconds: 60 * 60 * 24 * 30});\n\t\tLogSubscriptions.createIndex({type: 1});\n\t\tLogSubscriptions.createIndex({collection_name: 1});\n\t\tLogSubscriptions.createIndex({date: 1, type: 1});\n\t\tLogSubscriptions.createIndex({createdAt: -1, client: 1});\n\t}\n\telse {\n\t\tsetTimeout(() => {\n\t\t\tinitializeCollection();\n\t\t}, 1);\n\t}\n}"]}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Logs=void 0;var resolveio_server_app_1=require("../resolveio-server-app"),mongo_manager_1=require("../managers/mongo.manager"),schema={_id:{type:String,optional:!0},__v:{type:Number,optional:!0},updatedAt:{type:Date,optional:!0},createdAt:{type:Date,optional:!0},type:{type:String},collection:{type:String},id_document:{type:String},payload:{type:String},method:{type:String},id_user:{type:String},user:{type:String},messageId:{type:Number},route:{type:String},client:{type:String},instance:{type:String}};function initializeCollection(){var e;resolveio_server_app_1.ResolveIOServer&&resolveio_server_app_1.ResolveIOServer.getMainDB()?(e=new mongo_manager_1.MongoManagerModel({collectionName:"logs",schema:schema,useVersionCollection:!1,useReportBuilder:!1,reportBuilderLookupTables:[],timestamps:!0,createLogs:!1,checkSchema:!0,collectionOptions:null}),exports.Logs=e.collection_main,exports.Logs.createIndex({createdAt:1},{expireAfterSeconds:7776e3}),exports.Logs.createIndex({createdAt:-1,type:1,id_document:1})):setTimeout(function(){initializeCollection()},1)}exports.Logs=null,initializeCollection();
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Logs=void 0;var resolveio_server_app_1=require("../resolveio-server-app"),mongo_manager_1=require("../managers/mongo.manager"),schema={_id:{type:String,optional:!0},__v:{type:Number,optional:!0},updatedAt:{type:Date,optional:!0},createdAt:{type:Date,optional:!0},type:{type:String},collection:{type:String},id_document:{type:String},payload:{type:String},method:{type:String},id_user:{type:String},user:{type:String},messageId:{type:Number},route:{type:String},client:{type:String},instance:{type:String}};function initializeCollection(){var e;resolveio_server_app_1.ResolveIOServer&&resolveio_server_app_1.ResolveIOServer.getMainDB()?(e=new mongo_manager_1.MongoManagerModel({collectionName:"logs",schema:schema,useVersionCollection:!1,useReportBuilder:!1,reportBuilderLookupTables:[],timestamps:!0,createLogs:!1,checkSchema:!0,collectionOptions:null}),exports.Logs=e.collection_main,exports.Logs.createIndex({createdAt:1},{expireAfterSeconds:7776e3}),exports.Logs.createIndex({createdAt:-1,client:1,type:1,id_document:1})):setTimeout(function(){initializeCollection()},1)}exports.Logs=null,initializeCollection();
2
2
  //# sourceMappingURL=log.collection.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/collections/log.collection.ts"],"names":["resolveio_server_app_1","require","mongo_manager_1","schema","_id","type","String","optional","__v","Number","updatedAt","Date","createdAt","collection","id_document","payload","method","id_user","user","messageId","route","client","instance","initializeCollection","model","ResolveIOServer","getMainDB","MongoManagerModel","collectionName","useVersionCollection","useReportBuilder","reportBuilderLookupTables","timestamps","createLogs","checkSchema","collectionOptions","exports","Logs","collection_main","createIndex","expireAfterSeconds","setTimeout"],"mappings":"wFAAA,IAAAA,uBAAAC,QAAA,yBAAA,EACAC,gBAAAD,QAAA,2BAAA,EAGIE,OAAc,CACjBC,IAAK,CACJC,KAAMC,OACNC,SAAU,CAAA,C,EAEXC,IAAK,CACJH,KAAMI,OACNF,SAAU,CAAA,C,EAEXG,UAAW,CACVL,KAAMM,KACNJ,SAAU,CAAA,C,EAEXK,UAAW,CACVP,KAAMM,KACNJ,SAAU,CAAA,C,EAEXF,KAAM,CACLA,KAAMC,M,EAEPO,WAAY,CACXR,KAAMC,M,EAEPQ,YAAa,CACZT,KAAMC,M,EAEPS,QAAS,CACRV,KAAMC,M,EAEPU,OAAQ,CACPX,KAAMC,M,EAEPW,QAAS,CACRZ,KAAMC,M,EAEPY,KAAM,CACLb,KAAMC,M,EAEPa,UAAW,CACVd,KAAMI,M,EAEPW,MAAO,CACNf,KAAMC,M,EAEPe,OAAQ,CACPhB,KAAMC,M,EAEPgB,SAAU,CACTjB,KAAMC,M,GAQR,SAASiB,uBACR,IACOC,EADHxB,uBAAAyB,iBAAmBzB,uBAAAyB,gBAAgBC,UAAS,GACzCF,EAAQ,IAAItB,gBAAAyB,kBAA4B,CAC7CC,eAAgB,OAChBzB,OAAQA,OACR0B,qBAAsB,CAAA,EACtBC,iBAAkB,CAAA,EAClBC,0BAA2B,GAC3BC,WAAY,CAAA,EACZC,WAAY,CAAA,EACZC,YAAa,CAAA,EACbC,kBAAmB,I,CACnB,EACDC,QAAAC,KAAOb,EAAMc,gBACbF,QAAAC,KAAKE,YAAY,CAAC3B,UAAW,CAAC,EAAG,CAAC4B,mBAAoB,MAAiB,CAAC,EACxEJ,QAAAC,KAAKE,YAAY,CAAC3B,UAAW,CAAC,EAAGP,KAAM,EAAGS,YAAa,CAAC,CAAC,GAGzD2B,WAAW,WACVlB,qBAAoB,CACrB,EAAG,CAAC,CAEN,CA1BWa,QAAAC,KAAyC,KAEpDd,qBAAoB","file":"log.collection.js","sourcesContent":["import { ResolveIOServer } from '../resolveio-server-app';\nimport { MongoManagerCollection, MongoManagerModel } from '../managers/mongo.manager';\nimport { LogModel } from '../models/log.model';\n\nlet schema: any = {\n\t_id: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\t__v: {\n\t\ttype: Number,\n\t\toptional: true\n\t},\n\tupdatedAt: {\n\t\ttype: Date,\n\t\toptional: true\n\t},\n\tcreatedAt: {\n\t\ttype: Date,\n\t\toptional: true\n\t},\n\ttype: {\n\t\ttype: String\n\t},\n\tcollection: {\n\t\ttype: String\n\t},\n\tid_document: {\n\t\ttype: String\n\t},\n\tpayload: {\n\t\ttype: String\n\t},\n\tmethod: {\n\t\ttype: String\n\t},\n\tid_user: {\n\t\ttype: String\n\t},\n\tuser: {\n\t\ttype: String\n\t},\n\tmessageId: {\n\t\ttype: Number\n\t},\n\troute: {\n\t\ttype: String\n\t},\n\tclient: {\n\t\ttype: String\n\t},\n\tinstance: {\n\t\ttype: String\n\t}\n};\n\nexport let Logs: MongoManagerCollection<LogModel> = null;\n\ninitializeCollection();\n\nfunction initializeCollection() {\n\tif (ResolveIOServer && ResolveIOServer.getMainDB()) {\n\t\tconst model = new MongoManagerModel<LogModel>({\n\t\t\tcollectionName: 'logs',\n\t\t\tschema: schema,\n\t\t\tuseVersionCollection: false,\n\t\t\tuseReportBuilder: false,\n\t\t\treportBuilderLookupTables: [],\n\t\t\ttimestamps: true,\n\t\t\tcreateLogs: false,\n\t\t\tcheckSchema: true,\n\t\t\tcollectionOptions: null\n\t\t});\n\t\tLogs = model.collection_main;\n\t\tLogs.createIndex({createdAt: 1}, {expireAfterSeconds: 60 * 60 * 24 * 90});\n\t\tLogs.createIndex({createdAt: -1, type: 1, id_document: 1});\n\t}\n\telse {\n\t\tsetTimeout(() => {\n\t\t\tinitializeCollection();\n\t\t}, 1);\n\t}\n}"]}
1
+ {"version":3,"sources":["../../src/collections/log.collection.ts"],"names":["resolveio_server_app_1","require","mongo_manager_1","schema","_id","type","String","optional","__v","Number","updatedAt","Date","createdAt","collection","id_document","payload","method","id_user","user","messageId","route","client","instance","initializeCollection","model","ResolveIOServer","getMainDB","MongoManagerModel","collectionName","useVersionCollection","useReportBuilder","reportBuilderLookupTables","timestamps","createLogs","checkSchema","collectionOptions","exports","Logs","collection_main","createIndex","expireAfterSeconds","setTimeout"],"mappings":"wFAAA,IAAAA,uBAAAC,QAAA,yBAAA,EACAC,gBAAAD,QAAA,2BAAA,EAGIE,OAAc,CACjBC,IAAK,CACJC,KAAMC,OACNC,SAAU,CAAA,C,EAEXC,IAAK,CACJH,KAAMI,OACNF,SAAU,CAAA,C,EAEXG,UAAW,CACVL,KAAMM,KACNJ,SAAU,CAAA,C,EAEXK,UAAW,CACVP,KAAMM,KACNJ,SAAU,CAAA,C,EAEXF,KAAM,CACLA,KAAMC,M,EAEPO,WAAY,CACXR,KAAMC,M,EAEPQ,YAAa,CACZT,KAAMC,M,EAEPS,QAAS,CACRV,KAAMC,M,EAEPU,OAAQ,CACPX,KAAMC,M,EAEPW,QAAS,CACRZ,KAAMC,M,EAEPY,KAAM,CACLb,KAAMC,M,EAEPa,UAAW,CACVd,KAAMI,M,EAEPW,MAAO,CACNf,KAAMC,M,EAEPe,OAAQ,CACPhB,KAAMC,M,EAEPgB,SAAU,CACTjB,KAAMC,M,GAQR,SAASiB,uBACR,IACOC,EADHxB,uBAAAyB,iBAAmBzB,uBAAAyB,gBAAgBC,UAAS,GACzCF,EAAQ,IAAItB,gBAAAyB,kBAA4B,CAC7CC,eAAgB,OAChBzB,OAAQA,OACR0B,qBAAsB,CAAA,EACtBC,iBAAkB,CAAA,EAClBC,0BAA2B,GAC3BC,WAAY,CAAA,EACZC,WAAY,CAAA,EACZC,YAAa,CAAA,EACbC,kBAAmB,I,CACnB,EACDC,QAAAC,KAAOb,EAAMc,gBACbF,QAAAC,KAAKE,YAAY,CAAC3B,UAAW,CAAC,EAAG,CAAC4B,mBAAoB,MAAiB,CAAC,EACxEJ,QAAAC,KAAKE,YAAY,CAAC3B,UAAW,CAAC,EAAGS,OAAQ,EAAGhB,KAAM,EAAGS,YAAa,CAAC,CAAC,GAGpE2B,WAAW,WACVlB,qBAAoB,CACrB,EAAG,CAAC,CAEN,CA1BWa,QAAAC,KAAyC,KAEpDd,qBAAoB","file":"log.collection.js","sourcesContent":["import { ResolveIOServer } from '../resolveio-server-app';\nimport { MongoManagerCollection, MongoManagerModel } from '../managers/mongo.manager';\nimport { LogModel } from '../models/log.model';\n\nlet schema: any = {\n\t_id: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\t__v: {\n\t\ttype: Number,\n\t\toptional: true\n\t},\n\tupdatedAt: {\n\t\ttype: Date,\n\t\toptional: true\n\t},\n\tcreatedAt: {\n\t\ttype: Date,\n\t\toptional: true\n\t},\n\ttype: {\n\t\ttype: String\n\t},\n\tcollection: {\n\t\ttype: String\n\t},\n\tid_document: {\n\t\ttype: String\n\t},\n\tpayload: {\n\t\ttype: String\n\t},\n\tmethod: {\n\t\ttype: String\n\t},\n\tid_user: {\n\t\ttype: String\n\t},\n\tuser: {\n\t\ttype: String\n\t},\n\tmessageId: {\n\t\ttype: Number\n\t},\n\troute: {\n\t\ttype: String\n\t},\n\tclient: {\n\t\ttype: String\n\t},\n\tinstance: {\n\t\ttype: String\n\t}\n};\n\nexport let Logs: MongoManagerCollection<LogModel> = null;\n\ninitializeCollection();\n\nfunction initializeCollection() {\n\tif (ResolveIOServer && ResolveIOServer.getMainDB()) {\n\t\tconst model = new MongoManagerModel<LogModel>({\n\t\t\tcollectionName: 'logs',\n\t\t\tschema: schema,\n\t\t\tuseVersionCollection: false,\n\t\t\tuseReportBuilder: false,\n\t\t\treportBuilderLookupTables: [],\n\t\t\ttimestamps: true,\n\t\t\tcreateLogs: false,\n\t\t\tcheckSchema: true,\n\t\t\tcollectionOptions: null\n\t\t});\n\t\tLogs = model.collection_main;\n\t\tLogs.createIndex({createdAt: 1}, {expireAfterSeconds: 60 * 60 * 24 * 90});\n\t\tLogs.createIndex({createdAt: -1, client: 1, type: 1, id_document: 1});\n\t}\n\telse {\n\t\tsetTimeout(() => {\n\t\t\tinitializeCollection();\n\t\t}, 1);\n\t}\n}"]}
@@ -0,0 +1,3 @@
1
+ import { MongoManagerCollection } from '../managers/mongo.manager';
2
+ import { MonitorFunctionModel } from '../models/monitor-function.model';
3
+ export declare let MonitorFunctions: MongoManagerCollection<MonitorFunctionModel>;
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.MonitorFunctions=void 0;var resolveio_server_app_1=require("../resolveio-server-app"),mongo_manager_1=require("../managers/mongo.manager"),schema={_id:{type:String,optional:!0},metadata:{type:Object},"metadata.client":{type:String},"metadata.instance":{type:String},date:{type:Date},type:{type:String},name:{type:String},user:{type:String},duration:{type:Number},data:{type:String}};function initializeCollection(){var e;resolveio_server_app_1.ResolveIOServer&&resolveio_server_app_1.ResolveIOServer.getMainDB()?(e=new mongo_manager_1.MongoManagerModel({collectionName:"monitor-functions",schema:schema,useVersionCollection:!1,useReportBuilder:!1,reportBuilderLookupTables:[],timestamps:!1,createLogs:!1,checkSchema:!1,collectionOptions:{timeseries:{timeField:"date",granularity:"seconds",metaField:"metadata"},expireAfterSeconds:259200}}),exports.MonitorFunctions=e.collection_main,exports.MonitorFunctions.createIndex({"metadata.client":1,date:1}),exports.MonitorFunctions.createIndex({"metadata.client":1,"metadata.instance":1,date:1})):setTimeout(function(){initializeCollection()},1)}exports.MonitorFunctions=null,initializeCollection();
2
+ //# sourceMappingURL=monitor-function.collection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/collections/monitor-function.collection.ts"],"names":["resolveio_server_app_1","require","mongo_manager_1","schema","_id","type","String","optional","metadata","Object","metadata.client","metadata.instance","date","Date","name","user","duration","Number","data","initializeCollection","model","ResolveIOServer","getMainDB","MongoManagerModel","collectionName","useVersionCollection","useReportBuilder","reportBuilderLookupTables","timestamps","createLogs","checkSchema","collectionOptions","timeseries","timeField","granularity","metaField","expireAfterSeconds","exports","MonitorFunctions","collection_main","createIndex","setTimeout"],"mappings":"oGAAA,IAAAA,uBAAAC,QAAA,yBAAA,EACAC,gBAAAD,QAAA,2BAAA,EAGIE,OAAc,CACjBC,IAAK,CACJC,KAAMC,OACNC,SAAU,CAAA,C,EAEXC,SAAU,CACTH,KAAMI,M,EAEPC,kBAAmB,CAClBL,KAAMC,M,EAEPK,oBAAqB,CACpBN,KAAMC,M,EAEPM,KAAM,CACLP,KAAMQ,I,EAEPR,KAAM,CACLA,KAAMC,M,EAEPQ,KAAM,CACLT,KAAMC,M,EAEPS,KAAM,CACLV,KAAMC,M,EAEPU,SAAU,CACTX,KAAMY,M,EAEPC,KAAM,CACLb,KAAMC,M,GAQR,SAASa,uBACR,IACOC,EADHpB,uBAAAqB,iBAAmBrB,uBAAAqB,gBAAgBC,UAAS,GACzCF,EAAQ,IAAIlB,gBAAAqB,kBAAwC,CACzDC,eAAgB,oBAChBrB,OAAQA,OACRsB,qBAAsB,CAAA,EACtBC,iBAAkB,CAAA,EAClBC,0BAA2B,GAC3BC,WAAY,CAAA,EACZC,WAAY,CAAA,EACZC,YAAa,CAAA,EACbC,kBAAmB,CAClBC,WAAY,CACXC,UAAW,OACXC,YAAa,UACbC,UAAW,U,EAEZC,mBAAoB,M,EAErB,EACDC,QAAAC,iBAAmBlB,EAAMmB,gBACzBF,QAAAC,iBAAiBE,YAAY,CAAC9B,kBAAmB,EAAGE,KAAM,CAAC,CAAC,EAC5DyB,QAAAC,iBAAiBE,YAAY,CAAC9B,kBAAmB,EAAGC,oBAAqB,EAAGC,KAAM,CAAC,CAAC,GAGpF6B,WAAW,WACVtB,qBAAoB,CACrB,EAAG,CAAC,CAEN,CAjCWkB,QAAAC,iBAAiE,KAE5EnB,qBAAoB","file":"monitor-function.collection.js","sourcesContent":["import { ResolveIOServer } from '../resolveio-server-app';\nimport { MongoManagerCollection, MongoManagerModel } from '../managers/mongo.manager';\nimport { MonitorFunctionModel } from '../models/monitor-function.model';\n\nlet schema: any = {\n\t_id: {\n\t\ttype: String,\n\t\toptional: true\n\t},\n\tmetadata: {\n\t\ttype: Object\n\t},\n\t'metadata.client': {\n\t\ttype: String\n\t},\n\t'metadata.instance': {\n\t\ttype: String\n\t},\n\tdate: {\n\t\ttype: Date\n\t},\n\ttype: {\n\t\ttype: String\n\t},\n\tname: {\n\t\ttype: String\n\t},\n\tuser: {\n\t\ttype: String\n\t},\n\tduration: {\n\t\ttype: Number\n\t},\n\tdata: {\n\t\ttype: String\n\t}\n};\n\nexport let MonitorFunctions: MongoManagerCollection<MonitorFunctionModel> = null;\n\ninitializeCollection();\n\nfunction initializeCollection() {\n\tif (ResolveIOServer && ResolveIOServer.getMainDB()) {\n\t\tconst model = new MongoManagerModel<MonitorFunctionModel>({\n\t\t\tcollectionName: 'monitor-functions',\n\t\t\tschema: schema,\n\t\t\tuseVersionCollection: false,\n\t\t\tuseReportBuilder: false,\n\t\t\treportBuilderLookupTables: [],\n\t\t\ttimestamps: false,\n\t\t\tcreateLogs: false,\n\t\t\tcheckSchema: false,\n\t\t\tcollectionOptions: {\n\t\t\t\ttimeseries: {\n\t\t\t\t\ttimeField: 'date',\n\t\t\t\t\tgranularity: 'seconds',\n\t\t\t\t\tmetaField: 'metadata'\n\t\t\t\t},\n\t\t\t\texpireAfterSeconds: 60 * 60 * 24 * 3\n\t\t\t}\n\t\t});\n\t\tMonitorFunctions = model.collection_main;\n\t\tMonitorFunctions.createIndex({'metadata.client': 1, date: 1});\n\t\tMonitorFunctions.createIndex({'metadata.client': 1, 'metadata.instance': 1, date: 1});\n\t}\n\telse {\n\t\tsetTimeout(() => {\n\t\t\tinitializeCollection();\n\t\t}, 1);\n\t}\n}"]}
package/http/auth.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var __awaiter=this&&this.__awaiter||function(e,s,t,o){return new(t=t||Promise)(function(n,r){function fulfilled(e){try{step(o.next(e))}catch(e){r(e)}}function rejected(e){try{step(o.throw(e))}catch(e){r(e)}}function step(e){var r;e.done?n(e.value):((r=e.value)instanceof t?r:new t(function(e){e(r)})).then(fulfilled,rejected)}step((o=o.apply(e,s||[])).next())})},__generator=this&&this.__generator||function(s,t){var o,i,a,l={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},d={next:verb(0),throw:verb(1),return:verb(2)};return"function"==typeof Symbol&&(d[Symbol.iterator]=function(){return this}),d;function verb(n){return function(e){var r=[n,e];if(o)throw new TypeError("Generator is already executing.");for(;l=d&&r[d=0]?0:l;)try{if(o=1,i&&(a=2&r[0]?i.return:r[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,r[1])).done)return a;switch(i=0,(r=a?[2&r[0],a.value]:r)[0]){case 0:case 1:a=r;break;case 4:return l.label++,{value:r[1],done:!1};case 5:l.label++,i=r[1],r=[0];continue;case 7:r=l.ops.pop(),l.trys.pop();continue;default:if(!(a=0<(a=l.trys).length&&a[a.length-1])&&(6===r[0]||2===r[0])){l=0;continue}if(3===r[0]&&(!a||r[1]>a[0]&&r[1]<a[3]))l.label=r[1];else if(6===r[0]&&l.label<a[1])l.label=a[1],a=r;else{if(!(a&&l.label<a[2])){a[2]&&l.ops.pop(),l.trys.pop();continue}l.label=a[2],l.ops.push(r)}}r=t.call(s,l)}catch(e){r=[6,e],i=0}finally{o=a=0}if(5&r[0])throw r[1];return{value:r[0]?r[1]:void 0,done:!0}}}},user_collection_1=(Object.defineProperty(exports,"__esModule",{value:!0}),exports.setupAuthRoutes=void 0,require("../collections/user.collection")),jwt=require("jsonwebtoken"),handlebars=require("handlebars"),resolveio_server_app_1=require("../resolveio-server-app"),simpl_schema_1=require("simpl-schema"),bodyParser=require("body-parser"),jwt_decode_1=require("jwt-decode"),common_1=require("../util/common");function setupAuthRoutes(d,e,u){var r=this;e.post("/login365",bodyParser.json(),function(i,a){return __awaiter(r,void 0,void 0,function(){var r,n,s,t,o;return __generator(this,function(e){switch(e.label){case 0:return i.headers.origin===u.ROOT_URL||i.headers.origin===u.SEC_ROOT_URL?[3,1]:(a.send(JSON.stringify({error:!0,result:"Invalid header"})),[3,11]);case 1:n=i.body,r=new simpl_schema_1.default({id_token:{type:String}});try{r.validate(n)}catch(e){if(e)return console.error(new Date,"Error in HTTP Check (/login)",e),resolveio_server_app_1.ResolveIOServer.getMainServer().getMethodManager().sendEmail("dev@resolveio.com",resolveio_server_app_1.ResolveIOServer.getClientName()+"HTTP - Error Detected","Match Error On HTTP /login365\n\nData Being Checked\n"+JSON.stringify(n,null,2)+"\n\nErrors\n"+JSON.stringify(e,null,2)),a.send(JSON.stringify({error:!0,result:"Invalid Parameters"})),[2]}return(r=n.id_token.split("&"),n=r[0].split("=")[1],(s=(0,jwt_decode_1.default)(n))&&s.name&&s.preferred_username&&s.oid)?[4,user_collection_1.Users.findOne({"other.ms_oid":s.oid})]:[3,10];case 2:return(t=e.sent())?[3,5]:[4,user_collection_1.Users.findOne({email:s.preferred_username.toLowerCase()})];case 3:return(t=e.sent())?[4,user_collection_1.Users.updateOne({_id:t._id},{$set:{"other.ms_oid":s.oid}})]:[3,5];case 4:e.sent(),e.label=5;case 5:return t?[3,7]:(t={_id:(0,common_1.objectIdHexString)(),__v:0,roles:{super_admin:!1,approvals:[],groups:[],notifications:[],miscs:[]},username:s.preferred_username.toLowerCase(),email:s.preferred_username.toLowerCase(),fullname:s.name,active:!0,phonenumber:"",readonly:!1,other:{ms_oid:s.oid},attempts:0,salt:jwt.sign({now:(Date.now()-1e3).toString()},u.JWT_SECRET,{expiresIn:7776e6}),hash:jwt.sign({now:(Date.now()+1e3).toString()},u.JWT_SECRET,{expiresIn:7776e6}),last:new Date,settings:null,services:null,is_customer:!1},[4,user_collection_1.Users.create(t)]);case 6:return e.sent(),[3,9];case 7:return(o=!1,t.email!==s.preferred_username.toLowerCase()&&(t.email=s.preferred_username.toLowerCase(),o=!0),t.fullname!==s.name&&(t.fullname=s.name,o=!0),o)?[4,user_collection_1.Users.updateOne({_id:t._id},{$set:{email:t.email,fullname:t.fullname}})]:[3,9];case 8:e.sent(),e.label=9;case 9:return a.send(JSON.stringify({error:!1,result:{token:jwt.sign({id_user:t._id},u.JWT_SECRET,{expiresIn:7776e6})}})),[3,11];case 10:console.log("ERROR - 1",r,n,s),a.send(JSON.stringify({error:!0,result:"Invalid Azure Token"})),e.label=11;case 11:return[2]}})})}),e.post("/login",bodyParser.json(),function(a,l){return __awaiter(r,void 0,void 0,function(){var r,n,s,t,o,i;return __generator(this,function(e){switch(e.label){case 0:return a.headers.origin===u.ROOT_URL||a.headers.origin===u.SEC_ROOT_URL?[3,1]:(l.send(JSON.stringify({error:!0,result:"Invalid header"})),[3,8]);case 1:r=a.body,n=new simpl_schema_1.default({username:{type:String},password:{type:String}});try{n.validate(r)}catch(e){if(e)return console.error(new Date,"Error in HTTP Check (/login)",e),resolveio_server_app_1.ResolveIOServer.getMainServer().getMethodManager().sendEmail("dev@resolveio.com",resolveio_server_app_1.ResolveIOServer.getClientName()+"HTTP - Error Detected","Match Error On HTTP /login\n\nData Being Checked\n"+JSON.stringify(r,null,2)+"\n\nErrors\n"+JSON.stringify(e,null,2)),l.send(JSON.stringify({error:!0,result:"Invalid Parameters"})),[2]}return[4,user_collection_1.Users.findOne({active:!0,username:r.username})];case 2:return(s=e.sent())?[3,4]:[4,user_collection_1.Users.findOne({active:!0,email:r.username})];case 3:s=e.sent(),e.label=4;case 4:return s?[4,user_collection_1.Users.authenticate(s,r.password)]:(l.send(JSON.stringify({error:!0,result:"Invalid Username And Password"})),[2]);case 5:return(t=e.sent()).error?("Too Many Attempts"===t.error?(l.send(JSON.stringify({error:!0,result:t.error+". A password reset link has been sent to your email, please reset your password."})),s.services||(s.services={}),s.services.forgot_password=jwt.sign({id_user:s._id},u.JWT_SECRET),o={userToChangePassword:s.fullname,userWhoResetPassword:resolveio_server_app_1.ResolveIOServer.getClientName()+" System",url:u.ROOT_URL+"/forgot-password?"+encodeURIComponent(u.SERVER_URL)+"&"+s.services.forgot_password},user_collection_1.Users.updateOne({_id:s._id},{$set:{services:s.services}}).then(function(e){d.getMethodManager().readFile("email-templates/forgot-password.html").then(function(e){e=handlebars.compile(e);handlebars.registerHelper("equals",function(e,r){return e===r}),d.getMethodManager().sendEmail(s.email,"ResolveIO ("+resolveio_server_app_1.ResolveIOServer.getClientName()+") - Forgot Password","",e(o),null,null,"")},function(e){return console.log(e)})},function(e){})):"No Salt Value Stored"===t.error?(l.send(JSON.stringify({error:!0,result:"A password reset link has been sent to your email, please reset your password."})),s.services||(s.services={}),s.services.forgot_password=jwt.sign({id_user:s._id},u.JWT_SECRET),i={userToChangePassword:s.fullname,userWhoResetPassword:resolveio_server_app_1.ResolveIOServer.getClientName()+" System",url:u.ROOT_URL+"/forgot-password?"+encodeURIComponent(u.SERVER_URL)+"&"+s.services.forgot_password},user_collection_1.Users.updateOne({_id:s._id},{$set:{services:s.services}}).then(function(e){d.getMethodManager().readFile("email-templates/forgot-password.html").then(function(e){e=handlebars.compile(e);handlebars.registerHelper("equals",function(e,r){return e===r}),d.getMethodManager().sendEmail(s.email,"ResolveIO ("+resolveio_server_app_1.ResolveIOServer.getClientName()+") - Forgot Password","",e(i),null,null,"")},function(e){return console.log(e)})},function(e){})):l.send(JSON.stringify({error:!0,result:t.error})),[3,8]):[3,6];case 6:return t&&t.data&&t.data.active?[4,user_collection_1.Users.resetAttempts(t.data)]:[3,8];case 7:e.sent(),l.send(JSON.stringify({error:!1,result:{token:jwt.sign({id_user:t.data._id},u.JWT_SECRET,{expiresIn:7776e6})}})),e.label=8;case 8:return[2]}})})}),e.post("/accessToken",bodyParser.json(),function(t,o){return __awaiter(this,void 0,void 0,function(){var r,n,s=this;return __generator(this,function(e){if(t.headers.origin!==u.ROOT_URL&&t.headers.origin!==u.SEC_ROOT_URL&&t.headers.origin!==u.RESOLVEIO_URL&&t.headers.origin!==u.RESOLVEIO_SECONDARY_URL)o.send(JSON.stringify({error:!0,result:"Invalid header"}));else{r=t.body,n=new simpl_schema_1.default({refreshToken:{type:String}});try{n.validate(r)}catch(e){if(e)return console.error(new Date,"Error in HTTP Check (/accessToken)",e),resolveio_server_app_1.ResolveIOServer.getMainServer().getMethodManager().sendEmail("dev@resolveio.com",resolveio_server_app_1.ResolveIOServer.getClientName()+"HTTP - Error Detected","Match Error On HTTP /accessToken\n\nData Being Checked\n"+JSON.stringify(r,null,2)+"\n\nErrors\n"+JSON.stringify(e,null,2)),o.send(JSON.stringify({error:!0,result:"Invalid Parameters"})),[2]}jwt.verify(r.refreshToken,u.JWT_SECRET,function(e,r){e?o.send(JSON.stringify({error:!0,result:"Invalid Token"})):user_collection_1.Users.findById(r.id_user).then(function(r){return __awaiter(s,void 0,void 0,function(){return __generator(this,function(e){return r?r.active?o.send(JSON.stringify({error:!1,result:{token:jwt.sign({id_user:r._id},u.JWT_SECRET,{expiresIn:2592e5}),user:r}})):o.send(JSON.stringify({error:!0,result:"Account is Disabled"})):o.send(JSON.stringify({error:!0,result:"Invalid User"})),[2]})})},function(e){o.send(JSON.stringify({error:!0,result:"Invalid Mongo Get User"}))})})}return[2]})})}),e.post("/userWithEnrollmentToken",bodyParser.json(),function(e,n){if(e.headers.origin!==u.ROOT_URL&&e.headers.origin!==u.SEC_ROOT_URL&&e.headers.origin!==u.RESOLVEIO_URL&&e.headers.origin!==u.RESOLVEIO_SECONDARY_URL)n.send(JSON.stringify({error:!0,result:"Invalid header"}));else{var s=e.body,e=new simpl_schema_1.default({enrollmentToken:{type:String}});try{e.validate(s)}catch(e){if(e)return console.error(new Date,"Error in HTTP Check (/userWithEnrollmentToken)",e),resolveio_server_app_1.ResolveIOServer.getMainServer().getMethodManager().sendEmail("dev@resolveio.com",resolveio_server_app_1.ResolveIOServer.getClientName()+"HTTP - Error Detected","Match Error On HTTP /userWithEnrollmentToken\n\nData Being Checked\n"+JSON.stringify(s,null,2)+"\n\nErrors\n"+JSON.stringify(e,null,2)),void n.send(JSON.stringify({error:!0,result:"Invalid Parameters"}))}jwt.verify(s.enrollmentToken,u.JWT_SECRET,function(e,r){e?n.send(JSON.stringify({error:!0,result:"Invalid Token"})):user_collection_1.Users.findOne({$and:[{_id:r.id_user},{"services.enrollment":s.enrollmentToken}]},{projection:{_id:1,__v:1,username:1,active:1}}).then(function(e){e?e.active?n.send(JSON.stringify({error:!1,result:{user:e}})):n.send(JSON.stringify({error:!0,result:"Account is Disabled"})):n.send(JSON.stringify({error:!0,result:"Invalid User"}))},function(e){n.send(JSON.stringify({error:!0,result:"Invalid Mongo Get User"}))})})}}),e.post("/setUserWithEnrollmentToken",bodyParser.json(),function(e,t){var n=this;if(e.headers.origin!==u.ROOT_URL&&e.headers.origin!==u.SEC_ROOT_URL&&e.headers.origin!==u.RESOLVEIO_URL&&e.headers.origin!==u.RESOLVEIO_SECONDARY_URL)t.send(JSON.stringify({error:!0,result:"Invalid header"}));else{var o=e.body,e=new simpl_schema_1.default({enrollmentToken:{type:String},password:{type:String}});try{e.validate(o)}catch(e){if(e)return console.error(new Date,"Error in HTTP Check (/setUserWithEnrollmentToken)",e),resolveio_server_app_1.ResolveIOServer.getMainServer().getMethodManager().sendEmail("dev@resolveio.com",resolveio_server_app_1.ResolveIOServer.getClientName()+"HTTP - Error Detected","Match Error On HTTP /setUserWithEnrollmentToken\n\nData Being Checked\n"+JSON.stringify(o,null,2)+"\n\nErrors\n"+JSON.stringify(e,null,2)),void t.send(JSON.stringify({error:!0,result:"Invalid Parameters"}))}jwt.verify(o.enrollmentToken,u.JWT_SECRET,function(r,s){return __awaiter(n,void 0,void 0,function(){var n=this;return __generator(this,function(e){return r?t.send(JSON.stringify({error:!0,result:"Invalid Token"})):user_collection_1.Users.findOne({$and:[{_id:s.id_user},{"services.enrollment":o.enrollmentToken}]}).then(function(r){return __awaiter(n,void 0,void 0,function(){return __generator(this,function(e){switch(e.label){case 0:return r?r.active?[4,user_collection_1.Users.setPassword(r,o.password)]:[3,2]:[3,4];case 1:return e.sent(),t.send(JSON.stringify({error:!1,result:!0})),[3,3];case 2:t.send(JSON.stringify({error:!0,result:"Account is Disabled"})),e.label=3;case 3:return[3,5];case 4:t.send(JSON.stringify({error:!0,result:"Invalid User"})),e.label=5;case 5:return[2]}})})},function(e){t.send(JSON.stringify({error:!0,result:"Invalid Mongo Get User"}))}),[2]})})})}}),e.post("/userWithForgotPasswordToken",bodyParser.json(),function(e,n){if(e.headers.origin!==u.ROOT_URL&&e.headers.origin!==u.SEC_ROOT_URL&&e.headers.origin!==u.RESOLVEIO_URL&&e.headers.origin!==u.RESOLVEIO_SECONDARY_URL)n.send(JSON.stringify({error:!0,result:"Invalid header"}));else{var s=e.body,e=new simpl_schema_1.default({forgotPasswordToken:{type:String}});try{e.validate(s)}catch(e){if(e)return console.error(new Date,"Error in HTTP Check (/userWithForgotPasswordToken)",e),resolveio_server_app_1.ResolveIOServer.getMainServer().getMethodManager().sendEmail("dev@resolveio.com",resolveio_server_app_1.ResolveIOServer.getClientName()+"HTTP - Error Detected","Match Error On HTTP /userWithForgotPasswordToken\n\nData Being Checked\n"+JSON.stringify(s,null,2)+"\n\nErrors\n"+JSON.stringify(e,null,2)),void n.send(JSON.stringify({error:!0,result:"Invalid Parameters"}))}jwt.verify(s.forgotPasswordToken,u.JWT_SECRET,function(e,r){e?n.send(JSON.stringify({error:!0,result:"Invalid Token"})):user_collection_1.Users.findOne({$and:[{_id:r.id_user},{"services.forgot_password":s.forgotPasswordToken}]},{projection:{_id:1,__v:1,username:1,active:1}}).then(function(e){e?e.active?n.send(JSON.stringify({error:!1,result:{user:e}})):n.send(JSON.stringify({error:!0,result:"Account is Disabled"})):n.send(JSON.stringify({error:!0,result:"Invalid Token"}))},function(e){n.send(JSON.stringify({error:!0,result:"Invalid Mongo Get User"}))})})}}),e.post("/setUserWithForgotPasswordToken",bodyParser.json(),function(e,t){var n=this;if(e.headers.origin!==u.ROOT_URL&&e.headers.origin!==u.SEC_ROOT_URL&&e.headers.origin!==u.RESOLVEIO_URL&&e.headers.origin!==u.RESOLVEIO_SECONDARY_URL)t.send(JSON.stringify({error:!0,result:"Invalid header"}));else{var o=e.body,e=new simpl_schema_1.default({forgotPasswordToken:{type:String},password:{type:String}});try{e.validate(o)}catch(e){if(e)return console.error(new Date,"Error in HTTP Check (/setUserWithForgotPasswordToken)",e),resolveio_server_app_1.ResolveIOServer.getMainServer().getMethodManager().sendEmail("dev@resolveio.com",resolveio_server_app_1.ResolveIOServer.getClientName()+"HTTP - Error Detected","Match Error On HTTP /setUserWithForgotPasswordToken\n\nData Being Checked\n"+JSON.stringify(o,null,2)+"\n\nErrors\n"+JSON.stringify(e,null,2)),void t.send(JSON.stringify({error:!0,result:"Invalid Parameters"}))}jwt.verify(o.forgotPasswordToken,u.JWT_SECRET,function(r,s){return __awaiter(n,void 0,void 0,function(){var n=this;return __generator(this,function(e){return r?t.send(JSON.stringify({error:!0,result:"Invalid Token"})):user_collection_1.Users.findOne({$and:[{_id:s.id_user},{"services.forgot_password":o.forgotPasswordToken}]}).then(function(r){return __awaiter(n,void 0,void 0,function(){return __generator(this,function(e){switch(e.label){case 0:return r?r.active?[4,user_collection_1.Users.setPassword(r,o.password)]:[3,2]:[3,4];case 1:return e.sent(),t.send(JSON.stringify({error:!1,result:!0})),[3,3];case 2:t.send(JSON.stringify({error:!0,result:"Account is Disabled"})),e.label=3;case 3:return[3,5];case 4:t.send(JSON.stringify({error:!0,result:"Invalid User"})),e.label=5;case 5:return[2]}})})},function(e){t.send(JSON.stringify({error:!0,result:"Invalid Mongo Get User"}))}),[2]})})})}}),e.post("/resetPassword",bodyParser.json(),function(t,o){return __awaiter(r,void 0,void 0,function(){var r,n,s;return __generator(this,function(e){switch(e.label){case 0:return t.headers.origin===u.ROOT_URL||t.headers.origin===u.SEC_ROOT_URL?[3,1]:(o.send(JSON.stringify({error:!0,result:"Invalid header"})),[3,5]);case 1:r=t.body,n=new simpl_schema_1.default({username:{type:String}});try{n.validate(r)}catch(e){if(e)return console.error(new Date,"Error in HTTP Check (/resetPassword)",e),resolveio_server_app_1.ResolveIOServer.getMainServer().getMethodManager().sendEmail("dev@resolveio.com",resolveio_server_app_1.ResolveIOServer.getClientName()+"HTTP - Error Detected","Match Error On HTTP /resetPassword\n\nData Being Checked\n"+JSON.stringify(r,null,2)+"\n\nErrors\n"+JSON.stringify(e,null,2)),o.send(JSON.stringify({error:!0,result:"Invalid Parameters"})),[2]}return[4,user_collection_1.Users.findOne({active:!0,username:r.username})];case 2:return(s=e.sent())?[3,4]:[4,user_collection_1.Users.findOne({active:!0,email:r.username})];case 3:s=e.sent(),e.label=4;case 4:s&&d.getMethodManager().callMethodInternal.call(d.getMethodManager(),"resetUserPassword",s._id),o.send(JSON.stringify({error:!1,result:""})),e.label=5;case 5:return[2]}})})})}exports.setupAuthRoutes=setupAuthRoutes;
1
+ "use strict";var __awaiter=this&&this.__awaiter||function(e,s,t,o){return new(t=t||Promise)(function(n,r){function fulfilled(e){try{step(o.next(e))}catch(e){r(e)}}function rejected(e){try{step(o.throw(e))}catch(e){r(e)}}function step(e){var r;e.done?n(e.value):((r=e.value)instanceof t?r:new t(function(e){e(r)})).then(fulfilled,rejected)}step((o=o.apply(e,s||[])).next())})},__generator=this&&this.__generator||function(s,t){var o,i,a,l={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},d={next:verb(0),throw:verb(1),return:verb(2)};return"function"==typeof Symbol&&(d[Symbol.iterator]=function(){return this}),d;function verb(n){return function(e){var r=[n,e];if(o)throw new TypeError("Generator is already executing.");for(;l=d&&r[d=0]?0:l;)try{if(o=1,i&&(a=2&r[0]?i.return:r[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,r[1])).done)return a;switch(i=0,(r=a?[2&r[0],a.value]:r)[0]){case 0:case 1:a=r;break;case 4:return l.label++,{value:r[1],done:!1};case 5:l.label++,i=r[1],r=[0];continue;case 7:r=l.ops.pop(),l.trys.pop();continue;default:if(!(a=0<(a=l.trys).length&&a[a.length-1])&&(6===r[0]||2===r[0])){l=0;continue}if(3===r[0]&&(!a||r[1]>a[0]&&r[1]<a[3]))l.label=r[1];else if(6===r[0]&&l.label<a[1])l.label=a[1],a=r;else{if(!(a&&l.label<a[2])){a[2]&&l.ops.pop(),l.trys.pop();continue}l.label=a[2],l.ops.push(r)}}r=t.call(s,l)}catch(e){r=[6,e],i=0}finally{o=a=0}if(5&r[0])throw r[1];return{value:r[0]?r[1]:void 0,done:!0}}}},user_collection_1=(Object.defineProperty(exports,"__esModule",{value:!0}),exports.setupAuthRoutes=void 0,require("../collections/user.collection")),jwt=require("jsonwebtoken"),handlebars=require("handlebars"),resolveio_server_app_1=require("../resolveio-server-app"),simpl_schema_1=require("simpl-schema"),bodyParser=require("body-parser"),jwt_decode_1=require("jwt-decode"),common_1=require("../util/common");function setupAuthRoutes(d,e,u){var r=this;e.post("/login365",bodyParser.json(),function(i,a){return __awaiter(r,void 0,void 0,function(){var r,n,s,t,o;return __generator(this,function(e){switch(e.label){case 0:return i.headers.origin===u.ROOT_URL||i.headers.origin===u.SEC_ROOT_URL?[3,1]:(a.send(JSON.stringify({error:!0,result:"Invalid header"})),[3,11]);case 1:n=i.body,r=new simpl_schema_1.default({id_token:{type:String}});try{r.validate(n)}catch(e){if(e)return console.error(new Date,"Error in HTTP Check (/login)",e),resolveio_server_app_1.ResolveIOServer.getMainServer().getMethodManager().sendEmail("dev@resolveio.com",resolveio_server_app_1.ResolveIOServer.getClientName()+"HTTP - Error Detected","Match Error On HTTP /login365\n\nData Being Checked\n"+JSON.stringify(n,null,2)+"\n\nErrors\n"+JSON.stringify(e,null,2)),a.send(JSON.stringify({error:!0,result:"Invalid Parameters"})),[2]}return(r=n.id_token.split("&"),n=r[0].split("=")[1],(s=(0,jwt_decode_1.default)(n))&&s.name&&s.preferred_username&&s.oid)?[4,user_collection_1.Users.findOne({"other.ms_oid":s.oid})]:[3,10];case 2:return(t=e.sent())?[3,5]:[4,user_collection_1.Users.findOne({email:s.preferred_username.toLowerCase()})];case 3:return(t=e.sent())?[4,user_collection_1.Users.updateOne({_id:t._id},{$set:{"other.ms_oid":s.oid}})]:[3,5];case 4:e.sent(),e.label=5;case 5:return t?[3,7]:(t={_id:(0,common_1.objectIdHexString)(),__v:0,roles:{super_admin:!1,approvals:[],groups:[],notifications:[],miscs:[]},username:s.preferred_username.toLowerCase(),email:s.preferred_username.toLowerCase(),fullname:s.name,active:!0,phonenumber:"",readonly:!1,other:{ms_oid:s.oid},attempts:0,salt:jwt.sign({now:(Date.now()-1e3).toString()},u.JWT_SECRET,{expiresIn:7776e6}),hash:jwt.sign({now:(Date.now()+1e3).toString()},u.JWT_SECRET,{expiresIn:7776e6}),last:new Date,settings:null,services:null,is_customer:!1},[4,user_collection_1.Users.create(t)]);case 6:return e.sent(),[3,9];case 7:return(o=!1,t.email!==s.preferred_username.toLowerCase()&&(t.email=s.preferred_username.toLowerCase(),o=!0),t.fullname!==s.name&&(t.fullname=s.name,o=!0),o)?[4,user_collection_1.Users.updateOne({_id:t._id},{$set:{email:t.email,fullname:t.fullname}})]:[3,9];case 8:e.sent(),e.label=9;case 9:return a.send(JSON.stringify({error:!1,result:{token:jwt.sign({id_user:t._id},u.JWT_SECRET,{expiresIn:7776e6})}})),[3,11];case 10:console.log("ERROR - 1",r,n,s),a.send(JSON.stringify({error:!0,result:"Invalid Azure Token"})),e.label=11;case 11:return[2]}})})}),e.post("/login",bodyParser.json(),function(a,l){return __awaiter(r,void 0,void 0,function(){var r,n,s,t,o,i;return __generator(this,function(e){switch(e.label){case 0:return a.headers.origin===u.ROOT_URL||a.headers.origin===u.SEC_ROOT_URL?[3,1]:(l.send(JSON.stringify({error:!0,result:"Invalid header"})),[3,8]);case 1:r=a.body,n=new simpl_schema_1.default({username:{type:String},password:{type:String}});try{n.validate(r)}catch(e){if(e)return console.error(new Date,"Error in HTTP Check (/login)",e),resolveio_server_app_1.ResolveIOServer.getMainServer().getMethodManager().sendEmail("dev@resolveio.com",resolveio_server_app_1.ResolveIOServer.getClientName()+"HTTP - Error Detected","Match Error On HTTP /login\n\nData Being Checked\n"+JSON.stringify(r,null,2)+"\n\nErrors\n"+JSON.stringify(e,null,2)),l.send(JSON.stringify({error:!0,result:"Invalid Parameters"})),[2]}return[4,user_collection_1.Users.findOne({active:!0,username:r.username})];case 2:return(s=e.sent())?[3,4]:[4,user_collection_1.Users.findOne({active:!0,email:r.username})];case 3:s=e.sent(),e.label=4;case 4:return s?[4,user_collection_1.Users.authenticate(s,r.password)]:(l.send(JSON.stringify({error:!0,result:"Invalid Username And Password"})),[2]);case 5:return(t=e.sent()).error?("Too Many Attempts"===t.error?(l.send(JSON.stringify({error:!0,result:t.error+". A password reset link has been sent to your email, please reset your password."})),s.services||(s.services={}),s.services.forgot_password=jwt.sign({id_user:s._id},u.JWT_SECRET),o={userToChangePassword:s.fullname,userWhoResetPassword:resolveio_server_app_1.ResolveIOServer.getClientName()+" System",url:u.ROOT_URL+"/forgot-password?"+encodeURIComponent(u.SERVER_URL)+"&"+s.services.forgot_password},user_collection_1.Users.updateOne({_id:s._id},{$set:{services:s.services}}).then(function(e){d.getMethodManager().readFile("email-templates/forgot-password.html").then(function(e){e=handlebars.compile(e);handlebars.registerHelper("equals",function(e,r){return e===r}),d.getMethodManager().sendEmail(s.email,"ResolveIO ("+resolveio_server_app_1.ResolveIOServer.getClientName()+") - Forgot Password","",e(o),null,null,"")},function(e){return console.log(e)})},function(e){})):"No Salt Value Stored"===t.error?(l.send(JSON.stringify({error:!0,result:"A password reset link has been sent to your email, please reset your password."})),s.services||(s.services={}),s.services.forgot_password=jwt.sign({id_user:s._id},u.JWT_SECRET),i={userToChangePassword:s.fullname,userWhoResetPassword:resolveio_server_app_1.ResolveIOServer.getClientName()+" System",url:u.ROOT_URL+"/forgot-password?"+encodeURIComponent(u.SERVER_URL)+"&"+s.services.forgot_password},user_collection_1.Users.updateOne({_id:s._id},{$set:{services:s.services}}).then(function(e){d.getMethodManager().readFile("email-templates/forgot-password.html").then(function(e){e=handlebars.compile(e);handlebars.registerHelper("equals",function(e,r){return e===r}),d.getMethodManager().sendEmail(s.email,"ResolveIO ("+resolveio_server_app_1.ResolveIOServer.getClientName()+") - Forgot Password","",e(i),null,null,"")},function(e){return console.log(e)})},function(e){})):l.send(JSON.stringify({error:!0,result:t.error})),[3,8]):[3,6];case 6:return t&&t.data&&t.data.active?[4,user_collection_1.Users.resetAttempts(t.data)]:[3,8];case 7:e.sent(),l.send(JSON.stringify({error:!1,result:{token:jwt.sign({id_user:t.data._id},u.JWT_SECRET,{expiresIn:7776e6})}})),e.label=8;case 8:return[2]}})})}),e.post("/accessToken",bodyParser.json(),function(t,o){return __awaiter(this,void 0,void 0,function(){var r,n,s=this;return __generator(this,function(e){if(t.headers.origin!==u.ROOT_URL&&t.headers.origin!==u.SEC_ROOT_URL&&t.headers.origin!==u.RESOLVEIO_URL&&t.headers.origin!==u.RESOLVEIO_SECONDARY_URL)o.send(JSON.stringify({error:!0,result:"Invalid header"}));else{r=t.body,n=new simpl_schema_1.default({refreshToken:{type:String}});try{n.validate(r)}catch(e){if(e)return console.error(new Date,"Error in HTTP Check (/accessToken)",e),resolveio_server_app_1.ResolveIOServer.getMainServer().getMethodManager().sendEmail("dev@resolveio.com",resolveio_server_app_1.ResolveIOServer.getClientName()+"HTTP - Error Detected","Match Error On HTTP /accessToken\n\nData Being Checked\n"+JSON.stringify(r,null,2)+"\n\nErrors\n"+JSON.stringify(e,null,2)),o.send(JSON.stringify({error:!0,result:"Invalid Parameters"})),[2]}jwt.verify(r.refreshToken,u.JWT_SECRET,function(e,r){e?o.send(JSON.stringify({error:!0,result:"Invalid Token"})):user_collection_1.Users.findById(r.id_user).then(function(r){return __awaiter(s,void 0,void 0,function(){return __generator(this,function(e){return r?r.active?o.send(JSON.stringify({error:!1,result:{token:jwt.sign({id_user:r._id},u.JWT_SECRET,{expiresIn:2592e5}),user:r}})):o.send(JSON.stringify({error:!0,result:"Account is Disabled"})):o.send(JSON.stringify({error:!0,result:"Invalid User"})),[2]})})},function(e){o.send(JSON.stringify({error:!0,result:"Invalid Mongo Get User"}))})})}return[2]})})}),e.post("/userWithEnrollmentToken",bodyParser.json(),function(e,n){if(e.headers.origin!==u.ROOT_URL&&e.headers.origin!==u.SEC_ROOT_URL&&e.headers.origin!==u.RESOLVEIO_URL&&e.headers.origin!==u.RESOLVEIO_SECONDARY_URL)n.send(JSON.stringify({error:!0,result:"Invalid header"}));else{var s=e.body,e=new simpl_schema_1.default({enrollmentToken:{type:String}});try{e.validate(s)}catch(e){if(e)return console.error(new Date,"Error in HTTP Check (/userWithEnrollmentToken)",e),resolveio_server_app_1.ResolveIOServer.getMainServer().getMethodManager().sendEmail("dev@resolveio.com",resolveio_server_app_1.ResolveIOServer.getClientName()+"HTTP - Error Detected","Match Error On HTTP /userWithEnrollmentToken\n\nData Being Checked\n"+JSON.stringify(s,null,2)+"\n\nErrors\n"+JSON.stringify(e,null,2)),void n.send(JSON.stringify({error:!0,result:"Invalid Parameters"}))}jwt.verify(s.enrollmentToken,u.JWT_SECRET,function(e,r){e?n.send(JSON.stringify({error:!0,result:"Invalid Token"})):user_collection_1.Users.findOne({$and:[{_id:r.id_user},{"services.enrollment":s.enrollmentToken}]},{projection:{_id:1,__v:1,username:1,active:1}}).then(function(e){e?e.active?n.send(JSON.stringify({error:!1,result:{user:e}})):n.send(JSON.stringify({error:!0,result:"Account is Disabled"})):n.send(JSON.stringify({error:!0,result:"Invalid User"}))},function(e){n.send(JSON.stringify({error:!0,result:"Invalid Mongo Get User"}))})})}}),e.post("/setUserWithEnrollmentToken",bodyParser.json(),function(e,t){var n=this;if(e.headers.origin!==u.ROOT_URL&&e.headers.origin!==u.SEC_ROOT_URL&&e.headers.origin!==u.RESOLVEIO_URL&&e.headers.origin!==u.RESOLVEIO_SECONDARY_URL)t.send(JSON.stringify({error:!0,result:"Invalid header"}));else{var o=e.body,e=new simpl_schema_1.default({enrollmentToken:{type:String},password:{type:String}});try{e.validate(o)}catch(e){if(e)return console.error(new Date,"Error in HTTP Check (/setUserWithEnrollmentToken)",e),resolveio_server_app_1.ResolveIOServer.getMainServer().getMethodManager().sendEmail("dev@resolveio.com",resolveio_server_app_1.ResolveIOServer.getClientName()+"HTTP - Error Detected","Match Error On HTTP /setUserWithEnrollmentToken\n\nData Being Checked\n"+JSON.stringify(o,null,2)+"\n\nErrors\n"+JSON.stringify(e,null,2)),void t.send(JSON.stringify({error:!0,result:"Invalid Parameters"}))}jwt.verify(o.enrollmentToken,u.JWT_SECRET,function(r,s){return __awaiter(n,void 0,void 0,function(){var n=this;return __generator(this,function(e){return r?t.send(JSON.stringify({error:!0,result:"Invalid Token"})):user_collection_1.Users.findOne({$and:[{_id:s.id_user},{"services.enrollment":o.enrollmentToken}]}).then(function(r){return __awaiter(n,void 0,void 0,function(){return __generator(this,function(e){switch(e.label){case 0:return r?r.active?[4,user_collection_1.Users.setPassword(r,o.password)]:[3,2]:[3,4];case 1:return e.sent(),t.send(JSON.stringify({error:!1,result:!0})),[3,3];case 2:t.send(JSON.stringify({error:!0,result:"Account is Disabled"})),e.label=3;case 3:return[3,5];case 4:t.send(JSON.stringify({error:!0,result:"Invalid User"})),e.label=5;case 5:return[2]}})})},function(e){t.send(JSON.stringify({error:!0,result:"Invalid Mongo Get User"}))}),[2]})})})}}),e.post("/userWithForgotPasswordToken",bodyParser.json(),function(e,n){if(e.headers.origin!==u.ROOT_URL&&e.headers.origin!==u.SEC_ROOT_URL&&e.headers.origin!==u.RESOLVEIO_URL&&e.headers.origin!==u.RESOLVEIO_SECONDARY_URL)n.send(JSON.stringify({error:!0,result:"Invalid header"}));else{var s=e.body,e=new simpl_schema_1.default({forgotPasswordToken:{type:String}});try{e.validate(s)}catch(e){if(e)return console.error(new Date,"Error in HTTP Check (/userWithForgotPasswordToken)",e),resolveio_server_app_1.ResolveIOServer.getMainServer().getMethodManager().sendEmail("dev@resolveio.com",resolveio_server_app_1.ResolveIOServer.getClientName()+"HTTP - Error Detected","Match Error On HTTP /userWithForgotPasswordToken\n\nData Being Checked\n"+JSON.stringify(s,null,2)+"\n\nErrors\n"+JSON.stringify(e,null,2)),void n.send(JSON.stringify({error:!0,result:"Invalid Parameters"}))}jwt.verify(s.forgotPasswordToken,u.JWT_SECRET,function(e,r){e?n.send(JSON.stringify({error:!0,result:"Invalid Token"})):user_collection_1.Users.findOne({$and:[{_id:r.id_user},{"services.forgot_password":s.forgotPasswordToken}]},{projection:{_id:1,__v:1,username:1,active:1}}).then(function(e){e?e.active?n.send(JSON.stringify({error:!1,result:{user:e}})):n.send(JSON.stringify({error:!0,result:"Account is Disabled"})):n.send(JSON.stringify({error:!0,result:"Invalid Token"}))},function(e){n.send(JSON.stringify({error:!0,result:"Invalid Mongo Get User"}))})})}}),e.post("/setUserWithForgotPasswordToken",bodyParser.json(),function(e,t){var n=this;if(e.headers.origin!==u.ROOT_URL&&e.headers.origin!==u.SEC_ROOT_URL&&e.headers.origin!==u.RESOLVEIO_URL&&e.headers.origin!==u.RESOLVEIO_SECONDARY_URL)t.send(JSON.stringify({error:!0,result:"Invalid header"}));else{var o=e.body,e=new simpl_schema_1.default({forgotPasswordToken:{type:String},password:{type:String}});try{e.validate(o)}catch(e){if(e)return console.error(new Date,"Error in HTTP Check (/setUserWithForgotPasswordToken)",e),resolveio_server_app_1.ResolveIOServer.getMainServer().getMethodManager().sendEmail("dev@resolveio.com",resolveio_server_app_1.ResolveIOServer.getClientName()+"HTTP - Error Detected","Match Error On HTTP /setUserWithForgotPasswordToken\n\nData Being Checked\n"+JSON.stringify(o,null,2)+"\n\nErrors\n"+JSON.stringify(e,null,2)),void t.send(JSON.stringify({error:!0,result:"Invalid Parameters"}))}jwt.verify(o.forgotPasswordToken,u.JWT_SECRET,function(r,s){return __awaiter(n,void 0,void 0,function(){var n=this;return __generator(this,function(e){return r?t.send(JSON.stringify({error:!0,result:"Invalid Token"})):user_collection_1.Users.findOne({$and:[{_id:s.id_user},{"services.forgot_password":o.forgotPasswordToken}]}).then(function(r){return __awaiter(n,void 0,void 0,function(){return __generator(this,function(e){switch(e.label){case 0:return r?r.active?[4,user_collection_1.Users.setPassword(r,o.password)]:[3,2]:[3,4];case 1:return e.sent(),t.send(JSON.stringify({error:!1,result:!0})),[3,3];case 2:t.send(JSON.stringify({error:!0,result:"Account is Disabled"})),e.label=3;case 3:return[3,5];case 4:t.send(JSON.stringify({error:!0,result:"Invalid User"})),e.label=5;case 5:return[2]}})})},function(e){t.send(JSON.stringify({error:!0,result:"Invalid Mongo Get User"}))}),[2]})})})}}),e.post("/resetPassword",bodyParser.json(),function(t,o){return __awaiter(r,void 0,void 0,function(){var r,n,s;return __generator(this,function(e){switch(e.label){case 0:return t.headers.origin===u.ROOT_URL||t.headers.origin===u.SEC_ROOT_URL?[3,1]:(o.send(JSON.stringify({error:!0,result:"Invalid header"})),[3,5]);case 1:r=t.body,n=new simpl_schema_1.default({username:{type:String}});try{n.validate(r)}catch(e){if(e)return console.error(new Date,"Error in HTTP Check (/resetPassword)",e),resolveio_server_app_1.ResolveIOServer.getMainServer().getMethodManager().sendEmail("dev@resolveio.com",resolveio_server_app_1.ResolveIOServer.getClientName()+"HTTP - Error Detected","Match Error On HTTP /resetPassword\n\nData Being Checked\n"+JSON.stringify(r,null,2)+"\n\nErrors\n"+JSON.stringify(e,null,2)),o.send(JSON.stringify({error:!0,result:"Invalid Parameters"})),[2]}return[4,user_collection_1.Users.findOne({active:!0,username:r.username})];case 2:return(s=e.sent())?[3,4]:[4,user_collection_1.Users.findOne({active:!0,email:r.username})];case 3:s=e.sent(),e.label=4;case 4:s&&d.getMethodManager().callMethod.call(d.getMethodManager(),"resetUserPassword",s._id),o.send(JSON.stringify({error:!1,result:""})),e.label=5;case 5:return[2]}})})})}exports.setupAuthRoutes=setupAuthRoutes;
2
2
  //# sourceMappingURL=auth.js.map
package/http/auth.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/http/auth.ts"],"names":["user_collection_1","require","jwt","handlebars","resolveio_server_app_1","simpl_schema_1","bodyParser","jwt_decode_1","common_1","setupAuthRoutes","mainServer","app","serverConfig","_this","this","post","json","request","response","__awaiter","headers","origin","send","JSON","stringify","error","result","body","schema","default","id_token","type","String","validate","errors","console","Date","ResolveIOServer","getMainServer","getMethodManager","sendEmail","getClientName","tokenData","split","token","decodedJWT","Users","findOne","other.ms_oid","user","_a","sent","email","toLowerCase","updateOne","_id","$set","objectIdHexString","__v","roles","super_admin","approvals","groups","notifications","miscs","username","fullname","active","phonenumber","readonly","other","ms_oid","attempts","salt","sign","now","toString","expiresIn","hash","last","settings","services","is_customer","create","update","id_user","log","password","user_1","authenticate","resAuth","emailData_1","userToChangePassword","userWhoResetPassword","url","encodeURIComponent","then","resUp","readFile","html","template","compile","registerHelper","a","b","errEmail","errUp","emailData_2","err","resetAttempts","refreshToken","verify","decoded","findById","body_1","enrollmentToken","$and","services.enrollment","projection","body_2","setPassword","body_3","forgotPasswordToken","services.forgot_password","body_4","callMethodInternal","call","exports"],"mappings":"k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MC,M,EAEP,EAED,IACCJ,EAAOK,SAASN,CAAI,C,CAErB,MAAOO,GACN,GAAIA,EAUH,OATAC,QAAQV,MAAM,IAAIW,KAAQ,uCAAwCF,CAAM,EAExE9B,uBAAAiC,gBAAgBC,cAAa,EAAGC,iBAAgB,EAAGC,UAAU,oBAAqBpC,uBAAAiC,gBAAgBI,cAAa,EAAK,wBAAyB,6DAAyElB,KAAKC,UAAUG,EAAM,KAAM,CAAC,EAAI,eAAiBJ,KAAKC,UAAUU,EAAQ,KAAM,CAAC,CAAC,EAEtShB,EAASI,KAAKC,KAAKC,UAAU,CAC5BC,MAAO,CAAA,EACPC,OAAQ,oB,CACR,CAAC,EAEF,CAAA,E,CAIS,MAAA,CAAA,EAAM1B,kBAAA8C,MAAMC,QAAQ,CAACoB,OAAQ,CAAA,EAAMF,SAAUtC,EAAKsC,QAAQ,CAAC,G,cAAlEhB,EAAOC,EAAAC,KAAA,GAEP,CAAA,EAAA,GACI,CAAA,EAAMnD,kBAAA8C,MAAMC,QAAQ,CAACoB,OAAQ,CAAA,EAAMf,MAAOzB,EAAKsC,QAAQ,CAAC,G,OAA/DhB,EAAOC,EAAAC,KAAA,E,iBAGJF,GACHvC,EAAW6B,iBAAgB,EAAGsF,mBAAmBC,KAAKpH,EAAW6B,iBAAgB,EAAI,oBAAqBU,EAAKM,GAAG,EAGnHrC,EAASI,KAAKC,KAAKC,UAAU,CAC5BC,MAAO,CAAA,EACPC,OAAQ,E,CACR,CAAC,E,gCAEH,CACF,CAjtBAqG,QAAAtH,gBAAAA","file":"auth.js","sourcesContent":["import { Users } from '../collections/user.collection';\nimport * as jwt from 'jsonwebtoken';\nimport * as handlebars from 'handlebars';\nimport { ResolveIOServer } from '../resolveio-server-app';\nimport { UserModel } from '../models/user.model';\nimport SimpleSchema from 'simpl-schema';\nimport * as bodyParser from 'body-parser';\nimport jwt_decode from 'jwt-decode';\nimport { objectIdHexString } from '../util/common';\n\nexport function setupAuthRoutes(mainServer, 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\tResolveIOServer.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\tResolveIOServer.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\tUsers.updateOne({_id: user._id}, {$set: {services: user.services}}).then(resUp => {\n\t\t\t\t\t\tmainServer.getMethodManager().readFile('email-templates/forgot-password.html').then(html => {\n\t\t\t\t\t\t\tlet template = handlebars.compile(html);\n\t\t\t\t\t\t\thandlebars.registerHelper('equals', (a, b) => {\n\t\t\t\t\t\t\t\treturn a === b;\n\t\t\t\t\t\t\t});\n\t\t\n\t\t\t\t\t\t\tmainServer.getMethodManager().sendEmail(user.email, 'ResolveIO (' + ResolveIOServer.getClientName() + ') - Forgot Password', '', template(emailData), null, null, '');\n\t\t\t\t\t\t}, errEmail => console.log(errEmail));\n\t\t\t\t\t}, errUp => {});\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\tUsers.updateOne({_id: user._id}, {$set: {services: user.services}}).then(resUp => {\n\t\t\t\t\t\tmainServer.getMethodManager().readFile('email-templates/forgot-password.html').then(html => {\n\t\t\t\t\t\t\tlet template = handlebars.compile(html);\n\t\t\t\t\t\t\thandlebars.registerHelper('equals', (a, b) => {\n\t\t\t\t\t\t\t\treturn a === b;\n\t\t\t\t\t\t\t});\n\t\t\n\t\t\t\t\t\t\tmainServer.getMethodManager().sendEmail(user.email, 'ResolveIO (' + ResolveIOServer.getClientName() + ') - Forgot Password', '', template(emailData), null, null, '');\n\t\t\t\t\t\t}, errEmail => console.log(errEmail));\n\t\t\t\t\t}, err => {});\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 function (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\tResolveIOServer.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'], (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\tUsers.findById(decoded['id_user']).then(async (user: UserModel) => {\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}, error => {\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(), function (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\tResolveIOServer.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'], (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\tUsers.findOne({\n\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t{_id: decoded['id_user']},\n\t\t\t\t\t\t\t{'services.enrollment': body.enrollmentToken}\n\t\t\t\t\t\t]\n\t\t\t\t\t}, {projection: {_id: 1, __v: 1, username: 1, active: 1}}).then((user) => {\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}, error => {\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(), function (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\tResolveIOServer.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\tUsers.findOne({\n\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t{_id: decoded['id_user']},\n\t\t\t\t\t\t\t{'services.enrollment': body.enrollmentToken}\n\t\t\t\t\t\t]\n\t\t\t\t\t}).then(async (user: UserModel) => {\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}, error => {\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(), function (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\tResolveIOServer.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'], (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\tUsers.findOne({\n\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t{_id: decoded['id_user']},\n\t\t\t\t\t\t\t{'services.forgot_password': body.forgotPasswordToken}\n\t\t\t\t\t\t]\n\t\t\t\t\t}, {projection: {_id: 1, __v: 1, username: 1, active: 1}}).then((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\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}, error => {\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(), function (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\tResolveIOServer.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\tUsers.findOne({\n\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t{_id: decoded['id_user']},\n\t\t\t\t\t\t\t{'services.forgot_password': body.forgotPasswordToken}\n\t\t\t\t\t\t]\n\t\t\t\t\t}).then(async (user: UserModel) => {\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}, error => {\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\tResolveIOServer.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().callMethodInternal.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}"]}
1
+ {"version":3,"sources":["../../src/http/auth.ts"],"names":["user_collection_1","require","jwt","handlebars","resolveio_server_app_1","simpl_schema_1","bodyParser","jwt_decode_1","common_1","setupAuthRoutes","mainServer","app","serverConfig","_this","this","post","json","request","response","__awaiter","headers","origin","send","JSON","stringify","error","result","body","schema","default","id_token","type","String","validate","errors","console","Date","ResolveIOServer","getMainServer","getMethodManager","sendEmail","getClientName","tokenData","split","token","decodedJWT","Users","findOne","other.ms_oid","user","_a","sent","email","toLowerCase","updateOne","_id","$set","objectIdHexString","__v","roles","super_admin","approvals","groups","notifications","miscs","username","fullname","active","phonenumber","readonly","other","ms_oid","attempts","salt","sign","now","toString","expiresIn","hash","last","settings","services","is_customer","create","update","id_user","log","password","user_1","authenticate","resAuth","emailData_1","userToChangePassword","userWhoResetPassword","url","encodeURIComponent","then","resUp","readFile","html","template","compile","registerHelper","a","b","errEmail","errUp","emailData_2","err","resetAttempts","refreshToken","verify","decoded","findById","body_1","enrollmentToken","$and","services.enrollment","projection","body_2","setPassword","body_3","forgotPasswordToken","services.forgot_password","body_4","callMethod","call","exports"],"mappings":"k8CAAAA,mB,sFAAAC,QAAA,gCAAA,GACAC,IAAAD,QAAA,cAAA,EACAE,WAAAF,QAAA,YAAA,EACAG,uBAAAH,QAAA,yBAAA,EAEAI,eAAAJ,QAAA,cAAA,EACAK,WAAAL,QAAA,aAAA,EACAM,aAAAN,QAAA,YAAA,EACAO,SAAAP,QAAA,gBAAA,EAEA,SAAgBQ,gBAAgBC,EAAYC,EAAKC,GAAjD,IAAAC,EAAAC,KACCH,EAAII,KAAK,YAAaT,WAAWU,KAAI,EAAI,SAAOC,EAASC,GAAQ,OAAAC,UAAAN,EAAA,KAAA,EAAA,KAAA,EAAA,W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AA,EACPC,OAAQ,oB,CACR,CAAC,EAEF,CAAA,E,CAIS,MAAA,CAAA,EAAM1B,kBAAA8C,MAAMC,QAAQ,CAACoB,OAAQ,CAAA,EAAMF,SAAUtC,EAAKsC,QAAQ,CAAC,G,cAAlEhB,EAAOC,EAAAC,KAAA,GAEP,CAAA,EAAA,GACI,CAAA,EAAMnD,kBAAA8C,MAAMC,QAAQ,CAACoB,OAAQ,CAAA,EAAMf,MAAOzB,EAAKsC,QAAQ,CAAC,G,OAA/DhB,EAAOC,EAAAC,KAAA,E,iBAGJF,GACHvC,EAAW6B,iBAAgB,EAAGsF,WAAWC,KAAKpH,EAAW6B,iBAAgB,EAAI,oBAAqBU,EAAKM,GAAG,EAG3GrC,EAASI,KAAKC,KAAKC,UAAU,CAC5BC,MAAO,CAAA,EACPC,OAAQ,E,CACR,CAAC,E,gCAEH,CACF,CAjtBAqG,QAAAtH,gBAAAA","file":"auth.js","sourcesContent":["import { Users } from '../collections/user.collection';\nimport * as jwt from 'jsonwebtoken';\nimport * as handlebars from 'handlebars';\nimport { ResolveIOServer } from '../resolveio-server-app';\nimport { UserModel } from '../models/user.model';\nimport SimpleSchema from 'simpl-schema';\nimport * as bodyParser from 'body-parser';\nimport jwt_decode from 'jwt-decode';\nimport { objectIdHexString } from '../util/common';\n\nexport function setupAuthRoutes(mainServer, 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\tResolveIOServer.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\tResolveIOServer.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\tUsers.updateOne({_id: user._id}, {$set: {services: user.services}}).then(resUp => {\n\t\t\t\t\t\tmainServer.getMethodManager().readFile('email-templates/forgot-password.html').then(html => {\n\t\t\t\t\t\t\tlet template = handlebars.compile(html);\n\t\t\t\t\t\t\thandlebars.registerHelper('equals', (a, b) => {\n\t\t\t\t\t\t\t\treturn a === b;\n\t\t\t\t\t\t\t});\n\t\t\n\t\t\t\t\t\t\tmainServer.getMethodManager().sendEmail(user.email, 'ResolveIO (' + ResolveIOServer.getClientName() + ') - Forgot Password', '', template(emailData), null, null, '');\n\t\t\t\t\t\t}, errEmail => console.log(errEmail));\n\t\t\t\t\t}, errUp => {});\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\tUsers.updateOne({_id: user._id}, {$set: {services: user.services}}).then(resUp => {\n\t\t\t\t\t\tmainServer.getMethodManager().readFile('email-templates/forgot-password.html').then(html => {\n\t\t\t\t\t\t\tlet template = handlebars.compile(html);\n\t\t\t\t\t\t\thandlebars.registerHelper('equals', (a, b) => {\n\t\t\t\t\t\t\t\treturn a === b;\n\t\t\t\t\t\t\t});\n\t\t\n\t\t\t\t\t\t\tmainServer.getMethodManager().sendEmail(user.email, 'ResolveIO (' + ResolveIOServer.getClientName() + ') - Forgot Password', '', template(emailData), null, null, '');\n\t\t\t\t\t\t}, errEmail => console.log(errEmail));\n\t\t\t\t\t}, err => {});\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 function (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\tResolveIOServer.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'], (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\tUsers.findById(decoded['id_user']).then(async (user: UserModel) => {\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}, error => {\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(), function (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\tResolveIOServer.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'], (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\tUsers.findOne({\n\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t{_id: decoded['id_user']},\n\t\t\t\t\t\t\t{'services.enrollment': body.enrollmentToken}\n\t\t\t\t\t\t]\n\t\t\t\t\t}, {projection: {_id: 1, __v: 1, username: 1, active: 1}}).then((user) => {\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}, error => {\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(), function (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\tResolveIOServer.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\tUsers.findOne({\n\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t{_id: decoded['id_user']},\n\t\t\t\t\t\t\t{'services.enrollment': body.enrollmentToken}\n\t\t\t\t\t\t]\n\t\t\t\t\t}).then(async (user: UserModel) => {\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}, error => {\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(), function (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\tResolveIOServer.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'], (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\tUsers.findOne({\n\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t{_id: decoded['id_user']},\n\t\t\t\t\t\t\t{'services.forgot_password': body.forgotPasswordToken}\n\t\t\t\t\t\t]\n\t\t\t\t\t}, {projection: {_id: 1, __v: 1, username: 1, active: 1}}).then((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\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}, error => {\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(), function (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\tResolveIOServer.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\tUsers.findOne({\n\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t{_id: decoded['id_user']},\n\t\t\t\t\t\t\t{'services.forgot_password': body.forgotPasswordToken}\n\t\t\t\t\t\t]\n\t\t\t\t\t}).then(async (user: UserModel) => {\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}, error => {\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\tResolveIOServer.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}"]}
@@ -1,4 +1,4 @@
1
- export type LocalLogType = 'monitor-mongo' | 'monitor-memory' | 'monitor-cpu' | 'log' | 'log-method-latency' | 'log-subscription';
1
+ export type LocalLogType = 'monitor-mongo' | 'monitor-memory' | 'monitor-cpu' | 'monitor-function' | 'log';
2
2
  export interface LocalLogModel {
3
3
  type: LocalLogType;
4
4
  data: any;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/managers/local-log.manager.ts"],"names":["fs","require","resolveio_server_app_1","LocalLogManager","ResolveIOServer","getServerConfig","existsSync","mkdirSync","this","_logFilePath","prototype","writeLog","logEntry","line","JSON","stringify","appendFileSync","encoding","err","console","error","Date","writeLogs","items","length","lines","map","item","join","offloadLogs","result","fileData","readFileSync","trim","split","filter","l","writeFileSync","exports"],"mappings":"mGAGA,IAAAA,GAAAC,QAAA,IAAA,EACAC,uBAAAD,QAAA,yBAAA,EAcAE,gBAAA,WAGC,SAAAA,kBAEoD,0BAAlDD,uBAAAE,gBAAgBC,gBAAe,EAAa,UACS,0BAAlDH,uBAAAE,gBAAgBC,gBAAe,EAAa,UAE1CL,GAAGM,WAAW,6BAA6B,GAC/CN,GAAGO,UAAU,6BAA6B,EAI5CC,KAAKC,aAAe,8CACrB,CAwDD,OArDQN,gBAAAO,UAAAC,SAAP,SAAgBC,GACf,IACC,IAAIC,EAAOC,KAAKC,UAAUH,CAAQ,EAAI,KACtCZ,GAAGgB,eAAeR,KAAKC,aAAcI,EAAM,CAAEI,SAAU,MAAM,CAAE,C,CAEhE,MAAMC,GAELC,QAAQC,MAAM,IAAIC,KAAQ,kBAAmB,+BAAgCH,CAAG,C,CAElF,EAEOf,gBAAAO,UAAAY,UAAP,SAAiBC,GAChB,GAAKA,GAA0B,IAAjBA,EAAMC,OAIpB,IAEC,IAAIC,EAAQF,EAAMG,IAAI,SAAAC,GAAQ,OAAAb,KAAKC,UAAUY,CAAI,CAAnB,CAAoB,EAAEC,KAAK,IAAI,EAAI,KACjE5B,GAAGgB,eAAeR,KAAKC,aAAcgB,EAAO,CAAER,SAAU,MAAM,CAAE,C,CAEjE,MAAOC,GACNC,QAAQC,MAAM,IAAIC,KAAQ,kBAAmB,8BAA+BH,CAAG,C,CAEjF,EAKOf,gBAAAO,UAAAmB,YAAP,WACC,IAAIC,EAAS,GAEb,IACC,GAAI,CAAC9B,GAAGM,WAAWE,KAAKC,YAAY,EACnC,OAAOqB,EAGR,IAAIC,EAAW/B,GAAGgC,aAAaxB,KAAKC,aAAc,MAAM,EACxD,GAA+B,IAA3BsB,EAASE,KAAI,EAAGT,OACnB,OAAOM,EAGRA,EAASC,EAASG,MAAM,IAAI,EAAEC,OAAO,SAAAC,GAAK,MAAa,KAAbA,EAAEH,KAAI,CAAN,CAAe,EAGzDjC,GAAGqC,cAAc7B,KAAKC,aAAc,EAAE,C,CAEvC,MAAMS,GACLC,QAAQC,MAAM,IAAIC,KAAQ,kBAAmB,0BAA2BH,CAAG,C,CAG5E,OAAOY,CACR,EACD3B,eAAA,EAAC,EAtEYmC,QAAAnC,gBAAAA","file":"local-log.manager.js","sourcesContent":["/***************\nlocal-logs.manager.ts\n****************/\nimport * as fs from 'fs';\nimport { ResolveIOServer } from '../resolveio-server-app';\n\nexport type LocalLogType = 'monitor-mongo' \n\t| 'monitor-memory'\n\t| 'monitor-cpu'\n\t| 'log'\n\t| 'log-method-latency'\n\t| 'log-subscription';\n\nexport interface LocalLogModel {\n\ttype: LocalLogType;\n\tdata: any;\n}\n\nexport class LocalLogManager {\n\tprivate _logFilePath: string;\n\n\tconstructor() {\n\t\tif (\n\t\t\tResolveIOServer.getServerConfig()['ROOT_URL'] !== 'https://resolveio.com'\n\t\t\t&& ResolveIOServer.getServerConfig()['ROOT_URL'] !== 'http://localhost:4200'\n\t\t) {\n\t\t\tif (!fs.existsSync('/home/ubuntu/resolveio/logs')) {\n\t\t\t\tfs.mkdirSync('/home/ubuntu/resolveio/logs');\n\t\t\t}\n\t\t}\n\t\t\n\t\tthis._logFilePath = '/home/ubuntu/resolveio/logs/local-logs.jsonl';\n\t}\n\n\t// Internal method to append a JSON line to the file\n\tpublic writeLog(logEntry: LocalLogModel): void {\n\t\ttry {\n\t\t\tlet line = JSON.stringify(logEntry) + '\\n';\n\t\t\tfs.appendFileSync(this._logFilePath, line, { encoding: 'utf8' });\n\t\t}\n\t\tcatch(err) {\n\t\t\t// If there's an error writing logs, you might want to handle it or queue it\n\t\t\tconsole.error(new Date(), 'LocalLogManager', 'Failed to write log to file:', err);\n\t\t}\n\t}\n\n\tpublic writeLogs(items: LocalLogModel[]): void {\n\t\tif (!items || items.length === 0) {\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\t// Convert each item to a JSON string, add newline\n\t\t\tlet lines = items.map(item => JSON.stringify(item)).join('\\n') + '\\n';\n\t\t\tfs.appendFileSync(this._logFilePath, lines, { encoding: 'utf8' });\n\t\t}\n\t\tcatch (err) {\n\t\t\tconsole.error(new Date(), 'LocalLogManager', 'Failed to write logs batch:', err);\n\t\t}\n\t}\n\n\t/**\n\t * Reads all logs from disk, then empties the file.\n\t */\n\tpublic offloadLogs(): any[] {\n\t\tlet result = [];\n\n\t\ttry {\n\t\t\tif (!fs.existsSync(this._logFilePath)) {\n\t\t\t\treturn result;\n\t\t\t}\n\n\t\t\tlet fileData = fs.readFileSync(this._logFilePath, 'utf8');\n\t\t\tif (fileData.trim().length === 0) {\n\t\t\t\treturn result;\n\t\t\t}\n\n\t\t\tresult = fileData.split('\\n').filter(l => l.trim() !== '');\n\n\t\t\t// Truncate the file so we don't send logs more than once\n\t\t\tfs.writeFileSync(this._logFilePath, '');\n\t\t}\n\t\tcatch(err) {\n\t\t\tconsole.error(new Date(), 'LocalLogManager', 'Failed to offload logs:', err);\n\t\t}\n\n\t\treturn result;\n\t}\n}"]}
1
+ {"version":3,"sources":["../../src/managers/local-log.manager.ts"],"names":["fs","require","resolveio_server_app_1","LocalLogManager","ResolveIOServer","getServerConfig","existsSync","mkdirSync","this","_logFilePath","prototype","writeLog","logEntry","line","JSON","stringify","appendFileSync","encoding","err","console","error","Date","writeLogs","items","length","lines","map","item","join","offloadLogs","result","fileData","readFileSync","trim","split","filter","l","writeFileSync","exports"],"mappings":"mGAGA,IAAAA,GAAAC,QAAA,IAAA,EACAC,uBAAAD,QAAA,yBAAA,EAaAE,gBAAA,WAGC,SAAAA,kBAEoD,0BAAlDD,uBAAAE,gBAAgBC,g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EAtEYmC,QAAAnC,gBAAAA","file":"local-log.manager.js","sourcesContent":["/***************\nlocal-logs.manager.ts\n****************/\nimport * as fs from 'fs';\nimport { ResolveIOServer } from '../resolveio-server-app';\n\nexport type LocalLogType = 'monitor-mongo' \n\t| 'monitor-memory'\n\t| 'monitor-cpu'\n\t| 'monitor-function'\n\t| 'log'\n\nexport interface LocalLogModel {\n\ttype: LocalLogType;\n\tdata: any;\n}\n\nexport class LocalLogManager {\n\tprivate _logFilePath: string;\n\n\tconstructor() {\n\t\tif (\n\t\t\tResolveIOServer.getServerConfig()['ROOT_URL'] !== 'https://resolveio.com'\n\t\t\t&& ResolveIOServer.getServerConfig()['ROOT_URL'] !== 'http://localhost:4200'\n\t\t) {\n\t\t\tif (!fs.existsSync('/home/ubuntu/resolveio/logs')) {\n\t\t\t\tfs.mkdirSync('/home/ubuntu/resolveio/logs');\n\t\t\t}\n\t\t}\n\t\t\n\t\tthis._logFilePath = '/home/ubuntu/resolveio/logs/local-logs.jsonl';\n\t}\n\n\t// Internal method to append a JSON line to the file\n\tpublic writeLog(logEntry: LocalLogModel): void {\n\t\ttry {\n\t\t\tlet line = JSON.stringify(logEntry) + '\\n';\n\t\t\tfs.appendFileSync(this._logFilePath, line, { encoding: 'utf8' });\n\t\t}\n\t\tcatch(err) {\n\t\t\t// If there's an error writing logs, you might want to handle it or queue it\n\t\t\tconsole.error(new Date(), 'LocalLogManager', 'Failed to write log to file:', err);\n\t\t}\n\t}\n\n\tpublic writeLogs(items: LocalLogModel[]): void {\n\t\tif (!items || items.length === 0) {\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\t// Convert each item to a JSON string, add newline\n\t\t\tlet lines = items.map(item => JSON.stringify(item)).join('\\n') + '\\n';\n\t\t\tfs.appendFileSync(this._logFilePath, lines, { encoding: 'utf8' });\n\t\t}\n\t\tcatch (err) {\n\t\t\tconsole.error(new Date(), 'LocalLogManager', 'Failed to write logs batch:', err);\n\t\t}\n\t}\n\n\t/**\n\t * Reads all logs from disk, then empties the file.\n\t */\n\tpublic offloadLogs(): any[] {\n\t\tlet result = [];\n\n\t\ttry {\n\t\t\tif (!fs.existsSync(this._logFilePath)) {\n\t\t\t\treturn result;\n\t\t\t}\n\n\t\t\tlet fileData = fs.readFileSync(this._logFilePath, 'utf8');\n\t\t\tif (fileData.trim().length === 0) {\n\t\t\t\treturn result;\n\t\t\t}\n\n\t\t\tresult = fileData.split('\\n').filter(l => l.trim() !== '');\n\n\t\t\t// Truncate the file so we don't send logs more than once\n\t\t\tfs.writeFileSync(this._logFilePath, '');\n\t\t}\n\t\tcatch(err) {\n\t\t\tconsole.error(new Date(), 'LocalLogManager', 'Failed to offload logs:', err);\n\t\t}\n\n\t\treturn result;\n\t}\n}"]}
@@ -1,7 +1,6 @@
1
1
  import { MethodModel } from '../models/method.model';
2
2
  import { MonitorManagerFunction } from './monitor.manager';
3
3
  import { S3 } from '@aws-sdk/client-s3';
4
- import * as WebSocket from 'ws';
5
4
  export declare class AWS {
6
5
  private _s3;
7
6
  private _s3USEast1;
@@ -19,7 +18,7 @@ export declare class MethodManager {
19
18
  private _isWorkerInstance;
20
19
  private emailQueue;
21
20
  private isEmailProcessing;
22
- private _debugCallMethodInternalHits;
21
+ private _debugcallMethodHits;
23
22
  private _debugCallMethodHits;
24
23
  private _debugCallMethodCronJobHits;
25
24
  private _debugSendQueueHits;
@@ -28,8 +27,7 @@ export declare class MethodManager {
28
27
  constructor(monitorManagerFunction: MonitorManagerFunction, isWorkersEnabled: any, isWorkerInstance: any);
29
28
  methods(method: MethodModel): void;
30
29
  callMethodCron(method: string, ...methodData: any[]): any;
31
- callMethod(id_methodLatency: string, ws: WebSocket, messageDate: Date, messageId: number, method: string, ...methodData: any[]): void;
32
- callMethodInternal(method: string, ...methodData: any[]): Promise<any>;
30
+ callMethod(method: string, ...methodData: any[]): Promise<any>;
33
31
  private sendWS;
34
32
  setupEmailWatcher(): Promise<void>;
35
33
  loadPendingEmails(): Promise<void>;