Class: JOSE::JWK::Set

Inherits:
Immutable::Vector
  • Object
show all
Defined in:
lib/jose/jwk/set.rb

Overview

Immutable Set structure based on Immutable::Vector.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_map(fields) ⇒ Object

Raises:

  • (ArgumentError)


6
7
8
9
10
11
12
13
14
# File 'lib/jose/jwk/set.rb', line 6

def self.from_map(fields)
  if fields['keys'].is_a?(Array)
    keys = fields['keys'].map do |key|
      next JOSE::JWK.from(key)
    end
    return JOSE::JWK::Set.new(keys), fields.except('keys')
  end
  raise ArgumentError, "invalid 'OKP' crv 'X448' JWK"
end

Instance Method Details

#to_map(fields) ⇒ Object



16
17
18
19
20
21
# File 'lib/jose/jwk/set.rb', line 16

def to_map(fields)
  jwks = self.map do |key|
    next key.to_map
  end.to_a
  return fields.put('keys', jwks)
end