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

Remove web5 shim #115

Merged
merged 4 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ license-file = "LICENSE"
serde = { version = "1.0.193", features = ["derive", "rc"] }
serde_json = "1.0.108"
thiserror = "1.0.50"
web5 = { git = "https://github.com/TBD54566975/web5-rs", rev = "76adcba82bc2547f09cb70435b5528b7b64090bd" }
web5 = { git = "https://github.com/TBD54566975/web5-rs", rev = "f28d90cb8978305bc25279439fa463aa21ee77ea" }
web5_uniffi_wrapper = { git = "https://github.com/TBD54566975/web5-rs", rev = "f28d90cb8978305bc25279439fa463aa21ee77ea" }
2 changes: 1 addition & 1 deletion bindings/tbdex_uniffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ tbdex = { path = "../../crates/tbdex" }
thiserror = { workspace = true }
uniffi = { version = "0.27.1", features = ["cli"] }
web5 = { workspace = true }
web5_uniffi_wrapper = { git = "https://github.com/TBD54566975/web5-rs", rev = "76adcba82bc2547f09cb70435b5528b7b64090bd" }
web5_uniffi_wrapper = { workspace = true }

[build-dependencies]
uniffi = { version = "0.27.1", features = ["build"] }
Expand Down
10 changes: 3 additions & 7 deletions bindings/tbdex_uniffi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,13 @@ use web5::{
verification_method::VerificationMethod as VerificationMethodData,
},
did::Did as DidData,
portable_did::PortableDid as PortableDidData,
},
};
use web5_uniffi_wrapper::{
credentials::presentation_definition::PresentationDefinition,
crypto::{dsa::Signer, in_memory_key_manager::InMemoryKeyManager, key_manager::KeyManager},
dids::{
bearer_did::{BearerDid, BearerDidData},
portable_did::PortableDid,
},
errors::RustCoreError as Web5RustCoreError,
crypto::{dsa::Signer, key_manager::KeyManager},
dids::bearer_did::BearerDid,
errors::Web5Error,
};

