import { Injectable } from "@nestjs/common"; import type * as jose from "jose"; import { EncryptionService } from "./services/encryption.service"; import { HashingService } from "./services/hashing.service"; import { JwtService } from "./services/jwt.service"; import { PostQuantumService } from "./services/post-quantum.service"; /** * @deprecated Use HashingService, JwtService, EncryptionService or PostQuantumService directly. * This service acts as a Facade for backward compatibility. */ @Injectable() export class CryptoService { constructor( private readonly hashingService: HashingService, private readonly jwtService: JwtService, private readonly encryptionService: EncryptionService, private readonly postQuantumService: PostQuantumService, ) {} async hashEmail(email: string): Promise { return this.hashingService.hashEmail(email); } async hashIp(ip: string): Promise { return this.hashingService.hashIp(ip); } getPgpEncryptionKey(): string { return this.encryptionService.getPgpEncryptionKey(); } async hashPassword(password: string): Promise { return this.hashingService.hashPassword(password); } async verifyPassword(password: string, hash: string): Promise { return this.hashingService.verifyPassword(password, hash); } async generateJwt( payload: jose.JWTPayload, expiresIn = "2h", ): Promise { return this.jwtService.generateJwt(payload, expiresIn); } async verifyJwt(token: string): Promise { return this.jwtService.verifyJwt(token); } async encryptContent(content: string): Promise { return this.encryptionService.encryptContent(content); } async decryptContent(jwe: string): Promise { return this.encryptionService.decryptContent(jwe); } async signContent(content: string): Promise { return this.encryptionService.signContent(content); } async verifyContentSignature(jws: string): Promise { return this.encryptionService.verifyContentSignature(jws); } generatePostQuantumKeyPair() { return this.postQuantumService.generatePostQuantumKeyPair(); } encapsulate(publicKey: Uint8Array) { return this.postQuantumService.encapsulate(publicKey); } decapsulate(cipherText: Uint8Array, secretKey: Uint8Array) { return this.postQuantumService.decapsulate(cipherText, secretKey); } }