Updated on 2026-08-14
This commit is contained in:
parent
6111067060
commit
8ca71f0788
25 changed files with 554 additions and 20 deletions
1
domain/visa/models/.gitignore
vendored
Normal file
1
domain/visa/models/.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
/build
|
||||
11
domain/visa/models/build.gradle.kts
Normal file
11
domain/visa/models/build.gradle.kts
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
plugins {
|
||||
alias(deps.plugins.kotlin.jvm)
|
||||
alias(deps.plugins.kotlin.serialization)
|
||||
id("configuration")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(deps.moshi.kotlin)
|
||||
implementation(deps.moshi.adapters)
|
||||
implementation(deps.kotlin.serialization)
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
package com.tangem.domain.visa.model
|
||||
|
||||
import com.squareup.moshi.Json
|
||||
import com.squareup.moshi.JsonClass
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class VisaActivationInput(
|
||||
@Json(name = "cardId") val cardId: String,
|
||||
@Json(name = "cardPublicKey") val cardPublicKey: ByteArray,
|
||||
@Json(name = "isAccessCodeSet") val isAccessCodeSet: Boolean,
|
||||
) {
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (javaClass != other?.javaClass) return false
|
||||
|
||||
other as VisaActivationInput
|
||||
|
||||
if (cardId != other.cardId) return false
|
||||
if (!cardPublicKey.contentEquals(other.cardPublicKey)) return false
|
||||
if (isAccessCodeSet != other.isAccessCodeSet) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var result = cardId.hashCode()
|
||||
result = 31 * result + cardPublicKey.contentHashCode()
|
||||
result = 31 * result + isAccessCodeSet.hashCode()
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
package com.tangem.domain.visa.model
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
enum class VisaActivationRemoteState {
|
||||
CardWalletSignatureRequired,
|
||||
CustomerWalletSignatureRequired,
|
||||
PaymentAccountDeploying,
|
||||
WaitingPinCode,
|
||||
WaitingForActivationFinishing,
|
||||
Activated,
|
||||
BlockedForActivation,
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
package com.tangem.domain.visa.model
|
||||
|
||||
sealed class VisaAuthChallenge {
|
||||
|
||||
abstract val session: VisaAuthSession
|
||||
|
||||
data class Card(
|
||||
val challenge: String,
|
||||
override val session: VisaAuthSession,
|
||||
) : VisaAuthChallenge()
|
||||
|
||||
data class Wallet(
|
||||
val challenge: String,
|
||||
override val session: VisaAuthSession,
|
||||
) : VisaAuthChallenge()
|
||||
}
|
||||
|
||||
fun VisaAuthChallenge.Card.toSignedChallenge(signedChallenge: String, salt: String): VisaAuthSignedChallenge {
|
||||
return VisaAuthSignedChallenge.ByCardPublicKey(
|
||||
challenge = this,
|
||||
signature = signedChallenge,
|
||||
salt = salt,
|
||||
)
|
||||
}
|
||||
|
||||
fun VisaAuthChallenge.Wallet.toSignedChallenge(signedChallenge: String): VisaAuthSignedChallenge {
|
||||
return VisaAuthSignedChallenge.ByWallet(
|
||||
challenge = this,
|
||||
signature = signedChallenge,
|
||||
)
|
||||
}
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
package com.tangem.domain.visa.model
|
||||
|
||||
@JvmInline
|
||||
value class VisaAuthSession(val sessionId: String)
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
package com.tangem.domain.visa.model
|
||||
|
||||
sealed class VisaAuthSignedChallenge {
|
||||
|
||||
data class ByCardPublicKey(
|
||||
val challenge: VisaAuthChallenge.Card,
|
||||
val signature: String,
|
||||
val salt: String,
|
||||
) : VisaAuthSignedChallenge()
|
||||
|
||||
data class ByWallet(
|
||||
val challenge: VisaAuthChallenge.Wallet,
|
||||
val signature: String,
|
||||
) : VisaAuthSignedChallenge()
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
package com.tangem.domain.visa.model
|
||||
|
||||
import com.squareup.moshi.Json
|
||||
import com.squareup.moshi.JsonClass
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class VisaAuthTokens(
|
||||
@Json(name = "accessToken") val accessToken: String,
|
||||
@Json(name = "refreshToken") val refreshToken: String,
|
||||
)
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
package com.tangem.domain.visa.model
|
||||
|
||||
import com.squareup.moshi.Json
|
||||
import com.squareup.moshi.adapters.PolymorphicJsonAdapterFactory
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
sealed class VisaCardActivationStatus {
|
||||
|
||||
@Serializable
|
||||
data class Activated(
|
||||
@Json(name = "visaAuthTokens") val visaAuthTokens: VisaAuthTokens,
|
||||
) : VisaCardActivationStatus()
|
||||
|
||||
@Serializable
|
||||
data class ActivationStarted(
|
||||
@Json(name = "activationInput") val activationInput: VisaActivationInput,
|
||||
@Json(name = "authTokens") val authTokens: VisaAuthTokens,
|
||||
@Json(name = "remoteState") val remoteState: VisaActivationRemoteState,
|
||||
) : VisaCardActivationStatus()
|
||||
|
||||
@Serializable
|
||||
data class NotStartedActivation(
|
||||
@Json(name = "activationInput") val activationInput: VisaActivationInput,
|
||||
) : VisaCardActivationStatus()
|
||||
|
||||
@Serializable
|
||||
data object Blocked : VisaCardActivationStatus()
|
||||
|
||||
companion object {
|
||||
val serializer: PolymorphicJsonAdapterFactory<VisaCardActivationStatus>
|
||||
get() = PolymorphicJsonAdapterFactory.of(VisaCardActivationStatus::class.java, "type")
|
||||
.withSubtype(Activated::class.java, "Activated")
|
||||
.withSubtype(ActivationStarted::class.java, "ActivationStarted")
|
||||
.withSubtype(NotStartedActivation::class.java, "NotStartedActivation")
|
||||
.withDefaultValue(Blocked)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue