Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -573,23 +573,16 @@ class AppPasskeyProviderActivity : BaseGitActivity() {

try {
val publicCredential = createdCredential.credential
val credentialWithBinding =
publicCredential.copy(
createdByCallerType = verifiedContext.callerType,
createdByPackage = verifiedContext.callingPackage,
createdByCertificateDigest = verifiedContext.signingCertificateDigests.firstOrNull(),
verifiedOrigin = verifiedContext.origin,
)

val responseJson =
PasskeyProviderUtils.buildAttestationResponse(
credentialWithBinding,
publicCredential,
createRequest.requestJson,
verifiedContext,
)

val saveResult = createdCredential.usePrivateKeySuspend { privateKey ->
passkeyStorage.saveCredential(credentialWithBinding, privateKey)
passkeyStorage.saveCredential(publicCredential, privateKey)
}
if (saveResult.isErr) {
val error: Throwable? =
Expand All @@ -611,12 +604,12 @@ class AppPasskeyProviderActivity : BaseGitActivity() {
passkeyRepositoryState.onCredentialSaved()
generationProvider.bumpWorktreeGeneration()
metadataIndex.put(
credentialWithBinding.credentialId,
publicCredential.credentialId,
MetadataEntry(
userName = credentialWithBinding.user.name,
userDisplayName = credentialWithBinding.user.displayName,
rpId = credentialWithBinding.rpId,
createdAt = credentialWithBinding.createdAt.toEpochMilliseconds(),
userName = publicCredential.user.name,
userDisplayName = publicCredential.user.displayName,
rpId = publicCredential.rpId,
createdAt = publicCredential.createdAt.toEpochMilliseconds(),
),
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

package app.passwordstore.passkeys.model

import app.passwordstore.passkeys.crypto.CallerType
import kotlin.time.Instant
import kotlinx.serialization.Serializable

Expand All @@ -23,10 +22,6 @@ public data class PasskeyCredential(
public val uvInitialized: Boolean = true,
public val backupEligible: Boolean = true,
public val backupState: Boolean = false,
public val createdByCallerType: CallerType? = null,
public val createdByPackage: String? = null,
public val createdByCertificateDigest: String? = null,
public val verifiedOrigin: String? = null,
) {

init {
Expand All @@ -51,10 +46,6 @@ public data class PasskeyCredential(
if (uvInitialized != other.uvInitialized) return false
if (backupEligible != other.backupEligible) return false
if (backupState != other.backupState) return false
if (createdByCallerType != other.createdByCallerType) return false
if (createdByPackage != other.createdByPackage) return false
if (createdByCertificateDigest != other.createdByCertificateDigest) return false
if (verifiedOrigin != other.verifiedOrigin) return false
return true
}

Expand All @@ -69,10 +60,6 @@ public data class PasskeyCredential(
result = 31 * result + uvInitialized.hashCode()
result = 31 * result + backupEligible.hashCode()
result = 31 * result + backupState.hashCode()
result = 31 * result + (createdByCallerType?.hashCode() ?: 0)
result = 31 * result + (createdByPackage?.hashCode() ?: 0)
result = 31 * result + (createdByCertificateDigest?.hashCode() ?: 0)
result = 31 * result + (verifiedOrigin?.hashCode() ?: 0)
return result
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import app.passwordstore.passkeys.cbor.Cbor
import app.passwordstore.passkeys.cbor.CborMap
import app.passwordstore.passkeys.cbor.CborValue
import app.passwordstore.passkeys.cbor.toCborIntegerArray
import app.passwordstore.passkeys.crypto.CallerType
import java.math.BigInteger
import kotlin.time.Instant
import logcat.LogPriority
Expand All @@ -31,10 +30,6 @@ public data class StoredCredential(
val extensions: Extensions = Extensions(),
val backupEligible: Boolean = true,
val backupState: Boolean = false,
val createdByCallerType: CallerType? = null,
val createdByPackage: String? = null,
val createdByCertificateDigest: String? = null,
val verifiedOrigin: String? = null,
) : AutoCloseable {

@Volatile private var wiped = false
Expand Down Expand Up @@ -70,18 +65,6 @@ public data class StoredCredential(
map["extensions"] = CborValue.Map(extensions.toCborMap())
map["backup_eligible"] = if (backupEligible) CborValue.True else CborValue.False
map["backup_state"] = if (backupState) CborValue.True else CborValue.False
createdByCallerType?.let {
map["created_by_caller_type"] = CborValue.TextString(it.name)
} ?: run { map["created_by_caller_type"] = CborValue.Null }
createdByPackage?.let {
map["created_by_package"] = CborValue.TextString(it)
} ?: run { map["created_by_package"] = CborValue.Null }
createdByCertificateDigest?.let {
map["created_by_cert_digest"] = CborValue.TextString(it)
} ?: run { map["created_by_cert_digest"] = CborValue.Null }
verifiedOrigin?.let {
map["verified_origin"] = CborValue.TextString(it)
} ?: run { map["verified_origin"] = CborValue.Null }
return Cbor.fromMap(CborMap.from(map)).toBytes()
}

Expand All @@ -97,10 +80,6 @@ public data class StoredCredential(
uvInitialized = true,
backupEligible = backupEligible,
backupState = backupState,
createdByCallerType = createdByCallerType,
createdByPackage = createdByPackage,
createdByCertificateDigest = createdByCertificateDigest,
verifiedOrigin = verifiedOrigin,
)
}

Expand All @@ -126,10 +105,6 @@ public data class StoredCredential(
if (extensions != other.extensions) return false
if (backupEligible != other.backupEligible) return false
if (backupState != other.backupState) return false
if (createdByCallerType != other.createdByCallerType) return false
if (createdByPackage != other.createdByPackage) return false
if (createdByCertificateDigest != other.createdByCertificateDigest) return false
if (verifiedOrigin != other.verifiedOrigin) return false
return true
}

Expand All @@ -146,10 +121,6 @@ public data class StoredCredential(
result = 31 * result + extensions.hashCode()
result = 31 * result + backupEligible.hashCode()
result = 31 * result + backupState.hashCode()
result = 31 * result + (createdByCallerType?.hashCode() ?: 0)
result = 31 * result + (createdByPackage?.hashCode() ?: 0)
result = 31 * result + (createdByCertificateDigest?.hashCode() ?: 0)
result = 31 * result + (verifiedOrigin?.hashCode() ?: 0)
return result
}

Expand Down Expand Up @@ -211,22 +182,6 @@ public data class StoredCredential(
val extensionsMap = map.getMap("extensions")
val backupEligible = map.getBoolean("backup_eligible") ?: true
val backupState = map.getBoolean("backup_state") ?: false
val createdByCallerType =
if (map.isNull("created_by_caller_type")) null
else
map.getString("created_by_caller_type")?.let {
try {
CallerType.valueOf(it)
} catch (_: Exception) {
null
}
}
val createdByPackage =
if (map.isNull("created_by_package")) null else map.getString("created_by_package")
val createdByCertificateDigest =
if (map.isNull("created_by_cert_digest")) null else map.getString("created_by_cert_digest")
val verifiedOrigin =
if (map.isNull("verified_origin")) null else map.getString("verified_origin")

return StoredCredential(
id = id,
Expand All @@ -241,10 +196,6 @@ public data class StoredCredential(
extensions = extensionsMap?.let { Extensions.fromCborMap(it) } ?: Extensions(),
backupEligible = backupEligible,
backupState = backupState,
createdByCallerType = createdByCallerType,
createdByPackage = createdByPackage,
createdByCertificateDigest = createdByCertificateDigest,
verifiedOrigin = verifiedOrigin,
)
}

Expand Down Expand Up @@ -301,10 +252,6 @@ public data class StoredCredential(
extensions = Extensions(),
backupEligible = credential.backupEligible,
backupState = credential.backupState,
createdByCallerType = credential.createdByCallerType,
createdByPackage = credential.createdByPackage,
createdByCertificateDigest = credential.createdByCertificateDigest,
verifiedOrigin = credential.verifiedOrigin,
)
}
}
Expand Down

This file was deleted.