Skip to content

Commit c3b5a52

Browse files
Merge pull request #41 from Web3Auth/feat/remove-application-class
Removing application context and remove We3AuthApp
2 parents 6368988 + 2ed712a commit c3b5a52

File tree

4 files changed

+12
-33
lines changed

4 files changed

+12
-33
lines changed

core/src/main/AndroidManifest.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@
33
package="com.web3auth.core">
44

55
<uses-permission android:name="android.permission.INTERNET" />
6-
7-
<application
8-
android:name=".Web3AuthApp"/>
9-
106
<queries>
117
<intent>
128
<action android:name="android.support.customtabs.action.CustomTabsService" />

core/src/main/java/com/web3auth/core/Web3Auth.kt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,6 @@ class Web3Auth(web3AuthOptions: Web3AuthOptions) {
5454
private var web3AuthOption = web3AuthOptions
5555

5656
init {
57-
//initiate keyStore
58-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
59-
initiateKeyStoreManager()
60-
}
61-
6257
// Build init params
6358
val initParams = mutableMapOf(
6459
"clientId" to web3AuthOptions.clientId,
@@ -74,11 +69,15 @@ class Web3Auth(web3AuthOptions: Web3AuthOptions) {
7469
this.initParams = initParams
7570
this.context = web3AuthOptions.context
7671

72+
KeyStoreManagerUtils.initializePreferences(context.applicationContext)
73+
74+
//initiate keyStore
75+
initiateKeyStoreManager()
76+
7777
//authorize session
7878
authorizeSession()
7979
}
8080

81-
@RequiresApi(Build.VERSION_CODES.M)
8281
private fun initiateKeyStoreManager() {
8382
KeyStoreManagerUtils.getKeyGenerator()
8483
}

core/src/main/java/com/web3auth/core/Web3AuthApp.kt

Lines changed: 0 additions & 18 deletions
This file was deleted.

core/src/main/java/com/web3auth/core/keystore/KeyStoreManagerUtils.kt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package com.web3auth.core.keystore
22

3+
import android.content.Context
34
import android.security.keystore.KeyGenParameterSpec
45
import android.security.keystore.KeyProperties
56
import androidx.security.crypto.EncryptedSharedPreferences
67
import androidx.security.crypto.MasterKeys
7-
import com.web3auth.core.Web3AuthApp
88
import org.bouncycastle.asn1.ASN1EncodableVector
99
import org.bouncycastle.asn1.ASN1Integer
1010
import org.bouncycastle.asn1.DERSequence
@@ -33,14 +33,16 @@ object KeyStoreManagerUtils {
3333
private lateinit var encryptedPairData: Pair<ByteArray, ByteArray>
3434

3535
private val masterKeyAlias = MasterKeys.getOrCreate(MasterKeys.AES256_GCM_SPEC)
36-
private val sharedPreferences = Web3AuthApp.getContext()?.let {
37-
EncryptedSharedPreferences.create(
36+
private lateinit var sharedPreferences: EncryptedSharedPreferences
37+
38+
fun initializePreferences(context: Context) {
39+
sharedPreferences = EncryptedSharedPreferences.create(
3840
"Web3Auth",
3941
masterKeyAlias,
40-
it,
42+
context,
4143
EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV,
4244
EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM
43-
)
45+
) as EncryptedSharedPreferences
4446
}
4547

4648
/**

0 commit comments

Comments
 (0)