Class: MailAuth::Arc::Chain
- Inherits:
-
Object
- Object
- MailAuth::Arc::Chain
- Defined in:
- lib/mailauth/arc/chain.rb
Overview
Every ARC header on a message, grouped into the sets they claim to belong to, and held to the structure RFC 8617 §5.2 step 3 requires of them.
Constant Summary collapse
- KINDS =
{ "arc-authentication-results" => :authentication_results, "arc-message-signature" => :message_signature, "arc-seal" => :seal }.freeze
Instance Method Summary collapse
- #empty? ⇒ Boolean
-
#initialize(message) ⇒ Chain
constructor
A new instance of Chain.
- #newest ⇒ Object
- #ordered ⇒ Object
-
#oversized? ⇒ Boolean
Instance values run 1..50 (§4.2.1), so a chain longer than that is over the ceiling however its instances are numbered.
- #sets ⇒ Object
- #structural_error ⇒ Object
-
#through(instance) ⇒ Object
Everything up to and including one instance — what that instance's seal signs (§5.1.1).
Constructor Details
#initialize(message) ⇒ Chain
Returns a new instance of Chain.
14 15 16 |
# File 'lib/mailauth/arc/chain.rb', line 14 def initialize() @message = end |
Instance Method Details
#empty? ⇒ Boolean
18 19 20 |
# File 'lib/mailauth/arc/chain.rb', line 18 def empty? sets.empty? end |
#newest ⇒ Object
36 37 38 |
# File 'lib/mailauth/arc/chain.rb', line 36 def newest ordered.last end |
#ordered ⇒ Object
32 33 34 |
# File 'lib/mailauth/arc/chain.rb', line 32 def ordered sets.values.sort_by(&:instance) end |
#oversized? ⇒ Boolean
Instance values run 1..50 (§4.2.1), so a chain longer than that is over the ceiling however its instances are numbered.
24 25 26 |
# File 'lib/mailauth/arc/chain.rb', line 24 def oversized? sets.size > MAXIMUM_SETS end |
#sets ⇒ Object
28 29 30 |
# File 'lib/mailauth/arc/chain.rb', line 28 def sets @sets ||= collect end |
#structural_error ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/mailauth/arc/chain.rb', line 46 def structural_error if incomplete = ordered.find { |set| !set.complete? } "ARC set i=#{incomplete.instance} does not carry exactly one of each header" elsif unreadable = ordered.find { |set| !set.readable? } "ARC set i=#{unreadable.instance} carries an invalid tag list" elsif ordered.map(&:instance) != (1..sets.size).to_a "ARC instances are not a continuous sequence" else chain_status_error end end |
#through(instance) ⇒ Object
Everything up to and including one instance — what that instance's seal signs (§5.1.1).
42 43 44 |
# File 'lib/mailauth/arc/chain.rb', line 42 def through(instance) ordered.take_while { |set| set.instance <= instance } end |