@proteinjs/user-server 1.26.1 → 1.28.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.
- package/CHANGELOG.md +22 -0
- package/dist/generated/index.d.ts.map +1 -1
- package/dist/generated/index.js +3 -1
- package/dist/generated/index.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -1
- package/dist/index.js.map +1 -1
- package/dist/src/authentication/EmailVerificationToken.d.ts +23 -0
- package/dist/src/authentication/EmailVerificationToken.d.ts.map +1 -0
- package/dist/src/authentication/EmailVerificationToken.js +90 -0
- package/dist/src/authentication/EmailVerificationToken.js.map +1 -0
- package/dist/src/authentication/MailedToken.d.ts +91 -0
- package/dist/src/authentication/MailedToken.d.ts.map +1 -0
- package/dist/src/authentication/MailedToken.js +221 -0
- package/dist/src/authentication/MailedToken.js.map +1 -0
- package/dist/src/authentication/PasswordResetToken.d.ts +7 -61
- package/dist/src/authentication/PasswordResetToken.d.ts.map +1 -1
- package/dist/src/authentication/PasswordResetToken.js +25 -140
- package/dist/src/authentication/PasswordResetToken.js.map +1 -1
- package/dist/src/routes/signup.d.ts +8 -3
- package/dist/src/routes/signup.d.ts.map +1 -1
- package/dist/src/routes/signup.js +55 -15
- package/dist/src/routes/signup.js.map +1 -1
- package/dist/src/routes/verifyEmail.d.ts +21 -0
- package/dist/src/routes/verifyEmail.d.ts.map +1 -0
- package/dist/src/routes/verifyEmail.js +107 -0
- package/dist/src/routes/verifyEmail.js.map +1 -0
- package/dist/src/services/DisposableEmailDomains.d.ts +24 -0
- package/dist/src/services/DisposableEmailDomains.d.ts.map +1 -0
- package/dist/src/services/DisposableEmailDomains.js +129 -0
- package/dist/src/services/DisposableEmailDomains.js.map +1 -0
- package/dist/src/services/Signup.d.ts +27 -1
- package/dist/src/services/Signup.d.ts.map +1 -1
- package/dist/src/services/Signup.js +166 -30
- package/dist/src/services/Signup.js.map +1 -1
- package/dist/src/services/SignupGuard.d.ts +55 -0
- package/dist/src/services/SignupGuard.d.ts.map +1 -0
- package/dist/src/services/SignupGuard.js +13 -0
- package/dist/src/services/SignupGuard.js.map +1 -0
- package/dist/test/EmailVerification.test.d.ts +2 -0
- package/dist/test/EmailVerification.test.d.ts.map +1 -0
- package/dist/test/EmailVerification.test.js +451 -0
- package/dist/test/EmailVerification.test.js.map +1 -0
- package/dist/test/Signup.test.js +8 -0
- package/dist/test/Signup.test.js.map +1 -1
- package/dist/test/SignupGuardSeam.test.d.ts +2 -0
- package/dist/test/SignupGuardSeam.test.d.ts.map +1 -0
- package/dist/test/SignupGuardSeam.test.js +474 -0
- package/dist/test/SignupGuardSeam.test.js.map +1 -0
- package/dist/test/UserServerTestEnvironment.d.ts.map +1 -1
- package/dist/test/UserServerTestEnvironment.js +4 -0
- package/dist/test/UserServerTestEnvironment.js.map +1 -1
- package/generated/index.ts +3 -1
- package/index.ts +10 -0
- package/package.json +4 -4
- package/src/authentication/EmailVerificationToken.ts +32 -0
- package/src/authentication/MailedToken.ts +171 -0
- package/src/authentication/PasswordResetToken.ts +13 -131
- package/src/routes/signup.ts +58 -9
- package/src/routes/verifyEmail.ts +64 -0
- package/src/services/DisposableEmailDomains.ts +125 -0
- package/src/services/Signup.ts +111 -10
- package/src/services/SignupGuard.ts +58 -0
- package/test/EmailVerification.test.ts +297 -0
- package/test/Signup.test.ts +11 -1
- package/test/SignupGuardSeam.test.ts +299 -0
- package/test/UserServerTestEnvironment.ts +4 -0
|
@@ -1,4 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
2
17
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
18
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
19
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -35,90 +50,22 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
35
50
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
51
|
}
|
|
37
52
|
};
|
|
38
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
-
};
|
|
41
53
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
54
|
exports.PasswordResetToken = void 0;
|
|
43
|
-
var
|
|
44
|
-
var moment_1 = __importDefault(require("moment"));
|
|
45
|
-
var db_1 = require("@proteinjs/db");
|
|
46
|
-
var user_1 = require("@proteinjs/user");
|
|
55
|
+
var MailedToken_1 = require("./MailedToken");
|
|
47
56
|
/**
|
|
48
|
-
* The password-reset token
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
* A token is 32 bytes from the platform CSPRNG, hex-encoded (64 lowercase hex characters). The
|
|
52
|
-
* token itself exists only in the link mailed to the account: the user row stores its SHA-256
|
|
53
|
-
* digest (hex) beside the expiry, never the token, so a read of the table yields nothing that
|
|
54
|
-
* can be presented. A digest is not a token — presenting one is hashed again and matches no row.
|
|
55
|
-
* A fast unsalted hash is enough here because the input is 256 bits of CSPRNG output, not a
|
|
56
|
-
* human-chosen secret.
|
|
57
|
-
*
|
|
58
|
-
* Resolution refuses anything that is not a value of the token's shape BEFORE any lookup. A
|
|
59
|
-
* query filter built from a request value that is not a token does not compare the way a token
|
|
60
|
-
* does: `null` renders as `IS NULL` and would match every account with no pending reset, an
|
|
61
|
-
* empty string matches an emptied column, and other types reach the driver. The presented token
|
|
62
|
-
* is then hashed, the row is looked up by that digest, and the row the lookup returns is
|
|
63
|
-
* re-checked in code — its stored digest must be a string equal to the presented token's digest
|
|
64
|
-
* (compared in constant time) and its expiry a real timestamp still in the future — so the
|
|
65
|
-
* outcome never rests on how the storage compares.
|
|
57
|
+
* The password-reset token: a `MailedToken` on the row's `passwordResetToken` /
|
|
58
|
+
* `passwordResetTokenExpiration` cells, live for an hour, spent by the password write.
|
|
66
59
|
*
|
|
67
|
-
* No migration
|
|
60
|
+
* No migration accompanied the move from a stored token to a stored digest: a row that still
|
|
68
61
|
* holds a token minted before it never equals the digest of anything presented, so that token
|
|
69
62
|
* fails validation for what remains of its hour and the person asks for a new link.
|
|
70
63
|
*/
|
|
71
|
-
var PasswordResetToken = /** @class */ (function () {
|
|
64
|
+
var PasswordResetToken = /** @class */ (function (_super) {
|
|
65
|
+
__extends(PasswordResetToken, _super);
|
|
72
66
|
function PasswordResetToken() {
|
|
67
|
+
return _super.call(this, { token: 'passwordResetToken', expiration: 'passwordResetTokenExpiration' }, { amount: PasswordResetToken.LIFETIME_MINUTES, unit: 'minutes' }) || this;
|
|
73
68
|
}
|
|
74
|
-
/**
|
|
75
|
-
* Issue a token to `user`: store its digest and its expiry on the row, replacing any token
|
|
76
|
-
* outstanding, and return the token — the only time it exists outside the mailed link.
|
|
77
|
-
*/
|
|
78
|
-
PasswordResetToken.prototype.mint = function (user) {
|
|
79
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
80
|
-
var token;
|
|
81
|
-
return __generator(this, function (_a) {
|
|
82
|
-
switch (_a.label) {
|
|
83
|
-
case 0:
|
|
84
|
-
token = (0, crypto_1.randomBytes)(32).toString('hex');
|
|
85
|
-
return [4 /*yield*/, (0, db_1.getDbAsSystem)().update(user_1.tables.User, {
|
|
86
|
-
id: user.id,
|
|
87
|
-
passwordResetToken: this.digest(token),
|
|
88
|
-
passwordResetTokenExpiration: (0, moment_1.default)().add(PasswordResetToken.LIFETIME_MINUTES, 'minutes'),
|
|
89
|
-
})];
|
|
90
|
-
case 1:
|
|
91
|
-
_a.sent();
|
|
92
|
-
return [2 /*return*/, token];
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
});
|
|
96
|
-
};
|
|
97
|
-
PasswordResetToken.prototype.resolve = function (presented) {
|
|
98
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
99
|
-
var token, digest, user;
|
|
100
|
-
return __generator(this, function (_a) {
|
|
101
|
-
switch (_a.label) {
|
|
102
|
-
case 0:
|
|
103
|
-
token = this.parse(presented);
|
|
104
|
-
if (token === undefined) {
|
|
105
|
-
return [2 /*return*/, { status: 'malformed' }];
|
|
106
|
-
}
|
|
107
|
-
digest = this.digest(token);
|
|
108
|
-
return [4 /*yield*/, (0, db_1.getDbAsSystem)().get(user_1.tables.User, { passwordResetToken: digest })];
|
|
109
|
-
case 1:
|
|
110
|
-
user = _a.sent();
|
|
111
|
-
if (!user || !this.matches(user.passwordResetToken, digest)) {
|
|
112
|
-
return [2 /*return*/, { status: 'unknown' }];
|
|
113
|
-
}
|
|
114
|
-
if (!this.isLive(user.passwordResetTokenExpiration)) {
|
|
115
|
-
return [2 /*return*/, { status: 'expired', user: user }];
|
|
116
|
-
}
|
|
117
|
-
return [2 /*return*/, { status: 'live', user: user, token: token }];
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
});
|
|
121
|
-
};
|
|
122
69
|
/**
|
|
123
70
|
* Write the new credential and clear the token in one conditional update: the row must still
|
|
124
71
|
* carry this token's digest at write time, so two presentations of the same token cannot both
|
|
@@ -126,78 +73,16 @@ var PasswordResetToken = /** @class */ (function () {
|
|
|
126
73
|
*/
|
|
127
74
|
PasswordResetToken.prototype.redeem = function (user, token, hashedPassword) {
|
|
128
75
|
return __awaiter(this, void 0, void 0, function () {
|
|
129
|
-
var updated;
|
|
130
76
|
return __generator(this, function (_a) {
|
|
131
77
|
switch (_a.label) {
|
|
132
|
-
case 0: return [4 /*yield*/, (
|
|
133
|
-
case 1:
|
|
134
|
-
updated = _a.sent();
|
|
135
|
-
return [2 /*return*/, updated === 1];
|
|
78
|
+
case 0: return [4 /*yield*/, this.spend(user, token, { password: hashedPassword })];
|
|
79
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
136
80
|
}
|
|
137
81
|
});
|
|
138
82
|
});
|
|
139
83
|
};
|
|
140
|
-
/**
|
|
141
|
-
* Withdraw a token that never reached its owner (the mail carrying it failed to send): the row
|
|
142
|
-
* is cleared only while it still carries this token's digest, so a newer token is left alone.
|
|
143
|
-
*/
|
|
144
|
-
PasswordResetToken.prototype.revoke = function (user, token) {
|
|
145
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
146
|
-
return __generator(this, function (_a) {
|
|
147
|
-
switch (_a.label) {
|
|
148
|
-
case 0: return [4 /*yield*/, (0, db_1.getDbAsSystem)().update(user_1.tables.User, { passwordResetToken: null, passwordResetTokenExpiration: null }, { id: user.id, passwordResetToken: this.digest(token) })];
|
|
149
|
-
case 1:
|
|
150
|
-
_a.sent();
|
|
151
|
-
return [2 /*return*/];
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
});
|
|
155
|
-
};
|
|
156
|
-
/** When the token outstanding on `user` was minted, or undefined when the row carries none. */
|
|
157
|
-
PasswordResetToken.prototype.mintedAt = function (user) {
|
|
158
|
-
if (!user.passwordResetToken || !user.passwordResetTokenExpiration) {
|
|
159
|
-
return undefined;
|
|
160
|
-
}
|
|
161
|
-
return (0, moment_1.default)(user.passwordResetTokenExpiration).subtract(PasswordResetToken.LIFETIME_MINUTES, 'minutes');
|
|
162
|
-
};
|
|
163
|
-
/**
|
|
164
|
-
* A log-safe reference to a presented token: a short prefix of a well-formed one's digest,
|
|
165
|
-
* never the value itself and never a part of it. The routes log it only for a token that
|
|
166
|
-
* resolved `unknown` — one no row carries — so it never lines up with a digest a row holds.
|
|
167
|
-
* What it is for is telling refusals apart in the log: one stale link presented again reads
|
|
168
|
-
* the same each time, a run of different values reads differently. 48 bits of the SHA-256 of
|
|
169
|
-
* 256 random bits identify nothing and can be presented nowhere.
|
|
170
|
-
*/
|
|
171
|
-
PasswordResetToken.prototype.fingerprint = function (presented) {
|
|
172
|
-
var token = this.parse(presented);
|
|
173
|
-
if (token === undefined) {
|
|
174
|
-
return undefined;
|
|
175
|
-
}
|
|
176
|
-
return this.digest(token).slice(0, 12);
|
|
177
|
-
};
|
|
178
|
-
PasswordResetToken.prototype.parse = function (presented) {
|
|
179
|
-
return typeof presented === 'string' && PasswordResetToken.SHAPE.test(presented) ? presented : undefined;
|
|
180
|
-
};
|
|
181
|
-
/** What the row stores in place of a token: its SHA-256, hex-encoded. */
|
|
182
|
-
PasswordResetToken.prototype.digest = function (token) {
|
|
183
|
-
return (0, crypto_1.createHash)('sha256').update(token).digest('hex');
|
|
184
|
-
};
|
|
185
|
-
PasswordResetToken.prototype.matches = function (storedDigest, presentedDigest) {
|
|
186
|
-
if (typeof storedDigest !== 'string' || storedDigest.length !== presentedDigest.length) {
|
|
187
|
-
return false;
|
|
188
|
-
}
|
|
189
|
-
return (0, crypto_1.timingSafeEqual)(Buffer.from(storedDigest), Buffer.from(presentedDigest));
|
|
190
|
-
};
|
|
191
|
-
PasswordResetToken.prototype.isLive = function (expiration) {
|
|
192
|
-
if (!expiration) {
|
|
193
|
-
return false;
|
|
194
|
-
}
|
|
195
|
-
var expiresAt = (0, moment_1.default)(expiration);
|
|
196
|
-
return expiresAt.isValid() && (0, moment_1.default)().isBefore(expiresAt);
|
|
197
|
-
};
|
|
198
|
-
PasswordResetToken.SHAPE = /^[0-9a-f]{64}$/;
|
|
199
84
|
PasswordResetToken.LIFETIME_MINUTES = 60;
|
|
200
85
|
return PasswordResetToken;
|
|
201
|
-
}());
|
|
86
|
+
}(MailedToken_1.MailedToken));
|
|
202
87
|
exports.PasswordResetToken = PasswordResetToken;
|
|
203
88
|
//# sourceMappingURL=PasswordResetToken.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PasswordResetToken.js","sourceRoot":"","sources":["../../../src/authentication/PasswordResetToken.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PasswordResetToken.js","sourceRoot":"","sources":["../../../src/authentication/PasswordResetToken.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,6CAAmE;AAInE;;;;;;;GAOG;AACH;IAAwC,sCAAW;IAGjD;eACE,kBACE,EAAE,KAAK,EAAE,oBAAoB,EAAE,UAAU,EAAE,8BAA8B,EAAE,EAC3E,EAAE,MAAM,EAAE,kBAAkB,CAAC,gBAAgB,EAAE,IAAI,EAAE,SAAS,EAAE,CACjE;IACH,CAAC;IAED;;;;OAIG;IACG,mCAAM,GAAZ,UAAa,IAAU,EAAE,KAAa,EAAE,cAAsB;;;;4BACrD,qBAAM,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,cAAc,EAAE,CAAC,EAAA;4BAAlE,sBAAO,SAA2D,EAAC;;;;KACpE;IAhBuB,mCAAgB,GAAG,EAAE,CAAC;IAiBhD,yBAAC;CAAA,AAlBD,CAAwC,yBAAW,GAkBlD;AAlBY,gDAAkB"}
|
|
@@ -6,14 +6,19 @@ import { Route } from '@proteinjs/server-api';
|
|
|
6
6
|
* because session establishment is a request-level concern services never see; the domain flow
|
|
7
7
|
* (invite validation, account creation, notification emails) stays owned by `Signup.createUser`.
|
|
8
8
|
*
|
|
9
|
-
* Body: `
|
|
10
|
-
*
|
|
11
|
-
* user-readable copy otherwise.
|
|
9
|
+
* Body: `SignupSubmission`. Response mirrors the login route's contract: 200 with `{}` on
|
|
10
|
+
* success, `{ error }` with user-readable copy otherwise.
|
|
12
11
|
*
|
|
13
12
|
* When the email is already registered the response is byte-identical to success but NO session
|
|
14
13
|
* is minted — auto-login must never hand out a session for an account the caller didn't just
|
|
15
14
|
* create; the caller falls through to the login screen exactly as before. Existence is reported
|
|
16
15
|
* to the mailbox owner by email, never to the caller.
|
|
16
|
+
*
|
|
17
|
+
* The NO-INVITE road passes two doors before any write, in this order: the throwaway-mail list
|
|
18
|
+
* (`DisposableEmailDomains`, refused with its one sentence) and the consumer's registered
|
|
19
|
+
* `DefaultSignupGuard`, handed the submission's facts (`SignupGuardFacts`) — `refuse` answers
|
|
20
|
+
* `{ error: sentence }`, `drop` answers exactly as success, and neither writes an account or
|
|
21
|
+
* mints a session. The invite road passes neither: an invited address was chosen by an admin.
|
|
17
22
|
*/
|
|
18
23
|
export declare const signup: Route;
|
|
19
24
|
//# sourceMappingURL=signup.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signup.d.ts","sourceRoot":"","sources":["../../../src/routes/signup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"signup.d.ts","sourceRoot":"","sources":["../../../src/routes/signup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAyB9C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,MAAM,EAAE,KAmDpB,CAAC"}
|
|
@@ -41,7 +41,10 @@ var logger_1 = require("@proteinjs/logger");
|
|
|
41
41
|
var util_node_1 = require("@proteinjs/util-node");
|
|
42
42
|
var user_1 = require("@proteinjs/user");
|
|
43
43
|
var establishSession_1 = require("../authentication/establishSession");
|
|
44
|
+
var DisposableEmailDomains_1 = require("../services/DisposableEmailDomains");
|
|
44
45
|
var Signup_1 = require("../services/Signup");
|
|
46
|
+
var SignupGuard_1 = require("../services/SignupGuard");
|
|
47
|
+
var ClientAddress_1 = require("../throttle/ClientAddress");
|
|
45
48
|
var logger = new logger_1.Logger({ name: 'signup' });
|
|
46
49
|
/**
|
|
47
50
|
* `POST /user/signup` — create the account AND establish its session in the same request
|
|
@@ -50,20 +53,25 @@ var logger = new logger_1.Logger({ name: 'signup' });
|
|
|
50
53
|
* because session establishment is a request-level concern services never see; the domain flow
|
|
51
54
|
* (invite validation, account creation, notification emails) stays owned by `Signup.createUser`.
|
|
52
55
|
*
|
|
53
|
-
* Body: `
|
|
54
|
-
*
|
|
55
|
-
* user-readable copy otherwise.
|
|
56
|
+
* Body: `SignupSubmission`. Response mirrors the login route's contract: 200 with `{}` on
|
|
57
|
+
* success, `{ error }` with user-readable copy otherwise.
|
|
56
58
|
*
|
|
57
59
|
* When the email is already registered the response is byte-identical to success but NO session
|
|
58
60
|
* is minted — auto-login must never hand out a session for an account the caller didn't just
|
|
59
61
|
* create; the caller falls through to the login screen exactly as before. Existence is reported
|
|
60
62
|
* to the mailbox owner by email, never to the caller.
|
|
63
|
+
*
|
|
64
|
+
* The NO-INVITE road passes two doors before any write, in this order: the throwaway-mail list
|
|
65
|
+
* (`DisposableEmailDomains`, refused with its one sentence) and the consumer's registered
|
|
66
|
+
* `DefaultSignupGuard`, handed the submission's facts (`SignupGuardFacts`) — `refuse` answers
|
|
67
|
+
* `{ error: sentence }`, `drop` answers exactly as success, and neither writes an account or
|
|
68
|
+
* mints a session. The invite road passes neither: an invited address was chosen by an admin.
|
|
61
69
|
*/
|
|
62
70
|
exports.signup = {
|
|
63
71
|
path: user_1.routes.signup.path,
|
|
64
72
|
method: user_1.routes.signup.method,
|
|
65
73
|
onRequest: function (request, response) { return __awaiter(void 0, void 0, void 0, function () {
|
|
66
|
-
var body, result, error_1;
|
|
74
|
+
var body, digests, email, facts, verdict, result, error_1;
|
|
67
75
|
var _a;
|
|
68
76
|
return __generator(this, function (_b) {
|
|
69
77
|
switch (_b.label) {
|
|
@@ -73,33 +81,65 @@ exports.signup = {
|
|
|
73
81
|
response.send({ error: 'Name and password cannot be blank' });
|
|
74
82
|
return [2 /*return*/];
|
|
75
83
|
}
|
|
76
|
-
|
|
84
|
+
digests = new util_node_1.RequestDigests();
|
|
85
|
+
email = typeof body.email === 'string' ? body.email.trim() : undefined;
|
|
86
|
+
if (!(!body.token && email)) return [3 /*break*/, 2];
|
|
87
|
+
if (new DisposableEmailDomains_1.DisposableEmailDomains().isDisposable(email)) {
|
|
88
|
+
logger.info({ message: 'Signup refused: throwaway-mail domain', obj: { account: digests.account(email) } });
|
|
89
|
+
response.send({ error: DisposableEmailDomains_1.DisposableEmailDomains.REFUSAL });
|
|
90
|
+
return [2 /*return*/];
|
|
91
|
+
}
|
|
92
|
+
facts = signupFacts(request, body, email);
|
|
93
|
+
return [4 /*yield*/, (0, SignupGuard_1.getDefaultSignupGuard)().check(facts)];
|
|
77
94
|
case 1:
|
|
78
|
-
_b.
|
|
79
|
-
|
|
95
|
+
verdict = _b.sent();
|
|
96
|
+
if (verdict.verdict !== 'allow') {
|
|
97
|
+
logger.info({
|
|
98
|
+
message: "Signup ".concat(verdict.verdict === 'refuse' ? 'refused' : 'dropped', " by the guard"),
|
|
99
|
+
obj: { account: digests.account(email), device: facts.clientDevice },
|
|
100
|
+
});
|
|
101
|
+
// A drop answers exactly as success: the caller learns nothing it can iterate against.
|
|
102
|
+
response.send(verdict.verdict === 'refuse' ? { error: verdict.sentence } : {});
|
|
103
|
+
return [2 /*return*/];
|
|
104
|
+
}
|
|
105
|
+
_b.label = 2;
|
|
80
106
|
case 2:
|
|
81
|
-
|
|
82
|
-
return [
|
|
107
|
+
_b.trys.push([2, 4, , 5]);
|
|
108
|
+
return [4 /*yield*/, new Signup_1.Signup().createUser({ name: body.name, email: email, password: body.password }, body.token)];
|
|
83
109
|
case 3:
|
|
110
|
+
result = _b.sent();
|
|
111
|
+
return [3 /*break*/, 5];
|
|
112
|
+
case 4:
|
|
84
113
|
error_1 = _b.sent();
|
|
85
114
|
// createUser throws plain-words errors deliberately (invite expired / invite required /
|
|
86
115
|
// email missing); the message is the user-facing contract, same as the RPC layer's. The log
|
|
87
116
|
// gets the error through the digest door: a concurrent double sign-up's unique-index refusal
|
|
88
117
|
// names the address in the database's own words.
|
|
89
|
-
logger.error({ message: 'Signup failed', error:
|
|
118
|
+
logger.error({ message: 'Signup failed', error: digests.redactError(error_1) });
|
|
90
119
|
response.send({ error: error_1 instanceof Error ? error_1.message : 'Sign up failed.' });
|
|
91
120
|
return [2 /*return*/];
|
|
92
|
-
case 4:
|
|
93
|
-
if (!(result.outcome === 'created')) return [3 /*break*/, 6];
|
|
94
|
-
return [4 /*yield*/, (0, establishSession_1.establishSession)(request, result.email)];
|
|
95
121
|
case 5:
|
|
96
|
-
|
|
97
|
-
|
|
122
|
+
if (!(result.outcome === 'created')) return [3 /*break*/, 7];
|
|
123
|
+
return [4 /*yield*/, (0, establishSession_1.establishSession)(request, result.email)];
|
|
98
124
|
case 6:
|
|
125
|
+
_b.sent();
|
|
126
|
+
_b.label = 7;
|
|
127
|
+
case 7:
|
|
99
128
|
response.send({});
|
|
100
129
|
return [2 /*return*/];
|
|
101
130
|
}
|
|
102
131
|
});
|
|
103
132
|
}); },
|
|
104
133
|
};
|
|
134
|
+
/** The facts the guard judges — the address lowercased, the form's two optional fields as sent, the device as a digest. */
|
|
135
|
+
var signupFacts = function (request, body, email) {
|
|
136
|
+
var _a;
|
|
137
|
+
return ({
|
|
138
|
+
email: email.toLowerCase(),
|
|
139
|
+
honeypot: typeof body.website === 'string' ? body.website : undefined,
|
|
140
|
+
formToken: typeof body.formToken === 'string' ? body.formToken : undefined,
|
|
141
|
+
clientDevice: new util_node_1.RequestDigests().coarseIp(new ClientAddress_1.ClientAddress().of(request)),
|
|
142
|
+
hasUserAgent: Boolean((_a = request.headers) === null || _a === void 0 ? void 0 : _a['user-agent']),
|
|
143
|
+
});
|
|
144
|
+
};
|
|
105
145
|
//# sourceMappingURL=signup.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signup.js","sourceRoot":"","sources":["../../../src/routes/signup.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,4CAA2C;AAC3C,kDAAsD;AACtD,wCAAqD;AACrD,uEAAsE;AACtE,6CAA4C;
|
|
1
|
+
{"version":3,"file":"signup.js","sourceRoot":"","sources":["../../../src/routes/signup.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,4CAA2C;AAC3C,kDAAsD;AACtD,wCAAqD;AACrD,uEAAsE;AACtE,6EAA4E;AAC5E,6CAA4C;AAC5C,uDAAkF;AAClF,2DAA0D;AAE1D,IAAM,MAAM,GAAG,IAAI,eAAM,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;AAe9C;;;;;;;;;;;;;;;;;;;;GAoBG;AACU,QAAA,MAAM,GAAU;IAC3B,IAAI,EAAE,aAAM,CAAC,MAAM,CAAC,IAAI;IACxB,MAAM,EAAE,aAAM,CAAC,MAAM,CAAC,MAAM;IAC5B,SAAS,EAAE,UAAO,OAAY,EAAE,QAAQ;;;;;;oBAChC,IAAI,GAAqB,MAAA,OAAO,CAAC,IAAI,mCAAI,EAAE,CAAC;oBAClD,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;wBAChC,QAAQ,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,mCAAmC,EAAE,CAAC,CAAC;wBAC9D,sBAAO;qBACR;oBAEK,OAAO,GAAG,IAAI,0BAAc,EAAE,CAAC;oBAC/B,KAAK,GAAG,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;yBACzE,CAAA,CAAC,IAAI,CAAC,KAAK,IAAI,KAAK,CAAA,EAApB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AAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Route } from '@proteinjs/server-api';
|
|
2
|
+
/** What the route answers, for the page that called it: `{ state }`. */
|
|
3
|
+
export type VerifyEmailState = 'confirmed' | 'expired' | 'invalid';
|
|
4
|
+
/**
|
|
5
|
+
* `GET /user/verify-email?token=` — confirms an account's email address from the token in its
|
|
6
|
+
* mailed link. The link lands on the app's verify page (`uiRoutes.account.verifyEmail`), which
|
|
7
|
+
* calls this route with the token and shows the state it answers, the way the password-reset
|
|
8
|
+
* page calls its token routes: JSON, never a redirect.
|
|
9
|
+
*
|
|
10
|
+
* Resolves the presented token through `EmailVerificationToken` — which refuses anything but a
|
|
11
|
+
* well-formed token before any lookup — checks its expiry, and spends it: `emailVerified` is
|
|
12
|
+
* written and the token cleared in one conditional update, so a link confirms once.
|
|
13
|
+
* - 'confirmed': the address is now verified and the token spent;
|
|
14
|
+
* - 'expired': the link lapsed — the flag is unchanged; the account page's re-send mints a new one;
|
|
15
|
+
* - 'invalid': malformed, unknown, or already spent — the same word for all three, so the
|
|
16
|
+
* answer says nothing about whether a token ever existed.
|
|
17
|
+
* A request with no token at all is refused (400, 'invalid'). Nothing in any answer names an
|
|
18
|
+
* address, and the token itself never reaches the log.
|
|
19
|
+
*/
|
|
20
|
+
export declare const verifyEmail: Route;
|
|
21
|
+
//# sourceMappingURL=verifyEmail.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verifyEmail.d.ts","sourceRoot":"","sources":["../../../src/routes/verifyEmail.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAM9C,wEAAwE;AACxE,MAAM,MAAM,gBAAgB,GAAG,WAAW,GAAG,SAAS,GAAG,SAAS,CAAC;AAEnE;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,WAAW,EAAE,KAsCzB,CAAC"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
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;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.verifyEmail = void 0;
|
|
40
|
+
var user_1 = require("@proteinjs/user");
|
|
41
|
+
var logger_1 = require("@proteinjs/logger");
|
|
42
|
+
var util_node_1 = require("@proteinjs/util-node");
|
|
43
|
+
var EmailVerificationToken_1 = require("../authentication/EmailVerificationToken");
|
|
44
|
+
/**
|
|
45
|
+
* `GET /user/verify-email?token=` — confirms an account's email address from the token in its
|
|
46
|
+
* mailed link. The link lands on the app's verify page (`uiRoutes.account.verifyEmail`), which
|
|
47
|
+
* calls this route with the token and shows the state it answers, the way the password-reset
|
|
48
|
+
* page calls its token routes: JSON, never a redirect.
|
|
49
|
+
*
|
|
50
|
+
* Resolves the presented token through `EmailVerificationToken` — which refuses anything but a
|
|
51
|
+
* well-formed token before any lookup — checks its expiry, and spends it: `emailVerified` is
|
|
52
|
+
* written and the token cleared in one conditional update, so a link confirms once.
|
|
53
|
+
* - 'confirmed': the address is now verified and the token spent;
|
|
54
|
+
* - 'expired': the link lapsed — the flag is unchanged; the account page's re-send mints a new one;
|
|
55
|
+
* - 'invalid': malformed, unknown, or already spent — the same word for all three, so the
|
|
56
|
+
* answer says nothing about whether a token ever existed.
|
|
57
|
+
* A request with no token at all is refused (400, 'invalid'). Nothing in any answer names an
|
|
58
|
+
* address, and the token itself never reaches the log.
|
|
59
|
+
*/
|
|
60
|
+
exports.verifyEmail = {
|
|
61
|
+
path: user_1.routes.verifyEmail.path,
|
|
62
|
+
method: user_1.routes.verifyEmail.method,
|
|
63
|
+
onRequest: function (request, response) { return __awaiter(void 0, void 0, void 0, function () {
|
|
64
|
+
var logger, token, verification, resolution, account;
|
|
65
|
+
var _a;
|
|
66
|
+
return __generator(this, function (_b) {
|
|
67
|
+
switch (_b.label) {
|
|
68
|
+
case 0:
|
|
69
|
+
logger = new logger_1.Logger({ name: 'verifyEmail' });
|
|
70
|
+
token = ((_a = request.query) !== null && _a !== void 0 ? _a : {}).token;
|
|
71
|
+
if (!token) {
|
|
72
|
+
response.status(400).send({ state: 'invalid' });
|
|
73
|
+
return [2 /*return*/];
|
|
74
|
+
}
|
|
75
|
+
verification = new EmailVerificationToken_1.EmailVerificationToken();
|
|
76
|
+
return [4 /*yield*/, verification.resolve(token)];
|
|
77
|
+
case 1:
|
|
78
|
+
resolution = _b.sent();
|
|
79
|
+
if (resolution.status === 'malformed' || resolution.status === 'unknown') {
|
|
80
|
+
logger.info({
|
|
81
|
+
message: "Invalid email verification token used",
|
|
82
|
+
obj: { reason: resolution.status, token: verification.fingerprint(token) },
|
|
83
|
+
});
|
|
84
|
+
response.status(200).send({ state: 'invalid' });
|
|
85
|
+
return [2 /*return*/];
|
|
86
|
+
}
|
|
87
|
+
account = new util_node_1.RequestDigests().account(resolution.user.email);
|
|
88
|
+
if (resolution.status === 'expired') {
|
|
89
|
+
logger.info({ message: "Expired email verification token used", obj: { account: account } });
|
|
90
|
+
response.status(200).send({ state: 'expired' });
|
|
91
|
+
return [2 /*return*/];
|
|
92
|
+
}
|
|
93
|
+
return [4 /*yield*/, verification.confirm(resolution.user, resolution.token)];
|
|
94
|
+
case 2:
|
|
95
|
+
if (!(_b.sent())) {
|
|
96
|
+
logger.info({ message: "Email verification token already spent", obj: { account: account } });
|
|
97
|
+
response.status(200).send({ state: 'invalid' });
|
|
98
|
+
return [2 /*return*/];
|
|
99
|
+
}
|
|
100
|
+
logger.info({ message: "Email address verified", obj: { account: account } });
|
|
101
|
+
response.status(200).send({ state: 'confirmed' });
|
|
102
|
+
return [2 /*return*/];
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
}); },
|
|
106
|
+
};
|
|
107
|
+
//# sourceMappingURL=verifyEmail.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verifyEmail.js","sourceRoot":"","sources":["../../../src/routes/verifyEmail.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,wCAAyC;AACzC,4CAA2C;AAC3C,kDAAsD;AACtD,mFAAkF;AAKlF;;;;;;;;;;;;;;;GAeG;AACU,QAAA,WAAW,GAAU;IAChC,IAAI,EAAE,aAAM,CAAC,WAAW,CAAC,IAAI;IAC7B,MAAM,EAAE,aAAM,CAAC,WAAW,CAAC,MAAM;IACjC,SAAS,EAAE,UAAO,OAAO,EAAE,QAAQ;;;;;;oBAC3B,MAAM,GAAG,IAAI,eAAM,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC,CAAC;oBAC3C,KAAK,GAAK,CAAA,MAAA,OAAO,CAAC,KAAK,mCAAI,EAAE,CAAA,MAAxB,CAAyB;oBACtC,IAAI,CAAC,KAAK,EAAE;wBACV,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,SAAoC,EAAE,CAAC,CAAC;wBAC3E,sBAAO;qBACR;oBAEK,YAAY,GAAG,IAAI,+CAAsB,EAAE,CAAC;oBAC/B,qBAAM,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC,EAAA;;oBAA9C,UAAU,GAAG,SAAiC;oBACpD,IAAI,UAAU,CAAC,MAAM,KAAK,WAAW,IAAI,UAAU,CAAC,MAAM,KAAK,SAAS,EAAE;wBACxE,MAAM,CAAC,IAAI,CA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CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,WAAsC,EAAE,CAAC,CAAC;;;;SAC9E;CACF,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The common throwaway-mail domains — inboxes anyone can open or that are minted on demand with
|
|
3
|
+
* nobody behind them — so a sign-up from one is an account whose mail no one reads. A short list
|
|
4
|
+
* in code, no vendor, applied on the no-invite road before the guard: a deliverability check
|
|
5
|
+
* refuses only a domain that takes no mail, and a throwaway on a real domain passes it; this list
|
|
6
|
+
* is the other half. Written 2026-10-28.
|
|
7
|
+
*
|
|
8
|
+
* The rule for adding a domain: it goes on the list when its service describes itself as
|
|
9
|
+
* temporary, disposable or anonymous mail — addresses with no owner, read by whoever asks — and
|
|
10
|
+
* never when people hold their own mailboxes there (a webmail, a school, a company, a forwarding
|
|
11
|
+
* service with an owner behind each alias). Keep it short: the list carries the names that
|
|
12
|
+
* actually show up at the door, and a consumer's guard bounds the rest. Entries are lowercase
|
|
13
|
+
* registrable domains, one per line; a subdomain of a listed domain is refused with it.
|
|
14
|
+
*/
|
|
15
|
+
export declare class DisposableEmailDomains {
|
|
16
|
+
/** The one sentence a refused address is told — read by the person, shown in full. */
|
|
17
|
+
static readonly REFUSAL = "Use an email address you can read mail at.";
|
|
18
|
+
private static readonly DOMAINS;
|
|
19
|
+
/** Whether the address's domain is a listed domain or a subdomain of one; the case of the address does not matter. */
|
|
20
|
+
isDisposable(email: string): boolean;
|
|
21
|
+
/** The part after the last `@`, trimmed and lowercased; undefined when there is none. */
|
|
22
|
+
private domainOf;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=DisposableEmailDomains.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DisposableEmailDomains.d.ts","sourceRoot":"","sources":["../../../src/services/DisposableEmailDomains.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,qBAAa,sBAAsB;IACjC,sFAAsF;IACtF,MAAM,CAAC,QAAQ,CAAC,OAAO,gDAAgD;IAEvE,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CA0E5B;IAEH,sHAAsH;IACtH,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAiBpC,yFAAyF;IACzF,OAAO,CAAC,QAAQ;CAWjB"}
|