Module: JWT::JWK

Defined in:
lib/jwt/jwk.rb,
lib/jwt/jwk/ec.rb,
lib/jwt/jwk/rsa.rb,
lib/jwt/jwk/set.rb,
lib/jwt/jwk/hmac.rb,
lib/jwt/jwk/key_base.rb,
lib/jwt/jwk/key_finder.rb,
lib/jwt/jwk/okp_rbnacl.rb,
lib/jwt/jwk/thumbprint.rb,
lib/jwt/jwk/kid_as_key_digest.rb

Defined Under Namespace

Classes: EC, HMAC, KeyBase, KeyFinder, KidAsKeyDigest, OKPRbNaCl, RSA, Set, Thumbprint

Class Method Summary collapse

Class Method Details

.classesObject



24
25
26
27
# File 'lib/jwt/jwk.rb', line 24

def classes
  @mappings = nil # reset the cached mappings
  @classes ||= []
end

.create_from(key, params = nil, options = {}) ⇒ Object Also known as: new, import



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/jwt/jwk.rb', line 9

def create_from(key, params = nil, options = {})
  if key.is_a?(Hash)
    jwk_kty = key[:kty] || key['kty']
    raise JWT::JWKError, 'Key type (kty) not provided' unless jwk_kty

    return mappings.fetch(jwk_kty.to_s) do |kty|
      raise JWT::JWKError, "Key type #{kty} not supported"
    end.new(key, params, options)
  end

  mappings.fetch(key.class) do |klass|
    raise JWT::JWKError, "Cannot create JWK from a #{klass.name}"
  end.new(key, params, options)
end