@flusys/nestjs-auth 4.1.1 → 5.0.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.
Files changed (51) hide show
  1. package/README.md +151 -719
  2. package/cjs/config/message-keys.js +6 -61
  3. package/cjs/controllers/authentication.controller.js +113 -87
  4. package/cjs/controllers/company-selection.controller.js +24 -4
  5. package/cjs/controllers/email-verification.controller.js +12 -13
  6. package/cjs/docs/auth-swagger.config.js +143 -106
  7. package/cjs/dtos/authentication.dto.js +0 -15
  8. package/cjs/entities/company-branch.entity.js +1 -1
  9. package/cjs/entities/company.entity.js +2 -2
  10. package/cjs/entities/pending-registration.entity.js +3 -2
  11. package/cjs/entities/user-company-permission.entity.js +0 -8
  12. package/cjs/entities/user-token.entity.js +0 -9
  13. package/cjs/interceptors/set-token.interceptor.js +15 -7
  14. package/cjs/services/auth-config.service.js +0 -4
  15. package/cjs/services/auth-email.service.js +8 -31
  16. package/cjs/services/authentication.service.js +99 -15
  17. package/cjs/services/user-permission.service.js +6 -8
  18. package/cjs/services/user.service.js +16 -13
  19. package/cjs/strategies/jwt.strategy.js +10 -3
  20. package/config/message-keys.d.ts +5 -153
  21. package/controllers/authentication.controller.d.ts +6 -7
  22. package/controllers/company-selection.controller.d.ts +3 -2
  23. package/controllers/email-verification.controller.d.ts +6 -2
  24. package/dtos/authentication.dto.d.ts +0 -2
  25. package/entities/user-company-permission.entity.d.ts +0 -1
  26. package/entities/user-token.entity.d.ts +0 -1
  27. package/fesm/config/message-keys.js +6 -53
  28. package/fesm/controllers/authentication.controller.js +115 -90
  29. package/fesm/controllers/company-selection.controller.js +25 -5
  30. package/fesm/controllers/email-verification.controller.js +13 -14
  31. package/fesm/docs/auth-swagger.config.js +146 -113
  32. package/fesm/dtos/authentication.dto.js +0 -15
  33. package/fesm/entities/company-branch.entity.js +2 -2
  34. package/fesm/entities/company.entity.js +3 -3
  35. package/fesm/entities/pending-registration.entity.js +3 -2
  36. package/fesm/entities/user-company-permission.entity.js +0 -8
  37. package/fesm/entities/user-token.entity.js +0 -9
  38. package/fesm/interceptors/set-token.interceptor.js +15 -7
  39. package/fesm/services/auth-config.service.js +0 -4
  40. package/fesm/services/auth-email.service.js +8 -32
  41. package/fesm/services/authentication.service.js +100 -17
  42. package/fesm/services/user-permission.service.js +6 -8
  43. package/fesm/services/user.service.js +16 -14
  44. package/fesm/strategies/jwt.strategy.js +10 -3
  45. package/interfaces/auth-module-options.interface.d.ts +0 -1
  46. package/package.json +4 -4
  47. package/services/auth-config.service.d.ts +0 -1
  48. package/services/auth-email.service.d.ts +0 -4
  49. package/services/authentication.service.d.ts +1 -1
  50. package/services/user-permission.service.d.ts +1 -1
  51. package/services/user.service.d.ts +5 -5
@@ -8,36 +8,17 @@ Object.defineProperty(exports, "authSwaggerConfig", {
8
8
  return authSwaggerConfig;
9
9
  }
10
10
  });
