stytch 6.4.0 → 9.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +13 -0
- data/.gitignore +2 -0
- data/.rubocop.yml +22 -0
- data/DEVELOPMENT.md +5 -2
- data/README.md +52 -3
- data/lib/stytch/b2b_client.rb +18 -3
- data/lib/stytch/b2b_discovery.rb +73 -33
- data/lib/stytch/b2b_magic_links.rb +63 -24
- data/lib/stytch/b2b_oauth.rb +31 -16
- data/lib/stytch/b2b_organizations.rb +788 -51
- data/lib/stytch/b2b_otp.rb +35 -10
- data/lib/stytch/b2b_passwords.rb +141 -44
- data/lib/stytch/b2b_rbac.rb +47 -0
- data/lib/stytch/b2b_recovery_codes.rb +196 -0
- data/lib/stytch/b2b_scim.rb +496 -0
- data/lib/stytch/b2b_sessions.rb +299 -15
- data/lib/stytch/b2b_sso.rb +486 -24
- data/lib/stytch/b2b_totps.rb +255 -0
- data/lib/stytch/client.rb +6 -3
- data/lib/stytch/crypto_wallets.rb +19 -4
- data/lib/stytch/errors.rb +21 -0
- data/lib/stytch/m2m.rb +80 -19
- data/lib/stytch/magic_links.rb +20 -12
- data/lib/stytch/method_options.rb +22 -0
- data/lib/stytch/oauth.rb +10 -4
- data/lib/stytch/otps.rb +27 -17
- data/lib/stytch/passwords.rb +67 -19
- data/lib/stytch/project.rb +26 -0
- data/lib/stytch/rbac_local.rb +58 -0
- data/lib/stytch/request_helper.rb +12 -8
- data/lib/stytch/sessions.rb +131 -31
- data/lib/stytch/totps.rb +9 -5
- data/lib/stytch/users.rb +30 -16
- data/lib/stytch/version.rb +1 -1
- data/lib/stytch/webauthn.rb +126 -24
- data/lib/stytch.rb +1 -0
- data/stytch.gemspec +2 -0
- metadata +42 -6
@@ -20,11 +20,12 @@ module StytchB2B
|
|
20
20
|
@discovery = StytchB2B::MagicLinks::Discovery.new(@connection)
|
21
21
|
end
|
22
22
|
|
23
|
-
# Authenticate a
|
23
|
+
# Authenticate a with a Magic Link. This endpoint requires a Magic Link token that is not expired or previously used. If the Member’s status is `pending` or `invited`, they will be updated to `active`.
|
24
24
|
# Provide the `session_duration_minutes` parameter to set the lifetime of the session. If the `session_duration_minutes` parameter is not specified, a Stytch session will be created with a 60 minute duration.
|
25
25
|
#
|
26
|
-
# If the Member is required to complete MFA to log in to the
|
27
|
-
# The `intermediate_session_token` can be passed into the [OTP SMS Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-otp-sms)
|
26
|
+
# If the Member is required to complete MFA to log in to the, the returned value of `member_authenticated` will be `false`, and an `intermediate_session_token` will be returned.
|
27
|
+
# The `intermediate_session_token` can be passed into 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),
|
28
|
+
# or [Recovery Codes Recover endpoint](https://stytch.com/docs/b2b/api/recovery-codes-recover) to complete the MFA step and acquire a full member session.
|
28
29
|
# The `intermediate_session_token` can also be used with the [Exchange Intermediate Session endpoint](https://stytch.com/docs/b2b/api/exchange-intermediate-session) or the [Create Organization via Discovery endpoint](https://stytch.com/docs/b2b/api/create-organization-via-discovery) to join a different Organization or create a new one.
|
29
30
|
# The `session_duration_minutes` and `session_custom_claims` parameters will be ignored.
|
30
31
|
#
|
@@ -66,7 +67,7 @@ module StytchB2B
|
|
66
67
|
# Total custom claims size cannot exceed four kilobytes.
|
67
68
|
# The type of this field is nilable +object+.
|
68
69
|
# locale::
|
69
|
-
# If the
|
70
|
+
# If the needs to complete an MFA step, and the Member has a phone number, this endpoint will pre-emptively send a one-time passcode (OTP) to the Member's phone number. The locale argument will be used to determine which language to use when sending the passcode.
|
70
71
|
#
|
71
72
|
# Parameter is a [IETF BCP 47 language tag](https://www.w3.org/International/articles/language-tags/), e.g. `"en"`.
|
72
73
|
#
|
@@ -75,6 +76,9 @@ module StytchB2B
|
|
75
76
|
# Request support for additional languages [here](https://docs.google.com/forms/d/e/1FAIpQLScZSpAu_m2AmLXRT3F3kap-s_mcV6UTBitYn6CdyWP0-o7YjQ/viewform?usp=sf_link")!
|
76
77
|
#
|
77
78
|
# The type of this field is nilable +AuthenticateRequestLocale+ (string enum).
|
79
|
+
# intermediate_session_token::
|
80
|
+
# Adds this primary authentication factor to the intermediate session token. If the resulting set of factors satisfies the organization's primary authentication requirements and MFA requirements, the intermediate session token will be consumed and converted to a member session. If not, the same intermediate session token will be returned.
|
81
|
+
# The type of this field is nilable +String+.
|
78
82
|
#
|
79
83
|
# == Returns:
|
80
84
|
# An object with the following fields:
|
@@ -103,17 +107,11 @@ module StytchB2B
|
|
103
107
|
# session_jwt::
|
104
108
|
# The JSON Web Token (JWT) for a given Stytch Session.
|
105
109
|
# The type of this field is +String+.
|
106
|
-
# member_session::
|
107
|
-
# The [Session object](https://stytch.com/docs/b2b/api/session-object).
|
108
|
-
# The type of this field is +MemberSession+ (+object+).
|
109
110
|
# organization::
|
110
111
|
# The [Organization object](https://stytch.com/docs/b2b/api/organization-object).
|
111
112
|
# The type of this field is +Organization+ (+object+).
|
112
113
|
# intermediate_session_token::
|
113
|
-
# The returned Intermediate Session Token contains an Email Magic Link factor associated with the Member's email address.
|
114
|
-
# The token can be used with the [OTP SMS Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-otp-sms) to complete the MFA flow and log in to the Organization.
|
115
|
-
# It can also be used with the [Exchange Intermediate Session endpoint](https://stytch.com/docs/b2b/api/exchange-intermediate-session) to join a different existing Organization that allows login with Email Magic Links,
|
116
|
-
# or the [Create Organization via Discovery endpoint](https://stytch.com/docs/b2b/api/create-organization-via-discovery) to create a new Organization.
|
114
|
+
# The returned Intermediate Session Token contains an Email Magic Link factor associated with the Member's email address. 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. It can also be used with the [Exchange Intermediate Session endpoint](https://stytch.com/docs/b2b/api/exchange-intermediate-session) to join a specific Organization that allows the factors represented by the intermediate session token; or the [Create Organization via Discovery endpoint](https://stytch.com/docs/b2b/api/create-organization-via-discovery) to create a new Organization and Member.
|
117
115
|
# The type of this field is +String+.
|
118
116
|
# member_authenticated::
|
119
117
|
# Indicates whether the Member is fully authenticated. If false, the Member needs to complete an MFA step to log in to the Organization.
|
@@ -121,6 +119,9 @@ module StytchB2B
|
|
121
119
|
# status_code::
|
122
120
|
# 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.
|
123
121
|
# The type of this field is +Integer+.
|
122
|
+
# member_session::
|
123
|
+
# The [Session object](https://stytch.com/docs/b2b/api/session-object).
|
124
|
+
# The type of this field is nilable +MemberSession+ (+object+).
|
124
125
|
# mfa_required::
|
125
126
|
# Information about the MFA requirements of the Organization and the Member's options for fulfilling MFA.
|
126
127
|
# The type of this field is nilable +MfaRequired+ (+object+).
|
@@ -131,8 +132,10 @@ module StytchB2B
|
|
131
132
|
session_jwt: nil,
|
132
133
|
session_duration_minutes: nil,
|
133
134
|
session_custom_claims: nil,
|
134
|
-
locale: nil
|
135
|
+
locale: nil,
|
136
|
+
intermediate_session_token: nil
|
135
137
|
)
|
138
|
+
headers = {}
|
136
139
|
request = {
|
137
140
|
magic_links_token: magic_links_token
|
138
141
|
}
|
@@ -142,11 +145,31 @@ module StytchB2B
|
|
142
145
|
request[:session_duration_minutes] = session_duration_minutes unless session_duration_minutes.nil?
|
143
146
|
request[:session_custom_claims] = session_custom_claims unless session_custom_claims.nil?
|
144
147
|
request[:locale] = locale unless locale.nil?
|
148
|
+
request[:intermediate_session_token] = intermediate_session_token unless intermediate_session_token.nil?
|
145
149
|
|
146
|
-
post_request('/v1/b2b/magic_links/authenticate', request)
|
150
|
+
post_request('/v1/b2b/magic_links/authenticate', request, headers)
|
147
151
|
end
|
148
152
|
|
149
153
|
class Email
|
154
|
+
class InviteRequestOptions
|
155
|
+
# Optional authorization object.
|
156
|
+
# Pass in an active Stytch Member session token or session JWT and the request
|
157
|
+
# will be run using that member's permissions.
|
158
|
+
attr_accessor :authorization
|
159
|
+
|
160
|
+
def initialize(
|
161
|
+
authorization: nil
|
162
|
+
)
|
163
|
+
@authorization = authorization
|
164
|
+
end
|
165
|
+
|
166
|
+
def to_headers
|
167
|
+
headers = {}
|
168
|
+
headers.merge!(@authorization.to_headers) if authorization
|
169
|
+
headers
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
150
173
|
include Stytch::RequestHelper
|
151
174
|
attr_reader :discovery
|
152
175
|
|
@@ -158,6 +181,8 @@ module StytchB2B
|
|
158
181
|
|
159
182
|
# Send either a login or signup magic link to a Member. A new, pending, or invited Member will receive a signup Email Magic Link. Members will have a `pending` status until they successfully authenticate. An active Member will receive a login Email Magic Link.
|
160
183
|
#
|
184
|
+
# The magic link is valid for 60 minutes.
|
185
|
+
#
|
161
186
|
# == Parameters:
|
162
187
|
# organization_id::
|
163
188
|
# 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.
|
@@ -225,6 +250,7 @@ module StytchB2B
|
|
225
250
|
signup_template_id: nil,
|
226
251
|
locale: nil
|
227
252
|
)
|
253
|
+
headers = {}
|
228
254
|
request = {
|
229
255
|
organization_id: organization_id,
|
230
256
|
email_address: email_address
|
@@ -236,10 +262,12 @@ module StytchB2B
|
|
236
262
|
request[:signup_template_id] = signup_template_id unless signup_template_id.nil?
|
237
263
|
request[:locale] = locale unless locale.nil?
|
238
264
|
|
239
|
-
post_request('/v1/b2b/magic_links/email/login_or_signup', request)
|
265
|
+
post_request('/v1/b2b/magic_links/email/login_or_signup', request, headers)
|
240
266
|
end
|
241
267
|
|
242
|
-
# Send an invite email to a new
|
268
|
+
# Send an invite email to a new to join an. The Member will be created with an `invited` status until they successfully authenticate. Sending invites to `pending` Members will update their status to `invited`. Sending invites to already `active` Members will return an error.
|
269
|
+
#
|
270
|
+
# The magic link invite will be valid for 1 week.
|
243
271
|
#
|
244
272
|
# == Parameters:
|
245
273
|
# organization_id::
|
@@ -279,6 +307,10 @@ module StytchB2B
|
|
279
307
|
# Request support for additional languages [here](https://docs.google.com/forms/d/e/1FAIpQLScZSpAu_m2AmLXRT3F3kap-s_mcV6UTBitYn6CdyWP0-o7YjQ/viewform?usp=sf_link")!
|
280
308
|
#
|
281
309
|
# The type of this field is nilable +InviteRequestLocale+ (string enum).
|
310
|
+
# roles::
|
311
|
+
# Roles to explicitly assign to this Member. See the [RBAC guide](https://stytch.com/docs/b2b/guides/rbac/role-assignment)
|
312
|
+
# for more information about role assignment.
|
313
|
+
# The type of this field is nilable list of +String+.
|
282
314
|
#
|
283
315
|
# == Returns:
|
284
316
|
# An object with the following fields:
|
@@ -297,6 +329,9 @@ module StytchB2B
|
|
297
329
|
# status_code::
|
298
330
|
# 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.
|
299
331
|
# The type of this field is +Integer+.
|
332
|
+
#
|
333
|
+
# == Method Options:
|
334
|
+
# This method supports an optional +StytchB2B::MagicLinks::Email::InviteRequestOptions+ object which will modify the headers sent in the HTTP request.
|
300
335
|
def invite(
|
301
336
|
organization_id:,
|
302
337
|
email_address:,
|
@@ -306,8 +341,12 @@ module StytchB2B
|
|
306
341
|
trusted_metadata: nil,
|
307
342
|
untrusted_metadata: nil,
|
308
343
|
invite_template_id: nil,
|
309
|
-
locale: nil
|
344
|
+
locale: nil,
|
345
|
+
roles: nil,
|
346
|
+
method_options: nil
|
310
347
|
)
|
348
|
+
headers = {}
|
349
|
+
headers = headers.merge(method_options.to_headers) unless method_options.nil?
|
311
350
|
request = {
|
312
351
|
organization_id: organization_id,
|
313
352
|
email_address: email_address
|
@@ -319,8 +358,9 @@ module StytchB2B
|
|
319
358
|
request[:untrusted_metadata] = untrusted_metadata unless untrusted_metadata.nil?
|
320
359
|
request[:invite_template_id] = invite_template_id unless invite_template_id.nil?
|
321
360
|
request[:locale] = locale unless locale.nil?
|
361
|
+
request[:roles] = roles unless roles.nil?
|
322
362
|
|
323
|
-
post_request('/v1/b2b/magic_links/email/invite', request)
|
363
|
+
post_request('/v1/b2b/magic_links/email/invite', request, headers)
|
324
364
|
end
|
325
365
|
|
326
366
|
class Discovery
|
@@ -330,7 +370,7 @@ module StytchB2B
|
|
330
370
|
@connection = connection
|
331
371
|
end
|
332
372
|
|
333
|
-
# Send a discovery magic link to an email address.
|
373
|
+
# Send a discovery magic link to an email address. The magic link is valid for 60 minutes.
|
334
374
|
#
|
335
375
|
# == Parameters:
|
336
376
|
# email_address::
|
@@ -372,6 +412,7 @@ module StytchB2B
|
|
372
412
|
login_template_id: nil,
|
373
413
|
locale: nil
|
374
414
|
)
|
415
|
+
headers = {}
|
375
416
|
request = {
|
376
417
|
email_address: email_address
|
377
418
|
}
|
@@ -380,7 +421,7 @@ module StytchB2B
|
|
380
421
|
request[:login_template_id] = login_template_id unless login_template_id.nil?
|
381
422
|
request[:locale] = locale unless locale.nil?
|
382
423
|
|
383
|
-
post_request('/v1/b2b/magic_links/email/discovery/send', request)
|
424
|
+
post_request('/v1/b2b/magic_links/email/discovery/send', request, headers)
|
384
425
|
end
|
385
426
|
end
|
386
427
|
end
|
@@ -408,10 +449,7 @@ module StytchB2B
|
|
408
449
|
# 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.
|
409
450
|
# The type of this field is +String+.
|
410
451
|
# intermediate_session_token::
|
411
|
-
# The Intermediate Session Token. This token does not necessarily belong to a specific instance of a Member, but represents a bag of factors that may be converted to a member session.
|
412
|
-
# The token can be used with the [OTP SMS Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-otp-sms) to complete an MFA flow;
|
413
|
-
# the [Exchange Intermediate Session endpoint](https://stytch.com/docs/b2b/api/exchange-intermediate-session) to join a specific Organization that allows the factors represented by the intermediate session token;
|
414
|
-
# or the [Create Organization via Discovery endpoint](https://stytch.com/docs/b2b/api/create-organization-via-discovery) to create a new Organization and Member.
|
452
|
+
# The Intermediate Session Token. This token does not necessarily belong to a specific instance of a Member, but represents a bag of factors that may be converted to a member session. 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. It can also be used with the [Exchange Intermediate Session endpoint](https://stytch.com/docs/b2b/api/exchange-intermediate-session) to join a specific Organization that allows the factors represented by the intermediate session token; or the [Create Organization via Discovery endpoint](https://stytch.com/docs/b2b/api/create-organization-via-discovery) to create a new Organization and Member.
|
415
453
|
# The type of this field is +String+.
|
416
454
|
# email_address::
|
417
455
|
# The email address.
|
@@ -437,12 +475,13 @@ module StytchB2B
|
|
437
475
|
discovery_magic_links_token:,
|
438
476
|
pkce_code_verifier: nil
|
439
477
|
)
|
478
|
+
headers = {}
|
440
479
|
request = {
|
441
480
|
discovery_magic_links_token: discovery_magic_links_token
|
442
481
|
}
|
443
482
|
request[:pkce_code_verifier] = pkce_code_verifier unless pkce_code_verifier.nil?
|
444
483
|
|
445
|
-
post_request('/v1/b2b/magic_links/discovery/authenticate', request)
|
484
|
+
post_request('/v1/b2b/magic_links/discovery/authenticate', request, headers)
|
446
485
|
end
|
447
486
|
end
|
448
487
|
end
|
data/lib/stytch/b2b_oauth.rb
CHANGED
@@ -19,15 +19,20 @@ module StytchB2B
|
|
19
19
|
@discovery = StytchB2B::OAuth::Discovery.new(@connection)
|
20
20
|
end
|
21
21
|
|
22
|
-
# Authenticate a
|
22
|
+
# Authenticate a given a `token`. This endpoint verifies that the member completed the flow by verifying that the token is valid and hasn't expired. Provide the `session_duration_minutes` parameter to set the lifetime of the session. If the `session_duration_minutes` parameter is not specified, a Stytch session will be created with a 60 minute duration.
|
23
23
|
#
|
24
|
-
# If the Member is required to complete MFA to log in to the
|
24
|
+
# If the Member is required to complete MFA to log in to the, the returned value of `member_authenticated` will be `false`, and an `intermediate_session_token` will be returned.
|
25
25
|
# The `intermediate_session_token` can be passed into the [OTP SMS Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-otp-sms) to complete the MFA step and acquire a full member session.
|
26
26
|
# The `intermediate_session_token` can also be used with the [Exchange Intermediate Session endpoint](https://stytch.com/docs/b2b/api/exchange-intermediate-session) or the [Create Organization via Discovery endpoint](https://stytch.com/docs/b2b/api/create-organization-via-discovery) to join a different Organization or create a new one.
|
27
27
|
# The `session_duration_minutes` and `session_custom_claims` parameters will be ignored.
|
28
28
|
#
|
29
29
|
# If a valid `session_token` or `session_jwt` is passed in, the Member will not be required to complete an MFA step.
|
30
30
|
#
|
31
|
+
# If the Member is logging in via an OAuth provider that does not fully verify the email, the returned value of `member_authenticated` will be `false`, and an `intermediate_session_token` will be returned.
|
32
|
+
# The `primary_required` field details the authentication flow the Member must perform in order to [complete a step-up authentication](https://stytch.com/docs/b2b/guides/oauth/auth-flows) into the organization. The `intermediate_session_token` must be passed into that authentication flow.
|
33
|
+
#
|
34
|
+
# We’re actively accepting requests for new OAuth providers! Please [email us](mailto:support@stytch.com) or [post in our community](https://stytch.com/docs/b2b/resources) if you are looking for an OAuth provider that is not currently supported.
|
35
|
+
#
|
31
36
|
# == Parameters:
|
32
37
|
# oauth_token::
|
33
38
|
# The token to authenticate.
|
@@ -60,7 +65,7 @@ module StytchB2B
|
|
60
65
|
# A base64url encoded one time secret used to validate that the request starts and ends on the same device.
|
61
66
|
# The type of this field is nilable +String+.
|
62
67
|
# locale::
|
63
|
-
# If the
|
68
|
+
# If the needs to complete an MFA step, and the Member has a phone number, this endpoint will pre-emptively send a one-time passcode (OTP) to the Member's phone number. The locale argument will be used to determine which language to use when sending the passcode.
|
64
69
|
#
|
65
70
|
# Parameter is a [IETF BCP 47 language tag](https://www.w3.org/International/articles/language-tags/), e.g. `"en"`.
|
66
71
|
#
|
@@ -69,6 +74,9 @@ module StytchB2B
|
|
69
74
|
# Request support for additional languages [here](https://docs.google.com/forms/d/e/1FAIpQLScZSpAu_m2AmLXRT3F3kap-s_mcV6UTBitYn6CdyWP0-o7YjQ/viewform?usp=sf_link")!
|
70
75
|
#
|
71
76
|
# The type of this field is nilable +AuthenticateRequestLocale+ (string enum).
|
77
|
+
# intermediate_session_token::
|
78
|
+
# Adds this primary authentication factor to the intermediate session token. If the resulting set of factors satisfies the organization's primary authentication requirements and MFA requirements, the intermediate session token will be consumed and converted to a member session. If not, the same intermediate session token will be returned.
|
79
|
+
# The type of this field is nilable +String+.
|
72
80
|
#
|
73
81
|
# == Returns:
|
74
82
|
# An object with the following fields:
|
@@ -106,10 +114,7 @@ module StytchB2B
|
|
106
114
|
# Indicates whether the Member is fully authenticated. If false, the Member needs to complete an MFA step to log in to the Organization.
|
107
115
|
# The type of this field is +Boolean+.
|
108
116
|
# intermediate_session_token::
|
109
|
-
# The returned Intermediate Session Token contains an OAuth factor associated with the Member's email address.
|
110
|
-
# The token can be used with the [OTP SMS Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-otp-sms) to complete the MFA flow and log in to the Organization.
|
111
|
-
# It can also be used with the [Exchange Intermediate Session endpoint](https://stytch.com/docs/b2b/api/exchange-intermediate-session) to join a different existing Organization that allows login with OAuth,
|
112
|
-
# or the [Create Organization via Discovery endpoint](https://stytch.com/docs/b2b/api/create-organization-via-discovery) to create a new Organization.
|
117
|
+
# The returned Intermediate Session Token contains an OAuth factor associated with the Member's email address. 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. It can also be used with the [Exchange Intermediate Session endpoint](https://stytch.com/docs/b2b/api/exchange-intermediate-session) to join a specific Organization that allows the factors represented by the intermediate session token; or the [Create Organization via Discovery endpoint](https://stytch.com/docs/b2b/api/create-organization-via-discovery) to create a new Organization and Member.
|
113
118
|
# The type of this field is +String+.
|
114
119
|
# status_code::
|
115
120
|
# 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.
|
@@ -120,11 +125,14 @@ module StytchB2B
|
|
120
125
|
# provider_values::
|
121
126
|
# The `provider_values` object lists relevant identifiers, values, and scopes for a given OAuth provider. For example this object will include a provider's `access_token` that you can use to access the provider's API for a given user.
|
122
127
|
#
|
123
|
-
# Note that these values will vary based on the OAuth provider in question, e.g. `id_token` is only returned by Microsoft.
|
128
|
+
# Note that these values will vary based on the OAuth provider in question, e.g. `id_token` is only returned by Microsoft. Google One Tap does not return access tokens or refresh tokens.
|
124
129
|
# The type of this field is nilable +ProviderValues+ (+object+).
|
125
130
|
# mfa_required::
|
126
131
|
# Information about the MFA requirements of the Organization and the Member's options for fulfilling MFA.
|
127
132
|
# The type of this field is nilable +MfaRequired+ (+object+).
|
133
|
+
# primary_required::
|
134
|
+
# Information about the primary authentication requirements of the Organization.
|
135
|
+
# The type of this field is nilable +PrimaryRequired+ (+object+).
|
128
136
|
def authenticate(
|
129
137
|
oauth_token:,
|
130
138
|
session_token: nil,
|
@@ -132,8 +140,10 @@ module StytchB2B
|
|
132
140
|
session_jwt: nil,
|
133
141
|
session_custom_claims: nil,
|
134
142
|
pkce_code_verifier: nil,
|
135
|
-
locale: nil
|
143
|
+
locale: nil,
|
144
|
+
intermediate_session_token: nil
|
136
145
|
)
|
146
|
+
headers = {}
|
137
147
|
request = {
|
138
148
|
oauth_token: oauth_token
|
139
149
|
}
|
@@ -143,8 +153,9 @@ module StytchB2B
|
|
143
153
|
request[:session_custom_claims] = session_custom_claims unless session_custom_claims.nil?
|
144
154
|
request[:pkce_code_verifier] = pkce_code_verifier unless pkce_code_verifier.nil?
|
145
155
|
request[:locale] = locale unless locale.nil?
|
156
|
+
request[:intermediate_session_token] = intermediate_session_token unless intermediate_session_token.nil?
|
146
157
|
|
147
|
-
post_request('/v1/b2b/oauth/authenticate', request)
|
158
|
+
post_request('/v1/b2b/oauth/authenticate', request, headers)
|
148
159
|
end
|
149
160
|
|
150
161
|
class Discovery
|
@@ -154,7 +165,7 @@ module StytchB2B
|
|
154
165
|
@connection = connection
|
155
166
|
end
|
156
167
|
|
157
|
-
# Authenticates the Discovery
|
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.
|
158
169
|
#
|
159
170
|
# == Parameters:
|
160
171
|
# discovery_oauth_token::
|
@@ -182,10 +193,7 @@ module StytchB2B
|
|
182
193
|
# 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.
|
183
194
|
# The type of this field is +String+.
|
184
195
|
# intermediate_session_token::
|
185
|
-
# The Intermediate Session Token. This token does not necessarily belong to a specific instance of a Member, but represents a bag of factors that may be converted to a member session.
|
186
|
-
# The token can be used with the [OTP SMS Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-otp-sms) to complete an MFA flow;
|
187
|
-
# the [Exchange Intermediate Session endpoint](https://stytch.com/docs/b2b/api/exchange-intermediate-session) to join a specific Organization that allows the factors represented by the intermediate session token;
|
188
|
-
# or the [Create Organization via Discovery endpoint](https://stytch.com/docs/b2b/api/create-organization-via-discovery) to create a new Organization and Member.
|
196
|
+
# The Intermediate Session Token. This token does not necessarily belong to a specific instance of a Member, but represents a bag of factors that may be converted to a member session. 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. It can also be used with the [Exchange Intermediate Session endpoint](https://stytch.com/docs/b2b/api/exchange-intermediate-session) to join a specific Organization that allows the factors represented by the intermediate session token; or the [Create Organization via Discovery endpoint](https://stytch.com/docs/b2b/api/create-organization-via-discovery) to create a new Organization and Member.
|
189
197
|
# The type of this field is +String+.
|
190
198
|
# email_address::
|
191
199
|
# The email address.
|
@@ -204,6 +212,12 @@ module StytchB2B
|
|
204
212
|
#
|
205
213
|
# 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).
|
206
214
|
# The type of this field is list of +DiscoveredOrganization+ (+object+).
|
215
|
+
# provider_type::
|
216
|
+
# (no documentation yet)
|
217
|
+
# The type of this field is +String+.
|
218
|
+
# provider_tenant_id::
|
219
|
+
# (no documentation yet)
|
220
|
+
# The type of this field is +String+.
|
207
221
|
# status_code::
|
208
222
|
# 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.
|
209
223
|
# The type of this field is +Integer+.
|
@@ -215,6 +229,7 @@ module StytchB2B
|
|
215
229
|
session_custom_claims: nil,
|
216
230
|
pkce_code_verifier: nil
|
217
231
|
)
|
232
|
+
headers = {}
|
218
233
|
request = {
|
219
234
|
discovery_oauth_token: discovery_oauth_token
|
220
235
|
}
|
@@ -224,7 +239,7 @@ module StytchB2B
|
|
224
239
|
request[:session_custom_claims] = session_custom_claims unless session_custom_claims.nil?
|
225
240
|
request[:pkce_code_verifier] = pkce_code_verifier unless pkce_code_verifier.nil?
|
226
241
|
|
227
|
-
post_request('/v1/b2b/oauth/discovery/authenticate', request)
|
242
|
+
post_request('/v1/b2b/oauth/discovery/authenticate', request, headers)
|
228
243
|
end
|
229
244
|
end
|
230
245
|
end
|