@solidstarters/solid-core 1.2.143 → 1.2.145

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.
Files changed (133) hide show
  1. package/dist/config/common.config.d.ts +2 -0
  2. package/dist/config/common.config.d.ts.map +1 -1
  3. package/dist/config/common.config.js +3 -2
  4. package/dist/config/common.config.js.map +1 -1
  5. package/dist/constants/error-messages.d.ts +83 -0
  6. package/dist/constants/error-messages.d.ts.map +1 -0
  7. package/dist/constants/error-messages.js +86 -0
  8. package/dist/constants/error-messages.js.map +1 -0
  9. package/dist/constants/success-messages.d.ts +11 -0
  10. package/dist/constants/success-messages.d.ts.map +1 -0
  11. package/dist/constants/success-messages.js +14 -0
  12. package/dist/constants/success-messages.js.map +1 -0
  13. package/dist/index.d.ts +7 -3
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +10 -4
  16. package/dist/index.js.map +1 -1
  17. package/dist/interfaces.js.map +1 -1
  18. package/dist/jobs/api-email-subscriber.service.d.ts +1 -1
  19. package/dist/jobs/api-email-subscriber.service.d.ts.map +1 -1
  20. package/dist/jobs/api-email-subscriber.service.js +2 -2
  21. package/dist/jobs/api-email-subscriber.service.js.map +1 -1
  22. package/dist/jobs/database/api-email-subscriber-database.service.d.ts +1 -1
  23. package/dist/jobs/database/api-email-subscriber-database.service.d.ts.map +1 -1
  24. package/dist/jobs/database/api-email-subscriber-database.service.js +2 -2
  25. package/dist/jobs/database/api-email-subscriber-database.service.js.map +1 -1
  26. package/dist/jobs/database/email-subscriber-database.service.d.ts +1 -1
  27. package/dist/jobs/database/email-subscriber-database.service.d.ts.map +1 -1
  28. package/dist/jobs/database/email-subscriber-database.service.js +2 -2
  29. package/dist/jobs/database/email-subscriber-database.service.js.map +1 -1
  30. package/dist/jobs/email-subscriber.service.d.ts +1 -1
  31. package/dist/jobs/email-subscriber.service.d.ts.map +1 -1
  32. package/dist/jobs/email-subscriber.service.js +2 -2
  33. package/dist/jobs/email-subscriber.service.js.map +1 -1
  34. package/dist/seeders/seed-data/solid-core-metadata.json +12 -12
  35. package/dist/services/ai-interaction.service.d.ts.map +1 -1
  36. package/dist/services/ai-interaction.service.js +4 -3
  37. package/dist/services/ai-interaction.service.js.map +1 -1
  38. package/dist/services/authentication.service.d.ts +1 -1
  39. package/dist/services/authentication.service.d.ts.map +1 -1
  40. package/dist/services/authentication.service.js +68 -66
  41. package/dist/services/authentication.service.js.map +1 -1
  42. package/dist/services/crud-helper.service.d.ts.map +1 -1
  43. package/dist/services/crud-helper.service.js +3 -2
  44. package/dist/services/crud-helper.service.js.map +1 -1
  45. package/dist/services/crud.service.d.ts.map +1 -1
  46. package/dist/services/crud.service.js +23 -21
  47. package/dist/services/crud.service.js.map +1 -1
  48. package/dist/services/csv.service.d.ts.map +1 -1
  49. package/dist/services/csv.service.js +3 -2
  50. package/dist/services/csv.service.js.map +1 -1
  51. package/dist/services/excel.service.d.ts.map +1 -1
  52. package/dist/services/excel.service.js +3 -2
  53. package/dist/services/excel.service.js.map +1 -1
  54. package/dist/services/export-transaction.service.d.ts.map +1 -1
  55. package/dist/services/export-transaction.service.js +2 -1
  56. package/dist/services/export-transaction.service.js.map +1 -1
  57. package/dist/services/field-metadata.service.d.ts.map +1 -1
  58. package/dist/services/field-metadata.service.js +9 -8
  59. package/dist/services/field-metadata.service.js.map +1 -1
  60. package/dist/services/file.service.d.ts.map +1 -1
  61. package/dist/services/file.service.js +5 -4
  62. package/dist/services/file.service.js.map +1 -1
  63. package/dist/services/import-transaction.service.d.ts.map +1 -1
  64. package/dist/services/import-transaction.service.js +11 -9
  65. package/dist/services/import-transaction.service.js.map +1 -1
  66. package/dist/services/mail/{ElasticEmailService.d.ts → elastic-email.service.d.ts} +1 -1
  67. package/dist/services/mail/elastic-email.service.d.ts.map +1 -0
  68. package/dist/services/mail/{ElasticEmailService.js → elastic-email.service.js} +1 -1
  69. package/dist/services/mail/elastic-email.service.js.map +1 -0
  70. package/dist/services/mail/{SMTPEmailService.d.ts → smtp-email.service.d.ts} +3 -3
  71. package/dist/services/mail/smtp-email.service.d.ts.map +1 -0
  72. package/dist/services/mail/{SMTPEmailService.js → smtp-email.service.js} +8 -6
  73. package/dist/services/mail/smtp-email.service.js.map +1 -0
  74. package/dist/services/media-storage-provider-metadata.service.d.ts.map +1 -1
  75. package/dist/services/media-storage-provider-metadata.service.js +4 -3
  76. package/dist/services/media-storage-provider-metadata.service.js.map +1 -1
  77. package/dist/services/media.service.d.ts.map +1 -1
  78. package/dist/services/media.service.js +2 -1
  79. package/dist/services/media.service.js.map +1 -1
  80. package/dist/services/model-metadata.service.d.ts.map +1 -1
  81. package/dist/services/model-metadata.service.js +11 -10
  82. package/dist/services/model-metadata.service.js.map +1 -1
  83. package/dist/services/module-metadata.service.d.ts.map +1 -1
  84. package/dist/services/module-metadata.service.js +11 -10
  85. package/dist/services/module-metadata.service.js.map +1 -1
  86. package/dist/services/role-metadata.service.d.ts.map +1 -1
  87. package/dist/services/role-metadata.service.js +3 -2
  88. package/dist/services/role-metadata.service.js.map +1 -1
  89. package/dist/services/sql-expression-resolver.service.d.ts.map +1 -1
  90. package/dist/services/sql-expression-resolver.service.js +2 -1
  91. package/dist/services/sql-expression-resolver.service.js.map +1 -1
  92. package/dist/services/user.service.d.ts.map +1 -1
  93. package/dist/services/user.service.js +11 -10
  94. package/dist/services/user.service.js.map +1 -1
  95. package/dist/solid-core.module.d.ts.map +1 -1
  96. package/dist/solid-core.module.js +9 -7
  97. package/dist/solid-core.module.js.map +1 -1
  98. package/dist/tsconfig.tsbuildinfo +1 -1
  99. package/package.json +1 -1
  100. package/src/config/common.config.ts +3 -2
  101. package/src/constants/error-messages.ts +123 -0
  102. package/src/constants/success-messages.ts +13 -0
  103. package/src/index.ts +10 -4
  104. package/src/interfaces.ts +3 -3
  105. package/src/jobs/api-email-subscriber.service.ts +1 -1
  106. package/src/jobs/database/api-email-subscriber-database.service.ts +1 -1
  107. package/src/jobs/database/email-subscriber-database.service.ts +1 -1
  108. package/src/jobs/email-subscriber.service.ts +1 -1
  109. package/src/seeders/seed-data/solid-core-metadata.json +12 -12
  110. package/src/services/ai-interaction.service.ts +4 -3
  111. package/src/services/authentication.service.ts +67 -65
  112. package/src/services/crud-helper.service.ts +3 -2
  113. package/src/services/crud.service.ts +23 -23
  114. package/src/services/csv.service.ts +3 -2
  115. package/src/services/excel.service.ts +3 -2
  116. package/src/services/export-transaction.service.ts +2 -1
  117. package/src/services/field-metadata.service.ts +9 -8
  118. package/src/services/file.service.ts +5 -4
  119. package/src/services/import-transaction.service.ts +11 -9
  120. package/src/services/mail/{SMTPEmailService.ts → smtp-email.service.ts} +7 -5
  121. package/src/services/media-storage-provider-metadata.service.ts +4 -3
  122. package/src/services/media.service.ts +2 -1
  123. package/src/services/model-metadata.service.ts +11 -10
  124. package/src/services/module-metadata.service.ts +11 -10
  125. package/src/services/role-metadata.service.ts +3 -2
  126. package/src/services/sql-expression-resolver.service.ts +2 -1
  127. package/src/services/user.service.ts +11 -10
  128. package/src/solid-core.module.ts +5 -3
  129. package/dist/services/mail/ElasticEmailService.d.ts.map +0 -1
  130. package/dist/services/mail/ElasticEmailService.js.map +0 -1
  131. package/dist/services/mail/SMTPEmailService.d.ts.map +0 -1
  132. package/dist/services/mail/SMTPEmailService.js.map +0 -1
  133. /package/src/services/mail/{ElasticEmailService.ts → elastic-email.service.ts} +0 -0
@@ -24,7 +24,7 @@ const jwt_1 = require("@nestjs/jwt");
24
24
  const typeorm_1 = require("@nestjs/typeorm");
25
25
  const class_validator_1 = require("class-validator");
26
26
  const crypto_1 = require("crypto");
27
- const SMTPEmailService_1 = require("./mail/SMTPEmailService");
27
+ const smtp_email_service_1 = require("./mail/smtp-email.service");
28
28
  const Msg91OTPService_1 = require("./sms/Msg91OTPService");
29
29
  const typeorm_2 = require("typeorm");
30
30
  const iam_config_1 = require("../config/iam.config");
@@ -40,6 +40,8 @@ const role_metadata_service_1 = require("./role-metadata.service");
40
40
  const common_config_1 = __importDefault(require("../config/common.config"));
41
41
  const user_activity_history_service_1 = require("./user-activity-history.service");
42
42
  const request_context_service_1 = require("./request-context.service");
43
+ const error_messages_1 = require("../constants/error-messages");
44
+ const success_messages_1 = require("../constants/success-messages");
43
45
  var LoginProvider;
44
46
  (function (LoginProvider) {
45
47
  LoginProvider["LOCAL"] = "local";
@@ -87,20 +89,20 @@ let AuthenticationService = AuthenticationService_1 = class AuthenticationServic
87
89
  async validateUser(signInDto) {
88
90
  const user = await this.resolveUser(signInDto.username, signInDto.email);
89
91
  if (!user) {
90
- throw new common_1.UnauthorizedException('User does not exists');
92
+ throw new common_1.UnauthorizedException(error_messages_1.ERROR_MESSAGES.USER_NOT_FOUND);
91
93
  }
92
94
  if (!user.active) {
93
- throw new common_1.UnauthorizedException('User profile not activated');
95
+ throw new common_1.UnauthorizedException(error_messages_1.ERROR_MESSAGES.USER_NOT_ACTIVE);
94
96
  }
95
97
  const isEqual = await this.hashingService.compare(signInDto.password, user.password);
96
98
  if (!isEqual) {
97
- throw new common_1.UnauthorizedException('Password does not match');
99
+ throw new common_1.UnauthorizedException(error_messages_1.ERROR_MESSAGES.PASSWORD_INCORRECT);
98
100
  }
99
101
  return user;
100
102
  }
101
103
  async signUp(signUpDto, activeUser = null) {
102
104
  if (!(await this.settingService.getConfigValue('allowPublicRegistration')) && !activeUser) {
103
- throw new common_1.BadRequestException('Public registrations are disabled.');
105
+ throw new common_1.BadRequestException(error_messages_1.ERROR_MESSAGES.PUBLIC_REGISTRATION_DISABLED);
104
106
  }
105
107
  try {
106
108
  const onForcePasswordChange = await this.getConfig('forceChangePasswordOnFirstLogin');
@@ -116,7 +118,7 @@ let AuthenticationService = AuthenticationService_1 = class AuthenticationServic
116
118
  catch (err) {
117
119
  const pgUniqueViolationErrorCode = '23505';
118
120
  if (err.code === pgUniqueViolationErrorCode) {
119
- throw new common_1.ConflictException();
121
+ throw new common_1.ConflictException(error_messages_1.ERROR_MESSAGES.USER_ALREADY_EXISTS);
120
122
  }
121
123
  throw err;
122
124
  }
@@ -133,7 +135,7 @@ let AuthenticationService = AuthenticationService_1 = class AuthenticationServic
133
135
  catch (err) {
134
136
  const pgUniqueViolationErrorCode = '23505';
135
137
  if (err.code === pgUniqueViolationErrorCode) {
136
- throw new common_1.ConflictException(parseUniqueConstraintError(err.detail || 'A unique constraint violation occurred.'));
138
+ throw new common_1.ConflictException(parseUniqueConstraintError(err.detail || error_messages_1.ERROR_MESSAGES.UNIQUE_CONSTRAINT_VIOLATION));
137
139
  }
138
140
  throw err;
139
141
  }
@@ -206,16 +208,16 @@ let AuthenticationService = AuthenticationService_1 = class AuthenticationServic
206
208
  async otpInitiateRegistration(signUpDto) {
207
209
  try {
208
210
  if (!this.isPasswordlessRegistrationEnabled()) {
209
- throw new common_1.BadRequestException('Passwordless registration is not enabled');
211
+ throw new common_1.BadRequestException(error_messages_1.ERROR_MESSAGES.PASSWORDLESS_REGISTRATION_DISABLED);
210
212
  }
211
213
  if ((0, class_validator_1.isEmpty)(signUpDto.mobile) && (0, class_validator_1.isEmpty)(signUpDto.email)) {
212
- throw new common_1.BadRequestException('Either mobile or email is required for initiating registration');
214
+ throw new common_1.BadRequestException(error_messages_1.ERROR_MESSAGES.REGISTRATION_REQUIRES_CONTACT);
213
215
  }
214
216
  if (signUpDto.validationSources.includes(constants_1.TransactionalRegistrationValidationSource.EMAIL) && (0, class_validator_1.isEmpty)(signUpDto.email)) {
215
- throw new common_1.BadRequestException('Email is required for email validation source');
217
+ throw new common_1.BadRequestException(error_messages_1.ERROR_MESSAGES.EMAIL_REQUIRED_FOR_VALIDATION);
216
218
  }
217
219
  if (signUpDto.validationSources.includes(constants_1.TransactionalRegistrationValidationSource.MOBILE) && (0, class_validator_1.isEmpty)(signUpDto.mobile)) {
218
- throw new common_1.BadRequestException('Mobile is required for mobile validation source');
220
+ throw new common_1.BadRequestException(error_messages_1.ERROR_MESSAGES.MOBILE_REQUIRED_FOR_VALIDATION);
219
221
  }
220
222
  const existingUser = await this.userRepository.findOne({
221
223
  where: [
@@ -225,7 +227,7 @@ let AuthenticationService = AuthenticationService_1 = class AuthenticationServic
225
227
  ]
226
228
  });
227
229
  if ((0, class_validator_1.isNotEmpty)(existingUser) && existingUser.active) {
228
- throw new common_1.ConflictException('User already exists. Please sign in');
230
+ throw new common_1.ConflictException(error_messages_1.ERROR_MESSAGES.USER_ALREADY_EXISTS);
229
231
  }
230
232
  const finalRegistrationVerificationSources = this.calculateVerificationSources(this.iamConfiguration.passwordlessRegistrationValidateWhat, signUpDto);
231
233
  let user = existingUser;
@@ -240,12 +242,12 @@ let AuthenticationService = AuthenticationService_1 = class AuthenticationServic
240
242
  await this.userRepository.save(user);
241
243
  }
242
244
  this.notifyUserOnOtpInitiateRegistration(user, finalRegistrationVerificationSources);
243
- return { message: 'User registration initiated. OTP sent to the user.' };
245
+ return { message: success_messages_1.SUCCESS_MESSAGES.OTP_SENT_SUCCESS_REGISTRATION };
244
246
  }
245
247
  catch (err) {
246
248
  const pgUniqueViolationErrorCode = '23505';
247
249
  if (err.code === pgUniqueViolationErrorCode) {
248
- throw new common_1.ConflictException();
250
+ throw new common_1.ConflictException(error_messages_1.ERROR_MESSAGES.USER_ALREADY_EXISTS);
249
251
  }
250
252
  throw err;
251
253
  }
@@ -268,7 +270,7 @@ let AuthenticationService = AuthenticationService_1 = class AuthenticationServic
268
270
  }
269
271
  populateVerificationTokens(finalRegistrationValidationSources, user) {
270
272
  if (finalRegistrationValidationSources.length === 0) {
271
- throw new common_1.BadRequestException('At least one validation source is required');
273
+ throw new common_1.BadRequestException(error_messages_1.ERROR_MESSAGES.VALIDATION_SOURCE_REQUIRED);
272
274
  }
273
275
  if (finalRegistrationValidationSources.includes(constants_1.TransactionalRegistrationValidationSource.EMAIL)) {
274
276
  const { token, expiresAt } = this.otp();
@@ -316,7 +318,7 @@ let AuthenticationService = AuthenticationService_1 = class AuthenticationServic
316
318
  }
317
319
  async otpConfirmRegistration(confirmSignUpDto) {
318
320
  if (!this.isPasswordlessRegistrationEnabled()) {
319
- throw new common_1.BadRequestException('Passwordless registration is not enabled');
321
+ throw new common_1.BadRequestException(error_messages_1.ERROR_MESSAGES.PASSWORDLESS_REGISTRATION_DISABLED);
320
322
  }
321
323
  if (confirmSignUpDto.type === constants_1.RegistrationValidationSource.EMAIL) {
322
324
  const user = await this.userRepository.findOne({
@@ -325,13 +327,13 @@ let AuthenticationService = AuthenticationService_1 = class AuthenticationServic
325
327
  }
326
328
  });
327
329
  if (!user) {
328
- throw new common_1.UnauthorizedException('User does not exist');
330
+ throw new common_1.UnauthorizedException(error_messages_1.ERROR_MESSAGES.USER_NOT_FOUND);
329
331
  }
330
332
  if (user.emailVerificationTokenOnRegistration !== confirmSignUpDto.otp) {
331
- throw new common_1.UnauthorizedException('Invalid OTP');
333
+ throw new common_1.UnauthorizedException(error_messages_1.ERROR_MESSAGES.INVALID_OTP);
332
334
  }
333
335
  if (user.emailVerificationTokenOnRegistrationExpiresAt < new Date()) {
334
- throw new common_1.UnauthorizedException('OTP expired');
336
+ throw new common_1.UnauthorizedException(error_messages_1.ERROR_MESSAGES.OTP_EXPIRED);
335
337
  }
336
338
  user.emailVerifiedOnRegistrationAt = new Date();
337
339
  user.emailVerificationTokenOnRegistration = null;
@@ -348,13 +350,13 @@ let AuthenticationService = AuthenticationService_1 = class AuthenticationServic
348
350
  }
349
351
  });
350
352
  if (!user) {
351
- throw new common_1.UnauthorizedException('User does not exist');
353
+ throw new common_1.UnauthorizedException(error_messages_1.ERROR_MESSAGES.USER_NOT_FOUND);
352
354
  }
353
355
  if (user.mobileVerificationTokenOnRegistration !== confirmSignUpDto.otp) {
354
- throw new common_1.UnauthorizedException('Invalid OTP');
356
+ throw new common_1.UnauthorizedException(error_messages_1.ERROR_MESSAGES.INVALID_OTP);
355
357
  }
356
358
  if (user.mobileVerificationTokenOnRegistrationExpiresAt < new Date()) {
357
- throw new common_1.UnauthorizedException('Invalid OTP');
359
+ throw new common_1.UnauthorizedException(error_messages_1.ERROR_MESSAGES.INVALID_OTP);
358
360
  }
359
361
  user.mobileVerifiedOnRegistrationAt = new Date();
360
362
  user.mobileVerificationTokenOnRegistration = null;
@@ -364,7 +366,7 @@ let AuthenticationService = AuthenticationService_1 = class AuthenticationServic
364
366
  this.triggerRegistrationEvent(savedUser);
365
367
  return { active: savedUser.active, message: `User registration verified for ${confirmSignUpDto.type}` };
366
368
  }
367
- throw new common_1.BadRequestException('Invalid type. Must be either email or mobile');
369
+ throw new common_1.BadRequestException(error_messages_1.ERROR_MESSAGES.INVALID_VERIFICATION_TYPE);
368
370
  }
