Skip to content

Add a Mercure connector - #549

Open
dunglas wants to merge 5 commits into
laravel:2.xfrom
dunglas:feat/mercure-connector
Open

Add a Mercure connector#549
dunglas wants to merge 5 commits into
laravel:2.xfrom
dunglas:feat/mercure-connector

Conversation

@dunglas

@dunglas dunglas commented Sep 7, 2026

Copy link
Copy Markdown

Companion PR for laravel/framework#61474

It adds a connector for the Mercure broadcast driver.

It relies on the native EventSource API: no client library to install, and the hub URL defaults to /.well-known/mercure on the current origin.

Features:

  • One EventSource multiplexes every joined channel; joins and leaves coalesce into a single re-auth and reopen.
  • Auth uses the batch /broadcasting/auth endpoint and an httpOnly cookie, re-minted before the reported expires_in elapses.
  • Presence channels are seeded from the hub's subscription API and updated live from subscription events.
  • End-to-end encrypted channels decrypt compact JWEs with WebCrypto, using the per-channel JWK returned by the auth endpoint. Plaintext updates targeting an encrypted channel are dropped.
  • Whispers publish directly to the hub on per-channel whisper topics and arrive on a second, whisper-only EventSource that dispatches client-* events exclusively, so channel members cannot forge server events. On encrypted channels, whispers are sealed under the channel key before leaving the sender.
  • Config presets for the React, Vue, and Svelte packages (VITE_MERCURE_HUB_URL).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants