@proteinjs/user-server 1.26.1 → 1.27.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 +11 -0
- package/dist/generated/index.js +1 -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/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/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/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/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 +1 -1
- package/index.ts +10 -0
- package/package.json +2 -2
- package/src/routes/signup.ts +58 -9
- package/src/services/DisposableEmailDomains.ts +125 -0
- package/src/services/SignupGuard.ts +58 -0
- package/test/SignupGuardSeam.test.ts +299 -0
- package/test/UserServerTestEnvironment.ts +4 -0
|
@@ -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,KAA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AAC;QAC5E,YAAY,EAAE,OAAO,CAAC,MAAA,OAAO,CAAC,OAAO,0CAAG,YAAY,CAAC,CAAC;KACvD,CAAC,CAAA;CAAA,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"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DisposableEmailDomains = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* The common throwaway-mail domains — inboxes anyone can open or that are minted on demand with
|
|
6
|
+
* nobody behind them — so a sign-up from one is an account whose mail no one reads. A short list
|
|
7
|
+
* in code, no vendor, applied on the no-invite road before the guard: a deliverability check
|
|
8
|
+
* refuses only a domain that takes no mail, and a throwaway on a real domain passes it; this list
|
|
9
|
+
* is the other half. Written 2026-10-28.
|
|
10
|
+
*
|
|
11
|
+
* The rule for adding a domain: it goes on the list when its service describes itself as
|
|
12
|
+
* temporary, disposable or anonymous mail — addresses with no owner, read by whoever asks — and
|
|
13
|
+
* never when people hold their own mailboxes there (a webmail, a school, a company, a forwarding
|
|
14
|
+
* service with an owner behind each alias). Keep it short: the list carries the names that
|
|
15
|
+
* actually show up at the door, and a consumer's guard bounds the rest. Entries are lowercase
|
|
16
|
+
* registrable domains, one per line; a subdomain of a listed domain is refused with it.
|
|
17
|
+
*/
|
|
18
|
+
var DisposableEmailDomains = /** @class */ (function () {
|
|
19
|
+
function DisposableEmailDomains() {
|
|
20
|
+
}
|
|
21
|
+
/** Whether the address's domain is a listed domain or a subdomain of one; the case of the address does not matter. */
|
|
22
|
+
DisposableEmailDomains.prototype.isDisposable = function (email) {
|
|
23
|
+
var domain = this.domainOf(email);
|
|
24
|
+
if (!domain) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
// `mail.mailinator.com` is refused with `mailinator.com`: every suffix at a label boundary
|
|
28
|
+
// is looked up, so a domain that merely ends with a listed name (`notmailinator.com`) is not.
|
|
29
|
+
var labels = domain.split('.');
|
|
30
|
+
for (var start = 0; start < labels.length - 1; start++) {
|
|
31
|
+
if (DisposableEmailDomains.DOMAINS.has(labels.slice(start).join('.'))) {
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return false;
|
|
36
|
+
};
|
|
37
|
+
/** The part after the last `@`, trimmed and lowercased; undefined when there is none. */
|
|
38
|
+
DisposableEmailDomains.prototype.domainOf = function (email) {
|
|
39
|
+
var at = email.lastIndexOf('@');
|
|
40
|
+
if (at < 0) {
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
var domain = email
|
|
44
|
+
.slice(at + 1)
|
|
45
|
+
.trim()
|
|
46
|
+
.toLowerCase();
|
|
47
|
+
return domain || undefined;
|
|
48
|
+
};
|
|
49
|
+
/** The one sentence a refused address is told — read by the person, shown in full. */
|
|
50
|
+
DisposableEmailDomains.REFUSAL = 'Use an email address you can read mail at.';
|
|
51
|
+
DisposableEmailDomains.DOMAINS = new Set([
|
|
52
|
+
'10minemail.com',
|
|
53
|
+
'10minutemail.com',
|
|
54
|
+
'10minutemail.net',
|
|
55
|
+
'anonbox.net',
|
|
56
|
+
'burnermail.io',
|
|
57
|
+
'cool.fr.nf',
|
|
58
|
+
'courriel.fr.nf',
|
|
59
|
+
'crazymailing.com',
|
|
60
|
+
'discard.email',
|
|
61
|
+
'dispostable.com',
|
|
62
|
+
'dropmail.me',
|
|
63
|
+
'emailfake.com',
|
|
64
|
+
'emailondeck.com',
|
|
65
|
+
'fakeinbox.com',
|
|
66
|
+
'fakemail.net',
|
|
67
|
+
'generator.email',
|
|
68
|
+
'getairmail.com',
|
|
69
|
+
'getnada.com',
|
|
70
|
+
'grr.la',
|
|
71
|
+
'guerrillamail.biz',
|
|
72
|
+
'guerrillamail.com',
|
|
73
|
+
'guerrillamail.de',
|
|
74
|
+
'guerrillamail.net',
|
|
75
|
+
'guerrillamail.org',
|
|
76
|
+
'guerrillamailblock.com',
|
|
77
|
+
'harakirimail.com',
|
|
78
|
+
'inboxkitten.com',
|
|
79
|
+
'jetable.fr.nf',
|
|
80
|
+
'jetable.org',
|
|
81
|
+
'mail-temp.com',
|
|
82
|
+
'mail7.io',
|
|
83
|
+
'mailcatch.com',
|
|
84
|
+
'maildrop.cc',
|
|
85
|
+
'mailexpire.com',
|
|
86
|
+
'mailin8r.com',
|
|
87
|
+
'mailinater.com',
|
|
88
|
+
'mailinator.com',
|
|
89
|
+
'mailinator2.com',
|
|
90
|
+
'mailnesia.com',
|
|
91
|
+
'mailpoof.com',
|
|
92
|
+
'mailsac.com',
|
|
93
|
+
'mailtemp.net',
|
|
94
|
+
'mega.zik.dj',
|
|
95
|
+
'meltmail.com',
|
|
96
|
+
'mintemail.com',
|
|
97
|
+
'mohmal.com',
|
|
98
|
+
'moncourrier.fr.nf',
|
|
99
|
+
'monemail.fr.nf',
|
|
100
|
+
'monmail.fr.nf',
|
|
101
|
+
'mytemp.email',
|
|
102
|
+
'nomail.xl.cx',
|
|
103
|
+
'nospam.ze.tc',
|
|
104
|
+
'pokemail.net',
|
|
105
|
+
'sharklasers.com',
|
|
106
|
+
'sogetthis.com',
|
|
107
|
+
'spam4.me',
|
|
108
|
+
'spambox.us',
|
|
109
|
+
'speed.1s.fr',
|
|
110
|
+
'temp-mail.io',
|
|
111
|
+
'temp-mail.org',
|
|
112
|
+
'tempail.com',
|
|
113
|
+
'tempinbox.com',
|
|
114
|
+
'tempmail.com',
|
|
115
|
+
'tempmail.dev',
|
|
116
|
+
'tempmailo.com',
|
|
117
|
+
'tempr.email',
|
|
118
|
+
'throwawaymail.com',
|
|
119
|
+
'trashmail.com',
|
|
120
|
+
'trashmail.me',
|
|
121
|
+
'trashmail.net',
|
|
122
|
+
'yopmail.com',
|
|
123
|
+
'yopmail.fr',
|
|
124
|
+
'yopmail.net',
|
|
125
|
+
]);
|
|
126
|
+
return DisposableEmailDomains;
|
|
127
|
+
}());
|
|
128
|
+
exports.DisposableEmailDomains = DisposableEmailDomains;
|
|
129
|
+
//# sourceMappingURL=DisposableEmailDomains.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DisposableEmailDomains.js","sourceRoot":"","sources":["../../../src/services/DisposableEmailDomains.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;GAaG;AACH;IAAA;IA8GA,CAAC;IA9BC,sHAAsH;IACtH,6CAAY,GAAZ,UAAa,KAAa;QACxB,IAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACpC,IAAI,CAAC,MAAM,EAAE;YACX,OAAO,KAAK,CAAC;SACd;QAED,2FAA2F;QAC3F,8FAA8F;QAC9F,IAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACjC,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,KAAK,EAAE,EAAE;YACtD,IAAI,sBAAsB,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE;gBACrE,OAAO,IAAI,CAAC;aACb;SACF;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,yFAAyF;IACjF,yCAAQ,GAAhB,UAAiB,KAAa;QAC5B,IAAM,EAAE,GAAG,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QAClC,IAAI,EAAE,GAAG,CAAC,EAAE;YACV,OAAO,SAAS,CAAC;SAClB;QACD,IAAM,MAAM,GAAG,KAAK;aACjB,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC;aACb,IAAI,EAAE;aACN,WAAW,EAAE,CAAC;QACjB,OAAO,MAAM,IAAI,SAAS,CAAC;IAC7B,CAAC;IA5GD,sFAAsF;IACtE,8BAAO,GAAG,4CAA4C,CAAC;IAE/C,8BAAO,GAAwB,IAAI,GAAG,CAAC;QAC7D,gBAAgB;QAChB,kBAAkB;QAClB,kBAAkB;QAClB,aAAa;QACb,eAAe;QACf,YAAY;QACZ,gBAAgB;QAChB,kBAAkB;QAClB,eAAe;QACf,iBAAiB;QACjB,aAAa;QACb,eAAe;QACf,iBAAiB;QACjB,eAAe;QACf,cAAc;QACd,iBAAiB;QACjB,gBAAgB;QAChB,aAAa;QACb,QAAQ;QACR,mBAAmB;QACnB,mBAAmB;QACnB,kBAAkB;QAClB,mBAAmB;QACnB,mBAAmB;QACnB,wBAAwB;QACxB,kBAAkB;QAClB,iBAAiB;QACjB,eAAe;QACf,aAAa;QACb,eAAe;QACf,UAAU;QACV,eAAe;QACf,aAAa;QACb,gBAAgB;QAChB,cAAc;QACd,gBAAgB;QAChB,gBAAgB;QAChB,iBAAiB;QACjB,eAAe;QACf,cAAc;QACd,aAAa;QACb,cAAc;QACd,aAAa;QACb,cAAc;QACd,eAAe;QACf,YAAY;QACZ,mBAAmB;QACnB,gBAAgB;QAChB,eAAe;QACf,cAAc;QACd,cAAc;QACd,cAAc;QACd,cAAc;QACd,iBAAiB;QACjB,eAAe;QACf,UAAU;QACV,YAAY;QACZ,aAAa;QACb,cAAc;QACd,eAAe;QACf,aAAa;QACb,eAAe;QACf,cAAc;QACd,cAAc;QACd,eAAe;QACf,aAAa;QACb,mBAAmB;QACnB,eAAe;QACf,cAAc;QACd,eAAe;QACf,aAAa;QACb,YAAY;QACZ,aAAa;KACd,CAAC,CAAC;IAgCL,6BAAC;CAAA,AA9GD,IA8GC;AA9GY,wDAAsB"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Loadable } from '@proteinjs/reflection';
|
|
2
|
+
/**
|
|
3
|
+
* What the signup route hands the guard about a no-invite submission: request facts only the
|
|
4
|
+
* route can read, reduced to what an abuse posture needs and never anything that identifies the
|
|
5
|
+
* client on its own.
|
|
6
|
+
*/
|
|
7
|
+
export type SignupGuardFacts = {
|
|
8
|
+
/** The address the form carries, trimmed and lowercased — the account's address if the signup goes through. */
|
|
9
|
+
email: string;
|
|
10
|
+
/**
|
|
11
|
+
* The form's honeypot field (`website`) when the form carries one — a field no person sees, so
|
|
12
|
+
* a value in it is bot-shaped. Undefined when the form has no such field.
|
|
13
|
+
*/
|
|
14
|
+
honeypot?: string;
|
|
15
|
+
/** The render-moment token the form carries, when it carries one — a consumer's time trap verifies it. */
|
|
16
|
+
formToken?: string;
|
|
17
|
+
/**
|
|
18
|
+
* The coarse hash of the client's address (`RequestDigests.coarseIp` of the address `ClientAddress`
|
|
19
|
+
* reads): the key a per-device window counts on and the name a log line gives a device. Never
|
|
20
|
+
* the address itself.
|
|
21
|
+
*/
|
|
22
|
+
clientDevice: string;
|
|
23
|
+
/** Whether the request carried a User-Agent header at all. */
|
|
24
|
+
hasUserAgent: boolean;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* The guard's answer, one of three:
|
|
28
|
+
* - `allow` — the signup continues: the account is created and its session established;
|
|
29
|
+
* - `refuse` — the route answers `{ error: sentence }` with no account and no session; the
|
|
30
|
+
* sentence is read by the person, so it is plain words in full;
|
|
31
|
+
* - `drop` — the route answers exactly as it answers success (`{}`) with no account and no
|
|
32
|
+
* session, and the caller cannot tell: the silent drop for a bot-shaped submission, which gets
|
|
33
|
+
* nothing to iterate against.
|
|
34
|
+
*/
|
|
35
|
+
export type SignupGuardVerdict = {
|
|
36
|
+
verdict: 'allow';
|
|
37
|
+
} | {
|
|
38
|
+
verdict: 'refuse';
|
|
39
|
+
sentence: string;
|
|
40
|
+
} | {
|
|
41
|
+
verdict: 'drop';
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* The seam a consumer plugs its sign-up abuse posture into — a honeypot, a time trap, a
|
|
45
|
+
* per-device throttle, a daily breaker, whatever it holds — by registering a class that
|
|
46
|
+
* implements this interface (the `DefaultInviteConfigFactory` pattern; the first registration
|
|
47
|
+
* found is the guard). The signup route consults it on the NO-INVITE road only: an invited
|
|
48
|
+
* address was chosen by an admin, and the invite road is unchanged. With no registration every
|
|
49
|
+
* submission is allowed.
|
|
50
|
+
*/
|
|
51
|
+
export interface DefaultSignupGuard extends Loadable {
|
|
52
|
+
check(facts: SignupGuardFacts): SignupGuardVerdict | Promise<SignupGuardVerdict>;
|
|
53
|
+
}
|
|
54
|
+
export declare const getDefaultSignupGuard: () => DefaultSignupGuard;
|
|
55
|
+
//# sourceMappingURL=SignupGuard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SignupGuard.d.ts","sourceRoot":"","sources":["../../../src/services/SignupGuard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAoB,MAAM,uBAAuB,CAAC;AAEnE;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,+GAA+G;IAC/G,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,0GAA0G;IAC1G,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,YAAY,EAAE,MAAM,CAAC;IACrB,8DAA8D;IAC9D,YAAY,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,GAAG;IAAE,OAAO,EAAE,QAAQ,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAEtH;;;;;;;GAOG;AACH,MAAM,WAAW,kBAAmB,SAAQ,QAAQ;IAClD,KAAK,CAAC,KAAK,EAAE,gBAAgB,GAAG,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;CAClF;AAED,eAAO,MAAM,qBAAqB,QAAO,kBAOxC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getDefaultSignupGuard = void 0;
|
|
4
|
+
var reflection_1 = require("@proteinjs/reflection");
|
|
5
|
+
var getDefaultSignupGuard = function () {
|
|
6
|
+
var allowEvery = {
|
|
7
|
+
check: function () { return ({ verdict: 'allow' }); },
|
|
8
|
+
};
|
|
9
|
+
var guard = reflection_1.SourceRepository.get().object('@proteinjs/user-server/DefaultSignupGuard');
|
|
10
|
+
return guard || allowEvery;
|
|
11
|
+
};
|
|
12
|
+
exports.getDefaultSignupGuard = getDefaultSignupGuard;
|
|
13
|
+
//# sourceMappingURL=SignupGuard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SignupGuard.js","sourceRoot":"","sources":["../../../src/services/SignupGuard.ts"],"names":[],"mappings":";;;AAAA,oDAAmE;AAkD5D,IAAM,qBAAqB,GAAG;IACnC,IAAM,UAAU,GAAuB;QACrC,KAAK,EAAE,cAA0B,OAAA,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,EAAtB,CAAsB;KACxD,CAAC;IAEF,IAAM,KAAK,GAAG,6BAAgB,CAAC,GAAG,EAAE,CAAC,MAAM,CAAqB,2CAA2C,CAAC,CAAC;IAC7G,OAAO,KAAK,IAAI,UAAU,CAAC;AAC7B,CAAC,CAAC;AAPW,QAAA,qBAAqB,yBAOhC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SignupGuardSeam.test.d.ts","sourceRoot":"","sources":["../../test/SignupGuardSeam.test.ts"],"names":[],"mappings":""}
|