stytch 6.0.0 → 6.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -21,7 +21,7 @@ module StytchB2B
21
21
 
22
22
  # Creates an Organization. An `organization_name` and a unique `organization_slug` are required.
23
23
  #
24
- # By default, `email_invites` and `sso_jit_provisioning` will be set to `ALL_ALLOWED` if no Organization authentication settings are explicitly defined in the request.
24
+ # By default, `email_invites` and `sso_jit_provisioning` will be set to `ALL_ALLOWED`, and `mfa_policy` will be set to `OPTIONAL` if no Organization authentication settings are explicitly defined in the request.
25
25
  #
26
26
  # *See the [Organization authentication settings](https://stytch.com/docs/b2b/api/org-auth-settings) resource to learn more about fields like `email_jit_provisioning`, `email_invites`, `sso_jit_provisioning`, etc., and their behaviors.
27
27
  #
@@ -86,6 +86,14 @@ module StytchB2B
86
86
  # The list's accepted values are: `sso`, `magic_link`, `password`, `google_oauth`, and `microsoft_oauth`.
87
87
  #
88
88
  # The type of this field is nilable list of +String+.
89
+ # mfa_policy::
90
+ # (Coming Soon) The setting that controls the MFA policy for all Members in the Organization. The accepted values are:
91
+ #
92
+ # `REQUIRED_FOR_ALL` – All Members within the Organization will be required to complete MFA every time they wish to log in.
93
+ #
94
+ # `OPTIONAL` – The default value. The Organization does not require MFA by default for all Members. Members will be required to complete MFA only if their `mfa_enrolled` status is set to true.
95
+ #
96
+ # The type of this field is nilable +String+.
89
97
  #
90
98
  # == Returns:
91
99
  # An object with the following fields:
@@ -108,7 +116,8 @@ module StytchB2B
108
116
  email_jit_provisioning: nil,
109
117
  email_invites: nil,
110
118
  auth_methods: nil,
111
- allowed_auth_methods: nil
119
+ allowed_auth_methods: nil,
120
+ mfa_policy: nil
112
121
  )
113
122
  request = {
114
123
  organization_name: organization_name
@@ -122,6 +131,7 @@ module StytchB2B
122
131
  request[:email_invites] = email_invites unless email_invites.nil?
123
132
  request[:auth_methods] = auth_methods unless auth_methods.nil?
124
133
  request[:allowed_auth_methods] = allowed_auth_methods unless allowed_auth_methods.nil?
134
+ request[:mfa_policy] = mfa_policy unless mfa_policy.nil?
125
135
 
126
136
  post_request('/v1/b2b/organizations', request)
127
137
  end
@@ -227,6 +237,14 @@ module StytchB2B
227
237
  # The list's accepted values are: `sso`, `magic_link`, `password`, `google_oauth`, and `microsoft_oauth`.
228
238
  #
229
239
  # The type of this field is nilable list of +String+.
240
+ # mfa_policy::
241
+ # (Coming Soon) The setting that controls the MFA policy for all Members in the Organization. The accepted values are:
242
+ #
243
+ # `REQUIRED_FOR_ALL` – All Members within the Organization will be required to complete MFA every time they wish to log in.
244
+ #
245
+ # `OPTIONAL` – The default value. The Organization does not require MFA by default for all Members. Members will be required to complete MFA only if their `mfa_enrolled` status is set to true.
246
+ #
247
+ # The type of this field is nilable +String+.
230
248
  #
231
249
  # == Returns:
232
250
  # An object with the following fields:
@@ -252,7 +270,8 @@ module StytchB2B
252
270
  email_jit_provisioning: nil,
253
271
  email_invites: nil,
254
272
  auth_methods: nil,
255
- allowed_auth_methods: nil
273
+ allowed_auth_methods: nil,
274
+ mfa_policy: nil
256
275
  )
257
276
  request = {}
258
277
  request[:organization_name] = organization_name unless organization_name.nil?
@@ -270,6 +289,7 @@ module StytchB2B
270
289
  request[:email_invites] = email_invites unless email_invites.nil?
271
290
  request[:auth_methods] = auth_methods unless auth_methods.nil?
272
291
  request[:allowed_auth_methods] = allowed_auth_methods unless allowed_auth_methods.nil?
