Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions miracl-sdk/src/main/java/com/miracl/trust/MIRACLResult.kt
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package com.miracl.trust

/**
* MIRACLResult is a class representing the MIRACLTrust SDK responses.
* MIRACLResult is a class representing the MIRACL Trust SDK responses.
*/
public sealed class MIRACLResult<SUCCESS, FAIL>

/**
* MIRACLSuccess<SUCCESS, FAIL> is a success response from the MIRACLTrust SDK.
* MIRACLSuccess<SUCCESS, FAIL> is a success response from the MIRACL Trust SDK.
* It provides a value of type SUCCESS.
*/
public data class MIRACLSuccess<SUCCESS, FAIL>(val value: SUCCESS) : MIRACLResult<SUCCESS, FAIL>()

/**
* MIRACLError<SUCCESS, FAIL> is an error response from the MIRACLTrust SDK.
* MIRACLError<SUCCESS, FAIL> is an error response from the MIRACL Trust SDK.
* It provides a value of type FAIL and an optional exception.
*/
public data class MIRACLError<SUCCESS, FAIL>(val value: FAIL) : MIRACLResult<SUCCESS, FAIL>()
585 changes: 291 additions & 294 deletions miracl-sdk/src/main/java/com/miracl/trust/MIRACLTrust.kt

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@ package com.miracl.trust.authentication

