@steedos/accounts 2.1.78 → 2.1.84
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/lib/core/index.js +47 -35
- package/lib/core/index.js.map +1 -1
- package/lib/database-mongo/mongo.js +97 -98
- package/lib/database-mongo/mongo.js.map +1 -1
- package/lib/db.js +1 -1
- package/lib/db.js.map +1 -1
- package/lib/index.js +16 -16
- package/lib/index.js.map +1 -1
- package/lib/mail.js +5 -4
- package/lib/mail.js.map +1 -1
- package/lib/oauth2/consent.js +3 -3
- package/lib/oauth2/consent.js.map +1 -1
- package/lib/oauth2/login.js +2 -2
- package/lib/oauth2/login.js.map +1 -1
- package/lib/oauth2/stub/oidc-cert.js +5 -3
- package/lib/oauth2/stub/oidc-cert.js.map +1 -1
- package/lib/password/accounts-password.js +77 -77
- package/lib/password/accounts-password.js.map +1 -1
- package/lib/password/index.js +1 -1
- package/lib/password/index.js.map +1 -1
- package/lib/password/utils/encryption.js +8 -5
- package/lib/password/utils/encryption.js.map +1 -1
- package/lib/password/utils/index.js +1 -0
- package/lib/password/utils/index.js.map +1 -1
- package/lib/password/utils/is-email.js +2 -1
- package/lib/password/utils/is-email.js.map +1 -1
- package/lib/password/utils/user.js +6 -4
- package/lib/password/utils/user.js.map +1 -1
- package/lib/rest-express/endpoints/authorize.js +14 -13
- package/lib/rest-express/endpoints/authorize.js.map +1 -1
- package/lib/rest-express/endpoints/get-user.js +4 -3
- package/lib/rest-express/endpoints/get-user.js.map +1 -1
- package/lib/rest-express/endpoints/impersonate.js +5 -4
- package/lib/rest-express/endpoints/impersonate.js.map +1 -1
- package/lib/rest-express/endpoints/initServer.js +3 -3
- package/lib/rest-express/endpoints/initServer.js.map +1 -1
- package/lib/rest-express/endpoints/login.js +6 -5
- package/lib/rest-express/endpoints/login.js.map +1 -1
- package/lib/rest-express/endpoints/logout.js +7 -6
- package/lib/rest-express/endpoints/logout.js.map +1 -1
- package/lib/rest-express/endpoints/oauth/provider-callback.js +6 -5
- package/lib/rest-express/endpoints/oauth/provider-callback.js.map +1 -1
- package/lib/rest-express/endpoints/password/change-password.js +7 -6
- package/lib/rest-express/endpoints/password/change-password.js.map +1 -1
- package/lib/rest-express/endpoints/password/register.js +7 -6
- package/lib/rest-express/endpoints/password/register.js.map +1 -1
- package/lib/rest-express/endpoints/password/reset.js +10 -8
- package/lib/rest-express/endpoints/password/reset.js.map +1 -1
- package/lib/rest-express/endpoints/password/two-factor.js +12 -9
- package/lib/rest-express/endpoints/password/two-factor.js.map +1 -1
- package/lib/rest-express/endpoints/password/verify-email.js +12 -9
- package/lib/rest-express/endpoints/password/verify-email.js.map +1 -1
- package/lib/rest-express/endpoints/password/verify.js +8 -6
- package/lib/rest-express/endpoints/password/verify.js.map +1 -1
- package/lib/rest-express/endpoints/put-user-name.js +4 -3
- package/lib/rest-express/endpoints/put-user-name.js.map +1 -1
- package/lib/rest-express/endpoints/refresh-access-token.js +5 -4
- package/lib/rest-express/endpoints/refresh-access-token.js.map +1 -1
- package/lib/rest-express/endpoints/service-authenticate.js +9 -8
- package/lib/rest-express/endpoints/service-authenticate.js.map +1 -1
- package/lib/rest-express/endpoints/spaces.js +3 -2
- package/lib/rest-express/endpoints/spaces.js.map +1 -1
- package/lib/rest-express/endpoints/steedos/create-tenant.js +4 -3
- package/lib/rest-express/endpoints/steedos/create-tenant.js.map +1 -1
- package/lib/rest-express/endpoints/steedos/get-tenant.js +6 -5
- package/lib/rest-express/endpoints/steedos/get-tenant.js.map +1 -1
- package/lib/rest-express/endpoints/steedos/settings.js +8 -7
- package/lib/rest-express/endpoints/steedos/settings.js.map +1 -1
- package/lib/rest-express/endpoints/update-session.js +8 -7
- package/lib/rest-express/endpoints/update-session.js.map +1 -1
- package/lib/rest-express/express-middleware.js +24 -24
- package/lib/rest-express/express-middleware.js.map +1 -1
- package/lib/rest-express/index.js +1 -0
- package/lib/rest-express/index.js.map +1 -1
- package/lib/rest-express/user-loader.js +10 -9
- package/lib/rest-express/user-loader.js.map +1 -1
- package/lib/rest-express/utils/get-user-agent.js +2 -1
- package/lib/rest-express/utils/get-user-agent.js.map +1 -1
- package/lib/rest-express/utils/send-error.js +2 -1
- package/lib/rest-express/utils/send-error.js.map +1 -1
- package/lib/rest-express/utils/steedos-auth.js +12 -7
- package/lib/rest-express/utils/steedos-auth.js.map +1 -1
- package/lib/rest-express/utils/users.js +7 -5
- package/lib/rest-express/utils/users.js.map +1 -1
- package/lib/saml-idp/config.js +13 -0
- package/lib/saml-idp/config.js.map +1 -1
- package/lib/saml-idp/express-middleware.js +15 -18
- package/lib/saml-idp/express-middleware.js.map +1 -1
- package/lib/server/accounts-server.js +37 -37
- package/lib/server/accounts-server.js.map +1 -1
- package/lib/server/index.js +1 -1
- package/lib/server/utils/email.js +11 -10
- package/lib/server/utils/email.js.map +1 -1
- package/lib/server/utils/get-first-user-email.js +2 -2
- package/lib/server/utils/get-first-user-email.js.map +1 -1
- package/lib/server/utils/tokens.js +11 -6
- package/lib/server/utils/tokens.js.map +1 -1
- package/lib/types/index.js +14 -14
- package/lib/types/index.js.map +1 -1
- package/package.json +6 -7
|
@@ -30,7 +30,7 @@ var defaultOptions = {
|
|
|
30
30
|
};
|
|
31
31
|
var Mongo = /** @class */ (function () {
|
|
32
32
|
function Mongo(db, options) {
|
|
33
|
-
this.options = lodash_1.merge(tslib_1.__assign({}, defaultOptions), options);
|
|
33
|
+
this.options = (0, lodash_1.merge)((0, tslib_1.__assign)({}, defaultOptions), options);
|
|
34
34
|
if (!db) {
|
|
35
35
|
throw new Error("A database connection is required");
|
|
36
36
|
}
|
|
@@ -42,9 +42,9 @@ var Mongo = /** @class */ (function () {
|
|
|
42
42
|
this.spaceUserCollection = this.db.collection(this.options.spaceUserCollectionName);
|
|
43
43
|
}
|
|
44
44
|
Mongo.prototype.findValidSessionsByUserId = function (userId, is_phone) {
|
|
45
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
45
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
46
46
|
var query, sessions;
|
|
47
|
-
return tslib_1.__generator(this, function (_a) {
|
|
47
|
+
return (0, tslib_1.__generator)(this, function (_a) {
|
|
48
48
|
switch (_a.label) {
|
|
49
49
|
case 0:
|
|
50
50
|
query = {
|
|
@@ -74,8 +74,8 @@ var Mongo = /** @class */ (function () {
|
|
|
74
74
|
});
|
|
75
75
|
};
|
|
76
76
|
Mongo.prototype.setupIndexes = function () {
|
|
77
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
78
|
-
return tslib_1.__generator(this, function (_a) {
|
|
77
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
78
|
+
return (0, tslib_1.__generator)(this, function (_a) {
|
|
79
79
|
switch (_a.label) {
|
|
80
80
|
case 0: return [4 /*yield*/, this.sessionCollection.createIndex("token", {
|
|
81
81
|
unique: true,
|
|
@@ -101,14 +101,14 @@ var Mongo = /** @class */ (function () {
|
|
|
101
101
|
});
|
|
102
102
|
};
|
|
103
103
|
Mongo.prototype.createUser = function (_a) {
|
|
104
|
-
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"]);
|
|
105
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
104
|
+
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"]);
|
|
105
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
106
106
|
var user, ret;
|
|
107
107
|
var _b;
|
|
108
|
-
return tslib_1.__generator(this, function (_c) {
|
|
108
|
+
return (0, tslib_1.__generator)(this, function (_c) {
|
|
109
109
|
switch (_c.label) {
|
|
110
110
|
case 0:
|
|
111
|
-
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));
|
|
111
|
+
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
112
|
if (password) {
|
|
113
113
|
user.services.password = { bcrypt: password };
|
|
114
114
|
}
|
|
@@ -139,9 +139,9 @@ var Mongo = /** @class */ (function () {
|
|
|
139
139
|
});
|
|
140
140
|
};
|
|
141
141
|
Mongo.prototype.findUserById = function (userId) {
|
|
142
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
142
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
143
143
|
var id, user;
|
|
144
|
-
return tslib_1.__generator(this, function (_a) {
|
|
144
|
+
return (0, tslib_1.__generator)(this, function (_a) {
|
|
145
145
|
switch (_a.label) {
|
|
146
146
|
case 0:
|
|
147
147
|
id = this.options.convertUserIdToMongoObjectId
|
|
@@ -159,9 +159,9 @@ var Mongo = /** @class */ (function () {
|
|
|
159
159
|
});
|
|
160
160
|
};
|
|
161
161
|
Mongo.prototype.findUserByEmail = function (email) {
|
|
162
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
162
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
163
163
|
var user;
|
|
164
|
-
return tslib_1.__generator(this, function (_a) {
|
|
164
|
+
return (0, tslib_1.__generator)(this, function (_a) {
|
|
165
165
|
switch (_a.label) {
|
|
166
166
|
case 0: return [4 /*yield*/, this.collection.findOne({
|
|
167
167
|
email: email.toLowerCase(),
|
|
@@ -177,9 +177,9 @@ var Mongo = /** @class */ (function () {
|
|
|
177
177
|
});
|
|
178
178
|
};
|
|
179
179
|
Mongo.prototype.findUserByMobile = function (mobile) {
|
|
180
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
180
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
181
181
|
var user;
|
|
182
|
-
return tslib_1.__generator(this, function (_a) {
|
|
182
|
+
return (0, tslib_1.__generator)(this, function (_a) {
|
|
183
183
|
switch (_a.label) {
|
|
184
184
|
case 0: return [4 /*yield*/, this.collection.findOne({
|
|
185
185
|
mobile: mobile,
|
|
@@ -195,15 +195,15 @@ var Mongo = /** @class */ (function () {
|
|
|
195
195
|
});
|
|
196
196
|
};
|
|
197
197
|
Mongo.prototype.findUserByUsername = function (username) {
|
|
198
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
198
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
199
199
|
var filter, user;
|
|
200
|
-
return tslib_1.__generator(this, function (_a) {
|
|
200
|
+
return (0, tslib_1.__generator)(this, function (_a) {
|
|
201
201
|
switch (_a.label) {
|
|
202
202
|
case 0:
|
|
203
203
|
filter = this.options.caseSensitiveUserName
|
|
204
204
|
? { username: username }
|
|
205
205
|
: {
|
|
206
|
-
$where: "obj.username && (obj.username.toLowerCase() === \""
|
|
206
|
+
$where: "obj.username && (obj.username.toLowerCase() === \"".concat(username.toLowerCase(), "\")"),
|
|
207
207
|
};
|
|
208
208
|
return [4 /*yield*/, this.collection.findOne(filter)];
|
|
209
209
|
case 1:
|
|
@@ -217,15 +217,15 @@ var Mongo = /** @class */ (function () {
|
|
|
217
217
|
});
|
|
218
218
|
};
|
|
219
219
|
Mongo.prototype.findPasswordHash = function (userId) {
|
|
220
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
220
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
221
221
|
var user;
|
|
222
|
-
return tslib_1.__generator(this, function (_a) {
|
|
222
|
+
return (0, tslib_1.__generator)(this, function (_a) {
|
|
223
223
|
switch (_a.label) {
|
|
224
224
|
case 0: return [4 /*yield*/, this.findUserById(userId)];
|
|
225
225
|
case 1:
|
|
226
226
|
user = _a.sent();
|
|
227
227
|
if (user) {
|
|
228
|
-
return [2 /*return*/, lodash_1.get(user, "services.password.bcrypt")];
|
|
228
|
+
return [2 /*return*/, (0, lodash_1.get)(user, "services.password.bcrypt")];
|
|
229
229
|
}
|
|
230
230
|
return [2 /*return*/, null];
|
|
231
231
|
}
|
|
@@ -233,9 +233,9 @@ var Mongo = /** @class */ (function () {
|
|
|
233
233
|
});
|
|
234
234
|
};
|
|
235
235
|
Mongo.prototype.findUserByEmailVerificationToken = function (token) {
|
|
236
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
236
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
237
237
|
var user;
|
|
238
|
-
return tslib_1.__generator(this, function (_a) {
|
|
238
|
+
return (0, tslib_1.__generator)(this, function (_a) {
|
|
239
239
|
switch (_a.label) {
|
|
240
240
|
case 0: return [4 /*yield*/, this.collection.findOne({
|
|
241
241
|
"services.email.verificationTokens.token": token,
|
|
@@ -251,9 +251,9 @@ var Mongo = /** @class */ (function () {
|
|
|
251
251
|
});
|
|
252
252
|
};
|
|
253
253
|
Mongo.prototype.findUserByResetPasswordToken = function (token) {
|
|
254
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
254
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
255
255
|
var user;
|
|
256
|
-
return tslib_1.__generator(this, function (_a) {
|
|
256
|
+
return (0, tslib_1.__generator)(this, function (_a) {
|
|
257
257
|
switch (_a.label) {
|
|
258
258
|
case 0: return [4 /*yield*/, this.collection.findOne({
|
|
259
259
|
"services.password.reset.token": token,
|
|
@@ -269,13 +269,13 @@ var Mongo = /** @class */ (function () {
|
|
|
269
269
|
});
|
|
270
270
|
};
|
|
271
271
|
Mongo.prototype.findUserByServiceId = function (serviceName, serviceId) {
|
|
272
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
272
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
273
273
|
var user;
|
|
274
274
|
var _a;
|
|
275
|
-
return tslib_1.__generator(this, function (_b) {
|
|
275
|
+
return (0, tslib_1.__generator)(this, function (_b) {
|
|
276
276
|
switch (_b.label) {
|
|
277
277
|
case 0: return [4 /*yield*/, this.collection.findOne((_a = {},
|
|
278
|
-
_a["services."
|
|
278
|
+
_a["services.".concat(serviceName, ".id")] = serviceId,
|
|
279
279
|
_a))];
|
|
280
280
|
case 1:
|
|
281
281
|
user = _b.sent();
|
|
@@ -300,10 +300,10 @@ var Mongo = /** @class */ (function () {
|
|
|
300
300
|
// return user;
|
|
301
301
|
// }
|
|
302
302
|
Mongo.prototype.addEmail = function (userId, newEmail, verified) {
|
|
303
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
303
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
304
304
|
var id, ret;
|
|
305
305
|
var _a;
|
|
306
|
-
return tslib_1.__generator(this, function (_b) {
|
|
306
|
+
return (0, tslib_1.__generator)(this, function (_b) {
|
|
307
307
|
switch (_b.label) {
|
|
308
308
|
case 0:
|
|
309
309
|
id = this.options.convertUserIdToMongoObjectId
|
|
@@ -331,10 +331,10 @@ var Mongo = /** @class */ (function () {
|
|
|
331
331
|
});
|
|
332
332
|
};
|
|
333
333
|
Mongo.prototype.removeEmail = function (userId, email) {
|
|
334
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
334
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
335
335
|
var id, ret;
|
|
336
336
|
var _a;
|
|
337
|
-
return tslib_1.__generator(this, function (_b) {
|
|
337
|
+
return (0, tslib_1.__generator)(this, function (_b) {
|
|
338
338
|
switch (_b.label) {
|
|
339
339
|
case 0:
|
|
340
340
|
id = this.options.convertUserIdToMongoObjectId
|
|
@@ -357,10 +357,10 @@ var Mongo = /** @class */ (function () {
|
|
|
357
357
|
});
|
|
358
358
|
};
|
|
359
359
|
Mongo.prototype.verifyEmail = function (userId, email) {
|
|
360
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
360
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
361
361
|
var id, ret;
|
|
362
362
|
var _a;
|
|
363
|
-
return tslib_1.__generator(this, function (_b) {
|
|
363
|
+
return (0, tslib_1.__generator)(this, function (_b) {
|
|
364
364
|
switch (_b.label) {
|
|
365
365
|
case 0:
|
|
366
366
|
id = this.options.convertUserIdToMongoObjectId
|
|
@@ -396,10 +396,10 @@ var Mongo = /** @class */ (function () {
|
|
|
396
396
|
});
|
|
397
397
|
};
|
|
398
398
|
Mongo.prototype.verifyMobile = function (userId, mobile) {
|
|
399
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
399
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
400
400
|
var id, ret;
|
|
401
401
|
var _a;
|
|
402
|
-
return tslib_1.__generator(this, function (_b) {
|
|
402
|
+
return (0, tslib_1.__generator)(this, function (_b) {
|
|
403
403
|
switch (_b.label) {
|
|
404
404
|
case 0:
|
|
405
405
|
id = this.options.convertUserIdToMongoObjectId
|
|
@@ -435,10 +435,10 @@ var Mongo = /** @class */ (function () {
|
|
|
435
435
|
});
|
|
436
436
|
};
|
|
437
437
|
Mongo.prototype.setMobile = function (userId, newMobile) {
|
|
438
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
438
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
439
439
|
var id, existed, user, ret;
|
|
440
440
|
var _a;
|
|
441
|
-
return tslib_1.__generator(this, function (_b) {
|
|
441
|
+
return (0, tslib_1.__generator)(this, function (_b) {
|
|
442
442
|
switch (_b.label) {
|
|
443
443
|
case 0:
|
|
444
444
|
id = this.options.convertUserIdToMongoObjectId
|
|
@@ -488,10 +488,10 @@ var Mongo = /** @class */ (function () {
|
|
|
488
488
|
});
|
|
489
489
|
};
|
|
490
490
|
Mongo.prototype.setEmail = function (userId, newEmail) {
|
|
491
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
491
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
492
492
|
var id, existed, user, ret;
|
|
493
493
|
var _a;
|
|
494
|
-
return tslib_1.__generator(this, function (_b) {
|
|
494
|
+
return (0, tslib_1.__generator)(this, function (_b) {
|
|
495
495
|
switch (_b.label) {
|
|
496
496
|
case 0:
|
|
497
497
|
id = this.options.convertUserIdToMongoObjectId
|
|
@@ -541,10 +541,10 @@ var Mongo = /** @class */ (function () {
|
|
|
541
541
|
});
|
|
542
542
|
};
|
|
543
543
|
Mongo.prototype.setUsername = function (userId, newUsername) {
|
|
544
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
544
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
545
545
|
var id, ret;
|
|
546
546
|
var _a;
|
|
547
|
-
return tslib_1.__generator(this, function (_b) {
|
|
547
|
+
return (0, tslib_1.__generator)(this, function (_b) {
|
|
548
548
|
switch (_b.label) {
|
|
549
549
|
case 0:
|
|
550
550
|
id = this.options.convertUserIdToMongoObjectId
|
|
@@ -568,10 +568,10 @@ var Mongo = /** @class */ (function () {
|
|
|
568
568
|
});
|
|
569
569
|
};
|
|
570
570
|
Mongo.prototype.setPassword = function (userId, newPassword) {
|
|
571
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
571
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
572
572
|
var id, ret;
|
|
573
573
|
var _a;
|
|
574
|
-
return tslib_1.__generator(this, function (_b) {
|
|
574
|
+
return (0, tslib_1.__generator)(this, function (_b) {
|
|
575
575
|
switch (_b.label) {
|
|
576
576
|
case 0:
|
|
577
577
|
id = this.options.convertUserIdToMongoObjectId
|
|
@@ -601,10 +601,10 @@ var Mongo = /** @class */ (function () {
|
|
|
601
601
|
});
|
|
602
602
|
};
|
|
603
603
|
Mongo.prototype.setService = function (userId, serviceName, service) {
|
|
604
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
604
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
605
605
|
var id;
|
|
606
606
|
var _a;
|
|
607
|
-
return tslib_1.__generator(this, function (_b) {
|
|
607
|
+
return (0, tslib_1.__generator)(this, function (_b) {
|
|
608
608
|
switch (_b.label) {
|
|
609
609
|
case 0:
|
|
610
610
|
id = this.options.convertUserIdToMongoObjectId
|
|
@@ -612,7 +612,7 @@ var Mongo = /** @class */ (function () {
|
|
|
612
612
|
: userId;
|
|
613
613
|
return [4 /*yield*/, this.collection.updateOne({ _id: id }, {
|
|
614
614
|
$set: (_a = {},
|
|
615
|
-
_a["services."
|
|
615
|
+
_a["services.".concat(serviceName)] = service,
|
|
616
616
|
_a[this.options.timestamps.updatedAt] = this.options.dateProvider(),
|
|
617
617
|
_a),
|
|
618
618
|
})];
|
|
@@ -624,10 +624,10 @@ var Mongo = /** @class */ (function () {
|
|
|
624
624
|
});
|
|
625
625
|
};
|
|
626
626
|
Mongo.prototype.unsetService = function (userId, serviceName) {
|
|
627
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
627
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
628
628
|
var id;
|
|
629
629
|
var _a, _b;
|
|
630
|
-
return tslib_1.__generator(this, function (_c) {
|
|
630
|
+
return (0, tslib_1.__generator)(this, function (_c) {
|
|
631
631
|
switch (_c.label) {
|
|
632
632
|
case 0:
|
|
633
633
|
id = this.options.convertUserIdToMongoObjectId
|
|
@@ -638,7 +638,7 @@ var Mongo = /** @class */ (function () {
|
|
|
638
638
|
_a[this.options.timestamps.updatedAt] = this.options.dateProvider(),
|
|
639
639
|
_a),
|
|
640
640
|
$unset: (_b = {},
|
|
641
|
-
_b["services."
|
|
641
|
+
_b["services.".concat(serviceName)] = "",
|
|
642
642
|
_b),
|
|
643
643
|
})];
|
|
644
644
|
case 1:
|
|
@@ -649,10 +649,10 @@ var Mongo = /** @class */ (function () {
|
|
|
649
649
|
});
|
|
650
650
|
};
|
|
651
651
|
Mongo.prototype.setUserDeactivated = function (userId, deactivated) {
|
|
652
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
652
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
653
653
|
var id;
|
|
654
654
|
var _a;
|
|
655
|
-
return tslib_1.__generator(this, function (_b) {
|
|
655
|
+
return (0, tslib_1.__generator)(this, function (_b) {
|
|
656
656
|
switch (_b.label) {
|
|
657
657
|
case 0:
|
|
658
658
|
id = this.options.convertUserIdToMongoObjectId
|
|
@@ -711,15 +711,14 @@ var Mongo = /** @class */ (function () {
|
|
|
711
711
|
};
|
|
712
712
|
Mongo.prototype.createSession = function (userId, token, connection, extraData) {
|
|
713
713
|
if (connection === void 0) { connection = {}; }
|
|
714
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
714
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
715
715
|
var infos, session, ret;
|
|
716
716
|
var _a;
|
|
717
|
-
return tslib_1.__generator(this, function (_b) {
|
|
717
|
+
return (0, tslib_1.__generator)(this, function (_b) {
|
|
718
718
|
switch (_b.label) {
|
|
719
719
|
case 0:
|
|
720
720
|
infos = this.resolveInfo(connection);
|
|
721
|
-
session = tslib_1.__assign(tslib_1.__assign({ userId: userId,
|
|
722
|
-
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));
|
|
721
|
+
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));
|
|
723
722
|
if (this.options.idProvider) {
|
|
724
723
|
session._id = this.options.idProvider();
|
|
725
724
|
}
|
|
@@ -735,10 +734,10 @@ var Mongo = /** @class */ (function () {
|
|
|
735
734
|
});
|
|
736
735
|
};
|
|
737
736
|
Mongo.prototype.updateSession = function (sessionId, connection) {
|
|
738
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
737
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
739
738
|
var _id, infos, _set;
|
|
740
739
|
var _a;
|
|
741
|
-
return tslib_1.__generator(this, function (_b) {
|
|
740
|
+
return (0, tslib_1.__generator)(this, function (_b) {
|
|
742
741
|
switch (_b.label) {
|
|
743
742
|
case 0:
|
|
744
743
|
_id = this.options.convertSessionIdToMongoObjectId
|
|
@@ -765,10 +764,10 @@ var Mongo = /** @class */ (function () {
|
|
|
765
764
|
});
|
|
766
765
|
};
|
|
767
766
|
Mongo.prototype.invalidateSession = function (sessionId) {
|
|
768
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
767
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
769
768
|
var _id, session;
|
|
770
769
|
var _a;
|
|
771
|
-
return tslib_1.__generator(this, function (_b) {
|
|
770
|
+
return (0, tslib_1.__generator)(this, function (_b) {
|
|
772
771
|
switch (_b.label) {
|
|
773
772
|
case 0:
|
|
774
773
|
_id = this.options.convertSessionIdToMongoObjectId
|
|
@@ -797,9 +796,9 @@ var Mongo = /** @class */ (function () {
|
|
|
797
796
|
});
|
|
798
797
|
};
|
|
799
798
|
Mongo.prototype.invalidateAllSessions = function (userId) {
|
|
800
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
799
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
801
800
|
var _a;
|
|
802
|
-
return tslib_1.__generator(this, function (_b) {
|
|
801
|
+
return (0, tslib_1.__generator)(this, function (_b) {
|
|
803
802
|
switch (_b.label) {
|
|
804
803
|
case 0: return [4 /*yield*/, this.sessionCollection.updateMany({ userId: userId }, {
|
|
805
804
|
$set: (_a = {
|
|
@@ -816,9 +815,9 @@ var Mongo = /** @class */ (function () {
|
|
|
816
815
|
});
|
|
817
816
|
};
|
|
818
817
|
Mongo.prototype.findSessionByToken = function (token) {
|
|
819
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
818
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
820
819
|
var session;
|
|
821
|
-
return tslib_1.__generator(this, function (_a) {
|
|
820
|
+
return (0, tslib_1.__generator)(this, function (_a) {
|
|
822
821
|
switch (_a.label) {
|
|
823
822
|
case 0: return [4 /*yield*/, this.sessionCollection.findOne({ token: token })];
|
|
824
823
|
case 1:
|
|
@@ -832,9 +831,9 @@ var Mongo = /** @class */ (function () {
|
|
|
832
831
|
});
|
|
833
832
|
};
|
|
834
833
|
Mongo.prototype.findSessionById = function (sessionId) {
|
|
835
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
834
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
836
835
|
var _id, session;
|
|
837
|
-
return tslib_1.__generator(this, function (_a) {
|
|
836
|
+
return (0, tslib_1.__generator)(this, function (_a) {
|
|
838
837
|
switch (_a.label) {
|
|
839
838
|
case 0:
|
|
840
839
|
_id = this.options.convertSessionIdToMongoObjectId
|
|
@@ -852,9 +851,9 @@ var Mongo = /** @class */ (function () {
|
|
|
852
851
|
});
|
|
853
852
|
};
|
|
854
853
|
Mongo.prototype.addEmailVerificationToken = function (userId, email, token) {
|
|
855
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
854
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
856
855
|
var _id;
|
|
857
|
-
return tslib_1.__generator(this, function (_a) {
|
|
856
|
+
return (0, tslib_1.__generator)(this, function (_a) {
|
|
858
857
|
switch (_a.label) {
|
|
859
858
|
case 0:
|
|
860
859
|
_id = this.options.convertUserIdToMongoObjectId
|
|
@@ -877,9 +876,9 @@ var Mongo = /** @class */ (function () {
|
|
|
877
876
|
});
|
|
878
877
|
};
|
|
879
878
|
Mongo.prototype.addResetPasswordToken = function (userId, email, token, reason) {
|
|
880
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
879
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
881
880
|
var _id;
|
|
882
|
-
return tslib_1.__generator(this, function (_a) {
|
|
881
|
+
return (0, tslib_1.__generator)(this, function (_a) {
|
|
883
882
|
switch (_a.label) {
|
|
884
883
|
case 0:
|
|
885
884
|
_id = this.options.convertUserIdToMongoObjectId
|
|
@@ -903,8 +902,8 @@ var Mongo = /** @class */ (function () {
|
|
|
903
902
|
});
|
|
904
903
|
};
|
|
905
904
|
Mongo.prototype.setResetPassword = function (userId, email, newPassword) {
|
|
906
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
907
|
-
return tslib_1.__generator(this, function (_a) {
|
|
905
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
906
|
+
return (0, tslib_1.__generator)(this, function (_a) {
|
|
908
907
|
switch (_a.label) {
|
|
909
908
|
case 0: return [4 /*yield*/, this.setPassword(userId, newPassword)];
|
|
910
909
|
case 1:
|
|
@@ -915,10 +914,10 @@ var Mongo = /** @class */ (function () {
|
|
|
915
914
|
});
|
|
916
915
|
};
|
|
917
916
|
Mongo.prototype.applyCode = function (name, owner, nextCode, MAX_FAILURE_COUNT, EFFECTIVE_TIME) {
|
|
918
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
917
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
919
918
|
var now, query, record, doc, result;
|
|
920
919
|
var _a;
|
|
921
|
-
return tslib_1.__generator(this, function (_b) {
|
|
920
|
+
return (0, tslib_1.__generator)(this, function (_b) {
|
|
922
921
|
switch (_b.label) {
|
|
923
922
|
case 0:
|
|
924
923
|
now = new Date();
|
|
@@ -958,9 +957,9 @@ var Mongo = /** @class */ (function () {
|
|
|
958
957
|
});
|
|
959
958
|
};
|
|
960
959
|
Mongo.prototype.addVerificationCode = function (user, code, options) {
|
|
961
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
960
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
962
961
|
var foundedUser, owner, ret;
|
|
963
|
-
return tslib_1.__generator(this, function (_a) {
|
|
962
|
+
return (0, tslib_1.__generator)(this, function (_a) {
|
|
964
963
|
switch (_a.label) {
|
|
965
964
|
case 0:
|
|
966
965
|
foundedUser = null;
|
|
@@ -986,9 +985,9 @@ var Mongo = /** @class */ (function () {
|
|
|
986
985
|
});
|
|
987
986
|
};
|
|
988
987
|
Mongo.prototype.verifyCodeByName = function (name, code) {
|
|
989
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
988
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
990
989
|
var now, query, result;
|
|
991
|
-
return tslib_1.__generator(this, function (_a) {
|
|
990
|
+
return (0, tslib_1.__generator)(this, function (_a) {
|
|
992
991
|
switch (_a.label) {
|
|
993
992
|
case 0:
|
|
994
993
|
now = new Date();
|
|
@@ -1012,9 +1011,9 @@ var Mongo = /** @class */ (function () {
|
|
|
1012
1011
|
});
|
|
1013
1012
|
};
|
|
1014
1013
|
Mongo.prototype.verifyCodeByOwner = function (owner, code) {
|
|
1015
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
1014
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
1016
1015
|
var now, query, result;
|
|
1017
|
-
return tslib_1.__generator(this, function (_a) {
|
|
1016
|
+
return (0, tslib_1.__generator)(this, function (_a) {
|
|
1018
1017
|
switch (_a.label) {
|
|
1019
1018
|
case 0:
|
|
1020
1019
|
now = new Date();
|
|
@@ -1040,9 +1039,9 @@ var Mongo = /** @class */ (function () {
|
|
|
1040
1039
|
});
|
|
1041
1040
|
};
|
|
1042
1041
|
Mongo.prototype.checkVerificationCode = function (user, code) {
|
|
1043
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
1042
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
1044
1043
|
var name, record;
|
|
1045
|
-
return tslib_1.__generator(this, function (_a) {
|
|
1044
|
+
return (0, tslib_1.__generator)(this, function (_a) {
|
|
1046
1045
|
switch (_a.label) {
|
|
1047
1046
|
case 0:
|
|
1048
1047
|
name = null;
|
|
@@ -1063,9 +1062,9 @@ var Mongo = /** @class */ (function () {
|
|
|
1063
1062
|
});
|
|
1064
1063
|
};
|
|
1065
1064
|
Mongo.prototype.findUserByVerificationCode = function (user, code) {
|
|
1066
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
1065
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
1067
1066
|
var foundedUser, owner, record;
|
|
1068
|
-
return tslib_1.__generator(this, function (_a) {
|
|
1067
|
+
return (0, tslib_1.__generator)(this, function (_a) {
|
|
1069
1068
|
switch (_a.label) {
|
|
1070
1069
|
case 0:
|
|
1071
1070
|
foundedUser = null;
|
|
@@ -1112,9 +1111,9 @@ var Mongo = /** @class */ (function () {
|
|
|
1112
1111
|
});
|
|
1113
1112
|
};
|
|
1114
1113
|
Mongo.prototype.getMySpaces = function (userId) {
|
|
1115
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
1114
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
1116
1115
|
var userSpaces, spaceIds, spaces;
|
|
1117
|
-
return tslib_1.__generator(this, function (_a) {
|
|
1116
|
+
return (0, tslib_1.__generator)(this, function (_a) {
|
|
1118
1117
|
switch (_a.label) {
|
|
1119
1118
|
case 0: return [4 /*yield*/, this.db
|
|
1120
1119
|
.collection("space_users")
|
|
@@ -1123,7 +1122,7 @@ var Mongo = /** @class */ (function () {
|
|
|
1123
1122
|
.toArray()];
|
|
1124
1123
|
case 1:
|
|
1125
1124
|
userSpaces = _a.sent();
|
|
1126
|
-
spaceIds = lodash_1.map(userSpaces, "space");
|
|
1125
|
+
spaceIds = (0, lodash_1.map)(userSpaces, "space");
|
|
1127
1126
|
return [4 /*yield*/, this.db
|
|
1128
1127
|
.collection("spaces")
|
|
1129
1128
|
.find({ _id: { $in: spaceIds } })
|
|
@@ -1137,15 +1136,15 @@ var Mongo = /** @class */ (function () {
|
|
|
1137
1136
|
});
|
|
1138
1137
|
};
|
|
1139
1138
|
Mongo.prototype.updateMeteorSession = function (userId, token, infos) {
|
|
1140
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
1139
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
1141
1140
|
var when, login_expiration_in_days, is_phone, is_tablet, stampedAuthToken, hashedToken, _user, data;
|
|
1142
|
-
return tslib_1.__generator(this, function (_a) {
|
|
1141
|
+
return (0, tslib_1.__generator)(this, function (_a) {
|
|
1143
1142
|
switch (_a.label) {
|
|
1144
1143
|
case 0:
|
|
1145
1144
|
when = new Date();
|
|
1146
1145
|
login_expiration_in_days = infos.login_expiration_in_days, is_phone = infos.is_phone, is_tablet = infos.is_tablet;
|
|
1147
1146
|
if (login_expiration_in_days &&
|
|
1148
|
-
lodash_2.isNumber(login_expiration_in_days) &&
|
|
1147
|
+
(0, lodash_2.isNumber)(login_expiration_in_days) &&
|
|
1149
1148
|
login_expiration_in_days > 0) {
|
|
1150
1149
|
when = moment()
|
|
1151
1150
|
.subtract((90 - login_expiration_in_days) * 24 * 60, "minute")
|
|
@@ -1155,7 +1154,7 @@ var Mongo = /** @class */ (function () {
|
|
|
1155
1154
|
token: token,
|
|
1156
1155
|
when: when,
|
|
1157
1156
|
};
|
|
1158
|
-
hashedToken = auth_1.hashStampedToken(stampedAuthToken);
|
|
1157
|
+
hashedToken = (0, auth_1.hashStampedToken)(stampedAuthToken);
|
|
1159
1158
|
hashedToken.created = new Date();
|
|
1160
1159
|
hashedToken.is_phone = is_phone;
|
|
1161
1160
|
hashedToken.is_tablet = is_tablet;
|
|
@@ -1182,16 +1181,16 @@ var Mongo = /** @class */ (function () {
|
|
|
1182
1181
|
});
|
|
1183
1182
|
};
|
|
1184
1183
|
Mongo.prototype.destroyMeteorToken = function (userId, token) {
|
|
1185
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
1184
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
1186
1185
|
var stampedAuthToken, hashedTokenDoc, loginToken;
|
|
1187
|
-
return tslib_1.__generator(this, function (_a) {
|
|
1186
|
+
return (0, tslib_1.__generator)(this, function (_a) {
|
|
1188
1187
|
switch (_a.label) {
|
|
1189
1188
|
case 0:
|
|
1190
1189
|
stampedAuthToken = {
|
|
1191
1190
|
token: token,
|
|
1192
1191
|
when: new Date(),
|
|
1193
1192
|
};
|
|
1194
|
-
hashedTokenDoc = auth_1.hashStampedToken(stampedAuthToken);
|
|
1193
|
+
hashedTokenDoc = (0, auth_1.hashStampedToken)(stampedAuthToken);
|
|
1195
1194
|
loginToken = hashedTokenDoc.hashedToken;
|
|
1196
1195
|
return [4 /*yield*/, this.collection.updateOne({ _id: userId }, {
|
|
1197
1196
|
$pull: {
|
|
@@ -1208,8 +1207,8 @@ var Mongo = /** @class */ (function () {
|
|
|
1208
1207
|
});
|
|
1209
1208
|
};
|
|
1210
1209
|
Mongo.prototype.getInviteInfo = function (id) {
|
|
1211
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
1212
|
-
return tslib_1.__generator(this, function (_a) {
|
|
1210
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
1211
|
+
return (0, tslib_1.__generator)(this, function (_a) {
|
|
1213
1212
|
switch (_a.label) {
|
|
1214
1213
|
case 0: return [4 /*yield*/, this.inviteCollection.findOne({ _id: id })];
|
|
1215
1214
|
case 1: return [2 /*return*/, _a.sent()];
|
|
@@ -1218,8 +1217,8 @@ var Mongo = /** @class */ (function () {
|
|
|
1218
1217
|
});
|
|
1219
1218
|
};
|
|
1220
1219
|
Mongo.prototype.updateUser = function (userId, options) {
|
|
1221
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
1222
|
-
return tslib_1.__generator(this, function (_a) {
|
|
1220
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
1221
|
+
return (0, tslib_1.__generator)(this, function (_a) {
|
|
1223
1222
|
return [2 /*return*/, this.collection.updateOne({ _id: userId }, options)];
|
|
1224
1223
|
});
|
|
1225
1224
|
});
|