@proteinjs/user-server 1.1.4 → 1.2.0

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.
@@ -0,0 +1,309 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
+ return new (P || (P = Promise))(function (resolve, reject) {
16
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
20
+ });
21
+ };
22
+ var __generator = (this && this.__generator) || function (thisArg, body) {
23
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
+ function verb(n) { return function (v) { return step([n, v]); }; }
26
+ function step(op) {
27
+ if (f) throw new TypeError("Generator is already executing.");
28
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
+ 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;
30
+ if (y = 0, t) op = [op[0] & 2, t.value];
31
+ switch (op[0]) {
32
+ case 0: case 1: t = op; break;
33
+ case 4: _.label++; return { value: op[1], done: false };
34
+ case 5: _.label++; y = op[1]; op = [0]; continue;
35
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
+ default:
37
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
+ if (t[2]) _.ops.pop();
42
+ _.trys.pop(); continue;
43
+ }
44
+ op = body.call(thisArg, _);
45
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
+ }
48
+ };
49
+ var __importDefault = (this && this.__importDefault) || function (mod) {
50
+ return (mod && mod.__esModule) ? mod : { "default": mod };
51
+ };
52
+ Object.defineProperty(exports, "__esModule", { value: true });
53
+ exports.Signup = exports.getDefaultInviteConfigFactory = void 0;
54
+ var db_1 = require("@proteinjs/db");
55
+ var user_1 = require("@proteinjs/user");
56
+ var moment_1 = __importDefault(require("moment"));
57
+ var crypto_js_1 = require("crypto-js");
58
+ var util_1 = require("@proteinjs/util");
59
+ var email_server_1 = require("@proteinjs/email-server");
60
+ var sha256_1 = __importDefault(require("crypto-js/sha256"));
61
+ var reflection_1 = require("@proteinjs/reflection");
62
+ var getDefaultInviteConfigFactory = function () {
63
+ var defaultFactory = {
64
+ getConfig: function () { return ({ isInviteOnly: false }); },
65
+ };
66
+ var factory = reflection_1.SourceRepository.get().object('@proteinjs/user-server/DefaultInviteConfigFactory');
67
+ return factory || defaultFactory;
68
+ };
69
+ exports.getDefaultInviteConfigFactory = getDefaultInviteConfigFactory;
70
+ var Signup = /** @class */ (function () {
71
+ function Signup() {
72
+ this.serviceMetadata = {
73
+ auth: {
74
+ canAccess: function (methodName, args) {
75
+ if (methodName === 'sendInvite' || methodName === 'revokeInvite') {
76
+ user_1.UserAuth.hasRole('admin');
77
+ }
78
+ return true;
79
+ },
80
+ },
81
+ };
82
+ }
83
+ Signup.prototype.createUser = function (user, token) {
84
+ var _a, _b;
85
+ return __awaiter(this, void 0, void 0, function () {
86
+ var logger, db, initSignupResponse, invite, _c, email, defaultEmailConfigFactory, config, emailSender, userRecord, _d, text_1, html_1, _e, text, html;
87
+ return __generator(this, function (_f) {
88
+ switch (_f.label) {
89
+ case 0:
90
+ logger = new util_1.Logger('SignupService: createUser');
91
+ db = (0, db_1.getDbAsSystem)();
92
+ return [4 /*yield*/, this.initializeSignup(token)];
93
+ case 1:
94
+ initSignupResponse = _f.sent();
95
+ if (!initSignupResponse.isReady) {
96
+ throw new Error(initSignupResponse.error);
97
+ }
98
+ if (!token) return [3 /*break*/, 3];
99
+ return [4 /*yield*/, this.getValidInvite(token)];
100
+ case 2:
101
+ _c = _f.sent();
102
+ return [3 /*break*/, 4];
103
+ case 3:
104
+ _c = null;
105
+ _f.label = 4;
106
+ case 4:
107
+ invite = _c;
108
+ if (!token) return [3 /*break*/, 6];
109
+ return [4 /*yield*/, db.delete(user_1.tables.Invite, { token: token })];
110
+ case 5:
111
+ _f.sent();
112
+ _f.label = 6;
113
+ case 6:
114
+ email = invite ? invite.email : user.email;
115
+ if (!email) {
116
+ throw new Error('Email is required when there is no invite');
117
+ }
118
+ defaultEmailConfigFactory = (0, email_server_1.getDefaultSignupConfirmationEmailConfigFactory)();
119
+ config = defaultEmailConfigFactory.getConfig();
120
+ emailSender = new email_server_1.EmailSender();
121
+ return [4 /*yield*/, db.get(user_1.tables.User, { email: email })];
122
+ case 7:
123
+ userRecord = _f.sent();
124
+ if (!userRecord) return [3 /*break*/, 9];
125
+ logger.error("User with this email already exists: ".concat(email));
126
+ _d = config.getExistingUserEmailContent(), text_1 = _d.text, html_1 = _d.html;
127
+ return [4 /*yield*/, emailSender.sendEmail(__assign({ to: email, subject: config.existingUserSubject || ((_a = config.options) === null || _a === void 0 ? void 0 : _a.subject) || 'Account already exists', text: text_1, html: html_1 }, config.options))];
128
+ case 8:
129
+ _f.sent();
130
+ return [2 /*return*/];
131
+ case 9: return [4 /*yield*/, db.insert(user_1.tables.User, {
132
+ name: user.name,
133
+ email: email,
134
+ password: (0, sha256_1.default)(user.password).toString(),
135
+ emailVerified: false,
136
+ roles: '',
137
+ invitedBy: invite ? invite.invitedBy : null,
138
+ })];
139
+ case 10:
140
+ _f.sent();
141
+ _e = config.getNewUserEmailContent(), text = _e.text, html = _e.html;
142
+ return [4 /*yield*/, emailSender.sendEmail(__assign({ to: email, subject: config.newUserSubject || ((_b = config.options) === null || _b === void 0 ? void 0 : _b.subject) || 'Welcome!', text: text, html: html }, config.options))];
143
+ case 11:
144
+ _f.sent();
145
+ logger.info("Created user: ".concat(email));
146
+ return [2 /*return*/];
147
+ }
148
+ });
149
+ });
150
+ };
151
+ Signup.prototype.sendInvite = function (email) {
152
+ var _a;
153
+ return __awaiter(this, void 0, void 0, function () {
154
+ var logger, db, userRecord, emailSender, defaultConfigFactory, config, token, tokenExpiresAt, invite, userId, _b, text, html, error_1;
155
+ return __generator(this, function (_c) {
156
+ switch (_c.label) {
157
+ case 0:
158
+ logger = new util_1.Logger('SignupService: sendInvite');
159
+ _c.label = 1;
160
+ case 1:
161
+ _c.trys.push([1, 9, , 10]);
162
+ db = (0, db_1.getDbAsSystem)();
163
+ return [4 /*yield*/, db.get(user_1.tables.User, { email: email })];
164
+ case 2:
165
+ userRecord = _c.sent();
166
+ if (userRecord) {
167
+ return [2 /*return*/, { sent: false, error: 'User already exists with that email.' }];
168
+ }
169
+ emailSender = new email_server_1.EmailSender();
170
+ defaultConfigFactory = (0, email_server_1.getDefaultInviteEmailConfigFactory)();
171
+ if (!defaultConfigFactory) {
172
+ throw new Error("Unable to find a @proteinjs/email-server/DefaultInviteEmailConfigFactory implementation when sending invite.");
173
+ }
174
+ config = defaultConfigFactory.getConfig();
175
+ token = crypto_js_1.lib.WordArray.random(32).toString();
176
+ tokenExpiresAt = (0, moment_1.default)().add(7, 'days');
177
+ return [4 /*yield*/, db.get(user_1.tables.Invite, { email: email })];
178
+ case 3:
179
+ invite = _c.sent();
180
+ if (!invite) return [3 /*break*/, 5];
181
+ invite = __assign(__assign({}, invite), { token: token, tokenExpiresAt: tokenExpiresAt });
182
+ return [4 /*yield*/, db.update(user_1.tables.Invite, invite)];
183
+ case 4:
184
+ _c.sent();
185
+ return [3 /*break*/, 7];
186
+ case 5:
187
+ userId = new user_1.UserRepo().getUser().id;
188
+ return [4 /*yield*/, db.insert(user_1.tables.Invite, { email: email, token: token, tokenExpiresAt: tokenExpiresAt, invitedBy: userId })];
189
+ case 6:
190
+ invite = _c.sent();
191
+ _c.label = 7;
192
+ case 7:
193
+ _b = config.getEmailContent("".concat(user_1.uiRoutes.auth.signup, "?token=").concat(token)), text = _b.text, html = _b.html;
194
+ return [4 /*yield*/, emailSender.sendEmail(__assign({ to: email, subject: ((_a = config.options) === null || _a === void 0 ? void 0 : _a.subject) || "You're Invited", text: text, html: html }, config.options))];
195
+ case 8:
196
+ _c.sent();
197
+ return [2 /*return*/, { sent: true }];
198
+ case 9:
199
+ error_1 = _c.sent();
200
+ logger.error('Error: ', error_1);
201
+ return [2 /*return*/, {
202
+ sent: false,
203
+ error: 'Error occurred.',
204
+ }];
205
+ case 10: return [2 /*return*/];
206
+ }
207
+ });
208
+ });
209
+ };
210
+ Signup.prototype.revokeInvite = function (email) {
211
+ return __awaiter(this, void 0, void 0, function () {
212
+ var db;
213
+ return __generator(this, function (_a) {
214
+ switch (_a.label) {
215
+ case 0:
216
+ if (!email) {
217
+ throw new Error('No email was provided.');
218
+ }
219
+ db = (0, db_1.getDb)();
220
+ return [4 /*yield*/, db.delete(user_1.tables.Invite, { email: email })];
221
+ case 1:
222
+ _a.sent();
223
+ return [2 /*return*/];
224
+ }
225
+ });
226
+ });
227
+ };
228
+ /**
229
+ * Initializes signup process, validating invite configuration and token if provided.
230
+ * `DefaultInviteConfigFactory` defaults to invite optional.
231
+ */
232
+ Signup.prototype.initializeSignup = function (inviteToken) {
233
+ return __awaiter(this, void 0, void 0, function () {
234
+ var config, isInviteOnly, invite, _a, error_2;
235
+ return __generator(this, function (_b) {
236
+ switch (_b.label) {
237
+ case 0:
238
+ _b.trys.push([0, 4, , 5]);
239
+ config = (0, exports.getDefaultInviteConfigFactory)().getConfig();
240
+ isInviteOnly = config.isInviteOnly;
241
+ if (!inviteToken) return [3 /*break*/, 2];
242
+ return [4 /*yield*/, this.getValidInvite(inviteToken)];
243
+ case 1:
244
+ _a = _b.sent();
245
+ return [3 /*break*/, 3];
246
+ case 2:
247
+ _a = undefined;
248
+ _b.label = 3;
249
+ case 3:
250
+ invite = _a;
251
+ if (isInviteOnly) {
252
+ if (!inviteToken) {
253
+ return [2 /*return*/, {
254
+ isReady: false,
255
+ error: 'An invite is required to sign up.',
256
+ isInviteOnly: isInviteOnly,
257
+ }];
258
+ }
259
+ if (!invite) {
260
+ return [2 /*return*/, {
261
+ isReady: false,
262
+ error: 'The provided invite was not found or has expired.',
263
+ isInviteOnly: isInviteOnly,
264
+ }];
265
+ }
266
+ }
267
+ return [2 /*return*/, {
268
+ isReady: true,
269
+ isInviteOnly: isInviteOnly,
270
+ invite: invite ? invite : undefined,
271
+ }];
272
+ case 4:
273
+ error_2 = _b.sent();
274
+ return [2 /*return*/, {
275
+ isReady: false,
276
+ error: 'Initializing sign up failed.',
277
+ }];
278
+ case 5: return [2 /*return*/];
279
+ }
280
+ });
281
+ });
282
+ };
283
+ /** Returns a valid invite if it exists and is not expired, returns `null` otherwise. */
284
+ Signup.prototype.getValidInvite = function (token) {
285
+ return __awaiter(this, void 0, void 0, function () {
286
+ var db, invite, currentTime;
287
+ return __generator(this, function (_a) {
288
+ switch (_a.label) {
289
+ case 0:
290
+ db = (0, db_1.getDbAsSystem)();
291
+ return [4 /*yield*/, db.get(user_1.tables.Invite, { token: token })];
292
+ case 1:
293
+ invite = _a.sent();
294
+ if (!invite) {
295
+ return [2 /*return*/, null];
296
+ }
297
+ currentTime = (0, moment_1.default)();
298
+ if (invite.tokenExpiresAt && (0, moment_1.default)(invite.tokenExpiresAt).isBefore(currentTime)) {
299
+ return [2 /*return*/, null];
300
+ }
301
+ return [2 /*return*/, invite];
302
+ }
303
+ });
304
+ });
305
+ };
306
+ return Signup;
307
+ }());
308
+ exports.Signup = Signup;
309
+ //# sourceMappingURL=Signup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Signup.js","sourceRoot":"","sources":["../../../src/services/Signup.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oCAAqD;AACrD,wCAUyB;AACzB,kDAA4B;AAC5B,uCAAgC;AAChC,wCAAyC;AACzC,wDAIiC;AACjC,4DAAsC;AACtC,oDAAmE;AAU5D,IAAM,6BAA6B,GAAG;IAC3C,IAAM,cAAc,GAA+B;QACjD,SAAS,EAAE,cAAoB,OAAA,CAAC,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC,EAAzB,CAAyB;KACzD,CAAC;IAEF,IAAM,OAAO,GAAG,6BAAgB,CAAC,GAAG,EAAE,CAAC,MAAM,CAC3C,mDAAmD,CACpD,CAAC;IACF,OAAO,OAAO,IAAI,cAAc,CAAC;AACnC,CAAC,CAAC;AATW,QAAA,6BAA6B,iCASxC;AAEF;IAAA;QACS,oBAAe,GAAG;YACvB,IAAI,EAAE;gBACJ,SAAS,EAAE,UAAC,UAAkB,EAAE,IAAW;oBACzC,IAAI,UAAU,KAAK,YAAY,IAAI,UAAU,KAAK,cAAc,EAAE;wBAChE,eAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;qBAC3B;oBAED,OAAO,IAAI,CAAC;gBACd,CAAC;aACF;SACF,CAAC;IAgLJ,CAAC;IA9KO,2BAAU,GAAhB,UAAiB,IAAgB,EAAE,KAAc;;;;;;;wBACzC,MAAM,GAAG,IAAI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C,WAAW,EAAE;gCAChB,sBAAO;wCACL,OAAO,EAAE,KAAK;wCACd,KAAK,EAAE,mCAAmC;wCAC1C,YAAY,cAAA;qCACb,EAAC;6BACH;4BACD,IAAI,CAAC,MAAM,EAAE;gCACX,sBAAO;wCACL,OAAO,EAAE,KAAK;wCACd,KAAK,EAAE,mDAAmD;wCAC1D,YAAY,cAAA;qCACb,EAAC;6BACH;yBACF;wBAED,sBAAO;gCACL,OAAO,EAAE,IAAI;gCACb,YAAY,cAAA;gCACZ,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS;6BACpC,EAAC;;;wBAEF,sBAAO;gCACL,OAAO,EAAE,KAAK;gCACd,KAAK,EAAE,8BAA8B;6BACtC,EAAC;;;;;KAEL;IAED,wFAAwF;IAC1E,+BAAc,GAA5B,UAA6B,KAAa;;;;;;wBAClC,EAAE,GAAG,IAAA,kBAAa,GAAE,CAAC;wBACZ,qBAAM,EAAE,CAAC,GAAG,CAAC,aAAM,CAAC,MAAM,EAAE,EAAE,KAAK,OAAA,EAAE,CAAC,EAAA;;wBAA/C,MAAM,GAAG,SAAsC;wBAErD,IAAI,CAAC,MAAM,EAAE;4BACX,sBAAO,IAAI,EAAC;yBACb;wBAEK,WAAW,GAAG,IAAA,gBAAM,GAAE,CAAC;wBAC7B,IAAI,MAAM,CAAC,cAAc,IAAI,IAAA,gBAAM,EAAC,MAAM,CAAC,cAAc,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE;4BAChF,sBAAO,IAAI,EAAC;yBACb;wBAED,sBAAO,MAAM,EAAC;;;;KACf;IACH,aAAC;AAAD,CAAC,AA3LD,IA2LC;AA3LY,wBAAM"}
@@ -11,41 +11,38 @@ import 'crypto-js';
11
11
  import 'express-session';
