ruby-common 1.0.2 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0dd03746b475edbc264058f3faaa16831625260421dc077dd90443c43f23237e
4
- data.tar.gz: 94104a902329dcf94ef5d1267716a5c10a69bee660c4182f76d559a2f42227bb
3
+ metadata.gz: 84bf79c0a169246ff83fbe15486b281b34b54976009fb2dd0d1d06dd22092140
4
+ data.tar.gz: 31e74cde29d8600b41fae7be4e4579cf2e890b86ab61caf88a3332c2e1eade37
5
5
  SHA512:
6
- metadata.gz: 66c026586ab134fa73bfeb96154970fea8bac2471e8a4dc5a3f6099e1a71f51c9282f84cfe251d0eb7c1ee2211008dbe9ab98ebdc346fb007a253de535fb5971
7
- data.tar.gz: '09cdc1c043e63cbb912d6bac89721c0bc280adb44649825f3925e586187748657902dec2a936ced13690ebf293d8c6cda6523cbfa27b319e1aca24be4e529c78'
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 = FIELD_IDS[header['fieldId'].first]
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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Ruby
4
4
  module Common
5
- VERSION = "1.0.2"
5
+ VERSION = "1.0.3"
6
6
  end
7
7
  end
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.2
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: 2024-11-05 00:00:00.000000000 Z
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