369
371
  triggerRegistrationEvent(savedUser) {
370
372
  const event = new interfaces_1.EventDetails(interfaces_1.EventType.USER_REGISTERED, savedUser);
@@ -410,7 +412,7 @@ let AuthenticationService = AuthenticationService_1 = class AuthenticationServic
410
412
  }
411
413
  async otpInitiateLogin(signInDto) {
412
414
  if (!this.isPasswordlessRegistrationEnabled()) {
413
- throw new common_1.BadRequestException('Passwordless registration is not enabled');
415
+ throw new common_1.BadRequestException(error_messages_1.ERROR_MESSAGES.PASSWORDLESS_REGISTRATION_DISABLED);
414
416
  }
415
417
  if (signInDto.type === constants_1.RegistrationValidationSource.EMAIL) {
416
418
  const user = await this.userRepository.findOne({
@@ -419,10 +421,10 @@ let AuthenticationService = AuthenticationService_1 = class AuthenticationServic
419
421
  }
420
422
  });
421
423
  if (!user) {
422
- throw new common_1.UnauthorizedException('User does not exist');
424
+ throw new common_1.UnauthorizedException(error_messages_1.ERROR_MESSAGES.USER_NOT_FOUND);
423
425
  }
424
426
  if (!user.active) {
425
- throw new common_1.UnauthorizedException('User is inactive');
427
+ throw new common_1.UnauthorizedException(error_messages_1.ERROR_MESSAGES.USER_INACTIVE);
426
428
  }
427
429
  const { token, expiresAt } = this.otp();
428
430
  user.emailVerificationTokenOnLogin = token;
@@ -437,7 +439,7 @@ let AuthenticationService = AuthenticationService_1 = class AuthenticationServic
437
439
  }
