Sha256: 62edd99886a5188e62229285b0f4612a445391c9adb73e236e689542a788d87f

Contents?: true

Size: 798 Bytes

Versions: 7

Compression:

Stored size: 798 Bytes

Contents

# @deprecated
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

7 entries across 7 versions & 1 rubygems

Version Path
hubspot-api-client-17.0.0.pre.beta.3 lib/hubspot/helpers/webhooks_helper.rb
hubspot-api-client-17.0.0.pre.beta.2 lib/hubspot/helpers/webhooks_helper.rb
hubspot-api-client-17.0.0.pre.beta.1 lib/hubspot/helpers/webhooks_helper.rb
hubspot-api-client-16.4.0 lib/hubspot/helpers/webhooks_helper.rb
hubspot-api-client-16.3.0 lib/hubspot/helpers/webhooks_helper.rb
hubspot-api-client-16.2.1 lib/hubspot/helpers/webhooks_helper.rb
hubspot-api-client-16.2.0 lib/hubspot/helpers/webhooks_helper.rb