Class: HealthCards::Issuer
- Inherits:
-
Object
- Object
- HealthCards::Issuer
- Defined in:
- lib/health_cards/issuer.rb
Overview
Issue Health Cards based on a stored private key
Instance Attribute Summary collapse
-
#key ⇒ Object
Returns the value of attribute key.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
-
#create_payload(bundle, type: Payload) ⇒ Payload::
Create a Payload from the supplied FHIR bundle.
-
#initialize(key:, url: nil) ⇒ Issuer
constructor
Create an Issuer.
- #issue_health_card(bundle, type: Payload) ⇒ Object
-
#issue_jws(bundle, type: Payload) ⇒ HealthCards::JWS
Create a JWS for a given payload.
-
#to_jwk ⇒ String
Returns the public key matching this issuer’s private key as a JWK KeySet JSON string useful for .well-known endpoints.
Constructor Details
#initialize(key:, url: nil) ⇒ Issuer
Create an Issuer
13 14 15 16 17 |
# 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 |
Instance Attribute Details
#key ⇒ Object
Returns the value of attribute key.
8 9 10 |
# File 'lib/health_cards/issuer.rb', line 8 def key @key end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
8 9 10 |
# File 'lib/health_cards/issuer.rb', line 8 def url @url end |
Instance Method Details
#create_payload(bundle, type: Payload) ⇒ Payload::
Create a Payload from the supplied FHIR bundle
23 24 25 |
# File 'lib/health_cards/issuer.rb', line 23 def create_payload(bundle, type: Payload) type.new(issuer: url, bundle: bundle) end |
#issue_health_card(bundle, type: Payload) ⇒ Object
38 39 40 41 |
# File 'lib/health_cards/issuer.rb', line 38 def issue_health_card(bundle, type: Payload) jws = issue_jws(bundle, type: type) HealthCards::HealthCard.new(jws) end |
#issue_jws(bundle, type: Payload) ⇒ HealthCards::JWS
Create a JWS for a given payload
Leave blank for default SMART Health Card behavior
33 34 35 36 |
# File 'lib/health_cards/issuer.rb', line 33 def issue_jws(bundle, type: Payload) card = create_payload(bundle, type: type) JWS.new(header: jws_header, payload: card.to_s, key: key) end |