minfraud 2.9.0 → 2.10.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.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +18 -0
  3. data/LICENSE.txt +1 -1
  4. data/README.md +12 -9
  5. data/lib/minfraud/assessments.rb +1 -1
  6. data/lib/minfraud/components/account.rb +1 -1
  7. data/lib/minfraud/components/base.rb +3 -0
  8. data/lib/minfraud/components/billing.rb +1 -1
  9. data/lib/minfraud/components/credit_card.rb +8 -7
  10. data/lib/minfraud/components/custom_inputs.rb +1 -1
  11. data/lib/minfraud/components/device.rb +8 -1
  12. data/lib/minfraud/components/email.rb +1 -1
  13. data/lib/minfraud/components/event.rb +3 -3
  14. data/lib/minfraud/components/order.rb +2 -2
  15. data/lib/minfraud/components/payment.rb +5 -1
  16. data/lib/minfraud/components/report/transaction.rb +5 -4
  17. data/lib/minfraud/components/shipping.rb +1 -1
  18. data/lib/minfraud/components/shopping_cart.rb +1 -1
  19. data/lib/minfraud/components/shopping_cart_item.rb +4 -4
  20. data/lib/minfraud/enum.rb +6 -0
  21. data/lib/minfraud/http_service/response.rb +4 -2
  22. data/lib/minfraud/model/abstract.rb +3 -0
  23. data/lib/minfraud/model/device.rb +1 -1
  24. data/lib/minfraud/model/email.rb +2 -1
  25. data/lib/minfraud/model/email_domain.rb +3 -2
  26. data/lib/minfraud/model/email_domain_visit.rb +10 -7
  27. data/lib/minfraud/model/factors.rb +1 -1
  28. data/lib/minfraud/model/geoip2_location.rb +1 -1
  29. data/lib/minfraud/model/insights.rb +1 -1
  30. data/lib/minfraud/model/ip_address.rb +1 -1
  31. data/lib/minfraud/model/reason.rb +1 -1
  32. data/lib/minfraud/model/shipping_address.rb +3 -1
  33. data/lib/minfraud/model/warning.rb +13 -2
  34. data/lib/minfraud/report.rb +1 -1
  35. data/lib/minfraud/validates.rb +139 -2
  36. data/lib/minfraud/version.rb +1 -1
  37. metadata +20 -19
  38. data/.rspec +0 -2
  39. data/.rubocop.yml +0 -113
  40. data/CLAUDE.md +0 -443
  41. data/CODE_OF_CONDUCT.md +0 -49
  42. data/Gemfile +0 -5
  43. data/README.dev.md +0 -28
  44. data/Rakefile +0 -12
  45. data/bin/console +0 -15
  46. data/bin/setup +0 -8
  47. data/minfraud.gemspec +0 -42
@@ -17,19 +17,30 @@ module Minfraud
17
17
  # our database.
18
18
  # * BILLING_POSTAL_NOT_FOUND - the billing postal could not be found in our
19
19
  # database.
20
+ # * BILLING_REGION_NOT_FOUND - the billing region could not be found in our
21
+ # database.
22
+ # * EMAIL_ADDRESS_UNUSABLE - the email address entered is likely incorrect
23
+ # due to an integration issue. To avoid false positives, it has not been
24
+ # used in scoring.
20
25
  # * INPUT_INVALID - the value associated with the key does not meet the
21
26
  # required constraints, e.g., "United States" in a field that requires a
22
27
  # two-letter country code.
23
28
  # * INPUT_UNKNOWN - an unknown key was encountered in the request body.
29
+ # * IP_ADDRESS_INVALID - the IP address supplied is not a valid IPv4 or
30
+ # IPv6 address.
24
31
  # * IP_ADDRESS_NOT_FOUND - the IP address could not be geolocated.
25
- # * SHIPPING_COUNTRY_MISSING - shipping address information was provided
26
- # without providing a shipping country.
32
+ # * IP_ADDRESS_RESERVED - the IP address supplied is in a reserved
33
+ # network.
27
34
  # * SHIPPING_CITY_NOT_FOUND - the shipping city could not be found in our
28
35
  # database.
36
+ # * SHIPPING_COUNTRY_MISSING - shipping address information was provided
37
+ # without providing a shipping country.
29
38
  # * SHIPPING_COUNTRY_NOT_FOUND - the shipping country could not be found in
30
39
  # our database.
31
40
  # * SHIPPING_POSTAL_NOT_FOUND - the shipping postal could not be found in
32
41
  # our database.
