From 654c024dba26bc75f6ecf204fa387a5218bced2f Mon Sep 17 00:00:00 2001 From: juyeong525 Date: Tue, 30 May 2023 00:31:59 +0900 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=C2=A0::=20Loacl=20->=20Local?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/DI/AuthServiceDependency.swift | 6 ++--- ...ource.swift => LocalTokenDataSource.swift} | 2 +- ...l.swift => LocalTokenDataSourceImpl.swift} | 2 +- .../Data/Repository/AuthRepositoryImpl.swift | 26 +++++++++---------- .../Sources/Plugin/JWTPulgin.swift | 10 +++---- 5 files changed, 23 insertions(+), 23 deletions(-) rename Services/AuthService/Sources/Data/Local/DataSource/{LoaclTokenDataSource.swift => LocalTokenDataSource.swift} (90%) rename Services/AuthService/Sources/Data/Local/DataSource/{LoaclTokenDataSourceImpl.swift => LocalTokenDataSourceImpl.swift} (95%) diff --git a/Services/AuthService/Sources/DI/AuthServiceDependency.swift b/Services/AuthService/Sources/DI/AuthServiceDependency.swift index ef960272..188924cf 100644 --- a/Services/AuthService/Sources/DI/AuthServiceDependency.swift +++ b/Services/AuthService/Sources/DI/AuthServiceDependency.swift @@ -20,13 +20,13 @@ extension AuthServiceDependency { static func resolve() -> AuthServiceDependency { // MARK: - Datasources let remoteAuthDataSource: RemoteAuthDataSource = RemoteAuthDataSourceImpl() - let loaclTokenDataSource: LoaclTokenDataSource = LoaclTokenDataSourceImpl() + let localTokenDataSource: LocalTokenDataSource = LocalTokenDataSourceImpl() let localAuthDataSource: LocalAuthDataSource = LocalAuthDataSourceImpl() // MARK: - Respositories let authRepository: AuthRepository = AuthRepositoryImpl( remoteAuthDataSource: remoteAuthDataSource, - loaclTokenDataSource: loaclTokenDataSource, + localTokenDataSource: localTokenDataSource, localAuthDataSource: localAuthDataSource ) @@ -58,7 +58,7 @@ extension AuthServiceDependency { // MARK: - Plugin let jwtPlugin = JWTPlugin( - loaclTokenDataSource: loaclTokenDataSource + localTokenDataSource: localTokenDataSource ) return AuthServiceDependency( diff --git a/Services/AuthService/Sources/Data/Local/DataSource/LoaclTokenDataSource.swift b/Services/AuthService/Sources/Data/Local/DataSource/LocalTokenDataSource.swift similarity index 90% rename from Services/AuthService/Sources/Data/Local/DataSource/LoaclTokenDataSource.swift rename to Services/AuthService/Sources/Data/Local/DataSource/LocalTokenDataSource.swift index fbccca33..f02d6ef6 100644 --- a/Services/AuthService/Sources/Data/Local/DataSource/LoaclTokenDataSource.swift +++ b/Services/AuthService/Sources/Data/Local/DataSource/LocalTokenDataSource.swift @@ -1,6 +1,6 @@ import Foundation -protocol LoaclTokenDataSource { +protocol LocalTokenDataSource { func registerAccessToken(_ accessToken: String) func fetchAccessToken() -> String? func registerRefreshToken(_ refreshToken: String) diff --git a/Services/AuthService/Sources/Data/Local/DataSource/LoaclTokenDataSourceImpl.swift b/Services/AuthService/Sources/Data/Local/DataSource/LocalTokenDataSourceImpl.swift similarity index 95% rename from Services/AuthService/Sources/Data/Local/DataSource/LoaclTokenDataSourceImpl.swift rename to Services/AuthService/Sources/Data/Local/DataSource/LocalTokenDataSourceImpl.swift index d50a349d..adbea96c 100644 --- a/Services/AuthService/Sources/Data/Local/DataSource/LoaclTokenDataSourceImpl.swift +++ b/Services/AuthService/Sources/Data/Local/DataSource/LocalTokenDataSourceImpl.swift @@ -3,7 +3,7 @@ import Foundation import XDateUtil import KeychainModule -class LoaclTokenDataSourceImpl: LoaclTokenDataSource { +class LocalTokenDataSourceImpl: LocalTokenDataSource { let keychain = KeychainModule() diff --git a/Services/AuthService/Sources/Data/Repository/AuthRepositoryImpl.swift b/Services/AuthService/Sources/Data/Repository/AuthRepositoryImpl.swift index 29e05bd4..4c05732e 100644 --- a/Services/AuthService/Sources/Data/Repository/AuthRepositoryImpl.swift +++ b/Services/AuthService/Sources/Data/Repository/AuthRepositoryImpl.swift @@ -6,23 +6,23 @@ import RxSwift class AuthRepositoryImpl: AuthRepository { private let remoteAuthDataSource: RemoteAuthDataSource - private let loaclTokenDataSource: LoaclTokenDataSource + private let localTokenDataSource: LocalTokenDataSource private let localAuthDataSource: LocalAuthDataSource init(remoteAuthDataSource: RemoteAuthDataSource, - loaclTokenDataSource: LoaclTokenDataSource, + localTokenDataSource: LocalTokenDataSource, localAuthDataSource: LocalAuthDataSource) { self.remoteAuthDataSource = remoteAuthDataSource - self.loaclTokenDataSource = loaclTokenDataSource + self.localTokenDataSource = localTokenDataSource self.localAuthDataSource = localAuthDataSource } func signin(signinEntity: SigninEntity) -> Completable { self.remoteAuthDataSource.signin(request: signinEntity.toSigninRequest()) .do(onSuccess: { [weak self] tokenResponse in - self?.loaclTokenDataSource.registerAccessToken(tokenResponse.accessToken) - self?.loaclTokenDataSource.registerRefreshToken(tokenResponse.refreshToken) - self?.loaclTokenDataSource.registerExpiredAt(tokenResponse.expirationAt) + self?.localTokenDataSource.registerAccessToken(tokenResponse.accessToken) + self?.localTokenDataSource.registerRefreshToken(tokenResponse.refreshToken) + self?.localTokenDataSource.registerExpiredAt(tokenResponse.expirationAt) self?.localAuthDataSource.registerIdAndPassword(id: signinEntity.id, password: signinEntity.password) }).catch { error in let moyaError = error as? MoyaError @@ -48,14 +48,14 @@ class AuthRepositoryImpl: AuthRepository { } func refreshToken() -> Completable { - guard let refershToken = self.loaclTokenDataSource.fetchRefreshToken() else { + guard let refershToken = self.localTokenDataSource.fetchRefreshToken() else { return Completable.error(AuthServiceError.noToken) } return self.remoteAuthDataSource.refreshToken(refreshToken: refershToken) .do(onSuccess: { [weak self] tokenResponse in - self?.loaclTokenDataSource.registerAccessToken(tokenResponse.accessToken) - self?.loaclTokenDataSource.registerRefreshToken(tokenResponse.refreshToken) - self?.loaclTokenDataSource.registerExpiredAt(tokenResponse.expirationAt) + self?.localTokenDataSource.registerAccessToken(tokenResponse.accessToken) + self?.localTokenDataSource.registerRefreshToken(tokenResponse.refreshToken) + self?.localTokenDataSource.registerExpiredAt(tokenResponse.expirationAt) }).catch { [weak self] error in let moyaError = error as? MoyaError guard moyaError?.response?.statusCode != nil else { return .error(AuthServiceError.networkNotWorking) } @@ -68,14 +68,14 @@ class AuthRepositoryImpl: AuthRepository { } func fetchAccessToken() throws -> String { - guard let accessToken = self.loaclTokenDataSource.fetchAccessToken() else { + guard let accessToken = self.localTokenDataSource.fetchAccessToken() else { throw AuthServiceError.noToken } return accessToken } func fetchTokenExpiredDate() throws -> Date { - guard let expiredDate = self.loaclTokenDataSource.fetchExpiredDate() else { + guard let expiredDate = self.localTokenDataSource.fetchExpiredDate() else { throw AuthServiceError.noToken } return expiredDate @@ -91,7 +91,7 @@ class AuthRepositoryImpl: AuthRepository { func logout() -> Completable { Completable.create { completable in - self.loaclTokenDataSource.resetToken() + self.localTokenDataSource.resetToken() completable(.completed) return Disposables.create() } diff --git a/Services/AuthService/Sources/Plugin/JWTPulgin.swift b/Services/AuthService/Sources/Plugin/JWTPulgin.swift index 29ad02d3..6af0b6c3 100644 --- a/Services/AuthService/Sources/Plugin/JWTPulgin.swift +++ b/Services/AuthService/Sources/Plugin/JWTPulgin.swift @@ -32,10 +32,10 @@ public enum JWTTokenType { // MARK: - JWTPlugin final public class JWTPlugin: PluginType { - private let loaclTokenDataSource: LoaclTokenDataSource + private let localTokenDataSource: LocalTokenDataSource - init(loaclTokenDataSource: LoaclTokenDataSource) { - self.loaclTokenDataSource = loaclTokenDataSource + init(localTokenDataSource: LocalTokenDataSource) { + self.localTokenDataSource = localTokenDataSource } public func prepare(_ request: URLRequest, target: TargetType) -> URLRequest { @@ -68,11 +68,11 @@ extension JWTPlugin { } private func fetchAccessToken() -> String? { - self.loaclTokenDataSource.fetchAccessToken() + self.localTokenDataSource.fetchAccessToken() } private func fetchRefreshToken() -> String? { - self.loaclTokenDataSource.fetchRefreshToken() + self.localTokenDataSource.fetchRefreshToken() } }