Skip to content

Conversation

@lukejmann
Copy link
Contributor

@lukejmann lukejmann commented Oct 16, 2025

This PR implements the universal add factor feature described here: https://www.notion.so/worldcoin/Backup-Service-Universal-Add-Factor-Proposal-2548614bdf8c80b5a872c3a08d43ed67?source=copy_link

tldr: we extend the add_factor flow to include all factor combinations, not just passkey->oidc

@lukejmann lukejmann changed the title universal add factor pt 1 Universal Add Factor Oct 16, 2025
return Err(BackupManagerError::ETagNotFound);
};

metadata.keys.push(encryption_key);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't we check if the key already exist and skip if it does?

}
}
// best-effort cleanup if we inserted lookup above when not needed
let _ = factor_lookup
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't first check lookup_insert_succeeded before the cleanup here?

)
.await?;
(
serde_json::Value::String(STANDARD.encode(new_factor_challenge)),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some parts of the code we use STANDARD others URL_SAFE_NO_PAD. It'd be simpler to settle on one flavor.

/// # Errors
/// - `BackupManagerError::BackupNotFound` - if the backup does not exist.
/// - `BackupManagerError::ETagNotFound` - if `ETag` is missing (unexpected).
pub async fn add_encryption_key_only(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

discussing in Slack

new_factor: NewFactor,
/// Optional; defaults to PASSKEY to preserve current clients
#[serde(default)]
existing_factor_kind: Option<ExistingFactorKind>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we really need this and we need to distinguish the challenge_type in the challenge_token. I don't think having that is adding much. thoughts @aurel-fr too?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants