Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: [ATL-2994] [Wallet SDK] Define domain interfaces and models #3

Merged
2 changes: 2 additions & 0 deletions authenticate-sdk/src/androidMain/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="io.iohk.prism.io.iohk.atala.prism.authenticatesdk.authenticate" />
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ buildscript {
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.20")
classpath("com.android.tools.build:gradle:7.2.2")
classpath("com.google.protobuf:protobuf-gradle-plugin:0.9.1")
classpath("com.squareup.sqldelight:gradle-plugin:1.5.4")
}
}

Expand Down
2 changes: 1 addition & 1 deletion castor/src/androidMain/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="io.iohk.atala.prism.walletsdk.castor" />
<manifest package="io.iohk.atala.prism.walletsdk.castor" />
2 changes: 1 addition & 1 deletion core-sdk/src/androidMain/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="io.iohk.atala.prism.walletcore" />
<manifest package="io.iohk.atala.prism.walletcore" />
1 change: 1 addition & 0 deletions domain/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ kotlin {
dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.4.1")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4")
implementation("com.benasher44:uuid:0.3.0") // TODO("use Apollo UUID")
}
}
val commonTest by getting {
Expand Down
2 changes: 1 addition & 1 deletion domain/src/androidMain/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="io.iohk.atala.prism.walletsdk.domain" />
<manifest package="io.iohk.atala.prism.walletsdk.domain" />
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package io.iohk.atala.prism.domain.buildingBlocks

import io.iohk.atala.prism.domain.models.DID
import io.iohk.atala.prism.domain.models.DIDDocument
import io.iohk.atala.prism.domain.models.KeyPair
import io.iohk.atala.prism.domain.models.PublicKey

interface Castor {

@Throws()
fun parseDID(did: String): DID

@Throws()
fun createPrismDID(
masterPublicKey: PublicKey,
services: Array<DIDDocument.Service>? = null
): DID

@Throws()
fun createPeerDID(
keyAgreementKeyPair: KeyPair,
authenticationKeyPair: KeyPair,
services: Array<DIDDocument.Service>
): DID

@Throws()
suspend fun resolveDID(did: DID): DIDDocument

@Throws()
suspend fun verifySignature(
did: DID,
challenge: ByteArray,
signature: ByteArray
): Boolean

@Throws()
fun getEcnumbasis(
did: DID,
keyPair: KeyPair
): String
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package io.iohk.atala.prism.domain.buildingBlocks

import io.iohk.atala.prism.domain.models.Message

interface Mercury {

@Throws()
suspend fun packMessage(message: Message): String

@Throws()
suspend fun unpackMessage(message: String): Message

@Throws()
suspend fun sendMessage(message: Message): ByteArray?

@Throws()
suspend fun sendMessageParseMessage(message: Message): Message?
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package io.iohk.atala.prism.domain.buildingBlocks

import io.iohk.atala.prism.domain.models.DID
import io.iohk.atala.prism.domain.models.DIDPair
import io.iohk.atala.prism.domain.models.MediatorDID
import io.iohk.atala.prism.domain.models.Message
import io.iohk.atala.prism.domain.models.PeerDID
import io.iohk.atala.prism.domain.models.PrismDIDInfo
import io.iohk.atala.prism.domain.models.PrivateKey
import io.iohk.atala.prism.domain.models.VerifiableCredential
import kotlinx.coroutines.flow.Flow

interface Pluto {

fun storePrismDID(
did: DID,
keyPairIndex: Int,
alias: String?
)

fun storePeerDID(did: DID, privateKeys: Array<PrivateKey>)

fun storeDIDPair(holder: DID, other: DID, name: String)

fun storeMessage(message: Message, direction: Message.Direction)

fun storeMessages(messages: Map<Message, Message.Direction>)

fun storeMediator(peer: DID, routingDID: DID, mediatorDID: DID)

fun storeCredential(credential: VerifiableCredential)

fun getAllPrismDIDs(): Flow<Array<PrismDIDInfo>>

fun getPrismDIDInfo(did: DID): Flow<PrismDIDInfo?>

fun getPrismDIDInfo(alias: String): Flow<Array<PrismDIDInfo>>

fun getPrismDIDKeyPairIndex(did: DID): Flow<Int?>

fun getPrismLastKeyPairIndex(): Flow<Int>

fun getAllPeerDIDs(): Flow<Array<PeerDID>>

fun getPeerDIDInfo(did: DID): Flow<PeerDID?>

fun getPeerDIDPrivateKeys(did: DID): Flow<Array<PrivateKey>?>

fun getAllDidPairs(): Flow<Array<DIDPair>>

fun getPair(did: DID): Flow<Array<DIDPair>?>

fun getPair(name: String): Flow<DIDPair?>

fun getAllMessages(): Flow<Array<Message>>

fun getAllMessages(did: DID): Flow<Array<Message>>

fun getAllMessagesSent(): Flow<Array<Message>>

fun getAllMessagesReceived(): Flow<Array<Message>>

fun getAllMessagesSentTo(did: DID): Flow<Array<Message>>

fun getAllMessagesReceivedFrom(did: DID): Flow<Array<Message>>

fun getAllMessagesOfType(type: String, relatedWithDID: DID?): Flow<Array<Message>>

fun getAllMessages(from: DID, to: DID): Flow<Array<Message>>

fun getMessage(id: String): Flow<Message?>

fun getAllMediators(): Flow<Array<MediatorDID>>

fun getAllCredentials(): Flow<Array<VerifiableCredential>>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package io.iohk.atala.prism.domain.buildingBlocks

import io.iohk.atala.prism.domain.models.VerifiableCredential

interface Pollux {

@Throws
fun parseVerifiableCredential(jsonString: String): VerifiableCredential
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package io.iohk.atala.prism.domain.models
data class DID(
val schema: String,
val method: String,
val methodId: String
) {

constructor(
string: String
) : this(getSchemaFromString(string), getMethodFromString(string), getMethodIdFromString(string))

override fun toString(): String {
return "$schema:$method:$methodId"
}

companion object {
fun getSchemaFromString(string: String): String {
val split = string.split(":")
return split[0]
}

fun getMethodFromString(string: String): String {
val split = string.split(":")
return split[1]
}

fun getMethodIdFromString(string: String): String {
val split = string.split(":")
return split[2]
}
}
}
Loading