castle-rb 5.0.0 → 7.1.1

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.
Files changed (144) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +113 -39
  3. data/lib/castle.rb +49 -29
  4. data/lib/castle/api.rb +20 -16
  5. data/lib/castle/api/approve_device.rb +20 -0
  6. data/lib/castle/api/authenticate.rb +37 -0
  7. data/lib/castle/api/end_impersonation.rb +24 -0
  8. data/lib/castle/api/filter.rb +37 -0
  9. data/lib/castle/api/get_device.rb +20 -0
  10. data/lib/castle/api/get_devices_for_user.rb +20 -0
  11. data/lib/castle/api/log.rb +37 -0
  12. data/lib/castle/api/report_device.rb +20 -0
  13. data/lib/castle/api/risk.rb +37 -0
  14. data/lib/castle/api/start_impersonation.rb +24 -0
  15. data/lib/castle/api/track.rb +21 -0
  16. data/lib/castle/client.rb +74 -68
  17. data/lib/castle/{extractors/client_id.rb → client_id/extract.rb} +2 -2
  18. data/lib/castle/commands/approve_device.rb +17 -0
  19. data/lib/castle/commands/authenticate.rb +13 -13
  20. data/lib/castle/commands/end_impersonation.rb +25 -0
  21. data/lib/castle/commands/filter.rb +22 -0
  22. data/lib/castle/commands/get_device.rb +17 -0
  23. data/lib/castle/commands/get_devices_for_user.rb +17 -0
  24. data/lib/castle/commands/log.rb +22 -0
  25. data/lib/castle/commands/report_device.rb +17 -0
  26. data/lib/castle/commands/risk.rb +22 -0
  27. data/lib/castle/commands/start_impersonation.rb +25 -0
  28. data/lib/castle/commands/track.rb +12 -13
  29. data/lib/castle/configuration.rb +31 -23
  30. data/lib/castle/context/{default.rb → get_default.rb} +5 -6
  31. data/lib/castle/context/{merger.rb → merge.rb} +3 -3
  32. data/lib/castle/context/prepare.rb +18 -0
  33. data/lib/castle/context/{sanitizer.rb → sanitize.rb} +1 -1
  34. data/lib/castle/core/get_connection.rb +27 -0
  35. data/lib/castle/{api/response.rb → core/process_response.rb} +8 -3
  36. data/lib/castle/core/process_webhook.rb +25 -0
  37. data/lib/castle/core/send_request.rb +42 -0
  38. data/lib/castle/errors.rb +38 -12
  39. data/lib/castle/failover/prepare_response.rb +28 -0
  40. data/lib/castle/failover/strategy.rb +23 -0
  41. data/lib/castle/{extractors/headers.rb → headers/extract.rb} +8 -6
  42. data/lib/castle/headers/filter.rb +40 -0
  43. data/lib/castle/headers/format.rb +24 -0
  44. data/lib/castle/{extractors/ip.rb → ips/extract.rb} +11 -7
  45. data/lib/castle/logger.rb +19 -0
  46. data/lib/castle/payload/prepare.rb +26 -0
  47. data/lib/castle/secure_mode.rb +7 -2
  48. data/lib/castle/session.rb +18 -0
  49. data/lib/castle/singleton_configuration.rb +9 -0
  50. data/lib/castle/support/hanami.rb +2 -6
  51. data/lib/castle/support/rails.rb +1 -3
  52. data/lib/castle/utils/clean_invalid_chars.rb +22 -0
  53. data/lib/castle/utils/clone.rb +15 -0
  54. data/lib/castle/utils/deep_symbolize_keys.rb +45 -0
  55. data/lib/castle/utils/get_timestamp.rb +15 -0
  56. data/lib/castle/utils/{merger.rb → merge.rb} +3 -3
  57. data/lib/castle/utils/secure_compare.rb +22 -0
  58. data/lib/castle/validators/not_supported.rb +1 -0
  59. data/lib/castle/validators/present.rb +1 -0
  60. data/lib/castle/verdict.rb +15 -0
  61. data/lib/castle/version.rb +1 -1
  62. data/lib/castle/webhooks/verify.rb +45 -0
  63. data/spec/integration/rails/rails_spec.rb +42 -14
  64. data/spec/integration/rails/support/application.rb +3 -1
  65. data/spec/integration/rails/support/home_controller.rb +50 -6
  66. data/spec/lib/castle/api/approve_device_spec.rb +21 -0
  67. data/spec/lib/castle/api/authenticate_spec.rb +136 -0
  68. data/spec/lib/castle/api/end_impersonation_spec.rb +65 -0
  69. data/spec/lib/castle/api/filter_spec.rb +5 -0
  70. data/spec/lib/castle/api/get_device_spec.rb +19 -0
  71. data/spec/lib/castle/api/get_devices_for_user_spec.rb +19 -0
  72. data/spec/lib/castle/api/log_spec.rb +5 -0
  73. data/spec/lib/castle/api/report_device_spec.rb +21 -0
  74. data/spec/lib/castle/api/risk_spec.rb +5 -0
  75. data/spec/lib/castle/api/start_impersonation_spec.rb +65 -0
  76. data/spec/lib/castle/api/track_spec.rb +72 -0
  77. data/spec/lib/castle/api_spec.rb +14 -15
  78. data/spec/lib/castle/{extractors/client_id_spec.rb → client_id/extract_spec.rb} +6 -15
  79. data/spec/lib/castle/client_spec.rb +110 -92
  80. data/spec/lib/castle/commands/approve_device_spec.rb +24 -0
  81. data/spec/lib/castle/commands/authenticate_spec.rb +15 -31
  82. data/spec/lib/castle/commands/end_impersonation_spec.rb +79 -0
  83. data/spec/lib/castle/commands/filter_spec.rb +72 -0
  84. data/spec/lib/castle/commands/get_device_spec.rb +24 -0
  85. data/spec/lib/castle/commands/{review_spec.rb → get_devices_for_user_spec.rb} +7 -7
  86. data/spec/lib/castle/commands/log_spec.rb +73 -0
  87. data/spec/lib/castle/commands/report_device_spec.rb +24 -0
  88. data/spec/lib/castle/commands/risk_spec.rb +73 -0
  89. data/spec/lib/castle/commands/{impersonate_spec.rb → start_impersonation_spec.rb} +13 -41
  90. data/spec/lib/castle/commands/track_spec.rb +14 -34
  91. data/spec/lib/castle/configuration_spec.rb +8 -141
  92. data/spec/lib/castle/context/{default_spec.rb → get_default_spec.rb} +9 -10
  93. data/spec/lib/castle/context/{merger_spec.rb → merge_spec.rb} +1 -1
  94. data/spec/lib/castle/context/prepare_spec.rb +43 -0
  95. data/spec/lib/castle/context/{sanitizer_spec.rb → sanitize_spec.rb} +1 -1
  96. data/spec/lib/castle/core/get_connection_spec.rb +43 -0
  97. data/spec/lib/castle/{api/response_spec.rb → core/process_response_spec.rb} +49 -1
  98. data/spec/lib/castle/core/process_webhook_spec.rb +46 -0
  99. data/spec/lib/castle/{api/request_spec.rb → core/send_request_spec.rb} +16 -37
  100. data/spec/lib/castle/failover/strategy_spec.rb +12 -0
  101. data/spec/lib/castle/{extractors/headers_spec.rb → headers/extract_spec.rb} +7 -9
  102. data/spec/lib/castle/headers/filter_spec.rb +39 -0
  103. data/spec/lib/castle/headers/format_spec.rb +25 -0
  104. data/spec/lib/castle/{extractors/ip_spec.rb → ips/extract_spec.rb} +5 -14
  105. data/spec/lib/castle/logger_spec.rb +38 -0
  106. data/spec/lib/castle/payload/prepare_spec.rb +55 -0
  107. data/spec/lib/castle/session_spec.rb +65 -0
  108. data/spec/lib/castle/singleton_configuration_spec.rb +14 -0
  109. data/spec/lib/castle/utils/clean_invalid_chars_spec.rb +69 -0
  110. data/spec/lib/castle/utils/{cloner_spec.rb → clone_spec.rb} +3 -3
  111. data/spec/lib/castle/utils/deep_symbolize_keys_spec.rb +50 -0
  112. data/spec/lib/castle/utils/{timestamp_spec.rb → get_timestamp_spec.rb} +1 -1
  113. data/spec/lib/castle/utils/merge_spec.rb +15 -0
  114. data/spec/lib/castle/validators/present_spec.rb +5 -6
  115. data/spec/lib/castle/verdict_spec.rb +9 -0
  116. data/spec/lib/castle/webhooks/verify_spec.rb +53 -0
  117. data/spec/lib/castle_spec.rb +4 -10
  118. data/spec/spec_helper.rb +3 -3
  119. data/spec/support/shared_examples/action_request.rb +155 -0
  120. data/spec/support/shared_examples/configuration.rb +101 -0
  121. metadata +144 -67
  122. data/lib/castle/api/connection.rb +0 -24
  123. data/lib/castle/api/request.rb +0 -42
  124. data/lib/castle/api/session.rb +0 -20
  125. data/lib/castle/commands/identify.rb +0 -23
  126. data/lib/castle/commands/impersonate.rb +0 -26
  127. data/lib/castle/commands/review.rb +0 -14
  128. data/lib/castle/events.rb +0 -49
  129. data/lib/castle/failover_auth_response.rb +0 -21
  130. data/lib/castle/headers_filter.rb +0 -35
  131. data/lib/castle/headers_formatter.rb +0 -22
  132. data/lib/castle/review.rb +0 -11
  133. data/lib/castle/utils.rb +0 -55
  134. data/lib/castle/utils/cloner.rb +0 -11
  135. data/lib/castle/utils/timestamp.rb +0 -12
  136. data/spec/lib/castle/api/connection_spec.rb +0 -59
  137. data/spec/lib/castle/api/session_spec.rb +0 -86
  138. data/spec/lib/castle/commands/identify_spec.rb +0 -88
  139. data/spec/lib/castle/events_spec.rb +0 -5
  140. data/spec/lib/castle/headers_filter_spec.rb +0 -38
  141. data/spec/lib/castle/headers_formatter_spec.rb +0 -25
  142. data/spec/lib/castle/review_spec.rb +0 -19
  143. data/spec/lib/castle/utils/merger_spec.rb +0 -13
  144. data/spec/lib/castle/utils_spec.rb +0 -156
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Castle
4
- module Extractors
4
+ module ClientId
5
5
  # used for extraction of cookies and headers from the request
