Sha256: 5013c8936174b91f0bdb332635ff949d524a1587d5775090b73534c983d567fb

Contents?: true

Size: 902 Bytes

Versions: 4

Compression:

Stored size: 902 Bytes

Contents

module RealSavvy
  module JWT
    class Token < AbstractToken

      def to_share_token
        share_token_payload_keys = ['aud','sub']
        share_token_payload = ::Hash[[share_token_payload_keys, claims.values_at(*share_token_payload_keys)].transpose]
        ShareToken.new(
          ::JWT.encode(
            share_token_payload, nil, 'none'
          )
        )
      end

      private

      def retrieve_claims
        @claims, @header = ::JWT.decode(
                              token,
                              ::RealSavvy::JWT::Config.public_key,
                              true,
                              algorithm: 'RS256',
                            )
      rescue ::JWT::DecodeError => e
        raise ::RealSavvy::JWT::BadCredentials.new(e.message)
      end

      def validate_token
        ::RealSavvy::JWT::Config.validate_token(self)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
real_savvy-0.0.12 lib/real_savvy/jwt/token.rb
real_savvy-0.0.10 lib/real_savvy/jwt/token.rb
real_savvy-0.0.9 lib/real_savvy/jwt/token.rb
real_savvy-0.0.8 lib/real_savvy/jwt/token.rb