aliquot 0.14.0 → 0.15.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/payment.rb +10 -10
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aef4508df550d2c0646e46e3c9af7ec424ac424bf2ac83df5f2d58185a5b776f
4
- data.tar.gz: 89e191121749427cca2a0514ab667e35866db81fd331f61df583d9ac089084db
3
+ metadata.gz: 54635adaeefcc42d7fb42a854825fb7f88472ab34be2992813d899581f278969
4
+ data.tar.gz: 3f66d3b5d5cc20d3a58e0c0e64958906beee8e80f07af26a4868ad27efa68e2d
5
5
  SHA512:
6
- metadata.gz: 29a5aa707b1125ea0c9f9855aa023e862d5b05f8adb32b3d9752cef4606686059d3de09c1ac763d6aa874e514fa006b5585f719d2de50d6dd0a586205da95397
7
- data.tar.gz: 3a41488d17b8dceac58285802de953422bdd9853490b2bf943101a45c11dc2b09d76c2e3200f1db7b8c8e33dcf89fd9abedd62a2550eb7a580af315298a633e7
6
+ metadata.gz: 23548bcc9c7e7a5ad77353bae8eab0283bd7593b3a9cf536298961d501a0b1b3181b722bf3e75ae0805d9c9dfa336d71a037ed5553eb57d0082b69a7e62aa60b
7
+ data.tar.gz: a14a66a56577b6de570fa4164f30d2ca96c3a23b5b6b915d136dfd7d825242c0ae6a403cc138ff97e26f76dcad1450ba67d8a733f7b45611141ba46241fafdb8
@@ -26,7 +26,7 @@ module Aliquot
26
26
  validation = Aliquot::Validator::Token.new(JSON.parse(token_string))
27
27
  validation.validate
28
28
  rescue JSON::JSONError => e
29
- raise InputError, "token JSON invalid, #{e.message}"
29
+ raise InputError, "invalid token JSON, #{e.message}"
30
30
  end
31
31
 
32
32
  @token = validation.output
@@ -49,7 +49,7 @@ module Aliquot
49
49
 
50
50
  if protocol_version == 'ECv2'
51
51
  @intermediate_key = validate_intermediate_key
52
- raise InvalidSignatureError, 'intermediate certificate expired' if intermediate_key_expired?
52
+ raise InvalidSignatureError, 'intermediate certificate has expired' if intermediate_key_expired?
53
53
  end
54
54
 
55
55
  check_signature
@@ -62,19 +62,19 @@ module Aliquot
62
62
  raise KeyDerivationError, "unable to derive keys, #{e.message}"
63
63
  end
64
64
 
65
- raise InvalidMacError unless valid_mac?(mac_key)
65
+ raise InvalidMacError, 'MAC did not match' unless valid_mac?(mac_key)
66
66
 
67
67
  begin
68
68
  @message = JSON.parse(decrypt(aes_key, @signed_message[:encryptedMessage]))
69
69
  rescue JSON::JSONError => e
70
- raise InputError, "encryptedMessage JSON invalid, #{e.message}"
70
+ raise InputError, "invalid encryptedMessage JSON, #{e.message}"
71
71
  rescue => e
72
72
  raise DecryptionError, "decryption failed, #{e.message}"
73
73
  end
74
74
 
75
75
  @message = validate_message
76
76
 
77
- raise TokenExpiredError if expired?
77
+ raise TokenExpiredError, 'token has expired' if expired?
78
78
 
79
79
  @message
80
80
  end
@@ -103,7 +103,7 @@ module Aliquot
103
103
  end
104
104
 
105
105
  def validate_merchant_id
106
- raise InvalidMerchantIDError unless /[[:graph:]]/ =~ @merchant_id
106
+ raise InvalidMerchantIDError unless /\A[[:graph:]]+\z/ =~ @merchant_id
107
107
  "merchant:#{@merchant_id}"
108
108
  end
109
109
 
@@ -133,7 +133,7 @@ module Aliquot
133
133
  key.verify(new_digest, message_signature, signed_string_message)
134
134
  end.any?
135
135
 
136
- raise InvalidSignatureError unless success
136
+ raise InvalidSignatureError, 'signature of signedMessage did not match' unless success
137
137
  when 'ECv2'
138
138
  signed_key_signature = ['Google', 'ECv2', @token[:intermediateSigningKey][:signedKey]].map do |str|
139
139
  [str.length].pack('V') + str
@@ -141,7 +141,7 @@ module Aliquot
141
141
 
142
142
  # Check that the intermediate key signed the message
143
143
  pkey = OpenSSL::PKey::EC.new(Base64.strict_decode64(@intermediate_key[:keyValue]))
144
- raise InvalidSignatureError, 'intermediate did not sign message' unless pkey.verify(new_digest, message_signature, signed_string_message)
144
+ raise InvalidSignatureError, 'signature of signedMessage did not match' unless pkey.verify(new_digest, message_signature, signed_string_message)
145
145
 
146
146
  intermediate_signatures = @token[:intermediateSigningKey][:signatures]
147
147
 
@@ -152,12 +152,12 @@ module Aliquot
152
152
  signed_key_signature
153
153
  )
154
154
 
155
- raise InvalidSignatureError, 'intermediate not signed' unless success
155
+ raise InvalidSignatureError, 'no valid signature of intermediate key found' unless success
156
156
  end
157
157
  rescue OpenSSL::PKey::PKeyError => e
158
158
  # Catches problems with verifying signature. Can be caused by signature
159
159
  # being valid ASN1 but having invalid structure.
160
- raise InvalidSignatureError, e.message
160
+ raise InvalidSignatureError, "error verifying signature, #{e.message}"
161
161
  end
162
162
 
163
163
  def root_keys
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aliquot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.0
4
+ version: 0.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Clearhaus
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-14 00:00:00.000000000 Z
11
+ date: 2019-01-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-validation