uniffi::include_scaffolding!("tbdex");
58 changes: 15 additions & 43 deletions bindings/tbdex_uniffi/src/tbdex.udl
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,10 @@ dictionary GetExchangeIdsQueryParamsData {




[Error]
interface Web5Error {
Error(string variant, string msg);
};

dictionary JwkData {
string? alg;
Expand Down Expand Up @@ -509,70 +512,39 @@ dictionary ServiceData {
sequence<string> service_endpoint;
};

[Error]
interface Web5RustCoreError {
Error(string type, string variant, string msg);
};

[Trait, WithForeign]
interface Signer {
[Throws=Web5RustCoreError]
[Throws=Web5Error]
bytes sign(bytes payload);
};

[Trait, WithForeign]
interface KeyManager {
[Throws=Web5RustCoreError]
Signer get_signer(JwkData public_jwk);
};

interface InMemoryKeyManager {
constructor();
[Throws=Web5RustCoreError]
[Throws=Web5Error]
JwkData import_private_jwk(JwkData private_jwk);
[Throws=Web5Error]
Signer get_signer(JwkData public_jwk);
[Throws=Web5RustCoreError]
JwkData import_private_jwk(JwkData private_key);
KeyManager get_as_key_manager();
};

dictionary PortableDidData {
string did_uri;
DocumentData document;
sequence<JwkData> private_jwks;
interface BearerDid {
constructor(DidData did, DocumentData document, KeyManager key_manager);
[Throws=Web5Error]
Signer get_signer(string verification_method_id);
};

interface PortableDid {
[Throws=Web5RustCoreError]
constructor([ByRef] string json);
PortableDidData get_data();
};

dictionary BearerDidData {
DidData did;
DocumentData document;
KeyManager key_manager;
};

interface BearerDid {
[Throws=Web5RustCoreError]
constructor([ByRef] string uri, KeyManager key_manager);
[Throws=Web5RustCoreError, Name=from_portable_did]
constructor(PortableDid portable_did);
BearerDidData get_data();
[Throws=Web5RustCoreError]
Signer get_signer(string key_id);
};






interface PresentationDefinition {
[Throws=Web5RustCoreError]
[Throws=Web5Error]
constructor(string json_serialized_presentation_definition);
[Throws=Web5RustCoreError]
[Throws=Web5Error]
string get_json_serialized_presentation_definition();
[Throws=Web5RustCoreError]
[Throws=Web5Error]
sequence<string> select_credentials([ByRef] sequence<string> vc_jwts);
};
10 changes: 10 additions & 0 deletions bound/kt/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
<version.com.fasterxml.jackson>2.17.0</version.com.fasterxml.jackson>
<version.net.java.dev.jna>5.12.0</version.net.java.dev.jna>
<version.org.jetbrains.kotlinx.kotlinx.coroutines.core>1.8.1</version.org.jetbrains.kotlinx.kotlinx.coroutines.core>
<version.xyz.block.web5>commit-f28d90c-SNAPSHOT</version.xyz.block.web5>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is currently using a snapshot build, but that's because we don't have an official web5-kt release yet -- will follow up with the official release once its available


<!-- Versioning for Test Dependencies -->
<version.org.junit.jupiter>5.10.1</version.org.junit.jupiter>
Expand Down Expand Up @@ -188,6 +189,11 @@
<artifactId>kotlinx-coroutines-core</artifactId>
<version>${version.org.jetbrains.kotlinx.kotlinx.coroutines.core}</version>
</dependency>
<dependency>
<groupId>xyz.block</groupId>
<artifactId>web5</artifactId>
<version>${version.xyz.block.web5}</version>
</dependency>

<!-- Test Dependency Management -->
<dependency>
Expand Down Expand Up @@ -231,6 +237,10 @@
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
</dependency>
<dependency>
<groupId>xyz.block</groupId>
<artifactId>web5</artifactId>
</dependency>

<!-- Test Dependencies -->
<dependency>
Expand Down
4 changes: 3 additions & 1 deletion bound/kt/src/main/kotlin/tbdex/sdk/httpclient/Balances.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ package tbdex.sdk.httpclient

import tbdex.sdk.resources.Balance
import tbdex.sdk.rust.getBalances as rustCoreGetBalances
import tbdex.sdk.rust.fromWeb5
import tbdex.sdk.rust.BearerDid as RustCoreBearerDid
import web5.sdk.dids.BearerDid

fun getBalances(pfiDidUri: String, bearerDid: BearerDid): List<Balance> {
val rustCoreBalances = rustCoreGetBalances(pfiDidUri, bearerDid.rustCoreBearerDid)
val rustCoreBalances = rustCoreGetBalances(pfiDidUri, RustCoreBearerDid.fromWeb5(bearerDid))
return rustCoreBalances.map { Balance.fromRustCoreBalance(it) }
}
6 changes: 4 additions & 2 deletions bound/kt/src/main/kotlin/tbdex/sdk/httpclient/Exchanges.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import tbdex.sdk.rust.submitOrder as rustCoreSubmitOrder
import tbdex.sdk.rust.submitCancel as rustCoreSubmitCancel
import tbdex.sdk.rust.getExchange as rustCoreGetExchange
import tbdex.sdk.rust.getExchangeIds as rustCoreGetExchangeIds
import tbdex.sdk.rust.fromWeb5
import tbdex.sdk.rust.BearerDid as RustCoreBearerDid
import web5.sdk.dids.BearerDid

data class Exchange(
Expand Down Expand Up @@ -47,14 +49,14 @@ fun submitCancel(cancel: Cancel) {
}

fun getExchange(pfiDidUri: String, bearerDid: BearerDid, exchangeId: String): Exchange {
val rustCoreExchange = rustCoreGetExchange(pfiDidUri, bearerDid.rustCoreBearerDid, exchangeId)
val rustCoreExchange = rustCoreGetExchange(pfiDidUri, RustCoreBearerDid.fromWeb5(bearerDid), exchangeId)
return Exchange.fromRustCore(rustCoreExchange)
}

typealias GetExchangeIdsQueryParams = RustCoreGetExchangeIdsQueryParams

fun getExchangeIds(pfiDidUri: String, bearerDid: BearerDid, queryParams: GetExchangeIdsQueryParams? = null): List<String> {
return rustCoreGetExchangeIds(pfiDidUri, bearerDid.rustCoreBearerDid, queryParams)
return rustCoreGetExchangeIds(pfiDidUri, RustCoreBearerDid.fromWeb5(bearerDid), queryParams)
}


Expand Down
4 changes: 3 additions & 1 deletion bound/kt/src/main/kotlin/tbdex/sdk/messages/Cancel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package tbdex.sdk.messages
import tbdex.sdk.http.WalletUpdateMessage
import tbdex.sdk.rust.Cancel as RustCoreCancel
import tbdex.sdk.rust.CancelDataData as RustCoreCancelData
import tbdex.sdk.rust.fromWeb5
import tbdex.sdk.rust.BearerDid as RustCoreBearerDid
import web5.sdk.dids.BearerDid

typealias CancelData = RustCoreCancelData
Expand Down Expand Up @@ -44,7 +46,7 @@ class Cancel private constructor(
}

fun sign(bearerDid: BearerDid) {
this.rustCoreCancel.sign(bearerDid.rustCoreBearerDid)
this.rustCoreCancel.sign(RustCoreBearerDid.fromWeb5(bearerDid))
}

fun verify() {
Expand Down
4 changes: 3 additions & 1 deletion bound/kt/src/main/kotlin/tbdex/sdk/messages/Close.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package tbdex.sdk.messages
import tbdex.sdk.http.ReplyToMessage
import tbdex.sdk.rust.Close as RustCoreClose
import tbdex.sdk.rust.CloseDataData as RustCoreCloseData
import tbdex.sdk.rust.fromWeb5
import tbdex.sdk.rust.BearerDid as RustCoreBearerDid
import web5.sdk.dids.BearerDid

typealias CloseData = RustCoreCloseData
Expand Down Expand Up @@ -44,7 +46,7 @@ class Close private constructor(
}

fun sign(bearerDid: BearerDid) {
this.rustCoreClose.sign(bearerDid.rustCoreBearerDid)
this.rustCoreClose.sign(RustCoreBearerDid.fromWeb5(bearerDid))
}

fun verify() {
Expand Down
4 changes: 3 additions & 1 deletion bound/kt/src/main/kotlin/tbdex/sdk/messages/Order.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package tbdex.sdk.messages

import tbdex.sdk.http.WalletUpdateMessage
import tbdex.sdk.rust.Order as RustCoreOrder
import tbdex.sdk.rust.fromWeb5
import tbdex.sdk.rust.BearerDid as RustCoreBearerDid
import web5.sdk.dids.BearerDid

class Order private constructor(
Expand Down Expand Up @@ -39,7 +41,7 @@ class Order private constructor(
}

fun sign(bearerDid: BearerDid) {
this.rustCoreOrder.sign(bearerDid.rustCoreBearerDid)
this.rustCoreOrder.sign(RustCoreBearerDid.fromWeb5(bearerDid))
}

fun verify() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package tbdex.sdk.messages

import tbdex.sdk.http.ReplyToMessage
import tbdex.sdk.rust.OrderInstructionsDataData as RustCoreOrderInstructionsData
import tbdex.sdk.rust.fromWeb5
import tbdex.sdk.rust.BearerDid as RustCoreBearerDid
import web5.sdk.dids.BearerDid

typealias OrderInstructionsData = RustCoreOrderInstructionsData
Expand Down Expand Up @@ -44,7 +46,7 @@ class OrderInstructions private constructor(
}

fun sign(bearerDid: BearerDid) {
this.rustCoreOrderInstructions.sign(bearerDid.rustCoreBearerDid)
this.rustCoreOrderInstructions.sign(RustCoreBearerDid.fromWeb5(bearerDid))
}

fun verify() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import tbdex.sdk.http.ReplyToMessage
import tbdex.sdk.rust.OrderStatusStatus as RustCoreStatus
import tbdex.sdk.rust.OrderStatus as RustCoreOrderStatus
import tbdex.sdk.rust.OrderStatusDataData as RustCoreOrderStatusData
import tbdex.sdk.rust.fromWeb5
import tbdex.sdk.rust.BearerDid as RustCoreBearerDid
import web5.sdk.dids.BearerDid

typealias OrderStatusData = RustCoreOrderStatusData
Expand Down Expand Up @@ -46,7 +48,7 @@ class OrderStatus private constructor(
}

fun sign(bearerDid: BearerDid) {
this.rustCoreOrderStatus.sign(bearerDid.rustCoreBearerDid)
this.rustCoreOrderStatus.sign(RustCoreBearerDid.fromWeb5(bearerDid))
}

fun verify() {
Expand Down
4 changes: 3 additions & 1 deletion bound/kt/src/main/kotlin/tbdex/sdk/messages/Quote.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import tbdex.sdk.rust.PaymentInstructionData as RustCorePaymentInstruction
import tbdex.sdk.rust.QuoteDetailsData as RustCoreQuoteDetails
import tbdex.sdk.rust.Quote as RustCoreQuote
import tbdex.sdk.rust.QuoteDataData as RustCoreQuoteData
import tbdex.sdk.rust.fromWeb5
import tbdex.sdk.rust.BearerDid as RustCoreBearerDid
import web5.sdk.dids.BearerDid

typealias QuoteData = RustCoreQuoteData
Expand Down Expand Up @@ -48,7 +50,7 @@ class Quote private constructor(
}

fun sign(bearerDid: BearerDid) {
this.rustCoreQuote.sign(bearerDid.rustCoreBearerDid)
this.rustCoreQuote.sign(RustCoreBearerDid.fromWeb5(bearerDid))
}

fun verify() {
Expand Down
4 changes: 3 additions & 1 deletion bound/kt/src/main/kotlin/tbdex/sdk/messages/Rfq.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package tbdex.sdk.messages

import tbdex.sdk.Json
import tbdex.sdk.resources.Offering
import tbdex.sdk.rust.fromWeb5
import tbdex.sdk.rust.Rfq as RustCoreRfq
import tbdex.sdk.rust.BearerDid as RustCoreBearerDid
import web5.sdk.dids.BearerDid

class Rfq private constructor(
Expand Down Expand Up @@ -61,7 +63,7 @@ class Rfq private constructor(
}

fun sign(bearerDid: BearerDid) {
this.rustCoreRfq.sign(bearerDid.rustCoreBearerDid)
this.rustCoreRfq.sign(RustCoreBearerDid.fromWeb5(bearerDid))
}

fun verify() {
Expand Down
4 changes: 3 additions & 1 deletion bound/kt/src/main/kotlin/tbdex/sdk/resources/Balance.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package tbdex.sdk.resources

import tbdex.sdk.rust.Balance as RustCoreBalance
import tbdex.sdk.rust.BalanceDataData as RustCoreBalanceData
import tbdex.sdk.rust.fromWeb5
import tbdex.sdk.rust.BearerDid as RustCoreBearerDid
import web5.sdk.dids.BearerDid

typealias BalanceData = RustCoreBalanceData
Expand Down Expand Up @@ -40,7 +42,7 @@ class Balance private constructor(
}

fun sign(bearerDid: BearerDid) {
this.rustCoreBalance.sign(bearerDid.rustCoreBearerDid)
this.rustCoreBalance.sign(RustCoreBearerDid.fromWeb5(bearerDid))
}

fun verify() {
Expand Down
4 changes: 3 additions & 1 deletion bound/kt/src/main/kotlin/tbdex/sdk/resources/Offering.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package tbdex.sdk.resources

import tbdex.sdk.Json
import tbdex.sdk.rust.Offering as RustCoreOffering
import tbdex.sdk.rust.fromWeb5
import tbdex.sdk.rust.BearerDid as RustCoreBearerDid
import web5.sdk.dids.BearerDid
import web5.sdk.vc.pex.PresentationDefinition

Expand Down Expand Up @@ -47,7 +49,7 @@ class Offering private constructor(
}

fun sign(bearerDid: BearerDid) {
this.rustCoreOffering.sign(bearerDid.rustCoreBearerDid)
this.rustCoreOffering.sign(RustCoreBearerDid.fromWeb5(bearerDid))
}

fun verify() {
Expand Down
Loading
Loading