Skip to content

Commit efb24b8

Browse files
author
Jan
authored
Merge pull request #31 from Liftric/feat/custom-filename
Feature: custom file name
2 parents 81fa632 + 641c874 commit efb24b8

File tree

5 files changed

+18
-30
lines changed

5 files changed

+18
-30
lines changed

README.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,23 @@ sourceSets {
2424
#### Android
2525

2626
```kotlin
27-
val store = KVault(context)
27+
val store = KVault(context, "<fileName>")
2828
```
2929

30+
| Parameter | Description |
31+
| :------------------ | :---------------------------------- |
32+
| fileName (optional) | Name of the shared preferences file |
33+
3034
#### iOS
3135

3236
```kotlin
33-
val store = KVault(serviceName = null, accessGroup = null)
37+
val store = KVault("<serviceName>", "<accessGroup>")
3438
```
3539

36-
| Parameter | Description |
37-
| :----------- | :---------------------------------- |
38-
| serviceName | Used to categories objects. |
39-
| accessGroup | Used to share objects between apps. |
40+
| Parameter | Description |
41+
| :--------------------- | :---------------------------------- |
42+
| serviceName (optional) | Used to categories objects |
43+
| accessGroup (optional) | Used to share objects between apps |
4044

4145
### Setting
4246

buildSrc/src/main/java/Libs.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ object Android {
66
}
77

88
object Versions {
9-
const val Gradle = "7.0.0"
10-
const val Kotlin = "1.5.30"
11-
const val Versioning = "2.14.0"
9+
const val Gradle = "7.1.1"
10+
const val Kotlin = "1.6.10"
11+
const val Versioning = "2.15.1"
1212
const val Crypto = "1.1.0-alpha03"
1313
const val RoboElectric = "4.5.1"
14-
const val TestCore = "1.2.0"
14+
const val TestCore = "1.4.0"
1515
}
1616

1717
object Libs {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

src/androidMain/kotlin/com/liftric/kvault/KVault.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ import android.content.SharedPreferences
55
import androidx.security.crypto.EncryptedSharedPreferences
66
import androidx.security.crypto.MasterKey
77

8-
actual open class KVault(context: Context) {
8+
actual open class KVault(context: Context, fileName: String? = null) {
99
private val encSharedPrefs: SharedPreferences
1010

1111
init {
1212
val masterKey = MasterKey.Builder(context).setKeyScheme(MasterKey.KeyScheme.AES256_GCM).build()
1313
encSharedPrefs = EncryptedSharedPreferences.create(
1414
context,
15-
"secure-shared-preferences",
15+
fileName ?: "secure-shared-preferences",
1616
masterKey,
1717
EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV,
1818
EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM

src/iosMain/kotlin/com/liftric/kvault/KVault.kt

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@ import platform.Security.*
77
import platform.darwin.OSStatus
88
import platform.darwin.noErr
99

10-
internal val NSBundle.Companion.mainIdentifier
11-
get() = this.mainBundle.bundleIdentifier?: "com.liftric.KVault"
12-
1310
/**
1411
* Keychain wrapper.
12+
* Note: Using the deprecated init() the service name was the apps bundle identifier or if null "com.liftric.KVault".
1513
*
1614
* @param serviceName Name of the service. Used to categories entries.
1715
* @param accessGroup Name of the access group. Used to share entries between apps.
@@ -21,20 +19,6 @@ actual open class KVault(
2119
val serviceName: String? = null,
2220
val accessGroup: String? = null
2321
) {
24-
/**
25-
* Initiates a Keychain with the main bundle identifier as the service name and without an access group.
26-
* If the main bundle identifier is null, it will fallback to `com.liftric.KVault`.
27-
*/
28-
@Deprecated(
29-
"""
30-
Will be removed in a future version,
31-
please use the primary constructor.
32-
Check your service name before migrating.
33-
""",
34-
level = DeprecationLevel.WARNING
35-
)
36-
constructor() : this(NSBundle.mainIdentifier, null)
37-
3822
/**
3923
* Saves a string value in the Keychain.
4024
* @param key The key to store

0 commit comments

Comments
 (0)