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 ¶
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.
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 ¶
var ErrMessageTooLarge = errors.New("nm: message exceeds size cap")
ErrMessageTooLarge is returned when a payload exceeds the configured cap.
Functions ¶
func Read ¶
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).
Types ¶
This section is empty.