/** A class hierarchy that describes authentication issues. */
public sealed class AuthenticationException(cause: Throwable? = null) : Exception(cause) {
/** User object passed for authentication is not valid. */
/** The user object passed for authentication is not valid. */
public object InvalidUserData : AuthenticationException()

/** Could not find the session identifier in App Link. */
/** Could not find the session identifier in the App Link. */
public object InvalidAppLink : AuthenticationException()

/** Could not find the session identifier in QR URL. */
/** Could not find the session identifier in the QR code URL. */
public object InvalidQRCode : AuthenticationException()

/** Could not find a valid projectID, qrURL, or userID in the push notification payload. */
public object InvalidPushNotificationPayload : AuthenticationException()

/** There isn't a registered user for the provided user ID and project in the push notification payload. */
/** There is no registered user for the provided User ID and project in the push notification payload. */
public object UserNotFound : AuthenticationException()

/** Pin code includes invalid symbols or pin length does not match. */
/** PIN code contains invalid symbols or PIN length does not match. */
public object InvalidPin : AuthenticationException()

/** Pin not entered. */
/** PIN not entered. */
public object PinCancelled : AuthenticationException()

/** Invalid or expired authentication session. */
Expand All @@ -29,11 +29,11 @@ public sealed class AuthenticationException(cause: Throwable? = null) : Exceptio
/** Invalid or expired cross-device session. */
public object InvalidCrossDeviceSession : AuthenticationException()

/** The authentication was not successful. */
/** Authentication was not successful. */
public object UnsuccessfulAuthentication : AuthenticationException()

/** The user is revoked because of too many unsuccessful authentication attempts or has not been
* used in a substantial amount of time. The device needs to be re-registered.
/** The user was revoked due to too many failed authentication attempts or prolonged
* inactivity. The device must be re-registered.
*/
public object Revoked : AuthenticationException()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import kotlin.coroutines.CoroutineContext
import kotlin.jvm.Throws

/**
* The Configuration class is used to set up the MIRACLTrust SDK. It provides a way
* The Configuration class is used to set up the MIRACL Trust SDK. It provides a way
* to customize some of the SDK components.
*
* Instance is created though its [Builder]
* Instance is created through its [Builder].
*/
public class Configuration private constructor(
internal val projectId: String,
Expand Down Expand Up @@ -73,7 +73,7 @@ public class Configuration private constructor(
* Builds a [Configuration] object.
*
* @param projectId The unique identifier for your MIRACL Trust project.
* @param projectUrl MIRACL Trust Project URL that is used for communication with the MIRACL Trust API.
* @param projectUrl The MIRACL Trust Project URL that is used for communication with the MIRACL Trust API.
*/
public class Builder @JvmOverloads constructor(
internal val projectId: String,
Expand Down Expand Up @@ -107,64 +107,64 @@ public class Configuration private constructor(
apply { this.coroutineContext = coroutineContext }

/**
* Sets additional information that will be sent via X-MIRACL-CLIENT HTTP header.
* Sets additional information that will be sent via the X-MIRACL-CLIENT HTTP header.
*/
public fun applicationInfo(applicationInfo: String): Builder =
apply { this.applicationInfo = applicationInfo }

/**
* Sets value of device name.
* Sets the value of the device name.
*/
public fun deviceName(deviceName: String): Builder =
apply { this.deviceNameValue = deviceName }

/**
* Provides implementation of the [HttpRequestExecutor] interface to be used by the SDK.
* Provides the implementation of the [HttpRequestExecutor] interface to be used by the SDK.
*/
public fun httpRequestExecutor(httpRequestExecutor: HttpRequestExecutor): Builder =
apply { this.httpRequestExecutorValue = httpRequestExecutor }

/**
* Provides implementation of the [UserStorage] interface to be used by the SDK.
* Provides the implementation of the [UserStorage] interface to be used by the SDK.
*/
public fun userStorage(userStorage: UserStorage): Builder =
apply { this.userStorage = userStorage }

/**
* Provides implementation of the [Logger] interface to be used by the SDK.
* Provides the implementation of the [Logger] interface to be used by the SDK.
*/
public fun logger(logger: Logger): Builder =
apply { this.loggerValue = logger }

/**
* Provides specific [Logger.LoggingLevel] to be used by the SDK default logger.
*
* The default is [Logger.LoggingLevel.NONE]
* The default is [Logger.LoggingLevel.NONE].
* >
* **Has no effect if using custom logger provided by
* [logger(logger: Logger)][logger]**
* [logger(logger: Logger)][logger].**
*/
public fun loggingLevel(loggingLevel: Logger.LoggingLevel): Builder =
apply { this.loggingLevel = loggingLevel }

/**
* Sets HTTP requests connect timeout in seconds to be used by the SDK default [HttpRequestExecutor].
* Sets the HTTP requests connect timeout in seconds to be used by the SDK default [HttpRequestExecutor].
*
* The default is 10 seconds.
* >
* **Has no effect if using custom HTTP request executor provided by
* [httpRequestExecutor(httpRequestExecutor: HttpRequestExecutor)][httpRequestExecutor]**
* **Has no effect if using the custom HTTP request executor provided by
* [httpRequestExecutor(httpRequestExecutor: HttpRequestExecutor)][httpRequestExecutor].**
*/
public fun connectTimeout(connectTimeout: Int): Builder =
apply { this.connectTimeout = connectTimeout }

/**
* Sets HTTP requests read timeout in seconds to be used by the SDK default [HttpRequestExecutor].
* Sets the HTTP requests read timeout in seconds to be used by the SDK default [HttpRequestExecutor].
*
* The default is 10 seconds.
* >
* **Has no effect if using custom HTTP request executor provided by
* [httpRequestExecutor(httpRequestExecutor: HttpRequestExecutor)][httpRequestExecutor]**
* **Has no effect if using the custom HTTP request executor provided by
* [httpRequestExecutor(httpRequestExecutor: HttpRequestExecutor)][httpRequestExecutor].**
*/
public fun readTimeout(readTimeout: Int): Builder =
apply { this.readTimeout = readTimeout }
Expand Down Expand Up @@ -198,4 +198,4 @@ public class Configuration private constructor(
return Configuration(this)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.miracl.trust.configuration
/** A class hierarchy that describes issues with the SDK configuration. */
public sealed class ConfigurationException : Exception() {

/** Empty project ID. */
/** Empty Project ID. */
public object EmptyProjectId : ConfigurationException()

/** Invalid Project URL. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import androidx.annotation.Nullable;

/**
* An interface used to allow the application, using the MIRACLTrust SDK, to pass the PIN
* An interface used to allow the application, using the MIRACL Trust SDK, to pass the PIN
* to the SDK.
*/
public interface PinConsumer {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import androidx.annotation.NonNull;

/**
* An interface used to allow the MIRACLTrust SDK to request PIN. The application using
* the SDK is responsible for obtaining the PIN from the user and then pass it
* An interface used to allow the MIRACL Trust SDK to request PIN. The application using
* the SDK is responsible for obtaining the PIN from the user and then passing it
* to the {@link PinConsumer}.
*/
public interface PinProvider {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@
import com.miracl.trust.MIRACLError;

/**
* An interface used to connect MIRACLTrust SDK output to your application.
* An interface used to connect the MIRACL Trust SDK output to your application.
*
* <p>This interface defines the {@link #onResult(MIRACLResult)} method, which handles the result of a MIRACLTrust SDK operation.
* <p>This interface defines the {@link #onResult(MIRACLResult)} method which handles the result of a MIRACL Trust SDK operation.
* <b>Important:</b> Implementations of this method will be invoked on the main thread.</p>
*
* @param <SUCCESS> type of the value on success.
* @param <FAIL> type of the value on failure.
* @param <SUCCESS> The value type on success.
* @param <FAIL> The value type on failure.
*/
public interface ResultHandler<SUCCESS, FAIL> {
/**
* Handles the result of a MIRACLTrust SDK operation.
* Handles the result of a MIRACL Trust SDK operation.
*
* <p><b>Important:</b> The implementation of this method will be invoked on the main thread.</p>
*
* @param result The {@link MIRACLResult} containing the result of the SDK operation.
* It can be either a {@link MIRACLSuccess} or a {@link MIRACLError}.
*/
void onResult(@NonNull MIRACLResult<SUCCESS, FAIL> result);
}
}
4 changes: 2 additions & 2 deletions miracl-sdk/src/main/java/com/miracl/trust/model/QuickCode.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import java.io.Serializable
/**
* Object representing QuickCode and its validity period.
* @property code The issued QuickCode.
* @property expireTime MIRACL MFA system time when the code will expire.
* @property expireTime The MIRACL Trust system time when the code will expire.
* @property ttlSeconds The expiration period in seconds.
*/
public class QuickCode internal constructor(
Expand All @@ -16,4 +16,4 @@ public class QuickCode internal constructor(
override fun toString(): String {
return "QuickCode(code=<REDACTED>, expireTime=$expireTime, ttlSeconds=$ttlSeconds"
}
}
}
10 changes: 5 additions & 5 deletions miracl-sdk/src/main/java/com/miracl/trust/model/User.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import com.miracl.trust.util.toSHA256

/**
* Object representing the user in the platform.
* @property userId Identifier of the user. Could be email, username, etc.
* @property projectId Required to link the user with the project on the MIRACLTrust platform.
* @property revoked Provides information if the user is revoked or not.
* @property pinLength The number of the digits the user PIN should be.
* @property userId The identifier of the user.
* @property projectId Required to link the user with the project on the MIRACL Trust platform.
* @property revoked Provides information about whether the user is revoked or not.
* @property pinLength The number of digits in the user's PIN.
*/
@Keep
public class User internal constructor(
Expand Down Expand Up @@ -49,4 +49,4 @@ internal fun User.revoke(): User = User(
token = token,
dtas = dtas,
publicKey = publicKey
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package com.miracl.trust.network
public sealed class ApiException(public val url: String, cause: Throwable? = null) :
Exception(cause) {

/** Error while executing HTTP request. */
/** Error while executing the HTTP request. */
public class ExecutionError internal constructor(url: String = "", cause: Throwable? = null) :
ApiException(url, cause)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.miracl.trust.network

/***
* HttpMethod is a MIRACLTrust SDK representation of the HTTP methods
* HttpMethod is a MIRACL Trust SDK representation of the HTTP methods.
*/
public enum class HttpMethod(public val method: String) {
GET("GET"),
Expand All @@ -11,7 +11,7 @@ public enum class HttpMethod(public val method: String) {
}

/***
* ApiRequest is a data class that keeps the main properties of a HTTP request.
* ApiRequest is a data class that keeps the main properties of an HTTP request.
*/
public data class ApiRequest(
val method: HttpMethod,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.miracl.trust.network

/**
* Client error representation which is returned by the MIRACL API.
* Client error representation which is returned by the MIRACL Trust API.
*
* @property code Code of the error.
* @property info Human readable representation of the error.
* @property code The code of the error.
* @property info The human-readable representation of the error.
* @property context Additional information received in the error response.
*/
public class ClientErrorData internal constructor(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
package com.miracl.trust.network

import com.miracl.trust.MIRACLError
import com.miracl.trust.MIRACLResult
import com.miracl.trust.MIRACLSuccess

/**
* HttpRequestExecutor is an interface providing pluggable networking layer
* of the MIRACLTrust SDK. If implemented and passed as an argument when initializing the
* MIRACLTrust SDK, you can provide your own HTTP request executor.
* HttpRequestExecutor is an interface providing a pluggable networking layer
* of the MIRACL Trust SDK. If implemented and passed as an argument when initializing the
* MIRACL Trust SDK, you can provide your own HTTP request executor.
*/
public interface HttpRequestExecutor {

/**
* Executes HTTP requests.
* @param apiRequest provides the required information for processing the HTTP request.
* @param apiRequest Provides the required information for processing the HTTP request.
* @return MIRACLResult<String, HttpRequestExecutorException> which can be either:
* - MIRACLSuccess with value of type [String] (the response of the executed request)
* - MIRACLError with value of type [HttpRequestExecutorException].
* - [MIRACLSuccess] with a value of type [String] (the response of the executed request).
* - [MIRACLError] with a value of type [HttpRequestExecutorException].
*/
public suspend fun execute(apiRequest: ApiRequest): MIRACLResult<String, HttpRequestExecutorException>
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public sealed class HttpRequestExecutorException(
public class HttpError(public val responseCode: Int, public val responseBody: String) :
HttpRequestExecutorException()

/** Error while executing HTTP request. */
/** Error while executing the HTTP request. */
public class ExecutionError(message: String? = null, cause: Throwable? = null) :
HttpRequestExecutorException(message = message, cause = cause)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.miracl.trust.network
import com.miracl.trust.MIRACLError
import com.miracl.trust.MIRACLResult
import com.miracl.trust.MIRACLSuccess
import com.miracl.trust.MIRACLTrust
import com.miracl.trust.util.log.Loggable
import com.miracl.trust.util.log.LoggerConstants
import com.miracl.trust.util.log.LoggerConstants.NETWORK_TAG
Expand Down Expand Up @@ -42,12 +43,12 @@ internal class HttpsURLConnectionRequestExecutor(

/**
* Implementation of the [HttpRequestExecutor.execute].
* @param apiRequest is a MIRACLTrust class that provides the needed data for
* a http request to be executed.
* @param apiRequest А [MIRACLTrust] class that provides the needed data for
* an HTTP request to be executed.
* @return MIRACLResult<String, HttpRequestExecutorException>
* - If the result is success execute returns MIRACLSuccess with a string value of the
* - If successful, the execute returns a [MIRACLSuccess] with a string value of the
* received response.
* - If the result is error execute returns the error with a message.
* - If an error occurs, the execute returns a [MIRACLError] with a message.
* If an exception is thrown, the error passes the exception as an object.
*/
override suspend fun execute(apiRequest: ApiRequest): MIRACLResult<String, HttpRequestExecutorException> {
Expand Down Expand Up @@ -165,4 +166,4 @@ internal class HttpsURLConnectionRequestExecutor(
require(millis <= Int.MAX_VALUE) { "timeout too large." }
return millis.toInt()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import androidx.annotation.Keep
import com.miracl.trust.MIRACLTrust

/**
* The response returned from [getActivationToken][MIRACLTrust.getActivationToken] method when there is an error in the request.
* @property projectId Identifier of the project against which the verification is performed.
* @property userId Identifier of the user for which the verification is performed.
* @property accessId Identifier of the session from which the verification started.
* The response returned from the [getActivationToken][MIRACLTrust.getActivationToken] method when there is an error in the request.
* @property projectId The identifier of the project against which the verification is performed.
* @property userId The identifier of the user for which the verification is performed.
* @property accessId The identifier of the session from which the verification started.
*/
@Keep
public class ActivationTokenErrorResponse internal constructor(
Expand Down
Loading
Loading