workos 10.3.0 → 10.4.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.
Files changed (96) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +2 -2
  3. data/.github/workflows/docs.yml +3 -3
  4. data/.github/workflows/lint.yml +2 -2
  5. data/.github/workflows/release-please.yml +3 -3
  6. data/.github/workflows/release.yml +2 -2
  7. data/.last-synced-sha +1 -1
  8. data/.oagen-manifest.json +234 -156
  9. data/.release-please-manifest.json +1 -1
  10. data/.ruby-version +1 -1
  11. data/CHANGELOG.md +174 -0
  12. data/Gemfile.lock +14 -14
  13. data/README.md +23 -0
  14. data/lib/workos/admin_portal.rb +2 -2
  15. data/lib/workos/agents.rb +5 -1
  16. data/lib/workos/api_keys/validate_api_key.rb +12 -1
  17. data/lib/workos/base_client.rb +6 -2
  18. data/lib/workos/configuration.rb +3 -2
  19. data/lib/workos/inflections.rb +2 -0
  20. data/lib/workos/multi_factor_auth.rb +1 -1
  21. data/lib/workos/pipes/connected_account.rb +9 -0
  22. data/lib/workos/pipes/create_data_integration.rb +3 -0
  23. data/lib/workos/pipes/data_integration.rb +3 -0
  24. data/lib/workos/pipes/data_integration_installation.rb +9 -0
  25. data/lib/workos/pipes/data_integrations_get_data_integration_authorize_url_request.rb +3 -0
  26. data/lib/workos/pipes/data_integrations_get_user_token_request.rb +11 -2
  27. data/lib/workos/pipes/data_integrations_list_response_data.rb +18 -3
  28. data/lib/workos/pipes/data_integrations_list_response_data_connected_account.rb +9 -0
  29. data/lib/workos/pipes/data_integrations_upsert_api_key_request.rb +25 -1
  30. data/lib/workos/pipes/data_integrations_upsert_client_credentials_request.rb +6 -0
  31. data/lib/workos/pipes/data_integrations_vend_credentials_request.rb +11 -2
  32. data/lib/workos/pipes.rb +324 -17
  33. data/lib/workos/session_manager.rb +11 -6
  34. data/lib/workos/shared/account_selection_required_error.rb +22 -0
  35. data/lib/workos/shared/pipe_connected_account.rb +15 -0
  36. data/lib/workos/shared/pipes_account_connection_add_failed.rb +34 -0
  37. data/lib/workos/shared/pipes_account_connection_add_failed_data.rb +49 -0
  38. data/lib/workos/shared/pipes_account_connection_connected.rb +34 -0
  39. data/lib/workos/shared/pipes_account_connection_connection_failed.rb +34 -0
  40. data/lib/workos/shared/pipes_account_connection_connection_failed_data.rb +7 -0
  41. data/lib/workos/shared/pipes_account_connection_disconnected.rb +34 -0
  42. data/lib/workos/shared/pipes_account_connection_reauthorization_needed.rb +34 -0
  43. data/lib/workos/shared/pipes_connected_account_connection_failed_data.rb +1 -40
  44. data/lib/workos/types/connected_account_connection_role.rb +13 -0
  45. data/lib/workos/types/create_data_integration_ownership.rb +13 -0
  46. data/lib/workos/types/create_webhook_endpoint_events.rb +6 -1
  47. data/lib/workos/types/data_integration_installation_connection_role.rb +9 -0
  48. data/lib/workos/types/data_integration_ownership.rb +9 -0
  49. data/lib/workos/types/data_integrations_get_data_integration_authorize_url_request_connection_owner.rb +9 -0
  50. data/lib/workos/types/data_integrations_get_user_token_request_connection_owner.rb +9 -0
  51. data/lib/workos/types/data_integrations_list_response_data_connected_account_connection_role.rb +9 -0
  52. data/lib/workos/types/data_integrations_list_response_data_connection_owner.rb +9 -0
  53. data/lib/workos/types/data_integrations_upsert_api_key_request_connection_owner.rb +9 -0
  54. data/lib/workos/types/data_integrations_upsert_client_credentials_request_connection_owner.rb +9 -0
  55. data/lib/workos/types/data_integrations_vend_credentials_request_connection_owner.rb +9 -0
  56. data/lib/workos/types/pipe_connected_account_auth_method.rb +9 -0
  57. data/lib/workos/types/pipe_connected_account_connection_role.rb +9 -0
  58. data/lib/workos/types/pipes_ownership.rb +9 -0
  59. data/lib/workos/types/resource_export_completed_data_resource_type.rb +3 -1
  60. data/lib/workos/user_management/authkit_oauth_resource.rb +34 -0
  61. data/lib/workos/user_management/create_authkit_oauth_resource.rb +22 -0
  62. data/lib/workos/user_management.rb +87 -0
  63. data/lib/workos/version.rb +1 -1
  64. data/rbi/workos/account_selection_required_error.rbi +30 -0
  65. data/rbi/workos/agents.rbi +2 -1
  66. data/rbi/workos/authkit_oauth_resource.rbi +54 -0
  67. data/rbi/workos/connected_account.rbi +18 -0
  68. data/rbi/workos/create_authkit_oauth_resource.rbi +30 -0
  69. data/rbi/workos/create_data_integration.rbi +6 -0
  70. data/rbi/workos/data_integration.rbi +6 -0
  71. data/rbi/workos/data_integration_installation.rbi +19 -1
  72. data/rbi/workos/data_integrations_get_data_integration_authorize_url_request.rbi +6 -0
  73. data/rbi/workos/data_integrations_get_user_token_request.rbi +18 -0
  74. data/rbi/workos/data_integrations_list_response_data.rbi +12 -0
  75. data/rbi/workos/data_integrations_list_response_data_connected_account.rbi +18 -0
  76. data/rbi/workos/data_integrations_upsert_api_key_request.rbi +12 -0
  77. data/rbi/workos/data_integrations_upsert_client_credentials_request.rbi +12 -0
  78. data/rbi/workos/data_integrations_vend_credentials_request.rbi +18 -0
  79. data/rbi/workos/pipe_connected_account.rbi +30 -0
  80. data/rbi/workos/pipes.rbi +122 -11
  81. data/rbi/workos/pipes_account_connection_add_failed.rbi +54 -0
  82. data/rbi/workos/pipes_account_connection_add_failed_data.rbi +84 -0
  83. data/rbi/workos/pipes_account_connection_connected.rbi +54 -0
  84. data/rbi/workos/pipes_account_connection_connection_failed.rbi +54 -0
  85. data/rbi/workos/pipes_account_connection_connection_failed_data.rbi +84 -0
  86. data/rbi/workos/pipes_account_connection_disconnected.rbi +54 -0
  87. data/rbi/workos/pipes_account_connection_reauthorization_needed.rbi +54 -0
  88. data/rbi/workos/pipes_connected_account_connection_failed_data.rbi +6 -0
  89. data/rbi/workos/user_management.rbi +28 -0
  90. data/test/workos/test_pipes.rb +64 -0
  91. data/test/workos/test_pipes_model_round_trip.rb +35 -5
  92. data/test/workos/test_session.rb +63 -0
  93. data/test/workos/test_shared_model_round_trip.rb +161 -0
  94. data/test/workos/test_user_management.rb +24 -0
  95. data/test/workos/test_user_management_model_round_trip.rb +32 -0
  96. metadata +35 -1
