virgil-sdk 4.2.3

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 (63) hide show
  1. checksums.yaml +7 -0
  2. data/.DS_Store +0 -0
  3. data/.gitignore +15 -0
  4. data/Gemfile +4 -0
  5. data/README.md +134 -0
  6. data/Rakefile +9 -0
  7. data/bin/console +16 -0
  8. data/bin/setup +8 -0
  9. data/dockefiles/Dockerfile-200 +25 -0
  10. data/dockefiles/Dockerfile-2110 +36 -0
  11. data/dockefiles/Dockerfile-220 +26 -0
  12. data/dockefiles/Dockerfile-226 +25 -0
  13. data/dockefiles/Dockerfile-233 +25 -0
  14. data/dockefiles/Dockerfile-240 +26 -0
  15. data/docker-compose.yml +107 -0
  16. data/lib/virgil/sdk.rb +10 -0
  17. data/lib/virgil/sdk/client.rb +47 -0
  18. data/lib/virgil/sdk/client/card.rb +142 -0
  19. data/lib/virgil/sdk/client/card_validator.rb +104 -0
  20. data/lib/virgil/sdk/client/http.rb +45 -0
  21. data/lib/virgil/sdk/client/http/base_connection.rb +112 -0
  22. data/lib/virgil/sdk/client/http/cards_service_connection.rb +113 -0
  23. data/lib/virgil/sdk/client/http/request.rb +63 -0
  24. data/lib/virgil/sdk/client/request_signer.rb +90 -0
  25. data/lib/virgil/sdk/client/requests.rb +50 -0
  26. data/lib/virgil/sdk/client/requests/confirm_identity_request.rb +67 -0
  27. data/lib/virgil/sdk/client/requests/create_card_request.rb +105 -0
  28. data/lib/virgil/sdk/client/requests/revoke_card_request.rb +85 -0
  29. data/lib/virgil/sdk/client/requests/signable_request.rb +142 -0
  30. data/lib/virgil/sdk/client/requests/verify_identity_request.rb +60 -0
  31. data/lib/virgil/sdk/client/search_criteria.rb +79 -0
  32. data/lib/virgil/sdk/client/signatures_base64.rb +25 -0
  33. data/lib/virgil/sdk/client/virgil_client.rb +425 -0
  34. data/lib/virgil/sdk/cryptography.rb +42 -0
  35. data/lib/virgil/sdk/cryptography/hashes.rb +44 -0
  36. data/lib/virgil/sdk/cryptography/hashes/fingerprint.rb +79 -0
  37. data/lib/virgil/sdk/cryptography/hashes/hash_algorithm.rb +91 -0
  38. data/lib/virgil/sdk/cryptography/keys.rb +48 -0
  39. data/lib/virgil/sdk/cryptography/keys/key_pair.rb +46 -0
  40. data/lib/virgil/sdk/cryptography/keys/key_pair_type.rb +108 -0
  41. data/lib/virgil/sdk/cryptography/keys/key_storage.rb +177 -0
  42. data/lib/virgil/sdk/cryptography/keys/private_key.rb +44 -0
  43. data/lib/virgil/sdk/cryptography/keys/public_key.rb +44 -0
  44. data/lib/virgil/sdk/cryptography/keys/storage_item.rb +63 -0
  45. data/lib/virgil/sdk/cryptography/virgil_crypto.rb +411 -0
  46. data/lib/virgil/sdk/high_level.rb +21 -0
  47. data/lib/virgil/sdk/high_level/virgil_api.rb +71 -0
  48. data/lib/virgil/sdk/high_level/virgil_app_credentials.rb +54 -0
  49. data/lib/virgil/sdk/high_level/virgil_buffer.rb +161 -0
  50. data/lib/virgil/sdk/high_level/virgil_card.rb +204 -0
  51. data/lib/virgil/sdk/high_level/virgil_card_manager.rb +294 -0
  52. data/lib/virgil/sdk/high_level/virgil_card_verifier_info.rb +49 -0
  53. data/lib/virgil/sdk/high_level/virgil_context.rb +69 -0
  54. data/lib/virgil/sdk/high_level/virgil_identity.rb +17 -0
  55. data/lib/virgil/sdk/high_level/virgil_identity/email_confirmation.rb +60 -0
  56. data/lib/virgil/sdk/high_level/virgil_identity/validation_token.rb +49 -0
  57. data/lib/virgil/sdk/high_level/virgil_identity/verification_attempt.rb +69 -0
  58. data/lib/virgil/sdk/high_level/virgil_identity/verification_options.rb +56 -0
  59. data/lib/virgil/sdk/high_level/virgil_key.rb +168 -0
  60. data/lib/virgil/sdk/high_level/virgil_key_manager.rb +97 -0
  61. data/lib/virgil/sdk/version.rb +5 -0
  62. data/virgil-sdk.gemspec +31 -0
  63. metadata +203 -0
