This is an automated email from the ASF dual-hosted git repository.

Xuanwo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/opendal-reqsign.git


The following commit(s) were added to refs/heads/main by this push:
     new 8209939  refactor: make reqsign-core jwt optional (#773)
8209939 is described below

commit 820993984923471cc410b9947c8550d2468df645
Author: tison <[email protected]>
AuthorDate: Sat Jul 4 12:29:39 2026 +0800

    refactor: make reqsign-core jwt optional (#773)
---
 Cargo.toml                          |  1 +
 core/Cargo.toml                     | 12 ++++++++----
 core/src/lib.rs                     |  2 +-
 services/azure-storage/Cargo.toml   |  3 ++-
 services/google/Cargo.toml          |  3 +++
 services/google/src/sign_request.rs |  4 ++--
 6 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/Cargo.toml b/Cargo.toml
index 20c35c1..92632ed 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -54,6 +54,7 @@ hmac = "0.13"
 http = "1"
 jiff = "0.2"
 log = "0.4"
+pem = "3.0"
 percent-encoding = "2"
 pretty_assertions = "1.3"
 quick-xml = { version = "0.40.0", features = ["serialize"] }
diff --git a/core/Cargo.toml b/core/Cargo.toml
index 0437cfc..0aeb6a3 100644
--- a/core/Cargo.toml
+++ b/core/Cargo.toml
@@ -27,6 +27,10 @@ license.workspace = true
 repository.workspace = true
 rust-version.workspace = true
 
+[features]
+default = []
+jwt = ["dep:rsa", "dep:serde", "dep:serde_json"]
+
 [dependencies]
 anyhow = { workspace = true }
 base64 = { workspace = true }
@@ -42,10 +46,10 @@ percent-encoding = { workspace = true }
 sha1 = { workspace = true }
 sha2 = { workspace = true }
 
-[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
-rsa = { workspace = true }
-serde = { workspace = true }
-serde_json = { workspace = true }
+# Optional dependencies
+rsa = { workspace = true, optional = true }
+serde = { workspace = true, optional = true }
+serde_json = { workspace = true, optional = true }
 
 [target.'cfg(target_os = "windows")'.dependencies]
 windows-sys = { version = "0.61.0", features = [
diff --git a/core/src/lib.rs b/core/src/lib.rs
index 9ed35c5..00b96f5 100644
--- a/core/src/lib.rs
+++ b/core/src/lib.rs
@@ -153,7 +153,7 @@
 pub mod error;
 mod futures_util;
 pub mod hash;
-#[cfg(not(target_arch = "wasm32"))]
+#[cfg(all(not(target_arch = "wasm32"), feature = "jwt"))]
 pub mod jwt;
 pub mod time;
 pub mod utils;
diff --git a/services/azure-storage/Cargo.toml 
b/services/azure-storage/Cargo.toml
index b9bb058..00cafd0 100644
--- a/services/azure-storage/Cargo.toml
+++ b/services/azure-storage/Cargo.toml
@@ -40,8 +40,9 @@ serde_json = { workspace = true }
 sha1 = { workspace = true }
 
 [target.'cfg(not(target_arch = "wasm32"))'.dependencies]
-pem = "3.0"
+pem = { workspace = true }
 rsa = { workspace = true }
+reqsign-core = { workspace = true, features = ["jwt"] }
 
 [dev-dependencies]
 env_logger = { workspace = true }
diff --git a/services/google/Cargo.toml b/services/google/Cargo.toml
index edaa389..c23a863 100644
--- a/services/google/Cargo.toml
+++ b/services/google/Cargo.toml
@@ -38,6 +38,9 @@ serde = { workspace = true }
 serde_json = { workspace = true }
 tokio = { workspace = true, features = ["time"] }
 
+[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
+reqsign-core = { workspace = true, features = ["jwt"] }
+
 [dev-dependencies]
 bytes = { workspace = true }
 dotenvy = { workspace = true }
diff --git a/services/google/src/sign_request.rs 
b/services/google/src/sign_request.rs
index 583382e..dcec4e9 100644
--- a/services/google/src/sign_request.rs
+++ b/services/google/src/sign_request.rs
@@ -28,7 +28,7 @@ use std::time::Duration;
 
 use reqsign_core::{
     Context, Result, SignRequest, SigningCredential, SigningMethod, 
SigningRequest,
-    hash::hex_sha256, jwt, time::*,
+    hash::hex_sha256, time::*,
 };
 
 use crate::constants::{DEFAULT_SCOPE, GOOG_QUERY_ENCODE_SET, 
GOOG_URI_ENCODE_SET, GOOGLE_SCOPE};
@@ -147,7 +147,7 @@ impl RequestSigner {
 
         debug!("exchanging service account for token with scope: {scope}");
 
-        let jwt = jwt::encode_rs256_pem(
+        let jwt = reqsign_core::jwt::encode_rs256_pem(
             &JwtHeader::rs256(),
             &Claims::new(&sa.client_email, &scope),
             sa.private_key.as_bytes(),

Reply via email to