data/lib/workos/pipes.rb CHANGED
@@ -15,6 +15,7 @@ module WorkOS
15
15
  # @param after [String, nil] An object ID that defines your place in the list. When the ID is not present, you are at the end of the list. For example, if you make a list request and receive 100 objects, ending with `"obj_123"`, your subsequent call can include `after="obj_123"` to fetch a new batch of objects after `"obj_123"`.
16
16
  # @param limit [Integer, nil] Upper limit on the number of objects to return, between `1` and `100`.
17
17
  # @param order [WorkOS::Types::PaginationOrder, nil] Order the results by the creation time. Supported values are `"asc"` (ascending), `"desc"` (descending), and `"normal"` (descending with reversed cursor semantics where `before` fetches older records and `after` fetches newer records).
18
+ # @param ownership [WorkOS::Types::PipesOwnership, nil] Only return Data Integrations with this ownership: `user` for the integrations users connect their own accounts to, or `organization` for the roots organizations connect to. Omit to return both.
18
19
  # @param request_options [Hash] (see WorkOS::Types::RequestOptions)
19
20
  # @return [WorkOS::Types::ListStruct<WorkOS::DataIntegration>]
20
21
  def list_data_integrations(
@@ -22,13 +23,15 @@ module WorkOS
22
23
  after: nil,
23
24
  limit: 10,
24
25
  order: "desc",
26
+ ownership: nil,
25
27
  request_options: {}
26
28
  )
27
29
  params = {
28
30
  "before" => before,
29
31
  "after" => after,
30
32
  "limit" => limit,
31
- "order" => order
33
+ "order" => order,
34
+ "ownership" => ownership
32
35
  }.compact
33
36
  response = @client.request(
34
37
  method: :get,
@@ -43,19 +46,21 @@ module WorkOS
43
46
  after: cursor,
44
47
  limit: limit,
45
48
  order: order,
49
+ ownership: ownership,
46
50
  request_options: request_options
47
51
  )
48
52
  }
49
53
  WorkOS::Types::ListStruct.from_response(
50
54
  response,
51
55
  model: WorkOS::DataIntegration,
52
- filters: {before: before, limit: limit, order: order},
56
+ filters: {before: before, limit: limit, order: order, ownership: ownership},
53
57
  fetch_next: fetch_next
54
58
  )
55
59
  end
56
60
 
57
61
  # Create a data integration
58
62
  # @param provider [String] The provider to create a Data Integration for. For a built-in provider use its slug (e.g. `github`, `slack`). For a custom provider, this is the new provider slug and `custom_provider` must be supplied. A custom provider slug cannot shadow an existing global provider slug.
63
+ # @param ownership [WorkOS::Types::CreateDataIntegrationOwnership, nil] Who owns the Data Integration. `user` (the default) creates the integration users connect their own accounts to; `organization` creates the root organizations connect to. Ownership is fixed at creation, and one integration of each ownership may exist per provider. Independent of `credentials.type`.
59
64
  # @param description [String, nil] An optional description of the Data Integration.
60
65
  # @param enabled [Boolean, nil] Whether the Data Integration is enabled. Defaults to `false`.
61
66
  # @param scopes [Array<String>, nil] The OAuth scopes to request for the Data Integration. Defaults to the provider's configured scopes when omitted.
@@ -68,6 +73,7 @@ module WorkOS
68
73
  # @return [WorkOS::DataIntegration]
69
74
  def create_data_integration(
70
75
  provider:,
76
+ ownership: nil,
71
77
  description: WorkOS::OMIT,
72
78
  enabled: nil,
73
79
  scopes: WorkOS::OMIT,
@@ -80,6 +86,7 @@ module WorkOS
80
86
  )
