recaptcha 5.12.3 → 5.13.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: 4052ca42cf536d84329b553a058de58f2c3579e0ac2ad1e08ba42fed8ce974b4
4
- data.tar.gz: 90c873c15d0772690ca3da6cf2588669a05c159e4fbaa1d6bdf5d809ad05dfd0
3
+ metadata.gz: 413f379aca4968847b291687d0c36e7ef432f7d6ebdce5b87c164afe45291b83
4
+ data.tar.gz: e277f54b020495ffe3a431e51ff3d8ed6080d01bc7a93a291f60894e888bc102
5
5
  SHA512:
6
- metadata.gz: 403d9de96d890bb3f75cfb83c5907f01944d8e88233248ec199fe014e04f7f1386c13cd867c9020a232cd5501faada986f6d3413d3a2369e5d38d9c56a0704b9
7
- data.tar.gz: ce0d965054455acff094e60ccad808fbf836992666f9bd1233684b172e766440ba922a0f8d030803575b3a538945e3273d0ae237ce2527f9e0983b7b76671328
6
+ metadata.gz: bcf166047a4de7972b3040301fb51f7b8b0a17b5c7f46ba9cef127c3418538635ffe707ac208b091254da5501538134285870f01ff880555e21cc7ff2ab39bf8
7
+ data.tar.gz: 9e8ad8cd049c352a48810b19c1611ac82f62d196a91af17f2baa8f568e9a77bc0d7aac3662cd52174cccca371afceae076bdb6d4f17072be90cf51268d714100
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  ## Next
2
2
 
3
+ ## 5.13.0
4
+ * Added option to ignore_no_element.
5
+
3
6
  ## 5.12.3
4
7
  * Remove score fallback for enterprise
5
8
  * Update enterprise tests to v1 assessment schema
data/README.md CHANGED
@@ -427,6 +427,7 @@ but only accepts the following options:
427
427
  | `:inline_script` | If `true`, adds an inline script tag that calls `grecaptcha.execute` for the given `site_key` and `action` and calls the `callback` with the resulting response token. Pass `false` if you want to handle calling `grecaptcha.execute` yourself. (default: `true`) |
428
428
  | `:element` | The element to render, if any (default: `:input`)<br/>`:input`: Renders a hidden `<input type="hidden">` tag. The value of this will be set to the response token by the default `setInputWithRecaptchaResponseTokenFor{action}` callback.<br/>`false`: Doesn't render any tag. You'll have to add a custom callback that does something with the token. |
429
429
  | `:turbolinks` | If `true`, calls the js function which executes reCAPTCHA after all the dependencies have been loaded. This cannot be used with the js param `:onload`. This makes reCAPTCHAv3 usable with turbolinks. |
430
+ | `:ignore_no_element` | If `true`, adds null element checker for forms that can be removed from the page by javascript like modals with forms. (default: true) |
430
431
 
431
432
  [JavaScript resource (api.js) parameters](https://developers.google.com/recaptcha/docs/invisible#js_param):
432
433
 
@@ -16,6 +16,7 @@ module Recaptcha
16
16
  options[:render] = site_key
17
17
  options[:script_async] ||= false
18
18
  options[:script_defer] ||= false
19
+ options[:ignore_no_element] = options.key?(:ignore_no_element) ? options[:ignore_no_element] : true
19
20
  element = options.delete(:element)
20
21
  element = element == false ? false : :input
21
22
  if element == :input
@@ -138,6 +139,7 @@ module Recaptcha
138
139
  nonce = options.delete(:nonce)
139
140
  skip_script = (options.delete(:script) == false) || (options.delete(:external_script) == false)
140
141
  ui = options.delete(:ui)
142
+ options.delete(:ignore_no_element)
141
143
 
142
144
  data_attribute_keys = [:badge, :theme, :type, :callback, :expired_callback, :error_callback, :size]
143
145
  data_attribute_keys << :tabindex unless ui == :button
@@ -206,7 +208,7 @@ module Recaptcha
206
208
  })
207
209
  };
208
210
 
209
- #{recaptcha_v3_define_default_callback(callback) if recaptcha_v3_define_default_callback?(callback, action, options)}
211
+ #{recaptcha_v3_define_default_callback(callback, options) if recaptcha_v3_define_default_callback?(callback, action, options)}
210
212
  </script>
211
213
  HTML
212
214
  end
@@ -224,7 +226,7 @@ module Recaptcha
224
226
  });
225
227
  });
226
228
  };
227
- #{recaptcha_v3_define_default_callback(callback) if recaptcha_v3_define_default_callback?(callback, action, options)}
229
+ #{recaptcha_v3_define_default_callback(callback, options) if recaptcha_v3_define_default_callback?(callback, action, options)}
228
230
  </script>
229
231
  HTML
230
232
  end
@@ -235,12 +237,12 @@ module Recaptcha
235
237
  options[:inline_script] != false
236
238
  end
237
239
 
238
- private_class_method def self.recaptcha_v3_define_default_callback(callback)
240
+ private_class_method def self.recaptcha_v3_define_default_callback(callback, options)
239
241
  <<-HTML
240
- var #{callback} = function(id, token) {
241
- var element = document.getElementById(id);
242
- element.value = token;
243
- }
242
+ var #{callback} = function(id, token) {
243
+ var element = document.getElementById(id);
244
+ #{element_check_condition(options)} element.value = token;
245
+ }
244
246
  HTML
245
247
  end
246
248
 
@@ -328,5 +330,9 @@ module Recaptcha
328
330
  private_class_method def self.hash_to_query(hash)
329
331
  hash.delete_if { |_, val| val.nil? || val.empty? }.to_a.map { |pair| pair.join('=') }.join('&')
330
332
  end
333
+
334
+ private_class_method def self.element_check_condition(options)
335
+ options[:ignore_no_element] ? "if (element !== null)" : ""
336
+ end
331
337
  end
332
338
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Recaptcha
4
- VERSION = '5.12.3'
4
+ VERSION = '5.13.0'
5
5
  end
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.12.3
4
+ version: 5.13.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: 2022-09-05 00:00:00.000000000 Z
11
+ date: 2023-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json