recaptcha 5.12.3 → 5.13.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: 4052ca42cf536d84329b553a058de58f2c3579e0ac2ad1e08ba42fed8ce974b4
4
- data.tar.gz: 90c873c15d0772690ca3da6cf2588669a05c159e4fbaa1d6bdf5d809ad05dfd0
3
+ metadata.gz: a5f8e49184cd3c0a7faab777fc3f65ed6b85f12e6dbdccf92d348380b67b99e9
4
+ data.tar.gz: 2ae58417d087559999a5f94d19aa56790fb8589f7f49107bdd9e2d9f451f4c82
5
5
  SHA512:
6
- metadata.gz: 403d9de96d890bb3f75cfb83c5907f01944d8e88233248ec199fe014e04f7f1386c13cd867c9020a232cd5501faada986f6d3413d3a2369e5d38d9c56a0704b9
7
- data.tar.gz: ce0d965054455acff094e60ccad808fbf836992666f9bd1233684b172e766440ba922a0f8d030803575b3a538945e3273d0ae237ce2527f9e0983b7b76671328
6
+ metadata.gz: 53aaceab8e0d55c84c612b8a62ae7dc77f58052f20ddec8674e79b9735104558584d0dfbdde3172f36227af2a8c87c3ea031a12ba5928b7873b1559aa97f4ba1
7
+ data.tar.gz: 9ccae1a7fdfe7e3afe1b7ac80814688a840e695e13af749e7d576fa8c74a3c3fe27dcdff26fae5790c5cf391594853d29259be0a63dfa5d119cf6476ff2dc808
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  ## Next
2
2
 
3
+ ## 5.13.1
4
+ * Permit actions as symbol
5
+
6
+ ## 5.13.0
7
+ * Added option to ignore_no_element.
8
+
3
9
  ## 5.12.3
4
10
  * Remove score fallback for enterprise
5
11
  * 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.1'
5
5
  end
data/lib/recaptcha.rb CHANGED
@@ -125,7 +125,7 @@ module Recaptcha
125
125
  def self.action_valid?(action, expected_action)
126
126
  case expected_action
127
127
  when nil, FalseClass then true
128
- else action == expected_action
128
+ else action == expected_action.to_s
129
129
  end
130
130
  end
131
131
 
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.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: 2022-09-05 00:00:00.000000000 Z
11
+ date: 2023-04-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json