virgil-sdk 4.2.5 → 4.2.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: caf90993b1ff232ef33d9e7f602312730d8f8ced
4
- data.tar.gz: 8973c40c7a43ca0910ae2ac4d22efdd0e1926635
3
+ metadata.gz: 16acb388b3bf946a6c34865ae853cc522ce7b272
4
+ data.tar.gz: 421df1a63fd56ef79abd928b4cb51df4fbf088b2
5
5
  SHA512:
6
- metadata.gz: a38a32dec1433ed979d0231711dd8614574ee85b94b0f2cbaf661058b8a55f86a6f28f14262df3b4418a4ac76c173536784b8b0b745da4f665b97c55919e7494
7
- data.tar.gz: 38ec5674f9eb5f959422b4d11167618aaaf688a5eb90bb41aa89c85fef6f3066341ef66630cdb524fb23dc7e0c752f054d5c70e70ee4be989960ce4048652dc3
6
+ metadata.gz: 4be3c89279093ae449bdd3cbb98894c61d617821f7b4552544f6ff86abb243f50575dc6eea0f1ea8c7feb0c01650063b7dbee7553bacbe7f2eeaee7776861957
7
+ data.tar.gz: e89ca01b97a3af8f310efc30fd2098106ceec3ec5e964ea7709c275b8ecb7496471ae12d19e5b66369b3c98e5a70beb1cc29e8b833bbc0f4c90b97962e321035
data/README.md CHANGED
@@ -23,7 +23,7 @@ gem install virgil-sdk
23
23
  or add the following line to your Gemfile:
24
24
 
25
25
  ```
26
- gem 'virgil-sdk', '~> 4.2.5'
26
+ gem 'virgil-sdk', '~> 4.2.6'
27
27
  ```
28
28
 
29
29
  __Next:__ [Get Started with the Ruby SDK][_getstarted].
@@ -134,9 +134,9 @@ module Virgil
134
134
 
135
135
 
136
136
 
137
- Card::SERVICE_URL = ENV["VIRGIL_SERVICE_URL"] || "https://cards.virgilsecurity.com"
138
- Card::READ_ONLY_SERVICE_URL = ENV["VIRGIL_READ_ONLY_SERVICE_URL"] || "https://cards-ro.virgilsecurity.com"
139
- Card::RA_SERVICE_URL = ENV["VIRGIL_RA_SERVICE_URL"] || "https://ra.virgilsecurity.com"
137
+ Card::SERVICE_URL = "https://cards.virgilsecurity.com"
138
+ Card::READ_ONLY_SERVICE_URL = "https://cards-ro.virgilsecurity.com"
139
+ Card::RA_SERVICE_URL = "https://ra.virgilsecurity.com"
140
140
  Card::VRA_VERSION = "v1" # version of service, which creates and deletes local and global cards
141
141
  Card::VC_VERSION = "v4" # version of service, which gets, searchs card
142
142
  end
@@ -33,18 +33,15 @@
33
33
  # POSSIBILITY OF SUCH DAMAGE.
34
34
 
35
35
 
36
-
37
36
  module Virgil
38
37
  module SDK
39
38
  module Client
40
39
  # Class used for cards signatures validation.
41
40
  class CardValidator
42
- SERVICE_CARD_ID =
43
- '3e29d43373348cfb373b7eae189214dc01d7237765e572db685839b64adca853'
44
- SERVICE_PUBLIC_KEY =
45
- 'LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0KTUNvd0JRWURLMlZ3QXlFQVlSNTAx'\
46
- 'a1YxdFVuZTJ1T2RrdzRrRXJSUmJKcmMyU3lhejVWMWZ1RytyVnM9Ci0tLS0tRU5E'\
47
- 'IFBVQkxJQyBLRVktLS0tLQo='
41
+ SERVICE_CARD_ID = '3e29d43373348cfb373b7eae189214dc01d7237765e572db685839b64adca853'
42
+ SERVICE_PUBLIC_KEY = 'LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0KTUNvd0JRWURLMlZ3QXlFQVlSNTAx'\
43
+ 'a1YxdFVuZTJ1T2RrdzRrRXJSUmJKcmMyU3lhejVWMWZ1RytyVnM9Ci0tLS0tRU5E'\
44
+ 'IFBVQkxJQyBLRVktLS0tLQo='
48
45
 
49
46
  attr_reader :crypto, :verifiers
50
47
 
@@ -53,7 +50,7 @@ module Virgil
53
50
  @public_key_bytes = Crypto::Bytes.from_base64(SERVICE_PUBLIC_KEY)
54
51
  @public_key = crypto.import_public_key(@public_key_bytes)
