/** * Claude's OAuth token refresh, owned by the shared-core Claude adapter * (design 5.3, Claude track; moved here from the deleted legacy token module * by C4): the refresh request with its ten-second deadline and bounded * bodies, the credential a refresh produces, and the two refusals the * adapter, the bearer resolver and the worker classify. Pure helpers: no * database access and no legacy table. */ import { ClaudeSubscriptionCredential } from "@opengeni/config"; import type { z } from "zod"; /** The sign-in was refused or revoked: only a new sign-in recovers it. */ export declare class ClaudeSubscriptionReconnectRequired extends Error { readonly status = 401; constructor(); } /** The refresh failed for a reason a later attempt may not repeat. */ export declare class ClaudeSubscriptionRefreshUnavailable extends Error { readonly status = 503; constructor(); } type ClaudeCredential = z.infer; /** * One OAuth refresh. A 401 or `invalid_grant`, or a response missing a * required scope, is a relogin; anything else is a retryable failure. A * credential without `oauth` (a setup token) never refreshes. */ export declare function requestClaudeTokenRefresh(bundle: ClaudeCredential, fetchImpl?: typeof fetch): Promise<{ [x: string]: unknown; access_token: string; refresh_token?: string | undefined; expires_in: number; scope: string; }>; /** * The credential an OAuth refresh produced: the new access token, the rotated * refresh token (or the current one when Claude kept it), the new expiry and * the granted scopes. The identity is kept. Every Claude refresh path builds * it here. */ export declare function claudeRefreshedCredential(credential: ClaudeCredential, tokens: Awaited>, nowMs: number): { credential: { version: 1; token: string; identity: { accountUuid: string; deviceId: string; }; oauth?: { refreshToken: string; expiresAt: string; scopes: string[]; } | undefined; }; expiresAt: Date; }; /** * The plan a Claude sign-in reports at renewal, from the profile endpoint: * Claude's token refresh reports none, so a plan change (or the Max tier, * Max or Ultra) shows after the next renewal instead of only on a new * sign-in. Optional: without the `user:profile` scope, or on any failure, it * is null and the recorded plan stays. A Max plan whose tier the profile * doesn't name is null too, so an unresolved read never replaces a known * tier (a plan change also clears the connection's model cooldowns). Never * throws; its deadline bounds how long the renewal waits for it. */ export declare function requestClaudeProfilePlan(token: string, scopes: readonly string[], fetchImpl?: typeof fetch): Promise; export {};