class HealthCards::Issuer
Issue Health Cards based on a stored private key
Attributes
Public Class Methods
Create an Issuer
@param key [HealthCards::PrivateKey] the private key used for signing issued health cards
# File lib/health_cards/issuer.rb, line 13 def initialize(key:, url: nil) @url = url PrivateKey.enforce_valid_key_type!(key) self.key = key end
Public Instance Methods
Create a HealthCard
from the supplied FHIR bundle
@param bundle [FHIR::Bundle, String] the FHIR bundle used as the Health Card payload @return [HealthCard::]
# File lib/health_cards/issuer.rb, line 23 def create_health_card(bundle, type: HealthCard) type.new(issuer: url, bundle: bundle) end
Create a JWS
for a given payload
@param bundle [FHIR::Bundle] A FHIR::Bundle that will form the payload of the JWS
object @param type [Class] A subclass of HealthCards::Card that processes the bundle according to a specific IG. Leave blank for default SMART Health Card behavior @return [HealthCards::JWS] An instance of JWS
using the payload and signed by the issuer's private key
# File lib/health_cards/issuer.rb, line 33 def issue_jws(bundle, type: HealthCard) card = create_health_card(bundle, type: type) JWS.new(header: jws_header, payload: card.to_s, key: key) end
Set the private key used for signing issued health cards
@param key [HealthCards::PrivateKey, nil] the private key used for signing issued health cards
# File lib/health_cards/issuer.rb, line 41 def key=(key) PrivateKey.enforce_valid_key_type!(key) @key = key end
Returns the public key matching this issuer's private key as a JWK KeySet
JSON string useful for .well-known endpoints @return [String] JSON string in JWK standard
# File lib/health_cards/issuer.rb, line 50 def to_jwk KeySet.new(key.public_key).to_jwk end
Private Instance Methods
# File lib/health_cards/issuer.rb, line 56 def jws_header { 'zip' => 'DEF', 'alg' => 'ES256', 'kid' => key.public_key.kid } end