12
12
  import 'moment';
13
13
 
14
-
15
14
  /** Generate Source Graph */
16
15
 
17
- const sourceGraph = "{\"options\":{\"directed\":true,\"multigraph\":false,\"compound\":false},\"nodes\":[{\"v\":\"@proteinjs/user-server/DbSessionStore\",\"value\":{\"packageName\":\"@proteinjs/user-server\",\"name\":\"DbSessionStore\",\"filePath\":\"/Users/brentbahry/workspaces/n3xa/packages/proteinjs/packages/user/packages/server/src/authentication/DbSessionStore.ts\",\"qualifiedName\":\"@proteinjs/user-server/DbSessionStore\",\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\",\"properties\":[{\"name\":\"TWELVE_HOURS\",\"type\":null,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":true,\"visibility\":\"private\"},{\"name\":\"get\",\"type\":null,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\"},{\"name\":\"set\",\"type\":null,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\"},{\"name\":\"touch\",\"type\":null,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\"},{\"name\":\"destroy\",\"type\":null,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\"}],\"methods\":[{\"name\":\"insertOrUpdate\",\"returnType\":{\"packageName\":\"\",\"name\":\"Promise<void>\",\"filePath\":null,\"qualifiedName\":\"/Promise<void>\",\"typeParameters\":null,\"directParents\":null},\"isAsync\":true,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"private\",\"parameters\":[{\"name\":\"sessionId\",\"type\":{\"packageName\":\"\",\"name\":\"string\",\"filePath\":null,\"qualifiedName\":\"/string\",\"typeParameters\":null,\"directParents\":null}},{\"name\":\"session\",\"type\":{\"packageName\":\"\",\"name\":\"Express.SessionData\",\"filePath\":null,\"qualifiedName\":\"/Express.SessionData\",\"typeParameters\":null,\"directParents\":null}},{\"name\":\"cb\",\"type\":{\"packageName\":\"\",\"name\":\"(error?: any) => void\",\"filePath\":null,\"qualifiedName\":\"/(error?: any) => void\",\"typeParameters\":null,\"directParents\":null}}]},{\"name\":\"sweep\",\"returnType\":{\"packageName\":\"\",\"name\":\"Promise<void>\",\"filePath\":null,\"qualifiedName\":\"/Promise<void>\",\"typeParameters\":null,\"directParents\":null},\"isAsync\":true,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"private\",\"parameters\":[]}],\"typeParameters\":[],\"directParentInterfaces\":[],\"directParentClasses\":[{\"packageName\":\"express-session\",\"name\":\"Store\",\"filePath\":null,\"qualifiedName\":\"express-session/Store\",\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\",\"properties\":[],\"methods\":[],\"typeParameters\":[],\"directParentInterfaces\":[],\"directParentClasses\":[]}],\"sourceType\":2}},{\"v\":\"express-session/Store\"},{\"v\":\"@proteinjs/user-server/SocketIOSessionWatcher\",\"value\":{\"packageName\":\"@proteinjs/user-server\",\"name\":\"SocketIOSessionWatcher\",\"filePath\":\"/Users/brentbahry/workspaces/n3xa/packages/proteinjs/packages/user/packages/server/src/authentication/SocketIOSessionWatcher.ts\",\"qualifiedName\":\"@proteinjs/user-server/SocketIOSessionWatcher\",\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\",\"properties\":[],\"methods\":[{\"name\":\"name\",\"returnType\":{\"packageName\":\"\",\"name\":\"string\",\"filePath\":null,\"qualifiedName\":\"/string\",\"typeParameters\":null,\"directParents\":null},\"isAsync\":false,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\",\"parameters\":[]},{\"name\":\"table\",\"returnType\":{\"packageName\":\"\",\"name\":\"Table<Session>\",\"filePath\":null,\"qualifiedName\":\"/Table<Session>\",\"typeParameters\":null,\"directParents\":null},\"isAsync\":false,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\",\"parameters\":[]},{\"name\":\"afterDelete\",\"returnType\":{\"packageName\":\"\",\"name\":\"Promise<void>\",\"filePath\":null,\"qualifiedName\":\"/Promise<void>\",\"typeParameters\":null,\"directParents\":null},\"isAsync\":true,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\",\"parameters\":[{\"name\":\"recordDeleteCount\",\"type\":{\"packageName\":\"\",\"name\":\"number\",\"filePath\":null,\"qualifiedName\":\"/number\",\"typeParameters\":null,\"directParents\":null}},{\"name\":\"deletedRecords\",\"type\":{\"packageName\":\"\",\"name\":\"T[]\",\"filePath\":null,\"qualifiedName\":\"/T[]\",\"typeParameters\":null,\"directParents\":null}},{\"name\":\"qb\",\"type\":{\"packageName\":\"\",\"name\":\"QueryBuilder<T>\",\"filePath\":null,\"qualifiedName\":\"/QueryBuilder<T>\",\"typeParameters\":null,\"directParents\":null}}]}],\"typeParameters\":[],\"directParentInterfaces\":[{\"packageName\":\"@proteinjs/db\",\"name\":\"TableWatcher\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/db/TableWatcher\",\"properties\":[],\"methods\":[],\"typeParameters\":[\"@proteinjs/user/Session\"],\"directParents\":[]}],\"directParentClasses\":[],\"sourceType\":2}},{\"v\":\"@proteinjs/db/TableWatcher\"},{\"v\":\"@proteinjs/user-server/userCache\",\"value\":{\"packageName\":\"@proteinjs/user-server\",\"name\":\"userCache\",\"filePath\":\"/Users/brentbahry/workspaces/n3xa/packages/proteinjs/packages/user/packages/server/src/authorization/userCache.ts\",\"qualifiedName\":\"@proteinjs/user-server/userCache\",\"type\":{\"packageName\":\"\",\"name\":\"SessionDataCache<User>\",\"filePath\":null,\"qualifiedName\":\"/SessionDataCache<User>\",\"typeParameters\":[],\"directParents\":[{\"packageName\":\"@proteinjs/server-api\",\"name\":\"SessionDataCache\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/server-api/SessionDataCache\",\"typeParameters\":[\"@proteinjs/user/User\"],\"directParents\":null}]},\"isExported\":true,\"isConst\":true,\"sourceType\":0}},{\"v\":\"@proteinjs/server-api/SessionDataCache\"},{\"v\":\"@proteinjs/user-server/createUser\",\"value\":{\"packageName\":\"@proteinjs/user-server\",\"name\":\"createUser\",\"filePath\":\"/Users/brentbahry/workspaces/n3xa/packages/proteinjs/packages/user/packages/server/src/routes/createUser.ts\",\"qualifiedName\":\"@proteinjs/user-server/createUser\",\"type\":{\"packageName\":\"@proteinjs/server-api\",\"name\":\"Route\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/server-api/Route\",\"typeParameters\":[],\"directParents\":[{\"packageName\":\"@proteinjs/server-api\",\"name\":\"Route\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/server-api/Route\",\"typeParameters\":[],\"directParents\":null}]},\"isExported\":true,\"isConst\":true,\"sourceType\":0}},{\"v\":\"@proteinjs/server-api/Route\"},{\"v\":\"@proteinjs/user-server/executePasswordReset\",\"value\":{\"packageName\":\"@proteinjs/user-server\",\"name\":\"executePasswordReset\",\"filePath\":\"/Users/brentbahry/workspaces/n3xa/packages/proteinjs/packages/user/packages/server/src/routes/executePasswordReset.ts\",\"qualifiedName\":\"@proteinjs/user-server/executePasswordReset\",\"type\":{\"packageName\":\"@proteinjs/server-api\",\"name\":\"Route\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/server-api/Route\",\"typeParameters\":[],\"directParents\":[{\"packageName\":\"@proteinjs/server-api\",\"name\":\"Route\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/server-api/Route\",\"typeParameters\":[],\"directParents\":null}]},\"isExported\":true,\"isConst\":true,\"sourceType\":0}},{\"v\":\"@proteinjs/user-server/initiatePasswordReset\",\"value\":{\"packageName\":\"@proteinjs/user-server\",\"name\":\"initiatePasswordReset\",\"filePath\":\"/Users/brentbahry/workspaces/n3xa/packages/proteinjs/packages/user/packages/server/src/routes/initiatePasswordReset.ts\",\"qualifiedName\":\"@proteinjs/user-server/initiatePasswordReset\",\"type\":{\"packageName\":\"@proteinjs/server-api\",\"name\":\"Route\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/server-api/Route\",\"typeParameters\":[],\"directParents\":[{\"packageName\":\"@proteinjs/server-api\",\"name\":\"Route\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/server-api/Route\",\"typeParameters\":[],\"directParents\":null}]},\"isExported\":true,\"isConst\":true,\"sourceType\":0}},{\"v\":\"@proteinjs/user-server/login\",\"value\":{\"packageName\":\"@proteinjs/user-server\",\"name\":\"login\",\"filePath\":\"/Users/brentbahry/workspaces/n3xa/packages/proteinjs/packages/user/packages/server/src/routes/login.ts\",\"qualifiedName\":\"@proteinjs/user-server/login\",\"type\":{\"packageName\":\"@proteinjs/server-api\",\"name\":\"Route\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/server-api/Route\",\"typeParameters\":[],\"directParents\":[{\"packageName\":\"@proteinjs/server-api\",\"name\":\"Route\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/server-api/Route\",\"typeParameters\":[],\"directParents\":null}]},\"isExported\":true,\"isConst\":true,\"sourceType\":0}},{\"v\":\"@proteinjs/user-server/logout\",\"value\":{\"packageName\":\"@proteinjs/user-server\",\"name\":\"logout\",\"filePath\":\"/Users/brentbahry/workspaces/n3xa/packages/proteinjs/packages/user/packages/server/src/routes/logout.ts\",\"qualifiedName\":\"@proteinjs/user-server/logout\",\"type\":{\"packageName\":\"@proteinjs/server-api\",\"name\":\"Route\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/server-api/Route\",\"typeParameters\":[],\"directParents\":[{\"packageName\":\"@proteinjs/server-api\",\"name\":\"Route\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/server-api/Route\",\"typeParameters\":[],\"directParents\":null}]},\"isExported\":true,\"isConst\":true,\"sourceType\":0}},{\"v\":\"@proteinjs/user-server/validateResetPasswordToken\",\"value\":{\"packageName\":\"@proteinjs/user-server\",\"name\":\"validateResetPasswordToken\",\"filePath\":\"/Users/brentbahry/workspaces/n3xa/packages/proteinjs/packages/user/packages/server/src/routes/validateResetPasswordToken.ts\",\"qualifiedName\":\"@proteinjs/user-server/validateResetPasswordToken\",\"type\":{\"packageName\":\"@proteinjs/server-api\",\"name\":\"Route\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/server-api/Route\",\"typeParameters\":[],\"directParents\":[{\"packageName\":\"@proteinjs/server-api\",\"name\":\"Route\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/server-api/Route\",\"typeParameters\":[],\"directParents\":null}]},\"isExported\":true,\"isConst\":true,\"sourceType\":0}}],\"edges\":[{\"v\":\"@proteinjs/user-server/DbSessionStore\",\"w\":\"express-session/Store\",\"value\":\"extends class\"},{\"v\":\"@proteinjs/user-server/SocketIOSessionWatcher\",\"w\":\"@proteinjs/db/TableWatcher\",\"value\":\"implements interface\"},{\"v\":\"@proteinjs/user-server/userCache\",\"w\":\"@proteinjs/server-api/SessionDataCache\",\"value\":\"has type\"},{\"v\":\"@proteinjs/user-server/createUser\",\"w\":\"@proteinjs/server-api/Route\",\"value\":\"has type\"},{\"v\":\"@proteinjs/user-server/executePasswordReset\",\"w\":\"@proteinjs/server-api/Route\",\"value\":\"has type\"},{\"v\":\"@proteinjs/user-server/initiatePasswordReset\",\"w\":\"@proteinjs/server-api/Route\",\"value\":\"has type\"},{\"v\":\"@proteinjs/user-server/login\",\"w\":\"@proteinjs/server-api/Route\",\"value\":\"has type\"},{\"v\":\"@proteinjs/user-server/logout\",\"w\":\"@proteinjs/server-api/Route\",\"value\":\"has type\"},{\"v\":\"@proteinjs/user-server/validateResetPasswordToken\",\"w\":\"@proteinjs/server-api/Route\",\"value\":\"has type\"}]}";
18
-
16
+ const sourceGraph =
17
+ '{"options":{"directed":true,"multigraph":false,"compound":false},"nodes":[{"v":"@proteinjs/user-server/DbSessionStore","value":{"packageName":"@proteinjs/user-server","name":"DbSessionStore","filePath":"/home/runner/work/user/user/packages/server/src/authentication/DbSessionStore.ts","qualifiedName":"@proteinjs/user-server/DbSessionStore","isAbstract":false,"isStatic":false,"visibility":"public","properties":[{"name":"TWELVE_HOURS","type":null,"isOptional":false,"isAbstract":false,"isStatic":true,"visibility":"private"},{"name":"get","type":null,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public"},{"name":"set","type":null,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public"},{"name":"touch","type":null,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public"},{"name":"destroy","type":null,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public"}],"methods":[{"name":"insertOrUpdate","returnType":{"packageName":"","name":"Promise<void>","filePath":null,"qualifiedName":"/Promise<void>","typeParameters":null,"directParents":null},"isAsync":true,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private","parameters":[{"name":"sessionId","type":{"packageName":"","name":"string","filePath":null,"qualifiedName":"/string","typeParameters":null,"directParents":null}},{"name":"session","type":{"packageName":"","name":"Express.SessionData","filePath":null,"qualifiedName":"/Express.SessionData","typeParameters":null,"directParents":null}},{"name":"cb","type":{"packageName":"","name":"(error?: any) => void","filePath":null,"qualifiedName":"/(error?: any) => void","typeParameters":null,"directParents":null}}]},{"name":"sweep","returnType":{"packageName":"","name":"Promise<void>","filePath":null,"qualifiedName":"/Promise<void>","typeParameters":null,"directParents":null},"isAsync":true,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private","parameters":[]}],"typeParameters":[],"directParentInterfaces":[],"directParentClasses":[{"packageName":"express-session","name":"Store","filePath":null,"qualifiedName":"express-session/Store","isAbstract":false,"isStatic":false,"visibility":"public","properties":[],"methods":[],"typeParameters":[],"directParentInterfaces":[],"directParentClasses":[]}],"sourceType":2}},{"v":"express-session/Store"},{"v":"@proteinjs/user-server/SocketIOSessionWatcher","value":{"packageName":"@proteinjs/user-server","name":"SocketIOSessionWatcher","filePath":"/home/runner/work/user/user/packages/server/src/authentication/SocketIOSessionWatcher.ts","qualifiedName":"@proteinjs/user-server/SocketIOSessionWatcher","isAbstract":false,"isStatic":false,"visibility":"public","properties":[],"methods":[{"name":"name","returnType":{"packageName":"","name":"string","filePath":null,"qualifiedName":"/string","typeParameters":null,"directParents":null},"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[]},{"name":"table","returnType":{"packageName":"","name":"Table<Session>","filePath":null,"qualifiedName":"/Table<Session>","typeParameters":null,"directParents":null},"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[]},{"name":"afterDelete","returnType":{"packageName":"","name":"Promise<void>","filePath":null,"qualifiedName":"/Promise<void>","typeParameters":null,"directParents":null},"isAsync":true,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[{"name":"recordDeleteCount","type":{"packageName":"","name":"number","filePath":null,"qualifiedName":"/number","typeParameters":null,"directParents":null}},{"name":"deletedRecords","type":{"packageName":"","name":"T[]","filePath":null,"qualifiedName":"/T[]","typeParameters":null,"directParents":null}},{"name":"qb","type":{"packageName":"","name":"QueryBuilder<T>","filePath":null,"qualifiedName":"/QueryBuilder<T>","typeParameters":null,"directParents":null}}]}],"typeParameters":[],"directParentInterfaces":[{"packageName":"@proteinjs/db","name":"TableWatcher","filePath":null,"qualifiedName":"@proteinjs/db/TableWatcher","properties":[],"methods":[],"typeParameters":["@proteinjs/user/Session"],"directParents":[]}],"directParentClasses":[],"sourceType":2}},{"v":"@proteinjs/db/TableWatcher"},{"v":"@proteinjs/user-server/userCache","value":{"packageName":"@proteinjs/user-server","name":"userCache","filePath":"/home/runner/work/user/user/packages/server/src/authorization/userCache.ts","qualifiedName":"@proteinjs/user-server/userCache","type":{"packageName":"","name":"SessionDataCache<User>","filePath":null,"qualifiedName":"/SessionDataCache<User>","typeParameters":[],"directParents":[{"packageName":"@proteinjs/server-api","name":"SessionDataCache","filePath":null,"qualifiedName":"@proteinjs/server-api/SessionDataCache","typeParameters":["@proteinjs/user/User"],"directParents":null}]},"isExported":true,"isConst":true,"sourceType":0}},{"v":"@proteinjs/server-api/SessionDataCache"},{"v":"@proteinjs/user-server/executePasswordReset","value":{"packageName":"@proteinjs/user-server","name":"executePasswordReset","filePath":"/home/runner/work/user/user/packages/server/src/routes/executePasswordReset.ts","qualifiedName":"@proteinjs/user-server/executePasswordReset","type":{"packageName":"@proteinjs/server-api","name":"Route","filePath":null,"qualifiedName":"@proteinjs/server-api/Route","typeParameters":[],"directParents":[{"packageName":"@proteinjs/server-api","name":"Route","filePath":null,"qualifiedName":"@proteinjs/server-api/Route","typeParameters":[],"directParents":null}]},"isExported":true,"isConst":true,"sourceType":0}},{"v":"@proteinjs/server-api/Route"},{"v":"@proteinjs/user-server/initiatePasswordReset","value":{"packageName":"@proteinjs/user-server","name":"initiatePasswordReset","filePath":"/home/runner/work/user/user/packages/server/src/routes/initiatePasswordReset.ts","qualifiedName":"@proteinjs/user-server/initiatePasswordReset","type":{"packageName":"@proteinjs/server-api","name":"Route","filePath":null,"qualifiedName":"@proteinjs/server-api/Route","typeParameters":[],"directParents":[{"packageName":"@proteinjs/server-api","name":"Route","filePath":null,"qualifiedName":"@proteinjs/server-api/Route","typeParameters":[],"directParents":null}]},"isExported":true,"isConst":true,"sourceType":0}},{"v":"@proteinjs/user-server/login","value":{"packageName":"@proteinjs/user-server","name":"login","filePath":"/home/runner/work/user/user/packages/server/src/routes/login.ts","qualifiedName":"@proteinjs/user-server/login","type":{"packageName":"@proteinjs/server-api","name":"Route","filePath":null,"qualifiedName":"@proteinjs/server-api/Route","typeParameters":[],"directParents":[{"packageName":"@proteinjs/server-api","name":"Route","filePath":null,"qualifiedName":"@proteinjs/server-api/Route","typeParameters":[],"directParents":null}]},"isExported":true,"isConst":true,"sourceType":0}},{"v":"@proteinjs/user-server/logout","value":{"packageName":"@proteinjs/user-server","name":"logout","filePath":"/home/runner/work/user/user/packages/server/src/routes/logout.ts","qualifiedName":"@proteinjs/user-server/logout","type":{"packageName":"@proteinjs/server-api","name":"Route","filePath":null,"qualifiedName":"@proteinjs/server-api/Route","typeParameters":[],"directParents":[{"packageName":"@proteinjs/server-api","name":"Route","filePath":null,"qualifiedName":"@proteinjs/server-api/Route","typeParameters":[],"directParents":null}]},"isExported":true,"isConst":true,"sourceType":0}},{"v":"@proteinjs/user-server/validateResetPasswordToken","value":{"packageName":"@proteinjs/user-server","name":"validateResetPasswordToken","filePath":"/home/runner/work/user/user/packages/server/src/routes/validateResetPasswordToken.ts","qualifiedName":"@proteinjs/user-server/validateResetPasswordToken","type":{"packageName":"@proteinjs/server-api","name":"Route","filePath":null,"qualifiedName":"@proteinjs/server-api/Route","typeParameters":[],"directParents":[{"packageName":"@proteinjs/server-api","name":"Route","filePath":null,"qualifiedName":"@proteinjs/server-api/Route","typeParameters":[],"directParents":null}]},"isExported":true,"isConst":true,"sourceType":0}},{"v":"@proteinjs/user-server/DefaultInviteConfigFactory","value":{"packageName":"@proteinjs/user-server","name":"DefaultInviteConfigFactory","filePath":"/home/runner/work/user/user/packages/server/src/services/Signup.ts","qualifiedName":"@proteinjs/user-server/DefaultInviteConfigFactory","properties":[],"methods":[{"name":"getConfig","returnType":{"packageName":"@proteinjs/user-server","name":"InviteConfig","filePath":null,"qualifiedName":"@proteinjs/user-server/InviteConfig","typeParameters":null,"directParents":null},"isAsync":false,"isOptional":false,"isAbstract":true,"isStatic":false,"visibility":"public","parameters":[]}],"typeParameters":[],"directParents":[{"packageName":"@proteinjs/reflection","name":"Loadable","filePath":null,"qualifiedName":"@proteinjs/reflection/Loadable","properties":[],"methods":[],"typeParameters":[],"directParents":[]}],"sourceType":3}},{"v":"@proteinjs/reflection/Loadable"},{"v":"@proteinjs/user-server/Signup","value":{"packageName":"@proteinjs/user-server","name":"Signup","filePath":"/home/runner/work/user/user/packages/server/src/services/Signup.ts","qualifiedName":"@proteinjs/user-server/Signup","isAbstract":false,"isStatic":false,"visibility":"public","properties":[{"name":"serviceMetadata","type":null,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public"}],"methods":[{"name":"createUser","returnType":{"packageName":"","name":"Promise<void>","filePath":null,"qualifiedName":"/Promise<void>","typeParameters":null,"directParents":null},"isAsync":true,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[{"name":"user","type":{"packageName":"@proteinjs/user","name":"UserSignup","filePath":null,"qualifiedName":"@proteinjs/user/UserSignup","typeParameters":null,"directParents":null}},{"name":"token","type":{"packageName":"","name":"string","filePath":null,"qualifiedName":"/string","typeParameters":null,"directParents":null}}]},{"name":"sendInvite","returnType":{"packageName":"","name":"Promise<SendInviteResponse>","filePath":null,"qualifiedName":"/Promise<SendInviteResponse>","typeParameters":null,"directParents":null},"isAsync":true,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[{"name":"email","type":{"packageName":"","name":"string","filePath":null,"qualifiedName":"/string","typeParameters":null,"directParents":null}}]},{"name":"revokeInvite","returnType":{"packageName":"","name":"Promise<void>","filePath":null,"qualifiedName":"/Promise<void>","typeParameters":null,"directParents":null},"isAsync":true,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[{"name":"email","type":{"packageName":"","name":"string","filePath":null,"qualifiedName":"/string","typeParameters":null,"directParents":null}}]},{"name":"initializeSignup","returnType":{"packageName":"","name":"Promise<InitializeSignupResponse>","filePath":null,"qualifiedName":"/Promise<InitializeSignupResponse>","typeParameters":null,"directParents":null},"isAsync":true,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[{"name":"inviteToken","type":{"packageName":"","name":"string | undefined","filePath":null,"qualifiedName":"/string | undefined","typeParameters":null,"directParents":null}}]},{"name":"getValidInvite","returnType":{"packageName":"","name":"Promise<Invite | null>","filePath":null,"qualifiedName":"/Promise<Invite | null>","typeParameters":null,"directParents":null},"isAsync":true,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private","parameters":[{"name":"token","type":{"packageName":"","name":"string","filePath":null,"qualifiedName":"/string","typeParameters":null,"directParents":null}}]}],"typeParameters":[],"directParentInterfaces":[{"packageName":"@proteinjs/user","name":"SignupService","filePath":null,"qualifiedName":"@proteinjs/user/SignupService","properties":[],"methods":[],"typeParameters":[],"directParents":[]}],"directParentClasses":[],"sourceType":2}},{"v":"@proteinjs/user/SignupService"}],"edges":[{"v":"@proteinjs/user-server/DbSessionStore","w":"express-session/Store","value":"extends class"},{"v":"@proteinjs/user-server/SocketIOSessionWatcher","w":"@proteinjs/db/TableWatcher","value":"implements interface"},{"v":"@proteinjs/user-server/userCache","w":"@proteinjs/server-api/SessionDataCache","value":"has type"},{"v":"@proteinjs/user-server/executePasswordReset","w":"@proteinjs/server-api/Route","value":"has type"},{"v":"@proteinjs/user-server/initiatePasswordReset","w":"@proteinjs/server-api/Route","value":"has type"},{"v":"@proteinjs/user-server/login","w":"@proteinjs/server-api/Route","value":"has type"},{"v":"@proteinjs/user-server/logout","w":"@proteinjs/server-api/Route","value":"has type"},{"v":"@proteinjs/user-server/validateResetPasswordToken","w":"@proteinjs/server-api/Route","value":"has type"},{"v":"@proteinjs/user-server/DefaultInviteConfigFactory","w":"@proteinjs/reflection/Loadable","value":"extends interface"},{"v":"@proteinjs/user-server/Signup","w":"@proteinjs/user/SignupService","value":"implements interface"}]}';
19
18
 
