cca-auth-module 0.0.2 → 0.0.3
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/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -0
- package/dist/metafile-cjs.json +1 -1
- package/dist/metafile-esm.json +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -39,6 +39,7 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
39
39
|
// src/index.ts
|
|
40
40
|
var index_exports = {};
|
|
41
41
|
__export(index_exports, {
|
|
42
|
+
AuthController: () => AuthController,
|
|
42
43
|
createAuthContainer: () => createAuthContainer
|
|
43
44
|
});
|
|
44
45
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -564,6 +565,7 @@ function createAuthContainer(database) {
|
|
|
564
565
|
__name(createAuthContainer, "createAuthContainer");
|
|
565
566
|
// Annotate the CommonJS export names for ESM import in node:
|
|
566
567
|
0 && (module.exports = {
|
|
568
|
+
AuthController,
|
|
567
569
|
createAuthContainer
|
|
568
570
|
});
|
|
569
571
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/infrastructure/container/createAuthContainer.ts","../src/application/useCase/LoginUseCase.ts","../src/application/dtos/UserDTO.ts","../src/application/validators/authValidation.ts","../src/utils/Errors.ts","../src/application/mappers/utils/mapper.ts","../src/application/mappers/createUserMappings.ts","../src/application/dtos/RegisterDTO.ts","../src/application/useCase/RegisterUseCase.ts","../src/application/useCase/RefreshTokenUseCase.ts","../src/presentation/controller/AuthController.ts","../src/infrastructure/repository/AuthRepository.ts","../src/infrastructure/auth/JwtAuthService.ts"],"sourcesContent":["import { createAuthContainer } from \"./infrastructure/container/createAuthContainer\";\r\n\r\nexport { createAuthContainer };\r\n","import { BaseContainer, BaseDatabase } from \"cca-core\";\r\nimport { AuthEntity } from \"cca-entities\";\r\n\r\nimport { LoginUseCase } from \"../../application/useCase/LoginUseCase\";\r\nimport { RegisterUseCase } from \"../../application/useCase/RegisterUseCase\";\r\nimport { RefreshTokenUseCase } from \"../../application/useCase/RefreshTokenUseCase\";\r\n\r\nimport { AuthController } from \"../../presentation/controller/AuthController\";\r\n\r\nimport { AuthRepository } from \"../repository/AuthRepository\";\r\nimport { JwtAuthService } from \"../auth/JwtAuthService\";\r\n\r\nfunction createAuthContainer(database: BaseDatabase) {\r\n const container = new BaseContainer({ database });\r\n\r\n const authRepository = new AuthRepository(\r\n database.getRepository(AuthEntity)\r\n );\r\n container.registerRepository<AuthEntity>(\"AuthRepository\", authRepository);\r\n\r\n const jwtAuthService = new JwtAuthService(authRepository);\r\n container.registerService(\"JwtAuthService\", jwtAuthService);\r\n\r\n const loginUseCase = new LoginUseCase(authRepository, jwtAuthService);\r\n const registerUseCase = new RegisterUseCase(authRepository);\r\n const refreshTokenUseCase = new RefreshTokenUseCase(\r\n authRepository,\r\n jwtAuthService\r\n );\r\n container.registerService(\"LoginUseCase\", loginUseCase);\r\n container.registerService(\"RegisterUseCase\", registerUseCase);\r\n container.registerService(\"RefreshTokenUseCase\", refreshTokenUseCase);\r\n\r\n const authController = new AuthController(\r\n loginUseCase,\r\n registerUseCase,\r\n refreshTokenUseCase\r\n );\r\n\r\n return { container, authController };\r\n}\r\n\r\nexport { createAuthContainer };\r\n","import { IBaseService, validateRepository } from \"cca-core\";\r\nimport { AuthEntity, UserEntity, UserRole } from \"cca-entities\";\r\n\r\nimport { AuthRepository } from \"../../infrastructure/repository/AuthRepository\";\r\nimport { JwtAuthService } from \"../../infrastructure/auth/JwtAuthService\";\r\n\r\nimport { UserDTO } from \"../dtos/UserDTO\";\r\nimport { LoginDTO } from \"../dtos/LoginDTO\";\r\nimport {\r\n validateAdminSecret,\r\n validateLoginDTO,\r\n} from \"../validators/authValidation\";\r\nimport { mapper } from \"../mappers/utils/mapper\";\r\n\r\nexport class LoginUseCase implements IBaseService {\r\n private readonly repository: AuthRepository;\r\n private readonly authService: JwtAuthService;\r\n\r\n constructor(repository: AuthRepository, authService: JwtAuthService) {\r\n this.repository = repository;\r\n this.authService = authService;\r\n }\r\n\r\n public async initialize(): Promise<void> {\r\n await validateRepository(this.repository, (repo) => repo.getAll());\r\n }\r\n\r\n async execute(\r\n loginDTO: LoginDTO,\r\n adminPassword?: string\r\n ): Promise<{\r\n token: { accessToken: string; refreshToken: string };\r\n user: UserDTO;\r\n }> {\r\n const { role } = loginDTO;\r\n\r\n const auth = await validateLoginDTO(loginDTO, this.repository);\r\n\r\n if (role === UserRole.ADMIN && adminPassword) {\r\n await validateAdminSecret(adminPassword);\r\n }\r\n\r\n const token = this.generateTokens(auth);\r\n\r\n const userDTO = mapper.map(auth.user, UserEntity, UserDTO);\r\n\r\n return { token, user: userDTO };\r\n }\r\n\r\n private generateTokens(auth: AuthEntity): {\r\n accessToken: string;\r\n refreshToken: string;\r\n } {\r\n const accessToken = this.authService.generateAccessToken(auth.user);\r\n const refreshToken = this.authService.generateRefreshToken(auth.user);\r\n this.updateUserRefreshToken(auth, refreshToken); \r\n return { accessToken, refreshToken };\r\n }\r\n\r\n private async updateUserRefreshToken(\r\n auth: AuthEntity,\r\n refreshToken: string\r\n ): Promise<void> {\r\n auth.refreshToken = refreshToken;\r\n await this.repository.update(auth.id, { refreshToken });\r\n }\r\n}\r\n","import { AutoMap } from \"@automapper/classes\";\r\nimport { UserRole } from \"cca-entities\";\r\n\r\nexport class UserDTO {\r\n @AutoMap()\r\n id!: string;\r\n\r\n @AutoMap()\r\n name!: string;\r\n\r\n @AutoMap()\r\n email!: string;\r\n\r\n @AutoMap()\r\n role!: UserRole;\r\n\r\n adminPassword?: string;\r\n}","import * as yup from \"yup\";\r\nimport { AuthEntity, UserRole } from \"cca-entities\";\r\nimport bcrypt from \"bcrypt\";\r\n\r\nimport {\r\n ForbiddenError,\r\n NotFoundError,\r\n ValidationError,\r\n} from \"../../utils/Errors\";\r\nimport { AuthRepository } from \"../../infrastructure/repository/AuthRepository\";\r\nimport { ConfigFinder } from \"../../utils/ConfigFinder\";\r\n\r\nimport { RegisterDTO } from \"../dtos/RegisterDTO\";\r\nimport { LoginDTO } from \"../dtos/LoginDTO\";\r\nimport { findConfig } from \"cca-core\";\r\n\r\nconst schemas = {\r\n id: yup.string().uuid(\"Invalid user ID format\"),\r\n email: yup\r\n .string()\r\n .email(\"Invalid email format\")\r\n .max(255, \"Email cannot exceed 255 characters\"),\r\n name: yup\r\n .string()\r\n .required(\"Name is required\")\r\n .min(2, \"Name must be at least 2 characters long\")\r\n .max(50, \"Name cannot exceed 50 characters\")\r\n .matches(/^[a-zA-Z\\s]+$/, \"Name must only contain letters and spaces\"),\r\n password: yup\r\n .string()\r\n .required(\"Password is required\")\r\n .min(8, \"Password must be at least 8 characters long\")\r\n .max(100, \"Password cannot exceed 100 characters\")\r\n .matches(\r\n /^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[@$!%*?&])[A-Za-z\\d@$!%*?&]/,\r\n \"Password must contain at least one uppercase letter, one lowercase letter, one number, and one special character\"\r\n ),\r\n role: yup\r\n .string()\r\n .required(\"Role is required\")\r\n .oneOf(Object.values(UserRole), \"Invalid role specified\"),\r\n};\r\n\r\nexport const validateEmail = async (\r\n email: string,\r\n repository: AuthRepository\r\n): Promise<AuthEntity> => {\r\n try {\r\n await schemas.email.validate(email?.trim().toLowerCase());\r\n const user = await repository.findByEmail(email);\r\n if (!user) {\r\n throw new NotFoundError(\r\n \"The email address or password is incorrect. Please retry\"\r\n );\r\n }\r\n return user;\r\n } catch (error: any) {\r\n throw new ValidationError(error.message || \"Invalid email format\");\r\n }\r\n};\r\n\r\nexport const validatePassword = async (password?: string): Promise<void> => {\r\n if (password) {\r\n try {\r\n await schemas.password.validate(password);\r\n } catch (error: any) {\r\n throw new ValidationError(error.message || \"Invalid password format\");\r\n }\r\n }\r\n};\r\n\r\nexport const validateEmailUniqueness = async (\r\n repository: AuthRepository,\r\n email: string,\r\n excludeUserId?: string\r\n): Promise<void> => {\r\n try {\r\n schemas.email.validate(email);\r\n const existingUser = await repository.findByEmail(email);\r\n if (!existingUser) return;\r\n\r\n if (existingUser.id !== excludeUserId) {\r\n throw new ValidationError(\r\n `Email ${email} is already in use by another user`\r\n );\r\n }\r\n } catch (error) {\r\n if (error instanceof ValidationError) {\r\n throw error;\r\n }\r\n throw new ValidationError(\"Error checking email uniqueness\");\r\n }\r\n};\r\n\r\nexport const validateRegisterDTO = async (\r\n auth: RegisterDTO,\r\n repository: AuthRepository\r\n): Promise<void> => {\r\n const { name, email, role, password } = auth;\r\n\r\n await Promise.all([\r\n schemas.name.validate(name),\r\n schemas.role.validate(role),\r\n validateEmailUniqueness(repository, email),\r\n validatePassword(password),\r\n ]);\r\n};\r\n\r\nexport const validateLoginDTO = async (\r\n data: LoginDTO,\r\n repository: AuthRepository\r\n): Promise<AuthEntity> => {\r\n const { email, role, password } = data;\r\n\r\n await Promise.all([schemas.role.validate(role), validatePassword(password)]);\r\n\r\n const auth = await validateEmail(email, repository);\r\n const isValidPassword = await bcrypt.compare(password, auth.password);\r\n if (!isValidPassword) {\r\n throw new ForbiddenError(\r\n \"The email address or password is incorrect. Please retry\"\r\n );\r\n }\r\n\r\n return auth;\r\n};\r\n\r\nexport const validateAdminSecret = async (\r\n secretPassword?: string\r\n): Promise<void> => {\r\n if (!secretPassword) {\r\n throw new ValidationError(\"Admin password is required\");\r\n }\r\n\r\n try {\r\n const configPath = await findConfig({\r\n fileName: \"cca.config.json\",\r\n maxDepth: 10,\r\n startPath: process.cwd(),\r\n });\r\n const configContent = await import(\"fs/promises\").then((fs) =>\r\n fs.readFile(configPath, \"utf-8\")\r\n );\r\n\r\n const config = JSON.parse(configContent);\r\n\r\n if (!config.ADMIN_SECRET_PASSWORD) {\r\n throw new ValidationError(\"ADMIN_SECRET_PASSWORD not found in config\");\r\n }\r\n\r\n if (secretPassword !== config.ADMIN_SECRET_PASSWORD) {\r\n throw new ValidationError(\"Invalid admin password\");\r\n }\r\n } catch (error) {\r\n if (error instanceof ValidationError) {\r\n throw error;\r\n }\r\n throw new ValidationError(\"Error validating admin password\");\r\n }\r\n};\r\n","export class AppError extends Error {\r\n constructor(\r\n public message: string,\r\n public statusCode: number = 500,\r\n public name: string = \"AppError\"\r\n ) {\r\n super(message);\r\n Object.setPrototypeOf(this, new.target.prototype);\r\n Error.captureStackTrace(this);\r\n }\r\n}\r\n\r\nexport class ValidationError extends AppError {\r\n constructor(message: string) {\r\n super(message, 400);\r\n this.name = \"ValidationError\";\r\n }\r\n}\r\n\r\nexport class ConfigNotFoundException extends AppError {\r\n constructor(message: string) {\r\n super(message);\r\n this.name = \"ConfigNotFoundException\";\r\n }\r\n}\r\n\r\nexport class NotFoundError extends AppError {\r\n constructor(message: string) {\r\n super(message, 404, \"UserNotFoundError\");\r\n }\r\n}\r\n\r\nexport class ForbiddenError extends AppError {\r\n constructor(message: string = \"Forbidden access\") {\r\n super(message, 403);\r\n this.name = \"ForbiddenError\";\r\n }\r\n}\r\n\r\nexport class UnauthorizedError extends AppError {\r\n constructor(message: string = \"Unauthorized access\") {\r\n super(message, 401);\r\n this.name = \"UnauthorizedError\";\r\n }\r\n}\r\n","import { createMapper } from '@automapper/core';\r\nimport { classes } from '@automapper/classes';\r\n\r\nimport { createUserMappings } from '../createUserMappings';\r\n\r\nexport const mapper = createMapper({\r\n strategyInitializer: classes(),\r\n});\r\n\r\ncreateUserMappings(mapper);\r\n","import { Mapper, createMap, forMember, mapFrom } from '@automapper/core';\r\nimport { AuthEntity, UserEntity } from 'cca-entities';\r\n\r\nimport { RegisterDTO } from '../dtos/RegisterDTO';\r\nimport { UserDTO } from '../dtos/UserDTO';\r\n\r\nexport function createUserMappings(mapper: Mapper): void {\r\n createMap(\r\n mapper,\r\n AuthEntity,\r\n RegisterDTO,\r\n forMember(dest => dest.email, mapFrom(src => src.email)),\r\n forMember(dest => dest.password, mapFrom(src => src.password)),\r\n forMember(dest => dest.role, mapFrom(src => src.role)));\r\n\r\n createMap(\r\n mapper,\r\n UserEntity,\r\n RegisterDTO,\r\n forMember(dest => dest.name, mapFrom(src => src.name)),\r\n forMember(dest => dest.email, mapFrom(src => src.email)),\r\n forMember(dest => dest.role, mapFrom(src => src.role)));\r\n\r\n createMap(\r\n mapper,\r\n UserEntity,\r\n UserDTO,\r\n forMember(dest => dest.id, mapFrom(src => src.id)),\r\n forMember(dest => dest.name, mapFrom(src => src.name)),\r\n forMember(dest => dest.email, mapFrom(src => src.email)),\r\n forMember(dest => dest.role, mapFrom(src => src.role)));\r\n}","import { UserRole } from \"cca-entities\";\r\n\r\nexport class RegisterDTO {\r\n email!: string;\r\n name!: string;\r\n password!: string;\r\n role!: UserRole;\r\n adminPassword?: string;\r\n}\r\n","import { IBaseService, validateRepository } from \"cca-core\";\r\nimport * as bcrypt from \"bcrypt\";\r\nimport { AuthEntity, UserEntity, UserRole } from \"cca-entities\";\r\n\r\nimport { AuthRepository } from \"../../infrastructure/repository/AuthRepository\";\r\n\r\nimport { mapper } from \"../mappers/utils/mapper\";\r\nimport { RegisterDTO } from \"../dtos/RegisterDTO\";\r\nimport { validateRegisterDTO } from \"../validators/authValidation\";\r\n\r\nexport class RegisterUseCase implements IBaseService {\r\n private readonly repository: AuthRepository;\r\n private readonly SALT_ROUNDS = 10;\r\n\r\n constructor(repository: AuthRepository) {\r\n this.repository = repository;\r\n }\r\n\r\n public async initialize(): Promise<void> {\r\n await validateRepository(this.repository, (repo) => repo.getAll());\r\n }\r\n\r\n public async execute(\r\n email: string,\r\n name: string,\r\n password: string,\r\n role: UserRole = UserRole.GUEST\r\n ): Promise<AuthEntity> {\r\n try {\r\n const normalizedDTO = this.normalizeAuthDTO({\r\n email,\r\n name,\r\n password,\r\n role,\r\n });\r\n\r\n await validateRegisterDTO(normalizedDTO, this.repository);\r\n\r\n const hashedPassword = await this.hashPassword(normalizedDTO.password);\r\n const authEntity = await this.createAuthEntity(\r\n normalizedDTO,\r\n hashedPassword\r\n );\r\n\r\n return await this.repository.create(authEntity);\r\n } catch (error) {\r\n throw error instanceof Error ? error : new Error(\"Registration failed\");\r\n }\r\n }\r\n\r\n private normalizeAuthDTO(dto: RegisterDTO): RegisterDTO {\r\n return {\r\n name: dto.name.trim(),\r\n email: dto.email.trim().toLowerCase(),\r\n role: dto.role,\r\n password: dto.password.trim(),\r\n };\r\n }\r\n\r\n private async hashPassword(password: string): Promise<string> {\r\n return await bcrypt.hash(password, this.SALT_ROUNDS);\r\n }\r\n\r\n private async createAuthEntity(\r\n dto: RegisterDTO,\r\n hashedPassword: string\r\n ): Promise<AuthEntity> {\r\n const authEntity = mapper.map(dto, RegisterDTO, AuthEntity);\r\n authEntity.password = hashedPassword;\r\n\r\n const userEntity = mapper.map(dto, RegisterDTO, UserEntity);\r\n authEntity.user.createdAt = userEntity.createdAt;\r\n authEntity.user = userEntity;\r\n\r\n return authEntity;\r\n }\r\n}\r\n","import { IBaseService, validateRepository } from \"cca-core\";\r\n\r\nimport { IDecodedToken } from \"../../domain/interfaces/IDecodedToken\";\r\n\r\nimport { JwtAuthService } from \"../../infrastructure/auth/JwtAuthService\";\r\nimport { AuthRepository } from \"../../infrastructure/repository/AuthRepository\";\r\n\r\nexport class RefreshTokenUseCase implements IBaseService {\r\n private readonly repository: AuthRepository;\r\n private readonly service: JwtAuthService;\r\n\r\n constructor(repository: AuthRepository, service: JwtAuthService) {\r\n this.repository = repository;\r\n this.service = service;\r\n }\r\n\r\n public async initialize(): Promise<void> {\r\n await validateRepository(this.repository, (repo) => repo.getAll());\r\n }\r\n\r\n async execute(\r\n refreshToken: string\r\n ): Promise<{ accessToken: string; refreshToken: string } | null> {\r\n try {\r\n const decoded = await this.service.verifyRefreshToken(refreshToken);\r\n\r\n const auth = decoded.userId\r\n ? await this.repository.findById(decoded.userId)\r\n : null;\r\n\r\n if (!auth || auth.refreshToken !== refreshToken) {\r\n return null;\r\n }\r\n\r\n const accessToken = this.service.generateAccessToken(auth.user);\r\n const newRefreshToken = this.service.generateRefreshToken(auth.user);\r\n\r\n await this.repository.update(auth.id, {\r\n refreshToken: newRefreshToken,\r\n });\r\n\r\n return { accessToken, refreshToken: newRefreshToken };\r\n } catch (error) {\r\n return null;\r\n }\r\n }\r\n\r\n async verityToken(token: string): Promise<IDecodedToken> {\r\n return await this.service.verifyAccessToken(token);\r\n }\r\n}\r\n","import { NextFunction, Request, Response } from \"express\";\r\n\r\nimport { LoginDTO } from \"../../application/dtos/LoginDTO\";\r\nimport { RegisterDTO } from \"../../application/dtos/RegisterDTO\";\r\n\r\nimport { RegisterUseCase } from \"../../application/useCase/RegisterUseCase\";\r\nimport { LoginUseCase } from \"../../application/useCase/LoginUseCase\";\r\nimport { RefreshTokenUseCase } from \"../../application/useCase/RefreshTokenUseCase\";\r\n\r\nimport { IRefreshTokenRequest } from \"../../domain/interfaces/IRefreshTokenRequest\";\r\nimport { IDecodedToken } from \"../../domain/interfaces/IDecodedToken\";\r\n\r\n\r\nexport class AuthController {\r\n private loginUseCase: LoginUseCase;\r\n private registerUseCase: RegisterUseCase;\r\n private refreshTokenUseCase: RefreshTokenUseCase;\r\n\r\n constructor(\r\n loginUseCase: LoginUseCase,\r\n registerUseCase: RegisterUseCase,\r\n refreshTokenUseCase: RefreshTokenUseCase\r\n ) {\r\n this.loginUseCase = loginUseCase;\r\n this.registerUseCase = registerUseCase;\r\n this.refreshTokenUseCase = refreshTokenUseCase;\r\n }\r\n\r\n login = async (req: Request, res: Response, next: NextFunction) => {\r\n try {\r\n const { adminPassword, ...loginDTO }: LoginDTO = req.body;\r\n const result = await this.loginUseCase.execute(loginDTO, adminPassword);\r\n res.status(201).json(result);\r\n } catch (error) {\r\n next(error);\r\n }\r\n };\r\n\r\n register = async (\r\n req: Request,\r\n res: Response,\r\n next: NextFunction\r\n ): Promise<void> => {\r\n try {\r\n const { email, name, password, role }: RegisterDTO = req.body;\r\n await this.registerUseCase.execute(email, name, password, role);\r\n } catch (error) {\r\n next(error);\r\n }\r\n };\r\n\r\n refreshToken = async (req: Request, res: Response) => {\r\n const { refreshToken }: IRefreshTokenRequest = req.body;\r\n const result = await this.refreshTokenUseCase.execute(refreshToken);\r\n res.json(result);\r\n };\r\n\r\n verifyToken = async (token: string): Promise<IDecodedToken> => {\r\n return await this.refreshTokenUseCase.verityToken(token);\r\n };\r\n}\r\n","import { BaseRepository, IBaseRepository, IExtendedBaseRepository } from \"cca-core\";\r\nimport { AuthEntity } from \"cca-entities\";\r\nimport { Repository } from \"typeorm\";\r\n\r\nexport class AuthRepository\r\n extends BaseRepository<AuthEntity>\r\n implements IExtendedBaseRepository<AuthEntity>\r\n{\r\n constructor(repository: Repository<AuthEntity>) {\r\n super(repository);\r\n }\r\n\r\n async findByEmail(email: string): Promise<AuthEntity | null> {\r\n return await this.repository.findOne({\r\n where: { email },\r\n relations: [\"users\"],\r\n });\r\n }\r\n\r\n async create(entity: Omit<AuthEntity, \"createdAt\">): Promise<AuthEntity> {\r\n return super.create(entity);\r\n }\r\n}\r\n","import * as jwt from \"jsonwebtoken\";\r\nimport * as bcrypt from \"bcrypt\";\r\nimport { IBaseService, validateRepository } from \"cca-core\";\r\nimport { AuthEntity, UserEntity } from \"cca-entities\";\r\n\r\nimport { IJwtConfig } from \"../../domain/interfaces/IJwtConfig\";\r\nimport { IAuthService } from \"../../domain/interfaces/IAuthService\";\r\nimport { IDecodedToken } from \"../../domain/interfaces/IDecodedToken\";\r\n\r\nimport {\r\n ForbiddenError,\r\n NotFoundError,\r\n UnauthorizedError,\r\n} from \"../../utils/Errors\";\r\n\r\nimport { AuthRepository } from \"../repository/AuthRepository\";\r\n\r\nexport class JwtAuthService implements IBaseService, IAuthService {\r\n private readonly jwtConfig: IJwtConfig;\r\n private readonly repository: AuthRepository;\r\n\r\n constructor(repository: AuthRepository, config?: IJwtConfig) {\r\n this.repository = repository;\r\n this.jwtConfig = {\r\n accessTokenSecret:\r\n process.env.JWT_ACCESS_SECRET || \"default-access-secret\",\r\n refreshTokenSecret:\r\n process.env.JWT_REFRESH_SECRET || \"default-refresh-secret\",\r\n accessTokenExpiry: \"15m\",\r\n refreshTokenExpiry: \"7d\",\r\n };\r\n if (config) {\r\n this.jwtConfig = {\r\n ...this.jwtConfig,\r\n ...config,\r\n };\r\n }\r\n\r\n this.validateConfiguration();\r\n }\r\n \r\n public async initialize(): Promise<void> {\r\n await validateRepository(this.repository, (repo) => repo.getAll());\r\n }\r\n\r\n private validateConfiguration(): void {\r\n if (\r\n !this.jwtConfig.accessTokenSecret ||\r\n !this.jwtConfig.refreshTokenSecret\r\n ) {\r\n throw new Error(\r\n \"JWT secrets must be defined in environment variables or configuration\"\r\n );\r\n }\r\n }\r\n\r\n async validateUser(\r\n email: string,\r\n password: string\r\n ): Promise<AuthEntity | null> {\r\n try {\r\n const user = await this.repository.findByEmail(email);\r\n\r\n if (!user) {\r\n throw new NotFoundError(\r\n \"The email address or password is incorrect. Please retry\"\r\n );\r\n }\r\n\r\n const isValidPassword = await bcrypt.compare(password, user.password);\r\n if (!isValidPassword) {\r\n throw new ForbiddenError(\r\n \"The email address or password is incorrect. Please retry\"\r\n );\r\n }\r\n\r\n return user;\r\n } catch (error: any) {\r\n if (error instanceof NotFoundError || error instanceof ForbiddenError) {\r\n throw error;\r\n }\r\n throw new Error(`Authentication failed: ${error.message}`);\r\n }\r\n }\r\n\r\n generateAccessToken(user: UserEntity): string {\r\n return jwt.sign(\r\n {\r\n userId: user.id,\r\n email: user.email,\r\n role: user.role,\r\n },\r\n this.jwtConfig.accessTokenSecret,\r\n { expiresIn: this.jwtConfig.accessTokenExpiry }\r\n );\r\n }\r\n\r\n generateRefreshToken(user: UserEntity): string {\r\n return jwt.sign({ userId: user.id }, this.jwtConfig.refreshTokenSecret, {\r\n expiresIn: this.jwtConfig.refreshTokenExpiry,\r\n });\r\n }\r\n\r\n async verifyAccessToken(token: string): Promise<IDecodedToken> {\r\n return this.verifyToken(token, this.jwtConfig.accessTokenSecret);\r\n }\r\n\r\n async verifyRefreshToken(token: string): Promise<IDecodedToken> {\r\n return this.verifyToken(token, this.jwtConfig.refreshTokenSecret);\r\n }\r\n\r\n private async verifyToken(\r\n token: string,\r\n secret: string\r\n ): Promise<IDecodedToken> {\r\n try {\r\n return jwt.verify(token, secret) as IDecodedToken;\r\n } catch (error) {\r\n if (\r\n error instanceof jwt.TokenExpiredError ||\r\n error instanceof jwt.JsonWebTokenError\r\n ) {\r\n throw new UnauthorizedError();\r\n }\r\n throw new UnauthorizedError();\r\n }\r\n }\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,mBAA4C;AAC5C,IAAAC,uBAA2B;;;ACD3B,IAAAC,mBAAiD;AACjD,IAAAC,uBAAiD;;;ACDjD,qBAAwB;AAGjB,IAAM,WAAN,MAAM,SAAQ;AAcrB;AAdqB;AAEnB;AAAA,MADC,wBAAQ;AAAA,GADE,SAEX;AAGA;AAAA,MADC,wBAAQ;AAAA,GAJE,SAKX;AAGA;AAAA,MADC,wBAAQ;AAAA,GAPE,SAQX;AAGA;AAAA,MADC,wBAAQ;AAAA,GAVE,SAWX;AAXK,IAAM,UAAN;;;ACHP,UAAqB;AACrB,0BAAqC;AACrC,oBAAmB;;;ACFZ,IAAM,YAAN,MAAM,kBAAiB,MAAM;AAAA,EAClC,YACS,SACA,aAAqB,KACrB,OAAe,YACtB;AACA,UAAM,OAAO;AAJN;AACA;AACA;AAGP,WAAO,eAAe,MAAM,WAAW,SAAS;AAChD,UAAM,kBAAkB,IAAI;AAAA,EAC9B;AACF;AAVoC;AAA7B,IAAM,WAAN;AAYA,IAAM,mBAAN,MAAM,yBAAwB,SAAS;AAAA,EAC5C,YAAY,SAAiB;AAC3B,UAAM,SAAS,GAAG;AAClB,SAAK,OAAO;AAAA,EACd;AACF;AAL8C;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Ae,IAAI,aAAa,gBAAgB,cAAc;AACpE,QAAM,kBAAkB,IAAI,gBAAgB,cAAc;AAC1D,QAAM,sBAAsB,IAAI;AAAA,IAC9B;AAAA,IACA;AAAA,EACF;AACA,YAAU,gBAAgB,gBAAgB,YAAY;AACtD,YAAU,gBAAgB,mBAAmB,eAAe;AAC5D,YAAU,gBAAgB,uBAAuB,mBAAmB;AAEpE,QAAM,iBAAiB,IAAI;AAAA,IACzB;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,SAAO,EAAE,WAAW,eAAe;AACrC;AA5BS;","names":["import_cca_core","import_cca_entities","import_cca_core","import_cca_entities","bcrypt","import_core","import_classes","import_cca_entities","mapper","import_cca_core","bcrypt","import_cca_entities","import_cca_core","import_cca_core","bcrypt","import_cca_core"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/infrastructure/container/createAuthContainer.ts","../src/application/useCase/LoginUseCase.ts","../src/application/dtos/UserDTO.ts","../src/application/validators/authValidation.ts","../src/utils/Errors.ts","../src/application/mappers/utils/mapper.ts","../src/application/mappers/createUserMappings.ts","../src/application/dtos/RegisterDTO.ts","../src/application/useCase/RegisterUseCase.ts","../src/application/useCase/RefreshTokenUseCase.ts","../src/presentation/controller/AuthController.ts","../src/infrastructure/repository/AuthRepository.ts","../src/infrastructure/auth/JwtAuthService.ts"],"sourcesContent":["import { createAuthContainer } from \"./infrastructure/container/createAuthContainer\";\r\nimport { AuthController } from \"./presentation/controller/AuthController\";\r\n\r\nexport { createAuthContainer, AuthController};\r\n","import { BaseContainer, BaseDatabase } from \"cca-core\";\r\nimport { AuthEntity } from \"cca-entities\";\r\n\r\nimport { LoginUseCase } from \"../../application/useCase/LoginUseCase\";\r\nimport { RegisterUseCase } from \"../../application/useCase/RegisterUseCase\";\r\nimport { RefreshTokenUseCase } from \"../../application/useCase/RefreshTokenUseCase\";\r\n\r\nimport { AuthController } from \"../../presentation/controller/AuthController\";\r\n\r\nimport { AuthRepository } from \"../repository/AuthRepository\";\r\nimport { JwtAuthService } from \"../auth/JwtAuthService\";\r\n\r\nfunction createAuthContainer(database: BaseDatabase) {\r\n const container = new BaseContainer({ database });\r\n\r\n const authRepository = new AuthRepository(\r\n database.getRepository(AuthEntity)\r\n );\r\n container.registerRepository<AuthEntity>(\"AuthRepository\", authRepository);\r\n\r\n const jwtAuthService = new JwtAuthService(authRepository);\r\n container.registerService(\"JwtAuthService\", jwtAuthService);\r\n\r\n const loginUseCase = new LoginUseCase(authRepository, jwtAuthService);\r\n const registerUseCase = new RegisterUseCase(authRepository);\r\n const refreshTokenUseCase = new RefreshTokenUseCase(\r\n authRepository,\r\n jwtAuthService\r\n );\r\n container.registerService(\"LoginUseCase\", loginUseCase);\r\n container.registerService(\"RegisterUseCase\", registerUseCase);\r\n container.registerService(\"RefreshTokenUseCase\", refreshTokenUseCase);\r\n\r\n const authController = new AuthController(\r\n loginUseCase,\r\n registerUseCase,\r\n refreshTokenUseCase\r\n );\r\n\r\n return { container, authController };\r\n}\r\n\r\nexport { createAuthContainer };\r\n","import { IBaseService, validateRepository } from \"cca-core\";\r\nimport { AuthEntity, UserEntity, UserRole } from \"cca-entities\";\r\n\r\nimport { AuthRepository } from \"../../infrastructure/repository/AuthRepository\";\r\nimport { JwtAuthService } from \"../../infrastructure/auth/JwtAuthService\";\r\n\r\nimport { UserDTO } from \"../dtos/UserDTO\";\r\nimport { LoginDTO } from \"../dtos/LoginDTO\";\r\nimport {\r\n validateAdminSecret,\r\n validateLoginDTO,\r\n} from \"../validators/authValidation\";\r\nimport { mapper } from \"../mappers/utils/mapper\";\r\n\r\nexport class LoginUseCase implements IBaseService {\r\n private readonly repository: AuthRepository;\r\n private readonly authService: JwtAuthService;\r\n\r\n constructor(repository: AuthRepository, authService: JwtAuthService) {\r\n this.repository = repository;\r\n this.authService = authService;\r\n }\r\n\r\n public async initialize(): Promise<void> {\r\n await validateRepository(this.repository, (repo) => repo.getAll());\r\n }\r\n\r\n async execute(\r\n loginDTO: LoginDTO,\r\n adminPassword?: string\r\n ): Promise<{\r\n token: { accessToken: string; refreshToken: string };\r\n user: UserDTO;\r\n }> {\r\n const { role } = loginDTO;\r\n\r\n const auth = await validateLoginDTO(loginDTO, this.repository);\r\n\r\n if (role === UserRole.ADMIN && adminPassword) {\r\n await validateAdminSecret(adminPassword);\r\n }\r\n\r\n const token = this.generateTokens(auth);\r\n\r\n const userDTO = mapper.map(auth.user, UserEntity, UserDTO);\r\n\r\n return { token, user: userDTO };\r\n }\r\n\r\n private generateTokens(auth: AuthEntity): {\r\n accessToken: string;\r\n refreshToken: string;\r\n } {\r\n const accessToken = this.authService.generateAccessToken(auth.user);\r\n const refreshToken = this.authService.generateRefreshToken(auth.user);\r\n this.updateUserRefreshToken(auth, refreshToken); \r\n return { accessToken, refreshToken };\r\n }\r\n\r\n private async updateUserRefreshToken(\r\n auth: AuthEntity,\r\n refreshToken: string\r\n ): Promise<void> {\r\n auth.refreshToken = refreshToken;\r\n await this.repository.update(auth.id, { refreshToken });\r\n }\r\n}\r\n","import { AutoMap } from \"@automapper/classes\";\r\nimport { UserRole } from \"cca-entities\";\r\n\r\nexport class UserDTO {\r\n @AutoMap()\r\n id!: string;\r\n\r\n @AutoMap()\r\n name!: string;\r\n\r\n @AutoMap()\r\n email!: string;\r\n\r\n @AutoMap()\r\n role!: UserRole;\r\n\r\n adminPassword?: string;\r\n}","import * as yup from \"yup\";\r\nimport { AuthEntity, UserRole } from \"cca-entities\";\r\nimport bcrypt from \"bcrypt\";\r\n\r\nimport {\r\n ForbiddenError,\r\n NotFoundError,\r\n ValidationError,\r\n} from \"../../utils/Errors\";\r\nimport { AuthRepository } from \"../../infrastructure/repository/AuthRepository\";\r\nimport { ConfigFinder } from \"../../utils/ConfigFinder\";\r\n\r\nimport { RegisterDTO } from \"../dtos/RegisterDTO\";\r\nimport { LoginDTO } from \"../dtos/LoginDTO\";\r\nimport { findConfig } from \"cca-core\";\r\n\r\nconst schemas = {\r\n id: yup.string().uuid(\"Invalid user ID format\"),\r\n email: yup\r\n .string()\r\n .email(\"Invalid email format\")\r\n .max(255, \"Email cannot exceed 255 characters\"),\r\n name: yup\r\n .string()\r\n .required(\"Name is required\")\r\n .min(2, \"Name must be at least 2 characters long\")\r\n .max(50, \"Name cannot exceed 50 characters\")\r\n .matches(/^[a-zA-Z\\s]+$/, \"Name must only contain letters and spaces\"),\r\n password: yup\r\n .string()\r\n .required(\"Password is required\")\r\n .min(8, \"Password must be at least 8 characters long\")\r\n .max(100, \"Password cannot exceed 100 characters\")\r\n .matches(\r\n /^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[@$!%*?&])[A-Za-z\\d@$!%*?&]/,\r\n \"Password must contain at least one uppercase letter, one lowercase letter, one number, and one special character\"\r\n ),\r\n role: yup\r\n .string()\r\n .required(\"Role is required\")\r\n .oneOf(Object.values(UserRole), \"Invalid role specified\"),\r\n};\r\n\r\nexport const validateEmail = async (\r\n email: string,\r\n repository: AuthRepository\r\n): Promise<AuthEntity> => {\r\n try {\r\n await schemas.email.validate(email?.trim().toLowerCase());\r\n const user = await repository.findByEmail(email);\r\n if (!user) {\r\n throw new NotFoundError(\r\n \"The email address or password is incorrect. Please retry\"\r\n );\r\n }\r\n return user;\r\n } catch (error: any) {\r\n throw new ValidationError(error.message || \"Invalid email format\");\r\n }\r\n};\r\n\r\nexport const validatePassword = async (password?: string): Promise<void> => {\r\n if (password) {\r\n try {\r\n await schemas.password.validate(password);\r\n } catch (error: any) {\r\n throw new ValidationError(error.message || \"Invalid password format\");\r\n }\r\n }\r\n};\r\n\r\nexport const validateEmailUniqueness = async (\r\n repository: AuthRepository,\r\n email: string,\r\n excludeUserId?: string\r\n): Promise<void> => {\r\n try {\r\n schemas.email.validate(email);\r\n const existingUser = await repository.findByEmail(email);\r\n if (!existingUser) return;\r\n\r\n if (existingUser.id !== excludeUserId) {\r\n throw new ValidationError(\r\n `Email ${email} is already in use by another user`\r\n );\r\n }\r\n } catch (error) {\r\n if (error instanceof ValidationError) {\r\n throw error;\r\n }\r\n throw new ValidationError(\"Error checking email uniqueness\");\r\n }\r\n};\r\n\r\nexport const validateRegisterDTO = async (\r\n auth: RegisterDTO,\r\n repository: AuthRepository\r\n): Promise<void> => {\r\n const { name, email, role, password } = auth;\r\n\r\n await Promise.all([\r\n schemas.name.validate(name),\r\n schemas.role.validate(role),\r\n validateEmailUniqueness(repository, email),\r\n validatePassword(password),\r\n ]);\r\n};\r\n\r\nexport const validateLoginDTO = async (\r\n data: LoginDTO,\r\n repository: AuthRepository\r\n): Promise<AuthEntity> => {\r\n const { email, role, password } = data;\r\n\r\n await Promise.all([schemas.role.validate(role), validatePassword(password)]);\r\n\r\n const auth = await validateEmail(email, repository);\r\n const isValidPassword = await bcrypt.compare(password, auth.password);\r\n if (!isValidPassword) {\r\n throw new ForbiddenError(\r\n \"The email address or password is incorrect. Please retry\"\r\n );\r\n }\r\n\r\n return auth;\r\n};\r\n\r\nexport const validateAdminSecret = async (\r\n secretPassword?: string\r\n): Promise<void> => {\r\n if (!secretPassword) {\r\n throw new ValidationError(\"Admin password is required\");\r\n }\r\n\r\n try {\r\n const configPath = await findConfig({\r\n fileName: \"cca.config.json\",\r\n maxDepth: 10,\r\n startPath: process.cwd(),\r\n });\r\n const configContent = await import(\"fs/promises\").then((fs) =>\r\n fs.readFile(configPath, \"utf-8\")\r\n );\r\n\r\n const config = JSON.parse(configContent);\r\n\r\n if (!config.ADMIN_SECRET_PASSWORD) {\r\n throw new ValidationError(\"ADMIN_SECRET_PASSWORD not found in config\");\r\n }\r\n\r\n if (secretPassword !== config.ADMIN_SECRET_PASSWORD) {\r\n throw new ValidationError(\"Invalid admin password\");\r\n }\r\n } catch (error) {\r\n if (error instanceof ValidationError) {\r\n throw error;\r\n }\r\n throw new ValidationError(\"Error validating admin password\");\r\n }\r\n};\r\n","export class AppError extends Error {\r\n constructor(\r\n public message: string,\r\n public statusCode: number = 500,\r\n public name: string = \"AppError\"\r\n ) {\r\n super(message);\r\n Object.setPrototypeOf(this, new.target.prototype);\r\n Error.captureStackTrace(this);\r\n }\r\n}\r\n\r\nexport class ValidationError extends AppError {\r\n constructor(message: string) {\r\n super(message, 400);\r\n this.name = \"ValidationError\";\r\n }\r\n}\r\n\r\nexport class ConfigNotFoundException extends AppError {\r\n constructor(message: string) {\r\n super(message);\r\n this.name = \"ConfigNotFoundException\";\r\n }\r\n}\r\n\r\nexport class NotFoundError extends AppError {\r\n constructor(message: string) {\r\n super(message, 404, \"UserNotFoundError\");\r\n }\r\n}\r\n\r\nexport class ForbiddenError extends AppError {\r\n constructor(message: string = \"Forbidden access\") {\r\n super(message, 403);\r\n this.name = \"ForbiddenError\";\r\n }\r\n}\r\n\r\nexport class UnauthorizedError extends AppError {\r\n constructor(message: string = \"Unauthorized access\") {\r\n super(message, 401);\r\n this.name = \"UnauthorizedError\";\r\n }\r\n}\r\n","import { createMapper } from '@automapper/core';\r\nimport { classes } from '@automapper/classes';\r\n\r\nimport { createUserMappings } from '../createUserMappings';\r\n\r\nexport const mapper = createMapper({\r\n strategyInitializer: classes(),\r\n});\r\n\r\ncreateUserMappings(mapper);\r\n","import { Mapper, createMap, forMember, mapFrom } from '@automapper/core';\r\nimport { AuthEntity, UserEntity } from 'cca-entities';\r\n\r\nimport { RegisterDTO } from '../dtos/RegisterDTO';\r\nimport { UserDTO } from '../dtos/UserDTO';\r\n\r\nexport function createUserMappings(mapper: Mapper): void {\r\n createMap(\r\n mapper,\r\n AuthEntity,\r\n RegisterDTO,\r\n forMember(dest => dest.email, mapFrom(src => src.email)),\r\n forMember(dest => dest.password, mapFrom(src => src.password)),\r\n forMember(dest => dest.role, mapFrom(src => src.role)));\r\n\r\n createMap(\r\n mapper,\r\n UserEntity,\r\n RegisterDTO,\r\n forMember(dest => dest.name, mapFrom(src => src.name)),\r\n forMember(dest => dest.email, mapFrom(src => src.email)),\r\n forMember(dest => dest.role, mapFrom(src => src.role)));\r\n\r\n createMap(\r\n mapper,\r\n UserEntity,\r\n UserDTO,\r\n forMember(dest => dest.id, mapFrom(src => src.id)),\r\n forMember(dest => dest.name, mapFrom(src => src.name)),\r\n forMember(dest => dest.email, mapFrom(src => src.email)),\r\n forMember(dest => dest.role, mapFrom(src => src.role)));\r\n}","import { UserRole } from \"cca-entities\";\r\n\r\nexport class RegisterDTO {\r\n email!: string;\r\n name!: string;\r\n password!: string;\r\n role!: UserRole;\r\n adminPassword?: string;\r\n}\r\n","import { IBaseService, validateRepository } from \"cca-core\";\r\nimport * as bcrypt from \"bcrypt\";\r\nimport { AuthEntity, UserEntity, UserRole } from \"cca-entities\";\r\n\r\nimport { AuthRepository } from \"../../infrastructure/repository/AuthRepository\";\r\n\r\nimport { mapper } from \"../mappers/utils/mapper\";\r\nimport { RegisterDTO } from \"../dtos/RegisterDTO\";\r\nimport { validateRegisterDTO } from \"../validators/authValidation\";\r\n\r\nexport class RegisterUseCase implements IBaseService {\r\n private readonly repository: AuthRepository;\r\n private readonly SALT_ROUNDS = 10;\r\n\r\n constructor(repository: AuthRepository) {\r\n this.repository = repository;\r\n }\r\n\r\n public async initialize(): Promise<void> {\r\n await validateRepository(this.repository, (repo) => repo.getAll());\r\n }\r\n\r\n public async execute(\r\n email: string,\r\n name: string,\r\n password: string,\r\n role: UserRole = UserRole.GUEST\r\n ): Promise<AuthEntity> {\r\n try {\r\n const normalizedDTO = this.normalizeAuthDTO({\r\n email,\r\n name,\r\n password,\r\n role,\r\n });\r\n\r\n await validateRegisterDTO(normalizedDTO, this.repository);\r\n\r\n const hashedPassword = await this.hashPassword(normalizedDTO.password);\r\n const authEntity = await this.createAuthEntity(\r\n normalizedDTO,\r\n hashedPassword\r\n );\r\n\r\n return await this.repository.create(authEntity);\r\n } catch (error) {\r\n throw error instanceof Error ? error : new Error(\"Registration failed\");\r\n }\r\n }\r\n\r\n private normalizeAuthDTO(dto: RegisterDTO): RegisterDTO {\r\n return {\r\n name: dto.name.trim(),\r\n email: dto.email.trim().toLowerCase(),\r\n role: dto.role,\r\n password: dto.password.trim(),\r\n };\r\n }\r\n\r\n private async hashPassword(password: string): Promise<string> {\r\n return await bcrypt.hash(password, this.SALT_ROUNDS);\r\n }\r\n\r\n private async createAuthEntity(\r\n dto: RegisterDTO,\r\n hashedPassword: string\r\n ): Promise<AuthEntity> {\r\n const authEntity = mapper.map(dto, RegisterDTO, AuthEntity);\r\n authEntity.password = hashedPassword;\r\n\r\n const userEntity = mapper.map(dto, RegisterDTO, UserEntity);\r\n authEntity.user.createdAt = userEntity.createdAt;\r\n authEntity.user = userEntity;\r\n\r\n return authEntity;\r\n }\r\n}\r\n","import { IBaseService, validateRepository } from \"cca-core\";\r\n\r\nimport { IDecodedToken } from \"../../domain/interfaces/IDecodedToken\";\r\n\r\nimport { JwtAuthService } from \"../../infrastructure/auth/JwtAuthService\";\r\nimport { AuthRepository } from \"../../infrastructure/repository/AuthRepository\";\r\n\r\nexport class RefreshTokenUseCase implements IBaseService {\r\n private readonly repository: AuthRepository;\r\n private readonly service: JwtAuthService;\r\n\r\n constructor(repository: AuthRepository, service: JwtAuthService) {\r\n this.repository = repository;\r\n this.service = service;\r\n }\r\n\r\n public async initialize(): Promise<void> {\r\n await validateRepository(this.repository, (repo) => repo.getAll());\r\n }\r\n\r\n async execute(\r\n refreshToken: string\r\n ): Promise<{ accessToken: string; refreshToken: string } | null> {\r\n try {\r\n const decoded = await this.service.verifyRefreshToken(refreshToken);\r\n\r\n const auth = decoded.userId\r\n ? await this.repository.findById(decoded.userId)\r\n : null;\r\n\r\n if (!auth || auth.refreshToken !== refreshToken) {\r\n return null;\r\n }\r\n\r\n const accessToken = this.service.generateAccessToken(auth.user);\r\n const newRefreshToken = this.service.generateRefreshToken(auth.user);\r\n\r\n await this.repository.update(auth.id, {\r\n refreshToken: newRefreshToken,\r\n });\r\n\r\n return { accessToken, refreshToken: newRefreshToken };\r\n } catch (error) {\r\n return null;\r\n }\r\n }\r\n\r\n async verityToken(token: string): Promise<IDecodedToken> {\r\n return await this.service.verifyAccessToken(token);\r\n }\r\n}\r\n","import { NextFunction, Request, Response } from \"express\";\r\n\r\nimport { LoginDTO } from \"../../application/dtos/LoginDTO\";\r\nimport { RegisterDTO } from \"../../application/dtos/RegisterDTO\";\r\n\r\nimport { RegisterUseCase } from \"../../application/useCase/RegisterUseCase\";\r\nimport { LoginUseCase } from \"../../application/useCase/LoginUseCase\";\r\nimport { RefreshTokenUseCase } from \"../../application/useCase/RefreshTokenUseCase\";\r\n\r\nimport { IRefreshTokenRequest } from \"../../domain/interfaces/IRefreshTokenRequest\";\r\nimport { IDecodedToken } from \"../../domain/interfaces/IDecodedToken\";\r\n\r\n\r\nexport class AuthController {\r\n private loginUseCase: LoginUseCase;\r\n private registerUseCase: RegisterUseCase;\r\n private refreshTokenUseCase: RefreshTokenUseCase;\r\n\r\n constructor(\r\n loginUseCase: LoginUseCase,\r\n registerUseCase: RegisterUseCase,\r\n refreshTokenUseCase: RefreshTokenUseCase\r\n ) {\r\n this.loginUseCase = loginUseCase;\r\n this.registerUseCase = registerUseCase;\r\n this.refreshTokenUseCase = refreshTokenUseCase;\r\n }\r\n\r\n login = async (req: Request, res: Response, next: NextFunction) => {\r\n try {\r\n const { adminPassword, ...loginDTO }: LoginDTO = req.body;\r\n const result = await this.loginUseCase.execute(loginDTO, adminPassword);\r\n res.status(201).json(result);\r\n } catch (error) {\r\n next(error);\r\n }\r\n };\r\n\r\n register = async (\r\n req: Request,\r\n res: Response,\r\n next: NextFunction\r\n ): Promise<void> => {\r\n try {\r\n const { email, name, password, role }: RegisterDTO = req.body;\r\n await this.registerUseCase.execute(email, name, password, role);\r\n } catch (error) {\r\n next(error);\r\n }\r\n };\r\n\r\n refreshToken = async (req: Request, res: Response) => {\r\n const { refreshToken }: IRefreshTokenRequest = req.body;\r\n const result = await this.refreshTokenUseCase.execute(refreshToken);\r\n res.json(result);\r\n };\r\n\r\n verifyToken = async (token: string): Promise<IDecodedToken> => {\r\n return await this.refreshTokenUseCase.verityToken(token);\r\n };\r\n}\r\n","import { BaseRepository, IBaseRepository, IExtendedBaseRepository } from \"cca-core\";\r\nimport { AuthEntity } from \"cca-entities\";\r\nimport { Repository } from \"typeorm\";\r\n\r\nexport class AuthRepository\r\n extends BaseRepository<AuthEntity>\r\n implements IExtendedBaseRepository<AuthEntity>\r\n{\r\n constructor(repository: Repository<AuthEntity>) {\r\n super(repository);\r\n }\r\n\r\n async findByEmail(email: string): Promise<AuthEntity | null> {\r\n return await this.repository.findOne({\r\n where: { email },\r\n relations: [\"users\"],\r\n });\r\n }\r\n\r\n async create(entity: Omit<AuthEntity, \"createdAt\">): Promise<AuthEntity> {\r\n return super.create(entity);\r\n }\r\n}\r\n","import * as jwt from \"jsonwebtoken\";\r\nimport * as bcrypt from \"bcrypt\";\r\nimport { IBaseService, validateRepository } from \"cca-core\";\r\nimport { AuthEntity, UserEntity } from \"cca-entities\";\r\n\r\nimport { IJwtConfig } from \"../../domain/interfaces/IJwtConfig\";\r\nimport { IAuthService } from \"../../domain/interfaces/IAuthService\";\r\nimport { IDecodedToken } from \"../../domain/interfaces/IDecodedToken\";\r\n\r\nimport {\r\n ForbiddenError,\r\n NotFoundError,\r\n UnauthorizedError,\r\n} from \"../../utils/Errors\";\r\n\r\nimport { AuthRepository } from \"../repository/AuthRepository\";\r\n\r\nexport class JwtAuthService implements IBaseService, IAuthService {\r\n private readonly jwtConfig: IJwtConfig;\r\n private readonly repository: AuthRepository;\r\n\r\n constructor(repository: AuthRepository, config?: IJwtConfig) {\r\n this.repository = repository;\r\n this.jwtConfig = {\r\n accessTokenSecret:\r\n process.env.JWT_ACCESS_SECRET || \"default-access-secret\",\r\n refreshTokenSecret:\r\n process.env.JWT_REFRESH_SECRET || \"default-refresh-secret\",\r\n accessTokenExpiry: \"15m\",\r\n refreshTokenExpiry: \"7d\",\r\n };\r\n if (config) {\r\n this.jwtConfig = {\r\n ...this.jwtConfig,\r\n ...config,\r\n };\r\n }\r\n\r\n this.validateConfiguration();\r\n }\r\n \r\n public async initialize(): Promise<void> {\r\n await validateRepository(this.repository, (repo) => repo.getAll());\r\n }\r\n\r\n private validateConfiguration(): void {\r\n if (\r\n !this.jwtConfig.accessTokenSecret ||\r\n !this.jwtConfig.refreshTokenSecret\r\n ) {\r\n throw new Error(\r\n \"JWT secrets must be defined in environment variables or configuration\"\r\n );\r\n }\r\n }\r\n\r\n async validateUser(\r\n email: string,\r\n password: string\r\n ): Promise<AuthEntity | null> {\r\n try {\r\n const user = await this.repository.findByEmail(email);\r\n\r\n if (!user) {\r\n throw new NotFoundError(\r\n \"The email address or password is incorrect. Please retry\"\r\n );\r\n }\r\n\r\n const isValidPassword = await bcrypt.compare(password, user.password);\r\n if (!isValidPassword) {\r\n throw new ForbiddenError(\r\n \"The email address or password is incorrect. Please retry\"\r\n );\r\n }\r\n\r\n return user;\r\n } catch (error: any) {\r\n if (error instanceof NotFoundError || error instanceof ForbiddenError) {\r\n throw error;\r\n }\r\n throw new Error(`Authentication failed: ${error.message}`);\r\n }\r\n }\r\n\r\n generateAccessToken(user: UserEntity): string {\r\n return jwt.sign(\r\n {\r\n userId: user.id,\r\n email: user.email,\r\n role: user.role,\r\n },\r\n this.jwtConfig.accessTokenSecret,\r\n { expiresIn: this.jwtConfig.accessTokenExpiry }\r\n );\r\n }\r\n\r\n generateRefreshToken(user: UserEntity): string {\r\n return jwt.sign({ userId: user.id }, this.jwtConfig.refreshTokenSecret, {\r\n expiresIn: this.jwtConfig.refreshTokenExpiry,\r\n });\r\n }\r\n\r\n async verifyAccessToken(token: string): Promise<IDecodedToken> {\r\n return this.verifyToken(token, this.jwtConfig.accessTokenSecret);\r\n }\r\n\r\n async verifyRefreshToken(token: string): Promise<IDecodedToken> {\r\n return this.verifyToken(token, this.jwtConfig.refreshTokenSecret);\r\n }\r\n\r\n private async verifyToken(\r\n token: string,\r\n secret: string\r\n ): Promise<IDecodedToken> {\r\n try {\r\n return jwt.verify(token, secret) as IDecodedToken;\r\n } catch (error) {\r\n if (\r\n error instanceof jwt.TokenExpiredError ||\r\n error instanceof jwt.JsonW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AAA,EACF;AAEA,SAAO,EAAE,WAAW,eAAe;AACrC;AA5BS;","names":["import_cca_core","import_cca_entities","import_cca_core","import_cca_entities","bcrypt","import_core","import_classes","import_cca_entities","mapper","import_cca_core","bcrypt","import_cca_entities","import_cca_core","import_cca_core","bcrypt","import_cca_core"]}
|
package/dist/index.mjs
CHANGED
package/dist/metafile-cjs.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"src/application/dtos/UserDTO.ts":{"bytes":281,"imports":[{"path":"@automapper/classes","kind":"import-statement","external":true},{"path":"cca-entities","kind":"import-statement","external":true},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/utils/Errors.ts":{"bytes":1104,"imports":[{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/application/validators/authValidation.ts":{"bytes":4701,"imports":[{"path":"yup","kind":"import-statement","external":true},{"path":"cca-entities","kind":"import-statement","external":true},{"path":"bcrypt","kind":"import-statement","external":true},{"path":"src/utils/Errors.ts","kind":"import-statement","original":"../../utils/Errors"},{"path":"../../infrastructure/repository/AuthRepository","kind":"import-statement","external":true},{"path":"../../utils/ConfigFinder","kind":"import-statement","external":true},{"path":"../dtos/RegisterDTO","kind":"import-statement","external":true},{"path":"../dtos/LoginDTO","kind":"import-statement","external":true},{"path":"cca-core","kind":"import-statement","external":true},{"path":"fs/promises","kind":"dynamic-import","external":true},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/application/dtos/RegisterDTO.ts":{"bytes":181,"imports":[{"path":"cca-entities","kind":"import-statement","external":true},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/application/mappers/createUserMappings.ts":{"bytes":1183,"imports":[{"path":"@automapper/core","kind":"import-statement","external":true},{"path":"cca-entities","kind":"import-statement","external":true},{"path":"src/application/dtos/RegisterDTO.ts","kind":"import-statement","original":"../dtos/RegisterDTO"},{"path":"src/application/dtos/UserDTO.ts","kind":"import-statement","original":"../dtos/UserDTO"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/application/mappers/utils/mapper.ts":{"bytes":272,"imports":[{"path":"@automapper/core","kind":"import-statement","external":true},{"path":"@automapper/classes","kind":"import-statement","external":true},{"path":"src/application/mappers/createUserMappings.ts","kind":"import-statement","original":"../createUserMappings"}],"format":"esm"},"src/application/useCase/LoginUseCase.ts":{"bytes":2092,"imports":[{"path":"cca-core","kind":"import-statement","external":true},{"path":"cca-entities","kind":"import-statement","external":true},{"path":"../../infrastructure/repository/AuthRepository","kind":"import-statement","external":true},{"path":"../../infrastructure/auth/JwtAuthService","kind":"import-statement","external":true},{"path":"src/application/dtos/UserDTO.ts","kind":"import-statement","original":"../dtos/UserDTO"},{"path":"../dtos/LoginDTO","kind":"import-statement","external":true},{"path":"src/application/validators/authValidation.ts","kind":"import-statement","original":"../validators/authValidation"},{"path":"src/application/mappers/utils/mapper.ts","kind":"import-statement","original":"../mappers/utils/mapper"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/application/useCase/RegisterUseCase.ts":{"bytes":2284,"imports":[{"path":"cca-core","kind":"import-statement","external":true},{"path":"bcrypt","kind":"import-statement","external":true},{"path":"cca-entities","kind":"import-statement","external":true},{"path":"../../infrastructure/repository/AuthRepository","kind":"import-statement","external":true},{"path":"src/application/mappers/utils/mapper.ts","kind":"import-statement","original":"../mappers/utils/mapper"},{"path":"src/application/dtos/RegisterDTO.ts","kind":"import-statement","original":"../dtos/RegisterDTO"},{"path":"src/application/validators/authValidation.ts","kind":"import-statement","original":"../validators/authValidation"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/application/useCase/RefreshTokenUseCase.ts":{"bytes":1623,"imports":[{"path":"cca-core","kind":"import-statement","external":true},{"path":"../../domain/interfaces/IDecodedToken","kind":"import-statement","external":true},{"path":"../../infrastructure/auth/JwtAuthService","kind":"import-statement","external":true},{"path":"../../infrastructure/repository/AuthRepository","kind":"import-statement","external":true},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/presentation/controller/AuthController.ts":{"bytes":2058,"imports":[{"path":"express","kind":"import-statement","external":true},{"path":"../../application/dtos/LoginDTO","kind":"import-statement","external":true},{"path":"../../application/dtos/RegisterDTO","kind":"import-statement","external":true},{"path":"../../application/useCase/RegisterUseCase","kind":"import-statement","external":true},{"path":"../../application/useCase/LoginUseCase","kind":"import-statement","external":true},{"path":"../../application/useCase/RefreshTokenUseCase","kind":"import-statement","external":true},{"path":"../../domain/interfaces/IRefreshTokenRequest","kind":"import-statement","external":true},{"path":"../../domain/interfaces/IDecodedToken","kind":"import-statement","external":true},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/infrastructure/repository/AuthRepository.ts":{"bytes":675,"imports":[{"path":"cca-core","kind":"import-statement","external":true},{"path":"cca-entities","kind":"import-statement","external":true},{"path":"typeorm","kind":"import-statement","external":true},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/infrastructure/auth/JwtAuthService.ts":{"bytes":3672,"imports":[{"path":"jsonwebtoken","kind":"import-statement","external":true},{"path":"bcrypt","kind":"import-statement","external":true},{"path":"cca-core","kind":"import-statement","external":true},{"path":"cca-entities","kind":"import-statement","external":true},{"path":"../../domain/interfaces/IJwtConfig","kind":"import-statement","external":true},{"path":"../../domain/interfaces/IAuthService","kind":"import-statement","external":true},{"path":"../../domain/interfaces/IDecodedToken","kind":"import-statement","external":true},{"path":"src/utils/Errors.ts","kind":"import-statement","original":"../../utils/Errors"},{"path":"../repository/AuthRepository","kind":"import-statement","external":true},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/infrastructure/container/createAuthContainer.ts":{"bytes":1602,"imports":[{"path":"cca-core","kind":"import-statement","external":true},{"path":"cca-entities","kind":"import-statement","external":true},{"path":"src/application/useCase/LoginUseCase.ts","kind":"import-statement","original":"../../application/useCase/LoginUseCase"},{"path":"src/application/useCase/RegisterUseCase.ts","kind":"import-statement","original":"../../application/useCase/RegisterUseCase"},{"path":"src/application/useCase/RefreshTokenUseCase.ts","kind":"import-statement","original":"../../application/useCase/RefreshTokenUseCase"},{"path":"src/presentation/controller/AuthController.ts","kind":"import-statement","original":"../../presentation/controller/AuthController"},{"path":"src/infrastructure/repository/AuthRepository.ts","kind":"import-statement","original":"../repository/AuthRepository"},{"path":"src/infrastructure/auth/JwtAuthService.ts","kind":"import-statement","original":"../auth/JwtAuthService"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/index.ts":{"bytes":122,"imports":[{"path":"src/infrastructure/container/createAuthContainer.ts","kind":"import-statement","original":"./infrastructure/container/createAuthContainer"}],"format":"esm"}},"outputs":{"dist/index.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":35057},"dist/index.js":{"imports":[{"path":"cca-core","kind":"require-call","external":true},{"path":"cca-entities","kind":"require-call","external":true},{"path":"cca-core","kind":"require-call","external":true},{"path":"cca-entities","kind":"require-call","external":true},{"path":"@automapper/classes","kind":"require-call","external":true},{"path":"yup","kind":"require-call","external":true},{"path":"cca-entities","kind":"require-call","external":true},{"path":"bcrypt","kind":"require-call","external":true},{"path":"cca-core","kind":"require-call","external":true},{"path":"fs/promises","kind":"dynamic-import","external":true},{"path":"@automapper/core","kind":"require-call","external":true},{"path":"@automapper/classes","kind":"require-call","external":true},{"path":"@automapper/core","kind":"require-call","external":true},{"path":"cca-entities","kind":"require-call","external":true},{"path":"cca-core","kind":"require-call","external":true},{"path":"bcrypt","kind":"require-call","external":true},{"path":"cca-entities","kind":"require-call","external":true},{"path":"cca-core","kind":"require-call","external":true},{"path":"cca-core","kind":"require-call","external":true},{"path":"jsonwebtoken","kind":"require-call","external":true},{"path":"bcrypt","kind":"require-call","external":true},{"path":"cca-core","kind":"require-call","external":true}],"exports":[],"entryPoint":"src/index.ts","inputs":{"src/index.ts":{"bytesInOutput":149},"src/infrastructure/container/createAuthContainer.ts":{"bytesInOutput":1146},"src/application/useCase/LoginUseCase.ts":{"bytesInOutput":1318},"src/application/dtos/UserDTO.ts":{"bytesInOutput":480},"src/application/validators/authValidation.ts":{"bytesInOutput":4139},"src/utils/Errors.ts":{"bytesInOutput":1362},"src/application/mappers/utils/mapper.ts":{"bytesInOutput":234},"src/application/mappers/createUserMappings.ts":{"bytesInOutput":1479},"src/application/dtos/RegisterDTO.ts":{"bytesInOutput":112},"src/application/useCase/RegisterUseCase.ts":{"bytesInOutput":1778},"src/application/useCase/RefreshTokenUseCase.ts":{"bytesInOutput":1164},"src/presentation/controller/AuthController.ts":{"bytesInOutput":1334},"src/infrastructure/repository/AuthRepository.ts":{"bytesInOutput":466},"src/infrastructure/auth/JwtAuthService.ts":{"bytesInOutput":2731}},"bytes":20738}}}
|
|
1
|
+
{"inputs":{"src/application/dtos/UserDTO.ts":{"bytes":281,"imports":[{"path":"@automapper/classes","kind":"import-statement","external":true},{"path":"cca-entities","kind":"import-statement","external":true},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/utils/Errors.ts":{"bytes":1104,"imports":[{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/application/validators/authValidation.ts":{"bytes":4701,"imports":[{"path":"yup","kind":"import-statement","external":true},{"path":"cca-entities","kind":"import-statement","external":true},{"path":"bcrypt","kind":"import-statement","external":true},{"path":"src/utils/Errors.ts","kind":"import-statement","original":"../../utils/Errors"},{"path":"../../infrastructure/repository/AuthRepository","kind":"import-statement","external":true},{"path":"../../utils/ConfigFinder","kind":"import-statement","external":true},{"path":"../dtos/RegisterDTO","kind":"import-statement","external":true},{"path":"../dtos/LoginDTO","kind":"import-statement","external":true},{"path":"cca-core","kind":"import-statement","external":true},{"path":"fs/promises","kind":"dynamic-import","external":true},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/application/dtos/RegisterDTO.ts":{"bytes":181,"imports":[{"path":"cca-entities","kind":"import-statement","external":true},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/application/mappers/createUserMappings.ts":{"bytes":1183,"imports":[{"path":"@automapper/core","kind":"import-statement","external":true},{"path":"cca-entities","kind":"import-statement","external":true},{"path":"src/application/dtos/RegisterDTO.ts","kind":"import-statement","original":"../dtos/RegisterDTO"},{"path":"src/application/dtos/UserDTO.ts","kind":"import-statement","original":"../dtos/UserDTO"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/application/mappers/utils/mapper.ts":{"bytes":272,"imports":[{"path":"@automapper/core","kind":"import-statement","external":true},{"path":"@automapper/classes","kind":"import-statement","external":true},{"path":"src/application/mappers/createUserMappings.ts","kind":"import-statement","original":"../createUserMappings"}],"format":"esm"},"src/application/useCase/LoginUseCase.ts":{"bytes":2092,"imports":[{"path":"cca-core","kind":"import-statement","external":true},{"path":"cca-entities","kind":"import-statement","external":true},{"path":"../../infrastructure/repository/AuthRepository","kind":"import-statement","external":true},{"path":"../../infrastructure/auth/JwtAuthService","kind":"import-statement","external":true},{"path":"src/application/dtos/UserDTO.ts","kind":"import-statement","original":"../dtos/UserDTO"},{"path":"../dtos/LoginDTO","kind":"import-statement","external":true},{"path":"src/application/validators/authValidation.ts","kind":"import-statement","original":"../validators/authValidation"},{"path":"src/application/mappers/utils/mapper.ts","kind":"import-statement","original":"../mappers/utils/mapper"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/application/useCase/RegisterUseCase.ts":{"bytes":2284,"imports":[{"path":"cca-core","kind":"import-statement","external":true},{"path":"bcrypt","kind":"import-statement","external":true},{"path":"cca-entities","kind":"import-statement","external":true},{"path":"../../infrastructure/repository/AuthRepository","kind":"import-statement","external":true},{"path":"src/application/mappers/utils/mapper.ts","kind":"import-statement","original":"../mappers/utils/mapper"},{"path":"src/application/dtos/RegisterDTO.ts","kind":"import-statement","original":"../dtos/RegisterDTO"},{"path":"src/application/validators/authValidation.ts","kind":"import-statement","original":"../validators/authValidation"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/application/useCase/RefreshTokenUseCase.ts":{"bytes":1623,"imports":[{"path":"cca-core","kind":"import-statement","external":true},{"path":"../../domain/interfaces/IDecodedToken","kind":"import-statement","external":true},{"path":"../../infrastructure/auth/JwtAuthService","kind":"import-statement","external":true},{"path":"../../infrastructure/repository/AuthRepository","kind":"import-statement","external":true},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/presentation/controller/AuthController.ts":{"bytes":2058,"imports":[{"path":"express","kind":"import-statement","external":true},{"path":"../../application/dtos/LoginDTO","kind":"import-statement","external":true},{"path":"../../application/dtos/RegisterDTO","kind":"import-statement","external":true},{"path":"../../application/useCase/RegisterUseCase","kind":"import-statement","external":true},{"path":"../../application/useCase/LoginUseCase","kind":"import-statement","external":true},{"path":"../../application/useCase/RefreshTokenUseCase","kind":"import-statement","external":true},{"path":"../../domain/interfaces/IRefreshTokenRequest","kind":"import-statement","external":true},{"path":"../../domain/interfaces/IDecodedToken","kind":"import-statement","external":true},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/infrastructure/repository/AuthRepository.ts":{"bytes":675,"imports":[{"path":"cca-core","kind":"import-statement","external":true},{"path":"cca-entities","kind":"import-statement","external":true},{"path":"typeorm","kind":"import-statement","external":true},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/infrastructure/auth/JwtAuthService.ts":{"bytes":3672,"imports":[{"path":"jsonwebtoken","kind":"import-statement","external":true},{"path":"bcrypt","kind":"import-statement","external":true},{"path":"cca-core","kind":"import-statement","external":true},{"path":"cca-entities","kind":"import-statement","external":true},{"path":"../../domain/interfaces/IJwtConfig","kind":"import-statement","external":true},{"path":"../../domain/interfaces/IAuthService","kind":"import-statement","external":true},{"path":"../../domain/interfaces/IDecodedToken","kind":"import-statement","external":true},{"path":"src/utils/Errors.ts","kind":"import-statement","original":"../../utils/Errors"},{"path":"../repository/AuthRepository","kind":"import-statement","external":true},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/infrastructure/container/createAuthContainer.ts":{"bytes":1602,"imports":[{"path":"cca-core","kind":"import-statement","external":true},{"path":"cca-entities","kind":"import-statement","external":true},{"path":"src/application/useCase/LoginUseCase.ts","kind":"import-statement","original":"../../application/useCase/LoginUseCase"},{"path":"src/application/useCase/RegisterUseCase.ts","kind":"import-statement","original":"../../application/useCase/RegisterUseCase"},{"path":"src/application/useCase/RefreshTokenUseCase.ts","kind":"import-statement","original":"../../application/useCase/RefreshTokenUseCase"},{"path":"src/presentation/controller/AuthController.ts","kind":"import-statement","original":"../../presentation/controller/AuthController"},{"path":"src/infrastructure/repository/AuthRepository.ts","kind":"import-statement","original":"../repository/AuthRepository"},{"path":"src/infrastructure/auth/JwtAuthService.ts","kind":"import-statement","original":"../auth/JwtAuthService"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/index.ts":{"bytes":214,"imports":[{"path":"src/infrastructure/container/createAuthContainer.ts","kind":"import-statement","original":"./infrastructure/container/createAuthContainer"},{"path":"src/presentation/controller/AuthController.ts","kind":"import-statement","original":"./presentation/controller/AuthController"}],"format":"esm"}},"outputs":{"dist/index.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":35158},"dist/index.js":{"imports":[{"path":"cca-core","kind":"require-call","external":true},{"path":"cca-entities","kind":"require-call","external":true},{"path":"cca-core","kind":"require-call","external":true},{"path":"cca-entities","kind":"require-call","external":true},{"path":"@automapper/classes","kind":"require-call","external":true},{"path":"yup","kind":"require-call","external":true},{"path":"cca-entities","kind":"require-call","external":true},{"path":"bcrypt","kind":"require-call","external":true},{"path":"cca-core","kind":"require-call","external":true},{"path":"fs/promises","kind":"dynamic-import","external":true},{"path":"@automapper/core","kind":"require-call","external":true},{"path":"@automapper/classes","kind":"require-call","external":true},{"path":"@automapper/core","kind":"require-call","external":true},{"path":"cca-entities","kind":"require-call","external":true},{"path":"cca-core","kind":"require-call","external":true},{"path":"bcrypt","kind":"require-call","external":true},{"path":"cca-entities","kind":"require-call","external":true},{"path":"cca-core","kind":"require-call","external":true},{"path":"cca-core","kind":"require-call","external":true},{"path":"jsonwebtoken","kind":"require-call","external":true},{"path":"bcrypt","kind":"require-call","external":true},{"path":"cca-core","kind":"require-call","external":true}],"exports":[],"entryPoint":"src/index.ts","inputs":{"src/index.ts":{"bytesInOutput":189},"src/infrastructure/container/createAuthContainer.ts":{"bytesInOutput":1146},"src/application/useCase/LoginUseCase.ts":{"bytesInOutput":1318},"src/application/dtos/UserDTO.ts":{"bytesInOutput":480},"src/application/validators/authValidation.ts":{"bytesInOutput":4139},"src/utils/Errors.ts":{"bytesInOutput":1362},"src/application/mappers/utils/mapper.ts":{"bytesInOutput":234},"src/application/mappers/createUserMappings.ts":{"bytesInOutput":1479},"src/application/dtos/RegisterDTO.ts":{"bytesInOutput":112},"src/application/useCase/RegisterUseCase.ts":{"bytesInOutput":1778},"src/application/useCase/RefreshTokenUseCase.ts":{"bytesInOutput":1164},"src/presentation/controller/AuthController.ts":{"bytesInOutput":1334},"src/infrastructure/repository/AuthRepository.ts":{"bytesInOutput":466},"src/infrastructure/auth/JwtAuthService.ts":{"bytesInOutput":2731}},"bytes":20796}}}
|
package/dist/metafile-esm.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"src/application/dtos/UserDTO.ts":{"bytes":281,"imports":[{"path":"@automapper/classes","kind":"import-statement","external":true},{"path":"cca-entities","kind":"import-statement","external":true},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/utils/Errors.ts":{"bytes":1104,"imports":[{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/application/validators/authValidation.ts":{"bytes":4701,"imports":[{"path":"yup","kind":"import-statement","external":true},{"path":"cca-entities","kind":"import-statement","external":true},{"path":"bcrypt","kind":"import-statement","external":true},{"path":"src/utils/Errors.ts","kind":"import-statement","original":"../../utils/Errors"},{"path":"../../infrastructure/repository/AuthRepository","kind":"import-statement","external":true},{"path":"../../utils/ConfigFinder","kind":"import-statement","external":true},{"path":"../dtos/RegisterDTO","kind":"import-statement","external":true},{"path":"../dtos/LoginDTO","kind":"import-statement","external":true},{"path":"cca-core","kind":"import-statement","external":true},{"path":"fs/promises","kind":"dynamic-import","external":true},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/application/dtos/RegisterDTO.ts":{"bytes":181,"imports":[{"path":"cca-entities","kind":"import-statement","external":true},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/application/mappers/createUserMappings.ts":{"bytes":1183,"imports":[{"path":"@automapper/core","kind":"import-statement","external":true},{"path":"cca-entities","kind":"import-statement","external":true},{"path":"src/application/dtos/RegisterDTO.ts","kind":"import-statement","original":"../dtos/RegisterDTO"},{"path":"src/application/dtos/UserDTO.ts","kind":"import-statement","original":"../dtos/UserDTO"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/application/mappers/utils/mapper.ts":{"bytes":272,"imports":[{"path":"@automapper/core","kind":"import-statement","external":true},{"path":"@automapper/classes","kind":"import-statement","external":true},{"path":"src/application/mappers/createUserMappings.ts","kind":"import-statement","original":"../createUserMappings"}],"format":"esm"},"src/application/useCase/LoginUseCase.ts":{"bytes":2092,"imports":[{"path":"cca-core","kind":"import-statement","external":true},{"path":"cca-entities","kind":"import-statement","external":true},{"path":"../../infrastructure/repository/AuthRepository","kind":"import-statement","external":true},{"path":"../../infrastructure/auth/JwtAuthService","kind":"import-statement","external":true},{"path":"src/application/dtos/UserDTO.ts","kind":"import-statement","original":"../dtos/UserDTO"},{"path":"../dtos/LoginDTO","kind":"import-statement","external":true},{"path":"src/application/validators/authValidation.ts","kind":"import-statement","original":"../validators/authValidation"},{"path":"src/application/mappers/utils/mapper.ts","kind":"import-statement","original":"../mappers/utils/mapper"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/application/useCase/RegisterUseCase.ts":{"bytes":2284,"imports":[{"path":"cca-core","kind":"import-statement","external":true},{"path":"bcrypt","kind":"import-statement","external":true},{"path":"cca-entities","kind":"import-statement","external":true},{"path":"../../infrastructure/repository/AuthRepository","kind":"import-statement","external":true},{"path":"src/application/mappers/utils/mapper.ts","kind":"import-statement","original":"../mappers/utils/mapper"},{"path":"src/application/dtos/RegisterDTO.ts","kind":"import-statement","original":"../dtos/RegisterDTO"},{"path":"src/application/validators/authValidation.ts","kind":"import-statement","original":"../validators/authValidation"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/application/useCase/RefreshTokenUseCase.ts":{"bytes":1623,"imports":[{"path":"cca-core","kind":"import-statement","external":true},{"path":"../../domain/interfaces/IDecodedToken","kind":"import-statement","external":true},{"path":"../../infrastructure/auth/JwtAuthService","kind":"import-statement","external":true},{"path":"../../infrastructure/repository/AuthRepository","kind":"import-statement","external":true},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/presentation/controller/AuthController.ts":{"bytes":2058,"imports":[{"path":"express","kind":"import-statement","external":true},{"path":"../../application/dtos/LoginDTO","kind":"import-statement","external":true},{"path":"../../application/dtos/RegisterDTO","kind":"import-statement","external":true},{"path":"../../application/useCase/RegisterUseCase","kind":"import-statement","external":true},{"path":"../../application/useCase/LoginUseCase","kind":"import-statement","external":true},{"path":"../../application/useCase/RefreshTokenUseCase","kind":"import-statement","external":true},{"path":"../../domain/interfaces/IRefreshTokenRequest","kind":"import-statement","external":true},{"path":"../../domain/interfaces/IDecodedToken","kind":"import-statement","external":true},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/infrastructure/repository/AuthRepository.ts":{"bytes":675,"imports":[{"path":"cca-core","kind":"import-statement","external":true},{"path":"cca-entities","kind":"import-statement","external":true},{"path":"typeorm","kind":"import-statement","external":true},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/infrastructure/auth/JwtAuthService.ts":{"bytes":3672,"imports":[{"path":"jsonwebtoken","kind":"import-statement","external":true},{"path":"bcrypt","kind":"import-statement","external":true},{"path":"cca-core","kind":"import-statement","external":true},{"path":"cca-entities","kind":"import-statement","external":true},{"path":"../../domain/interfaces/IJwtConfig","kind":"import-statement","external":true},{"path":"../../domain/interfaces/IAuthService","kind":"import-statement","external":true},{"path":"../../domain/interfaces/IDecodedToken","kind":"import-statement","external":true},{"path":"src/utils/Errors.ts","kind":"import-statement","original":"../../utils/Errors"},{"path":"../repository/AuthRepository","kind":"import-statement","external":true},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/infrastructure/container/createAuthContainer.ts":{"bytes":1602,"imports":[{"path":"cca-core","kind":"import-statement","external":true},{"path":"cca-entities","kind":"import-statement","external":true},{"path":"src/application/useCase/LoginUseCase.ts","kind":"import-statement","original":"../../application/useCase/LoginUseCase"},{"path":"src/application/useCase/RegisterUseCase.ts","kind":"import-statement","original":"../../application/useCase/RegisterUseCase"},{"path":"src/application/useCase/RefreshTokenUseCase.ts","kind":"import-statement","original":"../../application/useCase/RefreshTokenUseCase"},{"path":"src/presentation/controller/AuthController.ts","kind":"import-statement","original":"../../presentation/controller/AuthController"},{"path":"src/infrastructure/repository/AuthRepository.ts","kind":"import-statement","original":"../repository/AuthRepository"},{"path":"src/infrastructure/auth/JwtAuthService.ts","kind":"import-statement","original":"../auth/JwtAuthService"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/index.ts":{"bytes":122,"imports":[{"path":"src/infrastructure/container/createAuthContainer.ts","kind":"import-statement","original":"./infrastructure/container/createAuthContainer"}],"format":"esm"}},"outputs":{"dist/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":35002},"dist/index.mjs":{"imports":[{"path":"cca-core","kind":"import-statement","external":true},{"path":"cca-entities","kind":"import-statement","external":true},{"path":"cca-core","kind":"import-statement","external":true},{"path":"cca-entities","kind":"import-statement","external":true},{"path":"@automapper/classes","kind":"import-statement","external":true},{"path":"yup","kind":"import-statement","external":true},{"path":"cca-entities","kind":"import-statement","external":true},{"path":"bcrypt","kind":"import-statement","external":true},{"path":"cca-core","kind":"import-statement","external":true},{"path":"fs/promises","kind":"dynamic-import","external":true},{"path":"@automapper/core","kind":"import-statement","external":true},{"path":"@automapper/classes","kind":"import-statement","external":true},{"path":"@automapper/core","kind":"import-statement","external":true},{"path":"cca-entities","kind":"import-statement","external":true},{"path":"cca-core","kind":"import-statement","external":true},{"path":"bcrypt","kind":"import-statement","external":true},{"path":"cca-entities","kind":"import-statement","external":true},{"path":"cca-core","kind":"import-statement","external":true},{"path":"cca-core","kind":"import-statement","external":true},{"path":"jsonwebtoken","kind":"import-statement","external":true},{"path":"bcrypt","kind":"import-statement","external":true},{"path":"cca-core","kind":"import-statement","external":true}],"exports":["createAuthContainer"],"entryPoint":"src/index.ts","inputs":{"src/infrastructure/container/createAuthContainer.ts":{"bytesInOutput":1113},"src/application/useCase/LoginUseCase.ts":{"bytesInOutput":1288},"src/application/dtos/UserDTO.ts":{"bytesInOutput":394},"src/application/validators/authValidation.ts":{"bytesInOutput":4043},"src/utils/Errors.ts":{"bytesInOutput":1362},"src/application/mappers/utils/mapper.ts":{"bytesInOutput":189},"src/application/mappers/createUserMappings.ts":{"bytesInOutput":1063},"src/application/dtos/RegisterDTO.ts":{"bytesInOutput":112},"src/application/useCase/RegisterUseCase.ts":{"bytesInOutput":1772},"src/application/useCase/RefreshTokenUseCase.ts":{"bytesInOutput":1169},"src/presentation/controller/AuthController.ts":{"bytesInOutput":1334},"src/infrastructure/repository/AuthRepository.ts":{"bytesInOutput":448},"src/infrastructure/auth/JwtAuthService.ts":{"bytesInOutput":2722},"src/index.ts":{"bytesInOutput":0}},"bytes":18458}}}
|
|
1
|
+
{"inputs":{"src/application/dtos/UserDTO.ts":{"bytes":281,"imports":[{"path":"@automapper/classes","kind":"import-statement","external":true},{"path":"cca-entities","kind":"import-statement","external":true},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/utils/Errors.ts":{"bytes":1104,"imports":[{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/application/validators/authValidation.ts":{"bytes":4701,"imports":[{"path":"yup","kind":"import-statement","external":true},{"path":"cca-entities","kind":"import-statement","external":true},{"path":"bcrypt","kind":"import-statement","external":true},{"path":"src/utils/Errors.ts","kind":"import-statement","original":"../../utils/Errors"},{"path":"../../infrastructure/repository/AuthRepository","kind":"import-statement","external":true},{"path":"../../utils/ConfigFinder","kind":"import-statement","external":true},{"path":"../dtos/RegisterDTO","kind":"import-statement","external":true},{"path":"../dtos/LoginDTO","kind":"import-statement","external":true},{"path":"cca-core","kind":"import-statement","external":true},{"path":"fs/promises","kind":"dynamic-import","external":true},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/application/dtos/RegisterDTO.ts":{"bytes":181,"imports":[{"path":"cca-entities","kind":"import-statement","external":true},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/application/mappers/createUserMappings.ts":{"bytes":1183,"imports":[{"path":"@automapper/core","kind":"import-statement","external":true},{"path":"cca-entities","kind":"import-statement","external":true},{"path":"src/application/dtos/RegisterDTO.ts","kind":"import-statement","original":"../dtos/RegisterDTO"},{"path":"src/application/dtos/UserDTO.ts","kind":"import-statement","original":"../dtos/UserDTO"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/application/mappers/utils/mapper.ts":{"bytes":272,"imports":[{"path":"@automapper/core","kind":"import-statement","external":true},{"path":"@automapper/classes","kind":"import-statement","external":true},{"path":"src/application/mappers/createUserMappings.ts","kind":"import-statement","original":"../createUserMappings"}],"format":"esm"},"src/application/useCase/LoginUseCase.ts":{"bytes":2092,"imports":[{"path":"cca-core","kind":"import-statement","external":true},{"path":"cca-entities","kind":"import-statement","external":true},{"path":"../../infrastructure/repository/AuthRepository","kind":"import-statement","external":true},{"path":"../../infrastructure/auth/JwtAuthService","kind":"import-statement","external":true},{"path":"src/application/dtos/UserDTO.ts","kind":"import-statement","original":"../dtos/UserDTO"},{"path":"../dtos/LoginDTO","kind":"import-statement","external":true},{"path":"src/application/validators/authValidation.ts","kind":"import-statement","original":"../validators/authValidation"},{"path":"src/application/mappers/utils/mapper.ts","kind":"import-statement","original":"../mappers/utils/mapper"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/application/useCase/RegisterUseCase.ts":{"bytes":2284,"imports":[{"path":"cca-core","kind":"import-statement","external":true},{"path":"bcrypt","kind":"import-statement","external":true},{"path":"cca-entities","kind":"import-statement","external":true},{"path":"../../infrastructure/repository/AuthRepository","kind":"import-statement","external":true},{"path":"src/application/mappers/utils/mapper.ts","kind":"import-statement","original":"../mappers/utils/mapper"},{"path":"src/application/dtos/RegisterDTO.ts","kind":"import-statement","original":"../dtos/RegisterDTO"},{"path":"src/application/validators/authValidation.ts","kind":"import-statement","original":"../validators/authValidation"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/application/useCase/RefreshTokenUseCase.ts":{"bytes":1623,"imports":[{"path":"cca-core","kind":"import-statement","external":true},{"path":"../../domain/interfaces/IDecodedToken","kind":"import-statement","external":true},{"path":"../../infrastructure/auth/JwtAuthService","kind":"import-statement","external":true},{"path":"../../infrastructure/repository/AuthRepository","kind":"import-statement","external":true},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/presentation/controller/AuthController.ts":{"bytes":2058,"imports":[{"path":"express","kind":"import-statement","external":true},{"path":"../../application/dtos/LoginDTO","kind":"import-statement","external":true},{"path":"../../application/dtos/RegisterDTO","kind":"import-statement","external":true},{"path":"../../application/useCase/RegisterUseCase","kind":"import-statement","external":true},{"path":"../../application/useCase/LoginUseCase","kind":"import-statement","external":true},{"path":"../../application/useCase/RefreshTokenUseCase","kind":"import-statement","external":true},{"path":"../../domain/interfaces/IRefreshTokenRequest","kind":"import-statement","external":true},{"path":"../../domain/interfaces/IDecodedToken","kind":"import-statement","external":true},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/infrastructure/repository/AuthRepository.ts":{"bytes":675,"imports":[{"path":"cca-core","kind":"import-statement","external":true},{"path":"cca-entities","kind":"import-statement","external":true},{"path":"typeorm","kind":"import-statement","external":true},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/infrastructure/auth/JwtAuthService.ts":{"bytes":3672,"imports":[{"path":"jsonwebtoken","kind":"import-statement","external":true},{"path":"bcrypt","kind":"import-statement","external":true},{"path":"cca-core","kind":"import-statement","external":true},{"path":"cca-entities","kind":"import-statement","external":true},{"path":"../../domain/interfaces/IJwtConfig","kind":"import-statement","external":true},{"path":"../../domain/interfaces/IAuthService","kind":"import-statement","external":true},{"path":"../../domain/interfaces/IDecodedToken","kind":"import-statement","external":true},{"path":"src/utils/Errors.ts","kind":"import-statement","original":"../../utils/Errors"},{"path":"../repository/AuthRepository","kind":"import-statement","external":true},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/infrastructure/container/createAuthContainer.ts":{"bytes":1602,"imports":[{"path":"cca-core","kind":"import-statement","external":true},{"path":"cca-entities","kind":"import-statement","external":true},{"path":"src/application/useCase/LoginUseCase.ts","kind":"import-statement","original":"../../application/useCase/LoginUseCase"},{"path":"src/application/useCase/RegisterUseCase.ts","kind":"import-statement","original":"../../application/useCase/RegisterUseCase"},{"path":"src/application/useCase/RefreshTokenUseCase.ts","kind":"import-statement","original":"../../application/useCase/RefreshTokenUseCase"},{"path":"src/presentation/controller/AuthController.ts","kind":"import-statement","original":"../../presentation/controller/AuthController"},{"path":"src/infrastructure/repository/AuthRepository.ts","kind":"import-statement","original":"../repository/AuthRepository"},{"path":"src/infrastructure/auth/JwtAuthService.ts","kind":"import-statement","original":"../auth/JwtAuthService"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/index.ts":{"bytes":214,"imports":[{"path":"src/infrastructure/container/createAuthContainer.ts","kind":"import-statement","original":"./infrastructure/container/createAuthContainer"},{"path":"src/presentation/controller/AuthController.ts","kind":"import-statement","original":"./presentation/controller/AuthController"}],"format":"esm"}},"outputs":{"dist/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":35002},"dist/index.mjs":{"imports":[{"path":"cca-core","kind":"import-statement","external":true},{"path":"cca-entities","kind":"import-statement","external":true},{"path":"cca-core","kind":"import-statement","external":true},{"path":"cca-entities","kind":"import-statement","external":true},{"path":"@automapper/classes","kind":"import-statement","external":true},{"path":"yup","kind":"import-statement","external":true},{"path":"cca-entities","kind":"import-statement","external":true},{"path":"bcrypt","kind":"import-statement","external":true},{"path":"cca-core","kind":"import-statement","external":true},{"path":"fs/promises","kind":"dynamic-import","external":true},{"path":"@automapper/core","kind":"import-statement","external":true},{"path":"@automapper/classes","kind":"import-statement","external":true},{"path":"@automapper/core","kind":"import-statement","external":true},{"path":"cca-entities","kind":"import-statement","external":true},{"path":"cca-core","kind":"import-statement","external":true},{"path":"bcrypt","kind":"import-statement","external":true},{"path":"cca-entities","kind":"import-statement","external":true},{"path":"cca-core","kind":"import-statement","external":true},{"path":"cca-core","kind":"import-statement","external":true},{"path":"jsonwebtoken","kind":"import-statement","external":true},{"path":"bcrypt","kind":"import-statement","external":true},{"path":"cca-core","kind":"import-statement","external":true}],"exports":["AuthController","createAuthContainer"],"entryPoint":"src/index.ts","inputs":{"src/infrastructure/container/createAuthContainer.ts":{"bytesInOutput":1113},"src/application/useCase/LoginUseCase.ts":{"bytesInOutput":1288},"src/application/dtos/UserDTO.ts":{"bytesInOutput":394},"src/application/validators/authValidation.ts":{"bytesInOutput":4043},"src/utils/Errors.ts":{"bytesInOutput":1362},"src/application/mappers/utils/mapper.ts":{"bytesInOutput":189},"src/application/mappers/createUserMappings.ts":{"bytesInOutput":1063},"src/application/dtos/RegisterDTO.ts":{"bytesInOutput":112},"src/application/useCase/RegisterUseCase.ts":{"bytesInOutput":1772},"src/application/useCase/RefreshTokenUseCase.ts":{"bytesInOutput":1169},"src/presentation/controller/AuthController.ts":{"bytesInOutput":1334},"src/infrastructure/repository/AuthRepository.ts":{"bytesInOutput":448},"src/infrastructure/auth/JwtAuthService.ts":{"bytesInOutput":2722},"src/index.ts":{"bytesInOutput":0}},"bytes":18476}}}
|