Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
package com.stytch.java.b2b.api.passwordsemail
// !!!
// WARNING: This file is autogenerated
// Only modify code within MANUAL() sections
// or your changes may be overwritten later!
// !!!
import com.squareup.moshi.Moshi
import com.stytch.java.b2b.models.passwordsemail.ResetRequest
import com.stytch.java.b2b.models.passwordsemail.ResetResponse
import com.stytch.java.b2b.models.passwordsemail.ResetStartRequest
import com.stytch.java.b2b.models.passwordsemail.ResetStartResponse
import com.stytch.java.common.InstantAdapter
import com.stytch.java.common.StytchResult
import com.stytch.java.http.HttpClient
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.async
import kotlinx.coroutines.future.asCompletableFuture
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import java.util.concurrent.CompletableFuture
public interface Email {
/**
* 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).
*/
public suspend fun resetStart(data: ResetStartRequest): StytchResult
/**
* 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).
*/
public fun resetStart(
data: ResetStartRequest,
callback: (StytchResult) -> Unit,
)
/**
* 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).
*/
public fun resetStartCompletable(data: ResetStartRequest): CompletableFuture>
/**
* 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.
*
* 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.
*/
public suspend fun reset(data: ResetRequest): StytchResult
/**
* 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.
*
* 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.
*/
public fun reset(
data: ResetRequest,
callback: (StytchResult) -> Unit,
)
/**
* 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.
*
* 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.
*/
public fun resetCompletable(data: ResetRequest): CompletableFuture>
}
internal class EmailImpl(
private val httpClient: HttpClient,
private val coroutineScope: CoroutineScope,
) : Email {
private val moshi = Moshi.Builder().add(InstantAdapter()).build()
override suspend fun resetStart(data: ResetStartRequest): StytchResult =
withContext(Dispatchers.IO) {
var headers = emptyMap()
val asJson = moshi.adapter(ResetStartRequest::class.java).toJson(data)
httpClient.post("/v1/b2b/passwords/email/reset/start", asJson, headers)
}
override fun resetStart(
data: ResetStartRequest,
callback: (StytchResult) -> Unit,
) {
coroutineScope.launch {
callback(resetStart(data))
}
}
override fun resetStartCompletable(data: ResetStartRequest): CompletableFuture> =
coroutineScope.async {
resetStart(data)
}.asCompletableFuture()
override suspend fun reset(data: ResetRequest): StytchResult =
withContext(Dispatchers.IO) {
var headers = emptyMap()
val asJson = moshi.adapter(ResetRequest::class.java).toJson(data)
httpClient.post("/v1/b2b/passwords/email/reset", asJson, headers)
}
override fun reset(
data: ResetRequest,
callback: (StytchResult) -> Unit,
) {
coroutineScope.launch {
callback(reset(data))
}
}
override fun resetCompletable(data: ResetRequest): CompletableFuture> =
coroutineScope.async {
reset(data)
}.asCompletableFuture()
}