Sha256: 0ea0c543338a2c6b2d261ca2fda8b190fcdbf1e255c4b5f4851c9cd565da67b8

Contents?: true

Size: 903 Bytes

Versions: 1

Compression:

Stored size: 903 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(token)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
real_savvy-0.0.7 lib/real_savvy/jwt/token.rb