Parse custom_recovery_passphrase_settings from Element .well-known

Add CustomRecoveryPassphraseRequirements to ElementWellKnown and decode
the custom_recovery_passphrase_settings block (currently just
min_character_count) from the homeserver's element.json. Invalid specs
(missing or non-positive min_character_count) are logged and mapped to
null so the setup flow falls back to the generated-key path. Field names
match the ESS well-known schema (element-enterprise#261).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jenna Vassar
2026-06-02 13:33:18 -07:00
parent 748454f34d
commit 2931418018
7 changed files with 181 additions and 1 deletions
@@ -0,0 +1,23 @@
/*
* Copyright (c) 2026 Element Creations Ltd.
*
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
* Please see LICENSE files in the repository root for full details.
*/
package io.element.android.libraries.wellknown.api
/**
* Server-driven requirements for a user-chosen recovery passphrase. Today the only rule
* is a minimum character count; additional rules can be added here as the well-known
* schema (`custom_recovery_passphrase_settings`) grows.
*/
data class CustomRecoveryPassphraseRequirements(
val minCharacterCount: Int,
) {
/** True when [input] meets every active rule. */
fun isSatisfiedBy(input: String): Boolean = isSatisfiedBy(input.length)
/** True when an input of [length] characters meets every active rule. */
fun isSatisfiedBy(length: Int): Boolean = length >= minCharacterCount
}
@@ -15,4 +15,5 @@ data class ElementWellKnown(
val brandColor: String?,
val notificationSound: String?,
val identityProviderAppScheme: String?,
val customRecoveryPassphraseRequirements: CustomRecoveryPassphraseRequirements?,
)