Skip to content

Commit

Permalink
Add CredentialPack.clearPacks (#38)
Browse files Browse the repository at this point in the history
Signed-off-by: Tiago Nascimento <[email protected]>
  • Loading branch information
theosirian authored Nov 7, 2024
1 parent e5f7d91 commit 976f73b
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions MobileSdk/src/main/java/com/spruceid/mobile/sdk/CredentialPack.kt
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,19 @@ class CredentialPack {
CredentialPackContents(id, list().map { it.id() })

companion object {
/**
* Clears all stored CredentialPacks.
*/
fun clearPacks(storage: StorageManagerInterface) {
try {
storage.list()
.filter { it.startsWith(CredentialPackContents.STORAGE_PREFIX) }
.forEach { storage.remove(it) }
} catch (e: Exception) {
throw ClearingException("unable to clear CredentialPacks", e)
}
}

/**
* List all CredentialPacks.
*
Expand Down Expand Up @@ -361,3 +374,4 @@ class CredentialPackContents {
class ParsingException(message: String, cause: Throwable?) : Exception(message, cause)
class LoadingException(message: String, cause: Throwable) : Exception(message, cause)
class SavingException(message: String, cause: Throwable) : Exception(message, cause)
class ClearingException(message: String, cause: Throwable) : Exception(message, cause)

0 comments on commit 976f73b

Please sign in to comment.