@steedos/accounts 2.2.52-beta.22 → 2.2.52-beta.24

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 (54) hide show
  1. package/LICENSE.txt +2 -3
  2. package/lib/core/index.js +18 -18
  3. package/lib/database-mongo/mongo.js +90 -90
  4. package/lib/database-mongo/mongo.js.map +1 -1
  5. package/lib/index.js +4 -4
  6. package/lib/index.js.map +1 -1
  7. package/lib/mail.js +2 -2
  8. package/lib/oauth2/stub/oidc-cert.js +1 -1
  9. package/lib/oauth2/stub/oidc-cert.js.map +1 -1
  10. package/lib/password/accounts-password.js +54 -41
  11. package/lib/password/accounts-password.js.map +1 -1
  12. package/lib/password/index.js +1 -1
  13. package/lib/password/index.js.map +1 -1
  14. package/lib/password/utils/encryption.js +3 -3
  15. package/lib/rest-express/endpoints/authorize.js +2 -2
  16. package/lib/rest-express/endpoints/get-user.js +2 -2
  17. package/lib/rest-express/endpoints/impersonate.js +2 -2
  18. package/lib/rest-express/endpoints/initServer.js +2 -2
  19. package/lib/rest-express/endpoints/login.js +2 -2
  20. package/lib/rest-express/endpoints/logout.js +2 -2
  21. package/lib/rest-express/endpoints/oauth/provider-callback.js +3 -3
  22. package/lib/rest-express/endpoints/oauth/provider-callback.js.map +1 -1
  23. package/lib/rest-express/endpoints/password/change-password.js +2 -2
  24. package/lib/rest-express/endpoints/password/register.js +2 -2
  25. package/lib/rest-express/endpoints/password/reset.js +4 -4
  26. package/lib/rest-express/endpoints/password/two-factor.js +6 -6
  27. package/lib/rest-express/endpoints/password/verify-email.js +6 -6
  28. package/lib/rest-express/endpoints/password/verify.js +4 -4
  29. package/lib/rest-express/endpoints/put-user-name.js +2 -2
  30. package/lib/rest-express/endpoints/refresh-access-token.js +2 -2
  31. package/lib/rest-express/endpoints/service-authenticate.js +2 -2
  32. package/lib/rest-express/endpoints/spaces.js +2 -2
  33. package/lib/rest-express/endpoints/steedos/create-tenant.js +2 -2
  34. package/lib/rest-express/endpoints/steedos/get-tenant.js +2 -2
  35. package/lib/rest-express/endpoints/steedos/settings.js +2 -2
  36. package/lib/rest-express/endpoints/update-session.js +2 -2
  37. package/lib/rest-express/express-middleware.js +1 -1
  38. package/lib/rest-express/express-middleware.js.map +1 -1
  39. package/lib/rest-express/user-loader.js +2 -2
  40. package/lib/rest-express/utils/steedos-auth.js +2 -2
  41. package/lib/rest-express/utils/steedos-auth.js.map +1 -1
  42. package/lib/rest-express/utils/users.js +4 -4
  43. package/lib/saml-idp/express-middleware.js +10 -10
  44. package/lib/saml-idp/express-middleware.js.map +1 -1
  45. package/lib/server/accounts-server.js +37 -29
  46. package/lib/server/accounts-server.js.map +1 -1
  47. package/lib/server/utils/email.js +2 -2
  48. package/lib/types/index.js +14 -14
  49. package/lib/types/index.js.map +1 -1
  50. package/package.json +6 -6
  51. package/src/index.ts +3 -3
  52. package/src/password/accounts-password.ts +17 -5
  53. package/src/server/accounts-server.ts +14 -2
  54. package/src/server/types/jwt-data.ts +10 -1
package/LICENSE.txt CHANGED
@@ -6,9 +6,8 @@ To determine under which license you may use a file from the Steedos source code
6
6
  please resort to the header of that file.
7
7
 
8
8
  If the file has no header, the following rules apply
9
- 1. project templates are licensed under MIT, see License.MIT.txt
10
- 2. enterprise features are licensed under Steedos Enterprise Terms, see License.enterprise.txt
11
- 3. source code that is neither (1) nor (2) is licensed under AGPL, see License.AGPL.txt
9
+ 1. enterprise features are licensed under Steedos Enterprise Terms, see License.enterprise.txt
10
+ 2. source code that is neither (1) is licensed under MIT, see https://opensource.org/licenses/MIT
12
11
 
13
12
  On request, licenses under different terms are available.
14
13
 
package/lib/core/index.js CHANGED
@@ -7,9 +7,9 @@ var db_1 = require("../db");
7
7
  var _ = require("lodash");
