encoded_id-rails 1.0.0.rc6 → 1.0.0

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: 45d2f2c1637f43c14a714d4051ec7a1692a8267234ea90c302da97872b2da7b0
4
- data.tar.gz: 26030ffcef1dc8798d0919a68faf4ec5bb6d17c3a28730eee0d2bb1e9ecb8e3e
3
+ metadata.gz: 7e99068282cd5784294cc5d14e2c9b9d0a80604c1a2f585438e547fb0dd83bd4
4
+ data.tar.gz: e089cc0f30a7e18bc4034fa80ec11c9a48e69b89133fc6e283a912ca143c3bc8
5
5
  SHA512:
6
- metadata.gz: 05ca59de2b281917cb214cfaeb9a94c7453aba4a64d8e89ac484a583030839a192d5242a774bc511e78d6667c47d11bca27bb3a0b096aefa6c2aad3e3c39ad84
7
- data.tar.gz: e3cc3563234d3c13d10f34c55cc77b14f3a7c55e3b391d679d5c2239f39b272cd3e4a02c614f0638a20db815d1c425fd58c334a3b842d0cdb8c88a2c26e6e655
6
+ metadata.gz: 0156bd7504114ab4857e34851ec615511c5100f8d86a580078573e3d761e5475405a5399dbc089a26f34dcb234e92bd2685db693db509187f148658f6b56920d
7
+ data.tar.gz: 72d5b551086ac2e979cbde77bac313586d5c5e02f3f0f7c2e041eacfe5b44210ad6327f78da65a917b4ad97be28606548aadffd217528b6a067257e19a41534d
data/CHANGELOG.md CHANGED
@@ -1,14 +1,39 @@
1
1
  ## [Unreleased]
2
2
 
3
- ## [2.0.0.alpha1] - unreleased
3
+ - nothing yet
4
+
5
+ ## [1.0.0] - 2025-11-21
6
+
7
+ - First stable release!
8
+
9
+ **Important!!: `:sqids` are not compatible with `:hashids`, DO NOT CHANGE FROM ONE TO THE OTHER AFTER GOING LIVE.**
10
+
11
+ ### Fixed (Rails integration)
12
+
13
+ - Ensure finder methods correctly override their ActiveRecord counterparts
14
+ - Warn when ActiveRecord integration used in model that doesn't use `id` as primary key
15
+
16
+ ## [1.0.0.rc7] - 2025-11-19
4
17
 
5
18
  ### Breaking changes
6
19
 
