# frozen_string_literal: true # !!! # WARNING: This file is autogenerated # Only modify code within MANUAL() sections # or your changes may be overwritten later! # !!! require_relative 'request_helper' module StytchB2B class Passwords include Stytch::RequestHelper attr_reader :email, :sessions, :existing_password, :discovery def initialize(connection) @connection = connection @email = StytchB2B::Passwords::Email.new(@connection) @sessions = StytchB2B::Passwords::Sessions.new(@connection) @existing_password = StytchB2B::Passwords::ExistingPassword.new(@connection) @discovery = StytchB2B::Passwords::Discovery.new(@connection) end # 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. # # 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). # # ## Password feedback # 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. # # 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. # # 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. # # == Parameters: # password:: # The password to authenticate, reset, or set for the first time. Any UTF8 character is allowed, e.g. spaces, emojis, non-English characers, etc. # The type of this field is +String+. # email_address:: # The email address of the Member. # The type of this field is nilable +String+. # # == Returns: # An object with the following fields: # request_id:: # 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. # The type of this field is +String+. # valid_password:: # Returns `true` if the password passes our password validation. We offer two validation options, # [zxcvbn](https://stytch.com/docs/passwords#strength-requirements) is the default option which offers a high level of sophistication. # We also offer [LUDS](https://stytch.com/docs/passwords#strength-requirements). If an email address is included in the call we also # require that the password hasn't been compromised using built-in breach detection powered by [HaveIBeenPwned](https://haveibeenpwned.com/) # The type of this field is +Boolean+. # score:: # 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. # The type of this field is +Integer+. # breached_password:: # Returns `true` if the password has been breached. Powered by [HaveIBeenPwned](https://haveibeenpwned.com/). # The type of this field is +Boolean+. # strength_policy:: # The strength policy type enforced, either `zxcvbn` or `luds`. # The type of this field is +String+. # breach_detection_on_create:: # Will return `true` if breach detection will be evaluated. By default this option is enabled. # This option can be disabled by contacting [support@stytch.com](mailto:support@stytch.com?subject=Password%20strength%20configuration). # If this value is false then `breached_password` will always be `false` as well. # The type of this field is +Boolean+. # status_code:: # 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. # The type of this field is +Integer+. # luds_feedback:: # Feedback for how to improve the password's strength using [luds](https://stytch.com/docs/passwords#strength-requirements). # The type of this field is nilable +LudsFeedback+ (+object+). # zxcvbn_feedback:: # Feedback for how to improve the password's strength using [zxcvbn](https://stytch.com/docs/passwords#strength-requirements). # The type of this field is nilable +ZxcvbnFeedback+ (+object+). def strength_check( password:, email_address: nil ) headers = {} request = { password: password } request[:email_address] = email_address unless email_address.nil? post_request('/v1/b2b/passwords/strength_check', request, headers) end # 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. # # The member's email will be marked as verified when you use this endpoint. # # == Parameters: # email_address:: # The email address of the Member. # The type of this field is +String+. # hash:: # The password hash. For a Scrypt or PBKDF2 hash, the hash needs to be a base64 encoded string. # The type of this field is +String+. # hash_type:: # The password hash used. Currently `bcrypt`, `scrypt`, `argon_2i`, `argon2_id`, `md_5`, `sha_1`, and `pbkdf_2` are supported. # The type of this field is +MigrateRequestHashType+ (string enum). # organization_id:: # 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. # The type of this field is +String+. # md_5_config:: # Optional parameters for MD-5 hash types. # The type of this field is nilable +MD5Config+ (+object+). # argon_2_config:: # Required parameters if the argon2 hex form, as opposed to the encoded form, is supplied. # The type of this field is nilable +Argon2Config+ (+object+). # sha_1_config:: # Optional parameters for SHA-1 hash types. # The type of this field is nilable +SHA1Config+ (+object+). # scrypt_config:: # Required parameters if the scrypt is not provided in a **PHC encoded form**. # The type of this field is nilable +ScryptConfig+ (+object+). # pbkdf_2_config:: # 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. # The type of this field is nilable +PBKDF2Config+ (+object+). # name:: # The name of the Member. Each field in the name object is optional. # The type of this field is nilable +String+. # trusted_metadata:: # An arbitrary JSON object for storing application-specific data or identity-provider-specific data. # The type of this field is nilable +object+. # untrusted_metadata:: # An arbitrary JSON object of application-specific data. These fields can be edited directly by the # frontend SDK, and should not be used to store critical information. See the [Metadata resource](https://stytch.com/docs/b2b/api/metadata) # for complete field behavior details. # The type of this field is nilable +object+. # roles:: # Roles to explicitly assign to this Member. # Will completely replace any existing explicitly assigned roles. See the # [RBAC guide](https://stytch.com/docs/b2b/guides/rbac/role-assignment) for more information about role assignment. # # If a Role is removed from a Member, and the Member is also implicitly assigned this Role from an SSO connection # or an SSO group, we will by default revoke any existing sessions for the Member that contain any SSO # authentication factors with the affected connection ID. You can preserve these sessions by passing in the # `preserve_existing_sessions` parameter with a value of `true`. # The type of this field is nilable list of +String+. # preserve_existing_sessions:: # Whether to preserve existing sessions when explicit Roles that are revoked are also implicitly assigned # by SSO connection or SSO group. Defaults to `false` - that is, existing Member Sessions that contain SSO # authentication factors with the affected SSO connection IDs will be revoked. # The type of this field is nilable +Boolean+. # # == Returns: # An object with the following fields: # request_id:: # 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. # The type of this field is +String+. # member_id:: # Globally unique UUID that identifies a specific Member. # The type of this field is +String+. # member_created:: # A flag indicating `true` if a new Member object was created and `false` if the Member object already existed. # The type of this field is +Boolean+. # member:: # The [Member object](https://stytch.com/docs/b2b/api/member-object) # The type of this field is +Member+ (+object+). # organization:: # The [Organization object](https://stytch.com/docs/b2b/api/organization-object). # The type of this field is +Organization+ (+object+). # status_code:: # 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. # The type of this field is +Integer+. def migrate( email_address:, hash:, hash_type:, organization_id:, md_5_config: nil, argon_2_config: nil, sha_1_config: nil, scrypt_config: nil, pbkdf_2_config: nil, name: nil, trusted_metadata: nil, untrusted_metadata: nil, roles: nil, preserve_existing_sessions: nil ) headers = {} request = { email_address: email_address, hash: hash, hash_type: hash_type, organization_id: organization_id } request[:md_5_config] = md_5_config unless md_5_config.nil? request[:argon_2_config] = argon_2_config unless argon_2_config.nil? request[:sha_1_config] = sha_1_config unless sha_1_config.nil? request[:scrypt_config] = scrypt_config unless scrypt_config.nil? request[:pbkdf_2_config] = pbkdf_2_config unless pbkdf_2_config.nil? request[:name] = name unless name.nil? request[:trusted_metadata] = trusted_metadata unless trusted_metadata.nil? request[:untrusted_metadata] = untrusted_metadata unless untrusted_metadata.nil? request[:roles] = roles unless roles.nil? request[:preserve_existing_sessions] = preserve_existing_sessions unless preserve_existing_sessions.nil? post_request('/v1/b2b/passwords/migrate', request, headers) end # 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. # # If you have breach detection during authentication enabled in your [password strength policy](https://stytch.com/docs/b2b/guides/passwords/strength-policies) and the member's credentials have appeared in the HaveIBeenPwned dataset, this endpoint will return a `member_reset_password` error even if the member enters a correct password. We force a password reset in this case to ensure that the member is the legitimate owner of the email address and not a malicious actor abusing the compromised credentials. # # If the is required to complete MFA to log in to the, the returned value of `member_authenticated` will be `false`, and an `intermediate_session_token` will be returned. # 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. # The `session_duration_minutes` and `session_custom_claims` parameters will be ignored. # # If a valid `session_token` or `session_jwt` is passed in, the Member will not be required to complete an MFA step. # # == Parameters: # organization_id:: # 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. # The type of this field is +String+. # email_address:: # The email address of the Member. # The type of this field is +String+. # password:: # The password to authenticate, reset, or set for the first time. Any UTF8 character is allowed, e.g. spaces, emojis, non-English characers, etc. # The type of this field is +String+. # session_token:: # A secret token for a given Stytch Session. # The type of this field is nilable +String+. # session_duration_minutes:: # Set the session lifetime to be this many minutes from now. This will start a new session if one doesn't already exist, # returning both an opaque `session_token` and `session_jwt` for this session. Remember that the `session_jwt` will have a fixed lifetime of # five minutes regardless of the underlying session duration, and will need to be refreshed over time. # # This value must be a minimum of 5 and a maximum of 527040 minutes (366 days). # # If a `session_token` or `session_jwt` is provided then a successful authentication will continue to extend the session this many minutes. # # 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 # to use the Stytch session product, you can ignore the session fields in the response. # The type of this field is nilable +Integer+. # session_jwt:: # The JSON Web Token (JWT) for a given Stytch Session. # The type of this field is nilable +String+. # session_custom_claims:: # Add a custom claims map to the Session being authenticated. Claims are only created if a Session is initialized by providing a value in # `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 # delete a key, supply a null value. Custom claims made with reserved claims (`iss`, `sub`, `aud`, `exp`, `nbf`, `iat`, `jti`) will be ignored. # Total custom claims size cannot exceed four kilobytes. # The type of this field is nilable +object+. # locale:: # If the needs to complete an MFA step, and the Member has a phone number, this endpoint will pre-emptively send a one-time passcode (OTP) to the Member's phone number. The locale argument will be used to determine which language to use when sending the passcode. # # Parameter is a [IETF BCP 47 language tag](https://www.w3.org/International/articles/language-tags/), e.g. `"en"`. # # Currently supported languages are English (`"en"`), Spanish (`"es"`), and Brazilian Portuguese (`"pt-br"`); if no value is provided, the copy defaults to English. # # Request support for additional languages [here](https://docs.google.com/forms/d/e/1FAIpQLScZSpAu_m2AmLXRT3F3kap-s_mcV6UTBitYn6CdyWP0-o7YjQ/viewform?usp=sf_link")! # # The type of this field is nilable +AuthenticateRequestLocale+ (string enum). # intermediate_session_token:: # Adds this primary authentication factor to the intermediate session token. If the resulting set of factors satisfies the organization's primary authentication requirements and MFA requirements, the intermediate session token will be consumed and converted to a member session. If not, the same intermediate session token will be returned. # The type of this field is nilable +String+. # # == Returns: # An object with the following fields: # request_id:: # 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. # The type of this field is +String+. # member_id:: # Globally unique UUID that identifies a specific Member. # The type of this field is +String+. # organization_id:: # 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. # The type of this field is +String+. # member:: # The [Member object](https://stytch.com/docs/b2b/api/member-object) # The type of this field is +Member+ (+object+). # session_token:: # A secret token for a given Stytch Session. # The type of this field is +String+. # session_jwt:: # The JSON Web Token (JWT) for a given Stytch Session. # The type of this field is +String+. # organization:: # The [Organization object](https://stytch.com/docs/b2b/api/organization-object). # The type of this field is +Organization+ (+object+). # intermediate_session_token:: # The returned Intermediate Session Token contains a password factor associated with the Member. If this value is non-empty, the member must complete an MFA step to finish logging in to the Organization. The token can be used with the [OTP SMS Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-otp-sms), [TOTP Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-totp), or [Recovery Codes Recover endpoint](https://stytch.com/docs/b2b/api/recovery-codes-recover) to complete an MFA flow and log in to the Organization. Password factors are not transferable between Organizations, so the intermediate session token is not valid for use with discovery endpoints. # The type of this field is +String+. # member_authenticated:: # Indicates whether the Member is fully authenticated. If false, the Member needs to complete an MFA step to log in to the Organization. # The type of this field is +Boolean+. # status_code:: # 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. # The type of this field is +Integer+. # member_session:: # The [Session object](https://stytch.com/docs/b2b/api/session-object). # The type of this field is nilable +MemberSession+ (+object+). # mfa_required:: # Information about the MFA requirements of the Organization and the Member's options for fulfilling MFA. # The type of this field is nilable +MfaRequired+ (+object+). def authenticate( organization_id:, email_address:, password:, session_token: nil, session_duration_minutes: nil, session_jwt: nil, session_custom_claims: nil, locale: nil, intermediate_session_token: nil ) headers = {} request = { organization_id: organization_id, email_address: email_address, password: password } request[:session_token] = session_token unless session_token.nil? request[:session_duration_minutes] = session_duration_minutes unless session_duration_minutes.nil? request[:session_jwt] = session_jwt unless session_jwt.nil? request[:session_custom_claims] = session_custom_claims unless session_custom_claims.nil? request[:locale] = locale unless locale.nil? request[:intermediate_session_token] = intermediate_session_token unless intermediate_session_token.nil? post_request('/v1/b2b/passwords/authenticate', request, headers) end class Email class RequireResetRequestOptions # Optional authorization object. # Pass in an active Stytch Member session token or session JWT and the request # will be run using that member's permissions. attr_accessor :authorization def initialize( authorization: nil ) @authorization = authorization end def to_headers headers = {} headers.merge!(@authorization.to_headers) if authorization headers end end include Stytch::RequestHelper def initialize(connection) @connection = connection end # 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. # # 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). # # == Parameters: # organization_id:: # 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. # The type of this field is +String+. # email_address:: # The email address of the Member to start the email reset process for. # The type of this field is +String+. # reset_password_redirect_url:: # 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 # 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. # If you have not set a default `reset_password_redirect_url`, an error is returned. # The type of this field is nilable +String+. # reset_password_expiration_minutes:: # Sets a time limit after which the email link to reset the member's password will no longer be valid. # The type of this field is nilable +Integer+. # code_challenge:: # A base64url encoded SHA256 hash of a one time secret used to validate that the request starts and ends on the same device. # The type of this field is nilable +String+. # login_redirect_url:: # The URL that the member clicks from the reset without password link. This URL should be an endpoint in the backend server # that verifies the request by querying Stytch's authenticate endpoint and finishes the magic link flow. If this value is not passed, the # 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 # you have not set a default `login_redirect_url` and magic links are not enabled for the member, an error is returned. # The type of this field is nilable +String+. # locale:: # 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"`. # # Currently supported languages are English (`"en"`), Spanish (`"es"`), and Brazilian Portuguese (`"pt-br"`); if no value is provided, the copy defaults to English. # # Request support for additional languages [here](https://docs.google.com/forms/d/e/1FAIpQLScZSpAu_m2AmLXRT3F3kap-s_mcV6UTBitYn6CdyWP0-o7YjQ/viewform?usp=sf_link")! # # The type of this field is nilable +ResetStartRequestLocale+ (string enum). # reset_password_template_id:: # 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. # The type of this field is nilable +String+. # # == Returns: # An object with the following fields: # request_id:: # 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. # The type of this field is +String+. # member_id:: # Globally unique UUID that identifies a specific Member. # The type of this field is +String+. # member_email_id:: # Globally unique UUID that identifies a member's email # The type of this field is +String+. # member:: # The [Member object](https://stytch.com/docs/b2b/api/member-object) # The type of this field is +Member+ (+object+). # status_code:: # 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. # The type of this field is +Integer+. def reset_start( organization_id:, email_address:, reset_password_redirect_url: nil, reset_password_expiration_minutes: nil, code_challenge: nil, login_redirect_url: nil, locale: nil, reset_password_template_id: nil ) headers = {} request = { organization_id: organization_id, email_address: email_address } request[:reset_password_redirect_url] = reset_password_redirect_url unless reset_password_redirect_url.nil? request[:reset_password_expiration_minutes] = reset_password_expiration_minutes unless reset_password_expiration_minutes.nil? request[:code_challenge] = code_challenge unless code_challenge.nil? request[:login_redirect_url] = login_redirect_url unless login_redirect_url.nil? request[:locale] = locale unless locale.nil? request[:reset_password_template_id] = reset_password_template_id unless reset_password_template_id.nil? post_request('/v1/b2b/passwords/email/reset/start', request, headers) end # Reset the's password and authenticate them. This endpoint checks that the password reset token is valid, hasn’t expired, or already been used. # # 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. # # 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. # 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. # The `session_duration_minutes` and `session_custom_claims` parameters will be ignored. # # If a valid `session_token` or `session_jwt` is passed in, the Member will not be required to complete an MFA step. # # Note that a successful password reset by email will revoke all active sessions for the `member_id`. # # == Parameters: # password_reset_token:: # The password reset token to authenticate. # The type of this field is +String+. # password:: # The password to authenticate, reset, or set for the first time. Any UTF8 character is allowed, e.g. spaces, emojis, non-English characers, etc. # The type of this field is +String+. # session_token:: # Reuse an existing session instead of creating a new one. If you provide a `session_token`, Stytch will update the session. # If the `session_token` and `magic_links_token` belong to different Members, the `session_token` will be ignored. This endpoint will error if # both `session_token` and `session_jwt` are provided. # The type of this field is nilable +String+. # session_duration_minutes:: # Set the session lifetime to be this many minutes from now. This will start a new session if one doesn't already exist, # returning both an opaque `session_token` and `session_jwt` for this session. Remember that the `session_jwt` will have a fixed lifetime of # five minutes regardless of the underlying session duration, and will need to be refreshed over time. # # This value must be a minimum of 5 and a maximum of 527040 minutes (366 days). # # If a `session_token` or `session_jwt` is provided then a successful authentication will continue to extend the session this many minutes. # # 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 # to use the Stytch session product, you can ignore the session fields in the response. # The type of this field is nilable +Integer+. # session_jwt:: # 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` # 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` # are provided. # The type of this field is nilable +String+. # code_verifier:: # A base64url encoded one time secret used to validate that the request starts and ends on the same device. # The type of this field is nilable +String+. # session_custom_claims:: # Add a custom claims map to the Session being authenticated. Claims are only created if a Session is initialized by providing a value in # `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 # delete a key, supply a null value. Custom claims made with reserved claims (`iss`, `sub`, `aud`, `exp`, `nbf`, `iat`, `jti`) will be ignored. # Total custom claims size cannot exceed four kilobytes. # The type of this field is nilable +object+. # locale:: # If the needs to complete an MFA step, and the Member has a phone number, this endpoint will pre-emptively send a one-time passcode (OTP) to the Member's phone number. The locale argument will be used to determine which language to use when sending the passcode. # # Parameter is a [IETF BCP 47 language tag](https://www.w3.org/International/articles/language-tags/), e.g. `"en"`. # # Currently supported languages are English (`"en"`), Spanish (`"es"`), and Brazilian Portuguese (`"pt-br"`); if no value is provided, the copy defaults to English. # # Request support for additional languages [here](https://docs.google.com/forms/d/e/1FAIpQLScZSpAu_m2AmLXRT3F3kap-s_mcV6UTBitYn6CdyWP0-o7YjQ/viewform?usp=sf_link")! # # The type of this field is nilable +ResetRequestLocale+ (string enum). # intermediate_session_token:: # Adds this primary authentication factor to the intermediate session token. If the resulting set of factors satisfies the organization's primary authentication requirements and MFA requirements, the intermediate session token will be consumed and converted to a member session. If not, the same intermediate session token will be returned. # The type of this field is nilable +String+. # # == Returns: # An object with the following fields: # request_id:: # 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. # The type of this field is +String+. # member_id:: # Globally unique UUID that identifies a specific Member. # The type of this field is +String+. # member_email_id:: # Globally unique UUID that identifies a member's email # The type of this field is +String+. # organization_id:: # 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. # The type of this field is +String+. # member:: # The [Member object](https://stytch.com/docs/b2b/api/member-object) # The type of this field is +Member+ (+object+). # session_token:: # A secret token for a given Stytch Session. # The type of this field is +String+. # session_jwt:: # The JSON Web Token (JWT) for a given Stytch Session. # The type of this field is +String+. # organization:: # The [Organization object](https://stytch.com/docs/b2b/api/organization-object). # The type of this field is +Organization+ (+object+). # intermediate_session_token:: # The returned Intermediate Session Token contains a password factor associated with the Member. If this value is non-empty, the member must complete an MFA step to finish logging in to the Organization. The token can be used with the [OTP SMS Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-otp-sms), [TOTP Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-totp), or [Recovery Codes Recover endpoint](https://stytch.com/docs/b2b/api/recovery-codes-recover) to complete an MFA flow and log in to the Organization. Password factors are not transferable between Organizations, so the intermediate session token is not valid for use with discovery endpoints. # The type of this field is +String+. # member_authenticated:: # Indicates whether the Member is fully authenticated. If false, the Member needs to complete an MFA step to log in to the Organization. # The type of this field is +Boolean+. # status_code:: # 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. # The type of this field is +Integer+. # member_session:: # The [Session object](https://stytch.com/docs/b2b/api/session-object). # The type of this field is nilable +MemberSession+ (+object+). # mfa_required:: # Information about the MFA requirements of the Organization and the Member's options for fulfilling MFA. # The type of this field is nilable +MfaRequired+ (+object+). def reset( password_reset_token:, password:, session_token: nil, session_duration_minutes: nil, session_jwt: nil, code_verifier: nil, session_custom_claims: nil, locale: nil, intermediate_session_token: nil ) headers = {} request = { password_reset_token: password_reset_token, password: password } request[:session_token] = session_token unless session_token.nil? request[:session_duration_minutes] = session_duration_minutes unless session_duration_minutes.nil? request[:session_jwt] = session_jwt unless session_jwt.nil? request[:code_verifier] = code_verifier unless code_verifier.nil? request[:session_custom_claims] = session_custom_claims unless session_custom_claims.nil? request[:locale] = locale unless locale.nil? request[:intermediate_session_token] = intermediate_session_token unless intermediate_session_token.nil? post_request('/v1/b2b/passwords/email/reset', request, headers) end # Require a password be reset by the associated email address. This endpoint is only functional for cross-org password use cases. # # == Parameters: # email_address:: # The email address of the Member to start the email reset process for. # The type of this field is +String+. # organization_id:: # 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. # The type of this field is nilable +String+. # member_id:: # 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. # The type of this field is nilable +String+. # # == Returns: # An object with the following fields: # member:: # The [Member object](https://stytch.com/docs/b2b/api/member-object) # The type of this field is +Member+ (+object+). # organization:: # The [Organization object](https://stytch.com/docs/b2b/api/organization-object). # The type of this field is +Organization+ (+object+). # status_code:: # 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. # The type of this field is +Integer+. # member_id:: # Globally unique UUID that identifies a specific Member. # The type of this field is nilable +String+. # # == Method Options: # This method supports an optional +StytchB2B::Passwords::Email::RequireResetRequestOptions+ object which will modify the headers sent in the HTTP request. def require_reset( email_address:, organization_id: nil, member_id: nil, method_options: nil ) headers = {} headers = headers.merge(method_options.to_headers) unless method_options.nil? request = { email_address: email_address } request[:organization_id] = organization_id unless organization_id.nil? request[:member_id] = member_id unless member_id.nil? post_request('/v1/b2b/passwords/email/require_reset', request, headers) end end class Sessions include Stytch::RequestHelper def initialize(connection) @connection = connection end # Reset the'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. # # Note that a successful password reset via an existing session will revoke all active sessions for the `member_id`, except for the one used during the reset flow. # # == Parameters: # organization_id:: # 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. # The type of this field is +String+. # password:: # The password to authenticate, reset, or set for the first time. Any UTF8 character is allowed, e.g. spaces, emojis, non-English characers, etc. # The type of this field is +String+. # session_token:: # A secret token for a given Stytch Session. # The type of this field is nilable +String+. # session_jwt:: # The JSON Web Token (JWT) for a given Stytch Session. # The type of this field is nilable +String+. # session_duration_minutes:: # Set the session lifetime to be this many minutes from now. This will start a new session if one doesn't already exist, # returning both an opaque `session_token` and `session_jwt` for this session. Remember that the `session_jwt` will have a fixed lifetime of # five minutes regardless of the underlying session duration, and will need to be refreshed over time. # # This value must be a minimum of 5 and a maximum of 527040 minutes (366 days). # # If a `session_token` or `session_jwt` is provided then a successful authentication will continue to extend the session this many minutes. # # 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 # to use the Stytch session product, you can ignore the session fields in the response. # The type of this field is nilable +Integer+. # session_custom_claims:: # Add a custom claims map to the Session being authenticated. Claims are only created if a Session is initialized by providing a value in # `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 # delete a key, supply a null value. Custom claims made with reserved claims (`iss`, `sub`, `aud`, `exp`, `nbf`, `iat`, `jti`) will be ignored. # Total custom claims size cannot exceed four kilobytes. # The type of this field is nilable +object+. # locale:: # 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"`. # # Currently supported languages are English (`"en"`), Spanish (`"es"`), and Brazilian Portuguese (`"pt-br"`); if no value is provided, the copy defaults to English. # # Request support for additional languages [here](https://docs.google.com/forms/d/e/1FAIpQLScZSpAu_m2AmLXRT3F3kap-s_mcV6UTBitYn6CdyWP0-o7YjQ/viewform?usp=sf_link")! # # The type of this field is nilable +ResetRequestLocale+ (string enum). # # == Returns: # An object with the following fields: # request_id:: # 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. # The type of this field is +String+. # member_id:: # Globally unique UUID that identifies a specific Member. # The type of this field is +String+. # member:: # The [Member object](https://stytch.com/docs/b2b/api/member-object) # The type of this field is +Member+ (+object+). # organization:: # The [Organization object](https://stytch.com/docs/b2b/api/organization-object). # The type of this field is +Organization+ (+object+). # session_token:: # A secret token for a given Stytch Session. # The type of this field is +String+. # session_jwt:: # The JSON Web Token (JWT) for a given Stytch Session. # The type of this field is +String+. # intermediate_session_token:: # The Intermediate Session Token. This token does not necessarily belong to a specific instance of a Member, but represents a bag of factors that may be converted to a member session. The token can be used with the [OTP SMS Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-otp-sms), [TOTP Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-totp), or [Recovery Codes Recover endpoint](https://stytch.com/docs/b2b/api/recovery-codes-recover) to complete an MFA flow and log in to the Organization. It can also be used with the [Exchange Intermediate Session endpoint](https://stytch.com/docs/b2b/api/exchange-intermediate-session) to join a specific Organization that allows the factors represented by the intermediate session token; or the [Create Organization via Discovery endpoint](https://stytch.com/docs/b2b/api/create-organization-via-discovery) to create a new Organization and Member. # The type of this field is +String+. # member_authenticated:: # Indicates whether the Member is fully authenticated. If false, the Member needs to complete an MFA step to log in to the Organization. # The type of this field is +Boolean+. # status_code:: # 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. # The type of this field is +Integer+. # member_session:: # The [Session object](https://stytch.com/docs/b2b/api/session-object). # The type of this field is nilable +MemberSession+ (+object+). # mfa_required:: # Information about the MFA requirements of the Organization and the Member's options for fulfilling MFA. # The type of this field is nilable +MfaRequired+ (+object+). def reset( organization_id:, password:, session_token: nil, session_jwt: nil, session_duration_minutes: nil, session_custom_claims: nil, locale: nil ) headers = {} request = { organization_id: organization_id, password: password } request[:session_token] = session_token unless session_token.nil? request[:session_jwt] = session_jwt unless session_jwt.nil? request[:session_duration_minutes] = session_duration_minutes unless session_duration_minutes.nil? request[:session_custom_claims] = session_custom_claims unless session_custom_claims.nil? request[:locale] = locale unless locale.nil? post_request('/v1/b2b/passwords/session/reset', request, headers) end end class ExistingPassword include Stytch::RequestHelper def initialize(connection) @connection = connection end # Reset the’s password using their existing password. # # 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). # # 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. # 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. # The `session_duration_minutes` and `session_custom_claims` parameters will be ignored. # # If a valid `session_token` or `session_jwt` is passed in, the Member will not be required to complete an MFA step. # # Note that a successful password reset via an existing password will revoke all active sessions for the `member_id`. # # == Parameters: # email_address:: # The email address of the Member. # The type of this field is +String+. # existing_password:: # The Member's current password that they supplied. # The type of this field is +String+. # new_password:: # The Member's elected new password. # The type of this field is +String+. # organization_id:: # 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. # The type of this field is +String+. # session_token:: # A secret token for a given Stytch Session. # The type of this field is nilable +String+. # session_duration_minutes:: # Set the session lifetime to be this many minutes from now. This will start a new session if one doesn't already exist, # returning both an opaque `session_token` and `session_jwt` for this session. Remember that the `session_jwt` will have a fixed lifetime of # five minutes regardless of the underlying session duration, and will need to be refreshed over time. # # This value must be a minimum of 5 and a maximum of 527040 minutes (366 days). # # If a `session_token` or `session_jwt` is provided then a successful authentication will continue to extend the session this many minutes. # # 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 # to use the Stytch session product, you can ignore the session fields in the response. # The type of this field is nilable +Integer+. # session_jwt:: # The JSON Web Token (JWT) for a given Stytch Session. # The type of this field is nilable +String+. # session_custom_claims:: # Add a custom claims map to the Session being authenticated. Claims are only created if a Session is initialized by providing a value in # `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 # delete a key, supply a null value. Custom claims made with reserved claims (`iss`, `sub`, `aud`, `exp`, `nbf`, `iat`, `jti`) will be ignored. # Total custom claims size cannot exceed four kilobytes. # The type of this field is nilable +object+. # locale:: # If the needs to complete an MFA step, and the Member has a phone number, this endpoint will pre-emptively send a one-time passcode (OTP) to the Member's phone number. The locale argument will be used to determine which language to use when sending the passcode. # # Parameter is a [IETF BCP 47 language tag](https://www.w3.org/International/articles/language-tags/), e.g. `"en"`. # # Currently supported languages are English (`"en"`), Spanish (`"es"`), and Brazilian Portuguese (`"pt-br"`); if no value is provided, the copy defaults to English. # # Request support for additional languages [here](https://docs.google.com/forms/d/e/1FAIpQLScZSpAu_m2AmLXRT3F3kap-s_mcV6UTBitYn6CdyWP0-o7YjQ/viewform?usp=sf_link")! # # The type of this field is nilable +ResetRequestLocale+ (string enum). # # == Returns: # An object with the following fields: # request_id:: # 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. # The type of this field is +String+. # member_id:: # Globally unique UUID that identifies a specific Member. # The type of this field is +String+. # member:: # The [Member object](https://stytch.com/docs/b2b/api/member-object) # The type of this field is +Member+ (+object+). # session_token:: # A secret token for a given Stytch Session. # The type of this field is +String+. # session_jwt:: # The JSON Web Token (JWT) for a given Stytch Session. # The type of this field is +String+. # organization:: # The [Organization object](https://stytch.com/docs/b2b/api/organization-object). # The type of this field is +Organization+ (+object+). # intermediate_session_token:: # The returned Intermediate Session Token contains a password factor associated with the Member. If this value is non-empty, the member must complete an MFA step to finish logging in to the Organization. The token can be used with the [OTP SMS Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-otp-sms), [TOTP Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-totp), or [Recovery Codes Recover endpoint](https://stytch.com/docs/b2b/api/recovery-codes-recover) to complete an MFA flow and log in to the Organization. Password factors are not transferable between Organizations, so the intermediate session token is not valid for use with discovery endpoints. # The type of this field is +String+. # member_authenticated:: # Indicates whether the Member is fully authenticated. If false, the Member needs to complete an MFA step to log in to the Organization. # The type of this field is +Boolean+. # status_code:: # 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. # The type of this field is +Integer+. # member_session:: # The [Session object](https://stytch.com/docs/b2b/api/session-object). # The type of this field is nilable +MemberSession+ (+object+). # mfa_required:: # Information about the MFA requirements of the Organization and the Member's options for fulfilling MFA. # The type of this field is nilable +MfaRequired+ (+object+). def reset( email_address:, existing_password:, new_password:, organization_id:, session_token: nil, session_duration_minutes: nil, session_jwt: nil, session_custom_claims: nil, locale: nil ) headers = {} request = { email_address: email_address, existing_password: existing_password, new_password: new_password, organization_id: organization_id } request[:session_token] = session_token unless session_token.nil? request[:session_duration_minutes] = session_duration_minutes unless session_duration_minutes.nil? request[:session_jwt] = session_jwt unless session_jwt.nil? request[:session_custom_claims] = session_custom_claims unless session_custom_claims.nil? request[:locale] = locale unless locale.nil? post_request('/v1/b2b/passwords/existing_password/reset', request, headers) end end class Discovery include Stytch::RequestHelper attr_reader :email def initialize(connection) @connection = connection @email = StytchB2B::Passwords::Discovery::Email.new(@connection) end # Authenticate an email/password combination in the discovery flow. This authenticate flow is only valid for cross-org passwords use cases, and is not tied to a specific organization. # # If you have breach detection during authentication enabled in your [password strength policy](https://stytch.com/docs/b2b/guides/passwords/strength-policies) and the member's credentials have appeared in the HaveIBeenPwned dataset, this endpoint will return a `member_reset_password` error even if the member enters a correct password. We force a password reset in this case to ensure that the member is the legitimate owner of the email address and not a malicious actor abusing the compromised credentials. # # If successful, this endpoint will create a new intermediate session and return a list of discovered organizations that can be session exchanged into. # # == Parameters: # email_address:: # The email address of the Member. # The type of this field is +String+. # password:: # The password to authenticate, reset, or set for the first time. Any UTF8 character is allowed, e.g. spaces, emojis, non-English characers, etc. # The type of this field is +String+. # # == Returns: # An object with the following fields: # request_id:: # 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. # The type of this field is +String+. # email_address:: # The email address. # The type of this field is +String+. # intermediate_session_token:: # The returned Intermediate Session Token contains a password factor associated with the Member. If this value is non-empty, the member must complete an MFA step to finish logging in to the Organization. The token can be used with the [OTP SMS Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-otp-sms), [TOTP Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-totp), or [Recovery Codes Recover endpoint](https://stytch.com/docs/b2b/api/recovery-codes-recover) to complete an MFA flow and log in to the Organization. Password factors are not transferable between Organizations, so the intermediate session token is not valid for use with discovery endpoints. # The type of this field is +String+. # discovered_organizations:: # An array of `discovered_organization` objects tied to the `intermediate_session_token`, `session_token`, or `session_jwt`. See the [Discovered Organization Object](https://stytch.com/docs/b2b/api/discovered-organization-object) for complete details. # # Note that Organizations will only appear here under any of the following conditions: # 1. The end user is already a Member of the Organization. # 2. The end user is invited to the Organization. # 3. The end user can join the Organization because: # # a) The Organization allows JIT provisioning. # # b) The Organizations' allowed domains list contains the Member's email domain. # # c) The Organization has at least one other Member with a verified email address with the same domain as the end user (to prevent phishing attacks). # The type of this field is list of +DiscoveredOrganization+ (+object+). # status_code:: # 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. # The type of this field is +Integer+. def authenticate( email_address:, password: ) headers = {} request = { email_address: email_address, password: password } post_request('/v1/b2b/passwords/discovery/authenticate', request, headers) end class Email include Stytch::RequestHelper def initialize(connection) @connection = connection end # Initiates a password reset for the email address provided, when cross-org passwords are enabled. 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. # # 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). # # == Parameters: # email_address:: # The email address of the Member to start the email reset process for. # The type of this field is +String+. # reset_password_redirect_url:: # 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 # 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. # If you have not set a default `reset_password_redirect_url`, an error is returned. # The type of this field is nilable +String+. # discovery_redirect_url:: # The URL that the end user clicks from the discovery Magic Link. This URL should be an endpoint in the backend server that # verifies the request by querying Stytch's discovery authenticate endpoint and continues the flow. If this value is not passed, the default # discovery redirect URL that you set in your Dashboard is used. If you have not set a default discovery redirect URL, an error is returned. # The type of this field is nilable +String+. # reset_password_template_id:: # 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. # The type of this field is nilable +String+. # reset_password_expiration_minutes:: # Sets a time limit after which the email link to reset the member's password will no longer be valid. # The type of this field is nilable +Integer+. # pkce_code_challenge:: # (no documentation yet) # The type of this field is nilable +String+. # locale:: # 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"`. # # Currently supported languages are English (`"en"`), Spanish (`"es"`), and Brazilian Portuguese (`"pt-br"`); if no value is provided, the copy defaults to English. # # Request support for additional languages [here](https://docs.google.com/forms/d/e/1FAIpQLScZSpAu_m2AmLXRT3F3kap-s_mcV6UTBitYn6CdyWP0-o7YjQ/viewform?usp=sf_link")! # # The type of this field is nilable +String+. # # == Returns: # An object with the following fields: # request_id:: # 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. # The type of this field is +String+. # status_code:: # 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. # The type of this field is +Integer+. def reset_start( email_address:, reset_password_redirect_url: nil, discovery_redirect_url: nil, reset_password_template_id: nil, reset_password_expiration_minutes: nil, pkce_code_challenge: nil, locale: nil ) headers = {} request = { email_address: email_address } request[:reset_password_redirect_url] = reset_password_redirect_url unless reset_password_redirect_url.nil? request[:discovery_redirect_url] = discovery_redirect_url unless discovery_redirect_url.nil? request[:reset_password_template_id] = reset_password_template_id unless reset_password_template_id.nil? request[:reset_password_expiration_minutes] = reset_password_expiration_minutes unless reset_password_expiration_minutes.nil? request[:pkce_code_challenge] = pkce_code_challenge unless pkce_code_challenge.nil? request[:locale] = locale unless locale.nil? post_request('/v1/b2b/passwords/discovery/email/reset/start', request, headers) end # Reset the password associated with an email and start an intermediate session. This endpoint checks that the password reset token is valid, hasn’t expired, or already been used. # # The provided password needs to meet the project's 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. # # Resetting a password will start an intermediate session and return a list of discovered organizations the session can be exchanged into. # # == Parameters: # password_reset_token:: # The password reset token to authenticate. # The type of this field is +String+. # password:: # The password to authenticate, reset, or set for the first time. Any UTF8 character is allowed, e.g. spaces, emojis, non-English characers, etc. # The type of this field is +String+. # pkce_code_verifier:: # (no documentation yet) # The type of this field is nilable +String+. # # == Returns: # An object with the following fields: # request_id:: # 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. # The type of this field is +String+. # intermediate_session_token:: # The returned Intermediate Session Token contains a password factor associated with the Member. If this value is non-empty, the member must complete an MFA step to finish logging in to the Organization. The token can be used with the [OTP SMS Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-otp-sms), [TOTP Authenticate endpoint](https://stytch.com/docs/b2b/api/authenticate-totp), or [Recovery Codes Recover endpoint](https://stytch.com/docs/b2b/api/recovery-codes-recover) to complete an MFA flow and log in to the Organization. Password factors are not transferable between Organizations, so the intermediate session token is not valid for use with discovery endpoints. # The type of this field is +String+. # email_address:: # The email address. # The type of this field is +String+. # discovered_organizations:: # An array of `discovered_organization` objects tied to the `intermediate_session_token`, `session_token`, or `session_jwt`. See the [Discovered Organization Object](https://stytch.com/docs/b2b/api/discovered-organization-object) for complete details. # # Note that Organizations will only appear here under any of the following conditions: # 1. The end user is already a Member of the Organization. # 2. The end user is invited to the Organization. # 3. The end user can join the Organization because: # # a) The Organization allows JIT provisioning. # # b) The Organizations' allowed domains list contains the Member's email domain. # # c) The Organization has at least one other Member with a verified email address with the same domain as the end user (to prevent phishing attacks). # The type of this field is list of +DiscoveredOrganization+ (+object+). # status_code:: # 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. # The type of this field is +Integer+. def reset( password_reset_token:, password:, pkce_code_verifier: nil ) headers = {} request = { password_reset_token: password_reset_token, password: password } request[:pkce_code_verifier] = pkce_code_verifier unless pkce_code_verifier.nil? post_request('/v1/b2b/passwords/discovery/email/reset', request, headers) end end end end end