@resolveio/server-lib 3.2.10 → 3.2.11

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 (177) hide show
  1. package/package.json +26 -26
  2. package/collections/active-subscription.collection.d.ts +0 -7
  3. package/collections/active-subscription.collection.js +0 -68
  4. package/collections/app-status.collection.d.ts +0 -7
  5. package/collections/app-status.collection.js +0 -43
  6. package/collections/app-version.collection.d.ts +0 -7
  7. package/collections/app-version.collection.js +0 -56
  8. package/collections/billing-logged-in-users.collection.d.ts +0 -7
  9. package/collections/billing-logged-in-users.collection.js +0 -73
  10. package/collections/counter.collection.d.ts +0 -9
  11. package/collections/counter.collection.js +0 -73
  12. package/collections/cron-job-history.collection.d.ts +0 -7
  13. package/collections/cron-job-history.collection.js +0 -86
  14. package/collections/cron-job.collection.d.ts +0 -7
  15. package/collections/cron-job.collection.js +0 -89
  16. package/collections/file.collection.d.ts +0 -9
  17. package/collections/file.collection.js +0 -73
  18. package/collections/flag.collection.d.ts +0 -7
  19. package/collections/flag.collection.js +0 -47
  20. package/collections/log.collection.d.ts +0 -7
  21. package/collections/log.collection.js +0 -65
  22. package/collections/logged-in-users.collection.d.ts +0 -7
  23. package/collections/logged-in-users.collection.js +0 -70
  24. package/collections/method-call.collection.d.ts +0 -6
  25. package/collections/method-call.collection.js +0 -44
  26. package/collections/method-response.collection.d.ts +0 -6
  27. package/collections/method-response.collection.js +0 -48
  28. package/collections/notification.collection.d.ts +0 -7
  29. package/collections/notification.collection.js +0 -43
  30. package/collections/queue-flag.collection.d.ts +0 -7
  31. package/collections/queue-flag.collection.js +0 -41
  32. package/collections/queue-method.collection.d.ts +0 -7
  33. package/collections/queue-method.collection.js +0 -119
  34. package/collections/queue-response.collection.d.ts +0 -7
  35. package/collections/queue-response.collection.js +0 -74
  36. package/collections/support-ticket.collection.d.ts +0 -7
  37. package/collections/support-ticket.collection.js +0 -200
  38. package/collections/user.collection.d.ts +0 -9
  39. package/collections/user.collection.js +0 -153
  40. package/cron/cron.d.ts +0 -5
  41. package/cron/cron.js +0 -160
  42. package/fixtures/cron-jobs.d.ts +0 -1
  43. package/fixtures/cron-jobs.js +0 -90
  44. package/fixtures/init.d.ts +0 -1
  45. package/fixtures/init.js +0 -67
  46. package/http/auth.d.ts +0 -2
  47. package/http/auth.js +0 -468
  48. package/http/health.d.ts +0 -1
  49. package/http/health.js +0 -8
  50. package/index.d.ts +0 -16
  51. package/index.js +0 -125
  52. package/managers/cron.manager.d.ts +0 -16
  53. package/managers/cron.manager.js +0 -202
  54. package/managers/database.manager.d.ts +0 -6
  55. package/managers/database.manager.js +0 -12
  56. package/managers/method.manager.d.ts +0 -28
  57. package/managers/method.manager.js +0 -584
  58. package/managers/queue-method.manager.d.ts +0 -13
  59. package/managers/queue-method.manager.js +0 -240
  60. package/managers/subscription.manager.d.ts +0 -28
  61. package/managers/subscription.manager.js +0 -803
  62. package/managers/support.manager.d.ts +0 -22
  63. package/managers/support.manager.js +0 -320
  64. package/methods/accounts.d.ts +0 -2
  65. package/methods/accounts.js +0 -253
  66. package/methods/aws.d.ts +0 -2
  67. package/methods/aws.js +0 -387
  68. package/methods/cloudconvert.d.ts +0 -2
  69. package/methods/cloudconvert.js +0 -37
  70. package/methods/collections.d.ts +0 -2
  71. package/methods/collections.js +0 -750
  72. package/methods/counters.d.ts +0 -2
  73. package/methods/counters.js +0 -107
  74. package/methods/cron-jobs.d.ts +0 -2
  75. package/methods/cron-jobs.js +0 -132
  76. package/methods/flags.d.ts +0 -2
  77. package/methods/flags.js +0 -6
  78. package/methods/logs.d.ts +0 -2
  79. package/methods/logs.js +0 -29
  80. package/methods/pdf.d.ts +0 -2
  81. package/methods/pdf.js +0 -303
  82. package/models/active-subscription.model.d.ts +0 -13
  83. package/models/active-subscription.model.js +0 -2
  84. package/models/app-status.model.d.ts +0 -4
  85. package/models/app-status.model.js +0 -2
  86. package/models/app-version.model.d.ts +0 -4
  87. package/models/app-version.model.js +0 -2
  88. package/models/billing-logged-in-users.model.d.ts +0 -7
  89. package/models/billing-logged-in-users.model.js +0 -2
  90. package/models/collection-document.model.d.ts +0 -6
  91. package/models/collection-document.model.js +0 -2
  92. package/models/counter.model.d.ts +0 -5
  93. package/models/counter.model.js +0 -2
  94. package/models/cron-job-history.model.d.ts +0 -12
  95. package/models/cron-job-history.model.js +0 -2
  96. package/models/cron-job.model.d.ts +0 -13
  97. package/models/cron-job.model.js +0 -2
  98. package/models/dialog.model.d.ts +0 -23
  99. package/models/dialog.model.js +0 -2
  100. package/models/file.model.d.ts +0 -9
  101. package/models/file.model.js +0 -2
  102. package/models/flag.model.d.ts +0 -5
  103. package/models/flag.model.js +0 -2
  104. package/models/log.model.d.ts +0 -11
  105. package/models/log.model.js +0 -2
  106. package/models/logged-in-users.model.d.ts +0 -9
  107. package/models/logged-in-users.model.js +0 -2
  108. package/models/method-call.model.d.ts +0 -7
  109. package/models/method-call.model.js +0 -2
  110. package/models/method-response.model.d.ts +0 -8
  111. package/models/method-response.model.js +0 -2
  112. package/models/method.model.d.ts +0 -10
  113. package/models/method.model.js +0 -2
  114. package/models/notification.model.d.ts +0 -4
  115. package/models/notification.model.js +0 -2
  116. package/models/pagination.model.d.ts +0 -11
  117. package/models/pagination.model.js +0 -20
  118. package/models/permission.model.d.ts +0 -12
  119. package/models/permission.model.js +0 -2
  120. package/models/queue-method.model.d.ts +0 -10
  121. package/models/queue-method.model.js +0 -2
  122. package/models/queue-response.model.d.ts +0 -10
  123. package/models/queue-response.model.js +0 -2
  124. package/models/select-data-label.model.d.ts +0 -9
  125. package/models/select-data-label.model.js +0 -2
  126. package/models/server-response.model.d.ts +0 -5
  127. package/models/server-response.model.js +0 -2
  128. package/models/subscription.model.d.ts +0 -30
  129. package/models/subscription.model.js +0 -2
  130. package/models/support-method.model.d.ts +0 -9
  131. package/models/support-method.model.js +0 -2
  132. package/models/support-ticket.model.d.ts +0 -61
  133. package/models/support-ticket.model.js +0 -2
  134. package/models/user.model.d.ts +0 -14
  135. package/models/user.model.js +0 -2
  136. package/private/email-templates/enrollment.html +0 -12
  137. package/private/email-templates/forgot-password.html +0 -12
  138. package/private/email-templates/support-ticket-deleted.html +0 -40
  139. package/private/email-templates/support-ticket-modified.html +0 -71
  140. package/private/email-templates/support-ticket.html +0 -71
  141. package/private/images/ResolveIO.png +0 -0
  142. package/publications/app-status.d.ts +0 -2
  143. package/publications/app-status.js +0 -14
  144. package/publications/app-version.d.ts +0 -2
  145. package/publications/app-version.js +0 -14
  146. package/publications/billing-logged-in-users.d.ts +0 -1
  147. package/publications/billing-logged-in-users.js +0 -63
  148. package/publications/cron-jobs.d.ts +0 -2
  149. package/publications/cron-jobs.js +0 -14
  150. package/publications/files.d.ts +0 -2
  151. package/publications/files.js +0 -71
  152. package/publications/flags.d.ts +0 -2
  153. package/publications/flags.js +0 -23
  154. package/publications/logs.d.ts +0 -2
  155. package/publications/logs.js +0 -26
  156. package/publications/method-calls.d.ts +0 -2
  157. package/publications/method-calls.js +0 -14
  158. package/publications/method-responses.d.ts +0 -2
  159. package/publications/method-responses.js +0 -14
  160. package/publications/notifications.d.ts +0 -2
  161. package/publications/notifications.js +0 -14
  162. package/publications/super-admin.d.ts +0 -2
  163. package/publications/super-admin.js +0 -21
  164. package/publications/support-tickets.d.ts +0 -1
  165. package/publications/support-tickets.js +0 -200
  166. package/server-app.d.ts +0 -35
  167. package/server-app.js +0 -636
  168. package/support-methods/aws.d.ts +0 -2
  169. package/support-methods/aws.js +0 -276
  170. package/support-methods/collections.d.ts +0 -2
  171. package/support-methods/collections.js +0 -471
  172. package/support-methods/counters.d.ts +0 -2
  173. package/support-methods/counters.js +0 -189
  174. package/support-methods/support.d.ts +0 -2
  175. package/support-methods/support.js +0 -236
  176. package/util/common.d.ts +0 -14
  177. package/util/common.js +0 -341
