aliquot-pay 2.2.0 → 3.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/aliquot-pay.rb +9 -17
  3. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: df10b773da7321ea564c012fd5d487c07c0779ced77d1535e3b3a10691157b39
4
- data.tar.gz: c6231c0006e33298f414ced2e286ac45ef4df5f16a2efa633a8025e1373fca15
3
+ metadata.gz: bd781c1bcf3c08449d83bdd303af4e9ea5f626edf34ef36d693e59c5046bd76d
4
+ data.tar.gz: 14b8f7ca9f162cf03ff041f4a441e530b7847a13fbdc5d09de19cd3ccc8eb941
5
5
  SHA512:
6
- metadata.gz: 32790400342af932a01adeaaf8cb0ed943ffe2343954972deb4d20f7e5e34482ff71ab924f395221db3affd0128cfeb8b6ae95cc19d1c19dbcedde0d2ca963a6
7
- data.tar.gz: 23aa8bec6cb97d8ec513e1fb6323f35b60f7ad1baca8627d4091e2898b1d1a03f38882b1949f34f56064bde33ba330978b84b0a69c0f321c35639bba26539d02
6
+ metadata.gz: be990eb9f8bce95b200b8c9be5fa88ec3fb24aaa8f91be448a76e0758f04a7717679bde3447c3a82fb42a63b1a7b257ba8a3d06ec296df9b685154f1b0233579
7
+ data.tar.gz: c635f9118731166e62d49ba5cedff290f78e28233303e92a07d562002a3b91c57e882e151ac46724da142ac5506452c71dcdd81e5eeef2da710d950fe82fe30b
data/lib/aliquot-pay.rb CHANGED
@@ -25,8 +25,11 @@ class AliquotPay
25
25
  attr_accessor :recipient, :info, :root_key, :intermediate_key
26
26
  attr_writer :recipient_id, :shared_secret, :token, :signed_key_string
27
27
 
28
- def initialize(protocol_version = :ECv2)
28
+ def initialize(protocol_version = :ECv2, root_key = nil)
29
29
  @protocol_version = protocol_version
30
+ if root_key
31
+ @root_key = root_key
32
+ end
30
33
  end
31
34
 
32
35
  def token
@@ -34,7 +37,7 @@ class AliquotPay
34
37
  end
35
38
 
36
39
  def extract_root_signing_keys
37
- key = Base64.strict_encode64(eckey_to_public(ensure_root_key))
40
+ key = Base64.strict_encode64(ensure_root_key.to_der)
38
41
  {
39
42
  'keys' => [
40
43
  'protocolVersion' => @protocol_version,
@@ -43,22 +46,11 @@ class AliquotPay
43
46
  }.to_json
44
47
  end
45
48
 
46
- if OpenSSL::VERSION >= '3'
47
- # pkeys are immutable on OpenSSL >=3.0
48
- def eckey_to_public(key)
49
- key.public_to_der
50
- end
51
- else
52
- def eckey_to_public(key)
53
- k = OpenSSL::PKey::EC.new(EC_CURVE)
54
- k.public_key = key.public_key
55
- k.to_der
56
- end
57
- end
58
-
59
49
  def sign(key, message)
60
50
  d = OpenSSL::Digest::SHA256.new
61
- def key.private?; private_key?; end
51
+ def key.private?
52
+ private_key?
53
+ end
62
54
  Base64.strict_encode64(key.sign(d, message))
63
55
  end
64
56
 
@@ -159,7 +151,7 @@ class AliquotPay
159
151
  fail 'Intermediate key must be public and private key'
160
152
  end
161
153
 
162
- default_key_value = Base64.strict_encode64(eckey_to_public(@intermediate_key))
154
+ default_key_value = Base64.strict_encode64(@intermediate_key.to_der)
163
155
  default_key_expiration = "#{Time.now.to_i + 3600}000"
164
156
 
165
157
  @signed_key = {
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aliquot-pay
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 3.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Clearhaus
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-27 00:00:00.000000000 Z
11
+ date: 2023-11-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hkdf
@@ -79,7 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
79
79
  - !ruby/object:Gem::Version
80
80
  version: '0'
81
81
  requirements: []
82
- rubygems_version: 3.1.6
82
+ rubygems_version: 3.3.26
83
83
  signing_key:
84
84
  specification_version: 4
85
85
  summary: Generates Google Pay test dummy tokens