-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from PBTP/feature/profile
DMVM-174 feat: Modify update profile feature
- Loading branch information
Showing
37 changed files
with
696 additions
and
399 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Global, Module } from '@nestjs/common'; | ||
import { SecurityService } from './security.service'; | ||
|
||
@Global() | ||
@Module({ | ||
providers: [SecurityService], | ||
exports: [SecurityService], | ||
}) | ||
export class SecurityModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { Injectable } from "@nestjs/common"; | ||
import * as crypto from "crypto"; | ||
import { ConfigService } from "@nestjs/config"; | ||
|
||
@Injectable() | ||
export class SecurityService { | ||
private readonly algorithm: string; | ||
private readonly secretKey: string; | ||
private iv = crypto.randomBytes(16); // 초기화 벡터(IV) | ||
|
||
constructor(private readonly configService: ConfigService) { | ||
this.algorithm = this.configService.get('security/crypto/algorithm'); | ||
this.secretKey = this.configService.get('security/crypto/key'); | ||
} | ||
|
||
encrypt(text: string): string { | ||
if (!text) return null; | ||
|
||
const cipher = crypto.createCipheriv( | ||
this.algorithm, | ||
this.secretKey, | ||
this.iv, | ||
); | ||
const encrypted = Buffer.concat([cipher.update(text), cipher.final()]); | ||
return `${this.iv.toString('hex')}:${encrypted.toString('hex')}`; // IV와 암호화된 데이터를 함께 반환 | ||
} | ||
|
||
decrypt(hash: string): string { | ||
if (!hash) return null; | ||
|
||
const [iv, encryptedText] = hash.split(':'); | ||
const decipher = crypto.createDecipheriv( | ||
this.algorithm, | ||
this.secretKey, | ||
Buffer.from(iv, 'hex'), | ||
); | ||
const decrypted = Buffer.concat([ | ||
decipher.update(Buffer.from(encryptedText, 'hex')), | ||
decipher.final(), | ||
]); | ||
return decrypted.toString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { ImageMetaDataDto } from "../image/presentation/image.dto"; | ||
import { PresignedUrlDto } from "./aws/s3/presentation/presigned-url.dto"; | ||
|
||
export interface ICloudStorage { | ||
generatePreSignedUrl( | ||
key: string, | ||
metadata: ImageMetaDataDto, | ||
expiredTime: number, | ||
): Promise<PresignedUrlDto>; | ||
|
||
generatePreSignedUrls( | ||
key: string, | ||
metadata: ImageMetaDataDto[], | ||
): Promise<PresignedUrlDto[]>; | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.