yoti 1.6.4 → 1.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -1
  3. data/README.md +22 -224
  4. data/lib/yoti.rb +63 -1
  5. data/lib/yoti/activity_details.rb +3 -5
  6. data/lib/yoti/client.rb +13 -4
  7. data/lib/yoti/configuration.rb +8 -3
  8. data/lib/yoti/data_type/age_verification.rb +1 -1
  9. data/lib/yoti/data_type/base_profile.rb +1 -1
  10. data/lib/yoti/data_type/document_details.rb +1 -1
  11. data/lib/yoti/data_type/image.rb +4 -12
  12. data/lib/yoti/data_type/image_jpeg.rb +2 -0
  13. data/lib/yoti/data_type/image_png.rb +2 -0
  14. data/lib/yoti/data_type/media.rb +22 -0
  15. data/lib/yoti/data_type/signed_time_stamp.rb +1 -1
  16. data/lib/yoti/doc_scan/client.rb +191 -0
  17. data/lib/yoti/doc_scan/constants.rb +35 -0
  18. data/lib/yoti/doc_scan/errors.rb +81 -0
  19. data/lib/yoti/doc_scan/session/create/create_session_result.rb +50 -0
  20. data/lib/yoti/doc_scan/session/create/document_filter.rb +31 -0
  21. data/lib/yoti/doc_scan/session/create/document_restrictions_filter.rb +140 -0
  22. data/lib/yoti/doc_scan/session/create/notification_config.rb +142 -0
  23. data/lib/yoti/doc_scan/session/create/objective/objective.rb +31 -0
  24. data/lib/yoti/doc_scan/session/create/objective/proof_of_address_objective.rb +31 -0
  25. data/lib/yoti/doc_scan/session/create/orthogonal_restrictions_filter.rb +150 -0
  26. data/lib/yoti/doc_scan/session/create/requested_check.rb +39 -0
  27. data/lib/yoti/doc_scan/session/create/requested_document_authenticity_check.rb +95 -0
  28. data/lib/yoti/doc_scan/session/create/requested_face_match_check.rb +95 -0
  29. data/lib/yoti/doc_scan/session/create/requested_id_document_comparison_check.rb +53 -0
  30. data/lib/yoti/doc_scan/session/create/requested_liveness_check.rb +108 -0
  31. data/lib/yoti/doc_scan/session/create/requested_supplementary_doc_text_extraction_task.rb +94 -0
  32. data/lib/yoti/doc_scan/session/create/requested_task.rb +39 -0
  33. data/lib/yoti/doc_scan/session/create/requested_text_extraction_task.rb +116 -0
  34. data/lib/yoti/doc_scan/session/create/required_document.rb +31 -0
  35. data/lib/yoti/doc_scan/session/create/required_id_document.rb +53 -0
  36. data/lib/yoti/doc_scan/session/create/required_supplementary_document.rb +90 -0
  37. data/lib/yoti/doc_scan/session/create/sdk_config.rb +221 -0
  38. data/lib/yoti/doc_scan/session/create/session_specification.rb +221 -0
  39. data/lib/yoti/doc_scan/session/retrieve/authenticity_check_response.rb +12 -0
  40. data/lib/yoti/doc_scan/session/retrieve/breakdown_response.rb +38 -0
  41. data/lib/yoti/doc_scan/session/retrieve/check_response.rb +63 -0
  42. data/lib/yoti/doc_scan/session/retrieve/details_response.rb +28 -0
  43. data/lib/yoti/doc_scan/session/retrieve/document_fields_response.rb +21 -0
  44. data/lib/yoti/doc_scan/session/retrieve/document_id_photo_response.rb +21 -0
  45. data/lib/yoti/doc_scan/session/retrieve/face_map_response.rb +21 -0
  46. data/lib/yoti/doc_scan/session/retrieve/face_match_check_response.rb +12 -0
  47. data/lib/yoti/doc_scan/session/retrieve/file_response.rb +21 -0
  48. data/lib/yoti/doc_scan/session/retrieve/frame_response.rb +21 -0
  49. data/lib/yoti/doc_scan/session/retrieve/generated_check_response.rb +28 -0
  50. data/lib/yoti/doc_scan/session/retrieve/generated_media.rb +28 -0
  51. data/lib/yoti/doc_scan/session/retrieve/generated_supplementary_document_text_data_check_response.rb +12 -0
  52. data/lib/yoti/doc_scan/session/retrieve/generated_text_data_check_response.rb +12 -0
  53. data/lib/yoti/doc_scan/session/retrieve/get_session_result.rb +145 -0
  54. data/lib/yoti/doc_scan/session/retrieve/id_document_comparison_check_response.rb +12 -0
  55. data/lib/yoti/doc_scan/session/retrieve/id_document_resource_response.rb +57 -0
  56. data/lib/yoti/doc_scan/session/retrieve/liveness_check_response.rb +12 -0
  57. data/lib/yoti/doc_scan/session/retrieve/liveness_resource_response.rb +24 -0
  58. data/lib/yoti/doc_scan/session/retrieve/media_response.rb +38 -0
  59. data/lib/yoti/doc_scan/session/retrieve/page_response.rb +37 -0
  60. data/lib/yoti/doc_scan/session/retrieve/recommendation_response.rb +34 -0
  61. data/lib/yoti/doc_scan/session/retrieve/report_response.rb +31 -0
  62. data/lib/yoti/doc_scan/session/retrieve/resource_container.rb +69 -0
  63. data/lib/yoti/doc_scan/session/retrieve/resource_response.rb +41 -0
  64. data/lib/yoti/doc_scan/session/retrieve/supplementary_document_resource_response.rb +57 -0
  65. data/lib/yoti/doc_scan/session/retrieve/supplementary_document_text_data_check_response.rb +12 -0
  66. data/lib/yoti/doc_scan/session/retrieve/supplementary_document_text_extraction_task_response.rb +18 -0
  67. data/lib/yoti/doc_scan/session/retrieve/task_response.rb +89 -0
  68. data/lib/yoti/doc_scan/session/retrieve/text_data_check_response.rb +12 -0
  69. data/lib/yoti/doc_scan/session/retrieve/text_extraction_task_response.rb +18 -0
  70. data/lib/yoti/doc_scan/session/retrieve/zoom_liveness_resource_response.rb +33 -0
  71. data/lib/yoti/doc_scan/support/supported_documents.rb +60 -0
  72. data/lib/yoti/dynamic_share_service/dynamic_scenario.rb +5 -0
  73. data/lib/yoti/dynamic_share_service/extension/extension.rb +3 -0
  74. data/lib/yoti/dynamic_share_service/extension/location_constraint_extension.rb +3 -0
  75. data/lib/yoti/dynamic_share_service/extension/thirdparty_attribute_extension.rb +1 -1
  76. data/lib/yoti/dynamic_share_service/extension/transactional_flow_extension.rb +4 -0
  77. data/lib/yoti/dynamic_share_service/policy/dynamic_policy.rb +74 -9
  78. data/lib/yoti/dynamic_share_service/policy/wanted_anchor.rb +3 -0
  79. data/lib/yoti/dynamic_share_service/policy/wanted_attribute.rb +5 -0
  80. data/lib/yoti/dynamic_share_service/share_url.rb +26 -33
  81. data/lib/yoti/errors.rb +15 -2
  82. data/lib/yoti/http/aml_check_request.rb +12 -6
  83. data/lib/yoti/http/payloads/aml_address.rb +4 -0
  84. data/lib/yoti/http/payloads/aml_profile.rb +7 -1
  85. data/lib/yoti/http/profile_request.rb +11 -6
  86. data/lib/yoti/http/request.rb +219 -18
  87. data/lib/yoti/http/signed_request.rb +13 -4
  88. data/lib/yoti/protobuf/main.rb +8 -8
  89. data/lib/yoti/share/attribute_issuance_details.rb +6 -0
  90. data/lib/yoti/ssl.rb +4 -4
  91. data/lib/yoti/util/age_processor.rb +1 -1
  92. data/lib/yoti/util/anchor_processor.rb +2 -2
  93. data/lib/yoti/util/log.rb +1 -1
  94. data/lib/yoti/util/validation.rb +41 -0
  95. data/lib/yoti/version.rb +1 -1
  96. data/yoti.gemspec +18 -6
  97. metadata +69 -33
  98. data/.github/ISSUE_TEMPLATE.md +0 -17
  99. data/.gitignore +0 -39
  100. data/CONTRIBUTING.md +0 -98
  101. data/Guardfile +0 -11
  102. data/Rakefile +0 -54
  103. data/login_flow.png +0 -0
  104. data/rubocop.yml +0 -57
  105. data/yardstick.yml +0 -9
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Yoti
4
+ module DocScan
5
+ module Session
6
+ module Create
7
+ class DocumentFilter
8
+ #
9
+ # @param [String] type
10
+ #
11
+ def initialize(type)
12
+ raise(TypeError, "#{self.class} cannot be instantiated") if instance_of?(DocumentFilter)
13
+
14
+ Validation.assert_is_a(String, type, 'type')
15
+ @type = type
16
+ end
17
+
18
+ def to_json(*_args)
19
+ as_json.to_json
20
+ end
21
+
22
+ def as_json(*_args)
23
+ {
24
+ type: @type
25
+ }
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,140 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Yoti
4
+ module DocScan
5
+ module Session
6
+ module Create
7
+ class DocumentRestrictionsFilter < DocumentFilter
8
+ #
9
+ # @param [String] inclusion
10
+ # @param [Array<DocumentRestriction>] documents
11
+ #
12
+ def initialize(inclusion, documents)
13
+ super(Constants::DOCUMENT_RESTRICTIONS)
14
+
15
+ Validation.assert_is_a(String, inclusion, 'country_restriction')
16
+ @inclusion = inclusion
17
+
18
+ Validation.assert_is_a(Array, documents, 'documents')
19
+ @documents = documents
20
+ end
21
+
22
+ def as_json(*_args)
23
+ super.merge(
24
+ inclusion: @inclusion,
25
+ documents: @documents.map(&:as_json)
26
+ ).compact
27
+ end
28
+
29
+ #
30
+ # @return [DocumentRestrictionsFilterBuilder]
31
+ #
32
+ def self.builder
33
+ DocumentRestrictionsFilterBuilder.new
34
+ end
35
+ end
36
+
37
+ class DocumentRestrictionsFilterBuilder
38
+ def initialize
39
+ @documents = []
40
+ end
41
+
42
+ #
43
+ # @return [self]
44
+ #
45
+ def for_inclusion
46
+ @inclusion = Constants::INCLUDE
47
+ self
48
+ end
49
+
50
+ #
51
+ # @return [self]
52
+ #
53
+ def for_exclusion
54
+ @inclusion = Constants::EXCLUDE
55
+ self
56
+ end
57
+
58
+ #
59
+ # @param [DocumentRestriction] document_restriction
60
+ #
61
+ # @return [self]
62
+ #
63
+ def with_document_restriction(document_restriction)
64
+ Validation.assert_is_a(DocumentRestriction, document_restriction, 'document_restriction')
65
+ @documents.push(document_restriction)
66
+ self
67
+ end
68
+
69
+ #
70
+ # @return [DocumentRestrictionsFilter]
71
+ #
72
+ def build
73
+ DocumentRestrictionsFilter.new(@inclusion, @documents)
74
+ end
75
+ end
76
+
77
+ class DocumentRestriction
78
+ #
79
+ # @param [Array<String>] country_codes
80
+ # @param [Array<String>] document_types
81
+ #
82
+ def initialize(country_codes, document_types)
83
+ Validation.assert_is_a(Array, country_codes, 'country_codes', true)
84
+ @country_codes = country_codes
85
+
86
+ Validation.assert_is_a(Array, document_types, 'document_types', true)
87
+ @document_types = document_types
88
+ end
89
+
90
+ def to_json(*_args)
91
+ as_json.to_json
92
+ end
93
+
94
+ def as_json(*_args)
95
+ json = {}
96
+ json[:document_types] = @document_types unless @document_types.nil?
97
+ json[:country_codes] = @country_codes unless @country_codes.nil?
98
+ json
99
+ end
100
+
101
+ #
102
+ # @return [DocumentRestrictionBuilder]
103
+ #
104
+ def self.builder
105
+ DocumentRestrictionBuilder.new
106
+ end
107
+ end
108
+
109
+ class DocumentRestrictionBuilder
110
+ #
111
+ # @param [Array<String>] document_types
112
+ #
113
+ # @return [self]
114
+ #
115
+ def with_document_types(document_types)
116
+ @document_types = document_types
117
+ self
118
+ end
119
+
120
+ #
121
+ # @param [Array<String>] country_codes
122
+ #
123
+ # @return [self]
124
+ #
125
+ def with_countries(country_codes)
126
+ @country_codes = country_codes
127
+ self
128
+ end
129
+
130
+ #
131
+ # @return [DocumentRestriction]
132
+ #
133
+ def build
134
+ DocumentRestriction.new(@country_codes, @document_types)
135
+ end
136
+ end
137
+ end
138
+ end
139
+ end
140
+ end
@@ -0,0 +1,142 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Yoti
4
+ module DocScan
5
+ module Session
6
+ module Create
7
+ #
8
+ # Configures call-back Notifications to some backend endpoint provided
9
+ # by the Relying Business.
10
+ #
11
+ # Notifications can be configured to notified a client backend of certain
12
+ # events, avoiding the need to poll for the state of the Session.
13
+ #
14
+ class NotificationConfig
15
+ #
16
+ # @param [String] auth_token
17
+ # The authorization token to be included in call-back messages
18
+ # @param [String] endpoint
19
+ # The endpoint that notifications should be sent to
20
+ # @param [Array<String>] topics
21
+ # The list of topics that should trigger notifications
22
+ #
23
+ def initialize(auth_token, endpoint, topics)
24
+ Validation.assert_is_a(String, auth_token, 'auth_token', true)
25
+ @auth_token = auth_token
26
+
27
+ Validation.assert_is_a(String, endpoint, 'endpoint', true)
28
+ @endpoint = endpoint
29
+
30
+ Validation.assert_is_a(Array, topics, 'auth_token', true)
31
+ @topics = topics.uniq unless topics.nil?
32
+ end
33
+
34
+ def to_json(*_args)
35
+ as_json.to_json
36
+ end
37
+
38
+ def as_json(*_args)
39
+ {
40
+ auth_token: @auth_token,
41
+ endpoint: @endpoint,
42
+ topics: @topics
43
+ }.compact
44
+ end
45
+
46
+ #
47
+ # @return [NotificationConfigBuilder]
48
+ #
49
+ def self.builder
50
+ NotificationConfigBuilder.new
51
+ end
52
+ end
53
+
54
+ class NotificationConfigBuilder
55
+ def initialize
56
+ @topics = []
57
+ end
58
+
59
+ #
60
+ # Sets the authorization token to be included in call-back messages
61
+ #
62
+ # @param [String] auth_token
63
+ #
64
+ # @return [self]
65
+ #
66
+ def with_auth_token(auth_token)
67
+ @auth_token = auth_token
68
+ self
69
+ end
70
+
71
+ #
72
+ # Sets the endpoint that notifications should be sent to
73
+ #
74
+ # @param [String] endpoint
75
+ #
76
+ # @return [self]
77
+ #
78
+ def with_endpoint(endpoint)
79
+ @endpoint = endpoint
80
+ self
81
+ end
82
+
83
+ #
84
+ # Adds a topic to the list of topics that trigger notification messages
85
+ #
86
+ # @param [String] topic
87
+ #
88
+ # @return [self]
89
+ #
90
+ def with_topic(topic)
91
+ Validation.assert_is_a(String, topic, 'topic')
92
+ @topics.push(topic)
93
+ self
94
+ end
95
+
96
+ #
97
+ # Adds RESOURCE_UPDATE to the list of topics that trigger notification messages
98
+ #
99
+ # @return [self]
100
+ #
101
+ def for_resource_update
102
+ with_topic(Constants::RESOURCE_UPDATE)
103
+ end
104
+
105
+ #
106
+ # Adds TASK_COMPLETION to the list of topics that trigger notification messages
107
+ #
108
+ # @return [self]
109
+ #
110
+ def for_task_completion
111
+ with_topic(Constants::TASK_COMPLETION)
112
+ end
113
+
114
+ #
115
+ # Adds CHECK_COMPLETION to the list of topics that trigger notification messages
116
+ #
117
+ # @return [self]
118
+ #
119
+ def for_check_completion
120
+ with_topic(Constants::CHECK_COMPLETION)
121
+ end
122
+
123
+ #
124
+ # Adds SESSION_COMPLETION to the list of topics that trigger notification messages
125
+ #
126
+ # @return [self]
127
+ #
128
+ def for_session_completion
129
+ with_topic(Constants::SESSION_COMPLETION)
130
+ end
131
+
132
+ #
133
+ # @return [NotificationConfig]
134
+ #
135
+ def build
136
+ NotificationConfig.new(@auth_token, @endpoint, @topics)
137
+ end
138
+ end
139
+ end
140
+ end
141
+ end
142
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Yoti
4
+ module DocScan
5
+ module Session
6
+ module Create
7
+ class Objective
8
+ #
9
+ # @param [String] type
10
+ #
11
+ def initialize(type)
12
+ raise(TypeError, "#{self.class} cannot be instantiated") if instance_of?(Objective)
13
+
14
+ Validation.assert_is_a(String, type, 'type')
15
+ @type = type
16
+ end
17
+
18
+ def to_json(*_args)
19
+ as_json.to_json
20
+ end
21
+
22
+ def as_json(*_args)
23
+ {
24
+ type: @type
25
+ }
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Yoti
4
+ module DocScan
5
+ module Session
6
+ module Create
7
+ class ProofOfAddressObjective < Objective
8
+ def initialize
9
+ super(Constants::PROOF_OF_ADDRESS)
10
+ end
11
+
12
+ #
13
+ # @return [ProofOfAddressObjectiveBuilder]
14
+ #
15
+ def self.builder
16
+ ProofOfAddressObjectiveBuilder.new
17
+ end
18
+ end
19
+
20
+ class ProofOfAddressObjectiveBuilder
21
+ #
22
+ # @return [ProofOfAddressObjective]
23
+ #
24
+ def build
25
+ ProofOfAddressObjective.new
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,150 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Yoti
4
+ module DocScan
5
+ module Session
6
+ module Create
7
+ class OrthogonalRestrictionsFilter < DocumentFilter
8
+ #
9
+ # @param [CountryRestriction] country_restriction
10
+ # @param [TypeRestriction] type_restriction
11
+ #
12
+ def initialize(country_restriction, type_restriction)
13
+ super(Constants::ORTHOGONAL_RESTRICTIONS)
14
+
15
+ Validation.assert_is_a(CountryRestriction, country_restriction, 'country_restriction', true)
16
+ @country_restriction = country_restriction
17
+
18
+ Validation.assert_is_a(TypeRestriction, type_restriction, 'type_restriction', true)
19
+ @type_restriction = type_restriction
20
+ end
21
+
22
+ def as_json(*_args)
23
+ json = super
24
+ json[:country_restriction] = @country_restriction.as_json unless @country_restriction.nil?
25
+ json[:type_restriction] = @type_restriction.as_json unless @type_restriction.nil?
26
+ json
27
+ end
28
+
29
+ #
30
+ # @return [OrthogonalRestrictionsFilterBuilder]
31
+ #
32
+ def self.builder
33
+ OrthogonalRestrictionsFilterBuilder.new
34
+ end
35
+ end
36
+
37
+ class OrthogonalRestrictionsFilterBuilder
38
+ #
39
+ # @param [Array<String>] country_codes
40
+ #
41
+ # @return [self]
42
+ #
43
+ def with_included_countries(country_codes)
44
+ @country_restriction = CountryRestriction.new(
45
+ Constants::INCLUDE,
46
+ country_codes
47
+ )
48
+ self
49
+ end
50
+
51
+ #
52
+ # @param [Array<String>] country_codes
53
+ #
54
+ # @return [self]
55
+ #
56
+ def with_excluded_countries(country_codes)
57
+ @country_restriction = CountryRestriction.new(
58
+ Constants::EXCLUDE,
59
+ country_codes
60
+ )
61
+ self
62
+ end
63
+
64
+ #
65
+ # @param [Array<String>] document_types
66
+ #
67
+ # @return [self]
68
+ #
69
+ def with_included_document_types(document_types)
70
+ @type_restriction = TypeRestriction.new(
71
+ Constants::INCLUDE,
72
+ document_types
73
+ )
74
+ self
75
+ end
76
+
77
+ #
78
+ # @param [Array<String>] document_types
79
+ #
80
+ # @return [self]
81
+ #
82
+ def with_excluded_document_types(document_types)
83
+ @type_restriction = TypeRestriction.new(
84
+ Constants::EXCLUDE,
85
+ document_types
86
+ )
87
+ self
88
+ end
89
+
90
+ #
91
+ # @return [OrthogonalRestrictionsFilter]
92
+ #
93
+ def build
94
+ OrthogonalRestrictionsFilter.new(@country_restriction, @type_restriction)
95
+ end
96
+ end
97
+
98
+ class CountryRestriction
99
+ #
100
+ # @param [String] inclusion
101
+ # @param [Array<String>] country_codes
102
+ #
103
+ def initialize(inclusion, country_codes)
104
+ Validation.assert_is_a(String, inclusion, 'inclusion')
105
+ @inclusion = inclusion
106
+
107
+ Validation.assert_is_a(Array, country_codes, 'country_codes')
108
+ @country_codes = country_codes
109
+ end
110
+
111
+ def to_json(*_args)
112
+ as_json.to_json
113
+ end
114
+
115
+ def as_json(*_args)
116
+ {
117
+ inclusion: @inclusion,
118
+ country_codes: @country_codes
119
+ }
120
+ end
121
+ end
122
+
123
+ class TypeRestriction
124
+ #
125
+ # @param [String] inclusion
126
+ # @param [Array<String>] document_types
127
+ #
128
+ def initialize(inclusion, document_types)
129
+ Validation.assert_is_a(String, inclusion, 'inclusion')
130
+ @inclusion = inclusion
131
+
132
+ Validation.assert_is_a(Array, document_types, 'document_types')
133
+ @document_types = document_types
134
+ end
135
+
136
+ def to_json(*_args)
137
+ as_json.to_json
138
+ end
139
+
140
+ def as_json(*_args)
141
+ {
142
+ inclusion: @inclusion,
143
+ document_types: @document_types
144
+ }
145
+ end
146
+ end
147
+ end
148
+ end
149
+ end
150
+ end