yoti 1.6.1 → 1.6.2
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.
- checksums.yaml +5 -5
- data/lib/yoti/data_type/document_details.rb +5 -13
- data/lib/yoti/sandbox.rb +0 -1
- data/lib/yoti/sandbox/sandbox_client.rb +3 -8
- data/lib/yoti/ssl.rb +1 -0
- data/lib/yoti/version.rb +1 -1
- metadata +9 -11
- data/lib/yoti/sandbox/sandbox.rb +0 -105
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9c4c6b42bdd6df1e2563833af67cdae2986629ac2af375f12bcaf4ece3337584
|
4
|
+
data.tar.gz: 4c715d060b60a2fea8d72a29ba36706b8f95e72dd86fbece7a73a7e750a6f9f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36ea44c5b17a8f8b87ce6177e1d3278aa6323f3e77492cd87a6fc88bb7d0fd47d33be56c81e810ae3cac54fa21d61df80cb1d95941d98cec681b5a642667f60e
|
7
|
+
data.tar.gz: 36e481733c4d16d4f894e341695d63cb8ac20c34be7116439f8881f5d8d5a4e0e9f819c8e1c89b2f971cd2439a1b17e3033dc5da51242344a4bd95971d25ec94
|
@@ -1,10 +1,10 @@
|
|
1
1
|
module Yoti
|
2
2
|
class DocumentDetails
|
3
3
|
#
|
4
|
-
#
|
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
@@ -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(
|
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/#{
|
13
|
+
endpoint = "/apps/#{Yoti.configuration.client_sdk_id}/tokens?\
|
18
14
|
nonce=#{SecureRandom.uuid}×tamp=#{Time.now.to_i}"
|
19
15
|
uri = URI(
|
20
16
|
"#{@base_url}/#{endpoint}"
|
@@ -23,8 +19,7 @@ nonce=#{SecureRandom.uuid}×tamp=#{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
data/lib/yoti/version.rb
CHANGED
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.
|
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-
|
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
|
-
|
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.
|
data/lib/yoti/sandbox/sandbox.rb
DELETED
@@ -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}×tamp=#{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
|