castle-rb 9.1.0 → 9.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c138f51f6546b1a01b53f8542506e6e8566928d4b0907992d33dcb648788c9ee
4
- data.tar.gz: d8f282e27ad75bad8e0d137b21ca15158ac3b6c3603f89098a3d77487cfa3658
3
+ metadata.gz: 93980c047867e58e332b7503edfb243e157de612024a137e7e8fe2f6cd69b0ab
4
+ data.tar.gz: 487754c292626984bb233f67c88b0101aba4a206dfa7ab738f7e042799be59cf
5
5
  SHA512:
6
- metadata.gz: 9b5c96cf024088766cd6cf1dad0b6c371dcfee03241ec695fc148c08d5bafd5658b4731514db4e8cf88ad430607cf26650077ce0db2ee9b95d56d62459b6a987
7
- data.tar.gz: 054deed51da4427e2c715b2e5f63a646d8acc73125e64d30b5d3fa2fadbd42119baf536d2b83e31b158fb5423f0b18b7d0bda67613d0f1fbb360c59c8f4959e3
6
+ metadata.gz: 42b66ed4b557d084bbfbb0b15b69793811c35e87e642b0a07de4aee9c8c0379732747aa9bd8a4890ff34a0420926f280d7d44044f09347e4078b9d65af6c9630
7
+ data.tar.gz: f15c06bfdcc644c419ff45fa6777c11ddae889a1be42d3b2c88665ce45b08acb71474c182b6524b6d70aa3777349733753fda516bd2215f63ca337bdf7daf102
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 9.2.0
4
+
5
+ **Changes:**
6
+
7
+ - Slim down the default request context to `headers`, `ip` and `library`; the remaining data is already available via `headers`.
8
+ - Remove the internal `Castle::ClientId::Extract` service and the now-unused `cookies` plumbing in `Castle::Context::GetDefault`.
9
+ - No longer read the API secret from the `CASTLE_API_SECRET` environment variable automatically; set `Castle.api_secret` explicitly (for example `Castle.api_secret = ENV.fetch('CASTLE_API_SECRET')`).
10
+
3
11
  ## 9.1.0
4
12
 
5
13
  **Enhancements:**
@@ -69,7 +69,7 @@ module Castle
69
69
  self.base_url = BASE_URL
70
70
  self.allowlisted = [].freeze
71
71
  self.denylisted = [].freeze
72
- self.api_secret = ENV.fetch('CASTLE_API_SECRET', '')
72
+ self.api_secret = ''
73
73
  self.ip_headers = [].freeze
74
74
  self.trusted_proxies = [].freeze
75
75
  self.trust_proxy_chain = false
@@ -3,50 +3,21 @@
3
3
  module Castle
4
4
  module Context
5
5
  class GetDefault
6
- def initialize(request, cookies = nil)
6
+ def initialize(request)
7
7
  @pre_headers = Castle::Headers::Filter.new(request).call
8
- @cookies = cookies || request.cookies
9
- @request = request
10
8
  end
11
9
 
12
10
  def call
13
- {
14
- client_id: client_id,
15
- active: true,
16
- headers: headers,
17
- ip: ip,
18
- library: {
19
- name: 'castle-rb',
20
- version: Castle::VERSION
21
- }
22
- }.tap do |result|
23
- result[:locale] = locale if locale
24
- result[:user_agent] = user_agent if user_agent
25
- end
11
+ { headers: headers, ip: ip, library: { name: 'castle-rb', version: Castle::VERSION } }
26
12
  end
27
13
 
28
14
  private
29
15
 
30
- # @return [String]
31
- def locale
32
- @pre_headers['Accept-Language']
33
- end
34
-
35
- # @return [String]
36
- def user_agent
37
- @pre_headers['User-Agent']
38
- end
39
-
40
16
  # @return [String]
41
17
  def ip
42
18
  Castle::IPs::Extract.new(@pre_headers).call
43
19
  end
44
20
 
45
- # @return [String]
46
- def client_id
47
- Castle::ClientId::Extract.new(@pre_headers, @cookies).call
48
- end
49
-
50
21
  # formatted and filtered headers
51
22
  # @return [Hash]
52
23
  def headers
@@ -9,7 +9,7 @@ module Castle
9
9
  # @param options [Hash]
10
10
  # @return [Hash]
11
11
  def call(request, options = {})
12
- default_context = Castle::Context::GetDefault.new(request, options[:cookies]).call
12
+ default_context = Castle::Context::GetDefault.new(request).call
13
13
  Castle::Context::Merge.call(default_context, options[:context])
14
14
  end
15
15
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Castle
4
- VERSION = '9.1.0'
4
+ VERSION = '9.2.0'
5
5
  end
data/lib/castle.rb CHANGED
@@ -78,7 +78,6 @@
78
78
  castle/headers/format
79
79
  castle/headers/extract
80
80
  castle/secure_mode
81
- castle/client_id/extract
82
81
  castle/ips/extract
83
82
  castle/core/get_connection
84
83
  castle/core/process_response
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: castle-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 9.1.0
4
+ version: 9.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Johan Brissmyr
@@ -67,7 +67,6 @@ files:
67
67
  - lib/castle/client_actions/list_items.rb
68
68
  - lib/castle/client_actions/lists.rb
69
69
  - lib/castle/client_actions/privacy.rb
70
- - lib/castle/client_id/extract.rb
71
70
  - lib/castle/command.rb
72
71
  - lib/castle/commands/events/group.rb
73
72
  - lib/castle/commands/events/query.rb
@@ -147,7 +146,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
147
146
  - !ruby/object:Gem::Version
148
147
  version: '0'
149
148
  requirements: []
150
- rubygems_version: 4.0.8
149
+ rubygems_version: 3.6.9
151
150
  specification_version: 4
152
151
  summary: Official Ruby SDK for the Castle fraud and account-abuse prevention platform
153
152
  test_files: []
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Castle
4
- module ClientId
5
- # used for extraction of cookies and headers from the request
6
- class Extract
7
- # @param headers [Hash]
8
- # @param cookies [NilClass|Hash]
9
- def initialize(headers, cookies)
10
- @headers = headers
11
- @cookies = cookies || {}
12
- end
13
-
14
- # extracts client id
15
- # @return [String]
16
- def call
17
- @headers['X-Castle-Client-Id'] || @cookies['__cid'] || ''
18
- end
19
- end
20
- end
21
- end