All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.workos.usermanagement.builders.AuthenticationWithTotpOptionsBuilder.kt Maven / Gradle / Ivy

package com.workos.usermanagement.builders

import com.workos.usermanagement.types.AuthenticationAdditionalOptions
import com.workos.usermanagement.types.AuthenticationWithTotpOptions

/**
 * Builder for options when authenticating with a time-based one-time password.
 *
 * @param clientId Identifies the application making the request to the WorkOS server.
 * @param clientSecret Authenticates the application making the request to the WorkOS server.
 * @param code The one-time code generated by the user's second-factor device.
 * @param authenticationChallengeId The unique ID of the authentication challenge created for the TOTP factor for which the user is enrolled.
 * @param pendingAuthenticationToken The authentication token returned from a failed authentication attempt due to the corresponding error.
 * @param options The authentication options passed to the authentication request.
 */
class AuthenticationWithTotpOptionsBuilder(
  private val clientId: String,
  private val clientSecret: String,
  private val code: String,
  private val authenticationChallengeId: String,
  private val pendingAuthenticationToken: String,
  private val options: AuthenticationAdditionalOptions? = null
) {
  /**
   * Generates the AuthenticationWithTotpOptions object.
   */
  fun build(): AuthenticationWithTotpOptions {
    return AuthenticationWithTotpOptions(
      clientId = this.clientId,
      clientSecret = this.clientSecret,
      grantType = "urn:workos:oauth:grant-type:mfa-totp",
      code = this.code,
      authenticationChallengeId = this.authenticationChallengeId,
      pendingAuthenticationToken = this.pendingAuthenticationToken,
      invitationToken = this.options?.invitationToken,
      ipAddress = this.options?.ipAddress,
      userAgent = this.options?.userAgent,
    )
  }

  /**
   * @suppress
   */
  companion object {
    @JvmStatic
    fun create(clientId: String, clientSecret: String, code: String, authenticationChallengeId: String, pendingAuthenticationToken: String, options: AuthenticationAdditionalOptions? = null): AuthenticationWithTotpOptionsBuilder {
      return AuthenticationWithTotpOptionsBuilder(clientId, clientSecret, code, authenticationChallengeId, pendingAuthenticationToken, options)
    }
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy