@j3r3mcdev/auth-service 1.0.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 (52) hide show
  1. package/dist/auth/auth.controller.d.ts +60 -0
  2. package/dist/auth/auth.controller.d.ts.map +1 -0
  3. package/dist/auth/auth.controller.js +128 -0
  4. package/dist/auth/auth.module.d.ts +3 -0
  5. package/dist/auth/auth.module.d.ts.map +1 -0
  6. package/dist/auth/auth.module.js +44 -0
  7. package/dist/auth/auth.repository.d.ts +119 -0
  8. package/dist/auth/auth.repository.d.ts.map +1 -0
  9. package/dist/auth/auth.repository.js +108 -0
  10. package/dist/auth/auth.service.d.ts +61 -0
  11. package/dist/auth/auth.service.d.ts.map +1 -0
  12. package/dist/auth/auth.service.js +287 -0
  13. package/dist/auth/dto/forgot-password.dto.d.ts +4 -0
  14. package/dist/auth/dto/forgot-password.dto.d.ts.map +1 -0
  15. package/dist/auth/dto/forgot-password.dto.js +21 -0
  16. package/dist/auth/dto/login.dto.d.ts +5 -0
  17. package/dist/auth/dto/login.dto.d.ts.map +1 -0
  18. package/dist/auth/dto/login.dto.js +26 -0
  19. package/dist/auth/dto/refresh.dto.d.ts +4 -0
  20. package/dist/auth/dto/refresh.dto.d.ts.map +1 -0
  21. package/dist/auth/dto/refresh.dto.js +21 -0
  22. package/dist/auth/dto/register.dto.d.ts +5 -0
  23. package/dist/auth/dto/register.dto.d.ts.map +1 -0
  24. package/dist/auth/dto/register.dto.js +27 -0
  25. package/dist/auth/dto/reset-password.dto.d.ts +5 -0
  26. package/dist/auth/dto/reset-password.dto.d.ts.map +1 -0
  27. package/dist/auth/dto/reset-password.dto.js +27 -0
  28. package/dist/auth/dto/update-user.dto.d.ts +5 -0
  29. package/dist/auth/dto/update-user.dto.d.ts.map +1 -0
  30. package/dist/auth/dto/update-user.dto.js +28 -0
  31. package/dist/auth/guards/jwt.guard.d.ts +5 -0
  32. package/dist/auth/guards/jwt.guard.d.ts.map +1 -0
  33. package/dist/auth/guards/jwt.guard.js +18 -0
  34. package/dist/auth/guards/jwt.refresh-guard.d.ts +5 -0
  35. package/dist/auth/guards/jwt.refresh-guard.d.ts.map +1 -0
  36. package/dist/auth/guards/jwt.refresh-guard.js +18 -0
  37. package/dist/auth/strategies/jwt-refresh.strategy.d.ts +22 -0
  38. package/dist/auth/strategies/jwt-refresh.strategy.d.ts.map +1 -0
  39. package/dist/auth/strategies/jwt-refresh.strategy.js +45 -0
  40. package/dist/auth/strategies/jwt.strategy.d.ts +10 -0
  41. package/dist/auth/strategies/jwt.strategy.d.ts.map +1 -0
  42. package/dist/auth/strategies/jwt.strategy.js +33 -0
  43. package/dist/auth/strategies/strategies/jwt-refresh.strategy.d.ts +22 -0
  44. package/dist/auth/strategies/strategies/jwt-refresh.strategy.d.ts.map +1 -0
  45. package/dist/auth/strategies/strategies/jwt-refresh.strategy.js +45 -0
  46. package/dist/auth/strategies/strategies/jwt.strategy.d.ts +10 -0
  47. package/dist/auth/strategies/strategies/jwt.strategy.d.ts.map +1 -0
  48. package/dist/auth/strategies/strategies/jwt.strategy.js +33 -0
  49. package/dist/index.d.ts +13 -0
  50. package/dist/index.d.ts.map +1 -0
  51. package/dist/index.js +30 -0
  52. package/package.json +18 -0
