From 99b940b03b2ff9eb028c80f77695acfba3ee60a6 Mon Sep 17 00:00:00 2001 From: Huakun Shen Date: Wed, 11 Dec 2024 08:14:40 -0500 Subject: [PATCH] File Transfer (Local Network) (#34) * feat: implement a file streamer for file share Only server with hardcoded file path * bump valibot version * feat: add server-info gRPC module to serve server info * feat: add ssl cert and public key to peers state When peer is online, KK always have know its cert and pub key for future secure communication * feat: add grpc ts package * Enable "/refresh-worker-extension" rest API, grpc version isn't ready yet * update pnpm lock * ci: fix CI by moving protobuf install order * ci: fix * upgrade api due to valibot incompatibility * fix: use fs instead of bun shell to be compatible with windows * skip grpc pkg build on windows * feat: local network file transfer prototype working * fix: grpc build.ts * download next to 14 * ci: add ci env try to fix next * fix: hideRefreshBtn and a few other btns' hide API in iframe ext page * feat: disable NODE_TLS_REJECT_UNAUTHORIZED for extension HMR refresh * fix: manifest json schema with objectWithRest to allow any other fields in package.json * chore: update valibot and related dependencies to version 1.0.0-beta.9 in pnpm-lock.yaml * ci: add protobuf compiler installation to manifest-schema-upload workflow * refactor: move grpc code from jarvis to a separate grpc crate for easier testing * feat(file-transfer): POC multi file + directory file transfer * feat(file-transfer): replace file transfer recursive download in ts with rust * feat(file-transfer): implement on_progress event for file transfer * feat(file-transfer): report progress every 1MB instead of 100 iterations * feat(file-transfer): add progress bar * feat(file-transfer): UI * feat(file-transfer): add file transfer bucket info preview Show total size and number of files * feat(file-transfer): improve UX Show bucket info during confirm; improve progress bar UI, prevent inconsistent width * feat(grpc): skip build in Cloudflare Pages due to missing protoc * refactor: with cargo fix, unused imports removed * ci: debug cloudflare pages env var * fix(grpc): update environment variable access for Cloudflare Pages build check * fix(grpc): add error handling for protoc command in build script * chore: update kkrpc version to 0.0.13, remove kkrpc submodule, and enhance grpc build script logging - Updated kkrpc dependency version from 0.0.12 to 0.0.13 in package.json. - Removed the kkrpc submodule from the project. - Enhanced logging in the grpc build script to include additional Cloudflare Pages environment variables for better debugging. * fix(api): typescript error, remove base.json from tsconfig * chore: update pnpm lock * fix(api): update TypeScript configuration to extend base.json and clean up unused options * refactor(api): update TypeScript configuration to extend path-alias.json and enhance compiler options * fix(api): restore KunkunManifestPermission in PermissionUnion and update valibot import in schema tests * fix: missing trait error * fix: js require replaced with import * test: fix a unit test with a more robust method --------- Co-authored-by: Huakun Shen --- .github/workflows/ci.yml | 25 +- .github/workflows/manifest-schema-upload.yml | 4 + .vscode/extensions.json | 3 +- Cargo.lock | 216 +- Cargo.toml | 9 + apps/cli/package.json | 4 +- apps/create-kunkun/package.json | 2 +- apps/desktop/package.json | 3 +- apps/desktop/src-tauri/Cargo.toml | 4 +- apps/desktop/src-tauri/src/lib.rs | 7 +- apps/desktop/src-tauri/tauri.conf.json | 3 + apps/desktop/src/lib/cmds/builtin.ts | 12 + .../lib/components/common/DragNDrop.svelte | 13 +- apps/desktop/src/lib/stores/extensions.ts | 27 +- apps/desktop/src/routes/+layout.svelte | 2 +- .../extension/create-quick-link/+page.svelte | 1 + .../extension/file-transfer/+page.svelte | 187 ++ .../extension/file-transfer/file-icon.svelte | 35 + .../routes/extension/ui-iframe/+page.svelte | 7 +- apps/desktop/src/routes/settings/+page.svelte | 5 + package.json | 4 +- packages/api/package.json | 10 +- packages/api/src/commands/file-transfer.ts | 79 + packages/api/src/commands/index.ts | 2 + packages/api/src/dev/index.ts | 2 + .../api/src/models/__tests__/schema.test.ts | 7 +- packages/api/src/models/file-transfer.ts | 34 + packages/api/src/models/index.ts | 1 + packages/api/src/models/manifest.ts | 1 - packages/api/src/models/mdns.ts | 5 +- packages/api/src/permissions/schema.ts | 175 +- packages/api/src/ui/iframe/index.ts | 2 +- packages/api/src/version.ts | 6 +- packages/api/tsconfig.json | 2 +- packages/crypto/Cargo.toml | 5 +- packages/crypto/src/rsa.rs | 17 + packages/db/src/lib.rs | 6 +- packages/db/src/main.rs | 2 +- packages/extension/package.json | 2 +- packages/extension/src/load.ts | 11 +- .../ext-sveltekit-exp/deno-src/deno.json | 9 + .../ext-sveltekit-exp/deno-src/deno.lock | 896 +++++++ .../ext-sveltekit-exp/deno-src/index.ts | 5 + .../extensions/ext-sveltekit-exp/package.json | 10 +- .../ext-sveltekit-exp/src/routes/+page.svelte | 57 +- packages/grpc/.gitignore | 177 ++ packages/grpc/Cargo.toml | 16 + packages/grpc/build.rs | 14 + packages/grpc/build.ts | 44 + packages/grpc/dev.ts | 39 + packages/grpc/index.ts | 0 packages/grpc/package.json | 23 + .../proto => grpc/protos}/file-transfer.proto | 31 +- packages/grpc/protos/kunkun.proto | 16 + packages/grpc/src/lib.rs | 2 + packages/grpc/src/main.rs | 8 + packages/grpc/src/mods/file_transfer.rs | 4 + packages/grpc/src/mods/kunkun.rs | 4 + packages/grpc/src/mods/mod.rs | 2 + packages/grpc/tsconfig.json | 27 + packages/mac-security-rs/src/lib.rs | 4 +- packages/schema/package.json | 2 +- .../schema/scripts/upload-schema-to-s3.ts | 2 +- .../scripts/upload-schema-to-supabase.ts | 1 + packages/schema/src/index.ts | 5 +- packages/tauri-plugins/jarvis/Cargo.toml | 17 +- packages/tauri-plugins/jarvis/build.rs | 15 +- .../tauri-plugins/jarvis/permissions/all.toml | 6 + .../autogenerated/commands/download_file.toml | 13 + .../commands/download_files.toml | 13 + .../file_transfer_preview_bucket.toml | 13 + .../get_file_transfer_bucket_by_key.toml | 13 + .../get_file_transfer_bucket_keys.toml | 13 + .../commands/get_files_to_send.toml | 13 + .../commands/local_net_send_file.toml | 13 + .../permissions/autogenerated/reference.md | 182 ++ .../jarvis/permissions/schemas/schema.json | 70 + .../jarvis/proto/helloworld.proto | 14 - .../tauri-plugins/jarvis/src/commands/db.rs | 2 +- .../jarvis/src/commands/discovery.rs | 86 +- .../jarvis/src/commands/extension.rs | 2 +- .../jarvis/src/commands/file_transfer.rs | 275 ++ .../tauri-plugins/jarvis/src/commands/mod.rs | 1 + .../jarvis/src/commands/server.rs | 3 +- packages/tauri-plugins/jarvis/src/desktop.rs | 14 - packages/tauri-plugins/jarvis/src/lib.rs | 60 +- .../jarvis/src/model/app_state.rs | 1 - .../jarvis/src/model/extension.rs | 2 - packages/tauri-plugins/jarvis/src/models.rs | 32 + .../jarvis/src/server/grpc/client.rs | 31 + .../jarvis/src/server/grpc/file_transfer.rs | 276 +- .../jarvis/src/server/grpc/greeter.rs | 35 - .../jarvis/src/server/grpc/kunkun.rs | 44 + .../jarvis/src/server/grpc/mod.rs | 3 +- .../tauri-plugins/jarvis/src/server/http.rs | 92 +- .../tauri-plugins/jarvis/src/server/model.rs | 21 +- .../tauri-plugins/jarvis/src/server/rest.rs | 140 +- .../jarvis/src/setup/peer_discovery.rs | 31 +- .../tauri-plugins/jarvis/src/utils/icns.rs | 7 +- .../tauri-plugins/jarvis/src/utils/mod.rs | 2 + .../tauri-plugins/jarvis/src/utils/reqwest.rs | 17 + .../jarvis/src/utils/transfer_stats.rs | 57 + .../templates/template-ext-next/package.json | 6 +- .../template-ext-vue/tailwind.config.js | 2 +- packages/typescript-config/base.json | 18 +- packages/typescript-config/path-alias.json | 20 + pnpm-lock.yaml | 2264 ++++++----------- pnpm-workspace.yaml | 1 + vendors/tauri-plugin-network | 2 +- vendors/tauri-plugin-system-info | 2 +- 110 files changed, 4226 insertions(+), 2058 deletions(-) create mode 100644 apps/desktop/src/routes/extension/file-transfer/+page.svelte create mode 100644 apps/desktop/src/routes/extension/file-transfer/file-icon.svelte create mode 100644 packages/api/src/commands/file-transfer.ts create mode 100644 packages/api/src/models/file-transfer.ts create mode 100644 packages/extensions/ext-sveltekit-exp/deno-src/deno.json create mode 100644 packages/extensions/ext-sveltekit-exp/deno-src/deno.lock create mode 100644 packages/extensions/ext-sveltekit-exp/deno-src/index.ts create mode 100644 packages/grpc/.gitignore create mode 100644 packages/grpc/Cargo.toml create mode 100644 packages/grpc/build.rs create mode 100644 packages/grpc/build.ts create mode 100644 packages/grpc/dev.ts create mode 100644 packages/grpc/index.ts create mode 100644 packages/grpc/package.json rename packages/{tauri-plugins/jarvis/proto => grpc/protos}/file-transfer.proto (53%) create mode 100644 packages/grpc/protos/kunkun.proto create mode 100644 packages/grpc/src/lib.rs create mode 100644 packages/grpc/src/main.rs create mode 100644 packages/grpc/src/mods/file_transfer.rs create mode 100644 packages/grpc/src/mods/kunkun.rs create mode 100644 packages/grpc/src/mods/mod.rs create mode 100644 packages/grpc/tsconfig.json create mode 100644 packages/tauri-plugins/jarvis/permissions/autogenerated/commands/download_file.toml create mode 100644 packages/tauri-plugins/jarvis/permissions/autogenerated/commands/download_files.toml create mode 100644 packages/tauri-plugins/jarvis/permissions/autogenerated/commands/file_transfer_preview_bucket.toml create mode 100644 packages/tauri-plugins/jarvis/permissions/autogenerated/commands/get_file_transfer_bucket_by_key.toml create mode 100644 packages/tauri-plugins/jarvis/permissions/autogenerated/commands/get_file_transfer_bucket_keys.toml create mode 100644 packages/tauri-plugins/jarvis/permissions/autogenerated/commands/get_files_to_send.toml create mode 100644 packages/tauri-plugins/jarvis/permissions/autogenerated/commands/local_net_send_file.toml delete mode 100644 packages/tauri-plugins/jarvis/proto/helloworld.proto create mode 100644 packages/tauri-plugins/jarvis/src/commands/file_transfer.rs delete mode 100644 packages/tauri-plugins/jarvis/src/desktop.rs create mode 100644 packages/tauri-plugins/jarvis/src/server/grpc/client.rs delete mode 100644 packages/tauri-plugins/jarvis/src/server/grpc/greeter.rs create mode 100644 packages/tauri-plugins/jarvis/src/server/grpc/kunkun.rs create mode 100644 packages/tauri-plugins/jarvis/src/utils/reqwest.rs create mode 100644 packages/tauri-plugins/jarvis/src/utils/transfer_stats.rs create mode 100644 packages/typescript-config/path-alias.json diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3ef97ec..44bddbc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,15 +31,6 @@ jobs: deno-version: v2.x - name: Install Rust stable uses: dtolnay/rust-toolchain@stable - - name: Install Dependencies - run: pnpm install - - name: Setup - run: pnpm prepare - - name: Build - run: pnpm build - - name: JS Test - if: matrix.os == 'ubuntu-24.04' - run: pnpm test - name: Install protobuf (Mac) if: matrix.os == 'macos-14' run: | @@ -55,11 +46,17 @@ jobs: choco install protoc echo "VCPKG_ROOT=$env:VCPKG_INSTALLATION_ROOT" | Out-File -FilePath $env:GITHUB_ENV -Append vcpkg install openssl:x64-windows-static-md - # choco install openssl -y - # echo OPENSSL_DIR='"C:\\Program Files\\OpenSSL-Win64"' >> $env:GITHUB_ENV - # echo OPENSSL_INCLUDE_DIR='"C:\\Program Files\\OpenSSL-Win64\\include"' >> $env:GITHUB_ENV - # echo OPENSSL_LIB_DIR='"C:\\Program Files\\OpenSSL-Win64\\lib"' >> $env:GITHUB_ENV - # openssl version + - name: Install Dependencies + run: pnpm install + - name: Setup + run: pnpm prepare + - name: Build + env: + NODE_OPTIONS: --max-old-space-size=4096 + run: pnpm build + - name: JS Test + if: matrix.os == 'ubuntu-24.04' + run: pnpm test - name: Cargo Build and Test if: matrix.os == 'ubuntu-24.04' run: | diff --git a/.github/workflows/manifest-schema-upload.yml b/.github/workflows/manifest-schema-upload.yml index 3aa0c8f..76f87ec 100644 --- a/.github/workflows/manifest-schema-upload.yml +++ b/.github/workflows/manifest-schema-upload.yml @@ -23,6 +23,10 @@ jobs: - uses: denoland/setup-deno@v2 with: deno-version: v2.x + - name: Install Protobuf + run: | + sudo apt-get update + sudo apt-get install -y protobuf-compiler - name: Install Dependencies run: pnpm install - name: Setup diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 63da6db..89b5b48 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -3,6 +3,7 @@ "svelte.svelte-vscode", "tauri-apps.tauri-vscode", "rust-lang.rust-analyzer", - "denoland.vscode-deno" + "denoland.vscode-deno", + "tamasfe.even-better-toml" ] } diff --git a/Cargo.lock b/Cargo.lock index 10958e2..b7844fd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -612,12 +612,6 @@ version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" -[[package]] -name = "base64ct" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" - [[package]] name = "bindgen" version = "0.69.5" @@ -1235,12 +1229,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fe1d7dcda7d1da79e444bdfba1465f2f849a58b07774e1df473ee77030cb47a7" -[[package]] -name = "const-oid" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" - [[package]] name = "const-random" version = "0.1.18" @@ -1471,14 +1459,11 @@ dependencies = [ "axum-server", "block-padding", "cbc", - "hex", "openssl", "rand 0.8.5", "reqwest 0.12.9", "ring", - "rsa", "rustls 0.23.16", - "sha2", "tokio", ] @@ -1589,17 +1574,6 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da692b8d1080ea3045efaab14434d40468c3d8657e42abddfffca87b428f4c1b" -[[package]] -name = "der" -version = "0.7.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f55bf8e7b65898637379c1b74eb1551107c8294ed26d855ceb9fd1a09cfc9bc0" -dependencies = [ - "const-oid", - "pem-rfc7468", - "zeroize", -] - [[package]] name = "deranged" version = "0.3.11" @@ -1652,7 +1626,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", - "const-oid", "crypto-common", "subtle", ] @@ -2026,9 +1999,9 @@ checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" [[package]] name = "flate2" -version = "1.0.34" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1b589b4dc103969ad3cf85c950899926ec64300a1a46d76c03a6072957036f0" +checksum = "c936bfdafb507ebbf50b8074c54fa31c5be9a1e7e5f467dd659697041407d07c" dependencies = [ "crc32fast", "libz-ng-sys", @@ -2529,6 +2502,19 @@ dependencies = [ "system-deps", ] +[[package]] +name = "grpc" +version = "0.1.0" +dependencies = [ + "anyhow", + "prost", + "serde", + "serde_json", + "tonic", + "tonic-build", + "uuid", +] + [[package]] name = "gtk" version = "0.18.1" @@ -3318,6 +3304,7 @@ dependencies = [ "anyhow", "chrono", "cocoa 0.24.1", + "crypto", "log", "mac-security-rs", "mdns-sd", @@ -3358,9 +3345,6 @@ name = "lazy_static" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" -dependencies = [ - "spin", -] [[package]] name = "lazycell" @@ -3435,12 +3419,6 @@ dependencies = [ "windows-targets 0.52.6", ] -[[package]] -name = "libm" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8355be11b20d696c8f18f6cc018c4e372165b1fa8126cef092399c9951984ffa" - [[package]] name = "libredox" version = "0.1.3" @@ -3882,23 +3860,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "num-bigint-dig" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc84195820f291c7697304f3cbdadd1cb7199c0efc917ff5eafd71225c136151" -dependencies = [ - "byteorder", - "lazy_static", - "libm", - "num-integer", - "num-iter", - "num-traits", - "rand 0.8.5", - "smallvec", - "zeroize", -] - [[package]] name = "num-conv" version = "0.1.0" @@ -3936,17 +3897,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "num-iter" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - [[package]] name = "num-rational" version = "0.4.2" @@ -3965,7 +3915,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", - "libm", ] [[package]] @@ -4468,15 +4417,6 @@ dependencies = [ "hmac", ] -[[package]] -name = "pem-rfc7468" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412" -dependencies = [ - "base64ct", -] - [[package]] name = "percent-encoding" version = "2.3.1" @@ -4670,27 +4610,6 @@ dependencies = [ "futures-io", ] -[[package]] -name = "pkcs1" -version = "0.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8ffb9f10fa047879315e6625af03c164b16962a5368d724ed16323b68ace47f" -dependencies = [ - "der", - "pkcs8", - "spki", -] - -[[package]] -name = "pkcs8" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" -dependencies = [ - "der", - "spki", -] - [[package]] name = "pkg-config" version = "0.3.31" @@ -5448,27 +5367,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "rsa" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d0e5124fcb30e76a7e79bfee683a2746db83784b86289f6251b54b7950a0dfc" -dependencies = [ - "const-oid", - "digest", - "num-bigint-dig", - "num-integer", - "num-traits", - "pkcs1", - "pkcs8", - "rand_core 0.6.4", - "sha2", - "signature", - "spki", - "subtle", - "zeroize", -] - [[package]] name = "rusqlite" version = "0.31.0" @@ -5575,6 +5473,20 @@ dependencies = [ "sct", ] +[[package]] +name = "rustls" +version = "0.22.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf4ef73721ac7bcd79b2b315da7779d8fc09718c6b3d2d1b2d94850eb8c18432" +dependencies = [ + "log", + "ring", + "rustls-pki-types", + "rustls-webpki 0.102.8", + "subtle", + "zeroize", +] + [[package]] name = "rustls" version = "0.23.16" @@ -5979,16 +5891,6 @@ dependencies = [ "libc", ] -[[package]] -name = "signature" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" -dependencies = [ - "digest", - "rand_core 0.6.4", -] - [[package]] name = "simd-adler32" version = "0.3.7" @@ -6098,16 +6000,6 @@ dependencies = [ "lock_api", ] -[[package]] -name = "spki" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" -dependencies = [ - "base64ct", - "der", -] - [[package]] name = "stable_deref_trait" version = "1.2.0" @@ -6293,6 +6185,20 @@ dependencies = [ "windows 0.52.0", ] +[[package]] +name = "sysinfo" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3b5ae3f4f7d64646c46c4cae4e3f01d1c5d255c7406fdd7c7f999a94e488791" +dependencies = [ + "core-foundation-sys", + "libc", + "memchr", + "ntapi", + "rayon", + "windows 0.56.0", +] + [[package]] name = "system-configuration" version = "0.5.1" @@ -6702,18 +6608,26 @@ dependencies = [ "crypto", "db", "flate2", + "futures-util", + "grpc", "ico", "log", "mac-security-rs", "mdns-sd", + "mime_guess", "obfstr", + "openssl", "plist", "prost", + "rayon", + "reqwest 0.12.9", "rust_search", + "rustls 0.23.16", "serde", "serde_json", "strum", "strum_macros", + "sysinfo 0.32.0", "tar", "tauri", "tauri-icns", @@ -6721,9 +6635,12 @@ dependencies = [ "tauri-plugin-clipboard", "tauri-plugin-network", "tauri-plugin-store", + "tauri-plugin-upload", "tauri-winres", "thiserror 1.0.66", "tokio", + "tokio-stream", + "tokio-util", "tonic", "tonic-build", "tonic-reflection", @@ -6901,7 +6818,7 @@ version = "2.0.8" dependencies = [ "serde", "starship-battery", - "sysinfo", + "sysinfo 0.30.13", "tauri", "tauri-plugin", "thiserror 1.0.66", @@ -6940,9 +6857,8 @@ dependencies = [ [[package]] name = "tauri-plugin-upload" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "116754130d3f95cf73552a0723376186a8f21607ac5ff350980af87a0eccba73" +version = "2.2.1" +source = "git+https://github.com/HuakunShen/tauri-plugins-workspace.git?branch=kunkun#70f6d77c69715683a0b63841b49bf6c0c3b98d4c" dependencies = [ "futures-util", "log", @@ -6952,7 +6868,7 @@ dependencies = [ "serde_json", "tauri", "tauri-plugin", - "thiserror 1.0.66", + "thiserror 2.0.3", "tokio", "tokio-util", ] @@ -7257,6 +7173,17 @@ dependencies = [ "tokio", ] +[[package]] +name = "tokio-rustls" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "775e0c0f0adb3a2f22a00c4745d728b479985fc15ee7ca6a2608388c5569860f" +dependencies = [ + "rustls 0.22.4", + "rustls-pki-types", + "tokio", +] + [[package]] name = "tokio-rustls" version = "0.26.0" @@ -7370,7 +7297,10 @@ dependencies = [ "percent-encoding", "pin-project", "prost", + "rustls-pemfile 2.2.0", + "rustls-pki-types", "tokio", + "tokio-rustls 0.25.0", "tokio-stream", "tower", "tower-layer", diff --git a/Cargo.toml b/Cargo.toml index 2e165db..45caf75 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,6 +8,7 @@ members = [ "packages/mac-security-rs", "packages/tauri-plugins/jarvis", "packages/crypto", + "packages/grpc", ] [workspace.dependencies] @@ -15,6 +16,7 @@ serde = { version = "1", features = ["derive"] } anyhow = "1.0.86" serde_json = "1" tokio = { version = "1.0", features = ["macros", "rt-multi-thread", "signal"] } +tokio-util = "0.7.12" mdns-sd = "0.11.1" tauri-plugin-network = { path = "./vendors/tauri-plugin-network" } tauri-plugin-clipboard = "2.1.8" @@ -24,6 +26,7 @@ strum = "0.26" strum_macros = "0.26" chrono = "0.4.38" applications = { path = "./vendors/applications-rs" } +grpc = { path = "./packages/grpc" } tauri-plugin-jarvis = { path = "./packages/tauri-plugins/jarvis" } tauri-plugin-system-info = { path = "./vendors/tauri-plugin-system-info" } db = { path = "./packages/db" } @@ -35,3 +38,9 @@ reqwest = { version = "0.12", features = ["json", "rustls-tls"] } crypto = { path = "./packages/crypto" } base64 = "0.22.1" obfstr = "0.4.4" +sysinfo = "0.32.0" +openssl = "0.10.68" +tower = { version = "0.4", features = ["util"] } +tower-http = { version = "0.4.0", features = ["fs", "trace", "cors"] } +rayon = "1.10.0" +tauri-plugin-upload = { git = "https://github.com/HuakunShen/tauri-plugins-workspace.git", branch = "kunkun", package = "tauri-plugin-upload" } diff --git a/apps/cli/package.json b/apps/cli/package.json index 8dd72aa..7de5fa4 100644 --- a/apps/cli/package.json +++ b/apps/cli/package.json @@ -30,9 +30,9 @@ "debug": "^4.3.6", "fs-extra": "^11.2.0", "inquirer": "^10.1.2", - "valibot": "^0.40.0" + "valibot": "^1.0.0-beta.8" }, "files": [ "dist" ] -} \ No newline at end of file +} diff --git a/apps/create-kunkun/package.json b/apps/create-kunkun/package.json index 314e834..e4c587e 100644 --- a/apps/create-kunkun/package.json +++ b/apps/create-kunkun/package.json @@ -27,7 +27,7 @@ "commander": "^12.1.0", "fs-extra": "^11.2.0", "handlebars": "^4.7.8", - "valibot": "^0.40.0" + "valibot": "^1.0.0-beta.8" }, "files": [ "dist" diff --git a/apps/desktop/package.json b/apps/desktop/package.json index 8a8c374..ecd4242 100644 --- a/apps/desktop/package.json +++ b/apps/desktop/package.json @@ -24,8 +24,9 @@ "@tauri-apps/api": "^2.1.1", "@tauri-apps/plugin-shell": "^2.0.1", "gsap": "^3.12.5", - "kkrpc": "^0.0.12", + "kkrpc": "^0.0.13", "lz-string": "^1.5.0", + "pretty-bytes": "^6.1.1", "semver": "^7.6.3", "svelte-sonner": "^0.3.28", "sveltekit-superforms": "^2.20.1", diff --git a/apps/desktop/src-tauri/Cargo.toml b/apps/desktop/src-tauri/Cargo.toml index ec90199..6e88b19 100644 --- a/apps/desktop/src-tauri/Cargo.toml +++ b/apps/desktop/src-tauri/Cargo.toml @@ -40,7 +40,8 @@ tauri-plugin-dialog = "2.0.1" tauri-plugin-notification = "2.0.1" tauri-plugin-os = "2.0.1" tauri-plugin-http = "2.0.1" -tauri-plugin-upload = "2.0.1" +tauri-plugin-upload = { workspace = true } +# tauri-plugin-upload = "2.2.1" tauri-plugin-jarvis = { workspace = true } tauri-plugin-network = { workspace = true } tauri-plugin-system-info = { workspace = true } @@ -48,6 +49,7 @@ tauri-plugin-clipboard = { workspace = true } tauri-plugin-store = "2.1.0" tauri-plugin-deep-link = "2" tauri-plugin-log = { version = "2.0.1", features = ["colored"] } +crypto = { workspace = true } zip = "2.1.3" uuid = "1.11.0" # tauri-plugin-devtools = "2.0.0" diff --git a/apps/desktop/src-tauri/src/lib.rs b/apps/desktop/src-tauri/src/lib.rs index ecadf7f..b870223 100644 --- a/apps/desktop/src-tauri/src/lib.rs +++ b/apps/desktop/src-tauri/src/lib.rs @@ -173,8 +173,11 @@ pub fn run() { )); app.manage(tauri_plugin_jarvis::model::app_state::AppState {}); tauri_plugin_jarvis::setup::server::setup_server(app.handle())?; // start the server - - let mdns = tauri_plugin_jarvis::setup::peer_discovery::setup_mdns(my_port)?; + let jarvis_state = app.state::(); + let mdns = tauri_plugin_jarvis::setup::peer_discovery::setup_mdns( + my_port, + crypto::RsaCrypto::public_key_to_string(&jarvis_state.rsa_public_key), + )?; tauri_plugin_jarvis::setup::peer_discovery::handle_mdns_service_evt( app.handle(), mdns.browse()?, diff --git a/apps/desktop/src-tauri/tauri.conf.json b/apps/desktop/src-tauri/tauri.conf.json index 6d03a5d..ef42742 100644 --- a/apps/desktop/src-tauri/tauri.conf.json +++ b/apps/desktop/src-tauri/tauri.conf.json @@ -36,6 +36,9 @@ ] }, "plugins": { + "fs": { + "requireLiteralLeadingDot": false + }, "updater": { "endpoints": ["https://updater.kunkun.sh"], "pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDc1NENCRjZFM0JBOEQ0ODMKUldTRDFLZzdicjlNZFhHS0ZKYk13WkdZUTFUM01LNjkvVW5Bb2x1SnB1R0crbFRuMnlRSlJ0STgK" diff --git a/apps/desktop/src/lib/cmds/builtin.ts b/apps/desktop/src/lib/cmds/builtin.ts index f34cddb..f9f0b01 100644 --- a/apps/desktop/src/lib/cmds/builtin.ts +++ b/apps/desktop/src/lib/cmds/builtin.ts @@ -73,6 +73,18 @@ export const rawBuiltinCmds: BuiltinCmd[] = [ }, 2_000) } }, + { + name: "File Transfer", + icon: { + type: IconEnum.Iconify, + value: "clarity:file-share-solid" + }, + description: "", + function: async () => { + goto("/extension/file-transfer") + appState.clearSearchTerm() + } + }, { name: "Add Dev Extension", icon: { diff --git a/apps/desktop/src/lib/components/common/DragNDrop.svelte b/apps/desktop/src/lib/components/common/DragNDrop.svelte index c74dbce..0cea233 100644 --- a/apps/desktop/src/lib/components/common/DragNDrop.svelte +++ b/apps/desktop/src/lib/components/common/DragNDrop.svelte @@ -1,5 +1,5 @@ + + + +
+
+ {#if progresses.length > 0} + {#each progresses as progress} + {@const progressPerc = Math.round((progress.progressBytes / progress.totalBytes) * 100)} +
+ + {progressPerc}% + {prettyBytes(progress.transferSpeedBytesPerSecond)}ps +
+ {/each} + {/if} + + + (dragging = true)} onCancelled={() => (dragging = false)}> + + + {#if files.length > 0} +
+
Total Files: {previewBucketInfo?.total_files ?? 0}
+
Total Bytes: {prettyBytes(
+								previewBucketInfo?.total_bytes ?? 0
+							)}
+
+
+
+ {#each files as file} + { + files = files.filter((f) => f !== file) + }} + /> + {/each} +
+
+ {/if} +
+
+
+
+ + + Peers in local network + + + Hostname + Addreess + Port + Send + + + + {#each Object.values(peers) as peer} + + {peer.hostname} + {peer.addresses[0]} + {peer.port} + + + + + {/each} + + +
+
diff --git a/apps/desktop/src/routes/extension/file-transfer/file-icon.svelte b/apps/desktop/src/routes/extension/file-transfer/file-icon.svelte new file mode 100644 index 0000000..ca836cb --- /dev/null +++ b/apps/desktop/src/routes/extension/file-transfer/file-icon.svelte @@ -0,0 +1,35 @@ + + + + + {#if isDirectory} + + {:else} + + {/if} + + + +
{filepath}
+ +
+
diff --git a/apps/desktop/src/routes/extension/ui-iframe/+page.svelte b/apps/desktop/src/routes/extension/ui-iframe/+page.svelte index a7f0389..cd92fe7 100644 --- a/apps/desktop/src/routes/extension/ui-iframe/+page.svelte +++ b/apps/desktop/src/routes/extension/ui-iframe/+page.svelte @@ -63,6 +63,7 @@ uiControl.showMoveBtn = false }, hideRefreshButton: async () => { + console.log("hideRefreshButton") uiControl.showRefreshBtn = false }, showBackButton: async (position?: Position) => { @@ -153,7 +154,7 @@ -{#if uiControl.backBtnPosition} +{#if uiControl.backBtnPosition && uiControl.showBackBtn} {/if} -{#if uiControl.refreshBtnPosition} +{#if uiControl.refreshBtnPosition && uiControl.showRefreshBtn}