increase 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/README.md +10 -9
- data/lib/increase/version.rb +1 -1
- data/lib/increase/webhook/signature.rb +7 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 316c9f7266fa873bde94e93509769dc4883691aa435da355d636a94f9c48b762
|
4
|
+
data.tar.gz: c38729a1d10974a7e46911e834c539b9931f18380d9e20aedcc71bc810fdb22d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7b31744c795da1c21e7f7dc85721bfeacdf115de67dee45a2751adc1a4e1d97d8a8fe69bac13d658921aeaf42873bbbe400d835e9f1a1a6e77941a19f5154bb
|
7
|
+
data.tar.gz: 1f89985c494abd6b3e50df9d24a21cc1d0078b576b20010a04a11ab666ad3c8f55e910fc7959d0ae10ed72dd40bd8eae6fdc7f91dbfe71e5f91c14cd7d756da9
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -19,14 +19,14 @@ Bare-Metal Banking APIs!
|
|
19
19
|
Install the gem and add to the application's Gemfile by executing:
|
20
20
|
|
21
21
|
```sh
|
22
|
-
$ bundle add increase -v 0.3.
|
22
|
+
$ bundle add increase -v 0.3.2
|
23
23
|
```
|
24
24
|
|
25
25
|
If bundler is not being used to manage dependencies, install the gem by
|
26
26
|
executing:
|
27
27
|
|
28
28
|
```sh
|
29
|
-
$ gem install increase -v 0.3.
|
29
|
+
$ gem install increase -v 0.3.2
|
30
30
|
```
|
31
31
|
|
32
32
|
## Usage
|
@@ -326,14 +326,15 @@ to run the console with your Increase sandbox API key pre-filled.
|
|
326
326
|
|
327
327
|
To install this gem onto your local machine, run `bundle exec rake install`.
|
328
328
|
|
329
|
-
To release a new version
|
330
|
-
run `bundle exec rake release`, which will create a git tag for the version,
|
331
|
-
push git commits and the created tag, and push the `.gem` file
|
332
|
-
to [rubygems.org](https://rubygems.org).
|
329
|
+
To release a new version:
|
333
330
|
|
334
|
-
|
335
|
-
|
336
|
-
|
331
|
+
- `gem bump --version patch|minor|major`
|
332
|
+
- Make sure you
|
333
|
+
have [`gem-release`](https://github.com/svenfuchs/gem-release)
|
334
|
+
installed
|
335
|
+
- Update the CHANGELOG and README if necessary
|
336
|
+
- `bundle exec rake release`
|
337
|
+
- Create release on GitHub from newly created tag
|
337
338
|
|
338
339
|
## Contributing
|
339
340
|
|
data/lib/increase/version.rb
CHANGED
@@ -23,7 +23,7 @@ module Increase
|
|
23
23
|
end
|
24
24
|
|
25
25
|
# Parse header
|
26
|
-
sig_values = signature_header
|
26
|
+
sig_values = signature_header&.split(",")&.map { |pair| pair.split("=") }&.to_h || {}
|
27
27
|
|
28
28
|
# Extract values
|
29
29
|
t = sig_values["t"] # Should be a string (ISO-8601 timestamp)
|
@@ -32,6 +32,8 @@ module Increase
|
|
32
32
|
raise sig_error.call("No signature found with scheme #{scheme} in signature header") if sig.nil?
|
33
33
|
|
34
34
|
# Check signature
|
35
|
+
raise sig_error.call("Webhook secret is required") if secret.nil?
|
36
|
+
raise sig_error.call("Payload is required") if payload.nil?
|
35
37
|
expected_sig = compute_signature(timestamp: t, payload: payload, secret: secret)
|
36
38
|
matches = Util.secure_compare(expected_sig, sig)
|
37
39
|
raise sig_error.call("Signature mismatch") unless matches
|
@@ -56,6 +58,10 @@ module Increase
|
|
56
58
|
end
|
57
59
|
|
58
60
|
def self.compute_signature(timestamp:, payload:, secret:)
|
61
|
+
raise ArgumentError, "timestamp is required" if timestamp.nil?
|
62
|
+
raise ArgumentError, "payload is required" if payload.nil?
|
63
|
+
raise ArgumentError, "secret is required" if secret.nil?
|
64
|
+
|
59
65
|
signed_payload = timestamp.to_s + "." + payload.to_s
|
60
66
|
OpenSSL::HMAC.hexdigest("SHA256", secret, signed_payload)
|
61
67
|
end
|