292
+ request[:mfa_policy] = mfa_policy unless mfa_policy.nil?
273
293
 
274
294
  put_request("/v1/b2b/organizations/#{organization_id}", request)
275
295
  end
@@ -368,6 +388,12 @@ module StytchB2B
368
388
  # is_breakglass::
369
389
  # Identifies the Member as a break glass user - someone who has permissions to authenticate into an Organization by bypassing the Organization's settings. A break glass account is typically used for emergency purposes to gain access outside of normal authentication procedures. Refer to the [Organization object](organization-object) and its `auth_methods` and `allowed_auth_methods` fields for more details.
370
390
  # The type of this field is nilable +Boolean+.
391
+ # mfa_phone_number::
392
+ # (no documentation yet)
393
+ # The type of this field is nilable +String+.
394
+ # mfa_enrolled::
395
+ # (Coming Soon) Sets whether the Member is enrolled in MFA. If true, the Member must complete an MFA step whenever they wish to log in to their Organization. If false, the Member only needs to complete an MFA step if the Organization's MFA policy is set to `REQUIRED_FOR_ALL`.
396
+ # The type of this field is nilable +Boolean+.
371
397
  #
372
398
  # == Returns:
373
399
  # An object with the following fields:
@@ -392,13 +418,17 @@ module StytchB2B
392
418
  name: nil,
393
419
  trusted_metadata: nil,
394
420
  untrusted_metadata: nil,
395
- is_breakglass: nil
421
+ is_breakglass: nil,
422
+ mfa_phone_number: nil,
423
+ mfa_enrolled: nil
396
424
  )
397
425
  request = {}
398
426
  request[:name] = name unless name.nil?
399
427
  request[:trusted_metadata] = trusted_metadata unless trusted_metadata.nil?
400
428
  request[:untrusted_metadata] = untrusted_metadata unless untrusted_metadata.nil?
401
429
  request[:is_breakglass] = is_breakglass unless is_breakglass.nil?
430
+ request[:mfa_phone_number] = mfa_phone_number unless mfa_phone_number.nil?
431
+ request[:mfa_enrolled] = mfa_enrolled unless mfa_enrolled.nil?
402
432
 
403
433
  put_request("/v1/b2b/organizations/#{organization_id}/members/#{member_id}", request)
404
434
  end
@@ -431,6 +461,13 @@ module StytchB2B
431
461
  delete_request("/v1/b2b/organizations/#{organization_id}/members/#{member_id}")
432
462
  end
433
463
 
464
+ def delete_mfa_phone_number(
465
+ organization_id:,
466
+ member_id:
467
+ )
468
+ delete_request("/v1/b2b/organizations/#{organization_id}/members/mfa_phone_numbers/#{member_id}")
469
+ end
470
+
434
471
  # Search for Members within specified Organizations. An array with at least one `organization_id` is required. Submitting an empty `query` returns all Members within the specified Organizations.
435
472
  #
436
473
  # *All fuzzy search filters require a minimum of three characters.
@@ -446,7 +483,7 @@ module StytchB2B
446
483
  # The number of search results to return per page. The default limit is 100. A maximum of 1000 results can be returned by a single search request. If the total size of your result set is greater than one page size, you must paginate the response. See the `cursor` field.
447
484
  # The type of this field is nilable +Integer+.
448
485
  # query::
449
- # The optional query object contains the operator, i.e. `AND` or `OR`, and the operands that will filter your results. Only an operator is required. If you include no operands, no filtering will be applied. If you include no query object, it will return all Organizations with no filtering applied.
486
+ # The optional query object contains the operator, i.e. `AND` or `OR`, and the operands that will filter your results. Only an operator is required. If you include no operands, no filtering will be applied. If you include no query object, it will return all Members with no filtering applied.
450
487
  # The type of this field is nilable +SearchQuery+ (+object+).
451
488
  #
452
489
  # == Returns:
@@ -542,6 +579,12 @@ module StytchB2B
542
579
  # is_breakglass::
543
580
  # Identifies the Member as a break glass user - someone who has permissions to authenticate into an Organization by bypassing the Organization's settings. A break glass account is typically used for emergency purposes to gain access outside of normal authentication procedures. Refer to the [Organization object](organization-object) and its `auth_methods` and `allowed_auth_methods` fields for more details.
