import { ScramjetClient } from "./client/index"; import { SCRAMJETCLIENT } from "./symbols"; import { DBSchema } from "idb"; /** * Version information for the current Scramjet build. * Contains both the semantic version string and the git commit hash for build identification. */ export interface ScramjetVersionInfo { /** The semantic version */ version: string; /** The git commit hash that this build was created from */ build: string; /** The date of the build */ date: string; } /** * Scramjet Feature Flags, configured at build time */ export type ScramjetFlags = { syncxhr: boolean; strictRewrites: boolean; rewriterLogs: boolean; captureErrors: boolean; cleanErrors: boolean; scramitize: boolean; sourcemaps: boolean; destructureRewrites: boolean; allowInvalidJs: boolean; allowFailedIntercepts: boolean; debugTrampolines: boolean; encapsulateWorkers: boolean; }; export interface ScramjetConfig { globals: { wrapfn: string; wrappropertybase: string; wrappropertyfn: string; cleanrestfn: string; importfn: string; rewritefn: string; metafn: string; wrappostmessagefn: string; pushsourcemapfn: string; trysetfn: string; templocid: string; tempunusedid: string; }; maskedfiles: string[]; flags: ScramjetFlags; siteFlags: Record>; } /** * The config for Scramjet initialization. */ export interface ScramjetInitConfig extends Omit { flags: Partial; codec: { encode: (url: string) => string; decode: (url: string) => string; }; } declare global { interface Window { WASM: string; REAL_WASM: Uint8Array; /** * The scramjet client belonging to a window. */ [SCRAMJETCLIENT]: ScramjetClient; } interface HTMLDocument { /** * Should be the same as window. */ [SCRAMJETCLIENT]: ScramjetClient; } interface HTMLIFrameElement { } } export type SiteDirective = "same-origin" | "same-site" | "cross-site" | "none"; export interface RedirectTracker { originalReferrer: string; mostRestrictiveSite: SiteDirective; referrerPolicy: string; chainStarted: number; } export interface ReferrerPolicyData { policy: string; referrer: string; } export interface ScramjetDB extends DBSchema { config: { key: string; value: ScramjetConfig; }; cookies: { key: string; value: any; }; redirectTrackers: { key: string; value: RedirectTracker; }; referrerPolicies: { key: string; value: ReferrerPolicyData; }; publicSuffixList: { key: string; value: { data: string[]; expiry: number; }; }; }