6
- class ClientId
6
+ class Extract
7
7
  # @param headers [Hash]
8
8
  # @param cookies [NilClass|Hash]
9
9
  def initialize(headers, cookies)
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Castle
4
+ module Commands
5
+ # Generates the payload for the PUT devices/#{device_token}/approve request
6
+ class ApproveDevice
7
+ class << self
8
+ # @param options [Hash]
9
+ # @return [Castle::Command]
10
+ def build(options = {})
11
+ Castle::Validators::Present.call(options, %i[device_token])
12
+ Castle::Command.new("devices/#{options[:device_token]}/approve", nil, :put)
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -2,21 +2,21 @@
2
2
 
3
3
  module Castle
4
4
  module Commands
5
+ # Generates the payload for the authenticate request
5
6
  class Authenticate
6
- def initialize(context)
7
- @context = context
8
- end
9
-
10
- def build(options = {})
11
- Castle::Validators::Present.call(options, %i[event])
12
- context = Castle::Context::Merger.call(@context, options[:context])
13
- context = Castle::Context::Sanitizer.call(context)
7
+ class << self
8
+ # @param options [Hash]
9
+ # @return [Castle::Command]
10
+ def build(options = {})
11
+ Castle::Validators::Present.call(options, %i[event])
12
+ context = Castle::Context::Sanitize.call(options[:context])
14
13
 
