Module: JWT::JWA

Defined in:
lib/jwt/jwa.rb,
lib/jwt/jwa/ps.rb,
lib/jwt/jwa/rsa.rb,
lib/jwt/jwa/hmac.rb,
lib/jwt/jwa/none.rb,
lib/jwt/jwa/ecdsa.rb,
lib/jwt/jwa/eddsa.rb,
lib/jwt/jwa/compat.rb,
lib/jwt/jwa/wrapper.rb,
lib/jwt/jwa/hmac_rbnacl.rb,
lib/jwt/jwa/unsupported.rb,
lib/jwt/jwa/hmac_rbnacl_fixed.rb,
lib/jwt/jwa/signing_algorithm.rb

Defined Under Namespace

Modules: Compat, SigningAlgorithm, Unsupported Classes: Ecdsa, Eddsa, Hmac, HmacRbNaCl, HmacRbNaClFixed, None, Ps, Rsa, Wrapper

Class Method Summary collapse

Class Method Details

.create(algorithm) ⇒ Object



45
46
47
# File 'lib/jwt/jwa.rb', line 45

def create(algorithm)
  resolve(algorithm)
end

.find(algo) ⇒ Object



49
50
51
# File 'lib/jwt/jwa/signing_algorithm.rb', line 49

def find(algo)
  algorithms.fetch(algo.to_s.downcase, Unsupported)
end

.register_algorithm(algo) ⇒ Object



45
46
47
# File 'lib/jwt/jwa/signing_algorithm.rb', line 45

def register_algorithm(algo)
  algorithms[algo.alg.to_s.downcase] = algo
end

.resolve(algorithm) ⇒ Object



34
35
36
37
38
39
40
41
42
43
# File 'lib/jwt/jwa.rb', line 34

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