module JWT::Algos

Constants

ALGOS

Public Instance Methods

create(algorithm) click to toggle source
# File lib/jwt/algos.rb, line 44
def create(algorithm)
  Algos::AlgoWrapper.new(*find(algorithm))
end
find(algorithm) click to toggle source
# File lib/jwt/algos.rb, line 40
def find(algorithm)
  indexed[algorithm && algorithm.downcase]
end
implementation?(algorithm) click to toggle source
# File lib/jwt/algos.rb, line 48
def implementation?(algorithm)
  (algorithm.respond_to?(:valid_alg?) && algorithm.respond_to?(:verify)) ||
    (algorithm.respond_to?(:alg) && algorithm.respond_to?(:sign))
end

Private Instance Methods

indexed() click to toggle source
# File lib/jwt/algos.rb, line 55
def indexed
  @indexed ||= begin
    fallback = [nil, Algos::Unsupported]
    ALGOS.each_with_object(Hash.new(fallback)) do |cls, hash|
      cls.const_get(:SUPPORTED).each do |alg|
        hash[alg.downcase] = [alg, cls]
      end
    end
  end
end