Add hook for YJS Transaction filter
The problem I am facing
When syncing YDoc using other means than just Hocuspocus (eg WebRTC), it's possible for an authenticated client to receive changes from unauthorised clients and inadvertantly forward those changes to hocuspocus. Hocuspocus will then blindly apply those changes because the connection is authorised.
The solution I would like
YJS has built in support for Transaction origins. TipTap could be configured to sign each change and attatch the signature to the transaction. When the hocuspocus server receives a set of transations via an authorised client, it would be good if there was a way to authorise each transaction, not just the connection.
TipTap/Hocuspocus does not need to implement the signature/verification algorithms, just provide the hooks that allow the transaction origin to be set and for transactions to be filtered before being applied.
Alternatives I have considered
Use the local transaction flag and not forward any non-local transactions to hocuspocus from the client. But with this we loose some of the benefit of using p2p, where an authorised transaction should be able to make it to the server via other nodes in the network.
It should also be possible to filter transactions on the client, but this should be in addition to the server filtering, since we don't want a maliciously modified client to be able to bypass client-side-only restrictions.
Additional context
Using WebRTC allows for systems that can continue to function when there are network issues or issues with a central hub. It can also help solve latency issues for clusters of clients who are co-located but further from the closest hocuspocus hub.