Sha256: 6f7cbdb83dd863e7e0b711cca5d07416e139822852870471a15741d2def91858

Contents?: true

Size: 701 Bytes

Versions: 2

Compression:

Stored size: 701 Bytes

Contents

require 'openssl'

module PusherSignatureHelper
  def sign_pusher_request(payload)
    secret = PUSHER_CONFIG["secret"]
    digest = OpenSSL::Digest::SHA256.new
    body = payload.to_query
    signature = OpenSSL::HMAC.hexdigest(digest, secret, body)
    request.env['HTTP_X_PUSHER_SIGNATURE'] = signature

    request.env['HTTP_X_PUSHER_KEY'] = PUSHER_CONFIG["app_key"]
  end

  def get_pusher_params(payload)
    secret = PUSHER_CONFIG["secret"]
    digest = OpenSSL::Digest::SHA256.new
    body = payload.to_query
    signature = OpenSSL::HMAC.hexdigest(digest, secret, body)
    {
      'HTTP_X_PUSHER_SIGNATURE' => signature,
      'HTTP_X_PUSHER_KEY' => PUSHER_CONFIG["app_key"]
    }
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
telephony-1.0.4 spec/support/pusher_helper.rb
telephony-1.0.3 spec/support/pusher_helper.rb