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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0aefd75093db988be98ed2ee2a5649567f768ea1a5506306fec9cf13dce5e161
4
- data.tar.gz: 552f058e0408b3d83845ddd2ed98fb363f8bb7a0c734e1a526e0dee4f4eb89ba
3
+ metadata.gz: 7b7ba3baa7fb9c34eca4e865b3ddcf567348c1f2b6d81a81adcff5bf2da090f0
4
+ data.tar.gz: c77f8b6f2cef32c1709314cccf7bdf9cf8d3e1cdbe8a43023c76b019743d13db
5
5
  SHA512:
6
- metadata.gz: 1ff4df3ef60ab13e0778b5c469459d126f33219431b0ec81f828191b368b3add7a8a657ab107ac35fdc7be81776924d5ccae693c2db44d7940081f235d0c02af
7
- data.tar.gz: 890aeea078fbf44a6e0d4b875a10ee0618526656d622a9f554d884fb9c2c76a5e60b20918aadc2beb82e50c3ebe9f294cd08a0f9ac02646b9600a7dc19064c0f
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: Base64.strict_encode64(a.decoded), content_type: a.mime_type }
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
@@ -1,3 +1,3 @@
1
1
  module Mailtruss
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
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 : Base64.strict_decode64(secret.delete_prefix("whsec_"))
163
- expected = Base64.strict_encode64(OpenSSL::HMAC.digest("SHA256", key, "#{id}.#{ts}.#{body}"))
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)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mailtruss
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mailtruss