Sha256: c01d6cd189d777058276508462b20f12acc94aaa9b9fc6f9aaff502d77e8e49a

Contents?: true

Size: 1.15 KB

Versions: 3

Compression:

Stored size: 1.15 KB

Contents

# typed: strict
# frozen_string_literal: true

module Paseto
  module Verifiers
    class Payload < T::Enum
      extend T::Sig

      enums do
        Audience = new
        IssuedAt = new
        Issuer = new
        Expiration = new
        NotBefore = new
        Subject = new
        TokenIdentifier = new
      end

      sig { params(body: T::Hash[String, T.untyped], options: T::Hash[Symbol, T.untyped]).void }
      def self.verify(body, options)
        values.each { |v| v.verifier.new(body, options).verify }
      end

      sig { returns(T.class_of(Validator)) }
      def verifier # rubocop:disable Metrics/CyclomaticComplexity
        case self
        when Audience then Paseto::Validator::Audience
        when IssuedAt then Paseto::Validator::IssuedAt
        when Issuer then Paseto::Validator::Issuer
        when Expiration then Paseto::Validator::Expiration
        when NotBefore then Paseto::Validator::NotBefore
        when Subject then Paseto::Validator::Subject
        when TokenIdentifier then Paseto::Validator::TokenIdentifier
        else
          # :nocov:
          T.absurd(self)
          # :nocov:
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ruby-paseto-0.1.2 lib/paseto/verifiers/payload.rb
ruby-paseto-0.1.1 lib/paseto/verifiers/payload.rb
ruby-paseto-0.1.0 lib/paseto/verifiers/payload.rb