stytch 9.7.0 → 9.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2234d80bb5d7d5fa35a2f270fb6edf74d42e8f23a75751f5eba3942cf6fa3b3a
4
- data.tar.gz: 90df59d4eac45d2ffa9b4156c040d30dc0ea4ba852db24be010a0247825ef772
3
+ metadata.gz: 7dbe1acf900692dfab76ad6a2a915b6d0aa570c86b49548a5adb158791b456e8
4
+ data.tar.gz: 56b31a4337f5b38f5540046c8183556686d4315cb591c470b0770f18f719d523
5
5
  SHA512:
6
- metadata.gz: 2cdcc7b6d7e4aacdf2f912f9fd253bb81be8f53e262a7d8ddd380f8c83610895c29c2ecbd87870b8edff04ca7d5f0d047c86215a74d78afec0d4372659f3c4e5
7
- data.tar.gz: 0b321be206d3cb41a31806b9893dfb67405a098f42b950fb456f55d16ae0a12d7c73455391cafb2f3177aef87f4142e9be3293c963b0f5660fd7cbab3c6f8a2c
6
+ metadata.gz: 25ef246a9e7aa615977da5ed743b24b533c9bc94925fb69d33ad79090c70582c05e8e983b5f39f46a5edd54ffcc840a29a715470a67cfe1cb78019e2115b7d97
7
+ data.tar.gz: fb6a211871535e2269d951b10e009a3051ecdfa09ed3ab879de7436662800fc4678b8d457e628a09d203ecc395e55cfb026de75b0b03def56864d1cc1e798aa3
@@ -276,7 +276,7 @@ module StytchB2B
276
276
  #
277
277
  # The type of this field is nilable +String+.
278
278
  # allowed_oauth_tenants::
279
- # A map of allowed OAuth tenants. If this field is not passed in, the Organization will not allow JIT provisioning by OAuth Tenant. Allowed keys are "slack" and "hubspot".
279
+ # A map of allowed OAuth tenants. If this field is not passed in, the Organization will not allow JIT provisioning by OAuth Tenant. Allowed keys are "slack", "hubspot", and "github".
280
280
  # The type of this field is nilable +object+.
281
281
  #
282
282
  # == Returns:
@@ -165,7 +165,8 @@ module StytchB2B
165
165
  @connection = connection
166
166
  end
167
167
 
168
- # Authenticates the Discovery token and exchanges it for an Intermediate Session Token. Intermediate Session Tokens can be used for various Discovery login flows and are valid for 10 minutes.
168
+ # Authenticates the Discovery token and exchanges it for an Intermediate
169
+ # Session Token. Intermediate Session Tokens can be used for various Discovery login flows and are valid for 10 minutes.
169
170
  #
170
171
  # == Parameters:
171
172
  # discovery_oauth_token::
@@ -213,11 +214,14 @@ module StytchB2B
213
214
  # c) The Organization has at least one other Member with a verified email address with the same domain as the end user (to prevent phishing attacks).
214
215
  # The type of this field is list of +DiscoveredOrganization+ (+object+).
215
216
  # provider_type::
216
- # (no documentation yet)
217
+ # Denotes the OAuth identity provider that the user has authenticated with, e.g. Google, Microsoft, GitHub etc.
217
218
  # The type of this field is +String+.
218
219
  # provider_tenant_id::
219
- # (no documentation yet)
220
+ # The tenant ID returned by the OAuth provider. This is typically used to identify an organization or group within the provider's domain. For example, in HubSpot this is a Hub ID, in Slack this is the Workspace ID, and in GitHub this is an organization ID. This field will only be populated if exactly one tenant ID is returned from a successful OAuth authentication and developers should prefer `provider_tenant_ids` over this since it accounts for the possibility of an OAuth provider yielding multiple tenant IDs.
220
221
  # The type of this field is +String+.
222
+ # provider_tenant_ids::
223
+ # All tenant IDs returned by the OAuth provider. These is typically used to identify organizations or groups within the provider's domain. For example, in HubSpot this is a Hub ID, in Slack this is the Workspace ID, and in GitHub this is an organization ID. Some OAuth providers do not return tenant IDs, some providers are guaranteed to return one, and some may return multiple. This field will always be populated if at least one tenant ID was returned from the OAuth provider and developers should prefer this field over `provider_tenant_id`.
224
+ # The type of this field is list of +String+.
221
225
  # status_code::
222
226
  # The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.
223
227
  # The type of this field is +Integer+.
@@ -159,7 +159,7 @@ module StytchB2B
159
159
  #
160
160
  # The type of this field is nilable +String+.
161
161
  # allowed_oauth_tenants::
162
- # A map of allowed OAuth tenants. If this field is not passed in, the Organization will not allow JIT provisioning by OAuth Tenant. Allowed keys are "slack" and "hubspot".
162
+ # A map of allowed OAuth tenants. If this field is not passed in, the Organization will not allow JIT provisioning by OAuth Tenant. Allowed keys are "slack", "hubspot", and "github".
163
163
  # The type of this field is nilable +object+.
164
164
  #
165
165
  # == Returns:
@@ -385,7 +385,7 @@ module StytchB2B
385
385
  # If this field is provided and a session header is passed into the request, the Member Session must have permission to perform the `update.settings.oauth-tenant-jit-provisioning` action on the `stytch.organization` Resource.
386
386
  # The type of this field is nilable +String+.
387
387
  # allowed_oauth_tenants::
388
- # A map of allowed OAuth tenants. If this field is not passed in, the Organization will not allow JIT provisioning by OAuth Tenant. Allowed keys are "slack" and "hubspot".
388
+ # A map of allowed OAuth tenants. If this field is not passed in, the Organization will not allow JIT provisioning by OAuth Tenant. Allowed keys are "slack", "hubspot", and "github".
389
389
  #
