Class: Linzer::Signature::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/linzer/signature/context.rb

Overview

A mutable context object used during signature generation.

The context represents all state required to produce a signature, including:

  • the HTTP message being signed

  • the signing key

  • covered signature components

  • signature parameters

  • optional overlay headers introduced by signing profiles

Profiles may mutate this context before or during signing in order to influence the final signature output (e.g., adding headers, modifying components, or adjusting parameters).

This object is intentionally mutable and is not thread-safe.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message:, key:, label:, components:, params:) ⇒ Context

Creates a new signing context.

Parameters:

  • message (Linzer::Message)

    The HTTP message being signed

  • key (Linzer::Key)

    The signing key used to generate the signature

  • label (String, nil)

    Optional signature label. If provided, it is merged into params as ‘:label`.

  • components (Array<String>)

    The list of HTTP components covered by the signature

  • params (Hash)

    Signature parameters passed to the signing algorithm



55
56
57
58
59
60
61
# File 'lib/linzer/signature/context.rb', line 55

def initialize(message:, key:, label:, components:, params:)
  @message         = message
  @key             = key
  @components      = components.dup
  @params          = (label ? params.merge(label: label) : params).dup
  @overlay_headers = {}
end

Instance Attribute Details

#componentsArray<String> (readonly)

list of covered signature components

Returns:

  • (Array<String>)

    the current value of components



37
38
39
# File 'lib/linzer/signature/context.rb', line 37

def components
  @components
end

#keyObject (readonly)

the signing key used to generate the signature

Returns:

  • (Object)

    the current value of key



37
38
39
# File 'lib/linzer/signature/context.rb', line 37

def key
  @key
end

#messageLinzer::Message (readonly)

Returns a message view that includes any overlay headers.

The returned object is cached after first construction.

Overlay headers are applied lazily and only affect the derived signing view; the original message remains unchanged.

Returns:



37
38
39
# File 'lib/linzer/signature/context.rb', line 37

def message
  @message
end

#overlay_headersHash (readonly)

Overlay headers are merged into the message view during signature computation but do not mutate the underlying message.

Returns:

  • (Hash)

    the current value of overlay_headers



37
38
39
# File 'lib/linzer/signature/context.rb', line 37

def overlay_headers
  @overlay_headers
end

#paramsHash (readonly)

signature parameters (may include :label if provided)

Returns:

  • (Hash)

    the current value of params



37
38
39
# File 'lib/linzer/signature/context.rb', line 37

def params
  @params
end