Module: Turbo::Streams::StreamName
- Included in:
- Turbo::StreamsChannel
- Defined in:
- app/channels/turbo/streams/stream_name.rb
Overview
Stream names are how we identify which updates should go to which users. All streams run over the same Turbo::StreamsChannel
, but each with their own subscription. Since stream names are exposed directly to the user via the HTML stream subscription tags, we need to ensure that the name isn’t tampered with, so the names are signed upon generation and verified upon receipt. All verification happens through the Turbo.signed_stream_verifier
.
Instance Method Summary collapse
-
#signed_stream_name(streamables) ⇒ Object
Used by
Turbo::StreamsHelper#turbo_stream_from(*streamables)
to generate a signed stream name. -
#verified_stream_name(signed_stream_name) ⇒ Object
Used by
Turbo::StreamsChannel
to verify a signed stream name.
Instance Method Details
#signed_stream_name(streamables) ⇒ Object
Used by Turbo::StreamsHelper#turbo_stream_from(*streamables)
to generate a signed stream name.
12 13 14 |
# File 'app/channels/turbo/streams/stream_name.rb', line 12 def signed_stream_name(streamables) Turbo.signed_stream_verifier.generate stream_name_from(streamables) end |
#verified_stream_name(signed_stream_name) ⇒ Object
Used by Turbo::StreamsChannel
to verify a signed stream name.
7 8 9 |
# File 'app/channels/turbo/streams/stream_name.rb', line 7 def verified_stream_name(signed_stream_name) Turbo.signed_stream_verifier.verified signed_stream_name end |