rails_consent 0.1.0 → 0.1.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 +4 -0
- data/README.md +104 -0
- data/{app/helpers → lib}/rails_consent/application_helper.rb +2 -0
- data/lib/rails_consent/version.rb +1 -1
- data/lib/rails_consent.rb +2 -0
- data/sig/manifest.yaml +1 -0
- data/sig/rails_consent.rbs +107 -0
- metadata +5 -3
- /data/{app/controllers/concerns → lib}/rails_consent/controller_helpers.rb +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: db41ad501b276a6a3b243164d5eb0641f5a8a4b3b0fadd3d6becfaecfbb2716c
|
|
4
|
+
data.tar.gz: 3a99070e8cb4e92b911d79cbe3b1339f81f5cbe5b62f53ead4b311b47c9e47f4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7a9522f106b096c57ba280fd24a3c013f65bef654ab4fe49a72ca61e86da547a16edaf0137d629519c8906c2e901841d7695ae375f5b4baf79ab9827fc6b045a
|
|
7
|
+
data.tar.gz: 822a6f4e889cf71691a3624cdfe2d77f23609beab60df3a26a3379fd76c5b2e2d1f572cafaaef8efcc80f4c2a67a60df97b37b124a6d83d0be3704aa31cd2505
|
data/CHANGELOG.md
CHANGED
|
@@ -2,9 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 0.1.1
|
|
6
|
+
|
|
5
7
|
- Relaxed the development baseline to Ruby 3.4.7 and Rails 7.1+
|
|
6
8
|
- Simplified the gem contract so consent persistence stays in the host application
|
|
7
9
|
- Refreshed the documentation application into a richer documentation-first Rails app with enhanced live consent demos
|
|
10
|
+
- Fixed engine boot and installer helper loading so the public helper modules are available during initialization
|
|
11
|
+
- Documented the supported public API and shipped RBS signatures for the stable Ruby surface
|
|
8
12
|
|
|
9
13
|
## 0.1.0
|
|
10
14
|
|
data/README.md
CHANGED
|
@@ -166,6 +166,89 @@ consent_recorded?
|
|
|
166
166
|
reset_consent!
|
|
167
167
|
```
|
|
168
168
|
|
|
169
|
+
## Public API
|
|
170
|
+
|
|
171
|
+
Rails Consent treats the following server-side entrypoints as its supported public API for host applications:
|
|
172
|
+
|
|
173
|
+
- `RailsConsent.configure`
|
|
174
|
+
- `RailsConsent.configuration` and `RailsConsent.config`
|
|
175
|
+
- `RailsConsent::Configuration`
|
|
176
|
+
- `RailsConsent::DefaultConsentResolver`
|
|
177
|
+
- `RailsConsent::CategoryLoader`
|
|
178
|
+
- `RailsConsent::Category`
|
|
179
|
+
- `RailsConsent::CookieDefinition`
|
|
180
|
+
- `RailsConsent::PreferenceSet`
|
|
181
|
+
- `RailsConsent::CookieStore` when you want to wrap the built-in signed cookie flow
|
|
182
|
+
- `RailsConsent::ApplicationHelper`
|
|
183
|
+
- `RailsConsent::ControllerHelpers`
|
|
184
|
+
- The generated initializer and locale structure installed by `rails_consent:install`
|
|
185
|
+
- The shipped partial override points under `app/views/rails_consent/*`
|
|
186
|
+
- The browser API exposed through `window.RailsConsent`
|
|
187
|
+
|
|
188
|
+
Everything else should be treated as internal implementation detail and may change more freely between releases.
|
|
189
|
+
|
|
190
|
+
### Server-side API Reference
|
|
191
|
+
|
|
192
|
+
#### Configuration
|
|
193
|
+
|
|
194
|
+
```ruby
|
|
195
|
+
RailsConsent.configure do |config|
|
|
196
|
+
config.storage = :cookie
|
|
197
|
+
config.banner_position = :bottom
|
|
198
|
+
config.prompt_dismissible = true
|
|
199
|
+
config.cookie_name = "rails_consent_preferences"
|
|
200
|
+
config.cookie_expiration_days = 180
|
|
201
|
+
config.consent_resolver = RailsConsent::DefaultConsentResolver.new
|
|
202
|
+
end
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
`RailsConsent::Configuration` exposes these stable attributes and hooks:
|
|
206
|
+
|
|
207
|
+
- `storage`
|
|
208
|
+
- `banner_position`
|
|
209
|
+
- `prompt_dismissible`
|
|
210
|
+
- `cookie_name`
|
|
211
|
+
- `cookie_expiration_days`
|
|
212
|
+
- `cookie_same_site`
|
|
213
|
+
- `cookie_http_only`
|
|
214
|
+
- `cookie_secure`
|
|
215
|
+
- `cookie_path`
|
|
216
|
+
- `cookie_reader`
|
|
217
|
+
- `cookie_writer`
|
|
218
|
+
- `cookie_destroyer`
|
|
219
|
+
- `preferences_provider`
|
|
220
|
+
- `preferences_writer`
|
|
221
|
+
- `preferences_destroyer`
|
|
222
|
+
- `consent_recorded_provider`
|
|
223
|
+
- `consent_resolver`
|
|
224
|
+
- `validate!`
|
|
225
|
+
|
|
226
|
+
#### Category and Preference Objects
|
|
227
|
+
|
|
228
|
+
These objects are safe to use in host code when you want to inspect or extend consent behavior:
|
|
229
|
+
|
|
230
|
+
```ruby
|
|
231
|
+
RailsConsent::CategoryLoader.new.categories
|
|
232
|
+
RailsConsent::PreferenceSet.new(categories: categories, source: raw_preferences).to_h
|
|
233
|
+
RailsConsent::CookieStore.read(configuration: config, cookies: cookies, categories: categories, request: request)
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
`RailsConsent::Category` exposes:
|
|
237
|
+
|
|
238
|
+
- `key`
|
|
239
|
+
- `label`
|
|
240
|
+
- `description`
|
|
241
|
+
- `cookies`
|
|
242
|
+
- `required?`
|
|
243
|
+
|
|
244
|
+
`RailsConsent::CookieDefinition` exposes:
|
|
245
|
+
|
|
246
|
+
- `name`
|
|
247
|
+
- `provider`
|
|
248
|
+
- `purpose`
|
|
249
|
+
|
|
250
|
+
`RailsConsent::PreferenceSet#to_h` returns a normalized hash keyed by category name plus an optional `"timestamp"` entry.
|
|
251
|
+
|
|
169
252
|
## Client-side API
|
|
170
253
|
|
|
171
254
|
Rails Consent also exposes a small browser API through `window.RailsConsent`:
|
|
@@ -188,6 +271,27 @@ Lifecycle events are dispatched on `document` so host apps can react without mod
|
|
|
188
271
|
- `rails-consent:rejected-optional`
|
|
189
272
|
- `rails-consent:dismissed`
|
|
190
273
|
|
|
274
|
+
## Type Signatures
|
|
275
|
+
|
|
276
|
+
Rails Consent now ships RBS signatures for its documented public API under [`sig/`](sig).
|
|
277
|
+
|
|
278
|
+
That gives downstream applications and editors a machine-readable contract for the stable Ruby surface, including:
|
|
279
|
+
|
|
280
|
+
- `RailsConsent.configure`
|
|
281
|
+
- `RailsConsent::Configuration`
|
|
282
|
+
- `RailsConsent::CategoryLoader`
|
|
283
|
+
- `RailsConsent::Category`
|
|
284
|
+
- `RailsConsent::PreferenceSet`
|
|
285
|
+
- `RailsConsent::CookieStore`
|
|
286
|
+
- `RailsConsent::ApplicationHelper`
|
|
287
|
+
- `RailsConsent::ControllerHelpers`
|
|
288
|
+
|
|
289
|
+
You can validate the shipped signatures locally with:
|
|
290
|
+
|
|
291
|
+
```bash
|
|
292
|
+
rbs -I sig validate
|
|
293
|
+
```
|
|
294
|
+
|
|
191
295
|
## Storage Modes
|
|
192
296
|
|
|
193
297
|
### Signed Cookie Storage
|
data/lib/rails_consent.rb
CHANGED
|
@@ -9,6 +9,8 @@ require "rails_consent/category_loader"
|
|
|
9
9
|
require "rails_consent/cookie_store"
|
|
10
10
|
require "rails_consent/preference_set"
|
|
11
11
|
require "rails_consent/default_consent_resolver"
|
|
12
|
+
require "rails_consent/controller_helpers"
|
|
13
|
+
require "rails_consent/application_helper"
|
|
12
14
|
require "rails_consent/engine"
|
|
13
15
|
|
|
14
16
|
module RailsConsent
|
data/sig/manifest.yaml
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
dependencies: []
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
module RailsConsent
|
|
2
|
+
type preference_value = bool | ::Integer
|
|
3
|
+
type consent_hash = ::Hash[::String, preference_value]
|
|
4
|
+
|
|
5
|
+
VERSION: ::String
|
|
6
|
+
|
|
7
|
+
class Error < ::StandardError
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
class ConfigurationError < Error
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def self.configuration: () -> Configuration
|
|
14
|
+
def self.configuration=: (Configuration configuration) -> Configuration
|
|
15
|
+
def self.config: () -> Configuration
|
|
16
|
+
def self.configure: () { (Configuration configuration) -> void } -> true
|
|
17
|
+
|
|
18
|
+
class CookieDefinition
|
|
19
|
+
attr_reader name: ::String
|
|
20
|
+
attr_reader provider: ::String?
|
|
21
|
+
attr_reader purpose: ::String?
|
|
22
|
+
|
|
23
|
+
def initialize: (name: ::String | ::Symbol, ?provider: ::String?, ?purpose: ::String?) -> void
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
class Category
|
|
27
|
+
attr_reader description: ::String
|
|
28
|
+
attr_reader key: ::Symbol
|
|
29
|
+
attr_reader label: ::String
|
|
30
|
+
attr_reader cookies: ::Array[CookieDefinition]
|
|
31
|
+
|
|
32
|
+
def initialize: (
|
|
33
|
+
key: ::String | ::Symbol,
|
|
34
|
+
required: bool,
|
|
35
|
+
description: ::String?,
|
|
36
|
+
?label: ::String?,
|
|
37
|
+
?cookies: ::Array[untyped]
|
|
38
|
+
) -> void
|
|
39
|
+
|
|
40
|
+
def required?: () -> bool
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
class CategoryLoader
|
|
44
|
+
def initialize: (?locale: ::String | ::Symbol) -> void
|
|
45
|
+
def categories: () -> ::Array[Category]
|
|
46
|
+
def category_keys: () -> ::Array[::String]
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
class Configuration
|
|
50
|
+
BANNER_POSITIONS: ::Array[::Symbol]
|
|
51
|
+
STORAGE_VALUES: ::Array[::Symbol]
|
|
52
|
+
|
|
53
|
+
attr_accessor banner_position: ::Symbol
|
|
54
|
+
attr_accessor cookie_destroyer: untyped
|
|
55
|
+
attr_accessor cookie_expiration_days: ::Integer
|
|
56
|
+
attr_accessor cookie_http_only: bool
|
|
57
|
+
attr_accessor cookie_name: ::String
|
|
58
|
+
attr_accessor cookie_path: ::String
|
|
59
|
+
attr_accessor cookie_reader: untyped
|
|
60
|
+
attr_accessor cookie_same_site: ::Symbol?
|
|
61
|
+
attr_accessor cookie_secure: untyped
|
|
62
|
+
attr_accessor cookie_writer: untyped
|
|
63
|
+
attr_accessor consent_recorded_provider: untyped
|
|
64
|
+
attr_accessor preferences_provider: untyped
|
|
65
|
+
attr_accessor preferences_destroyer: untyped
|
|
66
|
+
attr_accessor preferences_writer: untyped
|
|
67
|
+
attr_accessor prompt_dismissible: bool
|
|
68
|
+
attr_reader consent_resolver: untyped
|
|
69
|
+
attr_reader storage: ::Symbol
|
|
70
|
+
|
|
71
|
+
def initialize: () -> void
|
|
72
|
+
def consent_resolver=: (untyped value) -> untyped
|
|
73
|
+
def consent_resolver_configured?: () -> bool
|
|
74
|
+
def storage=: (::Symbol value) -> ::Symbol
|
|
75
|
+
def validate!: () -> true
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
module ControllerHelpers
|
|
79
|
+
def consent_given?: (::String | ::Symbol category_name) -> bool
|
|
80
|
+
def consent_preferences: () -> consent_hash
|
|
81
|
+
def consent_recorded?: () -> bool
|
|
82
|
+
def reset_consent!: () -> true
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
module ApplicationHelper
|
|
86
|
+
def rails_consent_assets: () -> ::String
|
|
87
|
+
def rails_consent_banner: (?position: ::Symbol?, ?dismissible: bool?) -> untyped
|
|
88
|
+
def rails_consent_preferences_button: (?untyped label, **untyped options) ?{ () -> untyped } -> untyped
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
class CookieStore
|
|
92
|
+
def self.read: (configuration: Configuration, cookies: untyped, categories: ::Array[Category], ?request: untyped) -> consent_hash
|
|
93
|
+
def self.write!: (configuration: Configuration, cookies: untyped, categories: ::Array[Category], preferences: untyped, request: untyped) -> consent_hash
|
|
94
|
+
def self.delete!: (configuration: Configuration, cookies: untyped, ?request: untyped) -> untyped
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
class DefaultConsentResolver
|
|
98
|
+
def call: (category: Category, preferences: ::Hash[::String | ::Symbol, untyped], **untyped options) -> bool
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
class PreferenceSet
|
|
102
|
+
TIMESTAMP_KEY: ::String
|
|
103
|
+
|
|
104
|
+
def initialize: (categories: ::Array[Category], source: untyped) -> void
|
|
105
|
+
def to_h: () -> consent_hash
|
|
106
|
+
end
|
|
107
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rails_consent
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Dhairya Gabhawala
|
|
@@ -44,9 +44,7 @@ files:
|
|
|
44
44
|
- app/assets/config/rails_consent_manifest.js
|
|
45
45
|
- app/assets/javascripts/rails_consent.js
|
|
46
46
|
- app/assets/stylesheets/rails_consent/application.css
|
|
47
|
-
- app/controllers/concerns/rails_consent/controller_helpers.rb
|
|
48
47
|
- app/controllers/rails_consent/preferences_controller.rb
|
|
49
|
-
- app/helpers/rails_consent/application_helper.rb
|
|
50
48
|
- app/views/rails_consent/_banner.html.erb
|
|
51
49
|
- app/views/rails_consent/_category_toggle.html.erb
|
|
52
50
|
- app/views/rails_consent/_cookie_table.html.erb
|
|
@@ -56,14 +54,18 @@ files:
|
|
|
56
54
|
- lib/generators/rails_consent/install/templates/initializer.rb
|
|
57
55
|
- lib/generators/rails_consent/install/templates/rails_consent.en.yml
|
|
58
56
|
- lib/rails_consent.rb
|
|
57
|
+
- lib/rails_consent/application_helper.rb
|
|
59
58
|
- lib/rails_consent/category.rb
|
|
60
59
|
- lib/rails_consent/category_loader.rb
|
|
61
60
|
- lib/rails_consent/configuration.rb
|
|
61
|
+
- lib/rails_consent/controller_helpers.rb
|
|
62
62
|
- lib/rails_consent/cookie_store.rb
|
|
63
63
|
- lib/rails_consent/default_consent_resolver.rb
|
|
64
64
|
- lib/rails_consent/engine.rb
|
|
65
65
|
- lib/rails_consent/preference_set.rb
|
|
66
66
|
- lib/rails_consent/version.rb
|
|
67
|
+
- sig/manifest.yaml
|
|
68
|
+
- sig/rails_consent.rbs
|
|
67
69
|
homepage: https://rails-consent.dhairyagabhawala.com/
|
|
68
70
|
licenses:
|
|
69
71
|
- MIT
|
|
File without changes
|