Sha256: 4f77b1d3274eda758d1298f588232dbd183c5a1b3f47f2dfb604ac92736c81d9

Contents?: true

Size: 784 Bytes

Versions: 48

Compression:

Stored size: 784 Bytes

Contents

module Hubspot
  module Helpers
    class WebhooksHelper
      def self.validate_signature(
        signature:,
        client_secret:,
        http_uri:,
        request_body:,
        http_method: 'POST',
        signature_version: 'v2'
      )

        if signature_version == 'v1'
          source_string = client_secret + request_body.to_s
        else
          source_string = client_secret + http_method + http_uri + request_body.to_s
        end

        hash_result = Digest::SHA2.hexdigest(source_string.encode('utf-8'))

        if hash_result != signature
          raise InvalidSignatureError.new(
            signature: signature,
            signature_version: signature_version,
            hash_result: hash_result
          )
        end
      end
    end
  end
end

Version data entries

48 entries across 48 versions & 1 rubygems

Version Path
hubspot-api-client-16.1.1 lib/hubspot/helpers/webhooks_helper.rb
hubspot-api-client-16.1.0 lib/hubspot/helpers/webhooks_helper.rb
hubspot-api-client-16.0.4 lib/hubspot/helpers/webhooks_helper.rb
hubspot-api-client-16.0.3 lib/hubspot/helpers/webhooks_helper.rb
hubspot-api-client-16.0.2 lib/hubspot/helpers/webhooks_helper.rb
hubspot-api-client-16.0.1 lib/hubspot/helpers/webhooks_helper.rb
hubspot-api-client-16.0.0 lib/hubspot/helpers/webhooks_helper.rb
hubspot-api-client-15.0.2 lib/hubspot/helpers/webhooks_helper.rb
hubspot-api-client-15.0.1 lib/hubspot/helpers/webhooks_helper.rb
hubspot-api-client-15.0.0 lib/hubspot/helpers/webhooks_helper.rb
hubspot-api-client-14.5.2 lib/hubspot/helpers/webhooks_helper.rb
hubspot-api-client-14.5.1 lib/hubspot/helpers/webhooks_helper.rb
hubspot-api-client-14.5.0 lib/hubspot/helpers/webhooks_helper.rb
hubspot-api-client-14.4.0 lib/hubspot/helpers/webhooks_helper.rb
hubspot-api-client-14.3.0 lib/hubspot/helpers/webhooks_helper.rb
hubspot-api-client-14.2.0 lib/hubspot/helpers/webhooks_helper.rb
hubspot-api-client-14.1.0 lib/hubspot/helpers/webhooks_helper.rb
hubspot-api-client-14.0.0 lib/hubspot/helpers/webhooks_helper.rb
hubspot-api-client-13.2.0 lib/hubspot/helpers/webhooks_helper.rb
hubspot-api-client-13.1.0 lib/hubspot/helpers/webhooks_helper.rb