438
440
  });
439
441
  if (!user) {
440
- throw new common_1.UnauthorizedException('User does not exist');
442
+ throw new common_1.UnauthorizedException(error_messages_1.ERROR_MESSAGES.USER_NOT_FOUND);
441
443
  }
442
444
  const { token, expiresAt } = this.otp();
443
445
  user.mobileVerificationTokenOnLogin = token;
@@ -446,9 +448,9 @@ let AuthenticationService = AuthenticationService_1 = class AuthenticationServic
446
448
  this.notifyUserOnOtpInititateLogin(user, constants_1.RegistrationValidationSource.MOBILE);
447
449
  }
448
450
  else {
449
- throw new common_1.BadRequestException('Invalid type. Must be either email or mobile');
451
+ throw new common_1.BadRequestException(error_messages_1.ERROR_MESSAGES.INVALID_VERIFICATION_TYPE);
450
452
  }
451
- return { message: 'User login initiated. OTP sent to the user.' };
453
+ return { message: success_messages_1.SUCCESS_MESSAGES.OTP_SENT_SUCCESS_LOGIN };
452
454
  }
453
455
  async notifyUserOnOtpInititateLogin(user, loginType) {
454
456
  const companyLogo = await this.getCompanyLogo();
@@ -477,7 +479,7 @@ let AuthenticationService = AuthenticationService_1 = class AuthenticationServic
477
479
  }