81
87
  body = {
82
88
  "provider" => provider,
89
+ "ownership" => ownership,
83
90
  "enabled" => enabled,
84
91
  "auth_methods" => auth_methods,
85
92
  "config" => config,
@@ -180,7 +187,9 @@ module WorkOS
180
187
  # Upsert an API key for a connected account
181
188
  # @param slug [String] The identifier of the integration.
182
189
  # @param user_id [String] A [User](https://workos.com/docs/reference/authkit/user) identifier.
183
- # @param organization_id [String, nil] An [Organization](https://workos.com/docs/reference/organization) identifier. Optional parameter to scope the connection to a specific organization.
190
+ # @param organization_id [String, nil] An [Organization](https://workos.com/docs/reference/organization) identifier. Optional parameter to scope the connection to a specific organization. Required when `connection_owner` is `organization`.
191
+ # @param connected_account_id [String, nil] A [connected account](https://workos.com/docs/reference/pipes/connected-account) identifier. Use this to rotate a specific existing connection.
192
+ # @param connection_owner [WorkOS::Types::DataIntegrationsUpsertApiKeyRequestConnectionOwner, nil] Whose connection to create or rotate. `user` (the default) addresses the connection owned by `user_id`. `organization` addresses the connection shared by every member of `organization_id`; `user_id` then identifies the member performing the request and must be an active member of the organization.
184
193
  # @param secret [String] The API key secret to store for this integration.
185
194
  # @param request_options [Hash] (see WorkOS::Types::RequestOptions)
186
195
  # @return [WorkOS::ConnectedAccount]
@@ -189,11 +198,15 @@ module WorkOS
189
198
  user_id:,
190
199
  secret:,
191
200
  organization_id: nil,
201
+ connected_account_id: nil,
202
+ connection_owner: nil,
192
203
  request_options: {}
193
204
  )
194
205
  body = {
195
206
  "user_id" => user_id,
196
207
  "organization_id" => organization_id,
208
+ "connected_account_id" => connected_account_id,
209
+ "connection_owner" => connection_owner,
197
210
  "secret" => secret
198
211
  }.compact
199
212
  response = @client.request(
@@ -210,8 +223,9 @@ module WorkOS
210
223
 
211
224
  # Get authorization URL
212
225
  # @param slug [String] The slug identifier of the provider (e.g., `github`, `slack`, `notion`).
213
- # @param user_id [String] The ID of the user to authorize.
214
- # @param organization_id [String, nil] An organization ID to scope the authorization to a specific organization.
226
+ # @param user_id [String] The ID of the user to authorize. When `connection_owner` is `organization`, this is the user authorizing on behalf of the organization; they must be an active member of the organization and do not become the owner of the resulting connected account.
227
+ # @param organization_id [String, nil] An organization ID to scope the authorization to a specific organization. Required when `connection_owner` is `organization`.
228
+ # @param connection_owner [WorkOS::Types::DataIntegrationsGetDataIntegrationAuthorizeUrlRequestConnectionOwner, nil] Who will own the connected account. `user` (the default) connects the user's own account. `organization` connects the organization's shared account and requires `organization_id`.
215
229
  # @param return_to [String, nil] The URL to redirect the user to after authorization.
216
230
  # @param config [Hash{String => String}, nil] Connect-time config values for the provider-declared `installation`-scope fields (e.g. a Zendesk `subdomain`), keyed by the config field. Only fields the provider declares may be supplied, and required fields must be provided unless already pinned on the integration.
217
231
  # @param request_options [Hash] (see WorkOS::Types::RequestOptions)
@@ -220,6 +234,7 @@ module WorkOS
220
234
  slug:,
221
235
  user_id:,
222
236
  organization_id: nil,
237
+ connection_owner: nil,
223
238
  return_to: nil,
224
239
  config: nil,
225
240
  request_options: {}
@@ -227,6 +242,7 @@ module WorkOS
227
242
  body = {
228
243
  "user_id" => user_id,
229
244
  "organization_id" => organization_id,
245
+ "connection_owner" => connection_owner,
230
246
  "return_to" => return_to,
231
247
  "config" => config
232
248
  }.compact
@@ -245,7 +261,9 @@ module WorkOS
245
261
  # Upsert client credentials for a connected account
246
262
  # @param slug [String] The identifier of the integration.
247
263
  # @param user_id [String] A [User](https://workos.com/docs/reference/authkit/user) identifier.
248
- # @param organization_id [String, nil] An [Organization](https://workos.com/docs/reference/organization) identifier. Optional parameter to scope the connection to a specific organization.
264
+ # @param organization_id [String, nil] An [Organization](https://workos.com/docs/reference/organization) identifier. Optional parameter to scope the connection to a specific organization. Required when `connection_owner` is `organization`.
265
+ # @param connected_account_id [String, nil] A [connected account](https://workos.com/docs/reference/pipes/connected-account) identifier. Use this to rotate a specific existing connection.
266
+ # @param connection_owner [WorkOS::Types::DataIntegrationsUpsertClientCredentialsRequestConnectionOwner, nil] Whose connection to create or rotate. `user` (the default) addresses the connection owned by `user_id`. `organization` addresses the connection shared by every member of `organization_id`; `user_id` then identifies the member performing the request and must be an active member of the organization.
249
267
  # @param client_id [String] The OAuth client ID to store for this integration.
250
268
  # @param client_secret [String] The OAuth client secret to store for this integration.
251
269
  # @param config [Hash{String => String}, nil] Provider-specific configuration values collected for this installation, keyed by the provider's config field descriptors.
@@ -257,12 +275,16 @@ module WorkOS
257
275
  client_id:,
258
276
  client_secret:,
259
277
  organization_id: nil,
278
+ connected_account_id: nil,
279
+ connection_owner: nil,
260
280
  config: nil,
261
281
  request_options: {}
262
282
  )
263
283
  body = {
264
284
  "user_id" => user_id,
265
285
  "organization_id" => organization_id,
286
+ "connected_account_id" => connected_account_id,
287
+ "connection_owner" => connection_owner,
266
288
  "client_id" => client_id,
267
289
  "client_secret" => client_secret,
268
290
  "config" => config
@@ -281,19 +303,28 @@ module WorkOS
281
303
 
282
304
  # Vend credentials for a connected account
283
305
  # @param slug [String] The identifier of the integration.
284
- # @param user_id [String] A [User](https://workos.com/docs/reference/authkit/user) identifier.
285
- # @param organization_id [String, nil] An [Organization](https://workos.com/docs/reference/organization) identifier. Optional parameter to scope the connection to a specific organization.
306
+ # @param user_id [String] A [User](https://workos.com/docs/reference/authkit/user) identifier. When `connection_owner` is `organization`, this is the user the credentials are vended on behalf of; they must be an active member of the organization.
307
+ # @param organization_id [String, nil] An [Organization](https://workos.com/docs/reference/organization) identifier. Optional parameter to scope the connection to a specific organization. Required when `connection_owner` is `organization`.
308
+ # @param connected_account_id [String, nil] A [connected account](https://workos.com/docs/reference/pipes/connected-account) identifier. Use this to select a specific connection when the user has several for this provider.
309
+ # @param connection_owner [WorkOS::Types::DataIntegrationsVendCredentialsRequestConnectionOwner, nil] Which connection to vend from. `user` (the default) vends the user's own connection and requires `user_id`. `organization` vends the organization's shared connection and requires `organization_id`.
310
+ # @param supports_multiple_connections [Boolean, nil] Set to `true` to use the plural connection contract. If no `connected_account_id` is supplied and several connections match, the request returns `account_selection_required`. When omitted or `false`, only the compatibility connection is considered.
286
311
  # @param request_options [Hash] (see WorkOS::Types::RequestOptions)
287
312
  # @return [WorkOS::DataIntegrationCredentialsResponse]
288
313
  def create_data_integration_credential(
289
314
  slug:,
290
315
  user_id:,
291
316
  organization_id: nil,
317
+ connected_account_id: nil,
318
+ connection_owner: nil,
319
+ supports_multiple_connections: nil,
292
320
  request_options: {}
293
321
  )
294
322
  body = {
295
323
  "user_id" => user_id,
296
- "organization_id" => organization_id
324
+ "organization_id" => organization_id,
325
+ "connected_account_id" => connected_account_id,
326
+ "connection_owner" => connection_owner,
327
+ "supports_multiple_connections" => supports_multiple_connections
297
328
  }.compact
298
329
  response = @client.request(
299
330
  method: :post,
@@ -307,21 +338,106 @@ module WorkOS
307
338
  result
308
339
  end
309
340
 
341
+ # Get an organization-owned data integration
342
+ # @param slug [String] The slug identifier of the data integration.
343
+ # @param request_options [Hash] (see WorkOS::Types::RequestOptions)
344
+ # @return [WorkOS::DataIntegration]
345
+ def list_data_integration_organization(
346
+ slug:,
347
+ request_options: {}
348
+ )
349
+ response = @client.request(
350
+ method: :get,
351
+ path: "/data-integrations/#{WorkOS::Util.encode_path(slug)}/organization",
352
+ auth: true,
353
+ request_options: request_options
354
+ )
355
+ result = WorkOS::DataIntegration.new(response.body)
356
+ result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
357
+ result
358
+ end
359
+
360
+ # Update an organization-owned data integration
361
+ # @param slug [String] The slug identifier of the data integration.
362
+ # @param description [String, nil] An optional description of the Data Integration.
363
+ # @param enabled [Boolean, nil] Whether the Data Integration is enabled.
364
+ # @param scopes [Array<String>, nil] The OAuth scopes to request for the Data Integration. Pass `null` to reset to the provider's configured scopes.
365
+ # @param credentials [WorkOS::DataIntegrationCredentialsInput, nil] New OAuth credentials for the Data Integration. When provided, rotates the stored client secret. Mutually exclusive with `api_key`.
366
+ # @param api_key [WorkOS::ApiKeyInstallation, nil] An API key to install or rotate for a tenant on an `api_key` integration. Upserts the tenant installation identified by `user_id` (and optional `organization_id`).
367
+ # @param custom_provider [WorkOS::UpdateCustomProviderDefinition, nil] Updates to a custom provider's OAuth definition. Only valid for custom-provider integrations.
368
+ # @param request_options [Hash] (see WorkOS::Types::RequestOptions)
369
+ # @return [WorkOS::DataIntegration]
370
+ def update_data_integration_organization(
371
+ slug:,
372
+ description: WorkOS::OMIT,
373
+ enabled: nil,
374
+ scopes: WorkOS::OMIT,
375
+ credentials: nil,
376
+ api_key: nil,
377
+ custom_provider: nil,
378
+ request_options: {}
379
+ )
380
+ body = {
381
+ "enabled" => enabled,
382
+ "credentials" => credentials,
383
+ "api_key" => api_key,
384
+ "custom_provider" => custom_provider
385
+ }.compact
386
+ body["description"] = description unless description.equal?(WorkOS::OMIT)
387
+ body["scopes"] = scopes unless scopes.equal?(WorkOS::OMIT)
388
+ response = @client.request(
389
+ method: :put,
390
+ path: "/data-integrations/#{WorkOS::Util.encode_path(slug)}/organization",
391
+ auth: true,
392
+ body: body,
393
+ request_options: request_options
394
+ )
395
+ result = WorkOS::DataIntegration.new(response.body)
396
+ result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
397
+ result
398
+ end
399
+
400
+ # Delete an organization-owned data integration
401
+ # @param slug [String] The slug identifier of the data integration.
402
+ # @param request_options [Hash] (see WorkOS::Types::RequestOptions)
403
+ # @return [void]
404
+ def delete_data_integration_organization(
405
+ slug:,
406
+ request_options: {}
407
+ )
408
+ @client.request(
409
+ method: :delete,
410
+ path: "/data-integrations/#{WorkOS::Util.encode_path(slug)}/organization",
411
+ auth: true,
412
+ request_options: request_options
413
+ )
414
+ nil
415
+ end
416
+
310
417
  # Get an access token for a connected account
311
418
  # @param provider [String] The identifier of the integration.
312
- # @param user_id [String] A [User](https://workos.com/docs/reference/authkit/user) identifier.
313
- # @param organization_id [String, nil] An [Organization](https://workos.com/docs/reference/organization) identifier. Optional parameter to scope the connection to a specific organization.
419
+ # @param user_id [String] A [User](https://workos.com/docs/reference/authkit/user) identifier. When `connection_owner` is `organization`, this is the user the credentials are vended on behalf of; they must be an active member of the organization.
420
+ # @param organization_id [String, nil] An [Organization](https://workos.com/docs/reference/organization) identifier. Optional parameter to scope the connection to a specific organization. Required when `connection_owner` is `organization`.
421
+ # @param connected_account_id [String, nil] A [connected account](https://workos.com/docs/reference/pipes/connected-account) identifier. Use this to select a specific connection when the user has several for this provider.
422
+ # @param connection_owner [WorkOS::Types::DataIntegrationsGetUserTokenRequestConnectionOwner, nil] Which connection to vend from. `user` (the default) vends the user's own connection and requires `user_id`. `organization` vends the organization's shared connection and requires `organization_id`.
423
+ # @param supports_multiple_connections [Boolean, nil] Set to `true` to use the plural connection contract. If no `connected_account_id` is supplied and several connections match, the request returns `account_selection_required`. When omitted or `false`, only the compatibility connection is considered.
314
424
  # @param request_options [Hash] (see WorkOS::Types::RequestOptions)
315
425
  # @return [WorkOS::DataIntegrationAccessTokenResponse]
316
426
  def get_access_token(
317
427
  provider:,
318
428
  user_id:,
319
429
  organization_id: WorkOS::OMIT,
430
+ connected_account_id: nil,
431
+ connection_owner: nil,
432
+ supports_multiple_connections: nil,
320
433
  request_options: {}
321
434
  )
322
435
  body = {
323
- "user_id" => user_id
324
- }
436
+ "user_id" => user_id,
437
+ "connected_account_id" => connected_account_id,
438
+ "connection_owner" => connection_owner,
439
+ "supports_multiple_connections" => supports_multiple_connections
440
+ }.compact
325
441
  body["organization_id"] = organization_id unless organization_id.equal?(WorkOS::OMIT)
326
442
  response = @client.request(
327
443
  method: :post,
@@ -335,20 +451,196 @@ module WorkOS
335
451
  result
336
452
  end
337
453
 
454
+ # Get an organization connected account
455
+ # @param organization_id [String] An [Organization](https://workos.com/docs/reference/organization) identifier.
456
+ # @param slug [String] The slug identifier of the provider (e.g., `github`, `slack`, `notion`).
457
+ # @param supports_multiple_connections [Boolean, nil] Set to `true` to use the plural connection contract. When omitted or `false`, only the compatibility connection is considered.
458
+ # @param connected_account_id [String, nil] A [connected account](https://workos.com/docs/reference/pipes/connected-account) identifier. Use this to select a specific connection when the organization has several for this provider.
459
+ # @param request_options [Hash] (see WorkOS::Types::RequestOptions)
460
+ # @return [WorkOS::ConnectedAccount]
461
+ def get_organization_connected_account(
462
+ organization_id:,
463
+ slug:,
464
+ supports_multiple_connections: nil,
465
+ connected_account_id: nil,
466
+ request_options: {}
467
+ )
468
+ params = {
469
+ "supports_multiple_connections" => supports_multiple_connections,
470
+ "connected_account_id" => connected_account_id
471
+ }.compact
472
+ response = @client.request(
473
+ method: :get,
474
+ path: "/organizations/#{WorkOS::Util.encode_path(organization_id)}/connected_accounts/#{WorkOS::Util.encode_path(slug)}",
475
+ auth: true,
476
+ params: params,
477
+ request_options: request_options
478
+ )
479
+ result = WorkOS::ConnectedAccount.new(response.body)
480
+ result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
481
+ result
482
+ end
483
+
484
+ # Import an organization connected account
485
+ # @param organization_id [String] An [Organization](https://workos.com/docs/reference/organization) identifier.
486
+ # @param slug [String] The slug identifier of the provider (e.g., `github`, `slack`, `notion`).
487
+ # @param access_token [String, nil] The OAuth access token for the connected account.
488
+ # @param refresh_token [String, nil] The OAuth refresh token for the connected account.
489
+ # @param expires_at [String, nil] The ISO-8601 timestamp when the access token expires. Required when `access_token` is provided for tokens that expire.
490
+ # @param scopes [Array<String>, nil] The OAuth scopes granted for this connection.
491
+ # @param state [WorkOS::Types::ConnectedAccountInputState, nil] Explicitly set the state of the connected account. When omitted, the state is derived from the token combination provided.
492
+ # @param request_options [Hash] (see WorkOS::Types::RequestOptions)
493
+ # @return [WorkOS::ConnectedAccount]
494
+ def create_organization_connected_account(
495
+ organization_id:,
496
+ slug:,
497
+ access_token: nil,
498
+ refresh_token: nil,
499
+ expires_at: nil,
500
+ scopes: nil,
501
+ state: nil,
502
+ request_options: {}
503
+ )
504
+ body = {
505
+ "access_token" => access_token,
506
+ "refresh_token" => refresh_token,
507
+ "expires_at" => expires_at,
508
+ "scopes" => scopes,
509
+ "state" => state
510
+ }.compact
511
+ response = @client.request(
512
+ method: :post,
513
+ path: "/organizations/#{WorkOS::Util.encode_path(organization_id)}/connected_accounts/#{WorkOS::Util.encode_path(slug)}",
514
+ auth: true,
515
+ body: body,
516
+ request_options: request_options
517
+ )
518
+ result = WorkOS::ConnectedAccount.new(response.body)
519
+ result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
520
+ result
521
+ end
522
+
523
+ # Update an organization connected account
524
+ # @param organization_id [String] An [Organization](https://workos.com/docs/reference/organization) identifier.
525
+ # @param slug [String] The slug identifier of the provider (e.g., `github`, `slack`, `notion`).
526
+ # @param access_token [String, nil] The OAuth access token for the connected account.
527
+ # @param refresh_token [String, nil] The OAuth refresh token for the connected account.
528
+ # @param expires_at [String, nil] The ISO-8601 timestamp when the access token expires. Required when `access_token` is provided for tokens that expire.
529
+ # @param scopes [Array<String>, nil] The OAuth scopes granted for this connection.
530
+ # @param state [WorkOS::Types::ConnectedAccountInputState, nil] Explicitly set the state of the connected account. When omitted, the state is derived from the token combination provided.
531
+ # @param supports_multiple_connections [Boolean, nil] Set to `true` to use the plural connection contract. When omitted or `false`, only the compatibility connection is considered.
532
+ # @param connected_account_id [String, nil] A [connected account](https://workos.com/docs/reference/pipes/connected-account) identifier. Use this to select the connection to update.
533
+ # @param request_options [Hash] (see WorkOS::Types::RequestOptions)
534
+ # @return [WorkOS::ConnectedAccount]
535
+ def update_organization_connected_account(
536
+ organization_id:,
537
+ slug:,
538
+ access_token: nil,
539
+ refresh_token: nil,
540
+ expires_at: nil,
541
+ scopes: nil,
542
+ state: nil,
543
+ supports_multiple_connections: nil,
544
+ connected_account_id: nil,
545
+ request_options: {}
546
+ )
547
+ params = {
548
+ "supports_multiple_connections" => supports_multiple_connections,
549
+ "connected_account_id" => connected_account_id
550
+ }.compact
551
+ body = {
552
+ "access_token" => access_token,
553
+ "refresh_token" => refresh_token,
554
+ "expires_at" => expires_at,
555
+ "scopes" => scopes,
556
+ "state" => state
557
+ }.compact
558
+ response = @client.request(
559
+ method: :put,
560
+ path: "/organizations/#{WorkOS::Util.encode_path(organization_id)}/connected_accounts/#{WorkOS::Util.encode_path(slug)}",
561
+ auth: true,
562
+ params: params,
563
+ body: body,
564
+ request_options: request_options
565
+ )
566
+ result = WorkOS::ConnectedAccount.new(response.body)
567
+ result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
568
+ result
569
+ end
570
+
571
+ # Delete an organization connected account
572
+ # @param organization_id [String] An [Organization](https://workos.com/docs/reference/organization) identifier.
573
+ # @param slug [String] The slug identifier of the provider (e.g., `github`, `slack`, `notion`).
574
+ # @param supports_multiple_connections [Boolean, nil] Set to `true` to use the plural connection contract. When omitted or `false`, only the compatibility connection is considered.
575
+ # @param connected_account_id [String, nil] A [connected account](https://workos.com/docs/reference/pipes/connected-account) identifier. Use this to select the connection to delete.
576
+ # @param request_options [Hash] (see WorkOS::Types::RequestOptions)
577
+ # @return [void]
578
+ def delete_organization_connected_account(
579
+ organization_id:,
580
+ slug:,
581
+ supports_multiple_connections: nil,
582
+ connected_account_id: nil,
583
+ request_options: {}
584
+ )
585
+ params = {
586
+ "supports_multiple_connections" => supports_multiple_connections,
587
+ "connected_account_id" => connected_account_id
588
+ }.compact
589
+ @client.request(
590
+ method: :delete,
591
+ path: "/organizations/#{WorkOS::Util.encode_path(organization_id)}/connected_accounts/#{WorkOS::Util.encode_path(slug)}",
592
+ auth: true,
593
+ params: params,
594
+ request_options: request_options
595
+ )
596
+ nil
597
+ end
598
+
599
+ # List providers for an organization
600
+ # @param organization_id [String] An [Organization](https://workos.com/docs/reference/organization) identifier to list providers and connected accounts for.
601
+ # @param supports_multiple_connections [Boolean, nil] Set to `true` to use the plural connection contract. When omitted or `false`, only the compatibility connection is considered.
602
+ # @param request_options [Hash] (see WorkOS::Types::RequestOptions)
603
+ # @return [WorkOS::DataIntegrationsListResponse]
604
+ def list_organization_data_providers(
605
+ organization_id:,
606
+ supports_multiple_connections: nil,
607
+ request_options: {}
608
+ )
609
+ params = {
610
+ "supports_multiple_connections" => supports_multiple_connections
611
+ }.compact
612
+ response = @client.request(
613
+ method: :get,
614
+ path: "/organizations/#{WorkOS::Util.encode_path(organization_id)}/data_providers",
615
+ auth: true,
616
+ params: params,
617
+ request_options: request_options
618
+ )
619
+ result = WorkOS::DataIntegrationsListResponse.new(response.body)
620
+ result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
621
+ result
622
+ end
623
+
338
624
  # Get a connected account
339
625
  # @param user_id [String] A [User](https://workos.com/docs/reference/authkit/user) identifier.
340
626
  # @param slug [String] The slug identifier of the provider (e.g., `github`, `slack`, `notion`).
341
627
  # @param organization_id [String, nil] An [Organization](https://workos.com/docs/reference/organization) identifier. Optional parameter if the connection is scoped to an organization.
628
+ # @param supports_multiple_connections [Boolean, nil] Set to `true` to use the plural connection contract. When omitted or `false`, only the compatibility connection is considered.
629
+ # @param connected_account_id [String, nil] A [connected account](https://workos.com/docs/reference/pipes/connected-account) identifier. Use this to select a specific connection when the user has several for this provider.
342
630
  # @param request_options [Hash] (see WorkOS::Types::RequestOptions)
343
631
  # @return [WorkOS::ConnectedAccount]
344
632
  def get_user_connected_account(
345
633
  user_id:,
346
634
  slug:,
347
635
  organization_id: nil,
636
+ supports_multiple_connections: nil,
637
+ connected_account_id: nil,
348
638
  request_options: {}
349
639
  )
350
640
  params = {
351
- "organization_id" => organization_id
641
+ "organization_id" => organization_id,
642
+ "supports_multiple_connections" => supports_multiple_connections,
643
+ "connected_account_id" => connected_account_id
352
644
  }.compact
353
645
  response = @client.request(
354
646
  method: :get,
@@ -416,6 +708,8 @@ module WorkOS
416
708
  # @param scopes [Array<String>, nil] The OAuth scopes granted for this connection.
417
709
  # @param state [WorkOS::Types::ConnectedAccountInputState, nil] Explicitly set the state of the connected account. When omitted, the state is derived from the token combination provided.
418
710
  # @param organization_id [String, nil] An [Organization](https://workos.com/docs/reference/organization) identifier. Optional parameter if the connection is scoped to an organization.
711
+ # @param supports_multiple_connections [Boolean, nil] Set to `true` to use the plural connection contract. When omitted or `false`, only the compatibility connection is considered.
712
+ # @param connected_account_id [String, nil] A [connected account](https://workos.com/docs/reference/pipes/connected-account) identifier. Use this to select the connection to update.
419
713
  # @param request_options [Hash] (see WorkOS::Types::RequestOptions)
420
714
  # @return [WorkOS::ConnectedAccount]
421
715
  def update_user_connected_account(
@@ -427,10 +721,14 @@ module WorkOS
427
721
  scopes: nil,
428
722
  state: nil,
429
723
  organization_id: nil,
724
+ supports_multiple_connections: nil,
725
+ connected_account_id: nil,
430
726
  request_options: {}
431
727
  )
432
728
  params = {
433
- "organization_id" => organization_id
729
+ "organization_id" => organization_id,
730
+ "supports_multiple_connections" => supports_multiple_connections,
731
+ "connected_account_id" => connected_account_id
434
732
  }.compact
435
733
  body = {
436
734
  "access_token" => access_token,
@@ -456,16 +754,22 @@ module WorkOS
456
754
  # @param user_id [String] A [User](https://workos.com/docs/reference/authkit/user) identifier.
457
755
  # @param slug [String] The slug identifier of the provider (e.g., `github`, `slack`, `notion`).
458
756
  # @param organization_id [String, nil] An [Organization](https://workos.com/docs/reference/organization) identifier. Optional parameter if the connection is scoped to an organization.
757
+ # @param supports_multiple_connections [Boolean, nil] Set to `true` to use the plural connection contract. When omitted or `false`, only the compatibility connection is considered.
758
+ # @param connected_account_id [String, nil] A [connected account](https://workos.com/docs/reference/pipes/connected-account) identifier. Use this to select the connection to delete.
459
759
  # @param request_options [Hash] (see WorkOS::Types::RequestOptions)
460
760
  # @return [void]
461
761
  def delete_user_connected_account(
462
762
  user_id:,
463
763
  slug:,
464
764
  organization_id: nil,
765
+ supports_multiple_connections: nil,
766
+ connected_account_id: nil,
465
767
  request_options: {}
466
768
  )
467
769
  params = {
468
- "organization_id" => organization_id
770
+ "organization_id" => organization_id,
771
+ "supports_multiple_connections" => supports_multiple_connections,
772
+ "connected_account_id" => connected_account_id
469
773
  }.compact
470
774
  @client.request(
471
775
  method: :delete,
@@ -480,15 +784,18 @@ module WorkOS
480
784
  # List providers for a user
481
785
  # @param user_id [String] A [User](https://workos.com/docs/reference/authkit/user) identifier to list providers and connected accounts for.
482
786
  # @param organization_id [String, nil] An [Organization](https://workos.com/docs/reference/organization) identifier. Optional parameter to filter connections for a specific organization.
787
+ # @param supports_multiple_connections [Boolean, nil] Set to `true` to use the plural connection contract. When omitted or `false`, only the compatibility connection is considered.
483
788
  # @param request_options [Hash] (see WorkOS::Types::RequestOptions)
484
789
  # @return [WorkOS::DataIntegrationsListResponse]
485
790
  def list_user_data_providers(
486
791
  user_id:,
487
792
  organization_id: nil,
793
+ supports_multiple_connections: nil,
488
794
  request_options: {}
489
795
  )
490
796
  params = {
491
- "organization_id" => organization_id
797
+ "organization_id" => organization_id,
798
+ "supports_multiple_connections" => supports_multiple_connections
492
799
  }.compact
493
800
  response = @client.request(
494
801
  method: :get,
@@ -174,7 +174,10 @@ module WorkOS
174
174
  # Verify an access-token JWT against the WorkOS JWKS for this client.
175
175
  # Used by Session#authenticate; exposed publicly for advanced cases.
176
176
  #
177
- # NOTE on iss/aud/required_claims: this method intentionally does not
177
+ # The `iss` claim is only checked when the client was built with
178
+ # `jwt_issuer:` (a String or an Array of accepted issuers).
179
+ #
180
+ # NOTE on iss/aud/required_claims: by default this method does not
178
181
  # enforce iss, aud, or required_claims. workos-node's `jose` call and
179
182
  # workos-php's `isset($exp) && $exp < time()` accept exp-less tokens, and
180
183
  # cross-SDK parity is required for the planned coordinated hardening of
@@ -182,15 +185,17 @@ module WorkOS
182
185
  # required_claims: ['exp'] tightening that was considered here.
183
186
  def decode_jwt(access_token, verify_expiration: true)
184
187
  jwks = fetch_jwks
185
- JWT.decode(
186
- access_token,
187
- nil,
188
- true,
188
+ options = {
189
189
  algorithms: JWK_ALGORITHMS,
190
190
  jwks: jwks,
191
191
  verify_aud: false,
192
192
  verify_expiration: verify_expiration
193
- ).first
193
+ }
194
+ unless client.jwt_issuer.nil?
195
+ options[:iss] = client.jwt_issuer
196
+ options[:verify_iss] = true
197
+ end
198
+ JWT.decode(access_token, nil, true, options).first
194
199
  end
195
200
 
196
201
  private
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file is auto-generated by oagen. Do not edit.
4
+
5
+ module WorkOS
6
+ class AccountSelectionRequiredError < WorkOS::Types::BaseModel
7
+ HASH_ATTRS = {
8
+ code: :code,
9
+ message: :message
10
+ }.freeze
11
+
12
+ attr_accessor \
13
+ :code,
14
+ :message
15
+
16
+ def initialize(json)
17
+ hash = self.class.normalize(json)
18
+ @code = hash[:code]
19
+ @message = hash[:message]
20
+ end
21
+ end
22
+ end
@@ -7,11 +7,16 @@ module WorkOS
7
7
  HASH_ATTRS = {
8
8
  object: :object,
9
9
  id: :id,
10
+ connection_role: :connection_role,
11
+ account_identifier: :account_identifier,
12
+ account_display_name: :account_display_name,
10
13
  data_integration_id: :data_integration_id,
11
14
  provider_slug: :provider_slug,
12
15
  user_id: :user_id,
13
16
  organization_id: :organization_id,
14
17
  scopes: :scopes,
18
+ auth_method: :auth_method,
19
+ api_key_last_4: :api_key_last_4,
15
20
  state: :state,
16
21
  created_at: :created_at,
17
22
  updated_at: :updated_at
@@ -20,11 +25,16 @@ module WorkOS
20
25
  attr_accessor \
21
26
  :object,
22
27
  :id,
28
+ :connection_role,
29
+ :account_identifier,
30
+ :account_display_name,
23
31
  :data_integration_id,
24
32
  :provider_slug,
25
33
  :user_id,
26
34
  :organization_id,
27
35
  :scopes,
36
+ :auth_method,
37
+ :api_key_last_4,
28
38
  :state,
29
39
  :created_at,
30
40
  :updated_at
@@ -33,11 +43,16 @@ module WorkOS
33
43
  hash = self.class.normalize(json)
34
44
  @object = hash[:object]
35
45
  @id = hash[:id]
46
+ @connection_role = hash[:connection_role]
47
+ @account_identifier = hash[:account_identifier]
48
+ @account_display_name = hash[:account_display_name]
36
49
  @data_integration_id = hash[:data_integration_id]
37
50
  @provider_slug = hash[:provider_slug]
38
51
  @user_id = hash[:user_id]
39
52
  @organization_id = hash[:organization_id]
40
53
  @scopes = hash[:scopes] || []
54
+ @auth_method = hash[:auth_method]
55
+ @api_key_last_4 = hash[:api_key_last_4]
41
56
  @state = hash[:state]
42
57
  @created_at = hash[:created_at]
43
58
  @updated_at = hash[:updated_at]