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 +4 -4
- data/CHANGELOG.md +8 -0
- data/lib/castle/configuration.rb +1 -1
- data/lib/castle/context/get_default.rb +2 -31
- data/lib/castle/context/prepare.rb +1 -1
- data/lib/castle/version.rb +1 -1
- data/lib/castle.rb +0 -1
- metadata +2 -3
- data/lib/castle/client_id/extract.rb +0 -21
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 93980c047867e58e332b7503edfb243e157de612024a137e7e8fe2f6cd69b0ab
|
|
4
|
+
data.tar.gz: 487754c292626984bb233f67c88b0101aba4a206dfa7ab738f7e042799be59cf
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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:**
|
data/lib/castle/configuration.rb
CHANGED
|
@@ -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 =
|
|
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
|
|
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
|
|
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
|
data/lib/castle/version.rb
CHANGED
data/lib/castle.rb
CHANGED
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.
|
|
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:
|
|
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
|