478
480
  async otpConfirmLogin(confirmSignInDto) {
479
481
  if (!this.isPasswordlessRegistrationEnabled()) {
480
- throw new common_1.BadRequestException('Passwordless registration is not enabled');
482
+ throw new common_1.BadRequestException(error_messages_1.ERROR_MESSAGES.PASSWORDLESS_REGISTRATION_DISABLED);
481
483
  }
482
484
  if (confirmSignInDto.type === constants_1.RegistrationValidationSource.EMAIL) {
483
485
  const user = await this.userRepository.findOne({
@@ -487,16 +489,16 @@ let AuthenticationService = AuthenticationService_1 = class AuthenticationServic
487
489
  relations: ['roles']
488
490
  });
489
491
  if (!user) {
490
- throw new common_1.UnauthorizedException('User does not exist');
492
+ throw new common_1.UnauthorizedException(error_messages_1.ERROR_MESSAGES.USER_NOT_FOUND);
491
493
  }
492
494
  if (!user.active) {
493
- throw new common_1.UnauthorizedException('User is inactive');
495
+ throw new common_1.UnauthorizedException(error_messages_1.ERROR_MESSAGES.USER_INACTIVE);
494
496
  }
495
497
  if (user.emailVerificationTokenOnLogin !== confirmSignInDto.otp) {
496
- throw new common_1.UnauthorizedException('Invalid OTP');
498
+ throw new common_1.UnauthorizedException(error_messages_1.ERROR_MESSAGES.INVALID_OTP);
497
499
  }
498
500
  if (user.emailVerificationTokenOnLoginExpiresAt < new Date()) {
499
- throw new common_1.UnauthorizedException('Invalid OTP');
501
+ throw new common_1.UnauthorizedException(error_messages_1.ERROR_MESSAGES.INVALID_OTP);
500
502
  }
501
503
  user.emailVerifiedOnLoginAt = new Date();
502
504
  user.emailVerificationTokenOnLogin = null;
@@ -515,16 +517,16 @@ let AuthenticationService = AuthenticationService_1 = class AuthenticationServic
515
517
  relations: ['roles']
516
518
  });
