simple_oauth 1.0.3 → 1.0.4

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: ed41a0a0f5917e46e47d2fc785730f9c194a0541af8199b46a4928405000f110
4
- data.tar.gz: 34d5043273278eb6571534259ee8628268c851d468462e6a25806402ce2afd83
3
+ metadata.gz: '085f7b377ecba7e5a389e1fa122341ca4c5b517b65cf77ac41d4e69c6f3ac2d0'
4
+ data.tar.gz: d38ee1bd5f40c23c29182df41d687f6eee8bb04004b9aee9152ed04b61e532bd
5
5
  SHA512:
6
- metadata.gz: eca0708e81fc8a823e7c5c3e87b48003bce4f6da9ac16d9c8fc0f6a5a45003261ecfaae9bf787e54f5f46b89acdaaf2c1719ad9ba9ac52c4523aaf201cd1aaac
7
- data.tar.gz: ba7096154201bf4a19cfa3c34e5cf92a5c566e46165be3d1bf9632bbeb28bcd78b891b07a6743d631140a18a1d3bd7170176d65585af3da0f455a01a06236479
6
+ metadata.gz: 111934cffa979ed69516a53f3dbe875e8f4ebc3dfb60890dd202019df92f267ae46cbcf8dd313c3241889548e05e026583e72ee455283635f0e06822a639d063
7
+ data.tar.gz: 267bbab778351538d6173534b4315ca9a953911cbc74c610f3c1395f9cbea6fc854ae9b274cfcaeb4ba62a58158d43232ad67f75fc745aeecc6246b79b4ab98d
data/CHANGELOG.md CHANGED
@@ -5,6 +5,18 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/2.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.0.4] - 2026-11-14
9
+
10
+ ### Changed
11
+
12
+ - Look up a signature method by the name it was registered under without allocating, so signing a request allocates at least 4 fewer objects and verifying one at least 6 fewer. Verifying without a `signature_method` now allocates fewer objects than in 1.0.1
13
+
14
+ ## [0.5.4] - 2026-11-14
15
+
16
+ ### Changed
17
+
18
+ - Look up a signature method by the name it was registered under without allocating, so signing a request allocates at least 4 fewer objects and verifying one at least 6 fewer. Verifying without a `signature_method` now allocates fewer objects than in 0.5.1
19
+
8
20
  ## [1.0.3] - 2026-11-14
9
21
 
10
22
  ### Fixed
@@ -143,6 +155,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
143
155
  - Avoid symbolizing untrusted input in parse methods for security
144
156
  - Refactored `Header.parse` for improved robustness using StringScanner
145
157
 
158
+ [1.0.4]: https://github.com/laserlemon/simple_oauth/compare/v1.0.3...v1.0.4
159
+ [0.5.4]: https://github.com/laserlemon/simple_oauth/compare/v0.5.3...v0.5.4
146
160
  [1.0.3]: https://github.com/laserlemon/simple_oauth/compare/v1.0.2...v1.0.3
147
161
  [0.5.3]: https://github.com/laserlemon/simple_oauth/compare/v0.5.2...v0.5.3
148
162
  [1.0.2]: https://github.com/laserlemon/simple_oauth/compare/v1.0.1...v1.0.2
@@ -27,6 +27,10 @@ module SimpleOAuth
27
27
  # Registry of signature method implementations
28
28
  @registry = {}
29
29
 
30
+ # The registry key of each name a signature method was registered under, so a lookup by that
31
+ # name, as nearly every lookup is, needs no normalizing and allocates nothing
32
+ @names = {}
33
+
30
34
  class << self
31
35
  # Registers a custom signature method
32
36
  #
@@ -48,7 +52,9 @@ module SimpleOAuth
48
52
  # )
49
53
  # end
50
54
  def register(name, rsa: false, verify: nil, digest: DEFAULT_DIGEST, &block)
