Skip to content

Commit 0ae6e35

Browse files
authored
Merge branch 'master' into chore/update-terms
2 parents edc404d + 9159351 commit 0ae6e35

3 files changed

Lines changed: 13 additions & 3 deletions

File tree

AGENTS.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@ suspend fun getData(): Result<Data> = withContext(Dispatchers.IO) {
164164
- ALWAYS when fixing lint or test failures prefer to do the minimal amount of changes to fix the issues
165165
- USE single-line commit messages under 50 chars; use conventional commit messages template format: `feat: add something new`
166166
- USE `git diff HEAD sourceFilePath` to diff an uncommitted file against the last commit
167-
- ALWAYS run `git status` to check ALL uncommitted changes after completing any code edits, then provide exactly 3 commit message suggestions covering the ENTIRE uncommitted diff
167+
- NEVER capitalize words in commit messages
168+
- ALWAYS run `git status` to check ALL uncommitted changes after completing any code edits, then reply with 3 commit message suggestions covering the ENTIRE uncommitted diff
168169
- ALWAYS check existing code patterns before implementing new features
169170
- USE existing extensions and utilities rather than creating new ones
170171
- ALWAYS consider applying YAGNI (You Ain't Gonna Need It) principle for new code

app/src/main/java/to/bitkit/data/keychain/AndroidKeyStore.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class AndroidKeyStore(
2828
generateKey()
2929
}
3030

31-
private fun generateKey() {
31+
private fun generateKey(alias: String = this.alias) {
3232
if (!keyStore.containsAlias(alias)) {
3333
try {
3434
val generator = KeyGenerator.getInstance(algorithm, type)
@@ -80,4 +80,11 @@ class AndroidKeyStore(
8080
val decryptedDataBytes = cipher.doFinal(actualEncryptedData)
8181
return decryptedDataBytes
8282
}
83+
84+
fun resetEncryptionKey() {
85+
if (keyStore.containsAlias(alias)) {
86+
keyStore.deleteEntry(alias)
87+
}
88+
generateKey()
89+
}
8390
}

app/src/main/java/to/bitkit/data/keychain/Keychain.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,10 @@ class Keychain @Inject constructor(
9696
suspend fun wipe() {
9797
val keys = snapshot.asMap().keys
9898
keychain.edit { it.clear() }
99+
keyStore.resetEncryptionKey()
100+
val count = keys.size
99101

100-
Logger.info("Deleted all keychain entries: ${keys.joinToString()}")
102+
Logger.info("Reset keychain encryption key and deleted all '$count' entries")
101103
}
102104

103105
private val String.indexed: Preferences.Key<String>

0 commit comments

Comments
 (0)