isUpgradeRequest previously flagged any request carrying a bare
`Connection: upgrade` header -- or a bare `Upgrade: websocket` header --
as a protocol upgrade, bypassing plugin HTML injection and
request/response hooks. Some reverse-proxy templates (e.g. sites created
by 1Panel) set `proxy_set_header Connection upgrade;` unconditionally, so
every proxied page request skipped the plugin middleware silently while
plugins still reported as loaded.
Per RFC 9110 section 7.8 a valid upgrade request carries both headers:
Connection lists the upgrade token and Upgrade names the target protocol.
Require the Upgrade header to be present and the Connection list to
contain the upgrade token, and accept any upgrade protocol rather than
only websocket.
RPC results were passed directly to goja's resolve, which could fail for
non-JSON-compatible Go types. Add normalizeRPCValue to round-trip the
result through JSON, ensuring it becomes plain data structures. Handle
serialization errors properly by rejecting the promise.
Implement wsConnect, wsMessage, wsSend, and wsClose hook kinds so plugins
can intercept WebSocket connections and frames. Refactor the hook matcher
to match paths independently of HTTP requests and add runHookTurnTimeout
so WebSocket hook turns that exceed the runtime timeout can fall back to
passing the message through without blocking the caller.
Add StorageDir (data/plugin-data/<short>) exposed to plugin runtimes as
__storageDir__, giving plugins a location for long-term data that
survives plugin updates. The existing DataDir/<short> remains the
install/code directory and is replaced on update, while storage is
preserved and only removed when the plugin is deleted.
Update filesystem path handling to support plugin storage roots, reset
StorageDir in tests, and drop the unused golang.org/x/image dependency.
Update plugin permissions to separate admin-approved capabilities from
runtime settings. Add AllowSystemRPC, AllowRoutes, and AllowHooks to
control server.call, server.route, and server.hook respectively.
Registering RPC methods, reading own config, and accessing plugin-local
files remain always allowed, so plugins without dangerous permissions
can be enabled without approval.
Add tests covering server module enforcement and default-granted
capabilities.