VaultEntry.kt

2.2 KB · raw

1package com.peachpasswords.vault23import android.os.Parcelable4import kotlinx.parcelize.Parcelize5import kotlinx.serialization.Serializable67@Parcelize8@Serializable9data class VaultEntry(10    val id: String,11    val type: String? = null,12    val title: String,13    val username: String? = null,14    val email: String? = null,15    val password: String? = null,16    val url: String? = null,17    val additionalUrls: List<String>? = null,18    val totp: String? = null,19    val notes: String? = null,20    val breach: Int? = null,21    val passwordChangedAt: Long? = null,22    /** Past passwords, newest first. Captured automatically on password change. */23    val passwordHistory: List<PasswordHistoryItem>? = null,24    val canary: Canary? = null,25    val createdAt: Long,26    val modifiedAt: Long,27    val deletedAt: Long? = null,28    val tags: List<String>? = null,29    val passkey: PasskeyData? = null,30    val signCount: Int? = null,31    val lastUsedAt: Long? = null,32    val cardholderName: String? = null,33    val cardNumber: String? = null,34    val expMonth: String? = null,35    val expYear: String? = null,36    val cvc: String? = null,37    val cardNickname: String? = null,38    val rpId: String? = null,39    val rpName: String? = null,40    val credentialId: String? = null,41    val publicKeyCose: String? = null,42    val userHandle: String? = null,43    val userName: String? = null,44    val userDisplayName: String? = null,45    val algorithm: Int? = null,46    val aaguid: String? = null,47    val backupEligible: Boolean? = null,48    val backupState: Boolean? = null,49    val browser: String? = null,50    val transports: List<String>? = null,51) : Parcelable5253fun VaultEntry.isLogin() = type == "login" || type == null54fun VaultEntry.isNote() = type == "note"55fun VaultEntry.isCard() = type == "card"56fun VaultEntry.isDeleted() = deletedAt != null57fun VaultEntry.hasTOTP() = !totp.isNullOrBlank()58fun VaultEntry.hasPasskey() = passkey != null59fun VaultEntry.isBreach() = (breach ?: 0) > 06061fun VaultEntry.domainKey(): String? {62    val urlStr = url ?: return null63    return try {64        val host = java.net.URL(urlStr).host65        host.removePrefix("www.")66    } catch (_: Exception) {67        null68    }69}