aliquot-pay 0.7.2 → 0.8.0

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/aliquot-pay.rb +12 -8
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4dbf56f4fc63c0b699ee99e3f6351826b9377e1e712e38a9b7f3cbe454979d25
4
- data.tar.gz: 51d777f4570431fedb62896e51bc371f7abe4a88547aad9440eae49b658fda12
3
+ metadata.gz: ac0940b9a875b2ab9a701f8119a16d3a6c23dc0364f75d43a95f6d3b5322d933
4
+ data.tar.gz: a797dd4244f1588b268bf6897c2f3767ab96fbbf2ad2e6ac12480e9608d40561
5
5
  SHA512:
6
- metadata.gz: 10e43724e68f871d4dad12c68c481f1635dc101e7afb2aa353ade22228d1c5e245c347c4d24f6eb69ef4ffae27d23465edb94d7786995edac28b7e56b198bd3f
7
- data.tar.gz: d230dcd3a359e8d77b664057e3e87e0066f82f1512b0677485094ae009894fe25d2caf59c9cb7a6b9955f7baec4b182a7a532059ab266f2b104171401ae86a89
6
+ metadata.gz: '0188e39eec0d9758e300d4ab782a1d1b4cadab2d5afee6c146a4b8e06123dfa481bbf3ad656586a33a3485f8fed9570007aa9cf6f7479b97100a6e33936b44b9'
7
+ data.tar.gz: 334e18c73fefb6f667107104cc0d297a176db3a2dd59b2ae668211e7daf377a50f5ea72958e7875ac596fa90395df2130438354b69fe52daca1caa23c791c2aa
data/lib/aliquot-pay.rb CHANGED
@@ -80,9 +80,9 @@ module AliquotPay
80
80
 
81
81
  def self.signature_string(
82
82
  message,
83
- recipient_id = DEFAULTS[:merchant_id],
84
- sender_id = DEFAULTS[:info],
85
- protocol_version = 'ECv1'
83
+ recipient_id: DEFAULTS[:merchant_id],
84
+ sender_id: DEFAULTS[:info],
85
+ protocol_version: 'ECv1'
86
86
  )
87
87
 
88
88
  generate_signature(sender_id, recipient_id, protocol_version, message)
@@ -104,14 +104,18 @@ module AliquotPay
104
104
  }
105
105
  end
106
106
 
107
- def self.generate_token_ecv2(payment, signing_key, intermediate_key, recipient, signed_message = nil)
107
+ def self.generate_token_ecv2(payment, signing_key, intermediate_key, recipient,
108
+ signed_message: nil, expire_time: "#{Time.now.to_i + 3600}000")
108
109
  cipher = OpenSSL::Cipher::AES256.new(:CTR)
109
110
  signed_message ||= JSON.unparse(encrypt(JSON.unparse(payment), recipient, cipher))
110
- signature_string = signature_string(signed_message)
111
+ sig = signature_string(signed_message, protocol_version: 'ECv2')
112
+
113
+ intermediate_pub = OpenSSL::PKey::EC.new(EC_CURVE)
114
+ intermediate_pub.public_key = intermediate_key.public_key
111
115
 
112
116
  signed_key = JSON.unparse(
113
- 'keyExpiration' => "#{Time.now.to_i + 3600}000",
114
- 'keyValue' => Base64.strict_encode64(intermediate_key.public_key.to_bn.to_s(2))
117
+ 'keyExpiration' => expire_time,
118
+ 'keyValue' => Base64.strict_encode64(intermediate_pub.to_der)
115
119
  )
116
120
 
117
121
  ik_signature_string = generate_signature('Google', 'ECv2', signed_key)
@@ -119,7 +123,7 @@ module AliquotPay
119
123
 
120
124
  {
121
125
  'protocolVersion' => 'ECv2',
122
- 'signature' => sign(intermediate_key, signature_string),
126
+ 'signature' => sign(intermediate_key, sig),
123
127
  'signedMessage' => signed_message,
124
128
  'intermediateSigningKey' => {
125
129
  'signedKey' => signed_key,
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aliquot-pay
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.2
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Clearhaus