class HealthCards::Verifier

Verifiers can validate HealthCards using public keys

Attributes

keys[R]
resolve_keys[RW]

Public Class Methods

new(keys: nil, resolve_keys: true) click to toggle source

Create a new Verifier

@param keys [HealthCards::KeySet, HealthCards::Key, nil] keys to use when verifying Health Cards @param resolve_keys [Boolean] Enables or disables key resolution

# File lib/health_cards/verifier.rb, line 29
def initialize(keys: nil, resolve_keys: true)
  @keys = case keys
          when KeySet
            keys
          when Key
            KeySet.new(keys)
          else
            KeySet.new
          end

  self.resolve_keys = resolve_keys
end
verify(verifiable) click to toggle source

Verify a HealthCard

This method always uses key resolution and does not depend on any cached keys

@param verifiable [HealthCards::JWS, String] the health card to verify @return [Boolean]

# File lib/health_cards/verifier.rb, line 21
def self.verify(verifiable)
  verify_using_key_set(verifiable)
end

Public Instance Methods

add_keys(key) click to toggle source

Add a key to use when verifying

@param key [HealthCards::Key, HealthCards::KeySet] the key to add

# File lib/health_cards/verifier.rb, line 45
def add_keys(key)
  @keys.add_keys(key)
end
remove_keys(key) click to toggle source

Remove a key to use when verifying

@param key [HealthCards::Key] the key to remove

# File lib/health_cards/verifier.rb, line 52
def remove_keys(key)
  @keys.remove_keys(key)
end
resolve_keys?() click to toggle source
# File lib/health_cards/verifier.rb, line 64
def resolve_keys?
  resolve_keys
end
verify(verifiable) click to toggle source

Verify a HealthCard

@param verifiable [HealthCards::JWS, String] the health card to verify @return [Boolean]

# File lib/health_cards/verifier.rb, line 60
def verify(verifiable)
  verify_using_key_set(verifiable, keys, resolve_keys: resolve_keys?)
end