stytch 5.0.2 → 6.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/lib/stytch/b2b_client.rb +7 -1
- data/lib/stytch/b2b_discovery.rb +243 -3
- data/lib/stytch/b2b_magic_links.rb +276 -1
- data/lib/stytch/b2b_oauth.rb +202 -0
- data/lib/stytch/b2b_organizations.rb +513 -48
- data/lib/stytch/b2b_otp.rb +72 -0
- data/lib/stytch/b2b_passwords.rb +453 -3
- data/lib/stytch/b2b_sessions.rb +192 -5
- data/lib/stytch/b2b_sso.rb +302 -8
- data/lib/stytch/client.rb +9 -9
- data/lib/stytch/crypto_wallets.rb +112 -13
- data/lib/stytch/errors.rb +16 -16
- data/lib/stytch/magic_links.rb +350 -56
- data/lib/stytch/oauth.rb +129 -22
- data/lib/stytch/otps.rb +454 -71
- data/lib/stytch/passwords.rb +513 -67
- data/lib/stytch/sessions.rb +152 -40
- data/lib/stytch/totps.rb +193 -13
- data/lib/stytch/users.rb +427 -96
- data/lib/stytch/version.rb +1 -1
- data/lib/stytch/webauthn.rb +156 -10
- data/lib/stytch.rb +1 -0
- metadata +4 -2
@@ -0,0 +1,72 @@
|
|
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
|
+
def send(
|
30
|
+
organization_id:,
|
31
|
+
member_id:,
|
32
|
+
phone_number: nil,
|
33
|
+
locale: nil
|
34
|
+
)
|
35
|
+
request = {
|
36
|
+
organization_id: organization_id,
|
37
|
+
member_id: member_id
|
38
|
+
}
|
39
|
+
request[:phone_number] = phone_number unless phone_number.nil?
|
40
|
+
request[:locale] = locale unless locale.nil?
|
41
|
+
|
42
|
+
post_request('/v1/b2b/otps/sms/send', request)
|
43
|
+
end
|
44
|
+
|
45
|
+
def authenticate(
|
46
|
+
organization_id:,
|
47
|
+
member_id:,
|
48
|
+
code:,
|
49
|
+
intermediate_session_token: nil,
|
50
|
+
session_token: nil,
|
51
|
+
session_jwt: nil,
|
52
|
+
session_duration_minutes: nil,
|
53
|
+
session_custom_claims: nil,
|
54
|
+
set_mfa_enrollment: nil
|
55
|
+
)
|
56
|
+
request = {
|
57
|
+
organization_id: organization_id,
|
58
|
+
member_id: member_id,
|
59
|
+
code: code
|
60
|
+
}
|
61
|
+
request[:intermediate_session_token] = intermediate_session_token unless intermediate_session_token.nil?
|
62
|
+
request[:session_token] = session_token unless session_token.nil?
|
63
|
+
request[:session_jwt] = session_jwt unless session_jwt.nil?
|
64
|
+
request[:session_duration_minutes] = session_duration_minutes unless session_duration_minutes.nil?
|
65
|
+
request[:session_custom_claims] = session_custom_claims unless session_custom_claims.nil?
|
66
|
+
request[:set_mfa_enrollment] = set_mfa_enrollment unless set_mfa_enrollment.nil?
|
67
|
+
|
68
|
+
post_request('/v1/b2b/otps/sms/authenticate', request)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
data/lib/stytch/b2b_passwords.rb
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# !!!
|
4
|
+
# WARNING: This file is autogenerated
|
5
|
+
# Only modify code within MANUAL() sections
|
6
|
+
# or your changes may be overwritten later!
|
7
|
+
# !!!
|
8
|
+
|
3
9
|
require_relative 'request_helper'
|
4
10
|
|
5
11
|
module StytchB2B
|
@@ -15,6 +21,59 @@ module StytchB2B
|
|
15
21
|
@existing_password = StytchB2B::Passwords::ExistingPassword.new(@connection)
|
16
22
|
end
|
17
23
|
|
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
|
+
#
|
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).
|
27
|
+
#
|
28
|
+
# ## Password feedback
|
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
|
+
#
|
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.
|
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.
|
34
|
+
#
|
35
|
+
# == Parameters:
|
36
|
+
# password::
|
37
|
+
# The password to authenticate.
|
38
|
+
# The type of this field is +String+.
|
39
|
+
# email_address::
|
40
|
+
# The email address of the Member.
|
41
|
+
# The type of this field is nilable +String+.
|
42
|
+
#
|
43
|
+
# == Returns:
|
44
|
+
# An object with the following fields:
|
45
|
+
# request_id::
|
46
|
+
# 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.
|
47
|
+
# The type of this field is +String+.
|
48
|
+
# valid_password::
|
49
|
+
# Returns `true` if the password passes our password validation. We offer two validation options,
|
50
|
+
# [zxcvbn](https://stytch.com/docs/passwords#strength-requirements) is the default option which offers a high level of sophistication.
|
51
|
+
# We also offer [LUDS](https://stytch.com/docs/passwords#strength-requirements). If an email address is included in the call we also
|
52
|
+
# require that the password hasn't been compromised using built-in breach detection powered by [HaveIBeenPwned](https://haveibeenpwned.com/)
|
53
|
+
# The type of this field is +Boolean+.
|
54
|
+
# score::
|
55
|
+
# The score of the password determined by [zxcvbn](https://github.com/dropbox/zxcvbn). Values will be between 1 and 4, a 3 or greater is required to pass validation.
|
56
|
+
# The type of this field is +Integer+.
|
57
|
+
# breached_password::
|
58
|
+
# Returns `true` if the password has been breached. Powered by [HaveIBeenPwned](https://haveibeenpwned.com/).
|
59
|
+
# The type of this field is +Boolean+.
|
60
|
+
# strength_policy::
|
61
|
+
# The strength policy type enforced, either `zxcvbn` or `luds`.
|
62
|
+
# The type of this field is +String+.
|
63
|
+
# breach_detection_on_create::
|
64
|
+
# Will return `true` if breach detection will be evaluated. By default this option is enabled.
|
65
|
+
# This option can be disabled by contacting [support@stytch.com](mailto:support@stytch.com?subject=Password%20strength%20configuration).
|
66
|
+
# If this value is false then `breached_password` will always be `false` as well.
|
67
|
+
# The type of this field is +Boolean+.
|
68
|
+
# status_code::
|
69
|
+
# 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.
|
70
|
+
# The type of this field is +Integer+.
|
71
|
+
# luds_feedback::
|
72
|
+
# Feedback for how to improve the password's strength using [luds](https://stytch.com/docs/passwords#strength-requirements).
|
73
|
+
# The type of this field is nilable +LudsFeedback+ (+object+).
|
74
|
+
# zxcvbn_feedback::
|
75
|
+
# Feedback for how to improve the password's strength using [zxcvbn](https://stytch.com/docs/passwords#strength-requirements).
|
76
|
+
# The type of this field is nilable +ZxcvbnFeedback+ (+object+).
|
18
77
|
def strength_check(
|
19
78
|
password:,
|
20
79
|
email_address: nil
|
@@ -27,6 +86,68 @@ module StytchB2B
|
|
27
86
|
post_request('/v1/b2b/passwords/strength_check', request)
|
28
87
|
end
|
29
88
|
|
89
|
+
# Adds an existing password to a member's email that doesn't have a password yet. We support migrating members from passwords stored with bcrypt, scrypt, argon2, MD-5, SHA-1, and PBKDF2. This endpoint has a rate limit of 100 requests per second.
|
90
|
+
#
|
91
|
+
# == Parameters:
|
92
|
+
# email_address::
|
93
|
+
# The email address of the Member.
|
94
|
+
# The type of this field is +String+.
|
95
|
+
# hash::
|
96
|
+
# The password hash. For a Scrypt or PBKDF2 hash, the hash needs to be a base64 encoded string.
|
97
|
+
# The type of this field is +String+.
|
98
|
+
# hash_type::
|
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+ (string enum).
|
101
|
+
# organization_id::
|
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
|
+
# The type of this field is +String+.
|
104
|
+
# md_5_config::
|
105
|
+
# Optional parameters for MD-5 hash types.
|
106
|
+
# The type of this field is nilable +MD5Config+ (+object+).
|
107
|
+
# argon_2_config::
|
108
|
+
# Required parameters if the argon2 hex form, as opposed to the encoded form, is supplied.
|
109
|
+
# The type of this field is nilable +Argon2Config+ (+object+).
|
110
|
+
# sha_1_config::
|
111
|
+
# Optional parameters for SHA-1 hash types.
|
112
|
+
# The type of this field is nilable +SHA1Config+ (+object+).
|
113
|
+
# scrypt_config::
|
114
|
+
# Required parameters if the scrypt is not provided in a **PHC encoded form**.
|
115
|
+
# The type of this field is nilable +ScryptConfig+ (+object+).
|
116
|
+
# pbkdf_2_config::
|
117
|
+
# Required additional parameters for PBKDF2 hash keys. Note that we use the SHA-256 by default, please contact [support@stytch.com](mailto:support@stytch.com) if you use another hashing function.
|
118
|
+
# The type of this field is nilable +PBKDF2Config+ (+object+).
|
119
|
+
# name::
|
120
|
+
# The name of the Member. Each field in the name object is optional.
|
121
|
+
# The type of this field is nilable +String+.
|
122
|
+
# trusted_metadata::
|
123
|
+
# An arbitrary JSON object for storing application-specific data or identity-provider-specific data.
|
124
|
+
# The type of this field is nilable +object+.
|
125
|
+
# untrusted_metadata::
|
126
|
+
# An arbitrary JSON object of application-specific data. These fields can be edited directly by the
|
127
|
+
# frontend SDK, and should not be used to store critical information. See the [Metadata resource](https://stytch.com/docs/b2b/api/metadata)
|
128
|
+
# for complete field behavior details.
|
129
|
+
# The type of this field is nilable +object+.
|
130
|
+
#
|
131
|
+
# == Returns:
|
132
|
+
# An object with the following fields:
|
133
|
+
# request_id::
|
134
|
+
# 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.
|
135
|
+
# The type of this field is +String+.
|
136
|
+
# member_id::
|
137
|
+
# Globally unique UUID that identifies a specific Member.
|
138
|
+
# The type of this field is +String+.
|
139
|
+
# member_created::
|
140
|
+
# A flag indicating `true` if a new Member object was created and `false` if the Member object already existed.
|
141
|
+
# The type of this field is +Boolean+.
|
142
|
+
# member::
|
143
|
+
# The [Member object](https://stytch.com/docs/b2b/api/member-object).
|
144
|
+
# The type of this field is +Member+ (+object+).
|
145
|
+
# organization::
|
146
|
+
# The [Organization object](https://stytch.com/docs/b2b/api/organization-object).
|
147
|
+
# The type of this field is +Organization+ (+object+).
|
148
|
+
# status_code::
|
149
|
+
# 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.
|
150
|
+
# The type of this field is +Integer+.
|
30
151
|
def migrate(
|
31
152
|
email_address:,
|
32
153
|
hash:,
|
@@ -36,6 +157,7 @@ module StytchB2B
|
|
36
157
|
argon_2_config: nil,
|
37
158
|
sha_1_config: nil,
|
38
159
|
scrypt_config: nil,
|
160
|
+
pbkdf_2_config: nil,
|
39
161
|
name: nil,
|
40
162
|
trusted_metadata: nil,
|
41
163
|
untrusted_metadata: nil
|
@@ -50,6 +172,7 @@ module StytchB2B
|
|
50
172
|
request[:argon_2_config] = argon_2_config unless argon_2_config.nil?
|
51
173
|
request[:sha_1_config] = sha_1_config unless sha_1_config.nil?
|
52
174
|
request[:scrypt_config] = scrypt_config unless scrypt_config.nil?
|
175
|
+
request[:pbkdf_2_config] = pbkdf_2_config unless pbkdf_2_config.nil?
|
53
176
|
request[:name] = name unless name.nil?
|
54
177
|
request[:trusted_metadata] = trusted_metadata unless trusted_metadata.nil?
|
55
178
|
request[:untrusted_metadata] = untrusted_metadata unless untrusted_metadata.nil?
|
@@ -57,6 +180,80 @@ module StytchB2B
|
|
57
180
|
post_request('/v1/b2b/passwords/migrate', request)
|
58
181
|
end
|
59
182
|
|
183
|
+
# Authenticate a member with their email address and password. This endpoint verifies that the member has a password currently set, and that the entered password is correct. There are two instances where the endpoint will return a reset_password error even if they enter their previous password:
|
184
|
+
# * The member’s credentials appeared in the HaveIBeenPwned dataset.
|
185
|
+
# * We force a password reset to ensure that the member is the legitimate owner of the email address, and not a malicious actor abusing the compromised credentials.
|
186
|
+
# * A member that has previously authenticated with email/password uses a passwordless authentication method tied to the same email address (e.g. Magic Links) for the first time. Any subsequent email/password authentication attempt will result in this error.
|
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
|
+
# * 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
|
+
#
|
190
|
+
# == Parameters:
|
191
|
+
# organization_id::
|
192
|
+
# 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.
|
193
|
+
# The type of this field is +String+.
|
194
|
+
# email_address::
|
195
|
+
# The email address of the Member.
|
196
|
+
# The type of this field is +String+.
|
197
|
+
# password::
|
198
|
+
# The password to authenticate.
|
199
|
+
# The type of this field is +String+.
|
200
|
+
# session_token::
|
201
|
+
# A secret token for a given Stytch Session.
|
202
|
+
# The type of this field is nilable +String+.
|
203
|
+
# session_duration_minutes::
|
204
|
+
# Set the session lifetime to be this many minutes from now. This will start a new session if one doesn't already exist,
|
205
|
+
# returning both an opaque `session_token` and `session_jwt` for this session. Remember that the `session_jwt` will have a fixed lifetime of
|
206
|
+
# five minutes regardless of the underlying session duration, and will need to be refreshed over time.
|
207
|
+
#
|
208
|
+
# This value must be a minimum of 5 and a maximum of 527040 minutes (366 days).
|
209
|
+
#
|
210
|
+
# If a `session_token` or `session_jwt` is provided then a successful authentication will continue to extend the session this many minutes.
|
211
|
+
#
|
212
|
+
# 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
|
213
|
+
# to use the Stytch session product, you can ignore the session fields in the response.
|
214
|
+
# The type of this field is nilable +Integer+.
|
215
|
+
# session_jwt::
|
216
|
+
# The JSON Web Token (JWT) for a given Stytch Session.
|
217
|
+
# The type of this field is nilable +String+.
|
218
|
+
# session_custom_claims::
|
219
|
+
# Add a custom claims map to the Session being authenticated. Claims are only created if a Session is initialized by providing a value in
|
220
|
+
# `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
|
221
|
+
# delete a key, supply a null value. Custom claims made with reserved claims (`iss`, `sub`, `aud`, `exp`, `nbf`, `iat`, `jti`) will be ignored.
|
222
|
+
# Total custom claims size cannot exceed four kilobytes.
|
223
|
+
# The type of this field is nilable +object+.
|
224
|
+
# locale::
|
225
|
+
# (no documentation yet)
|
226
|
+
# The type of this field is nilable +AuthenticateRequestLocale+ (string enum).
|
227
|
+
#
|
228
|
+
# == Returns:
|
229
|
+
# An object with the following fields:
|
230
|
+
# request_id::
|
231
|
+
# 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.
|
232
|
+
# The type of this field is +String+.
|
233
|
+
# member_id::
|
234
|
+
# Globally unique UUID that identifies a specific Member.
|
235
|
+
# The type of this field is +String+.
|
236
|
+
# organization_id::
|
237
|
+
# 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.
|
238
|
+
# The type of this field is +String+.
|
239
|
+
# member::
|
240
|
+
# The [Member object](https://stytch.com/docs/b2b/api/member-object).
|
241
|
+
# The type of this field is +Member+ (+object+).
|
242
|
+
# session_token::
|
243
|
+
# A secret token for a given Stytch Session.
|
244
|
+
# The type of this field is +String+.
|
245
|
+
# session_jwt::
|
246
|
+
# The JSON Web Token (JWT) for a given Stytch Session.
|
247
|
+
# The type of this field is +String+.
|
248
|
+
# organization::
|
249
|
+
# The [Organization object](https://stytch.com/docs/b2b/api/organization-object).
|
250
|
+
# The type of this field is +Organization+ (+object+).
|
251
|
+
# status_code::
|
252
|
+
# The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.
|
253
|
+
# The type of this field is +Integer+.
|
254
|
+
# member_session::
|
255
|
+
# The [Session object](https://stytch.com/docs/b2b/api/session-object).
|
256
|
+
# The type of this field is nilable +MemberSession+ (+object+).
|
60
257
|
def authenticate(
|
61
258
|
organization_id:,
|
62
259
|
email_address:,
|
@@ -64,7 +261,8 @@ module StytchB2B
|
|
64
261
|
session_token: nil,
|
65
262
|
session_duration_minutes: nil,
|
66
263
|
session_jwt: nil,
|
67
|
-
session_custom_claims: nil
|
264
|
+
session_custom_claims: nil,
|
265
|
+
locale: nil
|
68
266
|
)
|
69
267
|
request = {
|
70
268
|
organization_id: organization_id,
|
@@ -75,6 +273,7 @@ module StytchB2B
|
|
75
273
|
request[:session_duration_minutes] = session_duration_minutes unless session_duration_minutes.nil?
|
76
274
|
request[:session_jwt] = session_jwt unless session_jwt.nil?
|
77
275
|
request[:session_custom_claims] = session_custom_claims unless session_custom_claims.nil?
|
276
|
+
request[:locale] = locale unless locale.nil?
|
78
277
|
|
79
278
|
post_request('/v1/b2b/passwords/authenticate', request)
|
80
279
|
end
|
@@ -86,6 +285,64 @@ module StytchB2B
|
|
86
285
|
@connection = connection
|
87
286
|
end
|
88
287
|
|
288
|
+
# 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
|
+
#
|
290
|
+
# 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
|
293
|
+
# considered valid if they meet the requirements that you've set with Stytch.
|
294
|
+
# You may update your password strength configuration in the [stytch dashboard](https://stytch.com/dashboard/password-strength-config).
|
295
|
+
#
|
296
|
+
# == Parameters:
|
297
|
+
# organization_id::
|
298
|
+
# 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.
|
299
|
+
# The type of this field is +String+.
|
300
|
+
# email_address::
|
301
|
+
# The email address of the Member to start the email reset process for.
|
302
|
+
# The type of this field is +String+.
|
303
|
+
# reset_password_redirect_url::
|
304
|
+
# The URL that the Member clicks from the reset password link. This URL should be an endpoint in the backend server that verifies the request by querying
|
305
|
+
# Stytch's authenticate endpoint and finishes the reset password flow. If this value is not passed, the default `reset_password_redirect_url` that you set in your Dashboard is used.
|
306
|
+
# If you have not set a default `reset_password_redirect_url`, an error is returned.
|
307
|
+
# The type of this field is nilable +String+.
|
308
|
+
# reset_password_expiration_minutes::
|
309
|
+
# Sets a time limit after which the email link to reset the member's password will no longer be valid.
|
310
|
+
# The type of this field is nilable +Integer+.
|
311
|
+
# code_challenge::
|
312
|
+
# A base64url encoded SHA256 hash of a one time secret used to validate that the request starts and ends on the same device.
|
313
|
+
# The type of this field is nilable +String+.
|
314
|
+
# login_redirect_url::
|
315
|
+
# The URL that the member clicks from the reset without password link. This URL should be an endpoint in the backend server
|
316
|
+
# that verifies the request by querying Stytch's authenticate endpoint and finishes the magic link flow. If this value is not passed, the
|
317
|
+
# default `login_redirect_url` that you set in your Dashboard is used. This value is only used if magic links are enabled for the member. If
|
318
|
+
# you have not set a default `login_redirect_url` and magic links are not enabled for the member, an error is returned.
|
319
|
+
# The type of this field is nilable +String+.
|
320
|
+
# locale::
|
321
|
+
# 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"`.
|
322
|
+
#
|
323
|
+
# Currently supported languages are English (`"en"`), Spanish (`"es"`), and Brazilian Portuguese (`"pt-br"`); if no value is provided, the copy defaults to English.
|
324
|
+
#
|
325
|
+
# Request support for additional languages [here](https://docs.google.com/forms/d/e/1FAIpQLScZSpAu_m2AmLXRT3F3kap-s_mcV6UTBitYn6CdyWP0-o7YjQ/viewform?usp=sf_link")!
|
326
|
+
#
|
327
|
+
# The type of this field is nilable +ResetStartRequestLocale+ (string enum).
|
328
|
+
# reset_password_template_id::
|
329
|
+
# 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.
|
330
|
+
# The type of this field is nilable +String+.
|
331
|
+
#
|
332
|
+
# == Returns:
|
333
|
+
# An object with the following fields:
|
334
|
+
# request_id::
|
335
|
+
# 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.
|
336
|
+
# The type of this field is +String+.
|
337
|
+
# member_id::
|
338
|
+
# Globally unique UUID that identifies a specific Member.
|
339
|
+
# The type of this field is +String+.
|
340
|
+
# member_email_id::
|
341
|
+
# Globally unique UUID that identifies a member's email
|
342
|
+
# The type of this field is +String+.
|
343
|
+
# status_code::
|
344
|
+
# 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.
|
345
|
+
# The type of this field is +Integer+.
|
89
346
|
def reset_start(
|
90
347
|
organization_id:,
|
91
348
|
email_address:,
|
@@ -113,6 +370,84 @@ module StytchB2B
|
|
113
370
|
post_request('/v1/b2b/passwords/email/reset/start', request)
|
114
371
|
end
|
115
372
|
|
373
|
+
# Reset the member's password and authenticate them. This endpoint checks that the password reset token is valid, hasn’t expired, or already been used.
|
374
|
+
#
|
375
|
+
# 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
|
+
#
|
377
|
+
# == Parameters:
|
378
|
+
# password_reset_token::
|
379
|
+
# The password reset token to authenticate.
|
380
|
+
# The type of this field is +String+.
|
381
|
+
# password::
|
382
|
+
# The password to reset.
|
383
|
+
# The type of this field is +String+.
|
384
|
+
# session_token::
|
385
|
+
# Reuse an existing session instead of creating a new one. If you provide a `session_token`, Stytch will update the session.
|
386
|
+
# If the `session_token` and `magic_links_token` belong to different Members, the `session_token` will be ignored. This endpoint will error if
|
387
|
+
# both `session_token` and `session_jwt` are provided.
|
388
|
+
# The type of this field is nilable +String+.
|
389
|
+
# session_duration_minutes::
|
390
|
+
# Set the session lifetime to be this many minutes from now. This will start a new session if one doesn't already exist,
|
391
|
+
# returning both an opaque `session_token` and `session_jwt` for this session. Remember that the `session_jwt` will have a fixed lifetime of
|
392
|
+
# five minutes regardless of the underlying session duration, and will need to be refreshed over time.
|
393
|
+
#
|
394
|
+
# This value must be a minimum of 5 and a maximum of 527040 minutes (366 days).
|
395
|
+
#
|
396
|
+
# If a `session_token` or `session_jwt` is provided then a successful authentication will continue to extend the session this many minutes.
|
397
|
+
#
|
398
|
+
# 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
|
399
|
+
# to use the Stytch session product, you can ignore the session fields in the response.
|
400
|
+
# The type of this field is nilable +Integer+.
|
401
|
+
# session_jwt::
|
402
|
+
# Reuse an existing session instead of creating a new one. If you provide a `session_jwt`, Stytch will update the session. If the `session_jwt`
|
403
|
+
# and `magic_links_token` belong to different Members, the `session_jwt` will be ignored. This endpoint will error if both `session_token` and `session_jwt`
|
404
|
+
# are provided.
|
405
|
+
# The type of this field is nilable +String+.
|
406
|
+
# code_verifier::
|
407
|
+
# A base64url encoded one time secret used to validate that the request starts and ends on the same device.
|
408
|
+
# The type of this field is nilable +String+.
|
409
|
+
# session_custom_claims::
|
410
|
+
# Add a custom claims map to the Session being authenticated. Claims are only created if a Session is initialized by providing a value in
|
411
|
+
# `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
|
412
|
+
# delete a key, supply a null value. Custom claims made with reserved claims (`iss`, `sub`, `aud`, `exp`, `nbf`, `iat`, `jti`) will be ignored.
|
413
|
+
# Total custom claims size cannot exceed four kilobytes.
|
414
|
+
# The type of this field is nilable +object+.
|
415
|
+
# locale::
|
416
|
+
# (no documentation yet)
|
417
|
+
# The type of this field is nilable +ResetRequestLocale+ (string enum).
|
418
|
+
#
|
419
|
+
# == Returns:
|
420
|
+
# An object with the following fields:
|
421
|
+
# request_id::
|
422
|
+
# 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.
|
423
|
+
# The type of this field is +String+.
|
424
|
+
# member_id::
|
425
|
+
# Globally unique UUID that identifies a specific Member.
|
426
|
+
# The type of this field is +String+.
|
427
|
+
# member_email_id::
|
428
|
+
# Globally unique UUID that identifies a member's email
|
429
|
+
# The type of this field is +String+.
|
430
|
+
# organization_id::
|
431
|
+
# 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.
|
432
|
+
# The type of this field is +String+.
|
433
|
+
# member::
|
434
|
+
# The [Member object](https://stytch.com/docs/b2b/api/member-object).
|
435
|
+
# The type of this field is +Member+ (+object+).
|
436
|
+
# session_token::
|
437
|
+
# A secret token for a given Stytch Session.
|
438
|
+
# The type of this field is +String+.
|
439
|
+
# session_jwt::
|
440
|
+
# The JSON Web Token (JWT) for a given Stytch Session.
|
441
|
+
# The type of this field is +String+.
|
442
|
+
# organization::
|
443
|
+
# The [Organization object](https://stytch.com/docs/b2b/api/organization-object).
|
444
|
+
# The type of this field is +Organization+ (+object+).
|
445
|
+
# status_code::
|
446
|
+
# 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
|
+
# The type of this field is +Integer+.
|
448
|
+
# member_session::
|
449
|
+
# The [Session object](https://stytch.com/docs/b2b/api/session-object).
|
450
|
+
# The type of this field is nilable +MemberSession+ (+object+).
|
116
451
|
def reset(
|
117
452
|
password_reset_token:,
|
118
453
|
password:,
|
@@ -120,7 +455,8 @@ module StytchB2B
|
|
120
455
|
session_duration_minutes: nil,
|
121
456
|
session_jwt: nil,
|
122
457
|
code_verifier: nil,
|
123
|
-
session_custom_claims: nil
|
458
|
+
session_custom_claims: nil,
|
459
|
+
locale: nil
|
124
460
|
)
|
125
461
|
request = {
|
126
462
|
password_reset_token: password_reset_token,
|
@@ -131,6 +467,7 @@ module StytchB2B
|
|
131
467
|
request[:session_jwt] = session_jwt unless session_jwt.nil?
|
132
468
|
request[:code_verifier] = code_verifier unless code_verifier.nil?
|
133
469
|
request[:session_custom_claims] = session_custom_claims unless session_custom_claims.nil?
|
470
|
+
request[:locale] = locale unless locale.nil?
|
134
471
|
|
135
472
|
post_request('/v1/b2b/passwords/email/reset', request)
|
136
473
|
end
|
@@ -143,6 +480,42 @@ module StytchB2B
|
|
143
480
|
@connection = connection
|
144
481
|
end
|
145
482
|
|
483
|
+
# Reset the Member's password using their existing session. The endpoint will error if the session does not contain an authentication factor that has been issued within the last 5 minutes. Either `session_token` or `session_jwt` should be provided.
|
484
|
+
#
|
485
|
+
# == Parameters:
|
486
|
+
# organization_id::
|
487
|
+
# 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.
|
488
|
+
# The type of this field is +String+.
|
489
|
+
# password::
|
490
|
+
# The password to authenticate.
|
491
|
+
# The type of this field is +String+.
|
492
|
+
# session_token::
|
493
|
+
# A secret token for a given Stytch Session.
|
494
|
+
# The type of this field is nilable +String+.
|
495
|
+
# session_jwt::
|
496
|
+
# The JSON Web Token (JWT) for a given Stytch Session.
|
497
|
+
# The type of this field is nilable +String+.
|
498
|
+
#
|
499
|
+
# == Returns:
|
500
|
+
# An object with the following fields:
|
501
|
+
# request_id::
|
502
|
+
# 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.
|
503
|
+
# The type of this field is +String+.
|
504
|
+
# member_id::
|
505
|
+
# Globally unique UUID that identifies a specific Member.
|
506
|
+
# The type of this field is +String+.
|
507
|
+
# member::
|
508
|
+
# The [Member object](https://stytch.com/docs/b2b/api/member-object).
|
509
|
+
# The type of this field is +Member+ (+object+).
|
510
|
+
# organization::
|
511
|
+
# The [Organization object](https://stytch.com/docs/b2b/api/organization-object).
|
512
|
+
# The type of this field is +Organization+ (+object+).
|
513
|
+
# status_code::
|
514
|
+
# 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.
|
515
|
+
# The type of this field is +Integer+.
|
516
|
+
# member_session::
|
517
|
+
# The [Session object](https://stytch.com/docs/b2b/api/session-object).
|
518
|
+
# The type of this field is nilable +MemberSession+ (+object+).
|
146
519
|
def reset(
|
147
520
|
organization_id:,
|
148
521
|
password:,
|
@@ -167,6 +540,81 @@ module StytchB2B
|
|
167
540
|
@connection = connection
|
168
541
|
end
|
169
542
|
|
543
|
+
# Reset the member’s password using their existing password.
|
544
|
+
#
|
545
|
+
# 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
|
548
|
+
# considered valid if they meet the requirements that you've set with Stytch.
|
549
|
+
# You may update your password strength configuration in the [stytch dashboard](https://stytch.com/dashboard/password-strength-config).
|
550
|
+
#
|
551
|
+
# == Parameters:
|
552
|
+
# email_address::
|
553
|
+
# The email address of the Member.
|
554
|
+
# The type of this field is +String+.
|
555
|
+
# existing_password::
|
556
|
+
# The member's current password that they supplied.
|
557
|
+
# The type of this field is +String+.
|
558
|
+
# new_password::
|
559
|
+
# The member's elected new password.
|
560
|
+
# The type of this field is +String+.
|
561
|
+
# organization_id::
|
562
|
+
# 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.
|
563
|
+
# The type of this field is +String+.
|
564
|
+
# session_token::
|
565
|
+
# A secret token for a given Stytch Session.
|
566
|
+
# The type of this field is nilable +String+.
|
567
|
+
# session_duration_minutes::
|
568
|
+
# Set the session lifetime to be this many minutes from now. This will start a new session if one doesn't already exist,
|
569
|
+
# returning both an opaque `session_token` and `session_jwt` for this session. Remember that the `session_jwt` will have a fixed lifetime of
|
570
|
+
# five minutes regardless of the underlying session duration, and will need to be refreshed over time.
|
571
|
+
#
|
572
|
+
# This value must be a minimum of 5 and a maximum of 527040 minutes (366 days).
|
573
|
+
#
|
574
|
+
# If a `session_token` or `session_jwt` is provided then a successful authentication will continue to extend the session this many minutes.
|
575
|
+
#
|
576
|
+
# 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
|
577
|
+
# to use the Stytch session product, you can ignore the session fields in the response.
|
578
|
+
# The type of this field is nilable +Integer+.
|
579
|
+
# session_jwt::
|
580
|
+
# The JSON Web Token (JWT) for a given Stytch Session.
|
581
|
+
# The type of this field is nilable +String+.
|
582
|
+
# session_custom_claims::
|
583
|
+
# Add a custom claims map to the Session being authenticated. Claims are only created if a Session is initialized by providing a value in
|
584
|
+
# `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
|
585
|
+
# delete a key, supply a null value. Custom claims made with reserved claims (`iss`, `sub`, `aud`, `exp`, `nbf`, `iat`, `jti`) will be ignored.
|
586
|
+
# Total custom claims size cannot exceed four kilobytes.
|
587
|
+
# The type of this field is nilable +object+.
|
588
|
+
# locale::
|
589
|
+
# (no documentation yet)
|
590
|
+
# The type of this field is nilable +ResetRequestLocale+ (string enum).
|
591
|
+
#
|
592
|
+
# == Returns:
|
593
|
+
# An object with the following fields:
|
594
|
+
# request_id::
|
595
|
+
# 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.
|
596
|
+
# The type of this field is +String+.
|
597
|
+
# member_id::
|
598
|
+
# Globally unique UUID that identifies a specific Member.
|
599
|
+
# The type of this field is +String+.
|
600
|
+
# member::
|
601
|
+
# The [Member object](https://stytch.com/docs/b2b/api/member-object).
|
602
|
+
# The type of this field is +Member+ (+object+).
|
603
|
+
# session_token::
|
604
|
+
# A secret token for a given Stytch Session.
|
605
|
+
# The type of this field is +String+.
|
606
|
+
# session_jwt::
|
607
|
+
# The JSON Web Token (JWT) for a given Stytch Session.
|
608
|
+
# The type of this field is +String+.
|
609
|
+
# organization::
|
610
|
+
# The [Organization object](https://stytch.com/docs/b2b/api/organization-object).
|
611
|
+
# The type of this field is +Organization+ (+object+).
|
612
|
+
# status_code::
|
613
|
+
# 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
|
+
# The type of this field is +Integer+.
|
615
|
+
# member_session::
|
616
|
+
# The [Session object](https://stytch.com/docs/b2b/api/session-object).
|
617
|
+
# The type of this field is nilable +MemberSession+ (+object+).
|
170
618
|
def reset(
|
171
619
|
email_address:,
|
172
620
|
existing_password:,
|
@@ -175,7 +623,8 @@ module StytchB2B
|
|
175
623
|
session_token: nil,
|
176
624
|
session_duration_minutes: nil,
|
177
625
|
session_jwt: nil,
|
178
|
-
session_custom_claims: nil
|
626
|
+
session_custom_claims: nil,
|
627
|
+
locale: nil
|
179
628
|
)
|
180
629
|
request = {
|
181
630
|
email_address: email_address,
|
@@ -187,6 +636,7 @@ module StytchB2B
|
|
187
636
|
request[:session_duration_minutes] = session_duration_minutes unless session_duration_minutes.nil?
|
188
637
|
request[:session_jwt] = session_jwt unless session_jwt.nil?
|
189
638
|
request[:session_custom_claims] = session_custom_claims unless session_custom_claims.nil?
|
639
|
+
request[:locale] = locale unless locale.nil?
|
190
640
|
|
191
641
|
post_request('/v1/b2b/passwords/existing_password/reset', request)
|
192
642
|
end
|