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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/svix/version.rb +1 -1
- data/lib/svix/webhook.rb +15 -6
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 60771bc17c0373445147a1d0e99f14e54832360034886934a75041b1534db278
|
|
4
|
+
data.tar.gz: b50ca6ac15036c6a156363f2a38b41cbcc65a4dcf941f54ba9757e806db2122d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5c688347d70e2fc86f6343b4955deda84fa372a3d35477bc8f16531a3f37aeb6fc80ddb936d01e2902dd9f279a0b008cb5b8f102c26743ba3542a1716e6291fe
|
|
7
|
+
data.tar.gz: a2854d721ea7a863cb5e161f8f9b56565ef038cd617cd7aa248c499ba0bdeb9d8fda8213bf8bafad8fbb3fe8a63f199d85d7e714c3e4470a7c4984c61e71df28
|
data/Gemfile.lock
CHANGED
data/lib/svix/version.rb
CHANGED
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*")
|
|
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.
|
|
14
|
-
secret
|
|
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.
|
|
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-
|
|
10
|
+
date: 2026-10-08 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: base64
|