@ackplus/nest-auth 1.1.69-beta.8 → 2.0.0-beta.1
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/README.md +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/admin-console/admin-console.module.d.ts.map +1 -1
- package/dist/lib/admin-console/admin-console.module.js +8 -1
- package/dist/lib/admin-console/admin-console.module.js.map +1 -1
- package/dist/lib/admin-console/controllers/admin-console.controller.d.ts.map +1 -1
- package/dist/lib/admin-console/controllers/admin-console.controller.js +0 -4
- package/dist/lib/admin-console/controllers/admin-console.controller.js.map +1 -1
- package/dist/lib/admin-console/controllers/admin-users.controller.d.ts +35 -5
- package/dist/lib/admin-console/controllers/admin-users.controller.d.ts.map +1 -1
- package/dist/lib/admin-console/controllers/admin-users.controller.js +74 -14
- package/dist/lib/admin-console/controllers/admin-users.controller.js.map +1 -1
- package/dist/lib/admin-console/dto/admin-user.dto.d.ts +1 -0
- package/dist/lib/admin-console/dto/admin-user.dto.d.ts.map +1 -1
- package/dist/lib/admin-console/dto/admin-user.dto.js +7 -0
- package/dist/lib/admin-console/dto/admin-user.dto.js.map +1 -1
- package/dist/lib/admin-console/static/index.html +589 -542
- package/dist/lib/admin-console/static/nest-auth.json +251 -25
- package/dist/lib/auth/auth.module.d.ts.map +1 -1
- package/dist/lib/auth/auth.module.js +3 -0
- package/dist/lib/auth/auth.module.js.map +1 -1
- package/dist/lib/auth/controllers/auth.controller.d.ts +8 -2
- package/dist/lib/auth/controllers/auth.controller.d.ts.map +1 -1
- package/dist/lib/auth/controllers/auth.controller.js +61 -3
- package/dist/lib/auth/controllers/auth.controller.js.map +1 -1
- package/dist/lib/auth/dto/credentials/passwordless-otp-credentials.dto.d.ts +6 -0
- package/dist/lib/auth/dto/credentials/passwordless-otp-credentials.dto.d.ts.map +1 -0
- package/dist/lib/auth/dto/credentials/passwordless-otp-credentials.dto.js +52 -0
- package/dist/lib/auth/dto/credentials/passwordless-otp-credentials.dto.js.map +1 -0
- package/dist/lib/auth/dto/requests/login.request.dto.d.ts +2 -1
- package/dist/lib/auth/dto/requests/login.request.dto.d.ts.map +1 -1
- package/dist/lib/auth/dto/requests/login.request.dto.js +17 -4
- package/dist/lib/auth/dto/requests/login.request.dto.js.map +1 -1
- package/dist/lib/auth/dto/requests/passwordless-send.request.dto.d.ts +7 -0
- package/dist/lib/auth/dto/requests/passwordless-send.request.dto.d.ts.map +1 -0
- package/dist/lib/auth/dto/requests/passwordless-send.request.dto.js +41 -0
- package/dist/lib/auth/dto/requests/passwordless-send.request.dto.js.map +1 -0
- package/dist/lib/auth/dto/requests/refresh-token.request.dto.d.ts +1 -1
- package/dist/lib/auth/dto/requests/refresh-token.request.dto.d.ts.map +1 -1
- package/dist/lib/auth/dto/requests/refresh-token.request.dto.js +2 -2
- package/dist/lib/auth/dto/requests/refresh-token.request.dto.js.map +1 -1
- package/dist/lib/auth/dto/requests/send-phone-verification.request.dto.d.ts +5 -0
- package/dist/lib/auth/dto/requests/send-phone-verification.request.dto.d.ts.map +1 -0
- package/dist/lib/auth/dto/requests/send-phone-verification.request.dto.js +28 -0
- package/dist/lib/auth/dto/requests/send-phone-verification.request.dto.js.map +1 -0
- package/dist/lib/auth/dto/requests/verify-email.request.dto.d.ts +1 -1
- package/dist/lib/auth/dto/requests/verify-email.request.dto.d.ts.map +1 -1
- package/dist/lib/auth/dto/requests/verify-email.request.dto.js +3 -3
- package/dist/lib/auth/dto/requests/verify-email.request.dto.js.map +1 -1
- package/dist/lib/auth/dto/requests/verify-forgot-password-otp-request-dto.d.ts +1 -1
- package/dist/lib/auth/dto/requests/verify-forgot-password-otp-request-dto.d.ts.map +1 -1
- package/dist/lib/auth/dto/requests/verify-forgot-password-otp-request-dto.js +3 -3
- package/dist/lib/auth/dto/requests/verify-forgot-password-otp-request-dto.js.map +1 -1
- package/dist/lib/auth/dto/requests/verify-phone.request.dto.d.ts +6 -0
- package/dist/lib/auth/dto/requests/verify-phone.request.dto.d.ts.map +1 -0
- package/dist/lib/auth/dto/requests/verify-phone.request.dto.js +40 -0
- package/dist/lib/auth/dto/requests/verify-phone.request.dto.js.map +1 -0
- package/dist/lib/auth/dto/responses/auth-messages.response.dto.d.ts +6 -0
- package/dist/lib/auth/dto/responses/auth-messages.response.dto.d.ts.map +1 -1
- package/dist/lib/auth/dto/responses/auth-messages.response.dto.js +17 -1
- package/dist/lib/auth/dto/responses/auth-messages.response.dto.js.map +1 -1
- package/dist/lib/auth/entities/otp.entity.d.ts +4 -2
- package/dist/lib/auth/entities/otp.entity.d.ts.map +1 -1
- package/dist/lib/auth/entities/otp.entity.js +29 -8
- package/dist/lib/auth/entities/otp.entity.js.map +1 -1
- package/dist/lib/auth/entities/trusted-device.entity.d.ts +4 -1
- package/dist/lib/auth/entities/trusted-device.entity.d.ts.map +1 -1
- package/dist/lib/auth/entities/trusted-device.entity.js +18 -4
- package/dist/lib/auth/entities/trusted-device.entity.js.map +1 -1
- package/dist/lib/auth/events/email-verification-requested.event.d.ts +13 -0
- package/dist/lib/auth/events/email-verification-requested.event.d.ts.map +1 -0
- package/dist/lib/auth/events/email-verification-requested.event.js +11 -0
- package/dist/lib/auth/events/email-verification-requested.event.js.map +1 -0
- package/dist/lib/auth/events/password-reset-requested.event.d.ts +1 -0
- package/dist/lib/auth/events/password-reset-requested.event.d.ts.map +1 -1
- package/dist/lib/auth/events/password-reset-requested.event.js.map +1 -1
- package/dist/lib/auth/events/passwordless-code-requested.event.d.ts +15 -0
- package/dist/lib/auth/events/passwordless-code-requested.event.d.ts.map +1 -0
- package/dist/lib/auth/events/passwordless-code-requested.event.js +11 -0
- package/dist/lib/auth/events/passwordless-code-requested.event.js.map +1 -0
- package/dist/lib/auth/events/phone-verification-requested.event.d.ts +13 -0
- package/dist/lib/auth/events/phone-verification-requested.event.d.ts.map +1 -0
- package/dist/lib/auth/events/phone-verification-requested.event.js +11 -0
- package/dist/lib/auth/events/phone-verification-requested.event.js.map +1 -0
- package/dist/lib/auth/filters/auth-exception.filter.d.ts +2 -2
- package/dist/lib/auth/filters/auth-exception.filter.d.ts.map +1 -1
- package/dist/lib/auth/filters/auth-exception.filter.js +17 -3
- package/dist/lib/auth/filters/auth-exception.filter.js.map +1 -1
- package/dist/lib/auth/guards/auth.guard.d.ts.map +1 -1
- package/dist/lib/auth/guards/auth.guard.js +3 -5
- package/dist/lib/auth/guards/auth.guard.js.map +1 -1
- package/dist/lib/auth/index.d.ts +5 -0
- package/dist/lib/auth/index.d.ts.map +1 -1
- package/dist/lib/auth/index.js +5 -0
- package/dist/lib/auth/index.js.map +1 -1
- package/dist/lib/auth/interceptors/token-response.interceptor.d.ts.map +1 -1
- package/dist/lib/auth/interceptors/token-response.interceptor.js +23 -20
- package/dist/lib/auth/interceptors/token-response.interceptor.js.map +1 -1
- package/dist/lib/auth/services/auth.service.d.ts +11 -1
- package/dist/lib/auth/services/auth.service.d.ts.map +1 -1
- package/dist/lib/auth/services/auth.service.js +136 -18
- package/dist/lib/auth/services/auth.service.js.map +1 -1
- package/dist/lib/auth/services/mfa.service.d.ts +4 -3
- package/dist/lib/auth/services/mfa.service.d.ts.map +1 -1
- package/dist/lib/auth/services/mfa.service.js +54 -66
- package/dist/lib/auth/services/mfa.service.js.map +1 -1
- package/dist/lib/auth/services/otp-flow.service.d.ts +28 -0
- package/dist/lib/auth/services/otp-flow.service.d.ts.map +1 -0
- package/dist/lib/auth/services/otp-flow.service.js +127 -0
- package/dist/lib/auth/services/otp-flow.service.js.map +1 -0
- package/dist/lib/auth/services/password.service.d.ts +5 -5
- package/dist/lib/auth/services/password.service.d.ts.map +1 -1
- package/dist/lib/auth/services/password.service.js +25 -57
- package/dist/lib/auth/services/password.service.js.map +1 -1
- package/dist/lib/auth/services/verification.service.d.ts +13 -4
- package/dist/lib/auth/services/verification.service.d.ts.map +1 -1
- package/dist/lib/auth/services/verification.service.js +116 -77
- package/dist/lib/auth/services/verification.service.js.map +1 -1
- package/dist/lib/auth.constants.d.ts +11 -0
- package/dist/lib/auth.constants.d.ts.map +1 -1
- package/dist/lib/auth.constants.js +9 -1
- package/dist/lib/auth.constants.js.map +1 -1
- package/dist/lib/core/core.module.d.ts.map +1 -1
- package/dist/lib/core/core.module.js +2 -0
- package/dist/lib/core/core.module.js.map +1 -1
- package/dist/lib/core/entities.d.ts +1 -1
- package/dist/lib/core/index.d.ts +1 -0
- package/dist/lib/core/index.d.ts.map +1 -1
- package/dist/lib/core/index.js +1 -0
- package/dist/lib/core/index.js.map +1 -1
- package/dist/lib/core/interfaces/auth-module-options.interface.d.ts +11 -20
- package/dist/lib/core/interfaces/auth-module-options.interface.d.ts.map +1 -1
- package/dist/lib/core/interfaces/mfa-options.interface.d.ts +3 -3
- package/dist/lib/core/interfaces/mfa-options.interface.d.ts.map +1 -1
- package/dist/lib/core/interfaces/session-options.interface.d.ts +8 -2
- package/dist/lib/core/interfaces/session-options.interface.d.ts.map +1 -1
- package/dist/lib/core/providers/base-auth.provider.d.ts +4 -4
- package/dist/lib/core/providers/base-auth.provider.d.ts.map +1 -1
- package/dist/lib/core/providers/base-auth.provider.js +7 -5
- package/dist/lib/core/providers/base-auth.provider.js.map +1 -1
- package/dist/lib/core/providers/email-auth.provider.d.ts +3 -3
- package/dist/lib/core/providers/email-auth.provider.d.ts.map +1 -1
- package/dist/lib/core/providers/email-auth.provider.js +9 -4
- package/dist/lib/core/providers/email-auth.provider.js.map +1 -1
- package/dist/lib/core/providers/facebook-auth.provider.d.ts +2 -2
- package/dist/lib/core/providers/facebook-auth.provider.d.ts.map +1 -1
- package/dist/lib/core/providers/facebook-auth.provider.js +1 -1
- package/dist/lib/core/providers/facebook-auth.provider.js.map +1 -1
- package/dist/lib/core/providers/github-auth.provider.d.ts +2 -2
- package/dist/lib/core/providers/github-auth.provider.d.ts.map +1 -1
- package/dist/lib/core/providers/github-auth.provider.js +1 -1
- package/dist/lib/core/providers/github-auth.provider.js.map +1 -1
- package/dist/lib/core/providers/google-auth.provider.d.ts +2 -2
- package/dist/lib/core/providers/google-auth.provider.d.ts.map +1 -1
- package/dist/lib/core/providers/google-auth.provider.js +1 -1
- package/dist/lib/core/providers/google-auth.provider.js.map +1 -1
- package/dist/lib/core/providers/jwt-auth.provider.d.ts +2 -2
- package/dist/lib/core/providers/jwt-auth.provider.d.ts.map +1 -1
- package/dist/lib/core/providers/jwt-auth.provider.js +2 -2
- package/dist/lib/core/providers/jwt-auth.provider.js.map +1 -1
- package/dist/lib/core/providers/passwordless-auth.provider.d.ts +19 -0
- package/dist/lib/core/providers/passwordless-auth.provider.d.ts.map +1 -0
- package/dist/lib/core/providers/passwordless-auth.provider.js +134 -0
- package/dist/lib/core/providers/passwordless-auth.provider.js.map +1 -0
- package/dist/lib/core/providers/phone-auth.provider.d.ts +2 -2
- package/dist/lib/core/providers/phone-auth.provider.d.ts.map +1 -1
- package/dist/lib/core/providers/phone-auth.provider.js +3 -3
- package/dist/lib/core/providers/phone-auth.provider.js.map +1 -1
- package/dist/lib/core/services/auth-config.service.d.ts +1 -3
- package/dist/lib/core/services/auth-config.service.d.ts.map +1 -1
- package/dist/lib/core/services/auth-config.service.js +29 -44
- package/dist/lib/core/services/auth-config.service.js.map +1 -1
- package/dist/lib/core/services/auth-provider-registry.service.d.ts +3 -1
- package/dist/lib/core/services/auth-provider-registry.service.d.ts.map +1 -1
- package/dist/lib/core/services/auth-provider-registry.service.js +9 -2
- package/dist/lib/core/services/auth-provider-registry.service.js.map +1 -1
- package/dist/lib/core/services/jwt.service.d.ts.map +1 -1
- package/dist/lib/core/services/jwt.service.js +35 -11
- package/dist/lib/core/services/jwt.service.js.map +1 -1
- package/dist/lib/session/services/session-manager.service.d.ts +3 -3
- package/dist/lib/session/services/session-manager.service.d.ts.map +1 -1
- package/dist/lib/session/services/session-manager.service.js +19 -33
- package/dist/lib/session/services/session-manager.service.js.map +1 -1
- package/dist/lib/session/session.module.js +1 -1
- package/dist/lib/session/session.module.js.map +1 -1
- package/dist/lib/tenant/services/tenant.service.d.ts.map +1 -1
- package/dist/lib/tenant/services/tenant.service.js +6 -1
- package/dist/lib/tenant/services/tenant.service.js.map +1 -1
- package/dist/lib/user/entities/user.entity.d.ts.map +1 -1
- package/dist/lib/user/entities/user.entity.js +1 -10
- package/dist/lib/user/entities/user.entity.js.map +1 -1
- package/dist/lib/utils/has-token.d.ts +6 -0
- package/dist/lib/utils/has-token.d.ts.map +1 -0
- package/dist/lib/utils/has-token.js +28 -0
- package/dist/lib/utils/has-token.js.map +1 -0
- package/dist/lib/utils/index.d.ts +1 -0
- package/dist/lib/utils/index.d.ts.map +1 -1
- package/dist/lib/utils/index.js +1 -0
- package/dist/lib/utils/index.js.map +1 -1
- package/dist/lib/utils/otp.d.ts +1 -1
- package/dist/lib/utils/otp.d.ts.map +1 -1
- package/dist/lib/utils/otp.js +8 -2
- package/dist/lib/utils/otp.js.map +1 -1
- package/package.json +3 -2
|
@@ -11,35 +11,28 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
12
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
13
|
};
|
|
14
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
15
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
16
|
-
};
|
|
17
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
15
|
exports.PasswordService = void 0;
|
|
19
16
|
const common_1 = require("@nestjs/common");
|
|
20
17
|
const typeorm_1 = require("@nestjs/typeorm");
|
|
21
18
|
const typeorm_2 = require("typeorm");
|
|
22
19
|
const user_entity_1 = require("../../user/entities/user.entity");
|
|
23
|
-
const otp_entity_1 = require("../../auth/entities/otp.entity");
|
|
24
20
|
const nest_auth_contracts_1 = require("@ackplus/nest-auth-contracts");
|
|
25
21
|
const auth_constants_1 = require("../../auth.constants");
|
|
26
22
|
const jwt_service_1 = require("../../core/services/jwt.service");
|
|
27
23
|
const event_emitter_1 = require("@nestjs/event-emitter");
|
|
28
24
|
const session_manager_service_1 = require("../../session/services/session-manager.service");
|
|
29
25
|
const request_context_1 = require("../../request-context/request-context");
|
|
30
|
-
const otp_1 = require("../../utils/otp");
|
|
31
26
|
const user_password_changed_event_1 = require("../events/user-password-changed.event");
|
|
32
27
|
const password_reset_requested_event_1 = require("../events/password-reset-requested.event");
|
|
33
28
|
const password_reset_event_1 = require("../events/password-reset.event");
|
|
34
29
|
const auth_provider_registry_service_1 = require("../../core/services/auth-provider-registry.service");
|
|
35
30
|
const tenant_service_1 = require("../../tenant/services/tenant.service");
|
|
36
31
|
const debug_logger_service_1 = require("../../core/services/debug-logger.service");
|
|
37
|
-
const moment_1 = __importDefault(require("moment"));
|
|
38
32
|
const auth_config_service_1 = require("../../core/services/auth-config.service");
|
|
39
|
-
const
|
|
33
|
+
const otp_flow_service_1 = require("./otp-flow.service");
|
|
40
34
|
let PasswordService = class PasswordService {
|
|
41
35
|
userRepository;
|
|
42
|
-
otpRepository;
|
|
43
36
|
authProviderRegistry;
|
|
44
37
|
sessionManager;
|
|
45
38
|
jwtService;
|
|
@@ -47,9 +40,9 @@ let PasswordService = class PasswordService {
|
|
|
47
40
|
tenantService;
|
|
48
41
|
debugLogger;
|
|
49
42
|
authConfigService;
|
|
50
|
-
|
|
43
|
+
otpFlow;
|
|
44
|
+
constructor(userRepository, authProviderRegistry, sessionManager, jwtService, eventEmitter, tenantService, debugLogger, authConfigService, otpFlow) {
|
|
51
45
|
this.userRepository = userRepository;
|
|
52
|
-
this.otpRepository = otpRepository;
|
|
53
46
|
this.authProviderRegistry = authProviderRegistry;
|
|
54
47
|
this.sessionManager = sessionManager;
|
|
55
48
|
this.jwtService = jwtService;
|
|
@@ -57,6 +50,7 @@ let PasswordService = class PasswordService {
|
|
|
57
50
|
this.tenantService = tenantService;
|
|
58
51
|
this.debugLogger = debugLogger;
|
|
59
52
|
this.authConfigService = authConfigService;
|
|
53
|
+
this.otpFlow = otpFlow;
|
|
60
54
|
}
|
|
61
55
|
get mfaConfig() {
|
|
62
56
|
return auth_config_service_1.AuthConfigService.getOptions().mfa || {};
|
|
@@ -155,39 +149,18 @@ let PasswordService = class PasswordService {
|
|
|
155
149
|
return { message: 'If the account exists, a password reset code has been sent' };
|
|
156
150
|
}
|
|
157
151
|
const options = auth_config_service_1.AuthConfigService.getOptions();
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
code = await options.otp.generate(this.mfaConfig.otpLength);
|
|
161
|
-
}
|
|
162
|
-
else {
|
|
163
|
-
code = (0, otp_1.generateOtp)(this.mfaConfig.otpLength);
|
|
164
|
-
}
|
|
165
|
-
let expiresAtMs;
|
|
166
|
-
if (typeof this.mfaConfig.otpExpiresIn === 'string') {
|
|
167
|
-
expiresAtMs = (0, ms_1.default)(this.mfaConfig.otpExpiresIn);
|
|
168
|
-
}
|
|
169
|
-
else {
|
|
170
|
-
expiresAtMs = this.mfaConfig.otpExpiresIn || 900000;
|
|
171
|
-
}
|
|
172
|
-
if (!expiresAtMs || isNaN(expiresAtMs) || expiresAtMs <= 0) {
|
|
173
|
-
expiresAtMs = 900000;
|
|
174
|
-
}
|
|
175
|
-
await this.otpRepository.delete({
|
|
176
|
-
userId: identity.user?.id,
|
|
177
|
-
type: nest_auth_contracts_1.NestAuthOTPTypeEnum.PASSWORD_RESET
|
|
178
|
-
});
|
|
179
|
-
const otpEntity = await this.otpRepository.create({
|
|
180
|
-
userId: identity.user?.id,
|
|
152
|
+
const { entity: otpEntity, plainCode } = await this.otpFlow.createOtp({
|
|
153
|
+
userId: identity.user.id,
|
|
181
154
|
type: nest_auth_contracts_1.NestAuthOTPTypeEnum.PASSWORD_RESET,
|
|
182
|
-
|
|
183
|
-
|
|
155
|
+
otpOptions: options.otp,
|
|
156
|
+
replaceExisting: true,
|
|
184
157
|
});
|
|
185
|
-
await this.otpRepository.save(otpEntity);
|
|
186
158
|
await this.eventEmitter.emitAsync(auth_constants_1.NestAuthEvents.PASSWORD_RESET_REQUESTED, new password_reset_requested_event_1.PasswordResetRequestedEvent({
|
|
187
159
|
user: identity.user,
|
|
188
160
|
tenantId,
|
|
189
161
|
input,
|
|
190
162
|
otp: otpEntity,
|
|
163
|
+
code: plainCode,
|
|
191
164
|
provider,
|
|
192
165
|
}));
|
|
193
166
|
this.debugLogger.logFunctionExit('forgotPassword', 'PasswordService');
|
|
@@ -202,7 +175,7 @@ let PasswordService = class PasswordService {
|
|
|
202
175
|
async verifyForgotPasswordOtp(input) {
|
|
203
176
|
this.debugLogger.logFunctionEntry('verifyForgotPasswordOtp', 'PasswordService');
|
|
204
177
|
try {
|
|
205
|
-
const { email, phone,
|
|
178
|
+
const { email, phone, code, tenantId } = input;
|
|
206
179
|
if (!email && !phone) {
|
|
207
180
|
throw new common_1.BadRequestException({
|
|
208
181
|
message: 'Either email or phone must be provided',
|
|
@@ -227,28 +200,25 @@ let PasswordService = class PasswordService {
|
|
|
227
200
|
code: auth_constants_1.ERROR_CODES.PASSWORD_RESET_INVALID_REQUEST,
|
|
228
201
|
});
|
|
229
202
|
}
|
|
230
|
-
const
|
|
231
|
-
|
|
232
|
-
userId: identity.user?.id,
|
|
233
|
-
code: otp,
|
|
234
|
-
type: nest_auth_contracts_1.NestAuthOTPTypeEnum.PASSWORD_RESET,
|
|
235
|
-
used: false,
|
|
236
|
-
},
|
|
237
|
-
relations: ['user']
|
|
238
|
-
});
|
|
239
|
-
if (!validOtp) {
|
|
203
|
+
const userId = identity.user?.id;
|
|
204
|
+
if (!userId) {
|
|
240
205
|
throw new common_1.BadRequestException({
|
|
241
|
-
message: 'Invalid
|
|
242
|
-
code: auth_constants_1.ERROR_CODES.
|
|
206
|
+
message: 'Invalid reset request',
|
|
207
|
+
code: auth_constants_1.ERROR_CODES.PASSWORD_RESET_INVALID_REQUEST,
|
|
243
208
|
});
|
|
244
209
|
}
|
|
245
|
-
|
|
210
|
+
await this.otpFlow.validateAndConsume({
|
|
211
|
+
userId,
|
|
212
|
+
type: nest_auth_contracts_1.NestAuthOTPTypeEnum.PASSWORD_RESET,
|
|
213
|
+
code,
|
|
214
|
+
});
|
|
215
|
+
const user = await this.userRepository.findOne({ where: { id: userId } });
|
|
216
|
+
if (!user) {
|
|
246
217
|
throw new common_1.BadRequestException({
|
|
247
|
-
message: '
|
|
248
|
-
code: auth_constants_1.ERROR_CODES.
|
|
218
|
+
message: 'User not found',
|
|
219
|
+
code: auth_constants_1.ERROR_CODES.USER_NOT_FOUND,
|
|
249
220
|
});
|
|
250
221
|
}
|
|
251
|
-
const user = validOtp.user;
|
|
252
222
|
const passwordHashPrefix = user.passwordHash ? user.passwordHash.substring(0, 10) : '';
|
|
253
223
|
const resetToken = await this.jwtService.generatePasswordResetToken({
|
|
254
224
|
userId: user.id,
|
|
@@ -256,7 +226,6 @@ let PasswordService = class PasswordService {
|
|
|
256
226
|
tenantId: tenantId,
|
|
257
227
|
type: 'password-reset'
|
|
258
228
|
});
|
|
259
|
-
await this.otpRepository.remove(validOtp);
|
|
260
229
|
this.debugLogger.logFunctionExit('verifyForgotPasswordOtp', 'PasswordService');
|
|
261
230
|
return {
|
|
262
231
|
message: 'OTP verified successfully',
|
|
@@ -326,15 +295,14 @@ exports.PasswordService = PasswordService;
|
|
|
326
295
|
exports.PasswordService = PasswordService = __decorate([
|
|
327
296
|
(0, common_1.Injectable)(),
|
|
328
297
|
__param(0, (0, typeorm_1.InjectRepository)(user_entity_1.NestAuthUser)),
|
|
329
|
-
__param(1, (0, typeorm_1.InjectRepository)(otp_entity_1.NestAuthOTP)),
|
|
330
298
|
__metadata("design:paramtypes", [typeorm_2.Repository,
|
|
331
|
-
typeorm_2.Repository,
|
|
332
299
|
auth_provider_registry_service_1.AuthProviderRegistryService,
|
|
333
300
|
session_manager_service_1.SessionManagerService,
|
|
334
301
|
jwt_service_1.JwtService,
|
|
335
302
|
event_emitter_1.EventEmitter2,
|
|
336
303
|
tenant_service_1.TenantService,
|
|
337
304
|
debug_logger_service_1.DebugLoggerService,
|
|
338
|
-
auth_config_service_1.AuthConfigService
|
|
305
|
+
auth_config_service_1.AuthConfigService,
|
|
306
|
+
otp_flow_service_1.OtpFlowService])
|
|
339
307
|
], PasswordService);
|
|
340
308
|
//# sourceMappingURL=password.service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"password.service.js","sourceRoot":"","sources":["../../../../src/lib/auth/services/password.service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"password.service.js","sourceRoot":"","sources":["../../../../src/lib/auth/services/password.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAwF;AACxF,6CAAmD;AACnD,qCAAqC;AACrC,iEAA+D;AAC/D,sEAAmE;AACnE,yDAK8B;AAC9B,iEAA6D;AAC7D,yDAAsD;AACtD,4FAAuF;AACvF,2EAAuE;AAEvE,uFAAiF;AACjF,6FAAuF;AACvF,yEAAoE;AACpE,uGAAiG;AACjG,yEAAqE;AACrE,mFAA8E;AAK9E,iFAA4E;AAE5E,yDAAoD;AAI7C,IAAM,eAAe,GAArB,MAAM,eAAe;IAIH;IAEA;IAEA;IAEA;IAEA;IAEA;IAEA;IAEA;IAEA;IAlBrB,YAEqB,cAAwC,EAExC,oBAAiD,EAEjD,cAAqC,EAErC,UAAsB,EAEtB,YAA2B,EAE3B,aAA4B,EAE5B,WAA+B,EAE/B,iBAAoC,EAEpC,OAAuB;QAhBvB,mBAAc,GAAd,cAAc,CAA0B;QAExC,yBAAoB,GAApB,oBAAoB,CAA6B;QAEjD,mBAAc,GAAd,cAAc,CAAuB;QAErC,eAAU,GAAV,UAAU,CAAY;QAEtB,iBAAY,GAAZ,YAAY,CAAe;QAE3B,kBAAa,GAAb,aAAa,CAAe;QAE5B,gBAAW,GAAX,WAAW,CAAoB;QAE/B,sBAAiB,GAAjB,iBAAiB,CAAmB;QAEpC,YAAO,GAAP,OAAO,CAAgB;IACxC,CAAC;IAEL,IAAI,SAAS;QACT,OAAO,uCAAiB,CAAC,UA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,EAC7B,IAAI,yCAAkB,CAAC;gBACnB,IAAI;gBACJ,QAAQ,EAAE,gCAAc,CAAC,eAAe,EAAE;gBAC1C,KAAK,EAAE,EAAE,KAAK,EAAE,WAAW,EAAS;aACvC,CAAC,CACL,CAAC;YAEF,IAAI,CAAC,WAAW,CAAC,eAAe,CAAC,wBAAwB,EAAE,iBAAiB,CAAC,CAAC;YAC9E,OAAO,IAAI,CAAC;QAChB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,KAAK,EAAE,wBAAwB,CAAC,CAAC;YAC3D,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,gBAAgB,CAAC,CAAC;YAC1C,MAAM,KAAK,CAAC;QAChB,CAAC;IACL,CAAC;CACJ,CAAA;AArTY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,mBAAU,GAAE;IAIJ,WAAA,IAAA,0BAAgB,EAAC,0BAAY,CAAC,CAAA;qCACE,oBAAU;QAEJ,4DAA2B;QAEjC,+CAAqB;QAEzB,wBAAU;QAER,6BAAa;QAEZ,8BAAa;QAEf,yCAAkB;QAEZ,uCAAiB;QAE3B,iCAAc;GApBnC,eAAe,CAqT3B"}
|
|
@@ -1,24 +1,33 @@
|
|
|
1
1
|
import { Repository } from 'typeorm';
|
|
2
2
|
import { NestAuthUser } from '../../user/entities/user.entity';
|
|
3
|
-
import { NestAuthOTP } from '../../auth/entities/otp.entity';
|
|
4
3
|
import { EventEmitter2 } from '@nestjs/event-emitter';
|
|
5
4
|
import { DebugLoggerService } from '../../core/services/debug-logger.service';
|
|
5
|
+
import { OtpFlowService } from './otp-flow.service';
|
|
6
6
|
import { NestAuthSendEmailVerificationRequestDto } from '../dto/requests/send-email-verification.request.dto';
|
|
7
7
|
import { NestAuthVerifyEmailRequestDto } from '../dto/requests/verify-email.request.dto';
|
|
8
|
+
import { NestAuthSendPhoneVerificationRequestDto } from '../dto/requests/send-phone-verification.request.dto';
|
|
9
|
+
import { NestAuthVerifyPhoneRequestDto } from '../dto/requests/verify-phone.request.dto';
|
|
8
10
|
import { AuthConfigService } from '../../core/services/auth-config.service';
|
|
9
11
|
export declare class VerificationService {
|
|
10
12
|
private readonly userRepository;
|
|
11
|
-
private otpRepository;
|
|
12
13
|
private readonly eventEmitter;
|
|
13
14
|
private readonly debugLogger;
|
|
14
15
|
private readonly authConfigService;
|
|
15
|
-
|
|
16
|
+
private readonly otpFlow;
|
|
17
|
+
constructor(userRepository: Repository<NestAuthUser>, eventEmitter: EventEmitter2, debugLogger: DebugLoggerService, authConfigService: AuthConfigService, otpFlow: OtpFlowService);
|
|
16
18
|
private handleError;
|
|
17
|
-
|
|
19
|
+
private requireAuthenticatedUser;
|
|
20
|
+
sendEmailVerification(_input: NestAuthSendEmailVerificationRequestDto): Promise<{
|
|
18
21
|
message: string;
|
|
19
22
|
}>;
|
|
20
23
|
verifyEmail(input: NestAuthVerifyEmailRequestDto): Promise<{
|
|
21
24
|
message: string;
|
|
22
25
|
}>;
|
|
26
|
+
sendPhoneVerification(_input: NestAuthSendPhoneVerificationRequestDto): Promise<{
|
|
27
|
+
message: string;
|
|
28
|
+
}>;
|
|
29
|
+
verifyPhone(input: NestAuthVerifyPhoneRequestDto): Promise<{
|
|
30
|
+
message: string;
|
|
31
|
+
}>;
|
|
23
32
|
}
|
|
24
33
|
//# sourceMappingURL=verification.service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verification.service.d.ts","sourceRoot":"","sources":["../../../../src/lib/auth/services/verification.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"verification.service.d.ts","sourceRoot":"","sources":["../../../../src/lib/auth/services/verification.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC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AO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CA6CxF"}
|
|
@@ -11,36 +11,33 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
12
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
13
|
};
|
|
14
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
15
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
16
|
-
};
|
|
17
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
15
|
exports.VerificationService = void 0;
|
|
19
16
|
const common_1 = require("@nestjs/common");
|
|
20
17
|
const typeorm_1 = require("@nestjs/typeorm");
|
|
21
18
|
const typeorm_2 = require("typeorm");
|
|
22
19
|
const user_entity_1 = require("../../user/entities/user.entity");
|
|
23
|
-
const otp_entity_1 = require("../../auth/entities/otp.entity");
|
|
24
20
|
const nest_auth_contracts_1 = require("@ackplus/nest-auth-contracts");
|
|
25
21
|
const auth_constants_1 = require("../../auth.constants");
|
|
26
22
|
const event_emitter_1 = require("@nestjs/event-emitter");
|
|
27
23
|
const request_context_1 = require("../../request-context/request-context");
|
|
28
|
-
const otp_1 = require("../../utils/otp");
|
|
29
24
|
const debug_logger_service_1 = require("../../core/services/debug-logger.service");
|
|
30
|
-
const
|
|
25
|
+
const otp_flow_service_1 = require("./otp-flow.service");
|
|
31
26
|
const auth_config_service_1 = require("../../core/services/auth-config.service");
|
|
27
|
+
const email_verification_requested_event_1 = require("../events/email-verification-requested.event");
|
|
28
|
+
const phone_verification_requested_event_1 = require("../events/phone-verification-requested.event");
|
|
32
29
|
let VerificationService = class VerificationService {
|
|
33
30
|
userRepository;
|
|
34
|
-
otpRepository;
|
|
35
31
|
eventEmitter;
|
|
36
32
|
debugLogger;
|
|
37
33
|
authConfigService;
|
|
38
|
-
|
|
34
|
+
otpFlow;
|
|
35
|
+
constructor(userRepository, eventEmitter, debugLogger, authConfigService, otpFlow) {
|
|
39
36
|
this.userRepository = userRepository;
|
|
40
|
-
this.otpRepository = otpRepository;
|
|
41
37
|
this.eventEmitter = eventEmitter;
|
|
42
38
|
this.debugLogger = debugLogger;
|
|
43
39
|
this.authConfigService = authConfigService;
|
|
40
|
+
this.otpFlow = otpFlow;
|
|
44
41
|
}
|
|
45
42
|
handleError(error, context) {
|
|
46
43
|
const config = this.authConfigService.getConfig();
|
|
@@ -51,26 +48,30 @@ let VerificationService = class VerificationService {
|
|
|
51
48
|
}
|
|
52
49
|
}
|
|
53
50
|
}
|
|
54
|
-
async
|
|
51
|
+
async requireAuthenticatedUser() {
|
|
52
|
+
const userId = request_context_1.RequestContext.currentUserId();
|
|
53
|
+
if (!userId) {
|
|
54
|
+
throw new common_1.UnauthorizedException({
|
|
55
|
+
message: 'User not authenticated',
|
|
56
|
+
code: auth_constants_1.ERROR_CODES.UNAUTHORIZED,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
const user = await this.userRepository.findOne({
|
|
60
|
+
where: { id: userId },
|
|
61
|
+
relations: ['roles'],
|
|
62
|
+
});
|
|
63
|
+
if (!user) {
|
|
64
|
+
throw new common_1.UnauthorizedException({
|
|
65
|
+
message: 'User not found',
|
|
66
|
+
code: auth_constants_1.ERROR_CODES.USER_NOT_FOUND,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
return user;
|
|
70
|
+
}
|
|
71
|
+
async sendEmailVerification(_input) {
|
|
55
72
|
this.debugLogger.logFunctionEntry('sendEmailVerification', 'VerificationService');
|
|
56
73
|
try {
|
|
57
|
-
const
|
|
58
|
-
if (!userId) {
|
|
59
|
-
throw new common_1.UnauthorizedException({
|
|
60
|
-
message: 'User not authenticated',
|
|
61
|
-
code: auth_constants_1.ERROR_CODES.UNAUTHORIZED,
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
const fullUser = await this.userRepository.findOne({
|
|
65
|
-
where: { id: userId },
|
|
66
|
-
relations: ['roles']
|
|
67
|
-
});
|
|
68
|
-
if (!fullUser) {
|
|
69
|
-
throw new common_1.UnauthorizedException({
|
|
70
|
-
message: 'User not found',
|
|
71
|
-
code: auth_constants_1.ERROR_CODES.USER_NOT_FOUND,
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
+
const fullUser = await this.requireAuthenticatedUser();
|
|
74
75
|
if (!fullUser.email) {
|
|
75
76
|
throw new common_1.BadRequestException({
|
|
76
77
|
message: 'User does not have an email address',
|
|
@@ -83,20 +84,17 @@ let VerificationService = class VerificationService {
|
|
|
83
84
|
code: auth_constants_1.ERROR_CODES.EMAIL_ALREADY_VERIFIED,
|
|
84
85
|
});
|
|
85
86
|
}
|
|
86
|
-
const
|
|
87
|
-
const expiresAt = new Date();
|
|
88
|
-
expiresAt.setMinutes(expiresAt.getMinutes() + 30);
|
|
89
|
-
const otpEntity = await this.otpRepository.save({
|
|
87
|
+
const { entity: otpEntity, plainCode: code } = await this.otpFlow.createOtp({
|
|
90
88
|
userId: fullUser.id,
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
type: nest_auth_contracts_1.NestAuthOTPTypeEnum.VERIFICATION,
|
|
89
|
+
type: nest_auth_contracts_1.NestAuthOTPTypeEnum.EMAIL_VERIFICATION,
|
|
90
|
+
replaceExisting: true,
|
|
94
91
|
});
|
|
95
|
-
await this.eventEmitter.emitAsync(auth_constants_1.NestAuthEvents.EMAIL_VERIFICATION_REQUESTED, {
|
|
92
|
+
await this.eventEmitter.emitAsync(auth_constants_1.NestAuthEvents.EMAIL_VERIFICATION_REQUESTED, new email_verification_requested_event_1.EmailVerificationRequestedEvent({
|
|
96
93
|
user: fullUser,
|
|
97
94
|
tenantId: request_context_1.RequestContext.currentTenantId(),
|
|
98
95
|
otp: otpEntity,
|
|
99
|
-
|
|
96
|
+
code,
|
|
97
|
+
}));
|
|
100
98
|
this.debugLogger.logFunctionExit('sendEmailVerification', 'VerificationService');
|
|
101
99
|
return { message: 'Verification email sent successfully' };
|
|
102
100
|
}
|
|
@@ -109,23 +107,7 @@ let VerificationService = class VerificationService {
|
|
|
109
107
|
async verifyEmail(input) {
|
|
110
108
|
this.debugLogger.logFunctionEntry('verifyEmail', 'VerificationService');
|
|
111
109
|
try {
|
|
112
|
-
const
|
|
113
|
-
if (!userId) {
|
|
114
|
-
throw new common_1.UnauthorizedException({
|
|
115
|
-
message: 'User not authenticated',
|
|
116
|
-
code: auth_constants_1.ERROR_CODES.UNAUTHORIZED,
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
const fullUser = await this.userRepository.findOne({
|
|
120
|
-
where: { id: userId },
|
|
121
|
-
relations: ['roles']
|
|
122
|
-
});
|
|
123
|
-
if (!fullUser) {
|
|
124
|
-
throw new common_1.UnauthorizedException({
|
|
125
|
-
message: 'User not found',
|
|
126
|
-
code: auth_constants_1.ERROR_CODES.USER_NOT_FOUND,
|
|
127
|
-
});
|
|
128
|
-
}
|
|
110
|
+
const fullUser = await this.requireAuthenticatedUser();
|
|
129
111
|
if (!fullUser.email) {
|
|
130
112
|
throw new common_1.BadRequestException({
|
|
131
113
|
message: 'User does not have an email address',
|
|
@@ -138,28 +120,11 @@ let VerificationService = class VerificationService {
|
|
|
138
120
|
code: auth_constants_1.ERROR_CODES.EMAIL_ALREADY_VERIFIED,
|
|
139
121
|
});
|
|
140
122
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
type: nest_auth_contracts_1.NestAuthOTPTypeEnum.VERIFICATION,
|
|
146
|
-
used: false
|
|
147
|
-
}
|
|
123
|
+
await this.otpFlow.validateAndConsume({
|
|
124
|
+
userId: fullUser.id,
|
|
125
|
+
type: nest_auth_contracts_1.NestAuthOTPTypeEnum.EMAIL_VERIFICATION,
|
|
126
|
+
code: input.code,
|
|
148
127
|
});
|
|
149
|
-
if (!validOtp) {
|
|
150
|
-
throw new common_1.BadRequestException({
|
|
151
|
-
message: 'Invalid verification code',
|
|
152
|
-
code: auth_constants_1.ERROR_CODES.VERIFICATION_CODE_INVALID,
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
if ((0, moment_1.default)(validOtp.expiresAt).isBefore(new Date())) {
|
|
156
|
-
throw new common_1.BadRequestException({
|
|
157
|
-
message: 'Verification code has expired',
|
|
158
|
-
code: auth_constants_1.ERROR_CODES.VERIFICATION_CODE_EXPIRED,
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
validOtp.used = true;
|
|
162
|
-
await this.otpRepository.save(validOtp);
|
|
163
128
|
fullUser.emailVerifiedAt = new Date();
|
|
164
129
|
fullUser.isVerified = true;
|
|
165
130
|
await this.userRepository.save(fullUser);
|
|
@@ -176,16 +141,90 @@ let VerificationService = class VerificationService {
|
|
|
176
141
|
throw error;
|
|
177
142
|
}
|
|
178
143
|
}
|
|
144
|
+
async sendPhoneVerification(_input) {
|
|
145
|
+
this.debugLogger.logFunctionEntry('sendPhoneVerification', 'VerificationService');
|
|
146
|
+
try {
|
|
147
|
+
const fullUser = await this.requireAuthenticatedUser();
|
|
148
|
+
if (!fullUser.phone) {
|
|
149
|
+
throw new common_1.BadRequestException({
|
|
150
|
+
message: 'User does not have a phone number',
|
|
151
|
+
code: auth_constants_1.ERROR_CODES.NO_PHONE_NUMBER,
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
if (fullUser.phoneVerifiedAt) {
|
|
155
|
+
throw new common_1.BadRequestException({
|
|
156
|
+
message: 'Phone number is already verified',
|
|
157
|
+
code: auth_constants_1.ERROR_CODES.PHONE_ALREADY_VERIFIED,
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
const { entity: otpEntity, plainCode: code } = await this.otpFlow.createOtp({
|
|
161
|
+
userId: fullUser.id,
|
|
162
|
+
type: nest_auth_contracts_1.NestAuthOTPTypeEnum.PHONE_VERIFICATION,
|
|
163
|
+
replaceExisting: true,
|
|
164
|
+
});
|
|
165
|
+
await this.eventEmitter.emitAsync(auth_constants_1.NestAuthEvents.PHONE_VERIFICATION_REQUESTED, new phone_verification_requested_event_1.PhoneVerificationRequestedEvent({
|
|
166
|
+
user: fullUser,
|
|
167
|
+
tenantId: request_context_1.RequestContext.currentTenantId(),
|
|
168
|
+
otp: otpEntity,
|
|
169
|
+
code,
|
|
170
|
+
}));
|
|
171
|
+
this.debugLogger.logFunctionExit('sendPhoneVerification', 'VerificationService');
|
|
172
|
+
return { message: 'Verification SMS sent successfully' };
|
|
173
|
+
}
|
|
174
|
+
catch (error) {
|
|
175
|
+
this.debugLogger.logError(error, 'sendPhoneVerification');
|
|
176
|
+
this.handleError(error, 'signup');
|
|
177
|
+
throw error;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
async verifyPhone(input) {
|
|
181
|
+
this.debugLogger.logFunctionEntry('verifyPhone', 'VerificationService');
|
|
182
|
+
try {
|
|
183
|
+
const fullUser = await this.requireAuthenticatedUser();
|
|
184
|
+
if (!fullUser.phone) {
|
|
185
|
+
throw new common_1.BadRequestException({
|
|
186
|
+
message: 'User does not have a phone number',
|
|
187
|
+
code: auth_constants_1.ERROR_CODES.NO_PHONE_NUMBER,
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
if (fullUser.phoneVerifiedAt) {
|
|
191
|
+
throw new common_1.BadRequestException({
|
|
192
|
+
message: 'Phone number is already verified',
|
|
193
|
+
code: auth_constants_1.ERROR_CODES.PHONE_ALREADY_VERIFIED,
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
await this.otpFlow.validateAndConsume({
|
|
197
|
+
userId: fullUser.id,
|
|
198
|
+
type: nest_auth_contracts_1.NestAuthOTPTypeEnum.PHONE_VERIFICATION,
|
|
199
|
+
code: input.code,
|
|
200
|
+
});
|
|
201
|
+
fullUser.phoneVerifiedAt = new Date();
|
|
202
|
+
if (!fullUser.isVerified) {
|
|
203
|
+
fullUser.isVerified = true;
|
|
204
|
+
}
|
|
205
|
+
await this.userRepository.save(fullUser);
|
|
206
|
+
await this.eventEmitter.emitAsync(auth_constants_1.NestAuthEvents.PHONE_VERIFIED, {
|
|
207
|
+
user: fullUser,
|
|
208
|
+
tenantId: request_context_1.RequestContext.currentTenantId(),
|
|
209
|
+
});
|
|
210
|
+
this.debugLogger.logFunctionExit('verifyPhone', 'VerificationService');
|
|
211
|
+
return { message: 'Phone verified successfully' };
|
|
212
|
+
}
|
|
213
|
+
catch (error) {
|
|
214
|
+
this.debugLogger.logError(error, 'verifyPhone');
|
|
215
|
+
this.handleError(error, 'signup');
|
|
216
|
+
throw error;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
179
219
|
};
|
|
180
220
|
exports.VerificationService = VerificationService;
|
|
181
221
|
exports.VerificationService = VerificationService = __decorate([
|
|
182
222
|
(0, common_1.Injectable)(),
|
|
183
223
|
__param(0, (0, typeorm_1.InjectRepository)(user_entity_1.NestAuthUser)),
|
|
184
|
-
__param(1, (0, typeorm_1.InjectRepository)(otp_entity_1.NestAuthOTP)),
|
|
185
224
|
__metadata("design:paramtypes", [typeorm_2.Repository,
|
|
186
|
-
typeorm_2.Repository,
|
|
187
225
|
event_emitter_1.EventEmitter2,
|
|
188
226
|
debug_logger_service_1.DebugLoggerService,
|
|
189
|
-
auth_config_service_1.AuthConfigService
|
|
227
|
+
auth_config_service_1.AuthConfigService,
|
|
228
|
+
otp_flow_service_1.OtpFlowService])
|
|
190
229
|
], VerificationService);
|
|
191
230
|
//# sourceMappingURL=verification.service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verification.service.js","sourceRoot":"","sources":["../../../../src/lib/auth/services/verification.service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"verification.service.js","sourceRoot":"","sources":["../../../../src/lib/auth/services/verification.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAwF;AACxF,6CAAmD;AACnD,qCAAqC;AACrC,iEAA+D;AAC/D,sEAAmE;AACnE,yDAAmE;AACnE,yDAAsD;AACtD,2EAAuE;AACvE,mFAA8E;A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HONE_AUTH_PROVIDER = "phone";
|
|
11
|
+
export declare const PASSWORDLESS_AUTH_PROVIDER = "passwordless";
|
|
11
12
|
export declare const OPTIONAL_AUTH_KEY = "optional_auth";
|
|
12
13
|
export declare const AUTH_ERROR_CODES: {
|
|
13
14
|
readonly REGISTRATION_DISABLED: "REGISTRATION_DISABLED";
|
|
@@ -17,6 +18,8 @@ export declare const AUTH_ERROR_CODES: {
|
|
|
17
18
|
readonly INVALID_CREDENTIALS: "INVALID_CREDENTIALS";
|
|
18
19
|
readonly INVALID_PROVIDER: "INVALID_PROVIDER";
|
|
19
20
|
readonly MISSING_REQUIRED_FIELDS: "MISSING_REQUIRED_FIELDS";
|
|
21
|
+
readonly PASSWORDLESS_DISABLED: "PASSWORDLESS_DISABLED";
|
|
22
|
+
readonly MAGIC_LINK_URL_NOT_CONFIGURED: "MAGIC_LINK_URL_NOT_CONFIGURED";
|
|
20
23
|
readonly USER_NOT_FOUND: "USER_NOT_FOUND";
|
|
21
24
|
readonly ACCOUNT_SUSPENDED: "ACCOUNT_SUSPENDED";
|
|
22
25
|
readonly ACCOUNT_INACTIVE: "ACCOUNT_INACTIVE";
|
|
@@ -35,6 +38,7 @@ export declare const AUTH_ERROR_CODES: {
|
|
|
35
38
|
readonly VERIFICATION_CODE_EXPIRED: "VERIFICATION_CODE_EXPIRED";
|
|
36
39
|
readonly NO_EMAIL_ADDRESS: "NO_EMAIL_ADDRESS";
|
|
37
40
|
readonly NO_PHONE_NUMBER: "NO_PHONE_NUMBER";
|
|
41
|
+
readonly PHONE_ALREADY_VERIFIED: "PHONE_ALREADY_VERIFIED";
|
|
38
42
|
};
|
|
39
43
|
export declare const MFA_ERROR_CODES: {
|
|
40
44
|
readonly MFA_NOT_ENABLED: "MFA_NOT_ENABLED";
|
|
@@ -156,6 +160,8 @@ export declare const ERROR_CODES: {
|
|
|
156
160
|
readonly INVALID_CREDENTIALS: "INVALID_CREDENTIALS";
|
|
157
161
|
readonly INVALID_PROVIDER: "INVALID_PROVIDER";
|
|
158
162
|
readonly MISSING_REQUIRED_FIELDS: "MISSING_REQUIRED_FIELDS";
|
|
163
|
+
readonly PASSWORDLESS_DISABLED: "PASSWORDLESS_DISABLED";
|
|
164
|
+
readonly MAGIC_LINK_URL_NOT_CONFIGURED: "MAGIC_LINK_URL_NOT_CONFIGURED";
|
|
159
165
|
readonly ACCOUNT_SUSPENDED: "ACCOUNT_SUSPENDED";
|
|
160
166
|
readonly ACCOUNT_INACTIVE: "ACCOUNT_INACTIVE";
|
|
161
167
|
readonly EMAIL_NOT_VERIFIED: "EMAIL_NOT_VERIFIED";
|
|
@@ -173,6 +179,7 @@ export declare const ERROR_CODES: {
|
|
|
173
179
|
readonly VERIFICATION_CODE_EXPIRED: "VERIFICATION_CODE_EXPIRED";
|
|
174
180
|
readonly NO_EMAIL_ADDRESS: "NO_EMAIL_ADDRESS";
|
|
175
181
|
readonly NO_PHONE_NUMBER: "NO_PHONE_NUMBER";
|
|
182
|
+
readonly PHONE_ALREADY_VERIFIED: "PHONE_ALREADY_VERIFIED";
|
|
176
183
|
};
|
|
177
184
|
export type ErrorCode = typeof ERROR_CODES[keyof typeof ERROR_CODES];
|
|
178
185
|
export declare const ACCESS_TOKEN_COOKIE_NAME = "accessToken";
|
|
@@ -182,7 +189,11 @@ export declare const DEFAULT_GUARD_NAME = "web";
|
|
|
182
189
|
export declare const NestAuthEvents: {
|
|
183
190
|
readonly EMAIL_VERIFICATION_REQUESTED: "email.verification.requested";
|
|
184
191
|
readonly EMAIL_VERIFIED: "email.verified";
|
|
192
|
+
readonly PHONE_VERIFICATION_REQUESTED: "phone.verification.requested";
|
|
193
|
+
readonly PHONE_VERIFIED: "phone.verified";
|
|
185
194
|
readonly LOGGED_IN: "nest_auth.logged_in";
|
|
195
|
+
readonly PASSWORDLESS_CODE_REQUESTED: "nest_auth.passwordless.code.requested";
|
|
196
|
+
readonly MAGIC_LINK_REQUESTED: "nest_auth.passwordless.magic_link.requested";
|
|
186
197
|
readonly REGISTERED: "nest_auth.registered";
|
|
187
198
|
readonly TWO_FACTOR_VERIFIED: "nest_auth.two_factor_verified";
|
|
188
199
|
readonly TWO_FACTOR_CODE_SENT: "nest_auth.two_factor_code_sent";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.constants.d.ts","sourceRoot":"","sources":["../../src/lib/auth.constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mBAAmB,kCAAkC,CAAC;AACnE,eAAO,MAAM,gCAAgC,qCAAqC,CAAC;AAGnF,eAAO,MAAM,gCAAgC,qCAAqC,CAAC;AAEnF,eAAO,MAAM,iBAAiB,QAAQ,CAAC;AACvC,eAAO,MAAM,oBAAoB,WAAW,CAAC;AAC7C,eAAO,MAAM,sBAAsB,aAAa,CAAC;AACjD,eAAO,MAAM,mBAAmB,UAAU,CAAC;AAC3C,eAAO,MAAM,oBAAoB,WAAW,CAAC;AAC7C,eAAO,MAAM,mBAAmB,UAAU,CAAC;AAC3C,eAAO,MAAM,mBAAmB,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"auth.constants.d.ts","sourceRoot":"","sources":["../../src/lib/auth.constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mBAAmB,kCAAkC,CAAC;AACnE,eAAO,MAAM,gCAAgC,qCAAqC,CAAC;AAGnF,eAAO,MAAM,gCAAgC,qCAAqC,CAAC;AAEnF,eAAO,MAAM,iBAAiB,QAAQ,CAAC;AACvC,eAAO,MAAM,oBAAoB,WAAW,CAAC;AAC7C,eAAO,MAAM,sBAAsB,aAAa,CAAC;AACjD,eAAO,MAAM,mBAAmB,UAAU,CAAC;AAC3C,eAAO,MAAM,oBAAoB,WAAW,CAAC;AAC7C,eAAO,MAAM,mBAAmB,UAAU,CAAC;AAC3C,eAAO,MAAM,mBAAmB,UAAU,CAAC;AAE3C,eAAO,MAAM,0BAA0B,iBAAiB,CAAC;AAIzD,eAAO,MAAM,iBAAiB,kBAAkB,CAAC;AAOjD,eAAO,MAA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