@@ -0,0 +1,294 @@
1
+ # Copyright (C) 2016 Virgil Security Inc.
2
+ #
3
+ # Lead Maintainer: Virgil Security Inc. <support@virgilsecurity.com>
4
+ #
5
+ # All rights reserved.
6
+ #
7
+ # Redistribution and use in source and binary forms, with or without
8
+ # modification, are permitted provided that the following conditions are
9
+ # met:
10
+ #
11
+ # (1) Redistributions of source code must retain the above copyright
12
+ # notice, this list of conditions and the following disclaimer.
13
+ #
14
+ # (2) Redistributions in binary form must reproduce the above copyright
15
+ # notice, this list of conditions and the following disclaimer in
16
+ # the documentation and/or other materials provided with the
17
+ # distribution.
18
+ #
19
+ # (3) Neither the name of the copyright holder nor the names of its
20
+ # contributors may be used to endorse or promote products derived from
21
+ # this software without specific prior written permission.
22
+ #
23
+ # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR
24
+ # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25
+ # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26
+ # DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
27
+ # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28
+ # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
29
+ # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30
+ # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
31
+ # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
32
+ # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33
+ # POSSIBILITY OF SUCH DAMAGE.
34
+ module Virgil
35
+ module SDK
36
+ module HighLevel
37
+ class VirgilCardManager
38
+ attr_reader :context
39
+ protected :context
40
+
41
+ def initialize(context)
42
+ @context = context
43
+ end
44
+
45
+
46
+ class AppCredentialsException < StandardError
47
+
48
+ def to_s
49
+ "For this operation we need app_id and app_key"
50
+ end
51
+
52
+ end
53
+
54
+ class AccessTokenException < StandardError
55
+
56
+ def to_s
57
+ "For this operation access token can't be empty"
58
+ end
59
+
60
+ end
61
+
62
+ class CardArray < Array
63
+
64
+ attr_accessor :crypto
65
+
66
+ def initialize(array)
67
+ @crypto = Cryptography::VirgilCrypto.new
68
+ super
69
+ end
70
+
71
+ # Encrypts the specified data using recipients Public keys.
72
+ #
73
+ # Args:
74
+ # buffer: The data to be encrypted.
75
+ #
76
+ # Returns:
77
+ # Encrypted data for current recipients Public keys
78
+ #
79
+ # Raises:
80
+ # ArgumentError: buffer is not valid if buffer doesn't have type VirgilBuffer or String
81
+ def encrypt(buffer)
82
+
83
+ raise ArgumentError.new("buffer is not valid") if !(buffer.is_a?(VirgilBuffer) || buffer.is_a?(String))
84
+
85
+ all_public_keys = self.map(&:public_key)
86
+ VirgilBuffer.new(crypto.encrypt(buffer.bytes, *all_public_keys))
87
+ end
88
+
89
+ end
90
+
91
+
92
+ # Creates a new Virgil Card that is representing user's Public key and information
93
+ #
94
+ # Args:
95
+ # identity: The user's identity.
96
+ # owner_key: The owner's Virgil key.
97
+ # custom_data(optional): is an associative array that contains application specific
98
+ # parameters(under key :data) and information about the device
99
+ # on which the keypair was created(under key :device and :device_name).
100
+ # example: {data: {my_key1: "my_val1", my_key2: "my_val2"}, device: "iPhone6s", device_name: "Space grey one"}
101
+ #
102
+ # Returns:
103
+ # Created unpublished Virgil Card that is representing user's Public key
104
+ def create(identity, owner_key, custom_data={})
105
+ card = context.client.new_card(
106
+ identity,
107
+ VirgilIdentity::USERNAME,
108
+ owner_key.private_key,
109
+ custom_data
110
+ )
111
+
112
+ VirgilCard.new(context: context, card: card)
113
+ end
114
+
115
+
116
+ # Creates a new Global Virgil Card that is representing user's Public key and information
117
+ #
118
+ # Args:
119
+ # identity: The user's identity.
120
+ # owner_key: The owner's Virgil key.
121
+ # custom_data(optional): is an associative array that contains application specific
122
+ # parameters(under key :data) and information about the device
123
+ # on which the keypair was created(under key :device and :device_name).
124
+ # example: {data: {my_key1: "my_val1", my_key2: "my_val2"}, device: "iPhone6s", device_name: "Space grey one"}
125
+ #
126
+ # Returns:
127
+ # Created unpublished Global Virgil Card that is representing user's Public key
128
+ def create_global(identity:, identity_type:, owner_key:, custom_data: {})
129
+ card = context.client.new_global_card(
130
+ identity,
131
+ identity_type,
132
+ owner_key.private_key,
133
+ custom_data
134
+ )
135
+ VirgilCard.new(context: context, card: card)
136
+ end
137
+
138
+
139
+ # Publish asynchronously a card into application Virgil Services scope
140
+ # Args:
141
+ # card: the card to be published
142
+ # Raises:
143
+ # Virgil::SDK::Client::HTTP::BaseConnection::ApiError if application credentials is invalid or
144
+ # Virgil Card with the same fingerprint already exists in Virgil Security services
145
+ def publish_async(card)
146
+ card.publish_async
147
+ end
148
+
149
+
150
+ # Publish synchronously a card into application Virgil Services scope
151
+ # Args:
152
+ # card: the card to be published
153
+ # Raises:
154
+ # Client::HTTP::BaseConnection::ApiError if application credentials is invalid or
155
+ # Virgil Card with the same fingerprint already exists in Virgil Security services
156
+ def publish(card)
157
+ card.publish
158
+ end
159
+
160
+
161
+ # Publish a global card into application Virgil Services scope
162
+ # Args:
163
+ # card: the global card to be published
164
+ # Raises:
165
+ # Client::HTTP::BaseConnection::ApiError if VirgilIdentity Validation Token is invalid or has expired
166
+ # Virgil Card with the same fingerprint already exists in Virgil Security services
167
+ def publish_global(card, validation_token)
168
+ card.publish_as_global(validation_token)
169
+ end
170
+
171
+
172
+ # Get a card from Virgil Security services by specified Card ID.
173
+ #
174
+ # Args:
175
+ # card_id: unique string that identifies the Card within Virgil Security services
176
+ #
177
+ # Returns:
178
+ # Found card from server response.
179
+ #
180
+ # Raises:
181
+ # VirgilClient::InvalidCardException if client has validator
182
+ # and retrieved card signatures are not valid.
183
+ def get(card_id)
184
+ VirgilCard.new(context: context, card: context.client.get_card(card_id))
185
+ end
186
+
187
+
188
+ # Find Virgil cards by specified identities in application scope.
189
+ #
190
+ # Args:
191
+ # identities: the list of identities
192
+ #
193
+ # Returns:
194
+ # A list of found Virgil cards
195
+ #
196
+ # Raises:
197
+ # VirgilClient::InvalidCardException if client has validator
198
+ # and retrieved card signatures are not valid.
199
+ # AccessTokenException:: "For this operation access token can't be empty"
200
+ #
201
+ def find(*identities)
202
+
203
+ raise AccessTokenException unless (context && context.access_token)
204
+
205
+ validate_identities_param(identities)
206
+
207
+ cards = context.client.search_cards_by_identities(*identities)
208
+ virgil_cards = cards.map { |v| VirgilCard.new(context: context, card: v) }
209
+ CardArray.new(virgil_cards)
210
+ end
211
+
212
+
213
+ def find_global(identity_type, *identities)
214
+
215
+ validate_identities_param(identities)
216
+
217
+ cards = context.client.search_cards_by_criteria(
218
+ Client::SearchCriteria.new(identities, identity_type, Client::Card::GLOBAL)
219
+ )
220
+ virgil_global_cards = cards.map { |v| VirgilCard.new(context: context, card: v) }
221
+ CardArray.new(virgil_global_cards)
222
+ end
223
+
224
+
225
+ # Revoke a card from Virgil Services
226
+ #
227
+ # Args:
228
+ # card: the card to be revoked
229
+ #
230
+ # Raises:
231
+ # Client::HTTP::BaseConnection::ApiError if the card was not published
232
+ # or application credentials is not valid.
233
+ # AppCredentialsException: For this operation we need app_id and app_key
234
+ # if application credentials are missing
235
+
236
+ def revoke(card)
237
+ validate_app_credentials
238
+
239
+ context.client.revoke_card(
240
+ card.id,
241
+ context.credentials.app_id,
242
+ context.credentials.app_key(context.crypto))
243
+ end
244
+
245
+
246
+ # Revoke a global card from Virgil Services
247
+ #
248
+ # Args:
249
+ # card: the global card to be revoked
250
+ #
251
+ # Raises:
252
+ # Client::HTTP::BaseConnection::ApiError if the global card was not published
253
+ # Client::HTTP::BaseConnection::ApiError if VirgilIdentity Validation Token is invalid or has expired
254
+ def revoke_global(global_card, key_pair, validation_token)
255
+ context.client.revoke_global_card(global_card.id, key_pair, validation_token)
256
+
257
+ end
258
+
259
+
260
+ # Create new Card from base64-encoded json representation of card's content_snapshot and meta
261
+ #
262
+ # Args:
263
+ # base64-encoded json representation of card
264
+ #
265
+ # Returns:
266
+ # Virgil Card restored from snapshot.
267
+
268
+ def import(exported_card)
269
+ request = Client::Requests::CreateCardRequest.import(exported_card)
270
+
271
+ VirgilCard.new(
272
+ context: self.context,
273
+ card: Client::Card.from_request_model(request.request_model)
274
+ )
275
+ end
276
+
277
+
278
+ private
279
+
280
+ def validate_identities_param(param)
281
+ raise ArgumentError.new("identities is not valid") if (!param.is_a?(Array) || param.empty?)
282
+ end
283
+
284
+ def validate_app_credentials
285
+
286
+ if !(context.credentials && context.credentials.app_id && context.credentials.app_key(context.crypto))
287
+ raise AppCredentialsException
288
+ end
289
+
290
+ end
291
+ end
292
+ end
293
+ end
294
+ end
@@ -0,0 +1,49 @@
1
+ # Copyright (C) 2016 Virgil Security Inc.
2
+ #
3
+ # Lead Maintainer: Virgil Security Inc. <support@virgilsecurity.com>
4
+ #
5
+ # All rights reserved.
6
+ #
7
+ # Redistribution and use in source and binary forms, with or without
8
+ # modification, are permitted provided that the following conditions are
9
+ # met:
10
+ #
11
+ # (1) Redistributions of source code must retain the above copyright
12
+ # notice, this list of conditions and the following disclaimer.
13
+ #
14
+ # (2) Redistributions in binary form must reproduce the above copyright
15
+ # notice, this list of conditions and the following disclaimer in
16
+ # the documentation and/or other materials provided with the
17
+ # distribution.
18
+ #
19
+ # (3) Neither the name of the copyright holder nor the names of its
20
+ # contributors may be used to endorse or promote products derived from
21
+ # this software without specific prior written permission.
22
+ #
23
+ # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR
24
+ # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25
+ # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26
+ # DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
27
+ # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28
+ # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
29
+ # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30
+ # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
31
+ # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
32
+ # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33
+ # POSSIBILITY OF SUCH DAMAGE.
34
+ require 'base64'
35
+ require 'json'
36
+
37
+ module Virgil
38
+ module SDK
39
+ module HighLevel
40
+ # This class represents an information about Virgil Card
41
+ # verifier such as Public key and Card Id.
42
+ # card_id: Card identifier
43
+ # public_key_value: Public key value wrapped by VirgilBuffer used for signature verification.
44
+ #
45
+ VirgilCardVerifierInfo = Struct.new(:card_id, :public_key_value) do
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,69 @@
1
+ # Copyright (C) 2016 Virgil Security Inc.
2
+ #
3
+ # Lead Maintainer: Virgil Security Inc. <support@virgilsecurity.com>
4
+ #
5
+ # All rights reserved.
6
+ #
7
+ # Redistribution and use in source and binary forms, with or without
8
+ # modification, are permitted provided that the following conditions are
9
+ # met:
10
+ #
11
+ # (1) Redistributions of source code must retain the above copyright
12
+ # notice, this list of conditions and the following disclaimer.
13
+ #
14
+ # (2) Redistributions in binary form must reproduce the above copyright
15
+ # notice, this list of conditions and the following disclaimer in
16
+ # the documentation and/or other materials provided with the
17
+ # distribution.
18
+ #
19
+ # (3) Neither the name of the copyright holder nor the names of its
20
+ # contributors may be used to endorse or promote products derived from
21
+ # this software without specific prior written permission.
22
+ #
23
+ # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR
24
+ # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25
+ # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26
+ # DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
27
+ # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28
+ # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
29
+ # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30
+ # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
31
+ # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
32
+ # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33
+ # POSSIBILITY OF SUCH DAMAGE.
34
+ module Virgil
35
+ module SDK
36
+ module HighLevel
37
+ class VirgilContext
38
+ attr_reader :access_token, :client, :crypto, :credentials,
39
+ :cards_service_url, :cards_read_only_service_url,
40
+ :identity_service_url, :key_storage
41
+
42
+ def initialize(access_token:, credentials: nil, key_storage_path: Cryptography::Keys::KeyStorage.default_folder,
43
+ cards_service_url: Client::Card::SERVICE_URL,
44
+ cards_read_only_service_url: Client::Card::READ_ONLY_SERVICE_URL,
45
+ identity_service_url: VirgilIdentity::IDENTITY_SERVICE_URL,
46
+ card_verifiers: []
47
+ )
48
+ @access_token = access_token
49
+ @client = Client::VirgilClient.new(access_token, cards_service_url, cards_read_only_service_url, identity_service_url)
50
+ @crypto = Cryptography::VirgilCrypto.new
51
+ @credentials = credentials
52
+ @key_storage = Cryptography::Keys::KeyStorage.new(key_storage_path)
53
+
54
+ if card_verifiers.any?
55
+
56
+ @client.card_validator = Client::CardValidator.new(@crypto)
57
+
58
+ card_verifiers.each do |card_verifier|
59
+ raise ArgumentError.new("card_verifiers is not valid") unless card_verifier.is_a? VirgilCardVerifierInfo
60
+ @client.card_validator.add_verifier(card_verifier.card_id, @crypto.import_public_key(card_verifier.public_key_value.bytes))
61
+ end
62
+ end
63
+
64
+ end
65
+ end
66
+
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,17 @@
1
+ module Virgil
2
+ module SDK
3
+ module HighLevel
4
+ module VirgilIdentity
5
+ autoload :VerificationAttempt, 'virgil/sdk/high_level/virgil_identity/verification_attempt'
6
+ autoload :VerificationOptions, 'virgil/sdk/high_level/virgil_identity/verification_options'
7
+ autoload :ValidationToken, 'virgil/sdk/high_level/virgil_identity/validation_token'
8
+ autoload :EmailConfirmation, 'virgil/sdk/high_level/virgil_identity/email_confirmation'
9
+
10
+ IDENTITY_SERVICE_URL = ENV["VIRGIL_IDENTITY_SERVICE_URL"] || "https://identity.virgilsecurity.com"
11
+
12
+ EMAIL = "email"
13
+ USERNAME = "username"
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,60 @@
1
+ # Copyright (C) 2016 Virgil Security Inc.
2
+ #
3
+ # Lead Maintainer: Virgil Security Inc. <support@virgilsecurity.com>
4
+ #
5
+ # All rights reserved.
6
+ #
7
+ # Redistribution and use in source and binary forms, with or without
8
+ # modification, are permitted provided that the following conditions are
9
+ # met:
10
+ #
11
+ # (1) Redistributions of source code must retain the above copyright
12
+ # notice, this list of conditions and the following disclaimer.
13
+ #
14
+ # (2) Redistributions in binary form must reproduce the above copyright
15
+ # notice, this list of conditions and the following disclaimer in
16
+ # the documentation and/or other materials provided with the
17
+ # distribution.
18
+ #
19
+ # (3) Neither the name of the copyright holder nor the names of its
20
+ # contributors may be used to endorse or promote products derived from
21
+ # this software without specific prior written permission.
22
+ #
23
+ # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR
24
+ # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25
+ # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26
+ # DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
27
+ # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28
+ # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
29
+ # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30
+ # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
31
+ # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
32
+ # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33
+ # POSSIBILITY OF SUCH DAMAGE.
34
+ module Virgil
35
+ module SDK
36
+ module HighLevel
37
+ module VirgilIdentity
38
+ class EmailConfirmation
39
+ attr_reader :confirmation_code
40
+
41
+
42
+ def initialize(confirmation_code)
43
+ @confirmation_code = confirmation_code
44
+ end
45
+
46
+ def confirm_and_grab_validation_token(verification_attempt, client)
47
+ token = client.confirm_identity(verification_attempt.action_id,
48
+ confirmation_code,
49
+ verification_attempt.additional_options.time_to_live,
50
+ verification_attempt.additional_options.count_to_live
51
+ )
52
+
53
+ token
54
+ end
55
+
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end