@flusys/nestjs-auth 8.0.2 → 8.1.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.
Files changed (2) hide show
  1. package/fesm/24.js +30 -30
  2. package/package.json +3 -3
package/fesm/24.js CHANGED
@@ -845,9 +845,9 @@ __webpack_require__.d(__webpack_exports__, {
845
845
  /* import */ var _flusys_nestjs_shared__rspack_import_0 = __webpack_require__(3422);
846
846
  /* import */ var _flusys_nestjs_shared_classes__rspack_import_1 = __webpack_require__(6937);
847
847
  /* import */ var _flusys_nestjs_shared_constants__rspack_import_2 = __webpack_require__(9140);
848
- /* import */ var _nestjs_common__rspack_import_3 = __webpack_require__(6157);
849
- /* import */ var bcrypt__rspack_import_4 = __webpack_require__(7176);
850
- /* import */ var crypto__rspack_import_5 = __webpack_require__(7823);
848
+ /* import */ var _flusys_nestjs_shared_utils__rspack_import_3 = __webpack_require__(9216);
849
+ /* import */ var _nestjs_common__rspack_import_4 = __webpack_require__(6157);
850
+ /* import */ var bcrypt__rspack_import_5 = __webpack_require__(7176);
851
851
  /* import */ var _config_index_js__rspack_import_10 = __webpack_require__(5363);
852
852
  /* import */ var _config_index_js__rspack_import_12 = __webpack_require__(7987);
853
853
  /* import */ var _entities_app_user_entity_js__rspack_import_6 = __webpack_require__(4758);
@@ -904,7 +904,7 @@ class AuthEmailService {
904
904
  }
905
905
  async getRepository(entity) {
906
906
  if (!this.dataSourceProvider) {
907
- throw new _nestjs_common__rspack_import_3.InternalServerErrorException({
907
+ throw new _nestjs_common__rspack_import_4.InternalServerErrorException({
908
908
  message: `${String(entity)} repository not available`,
909
909
  messageKey: _flusys_nestjs_shared_constants__rspack_import_2.SYSTEM_MESSAGES.REPOSITORY_NOT_AVAILABLE,
910
910
  messageVariables: {
@@ -915,14 +915,14 @@ class AuthEmailService {
915
915
  return this.dataSourceProvider.getRepository(entity);
916
916
  }
917
917
  generateToken() {
918
- return crypto__rspack_import_5.randomBytes(32).toString('hex');
918
+ return (0,_flusys_nestjs_shared_utils__rspack_import_3.generateSecureToken)();
919
919
  }
920
920
  hashToken(token) {
921
- return crypto__rspack_import_5.createHash('sha256').update(token).digest('hex');
921
+ return (0,_flusys_nestjs_shared_utils__rspack_import_3.hashToken)(token);
922
922
  }
923
923
  assertEmailEnabled() {
924
924
  if (!this.emailProvider) {
925
- throw new _nestjs_common__rspack_import_3.BadRequestException({
925
+ throw new _nestjs_common__rspack_import_4.BadRequestException({
926
926
  message: 'Email service is not configured',
927
927
  messageKey: _config_index_js__rspack_import_10/* .AUTH_MESSAGES.EMAIL_NOT_CONFIGURED */.mK.EMAIL_NOT_CONFIGURED
928
928
  });
@@ -932,21 +932,21 @@ class AuthEmailService {
932
932
  try {
933
933
  await this.emailProvider.sendVerificationEmail(email, token, verifyUrl);
934
934
  } catch {
935
- throw new _nestjs_common__rspack_import_3.BadRequestException({
935
+ throw new _nestjs_common__rspack_import_4.BadRequestException({
936
936
  message: 'Failed to send verification email. Please try again.',
937
937
  messageKey: _config_index_js__rspack_import_10/* .AUTH_MESSAGES.EMAIL_SEND_FAILED */.mK.EMAIL_SEND_FAILED
938
938
  });
939
939
  }
940
940
  }
941
941
  validateTokenNotExpiredOrUsed(token, expiredMessage, expiredMessageKey, usedMessage, usedMessageKey) {
942
- if (token.expiresAt < new Date()) {
943
- throw new _nestjs_common__rspack_import_3.BadRequestException({
942
+ if ((0,_flusys_nestjs_shared_utils__rspack_import_3.isExpired)(token.expiresAt)) {
943
+ throw new _nestjs_common__rspack_import_4.BadRequestException({
944
944
  message: expiredMessage,
945
945
  messageKey: expiredMessageKey
946
946
  });
947
947
  }
948
948
  if (usedMessage && usedMessageKey && token.usedAt) {
949
- throw new _nestjs_common__rspack_import_3.BadRequestException({
949
+ throw new _nestjs_common__rspack_import_4.BadRequestException({
950
950
  message: usedMessage,
951
951
  messageKey: usedMessageKey
952
952
  });
@@ -960,7 +960,7 @@ class AuthEmailService {
960
960
  email
961
961
  }
962
962
  });
963
- return !!pending && pending.expiresAt > new Date();
963
+ return !!pending && !(0,_flusys_nestjs_shared_utils__rspack_import_3.isExpired)(pending.expiresAt);
964
964
  }
965
965
  async createPendingRegistration(data) {
966
966
  this.assertEmailEnabled();
@@ -973,7 +973,7 @@ class AuthEmailService {
973
973
  }
974
974
  });
975
975
  if (existingUser) {
976
- throw new _nestjs_common__rspack_import_3.BadRequestException({
976
+ throw new _nestjs_common__rspack_import_4.BadRequestException({
977
977
  message: 'Registration failed. Please try again or contact support.',
978
978
  messageKey: _config_index_js__rspack_import_10/* .AUTH_MESSAGES.REGISTER_FAILED */.mK.REGISTER_FAILED
979
979
  });
@@ -985,7 +985,7 @@ class AuthEmailService {
985
985
  // Create pending registration with hashed token for secure storage
986
986
  const token = this.generateToken();
987
987
  const tokenHash = this.hashToken(token);
988
- const passwordHash = await bcrypt__rspack_import_4.hash(data.password, (/* inlined export .BCRYPT_SALT_ROUNDS */12));
988
+ const passwordHash = await bcrypt__rspack_import_5.hash(data.password, (/* inlined export .BCRYPT_SALT_ROUNDS */12));
989
989
  const expiresAt = new Date(Date.now() + this.EMAIL_VERIFICATION_EXPIRY);
990
990
  const pending = pendingRepository.create({
991
991
  email: data.email,
@@ -1044,7 +1044,7 @@ class AuthEmailService {
1044
1044
  try {
1045
1045
  await this.emailProvider.sendPasswordResetEmail(email, token, resetUrl);
1046
1046
  } catch {
1047
- throw new _nestjs_common__rspack_import_3.BadRequestException({
1047
+ throw new _nestjs_common__rspack_import_4.BadRequestException({
1048
1048
  message: 'Failed to process request. Please try again later.',
1049
1049
  messageKey: _flusys_nestjs_shared_constants__rspack_import_2.SYSTEM_MESSAGES.INTERNAL_ERROR,
1050
1050
  messageVariables: {
@@ -1074,7 +1074,7 @@ class AuthEmailService {
1074
1074
  }
1075
1075
  });
1076
1076
  if (!userToken) {
1077
- throw new _nestjs_common__rspack_import_3.BadRequestException({
1077
+ throw new _nestjs_common__rspack_import_4.BadRequestException({
1078
1078
  message: 'Invalid or expired reset token',
1079
1079
  messageKey: _config_index_js__rspack_import_10/* .EMAIL_VERIFICATION_MESSAGES.VERIFICATION_TOKEN_INVALID */.sv.VERIFICATION_TOKEN_INVALID
1080
1080
  });
@@ -1086,13 +1086,13 @@ class AuthEmailService {
1086
1086
  }
1087
1087
  });
1088
1088
  if (!user) {
1089
- throw new _nestjs_common__rspack_import_3.BadRequestException({
1089
+ throw new _nestjs_common__rspack_import_4.BadRequestException({
1090
1090
  message: 'User not found',
1091
1091
  messageKey: _config_index_js__rspack_import_10/* .USER_MESSAGES.NOT_FOUND */.ny.NOT_FOUND
1092
1092
  });
1093
1093
  }
1094
1094
  // Update password
1095
- user.password = await bcrypt__rspack_import_4.hash(newPassword, (/* inlined export .BCRYPT_SALT_ROUNDS */12));
1095
+ user.password = await bcrypt__rspack_import_5.hash(newPassword, (/* inlined export .BCRYPT_SALT_ROUNDS */12));
1096
1096
  await userRepository.save(user);
1097
1097
  // Mark token as used
1098
1098
  userToken.usedAt = new Date();
@@ -1119,11 +1119,11 @@ class AuthEmailService {
1119
1119
  }
1120
1120
  });
1121
1121
  if (pending) {
1122
- if (pending.expiresAt < new Date()) {
1122
+ if ((0,_flusys_nestjs_shared_utils__rspack_import_3.isExpired)(pending.expiresAt)) {
1123
1123
  await pendingRepository.delete({
1124
1124
  id: pending.id
1125
1125
  });
1126
- throw new _nestjs_common__rspack_import_3.BadRequestException({
1126
+ throw new _nestjs_common__rspack_import_4.BadRequestException({
1127
1127
  message: 'Verification token has expired. Please register again.',
1128
1128
  messageKey: _config_index_js__rspack_import_10/* .EMAIL_VERIFICATION_MESSAGES.VERIFICATION_TOKEN_EXPIRED */.sv.VERIFICATION_TOKEN_EXPIRED
1129
1129
  });
@@ -1145,16 +1145,16 @@ class AuthEmailService {
1145
1145
  }
1146
1146
  });
1147
1147
  if (!userToken) {
1148
- throw new _nestjs_common__rspack_import_3.BadRequestException({
1148
+ throw new _nestjs_common__rspack_import_4.BadRequestException({
1149
1149
  message: 'Invalid or expired verification token',
1150
1150
  messageKey: _config_index_js__rspack_import_10/* .EMAIL_VERIFICATION_MESSAGES.VERIFICATION_TOKEN_INVALID */.sv.VERIFICATION_TOKEN_INVALID
1151
1151
  });
1152
1152
  }
1153
- if (userToken.expiresAt < new Date()) {
1153
+ if ((0,_flusys_nestjs_shared_utils__rspack_import_3.isExpired)(userToken.expiresAt)) {
1154
1154
  await tokenRepository.delete({
1155
1155
  id: userToken.id
1156
1156
  });
1157
- throw new _nestjs_common__rspack_import_3.BadRequestException({
1157
+ throw new _nestjs_common__rspack_import_4.BadRequestException({
1158
1158
  message: 'Verification token has expired. Please request a new one.',
1159
1159
  messageKey: _config_index_js__rspack_import_10/* .EMAIL_VERIFICATION_MESSAGES.VERIFICATION_TOKEN_EXPIRED */.sv.VERIFICATION_TOKEN_EXPIRED
1160
1160
  });
@@ -1172,7 +1172,7 @@ class AuthEmailService {
1172
1172
  }
1173
1173
  });
1174
1174
  if (!user) {
1175
- throw new _nestjs_common__rspack_import_3.BadRequestException({
1175
+ throw new _nestjs_common__rspack_import_4.BadRequestException({
1176
1176
  message: 'User not found',
1177
1177
  messageKey: _config_index_js__rspack_import_10/* .USER_MESSAGES.NOT_FOUND */.ny.NOT_FOUND
1178
1178
  });
@@ -1324,13 +1324,13 @@ _ts_decorate([
1324
1324
  _ts_metadata("design:returntype", Promise)
1325
1325
  ], AuthEmailService.prototype, "resendVerificationEmail", null);
1326
1326
  AuthEmailService = _ts_decorate([
1327
- (0,_nestjs_common__rspack_import_3.Injectable)({
1328
- scope: _nestjs_common__rspack_import_3.Scope.REQUEST
1327
+ (0,_nestjs_common__rspack_import_4.Injectable)({
1328
+ scope: _nestjs_common__rspack_import_4.Scope.REQUEST
1329
1329
  }),
1330
- _ts_param(0, (0,_nestjs_common__rspack_import_3.Optional)()),
1331
- _ts_param(0, (0,_nestjs_common__rspack_import_3.Inject)(_auth_datasource_provider_js__rspack_import_9/* .AuthDataSourceProvider */.v)),
1332
- _ts_param(1, (0,_nestjs_common__rspack_import_3.Optional)()),
1333
- _ts_param(1, (0,_nestjs_common__rspack_import_3.Inject)(_interfaces_index_js__rspack_import_13/* .AUTH_EMAIL_PROVIDER */.C)),
1330
+ _ts_param(0, (0,_nestjs_common__rspack_import_4.Optional)()),
1331
+ _ts_param(0, (0,_nestjs_common__rspack_import_4.Inject)(_auth_datasource_provider_js__rspack_import_9/* .AuthDataSourceProvider */.v)),
1332
+ _ts_param(1, (0,_nestjs_common__rspack_import_4.Optional)()),
1333
+ _ts_param(1, (0,_nestjs_common__rspack_import_4.Inject)(_interfaces_index_js__rspack_import_13/* .AUTH_EMAIL_PROVIDER */.C)),
1334
1334
  _ts_metadata("design:type", Function),
1335
1335
  _ts_metadata("design:paramtypes", [
1336
1336
  typeof _auth_datasource_provider_js__rspack_import_9/* .AuthDataSourceProvider */.v === "undefined" ? Object : _auth_datasource_provider_js__rspack_import_9/* .AuthDataSourceProvider */.v,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flusys/nestjs-auth",
3
- "version": "8.0.2",
3
+ "version": "8.1.0",
4
4
  "description": "Authentication and authorization infrastructure for NestJS applications",
5
5
  "type": "module",
6
6
  "main": "./fesm/index.js",
@@ -91,7 +91,7 @@
91
91
  "rxjs": "^7.8.0"
92
92
  },
93
93
  "dependencies": {
94
- "@flusys/nestjs-core": "8.0.2",
95
- "@flusys/nestjs-shared": "8.0.2"
94
+ "@flusys/nestjs-core": "8.1.0",
95
+ "@flusys/nestjs-shared": "8.1.0"
96
96
  }
97
97
  }