Module: AnyCable::Streams
- Defined in:
- lib/anycable/streams.rb
Class Method Summary collapse
Class Method Details
.signed(stream_name) ⇒ Object
10 11 12 13 14 |
# File 'lib/anycable/streams.rb', line 10 def signed(stream_name) ::Base64.urlsafe_encode64(::JSON.dump(stream_name)).then do |encoded| "#{encoded}--#{signature(encoded)}" end end |
.verified(signed_stream_name) ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/anycable/streams.rb', line 16 def verified(signed_stream_name) encoded, sig = signed_stream_name.split("--") raise ArgumentError, "stream name has incorrect format" unless encoded return unless sig == signature(encoded) ::Base64.urlsafe_decode64(encoded).then do |decoded| ::JSON.parse(decoded) end end |