recaptcha 5.12.3 → 5.13.1
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 +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +1 -0
- data/lib/recaptcha/helpers.rb +13 -7
- data/lib/recaptcha/version.rb +1 -1
- data/lib/recaptcha.rb +1 -1
- metadata +2 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: a5f8e49184cd3c0a7faab777fc3f65ed6b85f12e6dbdccf92d348380b67b99e9
         | 
| 4 | 
            +
              data.tar.gz: 2ae58417d087559999a5f94d19aa56790fb8589f7f49107bdd9e2d9f451f4c82
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 53aaceab8e0d55c84c612b8a62ae7dc77f58052f20ddec8674e79b9735104558584d0dfbdde3172f36227af2a8c87c3ea031a12ba5928b7873b1559aa97f4ba1
         | 
| 7 | 
            +
              data.tar.gz: 9ccae1a7fdfe7e3afe1b7ac80814688a840e695e13af749e7d576fa8c74a3c3fe27dcdff26fae5790c5cf391594853d29259be0a63dfa5d119cf6476ff2dc808
         | 
    
        data/CHANGELOG.md
    CHANGED
    
    
    
        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 |  | 
    
        data/lib/recaptcha/helpers.rb
    CHANGED
    
    | @@ -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 | 
            -
             | 
| 241 | 
            -
             | 
| 242 | 
            -
             | 
| 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
         | 
    
        data/lib/recaptcha/version.rb
    CHANGED
    
    
    
        data/lib/recaptcha.rb
    CHANGED
    
    
    
        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. | 
| 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:  | 
| 11 | 
            +
            date: 2023-04-17 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: json
         |