yoti 1.6.3 → 1.9.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 +4 -4
  2. data/README.md +22 -224
  3. data/lib/yoti.rb +54 -1
  4. data/lib/yoti/client.rb +13 -4
  5. data/lib/yoti/configuration.rb +7 -2
  6. data/lib/yoti/data_type/age_verification.rb +1 -1
  7. data/lib/yoti/data_type/base_profile.rb +1 -1
  8. data/lib/yoti/data_type/image.rb +4 -12
  9. data/lib/yoti/data_type/image_jpeg.rb +2 -0
  10. data/lib/yoti/data_type/image_png.rb +2 -0
  11. data/lib/yoti/data_type/media.rb +19 -0
  12. data/lib/yoti/data_type/signed_time_stamp.rb +1 -1
  13. data/lib/yoti/doc_scan/client.rb +187 -0
  14. data/lib/yoti/doc_scan/constants.rb +31 -0
  15. data/lib/yoti/doc_scan/errors.rb +81 -0
  16. data/lib/yoti/doc_scan/session/create/create_session_result.rb +50 -0
  17. data/lib/yoti/doc_scan/session/create/document_filter.rb +31 -0
  18. data/lib/yoti/doc_scan/session/create/document_restrictions_filter.rb +140 -0
  19. data/lib/yoti/doc_scan/session/create/notification_config.rb +142 -0
  20. data/lib/yoti/doc_scan/session/create/orthogonal_restrictions_filter.rb +150 -0
  21. data/lib/yoti/doc_scan/session/create/requested_check.rb +39 -0
  22. data/lib/yoti/doc_scan/session/create/requested_document_authenticity_check.rb +95 -0
  23. data/lib/yoti/doc_scan/session/create/requested_face_match_check.rb +95 -0
  24. data/lib/yoti/doc_scan/session/create/requested_id_document_comparison_check.rb +53 -0
  25. data/lib/yoti/doc_scan/session/create/requested_liveness_check.rb +108 -0
  26. data/lib/yoti/doc_scan/session/create/requested_task.rb +39 -0
  27. data/lib/yoti/doc_scan/session/create/requested_text_extraction_task.rb +116 -0
  28. data/lib/yoti/doc_scan/session/create/required_document.rb +31 -0
  29. data/lib/yoti/doc_scan/session/create/required_id_document.rb +53 -0
  30. data/lib/yoti/doc_scan/session/create/sdk_config.rb +221 -0
  31. data/lib/yoti/doc_scan/session/create/session_specification.rb +221 -0
  32. data/lib/yoti/doc_scan/session/retrieve/authenticity_check_response.rb +12 -0
  33. data/lib/yoti/doc_scan/session/retrieve/breakdown_response.rb +38 -0
  34. data/lib/yoti/doc_scan/session/retrieve/check_response.rb +63 -0
  35. data/lib/yoti/doc_scan/session/retrieve/details_response.rb +28 -0
  36. data/lib/yoti/doc_scan/session/retrieve/document_fields_response.rb +21 -0
  37. data/lib/yoti/doc_scan/session/retrieve/document_id_photo_response.rb +21 -0
  38. data/lib/yoti/doc_scan/session/retrieve/face_map_response.rb +21 -0
  39. data/lib/yoti/doc_scan/session/retrieve/face_match_check_response.rb +12 -0
  40. data/lib/yoti/doc_scan/session/retrieve/frame_response.rb +21 -0
  41. data/lib/yoti/doc_scan/session/retrieve/generated_check_response.rb +28 -0
  42. data/lib/yoti/doc_scan/session/retrieve/generated_media.rb +28 -0
  43. data/lib/yoti/doc_scan/session/retrieve/generated_text_data_check_response.rb +12 -0
  44. data/lib/yoti/doc_scan/session/retrieve/get_session_result.rb +127 -0
  45. data/lib/yoti/doc_scan/session/retrieve/id_document_comparison_check_response.rb +12 -0
  46. data/lib/yoti/doc_scan/session/retrieve/id_document_resource_response.rb +57 -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 +62 -11
  61. data/lib/yoti/dynamic_share_service/policy/dynamic_policy.rb +84 -22
  62. data/lib/yoti/dynamic_share_service/share_url.rb +28 -33
  63. data/lib/yoti/errors.rb +15 -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 +221 -18
  69. data/lib/yoti/http/signed_request.rb +13 -4
  70. data/lib/yoti/protobuf/main.rb +1 -1
  71. data/lib/yoti/ssl.rb +2 -2
  72. data/lib/yoti/util/anchor_processor.rb +1 -1
  73. data/lib/yoti/util/validation.rb +41 -0
  74. data/lib/yoti/version.rb +1 -1
  75. data/yoti.gemspec +19 -9
  76. metadata +60 -67
  77. data/.github/ISSUE_TEMPLATE.md +0 -17
  78. data/.gitignore +0 -39
  79. data/CONTRIBUTING.md +0 -127
  80. data/Guardfile +0 -11
  81. data/Rakefile +0 -49
  82. data/login_flow.png +0 -0
  83. data/rubocop.yml +0 -57
  84. data/yardstick.yml +0 -9
@@ -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,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
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Yoti
4
+ module DocScan
5
+ module Session
6
+ module Create
7
+ #
8
+ # Requests creation of a Check to be performed on a document
9
+ #
10
+ class RequestedCheck
11
+ #
12
+ # @param [String] type The type of the Check to create
13
+ # @param [#as_json] config The configuration to apply to the Check
14
+ #
15
+ def initialize(type, config)
16
+ raise(TypeError, "#{self.class} cannot be instantiated") if self.class == RequestedCheck
17
+
18
+ Validation.assert_is_a(String, type, 'type')
19
+ @type = type
20
+
21
+ Validation.assert_respond_to(:as_json, config, 'config')
22
+ @config = config
23
+ end
24
+
25
+ def to_json(*_args)
26
+ as_json.to_json
27
+ end
28
+
29
+ def as_json(*_args)
30
+ {
31
+ type: @type,
32
+ config: @config.as_json
33
+ }
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end