20
19
  /** Generate Source Links */
21
20
 
22
21
  import { DbSessionStore } from '../src/authentication/DbSessionStore';
23
22
  import { SocketIOSessionWatcher } from '../src/authentication/SocketIOSessionWatcher';
24
23
  import { userCache } from '../src/authorization/userCache';
25
- import { createUser } from '../src/routes/createUser';
26
24
  import { executePasswordReset } from '../src/routes/executePasswordReset';
27
25
  import { initiatePasswordReset } from '../src/routes/initiatePasswordReset';
28
26
  import { login } from '../src/routes/login';
29
27
  import { logout } from '../src/routes/logout';
30
28
  import { validateResetPasswordToken } from '../src/routes/validateResetPasswordToken';
29
+ import { Signup } from '../src/services/Signup';
31
30
 
32
31
  const sourceLinks = {
33
- '@proteinjs/user-server/DbSessionStore': DbSessionStore,
34
- '@proteinjs/user-server/SocketIOSessionWatcher': SocketIOSessionWatcher,
35
- '@proteinjs/user-server/userCache': userCache,
36
- '@proteinjs/user-server/createUser': createUser,
37
- '@proteinjs/user-server/executePasswordReset': executePasswordReset,
38
- '@proteinjs/user-server/initiatePasswordReset': initiatePasswordReset,
39
- '@proteinjs/user-server/login': login,
40
- '@proteinjs/user-server/logout': logout,
41
- '@proteinjs/user-server/validateResetPasswordToken': validateResetPasswordToken,
32
+ '@proteinjs/user-server/DbSessionStore': DbSessionStore,
33
+ '@proteinjs/user-server/SocketIOSessionWatcher': SocketIOSessionWatcher,
34
+ '@proteinjs/user-server/userCache': userCache,
35
+ '@proteinjs/user-server/executePasswordReset': executePasswordReset,
36
+ '@proteinjs/user-server/initiatePasswordReset': initiatePasswordReset,
37
+ '@proteinjs/user-server/login': login,
38
+ '@proteinjs/user-server/logout': logout,
39
+ '@proteinjs/user-server/validateResetPasswordToken': validateResetPasswordToken,
40
+ '@proteinjs/user-server/Signup': Signup,
42
41
  };