@@ -1 +0,0 @@
1
- export declare function loadServerInit(): Promise<void>;
package/fixtures/init.js DELETED
@@ -1,67 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- var __generator = (this && this.__generator) || function (thisArg, body) {
11
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
- function verb(n) { return function (v) { return step([n, v]); }; }
14
- function step(op) {
15
- if (f) throw new TypeError("Generator is already executing.");
16
- while (_) try {
17
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
- if (y = 0, t) op = [op[0] & 2, t.value];
19
- switch (op[0]) {
20
- case 0: case 1: t = op; break;
21
- case 4: _.label++; return { value: op[1], done: false };
22
- case 5: _.label++; y = op[1]; op = [0]; continue;
23
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
- default:
25
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
- if (t[2]) _.ops.pop();
30
- _.trys.pop(); continue;
31
- }
32
- op = body.call(thisArg, _);
33
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
- }
36
- };
37
- Object.defineProperty(exports, "__esModule", { value: true });
38
- var app_version_collection_1 = require("../collections/app-version.collection");
39
- var logged_in_users_collection_1 = require("../collections/logged-in-users.collection");
40
- var active_subscription_collection_1 = require("../collections/active-subscription.collection");
41
- var mongoose_1 = require("mongoose");
42
- function loadServerInit() {
43
- return __awaiter(this, void 0, void 0, function () {
44
- var appVersion;
45
- return __generator(this, function (_a) {
46
- switch (_a.label) {
47
- case 0: return [4 /*yield*/, app_version_collection_1.AppVersions.findOne()];
48
- case 1:
49
- appVersion = _a.sent();
50
- if (!appVersion) {
51
- app_version_collection_1.AppVersions.create({
52
- _id: mongoose_1.Types.ObjectId().toHexString(),
53
- version: 1
54
- });
55
- }
56
- return [4 /*yield*/, logged_in_users_collection_1.LoggedInUsers.deleteMany({}).exec()];
57
- case 2:
58
- _a.sent();
59
- return [4 /*yield*/, active_subscription_collection_1.ActiveSubscriptions.deleteMany({}).exec()];
60
- case 3:
61
- _a.sent();
62
- return [2 /*return*/];
63
- }
64
- });
65
- });
66
- }
67
- exports.loadServerInit = loadServerInit;
package/http/auth.d.ts DELETED
@@ -1,2 +0,0 @@
1
- import ResolveIOMainServer from '../server-app';
2
- export declare function setupAuthRoutes(mainServer: ResolveIOMainServer, app: any, serverConfig: any): void;
package/http/auth.js DELETED
@@ -1,468 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- var __generator = (this && this.__generator) || function (thisArg, body) {
11
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
- function verb(n) { return function (v) { return step([n, v]); }; }
14
- function step(op) {
15
- if (f) throw new TypeError("Generator is already executing.");
16
- while (_) try {
17
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
- if (y = 0, t) op = [op[0] & 2, t.value];
19
- switch (op[0]) {
20
- case 0: case 1: t = op; break;
21
- case 4: _.label++; return { value: op[1], done: false };
22
- case 5: _.label++; y = op[1]; op = [0]; continue;
23
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
- default:
25
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
- if (t[2]) _.ops.pop();
30
- _.trys.pop(); continue;
31
- }
32
- op = body.call(thisArg, _);
33
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
- }
36
- };
37
- Object.defineProperty(exports, "__esModule", { value: true });
38
- var user_collection_1 = require("../collections/user.collection");
39
- var jwt = require("jsonwebtoken");
40
- var handlebars = require("handlebars");
41
- var __1 = require("..");
42
- function setupAuthRoutes(mainServer, app, serverConfig) {
43
- var _this = this;
44
- // Login via HTTP, return refresh token if authenticated
45
- app.post('/login', function (request, response) { return __awaiter(_this, void 0, void 0, function () {
46
- var user_1, username;
47
- return __generator(this, function (_a) {
48
- switch (_a.label) {
49
- case 0:
50
- if (!(request.headers.origin !== serverConfig['ROOT_URL'] && request.headers.origin !== serverConfig['SEC_ROOT_URL'])) return [3 /*break*/, 1];
51
- response.send(JSON.stringify({
52
- error: true,
53
- result: 'Invalid header'
54
- }));
55
- return [3 /*break*/, 5];
56
- case 1: return [4 /*yield*/, user_collection_1.Users.findOne({ username: request.body.username }).exec()];
57
- case 2:
58
- user_1 = _a.sent();
59
- if (!!user_1) return [3 /*break*/, 4];
60
- return [4 /*yield*/, user_collection_1.Users.findOne({ email: request.body.username }).exec()];
61
- case 3:
62
- user_1 = _a.sent();
63
- _a.label = 4;
64
- case 4:
65
- username = user_1 ? user_1.username : request.body.username;
66
- user_collection_1.Users.authenticate()(username, request.body.password).then(function (res) {
67
- if (res && res.user && res.user.active && !res.error) {
68
- res.user.resetAttempts(function (errAt, resAt, errorAt) {
69
- response.send(JSON.stringify({
70
- error: false,
71
- result: {
72
- token: jwt.sign({ id_user: res.user._id }, serverConfig['JWT_SECRET'], {
73
- expiresIn: 90 * 24 * 60 * 60 * 1000 // 90 days
74
- })
75
- }
76
- }));
77
- });
78
- }
79
- else if (res.error.name === 'TooManyAttemptsError') {
80
- response.send(JSON.stringify({
81
- error: true,
82
- result: res.error.message + '. A password reset link has been sent to your email, please reset your password.'
83
- }));
84
- user_1.services.forgot_password = jwt.sign({ id_user: user_1._id }, serverConfig['JWT_SECRET']);
85
- var emailData_1 = {
86
- userToChangePassword: user_1.fullname,
87
- userWhoResetPassword: __1.ResolveIOServer.getClientName() + ' System',
88
- url: serverConfig['ROOT_URL'] + '/forgot-password?' + encodeURIComponent(serverConfig['SERVER_URL']) + '&' + user_1.services.forgot_password
89
- };
90
- user_collection_1.Users.updateOne({ _id: user_1._id }, { $set: { services: user_1.services } }).exec(function (errUp, resUp) {
91
- mainServer.getMethodManager().readFile('email-templates/forgot-password.html').then(function (html) {
92
- var template = handlebars.compile(html);
93
- handlebars.registerHelper('equals', function (a, b) {
94
- return a === b;
95
- });
96
- mainServer.getMethodManager().sendEmail(user_1.email, 'ResolveIO (' + __1.ResolveIOServer.getClientName() + ') - Forgot Password', '', template(emailData_1));
97
- }, function (errEmail) { return console.log(errEmail); });
98
- });
99
- }
100
- else {
101
- response.send(JSON.stringify({
102
- error: true,
103
- result: res.error.message
104
- }));
105
- }
106
- });
107
- _a.label = 5;
108
- case 5: return [2 /*return*/];
109
- }
110
- });
111
- }); });
112
- app.post('/accessToken', function (request, response) {
113
- return __awaiter(this, void 0, void 0, function () {
114
- return __generator(this, function (_a) {
115
- if (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']) {
116
- response.send(JSON.stringify({
117
- error: true,
118
- result: 'Invalid header'
119
- }));
120
- }
121
- else {
122
- if (serverConfig['ROOT_URL'] !== 'http://localhost:4200') {
123
- jwt.verify(request.body.refreshToken, serverConfig['JWT_SECRET'], function (err, decoded) {
124
- if (err) {
125
- response.send(JSON.stringify({
126
- error: true,
127
- result: 'Invalid Token'
128
- }));
129
- }
130
- else {
131
- user_collection_1.Users.findById(decoded['id_user']).exec().then(function (user) {
132
- if (user) {
133
- if (user.active) {
134
- user.resetAttempts(function (err, res) {
135
- user.save();
136
- response.send(JSON.stringify({
137
- error: false,
138
- result: {
139
- token: jwt.sign({ id_user: user._id }, serverConfig['JWT_SECRET'], {
140
- expiresIn: 3 * 24 * 60 * 60 * 1000 // 3 days
141
- }),
142
- user: user
143
- }
144
- }));
145
- });
146
- }
147
- else {
148
- response.send(JSON.stringify({
149
- error: true,
150
- result: 'Account is Disabled'
151
- }));
152
- }
153
- }
154
- else {
155
- response.send(JSON.stringify({
156
- error: true,
157
- result: 'Invalid User'
158
- }));
159
- }
160
- }, function (error) {
161
- response.send(JSON.stringify({
162
- error: true,
163
- result: 'Invalid Mongoose Get User'
164
- }));
165
- });
166
- }
167
- });
168
- }
169
- else {
170
- jwt.verify(request.body.refreshToken, serverConfig['JWT_SECRET'], function (err, decoded) {
171
- if (err) {
172
- response.send(JSON.stringify({
173
- error: true,
174
- result: 'Invalid Token'
175
- }));
176
- }
177
- else {
178
- user_collection_1.Users.findById(decoded['id_user']).exec().then(function (user) {
179
- if (user) {
180
- if (user.active) {
181
- user.resetAttempts(function (err, res) {
182
- user.save();
183
- response.send(JSON.stringify({
184
- error: false,
185
- result: {
186
- token: jwt.sign({ id_user: user._id }, serverConfig['JWT_SECRET'], {
187
- expiresIn: 3 * 24 * 60 * 60 * 1000 // 3 days
188
- }),
189
- user: user
190
- }
191
- }));
192
- });
193
- }
194
- else {
195
- response.send(JSON.stringify({
196
- error: true,
197
- result: 'Account is Disabled'
198
- }));
199
- }
200
- }
201
- else {
202
- response.send(JSON.stringify({
203
- error: true,
204
- result: 'Invalid User'
205
- }));
206
- }
207
- }, function (error) {
208
- response.send(JSON.stringify({
209
- error: true,
210
- result: 'Invalid Mongoose Get User'
211
- }));
212
- });
213
- }
214
- });
215
- }
216
- }
217
- return [2 /*return*/];
218
- });
219
- });
220
- });
221
- app.post('/userWithEnrollmentToken', function (request, response) {
222
- if (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']) {
223
- response.send(JSON.stringify({
224
- error: true,
225
- result: 'Invalid header'
226
- }));
227
- }
228
- else {
229
- jwt.verify(request.body.enrollmentToken, serverConfig['JWT_SECRET'], function (err, decoded) {
230
- if (err) {
231
- response.send(JSON.stringify({
232
- error: true,
233
- result: 'Invalid Token'
234
- }));
235
- }
236
- else {
237
- user_collection_1.Users.findOne({
238
- $and: [
239
- { _id: decoded['id_user'] },
240
- { 'services.enrollment': request.body.enrollmentToken }
241
- ]
242
- }).select('_id __v username active').exec().then(function (user) {
243
- if (user) {
244
- if (user.active) {
245
- response.send(JSON.stringify({
246
- error: false,
247
- result: {
248
- user: user
249
- }
250
- }));
251
- }
252
- else {
253
- response.send(JSON.stringify({
254
- error: true,
255
- result: 'Account is Disabled'
256
- }));
257
- }
258
- }
259
- else {
260
- response.send(JSON.stringify({
261
- error: true,
262
- result: 'Invalid User'
263
- }));
264
- }
265
- }, function (error) {
266
- response.send(JSON.stringify({
267
- error: true,
268
- result: 'Invalid Mongoose Get User'
269
- }));
270
- });
271
- }
272
- });
273
- }
274
- });
275
- app.post('/setUserWithEnrollmentToken', function (request, response) {
276
- var _this = this;
277
- if (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']) {
278
- response.send(JSON.stringify({
279
- error: true,
280
- result: 'Invalid header'
281
- }));
282
- }
283
- else {
284
- jwt.verify(request.body.enrollmentToken, serverConfig['JWT_SECRET'], function (err, decoded) { return __awaiter(_this, void 0, void 0, function () {
285
- return __generator(this, function (_a) {
286
- if (err) {
287
- response.send(JSON.stringify({
288
- error: true,
289
- result: 'Invalid Token'
290
- }));
291
- }
292
- else {
293
- user_collection_1.Users.findOne({
294
- $and: [
295
- { _id: decoded['id_user'] },
296
- { 'services.enrollment': request.body.enrollmentToken }
297
- ]
298
- }).exec().then(function (user) {
299
- if (user) {
300
- if (user.active) {
301
- user.setPassword(request.body.password, function (errSet, resSet) {
302
- if (resSet) {
303
- user.services.enrollment = '';
304
- user.save();
305
- response.send(JSON.stringify({
306
- error: false,
307
- result: true
308
- }));
309
- }
310
- else {
311
- response.send(JSON.stringify({
312
- error: true,
313
- result: errSet
314
- }));
315
- }
316
- });
317
- }
318
- else {
319
- response.send(JSON.stringify({
320
- error: true,
321
- result: 'Account is Disabled'
322
- }));
323
- }
324
- }
325
- else {
326
- response.send(JSON.stringify({
327
- error: true,
328
- result: 'Invalid User'
329
- }));
330
- }
331
- }, function (error) {
332
- response.send(JSON.stringify({
333
- error: true,
334
- result: 'Invalid Mongoose Get User'
335
- }));
336
- });
337
- }
338
- return [2 /*return*/];
339
- });
340
- }); });
341
- }
342
- });
343
- app.post('/userWithForgotPasswordToken', function (request, response) {
344
- if (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']) {
345
- response.send(JSON.stringify({
346
- error: true,
347
- result: 'Invalid header'
348
- }));
349
- }
350
- else {
351
- jwt.verify(request.body.forgotPasswordToken, serverConfig['JWT_SECRET'], function (err, decoded) {
352
- if (err) {
353
- response.send(JSON.stringify({
354
- error: true,
355
- result: 'Invalid Token'
356
- }));
357
- }
358
- else {
359
- user_collection_1.Users.findOne({
360
- $and: [
361
- { _id: decoded['id_user'] },
362
- { 'services.forgot_password': request.body.forgotPasswordToken }
363
- ]
364
- }).select('_id __v username active').exec().then(function (user) {
365
- if (user) {
366
- if (user.active) {
367
- response.send(JSON.stringify({
368
- error: false,
369
- result: {
370
- user: user
371
- }
372
- }));
373
- }
374
- else {
375
- response.send(JSON.stringify({
376
- error: true,
377
- result: 'Account is Disabled'
378
- }));
379
- }
380
- }
381
- else {
382
- response.send(JSON.stringify({
383
- error: true,
384
- result: 'Invalid User'
385
- }));
386
- }
387
- }, function (error) {
388
- response.send(JSON.stringify({
389
- error: true,
390
- result: 'Invalid Mongoose Get User'
391
- }));
392
- });
393
- }
394
- });
395
- }
396
- });
397
- app.post('/setUserWithForgotPasswordToken', function (request, response) {
398
- var _this = this;
399
- if (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']) {
400
- response.send(JSON.stringify({
401
- error: true,
402
- result: 'Invalid header'
403
- }));
404
- }
405
- else {
406
- jwt.verify(request.body.forgotPasswordToken, serverConfig['JWT_SECRET'], function (err, decoded) { return __awaiter(_this, void 0, void 0, function () {
407
- return __generator(this, function (_a) {
408
- if (err) {
409
- response.send(JSON.stringify({
410
- error: true,
411
- result: 'Invalid Token'
412
- }));
413
- }
414
- else {
415
- user_collection_1.Users.findOne({
416
- $and: [
417
- { _id: decoded['id_user'] },
418
- { 'services.forgot_password': request.body.forgotPasswordToken }
419
- ]
420
- }).exec().then(function (user) {
421
- if (user) {
422
- if (user.active) {
423
- user.setPassword(request.body.password, function (errSet, resSet) {
424
- if (resSet) {
425
- user.services.forgot_password = '';
426
- user.resetAttempts(function (err, res) {
427
- user.save();
428
- });
429
- response.send(JSON.stringify({
430
- error: false,
431
- result: true
432
- }));
433
- }
434
- else {
435
- response.send(JSON.stringify({
436
- error: true,
437
- result: errSet
438
- }));
439
- }
440
- });
441
- }
442
- else {
443
- response.send(JSON.stringify({
444
- error: true,
445
- result: 'Account is Disabled'
446
- }));
447
- }
448
- }
449
- else {
450
- response.send(JSON.stringify({
451
- error: true,
452
- result: 'Invalid User'
453
- }));
454
- }
455
- }, function (error) {
456
- response.send(JSON.stringify({
457
- error: true,
458
- result: 'Invalid Mongoose Get User'
459
- }));
460
- });
461
- }
462
- return [2 /*return*/];
463
- });
464
- }); });
465
- }
466
- });
467
- }
468
- exports.setupAuthRoutes = setupAuthRoutes;
package/http/health.d.ts DELETED
@@ -1 +0,0 @@
1
- export declare function setupHealthRoutes(app: any, serverConfig: any): void;
package/http/health.js DELETED
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- function setupHealthRoutes(app, serverConfig) {
4
- app.get('/health', function (request, response) {
5
- response.sendStatus(200);
6
- });
7
- }
8
- exports.setupHealthRoutes = setupHealthRoutes;
package/index.d.ts DELETED
@@ -1,16 +0,0 @@
1
- import ResolveIOMainServer from './server-app';
2
- export declare class ResolveIOServer {
3
- private static _serverConfig;
4
- private static _mainDB;
5
- private static _supportDB;
6
- private static _mainServer;
7
- private static _client;
8
- private static _clientDir;
9
- private static _dontRunSupport;
10
- constructor(serverConfig: any, client: string, clientDir: any, _dontRunSupport?: any);
11
- static connectAndRun(): Promise<{}>;
12
- static getClientName(): string;
13
- static getMainServer(): ResolveIOMainServer;
14
- static getMainDB(): any;
15
- static getSupportDB(): any;
16
- }