Sha256: 244c0d1922165c88d6d97c40f72b937f4d1f6056841a828cbd37981c16e18d2b

Contents?: true

Size: 609 Bytes

Versions: 4

Compression:

Stored size: 609 Bytes

Contents

# frozen_string_literal: true

module JWT
  module Claims
    class JwtId
      def initialize(validator:)
        @validator = validator
      end

      def verify!(context:, **_args)
        jti = context.payload['jti']
        if validator.respond_to?(:call)
          verified = validator.arity == 2 ? validator.call(jti, context.payload) : validator.call(jti)
          raise(JWT::InvalidJtiError, 'Invalid jti') unless verified
        elsif jti.to_s.strip.empty?
          raise(JWT::InvalidJtiError, 'Missing jti')
        end
      end

      private

      attr_reader :validator
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
jwt-2.9.3 lib/jwt/claims/jwt_id.rb
jwt-2.9.2 lib/jwt/claims/jwt_id.rb
jwt-2.9.1 lib/jwt/claims/jwt_id.rb
jwt-2.9.0 lib/jwt/claims/jwt_id.rb