import { BillingClient } from '@monetize.software/sdk'; import { AuthClient } from '@monetize.software/sdk'; import { EventTracker } from '@monetize.software/sdk'; import { OffscreenServerOptions } from './index'; import { TransportServer } from '../shared/transport-server'; export declare class OffscreenServer { readonly billing: BillingClient; readonly auth: AuthClient | undefined; readonly tracker: EventTracker | undefined; private readonly transport; private readonly stagedFiles; private connectListener; private userUnsub; private balanceUnsub; private authUnsub; /** States handed out by auth.oauthStart, oldest first. The adopt path (service * worker) learns only the code — the state rides in `window.name`, which a * worker cannot read — so we resolve the flow from here. */ private pendingOAuthStates; /** Exchanges keyed by state, in-flight and briefly after settling. Both entry * points funnel through it so one auth code is never sent to GoTrue twice. */ private oauthExchanges; constructor(opts: OffscreenServerOptions); private registerTrackerHandlers; /** Drop staged support attachments older than the TTL. Called on every * stage request — no timer needed, the map is only ever populated by the * same request path. */ private sweepStagedFiles; private registerBillingHandlers; /** Each trial handler creates a fresh store — it's stateless and reads state * from storage. There's no point caching instances (storage = SoT). */ private makeTrialStore; private registerAuthHandlers; private rememberOAuthState; /** * Creates the checkout a finished sign-in was gating. Returns the URL, or * undefined when there is nothing to open — including the 409 for a user who * already owns the subscription, where sending them to pay again would be * worse than sending them nowhere (they reopen the extension and the settled * -user gate shows the restored state). * * Mirrors what PaywallUI does around a checkout, because the surface that * normally would is gone: the pending marker keeps the next open from flashing * the paywall at a user who is mid-payment, and the analytics event keeps the * funnel honest. */ private createResumeCheckout; /** The most recently started flow, which is the one a returning code belongs * to. Concurrent OAuth flows in one extension are not a real scenario — each * needs its own provider window — so newest-wins is enough, and a wrong guess * costs only a failed exchange, never a wrong session (the code is bound to * the challenge sent with that state). */ private newestPendingOAuthFlow; private forgetOAuthState; private exchangeOAuthOnce; private bridgeBroadcasts; /** Accept a raw MessageChannel, bypassing chrome.runtime. Unit tests wire an * in-memory channel here to exercise the real handler graph; prod traffic * always arrives through start() → onConnect. */ acceptChannel(channel: Parameters[0]): void; /** Start the listener on chrome.runtime.onConnect. */ start(): void; stop(): void; } //# sourceMappingURL=server.d.ts.map