diff --git a/.gitignore b/.gitignore index 94240d37..9683a226 100644 --- a/.gitignore +++ b/.gitignore @@ -17,4 +17,5 @@ Cargo.lock .hermit/ build/ -.gradle/ \ No newline at end of file +.gradle/ +tmp/ \ No newline at end of file diff --git a/Justfile b/Justfile index 6ff000f1..63699666 100644 --- a/Justfile +++ b/Justfile @@ -26,12 +26,11 @@ bind: setup just bind-kotlin bind-kotlin: setup - cargo build --release --package tbdex_uniffi - cargo run --package tbdex_uniffi \ + cargo build --release --target aarch64-apple-darwin --package tbdex_uniffi + cargo run --release --package tbdex_uniffi \ --bin uniffi-bindgen \ - generate --library target/release/libtbdex_uniffi.dylib \ + generate --library target/aarch64-apple-darwin/release/libtbdex_uniffi.dylib \ --language kotlin \ --out-dir target/bindgen-kotlin - cp target/release/libtbdex_uniffi.dylib bound/kt/src/main/resources/natives - cp target/bindgen-kotlin/tbdex/sdk/rust/tbdex.kt bound/kt/src/main/kotlin/tbdex/sdk/rust - cd bound/kt && ./fix-load.sh \ No newline at end of file + cp target/aarch64-apple-darwin/release/libtbdex_uniffi.dylib bound/kt/src/main/resources + cp target/bindgen-kotlin/tbdex/sdk/rust/tbdex.kt bound/kt/src/main/kotlin/tbdex/sdk/rust \ No newline at end of file diff --git a/bin/.openjdk@11.pkg b/bin/.openjdk@17.pkg similarity index 100% rename from bin/.openjdk@11.pkg rename to bin/.openjdk@17.pkg diff --git a/bin/jaotc b/bin/jaotc deleted file mode 120000 index 213a2b09..00000000 --- a/bin/jaotc +++ /dev/null @@ -1 +0,0 @@ -.openjdk@11.pkg \ No newline at end of file diff --git a/bin/jar b/bin/jar index 213a2b09..cf7b7e07 120000 --- a/bin/jar +++ b/bin/jar @@ -1 +1 @@ -.openjdk@11.pkg \ No newline at end of file +.openjdk@17.pkg \ No newline at end of file diff --git a/bin/jarsigner b/bin/jarsigner index 213a2b09..cf7b7e07 120000 --- a/bin/jarsigner +++ b/bin/jarsigner @@ -1 +1 @@ -.openjdk@11.pkg \ No newline at end of file +.openjdk@17.pkg \ No newline at end of file diff --git a/bin/java b/bin/java index 213a2b09..cf7b7e07 120000 --- a/bin/java +++ b/bin/java @@ -1 +1 @@ -.openjdk@11.pkg \ No newline at end of file +.openjdk@17.pkg \ No newline at end of file diff --git a/bin/javac b/bin/javac index 213a2b09..cf7b7e07 120000 --- a/bin/javac +++ b/bin/javac @@ -1 +1 @@ -.openjdk@11.pkg \ No newline at end of file +.openjdk@17.pkg \ No newline at end of file diff --git a/bin/javadoc b/bin/javadoc index 213a2b09..cf7b7e07 120000 --- a/bin/javadoc +++ b/bin/javadoc @@ -1 +1 @@ -.openjdk@11.pkg \ No newline at end of file +.openjdk@17.pkg \ No newline at end of file diff --git a/bin/javap b/bin/javap index 213a2b09..cf7b7e07 120000 --- a/bin/javap +++ b/bin/javap @@ -1 +1 @@ -.openjdk@11.pkg \ No newline at end of file +.openjdk@17.pkg \ No newline at end of file diff --git a/bin/jcmd b/bin/jcmd index 213a2b09..cf7b7e07 120000 --- a/bin/jcmd +++ b/bin/jcmd @@ -1 +1 @@ -.openjdk@11.pkg \ No newline at end of file +.openjdk@17.pkg \ No newline at end of file diff --git a/bin/jconsole b/bin/jconsole index 213a2b09..cf7b7e07 120000 --- a/bin/jconsole +++ b/bin/jconsole @@ -1 +1 @@ -.openjdk@11.pkg \ No newline at end of file +.openjdk@17.pkg \ No newline at end of file diff --git a/bin/jdb b/bin/jdb index 213a2b09..cf7b7e07 120000 --- a/bin/jdb +++ b/bin/jdb @@ -1 +1 @@ -.openjdk@11.pkg \ No newline at end of file +.openjdk@17.pkg \ No newline at end of file diff --git a/bin/jdeprscan b/bin/jdeprscan index 213a2b09..cf7b7e07 120000 --- a/bin/jdeprscan +++ b/bin/jdeprscan @@ -1 +1 @@ -.openjdk@11.pkg \ No newline at end of file +.openjdk@17.pkg \ No newline at end of file diff --git a/bin/jdeps b/bin/jdeps index 213a2b09..cf7b7e07 120000 --- a/bin/jdeps +++ b/bin/jdeps @@ -1 +1 @@ -.openjdk@11.pkg \ No newline at end of file +.openjdk@17.pkg \ No newline at end of file diff --git a/bin/jfr b/bin/jfr index 213a2b09..cf7b7e07 120000 --- a/bin/jfr +++ b/bin/jfr @@ -1 +1 @@ -.openjdk@11.pkg \ No newline at end of file +.openjdk@17.pkg \ No newline at end of file diff --git a/bin/jhsdb b/bin/jhsdb index 213a2b09..cf7b7e07 120000 --- a/bin/jhsdb +++ b/bin/jhsdb @@ -1 +1 @@ -.openjdk@11.pkg \ No newline at end of file +.openjdk@17.pkg \ No newline at end of file diff --git a/bin/jimage b/bin/jimage index 213a2b09..cf7b7e07 120000 --- a/bin/jimage +++ b/bin/jimage @@ -1 +1 @@ -.openjdk@11.pkg \ No newline at end of file +.openjdk@17.pkg \ No newline at end of file diff --git a/bin/jinfo b/bin/jinfo index 213a2b09..cf7b7e07 120000 --- a/bin/jinfo +++ b/bin/jinfo @@ -1 +1 @@ -.openjdk@11.pkg \ No newline at end of file +.openjdk@17.pkg \ No newline at end of file diff --git a/bin/jjs b/bin/jjs deleted file mode 120000 index 213a2b09..00000000 --- a/bin/jjs +++ /dev/null @@ -1 +0,0 @@ -.openjdk@11.pkg \ No newline at end of file diff --git a/bin/jlink b/bin/jlink index 213a2b09..cf7b7e07 120000 --- a/bin/jlink +++ b/bin/jlink @@ -1 +1 @@ -.openjdk@11.pkg \ No newline at end of file +.openjdk@17.pkg \ No newline at end of file diff --git a/bin/jmap b/bin/jmap index 213a2b09..cf7b7e07 120000 --- a/bin/jmap +++ b/bin/jmap @@ -1 +1 @@ -.openjdk@11.pkg \ No newline at end of file +.openjdk@17.pkg \ No newline at end of file diff --git a/bin/jmod b/bin/jmod index 213a2b09..cf7b7e07 120000 --- a/bin/jmod +++ b/bin/jmod @@ -1 +1 @@ -.openjdk@11.pkg \ No newline at end of file +.openjdk@17.pkg \ No newline at end of file diff --git a/bin/jpackage b/bin/jpackage new file mode 120000 index 00000000..cf7b7e07 --- /dev/null +++ b/bin/jpackage @@ -0,0 +1 @@ +.openjdk@17.pkg \ No newline at end of file diff --git a/bin/jps b/bin/jps index 213a2b09..cf7b7e07 120000 --- a/bin/jps +++ b/bin/jps @@ -1 +1 @@ -.openjdk@11.pkg \ No newline at end of file +.openjdk@17.pkg \ No newline at end of file diff --git a/bin/jrunscript b/bin/jrunscript index 213a2b09..cf7b7e07 120000 --- a/bin/jrunscript +++ b/bin/jrunscript @@ -1 +1 @@ -.openjdk@11.pkg \ No newline at end of file +.openjdk@17.pkg \ No newline at end of file diff --git a/bin/jshell b/bin/jshell index 213a2b09..cf7b7e07 120000 --- a/bin/jshell +++ b/bin/jshell @@ -1 +1 @@ -.openjdk@11.pkg \ No newline at end of file +.openjdk@17.pkg \ No newline at end of file diff --git a/bin/jstack b/bin/jstack index 213a2b09..cf7b7e07 120000 --- a/bin/jstack +++ b/bin/jstack @@ -1 +1 @@ -.openjdk@11.pkg \ No newline at end of file +.openjdk@17.pkg \ No newline at end of file diff --git a/bin/jstat b/bin/jstat index 213a2b09..cf7b7e07 120000 --- a/bin/jstat +++ b/bin/jstat @@ -1 +1 @@ -.openjdk@11.pkg \ No newline at end of file +.openjdk@17.pkg \ No newline at end of file diff --git a/bin/jstatd b/bin/jstatd index 213a2b09..cf7b7e07 120000 --- a/bin/jstatd +++ b/bin/jstatd @@ -1 +1 @@ -.openjdk@11.pkg \ No newline at end of file +.openjdk@17.pkg \ No newline at end of file diff --git a/bin/keytool b/bin/keytool index 213a2b09..cf7b7e07 120000 --- a/bin/keytool +++ b/bin/keytool @@ -1 +1 @@ -.openjdk@11.pkg \ No newline at end of file +.openjdk@17.pkg \ No newline at end of file diff --git a/bin/pack200 b/bin/pack200 deleted file mode 120000 index 213a2b09..00000000 --- a/bin/pack200 +++ /dev/null @@ -1 +0,0 @@ -.openjdk@11.pkg \ No newline at end of file diff --git a/bin/rmic b/bin/rmic deleted file mode 120000 index 213a2b09..00000000 --- a/bin/rmic +++ /dev/null @@ -1 +0,0 @@ -.openjdk@11.pkg \ No newline at end of file diff --git a/bin/rmid b/bin/rmid deleted file mode 120000 index 213a2b09..00000000 --- a/bin/rmid +++ /dev/null @@ -1 +0,0 @@ -.openjdk@11.pkg \ No newline at end of file diff --git a/bin/rmiregistry b/bin/rmiregistry index 213a2b09..cf7b7e07 120000 --- a/bin/rmiregistry +++ b/bin/rmiregistry @@ -1 +1 @@ -.openjdk@11.pkg \ No newline at end of file +.openjdk@17.pkg \ No newline at end of file diff --git a/bin/serialver b/bin/serialver index 213a2b09..cf7b7e07 120000 --- a/bin/serialver +++ b/bin/serialver @@ -1 +1 @@ -.openjdk@11.pkg \ No newline at end of file +.openjdk@17.pkg \ No newline at end of file diff --git a/bin/unpack200 b/bin/unpack200 deleted file mode 120000 index 213a2b09..00000000 --- a/bin/unpack200 +++ /dev/null @@ -1 +0,0 @@ -.openjdk@11.pkg \ No newline at end of file diff --git a/bindings/tbdex_uniffi/Dockerfile b/bindings/tbdex_uniffi/Dockerfile new file mode 100644 index 00000000..53691997 --- /dev/null +++ b/bindings/tbdex_uniffi/Dockerfile @@ -0,0 +1,18 @@ +FROM rust:latest + +RUN apt-get update && \ + apt-get install -y musl-tools llvm && \ + rustup target add x86_64-unknown-linux-musl + +WORKDIR /app + +COPY .cargo/ Cargo.toml Cargo.lock ./ +COPY crates/tbdex crates/tbdex +COPY crates/pfi_exemplar_integration_test crates/pfi_exemplar_integration_test +COPY bindings/tbdex_uniffi bindings/tbdex_uniffi + +WORKDIR /app/bindings/tbdex_uniffi + +RUN cargo build --release --target x86_64-unknown-linux-musl + +CMD tail -f /dev/null diff --git a/bindings/tbdex_uniffi/DockerfileBindLinuxAmd64 b/bindings/tbdex_uniffi/DockerfileBindLinuxAmd64 new file mode 100644 index 00000000..fe71b006 --- /dev/null +++ b/bindings/tbdex_uniffi/DockerfileBindLinuxAmd64 @@ -0,0 +1,30 @@ +FROM --platform=linux/amd64 ubuntu:22.04 + +RUN apt-get update && apt-get install -y \ + build-essential \ + cmake \ + pkg-config \ + libssl-dev \ + curl \ + wget \ + git \ + ca-certificates \ + && rm -rf /var/lib/apt/lists/* + +RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y +ENV PATH="/root/.cargo/bin:${PATH}" + +RUN rustup default 1.78.0 + +WORKDIR /app + +COPY Cargo.toml Cargo.lock ./ +COPY crates/tbdex crates/tbdex +COPY crates/pfi_exemplar_integration_test crates/pfi_exemplar_integration_test +COPY bindings/tbdex_uniffi bindings/tbdex_uniffi + +WORKDIR /app/bindings/tbdex_uniffi + +RUN cargo build --release + +CMD tail -f /dev/null \ No newline at end of file diff --git a/bindings/tbdex_uniffi/DockerfileBuildAlpine b/bindings/tbdex_uniffi/DockerfileBuildAlpine new file mode 100644 index 00000000..86406737 --- /dev/null +++ b/bindings/tbdex_uniffi/DockerfileBuildAlpine @@ -0,0 +1,29 @@ +FROM --platform=linux/amd64 alpine:latest + +RUN apk add --no-cache \ + build-base \ + cmake \ + pkgconfig \ + openssl-dev \ + curl \ + wget \ + git \ + ca-certificates + +RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y +ENV PATH="/root/.cargo/bin:${PATH}" + +RUN rustup default 1.78.0 + +WORKDIR /app + +COPY Cargo.toml Cargo.lock ./ +COPY crates/tbdex crates/tbdex +COPY crates/pfi_exemplar_integration_test crates/pfi_exemplar_integration_test +COPY bindings/tbdex_uniffi bindings/tbdex_uniffi + +WORKDIR /app/bindings/tbdex_uniffi + +RUN cargo build --release --target x86_64-unknown-linux-musl + +CMD tail -f /dev/null diff --git a/bindings/tbdex_uniffi/DockerfileBuildAlpine_old b/bindings/tbdex_uniffi/DockerfileBuildAlpine_old new file mode 100644 index 00000000..d567f550 --- /dev/null +++ b/bindings/tbdex_uniffi/DockerfileBuildAlpine_old @@ -0,0 +1,41 @@ +FROM --platform=linux/amd64 alpine:latest + +# Install build dependencies +RUN apk add --no-cache \ + build-base \ + cmake \ + pkgconfig \ + openssl-dev \ + curl \ + wget \ + git \ + ca-certificates \ + linux-headers + +# Install rustup and set default toolchain +RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y +ENV PATH="/root/.cargo/bin:${PATH}" + +RUN rustup default 1.78.0 + +# Set working directory +WORKDIR /app + +# Copy project files +COPY Cargo.toml Cargo.lock ./ +COPY crates/tbdex crates/tbdex +COPY crates/pfi_exemplar_integration_test crates/pfi_exemplar_integration_test +COPY bindings/tbdex_uniffi bindings/tbdex_uniffi + +WORKDIR /app/bindings/tbdex_uniffi + +# Set environment variables to help linker find OpenSSL libraries +ENV OPENSSL_DIR=/usr +ENV OPENSSL_LIB_DIR=/usr/lib +ENV OPENSSL_INCLUDE_DIR=/usr/include +ENV PKG_CONFIG_PATH=/usr/lib/pkgconfig + +# Build the project +RUN RUSTFLAGS="-C target-feature=-crt-static" cargo build --release --target x86_64-unknown-linux-musl + +CMD tail -f /dev/null diff --git a/bindings/tbdex_uniffi/docker-build-linux-amd64 b/bindings/tbdex_uniffi/docker-build-linux-amd64 new file mode 100755 index 00000000..2b00da27 --- /dev/null +++ b/bindings/tbdex_uniffi/docker-build-linux-amd64 @@ -0,0 +1,7 @@ +#!/bin/bash + +docker build -f DockerfileBindLinuxAmd64 -t tbdex-uniffi-linux-amd64-image ../../ +docker run -d --name tbdex-uniffi-linux-amd64-container tbdex-uniffi-linux-amd64-image +docker cp tbdex-uniffi-linux-amd64-container:/app/target/release/libtbdex_uniffi.so ../../bound/kt/src/main/resources +docker stop tbdex-uniffi-linux-amd64-container +docker rm tbdex-uniffi-linux-amd64-container \ No newline at end of file diff --git a/bound/kt/fix-load.sh b/bound/kt/fix-load.sh deleted file mode 100755 index 3c43dd8b..00000000 --- a/bound/kt/fix-load.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash - -# Path to your Kotlin file -FILE="src/main/kotlin/tbdex/sdk/rust/tbdex.kt" - -# Add the import line after the last import -awk '/^import/ {print; found=1; next} found && !/^import/ {print "import java.nio.file.Files"; found=0} {print}' $FILE > tmpfile && mv tmpfile $FILE - -# Replace the specified block of code using a more BSD-friendly approach -sed -i '' '/loadIndirect(componentName = "tbdex")/,/also { lib: UniffiLib ->/c\ - val tempDir = Files.createTempDirectory("library")\ - val libraryPath = tempDir.resolve("libtbdex_uniffi.dylib")\ - Thread.currentThread().contextClassLoader.getResourceAsStream("natives/libtbdex_uniffi.dylib").use { input ->\ - Files.copy(input, libraryPath)\ - }\ - libraryPath.toFile().deleteOnExit()\ - val lib = Native.load(libraryPath.toString(), UniffiLib::class.java)\ - lib.also {' $FILE diff --git a/bound/kt/src/main/kotlin/tbdex/sdk/rust/tbdex.kt b/bound/kt/src/main/kotlin/tbdex/sdk/rust/tbdex.kt index 96439fc9..3794726f 100644 --- a/bound/kt/src/main/kotlin/tbdex/sdk/rust/tbdex.kt +++ b/bound/kt/src/main/kotlin/tbdex/sdk/rust/tbdex.kt @@ -31,7 +31,6 @@ import java.nio.charset.CodingErrorAction import java.util.concurrent.atomic.AtomicLong import java.util.concurrent.ConcurrentHashMap import java.util.concurrent.atomic.AtomicBoolean -import java.nio.file.Files // This is a helper for safely working with byte buffers returned from the Rust code. // A rust-owned buffer is represented by its capacity, its current length, and a @@ -876,14 +875,9 @@ internal open class UniffiVTableCallbackInterfaceSigner( internal interface UniffiLib : Library { companion object { internal val INSTANCE: UniffiLib by lazy { - val tempDir = Files.createTempDirectory("library") - val libraryPath = tempDir.resolve("libtbdex_uniffi.dylib") - Thread.currentThread().contextClassLoader.getResourceAsStream("natives/libtbdex_uniffi.dylib").use { input -> - Files.copy(input, libraryPath) - } - libraryPath.toFile().deleteOnExit() - val lib = Native.load(libraryPath.toString(), UniffiLib::class.java) - lib.also { uniffiCheckContractApiVersion(lib) + loadIndirect(componentName = "tbdex") + .also { lib: UniffiLib -> + uniffiCheckContractApiVersion(lib) uniffiCheckApiChecksums(lib) uniffiCallbackInterfaceKeyManager.register(lib) uniffiCallbackInterfaceSigner.register(lib) diff --git a/bound/kt/src/main/resources/natives/libtbdex_uniffi.dylib b/bound/kt/src/main/resources/libtbdex_uniffi.dylib similarity index 59% rename from bound/kt/src/main/resources/natives/libtbdex_uniffi.dylib rename to bound/kt/src/main/resources/libtbdex_uniffi.dylib index 6f709389..0ad2dd7e 100755 Binary files a/bound/kt/src/main/resources/natives/libtbdex_uniffi.dylib and b/bound/kt/src/main/resources/libtbdex_uniffi.dylib differ diff --git a/bound/kt/src/main/resources/libtbdex_uniffi.so b/bound/kt/src/main/resources/libtbdex_uniffi.so new file mode 100755 index 00000000..071b90d8 Binary files /dev/null and b/bound/kt/src/main/resources/libtbdex_uniffi.so differ diff --git a/bound/kt/src/test/kotlin/tbdex/sdk/httpclient/E2ePfiExemplarIntegrationTest.kt b/bound/kt/src/test/kotlin/tbdex/sdk/httpclient/E2ePfiExemplarIntegrationTest.kt index 5b02fc23..0ac4e6a5 100644 --- a/bound/kt/src/test/kotlin/tbdex/sdk/httpclient/E2ePfiExemplarIntegrationTest.kt +++ b/bound/kt/src/test/kotlin/tbdex/sdk/httpclient/E2ePfiExemplarIntegrationTest.kt @@ -15,7 +15,8 @@ class E2ePfiExemplarIntegrationTest { @Disabled @Test fun `can make the happy path`() { - val pfiDidUri = "did:dht:swit41ctrddy1s38c5j46yfgbxmwo1emau71zo5hn1tws1g63hiy" +// val pfiDidUri = "did:dht:swit41ctrddy1s38c5j46yfgbxmwo1emau71zo5hn1tws1g63hiy" + val pfiDidUri = "did:web:localhost%3A8891" val didUri = "did:dht:1fs5hnxsgtxgdr4wzqi38cnj46b1whhn94ojwo66g8hsc5bt3fgy" val keyManager = InMemoryKeyManager(listOf()) diff --git a/examples/hosted-wallet-kt/Dockerfile b/examples/hosted-wallet-kt/Dockerfile new file mode 100644 index 00000000..8e1698df --- /dev/null +++ b/examples/hosted-wallet-kt/Dockerfile @@ -0,0 +1,21 @@ +FROM --platform=linux/amd64 ubuntu:22.04 + +RUN apt-get update && apt-get install -y \ + openjdk-17-jdk \ + gradle \ + maven \ + git + +COPY bound/kt /app/bound/kt +COPY examples/hosted-wallet-kt /app/examples/hosted-wallet-kt + +WORKDIR /app/bound/kt +RUN mvn install + +WORKDIR /app/examples/hosted-wallet-kt +RUN ./gradlew build + +EXPOSE 8081 +EXPOSE 8082 + +CMD ["bash"] diff --git a/examples/hosted-wallet-kt/pfi/build.gradle.kts b/examples/hosted-wallet-kt/pfi/build.gradle.kts index 6e2b9f71..debcf9b0 100644 --- a/examples/hosted-wallet-kt/pfi/build.gradle.kts +++ b/examples/hosted-wallet-kt/pfi/build.gradle.kts @@ -16,13 +16,13 @@ dependencies { } java { - sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_11 + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 } tasks.withType { kotlinOptions { - jvmTarget = "11" + jvmTarget = "17" } } diff --git a/examples/hosted-wallet-kt/run b/examples/hosted-wallet-kt/run new file mode 100755 index 00000000..fd4c05a9 --- /dev/null +++ b/examples/hosted-wallet-kt/run @@ -0,0 +1,14 @@ +#!/bin/bash + +# Create the network +docker network create hosted-wallet-kt-network + +# Build the image +docker build -t hosted-wallet-kt . +docker build -f Dockerfile -t hosted-wallet-kt ../../ + +# Run the pfi application +docker run -d --name pfi-app --network hosted-wallet-kt-network -p 8082:8082 hosted-wallet-kt ./gradlew :pfi:run + +# Run the wallet application +docker run -d --name wallet-app --network hosted-wallet-kt-network -p 8081:8081 hosted-wallet-kt ./gradlew :wallet:run