43
42
 
44
-
45
43
  /** Load Source Graph and Links */
46
44
 
47
45
  import { SourceRepository } from '@proteinjs/reflection';
48
46
  SourceRepository.merge(sourceGraph, sourceLinks);
49
47
 
50
-
51
- export * from '../index';
48
+ export * from '../index';
package/index.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export { createAuthentication } from './src/authentication/authenticate';
2
2
  export * from './src/authentication/DbSessionStore';
3
+ export { InviteConfig, DefaultInviteConfigFactory } from './src/services/Signup';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@proteinjs/user-server",
3
- "version": "1.1.4",
3
+ "version": "1.2.0",
4
4
  "description": "User server components",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -21,19 +21,19 @@
21
21
  "watch": "reflection-watch"
22
22
  },
23
23
  "dependencies": {
24
- "@proteinjs/db": "1.5.1",
25
- "@proteinjs/email-server": "1.0.5",
26
- "@proteinjs/reflection": "1.1.7",
27
- "@proteinjs/server": "1.6.0",
28
- "@proteinjs/server-api": "1.4.0",
29
- "@proteinjs/user": "^1.0.39",
30
- "@proteinjs/util": "1.3.1",
24
+ "@proteinjs/db": "1.5.3",
25
+ "@proteinjs/email-server": "1.1.1",
26
+ "@proteinjs/reflection": "1.1.8",
27
+ "@proteinjs/server": "1.6.1",
28
+ "@proteinjs/server-api": "1.4.1",
29
+ "@proteinjs/user": "^1.1.0",
30
+ "@proteinjs/util": "1.4.0",
31
31
  "crypto-js": "4.0.0",
32
32
  "express-session": "1.17.1",
33
33
  "moment": "2.29.4"
34
34
  },
