Skip to content

Commit

Permalink
fix: more features
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniPopes committed Sep 26, 2024
1 parent c0802ad commit dff4d1f
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 13 deletions.
5 changes: 2 additions & 3 deletions crates/rpc-client/src/builtin.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
use std::str::FromStr;

use alloy_json_rpc::RpcError;
use alloy_transport::{BoxTransport, BoxTransportConnect, TransportError, TransportErrorKind};
use std::str::FromStr;

#[cfg(feature = "pubsub")]
#[cfg(any(feature = "ws", feature = "ipc"))]
use alloy_pubsub::PubSubConnect;

/// Connection string for built-in transports.
Expand Down
13 changes: 8 additions & 5 deletions crates/rpc-types-engine/src/jwt.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
//! JWT (JSON Web Token) utilities for the Engine API.

use alloc::{format, string::String};
use alloc::string::String;
use alloy_primitives::hex;
use core::{str::FromStr, time::Duration};
use jsonwebtoken::{
decode, errors::ErrorKind, get_current_timestamp, Algorithm, DecodingKey, Validation,
};
use jsonwebtoken::get_current_timestamp;
use rand::Rng;

#[cfg(feature = "std")]
use std::{
fs, io,
path::{Path, PathBuf},
};

#[cfg(feature = "serde")]
use jsonwebtoken::{errors::ErrorKind, Algorithm, DecodingKey, Validation};

/// Errors returned by the [`JwtSecret`]
#[derive(Debug, derive_more::Display)]
pub enum JwtError {
Expand Down Expand Up @@ -106,6 +108,7 @@ const JWT_SECRET_LEN: usize = 64;
const JWT_MAX_IAT_DIFF: Duration = Duration::from_secs(60);

/// The execution layer client MUST support at least the following alg HMAC + SHA256 (HS256)
#[cfg(feature = "serde")]
const JWT_SIGNATURE_ALGO: Algorithm = Algorithm::HS256;

/// Claims in JWT are used to represent a set of information about an entity.
Expand Down Expand Up @@ -223,7 +226,7 @@ impl JwtSecret {
validation.set_required_spec_claims(&["iat"]);
let bytes = &self.0;

match decode::<Claims>(jwt, &DecodingKey::from_secret(bytes), &validation) {
match jsonwebtoken::decode::<Claims>(jwt, &DecodingKey::from_secret(bytes), &validation) {
Ok(token) => {
if !token.claims.is_within_time_window() {
Err(JwtError::InvalidIssuanceTimestamp)?
Expand Down
2 changes: 2 additions & 0 deletions crates/rpc-types-engine/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
#![cfg_attr(not(feature = "std"), no_std)]

#[macro_use]
#[allow(unused_imports)]
extern crate alloc;

mod cancun;
Expand Down
2 changes: 1 addition & 1 deletion crates/rpc-types-eth/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ arbitrary = [
"std",
"dep:arbitrary",
"alloy-primitives/arbitrary",
"alloy-serde/arbitrary",
"alloy-serde?/arbitrary",
"alloy-eips/arbitrary",
]
jsonrpsee-types = ["dep:jsonrpsee-types"]
Expand Down
2 changes: 1 addition & 1 deletion crates/rpc-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ rustdoc-args = ["--cfg", "docsrs"]
workspace = true

[dependencies]
alloy-primitives.workspace = true
alloy-primitives = { workspace = true, features = ["map"] }
alloy-serde.workspace = true
alloy-rpc-types-admin = { workspace = true, optional = true }
alloy-rpc-types-anvil = { workspace = true, optional = true }
Expand Down
10 changes: 7 additions & 3 deletions crates/signer-local/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ thiserror.workspace = true
async-trait.workspace = true

# keystore
elliptic-curve = { workspace = true, optional = true }
eth-keystore = { version = "0.5.0", default-features = false, optional = true }

# mnemonic
Expand All @@ -40,7 +39,12 @@ coins-bip39 = { version = "0.12", default-features = false, features = [
], optional = true }

# yubi
yubihsm = { version = "0.42", features = ["secp256k1", "http", "usb"], optional = true }
elliptic-curve = { workspace = true, optional = true }
yubihsm = { version = "0.42", features = [
"secp256k1",
"http",
"usb",
], optional = true }

[dev-dependencies]
alloy-dyn-abi.workspace = true
Expand All @@ -57,7 +61,7 @@ tokio = { workspace = true, features = ["macros", "rt-multi-thread"] }
yubihsm = { version = "0.42", features = ["mockhsm"] }

[features]
keystore = ["dep:eth-keystore", "dep:elliptic-curve"]
keystore = ["dep:eth-keystore"]
keystore-geth-compat = ["keystore", "eth-keystore?/geth-compat"]
mnemonic = ["dep:coins-bip32", "dep:coins-bip39"]
mnemonic-all-languages = ["mnemonic", "coins-bip39?/all-langs"]
Expand Down

0 comments on commit dff4d1f

Please sign in to comment.