stripe 19.6.0 → 19.6.2
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/lib/stripe/api_requestor.rb +2 -2
- data/lib/stripe/resources/v2/core/event_notification.rb +6 -3
- data/lib/stripe/services/oauth_service.rb +1 -1
- data/lib/stripe/stripe_context.rb +7 -1
- data/lib/stripe/util.rb +32 -0
- data/lib/stripe/v2_list_object.rb +2 -1
- data/lib/stripe/version.rb +1 -1
- data/lib/stripe/webhook.rb +8 -0
- data/rbi/stripe/stripe_client.rbi +1 -1
- 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: 310e2209501ef945d302084ec788e94effc1d49d7b28ae696f96c72ba8b16352
|
|
4
|
+
data.tar.gz: 8b6c08b64f0f314f69a276b37c251079b19b17fff9b36e362751096a3896fac3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5fa01da68c76512fb633bd82c8c36010cfd5b6d85ea38d1ba71acc6464859c5093514d9b8bb3c68b71616dfbdc238f286f436a2726d887066f173e1363b899c4
|
|
7
|
+
data.tar.gz: 79467cd47cd0712f1c95605a89ac2790b06c865c47d8dc438031479a1d5d72713bce5872fa9c38fc5d110b73adacb5457074fd3e92f7769858fc2d9a405dcb4e
|
data/lib/stripe/api_requestor.rb
CHANGED
|
@@ -462,13 +462,13 @@ module Stripe
|
|
|
462
462
|
private def execute_request_internal(method, path,
|
|
463
463
|
base_address, params, opts, usage,
|
|
464
464
|
&read_body_chunk_block)
|
|
465
|
+
Util.validate_path!(path)
|
|
466
|
+
|
|
465
467
|
api_mode = Util.get_api_mode(path)
|
|
466
468
|
opts = RequestOptions.merge_config_and_opts(config, opts)
|
|
467
469
|
|
|
468
470
|
raise ArgumentError, "method should be a symbol" \
|
|
469
471
|
unless method.is_a?(Symbol)
|
|
470
|
-
raise ArgumentError, "path should be a string" \
|
|
471
|
-
unless path.is_a?(String)
|
|
472
472
|
|
|
473
473
|
base_url ||= config.base_addresses[base_address]
|
|
474
474
|
|
|
@@ -53,9 +53,12 @@ module Stripe
|
|
|
53
53
|
|
|
54
54
|
# Retrieves the Event that generated this EventNotification.
|
|
55
55
|
def fetch_event
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
# `id` comes from the notification body, so escape it the way generated
|
|
57
|
+
# services do -- otherwise it can inject extra path or query segments.
|
|
58
|
+
path = "/v2/core/events/#{CGI.escape(id)}"
|
|
59
|
+
resp = @client.raw_request(:get, path, opts: { stripe_context: context,
|
|
60
|
+
"Stripe-Request-Trigger" => "event=#{id}", },
|
|
61
|
+
usage: ["fetch_event"])
|
|
59
62
|
@client.deserialize(resp.http_body, api_mode: :v2)
|
|
60
63
|
end
|
|
61
64
|
end
|
|
@@ -13,7 +13,7 @@ module Stripe
|
|
|
13
13
|
|
|
14
14
|
# Creates a new StripeContext with the given segments.
|
|
15
15
|
def initialize(segments = nil)
|
|
16
|
-
@segments = (segments || []).map(
|
|
16
|
+
@segments = (segments || []).map { |segment| (segment.is_a?(String) ? segment.dup : segment.to_s).freeze }.freeze
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
# Parses a context string into a StripeContext instance.
|
|
@@ -54,6 +54,12 @@ module Stripe
|
|
|
54
54
|
# Alias for == to support eql? method
|
|
55
55
|
alias eql? ==
|
|
56
56
|
|
|
57
|
+
# As with equality in #== and #eql?, contexts with equivalent segments
|
|
58
|
+
# hash to the same value.
|
|
59
|
+
def hash
|
|
60
|
+
@segments.hash
|
|
61
|
+
end
|
|
62
|
+
|
|
57
63
|
# Returns a human-readable representation for debugging.
|
|
58
64
|
def inspect
|
|
59
65
|
"#<#{self.class}:0x#{object_id.to_s(16)} segments=#{@segments.inspect}>"
|
data/lib/stripe/util.rb
CHANGED
|
@@ -375,6 +375,38 @@ module Stripe
|
|
|
375
375
|
res.zero?
|
|
376
376
|
end
|
|
377
377
|
|
|
378
|
+
# Asserts that a request path is origin-relative: that it begins with a
|
|
379
|
+
# single "/" and carries no scheme, authority or userinfo.
|
|
380
|
+
#
|
|
381
|
+
# The absolute URL is built by concatenating a base address onto this path,
|
|
382
|
+
# and no base address ends in a slash. A path like "@evil.example/v1/x" or
|
|
383
|
+
# ".evil.example/v1/x" would modify the resulting host and direct the request
|
|
384
|
+
# (including the API key) to a non-Stripe host.
|
|
385
|
+
#
|
|
386
|
+
# Because some relative urls arrive from potentially untrusted sources (like
|
|
387
|
+
# webhook bodies), we have to be a little defensive.
|
|
388
|
+
#
|
|
389
|
+
# So, we require that a path starts with a leading slash and that URI.parse
|
|
390
|
+
# finds no scheme or authority in it.
|
|
391
|
+
def self.validate_path!(path)
|
|
392
|
+
unless path.is_a?(String) && path.start_with?("/") && !path.start_with?("//")
|
|
393
|
+
raise ArgumentError,
|
|
394
|
+
"path must be a string beginning with a single \"/\", got: #{path.inspect}"
|
|
395
|
+
end
|
|
396
|
+
|
|
397
|
+
uri =
|
|
398
|
+
begin
|
|
399
|
+
URI.parse(path)
|
|
400
|
+
rescue URI::InvalidURIError
|
|
401
|
+
raise ArgumentError, "path is not a valid URI: #{path.inspect}"
|
|
402
|
+
end
|
|
403
|
+
|
|
404
|
+
return if uri.scheme.nil? && uri.host.nil? && uri.userinfo.nil?
|
|
405
|
+
|
|
406
|
+
raise ArgumentError,
|
|
407
|
+
"path may not contain a scheme or authority, got: #{path.inspect}"
|
|
408
|
+
end
|
|
409
|
+
|
|
378
410
|
# Returns either v1 or v2 as api_mode based on the given path
|
|
379
411
|
def self.get_api_mode(path)
|
|
380
412
|
if path.start_with?("/v2/")
|
data/lib/stripe/version.rb
CHANGED
data/lib/stripe/webhook.rb
CHANGED
|
@@ -135,6 +135,14 @@ module Stripe
|
|
|
135
135
|
)
|
|
136
136
|
end
|
|
137
137
|
|
|
138
|
+
if secret.nil? || secret.empty?
|
|
139
|
+
raise SignatureVerificationError.new(
|
|
140
|
+
"No webhook secret value was provided. It should start with " \
|
|
141
|
+
"`whsec_`",
|
|
142
|
+
header, http_body: payload
|
|
143
|
+
)
|
|
144
|
+
end
|
|
145
|
+
|
|
138
146
|
expected_sig = compute_signature(timestamp, payload, secret)
|
|
139
147
|
unless signatures.any? { |s| Util.secure_compare(expected_sig, s) }
|
|
140
148
|
raise SignatureVerificationError.new(
|
|
@@ -16,7 +16,7 @@ module Stripe
|
|
|
16
16
|
)
|
|
17
17
|
.returns(::Stripe::V2::Core::EventNotification)
|
|
18
18
|
end
|
|
19
|
-
def parse_event_notification(payload, sig_header, secret, tolerance: Webhook::DEFAULT_TOLERANCE); end
|
|
19
|
+
def parse_event_notification(payload, sig_header, secret, tolerance: ::Stripe::Webhook::DEFAULT_TOLERANCE); end
|
|
20
20
|
|
|
21
21
|
# Constructs a [thin event notification](https://docs.stripe.com/event-destinations#thin-payload) from
|
|
22
22
|
# an incoming webhook without first verifying its authenticity. Should be used after calling
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: stripe
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 19.6.
|
|
4
|
+
version: 19.6.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Stripe
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-09-09 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bigdecimal
|