diff --git a/.editorconfig b/.editorconfig index bd15146..0f64ec1 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,9 +1,6 @@ root = true [*.{kt,kts}] -ktlint_code_style = ktlint_official ktlint_standard_no_semi = disabled ktlint_standard_trailing-comma-on-call-site = disabled ktlint_standard_trailing-comma-on-declaration-site = disabled -ktlint_standard_function-signature = disabled -ktlint_standard_max-line-length = disabled diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml deleted file mode 100644 index fcc383c..0000000 --- a/.github/workflows/lint.yml +++ /dev/null @@ -1,34 +0,0 @@ ---- -# kics-scan ignore -name: "Pull Request - Mega Linter" - -defaults: - run: - shell: bash - -on: [pull_request] - -jobs: - lint: - name: Lint changes - runs-on: ubuntu-latest - env: - GITHUB_TOKEN: ${{ secrets.ATALA_GITHUB_TOKEN }} - steps: - - name: Checkout Code - uses: actions/checkout@v3 - with: - token: ${{ secrets.ATALA_GITHUB_TOKEN }} - fetch-depth: 0 - - - name: Mega-Linter - id: ml - uses: oxsecurity/megalinter@v7.4.0 - - - name: Archive production artifacts - uses: actions/upload-artifact@v3 - with: - name: Mega-Linter reports - path: | - megalinter-reports - mega-linter.log diff --git a/.github/workflows/release-documentation.yml b/.github/workflows/release-documentation.yml index b7ec36c..1b6068a 100644 --- a/.github/workflows/release-documentation.yml +++ b/.github/workflows/release-documentation.yml @@ -15,8 +15,8 @@ env: on: workflow_dispatch: push: - tags: - - "*" + branches: + - "main" jobs: build: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..010127e --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,68 @@ +--- +# kics-scan ignore +name: "Release" + +defaults: + run: + shell: bash + +env: + JAVA_VERSION: 11 + NODEJS_VERSION: 16.17.0 + ATALA_GITHUB_ACTOR: ${{ secrets.ATALA_GITHUB_ACTOR }} + ATALA_GITHUB_TOKEN: ${{ secrets.ATALA_GITHUB_TOKEN }} + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} + +on: + workflow_dispatch: + push: + branches: + - "main" + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: "Checkout the repo" + uses: actions/checkout@v3 + + - name: "Validate Gradle Wrapper" + uses: gradle/wrapper-validation-action@v1 + + - name: "Cache gradle" + uses: actions/cache@v3 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + ~/.konan + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} + restore-keys: | + ${{ runner.os }}-gradle- + + - name: "Install Java ${{ env.JAVA_VERSION }}" + uses: actions/setup-java@v3 + with: + java-version: ${{ env.JAVA_VERSION }} + distribution: "zulu" + + - uses: crazy-max/ghaction-import-gpg@v5 + id: import_gpg + with: + gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} + git_user_signingkey: true + git_commit_gpgsign: true + + - name: "Release" + env: + GIT_AUTHOR_EMAIL: ${{ steps.import_gpg.outputs.email }} + GIT_COMMITTER_EMAIL: ${{ steps.import_gpg.outputs.email }} + GIT_AUTHOR_NAME: ${{ steps.import_gpg.outputs.name }} + GIT_COMMITTER_NAME: ${{ steps.import_gpg.outputs.name }} + SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} + SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} + BASE64_ARMORED_GPG_SIGNING_KEY_MAVEN: ${{ secrets.BASE64_ARMORED_GPG_SIGNING_KEY_MAVEN }} + SIGNING_KEY_PASSWORD: "" + run: | + npm install + npx semantic-release diff --git a/.gitignore b/.gitignore index 37afc27..d392c30 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,5 @@ Pods/ *.jks *yarn.lock JSLibs/iohk-crypto/node_modules +node_modules/* +package-lock.json diff --git a/.mega-linter.yml b/.mega-linter.yml index 74151ba..c77ad9c 100644 --- a/.mega-linter.yml +++ b/.mega-linter.yml @@ -1,6 +1,6 @@ --- APPLY_FIXES: none -FILTER_REGEX_EXCLUDE: (karma.config.js|polyfill.js|timeout.js) +FILTER_REGEX_EXCLUDE: (karma.config.js|polyfill.js|timeout.js|CHANGELOG.md) VALIDATE_ALL_CODEBASE: true REPOSITORY_DEVSKIM_DISABLE_ERRORS: true MARKDOWN_MARKDOWN_LINK_CHECK_FILTER_REGEX_EXCLUDE: (pull-request.yml|Deployment.yml|badge.svg) diff --git a/.releaserc.yml b/.releaserc.yml new file mode 100644 index 0000000..6c67465 --- /dev/null +++ b/.releaserc.yml @@ -0,0 +1,38 @@ +branches: + - name: "main" + - name: "release" + - name: "prerelease" + prerelease: "snapshot" + +plugins: + - "@semantic-release/commit-analyzer" + - "@semantic-release/release-notes-generator" + - ["@semantic-release/changelog", {changelogFile: "CHANGELOG.md"}] + - "gradle-semantic-release-plugin" + - [ + "@semantic-release/git", + { + assets: [ + "CHANGELOG.md", + "gradle.properties" + ], + message: "chore(release): cut wallet sdk version ${nextRelease.version} + + ${nextRelease.notes}", + }, + ] + - [ + "semantic-release-slack-bot", + { + notifyOnSuccess: true, + notifyOnFail: true, + markdownReleaseNotes: true, + onSuccessTemplate: + {text: "A new version of `$package_name` successfully released!\n + Version: `v${nextRelease.version}`\n + Tag: $repo_url/releases/tag/v${nextRelease.version}n + \n + Release notes:\n + $release_notes"}, + }, + ] diff --git a/README.md b/README.md index 4b84a97..6de6ef7 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,15 @@ # Mercury -[![Kotlin](https://img.shields.io/badge/kotlin-1.8.20-blue.svg?logo=kotlin)](http://kotlinlang.org) +[![Kotlin](https://img.shields.io/badge/kotlin-1.9.22-blue.svg?logo=kotlin)](http://kotlinlang.org) +![badge-license] +![badge-latest-release] +[![semantic-release-kotlin]](https://github.com/semantic-release/semantic-release) -![android](https://camo.githubusercontent.com/b1d9ad56ab51c4ad1417e9a5ad2a8fe63bcc4755e584ec7defef83755c23f923/687474703a2f2f696d672e736869656c64732e696f2f62616467652f706c6174666f726d2d616e64726f69642d3645444238442e7376673f7374796c653d666c6174) -![ios](https://camo.githubusercontent.com/1fec6f0d044c5e1d73656bfceed9a78fd4121b17e82a2705d2a47f6fd1f0e3e5/687474703a2f2f696d672e736869656c64732e696f2f62616467652f706c6174666f726d2d696f732d4344434443442e7376673f7374796c653d666c6174) -![jvm](https://camo.githubusercontent.com/700f5dcd442fd835875568c038ae5cd53518c80ae5a0cf12c7c5cf4743b5225b/687474703a2f2f696d672e736869656c64732e696f2f62616467652f706c6174666f726d2d6a766d2d4442343133442e7376673f7374796c653d666c6174) -![js](https://camo.githubusercontent.com/3e0a143e39915184b54b60a2ecedec75e801f396d34b5b366c94ec3604f7e6bd/687474703a2f2f696d672e736869656c64732e696f2f62616467652f706c6174666f726d2d6a732d4638444235442e7376673f7374796c653d666c6174) -![getNode-js](https://camo.githubusercontent.com/d08fda729ceebcae0f23c83499ca8f06105350f037661ac9a4cc7f58edfdbca9/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f706c6174666f726d2d6e6f64656a732d3638613036332e7376673f7374796c653d666c6174) +![badge-platform-android] +![badge-platform-ios] +![badge-platform-jvm] +![badge-platform-js] +![badge-platform-js-node] ![Atala Prism Logo](Logo.png) @@ -36,3 +39,15 @@ This software is provided 'as-is', without any express or implied warranty. In n authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely. + + +[badge-latest-release]: https://img.shields.io/badge/latest--release-1.0.0-blue.svg?style=flat +[badge-license]: https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg?style=flat +[semantic-release-kotlin]: https://img.shields.io/badge/semantic--release-kotlin-blue?logo=semantic-release + + +[badge-platform-android]: http://img.shields.io/badge/-android-6EDB8D.svg?style=flat +[badge-platform-ios]: http://img.shields.io/badge/-ios-CDCDCD.svg?style=flat +[badge-platform-jvm]: http://img.shields.io/badge/-jvm-DB413D.svg?style=flat +[badge-platform-js]: http://img.shields.io/badge/-js-F8DB5D.svg?style=flat +[badge-platform-js-node]: https://img.shields.io/badge/-nodejs-68a063.svg?style=flat diff --git a/build.gradle.kts b/build.gradle.kts index 545bc31..3ae81fa 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,9 +1,15 @@ import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin +import java.util.Base64 + +val publishedMavenId: String = "io.iohk.atala.prism.didcomm" plugins { id("org.jetbrains.dokka") version "1.9.10" id("maven-publish") + id("signing") + id("io.github.gradle-nexus.publish-plugin") version "2.0.0-rc-1" + id("org.jlleitschuh.gradle.ktlint") version "11.6.1" } buildscript { @@ -13,15 +19,16 @@ buildscript { mavenCentral() } dependencies { - classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.20") + classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.22") classpath("com.android.tools.build:gradle:7.2.2") classpath("org.jetbrains.dokka:dokka-base:1.9.10") } } +group = publishedMavenId + allprojects { - version = "1.0.5-alpha" - group = "io.iohk.atala.prism.didcomm" + group = publishedMavenId repositories { google() @@ -35,9 +42,81 @@ allprojects { } } + apply(plugin = "org.jlleitschuh.gradle.ktlint") apply(plugin = "org.gradle.maven-publish") + apply(plugin = "org.gradle.signing") publishing { + publications { + withType { + groupId = publishedMavenId + artifactId = project.name + version = project.version.toString() + pom { + name.set("Atala PRISM DIDPeer") + description.set("DIDComm V2 & Peer:DID") + url.set("https://docs.atalaprism.io/") + organization { + name.set("IOG") + url.set("https://iog.io/") + } + issueManagement { + system.set("Github") + url.set("https://github.com/input-output-hk/atala-prism-didcomm-kmm") + } + licenses { + license { + name.set("The Apache License, Version 2.0") + url.set("https://www.apache.org/licenses/LICENSE-2.0.txt") + } + } + developers { + developer { + id.set("hamada147") + name.set("Ahmed Moussa") + email.set("ahmed.moussa@iohk.io") + organization.set("IOG") + roles.add("developer") + url.set("https://github.com/hamada147") + } + developer { + id.set("elribonazo") + name.set("Javier Ribó") + email.set("javier.ribo@iohk.io") + organization.set("IOG") + roles.add("developer") + } + developer { + id.set("cristianIOHK") + name.set("Cristian Gonzalez") + email.set("cristian.castro@iohk.io") + organization.set("IOG") + roles.add("developer") + } + } + scm { + connection.set("scm:git:git://input-output-hk/atala-prism-didcomm-kmm.git") + developerConnection.set("scm:git:ssh://input-output-hk/atala-prism-didcomm-kmm.git") + url.set("https://github.com/input-output-hk/atala-prism-didcomm-kmm") + } + } + signing { + val base64EncodedAsciiArmoredSigningKey: String = + System.getenv("BASE64_ARMORED_GPG_SIGNING_KEY_MAVEN") ?: "" + val signingKeyPassword: String = + System.getenv("SIGNING_KEY_PASSWORD") ?: "" + useInMemoryPgpKeys( + String( + Base64.getDecoder().decode( + base64EncodedAsciiArmoredSigningKey.toByteArray() + ) + ), + signingKeyPassword + ) + sign(this@withType) + } + } + } repositories { maven { this.name = "GitHubPackages" @@ -49,8 +128,24 @@ allprojects { } } } + + ktlint { + verbose.set(true) + outputToConsole.set(true) + } } rootProject.plugins.withType(NodeJsRootPlugin::class.java) { rootProject.extensions.getByType(NodeJsRootExtension::class.java).nodeVersion = "16.17.0" } + +nexusPublishing { + repositories { + sonatype { + nexusUrl.set(uri("https://oss.sonatype.org/service/local/")) + snapshotRepositoryUrl.set(uri("https://oss.sonatype.org/content/repositories/snapshots/")) + username.set(System.getenv("SONATYPE_USERNAME")) + password.set(System.getenv("SONATYPE_PASSWORD")) + } + } +} diff --git a/didpeer/README.md b/didpeer/README.md index 01f4f19..077b858 100644 --- a/didpeer/README.md +++ b/didpeer/README.md @@ -1,12 +1,15 @@ # PeerDID -[![Kotlin](https://img.shields.io/badge/kotlin-1.8.20-blue.svg?logo=kotlin)](http://kotlinlang.org) +[![Kotlin](https://img.shields.io/badge/kotlin-1.9.22-blue.svg?logo=kotlin)](http://kotlinlang.org) +![badge-license] +![badge-latest-release] +[![semantic-release-kotlin]](https://github.com/semantic-release/semantic-release) -![android](https://camo.githubusercontent.com/b1d9ad56ab51c4ad1417e9a5ad2a8fe63bcc4755e584ec7defef83755c23f923/687474703a2f2f696d672e736869656c64732e696f2f62616467652f706c6174666f726d2d616e64726f69642d3645444238442e7376673f7374796c653d666c6174) -![ios](https://camo.githubusercontent.com/1fec6f0d044c5e1d73656bfceed9a78fd4121b17e82a2705d2a47f6fd1f0e3e5/687474703a2f2f696d672e736869656c64732e696f2f62616467652f706c6174666f726d2d696f732d4344434443442e7376673f7374796c653d666c6174) -![jvm](https://camo.githubusercontent.com/700f5dcd442fd835875568c038ae5cd53518c80ae5a0cf12c7c5cf4743b5225b/687474703a2f2f696d672e736869656c64732e696f2f62616467652f706c6174666f726d2d6a766d2d4442343133442e7376673f7374796c653d666c6174) -![js](https://camo.githubusercontent.com/3e0a143e39915184b54b60a2ecedec75e801f396d34b5b366c94ec3604f7e6bd/687474703a2f2f696d672e736869656c64732e696f2f62616467652f706c6174666f726d2d6a732d4638444235442e7376673f7374796c653d666c6174) -![getNode-js](https://camo.githubusercontent.com/d08fda729ceebcae0f23c83499ca8f06105350f037661ac9a4cc7f58edfdbca9/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f706c6174666f726d2d6e6f64656a732d3638613036332e7376673f7374796c653d666c6174) +![badge-platform-android] +![badge-platform-ios] +![badge-platform-jvm] +![badge-platform-js] +![badge-platform-js-node] ![Atala Prism Logo](../Logo.png) @@ -128,3 +131,15 @@ Example of DID documents: - [Default] 2020 verification materials (`Ed25519VerificationKey2020` and `X25519KeyAgreementKey2020`) with multibase base58 (`publicKeyMultibase`) public key encoding. - JWK (`JsonWebKey2020`) using JWK (`publicKeyJwk`) public key encoding - 2018/2019 verification materials (`Ed25519VerificationKey2018` and `X25519KeyAgreementKey2019`) using base58 (`publicKeyBase58`) public key encoding. + + +[badge-latest-release]: https://img.shields.io/badge/latest--release-1.0.0-blue.svg?style=flat +[badge-license]: https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg?style=flat +[semantic-release-kotlin]: https://img.shields.io/badge/semantic--release-kotlin-blue?logo=semantic-release + + +[badge-platform-android]: http://img.shields.io/badge/-android-6EDB8D.svg?style=flat +[badge-platform-ios]: http://img.shields.io/badge/-ios-CDCDCD.svg?style=flat +[badge-platform-jvm]: http://img.shields.io/badge/-jvm-DB413D.svg?style=flat +[badge-platform-js]: http://img.shields.io/badge/-js-F8DB5D.svg?style=flat +[badge-platform-js-node]: https://img.shields.io/badge/-nodejs-68a063.svg?style=flat diff --git a/didpeer/build.gradle.kts b/didpeer/build.gradle.kts index 1ab01ad..0b361b5 100644 --- a/didpeer/build.gradle.kts +++ b/didpeer/build.gradle.kts @@ -8,13 +8,23 @@ val os: OperatingSystem = OperatingSystem.current() plugins { kotlin("multiplatform") - kotlin("plugin.serialization") version "1.7.20" + kotlin("plugin.serialization") version "1.9.21" id("com.android.library") id("org.jetbrains.dokka") } +/** + * The `javadocJar` variable is used to register a `Jar` task to generate a Javadoc JAR file. + * The Javadoc JAR file is created with the classifier "javadoc" and it includes the HTML documentation generated + * by the `dokkaHtml` task. + */ +val javadocJar by tasks.registering(Jar::class) { + archiveClassifier.set("javadoc") + from(tasks.dokkaHtml) +} + kotlin { - android { + androidTarget { publishAllLibraryVariants() } jvm { @@ -26,17 +36,28 @@ kotlin { testRuns["test"].executionTask.configure { useJUnitPlatform() } + withSourcesJar() + publishing { + publications { + withType { + artifact(javadocJar) + } + } + } + } + iosX64 { + binaries.framework { + baseName = currentModuleName + } + } + iosArm64 { + binaries.framework { + baseName = currentModuleName + } } - if (os.isMacOsX) { - ios() -// tvos() -// watchos() -// macosX64() - if (System.getProperty("os.arch") != "x86_64") { // M1Chip - iosSimulatorArm64() -// tvosSimulatorArm64() -// watchosSimulatorArm64() -// macosArm64() + iosSimulatorArm64 { + binaries.framework { + baseName = currentModuleName } } js(IR) { @@ -69,6 +90,7 @@ kotlin { } } } + applyDefaultHierarchyTemplate() sourceSets { val commonMain by getting { @@ -77,8 +99,8 @@ kotlin { implementation("io.iohk.atala.prism.apollo:varint:1.0.2") implementation("io.iohk.atala.prism.apollo:base64:1.0.2") implementation("io.iohk.atala.prism.apollo:base58:1.0.2") - implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.4.1") - implementation("com.squareup.okio:okio:3.2.0") + implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.2") + implementation("com.squareup.okio:okio:3.6.0") } } val commonTest by getting { @@ -93,62 +115,36 @@ kotlin { } } val androidMain by getting - val androidTest by getting { + val androidUnitTest by getting { dependencies { implementation("junit:junit:4.13.2") } } val jsMain by getting val jsTest by getting - if (os.isMacOsX) { - val iosMain by getting - val iosTest by getting -// val tvosMain by getting -// val tvosTest by getting -// val watchosMain by getting -// val watchosTest by getting -// val macosX64Main by getting -// val macosX64Test by getting - if (System.getProperty("os.arch") != "x86_64") { // M1Chip - val iosSimulatorArm64Main by getting { - this.dependsOn(iosMain) - } - val iosSimulatorArm64Test by getting { - this.dependsOn(iosTest) - } -// val tvosSimulatorArm64Main by getting { -// this.dependsOn(tvosMain) -// } -// val tvosSimulatorArm64Test by getting { -// this.dependsOn(tvosTest) -// } -// val watchosSimulatorArm64Main by getting { -// this.dependsOn(watchosMain) -// } -// val watchosSimulatorArm64Test by getting { -// this.dependsOn(watchosTest) -// } -// val macosArm64Main by getting { -// this.dependsOn(macosX64Main) -// } -// val macosArm64Test by getting { -// this.dependsOn(macosX64Test) -// } - } - } + val iosMain by getting + val iosTest by getting + all { languageSettings.optIn("kotlin.RequiresOptIn") } } + + // Enable the export of KDoc (Experimental feature) to Generated Native targets (Apple, Linux, etc.) + targets.withType { + compilations.getByName("main") { + compilerOptions.options.freeCompilerArgs.add("-Xexport-kdoc") + } + } } android { namespace = "io.iohk.atala.prism.didcomm.didpeer" - compileSdk = 32 + compileSdk = 34 sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml") defaultConfig { minSdk = 21 - targetSdk = 32 + targetSdk = 34 } compileOptions { sourceCompatibility = JavaVersion.VERSION_11 @@ -209,3 +205,19 @@ tasks.withType().configureEach { } } } + +afterEvaluate { + tasks.withType { + dependsOn(tasks.withType()) + } + if (tasks.findByName("lintAnalyzeDebug") != null) { + tasks.named("lintAnalyzeDebug") { + this.enabled = false + } + } + if (tasks.findByName("lintAnalyzeRelease") != null) { + tasks.named("lintAnalyzeRelease") { + this.enabled = false + } + } +} diff --git a/didpeer/docs/DIDPeer.md b/didpeer/docs/DIDPeer.md index e3c717b..e254080 100644 --- a/didpeer/docs/DIDPeer.md +++ b/didpeer/docs/DIDPeer.md @@ -1,13 +1,5 @@ # Module DIDCommDIDPeer -[![Kotlin](https://img.shields.io/badge/kotlin-1.8.20-blue.svg?logo=kotlin)](http://kotlinlang.org) - -![android](https://camo.githubusercontent.com/b1d9ad56ab51c4ad1417e9a5ad2a8fe63bcc4755e584ec7defef83755c23f923/687474703a2f2f696d672e736869656c64732e696f2f62616467652f706c6174666f726d2d616e64726f69642d3645444238442e7376673f7374796c653d666c6174) -![ios](https://camo.githubusercontent.com/1fec6f0d044c5e1d73656bfceed9a78fd4121b17e82a2705d2a47f6fd1f0e3e5/687474703a2f2f696d672e736869656c64732e696f2f62616467652f706c6174666f726d2d696f732d4344434443442e7376673f7374796c653d666c6174) -![jvm](https://camo.githubusercontent.com/700f5dcd442fd835875568c038ae5cd53518c80ae5a0cf12c7c5cf4743b5225b/687474703a2f2f696d672e736869656c64732e696f2f62616467652f706c6174666f726d2d6a766d2d4442343133442e7376673f7374796c653d666c6174) -![js](https://camo.githubusercontent.com/3e0a143e39915184b54b60a2ecedec75e801f396d34b5b366c94ec3604f7e6bd/687474703a2f2f696d672e736869656c64732e696f2f62616467652f706c6174666f726d2d6a732d4638444235442e7376673f7374796c653d666c6174) -![getNode-js](https://camo.githubusercontent.com/d08fda729ceebcae0f23c83499ca8f06105350f037661ac9a4cc7f58edfdbca9/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f706c6174666f726d2d6e6f64656a732d3638613036332e7376673f7374796c653d666c6174) - ![Atala Prism Logo](images/Logo.png) Implementation of the [Peer DID method specification](https://identity.foundation/peer-did-method-spec/) in Kotlin MultiPlatform with support for the following targets: @@ -121,6 +113,7 @@ Example of DID documents: ``` ## Assumptions and limitations + - Only static layers [1, 2a, 2b](https://identity.foundation/peer-did-method-spec/#layers-of-support) are supported - Only `X25519` keys are support for key agreement - Only `Ed25519` keys are support for authentication diff --git a/didpeer/src/commonMain/kotlin/io/iohk/atala/prism/didcomm/didpeer/DIDDoc.kt b/didpeer/src/commonMain/kotlin/io/iohk/atala/prism/didcomm/didpeer/DIDDoc.kt index 1825320..f956d47 100644 --- a/didpeer/src/commonMain/kotlin/io/iohk/atala/prism/didcomm/didpeer/DIDDoc.kt +++ b/didpeer/src/commonMain/kotlin/io/iohk/atala/prism/didcomm/didpeer/DIDDoc.kt @@ -16,63 +16,63 @@ const val SERVICE_ACCEPT = "accept" @Serializable data class DIDDocPeerDID - @JvmOverloads - constructor( - val did: String, - val authentication: List, - val keyAgreement: List = emptyList(), - val service: List? = null - ) { - val authenticationKids - get() = authentication.map { it.id } - val agreementKids - get() = keyAgreement.map { it.id } +@JvmOverloads +constructor( + val did: String, + val authentication: List, + val keyAgreement: List = emptyList(), + val service: List? = null +) { + val authenticationKids + get() = authentication.map { it.id } + val agreementKids + get() = keyAgreement.map { it.id } - fun toDict(): Map { - val res = - mutableMapOf( - "id" to did, - "authentication" to authentication.map { it.toDict() }, - ) - if (keyAgreement.isNotEmpty()) { - res["keyAgreement"] = keyAgreement.map { it.toDict() } - } - service?.let { - res["service"] = - service.map { - when (it) { - is OtherService -> it.data - is DIDCommServicePeerDID -> it.toDict() - } + fun toDict(): Map { + val res = + mutableMapOf( + "id" to did, + "authentication" to authentication.map { it.toDict() } + ) + if (keyAgreement.isNotEmpty()) { + res["keyAgreement"] = keyAgreement.map { it.toDict() } + } + service?.let { + res["service"] = + service.map { + when (it) { + is OtherService -> it.data + is DIDCommServicePeerDID -> it.toDict() } - } - return res + } } + return res + } - fun toJson(): String { - // Json.encodeToString(toDict().toJsonElement()) - return toDict().toJsonElement().toString() - } + fun toJson(): String { + // Json.encodeToString(toDict().toJsonElement()) + return toDict().toJsonElement().toString() + } - companion object { - /** - * Creates a new instance of DIDDocPeerDID from the given DID Doc JSON. - * - * @param value DID Doc JSON - * @throws MalformedPeerDIDDOcException if the input DID Doc JSON is not a valid peerdid DID Doc - * @return [DIDDocPeerDID] instance - */ - fun fromJson(value: JSON): DIDDocPeerDID { - try { - // Two ways - return didDocFromJson(Json.parseToJsonElement(value).jsonObject) - // return Json.decodeFromString(value) - } catch (e: Exception) { - throw MalformedPeerDIDDOcException(e) - } + companion object { + /** + * Creates a new instance of DIDDocPeerDID from the given DID Doc JSON. + * + * @param value DID Doc JSON + * @throws MalformedPeerDIDDOcException if the input DID Doc JSON is not a valid peerdid DID Doc + * @return [DIDDocPeerDID] instance + */ + fun fromJson(value: JSON): DIDDocPeerDID { + try { + // Two ways + return didDocFromJson(Json.parseToJsonElement(value).jsonObject) + // return Json.decodeFromString(value) + } catch (e: Exception) { + throw MalformedPeerDIDDOcException(e) } } } +} @Serializable data class VerificationMethodPeerDID( @@ -92,7 +92,7 @@ data class VerificationMethodPeerDID( "id" to id, "type" to verMaterial.type.value, "controller" to controller, - publicKeyField().value to verMaterial.value, + publicKeyField().value to verMaterial.value ) } @@ -111,7 +111,7 @@ data class DIDCommServicePeerDID( val res = mutableMapOf( SERVICE_ID to id, - SERVICE_TYPE to type, + SERVICE_TYPE to type ) res[SERVICE_ENDPOINT] = serviceEndpoint res[SERVICE_ROUTING_KEYS] = routingKeys diff --git a/didpeer/src/commonMain/kotlin/io/iohk/atala/prism/didcomm/didpeer/Exceptions.kt b/didpeer/src/commonMain/kotlin/io/iohk/atala/prism/didcomm/didpeer/Exceptions.kt index 6e7708e..148edb2 100644 --- a/didpeer/src/commonMain/kotlin/io/iohk/atala/prism/didcomm/didpeer/Exceptions.kt +++ b/didpeer/src/commonMain/kotlin/io/iohk/atala/prism/didcomm/didpeer/Exceptions.kt @@ -9,11 +9,11 @@ import kotlin.jvm.JvmOverloads * @param cause - the cause of this. */ open class PeerDIDException - @JvmOverloads - constructor( - message: String, - cause: Throwable? = null - ) : Throwable(message, cause) +@JvmOverloads +constructor( + message: String, + cause: Throwable? = null +) : Throwable(message, cause) /** * Raised if the peer DID to be resolved in not a valid peer DID. @@ -22,11 +22,11 @@ open class PeerDIDException * @param cause - the cause of this. */ class MalformedPeerDIDException - @JvmOverloads - constructor( - message: String, - cause: Throwable? = null - ) : PeerDIDException("Invalid peer DID provided. $message", cause) +@JvmOverloads +constructor( + message: String, + cause: Throwable? = null +) : PeerDIDException("Invalid peer DID provided. $message", cause) /** * Raised if the resolved peer DID Doc to be resolved in not a valid peer DID. @@ -34,7 +34,7 @@ class MalformedPeerDIDException * @param cause - the cause of this. */ class MalformedPeerDIDDOcException - @JvmOverloads - constructor( - cause: Throwable? = null - ) : PeerDIDException("Invalid peer DID Doc", cause) +@JvmOverloads +constructor( + cause: Throwable? = null +) : PeerDIDException("Invalid peer DID Doc", cause) diff --git a/didpeer/src/commonMain/kotlin/io/iohk/atala/prism/didcomm/didpeer/PeerDIDCreator.kt b/didpeer/src/commonMain/kotlin/io/iohk/atala/prism/didcomm/didpeer/PeerDIDCreator.kt index a87f259..3c3f8c6 100644 --- a/didpeer/src/commonMain/kotlin/io/iohk/atala/prism/didcomm/didpeer/PeerDIDCreator.kt +++ b/didpeer/src/commonMain/kotlin/io/iohk/atala/prism/didcomm/didpeer/PeerDIDCreator.kt @@ -21,7 +21,7 @@ fun isPeerDID(peerDID: String): Boolean { ( "^did:peer:(([0](z)([1-9a-km-zA-HJ-NP-Z]{46,47}))" + "|(2((.[AEVID](z)([1-9a-km-zA-HJ-NP-Z]{46,47}))+(.(S)[0-9a-zA-Z=]*)*)))$" - ).toRegex() + ).toRegex() return regex.matches(peerDID) } diff --git a/didpeer/src/commonMain/kotlin/io/iohk/atala/prism/didcomm/didpeer/PeerDIDResolver.kt b/didpeer/src/commonMain/kotlin/io/iohk/atala/prism/didcomm/didpeer/PeerDIDResolver.kt index 0ce450b..29fbd59 100644 --- a/didpeer/src/commonMain/kotlin/io/iohk/atala/prism/didcomm/didpeer/PeerDIDResolver.kt +++ b/didpeer/src/commonMain/kotlin/io/iohk/atala/prism/didcomm/didpeer/PeerDIDResolver.kt @@ -50,6 +50,7 @@ private fun buildDIDDocNumalgo2(peerDID: PeerDID, format: VerificationMaterialFo val keys = peerDID.drop(11) var service = "" + val encodedServicesJson = mutableListOf() val authentications = mutableListOf() val keyAgreement = mutableListOf() @@ -58,7 +59,9 @@ private fun buildDIDDocNumalgo2(peerDID: PeerDID, format: VerificationMaterialFo val value = it.drop(1) when (prefix) { - Numalgo2Prefix.SERVICE.prefix -> service = value + Numalgo2Prefix.SERVICE.prefix -> { + encodedServicesJson.add(value) + } Numalgo2Prefix.AUTHENTICATION.prefix -> { val decodedEncumbasis = decodeMultibaseEncnumbasisAuth(value, format) @@ -74,7 +77,7 @@ private fun buildDIDDocNumalgo2(peerDID: PeerDID, format: VerificationMaterialFo } } - val decodedService = doDecodeService(service, peerDID) + val decodedService = doDecodeService(encodedServicesJson, peerDID) return DIDDocPeerDID( did = peerDID, @@ -110,7 +113,7 @@ private fun decodeMultibaseEncnumbasisAgreement( } } -private fun doDecodeService(service: String, peerDID: String): List? { +private fun doDecodeService(service: List, peerDID: String): List? { try { return decodeService(service, peerDID) } catch (e: IllegalArgumentException) { diff --git a/didpeer/src/commonMain/kotlin/io/iohk/atala/prism/didcomm/didpeer/core/DIDDocHelper.kt b/didpeer/src/commonMain/kotlin/io/iohk/atala/prism/didcomm/didpeer/core/DIDDocHelper.kt index 948d5a9..43c336c 100644 --- a/didpeer/src/commonMain/kotlin/io/iohk/atala/prism/didcomm/didpeer/core/DIDDocHelper.kt +++ b/didpeer/src/commonMain/kotlin/io/iohk/atala/prism/didcomm/didpeer/core/DIDDocHelper.kt @@ -31,7 +31,7 @@ private val verTypeToField = VerificationMethodTypeAgreement.JsonWebKey2020 to PublicKeyField.JWK, VerificationMethodTypeAuthentication.ED25519VerificationKey2018 to PublicKeyField.BASE58, VerificationMethodTypeAuthentication.ED25519VerificationKey2020 to PublicKeyField.MULTIBASE, - VerificationMethodTypeAuthentication.JsonWebKey2020 to PublicKeyField.JWK, + VerificationMethodTypeAuthentication.JsonWebKey2020 to PublicKeyField.JWK ) private val verTypeToFormat = @@ -41,7 +41,7 @@ private val verTypeToFormat = VerificationMethodTypeAgreement.JsonWebKey2020 to VerificationMaterialFormatPeerDID.JWK, VerificationMethodTypeAuthentication.ED25519VerificationKey2018 to VerificationMaterialFormatPeerDID.BASE58, VerificationMethodTypeAuthentication.ED25519VerificationKey2020 to VerificationMaterialFormatPeerDID.MULTIBASE, - VerificationMethodTypeAuthentication.JsonWebKey2020 to VerificationMaterialFormatPeerDID.JWK, + VerificationMethodTypeAuthentication.JsonWebKey2020 to VerificationMaterialFormatPeerDID.JWK ) internal fun didDocFromJson(jsonObject: JsonObject): DIDDocPeerDID { @@ -102,11 +102,11 @@ internal fun verificationMethodFromJson(jsonObject: JsonObject): VerificationMet id = id, controller = controller, verMaterial = - VerificationMaterialPeerDID( - format = format, - type = verMaterialType, - value = value - ) + VerificationMaterialPeerDID( + format = format, + type = verMaterialType, + value = value + ) ) } diff --git a/didpeer/src/commonMain/kotlin/io/iohk/atala/prism/didcomm/didpeer/core/JWKOKP.kt b/didpeer/src/commonMain/kotlin/io/iohk/atala/prism/didcomm/didpeer/core/JWKOKP.kt index 222201c..fec6035 100644 --- a/didpeer/src/commonMain/kotlin/io/iohk/atala/prism/didcomm/didpeer/core/JWKOKP.kt +++ b/didpeer/src/commonMain/kotlin/io/iohk/atala/prism/didcomm/didpeer/core/JWKOKP.kt @@ -18,7 +18,7 @@ fun toJwk(publicKey: ByteArray, verMethodType: VerificationMethodTypePeerDID): M return mapOf( "kty" to "OKP", "crv" to crv, - "x" to x, + "x" to x ) } diff --git a/didpeer/src/commonMain/kotlin/io/iohk/atala/prism/didcomm/didpeer/core/PeerDIDHelper.kt b/didpeer/src/commonMain/kotlin/io/iohk/atala/prism/didcomm/didpeer/core/PeerDIDHelper.kt index 5ccc406..19ac376 100644 --- a/didpeer/src/commonMain/kotlin/io/iohk/atala/prism/didcomm/didpeer/core/PeerDIDHelper.kt +++ b/didpeer/src/commonMain/kotlin/io/iohk/atala/prism/didcomm/didpeer/core/PeerDIDHelper.kt @@ -2,6 +2,7 @@ package io.iohk.atala.prism.didcomm.didpeer.core +import io.iohk.atala.prism.apollo.base64.base64PadDecoded import io.iohk.atala.prism.apollo.base64.base64UrlDecoded import io.iohk.atala.prism.apollo.base64.base64UrlEncoded import io.iohk.atala.prism.didcomm.didpeer.JSON @@ -36,7 +37,7 @@ private val ServicePrefix = SERVICE_ENDPOINT to "s", SERVICE_DIDCOMM_MESSAGING to "dm", SERVICE_ROUTING_KEYS to "r", - SERVICE_ACCEPT to "a", + SERVICE_ACCEPT to "a" ) /** @@ -68,21 +69,28 @@ internal fun encodeService(service: JSON): String { * @throws IllegalArgumentException if service is not correctly decoded * @return decoded service */ -internal fun decodeService(encodedService: JSON, peerDID: PeerDID): List? { - if (encodedService.isEmpty()) { +internal fun decodeService(encodedServices: List, peerDID: PeerDID): List? { + if (encodedServices.isEmpty()) { return null } - // Base64.decodeBase64(encodedService).decodeToString() - val decodedService = encodedService.base64UrlDecoded + val decodedServices = encodedServices.map { encodedService -> + encodedService.base64PadDecoded + } + + val decodedServicesJson = if (decodedServices.size == 1) { + decodedServices[0] + } else { + decodedServices.joinToString(separator = ",", prefix = "[", postfix = "]") + } val serviceMapList = try { - fromJsonToList(decodedService) + fromJsonToList(decodedServicesJson) } catch (e: SerializationException) { try { - listOf(fromJsonToMap(decodedService)) + listOf(fromJsonToMap(decodedServicesJson)) } catch (e: SerializationException) { - throw IllegalArgumentException("Invalid JSON $decodedService") + throw IllegalArgumentException("Invalid JSON $decodedServices") } } @@ -170,24 +178,24 @@ internal fun decodeMultibaseEncnumbasis( format = format, type = VerificationMethodTypeAgreement.X25519KeyAgreementKey2020, value = - toBase58Multibase( - toMulticodec( - decodedEncnumbasisWithoutPrefix, - VerificationMethodTypeAgreement.X25519KeyAgreementKey2020 - ) + toBase58Multibase( + toMulticodec( + decodedEncnumbasisWithoutPrefix, + VerificationMethodTypeAgreement.X25519KeyAgreementKey2020 ) + ) ) Codec.ED25519 -> VerificationMaterialAuthentication( format = format, type = VerificationMethodTypeAuthentication.ED25519VerificationKey2020, value = - toBase58Multibase( - toMulticodec( - decodedEncnumbasisWithoutPrefix, - VerificationMethodTypeAuthentication.ED25519VerificationKey2020 - ) + toBase58Multibase( + toMulticodec( + decodedEncnumbasisWithoutPrefix, + VerificationMethodTypeAuthentication.ED25519VerificationKey2020 ) + ) ) } VerificationMaterialFormatPeerDID.JWK -> @@ -203,10 +211,10 @@ internal fun decodeMultibaseEncnumbasis( format = format, type = VerificationMethodTypeAuthentication.JsonWebKey2020, value = - toJwk( - decodedEncnumbasisWithoutPrefix, - VerificationMethodTypeAuthentication.JsonWebKey2020 - ) + toJwk( + decodedEncnumbasisWithoutPrefix, + VerificationMethodTypeAuthentication.JsonWebKey2020 + ) ) } } diff --git a/didpeer/src/commonTest/kotlin/io/iohk/atala/prism/didcomm/didpeer/Fixture.kt b/didpeer/src/commonTest/kotlin/io/iohk/atala/prism/didcomm/didpeer/Fixture.kt index e0aa161..25e8651 100644 --- a/didpeer/src/commonTest/kotlin/io/iohk/atala/prism/didcomm/didpeer/Fixture.kt +++ b/didpeer/src/commonTest/kotlin/io/iohk/atala/prism/didcomm/didpeer/Fixture.kt @@ -66,7 +66,7 @@ const val PEER_DID_NUMALGO_2 = ( ".Vz6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V" + ".Vz6MkgoLTnTypo3tDRwCkZXSccTPHRLhF4ZnjhueYAFpEX6vg" + ".SeyJ0IjoiZG0iLCJzIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS9lbmRwb2ludCIsInIiOlsiZGlkOmV4YW1wbGU6c29tZW1lZGlhdG9yI3NvbWVrZXkiXSwiYSI6WyJkaWRjb21tL3YyIiwiZGlkY29tbS9haXAyO2Vudj1yZmM1ODciXX0" -) + ) const val DID_DOC_NUMALGO_2_BASE58 = """ { @@ -208,7 +208,7 @@ const val PEER_DID_NUMALGO_2_2_SERVICES = ( ".Ez6LSpSrLxbAhg2SHwKk7kwpsH7DM7QjFS5iK6qP87eViohud" + ".Vz6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V" + ".SW3sidCI6ImRtIiwicyI6Imh0dHBzOi8vZXhhbXBsZS5jb20vZW5kcG9pbnQiLCJyIjpbImRpZDpleGFtcGxlOnNvbWVtZWRpYXRvciNzb21la2V5Il19LHsidCI6ImV4YW1wbGUiLCJzIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS9lbmRwb2ludDIiLCJyIjpbImRpZDpleGFtcGxlOnNvbWVtZWRpYXRvciNzb21la2V5MiJdLCJhIjpbImRpZGNvbW0vdjIiLCJkaWRjb21tL2FpcDI7ZW52PXJmYzU4NyJdfV0" -) + ) const val DID_DOC_NUMALGO_2_MULTIBASE_2_SERVICES = """ { @@ -251,11 +251,63 @@ const val DID_DOC_NUMALGO_2_MULTIBASE_2_SERVICES = """ } """ +const val PEER_DID_NUMALGO_2_2_ENCODED_SERVICES_INDIVIDUALLY = ( + "did:peer:2" + + ".Ez6LSpSrLxbAhg2SHwKk7kwpsH7DM7QjFS5iK6qP87eViohud" + + ".Vz6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V" + + ".SeyJ0IjoiZG0iLCJzIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS9lbmRwb2ludCIsInIiOlsiZGlkOmV4YW1wbGU6c29tZW1lZGlhdG9yI3NvbWVrZXkiXX0K" + + ".SeyJ0IjoiZXhhbXBsZSIsInMiOiJodHRwczovL2V4YW1wbGUuY29tL2VuZHBvaW50MiIsInIiOlsiZGlkOmV4YW1wbGU6c29tZW1lZGlhdG9yI3NvbWVrZXkyIl0sImEiOlsiZGlkY29tbS92MiIsImRpZGNvbW0vYWlwMjtlbnY9cmZjNTg3Il19" + ) + +const val DID_DOC_NUMALGO_2_MULTIBASE_2_SERVICES_INDIVIDUALLY = """ + { + "id": "did:peer:2.Ez6LSpSrLxbAhg2SHwKk7kwpsH7DM7QjFS5iK6qP87eViohud.Vz6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V.SeyJ0IjoiZG0iLCJzIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS9lbmRwb2ludCIsInIiOlsiZGlkOmV4YW1wbGU6c29tZW1lZGlhdG9yI3NvbWVrZXkiXX0K.SeyJ0IjoiZXhhbXBsZSIsInMiOiJodHRwczovL2V4YW1wbGUuY29tL2VuZHBvaW50MiIsInIiOlsiZGlkOmV4YW1wbGU6c29tZW1lZGlhdG9yI3NvbWVrZXkyIl0sImEiOlsiZGlkY29tbS92MiIsImRpZGNvbW0vYWlwMjtlbnY9cmZjNTg3Il19", + "authentication": [ + { + "id": "did:peer:2.Ez6LSpSrLxbAhg2SHwKk7kwpsH7DM7QjFS5iK6qP87eViohud.Vz6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V.SeyJ0IjoiZG0iLCJzIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS9lbmRwb2ludCIsInIiOlsiZGlkOmV4YW1wbGU6c29tZW1lZGlhdG9yI3NvbWVrZXkiXX0K.SeyJ0IjoiZXhhbXBsZSIsInMiOiJodHRwczovL2V4YW1wbGUuY29tL2VuZHBvaW50MiIsInIiOlsiZGlkOmV4YW1wbGU6c29tZW1lZGlhdG9yI3NvbWVrZXkyIl0sImEiOlsiZGlkY29tbS92MiIsImRpZGNvbW0vYWlwMjtlbnY9cmZjNTg3Il19#6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V", + "type": "Ed25519VerificationKey2020", + "controller": "did:peer:2.Ez6LSpSrLxbAhg2SHwKk7kwpsH7DM7QjFS5iK6qP87eViohud.Vz6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V.SeyJ0IjoiZG0iLCJzIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS9lbmRwb2ludCIsInIiOlsiZGlkOmV4YW1wbGU6c29tZW1lZGlhdG9yI3NvbWVrZXkiXX0K.SeyJ0IjoiZXhhbXBsZSIsInMiOiJodHRwczovL2V4YW1wbGUuY29tL2VuZHBvaW50MiIsInIiOlsiZGlkOmV4YW1wbGU6c29tZW1lZGlhdG9yI3NvbWVrZXkyIl0sImEiOlsiZGlkY29tbS92MiIsImRpZGNvbW0vYWlwMjtlbnY9cmZjNTg3Il19", + "publicKeyMultibase": "z6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V" + } + ], + "keyAgreement": [ + { + "id": "did:peer:2.Ez6LSpSrLxbAhg2SHwKk7kwpsH7DM7QjFS5iK6qP87eViohud.Vz6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V.SeyJ0IjoiZG0iLCJzIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS9lbmRwb2ludCIsInIiOlsiZGlkOmV4YW1wbGU6c29tZW1lZGlhdG9yI3NvbWVrZXkiXX0K.SeyJ0IjoiZXhhbXBsZSIsInMiOiJodHRwczovL2V4YW1wbGUuY29tL2VuZHBvaW50MiIsInIiOlsiZGlkOmV4YW1wbGU6c29tZW1lZGlhdG9yI3NvbWVrZXkyIl0sImEiOlsiZGlkY29tbS92MiIsImRpZGNvbW0vYWlwMjtlbnY9cmZjNTg3Il19#6LSpSrLxbAhg2SHwKk7kwpsH7DM7QjFS5iK6qP87eViohud", + "type": "X25519KeyAgreementKey2020", + "controller": "did:peer:2.Ez6LSpSrLxbAhg2SHwKk7kwpsH7DM7QjFS5iK6qP87eViohud.Vz6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V.SeyJ0IjoiZG0iLCJzIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS9lbmRwb2ludCIsInIiOlsiZGlkOmV4YW1wbGU6c29tZW1lZGlhdG9yI3NvbWVrZXkiXX0K.SeyJ0IjoiZXhhbXBsZSIsInMiOiJodHRwczovL2V4YW1wbGUuY29tL2VuZHBvaW50MiIsInIiOlsiZGlkOmV4YW1wbGU6c29tZW1lZGlhdG9yI3NvbWVrZXkyIl0sImEiOlsiZGlkY29tbS92MiIsImRpZGNvbW0vYWlwMjtlbnY9cmZjNTg3Il19", + "publicKeyMultibase": "z6LSpSrLxbAhg2SHwKk7kwpsH7DM7QjFS5iK6qP87eViohud" + } + ], + "service": [ + { + "id": "did:peer:2.Ez6LSpSrLxbAhg2SHwKk7kwpsH7DM7QjFS5iK6qP87eViohud.Vz6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V.SeyJ0IjoiZG0iLCJzIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS9lbmRwb2ludCIsInIiOlsiZGlkOmV4YW1wbGU6c29tZW1lZGlhdG9yI3NvbWVrZXkiXX0K.SeyJ0IjoiZXhhbXBsZSIsInMiOiJodHRwczovL2V4YW1wbGUuY29tL2VuZHBvaW50MiIsInIiOlsiZGlkOmV4YW1wbGU6c29tZW1lZGlhdG9yI3NvbWVrZXkyIl0sImEiOlsiZGlkY29tbS92MiIsImRpZGNvbW0vYWlwMjtlbnY9cmZjNTg3Il19#didcommmessaging-0", + "type": "DIDCommMessaging", + "serviceEndpoint": "https://example.com/endpoint", + "routingKeys": [ + "did:example:somemediator#somekey" + ] + }, + { + "id": "did:peer:2.Ez6LSpSrLxbAhg2SHwKk7kwpsH7DM7QjFS5iK6qP87eViohud.Vz6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V.SeyJ0IjoiZG0iLCJzIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS9lbmRwb2ludCIsInIiOlsiZGlkOmV4YW1wbGU6c29tZW1lZGlhdG9yI3NvbWVrZXkiXX0K.SeyJ0IjoiZXhhbXBsZSIsInMiOiJodHRwczovL2V4YW1wbGUuY29tL2VuZHBvaW50MiIsInIiOlsiZGlkOmV4YW1wbGU6c29tZW1lZGlhdG9yI3NvbWVrZXkyIl0sImEiOlsiZGlkY29tbS92MiIsImRpZGNvbW0vYWlwMjtlbnY9cmZjNTg3Il19#example-1", + "type": "example", + "serviceEndpoint": "https://example.com/endpoint2", + "routingKeys": [ + "did:example:somemediator#somekey2" + ], + "accept": [ + "didcomm/v2", + "didcomm/aip2;env=rfc587" + ] + } + ] + } + """ + const val PEER_DID_NUMALGO_2_NO_SERVICES = ( "did:peer:2" + ".Ez6LSpSrLxbAhg2SHwKk7kwpsH7DM7QjFS5iK6qP87eViohud" + ".Vz6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V" -) + ) const val DID_DOC_NUMALGO_2_MULTIBASE_NO_SERVICES = """ { diff --git a/didpeer/src/commonTest/kotlin/io/iohk/atala/prism/didcomm/didpeer/TestCreateNumalgo0.kt b/didpeer/src/commonTest/kotlin/io/iohk/atala/prism/didcomm/didpeer/TestCreateNumalgo0.kt index b6ec9b9..a4508f8 100644 --- a/didpeer/src/commonTest/kotlin/io/iohk/atala/prism/didcomm/didpeer/TestCreateNumalgo0.kt +++ b/didpeer/src/commonTest/kotlin/io/iohk/atala/prism/didcomm/didpeer/TestCreateNumalgo0.kt @@ -75,7 +75,7 @@ class TestCreateNumalgo0 { VerificationMaterialAuthentication( value = "z78kqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V", type = VerificationMethodTypeAuthentication.ED25519VerificationKey2020, - format = VerificationMaterialFormatPeerDID.MULTIBASE, + format = VerificationMaterialFormatPeerDID.MULTIBASE ) val ex = assertFails { @@ -90,34 +90,34 @@ class TestCreateNumalgo0 { VerificationMaterialAuthentication( value = "ByHnpUCFb1vAfh9CFZ8ZkmUZguURW8nSw889hy6rD8L7", type = VerificationMethodTypeAuthentication.ED25519VerificationKey2018, - format = VerificationMaterialFormatPeerDID.BASE58, + format = VerificationMaterialFormatPeerDID.BASE58 ), VerificationMaterialAuthentication( value = "z6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V", type = VerificationMethodTypeAuthentication.ED25519VerificationKey2020, - format = VerificationMaterialFormatPeerDID.MULTIBASE, + format = VerificationMaterialFormatPeerDID.MULTIBASE ), VerificationMaterialAuthentication( value = - mapOf( - "kty" to "OKP", - "crv" to "Ed25519", - "x" to "owBhCbktDjkfS6PdQddT0D3yjSitaSysP3YimJ_YgmA", - ), + mapOf( + "kty" to "OKP", + "crv" to "Ed25519", + "x" to "owBhCbktDjkfS6PdQddT0D3yjSitaSysP3YimJ_YgmA" + ), type = VerificationMethodTypeAuthentication.JsonWebKey2020, - format = VerificationMaterialFormatPeerDID.JWK, + format = VerificationMaterialFormatPeerDID.JWK ), VerificationMaterialAuthentication( value = - toJson( - mapOf( - "kty" to "OKP", - "crv" to "Ed25519", - "x" to "owBhCbktDjkfS6PdQddT0D3yjSitaSysP3YimJ_YgmA", - ) - ), + toJson( + mapOf( + "kty" to "OKP", + "crv" to "Ed25519", + "x" to "owBhCbktDjkfS6PdQddT0D3yjSitaSysP3YimJ_YgmA" + ) + ), type = VerificationMethodTypeAuthentication.JsonWebKey2020, - format = VerificationMaterialFormatPeerDID.JWK, + format = VerificationMaterialFormatPeerDID.JWK ) ) @@ -126,12 +126,12 @@ class TestCreateNumalgo0 { VerificationMaterialAuthentication( value = "x8xB2pv7cw8q1Pd0DacS", type = VerificationMethodTypeAuthentication.ED25519VerificationKey2018, - format = VerificationMaterialFormatPeerDID.BASE58, + format = VerificationMaterialFormatPeerDID.BASE58 ), VerificationMaterialAuthentication( value = "zx8xB2pv7cw8q1Pd0DacS", type = VerificationMethodTypeAuthentication.ED25519VerificationKey2020, - format = VerificationMaterialFormatPeerDID.MULTIBASE, + format = VerificationMaterialFormatPeerDID.MULTIBASE ) ) @@ -140,34 +140,34 @@ class TestCreateNumalgo0 { VerificationMaterialAuthentication( value = "ByHnpUCFb1vAfh9CFZ8ZkmUZguURW8nSw889hy6rD8", type = VerificationMethodTypeAuthentication.ED25519VerificationKey2018, - format = VerificationMaterialFormatPeerDID.BASE58, + format = VerificationMaterialFormatPeerDID.BASE58 ), VerificationMaterialAuthentication( value = "z6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7", type = VerificationMethodTypeAuthentication.ED25519VerificationKey2020, - format = VerificationMaterialFormatPeerDID.MULTIBASE, + format = VerificationMaterialFormatPeerDID.MULTIBASE ), VerificationMaterialAuthentication( value = - mapOf( - "kty" to "OKP", - "crv" to "Ed25519", - "x" to "owBhCbktDjkfS6PdQddT0D3yjSitaSysP3YimJ_Ygm", - ), + mapOf( + "kty" to "OKP", + "crv" to "Ed25519", + "x" to "owBhCbktDjkfS6PdQddT0D3yjSitaSysP3YimJ_Ygm" + ), type = VerificationMethodTypeAuthentication.JsonWebKey2020, - format = VerificationMaterialFormatPeerDID.JWK, + format = VerificationMaterialFormatPeerDID.JWK ), VerificationMaterialAuthentication( value = - toJson( - mapOf( - "kty" to "OKP", - "crv" to "Ed25519", - "x" to "owBhCbktDjkfS6PdQddT0D3yjSitaSysP3YimJ_Ygm", - ) - ), + toJson( + mapOf( + "kty" to "OKP", + "crv" to "Ed25519", + "x" to "owBhCbktDjkfS6PdQddT0D3yjSitaSysP3YimJ_Ygm" + ) + ), type = VerificationMethodTypeAuthentication.JsonWebKey2020, - format = VerificationMaterialFormatPeerDID.JWK, + format = VerificationMaterialFormatPeerDID.JWK ) ) @@ -176,34 +176,34 @@ class TestCreateNumalgo0 { VerificationMaterialAuthentication( value = "ByHnpUCFb1vAfh9CFZ8ZkmUZguURW8nSw889hy6rD8L77", type = VerificationMethodTypeAuthentication.ED25519VerificationKey2018, - format = VerificationMaterialFormatPeerDID.BASE58, + format = VerificationMaterialFormatPeerDID.BASE58 ), VerificationMaterialAuthentication( value = "z6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7VVV", type = VerificationMethodTypeAuthentication.ED25519VerificationKey2020, - format = VerificationMaterialFormatPeerDID.MULTIBASE, + format = VerificationMaterialFormatPeerDID.MULTIBASE ), VerificationMaterialAuthentication( value = - mapOf( - "kty" to "OKP", - "crv" to "Ed25519", - "x" to "owBhCbktDjkfS6PdQddT0D3yjSitaSysP3YimJ_YgmA7", - ), + mapOf( + "kty" to "OKP", + "crv" to "Ed25519", + "x" to "owBhCbktDjkfS6PdQddT0D3yjSitaSysP3YimJ_YgmA7" + ), type = VerificationMethodTypeAuthentication.JsonWebKey2020, - format = VerificationMaterialFormatPeerDID.JWK, + format = VerificationMaterialFormatPeerDID.JWK ), VerificationMaterialAuthentication( value = - toJson( - mapOf( - "kty" to "OKP", - "crv" to "Ed25519", - "x" to "owBhCbktDjkfS6PdQddT0D3yjSitaSysP3YimJ_YgmA7", - ) - ), + toJson( + mapOf( + "kty" to "OKP", + "crv" to "Ed25519", + "x" to "owBhCbktDjkfS6PdQddT0D3yjSitaSysP3YimJ_YgmA7" + ) + ), type = VerificationMethodTypeAuthentication.JsonWebKey2020, - format = VerificationMaterialFormatPeerDID.JWK, + format = VerificationMaterialFormatPeerDID.JWK ) ) @@ -212,34 +212,34 @@ class TestCreateNumalgo0 { VerificationMaterialAuthentication( value = "", type = VerificationMethodTypeAuthentication.ED25519VerificationKey2018, - format = VerificationMaterialFormatPeerDID.BASE58, + format = VerificationMaterialFormatPeerDID.BASE58 ), VerificationMaterialAuthentication( value = "", type = VerificationMethodTypeAuthentication.ED25519VerificationKey2020, - format = VerificationMaterialFormatPeerDID.MULTIBASE, + format = VerificationMaterialFormatPeerDID.MULTIBASE ), VerificationMaterialAuthentication( value = - mapOf( - "kty" to "OKP", - "crv" to "Ed25519", - "x" to "", - ), + mapOf( + "kty" to "OKP", + "crv" to "Ed25519", + "x" to "" + ), type = VerificationMethodTypeAuthentication.JsonWebKey2020, - format = VerificationMaterialFormatPeerDID.JWK, + format = VerificationMaterialFormatPeerDID.JWK ), VerificationMaterialAuthentication( value = - toJson( - mapOf( - "kty" to "OKP", - "crv" to "Ed25519", - "x" to "", - ) - ), + toJson( + mapOf( + "kty" to "OKP", + "crv" to "Ed25519", + "x" to "" + ) + ), type = VerificationMethodTypeAuthentication.JsonWebKey2020, - format = VerificationMaterialFormatPeerDID.JWK, + format = VerificationMaterialFormatPeerDID.JWK ) ) } diff --git a/didpeer/src/commonTest/kotlin/io/iohk/atala/prism/didcomm/didpeer/TestCreateNumalgo2.kt b/didpeer/src/commonTest/kotlin/io/iohk/atala/prism/didcomm/didpeer/TestCreateNumalgo2.kt index 1b06b6d..15b6310 100644 --- a/didpeer/src/commonTest/kotlin/io/iohk/atala/prism/didcomm/didpeer/TestCreateNumalgo2.kt +++ b/didpeer/src/commonTest/kotlin/io/iohk/atala/prism/didcomm/didpeer/TestCreateNumalgo2.kt @@ -30,11 +30,11 @@ class TestCreateNumalgo2 { val VALID_X25519_KEY_JWK_DICT = VerificationMaterialAgreement( value = - mapOf( - "kty" to "OKP", - "crv" to "X25519", - "x" to "BIiFcQEn3dfvB2pjlhOQQour6jXy9d5s2FKEJNTOJik", - ), + mapOf( + "kty" to "OKP", + "crv" to "X25519", + "x" to "BIiFcQEn3dfvB2pjlhOQQour6jXy9d5s2FKEJNTOJik" + ), type = VerificationMethodTypeAgreement.JsonWebKey2020, format = VerificationMaterialFormatPeerDID.JWK ) @@ -42,13 +42,13 @@ class TestCreateNumalgo2 { val VALID_X25519_KEY_JWK_JSON = VerificationMaterialAgreement( value = - toJson( - mapOf( - "kty" to "OKP", - "crv" to "X25519", - "x" to "BIiFcQEn3dfvB2pjlhOQQour6jXy9d5s2FKEJNTOJik", - ) - ), + toJson( + mapOf( + "kty" to "OKP", + "crv" to "X25519", + "x" to "BIiFcQEn3dfvB2pjlhOQQour6jXy9d5s2FKEJNTOJik" + ) + ), type = VerificationMethodTypeAgreement.JsonWebKey2020, format = VerificationMaterialFormatPeerDID.JWK ) @@ -68,11 +68,11 @@ class TestCreateNumalgo2 { val VALID_ED25519_KEY_1_JWK = VerificationMaterialAuthentication( value = - mapOf( - "kty" to "OKP", - "crv" to "Ed25519", - "x" to "owBhCbktDjkfS6PdQddT0D3yjSitaSysP3YimJ_YgmA", - ), + mapOf( + "kty" to "OKP", + "crv" to "Ed25519", + "x" to "owBhCbktDjkfS6PdQddT0D3yjSitaSysP3YimJ_YgmA" + ), type = VerificationMethodTypeAuthentication.JsonWebKey2020, format = VerificationMaterialFormatPeerDID.JWK ) @@ -92,11 +92,11 @@ class TestCreateNumalgo2 { val VALID_ED25519_KEY_2_JWK = VerificationMaterialAuthentication( value = - mapOf( - "kty" to "OKP", - "crv" to "Ed25519", - "x" to "Itv8B__b1-Jos3LCpUe8EdTFGTCa_Dza6_3848P3R70", - ), + mapOf( + "kty" to "OKP", + "crv" to "Ed25519", + "x" to "Itv8B__b1-Jos3LCpUe8EdTFGTCa_Dza6_3848P3R70" + ), type = VerificationMethodTypeAuthentication.JsonWebKey2020, format = VerificationMaterialFormatPeerDID.JWK ) diff --git a/didpeer/src/commonTest/kotlin/io/iohk/atala/prism/didcomm/didpeer/TestDemo.kt b/didpeer/src/commonTest/kotlin/io/iohk/atala/prism/didcomm/didpeer/TestDemo.kt index d3eae48..26bcc7a 100644 --- a/didpeer/src/commonTest/kotlin/io/iohk/atala/prism/didcomm/didpeer/TestDemo.kt +++ b/didpeer/src/commonTest/kotlin/io/iohk/atala/prism/didcomm/didpeer/TestDemo.kt @@ -10,7 +10,7 @@ class TestDemo { VerificationMaterialAgreement( type = VerificationMethodTypeAgreement.X25519KeyAgreementKey2019, format = VerificationMaterialFormatPeerDID.BASE58, - value = "DmgBSHMqaZiYqwNMEJJuxWzsGGC8jUYADrfSdBrC6L8s", + value = "DmgBSHMqaZiYqwNMEJJuxWzsGGC8jUYADrfSdBrC6L8s" ) ) val signingKeys = @@ -18,7 +18,7 @@ class TestDemo { VerificationMaterialAuthentication( type = VerificationMethodTypeAuthentication.ED25519VerificationKey2018, format = VerificationMaterialFormatPeerDID.BASE58, - value = "ByHnpUCFb1vAfh9CFZ8ZkmUZguURW8nSw889hy6rD8L7", + value = "ByHnpUCFb1vAfh9CFZ8ZkmUZguURW8nSw889hy6rD8L7" ) ) val service = diff --git a/didpeer/src/commonTest/kotlin/io/iohk/atala/prism/didcomm/didpeer/TestResolveNumalgo2.kt b/didpeer/src/commonTest/kotlin/io/iohk/atala/prism/didcomm/didpeer/TestResolveNumalgo2.kt index 2706d06..cb26d3c 100644 --- a/didpeer/src/commonTest/kotlin/io/iohk/atala/prism/didcomm/didpeer/TestResolveNumalgo2.kt +++ b/didpeer/src/commonTest/kotlin/io/iohk/atala/prism/didcomm/didpeer/TestResolveNumalgo2.kt @@ -36,6 +36,12 @@ class TestResolveNumalgo2 { assertEquals(fromJson(DID_DOC_NUMALGO_2_MULTIBASE_2_SERVICES), fromJson(realValue)) } + @Test + fun testResolvePositiveIndividuallyEncodedServiceIs2ElementsArray() { + val realValue = resolvePeerDID(PEER_DID_NUMALGO_2_2_ENCODED_SERVICES_INDIVIDUALLY) + assertEquals(fromJson(DID_DOC_NUMALGO_2_MULTIBASE_2_SERVICES_INDIVIDUALLY), fromJson(realValue)) + } + @Test fun testResolvePositiveNoService() { val realValue = resolvePeerDID(PEER_DID_NUMALGO_2_NO_SERVICES) diff --git a/didpeer/src/commonTest/kotlin/io/iohk/atala/prism/didcomm/didpeer/core/TestEncumbasisEncodeDecode.kt b/didpeer/src/commonTest/kotlin/io/iohk/atala/prism/didcomm/didpeer/core/TestEncumbasisEncodeDecode.kt index 3ba25ba..572adee 100644 --- a/didpeer/src/commonTest/kotlin/io/iohk/atala/prism/didcomm/didpeer/core/TestEncumbasisEncodeDecode.kt +++ b/didpeer/src/commonTest/kotlin/io/iohk/atala/prism/didcomm/didpeer/core/TestEncumbasisEncodeDecode.kt @@ -25,7 +25,7 @@ internal class TestEncumbasisEncodeDecode { VerificationMaterialAuthentication( format = VerificationMaterialFormatPeerDID.BASE58, type = VerificationMethodTypeAuthentication.ED25519VerificationKey2018, - value = "ByHnpUCFb1vAfh9CFZ8ZkmUZguURW8nSw889hy6rD8L7", + value = "ByHnpUCFb1vAfh9CFZ8ZkmUZguURW8nSw889hy6rD8L7" ) ), DecodeEncumbasisTestData( @@ -34,8 +34,8 @@ internal class TestEncumbasisEncodeDecode { VerificationMaterialAgreement( format = VerificationMaterialFormatPeerDID.BASE58, type = VerificationMethodTypeAgreement.X25519KeyAgreementKey2019, - value = "JhNWeSVLMYccCk7iopQW4guaSJTojqpMEELgSLhKwRr", - ), + value = "JhNWeSVLMYccCk7iopQW4guaSJTojqpMEELgSLhKwRr" + ) ), DecodeEncumbasisTestData( "z6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V", @@ -43,8 +43,8 @@ internal class TestEncumbasisEncodeDecode { VerificationMaterialAuthentication( format = VerificationMaterialFormatPeerDID.MULTIBASE, type = VerificationMethodTypeAuthentication.ED25519VerificationKey2020, - value = "z6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V", - ), + value = "z6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V" + ) ), DecodeEncumbasisTestData( "z6LSbysY2xFMRpGMhb7tFTLMpeuPRaqaWM1yECx2AtzE3KCc", @@ -52,8 +52,8 @@ internal class TestEncumbasisEncodeDecode { VerificationMaterialAgreement( format = VerificationMaterialFormatPeerDID.MULTIBASE, type = VerificationMethodTypeAgreement.X25519KeyAgreementKey2020, - value = "z6LSbysY2xFMRpGMhb7tFTLMpeuPRaqaWM1yECx2AtzE3KCc", - ), + value = "z6LSbysY2xFMRpGMhb7tFTLMpeuPRaqaWM1yECx2AtzE3KCc" + ) ), DecodeEncumbasisTestData( "z6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V", @@ -62,12 +62,12 @@ internal class TestEncumbasisEncodeDecode { format = VerificationMaterialFormatPeerDID.JWK, type = VerificationMethodTypeAuthentication.JsonWebKey2020, value = - mapOf( - "kty" to "OKP", - "crv" to "Ed25519", - "x" to "owBhCbktDjkfS6PdQddT0D3yjSitaSysP3YimJ_YgmA", - ) - ), + mapOf( + "kty" to "OKP", + "crv" to "Ed25519", + "x" to "owBhCbktDjkfS6PdQddT0D3yjSitaSysP3YimJ_YgmA" + ) + ) ), DecodeEncumbasisTestData( "z6LSbysY2xFMRpGMhb7tFTLMpeuPRaqaWM1yECx2AtzE3KCc", @@ -76,12 +76,12 @@ internal class TestEncumbasisEncodeDecode { format = VerificationMaterialFormatPeerDID.JWK, type = VerificationMethodTypeAgreement.JsonWebKey2020, value = - mapOf( - "kty" to "OKP", - "crv" to "X25519", - "x" to "BIiFcQEn3dfvB2pjlhOQQour6jXy9d5s2FKEJNTOJik", - ), - ), + mapOf( + "kty" to "OKP", + "crv" to "X25519", + "x" to "BIiFcQEn3dfvB2pjlhOQQour6jXy9d5s2FKEJNTOJik" + ) + ) ) ) diff --git a/didpeer/src/commonTest/kotlin/io/iohk/atala/prism/didcomm/didpeer/core/TestServiceEncodeDecode.kt b/didpeer/src/commonTest/kotlin/io/iohk/atala/prism/didcomm/didpeer/core/TestServiceEncodeDecode.kt index e436dd0..a707a42 100644 --- a/didpeer/src/commonTest/kotlin/io/iohk/atala/prism/didcomm/didpeer/core/TestServiceEncodeDecode.kt +++ b/didpeer/src/commonTest/kotlin/io/iohk/atala/prism/didcomm/didpeer/core/TestServiceEncodeDecode.kt @@ -33,13 +33,15 @@ class TestServiceEncodeDecode { "type" to "DIDCommMessaging", "serviceEndpoint" to "https://example.com/endpoint", "routingKeys" to listOf("did:example:somemediator#somekey"), - "accept" to listOf("didcomm/v2", "didcomm/aip2;env=rfc587"), + "accept" to listOf("didcomm/v2", "didcomm/aip2;env=rfc587") ) ) ) val service = decodeService( - "eyJ0IjoiZG0iLCJzIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS9lbmRwb2ludCIsInIiOlsiZGlkOmV4YW1wbGU6c29tZW1lZGlhdG9yI3NvbWVrZXkiXSwiYSI6WyJkaWRjb21tL3YyIiwiZGlkY29tbS9haXAyO2Vudj1yZmM1ODciXX0", + listOf( + "eyJ0IjoiZG0iLCJzIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS9lbmRwb2ludCIsInIiOlsiZGlkOmV4YW1wbGU6c29tZW1lZGlhdG9yI3NvbWVrZXkiXSwiYSI6WyJkaWRjb21tL3YyIiwiZGlkY29tbS9haXAyO2Vudj1yZmM1ODciXX0" + ), PEER_DID_NUMALGO_2 ) assertEquals(expected, service) @@ -74,7 +76,9 @@ class TestServiceEncodeDecode { ) val service = decodeService( - "eyJ0IjoiZG0iLCJzIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS9lbmRwb2ludCJ9", + listOf( + "eyJ0IjoiZG0iLCJzIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS9lbmRwb2ludCJ9" + ), PEER_DID_NUMALGO_2 ) assertEquals(expected, service) @@ -128,9 +132,42 @@ class TestServiceEncodeDecode { ) val service = decodeService( - "W3sidCI6ImRtIiwicyI6Imh0dHBzOi8vZXhhbXBsZS5jb20vZW5kcG9pbnQiLCJyIjpbImRpZDpleGFtcGxlOnNvbWVtZWRpYXRvciNzb21la2V5Il0sImEiOlsiZGlkY29tbS92MiIsImRpZGNvbW0vYWlwMjtlbnY9cmZjNTg3Il19LHsidCI6ImRtIiwicyI6Imh0dHBzOi8vZXhhbXBsZS5jb20vZW5kcG9pbnQyIiwiciI6WyJkaWQ6ZXhhbXBsZTpzb21lbWVkaWF0b3Ijc29tZWtleTIiXX1d", + listOf( + "W3sidCI6ImRtIiwicyI6Imh0dHBzOi8vZXhhbXBsZS5jb20vZW5kcG9pbnQiLCJyIjpbImRpZDpleGFtcGxlOnNvbWVtZWRpYXRvciNzb21la2V5Il0sImEiOlsiZGlkY29tbS92MiIsImRpZGNvbW0vYWlwMjtlbnY9cmZjNTg3Il19LHsidCI6ImRtIiwicyI6Imh0dHBzOi8vZXhhbXBsZS5jb20vZW5kcG9pbnQyIiwiciI6WyJkaWQ6ZXhhbXBsZTpzb21lbWVkaWF0b3Ijc29tZWtleTIiXX1d" + ), PEER_DID_NUMALGO_2 ) assertEquals(expected, service) } + + @Test + fun testDecodeServiceMultipleEntriesIndividualEncoded() { + val expected = listOf( + OtherService( + mapOf( + "id" to "$PEER_DID_NUMALGO_2#didcommmessaging-0", + "type" to "DIDCommMessaging", + "serviceEndpoint" to "https://example.com/endpoint", + "routingKeys" to listOf("did:example:somemediator#somekey"), + "accept" to listOf("didcomm/v2", "didcomm/aip2;env=rfc587") + ) + ), + OtherService( + mapOf( + "id" to "$PEER_DID_NUMALGO_2#didcommmessaging-1", + "type" to "DIDCommMessaging", + "serviceEndpoint" to "https://example.com/endpoint2", + "routingKeys" to listOf("did:example:somemediator#somekey2") + ) + ) + ) + val service = decodeService( + listOf( + "eyJ0IjoiZG0iLCJzIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS9lbmRwb2ludCIsInIiOlsiZGlkOmV4YW1wbGU6c29tZW1lZGlhdG9yI3NvbWVrZXkiXSwiYSI6WyJkaWRjb21tL3YyIiwiZGlkY29tbS9haXAyO2Vudj1yZmM1ODciXX0", + "eyJ0IjoiZG0iLCJzIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS9lbmRwb2ludDIiLCJyIjpbImRpZDpleGFtcGxlOnNvbWVtZWRpYXRvciNzb21la2V5MiJdfQ" + ), + PEER_DID_NUMALGO_2 + ) + assertEquals(expected, service) + } } diff --git a/gradle.properties b/gradle.properties index d859a10..5b584e8 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,4 @@ +version=1.0.0 #Gradle org.gradle.jvmargs=-Xmx3072M -Dkotlin.daemon.jvm.options\="-Xmx3072M" @@ -11,4 +12,7 @@ android.useAndroidX=true # kotlin.mpp.enableGranularSourceSetsMetadata=true # kotlin.native.enableDependencyPropagation=false kotlin.mpp.enableCInteropCommonization=true -kotlin.native.cacheKind.iosSimulatorArm64=none \ No newline at end of file +kotlin.native.cacheKind.iosSimulatorArm64=none +kotlin.native.cacheKind.iosArm64=none +kotlin.native.cacheKind.iosX64=none +kotlin.mpp.androidSourceSetLayoutVersion=2 \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..ba58a24 --- /dev/null +++ b/package.json @@ -0,0 +1,26 @@ +{ + "name": "atala-prism-didcomm-kmm", + "version": "0.0.1", + "description": "atala-prism-didcomm-kmm", + "directories": { + "example": "examples" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/input-output-hk/atala-prism-didcomm-kmm.git" + }, + "author": "IOG", + "license": "ISC", + "bugs": { + "url": "https://github.com/input-output-hk/atala-prism-didcomm-kmm/issues" + }, + "homepage": "https://github.com/input-output-hk/atala-prism-didcomm-kmm#readme", + "devDependencies": { + "@semantic-release/changelog": "^6.0.2", + "@semantic-release/exec": "^6.0.3", + "@semantic-release/git": "^10.0.1", + "gradle-semantic-release-plugin": "^1.7.4", + "semantic-release": "^19.0.5", + "semantic-release-slack-bot": "^3.5.3" + } +}