stytch 5.0.2 → 6.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # !!!
4
+ # WARNING: This file is autogenerated
5
+ # Only modify code within MANUAL() sections
6
+ # or your changes may be overwritten later!
7
+ # !!!
8
+
3
9
  require_relative 'request_helper'
4
10
 
5
11
  module StytchB2B
@@ -10,6 +16,27 @@ module StytchB2B
10
16
  @connection = connection
11
17
  end
12
18
 
19
+ # Retrieves all active Sessions for a Member.
20
+ #
21
+ # == Parameters:
22
+ # organization_id::
23
+ # 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.
24
+ # The type of this field is +String+.
25
+ # member_id::
26
+ # 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.
27
+ # The type of this field is +String+.
28
+ #
29
+ # == Returns:
30
+ # An object with the following fields:
31
+ # request_id::
32
+ # 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.
33
+ # The type of this field is +String+.
34
+ # member_sessions::
35
+ # An array of [Session objects](https://stytch.com/docs/b2b/api/session-object).
36
+ # The type of this field is list of +MemberSession+ (+object+).
37
+ # status_code::
38
+ # 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.
39
+ # The type of this field is +Integer+.
13
40
  def get(
14
41
  organization_id:,
15
42
  member_id:
@@ -22,6 +49,59 @@ module StytchB2B
22
49
  get_request(request)
23
50
  end
24
51
 
52
+ # Authenticates a Session and updates its lifetime by the specified `session_duration_minutes`. If the `session_duration_minutes` is not specified, a Session will not be extended. This endpoint requires either a `session_jwt` or `session_token` be included in the request. It will return an error if both are present.
53
+ #
54
+ # You may provide a JWT that needs to be refreshed and is expired according to its `exp` claim. A new JWT will be returned if both the signature and the underlying Session are still valid.
55
+ #
56
+ # == Parameters:
57
+ # session_token::
58
+ # A secret token for a given Stytch Session.
59
+ # The type of this field is nilable +String+.
60
+ # session_duration_minutes::
61
+ # Set the session lifetime to be this many minutes from now. This will start a new session if one doesn't already exist,
62
+ # returning both an opaque `session_token` and `session_jwt` for this session. Remember that the `session_jwt` will have a fixed lifetime of
63
+ # five minutes regardless of the underlying session duration, and will need to be refreshed over time.
64
+ #
65
+ # This value must be a minimum of 5 and a maximum of 527040 minutes (366 days).
66
+ #
67
+ # If a `session_token` or `session_jwt` is provided then a successful authentication will continue to extend the session this many minutes.
68
+ #
69
+ # If the `session_duration_minutes` parameter is not specified, a Stytch session will be created with a 60 minute duration. If you don't want
70
+ # to use the Stytch session product, you can ignore the session fields in the response.
71
+ # The type of this field is nilable +Integer+.
72
+ # session_jwt::
73
+ # The JSON Web Token (JWT) for a given Stytch Session.
74
+ # The type of this field is nilable +String+.
75
+ # session_custom_claims::
76
+ # Add a custom claims map to the Session being authenticated. Claims are only created if a Session is initialized by providing a value in
77
+ # `session_duration_minutes`. Claims will be included on the Session object and in the JWT. To update a key in an existing Session, supply a new value. To
78
+ # delete a key, supply a null value. Custom claims made with reserved claims (`iss`, `sub`, `aud`, `exp`, `nbf`, `iat`, `jti`) will be ignored.
79
+ # Total custom claims size cannot exceed four kilobytes.
80
+ # The type of this field is nilable +object+.
81
+ #
82
+ # == Returns:
83
+ # An object with the following fields:
84
+ # request_id::
85
+ # 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.
86
+ # The type of this field is +String+.
87
+ # member_session::
88
+ # The [Session object](https://stytch.com/docs/b2b/api/session-object).
89
+ # The type of this field is +MemberSession+ (+object+).
90
+ # session_token::
91
+ # A secret token for a given Stytch Session.
92
+ # The type of this field is +String+.
93
+ # session_jwt::
94
+ # The JSON Web Token (JWT) for a given Stytch Session.
95
+ # The type of this field is +String+.
96
+ # member::
97
+ # The [Member object](https://stytch.com/docs/b2b/api/member-object).
98
+ # The type of this field is +Member+ (+object+).
99
+ # organization::
100
+ # The [Organization object](https://stytch.com/docs/b2b/api/organization-object).
101
+ # The type of this field is +Organization+ (+object+).
102
+ # status_code::
103
+ # 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.
104
+ # The type of this field is +Integer+.
25
105
  def authenticate(
26
106
  session_token: nil,
27
107
  session_duration_minutes: nil,
@@ -37,6 +117,30 @@ module StytchB2B
37
117
  post_request('/v1/b2b/sessions/authenticate', request)
38
118
  end
39
119
 
120
+ # Revoke a Session and immediately invalidate all its tokens. To revoke a specific Session, pass either the `member_session_id`, `session_token`, or `session_jwt`. To revoke all Sessions for a Member, pass the `member_id`.
121
+ #
122
+ # == Parameters:
123
+ # member_session_id::
124
+ # Globally unique UUID that identifies a specific Session in the Stytch API. The `member_session_id` is critical to perform operations on an Session, so be sure to preserve this value.
125
+ # The type of this field is nilable +String+.
126
+ # session_token::
127
+ # A secret token for a given Stytch Session.
128
+ # The type of this field is nilable +String+.
129
+ # session_jwt::
130
+ # The JSON Web Token (JWT) for a given Stytch Session.
131
+ # The type of this field is nilable +String+.
132
+ # member_id::
133
+ # 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.
134
+ # The type of this field is nilable +String+.
135
+ #
136
+ # == Returns:
137
+ # An object with the following fields:
138
+ # request_id::
139
+ # 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.
140
+ # The type of this field is +String+.
141
+ # status_code::
142
+ # 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.
143
+ # The type of this field is +Integer+.
40
144
  def revoke(
41
145
  member_session_id: nil,
42
146
  session_token: nil,
@@ -52,6 +156,65 @@ module StytchB2B
52
156
  post_request('/v1/b2b/sessions/revoke', request)
53
157
  end
54
158
 
159
+ # Use this endpoint to exchange a Member's existing session for another session in a different Organization. This can be used to accept an invite, but not to create a new member via domain matching.
160
+ #
161
+ # To create a new member via domain matching, use the [Exchange Intermediate Session](https://stytch.com/docs/b2b/api/exchange-intermediate-session) flow instead.
162
+ #
163
+ # == Parameters:
164
+ # organization_id::
165
+ # 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.
166
+ # The type of this field is +String+.
167
+ # session_token::
168
+ # The `session_token` belonging to the member that you wish to associate the email with.
169
+ # The type of this field is nilable +String+.
170
+ # session_jwt::
171
+ # The `session_jwt` belonging to the member that you wish to associate the email with.
172
+ # The type of this field is nilable +String+.
173
+ # session_duration_minutes::
174
+ # Set the session lifetime to be this many minutes from now. This will start a new session if one doesn't already exist,
175
+ # returning both an opaque `session_token` and `session_jwt` for this session. Remember that the `session_jwt` will have a fixed lifetime of
176
+ # five minutes regardless of the underlying session duration, and will need to be refreshed over time.
177
+ #
178
+ # This value must be a minimum of 5 and a maximum of 527040 minutes (366 days).
179
+ #
180
+ # If a `session_token` or `session_jwt` is provided then a successful authentication will continue to extend the session this many minutes.
181
+ #
182
+ # If the `session_duration_minutes` parameter is not specified, a Stytch session will be created with a 60 minute duration. If you don't want
183
+ # to use the Stytch session product, you can ignore the session fields in the response.
184
+ # The type of this field is nilable +Integer+.
185
+ # session_custom_claims::
186
+ # Add a custom claims map to the Session being authenticated. Claims are only created if a Session is initialized by providing a value in
187
+ # `session_duration_minutes`. Claims will be included on the Session object and in the JWT. To update a key in an existing Session, supply a new value. To
188
+ # delete a key, supply a null value. Custom claims made with reserved claims (`iss`, `sub`, `aud`, `exp`, `nbf`, `iat`, `jti`) will be ignored.
189
+ # Total custom claims size cannot exceed four kilobytes.
190
+ # The type of this field is nilable +object+.
191
+ #
192
+ # == Returns:
193
+ # An object with the following fields:
194
+ # request_id::
195
+ # 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.
196
+ # The type of this field is +String+.
197
+ # member_id::
198
+ # Globally unique UUID that identifies a specific Member.
199
+ # The type of this field is +String+.
200
+ # member_session::
201
+ # The [Session object](https://stytch.com/docs/b2b/api/session-object).
202
+ # The type of this field is +MemberSession+ (+object+).
203
+ # session_token::
204
+ # A secret token for a given Stytch Session.
205
+ # The type of this field is +String+.
206
+ # session_jwt::
207
+ # The JSON Web Token (JWT) for a given Stytch Session.
208
+ # The type of this field is +String+.
209
+ # member::
210
+ # The [Member object](https://stytch.com/docs/b2b/api/member-object).
211
+ # The type of this field is +Member+ (+object+).
212
+ # organization::
213
+ # The [Organization object](https://stytch.com/docs/b2b/api/organization-object).
214
+ # The type of this field is +Organization+ (+object+).
215
+ # status_code::
216
+ # 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.
217
+ # The type of this field is +Integer+.
55
218
  def exchange(
56
219
  organization_id:,
57
220
  session_token: nil,
@@ -70,12 +233,28 @@ module StytchB2B
70
233
  post_request('/v1/b2b/sessions/exchange', request)
71
234
  end
72
235
 
73
- def jwks(
236
+ # Get the JSON Web Key Set (JWKS) for a project.
237
+ #
238
+ # == Parameters:
239
+ # project_id::
240
+ # The `project_id` to get the JWKS for.
241
+ # The type of this field is +String+.
242
+ #
243
+ # == Returns:
244
+ # An object with the following fields:
245
+ # keys::
246
+ # The JWK
247
+ # The type of this field is list of +JWK+ (+object+).
248
+ # request_id::
249
+ # 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.
250
+ # The type of this field is +String+.
251
+ # status_code::
252
+ # 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.
253
+ # The type of this field is +Integer+.
254
+ def get_jwks(
74
255
  project_id:
75
256
  )
76
- query_params = {
77
- project_id: project_id
78
- }
257
+ query_params = {}
79
258
  request = request_with_query_params("/v1/b2b/sessions/jwks/#{project_id}", query_params)
80
259
  get_request(request)
81
260
  end
@@ -1,5 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # !!!
4
+ # WARNING: This file is autogenerated
5
+ # Only modify code within MANUAL() sections
6
+ # or your changes may be overwritten later!
7
+ # !!!
8
+
3
9
  require_relative 'request_helper'
4
10
 
5
11
  module StytchB2B
@@ -14,6 +20,27 @@ module StytchB2B
14
20
  @saml = StytchB2B::SSO::SAML.new(@connection)
15
21
  end
16
22
 
23
+ # Get all SSO Connections owned by the organization.
24
+ #
25
+ # == Parameters:
26
+ # organization_id::
27
+ # 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.
28
+ # The type of this field is +String+.
29
+ #
30
+ # == Returns:
31
+ # An object with the following fields:
32
+ # request_id::
33
+ # 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.
34
+ # The type of this field is +String+.
35
+ # saml_connections::
36
+ # The list of [SAML Connections](https://stytch.com/docs/b2b/api/saml-connection-object) owned by this organization.
37
+ # The type of this field is list of +SAMLConnection+ (+object+).
38
+ # oidc_connections::
39
+ # The list of [OIDC Connections](https://stytch.com/docs/b2b/api/oidc-connection-object) owned by this organization.
40
+ # The type of this field is list of +OIDCConnection+ (+object+).
41
+ # status_code::
42
+ # 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.
43
+ # The type of this field is +Integer+.
17
44
  def get_connections(
18
45
  organization_id:
19
46
  )
@@ -22,6 +49,27 @@ module StytchB2B
22
49
  get_request(request)
23
50
  end
24
51
 
52
+ # Delete an existing SSO connection.
53
+ #
54
+ # == Parameters:
55
+ # organization_id::
56
+ # The organization ID that the SSO connection belongs to.
57
+ # The type of this field is +String+.
58
+ # connection_id::
59
+ # The ID of the SSO connection. Both SAML and OIDC connection IDs can be provided.
60
+ # The type of this field is +String+.
61
+ #
62
+ # == Returns:
63
+ # An object with the following fields:
64
+ # request_id::
65
+ # 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.
66
+ # The type of this field is +String+.
67
+ # connection_id::
68
+ # The `connection_id` that was deleted as part of the delete request.
69
+ # The type of this field is +String+.
70
+ # status_code::
71
+ # 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.
72
+ # The type of this field is +Integer+.
25
73
  def delete_connection(
26
74
  organization_id:,
27
75
  connection_id:
@@ -29,6 +77,77 @@ module StytchB2B
29
77
  delete_request("/v1/b2b/sso/#{organization_id}/connections/#{connection_id}")
30
78
  end
31
79
 
80
+ # Authenticate a user given a token.
81
+ # This endpoint verifies that the user completed the SSO Authentication flow by verifying that the token is valid and hasn't expired.
82
+ # Provide the `session_duration_minutes` parameter to set the lifetime of the session.
83
+ # If the `session_duration_minutes` parameter is not specified, a Stytch session will be created with a 60 minute duration.
84
+ # To link this authentication event to an existing Stytch session, include either the `session_token` or `session_jwt` param.
85
+ #
86
+ # == Parameters:
87
+ # sso_token::
88
+ # The token to authenticate.
89
+ # The type of this field is +String+.
90
+ # pkce_code_verifier::
91
+ # A base64url encoded one time secret used to validate that the request starts and ends on the same device.
92
+ # The type of this field is nilable +String+.
93
+ # session_token::
94
+ # The `session_token` belonging to the member that you wish to associate the email with.
95
+ # The type of this field is nilable +String+.
96
+ # session_jwt::
97
+ # The `session_jwt` belonging to the member that you wish to associate the email with.
98
+ # The type of this field is nilable +String+.
99
+ # session_duration_minutes::
100
+ # Set the session lifetime to be this many minutes from now. This will start a new session if one doesn't already exist,
101
+ # returning both an opaque `session_token` and `session_jwt` for this session. Remember that the `session_jwt` will have a fixed lifetime of
102
+ # five minutes regardless of the underlying session duration, and will need to be refreshed over time.
103
+ #
104
+ # This value must be a minimum of 5 and a maximum of 527040 minutes (366 days).
105
+ #
106
+ # If a `session_token` or `session_jwt` is provided then a successful authentication will continue to extend the session this many minutes.
107
+ #
108
+ # If the `session_duration_minutes` parameter is not specified, a Stytch session will be created with a 60 minute duration. If you don't want
109
+ # to use the Stytch session product, you can ignore the session fields in the response.
110
+ # The type of this field is nilable +Integer+.
111
+ # session_custom_claims::
112
+ # Add a custom claims map to the Session being authenticated. Claims are only created if a Session is initialized by providing a value in
113
+ # `session_duration_minutes`. Claims will be included on the Session object and in the JWT. To update a key in an existing Session, supply a new value. To
114
+ # delete a key, supply a null value. Custom claims made with reserved claims (`iss`, `sub`, `aud`, `exp`, `nbf`, `iat`, `jti`) will be ignored.
115
+ # Total custom claims size cannot exceed four kilobytes.
116
+ # The type of this field is nilable +object+.
117
+ #
118
+ # == Returns:
119
+ # An object with the following fields:
120
+ # request_id::
121
+ # 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.
122
+ # The type of this field is +String+.
123
+ # member_id::
124
+ # Globally unique UUID that identifies a specific Member.
125
+ # The type of this field is +String+.
126
+ # organization_id::
127
+ # 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.
128
+ # The type of this field is +String+.
129
+ # member::
130
+ # The [Member object](https://stytch.com/docs/b2b/api/member-object).
131
+ # The type of this field is +Member+ (+object+).
132
+ # session_token::
133
+ # A secret token for a given Stytch Session.
134
+ # The type of this field is +String+.
135
+ # session_jwt::
136
+ # The JSON Web Token (JWT) for a given Stytch Session.
137
+ # The type of this field is +String+.
138
+ # reset_session::
139
+ # Indicates if all Sessions linked to the Member need to be reset. You should check this field if you aren't using
140
+ # Stytch's Session product. If you are using Stytch's Session product, we revoke the Member’s other Sessions for you.
141
+ # The type of this field is +Boolean+.
142
+ # organization::
143
+ # The [Organization object](https://stytch.com/docs/b2b/api/organization-object).
144
+ # The type of this field is +Organization+ (+object+).
145
+ # status_code::
146
+ # 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.
147
+ # The type of this field is +Integer+.
148
+ # member_session::
149
+ # The [Session object](https://stytch.com/docs/b2b/api/session-object).
150
+ # The type of this field is nilable +MemberSession+ (+object+).
32
151
  def authenticate(
33
152
  sso_token:,
34
153
  pkce_code_verifier: nil,
@@ -56,18 +175,102 @@ module StytchB2B
56
175
  @connection = connection
57
176
  end
58
177
 
178
+ # Create a new OIDC Connection.
179
+ #
180
+ # == Parameters:
181
+ # organization_id::
182
+ # 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.
183
+ # The type of this field is +String+.
184
+ # display_name::
185
+ # A human-readable display name for the connection.
186
+ # The type of this field is nilable +String+.
187
+ #
188
+ # == Returns:
189
+ # An object with the following fields:
190
+ # request_id::
191
+ # 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.
192
+ # The type of this field is +String+.
193
+ # status_code::
194
+ # 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.
195
+ # The type of this field is +Integer+.
196
+ # connection::
197
+ # The `OIDC Connection` object affected by this API call. See the [OIDC Connection Object](https://stytch.com/docs/b2b/api/oidc-connection-object) for complete response field details.
198
+ # The type of this field is nilable +OIDCConnection+ (+object+).
59
199
  def create_connection(
60
200
  organization_id:,
61
201
  display_name: nil
62
202
  )
63
- request = {
64
- organization_id: organization_id
65
- }
203
+ request = {}
66
204
  request[:display_name] = display_name unless display_name.nil?
67
205
 
68
206
  post_request("/v1/b2b/sso/oidc/#{organization_id}", request)
69
207
  end
70
208
 
209
+ # Updates an existing OIDC connection.
210
+ #
211
+ # When the value of `issuer` changes, Stytch will attempt to retrieve the [OpenID Provider Metadata](https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata) document found at `$/.well-known/openid-configuration`.
212
+ # If the metadata document can be retrieved successfully, Stytch will use it to infer the values of `authorization_url`, `token_url`, `jwks_url`, and `userinfo_url`.
213
+ # The `client_id` and `client_secret` values cannot be inferred from the metadata document, and *must* be passed in explicitly.
214
+ #
215
+ # If the metadata document cannot be retrieved, Stytch will still update the connection using values from the request body.
216
+ #
217
+ # If the metadata document can be retrieved, and values are passed in the request body, the explicit values passed in from the request body will take precedence over the values inferred from the metadata document.
218
+ #
219
+ # Note that a newly created connection will not become active until all of the following fields are provided:
220
+ # * `issuer`
221
+ # * `client_id`
222
+ # * `client_secret`
223
+ # * `authorization_url`
224
+ # * `token_url`
225
+ # * `userinfo_url`
226
+ # * `jwks_url`
227
+ #
228
+ # == Parameters:
229
+ # organization_id::
230
+ # 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.
231
+ # The type of this field is +String+.
232
+ # connection_id::
233
+ # Globally unique UUID that identifies a specific SSO `connection_id` for a Member.
234
+ # The type of this field is +String+.
235
+ # display_name::
236
+ # A human-readable display name for the connection.
237
+ # The type of this field is nilable +String+.
238
+ # client_id::
239
+ # The OAuth2.0 client ID used to authenticate login attempts. This will be provided by the IdP.
240
+ # The type of this field is nilable +String+.
241
+ # client_secret::
242
+ # The secret belonging to the OAuth2.0 client used to authenticate login attempts. This will be provided by the IdP.
243
+ # The type of this field is nilable +String+.
244
+ # issuer::
245
+ # A case-sensitive `https://` URL that uniquely identifies the IdP. This will be provided by the IdP.
246
+ # The type of this field is nilable +String+.
247
+ # authorization_url::
248
+ # The location of the URL that starts an OAuth login at the IdP. This will be provided by the IdP.
249
+ # The type of this field is nilable +String+.
250
+ # token_url::
251
+ # The location of the URL that issues OAuth2.0 access tokens and OIDC ID tokens. This will be provided by the IdP.
252
+ # The type of this field is nilable +String+.
253
+ # userinfo_url::
254
+ # The location of the IDP's [UserInfo Endpoint](https://openid.net/specs/openid-connect-core-1_0.html#UserInfo). This will be provided by the IdP.
255
+ # The type of this field is nilable +String+.
256
+ # jwks_url::
257
+ # The location of the IdP's JSON Web Key Set, used to verify credentials issued by the IdP. This will be provided by the IdP.
258
+ # The type of this field is nilable +String+.
259
+ #
260
+ # == Returns:
261
+ # An object with the following fields:
262
+ # request_id::
263
+ # 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.
264
+ # The type of this field is +String+.
265
+ # status_code::
266
+ # 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.
267
+ # The type of this field is +Integer+.
268
+ # connection::
269
+ # The `OIDC Connection` object affected by this API call. See the [OIDC Connection Object](https://stytch.com/docs/b2b/api/oidc-connection-object) for complete response field details.
270
+ # The type of this field is nilable +OIDCConnection+ (+object+).
271
+ # warning::
272
+ # If it is not possible to resolve the well-known metadata document from the OIDC issuer, this field will explain what went wrong if the request is successful otherwise. In other words, even if the overall request succeeds, there could be relevant warnings related to the connection update.
273
+ # The type of this field is nilable +String+.
71
274
  def update_connection(
72
275
  organization_id:,
73
276
  connection_id:,
@@ -80,10 +283,7 @@ module StytchB2B
80
283
  userinfo_url: nil,
81
284
  jwks_url: nil
82
285
  )
83
- request = {
84
- organization_id: organization_id,
85
- connection_id: connection_id
86
- }
286
+ request = {}
87
287
  request[:display_name] = display_name unless display_name.nil?
88
288
  request[:client_id] = client_id unless client_id.nil?
89
289
  request[:client_secret] = client_secret unless client_secret.nil?
@@ -104,18 +304,79 @@ module StytchB2B
104
304
  @connection = connection
105
305
  end
106
306
 
307
+ # Create a new SAML Connection.
308
+ #
309
+ # == Parameters:
310
+ # organization_id::
311
+ # 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.
312
+ # The type of this field is +String+.
313
+ # display_name::
314
+ # A human-readable display name for the connection.
315
+ # The type of this field is nilable +String+.
316
+ #
317
+ # == Returns:
318
+ # An object with the following fields:
319
+ # request_id::
320
+ # 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.
321
+ # The type of this field is +String+.
322
+ # status_code::
323
+ # 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.
324
+ # The type of this field is +Integer+.
325
+ # connection::
326
+ # The `SAML Connection` object affected by this API call. See the [SAML Connection Object](https://stytch.com/docs/b2b/api/saml-connection-object) for complete response field details.
327
+ # The type of this field is nilable +SAMLConnection+ (+object+).
107
328
  def create_connection(
108
329
  organization_id:,
109
330
  display_name: nil
110
331
  )
111
- request = {
112
- organization_id: organization_id
113
- }
332
+ request = {}
114
333
  request[:display_name] = display_name unless display_name.nil?
115
334
 
116
335
  post_request("/v1/b2b/sso/saml/#{organization_id}", request)
117
336
  end
118
337
 
338
+ # Updates an existing SAML connection.
339
+ #
340
+ # Note that a newly created connection will not become active until all of the following are provided:
341
+ # * `idp_sso_url`
342
+ # * `attribute_mapping`
343
+ # * `idp_entity_id`
344
+ # * `x509_certificate`
345
+ #
346
+ # == Parameters:
347
+ # organization_id::
348
+ # 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.
349
+ # The type of this field is +String+.
350
+ # connection_id::
351
+ # Globally unique UUID that identifies a specific SSO `connection_id` for a Member.
352
+ # The type of this field is +String+.
353
+ # idp_entity_id::
354
+ # A globally unique name for the IdP. This will be provided by the IdP.
355
+ # The type of this field is nilable +String+.
356
+ # display_name::
357
+ # A human-readable display name for the connection.
358
+ # The type of this field is nilable +String+.
359
+ # attribute_mapping::
360
+ # An object that represents the attributes used to identify a Member. This object will map the IdP-defined User attributes to Stytch-specific values. Required attributes: `email` and one of `full_name` or `first_name` and `last_name`.
361
+ # The type of this field is nilable +object+.
362
+ # x509_certificate::
363
+ # A certificate that Stytch will use to verify the sign-in assertion sent by the IdP, in [PEM](https://en.wikipedia.org/wiki/Privacy-Enhanced_Mail) format. See our [X509 guide](https://stytch.com/docs/b2b/api/saml-certificates) for more info.
364
+ # The type of this field is nilable +String+.
365
+ # idp_sso_url::
366
+ # The URL for which assertions for login requests will be sent. This will be provided by the IdP.
367
+ # The type of this field is nilable +String+.
368
+ #
369
+ # == Returns:
370
+ # An object with the following fields:
371
+ # request_id::
372
+ # 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.
373
+ # The type of this field is +String+.
374
+ # status_code::
375
+ # 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.
376
+ # The type of this field is +Integer+.
377
+ # connection::
378
+ # The `SAML Connection` object affected by this API call. See the [SAML Connection Object](https://stytch.com/docs/b2b/api/saml-connection-object) for complete response field details.
379
+ # The type of this field is nilable +SAMLConnection+ (+object+).
119
380
  def update_connection(
120
381
  organization_id:,
121
382
  connection_id:,
@@ -125,10 +386,7 @@ module StytchB2B
125
386
  x509_certificate: nil,
126
387
  idp_sso_url: nil
127
388
  )
128
- request = {
129
- organization_id: organization_id,
130
- connection_id: connection_id
131
- }
389
+ request = {}
132
390
  request[:idp_entity_id] = idp_entity_id unless idp_entity_id.nil?
133
391
  request[:display_name] = display_name unless display_name.nil?
134
392
  request[:attribute_mapping] = attribute_mapping unless attribute_mapping.nil?
@@ -138,6 +396,32 @@ module StytchB2B
138
396
  put_request("/v1/b2b/sso/saml/#{organization_id}/connections/#{connection_id}", request)
139
397
  end
140
398
 
399
+ # Delete a SAML verification certificate.
400
+ #
401
+ # You may need to do this when rotating certificates from your IdP, since Stytch allows a maximum of 5 certificates per connection. There must always be at least one certificate per active connection.
402
+ #
403
+ # == Parameters:
404
+ # organization_id::
405
+ # The organization ID that the SAML connection belongs to.
406
+ # The type of this field is +String+.
407
+ # connection_id::
408
+ # The ID of the SAML connection.
409
+ # The type of this field is +String+.
410
+ # certificate_id::
411
+ # The ID of the certificate to be deleted.
412
+ # The type of this field is +String+.
413
+ #
414
+ # == Returns:
415
+ # An object with the following fields:
416
+ # request_id::
417
+ # 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.
418
+ # The type of this field is +String+.
419
+ # certificate_id::
420
+ # The ID of the certificate that was deleted.
421
+ # The type of this field is +String+.
422
+ # status_code::
423
+ # 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.
424
+ # The type of this field is +Integer+.
141
425
  def delete_verification_certificate(
142
426
  organization_id:,
143
427
  connection_id:,
data/lib/stytch/client.rb CHANGED
@@ -1,20 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'users'
3
+ require_relative 'crypto_wallets'
4
4
  require_relative 'magic_links'
5
5
  require_relative 'oauth'
6
6
  require_relative 'otps'
7
+ require_relative 'passwords'
7
8
  require_relative 'sessions'
8
9
  require_relative 'totps'
10
+ require_relative 'users'
9
11
  require_relative 'webauthn'
10
- require_relative 'crypto_wallets'
11
- require_relative 'passwords'
12
12
 
13
13
  module Stytch
14
14
  class Client
15
15
  ENVIRONMENTS = %i[live test].freeze
16
16
 
17
- attr_reader :users, :magic_links, :oauth, :otps, :sessions, :totps, :webauthn, :crypto_wallets, :passwords
17
+ attr_reader :crypto_wallets, :magic_links, :oauth, :otps, :passwords, :sessions, :totps, :users, :webauthn
18
18
 
19
19
  def initialize(project_id:, secret:, env: nil, &block)
20
20
  @api_host = api_host(env, project_id)
@@ -23,15 +23,15 @@ module Stytch
23
23
 
24
24
  create_connection(&block)
25
25
 
26
- @users = Stytch::Users.new(@connection)
26
+ @crypto_wallets = Stytch::CryptoWallets.new(@connection)
27
27
  @magic_links = Stytch::MagicLinks.new(@connection)
28
28
  @oauth = Stytch::OAuth.new(@connection)
29
29
  @otps = Stytch::OTPs.new(@connection)
30
- @sessions = Stytch::Sessions.new(@connection, @project_id)
30
+ @passwords = Stytch::Passwords.new(@connection)
31
+ @sessions = Stytch::Sessions.new(@connection, project_id)
31
32
  @totps = Stytch::TOTPs.new(@connection)
33
+ @users = Stytch::Users.new(@connection)
32
34
  @webauthn = Stytch::WebAuthn.new(@connection)
33
- @crypto_wallets = Stytch::CryptoWallets.new(@connection)
34
- @passwords = Stytch::Passwords.new(@connection)
35
35
  end
36
36
 
37
37
  private
@@ -42,7 +42,7 @@ module Stytch
42
42
  'https://api.stytch.com'
43
43
  when :test
44
44
  'https://test.stytch.com'
45
- when /\Ahttps?:\/\//
45
+ when %r{\Ahttps?://}
46
46
  # If this is a string that looks like a URL, assume it's an internal development URL.
47
47
  env
48
48
  else