Class: A2A::AgentCard::Signature

Inherits:
Object
  • Object
show all
Defined in:
lib/a2a/agent_card/signature.rb

Overview

§8.4.2 — JWS signature attached to an AgentCard. ‘protected` is the base64url-encoded JWS Protected Header. `signature` is the base64url-encoded signature value. `header` is the optional JWS Unprotected Header (plain JSON object, not encoded).

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(protected_header:, signature:, header: nil) ⇒ Signature

Returns a new instance of Signature.



12
13
14
15
16
# File 'lib/a2a/agent_card/signature.rb', line 12

def initialize(protected_header:, signature:, header: nil)
  @protected_header = protected_header
  @signature = signature
  @header = header
end

Instance Attribute Details

#headerObject (readonly)

Returns the value of attribute header.



10
11
12
# File 'lib/a2a/agent_card/signature.rb', line 10

def header
  @header
end

#protected_headerObject (readonly)

Returns the value of attribute protected_header.



10
11
12
# File 'lib/a2a/agent_card/signature.rb', line 10

def protected_header
  @protected_header
end

#signatureObject (readonly)

Returns the value of attribute signature.



10
11
12
# File 'lib/a2a/agent_card/signature.rb', line 10

def signature
  @signature
end

Class Method Details

.from_h(hash) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/a2a/agent_card/signature.rb', line 18

def self.from_h(hash)
  new(
    protected_header: hash.fetch("protected"),
    signature: hash.fetch("signature"),
    header: hash["header"]
  )
end

Instance Method Details

#to_hObject



26
27
28
29
30
31
32
# File 'lib/a2a/agent_card/signature.rb', line 26

def to_h
  {
    "protected" => protected_header,
    "signature" => signature,
    "header" => header
  }.compact
end