diff --git a/README.md b/README.md index 594764535..1cef706b0 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Atala Prism Wallet SDK - Kotlin Multiplatform (Android/JVM) -[![Kotlin](https://img.shields.io/badge/kotlin-1.7.20-blue.svg?logo=kotlin)](http://kotlinlang.org) +[![Kotlin](https://img.shields.io/badge/kotlin-1.9.10-blue.svg?logo=kotlin)](http://kotlinlang.org) ![android](https://camo.githubusercontent.com/b1d9ad56ab51c4ad1417e9a5ad2a8fe63bcc4755e584ec7defef83755c23f923/687474703a2f2f696d672e736869656c64732e696f2f62616467652f706c6174666f726d2d616e64726f69642d3645444238442e7376673f7374796c653d666c6174) ![jvm](https://camo.githubusercontent.com/700f5dcd442fd835875568c038ae5cd53518c80ae5a0cf12c7c5cf4743b5225b/687474703a2f2f696d672e736869656c64732e696f2f62616467652f706c6174666f726d2d6a766d2d4442343133442e7376673f7374796c653d666c6174) @@ -20,32 +20,32 @@ Atala PRISM is a self-sovereign identity (SSI) platform and service suite for ve The complete platform is separated in multiple repositories: * [atala-prism-wallet-sdk-swift](https://github.com/input-output-hk/atala-prism-wallet-sdk-swift) - Repo that implements Atala PRISM for Apple platforms in Swift. -* [atala-prism-wallet-sdk-ts](https://github.com/input-output-hk/atala-prism-wallet-sdk-ts) - Repo that implements Atala PRISM for Browser and NodeJS platforms in Typescript. +* [atala-prism-wallet-sdk-ts](https://github.com/input-output-hk/atala-prism-wallet-sdk-ts) - Repo that implements Atala PRISM for Browser and Node.js platforms in Typescript. * [atala-prism-building-blocks](https://github.com/input-output-hk/atala-prism-building-blocks) - Repo that contains the platform Building Blocks. ### Modules / APIs Atala PRISM Kotlin multiplatform SDK provides the following building blocks to create, manage and resolve decentralized identifiers, issue, manage and verify verifiable credentials, establish and manage trusted, peer-to-peer connections and interactions between DIDs, and store, manage, and recover verifiable data linked to DIDs. -* __Apollo__: Building block that provides a suite of criptographic operations. +* __Apollo__: Building block that provides a suite of cryptographic operations. * __Castor__: Building block that provides a suite of DID operations in a user-controlled manner. * __Pollux__: Building block that provides a suite of credential operations in a privacy-preserving manner. * __Mercury__: Building block that provides a set of secure, standards-based communications protocols in a transport-agnostic and interoperable manner. * __Pluto__: Building block that provides an interface for storage operations in a portable, storage-agnostic manner. -* __PrismAgent__: PrismAgent using all the building blocks provides a agent that can provide a set of high level DID functionalities. +* __PrismAgent__: PrismAgent using all the building blocks provides an agent that can provide a set of high level DID functionalities. ## Getting started ### Setup -To get started with the Atala PRISM kotlin multiplaform SDK, you can set up the SDK and start a new project or integrate it into an existing project. Before you start, make sure you have the following installed on your development machine: +To get started with the Atala PRISM kotlin multiplatform SDK, you can set up the SDK and start a new project or integrate it into an existing project. Before you start, make sure you have the following installed on your development machine: - Android: API level 21 and above. -- Kotlin 1.7.20 or later. +- Kotlin 1.9.10 or later. - JVM: 11 or later. ### Integrating the SDK in an existing project -To integrate the SDK into an exiting project, you have to import the SDK into your project: +To integrate the SDK into an exciting project, you have to import the SDK into your project: `implementation("io.iohk.atala.prism:walletsdk:$sdk_version")` diff --git a/atala-prism-sdk/build.gradle.kts b/atala-prism-sdk/build.gradle.kts index 8376e568c..4b76c2efa 100644 --- a/atala-prism-sdk/build.gradle.kts +++ b/atala-prism-sdk/build.gradle.kts @@ -10,10 +10,10 @@ val didpeerVersion = project.property("didpeer_version") plugins { id("com.squareup.sqldelight") kotlin("multiplatform") - kotlin("plugin.serialization") version "1.7.20" + kotlin("plugin.serialization") id("com.android.library") id("org.jetbrains.dokka") - id("org.jetbrains.kotlinx.kover") version "0.7.0" + id("org.jetbrains.kotlinx.kover") version "0.7.3" } koverReport { @@ -39,7 +39,7 @@ koverReport { } kotlin { - android { + androidTarget { publishAllLibraryVariants() } @@ -100,14 +100,14 @@ kotlin { kotlin.srcDir("${project(":protosLib").buildDir}/generated/source/proto/main/kotlin") resources.srcDir("${project(":protosLib").projectDir}/src/main") dependencies { - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4") - implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.4.0") - implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.4.1") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3") + implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.4.1") + implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.0") - implementation("io.ktor:ktor-client-core:2.1.3") - implementation("io.ktor:ktor-client-content-negotiation:2.1.3") - implementation("io.ktor:ktor-serialization-kotlinx-json:2.1.3") - implementation("io.ktor:ktor-client-logging:2.1.3") + implementation("io.ktor:ktor-client-core:2.3.4") + implementation("io.ktor:ktor-client-content-negotiation:2.3.4") + implementation("io.ktor:ktor-serialization-kotlinx-json:2.3.4") + implementation("io.ktor:ktor-client-logging:2.3.4") implementation("io.iohk.atala.prism.didcomm:didpeer:$didpeerVersion") @@ -122,13 +122,13 @@ kotlin { implementation("pro.streem.pbandk:pbandk-runtime:0.14.2") - implementation("org.didcommx:didcomm:0.3.0") + implementation("org.didcommx:didcomm:0.3.2") implementation("com.google.protobuf:protoc:3.12.0") { exclude("com.google.protobuf") } - implementation("com.squareup.sqldelight:coroutines-extensions:1.5.4") + implementation("com.squareup.sqldelight:coroutines-extensions:1.5.5") api("org.lighthousegames:logging:1.1.2") } @@ -136,15 +136,15 @@ kotlin { val commonTest by getting { dependencies { implementation(kotlin("test")) - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.4") - implementation("io.ktor:ktor-client-mock:2.1.3") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.7.3") + implementation("io.ktor:ktor-client-mock:2.3.4") } } val jvmMain by getting { dependencies { - implementation("io.ktor:ktor-client-okhttp:2.1.3") + implementation("io.ktor:ktor-client-okhttp:2.3.4") implementation("org.bouncycastle:bcprov-jdk15on:1.68") - implementation("com.squareup.sqldelight:sqlite-driver:1.5.4") + implementation("com.squareup.sqldelight:sqlite-driver:1.5.5") } } val jvmTest by getting { @@ -154,13 +154,13 @@ kotlin { } val androidMain by getting { dependencies { - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4") - implementation("io.ktor:ktor-client-okhttp:2.1.3") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3") + implementation("io.ktor:ktor-client-okhttp:2.3.4") implementation("org.bouncycastle:bcprov-jdk15on:1.68") - implementation("com.squareup.sqldelight:android-driver:1.5.4") + implementation("com.squareup.sqldelight:android-driver:1.5.5") } } - val androidTest by getting { + val androidUnitTest by getting { dependencies { implementation("junit:junit:4.13.2") } @@ -257,7 +257,7 @@ tasks.withType().configureEach { val antlrGenerationTask by tasks.register("generateKotlinCommonGrammarSource") { // the classpath used to run antlr code generation antlrClasspath = configurations.detachedConfiguration( - project.dependencies.create("com.github.piacenti:antlr-kotlin-runtime:0.0.14"), + project.dependencies.create("com.github.piacenti:antlr-kotlin-runtime:0.0.14") ) maxHeapSize = "64m" packageName = "io.iohk.atala.prism.walletsdk.castor.antlrgrammar" diff --git a/atala-prism-sdk/docs/Apollo.md b/atala-prism-sdk/docs/Apollo.md index 0886f8a73..67780e61f 100644 --- a/atala-prism-sdk/docs/Apollo.md +++ b/atala-prism-sdk/docs/Apollo.md @@ -22,7 +22,7 @@ Public-key encryption uses a public encryption key to encrypt data so that only ### Accumulators -Cryptographic accumulators allow for the accumulation of multiple values into one. Merkle trees are the most common type of accumulator used in the cryptocurrency domain. Accumulators make it possible to check (and prove) whether a given value has been accumulated. +Cryptographic accumulators allow for the accumulation of multiple values into one. Merkle's trees are the most common type of accumulator used in the cryptocurrency domain. Accumulators make it possible to check (and prove) whether a given value has been accumulated. ### MAC diff --git a/atala-prism-sdk/src/androidMain/kotlin/io/iohk/atala/prism/walletsdk/pluto/data/DbConnection.kt b/atala-prism-sdk/src/androidMain/kotlin/io/iohk/atala/prism/walletsdk/pluto/data/DbConnection.kt index a0aa0dda1..e864f6093 100644 --- a/atala-prism-sdk/src/androidMain/kotlin/io/iohk/atala/prism/walletsdk/pluto/data/DbConnection.kt +++ b/atala-prism-sdk/src/androidMain/kotlin/io/iohk/atala/prism/walletsdk/pluto/data/DbConnection.kt @@ -8,15 +8,11 @@ import io.iohk.atala.prism.walletsdk.domain.models.PlutoError actual class DbConnection actual constructor() { actual var driver: SqlDriver? = null - actual suspend fun connectDb( - context: Any?, - ): PrismPlutoDb { + actual suspend fun connectDb(context: Any?): PrismPlutoDb { val androidContext: Context = (context as? Context) ?: throw PlutoError.DatabaseContextError() val driver = AndroidSqliteDriver(PrismPlutoDb.Schema, androidContext, "prism.db") this.driver = driver - return PrismPlutoDb( - driver, - ) + return PrismPlutoDb(driver) } } diff --git a/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/AtalaPrismSDK.kt b/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/AtalaPrismSDK.kt deleted file mode 100644 index 5a1462013..000000000 --- a/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/AtalaPrismSDK.kt +++ /dev/null @@ -1,3 +0,0 @@ -package io.iohk.atala.prism.walletsdk - -class AtalaPrismSDK diff --git a/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/apollo/ApolloImpl.kt b/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/apollo/ApolloImpl.kt index 95aca08de..a03b498d0 100644 --- a/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/apollo/ApolloImpl.kt +++ b/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/apollo/ApolloImpl.kt @@ -51,8 +51,8 @@ class ApolloImpl : Apollo { return Seed( value = KeyDerivation.binarySeed( seed = mnemonicCode, - passphrase = passphrase, - ), + passphrase = passphrase + ) ) } @@ -70,9 +70,9 @@ class ApolloImpl : Apollo { Seed( value = KeyDerivation.binarySeed( seed = mnemonicCode, - passphrase = passphrase ?: "", - ), - ), + passphrase = passphrase ?: "" + ) + ) ) } @@ -98,12 +98,12 @@ class ApolloImpl : Apollo { keyCurve = curve, privateKey = PrivateKey( keyCurve = curve, - value = privateKey.getEncoded(), + value = privateKey.getEncoded() ), publicKey = PublicKey( curve = curve, - value = publicKey.getEncoded(), - ), + value = publicKey.getEncoded() + ) ) } @@ -133,12 +133,12 @@ class ApolloImpl : Apollo { keyCurve = privateKey.keyCurve, privateKey = PrivateKey( keyCurve = privateKey.keyCurve, - value = kmmPrivateKey.getEncoded(), + value = kmmPrivateKey.getEncoded() ), publicKey = PublicKey( curve = privateKey.keyCurve, - value = kmmPrivateKey.getPublicKey().getEncoded(), - ), + value = kmmPrivateKey.getPublicKey().getEncoded() + ) ) } @@ -150,12 +150,12 @@ class ApolloImpl : Apollo { keyCurve = privateKey.keyCurve, privateKey = PrivateKey( keyCurve = privateKey.keyCurve, - value = edPrivateKey.encoded, + value = edPrivateKey.encoded ), publicKey = PublicKey( curve = privateKey.keyCurve, - value = edPublicKey.encoded, - ), + value = edPublicKey.encoded + ) ) } @@ -167,12 +167,12 @@ class ApolloImpl : Apollo { keyCurve = privateKey.keyCurve, privateKey = PrivateKey( keyCurve = privateKey.keyCurve, - value = xPrivateKey.encoded, + value = xPrivateKey.encoded ), publicKey = PublicKey( curve = privateKey.keyCurve, - value = xPublicKey.encoded, - ), + value = xPublicKey.encoded + ) ) } } @@ -189,7 +189,7 @@ class ApolloImpl : Apollo { val kmmCompressed = kmmPublicKey.getEncodedCompressed() return CompressedPublicKey( uncompressed = publicKey, - value = kmmCompressed, + value = kmmCompressed ) } @@ -204,11 +204,11 @@ class ApolloImpl : Apollo { val kmmCompressed = kmmPublicKey.getEncodedCompressed() val publicKey = PublicKey( curve = KeyCurve(Curve.SECP256K1), - value = kmmPublicKey.getEncoded(), + value = kmmPublicKey.getEncoded() ) return CompressedPublicKey( uncompressed = publicKey, - value = kmmCompressed, + value = kmmCompressed ) } @@ -226,7 +226,7 @@ class ApolloImpl : Apollo { val kmmPublicKey = KMMECSecp256k1PublicKey.secp256k1FromByteCoordinates(x, y) PublicKey( curve = curve, - value = kmmPublicKey.getEncoded(), + value = kmmPublicKey.getEncoded() ) } @@ -250,7 +250,7 @@ class ApolloImpl : Apollo { val kmmPublicKey = KMMECSecp256k1PublicKey.secp256k1FromBytes(x) PublicKey( curve = curve, - value = kmmPublicKey.getEncoded(), + value = kmmPublicKey.getEncoded() ) } @@ -275,11 +275,9 @@ class ApolloImpl : Apollo { val kmmSignature = KMMECDSA.sign( type = ECDSAType.ECDSA_SHA256, data = message, - privateKey = kmmPrivateKey, - ) - Signature( - value = kmmSignature, + privateKey = kmmPrivateKey ) + Signature(value = kmmSignature) } Curve.ED25519 -> { @@ -287,9 +285,7 @@ class ApolloImpl : Apollo { privateKey = privateKey, message = message ) - Signature( - value = signature - ) + Signature(value = signature) } else -> { @@ -344,7 +340,7 @@ class ApolloImpl : Apollo { type = ECDSAType.ECDSA_SHA256, data = challenge, publicKey = kmmPublicKey, - signature = signature.value, + signature = signature.value ) } Curve.ED25519 -> { diff --git a/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/castor/CastorImpl.kt b/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/castor/CastorImpl.kt index 426aab8c7..bb257abdc 100644 --- a/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/castor/CastorImpl.kt +++ b/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/castor/CastorImpl.kt @@ -32,7 +32,7 @@ class CastorImpl(apollo: Apollo, private val logger: PrismLogger = PrismLoggerIm this.apollo = apollo this.resolvers = arrayOf( PeerDIDResolver(), - LongFormPrismDIDResolver(this.apollo), + LongFormPrismDIDResolver(this.apollo) ) } @@ -63,7 +63,7 @@ class CastorImpl(apollo: Apollo, private val logger: PrismLogger = PrismLoggerIm return CastorShared.createPrismDID( apollo = apollo, masterPublicKey = masterPublicKey, - services = services, + services = services ) } @@ -83,7 +83,7 @@ class CastorImpl(apollo: Apollo, private val logger: PrismLogger = PrismLoggerIm ): DID { return CastorShared.createPeerDID( keyPairs = keyPairs, - services = services, + services = services ) } diff --git a/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/castor/did/DIDUrlParser.kt b/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/castor/did/DIDUrlParser.kt index 6da615f73..d705cc78a 100644 --- a/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/castor/did/DIDUrlParser.kt +++ b/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/castor/did/DIDUrlParser.kt @@ -35,7 +35,7 @@ object DIDUrlParser { did, listener.path ?: emptyArray(), listener.query, - listener.fragment, + listener.fragment ) } } diff --git a/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/castor/did/prismdid/LongFormPrismDID.kt b/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/castor/did/prismdid/LongFormPrismDID.kt index 0361b9007..c3c0d5ae6 100644 --- a/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/castor/did/prismdid/LongFormPrismDID.kt +++ b/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/castor/did/prismdid/LongFormPrismDID.kt @@ -13,7 +13,7 @@ constructor(val did: DID) { init { val methodId = PrismDIDMethodId( - did.methodId, + did.methodId ) if (methodId.sections.size != 2) { diff --git a/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/castor/did/prismdid/PrismDIDPublicKey.kt b/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/castor/did/prismdid/PrismDIDPublicKey.kt index 6ae5494c0..93146ead3 100644 --- a/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/castor/did/prismdid/PrismDIDPublicKey.kt +++ b/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/castor/did/prismdid/PrismDIDPublicKey.kt @@ -44,8 +44,8 @@ class PrismDIDPublicKey { id = id, usage = usage.toProto(), keyData = io.iohk.atala.prism.protos.PublicKey.KeyData.CompressedEcKeyData( - compressed.toProto(), - ), + compressed.toProto() + ) ) } @@ -57,7 +57,7 @@ class PrismDIDPublicKey { CAPABILITY_DELEGATION_KEY("capabilityDelegationKey"), CAPABILITY_INVOCATION_KEY("capabilityInvocationKey"), KEY_AGREEMENT_KEY("keyAgreementKey"), - UNKNOWN_KEY("unknownKey"), + UNKNOWN_KEY("unknownKey") } } @@ -78,7 +78,7 @@ fun KeyUsage.fromProto(): PrismDIDPublicKey.Usage { fun CompressedPublicKey.toProto(): CompressedECKeyData { return CompressedECKeyData( curve = uncompressed.curve.curve.value, - data = ByteArr(value), + data = ByteArr(value) ) } diff --git a/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/castor/resolvers/LongFormPrismDIDResolver.kt b/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/castor/resolvers/LongFormPrismDIDResolver.kt index 89d899242..7e71cbb43 100644 --- a/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/castor/resolvers/LongFormPrismDIDResolver.kt +++ b/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/castor/resolvers/LongFormPrismDIDResolver.kt @@ -14,7 +14,7 @@ class LongFormPrismDIDResolver( override suspend fun resolve(didString: String): DIDDocument { return CastorShared.resolveLongFormPrismDID( apollo = apollo, - didString = didString, + didString = didString ) } } diff --git a/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/castor/shared/CastorShared.kt b/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/castor/shared/CastorShared.kt index b60ba163a..25a142fb8 100644 --- a/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/castor/shared/CastorShared.kt +++ b/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/castor/shared/CastorShared.kt @@ -82,7 +82,7 @@ internal class CastorShared { internal fun createPrismDID( apollo: Apollo, masterPublicKey: PublicKey, - services: Array?, + services: Array? ): DID { val atalaOperation = AtalaOperation( operation = AtalaOperation.Operation.CreateDid( @@ -93,25 +93,25 @@ internal class CastorShared { apollo = apollo, id = PrismDIDPublicKey.Usage.MASTER_KEY.defaultId(), usage = PrismDIDPublicKey.Usage.MASTER_KEY, - keyData = masterPublicKey, + keyData = masterPublicKey ).toProto(), PrismDIDPublicKey( apollo = apollo, id = PrismDIDPublicKey.Usage.AUTHENTICATION_KEY.defaultId(), usage = PrismDIDPublicKey.Usage.AUTHENTICATION_KEY, - keyData = masterPublicKey, + keyData = masterPublicKey ).toProto() ), services = services?.map { Service( id = it.id, type = it.type.first(), - serviceEndpoint = listOf(it.serviceEndpoint.uri), + serviceEndpoint = listOf(it.serviceEndpoint.uri) ) - } ?: emptyList(), - ), - ), - ), + } ?: emptyList() + ) + ) + ) ) val encodedState = atalaOperation.encodeToByteArray() @@ -120,14 +120,14 @@ internal class CastorShared { val methodSpecificId = PrismDIDMethodId( sections = listOf( stateHash, - base64State, - ), + base64State + ) ) return DID( schema = DID, method = PRISM, - methodId = methodSpecificId.toString(), + methodId = methodSpecificId.toString() ) } @@ -160,16 +160,16 @@ internal class CastorShared { urls = arrayOf(), verificationMethods = peerDIDDocument.authentication.map { fromVerificationMethodPeerDID(it.id, it) - }.toTypedArray(), - ), + }.toTypedArray() + ) ) coreProperties.add( DIDDocument.KeyAgreement( urls = arrayOf(), verificationMethods = peerDIDDocument.keyAgreement.map { fromVerificationMethodPeerDID(it.id, it) - }.toTypedArray(), - ), + }.toTypedArray() + ) ) val peerDIDServices = peerDIDDocument.service ?: listOf() @@ -185,9 +185,9 @@ internal class CastorShared { serviceEndpoint = DIDDocument.ServiceEndpoint( uri = service.serviceEndpoint, accept = service.accept.toTypedArray(), - routingKeys = service.routingKeys.toTypedArray(), - ), - ), + routingKeys = service.routingKeys.toTypedArray() + ) + ) ) } } @@ -195,15 +195,15 @@ internal class CastorShared { coreProperties.add( DIDDocument.Services( - services.toTypedArray(), - ), + services.toTypedArray() + ) ) val did = DIDParser.parse(didString) return DIDDocument( id = did, - coreProperties = coreProperties.toTypedArray(), + coreProperties = coreProperties.toTypedArray() ) } @@ -219,7 +219,7 @@ internal class CastorShared { @Throws(CastorError.InvalidKeyError::class) private fun fromVerificationMethodPeerDID( did: String, - verificationMethod: VerificationMethodPeerDID, + verificationMethod: VerificationMethodPeerDID ): DIDDocument.VerificationMethod { val didUrl = DIDUrlParser.parse(did) val controller = DIDParser.parse(verificationMethod.controller) @@ -245,7 +245,7 @@ internal class CastorShared { didUrl, controller, type, - Json.decodeFromString>(verificationMethod.verMaterial.value as String), + Json.decodeFromString>(verificationMethod.verMaterial.value as String) ) } @@ -255,7 +255,7 @@ internal class CastorShared { controller, type, null, - verificationMethod.verMaterial.value as String, + verificationMethod.verMaterial.value as String ) } @@ -265,7 +265,7 @@ internal class CastorShared { controller, type, null, - verificationMethod.verMaterial.value as String, + verificationMethod.verMaterial.value as String ) } } @@ -290,7 +290,7 @@ internal class CastorShared { apollo = apollo, did = did, stateHash = prismDID.stateHash, - encodedData = prismDID.encodedState.base64UrlDecodedBytes, + encodedData = prismDID.encodedState.base64UrlDecodedBytes ) } catch (e: Throwable) { logger.error( @@ -313,7 +313,7 @@ internal class CastorShared { val authenticate = verificationMethods.entries.map { DIDDocument.Authentication( urls = arrayOf(it.key), - verificationMethods = verificationMethods.values.toTypedArray(), + verificationMethods = verificationMethods.values.toTypedArray() ) } @@ -326,7 +326,7 @@ internal class CastorShared { return DIDDocument( id = did, - coreProperties = coreProperties.toTypedArray(), + coreProperties = coreProperties.toTypedArray() ) } @@ -349,7 +349,7 @@ internal class CastorShared { apollo: Apollo, did: DID, stateHash: String, - encodedData: ByteArray, + encodedData: ByteArray ): Pair, List> { val sha256 = SHA256() val verifyEncodedState = sha256.digest(encodedData) @@ -384,8 +384,8 @@ internal class CastorShared { it.id, arrayOf(it.type), DIDDocument.ServiceEndpoint( - uri = it.serviceEndpoint.first(), - ), + uri = it.serviceEndpoint.first() + ) ) } ?: listOf() @@ -393,13 +393,13 @@ internal class CastorShared { publicKeys.fold(emptyMap()) { partialResult, publicKey -> val didUrl = DIDUrl( did = did, - fragment = publicKey.id, + fragment = publicKey.id ) val method = DIDDocument.VerificationMethod( id = didUrl, controller = did, type = publicKey.keyData.curve.curve.value, - publicKeyMultibase = publicKey.keyData.value.base64Encoded, + publicKeyMultibase = publicKey.keyData.value.base64Encoded ) partialResult + (didUrl.string() to method) } @@ -439,7 +439,7 @@ internal class CastorShared { it.publicKeyMultibase?.let { publicKey -> PublicKey( curve = KeyCurve(DIDDocument.VerificationMethod.getCurveByType(it.type)), - value = publicKey.encodeToByteArray(), + value = publicKey.encodeToByteArray() ) } } @@ -468,7 +468,7 @@ internal class CastorShared { @Throws(CastorError.InvalidKeyError::class) internal fun createPeerDID( keyPairs: Array, - services: Array, + services: Array ): DID { val encryptionKeys: MutableList = mutableListOf() val signingKeys: MutableList = mutableListOf() @@ -481,8 +481,8 @@ internal class CastorShared { VerificationMaterialAgreement( format = VerificationMaterialFormatPeerDID.JWK, value = octetString, - type = VerificationMethodTypeAgreement.JSON_WEB_KEY_2020, - ), + type = VerificationMethodTypeAgreement.JSON_WEB_KEY_2020 + ) ) } @@ -492,8 +492,8 @@ internal class CastorShared { VerificationMaterialAuthentication( format = VerificationMaterialFormatPeerDID.JWK, value = octetString, - type = VerificationMethodTypeAuthentication.JSON_WEB_KEY_2020, - ), + type = VerificationMethodTypeAuthentication.JSON_WEB_KEY_2020 + ) ) } @@ -517,10 +517,10 @@ internal class CastorShared { type = it.type[0], serviceEndpoint = it.serviceEndpoint.uri, routingKeys = it.serviceEndpoint.routingKeys?.toList() ?: listOf(), - accept = it.serviceEndpoint.accept?.asList() ?: listOf(), - ).toDict().toJsonElement(), + accept = it.serviceEndpoint.accept?.asList() ?: listOf() + ).toDict().toJsonElement() ) - }.firstOrNull(), + }.firstOrNull() ) return DIDParser.parse(peerDID) diff --git a/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/domain/buildingblocks/Castor.kt b/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/domain/buildingblocks/Castor.kt index 5aa980daf..ecb70af00 100644 --- a/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/domain/buildingblocks/Castor.kt +++ b/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/domain/buildingblocks/Castor.kt @@ -34,7 +34,7 @@ interface Castor { */ fun createPrismDID( masterPublicKey: PublicKey, - services: Array?, + services: Array? ): DID /** @@ -48,7 +48,7 @@ interface Castor { */ fun createPeerDID( keyPairs: Array, - services: Array, + services: Array ): DID /** @@ -77,6 +77,6 @@ interface Castor { suspend fun verifySignature( did: DID, challenge: ByteArray, - signature: ByteArray, + signature: ByteArray ): Boolean } diff --git a/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/domain/buildingblocks/Pluto.kt b/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/domain/buildingblocks/Pluto.kt index 34da8e768..5f9e88459 100644 --- a/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/domain/buildingblocks/Pluto.kt +++ b/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/domain/buildingblocks/Pluto.kt @@ -18,7 +18,7 @@ interface Pluto { did: DID, keyPathIndex: Int, alias: String?, - privateKeys: List, + privateKeys: List ) fun storePeerDID(did: DID) diff --git a/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/domain/models/ApiImpl.kt b/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/domain/models/ApiImpl.kt index 53582be78..b8d471756 100644 --- a/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/domain/models/ApiImpl.kt +++ b/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/domain/models/ApiImpl.kt @@ -24,12 +24,12 @@ open class ApiImpl(override var client: HttpClient) : Api { url = Url(url), urlParametersArray = urlParameters, httpHeadersArray = httpHeaders, - body = body, + body = body ) val response = client.request(request) return HttpResponse( status = response.status.value, - jsonString = response.bodyAsText(), + jsonString = response.bodyAsText() ) } } diff --git a/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/domain/models/DID.kt b/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/domain/models/DID.kt index 054db4470..be146093d 100644 --- a/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/domain/models/DID.kt +++ b/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/domain/models/DID.kt @@ -17,7 +17,7 @@ import kotlin.jvm.JvmStatic data class DID @JvmOverloads constructor( val schema: String = DID, val method: String, - val methodId: String, + val methodId: String ) { // @JsName("fromString") diff --git a/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/domain/models/DIDDocument.kt b/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/domain/models/DIDDocument.kt index ae300800b..a87052d85 100644 --- a/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/domain/models/DIDDocument.kt +++ b/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/domain/models/DIDDocument.kt @@ -57,7 +57,7 @@ data class DIDDocument( val controller: DID, val type: String, val publicKeyJwk: Map? = null, - val publicKeyMultibase: String? = null, + val publicKeyMultibase: String? = null ) { companion object { @JvmStatic diff --git a/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/domain/models/JWTPayload.kt b/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/domain/models/JWTPayload.kt index b751da5e6..10891a75a 100644 --- a/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/domain/models/JWTPayload.kt +++ b/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/domain/models/JWTPayload.kt @@ -47,7 +47,7 @@ data class JWTPayload val credentialStatus: VerifiableCredentialTypeContainer? = null, val refreshService: VerifiableCredentialTypeContainer? = null, val evidence: VerifiableCredentialTypeContainer? = null, - val termsOfUse: VerifiableCredentialTypeContainer? = null, + val termsOfUse: VerifiableCredentialTypeContainer? = null ) { override fun equals(other: Any?): Boolean { if (this === other) return true diff --git a/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/domain/models/KeyPair.kt b/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/domain/models/KeyPair.kt index a4e0ac7d0..44bec73eb 100644 --- a/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/domain/models/KeyPair.kt +++ b/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/domain/models/KeyPair.kt @@ -26,7 +26,7 @@ data class KeyCurve @JvmOverloads constructor( enum class Curve(val value: String) { X25519("X25519"), ED25519("Ed25519"), - SECP256K1("secp256k1"), + SECP256K1("secp256k1") } fun getKeyCurveByNameAndIndex(name: String, index: Int?): KeyCurve { diff --git a/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/domain/models/Message.kt b/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/domain/models/Message.kt index fb0aa3bf5..88e93a0fb 100644 --- a/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/domain/models/Message.kt +++ b/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/domain/models/Message.kt @@ -3,6 +3,7 @@ package io.iohk.atala.prism.walletsdk.domain.models import io.iohk.atala.prism.apollo.uuid.UUID import kotlinx.datetime.Clock import kotlinx.serialization.EncodeDefault +import kotlinx.serialization.ExperimentalSerializationApi import kotlinx.serialization.Serializable import kotlinx.serialization.encodeToString import kotlinx.serialization.json.Json @@ -15,7 +16,9 @@ import kotlin.time.Duration.Companion.days * [Message] objects are typically exchanged between DID controllers using the [Mercury] building block. */ @Serializable -data class Message @JvmOverloads constructor( +data class Message @OptIn(ExperimentalSerializationApi::class) +@JvmOverloads +constructor( val id: String = UUID.randomUUID4().toString(), val piuri: String, @EncodeDefault val from: DID? = null, @@ -76,7 +79,7 @@ data class Message @JvmOverloads constructor( enum class Direction(val value: Int) { SENT(0), - RECEIVED(1), + RECEIVED(1) } companion object { diff --git a/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/domain/models/W3CCredential.kt b/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/domain/models/W3CCredential.kt index c75429478..949fe8800 100644 --- a/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/domain/models/W3CCredential.kt +++ b/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/domain/models/W3CCredential.kt @@ -33,7 +33,7 @@ data class W3CCredential @JvmOverloads constructor( val validFrom: VerifiableCredentialTypeContainer? = null, val validUntil: VerifiableCredentialTypeContainer? = null, val proof: JsonString?, - val aud: Array = arrayOf(), + val aud: Array = arrayOf() ) : Credential { override val id: String diff --git a/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/mercury/MercuryImpl.kt b/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/mercury/MercuryImpl.kt index 39300a34c..9378ae9ef 100644 --- a/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/mercury/MercuryImpl.kt +++ b/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/mercury/MercuryImpl.kt @@ -176,7 +176,7 @@ class MercuryImpl( body = ForwardMessage.ForwardBody(message.to.toString()), encryptedMessage = encrypted, from = message.from!!, - to = mediatorDid, + to = mediatorDid ) } diff --git a/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/mercury/forward/ForwardMessage.kt b/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/mercury/forward/ForwardMessage.kt index 1e3c296e3..44bc66710 100644 --- a/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/mercury/forward/ForwardMessage.kt +++ b/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/mercury/forward/ForwardMessage.kt @@ -28,7 +28,7 @@ class ForwardMessage @JvmOverloads constructor( from = from, to = to, body = forwardBody, - attachments = arrayOf(attachment), + attachments = arrayOf(attachment) ) return message diff --git a/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/mercury/resolvers/DIDCommWrapper.kt b/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/mercury/resolvers/DIDCommWrapper.kt index ca9cff40e..b48edcc4e 100644 --- a/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/mercury/resolvers/DIDCommWrapper.kt +++ b/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/mercury/resolvers/DIDCommWrapper.kt @@ -240,7 +240,7 @@ class DIDCommWrapper(castor: Castor, pluto: Pluto, apollo: Apollo) : DIDCommProt filename = attachment.filename?.split(ATTACHMENT_SEPARATOR)?.toTypedArray(), format = attachment.format, lastModTime = attachment.lastModTime?.toString(), - mediaType = attachment.mediaType, + mediaType = attachment.mediaType ) return acc.plus(attachmentDescriptor) @@ -261,16 +261,15 @@ class DIDCommWrapper(castor: Castor, pluto: Pluto, apollo: Apollo) : DIDCommProt val json = jsonObj[JSON] if (json is JSONObject) { + @Suppress("UNCHECKED_CAST") // JSONObject can be always cast as Map return AttachmentJsonData(JSONObject.toJSONString(json as Map)) } val links = jsonObj[LINKS] val hash = jsonObj[HASH] if (links is Array<*> && links.isArrayOf() && hash is String) { - return AttachmentLinkData( - links as Array, - hash - ) + @Suppress("UNCHECKED_CAST") // checks are applied in the if condition + return AttachmentLinkData(links as Array, hash) } throw MercuryError.UnknownAttachmentDataError() diff --git a/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/mercury/resolvers/DefaultSecretsResolverImpl.kt b/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/mercury/resolvers/DefaultSecretsResolverImpl.kt index 5378a276f..6ee5034ad 100644 --- a/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/mercury/resolvers/DefaultSecretsResolverImpl.kt +++ b/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/mercury/resolvers/DefaultSecretsResolverImpl.kt @@ -35,9 +35,9 @@ class DefaultSecretsResolverImpl(val pluto: Pluto) : SecretsResolver { PrivateJWK( secretId, privateKey.keyCurve.curve.toString(), - privateKey.value.base64UrlEncoded, - ).toString(), - ), + privateKey.value.base64UrlEncoded + ).toString() + ) ) } } diff --git a/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/pollux/PolluxImpl.kt b/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/pollux/PolluxImpl.kt index 3fc0e3e73..d7fd48539 100644 --- a/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/pollux/PolluxImpl.kt +++ b/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/pollux/PolluxImpl.kt @@ -44,8 +44,8 @@ class PolluxImpl(val castor: Castor) : Pollux { } } - override fun restoreCredential(recoveryId: String, credentialData: ByteArray): Credential { - return when (recoveryId) { + override fun restoreCredential(restorationIdentifier: String, credentialData: ByteArray): Credential { + return when (restorationIdentifier) { "jwt+credential" -> { JWTCredential(credentialData.decodeToString()).toStorableCredential() } diff --git a/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/prismagent/protocols/issueCredential/IssueCredential.kt b/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/prismagent/protocols/issueCredential/IssueCredential.kt index 318d5c74c..b85954f21 100644 --- a/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/prismagent/protocols/issueCredential/IssueCredential.kt +++ b/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/prismagent/protocols/issueCredential/IssueCredential.kt @@ -153,7 +153,7 @@ data class IssueCredential( } override fun hashCode(): Int { - var result = id?.hashCode() ?: 0 + var result = id.hashCode() result = 31 * result + body.hashCode() result = 31 * result + attachments.contentHashCode() result = 31 * result + (thid?.hashCode() ?: 0) @@ -169,7 +169,7 @@ inline fun IssueCredential.Companion.build( fromDID: DID, toDID: DID, thid: String?, - credentials: Map = mapOf(), + credentials: Map = mapOf() ): IssueCredential { val aux = credentials.map { (key, value) -> val attachment = AttachmentDescriptor.build(payload = value) diff --git a/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/prismagent/protocols/mediation/MediationRequest.kt b/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/prismagent/protocols/mediation/MediationRequest.kt index d50c4a11d..c81e46d8c 100644 --- a/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/prismagent/protocols/mediation/MediationRequest.kt +++ b/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/prismagent/protocols/mediation/MediationRequest.kt @@ -18,7 +18,7 @@ final class MediationRequest @JvmOverloads constructor( ) : this( id = UUID.randomUUID4().toString(), from = from, - to = to, + to = to ) fun makeMessage(): Message { diff --git a/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/prismagent/shared/PrismShared.kt b/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/prismagent/shared/PrismShared.kt index fe9b9fed5..153fe55c0 100644 --- a/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/prismagent/shared/PrismShared.kt +++ b/atala-prism-sdk/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/prismagent/shared/PrismShared.kt @@ -25,7 +25,7 @@ internal object PrismShared { url: Url, urlParametersArray: Array, httpHeadersArray: Array, - body: Any?, + body: Any? ): HttpRequestBuilder { val urlParameters: Map = mapFromKeyValueArray(urlParametersArray) val httpHeaders: Map = mapFromKeyValueArray(httpHeadersArray) diff --git a/atala-prism-sdk/src/commonTest/kotlin/io/iohk/atala/prism/walletsdk/apollo/derivation/Bip32Vectors.kt b/atala-prism-sdk/src/commonTest/kotlin/io/iohk/atala/prism/walletsdk/apollo/derivation/Bip32Vectors.kt index 72cfc684b..acc492b11 100644 --- a/atala-prism-sdk/src/commonTest/kotlin/io/iohk/atala/prism/walletsdk/apollo/derivation/Bip32Vectors.kt +++ b/atala-prism-sdk/src/commonTest/kotlin/io/iohk/atala/prism/walletsdk/apollo/derivation/Bip32Vectors.kt @@ -11,7 +11,7 @@ sealed class RawTestVectorBase { @Serializable class RawTestVector( override val seed: String, - override val derivations: List>, + override val derivations: List> ) : RawTestVectorBase() val bip32Vectors = diff --git a/atala-prism-sdk/src/commonTest/kotlin/io/iohk/atala/prism/walletsdk/castor/ApolloMock.kt b/atala-prism-sdk/src/commonTest/kotlin/io/iohk/atala/prism/walletsdk/castor/ApolloMock.kt index f66973498..05eff5cb3 100644 --- a/atala-prism-sdk/src/commonTest/kotlin/io/iohk/atala/prism/walletsdk/castor/ApolloMock.kt +++ b/atala-prism-sdk/src/commonTest/kotlin/io/iohk/atala/prism/walletsdk/castor/ApolloMock.kt @@ -17,18 +17,18 @@ class ApolloMock : Apollo { var createRandomSeedReturn: SeedWords = SeedWords(emptyArray(), Seed(ByteArray(0))) var createKeyPairReturn: KeyPair = KeyPair( privateKey = PrivateKey(KeyCurve(Curve.ED25519), ByteArray(0)), - publicKey = PublicKey(KeyCurve(Curve.ED25519), ByteArray(0)), + publicKey = PublicKey(KeyCurve(Curve.ED25519), ByteArray(0)) ) var compressedPublicKeyReturn: CompressedPublicKey = CompressedPublicKey( PublicKey(KeyCurve(Curve.SECP256K1), ByteArray(0)), - ByteArray(0), + ByteArray(0) ) var publicKeyReturn: PublicKey = PublicKey(KeyCurve(Curve.ED25519), ByteArray(0)) var signMessageReturn: Signature = Signature(ByteArray(0)) var verifySignatureReturn: Boolean = true var compressedPublicKeyDataReturn: CompressedPublicKey = CompressedPublicKey( PublicKey(KeyCurve(Curve.SECP256K1), ByteArray(0)), - ByteArray(0), + ByteArray(0) ) var signMessageByteArrayReturn: Signature = Signature(ByteArray(0)) var signMessageStringReturn: Signature = Signature(ByteArray(0)) @@ -73,6 +73,6 @@ class ApolloMock : Apollo { override fun verifySignature( publicKey: PublicKey, challenge: ByteArray, - signature: Signature, + signature: Signature ): Boolean = verifySignatureReturn } diff --git a/atala-prism-sdk/src/commonTest/kotlin/io/iohk/atala/prism/walletsdk/castor/PrismDIDPublicKeyTests.kt b/atala-prism-sdk/src/commonTest/kotlin/io/iohk/atala/prism/walletsdk/castor/PrismDIDPublicKeyTests.kt index 8186a046f..5daab8a15 100644 --- a/atala-prism-sdk/src/commonTest/kotlin/io/iohk/atala/prism/walletsdk/castor/PrismDIDPublicKeyTests.kt +++ b/atala-prism-sdk/src/commonTest/kotlin/io/iohk/atala/prism/walletsdk/castor/PrismDIDPublicKeyTests.kt @@ -20,23 +20,23 @@ class PrismDIDPublicKeyTests { val seed = apollo.createRandomSeed().seed val keyPair = apollo.createKeyPair( seed = seed, - curve = KeyCurve(Curve.SECP256K1), + curve = KeyCurve(Curve.SECP256K1) ) val publicKey = PrismDIDPublicKey( apollo = ApolloMock(), id = PrismDIDPublicKey.Usage.MASTER_KEY.id(0), usage = PrismDIDPublicKey.Usage.MASTER_KEY, - keyData = keyPair.publicKey, + keyData = keyPair.publicKey ) val protoData = publicKey.toProto() val proto = PublicKey( id = protoData.id, usage = protoData.usage, - keyData = protoData.keyData, + keyData = protoData.keyData ) val parsedPublicKey = PrismDIDPublicKey( apollo = apollo, - proto = proto, + proto = proto ) assertEquals(parsedPublicKey.id, "master0") assertContentEquals(parsedPublicKey.keyData.value, publicKey.keyData.value) diff --git a/atala-prism-sdk/src/commonTest/kotlin/io/iohk/atala/prism/walletsdk/mercury/CastorMock.kt b/atala-prism-sdk/src/commonTest/kotlin/io/iohk/atala/prism/walletsdk/mercury/CastorMock.kt index 49b065a0a..bebe179b1 100644 --- a/atala-prism-sdk/src/commonTest/kotlin/io/iohk/atala/prism/walletsdk/mercury/CastorMock.kt +++ b/atala-prism-sdk/src/commonTest/kotlin/io/iohk/atala/prism/walletsdk/mercury/CastorMock.kt @@ -13,7 +13,7 @@ class CastorMock : Castor { var createPeerDIDReturn: DID? = DID( "did", "prism", - "b6c0c33d701ac1b9a262a14454d1bbde3d127d697a76950963c5fd930605:Cj8KPRI7CgdtYXN0ZXIwEAFKLgoJc2VmsxEiECSTjyV7sUfCr_ArpN9rvCwR9fRMAhcsr_S7ZRiJk4p5k", + "b6c0c33d701ac1b9a262a14454d1bbde3d127d697a76950963c5fd930605:Cj8KPRI7CgdtYXN0ZXIwEAFKLgoJc2VmsxEiECSTjyV7sUfCr_ArpN9rvCwR9fRMAhcsr_S7ZRiJk4p5k" ) var resolveDIDReturn: DIDDocument? = null var verifySignatureReturn: Boolean = false @@ -26,7 +26,7 @@ class CastorMock : Castor { @Throws(Exception::class) override fun createPrismDID( masterPublicKey: PublicKey, - services: Array?, + services: Array? ): DID { return createPrismDIDReturn ?: throw Exception("createPrismDID() not implemented in mock") } @@ -34,7 +34,7 @@ class CastorMock : Castor { @Throws(Exception::class) override fun createPeerDID( keyPairs: Array, - services: Array, + services: Array ): DID { return createPeerDIDReturn ?: throw Exception("createPeerDID() not implemented in mock") } diff --git a/atala-prism-sdk/src/commonTest/kotlin/io/iohk/atala/prism/walletsdk/mercury/DIDResolverTests.kt b/atala-prism-sdk/src/commonTest/kotlin/io/iohk/atala/prism/walletsdk/mercury/DIDResolverTests.kt index ed5fe2158..bd99343e3 100644 --- a/atala-prism-sdk/src/commonTest/kotlin/io/iohk/atala/prism/walletsdk/mercury/DIDResolverTests.kt +++ b/atala-prism-sdk/src/commonTest/kotlin/io/iohk/atala/prism/walletsdk/mercury/DIDResolverTests.kt @@ -57,8 +57,8 @@ class DIDResolverTests { serviceEndpoint = DIDDocument.ServiceEndpoint( uri = "localhost:8082", accept = seAccept, - routingKeys = seRoutingKeys, - ), + routingKeys = seRoutingKeys + ) ) val allAuthentication = DIDDocument.Authentication(arrayOf(), arrayOf()) diff --git a/atala-prism-sdk/src/commonTest/kotlin/io/iohk/atala/prism/walletsdk/prismagent/ApolloMock.kt b/atala-prism-sdk/src/commonTest/kotlin/io/iohk/atala/prism/walletsdk/prismagent/ApolloMock.kt index dc0acbeb0..eab6f2f6f 100644 --- a/atala-prism-sdk/src/commonTest/kotlin/io/iohk/atala/prism/walletsdk/prismagent/ApolloMock.kt +++ b/atala-prism-sdk/src/commonTest/kotlin/io/iohk/atala/prism/walletsdk/prismagent/ApolloMock.kt @@ -17,18 +17,18 @@ class ApolloMock : Apollo { var createRandomSeedReturn: SeedWords = SeedWords(emptyArray(), Seed(ByteArray(0))) var createKeyPairReturn: KeyPair = KeyPair( privateKey = PrivateKey(KeyCurve(Curve.ED25519), ByteArray(0)), - publicKey = PublicKey(KeyCurve(Curve.ED25519), ByteArray(0)), + publicKey = PublicKey(KeyCurve(Curve.ED25519), ByteArray(0)) ) var compressedPublicKeyReturn: CompressedPublicKey = CompressedPublicKey( PublicKey(KeyCurve(Curve.ED25519), ByteArray(0)), - ByteArray(0), + ByteArray(0) ) var publicKeyReturn: PublicKey = PublicKey(KeyCurve(Curve.ED25519), ByteArray(0)) var signMessageReturn: Signature = Signature(ByteArray(0)) var verifySignatureReturn: Boolean = false var compressedPublicKeyDataReturn: CompressedPublicKey = CompressedPublicKey( PublicKey(KeyCurve(Curve.ED25519), ByteArray(0)), - ByteArray(0), + ByteArray(0) ) var signMessageByteArrayReturn: Signature = Signature(ByteArray(0)) var signMessageStringReturn: Signature = Signature(ByteArray(0)) @@ -74,6 +74,6 @@ class ApolloMock : Apollo { override fun verifySignature( publicKey: PublicKey, challenge: ByteArray, - signature: Signature, + signature: Signature ): Boolean = verifySignatureReturn } diff --git a/atala-prism-sdk/src/commonTest/kotlin/io/iohk/atala/prism/walletsdk/prismagent/CastorMock.kt b/atala-prism-sdk/src/commonTest/kotlin/io/iohk/atala/prism/walletsdk/prismagent/CastorMock.kt index 97d91af95..af2cfdf14 100644 --- a/atala-prism-sdk/src/commonTest/kotlin/io/iohk/atala/prism/walletsdk/prismagent/CastorMock.kt +++ b/atala-prism-sdk/src/commonTest/kotlin/io/iohk/atala/prism/walletsdk/prismagent/CastorMock.kt @@ -12,7 +12,7 @@ class CastorMock : Castor { var createPeerDIDReturn: DID? = DID( "did", "prism", - "b6c0c33d701ac1b9a262a14454d1bbde3d127d697a76950963c5fd930605:Cj8KPRI7CgdtYXN0ZXIwEAFKLgoJc2VmsxEiECSTjyV7sUfCr_ArpN9rvCwR9fRMAhcsr_S7ZRiJk4p5k", + "b6c0c33d701ac1b9a262a14454d1bbde3d127d697a76950963c5fd930605:Cj8KPRI7CgdtYXN0ZXIwEAFKLgoJc2VmsxEiECSTjyV7sUfCr_ArpN9rvCwR9fRMAhcsr_S7ZRiJk4p5k" ) var resolveDIDReturn: DIDDocument? = null var verifySignatureReturn: Boolean = false @@ -23,14 +23,14 @@ class CastorMock : Castor { override fun createPrismDID( masterPublicKey: PublicKey, - services: Array?, + services: Array? ): DID { return createPrismDIDReturn ?: throw Exception("createPrismDID() not implemented in mock") } override fun createPeerDID( keyPairs: Array, - services: Array, + services: Array ): DID { return createPeerDIDReturn ?: throw Exception("createPeerDID() not implemented in mock") } @@ -42,16 +42,16 @@ class CastorMock : Castor { serviceEndpoint = DIDDocument.ServiceEndpoint( uri = "localhost:8082", accept = arrayOf(DIDCOMM_MESSAGING), - routingKeys = arrayOf(), - ), + routingKeys = arrayOf() + ) ) resolveDIDReturn = DIDDocument( DID( "did", "prism", - "b6c0c33d701ac1b9a262a14454d1bbde3d127d697a76950963c5fd930605:Cj8KPRI7CgdtYXN0ZXIwEAFKLgoJc2VmsxEiECSTjyV7sUfCr_ArpN9rvCwR9fRMAhcsr_S7ZRiJk4p5k", + "b6c0c33d701ac1b9a262a14454d1bbde3d127d697a76950963c5fd930605:Cj8KPRI7CgdtYXN0ZXIwEAFKLgoJc2VmsxEiECSTjyV7sUfCr_ArpN9rvCwR9fRMAhcsr_S7ZRiJk4p5k" ), - arrayOf(coreProperty), + arrayOf(coreProperty) ) return resolveDIDReturn ?: throw Exception("resolveDID() not implemented in mock") } diff --git a/atala-prism-sdk/src/commonTest/kotlin/io/iohk/atala/prism/walletsdk/prismagent/DIDMock.kt b/atala-prism-sdk/src/commonTest/kotlin/io/iohk/atala/prism/walletsdk/prismagent/DIDMock.kt index f34414c79..9a1867eb7 100644 --- a/atala-prism-sdk/src/commonTest/kotlin/io/iohk/atala/prism/walletsdk/prismagent/DIDMock.kt +++ b/atala-prism-sdk/src/commonTest/kotlin/io/iohk/atala/prism/walletsdk/prismagent/DIDMock.kt @@ -5,7 +5,7 @@ import io.iohk.atala.prism.walletsdk.domain.models.DID fun DID.Companion.testable( schema: String = "did", method: String = "test1", - methodId: String = "test1Id", + methodId: String = "test1Id" ): DID { return DID(schema, method, methodId) } diff --git a/atala-prism-sdk/src/commonTest/kotlin/io/iohk/atala/prism/walletsdk/prismagent/MediationHandlerMock.kt b/atala-prism-sdk/src/commonTest/kotlin/io/iohk/atala/prism/walletsdk/prismagent/MediationHandlerMock.kt index c032396fb..76cdf8cf8 100644 --- a/atala-prism-sdk/src/commonTest/kotlin/io/iohk/atala/prism/walletsdk/prismagent/MediationHandlerMock.kt +++ b/atala-prism-sdk/src/commonTest/kotlin/io/iohk/atala/prism/walletsdk/prismagent/MediationHandlerMock.kt @@ -10,7 +10,7 @@ import kotlinx.coroutines.flow.flow class MediationHandlerMock( override var mediator: Mediator? = null, - override var mediatorDID: DID = DID.testable(), + override var mediatorDID: DID = DID.testable() ) : MediationHandler { var bootMediatorResponse: Mediator? = null diff --git a/atala-prism-sdk/src/commonTest/kotlin/io/iohk/atala/prism/walletsdk/prismagent/MessageMock.kt b/atala-prism-sdk/src/commonTest/kotlin/io/iohk/atala/prism/walletsdk/prismagent/MessageMock.kt index 6c7f5bb89..f87f30b82 100644 --- a/atala-prism-sdk/src/commonTest/kotlin/io/iohk/atala/prism/walletsdk/prismagent/MessageMock.kt +++ b/atala-prism-sdk/src/commonTest/kotlin/io/iohk/atala/prism/walletsdk/prismagent/MessageMock.kt @@ -18,7 +18,7 @@ fun Message.Companion.testable( thid: String? = null, pthid: String? = null, ack: Array = emptyArray(), - direction: Message.Direction = Message.Direction.RECEIVED, + direction: Message.Direction = Message.Direction.RECEIVED ): Message { return Message( id, @@ -34,6 +34,6 @@ fun Message.Companion.testable( thid, pthid, ack, - direction, + direction ) } diff --git a/atala-prism-sdk/src/commonTest/kotlin/io/iohk/atala/prism/walletsdk/prismagent/PlutoMock.kt b/atala-prism-sdk/src/commonTest/kotlin/io/iohk/atala/prism/walletsdk/prismagent/PlutoMock.kt index 5149de43d..66fe51daf 100644 --- a/atala-prism-sdk/src/commonTest/kotlin/io/iohk/atala/prism/walletsdk/prismagent/PlutoMock.kt +++ b/atala-prism-sdk/src/commonTest/kotlin/io/iohk/atala/prism/walletsdk/prismagent/PlutoMock.kt @@ -67,7 +67,7 @@ class PlutoMock : Pluto { did: DID, keyPathIndex: Int, alias: String?, - privateKeys: List, + privateKeys: List ) { storedPrismDID += did wasStorePrismDIDAndPrivateKeysCalled = true diff --git a/atala-prism-sdk/src/commonTest/kotlin/io/iohk/atala/prism/walletsdk/prismagent/PrismAgentTests.kt b/atala-prism-sdk/src/commonTest/kotlin/io/iohk/atala/prism/walletsdk/prismagent/PrismAgentTests.kt index 1c9e35368..aaf436f7a 100644 --- a/atala-prism-sdk/src/commonTest/kotlin/io/iohk/atala/prism/walletsdk/prismagent/PrismAgentTests.kt +++ b/atala-prism-sdk/src/commonTest/kotlin/io/iohk/atala/prism/walletsdk/prismagent/PrismAgentTests.kt @@ -121,8 +121,8 @@ class PrismAgentTests { serviceEndpoint = DIDDocument.ServiceEndpoint( uri = "localhost:8082", accept = seAccept, - routingKeys = seRoutingKeys, - ), + routingKeys = seRoutingKeys + ) ) val newDID = agent.createNewPeerDID(services = arrayOf(service), updateMediator = false) @@ -297,9 +297,9 @@ class PrismAgentTests { OutOfBandInvitation.Body( "issue-vc", "To issue a Faber College Graduate credential", - listOf("didcomm/v2", "didcomm/aip2;env=rfc587"), + listOf("didcomm/v2", "didcomm/aip2;env=rfc587") ), - oobInvitation.body, + oobInvitation.body ) } diff --git a/atala-prism-sdk/src/jvmMain/kotlin/io/iohk/atala/prism/walletsdk/pluto/data/DbConnection.kt b/atala-prism-sdk/src/jvmMain/kotlin/io/iohk/atala/prism/walletsdk/pluto/data/DbConnection.kt index afb0e7e5c..245413efb 100644 --- a/atala-prism-sdk/src/jvmMain/kotlin/io/iohk/atala/prism/walletsdk/pluto/data/DbConnection.kt +++ b/atala-prism-sdk/src/jvmMain/kotlin/io/iohk/atala/prism/walletsdk/pluto/data/DbConnection.kt @@ -11,9 +11,7 @@ actual class DbConnection actual constructor() { PrismPlutoDb.Schema.create(driver) } this.driver = driver - return PrismPlutoDb( - driver, - ) + return PrismPlutoDb(driver) } } diff --git a/build.gradle.kts b/build.gradle.kts index 1ac55b0ed..ccf1ab470 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -2,13 +2,13 @@ import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin plugins { - id("org.jetbrains.kotlin.android") version "1.7.10" apply false - kotlin("jvm") version "1.7.20" - kotlin("plugin.serialization") version "1.7.20" + id("org.jetbrains.kotlin.android") version "1.9.10" apply false + kotlin("jvm") version "1.9.10" + kotlin("plugin.serialization") version "1.9.10" id("maven-publish") id("dev.petuska.npm.publish") version "3.2.1" - id("org.jlleitschuh.gradle.ktlint") version "11.0.0" - id("org.jetbrains.dokka") version "1.8.10" + id("org.jlleitschuh.gradle.ktlint") version "11.5.1" + id("org.jetbrains.dokka") version "1.9.0" } buildscript { @@ -19,10 +19,10 @@ buildscript { gradlePluginPortal() } dependencies { - classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.20") - classpath("com.android.tools.build:gradle:7.2.2") + classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.10") + classpath("com.android.tools.build:gradle:7.4.0") // 7.4.2 is still not supported classpath("com.google.protobuf:protobuf-gradle-plugin:0.9.1") - classpath("com.squareup.sqldelight:gradle-plugin:1.5.4") + classpath("com.squareup.sqldelight:gradle-plugin:1.5.5") classpath("com.github.piacenti:antlr-kotlin-gradle-plugin:0.0.14") } } @@ -30,7 +30,7 @@ buildscript { java { toolchain { languageVersion.set(JavaLanguageVersion.of(11)) - vendor.set(JvmVendorSpec.ADOPTOPENJDK) + vendor.set(JvmVendorSpec.AZUL) } } @@ -122,7 +122,7 @@ subprojects { } rootProject.plugins.withType(NodeJsRootPlugin::class.java) { - rootProject.extensions.getByType(NodeJsRootExtension::class.java).nodeVersion = "16.17.0" + rootProject.extensions.getByType(NodeJsRootExtension::class.java).nodeVersion = "18.17.1" } tasks.dokkaGfmMultiModule.configure { diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 41dfb8790..070cb702f 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/sampleapp/build.gradle.kts b/sampleapp/build.gradle.kts index 1936bd8a5..e8942566c 100644 --- a/sampleapp/build.gradle.kts +++ b/sampleapp/build.gradle.kts @@ -53,22 +53,25 @@ dependencies { // Android implementation("androidx.core:core-ktx:1.7.0") implementation("androidx.appcompat:appcompat:1.6.0") - implementation("com.google.android.material:material:1.8.0") implementation("androidx.constraintlayout:constraintlayout:2.1.4") implementation("androidx.navigation:navigation-fragment-ktx:2.5.3") implementation("androidx.navigation:navigation-ui-ktx:2.5.3") - implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.4.1") + implementation("com.google.android.material:material:1.8.0") - implementation("io.ktor:ktor-client-core:2.1.3") - implementation("io.ktor:ktor-client-okhttp:2.1.3") - implementation("io.ktor:ktor-client-content-negotiation:2.1.3") - implementation("io.ktor:ktor-serialization-kotlinx-json:2.1.3") - implementation("io.ktor:ktor-client-logging:2.1.3") + implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.0") + + // Ktor + implementation("io.ktor:ktor-client-core:2.3.4") + implementation("io.ktor:ktor-client-okhttp:2.3.4") + implementation("io.ktor:ktor-client-content-negotiation:2.3.4") + implementation("io.ktor:ktor-serialization-kotlinx-json:2.3.4") + implementation("io.ktor:ktor-client-logging:2.3.4") // WalletSDK implementation(project(":atala-prism-sdk")) implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.3.1") implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1") + // Unit Tests testImplementation("junit:junit:4.13.2") androidTestImplementation("androidx.test.ext:junit:1.1.5")