42
+ # * SHIPPING_REGION_NOT_FOUND - the shipping region could not be found in
43
+ # our database.
33
44
  class Warning < Abstract
34
45
  # This value is a machine-readable code identifying the warning.
35
46
  #
@@ -3,7 +3,7 @@
3
3
  module Minfraud
4
4
  # Report is used to perform minFraud Report Transaction API requests.
5
5
  #
6
- # @see https://dev.maxmind.com/minfraud/report-a-transaction?lang=en
6
+ # @see https://dev.maxmind.com/minfraud/report-a-transaction/?lang=en
7
7
  class Report
8
8
  # The Report::Transaction component.
9
9
  #
@@ -4,10 +4,23 @@ require 'date'
4
4
  require 'ipaddr'
5
5
  require 'uri'
6
6
 
7
- # rubocop:disable Metrics/ModuleLength
8
7
  module Minfraud
9
8
  # @!visibility private
9
+ # Validates provides validation helper methods for component input values.
10
+ # These methods are used internally when validation is enabled via
11
+ # Minfraud.enable_validation.
12
+ #
13
+ # rubocop:disable Metrics/ModuleLength
10
14
  module Validates
15
+ # Validates that a string value does not exceed a maximum length.
16
+ #
17
+ # @param field [String] The field name for error messages.
18
+ # @param length [Integer] The maximum allowed length.
19
+ # @param value [String, nil] The value to validate.
20
+ #
21
+ # @raise [InvalidInputError] If the value exceeds the maximum length.
22
+ #
23
+ # @return [nil]
11
24
  def validate_string(field, length, value)
12
25
  return if !value
13
26
 
@@ -16,6 +29,14 @@ module Minfraud
16
29
  end
17
30
  end
18
31
 
32
+ # Validates that a value is a valid MD5 hash string.
33
+ #
34
+ # @param field [String] The field name for error messages.
35
+ # @param value [String, nil] The value to validate.
36
+ #
37
+ # @raise [InvalidInputError] If the value is not a valid MD5 hash.
38
+ #
39
+ # @return [nil]
19
40
  def validate_md5(field, value)
20
41
  return if !value
21
42
 
@@ -24,6 +45,14 @@ module Minfraud
24
45
  end
25
46
  end
26
47
 
48
+ # Validates that a value is a valid UUID string.
49
+ #
50
+ # @param field [String] The field name for error messages.
51
+ # @param value [String, nil] The value to validate.
52
+ #
53
+ # @raise [InvalidInputError] If the value is not a valid UUID.
54
+ #
55
+ # @return [nil]
27
56
  def validate_uuid(field, value)
28
57
  return if !value
29
58
 
@@ -37,6 +66,14 @@ module Minfraud
37
66
  end
38
67
  end
39
68
 
69
+ # Validates that a value is a valid ISO 3166-2 subdivision code.
70
+ #
71
+ # @param field [String] The field name for error messages.
72
+ # @param value [String, nil] The value to validate.
73
+ #
74
+ # @raise [InvalidInputError] If the value is not a valid subdivision code.
75
+ #
76
+ # @return [nil]
40
77
  def validate_subdivision_code(field, value)
41
78
  return if !value
42
79
 
@@ -45,6 +82,14 @@ module Minfraud
45
82
  end
46
83
  end
47
84
 
85
+ # Validates that a value is a valid ISO 3166-1 alpha-2 country code.
86
+ #
87
+ # @param field [String] The field name for error messages.
88
+ # @param value [String, nil] The value to validate.
89
+ #
90
+ # @raise [InvalidInputError] If the value is not a valid country code.
91
+ #
92
+ # @return [nil]
48
93
  def validate_country_code(field, value)
49
94
  return if !value
50
95
 
@@ -53,6 +98,15 @@ module Minfraud
53
98
  end
54
99
  end
55
100
 
101
+ # Validates that a value is a valid telephone country code (1-4 digits).
102
+ #
103
+ # @param field [String] The field name for error messages.
104
+ # @param value [String, nil] The value to validate.
105
+ #
106
+ # @raise [InvalidInputError] If the value is not a valid telephone country
107
+ # code.
108
+ #
109
+ # @return [nil]
56
110
  def validate_telephone_country_code(field, value)
57
111
  return if !value
58
112
 
@@ -61,6 +115,15 @@ module Minfraud
61
115
  end
62
116
  end
63
117
 
