yoti_sandbox 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: ee3b93e52cfe923f7311c9fb4e426c82f543d335d77986afce33a156020ebd49
4
+ data.tar.gz: c364243f9462bce1e2d115b4d538353b34c764412109e5fdbde6587e90e07ad3
5
+ SHA512:
6
+ metadata.gz: 942ea35d3fb25a5d7b7cf9dc70c8bef7e61b15109295de0c56fabbb5ae15d8cf10fbb202a54b879cda88980ef940ceed2293fe0c0db3506a2318dce9c213f58d
7
+ data.tar.gz: 965241d45bb97c05cd45c3d2a88c5ac843655ce427787c76b5a4b84c57fd4d9d2501f8a8f7a8317e7a55e81c780a768dd172e167e38623346acfb2522d20990d
@@ -0,0 +1,17 @@
1
+ ---
2
+ name: Custom issue template
3
+ about: " There's a better way to get help!"
4
+ title: ''
5
+ labels: ''
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ #
11
+ # Wait ✋
12
+ #
13
+ # There's a better way to get help!
14
+ #
15
+ # Send your questions or issues to sdksupport@yoti.com
16
+ #
17
+ #
data/.gitignore ADDED
@@ -0,0 +1,56 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /spec/examples.txt
9
+ /test/tmp/
10
+ /test/version_tmp/
11
+ /tmp/
12
+
13
+ # Used by dotenv library to load environment variables.
14
+ .env
15
+
16
+ # Ignore Byebug command history file.
17
+ .byebug_history
18
+
19
+ ## Specific to RubyMotion:
20
+ .dat*
21
+ .repl_history
22
+ build/
23
+ *.bridgesupport
24
+ build-iPhoneOS/
25
+ build-iPhoneSimulator/
26
+
27
+ ## Specific to RubyMotion (use of CocoaPods):
28
+ #
29
+ # We recommend against adding the Pods directory to your .gitignore. However
30
+ # you should judge for yourself, the pros and cons are mentioned at:
31
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
32
+ #
33
+ # vendor/Pods/
34
+
35
+ ## Documentation cache and generated files:
36
+ /.yardoc/
37
+ /_yardoc/
38
+ /doc/
39
+ /rdoc/
40
+
41
+ ## Environment normalization:
42
+ /.bundle/
43
+ /vendor/bundle
44
+ /lib/bundler/man/
45
+
46
+ # for a library or gem, you might want to ignore these files since the code is
47
+ # intended to run in multiple environments; otherwise, check them in:
48
+ Gemfile.lock
49
+ .ruby-version
50
+ .ruby-gemset
51
+
52
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
53
+ .rvmrc
54
+
55
+ # Used by RuboCop. Remote config files pulled in from inherit_from directive.
56
+ # .rubocop-https?--*
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,30 @@
1
+ # Contributing
2
+
3
+ After checking out the repo, run `bundle install` to install dependencies. Then, run `bundle exec rake spec` to run the tests. To install this gem onto your local machine, run `bundle exec rake install`.
4
+
5
+ You can use [Guard][] to automatically run the tests every time a file in the `lib` or `spec` folder changes.
6
+
7
+ Run Guard through Bundler with:
8
+
9
+ ```shell
10
+ bundle exec guard
11
+ ```
12
+
13
+ [Guard]: https://github.com/guard/guard
14
+
15
+ ## Code coverage
16
+
17
+ The 100% code coverage requirement must be met before submitting new code.
18
+ This can be checked by opening the generated [SimpleCov][] files:
19
+
20
+ ```shell
21
+ open coverage/index.html
22
+ ```
23
+
24
+ ## Style guide
25
+
26
+ The Ruby style guide is configured in the [rubocop.yml](rubocop.yml) file and can be checked by running:
27
+
28
+ ```shell
29
+ bundle exec rake rubocop
30
+ ```
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'guard'
4
+ gem 'guard-rspec'
5
+ gem 'rubocop'
6
+ gem 'rubocop-performance'
7
+
8
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,11 @@
1
+ guard :rspec, cmd: 'bundle exec rspec -c -f doc' do
2
+ # watch /lib/ files
3
+ watch(%r{^lib/(.+).rb$}) do |m|
4
+ "spec/#{m[1]}_spec.rb"
5
+ end
6
+
7
+ # watch /spec/ files
8
+ watch(%r{^spec/(.+).rb$}) do |m|
9
+ "spec/#{m[1]}.rb"
10
+ end
11
+ end
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Yoti Ltd
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,45 @@
1
+ # Yoti Ruby Sandbox SDK
2
+
3
+ This repository contains the tools you need to test your Yoti integration.
4
+
5
+ ## Installing the Sandbox
6
+
7
+ To import the Yoti Sandbox SDK inside your project, add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'yoti_sandbox'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ ```shell
16
+ bundle install
17
+ ```
18
+
19
+ Or simply run the following command from your terminal:
20
+
21
+ ```shell
22
+ gem install yoti_sandbox
23
+ ```
24
+
25
+ ## Configuration
26
+
27
+ * `SANDBOX_CLIENT_SDK_ID` is the Sandbox SDK identifier generated by Yoti Hub from the Sandbox section. This is different to the Client SDK ID for your application.
28
+
29
+ * `/path/to/your-pem-file.pem` is the path to the application pem file. It can be downloaded only once from the Keys tab in your Yoti Hub.
30
+
31
+ Please do not open the pem file as this might corrupt the key and you will need to create a new application.
32
+
33
+ ```ruby
34
+ require 'yoti_sandbox'
35
+
36
+ Yoti.configure do |config|
37
+ config.client_sdk_id = 'SANDBOX_CLIENT_SDK_ID'
38
+ config.key_file_path = '/path/to/your-pem-file.pem'
39
+ config.api_endpoint = 'https://api.yoti.com/sandbox/v1'
40
+ end
41
+ ```
42
+
43
+ ## Examples
44
+
45
+ - See [examples/profile](examples/profile) for a general example of how to use the Profile Sandbox in your tests.
data/Rakefile ADDED
@@ -0,0 +1,41 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+ require 'yaml'
4
+
5
+ ################################
6
+ # Tests #
7
+ ################################
8
+
9
+ RSpec::Core::RakeTask.new
10
+ task test: :spec
11
+
12
+ ################################
13
+ # Rubocop #
14
+ ################################
15
+
16
+ require 'rubocop/rake_task'
17
+ RuboCop::RakeTask.new(:rubocop) do |t|
18
+ t.options = ['--config', 'rubocop.yml']
19
+ end
20
+
21
+ ################################
22
+ # Documentation #
23
+ ################################
24
+
25
+ require 'yard'
26
+ YARD::Rake::YardocTask.new do |t|
27
+ t.stats_options = ['--list-undoc']
28
+ end
29
+
30
+ yardstick_options = YAML.load_file('yardstick.yml')
31
+
32
+ require 'yardstick/rake/measurement'
33
+ Yardstick::Rake::Measurement.new(:measurement, yardstick_options) do |measurement|
34
+ measurement.output = 'measurement/report.txt'
35
+ end
36
+
37
+ ################################
38
+ # Defaults #
39
+ ################################
40
+
41
+ task default: %i[spec rubocop]
@@ -0,0 +1 @@
1
+ require_relative 'yoti_sandbox/profile'
@@ -0,0 +1,5 @@
1
+ require_relative 'profile/age_verification'
2
+ require_relative 'profile/anchor'
3
+ require_relative 'profile/attribute'
4
+ require_relative 'profile/client'
5
+ require_relative 'profile/token_request'
@@ -0,0 +1,112 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Yoti
4
+ module Sandbox
5
+ module Profile
6
+ #
7
+ # Represents an Age Verification attribute that can be
8
+ # used by the profile sandbox service
9
+ #
10
+ class AgeVerification
11
+ #
12
+ # @param [DateTime|Time] date_of_birth
13
+ # @param [String] derivation
14
+ # @param [Array<Anchor>] anchors
15
+ #
16
+ # @return [self]
17
+ #
18
+ def initialize(
19
+ date_of_birth:,
20
+ derivation:,
21
+ anchors: []
22
+ )
23
+ @date_of_birth = date_of_birth
24
+ @derivation = derivation
25
+ @anchors = anchors
26
+ end
27
+
28
+ #
29
+ # @return [Attribute]
30
+ #
31
+ def to_attribute
32
+ Attribute.new(
33
+ name: Yoti::Attribute::DATE_OF_BIRTH,
34
+ value: @date_of_birth.strftime('%F'),
35
+ derivation: @derivation,
36
+ anchors: @anchors
37
+ )
38
+ end
39
+ end
40
+
41
+ #
42
+ # Builder for {AgeVerification}
43
+ #
44
+ class AgeVerificationBuilder
45
+ def initialize
46
+ @date_of_birth = nil
47
+ @derivation = nil
48
+ @anchors = []
49
+ end
50
+
51
+ #
52
+ # @param [DateTime|Time] date_of_birth
53
+ #
54
+ # @return [self]
55
+ #
56
+ def with_date_of_birth(date_of_birth)
57
+ @date_of_birth = date_of_birth
58
+ self
59
+ end
60
+
61
+ #
62
+ # @param [String] derivation
63
+ #
64
+ # @return [self]
65
+ #
66
+ def with_derivation(derivation)
67
+ @derivation = derivation
68
+ self
69
+ end
70
+
71
+ #
72
+ # @param [Integer] age
73
+ #
74
+ # @return [self]
75
+ #
76
+ def with_age_over(age)
77
+ with_derivation("#{Yoti::Attribute::AGE_OVER}#{age}")
78
+ end
79
+
80
+ #
81
+ # @param [Integer] age
82
+ #
83
+ # @return [self]
84
+ #
85
+ def with_age_under(age)
86
+ with_derivation("#{Yoti::Attribute::AGE_UNDER}#{age}")
87
+ end
88
+
89
+ #
90
+ # @param [Array<Anchor>] anchors
91
+ #
92
+ # @return [self]
93
+ #
94
+ def with_anchors(anchors)
95
+ @anchors = anchors
96
+ self
97
+ end
98
+
99
+ #
100
+ # @return [AgeVerification]
101
+ #
102
+ def build
103
+ AgeVerification.new(
104
+ date_of_birth: @date_of_birth,
105
+ derivation: @derivation,
106
+ anchors: @anchors
107
+ )
108
+ end
109
+ end
110
+ end
111
+ end
112
+ end
@@ -0,0 +1,72 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Yoti
4
+ module Sandbox
5
+ module Profile
6
+ #
7
+ # Represents an anchor that can be used by the profile sandbox service
8
+ #
9
+ class Anchor
10
+ #
11
+ # @param [String] type
12
+ # @param [String] value
13
+ # @param [String] sub_type
14
+ # @param [DateTime|Time] timestamp
15
+ #
16
+ def initialize(type:, value:, sub_type: '', timestamp: Time.now)
17
+ @type = type
18
+ @value = value
19
+ @sub_type = sub_type
20
+ @timestamp = timestamp
21
+ end
22
+
23
+ #
24
+ # @return [Hash]
25
+ #
26
+ def as_json(*_args)
27
+ {
28
+ type: @type,
29
+ value: @value,
30
+ sub_type: @sub_type,
31
+ timestamp: @timestamp.strftime('%s').to_i * 1_000_000
32
+ }
33
+ end
34
+
35
+ #
36
+ # @return [String]
37
+ #
38
+ def to_json(*args)
39
+ as_json.to_json(*args)
40
+ end
41
+
42
+ #
43
+ # @param [String] value
44
+ # @param [String] sub_type
45
+ # @param [DateTime|Time] timestamp
46
+ #
47
+ def self.source(value, sub_type: '', timestamp: Time.now)
48
+ Anchor.new(
49
+ type: 'SOURCE',
50
+ value: value,
51
+ sub_type: sub_type,
52
+ timestamp: timestamp
53
+ )
54
+ end
55
+
56
+ #
57
+ # @param [String] value
58
+ # @param [String] sub_type
59
+ # @param [DateTime|Time] timestamp
60
+ #
61
+ def self.verifier(value, sub_type: '', timestamp: Time.now)
62
+ Anchor.new(
63
+ type: 'VERIFIER',
64
+ value: value,
65
+ sub_type: sub_type,
66
+ timestamp: timestamp
67
+ )
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Yoti
4
+ module Sandbox
5
+ module Profile
6
+ #
7
+ # Represents an attribute that can be used by the profile sandbox service
8
+ #
9
+ class Attribute
10
+ #
11
+ # @param [String] name
12
+ # @param [String] value
13
+ # @param [String] derivation
14
+ # @param [Array<Anchor>] anchors
15
+ #
16
+ def initialize(
17
+ name: '',
18
+ value: '',
19
+ derivation: '',
20
+ anchors: []
21
+ )
22
+ @name = name
23
+ @value = value
24
+ @derivation = derivation
25
+ @anchors = anchors
26
+ end
27
+
28
+ #
29
+ # @return [Hash]
30
+ #
31
+ def as_json(*_args)
32
+ {
33
+ name: @name,
34
+ value: @value,
35
+ derivation: @derivation,
36
+ anchors: @anchors.map(&:as_json)
37
+ }
38
+ end
39
+
40
+ #
41
+ # @return [String]
42
+ #
43
+ def to_json(*args)
44
+ as_json(*args).to_json
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'yoti'
4
+ require 'securerandom'
5
+
6
+ module Yoti
7
+ module Sandbox
8
+ module Profile
9
+ #
10
+ # Client for the profile sandbox service
11
+ #
12
+ class Client
13
+ #
14
+ # @param [String] base_url
15
+ #
16
+ def initialize(base_url: nil)
17
+ @base_url = base_url || "#{Yoti.configuration.api_url}/sandbox/v1"
18
+ end
19
+
20
+ #
21
+ # @param [TokenRequest] token_request
22
+ #
23
+ # @return [String]
24
+ #
25
+ def setup_sharing_profile(token_request)
26
+ endpoint = "/apps/#{Yoti.configuration.client_sdk_id}/tokens?\
27
+ nonce=#{SecureRandom.uuid}&timestamp=#{Time.now.to_i}"
28
+ uri = URI(
29
+ "#{@base_url}#{endpoint}"
30
+ )
31
+
32
+ response = Net::HTTP.start(
33
+ uri.hostname,
34
+ uri.port,
35
+ use_ssl: true
36
+ ) do |http|
37
+ unsigned = Net::HTTP::Post.new uri
38
+ unsigned.body = token_request.to_json
39
+ signed_request = Yoti::SignedRequest.new(
40
+ unsigned,
41
+ endpoint,
42
+ token_request
43
+ ).sign
44
+ http.request signed_request
45
+ end
46
+
47
+ raise "Failed to share profile #{response.code}: #{response.body}" unless response.code == '201'
48
+
49
+ JSON.parse(response.body)['token']
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,319 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'yoti/data_type/attribute'
4
+
5
+ require 'base64'
6
+
7
+ require_relative 'attribute'
8
+
9
+ module Yoti
10
+ module Sandbox
11
+ module Profile
12
+ #
13
+ # TokenRequest used to retrieve a token from the profile sandbox service
14
+ #
15
+ class TokenRequest
16
+ #
17
+ # @param [String] remember_me_id
18
+ # @param [Array<Attribute>] attributes
19
+ #
20
+ def initialize(remember_me_id, attributes)
21
+ @remember_me_id = remember_me_id
22
+ @attributes = attributes
23
+ end
24
+
25
+ #
26
+ # @return [Hash]
27
+ #
28
+ def as_json(*_args)
29
+ {
30
+ remember_me_id: @remember_me_id,
31
+ profile_attributes: @attributes.map(&:as_json)
32
+ }
33
+ end
34
+
35
+ #
36
+ # @return [String]
37
+ #
38
+ def to_json(*_args)
39
+ as_json.to_json
40
+ end
41
+ end
42
+
43
+ #
44
+ # Builder for {TokenRequest}
45
+ #
46
+ class TokenRequestBuilder
47
+ def initialize
48
+ @remember_me_id = ''
49
+ @attributes = []
50
+ end
51
+
52
+ #
53
+ # @param [String] remember_me_id
54
+ #
55
+ # @return [self]
56
+ #
57
+ def with_remember_me_id(remember_me_id)
58
+ @remember_me_id = remember_me_id
59
+ self
60
+ end
61
+
62
+ #
63
+ # @param [Attribute] attribute
64
+ #
65
+ # @return [self]
66
+ #
67
+ def with_attribute(attribute)
68
+ @attributes.push attribute
69
+ self
70
+ end
71
+
72
+ #
73
+ # @param [String] value
74
+ # @param [Array<Anchor>] anchors
75
+ #
76
+ # @return [self]
77
+ #
78
+ def with_given_names(value, anchors: [])
79
+ with_attribute(
80
+ create_attribute(
81
+ name: Yoti::Attribute::GIVEN_NAMES,
82
+ value: value,
83
+ anchors: anchors
84
+ )
85
+ )
86
+ end
87
+
88
+ #
89
+ # @param [String] value
90
+ # @param [Array<Anchor>] anchors
91
+ #
92
+ # @return [self]
93
+ #
94
+ def with_family_name(value, anchors: [])
95
+ with_attribute(
96
+ create_attribute(
97
+ name: Yoti::Attribute::FAMILY_NAME,
98
+ value: value,
99
+ anchors: anchors
100
+ )
101
+ )
102
+ end
103
+
104
+ #
105
+ # @param [String] value
106
+ # @param [Array<Anchor>] anchors
107
+ #
108
+ # @return [self]
109
+ #
110
+ def with_full_name(value, anchors: [])
111
+ with_attribute(
112
+ create_attribute(
113
+ name: Yoti::Attribute::FULL_NAME,
114
+ value: value,
115
+ anchors: anchors
116
+ )
117
+ )
118
+ end
119
+
120
+ #
121
+ # @param [DateTime|Time] date
122
+ # @param [Array<Anchor>] anchors
123
+ #
124
+ # @return [self]
125
+ #
126
+ def with_date_of_birth(date, anchors: [])
127
+ with_attribute(
128
+ create_attribute(
129
+ name: Yoti::Attribute::DATE_OF_BIRTH,
130
+ value: date.strftime('%F'),
131
+ anchors: anchors
132
+ )
133
+ )
134
+ end
135
+
136
+ #
137
+ # @param [AgeVerification] age_verification
138
+ #
139
+ # @return [self]
140
+ #
141
+ def with_age_verification(age_verification)
142
+ with_attribute(age_verification.to_attribute)
143
+ end
144
+
145
+ #
146
+ # @param [String] value
147
+ # @param [Array<Anchor>] anchors
148
+ #
149
+ # @return [self]
150
+ #
151
+ def with_gender(value, anchors: [])
152
+ with_attribute(
153
+ create_attribute(
154
+ name: Yoti::Attribute::GENDER,
155
+ value: value,
156
+ anchors: anchors
157
+ )
158
+ )
159
+ end
160
+
161
+ #
162
+ # @param [String] value
163
+ # @param [Array<Anchor>] anchors
164
+ #
165
+ # @return [self]
166
+ #
167
+ def with_phone_number(value, anchors: [])
168
+ with_attribute(
169
+ create_attribute(
170
+ name: Yoti::Attribute::PHONE_NUMBER,
171
+ value: value,
172
+ anchors: anchors
173
+ )
174
+ )
175
+ end
176
+
177
+ #
178
+ # @param [String] value
179
+ # @param [Array<Anchor>] anchors
180
+ #
181
+ # @return [self]
182
+ #
183
+ def with_nationality(value, anchors: [])
184
+ with_attribute(
185
+ create_attribute(
186
+ name: Yoti::Attribute::NATIONALITY,
187
+ value: value,
188
+ anchors: anchors
189
+ )
190
+ )
191
+ end
192
+
193
+ #
194
+ # @param [String] value
195
+ # @param [Array<Anchor>] anchors
196
+ #
197
+ # @return [self]
198
+ #
199
+ def with_postal_address(value, anchors: [])
200
+ with_attribute(
201
+ create_attribute(
202
+ name: Yoti::Attribute::POSTAL_ADDRESS,
203
+ value: value,
204
+ anchors: anchors
205
+ )
206
+ )
207
+ end
208
+
209
+ #
210
+ # @param [Hash] data
211
+ # @param [Array<Anchor>] anchors
212
+ #
213
+ # @return [self]
214
+ #
215
+ def with_structured_postal_address(data, anchors: [])
216
+ with_attribute(
217
+ create_attribute(
218
+ name: Yoti::Attribute::STRUCTURED_POSTAL_ADDRESS,
219
+ value: data.to_json,
220
+ anchors: anchors
221
+ )
222
+ )
223
+ end
224
+
225
+ #
226
+ # @param [bin] data
227
+ # @param [Array<Anchor>] anchors
228
+ #
229
+ # @return [self]
230
+ #
231
+ def with_selfie(data, anchors: [])
232
+ with_base64_selfie(
233
+ Base64.strict_encode64(data),
234
+ anchors: anchors
235
+ )
236
+ end
237
+
238
+ #
239
+ # @param [String] base64_data
240
+ # @param [Array<Anchor>] anchors
241
+ #
242
+ # @return [self]
243
+ #
244
+ def with_base64_selfie(base64_data, anchors: [])
245
+ with_attribute(
246
+ create_attribute(
247
+ name: Yoti::Attribute::SELFIE,
248
+ value: base64_data,
249
+ anchors: anchors
250
+ )
251
+ )
252
+ end
253
+
254
+ #
255
+ # @param [String] value
256
+ # @param [Array<Anchor>] anchors
257
+ #
258
+ # @return [self]
259
+ #
260
+ def with_email_address(value, anchors: [])
261
+ with_attribute(
262
+ create_attribute(
263
+ name: Yoti::Attribute::EMAIL_ADDRESS,
264
+ value: value,
265
+ anchors: anchors
266
+ )
267
+ )
268
+ end
269
+
270
+ #
271
+ # @param [String] value
272
+ # @param [Array<Anchor>] anchors
273
+ #
274
+ # @return [self]
275
+ #
276
+ def with_document_details(value, anchors: [])
277
+ with_attribute(
278
+ create_attribute(
279
+ name: Yoti::Attribute::DOCUMENT_DETAILS,
280
+ value: value,
281
+ anchors: anchors
282
+ )
283
+ )
284
+ end
285
+
286
+ #
287
+ # @return [TokenRequest]
288
+ #
289
+ def build
290
+ TokenRequest.new(@remember_me_id, @attributes)
291
+ end
292
+
293
+ private
294
+
295
+ #
296
+ # @param [String] name
297
+ # @param [String] value
298
+ # @param [String] derivation
299
+ # @param [Array<Anchor>] anchors
300
+ #
301
+ # @return [Attribute]
302
+ #
303
+ def create_attribute(
304
+ name:,
305
+ value:,
306
+ derivation: '',
307
+ anchors: []
308
+ )
309
+ Yoti::Sandbox::Profile::Attribute.new(
310
+ name: name,
311
+ value: value,
312
+ derivation: derivation,
313
+ anchors: anchors
314
+ )
315
+ end
316
+ end
317
+ end
318
+ end
319
+ end
data/rubocop.yml ADDED
@@ -0,0 +1,44 @@
1
+ AllCops:
2
+ DisplayCopNames: true
3
+ DisplayStyleGuide: true
4
+ TargetRubyVersion: 2.4
5
+
6
+ Metrics/AbcSize:
7
+ Enabled: false
8
+ Max: 23
9
+
10
+ Metrics/BlockLength:
11
+ Exclude:
12
+ - spec/**/**/*.rb
13
+ - examples/**/*.rb
14
+
15
+ Metrics/ClassLength:
16
+ Enabled: false
17
+ Max: 115
18
+
19
+ Metrics/CyclomaticComplexity:
20
+ Max: 9
21
+
22
+ Metrics/LineLength:
23
+ Enabled: false
24
+
25
+ Metrics/MethodLength:
26
+ Enabled: false
27
+ CountComments: false
28
+ Max: 19
29
+
30
+ Style/Documentation:
31
+ Enabled: false
32
+
33
+ Style/FrozenStringLiteralComment:
34
+ Enabled: false
35
+
36
+ Style/NumericLiterals:
37
+ Enabled: false
38
+
39
+ Style/MutableConstant:
40
+ Enabled: false
41
+
42
+ Layout/MultilineMethodCallIndentation:
43
+ Exclude:
44
+ - examples/**/*.rb
data/yardstick.yml ADDED
@@ -0,0 +1,9 @@
1
+ rules:
2
+ ApiTag::Presence:
3
+ enabled: false
4
+ ApiTag::Inclusion:
5
+ enabled: false
6
+ ApiTag::PrivateMethod:
7
+ enabled: false
8
+ ExampleTag:
9
+ enabled: false
@@ -0,0 +1,33 @@
1
+ lib = File.expand_path('lib', __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+
4
+ Gem::Specification.new do |spec|
5
+ spec.name = 'yoti_sandbox'
6
+ spec.version = '1.0.0'
7
+ spec.authors = ['Yoti']
8
+ spec.email = ['websdk@yoti.com']
9
+
10
+ spec.summary = 'Yoti Ruby Sandbox SDK for back-end integration.'
11
+ spec.description = <<-DESC
12
+ This gem contains the tools you need to test your Ruby back-end
13
+ integration.
14
+ DESC
15
+
16
+ spec.homepage = 'https://github.com/getyoti/yoti-ruby-sdk-sandbox'
17
+ spec.license = 'MIT'
18
+
19
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|examples)/|^sonar-project.properties$|^.dependabot/config.yml$|^.travis.yml$}) }
20
+ spec.require_paths = ['lib']
21
+
22
+ spec.required_ruby_version = '>= 2.4'
23
+
24
+ spec.add_dependency 'yoti', '~> 1.6'
25
+
26
+ spec.add_development_dependency 'bundler', '~> 2.0'
27
+ spec.add_development_dependency 'rake', '~> 12.0'
28
+ spec.add_development_dependency 'rspec', '~> 3.5'
29
+ spec.add_development_dependency 'simplecov', '~> 0.13'
30
+ spec.add_development_dependency 'webmock', '~> 3.3'
31
+ spec.add_development_dependency 'yard', '~> 0.9'
32
+ spec.add_development_dependency 'yardstick', '~> 0.9'
33
+ end
metadata ADDED
@@ -0,0 +1,175 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: yoti_sandbox
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Yoti
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-04-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: yoti
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '12.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '12.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.5'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.5'
69
+ - !ruby/object:Gem::Dependency
70
+ name: simplecov
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.13'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.13'
83
+ - !ruby/object:Gem::Dependency
84
+ name: webmock
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3.3'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '3.3'
97
+ - !ruby/object:Gem::Dependency
98
+ name: yard
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '0.9'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '0.9'
111
+ - !ruby/object:Gem::Dependency
112
+ name: yardstick
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '0.9'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '0.9'
125
+ description: |2
126
+ This gem contains the tools you need to test your Ruby back-end
127
+ integration.
128
+ email:
129
+ - websdk@yoti.com
130
+ executables: []
131
+ extensions: []
132
+ extra_rdoc_files: []
133
+ files:
134
+ - ".github/ISSUE_TEMPLATE.md"
135
+ - ".gitignore"
136
+ - CONTRIBUTING.md
137
+ - Gemfile
138
+ - Guardfile
139
+ - LICENSE
140
+ - README.md
141
+ - Rakefile
142
+ - lib/yoti_sandbox.rb
143
+ - lib/yoti_sandbox/profile.rb
144
+ - lib/yoti_sandbox/profile/age_verification.rb
145
+ - lib/yoti_sandbox/profile/anchor.rb
146
+ - lib/yoti_sandbox/profile/attribute.rb
147
+ - lib/yoti_sandbox/profile/client.rb
148
+ - lib/yoti_sandbox/profile/token_request.rb
149
+ - rubocop.yml
150
+ - yardstick.yml
151
+ - yoti_sandbox.gemspec
152
+ homepage: https://github.com/getyoti/yoti-ruby-sdk-sandbox
153
+ licenses:
154
+ - MIT
155
+ metadata: {}
156
+ post_install_message:
157
+ rdoc_options: []
158
+ require_paths:
159
+ - lib
160
+ required_ruby_version: !ruby/object:Gem::Requirement
161
+ requirements:
162
+ - - ">="
163
+ - !ruby/object:Gem::Version
164
+ version: '2.4'
165
+ required_rubygems_version: !ruby/object:Gem::Requirement
166
+ requirements:
167
+ - - ">="
168
+ - !ruby/object:Gem::Version
169
+ version: '0'
170
+ requirements: []
171
+ rubygems_version: 3.0.6
172
+ signing_key:
173
+ specification_version: 4
174
+ summary: Yoti Ruby Sandbox SDK for back-end integration.
175
+ test_files: []