mailtruss 0.1.0 → 0.1.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/mailtruss/delivery_method.rb +1 -1
- data/lib/mailtruss/version.rb +1 -1
- data/lib/mailtruss.rb +2 -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: 7b7ba3baa7fb9c34eca4e865b3ddcf567348c1f2b6d81a81adcff5bf2da090f0
|
|
4
|
+
data.tar.gz: c77f8b6f2cef32c1709314cccf7bdf9cf8d3e1cdbe8a43023c76b019743d13db
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 834727cff3301866deec42c38d8361331f3e080656bbd152f223b036fe88540b3ef808626c5cad6d0f2136b74908092db8d86687ae4f39a1bec2bad9112e9c30
|
|
7
|
+
data.tar.gz: d5beda2e8a193e96c11664e53479566af75d4f8951b6f0d7c54bb6c7b5574bc155e18671e0504b38603daa9837d3fcdd258146a024d6a5e44ecc6792fc3e8341
|
|
@@ -49,7 +49,7 @@ module Mailtruss
|
|
|
49
49
|
end
|
|
50
50
|
if mail.attachments.any?
|
|
51
51
|
p[:attachments] = mail.attachments.map do |a|
|
|
52
|
-
att = { filename: a.filename, content:
|
|
52
|
+
att = { filename: a.filename, content: [a.decoded].pack("m0"), content_type: a.mime_type }
|
|
53
53
|
att[:content_id] = a.content_id.to_s.delete("<>") if a.inline?
|
|
54
54
|
att
|
|
55
55
|
end
|
data/lib/mailtruss/version.rb
CHANGED
data/lib/mailtruss.rb
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
require "json"
|
|
2
2
|
require "net/http"
|
|
3
3
|
require "openssl"
|
|
4
|
-
require "base64"
|
|
5
4
|
require "uri"
|
|
6
5
|
require_relative "mailtruss/version"
|
|
7
6
|
|
|
@@ -159,8 +158,8 @@ module Mailtruss
|
|
|
159
158
|
raise WebhookError, "Missing webhook-id, webhook-timestamp or webhook-signature header" unless id && ts && sigs
|
|
160
159
|
raise WebhookError, "Webhook timestamp is outside the allowed window" unless ts.to_s.match?(/\A\d+\z/) && (now - ts.to_i).abs <= tolerance
|
|
161
160
|
# Secrets issued before 2026-11-14 (whsec_ + 32 url-safe characters) are used as text; newer ones are base64 key bytes.
|
|
162
|
-
key = secret.match?(/\Awhsec_[A-Za-z0-9_-]{32}\z/) ? secret :
|
|
163
|
-
expected =
|
|
161
|
+
key = secret.match?(/\Awhsec_[A-Za-z0-9_-]{32}\z/) ? secret : secret.delete_prefix("whsec_").unpack1("m0")
|
|
162
|
+
expected = [OpenSSL::HMAC.digest("SHA256", key, "#{id}.#{ts}.#{body}")].pack("m0")
|
|
164
163
|
ok = sigs.to_s.split.any? { |part| v, sig = part.split(",", 2); v == "v1" && sig && sig.bytesize == expected.bytesize && OpenSSL.fixed_length_secure_compare(sig, expected) }
|
|
165
164
|
raise WebhookError, "Webhook signature does not match" unless ok
|
|
166
165
|
JSON.parse(body)
|