118
+ # Validates that a value matches a regular expression pattern.
119
+ #
120
+ # @param field [String] The field name for error messages.
121
+ # @param regex [Regexp] The regular expression pattern to match.
122
+ # @param value [String, nil] The value to validate.
123
+ #
124
+ # @raise [InvalidInputError] If the value does not match the pattern.
125
+ #
126
+ # @return [nil]
64
127
  def validate_regex(field, regex, value)
65
128
  return if !value
66
129
 
@@ -69,6 +132,14 @@ module Minfraud
69
132
  end
70
133
  end
71
134
 
135
+ # Validates that a value is a valid credit card token.
136
+ #
137
+ # @param field [String] The field name for error messages.
138
+ # @param value [String, nil] The value to validate.
139
+ #
140
+ # @raise [InvalidInputError] If the value is not a valid credit card token.
141
+ #
142
+ # @return [nil]
72
143
  def validate_credit_card_token(field, value)
73
144
  return if !value
74
145
 
@@ -83,6 +154,14 @@ module Minfraud
83
154
  end
84
155
  end
85
156
 
157
+ # Validates a custom input value (boolean, numeric, or string).
158
+ #
159
+ # @param field [String] The field name for error messages.
160
+ # @param value [Boolean, Numeric, String, nil] The value to validate.
161
+ #
162
+ # @raise [InvalidInputError] If the value is not valid.
163
+ #
164
+ # @return [nil]
86
165
  def validate_custom_input_value(field, value)
87
166
  return if !value
88
167
 
@@ -101,6 +180,14 @@ module Minfraud
101
180
  validate_string(field, 255, value)
102
181
  end
103
182
 
183
+ # Validates that a value is a valid IPv4 or IPv6 address.
184
+ #
185
+ # @param field [String] The field name for error messages.
186
+ # @param value [String, nil] The value to validate.
187
+ #
188
+ # @raise [InvalidInputError] If the value is not a valid IP address.
189
+ #
190
+ # @return [nil]
104
191
  def validate_ip(field, value)
105
192
  return if !value
106
193
 
@@ -120,6 +207,15 @@ module Minfraud
120
207
  nil
121
208
  end
122
209
 
210
+ # Validates that a value is a non-negative number within range.
211
+ #
212
+ # @param field [String] The field name for error messages.
213
+ # @param value [Numeric, nil] The value to validate.
214
+ #
215
+ # @raise [InvalidInputError] If the value is not a valid non-negative
216
+ # number.
217
+ #
218
+ # @return [nil]
123
219
  def validate_nonnegative_number(field, value)
124
220
  return if !value
125
221
 
@@ -132,6 +228,15 @@ module Minfraud
132
228
  end
133
229
  end
134
230
 
231
+ # Validates that a value is a non-negative integer within range.
232
+ #
233
+ # @param field [String] The field name for error messages.
234
+ # @param value [Integer, nil] The value to validate.
235
+ #
236
+ # @raise [InvalidInputError] If the value is not a valid non-negative
237
+ # integer.
238
+ #
239
+ # @return [nil]
135
240
  def validate_nonnegative_integer(field, value)
136
241
  return if !value
137
242
 
@@ -144,6 +249,14 @@ module Minfraud
144
249
  end
145
250
  end
146
251
 
252
+ # Validates that a value is a valid email address or MD5 hash of one.
253
+ #
254
+ # @param field [String] The field name for error messages.
255
+ # @param value [String, nil] The value to validate.
256
+ #
257
+ # @raise [InvalidInputError] If the value is not a valid email or MD5 hash.
258
+ #
259
+ # @return [nil]
147
260
  def validate_email(field, value)
148
261
  return if !value
149
262
 
@@ -155,6 +268,14 @@ module Minfraud
155
268
  validate_md5(field, value)
156
269
  end
157
270
 
271
+ # Validates that a value is in RFC 3339 date-time format.
272
+ #
273
+ # @param field [String] The field name for error messages.
274
+ # @param value [String, nil] The value to validate.
275
+ #
276
+ # @raise [InvalidInputError] If the value is not in RFC 3339 format.
277
+ #
278
+ # @return [nil]
158
279
  def validate_rfc3339(field, value)
159
280
  return if !value
160
281
 
@@ -169,6 +290,14 @@ module Minfraud
169
290
  nil
170
291
  end
171
292
 
293
+ # Validates that a value is a boolean.
294
+ #
295
+ # @param field [String] The field name for error messages.
296
+ # @param value [Boolean, nil] The value to validate.
297
+ #
298
+ # @raise [InvalidInputError] If the value is not a boolean.
299
+ #
300
+ # @return [nil]
172
301
  def validate_boolean(field, value)
173
302
  return if !value