15
- Castle::Command.new(
16
- 'authenticate',
17
- options.merge(context: context, sent_at: Castle::Utils::Timestamp.call),
18
- :post
19
- )
14
+ Castle::Command.new(
15
+ 'authenticate',
16
+ options.merge(context: context, sent_at: Castle::Utils::GetTimestamp.call),
17
+ :post
18
+ )
19
+ end
20
20
  end
21
21
  end
22
22
  end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Castle
4
+ module Commands
5
+ # builder for impersonate command
6
+ class EndImpersonation
7
+ class << self
8
+ # @param options [Hash]
9
+ # @return [Castle::Command]
10
+ def build(options = {})
11
+ Castle::Validators::Present.call(options, %i[user_id])
12
+ context = Castle::Context::Sanitize.call(options[:context])
13
+
14
+ Castle::Validators::Present.call(context, %i[user_agent ip])
15
+
16
+ Castle::Command.new(
17
+ 'impersonate',
18
+ options.merge(context: context, sent_at: Castle::Utils::GetTimestamp.call),
19
+ :delete
20
+ )
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Castle
4
+ module Commands
5
+ # Generates the payload for the filter request
6
+ class Filter
7
+ class << self
8
+ # @param options [Hash]
9
+ # @return [Castle::Command]
10
+ def build(options = {})
11
+ context = Castle::Context::Sanitize.call(options[:context])
12
+
13
+ Castle::Command.new(
14
+ 'filter',
15
+ options.merge(context: context, sent_at: Castle::Utils::GetTimestamp.call),
16
+ :post
17
+ )
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Castle
4
+ module Commands
5
+ # Generates the payload for the GET devices/#{device_token} request
6
+ class GetDevice
7
+ class << self
8
+ # @param options [Hash]
9
+ # @return [Castle::Command]
10
+ def build(options = {})
11
+ Castle::Validators::Present.call(options, %i[device_token])
12
+ Castle::Command.new("devices/#{options[:device_token]}", nil, :get)
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Castle
4
+ module Commands
5
+ # Generates the payload for the GET users/#{user_id}/devices request
6
+ class GetDevicesForUser
7
+ class << self
8
+ # @param options [Hash]
9
+ # @return [Castle::Command]
10
+ def build(options = {})
11
+ Castle::Validators::Present.call(options, %i[user_id])
12
+ Castle::Command.new("users/#{options[:user_id]}/devices", nil, :get)
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Castle
4
+ module Commands
5
+ # Generates the payload for the log request
6
+ class Log
7
+ class << self
8
+ # @param options [Hash]
9
+ # @return [Castle::Command]
10
+ def build(options = {})
11
+ context = Castle::Context::Sanitize.call(options[:context])
12
+
13
+ Castle::Command.new(
14
+ 'log',
15
+ options.merge(context: context, sent_at: Castle::Utils::GetTimestamp.call),
16
+ :post
17
+ )
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Castle
4
+ module Commands
5
+ # Generates the payload for the PUT devices/#{device_token}/report request
6
+ class ReportDevice
7
+ class << self
8
+ # @param options [Hash]
9
+ # @return [Castle::Command]
10
+ def build(options = {})
11
+ Castle::Validators::Present.call(options, %i[device_token])
12
+ Castle::Command.new("devices/#{options[:device_token]}/report", nil, :put)
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Castle
4
+ module Commands
5
+ # Generates the payload for the risk request
6
+ class Risk
7
+ class << self
8
+ # @param options [Hash]
9
+ # @return [Castle::Command]
10
+ def build(options = {})
11
+ context = Castle::Context::Sanitize.call(options[:context])
12
+
13
+ Castle::Command.new(
14
+ 'risk',
15
+ options.merge(context: context, sent_at: Castle::Utils::GetTimestamp.call),
16
+ :post
17
+ )
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Castle
4
+ module Commands
5
+ # builder for impersonate command
6
+ class StartImpersonation
7
+ class << self
8
+ # @param options [Hash]
9
+ # @return [Castle::Command]
10
+ def build(options = {})
11
+ Castle::Validators::Present.call(options, %i[user_id])
12
+ context = Castle::Context::Sanitize.call(options[:context])
13
+
14
+ Castle::Validators::Present.call(context, %i[user_agent ip])
15
+
16
+ Castle::Command.new(
17
+ 'impersonate',
18
+ options.merge(context: context, sent_at: Castle::Utils::GetTimestamp.call),
19
+ :post
20
+ )
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -3,20 +3,19 @@
3
3
  module Castle
