@bpinhosilva/agent-orchestrator 1.0.0-alpha.14 → 1.0.0-alpha.15

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 (79) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/app.module.js +26 -1
  3. package/dist/auth/auth.controller.js +65 -0
  4. package/dist/auth/auth.module.js +39 -0
  5. package/dist/auth/auth.service.js +106 -0
  6. package/dist/auth/decorators/public.decorator.js +7 -0
  7. package/dist/auth/dto/login.dto.js +27 -0
  8. package/dist/auth/dto/register.dto.js +33 -0
  9. package/dist/auth/guards/jwt-auth.guard.js +37 -0
  10. package/dist/auth/strategies/jwt.strategy.js +41 -0
  11. package/dist/config/env.validation.js +1 -0
  12. package/dist/scripts/seed-admin.d.ts +1 -0
  13. package/dist/scripts/seed-admin.js +40 -0
  14. package/dist/scripts/seed-admin.js.map +1 -0
  15. package/dist/src/app.module.js +26 -1
  16. package/dist/src/app.module.js.map +1 -1
  17. package/dist/src/auth/auth.controller.d.ts +20 -0
  18. package/dist/src/auth/auth.controller.js +71 -0
  19. package/dist/src/auth/auth.controller.js.map +1 -0
  20. package/dist/src/auth/auth.module.d.ts +2 -0
  21. package/dist/src/auth/auth.module.js +40 -0
  22. package/dist/src/auth/auth.module.js.map +1 -0
  23. package/dist/src/auth/auth.service.d.ts +21 -0
  24. package/dist/src/auth/auth.service.js +107 -0
  25. package/dist/src/auth/auth.service.js.map +1 -0
  26. package/dist/src/auth/decorators/public.decorator.d.ts +2 -0
  27. package/dist/src/auth/decorators/public.decorator.js +8 -0
  28. package/dist/src/auth/decorators/public.decorator.js.map +1 -0
  29. package/dist/src/auth/dto/login.dto.d.ts +4 -0
  30. package/dist/src/auth/dto/login.dto.js +34 -0
  31. package/dist/src/auth/dto/login.dto.js.map +1 -0
  32. package/dist/src/auth/dto/register.dto.d.ts +5 -0
  33. package/dist/src/auth/dto/register.dto.js +41 -0
  34. package/dist/src/auth/dto/register.dto.js.map +1 -0
  35. package/dist/src/auth/guards/jwt-auth.guard.d.ts +9 -0
  36. package/dist/src/auth/guards/jwt-auth.guard.js +39 -0
  37. package/dist/src/auth/guards/jwt-auth.guard.js.map +1 -0
  38. package/dist/src/auth/strategies/jwt.strategy.d.ts +16 -0
  39. package/dist/src/auth/strategies/jwt.strategy.js +44 -0
  40. package/dist/src/auth/strategies/jwt.strategy.js.map +1 -0
  41. package/dist/src/common/filters/http-exception.filter.d.ts +4 -0
  42. package/dist/src/common/filters/http-exception.filter.js +49 -0
  43. package/dist/src/common/filters/http-exception.filter.js.map +1 -0
  44. package/dist/src/config/env.validation.js +1 -0
  45. package/dist/src/config/env.validation.js.map +1 -1
  46. package/dist/src/main.js +3 -0
  47. package/dist/src/main.js.map +1 -1
  48. package/dist/src/tasks/dto/create-comment.dto.js +2 -1
  49. package/dist/src/tasks/dto/create-comment.dto.js.map +1 -1
  50. package/dist/src/tasks/dto/create-task.dto.js +3 -1
  51. package/dist/src/tasks/dto/create-task.dto.js.map +1 -1
  52. package/dist/src/tasks/entities/task.entity.d.ts +2 -1
  53. package/dist/src/tasks/entities/task.entity.js +1 -0
  54. package/dist/src/tasks/entities/task.entity.js.map +1 -1
  55. package/dist/src/tasks/tasks.controller.d.ts +7 -1
  56. package/dist/src/tasks/tasks.controller.js +8 -4
  57. package/dist/src/tasks/tasks.controller.js.map +1 -1
  58. package/dist/src/tasks/tasks.service.d.ts +11 -2
  59. package/dist/src/tasks/tasks.service.js +21 -3
  60. package/dist/src/tasks/tasks.service.js.map +1 -1
  61. package/dist/src/users/dto/create-user.dto.d.ts +2 -0
  62. package/dist/src/users/dto/create-user.dto.js +15 -1
  63. package/dist/src/users/dto/create-user.dto.js.map +1 -1
  64. package/dist/src/users/entities/user.entity.d.ts +2 -0
  65. package/dist/src/users/entities/user.entity.js +11 -1
  66. package/dist/src/users/entities/user.entity.js.map +1 -1
  67. package/dist/src/users/users.service.d.ts +1 -0
  68. package/dist/src/users/users.service.js +6 -0
  69. package/dist/src/users/users.service.js.map +1 -1
  70. package/dist/tasks/dto/create-comment.dto.js +1 -0
  71. package/dist/tasks/dto/create-task.dto.js +2 -0
  72. package/dist/tasks/entities/task.entity.js +1 -0
  73. package/dist/tasks/tasks.controller.js +7 -3
  74. package/dist/tasks/tasks.service.js +21 -3
  75. package/dist/tsconfig.build.tsbuildinfo +1 -1
  76. package/dist/users/dto/create-user.dto.js +12 -0
  77. package/dist/users/entities/user.entity.js +8 -0
  78. package/dist/users/users.service.js +6 -0
  79. package/package.json +11 -1
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # [1.0.0-alpha.15](https://github.com/bpinhosilva/agent-orchestrator/compare/v1.0.0-alpha.14...v1.0.0-alpha.15) (2026-03-28)
2
+
3
+
4
+ ### Features
5
+
6
+ * implement user authentication system with JWT, registration, and login functionality ([63582fa](https://github.com/bpinhosilva/agent-orchestrator/commit/63582fa8f318c8a6bc174795364a4d3cbd221d45))
7
+
1
8
  # [1.0.0-alpha.14](https://github.com/bpinhosilva/agent-orchestrator/compare/v1.0.0-alpha.13...v1.0.0-alpha.14) (2026-03-27)
2
9
 
3
10
 
@@ -24,6 +24,10 @@ const uploads_module_1 = require("./uploads/uploads.module");
24
24
  const schedule_1 = require("@nestjs/schedule");
25
25
  const config_1 = require("@nestjs/config");
26
26
  const env_validation_1 = require("./config/env.validation");
27
+ const throttler_1 = require("@nestjs/throttler");
28
+ const core_1 = require("@nestjs/core");
29
+ const auth_module_1 = require("./auth/auth.module");
30
+ const jwt_auth_guard_1 = require("./auth/guards/jwt-auth.guard");
27
31
  let AppModule = class AppModule {
28
32
  };
29
33
  exports.AppModule = AppModule;
@@ -34,6 +38,16 @@ exports.AppModule = AppModule = __decorate([
34
38
  isGlobal: true,
35
39
  validationSchema: env_validation_1.envValidationSchema,
36
40
  }),
41
+ throttler_1.ThrottlerModule.forRootAsync({
42
+ imports: [config_1.ConfigModule],
43
+ inject: [config_1.ConfigService],
44
+ useFactory: (config) => [
45
+ {
46
+ ttl: config.get('THROTTLE_TTL') || 60000,
47
+ limit: config.get('THROTTLE_LIMIT') || 60,
48
+ },
49
+ ],
50
+ }),
37
51
  schedule_1.ScheduleModule.forRoot(),
38
52
  typeorm_1.TypeOrmModule.forRootAsync({
39
53
  imports: [config_1.ConfigModule],
@@ -62,8 +76,19 @@ exports.AppModule = AppModule = __decorate([
62
76
  tasks_module_1.TasksModule,
63
77
  projects_module_1.ProjectsModule,
64
78
  users_module_1.UsersModule,
79
+ auth_module_1.AuthModule,
65
80
  ],
66
81
  controllers: [app_controller_1.AppController],
67
- providers: [app_service_1.AppService],
82
+ providers: [
83
+ app_service_1.AppService,
84
+ {
85
+ provide: core_1.APP_GUARD,
86
+ useClass: throttler_1.ThrottlerGuard,
87
+ },
88
+ {
89
+ provide: core_1.APP_GUARD,
90
+ useClass: jwt_auth_guard_1.JwtAuthGuard,
91
+ },
92
+ ],
68
93
  })
69
94
  ], AppModule);
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.AuthController = void 0;
16
+ const common_1 = require("@nestjs/common");
17
+ const auth_service_1 = require("./auth.service");
18
+ const register_dto_1 = require("./dto/register.dto");
19
+ const login_dto_1 = require("./dto/login.dto");
20
+ const public_decorator_1 = require("./decorators/public.decorator");
21
+ const swagger_1 = require("@nestjs/swagger");
22
+ let AuthController = class AuthController {
23
+ constructor(authService) {
24
+ this.authService = authService;
25
+ }
26
+ register(registerDto) {
27
+ return this.authService.register(registerDto);
28
+ }
29
+ login(loginDto) {
30
+ return this.authService.login(loginDto);
31
+ }
32
+ getMe(req) {
33
+ return req.user;
34
+ }
35
+ };
36
+ exports.AuthController = AuthController;
37
+ __decorate([
38
+ (0, public_decorator_1.Public)(),
39
+ (0, common_1.Post)('register'),
40
+ __param(0, (0, common_1.Body)()),
41
+ __metadata("design:type", Function),
42
+ __metadata("design:paramtypes", [register_dto_1.RegisterDto]),
43
+ __metadata("design:returntype", void 0)
44
+ ], AuthController.prototype, "register", null);
45
+ __decorate([
46
+ (0, public_decorator_1.Public)(),
47
+ (0, common_1.HttpCode)(common_1.HttpStatus.OK),
48
+ (0, common_1.Post)('login'),
49
+ __param(0, (0, common_1.Body)()),
50
+ __metadata("design:type", Function),
51
+ __metadata("design:paramtypes", [login_dto_1.LoginDto]),
52
+ __metadata("design:returntype", void 0)
53
+ ], AuthController.prototype, "login", null);
54
+ __decorate([
55
+ (0, common_1.Get)('me'),
56
+ __param(0, (0, common_1.Request)()),
57
+ __metadata("design:type", Function),
58
+ __metadata("design:paramtypes", [Object]),
59
+ __metadata("design:returntype", void 0)
60
+ ], AuthController.prototype, "getMe", null);
61
+ exports.AuthController = AuthController = __decorate([
62
+ (0, swagger_1.ApiTags)('auth'),
63
+ (0, common_1.Controller)('auth'),
64
+ __metadata("design:paramtypes", [auth_service_1.AuthService])
65
+ ], AuthController);
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.AuthModule = void 0;
10
+ const common_1 = require("@nestjs/common");
11
+ const auth_service_1 = require("./auth.service");
12
+ const auth_controller_1 = require("./auth.controller");
13
+ const users_module_1 = require("../users/users.module");
14
+ const passport_1 = require("@nestjs/passport");
15
+ const jwt_1 = require("@nestjs/jwt");
16
+ const config_1 = require("@nestjs/config");
17
+ const jwt_strategy_1 = require("./strategies/jwt.strategy");
18
+ let AuthModule = class AuthModule {
19
+ };
20
+ exports.AuthModule = AuthModule;
21
+ exports.AuthModule = AuthModule = __decorate([
22
+ (0, common_1.Module)({
23
+ imports: [
24
+ users_module_1.UsersModule,
25
+ passport_1.PassportModule,
26
+ jwt_1.JwtModule.registerAsync({
27
+ imports: [config_1.ConfigModule],
28
+ inject: [config_1.ConfigService],
29
+ useFactory: (configService) => ({
30
+ secret: configService.get('JWT_SECRET'),
31
+ signOptions: { expiresIn: '60m' },
32
+ }),
33
+ }),
34
+ ],
35
+ providers: [auth_service_1.AuthService, jwt_strategy_1.JwtStrategy],
36
+ controllers: [auth_controller_1.AuthController],
37
+ exports: [auth_service_1.AuthService],
38
+ })
39
+ ], AuthModule);
@@ -0,0 +1,106 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
19
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
20
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
21
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
22
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
23
+ };
24
+ var __importStar = (this && this.__importStar) || (function () {
25
+ var ownKeys = function(o) {
26
+ ownKeys = Object.getOwnPropertyNames || function (o) {
27
+ var ar = [];
28
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
29
+ return ar;
30
+ };
31
+ return ownKeys(o);
32
+ };
33
+ return function (mod) {
34
+ if (mod && mod.__esModule) return mod;
35
+ var result = {};
36
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
37
+ __setModuleDefault(result, mod);
38
+ return result;
39
+ };
40
+ })();
41
+ var __metadata = (this && this.__metadata) || function (k, v) {
42
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
43
+ };
44
+ Object.defineProperty(exports, "__esModule", { value: true });
45
+ exports.AuthService = void 0;
46
+ const common_1 = require("@nestjs/common");
47
+ const jwt_1 = require("@nestjs/jwt");
48
+ const users_service_1 = require("../users/users.service");
49
+ const bcrypt = __importStar(require("bcrypt"));
50
+ let AuthService = class AuthService {
51
+ constructor(usersService, jwtService) {
52
+ this.usersService = usersService;
53
+ this.jwtService = jwtService;
54
+ }
55
+ async validateUser(userId) {
56
+ try {
57
+ const user = await this.usersService.findOne(userId);
58
+ if (user) {
59
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
60
+ const { password, ...result } = user;
61
+ return result;
62
+ }
63
+ }
64
+ catch {
65
+ return null;
66
+ }
67
+ return null;
68
+ }
69
+ async register(registerDto) {
70
+ const existingUser = await this.usersService.findByEmail(registerDto.email);
71
+ if (existingUser) {
72
+ throw new common_1.ConflictException('Email already in use');
73
+ }
74
+ const hashedPassword = await bcrypt.hash(registerDto.password, 10);
75
+ const user = await this.usersService.create({
76
+ ...registerDto,
77
+ password: hashedPassword,
78
+ });
79
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
80
+ const { password, ...result } = user;
81
+ return result;
82
+ }
83
+ async login(loginDto) {
84
+ const user = await this.usersService.findByEmail(loginDto.email);
85
+ if (!user) {
86
+ throw new common_1.UnauthorizedException('Invalid credentials');
87
+ }
88
+ if (!user.password) {
89
+ throw new common_1.UnauthorizedException('Invalid credentials');
90
+ }
91
+ const isMatch = await bcrypt.compare(loginDto.password, user.password);
92
+ if (!isMatch) {
93
+ throw new common_1.UnauthorizedException('Invalid credentials');
94
+ }
95
+ const payload = { email: user.email, sub: user.id };
96
+ return {
97
+ access_token: this.jwtService.sign(payload),
98
+ };
99
+ }
100
+ };
101
+ exports.AuthService = AuthService;
102
+ exports.AuthService = AuthService = __decorate([
103
+ (0, common_1.Injectable)(),
104
+ __metadata("design:paramtypes", [users_service_1.UsersService,
105
+ jwt_1.JwtService])
106
+ ], AuthService);
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Public = exports.IS_PUBLIC_KEY = void 0;
4
+ const common_1 = require("@nestjs/common");
5
+ exports.IS_PUBLIC_KEY = 'isPublic';
6
+ const Public = () => (0, common_1.SetMetadata)(exports.IS_PUBLIC_KEY, true);
7
+ exports.Public = Public;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.LoginDto = void 0;
13
+ const class_validator_1 = require("class-validator");
14
+ class LoginDto {
15
+ }
16
+ exports.LoginDto = LoginDto;
17
+ __decorate([
18
+ (0, class_validator_1.IsEmail)(),
19
+ (0, class_validator_1.MaxLength)(255),
20
+ __metadata("design:type", String)
21
+ ], LoginDto.prototype, "email", void 0);
22
+ __decorate([
23
+ (0, class_validator_1.IsString)(),
24
+ (0, class_validator_1.MinLength)(8),
25
+ (0, class_validator_1.MaxLength)(72),
26
+ __metadata("design:type", String)
27
+ ], LoginDto.prototype, "password", void 0);
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.RegisterDto = void 0;
13
+ const class_validator_1 = require("class-validator");
14
+ class RegisterDto {
15
+ }
16
+ exports.RegisterDto = RegisterDto;
17
+ __decorate([
18
+ (0, class_validator_1.IsString)(),
19
+ (0, class_validator_1.IsNotEmpty)(),
20
+ (0, class_validator_1.MaxLength)(100),
21
+ __metadata("design:type", String)
22
+ ], RegisterDto.prototype, "name", void 0);
23
+ __decorate([
24
+ (0, class_validator_1.IsEmail)(),
25
+ (0, class_validator_1.MaxLength)(255),
26
+ __metadata("design:type", String)
27
+ ], RegisterDto.prototype, "email", void 0);
28
+ __decorate([
29
+ (0, class_validator_1.IsString)(),
30
+ (0, class_validator_1.MinLength)(8),
31
+ (0, class_validator_1.MaxLength)(72),
32
+ __metadata("design:type", String)
33
+ ], RegisterDto.prototype, "password", void 0);
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.JwtAuthGuard = void 0;
13
+ const common_1 = require("@nestjs/common");
14
+ const core_1 = require("@nestjs/core");
15
+ const passport_1 = require("@nestjs/passport");
16
+ const public_decorator_1 = require("../decorators/public.decorator");
17
+ let JwtAuthGuard = class JwtAuthGuard extends (0, passport_1.AuthGuard)('jwt') {
18
+ constructor(reflector) {
19
+ super();
20
+ this.reflector = reflector;
21
+ }
22
+ canActivate(context) {
23
+ const isPublic = this.reflector.getAllAndOverride(public_decorator_1.IS_PUBLIC_KEY, [
24
+ context.getHandler(),
25
+ context.getClass(),
26
+ ]);
27
+ if (isPublic) {
28
+ return true;
29
+ }
30
+ return super.canActivate(context);
31
+ }
32
+ };
33
+ exports.JwtAuthGuard = JwtAuthGuard;
34
+ exports.JwtAuthGuard = JwtAuthGuard = __decorate([
35
+ (0, common_1.Injectable)(),
36
+ __metadata("design:paramtypes", [core_1.Reflector])
37
+ ], JwtAuthGuard);
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.JwtStrategy = void 0;
13
+ const passport_jwt_1 = require("passport-jwt");
14
+ const passport_1 = require("@nestjs/passport");
15
+ const common_1 = require("@nestjs/common");
16
+ const config_1 = require("@nestjs/config");
17
+ const auth_service_1 = require("../auth.service");
18
+ let JwtStrategy = class JwtStrategy extends (0, passport_1.PassportStrategy)(passport_jwt_1.Strategy) {
19
+ constructor(configService, authService) {
20
+ super({
21
+ jwtFromRequest: passport_jwt_1.ExtractJwt.fromAuthHeaderAsBearerToken(),
22
+ ignoreExpiration: false,
23
+ secretOrKey: configService.get('JWT_SECRET'),
24
+ });
25
+ this.configService = configService;
26
+ this.authService = authService;
27
+ }
28
+ async validate(payload) {
29
+ const user = await this.authService.validateUser(payload.sub);
30
+ if (!user) {
31
+ throw new common_1.UnauthorizedException();
32
+ }
33
+ return user;
34
+ }
35
+ };
36
+ exports.JwtStrategy = JwtStrategy;
37
+ exports.JwtStrategy = JwtStrategy = __decorate([
38
+ (0, common_1.Injectable)(),
39
+ __metadata("design:paramtypes", [config_1.ConfigService,
40
+ auth_service_1.AuthService])
41
+ ], JwtStrategy);
@@ -38,6 +38,7 @@ const Joi = __importStar(require("joi"));
38
38
  exports.envValidationSchema = Joi.object({
39
39
  PORT: Joi.number().default(3000),
40
40
  DATABASE_URL: Joi.string().optional(),
41
+ JWT_SECRET: Joi.string().min(32).required(),
41
42
  GEMINI_API_KEY: Joi.string().optional(),
42
43
  ANTHROPIC_API_KEY: Joi.string().optional(),
43
44
  NODE_ENV: Joi.string()
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@nestjs/core");
4
+ const app_module_1 = require("../src/app.module");
5
+ const auth_service_1 = require("../src/auth/auth.service");
6
+ async function bootstrap() {
7
+ const password = process.argv[2];
8
+ if (!password) {
9
+ console.error('Error: Admin password must be provided as a CLI parameter.');
10
+ console.error('Usage: ts-node scripts/seed-admin.ts <password>');
11
+ process.exit(1);
12
+ }
13
+ const app = await core_1.NestFactory.createApplicationContext(app_module_1.AppModule);
14
+ const authService = app.get(auth_service_1.AuthService);
15
+ const adminData = {
16
+ name: 'Admin',
17
+ email: 'admin@agent-orchestrator.local',
18
+ password: password,
19
+ };
20
+ try {
21
+ console.log('Seeding admin user...');
22
+ await authService.register(adminData);
23
+ console.log('Admin user created successfully!');
24
+ console.log('Email: admin@agent-orchestrator.local');
25
+ console.log('Password: [HIDDEN]');
26
+ }
27
+ catch (error) {
28
+ if (error.status === 409) {
29
+ console.log('Admin user already exists.');
30
+ }
31
+ else {
32
+ console.error('Failed to seed admin user:', error.message);
33
+ }
34
+ }
35
+ finally {
36
+ await app.close();
37
+ }
38
+ }
39
+ bootstrap();
40
+ //# sourceMappingURL=seed-admin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"seed-admin.js","sourceRoot":"","sources":["../../scripts/seed-admin.ts"],"names":[],"mappings":";;AAAA,uCAA2C;AAC3C,kDAA8C;AAC9C,2DAAuD;AAEvD,KAAK,UAAU,SAAS;IACtB,MAAM,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAEjC,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO,CAAC,KAAK,CAAC,4DAA4D,CAAC,CAAC;QAC5E,OAAO,CAAC,KAAK,CAAC,iDAAiD,CAAC,CAAC;QACjE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,MAAM,GAAG,GAAG,MAAM,kBAAW,CAAC,wBAAwB,CAAC,sBAAS,CAAC,CAAC;IAClE,MAAM,WAAW,GAAG,GAAG,CAAC,GAAG,CAAC,0BAAW,CAAC,CAAC;IAEzC,MAAM,SAAS,GAAG;QAChB,IAAI,EAAE,OAAO;QACb,KAAK,EAAE,gCAAgC;QACvC,QAAQ,EAAE,QAAQ;KACnB,CAAC;IAEF,IAAI,CAAC;QACH,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;QACrC,MAAM,WAAW,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;QACtC,OAAO,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC;QAChD,OAAO,CAAC,GAAG,CAAC,uCAAuC,CAAC,CAAC;QACrD,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;IACpC,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,IAAI,KAAK,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;YACzB,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC;QAC5C,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,KAAK,CAAC,4BAA4B,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;QAC7D,CAAC;IACH,CAAC;YAAS,CAAC;QACT,MAAM,GAAG,CAAC,KAAK,EAAE,CAAC;IACpB,CAAC;AACH,CAAC;AAED,SAAS,EAAE,CAAC"}
@@ -24,6 +24,10 @@ const uploads_module_1 = require("./uploads/uploads.module");
24
24
  const schedule_1 = require("@nestjs/schedule");
25
25
  const config_1 = require("@nestjs/config");
26
26
  const env_validation_1 = require("./config/env.validation");
27
+ const throttler_1 = require("@nestjs/throttler");
28
+ const core_1 = require("@nestjs/core");
29
+ const auth_module_1 = require("./auth/auth.module");
30
+ const jwt_auth_guard_1 = require("./auth/guards/jwt-auth.guard");
27
31
  let AppModule = class AppModule {
28
32
  };
29
33
  exports.AppModule = AppModule;
@@ -34,6 +38,16 @@ exports.AppModule = AppModule = __decorate([
34
38
  isGlobal: true,
35
39
  validationSchema: env_validation_1.envValidationSchema,
36
40
  }),
41
+ throttler_1.ThrottlerModule.forRootAsync({
42
+ imports: [config_1.ConfigModule],
43
+ inject: [config_1.ConfigService],
44
+ useFactory: (config) => [
45
+ {
46
+ ttl: config.get('THROTTLE_TTL') || 60000,
47
+ limit: config.get('THROTTLE_LIMIT') || 60,
48
+ },
49
+ ],
50
+ }),
37
51
  schedule_1.ScheduleModule.forRoot(),
38
52
  typeorm_1.TypeOrmModule.forRootAsync({
39
53
  imports: [config_1.ConfigModule],
@@ -62,9 +76,20 @@ exports.AppModule = AppModule = __decorate([
62
76
  tasks_module_1.TasksModule,
63
77
  projects_module_1.ProjectsModule,
64
78
  users_module_1.UsersModule,
79
+ auth_module_1.AuthModule,
65
80
  ],
66
81
  controllers: [app_controller_1.AppController],
67
- providers: [app_service_1.AppService],
82
+ providers: [
83
+ app_service_1.AppService,
84
+ {
85
+ provide: core_1.APP_GUARD,
86
+ useClass: throttler_1.ThrottlerGuard,
87
+ },
88
+ {
89
+ provide: core_1.APP_GUARD,
90
+ useClass: jwt_auth_guard_1.JwtAuthGuard,
91
+ },
92
+ ],
68
93
  })
69
94
  ], AppModule);
70
95
  //# sourceMappingURL=app.module.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"app.module.js","sourceRoot":"","sources":["../../src/app.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,uDAAyD;AACzD,6CAAgD;AAChD,+BAA4B;AAC5B,0DAAsD;AACtD,qDAAiD;AACjD,+CAA2C;AAC3C,mEAA+D;AAC/D,0DAAsD;AACtD,uDAAmD;AACnD,gEAA4D;AAC5D,uDAAmD;AACnD,0DAAsD;AACtD,6DAAyD;AACzD,+CAAkD;AAClD,2CAA6D;AAC7D,4DAA8D;AAwCvD,IAAM,SAAS,GAAf,MAAM,SAAS;CAAG,CAAA;AAAZ,8BAAS;oBAAT,SAAS;IAtCrB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,qBAAY,CAAC,OAAO,CAAC;gBACnB,QAAQ,EAAE,IAAI;gBACd,gBAAgB,EAAE,oCAAmB;aACtC,CAAC;YACF,yBAAc,CAAC,OAAO,EAAE;YACxB,uBAAa,CAAC,YAAY,CAAC;gBACzB,OAAO,EAAE,CAAC,qBAAY,CAAC;gBACvB,MAAM,EAAE,CAAC,sBAAa,CAAC;gBACvB,UAAU,EAAE,CAAC,aAA4B,EAAE,EAAE;oBAC3C,MAAM,WAAW,GAAG,aAAa,CAAC,GAAG,CAAS,cAAc,CAAC,CAAC;oBAC9D,OAAO;wBACL,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ;wBACzC,QAAQ,EAAE,WAAW;4BACnB,CAAC,CAAC,SAAS;4BACX,CAAC,CAAC,IAAA,WAAI,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,cAAc,CAAC;wBACvC,GAAG,EAAE,WAAW;wBACh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AClB,QAAQ,EAAE,6BAAY;aACvB;SACF;KACF,CAAC;GACW,SAAS,CAAG"}
@@ -0,0 +1,20 @@
1
+ import { AuthService } from './auth.service';
2
+ import { RegisterDto } from './dto/register.dto';
3
+ import { LoginDto } from './dto/login.dto';
4
+ export declare class AuthController {
5
+ private readonly authService;
6
+ constructor(authService: AuthService);
7
+ register(registerDto: RegisterDto): Promise<{
8
+ id: string;
9
+ name: string;
10
+ email: string;
11
+ createdAt: Date;
12
+ updatedAt: Date;
13
+ }>;
14
+ login(loginDto: LoginDto): Promise<{
15
+ access_token: string;
16
+ }>;
17
+ getMe(req: {
18
+ user: unknown;
19
+ }): unknown;
20
+ }
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.AuthController = void 0;
16
+ const openapi = require("@nestjs/swagger");
17
+ const common_1 = require("@nestjs/common");
18
+ const auth_service_1 = require("./auth.service");
19
+ const register_dto_1 = require("./dto/register.dto");
20
+ const login_dto_1 = require("./dto/login.dto");
21
+ const public_decorator_1 = require("./decorators/public.decorator");
22
+ const swagger_1 = require("@nestjs/swagger");
23
+ let AuthController = class AuthController {
24
+ authService;
25
+ constructor(authService) {
26
+ this.authService = authService;
27
+ }
28
+ register(registerDto) {
29
+ return this.authService.register(registerDto);
30
+ }
31
+ login(loginDto) {
32
+ return this.authService.login(loginDto);
33
+ }
34
+ getMe(req) {
35
+ return req.user;
36
+ }
37
+ };
38
+ exports.AuthController = AuthController;
39
+ __decorate([
40
+ (0, public_decorator_1.Public)(),
41
+ (0, common_1.Post)('register'),
42
+ openapi.ApiResponse({ status: 201 }),
43
+ __param(0, (0, common_1.Body)()),
44
+ __metadata("design:type", Function),
45
+ __metadata("design:paramtypes", [register_dto_1.RegisterDto]),
46
+ __metadata("design:returntype", void 0)
47
+ ], AuthController.prototype, "register", null);
48
+ __decorate([
49
+ (0, public_decorator_1.Public)(),
50
+ (0, common_1.HttpCode)(common_1.HttpStatus.OK),
51
+ (0, common_1.Post)('login'),
52
+ openapi.ApiResponse({ status: common_1.HttpStatus.OK }),
53
+ __param(0, (0, common_1.Body)()),
54
+ __metadata("design:type", Function),
55
+ __metadata("design:paramtypes", [login_dto_1.LoginDto]),
56
+ __metadata("design:returntype", void 0)
57
+ ], AuthController.prototype, "login", null);
58
+ __decorate([
59
+ (0, common_1.Get)('me'),
60
+ openapi.ApiResponse({ status: 200, type: Object }),
61
+ __param(0, (0, common_1.Request)()),
62
+ __metadata("design:type", Function),
63
+ __metadata("design:paramtypes", [Object]),
64
+ __metadata("design:returntype", void 0)
65
+ ], AuthController.prototype, "getMe", null);
66
+ exports.AuthController = AuthController = __decorate([
67
+ (0, swagger_1.ApiTags)('auth'),
68
+ (0, common_1.Controller)('auth'),
69
+ __metadata("design:paramtypes", [auth_service_1.AuthService])
70
+ ], AuthController);
71
+ //# sourceMappingURL=auth.controller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.controller.js","sourceRoot":"","sources":["../../../src/auth/auth.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAQwB;AACxB,iDAA6C;AAC7C,qDAAiD;AACjD,+CAA2C;AAC3C,oEAAuD;AACvD,6CAA0C;AAInC,IAAM,cAAc,GAApB,MAAM,cAAc;IACI;IAA7B,YAA6B,WAAwB;QAAxB,gBAAW,GAAX,WAAW,CAAa;IAAG,CAAC;IAIzD,QAAQ,CAAS,WAAwB;QACvC,OAAO,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;IAChD,CAAC;IAKD,KAAK,CAAS,QAAkB;QAC9B,OAAO,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC1C,CAAC;IAGD,KAAK,CAAY,GAAsB;QACrC,OAAO,GAAG,CAAC,IAAI,CAAC;IAClB,CAAC;CACF,CAAA;AApBY,wCAAc;AAKzB;IAFC,IAAA,yBAAM,GAAE;IACR,IAAA,aAAI,EAAC,UAAU,CAAC;;IACP,WAAA,IAAA,aAAI,GAAE,CAAA;;qCAAc,0BAAW;;8CAExC;AAKD;IAHC,IAAA,yBAAM,GAAE;IACR,IAAA,iBAAQ,EAAC,mBAAU,CAAC,EAAE,CAAC;IACvB,IAAA,aAAI,EAAC,OAAO,CAAC;kCADJ,mBAAU,CAAC,EAAE;IAEhB,WAAA,IAAA,aAAI,GAAE,CAAA;;qCAAW,oBAAQ;;2CAE/B;AAGD;IADC,IAAA,YAAG,EAAC,IAAI,CAAC;;IACH,WAAA,IAAA,gBAAO,GAAE,CAAA;;;;2CAEf;yBAnBU,cAAc;IAF1B,IAAA,iBAAO,EAAC,MAAM,CAAC;IACf,IAAA,mBAAU,EAAC,MAAM,CAAC;qCAEyB,0BAAW;GAD1C,cAAc,CAoB1B"}
@@ -0,0 +1,2 @@
1
+ export declare class AuthModule {
2
+ }