@@ -0,0 +1,287 @@
1
+ "use strict";
2
+ // cSpell: disable
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
20
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
21
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
22
+ 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;
23
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
24
+ };
25
+ var __importStar = (this && this.__importStar) || (function () {
26
+ var ownKeys = function(o) {
27
+ ownKeys = Object.getOwnPropertyNames || function (o) {
28
+ var ar = [];
29
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
30
+ return ar;
31
+ };
32
+ return ownKeys(o);
33
+ };
34
+ return function (mod) {
35
+ if (mod && mod.__esModule) return mod;
36
+ var result = {};
37
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
38
+ __setModuleDefault(result, mod);
39
+ return result;
40
+ };
41
+ })();
42
+ var __metadata = (this && this.__metadata) || function (k, v) {
43
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
44
+ };
45
+ Object.defineProperty(exports, "__esModule", { value: true });
46
+ exports.AuthService = void 0;
47
+ const common_1 = require("@nestjs/common");
48
+ const bcrypt = __importStar(require("bcrypt"));
49
+ const auth_repository_1 = require("./auth.repository");
50
+ const jwt_1 = require("@nestjs/jwt");
51
+ const crypto_1 = require("crypto");
52
+ let AuthService = class AuthService {
53
+ repo;
54
+ jwt;
55
+ isE2E = process.env.NODE_ENV === 'test:e2e';
56
+ constructor(repo, jwt) {
57
+ this.repo = repo;
58
+ this.jwt = jwt;
59
+ }
60
+ // -------------------------
61
+ // UTILS
62
+ // -------------------------
63
+ sha256(data) {
64
+ return (0, crypto_1.createHash)('sha256').update(data).digest('hex');
65
+ }
66
+ generateTokens(user) {
67
+ const payload = { sub: user.id, email: user.email };
68
+ try {
69
+ const accessToken = this.jwt.sign(payload, {
70
+ secret: process.env.JWT_SECRET,
71
+ expiresIn: '15m',
72
+ });
73
+ const refreshToken = this.jwt.sign({
74
+ ...payload,
75
+ type: 'refresh',
76
+ jti: (0, crypto_1.randomBytes)(16).toString('hex'), // token unique
77
+ }, {
78
+ secret: process.env.JWT_REFRESH_SECRET,
79
+ expiresIn: '7d',
80
+ });
81
+ return { accessToken, refreshToken };
82
+ }
83
+ catch {
84
+ throw new Error('jwt failed');
85
+ }
86
+ }
87
+ // -------------------------
88
+ // REGISTER
89
+ // -------------------------
90
+ async register(dto) {
91
+ const hashed = await bcrypt.hash(dto.password, 10);
92
+ let user;
93
+ try {
94
+ user = await this.repo.createUser({
95
+ email: dto.email,
96
+ password: hashed,
97
+ });
98
+ }
99
+ catch (err) {
100
+ if (err?.code === 'P2002') {
101
+ throw new common_1.ConflictException('Email already exists');
102
+ }
103
+ throw err;
104
+ }
105
+ let tokens;
106
+ try {
107
+ tokens = this.generateTokens(user);
108
+ }
109
+ catch {
110
+ throw new Error('jwt failed');
111
+ }
112
+ try {
113
+ const refreshHash = await bcrypt.hash(tokens.refreshToken, 10);
114
+ await this.repo.updateRefreshToken(user.id, refreshHash);
115
+ }
116
+ catch {
117
+ throw new Error('refresh failed');
118
+ }
119
+ return {
120
+ message: 'User registered',
121
+ ...tokens,
122
+ };
123
+ }
124
+ // -------------------------
125
+ // LOGIN
126
+ // -------------------------
127
+ async login(dto) {
128
+ const user = await this.repo.findByEmail(dto.email);
129
+ if (!user)
130
+ throw new common_1.ForbiddenException('Invalid credentials');
131
+ const valid = await bcrypt.compare(dto.password, user.password);
132
+ if (!valid)
133
+ throw new common_1.ForbiddenException('Invalid credentials');
134
+ let tokens;
135
+ try {
136
+ tokens = this.generateTokens(user);
137
+ }
138
+ catch {
139
+ throw new Error('jwt failed');
140
+ }
141
+ try {
142
+ const refreshHash = await bcrypt.hash(tokens.refreshToken, 10);
143
+ await this.repo.updateRefreshToken(user.id, refreshHash);
144
+ }
145
+ catch {
146
+ throw new Error('refresh failed');
147
+ }
148
+ return {
149
+ message: 'Login successful',
150
+ ...tokens,
151
+ };
152
+ }
153
+ // -------------------------
154
+ // ME
155
+ // -------------------------
156
+ async me(userId) {
157
+ const user = await this.repo.findById(userId);
158
+ if (!user)
159
+ throw new common_1.NotFoundException('User not found');
160
+ return {
161
+ sub: user.id,
162
+ email: user.email,
163
+ };
164
+ }
165
+ // -------------------------
166
+ // UPDATE USER
167
+ // -------------------------
168
+ async updateUser(userId, dto) {
169
+ const data = {};
170
+ if (dto.email)
171
+ data.email = dto.email;
172
+ if (dto.password)
173
+ data.password = await bcrypt.hash(dto.password, 10);
174
+ const updated = await this.repo.updateUser(userId, data);
175
+ if (!this.isE2E) {
176
+ return {
177
+ message: 'User updated successfully',
178
+ user: {
179
+ id: updated.id,
180
+ email: updated.email,
181
+ },
182
+ };
183
+ }
184
+ return {
185
+ message: 'User updated',
186
+ email: updated.email,
187
+ };
188
+ }
189
+ // -------------------------
190
+ // LOGOUT
191
+ // -------------------------
192
+ async logout(userId) {
193
+ if (!this.isE2E) {
194
+ try {
195
+ await this.repo.updateRefreshToken(userId, null);
196
+ }
197
+ catch {
198
+ throw new Error('DB error');
199
+ }
200
+ }
201
+ else {
202
+ await this.repo.clearRefreshToken(userId);
203
+ }
204
+ return { message: 'Logged out' };
205
+ }
206
+ // -------------------------
207
+ // REFRESH (sans guard)
208
+ // -------------------------
209
+ async refresh(dto) {
210
+ const { refreshToken } = dto;
211
+ if (!refreshToken) {
212
+ throw new common_1.ForbiddenException('Access denied');
213
+ }
214
+ let payload;
215
+ try {
216
+ payload = this.jwt.verify(refreshToken, {
217
+ secret: process.env.JWT_REFRESH_SECRET,
218
+ });
219
+ }
220
+ catch {
221
+ throw new common_1.ForbiddenException('Access denied');
222
+ }
223
+ const user = await this.repo.findById(payload.sub);
224
+ if (!user)
225
+ throw new common_1.ForbiddenException('Access denied');
226
+ const valid = await bcrypt.compare(refreshToken, user.refreshToken);
227
+ if (!valid)
228
+ throw new common_1.ForbiddenException('Access denied');
229
+ let tokens;
230
+ try {
231
+ tokens = this.generateTokens(user);
232
+ }
233
+ catch {
234
+ throw new Error('jwt failed');
235
+ }
236
+ try {
237
+ const newHash = await bcrypt.hash(tokens.refreshToken, 10);
238
+ await this.repo.updateRefreshToken(user.id, newHash);
239
+ }
240
+ catch {
241
+ throw new Error('refresh failed');
242
+ }
243
+ return {
244
+ message: 'Token refreshed',
245
+ ...tokens,
246
+ };
247
+ }
248
+ // -------------------------
249
+ // FORGOT PASSWORD
250
+ // -------------------------
251
+ async forgotPassword(dto) {
252
+ const user = await this.repo.findByEmail(dto.email);
253
+ if (!user) {
254
+ return this.isE2E ? 'Reset email sent' : undefined;
255
+ }
256
+ const token = (0, crypto_1.randomBytes)(32).toString('hex');
257
+ const tokenHash = this.sha256(token);
258
+ const expiresAt = new Date(Date.now() + 1000 * 60 * 15);
259
+ await this.repo.setResetToken(user.id, tokenHash, expiresAt);
260
+ return token;
261
+ }
262
+ // -------------------------
263
+ // RESET PASSWORD
264
+ // -------------------------
265
+ async resetPassword(dto) {
266
+ const tokenHash = this.sha256(dto.token);
267
+ const user = await this.repo.findByResetToken(tokenHash);
268
+ if (!user) {
269
+ throw new common_1.ForbiddenException('Invalid or expired token');
270
+ }
271
+ if (!user.resetTokenExpiresAt || user.resetTokenExpiresAt < new Date()) {
272
+ throw new common_1.ForbiddenException('Invalid or expired token');
273
+ }
274
+ const hashedPassword = await bcrypt.hash(dto.password, 10);
275
+ await this.repo.updatePassword(user.id, hashedPassword);
276
+ await this.repo.clearResetToken(user.id);
277
+ return this.isE2E
278
+ ? { message: 'Password reset successfully' }
279
+ : { message: 'Password updated' };
280
+ }
281
+ };
282
+ exports.AuthService = AuthService;
283
+ exports.AuthService = AuthService = __decorate([
284
+ (0, common_1.Injectable)(),
285
+ __metadata("design:paramtypes", [auth_repository_1.AuthRepository,
286
+ jwt_1.JwtService])
287
+ ], AuthService);
@@ -0,0 +1,4 @@
1
+ export declare class ForgotPasswordDto {
2
+ email: string;
3
+ }
4
+ //# sourceMappingURL=forgot-password.dto.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"forgot-password.dto.d.ts","sourceRoot":"","sources":["../../../src/auth/dto/forgot-password.dto.ts"],"names":[],"mappings":"AAEA,qBAAa,iBAAiB;IAE5B,KAAK,EAAG,MAAM,CAAC;CAChB"}
@@ -0,0 +1,21 @@
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.ForgotPasswordDto = void 0;
13
+ const class_validator_1 = require("class-validator");
14
+ class ForgotPasswordDto {
15
+ email;
16
+ }
17
+ exports.ForgotPasswordDto = ForgotPasswordDto;
18
+ __decorate([
19
+ (0, class_validator_1.IsEmail)(),
20
+ __metadata("design:type", String)
21
+ ], ForgotPasswordDto.prototype, "email", void 0);
@@ -0,0 +1,5 @@
1
+ export declare class LoginDto {
2
+ email: string;
3
+ password: string;
4
+ }
5
+ //# sourceMappingURL=login.dto.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"login.dto.d.ts","sourceRoot":"","sources":["../../../src/auth/dto/login.dto.ts"],"names":[],"mappings":"AAEA,qBAAa,QAAQ;IAEnB,KAAK,EAAG,MAAM,CAAC;IAGf,QAAQ,EAAG,MAAM,CAAC;CACnB"}
@@ -0,0 +1,26 @@
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
+ email;
16
+ password;
17
+ }
18
+ exports.LoginDto = LoginDto;
19
+ __decorate([
20
+ (0, class_validator_1.IsEmail)(),
21
+ __metadata("design:type", String)
22
+ ], LoginDto.prototype, "email", void 0);
23
+ __decorate([
24
+ (0, class_validator_1.IsString)(),
25
+ __metadata("design:type", String)
26
+ ], LoginDto.prototype, "password", void 0);
@@ -0,0 +1,4 @@
1
+ export declare class RefreshDto {
2
+ refreshToken: string;
3
+ }
4
+ //# sourceMappingURL=refresh.dto.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"refresh.dto.d.ts","sourceRoot":"","sources":["../../../src/auth/dto/refresh.dto.ts"],"names":[],"mappings":"AAEA,qBAAa,UAAU;IAErB,YAAY,EAAG,MAAM,CAAC;CACvB"}
@@ -0,0 +1,21 @@
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.RefreshDto = void 0;
13
+ const class_validator_1 = require("class-validator");
14
+ class RefreshDto {
15
+ refreshToken;
16
+ }
17
+ exports.RefreshDto = RefreshDto;
18
+ __decorate([
19
+ (0, class_validator_1.IsString)(),
20
+ __metadata("design:type", String)
21
+ ], RefreshDto.prototype, "refreshToken", void 0);
@@ -0,0 +1,5 @@
1
+ export declare class RegisterDto {
2
+ email: string;
3
+ password: string;
4
+ }
5
+ //# sourceMappingURL=register.dto.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"register.dto.d.ts","sourceRoot":"","sources":["../../../src/auth/dto/register.dto.ts"],"names":[],"mappings":"AAEA,qBAAa,WAAW;IAEtB,KAAK,EAAG,MAAM,CAAC;IAIf,QAAQ,EAAG,MAAM,CAAC;CACnB"}
@@ -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.RegisterDto = void 0;
13
+ const class_validator_1 = require("class-validator");
14
+ class RegisterDto {
15
+ email;
16
+ password;
17
+ }
18
+ exports.RegisterDto = RegisterDto;
19
+ __decorate([
20
+ (0, class_validator_1.IsEmail)(),
21
+ __metadata("design:type", String)
22
+ ], RegisterDto.prototype, "email", void 0);
23
+ __decorate([
24
+ (0, class_validator_1.IsString)(),
25
+ (0, class_validator_1.MinLength)(6),
26
+ __metadata("design:type", String)
27
+ ], RegisterDto.prototype, "password", void 0);
@@ -0,0 +1,5 @@
1
+ export declare class ResetPasswordDto {
2
+ token: string;
3
+ password: string;
4
+ }
5
+ //# sourceMappingURL=reset-password.dto.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reset-password.dto.d.ts","sourceRoot":"","sources":["../../../src/auth/dto/reset-password.dto.ts"],"names":[],"mappings":"AAEA,qBAAa,gBAAgB;IAE3B,KAAK,EAAG,MAAM,CAAC;IAIf,QAAQ,EAAG,MAAM,CAAC;CACnB"}
@@ -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.ResetPasswordDto = void 0;
13
+ const class_validator_1 = require("class-validator");
14
+ class ResetPasswordDto {
15
+ token;
16
+ password;
17
+ }
18
+ exports.ResetPasswordDto = ResetPasswordDto;
19
+ __decorate([
20
+ (0, class_validator_1.IsString)(),
21
+ __metadata("design:type", String)
22
+ ], ResetPasswordDto.prototype, "token", void 0);
23
+ __decorate([
24
+ (0, class_validator_1.IsString)(),
25
+ (0, class_validator_1.MinLength)(6),
26
+ __metadata("design:type", String)
27
+ ], ResetPasswordDto.prototype, "password", void 0);
@@ -0,0 +1,5 @@
1
+ export declare class UpdateUserDto {
2
+ email?: string;
3
+ password?: string;
4
+ }
5
+ //# sourceMappingURL=update-user.dto.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-user.dto.d.ts","sourceRoot":"","sources":["../../../src/auth/dto/update-user.dto.ts"],"names":[],"mappings":"AAEA,qBAAa,aAAa;IAGxB,KAAK,CAAC,EAAE,MAAM,CAAC;IAIf,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB"}
@@ -0,0 +1,28 @@
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.UpdateUserDto = void 0;
13
+ const class_validator_1 = require("class-validator");
14
+ class UpdateUserDto {
15
+ email;
16
+ password;
17
+ }
18
+ exports.UpdateUserDto = UpdateUserDto;
19
+ __decorate([
20
+ (0, class_validator_1.IsOptional)(),
21
+ (0, class_validator_1.IsEmail)(),
22
+ __metadata("design:type", String)
23
+ ], UpdateUserDto.prototype, "email", void 0);
24
+ __decorate([
25
+ (0, class_validator_1.IsOptional)(),
26
+ (0, class_validator_1.MinLength)(6),
27
+ __metadata("design:type", String)
28
+ ], UpdateUserDto.prototype, "password", void 0);
@@ -0,0 +1,5 @@
1
+ declare const JwtAuthGuard_base: import("@nestjs/passport").Type<import("@nestjs/passport").IAuthGuard>;
2
+ export declare class JwtAuthGuard extends JwtAuthGuard_base {
3
+ }
4
+ export {};
5
+ //# sourceMappingURL=jwt.guard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jwt.guard.d.ts","sourceRoot":"","sources":["../../../src/auth/guards/jwt.guard.ts"],"names":[],"mappings":";AAIA,qBACa,YAAa,SAAQ,iBAAgB;CAAG"}
@@ -0,0 +1,18 @@
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.JwtAuthGuard = void 0;
10
+ // src/auth/guards/jwt.guard.ts
11
+ const common_1 = require("@nestjs/common");
12
+ const passport_1 = require("@nestjs/passport");
13
+ let JwtAuthGuard = class JwtAuthGuard extends (0, passport_1.AuthGuard)('jwt') {
14
+ };
15
+ exports.JwtAuthGuard = JwtAuthGuard;
16
+ exports.JwtAuthGuard = JwtAuthGuard = __decorate([
17
+ (0, common_1.Injectable)()
18
+ ], JwtAuthGuard);
@@ -0,0 +1,5 @@
1
+ declare const JwtRefreshGuard_base: import("@nestjs/passport").Type<import("@nestjs/passport").IAuthGuard>;
2
+ export declare class JwtRefreshGuard extends JwtRefreshGuard_base {
3
+ }
4
+ export {};
5
+ //# sourceMappingURL=jwt.refresh-guard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jwt.refresh-guard.d.ts","sourceRoot":"","sources":["../../../src/auth/guards/jwt.refresh-guard.ts"],"names":[],"mappings":";AAIA,qBACa,eAAgB,SAAQ,oBAAwB;CAAG"}
@@ -0,0 +1,18 @@
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.JwtRefreshGuard = void 0;
10
+ // src/auth/guards/jwt-refresh.guard.ts
11
+ const common_1 = require("@nestjs/common");
12
+ const passport_1 = require("@nestjs/passport");
13
+ let JwtRefreshGuard = class JwtRefreshGuard extends (0, passport_1.AuthGuard)('jwt-refresh') {
14
+ };
15
+ exports.JwtRefreshGuard = JwtRefreshGuard;
16
+ exports.JwtRefreshGuard = JwtRefreshGuard = __decorate([
17
+ (0, common_1.Injectable)()
18
+ ], JwtRefreshGuard);
@@ -0,0 +1,22 @@
1
+ import { Strategy } from 'passport-jwt';
2
+ declare const JwtRefreshStrategy_base: new (...args: [opt: import("passport-jwt").StrategyOptionsWithRequest] | [opt: import("passport-jwt").StrategyOptionsWithoutRequest]) => Strategy & {
3
+ validate(...args: any[]): unknown;
4
+ };
5
+ /**
6
+ * NOTE IMPORTANTE :
7
+ * -----------------
8
+ * Cette stratégie est volontairement "neutre".
9
+ *
10
+ * - Les tests E2E exigent un refresh SANS guard.
11
+ * - Les tests unitaires n'utilisent pas cette stratégie.
12
+ * - Passport renverrait 401 au lieu de 403 → casserait les E2E.
13
+ *
14
+ * Donc la stratégie existe pour satisfaire NestJS,
15
+ * mais elle n'est PAS utilisée dans le controller.
16
+ */
17
+ export declare class JwtRefreshStrategy extends JwtRefreshStrategy_base {
18
+ constructor();
19
+ validate(): Promise<null>;
20
+ }
21
+ export {};
22
+ //# sourceMappingURL=jwt-refresh.strategy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jwt-refresh.strategy.d.ts","sourceRoot":"","sources":["../../../src/auth/strategies/jwt-refresh.strategy.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;;;;AAExC;;;;;;;;;;;GAWG;AAEH,qBACa,kBAAmB,SAAQ,uBAGvC;;IASO,QAAQ;CAIf"}
@@ -0,0 +1,45 @@
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.JwtRefreshStrategy = void 0;
13
+ const common_1 = require("@nestjs/common");
14
+ const passport_1 = require("@nestjs/passport");
15
+ const passport_jwt_1 = require("passport-jwt");
16
+ /**
17
+ * NOTE IMPORTANTE :
18
+ * -----------------
19
+ * Cette stratégie est volontairement "neutre".
20
+ *
21
+ * - Les tests E2E exigent un refresh SANS guard.
22
+ * - Les tests unitaires n'utilisent pas cette stratégie.
23
+ * - Passport renverrait 401 au lieu de 403 → casserait les E2E.
24
+ *
25
+ * Donc la stratégie existe pour satisfaire NestJS,
26
+ * mais elle n'est PAS utilisée dans le controller.
27
+ */
28
+ let JwtRefreshStrategy = class JwtRefreshStrategy extends (0, passport_1.PassportStrategy)(passport_jwt_1.Strategy, 'jwt-refresh') {
29
+ constructor() {
30
+ super({
31
+ jwtFromRequest: () => null, // 🔥 Ne lit jamais de token
32
+ ignoreExpiration: true,
33
+ secretOrKey: process.env.JWT_REFRESH_SECRET,
34
+ });
35
+ }
36
+ async validate() {
37
+ // 🔥 Ne valide jamais rien
38
+ return null;
39
+ }
40
+ };
41
+ exports.JwtRefreshStrategy = JwtRefreshStrategy;
42
+ exports.JwtRefreshStrategy = JwtRefreshStrategy = __decorate([
43
+ (0, common_1.Injectable)(),
44
+ __metadata("design:paramtypes", [])
45
+ ], JwtRefreshStrategy);
@@ -0,0 +1,10 @@
1
+ import { Strategy } from 'passport-jwt';
2
+ declare const JwtStrategy_base: new (...args: [opt: import("passport-jwt").StrategyOptionsWithRequest] | [opt: import("passport-jwt").StrategyOptionsWithoutRequest]) => Strategy & {
3
+ validate(...args: any[]): unknown;
4
+ };
5
+ export declare class JwtStrategy extends JwtStrategy_base {
6
+ constructor();
7
+ validate(payload: any): Promise<any>;
8
+ }
9
+ export {};
10
+ //# sourceMappingURL=jwt.strategy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jwt.strategy.d.ts","sourceRoot":"","sources":["../../../src/auth/strategies/jwt.strategy.ts"],"names":[],"mappings":"AAEA,OAAO,EAAc,QAAQ,EAAE,MAAM,cAAc,CAAC;;;;AAEpD,qBACa,WAAY,SAAQ,gBAAiC;;IAS1D,QAAQ,CAAC,OAAO,EAAE,GAAG;CAI5B"}