Skip to content

feat(auth)!: add Yggdrasil site metadata store and refactor account providers - #335

Merged
H2Sxxa merged 3 commits into
mainfrom
feat/yggdrasil-site-metadata
Nov 29, 2026
Merged

H2Sxxa merged 3 commits into
mainfrom
feat/yggdrasil-site-metadata

Conversation

@H2Sxxa

@H2Sxxa H2Sxxa commented Nov 28, 2026

Copy link
Copy Markdown
Member

Closes #302

Summary

  • Normalized Yggdrasil site metadata store (accounts/yggdrasil_sites.json):

    • Added YggdrasilSiteId, YggdrasilSiteMetadata (wrapping nidhogg::types::meta::Meta + fetched_at), YggdrasilSiteIndex, and YggdrasilSiteStore.
    • Tracks AccountId -> YggdrasilSiteId inside YggdrasilSiteIndex so AccountRef remains generic ({ account_id, authorizer }) while supporting O(N) memory-backed GC and legacy account backfill.
    • Added single-flight request deduplication via tokio::sync::watch, configurable TTL (DEFAULT_YGGDRASIL_SITE_METADATA_TTL / AccountStore::with_site_metadata_ttl), structured tracing::warn! on network failure preserving last-known-good metadata, and explicit disk persistence error propagation.
    • Added AccountStore APIs: site_metadata, account_site_metadata, refresh_site_metadata, prune_unused_sites, remove_site_metadata, and clear_site_metadata.
  • Unified SwappableClient integration:

    • Wired SwappableClient into YggdrasilAuthorizer, YggdrasilAccountProvider (via Nidhogg::with_client), MicrosoftAccountProvider (all microsoft_protocol calls), and YggdrasilSiteStore.
    • Enabled http under yggdrasil-auth in elemental-core and elemental-kit.
  • Pure-data Account + AccountProvider / TextureProvider separation:

    • Simplified Account to a pure synchronous data trait (credential(&self) -> Credential, no #[serde(skip)] runtime handles or network methods).
    • Introduced TypedAccountProvider / AccountProvider and TypedTextureProvider / TextureProvider, so non-texture providers like OfflineAccountProvider have no texture methods and AccountStore::supports_textures can query capability from the registry.
    • Added AccountStore facade methods for textures, upload_skin, delete_skin, upload_cape, delete_cape, and select_cape, and updated SkinStore::upload to accept (&AccountStore, AccountId, ...).

Breaking Changes

  • Account::credential(&self) is now synchronous (Credential instead of async fn ... -> Result<Credential>).
  • Removed network/texture/metadata methods from Account; use AccountStore (refresh, textures, upload_skin, delete_skin, upload_cape, delete_cape, select_cape, account_site_metadata) or the AccountProvider / TextureProvider traits.
  • AccountRegistry::new(http_client) and AccountRegistry::with / with_textures now register TypedAccountProvider / TypedTextureProvider instances instead of Account types.
  • AccountStore::with_registry(scope, http_client, registry) takes a shared SwappableClient (or use AccountStore::open_with_http_client).
  • YggdrasilAuthorizer now uses YggdrasilAuthorizer::new(...) / YggdrasilAuthorizer::offline(...) constructors with .with_client_token(...) / .with_http_client(...).
  • Removed AccountSkinExt and LocalSkin; use SkinStore::upload(&accounts, account_id, skin_id, model).

Verification

  • .\format.bat
  • cargo test -p elemental-launcher --test account_store --test skin_store (9 passed)
  • cargo test -p elemental-launcher --features yggdrasil-auth --test account_store --test offline_yggdrasil --test yggdrasil_site_metadata --test send_futures --test skin_store (19 passed)
  • cargo check -p elemental-kit
  • cargo check -p elemental-kit --features yggdrasil-auth
  • cargo check -p launchpad
  • deslop-please elemental-core -F yggdrasil-auth & deslop-please elemental-launcher -F yggdrasil-auth (no errors in elemental_core::auth or elemental_launcher::account)

…roviders

- Persist normalized Yggdrasil site metadata in accounts/yggdrasil_sites.json with single-flight fetching, TTL refresh, offline fallback, and account-link GC
- Integrate SwappableClient into YggdrasilAuthorizer, YggdrasilAccountProvider, MicrosoftAccountProvider, and YggdrasilSiteStore
- Separate pure-data Account from TypedAccountProvider and TypedTextureProvider, moving network/texture operations to providers and AccountStore

BREAKING CHANGE: Account::credential is now synchronous, network/texture methods moved from Account/SkinStore to TypedAccountProvider/TypedTextureProvider/AccountStore, and AccountRegistry/AccountStore constructors take SwappableClient and provider instances.

Closes #302
@codacy-production

codacy-production Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Not up to standards ⛔

🔴 Issues 2 medium

Alerts:
⚠ 2 issues (≤ 0 issues of at least minor severity)

Results:
2 new issues

Category Results
Complexity 2 medium

View in Codacy

🟢 Metrics 211 complexity · 2 duplication

Metric Results
Complexity 211
Duplication 2

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

Normalize YggdrasilSiteId to lowercase scheme/host without default ports, query/fragment, or trailing slashes, and share it across YggdrasilAuthorizer, YggdrasilAccountProvider, and YggdrasilSiteStore.
@H2Sxxa
H2Sxxa merged commit 19a740c into main Nov 29, 2026
1 of 2 checks passed
@H2Sxxa
H2Sxxa deleted the feat/yggdrasil-site-metadata branch November 29, 2026 05:02
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.

Add a normalized, cleanable Yggdrasil site metadata store keyed by base_url

1 participant