yoti 1.6.1 → 1.7.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +5 -5
  2. data/.github/ISSUE_TEMPLATE.md +17 -0
  3. data/.gitignore +1 -0
  4. data/CONTRIBUTING.md +1 -30
  5. data/README.md +23 -224
  6. data/Rakefile +9 -8
  7. data/lib/yoti.rb +50 -1
  8. data/lib/yoti/activity_details.rb +1 -0
  9. data/lib/yoti/client.rb +13 -4
  10. data/lib/yoti/configuration.rb +7 -2
  11. data/lib/yoti/data_type/age_verification.rb +1 -1
  12. data/lib/yoti/data_type/base_profile.rb +1 -1
  13. data/lib/yoti/data_type/document_details.rb +5 -13
  14. data/lib/yoti/data_type/image.rb +4 -12
  15. data/lib/yoti/data_type/image_jpeg.rb +2 -0
  16. data/lib/yoti/data_type/image_png.rb +2 -0
  17. data/lib/yoti/data_type/media.rb +19 -0
  18. data/lib/yoti/doc_scan/client.rb +163 -0
  19. data/lib/yoti/doc_scan/constants.rb +28 -0
  20. data/lib/yoti/doc_scan/session/create/create_session_result.rb +50 -0
  21. data/lib/yoti/doc_scan/session/create/document_filter.rb +31 -0
  22. data/lib/yoti/doc_scan/session/create/document_restrictions_filter.rb +140 -0
  23. data/lib/yoti/doc_scan/session/create/notification_config.rb +142 -0
  24. data/lib/yoti/doc_scan/session/create/orthogonal_restrictions_filter.rb +150 -0
  25. data/lib/yoti/doc_scan/session/create/requested_check.rb +39 -0
  26. data/lib/yoti/doc_scan/session/create/requested_document_authenticity_check.rb +53 -0
  27. data/lib/yoti/doc_scan/session/create/requested_face_match_check.rb +95 -0
  28. data/lib/yoti/doc_scan/session/create/requested_liveness_check.rb +108 -0
  29. data/lib/yoti/doc_scan/session/create/requested_task.rb +39 -0
  30. data/lib/yoti/doc_scan/session/create/requested_text_extraction_task.rb +94 -0
  31. data/lib/yoti/doc_scan/session/create/required_document.rb +31 -0
  32. data/lib/yoti/doc_scan/session/create/required_id_document.rb +53 -0
  33. data/lib/yoti/doc_scan/session/create/sdk_config.rb +221 -0
  34. data/lib/yoti/doc_scan/session/create/session_specification.rb +203 -0
  35. data/lib/yoti/doc_scan/session/retrieve/authenticity_check_response.rb +12 -0
  36. data/lib/yoti/doc_scan/session/retrieve/breakdown_response.rb +38 -0
  37. data/lib/yoti/doc_scan/session/retrieve/check_response.rb +63 -0
  38. data/lib/yoti/doc_scan/session/retrieve/details_response.rb +28 -0
  39. data/lib/yoti/doc_scan/session/retrieve/document_fields_response.rb +21 -0
  40. data/lib/yoti/doc_scan/session/retrieve/face_map_response.rb +21 -0
  41. data/lib/yoti/doc_scan/session/retrieve/face_match_check_response.rb +12 -0
  42. data/lib/yoti/doc_scan/session/retrieve/frame_response.rb +21 -0
  43. data/lib/yoti/doc_scan/session/retrieve/generated_check_response.rb +28 -0
  44. data/lib/yoti/doc_scan/session/retrieve/generated_media.rb +28 -0
  45. data/lib/yoti/doc_scan/session/retrieve/generated_text_data_check_response.rb +12 -0
  46. data/lib/yoti/doc_scan/session/retrieve/get_session_result.rb +113 -0
  47. data/lib/yoti/doc_scan/session/retrieve/id_document_resource_response.rb +52 -0
  48. data/lib/yoti/doc_scan/session/retrieve/liveness_check_response.rb +12 -0
  49. data/lib/yoti/doc_scan/session/retrieve/liveness_resource_response.rb +24 -0
  50. data/lib/yoti/doc_scan/session/retrieve/media_response.rb +38 -0
  51. data/lib/yoti/doc_scan/session/retrieve/page_response.rb +27 -0
  52. data/lib/yoti/doc_scan/session/retrieve/recommendation_response.rb +34 -0
  53. data/lib/yoti/doc_scan/session/retrieve/report_response.rb +31 -0
  54. data/lib/yoti/doc_scan/session/retrieve/resource_container.rb +50 -0
  55. data/lib/yoti/doc_scan/session/retrieve/resource_response.rb +39 -0
  56. data/lib/yoti/doc_scan/session/retrieve/task_response.rb +87 -0
  57. data/lib/yoti/doc_scan/session/retrieve/text_data_check_response.rb +12 -0
  58. data/lib/yoti/doc_scan/session/retrieve/text_extraction_task_response.rb +18 -0
  59. data/lib/yoti/doc_scan/session/retrieve/zoom_liveness_resource_response.rb +33 -0
  60. data/lib/yoti/doc_scan/support/supported_documents.rb +60 -0
  61. data/lib/yoti/dynamic_share_service/extension/thirdparty_attribute_extension.rb +62 -11
  62. data/lib/yoti/dynamic_share_service/policy/dynamic_policy.rb +17 -17
  63. data/lib/yoti/dynamic_share_service/share_url.rb +28 -33
  64. data/lib/yoti/errors.rb +17 -2
  65. data/lib/yoti/http/aml_check_request.rb +12 -6
  66. data/lib/yoti/http/payloads/aml_address.rb +4 -0
  67. data/lib/yoti/http/payloads/aml_profile.rb +7 -1
  68. data/lib/yoti/http/profile_request.rb +11 -6
  69. data/lib/yoti/http/request.rb +221 -18
  70. data/lib/yoti/http/signed_request.rb +13 -4
  71. data/lib/yoti/protobuf/main.rb +1 -1
  72. data/lib/yoti/ssl.rb +3 -2
  73. data/lib/yoti/util/anchor_processor.rb +1 -1
  74. data/lib/yoti/util/validation.rb +41 -0
  75. data/lib/yoti/version.rb +1 -1
  76. data/rubocop.yml +9 -1
  77. data/yoti.gemspec +5 -8
  78. metadata +53 -63
  79. data/lib/yoti/sandbox.rb +0 -5
  80. data/lib/yoti/sandbox/anchor.rb +0 -49
  81. data/lib/yoti/sandbox/attribute.rb +0 -52
  82. data/lib/yoti/sandbox/profile.rb +0 -171
  83. data/lib/yoti/sandbox/sandbox.rb +0 -105
  84. data/lib/yoti/sandbox/sandbox_client.rb +0 -45
  85. data/login_flow.png +0 -0
