rails_cloudflare_turnstile 0.2.0 → 0.2.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 72dc292372557cd074ad5849a4bd3de12b55d56d53b14a57ca248f9e406bf17a
4
- data.tar.gz: 2b6b02151805b3e04a0970e8cfc0ed8d6231fb006547c17e8353c21a66b87f23
3
+ metadata.gz: 671ea3b114a69c80454ee276c0c8136f86c03bb004999cc99008ebd1ee225402
4
+ data.tar.gz: a2fca23ab298a5457e0a12817e9f32f838fbeec15b978a534aa864dee081c882
5
5
  SHA512:
6
- metadata.gz: d6f8af28dd1ae7581d2a47124e81fd9a34e2a168d3b6cd8dfaf1f19bce732b57e8e0b86b637cc39023ba66a81c16757076842f3989f5bfe05f1a4f228f2e27f7
7
- data.tar.gz: c4d387d37d0c0a2c01a30da6c5e85566517b7c14f12eb753513b32fa97d3dfd3f80408e3b1749f5cd82629e4d524ee5a07985ff0436dbce98467ffa4d5239b7d
6
+ metadata.gz: b3b46461d813e8021b3df1104c1da0b1151618be3065b72d30072e44c20ac22b427dec51568cb223d54ceff266199fd03f61ea52685f5cdb605d2a6b951aadc9
7
+ data.tar.gz: a8af33cd2746c38eac2987069fff8e04e6d02a25415f512a72685c8b16955cc02cd96ae5f9bcbb8a1003934cdb5160ca00a1de635cd686172119195db4f41c53
data/CHANGELOG.md CHANGED
@@ -1,6 +1,16 @@
1
1
  ChangeLog
2
2
  =========
3
3
 
4
+ 0.2.2
5
+ -----
6
+ - Resolve CVE-2025-27111
7
+ - Fix broken unit tests and update method documentation.
8
+ - Fix standardrb linting error.
9
+
10
+ 0.2.1
11
+ -----
12
+ - Add support for passing arbitary keyword arguments to the underlying `content_tag` from the `cloudflare_turnstile` helper
13
+
4
14
  0.2.0
5
15
  -----
6
16
  - drop support for Ruby 2.7
data/README.md CHANGED
@@ -38,14 +38,14 @@ To totally disable Turnstile, you can set `c.enabled = false` and all other conf
38
38
  To use Turnstile for a view:
39
39
 
40
40
  1. Call `cloudflare_turnstile_script_tag` in your layout
41
- 2. Call `cloudflare_turnstile` in your form View
41
+ 2. Call `cloudflare_turnstile` in your form View. Keyword arguments are passed to the tag helper (for example, to set the `tabindex` option, you could use `cloudflare_turnstile(data: {tabindex: 0})`)
42
42
  3. Call `validate_cloudflare_turnstile` as a `before_action` in your controller.
43
43
 
44
44
  If the challenge fails, the exception `RailsCloudflareTurnstile::Forbidden` will be raised; you should handle this with
45
45
  a `rescue_from` block.
46
46
 
47
47
  By default, in development and test mode, a special mock view will be inserted if real credentials are not present. To
48
- disable this, set the `mock_enable` property of the configuration to false.
48
+ disable this, set the `mock_enabled` property of the configuration to false.
49
49
 
50
50
  ## License
51
51
  The gem is available as open source under the terms of the [ISC License](LICENSE.txt).
@@ -16,7 +16,7 @@ module RailsCloudflareTurnstile
16
16
  # Timeout for operations with Cloudflare
17
17
  attr_accessor :timeout
18
18
 
19
- # size for the widget (:regular or :compact)
19
+ # size for the widget (:regular, :compact, or :flexible)
20
20
  attr_accessor :size
21
21
 
22
22
  # theme for the widget (:auto, :light, or :dark)
@@ -42,7 +42,7 @@ module RailsCloudflareTurnstile
42
42
  raise "Must set site key" if @site_key.nil?
43
43
  raise "Must set secret key" if @secret_key.nil?
44
44
  @size = @size.to_sym
45
- raise "Size must be one of ':regular' or ':compact'" unless [:regular, :compact].include? @size
45
+ raise "Size must be one of ':regular', ':compact' or ':flexible'" unless [:regular, :compact, :flexible].include? @size
46
46
  raise "Theme must be one of :auto, :light, or :dark" unless [:auto, :light, :dark].include? @theme
47
47
  end
48
48
 
@@ -1,3 +1,3 @@
1
1
  module RailsCloudflareTurnstile
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.2"
3
3
  end
@@ -2,25 +2,25 @@
2
2
 
3
3
  module RailsCloudflareTurnstile
4
4
  module ViewHelpers