8
8
  var chalk_1 = require("chalk");
9
9
  var config = (0, objectql_1.getSteedosConfig)();
10
- var getSettings = function () { return (0, tslib_1.__awaiter)(void 0, void 0, void 0, function () {
10
+ var getSettings = function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
11
11
  var tenant, spaceDoc, steedosService;
12
- return (0, tslib_1.__generator)(this, function (_a) {
12
+ return tslib_1.__generator(this, function (_a) {
13
13
  switch (_a.label) {
14
14
  case 0:
15
15
  tenant = {
@@ -55,9 +55,9 @@ var getSettings = function () { return (0, tslib_1.__awaiter)(void 0, void 0, vo
55
55
  });
56
56
  }); };
57
57
  exports.getSettings = getSettings;
58
- var getTenant = function (spaceId) { return (0, tslib_1.__awaiter)(void 0, void 0, void 0, function () {
58
+ var getTenant = function (spaceId) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
59
59
  var spaceDoc, steedosService;
60
- return (0, tslib_1.__generator)(this, function (_a) {
60
+ return tslib_1.__generator(this, function (_a) {
61
61
  switch (_a.label) {
62
62
  case 0:
63
63
  if (!spaceId) {
@@ -86,9 +86,9 @@ var getTenant = function (spaceId) { return (0, tslib_1.__awaiter)(void 0, void
86
86
  });
87
87
  }); };
88
88
  exports.getTenant = getTenant;
89
- var spaceExists = function (spaceId) { return (0, tslib_1.__awaiter)(void 0, void 0, void 0, function () {
89
+ var spaceExists = function (spaceId) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
90
90
  var spaceDoc;
91
- return (0, tslib_1.__generator)(this, function (_a) {
91
+ return tslib_1.__generator(this, function (_a) {
92
92
  switch (_a.label) {
93
93
  case 0: return [4 /*yield*/, db_1.db.findOne("spaces", spaceId, { fields: ["name", "avatar", "avatar_dark", "background", "enable_register"] })];
94
94
  case 1:
@@ -101,9 +101,9 @@ var spaceExists = function (spaceId) { return (0, tslib_1.__awaiter)(void 0, voi
101
101
  });
102
102
  }); };
103
103
  exports.spaceExists = spaceExists;
104
- var getMergedTenant = function (spaceId) { return (0, tslib_1.__awaiter)(void 0, void 0, void 0, function () {
104
+ var getMergedTenant = function (spaceId) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
105
105
  var settings, tenant;
106
- return (0, tslib_1.__generator)(this, function (_a) {
106
+ return tslib_1.__generator(this, function (_a) {
107
107
  switch (_a.label) {
108
108
  case 0: return [4 /*yield*/, (0, exports.getSettings)()];
109
109
  case 1:
@@ -116,9 +116,9 @@ var getMergedTenant = function (spaceId) { return (0, tslib_1.__awaiter)(void 0,
116
116
  });
117
117
  }); };
118
118
  exports.getMergedTenant = getMergedTenant;
119
- var canRegister = function (spaceId, action) { return (0, tslib_1.__awaiter)(void 0, void 0, void 0, function () {
119
+ var canRegister = function (spaceId, action) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
120
120
  var tenant;
121
- return (0, tslib_1.__generator)(this, function (_a) {
121
+ return tslib_1.__generator(this, function (_a) {
122
122
  switch (_a.label) {
123
123
  case 0: return [4 /*yield*/, (0, exports.getMergedTenant)(spaceId)];
124
124
  case 1:
@@ -137,9 +137,9 @@ var canRegister = function (spaceId, action) { return (0, tslib_1.__awaiter)(voi
137
137
  });
138
138
  }); };
139
139
  exports.canRegister = canRegister;
140
- var loginWithCode = function (spaceId) { return (0, tslib_1.__awaiter)(void 0, void 0, void 0, function () {
140
+ var loginWithCode = function (spaceId) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
141
141
  var loginWithCode, tenant;
142
- return (0, tslib_1.__generator)(this, function (_a) {
142
+ return tslib_1.__generator(this, function (_a) {
143
143
  switch (_a.label) {
144
144
  case 0:
145
145
  loginWithCode = false;
@@ -154,9 +154,9 @@ var loginWithCode = function (spaceId) { return (0, tslib_1.__awaiter)(void 0, v
154
154
  });
155
155
  }); };
156
156
  exports.loginWithCode = loginWithCode;
157
- var canPasswordLogin = function () { return (0, tslib_1.__awaiter)(void 0, void 0, void 0, function () {
157
+ var canPasswordLogin = function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
158
158
  var tenant;
159
- return (0, tslib_1.__generator)(this, function (_a) {
159
+ return tslib_1.__generator(this, function (_a) {
160
160
  switch (_a.label) {
161
161
  case 0: return [4 /*yield*/, (0, exports.getMergedTenant)()];
162
162
  case 1:
@@ -235,9 +235,9 @@ var getSteedosService = function () {
235
235
  return steedosService;
236
236
  };
237
237
  exports.getSteedosService = getSteedosService;
238
- var sendMail = function (mail) { return (0, tslib_1.__awaiter)(void 0, void 0, void 0, function () {
238
+ var sendMail = function (mail) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
239
239
  var to, subject, html, config, canSend;
240
- return (0, tslib_1.__generator)(this, function (_a) {
240
+ return tslib_1.__generator(this, function (_a) {
241
241
  to = mail.to, subject = mail.subject, html = mail.html;
242
242
  config = (0, objectql_1.getSteedosConfig)().email || {};
243
243
  canSend = (0, exports.canSendEmail)();
@@ -259,9 +259,9 @@ var sendMail = function (mail) { return (0, tslib_1.__awaiter)(void 0, void 0, v
259
259
  });
260
260
  }); };
261
261
  exports.sendMail = sendMail;
262
- var sendSMS = function (sms) { return (0, tslib_1.__awaiter)(void 0, void 0, void 0, function () {
262
+ var sendSMS = function (sms) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
263
263
  var mobile, message, spaceId, canSend;
264
- return (0, tslib_1.__generator)(this, function (_a) {
264
+ return tslib_1.__generator(this, function (_a) {
265
265
  mobile = sms.mobile, message = sms.message, spaceId = sms.spaceId;
266
266
  canSend = (0, exports.canSendSMS)();
267
267
  console.log(chalk_1.default.green("SMS: ".concat(mobile, ", ").concat(message)));
@@ -31,7 +31,7 @@ var defaultOptions = {
31
31
  };
32
32
  var Mongo = /** @class */ (function () {
33
33
  function Mongo(db, options) {
34
- this.options = (0, lodash_1.merge)((0, tslib_1.__assign)({}, defaultOptions), options);
34
+ this.options = (0, lodash_1.merge)(tslib_1.__assign({}, defaultOptions), options);
35
35
  if (!db) {
36
36
  throw new Error("A database connection is required");
37
37
  }
@@ -43,9 +43,9 @@ var Mongo = /** @class */ (function () {
43
43
  this.spaceUserCollection = this.db.collection(this.options.spaceUserCollectionName);
44
44
  }
45
45
  Mongo.prototype.findValidSessionsByUserId = function (userId, is_phone) {
46
- return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
46
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
47
47
  var query, sessions;
48
- return (0, tslib_1.__generator)(this, function (_a) {
48
+ return tslib_1.__generator(this, function (_a) {
49
49
  switch (_a.label) {
50
50
  case 0:
51
51
  query = {
@@ -75,8 +75,8 @@ var Mongo = /** @class */ (function () {
75
75
  });
76
76
  };
77
77
  Mongo.prototype.setupIndexes = function () {
78
- return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
79
- return (0, tslib_1.__generator)(this, function (_a) {
78
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
79
+ return tslib_1.__generator(this, function (_a) {
80
80
  switch (_a.label) {
81
81
  case 0: return [4 /*yield*/, this.sessionCollection.createIndex("token", {
82
82
  unique: true,
@@ -102,14 +102,14 @@ var Mongo = /** @class */ (function () {
102
102
  });
103
103
  };
104
104
  Mongo.prototype.createUser = function (_a) {
105
- var password = _a.password, username = _a.username, email = _a.email, email_verified = _a.email_verified, mobile = _a.mobile, mobile_verified = _a.mobile_verified, cleanUser = (0, tslib_1.__rest)(_a, ["password", "username", "email", "email_verified", "mobile", "mobile_verified"]);
106
- return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
105
+ var password = _a.password, username = _a.username, email = _a.email, email_verified = _a.email_verified, mobile = _a.mobile, mobile_verified = _a.mobile_verified, cleanUser = tslib_1.__rest(_a, ["password", "username", "email", "email_verified", "mobile", "mobile_verified"]);
106
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
107
107
  var user, encryptedMobile, encryptedName, ret;
108
108
  var _b;
109
- return (0, tslib_1.__generator)(this, function (_c) {
109
+ return tslib_1.__generator(this, function (_c) {
110
110
  switch (_c.label) {
111
111
  case 0:
112
- user = (0, tslib_1.__assign)((0, tslib_1.__assign)({}, cleanUser), (_b = { services: {} }, _b[this.options.timestamps.createdAt] = this.options.dateProvider(), _b[this.options.timestamps.updatedAt] = this.options.dateProvider(), _b));
112
+ user = tslib_1.__assign(tslib_1.__assign({}, cleanUser), (_b = { services: {} }, _b[this.options.timestamps.createdAt] = this.options.dateProvider(), _b[this.options.timestamps.updatedAt] = this.options.dateProvider(), _b));
113
113
  if (password) {
114
114
  user.services.password = { bcrypt: password };
115
115
  }
@@ -156,9 +156,9 @@ var Mongo = /** @class */ (function () {
156
156
  });
157
157
  };
158
158
  Mongo.prototype.findUserById = function (userId) {
159
- return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
159
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
160
160
  var id, user;
161
- return (0, tslib_1.__generator)(this, function (_a) {
161
+ return tslib_1.__generator(this, function (_a) {
162
162
  switch (_a.label) {
163
163
  case 0:
164
164
  id = this.options.convertUserIdToMongoObjectId
@@ -176,9 +176,9 @@ var Mongo = /** @class */ (function () {
176
176
  });
177
177
  };
178
178
  Mongo.prototype.findUserByEmail = function (email) {
179
- return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
179
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
180
180
  var user;
181
- return (0, tslib_1.__generator)(this, function (_a) {
181
+ return tslib_1.__generator(this, function (_a) {
182
182
  switch (_a.label) {
183
183
  case 0: return [4 /*yield*/, this.collection.findOne({
184
184
  email: email.toLowerCase(),
@@ -194,9 +194,9 @@ var Mongo = /** @class */ (function () {
194
194
  });
195
195
  };
196
196
  Mongo.prototype.findUserByMobile = function (mobile) {
197
- return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
197
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
198
198
  var selector, encryptedMobile, user;
199
- return (0, tslib_1.__generator)(this, function (_a) {
199
+ return tslib_1.__generator(this, function (_a) {
200
200
  switch (_a.label) {
201
201
  case 0:
202
202
  selector = {
@@ -220,9 +220,9 @@ var Mongo = /** @class */ (function () {
220
220
  });
221
221
  };
222
222
  Mongo.prototype.findUserByUsername = function (username) {
223
- return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
223
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
224
224
  var filter, user;
225
- return (0, tslib_1.__generator)(this, function (_a) {
225
+ return tslib_1.__generator(this, function (_a) {
226
226
  switch (_a.label) {
227
227
  case 0:
228
228
  filter = this.options.caseSensitiveUserName
@@ -242,9 +242,9 @@ var Mongo = /** @class */ (function () {
242
242
  });
243
243
  };
244
244
  Mongo.prototype.findPasswordHash = function (userId) {
245
- return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
245
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
246
246
  var user;
247
- return (0, tslib_1.__generator)(this, function (_a) {
247
+ return tslib_1.__generator(this, function (_a) {
248
248
  switch (_a.label) {
249
249
  case 0: return [4 /*yield*/, this.findUserById(userId)];
250
250
  case 1:
@@ -258,9 +258,9 @@ var Mongo = /** @class */ (function () {
258
258
  });
259
259
  };
260
260
  Mongo.prototype.findUserByEmailVerificationToken = function (token) {
261
- return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
261
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
262
262
  var user;
263
- return (0, tslib_1.__generator)(this, function (_a) {
263
+ return tslib_1.__generator(this, function (_a) {
264
264
  switch (_a.label) {
265
265
  case 0: return [4 /*yield*/, this.collection.findOne({
266
266
  "services.email.verificationTokens.token": token,
@@ -276,9 +276,9 @@ var Mongo = /** @class */ (function () {
276
276
  });
277
277
  };
278
278
  Mongo.prototype.findUserByResetPasswordToken = function (token) {
279
- return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
279
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
280
280
  var user;
281
- return (0, tslib_1.__generator)(this, function (_a) {
281
+ return tslib_1.__generator(this, function (_a) {
282
282
  switch (_a.label) {
283
283
  case 0: return [4 /*yield*/, this.collection.findOne({
284
284
  "services.password.reset.token": token,
@@ -294,10 +294,10 @@ var Mongo = /** @class */ (function () {
294
294
  });
295
295
  };
296
296
  Mongo.prototype.findUserByServiceId = function (serviceName, serviceId) {
297
- return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
297
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
298
298
  var user;
299
299
  var _a;
300
- return (0, tslib_1.__generator)(this, function (_b) {
300
+ return tslib_1.__generator(this, function (_b) {
301
301
  switch (_b.label) {
302
302
  case 0: return [4 /*yield*/, this.collection.findOne((_a = {},
303
303
  _a["services.".concat(serviceName, ".id")] = serviceId,
@@ -325,10 +325,10 @@ var Mongo = /** @class */ (function () {
325
325
  // return user;
326
326
  // }
327
327
  Mongo.prototype.addEmail = function (userId, newEmail, verified) {
328
- return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
328
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
329
329
  var id, ret;
330
330
  var _a;
331
- return (0, tslib_1.__generator)(this, function (_b) {
331
+ return tslib_1.__generator(this, function (_b) {
332
332
  switch (_b.label) {
333
333
  case 0:
334
334
  id = this.options.convertUserIdToMongoObjectId
@@ -356,10 +356,10 @@ var Mongo = /** @class */ (function () {
356
356
  });
357
357
  };
358
358
  Mongo.prototype.removeEmail = function (userId, email) {
359
- return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
359
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
360
360
  var id, ret;
361
361
  var _a;
362
- return (0, tslib_1.__generator)(this, function (_b) {
362
+ return tslib_1.__generator(this, function (_b) {
363
363
  switch (_b.label) {
364
364
  case 0:
365
365
  id = this.options.convertUserIdToMongoObjectId
@@ -382,10 +382,10 @@ var Mongo = /** @class */ (function () {
382
382
  });
383
383
  };
384
384
  Mongo.prototype.verifyEmail = function (userId, email) {
385
- return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
385
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
386
386
  var id, ret;
387
387
  var _a;
388
- return (0, tslib_1.__generator)(this, function (_b) {
388
+ return tslib_1.__generator(this, function (_b) {
389
389
  switch (_b.label) {
390
390
  case 0:
391
391
  id = this.options.convertUserIdToMongoObjectId
@@ -422,9 +422,9 @@ var Mongo = /** @class */ (function () {
422
422
  };
423
423
  // 如果开启了加密功能,则获取加密后的字段值
424
424
  Mongo.prototype.getEncryptedSpaceUserFieldValue = function (value, fieldName) {
425
- return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
425
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
426
426
  var objectql, objFields, datasource, encryptedValue;
427
- return (0, tslib_1.__generator)(this, function (_a) {
427
+ return tslib_1.__generator(this, function (_a) {
428
428
  switch (_a.label) {
429
429
  case 0:
430
430
  objectql = require('@steedos/objectql');
@@ -446,10 +446,10 @@ var Mongo = /** @class */ (function () {
446
446
  });
447
447
  };
448
448
  Mongo.prototype.verifyMobile = function (userId, mobile) {
449
- return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
449
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
450
450
  var id, encryptedMobile, ret;
451
451
  var _a;
452
- return (0, tslib_1.__generator)(this, function (_b) {
452
+ return tslib_1.__generator(this, function (_b) {
453
453
  switch (_b.label) {
454
454
  case 0:
455
455
  id = this.options.convertUserIdToMongoObjectId
@@ -488,10 +488,10 @@ var Mongo = /** @class */ (function () {
488
488
  });
489
489
  };
490
490
  Mongo.prototype.setMobile = function (userId, newMobile) {
491
- return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
491
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
492
492
  var id, encryptedMobile, existed, user, ret;
493
493
  var _a;
494
- return (0, tslib_1.__generator)(this, function (_b) {
494
+ return tslib_1.__generator(this, function (_b) {
495
495
  switch (_b.label) {
496
496
  case 0:
497
497
  id = this.options.convertUserIdToMongoObjectId
@@ -544,10 +544,10 @@ var Mongo = /** @class */ (function () {
544
544
  });
545
545
  };
546
546
  Mongo.prototype.setEmail = function (userId, newEmail) {
547
- return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
547
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
548
548
  var id, existed, user, ret;
549
549
  var _a;
550
- return (0, tslib_1.__generator)(this, function (_b) {
550
+ return tslib_1.__generator(this, function (_b) {
551
551
  switch (_b.label) {
552
552
  case 0:
553
553
  id = this.options.convertUserIdToMongoObjectId
@@ -597,10 +597,10 @@ var Mongo = /** @class */ (function () {
597
597
  });
598
598
  };
599
599
  Mongo.prototype.setUsername = function (userId, newUsername) {
600
- return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
600
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
601
601
  var id, ret;
602
602
  var _a;
603
- return (0, tslib_1.__generator)(this, function (_b) {
603
+ return tslib_1.__generator(this, function (_b) {
604
604
  switch (_b.label) {
605
605
  case 0:
606
606
  id = this.options.convertUserIdToMongoObjectId
@@ -624,10 +624,10 @@ var Mongo = /** @class */ (function () {
624
624
  });
625
625
  };
626
626
  Mongo.prototype.setPassword = function (userId, newPassword) {
627
- return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
627
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
628
628
  var id, ret;
629
629
  var _a;
630
- return (0, tslib_1.__generator)(this, function (_b) {
630
+ return tslib_1.__generator(this, function (_b) {
631
631
  switch (_b.label) {
632
632
  case 0:
633
633
  id = this.options.convertUserIdToMongoObjectId
@@ -657,10 +657,10 @@ var Mongo = /** @class */ (function () {
657
657
  });
658
658
  };
659
659
  Mongo.prototype.setService = function (userId, serviceName, service) {
660
- return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
660
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
661
661
  var id;
662
662
  var _a;
663
- return (0, tslib_1.__generator)(this, function (_b) {
663
+ return tslib_1.__generator(this, function (_b) {
664
664
  switch (_b.label) {
665
665
  case 0:
666
666
  id = this.options.convertUserIdToMongoObjectId
@@ -680,10 +680,10 @@ var Mongo = /** @class */ (function () {
680
680
  });
681
681
  };
682
682
  Mongo.prototype.unsetService = function (userId, serviceName) {
683
- return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
683
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
684
684
  var id;
685
685
  var _a, _b;
686
- return (0, tslib_1.__generator)(this, function (_c) {
686
+ return tslib_1.__generator(this, function (_c) {
687
687
  switch (_c.label) {
688
688
  case 0:
689
689
  id = this.options.convertUserIdToMongoObjectId
@@ -705,10 +705,10 @@ var Mongo = /** @class */ (function () {
705
705
  });
706
706
  };
707
707
  Mongo.prototype.setUserDeactivated = function (userId, deactivated) {
708
- return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
708
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
709
709
  var id;
710
710
  var _a;
711
- return (0, tslib_1.__generator)(this, function (_b) {
711
+ return tslib_1.__generator(this, function (_b) {
712
712
  switch (_b.label) {
713
713
  case 0:
714
714
  id = this.options.convertUserIdToMongoObjectId
@@ -770,14 +770,14 @@ var Mongo = /** @class */ (function () {
770
770
  };
771
771
  Mongo.prototype.createSession = function (userId, token, connection, extraData) {
772
772
  if (connection === void 0) { connection = {}; }
773
- return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
773
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
774
774
  var infos, session, ret;
775
775
  var _a;
776
- return (0, tslib_1.__generator)(this, function (_b) {
776
+ return tslib_1.__generator(this, function (_b) {
777
777
  switch (_b.label) {
778
778
  case 0:
779
779
  infos = this.resolveInfo(connection);
780
- session = (0, tslib_1.__assign)((0, tslib_1.__assign)({ userId: userId, token: token }, infos), (_a = { extraData: extraData, valid: true }, _a[this.options.timestamps.createdAt] = this.options.dateProvider(), _a[this.options.timestamps.updatedAt] = this.options.dateProvider(), _a));
780
+ session = tslib_1.__assign(tslib_1.__assign({ userId: userId, token: token }, infos), (_a = { extraData: extraData, valid: true }, _a[this.options.timestamps.createdAt] = this.options.dateProvider(), _a[this.options.timestamps.updatedAt] = this.options.dateProvider(), _a));
781
781
  if (this.options.idProvider) {
782
782
  session._id = this.options.idProvider();
783
783
  }
@@ -793,10 +793,10 @@ var Mongo = /** @class */ (function () {
793
793
  });
794
794
  };
795
795
  Mongo.prototype.updateSession = function (sessionId, connection) {
796
- return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
796
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
797
797
  var _id, infos, _set;
798
798
  var _a;
799
- return (0, tslib_1.__generator)(this, function (_b) {
799
+ return tslib_1.__generator(this, function (_b) {
800
800
  switch (_b.label) {
801
801
  case 0:
802
802
  _id = this.options.convertSessionIdToMongoObjectId
@@ -823,10 +823,10 @@ var Mongo = /** @class */ (function () {
823
823
  });
824
824
  };
825
825
  Mongo.prototype.invalidateSession = function (sessionId) {
826
- return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
826
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
827
827
  var _id, session;
828
828
  var _a;
829
- return (0, tslib_1.__generator)(this, function (_b) {
829
+ return tslib_1.__generator(this, function (_b) {
830
830
  switch (_b.label) {
831
831
  case 0:
832
832
  _id = this.options.convertSessionIdToMongoObjectId
@@ -855,9 +855,9 @@ var Mongo = /** @class */ (function () {
855
855
  });
856
856
  };
857
857
  Mongo.prototype.invalidateAllSessions = function (userId) {
858
- return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
858
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
859
859
  var _a;
860
- return (0, tslib_1.__generator)(this, function (_b) {
860
+ return tslib_1.__generator(this, function (_b) {
861
861
  switch (_b.label) {
862
862
  case 0: return [4 /*yield*/, this.sessionCollection.updateMany({ userId: userId }, {
863
863
  $set: (_a = {
@@ -874,9 +874,9 @@ var Mongo = /** @class */ (function () {
874
874
  });
875
875
  };
876
876
  Mongo.prototype.findSessionByToken = function (token) {
877
- return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
877
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
878
878
  var session;
879
- return (0, tslib_1.__generator)(this, function (_a) {
879
+ return tslib_1.__generator(this, function (_a) {
880
880
  switch (_a.label) {
881
881
  case 0: return [4 /*yield*/, this.sessionCollection.findOne({ token: token })];
882
882
  case 1:
@@ -890,9 +890,9 @@ var Mongo = /** @class */ (function () {
890
890
  });
891
891
  };
892
892
  Mongo.prototype.findSessionById = function (sessionId) {
893
- return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
893
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
894
894
  var _id, session;
895
- return (0, tslib_1.__generator)(this, function (_a) {
895
+ return tslib_1.__generator(this, function (_a) {
896
896
  switch (_a.label) {
897
897
  case 0:
898
898
  _id = this.options.convertSessionIdToMongoObjectId
@@ -910,9 +910,9 @@ var Mongo = /** @class */ (function () {
910
910
  });
911
911
  };
912
912
  Mongo.prototype.addEmailVerificationToken = function (userId, email, token) {
913
- return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
913
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
914
914
  var _id;
915
- return (0, tslib_1.__generator)(this, function (_a) {
915
+ return tslib_1.__generator(this, function (_a) {
916
916
  switch (_a.label) {
917
917
  case 0:
918
918
  _id = this.options.convertUserIdToMongoObjectId
@@ -935,9 +935,9 @@ var Mongo = /** @class */ (function () {
935
935
  });
936
936
  };
937
937
  Mongo.prototype.addResetPasswordToken = function (userId, email, token, reason) {
938
- return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
938
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
939
939
  var _id;
940
- return (0, tslib_1.__generator)(this, function (_a) {
940
+ return tslib_1.__generator(this, function (_a) {
941
941
  switch (_a.label) {
942
942
  case 0:
943
943
  _id = this.options.convertUserIdToMongoObjectId
@@ -961,8 +961,8 @@ var Mongo = /** @class */ (function () {
961
961
  });
962
962
  };
963
963
  Mongo.prototype.setResetPassword = function (userId, email, newPassword) {
964
- return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
965
- return (0, tslib_1.__generator)(this, function (_a) {
964
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
965
+ return tslib_1.__generator(this, function (_a) {
966
966
  switch (_a.label) {
967
967
  case 0: return [4 /*yield*/, this.setPassword(userId, newPassword)];
968
968
  case 1:
@@ -973,10 +973,10 @@ var Mongo = /** @class */ (function () {
973
973
  });
974
974
  };
975
975
  Mongo.prototype.applyCode = function (name, owner, nextCode, MAX_FAILURE_COUNT, EFFECTIVE_TIME) {
976
- return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
976
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
977
977
  var now, query, record, doc, result;
978
978
  var _a;
979
- return (0, tslib_1.__generator)(this, function (_b) {
979
+ return tslib_1.__generator(this, function (_b) {
980
980
  switch (_b.label) {
981
981
  case 0:
982
982
  now = new Date();
@@ -1016,9 +1016,9 @@ var Mongo = /** @class */ (function () {
1016
1016
  });
1017
1017
  };
1018
1018
  Mongo.prototype.addVerificationCode = function (user, code, options) {
1019
- return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
1019
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
1020
1020
  var foundedUser, owner, ret;
1021
- return (0, tslib_1.__generator)(this, function (_a) {
1021
+ return tslib_1.__generator(this, function (_a) {
1022
1022
  switch (_a.label) {
1023
1023
  case 0:
1024
1024
  foundedUser = null;
@@ -1044,9 +1044,9 @@ var Mongo = /** @class */ (function () {
1044
1044
  });
1045
1045
  };
1046
1046
  Mongo.prototype.verifyCodeByName = function (name, code) {
1047
- return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
1047
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
1048
1048
  var now, query, result;
1049
- return (0, tslib_1.__generator)(this, function (_a) {
1049
+ return tslib_1.__generator(this, function (_a) {
1050
1050
  switch (_a.label) {
1051
1051
  case 0:
1052
1052
  now = new Date();
@@ -1070,9 +1070,9 @@ var Mongo = /** @class */ (function () {
1070
1070
  });
1071
1071
  };
1072
1072
  Mongo.prototype.verifyCodeByOwner = function (owner, code) {
1073
- return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
1073
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
1074
1074
  var now, query, result;
1075
- return (0, tslib_1.__generator)(this, function (_a) {
1075
+ return tslib_1.__generator(this, function (_a) {
1076
1076
  switch (_a.label) {
1077
1077
  case 0:
1078
1078
  now = new Date();
@@ -1098,9 +1098,9 @@ var Mongo = /** @class */ (function () {
1098
1098
  });
1099
1099
  };
1100
1100
  Mongo.prototype.checkVerificationCode = function (user, code) {
1101
- return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
1101
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
1102
1102
  var name, record;
1103
- return (0, tslib_1.__generator)(this, function (_a) {
1103
+ return tslib_1.__generator(this, function (_a) {
1104
1104
  switch (_a.label) {
1105
1105
  case 0:
1106
1106
  name = null;
@@ -1121,9 +1121,9 @@ var Mongo = /** @class */ (function () {
1121
1121
  });
1122
1122
  };
1123
1123
  Mongo.prototype.findUserByVerificationCode = function (user, code) {
1124
- return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
1124
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
1125
1125
  var foundedUser, owner, record;
1126
- return (0, tslib_1.__generator)(this, function (_a) {
1126
+ return tslib_1.__generator(this, function (_a) {
1127
1127
  switch (_a.label) {
1128
1128
  case 0:
1129
1129
  foundedUser = null;
@@ -1170,9 +1170,9 @@ var Mongo = /** @class */ (function () {
1170
1170
  });
1171
1171
  };
1172
1172
  Mongo.prototype.getMySpaces = function (userId) {
1173
- return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
1173
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
1174
1174
  var userSpaces, spaceIds, spaces;
1175
- return (0, tslib_1.__generator)(this, function (_a) {
1175
+ return tslib_1.__generator(this, function (_a) {
1176
1176
  switch (_a.label) {
1177
1177
  case 0: return [4 /*yield*/, this.db
1178
1178
  .collection("space_users")
@@ -1195,9 +1195,9 @@ var Mongo = /** @class */ (function () {
1195
1195
  });
1196
1196
  };
1197
1197
  Mongo.prototype.updateMeteorSession = function (userId, token, infos) {
1198
- return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
1198
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
1199
1199
  var when, login_expiration_in_days, is_phone, is_tablet, stampedAuthToken, hashedToken, _user, data;
1200
- return (0, tslib_1.__generator)(this, function (_a) {
1200
+ return tslib_1.__generator(this, function (_a) {
1201
1201
  switch (_a.label) {
1202
1202
  case 0:
1203
1203
  when = new Date();
@@ -1240,9 +1240,9 @@ var Mongo = /** @class */ (function () {
1240
1240
  });
1241
1241
  };
1242
1242
  Mongo.prototype.destroyMeteorToken = function (userId, token) {
1243
- return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
1243
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
1244
1244
  var stampedAuthToken, hashedTokenDoc, loginToken;
1245
- return (0, tslib_1.__generator)(this, function (_a) {
1245
+ return tslib_1.__generator(this, function (_a) {
1246
1246
  switch (_a.label) {
1247
1247
  case 0:
1248
1248
  stampedAuthToken = {
@@ -1266,8 +1266,8 @@ var Mongo = /** @class */ (function () {
1266
1266
  });
1267
1267
  };
1268
1268
  Mongo.prototype.getInviteInfo = function (id) {
1269
- return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
1270
- return (0, tslib_1.__generator)(this, function (_a) {
1269
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
1270
+ return tslib_1.__generator(this, function (_a) {
1271
1271
  switch (_a.label) {
1272
1272
  case 0: return [4 /*yield*/, this.inviteCollection.findOne({ _id: id })];
1273
1273
  case 1: return [2 /*return*/, _a.sent()];
@@ -1276,8 +1276,8 @@ var Mongo = /** @class */ (function () {
1276
1276
  });
1277
1277
  };
1278
1278
  Mongo.prototype.updateUser = function (userId, options) {
1279
- return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
1280
- return (0, tslib_1.__generator)(this, function (_a) {
1279
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
1280
+ return tslib_1.__generator(this, function (_a) {
1281
1281
  return [2 /*return*/, this.collection.updateOne({ _id: userId }, options)];
1282
1282
  });
1283
1283
  });