Skip to content

Commit

Permalink
bumping web5-kt version to 0.16.0 (#213)
Browse files Browse the repository at this point in the history
* bumping web5-kt version to 0.15.0 and fixing compile errors. still wip, need to refactor CryptoUtils

* using Jws.sign in place of CryptoUtils.sign

* wrote a method to create decodedjws from detached sig and detached payload, simplifying cryptoutils.verify. tests pass

* making signature nullable again

* updating build.gradle.kts because danubetech is down. bumping web5-kt again

* moving typeid dependency to implementation deps and not api deps

* adding links to docs


Co-authored-by: Phoebe Lew <plew@tbd.email>
  • Loading branch information
jiyoonie9 and Phoebe Lew authored Mar 29, 2024
1 parent 40ec252 commit bd505a5
Show file tree
Hide file tree
Showing 15 changed files with 119 additions and 247 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,8 @@ git submodule update --init

# Other Docs

* [API Reference Guide](https://tbd54566975.github.io/tbdex-kt/)
* [Developer Docs](https://developer.tbd.website/docs/tbdex/)
* [Guidelines](./CONVENTIONS.md)
* [Code of Conduct](./CODE_OF_CONDUCT.md)
* [Governance](./GOVERNANCE.md)
9 changes: 9 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ plugins {

repositories {
mavenCentral()
// block's cache artifactory for tbd's oss third party dependencies
// that do not live in maven central
maven {
name = "tbd-oss-thirdparty"
url = uri("https://blockxyz.jfrog.io/artifactory/tbd-oss-thirdparty-maven2/")
mavenContent {
releasesOnly()
}
}
}

dependencies {
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ com_networknt = "1.0.87"
com_squareup_okhttp = "4.12.0"
de_fxlae = "0.2.0"
io_ktor = "2.3.7"
xyz_block_web5 = "0.14.0"
xyz_block_web5 = "0.16.0"

[libraries]
comFasterXmlJacksonModuleKotlin = { module = "com.fasterxml.jackson.module:jackson-module-kotlin", version.ref = "com_fasterxml_jackson" }
Expand Down
24 changes: 5 additions & 19 deletions httpclient/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,15 @@ plugins {

repositories {
mavenCentral()
// temp maven repo for danubetech
// block's cache artifactory for tbd's oss third party dependencies
// that do not live in maven central
maven {
name = "tbd-danubetech-temp"
url = uri("https://blockxyz.jfrog.io/artifactory/danubetech-temp/")
name = "tbd-oss-thirdparty"
url = uri("https://blockxyz.jfrog.io/artifactory/tbd-oss-thirdparty-maven2/")
mavenContent {
releasesOnly()
}
}
maven {
url = uri("https://repo.danubetech.com/repository/maven-public")
}
maven {
url = uri("https://jitpack.io")
}
maven {
url = uri("https://repository.jboss.org/nexus/content/repositories/thirdparty-releases/")
}
}

val jackson_version = "2.14.2"
Expand All @@ -41,17 +33,11 @@ dependencies {
// API
api(libs.xyzBlockWeb5)

/*
* API Leak: https://github.com/TBD54566975/tbdex-kt/issues/161
*
* Change and move to "implementation" when completed
*/
api(libs.deFxlaeTypeId)

// Project
implementation(project(":protocol"))

// Implementation
implementation(libs.deFxlaeTypeId)
implementation(libs.comSquareupOkhttpOkhttp)
implementation(libs.comFasterXmlJacksonModuleKotlin)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import com.nimbusds.jose.util.Base64URL
import com.nimbusds.jwt.JWTClaimsSet
import com.nimbusds.jwt.SignedJWT
import web5.sdk.common.Convert
import web5.sdk.dids.Did
import web5.sdk.dids.DidResolvers
import web5.sdk.dids.did.BearerDid
import web5.sdk.dids.didcore.VerificationMethod
import java.time.Instant
import java.util.Date
Expand Down Expand Up @@ -36,7 +36,7 @@ object RequestToken {
* @return signed request token to be included as Authorization header for sending to PFI endpoints
*
*/
fun generate(did: Did, pfiDid: String, assertionMethodId: String? = null): String {
fun generate(did: BearerDid, pfiDid: String, assertionMethodId: String? = null): String {

val didResolutionResult = DidResolvers.resolve(did.uri)
val assertionMethod: VerificationMethod =
Expand All @@ -50,7 +50,7 @@ object RequestToken {
val keyAlias = did.keyManager.getDeterministicAlias(publicKeyJwk)

// TODO: figure out how to make more reliable since algorithm is technically not a required property of a JWK
val algorithm = publicKeyJwk.algorithm
val algorithm = publicKeyJwk.alg
val jwsAlgorithm = JWSAlgorithm.parse(algorithm.toString())

val kid = when (assertionMethod.id.startsWith("#")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import tbdex.sdk.protocol.models.Order
import tbdex.sdk.protocol.models.Rfq
import tbdex.sdk.protocol.serialization.Json
import tbdex.sdk.protocol.serialization.Json.jsonMapper
import web5.sdk.dids.Did
import web5.sdk.dids.did.BearerDid

/**
* A client of the tbDEX HTTP interface for communicating with a PFI.
Expand Down Expand Up @@ -174,7 +174,7 @@ object TbdexHttpClient {
.put(requestBody)
.build()

println("Attempting to send message to exchange ${exchangeId} to: ${request.url}")
println("Attempting to send message to exchange $exchangeId to: ${request.url}")

executeRequest(request)
}
Expand All @@ -188,7 +188,7 @@ object TbdexHttpClient {
* @return An [Exchange] containing the requested exchange.
* @throws TbdexResponseException for request or response errors.
*/
fun getExchange(pfiDid: String, requesterDid: Did, exchangeId: String): Exchange {
fun getExchange(pfiDid: String, requesterDid: BearerDid, exchangeId: String): Exchange {
val pfiServiceEndpoint = getPfiServiceEndpoint(pfiDid)
val baseUrl = "$pfiServiceEndpoint/exchanges/$exchangeId"
val requestToken = RequestToken.generate(requesterDid, pfiDid)
Expand Down Expand Up @@ -226,7 +226,7 @@ object TbdexHttpClient {
* @return A list of matching [Exchange].
* @throws TbdexResponseException for request or response errors.
*/
fun getExchanges(pfiDid: String, requesterDid: Did, filter: GetExchangesFilter? = null): List<Exchange> {
fun getExchanges(pfiDid: String, requesterDid: BearerDid, filter: GetExchangesFilter? = null): List<Exchange> {
val pfiServiceEndpoint = getPfiServiceEndpoint(pfiDid)
val baseUrl = "$pfiServiceEndpoint/exchanges/"
val requestToken = RequestToken.generate(requesterDid, pfiDid)
Expand Down
21 changes: 9 additions & 12 deletions httpclient/src/test/kotlin/tbdex/sdk/httpclient/E2ETest.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package tbdex.sdk.httpclient

import com.nimbusds.jose.jwk.JWK
import org.junit.jupiter.api.Disabled
import tbdex.sdk.httpclient.models.GetExchangesFilter
import tbdex.sdk.httpclient.models.GetOfferingsFilter
Expand All @@ -14,7 +13,9 @@ import tbdex.sdk.protocol.models.RfqData
import tbdex.sdk.protocol.models.SelectedPaymentMethod
import web5.sdk.credentials.VerifiableCredential
import web5.sdk.crypto.InMemoryKeyManager
import web5.sdk.dids.Did
import web5.sdk.crypto.JwaCurve
import web5.sdk.crypto.jwk.Jwk
import web5.sdk.dids.did.BearerDid
import web5.sdk.dids.didcore.Purpose
import web5.sdk.dids.didcore.Service
import web5.sdk.dids.methods.dht.CreateDidDhtOptions
Expand All @@ -41,13 +42,9 @@ class E2ETest {
CreateDidDhtOptions(
verificationMethods = listOf(
Triple(
JWK.parse(
"""{
"crv": "Ed25519",
"kty": "OKP",
"x": "i6cnsuH4JTBMXKbseg28Hi3w4Xp13E85UwnSW3ZgYk8"
}"""
),
Jwk.Builder("OKP", JwaCurve.Ed25519.name)
.x("i6cnsuH4JTBMXKbseg28Hi3w4Xp13E85UwnSW3ZgYk8")
.build(),
listOf(Purpose.Authentication),
UUID.randomUUID().toString()
)
Expand Down Expand Up @@ -153,7 +150,7 @@ class E2ETest {
private fun getExchangeWithOrderStatus(
client: TbdexHttpClient,
pfiDid: String,
myDid: DidKey,
myDid: BearerDid,
rfq: Rfq,
): List<Message> {
var attempt = 0
Expand Down Expand Up @@ -206,7 +203,7 @@ class E2ETest {
private fun getCurrentExchange(
client: TbdexHttpClient,
pfiDid: String,
myDid: Did,
myDid: BearerDid,
rfq: Rfq
): List<Message> {
var listOfExchanges: List<List<Message>>
Expand Down Expand Up @@ -274,7 +271,7 @@ class E2ETest {
claims = listOf(vcJwt)
)

private fun buildVC(myDid: DidKey) = VerifiableCredential.create(
private fun buildVC(myDid: BearerDid) = VerifiableCredential.create(
type = "SanctionCredential",
issuer = myDid.uri,
subject = myDid.uri,
Expand Down
6 changes: 3 additions & 3 deletions httpclient/src/test/kotlin/tbdex/sdk/httpclient/TestData.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import web5.sdk.credentials.model.FieldV2
import web5.sdk.credentials.model.InputDescriptorV2
import web5.sdk.credentials.model.PresentationDefinitionV2
import web5.sdk.crypto.InMemoryKeyManager
import web5.sdk.dids.Did
import web5.sdk.dids.did.BearerDid
import web5.sdk.dids.methods.key.DidKey
import java.net.URI
import java.time.OffsetDateTime
Expand All @@ -30,8 +30,8 @@ import java.util.UUID
object TestData {
private val aliceKeyManager = InMemoryKeyManager()
private val pfiKeyManager = InMemoryKeyManager()
val ALICE_DID: Did = DidKey.create(aliceKeyManager)
val PFI_DID: Did = DidKey.create(pfiKeyManager)
val ALICE_DID: BearerDid = DidKey.create(aliceKeyManager)
val PFI_DID: BearerDid = DidKey.create(pfiKeyManager)

fun getPresentationDefinition(): PresentationDefinitionV2 {
return buildPresentationDefinition(
Expand Down
17 changes: 4 additions & 13 deletions httpserver/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,16 @@ plugins {

repositories {
mavenCentral()
// temp maven repo for danubetech
// block's cache artifactory for tbd's oss third party dependencies
// that do not live in maven central
maven {
name = "tbd-danubetech-temp"
url = uri("https://blockxyz.jfrog.io/artifactory/danubetech-temp/")
name = "tbd-oss-thirdparty"
url = uri("https://blockxyz.jfrog.io/artifactory/tbd-oss-thirdparty-maven2/")
mavenContent {
releasesOnly()
}
}
maven {
url = uri("https://repo.danubetech.com/repository/maven-public")
}
maven {
url = uri("https://jitpack.io")
}
maven {
url = uri("https://repository.jboss.org/nexus/content/repositories/thirdparty-releases/")
}
}

application {
mainClass.set("tbdex.sdk.httpserver.TbdexHttpServerKt")
}
Expand Down
24 changes: 6 additions & 18 deletions protocol/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,15 @@ plugins {

repositories {
mavenCentral()
// temp maven repo for danubetech
// block's cache artifactory for tbd's oss third party dependencies
// that do not live in maven central
maven {
name = "tbd-danubetech-temp"
url = uri("https://blockxyz.jfrog.io/artifactory/danubetech-temp/")
name = "tbd-oss-thirdparty"
url = uri("https://blockxyz.jfrog.io/artifactory/tbd-oss-thirdparty-maven2/")
mavenContent {
releasesOnly()
}
}
maven {
url = uri("https://repo.danubetech.com/repository/maven-public")
}
maven {
url = uri("https://jitpack.io")
}
maven {
url = uri("https://repository.jboss.org/nexus/content/repositories/thirdparty-releases/")
}
}

dependencies {
Expand All @@ -38,16 +30,12 @@ dependencies {

// API
api(libs.xyzBlockWeb5)
/*
* API Leak: https://github.com/TBD54566975/tbdex-kt/issues/161
*
* Change and move to "implementation" when completed
*/
api(libs.deFxlaeTypeId)


// Project

// Implementation
implementation(libs.deFxlaeTypeId)
implementation(libs.comFasterXmlJacksonModuleKotlin)
implementation(libs.comFasterXmlJacksonDatatypeJsr310)
implementation(libs.comNetworkntJsonSchemaValidator)
Expand Down
Loading

0 comments on commit bd505a5

Please sign in to comment.