51
- @registry[normalize_name(name)] = {implementation: block, rsa: rsa, verifier: verify, digest: digest}
55
+ key = normalize_name(name)
56
+ @names[name] = key
57
+ @registry[key] = {implementation: block, rsa: rsa, verifier: verify, digest: digest}
52
58
  end
53
59
 
54
60
  # Checks if a signature method is registered
@@ -59,7 +65,7 @@ module SimpleOAuth
59
65
  # @example
60
66
  # SimpleOAuth::Signature.registered?("HMAC-SHA1") # => true
61
67
  def registered?(name)
62
- @registry.key?(normalize_name(name))
68
+ @registry.key?(registry_key(name))
63
69
  end
64
70
 
65
71
  # Returns list of registered signature method names
@@ -139,7 +145,9 @@ module SimpleOAuth
139
145
  # @example
140
146
  # SimpleOAuth::Signature.unregister("HMAC-SHA512")
141
147
  def unregister(name)
142
- @registry.delete(normalize_name(name))
148
+ key = registry_key(name)
149
+ @names.delete_if { |_, registered| registered.eql?(key) }
150
+ @registry.delete(key)
143
151
  end
144
152
 
145
153
  # Resets the registry to only built-in methods (useful for testing)
@@ -150,6 +158,7 @@ module SimpleOAuth
150
158
  # SimpleOAuth::Signature.reset!
151
159
  def reset!
152
160
  @registry.clear
161
+ @names.clear
153
162
  register_builtin_methods
154
163
  end
155
164
 
@@ -188,12 +197,25 @@ module SimpleOAuth
188
197
  # @return [Hash] the registry entry
189
198
  # @raise [ArgumentError] if the signature method is not registered
190
199
  def fetch(name)
191
- @registry.fetch(normalize_name(name)) do
200
+ @registry.fetch(registry_key(name)) do
192
201
  raise ArgumentError, "Unknown signature method: #{name}. " \
193
202
  "Registered methods: #{@registry.keys.join(", ")}"
194
203
  end
195
204
  end
196
205
 
206
+ # Finds the registry key for a signature method name
207
+ #
208
+ # A name a method was registered under is found in the index of those names. Any other
209
+ # spelling is normalized, without being added to the index, so names from received headers
210
+ # cannot grow it.
211
+ #
212
+ # @api private
213
+ # @param name [String] the signature method name
214
+ # @return [String] the registry key (lowercase, dashes to underscores)
215
+ def registry_key(name)
216
+ @names[name] || normalize_name(name)
217
+ end
218
+
197
219
  # Normalizes signature method name for registry lookup
198
220
  #
199
221
  # @api private
@@ -3,5 +3,5 @@
3
3
  # OAuth 1.0 header generation library
4
4
  module SimpleOAuth
5
5
  # The current version of the SimpleOAuth gem
6
- VERSION = "1.0.3"
6
+ VERSION = "1.0.4"
7
7
  end
@@ -19,6 +19,9 @@ module SimpleOAuth
19
19
  # Registry of signature method implementations (class-level instance variable)
20
20
  self.@registry: Hash[String, registry_entry]
21
21
 
22
+ # The registry key of each name a signature method was registered under
23
+ self.@names: Hash[String | Symbol, String]
24
+
22
25
  # Registers a custom signature method
23
26
  def self.register: (String | Symbol name, ?rsa: bool, ?verify: verifier_block?, ?digest: String) { (untyped, String) -> String } -> void
24
27
 
@@ -57,6 +60,9 @@ module SimpleOAuth
57
60
  # Looks up a registered signature method
58
61
  def self.fetch: (String | Symbol name) -> registry_entry
59
62
 
63
+ # Finds the registry key for a signature method name
64
+ def self.registry_key: (String | Symbol name) -> String
65
+
60
66
  # Normalizes signature method name for registry lookup
61
67
  def self.normalize_name: (String | Symbol name) -> String
62
68
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_oauth
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Richert