feat: Add Xiaomi MiMo provider with session-based authentication#10
Merged
Conversation
…s, add test coverage (#9) * refactor: clean up code structure and improve utility functions * refactor: update detekt configuration for improved code analysis
… Xiaomi and Nebius providers
a37589c to
42738f3
Compare
3e537df to
abad3f6
Compare
- Remove unused HTTP constants from NebiusProviderClient - Remove unused extractCookiesFromBFlag from NebiusCurlParser - Refactor CurlCookieExtractor to reduce return count - Fix ArgumentListWrapping in TokenPulseStatusBarWidget and BalanceFormatter - Extract formatXiaomiTokenPlanCredits and formatUsagePercentage to reduce complexity - Add SHORT_FORMAT constant for magic number - Add 1000000000 to detekt ignore list - Increase TooManyFunctions threshold to 30 - Exclude test files from LargeClass rule
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds Xiaomi MiMo as a supported provider with two connection types: API (pay-as-you-go) and Token Plan (subscription Credits), using session-based authentication like Nebius.
Why
Xiaomi MiMo platform requires session cookies for balance/usage tracking, similar to Nebius. This PR implements the full provider with shared infrastructure for session-based providers.
Changes
New Provider
XiaomiProviderClient— Fetches balance (XIAOMI_API) and Token Plan usage (XIAOMI_TOKEN_PLAN) from Xiaomi platformXiaomiConnectDialog— UI for capturing Xiaomi session via cURL pastingConnectionType.XIAOMI_APIandXIAOMI_TOKEN_PLAN— New connection types with proper metadataShared Infrastructure (Refactoring)
SessionParser— Generic session parsing with validation, shared across Nebius and XiaomiHttpErrorHandler— HTTP error code mapping to ProviderResult.Failure, shared across providersCurlCookieExtractor— Cookie extraction from cURL commands, shared across connect dialogsStatus Bar Improvements
formatAutoModenow iterates all accounts until finding usable data (fixes "TP: --" bug)Bug Fixes
Accountfields changed tovarfor XStream serialization (fixes accounts not persisting)XIAOMI_TOKEN_PLANadded tousagePercentageTypes(fixes percentage display)Test Coverage
Files Modified
src/main/kotlin/.../provider/SessionParser.kt(new)src/main/kotlin/.../provider/HttpErrorHandler.kt(new)src/main/kotlin/.../utils/CurlCookieExtractor.kt(new)src/main/kotlin/.../provider/xiaomi/XiaomiProviderClient.kt(new)src/main/kotlin/.../ui/XiaomiConnectDialog.kt(new)src/main/kotlin/.../provider/nebius/NebiusProviderClient.kt(refactored)src/main/kotlin/.../ui/NebiusCurlParser.kt(refactored)src/main/kotlin/.../ui/BalanceFormatter.kt(enhanced)src/main/kotlin/.../ui/TokenPulseStatusBarWidget.kt(enhanced)src/main/kotlin/.../settings/Account.kt(fixed)src/test/kotlin/.../provider/xiaomi/XiaomiProviderClientTest.kt(new)src/test/kotlin/.../ui/BalanceFormatterTest.kt(enhanced)src/test/kotlin/.../ui/XiaomiConnectDialogTest.kt(new)Verification