@j3r3mcdev/auth-service 1.0.0 → 1.0.8
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.
- package/README.md +0 -0
- package/dist/hashing.d.ts +2 -0
- package/dist/hashing.d.ts.map +1 -0
- package/dist/hashing.js +8 -0
- package/dist/index.d.ts +4 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -30
- package/dist/sanitize.d.ts +2 -0
- package/dist/sanitize.d.ts.map +1 -0
- package/dist/sanitize.js +5 -0
- package/dist/tokens.d.ts +6 -0
- package/dist/tokens.d.ts.map +1 -0
- package/dist/tokens.js +11 -0
- package/dist/validators.d.ts +3 -0
- package/dist/validators.d.ts.map +1 -0
- package/dist/validators.js +14 -0
- package/package.json +46 -8
- package/dist/auth/auth.controller.d.ts +0 -60
- package/dist/auth/auth.controller.d.ts.map +0 -1
- package/dist/auth/auth.controller.js +0 -128
- package/dist/auth/auth.module.d.ts +0 -3
- package/dist/auth/auth.module.d.ts.map +0 -1
- package/dist/auth/auth.module.js +0 -44
- package/dist/auth/auth.repository.d.ts +0 -119
- package/dist/auth/auth.repository.d.ts.map +0 -1
- package/dist/auth/auth.repository.js +0 -108
- package/dist/auth/auth.service.d.ts +0 -61
- package/dist/auth/auth.service.d.ts.map +0 -1
- package/dist/auth/auth.service.js +0 -287
- package/dist/auth/dto/forgot-password.dto.d.ts +0 -4
- package/dist/auth/dto/forgot-password.dto.d.ts.map +0 -1
- package/dist/auth/dto/forgot-password.dto.js +0 -21
- package/dist/auth/dto/login.dto.d.ts +0 -5
- package/dist/auth/dto/login.dto.d.ts.map +0 -1
- package/dist/auth/dto/login.dto.js +0 -26
- package/dist/auth/dto/refresh.dto.d.ts +0 -4
- package/dist/auth/dto/refresh.dto.d.ts.map +0 -1
- package/dist/auth/dto/refresh.dto.js +0 -21
- package/dist/auth/dto/register.dto.d.ts +0 -5
- package/dist/auth/dto/register.dto.d.ts.map +0 -1
- package/dist/auth/dto/register.dto.js +0 -27
- package/dist/auth/dto/reset-password.dto.d.ts +0 -5
- package/dist/auth/dto/reset-password.dto.d.ts.map +0 -1
- package/dist/auth/dto/reset-password.dto.js +0 -27
- package/dist/auth/dto/update-user.dto.d.ts +0 -5
- package/dist/auth/dto/update-user.dto.d.ts.map +0 -1
- package/dist/auth/dto/update-user.dto.js +0 -28
- package/dist/auth/guards/jwt.guard.d.ts +0 -5
- package/dist/auth/guards/jwt.guard.d.ts.map +0 -1
- package/dist/auth/guards/jwt.guard.js +0 -18
- package/dist/auth/guards/jwt.refresh-guard.d.ts +0 -5
- package/dist/auth/guards/jwt.refresh-guard.d.ts.map +0 -1
- package/dist/auth/guards/jwt.refresh-guard.js +0 -18
- package/dist/auth/strategies/jwt-refresh.strategy.d.ts +0 -22
- package/dist/auth/strategies/jwt-refresh.strategy.d.ts.map +0 -1
- package/dist/auth/strategies/jwt-refresh.strategy.js +0 -45
- package/dist/auth/strategies/jwt.strategy.d.ts +0 -10
- package/dist/auth/strategies/jwt.strategy.d.ts.map +0 -1
- package/dist/auth/strategies/jwt.strategy.js +0 -33
- package/dist/auth/strategies/strategies/jwt-refresh.strategy.d.ts +0 -22
- package/dist/auth/strategies/strategies/jwt-refresh.strategy.d.ts.map +0 -1
- package/dist/auth/strategies/strategies/jwt-refresh.strategy.js +0 -45
- package/dist/auth/strategies/strategies/jwt.strategy.d.ts +0 -10
- package/dist/auth/strategies/strategies/jwt.strategy.d.ts.map +0 -1
- package/dist/auth/strategies/strategies/jwt.strategy.js +0 -33
package/README.md
ADDED
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hashing.d.ts","sourceRoot":"","sources":["../src/hashing.ts"],"names":[],"mappings":"AAEA,wBAAsB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAOpE"}
|
package/dist/hashing.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import bcrypt from "bcrypt";
|
|
2
|
+
export async function hashPassword(password) {
|
|
3
|
+
if (typeof password !== "string" || password.trim().length === 0) {
|
|
4
|
+
throw new Error("Password cannot be empty");
|
|
5
|
+
}
|
|
6
|
+
const saltRounds = 10;
|
|
7
|
+
return bcrypt.hash(password, saltRounds);
|
|
8
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,5 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './
|
|
5
|
-
export * from './auth/dto/register.dto';
|
|
6
|
-
export * from './auth/dto/login.dto';
|
|
7
|
-
export * from './auth/dto/refresh.dto';
|
|
8
|
-
export * from './auth/dto/update-user.dto';
|
|
9
|
-
export * from './auth/dto/forgot-password.dto';
|
|
10
|
-
export * from './auth/dto/reset-password.dto';
|
|
11
|
-
export * from './auth/strategies/jwt.strategy';
|
|
12
|
-
export * from './auth/strategies/jwt-refresh.strategy';
|
|
1
|
+
export * from './hashing.js';
|
|
2
|
+
export * from './tokens.js';
|
|
3
|
+
export * from './validators.js';
|
|
4
|
+
export * from './sanitize.js';
|
|
13
5
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,30 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./auth/auth.module"), exports);
|
|
18
|
-
__exportStar(require("./auth/auth.service"), exports);
|
|
19
|
-
__exportStar(require("./auth/auth.repository"), exports);
|
|
20
|
-
__exportStar(require("./auth/auth.controller"), exports);
|
|
21
|
-
// DTO
|
|
22
|
-
__exportStar(require("./auth/dto/register.dto"), exports);
|
|
23
|
-
__exportStar(require("./auth/dto/login.dto"), exports);
|
|
24
|
-
__exportStar(require("./auth/dto/refresh.dto"), exports);
|
|
25
|
-
__exportStar(require("./auth/dto/update-user.dto"), exports);
|
|
26
|
-
__exportStar(require("./auth/dto/forgot-password.dto"), exports);
|
|
27
|
-
__exportStar(require("./auth/dto/reset-password.dto"), exports);
|
|
28
|
-
// Strategies
|
|
29
|
-
__exportStar(require("./auth/strategies/jwt.strategy"), exports);
|
|
30
|
-
__exportStar(require("./auth/strategies/jwt-refresh.strategy"), exports);
|
|
1
|
+
export * from './hashing.js';
|
|
2
|
+
export * from './tokens.js';
|
|
3
|
+
export * from './validators.js';
|
|
4
|
+
export * from './sanitize.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../src/sanitize.ts"],"names":[],"mappings":"AAAA,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAG9C"}
|
package/dist/sanitize.js
ADDED
package/dist/tokens.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare function generateTokens(payload: any, secret: string, expiresIn: string): {
|
|
2
|
+
accessToken: string;
|
|
3
|
+
};
|
|
4
|
+
export declare function generateToken(payload: any, secret: string, expiresIn: string): string;
|
|
5
|
+
export declare function verifyToken(token: string, secret: string): any;
|
|
6
|
+
//# sourceMappingURL=tokens.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":"AAEA,wBAAgB,cAAc,CAC5B,OAAO,EAAE,GAAG,EACZ,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM;;EASlB;AAED,wBAAgB,aAAa,CAC3B,OAAO,EAAE,GAAG,EACZ,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,UAGlB;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,OAExD"}
|
package/dist/tokens.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as jwt from "jsonwebtoken";
|
|
2
|
+
export function generateTokens(payload, secret, expiresIn) {
|
|
3
|
+
const accessToken = jwt.sign(payload, secret, { expiresIn });
|
|
4
|
+
return { accessToken };
|
|
5
|
+
}
|
|
6
|
+
export function generateToken(payload, secret, expiresIn) {
|
|
7
|
+
return generateTokens(payload, secret, expiresIn).accessToken;
|
|
8
|
+
}
|
|
9
|
+
export function verifyToken(token, secret) {
|
|
10
|
+
return jwt.verify(token, secret);
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validators.d.ts","sourceRoot":"","sources":["../src/validators.ts"],"names":[],"mappings":"AAEA,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAS1D"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import validator from "validator";
|
|
2
|
+
export function validateEmail(email) {
|
|
3
|
+
return validator.isEmail(email);
|
|
4
|
+
}
|
|
5
|
+
export function validatePassword(password) {
|
|
6
|
+
// Exemple simple : min 8 chars, 1 maj, 1 min, 1 chiffre
|
|
7
|
+
return validator.isStrongPassword(password, {
|
|
8
|
+
minLength: 8,
|
|
9
|
+
minLowercase: 1,
|
|
10
|
+
minUppercase: 1,
|
|
11
|
+
minNumbers: 1,
|
|
12
|
+
minSymbols: 0
|
|
13
|
+
});
|
|
14
|
+
}
|
package/package.json
CHANGED
|
@@ -1,18 +1,56 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@j3r3mcdev/auth-service",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "
|
|
5
|
-
"
|
|
6
|
-
"
|
|
3
|
+
"version": "1.0.8",
|
|
4
|
+
"description": "Authentication utilities for Node/NestJS (hashing, tokens, validators, sanitization).",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"types": "./dist/index.d.ts"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
7
15
|
"files": [
|
|
8
16
|
"dist"
|
|
9
17
|
],
|
|
10
18
|
"scripts": {
|
|
11
|
-
"build": "tsc -p tsconfig.json"
|
|
19
|
+
"build": "tsc -p tsconfig.json",
|
|
20
|
+
"clean": "rimraf dist",
|
|
21
|
+
"prepublishOnly": "npm run clean && npm run build",
|
|
22
|
+
"test": "jest",
|
|
23
|
+
"test:watch": "jest --watch",
|
|
24
|
+
"test:coverage": "jest --coverage"
|
|
25
|
+
},
|
|
26
|
+
"keywords": [
|
|
27
|
+
"auth",
|
|
28
|
+
"authentication",
|
|
29
|
+
"bcrypt",
|
|
30
|
+
"jwt",
|
|
31
|
+
"nest",
|
|
32
|
+
"nestjs",
|
|
33
|
+
"security",
|
|
34
|
+
"typescript",
|
|
35
|
+
"esm"
|
|
36
|
+
],
|
|
37
|
+
"author": "Jérémy",
|
|
38
|
+
"license": "MIT",
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@types/bcrypt": "^6.0.0",
|
|
41
|
+
"@types/jest": "^30.0.0",
|
|
42
|
+
"@types/jsonwebtoken": "^9.0.10",
|
|
43
|
+
"@types/validator": "^13.15.10",
|
|
44
|
+
"jest": "^30.3.0",
|
|
45
|
+
"rimraf": "^6.1.3",
|
|
46
|
+
"ts-jest": "^29.4.9",
|
|
47
|
+
"typescript": "^5.4.0"
|
|
12
48
|
},
|
|
13
49
|
"peerDependencies": {
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
|
|
50
|
+
"bcrypt": "^5.1.1"
|
|
51
|
+
},
|
|
52
|
+
"dependencies": {
|
|
53
|
+
"jsonwebtoken": "^9.0.3",
|
|
54
|
+
"validator": "^13.15.35"
|
|
17
55
|
}
|
|
18
56
|
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import type { Request } from 'express';
|
|
2
|
-
import { AuthService } from './auth.service';
|
|
3
|
-
import { RegisterDto } from './dto/register.dto';
|
|
4
|
-
import { LoginDto } from './dto/login.dto';
|
|
5
|
-
import { RefreshDto } from './dto/refresh.dto';
|
|
6
|
-
import { UpdateUserDto } from './dto/update-user.dto';
|
|
7
|
-
import { ForgotPasswordDto } from './dto/forgot-password.dto';
|
|
8
|
-
import { ResetPasswordDto } from './dto/reset-password.dto';
|
|
9
|
-
type AuthRequest = Request & {
|
|
10
|
-
user: {
|
|
11
|
-
sub: string;
|
|
12
|
-
email: string;
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
export declare class AuthController {
|
|
16
|
-
private readonly authService;
|
|
17
|
-
constructor(authService: AuthService);
|
|
18
|
-
register(dto: RegisterDto): Promise<{
|
|
19
|
-
accessToken: string;
|
|
20
|
-
refreshToken: string;
|
|
21
|
-
message: string;
|
|
22
|
-
}>;
|
|
23
|
-
login(dto: LoginDto): Promise<{
|
|
24
|
-
accessToken: string;
|
|
25
|
-
refreshToken: string;
|
|
26
|
-
message: string;
|
|
27
|
-
}>;
|
|
28
|
-
me(req: AuthRequest): Promise<{
|
|
29
|
-
sub: string;
|
|
30
|
-
email: string;
|
|
31
|
-
}>;
|
|
32
|
-
updateUser(req: AuthRequest, dto: UpdateUserDto): Promise<{
|
|
33
|
-
message: string;
|
|
34
|
-
user: {
|
|
35
|
-
id: string;
|
|
36
|
-
email: string;
|
|
37
|
-
};
|
|
38
|
-
email?: undefined;
|
|
39
|
-
} | {
|
|
40
|
-
message: string;
|
|
41
|
-
email: string;
|
|
42
|
-
user?: undefined;
|
|
43
|
-
}>;
|
|
44
|
-
logout(req: AuthRequest): Promise<{
|
|
45
|
-
message: string;
|
|
46
|
-
}>;
|
|
47
|
-
refresh(req: any, dto: RefreshDto): Promise<{
|
|
48
|
-
accessToken: string;
|
|
49
|
-
refreshToken: string;
|
|
50
|
-
message: string;
|
|
51
|
-
}>;
|
|
52
|
-
forgotPassword(dto: ForgotPasswordDto): Promise<string | {
|
|
53
|
-
message: string;
|
|
54
|
-
} | undefined>;
|
|
55
|
-
resetPassword(dto: ResetPasswordDto): Promise<{
|
|
56
|
-
message: string;
|
|
57
|
-
}>;
|
|
58
|
-
}
|
|
59
|
-
export {};
|
|
60
|
-
//# sourceMappingURL=auth.controller.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth.controller.d.ts","sourceRoot":"","sources":["../../src/auth/auth.controller.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAG5D,KAAK,WAAW,GAAG,OAAO,GAAG;IAC3B,IAAI,EAAE;QACJ,GAAG,EAAE,MAAM,CAAC;QACZ,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;CACH,CAAC;AAEF,qBACa,cAAc;IACb,OAAO,CAAC,QAAQ,CAAC,WAAW;gBAAX,WAAW,EAAE,WAAW;IAG/C,QAAQ,CAAS,GAAG,EAAE,WAAW;;;;;IAMjC,KAAK,CAAS,GAAG,EAAE,QAAQ;;;;;IAM3B,EAAE,CAAQ,GAAG,EAAE,WAAW;;;;IAO1B,UAAU,CAAQ,GAAG,EAAE,WAAW,EAAU,GAAG,EAAE,aAAa;;;;;;;;;;;;IAO9D,MAAM,CAAQ,GAAG,EAAE,WAAW;;;IAM9B,OAAO,CAAQ,GAAG,EAAE,GAAG,EAAU,GAAG,EAAE,UAAU;;;;;IAKhD,cAAc,CAAS,GAAG,EAAE,iBAAiB;;;IAW7C,aAAa,CAAS,GAAG,EAAE,gBAAgB;;;CAGlD"}
|
|
@@ -1,128 +0,0 @@
|
|
|
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 refresh_dto_1 = require("./dto/refresh.dto");
|
|
21
|
-
const update_user_dto_1 = require("./dto/update-user.dto");
|
|
22
|
-
const forgot_password_dto_1 = require("./dto/forgot-password.dto");
|
|
23
|
-
const reset_password_dto_1 = require("./dto/reset-password.dto");
|
|
24
|
-
const jwt_guard_1 = require("./guards/jwt.guard");
|
|
25
|
-
let AuthController = class AuthController {
|
|
26
|
-
authService;
|
|
27
|
-
constructor(authService) {
|
|
28
|
-
this.authService = authService;
|
|
29
|
-
}
|
|
30
|
-
async register(dto) {
|
|
31
|
-
return this.authService.register(dto);
|
|
32
|
-
}
|
|
33
|
-
async login(dto) {
|
|
34
|
-
return this.authService.login(dto);
|
|
35
|
-
}
|
|
36
|
-
async me(req) {
|
|
37
|
-
return this.authService.me(req.user.sub);
|
|
38
|
-
}
|
|
39
|
-
async updateUser(req, dto) {
|
|
40
|
-
return this.authService.updateUser(req.user.sub, dto);
|
|
41
|
-
}
|
|
42
|
-
async logout(req) {
|
|
43
|
-
return this.authService.logout(req.user.sub);
|
|
44
|
-
}
|
|
45
|
-
async refresh(req, dto) {
|
|
46
|
-
return this.authService.refresh(dto);
|
|
47
|
-
}
|
|
48
|
-
async forgotPassword(dto) {
|
|
49
|
-
const token = await this.authService.forgotPassword(dto);
|
|
50
|
-
if (process.env.NODE_ENV === 'test:e2e') {
|
|
51
|
-
return token; // ✔ renvoie la string brute
|
|
52
|
-
}
|
|
53
|
-
return { message: 'Reset email sent' };
|
|
54
|
-
}
|
|
55
|
-
async resetPassword(dto) {
|
|
56
|
-
return this.authService.resetPassword(dto);
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
exports.AuthController = AuthController;
|
|
60
|
-
__decorate([
|
|
61
|
-
(0, common_1.Post)('register'),
|
|
62
|
-
__param(0, (0, common_1.Body)()),
|
|
63
|
-
__metadata("design:type", Function),
|
|
64
|
-
__metadata("design:paramtypes", [register_dto_1.RegisterDto]),
|
|
65
|
-
__metadata("design:returntype", Promise)
|
|
66
|
-
], AuthController.prototype, "register", null);
|
|
67
|
-
__decorate([
|
|
68
|
-
(0, common_1.HttpCode)(common_1.HttpStatus.OK),
|
|
69
|
-
(0, common_1.Post)('login'),
|
|
70
|
-
__param(0, (0, common_1.Body)()),
|
|
71
|
-
__metadata("design:type", Function),
|
|
72
|
-
__metadata("design:paramtypes", [login_dto_1.LoginDto]),
|
|
73
|
-
__metadata("design:returntype", Promise)
|
|
74
|
-
], AuthController.prototype, "login", null);
|
|
75
|
-
__decorate([
|
|
76
|
-
(0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
|
|
77
|
-
(0, common_1.Get)('me'),
|
|
78
|
-
__param(0, (0, common_1.Req)()),
|
|
79
|
-
__metadata("design:type", Function),
|
|
80
|
-
__metadata("design:paramtypes", [Object]),
|
|
81
|
-
__metadata("design:returntype", Promise)
|
|
82
|
-
], AuthController.prototype, "me", null);
|
|
83
|
-
__decorate([
|
|
84
|
-
(0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
|
|
85
|
-
(0, common_1.Patch)('update'),
|
|
86
|
-
(0, common_1.HttpCode)(common_1.HttpStatus.OK),
|
|
87
|
-
__param(0, (0, common_1.Req)()),
|
|
88
|
-
__param(1, (0, common_1.Body)()),
|
|
89
|
-
__metadata("design:type", Function),
|
|
90
|
-
__metadata("design:paramtypes", [Object, update_user_dto_1.UpdateUserDto]),
|
|
91
|
-
__metadata("design:returntype", Promise)
|
|
92
|
-
], AuthController.prototype, "updateUser", null);
|
|
93
|
-
__decorate([
|
|
94
|
-
(0, common_1.UseGuards)(jwt_guard_1.JwtAuthGuard),
|
|
95
|
-
(0, common_1.Post)('logout'),
|
|
96
|
-
(0, common_1.HttpCode)(common_1.HttpStatus.OK),
|
|
97
|
-
__param(0, (0, common_1.Req)()),
|
|
98
|
-
__metadata("design:type", Function),
|
|
99
|
-
__metadata("design:paramtypes", [Object]),
|
|
100
|
-
__metadata("design:returntype", Promise)
|
|
101
|
-
], AuthController.prototype, "logout", null);
|
|
102
|
-
__decorate([
|
|
103
|
-
(0, common_1.Post)('refresh'),
|
|
104
|
-
(0, common_1.HttpCode)(common_1.HttpStatus.OK),
|
|
105
|
-
__param(0, (0, common_1.Req)()),
|
|
106
|
-
__param(1, (0, common_1.Body)()),
|
|
107
|
-
__metadata("design:type", Function),
|
|
108
|
-
__metadata("design:paramtypes", [Object, refresh_dto_1.RefreshDto]),
|
|
109
|
-
__metadata("design:returntype", Promise)
|
|
110
|
-
], AuthController.prototype, "refresh", null);
|
|
111
|
-
__decorate([
|
|
112
|
-
(0, common_1.Post)('forgot-password'),
|
|
113
|
-
__param(0, (0, common_1.Body)()),
|
|
114
|
-
__metadata("design:type", Function),
|
|
115
|
-
__metadata("design:paramtypes", [forgot_password_dto_1.ForgotPasswordDto]),
|
|
116
|
-
__metadata("design:returntype", Promise)
|
|
117
|
-
], AuthController.prototype, "forgotPassword", null);
|
|
118
|
-
__decorate([
|
|
119
|
-
(0, common_1.Post)('reset-password'),
|
|
120
|
-
__param(0, (0, common_1.Body)()),
|
|
121
|
-
__metadata("design:type", Function),
|
|
122
|
-
__metadata("design:paramtypes", [reset_password_dto_1.ResetPasswordDto]),
|
|
123
|
-
__metadata("design:returntype", Promise)
|
|
124
|
-
], AuthController.prototype, "resetPassword", null);
|
|
125
|
-
exports.AuthController = AuthController = __decorate([
|
|
126
|
-
(0, common_1.Controller)('auth'),
|
|
127
|
-
__metadata("design:paramtypes", [auth_service_1.AuthService])
|
|
128
|
-
], AuthController);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth.module.d.ts","sourceRoot":"","sources":["../../src/auth/auth.module.ts"],"names":[],"mappings":"AAaA,qBAuBa,UAAU;CAAG"}
|
package/dist/auth/auth.module.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// cSpell: disable
|
|
3
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
4
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
6
|
-
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;
|
|
7
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
8
|
-
};
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.AuthModule = void 0;
|
|
11
|
-
const common_1 = require("@nestjs/common");
|
|
12
|
-
const jwt_1 = require("@nestjs/jwt");
|
|
13
|
-
const client_1 = require("@prisma/client");
|
|
14
|
-
const auth_controller_1 = require("./auth.controller");
|
|
15
|
-
const auth_service_1 = require("./auth.service");
|
|
16
|
-
const auth_repository_1 = require("./auth.repository");
|
|
17
|
-
const jwt_strategy_1 = require("./strategies/jwt.strategy");
|
|
18
|
-
const jwt_refresh_strategy_1 = require("./strategies/jwt-refresh.strategy");
|
|
19
|
-
let AuthModule = class AuthModule {
|
|
20
|
-
};
|
|
21
|
-
exports.AuthModule = AuthModule;
|
|
22
|
-
exports.AuthModule = AuthModule = __decorate([
|
|
23
|
-
(0, common_1.Module)({
|
|
24
|
-
imports: [
|
|
25
|
-
jwt_1.JwtModule.register({
|
|
26
|
-
secret: process.env.JWT_SECRET,
|
|
27
|
-
signOptions: { expiresIn: '15m' },
|
|
28
|
-
}),
|
|
29
|
-
],
|
|
30
|
-
controllers: [auth_controller_1.AuthController],
|
|
31
|
-
providers: [
|
|
32
|
-
auth_service_1.AuthService,
|
|
33
|
-
auth_repository_1.AuthRepository,
|
|
34
|
-
// PrismaClient pour une librairie NPM
|
|
35
|
-
{
|
|
36
|
-
provide: client_1.PrismaClient,
|
|
37
|
-
useValue: new client_1.PrismaClient(),
|
|
38
|
-
},
|
|
39
|
-
jwt_strategy_1.JwtStrategy,
|
|
40
|
-
jwt_refresh_strategy_1.JwtRefreshStrategy,
|
|
41
|
-
],
|
|
42
|
-
exports: [auth_service_1.AuthService],
|
|
43
|
-
})
|
|
44
|
-
], AuthModule);
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { PrismaClient } from '@prisma/client';
|
|
2
|
-
export declare class AuthRepository {
|
|
3
|
-
private prisma;
|
|
4
|
-
constructor(prisma: PrismaClient);
|
|
5
|
-
createUser(data: {
|
|
6
|
-
email: string;
|
|
7
|
-
password: string;
|
|
8
|
-
}): import(".prisma/client").Prisma.Prisma__UserClient<{
|
|
9
|
-
id: string;
|
|
10
|
-
email: string;
|
|
11
|
-
password: string;
|
|
12
|
-
refreshToken: string | null;
|
|
13
|
-
resetToken: string | null;
|
|
14
|
-
resetTokenExpiresAt: Date | null;
|
|
15
|
-
createdAt: Date;
|
|
16
|
-
updatedAt: Date;
|
|
17
|
-
}, never, import("@prisma/client/runtime/library").DefaultArgs>;
|
|
18
|
-
findByEmail(email: string): import(".prisma/client").Prisma.Prisma__UserClient<{
|
|
19
|
-
id: string;
|
|
20
|
-
email: string;
|
|
21
|
-
password: string;
|
|
22
|
-
refreshToken: string | null;
|
|
23
|
-
resetToken: string | null;
|
|
24
|
-
resetTokenExpiresAt: Date | null;
|
|
25
|
-
createdAt: Date;
|
|
26
|
-
updatedAt: Date;
|
|
27
|
-
} | null, null, import("@prisma/client/runtime/library").DefaultArgs>;
|
|
28
|
-
findById(id: string): import(".prisma/client").Prisma.Prisma__UserClient<{
|
|
29
|
-
id: string;
|
|
30
|
-
email: string;
|
|
31
|
-
password: string;
|
|
32
|
-
refreshToken: string | null;
|
|
33
|
-
resetToken: string | null;
|
|
34
|
-
resetTokenExpiresAt: Date | null;
|
|
35
|
-
createdAt: Date;
|
|
36
|
-
updatedAt: Date;
|
|
37
|
-
} | null, null, import("@prisma/client/runtime/library").DefaultArgs>;
|
|
38
|
-
updateUser(id: string, data: any): import(".prisma/client").Prisma.Prisma__UserClient<{
|
|
39
|
-
id: string;
|
|
40
|
-
email: string;
|
|
41
|
-
password: string;
|
|
42
|
-
refreshToken: string | null;
|
|
43
|
-
resetToken: string | null;
|
|
44
|
-
resetTokenExpiresAt: Date | null;
|
|
45
|
-
createdAt: Date;
|
|
46
|
-
updatedAt: Date;
|
|
47
|
-
}, never, import("@prisma/client/runtime/library").DefaultArgs>;
|
|
48
|
-
updateRefreshToken(id: string, refreshToken: string | null): import(".prisma/client").Prisma.Prisma__UserClient<{
|
|
49
|
-
id: string;
|
|
50
|
-
email: string;
|
|
51
|
-
password: string;
|
|
52
|
-
refreshToken: string | null;
|
|
53
|
-
resetToken: string | null;
|
|
54
|
-
resetTokenExpiresAt: Date | null;
|
|
55
|
-
createdAt: Date;
|
|
56
|
-
updatedAt: Date;
|
|
57
|
-
}, never, import("@prisma/client/runtime/library").DefaultArgs>;
|
|
58
|
-
clearRefreshToken(id: string): import(".prisma/client").Prisma.Prisma__UserClient<{
|
|
59
|
-
id: string;
|
|
60
|
-
email: string;
|
|
61
|
-
password: string;
|
|
62
|
-
refreshToken: string | null;
|
|
63
|
-
resetToken: string | null;
|
|
64
|
-
resetTokenExpiresAt: Date | null;
|
|
65
|
-
createdAt: Date;
|
|
66
|
-
updatedAt: Date;
|
|
67
|
-
}, never, import("@prisma/client/runtime/library").DefaultArgs>;
|
|
68
|
-
setResetToken(id: string, tokenHash: string, expiresAt: Date): import(".prisma/client").Prisma.Prisma__UserClient<{
|
|
69
|
-
id: string;
|
|
70
|
-
email: string;
|
|
71
|
-
password: string;
|
|
72
|
-
refreshToken: string | null;
|
|
73
|
-
resetToken: string | null;
|
|
74
|
-
resetTokenExpiresAt: Date | null;
|
|
75
|
-
createdAt: Date;
|
|
76
|
-
updatedAt: Date;
|
|
77
|
-
}, never, import("@prisma/client/runtime/library").DefaultArgs>;
|
|
78
|
-
/**
|
|
79
|
-
* IMPORTANT :
|
|
80
|
-
* On NE filtre PLUS l'expiration ici.
|
|
81
|
-
* Le service reset-password gère déjà :
|
|
82
|
-
* - token invalide
|
|
83
|
-
* - token expiré
|
|
84
|
-
* - token absent
|
|
85
|
-
*
|
|
86
|
-
* Donc ici on doit juste retrouver l'utilisateur par resetToken.
|
|
87
|
-
*/
|
|
88
|
-
findByResetToken(tokenHash: string): import(".prisma/client").Prisma.Prisma__UserClient<{
|
|
89
|
-
id: string;
|
|
90
|
-
email: string;
|
|
91
|
-
password: string;
|
|
92
|
-
refreshToken: string | null;
|
|
93
|
-
resetToken: string | null;
|
|
94
|
-
resetTokenExpiresAt: Date | null;
|
|
95
|
-
createdAt: Date;
|
|
96
|
-
updatedAt: Date;
|
|
97
|
-
} | null, null, import("@prisma/client/runtime/library").DefaultArgs>;
|
|
98
|
-
clearResetToken(id: string): import(".prisma/client").Prisma.Prisma__UserClient<{
|
|
99
|
-
id: string;
|
|
100
|
-
email: string;
|
|
101
|
-
password: string;
|
|
102
|
-
refreshToken: string | null;
|
|
103
|
-
resetToken: string | null;
|
|
104
|
-
resetTokenExpiresAt: Date | null;
|
|
105
|
-
createdAt: Date;
|
|
106
|
-
updatedAt: Date;
|
|
107
|
-
}, never, import("@prisma/client/runtime/library").DefaultArgs>;
|
|
108
|
-
updatePassword(id: string, hashedPassword: string): import(".prisma/client").Prisma.Prisma__UserClient<{
|
|
109
|
-
id: string;
|
|
110
|
-
email: string;
|
|
111
|
-
password: string;
|
|
112
|
-
refreshToken: string | null;
|
|
113
|
-
resetToken: string | null;
|
|
114
|
-
resetTokenExpiresAt: Date | null;
|
|
115
|
-
createdAt: Date;
|
|
116
|
-
updatedAt: Date;
|
|
117
|
-
}, never, import("@prisma/client/runtime/library").DefaultArgs>;
|
|
118
|
-
}
|
|
119
|
-
//# sourceMappingURL=auth.repository.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth.repository.d.ts","sourceRoot":"","sources":["../../src/auth/auth.repository.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,qBACa,cAAc;IACb,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,YAAY;IAMxC,UAAU,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE;;;;;;;;;;IAIpD,WAAW,CAAC,KAAK,EAAE,MAAM;;;;;;;;;;IAMzB,QAAQ,CAAC,EAAE,EAAE,MAAM;;;;;;;;;;IAMnB,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG;;;;;;;;;;IAWhC,kBAAkB,CAAC,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,IAAI;;;;;;;;;;IAO1D,iBAAiB,CAAC,EAAE,EAAE,MAAM;;;;;;;;;;IAW5B,aAAa,CAAC,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI;;;;;;;;;;IAU5D;;;;;;;;;OASG;IACH,gBAAgB,CAAC,SAAS,EAAE,MAAM;;;;;;;;;;IAQlC,eAAe,CAAC,EAAE,EAAE,MAAM;;;;;;;;;;IAU1B,cAAc,CAAC,EAAE,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM;;;;;;;;;;CAQlD"}
|