stytch 6.1.0 → 6.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -26,22 +26,150 @@ module StytchB2B
26
26
  @connection = connection
27
27
  end
28
28
 
29
+ # Send a one-time passcode (OTP) to a Member's phone number. If the Member already has a phone number, this will send an OTP to the number associated with their `member_id`. If not, then this will send an OTP to the `phone_number` provided and link the `phone_number` with the Member.
30
+ # An error will be thrown if the Member already has a phone number and the provided `phone_number` does not match the existing one.
31
+ #
32
+ # Note that sending another OTP code before the first has expired will invalidate the first code.
33
+ #
34
+ # 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.
35
+ #
36
+ # == Parameters:
37
+ # organization_id::
38
+ # 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.
39
+ # The type of this field is +String+.
40
+ # member_id::
41
+ # 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.
42
+ # The type of this field is +String+.
43
+ # mfa_phone_number::
44
+ # (no documentation yet)
45
+ # The type of this field is nilable +String+.
46
+ # locale::
47
+ # 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"`.
48
+ #
49
+ # Currently supported languages are English (`"en"`), Spanish (`"es"`), and Brazilian Portuguese (`"pt-br"`); if no value is provided, the copy defaults to English.
50
+ #
51
+ # Request support for additional languages [here](https://docs.google.com/forms/d/e/1FAIpQLScZSpAu_m2AmLXRT3F3kap-s_mcV6UTBitYn6CdyWP0-o7YjQ/viewform?usp=sf_link")!
52
+ #
53
+ # The type of this field is nilable +SendRequestLocale+ (string enum).
54
+ #
55
+ # == Returns:
56
+ # An object with the following fields:
57
+ # request_id::
58
+ # 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.
59
+ # The type of this field is +String+.
60
+ # member_id::
61
+ # Globally unique UUID that identifies a specific Member.
62
+ # The type of this field is +String+.
63
+ # member::
64
+ # The [Member object](https://stytch.com/docs/b2b/api/member-object).
65
+ # The type of this field is +Member+ (+object+).
66
+ # organization::
67
+ # The [Organization object](https://stytch.com/docs/b2b/api/organization-object).
68
+ # The type of this field is +Organization+ (+object+).
69
+ # status_code::
70
+ # 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.
71
+ # The type of this field is +Integer+.
29
72
  def send(
30
73
  organization_id:,
31
74
  member_id:,
32
- phone_number: nil,
75
+ mfa_phone_number: nil,
33
76
  locale: nil
34
77
  )
35
78
  request = {
36
79
  organization_id: organization_id,
37
80
  member_id: member_id
38
81
  }
39
- request[:phone_number] = phone_number unless phone_number.nil?
82
+ request[:mfa_phone_number] = mfa_phone_number unless mfa_phone_number.nil?
40
83
  request[:locale] = locale unless locale.nil?
41
84
 
42
85
  post_request('/v1/b2b/otps/sms/send', request)
43
86
  end
44
87
 
