hubspot-api-client 17.0.0.pre.beta.3 → 17.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +18 -1
- data/Gemfile.lock +1 -1
- data/lib/hubspot/client.rb +1 -1
- data/lib/hubspot/discovery/oauth/client.rb +0 -4
- data/lib/hubspot/exceptions.rb +9 -7
- data/lib/hubspot/helpers/association_type.rb +92 -0
- data/lib/hubspot/helpers/camel_case.rb +5 -1
- data/lib/hubspot/helpers/path.rb +1 -2
- data/lib/hubspot/helpers/signature.rb +2 -2
- data/lib/hubspot/helpers/snake_case.rb +2 -1
- data/lib/hubspot/oauth_helper.rb +12 -8
- data/lib/hubspot/version.rb +1 -1
- data/spec/discovery/client_spec.rb +1 -1
- data/spec/discovery/oauth/access_tokens_api_spec.rb +1 -1
- data/spec/discovery/oauth/refresh_tokens_api_spec.rb +1 -1
- data/spec/discovery/oauth/tokens_api_spec.rb +1 -1
- data/spec/helpers/authorize_url_spec.rb +75 -0
- data/spec/helpers/signature_spec.rb +4 -3
- metadata +7 -5
- data/lib/hubspot/helpers/webhooks_helper.rb +0 -32
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: abbad95ec7ed2eab3eec2d180f721b54f7de216328c1df44670c32b3e14a882e
|
4
|
+
data.tar.gz: 0ac955e55206a6cd81881825c3f2669eb8cc5a792af273cb24cfaf1342230d6f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3961b180b6ca01a771749514c85d48cbca3b7ba18344038c39d2aed54c53389e6a3c1490a5f77913d67cbf9897ec9f101ac8ece545e528d0c2e54c73749c6da0
|
7
|
+
data.tar.gz: 579b92cbc0cb4c1db21a313866953d586a7e1c61ec200400265007625fcd5f817b6b4653c99e6d7ee6e5768a6685a036905391b83bde016b6c49daac4a985d41
|
data/CHANGELOG.md
CHANGED
@@ -5,9 +5,26 @@ All notable changes to this project will be documented in this file.
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
7
|
|
8
|
-
## [Unreleased](https://github.com/HubSpot/hubspot-api-ruby/compare/v17.0.0
|
8
|
+
## [Unreleased](https://github.com/HubSpot/hubspot-api-ruby/compare/v17.0.0...HEAD)
|
9
9
|
|
10
10
|
|
11
|
+
## [17.0.0.pre.beta.4] - 2023-06-14
|
12
|
+
|
13
|
+
## Updated
|
14
|
+
|
15
|
+
- Fix `Hubspot::OAuthHelper.authorize_url()` (don't add empty scopes or optional scopes to OAuth url)
|
16
|
+
|
17
|
+
## [17.0.0.pre.beta.4] - 2023-05-17
|
18
|
+
|
19
|
+
## Added
|
20
|
+
|
21
|
+
- added custom exceptions for Signature
|
22
|
+
- add associations types
|
23
|
+
|
24
|
+
## Updated
|
25
|
+
|
26
|
+
- remove deprecated `validate_signature`
|
27
|
+
|
11
28
|
## [17.0.0-beta.3] - 2023-05-12
|
12
29
|
|
13
30
|
## Added
|
data/Gemfile.lock
CHANGED
data/lib/hubspot/client.rb
CHANGED
data/lib/hubspot/exceptions.rb
CHANGED
@@ -1,14 +1,16 @@
|
|
1
1
|
module Hubspot
|
2
2
|
class ConfigurationError < StandardError; end
|
3
|
-
|
4
|
-
|
5
|
-
def initialize(msg: nil, signature: nil, signature_version: nil, hash_result: nil)
|
6
|
-
@signature = signature
|
3
|
+
class InvalidSignatureVersionError < StandardError
|
4
|
+
def initialize(signature_version)
|
7
5
|
@signature_version = signature_version
|
8
|
-
|
9
|
-
|
6
|
+
super("Invalid signature version passed to request: #{@signature_version}")
|
7
|
+
end
|
8
|
+
end
|
10
9
|
|
11
|
-
|
10
|
+
class InvalidSignatureTimestampError < StandardError
|
11
|
+
def initialize(timestamp)
|
12
|
+
@timestamp = timestamp
|
13
|
+
super("Signature timestamp is invalid: #{@timestamp}.")
|
12
14
|
end
|
13
15
|
end
|
14
16
|
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
module Hubspot
|
2
|
+
module Helpers
|
3
|
+
class AssociationType
|
4
|
+
PRIMARY_CONTACT_TO_COMPANY = 1
|
5
|
+
PRIMARY_COMPANY_TO_CONTACT = 2
|
6
|
+
DEAL_TO_CONTACT = 3
|
7
|
+
CONTACT_TO_DEAL = 4
|
8
|
+
PRIMARY_DEAL_TO_COMPANY = 5
|
9
|
+
PRIMARY_COMPANY_TO_DEAL = 6
|
10
|
+
CONTACT_TO_TICKET = 15
|
11
|
+
TICKET_TO_CONTACT = 16
|
12
|
+
DEAL_TO_LINE_ITEM = 19
|
13
|
+
LINE_ITEM_TO_DEAL = 20
|
14
|
+
PRIMARY_COMPANY_TO_TICKET = 25
|
15
|
+
PRIMARY_TICKET_TO_COMPANY = 26
|
16
|
+
DEAL_TO_TICKET = 27
|
17
|
+
TICKET_TO_DEAL = 28
|
18
|
+
DEAL_TO_QUOTE = 63
|
19
|
+
QUOTE_TO_DEAL = 64
|
20
|
+
QUOTE_TO_LINE_ITEM = 67
|
21
|
+
LINE_ITEM_TO_QUOTE = 68
|
22
|
+
QUOTE_TO_CONTACT = 69
|
23
|
+
CONTACT_TO_QUOTE = 70
|
24
|
+
QUOTE_TO_COMPANY = 71
|
25
|
+
COMPANY_TO_QUOTE = 72
|
26
|
+
CONTACT_TO_FEEDBACK_SUBMISSION = 97
|
27
|
+
FEEDBACK_SUBMISSION_TO_CONTACT = 98
|
28
|
+
TICKET_TO_FEEDBACK_SUBMISSION = 99
|
29
|
+
FEEDBACK_SUBMISSION_TO_TICKET = 100
|
30
|
+
COMPANY_TO_CALL = 181
|
31
|
+
CALL_TO_COMPANY = 182
|
32
|
+
COMPANY_TO_EMAIL = 185
|
33
|
+
EMAIL_TO_COMPANY = 186
|
34
|
+
COMPANY_TO_MEETING = 187
|
35
|
+
MEETING_TO_COMPANY = 188
|
36
|
+
COMPANY_TO_NOTE = 189
|
37
|
+
NOTE_TO_COMPANY = 190
|
38
|
+
COMPANY_TO_TASK = 191
|
39
|
+
TASK_TO_COMPANY = 192
|
40
|
+
CONTACT_TO_CALL = 193
|
41
|
+
CALL_TO_CONTACT = 194
|
42
|
+
CONTACT_TO_EMAIL = 197
|
43
|
+
EMAIL_TO_CONTACT = 198
|
44
|
+
CONTACT_TO_MEETING = 199
|
45
|
+
MEETING_TO_CONTACT = 200
|
46
|
+
CONTACT_TO_NOTE = 201
|
47
|
+
NOTE_TO_CONTACT = 202
|
48
|
+
CONTACT_TO_TASK = 203
|
49
|
+
TASK_TO_CONTACT = 204
|
50
|
+
DEAL_TO_CALL = 205
|
51
|
+
CALL_TO_DEAL = 206
|
52
|
+
DEAL_TO_EMAIL = 209
|
53
|
+
EMAIL_TO_DEAL = 210
|
54
|
+
DEAL_TO_MEETING = 211
|
55
|
+
MEETING_TO_DEAL = 212
|
56
|
+
DEAL_TO_NOTE = 213
|
57
|
+
NOTE_TO_DEAL = 214
|
58
|
+
DEAL_TO_TASK = 215
|
59
|
+
TASK_TO_DEAL = 216
|
60
|
+
QUOTE_TO_TASK = 217
|
61
|
+
TASK_TO_QUOTE = 218
|
62
|
+
TICKET_TO_CALL = 219
|
63
|
+
CALL_TO_TICKET = 220
|
64
|
+
TICKET_TO_EMAIL = 223
|
65
|
+
EMAIL_TO_TICKET = 224
|
66
|
+
TICKET_TO_MEETING = 225
|
67
|
+
MEETING_TO_TICKET = 226
|
68
|
+
TICKET_TO_NOTE = 227
|
69
|
+
NOTE_TO_TICKET = 228
|
70
|
+
TICKET_TO_TASK = 229
|
71
|
+
TASK_TO_TICKET = 230
|
72
|
+
CONTACT_TO_COMPANY = 279
|
73
|
+
COMPANY_TO_CONTACT = 280
|
74
|
+
TICKET_TO_COMPANY = 339
|
75
|
+
COMPANY_TO_TICKET = 340
|
76
|
+
DEAL_TO_COMPANY = 341
|
77
|
+
COMPANY_TO_DEAL = 342
|
78
|
+
CALL_TO_MEETING = 399
|
79
|
+
MEETING_TO_CALL = 400
|
80
|
+
POSTAL_MAIL_TO_CONTACT = 453
|
81
|
+
CONTACT_TO_POSTAL_MAIL = 454
|
82
|
+
POSTAL_MAIL_TO_TICKET = 455
|
83
|
+
TICKET_TO_POSTAL_MAIL = 456
|
84
|
+
POSTAL_MAIL_TO_DEAL = 457
|
85
|
+
DEAL_TO_POSTAL_MAIL = 458
|
86
|
+
POSTAL_MAIL_TO_COMPANY = 459
|
87
|
+
COMPANY_TO_POSTAL_MAIL = 460
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
|
data/lib/hubspot/helpers/path.rb
CHANGED
@@ -8,12 +8,11 @@ module Hubspot
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def require_with_mapping(path)
|
11
|
-
require path
|
11
|
+
require path
|
12
12
|
end
|
13
13
|
|
14
14
|
def require_with_codegen_mapping(path)
|
15
15
|
require path
|
16
|
-
.gsub('o_auth', 'oauth')
|
17
16
|
.gsub('audit_logs/', 'audit-logs/')
|
18
17
|
.gsub('blog_posts/', 'blog-posts/')
|
19
18
|
.gsub('site_search', 'site-search')
|
@@ -17,7 +17,7 @@ module Hubspot
|
|
17
17
|
if signature_version == "v3"
|
18
18
|
current_time = DateTime.now.strftime("%s").to_i
|
19
19
|
if current_time - timestamp.to_i > MAX_ALLOWED_TIMESTAMP
|
20
|
-
raise
|
20
|
+
raise InvalidSignatureTimestampError.new(timestamp)
|
21
21
|
end
|
22
22
|
end
|
23
23
|
hashed_signature = get_signature(
|
@@ -54,7 +54,7 @@ module Hubspot
|
|
54
54
|
hash_result = OpenSSL::HMAC.base64digest('SHA256', client_secret, source_string.encode('utf-8'))
|
55
55
|
return hash_result
|
56
56
|
else
|
57
|
-
raise
|
57
|
+
raise InvalidSignatureVersionError.new(signature_version)
|
58
58
|
end
|
59
59
|
end
|
60
60
|
end
|
data/lib/hubspot/oauth_helper.rb
CHANGED
@@ -2,15 +2,19 @@ module Hubspot
|
|
2
2
|
class OAuthHelper
|
3
3
|
AUTHORIZE_URL = 'https://app.hubspot.com/oauth/authorize'.freeze
|
4
4
|
class << self
|
5
|
-
def authorize_url(client_id
|
6
|
-
|
7
|
-
client_id
|
8
|
-
redirect_uri
|
9
|
-
|
10
|
-
optional_scope: Array(optional_scope)
|
11
|
-
)
|
5
|
+
def authorize_url(client_id, redirect_uri, scopes = nil, optional_scopes = nil, state = nil)
|
6
|
+
query_params = {
|
7
|
+
"client_id" => client_id,
|
8
|
+
"redirect_uri" => redirect_uri
|
9
|
+
}
|
12
10
|
|
13
|
-
"
|
11
|
+
query_params["scope"] = scopes.join(' ') if scopes
|
12
|
+
query_params["optional_scope"] = optional_scopes.join(' ') if optional_scopes
|
13
|
+
query_params['state'] ||= state if state
|
14
|
+
|
15
|
+
params = URI.encode_www_form(query_params)
|
16
|
+
|
17
|
+
"#{AUTHORIZE_URL}?#{params}"
|
14
18
|
end
|
15
19
|
end
|
16
20
|
end
|
data/lib/hubspot/version.rb
CHANGED
@@ -11,6 +11,6 @@ describe 'Hubspot::Client' do
|
|
11
11
|
it { is_expected.to respond_to(:events) }
|
12
12
|
it { is_expected.to respond_to(:files) }
|
13
13
|
it { is_expected.to respond_to(:marketing) }
|
14
|
-
it { is_expected.to respond_to(:
|
14
|
+
it { is_expected.to respond_to(:oauth) }
|
15
15
|
it { is_expected.to respond_to(:webhooks) }
|
16
16
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe 'Hubspot::Discovery::OAuth::AccessTokensApi' do
|
4
|
-
subject(:api) { Hubspot::Client.new(access_token: 'test').
|
4
|
+
subject(:api) { Hubspot::Client.new(access_token: 'test').oauth.access_tokens_api }
|
5
5
|
|
6
6
|
it { is_expected.to respond_to(:get) }
|
7
7
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe 'Hubspot::Discovery::OAuth::RefreshTokensApi' do
|
4
|
-
subject(:api) { Hubspot::Client.new(access_token: 'test').
|
4
|
+
subject(:api) { Hubspot::Client.new(access_token: 'test').oauth.refresh_tokens_api }
|
5
5
|
|
6
6
|
it { is_expected.to respond_to(:archive) }
|
7
7
|
it { is_expected.to respond_to(:get) }
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe 'Hubspot::Discovery::OAuth::TokensApi' do
|
4
|
-
subject(:api) { Hubspot::Client.new(access_token: 'test').
|
4
|
+
subject(:api) { Hubspot::Client.new(access_token: 'test').oauth.tokens_api }
|
5
5
|
|
6
6
|
it { is_expected.to respond_to(:create) }
|
7
7
|
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'uri'
|
2
|
+
require 'rspec'
|
3
|
+
|
4
|
+
require_relative "../../lib/hubspot/oauth_helper"
|
5
|
+
|
6
|
+
describe 'get_auth_url' do
|
7
|
+
AUTHORIZE_URL = 'https://app.hubspot.com/oauth/authorize'
|
8
|
+
|
9
|
+
let(:data) do
|
10
|
+
{
|
11
|
+
client_id: 'client_id',
|
12
|
+
redirect_uri: 'http://localhost',
|
13
|
+
scope: ['contacts', 'timeline'],
|
14
|
+
optional_scope: ['scope1', 'scope3']
|
15
|
+
}
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'returns the correct URL with empty scope' do
|
19
|
+
expected_params = {
|
20
|
+
client_id: data[:client_id],
|
21
|
+
redirect_uri: data[:redirect_uri]
|
22
|
+
}
|
23
|
+
expected_url = "#{AUTHORIZE_URL}?#{URI.encode_www_form(expected_params)}"
|
24
|
+
|
25
|
+
result = Hubspot::OAuthHelper.authorize_url(data[:client_id], data[:redirect_uri])
|
26
|
+
|
27
|
+
expect(result).to eq(expected_url)
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'returns the correct URL with scope' do
|
31
|
+
expected_params = {
|
32
|
+
client_id: data[:client_id],
|
33
|
+
redirect_uri: data[:redirect_uri],
|
34
|
+
scope: data[:scope].join(' ')
|
35
|
+
}
|
36
|
+
expected_url = "#{AUTHORIZE_URL}?#{URI.encode_www_form(expected_params)}"
|
37
|
+
|
38
|
+
result = Hubspot::OAuthHelper.authorize_url(data[:client_id], data[:redirect_uri], data[:scope])
|
39
|
+
|
40
|
+
expect(result).to eq(expected_url)
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'returns the correct URL with optional_scope' do
|
44
|
+
expected_params = {
|
45
|
+
client_id: data[:client_id],
|
46
|
+
redirect_uri: data[:redirect_uri],
|
47
|
+
scope: data[:optional_scope].join(' ')
|
48
|
+
}
|
49
|
+
expected_url = "#{AUTHORIZE_URL}?#{URI.encode_www_form(expected_params)}"
|
50
|
+
|
51
|
+
result = Hubspot::OAuthHelper.authorize_url(data[:client_id], data[:redirect_uri], data[:optional_scope])
|
52
|
+
|
53
|
+
expect(result).to eq(expected_url)
|
54
|
+
end
|
55
|
+
it 'returns the correct URL' do
|
56
|
+
expected_params = {
|
57
|
+
client_id: data[:client_id],
|
58
|
+
redirect_uri: data[:redirect_uri],
|
59
|
+
scope: data[:scope].join(' '),
|
60
|
+
optional_scope: data[:optional_scope].join(' '),
|
61
|
+
state: "test_state"
|
62
|
+
}
|
63
|
+
expected_url = "#{AUTHORIZE_URL}?#{URI.encode_www_form(expected_params)}"
|
64
|
+
|
65
|
+
result = Hubspot::OAuthHelper.authorize_url(
|
66
|
+
data[:client_id],
|
67
|
+
data[:redirect_uri],
|
68
|
+
data[:scope],
|
69
|
+
data[:optional_scope],
|
70
|
+
"test_state"
|
71
|
+
)
|
72
|
+
|
73
|
+
expect(result).to eq(expected_url)
|
74
|
+
end
|
75
|
+
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'date'
|
2
2
|
require_relative "../../lib/hubspot/helpers/signature"
|
3
|
+
require_relative "../../lib/hubspot/exceptions"
|
3
4
|
|
4
5
|
TEST_DATA = {
|
5
6
|
:client_secret=> "yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy",
|
@@ -49,7 +50,7 @@ describe "Hubspot::Helpers::Signature.get_signature" do
|
|
49
50
|
client_secret: TEST_DATA[:client_secret],
|
50
51
|
request_body: TEST_DATA[:request_body],
|
51
52
|
signature_version: "wrong_signature_version"
|
52
|
-
) }.to raise_error(
|
53
|
+
) }.to raise_error(Hubspot::InvalidSignatureVersionError)
|
53
54
|
end
|
54
55
|
|
55
56
|
end
|
@@ -102,7 +103,7 @@ describe "Hubspot::Helpers::Signature.is_valid" do
|
|
102
103
|
request_body: TEST_DATA[:request_body],
|
103
104
|
http_uri: TEST_DATA[:http_uri],
|
104
105
|
signature_version: "v3"
|
105
|
-
) }.to raise_error(
|
106
|
+
) }.to raise_error(Hubspot::InvalidSignatureTimestampError)
|
106
107
|
end
|
107
108
|
it "should raise exception if :signature_version=>v3 and :timestamp=>wrong_timestamp" do
|
108
109
|
expect { signature.is_valid(
|
@@ -112,6 +113,6 @@ describe "Hubspot::Helpers::Signature.is_valid" do
|
|
112
113
|
http_uri: TEST_DATA[:http_uri],
|
113
114
|
timestamp: "wrong_timestamp",
|
114
115
|
signature_version: "v3"
|
115
|
-
) }.to raise_error(
|
116
|
+
) }.to raise_error(Hubspot::InvalidSignatureTimestampError)
|
116
117
|
end
|
117
118
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hubspot-api-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 17.0.0
|
4
|
+
version: 17.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- HubSpot
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-06-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: typhoeus
|
@@ -1783,12 +1783,12 @@ files:
|
|
1783
1783
|
- lib/hubspot/discovery/webhooks/api/subscriptions_api.rb
|
1784
1784
|
- lib/hubspot/discovery/webhooks/client.rb
|
1785
1785
|
- lib/hubspot/exceptions.rb
|
1786
|
+
- lib/hubspot/helpers/association_type.rb
|
1786
1787
|
- lib/hubspot/helpers/camel_case.rb
|
1787
1788
|
- lib/hubspot/helpers/get_all_helper.rb
|
1788
1789
|
- lib/hubspot/helpers/path.rb
|
1789
1790
|
- lib/hubspot/helpers/signature.rb
|
1790
1791
|
- lib/hubspot/helpers/snake_case.rb
|
1791
|
-
- lib/hubspot/helpers/webhooks_helper.rb
|
1792
1792
|
- lib/hubspot/oauth_helper.rb
|
1793
1793
|
- lib/hubspot/version.rb
|
1794
1794
|
- spec/discovery/automation/actions/callbacks_api_spec.rb
|
@@ -1939,6 +1939,7 @@ files:
|
|
1939
1939
|
- spec/discovery/settings/users/users_api_spec.rb
|
1940
1940
|
- spec/discovery/webhooks/settings_api_spec.rb
|
1941
1941
|
- spec/discovery/webhooks/subscriptions_api_spec.rb
|
1942
|
+
- spec/helpers/authorize_url_spec.rb
|
1942
1943
|
- spec/helpers/camel_case_spec.rb
|
1943
1944
|
- spec/helpers/signature_spec.rb
|
1944
1945
|
- spec/spec_helper.rb
|
@@ -1957,9 +1958,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
1957
1958
|
version: '2.7'
|
1958
1959
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
1959
1960
|
requirements:
|
1960
|
-
- - "
|
1961
|
+
- - ">="
|
1961
1962
|
- !ruby/object:Gem::Version
|
1962
|
-
version:
|
1963
|
+
version: '0'
|
1963
1964
|
requirements: []
|
1964
1965
|
rubygems_version: 3.2.3
|
1965
1966
|
signing_key:
|
@@ -2114,6 +2115,7 @@ test_files:
|
|
2114
2115
|
- spec/discovery/events/events_api_spec.rb
|
2115
2116
|
- spec/discovery/webhooks/settings_api_spec.rb
|
2116
2117
|
- spec/discovery/webhooks/subscriptions_api_spec.rb
|
2118
|
+
- spec/helpers/authorize_url_spec.rb
|
2117
2119
|
- spec/helpers/signature_spec.rb
|
2118
2120
|
- spec/helpers/camel_case_spec.rb
|
2119
2121
|
- spec/spec_helper.rb
|
@@ -1,32 +0,0 @@
|
|
1
|
-
# @deprecated
|
2
|
-
module Hubspot
|
3
|
-
module Helpers
|
4
|
-
class WebhooksHelper
|
5
|
-
def self.validate_signature(
|
6
|
-
signature:,
|
7
|
-
client_secret:,
|
8
|
-
http_uri:,
|
9
|
-
request_body:,
|
10
|
-
http_method: 'POST',
|
11
|
-
signature_version: 'v2'
|
12
|
-
)
|
13
|
-
|
14
|
-
if signature_version == 'v1'
|
15
|
-
source_string = client_secret + request_body.to_s
|
16
|
-
else
|
17
|
-
source_string = client_secret + http_method + http_uri + request_body.to_s
|
18
|
-
end
|
19
|
-
|
20
|
-
hash_result = Digest::SHA2.hexdigest(source_string.encode('utf-8'))
|
21
|
-
|
22
|
-
if hash_result != signature
|
23
|
-
raise InvalidSignatureError.new(
|
24
|
-
signature: signature,
|
25
|
-
signature_version: signature_version,
|
26
|
-
hash_result: hash_result
|
27
|
-
)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|