390
390
  # If this field is provided and a session header is passed into the request, the Member Session must have permission to perform the `update.settings.allowed-oauth-tenants` action on the `stytch.organization` Resource.
391
391
  # The type of this field is nilable +object+.
@@ -1104,6 +1104,9 @@ module StytchB2B
1104
1104
  # member_id::
1105
1105
  # Globally unique UUID that identifies a specific Member. The `member_id` is critical to perform operations on a Member, so be sure to preserve this value.
1106
1106
  # The type of this field is +String+.
1107
+ # include_deleted::
1108
+ # Whether to include deleted Members in the response. Defaults to false.
1109
+ # The type of this field is nilable +Boolean+.
1107
1110
  #
1108
1111
  # == Returns:
1109
1112
  # An object with the following fields:
@@ -1123,14 +1126,43 @@ module StytchB2B
1123
1126
  # The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.
1124
1127
  # The type of this field is +Integer+.
1125
1128
  def dangerously_get(
1126
- member_id:
1129
+ member_id:,
1130
+ include_deleted: nil
1127
1131
  )
1128
1132
  headers = {}
1129
- query_params = {}
1133
+ query_params = {
1134
+ include_deleted: include_deleted
1135
+ }
1130
1136
  request = request_with_query_params("/v1/b2b/organizations/members/dangerously_get/#{member_id}", query_params)
1131
1137
  get_request(request, headers)
1132
1138
  end
1133
1139
 
