Sha256: 7f9573387963dcbdfe046eadd4f0505a40bf49b21a3ac7f369272bd35781beb4

Contents?: true

Size: 870 Bytes

Versions: 6

Compression:

Stored size: 870 Bytes

Contents

# frozen_string_literal: true

require 'jwt/algos/hmac'
require 'jwt/algos/eddsa'
require 'jwt/algos/ecdsa'
require 'jwt/algos/rsa'
require 'jwt/algos/ps'
require 'jwt/algos/none'
require 'jwt/algos/unsupported'

# JWT::Signature module
module JWT
  # Signature logic for JWT
  module Algos
    extend self

    ALGOS = [
      Algos::Hmac,
      Algos::Ecdsa,
      Algos::Rsa,
      Algos::Eddsa,
      Algos::Ps,
      Algos::None,
      Algos::Unsupported
    ].freeze

    def find(algorithm)
      indexed[algorithm && algorithm.downcase]
    end

    private

    def indexed
      @indexed ||= begin
        fallback = [Algos::Unsupported, nil]
        ALGOS.each_with_object(Hash.new(fallback)) do |alg, hash|
          alg.const_get(:SUPPORTED).each do |code|
            hash[code.downcase] = [alg, code]
          end
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
jwt-2.5.0 lib/jwt/algos.rb
jwt-2.4.1 lib/jwt/algos.rb
jwt-2.4.0 lib/jwt/algos.rb
jwt-2.4.0.beta1 lib/jwt/algos.rb
jwt-2.3.0 lib/jwt/algos.rb
jwt-2.2.3 lib/jwt/algos.rb