docs/stepfun.md
StepFun (阶跃星辰) is a web-based provider. Usage data comes from the Step Plan rate limit API, authenticated via an Oasis-Token obtained through a username + password login flow.
Authentication — Three methods (in priority order):
GET https://platform.stepfun.com → INGRESSCOOKIEPOST …/RegisterDevice → anonymous tokenPOST …/SignInByPassword → authenticated Oasis-Token
The token is cached in Keychain-backed CookieHeaderCache and reused until it expires.STEPFUN_USERNAME + STEPFUN_PASSWORD, or STEPFUN_TOKEN.Rate limit endpoint
POST https://platform.stepfun.com/api/step.openapi.devcenter.Dashboard/QueryStepPlanRateLimitCookie: Oasis-Token=<token>, Content-Type: application/jsonfive_hour_usage_left_rate — remaining fraction for the 5-hour window (e.g. 0.99781543)weekly_usage_left_rate — remaining fraction for the weekly windowfive_hour_usage_reset_time — reset timestamp (string or integer)weekly_usage_reset_time — reset timestamp (string or integer)plan_family — plan family identifier; 2 = credit-based subscription (e.g. Mini, Pro).
For credit plans the rate-window fields above are 0 (no window configured).plan_credit_rate_limit — credit usage object (present for plan_family: 2):
subscription_credit_left_rate — remaining subscription credit fraction (e.g. 0.9641)subscription_credit_reset_time — credit refill/reset timestamptopup_credit_left_rate — remaining top-up credit fractioncredit_buckets — array of { credit_total, credit_residual, expire_at, next_reset_at }Plan status endpoint
POST https://platform.stepfun.com/api/step.openapi.devcenter.Dashboard/GetStepPlanStatussubscription.name → plan name (e.g. "Plus", "Mini")plan_family absent or ≠ 2):
usedPercent is computed as (1.0 - left_rate) × 100.plan_family: 2, e.g. Mini, Pro):
credit_buckets
residual/total values when available.subscription_credit_left_rate (or topup_credit_left_rate when
no subscription rate exists); the independent percentages cannot be safely added.usedPercent = (1.0 - credit_left_rate) × 100.loginMethod label in the menu card (e.g. "Plus").Oasis-Webid header/cookie must match the token's device_id claim. For tokens obtained
via Auto login the device_id is the app's own; for browser-imported (Manual) tokens it is
derived from the refresh-token JWT payload.Sources/CodexBarCore/Providers/StepFun/StepFunProviderDescriptor.swift (descriptor + web fetch strategy)Sources/CodexBarCore/Providers/StepFun/StepFunUsageFetcher.swift (login flow + HTTP client + JSON parser)Sources/CodexBarCore/Providers/StepFun/StepFunSettingsReader.swift (env var resolution)Sources/CodexBar/Providers/StepFun/StepFunProviderImplementation.swift (settings fields + activation logic)Sources/CodexBar/Providers/StepFun/StepFunSettingsStore.swift (SettingsStore extension)Tests/CodexBarTests/StepFunUsageFetcherTests.swift (26 test cases)