Skip to content

Commit 518e3d3

Browse files
feat: update identity_* dependencies to v1.6.0-beta.2 (#38)
Co-authored-by: Daniel Mader <[email protected]>
1 parent 6e98b11 commit 518e3d3

File tree

19 files changed

+186
-64
lines changed

19 files changed

+186
-64
lines changed

Cargo.toml

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,20 @@ repository = "https://github.com/impierce/did-manager"
3131
rust-version = "1.75"
3232

3333
[workspace.dependencies]
34-
identity_iota = { version = "1.5", default-features = false, features = ["resolver", "iota-client"] }
35-
identity_storage = { version = "1.5", default-features = false }
36-
identity_stronghold = { version = "1.5", features = ["send-sync-storage"] }
37-
identity_verification = { version = "1.5", default-features = false }
38-
iota-sdk = { version = "1.1", features = ["stronghold"] }
34+
identity_iota = { git = "https://github.com/iotaledger/identity", tag = "v1.6.0-beta.2", default-features = false, features = [
35+
"resolver",
36+
"iota-client",
37+
"send-sync",
38+
] }
39+
identity_storage = { git = "https://github.com/iotaledger/identity", tag = "v1.6.0-beta.2", default-features = false }
40+
identity_stronghold = { git = "https://github.com/iotaledger/identity", tag = "v1.6.0-beta.2", features = [
41+
"send-sync-storage",
42+
] }
43+
identity_verification = { git = "https://github.com/iotaledger/identity", tag = "v1.6.0-beta.2", default-features = false }
44+
iota-sdk = { git = "https://github.com/impierce/iota", package = "iota-sdk", branch = "temp/fix" }
45+
iota-sdk-legacy = { package = "iota-sdk", version = "1.1", features = [
46+
"stronghold",
47+
] }
3948
iota_stronghold = { version = "2.1" }
4049
log = "0.4"
4150
rand = "0.8"
@@ -48,4 +57,18 @@ ssi-jwk = { version = "0.1.2", default-features = false, features = [
4857
] }
4958
test-log = "0.2"
5059
thiserror = "1.0"
51-
tokio = { version = "1", features = ["full"] }
60+
tokio = { version = "1.43", features = ["full"] }
61+
62+
# TODO: Remove these patches once configuratble TLS is available in `iota-sdk`
63+
[patch.'https://github.com/iotaledger/iota']
64+
iota-sdk = { git = "https://github.com/impierce/iota", package = "iota-sdk", branch = "temp/fix" }
65+
move-core-types = { git = "https://github.com/impierce/iota.git", package = "move-core-types", branch = "temp/fix" }
66+
shared-crypto = { git = "https://github.com/impierce/iota.git", package = "shared-crypto", branch = "temp/fix" }
67+
iota-network-stack = { git = "https://github.com/impierce/iota.git", package = "iota-network-stack", branch = "temp/fix" }
68+
iota-types = { git = "https://github.com/impierce/iota.git", package = "iota-types", branch = "temp/fix" }
69+
iota-metrics = { git = "https://github.com/impierce/iota.git", package = "iota-metrics", branch = "temp/fix" }
70+
move-binary-format = { git = "https://github.com/impierce/iota.git", package = "move-binary-format", branch = "temp/fix" }
71+
iota-protocol-config = { git = "https://github.com/impierce/iota.git", package = "iota-protocol-config", branch = "temp/fix" }
72+
move-vm-config = { git = "https://github.com/impierce/iota.git", package = "move-vm-config", branch = "temp/fix" }
73+
iota-adapter-latest = { git = "https://github.com/impierce/iota.git", package = "iota-adapter-latest", branch = "temp/fix" }
74+
iota-execution = { git = "https://github.com/impierce/iota.git", package = "iota-execution", branch = "temp/fix" }

consumer/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ did_web = { path = "../did_web" }
1515
shared = { path = "../shared" }
1616

1717
identity_iota.workspace = true
18+
rustls = { version = "0.23", features = ["ring"] }
1819
signature.workspace = true
1920
tokio.workspace = true
2021

consumer/src/resolver.rs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,21 @@ use identity_iota::document::CoreDocument;
77
use identity_iota::resolver::Resolver as IdentityResolver;
88
use shared::error::ConsumerError;
99

10+
#[derive(Debug)]
1011
pub struct Resolver {
1112
pub(crate) resolver: IdentityResolver,
1213
}
1314

1415
impl Resolver {
1516
pub async fn new() -> Self {
16-
let resolver = configure_resolver(IdentityResolver::new())
17+
let resolver = configure_resolver(IdentityResolver::new(), None)
18+
.await
19+
.expect("Failed to configure resolver");
20+
Self { resolver }
21+
}
22+
23+
pub async fn new_with_tls_config(tls_config: rustls::ClientConfig) -> Self {
24+
let resolver = configure_resolver(IdentityResolver::new(), Some(tls_config))
1725
.await
1826
.expect("Failed to configure resolver");
1927
Self { resolver }
@@ -26,11 +34,18 @@ impl Resolver {
2634
}
2735
}
2836

29-
async fn configure_resolver(mut resolver: IdentityResolver) -> Result<IdentityResolver, ConsumerError> {
37+
async fn configure_resolver(
38+
mut resolver: IdentityResolver,
39+
tls_config: Option<rustls::ClientConfig>,
40+
) -> Result<IdentityResolver, ConsumerError> {
3041
resolver.attach_handler("jwk".to_owned(), resolve_did_jwk);
3142
resolver.attach_handler("key".to_owned(), resolve_did_key);
3243
resolver.attach_handler("web".to_owned(), resolve_did_web);
33-
resolver.attach_multiple_iota_handlers(iota_clients().await?);
44+
resolver.attach_multiple_iota_handlers(
45+
iota_clients(tls_config)
46+
.await
47+
.map_err(|e| ConsumerError::Generic(format!("Failed to attach IOTA handlers: {e}")))?,
48+
);
3449

3550
Ok(resolver)
3651
}

did_iota/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,16 @@ rust-version.workspace = true
1010
[dependencies]
1111
shared = { path = "../shared" }
1212

13+
anyhow = "1.0"
1314
identity_iota.workspace = true
1415
identity_stronghold.workspace = true
1516
iota-sdk.workspace = true
1617
log.workspace = true
18+
rustls = { version = "0.23", features = ["ring"] }
1719
tokio.workspace = true
1820

1921
[dev-dependencies]
22+
iota-sdk-legacy.workspace = true
2023
iota_stronghold = { version = "2.1" }
2124
serde_json.workspace = true
2225
test-log.workspace = true

did_iota/src/consumer.rs

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,38 @@
1-
use iota_sdk::client::error::Error;
2-
use iota_sdk::client::Client;
3-
4-
static MAINNET_URL: &str = "https://api.stardust-mainnet.iotaledger.net";
5-
static SHIMMER_URL: &str = "https://api.shimmer.network";
6-
static TESTNET_URL: &str = "https://api.testnet.shimmer.network";
1+
use identity_iota::iota::rebased::client::IdentityClientReadOnly;
2+
use identity_iota::iota::rebased::Error;
3+
use iota_sdk::IotaClientBuilder;
74

85
/// Builds clients for all IOTA networks.
9-
pub async fn iota_clients() -> Result<Vec<(&'static str, Client)>, Error> {
10-
let mainnet_client: Client = Client::builder().with_primary_node(MAINNET_URL, None)?.finish().await?;
11-
let shimmer_client: Client = Client::builder().with_primary_node(SHIMMER_URL, None)?.finish().await?;
12-
let testnet_client: Client = Client::builder().with_primary_node(TESTNET_URL, None)?.finish().await?;
6+
pub async fn iota_clients(
7+
tls_config: Option<rustls::ClientConfig>,
8+
) -> Result<Vec<(&'static str, IdentityClientReadOnly)>, Error> {
9+
let mut iota_testnet_client_builder = IotaClientBuilder::default();
10+
11+
if let Some(tls_config) = &tls_config {
12+
iota_testnet_client_builder = iota_testnet_client_builder.tls_config(tls_config.clone());
13+
}
14+
15+
let iota_testnet = iota_testnet_client_builder.build_testnet().await?;
16+
17+
let mut iota_devnet_client_builder = IotaClientBuilder::default();
18+
19+
if let Some(tls_config) = &tls_config {
20+
iota_devnet_client_builder = iota_devnet_client_builder.tls_config(tls_config.clone());
21+
}
22+
23+
let iota_devnet = iota_devnet_client_builder.build_devnet().await?;
24+
25+
let mut iota_mainnet_client_builder = IotaClientBuilder::default();
26+
27+
if let Some(tls_config) = tls_config {
28+
iota_mainnet_client_builder = iota_mainnet_client_builder.tls_config(tls_config);
29+
}
30+
31+
let iota_mainnet = iota_mainnet_client_builder.build_mainnet().await?;
1332

1433
Ok(vec![
15-
("iota", mainnet_client),
16-
("smr", shimmer_client),
17-
("rms", testnet_client),
34+
("testnet", IdentityClientReadOnly::new(iota_testnet).await?),
35+
("devnet", IdentityClientReadOnly::new(iota_devnet).await?),
36+
("iota", IdentityClientReadOnly::new(iota_mainnet).await?),
1837
])
1938
}

did_iota/src/producer/produce.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
use identity_iota::{
22
core::{FromJson, ToJson},
33
document::CoreDocument,
4-
iota::{IotaDID, NetworkName},
4+
iota::IotaDID,
55
verification::{jwk::Jwk, jws::JwsAlgorithm},
66
};
77
use log::{debug, info};
88
use shared::{error::ProducerError, JwkStorageWrapper};
99

1010
use crate::producer::resolve::resolve;
1111

12+
// TODO: Remove `Testnet` and `Shimmer`. Add `Devnet`.
1213
pub enum IotaMethod {
1314
Testnet,
1415
Shimmer,
@@ -27,23 +28,22 @@ pub async fn produce_did_iota(
2728
) -> Result<CoreDocument, ProducerError> {
2829
let public_key_jwk = storage.get_public_key(key_id, alg).await?;
2930

30-
let _ = match iota_method {
31+
match iota_method {
3132
IotaMethod::Testnet => {
3233
info!("Producing `did:iota:rms` for key_id `{key_id}` ({alg}) ...");
33-
NetworkName::try_from("rms").expect("Invalid network")
3434
}
3535
IotaMethod::Shimmer => {
3636
info!("Producing `did:iota:smr` for key_id `{key_id}` ({alg}) ...");
37-
NetworkName::try_from("smr").expect("Invalid network")
3837
}
3938
IotaMethod::Mainnet => {
4039
info!("Producing `did:iota` for key_id `{key_id}` ({alg}) ...");
41-
NetworkName::try_from("iota").expect("Invalid network")
4240
}
4341
};
4442

4543
// Sanity check: Can the document be resolved from the ledger?
46-
let published_document = resolve(managed_did).await?;
44+
let published_document = resolve(managed_did)
45+
.await
46+
.map_err(|e| ProducerError::Generic(e.to_string()))?;
4747

4848
// Sanity check: Is the method in the document?
4949
let verification_method = published_document.resolve_method(&managed_fragment, None).unwrap();
@@ -66,14 +66,15 @@ mod tests {
6666
use super::*;
6767

6868
use identity_stronghold::StrongholdStorage;
69-
use iota_sdk::client::{secret::stronghold::StrongholdSecretManager, Password};
69+
use iota_sdk_legacy::client::{secret::stronghold::StrongholdSecretManager, Password};
7070
use serde_json::json;
7171
use test_log::test;
7272

7373
const SNAPSHOT_PATH: &str = "../shared/tests/res/selv.stronghold";
7474
const PASSWORD: &str = "VNvRtH4tKyWwvJDpL6Vuc2aoLiKAecGQ";
7575
const KEY_ID: &str = "UVDxWhG2rB39FkaR7I27mHeUNrGtUgcr";
7676

77+
#[ignore = "This test needs to be updated to use `Devnet`"]
7778
#[test(tokio::test)]
7879
async fn produce_did_iota_testnet() {
7980
let stronghold_adapter = StrongholdSecretManager::builder()

did_iota/src/producer/resolve.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
use identity_iota::{
2-
document::CoreDocument,
3-
iota::IotaDID,
4-
resolver::{Error, Resolver},
5-
};
1+
use identity_iota::{document::CoreDocument, iota::IotaDID, resolver::Resolver};
62

73
use crate::consumer::iota_clients;
84

9-
pub async fn resolve(did: IotaDID) -> Result<CoreDocument, Error> {
5+
pub async fn resolve(did: IotaDID) -> Result<CoreDocument, anyhow::Error> {
106
let mut resolver = Resolver::<CoreDocument>::new();
11-
resolver.attach_multiple_iota_handlers(iota_clients().await.unwrap());
7+
resolver.attach_multiple_iota_handlers(iota_clients(None).await.unwrap());
128
let document = resolver.resolve(&did).await?;
139
Ok(document)
1410
}

did_web/src/consumer.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ pub async fn resolve_did_web(did: CoreDID) -> Result<CoreDocument, ConsumerError
1313
let (result, document, metadata) = resolver.resolve(did.as_str(), &input_metadata).await;
1414

1515
if let Some(error) = result.error.clone() {
16-
info!("Error: {:?}", error);
16+
info!("Error: {error:?}");
1717
return Err(ConsumerError::Generic(error));
1818
}
1919

20-
debug!("Result: {:#?}", result);
21-
debug!("Document: {:#?}", document);
22-
debug!("Metadata: {:#?}", metadata);
20+
debug!("Result: {result:#?}");
21+
debug!("Document: {document:#?}");
22+
debug!("Metadata: {metadata:#?}");
2323
CoreDocument::from_json(&document.to_json().unwrap()).map_err(|e| ConsumerError::Generic(e.to_string()))
2424
}
2525

did_web/src/producer.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ pub async fn produce_did_web(
4747
// Omit default HTTPS port
4848
let host_port_encoded = match port {
4949
443 => host.to_string(),
50-
_ => urlencoding::encode(format!("{}:{}", host, port).as_str()).to_string(),
50+
_ => urlencoding::encode(format!("{host}:{port}").as_str()).to_string(),
5151
};
5252

53-
let did_str = format!("did:web:{}", host_port_encoded);
53+
let did_str = format!("did:web:{host_port_encoded}");
5454

5555
info!("DID: `{did_str}`");
5656

@@ -76,7 +76,7 @@ pub async fn produce_did_web(
7676

7777
info!("Host the following json under the following url:");
7878
info!("================================================");
79-
info!("{}", well_known);
79+
info!("{well_known}");
8080
info!("================================================");
8181
info!("{}", document.to_json_pretty().unwrap());
8282
info!("================================================");

identity_stronghold_ext/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@ async-trait = { version = "0.1.64", default-features = false }
1313
elliptic-curve = { version = "0.13", features = ["jwk"] }
1414
identity_storage.workspace = true
1515
identity_verification.workspace = true
16-
iota-sdk.workspace = true
16+
iota-sdk-legacy.workspace = true
1717
iota_stronghold.workspace = true
1818
k256 = { version = "0.13", features = ["jwk"] }
1919
log.workspace = true
2020
p256 = { version = "0.13", features = ["jwk"] }
2121
serde_json.workspace = true
22+
secret-storage = { git = "https://github.com/iotaledger/secret-storage", tag = "v0.3.0" }
2223
stronghold_ext = { git = "https://github.com/impierce/stronghold_ext.git", features = [
2324
"crypto",
2425
] }

0 commit comments

Comments
 (0)