1140
+ # Retrieve the saved OIDC access tokens and ID tokens for a member. After a successful OIDC login, Stytch will save the
1141
+ # issued access token and ID token from the identity provider. If a refresh token has been issued, Stytch will refresh the
1142
+ # access token automatically.
1143
+ #
1144
+ # == Parameters:
1145
+ # organization_id::
1146
+ # Globally unique UUID that identifies a specific Organization. The `organization_id` is critical to perform operations on an Organization, so be sure to preserve this value.
1147
+ # The type of this field is +String+.
1148
+ # member_id::
1149
+ # Globally unique UUID that identifies a specific Member. The `member_id` is critical to perform operations on a Member, so be sure to preserve this value.
1150
+ # The type of this field is +String+.
1151
+ # include_refresh_token::
1152
+ # Whether to return the refresh token Stytch has stored for the OAuth Provider. Defaults to false. **Important:** If your application exchanges the refresh token, Stytch may not be able to automatically refresh access tokens in the future.
1153
+ # The type of this field is nilable +Boolean+.
1154
+ #
1155
+ # == Returns:
1156
+ # An object with the following fields:
1157
+ # request_id::
1158
+ # Globally unique UUID that is returned with every API call. This value is important to log for debugging purposes; we may ask for this value to help identify a specific API call when helping you debug an issue.
1159
+ # The type of this field is +String+.
1160
+ # registrations::
1161
+ # A list of tokens the member is registered with.
1162
+ # The type of this field is list of +OIDCProviderInfo+ (+object+).
1163
+ # status_code::
1164
+ # The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.
1165
+ # The type of this field is +Integer+.
1134
1166
  def oidc_providers(
1135
1167
  organization_id:,
1136
1168
  member_id:,
@@ -1469,6 +1501,125 @@ module StytchB2B
1469
1501
  request = request_with_query_params("/v1/b2b/organizations/#{organization_id}/members/#{member_id}/oauth_providers/microsoft", query_params)
1470
1502
  get_request(request, headers)
1471
1503
  end
1504
+
1505
+ # Retrieve the saved Slack access token and ID token for a member. After a successful OAuth login, Stytch will save the
1506
+ # issued access token and ID token from the identity provider.
1507
+ #
1508
+ # == Parameters:
1509
+ # organization_id::
1510
+ # Globally unique UUID that identifies a specific Organization. The `organization_id` is critical to perform operations on an Organization, so be sure to preserve this value.
1511
+ # The type of this field is +String+.
1512
+ # member_id::
1513
+ # Globally unique UUID that identifies a specific Member. The `member_id` is critical to perform operations on a Member, so be sure to preserve this value.
1514
+ # The type of this field is +String+.
1515
+ #
1516
+ # == Returns:
1517
+ # An object with the following fields:
1518
+ # request_id::
1519
+ # Globally unique UUID that is returned with every API call. This value is important to log for debugging purposes; we may ask for this value to help identify a specific API call when helping you debug an issue.
1520
+ # The type of this field is +String+.
1521
+ # provider_type::
1522
+ # Denotes the OAuth identity provider that the user has authenticated with, e.g. Google, Microsoft, GitHub etc.
1523
+ # The type of this field is +String+.
1524
+ # registrations::
1525
+ # A list of tokens the member is registered with.
1526
+ # The type of this field is list of +SlackProviderInfo+ (+object+).
1527
+ # status_code::
1528
+ # The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.
1529
+ # The type of this field is +Integer+.
1530
+ def slack(
1531
+ organization_id:,
1532
+ member_id:
1533
+ )
1534
+ headers = {}
1535
+ query_params = {}
1536
+ request = request_with_query_params("/v1/b2b/organizations/#{organization_id}/members/#{member_id}/oauth_providers/slack", query_params)
1537
+ get_request(request, headers)
1538
+ end
1539
+
1540
+ # Retrieve the saved Hubspot access token and ID token for a member. After a successful OAuth login, Stytch will save the
1541
+ # issued access token and ID token from the identity provider. If a refresh token has been issued, Stytch will refresh the
1542
+ # access token automatically.
1543
+ #
1544
+ # == Parameters:
1545
+ # organization_id::
1546
+ # Globally unique UUID that identifies a specific Organization. The `organization_id` is critical to perform operations on an Organization, so be sure to preserve this value.
1547
+ # The type of this field is +String+.
1548
+ # member_id::
1549
+ # Globally unique UUID that identifies a specific Member. The `member_id` is critical to perform operations on a Member, so be sure to preserve this value.
1550
+ # The type of this field is +String+.
1551
+ # include_refresh_token::
1552
+ # Whether to return the refresh token Stytch has stored for the OAuth Provider. Defaults to false. **Important:** If your application exchanges the refresh token, Stytch may not be able to automatically refresh access tokens in the future.
1553
+ # The type of this field is nilable +Boolean+.
1554
+ #
1555
+ # == Returns:
1556
+ # An object with the following fields:
1557
+ # request_id::
1558
+ # Globally unique UUID that is returned with every API call. This value is important to log for debugging purposes; we may ask for this value to help identify a specific API call when helping you debug an issue.
1559
+ # The type of this field is +String+.
1560
+ # provider_type::
1561
+ # Denotes the OAuth identity provider that the user has authenticated with, e.g. Google, Microsoft, GitHub etc.
1562
+ # The type of this field is +String+.
1563
+ # registrations::
1564
+ # A list of tokens the member is registered with.
1565
+ # The type of this field is list of +HubspotProviderInfo+ (+object+).
1566
+ # status_code::
1567
+ # The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.
1568
+ # The type of this field is +Integer+.
1569
+ def hubspot(
1570
+ organization_id:,
1571
+ member_id:,
1572
+ include_refresh_token: nil
1573
+ )
1574
+ headers = {}
1575
+ query_params = {
1576
+ include_refresh_token: include_refresh_token
1577
+ }
1578
+ request = request_with_query_params("/v1/b2b/organizations/#{organization_id}/members/#{member_id}/oauth_providers/hubspot", query_params)
1579
+ get_request(request, headers)
1580
+ end
1581
+
1582
+ # Retrieve the saved GitHub access token for a Member. After a successful OAuth login, Stytch will save the
1583
+ # issued access token from the identity provider. GitHub does not issue refresh tokens, but will invalidate access
1584
+ # tokens after very long periods of inactivity.
1585
+ #
1586
+ # == Parameters:
1587
+ # organization_id::
1588
+ # Globally unique UUID that identifies a specific Organization. The `organization_id` is critical to perform operations on an Organization, so be sure to preserve this value.
1589
+ # The type of this field is +String+.
1590
+ # member_id::
1591
+ # Globally unique UUID that identifies a specific Member. The `member_id` is critical to perform operations on a Member, so be sure to preserve this value.
1592
+ # The type of this field is +String+.
1593
+ # include_refresh_token::
1594
+ # Whether to return the refresh token Stytch has stored for the OAuth Provider. Defaults to false. **Important:** If your application exchanges the refresh token, Stytch may not be able to automatically refresh access tokens in the future.
1595
+ # The type of this field is nilable +Boolean+.
1596
+ #
1597
+ # == Returns:
1598
+ # An object with the following fields:
1599
+ # request_id::
1600
+ # Globally unique UUID that is returned with every API call. This value is important to log for debugging purposes; we may ask for this value to help identify a specific API call when helping you debug an issue.
1601
+ # The type of this field is +String+.
1602
+ # provider_type::
1603
+ # Denotes the OAuth identity provider that the user has authenticated with, e.g. Google, Microsoft, GitHub etc.
1604
+ # The type of this field is +String+.
1605
+ # registrations::
1606
+ # A list of tokens the member is registered with.
1607
+ # The type of this field is list of +GithubProviderInfo+ (+object+).
1608
+ # status_code::
1609
+ # The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.
1610
+ # The type of this field is +Integer+.
1611
+ def github(
1612
+ organization_id:,
1613
+ member_id:,
1614
+ include_refresh_token: nil
1615
+ )
1616
+ headers = {}
1617
+ query_params = {
1618
+ include_refresh_token: include_refresh_token
1619
+ }
1620
+ request = request_with_query_params("/v1/b2b/organizations/#{organization_id}/members/#{member_id}/oauth_providers/github", query_params)
1621
+ get_request(request, headers)
1622
+ end
1472
1623
  end
1473
1624
  end
1474
1625
  end
@@ -33,7 +33,7 @@ module StytchB2B
33
33
  #
34
34
  # An error will be thrown if the Member already has a phone number and the provided `mfa_phone_number` does not match the existing one.
35
35
  #
36
- # Note that sending another OTP code before the first has expired will invalidate the first code.
36
+ # OTP codes expire after two minutes. Note that sending another OTP code before the first has expired will invalidate the first code.
37
37
  #
38
38
  # If a Member has a phone number and is enrolled in MFA, then after a successful primary authentication event (e.g. [email magic link](https://stytch.com/docs/b2b/api/authenticate-magic-link) or [SSO](https://stytch.com/docs/b2b/api/sso-authenticate) login is complete), an SMS OTP will automatically be sent to their phone number. In that case, this endpoint should only be used for subsequent authentication events, such as prompting a Member for an OTP again after a period of inactivity.
39
39
  #
@@ -116,7 +116,9 @@ module StytchB2B
116
116
 
117
117
  # SMS OTPs may not be used as a primary authentication mechanism. They can be used to complete an MFA requirement, or they can be used as a step-up factor to be added to an existing session.
118
118
  #
119
- # This endpoint verifies that the one-time passcode (OTP) is valid and hasn't expired or been previously used. A given Member may only have a single active OTP code at any given time. If a Member requests another OTP code before the first one has expired, the first one will be invalidated.
119
+ # This endpoint verifies that the one-time passcode (OTP) is valid and hasn't expired or been previously used. OTP codes expire after two minutes.
120
+ #
121
+ # A given Member may only have a single active OTP code at any given time. If a Member requests another OTP code before the first one has expired, the first one will be invalidated.
120
122
  #
121
123
  # Exactly one of `intermediate_session_token`, `session_token`, or `session_jwt` must be provided in the request.
122
124
  # If an intermediate session token is provided, this operation will consume it.
@@ -11,7 +11,7 @@ require_relative 'request_helper'
11
11
  module StytchB2B
12
12
  class Passwords
13
13
  include Stytch::RequestHelper
14
- attr_reader :email, :sessions, :existing_password
14
+ attr_reader :email, :sessions, :existing_password, :discovery
15
15
 
16
16
  def initialize(connection)
17
17
  @connection = connection
@@ -19,6 +19,7 @@ module StytchB2B
19
19
  @email = StytchB2B::Passwords::Email.new(@connection)
20
20
  @sessions = StytchB2B::Passwords::Sessions.new(@connection)
21
21
  @existing_password = StytchB2B::Passwords::ExistingPassword.new(@connection)
22
+ @discovery = StytchB2B::Passwords::Discovery.new(@connection)
22
23
  end
23
24
 
24
25
  # This API allows you to check whether the user’s provided password is valid, and to provide feedback to the user on how to increase the strength of their password.
@@ -327,6 +328,25 @@ module StytchB2B
327
328
  end
328
329
 
329
330
  class Email
331
+ class RequireResetRequestOptions
332
+ # Optional authorization object.
333
+ # Pass in an active Stytch Member session token or session JWT and the request
334
+ # will be run using that member's permissions.
335
+ attr_accessor :authorization
336
+
337
+ def initialize(
338
+ authorization: nil
339
+ )
340
+ @authorization = authorization
341
+ end
342
+
343
+ def to_headers
344
+ headers = {}
345
+ headers.merge!(@authorization.to_headers) if authorization
346
+ headers
347
+ end
348
+ end
349
+
330
350
  include Stytch::RequestHelper
331
351
 
332
352
  def initialize(connection)
@@ -551,19 +571,51 @@ module StytchB2B
551
571
  post_request('/v1/b2b/passwords/email/reset', request, headers)
552
572
  end
553
573
 
554
- def delete(
574
+ # Require a password be reset by the associated email address. This endpoint is only functional for cross-org password use cases.
575
+ #
576
+ # == Parameters:
577
+ # email_address::
578
+ # The email address of the Member to start the email reset process for.
579
+ # The type of this field is +String+.
580
+ # organization_id::
581
+ # Globally unique UUID that identifies a specific Organization. The `organization_id` is critical to perform operations on an Organization, so be sure to preserve this value.
582
+ # The type of this field is nilable +String+.
583
+ # member_id::
584
+ # Globally unique UUID that identifies a specific Member. The `member_id` is critical to perform operations on a Member, so be sure to preserve this value.
585
+ # The type of this field is nilable +String+.
586
+ #
587
+ # == Returns:
588
+ # An object with the following fields:
589
+ # member::
590
+ # The [Member object](https://stytch.com/docs/b2b/api/member-object)
591
+ # The type of this field is +Member+ (+object+).
592
+ # organization::
593
+ # The [Organization object](https://stytch.com/docs/b2b/api/organization-object).
594
+ # The type of this field is +Organization+ (+object+).
595
+ # status_code::
596
+ # The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.
597
+ # The type of this field is +Integer+.
598
+ # member_id::
599
+ # Globally unique UUID that identifies a specific Member.
600
+ # The type of this field is nilable +String+.
601
+ #
602
+ # == Method Options:
603
+ # This method supports an optional +StytchB2B::Passwords::Email::RequireResetRequestOptions+ object which will modify the headers sent in the HTTP request.
604
+ def require_reset(
555
605
  email_address:,
556
606
  organization_id: nil,
557
- member_id: nil
607
+ member_id: nil,
608
+ method_options: nil
558
609
  )
559
610
  headers = {}
611
+ headers = headers.merge(method_options.to_headers) unless method_options.nil?
560
612
  request = {
561
613
  email_address: email_address
562
614
  }
563
615
  request[:organization_id] = organization_id unless organization_id.nil?
564
616
  request[:member_id] = member_id unless member_id.nil?
565
617
 
566
- post_request('/v1/b2b/passwords/email/delete', request, headers)
618
+ post_request('/v1/b2b/passwords/email/require_reset', request, headers)
567
619
  end
568
620
  end
569
621
 
@@ -810,5 +862,199 @@ module StytchB2B
810
862
  post_request('/v1/b2b/passwords/existing_password/reset', request, headers)
811
863
  end
812
864
  end
865
+
866
+ class Discovery
867
+ include Stytch::RequestHelper
868
+ attr_reader :email
869
+
870
+ def initialize(connection)
871
+ @connection = connection
872
+
873
+ @email = StytchB2B::Passwords::Discovery::Email.new(@connection)
874
+ end
875
+
876
+ # Authenticate an email/password combination in the discovery flow. This authenticate flow is only valid for cross-org passwords use cases, and is not tied to a specific organization.
877
+ #
878
+ # If you have breach detection during authentication enabled in your [password strength policy](https://stytch.com/docs/b2b/guides/passwords/strength-policies) and the member's credentials have appeared in the HaveIBeenPwned dataset, this endpoint will return a `member_reset_password` error even if the member enters a correct password. We force a password reset in this case to ensure that the member is the legitimate owner of the email address and not a malicious actor abusing the compromised credentials.
879
+ #
880
+ # If successful, this endpoint will create a new intermediate session and return a list of discovered organizations that can be session exchanged into.
881
+ #
882
+ # == Parameters:
883
+ # email_address::
884
+ # The email address of the Member.
885
+ # The type of this field is +String+.
886
+ # password::
887
+ # The password to authenticate, reset, or set for the first time. Any UTF8 character is allowed, e.g. spaces, emojis, non-English characers, etc.
888
+ # The type of this field is +String+.
889
+ #
890
+ # == Returns:
891
+ # An object with the following fields:
892
+ # request_id::
893
+ # Globally unique UUID that is returned with every API call. This value is important to log for debugging purposes; we may ask for this value to help identify a specific API call when helping you debug an issue.
894
+ # The type of this field is +String+.
895
+ # email_address::
896
+ # The email address.
897
+ # The type of this field is +String+.
898
+ # intermediate_session_token::
899
+ # The returned Intermediate Session Token contains a password factor associated with the Member. If this value is non-empty, the member must complete an MFA step to finish logging in to the Organization. The token can be used with the [OTP SMS Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-otp-sms), [TOTP Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-totp), or [Recovery Codes Recover endpoint](https://stytch.com/docs/b2b/api/recovery-codes-recover) to complete an MFA flow and log in to the Organization. Password factors are not transferable between Organizations, so the intermediate session token is not valid for use with discovery endpoints.
900
+ # The type of this field is +String+.
901
+ # discovered_organizations::
902
+ # An array of `discovered_organization` objects tied to the `intermediate_session_token`, `session_token`, or `session_jwt`. See the [Discovered Organization Object](https://stytch.com/docs/b2b/api/discovered-organization-object) for complete details.
903
+ #
904
+ # Note that Organizations will only appear here under any of the following conditions:
905
+ # 1. The end user is already a Member of the Organization.
906
+ # 2. The end user is invited to the Organization.
907
+ # 3. The end user can join the Organization because:
908
+ #
909
+ # a) The Organization allows JIT provisioning.
910
+ #
911
+ # b) The Organizations' allowed domains list contains the Member's email domain.
912
+ #
913
+ # c) The Organization has at least one other Member with a verified email address with the same domain as the end user (to prevent phishing attacks).
914
+ # The type of this field is list of +DiscoveredOrganization+ (+object+).
915
+ # status_code::
916
+ # The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.
917
+ # The type of this field is +Integer+.
918
+ def authenticate(
919
+ email_address:,
920
+ password:
921
+ )
922
+ headers = {}
923
+ request = {
924
+ email_address: email_address,
925
+ password: password
926
+ }
927
+
928
+ post_request('/v1/b2b/passwords/discovery/authenticate', request, headers)
929
+ end
930
+
931
+ class Email
932
+ include Stytch::RequestHelper
933
+
934
+ def initialize(connection)
935
+ @connection = connection
936
+ end
937
+
938
+ # Initiates a password reset for the email address provided, when cross-org passwords are enabled. This will trigger an email to be sent to the address, containing a magic link that will allow them to set a new password and authenticate.
939
+ #
940
+ # This endpoint adapts to your Project's password strength configuration.
941
+ # If you're using [zxcvbn](https://stytch.com/docs/guides/passwords/strength-policy), the default, your passwords are considered valid
942
+ # if the strength score is >= 3. If you're using [LUDS](https://stytch.com/docs/guides/passwords/strength-policy), your passwords are
943
+ # considered valid if they meet the requirements that you've set with Stytch.
944
+ # You may update your password strength configuration in the [stytch dashboard](https://stytch.com/dashboard/password-strength-config).
945
+ #
946
+ # == Parameters:
947
+ # email_address::
948
+ # The email address of the Member to start the email reset process for.
949
+ # The type of this field is +String+.
950
+ # reset_password_redirect_url::
951
+ # The URL that the Member clicks from the reset password link. This URL should be an endpoint in the backend server that verifies the request by querying
952
+ # Stytch's authenticate endpoint and finishes the reset password flow. If this value is not passed, the default `reset_password_redirect_url` that you set in your Dashboard is used.
953
+ # If you have not set a default `reset_password_redirect_url`, an error is returned.
954
+ # The type of this field is nilable +String+.
955
+ # discovery_redirect_url::
956
+ # The URL that the end user clicks from the discovery Magic Link. This URL should be an endpoint in the backend server that
957
+ # verifies the request by querying Stytch's discovery authenticate endpoint and continues the flow. If this value is not passed, the default
958
+ # discovery redirect URL that you set in your Dashboard is used. If you have not set a default discovery redirect URL, an error is returned.
959
+ # The type of this field is nilable +String+.
960
+ # reset_password_template_id::
961
+ # Use a custom template for reset password emails. By default, it will use your default email template. The template must be a template using our built-in customizations or a custom HTML email for Magic Links - Reset Password.
962
+ # The type of this field is nilable +String+.
963
+ # reset_password_expiration_minutes::
964
+ # Sets a time limit after which the email link to reset the member's password will no longer be valid.
965
+ # The type of this field is nilable +Integer+.
966
+ # pkce_code_challenge::
967
+ # (no documentation yet)
968
+ # The type of this field is nilable +String+.
969
+ # locale::
970
+ # Used to determine which language to use when sending the user this delivery method. Parameter is a [IETF BCP 47 language tag](https://www.w3.org/International/articles/language-tags/), e.g. `"en"`.
971
+ #
972
+ # Currently supported languages are English (`"en"`), Spanish (`"es"`), and Brazilian Portuguese (`"pt-br"`); if no value is provided, the copy defaults to English.
973
+ #
974
+ # Request support for additional languages [here](https://docs.google.com/forms/d/e/1FAIpQLScZSpAu_m2AmLXRT3F3kap-s_mcV6UTBitYn6CdyWP0-o7YjQ/viewform?usp=sf_link")!
975
+ #
976
+ # The type of this field is nilable +String+.
977
+ #
978
+ # == Returns:
979
+ # An object with the following fields:
980
+ # request_id::
981
+ # Globally unique UUID that is returned with every API call. This value is important to log for debugging purposes; we may ask for this value to help identify a specific API call when helping you debug an issue.
982
+ # The type of this field is +String+.
983
+ # status_code::
984
+ # The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.
985
+ # The type of this field is +Integer+.
986
+ def reset_start(
987
+ email_address:,
988
+ reset_password_redirect_url: nil,
989
+ discovery_redirect_url: nil,
990
+ reset_password_template_id: nil,
991
+ reset_password_expiration_minutes: nil,
992
+ pkce_code_challenge: nil,
993
+ locale: nil
994
+ )
995
+ headers = {}
996
+ request = {
997
+ email_address: email_address
998
+ }
999
+ request[:reset_password_redirect_url] = reset_password_redirect_url unless reset_password_redirect_url.nil?
1000
+ request[:discovery_redirect_url] = discovery_redirect_url unless discovery_redirect_url.nil?
1001
+ request[:reset_password_template_id] = reset_password_template_id unless reset_password_template_id.nil?
1002
+ request[:reset_password_expiration_minutes] = reset_password_expiration_minutes unless reset_password_expiration_minutes.nil?
1003
+ request[:pkce_code_challenge] = pkce_code_challenge unless pkce_code_challenge.nil?
1004
+ request[:locale] = locale unless locale.nil?
1005
+
1006
+ post_request('/v1/b2b/passwords/discovery/email/reset/start', request, headers)
1007
+ end
1008
+
1009
+ # Reset the password associated with an email and start an intermediate session. This endpoint checks that the password reset token is valid, hasn’t expired, or already been used.
1010
+ #
1011
+ # The provided password needs to meet the project's password strength requirements, which can be checked in advance with the password strength endpoint. If the token and password are accepted, the password is securely stored for future authentication and the user is authenticated.
1012
+ #
1013
+ # Resetting a password will start an intermediate session and return a list of discovered organizations the session can be exchanged into.
1014
+ #
1015
+ # == Parameters:
1016
+ # password_reset_token::
1017
+ # The password reset token to authenticate.
1018
+ # The type of this field is +String+.
1019
+ # password::
1020
+ # The password to authenticate, reset, or set for the first time. Any UTF8 character is allowed, e.g. spaces, emojis, non-English characers, etc.
1021
+ # The type of this field is +String+.
1022
+ # pkce_code_verifier::
1023
+ # (no documentation yet)
1024
+ # The type of this field is nilable +String+.
1025
+ #
1026
+ # == Returns:
1027
+ # An object with the following fields:
1028
+ # request_id::
1029
+ # Globally unique UUID that is returned with every API call. This value is important to log for debugging purposes; we may ask for this value to help identify a specific API call when helping you debug an issue.
1030
+ # The type of this field is +String+.
1031
+ # intermediate_session_token::
1032
+ # The returned Intermediate Session Token contains a password factor associated with the Member. If this value is non-empty, the member must complete an MFA step to finish logging in to the Organization. The token can be used with the [OTP SMS Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-otp-sms), [TOTP Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-totp), or [Recovery Codes Recover endpoint](https://stytch.com/docs/b2b/api/recovery-codes-recover) to complete an MFA flow and log in to the Organization. Password factors are not transferable between Organizations, so the intermediate session token is not valid for use with discovery endpoints.
1033
+ # The type of this field is +String+.
1034
+ # email_address::
1035
+ # (no documentation yet)
1036
+ # The type of this field is +String+.
1037
+ # discovered_organizations::
1038
+ # (no documentation yet)
1039
+ # The type of this field is list of +DiscoveredOrganization+ (+object+).
1040
+ # status_code::
1041
+ # The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.
1042
+ # The type of this field is +Integer+.
1043
+ def reset(
1044
+ password_reset_token:,
1045
+ password:,
1046
+ pkce_code_verifier: nil
1047
+ )
1048
+ headers = {}
1049
+ request = {
1050
+ password_reset_token: password_reset_token,
1051
+ password: password
1052
+ }
1053
+ request[:pkce_code_verifier] = pkce_code_verifier unless pkce_code_verifier.nil?
1054
+
1055
+ post_request('/v1/b2b/passwords/discovery/email/reset', request, headers)
1056
+ end
1057
+ end
1058
+ end
813
1059
  end
814
1060
  end
@@ -49,13 +49,14 @@ module StytchB2B
49
49
  end
50
50
 
51
51
  include Stytch::RequestHelper
52
- attr_reader :oidc, :saml
52
+ attr_reader :oidc, :saml, :external
53
53
 
54
54
  def initialize(connection)
55
55
  @connection = connection
56
56
 
57
57
  @oidc = StytchB2B::SSO::OIDC.new(@connection)
58
58
  @saml = StytchB2B::SSO::SAML.new(@connection)
59
+ @external = StytchB2B::SSO::External.new(@connection)
59
60
  end
60
61
 
61
62
  # Get all SSO Connections owned by the organization.
@@ -77,7 +78,7 @@ module StytchB2B
77
78
  # The list of [OIDC Connections](https://stytch.com/docs/b2b/api/oidc-connection-object) owned by this organization.
78
79
  # The type of this field is list of +OIDCConnection+ (+object+).
79
80
  # external_connections::
80
- # (no documentation yet)
81
+ # The list of [External Connections](https://stytch.com/docs/b2b/api/external-connection-object) owned by this organization.
81
82
  # The type of this field is list of +Connection+ (+object+).
82
83
  # status_code::
83
84
  # The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.
@@ -103,7 +104,7 @@ module StytchB2B
103
104
  # The organization ID that the SSO connection belongs to.
104
105
  # The type of this field is +String+.
105
106
  # connection_id::
106
- # The ID of the SSO connection. Both SAML and OIDC connection IDs can be provided.
107
+ # The ID of the SSO connection. SAML, OIDC, and External connection IDs can be provided.
107
108
  # The type of this field is +String+.
108
109
  #
109
110
  # == Returns:
@@ -616,8 +617,7 @@ module StytchB2B
616
617
  # Defines the names of the SAML groups
617
618
  # that grant specific role assignments. For each group-Role pair, if a Member logs in with this SAML connection and
618
619
  # belongs to the specified SAML group, they will be granted the associated Role. See the
619
- # [RBAC guide](https://stytch.com/docs/b2b/guides/rbac/role-assignment) for more information about role assignment.
620
- # Before adding any group implicit role assignments, you must add a "groups" key to your SAML connection's
620
+ # [RBAC guide](https://stytch.com/docs/b2b/guides/rbac/role-assignment) for more information about role assignment. Before adding any group implicit role assignments, you must add a "groups" key to your SAML connection's
621
621
  # `attribute_mapping`. Make sure that your IdP is configured to correctly send the group information.
622
622
  # The type of this field is nilable list of +SAMLGroupImplicitRoleAssignment+.
623
623
  # alternative_audience_uri::
@@ -759,5 +759,165 @@ module StytchB2B
759
759
  delete_request("/v1/b2b/sso/saml/#{organization_id}/connections/#{connection_id}/verification_certificates/#{certificate_id}", headers)
760
760
  end
761
761
  end
762
+
763
+ class External
764
+ class CreateConnectionRequestOptions
765
+ # Optional authorization object.
766
+ # Pass in an active Stytch Member session token or session JWT and the request
767
+ # will be run using that member's permissions.
768
+ attr_accessor :authorization
769
+
770
+ def initialize(
771
+ authorization: nil
772
+ )
773
+ @authorization = authorization
774
+ end
775
+
776
+ def to_headers
777
+ headers = {}
778
+ headers.merge!(@authorization.to_headers) if authorization
779
+ headers
780
+ end
781
+ end
782
+
783
+ class UpdateConnectionRequestOptions
784
+ # Optional authorization object.
785
+ # Pass in an active Stytch Member session token or session JWT and the request
786
+ # will be run using that member's permissions.
787
+ attr_accessor :authorization
788
+
789
+ def initialize(
790
+ authorization: nil
791
+ )
792
+ @authorization = authorization
793
+ end
794
+
795
+ def to_headers
796
+ headers = {}
797
+ headers.merge!(@authorization.to_headers) if authorization
798
+ headers
799
+ end
800
+ end
801
+
802
+ include Stytch::RequestHelper
803
+
804
+ def initialize(connection)
805
+ @connection = connection
806
+ end
807
+
808
+ # Create a new External SSO Connection.
809
+ #
810
+ # == Parameters:
811
+ # organization_id::
812
+ # Globally unique UUID that identifies a specific Organization. The `organization_id` is critical to perform operations on an Organization, so be sure to preserve this value.
813
+ # The type of this field is +String+.
814
+ # external_organization_id::
815
+ # Globally unique UUID that identifies a different Organization within your Project.
816
+ # The type of this field is +String+.
817
+ # external_connection_id::
818
+ # Globally unique UUID that identifies a specific SSO connection configured for a different Organization in your Project.
819
+ # The type of this field is +String+.
820
+ # display_name::
821
+ # A human-readable display name for the connection.
822
+ # The type of this field is nilable +String+.
823
+ # connection_implicit_role_assignments::
824
+ # (no documentation yet)
825
+ # The type of this field is nilable list of +SAMLConnectionImplicitRoleAssignment+.
826
+ # group_implicit_role_assignments::
827
+ # (no documentation yet)
828
+ # The type of this field is nilable list of +SAMLGroupImplicitRoleAssignment+.
829
+ #
830
+ # == Returns:
831
+ # An object with the following fields:
832
+ # request_id::
833
+ # Globally unique UUID that is returned with every API call. This value is important to log for debugging purposes; we may ask for this value to help identify a specific API call when helping you debug an issue.
834
+ # The type of this field is +String+.
835
+ # status_code::
836
+ # The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.
837
+ # The type of this field is +Integer+.
838
+ # connection::
839
+ # The `External Connection` object affected by this API call. See the [External Connection Object](https://stytch.com/docs/b2b/api/external-connection-object) for complete response field details.
840
+ # The type of this field is nilable +Connection+ (+object+).
841
+ #
842
+ # == Method Options:
843
+ # This method supports an optional +StytchB2B::SSO::External::CreateConnectionRequestOptions+ object which will modify the headers sent in the HTTP request.
844
+ def create_connection(
845
+ organization_id:,
846
+ external_organization_id:,
847
+ external_connection_id:,
848
+ display_name: nil,
849
+ connection_implicit_role_assignments: nil,
850
+ group_implicit_role_assignments: nil,
851
+ method_options: nil
852
+ )
853
+ headers = {}
854
+ headers = headers.merge(method_options.to_headers) unless method_options.nil?
855
+ request = {
856
+ external_organization_id: external_organization_id,
857
+ external_connection_id: external_connection_id
858
+ }
859
+ request[:display_name] = display_name unless display_name.nil?
860
+ request[:connection_implicit_role_assignments] = connection_implicit_role_assignments unless connection_implicit_role_assignments.nil?
861
+ request[:group_implicit_role_assignments] = group_implicit_role_assignments unless group_implicit_role_assignments.nil?
862
+
863
+ post_request("/v1/b2b/sso/external/#{organization_id}", request, headers)
864
+ end
865
+
866
+ # Updates an existing External SSO connection.
867
+ #
868
+ # == Parameters:
869
+ # organization_id::
870
+ # Globally unique UUID that identifies a specific Organization. The `organization_id` is critical to perform operations on an Organization, so be sure to preserve this value.
871
+ # The type of this field is +String+.
872
+ # connection_id::
873
+ # Globally unique UUID that identifies a specific External SSO Connection.
874
+ # The type of this field is +String+.
875
+ # display_name::
876
+ # A human-readable display name for the connection.
877
+ # The type of this field is nilable +String+.
878
+ # external_connection_implicit_role_assignments::
879
+ # All Members who log in with this External connection will implicitly receive the specified Roles. See the [RBAC guide](https://stytch.com/docs/b2b/guides/rbac/role-assignment) for more information about role assignment. Implicit role assignments are not supported for External connections if the underlying SSO connection is an OIDC connection.
880
+ # The type of this field is nilable list of +ConnectionImplicitRoleAssignment+.
881
+ # external_group_implicit_role_assignments::
882
+ # Defines the names of the groups
883
+ # that grant specific role assignments. For each group-Role pair, if a Member logs in with this external connection and
884
+ # belongs to the specified group, they will be granted the associated Role. See the
885
+ # [RBAC guide](https://stytch.com/docs/b2b/guides/rbac/role-assignment) for more information about role assignment. Before adding any group implicit role assignments to an external connection, you must add a "groups" key to the underlying SAML connection's
886
+ # `attribute_mapping`. Make sure that the SAML connection IdP is configured to correctly send the group information. Implicit role assignments are not supported
887
+ # for External connections if the underlying SSO connection is an OIDC connection.
888
+ # The type of this field is nilable list of +GroupImplicitRoleAssignment+.
889
+ #
890
+ # == Returns:
891
+ # An object with the following fields:
892
+ # request_id::
893
+ # Globally unique UUID that is returned with every API call. This value is important to log for debugging purposes; we may ask for this value to help identify a specific API call when helping you debug an issue.
894
+ # The type of this field is +String+.
895
+ # status_code::
896
+ # The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.
897
+ # The type of this field is +Integer+.
898
+ # connection::
899
+ # The `External Connection` object affected by this API call. See the [External Connection Object](https://stytch.com/docs/b2b/api/external-connection-object) for complete response field details.
900
+ # The type of this field is nilable +Connection+ (+object+).
901
+ #
902
+ # == Method Options:
903
+ # This method supports an optional +StytchB2B::SSO::External::UpdateConnectionRequestOptions+ object which will modify the headers sent in the HTTP request.
904
+ def update_connection(
905
+ organization_id:,
906
+ connection_id:,
907
+ display_name: nil,
908
+ external_connection_implicit_role_assignments: nil,
909
+ external_group_implicit_role_assignments: nil,
910
+ method_options: nil
911
+ )
912
+ headers = {}
913
+ headers = headers.merge(method_options.to_headers) unless method_options.nil?
914
+ request = {}
915
+ request[:display_name] = display_name unless display_name.nil?
916
+ request[:external_connection_implicit_role_assignments] = external_connection_implicit_role_assignments unless external_connection_implicit_role_assignments.nil?
917
+ request[:external_group_implicit_role_assignments] = external_group_implicit_role_assignments unless external_group_implicit_role_assignments.nil?
918
+
919
+ put_request("/v1/b2b/sso/external/#{organization_id}/connections/#{connection_id}", request, headers)
920
+ end
921
+ end
762
922
  end
763
923
  end
@@ -160,7 +160,7 @@ module Stytch
160
160
  #
161
161
  # == Parameters:
162
162
  # session_token::
163
- # The `session_token` associated with a User's existing Session.
163
+ # The authorization token Stytch will pass in to the external userinfo endpoint.
164
164
  # The type of this field is +String+.
165
165
  # session_duration_minutes::
166
166
  # Set the session lifetime to be this many minutes from now. This will start a new session if one doesn't already exist,
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Stytch
4
- VERSION = '9.7.0'
4
+ VERSION = '9.9.0'
5
5
  end
@@ -41,6 +41,15 @@ module Stytch
41
41
  # If true, the `public_key_credential_creation_options` returned will be optimized for Passkeys with `residentKey` set to `"required"` and `userVerification` set to `"preferred"`.
42
42
  #
43
43
  # The type of this field is nilable +Boolean+.
44
+ # override_id::
45
+ # (no documentation yet)
46
+ # The type of this field is nilable +String+.
47
+ # override_name::
48
+ # (no documentation yet)
49
+ # The type of this field is nilable +String+.
50
+ # override_display_name::
51
+ # (no documentation yet)
52
+ # The type of this field is nilable +String+.
44
53
  #
45
54
  # == Returns:
46
55
  # An object with the following fields:
@@ -61,7 +70,10 @@ module Stytch
61
70
  domain:,
62
71
  user_agent: nil,
63
72
  authenticator_type: nil,
64
- return_passkey_credential_options: nil
73
+ return_passkey_credential_options: nil,
74
+ override_id: nil,
75
+ override_name: nil,
76
+ override_display_name: nil
65
77
  )
66
78
  headers = {}
67
79
  request = {
@@ -71,6 +83,9 @@ module Stytch
71
83
  request[:user_agent] = user_agent unless user_agent.nil?
72
84
  request[:authenticator_type] = authenticator_type unless authenticator_type.nil?
73
85
  request[:return_passkey_credential_options] = return_passkey_credential_options unless return_passkey_credential_options.nil?
86
+ request[:override_id] = override_id unless override_id.nil?
87
+ request[:override_name] = override_name unless override_name.nil?
88
+ request[:override_display_name] = override_display_name unless override_display_name.nil?
74
89
 
75
90
  post_request('/v1/webauthn/register/start', request, headers)
76
91
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stytch
3
3
  version: !ruby/object:Gem::Version
4
- version: 9.7.0
4
+ version: 9.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - stytch
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-10-09 00:00:00.000000000 Z
11
+ date: 2024-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday