yoti 1.6.0 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. checksums.yaml +5 -5
  2. data/.github/ISSUE_TEMPLATE.md +17 -0
  3. data/CONTRIBUTING.md +0 -29
  4. data/README.md +4 -0
  5. data/Rakefile +7 -10
  6. data/lib/yoti.rb +50 -1
  7. data/lib/yoti/activity_details.rb +5 -1
  8. data/lib/yoti/client.rb +13 -4
  9. data/lib/yoti/configuration.rb +7 -2
  10. data/lib/yoti/data_type/age_verification.rb +1 -1
  11. data/lib/yoti/data_type/base_profile.rb +1 -1
  12. data/lib/yoti/data_type/document_details.rb +5 -13
  13. data/lib/yoti/data_type/image.rb +4 -12
  14. data/lib/yoti/data_type/image_jpeg.rb +2 -0
  15. data/lib/yoti/data_type/image_png.rb +2 -0
  16. data/lib/yoti/data_type/media.rb +19 -0
  17. data/lib/yoti/doc_scan/client.rb +163 -0
  18. data/lib/yoti/doc_scan/constants.rb +28 -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/orthogonal_restrictions_filter.rb +150 -0
  24. data/lib/yoti/doc_scan/session/create/requested_check.rb +39 -0
  25. data/lib/yoti/doc_scan/session/create/requested_document_authenticity_check.rb +53 -0
  26. data/lib/yoti/doc_scan/session/create/requested_face_match_check.rb +95 -0
  27. data/lib/yoti/doc_scan/session/create/requested_liveness_check.rb +108 -0
  28. data/lib/yoti/doc_scan/session/create/requested_task.rb +39 -0
  29. data/lib/yoti/doc_scan/session/create/requested_text_extraction_task.rb +94 -0
  30. data/lib/yoti/doc_scan/session/create/required_document.rb +31 -0
  31. data/lib/yoti/doc_scan/session/create/required_id_document.rb +53 -0
  32. data/lib/yoti/doc_scan/session/create/sdk_config.rb +221 -0
  33. data/lib/yoti/doc_scan/session/create/session_specification.rb +203 -0
  34. data/lib/yoti/doc_scan/session/retrieve/authenticity_check_response.rb +12 -0
  35. data/lib/yoti/doc_scan/session/retrieve/breakdown_response.rb +38 -0
  36. data/lib/yoti/doc_scan/session/retrieve/check_response.rb +63 -0
  37. data/lib/yoti/doc_scan/session/retrieve/details_response.rb +28 -0
  38. data/lib/yoti/doc_scan/session/retrieve/document_fields_response.rb +21 -0
  39. data/lib/yoti/doc_scan/session/retrieve/face_map_response.rb +21 -0
  40. data/lib/yoti/doc_scan/session/retrieve/face_match_check_response.rb +12 -0
  41. data/lib/yoti/doc_scan/session/retrieve/frame_response.rb +21 -0
  42. data/lib/yoti/doc_scan/session/retrieve/generated_check_response.rb +28 -0
  43. data/lib/yoti/doc_scan/session/retrieve/generated_media.rb +28 -0
  44. data/lib/yoti/doc_scan/session/retrieve/generated_text_data_check_response.rb +12 -0
  45. data/lib/yoti/doc_scan/session/retrieve/get_session_result.rb +113 -0
  46. data/lib/yoti/doc_scan/session/retrieve/id_document_resource_response.rb +52 -0
  47. data/lib/yoti/doc_scan/session/retrieve/liveness_check_response.rb +12 -0
  48. data/lib/yoti/doc_scan/session/retrieve/liveness_resource_response.rb +24 -0
  49. data/lib/yoti/doc_scan/session/retrieve/media_response.rb +38 -0
  50. data/lib/yoti/doc_scan/session/retrieve/page_response.rb +27 -0
  51. data/lib/yoti/doc_scan/session/retrieve/recommendation_response.rb +34 -0
  52. data/lib/yoti/doc_scan/session/retrieve/report_response.rb +31 -0
  53. data/lib/yoti/doc_scan/session/retrieve/resource_container.rb +50 -0
  54. data/lib/yoti/doc_scan/session/retrieve/resource_response.rb +39 -0
  55. data/lib/yoti/doc_scan/session/retrieve/task_response.rb +87 -0
  56. data/lib/yoti/doc_scan/session/retrieve/text_data_check_response.rb +12 -0
  57. data/lib/yoti/doc_scan/session/retrieve/text_extraction_task_response.rb +18 -0
  58. data/lib/yoti/doc_scan/session/retrieve/zoom_liveness_resource_response.rb +33 -0
  59. data/lib/yoti/doc_scan/support/supported_documents.rb +60 -0
  60. data/lib/yoti/dynamic_share_service/extension/thirdparty_attribute_extension.rb +73 -12
  61. data/lib/yoti/dynamic_share_service/policy/dynamic_policy.rb +17 -17
  62. data/lib/yoti/dynamic_share_service/share_url.rb +28 -33
  63. data/lib/yoti/errors.rb +17 -2
  64. data/lib/yoti/http/aml_check_request.rb +12 -6
  65. data/lib/yoti/http/payloads/aml_address.rb +4 -0
  66. data/lib/yoti/http/payloads/aml_profile.rb +7 -1
  67. data/lib/yoti/http/profile_request.rb +11 -6
  68. data/lib/yoti/http/request.rb +220 -18
  69. data/lib/yoti/http/signed_request.rb +13 -4
  70. data/lib/yoti/protobuf/main.rb +16 -6
  71. data/lib/yoti/share/attribute_issuance_details.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 +2 -5
  78. metadata +51 -60
  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
