recaptcha 5.8.1 → 5.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 32dd1cf286b8d6ddaba6c76b8be43d674569755cf4c72bafeb5845d319c0eeb5
4
- data.tar.gz: ca3c44b7410612d984e56f765ab3fce23f29024649248b067bc7d463eb94a137
3
+ metadata.gz: b4e91df77500a77804749d34ac9690c4ddc9a8cfa30af5f2eae6b51c3d0a0e02
4
+ data.tar.gz: 2fa166f38a4e39ee6b2244bdfc91991b3bfc6d65360c6dd2e846d584352e3aab
5
5
  SHA512:
6
- metadata.gz: 4210c65501bbb30ef9debbb53db1d1c69541e16000f6221ba1c9d16d7b0e625767c6861b79f10346643e2ab1a2ab1a210a1a4d8742e68b6efa48945da1d6d436
7
- data.tar.gz: 19784f36a070d092249321947b4dfe236834347ce96247c5c6782fdd4209f8e2b478224e302b974db896622ab271f23572d8fff853925c6942807afabf0b9014
6
+ metadata.gz: acfb0b7bf9d211b2571dfcd8ee5a8195dc149effee4a04fe609d116f869722e583f4a5737e7d21174f2ff3d0f08c1f73f845dd4859daa107500e272230562052
7
+ data.tar.gz: 8c64efbfd826ab4a817fdbd37ef8e199d6a7c661b0efc18f6e4c5b26aca45a4412c8c0b331772561fe478d1f88c88b1a0cc655471c3eb751883a767a852680cf
data/CHANGELOG.md CHANGED
@@ -1,5 +1,6 @@
1
1
  ## Next
2
2
  * Gracefully handle invalid params
3
+ * allow configuring response limit
3
4
 
4
5
  ## 5.8.0
5
6
  * Add support for the enterprise API
data/README.md CHANGED
@@ -551,6 +551,28 @@ recaptcha_tags site_key: '6Lc6BAAAAAAAAChqRbQZcn_yyyyyyyyyyyyyyyyy'
551
551
  verify_recaptcha secret_key: '6Lc6BAAAAAAAAKN3DRm6VA_xxxxxxxxxxxxxxxxx'
552
552
  ```
553
553
 
554
+
555
+ ## hCaptcha support
556
+
557
+ [hCaptcha](https://hcaptcha.com) is an alternative service providing reCAPTCHA API.
558
+
559
+ To use hCaptcha:
560
+ 1. Set a site and a secret key as usual
561
+ 2. Set two options in `verify_url` and `api_service_url` pointing to hCaptcha API endpoints.
562
+ 3. Disable a response limit check by setting a `response_limit` to the negative or large enough value (reCAPTCHA is limited by 4000 characters).
563
+ 4. It is not required to change a parameter name as [official docs suggest](https://docs.hcaptcha.com/switch) because API handles standard `g-recaptcha` for compatibility.
564
+
565
+ ```ruby
566
+ # config/initializers/recaptcha.rb
567
+ Recaptcha.configure do |config|
568
+ config.site_key = '6Lc6BAAAAAAAAChqRbQZcn_yyyyyyyyyyyyyyyyy'
569
+ config.secret_key = '6Lc6BAAAAAAAAKN3DRm6VA_xxxxxxxxxxxxxxxxx'
570
+ config.verify_url = 'https://hcaptcha.com/siteverify'
571
+ config.api_server_url = 'https://hcaptcha.com/1/api.js'
572
+ config.response_limit = -1
573
+ end
574
+ ```
575
+
554
576
  ## Misc
555
577
  - Check out the [wiki](https://github.com/ambethia/recaptcha/wiki) and leave whatever you found valuable there.
556
578
  - [Add multiple widgets to the same page](https://github.com/ambethia/recaptcha/wiki/Add-multiple-widgets-to-the-same-page)
@@ -38,7 +38,7 @@ module Recaptcha
38
38
  }.freeze
39
39
 
40
40
  attr_accessor :default_env, :skip_verify_env, :proxy, :secret_key, :site_key, :handle_timeouts_gracefully, :hostname
41
- attr_accessor :enterprise, :enterprise_api_key, :enterprise_project_id
41
+ attr_accessor :enterprise, :enterprise_api_key, :enterprise_project_id, :response_limit
42
42
  attr_writer :api_server_url, :verify_url
43
43
 
44
44
  def initialize #:nodoc:
@@ -55,6 +55,8 @@ module Recaptcha
55
55
 
56
56
  @verify_url = nil
57
57
  @api_server_url = nil
58
+
59
+ @response_limit = 4000
58
60
  end
59
61
 
60
62
  def secret_key!
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Recaptcha
4
- VERSION = '5.8.1'
4
+ VERSION = '5.9.0'
5
5
  end
data/lib/recaptcha.rb CHANGED
@@ -14,7 +14,6 @@ end
14
14
 
15
15
  module Recaptcha
16
16
  DEFAULT_TIMEOUT = 3
17
- RESPONSE_LIMIT = 4000
18
17
 
19
18
  class RecaptchaError < StandardError
20
19
  end
@@ -56,7 +55,7 @@ module Recaptcha
56
55
  end
57
56
 
58
57
  def self.invalid_response?(resp)
59
- resp.empty? || resp.length > RESPONSE_LIMIT
58
+ resp.empty? || resp.length > configuration.response_limit
60
59
  end
61
60
 
62
61
  def self.verify_via_api_call(response, options)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: recaptcha
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.8.1
4
+ version: 5.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason L Perry
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-09 00:00:00.000000000 Z
11
+ date: 2022-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -176,7 +176,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
176
176
  - !ruby/object:Gem::Version
177
177
  version: '0'
178
178
  requirements: []
179
- rubygems_version: 3.2.16
179
+ rubygems_version: 3.1.6
180
180
  signing_key:
181
181
  specification_version: 4
182
182
  summary: Helpers for the reCAPTCHA API