Sha256: 0065517b13c9d265d63c2e5d9ba0fe9524b9144d770b3e9f8047b0146aa6ee04

Contents?: true

Size: 995 Bytes

Versions: 3

Compression:

Stored size: 995 Bytes

Contents

# typed: strict
# frozen_string_literal: true

module Paseto
  class Verify
    extend T::Sig

    sig { returns(Result) }
    attr_reader :result

    sig do
      params(
        result: Result,
        options: T::Hash[Symbol, T.untyped]
      ).returns(Result)
    end
    def self.verify(result, options = {})
      new(result, Paseto.config.decode.to_h.merge(options))
        .then(&:verify_footer)
        .then(&:verify_claims)
        .then(&:result)
    end

    sig do
      params(
        result: Result,
        options: T::Hash[Symbol, T.untyped]
      ).void
    end
    def initialize(result, options)
      @result = result
      @options = options
    end

    sig { returns(T.self_type) }
    def verify_claims
      Verifiers::Payload.verify(@result.claims, @options)
      self
    end

    sig { returns(T.self_type) }
    def verify_footer
      footer = @result.footer
      Verifiers::Footer.verify(footer, @options) if footer.is_a?(Hash)
      self
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

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