174
303
 
@@ -177,6 +306,14 @@ module Minfraud
177
306
  end
178
307
  end
179
308
 
309
+ # Validates that a value is a valid absolute URI.
310
+ #
311
+ # @param field [String] The field name for error messages.
312
+ # @param value [String, nil] The value to validate.
313
+ #
314
+ # @raise [InvalidInputError] If the value is not a valid absolute URI.
315
+ #
316
+ # @return [nil]
180
317
  def validate_uri(field, value)
181
318
  return if !value
182
319
 
@@ -195,6 +332,6 @@ module Minfraud
195
332
  end
196
333
  # rubocop:enable Style/RescueStandardError
197
334
  end
335
+ # rubocop:enable Metrics/ModuleLength
198
336
  end
199
337
  end
200
- # rubocop:enable Metrics/ModuleLength
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Minfraud
4
4
  # The Gem version.
5
- VERSION = '2.9.0'
5
+ VERSION = '2.10.0'
6
6
  end
metadata CHANGED
@@ -1,12 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minfraud
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.9.0
4
+ version: 2.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - kushnir.yb
8
8
  - William Storey
9
- bindir: exe
9
+ bindir: bin
10
10
  cert_chain: []
11
11
  date: 1980-01-02 00:00:00.000000000 Z
12
12
  dependencies:
@@ -14,16 +14,22 @@ dependencies:
14
14
  name: connection_pool
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '2.2'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '4.0'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "~>"
27
+ - - ">="
25
28
  - !ruby/object:Gem::Version
26
29
  version: '2.2'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '4.0'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: http
29
35
  requirement: !ruby/object:Gem::Requirement
@@ -33,7 +39,7 @@ dependencies:
33
39
  version: '4.3'
34
40
  - - "<"
35
41
  - !ruby/object:Gem::Version
36
- version: '6.0'
42
+ version: '7.0'
37
43
  type: :runtime
38
44
  prerelease: false
39
45
  version_requirements: !ruby/object:Gem::Requirement
@@ -43,21 +49,21 @@ dependencies:
43
49
  version: '4.3'
44
50
  - - "<"
45
51
  - !ruby/object:Gem::Version
46
- version: '6.0'
52
+ version: '7.0'
47
53
  - !ruby/object:Gem::Dependency
48
54
  name: maxmind-geoip2
49
55
  requirement: !ruby/object:Gem::Requirement
50
56
  requirements:
51
57
  - - "~>"
52
58
  - !ruby/object:Gem::Version
53
- version: '1.4'
59
+ version: '1.6'
54
60
  type: :runtime
55
61
  prerelease: false
56
62
  version_requirements: !ruby/object:Gem::Requirement
57
63
  requirements:
58
64
  - - "~>"
59
65
  - !ruby/object:Gem::Version
60
- version: '1.4'
66
+ version: '1.6'
61
67
  - !ruby/object:Gem::Dependency
62
68
  name: simpleidn
63
69
  requirement: !ruby/object:Gem::Requirement
@@ -210,18 +216,9 @@ executables: []
210
216
  extensions: []
211
217
  extra_rdoc_files: []
212
218
  files:
213
- - ".rspec"
214
- - ".rubocop.yml"
215
219
  - CHANGELOG.md
216
- - CLAUDE.md
217
- - CODE_OF_CONDUCT.md
218
- - Gemfile
219
220
  - LICENSE.txt
220
- - README.dev.md
221
221
  - README.md
222
- - Rakefile
223
- - bin/console
224
- - bin/setup
225
222
  - lib/minfraud.rb
226
223
  - lib/minfraud/assessments.rb
227
224
  - lib/minfraud/components/account.rb
@@ -271,12 +268,16 @@ files:
271
268
  - lib/minfraud/resolver.rb
272
269
  - lib/minfraud/validates.rb
273
270
  - lib/minfraud/version.rb
274
- - minfraud.gemspec
275
271
  homepage: https://github.com/maxmind/minfraud-api-ruby
276
272
  licenses:
277
273
  - MIT
278
274
  metadata:
275
+ bug_tracker_uri: https://github.com/maxmind/minfraud-api-ruby/issues
276
+ changelog_uri: https://github.com/maxmind/minfraud-api-ruby/blob/main/CHANGELOG.md
277
+ documentation_uri: https://www.rubydoc.info/gems/minfraud
278
+ homepage_uri: https://github.com/maxmind/minfraud-api-ruby
279
279
  rubygems_mfa_required: 'true'
280
+ source_code_uri: https://github.com/maxmind/minfraud-api-ruby
280
281
  rdoc_options: []