35
35
  "devDependencies": {
36
- "@proteinjs/reflection-build": "1.0.22",
36
+ "@proteinjs/reflection-build": "1.0.23",
37
37
  "@types/crypto-js": "4.0.1",
38
38
  "@types/express-session": "1.17.0",
39
39
  "@types/node": "14.0.13",
@@ -45,5 +45,6 @@
45
45
  "typescript": "5.2.2"
46
46
  },
47
47
  "main": "./dist/generated/index.js",
48
- "types": "./dist/generated/index.d.ts"
49
- }
48
+ "types": "./dist/generated/index.d.ts",
49
+ "gitHead": "bdc34d9e39b0a90babc5f7fe1ca764077c574b1a"
50
+ }
@@ -1,6 +1,6 @@
1
1
  import { Route } from '@proteinjs/server-api';
2
2
  import { getDbAsSystem } from '@proteinjs/db';
3
- import { routes, tables } from '@proteinjs/user';
3
+ import { routes, tables, uiRoutes } from '@proteinjs/user';
4
4
  import { Logger } from '@proteinjs/util';
5
5
  import moment from 'moment';
6
6
  import {
@@ -18,7 +18,6 @@ import { lib } from 'crypto-js';
18
18
  * Requires an implementation of `DefaultPasswordResetEmailConfigFactory` to build the password reset email with.
19
19
  *
20
20
  * @bodyParam {string} email - The email address of the user requesting a password reset.
21
- * @bodyParam {string} resetPath - The path to the password reset page in the client application.
22
21
  * This will be combined with the generated token to create the reset link that is emailed to the user.
23
22
  *
24
23
  * @throws {Error} If there's an issue with sending the email or updating the database.
@@ -28,7 +27,7 @@ export const initiatePasswordReset: Route = {
28
27
  method: routes.initiatePasswordReset.method,
29
28
  onRequest: async (request, response): Promise<void> => {
30
29
  const logger = new Logger('initiatePasswordReset');
31
- const { email, resetPath } = request.body;
30
+ const { email } = request.body;
32
31
  const db = getDbAsSystem();
33
32
 
34
33
  const genericResponse = { message: 'If an account with that email exists, we have sent a password reset link.' };
@@ -69,7 +68,7 @@ export const initiatePasswordReset: Route = {
69
68
 
70
69
  try {
71
70
  const config = defaultConfigFactory.getConfig();
72
- const { text, html } = config.getEmailContent(`${resetPath}?token=${passwordResetToken}`);
71
+ const { text, html } = config.getEmailContent(`${uiRoutes.auth.passwordReset}?token=${passwordResetToken}`);
73
72
 
74
73
  // Send email containing a reset link
75
74
  await emailSender.sendEmail({
@@ -77,6 +76,7 @@ export const initiatePasswordReset: Route = {
77
76
  subject: config.options?.subject || 'Reset Password',
78
77
  text,
79
78
  html,
79
+ ...config.options,
80
80
  });
81
81
 
82
82
  // If email is sent successfully, save reset token to user record