lib/pusher/channel.rb
def authentication_string(socket_id, custom_string = nil)
      validate_socket_id(socket_id)

      unless custom_string.nil? || custom_string.kind_of?(String)
        raise Error, 'Custom argument must be a string'
      end

      string_to_sign = [socket_id, name, custom_string].
        compact.map(&:to_s).join(':')
      Pusher.logger.debug "Signing #{string_to_sign}"
      token = @client.authentication_token
      digest = OpenSSL::Digest::SHA256.new
      signature = OpenSSL::HMAC.hexdigest(digest, token.secret, string_to_sign)

      return "#{token.key}:#{signature}"
    end
# Compute authentication string required as part of the authentication
# endpoint response. Generally the authenticate method should be used in
# preference to this one
#
# @param socket_id [String] Each Pusher socket connection receives a
#   unique socket_id. This is sent from pusher.js to your server when
#   channel authentication is required.
# @param custom_string [String] Allows signing additional data
# @return [String]
#
# @raise [Pusher::Error] if socket_id or custom_string invalid
#
Compute authentication string required as part of the authentication
endpoint response. Generally the authenticate method should be used in
preference to this one
Compute authentication string required as part of the authentication endpoint response . Generally the authenticate method should be used in preference to this one
def authentication_string(socket_id, custom_string = nil)
      validate_socket_id(socket_id)
      unless custom_string.nil? || custom_string.kind_of?(String)
        raise Error, 'Custom argument must be a string'
      end
      string_to_sign = [socket_id, name, custom_string].
        compact.map(&:to_s).join(':')
      Pusher.logger.debug "Signing #{string_to_sign}"
      token = @client.authentication_token
      digest = OpenSSL::Digest::SHA256.new
      signature = OpenSSL::HMAC.hexdigest(digest, token.secret, string_to_sign)
      return "#{token.key}:#{signature}"
    end
def authentication_string ( socket_id , custom_string = nil ) validate_socket_id ( socket_id ) unless custom_string . nil? || custom_string . kind_of? ( String ) raise Error , 'Custom argument must be a string' end string_to_sign = [ socket_id , name , custom_string ] . compact . map ( & :to_s ) . join ( ':' ) Pusher . logger . debug "Signing #{string_to_sign}" token = @client . authentication_token digest = OpenSSL :: Digest :: SHA256 . new signature = OpenSSL :: HMAC . hexdigest ( digest , token . secret , string_to_sign ) return "#{token.key}:#{signature}" end
Compute authentication string required as part of the authentication
endpoint response.
Compute authentication string required as part of the authentication endpoint response .
None
String
[Pusher::Error] if socket_id or custom_string invalid
[ Pusher :: Error ] if socket_id or custom_string invalid
socket_id
Each Pusher socket connection receives a unique socket_id. This is sent from pusher.js to your server when channel authentication is required.
Each Pusher socket connection receives a unique socket_id . This is sent from pusher . js to your server when channel authentication is required .
custom_string
Allows signing additional data
Allows signing additional data