castle-rb 8.0.0 → 9.0.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 +317 -0
- data/LICENSE +21 -0
- data/README.md +290 -112
- data/lib/castle/api/filter.rb +3 -1
- data/lib/castle/api/list_items/archive.rb +23 -0
- data/lib/castle/api/list_items/count.rb +22 -0
- data/lib/castle/api/list_items/create.rb +22 -0
- data/lib/castle/api/list_items/create_batch.rb +22 -0
- data/lib/castle/api/list_items/get.rb +22 -0
- data/lib/castle/api/list_items/query.rb +22 -0
- data/lib/castle/api/list_items/unarchive.rb +22 -0
- data/lib/castle/api/list_items/update.rb +22 -0
- data/lib/castle/api/lists/create.rb +23 -0
- data/lib/castle/api/lists/delete.rb +22 -0
- data/lib/castle/api/lists/get.rb +22 -0
- data/lib/castle/api/lists/get_all.rb +22 -0
- data/lib/castle/api/lists/query.rb +22 -0
- data/lib/castle/api/lists/update.rb +22 -0
- data/lib/castle/api/log.rb +2 -1
- data/lib/castle/api/privacy/delete_data.rb +23 -0
- data/lib/castle/api/privacy/request_data.rb +23 -0
- data/lib/castle/api/risk.rb +2 -1
- data/lib/castle/client.rb +15 -52
- data/lib/castle/client_actions/list_items.rb +49 -0
- data/lib/castle/client_actions/lists.rb +39 -0
- data/lib/castle/client_actions/privacy.rb +20 -0
- data/lib/castle/commands/list_items/archive.rb +24 -0
- data/lib/castle/commands/list_items/count.rb +23 -0
- data/lib/castle/commands/list_items/create.rb +22 -0
- data/lib/castle/commands/list_items/create_batch.rb +22 -0
- data/lib/castle/commands/list_items/get.rb +23 -0
- data/lib/castle/commands/list_items/query.rb +24 -0
- data/lib/castle/commands/list_items/unarchive.rb +23 -0
- data/lib/castle/commands/list_items/update.rb +22 -0
- data/lib/castle/commands/lists/create.rb +21 -0
- data/lib/castle/commands/lists/delete.rb +20 -0
- data/lib/castle/commands/lists/get.rb +20 -0
- data/lib/castle/commands/lists/get_all.rb +17 -0
- data/lib/castle/commands/lists/query.rb +21 -0
- data/lib/castle/commands/lists/update.rb +22 -0
- data/lib/castle/commands/privacy/delete_data.rb +20 -0
- data/lib/castle/commands/privacy/request_data.rb +20 -0
- data/lib/castle/core/get_connection.rb +5 -1
- data/lib/castle/core/process_response.rb +1 -0
- data/lib/castle/core/process_webhook.rb +1 -1
- data/lib/castle/core/send_request.rb +2 -1
- data/lib/castle/errors.rb +1 -5
- data/lib/castle/headers/filter.rb +1 -1
- data/lib/castle/version.rb +1 -1
- data/lib/castle.rb +36 -17
- metadata +62 -162
- data/lib/castle/api/approve_device.rb +0 -20
- data/lib/castle/api/authenticate.rb +0 -28
- data/lib/castle/api/end_impersonation.rb +0 -22
- data/lib/castle/api/get_device.rb +0 -20
- data/lib/castle/api/get_devices_for_user.rb +0 -20
- data/lib/castle/api/report_device.rb +0 -20
- data/lib/castle/api/start_impersonation.rb +0 -22
- data/lib/castle/api/track.rb +0 -19
- data/lib/castle/commands/approve_device.rb +0 -17
- data/lib/castle/commands/authenticate.rb +0 -23
- data/lib/castle/commands/end_impersonation.rb +0 -25
- data/lib/castle/commands/get_device.rb +0 -17
- data/lib/castle/commands/get_devices_for_user.rb +0 -17
- data/lib/castle/commands/report_device.rb +0 -17
- data/lib/castle/commands/start_impersonation.rb +0 -25
- data/lib/castle/commands/track.rb +0 -22
- data/lib/castle/support/hanami.rb +0 -15
- data/lib/castle/support/padrino.rb +0 -19
- data/spec/integration/rails/rails_spec.rb +0 -95
- data/spec/integration/rails/support/all.rb +0 -6
- data/spec/integration/rails/support/application.rb +0 -17
- data/spec/integration/rails/support/home_controller.rb +0 -39
- data/spec/lib/castle/api/approve_device_spec.rb +0 -17
- data/spec/lib/castle/api/authenticate_spec.rb +0 -133
- data/spec/lib/castle/api/end_impersonation_spec.rb +0 -59
- data/spec/lib/castle/api/filter_spec.rb +0 -5
- data/spec/lib/castle/api/get_device_spec.rb +0 -17
- data/spec/lib/castle/api/get_devices_for_user_spec.rb +0 -17
- data/spec/lib/castle/api/log_spec.rb +0 -5
- data/spec/lib/castle/api/report_device_spec.rb +0 -17
- data/spec/lib/castle/api/risk_spec.rb +0 -5
- data/spec/lib/castle/api/start_impersonation_spec.rb +0 -59
- data/spec/lib/castle/api/track_spec.rb +0 -65
- data/spec/lib/castle/api_spec.rb +0 -36
- data/spec/lib/castle/client_id/extract_spec.rb +0 -47
- data/spec/lib/castle/client_spec.rb +0 -337
- data/spec/lib/castle/command_spec.rb +0 -9
- data/spec/lib/castle/commands/approve_device_spec.rb +0 -24
- data/spec/lib/castle/commands/authenticate_spec.rb +0 -86
- data/spec/lib/castle/commands/end_impersonation_spec.rb +0 -72
- data/spec/lib/castle/commands/filter_spec.rb +0 -72
- data/spec/lib/castle/commands/get_device_spec.rb +0 -24
- data/spec/lib/castle/commands/get_devices_for_user_spec.rb +0 -24
- data/spec/lib/castle/commands/log_spec.rb +0 -73
- data/spec/lib/castle/commands/report_device_spec.rb +0 -24
- data/spec/lib/castle/commands/risk_spec.rb +0 -73
- data/spec/lib/castle/commands/start_impersonation_spec.rb +0 -72
- data/spec/lib/castle/commands/track_spec.rb +0 -89
- data/spec/lib/castle/configuration_spec.rb +0 -14
- data/spec/lib/castle/context/get_default_spec.rb +0 -41
- data/spec/lib/castle/context/merge_spec.rb +0 -23
- data/spec/lib/castle/context/prepare_spec.rb +0 -42
- data/spec/lib/castle/context/sanitize_spec.rb +0 -27
- data/spec/lib/castle/core/get_connection_spec.rb +0 -43
- data/spec/lib/castle/core/process_response_spec.rb +0 -103
- data/spec/lib/castle/core/process_webhook_spec.rb +0 -52
- data/spec/lib/castle/core/send_request_spec.rb +0 -97
- data/spec/lib/castle/failover/strategy_spec.rb +0 -12
- data/spec/lib/castle/headers/extract_spec.rb +0 -103
- data/spec/lib/castle/headers/filter_spec.rb +0 -42
- data/spec/lib/castle/headers/format_spec.rb +0 -25
- data/spec/lib/castle/ips/extract_spec.rb +0 -91
- data/spec/lib/castle/logger_spec.rb +0 -39
- data/spec/lib/castle/payload/prepare_spec.rb +0 -52
- data/spec/lib/castle/secure_mode_spec.rb +0 -7
- data/spec/lib/castle/session_spec.rb +0 -61
- data/spec/lib/castle/singleton_configuration_spec.rb +0 -14
- data/spec/lib/castle/utils/clean_invalid_chars_spec.rb +0 -69
- data/spec/lib/castle/utils/clone_spec.rb +0 -19
- data/spec/lib/castle/utils/deep_symbolize_keys_spec.rb +0 -50
- data/spec/lib/castle/utils/get_timestamp_spec.rb +0 -16
- data/spec/lib/castle/utils/merge_spec.rb +0 -13
- data/spec/lib/castle/validators/not_supported_spec.rb +0 -19
- data/spec/lib/castle/validators/present_spec.rb +0 -25
- data/spec/lib/castle/verdict_spec.rb +0 -9
- data/spec/lib/castle/version_spec.rb +0 -5
- data/spec/lib/castle/webhooks/verify_spec.rb +0 -59
- data/spec/lib/castle_spec.rb +0 -58
- data/spec/spec_helper.rb +0 -24
- data/spec/support/shared_examples/action_request.rb +0 -167
- data/spec/support/shared_examples/configuration.rb +0 -99
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Castle
|
|
4
|
+
module Commands
|
|
5
|
+
module Lists
|
|
6
|
+
# Builds the command to get a list
|
|
7
|
+
class Get
|
|
8
|
+
class << self
|
|
9
|
+
# @param options [Hash]
|
|
10
|
+
# @return [Castle::Command]
|
|
11
|
+
def build(options = {})
|
|
12
|
+
Castle::Validators::Present.call(options, %i[list_id])
|
|
13
|
+
|
|
14
|
+
Castle::Command.new("lists/#{options[:list_id]}", nil, :get)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Castle
|
|
4
|
+
module Commands
|
|
5
|
+
module Lists
|
|
6
|
+
# Builds the command to get all lists
|
|
7
|
+
class GetAll
|
|
8
|
+
class << self
|
|
9
|
+
# @return [Castle::Command]
|
|
10
|
+
def build
|
|
11
|
+
Castle::Command.new('lists', nil, :get)
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Castle
|
|
4
|
+
module Commands
|
|
5
|
+
module Lists
|
|
6
|
+
# Builds the command to query lists
|
|
7
|
+
class Query
|
|
8
|
+
class << self
|
|
9
|
+
# @param options [Hash]
|
|
10
|
+
# @return [Castle::Command]
|
|
11
|
+
def build(options = {})
|
|
12
|
+
options[:filters]&.each { |f| Castle::Validators::Present.call(f, %i[field op value]) }
|
|
13
|
+
Castle::Validators::Present.call(options[:sort], %i[field order]) if options[:sort]
|
|
14
|
+
|
|
15
|
+
Castle::Command.new('lists/query', options, :post)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Castle
|
|
4
|
+
module Commands
|
|
5
|
+
module Lists
|
|
6
|
+
# Builds the command to update a list
|
|
7
|
+
class Update
|
|
8
|
+
class << self
|
|
9
|
+
# @param options [Hash]
|
|
10
|
+
# @return [Castle::Command]
|
|
11
|
+
def build(options = {})
|
|
12
|
+
Castle::Validators::Present.call(options, %i[list_id])
|
|
13
|
+
|
|
14
|
+
list_id = options.delete(:list_id)
|
|
15
|
+
|
|
16
|
+
Castle::Command.new("lists/#{list_id}", options, :put)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Castle
|
|
4
|
+
module Commands
|
|
5
|
+
module Privacy
|
|
6
|
+
# Builds the command for DELETE /v1/privacy/users — GDPR Article 17 (right to be forgotten).
|
|
7
|
+
class DeleteData
|
|
8
|
+
class << self
|
|
9
|
+
# @param options [Hash] must include :identifier and :identifier_type ($id or $email)
|
|
10
|
+
# @return [Castle::Command]
|
|
11
|
+
def build(options = {})
|
|
12
|
+
Castle::Validators::Present.call(options, %i[identifier identifier_type])
|
|
13
|
+
|
|
14
|
+
Castle::Command.new('privacy/users', options, :delete)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Castle
|
|
4
|
+
module Commands
|
|
5
|
+
module Privacy
|
|
6
|
+
# Builds the command for POST /v1/privacy/users — GDPR Article 15 (right of access).
|
|
7
|
+
class RequestData
|
|
8
|
+
class << self
|
|
9
|
+
# @param options [Hash] must include :identifier and :identifier_type ($id or $email)
|
|
10
|
+
# @return [Castle::Command]
|
|
11
|
+
def build(options = {})
|
|
12
|
+
Castle::Validators::Present.call(options, %i[identifier identifier_type])
|
|
13
|
+
|
|
14
|
+
Castle::Command.new('privacy/users', options, :post)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -12,7 +12,11 @@ module Castle
|
|
|
12
12
|
def call(config = nil)
|
|
13
13
|
config ||= Castle.config
|
|
14
14
|
http = Net::HTTP.new(config.base_url.host, config.base_url.port)
|
|
15
|
-
|
|
15
|
+
# `request_timeout` is in milliseconds for historical reasons; both
|
|
16
|
+
# Net::HTTP timeouts take seconds.
|
|
17
|
+
timeout_seconds = config.request_timeout / 1000.0
|
|
18
|
+
http.open_timeout = timeout_seconds
|
|
19
|
+
http.read_timeout = timeout_seconds
|
|
16
20
|
|
|
17
21
|
if config.base_url.scheme == HTTPS_SCHEME
|
|
18
22
|
http.use_ssl = true
|
|
@@ -11,7 +11,7 @@ module Castle
|
|
|
11
11
|
# @return [String]
|
|
12
12
|
def call(webhook, config = nil)
|
|
13
13
|
webhook.body.read.tap do |result|
|
|
14
|
-
raise Castle::ApiError, 'Invalid webhook from Castle API' if result.
|
|
14
|
+
raise Castle::ApiError, 'Invalid webhook from Castle API' if result.nil? || result.empty?
|
|
15
15
|
|
|
16
16
|
Castle::Logger.call('webhook:', result.to_s, config)
|
|
17
17
|
end
|
|
@@ -15,7 +15,8 @@ module Castle
|
|
|
15
15
|
# @param http [Net::HTTP]
|
|
16
16
|
# @param config [Castle::Configuration, Castle::SingletonConfiguration, nil]
|
|
17
17
|
def call(command, headers, http = nil, config = nil)
|
|
18
|
-
|
|
18
|
+
connection = http || Castle::Core::GetConnection.call(config)
|
|
19
|
+
connection.request(build(command, headers.merge(DEFAULT_HEADERS), config))
|
|
19
20
|
end
|
|
20
21
|
|
|
21
22
|
# @param command [String]
|
data/lib/castle/errors.rb
CHANGED
|
@@ -12,7 +12,7 @@ module Castle
|
|
|
12
12
|
attr_reader :reason
|
|
13
13
|
|
|
14
14
|
# @param reason [Exception] the core exception that causes this error
|
|
15
|
-
def initialize(reason)
|
|
15
|
+
def initialize(reason) # rubocop:disable Lint/MissingSuper -- preserves legacy `to_s` (returns class name)
|
|
16
16
|
@reason = reason
|
|
17
17
|
end
|
|
18
18
|
end
|
|
@@ -68,8 +68,4 @@ module Castle
|
|
|
68
68
|
# all internal server errors
|
|
69
69
|
class InternalServerError < Castle::ApiError
|
|
70
70
|
end
|
|
71
|
-
|
|
72
|
-
# impersonation command failed
|
|
73
|
-
class ImpersonationFailed < Castle::ApiError
|
|
74
|
-
end
|
|
75
71
|
end
|
data/lib/castle/version.rb
CHANGED
data/lib/castle.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
%w[openssl net/http json time].each(&method(:require))
|
|
3
|
+
%w[openssl net/http json time base64].each(&method(:require))
|
|
4
4
|
|
|
5
5
|
%w[
|
|
6
6
|
castle/version
|
|
@@ -20,34 +20,53 @@
|
|
|
20
20
|
castle/context/sanitize
|
|
21
21
|
castle/context/get_default
|
|
22
22
|
castle/context/prepare
|
|
23
|
-
castle/commands/approve_device
|
|
24
|
-
castle/commands/authenticate
|
|
25
|
-
castle/commands/end_impersonation
|
|
26
23
|
castle/commands/filter
|
|
27
|
-
castle/commands/get_device
|
|
28
|
-
castle/commands/get_devices_for_user
|
|
29
24
|
castle/commands/log
|
|
30
|
-
castle/commands/report_device
|
|
31
25
|
castle/commands/risk
|
|
32
|
-
castle/commands/
|
|
33
|
-
castle/commands/
|
|
34
|
-
castle/
|
|
35
|
-
castle/
|
|
36
|
-
castle/
|
|
26
|
+
castle/commands/lists/get_all
|
|
27
|
+
castle/commands/lists/create
|
|
28
|
+
castle/commands/lists/delete
|
|
29
|
+
castle/commands/lists/get
|
|
30
|
+
castle/commands/lists/query
|
|
31
|
+
castle/commands/lists/update
|
|
32
|
+
castle/commands/list_items/archive
|
|
33
|
+
castle/commands/list_items/create
|
|
34
|
+
castle/commands/list_items/create_batch
|
|
35
|
+
castle/commands/list_items/count
|
|
36
|
+
castle/commands/list_items/get
|
|
37
|
+
castle/commands/list_items/query
|
|
38
|
+
castle/commands/list_items/unarchive
|
|
39
|
+
castle/commands/list_items/update
|
|
40
|
+
castle/commands/privacy/request_data
|
|
41
|
+
castle/commands/privacy/delete_data
|
|
37
42
|
castle/api/filter
|
|
38
|
-
castle/api/get_device
|
|
39
|
-
castle/api/get_devices_for_user
|
|
40
43
|
castle/api/log
|
|
41
|
-
castle/api/report_device
|
|
42
44
|
castle/api/risk
|
|
43
|
-
castle/api/
|
|
44
|
-
castle/api/
|
|
45
|
+
castle/api/lists/get_all
|
|
46
|
+
castle/api/lists/create
|
|
47
|
+
castle/api/lists/delete
|
|
48
|
+
castle/api/lists/get
|
|
49
|
+
castle/api/lists/query
|
|
50
|
+
castle/api/lists/update
|
|
51
|
+
castle/api/list_items/archive
|
|
52
|
+
castle/api/list_items/create
|
|
53
|
+
castle/api/list_items/create_batch
|
|
54
|
+
castle/api/list_items/count
|
|
55
|
+
castle/api/list_items/get
|
|
56
|
+
castle/api/list_items/query
|
|
57
|
+
castle/api/list_items/unarchive
|
|
58
|
+
castle/api/list_items/update
|
|
59
|
+
castle/api/privacy/request_data
|
|
60
|
+
castle/api/privacy/delete_data
|
|
45
61
|
castle/payload/prepare
|
|
46
62
|
castle/configuration
|
|
47
63
|
castle/singleton_configuration
|
|
48
64
|
castle/logger
|
|
49
65
|
castle/failover/prepare_response
|
|
50
66
|
castle/failover/strategy
|
|
67
|
+
castle/client_actions/lists
|
|
68
|
+
castle/client_actions/list_items
|
|
69
|
+
castle/client_actions/privacy
|
|
51
70
|
castle/client
|
|
52
71
|
castle/headers/filter
|
|
53
72
|
castle/headers/format
|
metadata
CHANGED
|
@@ -1,64 +1,89 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: castle-rb
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 9.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Johan Brissmyr
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
|
-
name:
|
|
13
|
+
name: base64
|
|
15
14
|
requirement: !ruby/object:Gem::Requirement
|
|
16
15
|
requirements:
|
|
17
|
-
- - "
|
|
16
|
+
- - "~>"
|
|
18
17
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '0'
|
|
20
|
-
type: :
|
|
18
|
+
version: '0.2'
|
|
19
|
+
type: :runtime
|
|
21
20
|
prerelease: false
|
|
22
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
22
|
requirements:
|
|
24
|
-
- - "
|
|
23
|
+
- - "~>"
|
|
25
24
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: '0'
|
|
27
|
-
description:
|
|
28
|
-
|
|
25
|
+
version: '0.2'
|
|
26
|
+
description: |-
|
|
27
|
+
Castle protects web and mobile applications from account takeovers,
|
|
28
|
+
fake accounts, bots, and other forms of account abuse. This gem is
|
|
29
|
+
the official server-side Ruby SDK: it sends user events, retrieves
|
|
30
|
+
real-time risk decisions, manages trust and block lists, and
|
|
31
|
+
verifies webhook signatures.
|
|
32
|
+
email: team@castle.io
|
|
29
33
|
executables: []
|
|
30
34
|
extensions: []
|
|
31
35
|
extra_rdoc_files: []
|
|
32
36
|
files:
|
|
37
|
+
- CHANGELOG.md
|
|
38
|
+
- LICENSE
|
|
33
39
|
- README.md
|
|
34
40
|
- lib/castle-rb.rb
|
|
35
41
|
- lib/castle.rb
|
|
36
42
|
- lib/castle/api.rb
|
|
37
|
-
- lib/castle/api/approve_device.rb
|
|
38
|
-
- lib/castle/api/authenticate.rb
|
|
39
|
-
- lib/castle/api/end_impersonation.rb
|
|
40
43
|
- lib/castle/api/filter.rb
|
|
41
|
-
- lib/castle/api/
|
|
42
|
-
- lib/castle/api/
|
|
44
|
+
- lib/castle/api/list_items/archive.rb
|
|
45
|
+
- lib/castle/api/list_items/count.rb
|
|
46
|
+
- lib/castle/api/list_items/create.rb
|
|
47
|
+
- lib/castle/api/list_items/create_batch.rb
|
|
48
|
+
- lib/castle/api/list_items/get.rb
|
|
49
|
+
- lib/castle/api/list_items/query.rb
|
|
50
|
+
- lib/castle/api/list_items/unarchive.rb
|
|
51
|
+
- lib/castle/api/list_items/update.rb
|
|
52
|
+
- lib/castle/api/lists/create.rb
|
|
53
|
+
- lib/castle/api/lists/delete.rb
|
|
54
|
+
- lib/castle/api/lists/get.rb
|
|
55
|
+
- lib/castle/api/lists/get_all.rb
|
|
56
|
+
- lib/castle/api/lists/query.rb
|
|
57
|
+
- lib/castle/api/lists/update.rb
|
|
43
58
|
- lib/castle/api/log.rb
|
|
44
|
-
- lib/castle/api/
|
|
59
|
+
- lib/castle/api/privacy/delete_data.rb
|
|
60
|
+
- lib/castle/api/privacy/request_data.rb
|
|
45
61
|
- lib/castle/api/risk.rb
|
|
46
|
-
- lib/castle/api/start_impersonation.rb
|
|
47
|
-
- lib/castle/api/track.rb
|
|
48
62
|
- lib/castle/client.rb
|
|
63
|
+
- lib/castle/client_actions/list_items.rb
|
|
64
|
+
- lib/castle/client_actions/lists.rb
|
|
65
|
+
- lib/castle/client_actions/privacy.rb
|
|
49
66
|
- lib/castle/client_id/extract.rb
|
|
50
67
|
- lib/castle/command.rb
|
|
51
|
-
- lib/castle/commands/approve_device.rb
|
|
52
|
-
- lib/castle/commands/authenticate.rb
|
|
53
|
-
- lib/castle/commands/end_impersonation.rb
|
|
54
68
|
- lib/castle/commands/filter.rb
|
|
55
|
-
- lib/castle/commands/
|
|
56
|
-
- lib/castle/commands/
|
|
69
|
+
- lib/castle/commands/list_items/archive.rb
|
|
70
|
+
- lib/castle/commands/list_items/count.rb
|
|
71
|
+
- lib/castle/commands/list_items/create.rb
|
|
72
|
+
- lib/castle/commands/list_items/create_batch.rb
|
|
73
|
+
- lib/castle/commands/list_items/get.rb
|
|
74
|
+
- lib/castle/commands/list_items/query.rb
|
|
75
|
+
- lib/castle/commands/list_items/unarchive.rb
|
|
76
|
+
- lib/castle/commands/list_items/update.rb
|
|
77
|
+
- lib/castle/commands/lists/create.rb
|
|
78
|
+
- lib/castle/commands/lists/delete.rb
|
|
79
|
+
- lib/castle/commands/lists/get.rb
|
|
80
|
+
- lib/castle/commands/lists/get_all.rb
|
|
81
|
+
- lib/castle/commands/lists/query.rb
|
|
82
|
+
- lib/castle/commands/lists/update.rb
|
|
57
83
|
- lib/castle/commands/log.rb
|
|
58
|
-
- lib/castle/commands/
|
|
84
|
+
- lib/castle/commands/privacy/delete_data.rb
|
|
85
|
+
- lib/castle/commands/privacy/request_data.rb
|
|
59
86
|
- lib/castle/commands/risk.rb
|
|
60
|
-
- lib/castle/commands/start_impersonation.rb
|
|
61
|
-
- lib/castle/commands/track.rb
|
|
62
87
|
- lib/castle/configuration.rb
|
|
63
88
|
- lib/castle/context/get_default.rb
|
|
64
89
|
- lib/castle/context/merge.rb
|
|
@@ -80,8 +105,6 @@ files:
|
|
|
80
105
|
- lib/castle/secure_mode.rb
|
|
81
106
|
- lib/castle/session.rb
|
|
82
107
|
- lib/castle/singleton_configuration.rb
|
|
83
|
-
- lib/castle/support/hanami.rb
|
|
84
|
-
- lib/castle/support/padrino.rb
|
|
85
108
|
- lib/castle/support/rails.rb
|
|
86
109
|
- lib/castle/support/sinatra.rb
|
|
87
110
|
- lib/castle/utils/clean_invalid_chars.rb
|
|
@@ -95,74 +118,15 @@ files:
|
|
|
95
118
|
- lib/castle/verdict.rb
|
|
96
119
|
- lib/castle/version.rb
|
|
97
120
|
- lib/castle/webhooks/verify.rb
|
|
98
|
-
- spec/integration/rails/rails_spec.rb
|
|
99
|
-
- spec/integration/rails/support/all.rb
|
|
100
|
-
- spec/integration/rails/support/application.rb
|
|
101
|
-
- spec/integration/rails/support/home_controller.rb
|
|
102
|
-
- spec/lib/castle/api/approve_device_spec.rb
|
|
103
|
-
- spec/lib/castle/api/authenticate_spec.rb
|
|
104
|
-
- spec/lib/castle/api/end_impersonation_spec.rb
|
|
105
|
-
- spec/lib/castle/api/filter_spec.rb
|
|
106
|
-
- spec/lib/castle/api/get_device_spec.rb
|
|
107
|
-
- spec/lib/castle/api/get_devices_for_user_spec.rb
|
|
108
|
-
- spec/lib/castle/api/log_spec.rb
|
|
109
|
-
- spec/lib/castle/api/report_device_spec.rb
|
|
110
|
-
- spec/lib/castle/api/risk_spec.rb
|
|
111
|
-
- spec/lib/castle/api/start_impersonation_spec.rb
|
|
112
|
-
- spec/lib/castle/api/track_spec.rb
|
|
113
|
-
- spec/lib/castle/api_spec.rb
|
|
114
|
-
- spec/lib/castle/client_id/extract_spec.rb
|
|
115
|
-
- spec/lib/castle/client_spec.rb
|
|
116
|
-
- spec/lib/castle/command_spec.rb
|
|
117
|
-
- spec/lib/castle/commands/approve_device_spec.rb
|
|
118
|
-
- spec/lib/castle/commands/authenticate_spec.rb
|
|
119
|
-
- spec/lib/castle/commands/end_impersonation_spec.rb
|
|
120
|
-
- spec/lib/castle/commands/filter_spec.rb
|
|
121
|
-
- spec/lib/castle/commands/get_device_spec.rb
|
|
122
|
-
- spec/lib/castle/commands/get_devices_for_user_spec.rb
|
|
123
|
-
- spec/lib/castle/commands/log_spec.rb
|
|
124
|
-
- spec/lib/castle/commands/report_device_spec.rb
|
|
125
|
-
- spec/lib/castle/commands/risk_spec.rb
|
|
126
|
-
- spec/lib/castle/commands/start_impersonation_spec.rb
|
|
127
|
-
- spec/lib/castle/commands/track_spec.rb
|
|
128
|
-
- spec/lib/castle/configuration_spec.rb
|
|
129
|
-
- spec/lib/castle/context/get_default_spec.rb
|
|
130
|
-
- spec/lib/castle/context/merge_spec.rb
|
|
131
|
-
- spec/lib/castle/context/prepare_spec.rb
|
|
132
|
-
- spec/lib/castle/context/sanitize_spec.rb
|
|
133
|
-
- spec/lib/castle/core/get_connection_spec.rb
|
|
134
|
-
- spec/lib/castle/core/process_response_spec.rb
|
|
135
|
-
- spec/lib/castle/core/process_webhook_spec.rb
|
|
136
|
-
- spec/lib/castle/core/send_request_spec.rb
|
|
137
|
-
- spec/lib/castle/failover/strategy_spec.rb
|
|
138
|
-
- spec/lib/castle/headers/extract_spec.rb
|
|
139
|
-
- spec/lib/castle/headers/filter_spec.rb
|
|
140
|
-
- spec/lib/castle/headers/format_spec.rb
|
|
141
|
-
- spec/lib/castle/ips/extract_spec.rb
|
|
142
|
-
- spec/lib/castle/logger_spec.rb
|
|
143
|
-
- spec/lib/castle/payload/prepare_spec.rb
|
|
144
|
-
- spec/lib/castle/secure_mode_spec.rb
|
|
145
|
-
- spec/lib/castle/session_spec.rb
|
|
146
|
-
- spec/lib/castle/singleton_configuration_spec.rb
|
|
147
|
-
- spec/lib/castle/utils/clean_invalid_chars_spec.rb
|
|
148
|
-
- spec/lib/castle/utils/clone_spec.rb
|
|
149
|
-
- spec/lib/castle/utils/deep_symbolize_keys_spec.rb
|
|
150
|
-
- spec/lib/castle/utils/get_timestamp_spec.rb
|
|
151
|
-
- spec/lib/castle/utils/merge_spec.rb
|
|
152
|
-
- spec/lib/castle/validators/not_supported_spec.rb
|
|
153
|
-
- spec/lib/castle/validators/present_spec.rb
|
|
154
|
-
- spec/lib/castle/verdict_spec.rb
|
|
155
|
-
- spec/lib/castle/version_spec.rb
|
|
156
|
-
- spec/lib/castle/webhooks/verify_spec.rb
|
|
157
|
-
- spec/lib/castle_spec.rb
|
|
158
|
-
- spec/spec_helper.rb
|
|
159
|
-
- spec/support/shared_examples/action_request.rb
|
|
160
|
-
- spec/support/shared_examples/configuration.rb
|
|
161
121
|
homepage: https://castle.io
|
|
162
122
|
licenses:
|
|
163
123
|
- MIT
|
|
164
|
-
metadata:
|
|
165
|
-
|
|
124
|
+
metadata:
|
|
125
|
+
homepage_uri: https://castle.io
|
|
126
|
+
source_code_uri: https://github.com/castle/castle-ruby
|
|
127
|
+
changelog_uri: https://github.com/castle/castle-ruby/blob/master/CHANGELOG.md
|
|
128
|
+
bug_tracker_uri: https://github.com/castle/castle-ruby/issues
|
|
129
|
+
rubygems_mfa_required: 'true'
|
|
166
130
|
rdoc_options: []
|
|
167
131
|
require_paths:
|
|
168
132
|
- lib
|
|
@@ -170,78 +134,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
170
134
|
requirements:
|
|
171
135
|
- - ">="
|
|
172
136
|
- !ruby/object:Gem::Version
|
|
173
|
-
version: '2
|
|
137
|
+
version: '3.2'
|
|
174
138
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
175
139
|
requirements:
|
|
176
140
|
- - ">="
|
|
177
141
|
- !ruby/object:Gem::Version
|
|
178
142
|
version: '0'
|
|
179
143
|
requirements: []
|
|
180
|
-
rubygems_version: 3.
|
|
181
|
-
signing_key:
|
|
144
|
+
rubygems_version: 3.6.9
|
|
182
145
|
specification_version: 4
|
|
183
|
-
summary: Castle
|
|
184
|
-
test_files:
|
|
185
|
-
- spec/integration/rails/rails_spec.rb
|
|
186
|
-
- spec/integration/rails/support/all.rb
|
|
187
|
-
- spec/integration/rails/support/application.rb
|
|
188
|
-
- spec/integration/rails/support/home_controller.rb
|
|
189
|
-
- spec/lib/castle/api/approve_device_spec.rb
|
|
190
|
-
- spec/lib/castle/api/authenticate_spec.rb
|
|
191
|
-
- spec/lib/castle/api/end_impersonation_spec.rb
|
|
192
|
-
- spec/lib/castle/api/filter_spec.rb
|
|
193
|
-
- spec/lib/castle/api/get_device_spec.rb
|
|
194
|
-
- spec/lib/castle/api/get_devices_for_user_spec.rb
|
|
195
|
-
- spec/lib/castle/api/log_spec.rb
|
|
196
|
-
- spec/lib/castle/api/report_device_spec.rb
|
|
197
|
-
- spec/lib/castle/api/risk_spec.rb
|
|
198
|
-
- spec/lib/castle/api/start_impersonation_spec.rb
|
|
199
|
-
- spec/lib/castle/api/track_spec.rb
|
|
200
|
-
- spec/lib/castle/api_spec.rb
|
|
201
|
-
- spec/lib/castle/client_id/extract_spec.rb
|
|
202
|
-
- spec/lib/castle/client_spec.rb
|
|
203
|
-
- spec/lib/castle/command_spec.rb
|
|
204
|
-
- spec/lib/castle/commands/approve_device_spec.rb
|
|
205
|
-
- spec/lib/castle/commands/authenticate_spec.rb
|
|
206
|
-
- spec/lib/castle/commands/end_impersonation_spec.rb
|
|
207
|
-
- spec/lib/castle/commands/filter_spec.rb
|
|
208
|
-
- spec/lib/castle/commands/get_device_spec.rb
|
|
209
|
-
- spec/lib/castle/commands/get_devices_for_user_spec.rb
|
|
210
|
-
- spec/lib/castle/commands/log_spec.rb
|
|
211
|
-
- spec/lib/castle/commands/report_device_spec.rb
|
|
212
|
-
- spec/lib/castle/commands/risk_spec.rb
|
|
213
|
-
- spec/lib/castle/commands/start_impersonation_spec.rb
|
|
214
|
-
- spec/lib/castle/commands/track_spec.rb
|
|
215
|
-
- spec/lib/castle/configuration_spec.rb
|
|
216
|
-
- spec/lib/castle/context/get_default_spec.rb
|
|
217
|
-
- spec/lib/castle/context/merge_spec.rb
|
|
218
|
-
- spec/lib/castle/context/prepare_spec.rb
|
|
219
|
-
- spec/lib/castle/context/sanitize_spec.rb
|
|
220
|
-
- spec/lib/castle/core/get_connection_spec.rb
|
|
221
|
-
- spec/lib/castle/core/process_response_spec.rb
|
|
222
|
-
- spec/lib/castle/core/process_webhook_spec.rb
|
|
223
|
-
- spec/lib/castle/core/send_request_spec.rb
|
|
224
|
-
- spec/lib/castle/failover/strategy_spec.rb
|
|
225
|
-
- spec/lib/castle/headers/extract_spec.rb
|
|
226
|
-
- spec/lib/castle/headers/filter_spec.rb
|
|
227
|
-
- spec/lib/castle/headers/format_spec.rb
|
|
228
|
-
- spec/lib/castle/ips/extract_spec.rb
|
|
229
|
-
- spec/lib/castle/logger_spec.rb
|
|
230
|
-
- spec/lib/castle/payload/prepare_spec.rb
|
|
231
|
-
- spec/lib/castle/secure_mode_spec.rb
|
|
232
|
-
- spec/lib/castle/session_spec.rb
|
|
233
|
-
- spec/lib/castle/singleton_configuration_spec.rb
|
|
234
|
-
- spec/lib/castle/utils/clean_invalid_chars_spec.rb
|
|
235
|
-
- spec/lib/castle/utils/clone_spec.rb
|
|
236
|
-
- spec/lib/castle/utils/deep_symbolize_keys_spec.rb
|
|
237
|
-
- spec/lib/castle/utils/get_timestamp_spec.rb
|
|
238
|
-
- spec/lib/castle/utils/merge_spec.rb
|
|
239
|
-
- spec/lib/castle/validators/not_supported_spec.rb
|
|
240
|
-
- spec/lib/castle/validators/present_spec.rb
|
|
241
|
-
- spec/lib/castle/verdict_spec.rb
|
|
242
|
-
- spec/lib/castle/version_spec.rb
|
|
243
|
-
- spec/lib/castle/webhooks/verify_spec.rb
|
|
244
|
-
- spec/lib/castle_spec.rb
|
|
245
|
-
- spec/spec_helper.rb
|
|
246
|
-
- spec/support/shared_examples/action_request.rb
|
|
247
|
-
- spec/support/shared_examples/configuration.rb
|
|
146
|
+
summary: Official Ruby SDK for the Castle fraud and account-abuse prevention platform
|
|
147
|
+
test_files: []
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Castle
|
|
4
|
-
module API
|
|
5
|
-
# Sends PUT devices/#{device_token}/approve request
|
|
6
|
-
module ApproveDevice
|
|
7
|
-
class << self
|
|
8
|
-
# @param options [Hash]
|
|
9
|
-
# return [Hash]
|
|
10
|
-
def call(options = {})
|
|
11
|
-
options = Castle::Utils::DeepSymbolizeKeys.call(options || {})
|
|
12
|
-
http = options.delete(:http)
|
|
13
|
-
config = options.delete(:config) || Castle.config
|
|
14
|
-
|
|
15
|
-
Castle::API.call(Castle::Commands::ApproveDevice.build(options), {}, http, config)
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Castle
|
|
4
|
-
module API
|
|
5
|
-
module Authenticate
|
|
6
|
-
class << self
|
|
7
|
-
# @param options [Hash]
|
|
8
|
-
# return [Hash]
|
|
9
|
-
def call(options = {})
|
|
10
|
-
options = Castle::Utils::DeepSymbolizeKeys.call(options || {}) unless options[:no_symbolize]
|
|
11
|
-
options.delete(:no_symbolize)
|
|
12
|
-
http = options.delete(:http)
|
|
13
|
-
config = options.delete(:config) || Castle.config
|
|
14
|
-
|
|
15
|
-
response = Castle::API.call(Castle::Commands::Authenticate.build(options), {}, http, config)
|
|
16
|
-
response.merge(failover: false, failover_reason: nil)
|
|
17
|
-
rescue Castle::RequestError, Castle::InternalServerError => e
|
|
18
|
-
unless config.failover_strategy == :throw
|
|
19
|
-
strategy = (config || Castle.config).failover_strategy
|
|
20
|
-
return(Castle::Failover::PrepareResponse.new(options[:user_id], reason: e.to_s, strategy: strategy).call)
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
raise e
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
end
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Castle
|
|
4
|
-
module API
|
|
5
|
-
# Sends DELETE impersonate request
|
|
6
|
-
module EndImpersonation
|
|
7
|
-
class << self
|
|
8
|
-
# @param options [Hash]
|
|
9
|
-
def call(options = {})
|
|
10
|
-
options = Castle::Utils::DeepSymbolizeKeys.call(options || {}) unless options[:no_symbolize]
|
|
11
|
-
options.delete(:no_symbolize)
|
|
12
|
-
http = options.delete(:http)
|
|
13
|
-
config = options.delete(:config) || Castle.config
|
|
14
|
-
|
|
15
|
-
Castle::API
|
|
16
|
-
.call(Castle::Commands::EndImpersonation.build(options), {}, http, config)
|
|
17
|
-
.tap { |response| raise Castle::ImpersonationFailed unless response[:success] }
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Castle
|
|
4
|
-
module API
|
|
5
|
-
# Sends GET devices/#{device_token} request
|
|
6
|
-
module GetDevice
|
|
7
|
-
class << self
|
|
8
|
-
# @param options [Hash]
|
|
9
|
-
# return [Hash]
|
|
10
|
-
def call(options = {})
|
|
11
|
-
options = Castle::Utils::DeepSymbolizeKeys.call(options || {})
|
|
12
|
-
http = options.delete(:http)
|
|
13
|
-
config = options.delete(:config) || Castle.config
|
|
14
|
-
|
|
15
|
-
Castle::API.call(Castle::Commands::GetDevice.build(options), {}, http, config)
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|