11
- /** Tags used for company-related APIs (excluded when company feature is disabled) */ const COMPANY_RELATED_TAGS = [
11
+ // ============================================================================
12
+ // Company feature exclusions
13
+ // ============================================================================
14
+ const COMPANY_RELATED_TAGS = [
12
15
  'Companies',
13
16
  'Branches',
14
17
  'User Permissions',
15
18
  'Company Selection'
16
19
  ];
17
- /** Examples to exclude when company feature is disabled */ const COMPANY_EXAMPLE_EXCLUSIONS = [
18
- {
19
- pathPattern: '/auth/login',
20
- method: 'post',
21
- examples: [
22
- 'loginSuccessWithCompany',
23
- 'companySelection'
24
- ]
25
- }
26
- ];
27
- /**
28
- * Schema properties to exclude when company feature is disabled
29
- *
30
- * This list controls which DTO properties are hidden from Swagger documentation
31
- * when bootstrapConfig.enableCompanyFeature = false
32
- *
33
- * **Documentation:**
34
- * - Usage: See FLUSYS_NEST/docs/AUTH-GUIDE.md "Swagger Schema Behavior" section
35
- * - Mechanism: See FLUSYS_NEST/docs/CORE-GUIDE.md "excludeSchemaProperties" section
36
- *
37
- * @see setupSwaggerDocs in @flusys/nestjs-core/docs
38
- * @see ISchemaPropertyExclusion interface
39
- */ const COMPANY_SCHEMA_EXCLUSIONS = [
40
- // ===== Authentication Request DTOs =====
20
+ const COMPANY_SCHEMA_EXCLUSIONS = [
21
+ // Request DTOs
41
22
  {
42
23
  schemaName: 'RegistrationDto',
43
24
  properties: [
@@ -63,7 +44,7 @@ Object.defineProperty(exports, "authSwaggerConfig", {
63
44
  'branchId'
64
45
  ]
65
46
  },
66
- // ===== Authentication Response DTOs =====
47
+ // Response DTOs
67
48
  {
68
49
  schemaName: 'RegistrationResponseDto',
69
50
  properties: [
@@ -85,7 +66,7 @@ Object.defineProperty(exports, "authSwaggerConfig", {
85
66
  'branch'
86
67
  ]
87
68
  },
88
- // ===== Nested/Helper DTOs (completely excluded) =====
69
+ // Nested helper DTOs
89
70
  {
90
71
  schemaName: 'CompanyInfoDto',
91
72
  properties: [
@@ -133,7 +114,7 @@ Object.defineProperty(exports, "authSwaggerConfig", {
133
114
  'companies'
134
115
  ]
135
116
  },
136
- // ===== Company Management DTOs =====
117
+ // Company management DTOs
137
118
  {
138
119
  schemaName: 'CreateCompanyDto',
139
120
  properties: [
@@ -187,7 +168,7 @@ Object.defineProperty(exports, "authSwaggerConfig", {
187
168
  'updatedAt'
188
169
  ]
189
170
  },
190
- // ===== Branch Management DTOs =====
171
+ // Branch management DTOs
191
172
  {
192
173
  schemaName: 'CreateCompanyBranchDto',
193
174
  properties: [
@@ -241,7 +222,7 @@ Object.defineProperty(exports, "authSwaggerConfig", {
241
222
  'updatedAt'
242
223
  ]
243
224
  },
244
- // ===== User Permission DTOs =====
225
+ // User permission DTOs
245
226
  {
246
227
  schemaName: 'UserCompanyPermissionDto',
247
228
  properties: [
@@ -297,120 +278,176 @@ Object.defineProperty(exports, "authSwaggerConfig", {
297
278
  ]
298
279
  }
299
280
  ];
300
- function authSwaggerConfig(bootstrapConfig) {
301
- const enableCompanyFeature = bootstrapConfig?.enableCompanyFeature ?? true;
302
- // Exclude company-related tags when company feature is disabled
303
- const excludeTags = enableCompanyFeature ? [] : COMPANY_RELATED_TAGS;
304
- return {
305
- title: 'Auth API',
306
- description: enableCompanyFeature ? `
307
- ## Authentication API
308
-
309
- Handles user authentication, registration, and company/branch management.
310
-
311
- ### Features
312
- - User registration (with optional company assignment)
313
- - Login with email/password
314
- - JWT token-based authentication
315
- - Company/Branch selection flow (when multi-company enabled)
316
- - Token refresh
317
- - Password change
318
-
281
+ const COMPANY_EXAMPLE_EXCLUSIONS = [
282
+ {
283
+ pathPattern: '/auth/login',
284
+ method: 'post',
285
+ examples: [
286
+ 'loginSuccessWithCompany',
287
+ 'companySelection'
288
+ ]
289
+ }
290
+ ];
291
+ // ============================================================================
292
+ // Email verification exclusions
293
+ // ============================================================================
294
+ const EMAIL_VERIFICATION_PATHS = [
295
+ '/auth/forgot-password',
296
+ '/auth/reset-password',
297
+ '/auth/resend-verification',
298
+ '/auth/verify-email'
299
+ ];
300
+ const EMAIL_VERIFICATION_SCHEMA_EXCLUSIONS = [
301
+ {
302
+ schemaName: 'RegistrationResponseDto',
303
+ properties: [
304
+ 'requiresEmailVerification'
305
+ ]
306
+ },
307
+ {
308
+ schemaName: 'LoginResponseRequiresEmailVerificationDto',
309
+ properties: [
310
+ 'requiresEmailVerification',
311
+ 'email'
312
+ ]
313
+ }
314
+ ];
315
+ const EMAIL_VERIFICATION_EXAMPLE_EXCLUSIONS = [
316
+ {
317
+ pathPattern: '/auth/login',
318
+ method: 'post',
319
+ examples: [
320
+ 'emailVerification'
321
+ ]
322
+ }
323
+ ];
324
+ // ============================================================================
325
+ // Description builder
326
+ // ============================================================================
327
+ function buildDescription(enableCompanyFeature, enableEmailVerification, isMultiTenant) {
328
+ const multiTenantNote = isMultiTenant ? `\n> **Multi-Tenant Mode**: Include \`x-tenant-id\` header to target a specific tenant database.\n` : '';
329
+ const features = [
330
+ '- User registration',
331
+ '- Login with email/password',
332
+ '- JWT token-based authentication',
333
+ ...enableEmailVerification ? [
334
+ '- Email verification',
335
+ '- Forgot/reset password'
336
+ ] : [],
337
+ ...enableCompanyFeature ? [
338
+ '- Company/Branch selection flow (multi-company enabled)'
339
+ ] : [],
340
+ '- Token refresh',
341
+ '- Password change'
342
+ ].join('\n');
343
+ const loginFlowSection = enableCompanyFeature ? `
319
344
  ### Authentication Flow
320
345
 
321
- #### Simple Login (Company feature disabled)
322
- \`\`\`
323
- POST /auth/login → { accessToken, refreshToken, user }
324
- \`\`\`
325
-
326
- #### Company-Based Login (Company feature enabled)
327
-
328
- **Case 1: Single company, single branch**
346
+ #### Simple Login (single company/branch)
329
347
  \`\`\`
330
348
  POST /auth/login → { accessToken, refreshToken, user, company, branch }
331
349
  \`\`\`
332
350
 
333
- **Case 2: Multiple companies or branches**
351
+ #### Multi-Company Login (multiple companies or branches)
334
352
  \`\`\`
335
353
  POST /auth/login → { requiresSelection: true, sessionId, companies }
336
354
  POST /auth/select → { accessToken, refreshToken, user, company, branch }
337
355
  \`\`\`
338
-
356
+ ${enableEmailVerification ? `
357
+ #### Email Verification Required
358
+ \`\`\`
359
+ POST /auth/login → { requiresEmailVerification: true, email }
360
+ POST /auth/verify-email → { accessToken, refreshToken, user }
361
+ \`\`\`
362
+ ` : ''}
339
363
  ### Company/Branch Selection Endpoints
340
364
  - \`POST /auth/select\` - Complete login by selecting company and branch
341
365
  - \`POST /auth/switch-company\` - Switch to different company/branch while logged in
342
- - \`GET /auth/companies\` - Get user's available companies
343
- - \`GET /auth/companies/:companyId/branches\` - Get branches for a company
344
-
366
+ ` : `
367
+ ### Authentication Flow
368
+ \`\`\`
369
+ POST /auth/login → { accessToken, refreshToken, user }
370
+ \`\`\`
371
+ ${enableEmailVerification ? `
372
+ #### Email Verification Required
373
+ \`\`\`
374
+ POST /auth/login → { requiresEmailVerification: true, email }
375
+ POST /auth/verify-email → { accessToken, refreshToken, user }
376
+ \`\`\`
377
+ ` : ''}`;
378
+ const emailVerificationSection = enableEmailVerification ? `
379
+ ### Email Verification Endpoints
380
+ - \`POST /auth/forgot-password\` - Request password reset email
381
+ - \`POST /auth/reset-password\` - Reset password using token
382
+ - \`POST /auth/resend-verification\` - Resend verification email
383
+ - \`POST /auth/verify-email\` - Verify email using token
384
+ ` : '';
385
+ const administrationSection = enableCompanyFeature ? `
345
386
  ### Administration Endpoints
346
387
  - \`POST /administration/users/*\` - User management
347
388
  - \`POST /administration/company/*\` - Company management
348
389
  - \`POST /administration/branch/*\` - Branch management
349
390
  - \`POST /administration/user-permissions/*\` - User permission management
350
-
391
+ ` : `
392
+ ### Administration Endpoints
393
+ - \`POST /administration/users/*\` - User management
394
+ `;
395
+ const registrationSection = enableCompanyFeature ? `
351
396
  ### Registration Flow
352
397
 
353
398
  **Simple registration:**
354
399
  \`\`\`json
355
- {
356
- "name": "John Doe",
357
- "email": "john@example.com",
358
- "password": "password123"
359
- }
400
+ { "name": "John Doe", "email": "john@example.com", "password": "password123" }
360
401
  \`\`\`
361
402
 
362
403
  **Join existing company:**
363
404
  \`\`\`json
364
- {
365
- "name": "John Doe",
366
- "email": "john@example.com",
367
- "password": "password123",
368
- "companySlug": "acme-corp",
369
- "branchSlug": "main-branch"
370
- }
405
+ { "name": "John Doe", "email": "john@example.com", "password": "password123", "companySlug": "acme-corp", "branchSlug": "main-branch" }
371
406
  \`\`\`
372
407
 
373
408
  **Create new company:**
374
409
  \`\`\`json
375
- {
376
- "name": "John Doe",
377
- "email": "john@example.com",
378
- "password": "password123",
379
- "newCompanyName": "My New Company",
380
- "newCompanyPhone": "+1234567890"
381
- }
410
+ { "name": "John Doe", "email": "john@example.com", "password": "password123", "newCompanyName": "My New Company" }
411
+ \`\`\`
412
+ ` : `
413
+ ### Registration Flow
414
+ \`\`\`json
415
+ { "name": "John Doe", "email": "john@example.com", "password": "password123" }
382
416
  \`\`\`
383
- ` : `
417
+ `;
418
+ return `
384
419
  ## Authentication API
385
-
386
- Handles user authentication and registration.
420
+ ${multiTenantNote}
421
+ Handles user authentication${enableCompanyFeature ? ', company/branch management' : ''}, and registration.
387
422
 
388
423
  ### Features
389
- - User registration
390
- - Login with email/password
391
- - JWT token-based authentication
392
- - Token refresh
393
- - Password change
394
-
395
- ### Authentication Flow
396
- \`\`\`
397
- POST /auth/login → { accessToken, refreshToken, user }
398
- \`\`\`
399
-
400
- ### Registration Flow
401
- \`\`\`json
402
- {
403
- "name": "John Doe",
404
- "email": "john@example.com",
405
- "password": "password123"
424
+ ${features}
425
+ ${loginFlowSection}${emailVerificationSection}${administrationSection}${registrationSection}`;
406
426
  }
407
- \`\`\`
408
- `,
427
+ function authSwaggerConfig(bootstrapConfig) {
428
+ const enableCompanyFeature = bootstrapConfig?.enableCompanyFeature ?? true;
429
+ const enableEmailVerification = bootstrapConfig?.enableEmailVerification ?? true;
430
+ const isMultiTenant = bootstrapConfig?.databaseMode === 'multi-tenant';
431
+ const excludeTags = enableCompanyFeature ? [] : COMPANY_RELATED_TAGS;
432
+ const excludeSchemaProperties = [
433
+ ...enableCompanyFeature ? [] : COMPANY_SCHEMA_EXCLUSIONS,
434
+ ...enableEmailVerification ? [] : EMAIL_VERIFICATION_SCHEMA_EXCLUSIONS
435
+ ];
436
+ // Merge example exclusions — both may target /auth/login with different example names
437
+ const excludeExamples = [
438
+ ...enableCompanyFeature ? [] : COMPANY_EXAMPLE_EXCLUSIONS,
439
+ ...enableEmailVerification ? [] : EMAIL_VERIFICATION_EXAMPLE_EXCLUSIONS
440
+ ];
441
+ const excludePaths = enableEmailVerification ? undefined : EMAIL_VERIFICATION_PATHS;
442
+ return {
443
+ title: 'Auth API',
444
+ description: buildDescription(enableCompanyFeature, enableEmailVerification, isMultiTenant),
409
445
  version: '1.0',
410
446
  path: 'api/docs/auth',
411
447
  bearerAuth: true,
412
448
  excludeTags,
413
- excludeSchemaProperties: enableCompanyFeature ? undefined : COMPANY_SCHEMA_EXCLUSIONS,
414
- excludeExamples: enableCompanyFeature ? undefined : COMPANY_EXAMPLE_EXCLUSIONS
449
+ excludeSchemaProperties: excludeSchemaProperties.length ? excludeSchemaProperties : undefined,
450
+ excludeExamples: excludeExamples.length ? excludeExamples : undefined,
451
+ excludePaths
415
452
  };
416
453
  }
@@ -684,8 +684,6 @@ let LoginResponseRequiresEmailVerificationDto = class LoginResponseRequiresEmail
684
684
  constructor(){
685
685
  _define_property(this, "requiresEmailVerification", void 0);
686
686
  _define_property(this, "email", void 0);
687
- _define_property(this, "message", void 0);
688
- _define_property(this, "messageKey", void 0);
689
687
  }
690
688
  };
691
689
  _ts_decorate([
@@ -700,19 +698,6 @@ _ts_decorate([
700
698
  }),
701
699
  _ts_metadata("design:type", String)
702
700
  ], LoginResponseRequiresEmailVerificationDto.prototype, "email", void 0);
703
- _ts_decorate([
704
- (0, _swagger.ApiProperty)({
705
- example: 'Please verify your email address before logging in.'
706
- }),
707
- _ts_metadata("design:type", String)
708
- ], LoginResponseRequiresEmailVerificationDto.prototype, "message", void 0);
709
- _ts_decorate([
710
- (0, _swagger.ApiProperty)({
711
- example: 'auth.login.email.not.verified',
712
- description: 'Translation key for localization'
713
- }),
714
- _ts_metadata("design:type", String)
715
- ], LoginResponseRequiresEmailVerificationDto.prototype, "messageKey", void 0);
716
701
  let ForgotPasswordDto = class ForgotPasswordDto {
717
702
  constructor(){
718
703
  _define_property(this, "email", void 0);
@@ -109,7 +109,7 @@ _ts_decorate([
109
109
  ], CompanyBranch.prototype, "isActive", void 0);
110
110
  _ts_decorate([
111
111
  (0, _typeorm.Column)({
112
- type: 'json',
112
+ type: (0, _nestjsshared.getJsonColumnType)(),
113
113
  nullable: true
114
114
  }),
115
115
  _ts_metadata("design:type", Object)
@@ -123,14 +123,14 @@ _ts_decorate([
123
123
  ], Company.prototype, "isActive", void 0);
124
124
  _ts_decorate([
125
125
  (0, _typeorm.Column)({
126
- type: 'json',
126
+ type: (0, _nestjsshared.getJsonColumnType)(),
127
127
  nullable: true
128
128
  }),
129
129
  _ts_metadata("design:type", Object)
130
130
  ], Company.prototype, "settings", void 0);
131
131
  _ts_decorate([
132
132
  (0, _typeorm.Column)({
133
- type: 'json',
133
+ type: (0, _nestjsshared.getJsonColumnType)(),
134
134
  nullable: true
135
135
  }),
136
136
  _ts_metadata("design:type", Object)
@@ -8,6 +8,7 @@ Object.defineProperty(exports, "PendingRegistration", {
8
8
  return PendingRegistration;
9
9
  }
10
10
  });
11
+ const _nestjsshared = require("@flusys/nestjs-shared");
11
12
  const _typeorm = require("typeorm");
12
13
  function _define_property(obj, key, value) {
13
14
  if (key in obj) {
@@ -95,7 +96,7 @@ _ts_decorate([
95
96
  ], PendingRegistration.prototype, "expiresAt", void 0);
96
97
  _ts_decorate([
97
98
  (0, _typeorm.Column)({
98
- type: 'json',
99
+ type: (0, _nestjsshared.getJsonColumnType)(),
99
100
  nullable: true,
100
101
  name: 'company_data'
101
102
  }),
@@ -103,7 +104,7 @@ _ts_decorate([
103
104
  ], PendingRegistration.prototype, "companyData", void 0);
104
105
  _ts_decorate([
105
106
  (0, _typeorm.Column)({
106
- type: 'json',
107
+ type: (0, _nestjsshared.getJsonColumnType)(),
107
108
  nullable: true,
108
109
  name: 'additional_fields'
109
110
  }),
@@ -50,7 +50,6 @@ let UserCompanyPermission = class UserCompanyPermission {
50
50
  _define_property(this, "user", void 0);
51
51
  /* ---------- Polymorphic Target ---------- */ _define_property(this, "permissionType", void 0);
52
52
  _define_property(this, "targetId", void 0);
53
- _define_property(this, "metadata", void 0);
54
53
  _define_property(this, "isActive", void 0);
55
54
  /* ---------- Optional Relations (no FK - polymorphic) ---------- */ _define_property(this, "company", void 0);
56
55
  _define_property(this, "branch", void 0);
@@ -93,13 +92,6 @@ _ts_decorate([
93
92
  }),
94
93
  _ts_metadata("design:type", String)
95
94
  ], UserCompanyPermission.prototype, "targetId", void 0);
96
- _ts_decorate([
97
- (0, _typeorm.Column)({
98
- type: 'json',
99
- nullable: true
100
- }),
101
- _ts_metadata("design:type", typeof Record === "undefined" ? Object : Record)
102
- ], UserCompanyPermission.prototype, "metadata", void 0);
103
95
  _ts_decorate([
104
96
  (0, _typeorm.Column)({
105
97
  type: 'boolean',
@@ -53,7 +53,6 @@ let UserToken = class UserToken {
53
53
  _define_property(this, "token", void 0);
54
54
  _define_property(this, "expiresAt", void 0);
55
55
  _define_property(this, "usedAt", void 0);
56
- _define_property(this, "metadata", void 0);
57
56
  _define_property(this, "createdAt", void 0);
58
57
  }
59
58
  };
@@ -97,14 +96,6 @@ _ts_decorate([
97
96
  }),
98
97
  _ts_metadata("design:type", Object)
99
98
  ], UserToken.prototype, "usedAt", void 0);
100
- _ts_decorate([
101
- (0, _typeorm.Column)({
102
- type: 'varchar',
103
- length: 255,
104
- nullable: true
105
- }),
106
- _ts_metadata("design:type", Object)
107
- ], UserToken.prototype, "metadata", void 0);
108
99
  _ts_decorate([
109
100
  (0, _typeorm.CreateDateColumn)({
110
101
  type: 'timestamp',
@@ -52,16 +52,24 @@ let SetToken = class SetToken {
52
52
  const req = context.switchToHttp().getRequest();
53
53
  const res = context.switchToHttp().getResponse();
54
54
  return next.handle().pipe((0, _rxjs.map)((value)=>{
55
- if (typeof value !== 'object' || value === null || !('refreshToken' in value)) {
55
+ if (typeof value !== 'object' || value === null) {
56
56
  return value;
57
57
  }
58
58
  const response = value;
59
- if ((0, _utils.isBrowserRequest)(req)) {
60
- this.setRefreshTokenCookie(req, res, String(response.refreshToken));
61
- const { refreshToken, ...responseWithoutToken } = response;
62
- return responseWithoutToken;
59
+ const data = typeof response['data'] === 'object' && response['data'] !== null ? response['data'] : null;
60
+ const tokenInData = data && typeof data['refreshToken'] === 'string';
61
+ if (!tokenInData) {
62
+ return value;
63
+ }
64
+ if (!(0, _utils.isBrowserRequest)(req)) {
65
+ return value;
63
66
  }
64
- return value;
67
+ this.setRefreshTokenCookie(req, res, data['refreshToken']);
68
+ const { refreshToken: _, ...dataWithoutToken } = data;
69
+ return {
70
+ ...response,
71
+ data: dataWithoutToken
72
+ };
65
73
  }), (0, _rxjs.catchError)((err)=>(0, _rxjs.throwError)(()=>err)));
66
74
  }
67
75
  setRefreshTokenCookie(req, res, tokenValue) {
@@ -71,7 +79,7 @@ let SetToken = class SetToken {
71
79
  throw new _common.PayloadTooLargeException({
72
80
  message: `Refresh token too large (≈${estimatedBytes} bytes)`,
73
81
  messageKey: _config.AUTH_MESSAGES.TOKEN_TOO_LARGE,
74
- messageParams: {
82
+ messageVariables: {
75
83
  size: estimatedBytes
76
84
  }
77
85
  });
@@ -86,10 +86,6 @@ let AuthConfigService = class AuthConfigService {
86
86
  getRefreshTokenCookieName() {
87
87
  return this.config.refreshTokenCookieName ?? 'fsn_refresh_token';
88
88
  }
89
- // Frontend Configuration
90
- getFrontendUrl() {
91
- return this.config.frontendUrl;
92
- }
93
89
  constructor(injectedOptions){
94
90
  _define_property(this, "options", void 0);
95
91
  _define_property(this, "config", void 0);
@@ -8,13 +8,12 @@ Object.defineProperty(exports, "AuthEmailService", {
8
8
  return AuthEmailService;
9
9
  }
10
10
  });
11
- const _constants = require("@flusys/nestjs-shared/constants");
12
11
  const _nestjsshared = require("@flusys/nestjs-shared");
13
- const _config = require("../config");
12
+ const _constants = require("@flusys/nestjs-shared/constants");
14
13
  const _common = require("@nestjs/common");
15
14
  const _bcrypt = /*#__PURE__*/ _interop_require_wildcard(require("bcrypt"));
16
15
  const _crypto = /*#__PURE__*/ _interop_require_wildcard(require("crypto"));
17
- const _typeorm = require("typeorm");
16
+ const _config = require("../config");
18
17
  const _pendingregistrationentity = require("../entities/pending-registration.entity");
19
18
  const _usertokenentity = require("../entities/user-token.entity");
20
19
  const _userentity = require("../entities/user.entity");
@@ -97,7 +96,7 @@ let AuthEmailService = class AuthEmailService {
97
96
  throw new _common.InternalServerErrorException({
98
97
  message: `${String(entity)} repository not available`,
99
98
  messageKey: _constants.SYSTEM_MESSAGES.REPOSITORY_NOT_AVAILABLE,
100
- messageParams: {
99
+ messageVariables: {
101
100
  entity: String(entity)
102
101
  }
103
102
  });
@@ -236,7 +235,11 @@ let AuthEmailService = class AuthEmailService {
236
235
  } catch {
237
236
  throw new _common.BadRequestException({
238
237
  message: 'Failed to process request. Please try again later.',
239
- messageKey: _constants.SYSTEM_MESSAGES.INTERNAL_ERROR
238
+ messageKey: _constants.SYSTEM_MESSAGES.INTERNAL_ERROR,
239
+ messageVariables: {
240
+ provider: 'EmailProvider',
241
+ error: 'Send email failed'
242
+ }
240
243
  });
241
244
  }
242
245
  return {
@@ -427,23 +430,6 @@ let AuthEmailService = class AuthEmailService {
427
430
  messageKey: _config.EMAIL_VERIFICATION_MESSAGES.RESEND_SUCCESS
428
431
  };
429
432
  }
430
- async cleanupExpired() {
431
- const tokenRepository = await this.getRepository(_usertokenentity.UserToken);
432
- const pendingRepository = await this.getRepository(_pendingregistrationentity.PendingRegistration);
433
- const now = new Date();
434
- const tokenResult = await tokenRepository.delete({
435
- expiresAt: (0, _typeorm.LessThan)(now)
436
- });
437
- const pendingResult = await pendingRepository.delete({
438
- expiresAt: (0, _typeorm.LessThan)(now)
439
- });
440
- const deletedTokens = tokenResult.affected ?? 0;
441
- const deletedPending = pendingResult.affected ?? 0;
442
- return {
443
- deletedTokens,
444
- deletedPending
445
- };
446
- }
447
433
  constructor(dataSourceProvider, emailProvider){
448
434
  _define_property(this, "dataSourceProvider", void 0);
449
435
  _define_property(this, "emailProvider", void 0);
@@ -516,15 +502,6 @@ _ts_decorate([
516
502
  ]),
517
503
  _ts_metadata("design:returntype", Promise)
518
504
  ], AuthEmailService.prototype, "resendVerificationEmail", null);
519
- _ts_decorate([
520
- (0, _nestjsshared.LogAction)({
521
- action: 'auth.cleanupExpiredTokens',
522
- module: 'auth'
523
- }),
524
- _ts_metadata("design:type", Function),
525
- _ts_metadata("design:paramtypes", []),
526
- _ts_metadata("design:returntype", Promise)
527
- ], AuthEmailService.prototype, "cleanupExpired", null);
528
505
  AuthEmailService = _ts_decorate([
529
506
  (0, _common.Injectable)({
530
507
  scope: _common.Scope.REQUEST