yoti 1.6.1 → 1.6.2

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
- SHA1:
3
- metadata.gz: 554c3f07a3798f6c7f40a0dcd126449a8d866fe6
4
- data.tar.gz: 3f09b020f30e99038faf01bc74db8106f4fc7b31
2
+ SHA256:
3
+ metadata.gz: 9c4c6b42bdd6df1e2563833af67cdae2986629ac2af375f12bcaf4ece3337584
4
+ data.tar.gz: 4c715d060b60a2fea8d72a29ba36706b8f95e72dd86fbece7a73a7e750a6f9f2
5
5
  SHA512:
6
- metadata.gz: 37cbabc0963156cdd95bc7ba2bd1657ce01a180619c44993f4e2298e902f0d7856d924c887a1333bec73fd8c24c8d553136b18733470191df2a59b3d5399fca2
7
- data.tar.gz: 49c22b5abc8a43e6e3c7b0021a7b3a2c37b417f24f6247f01dd6844c638969b4c216be52fd0e646b1f1a4285d93ce2a3982b6d687f9d9d06451c3a4387b19369
6
+ metadata.gz: 36ea44c5b17a8f8b87ce6177e1d3278aa6323f3e77492cd87a6fc88bb7d0fd47d33be56c81e810ae3cac54fa21d61df80cb1d95941d98cec681b5a642667f60e
7
+ data.tar.gz: 36e481733c4d16d4f894e341695d63cb8ac20c34be7116439f8881f5d8d5a4e0e9f819c8e1c89b2f971cd2439a1b17e3033dc5da51242344a4bd95971d25ec94
@@ -1,10 +1,10 @@
1
1
  module Yoti
2
2
  class DocumentDetails
3
3
  #
4
- # The values of the Document Details are in the format and order as defined in this pattern
5
- # e.g PASS_CARD GBR 22719564893 - CITIZENCARD, the last two are optionals
4
+ # @deprecated 2.0.0 pattern is no longer used for validation.
6
5
  #
7
6
  VALIDATION_PATTERN = '^([A-Za-z_]*) ([A-Za-z]{3}) ([A-Za-z0-9]{1}).*$'
7
+
8
8
  TYPE_INDEX = 0
9
9
  COUNTRY_INDEX = 1
10
10
  NUMBER_INDEX = 2
@@ -51,28 +51,20 @@ module Yoti
51
51
  # @param [String] value
52
52
  #
53
53
  def initialize(value)
54
- validate_value(value)
55
54
  parse_value(value)
56
55
  end
57
56
 
58
57
  private
59
58
 
60
- #
61
- # Asserts provided matches VALIDATION_PATTERN
62
- #
63
- # @param [String] value
64
- #
65
- def validate_value(value)
66
- raise(ArgumentError, "Invalid value for #{self.class.name}") unless /#{VALIDATION_PATTERN}/.match?(value)
67
- end
68
-
69
59
  #
70
60
  # Parses provided value into separate attributes
71
61
  #
72
62
  # @param [String] value
73
63
  #
74
64
  def parse_value(value)
75
- attributes = value.split(' ')
65
+ attributes = value.split(/ /)
66
+ raise(ArgumentError, "Invalid value for #{self.class.name}") if attributes.length < 3 || attributes.include?('')
67
+
76
68
  @type = attributes[TYPE_INDEX]
77
69
  @issuing_country = attributes[COUNTRY_INDEX]
78
70
  @document_number = attributes[NUMBER_INDEX]
data/lib/yoti/sandbox.rb CHANGED
@@ -2,4 +2,3 @@ require_relative 'sandbox/anchor'
2
2
  require_relative 'sandbox/attribute'
3
3
  require_relative 'sandbox/profile'
4
4
  require_relative 'sandbox/sandbox_client'
5
- require_relative 'sandbox/sandbox'
@@ -3,18 +3,14 @@
3
3
  module Sandbox
4
4
  # Client is responsible for setting up test data in the sandbox instance
5
5
  class Client
6
- attr_accessor :app_id
7
- attr_accessor :key
8
6
  attr_accessor :base_url
9
7
 
10
- def initialize(app_id:, private_key:, base_url:)
11
- @app_id = app_id
8
+ def initialize(base_url:)
12
9
  @base_url = base_url
13
- @key = OpenSSL::PKey::RSA.new(Base64.decode64(private_key))
14
10
  end
15
11
 
16
12
  def setup_sharing_profile(profile)
17
- endpoint = "/apps/#{app_id}/tokens?\
13
+ endpoint = "/apps/#{Yoti.configuration.client_sdk_id}/tokens?\
18
14
  nonce=#{SecureRandom.uuid}&timestamp=#{Time.now.to_i}"
