Skip to content

platform/electron/ipc-gate

Defined in: app/src/platform/electron/ipc-gate.ts:44

Decides whether an IPC request is accepted, in this order: the sender is a registered view, the message comes from its top frame with the expected origin, the view has the contract’s capability, the payload matches the schema, and the sender is within the channel’s rate limit. Web content never passes the first check.

new IpcGate(clock): IpcGate

Defined in: app/src/platform/electron/ipc-gate.ts:50

Clock

Time source for rate limiting.

IpcGate

check<Req>(contract, sender, payload): Result<Req, IpcRejection>

Defined in: app/src/platform/electron/ipc-gate.ts:90

Checks a request.

Req

RequestContract<Req, unknown>

The channel’s contract.

IpcSender

Where the request came from.

unknown

The untrusted payload.

Result<Req, IpcRejection>

The validated request, or the reason for refusing it.

mayReceive(viewId, capability): boolean

Defined in: app/src/platform/electron/ipc-gate.ts:79

Tells whether a view may receive events of a capability.

number

Id of a WebContents.

Capability

The capability of an event contract.

boolean

registerView(viewId, view): Disposable

Defined in: app/src/platform/electron/ipc-gate.ts:60

Registers a view of the browser’s own UI.

number

Id of its WebContents.

RegisteredView

Expected origin and capabilities.

Disposable

A disposable that unregisters the view.

Defined in: app/src/platform/electron/ipc-gate.ts:15

Where an IPC message came from.

readonly frameUrl: string

Defined in: app/src/platform/electron/ipc-gate.ts:19

URL of the sending frame.

readonly isMainFrame: boolean

Defined in: app/src/platform/electron/ipc-gate.ts:21

Whether the sending frame is the top frame of its view.

readonly viewId: number

Defined in: app/src/platform/electron/ipc-gate.ts:17

Id of the sending WebContents.


Defined in: app/src/platform/electron/ipc-gate.ts:8

A view of the browser that may talk to the browser process.

readonly capabilities: ReadonlySet<Capability>

Defined in: app/src/platform/electron/ipc-gate.ts:11

readonly origin: string

Defined in: app/src/platform/electron/ipc-gate.ts:10

Origin its top frame must have, such as app://shell.

IpcRejection = "unknown-sender" | "not-main-frame" | "wrong-origin" | "missing-capability" | "invalid-payload" | "rate-limited"

Defined in: app/src/platform/electron/ipc-gate.ts:25

Why a message was refused.

originOf(url): string

Defined in: app/src/platform/electron/ipc-gate.ts:140

The origin of a URL for the browser’s own schemes, such as app://shell.

string

A frame URL.

string