@carlonicora/nestjs-neo4jsonapi 8.3.0 → 8.5.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/dist/common/interfaces/assistant.user-message.interface.d.ts +33 -0
- package/dist/common/interfaces/assistant.user-message.interface.d.ts.map +1 -0
- package/dist/common/interfaces/assistant.user-message.interface.js +17 -0
- package/dist/common/interfaces/assistant.user-message.interface.js.map +1 -0
- package/dist/common/interfaces/index.d.ts +1 -0
- package/dist/common/interfaces/index.d.ts.map +1 -1
- package/dist/common/interfaces/index.js +1 -0
- package/dist/common/interfaces/index.js.map +1 -1
- package/dist/foundations/assistant/services/assistant.service.d.ts +8 -1
- package/dist/foundations/assistant/services/assistant.service.d.ts.map +1 -1
- package/dist/foundations/assistant/services/assistant.service.js +44 -2
- package/dist/foundations/assistant/services/assistant.service.js.map +1 -1
- package/dist/foundations/auth/auth.module.d.ts.map +1 -1
- package/dist/foundations/auth/auth.module.js +5 -0
- package/dist/foundations/auth/auth.module.js.map +1 -1
- package/dist/foundations/auth/controllers/auth.controller.d.ts +5 -1
- package/dist/foundations/auth/controllers/auth.controller.d.ts.map +1 -1
- package/dist/foundations/auth/controllers/auth.controller.js +25 -2
- package/dist/foundations/auth/controllers/auth.controller.js.map +1 -1
- package/dist/foundations/auth/controllers/auth.discord.controller.d.ts +1 -1
- package/dist/foundations/auth/controllers/auth.discord.controller.d.ts.map +1 -1
- package/dist/foundations/auth/controllers/auth.discord.controller.js +6 -3
- package/dist/foundations/auth/controllers/auth.discord.controller.js.map +1 -1
- package/dist/foundations/auth/entities/pending-registration.meta.d.ts +3 -0
- package/dist/foundations/auth/entities/pending-registration.meta.d.ts.map +1 -0
- package/dist/foundations/auth/entities/pending-registration.meta.js +10 -0
- package/dist/foundations/auth/entities/pending-registration.meta.js.map +1 -0
- package/dist/foundations/auth/entities/pending-registration.resource.d.ts +30 -0
- package/dist/foundations/auth/entities/pending-registration.resource.d.ts.map +1 -0
- package/dist/foundations/auth/entities/pending-registration.resource.js +52 -0
- package/dist/foundations/auth/entities/pending-registration.resource.js.map +1 -0
- package/dist/foundations/auth/index.d.ts +5 -0
- package/dist/foundations/auth/index.d.ts.map +1 -1
- package/dist/foundations/auth/index.js +9 -1
- package/dist/foundations/auth/index.js.map +1 -1
- package/dist/foundations/auth/interfaces/registration-pass.interface.d.ts +29 -0
- package/dist/foundations/auth/interfaces/registration-pass.interface.d.ts.map +1 -0
- package/dist/foundations/auth/interfaces/registration-pass.interface.js +8 -0
- package/dist/foundations/auth/interfaces/registration-pass.interface.js.map +1 -0
- package/dist/foundations/auth/services/auth.discord.service.d.ts +6 -2
- package/dist/foundations/auth/services/auth.discord.service.d.ts.map +1 -1
- package/dist/foundations/auth/services/auth.discord.service.js +38 -9
- package/dist/foundations/auth/services/auth.discord.service.js.map +1 -1
- package/dist/foundations/auth/services/auth.service.d.ts +10 -0
- package/dist/foundations/auth/services/auth.service.d.ts.map +1 -1
- package/dist/foundations/auth/services/auth.service.js +57 -5
- package/dist/foundations/auth/services/auth.service.js.map +1 -1
- package/dist/foundations/auth/services/pending-registration.service.d.ts +2 -0
- package/dist/foundations/auth/services/pending-registration.service.d.ts.map +1 -1
- package/dist/foundations/auth/services/pending-registration.service.js.map +1 -1
- package/dist/foundations/auth/utils/resolve-registration-pass.d.ts +10 -0
- package/dist/foundations/auth/utils/resolve-registration-pass.d.ts.map +1 -0
- package/dist/foundations/auth/utils/resolve-registration-pass.js +19 -0
- package/dist/foundations/auth/utils/resolve-registration-pass.js.map +1 -0
- package/package.json +1 -1
|
@@ -24,9 +24,14 @@ const auth_meta_1 = require("../../auth/entities/auth.meta");
|
|
|
24
24
|
const auth_service_1 = require("../../auth/services/auth.service");
|
|
25
25
|
const module_decorator_1 = require("../../../common/decorators/module.decorator");
|
|
26
26
|
const core_module_ids_1 = require("../../../common/constants/core-module.ids");
|
|
27
|
+
const audit_decorator_1 = require("../../../common/decorators/audit.decorator");
|
|
28
|
+
const audit_service_1 = require("../../audit/services/audit.service");
|
|
29
|
+
const pending_registration_meta_1 = require("../entities/pending-registration.meta");
|
|
27
30
|
let AuthController = class AuthController {
|
|
28
|
-
|
|
31
|
+
// auditService is optional: consumers subclass this controller with super(authService).
|
|
32
|
+
constructor(service, auditService) {
|
|
29
33
|
this.service = service;
|
|
34
|
+
this.auditService = auditService;
|
|
30
35
|
}
|
|
31
36
|
async findAuth(code) {
|
|
32
37
|
return await this.service.findAuthByCode({ code: code });
|
|
@@ -78,6 +83,11 @@ let AuthController = class AuthController {
|
|
|
78
83
|
async activateAccount(code, language) {
|
|
79
84
|
await this.service.activateAccount(code, language);
|
|
80
85
|
}
|
|
86
|
+
// Public: the pending id is an unguessable UUID that expires after 15 minutes.
|
|
87
|
+
async findPendingRegistration(_req, reply, pendingId) {
|
|
88
|
+
const response = await this.service.findPendingRegistration({ pendingId });
|
|
89
|
+
reply.send(response);
|
|
90
|
+
}
|
|
81
91
|
async completeOAuthRegistration(body, language) {
|
|
82
92
|
return this.service.completeOAuthRegistration(body, language);
|
|
83
93
|
}
|
|
@@ -169,6 +179,17 @@ __decorate([
|
|
|
169
179
|
__metadata("design:paramtypes", [String, String]),
|
|
170
180
|
__metadata("design:returntype", Promise)
|
|
171
181
|
], AuthController.prototype, "activateAccount", null);
|
|
182
|
+
__decorate([
|
|
183
|
+
(0, throttler_1.Throttle)({ default: { limit: 10, ttl: 60000 }, ip: { limit: 10, ttl: 60000 } }),
|
|
184
|
+
(0, common_1.Get)(`oauth/${pending_registration_meta_1.pendingRegistrationMeta.endpoint}/:pendingId`),
|
|
185
|
+
(0, audit_decorator_1.Audit)(pending_registration_meta_1.pendingRegistrationMeta, "pendingId"),
|
|
186
|
+
__param(0, (0, common_1.Req)()),
|
|
187
|
+
__param(1, (0, common_1.Res)()),
|
|
188
|
+
__param(2, (0, common_1.Param)("pendingId")),
|
|
189
|
+
__metadata("design:type", Function),
|
|
190
|
+
__metadata("design:paramtypes", [Object, Object, String]),
|
|
191
|
+
__metadata("design:returntype", Promise)
|
|
192
|
+
], AuthController.prototype, "findPendingRegistration", null);
|
|
172
193
|
__decorate([
|
|
173
194
|
(0, common_1.Post)("oauth/complete"),
|
|
174
195
|
__param(0, (0, common_1.Body)()),
|
|
@@ -180,6 +201,8 @@ __decorate([
|
|
|
180
201
|
exports.AuthController = AuthController = __decorate([
|
|
181
202
|
(0, module_decorator_1.ModuleACL)({ module: core_module_ids_1.CoreModuleId.Auth }),
|
|
182
203
|
(0, common_1.Controller)(auth_meta_1.authMeta.endpoint),
|
|
183
|
-
|
|
204
|
+
__param(1, (0, common_1.Optional)()),
|
|
205
|
+
__metadata("design:paramtypes", [auth_service_1.AuthService,
|
|
206
|
+
audit_service_1.AuditService])
|
|
184
207
|
], AuthController);
|
|
185
208
|
//# sourceMappingURL=auth.controller.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.controller.js","sourceRoot":"","sources":["../../../../src/foundations/auth/controllers/auth.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"auth.controller.js","sourceRoot":"","sources":["../../../../src/foundations/auth/controllers/auth.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAewB;AACxB,iDAA6C;AAG7C,0EAAqE;AACrE,+EAAyE;AACzE,6EAAuE;AACvE,mFAA6E;AAC7E,6FAAuF;AACvF,6DAAyD;AACzD,mEAA+D;AAC/D,kFAAwE;AACxE,+EAAyE;AACzE,gFAAmE;AACnE,sEAAkE;AAClE,qFAAgF;AAIzE,IAAM,cAAc,GAApB,MAAM,cAAc;IACzB,wFAAwF;IACxF,YACmB,OAAoB,EACR,YAA2B;QADvC,YAAO,GAAP,OAAO,CAAa;QACR,iBAAY,GAAZ,YAAY,CAAe;IACvD,CAAC;IAGE,AAAN,KAAK,CAAC,QAAQ,CAAgB,IAAY;QACxC,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,EAAE,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AuB,EAAE,WAAW,CAAC;IAGzC,WAAA,IAAA,YAAG,GAAE,CAAA;IACL,WAAA,IAAA,YAAG,GAAE,CAAA;IACL,WAAA,IAAA,cAAK,EAAC,WAAW,CAAC,CAAA;;;;6DAIpB;AAGK;IADL,IAAA,aAAI,EAAC,gBAAgB,CAAC;IAEpB,WAAA,IAAA,aAAI,GAAE,CAAA;IAON,WAAA,IAAA,gBAAO,EAAC,YAAY,CAAC,CAAA;;;;+DAGvB;yBApHU,cAAc;IAF1B,IAAA,4BAAS,EAAC,EAAE,MAAM,EAAE,8BAAY,CAAC,IAAI,EAAE,CAAC;IACxC,IAAA,mBAAU,EAAC,oBAAQ,CAAC,QAAQ,CAAC;IAKzB,WAAA,IAAA,iBAAQ,GAAE,CAAA;qCADe,0BAAW;QACO,4BAAY;GAJ/C,cAAc,CAqH1B"}
|
|
@@ -7,7 +7,7 @@ export declare class AuthDiscordController {
|
|
|
7
7
|
private readonly configService;
|
|
8
8
|
constructor(authDiscordService: AuthDiscordService, configService: ConfigService<BaseConfigInterface>);
|
|
9
9
|
private get discordConfig();
|
|
10
|
-
loginWithDiscord(reply: FastifyReply, inviteCode?: string, referralCode?: string, source?: string): Promise<void>;
|
|
10
|
+
loginWithDiscord(reply: FastifyReply, inviteCode?: string, referralCode?: string, source?: string, pass?: string): Promise<void>;
|
|
11
11
|
callbackDiscord(reply: FastifyReply, code: string, state?: string): Promise<void>;
|
|
12
12
|
}
|
|
13
13
|
//# sourceMappingURL=auth.discord.controller.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.discord.controller.d.ts","sourceRoot":"","sources":["../../../../src/foundations/auth/controllers/auth.discord.controller.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAKvC,OAAO,EAAE,mBAAmB,EAA0B,MAAM,4BAA4B,CAAC;AAEzF,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAEtE,qBACa,qBAAqB;IAE9B,OAAO,CAAC,QAAQ,CAAC,kBAAkB;IACnC,OAAO,CAAC,QAAQ,CAAC,aAAa;gBADb,kBAAkB,EAAE,kBAAkB,EACtC,aAAa,EAAE,aAAa,CAAC,mBAAmB,CAAC;IAGpE,OAAO,KAAK,aAAa,GAExB;IAGK,gBAAgB,CACb,KAAK,EAAE,YAAY,EACT,UAAU,CAAC,EAAE,MAAM,EACjB,YAAY,CAAC,EAAE,MAAM,EACvB,MAAM,CAAC,EAAE,MAAM;
|
|
1
|
+
{"version":3,"file":"auth.discord.controller.d.ts","sourceRoot":"","sources":["../../../../src/foundations/auth/controllers/auth.discord.controller.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAKvC,OAAO,EAAE,mBAAmB,EAA0B,MAAM,4BAA4B,CAAC;AAEzF,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAEtE,qBACa,qBAAqB;IAE9B,OAAO,CAAC,QAAQ,CAAC,kBAAkB;IACnC,OAAO,CAAC,QAAQ,CAAC,aAAa;gBADb,kBAAkB,EAAE,kBAAkB,EACtC,aAAa,EAAE,aAAa,CAAC,mBAAmB,CAAC;IAGpE,OAAO,KAAK,aAAa,GAExB;IAGK,gBAAgB,CACb,KAAK,EAAE,YAAY,EACT,UAAU,CAAC,EAAE,MAAM,EACjB,YAAY,CAAC,EAAE,MAAM,EACvB,MAAM,CAAC,EAAE,MAAM,EACjB,IAAI,CAAC,EAAE,MAAM;IASxB,eAAe,CAAQ,KAAK,EAAE,YAAY,EAAiB,IAAI,EAAE,MAAM,EAAkB,KAAK,CAAC,EAAE,MAAM;CAqB9G"}
|
|
@@ -28,10 +28,10 @@ let AuthDiscordController = class AuthDiscordController {
|
|
|
28
28
|
get discordConfig() {
|
|
29
29
|
return this.configService.get("discord");
|
|
30
30
|
}
|
|
31
|
-
async loginWithDiscord(reply, inviteCode, referralCode, source) {
|
|
31
|
+
async loginWithDiscord(reply, inviteCode, referralCode, source, pass) {
|
|
32
32
|
if (!this.discordConfig.clientId || !this.discordConfig.clientSecret)
|
|
33
33
|
throw new common_1.HttpException("Login with Discord is not available", common_1.HttpStatus.NOT_IMPLEMENTED);
|
|
34
|
-
reply.redirect(this.authDiscordService.generateLoginUrl(inviteCode, referralCode, source), 302);
|
|
34
|
+
reply.redirect(this.authDiscordService.generateLoginUrl(inviteCode, referralCode, source, pass), 302);
|
|
35
35
|
}
|
|
36
36
|
async callbackDiscord(reply, code, state) {
|
|
37
37
|
// Parse invite code and referral code from state if present
|
|
@@ -39,6 +39,7 @@ let AuthDiscordController = class AuthDiscordController {
|
|
|
39
39
|
const inviteCode = stateData?.invite;
|
|
40
40
|
const referralCode = stateData?.referral;
|
|
41
41
|
const source = stateData?.source;
|
|
42
|
+
const pass = stateData?.pass;
|
|
42
43
|
const accessToken = await this.authDiscordService.exchangeCodeForToken(code);
|
|
43
44
|
const userDetails = await this.authDiscordService.fetchUserDetails(accessToken);
|
|
44
45
|
const redirectUrl = await this.authDiscordService.handleDiscordLogin({
|
|
@@ -46,6 +47,7 @@ let AuthDiscordController = class AuthDiscordController {
|
|
|
46
47
|
inviteCode,
|
|
47
48
|
referralCode,
|
|
48
49
|
source,
|
|
50
|
+
pass,
|
|
49
51
|
});
|
|
50
52
|
reply.redirect(redirectUrl, 302);
|
|
51
53
|
}
|
|
@@ -57,8 +59,9 @@ __decorate([
|
|
|
57
59
|
__param(1, (0, common_1.Query)("invite")),
|
|
58
60
|
__param(2, (0, common_1.Query)("referral")),
|
|
59
61
|
__param(3, (0, common_1.Query)("source")),
|
|
62
|
+
__param(4, (0, common_1.Query)("pass")),
|
|
60
63
|
__metadata("design:type", Function),
|
|
61
|
-
__metadata("design:paramtypes", [Object, String, String, String]),
|
|
64
|
+
__metadata("design:paramtypes", [Object, String, String, String, String]),
|
|
62
65
|
__metadata("design:returntype", Promise)
|
|
63
66
|
], AuthDiscordController.prototype, "loginWithDiscord", null);
|
|
64
67
|
__decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.discord.controller.js","sourceRoot":"","sources":["../../../../src/foundations/auth/controllers/auth.discord.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAwF;AACxF,2CAA+C;AAE/C,sEAAsE;AACtE,8EAA8E;AAC9E,0CAA0C;AAC1C,qDAAiD;AAGjD,2EAAsE;AAG/D,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IAChC,YACmB,kBAAsC,EACtC,aAAiD;QADjD,uBAAkB,GAAlB,kBAAkB,CAAoB;QACtC,kBAAa,GAAb,aAAa,CAAoC;IACjE,CAAC;IAEJ,IAAY,aAAa;QACvB,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,CAAyB,SAAS,CAAC,CAAC;IACnE,CAAC;IAGK,AAAN,KAAK,CAAC,gBAAgB,CACb,KAAmB,EACT,UAAmB,EACjB,YAAqB,EACvB,MAAe;
|
|
1
|
+
{"version":3,"file":"auth.discord.controller.js","sourceRoot":"","sources":["../../../../src/foundations/auth/controllers/auth.discord.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAwF;AACxF,2CAA+C;AAE/C,sEAAsE;AACtE,8EAA8E;AAC9E,0CAA0C;AAC1C,qDAAiD;AAGjD,2EAAsE;AAG/D,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IAChC,YACmB,kBAAsC,EACtC,aAAiD;QADjD,uBAAkB,GAAlB,kBAAkB,CAAoB;QACtC,kBAAa,GAAb,aAAa,CAAoC;IACjE,CAAC;IAEJ,IAAY,aAAa;QACvB,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,CAAyB,SAAS,CAAC,CAAC;IACnE,CAAC;IAGK,AAAN,KAAK,CAAC,gBAAgB,CACb,KAAmB,EAC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IADL,IAAA,YAAG,EAAC,GAAG,oBAAQ,CAAC,QAAQ,UAAU,CAAC;IAEjC,WAAA,IAAA,YAAG,GAAE,CAAA;IACL,WAAA,IAAA,cAAK,EAAC,QAAQ,CAAC,CAAA;IACf,WAAA,IAAA,cAAK,EAAC,UAAU,CAAC,CAAA;IACjB,WAAA,IAAA,cAAK,EAAC,QAAQ,CAAC,CAAA;IACf,WAAA,IAAA,cAAK,EAAC,MAAM,CAAC,CAAA;;;;6DAMf;AAGK;IADL,IAAA,YAAG,EAAC,GAAG,oBAAQ,CAAC,QAAQ,mBAAmB,CAAC;IACtB,WAAA,IAAA,YAAG,GAAE,CAAA;IAAuB,WAAA,IAAA,cAAK,EAAC,MAAM,CAAC,CAAA;IAAgB,WAAA,IAAA,cAAK,EAAC,OAAO,CAAC,CAAA;;;;4DAoB7F;gCA7CU,qBAAqB;IADjC,IAAA,mBAAU,GAAE;qCAG4B,yCAAkB;QACvB,sBAAa;GAHpC,qBAAqB,CA8CjC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pending-registration.meta.d.ts","sourceRoot":"","sources":["../../../../src/foundations/auth/entities/pending-registration.meta.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gDAAgD,CAAC;AAE1E,eAAO,MAAM,uBAAuB,EAAE,QAKrC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.pendingRegistrationMeta = void 0;
|
|
4
|
+
exports.pendingRegistrationMeta = {
|
|
5
|
+
type: "pending-registrations",
|
|
6
|
+
endpoint: "pending-registrations",
|
|
7
|
+
nodeName: "pendingRegistration",
|
|
8
|
+
labelName: "PendingRegistration",
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=pending-registration.meta.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pending-registration.meta.js","sourceRoot":"","sources":["../../../../src/foundations/auth/entities/pending-registration.meta.ts"],"names":[],"mappings":";;;AAEa,QAAA,uBAAuB,GAAa;IAC/C,IAAI,EAAE,uBAAuB;IAC7B,QAAQ,EAAE,uBAAuB;IACjC,QAAQ,EAAE,qBAAqB;IAC/B,SAAS,EAAE,qBAAqB;CACjC,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Entity } from "../../../common";
|
|
2
|
+
/**
|
|
3
|
+
* PendingRegistrationResource Entity Type
|
|
4
|
+
*
|
|
5
|
+
* The read-only view of an OAuth sign-up waiting for the user to accept the
|
|
6
|
+
* terms (the Redis `PendingRegistration` record, which keeps that name).
|
|
7
|
+
*
|
|
8
|
+
* NEVER persisted: no `:PendingRegistration` node exists in Neo4j.
|
|
9
|
+
* `AuthService.findPendingRegistration` hands a plain object straight to
|
|
10
|
+
* `JsonApiService.buildSingle`, so the descriptor only describes the JSON:API
|
|
11
|
+
* shape. `hasPass` and `emailInUse` are derived by the service yet declared as
|
|
12
|
+
* fields, because `computed` needs a Neo4j record (owner decision D-C).
|
|
13
|
+
*/
|
|
14
|
+
export type PendingRegistrationResource = Entity & {
|
|
15
|
+
name: string;
|
|
16
|
+
email: string;
|
|
17
|
+
avatar?: string;
|
|
18
|
+
provider: string;
|
|
19
|
+
hasPass: boolean;
|
|
20
|
+
emailInUse: boolean;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* PendingRegistration Entity Descriptor
|
|
24
|
+
*
|
|
25
|
+
* SECURITY: not registered with the GraphDescriptorRegistry — it carries the
|
|
26
|
+
* name and email of someone who has no account yet.
|
|
27
|
+
*/
|
|
28
|
+
export declare const PendingRegistrationDescriptor: import("../../../common").EntityDescriptor<PendingRegistrationResource, {}>;
|
|
29
|
+
export type PendingRegistrationDescriptorType = typeof PendingRegistrationDescriptor;
|
|
30
|
+
//# sourceMappingURL=pending-registration.resource.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pending-registration.resource.d.ts","sourceRoot":"","sources":["../../../../src/foundations/auth/entities/pending-registration.resource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAGvD;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,2BAA2B,GAAG,MAAM,GAAG;IACjD,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,6BAA6B,6EA4CxC,CAAC;AAEH,MAAM,MAAM,iCAAiC,GAAG,OAAO,6BAA6B,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PendingRegistrationDescriptor = void 0;
|
|
4
|
+
const common_1 = require("../../../common");
|
|
5
|
+
const pending_registration_meta_1 = require("./pending-registration.meta");
|
|
6
|
+
/**
|
|
7
|
+
* PendingRegistration Entity Descriptor
|
|
8
|
+
*
|
|
9
|
+
* SECURITY: not registered with the GraphDescriptorRegistry — it carries the
|
|
10
|
+
* name and email of someone who has no account yet.
|
|
11
|
+
*/
|
|
12
|
+
exports.PendingRegistrationDescriptor = (0, common_1.defineEntity)()({
|
|
13
|
+
...pending_registration_meta_1.pendingRegistrationMeta,
|
|
14
|
+
// Not persisted, never joined to a Company: no account exists yet.
|
|
15
|
+
isCompanyScoped: false,
|
|
16
|
+
tenancy: "internal",
|
|
17
|
+
description: "An OAuth sign-up (registrazione in sospeso) waiting for the user to accept the terms before the account is created.",
|
|
18
|
+
fields: {
|
|
19
|
+
name: {
|
|
20
|
+
type: "string",
|
|
21
|
+
required: true,
|
|
22
|
+
description: "The display name returned by the OAuth provider.",
|
|
23
|
+
},
|
|
24
|
+
email: {
|
|
25
|
+
type: "string",
|
|
26
|
+
required: true,
|
|
27
|
+
description: "The email returned by the OAuth provider; the account will use it.",
|
|
28
|
+
},
|
|
29
|
+
avatar: {
|
|
30
|
+
type: "string",
|
|
31
|
+
description: "The avatar URL returned by the OAuth provider.",
|
|
32
|
+
},
|
|
33
|
+
provider: {
|
|
34
|
+
type: "string",
|
|
35
|
+
required: true,
|
|
36
|
+
description: "The OAuth provider the user signed in with (discord, google).",
|
|
37
|
+
},
|
|
38
|
+
hasPass: {
|
|
39
|
+
type: "boolean",
|
|
40
|
+
required: true,
|
|
41
|
+
description: "True when the sign-up carries a registration pass supplied by the application.",
|
|
42
|
+
},
|
|
43
|
+
emailInUse: {
|
|
44
|
+
type: "boolean",
|
|
45
|
+
required: true,
|
|
46
|
+
description: "True when a user (including a deleted one) already has this email, so the sign-up cannot complete.",
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
// No relationships: the pending sign-up carries no resource linkage.
|
|
50
|
+
relationships: {},
|
|
51
|
+
});
|
|
52
|
+
//# sourceMappingURL=pending-registration.resource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pending-registration.resource.js","sourceRoot":"","sources":["../../../../src/foundations/auth/entities/pending-registration.resource.ts"],"names":[],"mappings":";;;AAAA,4CAAuD;AACvD,2EAAsE;AAuBtE;;;;;GAKG;AACU,QAAA,6BAA6B,GAAG,IAAA,qBAAY,GAA+B,CAAC;IACvF,GAAG,mDAAuB;IAE1B,mEAAmE;IACnE,eAAe,EAAE,KAAK;IACtB,OAAO,EAAE,UAAU;IAEnB,WAAW,EACT,qHAAqH;IAEvH,MAAM,EAAE;QACN,IAAI,EAAE;YACJ,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;YACd,WAAW,EAAE,kDAAkD;SAChE;QACD,KAAK,EAAE;YACL,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;YACd,WAAW,EAAE,oEAAoE;SAClF;QACD,MAAM,EAAE;YACN,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,gDAAgD;SAC9D;QACD,QAAQ,EAAE;YACR,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;YACd,WAAW,EAAE,+DAA+D;SAC7E;QACD,OAAO,EAAE;YACP,IAAI,EAAE,SAAS;YACf,QAAQ,EAAE,IAAI;YACd,WAAW,EAAE,gFAAgF;SAC9F;QACD,UAAU,EAAE;YACV,IAAI,EAAE,SAAS;YACf,QAAQ,EAAE,IAAI;YACd,WAAW,EAAE,oGAAoG;SAClH;KACF;IAED,qEAAqE;IACrE,aAAa,EAAE,EAAE;CAClB,CAAC,CAAC"}
|
|
@@ -13,8 +13,13 @@ export { authMeta } from "./entities/auth.meta";
|
|
|
13
13
|
export { USER_ACTIVATED_EVENT } from "./events/auth.events";
|
|
14
14
|
export type { UserActivatedEvent } from "./events/auth.events";
|
|
15
15
|
export { PendingAuth, PendingAuthDescriptor } from "./entities/pending-auth";
|
|
16
|
+
export { PendingRegistrationResource, PendingRegistrationDescriptor } from "./entities/pending-registration.resource";
|
|
17
|
+
export { pendingRegistrationMeta } from "./entities/pending-registration.meta";
|
|
16
18
|
export { pendingAuthMeta } from "./entities/pending-auth.meta";
|
|
17
19
|
export { REGISTRATION_HOOK, RegistrationHookInterface } from "./interfaces/registration-hook.interface";
|
|
20
|
+
export { REGISTRATION_PASS } from "./interfaces/registration-pass.interface";
|
|
21
|
+
export type { RegistrationPassInterface, RegistrationPassVerdict } from "./interfaces/registration-pass.interface";
|
|
22
|
+
export { resolveRegistrationPass } from "./utils/resolve-registration-pass";
|
|
18
23
|
export { AuthRepository } from "./repositories/auth.repository";
|
|
19
24
|
export { AuthGoogleService } from "./services/auth.google.service";
|
|
20
25
|
export { AuthService } from "./services/auth.service";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/foundations/auth/index.ts"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EAAE,MAAM,0CAA0C,CAAC;AACxG,OAAO,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAC7E,YAAY,EAAE,yBAAyB,EAAE,uBAAuB,EAAE,MAAM,0CAA0C,CAAC;AACnH,OAAO,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAC;AACrF,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TrialQueueService = exports.PendingRegistrationService = exports.AuthService = exports.AuthGoogleService = exports.AuthRepository = exports.REGISTRATION_HOOK = exports.pendingAuthMeta = exports.PendingAuthDescriptor = exports.USER_ACTIVATED_EVENT = exports.authMeta = exports.authCodeMeta = exports.AuthCodeDescriptor = exports.AuthDescriptor = exports.AuthPostResetPasswordDTO = exports.AuthPostRegisterDTO = exports.AuthPostRegisterDataDTO = exports.AuthPostRegisterAttributesDTO = exports.AuthPostLoginDTO = exports.AuthPostLoginDataDTO = exports.AuthPostLoginAttributesDTO = exports.AuthPostForgotDTO = exports.AuthGoogleController = exports.AuthController = exports.AuthCompanyController = exports.AuthModule = void 0;
|
|
3
|
+
exports.TrialQueueService = exports.PendingRegistrationService = exports.AuthService = exports.AuthGoogleService = exports.AuthRepository = exports.resolveRegistrationPass = exports.REGISTRATION_PASS = exports.REGISTRATION_HOOK = exports.pendingAuthMeta = exports.pendingRegistrationMeta = exports.PendingRegistrationDescriptor = exports.PendingAuthDescriptor = exports.USER_ACTIVATED_EVENT = exports.authMeta = exports.authCodeMeta = exports.AuthCodeDescriptor = exports.AuthDescriptor = exports.AuthPostResetPasswordDTO = exports.AuthPostRegisterDTO = exports.AuthPostRegisterDataDTO = exports.AuthPostRegisterAttributesDTO = exports.AuthPostLoginDTO = exports.AuthPostLoginDataDTO = exports.AuthPostLoginAttributesDTO = exports.AuthPostForgotDTO = exports.AuthGoogleController = exports.AuthController = exports.AuthCompanyController = exports.AuthModule = void 0;
|
|
4
4
|
var auth_module_1 = require("./auth.module");
|
|
5
5
|
Object.defineProperty(exports, "AuthModule", { enumerable: true, get: function () { return auth_module_1.AuthModule; } });
|
|
6
6
|
var auth_company_controller_1 = require("./controllers/auth.company.controller");
|
|
@@ -33,10 +33,18 @@ var auth_events_1 = require("./events/auth.events");
|
|
|
33
33
|
Object.defineProperty(exports, "USER_ACTIVATED_EVENT", { enumerable: true, get: function () { return auth_events_1.USER_ACTIVATED_EVENT; } });
|
|
34
34
|
var pending_auth_1 = require("./entities/pending-auth");
|
|
35
35
|
Object.defineProperty(exports, "PendingAuthDescriptor", { enumerable: true, get: function () { return pending_auth_1.PendingAuthDescriptor; } });
|
|
36
|
+
var pending_registration_resource_1 = require("./entities/pending-registration.resource");
|
|
37
|
+
Object.defineProperty(exports, "PendingRegistrationDescriptor", { enumerable: true, get: function () { return pending_registration_resource_1.PendingRegistrationDescriptor; } });
|
|
38
|
+
var pending_registration_meta_1 = require("./entities/pending-registration.meta");
|
|
39
|
+
Object.defineProperty(exports, "pendingRegistrationMeta", { enumerable: true, get: function () { return pending_registration_meta_1.pendingRegistrationMeta; } });
|
|
36
40
|
var pending_auth_meta_1 = require("./entities/pending-auth.meta");
|
|
37
41
|
Object.defineProperty(exports, "pendingAuthMeta", { enumerable: true, get: function () { return pending_auth_meta_1.pendingAuthMeta; } });
|
|
38
42
|
var registration_hook_interface_1 = require("./interfaces/registration-hook.interface");
|
|
39
43
|
Object.defineProperty(exports, "REGISTRATION_HOOK", { enumerable: true, get: function () { return registration_hook_interface_1.REGISTRATION_HOOK; } });
|
|
44
|
+
var registration_pass_interface_1 = require("./interfaces/registration-pass.interface");
|
|
45
|
+
Object.defineProperty(exports, "REGISTRATION_PASS", { enumerable: true, get: function () { return registration_pass_interface_1.REGISTRATION_PASS; } });
|
|
46
|
+
var resolve_registration_pass_1 = require("./utils/resolve-registration-pass");
|
|
47
|
+
Object.defineProperty(exports, "resolveRegistrationPass", { enumerable: true, get: function () { return resolve_registration_pass_1.resolveRegistrationPass; } });
|
|
40
48
|
var auth_repository_1 = require("./repositories/auth.repository");
|
|
41
49
|
Object.defineProperty(exports, "AuthRepository", { enumerable: true, get: function () { return auth_repository_1.AuthRepository; } });
|
|
42
50
|
var auth_google_service_1 = require("./services/auth.google.service");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/foundations/auth/index.ts"],"names":[],"mappings":";;;AAAA,6CAA2C;AAAlC,yGAAA,UAAU,OAAA;AACnB,iFAA8E;AAArE,gIAAA,qBAAqB,OAAA;AAC9B,iEAA+D;AAAtD,iHAAA,cAAc,OAAA;AACvB,+EAA4E;AAAnE,8HAAA,oBAAoB,OAAA;AAC7B,oEAAgE;AAAvD,yHAAA,iBAAiB,OAAA;AAC1B,kEAAgH;AAAvG,iIAAA,0BAA0B,OAAA;AAAE,2HAAA,oBAAoB,OAAA;AAAE,uHAAA,gBAAgB,OAAA;AAC3E,wEAIuC;AAHrC,uIAAA,6BAA6B,OAAA;AAC7B,iIAAA,uBAAuB,OAAA;AACvB,6HAAA,mBAAmB,OAAA;AAErB,kFAA8E;AAArE,uIAAA,wBAAwB,OAAA;AACjC,wCAAuD;AAAxC,sGAAA,cAAc,OAAA;AAC7B,kDAAoE;AAAjD,+GAAA,kBAAkB,OAAA;AACrC,4DAAyD;AAAhD,8GAAA,YAAY,OAAA;AACrB,kDAAgD;AAAvC,qGAAA,QAAQ,OAAA;AACjB,oDAA4D;AAAnD,mHAAA,oBAAoB,OAAA;AAE7B,wDAA6E;AAAvD,qHAAA,q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OAAA;AACxB,wFAAwG;AAA/F,gIAAA,iBAAiB,OAAA;AAC1B,wFAA6E;AAApE,gIAAA,iBAAiB,OAAA;AAE1B,+EAA4E;AAAnE,oIAAA,uBAAuB,OAAA;AAChC,kEAAgE;AAAvD,iHAAA,cAAc,OAAA;AACvB,sEAAmE;AAA1D,wHAAA,iBAAiB,OAAA;AAC1B,wDAAsD;AAA7C,2GAAA,WAAW,OAAA;AACpB,wFAAqF;AAA5E,0IAAA,0BAA0B,OAAA;AACnC,sEAAmE;AAA1D,wHAAA,iBAAiB,OAAA"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Outcome of checking a registration pass for a provider user.
|
|
3
|
+
* - `valid`: the pass lets this provider user register.
|
|
4
|
+
* - `mismatch`: the pass exists but belongs to a different provider user.
|
|
5
|
+
* - `invalid`: the pass is missing, expired or no longer usable.
|
|
6
|
+
*/
|
|
7
|
+
export type RegistrationPassVerdict = "valid" | "mismatch" | "invalid";
|
|
8
|
+
/**
|
|
9
|
+
* Optional hook an application provides to let a specific provider user register
|
|
10
|
+
* (for example, skipping the waitlist) by carrying a "pass" through OAuth.
|
|
11
|
+
* Applications that provide no hook keep the default registration behaviour.
|
|
12
|
+
*/
|
|
13
|
+
export interface RegistrationPassInterface {
|
|
14
|
+
/** Whether this pass lets this provider user register. */
|
|
15
|
+
validate(params: {
|
|
16
|
+
pass: string;
|
|
17
|
+
provider: "discord";
|
|
18
|
+
providerUserId: string;
|
|
19
|
+
}): Promise<RegistrationPassVerdict>;
|
|
20
|
+
/** Called once the account exists; the pass cannot be reused. */
|
|
21
|
+
consume(params: {
|
|
22
|
+
pass: string;
|
|
23
|
+
}): Promise<void>;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Injection token for the optional registration pass hook
|
|
27
|
+
*/
|
|
28
|
+
export declare const REGISTRATION_PASS = "REGISTRATION_PASS";
|
|
29
|
+
//# sourceMappingURL=registration-pass.interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registration-pass.interface.d.ts","sourceRoot":"","sources":["../../../../src/foundations/auth/interfaces/registration-pass.interface.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,MAAM,uBAAuB,GAAG,OAAO,GAAG,UAAU,GAAG,SAAS,CAAC;AAEvE;;;;GAIG;AACH,MAAM,WAAW,yBAAyB;IACxC,0DAA0D;IAC1D,QAAQ,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,SAAS,CAAC;QAAC,cAAc,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;IAClH,iEAAiE;IACjE,OAAO,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAClD;AAED;;GAEG;AACH,eAAO,MAAM,iBAAiB,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.REGISTRATION_PASS = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Injection token for the optional registration pass hook
|
|
6
|
+
*/
|
|
7
|
+
exports.REGISTRATION_PASS = "REGISTRATION_PASS";
|
|
8
|
+
//# sourceMappingURL=registration-pass.interface.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registration-pass.interface.js","sourceRoot":"","sources":["../../../../src/foundations/auth/interfaces/registration-pass.interface.ts"],"names":[],"mappings":";;;AAoBA;;GAEG;AACU,QAAA,iBAAiB,GAAG,mBAAmB,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ConfigService } from "@nestjs/config";
|
|
2
|
+
import { ModuleRef } from "@nestjs/core";
|
|
2
3
|
import { ClsService } from "nestjs-cls";
|
|
3
4
|
import { AuthService } from "./auth.service";
|
|
4
5
|
import { BaseConfigInterface } from "../../../config";
|
|
@@ -16,21 +17,24 @@ export declare class AuthDiscordService {
|
|
|
16
17
|
private readonly config;
|
|
17
18
|
private readonly clsService;
|
|
18
19
|
private readonly pendingRegistrationService;
|
|
20
|
+
private readonly moduleRef;
|
|
19
21
|
private readonly waitlistService;
|
|
20
|
-
constructor(userRepository: UserRepository, discordUserRepository: DiscordUserRepository, discordUserService: DiscordUserService, authService: AuthService, config: ConfigService<BaseConfigInterface>, clsService: ClsService, pendingRegistrationService: PendingRegistrationService, waitlistService: WaitlistService | undefined);
|
|
22
|
+
constructor(userRepository: UserRepository, discordUserRepository: DiscordUserRepository, discordUserService: DiscordUserService, authService: AuthService, config: ConfigService<BaseConfigInterface>, clsService: ClsService, pendingRegistrationService: PendingRegistrationService, moduleRef: ModuleRef, waitlistService: WaitlistService | undefined);
|
|
21
23
|
private readonly _discordApiUrl;
|
|
22
24
|
private get authConfig();
|
|
23
|
-
generateLoginUrl(inviteCode?: string, referralCode?: string, source?: string): string;
|
|
25
|
+
generateLoginUrl(inviteCode?: string, referralCode?: string, source?: string, pass?: string): string;
|
|
24
26
|
parseStateData(state: string): {
|
|
25
27
|
invite?: string;
|
|
26
28
|
referral?: string;
|
|
27
29
|
source?: string;
|
|
30
|
+
pass?: string;
|
|
28
31
|
} | undefined;
|
|
29
32
|
handleDiscordLogin(params: {
|
|
30
33
|
userDetails: discordUser;
|
|
31
34
|
inviteCode?: string;
|
|
32
35
|
referralCode?: string;
|
|
33
36
|
source?: string;
|
|
37
|
+
pass?: string;
|
|
34
38
|
}): Promise<string>;
|
|
35
39
|
exchangeCodeForToken(code: string): Promise<string>;
|
|
36
40
|
fetchUserDetails(accessToken: string): Promise<discordUser>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.discord.service.d.ts","sourceRoot":"","sources":["../../../../src/foundations/auth/services/auth.discord.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAA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AAU,EACtB,0BAA0B,EAAE,0BAA0B,EACtD,SAAS,EAAE,SAAS,EAKpB,eAAe,EAAE,eAAe,GAAG,SAAS;IAG/D,OAAO,CAAC,QAAQ,CAAC,cAAc,CAA8B;IAE7D,OAAO,KAAK,UAAU,GAErB;IAED,gBAAgB,CAAC,UAAU,CAAC,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM;IAsBpG,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS;IAc3G,kBAAkB,CAAC,MAAM,EAAE;QAC/B,WAAW,EAAE,WAAW,CAAC;QACzB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,GAAG,OAAO,CAAC,MAAM,CAAC;IA8Fb,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAoBnD,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;CAkBlE"}
|
|
@@ -18,6 +18,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
18
18
|
exports.AuthDiscordService = void 0;
|
|
19
19
|
const common_1 = require("@nestjs/common");
|
|
20
20
|
const config_1 = require("@nestjs/config");
|
|
21
|
+
const core_1 = require("@nestjs/core");
|
|
21
22
|
const axios_1 = __importDefault(require("axios"));
|
|
22
23
|
const crypto_1 = require("crypto");
|
|
23
24
|
const nestjs_cls_1 = require("nestjs-cls");
|
|
@@ -30,9 +31,10 @@ const discord_user_repository_1 = require("../../discord-user/repositories/disco
|
|
|
30
31
|
const user_1 = require("../../user");
|
|
31
32
|
const waitlist_service_1 = require("../../waitlist/services/waitlist.service");
|
|
32
33
|
const signup_source_1 = require("../../waitlist/utils/signup-source");
|
|
34
|
+
const resolve_registration_pass_1 = require("../utils/resolve-registration-pass");
|
|
33
35
|
const pending_registration_service_1 = require("./pending-registration.service");
|
|
34
36
|
let AuthDiscordService = class AuthDiscordService {
|
|
35
|
-
constructor(userRepository, discordUserRepository, discordUserService, authService, config, clsService, pendingRegistrationService, waitlistService) {
|
|
37
|
+
constructor(userRepository, discordUserRepository, discordUserService, authService, config, clsService, pendingRegistrationService, moduleRef, waitlistService) {
|
|
36
38
|
this.userRepository = userRepository;
|
|
37
39
|
this.discordUserRepository = discordUserRepository;
|
|
38
40
|
this.discordUserService = discordUserService;
|
|
@@ -40,19 +42,21 @@ let AuthDiscordService = class AuthDiscordService {
|
|
|
40
42
|
this.config = config;
|
|
41
43
|
this.clsService = clsService;
|
|
42
44
|
this.pendingRegistrationService = pendingRegistrationService;
|
|
45
|
+
this.moduleRef = moduleRef;
|
|
43
46
|
this.waitlistService = waitlistService;
|
|
44
47
|
this._discordApiUrl = "https://discord.com/api/";
|
|
45
48
|
}
|
|
46
49
|
get authConfig() {
|
|
47
50
|
return this.config.get("auth");
|
|
48
51
|
}
|
|
49
|
-
generateLoginUrl(inviteCode, referralCode, source) {
|
|
50
|
-
// Encode invite code, referral code
|
|
52
|
+
generateLoginUrl(inviteCode, referralCode, source, pass) {
|
|
53
|
+
// Encode invite code, referral code, sign-up source (raw JSON string) AND registration pass in state parameter
|
|
51
54
|
const stateData = {
|
|
52
55
|
nonce: (0, crypto_1.randomUUID)(),
|
|
53
56
|
...(inviteCode && { invite: inviteCode }),
|
|
54
57
|
...(referralCode && { referral: referralCode }),
|
|
55
58
|
...(source && { source }),
|
|
59
|
+
...(pass && { pass }),
|
|
56
60
|
};
|
|
57
61
|
const state = Buffer.from(JSON.stringify(stateData)).toString("base64url");
|
|
58
62
|
const params = new URLSearchParams({
|
|
@@ -71,6 +75,7 @@ let AuthDiscordService = class AuthDiscordService {
|
|
|
71
75
|
invite: stateData.invite,
|
|
72
76
|
referral: stateData.referral,
|
|
73
77
|
source: typeof stateData.source === "string" ? stateData.source : undefined,
|
|
78
|
+
...(typeof stateData.pass === "string" && { pass: stateData.pass }),
|
|
74
79
|
};
|
|
75
80
|
}
|
|
76
81
|
catch {
|
|
@@ -106,28 +111,51 @@ let AuthDiscordService = class AuthDiscordService {
|
|
|
106
111
|
if (registrationMode === "closed") {
|
|
107
112
|
return `${this.config.get("app").url}oauth/error?error=registration_closed`;
|
|
108
113
|
}
|
|
109
|
-
|
|
114
|
+
// A new account needs an email; Discord accounts may have none.
|
|
115
|
+
if (!params.userDetails.email?.trim()) {
|
|
116
|
+
return `${this.config.get("app").url}oauth/error?error=email_required`;
|
|
117
|
+
}
|
|
118
|
+
// A registration pass (app-provided hook) can let this Discord user register
|
|
119
|
+
// past the waitlist. Without a hook, or with an invalid pass, it is ignored.
|
|
120
|
+
let passAccepted = false;
|
|
121
|
+
if (params.pass) {
|
|
122
|
+
const registrationPass = (0, resolve_registration_pass_1.resolveRegistrationPass)(this.moduleRef);
|
|
123
|
+
if (registrationPass) {
|
|
124
|
+
const verdict = await registrationPass.validate({
|
|
125
|
+
pass: params.pass,
|
|
126
|
+
provider: "discord",
|
|
127
|
+
providerUserId: params.userDetails.id,
|
|
128
|
+
});
|
|
129
|
+
if (verdict === "mismatch") {
|
|
130
|
+
return `${this.config.get("app").url}oauth/error?error=join_link_mismatch`;
|
|
131
|
+
}
|
|
132
|
+
passAccepted = verdict === "valid";
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
if (registrationMode === "waitlist" && !params.inviteCode && !passAccepted) {
|
|
110
136
|
return `${this.config.get("app").url}oauth/error?error=waitlist_required`;
|
|
111
137
|
}
|
|
112
138
|
// An invite registers only the email it was sent to. An invalid invite is
|
|
113
139
|
// left to completeOAuthRegistration, which rejects it.
|
|
114
|
-
if (registrationMode === "waitlist" && params.inviteCode && this.waitlistService) {
|
|
140
|
+
if (registrationMode === "waitlist" && params.inviteCode && !passAccepted && this.waitlistService) {
|
|
115
141
|
const inviteValidation = await this.waitlistService.validateInviteCode(params.inviteCode);
|
|
116
142
|
if (inviteValidation?.valid &&
|
|
117
143
|
(params.userDetails.email ?? "").trim().toLowerCase() !== (inviteValidation.email ?? "").trim().toLowerCase()) {
|
|
118
144
|
return `${this.config.get("app").url}oauth/error?error=invite_email_mismatch&invite=${encodeURIComponent(params.inviteCode)}`;
|
|
119
145
|
}
|
|
120
146
|
}
|
|
121
|
-
// Store pending registration in Redis (include invite code AND referral code if present)
|
|
147
|
+
// Store pending registration in Redis (include invite code AND referral code if present).
|
|
148
|
+
// An accepted pass is stored instead of the invite, so a pass sign-up never consumes an invite.
|
|
122
149
|
const pendingId = await this.pendingRegistrationService.create({
|
|
123
150
|
provider: "discord",
|
|
124
151
|
providerUserId: params.userDetails.id,
|
|
125
152
|
email: params.userDetails.email,
|
|
126
153
|
name: params.userDetails.username,
|
|
127
154
|
avatar: params.userDetails.avatar,
|
|
128
|
-
inviteCode: params.inviteCode,
|
|
155
|
+
inviteCode: passAccepted ? undefined : params.inviteCode,
|
|
129
156
|
referralCode: params.referralCode,
|
|
130
157
|
source: (0, signup_source_1.parseSignupSourceParam)(params.source),
|
|
158
|
+
...(passAccepted && { pass: params.pass }),
|
|
131
159
|
});
|
|
132
160
|
return `${this.config.get("app").url}auth/consent?pending=${pendingId}`;
|
|
133
161
|
}
|
|
@@ -165,8 +193,8 @@ let AuthDiscordService = class AuthDiscordService {
|
|
|
165
193
|
exports.AuthDiscordService = AuthDiscordService;
|
|
166
194
|
exports.AuthDiscordService = AuthDiscordService = __decorate([
|
|
167
195
|
(0, common_1.Injectable)(),
|
|
168
|
-
__param(
|
|
169
|
-
__param(
|
|
196
|
+
__param(8, (0, common_1.Optional)()),
|
|
197
|
+
__param(8, (0, common_1.Inject)(waitlist_service_1.WaitlistService)),
|
|
170
198
|
__metadata("design:paramtypes", [user_1.UserRepository,
|
|
171
199
|
discord_user_repository_1.DiscordUserRepository,
|
|
172
200
|
discord_user_1.DiscordUserService,
|
|
@@ -174,6 +202,7 @@ exports.AuthDiscordService = AuthDiscordService = __decorate([
|
|
|
174
202
|
config_1.ConfigService,
|
|
175
203
|
nestjs_cls_1.ClsService,
|
|
176
204
|
pending_registration_service_1.PendingRegistrationService,
|
|
205
|
+
core_1.ModuleRef,
|
|
177
206
|
waitlist_service_1.WaitlistService])
|
|
178
207
|
], AuthDiscordService);
|
|
179
208
|
//# sourceMappingURL=auth.discord.service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.discord.service.js","sourceRoot":"","sources":["../../../../src/foundations/auth/services/auth.discord.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,2CAA8D;AAC9D,2CAA+C;AAC/C,kDAA0B;AAC1B,mCAAoC;AACpC,2CAAwC;AACxC,sEAAsE;AACtE,8EAA8E;AAC9E,yEAAyE;AACzE,iDAA6C;AAG7C,qDAAwD;AAExD,qGAAgG;AAEhG,qCAA4C;AAC5C,+EAA2E;AAC3E,sEAA4E;AAC5E,iFAA4E;AAGrE,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAC7B,YACmB,cAA8B,EAC9B,qBAA4C,EAC5C,kBAAsC,EACtC,WAAwB,EACxB,MAA0C,EAC1C,UAAsB,EACtB,0BAAsD,
|
|
1
|
+
{"version":3,"file":"auth.discord.service.js","sourceRoot":"","sources":["../../../../src/foundations/auth/services/auth.discord.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,2CAA8D;AAC9D,2CAA+C;AAC/C,uCAAyC;AACzC,kDAA0B;AAC1B,mCAAoC;AACpC,2CAAwC;AACxC,sEAAsE;AACtE,8EAA8E;AAC9E,yEAAyE;AACzE,iDAA6C;AAG7C,qDAAwD;AAExD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uBAAU;QACM,yDAA0B;QAC3C,gBAAS;QAKH,kCAAe;GAdxC,kBAAkB,CAqM9B"}
|
|
@@ -150,6 +150,16 @@ export declare class AuthService extends AbstractService<Auth, typeof AuthDescri
|
|
|
150
150
|
}, language?: string): Promise<{
|
|
151
151
|
code: string;
|
|
152
152
|
}>;
|
|
153
|
+
/**
|
|
154
|
+
* Reads a pending OAuth sign-up for the consent page. `hasPass` tells the page
|
|
155
|
+
* the sign-up carries an application registration pass; `emailInUse` tells it
|
|
156
|
+
* the sign-up cannot complete because the email already has an account.
|
|
157
|
+
*/
|
|
158
|
+
findPendingRegistration(params: {
|
|
159
|
+
pendingId: string;
|
|
160
|
+
}): Promise<JsonApiSingleDocument>;
|
|
161
|
+
/** True when any User, soft-deleted included, already has this email. */
|
|
162
|
+
private isEmailInUse;
|
|
153
163
|
/**
|
|
154
164
|
* An invite code registers only the email it was sent to. Case and
|
|
155
165
|
* surrounding spaces are ignored.
|