-
Notifications
You must be signed in to change notification settings - Fork 1
[Refactor/#17] DI 생성 책임을 app 모듈로 이관 #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
500c205
Refactor: Security DI 모듈 app으로 이동
wjdrjs00 de4dd74
Refactor: DataStore 파일 경로 변경
wjdrjs00 62ad287
Refactor: DataStore DI 모듈 app으로 이동
wjdrjs00 630973c
Refactor: NetworkModule, Qualifier 파일 경로 변경
wjdrjs00 bdca6f8
Refactor: TokenProvider 인터페이스 정의
wjdrjs00 ac07ae0
Chore: 오타 수정
wjdrjs00 8034670
Chore: network 모듈 hilt 의존성 제거
wjdrjs00 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
app/src/main/java/com/threegap/bitnagil/di/core/DataStoreModule.kt
This file contains hidden or 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,35 @@ | ||
| package com.threegap.bitnagil.di.core | ||
|
|
||
| import android.content.Context | ||
| import com.threegap.bitnagil.datastore.auth.crypto.TokenCrypto | ||
| import com.threegap.bitnagil.datastore.auth.serializer.AuthTokenSerializer | ||
| import com.threegap.bitnagil.datastore.auth.storage.AuthTokenDataStore | ||
| import com.threegap.bitnagil.datastore.auth.storage.AuthTokenStorageFactory | ||
| import com.threegap.bitnagil.security.crypto.Crypto | ||
| import dagger.Module | ||
| import dagger.Provides | ||
| import dagger.hilt.InstallIn | ||
| import dagger.hilt.android.qualifiers.ApplicationContext | ||
| import dagger.hilt.components.SingletonComponent | ||
| import javax.inject.Singleton | ||
|
|
||
| @Module | ||
| @InstallIn(SingletonComponent::class) | ||
| object DataStoreModule { | ||
|
|
||
| @Singleton | ||
| @Provides | ||
| fun provideTokenCrypto(crypto: Crypto): TokenCrypto = | ||
| object : TokenCrypto { | ||
| override fun encrypt(bytes: ByteArray): ByteArray = crypto.encrypt(bytes) | ||
|
|
||
| override fun decrypt(bytes: ByteArray): ByteArray = crypto.decrypt(bytes) | ||
| } | ||
|
|
||
| @Provides | ||
| @Singleton | ||
| fun provideAuthTokenStorage( | ||
| @ApplicationContext context: Context, | ||
| serializer: AuthTokenSerializer, | ||
| ): AuthTokenDataStore = AuthTokenStorageFactory.create(context, serializer) | ||
| } |
This file contains hidden or 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
2 changes: 1 addition & 1 deletion
2
...ava/com/threegap/bitnagil/di/Qualifier.kt → ...om/threegap/bitnagil/di/core/Qualifier.kt
This file contains hidden or 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 |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| package com.threegap.bitnagil.di | ||
| package com.threegap.bitnagil.di.core | ||
|
|
||
| import javax.inject.Qualifier | ||
|
|
||
|
|
||
This file contains hidden or 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 hidden or 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
6 changes: 6 additions & 0 deletions
6
core/datastore/src/main/java/com/threegap/bitnagil/datastore/auth/crypto/TokenCrypto.kt
This file contains hidden or 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,6 @@ | ||
| package com.threegap.bitnagil.datastore.auth.crypto | ||
|
|
||
| interface TokenCrypto { | ||
| fun encrypt(bytes: ByteArray): ByteArray | ||
| fun decrypt(bytes: ByteArray): ByteArray | ||
| } |
2 changes: 1 addition & 1 deletion
2
...gap/bitnagil/datastore/model/AuthToken.kt → ...itnagil/datastore/auth/model/AuthToken.kt
This file contains hidden or 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
6 changes: 6 additions & 0 deletions
6
...tore/src/main/java/com/threegap/bitnagil/datastore/auth/serializer/AuthTokenSerializer.kt
This file contains hidden or 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,6 @@ | ||
| package com.threegap.bitnagil.datastore.auth.serializer | ||
|
|
||
| import androidx.datastore.core.Serializer | ||
| import com.threegap.bitnagil.datastore.auth.model.AuthToken | ||
|
|
||
| interface AuthTokenSerializer : Serializer<AuthToken> |
14 changes: 7 additions & 7 deletions
14
...tastore/serializer/AuthTokenSerializer.kt → ...uth/serializer/AuthTokenSerializerImpl.kt
This file contains hidden or 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
4 changes: 2 additions & 2 deletions
4
...l/datastore/storage/AuthTokenDataStore.kt → ...astore/auth/storage/AuthTokenDataStore.kt
This file contains hidden or 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
7 changes: 3 additions & 4 deletions
7
...tastore/storage/AuthTokenDataStoreImpl.kt → ...re/auth/storage/AuthTokenDataStoreImpl.kt
This file contains hidden or 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
20 changes: 20 additions & 0 deletions
20
...ore/src/main/java/com/threegap/bitnagil/datastore/auth/storage/AuthTokenStorageFactory.kt
This file contains hidden or 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,20 @@ | ||
| package com.threegap.bitnagil.datastore.auth.storage | ||
|
|
||
| import android.content.Context | ||
| import androidx.datastore.core.DataStoreFactory | ||
| import androidx.datastore.core.handlers.ReplaceFileCorruptionHandler | ||
| import androidx.datastore.dataStoreFile | ||
| import com.threegap.bitnagil.datastore.auth.model.AuthToken | ||
| import com.threegap.bitnagil.datastore.auth.serializer.AuthTokenSerializer | ||
|
|
||
| object AuthTokenStorageFactory { | ||
| fun create(context: Context, serializer: AuthTokenSerializer): AuthTokenDataStore { | ||
| val dataStore = DataStoreFactory.create( | ||
| serializer = serializer, | ||
| produceFile = { context.dataStoreFile("auth-token.enc") }, | ||
| corruptionHandler = ReplaceFileCorruptionHandler { AuthToken() }, | ||
| ) | ||
|
|
||
| return AuthTokenDataStoreImpl(dataStore) | ||
| } | ||
| } |
37 changes: 0 additions & 37 deletions
37
core/datastore/src/main/java/com/threegap/bitnagil/datastore/di/DataStoreModule.kt
This file was deleted.
Oops, something went wrong.
6 changes: 0 additions & 6 deletions
6
core/datastore/src/main/java/com/threegap/bitnagil/datastore/serializer/TokenSerializer.kt
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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
4 changes: 2 additions & 2 deletions
4
...ore/storage/AuthTokenDataStoreImplTest.kt → ...uth/storage/AuthTokenDataStoreImplTest.kt
This file contains hidden or 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
|
wjdrjs00 marked this conversation as resolved.
|
This file contains hidden or 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
7 changes: 3 additions & 4 deletions
7
core/network/src/main/java/com/threegap/bitnagil/network/auth/AuthInterceptor.kt
This file contains hidden or 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
10 changes: 2 additions & 8 deletions
10
core/network/src/main/java/com/threegap/bitnagil/network/auth/TokenAuthenticator.kt
This file contains hidden or 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
5 changes: 5 additions & 0 deletions
5
core/network/src/main/java/com/threegap/bitnagil/network/token/TokenProvider.kt
This file contains hidden or 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,5 @@ | ||
| package com.threegap.bitnagil.network.token | ||
|
|
||
| interface TokenProvider { | ||
| suspend fun getToken(): String? | ||
| } |
This file contains hidden or 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 |
|---|---|---|
| @@ -1,6 +1,5 @@ | ||
| plugins { | ||
| alias(libs.plugins.bitnagil.android.library) | ||
| alias(libs.plugins.bitnagil.android.hilt) | ||
| } | ||
|
|
||
| android { | ||
|
|
||
This file contains hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.