19
15
  uri = URI(
20
16
  "#{@base_url}/#{endpoint}"
@@ -23,8 +19,7 @@ nonce=#{SecureRandom.uuid}&timestamp=#{Time.now.to_i}"
23
19
  response = Net::HTTP.start(
24
20
  uri.hostname,
25
21
  uri.port,
26
- use_ssl: true,
27
- verify_mode: OpenSSL::SSL::VERIFY_NONE
22
+ use_ssl: true
28
23
  ) do |http|
29
24
  unsigned = Net::HTTP::Post.new uri
30
25
  unsigned.body = profile.to_json
data/lib/yoti/ssl.rb CHANGED
@@ -60,6 +60,7 @@ module Yoti
60
60
  end
61
61
 
62
62
  # Reset and reload the Private Key used for SSL functions
63
+ # @deprecated 2.0.0
63
64
  def reload!
64
65
  @private_key = nil
65
66
  @pem = nil
data/lib/yoti/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Yoti
2
2
  # @return [String] the gem's current version
3
- VERSION = '1.6.1'.freeze
3
+ VERSION = '1.6.2'.freeze
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yoti
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.1
4
+ version: 1.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastian Zaremba
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-23 00:00:00.000000000 Z
11
+ date: 2020-02-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -28,22 +28,22 @@ dependencies:
28
28
  name: google-protobuf
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '3.7'
34
31
  - - ">="
35
32
  - !ruby/object:Gem::Version
36
33
  version: 3.7.0
34
+ - - "~>"
35
+ - !ruby/object:Gem::Version
36
+ version: '3.7'
37
37
  type: :runtime
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
40
40
  requirements:
41
- - - "~>"
42
- - !ruby/object:Gem::Version
43
- version: '3.7'
44
41
  - - ">="
45
42
  - !ruby/object:Gem::Version
46
43
  version: 3.7.0
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '3.7'
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: protobuf
49
49
  requirement: !ruby/object:Gem::Requirement
@@ -265,7 +265,6 @@ files:
265
265
  - lib/yoti/sandbox/anchor.rb
266
266
  - lib/yoti/sandbox/attribute.rb
267
267
  - lib/yoti/sandbox/profile.rb
268
- - lib/yoti/sandbox/sandbox.rb
269
268
  - lib/yoti/sandbox/sandbox_client.rb
270
269
  - lib/yoti/share/attribute_issuance_details.rb
271
270
  - lib/yoti/share/extra_data.rb
@@ -297,8 +296,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
297
296
  - !ruby/object:Gem::Version
298
297
  version: '0'
299
298
  requirements: []
300
- rubyforge_project:
301
- rubygems_version: 2.6.14.4
299
+ rubygems_version: 3.0.6
302
300
  signing_key:
303
301
  specification_version: 4
304
302
  summary: Yoti Ruby SDK for back-end integration.
@@ -1,105 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'yoti'
4
- require 'yoti/configuration'
5
- require 'yoti/http/signed_request'
6
-
7
- require_relative 'sandbox_client'
8
- require_relative 'profile'
9
- require_relative 'anchor'
10
- require_relative 'attribute'
11
-
12
- require 'openssl'
13
- require 'net/http'
14
- require 'date'
15
- require 'securerandom'
16
-
17
- require 'dotenv'
18
- Dotenv.load
19
-
20
- # Singleton for sandbox test resources
21
- module Sandbox
22
- class << self
23
- attr_accessor :sandbox_client
24
- attr_accessor :dev_key
25
- attr_accessor :application
26
- end
27
-
28
- def self.setup!
29
- return if application
30
-
31
- read_dev_key!
32
- create_application!
33
- self.sandbox_client = Client.new(
34
- app_id: application['id'],
35
- private_key: application['private_key'],
36
- base_url: ENV['SANDBOX_BASE_URL']
37
- )
38
- configure_yoti(
39
- app_id: sandbox_client.app_id,
40
- pem: sandbox_client.key.to_pem
41
- )
42
- nil
43
- end
44
-
45
- def self.configure_yoti(app_id:, pem:)
46
- Yoti.configuration = Yoti::Configuration.new
47
- Yoti.configuration.client_sdk_id = app_id
48
- Yoti.configuration.key = pem
49
- Yoti.configuration.key_file_path = ''
50
- Yoti.configuration.api_endpoint = "#{ENV['SANDBOX_BASE_URL']}/"
51
- Yoti::SSL.reload!
52
- end
53
-
54
- def self.create_application_uri
55
- uri = URI(
56
- "#{ENV['SANDBOX_BASE_URL']}/#{ENV['SANDBOX_ENDPOINT']}?\
57
- nonce=#{SecureRandom.uuid}&timestamp=#{Time.now.to_i}"
58
- )
59
- uri.port = 11_443
60
- uri
61
- end
62
-
63
- def self.create_application!
64
- Yoti.configure do |config|
65
- config.key_file_path = ENV['SANDBOX_KEY']
66
- config.client_sdk_id = 'DUMMY'
67
- end
68
-
69
- uri = create_application_uri
70
- payload = { name: "Test Run #{DateTime.now.rfc3339}" }
71
-
72
- response = Net::HTTP.start(
73
- uri.hostname,
74
- uri.port,
75
- use_ssl: true,
76
- verify_mode: OpenSSL::SSL::VERIFY_NONE
77
- ) do |http|
78
- unsigned = Net::HTTP::Post.new uri
79
- unsigned.body = payload.to_json
80
- signed_request = Yoti::SignedRequest.new(
81
- unsigned,
82
- "#{ENV['SANDBOX_ENDPOINT']}?#{uri.query}",
83
- payload
84
- ).sign
85
- Yoti::Log.logger.info("Creating application #{signed_request.body}")
86
- http.request signed_request
87
- end
88
-
89
- raise "Create application failed #{response.code}: #{response.body}" unless response.code == '201'
90
-
91
- self.application = JSON.parse(response.body)
92
- nil
93
- end
94
-
95
- def self.read_dev_key!
96
- self.dev_key = OpenSSL::PKey::RSA.new(
97
- File.read(ENV['SANDBOX_KEY'], encoding: 'utf-8')
98
- )
99
- nil
100
- end
101
-
102
- def self.share(profile)
103
- sandbox_client.setup_sharing_profile profile
104
- end
105
- end