From c5a671be48fbb5579e315b02181e1a101f6410d1 Mon Sep 17 00:00:00 2001 From: Yasir Date: Tue, 18 Jun 2024 11:42:36 +0300 Subject: [PATCH 1/8] chore(grpc): change response for the endpoints --- bindings/grpc/proto/domain_linkage.proto | 77 ++++--- bindings/grpc/src/services/domain_linkage.rs | 200 +++++++++++------- bindings/grpc/tests/api/main.rs | 2 +- .../.well-known/did-configuration.json | 2 +- bindings/grpc/tooling/start-rpc-server.sh | 6 +- examples/1_advanced/6_domain_linkage.rs | 8 +- 6 files changed, 182 insertions(+), 113 deletions(-) diff --git a/bindings/grpc/proto/domain_linkage.proto b/bindings/grpc/proto/domain_linkage.proto index f2fe3426df..1ff4dcc045 100644 --- a/bindings/grpc/proto/domain_linkage.proto +++ b/bindings/grpc/proto/domain_linkage.proto @@ -4,6 +4,50 @@ syntax = "proto3"; package domain_linkage; +message ValidDomain { + string service_id = 1; + string url = 2; + string credential = 3; +} + +message InvalidDomain { + string service_id = 1; + optional string credential = 2; + string url = 3; + string error = 4; +} + +message ValidateDidResponse { + string did = 1; + message Domains { + repeated ValidDomain valid = 1; + repeated InvalidDomain invalid = 2; + } + Domains domains = 2; +} + +message ValidDid { + string service_id = 1; + string did = 2; + string credential = 3; +} + +message InvalidDid { + optional string service_id = 1; + optional string credential = 2; + optional string did = 3; + string error = 4; +} + +message ValidateDomainResponse { + string domain = 1; + message LinkedDid { + repeated ValidDid valid = 1; + repeated InvalidDid invalid = 2; + } + LinkedDid linked_dids = 2; +} + message ValidateDomainRequest { // domain to validate string domain = 1; @@ -16,27 +60,6 @@ message ValidateDomainAgainstDidConfigurationRequest { string did_configuration = 2; } -message LinkedDidValidationStatus { - // validation succeeded or not, `error` property is added for `false` cases - bool valid = 1; - // credential from `linked_dids` as compact JWT domain linkage credential if it could be retrieved - optional string document = 2; - // an error message, that occurred when validated, omitted if valid - optional string error = 3; -} - -message ValidateDomainResponse { - // list of JWT domain linkage credential, uses the same order as the `did-configuration.json` file for domain - repeated LinkedDidValidationStatus linked_dids = 1; -} - -message LinkedDidEndpointValidationStatus { - // id of service endpoint entry - string id = 1; - // list of JWT domain linkage credential, uses the same order as the `did-configuration.json` file for domain - repeated LinkedDidValidationStatus service_endpoint = 2; -} - message ValidateDidRequest { // DID to validate string did = 1; @@ -49,15 +72,13 @@ message ValidateDidAgainstDidConfigurationsRequest { repeated ValidateDomainAgainstDidConfigurationRequest did_configurations = 2; } -message ValidateDidResponse { - // mapping of service entries from DID with validation status for endpoint URLs - repeated LinkedDidEndpointValidationStatus service = 1; -} - service DomainLinkage { rpc validate_domain(ValidateDomainRequest) returns (ValidateDomainResponse); - rpc validate_domain_against_did_configuration(ValidateDomainAgainstDidConfigurationRequest) returns (ValidateDomainResponse); + rpc validate_domain_against_did_configuration( + ValidateDomainAgainstDidConfigurationRequest) + returns (ValidateDomainResponse); rpc validate_did(ValidateDidRequest) returns (ValidateDidResponse); - rpc validate_did_against_did_configurations(ValidateDidAgainstDidConfigurationsRequest) returns (ValidateDidResponse); + rpc validate_did_against_did_configurations( + ValidateDidAgainstDidConfigurationsRequest) returns (ValidateDidResponse); } \ No newline at end of file diff --git a/bindings/grpc/src/services/domain_linkage.rs b/bindings/grpc/src/services/domain_linkage.rs index 3c3935a413..1b9e6dfb0b 100644 --- a/bindings/grpc/src/services/domain_linkage.rs +++ b/bindings/grpc/src/services/domain_linkage.rs @@ -6,16 +6,16 @@ use std::error::Error; use domain_linkage::domain_linkage_server::DomainLinkage; use domain_linkage::domain_linkage_server::DomainLinkageServer; -use domain_linkage::LinkedDidEndpointValidationStatus; -use domain_linkage::LinkedDidValidationStatus; -use domain_linkage::ValidateDidAgainstDidConfigurationsRequest; -use domain_linkage::ValidateDidRequest; -use domain_linkage::ValidateDidResponse; -use domain_linkage::ValidateDomainAgainstDidConfigurationRequest; +use domain_linkage::validate_did_response::Domains; +use domain_linkage::validate_domain_response::LinkedDid; use domain_linkage::ValidateDomainRequest; use domain_linkage::ValidateDomainResponse; +use domain_linkage::{InvalidDid, ValidateDidAgainstDidConfigurationsRequest}; +use domain_linkage::{InvalidDomain, ValidateDomainAgainstDidConfigurationRequest}; +use domain_linkage::{ValidDid, ValidateDidRequest}; +use domain_linkage::{ValidDomain, ValidateDidResponse}; use futures::stream::FuturesOrdered; -use futures::TryStreamExt; +use futures::{StreamExt, TryStreamExt}; use identity_eddsa_verifier::EdDSAJwsVerifier; use identity_iota::core::FromJson; use identity_iota::core::Url; @@ -90,11 +90,15 @@ impl DomainValidationConfig { } /// Builds a validation status for a failed validation from an `Error`. -fn get_validation_failed_status(message: &str, err: &impl Error) -> LinkedDidValidationStatus { - LinkedDidValidationStatus { - valid: false, - document: None, - error: Some(format!("{}; {}", message, &err.to_string())), +fn get_linked_did_validation_failed_status(message: &str, err: &impl Error) -> LinkedDid { + LinkedDid { + valid: vec![], + invalid: vec![InvalidDid { + service_id: None, + credential: None, + did: None, + error: format!("{}: {}", message, err), + }], } } @@ -121,8 +125,7 @@ impl DomainLinkageService { &self, did: &IotaDID, did_configurations: Option>, - ) -> Result, DomainLinkageError> { - // fetch DID document for given DID + ) -> Result { let did_document = self .resolver .resolve(did) @@ -144,36 +147,64 @@ impl DomainLinkageService { None => HashMap::new(), }; - // check validation for all services and endpoints in them - let mut service_futures = FuturesOrdered::new(); + let mut futures = vec![]; + for service in services { let service_id: CoreDID = did.clone().into(); let domains: Vec = service.domains().into(); - let local_config_map = config_map.clone(); - service_futures.push_back(async move { - let mut domain_futures = FuturesOrdered::new(); - for domain in domains { - let config = local_config_map.get(&domain.origin()).map(|value| value.to_owned()); - domain_futures.push_back(self.validate_domains_with_optional_configuration( - domain.clone(), - Some(did.clone().into()), - config, - )); - } - domain_futures - .try_collect::>>() - .await - .map(|value| LinkedDidEndpointValidationStatus { - id: service_id.to_string(), - service_endpoint: value.into_iter().flatten().collect(), - }) - }); + for domain in domains { + let config = config_map.get(&domain.origin()).cloned(); + let service_id_clone = service_id.clone(); + futures.push({ + let domain = domain.clone(); + async move { + let result = self + .validate_domains_with_optional_configuration(&domain, Some(did.clone().into()), config) + .await; + (service_id_clone, domain, result) + } + }); + } } - let endpoint_validation_status = service_futures - .try_collect::>() - .await?; - Ok(endpoint_validation_status) + let results = futures::future::join_all(futures).await; + + let mut valid_domains = vec![]; + let mut invalid_domains = vec![]; + + for (service_id, domain, result) in results { + match result { + Ok(status) => { + status.valid.iter().for_each(|valid| { + valid_domains.push(ValidDomain { + service_id: service_id.to_string(), + url: domain.to_string(), + credential: valid.credential.clone(), + }); + }); + status.invalid.iter().for_each(|invalid| { + invalid_domains.push(InvalidDomain { + service_id: service_id.to_string(), + credential: invalid.credential.clone(), + url: domain.to_string(), + error: invalid.error.clone(), + }); + }); + } + Err(err) => { + invalid_domains.push(InvalidDomain { + service_id: service_id.to_string(), + credential: None, + url: domain.to_string(), + error: err.to_string(), + }); + } + } + } + Ok(Domains { + valid: valid_domains, + invalid: invalid_domains, + }) } /// Validates domain linkage for given origin. @@ -186,10 +217,10 @@ impl DomainLinkageService { /// origin async fn validate_domains_with_optional_configuration( &self, - domain: Url, + domain: &Url, did: Option, config: Option, - ) -> Result, DomainLinkageError> { + ) -> Result { // get domain linkage config let domain_linkage_configuration: DomainLinkageConfiguration = if let Some(config_value) = config { config_value @@ -197,14 +228,15 @@ impl DomainLinkageService { match DomainLinkageConfiguration::fetch_configuration(domain.clone()).await { Ok(value) => value, Err(err) => { - return Ok(vec![get_validation_failed_status( + return Ok(get_linked_did_validation_failed_status( "could not get domain linkage config", &err, - )]); + )); } } }; + // get issuers of `linked_dids` credentials // get issuers of `linked_dids` credentials let linked_dids: Vec = if let Some(issuer_did) = did { vec![issuer_did] @@ -212,10 +244,10 @@ impl DomainLinkageService { match domain_linkage_configuration.issuers() { Ok(value) => value, Err(err) => { - return Ok(vec![get_validation_failed_status( + return Ok(get_linked_did_validation_failed_status( "could not get issuers from domain linkage config credential", &err, - )]); + )); } } }; @@ -224,40 +256,49 @@ impl DomainLinkageService { let resolved = match self.resolver.resolve_multiple(&linked_dids).await { Ok(value) => value, Err(err) => { - return Ok(vec![get_validation_failed_status( + return Ok(get_linked_did_validation_failed_status( "could not resolve linked DIDs from domain linkage config", &err, - )]); + )); } }; + let mut valid_dids = vec![]; + let mut invalid_dids = vec![]; + // check linked DIDs separately - let errors: Vec> = resolved - .values() - .map(|issuer_did_doc| { - JwtDomainLinkageValidator::with_signature_verifier(EdDSAJwsVerifier::default()) + domain_linkage_configuration + .linked_dids() + .iter() + .zip(resolved.values()) + .for_each(|(credential, issuer_did_doc)| { + if let Err(err) = JwtDomainLinkageValidator::with_signature_verifier(EdDSAJwsVerifier::default()) .validate_linkage( &issuer_did_doc, &domain_linkage_configuration, - &domain.clone(), + &domain, &JwtCredentialValidationOptions::default(), ) - .err() - .map(|err| err.to_string()) - }) - .collect(); + { + invalid_dids.push(InvalidDid { + service_id: None, + credential: Some(credential.as_str().to_string()), + did: Some(issuer_did_doc.to_string()), + error: err.to_string(), + }); + } else { + valid_dids.push(ValidDid { + service_id: "None".into(), + did: issuer_did_doc.to_string(), + credential: credential.as_str().to_string(), + }); + } + }); - // collect resolved documents and their validation status into array following the order of `linked_dids` - let status_infos = domain_linkage_configuration - .linked_dids() - .iter() - .zip(errors.iter()) - .map(|(credential, error)| LinkedDidValidationStatus { - valid: error.is_none(), - document: Some(credential.as_str().to_string()), - error: error.clone(), - }) - .collect(); + let status_infos = LinkedDid { + valid: valid_dids, + invalid: invalid_dids, + }; Ok(status_infos) } @@ -282,12 +323,13 @@ impl DomainLinkage for DomainLinkageService { Url::parse(&request_data.domain).map_err(|err| DomainLinkageError::DomainParsing(err.to_string()))?; // get validation status for all issuer dids - let status_infos = self - .validate_domains_with_optional_configuration(domain, None, None) + let linked_dids = self + .validate_domains_with_optional_configuration(&domain, None, None) .await?; Ok(Response::new(ValidateDomainResponse { - linked_dids: status_infos, + domain: domain.to_string(), + linked_dids: Some(linked_dids), })) } @@ -306,18 +348,20 @@ impl DomainLinkage for DomainLinkageService { // parse given domain let domain: Url = Url::parse(&request_data.domain).map_err(|err| DomainLinkageError::DomainParsing(err.to_string()))?; + // parse config let config = DomainLinkageConfiguration::from_json(&request_data.did_configuration.to_string()).map_err(|err| { DomainLinkageError::DidConfigurationParsing(format!("could not parse given DID configuration; {}", &err)) })?; // get validation status for all issuer dids - let status_infos = self - .validate_domains_with_optional_configuration(domain, None, Some(config)) + let linked_dids = self + .validate_domains_with_optional_configuration(&domain, None, Some(config)) .await?; Ok(Response::new(ValidateDomainResponse { - linked_dids: status_infos, + domain: request_data.domain.clone(), + linked_dids: Some(linked_dids), })) } @@ -332,10 +376,11 @@ impl DomainLinkage for DomainLinkageService { // fetch DID document for given DID let did: IotaDID = IotaDID::parse(req.into_inner().did).map_err(|e| Status::internal(e.to_string()))?; - let endpoint_validation_status = self.validate_did_with_optional_configurations(&did, None).await?; + let domains = self.validate_did_with_optional_configurations(&did, None).await?; let response = ValidateDidResponse { - service: endpoint_validation_status, + did: did.to_string(), + domains: Some(domains), }; Ok(Response::new(response)) @@ -360,12 +405,13 @@ impl DomainLinkage for DomainLinkageService { .map(DomainValidationConfig::try_parse) .collect::, DomainLinkageError>>()?; - let endpoint_validation_status = self + let domains = self .validate_did_with_optional_configurations(&did, Some(did_configurations)) .await?; let response = ValidateDidResponse { - service: endpoint_validation_status, + did: did.to_string(), + domains: Some(domains), }; Ok(Response::new(response)) diff --git a/bindings/grpc/tests/api/main.rs b/bindings/grpc/tests/api/main.rs index af4929bfae..9955c0be3c 100644 --- a/bindings/grpc/tests/api/main.rs +++ b/bindings/grpc/tests/api/main.rs @@ -4,7 +4,7 @@ mod credential_revocation_check; mod credential_validation; mod did_document_creation; -mod domain_linkage; +// mod domain_linkage; mod health_check; mod helpers; mod jwt; diff --git a/bindings/grpc/tooling/domain-linkage-test-server/.well-known/did-configuration.json b/bindings/grpc/tooling/domain-linkage-test-server/.well-known/did-configuration.json index 802f453e3e..cabff8ee30 100644 --- a/bindings/grpc/tooling/domain-linkage-test-server/.well-known/did-configuration.json +++ b/bindings/grpc/tooling/domain-linkage-test-server/.well-known/did-configuration.json @@ -1,6 +1,6 @@ { "@context": "https://identity.foundation/.well-known/did-configuration/v1", "linked_dids": [ - "add your domain linkage credential here" + "eyJraWQiOiJkaWQ6aW90YTpzbmQ6MHg3NGZlYTM0MTdhMGEwNGI1MzkxNDk3NTBhNDQyZDIwNTFlZmY3MDE2ZDM4YTFmM2YxYTFjMWNkN2M0MGU2ZmNkI3ZXb1h3OGZWTFJteC04N3N2a0pMWTZod1RuZVFDSTNSaFhkTnd4TzVDSkkiLCJ0eXAiOiJKV1QiLCJhbGciOiJFZERTQSJ9.eyJleHAiOjE3NTAyMzQwMjYsImlzcyI6ImRpZDppb3RhOnNuZDoweDc0ZmVhMzQxN2EwYTA0YjUzOTE0OTc1MGE0NDJkMjA1MWVmZjcwMTZkMzhhMWYzZjFhMWMxY2Q3YzQwZTZmY2QiLCJuYmYiOjE3MTg2OTgwMjYsInN1YiI6ImRpZDppb3RhOnNuZDoweDc0ZmVhMzQxN2EwYTA0YjUzOTE0OTc1MGE0NDJkMjA1MWVmZjcwMTZkMzhhMWYzZjFhMWMxY2Q3YzQwZTZmY2QiLCJ2YyI6eyJAY29udGV4dCI6WyJodHRwczovL3d3dy53My5vcmcvMjAxOC9jcmVkZW50aWFscy92MSIsImh0dHBzOi8vaWRlbnRpdHkuZm91bmRhdGlvbi8ud2VsbC1rbm93bi9kaWQtY29uZmlndXJhdGlvbi92MSJdLCJ0eXBlIjpbIlZlcmlmaWFibGVDcmVkZW50aWFsIiwiRG9tYWluTGlua2FnZUNyZWRlbnRpYWwiXSwiY3JlZGVudGlhbFN1YmplY3QiOnsib3JpZ2luIjoiaHR0cHM6Ly9hYTI2LTJjMGYtMmE4MC0xMGVlLTM5MTAtYjhkYS1mMjcwLTRlMDctNDY2NS5uZ3Jvay1mcmVlLmFwcC8ifX19.h3Rwomay8_8fpXexV7Mq8smvcQ8QwJTlHIN_fmq5We_4lAzVNJYzOTkPT__FHywIAnkeXktTVOTAwjX4Y-o3Dw" ] } \ No newline at end of file diff --git a/bindings/grpc/tooling/start-rpc-server.sh b/bindings/grpc/tooling/start-rpc-server.sh index 69c207f6cf..2394f18d9f 100755 --- a/bindings/grpc/tooling/start-rpc-server.sh +++ b/bindings/grpc/tooling/start-rpc-server.sh @@ -1,7 +1,7 @@ #!/bin/sh cd .. -API_ENDPOINT=replace_me \ -STRONGHOLD_PWD=replace_me \ -SNAPSHOT_PATH=replace_me \ +API_ENDPOINT="http://localhost" \ +STRONGHOLD_PWD="secure_password" \ +SNAPSHOT_PATH="/var/folders/j1/0sqjj6g12tzg3g7gsrqjmdxh0000gn/T/test_strongholds/fzb8vO38BeexyNMajzOsmtvvWd6ADL3s.stronghold" \ cargo +nightly run --release diff --git a/examples/1_advanced/6_domain_linkage.rs b/examples/1_advanced/6_domain_linkage.rs index 6e7a629110..da1ec172d5 100644 --- a/examples/1_advanced/6_domain_linkage.rs +++ b/examples/1_advanced/6_domain_linkage.rs @@ -49,12 +49,14 @@ async fn main() -> anyhow::Result<()> { .with_primary_node(API_ENDPOINT, None)? .finish() .await?; + let stronghold_path = random_stronghold_path(); + println!("Using stronghold path: {stronghold_path:?}"); // Create a new secret manager backed by a Stronghold. let mut secret_manager: SecretManager = SecretManager::Stronghold( StrongholdSecretManager::builder() .password(Password::from("secure_password".to_owned())) - .build(random_stronghold_path())?, + .build(stronghold_path)?, ); // Create a DID for the entity that will issue the Domain Linkage Credential. @@ -68,8 +70,8 @@ async fn main() -> anyhow::Result<()> { // ===================================================== // The DID should be linked to the following domains. - let domain_1: Url = Url::parse("https://foo.example.com")?; - let domain_2: Url = Url::parse("https://bar.example.com")?; + let domain_1: Url = Url::parse("https://aa26-2c0f-2a80-10ee-3910-b8da-f270-4e07-4665.ngrok-free.app")?; + let domain_2: Url = Url::parse("https://foo.example.com")?; let mut domains: OrderedSet = OrderedSet::new(); domains.append(domain_1.clone()); From 9930bc097c5e6f470a39ca4d3b62435fd0207bcd Mon Sep 17 00:00:00 2001 From: Yasir Date: Wed, 19 Jun 2024 10:43:58 +0300 Subject: [PATCH 2/8] chore(tests): fix tests --- bindings/grpc/src/services/domain_linkage.rs | 18 +-- bindings/grpc/tests/api/domain_linkage.rs | 110 ++++++++++--------- bindings/grpc/tests/api/main.rs | 2 +- 3 files changed, 70 insertions(+), 60 deletions(-) diff --git a/bindings/grpc/src/services/domain_linkage.rs b/bindings/grpc/src/services/domain_linkage.rs index 1b9e6dfb0b..1704236e8a 100644 --- a/bindings/grpc/src/services/domain_linkage.rs +++ b/bindings/grpc/src/services/domain_linkage.rs @@ -14,16 +14,15 @@ use domain_linkage::{InvalidDid, ValidateDidAgainstDidConfigurationsRequest}; use domain_linkage::{InvalidDomain, ValidateDomainAgainstDidConfigurationRequest}; use domain_linkage::{ValidDid, ValidateDidRequest}; use domain_linkage::{ValidDomain, ValidateDidResponse}; -use futures::stream::FuturesOrdered; -use futures::{StreamExt, TryStreamExt}; + use identity_eddsa_verifier::EdDSAJwsVerifier; -use identity_iota::core::FromJson; use identity_iota::core::Url; +use identity_iota::core::{FromJson, ToJson}; use identity_iota::credential::DomainLinkageConfiguration; use identity_iota::credential::JwtCredentialValidationOptions; use identity_iota::credential::JwtDomainLinkageValidator; use identity_iota::credential::LinkedDomainService; -use identity_iota::did::CoreDID; +use identity_iota::did::{CoreDID, DID}; use identity_iota::iota::IotaDID; use identity_iota::iota::IotaDocument; use identity_iota::resolver::Resolver; @@ -150,7 +149,7 @@ impl DomainLinkageService { let mut futures = vec![]; for service in services { - let service_id: CoreDID = did.clone().into(); + let service_id = service.id().to_string(); let domains: Vec = service.domains().into(); for domain in domains { let config = config_map.get(&domain.origin()).cloned(); @@ -161,6 +160,7 @@ impl DomainLinkageService { let result = self .validate_domains_with_optional_configuration(&domain, Some(did.clone().into()), config) .await; + (service_id_clone, domain, result) } }); @@ -201,6 +201,7 @@ impl DomainLinkageService { } } } + Ok(Domains { valid: valid_domains, invalid: invalid_domains, @@ -236,7 +237,6 @@ impl DomainLinkageService { } }; - // get issuers of `linked_dids` credentials // get issuers of `linked_dids` credentials let linked_dids: Vec = if let Some(issuer_did) = did { vec![issuer_did] @@ -272,6 +272,8 @@ impl DomainLinkageService { .iter() .zip(resolved.values()) .for_each(|(credential, issuer_did_doc)| { + let id = issuer_did_doc.id().to_string(); + if let Err(err) = JwtDomainLinkageValidator::with_signature_verifier(EdDSAJwsVerifier::default()) .validate_linkage( &issuer_did_doc, @@ -281,14 +283,14 @@ impl DomainLinkageService { ) { invalid_dids.push(InvalidDid { - service_id: None, + service_id: Some(id), credential: Some(credential.as_str().to_string()), did: Some(issuer_did_doc.to_string()), error: err.to_string(), }); } else { valid_dids.push(ValidDid { - service_id: "None".into(), + service_id: id, did: issuer_did_doc.to_string(), credential: credential.as_str().to_string(), }); diff --git a/bindings/grpc/tests/api/domain_linkage.rs b/bindings/grpc/tests/api/domain_linkage.rs index a79b732d58..aae5c39aac 100644 --- a/bindings/grpc/tests/api/domain_linkage.rs +++ b/bindings/grpc/tests/api/domain_linkage.rs @@ -1,6 +1,8 @@ // Copyright 2020-2024 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 +use _credentials::validate_domain_response::LinkedDid; +use _credentials::{ValidDid, ValidDomain}; use identity_iota::core::Duration; use identity_iota::core::Object; use identity_iota::core::OrderedSet; @@ -13,13 +15,13 @@ use identity_iota::credential::Jwt; use identity_iota::credential::LinkedDomainService; use identity_iota::did::DIDUrl; use identity_iota::did::DID; +use identity_iota::iota::{IotaDID, IotaDocument}; use identity_storage::JwkDocumentExt; use identity_storage::JwsSignatureOptions; use identity_stronghold::StrongholdStorage; use crate::domain_linkage::_credentials::domain_linkage_client::DomainLinkageClient; -use crate::domain_linkage::_credentials::LinkedDidEndpointValidationStatus; -use crate::domain_linkage::_credentials::LinkedDidValidationStatus; + use crate::domain_linkage::_credentials::ValidateDidAgainstDidConfigurationsRequest; use crate::domain_linkage::_credentials::ValidateDidResponse; use crate::domain_linkage::_credentials::ValidateDomainAgainstDidConfigurationRequest; @@ -42,9 +44,10 @@ async fn prepare_test() -> anyhow::Result<(TestServer, Url, String, Jwt)> { issuer.create_did(api_client).await?; let did = issuer .document() - .ok_or_else(|| anyhow::anyhow!("no DID document for issuer"))? - .id(); + .ok_or_else(|| anyhow::anyhow!("no DID document for issuer"))?; let did_string = did.to_string(); + + let did = did.id().clone(); // ===================================================== // Create Linked Domain service // ===================================================== @@ -106,7 +109,7 @@ async fn prepare_test() -> anyhow::Result<(TestServer, Url, String, Jwt)> { #[tokio::test] async fn can_validate_domain() -> anyhow::Result<()> { - let (server, linked_domain, _, jwt) = prepare_test().await?; + let (server, linked_domain, did, jwt) = prepare_test().await?; let configuration_resource: DomainLinkageConfiguration = DomainLinkageConfiguration::new(vec![jwt.clone()]); let mut grpc_client = DomainLinkageClient::connect(server.endpoint()).await?; @@ -116,59 +119,64 @@ async fn can_validate_domain() -> anyhow::Result<()> { did_configuration: configuration_resource.to_string(), }) .await?; + let did_id = IotaDID::parse(&did)?.to_url().to_string(); assert_eq!( response.into_inner(), ValidateDomainResponse { - linked_dids: vec![LinkedDidValidationStatus { - valid: true, - document: Some(jwt.as_str().to_string()), - error: None, - }], + linked_dids: Some(LinkedDid { + invalid: vec![], + valid: vec![ValidDid { + service_id: did_id, + did: did.to_string().clone(), + credential: jwt.as_str().to_string(), + }] + }), + domain: linked_domain.to_string(), } ); Ok(()) } -#[tokio::test] -async fn can_validate_did() -> anyhow::Result<()> { - let (server, linked_domain, issuer_did, jwt) = prepare_test().await?; - let configuration_resource: DomainLinkageConfiguration = DomainLinkageConfiguration::new(vec![jwt.clone()]); - let mut grpc_client = DomainLinkageClient::connect(server.endpoint()).await?; - - let response = grpc_client - .validate_did_against_did_configurations(ValidateDidAgainstDidConfigurationsRequest { - did: issuer_did.clone(), - did_configurations: vec![ValidateDomainAgainstDidConfigurationRequest { - domain: linked_domain.to_string(), - did_configuration: configuration_resource.to_string(), - }], - }) - .await?; - - assert_eq!( - response.into_inner(), - ValidateDidResponse { - service: vec![ - LinkedDidEndpointValidationStatus { - id: issuer_did, - service_endpoint: vec![ - LinkedDidValidationStatus { - valid: true, - document: Some(jwt.as_str().to_string()), - error: None, - }, - LinkedDidValidationStatus { - valid: false, - document: None, - error: Some("could not get domain linkage config; domain linkage error: error sending request for url (https://bar.example.com/.well-known/did-configuration.json): error trying to connect: dns error: failed to lookup address information: nodename nor servname provided, or not known".to_string()), - } - ], - } - ] - } - ); - - Ok(()) -} +// #[tokio::test] +// async fn can_validate_did() -> anyhow::Result<()> { +// let (server, linked_domain, issuer_did, jwt) = prepare_test().await?; +// let configuration_resource: DomainLinkageConfiguration = DomainLinkageConfiguration::new(vec![jwt.clone()]); +// let mut grpc_client = DomainLinkageClient::connect(server.endpoint()).await?; + +// let response = grpc_client +// .validate_did_against_did_configurations(ValidateDidAgainstDidConfigurationsRequest { +// did: issuer_did.clone(), +// did_configurations: vec![ValidateDomainAgainstDidConfigurationRequest { +// domain: linked_domain.to_string(), +// did_configuration: configuration_resource.to_string(), +// }], +// }) +// .await?; + +// assert_eq!( +// response.into_inner(), +// ValidateDidResponse { +// service: vec![ +// LinkedDidEndpointValidationStatus { +// id: issuer_did, +// service_endpoint: vec![ +// LinkedDidValidationStatus { +// valid: true, +// document: Some(jwt.as_str().to_string()), +// error: None, +// }, +// LinkedDidValidationStatus { +// valid: false, +// document: None, +// error: Some("could not get domain linkage config; domain linkage error: error sending request for url (https://bar.example.com/.well-known/did-configuration.json): error trying to connect: dns error: failed to lookup address information: nodename nor servname provided, or not known".to_string()), +// } +// ], +// } +// ] +// } +// ); + +// Ok(()) +// } diff --git a/bindings/grpc/tests/api/main.rs b/bindings/grpc/tests/api/main.rs index 9955c0be3c..af4929bfae 100644 --- a/bindings/grpc/tests/api/main.rs +++ b/bindings/grpc/tests/api/main.rs @@ -4,7 +4,7 @@ mod credential_revocation_check; mod credential_validation; mod did_document_creation; -// mod domain_linkage; +mod domain_linkage; mod health_check; mod helpers; mod jwt; From 0408eb2fd2f57be614603cdc0c74772767cc664d Mon Sep 17 00:00:00 2001 From: Yasir Date: Wed, 19 Jun 2024 16:56:38 +0300 Subject: [PATCH 3/8] chore(tests): fix tests --- bindings/grpc/proto/domain_linkage.proto | 59 +++++----- bindings/grpc/src/services/domain_linkage.rs | 26 +++-- bindings/grpc/tests/api/domain_linkage.rs | 112 ++++++++++--------- bindings/grpc/tests/api/utils.rs | 6 +- 4 files changed, 110 insertions(+), 93 deletions(-) diff --git a/bindings/grpc/proto/domain_linkage.proto b/bindings/grpc/proto/domain_linkage.proto index 1ff4dcc045..d731af2aa5 100644 --- a/bindings/grpc/proto/domain_linkage.proto +++ b/bindings/grpc/proto/domain_linkage.proto @@ -4,48 +4,51 @@ syntax = "proto3"; package domain_linkage; -message ValidDomain { - string service_id = 1; - string url = 2; - string credential = 3; -} - -message InvalidDomain { - string service_id = 1; - optional string credential = 2; - string url = 3; - string error = 4; -} - message ValidateDidResponse { string did = 1; message Domains { + message ValidDomain { + string url = 1; + string credential = 2; + string service_id = 3; + } + repeated ValidDomain valid = 1; + + message InvalidDomain { + string url = 1; + optional string credential = 2; + string service_id = 3; + string error = 4; + } + repeated InvalidDomain invalid = 2; } Domains domains = 2; } -message ValidDid { - string service_id = 1; - string did = 2; - string credential = 3; -} - -message InvalidDid { - optional string service_id = 1; - optional string credential = 2; - optional string did = 3; - string error = 4; -} - message ValidateDomainResponse { string domain = 1; - message LinkedDid { + message LinkedDids { + + message ValidDid { + string did = 1; + string credential = 2; + string service_id = 3; + } + repeated ValidDid valid = 1; + + message InvalidDid { + optional string did = 1; + optional string credential = 2; + optional string service_id = 3; + string error = 4; + } + repeated InvalidDid invalid = 2; } - LinkedDid linked_dids = 2; + LinkedDids linked_dids = 2; } message ValidateDomainRequest { diff --git a/bindings/grpc/src/services/domain_linkage.rs b/bindings/grpc/src/services/domain_linkage.rs index 1704236e8a..9e02aed4a1 100644 --- a/bindings/grpc/src/services/domain_linkage.rs +++ b/bindings/grpc/src/services/domain_linkage.rs @@ -7,22 +7,25 @@ use std::error::Error; use domain_linkage::domain_linkage_server::DomainLinkage; use domain_linkage::domain_linkage_server::DomainLinkageServer; use domain_linkage::validate_did_response::Domains; -use domain_linkage::validate_domain_response::LinkedDid; + +use crate::services::domain_linkage::domain_linkage::validate_did_response::domains::{InvalidDomain, ValidDomain}; +use crate::services::domain_linkage::domain_linkage::validate_domain_response::linked_dids::{InvalidDid, ValidDid}; +use domain_linkage::validate_domain_response::LinkedDids; +use domain_linkage::ValidateDidAgainstDidConfigurationsRequest; +use domain_linkage::ValidateDidRequest; +use domain_linkage::ValidateDidResponse; +use domain_linkage::ValidateDomainAgainstDidConfigurationRequest; use domain_linkage::ValidateDomainRequest; use domain_linkage::ValidateDomainResponse; -use domain_linkage::{InvalidDid, ValidateDidAgainstDidConfigurationsRequest}; -use domain_linkage::{InvalidDomain, ValidateDomainAgainstDidConfigurationRequest}; -use domain_linkage::{ValidDid, ValidateDidRequest}; -use domain_linkage::{ValidDomain, ValidateDidResponse}; use identity_eddsa_verifier::EdDSAJwsVerifier; +use identity_iota::core::FromJson; use identity_iota::core::Url; -use identity_iota::core::{FromJson, ToJson}; use identity_iota::credential::DomainLinkageConfiguration; use identity_iota::credential::JwtCredentialValidationOptions; use identity_iota::credential::JwtDomainLinkageValidator; use identity_iota::credential::LinkedDomainService; -use identity_iota::did::{CoreDID, DID}; +use identity_iota::did::CoreDID; use identity_iota::iota::IotaDID; use identity_iota::iota::IotaDocument; use identity_iota::resolver::Resolver; @@ -89,8 +92,8 @@ impl DomainValidationConfig { } /// Builds a validation status for a failed validation from an `Error`. -fn get_linked_did_validation_failed_status(message: &str, err: &impl Error) -> LinkedDid { - LinkedDid { +fn get_linked_did_validation_failed_status(message: &str, err: &impl Error) -> LinkedDids { + LinkedDids { valid: vec![], invalid: vec![InvalidDid { service_id: None, @@ -221,7 +224,7 @@ impl DomainLinkageService { domain: &Url, did: Option, config: Option, - ) -> Result { + ) -> Result { // get domain linkage config let domain_linkage_configuration: DomainLinkageConfiguration = if let Some(config_value) = config { config_value @@ -297,7 +300,7 @@ impl DomainLinkageService { } }); - let status_infos = LinkedDid { + let status_infos = LinkedDids { valid: valid_dids, invalid: invalid_dids, }; @@ -356,7 +359,6 @@ impl DomainLinkage for DomainLinkageService { DomainLinkageError::DidConfigurationParsing(format!("could not parse given DID configuration; {}", &err)) })?; - // get validation status for all issuer dids let linked_dids = self .validate_domains_with_optional_configuration(&domain, None, Some(config)) .await?; diff --git a/bindings/grpc/tests/api/domain_linkage.rs b/bindings/grpc/tests/api/domain_linkage.rs index aae5c39aac..7eb512e3f4 100644 --- a/bindings/grpc/tests/api/domain_linkage.rs +++ b/bindings/grpc/tests/api/domain_linkage.rs @@ -1,13 +1,16 @@ // Copyright 2020-2024 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -use _credentials::validate_domain_response::LinkedDid; -use _credentials::{ValidDid, ValidDomain}; -use identity_iota::core::Duration; +use _credentials::validate_did_response::Domains; +use _credentials::validate_domain_response::LinkedDids; + +use crate::domain_linkage::_credentials::validate_did_response::domains::{InvalidDomain, ValidDomain}; +use crate::domain_linkage::_credentials::validate_domain_response::linked_dids::ValidDid; use identity_iota::core::Object; use identity_iota::core::OrderedSet; use identity_iota::core::Timestamp; use identity_iota::core::Url; +use identity_iota::core::{Duration, FromJson}; use identity_iota::credential::Credential; use identity_iota::credential::DomainLinkageConfiguration; use identity_iota::credential::DomainLinkageCredentialBuilder; @@ -15,7 +18,7 @@ use identity_iota::credential::Jwt; use identity_iota::credential::LinkedDomainService; use identity_iota::did::DIDUrl; use identity_iota::did::DID; -use identity_iota::iota::{IotaDID, IotaDocument}; +use identity_iota::iota::IotaDocument; use identity_storage::JwkDocumentExt; use identity_storage::JwsSignatureOptions; use identity_stronghold::StrongholdStorage; @@ -35,7 +38,7 @@ mod _credentials { } /// Prepares basically the same test setup as in test `examples/1_advanced/6_domain_linkage.rs`. -async fn prepare_test() -> anyhow::Result<(TestServer, Url, String, Jwt)> { +async fn prepare_test() -> anyhow::Result<(TestServer, Url, Url, String, Jwt)> { let stronghold = StrongholdStorage::new(make_stronghold()); let server = TestServer::new_with_stronghold(stronghold.clone()).await; let api_client = server.client(); @@ -45,7 +48,6 @@ async fn prepare_test() -> anyhow::Result<(TestServer, Url, String, Jwt)> { let did = issuer .document() .ok_or_else(|| anyhow::anyhow!("no DID document for issuer"))?; - let did_string = did.to_string(); let did = did.id().clone(); // ===================================================== @@ -73,6 +75,8 @@ async fn prepare_test() -> anyhow::Result<(TestServer, Url, String, Jwt)> { .document() .ok_or_else(|| anyhow::anyhow!("no DID document for issuer"))?; + let did_string = updated_did_document.to_string(); + println!("DID document with linked domain service: {updated_did_document:#}"); // ===================================================== @@ -104,12 +108,12 @@ async fn prepare_test() -> anyhow::Result<(TestServer, Url, String, Jwt)> { ) .await?; - Ok((server, domain_1, did_string, jwt)) + Ok((server, domain_1, domain_2, did_string, jwt)) } #[tokio::test] async fn can_validate_domain() -> anyhow::Result<()> { - let (server, linked_domain, did, jwt) = prepare_test().await?; + let (server, linked_domain, _, did, jwt) = prepare_test().await?; let configuration_resource: DomainLinkageConfiguration = DomainLinkageConfiguration::new(vec![jwt.clone()]); let mut grpc_client = DomainLinkageClient::connect(server.endpoint()).await?; @@ -119,12 +123,12 @@ async fn can_validate_domain() -> anyhow::Result<()> { did_configuration: configuration_resource.to_string(), }) .await?; - let did_id = IotaDID::parse(&did)?.to_url().to_string(); + let did_id = IotaDocument::from_json(&did)?.id().to_string(); assert_eq!( response.into_inner(), ValidateDomainResponse { - linked_dids: Some(LinkedDid { + linked_dids: Some(LinkedDids { invalid: vec![], valid: vec![ValidDid { service_id: did_id, @@ -139,44 +143,50 @@ async fn can_validate_domain() -> anyhow::Result<()> { Ok(()) } -// #[tokio::test] -// async fn can_validate_did() -> anyhow::Result<()> { -// let (server, linked_domain, issuer_did, jwt) = prepare_test().await?; -// let configuration_resource: DomainLinkageConfiguration = DomainLinkageConfiguration::new(vec![jwt.clone()]); -// let mut grpc_client = DomainLinkageClient::connect(server.endpoint()).await?; - -// let response = grpc_client -// .validate_did_against_did_configurations(ValidateDidAgainstDidConfigurationsRequest { -// did: issuer_did.clone(), -// did_configurations: vec![ValidateDomainAgainstDidConfigurationRequest { -// domain: linked_domain.to_string(), -// did_configuration: configuration_resource.to_string(), -// }], -// }) -// .await?; - -// assert_eq!( -// response.into_inner(), -// ValidateDidResponse { -// service: vec![ -// LinkedDidEndpointValidationStatus { -// id: issuer_did, -// service_endpoint: vec![ -// LinkedDidValidationStatus { -// valid: true, -// document: Some(jwt.as_str().to_string()), -// error: None, -// }, -// LinkedDidValidationStatus { -// valid: false, -// document: None, -// error: Some("could not get domain linkage config; domain linkage error: error sending request for url (https://bar.example.com/.well-known/did-configuration.json): error trying to connect: dns error: failed to lookup address information: nodename nor servname provided, or not known".to_string()), -// } -// ], -// } -// ] -// } -// ); - -// Ok(()) -// } +#[tokio::test] +async fn can_validate_did() -> anyhow::Result<()> { + let (server, linked_domain, domain2, issuer_did, jwt) = prepare_test().await?; + let configuration_resource: DomainLinkageConfiguration = DomainLinkageConfiguration::new(vec![jwt.clone()]); + let mut grpc_client = DomainLinkageClient::connect(server.endpoint()).await?; + let did_id = IotaDocument::from_json(&issuer_did)?.id().to_string(); + + let response = grpc_client + .validate_did_against_did_configurations(ValidateDidAgainstDidConfigurationsRequest { + did: did_id.clone(), + did_configurations: vec![ValidateDomainAgainstDidConfigurationRequest { + domain: linked_domain.to_string(), + did_configuration: configuration_resource.to_string(), + }], + }) + .await?; + + let service_id = format!("{}#domain-linkage", did_id); + + let valid_domain = ValidDomain { + service_id: service_id.clone(), + url: linked_domain.to_string(), + credential: jwt.as_str().to_string(), + }; + + let error = format!("could not get domain linkage config: domain linkage error: error sending request for url ({}.well-known/did-configuration.json): error trying to connect: dns error: failed to lookup address information: nodename nor servname provided, or not known", domain2.to_string()); + + let invalid_domain = InvalidDomain { + service_id: service_id.clone(), + credential: None, + url: domain2.to_string(), + error, + }; + + assert_eq!( + response.into_inner(), + ValidateDidResponse { + did: did_id, + domains: Some(Domains { + invalid: vec![invalid_domain], + valid: vec![valid_domain], + }), + } + ); + + Ok(()) +} diff --git a/bindings/grpc/tests/api/utils.rs b/bindings/grpc/tests/api/utils.rs index 9c863bf3de..72e1ebdb72 100644 --- a/bindings/grpc/tests/api/utils.rs +++ b/bindings/grpc/tests/api/utils.rs @@ -6,7 +6,7 @@ use _utils::DataSigningRequest; use identity_iota::verification::jws::JwsAlgorithm; use identity_storage::JwkStorage; use identity_storage::KeyType; -use identity_stronghold::StrongholdStorage; +use identity_stronghold::{StrongholdKeyType, StrongholdStorage}; use crate::helpers::make_stronghold; use crate::helpers::TestServer; @@ -28,7 +28,9 @@ async fn raw_data_signing_works() -> anyhow::Result<()> { .key_id; let expected_signature = { - let public_key_jwk = stronghold.get_public_key(&key_id).await?; + let public_key_jwk = stronghold + .get_public_key_with_type(&key_id, StrongholdKeyType::Ed25519) + .await?; stronghold.sign(&key_id, SAMPLE_SIGNING_DATA, &public_key_jwk).await? }; From 5715f4d540160cd38d0d60f7ac04c43413691eaf Mon Sep 17 00:00:00 2001 From: Yasir Date: Wed, 19 Jun 2024 17:03:00 +0300 Subject: [PATCH 4/8] chore: cargo fmt; add the fmt toml file --- bindings/grpc/rustfmt.toml | 8 ++++++++ bindings/grpc/src/services/domain_linkage.rs | 6 ++++-- bindings/grpc/tests/api/domain_linkage.rs | 6 ++++-- bindings/grpc/tests/api/utils.rs | 3 ++- 4 files changed, 18 insertions(+), 5 deletions(-) create mode 100644 bindings/grpc/rustfmt.toml diff --git a/bindings/grpc/rustfmt.toml b/bindings/grpc/rustfmt.toml new file mode 100644 index 0000000000..c0842c2114 --- /dev/null +++ b/bindings/grpc/rustfmt.toml @@ -0,0 +1,8 @@ +comment_width = 120 +format_code_in_doc_comments = true +max_width = 120 +normalize_comments = false +normalize_doc_attributes = false +tab_spaces = 2 +wrap_comments = true +imports_granularity = "Item" diff --git a/bindings/grpc/src/services/domain_linkage.rs b/bindings/grpc/src/services/domain_linkage.rs index 9e02aed4a1..cd1ec34356 100644 --- a/bindings/grpc/src/services/domain_linkage.rs +++ b/bindings/grpc/src/services/domain_linkage.rs @@ -8,8 +8,10 @@ use domain_linkage::domain_linkage_server::DomainLinkage; use domain_linkage::domain_linkage_server::DomainLinkageServer; use domain_linkage::validate_did_response::Domains; -use crate::services::domain_linkage::domain_linkage::validate_did_response::domains::{InvalidDomain, ValidDomain}; -use crate::services::domain_linkage::domain_linkage::validate_domain_response::linked_dids::{InvalidDid, ValidDid}; +use crate::services::domain_linkage::domain_linkage::validate_did_response::domains::InvalidDomain; +use crate::services::domain_linkage::domain_linkage::validate_did_response::domains::ValidDomain; +use crate::services::domain_linkage::domain_linkage::validate_domain_response::linked_dids::InvalidDid; +use crate::services::domain_linkage::domain_linkage::validate_domain_response::linked_dids::ValidDid; use domain_linkage::validate_domain_response::LinkedDids; use domain_linkage::ValidateDidAgainstDidConfigurationsRequest; use domain_linkage::ValidateDidRequest; diff --git a/bindings/grpc/tests/api/domain_linkage.rs b/bindings/grpc/tests/api/domain_linkage.rs index 7eb512e3f4..4870c74a8d 100644 --- a/bindings/grpc/tests/api/domain_linkage.rs +++ b/bindings/grpc/tests/api/domain_linkage.rs @@ -4,13 +4,15 @@ use _credentials::validate_did_response::Domains; use _credentials::validate_domain_response::LinkedDids; -use crate::domain_linkage::_credentials::validate_did_response::domains::{InvalidDomain, ValidDomain}; +use crate::domain_linkage::_credentials::validate_did_response::domains::InvalidDomain; +use crate::domain_linkage::_credentials::validate_did_response::domains::ValidDomain; use crate::domain_linkage::_credentials::validate_domain_response::linked_dids::ValidDid; +use identity_iota::core::Duration; +use identity_iota::core::FromJson; use identity_iota::core::Object; use identity_iota::core::OrderedSet; use identity_iota::core::Timestamp; use identity_iota::core::Url; -use identity_iota::core::{Duration, FromJson}; use identity_iota::credential::Credential; use identity_iota::credential::DomainLinkageConfiguration; use identity_iota::credential::DomainLinkageCredentialBuilder; diff --git a/bindings/grpc/tests/api/utils.rs b/bindings/grpc/tests/api/utils.rs index 72e1ebdb72..9b320bd154 100644 --- a/bindings/grpc/tests/api/utils.rs +++ b/bindings/grpc/tests/api/utils.rs @@ -6,7 +6,8 @@ use _utils::DataSigningRequest; use identity_iota::verification::jws::JwsAlgorithm; use identity_storage::JwkStorage; use identity_storage::KeyType; -use identity_stronghold::{StrongholdKeyType, StrongholdStorage}; +use identity_stronghold::StrongholdKeyType; +use identity_stronghold::StrongholdStorage; use crate::helpers::make_stronghold; use crate::helpers::TestServer; From 728bdba84db0dd83bac137ab878bca4b6dc4087d Mon Sep 17 00:00:00 2001 From: Yasir Date: Wed, 19 Jun 2024 17:05:43 +0300 Subject: [PATCH 5/8] chore: undo tooling files --- .../.well-known/did-configuration.json | 4 +--- bindings/grpc/tooling/start-rpc-server.sh | 6 +++--- examples/1_advanced/6_domain_linkage.rs | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/bindings/grpc/tooling/domain-linkage-test-server/.well-known/did-configuration.json b/bindings/grpc/tooling/domain-linkage-test-server/.well-known/did-configuration.json index cabff8ee30..912bce8548 100644 --- a/bindings/grpc/tooling/domain-linkage-test-server/.well-known/did-configuration.json +++ b/bindings/grpc/tooling/domain-linkage-test-server/.well-known/did-configuration.json @@ -1,6 +1,4 @@ { "@context": "https://identity.foundation/.well-known/did-configuration/v1", - "linked_dids": [ - "eyJraWQiOiJkaWQ6aW90YTpzbmQ6MHg3NGZlYTM0MTdhMGEwNGI1MzkxNDk3NTBhNDQyZDIwNTFlZmY3MDE2ZDM4YTFmM2YxYTFjMWNkN2M0MGU2ZmNkI3ZXb1h3OGZWTFJteC04N3N2a0pMWTZod1RuZVFDSTNSaFhkTnd4TzVDSkkiLCJ0eXAiOiJKV1QiLCJhbGciOiJFZERTQSJ9.eyJleHAiOjE3NTAyMzQwMjYsImlzcyI6ImRpZDppb3RhOnNuZDoweDc0ZmVhMzQxN2EwYTA0YjUzOTE0OTc1MGE0NDJkMjA1MWVmZjcwMTZkMzhhMWYzZjFhMWMxY2Q3YzQwZTZmY2QiLCJuYmYiOjE3MTg2OTgwMjYsInN1YiI6ImRpZDppb3RhOnNuZDoweDc0ZmVhMzQxN2EwYTA0YjUzOTE0OTc1MGE0NDJkMjA1MWVmZjcwMTZkMzhhMWYzZjFhMWMxY2Q3YzQwZTZmY2QiLCJ2YyI6eyJAY29udGV4dCI6WyJodHRwczovL3d3dy53My5vcmcvMjAxOC9jcmVkZW50aWFscy92MSIsImh0dHBzOi8vaWRlbnRpdHkuZm91bmRhdGlvbi8ud2VsbC1rbm93bi9kaWQtY29uZmlndXJhdGlvbi92MSJdLCJ0eXBlIjpbIlZlcmlmaWFibGVDcmVkZW50aWFsIiwiRG9tYWluTGlua2FnZUNyZWRlbnRpYWwiXSwiY3JlZGVudGlhbFN1YmplY3QiOnsib3JpZ2luIjoiaHR0cHM6Ly9hYTI2LTJjMGYtMmE4MC0xMGVlLTM5MTAtYjhkYS1mMjcwLTRlMDctNDY2NS5uZ3Jvay1mcmVlLmFwcC8ifX19.h3Rwomay8_8fpXexV7Mq8smvcQ8QwJTlHIN_fmq5We_4lAzVNJYzOTkPT__FHywIAnkeXktTVOTAwjX4Y-o3Dw" - ] + "linked_dids": [] } \ No newline at end of file diff --git a/bindings/grpc/tooling/start-rpc-server.sh b/bindings/grpc/tooling/start-rpc-server.sh index 2394f18d9f..69c207f6cf 100755 --- a/bindings/grpc/tooling/start-rpc-server.sh +++ b/bindings/grpc/tooling/start-rpc-server.sh @@ -1,7 +1,7 @@ #!/bin/sh cd .. -API_ENDPOINT="http://localhost" \ -STRONGHOLD_PWD="secure_password" \ -SNAPSHOT_PATH="/var/folders/j1/0sqjj6g12tzg3g7gsrqjmdxh0000gn/T/test_strongholds/fzb8vO38BeexyNMajzOsmtvvWd6ADL3s.stronghold" \ +API_ENDPOINT=replace_me \ +STRONGHOLD_PWD=replace_me \ +SNAPSHOT_PATH=replace_me \ cargo +nightly run --release diff --git a/examples/1_advanced/6_domain_linkage.rs b/examples/1_advanced/6_domain_linkage.rs index da1ec172d5..2a67d26e5f 100644 --- a/examples/1_advanced/6_domain_linkage.rs +++ b/examples/1_advanced/6_domain_linkage.rs @@ -70,7 +70,7 @@ async fn main() -> anyhow::Result<()> { // ===================================================== // The DID should be linked to the following domains. - let domain_1: Url = Url::parse("https://aa26-2c0f-2a80-10ee-3910-b8da-f270-4e07-4665.ngrok-free.app")?; + let domain_1: Url = Url::parse("https://foo.example.com")?; let domain_2: Url = Url::parse("https://foo.example.com")?; let mut domains: OrderedSet = OrderedSet::new(); From b50ab9a2eaabbeec8d42dbcc76ad0a3f5493c276 Mon Sep 17 00:00:00 2001 From: Yasir Date: Wed, 19 Jun 2024 17:06:27 +0300 Subject: [PATCH 6/8] chore: undo tooling files --- .../.well-known/did-configuration.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bindings/grpc/tooling/domain-linkage-test-server/.well-known/did-configuration.json b/bindings/grpc/tooling/domain-linkage-test-server/.well-known/did-configuration.json index 912bce8548..579b9ee575 100644 --- a/bindings/grpc/tooling/domain-linkage-test-server/.well-known/did-configuration.json +++ b/bindings/grpc/tooling/domain-linkage-test-server/.well-known/did-configuration.json @@ -1,4 +1,6 @@ { "@context": "https://identity.foundation/.well-known/did-configuration/v1", - "linked_dids": [] -} \ No newline at end of file + "linked_dids": [ + "add your domain linkage credential here" + ] +} From 6140606e04aaf494178120dfe6cf4a3ed2751f4f Mon Sep 17 00:00:00 2001 From: Yasir Date: Thu, 20 Jun 2024 12:31:59 +0300 Subject: [PATCH 7/8] chore: address comments --- bindings/grpc/proto/domain_linkage.proto | 1 - bindings/grpc/src/services/domain_linkage.rs | 32 +++++++++----------- examples/1_advanced/6_domain_linkage.rs | 2 +- 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/bindings/grpc/proto/domain_linkage.proto b/bindings/grpc/proto/domain_linkage.proto index d731af2aa5..5edee5e18a 100644 --- a/bindings/grpc/proto/domain_linkage.proto +++ b/bindings/grpc/proto/domain_linkage.proto @@ -30,7 +30,6 @@ message ValidateDidResponse { message ValidateDomainResponse { string domain = 1; message LinkedDids { - message ValidDid { string did = 1; string credential = 2; diff --git a/bindings/grpc/src/services/domain_linkage.rs b/bindings/grpc/src/services/domain_linkage.rs index cd1ec34356..90f5837e51 100644 --- a/bindings/grpc/src/services/domain_linkage.rs +++ b/bindings/grpc/src/services/domain_linkage.rs @@ -4,22 +4,20 @@ use std::collections::HashMap; use std::error::Error; -use domain_linkage::domain_linkage_server::DomainLinkage; -use domain_linkage::domain_linkage_server::DomainLinkageServer; -use domain_linkage::validate_did_response::Domains; - -use crate::services::domain_linkage::domain_linkage::validate_did_response::domains::InvalidDomain; -use crate::services::domain_linkage::domain_linkage::validate_did_response::domains::ValidDomain; -use crate::services::domain_linkage::domain_linkage::validate_domain_response::linked_dids::InvalidDid; -use crate::services::domain_linkage::domain_linkage::validate_domain_response::linked_dids::ValidDid; -use domain_linkage::validate_domain_response::LinkedDids; -use domain_linkage::ValidateDidAgainstDidConfigurationsRequest; -use domain_linkage::ValidateDidRequest; -use domain_linkage::ValidateDidResponse; -use domain_linkage::ValidateDomainAgainstDidConfigurationRequest; -use domain_linkage::ValidateDomainRequest; -use domain_linkage::ValidateDomainResponse; - +use _domain_linkage::domain_linkage_server::DomainLinkage; +use _domain_linkage::domain_linkage_server::DomainLinkageServer; +use _domain_linkage::validate_did_response::domains::InvalidDomain; +use _domain_linkage::validate_did_response::domains::ValidDomain; +use _domain_linkage::validate_did_response::Domains; +use _domain_linkage::validate_domain_response::linked_dids::InvalidDid; +use _domain_linkage::validate_domain_response::linked_dids::ValidDid; +use _domain_linkage::validate_domain_response::LinkedDids; +use _domain_linkage::ValidateDidAgainstDidConfigurationsRequest; +use _domain_linkage::ValidateDidRequest; +use _domain_linkage::ValidateDidResponse; +use _domain_linkage::ValidateDomainAgainstDidConfigurationRequest; +use _domain_linkage::ValidateDomainRequest; +use _domain_linkage::ValidateDomainResponse; use identity_eddsa_verifier::EdDSAJwsVerifier; use identity_iota::core::FromJson; use identity_iota::core::Url; @@ -41,7 +39,7 @@ use tonic::Status; use url::Origin; #[allow(clippy::module_inception)] -mod domain_linkage { +mod _domain_linkage { tonic::include_proto!("domain_linkage"); } diff --git a/examples/1_advanced/6_domain_linkage.rs b/examples/1_advanced/6_domain_linkage.rs index 2a67d26e5f..03d0472a37 100644 --- a/examples/1_advanced/6_domain_linkage.rs +++ b/examples/1_advanced/6_domain_linkage.rs @@ -71,7 +71,7 @@ async fn main() -> anyhow::Result<()> { // The DID should be linked to the following domains. let domain_1: Url = Url::parse("https://foo.example.com")?; - let domain_2: Url = Url::parse("https://foo.example.com")?; + let domain_2: Url = Url::parse("https://bar.example.com")?; let mut domains: OrderedSet = OrderedSet::new(); domains.append(domain_1.clone()); From 94ae3824b1c91d703c5bdf1819e780d9465904fa Mon Sep 17 00:00:00 2001 From: Yasir Date: Thu, 20 Jun 2024 15:01:27 +0300 Subject: [PATCH 8/8] chore: remove clippy warning --- bindings/grpc/src/services/domain_linkage.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/bindings/grpc/src/services/domain_linkage.rs b/bindings/grpc/src/services/domain_linkage.rs index 90f5837e51..bb8b214982 100644 --- a/bindings/grpc/src/services/domain_linkage.rs +++ b/bindings/grpc/src/services/domain_linkage.rs @@ -38,7 +38,6 @@ use tonic::Response; use tonic::Status; use url::Origin; -#[allow(clippy::module_inception)] mod _domain_linkage { tonic::include_proto!("domain_linkage"); }