517
519
  if (!user) {
518
- throw new common_1.UnauthorizedException('User does not exist');
520
+ throw new common_1.UnauthorizedException(error_messages_1.ERROR_MESSAGES.USER_NOT_ACTIVE);
519
521
  }
520
522
  if (!user.active) {
521
- throw new common_1.UnauthorizedException('User is inactive');
523
+ throw new common_1.UnauthorizedException(error_messages_1.ERROR_MESSAGES.USER_INACTIVE);
522
524
  }
523
525
  if (user.mobileVerificationTokenOnLogin !== confirmSignInDto.otp) {
524
- throw new common_1.UnauthorizedException('Invalid OTP');
526
+ throw new common_1.UnauthorizedException(error_messages_1.ERROR_MESSAGES.INVALID_OTP);
525
527
  }
526
528
  if (user.mobileVerificationTokenOnLoginExpiresAt < new Date()) {
527
- throw new common_1.UnauthorizedException('Invalid OTP');
529
+ throw new common_1.UnauthorizedException(error_messages_1.ERROR_MESSAGES.INVALID_OTP);
528
530
  }
529
531
  user.mobileVerifiedOnLoginAt = new Date();
530
532
  user.mobileVerificationTokenOnLogin = null;
@@ -535,36 +537,36 @@ let AuthenticationService = AuthenticationService_1 = class AuthenticationServic
535
537
  const roles = user.roles.map((role) => role.name);
536
538
  return { accessToken, refreshToken, user: { id, username, email, mobile, lastLoginProvider, roles } };
537
539
  }
538
- throw new common_1.BadRequestException('Invalid type. Must be either email or mobile');
540
+ throw new common_1.BadRequestException(error_messages_1.ERROR_MESSAGES.INVALID_VERIFICATION_TYPE);
539
541
  }
