module JWT::JWA
def algorithms
def algorithms @algorithms ||= {} end
def create(algorithm)
- The `::JWT::JWA.create` method is deprecated and will be removed in the next major version of ruby-jwt.
def create(algorithm) Deprecations.warning('The ::JWT::JWA.create method is deprecated and will be removed in the next major version of ruby-jwt.') resolve(algorithm) end
def find(algo)
def find(algo) algorithms.fetch(algo.to_s.downcase, Unsupported) end
def register_algorithm(algo)
def register_algorithm(algo) algorithms[algo.alg.to_s.downcase] = algo end
def resolve(algorithm)
- Api: - private
def resolve(algorithm) return find(algorithm) if algorithm.is_a?(String) || algorithm.is_a?(Symbol) unless algorithm.is_a?(SigningAlgorithm) Deprecations.warning('Custom algorithms are required to include JWT::JWA::SigningAlgorithm. Custom algorithms that do not include this module may stop working in the next major version of ruby-jwt.') return Wrapper.new(algorithm) end algorithm end
def resolve_and_sort(algorithms:, preferred_algorithm:)
- Api: - private
def resolve_and_sort(algorithms:, preferred_algorithm:) algs = Array(algorithms).map { |alg| JWA.resolve(alg) } algs.partition { |alg| alg.valid_alg?(preferred_algorithm) }.flatten end