Skip to content
This repository has been archived by the owner on Dec 12, 2024. It is now read-only.

Publish prep #64

Merged
merged 10 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,16 @@ subprojects {
config.setFrom("$rootDir/config/detekt.yml")
}

kotlin {
jvmToolchain(17)
}

java {
withJavadocJar()
withSourcesJar()

sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

publishing {
Expand Down
2 changes: 0 additions & 2 deletions httpclient/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ plugins {
id("java-library")
}

version = "1.0"

repositories {
mavenCentral()
maven {
Expand Down
1 change: 0 additions & 1 deletion httpserver/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ plugins {
id("idea")
}

version = "1.0"
var ktorVersion = "2.3.4"

repositories {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package tbdex.server.tbdex.sdk.http_server
package tbdex.sdk.httpserver

import io.ktor.http.HttpStatusCode
import io.ktor.server.application.Application
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import io.ktor.server.application.Application
import io.ktor.server.testing.handleRequest
import io.ktor.server.testing.withTestApplication
import org.junit.jupiter.api.Test
import tbdex.server.tbdex.sdk.http_server.module
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add UnusedImports to our detekt config? @phoebe-lew any thoughts?

style:
  UnusedImports:
    active: false

import kotlin.test.assertEquals

class ServerTest {
Expand Down
2 changes: 2 additions & 0 deletions jitpack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
jdk:
- openjdk17
5 changes: 2 additions & 3 deletions protocol/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ plugins {
id("java-library")
}

version = "1.0"

repositories {
mavenCentral()
maven {
Expand All @@ -16,7 +14,8 @@ repositories {
}

dependencies {
implementation("me.lessis:typeid:0.0.2")
api("me.lessis:typeid:0.0.2")

implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.14.2")
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.9.8")
implementation("com.fasterxml.jackson.datatype:jackson-datatype-json-org:2.11.0")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ object CryptoUtils {
// or just `#fragment`. See: https://www.w3.org/TR/did-core/#relative-did-urls.
// Using a set for fast string comparison. DIDs can be long.
val verificationMethodIds = setOf(parsedDidUrl.didUrlString, "#${parsedDidUrl.fragment}")
val assertionMethods = didResolutionResult.didDocument.assertionMethodVerificationMethodsDereferenced
val assertionMethods = didResolutionResult.didDocument.assertionMethodVerificationMethodsDereferenced ?: listOf()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could also do emptyList() :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oo good call!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done 802f4ce thanks @jiyoontbd !

var assertionMethod: VerificationMethod? = null

for (method in assertionMethods) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import tbdex.sdk.protocol.serialization.Json.jsonMapper
import tbdex.sdk.protocol.serialization.dateTimeFormat
import typeid.TypeID
import web5.sdk.dids.Did
import java.security.MessageDigest
import java.time.OffsetDateTime

/**
Expand Down Expand Up @@ -75,7 +76,8 @@ sealed class Message {
val payload = mapOf("metadata" to this.metadata, "data" to this.data)
val canonicalJsonSerializedPayload = JsonCanonicalizer(Json.stringify(payload))

return canonicalJsonSerializedPayload.encodedUTF8
val sha256 = MessageDigest.getInstance("SHA-256")
return sha256.digest(canonicalJsonSerializedPayload.encodedUTF8)
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import tbdex.sdk.protocol.serialization.Json.jsonMapper
import tbdex.sdk.protocol.serialization.dateTimeFormat
import typeid.TypeID
import web5.sdk.dids.Did
import java.security.MessageDigest
import java.time.OffsetDateTime

/**
Expand Down Expand Up @@ -73,7 +74,8 @@ sealed class Resource {
val payload = mapOf("metadata" to this.metadata, "data" to this.data)
val canonicalJsonSerializedPayload = JsonCanonicalizer(Json.stringify(payload))

return canonicalJsonSerializedPayload.encodedUTF8
val sha256 = MessageDigest.getInstance("SHA-256")
return sha256.digest(canonicalJsonSerializedPayload.encodedUTF8)
}

/**
Expand Down
74 changes: 37 additions & 37 deletions protocol/src/test/resources/testVectors.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
"offering": {
"metadata": {
"kind": "offering",
"from": "did:key:zQ3shYHEKhVFvDDvAEmyCTPB3kRkHZdD8QCbykAPpopj5ng4u",
"id": "offering_7zzzzzzwzyf678004shr000zqf",
"createdAt": "2023-10-20T19:28:09.594Z",
"updatedAt": "2023-10-20T19:28:09.594Z"
"from": "did:key:zQ3shwAYN63R4UHiKsVg3f3vG4RafNxAD4kpBR2Px8JT7dDj1",
"id": "offering_01hdgc6qfze80r000204001fpx",
"createdAt": "2023-10-24T08:18:18.214Z",
"updatedAt": "2023-10-24T08:18:18.214Z"
},
"data": {
"description": "A sample offering",
Expand Down Expand Up @@ -102,21 +102,21 @@
]
}
},
"signature": "eyJraWQiOiJkaWQ6a2V5OnpRM3NoWUhFS2hWRnZERHZBRW15Q1RQQjNrUmtIWmREOFFDYnlrQVBwb3BqNW5nNHUjelEzc2hZSEVLaFZGdkREdkFFbXlDVFBCM2tSa0haZEQ4UUNieWtBUHBvcGo1bmc0dSIsImFsZyI6IkVTMjU2SyJ9..52s8dGKKDW7-8_qo4Mp1aAtvT6v6r7yQEJY6P8Xo-etFClntFm0031Wyl8a76mS6Wiq_0Zr84_6lAUBYo-rVNw"
"signature": "eyJraWQiOiJkaWQ6a2V5OnpRM3Nod0FZTjYzUjRVSGlLc1ZnM2Yzdkc0UmFmTnhBRDRrcEJSMlB4OEpUN2REajEjelEzc2h3QVlONjNSNFVIaUtzVmczZjN2RzRSYWZOeEFENGtwQlIyUHg4SlQ3ZERqMSIsImFsZyI6IkVTMjU2SyJ9..d7JYMtV6UihYpPlbdIg5Lx6Of2ZA9kVgoUhpUckR6Xg9cg5kU7kxxO3HPkMos0cFlBV3x45Iv0YhErgFujVw5A"
}
},
"messages": {
"rfq": {
"metadata": {
"kind": "rfq",
"to": "did:key:zQ3shYHEKhVFvDDvAEmyCTPB3kRkHZdD8QCbykAPpopj5ng4u",
"from": "did:key:zQ3shizeS6VFzTasyXFXcLgYaiLN5yK5PQe9v37VYy9yQzXQq",
"id": "rfq_7zzzzzzzqke7nr003hxc001mey",
"exchangeId": "rfq_7zzzzzzzqke7nr003hxc001mey",
"createdAt": "2023-10-20T19:28:09.969Z"
"to": "did:key:zQ3shwAYN63R4UHiKsVg3f3vG4RafNxAD4kpBR2Px8JT7dDj1",
"from": "did:key:zQ3shujqALzHHaiBqC8Fyq9pYudE774t3ub7zc9HtA3GZ8x5S",
"id": "rfq_7zzzzzzzzff0er00683m0006gn",
"exchangeId": "rfq_7zzzzzzzzff0er00683m0006gn",
"createdAt": "2023-10-24T08:18:18.570Z"
},
"data": {
"offeringId": "offering_7zzzzzzx7yff7r002bsw001f3s",
"offeringId": "offering_7zzzzzzzyxfny8000xfg0001v7",
"payinSubunits": "1000",
"payinMethod": {
"kind": "BTC_ADDRESS",
Expand All @@ -135,19 +135,19 @@
"presentation submission"
]
},
"signature": "eyJraWQiOiJkaWQ6a2V5OnpRM3NoaXplUzZWRnpUYXN5WEZYY0xnWWFpTE41eUs1UFFlOXYzN1ZZeTl5UXpYUXEjelEzc2hpemVTNlZGelRhc3lYRlhjTGdZYWlMTjV5SzVQUWU5djM3Vll5OXlRelhRcSIsImFsZyI6IkVTMjU2SyJ9.._lWN41pV9Vi9emli0c6ZyYq-D1Jvx6padYxnb9Zneh1aXgCAracsCf_ehemi7OLK5GaV0Kp0JX688DQp1SUe-A"
"signature": "eyJraWQiOiJkaWQ6a2V5OnpRM3NodWpxQUx6SEhhaUJxQzhGeXE5cFl1ZEU3NzR0M3ViN3pjOUh0QTNHWjh4NVMjelEzc2h1anFBTHpISGFpQnFDOEZ5cTlwWXVkRTc3NHQzdWI3emM5SHRBM0daOHg1UyIsImFsZyI6IkVTMjU2SyJ9..GMY9UE62e3_U5aE7ZXmW2kTvurR2HY4SePLK4hAkCsIIZ1PSOfOJzGg1qrriJ-XpccXkDjaEJXtVTd70aqdOsQ"
},
"quote": {
"metadata": {
"kind": "quote",
"to": "did:key:zQ3shizeS6VFzTasyXFXcLgYaiLN5yK5PQe9v37VYy9yQzXQq",
"from": "did:key:zQ3shYHEKhVFvDDvAEmyCTPB3kRkHZdD8QCbykAPpopj5ng4u",
"id": "quote_7zzzzzzz7zfj1r006cgc000c6d",
"exchangeId": "rfq_7zzzzzzd7zfwzr006f7w000tbk",
"createdAt": "2023-10-20T19:28:09.981Z"
"to": "did:key:zQ3shujqALzHHaiBqC8Fyq9pYudE774t3ub7zc9HtA3GZ8x5S",
"from": "did:key:zQ3shwAYN63R4UHiKsVg3f3vG4RafNxAD4kpBR2Px8JT7dDj1",
"id": "quote_01hdgc6zyzfwrr002f640018ha",
"exchangeId": "rfq_7zzzzzzqvqe81r00620c001m5x",
"createdAt": "2023-10-24T08:18:18.584Z"
},
"data": {
"expiresAt": "2023-10-21T19:28:09.981Z",
"expiresAt": "2023-10-25T08:18:18.583Z",
"payin": {
"currencyCode": "AUD",
"amountSubunits": "1000",
Expand All @@ -169,47 +169,47 @@
}
}
},
"signature": "eyJraWQiOiJkaWQ6a2V5OnpRM3NoWUhFS2hWRnZERHZBRW15Q1RQQjNrUmtIWmREOFFDYnlrQVBwb3BqNW5nNHUjelEzc2hZSEVLaFZGdkREdkFFbXlDVFBCM2tSa0haZEQ4UUNieWtBUHBvcGo1bmc0dSIsImFsZyI6IkVTMjU2SyJ9..gl6vcasltpykqtIavynximjLKq41qPqlbZYmtg0AKu8OfTqOZvdjzmCzjMNMs8D6baZrSEfuyVLRq0medNA7CQ"
"signature": "eyJraWQiOiJkaWQ6a2V5OnpRM3Nod0FZTjYzUjRVSGlLc1ZnM2Yzdkc0UmFmTnhBRDRrcEJSMlB4OEpUN2REajEjelEzc2h3QVlONjNSNFVIaUtzVmczZjN2RzRSYWZOeEFENGtwQlIyUHg4SlQ3ZERqMSIsImFsZyI6IkVTMjU2SyJ9..SPblIoetEci1Yo_BxCn_94nwaHoWNrNlb2Nh25w_zmATcZhDgQQsNS5aZhBLqvcr_ntVR-3od1LA87Z__Scwrw"
},
"order": {
"metadata": {
"kind": "order",
"to": "did:key:zQ3shYHEKhVFvDDvAEmyCTPB3kRkHZdD8QCbykAPpopj5ng4u",
"from": "did:key:zQ3shizeS6VFzTasyXFXcLgYaiLN5yK5PQe9v37VYy9yQzXQq",
"id": "order_7zzzzzzf9pf478000s1r00130t",
"exchangeId": "rfq_01hd78yxvcf71r0029rc001xcz",
"createdAt": "2023-10-20T19:28:09.988Z"
"to": "did:key:zQ3shwAYN63R4UHiKsVg3f3vG4RafNxAD4kpBR2Px8JT7dDj1",
"from": "did:key:zQ3shujqALzHHaiBqC8Fyq9pYudE774t3ub7zc9HtA3GZ8x5S",
"id": "order_01hdgc6zzrfa7r002ahw001rn2",
"exchangeId": "rfq_7zzzzzzzv8ed88007ka0000vft",
"createdAt": "2023-10-24T08:18:18.592Z"
},
"data": {},
"signature": "eyJraWQiOiJkaWQ6a2V5OnpRM3NoaXplUzZWRnpUYXN5WEZYY0xnWWFpTE41eUs1UFFlOXYzN1ZZeTl5UXpYUXEjelEzc2hpemVTNlZGelRhc3lYRlhjTGdZYWlMTjV5SzVQUWU5djM3Vll5OXlRelhRcSIsImFsZyI6IkVTMjU2SyJ9..pgQBsE39vG93VjmwHNzRzFc9OiXgOBhKIOorulVtuPhj9k-Ck4-k9naUtCIjR0MuQYeSbwOmtrGGKwJ-4EGjRw"
"signature": "eyJraWQiOiJkaWQ6a2V5OnpRM3NodWpxQUx6SEhhaUJxQzhGeXE5cFl1ZEU3NzR0M3ViN3pjOUh0QTNHWjh4NVMjelEzc2h1anFBTHpISGFpQnFDOEZ5cTlwWXVkRTc3NHQzdWI3emM5SHRBM0daOHg1UyIsImFsZyI6IkVTMjU2SyJ9..PfMKeGcBqCoEMUZSein153a1_nxP7vIhpQAz95LhnzpsCstvtGGJeCYcUEFeSfyXR_pELtpzttSg4ySnu07QCQ"
},
"orderStatus": {
"metadata": {
"kind": "orderstatus",
"to": "did:key:zQ3shizeS6VFzTasyXFXcLgYaiLN5yK5PQe9v37VYy9yQzXQq",
"from": "did:key:zQ3shYHEKhVFvDDvAEmyCTPB3kRkHZdD8QCbykAPpopj5ng4u",
"id": "orderstatus_01hd78yz9ffv28003yrg001kwm",
"exchangeId": "rfq_7zzzzzzzfqe6zr002hqw00001x",
"createdAt": "2023-10-20T19:28:09.991Z"
"to": "did:key:zQ3shujqALzHHaiBqC8Fyq9pYudE774t3ub7zc9HtA3GZ8x5S",
"from": "did:key:zQ3shwAYN63R4UHiKsVg3f3vG4RafNxAD4kpBR2Px8JT7dDj1",
"id": "orderstatus_7zzzzzzzv2fs0r007y84000d1z",
"exchangeId": "rfq_01hdgc6zv7ff3r001brw000jpn",
"createdAt": "2023-10-24T08:18:18.594Z"
},
"data": {
"orderStatus": "PENDING"
},
"signature": "eyJraWQiOiJkaWQ6a2V5OnpRM3NoWUhFS2hWRnZERHZBRW15Q1RQQjNrUmtIWmREOFFDYnlrQVBwb3BqNW5nNHUjelEzc2hZSEVLaFZGdkREdkFFbXlDVFBCM2tSa0haZEQ4UUNieWtBUHBvcGo1bmc0dSIsImFsZyI6IkVTMjU2SyJ9..3zkNi8q9m7bfLoZhMxl-6FluTX16u86jEiro7O_SQJ0ovS0SmX4YRuR7_n7Zn85xF-IhzpM16jMIJj82fz9Tbw"
"signature": "eyJraWQiOiJkaWQ6a2V5OnpRM3Nod0FZTjYzUjRVSGlLc1ZnM2Yzdkc0UmFmTnhBRDRrcEJSMlB4OEpUN2REajEjelEzc2h3QVlONjNSNFVIaUtzVmczZjN2RzRSYWZOeEFENGtwQlIyUHg4SlQ3ZERqMSIsImFsZyI6IkVTMjU2SyJ9..nkYrhJLM6SthFYTQIksv9Xa1El5g9YG0aKsz75uBU8g9iBpfhKu4iQVBNT2nkUE0CilbjkKnYW5QPB-12RHhEA"
},
"close": {
"metadata": {
"kind": "close",
"to": "did:key:zQ3shizeS6VFzTasyXFXcLgYaiLN5yK5PQe9v37VYy9yQzXQq",
"from": "did:key:zQ3shYHEKhVFvDDvAEmyCTPB3kRkHZdD8QCbykAPpopj5ng4u",
"id": "close_01hd78yfsfe2hr0050mc000034",
"exchangeId": "rfq_7zzzzzzfwzf1yr0078fm0012xm",
"createdAt": "2023-10-20T19:28:09.994Z"
"to": "did:key:zQ3shujqALzHHaiBqC8Fyq9pYudE774t3ub7zc9HtA3GZ8x5S",
"from": "did:key:zQ3shwAYN63R4UHiKsVg3f3vG4RafNxAD4kpBR2Px8JT7dDj1",
"id": "close_01hdgc6zvzf908006t800009v7",
"exchangeId": "rfq_7zzzzzzqvfe1xr007gfc001xkn",
"createdAt": "2023-10-24T08:18:18.597Z"
},
"data": {
"reason": "test reason"
},
"signature": "eyJraWQiOiJkaWQ6a2V5OnpRM3NoWUhFS2hWRnZERHZBRW15Q1RQQjNrUmtIWmREOFFDYnlrQVBwb3BqNW5nNHUjelEzc2hZSEVLaFZGdkREdkFFbXlDVFBCM2tSa0haZEQ4UUNieWtBUHBvcGo1bmc0dSIsImFsZyI6IkVTMjU2SyJ9..zmfbOmR5qEpywemsDFQ4VOqJHtkLYHhFvpexNNVDm880TFik_df24bh8387GSy-U3WeRWEDDYMZ0k0k4KzyViA"
"signature": "eyJraWQiOiJkaWQ6a2V5OnpRM3Nod0FZTjYzUjRVSGlLc1ZnM2Yzdkc0UmFmTnhBRDRrcEJSMlB4OEpUN2REajEjelEzc2h3QVlONjNSNFVIaUtzVmczZjN2RzRSYWZOeEFENGtwQlIyUHg4SlQ3ZERqMSIsImFsZyI6IkVTMjU2SyJ9..5lzums4vWjb44UxkcNw2aQPkL9RIT2cN4nNnhhBFLyIHywVGVcbPkWNh3kEKf4DQxwa0oi3zfChggQHCMTkbUg"
}
}
}
Loading