Module: Yoti::Protobuf

Defined in:
lib/yoti/protobuf/main.rb,
lib/yoti/protobuf/attrpubapi/List_pb.rb,
lib/yoti/protobuf/attrpubapi/Signing_pb.rb,
lib/yoti/protobuf/attrpubapi/Attribute_pb.rb,
lib/yoti/protobuf/sharepubapi/DataEntry_pb.rb,
lib/yoti/protobuf/sharepubapi/ExtraData_pb.rb,
lib/yoti/protobuf/attrpubapi/ContentType_pb.rb,
lib/yoti/protobuf/compubapi/EncryptedData_pb.rb,
lib/yoti/protobuf/compubapi/SignedTimestamp_pb.rb,
lib/yoti/protobuf/sharepubapi/IssuingAttributes_pb.rb,
lib/yoti/protobuf/sharepubapi/ThirdPartyAttribute_pb.rb

Defined Under Namespace

Modules: Attrpubapi, Compubapi, Sharepubapi

Constant Summary collapse

CT_UNDEFINED =

should not be seen, and is used as an error placeholder

:UNDEFINED
CT_STRING =

UTF-8 encoded text.

:STRING
CT_JPEG =

standard .jpeg image.

:JPEG
CT_DATE =

string in RFC3339 format (YYYY-MM-DD)

:DATE
CT_PNG =

standard .png image

:PNG
CT_JSON =

json_string

:JSON
CT_MULTI_VALUE =

multi value

:MULTI_VALUE
CT_INT =

integer

:INT

Class Method Summary collapse

Class Method Details

.application_profile(receipt) ⇒ Object



40
41
42
43
44
# File 'lib/yoti/protobuf/main.rb', line 40

def application_profile(receipt)
  return nil unless valid_receipt?(receipt)

  decipher_profile(receipt['profile_content'], receipt['wrapped_receipt_key'])
end

.attribute_list(data) ⇒ Object



52
53
54
# File 'lib/yoti/protobuf/main.rb', line 52

def attribute_list(data)
  Yoti::Protobuf::Attrpubapi::AttributeList.decode(data)
end

.current_user(receipt) ⇒ Object

Deprecated.

replaced by user_profile



28
29
30
31
32
# File 'lib/yoti/protobuf/main.rb', line 28

def current_user(receipt)
  return nil unless valid_receipt?(receipt)

  decode_profile(receipt['other_party_profile_content'])
end

.extra_data(receipt) ⇒ Object



46
47
48
49
50
# File 'lib/yoti/protobuf/main.rb', line 46

def extra_data(receipt)
  return nil if receipt['extra_data_content'].nil? || receipt['extra_data_content'] == ''

  decipher_extra_data(receipt['extra_data_content'], receipt['wrapped_receipt_key'])
end

.user_profile(receipt) ⇒ Object



34
35
36
37
38
# File 'lib/yoti/protobuf/main.rb', line 34

def (receipt)
  return nil unless valid_receipt?(receipt)

  decipher_profile(receipt['other_party_profile_content'], receipt['wrapped_receipt_key'])
end

.value_based_on_attribute_name(value, attr_name) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/yoti/protobuf/main.rb', line 56

def value_based_on_attribute_name(value, attr_name)
  case attr_name
  when Yoti::Attribute::DOCUMENT_DETAILS
    Yoti::DocumentDetails.new(value)
  when Yoti::Attribute::DOCUMENT_IMAGES
    raise(TypeError, 'Document Images could not be decoded') unless value.is_a?(Yoti::MultiValue)

    value.allow_type(Yoti::Image).items
  else
    value
  end
end

.value_based_on_content_type(value, content_type = nil) ⇒ Object

Raises:

  • (TypeError)


69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/yoti/protobuf/main.rb', line 69

def value_based_on_content_type(value, content_type = nil)
  raise(TypeError, 'Warning: value is NULL') if value.empty? && content_type != CT_STRING

  case content_type
  when CT_STRING, CT_DATE
    value.encode('utf-8')
  when CT_JSON
    JSON.parse(value)
  when CT_INT
    value.to_i
  when CT_JPEG
    Yoti::ImageJpeg.new(value)
  when CT_PNG
    Yoti::ImagePng.new(value)
  when CT_MULTI_VALUE
    convert_multi_value(value)
  else
    Yoti::Log.logger.warn("Unknown Content Type '#{content_type}', parsing as a String")
    value.encode('utf-8')
  end
end