@resolveio/server-lib 9.7.12 → 9.7.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/managers/mongo.manager.js.map +1 -1
- package/managers/subscription.manager.d.ts +1 -1
- package/managers/subscription.manager.js +119 -124
- package/managers/subscription.manager.js.map +1 -1
- package/methods/accounts.js +13 -25
- package/methods/accounts.js.map +1 -1
- package/package.json +1 -1
- package/server-app.js +224 -213
- package/server-app.js.map +1 -1
package/methods/accounts.js
CHANGED
|
@@ -55,33 +55,21 @@ function loadAccountMethods(methodManager) {
|
|
|
55
55
|
function: function (version) {
|
|
56
56
|
var _this = this;
|
|
57
57
|
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
58
|
-
var user;
|
|
59
58
|
var _this = this;
|
|
60
59
|
return __generator(this, function (_a) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}, function (err) {
|
|
75
|
-
index_1.ResolveIOServer.getMainServer().getSubscriptionManager().unsubscribeAll(_this._mainServer.getWS(_this.id_ws));
|
|
76
|
-
resolve(false);
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
80
|
-
index_1.ResolveIOServer.getMainServer().getSubscriptionManager().unsubscribeAll(this._mainServer.getWS(this.id_ws));
|
|
81
|
-
resolve(false);
|
|
82
|
-
}
|
|
83
|
-
return [2 /*return*/];
|
|
84
|
-
}
|
|
60
|
+
logged_in_users_collection_1.LoggedInUsers.updateOne({ id_ws: this.id_ws }, { $set: { app_version: version } }).then(function (res) {
|
|
61
|
+
if (res) {
|
|
62
|
+
resolve(true);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
index_1.ResolveIOServer.getMainServer().getSubscriptionManager().unsubscribeAll(_this._mainServer.getWS(_this.id_ws));
|
|
66
|
+
resolve(false);
|
|
67
|
+
}
|
|
68
|
+
}, function (err) {
|
|
69
|
+
index_1.ResolveIOServer.getMainServer().getSubscriptionManager().unsubscribeAll(_this._mainServer.getWS(_this.id_ws));
|
|
70
|
+
resolve(false);
|
|
71
|
+
});
|
|
72
|
+
return [2 /*return*/];
|
|
85
73
|
});
|
|
86
74
|
}); });
|
|
87
75
|
}
|
package/methods/accounts.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/methods/accounts.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAwC;AACxC,kEAAuD;AACvD,uCAAyC;AACzC,kCAAoC;AACpC,wFAA0E;AAE1E,kCAA2C;AAE3C,2DAA8D;AAE9D,SAAgB,kBAAkB,CAAC,aAA4B;IAC9D,aAAa,CAAC,OAAO,CAAC;QACrB,eAAe,EAAE;YAChB,KAAK,EAAE,IAAI,sBAAY,CAAC;gBACvB,OAAO,EAAE;oBACR,IAAI,EAAE,MAAM;iBACZ;aACD,CAAC;YACF,QAAQ,EAAE,UAAS,OAAO;gBAAhB,iBAuBT;gBAtBA,OAAO,IAAI,OAAO,CAAC,UAAO,OAAO,EAAE,MAAM;;;;;oCAC7B,qBAAM,uBAAe,CAAC,aAAa,EAAE,CAAC,sBAAsB,EAAE,CAAC,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAA;;gCAApG,IAAI,GAAG,SAA6F;gCAExG,IAAI,IAAI,EAAE;oCACT,0CAAa,CAAC,SAAS,CAAC,EAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAC,EAAE,EAAC,IAAI,EAAE,EAAC,WAAW,EAAE,OAAO,EAAC,EAAC,CAAC,CAAC,IAAI,CAAC,UAAA,GAAG;wCACpF,IAAI,GAAG,EAAE;4CACR,OAAO,CAAC,IAAI,CAAC,CAAC;yCACd;6CACI;4CACJ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,CAAC;;;gCAGd,MAAM,CAAC,cAAc,CAAC,CAAC;;;;;qBAExB,CAAC,CAAC;YACJ,CAAC;SACD;KACD,CAAC,CAAC;AACJ,CAAC;AA/LD,gDA+LC","file":"accounts.js","sourcesContent":["import SimpleSchema from 'simpl-schema';\nimport { Users } from '../collections/user.collection';\nimport * as handlebars from 'handlebars';\nimport * as jwt from 'jsonwebtoken';\nimport { LoggedInUsers } from '../collections/logged-in-users.collection';\nimport { MethodManager } from '../managers/method.manager';\nimport { ResolveIOServer } from '../index';\nimport { UserModel } from '../models/user.model';\nimport { objectIdHexString } from '../managers/mongo.manager';\n\nexport function loadAccountMethods(methodManager: MethodManager) {\n\tmethodManager.methods({\n\t\tsetWSAppVersion: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tversion: {\n\t\t\t\t\ttype: Number\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: function(version) {\n\t\t\t\treturn new Promise(async (resolve, reject) => {\n\t\t\t\t\tlet user = await ResolveIOServer.getMainServer().getSubscriptionManager().ensureLoggedInUser(this.id_ws);\n\n\t\t\t\t\tif (user) {\n\t\t\t\t\t\tLoggedInUsers.updateOne({id_ws: this.id_ws}, {$set: {app_version: version}}).then(res => {\n\t\t\t\t\t\t\tif (res) {\n\t\t\t\t\t\t\t\tresolve(true);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tResolveIOServer.getMainServer().getSubscriptionManager().unsubscribeAll(this._mainServer.getWS(this.id_ws));\n\t\t\t\t\t\t\t\tresolve(false);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}, err => {\n\t\t\t\t\t\t\tResolveIOServer.getMainServer().getSubscriptionManager().unsubscribeAll(this._mainServer.getWS(this.id_ws));\n\t\t\t\t\t\t\tresolve(false);\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tResolveIOServer.getMainServer().getSubscriptionManager().unsubscribeAll(this._mainServer.getWS(this.id_ws));\n\t\t\t\t\t\tresolve(false);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t\treloadWS: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tid_ws: String\n\t\t\t}),\n\t\t\tfunction: function(id_ws) {\n\t\t\t\treturn new Promise(async (resolve, reject) => {\n\t\t\t\t\tlet ws = ResolveIOServer.getMainServer().getWS(id_ws);\n\n\t\t\t\t\tif (ws) {\n\t\t\t\t\t\tResolveIOServer.getMainServer().unsubscribeWS(ws);\n\t\t\t\t\t\tresolve(true);\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\treject('No WS');\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t\treconnectWS: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tid_ws: String\n\t\t\t}),\n\t\t\tfunction: function(id_ws) {\n\t\t\t\treturn new Promise(async (resolve, reject) => {\n\t\t\t\t\tlet ws = ResolveIOServer.getMainServer().getWS(id_ws);\n\n\t\t\t\t\tif (ws) {\n\t\t\t\t\t\tResolveIOServer.getMainServer().unsubscribeWS(ws);\n\t\t\t\t\t\tresolve(true);\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\treject('No WS');\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t\tdisconnectWS: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tid_ws: String\n\t\t\t}),\n\t\t\tfunction: function(id_ws) {\n\t\t\t\treturn new Promise(async (resolve, reject) => {\n\t\t\t\t\tlet ws = ResolveIOServer.getMainServer().getWS(id_ws);\n\n\t\t\t\t\tif (ws) {\n\t\t\t\t\t\tResolveIOServer.getMainServer().unsubscribeWS(ws);\n\t\t\t\t\t\tresolve(true);\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\treject('No WS');\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t\tcreateUserAndEmailEnrollment: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tnewUser: {\n\t\t\t\t\ttype: Users['simplschema']\n\t\t\t\t},\n\t\t\t\tsendEnrollmentEmail: {\n\t\t\t\t\ttype: Boolean,\n\t\t\t\t\toptional: true\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: function(newUser: UserModel, sendEnrollmentEmail = true) {\n\t\t\t\treturn new Promise(async (resolve, reject) => {\n\t\t\t\t\tnewUser._id = objectIdHexString();\n\n\t\t\t\t\tnewUser.services = {\n\t\t\t\t\t\tenrollment: jwt.sign({id_user: newUser._id}, this.serverConfig['JWT_SECRET'], {\n\t\t\t\t\t\t\texpiresIn : 3 * 24 * 60 * 60 * 1000 // 3 days\n\t\t\t\t\t\t})\n\t\t\t\t\t};\n\t\t\t\t\t\n\t\t\t\t\tawait Users.insertOne(newUser);\n\n\t\t\t\t\tif (sendEnrollmentEmail) {\n\t\t\t\t\t\tlet emailData = {\n\t\t\t\t\t\t\tfullname: newUser.fullname,\n\t\t\t\t\t\t\tuser: this.user,\n\t\t\t\t\t\t\turl: this.serverConfig['ROOT_URL'] + '/enroll-account?' + encodeURIComponent(this.serverConfig['SERVER_URL']) + '&' + newUser.services['enrollment']\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tthis.readFile('email-templates/enrollment.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\tthis.sendEmail(newUser.email, 'ResolveIO (' + ResolveIOServer.getClientName() + ') - Enrollment Email', '', template(emailData));\n\t\t\n\t\t\t\t\t\t\tresolve(newUser);\n\t\t\t\t\t\t}, errEmail => reject(errEmail));\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t\tresetUserPassword: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tuserId: {\n\t\t\t\t\ttype: String\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: function(userId: string) {\n\t\t\t\treturn new Promise(async (resolve, reject) => {\t\t\t\t\n\t\t\t\t\tlet user = await Users.findOne({_id: userId});\n\t\t\n\t\t\t\t\tif (user) {\n\n\t\t\t\t\t\tuser.services['forgot_password'] = jwt.sign({id_user: userId}, this.serverConfig['JWT_SECRET']);\n\n\t\t\t\t\t\tlet emailData = {\n\t\t\t\t\t\t\tuserToChangePassword: user.fullname,\n\t\t\t\t\t\t\tuserWhoResetPassword: this.user,\n\t\t\t\t\t\t\turl: this.serverConfig['ROOT_URL'] + '/forgot-password?' + encodeURIComponent(this.serverConfig['SERVER_URL']) + '&' + user.services['forgot_password']\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tUsers.updateOne({_id: user._id}, {$set: {services: user.services, attempts: 0}}).then(() => {\n\t\t\t\t\t\t\tthis.readFile('email-templates/forgot-password.html').then(html => {\n\t\t\t\t\t\t\t\tlet template = handlebars.compile(html);\n\t\t\t\t\t\t\t\thandlebars.registerHelper('equals', (a, b) => {\n\t\t\t\t\t\t\t\t\treturn a === b;\n\t\t\t\t\t\t\t\t});\n\t\t\t\n\t\t\t\t\t\t\t\tthis.sendEmail(user.email, 'ResolveIO (' + ResolveIOServer.getClientName() + ') - Forgot Password', '', template(emailData));\n\t\t\t\n\t\t\t\t\t\t\t\tresolve(true);\n\t\t\t\t\t\t\t}, errEmail => reject(errEmail));\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\tsetUserPassword: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tuserId: {\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\t\tfunction: function(userId: string, password: string) {\n\t\t\t\treturn new Promise(async (resolve, reject) => {\t\t\t\t\n\t\t\t\t\tlet user = await Users.findOne({_id: userId});\n\t\t\n\t\t\t\t\tif (user && !user.roles.super_admin) {\n\t\t\t\t\t\tawait Users.setPassword(user, password);\n\n\t\t\t\t\t\tresolve(true);\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\treject('Invalid User');\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t});\n}"]}
|
|
1
|
+
{"version":3,"sources":["../../src/methods/accounts.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAwC;AACxC,kEAAuD;AACvD,uCAAyC;AACzC,kCAAoC;AACpC,wFAA0E;AAE1E,kCAA2C;AAE3C,2DAA8D;AAE9D,SAAgB,kBAAkB,CAAC,aAA4B;IAC9D,aAAa,CAAC,OAAO,CAAC;QACrB,eAAe,EAAE;YAChB,KAAK,EAAE,IAAI,sBAAY,CAAC;gBACvB,OAAO,EAAE;oBACR,IAAI,EAAE,MAAM;iBACZ;aACD,CAAC;YACF,QAAQ,EAAE,UAAS,OAAO;gBAAhB,iBAeT;gBAdA,OAAO,IAAI,OAAO,CAAC,UAAO,OAAO,EAAE,MAAM;;;wBACxC,0CAAa,CAAC,SAAS,CAAC,EAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAC,EAAE,EAAC,IAAI,EAAE,EAAC,WAAW,EAAE,OAAO,EAAC,EAAC,CAAC,CAAC,IAAI,CAAC,UAAA,GAAG;4BACpF,IAAI,GAAG,EAAE;gCACR,OAAO,CAAC,IAAI,CAAC,CAAC;6BACd;iCACI;gCACJ,uBAAe,CAAC,aAAa,EAAE,CAAC,sBAAsB,EAAE,CAAC,cAAc,CAAC,KAAI,CAAC,WAAW,CAAC,KAAK,CAAC,KAAI,CAAC,KAAK,CAAC,CAAC,CAAC;gCAC5G,OAAO,CAAC,KAAK,CAAC,CAAC;6BACf;wBACF,CAAC,EAAE,UAAA,GAAG;4BACL,uBAAe,CAAC,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,CAAC,CAAC;wCACf,CAAC,EAAE,UAAA,QAAQ,IAAI,OAAA,MAAM,CAAC,QAAQ,CAAC,EAAhB,CAAgB,CAAC,CAAC;oCAClC,CAAC,EAAE,cAAO,CAAC,CAAC,CAAC;iCACb;;;;qBACD,CAAC,CAAC;YACJ,CAAC;SACD;QACD,eAAe,EAAE;YAChB,KAAK,EAAE,IAAI,sBAAY,CAAC;gBACvB,MAAM,EAAE;oBACP,IAAI,EAAE,MAAM;iBACZ;gBACD,QAAQ,EAAE;oBACT,IAAI,EAAE,MAAM;iBACZ;aACD,CAAC;YACF,QAAQ,EAAE,UAAS,MAAc,EAAE,QAAgB;gBAAzC,iBAaT;gBAZA,OAAO,IAAI,OAAO,CAAC,UAAO,OAAO,EAAE,MAAM;;;;oCAC7B,qBAAM,uBAAK,CAAC,OAAO,CAAC,EAAC,GAAG,EAAE,MAAM,EAAC,CAAC,EAAA;;gCAAzC,IAAI,GAAG,SAAkC;qCAEzC,CAAA,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,CAAA,EAA/B,wBAA+B;gCAClC,qBAAM,uBAAK,CAAC,WAAW,CAAC,IAAI,EAAE,QAAQ,CAAC,EAAA;;gCAAvC,SAAuC,CAAC;gCAExC,OAAO,CAAC,IAAI,CAAC,CAAC;;;gCAGd,MAAM,CAAC,cAAc,CAAC,CAAC;;;;;qBAExB,CAAC,CAAC;YACJ,CAAC;SACD;KACD,CAAC,CAAC;AACJ,CAAC;AAvLD,gDAuLC","file":"accounts.js","sourcesContent":["import SimpleSchema from 'simpl-schema';\nimport { Users } from '../collections/user.collection';\nimport * as handlebars from 'handlebars';\nimport * as jwt from 'jsonwebtoken';\nimport { LoggedInUsers } from '../collections/logged-in-users.collection';\nimport { MethodManager } from '../managers/method.manager';\nimport { ResolveIOServer } from '../index';\nimport { UserModel } from '../models/user.model';\nimport { objectIdHexString } from '../managers/mongo.manager';\n\nexport function loadAccountMethods(methodManager: MethodManager) {\n\tmethodManager.methods({\n\t\tsetWSAppVersion: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tversion: {\n\t\t\t\t\ttype: Number\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: function(version) {\n\t\t\t\treturn new Promise(async (resolve, reject) => {\n\t\t\t\t\tLoggedInUsers.updateOne({id_ws: this.id_ws}, {$set: {app_version: version}}).then(res => {\n\t\t\t\t\t\tif (res) {\n\t\t\t\t\t\t\tresolve(true);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tResolveIOServer.getMainServer().getSubscriptionManager().unsubscribeAll(this._mainServer.getWS(this.id_ws));\n\t\t\t\t\t\t\tresolve(false);\n\t\t\t\t\t\t}\n\t\t\t\t\t}, err => {\n\t\t\t\t\t\tResolveIOServer.getMainServer().getSubscriptionManager().unsubscribeAll(this._mainServer.getWS(this.id_ws));\n\t\t\t\t\t\tresolve(false);\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t\treloadWS: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tid_ws: String\n\t\t\t}),\n\t\t\tfunction: function(id_ws) {\n\t\t\t\treturn new Promise(async (resolve, reject) => {\n\t\t\t\t\tlet ws = ResolveIOServer.getMainServer().getWS(id_ws);\n\n\t\t\t\t\tif (ws) {\n\t\t\t\t\t\tResolveIOServer.getMainServer().unsubscribeWS(ws);\n\t\t\t\t\t\tresolve(true);\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\treject('No WS');\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t\treconnectWS: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tid_ws: String\n\t\t\t}),\n\t\t\tfunction: function(id_ws) {\n\t\t\t\treturn new Promise(async (resolve, reject) => {\n\t\t\t\t\tlet ws = ResolveIOServer.getMainServer().getWS(id_ws);\n\n\t\t\t\t\tif (ws) {\n\t\t\t\t\t\tResolveIOServer.getMainServer().unsubscribeWS(ws);\n\t\t\t\t\t\tresolve(true);\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\treject('No WS');\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t\tdisconnectWS: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tid_ws: String\n\t\t\t}),\n\t\t\tfunction: function(id_ws) {\n\t\t\t\treturn new Promise(async (resolve, reject) => {\n\t\t\t\t\tlet ws = ResolveIOServer.getMainServer().getWS(id_ws);\n\n\t\t\t\t\tif (ws) {\n\t\t\t\t\t\tResolveIOServer.getMainServer().unsubscribeWS(ws);\n\t\t\t\t\t\tresolve(true);\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\treject('No WS');\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t\tcreateUserAndEmailEnrollment: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tnewUser: {\n\t\t\t\t\ttype: Users['simplschema']\n\t\t\t\t},\n\t\t\t\tsendEnrollmentEmail: {\n\t\t\t\t\ttype: Boolean,\n\t\t\t\t\toptional: true\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: function(newUser: UserModel, sendEnrollmentEmail = true) {\n\t\t\t\treturn new Promise(async (resolve, reject) => {\n\t\t\t\t\tnewUser._id = objectIdHexString();\n\n\t\t\t\t\tnewUser.services = {\n\t\t\t\t\t\tenrollment: jwt.sign({id_user: newUser._id}, this.serverConfig['JWT_SECRET'], {\n\t\t\t\t\t\t\texpiresIn : 3 * 24 * 60 * 60 * 1000 // 3 days\n\t\t\t\t\t\t})\n\t\t\t\t\t};\n\t\t\t\t\t\n\t\t\t\t\tawait Users.insertOne(newUser);\n\n\t\t\t\t\tif (sendEnrollmentEmail) {\n\t\t\t\t\t\tlet emailData = {\n\t\t\t\t\t\t\tfullname: newUser.fullname,\n\t\t\t\t\t\t\tuser: this.user,\n\t\t\t\t\t\t\turl: this.serverConfig['ROOT_URL'] + '/enroll-account?' + encodeURIComponent(this.serverConfig['SERVER_URL']) + '&' + newUser.services['enrollment']\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tthis.readFile('email-templates/enrollment.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\tthis.sendEmail(newUser.email, 'ResolveIO (' + ResolveIOServer.getClientName() + ') - Enrollment Email', '', template(emailData));\n\t\t\n\t\t\t\t\t\t\tresolve(newUser);\n\t\t\t\t\t\t}, errEmail => reject(errEmail));\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t\tresetUserPassword: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tuserId: {\n\t\t\t\t\ttype: String\n\t\t\t\t}\n\t\t\t}),\n\t\t\tfunction: function(userId: string) {\n\t\t\t\treturn new Promise(async (resolve, reject) => {\t\t\t\t\n\t\t\t\t\tlet user = await Users.findOne({_id: userId});\n\t\t\n\t\t\t\t\tif (user) {\n\n\t\t\t\t\t\tuser.services['forgot_password'] = jwt.sign({id_user: userId}, this.serverConfig['JWT_SECRET']);\n\n\t\t\t\t\t\tlet emailData = {\n\t\t\t\t\t\t\tuserToChangePassword: user.fullname,\n\t\t\t\t\t\t\tuserWhoResetPassword: this.user,\n\t\t\t\t\t\t\turl: this.serverConfig['ROOT_URL'] + '/forgot-password?' + encodeURIComponent(this.serverConfig['SERVER_URL']) + '&' + user.services['forgot_password']\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tUsers.updateOne({_id: user._id}, {$set: {services: user.services, attempts: 0}}).then(() => {\n\t\t\t\t\t\t\tthis.readFile('email-templates/forgot-password.html').then(html => {\n\t\t\t\t\t\t\t\tlet template = handlebars.compile(html);\n\t\t\t\t\t\t\t\thandlebars.registerHelper('equals', (a, b) => {\n\t\t\t\t\t\t\t\t\treturn a === b;\n\t\t\t\t\t\t\t\t});\n\t\t\t\n\t\t\t\t\t\t\t\tthis.sendEmail(user.email, 'ResolveIO (' + ResolveIOServer.getClientName() + ') - Forgot Password', '', template(emailData));\n\t\t\t\n\t\t\t\t\t\t\t\tresolve(true);\n\t\t\t\t\t\t\t}, errEmail => reject(errEmail));\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\tsetUserPassword: {\n\t\t\tcheck: new SimpleSchema({\n\t\t\t\tuserId: {\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\t\tfunction: function(userId: string, password: string) {\n\t\t\t\treturn new Promise(async (resolve, reject) => {\t\t\t\t\n\t\t\t\t\tlet user = await Users.findOne({_id: userId});\n\t\t\n\t\t\t\t\tif (user && !user.roles.super_admin) {\n\t\t\t\t\t\tawait Users.setPassword(user, password);\n\n\t\t\t\t\t\tresolve(true);\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\treject('Invalid User');\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t});\n}"]}
|
package/package.json
CHANGED
package/server-app.js
CHANGED
|
@@ -359,224 +359,235 @@ var ResolveIOMainServer = /** @class */ (function () {
|
|
|
359
359
|
console.log('Running server on port %s', _this._port);
|
|
360
360
|
});
|
|
361
361
|
// On websocket connection (already verified)
|
|
362
|
-
this._wss.on('connection', function (ws, req) {
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
this._methodManager.sendEmail('dev@resolveio.com', 'SERVER - JSON Parse Error - ' + this._serverConfig['CLIENT_NAME'], JSON.stringify([message, e]));
|
|
411
|
-
parseErrorFound = true;
|
|
412
|
-
}
|
|
413
|
-
if (!!parseErrorFound) return [3 /*break*/, 8];
|
|
414
|
-
if (socketData[0] === 'ping') {
|
|
415
|
-
if (ws && ws.readyState === ws.OPEN) {
|
|
416
|
-
ws.send('pong', function (error) {
|
|
417
|
-
if (error) {
|
|
418
|
-
console.log('Error on WS: ', error);
|
|
419
|
-
_this.unsubscribeWS(ws);
|
|
362
|
+
this._wss.on('connection', function (ws, req) { return __awaiter(_this, void 0, void 0, function () {
|
|
363
|
+
var idSocket;
|
|
364
|
+
var _this = this;
|
|
365
|
+
return __generator(this, function (_a) {
|
|
366
|
+
switch (_a.label) {
|
|
367
|
+
case 0:
|
|
368
|
+
// Get user from token
|
|
369
|
+
ws['id_user'] = req['id_user'];
|
|
370
|
+
ws['user'] = req['user'];
|
|
371
|
+
ws['user_readonly'] = req['user_readonly'];
|
|
372
|
+
ws['doc_user'] = req['doc_user'];
|
|
373
|
+
idSocket = '';
|
|
374
|
+
while (!idSocket || Array.from(this._wss.clients).some(function (a) { return a['id_socket'] === idSocket; })) {
|
|
375
|
+
idSocket = uuid_1.v4();
|
|
376
|
+
}
|
|
377
|
+
ws['id_socket'] = idSocket;
|
|
378
|
+
ws['retryCnt'] = 0;
|
|
379
|
+
return [4 /*yield*/, this._subscriptionManager.createLoggedInUser(idSocket)];
|
|
380
|
+
case 1:
|
|
381
|
+
_a.sent();
|
|
382
|
+
setTimeout(function () {
|
|
383
|
+
ws['pingTime'] = new Date();
|
|
384
|
+
ws.ping(function () { });
|
|
385
|
+
}, 5000);
|
|
386
|
+
if (this.LOGGER === 'DEBUG') {
|
|
387
|
+
console.log('Connection from: ' + req['user']);
|
|
388
|
+
}
|
|
389
|
+
// Use for keeping connection alive (ping/pong)
|
|
390
|
+
ws['isAlive'] = true;
|
|
391
|
+
ws.on('pong', function () {
|
|
392
|
+
ws['isAlive'] = true;
|
|
393
|
+
ws['pongTime'] = new Date();
|
|
394
|
+
ws['latency'] = moment.duration(moment(ws['pongTime']).diff(ws['pingTime'])).asMilliseconds();
|
|
395
|
+
_this._subscriptionManager.loggedInLatency(ws);
|
|
396
|
+
});
|
|
397
|
+
ws['versionTimer'] = setTimeout(function () {
|
|
398
|
+
_this.unsubscribeWS(ws);
|
|
399
|
+
}, 20000);
|
|
400
|
+
// On data received (message)
|
|
401
|
+
ws.on('message', function (message) { return __awaiter(_this, void 0, void 0, function () {
|
|
402
|
+
var parseErrorFound, socketData, messageRoute_1, messageDate, messageId, type, subType, pub, serverRes, offlineUpdates, i, update, serverResMethod, i, update, data, updateRoute, updateDate, updateMessageId, updateType, method, methodLatencyId, method, serverRes, methodLatencyId;
|
|
403
|
+
var _a, _b, _c, _d;
|
|
404
|
+
var _this = this;
|
|
405
|
+
return __generator(this, function (_e) {
|
|
406
|
+
switch (_e.label) {
|
|
407
|
+
case 0:
|
|
408
|
+
if (this.LOGGER === 'DEBUG') {
|
|
409
|
+
console.log('Message from: ' + ws['user'], message);
|
|
420
410
|
}
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
messageRoute_1 = socketData[0];
|
|
426
|
-
if (this._clientRoutes.some(function (a) { return messageRoute_1.includes(a); }) && !ws['doc_user'].roles.groups.some(function (a) { return a.views.some(function (b) { return messageRoute_1.includes(b); }); }) && !ws['doc_user'].roles.super_admin) {
|
|
427
|
-
return [2 /*return*/];
|
|
428
|
-
}
|
|
429
|
-
messageDate = socketData[1];
|
|
430
|
-
messageId = socketData[2];
|
|
431
|
-
type = socketData[3];
|
|
432
|
-
if (!(type === 'subscription')) return [3 /*break*/, 1];
|
|
433
|
-
subType = socketData[4];
|
|
434
|
-
pub = socketData[5];
|
|
435
|
-
// Subscribe
|
|
436
|
-
if (subType === 'sub') {
|
|
437
|
-
(_a = this._subscriptionManager).subscribe.apply(_a, __spreadArrays([messageDate, ws, messageId, pub], socketData.slice(6)));
|
|
438
|
-
}
|
|
439
|
-
// Unsubscribe
|
|
440
|
-
else {
|
|
441
|
-
(_b = this._subscriptionManager).unsubscribe.apply(_b, __spreadArrays([messageDate, ws, messageId, pub], socketData.slice(6)));
|
|
442
|
-
}
|
|
443
|
-
return [3 /*break*/, 8];
|
|
444
|
-
case 1:
|
|
445
|
-
if (!(type === 'offline')) return [3 /*break*/, 7];
|
|
446
|
-
serverRes = {
|
|
447
|
-
messageId: messageId,
|
|
448
|
-
hasError: false,
|
|
449
|
-
data: 'ACK'
|
|
450
|
-
};
|
|
451
|
-
if (ws && ws.readyState === ws.OPEN) {
|
|
452
|
-
ws.send(JSON.stringify(serverRes), function (error) {
|
|
453
|
-
if (error) {
|
|
454
|
-
console.log('Error on WS: ', error);
|
|
455
|
-
_this.unsubscribeWS(ws);
|
|
456
|
-
}
|
|
457
|
-
});
|
|
458
|
-
}
|
|
459
|
-
offlineUpdates = socketData[4];
|
|
460
|
-
for (i = 0; i < offlineUpdates.length; i++) {
|
|
461
|
-
update = offlineUpdates[i];
|
|
462
|
-
serverResMethod = {
|
|
463
|
-
messageId: update.data[2],
|
|
464
|
-
hasError: false,
|
|
465
|
-
data: 'ACK'
|
|
466
|
-
};
|
|
467
|
-
if (ws && ws.readyState === ws.OPEN) {
|
|
468
|
-
ws.send(JSON.stringify(serverResMethod), function (error) {
|
|
469
|
-
if (error) {
|
|
470
|
-
console.log('Error on WS: ', error);
|
|
471
|
-
_this.unsubscribeWS(ws);
|
|
411
|
+
parseErrorFound = false;
|
|
412
|
+
socketData = [];
|
|
413
|
+
try {
|
|
414
|
+
socketData = JSON.parse(message, common_1.dateReviver);
|
|
472
415
|
}
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
_e.label = 2;
|
|
478
|
-
case 2:
|
|
479
|
-
if (!(i < offlineUpdates.length)) return [3 /*break*/, 6];
|
|
480
|
-
update = offlineUpdates[i];
|
|
481
|
-
data = update.data;
|
|
482
|
-
if (update.oldData) {
|
|
483
|
-
data.push(update.oldData);
|
|
484
|
-
}
|
|
485
|
-
updateRoute = data.shift();
|
|
486
|
-
updateDate = data.shift();
|
|
487
|
-
updateMessageId = data.shift();
|
|
488
|
-
updateType = data.shift();
|
|
489
|
-
method = data.shift();
|
|
490
|
-
methodLatencyId = mongo_manager_1.objectIdHexString();
|
|
491
|
-
log_method_latency_collection_1.LogMethodLatencies.create({
|
|
492
|
-
_id: methodLatencyId,
|
|
493
|
-
__v: 0,
|
|
494
|
-
date_start: new Date(),
|
|
495
|
-
date_end: null,
|
|
496
|
-
latency_ms: 0,
|
|
497
|
-
method: method
|
|
498
|
-
});
|
|
499
|
-
if (method !== 'reportBuilderGetResults' && method !== 'reportBuilderGetDistinctValue' && method !== 'reportBuilderBuildTree' && method !== 'generatePDF' && method !== 'getWOOfflineData' && method !== 'countQuery' && method !== 'countWithQuery' && method !== 'countCollectionWithQuery' && method !== 'find' && method !== 'findOne' && method !== 'findWithOptions' && method !== 'setWSAppVersion' && method !== 'getDrivers') {
|
|
500
|
-
log_collection_1.Logs.insertOne({
|
|
501
|
-
_id: mongo_manager_1.objectIdHexString(),
|
|
502
|
-
type: 'client-request',
|
|
503
|
-
collection: '',
|
|
504
|
-
id_document: '',
|
|
505
|
-
payload: common_1.getBinarySize(JSON.stringify(data)) < 200000 ? JSON.stringify(data, null, 2) : 'Too Big',
|
|
506
|
-
method: method,
|
|
507
|
-
id_user: ws['id_user'] || '',
|
|
508
|
-
user: ws['user'] || '',
|
|
509
|
-
messageId: messageId,
|
|
510
|
-
route: messageRoute_1
|
|
511
|
-
});
|
|
512
|
-
}
|
|
513
|
-
if (!this._methodManager._methods[method]) return [3 /*break*/, 4];
|
|
514
|
-
return [4 /*yield*/, (_c = this._methodManager.callMethodInternal).call.apply(_c, __spreadArrays([Object.assign({}, this._methodManager, { id_user: ws['id_user'], user: ws['user'], id_ws: ws['id_socket'] }), method], data))];
|
|
515
|
-
case 3:
|
|
516
|
-
_e.sent();
|
|
517
|
-
if (method === 'updateDocumentOffline' || method === 'updateDocumentPropsOffline') {
|
|
518
|
-
index_1.ResolveIOServer.getMongoManager().invalidateQueryCache(data[0]);
|
|
519
|
-
}
|
|
520
|
-
return [3 /*break*/, 5];
|
|
521
|
-
case 4:
|
|
522
|
-
console.log('Offline - Could not find method: ' + method);
|
|
523
|
-
_e.label = 5;
|
|
524
|
-
case 5:
|
|
525
|
-
i++;
|
|
526
|
-
return [3 /*break*/, 2];
|
|
527
|
-
case 6: return [3 /*break*/, 8];
|
|
528
|
-
case 7:
|
|
529
|
-
if (type === 'method' && socketData[4] === 'setWSAppVersion') {
|
|
530
|
-
clearTimeout(ws['versionTimer']);
|
|
531
|
-
method = socketData[4];
|
|
532
|
-
serverRes = {
|
|
533
|
-
messageId: messageId,
|
|
534
|
-
hasError: false,
|
|
535
|
-
data: 'ACK'
|
|
536
|
-
};
|
|
537
|
-
if (ws && ws.readyState === ws.OPEN) {
|
|
538
|
-
ws.send(JSON.stringify(serverRes), function (error) {
|
|
539
|
-
if (error) {
|
|
540
|
-
console.log('Error on WS: ', error);
|
|
541
|
-
_this.unsubscribeWS(ws);
|
|
416
|
+
catch (e) {
|
|
417
|
+
console.log('Error - JSON.parse', message);
|
|
418
|
+
this._methodManager.sendEmail('dev@resolveio.com', 'SERVER - JSON Parse Error - ' + this._serverConfig['CLIENT_NAME'], JSON.stringify([message, e]));
|
|
419
|
+
parseErrorFound = true;
|
|
542
420
|
}
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
421
|
+
if (!!parseErrorFound) return [3 /*break*/, 8];
|
|
422
|
+
if (socketData[0] === 'ping') {
|
|
423
|
+
if (ws && ws.readyState === ws.OPEN) {
|
|
424
|
+
ws.send('pong', function (error) {
|
|
425
|
+
if (error) {
|
|
426
|
+
console.log('Error on WS: ', error);
|
|
427
|
+
_this.unsubscribeWS(ws);
|
|
428
|
+
}
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
return [2 /*return*/];
|
|
432
|
+
}
|
|
433
|
+
messageRoute_1 = socketData[0];
|
|
434
|
+
if (this._clientRoutes.some(function (a) { return messageRoute_1.includes(a); }) && !ws['doc_user'].roles.groups.some(function (a) { return a.views.some(function (b) { return messageRoute_1.includes(b); }); }) && !ws['doc_user'].roles.super_admin) {
|
|
435
|
+
return [2 /*return*/];
|
|
436
|
+
}
|
|
437
|
+
messageDate = socketData[1];
|
|
438
|
+
messageId = socketData[2];
|
|
439
|
+
type = socketData[3];
|
|
440
|
+
if (!(type === 'subscription')) return [3 /*break*/, 1];
|
|
441
|
+
subType = socketData[4];
|
|
442
|
+
pub = socketData[5];
|
|
443
|
+
// Subscribe
|
|
444
|
+
if (subType === 'sub') {
|
|
445
|
+
(_a = this._subscriptionManager).subscribe.apply(_a, __spreadArrays([messageDate, ws, messageId, pub], socketData.slice(6)));
|
|
446
|
+
}
|
|
447
|
+
// Unsubscribe
|
|
448
|
+
else {
|
|
449
|
+
(_b = this._subscriptionManager).unsubscribe.apply(_b, __spreadArrays([messageDate, ws, messageId, pub], socketData.slice(6)));
|
|
450
|
+
}
|
|
451
|
+
return [3 /*break*/, 8];
|
|
452
|
+
case 1:
|
|
453
|
+
if (!(type === 'offline')) return [3 /*break*/, 7];
|
|
454
|
+
serverRes = {
|
|
455
|
+
messageId: messageId,
|
|
456
|
+
hasError: false,
|
|
457
|
+
data: 'ACK'
|
|
458
|
+
};
|
|
459
|
+
if (ws && ws.readyState === ws.OPEN) {
|
|
460
|
+
ws.send(JSON.stringify(serverRes), function (error) {
|
|
461
|
+
if (error) {
|
|
462
|
+
console.log('Error on WS: ', error);
|
|
463
|
+
_this.unsubscribeWS(ws);
|
|
464
|
+
}
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
offlineUpdates = socketData[4];
|
|
468
|
+
for (i = 0; i < offlineUpdates.length; i++) {
|
|
469
|
+
update = offlineUpdates[i];
|
|
470
|
+
serverResMethod = {
|
|
471
|
+
messageId: update.data[2],
|
|
472
|
+
hasError: false,
|
|
473
|
+
data: 'ACK'
|
|
474
|
+
};
|
|
475
|
+
if (ws && ws.readyState === ws.OPEN) {
|
|
476
|
+
ws.send(JSON.stringify(serverResMethod), function (error) {
|
|
477
|
+
if (error) {
|
|
478
|
+
console.log('Error on WS: ', error);
|
|
479
|
+
_this.unsubscribeWS(ws);
|
|
480
|
+
}
|
|
481
|
+
});
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
i = 0;
|
|
485
|
+
_e.label = 2;
|
|
486
|
+
case 2:
|
|
487
|
+
if (!(i < offlineUpdates.length)) return [3 /*break*/, 6];
|
|
488
|
+
update = offlineUpdates[i];
|
|
489
|
+
data = update.data;
|
|
490
|
+
if (update.oldData) {
|
|
491
|
+
data.push(update.oldData);
|
|
492
|
+
}
|
|
493
|
+
updateRoute = data.shift();
|
|
494
|
+
updateDate = data.shift();
|
|
495
|
+
updateMessageId = data.shift();
|
|
496
|
+
updateType = data.shift();
|
|
497
|
+
method = data.shift();
|
|
498
|
+
methodLatencyId = mongo_manager_1.objectIdHexString();
|
|
499
|
+
log_method_latency_collection_1.LogMethodLatencies.create({
|
|
500
|
+
_id: methodLatencyId,
|
|
501
|
+
__v: 0,
|
|
502
|
+
date_start: new Date(),
|
|
503
|
+
date_end: null,
|
|
504
|
+
latency_ms: 0,
|
|
505
|
+
method: method
|
|
506
|
+
});
|
|
507
|
+
if (method !== 'reportBuilderGetResults' && method !== 'reportBuilderGetDistinctValue' && method !== 'reportBuilderBuildTree' && method !== 'generatePDF' && method !== 'getWOOfflineData' && method !== 'countQuery' && method !== 'countWithQuery' && method !== 'countCollectionWithQuery' && method !== 'find' && method !== 'findOne' && method !== 'findWithOptions' && method !== 'setWSAppVersion' && method !== 'getDrivers') {
|
|
508
|
+
log_collection_1.Logs.insertOne({
|
|
509
|
+
_id: mongo_manager_1.objectIdHexString(),
|
|
510
|
+
type: 'client-request',
|
|
511
|
+
collection: '',
|
|
512
|
+
id_document: '',
|
|
513
|
+
payload: common_1.getBinarySize(JSON.stringify(data)) < 200000 ? JSON.stringify(data, null, 2) : 'Too Big',
|
|
514
|
+
method: method,
|
|
515
|
+
id_user: ws['id_user'] || '',
|
|
516
|
+
user: ws['user'] || '',
|
|
517
|
+
messageId: messageId,
|
|
518
|
+
route: messageRoute_1
|
|
519
|
+
});
|
|
520
|
+
}
|
|
521
|
+
if (!this._methodManager._methods[method]) return [3 /*break*/, 4];
|
|
522
|
+
return [4 /*yield*/, (_c = this._methodManager.callMethodInternal).call.apply(_c, __spreadArrays([Object.assign({}, this._methodManager, { id_user: ws['id_user'], user: ws['user'], id_ws: ws['id_socket'] }), method], data))];
|
|
523
|
+
case 3:
|
|
524
|
+
_e.sent();
|
|
525
|
+
if (method === 'updateDocumentOffline' || method === 'updateDocumentPropsOffline') {
|
|
526
|
+
index_1.ResolveIOServer.getMongoManager().invalidateQueryCache(data[0]);
|
|
527
|
+
}
|
|
528
|
+
return [3 /*break*/, 5];
|
|
529
|
+
case 4:
|
|
530
|
+
console.log('Offline - Could not find method: ' + method);
|
|
531
|
+
_e.label = 5;
|
|
532
|
+
case 5:
|
|
533
|
+
i++;
|
|
534
|
+
return [3 /*break*/, 2];
|
|
535
|
+
case 6: return [3 /*break*/, 8];
|
|
536
|
+
case 7:
|
|
537
|
+
if (type === 'method' && socketData[4] === 'setWSAppVersion') {
|
|
538
|
+
clearTimeout(ws['versionTimer']);
|
|
539
|
+
method = socketData[4];
|
|
540
|
+
serverRes = {
|
|
541
|
+
messageId: messageId,
|
|
542
|
+
hasError: false,
|
|
543
|
+
data: 'ACK'
|
|
544
|
+
};
|
|
545
|
+
if (ws && ws.readyState === ws.OPEN) {
|
|
546
|
+
ws.send(JSON.stringify(serverRes), function (error) {
|
|
547
|
+
if (error) {
|
|
548
|
+
console.log('Error on WS: ', error);
|
|
549
|
+
_this.unsubscribeWS(ws);
|
|
550
|
+
}
|
|
551
|
+
});
|
|
552
|
+
}
|
|
553
|
+
methodLatencyId = mongo_manager_1.objectIdHexString();
|
|
554
|
+
log_method_latency_collection_1.LogMethodLatencies.create({
|
|
555
|
+
_id: methodLatencyId,
|
|
556
|
+
__v: 0,
|
|
557
|
+
date_start: new Date(),
|
|
558
|
+
date_end: null,
|
|
559
|
+
latency_ms: 0,
|
|
560
|
+
method: method
|
|
561
|
+
});
|
|
562
|
+
if (this._methodManager._methods[method]) {
|
|
563
|
+
(_d = this._methodManager).callMethod.apply(_d, __spreadArrays([methodLatencyId, ws, messageDate, messageId, method], socketData.slice(5)));
|
|
564
|
+
}
|
|
565
|
+
else {
|
|
566
|
+
console.log('Could not find method: ' + method);
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
else {
|
|
570
|
+
this._msgQueue.splice(0, 0, {
|
|
571
|
+
ws: ws,
|
|
572
|
+
data: socketData
|
|
573
|
+
});
|
|
574
|
+
}
|
|
575
|
+
_e.label = 8;
|
|
576
|
+
case 8: return [2 /*return*/];
|
|
559
577
|
}
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
}
|
|
571
|
-
}); });
|
|
572
|
-
ws.on('close', function () {
|
|
573
|
-
_this.unsubscribeWS(ws);
|
|
574
|
-
});
|
|
575
|
-
ws.on('error', function (error) {
|
|
576
|
-
console.log(new Date(), ws['user'], ws['id_socket'], error);
|
|
577
|
-
_this.unsubscribeWS(ws);
|
|
578
|
+
});
|
|
579
|
+
}); });
|
|
580
|
+
ws.on('close', function () {
|
|
581
|
+
_this.unsubscribeWS(ws);
|
|
582
|
+
});
|
|
583
|
+
ws.on('error', function (error) {
|
|
584
|
+
console.log(new Date(), ws['user'], ws['id_socket'], error);
|
|
585
|
+
_this.unsubscribeWS(ws);
|
|
586
|
+
});
|
|
587
|
+
return [2 /*return*/];
|
|
588
|
+
}
|
|
578
589
|
});
|
|
579
|
-
});
|
|
590
|
+
}); });
|
|
580
591
|
// Keep alive timer to ping/pong
|
|
581
592
|
setInterval(function () {
|
|
582
593
|
_this._wss.clients.forEach(function (ws) {
|