export type PageMetadata = Record; export interface FeatureMeterableProperty { type: 'meterable'; hasAccess: boolean; remainingUnits?: number; } export interface FeatureNumberProperty { type: 'number'; value: number; } export interface Feature { featureSlug: string; properties: Record; sideEffects: unknown[]; } export interface SubSurfaceMetadataApi { cssSelector?: string | null; } export type SetHttpResponse = { headers?: Record; cookies?: string[]; status: number; statusText?: string; body: string | null; }; export type ModifyHttpResponse = { addHeaders?: { name: string; value: string; }[]; removeHeaders?: string[]; addCookies?: string[]; status?: number; statusText?: string; body?: string | null; }; export type SurfaceBehaviorApi = { http?: ModifyHttpResponse | SetHttpResponse; properties?: Record; } & Record; export type WebComponentElement> = { schema: string; props: T; }; export type WebElement = { type: 'html'; content: string; } | { type: 'text'; content: string; } | ({ type: 'element'; } & WebComponentElement) | ({ type: 'custom'; } & Record); export type WebComponentRangeReplacement = { fromMarker?: string; toMarker?: string; replaceWith?: WebElement[] | null; }; export type WebContentSurfaceBehavior = { before?: WebElement[]; prepend?: WebElement[]; remove?: boolean; replaceRange?: WebComponentRangeReplacement | null; append?: WebElement[]; after?: WebElement[]; }; export type SubSurfaceBehaviorApi = { content?: WebContentSurfaceBehavior; properties?: Record; metadata: SubSurfaceMetadataApi; } & Record; export interface SurfaceDecisionResponse { status: 'success'; identity: { identifier: string; isAuthenticated: boolean; authType: string; jwtClaims: Record; }; features: Record; customer: { hasProducts: boolean; }; surfaceBehavior: SurfaceBehaviorApi; componentsSkipped: boolean; componentBehaviors: Record; } export interface SurfaceDecisionError { message: string; status: 'error'; statusCode: number; } export type MosAuthenticatedApiRoute = { matchPath: string; method: 'POST' | 'PUT' | 'PATCH'; mosPath: string; }; export interface MOSConfigInput { /** Origin website base URL, e.g. `https://news.example.com`. */ originUrl: string; /** Surface slug identifying the MonetizationOS surface. */ surfaceSlug: string; /** MonetizationOS API base URL. */ mosHost: string; /** MonetizationOS secret key; expected format `sk__` */ mosSecretKey: string; /** Path prefix routed to the MonetizationOS endpoint proxy. Default: `/mos-endpoints/`. */ mosEndpointsPrefix?: string; /** Cookie name storing the anonymous session id. */ anonymousSessionCookieName: string; /** Cookie name storing the authenticated user JWT. */ authenticatedUserJwtCookieName: string; /** Optional script URL injected into the `` of HTML responses. */ injectScriptUrl?: string; /** Comma-separated regex patterns; matching pathnames skip surface decisions. */ surfaceDecisionsIgnorePaths?: string; /** Comma-separated regex patterns; matching request and origin Set-Cookie values are forwarded in the surface-decisions http payload. */ surfaceDecisionsCookies?: string; /** Optional headers added to or replacing client headers on every origin request. */ originRequestHeaders?: Record; /** * When true (default), JWT surface-decision requests include `createAnonymousIdentifierFallback: true` * so MonetizationOS can mint an anonymous identifier if JWT authentication fails. * Set to `false` to opt out. */ createAnonymousIdentifierFallback?: boolean; }