recaptcha 5.14.0 → 5.15.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a3e8441f1c05e97da5513f6b1b42ab0ee020d50b2d06196e4f83100251157c7b
4
- data.tar.gz: c911c40cfe25f413bf9d7ae6a10cce7170856fc45975b455872397c8827db3f6
3
+ metadata.gz: addd45d783c834ffbc2253f3b7df793762ffb839617315d6cfd17e7d5abec519
4
+ data.tar.gz: 1795b9d183326d23f408b5dd2b595531ff504885797012aa51953c6efc73a29d
5
5
  SHA512:
6
- metadata.gz: bbf6a050959ee4b95693bc336a4ce6f1bad590aefd62ec6f2a3e70f65affc22a44b04902cee5e695a7ea4922b0558e1a63c36b6a430f16094cba416f1d1a7e9f
7
- data.tar.gz: 928673a8221ffe3bcce8d577dce30a405f3b1bdad4cdfc80c15f64044390149134ce4b8d48e8ce18cc28b42c4945dba2641b0982fef009d22e64e79fb117cd66
6
+ metadata.gz: ddccc592d5d0ecdf7bae96d6a68ea29085dcdbfad9b346ae761a50d8b5b4c9f5337946e4e4374af4a1f74a2d8efd1e90e7a517f933f89f71a0cf3a1add44e701
7
+ data.tar.gz: 9b3fc098f10c2a53798adaebca95b60a0e54b6188275dd388afd3fb160ff881caf7724e57c9063478c08d7b8e3f268e952aefc413bf2e3e2ab4bdf7c13a4b0a4
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## Next
2
2
 
3
+ ## 5.15.0
4
+ * Add 3.2 to the list of Ruby CI versions
5
+ * Add ability to submit verify_recaptcha via POST with JSON Body with `options[:json] = true`
6
+
3
7
  ## 5.14.0
4
8
  * drop json dependency
5
9
 
data/README.md CHANGED
@@ -181,6 +181,7 @@ Some of the options available:
181
181
  | `:response` | Custom response parameter. (default: `params['g-recaptcha-response-data']`)
182
182
  | `:hostname` | Expected hostname or a callable that validates the hostname, see [domain validation](https://developers.google.com/recaptcha/docs/domain_validation) and [hostname](https://developers.google.com/recaptcha/docs/verify#api-response) docs. (default: `nil`, but can be changed by setting `config.hostname`)
183
183
  | `:env` | Current environment. The request to verify will be skipped if the environment is specified in configuration under `skip_verify_env`
184
+ | `:json` | Boolean; defaults to false; if true, will submit the verification request by POST with the request data in JSON
184
185
 
185
186
 
186
187
  ### `invisible_recaptcha_tags`
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Recaptcha
4
- VERSION = '5.14.0'
4
+ VERSION = '5.15.0'
5
5
  end
data/lib/recaptcha.rb CHANGED
@@ -98,7 +98,7 @@ module Recaptcha
98
98
  verify_hash = { 'secret' => secret_key, 'response' => response }
99
99
  verify_hash['remoteip'] = options[:remote_ip] if options.key?(:remote_ip)
100
100
 
101
- reply = api_verification_free(verify_hash, timeout: options[:timeout])
101
+ reply = api_verification_free(verify_hash, timeout: options[:timeout], json: options[:json])
102
102
  success = reply['success'].to_s == 'true' &&
103
103
  hostname_valid?(reply['hostname'], options[:hostname]) &&
104
104
  action_valid?(reply['action'], options[:action]) &&
@@ -152,11 +152,18 @@ module Recaptcha
152
152
  instance
153
153
  end
154
154
 
155
- def self.api_verification_free(verify_hash, timeout: nil)
156
- query = URI.encode_www_form(verify_hash)
157
- uri = URI.parse("#{configuration.verify_url}?#{query}")
155
+ def self.api_verification_free(verify_hash, timeout: nil, json: false)
156
+ if json
157
+ uri = URI.parse(configuration.verify_url)
158
+ request = Net::HTTP::Post.new(uri.request_uri)
159
+ request['Content-Type'] = 'application/json; charset=utf-8'
160
+ request.body = JSON.generate(verify_hash)
161
+ else
162
+ query = URI.encode_www_form(verify_hash)
163
+ uri = URI.parse("#{configuration.verify_url}?#{query}")
164
+ request = Net::HTTP::Get.new(uri.request_uri)
165
+ end
158
166
  http_instance = http_client_for(uri: uri, timeout: timeout)
159
- request = Net::HTTP::Get.new(uri.request_uri)
160
167
  JSON.parse(http_instance.request(request).body)
161
168
  end
162
169
 
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.14.0
4
+ version: 5.15.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: 2023-04-19 00:00:00.000000000 Z
11
+ date: 2023-08-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mocha