Skip to main content
The ScramjetClient class is the core client that runs inside proxified contexts. It handles DOM API interception, URL rewriting, and provides the sandboxing infrastructure.
Most users won’t need to interact with ScramjetClient directly. It’s automatically created and managed by ScramjetController and ScramjetFrame.

Constructor

Creates a new ScramjetClient instance.
typeof globalThis
required
The global object to apply Scramjet sandboxing to (typically window or self)
Only one ScramjetClient instance can exist per global context. Attempting to create multiple instances will throw an error.

Properties

global

The global object this client is sandboxing.

url

Gets or sets the current proxified URL.

Example

locationProxy

The proxified location object.

bare

The BareClient instance for making bare requests.

cookieStore

The cookie store for cookie emulation.

natives

Store for accessing native (unproxied) browser APIs.

Example

descriptors

Store for accessing native property descriptors.

frame

Returns the ScramjetFrame instance if this client is inside a frame, or null if top-level.

isSubframe

Returns true if this client is running in a subframe (not created by ScramjetFrame).

Methods

hook()

Applies all Scramjet hooks to the global context. This method is called automatically during initialization.
This method loads and applies all DOM and worker hooks based on the current context.

loadcookies()

Loads cookies from a cookie string.
string
required
The cookie string to load

Proxy()

Proxies a function or constructor to intercept calls.
string | string[]
required
The name(s) of the API to proxy (e.g., "fetch" or "XMLHttpRequest.prototype.open")
Proxy
required
Handler object with apply and/or construct methods

Example

Trap()

Traps a property to intercept get/set operations.
string | string[]
required
The name(s) of the property to trap (e.g., "window.location.href")
Trap<T>
required
Descriptor object with get and/or set methods

Example

RawProxy()

Lower-level proxy method that operates directly on objects.
any
required
The target object
string
required
The property name
Proxy
required
Handler object

RawTrap()

Lower-level trap method that operates directly on objects.
any
required
The target object
string
required
The property name
Trap<T>
required
Descriptor object

Type definitions

Proxy

Handler for proxying functions and constructors.

Trap

Handler for trapping properties.
See module types for complete type definitions.