88
+ # Authenticates a Member's OTP code. This endpoint verifies that the code 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.
89
+ #
90
+ # Exactly one of `intermediate_session_token`, `session_token`, or `session_jwt` must be provided in the request.
91
+ # If an intermediate session token is provided, this operation will consume it.
92
+ #
93
+ # If the Organization's MFA policy is `REQUIRED_FOR_ALL`, a successful OTP authentication will change the Member's `mfa_enrolled` status to `true` if it is not already `true`.
94
+ # If the Organization's MFA policy is `OPTIONAL`, the Member's MFA enrollment can be toggled by passing in a value for the `set_mfa_enrollment` field.
95
+ #
96
+ # 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 duration of 60 minutes.
97
+ #
98
+ # == Parameters:
99
+ # organization_id::
100
+ # 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.
101
+ # The type of this field is +String+.
102
+ # member_id::
103
+ # 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.
104
+ # The type of this field is +String+.
105
+ # code::
106
+ # The code to authenticate.
107
+ # The type of this field is +String+.
108
+ # intermediate_session_token::
109
+ # 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.
110
+ # 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;
111
+ # 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;
112
+ # 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
+ # The type of this field is nilable +String+.
114
+ # session_token::
115
+ # A secret token for a given Stytch Session.
116
+ # The type of this field is nilable +String+.
117
+ # session_jwt::
118
+ # The JSON Web Token (JWT) for a given Stytch Session.
119
+ # The type of this field is nilable +String+.
120
+ # session_duration_minutes::
121
+ # Set the session lifetime to be this many minutes from now. This will start a new session if one doesn't already exist,
122
+ # returning both an opaque `session_token` and `session_jwt` for this session. Remember that the `session_jwt` will have a fixed lifetime of
123
+ # five minutes regardless of the underlying session duration, and will need to be refreshed over time.
124
+ #
125
+ # This value must be a minimum of 5 and a maximum of 527040 minutes (366 days).
126
+ #
127
+ # If a `session_token` or `session_jwt` is provided then a successful authentication will continue to extend the session this many minutes.
128
+ #
129
+ # 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
130
+ # to use the Stytch session product, you can ignore the session fields in the response.
131
+ # The type of this field is nilable +Integer+.
132
+ # session_custom_claims::
133
+ # Add a custom claims map to the Session being authenticated. Claims are only created if a Session is initialized by providing a value in
134
+ # `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
135
+ # delete a key, supply a null value. Custom claims made with reserved claims (`iss`, `sub`, `aud`, `exp`, `nbf`, `iat`, `jti`) will be ignored.
136
+ # Total custom claims size cannot exceed four kilobytes.
137
+ # The type of this field is nilable +object+.
138
+ # set_mfa_enrollment::
139
+ # Optionally sets the Member’s MFA enrollment status upon a successful authentication. If the Organization’s MFA policy is `REQUIRED_FOR_ALL`, this field will be ignored. If this field is not passed in, the Member’s `mfa_enrolled` boolean will not be affected. The options are:
140
+ #
141
+ # `enroll` – sets the Member's `mfa_enrolled` boolean to `true`. The Member will be required to complete an MFA step upon subsequent logins to the Organization.
142
+ #
143
+ # `unenroll` – sets the Member's `mfa_enrolled` boolean to `false`. The Member will no longer be required to complete MFA steps when logging in to the Organization.
144
+ #
145
+ # The type of this field is nilable +String+.
146
+ #
147
+ # == Returns:
148
+ # An object with the following fields:
149
+ # request_id::
150
+ # 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.
151
+ # The type of this field is +String+.
152
+ # member_id::
153
+ # Globally unique UUID that identifies a specific Member.
154
+ # The type of this field is +String+.
155
+ # member::
156
+ # The [Member object](https://stytch.com/docs/b2b/api/member-object).
157
+ # The type of this field is +Member+ (+object+).
158
+ # organization::
159
+ # The [Organization object](https://stytch.com/docs/b2b/api/organization-object).
160
+ # The type of this field is +Organization+ (+object+).
161
+ # session_token::
162
+ # A secret token for a given Stytch Session.
163
+ # The type of this field is +String+.
164
+ # session_jwt::
165
+ # The JSON Web Token (JWT) for a given Stytch Session.
166
+ # The type of this field is +String+.
167
+ # status_code::
168
+ # 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.
169
+ # The type of this field is +Integer+.
170
+ # member_session::
171
+ # The [Session object](https://stytch.com/docs/b2b/api/session-object).
172
+ # The type of this field is nilable +MemberSession+ (+object+).
45
173
  def authenticate(
46
174
  organization_id:,
47
175
  member_id:,
@@ -23,14 +23,14 @@ module StytchB2B
23
23
 
24
24
  # 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.
25
25
  #
26
- # This endpoint adapts to your Project's password strength configuration. If you're using [zxcvbn](https://stytch.com/docs/passwords#strength-requirements), the default, your passwords are considered valid if the strength score is >= 3. If you're using [LUDS](https://stytch.com/docs/passwords#strength-requirements), your passwords are considered valid if they meet the requirements that you've set with Stytch. You may update your password strength configuration in the [stytch dashboard](https://stytch.com/dashboard/password-strength-config).
26
+ # This endpoint adapts to your Project's password strength configuration. If you're using [zxcvbn](https://stytch.com/docs/guides/passwords/strength-policy), the default, your passwords are considered valid if the strength score is >= 3. If you're using [LUDS](https://stytch.com/docs/guides/passwords/strength-policy), your passwords are considered valid if they meet the requirements that you've set with Stytch. You may update your password strength configuration in the [stytch dashboard](https://stytch.com/dashboard/password-strength-config).
27
27
  #
28
28
  # ## Password feedback
29
29
  # The zxcvbn_feedback and luds_feedback objects contains relevant fields for you to relay feedback to users that failed to create a strong enough password.
30
30
  #
31
- # If you're using [zxcvbn](https://stytch.com/docs/passwords#strength-requirements), the feedback object will contain warning and suggestions for any password that does not meet the [zxcvbn](https://stytch.com/docs/passwords#strength-requirements) strength requirements. You can return these strings directly to the user to help them craft a strong password.
31
+ # If you're using [zxcvbn](https://stytch.com/docs/guides/passwords/strength-policy), the feedback object will contain warning and suggestions for any password that does not meet the [zxcvbn](https://stytch.com/docs/guides/passwords/strength-policy) strength requirements. You can return these strings directly to the user to help them craft a strong password.
32
32
  #
33
- # If you're using [LUDS](https://stytch.com/docs/passwords#strength-requirements), the feedback object will contain a collection of fields that the user failed or passed. You'll want to prompt the user to create a password that meets all requirements that they failed.
33
+ # If you're using [LUDS](https://stytch.com/docs/guides/passwords/strength-policy), the feedback object will contain a collection of fields that the user failed or passed. You'll want to prompt the user to create a password that meets all requirements that they failed.
34
34
  #
35
35
  # == Parameters:
36
36
  # password::
@@ -187,6 +187,12 @@ module StytchB2B
187
187
  # * We force a password reset in this instance in order to safely deduplicate the account by email address, without introducing the risk of a pre-hijack account takeover attack.
188
188
  # * Imagine a bad actor creates many accounts using passwords and the known email addresses of their victims. If a victim comes to the site and logs in for the first time with an email-based passwordless authentication method then both the victim and the bad actor have credentials to access to the same account. To prevent this, any further email/password login attempts first require a password reset which can only be accomplished by someone with access to the underlying email address.
189
189
  #
190
+ # (Coming Soon) If the Member is required to complete MFA to log in to the Organization, the returned value of `member_authenticated` will be `false`, and an `intermediate_session_token` will be returned.
191
+ # 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.
192
+ # The `session_duration_minutes` and `session_custom_claims` parameters will be ignored.
193
+ #
194
+ # If a valid `session_token` or `session_jwt` is passed in, the Member will not be required to complete an MFA step.
195
+ #
190
196
  # == Parameters:
191
197
  # organization_id::
192
198
  # 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.
@@ -222,7 +228,14 @@ module StytchB2B
222
228
  # Total custom claims size cannot exceed four kilobytes.
223
229
  # The type of this field is nilable +object+.
224
230
  # locale::
225
- # (no documentation yet)
231
+ # (Coming Soon) If the Member 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.
232
+ #
233
+ # Parameter is a [IETF BCP 47 language tag](https://www.w3.org/International/articles/language-tags/), e.g. `"en"`.
234
+ #
235
+ # Currently supported languages are English (`"en"`), Spanish (`"es"`), and Brazilian Portuguese (`"pt-br"`); if no value is provided, the copy defaults to English.
236
+ #
237
+ # Request support for additional languages [here](https://docs.google.com/forms/d/e/1FAIpQLScZSpAu_m2AmLXRT3F3kap-s_mcV6UTBitYn6CdyWP0-o7YjQ/viewform?usp=sf_link")!
238
+ #
226
239
  # The type of this field is nilable +AuthenticateRequestLocale+ (string enum).
227
240
  #
228
241
  # == Returns:
@@ -248,12 +261,23 @@ module StytchB2B
248
261
  # organization::
249
262
  # The [Organization object](https://stytch.com/docs/b2b/api/organization-object).
250
263
  # The type of this field is +Organization+ (+object+).
264
+ # intermediate_session_token::
265
+ # The returned Intermediate Session Token contains a password factor associated with the Member.
266
+ # 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.
267
+ # Password factors are not transferable between Organizations, so the intermediate session token is not valid for use with discovery endpoints.
268
+ # The type of this field is +String+.
269
+ # member_authenticated::
270
+ # Indicates whether the Member is fully authenticated. If false, the Member needs to complete an MFA step to log in to the Organization.
271
+ # The type of this field is +Boolean+.
251
272
  # status_code::
252
273
  # 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
274
  # The type of this field is +Integer+.
254
275
  # member_session::
255
276
  # The [Session object](https://stytch.com/docs/b2b/api/session-object).
256
277
  # The type of this field is nilable +MemberSession+ (+object+).
278
+ # mfa_required::
279
+ # (Coming Soon) Information about the MFA requirements of the Organization and the Member's options for fulfilling MFA.
280
+ # The type of this field is nilable +MfaRequired+ (+object+).
257
281
  def authenticate(
258
282
  organization_id:,
259
283
  email_address:,
@@ -288,8 +312,8 @@ module StytchB2B
288
312
  # Initiates a password reset for the email address provided. 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.
289
313
  #
290
314
  # This endpoint adapts to your Project's password strength configuration.
291
- # If you're using [zxcvbn](https://stytch.com/docs/passwords#strength-requirements), the default, your passwords are considered valid
292
- # if the strength score is >= 3. If you're using [LUDS](https://stytch.com/docs/passwords#strength-requirements), your passwords are
315
+ # If you're using [zxcvbn](https://stytch.com/docs/guides/passwords/strength-policy), the default, your passwords are considered valid
316
+ # if the strength score is >= 3. If you're using [LUDS](https://stytch.com/docs/guides/passwords/strength-policy), your passwords are
293
317
  # considered valid if they meet the requirements that you've set with Stytch.
294
318
  # You may update your password strength configuration in the [stytch dashboard](https://stytch.com/dashboard/password-strength-config).
295
319
  #
@@ -374,6 +398,12 @@ module StytchB2B
374
398
  #
375
399
  # The provided password needs to meet our 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.
376
400
  #
401
+ # (Coming Soon) If the Member is required to complete MFA to log in to the Organization, the returned value of `member_authenticated` will be `false`, and an `intermediate_session_token` will be returned.
402
+ # 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.
403
+ # The `session_duration_minutes` and `session_custom_claims` parameters will be ignored.
404
+ #
405
+ # If a valid `session_token` or `session_jwt` is passed in, the Member will not be required to complete an MFA step.
406
+ #
377
407
  # == Parameters:
378
408
  # password_reset_token::
379
409
  # The password reset token to authenticate.
@@ -413,7 +443,14 @@ module StytchB2B
413
443
  # Total custom claims size cannot exceed four kilobytes.
414
444
  # The type of this field is nilable +object+.
415
445
  # locale::
416
- # (no documentation yet)
446
+ # (Coming Soon) If the Member 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.
447
+ #
448
+ # Parameter is a [IETF BCP 47 language tag](https://www.w3.org/International/articles/language-tags/), e.g. `"en"`.
449
+ #
450
+ # Currently supported languages are English (`"en"`), Spanish (`"es"`), and Brazilian Portuguese (`"pt-br"`); if no value is provided, the copy defaults to English.
451
+ #
452
+ # Request support for additional languages [here](https://docs.google.com/forms/d/e/1FAIpQLScZSpAu_m2AmLXRT3F3kap-s_mcV6UTBitYn6CdyWP0-o7YjQ/viewform?usp=sf_link")!
453
+ #
417
454
  # The type of this field is nilable +ResetRequestLocale+ (string enum).
418
455
  #
419
456
  # == Returns:
@@ -442,12 +479,23 @@ module StytchB2B
442
479
  # organization::
443
480
  # The [Organization object](https://stytch.com/docs/b2b/api/organization-object).
444
481
  # The type of this field is +Organization+ (+object+).
482
+ # intermediate_session_token::
483
+ # The returned Intermediate Session Token contains a password factor associated with the Member.
484
+ # 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.
485
+ # Password factors are not transferable between Organizations, so the intermediate session token is not valid for use with discovery endpoints.
486
+ # The type of this field is +String+.
487
+ # member_authenticated::
488
+ # Indicates whether the Member is fully authenticated. If false, the Member needs to complete an MFA step to log in to the Organization.
489
+ # The type of this field is +Boolean+.
445
490
  # status_code::
446
491
  # 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.
447
492
  # The type of this field is +Integer+.
448
493
  # member_session::
449
494
  # The [Session object](https://stytch.com/docs/b2b/api/session-object).
450
495
  # The type of this field is nilable +MemberSession+ (+object+).
496
+ # mfa_required::
497
+ # (Coming Soon) Information about the MFA requirements of the Organization and the Member's options for fulfilling MFA.
498
+ # The type of this field is nilable +MfaRequired+ (+object+).
451
499
  def reset(
452
500
  password_reset_token:,
453
501
  password:,
@@ -543,11 +591,17 @@ module StytchB2B
543
591
  # Reset the member’s password using their existing password.
544
592
  #
545
593
  # This endpoint adapts to your Project's password strength configuration.
546
- # If you're using [zxcvbn](https://stytch.com/docs/passwords#strength-requirements), the default, your passwords are considered valid
547
- # if the strength score is >= 3. If you're using [LUDS](https://stytch.com/docs/passwords#strength-requirements), your passwords are
594
+ # If you're using [zxcvbn](https://stytch.com/docs/guides/passwords/strength-policy), the default, your passwords are considered valid
595
+ # if the strength score is >= 3. If you're using [LUDS](https://stytch.com/docs/guides/passwords/strength-policy), your passwords are
548
596
  # considered valid if they meet the requirements that you've set with Stytch.
549
597
  # You may update your password strength configuration in the [stytch dashboard](https://stytch.com/dashboard/password-strength-config).
550
598
  #
599
+ # (Coming Soon) If the Member is required to complete MFA to log in to the Organization, the returned value of `member_authenticated` will be `false`, and an `intermediate_session_token` will be returned.
600
+ # 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.
601
+ # The `session_duration_minutes` and `session_custom_claims` parameters will be ignored.
602
+ #
603
+ # If a valid `session_token` or `session_jwt` is passed in, the Member will not be required to complete an MFA step.
604
+ #
551
605
  # == Parameters:
552
606
  # email_address::
553
607
  # The email address of the Member.
@@ -586,7 +640,14 @@ module StytchB2B
586
640
  # Total custom claims size cannot exceed four kilobytes.
587
641
  # The type of this field is nilable +object+.
588
642
  # locale::
589
- # (no documentation yet)
643
+ # (Coming Soon) If the Member 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.
644
+ #
645
+ # Parameter is a [IETF BCP 47 language tag](https://www.w3.org/International/articles/language-tags/), e.g. `"en"`.
646
+ #
647
+ # Currently supported languages are English (`"en"`), Spanish (`"es"`), and Brazilian Portuguese (`"pt-br"`); if no value is provided, the copy defaults to English.
648
+ #
649
+ # Request support for additional languages [here](https://docs.google.com/forms/d/e/1FAIpQLScZSpAu_m2AmLXRT3F3kap-s_mcV6UTBitYn6CdyWP0-o7YjQ/viewform?usp=sf_link")!
650
+ #
590
651
  # The type of this field is nilable +ResetRequestLocale+ (string enum).
591
652
  #
592
653
  # == Returns:
@@ -609,12 +670,23 @@ module StytchB2B
609
670
  # organization::
610
671
  # The [Organization object](https://stytch.com/docs/b2b/api/organization-object).
611
672
  # The type of this field is +Organization+ (+object+).
673
+ # intermediate_session_token::
674
+ # The returned Intermediate Session Token contains a password factor associated with the Member.
675
+ # 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.
676
+ # Password factors are not transferable between Organizations, so the intermediate session token is not valid for use with discovery endpoints.
677
+ # The type of this field is +String+.
678
+ # member_authenticated::
679
+ # Indicates whether the Member is fully authenticated. If false, the Member needs to complete an MFA step to log in to the Organization.
680
+ # The type of this field is +Boolean+.
612
681
  # status_code::
613
682
  # 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.
614
683
  # The type of this field is +Integer+.
615
684
  # member_session::
616
685
  # The [Session object](https://stytch.com/docs/b2b/api/session-object).
617
686
  # The type of this field is nilable +MemberSession+ (+object+).
687
+ # mfa_required::
688
+ # (Coming Soon) Information about the MFA requirements of the Organization and the Member's options for fulfilling MFA.
689
+ # The type of this field is nilable +MfaRequired+ (+object+).
618
690
  def reset(
619
691
  email_address:,
620
692
  existing_password:,
@@ -108,8 +108,7 @@ module StytchB2B
108
108
  session_jwt: nil,
109
109
  session_custom_claims: nil
110
110
  )
111
- request = {
112
- }
111
+ request = {}
113
112
  request[:session_token] = session_token unless session_token.nil?
114
113
  request[:session_duration_minutes] = session_duration_minutes unless session_duration_minutes.nil?
115
114
  request[:session_jwt] = session_jwt unless session_jwt.nil?
@@ -148,8 +147,7 @@ module StytchB2B
148
147
  session_jwt: nil,
149
148
  member_id: nil
150
149
  )
151
- request = {
152
- }
150
+ request = {}
153
151
  request[:member_session_id] = member_session_id unless member_session_id.nil?
154
152
  request[:session_token] = session_token unless session_token.nil?
155
153
  request[:session_jwt] = session_jwt unless session_jwt.nil?
@@ -162,6 +160,14 @@ module StytchB2B
162
160
  #
163
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.
164
162
  #
163
+ # Only Email Magic Link, OAuth, and SMS OTP factors can be transferred between sessions. Other authentication factors, such as password factors, will not be transferred to the new session.
164
+ # SMS OTP factors can be used to fulfill MFA requirements for the target Organization if both the original and target Member have the same phone number and the phone number is verified for both Members.
165
+ #
166
+ # (Coming Soon) If the Member is required to complete MFA to log in to the Organization, the returned value of `member_authenticated` will be `false`, and an `intermediate_session_token` will be returned.
167
+ # 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.
168
+ # 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.
169
+ # The `session_duration_minutes` and `session_custom_claims` parameters will be ignored.
170
+ #
165
171
  # == Parameters:
166
172
  # organization_id::
167
173
  # 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.
@@ -191,7 +197,14 @@ module StytchB2B
191
197
  # Total custom claims size cannot exceed four kilobytes.
192
198
  # The type of this field is nilable +object+.
193
199
  # locale::
194
- # (no documentation yet)
200
+ # (Coming Soon) If the Member 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.
201
+ #
202
+ # Parameter is a [IETF BCP 47 language tag](https://www.w3.org/International/articles/language-tags/), e.g. `"en"`.
203
+ #
204
+ # Currently supported languages are English (`"en"`), Spanish (`"es"`), and Brazilian Portuguese (`"pt-br"`); if no value is provided, the copy defaults to English.
205
+ #
206
+ # Request support for additional languages [here](https://docs.google.com/forms/d/e/1FAIpQLScZSpAu_m2AmLXRT3F3kap-s_mcV6UTBitYn6CdyWP0-o7YjQ/viewform?usp=sf_link")!
207
+ #
195
208
  # The type of this field is nilable +ExchangeRequestLocale+ (string enum).
196
209
  #
197
210
  # == Returns:
@@ -217,9 +230,21 @@ module StytchB2B
217
230
  # organization::
218
231
  # The [Organization object](https://stytch.com/docs/b2b/api/organization-object).
219
232
  # The type of this field is +Organization+ (+object+).
233
+ # member_authenticated::
234
+ # Indicates whether the Member is fully authenticated. If false, the Member needs to complete an MFA step to log in to the Organization.
235
+ # The type of this field is +Boolean+.
236
+ # intermediate_session_token::
237
+ # The returned Intermediate Session Token contains any Email Magic Link or OAuth factors from the original member session that are valid for the target Organization.
238
+ # 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 target Organization.
239
+ # 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,
240
+ # or the [Create Organization via Discovery endpoint](https://stytch.com/docs/b2b/api/create-organization-via-discovery) to create a new Organization.
241
+ # The type of this field is +String+.
220
242
  # status_code::
221
243
  # 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.
222
244
  # The type of this field is +Integer+.
245
+ # mfa_required::
246
+ # (Coming Soon) Information about the MFA requirements of the Organization and the Member's options for fulfilling MFA.
247
+ # The type of this field is nilable +MfaRequired+ (+object+).
223
248
  def exchange(
224
249
  organization_id:,
225
250
  session_token: nil,
@@ -261,8 +286,7 @@ module StytchB2B
261
286
  def get_jwks(
262
287
  project_id:
263
288
  )
264
- query_params = {
265
- }
289
+ query_params = {}
266
290
  request = request_with_query_params("/v1/b2b/sessions/jwks/#{project_id}", query_params)
267
291
  get_request(request)
268
292
  end
@@ -44,8 +44,7 @@ module StytchB2B
44
44
  def get_connections(
45
45
  organization_id:
46
46
  )
47
- query_params = {
48
- }
47
+ query_params = {}
49
48
  request = request_with_query_params("/v1/b2b/sso/#{organization_id}", query_params)
50
49
  get_request(request)
51
50
  end
@@ -84,6 +83,12 @@ module StytchB2B
84
83
  # If the `session_duration_minutes` parameter is not specified, a Stytch session will be created with a 60 minute duration.
85
84
  # To link this authentication event to an existing Stytch session, include either the `session_token` or `session_jwt` param.
86
85
  #
86
+ # (Coming Soon) If the Member is required to complete MFA to log in to the Organization, the returned value of `member_authenticated` will be `false`, and an `intermediate_session_token` will be returned.
87
+ # 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.
88
+ # The `session_duration_minutes` and `session_custom_claims` parameters will be ignored.
89
+ #
90
+ # If a valid `session_token` or `session_jwt` is passed in, the Member will not be required to complete an MFA step.
91
+ #
87
92
  # == Parameters:
88
93
  # sso_token::
89
94
  # The token to authenticate.
@@ -116,7 +121,14 @@ module StytchB2B
116
121
  # Total custom claims size cannot exceed four kilobytes.
117
122
  # The type of this field is nilable +object+.
118
123
  # locale::
119
- # (no documentation yet)
124
+ # (Coming Soon) If the Member 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.
125
+ #
126
+ # Parameter is a [IETF BCP 47 language tag](https://www.w3.org/International/articles/language-tags/), e.g. `"en"`.
127
+ #
128
+ # Currently supported languages are English (`"en"`), Spanish (`"es"`), and Brazilian Portuguese (`"pt-br"`); if no value is provided, the copy defaults to English.
129
+ #
130
+ # Request support for additional languages [here](https://docs.google.com/forms/d/e/1FAIpQLScZSpAu_m2AmLXRT3F3kap-s_mcV6UTBitYn6CdyWP0-o7YjQ/viewform?usp=sf_link")!
131
+ #
120
132
  # The type of this field is nilable +AuthenticateRequestLocale+ (string enum).
121
133
  #
122
134
  # == Returns:
@@ -146,12 +158,23 @@ module StytchB2B
146
158
  # organization::
147
159
  # The [Organization object](https://stytch.com/docs/b2b/api/organization-object).
148
160
  # The type of this field is +Organization+ (+object+).
161
+ # intermediate_session_token::
162
+ # The returned Intermediate Session Token contains an SSO factor associated with the Member.
163
+ # 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.
164
+ # SSO factors are not transferable between Organizations, so the intermediate session token is not valid for use with discovery endpoints.
165
+ # The type of this field is +String+.
166
+ # member_authenticated::
167
+ # Indicates whether the Member is fully authenticated. If false, the Member needs to complete an MFA step to log in to the Organization.
168
+ # The type of this field is +Boolean+.
149
169
  # status_code::
150
170
  # 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.
151
171
  # The type of this field is +Integer+.
152
172
  # member_session::
153
173
  # The [Session object](https://stytch.com/docs/b2b/api/session-object).
154
174
  # The type of this field is nilable +MemberSession+ (+object+).
175
+ # mfa_required::
176
+ # (Coming Soon) Information about the MFA requirements of the Organization and the Member's options for fulfilling MFA.
177
+ # The type of this field is nilable +MfaRequired+ (+object+).
155
178
  def authenticate(
156
179
  sso_token:,
157
180
  pkce_code_verifier: nil,
@@ -206,8 +229,7 @@ module StytchB2B
206
229
  organization_id:,
207
230
  display_name: nil
208
231
  )
209
- request = {
210
- }
232
+ request = {}
211
233
  request[:display_name] = display_name unless display_name.nil?
212
234
 
213
235
  post_request("/v1/b2b/sso/oidc/#{organization_id}", request)
@@ -290,8 +312,7 @@ module StytchB2B
290
312
  userinfo_url: nil,
291
313
  jwks_url: nil
292
314
  )
293
- request = {
294
- }
315
+ request = {}
295
316
  request[:display_name] = display_name unless display_name.nil?
296
317
  request[:client_id] = client_id unless client_id.nil?
297
318
  request[:client_secret] = client_secret unless client_secret.nil?
@@ -337,8 +358,7 @@ module StytchB2B
337
358
  organization_id:,
338
359
  display_name: nil
339
360
  )
340
- request = {
341
- }
361
+ request = {}
342
362
  request[:display_name] = display_name unless display_name.nil?
343
363
 
344
364
  post_request("/v1/b2b/sso/saml/#{organization_id}", request)
@@ -395,8 +415,7 @@ module StytchB2B
395
415
  x509_certificate: nil,
396
416
  idp_sso_url: nil
397
417
  )