55
52
  @verifiers = {
56
- SERVICE_CARD_ID => @public_key
53
+ SERVICE_CARD_ID => @public_key
57
54
  }
58
55
  end
59
56
 
@@ -74,10 +71,15 @@ module Virgil
74
71
  # True if card signatures are valid, false otherwise.
75
72
  def is_valid?(card)
76
73
 
77
- return true if (card.version == '4.0' || card.version == '3.0')
74
+ return true if (card.version == '3.0')
75
+
76
+ if (card.nil? || !card.is_a?(Card) || card.snapshot.nil? || (card.signatures.nil? || card.signatures.empty?))
77
+ return false
78
+ end
78
79
 
80
+ # add self signature verifier
79
81
  fingerprint = self.crypto.calculate_fingerprint(
80
- Crypto::Bytes.from_string(card.snapshot)
82
+ Crypto::Bytes.from_string(card.snapshot)
81
83
  )
82
84
  fingerprint_hex = fingerprint.to_hex
83
85
  return false if fingerprint_hex != card.id
@@ -85,14 +87,15 @@ module Virgil
85
87
  verifiers = self.verifiers.clone
86
88
  card_public_key = self.crypto.import_public_key(card.public_key)
87
89
  verifiers[fingerprint_hex] = card_public_key
90
+
88
91
  verifiers.each do |id, key|
89
92
  unless card.signatures.has_key?(id)
90
93
  return false
91
94
  end
92
95
  is_valid = self.crypto.verify(
93
- fingerprint.value,
94
- Crypto::Bytes.from_base64(card.signatures[id]),
95
- key
96
+ fingerprint.value,
97
+ Crypto::Bytes.from_base64(card.signatures[id]),
98
+ key
96
99
  )
97
100
  return false unless is_valid
98
101
  end
@@ -41,7 +41,7 @@ module Virgil
41
41
  # Contains cards service specific errors dictionary.
42
42
  class CardsServiceConnection < BaseConnection
43
43
  ERRORS = {
44
- 10000 => "Internal application error. You know, shit happens, so do internal server errors.Just take a deep breath and try harder.",
44
+ 10000 => "Internal application error",
45
45
  20300 => "The Virgil access token was not specified or is invalid",
46
46
  20301 => "The Virgil authenticator service responded with an error",
47
47
  20302 => "The Virgil access token validation has failed on the Virgil Authenticator service",
@@ -60,7 +60,7 @@ module Virgil
60
60
  access_token=nil,
61
61
  cards_service_url=Card::SERVICE_URL,
62
62
  cards_read_only_service_url=Card::READ_ONLY_SERVICE_URL,
63
- identity_service_url=Virgil::SDK::VirgilIdentity::IDENTITY_SERVICE_URL,
63
+ identity_service_url=Virgil::SDK::HighLevel::VirgilIdentity::IDENTITY_SERVICE_URL,
64
64
  ra_service_url=Card::RA_SERVICE_URL
65
65
  )
66
66
  self.access_token = access_token
@@ -53,9 +53,9 @@ module Virgil
53
53
  @credentials = credentials
54
54
  @key_storage = Cryptography::Keys::KeyStorage.new(key_storage_path)
55
55
 
56
- if card_verifiers.any?
56
+ @client.card_validator = Client::CardValidator.new(@crypto)
57
57
 
58
- @client.card_validator = Client::CardValidator.new(@crypto)
58
+ if card_verifiers.any?
59
59
 
60
60
  card_verifiers.each do |card_verifier|
61
61
  raise ArgumentError.new("card_verifiers is not valid") unless card_verifier.is_a? VirgilCardVerifierInfo
@@ -7,7 +7,7 @@ module Virgil
7
7
  autoload :ValidationToken, 'virgil/sdk/high_level/virgil_identity/validation_token'
8
8
  autoload :EmailConfirmation, 'virgil/sdk/high_level/virgil_identity/email_confirmation'
9
9
 
10
- IDENTITY_SERVICE_URL = ENV["VIRGIL_IDENTITY_SERVICE_URL"] || "https://identity.virgilsecurity.com"
10
+ IDENTITY_SERVICE_URL = "https://identity.virgilsecurity.com"
11
11
 
12
12
  EMAIL = "email"
13
13
  USERNAME = "username"
@@ -1,5 +1,5 @@
1
1
  module Virgil
2
2
  module SDK
3
- VERSION = "4.2.5"
3
+ VERSION = "4.2.6"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: virgil-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.5
4
+ version: 4.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitriy Dudkin
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-03-07 00:00:00.000000000 Z
11
+ date: 2017-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: virgil-crypto