basecradle 0.17.3 → 0.17.4
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 +40 -2
- data/README.md +23 -6
- data/lib/basecradle/errors.rb +12 -2
- data/lib/basecradle/version.rb +1 -1
- data/lib/basecradle/webhooks.rb +37 -21
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cf1828960f1b610b87acc8263f49d47389f1ebbe56b1194747f8927bd43057b6
|
|
4
|
+
data.tar.gz: 7869cfdb12753c5da849d0341f0d8e4e73fccf14b7b6985964f0d02b0dc708f4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 75e07cb441cf75f5c680de378494780e518faa2954dbc16cb9bcaa3984f0e381ac9fe769e064c371df687b9b83928be6491e56712839d67c81caa01e9381f4fa
|
|
7
|
+
data.tar.gz: 2ffbaf5284abb5067514dd0df3d1ffecf4fa0edc81e703ec417cbfd72beeb2a23ba8950d14f025d11fb7b9376f149164f021b4ef5482a9e24a497582c6d98ac5
|
data/CHANGELOG.md
CHANGED
|
@@ -9,6 +9,40 @@ section**. The newest heading is always the version `lib/basecradle/version.rb`
|
|
|
9
9
|
a release writes its entry and its version in the same PR — and `test/changelog_test.rb`
|
|
10
10
|
fails CI if the two ever disagree.
|
|
11
11
|
|
|
12
|
+
## [0.17.4] - 2026-11-27
|
|
13
|
+
|
|
14
|
+
A patch release that corrects what the SDK says about a platform change of 2026-11-27
|
|
15
|
+
([#336](https://github.com/basecradle/basecradle-ruby/issues/336)), and gives the error code
|
|
16
|
+
it added a class. No verb is added or removed, and no signature changes.
|
|
17
|
+
|
|
18
|
+
### Fixed
|
|
19
|
+
|
|
20
|
+
- **An endpoint's `verifier` has seven schemes, not five.** The platform now verifies
|
|
21
|
+
`stripe` and `sns`. `configure_verification` already passed the verifier through as a
|
|
22
|
+
string, so both work with this SDK as it is; only the docs listed five. The README,
|
|
23
|
+
`WebhookVerification` and `configure_verification` now list all seven.
|
|
24
|
+
- **`stripe`**, for a Stripe webhook destination. The secret is the destination's
|
|
25
|
+
Signing secret at Stripe (`whsec_…`). It reads Stripe's own `Stripe-Signature`, fixed,
|
|
26
|
+
so `signature_header` is ignored, as under `github`, `slack` and `twilio`. A delivery
|
|
27
|
+
whose signed timestamp is more than five minutes from now is refused, and a repeat of
|
|
28
|
+
one Stripe event (the same event `id`) is stored once.
|
|
29
|
+
- **`sns`**, for an Amazon SNS topic. The credential is **the ARN of the topic** the
|
|
30
|
+
endpoint listens to: not a secret, and still write-only. SNS signs inside the message,
|
|
31
|
+
so **`verification.signature_header` is an empty string** for an `sns` endpoint; the
|
|
32
|
+
SDK reads it as sent (a test now pins it), and nothing in the SDK assumed it was
|
|
33
|
+
non-empty. Pass `credential:` in the same call that moves an endpoint to or from `sns`:
|
|
34
|
+
an ARN is never carried over to a secret scheme, nor a secret to `sns`, so a call that
|
|
35
|
+
passes only `verifier:` raises `BaseCradle::ValidationError`. The endpoint confirms
|
|
36
|
+
the SNS subscription by itself, and the confirmation creates no event, so set the ARN
|
|
37
|
+
before you subscribe the topic. Raw message delivery must be off, and a repeat of one
|
|
38
|
+
SNS message (the same `MessageId`) is stored once.
|
|
39
|
+
- **`service_unavailable` maps to `BaseCradle::ServiceUnavailableError`.** The API
|
|
40
|
+
documents this code (`503`): a webhook delivery could not be verified right now, because
|
|
41
|
+
the sender's own certificate (Amazon SNS's) could not be fetched or its handshake could
|
|
42
|
+
not be completed, so nothing was stored and the sender sends it again. It is an answer to
|
|
43
|
+
a *sender*; no call this SDK makes receives it today. Until now the registry did not
|
|
44
|
+
list it, so it would have read as a bare `BaseCradle::Error`.
|
|
45
|
+
|
|
12
46
|
## [0.17.3] - 2026-11-26
|
|
13
47
|
|
|
14
48
|
A patch release that corrects what the SDK says about a platform change of 2026-11-26
|
|
@@ -34,6 +68,7 @@ no verb is added or removed, and no signature changes.
|
|
|
34
68
|
`configure_verification` already passed the verifier through as a string, so `twilio`
|
|
35
69
|
works with this SDK as it is; only the docs listed four. The README,
|
|
36
70
|
`WebhookVerification` and `configure_verification` now list all five.
|
|
71
|
+
*Corrected in 0.17.4: since 2026-11-27 it has seven, adding `stripe` and `sns`.*
|
|
37
72
|
|
|
38
73
|
## [0.17.2] - 2026-11-26
|
|
39
74
|
|
|
@@ -65,7 +100,8 @@ no verb is added or removed, and no signature changes.
|
|
|
65
100
|
`slack`. It is required in the same call that moves an endpoint to
|
|
66
101
|
`shared_secret_header`, or from it back to `hmac_sha256_hex`; a call that passes only
|
|
67
102
|
`verifier:` there raises `BaseCradle::ValidationError`.
|
|
68
|
-
*Corrected in 0.17.3: since 2026-11-26 it has five, adding `twilio
|
|
103
|
+
*Corrected in 0.17.3: since 2026-11-26 it has five, adding `twilio`; and in 0.17.4: since
|
|
104
|
+
2026-11-27 seven, adding `stripe` and `sns`.*
|
|
69
105
|
|
|
70
106
|
## [0.17.1] - 2026-11-21
|
|
71
107
|
|
|
@@ -178,7 +214,8 @@ you upgrade your own Ruby, to 3.3.14, 3.4.13 or 4.0.10.
|
|
|
178
214
|
*Corrected in 0.17.2: since 2026-11-25 the platform has four schemes, adding
|
|
179
215
|
`shared_secret_header` and `slack`, and `signature_header:` also names the header a
|
|
180
216
|
`shared_secret_header` endpoint reads the secret from. Corrected again in 0.17.3:
|
|
181
|
-
since 2026-11-26 it has five, adding `twilio
|
|
217
|
+
since 2026-11-26 it has five, adding `twilio`. Corrected again in 0.17.4: since
|
|
218
|
+
2026-11-27 it has seven, adding `stripe` and `sns`.*
|
|
182
219
|
- **`clear_verification`** sends `clear_credential: true`, which removes the secret and
|
|
183
220
|
turns verification off.
|
|
184
221
|
- Both update the endpoint in place and return it, like `rotate`, so the new state
|
|
@@ -1105,6 +1142,7 @@ the Python SDK's behavior in idiomatic Ruby. Zero runtime dependencies.
|
|
|
1105
1142
|
- **Quality bars** — a README-as-tested-doc harness (every example runs against a mocked
|
|
1106
1143
|
API) and a spec drift-guard (CI fails if the live API grows beyond the SDK).
|
|
1107
1144
|
|
|
1145
|
+
[0.17.4]: https://github.com/basecradle/basecradle-ruby/releases/tag/v0.17.4
|
|
1108
1146
|
[0.17.3]: https://github.com/basecradle/basecradle-ruby/releases/tag/v0.17.3
|
|
1109
1147
|
[0.17.2]: https://github.com/basecradle/basecradle-ruby/releases/tag/v0.17.2
|
|
1110
1148
|
[0.17.1]: https://github.com/basecradle/basecradle-ruby/releases/tag/v0.17.1
|
data/README.md
CHANGED
|
@@ -226,7 +226,7 @@ and the SDK invents none. `BaseCradle.uuid_of(endpoint)` reads it too, and is wh
|
|
|
226
226
|
**Signature verification is configured with two verbs.**
|
|
227
227
|
`endpoint.configure_verification(verifier:, credential:, signature_header:)` sends only
|
|
228
228
|
the keywords you pass, so anything left out stays as it is; passing none raises
|
|
229
|
-
`ArgumentError` before any request. `verifier:` is the scheme, one of
|
|
229
|
+
`ArgumentError` before any request. `verifier:` is the scheme, one of seven today:
|
|
230
230
|
|
|
231
231
|
| `verifier:` | For | The header it reads |
|
|
232
232
|
|---|---|---|
|
|
@@ -234,7 +234,13 @@ the keywords you pass, so anything left out stays as it is; passing none raises
|
|
|
234
234
|
| `"github"` | a GitHub webhook, pointed straight at the `ingest_url` | `X-Hub-Signature-256`, fixed |
|
|
235
235
|
| `"shared_secret_header"` | a sender that cannot sign | the `signature_header:` you set; carries the secret itself |
|
|
236
236
|
| `"slack"` | a Slack app's Events API | `X-Slack-Signature`, fixed; the endpoint answers Slack's `url_verification` handshake itself, and the handshake creates no event |
|
|
237
|
+
| `"stripe"` | a Stripe webhook destination | `Stripe-Signature`, fixed; it carries the signed timestamp and the digest |
|
|
237
238
|
| `"twilio"` | the webhooks Twilio sends (an incoming text message, a recording or transcription callback, a status callback) | `X-Twilio-Signature`, fixed; Twilio signs the URL it was given, so give it the `ingest_url` exactly as the endpoint reports it |
|
|
239
|
+
| `"sns"` | an Amazon SNS topic's HTTPS subscription | none: SNS signs inside the message, so `verification.signature_header` is an empty string |
|
|
240
|
+
|
|
241
|
+
Under `stripe` the secret is the destination's Signing secret at Stripe (`whsec_…`), which
|
|
242
|
+
is not an API key. A delivery whose signed timestamp is more than five minutes from now is
|
|
243
|
+
refused, and a repeat of one Stripe event (the same event `id`) is stored once.
|
|
238
244
|
|
|
239
245
|
Under `twilio` the secret is a shared key made at Twilio for signing webhooks (Twilio's own
|
|
240
246
|
recommendation) or the account's Auth Token. Twilio reads the reply to a delivery, so a
|
|
@@ -247,22 +253,33 @@ other is refused with `401`, and Twilio does not resend it by default, so when y
|
|
|
247
253
|
between a shared key and the Auth Token, or replace a shared key, change the secret here in
|
|
248
254
|
the same minute you change it at Twilio.
|
|
249
255
|
|
|
256
|
+
Under `sns` the credential is **the ARN of the topic** the endpoint listens to. It is not a
|
|
257
|
+
secret, and it is still write-only: the API never returns it. **Pass `credential:` in the
|
|
258
|
+
same call that moves an endpoint to or from `sns`**: a topic's ARN is never carried over to
|
|
259
|
+
a secret scheme, nor a secret to `sns`, so a call that passes only `verifier:` there raises
|
|
260
|
+
`BaseCradle::ValidationError`.
|
|
261
|
+
The endpoint confirms the SNS subscription by itself, and the confirmation creates no event,
|
|
262
|
+
so set the ARN before you subscribe the topic: with no ARN set, the confirmation is stored as
|
|
263
|
+
an event and its `SubscribeURL` is yours to open. Topics in the standard and GovCloud regions
|
|
264
|
+
are supported, the China regions are not. Raw message delivery must be off, and a repeat of
|
|
265
|
+
one SNS message (the same `MessageId`) is stored once.
|
|
266
|
+
|
|
250
267
|
The verifier is passed through as given, so a scheme the platform adds later needs no SDK
|
|
251
268
|
release; one it does not know raises `BaseCradle::ValidationError`. Use a signing scheme
|
|
252
269
|
whenever the sender can sign: `shared_secret_header` proves only that the sender holds the
|
|
253
270
|
secret, not that the body arrived unaltered. `credential:` is the signing secret (under
|
|
254
271
|
`shared_secret_header`, the header's exact value, compared as sent, so include any prefix
|
|
255
|
-
such as `Bearer `), and setting it turns verification on; a blank one is no change at all (the API's rule): the current secret
|
|
272
|
+
such as `Bearer `; under `sns`, the topic's ARN), and setting it turns verification on; a blank one is no change at all (the API's rule): the current secret
|
|
256
273
|
stays, and `verification.enabled` cannot tell you a rotation was skipped, so make sure a
|
|
257
274
|
secret read from the environment is not empty before passing it. It is **write-only**: the
|
|
258
275
|
API never returns it, and the SDK keeps no copy and never puts it in an `inspect` or an
|
|
259
276
|
error message. `signature_header:` names the header that is read: the signature's under
|
|
260
|
-
`hmac_sha256_hex`, the secret's under `shared_secret_header`; a `github`, `slack`
|
|
261
|
-
`twilio` endpoint ignores it. **Pass it in the same call that moves an endpoint to
|
|
277
|
+
`hmac_sha256_hex`, the secret's under `shared_secret_header`; a `github`, `slack`, `sns`,
|
|
278
|
+
`stripe` or `twilio` endpoint ignores it. **Pass it in the same call that moves an endpoint to
|
|
262
279
|
`shared_secret_header`, or from it back to `hmac_sha256_hex`** — a header named for one
|
|
263
280
|
scheme is never carried over to the other, so a call that passes only `verifier:` raises
|
|
264
|
-
`BaseCradle::ValidationError`. A move from `shared_secret_header` to `github`, `slack
|
|
265
|
-
`twilio` that names no header resets it to `X-Signature`. `endpoint.clear_verification` removes the secret and turns verification
|
|
281
|
+
`BaseCradle::ValidationError`. A move from `shared_secret_header` to `github`, `slack`,
|
|
282
|
+
`sns`, `stripe` or `twilio` that names no header resets it to `X-Signature`. `endpoint.clear_verification` removes the secret and turns verification
|
|
266
283
|
off. Both return the endpoint, updated in place; read the result at
|
|
267
284
|
`endpoint.content.verification`. How senders sign is in the API docs:
|
|
268
285
|
[Verifying Inbound Deliveries](https://basecradle.com/docs/api#verifying-inbound-deliveries-optional).
|
data/lib/basecradle/errors.rb
CHANGED
|
@@ -56,7 +56,10 @@ module BaseCradle
|
|
|
56
56
|
# +invalid_credentials+ — sign-in failed: the email address or password is wrong.
|
|
57
57
|
class InvalidCredentialsError < AuthenticationError; end
|
|
58
58
|
|
|
59
|
-
# +invalid_signature+ — webhook ingest: the
|
|
59
|
+
# +invalid_signature+ — webhook ingest: the delivery did not prove it holds the
|
|
60
|
+
# endpoint's secret. Its signature (or, under "shared_secret_header", its secret header)
|
|
61
|
+
# is missing or does not match, or a signed timestamp is more than five minutes from now,
|
|
62
|
+
# or, under "sns", the message is not from the endpoint's topic.
|
|
60
63
|
class InvalidSignatureError < AuthenticationError; end
|
|
61
64
|
|
|
62
65
|
# --- 403: account / permissions --------------------------------------------------------
|
|
@@ -153,6 +156,12 @@ module BaseCradle
|
|
|
153
156
|
# +binary_payload+ — webhook ingest: the request body is not UTF-8 text (HTTP 415).
|
|
154
157
|
class BinaryPayloadError < Error; end
|
|
155
158
|
|
|
159
|
+
# +service_unavailable+ — webhook ingest: the delivery could not be verified right now,
|
|
160
|
+
# because the sender's own certificate could not be fetched (Amazon SNS's) or its
|
|
161
|
+
# handshake could not be completed (HTTP 503). Nothing was stored; the sender sends it
|
|
162
|
+
# again. It is an answer to a *sender*: no call this SDK makes receives it today.
|
|
163
|
+
class ServiceUnavailableError < Error; end
|
|
164
|
+
|
|
156
165
|
# --- the code => class registry ----------------------------------------------------------
|
|
157
166
|
|
|
158
167
|
# Every API error is an RFC 9457 application/problem+json document with a stable,
|
|
@@ -177,7 +186,8 @@ module BaseCradle
|
|
|
177
186
|
"invalid_filter" => InvalidFilterError,
|
|
178
187
|
"endpoint_disabled" => EndpointDisabledError,
|
|
179
188
|
"payload_too_large" => PayloadTooLargeError,
|
|
180
|
-
"binary_payload" => BinaryPayloadError
|
|
189
|
+
"binary_payload" => BinaryPayloadError,
|
|
190
|
+
"service_unavailable" => ServiceUnavailableError
|
|
181
191
|
}.freeze
|
|
182
192
|
|
|
183
193
|
class Error
|
data/lib/basecradle/version.rb
CHANGED
data/lib/basecradle/webhooks.rb
CHANGED
|
@@ -19,11 +19,13 @@ module BaseCradle
|
|
|
19
19
|
attribute :enabled
|
|
20
20
|
# The header deliveries are checked against: the signature's under "hmac_sha256_hex",
|
|
21
21
|
# the secret's under "shared_secret_header". A "github" endpoint reports its fixed
|
|
22
|
-
# X-Hub-Signature-256 here; a "slack" endpoint always reads X-Slack-Signature,
|
|
23
|
-
# "twilio" endpoint X-Twilio-Signature.
|
|
22
|
+
# X-Hub-Signature-256 here; a "slack" endpoint always reads X-Slack-Signature, a
|
|
23
|
+
# "stripe" endpoint Stripe-Signature, and a "twilio" endpoint X-Twilio-Signature. An
|
|
24
|
+
# "sns" endpoint reports an empty string: SNS signs inside the message, so no header
|
|
25
|
+
# is read.
|
|
24
26
|
attribute :signature_header
|
|
25
|
-
# "hmac_sha256_hex", "github", "shared_secret_header", "slack"
|
|
26
|
-
# open set; read it as a string.
|
|
27
|
+
# "hmac_sha256_hex", "github", "shared_secret_header", "slack", "stripe", "twilio" or
|
|
28
|
+
# "sns" today — an open set; read it as a string.
|
|
27
29
|
attribute :verifier
|
|
28
30
|
end
|
|
29
31
|
|
|
@@ -77,23 +79,36 @@ module BaseCradle
|
|
|
77
79
|
# stays as it is; pass at least one, or this raises ArgumentError before any request
|
|
78
80
|
# is made.
|
|
79
81
|
#
|
|
80
|
-
# - +verifier+ is the scheme, one of
|
|
82
|
+
# - +verifier+ is the scheme, one of seven today: "hmac_sha256_hex" (the default; any
|
|
81
83
|
# sender you control signs the body), "github" (a GitHub webhook),
|
|
82
84
|
# "shared_secret_header" (a sender that cannot sign sends the secret itself in a
|
|
83
85
|
# header), "slack" (a Slack app's Events API; the endpoint answers Slack's
|
|
84
|
-
# url_verification handshake itself, and the handshake creates no event)
|
|
85
|
-
# (
|
|
86
|
-
#
|
|
87
|
-
#
|
|
88
|
-
#
|
|
89
|
-
#
|
|
90
|
-
# endpoint
|
|
91
|
-
#
|
|
92
|
-
#
|
|
93
|
-
#
|
|
86
|
+
# url_verification handshake itself, and the handshake creates no event), "stripe"
|
|
87
|
+
# (a Stripe webhook destination; a delivery whose signed timestamp is more than five
|
|
88
|
+
# minutes from now is refused, and a repeat of one Stripe event, the same event id,
|
|
89
|
+
# is stored once), "twilio" (the webhooks Twilio sends: an incoming text message, a
|
|
90
|
+
# recording or transcription callback, a status callback) or "sns" (an Amazon SNS
|
|
91
|
+
# topic's HTTPS subscription, in a standard or GovCloud region, not China; the
|
|
92
|
+
# endpoint confirms the subscription itself, and the confirmation creates no event,
|
|
93
|
+
# so set the topic's ARN before subscribing it, since with no ARN set the
|
|
94
|
+
# confirmation is stored as an event whose SubscribeURL is yours to open; raw message
|
|
95
|
+
# delivery must be off; a repeat of one SNS message, the same MessageId, is stored
|
|
96
|
+
# once). It is passed through as given, so a scheme the platform adds later
|
|
97
|
+
# works here unchanged; one it does not know raises ValidationError. Twilio signs the
|
|
98
|
+
# URL it was given, so give it +content.ingest_url+ exactly as the endpoint reports
|
|
99
|
+
# it. Twilio also reads the reply, so a "twilio" endpoint answers each delivery it
|
|
100
|
+
# stores with 200 OK and an empty TwiML document in place of the empty 201: the
|
|
101
|
+
# answer to the sender, which changes nothing this method returns. That empty answer
|
|
102
|
+
# ends a voice call, so the ingest_url is never a number's voice URL; point a
|
|
103
|
+
# recording's callbacks at it instead.
|
|
94
104
|
# - +credential+ is the signing secret, sent as +verification_credential+: setting it
|
|
95
105
|
# turns verification on. Under "shared_secret_header" nothing is signed: it is the
|
|
96
106
|
# header's exact value, compared as sent, so include any prefix the sender adds.
|
|
107
|
+
# Under "stripe" it is the destination's Signing secret at Stripe (whsec_...), not an
|
|
108
|
+
# API key. Under "sns" it is the ARN of the topic the endpoint listens to: not a
|
|
109
|
+
# secret, and still write-only. Pass it in the same call that moves an endpoint to
|
|
110
|
+
# or from "sns": a topic's ARN is never carried over to a secret scheme, nor a secret
|
|
111
|
+
# to "sns", so passing only +verifier+ there raises ValidationError.
|
|
97
112
|
# Under "twilio" it is a shared key made at Twilio for signing webhooks (Twilio's own
|
|
98
113
|
# recommendation) or the account's Auth Token. An endpoint holds one secret, a
|
|
99
114
|
# delivery signed with the other is refused with 401, and Twilio does not resend it
|
|
@@ -108,12 +123,13 @@ module BaseCradle
|
|
|
108
123
|
# the API never returns it, and this SDK keeps no copy and never puts it in an
|
|
109
124
|
# inspect or an error message.
|
|
110
125
|
# - +signature_header+ is the header that is read: the signature's under
|
|
111
|
-
# "hmac_sha256_hex", the secret's under "shared_secret_header". A "github", "slack"
|
|
112
|
-
# or "twilio" endpoint ignores it. Pass it in the same call that
|
|
113
|
-
# to "shared_secret_header", or from it back to "hmac_sha256_hex":
|
|
114
|
-
# for one is never carried over to the other, so passing only
|
|
115
|
-
# raises ValidationError. A move from "shared_secret_header" to
|
|
116
|
-
# "twilio" that names no header resets it to
|
|
126
|
+
# "hmac_sha256_hex", the secret's under "shared_secret_header". A "github", "slack",
|
|
127
|
+
# "sns", "stripe" or "twilio" endpoint ignores it. Pass it in the same call that
|
|
128
|
+
# moves an endpoint to "shared_secret_header", or from it back to "hmac_sha256_hex":
|
|
129
|
+
# a header named for one is never carried over to the other, so passing only
|
|
130
|
+
# +verifier+ there raises ValidationError. A move from "shared_secret_header" to
|
|
131
|
+
# "github", "slack", "sns", "stripe" or "twilio" that names no header resets it to
|
|
132
|
+
# X-Signature.
|
|
117
133
|
#
|
|
118
134
|
# Any viewer of the endpoint's timeline may configure it, locked timeline or not.
|
|
119
135
|
# Returns this endpoint, which adopts the one the API returns, so
|