540
542
  async changePassword(changePasswordDto, activeUser) {
541
543
  const user = await this.userRepository.findOne({
542
544
  where: { id: changePasswordDto.id }
543
545
  });
544
546
  if (!user) {
545
- throw new common_1.NotFoundException('User does not exists');
547
+ throw new common_1.NotFoundException(error_messages_1.ERROR_MESSAGES.USER_NOT_FOUND);
546
548
  }
547
549
  if (!user.active) {
548
- throw new common_1.UnauthorizedException('User is inactive');
550
+ throw new common_1.UnauthorizedException(error_messages_1.ERROR_MESSAGES.USER_INACTIVE);
549
551
  }
550
552
  if (user.lastLoginProvider !== 'local') {
551
- throw new common_1.BadRequestException('User seems to have used a passwordless mode to authenticate.');
553
+ throw new common_1.BadRequestException(error_messages_1.ERROR_MESSAGES.NON_LOCAL_PROVIDER);
552
554
  }
553
555
  if (!(user.id === activeUser.sub)) {
554
- throw new common_1.BadRequestException("User ID's do not match ");
556
+ throw new common_1.BadRequestException(error_messages_1.ERROR_MESSAGES.USER_ID_MISMATCH);
555
557
  }
556
558
  if (!(user.username === activeUser.username)) {
557
- throw new common_1.BadRequestException("User username's do not match");
559
+ throw new common_1.BadRequestException(error_messages_1.ERROR_MESSAGES.USERNAME_MISMATCH);
558
560
  }
559
561
  const isEqual = await this.hashingService.compare(changePasswordDto.currentPassword, user.password);
560
562
  if (!isEqual) {
561
- throw new common_1.UnauthorizedException('Incorrect current password specified...');
563
+ throw new common_1.UnauthorizedException(error_messages_1.ERROR_MESSAGES.INCORRECT_CURRENT_PASSWORD);
562
564
  }
563
565
  const newPwd = await this.hashingService.hash(changePasswordDto.newPassword);
564
566
  user.password = changePasswordDto.newPassword;
565
567
  user.forcePasswordChange = false;
566
568
  if (await this.isPasswordDuplicate(user)) {
567
- throw new common_1.BadRequestException('Previously used passwords cannot be used again.');
569
+ throw new common_1.BadRequestException(error_messages_1.ERROR_MESSAGES.PASSWORD_REUSED);
568
570
  }
569
571
  await this.deleteOldPasswords(user);
570
572
  user.password = newPwd;
@@ -578,13 +580,13 @@ let AuthenticationService = AuthenticationService_1 = class AuthenticationServic
578
580
  async initiateForgotPassword(initiateForgotPasswordDto) {
579
581
  const user = await this.resolveUser(initiateForgotPasswordDto.username, initiateForgotPasswordDto.email);
580
582
  if (!user) {
581
- throw new common_1.NotFoundException('User does not exists');
583
+ throw new common_1.NotFoundException(error_messages_1.ERROR_MESSAGES.USER_NOT_FOUND);
582
584
  }
583
585
  if (!user.active) {
584
- throw new common_1.UnauthorizedException('User is inactive');
586
+ throw new common_1.UnauthorizedException(error_messages_1.ERROR_MESSAGES.USER_INACTIVE);
585
587
  }
586
588
  if (user.lastLoginProvider !== 'local') {
587
- throw new common_1.BadRequestException('User seems to have used a passwordless mode to authenticate.');
589
+ throw new common_1.BadRequestException(error_messages_1.ERROR_MESSAGES.NON_LOCAL_PROVIDER);
588
590
  }
589
591
  const { token, expiresAt } = this.otp();
590
592
  user.verificationTokenOnForgotPassword = token;
@@ -593,7 +595,7 @@ let AuthenticationService = AuthenticationService_1 = class AuthenticationServic
593
595
  this.notifyUserOnForgotPassword(user);
594
596
  return {
595
597
  status: 'success',
596
- message: 'Forgot password - token generated and sent',
598
+ message: success_messages_1.SUCCESS_MESSAGES.FORGOT_PASSWORD_TOKEN_SENT,
597
599
  error: '',
598
600
  errorCode: '',
599
601
  data: {
@@ -631,19 +633,19 @@ let AuthenticationService = AuthenticationService_1 = class AuthenticationServic
631
633
  async confirmForgotPassword(confirmForgotPasswordDto) {
632
634
  const user = await this.resolveUser(confirmForgotPasswordDto.username, confirmForgotPasswordDto.email);
633
635
  if (!user) {
634
- throw new common_1.NotFoundException('User does not exists');
636
+ throw new common_1.NotFoundException(error_messages_1.ERROR_MESSAGES.USER_NOT_FOUND);
635
637
  }
636
638
  if (user.lastLoginProvider !== 'local') {
637
- throw new common_1.BadRequestException('User seems to have used a passwordless mode to authenticate.');
639
+ throw new common_1.BadRequestException(error_messages_1.ERROR_MESSAGES.NON_LOCAL_PROVIDER);
638
640
  }
639
641
  if (!user.active) {
640
- throw new common_1.UnauthorizedException('User is inactive');
642
+ throw new common_1.UnauthorizedException(error_messages_1.ERROR_MESSAGES.USER_INACTIVE);
641
643
  }
642
644
  if (user.verificationTokenOnForgotPassword !== confirmForgotPasswordDto.verificationToken) {
643
- throw new common_1.UnauthorizedException('Invalid verification token');
645
+ throw new common_1.UnauthorizedException(error_messages_1.ERROR_MESSAGES.INVALID_VERIFICATION_TOKEN);
644
646
  }
645
647
  if (user.verificationTokenOnForgotPasswordExpiresAt < new Date()) {
646
- throw new common_1.UnauthorizedException('Invalid verification token');
648
+ throw new common_1.UnauthorizedException(error_messages_1.ERROR_MESSAGES.INVALID_VERIFICATION_TOKEN);
647
649
  }
648
650
  user.forgotPasswordConfirmedAt = new Date();
649
651
  user.verificationTokenOnForgotPassword = null;
@@ -651,7 +653,7 @@ let AuthenticationService = AuthenticationService_1 = class AuthenticationServic
651
653
  const pwd = await this.hashingService.hash(confirmForgotPasswordDto.password);
652
654
  user.password = confirmForgotPasswordDto.password;
653
655
  if (await this.isPasswordDuplicate(user)) {
654
- throw new common_1.BadRequestException('Previously used passwords cannot be used again.');
656
+ throw new common_1.BadRequestException(error_messages_1.ERROR_MESSAGES.PASSWORD_REUSED);
655
657
  }
656
658
  await this.deleteOldPasswords(user);
657
659
  user.password = pwd;
@@ -662,7 +664,7 @@ let AuthenticationService = AuthenticationService_1 = class AuthenticationServic
662
664
  await this.userPasswordHistoryRepository.save(userPasswordHistory);
663
665
  return {
664
666
  status: 'success',
665
- message: 'Forgot password confirmed',
667
+ message: success_messages_1.SUCCESS_MESSAGES.FORGOT_PASSWORD_CONFIRMED,
666
668
  error: '',
667
669
  errorCode: '',
668
670
  data: {}
@@ -731,7 +733,7 @@ let AuthenticationService = AuthenticationService_1 = class AuthenticationServic
731
733
  }
732
734
  });
733
735
  if (!user) {
734
- throw new common_1.UnauthorizedException();
736
+ throw new common_1.UnauthorizedException(error_messages_1.ERROR_MESSAGES.SESSION_INVALID);
735
737
  }
736
738
  const currentRefreshToken = await this.refreshTokenIdsStorage.validateAndRotate(user, refreshTokenDto.refreshToken);
737
739
  await this.userActivityHistoryService.logEvent('tokenRefreshed', user);
@@ -742,9 +744,9 @@ let AuthenticationService = AuthenticationService_1 = class AuthenticationServic
742
744
  }
743
745
  catch (err) {
744
746
  if (err instanceof refresh_token_ids_storage_service_1.InvalidatedRefreshTokenError) {
745
- throw new common_1.UnauthorizedException('Access denied');
747
+ throw new common_1.UnauthorizedException(error_messages_1.ERROR_MESSAGES.ACCESS_DENIED);
746
748
  }
747
- throw new common_1.UnauthorizedException();
749
+ throw new common_1.UnauthorizedException(error_messages_1.ERROR_MESSAGES.SESSION_EXPIRED);
748
750
  }
749
751
  }
750
752
  async signToken(userId, expiresIn, payload) {
@@ -766,11 +768,11 @@ let AuthenticationService = AuthenticationService_1 = class AuthenticationServic
766
768
  return userProfile;
767
769
  }
768
770
  else {
769
- throw new common_1.UnauthorizedException('Invalid user profile');
771
+ throw new common_1.UnauthorizedException(error_messages_1.ERROR_MESSAGES.INVALID_USER_PROFILE);
770
772
  }
771
773
  }
