class ChannelEncrypter (View source)

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{kty: string, k: string, alg: string, use: string}
channelJwk(string $channel)

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

Details

__construct(string $key)

Create a new Mercure channel encrypter.

Parameters

string $key

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

string channelKey(string $channel)

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

Parameters

string $channel

Return Value

string

array{kty: string, k: string, alg: string, use: string} channelJwk(string $channel)

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

Parameters

string $channel

Return Value

array{kty: string, k: string, alg: string, use: string}