File tree Expand file tree Collapse file tree 3 files changed +6
-2
lines changed
Expand file tree Collapse file tree 3 files changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -62,7 +62,10 @@ def initialize(jwt)
6262 #
6363 # @return [self]
6464 # @raise [JWT::DuplicateKeyError] if duplicate keys are found during subsequent parsing.
65+ # @raise [JWT::UnsupportedError] if the JSON gem version does not support duplicate key detection.
6566 def raise_on_duplicate_keys!
67+ raise JWT ::UnsupportedError , 'Duplicate key detection requires JSON gem >= 2.13.0' unless JSON . supports_duplicate_key_detection?
68+
6669 @allow_duplicate_keys = false
6770 self
6871 end
Original file line number Diff line number Diff line change @@ -55,4 +55,7 @@ class JWKError < DecodeError; end
5555 # The DuplicateKeyError class is raised when a JWT contains duplicate keys in the header or payload.
5656 # @see https://datatracker.ietf.org/doc/html/rfc7519#section-4 RFC 7519 Section 4
5757 class DuplicateKeyError < DecodeError ; end
58+
59+ # The UnsupportedError class is raised when a feature is not supported by the current environment.
60+ class UnsupportedError < StandardError ; end
5861end
Original file line number Diff line number Diff line change @@ -21,8 +21,6 @@ def parse(data, allow_duplicate_keys: true)
2121 raise
2222 end
2323
24- private
25-
2624 def supports_duplicate_key_detection?
2725 return @supports_duplicate_key_detection if defined? ( @supports_duplicate_key_detection )
2826
You can’t perform that action at this time.
0 commit comments