772
774
  catch (error) {
773
- throw new common_1.UnauthorizedException('Failed to fetch user profile from Google OAuth service');
775
+ throw new common_1.UnauthorizedException(error_messages_1.ERROR_MESSAGES.GOOGLE_OAUTH_PROFILE_FETCH_FAILED);
774
776
  }
775
777
  }
776
778
  async signInUsingGoogle(accessCode) {
@@ -809,18 +811,18 @@ let AuthenticationService = AuthenticationService_1 = class AuthenticationServic
809
811
  });
810
812
  await this.refreshTokenIdsStorage.invalidate(userId);
811
813
  await this.userActivityHistoryService.logEvent('logout', user);
812
- return { message: 'Logged out successfully' };
814
+ return { message: success_messages_1.SUCCESS_MESSAGES.LOGOUT_SUCCESS };
813
815
  }
814
816
  catch (err) {
815
817
  throw err instanceof common_1.UnauthorizedException || err instanceof common_1.InternalServerErrorException
816
818
  ? err
817
- : new common_1.InternalServerErrorException('Logout failed due to an unexpected error.');
819
+ : new common_1.InternalServerErrorException(error_messages_1.ERROR_MESSAGES.LOGOUT_FAILED);
818
820
  }
819
821
  }
820
822
  async activateUser(userId) {
821
823
  const user = await this.userService.findOne(userId, {});
822
824
  if (!user) {
823
- throw new common_1.NotFoundException('User not found');
825
+ throw new common_1.NotFoundException(error_messages_1.ERROR_MESSAGES.USER_NOT_FOUND);
824
826
  }
825
827
  user.active = true;
826
828
  await this.userRepository.save(user);
@@ -862,7 +864,7 @@ exports.AuthenticationService = AuthenticationService = AuthenticationService_1
862
864
  hashing_service_1.HashingService,
863
865
  jwt_1.JwtService, void 0, void 0, refresh_token_ids_storage_service_1.RefreshTokenIdsStorageService,
864
866
  axios_1.HttpService,
865
- SMTPEmailService_1.SMTPEMailService,
867
+ smtp_email_service_1.SMTPEMailService,
866
868
  Msg91OTPService_1.Msg91OTPService,
867
869
  event_emitter_1.EventEmitter2,
868
870
  setting_service_1.SettingService,