Class: Clickwrap::Capture::PresentationVerifier

Inherits:
Object
  • Object
show all
Defined in:
lib/clickwrap/capture/presentation_verifier.rb

Overview

Verifies the complete render-to-submit contract before Capture opens a database transaction. It owns no writes: its result is the frozen input the transaction is allowed to turn into an evidence event.

Defined Under Namespace

Classes: Result

Instance Method Summary collapse

Constructor Details

#initialize(policy:, submission:, explicit_answers:, actor_reference:, tenant_key:, subject_key:, subject_fingerprint:, represented_party:, prospective_actor:, registration_flow_id:, explicit_capture_channel:, represented_party_creation_flow_id: nil, creating_represented_party: false) ⇒ PresentationVerifier

Returns a new instance of PresentationVerifier.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/clickwrap/capture/presentation_verifier.rb', line 18

def initialize(policy:, submission:, explicit_answers:, actor_reference:, tenant_key:,
               subject_key:, subject_fingerprint:, represented_party:,
               prospective_actor:, registration_flow_id:, explicit_capture_channel:,
               represented_party_creation_flow_id: nil,
               creating_represented_party: false)
  @policy = policy
  @submission = submission
  @explicit_answers = explicit_answers
  @actor_reference = actor_reference
  @tenant_key = tenant_key
  @subject_key = subject_key
  @subject_fingerprint = subject_fingerprint
  @represented_party = represented_party
  @prospective_actor = prospective_actor
  @registration_flow_id = registration_flow_id
  @explicit_capture_channel = explicit_capture_channel
  @represented_party_creation_flow_id = represented_party_creation_flow_id
  @creating_represented_party = creating_represented_party == true
end

Instance Method Details

#verify!(for_replay: false) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/clickwrap/capture/presentation_verifier.rb', line 38

def verify!(for_replay: false)
  manifest = 
  capture_channel = @explicit_capture_channel || manifest.capture_channel.to_s

  verify_bindings!(manifest, capture_channel, for_replay: for_replay)
  document_versions = verify_document_digests!(manifest)
  revision = load_revision!(manifest, require_current_policy: !for_replay)
  statement_snapshots = frozen_statement_snapshots(revision)
  verify_manifest_matches_revision!(manifest, statement_snapshots)
  verify_combined_control!(manifest, statement_snapshots)
  answers = collect_answers(manifest)
  validate_answers!(manifest, answers, statement_snapshots)

  Result.new(
    manifest: manifest,
    revision: revision,
    statement_snapshots: statement_snapshots.freeze,
    answers: answers.freeze,
    document_versions_by_id: document_versions.freeze,
    capture_channel: capture_channel.freeze
  )
end