nm

package
v0.0.0-...-cc4816d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 27, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package nm implements the Chrome Native Messaging stdio framing protocol: each message is a 4-byte little-endian unsigned length prefix followed by UTF-8-encoded JSON. Chrome's documented bounds:

host -> Chrome: ≤ 1 MB per message
Chrome -> host: ≤ 4 GB per message  (we cap incoming at 16 MB by default)

fenster's host process is launched by Chrome itself (Native Messaging hosts are spawned by the browser, not by the user), so stdin/stdout are the bridge. Both directions are full-duplex; readers and writers should run on separate goroutines.

Index

Constants

View Source
const DefaultMaxMessageSize = 16 * 1024 * 1024

DefaultMaxMessageSize is the cap fenster enforces on incoming messages. Chrome's hard ceiling is 4 GB but we don't expect to need that much.

View Source
const DefaultMaxOutgoing = 1 * 1024 * 1024

DefaultMaxOutgoing is Chrome's enforced ceiling for host -> Chrome messages. Writing more than this is rejected by Chrome anyway; we fail fast locally.

Variables

View Source
var ErrMessageTooLarge = errors.New("nm: message exceeds size cap")

ErrMessageTooLarge is returned when a payload exceeds the configured cap.

Functions

func Read

func Read(r io.Reader, maxSize int) ([]byte, error)

Read reads a single Native Messaging frame from r. It returns io.EOF on a clean end-of-stream and io.ErrUnexpectedEOF on a truncated frame.

maxSize must be > 0; payloads larger than maxSize fail with ErrMessageTooLarge (and the rest of the stream is undefined — caller should disconnect).

func Write

func Write(w io.Writer, payload []byte) error

Write writes payload as a single Native Messaging frame to w.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL