philiprehberger-webhook_builder 0.3.0 → 0.4.0

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: 7754a65fd17d3f711872d837db0a95670d245eab1da96df4d42c723b8d7f9f3d
4
- data.tar.gz: 8be04c1b22974980e572ca5073279d995f6e8f67d8853742de62297e5951a532
3
+ metadata.gz: 5c3d746e099083b6d9da206ce5b4630ca0a4c5ee2c4f1f99373af3c992d89c38
4
+ data.tar.gz: 23ed5e8d7b8e40f27a71cf7f4cb42c91d501ef8a5028d39d0a77cd1d08a589be
5
5
  SHA512:
6
- metadata.gz: 5f756201c37028a4f44d5975200d24fb811d87ecbc13467b9a9f3e5c792333c26dc546177871b9bda42d4bef3da1093202aa5f82279622521bf5c443d4fe61f8
7
- data.tar.gz: c09e9a31e51d343140eb0beaa1db83560bd7a35dca976f00332534a888ece0eb8263a9701a6b5bf14720388ad381245b44b089689700fa0298ff9a5b16130742
6
+ metadata.gz: 7e503cd54a9fb91a78879f0ccd541a24b91a447ca30ba89c7d832a4c757d07de2a35e7c0066c8c0e13c01b130f6765afdc96b4b8e234c4ba60d492aba2d3e536
7
+ data.tar.gz: 6f9942dc1678940173ab109c17b236f83bf14087ed1dae8880f17a2703e8e89a87c2455e752ea7c9b6aff14f6992bd408db65bd46b0499729ec8644d27e7d561
data/CHANGELOG.md CHANGED
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.4.0] - 2026-04-22
11
+
12
+ ### Added
13
+ - `Client#signature_for(body:)` — compute the HMAC-SHA256 signature this client would send for a given body without performing a delivery.
14
+
10
15
  ## [0.3.0] - 2026-04-18
11
16
 
12
17
  ### Added
data/README.md CHANGED
@@ -134,6 +134,24 @@ receiver.verify_signature(body: body, signature: signature) # => true
134
134
  receiver.verify_signature(body: body, signature: "tampered") # => false
135
135
  ```
136
136
 
137
+ You can also compute the signature the client would send for a body without
138
+ performing a delivery — useful for preparing payloads offline or mirroring
139
+ `verify_signature`:
140
+
141
+ ```ruby
142
+ require "philiprehberger/webhook_builder"
143
+
144
+ client = Philiprehberger::WebhookBuilder.new(
145
+ url: "https://example.com/webhooks",
146
+ secret: "shared-signing-secret"
147
+ )
148
+
149
+ body = '{"event":"order.created","payload":{"id":1}}'
150
+ signature = client.signature_for(body: body)
151
+
152
+ client.verify_signature(body: body, signature: signature) # => true
153
+ ```
154
+
137
155
  ### Delivery Tracking
138
156
 
139
157
  ```ruby
@@ -164,6 +182,7 @@ delivery.error # => nil or error message
164
182
  | `#deliver(event:, payload:, headers:)` | Deliver a webhook event and return a Delivery |
165
183
  | `#deliver_batch(events)` | Deliver multiple events concurrently and return an array of Delivery results |
166
184
  | `#verify_signature(body:, signature:)` | Constant-time HMAC-SHA256 verification of an incoming signature; returns `true`/`false` and never raises |
185
+ | `#signature_for(body:)` | Compute the HMAC-SHA256 signature for a body without sending |
167
186
 
168
187
  ### `Delivery`
169
188
 
@@ -153,6 +153,18 @@ module Philiprehberger
153
153
  OpenSSL.fixed_length_secure_compare(expected, signature)
154
154
  end
155
155
 
156
+ # Compute the HMAC-SHA256 hex signature this client would send for the given body.
157
+ #
158
+ # Mirrors +verify_signature+: the signature returned by +signature_for(body:)+
159
+ # will verify against the same body. Useful when preparing payloads offline or
160
+ # re-computing signatures without sending a request.
161
+ #
162
+ # @param body [String] the raw request body
163
+ # @return [String] the hex-encoded HMAC signature
164
+ def signature_for(body:)
165
+ sign(body)
166
+ end
167
+
156
168
  private
157
169
 
158
170
  # Sign the request body with HMAC-SHA256.
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Philiprehberger
4
4
  module WebhookBuilder
5
- VERSION = '0.3.0'
5
+ VERSION = '0.4.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: philiprehberger-webhook_builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Philip Rehberger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-04-19 00:00:00.000000000 Z
11
+ date: 2026-04-22 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A webhook delivery client that signs payloads with HMAC-SHA256, retries
14
14
  failed deliveries with configurable backoff strategies, supports batch delivery,