recaptcha 5.5.0 → 5.8.1

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: ba681f9321310ca16bb41dc622bf7051c30df10ec000582f9dd8d29310e21136
4
- data.tar.gz: 8d9a3a4a7adb2ea830f17ace469e6b475d4d5c633c6988cd04dd56a7fd70e414
3
+ metadata.gz: 32dd1cf286b8d6ddaba6c76b8be43d674569755cf4c72bafeb5845d319c0eeb5
4
+ data.tar.gz: ca3c44b7410612d984e56f765ab3fce23f29024649248b067bc7d463eb94a137
5
5
  SHA512:
6
- metadata.gz: efba5551493debe23617c41db429c224f51a4d0253274cf6fe28c5e384d78f4bd374ba3ad3132c2009cb2df9813266ac3a90eabd9a019aa7d48ee3999f2451e3
7
- data.tar.gz: 1dfd4f2281c8f6902b1c70ca0d272d0d2f671d9062669f147cfb38416ee771e7348ff131c8fd957c1e8674b7d83ad3f3c79f6c306a7779638b4481000534f695
6
+ metadata.gz: 4210c65501bbb30ef9debbb53db1d1c69541e16000f6221ba1c9d16d7b0e625767c6861b79f10346643e2ab1a2ab1a210a1a4d8742e68b6efa48945da1d6d436
7
+ data.tar.gz: 19784f36a070d092249321947b4dfe236834347ce96247c5c6782fdd4209f8e2b478224e302b974db896622ab271f23572d8fff853925c6942807afabf0b9014
data/CHANGELOG.md CHANGED
@@ -1,4 +1,24 @@
1
1
  ## Next
2
+ * Gracefully handle invalid params
3
+
4
+ ## 5.8.0
5
+ * Add support for the enterprise API
6
+
7
+ ## 5.7.0
8
+ * french locale
9
+ * drop ruby 2.3
10
+
11
+ ## 5.6.0
12
+ * Allow multiple invisible recaptchas on a single page by setting custom selector
13
+
14
+ ## 5.5.0
15
+ * add `recaptcha_reply` controller method for better debugging/inspection
16
+
17
+ ## 5.4.1
18
+ * fix v2 vs 'data' postfix
19
+
20
+ ## 5.4.0
21
+ * added 'data' postfix to g-recaptcha-response attribute name to avoid collisions
2
22
 
3
23
  ## 5.3.0
4
24
  * turbolinks support
data/README.md CHANGED
@@ -1,3 +1,4 @@
1
+
1
2
  # reCAPTCHA