4
4
  module Commands
5
5
  class Track
6
- def initialize(context)
7
- @context = context
8
- end
9
-
10
- def build(options = {})
11
- Castle::Validators::Present.call(options, %i[event])
12
- context = Castle::Context::Merger.call(@context, options[:context])
13
- context = Castle::Context::Sanitizer.call(context)
6
+ class << self
7
+ # @param options [Hash]
8
+ # @return [Castle::Command]
9
+ def build(options = {})
10
+ Castle::Validators::Present.call(options, %i[event])
11
+ context = Castle::Context::Sanitize.call(options[:context])
14
12
 
15
- Castle::Command.new(
16
- 'track',
17
- options.merge(context: context, sent_at: Castle::Utils::Timestamp.call),
18
- :post
19
- )
13
+ Castle::Command.new(
14
+ 'track',
15
+ options.merge(context: context, sent_at: Castle::Utils::GetTimestamp.call),
16
+ :post
17
+ )
18
+ end
20
19
  end
21
20
  end
22
21
  end
@@ -1,27 +1,25 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'singleton'
4
3
  require 'uri'
5
4
 
6
5
  module Castle
7
6
  # manages configuration variables
8
7
  class Configuration
9
- include Singleton
10
-
11
8
  # API endpoint
12
- URL = 'https://api.castle.io/v1'
13
- FAILOVER_STRATEGY = :allow
14
- REQUEST_TIMEOUT = 500 # in milliseconds
15
- FAILOVER_STRATEGIES = %i[allow deny challenge throw].freeze
9
+ BASE_URL = 'https://api.castle.io/v1'
10
+ REQUEST_TIMEOUT = 1000 # in milliseconds
11
+
16
12
  # regexp of trusted proxies which is always appended to the trusted proxy list
