mailtrap 2.11.0 → 2.11.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/CHANGELOG.md +13 -0
- data/Gemfile.lock +1 -1
- data/README.md +5 -5
- data/lib/mailtrap/version.rb +1 -1
- data/lib/mailtrap/webhooks.rb +49 -0
- data/lib/mailtrap.rb +1 -0
- metadata +4 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b6606da8d73e2112b813b87000d3aaa63c5490cf2d046dedf59eb5a4f56fc619
|
|
4
|
+
data.tar.gz: a7647dad5291d79758edd52e2b01c57e3e475d998a271ddcd5f6daf24455f59c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e8bca46ba63dfa33175e89b2fcdaba9cce1701d904b6eee25a4808e57524b17dd7f97f483e6289c889fdb6006d35ced29c857beacdc1d2431f8c43a26d878161
|
|
7
|
+
data.tar.gz: 7dbeaaf7198cc263e2ab8264113b0992836a2141745d96edd031f9ff33934649ab4b1cf5bf9a882016a63e243c77d129be61f8f9ab3957b8091019fdb90e2593
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
## [2.11.1] - 2026-07-02
|
|
2
|
+
|
|
3
|
+
## What's Changed
|
|
4
|
+
* Release v2.11.0 by @IgorDobryn in https://github.com/mailtrap/mailtrap-ruby/pull/109
|
|
5
|
+
* MT-22022: Add webhook signature verification helper by @Rabsztok in https://github.com/mailtrap/mailtrap-ruby/pull/110
|
|
6
|
+
* Add draft-release workflow placeholder by @IgorDobryn in https://github.com/mailtrap/mailtrap-ruby/pull/111
|
|
7
|
+
* Implement draft-release workflow by @IgorDobryn in https://github.com/mailtrap/mailtrap-ruby/pull/112
|
|
8
|
+
|
|
9
|
+
## New Contributors
|
|
10
|
+
* @Rabsztok made their first contribution in https://github.com/mailtrap/mailtrap-ruby/pull/110
|
|
11
|
+
|
|
12
|
+
**Full Changelog**: https://github.com/mailtrap/mailtrap-ruby/compare/v2.11.0...v2.11.1
|
|
13
|
+
|
|
1
14
|
## [2.11.0] - 2026-05-14
|
|
2
15
|
## What's Changed
|
|
3
16
|
* Update sandboxes api by @IgorDobryn in https://github.com/mailtrap/mailtrap-ruby/pull/103
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
|
|
9
9
|
This client uses API v2, for v1 refer to [this documentation](https://mailtrap.docs.apiary.io/)
|
|
10
10
|
|
|
11
|
-
|
|
12
11
|
## Prerequisites
|
|
13
12
|
|
|
14
13
|
To get the most out of this official Mailtrap.io Ruby SDK:
|
|
@@ -176,7 +175,7 @@ Email API:
|
|
|
176
175
|
|
|
177
176
|
- Full Email Sending – [`full.rb`](examples/full.rb)
|
|
178
177
|
- Batch Sending – [`batch.rb`](examples/batch.rb)
|
|
179
|
-
- Sending Domains API
|
|
178
|
+
- Sending Domains API – [`sending_domains_api.rb`](examples/sending_domains_api.rb)
|
|
180
179
|
- Sending Stats API – [`stats_api.rb`](examples/stats_api.rb)
|
|
181
180
|
- Email Logs API – [`email_logs_api.rb`](examples/email_logs_api.rb)
|
|
182
181
|
- Webhooks API – [`webhooks_api.rb`](examples/webhooks_api.rb)
|
|
@@ -199,6 +198,7 @@ General:
|
|
|
199
198
|
- Billing API – [`billing_api.rb`](examples/billing_api.rb)
|
|
200
199
|
- Templates API – [`email_templates_api.rb`](examples/email_templates_api.rb)
|
|
201
200
|
- Action Mailer – [`action_mailer.rb`](examples/action_mailer.rb)
|
|
201
|
+
- Verifying webhook signatures – [`webhooks_signature_verification.ru`](examples/webhooks_signature_verification.ru)
|
|
202
202
|
|
|
203
203
|
## Migration guide v1 → v2
|
|
204
204
|
|
|
@@ -213,14 +213,14 @@ Bug reports and pull requests are welcome on [GitHub](https://github.com/railswa
|
|
|
213
213
|
## Development
|
|
214
214
|
|
|
215
215
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
|
216
|
-
`rake spec` to run the tests. You can also run `bin/console` for an interactive
|
|
216
|
+
`rake spec` to run the tests. You can also run `bin/console` for an interactive
|
|
217
217
|
prompt that will allow you to experiment.
|
|
218
218
|
|
|
219
219
|
To install this gem onto your local machine, run `bundle exec rake install`.
|
|
220
220
|
|
|
221
221
|
To release a new version, update the version number in `version.rb`, and then
|
|
222
222
|
run `bundle exec rake release`, which will create a git tag for the version,
|
|
223
|
-
push git commits and the created tag, and push the `.gem` file to
|
|
223
|
+
push git commits and the created tag, and push the `.gem` file to
|
|
224
224
|
[rubygems.org](https://rubygems.org).
|
|
225
225
|
|
|
226
226
|
To run the documentation server, first generate the documentation with
|
|
@@ -241,4 +241,4 @@ Everyone interacting in the Mailtrap project's codebases, issue trackers, chat r
|
|
|
241
241
|
|
|
242
242
|
## Compatibility with previous releases
|
|
243
243
|
|
|
244
|
-
Versions of this package up to 2.0.2 were an [unofficial client](https://github.com/vchin/mailtrap-client) developed by [@vchin](https://github.com/vchin). Package version 3 is a completely new package.
|
|
244
|
+
Versions of this package up to 2.0.2 were an [unofficial client](https://github.com/vchin/mailtrap-client) developed by [@vchin](https://github.com/vchin). Package version 3 is a completely new package.
|
data/lib/mailtrap/version.rb
CHANGED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'openssl'
|
|
4
|
+
|
|
5
|
+
module Mailtrap
|
|
6
|
+
# Helpers for working with inbound Mailtrap webhooks.
|
|
7
|
+
#
|
|
8
|
+
# @see https://docs.mailtrap.io/email-api-smtp/advanced/webhooks#verifying-the-signature
|
|
9
|
+
module Webhooks
|
|
10
|
+
# Hex-encoded HMAC-SHA256 signature length.
|
|
11
|
+
SIGNATURE_HEX_LENGTH = 64
|
|
12
|
+
|
|
13
|
+
# Verifies the HMAC-SHA256 signature of a Mailtrap webhook payload.
|
|
14
|
+
#
|
|
15
|
+
# Mailtrap signs every outbound webhook by computing
|
|
16
|
+
# `HMAC-SHA256(signing_secret, raw_request_body)` and sending the lowercase
|
|
17
|
+
# hex digest in the `Mailtrap-Signature` HTTP header. Compute the same
|
|
18
|
+
# digest on your side and compare it in constant time.
|
|
19
|
+
#
|
|
20
|
+
# The comparison is performed with {OpenSSL.fixed_length_secure_compare} to
|
|
21
|
+
# avoid timing side-channels.
|
|
22
|
+
#
|
|
23
|
+
# The method never raises on inputs that could plausibly arrive over the
|
|
24
|
+
# wire (empty strings, wrong-length signatures, non-hex characters, missing
|
|
25
|
+
# secret) — it simply returns `false`. This makes it safe to call directly
|
|
26
|
+
# from a controller without rescuing.
|
|
27
|
+
#
|
|
28
|
+
# @param payload [String] The raw request body, exactly as received.
|
|
29
|
+
# **Do not** parse and re-serialize the JSON — re-encoding may reorder
|
|
30
|
+
# keys or alter whitespace and invalidate the signature.
|
|
31
|
+
# @param signature [String] The value of the `Mailtrap-Signature` HTTP
|
|
32
|
+
# header (lowercase hex string).
|
|
33
|
+
# @param signing_secret [String] The webhook's `signing_secret`, returned
|
|
34
|
+
# by {WebhooksAPI#create} on webhook creation.
|
|
35
|
+
# @return [Boolean] `true` if the signature is valid for the given payload
|
|
36
|
+
# and secret, `false` otherwise.
|
|
37
|
+
def self.verify_signature(payload:, signature:, signing_secret:)
|
|
38
|
+
return false unless [payload, signature, signing_secret].all? { |v| v.is_a?(String) && !v.empty? }
|
|
39
|
+
return false if signature.bytesize != SIGNATURE_HEX_LENGTH
|
|
40
|
+
|
|
41
|
+
expected = OpenSSL::HMAC.hexdigest('SHA256', signing_secret, payload)
|
|
42
|
+
|
|
43
|
+
OpenSSL.fixed_length_secure_compare(expected, signature)
|
|
44
|
+
rescue ArgumentError
|
|
45
|
+
# fixed_length_secure_compare raises ArgumentError on length mismatch
|
|
46
|
+
false
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
data/lib/mailtrap.rb
CHANGED
|
@@ -27,6 +27,7 @@ require_relative 'mailtrap/sandbox_messages_api'
|
|
|
27
27
|
require_relative 'mailtrap/sandbox_attachments_api'
|
|
28
28
|
require_relative 'mailtrap/stats_api'
|
|
29
29
|
require_relative 'mailtrap/webhooks_api'
|
|
30
|
+
require_relative 'mailtrap/webhooks'
|
|
30
31
|
|
|
31
32
|
module Mailtrap
|
|
32
33
|
# @!macro api_errors
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mailtrap
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.11.
|
|
4
|
+
version: 2.11.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Railsware Products Studio LLC
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-07-02 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: base64
|
|
@@ -104,6 +104,7 @@ files:
|
|
|
104
104
|
- lib/mailtrap/suppressions_api.rb
|
|
105
105
|
- lib/mailtrap/version.rb
|
|
106
106
|
- lib/mailtrap/webhook.rb
|
|
107
|
+
- lib/mailtrap/webhooks.rb
|
|
107
108
|
- lib/mailtrap/webhooks_api.rb
|
|
108
109
|
- mailtrap.gemspec
|
|
109
110
|
homepage: https://github.com/mailtrap/mailtrap-ruby
|
|
@@ -129,7 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
129
130
|
- !ruby/object:Gem::Version
|
|
130
131
|
version: '0'
|
|
131
132
|
requirements: []
|
|
132
|
-
rubygems_version: 3.5.
|
|
133
|
+
rubygems_version: 3.5.22
|
|
133
134
|
signing_key:
|
|
134
135
|
specification_version: 4
|
|
135
136
|
summary: Official mailtrap.io API client
|