govuk-registers-api-client 1.2.2 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.version +1 -1
- data/govuk-registers-api-client.gemspec +2 -3
- data/lib/data_store.rb +0 -6
- data/lib/in_memory_data_store.rb +0 -8
- data/lib/register_client.rb +0 -33
- data/lib/register_client_manager.rb +1 -1
- metadata +3 -6
- data/lib/exceptions/invalid_hash_value_error.rb +0 -5
- data/lib/exceptions/invalid_register_error.rb +0 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3c79b43538961d0c037891bc4eaa67e0da7bf69050a2cd7c2a1336dff51b0c2a
|
4
|
+
data.tar.gz: 61e8dd48b0039c5c056a84a36d533c2b0a524f009123cbc350e48f8c92af10b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac33158386fee446b0ff90467a32aea323966da03f04e03393b017b9f1eb7adeadb54316a493ccd240e74a0c7eb07c41d0e4c27912215d6045f7c1cfa09efc94
|
7
|
+
data.tar.gz: 3986be8a39634b281f86aa256d40dcc7917cbb30899fdd47e3c515983b62382429a8856fc71b84bef9cbda9c6e4a2d1324c121ed0d0d8137e16d75d962eab4eb
|
data/.version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
2.0.0
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: govuk-registers-api-client
|
2
|
+
# stub: govuk-registers-api-client 2.0.0 ruby lib
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "govuk-registers-api-client".freeze
|
@@ -8,7 +8,6 @@ Gem::Specification.new do |s|
|
|
8
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
9
9
|
s.require_paths = ["lib".freeze]
|
10
10
|
s.authors = ["GOV.UK Registers Team (Government Digital Service)".freeze]
|
11
|
-
s.date = "2017-11-06"
|
12
11
|
s.email = "registers ~@nospam@~ digital.cabinet-office.gov.uk".freeze
|
13
12
|
s.extra_rdoc_files = ["README.md".freeze]
|
14
13
|
s.files = `git ls-files -z`.split("\x0").reject do |f|
|
@@ -22,7 +21,7 @@ Gem::Specification.new do |s|
|
|
22
21
|
|
23
22
|
if s.respond_to? :specification_version then
|
24
23
|
s.specification_version = 4
|
25
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('
|
24
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('2.0.0') then
|
26
25
|
s.add_runtime_dependency(%q<rest-client>.freeze, ["~> 2"])
|
27
26
|
else
|
28
27
|
s.add_dependency(%q<rest-client>.freeze, ["~> 2"])
|
data/lib/data_store.rb
CHANGED
data/lib/in_memory_data_store.rb
CHANGED
data/lib/register_client.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
require 'rest-client'
|
2
2
|
require 'json'
|
3
|
-
require 'exceptions/invalid_register_error'
|
4
|
-
require 'exceptions/invalid_hash_value_error'
|
5
3
|
|
6
4
|
module RegistersClient
|
7
5
|
class RegisterClient
|
@@ -77,19 +75,9 @@ module RegistersClient
|
|
77
75
|
RecordCollection.new(get_records.select { |record| record.item.has_end_date }, @page_size)
|
78
76
|
end
|
79
77
|
|
80
|
-
def get_root_hash
|
81
|
-
root_hash = @data_store.get_root_hash
|
82
|
-
if !is_valid_hash_value(root_hash)
|
83
|
-
raise InvalidHashValueError
|
84
|
-
end
|
85
|
-
return root_hash
|
86
|
-
end
|
87
|
-
|
88
78
|
def refresh_data
|
89
79
|
user_entry_number = @data_store.get_latest_entry_number(:user)
|
90
80
|
rsf = download_rsf(user_entry_number)
|
91
|
-
|
92
|
-
validate_register_integrity(rsf, user_entry_number)
|
93
81
|
update_data_from_rsf(rsf, user_entry_number, @data_store)
|
94
82
|
end
|
95
83
|
|
@@ -118,20 +106,6 @@ module RegistersClient
|
|
118
106
|
records_with_history
|
119
107
|
end
|
120
108
|
|
121
|
-
def get_register_proof
|
122
|
-
@register_proof = JSON.parse(register_http_request('proof/register/merkle:sha-256'))
|
123
|
-
end
|
124
|
-
|
125
|
-
def validate_register_integrity(rsf, current_entry_number)
|
126
|
-
rsf_lines = rsf.split("\n")
|
127
|
-
expected_root_hash = rsf_lines[0].split("\t")[1]
|
128
|
-
local_root_hash = @data_store.get_root_hash
|
129
|
-
|
130
|
-
if (local_root_hash != expected_root_hash)
|
131
|
-
raise InvalidRegisterError, 'Register has been reloaded with different data - root hashes do not match'
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
109
|
def download_rsf(start_entry_number)
|
136
110
|
register_http_request("download-rsf/#{start_entry_number}")
|
137
111
|
end
|
@@ -161,9 +135,6 @@ module RegistersClient
|
|
161
135
|
data_store.append_entry(entry)
|
162
136
|
end
|
163
137
|
end
|
164
|
-
elsif command == 'assert-root-hash'
|
165
|
-
root_hash = line.split("\t")[1]
|
166
|
-
data_store.set_root_hash(root_hash)
|
167
138
|
end
|
168
139
|
end
|
169
140
|
|
@@ -182,9 +153,5 @@ module RegistersClient
|
|
182
153
|
|
183
154
|
RestClient.get(@register_url.merge(path).to_s, headers)
|
184
155
|
end
|
185
|
-
|
186
|
-
def is_valid_hash_value(hash_value)
|
187
|
-
(/sha-256:+\h{64}/) === hash_value
|
188
|
-
end
|
189
156
|
end
|
190
157
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: govuk-registers-api-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GOV.UK Registers Team (Government Digital Service)
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-03-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -46,8 +46,6 @@ files:
|
|
46
46
|
- lib/data_store.rb
|
47
47
|
- lib/entry.rb
|
48
48
|
- lib/entry_collection.rb
|
49
|
-
- lib/exceptions/invalid_hash_value_error.rb
|
50
|
-
- lib/exceptions/invalid_register_error.rb
|
51
49
|
- lib/in_memory_data_store.rb
|
52
50
|
- lib/item.rb
|
53
51
|
- lib/item_collection.rb
|
@@ -77,8 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
77
75
|
- !ruby/object:Gem::Version
|
78
76
|
version: '0'
|
79
77
|
requirements: []
|
80
|
-
|
81
|
-
rubygems_version: 2.7.7
|
78
|
+
rubygems_version: 3.0.3
|
82
79
|
signing_key:
|
83
80
|
specification_version: 4
|
84
81
|
summary: Client library for GOV.UK Registers
|