@@ -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
@@ -0,0 +1,63 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Yoti
4
+ module DocScan
5
+ module Session
6
+ module Retrieve
7
+ class CheckResponse
8
+ # @return [String]
9
+ attr_reader :type
10
+
11
+ # @return [String]
12
+ attr_reader :id
13
+
14
+ # @return [String]
15
+ attr_reader :state
16
+
17
+ # @return [Array<String>]
18
+ attr_reader :resources_used
19
+
20
+ # @return [Array<GeneratedMedia>]
21
+ attr_reader :generated_media
22
+
23
+ # @return [<ReportResponse>]
24
+ attr_reader :report
25
+
26
+ # @return [<DateTime>]
27
+ attr_reader :created
28
+
29
+ # @return [<DateTime>]
30
+ attr_reader :last_updated
31
+
32
+ #
33
+ # @param [Hash] check
34
+ #
35
+ def initialize(check)
36
+ Validation.assert_is_a(String, check['type'], 'type', true)
37
+ @type = check['type']
38
+
39
+ Validation.assert_is_a(String, check['id'], 'id', true)
40
+ @id = check['id']
41
+
42
+ Validation.assert_is_a(String, check['state'], 'state', true)
43
+ @state = check['state']
44
+
45
+ Validation.assert_is_a(Array, check['resources_used'], 'resources_used', true)
46
+ @resources_used = check['resources_used']
47
+
48
+ if check['generated_media'].nil?
49
+ @generated_media = []
50
+ else
51
+ Validation.assert_is_a(Array, check['generated_media'], 'generated_media')
52
+ @generated_media = check['generated_media'].map { |media| GeneratedMedia.new(media) }
53
+ end
54
+
55
+ @report = ReportResponse.new(check['report']) unless check['report'].nil?
56
+ @created = DateTime.parse(check['created']) unless check['created'].nil?
57
+ @last_updated = DateTime.parse(check['last_updated']) unless check['last_updated'].nil?
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Yoti
4
+ module DocScan
5
+ module Session
6
+ module Retrieve
7
+ class DetailsResponse
8
+ # @return [String]
9
+ attr_reader :name
10
+
11
+ # @return [String]
12
+ attr_reader :value
13
+
14
+ #
15
+ # @param [Hash] details
16
+ #
17
+ def initialize(details)
18
+ Validation.assert_is_a(String, details['name'], 'name', true)
19
+ @name = details['name']
20
+
21
+ Validation.assert_is_a(String, details['value'], 'value', true)
22
+ @value = details['value']
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Yoti
4
+ module DocScan
5
+ module Session
6
+ module Retrieve
7
+ class DocumentFieldsResponse
8
+ # @return [MediaResponse]
9
+ attr_reader :media
10
+
11
+ #
12
+ # @param [Hash] document_fields
13
+ #
14
+ def initialize(document_fields)
15
+ @media = MediaResponse.new(document_fields['media']) unless document_fields['media'].nil?
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Yoti
4
+ module DocScan
5
+ module Session
6
+ module Retrieve
7
+ class FaceMapResponse
8
+ # @return [MediaResponse]
9
+ attr_reader :media
10
+
11
+ #
12
+ # @param [Hash] facemap
13
+ #
14
+ def initialize(facemap)
15
+ @media = MediaResponse.new(facemap['media']) unless facemap['media'].nil?
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ 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 FaceMatchCheckResponse < CheckResponse
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Yoti
4
+ module DocScan
5
+ module Session
6
+ module Retrieve
7
+ class FrameResponse
8
+ # @return [MediaResponse]
9
+ attr_reader :media
10
+
11
+ #
12
+ # @param [Hash] frame
13
+ #
14
+ def initialize(frame)
15
+ @media = MediaResponse.new(frame['media']) unless frame['media'].nil?
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Yoti
4
+ module DocScan
5
+ module Session
6
+ module Retrieve
7
+ class GeneratedCheckResponse
8
+ # @return [String]
9
+ attr_reader :id
10
+
11
+ # @return [String]
12
+ attr_reader :type
13
+
14
+ #
15
+ # @param [Hash] check
16
+ #
17
+ def initialize(check)
18
+ Validation.assert_is_a(String, check['id'], 'id', true)
19
+ @id = check['id']
20
+
21
+ Validation.assert_is_a(String, check['type'], 'type', true)
22
+ @type = check['type']
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Yoti
4
+ module DocScan
5
+ module Session
6
+ module Retrieve
7
+ class GeneratedMedia
8
+ # @return [String]
9
+ attr_reader :id
10
+
11
+ # @return [String]
12
+ attr_reader :type
13
+
14
+ #
15
+ # @param [Hash] media
16
+ #
17
+ def initialize(media)
18
+ Validation.assert_is_a(String, media['id'], 'id', true)
19
+ @id = media['id']
20
+
21
+ Validation.assert_is_a(String, media['type'], 'type', true)
22
+ @type = media['type']
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ 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 GeneratedTextDataCheckResponse < GeneratedCheckResponse
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,113 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Yoti
4
+ module DocScan
5
+ module Session
6
+ module Retrieve
7
+ class GetSessionResult
8
+ # @return [Integer]
9
+ attr_reader :client_session_token_ttl
10
+
11
+ # @return [String]
12
+ attr_reader :client_session_token
13
+
14
+ # @return [String]
15
+ attr_reader :session_id
16
+
17
+ # @return [String]
18
+ attr_reader :user_tracking_id
19
+
20
+ # @return [String]
21
+ attr_reader :state
22
+
23
+ # @return [Array<CheckResponse>]
24
+ attr_reader :checks
25
+
26
+ # @return [ResourceContainer]
27
+ attr_reader :resources
28
+
29
+ #
30
+ # @param [Hash] response
31
+ #
32
+ def initialize(response)
33
+ Validation.assert_is_a(Integer, response['client_session_token_ttl'], 'client_session_token_ttl', true)
34
+ @client_session_token_ttl = response['client_session_token_ttl']
35
+
36
+ Validation.assert_is_a(String, response['session_id'], 'session_id', true)
37
+ @session_id = response['session_id']
38
+
39
+ Validation.assert_is_a(String, response['user_tracking_id'], 'user_tracking_id', true)
40
+ @user_tracking_id = response['user_tracking_id']
41
+
42
+ Validation.assert_is_a(String, response['state'], 'state', true)
43
+ @state = response['state']
44
+
45
+ Validation.assert_is_a(String, response['client_session_token'], 'client_session_token', true)
46
+ @client_session_token = response['client_session_token']
47
+
48
+ if response['checks'].nil?
49
+ @checks = []
50
+ else
51
+ Validation.assert_is_a(Array, response['checks'], 'checks')
52
+ @checks = map_checks(response['checks'])
53
+ end
54
+
55
+ @resources = ResourceContainer.new(response['resources']) unless response['resources'].nil?
56
+ end
57
+
58
+ #
59
+ # @return [Array<AuthenticityCheckResponse>]
60
+ #
61
+ def authenticity_checks
62
+ @checks.select { |check| check.is_a?(AuthenticityCheckResponse) }
63
+ end
64
+
65
+ #
66
+ # @return [Array<FaceMatchCheckResponse>]
67
+ #
68
+ def face_match_checks
69
+ @checks.select { |check| check.is_a?(FaceMatchCheckResponse) }
70
+ end
71
+
72
+ #
73
+ # @return [Array<TextDataCheckResponse>]
74
+ #
75
+ def text_data_checks
76
+ @checks.select { |check| check.is_a?(TextDataCheckResponse) }
77
+ end
78
+
79
+ #
80
+ # @return [Array<LivenessCheckResponse>]
81
+ #
82
+ def liveness_checks
83
+ @checks.select { |check| check.is_a?(LivenessCheckResponse) }
84
+ end
85
+
86
+ private
87
+
88
+ #
89
+ # @param [Array<Hash>] checks
90
+ #
91
+ # @return [Array<CheckResponse>]
92
+ #
93
+ def map_checks(checks)
94
+ checks.map do |check|
95
+ case check['type']
96
+ when Constants::ID_DOCUMENT_AUTHENTICITY
97
+ AuthenticityCheckResponse.new(check)
98
+ when Constants::ID_DOCUMENT_FACE_MATCH
99
+ FaceMatchCheckResponse.new(check)
100
+ when Constants::ID_DOCUMENT_TEXT_DATA_CHECK
101
+ TextDataCheckResponse.new(check)
102
+ when Constants::LIVENESS
103
+ LivenessCheckResponse.new(check)
104
+ else
105
+ CheckResponse.new(check)
106
+ end
107
+ end
108
+ end
109
+ end
110
+ end
111
+ end
112
+ end
113
+ end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Yoti
4
+ module DocScan
5
+ module Session
6
+ module Retrieve
7
+ class IdDocumentResourceResponse < ResourceResponse
8
+ # @return [String]
9
+ attr_reader :document_type
10
+
11
+ # @return [String]
12
+ attr_reader :issuing_country
13
+
14
+ # @return [Array<PageResponse>]
15
+ attr_reader :pages
16
+
17
+ # @return [DocumentFieldsResponse]
18
+ attr_reader :document_fields
19
+
20
+ #
21
+ # @param [Hash] resource
22
+ #
23
+ def initialize(resource)
24
+ super(resource)
25
+
26
+ Validation.assert_is_a(String, resource['document_type'], 'document_type', true)
27
+ @document_type = resource['document_type']
28
+
29
+ Validation.assert_is_a(String, resource['issuing_country'], 'issuing_country', true)
30
+ @issuing_country = resource['issuing_country']
31
+
32
+ if resource['pages'].nil?
33
+ @pages = []
34
+ else
35
+ Validation.assert_is_a(Array, resource['pages'], 'pages')
36
+ @pages = resource['pages'].map { |page| PageResponse.new(page) }
37
+ end
38
+
39
+ @document_fields = DocumentFieldsResponse.new(resource['document_fields']) unless resource['document_fields'].nil?
40
+ end
41
+
42
+ #
43
+ # @return [Array<TextExtractionTaskResponse>]
44
+ #
45
+ def text_extraction_tasks
46
+ @tasks.select { |task| task.is_a?(TextExtractionTaskResponse) }
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end