@@ -0,0 +1,221 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Yoti
4
+ module DocScan
5
+ module Session
6
+ module Create
7
+ class SdkConfig
8
+ #
9
+ # @param [String] allowed_capture_methods
10
+ # @param [String] primary_colour
11
+ # @param [String] secondary_colour
12
+ # @param [String] font_colour
13
+ # @param [String] locale
14
+ # @param [String] preset_issuing_country
15
+ # @param [String] success_url
16
+ # @param [String] error_url
17
+ #
18
+ def initialize(
19
+ allowed_capture_methods,
20
+ primary_colour,
21
+ secondary_colour,
22
+ font_colour,
23
+ locale,
24
+ preset_issuing_country,
25
+ success_url,
26
+ error_url
27
+ )
28
+ Validation.assert_is_a(String, allowed_capture_methods, 'allowed_capture_methods', true)
29
+ @allowed_capture_methods = allowed_capture_methods
30
+
31
+ Validation.assert_is_a(String, primary_colour, 'primary_colour', true)
32
+ @primary_colour = primary_colour
33
+
34
+ Validation.assert_is_a(String, secondary_colour, 'secondary_colour', true)
35
+ @secondary_colour = secondary_colour
36
+
37
+ Validation.assert_is_a(String, font_colour, 'font_colour', true)
38
+ @font_colour = font_colour
39
+
40
+ Validation.assert_is_a(String, locale, 'locale', true)
41
+ @locale = locale
42
+
43
+ Validation.assert_is_a(String, preset_issuing_country, 'preset_issuing_country', true)
44
+ @preset_issuing_country = preset_issuing_country
45
+
46
+ Validation.assert_is_a(String, success_url, 'success_url', true)
47
+ @success_url = success_url
48
+
49
+ Validation.assert_is_a(String, error_url, 'error_url', true)
50
+ @error_url = error_url
51
+ end
52
+
53
+ def to_json(*_args)
54
+ as_json.to_json
55
+ end
56
+
57
+ def as_json(*_args)
58
+ {
59
+ allowed_capture_methods: @allowed_capture_methods,
60
+ primary_colour: @primary_colour,
61
+ secondary_colour: @secondary_colour,
62
+ font_colour: @font_colour,
63
+ locale: @locale,
64
+ preset_issuing_country: @preset_issuing_country,
65
+ success_url: @success_url,
66
+ error_url: @error_url
67
+ }.compact
68
+ end
69
+
70
+ #
71
+ # @return [SdkConfigBuilder]
72
+ #
73
+ def self.builder
74
+ SdkConfigBuilder.new
75
+ end
76
+ end
77
+
78
+ #
79
+ # Builder to assist in the creation of {SdkConfig}.
80
+ #
81
+ class SdkConfigBuilder
82
+ def initialize
83
+ @topics = []
84
+ end
85
+
86
+ #
87
+ # Sets the allowed capture method to "CAMERA"
88
+ #
89
+ # @return [self]
90
+ #
91
+ def with_allows_camera
92
+ with_allowed_capture_methods(Constants::CAMERA)
93
+ end
94
+
95
+ #
96
+ # Sets the allowed capture method to "CAMERA_AND_UPLOAD"
97
+ #
98
+ # @return [self]
99
+ #
100
+ def with_allows_camera_and_upload
101
+ with_allowed_capture_methods(Constants::CAMERA_AND_UPLOAD)
102
+ end
103
+
104
+ #
105
+ # Sets the allowed capture method
106
+ #
107
+ # @param [String] allowed_capture_methods
108
+ #
109
+ # @return [self]
110
+ #
111
+ def with_allowed_capture_methods(allowed_capture_methods)
112
+ @allowed_capture_methods = allowed_capture_methods
113
+ self
114
+ end
115
+
116
+ #
117
+ # Sets the primary colour to be used by the web/native client
118
+ #
119
+ # @param [String] primary_colour
120
+ #
121
+ # @return [self]
122
+ #
123
+ def with_primary_colour(primary_colour)
124
+ @primary_colour = primary_colour
125
+ self
126
+ end
127
+
128
+ #
129
+ # Sets the secondary colour to be used by the web/native client (used on the button)
130
+ #
131
+ # @param [String] secondary_colour
132
+ #
133
+ # @return [self]
134
+ #
135
+ def with_secondary_colour(secondary_colour)
136
+ @secondary_colour = secondary_colour
137
+ self
138
+ end
139
+
140
+ #
141
+ # Sets the font colour to be used by the web/native client (used on the button)
142
+ #
143
+ # @param [String] font_colour
144
+ #
145
+ # @return [self]
146
+ #
147
+ def with_font_colour(font_colour)
148
+ @font_colour = font_colour
149
+ self
150
+ end
151
+
152
+ #
153
+ # Sets the locale on the builder
154
+ #
155
+ # @param [String] locale
156
+ #
157
+ # @return [self]
158
+ #
159
+ def with_locale(locale)
160
+ @locale = locale
161
+ self
162
+ end
163
+
164
+ #
165
+ # Sets the preset issuing country on the builder
166
+ #
167
+ # @param [String] preset_issuing_country
168
+ #
169
+ # @return [self]
170
+ #
171
+ def with_preset_issuing_country(preset_issuing_country)
172
+ @preset_issuing_country = preset_issuing_country
173
+ self
174
+ end
175
+
176
+ #
177
+ # Sets the success URL for the redirect that follows the web/native client
178
+ # uploading documents successfully
179
+ #
180
+ # @param [String] success_url
181
+ #
182
+ # @return [self]
183
+ #
184
+ def with_success_url(success_url)
185
+ @success_url = success_url
186
+ self
187
+ end
188
+
189
+ #
190
+ # Sets the error URL for the redirect that follows the web/native client
191
+ # uploading documents unsuccessfully
192
+ #
193
+ # @param [String] error_url
194
+ #
195
+ # @return [self]
196
+ #
197
+ def with_error_url(error_url)
198
+ @error_url = error_url
199
+ self
200
+ end
201
+
202
+ #
203
+ # @return [SdkConfig]
204
+ #
205
+ def build
206
+ SdkConfig.new(
207
+ @allowed_capture_methods,
208
+ @primary_colour,
209
+ @secondary_colour,
210
+ @font_colour,
211
+ @locale,
212
+ @preset_issuing_country,
213
+ @success_url,
214
+ @error_url
215
+ )
216
+ end
217
+ end
218
+ end
219
+ end
220
+ end
221
+ end
@@ -0,0 +1,203 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Yoti
4
+ module DocScan
5
+ module Session
6
+ module Create
7
+ class SessionSpecification
8
+ #
9
+ # @param [Integer] client_session_token_ttl
10
+ # @param [Integer] resources_ttl
11
+ # @param [String] user_tracking_id
12
+ # @param [NotificationConfig] notifications
13
+ # @param [Array<RequestedCheck>] requested_checks
14
+ # @param [Array<RequestedTask>] requested_tasks
15
+ # @param [SdkConfig] sdk_config
16
+ # @param [Array<RequiredDocument>] required_documents
17
+ #
18
+ def initialize(
19
+ client_session_token_ttl,
20
+ resources_ttl,
21
+ user_tracking_id,
22
+ notifications,
23
+ requested_checks,
24
+ requested_tasks,
25
+ sdk_config,
26
+ required_documents
27
+ )
28
+ Validation.assert_is_a(Integer, client_session_token_ttl, 'client_session_token_ttl', true)
29
+ @client_session_token_ttl = client_session_token_ttl
30
+
31
+ Validation.assert_is_a(Integer, resources_ttl, 'resources_ttl', true)
32
+ @resources_ttl = resources_ttl
33
+
34
+ Validation.assert_is_a(String, user_tracking_id, 'user_tracking_id', true)
35
+ @user_tracking_id = user_tracking_id
36
+
37
+ Validation.assert_is_a(NotificationConfig, notifications, 'notifications', true)
38
+ @notifications = notifications
39
+
40
+ Validation.assert_is_a(Array, requested_checks, 'requested_checks', true)
41
+ @requested_checks = requested_checks
42
+
43
+ Validation.assert_is_a(Array, requested_tasks, 'requested_tasks', true)
44
+ @requested_tasks = requested_tasks
45
+
46
+ Validation.assert_is_a(SdkConfig, sdk_config, 'sdk_config', true)
47
+ @sdk_config = sdk_config
48
+
49
+ Validation.assert_is_a(Array, required_documents, 'required_documents', true)
50
+ @required_documents = required_documents
51
+ end
52
+
53
+ def to_json(*_args)
54
+ as_json.to_json
55
+ end
56
+
57
+ def as_json(*_args)
58
+ {
59
+ client_session_token_ttl: @client_session_token_ttl,
60
+ resources_ttl: @resources_ttl,
61
+ user_tracking_id: @user_tracking_id,
62
+ notifications: @notifications,
63
+ requested_checks: @requested_checks.map(&:as_json),
64
+ requested_tasks: @requested_tasks.map(&:as_json),
65
+ sdk_config: @sdk_config,
66
+ required_documents: @required_documents.map(&:as_json)
67
+ }.compact
68
+ end
69
+
70
+ #
71
+ # @return [SessionSpecificationBuilder]
72
+ #
73
+ def self.builder
74
+ SessionSpecificationBuilder.new
75
+ end
76
+ end
77
+
78
+ class SessionSpecificationBuilder
79
+ def initialize
80
+ @requested_checks = []
81
+ @requested_tasks = []
82
+ @required_documents = []
83
+ end
84
+
85
+ #
86
+ # Client-session-token time-to-live to apply to the created session
87
+ #
88
+ # @param [Integer] client_session_token_ttl
89
+ #
90
+ # @return [self]
91
+ #
92
+ def with_client_session_token_ttl(client_session_token_ttl)
93
+ @client_session_token_ttl = client_session_token_ttl
94
+ self
95
+ end
96
+
97
+ #
98
+ # Time-to-live used for all Resources created in the course of the session
99
+ #
100
+ # @param [Integer] resources_ttl
101
+ #
102
+ # @return [self]
103
+ #
104
+ def with_resources_ttl(resources_ttl)
105
+ @resources_ttl = resources_ttl
106
+ self
107
+ end
108
+
109
+ #
110
+ # User tracking id, for the Relying Business to track returning users
111
+ #
112
+ # @param [String] user_tracking_id
113
+ #
114
+ # @return [self]
115
+ #
116
+ def with_user_tracking_id(user_tracking_id)
117
+ @user_tracking_id = user_tracking_id
118
+ self
119
+ end
120
+
121
+ #
122
+ # For configuring call-back messages
123
+ #
124
+ # @param [NotificationConfig] notifications
125
+ #
126
+ # @return [self]
127
+ #
128
+ def with_notifications(notifications)
129
+ @notifications = notifications
130
+ self
131
+ end
132
+
133
+ #
134
+ # The check to be performed on each Document
135
+ #
136
+ # @param [RequestedCheck] requested_check
137
+ #
138
+ # @return [self]
139
+ #
140
+ def with_requested_check(requested_check)
141
+ Validation.assert_is_a(RequestedCheck, requested_check, 'requested_check')
142
+ @requested_checks.push(requested_check)
143
+ self
144
+ end
145
+
146
+ #
147
+ # The task to be performed on each Document
148
+ #
149
+ # @param [RequestedTask] requested_task
150
+ #
151
+ # @return [self]
152
+ #
153
+ def with_requested_task(requested_task)
154
+ Validation.assert_is_a(RequestedTask, requested_task, 'requested_task')
155
+ @requested_tasks.push(requested_task)
156
+ self
157
+ end
158
+
159
+ #
160
+ # The SDK configuration set on the session specification
161
+ #
162
+ # @param [SdkConfig] sdk_config
163
+ #
164
+ # @return [self]
165
+ #
166
+ def with_sdk_config(sdk_config)
167
+ @sdk_config = sdk_config
168
+ self
169
+ end
170
+
171
+ #
172
+ # Adds a RequiredDocument to the list documents required from the client
173
+ #
174
+ # @param [RequiredDocument] required_document
175
+ #
176
+ # @return [self]
177
+ #
178
+ def with_required_document(required_document)
179
+ Validation.assert_is_a(RequiredDocument, required_document, 'required_document')
180
+ @required_documents.push(required_document)
181
+ self
182
+ end
183
+
184
+ #
185
+ # @return [SessionSpecification]
186
+ #
187
+ def build
188
+ SessionSpecification.new(
189
+ @client_session_token_ttl,
190
+ @resources_ttl,
191
+ @user_tracking_id,
192
+ @notifications,
193
+ @requested_checks,
194
+ @requested_tasks,
195
+ @sdk_config,
196
+ @required_documents
197
+ )
198
+ end
199
+ end
200
+ end
201
+ end
202
+ end
203
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Yoti
4
+ module DocScan
5
+ module Session
6
+ module Retrieve
7
+ class AuthenticityCheckResponse < CheckResponse
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Yoti
4
+ module DocScan
5
+ module Session
6
+ module Retrieve
7
+ class BreakdownResponse
8
+ # @return [String]
9
+ attr_reader :sub_check
10
+
11
+ # @return [String]
12
+ attr_reader :result
13
+
14
+ # @return [Array<DetailsResponse>]
15
+ attr_reader :details
16
+
17
+ #
18
+ # @param [Hash] breakdown
19
+ #
20
+ def initialize(breakdown)
21
+ Validation.assert_is_a(String, breakdown['sub_check'], 'sub_check', true)
22
+ @sub_check = breakdown['sub_check']
23
+
24
+ Validation.assert_is_a(String, breakdown['result'], 'result', true)
25
+ @result = breakdown['result']
26
+
27
+ if breakdown['details'].nil?
28
+ @details = []
29
+ else
30
+ Validation.assert_is_a(Array, breakdown['details'], 'details')
31
+ @details = breakdown['details'].map { |details| DetailsResponse.new(details) }
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end