2
3
  [![Gem Version](https://badge.fury.io/rb/recaptcha.svg)](https://badge.fury.io/rb/recaptcha)
3
4
 
@@ -12,6 +13,23 @@ views you can use the `recaptcha_tags` method to embed the needed javascript, an
12
13
  in your controllers with `verify_recaptcha` or `verify_recaptcha!`, which raises an error on
13
14
  failure.
14
15
 
16
+
17
+ # Table of Contents
18
+ 1. [Obtaining a key](#obtaining-a-key)
19
+ 2. [Rails Installation](#rails-installation)
20
+ 3. [Sinatra / Rack / Ruby Installation](#sinatra--rack--ruby-installation)
21
+ 4. [reCAPTCHA V2 API & Usage](#recaptcha-v2-api-and-usage)
22
+ - [`recaptcha_tags`](#recaptcha_tags)
23
+ - [`verify_recaptcha`](#verify_recaptcha)
24
+ - [`invisible_recaptcha_tags`](#invisible_recaptcha_tags)
25
+ 5. [reCAPTCHA V3 API & Usage](#recaptcha-v3-api-and-usage)
26
+ - [`recaptcha_v3`](#recaptcha_v3)
27
+ - [`verify_recaptcha` (use with v3)](#verify_recaptcha-use-with-v3)
28
+ - [`recaptcha_reply`](#recaptcha_reply)
29
+ 6. [I18n Support](#i18n-support)
30
+ 7. [Testing](#testing)
31
+ 8. [Alternative API Key Setup](#alternative-api-key-setup)
32
+
15
33
  ## Obtaining a key
16
34
 
17
35
  Go to the [reCAPTCHA admin console](https://www.google.com/recaptcha/admin) to obtain a reCAPTCHA API key.
@@ -50,6 +68,14 @@ export RECAPTCHA_SITE_KEY = '6Lc6BAAAAAAAAChqRbQZcn_yyyyyyyyyyyyyyyyy'
50
68
  export RECAPTCHA_SECRET_KEY = '6Lc6BAAAAAAAAKN3DRm6VA_xxxxxxxxxxxxxxxxx'
51
69
  ```
52
70
 
71
+ If you have an Enterprise API key:
72
+
73
+ ```shell
74
+ export RECAPTCHA_ENTERPRISE = 'true'
75
+ export RECAPTCHA_ENTERPRISE_API_KEY = 'AIzvFyE3TU-g4K_Kozr9F1smEzZSGBVOfLKyupA'
76
+ export RECAPTCHA_ENTERPRISE_PROJECT_ID = 'my-project'
77
+ ```
78
+
53
79
  Add `recaptcha_tags` to the forms you want to protect:
54
80
 
55
81
  ```erb
@@ -71,6 +97,7 @@ else
71
97
  render 'new'
72
98
  end
73
99
  ```
100
+ Please note that this setup uses [`reCAPTCHA_v2`](#recaptcha-v2-api-and-usage). For a `recaptcha_v3` use, please refer to [`reCAPTCHA_v3 setup`](#examples).
74
101
 
75
102
  ## Sinatra / Rack / Ruby installation
76
103
 
@@ -119,7 +146,7 @@ The following options are available:
119
146
  Any unrecognized options will be added as attributes on the generated tag.
120
147
 
121
148
  You can also override the html attributes for the sizes of the generated `textarea` and `iframe`
122
- elements, if CSS isn't your thing. Inspect the [source of `recaptcha_tags`](https://github.com/ambethia/recaptcha/blob/master/lib/recaptcha/client_helper.rb)
149
+ elements, if CSS isn't your thing. Inspect the [source of `recaptcha_tags`](https://github.com/ambethia/recaptcha/blob/master/lib/recaptcha/helpers.rb)
123
150
  to see these options.
124
151
 
125
152
  Note that you cannot submit/verify the same response token more than once or you will get a
@@ -140,16 +167,18 @@ you like.
140
167
 
141
168
  Some of the options available:
142
169
 
143
- | Option | Description |
144
- |----------------|-------------|
145
- | `:model` | Model to set errors.
146
- | `:attribute` | Model attribute to receive errors. (default: `:base`)
147
- | `:message` | Custom error message.
148
- | `:secret_key` | Override the secret API key from the configuration.
149
- | `:timeout` | The number of seconds to wait for reCAPTCHA servers before give up. (default: `3`)
150
- | `:response` | Custom response parameter. (default: `params['g-recaptcha-response-data']`)
151
- | `: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`)
152
- | `:env` | Current environment. The request to verify will be skipped if the environment is specified in configuration under `skip_verify_env`
170
+ | Option | Description |
171
+ |---------------------------|-------------|
172
+ | `:model` | Model to set errors.
173
+ | `:attribute` | Model attribute to receive errors. (default: `:base`)
174
+ | `:message` | Custom error message.
175
+ | `:secret_key` | Override the secret API key from the configuration.
176
+ | `:enterprise_api_key` | Override the Enterprise API key from the configuration.
177
+ | `:enterprise_project_id ` | Override the Enterprise project ID from the configuration.
178
+ | `:timeout` | The number of seconds to wait for reCAPTCHA servers before give up. (default: `3`)
179
+ | `:response` | Custom response parameter. (default: `params['g-recaptcha-response-data']`)
180
+ | `: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`)
181
+ | `:env` | Current environment. The request to verify will be skipped if the environment is specified in configuration under `skip_verify_env`
153
182
 
154
183
 
155
184
  ### `invisible_recaptcha_tags`
@@ -278,7 +307,7 @@ threshold:
278
307
  <% if @show_checkbox_recaptcha %>
279
308
  <%= recaptcha_tags %>
280
309
  <% else %>
281
- <%= recaptcha_v3(action: 'login') %>
310
+ <%= recaptcha_v3(action: 'login', site_key: ENV['RECAPTCHA_SITE_KEY_V3']) %>
282
311
  <% end %>
283
312
 
284
313
  ```
@@ -286,7 +315,7 @@ threshold:
286
315
  ```ruby
287
316
  # app/controllers/sessions_controller.rb
288
317
  def create
289
- success = verify_recaptcha(action: 'login', minimum_score: 0.5)
318
+ success = verify_recaptcha(action: 'login', minimum_score: 0.5, secret_key: ENV['RECAPTCHA_SECRET_KEY_V3'])
290
319
  checkbox_success = verify_recaptcha unless success
291
320
  if success || checkbox_success
292
321
  # Perform action
@@ -357,17 +386,19 @@ then you can either:
357
386
  2. write and specify a custom `callback` function. You may also want to pass `element: false` if you
358
387
  don't have a use for the hidden input element.
359
388
 
360
- Note that you cannot submit/verify the same response token more than once or you will get a
361
- `timeout-or-duplicate` error code. If you need reset the captcha and generate a new response token,
362
- then you need to call `grecaptcha.execute(…)` again. This helper provides a JavaScript method (for
363
- each action) named `executeRecaptchaFor{action}` to make this easier. That is the same method that
364
- is invoked immediately. It simply calls `grecaptcha.execute` again and then calls the `callback`
365
- function with the response token.
389
+ Note that you cannot submit/verify the same response token more than once or you
390
+ will get a `timeout-or-duplicate` error code. If you need reset the captcha and
391
+ generate a new response token, then you need to call `grecaptcha.execute(…)` or
392
+ `grecaptcha.enterprise.execute(…)` again. This helper provides a JavaScript
393
+ method (for each action) named `executeRecaptchaFor{action}` to make this
394
+ easier. That is the same method that is invoked immediately. It simply calls
395
+ `grecaptcha.execute` or `grecaptcha.enterprise.execute` again and then calls the
396
+ `callback` function with the response token.
366
397
 
367
398
  You will also get a `timeout-or-duplicate` error if too much time has passed between getting the
368
399
  response token and verifying it. This can easily happen with large forms that take the user a couple
369
400
  minutes to complete. Unlike v2, where you can use the `expired-callback` to be notified when the
370
- response expries, v3 appears to provide no such callback. See also
401
+ response expires, v3 appears to provide no such callback. See also
371
402
  [1](https://github.com/google/recaptcha/issues/281) and
372
403
  [2](https://stackoverflow.com/questions/54437745/recaptcha-v3-how-to-deal-with-expired-token-after-idle).
373
404
 
@@ -427,7 +458,7 @@ According to https://developers.google.com/recaptcha/docs/v3#placement,
427
458
 
428
459
  > Note: You can execute reCAPTCHA as many times as you'd like with different actions on the same page.
429
460
 
430
- You will need to verify each action individually with separate call to `verify_recaptcha`.
461
+ You will need to verify each action individually with a separate call to `verify_recaptcha`.
431
462
 
432
463
  ```ruby
433
464
  result_a = verify_recaptcha(action: 'a')
@@ -487,14 +518,20 @@ Recaptcha.configuration.skip_verify_env.delete("test")
487
518
  Recaptcha.configure do |config|
488
519
  config.site_key = '6Lc6BAAAAAAAAChqRbQZcn_yyyyyyyyyyyyyyyyy'
489
520
  config.secret_key = '6Lc6BAAAAAAAAKN3DRm6VA_xxxxxxxxxxxxxxxxx'
521
+
490
522
  # Uncomment the following line if you are using a proxy server:
491
523
  # config.proxy = 'http://myproxy.com.au:8080'
524
+
525
+ # Uncomment the following lines if you are using the Enterprise API:
526
+ # config.enterprise = true
527
+ # config.enterprise_api_key = 'AIzvFyE3TU-g4K_Kozr9F1smEzZSGBVOfLKyupA'
528
+ # config.enterprise_project_id = 'my-project'
492
529
  end
493
530
  ```
494
531
 
495
532
  ### Recaptcha.with_configuration
496
533
 
497
- For temporary overwrites (not thread safe).
534
+ For temporary overwrites (not thread-safe).
498
535
 
499
536
  ```ruby
500
537
  Recaptcha.with_configuration(site_key: '12345') do
@@ -83,10 +83,12 @@ module Recaptcha
83
83
  # @return [String] A response token if one was passed in the params; otherwise, `''`
84
84
  def recaptcha_response_token(action = nil)
85
85
  response_param = params['g-recaptcha-response-data'] || params['g-recaptcha-response']
86
- if response_param&.respond_to?(:to_h) # Includes ActionController::Parameters
87
- response_param[action].to_s
86
+ response_param = response_param[action] if action && response_param.respond_to?(:key?)
87
+
88
+ if response_param.is_a?(String)
89
+ response_param
88
90
  else
89
- response_param.to_s
91
+ ''
90
92
  end
91
93
  end
92
94
  end
@@ -31,11 +31,14 @@ module Recaptcha
31
31
  #
32
32
  class Configuration
33
33
  DEFAULTS = {
34
- 'server_url' => 'https://www.recaptcha.net/recaptcha/api.js',
35
- 'verify_url' => 'https://www.recaptcha.net/recaptcha/api/siteverify'
34
+ 'free_server_url' => 'https://www.recaptcha.net/recaptcha/api.js',
35
+ 'enterprise_server_url' => 'https://www.recaptcha.net/recaptcha/enterprise.js',
36
+ 'free_verify_url' => 'https://www.recaptcha.net/recaptcha/api/siteverify',
37
+ 'enterprise_verify_url' => 'https://recaptchaenterprise.googleapis.com/v1beta1/projects'
36
38
  }.freeze
37
39
 
38
- attr_accessor :default_env, :skip_verify_env, :secret_key, :site_key, :proxy, :handle_timeouts_gracefully, :hostname
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
39
42
  attr_writer :api_server_url, :verify_url
40
43
 
41
44
  def initialize #:nodoc:
@@ -45,6 +48,11 @@ module Recaptcha
45
48
 
46
49
  @secret_key = ENV['RECAPTCHA_SECRET_KEY']
47
50
  @site_key = ENV['RECAPTCHA_SITE_KEY']
51
+
52
+ @enterprise = ENV['RECAPTCHA_ENTERPRISE'] == 'true'
53
+ @enterprise_api_key = ENV['RECAPTCHA_ENTERPRISE_API_KEY']
54
+ @enterprise_project_id = ENV['RECAPTCHA_ENTERPRISE_PROJECT_ID']
55
+
48
56
  @verify_url = nil
49
57
  @api_server_url = nil
50
58
  end
@@ -57,12 +65,20 @@ module Recaptcha
57
65
  site_key || raise(RecaptchaError, "No site key specified.")
58
66
  end
59
67
 
68
+ def enterprise_api_key!
69
+ enterprise_api_key || raise(RecaptchaError, "No Enterprise API key specified.")
70
+ end
71
+
72
+ def enterprise_project_id!
73
+ enterprise_project_id || raise(RecaptchaError, "No Enterprise project ID specified.")
74
+ end
75
+
60
76
  def api_server_url
61
- @api_server_url || DEFAULTS.fetch('server_url')
77
+ @api_server_url || (enterprise ? DEFAULTS.fetch('enterprise_server_url') : DEFAULTS.fetch('free_server_url'))
62
78
  end
63
79
 
64
80
  def verify_url
65
- @verify_url || DEFAULTS.fetch('verify_url')
81
+ @verify_url || (enterprise ? DEFAULTS.fetch('enterprise_verify_url') : DEFAULTS.fetch('free_verify_url'))
66
82
  end
67
83
  end
68
84
  end
@@ -174,7 +174,8 @@ module Recaptcha
174
174
 
175
175
  # v3
176
176
 
177
- # Renders a script that calls `grecaptcha.execute` for the given `site_key` and `action` and
177
+ # Renders a script that calls `grecaptcha.execute` or
178
+ # `grecaptcha.enterprise.execute` for the given `site_key` and `action` and
178
179
  # calls the `callback` with the resulting response token.
179
180
  private_class_method def self.recaptcha_v3_inline_script(site_key, action, callback, id, options = {})
180
181
  nonce = options[:nonce]
@@ -185,8 +186,8 @@ module Recaptcha
185
186
  // Define function so that we can call it again later if we need to reset it
186
187
  // This executes reCAPTCHA and then calls our callback.
187
188
  function #{recaptcha_v3_execute_function_name(action)}() {
188
- grecaptcha.ready(function() {
189
- grecaptcha.execute('#{site_key}', {action: '#{action}'}).then(function(token) {
189
+ #{recaptcha_ready_method_name}(function() {
190
+ #{recaptcha_execute_method_name}('#{site_key}', {action: '#{action}'}).then(function(token) {
190
191
  #{callback}('#{id}', token)
191
192
  });
192
193
  });
@@ -199,8 +200,8 @@ module Recaptcha
199
200
  // Returns a Promise that resolves with the response token.
200
201
  async function #{recaptcha_v3_async_execute_function_name(action)}() {
201
202
  return new Promise((resolve, reject) => {
202
- grecaptcha.ready(async function() {
203
- resolve(await grecaptcha.execute('#{site_key}', {action: '#{action}'}))
203
+ #{recaptcha_ready_method_name}(async function() {
204
+ resolve(await #{recaptcha_execute_method_name}('#{site_key}', {action: '#{action}'}))
204
205
  });
205
206
  })
206
207
  };
@@ -217,8 +218,8 @@ module Recaptcha
217
218
  <<-HTML
218
219
  <script#{nonce_attr}>
219
220
  function #{recaptcha_v3_execute_function_name(action)}() {
220
- grecaptcha.ready(function() {
221
- grecaptcha.execute('#{site_key}', {action: '#{action}'}).then(function(token) {
221
+ #{recaptcha_ready_method_name}(function() {
222
+ #{recaptcha_execute_method_name}('#{site_key}', {action: '#{action}'}).then(function(token) {
222
223
  #{callback}('#{id}', token)
223
224
  });
224
225
  });
@@ -251,8 +252,9 @@ module Recaptcha
251
252
  recaptcha_v3_inline_script?(options)
252
253
  end
253
254
 
254
- # Returns the name of the JavaScript function that actually executes the reCAPTCHA code (calls
255
- # grecaptcha.execute). You can call it again later to reset it.
255
+ # Returns the name of the JavaScript function that actually executes the
256
+ # reCAPTCHA code (calls `grecaptcha.execute` or
257
+ # `grecaptcha.enterprise.execute`). You can call it again later to reset it.
256
258
  def self.recaptcha_v3_execute_function_name(action)
257
259
  "executeRecaptchaFor#{sanitize_action_for_js(action)}"
258
260
  end
@@ -271,6 +273,7 @@ module Recaptcha
271
273
  private_class_method def self.default_callback(options = {})
272
274
  nonce = options[:nonce]
273
275
  nonce_attr = " nonce='#{nonce}'" if nonce
276
+ selector_attr = options[:id] ? "##{options[:id]}" : ".g-recaptcha"
274
277
 
275
278
  <<-HTML
276
279
  <script#{nonce_attr}>
@@ -283,9 +286,9 @@ module Recaptcha
283
286
  return curEle.nodeName === 'FORM' ? curEle : null
284
287
  };
285
288
 
286
- var eles = document.getElementsByClassName('g-recaptcha');
287
- if (eles.length > 0) {
288
- var form = closestForm(eles[0]);
289
+ var el = document.querySelector("#{selector_attr}")
290
+ if (!!el) {
291
+ var form = closestForm(el);
289
292
  if (form) {
290
293
  form.submit();
291
294
  }
@@ -295,6 +298,14 @@ module Recaptcha
295
298
  HTML
296
299
  end
297
300
 
301
+ def self.recaptcha_execute_method_name
302
+ Recaptcha.configuration.enterprise ? "grecaptcha.enterprise.execute" : "grecaptcha.execute"
303
+ end
304
+
305
+ def self.recaptcha_ready_method_name
306
+ Recaptcha.configuration.enterprise ? "grecaptcha.enterprise.ready" : "grecaptcha.ready"
307
+ end
308
+
298
309
  private_class_method def self.default_callback_required?(options)
299
310
  options[:callback] == 'invisibleRecaptchaSubmit' &&
300
311
  !Recaptcha.skip_env?(options[:env]) &&
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Recaptcha
4
- VERSION = '5.5.0'
4
+ VERSION = '5.8.1'
5
5
  end
data/lib/recaptcha.rb CHANGED
@@ -60,11 +60,44 @@ module Recaptcha
60
60
  end
61
61
 
62
62
  def self.verify_via_api_call(response, options)
63
+ if Recaptcha.configuration.enterprise
64
+ verify_via_api_call_enterprise(response, options)
65
+ else
66
+ verify_via_api_call_free(response, options)
67
+ end
68
+ end
69
+
70
+ def self.verify_via_api_call_enterprise(response, options)
71
+ site_key = options.fetch(:site_key) { configuration.site_key! }
72
+ api_key = options.fetch(:enterprise_api_key) { configuration.enterprise_api_key! }
73
+ project_id = options.fetch(:enterprise_project_id) { configuration.enterprise_project_id! }
74
+
75
+ query_params = { 'key' => api_key }
76
+ body = { 'event' => { 'token' => response, 'siteKey' => site_key } }
77
+ body['event']['expectedAction'] = options[:action] if options.key?(:action)
78
+ body['event']['userIpAddress'] = options[:remote_ip] if options.key?(:remote_ip)
79
+
80
+ reply = api_verification_enterprise(query_params, body, project_id, timeout: options[:timeout])
81
+ token_properties = reply['tokenProperties']
82
+ success = !token_properties.nil? &&
83
+ token_properties['valid'].to_s == 'true' &&
84
+ hostname_valid?(token_properties['hostname'], options[:hostname]) &&
85
+ action_valid?(token_properties['action'], options[:action]) &&
86
+ score_above_threshold?(reply['score'], options[:minimum_score])
87
+
88
+ if options[:with_reply] == true
89
+ return success, reply
90
+ else
91
+ return success
92
+ end
93
+ end
94
+
95
+ def self.verify_via_api_call_free(response, options)
63
96
  secret_key = options.fetch(:secret_key) { configuration.secret_key! }
64
97
  verify_hash = { 'secret' => secret_key, 'response' => response }
65
98
  verify_hash['remoteip'] = options[:remote_ip] if options.key?(:remote_ip)
66
99
 
67
- reply = api_verification(verify_hash, timeout: options[:timeout])
100
+ reply = api_verification_free(verify_hash, timeout: options[:timeout])
68
101
  success = reply['success'].to_s == 'true' &&
69
102
  hostname_valid?(reply['hostname'], options[:hostname]) &&
70
103
  action_valid?(reply['action'], options[:action]) &&
@@ -105,7 +138,7 @@ module Recaptcha
105
138
  end
106
139
  end
107
140
 
108
- def self.api_verification(verify_hash, timeout: nil)
141
+ def self.http_client_for(uri:, timeout: nil)
109
142
  timeout ||= DEFAULT_TIMEOUT
110
143
  http = if configuration.proxy
111
144
  proxy_server = URI.parse(configuration.proxy)
@@ -113,12 +146,28 @@ module Recaptcha
113
146
  else
114
147
  Net::HTTP
115
148
  end
149
+ instance = http.new(uri.host, uri.port)
150
+ instance.read_timeout = instance.open_timeout = timeout
151
+ instance.use_ssl = true if uri.port == 443
152
+
153
+ instance
154
+ end
155
+
156
+ def self.api_verification_free(verify_hash, timeout: nil)
116
157
  query = URI.encode_www_form(verify_hash)
117
158
  uri = URI.parse(configuration.verify_url + '?' + query)
118
- http_instance = http.new(uri.host, uri.port)
119
- http_instance.read_timeout = http_instance.open_timeout = timeout
120
- http_instance.use_ssl = true if uri.port == 443
159
+ http_instance = http_client_for(uri: uri, timeout: timeout)
121
160
  request = Net::HTTP::Get.new(uri.request_uri)
122
161
  JSON.parse(http_instance.request(request).body)
123
162
  end
163
+
164
+ def self.api_verification_enterprise(query_params, body, project_id, timeout: nil)
165
+ query = URI.encode_www_form(query_params)
166
+ uri = URI.parse(configuration.verify_url + "/#{project_id}/assessments" + '?' + query)
167
+ http_instance = http_client_for(uri: uri, timeout: timeout)
168
+ request = Net::HTTP::Post.new(uri.request_uri)
169
+ request['Content-Type'] = 'application/json; charset=utf-8'
170
+ request.body = JSON.generate(body)
171
+ JSON.parse(http_instance.request(request).body)
172
+ end
124
173
  end
@@ -0,0 +1,5 @@
1
+ fr:
2
+ recaptcha:
3
+ errors:
4
+ verification_failed: La vérification reCAPTCHA a échoué, veuillez essayer à nouveau.
5
+ recaptcha_unreachable: Oops, nous n'avons pas pu valider votre réponse reCAPTCHA. Veuillez essayer à nouveau.
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.5.0
4
+ version: 5.8.1
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: 2020-03-31 00:00:00.000000000 Z
11
+ date: 2021-07-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -155,6 +155,7 @@ files:
155
155
  - lib/recaptcha/railtie.rb
156
156
  - lib/recaptcha/version.rb
157
157
  - rails/locales/en.yml
158
+ - rails/locales/fr.yml
158
159
  homepage: http://github.com/ambethia/recaptcha
159
160
  licenses:
160
161
  - MIT
@@ -168,14 +169,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
168
169
  requirements:
169
170
  - - ">="
170
171
  - !ruby/object:Gem::Version
171
- version: 2.3.0
172
+ version: 2.4.0
172
173
  required_rubygems_version: !ruby/object:Gem::Requirement
173
174
  requirements:
174
175
  - - ">="
175
176
  - !ruby/object:Gem::Version
176
177
  version: '0'
177
178
  requirements: []
178
- rubygems_version: 3.0.3
179
+ rubygems_version: 3.2.16
179
180
  signing_key:
180
181
  specification_version: 4
181
182
  summary: Helpers for the reCAPTCHA API