544
581
  # The type of this field is nilable +Boolean+.
582
+ # mfa_phone_number::
583
+ # (no documentation yet)
584
+ # The type of this field is nilable +String+.
585
+ # mfa_enrolled::
586
+ # (Coming Soon) Sets whether the Member is enrolled in MFA. If true, the Member must complete an MFA step whenever they wish to log in to their Organization. If false, the Member only needs to complete an MFA step if the Organization's MFA policy is set to `REQUIRED_FOR_ALL`.
587
+ # The type of this field is nilable +Boolean+.
545
588
  #
546
589
  # == Returns:
547
590
  # An object with the following fields:
@@ -567,7 +610,9 @@ module StytchB2B
567
610
  trusted_metadata: nil,
568
611
  untrusted_metadata: nil,
569
612
  create_member_as_pending: nil,
570
- is_breakglass: nil
613
+ is_breakglass: nil,
614
+ mfa_phone_number: nil,
615
+ mfa_enrolled: nil
571
616
  )
572
617
  request = {
573
618
  email_address: email_address
@@ -577,6 +622,8 @@ module StytchB2B
577
622
  request[:untrusted_metadata] = untrusted_metadata unless untrusted_metadata.nil?
578
623
  request[:create_member_as_pending] = create_member_as_pending unless create_member_as_pending.nil?
579
624
  request[:is_breakglass] = is_breakglass unless is_breakglass.nil?
625
+ request[:mfa_phone_number] = mfa_phone_number unless mfa_phone_number.nil?
626
+ request[:mfa_enrolled] = mfa_enrolled unless mfa_enrolled.nil?
580
627
 
581
628
  post_request("/v1/b2b/organizations/#{organization_id}/members", request)
582
629
  end
@@ -0,0 +1,200 @@
1
+ # frozen_string_literal: true
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
+
9
+ require_relative 'request_helper'
10
+
11
+ module StytchB2B
12
+ class OTPs
13
+ include Stytch::RequestHelper
14
+ attr_reader :sms
15
+
16
+ def initialize(connection)
17
+ @connection = connection
18
+
19
+ @sms = StytchB2B::OTPs::Sms.new(@connection)
20
+ end
21
+
22
+ class Sms
23
+ include Stytch::RequestHelper
24
+
25
+ def initialize(connection)
26
+ @connection = connection
27
+ end
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+.
72
+ def send(
73
+ organization_id:,
74
+ member_id:,
75
+ mfa_phone_number: nil,
76
+ locale: nil
77
+ )
78
+ request = {
79
+ organization_id: organization_id,
80
+ member_id: member_id
81
+ }
82
+ request[:mfa_phone_number] = mfa_phone_number unless mfa_phone_number.nil?
83
+ request[:locale] = locale unless locale.nil?
84
+
85
+ post_request('/v1/b2b/otps/sms/send', request)
86
+ end
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+).
173
+ def authenticate(
174
+ organization_id:,
175
+ member_id:,
176
+ code:,
177
+ intermediate_session_token: nil,
178
+ session_token: nil,
179
+ session_jwt: nil,
180
+ session_duration_minutes: nil,
181
+ session_custom_claims: nil,
182
+ set_mfa_enrollment: nil
183
+ )
184
+ request = {
185
+ organization_id: organization_id,
186
+ member_id: member_id,
187
+ code: code
188
+ }
189
+ request[:intermediate_session_token] = intermediate_session_token unless intermediate_session_token.nil?
190
+ request[:session_token] = session_token unless session_token.nil?
191
+ request[:session_jwt] = session_jwt unless session_jwt.nil?
192
+ request[:session_duration_minutes] = session_duration_minutes unless session_duration_minutes.nil?
193
+ request[:session_custom_claims] = session_custom_claims unless session_custom_claims.nil?
194
+ request[:set_mfa_enrollment] = set_mfa_enrollment unless set_mfa_enrollment.nil?
195
+
196
+ post_request('/v1/b2b/otps/sms/authenticate', request)
197
+ end
198
+ end
199
+ end
200
+ end
@@ -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::
@@ -97,7 +97,7 @@ module StytchB2B
97
97
  # The type of this field is +String+.
