dodopayments 2.36.0 → 2.37.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 92bc6483e15b2acb4336b40dc7b0506cfcf6459c1df9534b5f2298f5c914578f
4
- data.tar.gz: 031e012d15a53b9e54b167ecd3c294c82eec15c36f6553791b9831e53cdb5355
3
+ metadata.gz: c880e2fe0384012ad81cbc198006a6ee65af759203c8bbce66e8030039bb18d5
4
+ data.tar.gz: 5ab427e23feeba04ec23161257c215986f89ffea690e95cf45508d9eab3f174b
5
5
  SHA512:
6
- metadata.gz: 9a58eba2a64ac73d40c74e345aca8a06e15ecea1bbaa9e64e4812431ade3778748fe4fcdf543bba82fe8031fba96f9b25ab3cfd7059fc375dd27de5d348a28a5
7
- data.tar.gz: 365c61a379aab7d5500c558a76d7153dda3486a4fabdd4af7e90185752aeeb18f2fa45f38116e714e58d5394315decff720996ed7c8ff31c6c111e6e9b35510a
6
+ metadata.gz: 515ea4d5db9220dd321658f0f88c662e26203336402af529e1ea158bbad6ec30cef9e29f6225f7fac3235682e46a9b2aefb175c0de8f8f286f7e9ea310503303
7
+ data.tar.gz: cab907a551a55c24c492e28287b20e8f13e336ddc1fe2333e3357ed1229b0505e69d003c0b4802c1b0a1e58ad046fb54f410dceea6718b06d10c0ed9061e30f2
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.37.0](https://github.com/dodopayments/dodopayments-ruby/compare/v2.36.0...v2.37.0) (2026-10-28)
4
+
5
+
6
+ ### Features
7
+
8
+ * **api:** regenerate SDK from latest OpenAPI spec ([085b68e](https://github.com/dodopayments/dodopayments-ruby/commit/085b68ebf669f2e35556f322b309cc985172789c))
9
+ * **api:** regenerate SDK from latest OpenAPI spec ([f9d6fe6](https://github.com/dodopayments/dodopayments-ruby/commit/f9d6fe6886183baafb6256b064e50b70bc294fe0))
10
+
3
11
  ## [2.36.0](https://github.com/dodopayments/dodopayments-ruby/compare/v2.35.0...v2.36.0) (2026-10-28)
4
12
 
5
13
 
data/README.md CHANGED
@@ -23,7 +23,7 @@ To use this gem, install via Bundler by adding the following to your application
23
23
  <!-- x-release-please-start-version -->
24
24
 
25
25
  ```ruby
26
- gem "dodopayments", "~> 2.36.0"
26
+ gem "dodopayments", "~> 2.37.0"
27
27
  ```
28
28
 
29
29
  <!-- x-release-please-end -->
@@ -88,7 +88,7 @@ dodo_payments = Dodopayments::Client.new(
88
88
  dodo_payments.workload_identity.revoke
89
89
  ```
90
90
 
91
- The `Dodopayments::WorkloadIdentity` module has these token sources: `github_actions`, `gitlab`, `terraform_cloud`, `gcp`, `vercel`, `kubernetes`, `file`, `aws` (wraps your function), `static`, and `auto`. A `provider` can also be any object that responds to `call` and returns the JWT.
91
+ The `Dodopayments::WorkloadIdentity` module has these token sources: `github_actions`, `gitlab`, `terraform_cloud`, `gcp`, `vercel`, `kubernetes`, `file`, `aws` (wraps your function), `static`, and `auto`. A `provider` can also be any object that responds to `call` and returns the JWT. `vercel` gets a Vercel OIDC token with the Dodo Payments audience from the Vercel token endpoint.
92
92
 
93
93
  Do not set `bearer_token` together with `workload_identity`. If you set neither, and `ENV["DODO_PAYMENTS_API_KEY"]` is not set, the client reads `ENV["DODO_PAYMENTS_IDENTITY_PROVIDER_ID"]` and uses the token source that `auto` finds.
94
94
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dodopayments
4
- VERSION = "2.36.0"
4
+ VERSION = "2.37.0"
5
5
  end
@@ -31,6 +31,9 @@ module Dodopayments
31
31
  GCP_METADATA_URL =
32
32
  "http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/identity"
33
33
 
34
+ # @api private
35
+ VERCEL_TOKEN_URL = "https://oidc.vercel.com/~token"
36
+
34
37
  # The values that a subject token provider gets on each token exchange.
35
38
  class Context
36
39
  # The base URL of the client.
@@ -259,10 +262,32 @@ module Dodopayments
259
262
  end
260
263
  end
261
264
 
262
- # Vercel OIDC federation.
265
+ # Vercel: gets a Vercel OIDC token for the Dodo Payments audience on each exchange.
266
+ # The base token comes from `ENV["VERCEL_OIDC_TOKEN_FILE"]` or `ENV["VERCEL_OIDC_TOKEN"]`.
267
+ # Vercel exchanges the base token for a token with the audience.
268
+ #
269
+ # @param audience [String, nil] Defaults to the origin of the client base URL.
263
270
  #
264
271
  # @return [Proc]
265
- def vercel = ->(_context = nil) { env!("VERCEL_OIDC_TOKEN") }
272
+ def vercel(audience: nil)
273
+ lambda do |context|
274
+ body = {token: vercel_base_token, aud: audience || context.audience}
275
+ response = http_post_json(URI(VERCEL_TOKEN_URL), body)
276
+ unless response.is_a?(Net::HTTPSuccess)
277
+ raise Dodopayments::Errors::Error.new(
278
+ "The Vercel OIDC token request failed with status #{response.code}: #{response.body.to_s[0,
279
+ 200]}"
280
+ )
281
+ end
282
+ token = vercel_token(response.body.to_s)
283
+ if token.nil?
284
+ raise Dodopayments::Errors::Error.new(
285
+ "The Vercel OIDC token response has no token (status #{response.code})"
286
+ )
287
+ end
288
+ token
289
+ end
290
+ end
266
291
 
267
292
  # Kubernetes: a projected service account token. The file is read on each exchange.
268
293
  #
@@ -329,6 +354,41 @@ module Dodopayments
329
354
  value
330
355
  end
331
356
 
357
+ private def vercel_base_token
358
+ path = ENV["VERCEL_OIDC_TOKEN_FILE"]
359
+ token = path.nil? || path.empty? ? ENV["VERCEL_OIDC_TOKEN"].to_s.strip : File.read(path).strip
360
+ if token.empty?
361
+ raise Dodopayments::Errors::Error.new(
362
+ "Cannot find a Vercel OIDC token. Set VERCEL_OIDC_TOKEN_FILE or VERCEL_OIDC_TOKEN."
363
+ )
364
+ end
365
+ token
366
+ end
367
+
368
+ private def vercel_token(body)
369
+ data = JSON.parse(body)
370
+ token = data.is_a?(Hash) ? data["token"] : nil
371
+ token.is_a?(String) && !token.empty? ? token : nil
372
+ rescue JSON::ParserError
373
+ nil
374
+ end
375
+
376
+ private def http_post_json(uri, body)
377
+ Net::HTTP.start(
378
+ uri.host,
379
+ uri.port,
380
+ use_ssl: uri.scheme == "https",
381
+ open_timeout: PROVIDER_TIMEOUT_IN_SECONDS,
382
+ read_timeout: PROVIDER_TIMEOUT_IN_SECONDS
383
+ ) do |http|
384
+ http.post(
385
+ uri.request_uri,
386
+ JSON.generate(body),
387
+ {"content-type" => "application/json", "accept" => "application/json"}
388
+ )
389
+ end
390
+ end
391
+
332
392
  private def http_get(uri, headers)
333
393
  response = Net::HTTP.start(
334
394
  uri.host,
@@ -19,6 +19,8 @@ module Dodopayments
19
19
 
20
20
  GCP_METADATA_URL = T.let(T.unsafe(nil), String)
21
21
 
22
+ VERCEL_TOKEN_URL = T.let(T.unsafe(nil), String)
23
+
22
24
  # The values that a subject token provider gets on each token exchange.
23
25
  class Context
24
26
  # The base URL of the client.
@@ -165,9 +167,17 @@ module Dodopayments
165
167
  )
166
168
  end
167
169
 
168
- # Vercel OIDC federation.
169
- sig { returns(Dodopayments::WorkloadIdentity::Provider) }
170
- def vercel
170
+ # Vercel: gets a Vercel OIDC token for the Dodo Payments audience on each
171
+ # exchange.
172
+ sig do
173
+ params(audience: T.nilable(String)).returns(
174
+ Dodopayments::WorkloadIdentity::Provider
175
+ )
176
+ end
177
+ def vercel(
178
+ # Defaults to the origin of the client base URL.
179
+ audience: nil
180
+ )
171
181
  end
172
182
 
173
183
  # Kubernetes: a projected service account token. The file is read on each
@@ -12,6 +12,8 @@ module Dodopayments
12
12
 
13
13
  GCP_METADATA_URL: String
14
14
 
15
+ VERCEL_TOKEN_URL: String
16
+
15
17
  type provider = ^(Dodopayments::WorkloadIdentity::Context context) -> String
16
18
 
17
19
  class Context
@@ -68,7 +70,9 @@ module Dodopayments
68
70
  ?audience: String?
69
71
  ) -> Dodopayments::WorkloadIdentity::provider
70
72
 
71
- def self.vercel: -> Dodopayments::WorkloadIdentity::provider
73
+ def self.vercel: (
74
+ ?audience: String?
75
+ ) -> Dodopayments::WorkloadIdentity::provider
72
76
 
73
77
  def self.kubernetes: (
74
78
  ?path: String
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dodopayments
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.36.0
4
+ version: 2.37.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dodo Payments