Class: Compeon::Token::Decoder

Inherits:
Object
  • Object
show all
Defined in:
lib/compeon/token/decoder.rb

Instance Method Summary collapse

Constructor Details

#initialize(claim_verifications: {}, encoded_token:, key:, token_klass:) ⇒ Decoder

Returns a new instance of Decoder.



10
11
12
13
14
15
# File 'lib/compeon/token/decoder.rb', line 10

def initialize(claim_verifications: {}, encoded_token:, key:, token_klass:)
  @claim_verifications = claim_verifications
  @encoded_token = encoded_token
  @key = key
  @token_klass = token_klass
end

Instance Method Details

#decodeObject

Raises:



17
18
19
20
21
22
23
24
# File 'lib/compeon/token/decoder.rb', line 17

def decode
  raise DecodeError if decoded_token[:knd] != token_klass.kind

  attributes = decoded_token_attributes
  attributes.delete(:knd)

  token_klass.new(attributes)
end