98
98
  # hash_type::
99
99
  # The password hash used. Currently `bcrypt`, `scrypt`, `argon2i`, `argon2id`, `md_5`, `sha_1`, and `pbkdf_2` are supported.
100
- # The type of this field is +MigrateRequestHashType+ (+object+).
100
+ # The type of this field is +MigrateRequestHashType+ (string enum).
101
101
  # organization_id::
102
102
  # 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.
103
103
  # The type of this field is +String+.
@@ -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.
@@ -221,6 +227,16 @@ module StytchB2B
221
227
  # delete a key, supply a null value. Custom claims made with reserved claims (`iss`, `sub`, `aud`, `exp`, `nbf`, `iat`, `jti`) will be ignored.
222
228
  # Total custom claims size cannot exceed four kilobytes.
223
229
  # The type of this field is nilable +object+.
230
+ # locale::
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
+ #
239
+ # The type of this field is nilable +AuthenticateRequestLocale+ (string enum).
224
240
  #
225
241
  # == Returns:
226
242
  # An object with the following fields:
@@ -245,12 +261,23 @@ module StytchB2B
245
261
  # organization::
246
262
  # The [Organization object](https://stytch.com/docs/b2b/api/organization-object).
247
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+.
248
272
  # status_code::
249
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.
250
274
  # The type of this field is +Integer+.
251
275
  # member_session::
252
276
  # The [Session object](https://stytch.com/docs/b2b/api/session-object).
253
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+).
254
281
  def authenticate(
255
282
  organization_id:,
256
283
  email_address:,
@@ -258,7 +285,8 @@ module StytchB2B
258
285
  session_token: nil,
259
286
  session_duration_minutes: nil,
260
287
  session_jwt: nil,
261
- session_custom_claims: nil
288
+ session_custom_claims: nil,
289
+ locale: nil
262
290
  )
263
291
  request = {
264
292
  organization_id: organization_id,
@@ -269,6 +297,7 @@ module StytchB2B
269
297
  request[:session_duration_minutes] = session_duration_minutes unless session_duration_minutes.nil?
270
298
  request[:session_jwt] = session_jwt unless session_jwt.nil?
271
299
  request[:session_custom_claims] = session_custom_claims unless session_custom_claims.nil?
300
+ request[:locale] = locale unless locale.nil?
272
301
 
273
302
  post_request('/v1/b2b/passwords/authenticate', request)
274
303
  end
@@ -283,8 +312,8 @@ module StytchB2B
283
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.
284
313
  #
285
314
  # This endpoint adapts to your Project's password strength configuration.
286
- # If you're using [zxcvbn](https://stytch.com/docs/passwords#strength-requirements), the default, your passwords are considered valid
287
- # 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
288
317
  # considered valid if they meet the requirements that you've set with Stytch.
289
318
  # You may update your password strength configuration in the [stytch dashboard](https://stytch.com/dashboard/password-strength-config).
290
319
  #
@@ -319,7 +348,7 @@ module StytchB2B
319
348
  #
320
349
  # Request support for additional languages [here](https://docs.google.com/forms/d/e/1FAIpQLScZSpAu_m2AmLXRT3F3kap-s_mcV6UTBitYn6CdyWP0-o7YjQ/viewform?usp=sf_link")!
321
350
  #
322
- # The type of this field is nilable +ResetStartRequestLocale+ (+object+).
351
+ # The type of this field is nilable +ResetStartRequestLocale+ (string enum).
323
352
  # reset_password_template_id::
324
353
  # Use a custom template for reset password emails. By default, it will use your default email template. The template must be a template using our built-in customizations or a custom HTML email for Magic Links - Reset Password.
325
354
  # The type of this field is nilable +String+.
@@ -369,6 +398,12 @@ module StytchB2B
369
398
  #
370
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.
371
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
+ #
372
407
  # == Parameters:
373
408
  # password_reset_token::
374
409
  # The password reset token to authenticate.
@@ -407,6 +442,16 @@ module StytchB2B
407
442
  # delete a key, supply a null value. Custom claims made with reserved claims (`iss`, `sub`, `aud`, `exp`, `nbf`, `iat`, `jti`) will be ignored.
408
443
  # Total custom claims size cannot exceed four kilobytes.
409
444
  # The type of this field is nilable +object+.
445
+ # locale::
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
+ #
454
+ # The type of this field is nilable +ResetRequestLocale+ (string enum).
410
455
  #
411
456
  # == Returns:
412
457
  # An object with the following fields:
@@ -434,12 +479,23 @@ module StytchB2B
434
479
  # organization::
435
480
  # The [Organization object](https://stytch.com/docs/b2b/api/organization-object).
436
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+.
437
490
  # status_code::
438
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.
439
492
  # The type of this field is +Integer+.
440
493
  # member_session::
441
494
  # The [Session object](https://stytch.com/docs/b2b/api/session-object).
442
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+).
443
499
  def reset(
444
500
  password_reset_token:,
445
501
  password:,
@@ -447,7 +503,8 @@ module StytchB2B
447
503
  session_duration_minutes: nil,
448
504
  session_jwt: nil,
449
505
  code_verifier: nil,
450
- session_custom_claims: nil
506
+ session_custom_claims: nil,
507
+ locale: nil
451
508
  )
