class ChannelEncrypter

Encrypts Mercure updates end to end, so the hub never sees their content.

Properties

protected JWEBuilder|null $jweBuilder

The JWE builder, built on first use and reused across updates.

protected CompactSerializer|null $serializer

The compact JWE serializer.

Methods

__construct(string $key)

Create a new Mercure channel encrypter.

string
encrypt(string $plaintext, string $channel)

Encrypt the given plaintext for the given channel, as a compact JWE.

string
channelKey(string $channel)

Derive the AES-256-GCM key of the given channel.

array
channelJwk(string $channel)

Build the JSON Web Key sharing the given channel's key with an authorized subscriber.

Details

at line 36
__construct(string $key)

Create a new Mercure channel encrypter.

Parameters

string $key

at line 50
string encrypt(string $plaintext, string $channel)

Encrypt the given plaintext for the given channel, as a compact JWE.

Parameters

string $plaintext
string $channel

Return Value

string

at line 68
string channelKey(string $channel)

Derive the AES-256-GCM key of the given channel.

Parameters

string $channel

Return Value

string

at line 78
array channelJwk(string $channel)

Build the JSON Web Key sharing the given channel's key with an authorized subscriber.

Parameters

string $channel

Return Value

array