17
- TRUSTED_PROXIES = [/
13
+ TRUSTED_PROXIES = [
14
+ /
18
15
  \A127\.0\.0\.1\Z|
19
16
  \A(10|172\.(1[6-9]|2[0-9]|30|31)|192\.168)\.|
20
17
  \A::1\Z|\Afd[0-9a-f]{2}:.+|
21
18
  \Alocalhost\Z|
22
19
  \Aunix\Z|
23
20
  \Aunix:
24
- /ix].freeze
21
+ /ix
22
+ ].freeze
25
23
 
26
24
  # @note this value is not assigned as we don't recommend using a allowlist. If you need to use
27
25
  # one, this constant is provided as a good default.
@@ -51,19 +49,25 @@ module Castle
51
49
  X-Requested-With
52
50
  ].freeze
53
51
 
54
- attr_accessor :request_timeout, :trust_proxy_chain
55
- attr_reader :api_secret, :allowlisted, :denylisted, :failover_strategy, :ip_headers,
56
- :trusted_proxies, :trusted_proxy_depth, :url
52
+ attr_accessor :request_timeout, :trust_proxy_chain, :logger
53
+ attr_reader :api_secret,
54
+ :allowlisted,
55
+ :denylisted,
56
+ :failover_strategy,
57
+ :ip_headers,
58
+ :trusted_proxies,
59
+ :trusted_proxy_depth,
60
+ :base_url
57
61
 
58
62
  def initialize
59
- @formatter = Castle::HeadersFormatter
63
+ @header_format = Castle::Headers::Format
60
64
  @request_timeout = REQUEST_TIMEOUT
61
65
  reset
62
66
  end
63
67
 
64
68
  def reset
65
- self.failover_strategy = FAILOVER_STRATEGY
66
- self.url = URL
69
+ self.failover_strategy = Castle::Failover::Strategy::ALLOW
70
+ self.base_url = BASE_URL
67
71
  self.allowlisted = [].freeze
68
72
  self.denylisted = [].freeze
69
73
  self.api_secret = ENV.fetch('CASTLE_API_SECRET', '')
@@ -71,10 +75,11 @@ module Castle
71
75
  self.trusted_proxies = [].freeze
72
76
  self.trust_proxy_chain = false
73
77
  self.trusted_proxy_depth = nil
78
+ self.logger = nil
74
79
  end
75
80
 
76
- def url=(value)
77
- @url = URI(value)
81
+ def base_url=(value)
82
+ @base_url = URI(value)
78
83
  end
79
84
 
80
85
  def api_secret=(value)
@@ -82,11 +87,11 @@ module Castle
82
87
  end
83
88
 
84
89
  def allowlisted=(value)
85
- @allowlisted = (value ? value.map { |header| @formatter.call(header) } : []).freeze
90
+ @allowlisted = (value ? value.map { |header| @header_format.call(header) } : []).freeze
86
91
  end
87
92
 
88
93
  def denylisted=(value)
89
- @denylisted = (value ? value.map { |header| @formatter.call(header) } : []).freeze
94
+ @denylisted = (value ? value.map { |header| @header_format.call(header) } : []).freeze
90
95
  end
91
96
 
92
97
  # sets ip headers
@@ -94,13 +99,15 @@ module Castle
94
99
  def ip_headers=(value)
95
100
  raise Castle::ConfigurationError, 'ip headers must be an Array' unless value.is_a?(Array)
96
101
 
97
- @ip_headers = value.map { |header| @formatter.call(header) }.freeze
102
+ @ip_headers = value.map { |header| @header_format.call(header) }.freeze
98
103
  end
99
104
 
100
105
  # sets trusted proxies
101
106
  # @param value [Array<String,Regexp>]
102
107
  def trusted_proxies=(value)
103
- raise Castle::ConfigurationError, 'trusted proxies must be an Array' unless value.is_a?(Array)
108
+ unless value.is_a?(Array)
109
+ raise Castle::ConfigurationError, 'trusted proxies must be an Array'
110
+ end
104
111
 
105
112
  @trusted_proxies = value
106
113
  end
@@ -111,11 +118,12 @@ module Castle
111
118
  end
112
119
 
113
120
  def valid?
114
- !api_secret.to_s.empty? && !url.host.to_s.empty? && !url.port.to_s.empty?
121
+ !api_secret.to_s.empty? && !base_url.host.to_s.empty? && !base_url.port.to_s.empty?
115
122
  end
116
123
 
117
124
  def failover_strategy=(value)
118
- @failover_strategy = FAILOVER_STRATEGIES.detect { |strategy| strategy == value.to_sym }
125
+ @failover_strategy =
126
+ Castle::Failover::STRATEGIES.detect { |strategy| strategy == value.to_sym }
119
127
  raise Castle::ConfigurationError, 'unrecognized failover strategy' if @failover_strategy.nil?
120
128
  end
121
129
 
@@ -2,9 +2,9 @@
2
2
 
3
3
  module Castle
4
4
  module Context
5
- class Default
5
+ class GetDefault
6
6
  def initialize(request, cookies = nil)
7
- @pre_headers = HeadersFilter.new(request).call
7
+ @pre_headers = Castle::Headers::Filter.new(request).call
8
8
  @cookies = cookies || request.cookies
9
9
  @request = request
10
10
  end
@@ -13,7 +13,6 @@ module Castle
13
13
  {
14
14
  client_id: client_id,
15
15
  active: true,
16
- origin: 'web',
17
16
  headers: headers,
18
17
  ip: ip,
19
18
  library: {
@@ -40,18 +39,18 @@ module Castle
40
39
 
41
40
  # @return [String]
42
41
  def ip
43
- Extractors::IP.new(@pre_headers).call
42
+ Castle::IPs::Extract.new(@pre_headers).call
44
43
  end
45
44
 
46
45
  # @return [String]
47
46
  def client_id
48
- Extractors::ClientId.new(@pre_headers, @cookies).call
47
+ Castle::ClientId::Extract.new(@pre_headers, @cookies).call
49
48
  end
50
49
 
51
50
  # formatted and filtered headers
52
51
  # @return [Hash]
53
52
  def headers
54
- Extractors::Headers.new(@pre_headers).call
53
+ Castle::Headers::Extract.new(@pre_headers).call
55
54
  end
56
55
  end
57
56
  end