svix 2.7.0 → 2.8.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: 473ce371b4fad4bd881f5c78f9a097aa966621224cf75799a75865e82d3b1034
4
- data.tar.gz: 4fdd92b272002cb0fa770939f7310364024f38281242eff151bee692383fe6a1
3
+ metadata.gz: 60771bc17c0373445147a1d0e99f14e54832360034886934a75041b1534db278
4
+ data.tar.gz: b50ca6ac15036c6a156363f2a38b41cbcc65a4dcf941f54ba9757e806db2122d
5
5
  SHA512:
6
- metadata.gz: c27e2a4e758ec3ff6cf6f182a27cffb362e948d6a8c656ce4955164484ca7473c66b2c95b3f9e3f228d40c797216a73165741073af11f62fa885703ee1782171
7
- data.tar.gz: a6722c45076c6e42c956507baf4e9d6c91c0fbe923249fe8efd3295165b7300b92f01ef87c3713b4803e6a22f584599342395a7c644ba6b12a28e732ccadc7a4
6
+ metadata.gz: 5c688347d70e2fc86f6343b4955deda84fa372a3d35477bc8f16531a3f37aeb6fc80ddb936d01e2902dd9f279a0b008cb5b8f102c26743ba3542a1716e6291fe
7
+ data.tar.gz: a2854d721ea7a863cb5e161f8f9b56565ef038cd617cd7aa248c499ba0bdeb9d8fda8213bf8bafad8fbb3fe8a63f199d85d7e714c3e4470a7c4984c61e71df28
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- svix (2.7.0)
4
+ svix (2.8.0)
5
5
  base64 (~> 0.3.0)
6
6
  logger (~> 1.0)
7
7
 
data/lib/svix/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Svix
4
- VERSION = "2.7.0"
4
+ VERSION = "2.8.0"
5
5
  end
data/lib/svix/webhook.rb CHANGED
@@ -3,19 +3,28 @@
3
3
  module Svix
4
4
  class Webhook
5
5
 
6
+ # `secret` is the raw key as an array of bytes, used as the HMAC key as-is.
6
7
  def self.new_using_raw_bytes(secret, tolerance: DEFAULT_TOLERANCE)
7
- self.new(secret.pack("C*").force_encoding("UTF-8"), tolerance: tolerance)
8
+ self.new(raw_secret: secret.pack("C*"), tolerance: tolerance)
8
9
  end
9
10
 
11
+ # `secret` is the base64-encoded signing secret, with or without the
12
+ # `whsec_` prefix. Pass `raw_secret:` instead to use a binary string as the
13
+ # key as-is.
14
+ #
10
15
  # `tolerance` is the maximum difference allowed, in seconds, between the
11
16
  # webhook's timestamp and the current time. Defaults to 5 minutes.
12
- def initialize(secret, tolerance: DEFAULT_TOLERANCE)
13
- if secret.start_with?(SECRET_PREFIX)
14
- secret = secret[SECRET_PREFIX.length..-1]
17
+ def initialize(secret = nil, raw_secret: nil, tolerance: DEFAULT_TOLERANCE)
18
+ if !secret.nil? && !raw_secret.nil?
19
+ raise ArgumentError, "pass either secret or raw_secret, not both"
20
+ elsif !secret.nil?
21
+ @secret = Base64.decode64(secret.delete_prefix(SECRET_PREFIX))
22
+ elsif !raw_secret.nil?
23
+ @secret = raw_secret.b
24
+ else
25
+ raise ArgumentError, "must pass secret or raw_secret"
15
26
  end
16
27
 
17
- @secret = Base64.decode64(secret)
18
-
19
28
  if @secret.empty?
20
29
  raise EmptyWebhookSecretError, "Webhook secret must not be blank"
21
30
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: svix
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.0
4
+ version: 2.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Svix
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2026-10-06 00:00:00.000000000 Z
10
+ date: 2026-10-08 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: base64