452
509
  request = {
453
510
  password_reset_token: password_reset_token,
@@ -458,6 +515,7 @@ module StytchB2B
458
515
  request[:session_jwt] = session_jwt unless session_jwt.nil?
459
516
  request[:code_verifier] = code_verifier unless code_verifier.nil?
460
517
  request[:session_custom_claims] = session_custom_claims unless session_custom_claims.nil?
518
+ request[:locale] = locale unless locale.nil?
461
519
 
462
520
  post_request('/v1/b2b/passwords/email/reset', request)
463
521
  end
@@ -533,11 +591,17 @@ module StytchB2B
533
591
  # Reset the member’s password using their existing password.
534
592
  #
535
593
  # This endpoint adapts to your Project's password strength configuration.
536
- # If you're using [zxcvbn](https://stytch.com/docs/passwords#strength-requirements), the default, your passwords are considered valid
537
- # 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
538
596
  # considered valid if they meet the requirements that you've set with Stytch.
539
597
  # You may update your password strength configuration in the [stytch dashboard](https://stytch.com/dashboard/password-strength-config).
540
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
+ #
541
605
  # == Parameters:
542
606
  # email_address::
543
607
  # The email address of the Member.
@@ -575,6 +639,16 @@ module StytchB2B
575
639
  # delete a key, supply a null value. Custom claims made with reserved claims (`iss`, `sub`, `aud`, `exp`, `nbf`, `iat`, `jti`) will be ignored.
576
640
  # Total custom claims size cannot exceed four kilobytes.
577
641
  # The type of this field is nilable +object+.
642
+ # locale::
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
+ #
651
+ # The type of this field is nilable +ResetRequestLocale+ (string enum).
578
652
  #
579
653
  # == Returns:
580
654
  # An object with the following fields:
@@ -596,12 +670,23 @@ module StytchB2B
596
670
  # organization::
597
671
  # The [Organization object](https://stytch.com/docs/b2b/api/organization-object).
598
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+.
599
681
  # status_code::
600
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.
601
683
  # The type of this field is +Integer+.
602
684
  # member_session::
603
685
  # The [Session object](https://stytch.com/docs/b2b/api/session-object).
604
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+).
605
690
  def reset(
606
691
  email_address:,
607
692
  existing_password:,
@@ -610,7 +695,8 @@ module StytchB2B
610
695
  session_token: nil,
611
696
  session_duration_minutes: nil,
612
697
  session_jwt: nil,
613
- session_custom_claims: nil
698
+ session_custom_claims: nil,
699
+ locale: nil
614
700
  )
615
701
  request = {
616
702
  email_address: email_address,
@@ -622,6 +708,7 @@ module StytchB2B
622
708
  request[:session_duration_minutes] = session_duration_minutes unless session_duration_minutes.nil?
623
709
  request[:session_jwt] = session_jwt unless session_jwt.nil?
624
710
  request[:session_custom_claims] = session_custom_claims unless session_custom_claims.nil?
711
+ request[:locale] = locale unless locale.nil?
625
712
 
626
713
  post_request('/v1/b2b/passwords/existing_password/reset', request)
627
714
  end