Class: SelfSDK::Messages::FactResponse
- Inherits:
-
Base
- Object
- Base
- SelfSDK::Messages::FactResponse
show all
- Defined in:
- lib/messages/fact_response.rb
Constant Summary
collapse
- MSG_TYPE =
"identities.facts.query.resp"
Instance Attribute Summary collapse
Attributes inherited from Base
#description, #exp_timeout, #expires, #fields, #from, #from_device, #id, #input, #intermediary, #payload, #status, #sub, #to, #to_device, #typ
Instance Method Summary
collapse
Methods inherited from Base
#accepted?, #encrypt_message, #errored?, #initialize, #rejected?, #request, #send_message, #unauthorized?
Instance Attribute Details
permalink
#audience ⇒ Object
Returns the value of attribute audience.
14
15
16
|
# File 'lib/messages/fact_response.rb', line 14
def audience
@audience
end
|
Returns the value of attribute facts.
14
15
16
|
# File 'lib/messages/fact_response.rb', line 14
def facts
@facts
end
|
Instance Method Details
permalink
#attestation_values_for(name) ⇒ Object
[View source]
55
56
57
58
|
# File 'lib/messages/fact_response.rb', line 55
def attestation_values_for(name)
a = attestations_for(name)
a.map{|a| a.value}
end
|
permalink
#attestations_for(name) ⇒ Object
[View source]
49
50
51
52
53
|
# File 'lib/messages/fact_response.rb', line 49
def attestations_for(name)
f = fact(name)
return [] if f.nil?
f.attestations
end
|
[View source]
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
# File 'lib/messages/fact_response.rb', line 67
def body
encoded_facts = []
@facts.each do |fact|
encoded_facts.push(fact.to_hash)
end
{ typ: MSG_TYPE,
iss: @jwt.id,
sub: @sub || @to,
aud: @audience,
iat: SelfSDK::Time.now.strftime('%FT%TZ'),
exp: (SelfSDK::Time.now + 3600).strftime('%FT%TZ'),
cid: @id,
jti: SecureRandom.uuid,
status: @status,
facts: encoded_facts }
end
|
permalink
#fact(name) ⇒ Object
[View source]
44
45
46
47
|
# File 'lib/messages/fact_response.rb', line 44
def fact(name)
name = SelfSDK::fact_name(name)
@facts.select{|f| f.name == name}.first
end
|
permalink
#parse(input, envelope = nil) ⇒ Object
[View source]
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/messages/fact_response.rb', line 16
def parse(input, envelope=nil)
@input = input
@typ = MSG_TYPE
@payload = get_payload input
@id = payload[:cid]
@from = payload[:iss]
@to = payload[:sub]
@expires = ::Time.parse(payload[:exp])
@issued = ::Time.parse(payload[:iat])
@audience = payload[:aud]
@status = payload[:status]
@facts = []
payload[:facts] = [] if payload[:facts].nil?
payload[:facts].each do |f|
begin
fact = SelfSDK::Messages::Fact.new(@messaging)
fact.parse(f)
@facts.push(fact)
rescue StandardError => e
SelfSDK.logger.info e.message
end
end
if envelope
issuer = envelope.sender.split(":")
@from_device = issuer.last
end
end
|
permalink
#validate!(original) ⇒ Object
[View source]
60
61
62
63
64
65
|
# File 'lib/messages/fact_response.rb', line 60
def validate!(original)
super
@facts.each do |f|
f.validate! original
end
end
|