mailkube 1.2.0 → 1.2.1
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 +4 -4
- data/lib/mailkube/version.rb +1 -1
- data/lib/mailkube/webhooks.rb +10 -3
- 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: afd85d0c480e7cff16fd2df6344b221acf946f644e97e7f9d7b33f2472ac5c51
|
|
4
|
+
data.tar.gz: 32f66b35b8f0e9631ca737ffcc1c51b6e1b98be6746f9a1d4019c623ce24e9ff
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e7d1a7c1e83031bbd5fca5533ecff6635361726c401b20112e856d3b62ca62211764c3498501a36d9907a6de7a2b9d0d0304d0002a725f4f4c8c013c6e3a35d0
|
|
7
|
+
data.tar.gz: 9c7ecae8c33e302db1a539d4fbc88ec46bd1b3edf60cda62820e7b4d3ae8d499d67f116736bec04a6445f50692dc3b7a76d108b2e209e9faa983eac9890a1a17
|
data/lib/mailkube/version.rb
CHANGED
|
@@ -11,5 +11,5 @@ module Mailkube
|
|
|
11
11
|
# semantic-release rewrites this line **in the release runner** just before the gem is built, and
|
|
12
12
|
# commits nothing back to `main` (see `.rules/RELEASE.md`). So a checkout reports `0.0.0` and an
|
|
13
13
|
# installed gem reports the real version: that is intended, not a bug to fix by hardcoding one.
|
|
14
|
-
VERSION = "1.2.
|
|
14
|
+
VERSION = "1.2.1"
|
|
15
15
|
end
|
data/lib/mailkube/webhooks.rb
CHANGED
|
@@ -15,8 +15,15 @@ module Mailkube
|
|
|
15
15
|
# The prefix the server puts before the hex digest in `X-Webhook-Sig`.
|
|
16
16
|
SIGNATURE_PREFIX = "sha256="
|
|
17
17
|
# Decode webhook payloads deep-frozen, so a receiver cannot mutate an event it is about to
|
|
18
|
-
# forward or log.
|
|
19
|
-
#
|
|
18
|
+
# forward or log. Splatted as **keywords** at the call site, because json 3.0 made every
|
|
19
|
+
# `JSON.parse` option keyword-only: a positional hash now raises `ArgumentError`, and it is
|
|
20
|
+
# not coming back (ruby/json#1078 is closed as "not planned" — only `JSON.dump`'s positional
|
|
21
|
+
# `limit` was restored, in 3.0.1).
|
|
22
|
+
#
|
|
23
|
+
# The splat is also the compatible direction, which is why there is no `json` floor in the
|
|
24
|
+
# gemspec and the gem stays stdlib-only: json 2.x declares `(source, opts = nil)`, and Ruby
|
|
25
|
+
# collects keywords into the trailing positional Hash for a method that declares none. One
|
|
26
|
+
# call site, both majors. Verified against json 2.21.2 and 3.0.2 on Ruby 3.4.
|
|
20
27
|
PARSE_OPTIONS = { freeze: true }.freeze
|
|
21
28
|
|
|
22
29
|
# Verify a webhook's signature and timestamp freshness over the raw body.
|
|
@@ -65,7 +72,7 @@ module Mailkube
|
|
|
65
72
|
# @return [Events::Event] the parsed event; narrow it with `case` or `is_a?`.
|
|
66
73
|
# @raise [Error] when the body is not a JSON object.
|
|
67
74
|
def self.parse_event(payload)
|
|
68
|
-
body = JSON.parse(payload, PARSE_OPTIONS)
|
|
75
|
+
body = JSON.parse(payload, **PARSE_OPTIONS)
|
|
69
76
|
raise Error, "webhook payload is not a JSON object" unless body.is_a?(Hash)
|
|
70
77
|
|
|
71
78
|
Events::REGISTRY.fetch(body["type"], Events::UnknownEvent).new(body)
|