import "./environment.js"; import { ApiKeyEd25519AuthProvider, JwtAuthProvider } from "./shared/transports.js"; import { SubaccountResolver } from "./services/subaccount-resolver.js"; import { Me } from "./services/auth/auth.js"; import { PolyesterClientBaseConfig, PolyesterCore } from "./core-client.js"; import { CookieGetter } from "./utils/cookies.js"; import { AuthCookieLocation, POLYESTER_AUTH_TOKEN_COOKIE_NAME, POLYESTER_SESSION_COOKIE_NAME } from "./services/auth/cookie-constants.js"; import { ServerSessionSnapshot } from "./services/auth/session.types.js"; import "./services/auth/session.js"; //#region src/server-core.d.ts /** Configuration for the server Polyester client. */ type PolyesterServerClientConfig = PolyesterClientBaseConfig & { /** Auth provider config for HTTP/Connect endpoints. */ auth?: JwtAuthProvider | ApiKeyEd25519AuthProvider; /** Bearer authentication and display-only session data parsed from cookies. */ session?: ServerSessionSnapshot; /** * Use unsigned display-session `activeAccount` as the default subaccount for * calls that omit `subaccountId`. This preserves account-switcher intent for * apps that explicitly opt in; backend authorization must still decide what * the authenticated user can access. */ useDisplaySessionActiveAccountAsDefault?: boolean; }; /** * Tree-shakable server client core that can parse display-session cookies and verify * bearer-token sessions with the backend. Reach other services through * `@polyester/sdk/services/*` accessors, or use `PolyesterServerClient` for a getter per service. */ declare class PolyesterServerCore extends PolyesterCore { #private; constructor(config: PolyesterServerClientConfig); /** * Creates a resolver for server-side subaccount defaults. Display-session * `activeAccount` is only used as caller intent when explicitly enabled; * backend auth remains authoritative. */ protected createSubaccountResolver(): SubaccountResolver; get hasAuthProvider(): boolean; get hasBearerToken(): boolean; get hasUsableBearerToken(): boolean; get hasDisplaySession(): boolean; get session(): ServerSessionSnapshot; /** * Verifies the current server session. Returns null only when credentials * are absent or rejected as unauthenticated. Transport, configuration, and * other backend failures are rethrown so callers do not treat outages as logout. */ verifySession(): Promise; } type ServerClientFactoryBaseConfig = TConfig extends PolyesterClientBaseConfig ? Pick : never; /** Parameters for creating a server client from cookies. */ type CreateServerClientFromCookiesParams = ServerClientFactoryBaseConfig & { /** * A Request, name-value record, or synchronous cookie store whose `get` * method returns either a string or an object with a string `value`. * Await asynchronous framework cookie helpers before passing their result. */ cookies: CookieGetter; /** * The page or request location that supplied `cookies`. Required for * local framework cookie stores so their port-scoped auth cookies can * be parsed; a `Request` source derives this from `request.url`. */ cookieLocation?: AuthCookieLocation; /** Base name configured for the browser bearer-token cookie. */ tokenCookieName?: string; /** * Use unsigned display-session `activeAccount` as the default subaccount for * calls that omit `subaccountId`. This is caller intent from UI hydration, * not proof of authority; backend authorization remains authoritative. */ useDisplaySessionActiveAccountAsDefault?: boolean; }; /** Parameters for creating a server client from a request. */ type CreateServerClientFromRequestParams = ServerClientFactoryBaseConfig & { request: Request; /** Base name configured for the browser bearer-token cookie. */ tokenCookieName?: string; /** * Use unsigned display-session `activeAccount` as the default subaccount for * calls that omit `subaccountId`. This is caller intent from UI hydration, * not proof of authority; backend authorization remains authoritative. */ useDisplaySessionActiveAccountAsDefault?: boolean; }; /** * Creates a server client core from a Request, cookie record, or synchronous cookie store. */ declare function createPolyesterServerCoreFromCookies(params: CreateServerClientFromCookiesParams): PolyesterServerCore; /** * Creates a server client core from a Request object. */ declare function createPolyesterServerCoreFromRequest(params: CreateServerClientFromRequestParams): PolyesterServerCore; //#endregion export { CreateServerClientFromCookiesParams, CreateServerClientFromRequestParams, PolyesterServerClientConfig, PolyesterServerCore, type ServerSessionSnapshot, createPolyesterServerCoreFromCookies, createPolyesterServerCoreFromRequest }; //# sourceMappingURL=server-core.d.ts.map