7
- - `ReversibleId` now no longer downcases the encodedid input string by default on decode, ie the `decode` option `downcase` is now `false`. In a future release the `downcase` option will be removed.
8
- - The default encoding engine is now `:sqids` to reflect the official "deprecated" status of `Hashid`s (see https://sqids.org/faq#why-hashids)
20
+ - `ReversibleId` now no longer downcases the encodedid input string by default on decode, ie the `decode` option `downcase` is now `false`. This can be configured via the Rails configuration `downcase_on_decode` option. In a future release the `downcase` option will be removed.
21
+ - The default encoding engine is now `:sqids` to reflect the official "deprecated" status of `Hashid`s (see https://sqids.org/faq#why-hashids)
9
22
  - Ruby < 3.2 support dropped. The minimum supported Ruby version is now 3.2.0
23
+ - `Encoders` classes no longer expose `encode_hex` and `decode_hex` as they worked differently to the similarly named methods on ReversibleId
24
+ - Rails generator now needs you to specify which encoding algorithm you are using
10
25
 
11
- **Important!!: `:sqids` are not compatible with `:hashids`, DO NOT CHANGE FROM ONE TO THE OTHER AFTER GOING LIVE.**
26
+ ### Added (Rails integration)
27
+
28
+ - `encoded_id_options` class method to override `encoded_id` configuration on a model by model basis
29
+ - Blocklist application "modes". User can decide if the blocklist checks should be applied in situations
30
+ where very long encoded IDs are likely and hence block word collisions are undesirably likely.
31
+
32
+ ### Changed
33
+
34
+ - Blocklists are now pre-filtered to the encoder alphabet to avoid testing words which cannot be created by that alphabet anyway.
35
+ - Updates to inline RBS type signatures
36
+ - Documentation updates
12
37
 
13
38
  ## [1.0.0.rc6] - 2025-11-17
14
39
 
data/README.md CHANGED
@@ -7,28 +7,58 @@
7
7
 
8
8
  `encoded_id-rails` is a Rails integration that provides additional features for using `encoded_id` with ActiveRecord models.
9
9
 
10
+ It's one of the most, if not _the_ most, feature complete gem of its kind!
11
+
10
12
  👉 **Full documentation available at [encoded-id.onrender.com](https://encoded-id.onrender.com)**
11
13
 
14
+ ## Key Features
15
+
16
+ * 🔄 **Reversible** - Encoded IDs can be decoded back to the original values
17
+ * 👥 **Multiple IDs** - Encode multiple numeric IDs in one string
18
+ * 🚀 **Choose your encoding** - Supports `Sqids` (default) and `Hashids`, or use your own custom encoder
19
+ * 👓 **Human-readable** - Character grouping & character mappings of easily confused characters for better readability
20
+ * 🔡 **Custom alphabets** - Use your preferred character set, or a provided default
21
+ * 🚗 **Performance** - Uses an optimized `Hashids` encoder (compared to `hashids` gem) for better performance and less memory usage, and have pushed performance improvements to `Sqids` as well
22
+ * 🤬 **Blocklist filtering** - Built-in word blocklist support with configurable modes and optional default lists
23
+
24
+ ### Rails Integration Features
25
+
26
+ * 🏷️ **ActiveRecord integration** - Use with ActiveRecord models
27
+ * 🔑 **Per-model configuration** - Use custom salt and encoding settings per model
28
+ * 💅 **Slugged IDs** - URL-friendly slugs like `my-product--p5w9-z27j`
29
+ * 🔖 **Annotated IDs** - Model type indicators like `user_p5w9-z27j` (default behavior)
30
+ * 🔍 **Finder methods** - `find_by_encoded_id`, `find_by_encoded_id!`, `find_all_by_encoded_id`, `where_encoded_id`
31
+ * 🛣️ **URL params** - `to_param` automatically uses encoded IDs
32
+ * 🔒 **Safe defaults** - Limits on encoded ID lengths to prevent CPU and memory-intensive encode/decodes when used in URLs
33
+ * 💾 **Persistence** - Optional database persistence for efficient lookups
34
+
35
+
12
36
  ## Quick Example
13
37
 
14
38
  ```ruby
15
- coder = ::EncodedId::ReversibleId.new(salt: "my-salt")
39
+ # Using Hashids encoder (requires salt)
40
+ coder = ::EncodedId::ReversibleId.hashid(salt: "my-salt")
16
41
  coder.encode(123)
17
- # => "p5w9-z27j"
42
+ # => "m3pm-8anj"
18
43
 
19
44
  # The encoded strings are reversible
20
- coder.decode("p5w9-z27j")
45
+ coder.decode("m3pm-8anj")
21
46
  # => [123]
22
47
 
23
48
  # Supports encoding multiple IDs at once
24
49
  coder.encode([78, 45])
25
- # => "z2j7-0dmw"
50
+ # => "ny9y-sd7p"
51
+
52
+ # Using Sqids encoder (default, no salt required)
53
+ sqids_coder = ::EncodedId::ReversibleId.sqids
54
+ sqids_coder.encode(123)
55
+ # => (encoded value varies)
26
56
 
27
57
  # Can also be used with ActiveRecord models
28
58
  class User < ApplicationRecord
29
59
  include EncodedId::Rails::Model
30
-
31
- # Optional slug for the encoded ID
60
+
61
+ # Optional: define method to provide slug for encoded ID
32
62
  def name_for_encoded_id_slug
33
63
  full_name
34
64
  end
@@ -40,28 +70,6 @@ user.encoded_id # => "user_p5w9-z27j"
40
70
  user.slugged_encoded_id # => "bob-smith--user_p5w9-z27j"
41
71
  ```
42
72
 
43
- ## Key Features
44
-
45
- * 🔄 **Reversible** - Encoded IDs can be decoded back to the original values
46
- * 👥 **Multiple IDs** - Encode multiple numeric IDs in one string
47
- * 🚀 **Choose your encoding** - Supports `Hashids` and `Sqids` out of the box, or use your own custom encoder
48
- * 👓 **Human-readable** - Character grouping & character mappings of easily confused characters for better readability
49
- * 🔡 **Custom alphabets** - Use your preferred character set, or a provided default
50
- * 🚗 **Performance** - Uses an optimized `Hashids` encoder (compared to `hashids` gem) for better performance and less memory usage, and have pushed performance improvements to `Sqids` as well
51
- * 🤬 **Profanity blocking** - Built-in word blocklist support and optional default lists
52
-
53
- ### Rails Integration Features
54
-
55
- * 🏷️ **ActiveRecord integration** - Use with ActiveRecord models
56
- * 🔑 **Per-model salt** - Use a custom salt for encoding per model
57
- * 💅 **Slugged IDs** - URL-friendly slugs like `my-product--p5w9-z27j`
58
- * 🔖 **Annotated IDs** - Model type indicators like `user_p5w9-z27j`
59
- * 🔍 **Finder methods** - Find records using encoded IDs
60
- * 🛣️ **URL params** - `to_param` with encoded IDs
61
- * 🔒 **Safe defaults**: Limits on encoded ID lengths to prevent CPU and memory-intensive encode/decodes eg when used in URLs
62
- * 💾 **Persistence** - Optional database persistence for efficient lookups
63
-
64
-
65
73
  ## Standalone Gem
66
74
 
67
75
 
@@ -91,6 +99,10 @@ See the [Rails Integration](https://encoded-id.onrender.com/docs/encoded_id_rail
91
99
 
92
100
  **Encoded IDs are not secure**. They are meant to provide obfuscation, not encryption. Do not use them as a security mechanism.
93
101
 
102
+ As of version 1.0.0, `Sqids` is the default encoder. `Hashids` is still supported but is officially deprecated by the Hashids project in favor of Sqids.
103
+
104
+ Read more about the security implications: [Hashids expose salt value](https://www.sjoerdlangkemper.nl/2023/11/25/hashids-expose-salt-value/) (note: this specifically applies to Hashids encoder)
105
+
94
106
  ## Compare to Alternate Gems
95
107
 
96
108
  - [prefixed_ids](https://github.com/excid3/prefixed_ids)
@@ -105,11 +117,10 @@ For a detailed comparison, see the [Compared to Other Gems](https://encoded-id.o
105
117
 
106
118
  Visit [encoded-id.onrender.com](https://encoded-id.onrender.com) for comprehensive documentation including:
107
119
 
108
- - [EncodedId Core API](https://encoded-id.onrender.com/docs/encoded_id/api)
109
- - [Rails Integration API](https://encoded-id.onrender.com/docs/encoded_id_rails/api)
110
- - [Configuration Options](https://encoded-id.onrender.com/docs/encoded_id/configuration)
111
- - [Examples](https://encoded-id.onrender.com/docs/encoded_id/examples)
112
- - [Advanced Topics](https://encoded-id.onrender.com/docs/advanced-topics)
120
+ - [EncodedId Core Guide](https://encoded-id.onrender.com/docs/encoded_id/) - Installation, configuration, examples, and advanced topics
121
+ - [EncodedId Rails Guide](https://encoded-id.onrender.com/docs/encoded_id_rails/) - Rails integration, configuration, and examples
122
+ - [EncodedId Core API Reference](https://encoded-id.onrender.com/docs/encoded_id/api)
123
+ - [Rails Integration API Reference](https://encoded-id.onrender.com/docs/encoded_id_rails/api)
113
124
 
114
125
  ## Development
115
126