Codebase list ruby-recaptcha / 98aeb5e
Import upstream version 5.13.1 Debian Janitor 1 year, 22 days ago
6 changed file(s) with 25 addition(s) and 12 deletion(s). Raw diff Collapse all Expand all
00 ## Next
1
2 ## 5.13.1
3 * Permit actions as symbol
4
5 ## 5.13.0
6 * Added option to ignore_no_element.
17
28 ## 5.12.3
39 * Remove score fallback for enterprise
426426 | `: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`) |
427427 | `: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. |
428428 | `: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. |
429 | `: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) |
429430
430431 [JavaScript resource (api.js) parameters](https://developers.google.com/recaptcha/docs/invisible#js_param):
431432
1515 options[:render] = site_key
1616 options[:script_async] ||= false
1717 options[:script_defer] ||= false
18 options[:ignore_no_element] = options.key?(:ignore_no_element) ? options[:ignore_no_element] : true
1819 element = options.delete(:element)
1920 element = element == false ? false : :input
2021 if element == :input
137138 nonce = options.delete(:nonce)
138139 skip_script = (options.delete(:script) == false) || (options.delete(:external_script) == false)
139140 ui = options.delete(:ui)
141 options.delete(:ignore_no_element)
140142
141143 data_attribute_keys = [:badge, :theme, :type, :callback, :expired_callback, :error_callback, :size]
142144 data_attribute_keys << :tabindex unless ui == :button
205207 })
206208 };
207209
208 #{recaptcha_v3_define_default_callback(callback) if recaptcha_v3_define_default_callback?(callback, action, options)}
210 #{recaptcha_v3_define_default_callback(callback, options) if recaptcha_v3_define_default_callback?(callback, action, options)}
209211 </script>
210212 HTML
211213 end
223225 });
224226 });
225227 };
226 #{recaptcha_v3_define_default_callback(callback) if recaptcha_v3_define_default_callback?(callback, action, options)}
228 #{recaptcha_v3_define_default_callback(callback, options) if recaptcha_v3_define_default_callback?(callback, action, options)}
227229 </script>
228230 HTML
229231 end
234236 options[:inline_script] != false
235237 end
236238
237 private_class_method def self.recaptcha_v3_define_default_callback(callback)
239 private_class_method def self.recaptcha_v3_define_default_callback(callback, options)
238240 <<-HTML
239 var #{callback} = function(id, token) {
240 var element = document.getElementById(id);
241 element.value = token;
242 }
241 var #{callback} = function(id, token) {
242 var element = document.getElementById(id);
243 #{element_check_condition(options)} element.value = token;
244 }
243245 HTML
244246 end
245247
327329 private_class_method def self.hash_to_query(hash)
328330 hash.delete_if { |_, val| val.nil? || val.empty? }.to_a.map { |pair| pair.join('=') }.join('&')
329331 end
332
333 private_class_method def self.element_check_condition(options)
334 options[:ignore_no_element] ? "if (element !== null)" : ""
335 end
330336 end
331337 end
00 # frozen_string_literal: true
11
22 module Recaptcha
3 VERSION = '5.12.3'
3 VERSION = '5.13.1'
44 end
124124 def self.action_valid?(action, expected_action)
125125 case expected_action
126126 when nil, FalseClass then true
127 else action == expected_action
127 else action == expected_action.to_s
128128 end
129129 end
130130
11 # This file has been automatically generated by gem2tgz #
22 #########################################################
33 # -*- encoding: utf-8 -*-
4 # stub: recaptcha 5.12.3 ruby lib
4 # stub: recaptcha 5.13.1 ruby lib
55
66 Gem::Specification.new do |s|
77 s.name = "recaptcha".freeze
8 s.version = "5.12.3"
8 s.version = "5.13.1"
99
1010 s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
1111 s.metadata = { "source_code_uri" => "https://github.com/ambethia/recaptcha" } if s.respond_to? :metadata=
1212 s.require_paths = ["lib".freeze]
1313 s.authors = ["Jason L Perry".freeze]
14 s.date = "2022-09-05"
14 s.date = "2023-04-17"
1515 s.description = "Helpers for the reCAPTCHA API".freeze
1616 s.email = ["jasper@ambethia.com".freeze]
1717 s.files = ["CHANGELOG.md".freeze, "LICENSE".freeze, "README.md".freeze, "lib/recaptcha.rb".freeze, "lib/recaptcha/adapters/controller_methods.rb".freeze, "lib/recaptcha/adapters/view_methods.rb".freeze, "lib/recaptcha/configuration.rb".freeze, "lib/recaptcha/helpers.rb".freeze, "lib/recaptcha/rails.rb".freeze, "lib/recaptcha/railtie.rb".freeze, "lib/recaptcha/version.rb".freeze, "rails/locales/en.yml".freeze, "rails/locales/fr.yml".freeze, "rails/locales/ja.yml".freeze, "rails/locales/nl.yml".freeze]