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 all 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
4 changes: 1 addition & 3 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 All @@ -22,7 +20,7 @@ dependencies {
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.core:jackson-databind:2.15.2")
implementation("com.github.TBD54566975:web5-kt:0.0.4-beta")
implementation("com.github.TBD54566975:web5-kt:0.0.5-beta")
implementation("decentralized-identity:did-common-java:1.9.0") // would like to grab this via web5 dids

testImplementation(kotlin("test"))
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
7 changes: 3 additions & 4 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,11 +14,12 @@ 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")
implementation("com.github.TBD54566975:web5-kt:0.0.4-beta")
implementation("com.github.TBD54566975:web5-kt:0.0.5-beta")
implementation("com.networknt:json-schema-validator:1.0.87")
implementation("com.nimbusds:nimbus-jose-jwt:9.36")
implementation("decentralized-identity:did-common-java:1.9.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 ?: emptyList()
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
76 changes: 38 additions & 38 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:zQ3shhwZ18aebLvYzCDdkkUH78z6RXec843BQc9hybsMRSoxg",
"id": "offering_01hdh7fyftfkv8002wyr000nj5",
"createdAt": "2023-10-24T16:15:03.662Z",
"updatedAt": "2023-10-24T16:15:03.662Z"
},
"data": {
"description": "A sample offering",
Expand Down Expand Up @@ -85,7 +85,7 @@
"id": "test-pd-id",
"name": "simple PD",
"purpose": "pd for testing",
"inputDescriptors": [
"input_descriptors": [
{
"id": "whatever",
"purpose": "id for testing",
Expand All @@ -102,21 +102,21 @@
]
}
},
"signature": "eyJraWQiOiJkaWQ6a2V5OnpRM3NoWUhFS2hWRnZERHZBRW15Q1RQQjNrUmtIWmREOFFDYnlrQVBwb3BqNW5nNHUjelEzc2hZSEVLaFZGdkREdkFFbXlDVFBCM2tSa0haZEQ4UUNieWtBUHBvcGo1bmc0dSIsImFsZyI6IkVTMjU2SyJ9..52s8dGKKDW7-8_qo4Mp1aAtvT6v6r7yQEJY6P8Xo-etFClntFm0031Wyl8a76mS6Wiq_0Zr84_6lAUBYo-rVNw"
"signature": "eyJraWQiOiJkaWQ6a2V5OnpRM3NoaHdaMThhZWJMdll6Q0Rka2tVSDc4ejZSWGVjODQzQlFjOWh5YnNNUlNveGcjelEzc2hod1oxOGFlYkx2WXpDRGRra1VINzh6NlJYZWM4NDNCUWM5aHlic01SU294ZyIsImFsZyI6IkVTMjU2SyJ9..MyaMT4LZAlkLj4w9LZMqQLsaklhHlsrob60p1XmKMKg249kweyXPGABpEnvKD_65_1s1RjdyKlEotgQT15xAYw"
}
},
"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:zQ3shhwZ18aebLvYzCDdkkUH78z6RXec843BQc9hybsMRSoxg",
"from": "did:key:zQ3shizfQYEiB8dqac96P6SHYtUCCsY7gSci4Qeaebgsfz1VC",
"id": "rfq_7zzzzzzyzte028007g0g001xdc",
"exchangeId": "rfq_7zzzzzzyzte028007g0g001xdc",
"createdAt": "2023-10-24T16:15:04.010Z"
},
"data": {
"offeringId": "offering_7zzzzzzx7yff7r002bsw001f3s",
"offeringId": "offering_01hdh7fyzzek48003ms0001bv2",
"payinSubunits": "1000",
"payinMethod": {
"kind": "BTC_ADDRESS",
Expand All @@ -135,19 +135,19 @@
"presentation submission"
]
},
"signature": "eyJraWQiOiJkaWQ6a2V5OnpRM3NoaXplUzZWRnpUYXN5WEZYY0xnWWFpTE41eUs1UFFlOXYzN1ZZeTl5UXpYUXEjelEzc2hpemVTNlZGelRhc3lYRlhjTGdZYWlMTjV5SzVQUWU5djM3Vll5OXlRelhRcSIsImFsZyI6IkVTMjU2SyJ9.._lWN41pV9Vi9emli0c6ZyYq-D1Jvx6padYxnb9Zneh1aXgCAracsCf_ehemi7OLK5GaV0Kp0JX688DQp1SUe-A"
"signature": "eyJraWQiOiJkaWQ6a2V5OnpRM3NoaXpmUVlFaUI4ZHFhYzk2UDZTSFl0VUNDc1k3Z1NjaTRRZWFlYmdzZnoxVkMjelEzc2hpemZRWUVpQjhkcWFjOTZQNlNIWXRVQ0NzWTdnU2NpNFFlYWViZ3NmejFWQyIsImFsZyI6IkVTMjU2SyJ9..Y9gKs87CGalvHxlChHsL2fx2wtlPbY2-tBDciz7rSKRJkWmeIdyu-7NxwUdVMlQfJ58PTLoYPknXUKL8Hc0v4w"
},
"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:zQ3shizfQYEiB8dqac96P6SHYtUCCsY7gSci4Qeaebgsfz1VC",
"from": "did:key:zQ3shhwZ18aebLvYzCDdkkUH78z6RXec843BQc9hybsMRSoxg",
"id": "quote_7zzzzzzpyrfy2r004fgm0013c7",
"exchangeId": "rfq_7zzzzzzzztfxx8001ff8000ex2",
"createdAt": "2023-10-24T16:15:04.024Z"
},
"data": {
"expiresAt": "2023-10-21T19:28:09.981Z",
"expiresAt": "2023-10-25T16:15:04.024Z",
"payin": {
"currencyCode": "AUD",
"amountSubunits": "1000",
Expand All @@ -169,47 +169,47 @@
}
}
},
"signature": "eyJraWQiOiJkaWQ6a2V5OnpRM3NoWUhFS2hWRnZERHZBRW15Q1RQQjNrUmtIWmREOFFDYnlrQVBwb3BqNW5nNHUjelEzc2hZSEVLaFZGdkREdkFFbXlDVFBCM2tSa0haZEQ4UUNieWtBUHBvcGo1bmc0dSIsImFsZyI6IkVTMjU2SyJ9..gl6vcasltpykqtIavynximjLKq41qPqlbZYmtg0AKu8OfTqOZvdjzmCzjMNMs8D6baZrSEfuyVLRq0medNA7CQ"
"signature": "eyJraWQiOiJkaWQ6a2V5OnpRM3NoaHdaMThhZWJMdll6Q0Rka2tVSDc4ejZSWGVjODQzQlFjOWh5YnNNUlNveGcjelEzc2hod1oxOGFlYkx2WXpDRGRra1VINzh6NlJYZWM4NDNCUWM5aHlic01SU294ZyIsImFsZyI6IkVTMjU2SyJ9..B2n8TL3Tk_Bq0uf8l-1IIj_p44fuLghihElbrF493N1b1TqexdHqkhUuevdh5DKsTi3DgiQyHd8Vijwnz6Ap_A"
},
"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:zQ3shhwZ18aebLvYzCDdkkUH78z6RXec843BQc9hybsMRSoxg",
"from": "did:key:zQ3shizfQYEiB8dqac96P6SHYtUCCsY7gSci4Qeaebgsfz1VC",
"id": "order_01hdh7fpzjeh980014a8000t9d",
"exchangeId": "rfq_7zzzzzzqvhffw8002vz0000mwp",
"createdAt": "2023-10-24T16:15:04.032Z"
},
"data": {},
"signature": "eyJraWQiOiJkaWQ6a2V5OnpRM3NoaXplUzZWRnpUYXN5WEZYY0xnWWFpTE41eUs1UFFlOXYzN1ZZeTl5UXpYUXEjelEzc2hpemVTNlZGelRhc3lYRlhjTGdZYWlMTjV5SzVQUWU5djM3Vll5OXlRelhRcSIsImFsZyI6IkVTMjU2SyJ9..pgQBsE39vG93VjmwHNzRzFc9OiXgOBhKIOorulVtuPhj9k-Ck4-k9naUtCIjR0MuQYeSbwOmtrGGKwJ-4EGjRw"
"signature": "eyJraWQiOiJkaWQ6a2V5OnpRM3NoaXpmUVlFaUI4ZHFhYzk2UDZTSFl0VUNDc1k3Z1NjaTRRZWFlYmdzZnoxVkMjelEzc2hpemZRWUVpQjhkcWFjOTZQNlNIWXRVQ0NzWTdnU2NpNFFlYWViZ3NmejFWQyIsImFsZyI6IkVTMjU2SyJ9..FLzrqCirBzDFix3AuIpv-1FtGSUNq7v6ckUQjzrGc5JLDSggS8P-MdVJ1gW5SVCusZCRhkjk6UX4qQXSFZ4X8w"
},
"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:zQ3shizfQYEiB8dqac96P6SHYtUCCsY7gSci4Qeaebgsfz1VC",
"from": "did:key:zQ3shhwZ18aebLvYzCDdkkUH78z6RXec843BQc9hybsMRSoxg",
"id": "orderstatus_01hdh7fzvffj3r005wgw000ac4",
"exchangeId": "rfq_01hdh7fqvzesf8002pbr001x7t",
"createdAt": "2023-10-24T16:15:04.034Z"
},
"data": {
"orderStatus": "PENDING"
},
"signature": "eyJraWQiOiJkaWQ6a2V5OnpRM3NoWUhFS2hWRnZERHZBRW15Q1RQQjNrUmtIWmREOFFDYnlrQVBwb3BqNW5nNHUjelEzc2hZSEVLaFZGdkREdkFFbXlDVFBCM2tSa0haZEQ4UUNieWtBUHBvcGo1bmc0dSIsImFsZyI6IkVTMjU2SyJ9..3zkNi8q9m7bfLoZhMxl-6FluTX16u86jEiro7O_SQJ0ovS0SmX4YRuR7_n7Zn85xF-IhzpM16jMIJj82fz9Tbw"
"signature": "eyJraWQiOiJkaWQ6a2V5OnpRM3NoaHdaMThhZWJMdll6Q0Rka2tVSDc4ejZSWGVjODQzQlFjOWh5YnNNUlNveGcjelEzc2hod1oxOGFlYkx2WXpDRGRra1VINzh6NlJYZWM4NDNCUWM5aHlic01SU294ZyIsImFsZyI6IkVTMjU2SyJ9..dSZEztUIOWMfb8fLuJSL5A9DblEH7ROszTUztv1b-21dgKEZMCZCAPeju2MEEIObtv7SKvWopenL7IqtP2RpVQ"
},
"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:zQ3shizfQYEiB8dqac96P6SHYtUCCsY7gSci4Qeaebgsfz1VC",
"from": "did:key:zQ3shhwZ18aebLvYzCDdkkUH78z6RXec843BQc9hybsMRSoxg",
"id": "close_7zzzzzzpvqf2480048h0001jm6",
"exchangeId": "rfq_01hdh7fqvpevq8003pxr001a45",
"createdAt": "2023-10-24T16:15:04.037Z"
},
"data": {
"reason": "test reason"
},
"signature": "eyJraWQiOiJkaWQ6a2V5OnpRM3NoWUhFS2hWRnZERHZBRW15Q1RQQjNrUmtIWmREOFFDYnlrQVBwb3BqNW5nNHUjelEzc2hZSEVLaFZGdkREdkFFbXlDVFBCM2tSa0haZEQ4UUNieWtBUHBvcGo1bmc0dSIsImFsZyI6IkVTMjU2SyJ9..zmfbOmR5qEpywemsDFQ4VOqJHtkLYHhFvpexNNVDm880TFik_df24bh8387GSy-U3WeRWEDDYMZ0k0k4KzyViA"
"signature": "eyJraWQiOiJkaWQ6a2V5OnpRM3NoaHdaMThhZWJMdll6Q0Rka2tVSDc4ejZSWGVjODQzQlFjOWh5YnNNUlNveGcjelEzc2hod1oxOGFlYkx2WXpDRGRra1VINzh6NlJYZWM4NDNCUWM5aHlic01SU294ZyIsImFsZyI6IkVTMjU2SyJ9..TDtaxXdl1Bljuft8bZlvxTXTK472fKOia12kG_mQA7UhGTVIfwO9cuDCS_86EZHPMhkAvYdOnIiUodouZVba_A"
}
}
}
Loading