ruby-common 1.0.1 → 1.0.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.
- checksums.yaml +4 -4
- data/lib/ruby-common/common/Utils.rb +11 -0
- data/lib/ruby-common/v4/Signature4VerifierService.rb +18 -2
- data/lib/ruby-common/v5/Signature5VerificationResult.rb +1 -5
- data/lib/ruby-common/v5/StructUnpacker.rb +1 -0
- data/lib/ruby-common/version.rb +1 -1
- metadata +2 -3
- data/Gemfile.lock +0 -34
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 84bf79c0a169246ff83fbe15486b281b34b54976009fb2dd0d1d06dd22092140
|
4
|
+
data.tar.gz: 31e74cde29d8600b41fae7be4e4579cf2e890b86ab61caf88a3332c2e1eade37
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ede2c14c0687abd4447a015bdb53caeab2b461f68fb78a0153372f9edb02b37bc08c79f3d7f6309766d10a73f49f33ead48ddd65d5e8bca0dda0bf9b0c24247
|
7
|
+
data.tar.gz: 055e888365e655e077fd82f11e88eb35a696e471709b15f499e9e0c72cc386e276f1eac58ef177715538d16928bf093263b80a753d1ddd4039832160a41b179b
|
@@ -11,6 +11,10 @@ class SignatureVerifierUtils
|
|
11
11
|
return Base64.decode64(key)
|
12
12
|
end
|
13
13
|
|
14
|
+
def self.base64_encode(key)
|
15
|
+
return Base64.encode64(key)
|
16
|
+
end
|
17
|
+
|
14
18
|
def self.encode(key, data)
|
15
19
|
begin
|
16
20
|
hmac = OpenSSL::HMAC.new(key, 'sha256')
|
@@ -19,4 +23,11 @@ class SignatureVerifierUtils
|
|
19
23
|
raise SignatureParseError, "Error encode data"
|
20
24
|
end
|
21
25
|
end
|
26
|
+
|
27
|
+
def self.pad_start(input_string, length, char)
|
28
|
+
return input_string if input_string.length >= length
|
29
|
+
|
30
|
+
padding = char.to_s * (length - input_string.length)
|
31
|
+
padding + input_string
|
32
|
+
end
|
22
33
|
end
|
@@ -113,6 +113,10 @@ class Signature4VerifierService
|
|
113
113
|
raise StructParseError, 'no verdict'
|
114
114
|
end
|
115
115
|
|
116
|
+
def self.parse_4(signature)
|
117
|
+
return parse4(signature)
|
118
|
+
end
|
119
|
+
|
116
120
|
class << self
|
117
121
|
private
|
118
122
|
|
@@ -127,7 +131,6 @@ class Signature4VerifierService
|
|
127
131
|
raise SignatureParseError, 'invalid timestamp (future time)' if timestamp > (Time.now.to_i)
|
128
132
|
|
129
133
|
master_token_length = unpack_result['masterTokenLength']
|
130
|
-
#TODO CO TO KURWA JEST ZA METODA?
|
131
134
|
master_token = get_bytes_and_advance_position(sign_decoded, master_token_length)
|
132
135
|
unpack_result['masterToken'] = master_token
|
133
136
|
|
@@ -154,7 +157,7 @@ class Signature4VerifierService
|
|
154
157
|
|
155
158
|
raise SignatureParseError, 'premature end of signature 0x01' if header.empty? || !header.key?('fieldId')
|
156
159
|
|
157
|
-
field =
|
160
|
+
field = field_type_def(header['fieldId'].first, i)
|
158
161
|
v = {}
|
159
162
|
|
160
163
|
case field&.type
|
@@ -199,5 +202,18 @@ class Signature4VerifierService
|
|
199
202
|
def get_base(verdict, request_time, signature_time, ip_address, user_agent)
|
200
203
|
[verdict, request_time, signature_time, ip_address, user_agent].join("\n")
|
201
204
|
end
|
205
|
+
|
206
|
+
private def field_type_def(field_id, i)
|
207
|
+
if FIELD_IDS[field_id]
|
208
|
+
return FIELD_IDS[field_id]
|
209
|
+
end
|
210
|
+
|
211
|
+
result_type = FIELD_IDS[field_id & 0xC0].type
|
212
|
+
|
213
|
+
i_str = SignatureVerifierUtils.pad_start(i.to_s, 2, '0')
|
214
|
+
result_name = result_type + i_str
|
215
|
+
|
216
|
+
Field.new(result_name, result_type)
|
217
|
+
end
|
202
218
|
end
|
203
219
|
end
|
@@ -65,8 +65,6 @@ class Signature5VerificationResult
|
|
65
65
|
attr_accessor :request_time
|
66
66
|
# Signature time
|
67
67
|
attr_accessor :signature_time
|
68
|
-
# Signature time
|
69
|
-
attr_accessor :h_signature_time
|
70
68
|
# Token
|
71
69
|
attr_accessor :token
|
72
70
|
# Other, which has not been mapped to a field, or getting error during parsing
|
@@ -105,8 +103,7 @@ class Signature5VerificationResult
|
|
105
103
|
@incognito = hash.delete('incognito')
|
106
104
|
@sub_id = hash.delete('sub_id')
|
107
105
|
@request_time = hash.delete('requestTime')&.to_i
|
108
|
-
@
|
109
|
-
@signature_time = hash.delete('signatureTime')
|
106
|
+
@signature_time = hash.delete('signatureTime')&.to_i
|
110
107
|
@token = hash.delete('token')
|
111
108
|
@additional_data = hash
|
112
109
|
end
|
@@ -146,7 +143,6 @@ class Signature5VerificationResult
|
|
146
143
|
Subscriber ID: #{@sub_id}
|
147
144
|
Request Time: #{@request_time}
|
148
145
|
Signature Time: #{@signature_time}
|
149
|
-
H Signature Time: #{@h_signature_time}
|
150
146
|
Token: #{@token}
|
151
147
|
Additional Data: #{@additional_data}
|
152
148
|
STRING
|
data/lib/ruby-common/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-common
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adrian Parzych
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-02-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rbnacl
|
@@ -62,7 +62,6 @@ files:
|
|
62
62
|
- CHANGELOG.md
|
63
63
|
- CODE_OF_CONDUCT.md
|
64
64
|
- Gemfile
|
65
|
-
- Gemfile.lock
|
66
65
|
- LICENSE.md
|
67
66
|
- README.md
|
68
67
|
- Rakefile
|
data/Gemfile.lock
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
ruby-common (0.1.0)
|
5
|
-
|
6
|
-
GEM
|
7
|
-
remote: https://rubygems.org/
|
8
|
-
specs:
|
9
|
-
diff-lcs (1.5.1)
|
10
|
-
rake (13.2.1)
|
11
|
-
rspec (3.13.0)
|
12
|
-
rspec-core (~> 3.13.0)
|
13
|
-
rspec-expectations (~> 3.13.0)
|
14
|
-
rspec-mocks (~> 3.13.0)
|
15
|
-
rspec-core (3.13.0)
|
16
|
-
rspec-support (~> 3.13.0)
|
17
|
-
rspec-expectations (3.13.1)
|
18
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
19
|
-
rspec-support (~> 3.13.0)
|
20
|
-
rspec-mocks (3.13.1)
|
21
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
22
|
-
rspec-support (~> 3.13.0)
|
23
|
-
rspec-support (3.13.1)
|
24
|
-
|
25
|
-
PLATFORMS
|
26
|
-
x86_64-linux
|
27
|
-
|
28
|
-
DEPENDENCIES
|
29
|
-
rake (~> 13.0)
|
30
|
-
rspec
|
31
|
-
ruby-common!
|
32
|
-
|
33
|
-
BUNDLED WITH
|
34
|
-
2.3.5
|