basecradle 0.17.3 → 0.17.5

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: 3678e2e214d103af05b907532dd29db2adf6ab1b952194224bbb72421a44f379
4
- data.tar.gz: 42fa863ec1f9b122d3c9199323fda9a94060ea54f5b1810afcb966bd8ee83285
3
+ metadata.gz: c4975625da2b7b85af3c8a64937f2a5ec16276f71025f0b524eabee9d9b1cd0a
4
+ data.tar.gz: '024299e5e79792a1b019e5401c9a1e6ff6d34b771eeb697578daddac4314eef2'
5
5
  SHA512:
6
- metadata.gz: 04c4f0257547edab6f5304807288ee043873af0473d6c1bd31d2ba4e8e734ea2cbd74f7cfe1c4b8f811ba18f878a4534f402c83e8fa559cb64ff11706aafb769
7
- data.tar.gz: b7b71f2f8fdb4527785fc17cdc023a618419b62c4c22699173df8c33034208b9c25c70319cf76bfd3ad3fcd1ce5386160d5cfe14d4508b6e928b383fc329df76
6
+ metadata.gz: f49ee8af5c6bd623dfe5be6d096e076c2946a08d647e2c52873d53374d1671f3d5c3f02f53fe7b68144df3275758060d58b24b3d5c52aa526688f69f2b5d04c8
7
+ data.tar.gz: b69adbe0703a228472a40a532101638d581c3636f7a80ce894d53f789696fe45845cf316a86f0bb16905f683bbe91fcd1ffa2a289d86b1dae4c0abb47b798273
data/CHANGELOG.md CHANGED
@@ -9,6 +9,56 @@ 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.5] - 2026-11-27
13
+
14
+ A patch release that adds one sentence to the docs
15
+ ([#338](https://github.com/basecradle/basecradle-ruby/issues/338)). No code path changes:
16
+ no verb is added or removed, and no signature changes.
17
+
18
+ ### Fixed
19
+
20
+ - **The docs now say how to move an endpoint off `sns` before the new sender's secret
21
+ exists.** The rule that a move to or from `sns` carries `credential:` in the same call
22
+ binds only an endpoint that holds a credential: one with none moves between any two
23
+ schemes freely. So `endpoint.clear_verification`, then
24
+ `endpoint.configure_verification(verifier: "hmac_sha256_hex")` (or any other scheme),
25
+ makes the move in two calls, with no secret yet. The README, `configure_verification`
26
+ and `clear_verification` say so.
27
+
28
+ ## [0.17.4] - 2026-11-27
29
+
30
+ A patch release that corrects what the SDK says about a platform change of 2026-11-27
31
+ ([#336](https://github.com/basecradle/basecradle-ruby/issues/336)), and gives the error code
32
+ it added a class. No verb is added or removed, and no signature changes.
33
+
34
+ ### Fixed
35
+
36
+ - **An endpoint's `verifier` has seven schemes, not five.** The platform now verifies
37
+ `stripe` and `sns`. `configure_verification` already passed the verifier through as a
38
+ string, so both work with this SDK as it is; only the docs listed five. The README,
39
+ `WebhookVerification` and `configure_verification` now list all seven.
40
+ - **`stripe`**, for a Stripe webhook destination. The secret is the destination's
41
+ Signing secret at Stripe (`whsec_…`). It reads Stripe's own `Stripe-Signature`, fixed,
42
+ so `signature_header` is ignored, as under `github`, `slack` and `twilio`. A delivery
43
+ whose signed timestamp is more than five minutes from now is refused, and a repeat of
44
+ one Stripe event (the same event `id`) is stored once.
45
+ - **`sns`**, for an Amazon SNS topic. The credential is **the ARN of the topic** the
46
+ endpoint listens to: not a secret, and still write-only. SNS signs inside the message,
47
+ so **`verification.signature_header` is an empty string** for an `sns` endpoint; the
48
+ SDK reads it as sent (a test now pins it), and nothing in the SDK assumed it was
49
+ non-empty. Pass `credential:` in the same call that moves an endpoint to or from `sns`:
50
+ an ARN is never carried over to a secret scheme, nor a secret to `sns`, so a call that
51
+ passes only `verifier:` raises `BaseCradle::ValidationError`. The endpoint confirms
52
+ the SNS subscription by itself, and the confirmation creates no event, so set the ARN
53
+ before you subscribe the topic. Raw message delivery must be off, and a repeat of one
54
+ SNS message (the same `MessageId`) is stored once.
55
+ - **`service_unavailable` maps to `BaseCradle::ServiceUnavailableError`.** The API
56
+ documents this code (`503`): a webhook delivery could not be verified right now, because
57
+ the sender's own certificate (Amazon SNS's) could not be fetched or its handshake could
58
+ not be completed, so nothing was stored and the sender sends it again. It is an answer to
59
+ a *sender*; no call this SDK makes receives it today. Until now the registry did not
60
+ list it, so it would have read as a bare `BaseCradle::Error`.
61
+
12
62
  ## [0.17.3] - 2026-11-26
13
63
 
14
64
  A patch release that corrects what the SDK says about a platform change of 2026-11-26
@@ -34,6 +84,7 @@ no verb is added or removed, and no signature changes.
34
84
  `configure_verification` already passed the verifier through as a string, so `twilio`
35
85
  works with this SDK as it is; only the docs listed four. The README,
36
86
  `WebhookVerification` and `configure_verification` now list all five.
87
+ *Corrected in 0.17.4: since 2026-11-27 it has seven, adding `stripe` and `sns`.*
37
88
 
38
89
  ## [0.17.2] - 2026-11-26
39
90
 
@@ -65,7 +116,8 @@ no verb is added or removed, and no signature changes.
65
116
  `slack`. It is required in the same call that moves an endpoint to
66
117
  `shared_secret_header`, or from it back to `hmac_sha256_hex`; a call that passes only
67
118
  `verifier:` there raises `BaseCradle::ValidationError`.
68
- *Corrected in 0.17.3: since 2026-11-26 it has five, adding `twilio`.*
119
+ *Corrected in 0.17.3: since 2026-11-26 it has five, adding `twilio`; and in 0.17.4: since
120
+ 2026-11-27 seven, adding `stripe` and `sns`.*
69
121
 
70
122
  ## [0.17.1] - 2026-11-21
71
123
 
@@ -178,7 +230,8 @@ you upgrade your own Ruby, to 3.3.14, 3.4.13 or 4.0.10.
178
230
  *Corrected in 0.17.2: since 2026-11-25 the platform has four schemes, adding
179
231
  `shared_secret_header` and `slack`, and `signature_header:` also names the header a
180
232
  `shared_secret_header` endpoint reads the secret from. Corrected again in 0.17.3:
181
- since 2026-11-26 it has five, adding `twilio`.*
233
+ since 2026-11-26 it has five, adding `twilio`. Corrected again in 0.17.4: since
234
+ 2026-11-27 it has seven, adding `stripe` and `sns`.*
182
235
  - **`clear_verification`** sends `clear_credential: true`, which removes the secret and
183
236
  turns verification off.
184
237
  - Both update the endpoint in place and return it, like `rotate`, so the new state
@@ -1105,6 +1158,8 @@ the Python SDK's behavior in idiomatic Ruby. Zero runtime dependencies.
1105
1158
  - **Quality bars** — a README-as-tested-doc harness (every example runs against a mocked
1106
1159
  API) and a spec drift-guard (CI fails if the live API grows beyond the SDK).
1107
1160
 
1161
+ [0.17.5]: https://github.com/basecradle/basecradle-ruby/releases/tag/v0.17.5
1162
+ [0.17.4]: https://github.com/basecradle/basecradle-ruby/releases/tag/v0.17.4
1108
1163
  [0.17.3]: https://github.com/basecradle/basecradle-ruby/releases/tag/v0.17.3
1109
1164
  [0.17.2]: https://github.com/basecradle/basecradle-ruby/releases/tag/v0.17.2
1110
1165
  [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 five today:
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,36 @@ 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`. That rule binds only an endpoint that holds a credential: one
261
+ with none moves between any two schemes freely. So to move an endpoint off `sns` before the
262
+ new sender's secret exists, clear the verification first, then name the new scheme:
263
+ `endpoint.clear_verification`, then `endpoint.configure_verification(verifier: "hmac_sha256_hex")`.
264
+ The endpoint confirms the SNS subscription by itself, and the confirmation creates no event,
265
+ so set the ARN before you subscribe the topic: with no ARN set, the confirmation is stored as
266
+ an event and its `SubscribeURL` is yours to open. Topics in the standard and GovCloud regions
267
+ are supported, the China regions are not. Raw message delivery must be off, and a repeat of
268
+ one SNS message (the same `MessageId`) is stored once.
269
+
250
270
  The verifier is passed through as given, so a scheme the platform adds later needs no SDK
251
271
  release; one it does not know raises `BaseCradle::ValidationError`. Use a signing scheme
252
272
  whenever the sender can sign: `shared_secret_header` proves only that the sender holds the
253
273
  secret, not that the body arrived unaltered. `credential:` is the signing secret (under
254
274
  `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
275
+ 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
276
  stays, and `verification.enabled` cannot tell you a rotation was skipped, so make sure a
257
277
  secret read from the environment is not empty before passing it. It is **write-only**: the
258
278
  API never returns it, and the SDK keeps no copy and never puts it in an `inspect` or an
259
279
  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` or
261
- `twilio` endpoint ignores it. **Pass it in the same call that moves an endpoint to
280
+ `hmac_sha256_hex`, the secret's under `shared_secret_header`; a `github`, `slack`, `sns`,
281
+ `stripe` or `twilio` endpoint ignores it. **Pass it in the same call that moves an endpoint to
262
282
  `shared_secret_header`, or from it back to `hmac_sha256_hex`** — a header named for one
263
283
  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` or
265
- `twilio` that names no header resets it to `X-Signature`. `endpoint.clear_verification` removes the secret and turns verification
284
+ `BaseCradle::ValidationError`. A move from `shared_secret_header` to `github`, `slack`,
285
+ `sns`, `stripe` or `twilio` that names no header resets it to `X-Signature`. `endpoint.clear_verification` removes the secret and turns verification
266
286
  off. Both return the endpoint, updated in place; read the result at
267
287
  `endpoint.content.verification`. How senders sign is in the API docs:
268
288
  [Verifying Inbound Deliveries](https://basecradle.com/docs/api#verifying-inbound-deliveries-optional).
@@ -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 signature is missing or does not match.
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BaseCradle
4
- VERSION = "0.17.3"
4
+ VERSION = "0.17.5"
5
5
  end
@@ -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, and a
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" or "twilio" today — an
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,39 @@ 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 five today: "hmac_sha256_hex" (the default; any
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) or "twilio"
85
- # (the webhooks Twilio sends: an incoming text message, a recording or transcription
86
- # callback, a status callback). It is passed through as given, so a scheme the
87
- # platform adds later works here unchanged; one it does not know raises
88
- # ValidationError. Twilio signs the URL it was given, so give it +content.ingest_url+
89
- # exactly as the endpoint reports it. Twilio also reads the reply, so a "twilio"
90
- # endpoint answers each delivery it stores with 200 OK and an empty TwiML document
91
- # in place of the empty 201: the answer to the sender, which changes nothing this
92
- # method returns. That empty answer ends a voice call, so the ingest_url is never a
93
- # number's voice URL; point a recording's callbacks at it instead.
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. That rule binds
112
+ # only an endpoint that holds a credential: one with none moves between any two
113
+ # schemes freely. So to move an endpoint off "sns" before the new sender's secret
114
+ # exists, call clear_verification first, then name the new scheme here.
97
115
  # Under "twilio" it is a shared key made at Twilio for signing webhooks (Twilio's own
98
116
  # recommendation) or the account's Auth Token. An endpoint holds one secret, a
99
117
  # delivery signed with the other is refused with 401, and Twilio does not resend it
@@ -108,12 +126,13 @@ module BaseCradle
108
126
  # the API never returns it, and this SDK keeps no copy and never puts it in an
109
127
  # inspect or an error message.
110
128
  # - +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 moves an endpoint
113
- # to "shared_secret_header", or from it back to "hmac_sha256_hex": a header named
114
- # for one is never carried over to the other, so passing only +verifier+ there
115
- # raises ValidationError. A move from "shared_secret_header" to "github", "slack" or
116
- # "twilio" that names no header resets it to X-Signature.
129
+ # "hmac_sha256_hex", the secret's under "shared_secret_header". A "github", "slack",
130
+ # "sns", "stripe" or "twilio" endpoint ignores it. Pass it in the same call that
131
+ # moves an endpoint to "shared_secret_header", or from it back to "hmac_sha256_hex":
132
+ # a header named for one is never carried over to the other, so passing only
133
+ # +verifier+ there raises ValidationError. A move from "shared_secret_header" to
134
+ # "github", "slack", "sns", "stripe" or "twilio" that names no header resets it to
135
+ # X-Signature.
117
136
  #
118
137
  # Any viewer of the endpoint's timeline may configure it, locked timeline or not.
119
138
  # Returns this endpoint, which adopts the one the API returns, so
@@ -131,8 +150,11 @@ module BaseCradle
131
150
  end
132
151
 
133
152
  # Remove the signing secret and turn verification off: deliveries are accepted
134
- # unsigned again, and +content.verification.enabled+ reads false. Returns this
135
- # endpoint, which adopts the one the API returns.
153
+ # unsigned again, and +content.verification.enabled+ reads false. The verifier
154
+ # stays: an endpoint with no credential moves between any two schemes freely, so this,
155
+ # then configure_verification(verifier: ...), moves an endpoint off "sns" before the
156
+ # new sender's secret exists. Returns this endpoint, which adopts the one the API
157
+ # returns.
136
158
  def clear_verification
137
159
  adopt(require_client.request("PATCH", endpoint_path,
138
160
  json: { "webhook_endpoint" => { "clear_credential" => true } }))
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: basecradle
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.17.3
4
+ version: 0.17.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Drawk Kwast