398
- request = {
399
- }
418
+ request = {}
400
419
  request[:idp_entity_id] = idp_entity_id unless idp_entity_id.nil?
401
420
  request[:display_name] = display_name unless display_name.nil?
402
421
  request[:attribute_mapping] = attribute_mapping unless attribute_mapping.nil?
data/lib/stytch/client.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'crypto_wallets'
4
+ require_relative 'm2m'
4
5
  require_relative 'magic_links'
5
6
  require_relative 'oauth'
6
7
  require_relative 'otps'
@@ -14,7 +15,7 @@ module Stytch
14
15
  class Client
15
16
  ENVIRONMENTS = %i[live test].freeze
16
17
 
17
- attr_reader :crypto_wallets, :magic_links, :oauth, :otps, :passwords, :sessions, :totps, :users, :webauthn
18
+ attr_reader :crypto_wallets, :m2m, :magic_links, :oauth, :otps, :passwords, :sessions, :totps, :users, :webauthn
18
19
 
19
20
  def initialize(project_id:, secret:, env: nil, &block)
20
21
  @api_host = api_host(env, project_id)
@@ -24,6 +25,7 @@ module Stytch
24
25
  create_connection(&block)
25
26
 
26
27
  @crypto_wallets = Stytch::CryptoWallets.new(@connection)
28
+ @m2m = Stytch::M2M.new(@connection, project_id)
27
29
  @magic_links = Stytch::MagicLinks.new(@connection)
28
30
  @oauth = Stytch::OAuth.new(@connection)
29
31
  @otps = Stytch::OTPs.new(@connection)