svix 2.6.2 → 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/api/destination.rb +13 -0
- data/lib/svix/api/endpoint.rb +2 -1
- data/lib/svix/api/streaming_sink.rb +1 -1
- data/lib/svix/models/destination_secret_rotate_out.rb +53 -0
- data/lib/svix/models/sink_secret_rotate_out.rb +50 -0
- data/lib/svix/version.rb +1 -1
- data/lib/svix/webhook.rb +15 -6
- data/lib/svix.rb +2 -0
- metadata +4 -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/api/destination.rb
CHANGED
|
@@ -71,5 +71,18 @@ module Svix
|
|
|
71
71
|
DestinationOut.deserialize(res)
|
|
72
72
|
end
|
|
73
73
|
|
|
74
|
+
def rotate_secret(app_id, destination_id, endpoint_secret_rotate_in, options = {})
|
|
75
|
+
options = options.transform_keys(&:to_s)
|
|
76
|
+
res = @client.execute_request(
|
|
77
|
+
"POST",
|
|
78
|
+
"/api/v1/app/#{app_id}/destination/#{destination_id}/secret/rotate",
|
|
79
|
+
headers: {
|
|
80
|
+
"idempotency-key" => options["idempotency-key"]
|
|
81
|
+
},
|
|
82
|
+
body: endpoint_secret_rotate_in
|
|
83
|
+
)
|
|
84
|
+
DestinationSecretRotateOut.deserialize(res)
|
|
85
|
+
end
|
|
86
|
+
|
|
74
87
|
end
|
|
75
88
|
end
|
data/lib/svix/api/endpoint.rb
CHANGED
|
@@ -81,7 +81,7 @@ module Svix
|
|
|
81
81
|
|
|
82
82
|
def rotate_secret(app_id, endpoint_id, endpoint_secret_rotate_in, options = {})
|
|
83
83
|
options = options.transform_keys(&:to_s)
|
|
84
|
-
@client.execute_request(
|
|
84
|
+
res = @client.execute_request(
|
|
85
85
|
"POST",
|
|
86
86
|
"/api/v1/app/#{app_id}/endpoint/#{endpoint_id}/secret/rotate",
|
|
87
87
|
headers: {
|
|
@@ -89,6 +89,7 @@ module Svix
|
|
|
89
89
|
},
|
|
90
90
|
body: endpoint_secret_rotate_in
|
|
91
91
|
)
|
|
92
|
+
EndpointSecretOut.deserialize(res)
|
|
92
93
|
end
|
|
93
94
|
|
|
94
95
|
def get_headers(app_id, endpoint_id)
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
# This file is @generated
|
|
3
|
+
require "json"
|
|
4
|
+
|
|
5
|
+
module Svix
|
|
6
|
+
class DestinationSecretRotateOut
|
|
7
|
+
# The endpoint's verification secret.
|
|
8
|
+
#
|
|
9
|
+
# Format: `base64` encoded random bytes optionally prefixed with `whsec_`.
|
|
10
|
+
# It is recommended to not set this and let the server generate the secret.
|
|
11
|
+
attr_accessor :key
|
|
12
|
+
|
|
13
|
+
ALL_FIELD ||= ["key"].freeze
|
|
14
|
+
private_constant :ALL_FIELD
|
|
15
|
+
|
|
16
|
+
def initialize(attributes = {})
|
|
17
|
+
unless attributes.is_a?(Hash)
|
|
18
|
+
fail(
|
|
19
|
+
ArgumentError,
|
|
20
|
+
"The input argument (attributes) must be a hash in `Svix::DestinationSecretRotateOut` new method"
|
|
21
|
+
)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
attributes.each do |k, v|
|
|
25
|
+
unless ALL_FIELD.include?(k.to_s)
|
|
26
|
+
fail(ArgumentError, "The field #{k} is not part of Svix::DestinationSecretRotateOut")
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
instance_variable_set("@#{k}", v)
|
|
30
|
+
instance_variable_set("@__#{k}_is_defined", true)
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def self.deserialize(attributes = {})
|
|
35
|
+
attributes = attributes.transform_keys(&:to_s)
|
|
36
|
+
attrs = Hash.new
|
|
37
|
+
attrs["key"] = attributes["key"]
|
|
38
|
+
new(attrs)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def serialize
|
|
42
|
+
out = Hash.new
|
|
43
|
+
out["key"] = Svix::serialize_primitive(@key) unless @key.nil?
|
|
44
|
+
out
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Serializes the object to a json string
|
|
48
|
+
# @return String
|
|
49
|
+
def to_json(*args)
|
|
50
|
+
serialize.to_json(*args)
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
# This file is @generated
|
|
3
|
+
require "json"
|
|
4
|
+
|
|
5
|
+
module Svix
|
|
6
|
+
class SinkSecretRotateOut
|
|
7
|
+
# The endpoint's verification secret.
|
|
8
|
+
#
|
|
9
|
+
# Format: `base64` encoded random bytes optionally prefixed with `whsec_`.
|
|
10
|
+
# It is recommended to not set this and let the server generate the secret.
|
|
11
|
+
attr_accessor :key
|
|
12
|
+
|
|
13
|
+
ALL_FIELD ||= ["key"].freeze
|
|
14
|
+
private_constant :ALL_FIELD
|
|
15
|
+
|
|
16
|
+
def initialize(attributes = {})
|
|
17
|
+
unless attributes.is_a?(Hash)
|
|
18
|
+
fail(ArgumentError, "The input argument (attributes) must be a hash in `Svix::SinkSecretRotateOut` new method")
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
attributes.each do |k, v|
|
|
22
|
+
unless ALL_FIELD.include?(k.to_s)
|
|
23
|
+
fail(ArgumentError, "The field #{k} is not part of Svix::SinkSecretRotateOut")
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
instance_variable_set("@#{k}", v)
|
|
27
|
+
instance_variable_set("@__#{k}_is_defined", true)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def self.deserialize(attributes = {})
|
|
32
|
+
attributes = attributes.transform_keys(&:to_s)
|
|
33
|
+
attrs = Hash.new
|
|
34
|
+
attrs["key"] = attributes["key"]
|
|
35
|
+
new(attrs)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def serialize
|
|
39
|
+
out = Hash.new
|
|
40
|
+
out["key"] = Svix::serialize_primitive(@key) unless @key.nil?
|
|
41
|
+
out
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# Serializes the object to a json string
|
|
45
|
+
# @return String
|
|
46
|
+
def to_json(*args)
|
|
47
|
+
serialize.to_json(*args)
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
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
|
data/lib/svix.rb
CHANGED
|
@@ -87,6 +87,7 @@ require "svix/models/cron_config"
|
|
|
87
87
|
require "svix/models/destination_in"
|
|
88
88
|
require "svix/models/destination_out"
|
|
89
89
|
require "svix/models/destination_patch"
|
|
90
|
+
require "svix/models/destination_secret_rotate_out"
|
|
90
91
|
require "svix/models/destination_status"
|
|
91
92
|
require "svix/models/destination_status_in"
|
|
92
93
|
require "svix/models/destination_transform_in"
|
|
@@ -241,6 +242,7 @@ require "svix/models/sink_http_config_in"
|
|
|
241
242
|
require "svix/models/sink_http_config_out"
|
|
242
243
|
require "svix/models/sink_http_config_patch"
|
|
243
244
|
require "svix/models/sink_secret_out"
|
|
245
|
+
require "svix/models/sink_secret_rotate_out"
|
|
244
246
|
require "svix/models/sink_status"
|
|
245
247
|
require "svix/models/sink_status_in"
|
|
246
248
|
require "svix/models/sink_transform_in"
|
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
|
|
@@ -198,6 +198,7 @@ files:
|
|
|
198
198
|
- lib/svix/models/destination_in.rb
|
|
199
199
|
- lib/svix/models/destination_out.rb
|
|
200
200
|
- lib/svix/models/destination_patch.rb
|
|
201
|
+
- lib/svix/models/destination_secret_rotate_out.rb
|
|
201
202
|
- lib/svix/models/destination_status.rb
|
|
202
203
|
- lib/svix/models/destination_status_in.rb
|
|
203
204
|
- lib/svix/models/destination_transform_in.rb
|
|
@@ -356,6 +357,7 @@ files:
|
|
|
356
357
|
- lib/svix/models/sink_http_config_patch.rb
|
|
357
358
|
- lib/svix/models/sink_in_common.rb
|
|
358
359
|
- lib/svix/models/sink_secret_out.rb
|
|
360
|
+
- lib/svix/models/sink_secret_rotate_out.rb
|
|
359
361
|
- lib/svix/models/sink_status.rb
|
|
360
362
|
- lib/svix/models/sink_status_in.rb
|
|
361
363
|
- lib/svix/models/sink_transform_in.rb
|