281
282
  require_paths:
282
283
  - lib
@@ -291,7 +292,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
291
292
  - !ruby/object:Gem::Version
292
293
  version: '0'
293
294
  requirements: []
294
- rubygems_version: 3.6.9
295
+ rubygems_version: 4.0.16
295
296
  specification_version: 4
296
297
  summary: Ruby API for the minFraud Score, Insights, Factors, and Report Transactions
297
298
  services
data/.rspec DELETED
@@ -1,2 +0,0 @@
1
- --format documentation
2
- --color
data/.rubocop.yml DELETED
@@ -1,113 +0,0 @@
1
- plugins:
2
- - rubocop-performance
3
- - rubocop-rake
4
- - rubocop-rspec
5
- - rubocop-thread_safety
6
-
7
- AllCops:
8
- TargetRubyVersion: '3.2'
9
- NewCops: enable
10
-
11
- # Metrics.
12
-
13
- Metrics/BlockLength:
14
- Enabled: false # Default is true, but mostly hit in tests.
15
-
16
- Metrics/AbcSize:
17
- Enabled: false # To allow for pre-existing code.
18
-
19
- Metrics/ClassLength:
20
- Enabled: false # To allow for pre-existing code.
21
-
22
- Metrics/CyclomaticComplexity:
23
- Enabled: false # To allow for pre-existing code.
24
-
25
- Metrics/MethodLength:
26
- Enabled: false # To allow for pre-existing code.
27
-
28
- Metrics/PerceivedComplexity:
29
- Enabled: false # To allow for pre-existing code.
30
-
31
- # Layout.
32
-
33
- Layout/LineLength:
34
- Max: 150 # Default is 120.
35
-
36
- Layout/HashAlignment:
37
- EnforcedHashRocketStyle: table # Default is key.
38
- EnforcedColonStyle: table # Default is key.
39
-
40
- Layout/ExtraSpacing:
41
- ForceEqualSignAlignment: true # Default is false.
42
-
43
- Layout/IndentationStyle:
44
- IndentationWidth: 2 # Default is <none>.
45
-
46
- # Style.
47
-
48
- Style/HashSyntax:
49
- EnforcedStyle: ruby19_no_mixed_keys # Default is ruby19. This one is better.
50
-
51
- Style/CollectionMethods:
52
- Enabled: true # Default is false.
53
-
54
- Style/NumericLiterals:
55
- MinDigits: 4 # Default is 5.
56
-
57
- Style/NegatedIf: # I disagree with this.
58
- Enabled: false
59
-
60
- Style/IfUnlessModifier: # This doesn't always make sense.
61
- Enabled: false
62
-
63
- # Trailing commas are often good.
64
- Style/TrailingCommaInArguments:
65
- Enabled: false
66
- Style/TrailingCommaInArrayLiteral:
67
- Enabled: false
68
- Style/TrailingCommaInHashLiteral:
69
- Enabled: false
70
-
71
- # Default is both which is probably fine, but it changes code and I don't want
72
- # to investigate any possible behavior change right now.
73
- Style/EmptyElse:
74
- EnforcedStyle: empty
75
-
76
- Style/ConditionalAssignment:
77
- Enabled: false # This produces kind of strange results.
78
-
79
- Style/GuardClause:
80
- Enabled: false # Doesn't always make sense.
81
-
82
- Style/FormatStringToken:
83
- Enabled: false # Seems unnecessary.
84
-
85
- # Seems unnecessary. Asks us to call super in a bunch of places when there's no
86
- # need.
87
- Lint/MissingSuper:
88
- Enabled: false
89
-
90
- # Naming.
91
-
92
- Naming/VariableNumber:
93
- Enabled: false # Doesn't always make sense.
94
-
95
- Gemspec/DevelopmentDependencies:
96
- Enabled: false
97
-
98
- # This might make sense, but I don't think it's worth moving things around for.
99
- RSpec/SpecFilePathFormat:
100
- Enabled: false
101
- # Sometimes it makes sense to have lots of assertions.
102
- RSpec/MultipleExpectations:
103
- Enabled: false
104
- # Sometimes it makes sense to have long tests.
105
- RSpec/ExampleLength:
106
- Enabled: false
107
- # This seems okay.
108
- RSpec/MultipleDescribes:
109
- Enabled: false
110
- # This seems to give a bunch of false positives. Specifically it's flagging
111
- # things where we are creating an object and checking no exception happens.
112
- RSpec/NoExpectationExample:
113
- Enabled: false