5
- def cloudflare_turnstile(action: "other", data_callback: nil)
5
+ def cloudflare_turnstile(action: "other", data_callback: nil, **html_options)
6
6
  if RailsCloudflareTurnstile.enabled?
7
7
  content_tag(:div, class: "cloudflare-turnstile") do
8
- concat turnstile_div(action, data_callback: data_callback)
8
+ concat turnstile_div(action, data_callback: data_callback, **html_options)
9
9
  end
10
10
  elsif RailsCloudflareTurnstile.mock_enabled?
11
11
  content_tag(:div, class: "cloudflare-turnstile") do
12
- concat mock_turnstile_div(action, data_callback: data_callback)
12
+ concat mock_turnstile_div(action, data_callback: data_callback, **html_options)
13
13
  end
14
14
  end
15
15
  end
16
16
 
17
17
  def cloudflare_turnstile_script_tag(async: true, defer: true)
18
18
  if RailsCloudflareTurnstile.enabled?
19
- content_tag(:script, src: js_src, async: async, defer: defer) do
19
+ content_tag(:script, src: js_src, async: async, defer: defer, data: {turbo_track: "reload", turbo_temporary: true}) do
20
20
  ""
21
21
  end
22
22
  elsif RailsCloudflareTurnstile.mock_enabled?
23
- content_tag(:script, src: mock_js, async: async, defer: defer) do
23
+ content_tag(:script, src: mock_js, async: async, defer: defer, data: {turbo_track: "reload", turbo_temporary: true}) do
24
24
  ""
25
25
  end
26
26
  end
@@ -28,15 +28,15 @@ module RailsCloudflareTurnstile
28
28
 
29
29
  private
30
30
 
31
- def turnstile_div(action, data_callback: nil)
31
+ def turnstile_div(action, data_callback: nil, **html_options)
32
32
  config = RailsCloudflareTurnstile.configuration
33
- content_tag(:div, :class => "cf-turnstile", "data-sitekey" => site_key, "data-size" => config.size, "data-action" => action, "data-callback" => data_callback, "data-theme" => config.theme) do
33
+ content_tag(:div, :class => "cf-turnstile", "data-sitekey" => site_key, "data-size" => config.size, "data-action" => action, "data-callback" => data_callback, "data-theme" => config.theme, **html_options) do
34
34
  ""
35
35
  end
36
36
  end
37
37
 
38
- def mock_turnstile_div(action, data_callback: nil)
39
- content_tag(:div, :class => "cf-turnstile", :style => "width: 300px; height: 65px; border: 1px solid gray; display: flex; flex-direction: row; justify-content: center; align-items: center; margin: 10px;", "data-callback" => data_callback) do
38
+ def mock_turnstile_div(action, data_callback: nil, **html_options)
39
+ content_tag(:div, :class => "cf-turnstile", :style => "width: 300px; height: 65px; border: 1px solid gray; display: flex; flex-direction: row; justify-content: center; align-items: center; margin: 10px;", "data-callback" => data_callback, **html_options) do
40
40
  [
41
41
  tag.input(type: "hidden", name: "cf-turnstile-response", value: "mocked"),
42
42
  image_tag("turnstile-logo.svg"),
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_cloudflare_turnstile
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Brown
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-02-08 00:00:00.000000000 Z
10
+ date: 2025-03-07 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: rails
@@ -19,7 +18,7 @@ dependencies:
19
18
  version: '6.0'
20
19
  - - "<"
21
20
  - !ruby/object:Gem::Version
22
- version: '8'
21
+ version: '9'
23
22
  type: :runtime
24
23
  prerelease: false
25
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +28,7 @@ dependencies:
29
28
  version: '6.0'
30
29
  - - "<"
31
30
  - !ruby/object:Gem::Version
32
- version: '8'
31
+ version: '9'
33
32
  - !ruby/object:Gem::Dependency
34
33
  name: faraday
35
34
  requirement: !ruby/object:Gem::Requirement
@@ -79,7 +78,6 @@ metadata:
79
78
  homepage_uri: https://github.com/instrumentl/rails-cloudflare-turnstile
80
79
  source_code_uri: https://github.com/instrumentl/rails-cloudflare-turnstile
81
80
  changelog_uri: https://github.com/instrumentl/rails-cloudflare-turnstile/blob/main/CHANGELOG.md
82
- post_install_message:
83
81
  rdoc_options: []
84
82
  require_paths:
85
83
  - lib
@@ -94,8 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
94
92
  - !ruby/object:Gem::Version
95
93
  version: '0'
96
94
  requirements: []
97
- rubygems_version: 3.5.3
98
- signing_key:
95
+ rubygems_version: 3.6.2
99
96
  specification_version: 4
100
97
  summary: Rails extension for Cloudflare's Turnstile CAPTCHA alternative
101
98
  test_files: []